void set_ts5usba33402_cp_usb_mode(void) { /* Connect CP UART signals to AP */ usif_switch_ctrl(USIF_AP); /* Connect CP USB to MUIC UART */ dp3t_switch_ctrl(DP3T_CP_USB); /* Enable 200K, Charger Pump, and ADC (0x01=0x13) */ muic_i2c_write_byte(CONTROL_1, ID_200 | SEMREN | CP_EN); /* Enable UART Path (0x03=0x09) */ muic_i2c_write_byte(SW_CONTROL, COMP2_TO_U2 | COMN1_TO_U1); }
void set_ts5usba33402_ap_usb_mode(void) { /* Connect CP UART signals to AP */ usif_switch_ctrl(USIF_AP); /* * AP USB does not pass through DP3T. * Just connect AP UART to MUIC UART. */ dp3t_switch_ctrl(DP3T_AP_UART); muic_i2c_write_byte(SW_CONTROL, COMP2_TO_DP2 | COMN1_TO_DN1); /* Enable 200K, Charger Pump, and ADC (0x01=0x13) */ muic_i2c_write_byte(CONTROL_1, ID_200 | SEMREN | CP_EN); }
void set_max14526_cp_usb_mode(void) //USB_MODE { printk(KERN_WARNING "[MUIC] set_max14526_cp_usb_mode\n" ); /* Connect CP UART signals to AP */ usif_switch_ctrl(USIF_AP); /* Connect CP USB to MUIC UART */ dp3t_switch_ctrl(DP3T_CP_USB); /* Enable 200K, Charger Pump, and ADC (0x01=0x13) */ muic_i2c_write_byte(CONTROL_1, ID_200 | ADC_EN | CP_EN); /* Enable UART Path (0x03=0x09) */ muic_i2c_write_byte(SW_CONTROL, COMP2_TO_U2 | COMN1_TO_U1); }
void set_max14526_ap_usb_mode(void) //USB_MODE { s32 ret; printk(KERN_WARNING "[MUIC] set_max14526_ap_usb_mode\n" ); //KIMCS TEST usif_switch_ctrl(USIF_AP); dp3t_switch_ctrl(DP3T_CP_UART); /* Enables USB Path (0x03=0x00) */ muic_i2c_write_byte(SW_CONTROL, COMP2_TO_DP2 | COMN1_TO_DN1); /* Enables 200K, Charger Pump, and ADC (0x01=0x13) */ muic_i2c_write_byte(CONTROL_1, ID_200 | ADC_EN | CP_EN); }
void usif_switch_ctrl(TYPE_USIF_MODE mode){ /* LGE_CHANGE_START 2011-03-16 [email protected] patch for Adb offline set and Mass Storage Driver detecting fail */ /* 20110113 [email protected] check muic driver init. state [START] */ if(!muic_init_done){ printk(KERN_WARNING "[MUIC] MUIC has not been initialized! Nothing will be done!!!.\n"); return ; } /* 20110113 [email protected] check muic driver init. state [END] */ /* LGE_CHANGE_END 2011-03-16 [email protected] */ /* gpio output mode setting */ gpio_direction_output(USIF_IN_1_GPIO, 0); /* gpio data setting */ if(mode == USIF_AP){ gpio_set_value(USIF_IN_1_GPIO, 0); // START [email protected] 2011/04/16 LAB1_FW : JUSTIN_FOTA_FIX { printk(KERN_WARNING "[MUIC] usif_switch_ctrl( USIF_AP )\n"); dp3t_switch_ctrl(DP3T_NC); set_wakelock(1); fota_ing = 1; // END [email protected] 2011/04/16 LAB1_FW } } // START [email protected] 2011/04/16 LAB1_FW : JUSTIN_FOTA_FIX { else if( fota_ing ) { // do nothing. printk(KERN_WARNING "[MUIC] usif_switch_ctrl : do nothing!\n"); } // END [email protected] 2011/04/16 LAB1_FW } else if(mode == USIF_DP3T){ // START [email protected] 2011/04/16 LAB1_FW : JUSTIN_FOTA_FIX { printk(KERN_WARNING "[MUIC] usif_switch_ctrl( USIF_DP3T )\n"); if( !fota_ing ) { printk(KERN_WARNING "[MUIC] usif_switch_ctrl() : fota_ing != 1\n"); // END [email protected] 2011/04/16 LAB1_FW } gpio_set_value(USIF_IN_1_GPIO, 1); } } else{ /* Just keep the current path */ } usif_mode = mode; }
s32 muic_CP_UART_set(void){ s32 ret; /* LGE_CHANGE_START 2011-03-16 [email protected] patch for Adb offline set and Mass Storage Driver detecting fail */ /* 20110113 [email protected] check muic driver init. state [START] */ if(!muic_init_done){ printk(KERN_WARNING "[MUIC] MUIC has not been initialized! Nothing will be done!!!.\n"); return 0; } /* 20110113 [email protected] check muic driver init. state [END] */ /* LGE_CHANGE_END 2011-03-16 [email protected] */ /* Connect CP UART signals to DP3T */ usif_switch_ctrl(USIF_DP3T); /* Connect CP UART to MUIC UART */ dp3t_switch_ctrl(DP3T_CP_UART); if (muic_device == MAX14526) { /* ID_200, VLDO 2.6V, ADC is auto, Charge Pump.*/ ret = muic_i2c_write_byte(CONTROL_1, MID_200 | MADC_EN | MCP_EN); } else { /* ID_200, VLDO 2.6V, SEMREN on. ADC is auto.*/ ret = muic_i2c_write_byte(CONTROL_1, MID_200 | MSEMREN); } /* Connect DP, DM to UART_TX, UART_RX*/ ret = muic_i2c_write_byte(SW_CONTROL, DP_UART | DM_UART); /* Turn on charger IC with FACTORY mode */ charging_ic_set_factory_mode(); muic_mode = MUIC_CP_UART; printk(KERN_WARNING "[MUIC] muic_distinguish_vbus_accessory(): CP_UART\n"); /* wake lock for the factory mode */ /* LGE_CHANG_START 2011-03-30 [email protected] wakelock on when AT command sequence by CP UART */ set_wakelock(1); /* LGE_CHANGE_END 2011-03-30 [email protected] */ return ret; }
void set_ts5usba33402_ap_uart_mode(void) { /* Connects CP UART signals to AP */ usif_switch_ctrl(USIF_AP); /* Connects AP UART to MUIC UART */ dp3t_switch_ctrl(DP3T_AP_UART); /* Enables 200K, Charger Pump, and ADC (0x01=0x13) */ muic_i2c_write_byte(CONTROL_1, ID_200 | SEMREN | CP_EN); #if defined(CONFIG_LU6500) if(get_lge_pcb_revision() > REV_D) muic_i2c_write_byte(SW_CONTROL, COMP2_TO_AUD2|COMN1_TO_AUD1); else #endif /* Enable USB Path (0x03=0x00) */ muic_i2c_write_byte(SW_CONTROL, COMP2_TO_U2 | COMN1_TO_U1); }
void setting_for_factory_mode_hw_req(void) { #if 0 /* XXX_mbk */ /* Battery FET OFF */ lge_battery_fet_onoff(0); #else extern void dp3t_switch_ctrl(TYPE_DP3T_MODE mode); /* HW요청사항...Battery가 있으면...2A가 아닌 960mA로 충전하도록 Charger IC가 2A로 충전을 계속하게 되면 버티지 못함. */ if( check_battery_present() ) { printk(KERN_INFO "%s, Charger Current Setting TA mode from Factory Mode\n", __FUNCTION__); charging_ic_set_ta_mode(); } #endif /* USB Switch to CP */ dp3t_switch_ctrl(DP3T_CP_USB); }
void set_ts5usba33402_cp_usb_mode(void) { #if defined(CONFIG_MACH_BSSQ) gpio_set_value(GPIO_CP_USB_VBUS_EN, 1); #endif #if !defined(CONFIG_MACH_BSSQ) /* Connect CP UART signals to AP */ usif_switch_ctrl(USIF_AP); /* Connect CP USB to MUIC UART */ dp3t_switch_ctrl(DP3T_CP_USB); /* Enable 200K, Charger Pump, and ADC (0x01=0x13) */ muic_i2c_write_byte(CONTROL_1, ID_200 | SEMREN | CP_EN); #endif /* Enable UART Path (0x03=0x09) */ muic_i2c_write_byte(SW_CONTROL, COMP2_TO_U2 | COMN1_TO_U1); }
int muic_set_ap_uart_mode(struct muic_client_device *mcdev)// (struct i2c_client *client) { struct i2c_client *client = tsu5611; //to_i2c_client(%mcdev->dev);// i2c_verify_client(&mcdev->dev); dev_info(&client->dev, "muic: %s\n", __func__); #if 0 /* Connects CP UART signals to AP */ usif_switch_ctrl(USIF_AP); /* Connects AP UART to MUIC UART */ dp3t_switch_ctrl(DP3T_AP_UART); #endif /* Enables 200K, Charger Pump, and ADC (0x01=0x13) */ muic_i2c_write_byte(client, CONTROL_1, ID_200 | SEMREN | CP_EN); /* Enable USB Path (0x03=0x00) */ muic_i2c_write_byte(client, SW_CONTROL, COMP2_TO_U2 | COMN1_TO_U1); // muic_set_mode(MUIC_AP_UART); return 0; }
//MOBII_CHNANGE_S 20120416 [email protected] : FOTA UA Upgrade for ICS //LGE_CHANGE_S jinook.hong 2012-02-21 for FOTA void fota_cp_reset(void) { #if 1 // jdpark : fota reset int ret; gpio_request(GPIO_CP_RESET, "ifx_reset_n"); tegra_gpio_enable(GPIO_CP_RESET); gpio_direction_output(GPIO_CP_RESET, 1); dp3t_switch_ctrl(DP3T_NC); mdelay(5000); gpio_set_value(TEGRA_GPIO_PV0, 0); ret = gpio_get_value(TEGRA_GPIO_PV0); printk(KERN_INFO "[FOTA] fota_cp_reset: ret = %d ", ret); mdelay(10); gpio_set_value(TEGRA_GPIO_PV0, 1); ret = gpio_get_value(TEGRA_GPIO_PV0); printk(KERN_INFO "[FOTA] fota_cp_reset: ret = %d ", ret); #else gpio_set_value(TEGRA_GPIO_PO0, 1); mdelay(100); gpio_set_value(TEGRA_GPIO_PV1, 1); mdelay(50); gpio_set_value(TEGRA_GPIO_PO0, 0); mdelay(50); gpio_set_value(TEGRA_GPIO_PV1, 0); mdelay(2000); gpio_set_value(TEGRA_GPIO_PV1, 1); mdelay(50); gpio_set_value(TEGRA_GPIO_PO0, 1); mdelay(100); //gpio_set_value(TEGRA_GPIO_PO0, 0); printk(KERN_INFO "[FOTA] fota_cp_reset: TEGRA_GPIO_PO0/PV1 "); return; #endif }
//[[email protected]] - moved muic_ti.c to here void muic_set_mhl_mode_detect(void) { DBG("[MUIC] muic_set_mhl_mode_detect entry. \n"); /* Connect CP UART signals to AP */ usif_switch_ctrl(USIF_AP); /* 109 * AP USB does not pass through DP3T. 110 * Just connect AP UART to MUIC UART. 111 */ dp3t_switch_ctrl(DP3T_NC); //muic_i2c_write_byte(SW_CONTROL, COMP2_TO_DP2 | COMN1_TO_DN1); //Path USB muic_i2c_write_byte(SW_CONTROL, COMP2_TO_HZ | COMN1_TO_HZ); //Path OPEN /* Enable 200K, Charger Pump, and ADC (0x01=0x13) */ //muic_i2c_write_byte(CONTROL_1, ID_200 | SEMREN | CP_EN); MHL_On(1); //muic_mode = MUIC_MHL; //[[email protected]] - Set by caller. NOT here. }
void muic_init_max14526(TYPE_RESET reset) { printk(KERN_WARNING "[MUIC] max14526_init()\n"); //[[email protected]] muic detecting... //atomic_set(&muic_charger_detected,0); if (reset == RESET) { /* Clears default switch position (0x03=0x24) */ muic_i2c_write_byte(SW_CONTROL, COMP2_TO_HZ | COMN1_TO_HZ); } /* * Iniialize MAX14526 for Detection of Accessories * Enable 200K pull-up and ADC (0x01=0x12) * Enable Interrupt [XX REMOVED AUD related XX and set AUD Click/Pop resistor(CP_EN) XX XX] (0x02=0x50) */ muic_i2c_write_byte(CONTROL_1, ID_200 | ADC_EN); muic_i2c_write_byte(CONTROL_2, INT_EN); #ifdef CONFIG_MACH_STAR_SU660 dp3t_switch_ctrl(DP3T_NC); usif_switch_ctrl(USIF_AP); #endif }
s32 muic_AP_USB_set(void){ s32 ret; /* LGE_CHANGE_START 2011-03-16 [email protected] patch for Adb offline set and Mass Storage Driver detecting fail */ /* 20110113 [email protected] check muic driver init. state [START] */ if(!muic_init_done){ printk(KERN_WARNING "[MUIC] MUIC has not been initialized! Nothing will be done!!!.\n"); return 0; } /* 20110113 [email protected] check muic driver init. state [END] */ /* LGE_CHANGE_END 2011-03-16 [email protected] */ if(hidden_menu_switching == 8) // if USB mode change AP_USB through Proc filesystem, force D+/D- open { ret = muic_i2c_write_byte(SW_CONTROL, DP_OPEN | DM_OPEN); muic_udelay(100000); if(ret < 0) printk(KERN_WARNING "[MUIC] i2c write error for D+/D- open in muic_CP_USB_SET\n"); } /* Justin?�서 AP_UART�??�정??AP_USB ?�작 ?�함 */ dp3t_switch_ctrl(DP3T_NC); if (muic_device == MAX14526) { /* ID_200, VLDO 2.6V, ADC Enable, * USB 2.0 also needs the charge pump (CP_EN) on.*/ ret = muic_i2c_write_byte(CONTROL_1, MID_200 | MADC_EN | MCP_EN); } else { // START [email protected] 2011/03/10 LAB1_FW { if( MUIC_AP_USB != muic_mode ) { ret = muic_i2c_write_byte(SW_CONTROL, DP_OPEN | DM_OPEN); /* ID_200, VLDO 2.6V, SEMREN on. ADC is auto. * USB 2.0 also needs the charge pump (CP_EN) on.*/ ret = muic_i2c_write_byte(CONTROL_1, MID_200 | MSEMREN | MCP_EN); } // END [email protected] 2011/03/10 LAB1_FW } } /* Connect DP, DM to USB_DP, USB_DM */ ret = muic_i2c_write_byte(SW_CONTROL, DP_USB | DM_USB); /* Turn on charger IC with TA mode */ charging_ic_set_usb_mode(); muic_mode = MUIC_AP_USB; printk(KERN_WARNING "[MUIC] muic_distinguish_vbus_accessory(): AP_USB\n"); /* wake lock for usb connection */ set_wakelock(1); // check_usb_reg(); /* 20111105, [email protected], for stable USB connection. */ return ret; }
int muic_init(int isFactoryReset) { unsigned int retain_mode = NO_RETAIN; unsigned char i2c_ret; unsigned char reg_val; unsigned char muic_device; MUIC_MODE_TYPE muic_mode = MUIC_OPEN; char cmd_line[256]; strcpy(cmd_line, getenv("bootargs")); #if defined(CONFIG_COSMO_EVB_B) || defined(CONFIG_COSMO_EVB_C) printf("muic chip : I2C4\n"); select_bus(I2C4 , OMAP_I2C_STANDARD); #else printf("muic chip : I2C3\n"); select_bus(I2C3 , OMAP_I2C_STANDARD); #endif i2c_init(OMAP_I2C_STANDARD, MUIC_SLAVE_ADDR); i2c_ret = muic_i2c_read_byte(DEVICE_ID, ®_val); if ((reg_val & 0xf0) == 0x10) muic_device = TS5USBA33402; else if ((reg_val & 0xf0) == 0x20) muic_device = MAX14526; else if ((reg_val & 0xf0) == ANY_VANDOR_ID) muic_device = ANY_VANDOR; if (downloadkey()){ write_muic_retain_mode(NO_RETAIN); printf("[MUIC] No retain\n"); } retain_mode = read_muic_retain_mode(); printf("muic_init muic vendor : %d, reg_val:0x%x, retain_mode = %d\n", muic_device, reg_val, retain_mode); if (muic_device == TS5USBA33402) { printf("muic chip : TS5USBA33402\n"); if (retain_mode == RETAIN_AP_USB) { muic_i2c_write_byte(CONTROL_1, ID_200 | SEMREN | CP_EN); muic_i2c_write_byte(SW_CONTROL, USB); muic_mode = MUIC_USB; check_charging_mode(&muic_mode); printf("[MUIC] retain AP_USB\n"); printf("\n###[MUIC] USB charger may not have enough power to boot up depends on your board condition..... ###\n"); printf("\n###[MUIC] You'd better to use TA or PIF for power supply. ###\n"); strcat(cmd_line, " muic=2"); setenv("bootargs", cmd_line); } else if (retain_mode == RETAIN_CP_USB) { muic_i2c_write_byte(SW_CONTROL, OPEN); dp3t_switch_ctrl(DP3T_NC); muic_mode = MUIC_USB; check_charging_mode(&muic_mode); printf("[MUIC] retain CP_USB\n"); strcat(cmd_line, " muic=3"); setenv("bootargs", cmd_line); } else muic_mode = muic_device_ts5usba33402(isFactoryReset, cmd_line); } else if (muic_device == MAX14526) { printf("muic chip : MAX14526\n"); if (retain_mode == RETAIN_AP_USB) { muic_i2c_write_byte(CONTROL_1, ID_200 | ADC_EN | CP_EN); muic_i2c_write_byte(SW_CONTROL, USB); muic_mode = MUIC_USB; check_charging_mode(&muic_mode); printf("[MUIC] retain AP_USB\n"); printf("\n###[MUIC] USB charger may not have enough power to boot up depends on your board condition..... ###\n"); printf("\n###[MUIC] You'd better to use TA or PIF for power supply. ###\n"); strcat(cmd_line, " muic=2"); setenv("bootargs", cmd_line); } else if (retain_mode == RETAIN_CP_USB) { muic_i2c_write_byte(SW_CONTROL, OPEN); dp3t_switch_ctrl(DP3T_NC); muic_mode = MUIC_USB; check_charging_mode(&muic_mode); printf("[MUIC] retain CP_USB\n"); strcat(cmd_line, " muic=3"); setenv("bootargs", cmd_line); } else muic_mode = muic_device_max14526(isFactoryReset, cmd_line); } else printf("[MUIC] ANY VENDOR, Not supported\n"); select_bus(I2C1, OMAP_I2C_STANDARD); return muic_mode; }
s32 muic_CP_USB_set(void){ s32 ret; /* LGE_CHANGE_START 2011-03-16 [email protected] patch for Adb offline set and Mass Storage Driver detecting fail */ /* 20110113 [email protected] check muic driver init. state [START] */ if(!muic_init_done){ printk(KERN_WARNING "[MUIC] MUIC has not been initialized! Nothing will be done!!!.\n"); return 0; } /* 20110113 [email protected] check muic driver init. state [END] */ /* LGE_CHANGE_END 2011-03-16 [email protected] */ // LGE_UPDATE_S 20110411 [[email protected]] force D+/D- open in CP side ret = muic_i2c_write_byte(SW_CONTROL, DP_OPEN | DM_OPEN); muic_udelay(100000); if(ret < 0) printk(KERN_WARNING "[MUIC] i2c write error for D+/D- open in muic_CP_USB_SET\n"); // LGE_UPDATE_E 20110411 [[email protected]] force D+/D- open in CP side /* Connect CP UART signals to AP */ /* CP <-> USIF_AP ?�결??CP ?�운로드 Fail 발생 */ usif_switch_ctrl(USIF_DP3T); /* Connect CP USB to MUIC UART */ dp3t_switch_ctrl(DP3T_CP_USB); if (muic_device == MAX14526) { /* ID_200, VLDO 2.6V, ADC is auto. * USB 2.0 also needs the charge pump (CP_EN) on.*/ ret = muic_i2c_write_byte(CONTROL_1, MID_200 | MADC_EN | MCP_EN); } else { if( MUIC_CP_USB != muic_mode ) { /* ID_200, VLDO 2.6V, SEMREN on. ADC is auto. * USB 2.0 also needs the charge pump (CP_EN) on.*/ ret = muic_i2c_write_byte(CONTROL_1, MID_200 | MSEMREN | MCP_EN); } } ret = muic_i2c_write_byte(SW_CONTROL, DP_USB | DM_USB); // S [email protected] ; add for charging mode when CP USB is slected int check_battery_present(); if(check_battery_present()==1) charging_ic_set_usb_mode(); else charging_ic_set_factory_mode(); // E [email protected] ; add for charging mode when CP USB is slected muic_mode = MUIC_CP_USB; printk(KERN_ERR "[MUIC] muic_distinguish_vbus_accessory(): CP_USB\n"); // START [email protected] 2011/03/03 LAB1_FW : WAKELOCK_CASE_AT_CP_USB : Ref from LU3000 { if ( reset_status == 2 /* RESET_GLOBAL_SW_RESET */ ) { // If muic path is CP_USB, Reset cause is SW_RESET then WakeLock AP // wake lock for the factory mode if(0==the_wlock.wake_lock_on){ wake_lock(&the_wlock.wake_lock); the_wlock.wake_lock_on=1; printk(KERN_WARNING "[MUIC] ====^^==== wake_lock_on=1 (locked)\n"); } } else { /* wake lock off for the factory mode */ set_wakelock(0); } // END [email protected] 2011/03/03 LAB1_FW } return ret; }
/* Distinguish charger type. * This function is called *ONLY IF* INT_STAT's CHGDET == 1, i.e., a charger is detected. * * Chargers becomes to use the default MUIC setting * because the detection always happens only after the MUIC_NONE mode * which leads the default MUIC setting. * Thus, we don't need to explictly set MUIC registers here. */ s32 muic_distinguish_charger(void){ s32 ret = 0; /* Enable charger IC in TA mode */ charging_ic_set_ta_mode(); /* Connect AP UART to MUIC UART */ dp3t_switch_ctrl(DP3T_AP_UART); /* * LGE_UPDATE 20110425 [[email protected]] change IDNO for detecting LG_TA * * IDNO == 0x05(0101) 180 KOhm. LG TA : Standard usb cable * IDNO == 0x06(0110) 240 KOhm. LG TA : Docomo accessaary usb cable * IDNO == 0x0b(1011) OPEN. TA charger * There is no ADC value of MUIC table for 220KOhm * so, we need to double check 180 KOhm and 220 KOhm */ if ((int_stat_val & MIDNO) == 0x05 || (int_stat_val & MIDNO) == 0x06 || (int_stat_val & MIDNO) == 0x0b) { muic_mode = MUIC_LG_TA; printk(KERN_WARNING "[MUIC] muic_distinguish_charger(): MUIC_LG_TA\n"); set_wakelock(0); return ret; } if (muic_device == MAX14526) { /* Prepare for reading charger type */ ret = muic_i2c_write_byte(CONTROL_2, MINT_EN | MCHG_TYP); /* LGE_UPDATE_S [[email protected]] 2010-12-01, interrupt clear in TA detection */ msleep(70); ret = muic_i2c_read_byte(INT_STAT, &status_val); /* LGE_UPDATE_E [[email protected]] 2010-12-01, interrupt clear in TA detection */ } /* Read STATUS */ ret = muic_i2c_read_byte(STATUS, &status_val); if (ret < 0) { printk(KERN_INFO "[MUIC] STATUS reading failed\n"); muic_mode = MUIC_UNKNOWN; key_was_pressed = 0; // from HUB set_wakelock(0); return ret; } printk(KERN_INFO "[MUIC] STATUS = %x\n", status_val); /* DCPORT == 1. Dedicated Charger */ if ((status_val & MDCPORT) != 0) { muic_mode = MUIC_NA_TA; printk(KERN_WARNING "[MUIC] muic_distinguish_charger(): MUIC_NA_TA\n"); } /* CHPORT == 1. HCHH */ else if ((status_val & MCHPORT) != 0) { muic_mode = MUIC_HCHH; printk(KERN_WARNING "[MUIC] muic_distinguish_charger(): MUIC_HCHH\n"); } /* DCPORT == 0 && CHPORT == 0. Definitely INVALID_CHG */ else { muic_mode = MUIC_INVALID_CHG; printk(KERN_WARNING "[MUIC] muic_distinguish_charger(): MUIC_INVALID_CHG\n"); } set_wakelock(0); return ret; }
static MUIC_MODE_TYPE muic_device_max14526(int _isFactoryRest, char *cmd) { unsigned char i2c_ret; unsigned char status_val; unsigned char int_status_val; MUIC_MODE_TYPE muic_mode = MUIC_OPEN; i2c_ret = muic_i2c_write_byte(CONTROL_1, ID_200 | ADC_EN); i2c_ret = muic_i2c_write_byte(CONTROL_2, 0x00); usif1_switch_ctrl(USIF1_UART); udelay(70000); i2c_ret = muic_i2c_read_byte(INT_STATUS, &int_status_val); printf("INT_STAT = 0x%x\n", int_status_val); if ((int_status_val & VBUS) != 0) { if ((int_status_val & IDNO) == 0x02) { #ifdef CONFIG_COSMO_SU760 cable_56K_detect = 1; #endif if (_isFactoryRest) { muic_i2c_write_byte(SW_CONTROL, UART); dp3t_switch_ctrl(DP3T_S2_CP_UART); muic_mode = MUIC_FACTORY_MODE; strcat(cmd, " muic=1"); setenv("bootargs", cmd); printf("[MUIC] first boot, path = CP UART\n"); } else { muic_i2c_write_byte(SW_CONTROL, OPEN); dp3t_switch_ctrl(DP3T_NC); muic_mode = MUIC_FACTORY_MODE; printf("CP_USB\n"); } } else if ((int_status_val & IDNO) == 0x04) { muic_i2c_write_byte(SW_CONTROL, UART); dp3t_switch_ctrl(DP3T_S2_CP_UART); muic_mode = MUIC_FACTORY_MODE; printf("CP_UART\n"); } else if ((int_status_val & IDNO) == 0x0a || (int_status_val & IDNO) == 0x09) { mmc_init(1); cable_910K_detect = 1; dload_mode = read_muic_mode_of_dload(); if (dload_mode == NORMAL_MODE) { muic_i2c_write_byte(CONTROL_1, ID_200 | ADC_EN | CP_EN); muic_i2c_write_byte(SW_CONTROL, USB); muic_mode = MUIC_FACTORY_MODE; printf("AP_USB is set(910Kohm)\n"); } else { muic_i2c_write_byte(SW_CONTROL, OPEN); dp3t_switch_ctrl(DP3T_NC); write_muic_mode_of_dload(NORMAL_MODE); muic_mode = MUIC_FACTORY_MODE; printf("CP_USB is set(910Kohm)\n"); } }else { muic_i2c_write_byte(SW_CONTROL, COMP2_TO_HZ | COMN1_TO_C1COMP); udelay(2000); i2c_ret = muic_i2c_read_byte(STATUS, &status_val); printf("STATUS = 0x%x\n", status_val); if (status_val & C1COMP) { muic_i2c_write_byte(SW_CONTROL, OPEN); dp3t_switch_ctrl(DP3T_NC); muic_mode = MUIC_CHRGER; printf("Charger Detected\n"); } else { muic_i2c_write_byte(CONTROL_1, ID_200 | ADC_EN | CP_EN); muic_i2c_write_byte(SW_CONTROL, USB); dp3t_switch_ctrl(DP3T_NC); #ifdef CONFIG_COSMO_SU760 cable_open_usb_detect = 1; #endif muic_mode = MUIC_USB; printf("\n### USB charger may not have enough power to boot up depends on your board condition..... ###\n"); printf("\n### You'd better to use TA or PIF for power supply. ###\n"); printf("[MUIC] AP USB\n"); } } } else { if ((int_status_val & IDNO) == 0x02) { muic_i2c_write_byte(CONTROL_1, ID_200 | ADC_EN | CP_EN); muic_i2c_write_byte(SW_CONTROL, UART); dp3t_switch_ctrl(DP3T_S1_AP_UART); printf("AP_UART\n"); } else if ((int_status_val & IDNO) == 0x04) { muic_i2c_write_byte(CONTROL_1, ID_200 | ADC_EN); muic_i2c_write_byte(SW_CONTROL, UART); dp3t_switch_ctrl(DP3T_S2_CP_UART); printf("CP_UART\n"); } else { muic_i2c_write_byte(SW_CONTROL, OPEN); dp3t_switch_ctrl(DP3T_NC); muic_mode = MUIC_OPEN; printf("MUIC opened\n"); } } printf("INT_STAT = 0x%x\n", int_status_val); return muic_mode; }