void FSA9480_MhlSwitchSel(bool sw) { struct i2c_client *client = local_usbsw->client; //struct power_supply *mhl_power_supply = power_supply_get_by_name("battery"); // union power_supply_propval value; printk("[FSA] mutex_lock\n"); //mutex_lock(&FSA9480_MhlSwitchSel_lock);//avoid race condtion between mhl and hpd if(sw) { sii9234_cfg_power(1); if (gv_intr2&0x1) //cts: fix for 3355 { mhl_vbus = true; mhl_power_supply=1; local_pdata->charger_cb(FSA9480_ATTACHED); gv_intr2=0; printk("vbus_power is detected\n"); } SiI9234_init(); } else { if (tegra_dc_hdmi_hpd()) { printk("[FSA] Turn off hdmi\n"); mhl_hpd_handler(false); } if(mhl_power_supply==1) { mhl_power_supply=0; local_pdata->charger_cb(FSA9480_DETACHED); } mhl_vbus = false; sii9234_cfg_power(0); //Turn Off power to SiI9234 } /********************FSA-MHL-FSA Switching start***************************/ DisableFSA9480Interrupts(); { //gpio_set_value_cansleep(GPIO_MHL_SEL, sw); sii9234_switch_onoff(sw); i2c_smbus_read_byte_data(client, FSA9480_REG_INT1); } EnableFSA9480Interrupts(); /******************FSA-MHL-FSA Switching End*******************************/ //mutex_unlock(&FSA9480_MhlSwitchSel_lock); printk("[FSA] mutex_unlock\n"); }
void MHL_On(bool on) { if (on == 1) { s3c_gpio_cfgpin(GPIO_MHL_INT, GPIO_MHL_INT_AF); sii9234_cfg_power(1); sii9234_init(); } else { sii9234_cfg_power(0); s3c_gpio_setpull(GPIO_MHL_SEL, S3C_GPIO_PULL_NONE); gpio_set_value(GPIO_MHL_SEL, GPIO_LEVEL_LOW); } }
static ssize_t check_MHL_command(struct device *dev, struct device_attribute *attr, char *buf) { int count; int res; printk(KERN_ERR "[MHL]: check_MHL_command\n"); sii9234_cfg_power(1); res = SiI9234_startTPI(); count = sprintf(buf,"%d\n", res ); sii9234_cfg_power(0); return count; }
void MHL_On(bool on) { printk("MHL_On(%d)\n", on); if (on == 1) { gpio_set_value(GPIO_MHL_SEL, 1); sii9234_cfg_power(1); SiI9234_init(); } else { gpio_set_value(GPIO_MHL_RST, 0); sii9234_cfg_power(0); gpio_set_value(GPIO_MHL_SEL, 0); #ifdef TIMER_ACC_ADC old_adc_mhl_detected = false; hrtimer_start(&sii9234_adc_timer, ns_to_ktime(250000000/*500ms*/), HRTIMER_MODE_REL); #endif } }
static ssize_t change_switch_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t size) { char *after; unsigned long value = simple_strtoul(buf, &after, 10); int i; printk(KERN_ERR "[MHL_SWITCH] Change the switch: %ld\n", value); if (value == 0) { for (i = 0; i <1; i++) { printk(KERN_ERR "[MHL] try %d\n", i+1); msleep(500); } gpio_set_value(GPIO_MHL_SEL, 1); sii9234_cfg_power(1); SiI9234_init(); } else { gpio_set_value(GPIO_MHL_RST, 0); sii9234_cfg_power(0); gpio_set_value(GPIO_MHL_SEL, 0); } return size; }
static ssize_t change_switch_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t size) { char *after; unsigned long value = simple_strtoul(buf, &after, 10); int i; printk(KERN_ERR "[MHL_SWITCH] Change the switch: %ld\n", value); if (value == 0) { for (i = 0; i <20; i++) { printk(KERN_ERR "[MHL] try %d\n", i+1); msleep(500); } s3c_gpio_cfgpin(GPIO_MHL_INT, GPIO_MHL_INT_AF); s3c_gpio_setpull(GPIO_MHL_SEL, S3C_GPIO_PULL_UP); gpio_set_value(GPIO_MHL_SEL, GPIO_LEVEL_HIGH); sii9234_cfg_power(1); sii9234_init(); } else { sii9234_cfg_power(0); s3c_gpio_setpull(GPIO_MHL_SEL, S3C_GPIO_PULL_NONE); gpio_set_value(GPIO_MHL_SEL, GPIO_LEVEL_LOW); } return size; }
void mhl_onff_handler(struct work_struct *work) //Rajucm { // struct i2c_client *client = local_usbsw->client; printk("praveen: mhl on off handler\n"); //Rajucm: phone Power on with MHL Cable,avoid crash while((!SII9234_i2c_status)) { //4Control enters into while loop only when fsa9480 detects MHL-cable @ phone bootup //printk(KERN_ERR"[FSA9480]## mhl cable detected during boot ## \n"); //i2c_smbus_write_byte_data(client, 0x02, (0x01|i2c_smbus_read_byte_data(client, 0x02))); //DisableFSA9480Interrupts if(!sec_get_lpm_mode()) { printk(KERN_ERR "[FSA9480]## %s ## \n", SII9234_i2c_status? "Ready to start MHL":"Let's Sleep untill MHL condition comes true"); wait_event_interruptible_timeout(fsa9480_MhlWaitEvent, SII9234_i2c_status, msecs_to_jiffies(5*1000)); //5sec: } //skip controlling the sii9234 on lpm mode if(sec_get_lpm_mode()) { //ignore turn on mhl because of only charging mode in power off state! printk(KERN_DEBUG "lpm_mode booting, so there is no to turn on mhl:mhl_onoff[%d]\n",mhl_onoff); //only desk_dock without mhl cable! DisableFSA9480Interrupts(); FSA9480_CheckAndHookAudioDock(USE_DESK_DOCK,mhl_onoff); return; } } if(mhl_onoff) { sii9234_cfg_power(1); //Turn On power to SiI9234 printk("Praveen:The value of mhl_cable_status is %d\n", mhl_cable_status); if(mhl_cable_status == 0x08 || mhl_cable_status == 0x00 || mhl_cable_status == 0x03) { SiI9234_init(); local_usbsw->check_watchdog=0; schedule_delayed_work(&local_usbsw->fsa_watchdog, msecs_to_jiffies(3000)); DisableFSA9480Interrupts(); gpio_set_value_cansleep(GPIO_MHL_SEL, mhl_onoff); } } else { sii9234_cfg_power(0); //Turn Off power to SiI9234 DisableFSA9480Interrupts(); gpio_set_value_cansleep(GPIO_MHL_SEL, mhl_onoff); mhl_cable_status = 0x08; //Once mhl powered off cable status cannot be 0x07; } // this code only for deskdock [ if (!mhl_onoff) { if (usedeskdock) { FSA9480_CheckAndHookAudioDock(USE_DESK_DOCK, 0); } else { FSA9480_CheckAndHookAudioDock(USB_HDMI_CABLE,0); EnableFSA9480Interrupts(); } } // ] }
void FSA9480_CheckAndHookAudioDock(int value, int onoff) { struct i2c_client *client = local_usbsw->client; struct fsa9480_platform_data *pdata = local_usbsw->pdata; int ret = 0; // unsigned int ctrl = CON_MASK; if (onoff) local_usbsw->check_watchdog=1; if (value == USE_DESK_DOCK) { if (onoff) { //skip controlling the sii9234 on lpm mode if(!sec_get_lpm_mode()) { #if defined(CONFIG_VIDEO_MHL_V1) sii9234_cfg_power(0); //Turn Off power to SiI9234 #elif defined(CONFIG_VIDEO_MHL_V2) mhl_onoff_ex(0); //will call hw_onoff(0) #endif gpio_set_value_cansleep(GPIO_MHL_SEL, 0); } ret = i2c_smbus_read_byte_data(client,FSA9480_REG_CTRL); dev_info(&client->dev, "FSA9480_CheckAndHookAudioDock On ctrl reg: 0x%x\n", ret); if (pdata->deskdock_cb) pdata->deskdock_cb(FSA9480_ATTACHED); //#if !defined(CONFIG_USA_MODEL_SGH_I717) && !defined (CONFIG_USA_MODEL_SGH_T769) if (!get_sec_det_jack_state()) { if (HWversion ==VERSION_FSA9480) { ret = i2c_smbus_write_byte_data(client,FSA9480_REG_MANSW1,SW_AUDIO); } else { ret = i2c_smbus_write_byte_data(client,FSA9480_REG_MANSW1,AUDIO_9485); } if (ret < 0) dev_err(&client->dev,"%s: err %d\n", __func__, ret); } else printk("%s: Earjack exist..\n", __func__); //#endif ret = i2c_smbus_read_byte_data(client,FSA9480_REG_CTRL); if (ret < 0) dev_err(&client->dev,"%s: err %d\n", __func__, ret); ret = i2c_smbus_write_byte_data(client,FSA9480_REG_CTRL, ret & ~CON_MANUAL_SW & ~CON_RAW_DATA); if (ret < 0) dev_err(&client->dev,"%s: err %d\n", __func__, ret); ret = i2c_smbus_read_byte_data(client,FSA9480_REG_INT2_MASK); if (ret < 0) dev_err(&client->dev,"%s: err %d\n", __func__, ret); ret = i2c_smbus_write_byte_data(client, FSA9480_REG_INT2_MASK, ret & ~INT_MASK_ADC_CHANGE); if (ret < 0) dev_err(&client->dev,"%s: err %d\n", __func__, ret); usedeskdock= true; isDeskdockconnected=1; Dockconnected = 1; } else { dev_info(&client->dev, "FSA9480_CheckAndHookAudioDock Off ctrl reg: 0x%x\n", ret); if (pdata->deskdock_cb) pdata->deskdock_cb(FSA9480_DETACHED); ret = i2c_smbus_read_byte_data(client,FSA9480_REG_CTRL); if (ret < 0) dev_err(&client->dev,"%s: err %d\n", __func__, ret); ret = i2c_smbus_write_byte_data(client,FSA9480_REG_CTRL, ret | CON_MANUAL_SW | CON_RAW_DATA); if (ret < 0) dev_err(&client->dev,"%s: err %d\n", __func__, ret); ret = i2c_smbus_read_byte_data(client,FSA9480_REG_INT2_MASK); if (ret < 0) dev_err(&client->dev,"%s: err %d\n", __func__, ret); ret = i2c_smbus_write_byte_data(client, FSA9480_REG_INT2_MASK, ret | INT_MASK_ADC_CHANGE); if (ret < 0) dev_err(&client->dev,"%s: err %d\n", __func__, ret); usedeskdock= false; isDeskdockconnected=0; Dockconnected = 0; } EnableFSA9480Interrupts(); } else if (value == USB_HDMI_CABLE) { if (onoff) { if (pdata->mhl_cb) pdata->mhl_cb(FSA9480_ATTACHED); } else { if (pdata->mhl_cb) pdata->mhl_cb(FSA9480_DETACHED); if (local_usbsw!=NULL) fsa9480_reg_init(local_usbsw); } usedeskdock= false; isDeskdockconnected=0; Dockconnected = 0; } else if (value == USE_VEHICLE_DOCK) { if (onoff) { ret = i2c_smbus_read_byte_data(client,FSA9480_REG_CTRL); dev_info(&client->dev, "FSA9480_CheckAndHookAudioDock On ctrl reg: 0x%x\n", ret); //#if !defined(CONFIG_USA_MODEL_SGH_I717) && !defined (CONFIG_USA_MODEL_SGH_T769) if (!get_sec_det_jack_state()) { if (HWversion ==VERSION_FSA9480) { ret = i2c_smbus_write_byte_data(client,FSA9480_REG_MANSW1,SW_AUDIO); } else { ret = i2c_smbus_write_byte_data(client,FSA9480_REG_MANSW1,AUDIO_9485); } if (ret < 0) dev_err(&client->dev,"%s: err %d\n", __func__, ret); } else printk("%s: Earjack exist..\n", __func__); //#endif ret = i2c_smbus_read_byte_data(client,FSA9480_REG_CTRL); if (ret < 0) dev_err(&client->dev,"%s: err %d\n", __func__, ret); ret = i2c_smbus_write_byte_data(client,FSA9480_REG_CTRL, ret & ~CON_MANUAL_SW); if (ret < 0) dev_err(&client->dev,"%s: err %d\n", __func__, ret); Dockconnected = 1; } else { dev_info(&client->dev, "FSA9480_CheckAndHookAudioDock Off ctrl reg: 0x%x\n", ret); ret = i2c_smbus_read_byte_data(client,FSA9480_REG_CTRL); if (ret < 0) dev_err(&client->dev,"%s: err %d\n", __func__, ret); ret = i2c_smbus_write_byte_data(client,FSA9480_REG_CTRL, ret | CON_MANUAL_SW | CON_RAW_DATA); if (ret < 0) dev_err(&client->dev,"%s: err %d\n", __func__, ret); ret = i2c_smbus_read_byte_data(client,FSA9480_REG_INT2_MASK); if (ret < 0) dev_err(&client->dev,"%s: err %d\n", __func__, ret); ret = i2c_smbus_write_byte_data(client, FSA9480_REG_INT2_MASK, ret | INT_MASK_ADC_CHANGE); if (ret < 0) dev_err(&client->dev,"%s: err %d\n", __func__, ret); Dockconnected = 0; } } }