static void fm_radio_shutdown(struct marimba_fm_platform_data *pdata)
{
	int rc;
	const char *id = "FMPW";

	/* Releasing the GPIO line used by FM */
	uint32_t irqcfg = GPIO_CFG(FM_GPIO, 0, GPIO_CFG_INPUT,
		GPIO_CFG_PULL_UP, 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);

	/* Releasing the 1.8V Regulator */
	if (!IS_ERR_OR_NULL(fm_regulator)) {
		rc = regulator_disable(fm_regulator);
		if (rc)
			pr_err("%s: could not disable regulator: %d\n",
					__func__, rc);
		regulator_put(fm_regulator);
		fm_regulator = NULL;
	}

	/* Voting off the clock */
	rc = pmapp_clock_vote(id, PMAPP_CLOCK_ID_D1,
		PMAPP_CLOCK_VOTE_OFF);
	if (rc < 0)
		pr_err("%s: voting off failed with :(%d)\n",
			__func__, rc);
	rc = bt_set_gpio(0);
	if (rc)
		pr_err("%s: bt_set_gpio = %d", __func__, rc);
}
static int pn544_clock_output_mode_ctrl(void)
{
       const char * id = "nfcp";
	pmapp_clock_vote(id, PMAPP_CLOCK_ID_D1,
		PMAPP_CLOCK_VOTE_PIN_CTRL);
	return 0;
}
static int pn544_clock_output_ctrl(int vote)
{
       const char * id = "nfcp";
	pmapp_clock_vote(id, PMAPP_CLOCK_ID_D1,
		vote?PMAPP_CLOCK_VOTE_ON:PMAPP_CLOCK_VOTE_OFF);
	return 0;
}
static unsigned int setup_wlan_clock(bool on)
{
	int rc = 0;

	if (on) {
		/* Vote for A0 clock */
		rc = pmapp_clock_vote(id, PMAPP_CLOCK_ID_A0,
					PMAPP_CLOCK_VOTE_ON);
	} else {
		/* Vote against A0 clock */
		rc = pmapp_clock_vote(id, PMAPP_CLOCK_ID_A0,
					 PMAPP_CLOCK_VOTE_OFF);
	}

	if (rc)
		pr_err("%s: Configuring A0 clock for WLAN: Error", __func__);

	return rc;
}
예제 #5
0
static int wlan_clock_req(int on)
{
    const char *id = "WLPW";
    int ret = 0;
 
            printk("enter wlan_clock_req\n");
    if (on) {
        ret = pmapp_clock_vote(id, PMAPP_CLOCK_ID_A0,
                        PMAPP_CLOCK_VOTE_ON);
        if (ret < 0) {
            printk("Failed to vote for TCXO_A0 ON\n");
            return ret;
        }
        msleep(20);
        ret = pmapp_clock_vote(id, PMAPP_CLOCK_ID_A0,
                                  PMAPP_CLOCK_VOTE_PIN_CTRL);
        if (ret < 0) {
            printk("%s:Pin Control Failed, rc = %d",
                                        __func__, ret);
            return ret;
        }
 
        printk("%s() Enable 19.2MHz clock from PMIC\n", __func__);
 
    } else {
        ret = pmapp_clock_vote(id, PMAPP_CLOCK_ID_A0,
                        PMAPP_CLOCK_VOTE_OFF);
        if (ret < 0) {
            printk("Failed to vote for TCXO_A0 OFF\n");
            return ret;
        }
 
        printk("%s() Turn off 19.2MHz clock from PMIC\n", __func__);
 
    }
    msleep(100);
    return ret;
}
예제 #6
0
static int blueclock_start(void)
{// here is the main fucntion:

    int rc = 0;
    const char *id = "BTPW";

    printk(KERN_INFO "------blueclock_start is in! \n");

    rc = pmapp_clock_vote(id, PMAPP_CLOCK_ID_DO,
                        PMAPP_CLOCK_VOTE_PIN_CTRL);
    
    if (rc < 0)
    {
        printk(KERN_INFO "------pmapp_clock_vote error \n");
        return -1;
    }
    
    printk(KERN_INFO "------pmapp_clock_vote OK! \n");
    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 = regulator_get(NULL , "msme1");
	if (IS_ERR(fm_regulator)) {
		rc = PTR_ERR(fm_regulator);
		pr_err("%s: could not get regulator: %d\n", __func__, rc);
		goto out;
	}

	/* Set the voltage level to 1.8V */
	rc = regulator_set_voltage(fm_regulator, 1800000, 1800000);
	if (rc < 0) {
		pr_err("%s: could not set voltage: %d\n", __func__, rc);
		goto reg_free;
	}

	/* Enabling the 1.8V regulator */
	rc = regulator_enable(fm_regulator);
	if (rc) {
		pr_err("%s: could not enable regulator: %d\n", __func__, rc);
		goto reg_free;
	}

	/* 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 reg_disable;
	}

	rc = bt_set_gpio(1);
	if (rc) {
		pr_err("%s: bt_set_gpio = %d", __func__, rc);
		goto gpio_deconfig;
	}
	/*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 gpio_deconfig;
	}
	/* 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 gpio_deconfig;
	}

	return 0;

gpio_deconfig:
	pmapp_clock_vote(id, PMAPP_CLOCK_ID_D1,
		PMAPP_CLOCK_VOTE_OFF);
	bt_set_gpio(0);
reg_disable:
	regulator_disable(fm_regulator);
reg_free:
	regulator_put(fm_regulator);
	fm_regulator = NULL;
out:
	return rc;
};
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 {
	    gpio_tlmm_config(GPIO_CFG(gpio_wlan_sys_rest_en, 0, GPIO_CFG_OUTPUT,
				    GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
				    GPIO_CFG_ENABLE);	
		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()))
			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;
}
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;
}
예제 #10
0
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;
}