int camera_power_on (void) { int rc; struct device *dev = pecan_backlight_dev(); camera_power_mutex_lock(); if(lcd_bl_power_state == BL_POWER_SUSPEND) { pecan_pwrsink_resume(); mdelay(50); } /* clear RESET, PWDN to Low*/ gpio_set_value(GPIO_CAM_RESET, 0); gpio_set_value(GPIO_CAM_PWDN, 0); //2010-11-02 config_camera_off_gpios(); mdelay(40); /*AVDD power 2.8V*/ if (lge_bd_rev == LGE_REV_B) { rc = aat28xx_ldo_set_level(dev, LDO_CAM_AF_NO, 2800); if (rc < 0) { printk(KERN_ERR "%s: ldo %d set level error\n", __func__, LDO_CAM_AF_NO); goto power_on_fail; } rc = aat28xx_ldo_enable(dev, LDO_CAM_AF_NO, 1); if (rc < 0) { printk(KERN_ERR "%s: ldo %d control error\n", __func__, LDO_CAM_AF_NO); goto power_on_fail; } } else { /* it is for rev.c and default */ struct vreg *vreg_mmc = vreg_get(0, "mmc"); vreg_set_level(vreg_mmc, 2800); vreg_enable(vreg_mmc); } /* DVDD power 1.2V, change to 1.8V */ rc = aat28xx_ldo_set_level(dev, LDO_CAM_DVDD_NO, 1800); if (rc < 0) { printk(KERN_ERR "%s: ldo %d set level error\n", __func__, LDO_CAM_DVDD_NO); goto power_on_fail; } rc = aat28xx_ldo_enable(dev, LDO_CAM_DVDD_NO, 1); if (rc < 0) { printk(KERN_ERR "%s: ldo %d control error\n", __func__, LDO_CAM_DVDD_NO); goto power_on_fail; } mdelay(1); /*IOVDD power 2.6V*/ rc = aat28xx_ldo_set_level(dev, LDO_CAM_IOVDD_NO, 2600); if (rc < 0) { printk(KERN_ERR "%s: ldo %d set level error\n", __func__, LDO_CAM_IOVDD_NO); goto power_on_fail; } rc = aat28xx_ldo_enable(dev, LDO_CAM_IOVDD_NO, 1); if (rc < 0) { printk(KERN_ERR "%s: ldo %d control error\n", __func__, LDO_CAM_IOVDD_NO); goto power_on_fail; } /*AVDD power 2.7V*/ /* LGE_CHANGE * Change AVDD level from 2.7V to 2.8V in order to reduce camera noise in dard environment. * 2010-08-03. [email protected] */ rc = aat28xx_ldo_set_level(dev, LDO_CAM_AVDD_NO, 2800); if (rc < 0) { printk(KERN_ERR "%s: ldo %d set level error\n", __func__, LDO_CAM_AVDD_NO); goto power_on_fail; } rc = aat28xx_ldo_enable(dev, LDO_CAM_AVDD_NO, 1); if (rc < 0) { printk(KERN_ERR "%s: ldo %d control error\n", __func__, LDO_CAM_AVDD_NO); goto power_on_fail; } //mdelay(5); /*M Clock -24Mhz*/ mdelay(20); config_camera_on_gpios(); msm_camio_clk_rate_set(mclk_rate); mdelay(5); msm_camio_camif_pad_reg_reset(); mdelay(5); /*Nstandby high*/ gpio_set_value(GPIO_CAM_PWDN, 0); mdelay(1); /*reset high*/ gpio_set_value(GPIO_CAM_RESET, 1); mdelay(8); // T2 camera_power_state = CAM_POWER_ON; power_on_fail: camera_power_mutex_unlock(); return rc; }
static int bwpm_wifi_on( struct device *pdev , int on ) { bwpm_data_t *p_sts; int ret; if ( pdev == NULL ){ disp_err( "device not found\n" ); return -1; } p_sts = (bwpm_data_t *)dev_get_drvdata(pdev); if ( p_sts == NULL ){ disp_err( "driver infomation not found\n" ); return -1; } if ( p_sts->wifi == on ){ disp_dbg( "%s: no need to change status (%d->%d)\n" , __func__, p_sts->wifi , on ); return 0; } if ( on ){ /* Turn ON RF/WLAN_IO-3.0V */ if( p_sts->bluetooth <= 0 ){ gpio_set_value( BWPM_PORT_RF_LNA_EN, 1 ); /* WLAN_VDD_PA_LNA_EN */ disp_dbg( "%s: RF ON\n" , __func__); msleep(1); /* over 200 micro seconds */ } /* PM8058_VREG_L19 => ON at here*/ ret = vreg_enable( p_sts->vreg_wl ); /* Turn ON WL-1.8V */ // gpio_set_value( BWPM_PORT_WL_1P8V_EN, 1 ); /* WLAN_VREG_EN */ msleep(5); gpio_set_value( BWPM_PORT_WL_RESET_N, 1 ); /* WLAN_RST */ } else { gpio_set_value( BWPM_PORT_WL_RESET_N, 0 ); /* WLAN_RST */ /* [WLAN][SHARP] 2010.12.27 mod Start */ #if 1 msleep(5); /* over 1.5ms */ #endif /* [WLAN][SHARP] 2010.12.27 mod End */ /* PM8058_VREG_L19 => OFF at here */ ret = vreg_disable( p_sts->vreg_wl ); /* Turn OFF WL-1.8V */ // gpio_set_value( BWPM_PORT_WL_1P8V_EN, 0 ); /* WLAN_VREG_EN */ if( p_sts->bluetooth <= 0 ){ msleep(1); /* over 200 micro seconds */ gpio_set_value( BWPM_PORT_RF_LNA_EN, 0 ); /* WLAN_VDD_PA_LNA_EN */ disp_dbg( "%s: RF OFF\n" , __func__); } } if ( p_sts->wifi < 0 ){ disp_inf( "WiFi power on reset\n" ); } else { disp_dbg( "%s: change status (%d->%d)\n" , __func__, p_sts->wifi , on ); } p_sts->wifi = on; return 0; }
static int aps_12d_probe( struct i2c_client *client, const struct i2c_device_id *id) { /* define and initialization the value */ int value_lsb = 0; int value_msb = 0; int ret; struct aps_data *aps; /*the aps_12d sensors ispower on*/ int i; #ifdef CONFIG_ARCH_MSM7X30 struct vreg *vreg_gp4=NULL; int rc; /*delete this line,27A don't have to match the power supply*/ vreg_gp4 = vreg_get(NULL, VREG_GP4_NAME); if (IS_ERR(vreg_gp4)) { pr_err("%s:gp4 power init get failed\n", __func__); } /* set gp4 voltage as 2700mV for all */ rc = vreg_set_level(vreg_gp4,VREG_GP4_VOLTAGE_VALUE_2700); if (rc) { pr_err("%s: vreg_gp4 vreg_set_level failed (%d)\n", __func__, rc); return rc; } rc = vreg_enable(vreg_gp4); if (rc) { pr_err("%s: vreg_gp4 vreg_enable failed (%d)\n", __func__, rc); return rc; } #endif mdelay(5); if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) { printk(KERN_ERR "aps_12d_probe: need I2C_FUNC_I2C\n"); ret = -ENODEV; goto err_check_functionality_failed; } /* if querry the board is T1 or T2 turn off the proximity */ /* This modification for version A&B of U8800,only */ if((machine_is_msm7x30_u8800())&&((get_hw_sub_board_id() == HW_VER_SUB_VA) || ((get_hw_sub_board_id() == HW_VER_SUB_VB)))) { printk(KERN_ERR "aps_12d_probe: aps is not supported in U8800 and U8800 T1 board!\n"); ret = -ENODEV; goto err_check_functionality_failed; } aps = kzalloc(sizeof(*aps), GFP_KERNEL); if (aps == NULL) { ret = -ENOMEM; goto err_alloc_data_failed; } mutex_init(&aps->mlock); INIT_WORK(&aps->work, aps_12d_work_func); aps->client = client; i2c_set_clientdata(client, aps); PROXIMITY_DEBUG(KERN_INFO "ghj aps_12d_probe send command 2\n "); /* Command 2 register: 25mA,DC,12bit,Range1 */ /*power_down to avoid the iic read error */ aps_i2c_reg_write(aps, APS_12D_REG_CMD1, APS_12D_POWER_DOWN); /*init the flag,because everlight's 0x06,0x07's register's value low 4 bit is 0*/ value_lsb = aps_i2c_reg_read(aps, APS_INT_HT_LSB); value_msb = aps_i2c_reg_read(aps, APS_INT_HT_MSB); old_lsb = value_lsb; old_msb = value_msb; /* debug--- stare at the value of lsb & msb */ APS_DBG("value_lsb=%d,value_msb=%d\n",value_lsb,value_msb); /* judge the device type */ /* when 06 07 registers don't equal 0x00, we think it's a intersil hardware */ if((0x00 == value_lsb) && (0x00 == value_msb)) { intersil_flag = EVERLIGHT; } else { intersil_flag = INTERSIL; } /* write reg value for the two device */ if(EVERLIGHT == intersil_flag) { ret = aps_i2c_reg_write(aps, APS_12D_REG_CMD2, \ (uint8_t)(APS_12D_IRDR_SEL_50MA << 6 | \ APS_12D_FREQ_SEL_DC << 4 | \ APS_12D_RES_SEL_12 << 2 | \ APS_12D_RANGE_SEL_ALS_1000)); } else { /*because Power-up and Power Supply Considerations is not good enough for intersil's datasheet,so avoid it via software*/ ret = aps_i2c_reg_write(aps, APS_TEST, APS_12D_POWER_DOWN); if (ret < 0) { PROXIMITY_DEBUG("APS_TEST error!\n"); } msleep(10); ret = aps_i2c_reg_write(aps, APS_12D_REG_CMD1, APS_12D_POWER_DOWN); if (ret < 0) { PROXIMITY_DEBUG("APS_12D_POWER_DOWN error!\n"); } msleep(10); ret = aps_i2c_reg_write(aps, APS_12D_REG_CMD2, \ (uint8_t)(APS_12D_IRDR_SEL_INTERSIL_50MA << 4 | \ APS_FREQ_INTERSIL_DC << 6 | \ APS_ADC_12 << 2 | \ APS_INTERSIL_SCHEME_OFF| \ APS_12D_RANGE_SEL_ALS_1000)); } err_threshold_value[1] = 50; if (ret < 0) { goto err_detect_failed; } range_index = 0; #ifdef CONFIG_HUAWEI_HW_DEV_DCT /* detect current device successful, set the flag as present */ set_hw_dev_flag(DEV_I2C_APS); #endif for(i = 0; i < TOTAL_RANGE_NUM; i++) { /* NOTE: do NOT use the last one */ /* get the down_range_value */ if(EVERLIGHT == intersil_flag) { up_range_value[i] = MAX_ADC_OUTPUT - high_threshold_value_U8661[i] - RANGE_FIX + 500; } else { up_range_value[i] = MAX_ADC_OUTPUT - high_threshold_value_U8661_I[i] - RANGE_FIX + 500; } } down_range_value[0] = 0; for(i = 1; i < TOTAL_RANGE_NUM; i++) { /* NOTE: do not use the first one */ /* get the down_range_value */ if(EVERLIGHT == intersil_flag) { down_range_value[i] = (MAX_ADC_OUTPUT - high_threshold_value_U8661[i-1] - (MAX_ADC_OUTPUT / ADJUST_GATE)) / 4 - 650; } else { down_range_value[i] = (MAX_ADC_OUTPUT - high_threshold_value_U8661_I[i-1] - (MAX_ADC_OUTPUT / ADJUST_GATE)) / 4 - 650; } } /*we don't use the input device sensors again */ aps->input_dev = input_allocate_device(); if (aps->input_dev == NULL) { ret = -ENOMEM; PROXIMITY_DEBUG(KERN_ERR "aps_12d_probe: Failed to allocate input device\n"); goto err_input_dev_alloc_failed; } aps->input_dev->name = "sensors_aps"; aps->input_dev->id.bustype = BUS_I2C; input_set_drvdata(aps->input_dev, aps); ret = input_register_device(aps->input_dev); if (ret) { printk(KERN_ERR "aps_probe: Unable to register %s input device\n", aps->input_dev->name); goto err_input_register_device_failed; } set_bit(EV_ABS, aps->input_dev->evbit); input_set_abs_params(aps->input_dev, ABS_LIGHT, 0, 10240, 0, 0); input_set_abs_params(aps->input_dev, ABS_DISTANCE, 0, 1, 0, 0); ret = misc_register(&light_device); if (ret) { printk(KERN_ERR "aps_12d_probe: light_device register failed\n"); goto err_light_misc_device_register_failed; } ret = misc_register(&proximity_device); if (ret) { printk(KERN_ERR "aps_12d_probe: proximity_device register failed\n"); goto err_proximity_misc_device_register_failed; } if( light_device.minor != MISC_DYNAMIC_MINOR ){ light_device_minor = light_device.minor; } if( proximity_device.minor != MISC_DYNAMIC_MINOR ){ proximity_device_minor = proximity_device.minor ; } wake_lock_init(&proximity_wake_lock, WAKE_LOCK_SUSPEND, "proximity"); hrtimer_init(&aps->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL); aps->timer.function = aps_timer_func; aps_wq = create_singlethread_workqueue("aps_wq"); if (!aps_wq) { ret = -ENOMEM; goto err_create_workqueue_failed; } this_aps_data =aps; ret = set_sensor_input(PS, aps->input_dev->dev.kobj.name); if (ret) { dev_err(&client->dev, "%s set_sensor_input failed\n", __func__); goto err_create_workqueue_failed; } ret = set_sensor_input(ALS, aps->input_dev->dev.kobj.name); if (ret) { dev_err(&client->dev, "%s set_sensor_input failed\n", __func__); goto err_create_workqueue_failed; } /* delete the redundant code */ printk(KERN_INFO "aps_12d_probe: Start Proximity Sensor APS-12D\n"); set_sensors_list(L_SENSOR + P_SENSOR); return 0; err_create_workqueue_failed: misc_deregister(&proximity_device); err_proximity_misc_device_register_failed: misc_deregister(&light_device); err_light_misc_device_register_failed: err_input_register_device_failed: input_free_device(aps->input_dev); err_input_dev_alloc_failed: err_detect_failed: kfree(aps); err_alloc_data_failed: err_check_functionality_failed: #ifdef CONFIG_ARCH_MSM7X30 if(NULL != vreg_gp4) { /* can't use the flag ret here, it will change the return value of probe function */ vreg_disable(vreg_gp4); /* delete a line */ } #endif return ret; }
static void msm_camera_vreg_enable(struct platform_device *pdev) { #if defined(CONFIG_SH_CAMERA) #elif defined(CONFIG_T8EV4) /*----- 1.8v -----*/ vreg_lvsw1 = vreg_get(NULL, "lvsw1"); if (IS_ERR(vreg_lvsw1)) { pr_err("%s: VREG LVSW1 get failed %ld\n", __func__, PTR_ERR(vreg_lvsw1)); vreg_lvsw1 = NULL; return; } if (vreg_set_level(vreg_lvsw1, 1800)) { pr_err("%s: VREG LVSW1 set failed\n", __func__); goto lvsw1_put; } if (vreg_enable(vreg_lvsw1)) { pr_err("%s: VREG LVSW1 enable failed\n", __func__); goto lvsw1_put; } /*----- 2.8v -----*/ vreg_gp9 = vreg_get(NULL, "gp9"); if (IS_ERR(vreg_gp9)) { pr_err("%s: VREG GP9 get failed %ld\n", __func__, PTR_ERR(vreg_gp9)); vreg_gp9 = NULL; goto lvsw1_disable; } if (vreg_set_level(vreg_gp9, 2800)) { pr_err("%s: VREG GP9 set failed\n", __func__); goto gp9_put; } if (vreg_enable(vreg_gp9)) { pr_err("%s: VREG GP9 enable failed\n", __func__); goto gp9_put; } /*----- 3.0v -----*/ vreg_gp2 = vreg_get(NULL, "gp2"); if (IS_ERR(vreg_gp2)) { pr_err("%s: VREG GP2 get failed %ld\n", __func__, PTR_ERR(vreg_gp2)); vreg_gp2 = NULL; goto gp9_disable; } if (vreg_set_level(vreg_gp2, 3000)) { pr_err("%s: VREG GP2 set failed\n", __func__); goto gp2_put; } if (vreg_enable(vreg_gp2)) { pr_err("%s: VREG GP2 enable failed\n", __func__); goto gp2_put; } /*----- 1.225v -----*/ vreg_gp15 = vreg_get(NULL, "gp15"); if (IS_ERR(vreg_gp15)) { pr_err("%s: VREG GP15 get failed %ld\n", __func__, PTR_ERR(vreg_gp15)); vreg_gp15 = NULL; goto gp2_disable; } if (vreg_set_level(vreg_gp15, 1230)) { pr_err("%s: VREG GP15 set failed\n", __func__); goto gp15_put; } if (vreg_enable(vreg_gp15)) pr_err("%s: VREG GP15 enable failed\n", __func__); return; gp15_put: vreg_put(vreg_gp15); vreg_gp15 = NULL; gp2_disable: vreg_disable(vreg_gp2); gp2_put: vreg_put(vreg_gp2); vreg_gp2 = NULL; gp9_disable: vreg_disable(vreg_gp9); gp9_put: vreg_put(vreg_gp9); vreg_gp9 = NULL; lvsw1_disable: vreg_disable(vreg_lvsw1); lvsw1_put: vreg_put(vreg_lvsw1); vreg_lvsw1 = NULL; #else vreg_gp2 = vreg_get(NULL, "gp2"); if (IS_ERR(vreg_gp2)) { pr_err("%s: VREG GP2 get failed %ld\n", __func__, PTR_ERR(vreg_gp2)); vreg_gp2 = NULL; return; } if (vreg_set_level(vreg_gp2, 2600)) { pr_err("%s: VREG GP2 set failed\n", __func__); goto gp2_put; } if (vreg_enable(vreg_gp2)) { pr_err("%s: VREG GP2 enable failed\n", __func__); goto gp2_put; } vreg_lvsw1 = vreg_get(NULL, "lvsw1"); if (IS_ERR(vreg_lvsw1)) { pr_err("%s: VREG LVSW1 get failed %ld\n", __func__, PTR_ERR(vreg_lvsw1)); vreg_lvsw1 = NULL; goto gp2_disable; } if (vreg_set_level(vreg_lvsw1, 1800)) { pr_err("%s: VREG LVSW1 set failed\n", __func__); goto lvsw1_put; } if (vreg_enable(vreg_lvsw1)) { pr_err("%s: VREG LVSW1 enable failed\n", __func__); goto lvsw1_put; } if (!strcmp(pdev->name, "msm_camera_sn12m0pz")) { vreg_gp6 = vreg_get(NULL, "gp6"); if (IS_ERR(vreg_gp6)) { pr_err("%s: VREG GP6 get failed %ld\n", __func__, PTR_ERR(vreg_gp6)); vreg_gp6 = NULL; goto lvsw1_disable; } if (vreg_set_level(vreg_gp6, 3050)) { pr_err("%s: VREG GP6 set failed\n", __func__); goto gp6_put; } if (vreg_enable(vreg_gp6)) { pr_err("%s: VREG GP6 enable failed\n", __func__); goto gp6_put; } vreg_gp16 = vreg_get(NULL, "gp16"); if (IS_ERR(vreg_gp16)) { pr_err("%s: VREG GP16 get failed %ld\n", __func__, PTR_ERR(vreg_gp16)); vreg_gp16 = NULL; goto gp6_disable; } if (vreg_set_level(vreg_gp16, 1200)) { pr_err("%s: VREG GP16 set failed\n", __func__); goto gp16_put; } if (vreg_enable(vreg_gp16)) { pr_err("%s: VREG GP16 enable failed\n", __func__); goto gp16_put; } } return; gp16_put: vreg_put(vreg_gp16); vreg_gp16 = NULL; gp6_disable: vreg_disable(vreg_gp6); gp6_put: vreg_put(vreg_gp6); vreg_gp6 = NULL; lvsw1_disable: vreg_disable(vreg_lvsw1); lvsw1_put: vreg_put(vreg_lvsw1); vreg_lvsw1 = NULL; gp2_disable: vreg_disable(vreg_gp2); gp2_put: vreg_put(vreg_gp2); vreg_gp2 = NULL; #endif /* CONFIG_SH_CAMERA */ }
static int mipi_dsi_panel_power(int on) { int rc = 0; struct vreg *vreg_mipi_dsi_v28; printk("mipi_dsi_panel_power : %d \n", on); if (!dsi_gpio_initialized) { /*Resetting LCD Panel*/ rc = gpio_request(GPIO_LCD_RESET, "lcd_reset"); if (rc) { pr_err("%s: gpio_request GPIO_LCD_RESET failed\n", __func__); } rc = gpio_tlmm_config(GPIO_CFG(GPIO_LCD_RESET, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), GPIO_CFG_ENABLE); if (rc) { printk(KERN_ERR "%s: Failed to configure GPIO %d\n", __func__, rc); } dsi_gpio_initialized = 1; } vreg_mipi_dsi_v28 = vreg_get(0, "emmc"); if (IS_ERR(vreg_mipi_dsi_v28)) { pr_err("%s: vreg_get for emmc failed\n", __func__); return PTR_ERR(vreg_mipi_dsi_v28); } if (on) { rc = vreg_set_level(vreg_mipi_dsi_v28, 2800); if (rc) { pr_err("%s: vreg_set_level failed for mipi_dsi_v28\n", __func__); goto vreg_put_dsi_v28; } rc = vreg_enable(vreg_mipi_dsi_v28); if (rc) { pr_err("%s: vreg_enable failed for mipi_dsi_v28\n", __func__); goto vreg_put_dsi_v28; } rc = gpio_direction_output(GPIO_LCD_RESET, 1); if (rc) { pr_err("%s: gpio_direction_output failed for lcd_reset\n", __func__); goto vreg_put_dsi_v28; } if (Isfirstbootend) { printk("gpio lcd reset on...\n"); msleep(10); gpio_set_value(GPIO_LCD_RESET, 0); msleep(10); gpio_set_value(GPIO_LCD_RESET, 1); } else { Isfirstbootend = 1; } msleep(10); } else { rc = vreg_disable(vreg_mipi_dsi_v28); if (rc) { pr_err("%s: vreg_disable failed for mipi_dsi_v28\n", __func__); goto vreg_put_dsi_v28; } } vreg_put_dsi_v28: vreg_put(vreg_mipi_dsi_v28); return rc; }
static int ft5306_power_up(void) { int rc = -1; struct vreg *vreg = NULL; #if defined(CONFIG_LCT_AW551) vreg = vreg_get(NULL, "rfrx1"); //L1 #elif defined(CONFIG_LCT_AW550) vreg = vreg_get(NULL, "gp2"); //L12 #else vreg = vreg_get(NULL, "gp2"); //L12 #endif if (IS_ERR(vreg)) { pr_err("%s: vreg get failed (%ld)\n",__func__, PTR_ERR(vreg)); return PTR_ERR(vreg); } rc = vreg_set_level(vreg, 2850); if (rc < 0) { pr_err("%s: vreg set level failed (%d)\n",__func__, rc); } rc = vreg_enable(vreg); if (rc < 0) { pr_err("%s: vreg enable failed (%d)\n", __func__, rc); return rc; } msleep(100); printk(KERN_INFO "%s: Power VCC success\n", __func__); #if 1 #if defined(CONFIG_LCT_AW551) vreg = vreg_get(NULL, "wlan_tcx0"); //L11 #elif defined(CONFIG_LCT_AE550) vreg = vreg_get(NULL, "msme1"); //s3 #elif defined(CONFIG_LCT_AW550) vreg = vreg_get(NULL, "wlan_tcx0"); //L11 #else vreg = vreg_get(NULL, "wlan_tcx0"); //L11 #endif if (IS_ERR(vreg)) { pr_err("%s: vreg get failed (%ld)\n",__func__, PTR_ERR(vreg)); return PTR_ERR(vreg); } rc = vreg_set_level(vreg, 1800); if (rc < 0) { pr_err("%s: vreg set level failed (%d)\n",__func__, rc); } rc = vreg_enable(vreg); if (rc < 0) { pr_err("%s: vreg enable failed (%d)\n", __func__, rc); return rc; } msleep(100); printk(KERN_INFO "%s: Power iovdd success\n", __func__); #endif return rc ; }
int vreg_set_level(struct vreg *vreg, unsigned mv) { unsigned id = vreg->id; #if defined(CONFIG_MSM_AMSS_VERSION_WINCE) struct msm_dex_command dex = { .cmd = DEX_PMIC_REG_VOLTAGE, .has_data = 1, .data = (1U << id) }; // This reg appears to only be used by vreg_set_level() writel(mv, MSM_SHARED_RAM_BASE + 0xfc130); pr_debug("%s %d -> %u\n", __func__, id, mv); vreg->status = msm_dex_comm(&dex, 0); #else vreg->status = msm_proc_comm(PCOM_VREG_SET_LEVEL, &id, &mv); #endif return vreg->status; } #if defined(CONFIG_DEBUG_FS) static int vreg_debug_set(void *data, u64 val) { struct vreg *vreg = data; switch (val) { case 0: vreg_disable(vreg); break; case 1: vreg_enable(vreg); break; default: vreg_set_level(vreg, val); break; } return 0; } static int vreg_debug_get(void *data, u64 *val) { struct vreg *vreg = data; if (!vreg->status) *val = 0; else *val = 1; return 0; } static int vreg_debug_count_set(void *data, u64 val) { struct vreg *vreg = data; if (val > UINT_MAX) val = UINT_MAX; vreg->refcnt = val; return 0; } static int vreg_debug_count_get(void *data, u64 *val) { struct vreg *vreg = data; *val = vreg->refcnt; return 0; } DEFINE_SIMPLE_ATTRIBUTE(vreg_fops, vreg_debug_get, vreg_debug_set, "%llu\n"); DEFINE_SIMPLE_ATTRIBUTE(vreg_count_fops, vreg_debug_count_get, vreg_debug_count_set, "%llu\n"); static int __init vreg_debug_init(void) { struct dentry *dent; int n; char name[32]; const char *refcnt_name = "_refcnt"; dent = debugfs_create_dir("vreg", 0); if (IS_ERR(dent)) return 0; for (n = 0; n < ARRAY_SIZE(vregs); n++) { (void) debugfs_create_file(vregs[n].name, 0644, dent, vregs + n, &vreg_fops); strlcpy(name, vregs[n].name, sizeof(name)); strlcat(name, refcnt_name, sizeof(name)); (void) debugfs_create_file(name, 0644, dent, vregs + n, &vreg_count_fops); } return 0; } device_initcall(vreg_debug_init);
static uint32_t msm_sdcc_setup_power(struct device *dv, unsigned int vdd) { int rc = 0; struct platform_device *pdev; static int first_setup = 1; pdev = container_of(dv, struct platform_device, dev); msm_sdcc_setup_gpio(pdev->id, !!vdd); if (vdd == 0) { if (!vreg_sts) return 0; clear_bit(pdev->id, &vreg_sts); if (!vreg_sts) { if (machine_is_msm7x25_ffa() || machine_is_msm7x27_ffa()) { rc = mpp_config_digital_out(mpp_mmc, MPP_CFG(MPP_DLOGIC_LVL_MSMP, MPP_DLOGIC_OUT_CTRL_LOW)); } else rc = vreg_disable(vreg_mmc); if (rc) printk(KERN_ERR "%s: return val: %d \n", __func__, rc); } return 0; } if (!vreg_sts) { if (machine_is_msm7x25_ffa() || machine_is_msm7x27_ffa()) { rc = mpp_config_digital_out(mpp_mmc, MPP_CFG(MPP_DLOGIC_LVL_MSMP, MPP_DLOGIC_OUT_CTRL_HIGH)); } else { #ifdef CONFIG_MMC_MSM_CARD_HW_DETECTION rc = vreg_set_level(vreg_mmc, VREG_SD_LEVEL); #else rc = vreg_set_level(vreg_mmc, 2850); #endif if (!rc) rc = vreg_enable(vreg_mmc); } if (rc) printk(KERN_ERR "%s: return val: %d \n", __func__, rc); } set_bit(pdev->id, &vreg_sts); /* if first called related to sdcc1, irq should be registered as wakeup source * cleaneye.kim, 2010-02-19 */ #if 0 if (first_setup == 1) { struct mmc_platform_data *pdata = pdev->dev.platform_data; if (pdev->id == 1) { first_setup = 0; set_irq_wake(pdata->status_irq, 1); } } #endif return 0; }
static int fm_radio_setup(struct marimba_fm_platform_data *pdata) { int rc = 0; const char *id = "FMPW"; uint32_t irqcfg; struct marimba config = { .mod_id = SLAVE_ID_BAHAMA}; u8 value; /* Voting for 1.8V Regulator */ fm_regulator = vreg_get(NULL , "msme1"); if (IS_ERR(fm_regulator)) { pr_err("%s: vreg get failed with : (%ld)\n", __func__, PTR_ERR(fm_regulator)); return -EINVAL; } /* Set the voltage level to 1.8V */ rc = vreg_set_level(fm_regulator, 1800); if (rc < 0) { pr_err("%s: set regulator level failed with :(%d)\n", __func__, rc); goto fm_vreg_fail; } /* Enabling the 1.8V regulator */ rc = vreg_enable(fm_regulator); if (rc) { pr_err("%s: enable regulator failed with :(%d)\n", __func__, rc); goto fm_vreg_fail; } /* Voting for 19.2MHz clock */ rc = pmapp_clock_vote(id, PMAPP_CLOCK_ID_D1, PMAPP_CLOCK_VOTE_ON); if (rc < 0) { pr_err("%s: clock vote failed with :(%d)\n", __func__, rc); goto fm_clock_vote_fail; } rc = bt_set_gpio(1); if (rc) { pr_err("%s: bt_set_gpio = %d", __func__, rc); goto fm_gpio_config_fail; } /*re-write FM Slave Id, after reset*/ value = BAHAMA_SLAVE_ID_FM_ADDR; rc = marimba_write_bit_mask(&config, BAHAMA_SLAVE_ID_FM_REG, &value, 1, 0xFF); if (rc < 0) { pr_err("%s: FM Slave ID rewrite Failed = %d", __func__, rc); goto fm_gpio_config_fail; } /* Configuring the FM GPIO */ irqcfg = GPIO_CFG(FM_GPIO, 0, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA); rc = gpio_tlmm_config(irqcfg, GPIO_CFG_ENABLE); if (rc) { pr_err("%s: gpio_tlmm_config(%#x)=%d\n", __func__, irqcfg, rc); goto fm_gpio_config_fail; } return 0; fm_gpio_config_fail: pmapp_clock_vote(id, PMAPP_CLOCK_ID_D1, PMAPP_CLOCK_VOTE_OFF); bt_set_gpio(0); fm_clock_vote_fail: vreg_disable(fm_regulator); fm_vreg_fail: vreg_put(fm_regulator); return rc; };
static int avago_ofn_probe(struct platform_device *pdev) { int rc; struct vreg *vreg_ofn; #if 0 struct clk *clk; clk = clk_get(NULL, "i2c_clk"); if (IS_ERR(clk)) { dev_err(&pdev->dev, "Could not get clock\n"); rc = PTR_ERR(clk); goto fail_ofn_config; } clk_enable(clk); #endif printk("chenjun: avago_ofn_probe: SHUTDOWN = %d\n", gpio_get_value(GPIO_OFN_SHUTDOWN)); printk("chenjun: avago_ofn_probe: RESET = %d\n", gpio_get_value(GPIO_OFN_RESET)); printk("chenjun: avago_ofn_probe: SHUTDOWN = %d\n", gpio_get_value(GPIO_OFN_SHUTDOWN)); gpio_direction_output(GPIO_OFN_SHUTDOWN, 1); gpio_direction_output(GPIO_OFN_RESET, 1); printk("chenjun: avago_ofn_probe: SHUTDOWN = %d\n", gpio_get_value(GPIO_OFN_SHUTDOWN)); printk("chenjun: avago_ofn_probe: RESET = %d\n", gpio_get_value(GPIO_OFN_RESET)); mdelay(503); #if 1 vreg_ofn = vreg_get(NULL, "msmp"); if (IS_ERR(vreg_ofn)) { printk(KERN_ERR "%s: vreg get failed (%ld)\n", __func__, PTR_ERR(vreg_ofn)); return -EIO; } rc = vreg_set_level(vreg_ofn, 2800); if (rc) { printk(KERN_ERR "%s: vreg set level failed (%d)\n", __func__, rc); return -EIO; } rc = vreg_enable(vreg_ofn); if (rc) { printk(KERN_ERR "%s: vreg enable failed (%d)\n", __func__, rc); return -EIO; } mdelay(1000); #endif gpio_direction_output(32, 0); printk("chenjun: avago_ofn_probe: isp = %d\n", gpio_get_value(32)); rc = gpio_direction_input(GPIO_OFN_MOTION); if (rc) { printk("avago_ofn_probe FAILED: gpio_direction_input(%d), rc=%d\n", GPIO_OFN_MOTION, rc); goto fail_irq; } rc = request_irq(GPIO_OFN_MOTION_INT, &ofn_interrupt, IRQF_TRIGGER_LOW, "ofn", 0); if (rc) { printk("avago_ofn_probe FAILED: request_irq rc=%d\n", rc); goto fail_irq; } #if 1 gpio_direction_output(GPIO_OFN_SHUTDOWN, 0); gpio_direction_output(GPIO_OFN_RESET, 0); udelay(29); // Minimum: 20us gpio_direction_output(GPIO_OFN_RESET, 1); printk("avago_ofn_probe: SHUTDOWN = %d\n", gpio_get_value(GPIO_OFN_SHUTDOWN)); printk("avago_ofn_probe: RESET = %d\n", gpio_get_value(GPIO_OFN_RESET)); mdelay(103); // Minimum: 100ms #endif rc = ofn_config(); if (rc) { printk("avago_ofn_probe FAILED: ofn_config: rc=%d\n", rc); goto fail_ofn_config; } return 0; fail_ofn_config: fail_irq: return rc; }
static void mddi_novatec_power(struct msm_mddi_client_data *client_data, int on) { unsigned pulldown = 1; if (panel_type == 0) { if (on) { if(axi_clk) clk_set_rate(axi_clk, 192000000); vreg_enable(vreg_ldo20); hr_msleep(5); vreg_disable(vreg_ldo20); hr_msleep(55); gpio_set_value(GLACIER_LCD_2V85_EN, 1); /* OJ_2V85*/ vreg_enable(vreg_ldo12); hr_msleep(1); vreg_enable(vreg_ldo20); hr_msleep(2); vreg_enable(vreg_ldo19); hr_msleep(2); gpio_set_value(GLACIER_MDDI_RSTz, 1); hr_msleep(2); gpio_set_value(GLACIER_MDDI_RSTz, 0); hr_msleep(2); gpio_set_value(GLACIER_MDDI_RSTz, 1); hr_msleep(65); } else { hr_msleep(130); gpio_set_value(GLACIER_MDDI_RSTz, 0); hr_msleep(15); vreg_disable(vreg_ldo20); hr_msleep(15); vreg_disable(vreg_ldo19); /* OJ_2V85*/ vreg_disable(vreg_ldo12); gpio_set_value(GLACIER_LCD_2V85_EN, 0); msm_proc_comm(PCOM_VREG_PULLDOWN, &pulldown, &vreg_ldo20->id); msm_proc_comm(PCOM_VREG_PULLDOWN, &pulldown, &vreg_ldo19->id); msm_proc_comm(PCOM_VREG_PULLDOWN, &pulldown, &vreg_ldo12->id); } } else { if (on) { if(axi_clk) clk_set_rate(axi_clk, 192000000); vreg_enable(vreg_ldo20); hr_msleep(5); vreg_disable(vreg_ldo20); hr_msleep(55); gpio_set_value(GLACIER_LCD_2V85_EN, 1); /* OJ_2V85*/ vreg_enable(vreg_ldo12); hr_msleep(1); vreg_enable(vreg_ldo20); hr_msleep(2); vreg_enable(vreg_ldo19); hr_msleep(2); gpio_set_value(GLACIER_MDDI_RSTz, 1); hr_msleep(2); gpio_set_value(GLACIER_MDDI_RSTz, 0); hr_msleep(2); gpio_set_value(GLACIER_MDDI_RSTz, 1); hr_msleep(65); } else { hr_msleep(130); gpio_set_value(GLACIER_MDDI_RSTz, 0); hr_msleep(15); vreg_disable(vreg_ldo20); hr_msleep(15); vreg_disable(vreg_ldo19); /* OJ_2V85*/ vreg_disable(vreg_ldo12); gpio_set_value(GLACIER_LCD_2V85_EN, 0); msm_proc_comm(PCOM_VREG_PULLDOWN, &pulldown, &vreg_ldo20->id); msm_proc_comm(PCOM_VREG_PULLDOWN, &pulldown, &vreg_ldo19->id); msm_proc_comm(PCOM_VREG_PULLDOWN, &pulldown, &vreg_ldo12->id); } } }
static int synaptics_ts_probe( struct i2c_client *client, const struct i2c_device_id *id) { struct synaptics_ts_data *ts; int ret = 0; struct vreg *vreg_touch; printk("[TSP] %s, %d\n", __func__, __LINE__ ); tsp_ready=0; vreg_touch = vreg_get(NULL, "ldo6"); ret = vreg_set_level(vreg_touch, OUT2800mV); if (ret) { printk(KERN_ERR "%s: vreg set level failed (%d)\n", __func__, ret); return -EIO; } ret = vreg_enable(vreg_touch); if (ret) { printk(KERN_ERR "%s: vreg enable failed (%d)\n", __func__, ret); return -EIO; } msleep(100); gpio_configure( VTOUCH_EN, GPIOF_OUTPUT_HIGH ); //I2C Pullup 2.6V gpio_set_value( VTOUCH_EN, 1 ); msleep(100); ts = kzalloc(sizeof(*ts), GFP_KERNEL); if (ts == NULL) { ret = -ENOMEM; goto err_alloc_data_failed; } INIT_WORK(&ts->work, synaptics_ts_work_func); ts->client = client; i2c_set_clientdata(client, ts); ts_global = ts; ts->input_dev = input_allocate_device(); if (ts->input_dev == NULL) { ret = -ENOMEM; printk(KERN_ERR "synaptics_ts_probe: Failed to allocate input device\n"); goto err_input_dev_alloc_failed; } ts->input_dev->name = "synaptics-rmi-touchscreen"; set_bit(EV_SYN, ts->input_dev->evbit); set_bit(EV_KEY, ts->input_dev->evbit); set_bit(BTN_TOUCH, ts->input_dev->keybit); set_bit(EV_ABS, ts->input_dev->evbit); printk(KERN_INFO "synaptics_ts_probe: max_x: %d, max_y: %d\n", MAX_X, MAX_Y); input_set_abs_params(ts->input_dev, ABS_MT_WIDTH_MAJOR, 0, 255, 0, 0); input_set_abs_params(ts->input_dev, ABS_MT_POSITION_X, 0, MAX_X, 0, 0); input_set_abs_params(ts->input_dev, ABS_MT_POSITION_Y, 0, MAX_Y, 0, 0); input_set_abs_params(ts->input_dev, ABS_MT_TOUCH_MAJOR, 0, 255, 0, 0); /* ts->input_dev->name = ts->keypad_info->name; */ ret = input_register_device(ts->input_dev); if (ret) { printk(KERN_ERR "synaptics_ts_probe: Unable to register %s input device\n", ts->input_dev->name); goto err_input_register_device_failed; } printk("[TSP] %s, irq=%d\n", __func__, client->irq ); if (client->irq) { ret = request_irq(client->irq, synaptics_ts_irq_handler,/* IRQF_TRIGGER_RISING |*/ IRQF_TRIGGER_FALLING , client->name, ts); if (ret == 0) ts->use_irq = 1; else dev_err(&client->dev, "request_irq failed\n"); } #ifdef CONFIG_HAS_EARLYSUSPEND ts->early_suspend.level = EARLY_SUSPEND_LEVEL_DISABLE_FB; //CHJ origin ts->early_suspend.level = EARLY_SUSPEND_LEVEL_BLANK_SCREEN + 1; ts->early_suspend.suspend = synaptics_ts_early_suspend; ts->early_suspend.resume = synaptics_ts_late_resume; register_early_suspend(&ts->early_suspend); #endif printk(KERN_INFO "synaptics_ts_probe: Start touchscreen %s in %s mode\n", ts->input_dev->name, ts->use_irq ? "interrupt" : "polling"); /* sys fs */ touch_class = class_create(THIS_MODULE, "touch"); if (IS_ERR(touch_class)) pr_err("Failed to create class(touch)!\n"); firmware_dev = device_create(touch_class, NULL, 0, NULL, "firmware"); if (IS_ERR(firmware_dev)) pr_err("Failed to create device(firmware)!\n"); if (device_create_file(firmware_dev, &dev_attr_firmware) < 0) pr_err("Failed to create device file(%s)!\n", dev_attr_firmware.attr.name); if (device_create_file(firmware_dev, &dev_attr_firmware_ret) < 0) pr_err("Failed to create device file(%s)!\n", dev_attr_firmware_ret.attr.name); /* sys fs */ /* Check point - i2c check - start */ ret = read_ver(); if( !(HW_ver == 0x02 || HW_ver == 0x05 || HW_ver == 0x08 || HW_ver == 0x06 || HW_ver == 0x09 || HW_ver == 0x40 ) ) { if( board_hw_revision == 4 ){ HW_ver = 0x40; msleep(1000); firm_update(); } else printk("[TSP] %s, board_hw_revision=%d\n", __func__, board_hw_revision); } if (ret <= 0) { printk("[TSP] %s, ln=%d, Error\n", __func__, __LINE__ ); ret = read_ver(); if (ret <= 0) { printk("[TSP] %s, ln:%d, Failed to register TSP!!!\n\tcheck the i2c line!!!, ret=%d\n", __func__,__LINE__, ret); goto err_check_functionality_failed; } } /* Check point - i2c check - end */ #if 0//CHJ /* Check point - firmware ver check - start */ if(board_hw_revision == 0x02){ if( (HW_ver==0x08)&&(SW_ver<0x11) ){ printk(KERN_INFO "[TSP] board_rev=%d, TSP HW_ver=%2x, SW_ver=%2x\n", board_hw_revision, HW_ver, SW_ver); firm_update(); } } if(board_hw_revision == 0x03){ if( (HW_ver==HEX_HW_VER)&&(SW_ver<HEX_SW_VER) ){ printk(KERN_INFO "[TSP] board_rev=%d, TSP HW_ver=%2x, SW_ver=%2x\n", board_hw_revision, HW_ver, SW_ver); firm_update(); } } /* Check point - firmware ver check - end */ #endif return 0; err_input_register_device_failed: input_free_device(ts->input_dev); err_input_dev_alloc_failed: kfree(ts); err_alloc_data_failed: err_check_functionality_failed: return ret; }
int tsp_reset( void ) { int ret=0; struct vreg *vreg_touch; printk("[TSP] %s+\n", __func__ ); vreg_touch = vreg_get(NULL, "ldo6"); if (ts_global->use_irq) { disable_irq(ts_global->client->irq); } ret = vreg_disable(vreg_touch); msleep(10); if (ret) { printk(KERN_ERR "%s: vreg enable failed (%d)\n", __func__, ret); ret=-EIO; goto tsp_reset_out; } gpio_configure( TSP_SCL, GPIOF_DRIVE_OUTPUT ); gpio_configure( TSP_SDA, GPIOF_DRIVE_OUTPUT ); gpio_configure( TSP_INT, GPIOF_INPUT ); gpio_set_value( VTOUCH_EN , 0 ); //I2C Pullup msleep(10); gpio_set_value( TSP_SCL , 0 ); gpio_set_value( TSP_SDA , 0 ); gpio_set_value( TSP_INT , 0 ); msleep(200); gpio_set_value( TSP_SCL , 1 ); gpio_set_value( TSP_SDA , 1 ); gpio_set_value( TSP_INT , 1 ); gpio_set_value( VTOUCH_EN , 1 ); //I2C Pullup ret = vreg_enable(vreg_touch); if (ret) { printk(KERN_ERR "%s: vreg enable failed (%d)\n", __func__, ret); ret=-EIO; goto tsp_reset_out; } msleep(200); tsp_reset_out: if (ts_global->use_irq) { enable_irq(ts_global->client->irq); } printk("[TSP] %s-\n", __func__ ); return ret; }
static int cam_hw_init() { int rc = 0; struct vreg *vreg_L8; int test_value; pr_info("[sr030pc30] %s/%d\n", __func__, __LINE__); gpio_tlmm_config( GPIO_CFG(CAM_RESET, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), GPIO_CFG_ENABLE);/*CAM_RESET*/ gpio_tlmm_config( GPIO_CFG(CAM_STANDBY, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), GPIO_CFG_ENABLE);/*CAM_STANDBY*/ gpio_tlmm_config( GPIO_CFG(CAM_EN, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), GPIO_CFG_ENABLE);/*CAM_EN*/ gpio_tlmm_config( GPIO_CFG(CAM_EN_2, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), GPIO_CFG_ENABLE); /*CAM_EN_2*/ gpio_tlmm_config( GPIO_CFG(CAM_VT_RST, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), GPIO_CFG_ENABLE);/*CAM_VT_RST*/ gpio_tlmm_config( GPIO_CFG(CAM_VT_nSTBY, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), GPIO_CFG_ENABLE); vreg_L8 = vreg_get(NULL, "gp7"); vreg_set_level(vreg_L8, 1800); gpio_set_value(CAM_RESET, 0); gpio_set_value(CAM_STANDBY, 0); gpio_set_value(CAM_EN, 0); gpio_set_value(CAM_EN_2, 0); gpio_set_value(CAM_VT_RST, 0); gpio_set_value(CAM_VT_nSTBY, 0); usleep(1000); gpio_set_value(CAM_EN, 1); /*CAM_A_2.8V //CAM_EN->UP*/ usleep(1000); vreg_enable(vreg_L8); usleep(1000); gpio_set_value(CAM_EN_2, 1); /*CAM_IO, CAM_D, EN_2->UP*/ usleep(1000); gpio_set_value(CAM_VT_nSTBY, 1); /*VGA_STBY UP*/ usleep(1000); gpio_tlmm_config(GPIO_CFG(CAM_MCLK, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_14MA), GPIO_CFG_ENABLE); /*CAM_MCLK*/ msm_camio_clk_rate_set(24000000); /*MCLK*/ msm_camio_camif_pad_reg_reset(); usleep(1000); gpio_set_value(CAM_STANDBY, 1); /*3M_STBY UP*/ usleep(10000); gpio_set_value(CAM_RESET, 1); /*3M_RESET UP*/ usleep(10000); gpio_set_value(CAM_STANDBY, 0); /*3M_STBY DOWN*/ usleep(1000); gpio_set_value(CAM_VT_RST, 1); /*VGA_RESET UP*/ usleep(50000); return rc; }
static int __devinit st1232_ts_probe( struct i2c_client *client, const struct i2c_device_id *id) { struct input_dev *input_dev; int ret = 0; printk("[Bing][%s]\r\n", __func__); if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) { printk("[Bing][%s] st1232_ts_probe: need I2C_FUNC_I2C\r\n", __func__); ret = -ENODEV; goto err_check_functionality_failed; } ret = gpio_request(93,"touch_int"); if(ret < 0) printk("fail to request gpio93 for touch_int! error = %d\n",ret); printk("[Bing]After %s: TOUCH_GPIO93 = %d\n",__func__,gpio_get_value(93) ); gpio_set_value(93, 1); ret = gpio_request(TOUCH_GPIO,"touch_int"); if(ret < 0) printk("fail to request gpio for touch_int! error = %d\n",ret); printk("[Bing]Before %s: TOUCH_GPIO94 = %d\n",__func__,gpio_get_value(TOUCH_GPIO) ); printk("[Bing]After %s: TOUCH_GPIO94 = %d\n",__func__,gpio_get_value(TOUCH_GPIO) ); gpio_direction_output(TOUCH_GPIO, 1); #if 0 printk("%s: TOUCH_GPIO = %d\n",__func__,gpio_get_value(TOUCH_GPIO) ); mdelay(20); vreg_ruim = vreg_get(NULL, "ruim"); vreg_disable(vreg_ruim); mdelay(20); vreg_set_level(vreg_ruim,2600); vreg_enable(vreg_ruim); mdelay(20); vreg_disable(vreg_ruim); mdelay(20); vreg_enable(vreg_ruim); mdelay(200); #endif st1232_ts = (struct st1232_ts_data *)kzalloc(sizeof(struct st1232_ts_data), GFP_KERNEL); st1232_ts->input_dev = input_allocate_device(); if (!st1232_ts->input_dev || !st1232_ts) { ret = -ENOMEM; goto err_input; } INIT_WORK(&st1232_ts->ts_event_work, st1232_ts_irq_worker); //init st1232_ts->prev_touches = 0; st1232_ts->client = client; st1232_ts->irq = MSM_GPIO_TO_INT(TOUCH_GPIO); st1232_ts->isp_enabled = false; atomic_set(&st1232_ts->irq_disable, 1); i2c_set_clientdata(client, st1232_ts); input_dev = st1232_ts->input_dev; input_dev->name = "st1232-ts"; input_dev->phys = "msm_touch/input0"; input_dev->id.bustype = BUS_HOST; input_dev->id.vendor = 0x0001; input_dev->id.product = 0x0002; input_dev->id.version = 0x0100; input_dev->dev.parent = &st1232_ts->client->dev; /* input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS); input_dev->absbit[0] = BIT(ABS_X) | BIT(ABS_Y) | BIT(ABS_PRESSURE); input_dev->absbit[BIT_WORD(ABS_MISC)] = BIT_MASK(ABS_MISC); input_dev->keybit[BIT_WORD(BTN_TOUCH)] |= BIT_MASK(BTN_TOUCH); */ set_bit(EV_ABS, input_dev->evbit); set_bit(ABS_X, input_dev->absbit); set_bit(ABS_Y, input_dev->absbit); set_bit(ABS_PRESSURE, input_dev->absbit); set_bit(ABS_MISC, input_dev->absbit); set_bit(EV_KEY, input_dev->evbit); set_bit(BTN_TOUCH, input_dev->keybit); /* input_set_capability(input_dev,EV_KEY, KEY_HOME); input_set_capability(input_dev,EV_KEY, KEY_SEARCH); input_set_capability(input_dev,EV_KEY, KEY_BACK); input_set_capability(input_dev,EV_KEY, KEY_MENU);*/ /* set_bit(EV_SYN, st1232_ts->input_dev->evbit); set_bit(EV_ABS, st1232_ts->input_dev->evbit); set_bit(EV_KEY, st1232_ts->input_dev->evbit); set_bit(ABS_MT_TOUCH_MAJOR, st1232_ts->input_dev->keybit); set_bit(KEY_BACK, st1232_ts->input_dev->keybit); set_bit(0xE5, st1232_ts->input_dev->keybit); set_bit(KEY_SEARCH, st1232_ts->input_dev->keybit); */ //#if 0 input_set_capability(input_dev,EV_KEY, KEY_HOME); input_set_capability(input_dev,EV_KEY, KEY_SEARCH); input_set_capability(input_dev,EV_KEY, KEY_BACK); input_set_capability(input_dev,EV_KEY, KEY_MENU); //#endif input_set_abs_params(input_dev, ABS_MT_TOUCH_MAJOR,0, 1, 0, 0); input_set_abs_params(input_dev, ABS_MT_WIDTH_MAJOR,0, 320, 0, 0); input_set_abs_params(input_dev, ABS_MT_POSITION_X, 0, 320, 0, 0); input_set_abs_params(input_dev, ABS_MT_POSITION_Y, 0, 480, 0, 0); input_set_abs_params(input_dev, ABS_PRESSURE, 0, 255, 0, 0); //printk("[Bing][%s] st1232_ts->input_dev = 0x%x\r\n", __func__, st1232_ts->input_dev); ret = input_register_device(st1232_ts->input_dev); if (ret) { printk("[Bing][%s] input_register_device(st1232_ts->input_dev) fail\r\n", __func__); goto err_register; } input_set_drvdata(st1232_ts->input_dev, st1232_ts); setup_timer(&st1232_ts->timer,st1232_ts_timer,st1232_ts); ret = request_irq(st1232_ts->irq, st1232_ts_interrupt, IRQF_TRIGGER_LOW, "touchscreen", NULL); if (ret < 0) { dev_err(&st1232_ts->client->dev, "Failed to register interrupt\n"); goto err_irq; } return 0; err_register: input_free_device(st1232_ts->input_dev); err_irq: input_unregister_device(st1232_ts->input_dev); st1232_ts->input_dev = NULL; err_input: return ret; err_check_functionality_failed: return ret; }
int tsp_reset( void ) { int ret = 1; int key = 0; struct vreg *vreg_touch; printk("[TSP] %s+\n", __func__ ); vreg_touch = vreg_get(NULL, "maxldo06"); // for TSK for(key = 0; key < MAX_KEYS ; key++) touchkey_status[key] = TK_STATUS_RELEASE; if (ts_global->use_irq) { disable_irq(ts_global->client->irq); } ret = vreg_disable(vreg_touch); msleep(10); if (ret) { printk(KERN_ERR "%s: vreg enable failed (%d)\n", __func__, ret); ret=-EIO; goto tsp_reset_out; } #if 0 gpio_configure( TSP_SCL, GPIOF_DRIVE_OUTPUT ); gpio_configure( TSP_SDA, GPIOF_DRIVE_OUTPUT ); gpio_configure( TSP_INT, GPIOF_INPUT ); gpio_tlmm_config(GPIO_CFG( TSP_SCL, 0, GPIO_OUTPUT, GPIO_PULL_UP,GPIO_2MA), GPIO_ENABLE); gpio_tlmm_config(GPIO_CFG( TSP_SDA, 0, GPIO_OUTPUT, GPIO_PULL_UP,GPIO_2MA), GPIO_ENABLE); gpio_tlmm_config(GPIO_CFG( TSP_INT, 0, GPIO_OUTPUT, GPIO_PULL_UP,GPIO_2MA), GPIO_ENABLE); #endif msleep(10); gpio_set_value( TSP_SCL , 0 ); gpio_set_value( TSP_SDA , 0 ); gpio_set_value( TSP_INT , 0 ); msleep( 5 ); gpio_set_value( TSP_SCL , 1 ); gpio_set_value( TSP_SDA , 1 ); gpio_set_value( TSP_INT , 1 ); ret = vreg_enable(vreg_touch); if (ret) { printk(KERN_ERR "%s: vreg enable failed (%d)\n", __func__, ret); ret=-EIO; goto tsp_reset_out; } msleep(200); tsp_reset_out: if (ts_global->use_irq) { enable_irq(ts_global->client->irq); } printk("[TSP] %s-\n", __func__ ); return ret; }
static void mddi_novatec_power(struct msm_mddi_client_data *client_data, int on) { int rc; unsigned config; if (panel_type == 0) { if (on) { if(axi_clk) clk_set_rate(axi_clk, 192000000); vreg_enable(V_LCM_2V85); vreg_enable(V_LCMIO_1V8); hr_msleep(20); gpio_set_value(LEXIKONCT_LCD_RSTz, 1); hr_msleep(25); gpio_set_value(LEXIKONCT_LCD_RSTz, 0); hr_msleep(10); gpio_set_value(LEXIKONCT_LCD_RSTz, 1); hr_msleep(20); } else { vreg_disable(V_LCMIO_1V8); vreg_disable(V_LCM_2V85); gpio_set_value(LEXIKONCT_LCD_RSTz, 0); } } else { if (on) { if(axi_clk) clk_set_rate(axi_clk, 192000000); vreg_enable(V_LCM_2V85); hr_msleep(3); vreg_disable(V_LCM_2V85); hr_msleep(50); vreg_enable(V_LCM_2V85); vreg_enable(V_LCMIO_1V8); hr_msleep(2); gpio_set_value(LEXIKONCT_LCD_RSTz, 1); hr_msleep(1); gpio_set_value(LEXIKONCT_LCD_RSTz, 0); hr_msleep(1); gpio_set_value(LEXIKONCT_LCD_RSTz, 1); hr_msleep(60); config = PCOM_GPIO_CFG(LEXIKONCT_MDDI_TE, 1, GPIO_INPUT, GPIO_PULL_DOWN, GPIO_2MA); rc = msm_proc_comm(PCOM_RPC_GPIO_TLMM_CONFIG_EX, &config, 0); config = PCOM_GPIO_CFG(LEXIKONCT_LCD_ID1, 1, GPIO_INPUT, GPIO_NO_PULL, GPIO_2MA); rc = msm_proc_comm(PCOM_RPC_GPIO_TLMM_CONFIG_EX, &config, 0); config = PCOM_GPIO_CFG(LEXIKONCT_LCD_ID0, 1, GPIO_INPUT, GPIO_NO_PULL, GPIO_2MA); rc = msm_proc_comm(PCOM_RPC_GPIO_TLMM_CONFIG_EX, &config, 0); } else { config = PCOM_GPIO_CFG(LEXIKONCT_MDDI_TE, 0, GPIO_OUTPUT, GPIO_PULL_DOWN, GPIO_2MA); rc = msm_proc_comm(PCOM_RPC_GPIO_TLMM_CONFIG_EX, &config, 0); config = PCOM_GPIO_CFG(LEXIKONCT_LCD_ID1, 0, GPIO_INPUT, GPIO_PULL_DOWN, GPIO_2MA); rc = msm_proc_comm(PCOM_RPC_GPIO_TLMM_CONFIG_EX, &config, 0); config = PCOM_GPIO_CFG(LEXIKONCT_LCD_ID0, 0, GPIO_INPUT, GPIO_PULL_DOWN, GPIO_2MA); rc = msm_proc_comm(PCOM_RPC_GPIO_TLMM_CONFIG_EX, &config, 0); gpio_set_value(LEXIKONCT_LCD_RSTz, 0); hr_msleep(10); vreg_disable(V_LCMIO_1V8); vreg_disable(V_LCM_2V85); } } }
static int synaptics_ts_probe( struct i2c_client *client, const struct i2c_device_id *id) { struct synaptics_ts_data *ts; int ret = 0; int key = 0; struct vreg *vreg_touch; uint8_t i2c_addr = 0x1B; uint8_t buf_tmp[3]={0,}; HW_ver = 0; SW_ver = 0; printk("[TSP] %s, %d\n", __func__, __LINE__ ); vreg_touch = vreg_get(NULL, "maxldo06"); ret = vreg_set_level(vreg_touch, OUT3000mV); if (ret) { printk(KERN_ERR "%s: vreg set level failed (%d)\n", __func__, ret); return -EIO; } ret = vreg_enable(vreg_touch); if (ret) { printk(KERN_ERR "%s: vreg enable failed (%d)\n", __func__, ret); return -EIO; } msleep(700); ts = kzalloc(sizeof(*ts), GFP_KERNEL); if (ts == NULL) { ret = -ENOMEM; goto err_alloc_data_failed; } INIT_WORK(&ts->work, synaptics_ts_work_func); #ifdef TOUCH_VERIFY_WITH_TIMER if(board_hw_revision >= 0x3) { INIT_DELAYED_WORK(&ts->work_check_ic, check_ic_work_func ); schedule_delayed_work(&ts->work_check_ic, CHECK_TIME ); } #endif ts->client = client; i2c_set_clientdata(client, ts); ts_global = ts; ts->input_dev = input_allocate_device(); if (ts->input_dev == NULL) { ret = -ENOMEM; printk(KERN_ERR "synaptics_ts_probe: Failed to allocate input device\n"); goto err_input_dev_alloc_failed; } ts->input_dev->name = "synaptics-rmi-touchscreen"; set_bit(EV_SYN, ts->input_dev->evbit); set_bit(EV_KEY, ts->input_dev->evbit); set_bit(BTN_TOUCH, ts->input_dev->keybit); set_bit(EV_ABS, ts->input_dev->evbit); printk(KERN_INFO "synaptics_ts_probe: max_x: 240, max_y: 320\n"); input_set_abs_params(ts->input_dev, ABS_MT_POSITION_X, 0, MAX_X, 0, 0); //0, MAX_X, 0, 0 input_set_abs_params(ts->input_dev, ABS_MT_POSITION_Y, 0, MAX_Y, 0, 0); //0, MAX_Y, 0, 0 input_set_abs_params(ts->input_dev, ABS_MT_TOUCH_MAJOR, 0, 255, 0, 0); input_set_abs_params(ts->input_dev, ABS_MT_WIDTH_MAJOR, 0, 255, 0, 0); for(key = 0; key < MAX_KEYS ; key++) input_set_capability(ts->input_dev, EV_KEY, touchkey_keycodes[key]); // for TSK for(key = 0; key < MAX_KEYS ; key++) touchkey_status[key] = TK_STATUS_RELEASE; /* ts->input_dev->name = ts->keypad_info->name; */ ret = input_register_device(ts->input_dev); if (ret) { printk(KERN_ERR "synaptics_ts_probe: Unable to register %s input device\n", ts->input_dev->name); goto err_input_register_device_failed; } printk("[TSP] %s, irq=%d\n", __func__, client->irq ); if (client->irq) { ret = request_irq(client->irq, synaptics_ts_irq_handler,/* IRQF_TRIGGER_RISING |*/ IRQF_TRIGGER_FALLING , client->name, ts); if (ret == 0) ts->use_irq = 1; else dev_err(&client->dev, "request_irq failed\n"); } #ifdef CONFIG_HAS_EARLYSUSPEND ts->early_suspend.level = EARLY_SUSPEND_LEVEL_BLANK_SCREEN + 1; ts->early_suspend.suspend = synaptics_ts_early_suspend; ts->early_suspend.resume = synaptics_ts_late_resume; register_early_suspend(&ts->early_suspend); #endif printk(KERN_INFO "synaptics_ts_probe: Start touchscreen %s in %s mode\n", ts->input_dev->name, ts->use_irq ? "interrupt" : "polling"); /* sys fs */ touch_class = class_create(THIS_MODULE, "touch"); if (IS_ERR(touch_class)) pr_err("Failed to create class(touch)!\n"); firmware_dev = device_create(touch_class, NULL, 0, NULL, "firmware"); if (IS_ERR(firmware_dev)) pr_err("Failed to create device(firmware)!\n"); if (device_create_file(firmware_dev, &dev_attr_firmware) < 0) pr_err("Failed to create device file(%s)!\n", dev_attr_firmware.attr.name); if (device_create_file(firmware_dev, &dev_attr_firmware_ret) < 0) pr_err("Failed to create device file(%s)!\n", dev_attr_firmware_ret.attr.name); /* sys fs */ if(board_hw_revision >= 0x3) { msleep(400); } /* Check point - i2c check - start */ ret = tsp_i2c_read( i2c_addr, buf_tmp, sizeof(buf_tmp)); HW_ver = buf_tmp[1]; SW_ver = buf_tmp[2]; if (ret <= 0) { printk(KERN_ERR "i2c_transfer failed\n"); ret = tsp_i2c_read( i2c_addr, buf_tmp, sizeof(buf_tmp)); #ifdef EMERGENCY_FIRMWARE_UPDATE emergency_firm_update(); #endif if (ret <= 0) { printk("[TSP] %s, ln:%d, Failed to register TSP!!!\n\tcheck the i2c line!!!, ret=%d\n", __func__,__LINE__, ret); goto err_check_functionality_failed; } } /* Check point - i2c check - end */ printk("[TSP] %s, ver CY=%x\n", __func__ , buf_tmp[0] ); printk("[TSP] %s, ver HW=%x\n", __func__ , buf_tmp[1] ); printk("[TSP] %s, ver SW=%x\n", __func__ , buf_tmp[2] ); /* Check point - Firmware */ printk("[TSP] %s: Board REV[%d], ver SW=%x, HW=%x\n", __func__, board_hw_revision, SW_ver, HW_ver ); if(((HW_ver <= HEX_HW_VER ) || ( HW_ver < HEX_HW_VER && HW_ver > 0 )) && (board_hw_revision < 0x3)) { if((SW_ver<HEX_SW_VER)||((SW_ver&0xF0)==0xF0)||(SW_ver==0)){ printk(KERN_INFO "[TSP] Firmware Update on REV01"); firm_update(); } else { printk(KERN_INFO "[TSP] Firmware version is up-to-date"); } } else if(((HW_ver <= HEX_HW_VER_REV03) || (HW_ver < HEX_HW_VER_REV03 && HW_ver>0)) && (board_hw_revision == 0x3)) { if((SW_ver < HEX_SW_VER_REV03)||((SW_ver&0xF0)==0xF0)||(SW_ver==0)){ printk(KERN_INFO "[TSP] Firmware Update on REV03"); firm_update(); }else{ printk(KERN_INFO "[TSP] Firmware version is up-to-date"); } } else if(((HW_ver <= HEX_HW_VER_REV04) || (HW_ver < HEX_HW_VER_REV04 && HW_ver>0)) && (board_hw_revision >= 0x4)) { if((SW_ver < HEX_SW_VER_REV04)||((SW_ver&0xF0)==0xF0)||(SW_ver==0)){ printk(KERN_INFO "[TSP] Firmware Update on REV06"); firm_update(); }else{ printk(KERN_INFO "[TSP] Firmware version is up-to-date"); } } printk(KERN_INFO "%s: Manufacturer ID: %x, HW ver=%x, SW ver=%x\n", __func__, buf_tmp[0], buf_tmp[1], buf_tmp[2]); #ifdef KEY_LED_CONTROL init_timer(&g_led_timer); g_led_timer.expires= (jiffies + (HZ*KEY_LED_ON_TIME)); g_led_timer.function = TouchKey_Led_TimerProc; add_timer(&g_led_timer); #endif return 0; err_input_register_device_failed: input_free_device(ts->input_dev); err_input_dev_alloc_failed: kfree(ts); err_alloc_data_failed: err_check_functionality_failed: return ret; }
//XXX: trout_wifi_power() is hard-coded in wlan driver int trout_wifi_power(int on) { int rc; printk("%s: %d\n", __func__, on); if (on) { config_gpio_table(mmc_pdata.sdc1_on_gpio_table, mmc_pdata.sdc1_on_gpio_table_size); rc = vreg_enable(vreg_wifi_osc); if (rc) return rc; rc = vreg_enable(vreg_wifi_2); if (rc) return rc; if (machine_is_htctopaz()) { rc = vreg_enable(vreg_wifi_3); if (rc) return rc; } mdelay(100); htc_pwrsink_set(PWRSINK_WIFI, 70); gpio_direction_output(mmc_pdata.wifi_power_gpio1, 0); if (mmc_pdata.wifi_power_gpio2 >= 0) { mdelay(50); gpio_direction_output(mmc_pdata.wifi_power_gpio2, 0); } mdelay(200); } else { config_gpio_table(mmc_pdata.sdc1_off_gpio_table, mmc_pdata.sdc1_off_gpio_table_size); htc_pwrsink_set(PWRSINK_WIFI, 0); } gpio_direction_output(mmc_pdata.wifi_power_gpio1, on); mdelay(50); if (mmc_pdata.wifi_power_gpio2 >= 0) { gpio_direction_output(mmc_pdata.wifi_power_gpio2, on); } if (!machine_is_htcrhodium()) { /* Only used for TI WLAN */ gpio_direction_input(29); set_irq_wake(gpio_to_irq(29), on); } mdelay(150); if (!on) { if (machine_is_htctopaz()) { vreg_disable(vreg_wifi_3); //These vregs shuts the phone off raph/diam(/blac?) //So don't disable it for them. //The radio chip is fair enough not to drain everything anyway. //vreg_disable(vreg_wifi_osc); //vreg_disable(vreg_wifi_2); } } wifi_power_state = on; return 0; }
static int synaptics_ts_resume(struct i2c_client *client) { int ret; int key; struct vreg *vreg_touch; struct synaptics_ts_data *ts = i2c_get_clientdata(client); uint8_t i2c_addr = 0x1D; uint8_t buf[1]; printk("[TSP] %s+\n", __func__ ); gpio_set_value( TSP_SCL , 1 ); gpio_set_value( TSP_SDA , 1 ); gpio_set_value( TSP_INT , 1 ); vreg_touch = vreg_get(NULL, "maxldo06"); ret = vreg_enable(vreg_touch); if (ret) { printk(KERN_ERR "%s: vreg enable failed (%d)\n", __func__, ret); return -EIO; } #ifdef KEY_LED_CONTROL if(!touchkey_led_on_off) { ret = key_led_power_control(TRUE); if (ret < 0) { printk(KERN_ERR "%s: vreg enable failed (%d)\n",__func__, ret); return -EIO; } else { touchkey_led_on_off = 1; } } #endif msleep(200); // for TSK for(key = 0; key < MAX_KEYS; key++) touchkey_status[key] = TK_STATUS_RELEASE; while (ts->use_irq) { msleep(20); ret = tsp_i2c_read( i2c_addr, buf, sizeof(buf)); if (ret <= 0) { // printk("[TSP] %d : i2c_transfer failed\n", __LINE__); } else if ( buf[0] == 0 ) { continue; } else { printk("[TSP] %s:%d, ver SW=%x\n", __func__,__LINE__, buf[0] ); enable_irq(client->irq); break; } msleep(20); } #ifdef TOUCH_VERIFY_WITH_TIMER if(board_hw_revision >= 0x3) { prev_wdog_val = -1; schedule_delayed_work(&ts->work_check_ic, CHECK_TIME ); } #endif printk("[TSP] %s-\n", __func__ ); return 0; }
static uint32_t chacha_sdslot_switchvdd(struct device *dev, unsigned int vdd) { int i; BUG_ON(!vreg_sdslot); if (vdd == sdslot_vdd) return 0; sdslot_vdd = vdd; if (vdd == 0) { printk(KERN_INFO "%s: Disabling SD slot power\n", __func__); writel(MCI_PWR_OFF, MSM_SDC2_BASE + MMCIPOWER); mdelay(1); config_gpio_table(sdcard_off_gpio_table, ARRAY_SIZE(sdcard_off_gpio_table)); vreg_disable(vreg_sdslot); sdslot_vreg_enabled = 0; return 0; } if (!sdslot_vreg_enabled) { mdelay(5); vreg_enable(vreg_sdslot); } for (i = 0; i < ARRAY_SIZE(mmc_vdd_table); i++) { if (mmc_vdd_table[i].mask == (1 << vdd)) { printk(KERN_INFO "%s: Setting level to %u\n", __func__, mmc_vdd_table[i].level); vreg_set_level(vreg_sdslot, mmc_vdd_table[i].level); if (!sdslot_vreg_enabled) break; else return 0; } } /* All vdd match failed */ if (i == ARRAY_SIZE(mmc_vdd_table)) goto out; if (!sdslot_vreg_enabled) { u32 pwr = 0; /* Power on MCI controller */ mdelay(5); pwr = readl(MSM_SDC2_BASE + MMCIPOWER); writel(pwr | MCI_PWR_UP, MSM_SDC2_BASE + MMCIPOWER); mdelay(5); pwr = readl(MSM_SDC2_BASE + MMCIPOWER); writel(pwr | MCI_PWR_ON, MSM_SDC2_BASE + MMCIPOWER); mdelay(5); /* ..then, config GPIO */ config_gpio_table(sdcard_on_gpio_table, ARRAY_SIZE(sdcard_on_gpio_table)); sdslot_vreg_enabled = 1; return 0; } out: printk(KERN_ERR "%s: Invalid VDD %d specified\n", __func__, vdd); return 0; }
static int gs_probe( struct i2c_client *client, const struct i2c_device_id *id) { int ret; struct gs_data *gs; struct gs_platform_data *pdata; struct vreg *vreg_gp4=NULL; int rc; vreg_gp4 = vreg_get(NULL, "gp4"); /* set gp4 voltage as 2700mV for all */ rc = vreg_set_level(vreg_gp4,VREG_GP4_VOLTAGE_VALUE_2700); if (rc) { printk("%s: vreg_gp4 vreg_set_level failed \n", __func__); return rc; } rc = vreg_enable(vreg_gp4); if (rc) { printk("%s: vreg_gp4 vreg_enable failed \n", __func__); return rc; } mdelay(5); if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) { printk(KERN_ERR "gs_probe: need I2C_FUNC_I2C\n"); ret = -ENODEV; goto err_check_functionality_failed; } pdata = client->dev.platform_data; if (pdata){ if(pdata->adapt_fn != NULL){ ret = pdata->adapt_fn(); if(ret > 0){ client->addr = pdata->slave_addr;//actual address printk(KERN_INFO "%s:change i2c addr to actrual address = %d\n", __FUNCTION__, pdata->slave_addr); if(client->addr == 0){ printk(KERN_ERR "%s: bad i2c address = %d\n", __FUNCTION__, client->addr); ret = -EFAULT; goto err_check_functionality_failed; } } } if(pdata->init_flag != NULL){ if(*(pdata->init_flag)){ printk(KERN_ERR "gs_st probe failed, because the othe gsensor has been probed.\n"); ret = -ENODEV; goto err_check_functionality_failed; } } } #ifndef GS_POLLING ret = gs_config_int_pin(); if(ret <0) { goto err_check_functionality_failed; } #endif gs = kzalloc(sizeof(*gs), GFP_KERNEL); if (gs == NULL) { ret = -ENOMEM; goto err_alloc_data_failed; } mutex_init(&gs->mlock); INIT_WORK(&gs->work, gs_work_func); gs->client = client; i2c_set_clientdata(client, gs); #if 0 ret = i2c_smbus_write_byte_data(gs->client, 0x20, 0x47); /* device command = ctrl_reg1 */ if (ret < 0) { printk(KERN_ERR "i2c_smbus_write_byte_data failed\n"); /* fail? */ goto err_detect_failed; } #endif ret = reg_write(gs, GS_ST_REG_CTRL2, 0x00); /* device command = ctrl_reg2 */ if (ret < 0) { printk(KERN_ERR "i2c_smbus_write_byte_data failed\n"); /* fail? */ goto err_detect_failed; } #if 0 ret = i2c_smbus_write_byte_data(gs->client, 0x22, 0x04); /* device command = ctrl_reg3 */ if (ret < 0) { printk(KERN_ERR "i2c_smbus_write_byte_data failed\n"); /* fail? */ goto err_detect_failed; } #endif if (sensor_dev == NULL) { gs->input_dev = input_allocate_device(); if (gs->input_dev == NULL) { ret = -ENOMEM; printk(KERN_ERR "gs_probe: Failed to allocate input device\n"); goto err_input_dev_alloc_failed; } gs->input_dev->name = "sensors"; sensor_dev = gs->input_dev; }else{ gs->input_dev = sensor_dev; } gs->input_dev->id.vendor = GS_ST35DE;//for akm8973 compass detect. set_bit(EV_ABS,gs->input_dev->evbit); /* < DTS20111208XXXXX liujinggang 20111208 begin */ /* modify for ES-version*/ input_set_abs_params(gs->input_dev, ABS_X, -11520, 11520, 0, 0); input_set_abs_params(gs->input_dev, ABS_Y, -11520, 11520, 0, 0); input_set_abs_params(gs->input_dev, ABS_Z, -11520, 11520, 0, 0); /* DTS20111208XXXXX liujinggang 20111208 end > */ set_bit(EV_SYN,gs->input_dev->evbit); gs->input_dev->id.bustype = BUS_I2C; //gs->input_dev->open = gs_st_input_open; //gs->input_dev->close = gs_st_input_close; input_set_drvdata(gs->input_dev, gs); ret = input_register_device(gs->input_dev); if (ret) { printk(KERN_ERR "gs_probe: Unable to register %s input device\n", gs->input_dev->name); goto err_input_register_device_failed; } ret = misc_register(&gsensor_device); if (ret) { printk(KERN_ERR "gs_probe: gsensor_device register failed\n"); goto err_misc_device_register_failed; } #ifndef GS_POLLING if (client->irq) { ret = request_irq(client->irq, gs_irq_handler, 0, client->name, gs); if (ret == 0) gs->use_irq = 1; else dev_err(&client->dev, "request_irq failed\n"); } #endif if (!gs->use_irq) { hrtimer_init(&gs->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL); gs->timer.function = gs_timer_func; } #ifdef CONFIG_HAS_EARLYSUSPEND gs->early_suspend.level = EARLY_SUSPEND_LEVEL_BLANK_SCREEN + 1; gs->early_suspend.suspend = gs_early_suspend; gs->early_suspend.resume = gs_late_resume; register_early_suspend(&gs->early_suspend); #endif gs_wq = create_singlethread_workqueue("gs_wq"); if (!gs_wq) return -ENOMEM; this_gs_data =gs; printk(KERN_INFO "gs_probe: Start LIS35DE in %s mode\n", gs->use_irq ? "interrupt" : "polling"); if(pdata && pdata->init_flag) *(pdata->init_flag) = 1; return 0; err_misc_device_register_failed: misc_deregister(&gsensor_device); err_input_register_device_failed: input_free_device(gs->input_dev); err_input_dev_alloc_failed: err_detect_failed: kfree(gs); err_alloc_data_failed: #ifndef GS_POLLING gs_free_int(); #endif err_check_functionality_failed: if (vreg_gp4!=NULL) { rc = vreg_disable(vreg_gp4); if (rc) { printk("%s: vreg_gp4 vreg_enable failed \n", __func__); return rc; } } return ret; }
int camera_power_on (void) { int rc; struct device *dev = su370_backlight_dev(); camera_power_mutex_lock(); if(lcd_bl_power_state == BL_POWER_SUSPEND) { u370_pwrsink_resume(); mdelay(50); } /* clear RESET, PWDN to Low*/ gpio_set_value(GPIO_CAM_RESET, 0); gpio_set_value(GPIO_CAM_PWDN, 0); /*AVDD power 2.8V*/ { /* it is for rev.c and default */ struct vreg *vreg_mmc = vreg_get(0, "mmc"); vreg_set_level(vreg_mmc, 2800); vreg_enable(vreg_mmc); } /* DVDD power 1.2V */ rc = aat28xx_ldo_set_level(dev, LDO_CAM_DVDD_NO, 1200); if (rc < 0) { printk(KERN_ERR "%s: ldo %d set level error\n", __func__, LDO_CAM_DVDD_NO); goto power_on_fail; } rc = aat28xx_ldo_enable(dev, LDO_CAM_DVDD_NO, 1); if (rc < 0) { printk(KERN_ERR "%s: ldo %d control error\n", __func__, LDO_CAM_DVDD_NO); goto power_on_fail; } /*IOVDD power 2.6V*/ rc = aat28xx_ldo_set_level(dev, LDO_CAM_IOVDD_NO, 2600); if (rc < 0) { printk(KERN_ERR "%s: ldo %d set level error\n", __func__, LDO_CAM_IOVDD_NO); goto power_on_fail; } rc = aat28xx_ldo_enable(dev, LDO_CAM_IOVDD_NO, 1); if (rc < 0) { printk(KERN_ERR "%s: ldo %d control error\n", __func__, LDO_CAM_IOVDD_NO); goto power_on_fail; } rc = aat28xx_ldo_set_level(dev, LDO_CAM_AVDD_NO, 2800); if (rc < 0) { printk(KERN_ERR "%s: ldo %d set level error\n", __func__, LDO_CAM_AVDD_NO); goto power_on_fail; } rc = aat28xx_ldo_enable(dev, LDO_CAM_AVDD_NO, 1); if (rc < 0) { printk(KERN_ERR "%s: ldo %d control error\n", __func__, LDO_CAM_AVDD_NO); goto power_on_fail; } mdelay(5); /*M Clock -24Mhz*/ msm_camio_clk_rate_set(mclk_rate); mdelay(5); msm_camio_camif_pad_reg_reset(); mdelay(5); /*reset high*/ gpio_set_value(GPIO_CAM_RESET, 1); mdelay(5); /*Nstandby high*/ gpio_set_value(GPIO_CAM_PWDN, 1); mdelay(8); // T2 camera_power_state = CAM_POWER_ON; power_on_fail: camera_power_mutex_unlock(); return rc; }
int camera_power_on (void) { int rc; struct device *dev = thunderg_backlight_dev(); gpio_set_value(GPIO_CAM_RESET, 0); gpio_set_value(GPIO_CAM_PWDN, 0); if (lge_bd_rev == LGE_REV_B) { rc = aat28xx_ldo_set_level(dev, LDO_CAM_AF_NO, 2800); if (rc < 0) { printk(KERN_ERR "%s: ldo %d set level error\n", __func__, LDO_CAM_AF_NO); return rc; } rc = aat28xx_ldo_enable(dev, LDO_CAM_AF_NO, 1); if (rc < 0) { printk(KERN_ERR "%s: ldo %d control error\n", __func__, LDO_CAM_AF_NO); return rc; } } else { struct vreg *vreg_mmc = vreg_get(0, "mmc"); vreg_set_level(vreg_mmc, 2800); vreg_enable(vreg_mmc); } rc = aat28xx_ldo_set_level(dev, LDO_CAM_DVDD_NO, 1200); if (rc < 0) { printk(KERN_ERR "%s: ldo %d set level error\n", __func__, LDO_CAM_DVDD_NO); return rc; } rc = aat28xx_ldo_enable(dev, LDO_CAM_DVDD_NO, 1); if (rc < 0) { printk(KERN_ERR "%s: ldo %d control error\n", __func__, LDO_CAM_DVDD_NO); return rc; } rc = aat28xx_ldo_set_level(dev, LDO_CAM_IOVDD_NO, 2600); if (rc < 0) { printk(KERN_ERR "%s: ldo %d set level error\n", __func__, LDO_CAM_IOVDD_NO); return rc; } rc = aat28xx_ldo_enable(dev, LDO_CAM_IOVDD_NO, 1); if (rc < 0) { printk(KERN_ERR "%s: ldo %d control error\n", __func__, LDO_CAM_IOVDD_NO); return rc; } rc = aat28xx_ldo_set_level(dev, LDO_CAM_AVDD_NO, 2800); if (rc < 0) { printk(KERN_ERR "%s: ldo %d set level error\n", __func__, LDO_CAM_AVDD_NO); return rc; } rc = aat28xx_ldo_enable(dev, LDO_CAM_AVDD_NO, 1); if (rc < 0) { printk(KERN_ERR "%s: ldo %d control error\n", __func__, LDO_CAM_AVDD_NO); return rc; } mdelay(5); msm_camio_clk_rate_set(mclk_rate); mdelay(5); msm_camio_camif_pad_reg_reset(); mdelay(5); gpio_set_value(GPIO_CAM_RESET, 1); mdelay(5); gpio_set_value(GPIO_CAM_PWDN, 1); mdelay(8); return rc; }
static void marimba_vreg_enable(void) { vreg_enable(vreg_marimba1); vreg_enable(vreg_marimba2); vreg_enable(vreg_marimba3); }
static int bluetooth_power(int on) { struct vreg *vreg_bt; int pin, rc; printk(KERN_DEBUG "%s\n", __func__); /* do not have vreg bt defined, gp6 is the same */ /* vreg_get parameter 1 (struct device *) is ignored */ vreg_bt = vreg_get(NULL, "gp6"); if (IS_ERR(vreg_bt)) { printk(KERN_ERR "%s: vreg get failed (%ld)\n", __func__, PTR_ERR(vreg_bt)); return PTR_ERR(vreg_bt); } if (on) { for (pin = 0; pin < ARRAY_SIZE(bt_config_power_on); pin++) { rc = gpio_tlmm_config(bt_config_power_on[pin], GPIO_ENABLE); if (rc) { printk(KERN_ERR "%s: gpio_tlmm_config(%#x)=%d\n", __func__, bt_config_power_on[pin], rc); return -EIO; } } /* units of mV, steps of 50 mV */ rc = vreg_set_level(vreg_bt, 2600); if (rc) { printk(KERN_ERR "%s: vreg set level failed (%d)\n", __func__, rc); return -EIO; } rc = vreg_enable(vreg_bt); if (rc) { printk(KERN_ERR "%s: vreg enable failed (%d)\n", __func__, rc); return -EIO; } } else { rc = vreg_disable(vreg_bt); if (rc) { printk(KERN_ERR "%s: vreg disable failed (%d)\n", __func__, rc); return -EIO; } for (pin = 0; pin < ARRAY_SIZE(bt_config_power_off); pin++) { rc = gpio_tlmm_config(bt_config_power_off[pin], GPIO_ENABLE); if (rc) { printk(KERN_ERR "%s: gpio_tlmm_config(%#x)=%d\n", __func__, bt_config_power_off[pin], rc); return -EIO; } } } return 0; }
static int sr130pc10_set_power(int onoff) { int rc = 0; struct vreg *vreg_ldo20, *vreg_ldo11; /* test1*/ vreg_ldo20 = vreg_get(NULL, "gp13"); if(!vreg_ldo20){ printk("[S5K4ECGX]%s: VREG L20 get failed\n", __func__); } if(vreg_set_level(vreg_ldo20, 1800)){ printk("[S5K4ECGX]%s: vreg_set_level failed\n", __func__); } vreg_ldo11 = vreg_get(NULL, "gp2"); if (!vreg_ldo11) { printk("[S5K4ECGX]%s: VREG L11 get failed\n", __func__); } if (vreg_set_level(vreg_ldo11, 2800)) { printk("[S5K4ECGX]%s: vreg_set_level failed\n", __func__); } /* end of test1 */ if(onoff) { printk("<=PCAM=> ++++++++++++++++++++++++++sr130pc10 test driver++++++++++++++++++++++++++++++++++++ \n"); gpio_tlmm_config(GPIO_CFG(CAM_RESET, 0,GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), GPIO_CFG_ENABLE); //CAM_RESET gpio_tlmm_config(GPIO_CFG(CAM_STANDBY, 0,GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), GPIO_CFG_ENABLE); //CAM_STANDBY gpio_tlmm_config(GPIO_CFG(CAM_EN, 0,GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), GPIO_CFG_ENABLE); //CAM_EN gpio_tlmm_config(GPIO_CFG(CAM_VT_RST, 0,GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), GPIO_CFG_ENABLE); //CAM_VT_RST gpio_tlmm_config(GPIO_CFG(CAM_VT_nSTBY, 0,GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), GPIO_CFG_ENABLE); //CAM_VT_nSTBY #if 0 vreg_ldo20 = vreg_get(NULL, "gp13"); vreg_ldo11 = vreg_get(NULL, "gp2"); vreg_set_level(vreg_ldo20, 1800); vreg_set_level(vreg_ldo11, 2800); vreg_disable(vreg_ldo20); vreg_disable(vreg_ldo11); #endif gpio_set_value(CAM_RESET, 0); gpio_set_value(CAM_STANDBY, 0); gpio_set_value(CAM_EN, 0); gpio_set_value(CAM_VT_RST, 0); gpio_set_value(CAM_VT_nSTBY, 0); mdelay(1); gpio_set_value(CAM_EN, 1); //CAM_EN->UP #if 1 if (vreg_enable(vreg_ldo20)) { printk("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!![S5K4ECGX]%s: reg_enable failed\n", __func__); } if (vreg_enable(vreg_ldo11)) { printk("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!![S5K4ECGX]%s: reg_enable failed\n", __func__); } #else vreg_enable(vreg_ldo20); mdelay(1); vreg_enable(vreg_ldo11); #endif gpio_set_value(CAM_VT_nSTBY, 1); //VGA_STBY UP udelay(5); gpio_tlmm_config(GPIO_CFG(CAM_MCLK, 1,GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), GPIO_CFG_ENABLE); mdelay(10); //CAM_MCLK // msm_camio_clk_rate_set(24000000); //MCLK // msm_camio_camif_pad_reg_reset(); gpio_set_value(CAM_VT_RST, 1); //VGA_RESET UP mdelay(2); printk("I2C Enable \n"); gpio_tlmm_config(GPIO_CFG(0, 2, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA) , GPIO_CFG_ENABLE); gpio_tlmm_config(GPIO_CFG(1, 2, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA) , GPIO_CFG_ENABLE); } else { gpio_set_value(CAM_RESET, 0); //REST -> DOWN gpio_set_value(CAM_STANDBY,0); mdelay(1); gpio_set_value(CAM_EN, 0); //CAM_EN->UP printk("I2C Disable \n"); gpio_tlmm_config(GPIO_CFG(0, 2, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA) , GPIO_CFG_DISABLE); gpio_tlmm_config(GPIO_CFG(1, 2, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA) , GPIO_CFG_DISABLE); mdelay(7/*2*/); gpio_set_value(CAM_VT_RST, 0); //REST -> DOWN mdelay(2); gpio_tlmm_config(GPIO_CFG(CAM_MCLK, 1,GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), GPIO_CFG_DISABLE); udelay(5); gpio_set_value(CAM_VT_nSTBY, 0); //STBY -> DOWN udelay(5); #if 1 //Entering shutdown mode if (vreg_disable(vreg_ldo11)) { //Power down VDDIO 1.8V and 1.3Mcore 1.8V printk("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!![S5K4ECGX]%s: reg_disable failed\n", __func__); } mdelay(1); if (vreg_disable(vreg_ldo20)) { //Power down AVDD 2.8V printk("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!![S5K4ECGX]%s: reg_disable failed\n", __func__); } #else vreg_disable(vreg_get(NULL, "gp2")); mdelay(1); vreg_disable(vreg_get(NULL, "gp13")); mdelay(1); #endif // gpio_set_value(CAM_EN, 0); //EN -> DOWN // mdelay(1); } }
static int bluetooth_power(int on) { struct vreg *vreg_bt; int pin, rc; printk(KERN_DEBUG "%s\n", __func__); /* do not have vreg bt defined, gp6 is the same */ /* vreg_get parameter 1 (struct device *) is ignored */ vreg_bt = vreg_get(NULL, "gp6"); if (IS_ERR(vreg_bt)) { printk(KERN_ERR "%s: vreg get failed (%ld)\n", __func__, PTR_ERR(vreg_bt)); return PTR_ERR(vreg_bt); } if (on) { for (pin = 0; pin < ARRAY_SIZE(bt_config_power_on); pin++) { rc = gpio_tlmm_config(bt_config_power_on[pin], GPIO_CFG_ENABLE); if (rc) { printk(KERN_ERR "%s: gpio_tlmm_config(%#x)=%d\n", __func__, bt_config_power_on[pin], rc); return -EIO; } } /* units of mV, steps of 50 mV */ rc = vreg_set_level(vreg_bt, 2650); if (rc) { printk(KERN_ERR "%s: vreg set level failed (%d)\n", __func__, rc); return -EIO; } rc = vreg_enable(vreg_bt); if (rc) { printk(KERN_ERR "%s: vreg enable failed (%d)\n", __func__, rc); return -EIO; } msleep(100); printk(KERN_ERR "BlueZ required power up * QCOM\r\n"); gpio_direction_output(94, 0); gpio_direction_output(20, 0); msleep(1); printk(KERN_ERR "BlueZ required power up * QCOM delay 1ms\r\n"); printk(KERN_ERR "BlueZ required power up * QCOM delay 100ms\r\n"); gpio_direction_output(94, 1); msleep(100); gpio_direction_output(20, 1); msleep(100); } else { msleep(100); rc = vreg_disable(vreg_bt); if (rc) { printk(KERN_ERR "%s: vreg disable failed (%d)\n", __func__, rc); return -EIO; } msleep(100); for (pin = 0; pin < ARRAY_SIZE(bt_config_power_off); pin++) { rc = gpio_tlmm_config(bt_config_power_off[pin], GPIO_CFG_ENABLE); if (rc) { printk(KERN_ERR "%s: gpio_tlmm_config(%#x)=%d\n", __func__, bt_config_power_off[pin], rc); return -EIO; } } printk(KERN_ERR "BlueZ required power down * QCOM\r\n"); gpio_direction_output(94, 0); gpio_direction_output(20, 0); } return 0; }
static ssize_t misc_helper_write(struct file *fp, const char __user *buf, size_t count, loff_t *pos) { unsigned char cmd[64]; int len; int i, r; unsigned int id, val; unsigned char *uchar; char *soc_baseband_id, *args[10]={0}; static char bp_version[32]={0}; static int bp_taken=0; static smem_mot_vendor1_type *vendor1; if (count < 1) return 0; len = count > 63 ? 63 : count; if (copy_from_user(cmd, buf, len)) return -EFAULT; cmd[len] = 0; /* lazy */ if (cmd[len-1] == '\n') { cmd[len-1] = 0; len--; } if ((r = misc_helper_args (args, cmd, len)) > 0) { for (i=0; i < r; i++) D(KERN_ERR "ARG[%d] %s\n", i, args[i]); } if (r == 0) return count; switch (misc_helper_get_cmd (args[0], r)) { case CMD_BP_VER : misc_helper_info.response |= MH_RESP_REQUIRED | MH_RESP_READY | MH_RESP_FMT_BUFF; if (! bp_taken) { soc_baseband_id = socinfo_get_baseband_id(); if (soc_baseband_id) { strncpy (bp_version, soc_baseband_id, sizeof (bp_version)-1); bp_version[31] = 0; }else strcpy (bp_version, "undefined"); bp_taken = 1; } D("%s(): %s\n", misc_helper_cmd_name[CMD_BP_VER], bp_version); sprintf (misc_helper_info.data.buffer, "%s", bp_version); break; case CMD_AP_FLASH : if(!0) { misc_helper_info.response |= MH_RESP_REQUIRED | MH_RESP_READY | MH_RESP_FMT_BUFF; id = PROCCOMM_MODEM_SET_AP_FLASH_REASON; val = 0; r = meta_proc(id, &val); D("%s()=%08x,%08x rc=%d\n", misc_helper_cmd_name[CMD_AP_FLASH], id, val, r); sprintf (misc_helper_info.data.buffer, "%u %u", id, val); } else sprintf (misc_helper_info.data.buffer, "Permissions denied"); break; case CMD_UUID_HIGH : misc_helper_info.response |= MH_RESP_REQUIRED | MH_RESP_READY | MH_RESP_FMT_BUFF; id = 0; val = 0; r = msm_proc_comm (PCOM_GET_UUID_HIGH, &id, &val); D("%s()=%08x,%08x rc=%d\n", misc_helper_cmd_name[CMD_UUID_HIGH], id, val, r); uchar = (unsigned char *)&id; sprintf (misc_helper_info.data.buffer, "%02x %02x %02x %02x ", *uchar, *uchar+1, *uchar+2, *uchar+3); uchar = (unsigned char *)&val; sprintf (misc_helper_info.data.buffer+strlen(misc_helper_info.data.buffer), "%02x %02x %02x %02x", *uchar, *uchar+1, *uchar+2, *uchar+3); break; case CMD_UUID_LOW : misc_helper_info.response |= MH_RESP_REQUIRED | MH_RESP_READY | MH_RESP_FMT_BUFF; id = 0; val = 0; r = msm_proc_comm (PCOM_GET_UUID_LOW, &id, &val); D("%s()=%08x,%08x rc=%d\n", misc_helper_cmd_name[CMD_UUID_LOW], id, val, r); uchar = (unsigned char *)&id; sprintf (misc_helper_info.data.buffer, "%02x %02x %02x %02x ", *uchar, *uchar+1, *uchar+2, *uchar+3); uchar = (unsigned char *)&val; sprintf (misc_helper_info.data.buffer+strlen(misc_helper_info.data.buffer), "%02x %02x %02x %02x", *uchar, *uchar+1, *uchar+2, *uchar+3); break; case CMD_HELP : if (!is_secure_hw()) { misc_helper_info.response |= MH_RESP_REQUIRED | MH_RESP_READY | MH_RESP_FMT_BUFF; misc_helper_usage (args, r); } else sprintf (misc_helper_info.data.buffer, "Permissions denied"); break; case CMD_GPIO_GET : misc_helper_info.response |= MH_RESP_REQUIRED | MH_RESP_READY | MH_RESP_FMT_BUFF; id = (unsigned)simple_strtoul (args[1], NULL, 10); val = gpio_get_value (id); D("%s(%u)=%u\n", misc_helper_cmd_name[CMD_GPIO_GET], id, val); sprintf (misc_helper_info.data.buffer, "%u", val); break; case CMD_BATTERY : misc_helper_info.response |= MH_RESP_REQUIRED | MH_RESP_READY | MH_RESP_FMT_BUFF; id = 0; val = 0; r = msm_proc_comm (PCOM_GET_BATT_LEVEL, &id, &val); D("%s()=%u,%u rc=%d\n", misc_helper_cmd_name[CMD_BATTERY], id, val, r); sprintf (misc_helper_info.data.buffer, "%u %u", id, val); break; case CMD_CHARGING : misc_helper_info.response |= MH_RESP_REQUIRED | MH_RESP_READY | MH_RESP_FMT_BUFF; id = 0; val = 0; r = msm_proc_comm (PCOM_CHG_IS_CHARGING, &id, &val); D("%s()=%u,%u rc=%d\n", misc_helper_cmd_name[CMD_CHARGING], id, val, r); sprintf (misc_helper_info.data.buffer, "%u %u", id, val); break; case CMD_RESET : if(!0) { //if (!is_secure_hw()) { misc_helper_info.response |= MH_RESP_REQUIRED | MH_RESP_READY | MH_RESP_FMT_BUFF; id = 0; val = 0; r = msm_proc_comm (PCOM_RESET_MODEM, &id, &val); D("%s()=%u,%u rc=%d\n", misc_helper_cmd_name[CMD_RESET], id, val, r); sprintf (misc_helper_info.data.buffer, "%u %u", id, val); } else sprintf (misc_helper_info.data.buffer, "Permissions denied"); break; case CMD_CHIP_PWRDN : if(!0) { //if (!is_secure_hw()) { misc_helper_info.response |= MH_RESP_REQUIRED | MH_RESP_READY | MH_RESP_FMT_BUFF; id = 0; val = 0; r = msm_proc_comm (PCOM_POWER_DOWN, &id, &val); D("%s()=%u,%u rc=%d\n", misc_helper_cmd_name[CMD_CHIP_PWRDN], id, val, r); sprintf (misc_helper_info.data.buffer, "%u %u", id, val); } else sprintf (misc_helper_info.data.buffer, "Permissions denied"); break; case CMD_NVREAD : if (!0) { //if (!is_secure_hw()) { misc_helper_info.response |= MH_RESP_REQUIRED | MH_RESP_READY | MH_RESP_FMT_BUFF; id = (unsigned)simple_strtoul (args[1], NULL, 10); id = (id << 8) | PROCCOMM_NV_READ; val = 0; r = msm_proc_comm (PCOM_CUSTOMER_CMD3, &id, &val); D("%s(0x%08x)=%u rc=%d\n", misc_helper_cmd_name[CMD_NVREAD], id, val, r); sprintf (misc_helper_info.data.buffer, "%u %u", id, val); } else sprintf (misc_helper_info.data.buffer, "Permissions denied"); break; case CMD_NVWRITE : if (!0) { //if (!is_secure_hw()) { misc_helper_info.response |= MH_RESP_REQUIRED | MH_RESP_READY | MH_RESP_FMT_BUFF; id = (unsigned)simple_strtoul (args[1], NULL, 10); id = (id << 8) | PROCCOMM_NV_WRITE; val = (unsigned)simple_strtoul (args[2], NULL, 10); r = msm_proc_comm (PCOM_CUSTOMER_CMD3, &id, &val); D("%s(0x%08x, %u) rc=%d\n", misc_helper_cmd_name[CMD_NVWRITE], id, val, r); sprintf (misc_helper_info.data.buffer, "%d", r); } else sprintf (misc_helper_info.data.buffer, "Permissions denied"); break; #if 0 case CMD_NVR : misc_helper_info.response |= MH_RESP_REQUIRED | MH_RESP_READY | MH_RESP_FMT_BUFF; id = (unsigned)simple_strtoul (args[1], NULL, 10); val = 0; r = msm_proc_comm (PCOM_NV_READ, &id, &val); D("%s(%u)=%u rc=%d\n", misc_helper_cmd_name[CMD_NVR], id, val, r); sprintf (misc_helper_info.data.buffer, "%u %u", id, val); break; case CMD_NVW : misc_helper_info.response |= MH_RESP_REQUIRED | MH_RESP_READY | MH_RESP_FMT_BUFF; id = (unsigned)simple_strtoul (args[1], NULL, 10); val = (unsigned)simple_strtoul (args[2], NULL, 10); r = msm_proc_comm (PCOM_NV_WRITE, &id, &val); D("%s(%u, %u) rc=%d\n", misc_helper_cmd_name[CMD_NVW], id, val, r); sprintf (misc_helper_info.data.buffer, "%d", r); break; #endif case CMD_GPIO_SET : if (!is_secure_hw()) { misc_helper_info.response |= MH_RESP_REQUIRED | MH_RESP_READY | MH_RESP_FMT_BUFF; id = (unsigned)simple_strtoul (args[1], NULL, 10); val = (unsigned)simple_strtoul (args[2], NULL, 10); r = gpio_set_value (id, val); val = gpio_get_value (id); D("%s(%u, %u) rc=%d\n", misc_helper_cmd_name[CMD_GPIO_SET], id, val, r); sprintf (misc_helper_info.data.buffer, "%u", val); } else sprintf (misc_helper_info.data.buffer, "Permissions denied"); break; case CMD_VREG : if (!is_secure_hw()) { misc_helper_info.response |= MH_RESP_REQUIRED | MH_RESP_READY | MH_RESP_FMT_BUFF; { unsigned int mv = (unsigned)simple_strtoul (args[2], NULL, 10); int rc; struct vreg *vreg; vreg = vreg_get(0,args[1]); if (IS_ERR(vreg)) { sprintf(misc_helper_info.data.buffer, "* bad name (%s)", args[1]); break; } if (mv > 0) { if ((rc = vreg_set_level(vreg, mv))) { sprintf(misc_helper_info.data.buffer, "* failed to set level (%d mV) [%d]", mv, rc); break; } if ((rc = vreg_enable(vreg))) { sprintf(misc_helper_info.data.buffer, "* failed to enable [%d]", rc); break; } } else { if ((rc = vreg_disable(vreg))) { sprintf(misc_helper_info.data.buffer, "* failed to disable [%d]", rc); break; } } D("%s(%s,%d) rc=%d\n", misc_helper_cmd_name[CMD_VREG],args[1],mv,rc); } sprintf(misc_helper_info.data.buffer, "OK"); } else sprintf (misc_helper_info.data.buffer, "Permissions denied"); break; case CMD_CLK : if (!is_secure_hw()) { misc_helper_info.response |= MH_RESP_REQUIRED | MH_RESP_READY | MH_RESP_FMT_BUFF; { unsigned int rate = (unsigned)simple_strtoul (args[2], NULL, 10); int rc = 0; struct clk *clk; clk = clk_get(NULL, args[1]); if (IS_ERR(clk)) { sprintf(misc_helper_info.data.buffer, "* bad name (%s)", args[1]); break; } if (rate > 0) { if ((rc = clk_enable(clk))) { sprintf(misc_helper_info.data.buffer, "* failed to enable clk [%d]", rc); break; } if ((rc = clk_set_rate(clk,rate))) { sprintf(misc_helper_info.data.buffer, "* failed to set rate [%d]", rc); break; } } else { clk_disable(clk); } D("%s(%s,%d) rc=%d\n", misc_helper_cmd_name[CMD_CLK],args[1],rate,rc); } sprintf(misc_helper_info.data.buffer, "OK"); } else sprintf (misc_helper_info.data.buffer, "Permissions denied"); break; case CMD_FB_SET : if (!is_secure_hw()) { misc_helper_info.response |= MH_RESP_REQUIRED | MH_RESP_READY | MH_RESP_FMT_BUFF; id = (1 << 8) | PROCCOMM_FACTORY_BYTE; val = (unsigned)simple_strtoul (args[1], NULL, 10); r = msm_proc_comm (PCOM_CUSTOMER_CMD3, &id, &val); D("%s(%u)=%u\n", misc_helper_cmd_name[CMD_FB_SET], id, val); sprintf (misc_helper_info.data.buffer, "%u", val); } else sprintf (misc_helper_info.data.buffer, "Permissions denied"); break; case CMD_TRUSTED_BOOT : if (! vendor1) { vendor1 = smem_alloc(SMEM_ID_VENDOR1, sizeof(smem_mot_vendor1_type)); } if (vendor1) { r = 0; val = (unsigned int)vendor1->trusted_boot; } else { r = -1; val = -1; } misc_helper_info.response |= MH_RESP_REQUIRED | MH_RESP_READY | MH_RESP_FMT_BUFF; D("%s(is_boot_trusted)=%u, rc=%d\n", misc_helper_cmd_name[CMD_TRUSTED_BOOT], val, r); sprintf (misc_helper_info.data.buffer, "%u", val); break; case CMD_SECURE : r = 0; val = (unsigned int)is_secure_hw(); misc_helper_info.response |= MH_RESP_REQUIRED | MH_RESP_READY | MH_RESP_FMT_BUFF; D("%s(is_security_on)=%u, rc=%d\n", misc_helper_cmd_name[CMD_SECURE], val, r); sprintf (misc_helper_info.data.buffer, "%u", val); break; case CMD_FB_GET : if (! vendor1) { vendor1 = smem_alloc(SMEM_ID_VENDOR1, sizeof(smem_mot_vendor1_type)); } if (vendor1) { r = 0; val = (unsigned int)vendor1->fact_byte; } else { r = -1; val = -1; } misc_helper_info.response |= MH_RESP_REQUIRED | MH_RESP_READY | MH_RESP_FMT_BUFF; D("%s(10024)=%u, rc=%d\n", misc_helper_cmd_name[CMD_FB_GET], val, r); sprintf (misc_helper_info.data.buffer, "%u", val); break; case CMD_MAX : misc_helper_info.response |= MH_RESP_REQUIRED | MH_RESP_READY | MH_RESP_FMT_BUFF; sprintf (misc_helper_info.data.buffer, "missing parameters for command: %s", args[0]); break; default : misc_helper_info.response |= MH_RESP_REQUIRED | MH_RESP_READY | MH_RESP_FMT_BUFF; sprintf (misc_helper_info.data.buffer, "command: %s is not supported", cmd); } return count; }
static int synaptics_ts_probe( struct i2c_client *client, const struct i2c_device_id *id) { struct synaptics_ts_data *ts; int ret = 0; struct vreg *vreg_touch; uint8_t i2c_addr = 0x07; uint8_t buf[3]; int key=0; printk("[TSP] %s, %d\n", __func__, __LINE__ ); vreg_touch = vreg_get(NULL, "ldo6"); ret = vreg_set_level(vreg_touch, OUT2600mV); if (ret) { printk(KERN_ERR "%s: vreg set level failed (%d)\n", __func__, ret); return -EIO; } ret = vreg_enable(vreg_touch); if (ret) { printk(KERN_ERR "%s: vreg enable failed (%d)\n", __func__, ret); return -EIO; } msleep(100); ts = kzalloc(sizeof(*ts), GFP_KERNEL); if (ts == NULL) { ret = -ENOMEM; goto err_alloc_data_failed; } INIT_WORK(&ts->work, synaptics_ts_work_func); // INIT_WORK(&ts->work_timer, report_touch ); ts->client = client; i2c_set_clientdata(client, ts); ts_global = ts; /* Check point - i2c check - start */ ret = tsp_i2c_read( i2c_addr, buf, sizeof(buf)); if (ret <= 0) { printk(KERN_ERR "i2c_transfer failed\n"); ret = tsp_i2c_read( i2c_addr, buf, sizeof(buf)); if (ret <= 0) { printk("[TSP] %s, ln:%d, Failed to register TSP!!!\n\tcheck the i2c line!!!, ret=%d\n", __func__,__LINE__, ret); goto err_check_functionality_failed; } } /* Check point - i2c check - end */ ts->input_dev = input_allocate_device(); if (ts->input_dev == NULL) { ret = -ENOMEM; printk(KERN_ERR "synaptics_ts_probe: Failed to allocate input device\n"); goto err_input_dev_alloc_failed; } ts->input_dev->name = "synaptics-rmi-touchscreen"; set_bit(EV_SYN, ts->input_dev->evbit); set_bit(EV_KEY, ts->input_dev->evbit); set_bit(BTN_TOUCH, ts->input_dev->keybit); set_bit(EV_ABS, ts->input_dev->evbit); printk(KERN_INFO "synaptics_ts_probe: max_x: %d, max_y: %d\n", MAX_X, MAX_Y); input_set_abs_params(ts->input_dev, ABS_X, 0, MAX_X, 0, 0); input_set_abs_params(ts->input_dev, ABS_Y, 0, MAX_Y, 0, 0); input_set_abs_params(ts->input_dev, ABS_PRESSURE, 0, 255, 0, 0); input_set_abs_params(ts->input_dev, ABS_TOOL_WIDTH, 0, 15, 0, 0); // for touch key for(key = 0; key < touchkey_size; key++) input_set_capability(ts->input_dev, EV_KEY, touchkey_keycodes[key]); /* ts->input_dev->name = ts->keypad_info->name; */ ret = input_register_device(ts->input_dev); if (ret) { printk(KERN_ERR "synaptics_ts_probe: Unable to register %s input device\n", ts->input_dev->name); goto err_input_register_device_failed; } printk("[TSP] %s, irq=%d\n", __func__, client->irq ); if (client->irq) { ret = request_irq(client->irq, synaptics_ts_irq_handler,/* IRQF_TRIGGER_RISING |*/ IRQF_TRIGGER_FALLING , client->name, ts); if (ret == 0) ts->use_irq = 1; else dev_err(&client->dev, "request_irq failed\n"); } // hrtimer_init(&ts->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL); // ts->timer.function = synaptics_ts_timer_func; #ifdef CONFIG_HAS_EARLYSUSPEND ts->early_suspend.level = EARLY_SUSPEND_LEVEL_BLANK_SCREEN + 1; ts->early_suspend.suspend = synaptics_ts_early_suspend; ts->early_suspend.resume = synaptics_ts_late_resume; register_early_suspend(&ts->early_suspend); #endif printk(KERN_INFO "synaptics_ts_probe: Start touchscreen %s in %s mode\n", ts->input_dev->name, ts->use_irq ? "interrupt" : "polling"); /* sys fs */ touch_class = class_create(THIS_MODULE, "touch"); if (IS_ERR(touch_class)) pr_err("Failed to create class(touch)!\n"); firmware_dev = device_create(touch_class, NULL, 0, NULL, "firmware"); if (IS_ERR(firmware_dev)) pr_err("Failed to create device(firmware)!\n"); if (device_create_file(firmware_dev, &dev_attr_firmware) < 0) pr_err("Failed to create device file(%s)!\n", dev_attr_firmware.attr.name); if (device_create_file(firmware_dev, &dev_attr_firmware_ret) < 0) pr_err("Failed to create device file(%s)!\n", dev_attr_firmware_ret.attr.name); /* sys fs */ /* Check point - Firmware */ printk("[TSP] %s, ver CY=%x\n", __func__ , buf[0] ); printk("[TSP] %s, ver HW=%x\n", __func__ , buf[1] ); printk("[TSP] %s, ver SW=%x\n", __func__ , buf[2] ); HW_ver = buf[1]; printk(KERN_INFO "synaptics_ts_probe: Manufacturer ID: %x, HW ver=%d\n", buf[0], HW_ver); #if 0 if ( ( 0x00 < buf[2]) && (buf[2] < 0x04) ) { printk("[TSP] %s, ver SW=%x\n", __func__ , buf[2] ); printk("[TSP] %s, firm_update was blocked!!\n", __func__ ); //firm_update( ); } #endif /* Check point - Firmware */ return 0; err_input_register_device_failed: input_free_device(ts->input_dev); err_input_dev_alloc_failed: kfree(ts); err_alloc_data_failed: err_check_functionality_failed: return ret; }