linux3.10:pwm:renamed rk30/rk29-pwm-regulator to rockchip-pwm-regulator

This commit is contained in:
张晴
2014-03-17 11:39:27 +08:00
parent 44931817e5
commit 3d0820f5a9
3 changed files with 62 additions and 62 deletions

View File

@@ -52,7 +52,7 @@ obj-$(CONFIG_REGULATOR_RC5T583) += rc5t583-regulator.o
obj-$(CONFIG_REGULATOR_S2MPS11) += s2mps11.o
obj-$(CONFIG_REGULATOR_S5M8767) += s5m8767.o
obj-$(CONFIG_ROCKCHIP_PWM_REGULATOR) += rk30-pwm-regulator.o
obj-$(CONFIG_ROCKCHIP_PWM_REGULATOR) += rockchip-pwm-regulator.o
obj-$(CONFIG_REGULATOR_TPS6105X) += tps6105x-regulator.o
obj-$(CONFIG_REGULATOR_TPS62360) += tps62360-regulator.o

View File

@@ -20,19 +20,19 @@
#include <asm/io.h>
#include <linux/delay.h>
#include <linux/slab.h>
#include <linux/regulator/rk29-pwm-regulator.h>
#include <linux/gpio.h>
#include <linux/of_gpio.h>
#include <linux/regulator/rockchip-pwm-regulator.h>
#include <linux/gpio.h>
#include <linux/of_gpio.h>
#include <linux/module.h>
#include <linux/init.h>
#include <linux/init.h>
#include <linux/err.h>
#include <linux/pwm.h>
#include <linux/of.h>
#include <linux/of_device.h>
#include <linux/of.h>
#include <linux/of_device.h>
#include <linux/regulator/of_regulator.h>
#include <linux/regulator/driver.h>
#include <linux/regulator/machine.h>
#include <linux/regulator/driver.h>
#include <linux/regulator/machine.h>
#if 1
@@ -160,11 +160,11 @@ static struct regulator_desc regulators[] = {
},
};
#ifdef CONFIG_OF
#ifdef CONFIG_OF
static struct of_device_id pwm_of_match[] = {
{ .compatible = "rockchip_pwm_regulator"},
{ },
};
{ },
};
MODULE_DEVICE_TABLE(of, pwm_of_match);
static struct of_regulator_match pwm_matches[] = {
@@ -172,48 +172,48 @@ static struct of_regulator_match pwm_matches[] = {
};
static struct pwm_regulator_board *pwm_regulator_parse_dt(
struct platform_device *pdev,
struct platform_device *pdev,
struct of_regulator_match **pwm_reg_matches)
{
{
struct pwm_regulator_board *pwm_plat_data;
struct device_node *np, *regulators;
struct of_regulator_match *matches;
struct of_regulator_match *matches;
int idx = 0, ret, count;
struct property *prop;
int length;
const __be32 *init_vol, *max_vol,*min_vol,*suspend_vol,*coefficient,*id;
DBG("%s,line=%d\n", __func__,__LINE__);
pwm_plat_data = devm_kzalloc(&pdev->dev, sizeof(*pwm_plat_data),
GFP_KERNEL);
GFP_KERNEL);
if (!pwm_plat_data) {
dev_err(&pdev->dev, "Failure to alloc pdata for regulators.\n");
return NULL;
}
dev_err(&pdev->dev, "Failure to alloc pdata for regulators.\n");
return NULL;
}
np = of_node_get(pdev->dev.of_node);
regulators = of_find_node_by_name(np, "regulators");
if (!regulators) {
dev_err(&pdev->dev, "regulator node not found\n");
return NULL;
}
regulators = of_find_node_by_name(np, "regulators");
if (!regulators) {
dev_err(&pdev->dev, "regulator node not found\n");
return NULL;
}
count = ARRAY_SIZE(pwm_matches);
matches = pwm_matches;
ret = of_regulator_match(&pdev->dev, regulators, matches, count);
of_node_put(regulators);
if (ret < 0) {
dev_err(&pdev->dev, "Error parsing regulator init data: %d\n",
ret);
return NULL;
ret = of_regulator_match(&pdev->dev, regulators, matches, count);
of_node_put(regulators);
if (ret < 0) {
dev_err(&pdev->dev, "Error parsing regulator init data: %d\n",
ret);
return NULL;
}
pwm_plat_data ->num_regulators = count;
*pwm_reg_matches = matches;
for (idx = 0; idx < count; idx++) {
if (!matches[idx].init_data || !matches[idx].of_node)
for (idx = 0; idx < count; idx++) {
if (!matches[idx].init_data || !matches[idx].of_node)
continue;
pwm_plat_data->pwm_init_data[idx] =matches[idx].init_data;
pwm_plat_data->of_node[idx]=matches[idx].of_node;
@@ -244,12 +244,12 @@ static struct pwm_regulator_board *pwm_regulator_parse_dt(
pwm_plat_data->pwm_id = be32_to_cpu(*id );
prop = of_find_property(np, "rockchip,pwm_voltage_map", &length);
if (!prop)
if (!prop)
return NULL;
pwm_plat_data->pwm_vol_map_count = length / sizeof(u32);
if (pwm_plat_data->pwm_vol_map_count > 0) {
size_t size = sizeof(*pwm_plat_data->pwm_voltage_map) * pwm_plat_data->pwm_vol_map_count;
pwm_plat_data->pwm_voltage_map = devm_kzalloc(&pdev->dev, size, GFP_KERNEL);
if (! pwm_plat_data->pwm_voltage_map)
return NULL;
@@ -258,14 +258,14 @@ static struct pwm_regulator_board *pwm_regulator_parse_dt(
printk("pwm voltage map not specified\n");
}
return pwm_plat_data;
}
#else
}
#else
static inline struct pwm_regulator_board *pwm_regulator_parse_dt(
struct platform_device *pdev,
struct platform_device *pdev,
struct of_regulator_match **pwm_reg_matches)
{
{
return NULL;
}
}
#endif
@@ -290,8 +290,8 @@ static int __init pwm_regulator_probe(struct platform_device *pdev)
pwm_pdev = pwm_regulator_parse_dt(pdev,&pwm_reg_matches);
if (!pwm_pdev) {
dev_err(&pdev->dev, "Platform data not found\n");
return -EINVAL;
dev_err(&pdev->dev, "Platform data not found\n");
return -EINVAL;
}
if (!pwm_pdev->pwm_init_vol)
@@ -323,19 +323,19 @@ static int __init pwm_regulator_probe(struct platform_device *pdev)
pdata->pwm = devm_pwm_get(&pdev->dev, NULL);
if (IS_ERR(pdata->pwm)) {
dev_err(&pdev->dev, "unable to request PWM, trying legacy API\n");
dev_err(&pdev->dev, "unable to request PWM, trying legacy API\n");
pdata->pwm = pwm_request(pdata->pwm_id, "pwm-regulator");
if (IS_ERR(pdata->pwm)) {
dev_err(&pdev->dev, "unable to request legacy PWM\n");
dev_err(&pdev->dev, "unable to request legacy PWM\n");
ret = PTR_ERR(pdata->pwm);
goto err;
}
}
}
pwm_enable(pdata->pwm);
if (pdata->pwm_period_ns > 0)
pwm_set_period(pdata->pwm, pdata->pwm_period_ns);
pdata->period = pwm_get_period(pdata->pwm);
g_pdata = pdata;
@@ -344,32 +344,32 @@ static int __init pwm_regulator_probe(struct platform_device *pdev)
pdata->num_regulators = pwm_pdev ->num_regulators;
pdata->rdev = kcalloc(pdata->num_regulators,sizeof(struct regulator_dev *), GFP_KERNEL);
if (!pdata->rdev) {
return -ENOMEM;
return -ENOMEM;
}
/* Instantiate the regulators */
for (i = 0; i < pdata->num_regulators; i++) {
reg_data = pwm_pdev->pwm_init_data[i];
if (!reg_data)
continue;
if (!reg_data)
continue;
config.dev = &pdev->dev;
config.driver_data = pdata;
if (&pdev->dev.of_node)
config.of_node = pwm_pdev->of_node[i];
if (reg_data && reg_data->constraints.name)
rail_name = reg_data->constraints.name;
else
rail_name = regulators[i].name;
reg_data->supply_regulator = rail_name;
config.init_data =reg_data;
if (reg_data && reg_data->constraints.name)
rail_name = reg_data->constraints.name;
else
rail_name = regulators[i].name;
reg_data->supply_regulator = rail_name;
config.init_data =reg_data;
pwm_rdev = regulator_register(&regulators[i],&config);
if (IS_ERR(pwm_rdev)) {
printk("failed to register %d regulator\n",i);
goto err;
}
printk("failed to register %d regulator\n",i);
goto err;
}
pdata->rdev[i] = pwm_rdev;
}
}
}
/*********set pwm vol by defult***********/
//dc = regulator_get(NULL,"vdd_gpu");