static int mc7_sensor_open_init(const struct msm_camera_sensor_info *data) { int rc = 0; unsigned int val; struct packet *i2c_pkt; FUNC_ENTER(); /* Reset MIPI configuration flag */ config_csi = 0; if (mc7_i2c_client->irq) rc = request_irq(mc7_i2c_client->irq, mc7_int_handler, IRQF_DISABLED | IRQF_TRIGGER_RISING, mc7_i2c_client->name, NULL); if (rc) printk(KERN_ERR "LSI-MC7: %s: cannot request irq\n", __func__); mc7_ctrls = kzalloc(sizeof(struct mc7_ctrls_t), GFP_KERNEL); if (!mc7_ctrls) { printk(KERN_ERR "LSI-MC7: %s: probe from VFE failed\n", __func__); rc = -ENOMEM; goto vfe_probe_fail0; } if (data) mc7_ctrls->sensordata = data; msm_camio_clk_rate_set(24000000); mc7_gpio_int = 0; mc7_sensor_power_on_off(1 ,data); rc = wait_mc7_int(60); /* If the user has set update firmware flag then update the firmware first */ if (mc7_firmware_upd) { mc7_firmware_upd = 0; /* write PLL divider value */ mc7_catparam_i2c_write(2, 0xf, 0x24, 0x001A); /* firmware is send first */ for (i2c_pkt = &dynamic_firmware_array[0]; i2c_pkt->length != 0; i2c_pkt++) firmware_write(i2c_pkt->length, i2c_pkt->firmware); /* Now send the flash writer program */ for (i2c_pkt = &mc7_fl_write_array[0]; i2c_pkt->length != 0; i2c_pkt++) firmware_write(i2c_pkt->length, i2c_pkt->firmware); mc7_catparam_i2c_write(4, 0xf, 0x0C, 0x6807E000); mc7_catparam_i2c_write(1, 0xf, 0x12, 0x01); rc = wait_mc7_int(300); if (!rc) printk(KERN_ERR "LSI-MC7: firmware successfully writen to serial flash\n"); else { printk(KERN_ERR "LSI-MC7: firmware update failed\n"); return rc; } vfree(firmware_area); firmware_area = NULL; } /* Set the PLL divider value */ mc7_catparam_i2c_write(2, 0xf, 0x24, 0x001A); /* Now send the flash loader program */ firmware_write(sizeof(mc7_fl_load_1), mc7_fl_load_1); /* Set the camera start address */ mc7_catparam_i2c_write(4, 0xf, 0x0C, 0x6807E000); /* start the loader program */ mc7_catparam_i2c_write(1, 0xf, 0x12, 0x01); rc = wait_mc7_int(1); #ifdef DOWNLOAD_IF_MC7_EMPTY if (rc) { printk(KERN_ERR "LSI-MC7: serial flash is empty, going to write it\n"); /* Power recycle MC7 */ mc7_sensor_power_on_off(0 ,data); mc7_sensor_power_on_off(1 ,data); rc = wait_mc7_int(60); /* write PLL divider value */ mc7_catparam_i2c_write(2, 0xf, 0x24, 0x001A); /* firmware is send first */ for (i2c_pkt = &mc7_firmware_array[0]; i2c_pkt->length != 0; i2c_pkt++) firmware_write(i2c_pkt->length, i2c_pkt->firmware); /* Now send the flash writer program */ for (i2c_pkt = &mc7_fl_write_array[0]; i2c_pkt->length != 0; i2c_pkt++) firmware_write(i2c_pkt->length, i2c_pkt->firmware); /* write the address of the program */ mc7_catparam_i2c_write(4, 0xf, 0x0C, 0x6807E000); /* start the writer program */ mc7_catparam_i2c_write(1, 0xf, 0x12, 0x01); rc = wait_mc7_int(300); if (!rc) printk(KERN_ERR "LSI-MC7: firmware successfully writen to serial flash\n"); else printk(KERN_ERR "LSI-MC7: firmware update failed\n"); /* Set the PLL divider value */ mc7_catparam_i2c_write(2, 0xf, 0x24, 0x001A); /* Now send the flash loader program */ firmware_write(sizeof(mc7_fl_load_1), mc7_fl_load_1); /* Set the camera start address */ mc7_catparam_i2c_write(4, 0xf, 0x0C, 0x6807E000); /* start the loader program */ mc7_catparam_i2c_write(1, 0xf, 0x12, 0x01); rc = wait_mc7_int(1); } #endif /* Read the interrupt status */ mc7_catparam_i2c_read(1, 0x0, 0x1c, &val); MC7DBG("Loader program successfully booted the firmware\n"); return rc; vfe_probe_fail0: return rc; }
//#define DOWNLOAD_WHILE_BOOT static int mc7_sensor_probe(const struct msm_camera_sensor_info *info, struct msm_sensor_ctrl *s) { int rc = 0; unsigned int val = 0; #ifdef DOWNLOAD_WHILE_BOOT struct packet *i2c_pkt; #endif FUNC_ENTER(); rc = i2c_add_driver(&mc7_i2c_driver); if (rc < 0) { printk(KERN_ERR "LSI-MC7: %s: sensor probe failed\n", __func__); goto probe_fail0; } rc = i2c_add_driver(&lp8720_i2c_driver); if (rc < 0) { printk(KERN_ERR "LSI-MC7: %s: lp8720 probe failed\n", __func__); goto probe_fail1; } msm_camio_clk_rate_set(24000000); /* Check whether sensor is present and its powering on */ mc7_sensor_power_on_off(1 ,info); rc = poll_mc7_int(5); if (!rc) { mc7_catparam_i2c_read(4, 0xf, 0x1c, &val); if (val != 0x68000000) { printk(KERN_ERR "LSI-MC7:%s: Invalid read value= %x\n", __func__, val); goto probe_fail2; } #ifdef DOWNLOAD_WHILE_BOOT /* write PLL divider value */ mc7_catparam_i2c_write(2, 0xf, 0x24, 0x001A); /* firmware is send first */ for (i2c_pkt = &mc7_firmware_array[0]; i2c_pkt->length != 0; i2c_pkt++) firmware_write(i2c_pkt->length, i2c_pkt->firmware); /* Now send the flash writer program */ for (i2c_pkt = &mc7_fl_write_array[0]; i2c_pkt->length != 0; i2c_pkt++) firmware_write(i2c_pkt->length, i2c_pkt->firmware); /* write the address of the program */ mc7_catparam_i2c_write(4, 0xf, 0x0C, 0x6807E000); /* start the writer program */ mc7_catparam_i2c_write(1, 0xf, 0x12, 0x01); rc = poll_mc7_int(300); if (!rc) printk(KERN_ERR "LSI-MC7: firmware successfully writen to serial flash\n"); else printk(KERN_ERR "LSI-MC7: firmware update failed\n"); #endif /* Power off the sensor */ mc7_sensor_power_on_off(0 ,info); s->s_init = mc7_sensor_open_init; s->s_release = mc7_sensor_release; s->s_config = mc7_sensor_config; MC7DBG("mc7 sensor probe successful\n"); return rc; } probe_fail2: mc7_sensor_power_on_off(0 ,info); probe_fail1: i2c_del_driver(&lp8720_i2c_driver); probe_fail0: i2c_del_driver(&mc7_i2c_driver); printk(KERN_ERR "LSI-MC7: %s:probe failed\n", __func__); return rc; }
eMFSRet_t MFS_ISC_update(void) { extern void ts_power_enable(int en); eMFSRet_t ret; unsigned char paneltype, tspcomp, setcomp, redownload = 0; int i; MFS_I2C_set_slave_addr(mfs_i2c_slave_addr); ENTRANCE: MFS_ms_delay(50); #ifdef CONFIG_MACH_KYLE_I buf =& MELFAS_binary; #else ret= check_panel_type(&paneltype); if (ret != MRET_SUCCESS && !redownload) { MFS_TSP_reboot(); if (mass_erase() != MRET_SUCCESS) goto MFS_ISC_UPDATE_FINISH; #ifdef CONFIG_TOUCHSCREEN_MELFAS_KYLE_G2 if (firmware_write(G2_BINARY) != MRET_SUCCESS) goto MFS_ISC_UPDATE_FINISH; #else if (firmware_write(G1F_BINARY) != MRET_SUCCESS) goto MFS_ISC_UPDATE_FINISH; #endif MFS_TSP_reboot(); if (enter_ISC_mode() != MRET_SUCCESS) goto MFS_ISC_UPDATE_FINISH; #ifdef CONFIG_TOUCHSCREEN_MELFAS_KYLE_G2 if (firmware_verify(G2_BINARY) != MRET_SUCCESS) goto MFS_ISC_UPDATE_FINISH; #else if (firmware_verify(G1F_BINARY) != MRET_SUCCESS) goto MFS_ISC_UPDATE_FINISH; #endif MFS_TSP_reboot(); redownload = 1; goto ENTRANCE; } else if (ret != MRET_SUCCESS) { goto MFS_ISC_UPDATE_FINISH; } if(paneltype == 0x4d) { buf = &G1M_BINARY; printk(KERN_ERR "<MELFAS> buf_G1M\n"); } else if(paneltype == 0x46) { buf =& G1F_BINARY; printk(KERN_ERR "<MELFAS> buf_G1F\n"); } #ifdef CONFIG_TOUCHSCREEN_MELFAS_KYLE_G2 else if(paneltype == 0x58) { buf =& G2_BINARY; printk(KERN_ERR "<MELFAS> buf_G2\n"); //goto MFS_ISC_UPDATE_FINISH; } #endif #endif // TSP HW Revision if( get_tsp_compatibility(&tspcomp) != MRET_SUCCESS) goto MFS_ISC_UPDATE_FINISH; printk(KERN_ERR "<MELFAS> paneltype=%c\n", paneltype); printk(KERN_ERR "<MELFAS> tspcomp=%x\n", tspcomp); #if defined(CONFIG_TOUCHSCREEN_MELFAS_KYLE_G2) if((paneltype == 0x4d && tspcomp > 0x0E) || (paneltype == 0x46 && ( tspcomp < 0x0F || tspcomp > 0x14 )) || (paneltype == 0x58 && ( tspcomp < 0x15 || tspcomp > 0x19 )) ) #else if((paneltype == 0x4d && tspcomp > 0x0E) || (paneltype == 0x46 && tspcomp <= 0x0E)) #endif goto START_DOWNLOAD; get_main_compatibility(buf, &setcomp); #ifdef CONFIG_MACH_KYLE_I setcomp = TSP_SET_COMP; printk(KERN_ERR "<MELFAS> setcomp=%x\n", setcomp); printk(KERN_ERR "<MELFAS> tspcomp=%x\n", tspcomp); if(tspcomp != setcomp){ goto MFS_ISC_UPDATE_FINISH; } #else #if defined(CONFIG_TOUCHSCREEN_MELFAS_KYLE_G2) if( paneltype == 0x58 ) { setcomp = TSP_SET_COMP_G2; printk(KERN_ERR "<MELFAS> setcomp=%x\n", setcomp); printk(KERN_ERR "<MELFAS> tspcomp=%x\n", tspcomp); if(tspcomp != setcomp) goto MFS_ISC_UPDATE_FINISH; } else #endif { printk(KERN_ERR "<MELFAS> setcomp=%c\n", setcomp); printk(KERN_ERR "<MELFAS> tspcomp=%x\n", tspcomp); if(tspcomp != (setcomp-55)) goto MFS_ISC_UPDATE_FINISH; } #endif if (check_firmware_version(0, buf) != MRET_SUCCESS) goto MFS_ISC_UPDATE_FINISH; START_DOWNLOAD: if (mass_erase() != MRET_SUCCESS) goto MFS_ISC_UPDATE_FINISH; ret = firmware_write(buf); if (ret != MRET_SUCCESS) goto MFS_ISC_UPDATE_FINISH; MFS_TSP_reboot(); printk(KERN_ERR "<MELFAS> TOUCH IC REBOOT!!!\n"); if (enter_ISC_mode() != MRET_SUCCESS) goto MFS_ISC_UPDATE_FINISH; if (firmware_verify(buf) != MRET_SUCCESS) goto MFS_ISC_UPDATE_FINISH; printk(KERN_ERR "<MELFAS> FIRMWARE_UPDATE_FINISHED!!!\n\n"); MFS_ISC_UPDATE_FINISH: MFS_TSP_reboot(); printk(KERN_ERR "<MELFAS> TOUCH IC REBOOT2!!!\n"); check_firmware_version(1, buf); MFS_I2C_set_slave_addr(mfs_i2c_slave_addr); return ret; }