#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)
};
#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[] = {
.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],
},
};
#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
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
#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
\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
#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
\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
\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
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");
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)) {