/*----------------------------------------------------------------------------- Name : aps_detect_printers Purpose : Detect printers connected to system Inputs : printers : printers array max : printers array size Outputs : Fills printers array with model and port information Return : number of printers detected -----------------------------------------------------------------------------*/ int aps_detect_printers(aps_printer_t *printers,int max) { int i; int n = 0; memset(printers,0,max*sizeof(aps_printer_t)); /*detect serial printers*/ i = detect_serial(&printers[n],max); n += i; max -= i; /*detect parallel printers*/ i = detect_parallel(&printers[n],max); n += i; max -= i; /*detect USB printers*/ i = detect_usb(&printers[n],max); n += i; max -= i; return n; }
void check_low_bat() { u16 v = 0, cap = 0; s16 t = 0; int power_source=0; int input_limit=0; int voltage=0; int capacity=0; int temperature=0; int ms=0; int sec=0; int mbid=0; int value=0; //turn off the phy __raw_writel(0x100, 0x4A0093E0); //disable ocp2scp_usb_phy_ick __raw_writel(0x30000, 0x4A0093E0); //disable ocp2scp_usb_phy_phy_48m __raw_writel(0x0, 0x4A008640); //disable usb_phy_cm_clk32k __raw_writel(1, 0x4A002300); //power down the usb phy mbid=get_mbid(); if(mbid!=0){ __raw_writel(0x40000000,0x4a100620); //disable the detect charger fuction } bq27541_temperature(&t); temperature = t; bq27541_voltage(&v); voltage = v; bq27541_capacity(&cap); capacity = cap; printf("Battery capacity =%d voltage=%d temperature=%d\n",capacity,voltage,temperature); //Temperature protect if( (temperature>TEMPERATURE_HOT_LIMIT) || (temperature<TEMPERATURE_COLD_LIMIT)){ printf("shutdown due to temperature protect %d\n",temperature); twl6030_shutdown(); } if( (voltage < LOW_BATTERY_VOLTAGE_LIMIT) || (capacity < LOW_BATTERY_CAPACITY_LIMIT)){ //Prepare to display the low battery message. if(twl6030_get_vbus_status()){ run_command("setgreenled 0", 0); run_command("setamberled 5", 0); //enable the VUSB 3.3 V twl6030_disable_vusb(); twl6030_init_vusb(); g_smb_address = SUMMIT_SMB347_I2C_ADDRESS; if (smb347_i2c_read_u8(&value,SUMMIT_SMB347_SLAVE_ADDR) != 0){ g_smb_address = SUMMIT_SMB347_I2C_ADDRESS_SECONDARY; if (smb347_i2c_read_u8(&value,SUMMIT_SMB347_SLAVE_ADDR) != 0){ goto LOW_BAT_TURN_OFF; } else { value = value >> 1; if(value != SUMMIT_SMB347_I2C_ADDRESS_SECONDARY) goto LOW_BAT_TURN_OFF; } }else{ value = value >> 1; if(value != SUMMIT_SMB347_I2C_ADDRESS) goto LOW_BAT_TURN_OFF; } summit_write_config(1); //enable charge time out smb347_i2c_read_u8(&value,SUMMIT_SMB347_STAT_TIMERS); //enable Pre-charge Timeout 48 min CLEAR_BIT(value,1);CLEAR_BIT(value,0); //enable complete charge timeout 1527 min CLEAR_BIT(value,2);SET_BIT(value,3); smb347_i2c_write_u8(value,SUMMIT_SMB347_STAT_TIMERS); /*reset the charge current to maximum*/ smb347_i2c_write_u8(kc1_chargerdetect_setting_pvt[0],0); summit_write_config(0); //Detect the power source if(mbid==0){//EVT 1.0 DETECT_BY_PHY printf("DETECT_BY_PHY\n"); power_source=detect_usb(); }else{//DETECT_BY_CHARGER printf("DETECT_BY_CHARGER\n"); //check is this first boot? smb347_i2c_read_u8(&value,SUMMIT_SMB347_STAT_TIMERS); if(IS_BIT_CLEAR(value,5)){//FIRST BOOT printf("FIRST BOOT\n"); //disable stat summit_write_config(1); SET_BIT(value,5); smb347_i2c_write_u8(value,SUMMIT_SMB347_STAT_TIMERS); summit_write_config(0); //redo the apsd summit_config_apsd(0); summit_config_apsd(1); } power_source=summit_detect_usb(); if(power_source==NO_VBUS) goto LOW_BAT_TURN_OFF; if(power_source==2){ if(mbid==0){ //Need to fixed,this is bug of summit summit_switch_mode(USB5_OR_9_MODE); summit_init(mbid); summit_charge_enable(1); } /* Enter low battery charge loop */ low_bat_charge(); if(mbid==0) summit_charge_enable(0); }else if(power_source==3||power_source==1){ if(mbid==0){ summit_switch_mode(HC_MODE); summit_init(mbid); summit_charge_enable(1); } if(mbid>=4){ //For DVT input_limit=summit_is_aicl_complete(); if(input_limit==NO_VBUS) goto LOW_BAT_TURN_OFF; printf("Power:AICL=%d mA\n",input_limit); /* Enter low battery charge loop */ //if(input_limit>0 && input_limit<=900) low_bat_charge(); } } } }else{
void vbus_monitor_work_func(struct work_struct *work) { struct twl6030_usb *twl = container_of(work, struct twl6030_usb, vbus_work); int event = -1; unsigned long flags; int vbus_state, hw_state; int detect_result=0;u32 value=0; //spin_lock_irqsave(&twl->lock, flags); #ifdef CONFIG_USB_MUSB_HDRC_HCD hw_state = twl6030_readb(twl, TWL6030_MODULE_ID0, STS_HW_CONDITIONS); #endif vbus_state = twl6030_readb(twl, TWL6030_MODULE_CHARGER, CONTROLLER_STAT1); /* AC unplugg can also generate this IRQ * we only call the notifier in case of VBUS change */ if (twl->prev_vbus != (vbus_state & VBUS_DET)) { //printk("\n%s twl->prev_vbus=%d vbus_state=%d \n",__func__,twl->prev_vbus,vbus_state & VBUS_DET); twl->prev_vbus = vbus_state & VBUS_DET; #ifdef CONFIG_USB_MUSB_HDRC_HCD if (!(hw_state & STS_USB_ID)) { #endif if (vbus_state & VBUS_DET) { wake_lock(&twlusb_lock); regulator_enable(twl->vusb); if(twl->mbid==0){//detect by omap //printk("%s DETECT_BY_PHY\n",__func__); blocking_notifier_call_chain(&twl->otg.notifier,USB_EVENT_DETECT_SOURCE, twl->otg.gadget); detect_result=detect_usb(); if(detect_result==PHY_DETECT_PC) event = USB_EVENT_VBUS; else if(detect_result==PHY_DETECT_DEDICATED_CHARGER) event = USB_EVENT_CHARGER; else if(detect_result==PHY_DETECT_HOST_CHARGER) event = USB_EVENT_HOST_CHARGER; else event = USB_EVENT_CHARGER; twl->otg.default_a = false; twl->otg.state = OTG_STATE_B_IDLE; }else{//detect by charger //printk("%s DETECT_BY_CHARGER\n",__func__); __raw_writel(0x40000000,OMAP2_L4_IO_ADDRESS(0x4a100000 + (0x620))); event = USB_EVENT_DETECT_SOURCE; twl->otg.default_a = false; twl->otg.state = OTG_STATE_B_IDLE; } }else{ //printk("!!%s USB_EVENT_NONE\n\n",__func__); event = USB_EVENT_NONE; //regulator_disable(twl->vusb); } if (event >= 0) { twl->linkstat = event; blocking_notifier_call_chain(&twl->otg.notifier,event, twl->otg.gadget); } #ifdef CONFIG_USB_MUSB_HDRC_HCD } #endif sysfs_notify(&twl->dev->kobj, NULL, "vbus"); } if(event == USB_EVENT_NONE) { wake_unlock(&twlusb_lock); } }