diff options
-rw-r--r-- | drivers/regulator/Kconfig | 8 | ||||
-rw-r--r-- | drivers/regulator/Makefile | 1 | ||||
-rw-r--r-- | drivers/regulator/rt5033-regulator.c | 123 |
3 files changed, 132 insertions, 0 deletions
diff --git a/drivers/regulator/Kconfig b/drivers/regulator/Kconfig index 55d7b7b0f2e0..8558e1b21f05 100644 --- a/drivers/regulator/Kconfig +++ b/drivers/regulator/Kconfig | |||
@@ -521,6 +521,14 @@ config REGULATOR_RN5T618 | |||
521 | help | 521 | help |
522 | Say y here to support the regulators found on Ricoh RN5T618 PMIC. | 522 | Say y here to support the regulators found on Ricoh RN5T618 PMIC. |
523 | 523 | ||
524 | config REGULATOR_RT5033 | ||
525 | tristate "Richtek RT5033 Regulators" | ||
526 | depends on MFD_RT5033 | ||
527 | help | ||
528 | This adds support for voltage and current regulators in Richtek | ||
529 | RT5033 PMIC. The device supports multiple regulators like | ||
530 | current source, LDO and Buck. | ||
531 | |||
524 | config REGULATOR_S2MPA01 | 532 | config REGULATOR_S2MPA01 |
525 | tristate "Samsung S2MPA01 voltage regulator" | 533 | tristate "Samsung S2MPA01 voltage regulator" |
526 | depends on MFD_SEC_CORE | 534 | depends on MFD_SEC_CORE |
diff --git a/drivers/regulator/Makefile b/drivers/regulator/Makefile index 1029ed39c512..1f28ebfc6f3a 100644 --- a/drivers/regulator/Makefile +++ b/drivers/regulator/Makefile | |||
@@ -69,6 +69,7 @@ obj-$(CONFIG_REGULATOR_PCF50633) += pcf50633-regulator.o | |||
69 | obj-$(CONFIG_REGULATOR_RC5T583) += rc5t583-regulator.o | 69 | obj-$(CONFIG_REGULATOR_RC5T583) += rc5t583-regulator.o |
70 | obj-$(CONFIG_REGULATOR_RK808) += rk808-regulator.o | 70 | obj-$(CONFIG_REGULATOR_RK808) += rk808-regulator.o |
71 | obj-$(CONFIG_REGULATOR_RN5T618) += rn5t618-regulator.o | 71 | obj-$(CONFIG_REGULATOR_RN5T618) += rn5t618-regulator.o |
72 | obj-$(CONFIG_REGULATOR_RT5033) += rt5033-regulator.o | ||
72 | obj-$(CONFIG_REGULATOR_S2MPA01) += s2mpa01.o | 73 | obj-$(CONFIG_REGULATOR_S2MPA01) += s2mpa01.o |
73 | obj-$(CONFIG_REGULATOR_S2MPS11) += s2mps11.o | 74 | obj-$(CONFIG_REGULATOR_S2MPS11) += s2mps11.o |
74 | obj-$(CONFIG_REGULATOR_S5M8767) += s5m8767.o | 75 | obj-$(CONFIG_REGULATOR_S5M8767) += s5m8767.o |
diff --git a/drivers/regulator/rt5033-regulator.c b/drivers/regulator/rt5033-regulator.c new file mode 100644 index 000000000000..870cc49438db --- /dev/null +++ b/drivers/regulator/rt5033-regulator.c | |||
@@ -0,0 +1,123 @@ | |||
1 | /* | ||
2 | * Regulator driver for the Richtek RT5033 | ||
3 | * | ||
4 | * Copyright (C) 2014 Samsung Electronics, Co., Ltd. | ||
5 | * Author: Beomho Seo <beomho.seo@samsung.com> | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or modify | ||
8 | * it under the terms of the GNU General Public License version 2 as | ||
9 | * published bythe Free Software Foundation. | ||
10 | */ | ||
11 | |||
12 | #include <linux/module.h> | ||
13 | #include <linux/platform_device.h> | ||
14 | #include <linux/regulator/driver.h> | ||
15 | #include <linux/mfd/rt5033.h> | ||
16 | #include <linux/mfd/rt5033-private.h> | ||
17 | #include <linux/regulator/of_regulator.h> | ||
18 | |||
19 | static struct regulator_ops rt5033_safe_ldo_ops = { | ||
20 | .is_enabled = regulator_is_enabled_regmap, | ||
21 | .enable = regulator_enable_regmap, | ||
22 | .disable = regulator_disable_regmap, | ||
23 | .list_voltage = regulator_list_voltage_linear, | ||
24 | }; | ||
25 | |||
26 | static struct regulator_ops rt5033_buck_ops = { | ||
27 | .is_enabled = regulator_is_enabled_regmap, | ||
28 | .enable = regulator_enable_regmap, | ||
29 | .disable = regulator_disable_regmap, | ||
30 | .list_voltage = regulator_list_voltage_linear, | ||
31 | .map_voltage = regulator_map_voltage_linear, | ||
32 | .get_voltage_sel = regulator_get_voltage_sel_regmap, | ||
33 | .set_voltage_sel = regulator_set_voltage_sel_regmap, | ||
34 | }; | ||
35 | |||
36 | static const struct regulator_desc rt5033_supported_regulators[] = { | ||
37 | [RT5033_BUCK] = { | ||
38 | .name = "BUCK", | ||
39 | .id = RT5033_BUCK, | ||
40 | .ops = &rt5033_buck_ops, | ||
41 | .type = REGULATOR_VOLTAGE, | ||
42 | .owner = THIS_MODULE, | ||
43 | .n_voltages = RT5033_REGULATOR_BUCK_VOLTAGE_STEP_NUM, | ||
44 | .min_uV = RT5033_REGULATOR_BUCK_VOLTAGE_MIN, | ||
45 | .uV_step = RT5033_REGULATOR_BUCK_VOLTAGE_STEP, | ||
46 | .enable_reg = RT5033_REG_CTRL, | ||
47 | .enable_mask = RT5033_CTRL_EN_BUCK_MASK, | ||
48 | .vsel_reg = RT5033_REG_BUCK_CTRL, | ||
49 | .vsel_mask = RT5033_BUCK_CTRL_MASK, | ||
50 | }, | ||
51 | [RT5033_LDO] = { | ||
52 | .name = "LDO", | ||
53 | .id = RT5033_LDO, | ||
54 | .ops = &rt5033_buck_ops, | ||
55 | .type = REGULATOR_VOLTAGE, | ||
56 | .owner = THIS_MODULE, | ||
57 | .n_voltages = RT5033_REGULATOR_LDO_VOLTAGE_STEP_NUM, | ||
58 | .min_uV = RT5033_REGULATOR_LDO_VOLTAGE_MIN, | ||
59 | .uV_step = RT5033_REGULATOR_LDO_VOLTAGE_STEP, | ||
60 | .enable_reg = RT5033_REG_CTRL, | ||
61 | .enable_mask = RT5033_CTRL_EN_LDO_MASK, | ||
62 | .vsel_reg = RT5033_REG_LDO_CTRL, | ||
63 | .vsel_mask = RT5033_LDO_CTRL_MASK, | ||
64 | }, | ||
65 | [RT5033_SAFE_LDO] = { | ||
66 | .name = "SAFE_LDO", | ||
67 | .id = RT5033_SAFE_LDO, | ||
68 | .ops = &rt5033_safe_ldo_ops, | ||
69 | .type = REGULATOR_VOLTAGE, | ||
70 | .owner = THIS_MODULE, | ||
71 | .n_voltages = 1, | ||
72 | .min_uV = RT5033_REGULATOR_SAFE_LDO_VOLTAGE, | ||
73 | .enable_reg = RT5033_REG_CTRL, | ||
74 | .enable_mask = RT5033_CTRL_EN_SAFE_LDO_MASK, | ||
75 | }, | ||
76 | }; | ||
77 | |||
78 | static int rt5033_regulator_probe(struct platform_device *pdev) | ||
79 | { | ||
80 | struct rt5033_dev *rt5033 = dev_get_drvdata(pdev->dev.parent); | ||
81 | int ret, i; | ||
82 | struct regulator_config config = {}; | ||
83 | |||
84 | config.dev = &pdev->dev; | ||
85 | config.driver_data = rt5033; | ||
86 | |||
87 | for (i = 0; i < ARRAY_SIZE(rt5033_supported_regulators); i++) { | ||
88 | struct regulator_dev *regulator; | ||
89 | |||
90 | config.regmap = rt5033->regmap; | ||
91 | |||
92 | regulator = devm_regulator_register(&pdev->dev, | ||
93 | &rt5033_supported_regulators[i], &config); | ||
94 | if (IS_ERR(regulator)) { | ||
95 | ret = PTR_ERR(regulator); | ||
96 | dev_err(&pdev->dev, | ||
97 | "Regulator init failed %d: with error: %d\n", | ||
98 | i, ret); | ||
99 | return ret; | ||
100 | } | ||
101 | } | ||
102 | |||
103 | return 0; | ||
104 | } | ||
105 | |||
106 | static const struct platform_device_id rt5033_regulator_id[] = { | ||
107 | { "rt5033-regulator", }, | ||
108 | { } | ||
109 | }; | ||
110 | MODULE_DEVICE_TABLE(platform, rt5033_regulator_id); | ||
111 | |||
112 | static struct platform_driver rt5033_regulator_driver = { | ||
113 | .driver = { | ||
114 | .name = "rt5033-regulator", | ||
115 | }, | ||
116 | .probe = rt5033_regulator_probe, | ||
117 | .id_table = rt5033_regulator_id, | ||
118 | }; | ||
119 | module_platform_driver(rt5033_regulator_driver); | ||
120 | |||
121 | MODULE_DESCRIPTION("Richtek RT5033 Regulator driver"); | ||
122 | MODULE_AUTHOR("Beomho Seo <beomho.seo@samsung.com>"); | ||
123 | MODULE_LICENSE("GPL"); | ||