diff --git a/drivers/hwmon/pm8xxx-adc.c b/drivers/hwmon/pm8xxx-adc.c index ad19ea0835f9..363333254951 100644 --- a/drivers/hwmon/pm8xxx-adc.c +++ b/drivers/hwmon/pm8xxx-adc.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011-2012, The Linux Foundation. All rights reserved. + * Copyright (c) 2011-2013, The Linux Foundation. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 and @@ -31,6 +31,7 @@ #include #include #include +#include /* User Bank register set */ #define PM8XXX_ADC_ARB_USRP_CNTRL1 0x197 @@ -141,6 +142,7 @@ struct pm8xxx_adc { struct work_struct cool_work; uint32_t mpp_base; struct device *hwmon; + struct msm_xo_voter *adc_voter; int msm_suspend_check; struct pm8xxx_adc_amux_properties *conv; struct pm8xxx_adc_arb_btm_param batt; @@ -290,14 +292,34 @@ static int32_t pm8xxx_adc_patherm_power(bool on) return rc; } +static int32_t pm8xxx_adc_xo_vote(bool on) +{ + struct pm8xxx_adc *adc_pmic = pmic_adc; + + if (on) + msm_xo_mode_vote(adc_pmic->adc_voter, MSM_XO_MODE_ON); + else + msm_xo_mode_vote(adc_pmic->adc_voter, MSM_XO_MODE_OFF); + + return 0; +} + static int32_t pm8xxx_adc_channel_power_enable(uint32_t channel, bool power_cntrl) { int rc = 0; - switch (channel) + switch (channel) { case ADC_MPP_1_AMUX8: rc = pm8xxx_adc_patherm_power(power_cntrl); + break; + case CHANNEL_DIE_TEMP: + case CHANNEL_MUXOFF: + rc = pm8xxx_adc_xo_vote(power_cntrl); + break; + default: + break; + } return rc; } @@ -1147,6 +1169,7 @@ static int __devexit pm8xxx_adc_teardown(struct platform_device *pdev) struct pm8xxx_adc *adc_pmic = pmic_adc; int i; + msm_xo_put(adc_pmic->adc_voter); platform_set_drvdata(pdev, NULL); pmic_adc = NULL; if (!pa_therm) { @@ -1265,6 +1288,14 @@ static int __devinit pm8xxx_adc_probe(struct platform_device *pdev) } adc_pmic->hwmon = hwmon_device_register(adc_pmic->dev); + if (adc_pmic->adc_voter == NULL) { + adc_pmic->adc_voter = msm_xo_get(MSM_XO_TCXO_D0, "pmic_xoadc"); + if (IS_ERR(adc_pmic->adc_voter)) { + dev_err(&pdev->dev, "Failed to get XO vote\n"); + return PTR_ERR(adc_pmic->adc_voter); + } + } + pa_therm = regulator_get(adc_pmic->dev, "pa_therm"); if (IS_ERR(pa_therm)) { rc = PTR_ERR(pa_therm);