static int bluetooth_switch_regulators(int on) { int i, rc = 0; const char *id = "BTPW"; for (i = 0; i < ARRAY_SIZE(bt_vregs); i++) { if (IS_ERR_OR_NULL(bt_vregs[i].reg)) { rc = bt_vregs[i].reg ? PTR_ERR(bt_vregs[i].reg) : -ENODEV; dev_err(&msm_bt_power_device.dev, "%s: invalid regulator handle for %s: %d\n", __func__, bt_vregs[i].name, rc); goto reg_disable; } rc = on ? regulator_set_voltage(bt_vregs[i].reg, bt_vregs[i].min_level, bt_vregs[i].max_level) : 0; if (rc) { dev_err(&msm_bt_power_device.dev, "%s: could not set voltage for %s: %d\n", __func__, bt_vregs[i].name, rc); goto reg_disable; } rc = on ? regulator_enable(bt_vregs[i].reg) : 0; if (rc) { dev_err(&msm_bt_power_device.dev, "%s: could not %sable regulator %s: %d\n", __func__, "en", bt_vregs[i].name, rc); goto reg_disable; } if (bt_vregs[i].is_pin_controlled) { rc = pmapp_vreg_lpm_pincntrl_vote(id, bt_vregs[i].pmapp_id, PMAPP_CLOCK_ID_D1, on ? PMAPP_CLOCK_VOTE_ON : PMAPP_CLOCK_VOTE_OFF); if (rc) { dev_err(&msm_bt_power_device.dev, "%s: pin control failed for %s: %d\n", __func__, bt_vregs[i].name, rc); goto pin_cnt_fail; } } rc = on ? 0 : regulator_disable(bt_vregs[i].reg); if (rc) { dev_err(&msm_bt_power_device.dev, "%s: could not %sable regulator %s: %d\n", __func__, "dis", bt_vregs[i].name, rc); goto reg_disable; } } return rc; pin_cnt_fail: if (on) regulator_disable(bt_vregs[i].reg); reg_disable: while (i) { if (on) { i--; regulator_disable(bt_vregs[i].reg); regulator_put(bt_vregs[i].reg); } } return rc; }
static unsigned int wlan_switch_regulators(int on) { int rc = 0, index = 0; if (machine_is_msm7627a_qrd1()) index = 2; for ( ; index < ARRAY_SIZE(vreg_info); index++) { if (on) { rc = regulator_set_voltage(vreg_info[index].reg, vreg_info[index].level_min, vreg_info[index].level_max); if (rc) { pr_err("%s:%s set voltage failed %d\n", __func__, vreg_info[index].vreg_id, rc); goto reg_disable; } rc = regulator_enable(vreg_info[index].reg); if (rc) { pr_err("%s:%s vreg enable failed %d\n", __func__, vreg_info[index].vreg_id, rc); goto reg_disable; } if (vreg_info[index].is_vreg_pin_controlled) { rc = pmapp_vreg_lpm_pincntrl_vote(id, vreg_info[index].pmapp_id, PMAPP_CLOCK_ID_A0, 1); if (rc) { pr_err("%s:%s pincntrl failed %d\n", __func__, vreg_info[index].vreg_id, rc); goto pin_cnt_fail; } } } else { if (vreg_info[index].is_vreg_pin_controlled) { rc = pmapp_vreg_lpm_pincntrl_vote(id, vreg_info[index].pmapp_id, PMAPP_CLOCK_ID_A0, 0); if (rc) { pr_err("%s:%s pincntrl failed %d\n", __func__, vreg_info[index].vreg_id, rc); goto pin_cnt_fail; } } rc = regulator_disable(vreg_info[index].reg); if (rc) { pr_err("%s:%s vreg disable failed %d\n", __func__, vreg_info[index].vreg_id, rc); goto reg_disable; } } } return 0; pin_cnt_fail: if (on) regulator_disable(vreg_info[index].reg); reg_disable: if (!machine_is_msm7627a_qrd1()) { while (index) { if (on) { index--; regulator_disable(vreg_info[index].reg); regulator_put(vreg_info[index].reg); } } } return rc; }
int chip_power_qrf6285(bool on) { static bool init_done; int rc = 0, index = 0; if (unlikely(!init_done)) { rc = qrf6285_init_regs(); if (rc) return rc; else init_done = true; } if (on) { rc = gpio_request(WLAN_GPIO_EXT_POR_N, "WLAN_DEEP_SLEEP_N"); if (rc) { pr_err("WLAN reset GPIO %d request failed %d\n", WLAN_GPIO_EXT_POR_N, rc); goto fail; } rc = gpio_direction_output(WLAN_GPIO_EXT_POR_N, 1); if (rc < 0) { pr_err("WLAN reset GPIO %d set direction failed %d\n", WLAN_GPIO_EXT_POR_N, rc); goto fail_gpio_dir_out; } rc = pmapp_clock_vote(id, PMAPP_CLOCK_ID_A0, PMAPP_CLOCK_VOTE_ON); if (rc) { pr_err("%s: Configuring A0 to always" " on failed %d\n", __func__, rc); goto clock_vote_fail; } } else { gpio_set_value_cansleep(WLAN_GPIO_EXT_POR_N, 0); rc = gpio_direction_input(WLAN_GPIO_EXT_POR_N); if (rc) { pr_err("WLAN reset GPIO %d set direction failed %d\n", WLAN_GPIO_EXT_POR_N, rc); } gpio_free(WLAN_GPIO_EXT_POR_N); rc = pmapp_clock_vote(id, PMAPP_CLOCK_ID_A0, PMAPP_CLOCK_VOTE_OFF); if (rc) { pr_err("%s: Configuring A0 to turn OFF" " failed %d\n", __func__, rc); } } for (index = 0; index < ARRAY_SIZE(vreg_info); index++) { if (on) { rc = regulator_set_voltage(vreg_info[index].reg, vreg_info[index].level_min, vreg_info[index].level_max); if (rc) { pr_err("%s:%s set voltage failed %d\n", __func__, vreg_info[index].vreg_id, rc); goto vreg_fail; } rc = regulator_enable(vreg_info[index].reg); if (rc) { pr_err("%s:%s vreg enable failed %d\n", __func__, vreg_info[index].vreg_id, rc); goto vreg_fail; } if (vreg_info[index].is_vreg_pin_controlled) { rc = pmapp_vreg_lpm_pincntrl_vote(id, vreg_info[index].pmapp_id, PMAPP_CLOCK_ID_A0, 1); if (rc) { pr_err("%s:%s pmapp_vreg_lpm_pincntrl" " for enable failed %d\n", __func__, vreg_info[index].vreg_id, rc); goto vreg_clock_vote_fail; } } /* */ if (WLAN_VREG_L6 == index) { /* */ rc = pmapp_clock_vote(id, PMAPP_CLOCK_ID_A0, PMAPP_CLOCK_VOTE_PIN_CTRL); if (rc) { pr_err("%s: Configuring A0 to Pin" " controllable failed %d\n", __func__, rc); goto vreg_clock_vote_fail; } } } else { if (vreg_info[index].is_vreg_pin_controlled) { rc = pmapp_vreg_lpm_pincntrl_vote(id, vreg_info[index].pmapp_id, PMAPP_CLOCK_ID_A0, 0); if (rc) { pr_err("%s:%s pmapp_vreg_lpm_pincntrl" " for disable failed %d\n", __func__, vreg_info[index].vreg_id, rc); } } rc = regulator_disable(vreg_info[index].reg); if (rc) { pr_err("%s:%s vreg disable failed %d\n", __func__, vreg_info[index].vreg_id, rc); } } } return 0; vreg_fail: index--; vreg_clock_vote_fail: while (index >= 0) { rc = regulator_disable(vreg_info[index].reg); if (rc) { pr_err("%s:%s vreg disable failed %d\n", __func__, vreg_info[index].vreg_id, rc); } index--; } if (!on) goto fail; clock_vote_fail: gpio_set_value_cansleep(WLAN_GPIO_EXT_POR_N, 0); rc = gpio_direction_input(WLAN_GPIO_EXT_POR_N); if (rc) { pr_err("WLAN reset GPIO %d set direction failed %d\n", WLAN_GPIO_EXT_POR_N, rc); } fail_gpio_dir_out: gpio_free(WLAN_GPIO_EXT_POR_N); fail: return rc; }
static int bluetooth_switch_regulators(int on) { int i, rc = 0; const char *id = "BTPW"; for (i = 0; i < ARRAY_SIZE(bt_vregs); i++) { if (IS_ERR_OR_NULL(bt_vregs[i].reg)) { bt_vregs[i].reg = regulator_get(&msm_bt_power_device.dev, bt_vregs[i].name); if (IS_ERR(bt_vregs[i].reg)) { rc = PTR_ERR(bt_vregs[i].reg); dev_err(&msm_bt_power_device.dev, "%s: could not get regulator %s: %d\n", __func__, bt_vregs[i].name, rc); goto reg_disable; } } rc = on ? regulator_set_voltage(bt_vregs[i].reg, bt_vregs[i].min_level, bt_vregs[i].max_level) : 0; if (rc) { dev_err(&msm_bt_power_device.dev, "%s: could not set voltage for %s: %d\n", __func__, bt_vregs[i].name, rc); goto reg_disable; } rc = on ? regulator_enable(bt_vregs[i].reg) : 0; if (rc) { dev_err(&msm_bt_power_device.dev, "%s: could not %sable regulator %s: %d\n", __func__, "en", bt_vregs[i].name, rc); goto reg_disable; } #if defined (CONFIG_ARIMA_BT_DBG_INFO) if (on) { printk(KERN_INFO "[BT_DBG] - vreg_enable(\"msme1\") by bluetooth_switch_regulators() \n"); } else { printk(KERN_INFO "[BT_DBG] - vreg_disable(\"msme1\") by bluetooth_switch_regulators() \n"); } #endif if (bt_vregs[i].is_pin_controlled) { rc = pmapp_vreg_lpm_pincntrl_vote(id, bt_vregs[i].pmapp_id, PMAPP_CLOCK_ID_D1, on ? PMAPP_CLOCK_VOTE_ON : PMAPP_CLOCK_VOTE_OFF); if (rc) { dev_err(&msm_bt_power_device.dev, "%s: pin control failed for %s: %d\n", __func__, bt_vregs[i].name, rc); goto pin_cnt_fail; } } rc = on ? 0 : regulator_disable(bt_vregs[i].reg); if (rc) { dev_err(&msm_bt_power_device.dev, "%s: could not %sable regulator %s: %d\n", __func__, "dis", bt_vregs[i].name, rc); goto reg_disable; } } return rc; pin_cnt_fail: if (on) regulator_disable(bt_vregs[i].reg); reg_disable: while (i) { if (on) { i--; regulator_disable(bt_vregs[i].reg); regulator_put(bt_vregs[i].reg); bt_vregs[i].reg = NULL; } } return rc; }
void msm7x27a_wifi_power(bool on) { int rc = 0, index = 0; static int resultFlag = 0, flag = 1; for (index = 0; index < ARRAY_SIZE(vreg_info); index++) { vreg_info[index].vreg = vreg_get(NULL, vreg_info[index].vreg_id); if (IS_ERR(vreg_info[index].vreg)) { pr_err("%s:%s vreg get failed %ld\n", __func__, vreg_info[index].vreg_id, PTR_ERR(vreg_info[index].vreg)); rc = PTR_ERR(vreg_info[index].vreg); if (on) goto vreg_fail; else continue; } if (on) { rc = vreg_set_level(vreg_info[index].vreg, vreg_info[index].vreg_level); if (rc) { pr_err("%s:%s vreg set level failed %d\n", __func__, vreg_info[index].vreg_id, rc); goto vreg_fail; } rc = vreg_enable(vreg_info[index].vreg); if (rc) { pr_err("%s:%s vreg enable failed %d\n", __func__, vreg_info[index].vreg_id, rc); goto vreg_fail; } if (vreg_info[index].is_vreg_pin_controlled) { rc = pmapp_vreg_lpm_pincntrl_vote(id, vreg_info[index].pmapp_id, PMAPP_CLOCK_ID_A0, 1); if (rc) { pr_err("%s:%s pmapp_vreg_lpm_pincntrl_vote" " for enable failed %d\n", __func__, vreg_info[index].vreg_id, rc); goto vreg_fail; } } if (index == WLAN_VREG_L17) usleep(5); else if (index == WLAN_VREG_L19) usleep(10); printk("\n vote for %s vreg. \n",vreg_info[index].vreg_id); } else { if (vreg_info[index].is_vreg_pin_controlled) { rc = pmapp_vreg_lpm_pincntrl_vote(id, vreg_info[index].pmapp_id, PMAPP_CLOCK_ID_A0, 0); if (rc) { pr_err("%s:%s pmapp_vreg_lpm_pincntrl_vote" " for disable failed %d\n", __func__, vreg_info[index].vreg_id, rc); } } rc = vreg_disable(vreg_info[index].vreg); if (rc) { pr_err("%s:%s vreg disable failed %d\n", __func__, vreg_info[index].vreg_id, rc); } printk("\n vote against %s vreg. \n",vreg_info[index].vreg_id); } } if (on) { rc = gpio_request(WLAN_GPIO_EXT_POR_N, "WLAN_DEEP_SLEEP_N"); if (rc) { pr_err("WLAN reset GPIO %d request failed %d\n", WLAN_GPIO_EXT_POR_N, rc); goto fail; } if(flag) { flag=0; rc = gpio_direction_output(WLAN_GPIO_EXT_POR_N, 1); if (rc < 0) { pr_err("WLAN reset GPIO %d set direction failed %d\n", WLAN_GPIO_EXT_POR_N, rc); goto fail_gpio_dir_out; } } #ifdef A0_CLOCK rc = pmapp_clock_vote(id, PMAPP_CLOCK_ID_A0, PMAPP_CLOCK_VOTE_ON); printk("\nVote for A0 clock done\n"); rc = pmapp_clock_vote(id, PMAPP_CLOCK_ID_A0, PMAPP_CLOCK_VOTE_PIN_CTRL); if (rc) { pr_err("%s: Configuring A0 clock to Pin controllable failed %d\n", __func__, rc); } #else rc = pmapp_clock_vote(id, PMAPP_CLOCK_ID_A0, PMAPP_CLOCK_VOTE_OFF); printk("\nVote against A0 clock done\n"); #endif if (rc) { pr_err("%s: Configuring A0 to turn off" " failed %d\n", __func__, rc); } printk("\n vote for WLAN GPIO 134 done. \n"); } else { if(!resultFlag){ gpio_set_value_cansleep(WLAN_GPIO_EXT_POR_N, 0); rc = gpio_direction_input(WLAN_GPIO_EXT_POR_N); if (rc) { pr_err("WLAN reset GPIO %d set direction failed %d\n", WLAN_GPIO_EXT_POR_N, rc); } gpio_free(WLAN_GPIO_EXT_POR_N); printk("\n vote against WLAN GPIO 134 done. \n"); } rc = pmapp_clock_vote(id, PMAPP_CLOCK_ID_A0, PMAPP_CLOCK_VOTE_OFF); if (rc) { pr_err("%s: Configuring A0 to turn OFF" " failed %d\n", __func__, rc); } } printk("Interface %s success \n",on?"initialization":"deinitialization"); resultFlag = 0; return; fail_gpio_dir_out: gpio_free(WLAN_GPIO_EXT_POR_N); vreg_fail: index--; while (index > 0) { rc = vreg_disable(vreg_info[index].vreg); if (rc) { pr_err("%s:%s vreg disable failed %d\n", __func__, vreg_info[index].vreg_id, rc); } index--; } if (!on) goto fail; fail: resultFlag = 1; printk("Interface %s failed \n",on?"initialization":"deinitialization"); return; }
static int bluetooth_switch_regulators(int on) { int i, rc = 0; const char *id = "BTPW"; for (i = 0; i < ARRAY_SIZE(bt_vregs); i++) { if (IS_ERR_OR_NULL(bt_vregs[i].reg)) { //Cellon add start, Eagle.Yin, 2012/12/27 for debug WCN2243 code bt_vregs[i].reg = regulator_get(&msm_bt_power_device.dev, bt_vregs[i].name); if (IS_ERR(bt_vregs[i].reg)) { rc = PTR_ERR(bt_vregs[i].reg); dev_err(&msm_bt_power_device.dev, "%s: could not get regulator %s: %d\n", __func__, bt_vregs[i].name, rc); goto reg_disable; } //Cellon add end, Eagle.Yin, 2012/12/27 for debug WCN2243 code } rc = on ? regulator_set_voltage(bt_vregs[i].reg, bt_vregs[i].min_level, bt_vregs[i].max_level) : 0; if (rc) { dev_err(&msm_bt_power_device.dev, "%s: could not set voltage for %s: %d\n", __func__, bt_vregs[i].name, rc); goto reg_disable; } rc = on ? regulator_enable(bt_vregs[i].reg) : 0; if (rc) { dev_err(&msm_bt_power_device.dev, "%s: could not %sable regulator %s: %d\n", __func__, "en", bt_vregs[i].name, rc); goto reg_disable; } //Cellon add start, Eagle.Yin, 2012/12/27 for debug WCN2243 code dev_info(&msm_bt_power_device.dev, "%s: regulator_get_voltage of %s is %d\n", __func__, bt_vregs[i].name, regulator_get_voltage(bt_vregs[i].reg)); //Cellon add end, Eagle.Yin, 2012/12/27 for debug WCN2243 code if (bt_vregs[i].is_pin_controlled) { rc = pmapp_vreg_lpm_pincntrl_vote(id, bt_vregs[i].pmapp_id, PMAPP_CLOCK_ID_D1, on ? PMAPP_CLOCK_VOTE_ON : PMAPP_CLOCK_VOTE_OFF); if (rc) { dev_err(&msm_bt_power_device.dev, "%s: pin control failed for %s: %d\n", __func__, bt_vregs[i].name, rc); goto pin_cnt_fail; } } rc = on ? 0 : regulator_disable(bt_vregs[i].reg); if (rc) { dev_err(&msm_bt_power_device.dev, "%s: could not %sable regulator %s: %d\n", __func__, "dis", bt_vregs[i].name, rc); goto reg_disable; } } return rc; pin_cnt_fail: if (on) regulator_disable(bt_vregs[i].reg); reg_disable: while (i) { if (on) { i--; regulator_disable(bt_vregs[i].reg); regulator_put(bt_vregs[i].reg); //Cellon add start, Eagle.Yin, 2012/12/27 for debug WCN2243 code bt_vregs[i].reg = NULL; //Cellon add end, Eagle.Yin, 2012/12/27 for debug WCN2243 code } } return rc; }