static uint32_t spade_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__); 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); udelay(500); config_gpio_table(sdcard_on_gpio_table, ARRAY_SIZE(sdcard_on_gpio_table)); sdslot_vreg_enabled = 1; } 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); return 0; } } printk(KERN_ERR "%s: Invalid VDD %d specified\n", __func__, vdd); return 0; }
static int msm_hsusb_ldo_init(int init) { if (init) { /* * PHY 3.3V analog domain(VDDA33) is powered up by * an always enabled power supply (LP5900TL-3.3). * USB VREG default source is VBUS line. Turning * on USB VREG has a side effect on the USB suspend * current. Hence USB VREG is explicitly turned * off here. */ vreg_3p3 = vreg_get(NULL, "usb"); if (IS_ERR(vreg_3p3)) return PTR_ERR(vreg_3p3); vreg_enable(vreg_3p3); vreg_disable(vreg_3p3); vreg_put(vreg_3p3); } return 0; }
int keypad_led_set(unsigned char value) { #ifndef CONFIG_MACH_MSM7X27_GELATO_DOP struct vreg *vreg; static int mValue = -1; vreg = vreg_get(0, "gp16"); if(value != mValue) { if (value != LED_OFF) { printk("[MAINKEY BACKLIGHT] %s() on:%d, mValue:%d\n",__FUNCTION__, value, mValue); vreg_enable(vreg); } else { printk("[MAINKEY BACKLIGHT] %s() off:%d, mValue:%d\n",__FUNCTION__, value, mValue); vreg_disable(vreg); } mValue = value; } #endif return 0; }
int htcleo_wifi_power(int on) { printk("%s: %d\n", __func__, on); if (on) { config_gpio_table(wifi_on_gpio_table,ARRAY_SIZE(wifi_on_gpio_table)); mdelay(50); vreg_enable(wlan_vreg_3); } else { config_gpio_table(wifi_off_gpio_table, ARRAY_SIZE(wifi_off_gpio_table)); mdelay(200); vreg_disable(wlan_vreg_3); } mdelay(100); gpio_set_value(HTCLEO_GPIO_WIFI_SHUTDOWN_N, on); /* WIFI_SHUTDOWN */ mdelay(100); htcleo_wifi_power_state = on; return 0; }
/** accelerometer **/ int accel_power(unsigned char onoff) { int ret = 0; struct vreg *usim2_vreg = vreg_get(0, "usim2"); if (onoff) { printk(KERN_INFO "accel_power_on\n"); ret = vreg_set_level(usim2_vreg, 3000); if (ret != 0) { printk(KERN_INFO "[Accel] vreg_set_level failed\n"); return ret; } vreg_enable(usim2_vreg); } else { printk(KERN_INFO "accel_power_off\n"); vreg_disable(usim2_vreg); } return ret; }
static uint32_t mahimahi_sdslot_switchvdd(struct device *dev, unsigned int vdd) { int i; int ret; if (vdd == sdslot_vdd) return 0; sdslot_vdd = vdd; if (vdd == 0) { config_gpio_table(sdcard_off_gpio_table, ARRAY_SIZE(sdcard_off_gpio_table)); vreg_disable(sdslot_vreg); sdslot_vreg_enabled = 0; return 0; } if (!sdslot_vreg_enabled) { ret = vreg_enable(sdslot_vreg); if (ret) pr_err("%s: Error enabling vreg (%d)\n", __func__, ret); config_gpio_table(sdcard_on_gpio_table, ARRAY_SIZE(sdcard_on_gpio_table)); sdslot_vreg_enabled = 1; } for (i = 0; i < ARRAY_SIZE(mmc_vdd_table); i++) { if (mmc_vdd_table[i].mask != (1 << vdd)) continue; ret = vreg_set_level(sdslot_vreg, mmc_vdd_table[i].level); if (ret) pr_err("%s: Error setting level (%d)\n", __func__, ret); return 0; } pr_err("%s: Invalid VDD (%d) specified\n", __func__, vdd); return 0; }
int key_led_power_control(uint8_t LED_ON_OFF) { struct vreg *vreg_keyled; int ret=0; printk(KERN_ERR "%s: key_led_power_control ON/OFF [%d]\n",__func__, LED_ON_OFF); vreg_keyled = vreg_get(NULL, "maxldo04"); if (LED_ON_OFF == TRUE) { ret = vreg_set_level(vreg_keyled, OUT3000mV); ret = vreg_enable(vreg_keyled); mod_timer(&g_led_timer, jiffies + (HZ*KEY_LED_ON_TIME)); if (ret) { return -EIO; } } else { ret = vreg_disable(vreg_keyled); if (ret) { return -EIO; } } return ret; }
void primou_hs_n1v8_enable(int en) { int rc = 0; pr_aud_info("%s: %d\n", __func__, en); if (!vreg_audio_n1v8) { vreg_audio_n1v8 = vreg_get(NULL, "ncp"); if (IS_ERR(vreg_audio_n1v8)) { printk(KERN_ERR "%s: vreg_get() failed (%ld)\n", __func__, PTR_ERR(vreg_audio_n1v8)); rc = PTR_ERR(vreg_audio_n1v8); goto vreg_aud_hp_1v8_faill; } } if (en) { rc = vreg_enable(vreg_audio_n1v8); if (rc) { printk(KERN_ERR "%s: vreg_enable() = %d \n", __func__, rc); goto vreg_aud_hp_1v8_faill; } } else { rc = vreg_disable(vreg_audio_n1v8); if (rc) { printk(KERN_ERR "%s: vreg_disable() = %d \n", __func__, rc); goto vreg_aud_hp_1v8_faill; } } return; vreg_aud_hp_1v8_faill: printk(KERN_ERR "%s: failed (%ld)\n", __func__, PTR_ERR(vreg_audio_n1v8)); }
static int prox_power_set(unsigned char onoff) { int ret = 0; int flag_on = !!onoff; struct vreg *vreg = vreg_get(0, "mmc"); if (prox_power_save_on == flag_on) return; printk("[Proxi] %s() onoff:%d\n",__FUNCTION__, onoff); prox_power_save_on = flag_on; if(lge_bd_rev < LGE_REV_D) ecom_power_save_on = flag_on; if (onoff) { vreg_set_level(vreg, 2500); vreg_enable(vreg); if(lge_bd_rev >= LGE_REV_D) { /* GPIO setting for i2c and irq pins*/ gpio_tlmm_config(GPIO_CFG(PROXI_GPIO_I2C_SCL, 0, GPIO_OUTPUT, GPIO_PULL_UP, GPIO_2MA), GPIO_ENABLE); gpio_tlmm_config(GPIO_CFG(PROXI_GPIO_I2C_SDA, 0, GPIO_OUTPUT, GPIO_PULL_UP, GPIO_2MA), GPIO_ENABLE); gpio_tlmm_config(GPIO_CFG(PROXI_GPIO_DOUT, 0, GPIO_INPUT, GPIO_PULL_UP, GPIO_2MA), GPIO_ENABLE); } } else { if(lge_bd_rev >= LGE_REV_D) { vreg_set_level(vreg, 0); vreg_disable(vreg); /* GPIO setting when power off */ gpio_tlmm_config(GPIO_CFG(PROXI_GPIO_I2C_SCL, 0, GPIO_INPUT, GPIO_NO_PULL, GPIO_2MA), GPIO_ENABLE); gpio_tlmm_config(GPIO_CFG(PROXI_GPIO_I2C_SDA, 0, GPIO_INPUT, GPIO_NO_PULL, GPIO_2MA), GPIO_ENABLE); gpio_tlmm_config(GPIO_CFG(PROXI_GPIO_DOUT, 0, GPIO_INPUT, GPIO_PULL_DOWN, GPIO_2MA), GPIO_ENABLE); } } return ret; }
static int ts_set_vreg(unsigned char onoff) #endif { struct vreg *vreg_touch; int rc; // LGE_CHANGE [[email protected]] 2010-07-26, onoff stat static int old_onoff = 0; printk("[Touch] %s() onoff:%d\n",__FUNCTION__, onoff); // LGE_CHANGE [[email protected]] 2010-07-26, onoff stat if (old_onoff == onoff) return 0; vreg_touch = vreg_get(0, "synt"); if(IS_ERR(vreg_touch)) { printk("[Touch] vreg_get fail : touch\n"); return -1; } if (onoff) { rc = vreg_set_level(vreg_touch, 3050); if (rc != 0) { printk("[Touch] vreg_set_level failed\n"); return -1; } vreg_enable(vreg_touch); // LGE_CHANGE [[email protected]] 2010-07-26, onoff stat old_onoff = onoff; } else { vreg_disable(vreg_touch); // LGE_CHANGE [[email protected]] 2010-07-26, onoff stat old_onoff = onoff; } return 0; }
/* proximity */ static int prox_power_set(unsigned char onoff) { static bool init_done = 0; int ret = 0; struct vreg *gp6_vreg = vreg_get(0, "gp6"); printk("[Proximity] %s() : Power %s\n",__FUNCTION__, onoff ? "On" : "Off"); if (init_done == 0 && onoff) { if (onoff) { vreg_set_level(gp6_vreg, 2800); vreg_enable(gp6_vreg); init_done = 1; } else { vreg_disable(gp6_vreg); } } return ret; }
void mecha_snddev_usb_headset_on(int en) { struct vreg *vreg_ncp; int ret; vreg_ncp = vreg_get(NULL, "ncp"); if (IS_ERR(vreg_ncp)) { pr_err("%s: vreg_get(%s) failed (%ld)\n", __func__, "ncp", PTR_ERR(vreg_ncp)); return; } pr_err("%s %d\n",__func__, en); if (en) { gpio_set_value(MECHA_GPIO_AUD_UART_SWITCH, 0); gpio_set_value(MECHA_GPIO_USB_AUD_UART_SWITCH, 1); ret = vreg_enable(vreg_ncp); } else { ret = vreg_disable(vreg_ncp); gpio_set_value(MECHA_GPIO_AUD_UART_SWITCH, 1); gpio_set_value(MECHA_GPIO_USB_AUD_UART_SWITCH, 0); } }
//static int i; static int mipi_ili9486_lcd_off(struct platform_device *pdev) { struct msm_fb_data_type *mfd; mfd = platform_get_drvdata(pdev); if (!mfd) return -ENODEV; if (mfd->key != MFD_KEY) return -EINVAL; //[Arima Edison] add to trigger backlight ++ lm3533_backlight_control(0); //[Arima Edison] add to trigger backlight -- mipi_dsi_cmds_tx(&ili9486_tx_buf, ili9486_display_off_cmds, ARRAY_SIZE(ili9486_display_off_cmds)); vreg_l1= vreg_get(NULL, "rfrx1"); vreg_disable(vreg_l1); return 0; }
void vivow_snddev_usb_headset_on(int en) { struct vreg *vreg_ncp; int ret; vreg_ncp = vreg_get(NULL, "ncp"); if (IS_ERR(vreg_ncp)) { pr_aud_err("%s: vreg_get(%s) failed (%ld)\n", __func__, "ncp", PTR_ERR(vreg_ncp)); return; } pr_aud_err("%s %d\n",__func__, en); if (en) { gpio_set_value(VIVOW_AUDIOz_UART_SW, 0); gpio_set_value(VIVOW_USBz_AUDIO_SW, 1); ret = vreg_enable(vreg_ncp); } else { ret = vreg_disable(vreg_ncp); gpio_set_value(VIVOW_AUDIOz_UART_SW, 1); gpio_set_value(VIVOW_USBz_AUDIO_SW, 0); } }
/* Eenable VREG_MMC pin to turn on fastclock oscillator : colin */ int desirec_bt_fastclock_power(int on) { int rc; printk(KERN_INFO "%s: %d\n", __func__, on); if (vreg_wifi_osc) { if (on) { rc = vreg_enable(vreg_wifi_osc); if (rc) { printk(KERN_ERR "Error turn " "bt_fastclock_power rc=%d\n", rc); return rc; } } else { if (!desirec_wifi_power_state) vreg_disable(vreg_wifi_osc); } } desirec_bt_power_state = on; return 0; }
static int sonywvga_power(int on) { unsigned id, on_off; static struct vreg *vreg_lcm_2v6; if (!vreg_lcm_2v6) { vreg_lcm_2v6 = vreg_get(0, "gp1"); if (IS_ERR(vreg_lcm_2v6)) return -EINVAL; } if (on) { on_off = 0; id = PM_VREG_PDOWN_CAM_ID; msm_proc_comm(PCOM_VREG_PULLDOWN, &on, &id); vreg_enable(vreg_lcm_2v6); gpio_set_value(INCREDIBLEC_LCD_RST_ID1, 1); mdelay(10); gpio_set_value(INCREDIBLEC_LCD_RST_ID1, 0); udelay(500); gpio_set_value(INCREDIBLEC_LCD_RST_ID1, 1); mdelay(10); } else { on_off = 1; gpio_set_value(INCREDIBLEC_LCD_RST_ID1, 0); mdelay(120); id = PM_VREG_PDOWN_CAM_ID; msm_proc_comm(PCOM_VREG_PULLDOWN, &on, &id); vreg_disable(vreg_lcm_2v6); } return 0; }
/* proximity */ static int apds_power_set(unsigned char enable) { int err = 0; int hw_rev_num = lge_get_hw_rev(); struct vreg *vreg_power_1; printk("### apds_power_set enable : %d\n", enable); if(hw_rev_num < LGE_REV_11) vreg_power_1 = vreg_get(0, VREG_PROXI_VDD_26V); else if(hw_rev_num >= LGE_REV_11) vreg_power_1 = vreg_get(0, VREG_PERI_26V); if (enable) { vreg_enable(vreg_power_1); // LGE_UPDATE_S... [email protected] 13-Apr-2011 // Change Vreg_power value for Proximtiy Sensor Tunning.(2.6V --> 2.8V) // [email protected] 30-JUN-2011 Change Vreg_power value for Proximtiy Sensor Tunning.(2.8V --> 3.0V) err = vreg_set_level(vreg_power_1, 3000/*2800*/); // LGE_UPDATE_E... if (err != 0) { printk("### vreg_power_1 failed.\n"); return -1; } printk("### adps sensor power OK\n"); } else { vreg_disable(vreg_power_1); } return err; }
static int pp2106_vreg_set(unsigned char onoff) { int rc = 0; struct vreg *vreg_l12 = NULL; vreg_l12 = vreg_get(NULL, "gp2"); if (IS_ERR(vreg_l12)) { pr_err("%s: vreg_get failed (%ld)\n", __func__, PTR_ERR(vreg_l12)); return PTR_ERR(vreg_l12); } if (onoff) { rc = vreg_set_level(vreg_l12, 2850); if (rc < 0) { pr_err("%s: vreg_set_level failed (%d)\n", __func__, rc); goto vreg_fail; } rc = vreg_enable(vreg_l12); if (rc < 0) { pr_err("%s: vreg_enable failed (%d)\n", __func__, rc); goto vreg_fail; } } else { rc = vreg_disable(vreg_l12); if (rc < 0) { pr_err("%s: vreg_disable failed (%d)\n", __func__, rc); goto vreg_fail; } } return rc; vreg_fail: vreg_put(vreg_l12); return rc; }
static unsigned int runnymede_audio_2v85_power_on(int en) { struct vreg *vreg_2v85; int ret; pr_aud_info("%s %d", __func__, en); vreg_2v85 = vreg_get(NULL, "gp9"); if (IS_ERR(vreg_2v85)) { pr_aud_err("%s: vreg_get(%s) failed (%ld)\n", __func__, "vreg_2v85", PTR_ERR(vreg_2v85)); return -ENODEV; } if (en) { ret = vreg_enable(vreg_2v85); } else { ret = vreg_disable(vreg_2v85); } vreg_put(vreg_2v85); pr_aud_info("%s %d ret %d\n",__func__, en, ret); return ret; }
/* Proximity Sensor (Capella_CM3602)*/ static int __capella_cm3602_power(int on) { int ret; struct vreg *vreg = vreg_get(0, "gp1"); if (!vreg) { printk(KERN_ERR "%s: vreg error\n", __func__); return -EIO; } ret = vreg_set_level(vreg, 2800); printk(KERN_DEBUG "%s: Turn the capella_cm3602 power %s\n", __func__, (on) ? "on" : "off"); if (on) { gpio_direction_output(SUPERSONIC_GPIO_PROXIMITY_EN_N, 1); ret = vreg_enable(vreg); if (ret < 0) printk(KERN_ERR "%s: vreg enable failed\n", __func__); } else { vreg_disable(vreg); gpio_direction_output(SUPERSONIC_GPIO_PROXIMITY_EN_N, 0); } return ret; }
int32_t msm_camera_flash_disable_vreg(void) { int ret = 0; struct vreg *vreg_5v = NULL; vreg_5v = vreg_get(NULL,"boost"); ret = IS_ERR(vreg_5v); if(ret) { printk(KERN_ERR "%s: vreg_5v get failed (%d)\n", __func__, ret); return ret; } while(vreg_enable_times) { ret = vreg_disable(vreg_5v); if(ret) { printk(KERN_ERR "%s: vreg_5v disable failed (%d)\n", __func__, ret); return ret; } vreg_enable_times--; } return ret; }
void glacier_snddev_hsed_pamp_on(int en) { struct vreg *vreg_ncp; int ret; vreg_ncp = vreg_get(NULL, "ncp"); if (IS_ERR(vreg_ncp)) { pr_err("%s: vreg_get(%s) failed (%ld)\n", __func__, "ncp", PTR_ERR(vreg_ncp)); return; } if (en) { mdelay(60); gpio_set_value(PM8058_GPIO_PM_TO_SYS(GLACIER_AUD_HP_EN), 1); ret = vreg_enable(vreg_ncp); if (ret) pr_err("%s: vreg_enable failed (%d)\n", __func__, ret); } else { ret = vreg_disable(vreg_ncp); if (ret) pr_err("%s: vreg_disable failed (%d)\n", __func__, ret); gpio_set_value(PM8058_GPIO_PM_TO_SYS(GLACIER_AUD_HP_EN), 0); } }
////////////////////////////////// // LED Control ////////////////////////////////// static void cam12mp_led_control(int ctrl) { switch (ctrl) { case LED_OFF: if(cam12mp_ctrl->model == DEV_MODEL_NO_0 || cam12mp_ctrl->model == DEV_MODEL_NO_1) { pmic_set_led_intensity(LED_LCD, 0); pmic_set_led_intensity(LED_KEYPAD, 0); } else { pmic_secure_mpp_config_i_sink(PM_MPP_13,cam12mp_ctrl->led, PM_MPP__I_SINK__SWITCH_DIS); pmic_secure_mpp_config_i_sink(PM_MPP_18,cam12mp_ctrl->led, PM_MPP__I_SINK__SWITCH_DIS); } if ( vreg_disable(vreg_get(NULL, "boost"))) // VREG_5V LOGE("%s: vreg_5Vdisable failed !\n", __func__); break; case LED_LOW: case LED_HIGH: if ( vreg_enable(vreg_get(NULL, "boost"))) // VREG_5V LOGE("%s: vreg_5V enable failed !\n", __func__); mdelay(1); if(cam12mp_ctrl->model == DEV_MODEL_NO_0 || cam12mp_ctrl->model == DEV_MODEL_NO_1) { pmic_set_led_intensity(LED_LCD, 1); pmic_set_led_intensity(LED_KEYPAD, 1); } else { cam12mp_ctrl->led = ctrl == LED_LOW ? PM_MPP__I_SINK__LEVEL_10mA : PM_MPP__I_SINK__LEVEL_15mA; pmic_secure_mpp_config_i_sink(PM_MPP_13, cam12mp_ctrl->led, PM_MPP__I_SINK__SWITCH_ENA); pmic_secure_mpp_config_i_sink(PM_MPP_18, cam12mp_ctrl->led, PM_MPP__I_SINK__SWITCH_ENA); } break; } }
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 = PCOM_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); vreg->status = msm_proc_comm_wince(&dex, 0); #else vreg->status = msm_proc_comm(PCOM_VREG_SET_LEVEL, &id, &mv); #endif if (debug_mask & VREG_DEBUG_LEVEL) printk(KERN_DEBUG "%s: n=%s id=%u s=%d ref=%u -> %umv\n", __func__, vreg->name, vreg->id, vreg->status, vreg->refcnt, mv); 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 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; }
int tsp_reset( void ) { int ret = 1; struct vreg *vreg_touch; printk("[TSP] %s+\n", __func__ ); vreg_touch = vreg_get(NULL, "ldo6"); #if 0 if (ts_global->use_irq) { disable_irq(ts_global->client->irq); } #endif 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_tlmm_config(GPIO_CFG( TSP_SCL, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP,GPIO_CFG_2MA), GPIO_CFG_ENABLE); gpio_tlmm_config(GPIO_CFG( TSP_SDA, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP,GPIO_CFG_2MA), GPIO_CFG_ENABLE); gpio_tlmm_config(GPIO_CFG( TSP_INT, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP,GPIO_CFG_2MA), GPIO_CFG_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 0 if (ts_global->use_irq) { enable_irq(ts_global->client->irq); } #endif printk("[TSP] %s-\n", __func__ ); return ret; }
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 void msm_camera_vreg_enable(struct platform_device *pdev) { 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; }
int ts_set_vreg(unsigned char onoff) { if (lge_bd_rev == LGE_REV_A) { struct vreg *vreg_touch; int rc; printk(KERN_INFO "[Touch] %s() onoff:%d\n", __func__, onoff); vreg_touch = vreg_get(0, "bt"); if (IS_ERR(vreg_touch)) { printk(KERN_INFO"[Touch] vreg_get fail : touch\n"); return -EBUSY; } if (onoff) { rc = vreg_set_level(vreg_touch, 2850); if (rc != 0) { printk(KERN_INFO "[Touch] vreg_set_level failed\n"); return -EBUSY; } vreg_enable(vreg_touch); } else { vreg_disable(vreg_touch); } } else if (lge_bd_rev >= LGE_REV_B) { static struct regulator *ldo1 = NULL; int rc; static int init = 0; ldo1 = regulator_get(NULL, "RT8053_LDO1"); if (ldo1 == NULL) pr_err("%s: regulator_get(ldo1) failed\n", __func__); if (onoff) { rc = regulator_set_voltage(ldo1, 3000000, 3000000); if (rc < 0) pr_err( "%s: regulator_set_voltage(ldo1) failed\n", __func__); rc = regulator_enable(ldo1); if (rc < 0) pr_err( "%s: regulator_enable(ldo1) failed\n", __func__); init = 1; } else { if (init > 0) { rc = regulator_disable(ldo1); if (rc < 0) pr_err( "%s: regulator_disble(ldo1) failed\n", __func__); regulator_put(ldo1); } } } return 0; }
static int cypress_cpt_ts_probe(struct i2c_client *client, const struct i2c_device_id *id) { int ret = 0; int j = 0; #ifdef CONFIG_CYPRESS_1044_UPDATE_TS_FIRMWARE static char version[10]; int firmware_id; #endif int gpio_config; if(machine_is_msm7x27_c8800()) { lcd_x = LCD_X_WVGA; lcd_y = LCD_Y_WVGA; v_key_h = VIRTUAL_KEYS_H_WVGA; } else { lcd_x = LCD_X_HVGA; lcd_y = LCD_Y_HVGA; v_key_h = VIRTUAL_KEYS_H_HVGA; } gpio_config = GPIO_CFG(29, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_UP, GPIO_CFG_2MA); ret = gpio_tlmm_config(gpio_config, GPIO_CFG_ENABLE); if(ret) { printk(KERN_ERR "GPIO_CFG failed\n"); } /* power on touchscreen */ struct vreg *v_gp5 = NULL; v_gp5 = vreg_get(NULL,"gp5"); ret = IS_ERR(v_gp5); if(ret) { goto err_power_failed; } ret = vreg_set_level(v_gp5,2700); ret = vreg_enable(v_gp5); msleep(200); struct cypress_cpt_ts_data *ts = NULL; #if defined (CONFIG_CYPRESS_TOUCHSCREEN_GESTURE) || defined (CONFIG_CYPRESS_TOUCHSCREEN_1044_EXTRA_KEY) int i; #endif if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) { printk(KERN_ERR "cypress_cpt_ts_probe: need I2C_FUNC_I2C\n"); ret = -ENODEV; goto err_check_functionality_failed; } cypress_ts_power_on_reset(client); /* detect make sure the client really exists */ for( j = 5; j > 0; j-- ) { ret = i2c_smbus_read_byte_data(client, 0x00); if ( ret >= 0 ) { break; } msleep(10); } if( j <= 0 ) { goto err_i2c_read_failed; } #ifdef CONFIG_CYPRESS_1044_UPDATE_TS_FIRMWARE g_client = client; for (i = 0 ; i < 3; i++) { ret= ts_firmware_file(); if (!ret) break; } #endif cypress_cpt_wq = create_singlethread_workqueue("cypress_cpt_wq"); if (!cypress_cpt_wq) { printk(KERN_ERR "%s: create_singlethread_workqueue failed\n", __FUNCTION__); goto err_work_init_failed; } ts = kzalloc(sizeof(*ts), GFP_KERNEL); if (ts == NULL) { ret = -ENOMEM; goto err_alloc_data_failed; } INIT_WORK(&ts->work, cypress_cpt_ts_work_func); ts->client = client; i2c_set_clientdata(client, ts); ts->input_dev = input_allocate_device(); if (ts->input_dev == NULL) { ret = -ENOMEM; printk(KERN_ERR "cypress_cpt_ts_probe: Failed to allocate input device\n"); goto err_input_dev_alloc_failed; } if(client->flags) { muti_touch = TRUE; i2c_read_len = I2C_MUTI_READ_LEN; } else { muti_touch = FALSE; i2c_read_len = I2C_SNGL_READ_LEN; } #ifdef CONFIG_CYPRESS_TOUCHSCREEN_1044_EXTRA_KEY ts->input_extra_dev = input_allocate_device(); if(ts->input_extra_dev == NULL) { ret = -ENOMEM; printk(KERN_ERR"%s: Failed to allocate input extra device \n", __FUNCTION__ ); goto err_input_dev_alloc_failed; } #endif ts->input_dev->name = "cypress_cpt"; set_bit(EV_SYN, ts->input_dev->evbit); set_bit(EV_ABS, ts->input_dev->evbit); set_bit(EV_KEY, ts->input_dev->evbit); set_bit(BTN_TOUCH, ts->input_dev->keybit); set_bit(ABS_X, ts->input_dev->absbit); set_bit(ABS_Y, ts->input_dev->absbit); set_bit(KEY_NUMLOCK, ts->input_dev->keybit); /* single or mutil touch both set as this */ input_set_abs_params(ts->input_dev, ABS_MT_POSITION_X,0,lcd_x, 0, 0); input_set_abs_params(ts->input_dev, ABS_MT_POSITION_Y, 0, lcd_y-v_key_h, 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); #ifdef CONFIG_CYPRESS_TOUCHSCREEN_GESTURE set_bit(EV_GESTURE, ts->input_dev->evbit); for (i = GESTURE_NO_GESTURE; i < GESTURE_MAX; i++) set_bit(i, ts->input_dev->gesturebit); #endif /*CONFIG_CYPRESS_TOUCHSCREEN_GESTURE*/ /* query version number */ #ifdef CONFIG_CYPRESS_1044_UPDATE_TS_FIRMWARE ts->input_dev->uniq = version; firmware_id = i2c_smbus_read_byte_data(g_client, 0x0c); version[0] = (firmware_id / 16) + '0'; version[1] = '.'; version[2] = (firmware_id % 16) + '0'; version[3] = '\0'; #endif ret = input_register_device(ts->input_dev); if (ret) { printk(KERN_ERR "cypress_cpt_ts_probe: Unable to register %s input device\n", ts->input_dev->name); goto err_input_register_device_failed; } #ifdef CONFIG_CYPRESS_TOUCHSCREEN_1044_EXTRA_KEY ts->input_extra_dev->name ="cypress extra key"; set_bit(EV_KEY, ts->input_extra_dev->evbit); for(i =0; i < MAX_EXTRA_TOUCH_KEY; i++) { set_bit(touch_extra_key_region.touch_extra_key[i].keycode&KEY_MAX, ts->input_extra_dev->keybit); } ret = input_register_device(ts->input_extra_dev); if(ret) { printk(KERN_ERR"%s: Unable to register input device %s", __FUNCTION__, ts->input_extra_dev->name); goto err_input_register_extra_device_failed; } #endif ret = gpio_request(29, "gpio 29 for touch"); if(ret) printk("%s: request gpio %d failed!\n", __FUNCTION__, client->irq); ret = gpio_direction_input(29); if (ret) printk("touchscreen gpio 45 direction input error!\n"); if (client->irq) { printk(KERN_ERR "%s@%d: cypress_cpt_ts_probe\n", __FILE__,__LINE__); ret = request_irq(client->irq, cypress_cpt_ts_irq_handler, IRQF_TRIGGER_FALLING, client->name, ts); if (ret == 0) ts->use_irq = 1; else printk("cypress_cpt_ts_probe: request_irq %d failed\n", client->irq); } if (!ts->use_irq) { printk("cypress use timer-based polling\n "); hrtimer_init(&ts->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL); ts->timer.function = cypress_cpt_ts_timer_func; hrtimer_start(&ts->timer, ktime_set(1, 0), HRTIMER_MODE_REL); } #ifdef CONFIG_HAS_EARLYSUSPEND ts->early_suspend.level = EARLY_SUSPEND_LEVEL_BLANK_SCREEN + 1; ts->early_suspend.suspend = cypress_cpt_ts_early_suspend; ts->early_suspend.resume = cypress_cpt_ts_late_resume; register_early_suspend(&ts->early_suspend); #endif CYPRESS_DEBUG(KERN_INFO "cpt_ts_probe: Start touchscreen %s in %s mode\n", ts->input_dev->name, ts->use_irq ? "interrupt" : "polling"); return 0; #ifdef CONFIG_CYPRESS_TOUCHSCREEN_1044_EXTRA_KEY err_input_register_extra_device_failed: input_free_device(ts->input_extra_dev); #endif err_input_register_device_failed: input_free_device(ts->input_dev); err_input_dev_alloc_failed: kfree(ts); err_alloc_data_failed: err_work_init_failed: err_i2c_read_failed: if(NULL != v_gp5) { ret = vreg_disable(v_gp5); } err_power_failed: err_check_functionality_failed: return ret; }