diff options
author | Chris Zhong <zyw@rock-chips.com> | 2014-09-09 21:18:06 -0400 |
---|---|---|
committer | Mark Brown <broonie@kernel.org> | 2014-09-10 06:50:43 -0400 |
commit | 571a4010847a8b03c88de6543c5c00878a7e97d3 (patch) | |
tree | 23e65270891f094d3b529a0fc6f86c6c714fb61f | |
parent | b8074eba2a6b5b1b090cf9c53dbccf3bc3e5205a (diff) |
regulator: rk808: Remove pdata from the regulator
Signed-off-by: Chris Zhong <zyw@rock-chips.com>
Tested-by: Heiko Stuebner <heiko@sntech.de>
Reviewed-by: Doug Anderson <dianders@chromium.org>
Tested-by: Doug Anderson <dianders@chromium.org>
Signed-off-by: Mark Brown <broonie@kernel.org>
-rw-r--r-- | drivers/regulator/rk808-regulator.c | 89 |
1 files changed, 17 insertions, 72 deletions
diff --git a/drivers/regulator/rk808-regulator.c b/drivers/regulator/rk808-regulator.c index e3720085b4ce..d91f2b658080 100644 --- a/drivers/regulator/rk808-regulator.c +++ b/drivers/regulator/rk808-regulator.c | |||
@@ -14,24 +14,16 @@ | |||
14 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | 14 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
15 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | 15 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for |
16 | * more details. | 16 | * more details. |
17 | * | ||
18 | */ | 17 | */ |
19 | 18 | ||
20 | #include <linux/module.h> | 19 | #include <linux/module.h> |
21 | #include <linux/init.h> | ||
22 | #include <linux/i2c.h> | 20 | #include <linux/i2c.h> |
23 | #include <linux/err.h> | ||
24 | #include <linux/platform_device.h> | ||
25 | #include <linux/mfd/rk808.h> | 21 | #include <linux/mfd/rk808.h> |
26 | #include <linux/of.h> | ||
27 | #include <linux/of_device.h> | 22 | #include <linux/of_device.h> |
28 | #include <linux/regulator/driver.h> | 23 | #include <linux/regulator/driver.h> |
29 | #include <linux/regulator/of_regulator.h> | 24 | #include <linux/regulator/of_regulator.h> |
30 | #include <linux/regmap.h> | 25 | |
31 | #include <linux/slab.h> | 26 | /* Field Definitions */ |
32 | /* | ||
33 | * Field Definitions. | ||
34 | */ | ||
35 | #define RK808_BUCK_VSEL_MASK 0x3f | 27 | #define RK808_BUCK_VSEL_MASK 0x3f |
36 | #define RK808_BUCK4_VSEL_MASK 0xf | 28 | #define RK808_BUCK4_VSEL_MASK 0xf |
37 | #define RK808_LDO_VSEL_MASK 0x1f | 29 | #define RK808_LDO_VSEL_MASK 0x1f |
@@ -50,10 +42,6 @@ static const int buck_contr_base_addr[] = { | |||
50 | RK808_BUCK4_CONFIG_REG, | 42 | RK808_BUCK4_CONFIG_REG, |
51 | }; | 43 | }; |
52 | 44 | ||
53 | #define rk808_BUCK_SET_VOL_REG(x) (buck_set_vol_base_addr[x]) | ||
54 | #define rk808_BUCK_CONTR_REG(x) (buck_contr_base_addr[x]) | ||
55 | #define rk808_LDO_SET_VOL_REG(x) (ldo_set_vol_base_addr[x]) | ||
56 | |||
57 | static const int ldo_set_vol_base_addr[] = { | 45 | static const int ldo_set_vol_base_addr[] = { |
58 | RK808_LDO1_ON_VSEL_REG, | 46 | RK808_LDO1_ON_VSEL_REG, |
59 | RK808_LDO2_ON_VSEL_REG, | 47 | RK808_LDO2_ON_VSEL_REG, |
@@ -65,9 +53,7 @@ static const int ldo_set_vol_base_addr[] = { | |||
65 | RK808_LDO8_ON_VSEL_REG, | 53 | RK808_LDO8_ON_VSEL_REG, |
66 | }; | 54 | }; |
67 | 55 | ||
68 | /* | 56 | /* rk808 voltage number */ |
69 | * rk808 voltage number | ||
70 | */ | ||
71 | static const struct regulator_linear_range rk808_buck_voltage_ranges[] = { | 57 | static const struct regulator_linear_range rk808_buck_voltage_ranges[] = { |
72 | REGULATOR_LINEAR_RANGE(700000, 0, 63, 12500), | 58 | REGULATOR_LINEAR_RANGE(700000, 0, 63, 12500), |
73 | }; | 59 | }; |
@@ -308,77 +294,35 @@ static struct of_regulator_match rk808_reg_matches[] = { | |||
308 | [RK808_ID_SWITCH2] = { .name = "SWITCH_REG2" }, | 294 | [RK808_ID_SWITCH2] = { .name = "SWITCH_REG2" }, |
309 | }; | 295 | }; |
310 | 296 | ||
311 | static int rk808_regulator_dts(struct i2c_client *client, | ||
312 | struct rk808_board *pdata) | ||
313 | { | ||
314 | struct device_node *np, *reg_np; | ||
315 | int i, ret; | ||
316 | |||
317 | np = client->dev.of_node; | ||
318 | if (!np) { | ||
319 | dev_err(&client->dev, "could not find pmic sub-node\n"); | ||
320 | return -ENXIO; | ||
321 | } | ||
322 | |||
323 | reg_np = of_get_child_by_name(np, "regulators"); | ||
324 | if (!reg_np) | ||
325 | return -ENXIO; | ||
326 | |||
327 | ret = of_regulator_match(&client->dev, reg_np, rk808_reg_matches, | ||
328 | RK808_NUM_REGULATORS); | ||
329 | if (ret < 0) { | ||
330 | dev_err(&client->dev, | ||
331 | "failed to parse regulator data: %d\n", ret); | ||
332 | return ret; | ||
333 | } | ||
334 | |||
335 | for (i = 0; i < RK808_NUM_REGULATORS; i++) { | ||
336 | if (!rk808_reg_matches[i].init_data || | ||
337 | !rk808_reg_matches[i].of_node) | ||
338 | continue; | ||
339 | |||
340 | pdata->rk808_init_data[i] = rk808_reg_matches[i].init_data; | ||
341 | pdata->of_node[i] = rk808_reg_matches[i].of_node; | ||
342 | } | ||
343 | |||
344 | return 0; | ||
345 | } | ||
346 | |||
347 | static int rk808_regulator_probe(struct platform_device *pdev) | 297 | static int rk808_regulator_probe(struct platform_device *pdev) |
348 | { | 298 | { |
349 | struct rk808 *rk808 = dev_get_drvdata(pdev->dev.parent); | 299 | struct rk808 *rk808 = dev_get_drvdata(pdev->dev.parent); |
350 | struct i2c_client *client = rk808->i2c; | 300 | struct i2c_client *client = rk808->i2c; |
351 | struct rk808_board *pdata = dev_get_platdata(&client->dev); | 301 | struct device_node *reg_np; |
352 | struct regulator_config config = {}; | 302 | struct regulator_config config = {}; |
353 | struct regulator_dev *rk808_rdev; | 303 | struct regulator_dev *rk808_rdev; |
354 | struct regulator_init_data *reg_data; | 304 | int ret, i; |
355 | int i = 0; | ||
356 | int ret = 0; | ||
357 | 305 | ||
358 | if (!pdata) { | 306 | reg_np = of_get_child_by_name(client->dev.of_node, "regulators"); |
359 | pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL); | 307 | if (!reg_np) |
360 | if (!pdata) | 308 | return -ENXIO; |
361 | return -ENOMEM; | ||
362 | } | ||
363 | 309 | ||
364 | ret = rk808_regulator_dts(client, pdata); | 310 | ret = of_regulator_match(&client->dev, reg_np, rk808_reg_matches, |
365 | if (ret) | 311 | RK808_NUM_REGULATORS); |
312 | if (ret < 0) | ||
366 | return ret; | 313 | return ret; |
367 | 314 | ||
368 | /* Instantiate the regulators */ | 315 | /* Instantiate the regulators */ |
369 | for (i = 0; i < RK808_NUM_REGULATORS; i++) { | 316 | for (i = 0; i < RK808_NUM_REGULATORS; i++) { |
370 | reg_data = pdata->rk808_init_data[i]; | 317 | if (!rk808_reg_matches[i].init_data || |
371 | if (!reg_data) | 318 | !rk808_reg_matches[i].of_node) |
372 | continue; | 319 | continue; |
373 | 320 | ||
374 | config.dev = &client->dev; | 321 | config.dev = &client->dev; |
375 | config.driver_data = rk808; | 322 | config.driver_data = rk808; |
376 | config.regmap = rk808->regmap; | 323 | config.regmap = rk808->regmap; |
377 | 324 | config.of_node = rk808_reg_matches[i].of_node; | |
378 | if (client->dev.of_node) | 325 | config.init_data = rk808_reg_matches[i].init_data; |
379 | config.of_node = pdata->of_node[i]; | ||
380 | |||
381 | config.init_data = reg_data; | ||
382 | 326 | ||
383 | rk808_rdev = devm_regulator_register(&pdev->dev, | 327 | rk808_rdev = devm_regulator_register(&pdev->dev, |
384 | &rk808_reg[i], &config); | 328 | &rk808_reg[i], &config); |
@@ -388,6 +332,7 @@ static int rk808_regulator_probe(struct platform_device *pdev) | |||
388 | return PTR_ERR(rk808_rdev); | 332 | return PTR_ERR(rk808_rdev); |
389 | } | 333 | } |
390 | } | 334 | } |
335 | |||
391 | return 0; | 336 | return 0; |
392 | } | 337 | } |
393 | 338 | ||
@@ -403,6 +348,6 @@ module_platform_driver(rk808_regulator_driver); | |||
403 | 348 | ||
404 | MODULE_DESCRIPTION("regulator driver for the rk808 series PMICs"); | 349 | MODULE_DESCRIPTION("regulator driver for the rk808 series PMICs"); |
405 | MODULE_AUTHOR("Chris Zhong<zyw@rock-chips.com>"); | 350 | MODULE_AUTHOR("Chris Zhong<zyw@rock-chips.com>"); |
406 | MODULE_AUTHOR("Zhang Qing<zhanqging@rock-chips.com>"); | 351 | MODULE_AUTHOR("Zhang Qing<zhangqing@rock-chips.com>"); |
407 | MODULE_LICENSE("GPL"); | 352 | MODULE_LICENSE("GPL"); |
408 | MODULE_ALIAS("platform:rk808-regulator"); | 353 | MODULE_ALIAS("platform:rk808-regulator"); |