From dadb0ed4e9432619a473f9a9bdd28c26df810540 Mon Sep 17 00:00:00 2001 From: "lw@rock-chips.com" Date: Tue, 31 Jul 2012 18:48:12 +0800 Subject: [PATCH] phonepad:modify pwm regulator and change tps65910 starting time --- arch/arm/mach-rk30/board-rk30-phonepad.c | 19 +++++---- arch/arm/mach-rk30/board-rk30-sdk-tps65910.c | 8 +--- drivers/mfd/tps65910.c | 2 +- drivers/regulator/rk30-pwm-regulator.c | 45 +++++++++++--------- drivers/regulator/tps65910-regulator.c | 2 +- drivers/rtc/rtc-tps65910.c | 2 +- include/linux/regulator/rk29-pwm-regulator.h | 4 ++ 7 files changed, 45 insertions(+), 37 deletions(-) mode change 100644 => 100755 include/linux/regulator/rk29-pwm-regulator.h diff --git a/arch/arm/mach-rk30/board-rk30-phonepad.c b/arch/arm/mach-rk30/board-rk30-phonepad.c index da846b986009..82a8f031d5ce 100755 --- a/arch/arm/mach-rk30/board-rk30-phonepad.c +++ b/arch/arm/mach-rk30/board-rk30-phonepad.c @@ -45,6 +45,7 @@ #include #include #include +#include #include "../../../drivers/headset_observe/rk_headset.h" #if defined(CONFIG_HDMI_RK30) @@ -1516,15 +1517,8 @@ static struct platform_device rk30_device_adc_battery = { }; #endif #if CONFIG_RK30_PWM_REGULATOR -struct pwm_platform_data { - int pwm_id; - int pwm_gpio; - //char pwm_iomux_name[50]; - char* pwm_iomux_name; - unsigned int pwm_iomux_pwm; - int pwm_iomux_gpio; - int pwm_voltage; - struct regulator_init_data *init_data; +const static int pwm_voltage_map[] = { + 1000000, 1025000, 1050000, 1075000, 1100000, 1125000, 1150000, 1175000, 1200000, 1225000, 1250000, 1275000, 1300000, 1325000, 1350000, 1375000, 1400000 }; static struct regulator_consumer_supply pwm_dcdc1_consumers[] = { @@ -1556,6 +1550,10 @@ static struct pwm_platform_data pwm_regulator_info[1] = { .pwm_iomux_pwm = GPIO0D_PWM3, .pwm_iomux_gpio = GPIO0D_GPIO0D6, .pwm_voltage = 1100000, + .min_uV = 1000000, + .max_uV = 1400000, + .duty_cycle = 455, //45.5% + .pwm_voltage_map = pwm_voltage_map, .init_data = &pwm_regulator_init_dcdc[0], }, }; @@ -1639,6 +1637,9 @@ static struct platform_device device_rfkill_rk = { #endif static struct platform_device *devices[] __initdata = { +#ifdef CONFIG_RK30_PWM_REGULATOR + &pwm_regulator_device[0], +#endif #ifdef CONFIG_BACKLIGHT_RK29_BL &rk29_device_backlight, #endif diff --git a/arch/arm/mach-rk30/board-rk30-sdk-tps65910.c b/arch/arm/mach-rk30/board-rk30-sdk-tps65910.c index 19677ddfedd2..ac2ee6b19f1f 100755 --- a/arch/arm/mach-rk30/board-rk30-sdk-tps65910.c +++ b/arch/arm/mach-rk30/board-rk30-sdk-tps65910.c @@ -34,11 +34,7 @@ int tps65910_pre_init(struct tps65910 *tps65910){ int val = 0; int i = 0; int err = -1; - - #ifdef CONFIG_RK30_PWM_REGULATOR - platform_device_register(&pwm_regulator_device[0]); - #endif - + printk("%s,line=%d\n", __func__,__LINE__); //gpio_request(PMU_POWER_SLEEP, "NULL"); //gpio_direction_output(PMU_POWER_SLEEP, GPIO_HIGH); @@ -313,7 +309,7 @@ int tps65910_post_init(struct tps65910 *tps65910) #ifdef CONFIG_RK30_PWM_REGULATOR dcdc = regulator_get(NULL, "vdd_core"); // vdd_log - regulator_set_voltage(dcdc, 1150000, 1150000); + regulator_set_voltage(dcdc, 1100000, 1100000); regulator_enable(dcdc); printk("%s set vdd_core=%dmV end\n", __func__, regulator_get_voltage(dcdc)); regulator_put(dcdc); diff --git a/drivers/mfd/tps65910.c b/drivers/mfd/tps65910.c index cc8a29ad09cd..dd7813012b43 100755 --- a/drivers/mfd/tps65910.c +++ b/drivers/mfd/tps65910.c @@ -364,7 +364,7 @@ static int __init tps65910_i2c_init(void) return i2c_add_driver(&tps65910_i2c_driver); } /* init early so consumer devices can complete system boot */ -module_init(tps65910_i2c_init); +subsys_initcall_sync(tps65910_i2c_init); static void __exit tps65910_i2c_exit(void) { diff --git a/drivers/regulator/rk30-pwm-regulator.c b/drivers/regulator/rk30-pwm-regulator.c index 7a89527b0b06..07ab738f1792 100755 --- a/drivers/regulator/rk30-pwm-regulator.c +++ b/drivers/regulator/rk30-pwm-regulator.c @@ -57,7 +57,7 @@ struct rk_pwm_dcdc { struct regulator_desc desc; int pwm_id; struct regulator_dev *regulator; - struct pwm_platform_data *pdata; + struct pwm_platform_data *pdata; }; @@ -70,7 +70,7 @@ struct rk_pwm_dcdc { #endif const static int pwm_voltage_map[] = { - 850000,875000,900000,925000,950000, 975000, 1000000, 1025000, 1050000, 1075000, 1100000, 1125000, 1150000, 1175000, 1200000, 1225000, 1250000, 1275000, 1300000, 1325000 + 1000000, 1025000, 1050000, 1075000, 1100000, 1125000, 1150000, 1175000, 1200000, 1225000, 1250000, 1275000, 1300000, 1325000, 1350000, 1375000, 1400000 }; static struct clk *pwm_clk[2]; @@ -132,8 +132,9 @@ static int pwm_set_rate(struct pwm_platform_data *pdata,int nHz,u32 rate) static int pwm_regulator_list_voltage(struct regulator_dev *dev,unsigned int index) { - if (index < sizeof(pwm_voltage_map)/sizeof(int)) - return pwm_voltage_map[index]; + struct rk_pwm_dcdc *dcdc = rdev_get_drvdata(dev); + if (index < dcdc->desc.n_voltages) + return dcdc->pdata->pwm_voltage_map[index]; else return -1; } @@ -176,15 +177,14 @@ static int pwm_regulator_set_voltage(struct regulator_dev *dev, #endif { struct rk_pwm_dcdc *dcdc = rdev_get_drvdata(dev); - const int *voltage_map = pwm_voltage_map; - - int min_mV = min_uV, max_mA = max_uV; - - u32 size = sizeof(pwm_voltage_map)/sizeof(int), i, vol,pwm_value; + const int *voltage_map = dcdc->pdata->pwm_voltage_map; + int max = dcdc->pdata->max_uV; + int duty_cycle = dcdc->pdata->duty_cycle; + u32 size = dcdc->desc.n_voltages, i, vol,pwm_value; DBG("%s: min_uV = %d, max_uV = %d\n",__FUNCTION__, min_uV,max_uV); - if (min_mV < voltage_map[0] ||max_mA > voltage_map[size-1]) + if (min_uV < voltage_map[0] ||max_uV > voltage_map[size-1]) { printk("%s:voltage is out of table\n",__func__); return -EINVAL; @@ -192,7 +192,7 @@ static int pwm_regulator_set_voltage(struct regulator_dev *dev, for (i = 0; i < size; i++) { - if (voltage_map[i] >= min_mV) + if (voltage_map[i] >= min_uV) break; } @@ -201,9 +201,8 @@ static int pwm_regulator_set_voltage(struct regulator_dev *dev, dcdc->pdata->pwm_voltage = vol; - // VDD12 = 1.42 - 0.56*D , ÆäÖÐDΪPWMÕ¼¿Õ±È, - pwm_value = (1325000-vol)/5800; // pwm_value % - + // VDD12 = 1.40 - 0.455*D , ÆäÖÐDΪPWMÕ¼¿Õ±È, + pwm_value = (max-vol)/duty_cycle/10; // pwm_value %, duty_cycle = D*1000 if (pwm_set_rate(dcdc->pdata,1000*1000,pwm_value)!=0) { @@ -242,17 +241,25 @@ static int __devinit pwm_regulator_probe(struct platform_device *pdev) struct pwm_platform_data *pdata = pdev->dev.platform_data; struct rk_pwm_dcdc *dcdc; int pwm_id = pdata->pwm_id; - struct regulator_dev *rdev; int id = pdev->id; int ret ; - char gpio_name[20]; + char gpio_name[20]; if (!pdata) return -ENODEV; if (!pdata->pwm_voltage) - pdata->pwm_voltage = 1200000; // default 1.2v + pdata->pwm_voltage = 1100000; // default 1.1v + if(!pdata->pwm_voltage_map) + pdata->pwm_voltage_map = pwm_voltage_map; + + if(!pdata->max_uV) + pdata->max_uV = 1400000; + + if(!pdata->min_uV) + pdata->min_uV = 1000000; + dcdc = kzalloc(sizeof(struct rk_pwm_dcdc), GFP_KERNEL); if (dcdc == NULL) { dev_err(&pdev->dev, "Unable to allocate private data\n"); @@ -263,11 +270,11 @@ static int __devinit pwm_regulator_probe(struct platform_device *pdev) dcdc->desc.name = dcdc->name; dcdc->desc.id = id; dcdc->desc.type = REGULATOR_VOLTAGE; - dcdc->desc.n_voltages = 50; + dcdc->desc.n_voltages = ARRAY_SIZE(pwm_voltage_map); dcdc->desc.ops = &pwm_voltage_ops; dcdc->desc.owner = THIS_MODULE; dcdc->pdata = pdata; - + printk("%s:n_voltages=%d\n",__func__,dcdc->desc.n_voltages); dcdc->regulator = regulator_register(&dcdc->desc, &pdev->dev, pdata->init_data, dcdc); if (IS_ERR(dcdc->regulator)) { diff --git a/drivers/regulator/tps65910-regulator.c b/drivers/regulator/tps65910-regulator.c index 0739da51efd2..22e06e2cb98e 100755 --- a/drivers/regulator/tps65910-regulator.c +++ b/drivers/regulator/tps65910-regulator.c @@ -1324,7 +1324,7 @@ static int __init tps65910_init(void) { return platform_driver_register(&tps65910_driver); } -module_init(tps65910_init); +subsys_initcall_sync(tps65910_init); static void __exit tps65910_cleanup(void) { diff --git a/drivers/rtc/rtc-tps65910.c b/drivers/rtc/rtc-tps65910.c index 43e9235c67c0..f6a8693cabcf 100755 --- a/drivers/rtc/rtc-tps65910.c +++ b/drivers/rtc/rtc-tps65910.c @@ -681,7 +681,7 @@ static int __init tps65910_rtc_init(void) misc_register(&rtc_tps65910_test_misc); return platform_driver_register(&tps65910_rtc_driver); } -module_init(tps65910_rtc_init); +subsys_initcall_sync(tps65910_rtc_init); static void __exit tps65910_rtc_exit(void) { diff --git a/include/linux/regulator/rk29-pwm-regulator.h b/include/linux/regulator/rk29-pwm-regulator.h old mode 100644 new mode 100755 index e0a0487d2a85..a8c691727f47 --- a/include/linux/regulator/rk29-pwm-regulator.h +++ b/include/linux/regulator/rk29-pwm-regulator.h @@ -57,6 +57,10 @@ struct pwm_platform_data { unsigned int pwm_iomux_pwm; int pwm_iomux_gpio; int pwm_voltage; + int duty_cycle; + int min_uV; + int max_uV; + int *pwm_voltage_map; struct regulator_init_data *init_data; }; -- 2.34.1