示例#1
0
// ********************* LOW-LEVEL ISSP SUBROUTINE SECTION ********************
// ****************************************************************************
// ****                        PROCESSOR SPECIFIC                          ****
// ****************************************************************************
// ****                      USER ATTENTION REQUIRED                       ****
// ****************************************************************************
// AssertXRES()
// Set XRES pin High
// ****************************************************************************
void AssertXRES(void)
{
#if 0
	gpio_tlmm_config(EXT_TSP_RST);
	gpio_out(EXT_TSP_RST, GPIO_HIGH_VALUE);
	clk_busy_wait(1000);
	clk_busy_wait(1000);
	clk_busy_wait(1000);
#endif
}
示例#2
0
static int  adp5588_read_register(struct i2c_client *client,uint8_t address , uint8_t *value )
{
    uint8_t data[1];
    int	rc;

    I2C_MUTEX_LOCK;

    data[0] = address;  //reg 0
    if ((rc = i2c_master_send(client, data, 1)) < 0)
    {
        dev_err(&client->dev," %s(%s):i2c_master_send error %d\n",
                __FILE__, __FUNCTION__, rc);
        I2C_MUTEX_UNLOCK;
        return rc;
    }

    clk_busy_wait(1000);

    *value=0;
    if ((rc = i2c_master_recv(client, value,1 )) < 0 )
        dev_err(&client->dev," %s(%s):i2c_master_recv error %d\n",
                __FILE__, __FUNCTION__, rc);
    I2C_MUTEX_UNLOCK;
    return(rc);
}
// ********************* LOW-LEVEL ISSP SUBROUTINE SECTION ********************
// ****************************************************************************
// ****                        PROCESSOR SPECIFIC                          ****
// ****************************************************************************
// ****                      USER ATTENTION REQUIRED                       ****
// ****************************************************************************
// ApplyTargetVDD()
// Provide power to the target PSoC's Vdd pin through a GPIO.
// ****************************************************************************
void ApplyTargetVDD(void)
{
    #if 0
    gpio_tlmm_config(LED_26V_EN);
    gpio_tlmm_config(EXT_TSP_SCL);
    gpio_tlmm_config(EXT_TSP_SDA);
    gpio_tlmm_config(LED_RST);

    gpio_out(LED_RST, GPIO_LOW_VALUE);
    
    clk_busy_wait(10);
    
    gpio_out(LED_26V_EN, GPIO_HIGH_VALUE);
    #endif
    gpio_direction_input(_3_TOUCH_SDA_28V);
    gpio_direction_input(_3_TOUCH_SCL_28V);

    gpio_direction_output(_3_GPIO_TOUCH_EN, 1);
    mdelay(1);
    
//    for(temp=0; temp < 16;temp++) {
//        clk_busy_wait(1000); // gave the more delay, changed the LDO
//        dog_kick();
//    }
}
示例#4
0
//============================================================================
static void dci_delay_ms(uint32 milliseconds)
{
    int counter;

    for (counter = 0; counter < milliseconds; counter++)
    {
        clk_busy_wait(1000); 
    }   
}
示例#5
0
文件: fsbl_hw.c 项目: bgtwoigu/1110
/*===========================================================================

FUNCTION boot_pm_init( void )

DESCRIPTION
  Initializes SBI and PMIC in OSBL

SIDE EFFECTS
  PMIC, SBI are initialized.

===========================================================================*/
void boot_pm_init( void )
{
  /* Initialize the serial bus controllers */
  sbi_init( SBI_9p6MHZ );
  FSBL_VERIFY( pm_init_comm() == PM_ERR_FLAG__SUCCESS, FSBL_ERR_PM_INIT_FAIL );
  
  /* Init model specific parameters such as no of regs, mpps */
  pm_model_specific_init();

  /* Wait 102 microseconds for the rail to charge */
  clk_busy_wait(102);  
} /* boot_pm_init( void ) */
示例#6
0
/* adp5588 write configuration */
static int adp5588_write_config(struct i2c_client *client,ADP5588_cfg   *cfg)
{
    int ret=0 ,i;
    ADP5588_CMD_T  msg;

    if( !client || !cfg ) return -1;
    I2C_MUTEX_LOCK;
    for( i =0; cfg[i].reg !=0; i++ )
    {

        msg.reg = cfg[i].reg;
        msg.data = cfg[i].data;
        if ((ret = i2c_master_send(client, (uint8_t *)&msg,sizeof(msg))) < 0)
            dev_err(&client->dev," %s(%s):i2c_master_send error %d\n",
                    __FILE__, __FUNCTION__, ret);
        clk_busy_wait(1000);
    }
    I2C_MUTEX_UNLOCK;
    return ret;
}
示例#7
0
/* drivers/pm/pmapp.c */
void pm_app_clk_busy_wait(uint32 us)
{
    /* Halts the Microprocessor for the specified amount of usecs. */
    clk_busy_wait(us);
}
示例#8
0
static void adp5588_work_func( struct work_struct *work)
{
    int rc,i;
    uint8_t reg=ADP5588_REG_KEY_EVENTA;
    struct adp5588_keypad_data *kp = container_of(work, struct adp5588_keypad_data, work);
    struct i2c_client *client=kp->client;
    uint8_t  scan_code;


    /* set  read address */

    I2C_MUTEX_LOCK;

    if ((rc = i2c_master_send(client, &reg, 1)) <0)
    {
        dev_err(&client->dev," %s(%s):i2c_master_send error %d\n",
                __FILE__, __FUNCTION__, rc);
        /* I2c Write error  .  exit now , enable IRQ and read again if IRQ pin  still low */

    } else {

        /* read scancodes until queue is empty */
        i=0;
        do {
            scan_code =ADP5588_KEY_FIFO_EMPTY;

            if ((rc = i2c_master_recv(client, &scan_code,1 )) < 0 )
            {
                dev_err(&client->dev," %s(%s):i2c_master_recv error %d\n",
                        __FILE__, __FUNCTION__, rc);
                break;
            }

            if( scan_code != ADP5588_KEY_FIFO_EMPTY )
            {
                kp->last_key = ADP5588_KEY_CODE & scan_code ;
                kp->last_key_state  = !!(ADP5588_KEY_RELEASE & scan_code);

                dev_dbg(&client->dev,"ADP5588 got scancode %d ,keycode 0x%x ( %d ) state %d \n",

                        scan_code, kp->last_key, kp->last_key,kp->last_key_state );
                if(  kp->last_key == ADP5588_GPIO_KEY )
                {
                    /* got   RINGER/SILENCE  switch event */
                    adp5588_data.ringer_switch = kp->last_key_state;
                    switch_set_state(&adp5588_data.sw_mute_dev, !adp5588_data.ringer_switch);
                } else {
                    /* got   regular key event */
                    input_report_key(kp->input_dev, kp->last_key, kp->last_key_state);
                }

                //  Sync is removed.  It does not required  for key event
                //	  input_sync(kp->input_dev);
            } else  if( i == 0 ) { /*IRQ without the code ? , must be  key release  HW problem , Wait  5ms  */

                clk_busy_wait(5000);
            }

        } while( scan_code && (i++ <10) );
    }
    I2C_MUTEX_UNLOCK;

    /* Clear IRQ and enable it */
    if (kp->use_irq) {
        if ( adp5588_clear_irq(client)<0)
        {   /* I2c Problem , do not enable IRQ but wait 1 sec */
            hrtimer_start(&kp->timer, ktime_set(1,0), HRTIMER_MODE_REL);
        } else  enable_irq(client->irq);
    }

}
示例#9
0
static int adp5588_config(struct i2c_client *client)
{
    clk_busy_wait(1000);
    return(adp5588_write_config ( client,  adp5588_data.device_type  ? adp5588_init_seq_motus:adp5588_init_seq));
}
示例#10
0
/*===========================================================================

FUNCTION  OSBL_LOW_BATT_CHG

DESCRIPTION
    This function implements the core algorithm that handles the special 
case where the phone boots from USB and finds the battery is too low. It will
attempt to charge up the battery by trickle charging before boot-up continues.

DEPENDENCIES
  NONE
  
RETURN VALUE
  NONE

SIDE EFFECTS
  NONE

===========================================================================*/
static void osbl_low_batt_chg( void )
{
#if 0 /* Not used for KIP and HAN charging code */
  uint16 idx = 0, wait_idx = 0;uint32 delay_var =2500 ;
  /* tc_on: period when trickle charge is enabled
   * tc_off: period when trickle charge is disabled
   */
  uint16 tc_on = 250, tc_off = 2000 ;

  /* max number of tries to charge */
  uint32 max_loop_num = 50000;
  /* flag to indicate if HSUSB is already enumerated */
  boolean hsusb_enumerated = FALSE ;
  /* flag to indicate if a high current USB charger is connected */
  boolean usb_wall_charger_connected = FALSE ;

  /* Flag to indicate the bad battery */
  boolean bad_battery = FALSE ;  

  /* Flag to indicate if the fast charging has started or not */
  boolean has_fast_charging_started = FALSE ;

  /* Flag to indicate if the USB-cable has been disconnected */
  boolean has_usb_cable_been_disconn = FALSE ;

 /* Battery Level Indicator */  
  volatile int vbatt_threshold_indicator  = 0 ;


 
 if  ( pm_sbl_usb_sess_is_valid() )  // If it's not USB, then it's DC wall, continue to boot
  {
  
    pm_set_led_intensity(PM_LCD_LED, 0);
    pm_set_led_intensity(PM_KBD_LED, 0);

    /* Set the battery alarm upper and lower threshold
     * BAT_UPR_THRESH = 3600 mV = threshold for detection of battery absence
     * BAT_LWR_THRESH = 3200 mV = threshold for stopping charging
     */
    pm_sbl_set_batt_alarm_threshold(OSBL_USB_CHG_BAT_LWR_THRESH,
                                    OSBL_USB_CHG_BAT_UPR_THRESH); 

    /* Enable battery alarm comparators */
    pm_sbl_enable_batt_alarm(TRUE);

    /* Enable USB charging by closing the USB pass transistor */
    pm_chg_usb_charger_transistor_switch(PM_ON_CMD);

    /* Open battery FET */
    pm_chg_battery_transistor_switch(PM_OFF_CMD);

   /* Wait for sometime to settle the hardware circuitry */ 
    for (wait_idx = 0; wait_idx < 10; wait_idx++)
    {
      BOOTHW_KICK_WATCHDOG();
      clk_busy_wait(1000); 
    }
    /* Start the HSUSB stack */
    hsu_boot_start_stack();

    /* Pending: Check on the value of max_loop_num */
    for (idx = 0; idx < max_loop_num; idx++) 
    {
	  /* Delay variable for various charging phases */
	  uint32 delay_var = 0 ;

      /* Disable trickle charging */
      pm_chg_trickle_config(PM_CHG_TR_IMAX_00mA);

      /* It has to wait long enough because:
       * 1. The comparator needs time to settle before an accurate
       *    VBAT status can be read;
       * 2. The backlight has to stay on long enough for the user
       *    to see it
       */ 

     /*
     ** For trickle charging , tc_off would also serve to wait for the off pulse time
     ** For HSUSB charging , it would be a delay to make sure the VBAT
     ** is read after proper settling time.
      */

      if ( has_fast_charging_started == FALSE ) 
	  {
		  delay_var = tc_off ;  
          
	  }
	  else
	  {
		  delay_var = 2500 ;
	  }

  osbl_usb_chg_poll_while_waiting( 
                                           delay_var ,
                                           &hsusb_enumerated ,
                                           &usb_wall_charger_connected , 
                                           &has_fast_charging_started ,
										   &has_usb_cable_been_disconn ) ;
   
       if ( ( usb_wall_charger_connected ) || ( has_usb_cable_been_disconn ) )
       {
           break; /* Continue bootup with usb wall charger connected */
       }
   

      /* Check the VBAT status */
/*      vbatt_threshold_indicator = pm_sbl_read_bat_thresh() ;  */
      if ( vbatt_threshold_indicator > 0 ) 
      {
          /* If the battery is bad or disconnected, power down the phone */
          if ( bad_battery )
          {
              osbl_power_down() ; 
          }

        /* VBAT is higher than the desired level, battery is identified as good , Continue bootup*/
          break;
      }
      else if ( vbatt_threshold_indicator < 0 || !hsusb_enumerated ) 
      {
          /* VBAT is lower than the desired threshold and trickle-charging has
         * to begin/continue.
         * Put the phone in low power mode if it has not been already done. 
         */ 
         osbl_usb_chg_set_clock_mode(CLKRGM_USB_CHG_MODE);

        /* FET can switched off before we start the trickle-charging */
        pm_chg_battery_transistor_switch(PM_OFF_CMD);

        /* Enable trickle charging with current of 40mA */
        pm_chg_trickle_config(PM_CHG_TR_IMAX_40mA);

       /*
       ** For trickle charging , tc_on would serve as charging time
       */
       osbl_usb_chg_poll_while_waiting( 
                                            tc_on,
                                            &hsusb_enumerated ,
                                            &usb_wall_charger_connected , 
                                            &has_fast_charging_started ,
										    &has_usb_cable_been_disconn  ) ;
                                            
    
        if ( TRUE == usb_wall_charger_connected )
        {
            break; /* Continue bootup with usb wall charger connected */
        }
   
       
                    
        /* If any one of the conditions below is true, reset the phone:
         * 1. Battery is absent, which is indicated by VBAT being higher
              than the upper threshold
         * 2. USB is no longer connected (before the battery is charged
              up to the desired voltage level)
         * 3. It times out and the battery is still not charged up to
              the desired level, which indicates the battery may be
              very low or even dead
         */ 
        if ( !pm_sbl_usb_sess_is_valid() ||
             (idx == max_loop_num - 1) )
        {
          osbl_power_down () ; 
        }
        else if (pm_sbl_read_bat_thresh() > 0)
        { /* Battery is read again while trickle charging to get the most 
            updated value*/

          /* When the battery is absent, it takes much longer for perhaps
           * some kind of capacitance to discharge before VBAT can give
           * an accurate reading again. So set the wait state with trickle
           * charging disabled to a much longer period
           */
          tc_off = 1500 ;

		  /* Bad Battery detection needs a more complex algorithm and 
		   * that might be addressed in the next release. For this 
		   * release we will assume that we never get a bad battery.
		   
		   bad_battery = TRUE ; */
        }
        else
        {
          /* The battery is present and will continue to be charged.
           * It takes much shorter in this case to have an accurate
           * VBAT reading. Also a shorter period with trickle charge
           * disabled improves the efficiency of the charging
           * algorithm
           */
          tc_off = 50;
        }
      } 
      else if ( vbatt_threshold_indicator == 0 )
      {
        /* Battery voltage is good to facilitate HSUSB fast charging */
        if ( hsusb_enumerated && !has_fast_charging_started )
        {
          /* has_fast_charging_started is also used as flag to indicate HSUSB 
             is enumerated such that:
           * 1. hsu_boot_poll_stack is only called once
           * 2. the below configuration for high current charging will only be 
                done once
           */
          has_fast_charging_started  = TRUE ;

          /* Disable trickle charging, before fast charging is enabled */
          pm_chg_trickle_config(PM_CHG_TR_IMAX_00mA);
          /* Set current limit to 500mA for enumerated USB */
          pm_chg_usb_charger_transistor_imaxsel( PM_CHG_UCHG_Q_IMAX_050mV_div_R );
          /* Switch on the transistor to let the charging current through */
          pm_chg_battery_transistor_switch(PM_ON_CMD);

        }
      }
    } /* END for */
    /* Disable trickle charging */
    pm_chg_trickle_config(PM_CHG_TR_IMAX_00mA);

    /* Reset the battery alarm threshold */
    pm_sbl_set_batt_alarm_threshold(3200, 4000); 

    /* Disable battery alarm comparators */
    pm_sbl_enable_batt_alarm(FALSE);

    /* Put the phone out of lower mode to resume fast boot up */
    osbl_usb_chg_set_clock_mode(CLKRGM_USB_NORMAL_MODE);

     /* Disable USB charging by opening the USB pass transistor */
     if ( !usb_wall_charger_connected )
     {
        osbl_pm_set_usb_suspend_current () ; 
     } 
     /* Stop the stack and boot-up */
     hsu_boot_stop_stack();

   
  /* Put the USB transceiver back in SHUTDOWN mode */
  pm_sbl_usb_otg_shutdown(TRUE);

  /* Disable VREG_USB */
  pm_sbl_enable_vreg_usb(FALSE);

  /* Switch off the keypad light and LED */
  osbl_usb_chg_set_led( FALSE ) ;
 }
#endif /* Not used for KIP and HAN charging code */
 }