From 3d0820f5a9f8a6bc4342aa5ee5a5dd20a34b2681 Mon Sep 17 00:00:00 2001 From: =?utf8?q?=E5=BC=A0=E6=99=B4?= Date: Mon, 17 Mar 2014 11:39:27 +0800 Subject: [PATCH] linux3.10:pwm:renamed rk30/rk29-pwm-regulator to rockchip-pwm-regulator --- drivers/regulator/Makefile | 2 +- ...m-regulator.c => rockchip-pwm-regulator.c} | 122 +++++++++--------- ...m-regulator.h => rockchip-pwm-regulator.h} | 0 3 files changed, 62 insertions(+), 62 deletions(-) rename drivers/regulator/{rk30-pwm-regulator.c => rockchip-pwm-regulator.c} (95%) rename include/linux/regulator/{rk29-pwm-regulator.h => rockchip-pwm-regulator.h} (100%) diff --git a/drivers/regulator/Makefile b/drivers/regulator/Makefile index 74658dbb3d3f..6ed37407f0a8 100644 --- a/drivers/regulator/Makefile +++ b/drivers/regulator/Makefile @@ -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 diff --git a/drivers/regulator/rk30-pwm-regulator.c b/drivers/regulator/rockchip-pwm-regulator.c similarity index 95% rename from drivers/regulator/rk30-pwm-regulator.c rename to drivers/regulator/rockchip-pwm-regulator.c index 4de209ac3170..78451a795e21 100755 --- a/drivers/regulator/rk30-pwm-regulator.c +++ b/drivers/regulator/rockchip-pwm-regulator.c @@ -20,19 +20,19 @@ #include #include #include -#include -#include -#include +#include +#include +#include #include -#include +#include #include #include -#include -#include +#include +#include #include -#include -#include +#include +#include #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(®ulators[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"); diff --git a/include/linux/regulator/rk29-pwm-regulator.h b/include/linux/regulator/rockchip-pwm-regulator.h similarity index 100% rename from include/linux/regulator/rk29-pwm-regulator.h rename to include/linux/regulator/rockchip-pwm-regulator.h -- 2.34.1