static unsigned int msm_AR600X_setup_power(bool on) { int rc = 0; static bool init_done; if (wlan_powered_up) { pr_info("WLAN already powered up\n"); return 0; } if (unlikely(!init_done)) { gpio_wlan_config(); rc = qrf6285_init_regs(); if (rc) { pr_err("%s: qrf6285 init failed = %d\n", __func__, rc); return rc; } else { init_done = true; } } rc = wlan_switch_regulators(on); if (rc) { pr_err("%s: wlan_switch_regulators error = %d\n", __func__, rc); goto out; } /* GPIO_WLAN_3V3_EN is only required for the QRD7627a */ if (machine_is_msm7627a_qrd1()) { rc = gpio_tlmm_config(GPIO_CFG(GPIO_WLAN_3V3_EN, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), GPIO_CFG_ENABLE); if (rc) { pr_err("%s gpio_tlmm_config 119 failed,error = %d\n", __func__, rc); goto reg_disable; } gpio_set_value(GPIO_WLAN_3V3_EN, 1); } /* * gpio_wlan_sys_rest_en is not from the GPIO expander for QRD7627a, * EVB1.0 and QRD8625,so the below step is required for those devices. */ if (machine_is_msm7627a_qrd1() || machine_is_msm7627a_evb() || machine_is_msm8625_evb() || machine_is_msm8625_evt() || machine_is_msm7627a_qrd3() || machine_is_msm8625_qrd7()) { rc = gpio_tlmm_config(GPIO_CFG(gpio_wlan_sys_rest_en, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), GPIO_CFG_ENABLE); if (rc) { pr_err("%s gpio_tlmm_config 119 failed,error = %d\n", __func__, rc); goto qrd_gpio_fail; } gpio_set_value(gpio_wlan_sys_rest_en, 1); } else { rc = gpio_request(gpio_wlan_sys_rest_en, "WLAN_DEEP_SLEEP_N"); if (rc) { pr_err("%s: WLAN sys_rest_en GPIO %d request failed %d\n", __func__, gpio_wlan_sys_rest_en, rc); goto qrd_gpio_fail; } rc = setup_wlan_gpio(on); if (rc) { pr_err("%s: wlan_set_gpio = %d\n", __func__, rc); goto gpio_fail; } } /* Enable the A0 clock */ rc = setup_wlan_clock(on); if (rc) { pr_err("%s: setup_wlan_clock = %d\n", __func__, rc); goto set_gpio_fail; } /* Configure A0 clock to be slave to WLAN_CLK_PWR_REQ */ 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 set_clock_fail; } pr_info("WLAN power-up success\n"); wlan_powered_up = true; return 0; set_clock_fail: setup_wlan_clock(0); set_gpio_fail: setup_wlan_gpio(0); gpio_fail: if (!(machine_is_msm7627a_qrd1() || machine_is_msm7627a_evb() || machine_is_msm8625_evb() || machine_is_msm8625_evt() || machine_is_msm7627a_qrd3() || machine_is_msm8625_qrd7() || machine_is_msm8625q_evbd() || machine_is_qrd_skud_prime())) gpio_free(gpio_wlan_sys_rest_en); qrd_gpio_fail: /* GPIO_WLAN_3V3_EN is only required for the QRD7627a */ if (machine_is_msm7627a_qrd1()) gpio_free(GPIO_WLAN_3V3_EN); reg_disable: wlan_switch_regulators(0); out: pr_info("WLAN power-up failed\n"); wlan_powered_up = false; return rc; }
static unsigned int msm_AR600X_shutdown_power(bool on) { int rc = 0; if (!wlan_powered_up) { pr_info("WLAN is not powered up, returning success\n"); return 0; } /* Disable the A0 clock */ rc = setup_wlan_clock(on); if (rc) { pr_err("%s: setup_wlan_clock = %d\n", __func__, rc); goto set_clock_fail; } /* * gpio_wlan_sys_rest_en is not from the GPIO expander for QRD7627a, * EVB1.0 and QRD8625,so the below step is required for those devices. */ if (machine_is_msm7627a_qrd1() || machine_is_msm7627a_evb() || machine_is_msm8625_evb() || machine_is_msm8625_evt() || machine_is_msm7627a_qrd3() || machine_is_msm8625_qrd7() || machine_is_msm8625q_evbd() || machine_is_qrd_skud_prime()) { rc = gpio_tlmm_config(GPIO_CFG(gpio_wlan_sys_rest_en, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), GPIO_CFG_ENABLE); if (rc) { pr_err("%s gpio_tlmm_config 119 failed,error = %d\n", __func__, rc); goto gpio_fail; } gpio_set_value(gpio_wlan_sys_rest_en, 0); } else { #ifdef CONFIG_HUAWEI_KERNEL /* rollback to 1030 baseline */ gpio_request(gpio_wlan_sys_rest_en, "WLAN_DEEP_SLEEP_N"); rc = setup_wlan_gpio(on); if (rc) { pr_err("%s: wlan_set_gpio = %d\n", __func__, rc); goto set_gpio_fail; } gpio_free(gpio_wlan_sys_rest_en); #else rc = setup_wlan_gpio(on); if (rc) { pr_err("%s: setup_wlan_gpio = %d\n", __func__, rc); goto set_gpio_fail; } gpio_free(gpio_wlan_sys_rest_en); #endif } /* GPIO_WLAN_3V3_EN is only required for the QRD7627a */ if (machine_is_msm7627a_qrd1()) { rc = gpio_tlmm_config(GPIO_CFG(GPIO_WLAN_3V3_EN, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), GPIO_CFG_ENABLE); if (rc) { pr_err("%s gpio_tlmm_config 119 failed,error = %d\n", __func__, rc); goto qrd_gpio_fail; } gpio_set_value(GPIO_WLAN_3V3_EN, 0); } rc = wlan_switch_regulators(on); if (rc) { pr_err("%s: wlan_switch_regulators error = %d\n", __func__, rc); goto reg_disable; } wlan_powered_up = false; pr_info("WLAN power-down success\n"); return 0; set_clock_fail: setup_wlan_clock(0); set_gpio_fail: setup_wlan_gpio(0); gpio_fail: if (!(machine_is_msm7627a_qrd1() || machine_is_msm7627a_evb() || machine_is_msm8625_evb() || machine_is_msm8625_evt() || machine_is_msm7627a_qrd3() || machine_is_msm8625_qrd7())) gpio_free(gpio_wlan_sys_rest_en); qrd_gpio_fail: /* GPIO_WLAN_3V3_EN is only required for the QRD7627a */ if (machine_is_msm7627a_qrd1()) gpio_free(GPIO_WLAN_3V3_EN); reg_disable: wlan_switch_regulators(0); #ifndef CONFIG_HUAWEI_KERNEL out: pr_info("WLAN power-down failed\n"); #endif return rc; }