phonepad:modify pwm regulator and change tps65910 starting time
authorlw@rock-chips.com <lw@rock-chips.com>
Tue, 31 Jul 2012 10:48:12 +0000 (18:48 +0800)
committerlw <lw@rock-chips.com>
Tue, 31 Jul 2012 10:48:29 +0000 (18:48 +0800)
arch/arm/mach-rk30/board-rk30-phonepad.c
arch/arm/mach-rk30/board-rk30-sdk-tps65910.c
drivers/mfd/tps65910.c
drivers/regulator/rk30-pwm-regulator.c
drivers/regulator/tps65910-regulator.c
drivers/rtc/rtc-tps65910.c
include/linux/regulator/rk29-pwm-regulator.h [changed mode: 0644->0755]

index da846b9860093d78683180fcfae11f44d322195c..82a8f031d5ce1320cde8fb2fa3c61ebfdd184614 100755 (executable)
@@ -45,6 +45,7 @@
 #include <linux/rfkill-rk.h>
 #include <linux/sensor-dev.h>
 #include <linux/mfd/tps65910.h>
+#include <linux/regulator/rk29-pwm-regulator.h>
 #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
index 19677ddfedd24d459c81253a060eccc3fcc1adf3..ac2ee6b19f1f911f93baa773fe54fdcc44d58a9f 100755 (executable)
@@ -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);
index cc8a29ad09cd519d43052b1df1891f02c9fafd0e..dd7813012b433796621eda9eedfbbbf3745a671a 100755 (executable)
@@ -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)
 {
index 7a89527b0b06719dd30bf1fa5591f122501b4a14..07ab738f1792937bd5360e48b426637ea7fcfcd6 100755 (executable)
@@ -57,7 +57,7 @@ struct rk_pwm_dcdc {
         struct regulator_desc desc;\r
         int pwm_id;\r
         struct regulator_dev *regulator;\r
-               struct pwm_platform_data *pdata;\r
+       struct pwm_platform_data *pdata;\r
 };\r
 \r
 \r
@@ -70,7 +70,7 @@ struct rk_pwm_dcdc {
 #endif\r
 \r
 const static int pwm_voltage_map[] = {\r
-       850000,875000,900000,925000,950000, 975000, 1000000, 1025000, 1050000, 1075000, 1100000, 1125000, 1150000, 1175000, 1200000, 1225000, 1250000, 1275000, 1300000, 1325000\r
+       1000000, 1025000, 1050000, 1075000, 1100000, 1125000, 1150000, 1175000, 1200000, 1225000, 1250000, 1275000, 1300000, 1325000, 1350000, 1375000, 1400000\r
 };\r
 \r
 static struct clk *pwm_clk[2];\r
@@ -132,8 +132,9 @@ static int pwm_set_rate(struct pwm_platform_data *pdata,int nHz,u32 rate)
 \r
 static int pwm_regulator_list_voltage(struct regulator_dev *dev,unsigned int index)\r
 {\r
-       if (index < sizeof(pwm_voltage_map)/sizeof(int))\r
-               return pwm_voltage_map[index];\r
+       struct rk_pwm_dcdc *dcdc = rdev_get_drvdata(dev);\r
+       if (index < dcdc->desc.n_voltages)\r
+       return dcdc->pdata->pwm_voltage_map[index];\r
        else\r
                return -1;\r
 }\r
@@ -176,15 +177,14 @@ static int pwm_regulator_set_voltage(struct regulator_dev *dev,
 #endif\r
 {         \r
        struct rk_pwm_dcdc *dcdc = rdev_get_drvdata(dev);\r
-       const int *voltage_map = pwm_voltage_map;\r
-\r
-       int min_mV = min_uV, max_mA = max_uV;\r
-\r
-       u32 size = sizeof(pwm_voltage_map)/sizeof(int), i, vol,pwm_value;\r
+       const int *voltage_map = dcdc->pdata->pwm_voltage_map;\r
+       int max = dcdc->pdata->max_uV;\r
+       int duty_cycle = dcdc->pdata->duty_cycle;\r
+       u32 size = dcdc->desc.n_voltages, i, vol,pwm_value;\r
 \r
        DBG("%s:  min_uV = %d, max_uV = %d\n",__FUNCTION__, min_uV,max_uV);\r
 \r
-       if (min_mV < voltage_map[0] ||max_mA > voltage_map[size-1])\r
+       if (min_uV < voltage_map[0] ||max_uV > voltage_map[size-1])\r
        {\r
                printk("%s:voltage is out of table\n",__func__);\r
                return -EINVAL;\r
@@ -192,7 +192,7 @@ static int pwm_regulator_set_voltage(struct regulator_dev *dev,
 \r
        for (i = 0; i < size; i++)\r
        {\r
-               if (voltage_map[i] >= min_mV)\r
+               if (voltage_map[i] >= min_uV)\r
                        break;\r
        }\r
 \r
@@ -201,9 +201,8 @@ static int pwm_regulator_set_voltage(struct regulator_dev *dev,
 \r
        dcdc->pdata->pwm_voltage = vol;\r
 \r
-       // VDD12 = 1.42 - 0.56*D , ÆäÖÐDΪPWMÕ¼¿Õ±È, \r
-       pwm_value = (1325000-vol)/5800;  // pwm_value %\r
-\r
+       // VDD12 = 1.40 - 0.455*D , ÆäÖÐDΪPWMÕ¼¿Õ±È, \r
+       pwm_value = (max-vol)/duty_cycle/10;  // pwm_value %, duty_cycle = D*1000\r
 \r
        if (pwm_set_rate(dcdc->pdata,1000*1000,pwm_value)!=0)\r
        {\r
@@ -242,17 +241,25 @@ static int __devinit pwm_regulator_probe(struct platform_device *pdev)
        struct pwm_platform_data *pdata = pdev->dev.platform_data;\r
        struct rk_pwm_dcdc *dcdc;\r
        int pwm_id  =  pdata->pwm_id;\r
-       struct regulator_dev *rdev;\r
        int id = pdev->id;\r
        int ret ;\r
-    char gpio_name[20];\r
+       char gpio_name[20];\r
 \r
        if (!pdata)\r
                return -ENODEV;\r
 \r
        if (!pdata->pwm_voltage)\r
-               pdata->pwm_voltage = 1200000;   // default 1.2v\r
+               pdata->pwm_voltage = 1100000;   // default 1.1v\r
 \r
+       if(!pdata->pwm_voltage_map)\r
+               pdata->pwm_voltage_map = pwm_voltage_map;\r
+\r
+       if(!pdata->max_uV)\r
+               pdata->max_uV = 1400000;\r
+\r
+       if(!pdata->min_uV)\r
+               pdata->min_uV = 1000000;\r
+       \r
        dcdc = kzalloc(sizeof(struct rk_pwm_dcdc), GFP_KERNEL);\r
        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;\r
+       dcdc->desc.n_voltages = ARRAY_SIZE(pwm_voltage_map);\r
        dcdc->desc.ops = &pwm_voltage_ops;\r
        dcdc->desc.owner = THIS_MODULE;\r
        dcdc->pdata = pdata;\r
-\r
+       printk("%s:n_voltages=%d\n",__func__,dcdc->desc.n_voltages);\r
        dcdc->regulator = regulator_register(&dcdc->desc, &pdev->dev,\r
                                             pdata->init_data, dcdc);\r
        if (IS_ERR(dcdc->regulator)) {
index 0739da51efd20282b37c80712338ee2ff0c46a2f..22e06e2cb98e7b8cf0f4551a0e0056aa8dd7e4ed 100755 (executable)
@@ -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)
 {
index 43e9235c67c06c33cfdeb194b262a68dc9cb4b12..f6a8693cabcfd4a43ef2e478889c4130ede4c969 100755 (executable)
@@ -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)
 {      
old mode 100644 (file)
new mode 100755 (executable)
index e0a0487..a8c6917
@@ -57,6 +57,10 @@ struct pwm_platform_data {
        unsigned int    pwm_iomux_pwm;\r
        int     pwm_iomux_gpio;\r
        int     pwm_voltage;\r
+       int     duty_cycle;\r
+       int     min_uV;\r
+       int     max_uV;\r
+       int     *pwm_voltage_map;\r
        struct regulator_init_data *init_data;\r
 };