aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Documentation/devicetree/bindings/regulator/sky81452-regulator.txt16
-rw-r--r--drivers/regulator/Kconfig11
-rw-r--r--drivers/regulator/Makefile1
-rw-r--r--drivers/regulator/sky81452-regulator.c130
4 files changed, 158 insertions, 0 deletions
diff --git a/Documentation/devicetree/bindings/regulator/sky81452-regulator.txt b/Documentation/devicetree/bindings/regulator/sky81452-regulator.txt
new file mode 100644
index 000000000000..882455e9b36d
--- /dev/null
+++ b/Documentation/devicetree/bindings/regulator/sky81452-regulator.txt
@@ -0,0 +1,16 @@
1SKY81452 voltage regulator
2
3Required properties:
4- any required generic properties defined in regulator.txt
5
6Optional properties:
7- any available generic properties defined in regulator.txt
8
9Example:
10
11 regulator {
12 /* generic regulator properties */
13 regulator-name = "touch_en";
14 regulator-min-microvolt = <4500000>;
15 regulator-max-microvolt = <8000000>;
16 };
diff --git a/drivers/regulator/Kconfig b/drivers/regulator/Kconfig
index 2dc8289e5dba..f6bf208f0fca 100644
--- a/drivers/regulator/Kconfig
+++ b/drivers/regulator/Kconfig
@@ -483,6 +483,17 @@ config REGULATOR_S5M8767
483 via I2C bus. S5M8767A have 9 Bucks and 28 LDOs output and 483 via I2C bus. S5M8767A have 9 Bucks and 28 LDOs output and
484 supports DVS mode with 8bits of output voltage control. 484 supports DVS mode with 8bits of output voltage control.
485 485
486config REGULATOR_SKY81452
487 tristate "Skyworks Solutions SKY81452 voltage regulator"
488 depends on SKY81452
489 help
490 This driver supports Skyworks SKY81452 voltage output regulator
491 via I2C bus. SKY81452 has one voltage linear regulator can be
492 programmed from 4.5V to 20V.
493
494 This driver can also be built as a module. If so, the module
495 will be called sky81452-regulator.
496
486config REGULATOR_ST_PWM 497config REGULATOR_ST_PWM
487 tristate "STMicroelectronics PWM voltage regulator" 498 tristate "STMicroelectronics PWM voltage regulator"
488 depends on ARCH_STI 499 depends on ARCH_STI
diff --git a/drivers/regulator/Makefile b/drivers/regulator/Makefile
index aa4a6aa7b558..d8206ec63d15 100644
--- a/drivers/regulator/Makefile
+++ b/drivers/regulator/Makefile
@@ -65,6 +65,7 @@ obj-$(CONFIG_REGULATOR_RC5T583) += rc5t583-regulator.o
65obj-$(CONFIG_REGULATOR_S2MPA01) += s2mpa01.o 65obj-$(CONFIG_REGULATOR_S2MPA01) += s2mpa01.o
66obj-$(CONFIG_REGULATOR_S2MPS11) += s2mps11.o 66obj-$(CONFIG_REGULATOR_S2MPS11) += s2mps11.o
67obj-$(CONFIG_REGULATOR_S5M8767) += s5m8767.o 67obj-$(CONFIG_REGULATOR_S5M8767) += s5m8767.o
68obj-$(CONFIG_REGULATOR_SKY81452) += sky81452-regulator.o
68obj-$(CONFIG_REGULATOR_ST_PWM) += st-pwm.o 69obj-$(CONFIG_REGULATOR_ST_PWM) += st-pwm.o
69obj-$(CONFIG_REGULATOR_STW481X_VMMC) += stw481x-vmmc.o 70obj-$(CONFIG_REGULATOR_STW481X_VMMC) += stw481x-vmmc.o
70obj-$(CONFIG_REGULATOR_TI_ABB) += ti-abb-regulator.o 71obj-$(CONFIG_REGULATOR_TI_ABB) += ti-abb-regulator.o
diff --git a/drivers/regulator/sky81452-regulator.c b/drivers/regulator/sky81452-regulator.c
new file mode 100644
index 000000000000..97aff0ccd65f
--- /dev/null
+++ b/drivers/regulator/sky81452-regulator.c
@@ -0,0 +1,130 @@
1/*
2 * sky81452-regulator.c SKY81452 regulator driver
3 *
4 * Copyright 2014 Skyworks Solutions Inc.
5 * Author : Gyungoh Yoo <jack.yoo@skyworksinc.com>
6 *
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation; either version 2, or (at your option) any
10 * later version.
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License along
18 * with this program; if not, see <http://www.gnu.org/licenses/>.
19 */
20
21#include <linux/module.h>
22#include <linux/kernel.h>
23#include <linux/platform_device.h>
24#include <linux/init.h>
25#include <linux/err.h>
26#include <linux/of.h>
27#include <linux/regulator/driver.h>
28#include <linux/regulator/of_regulator.h>
29
30/* registers */
31#define SKY81452_REG1 0x01
32#define SKY81452_REG3 0x03
33
34/* bit mask */
35#define SKY81452_LEN 0x40
36#define SKY81452_LOUT 0x1F
37
38static struct regulator_ops sky81452_reg_ops = {
39 .list_voltage = regulator_list_voltage_linear_range,
40 .map_voltage = regulator_map_voltage_linear_range,
41 .get_voltage_sel = regulator_get_voltage_sel_regmap,
42 .set_voltage_sel = regulator_set_voltage_sel_regmap,
43 .enable = regulator_enable_regmap,
44 .disable = regulator_disable_regmap,
45 .is_enabled = regulator_is_enabled_regmap,
46};
47
48static const struct regulator_linear_range sky81452_reg_ranges[] = {
49 REGULATOR_LINEAR_RANGE(4500000, 0, 14, 250000),
50 REGULATOR_LINEAR_RANGE(9000000, 15, 31, 1000000),
51};
52
53static const struct regulator_desc sky81452_reg = {
54 .name = "LOUT",
55 .ops = &sky81452_reg_ops,
56 .type = REGULATOR_VOLTAGE,
57 .owner = THIS_MODULE,
58 .n_voltages = SKY81452_LOUT + 1,
59 .linear_ranges = sky81452_reg_ranges,
60 .n_linear_ranges = ARRAY_SIZE(sky81452_reg_ranges),
61 .vsel_reg = SKY81452_REG3,
62 .vsel_mask = SKY81452_LOUT,
63 .enable_reg = SKY81452_REG1,
64 .enable_mask = SKY81452_LEN,
65};
66
67#ifdef CONFIG_OF
68static struct regulator_init_data *sky81452_reg_parse_dt(struct device *dev)
69{
70 struct regulator_init_data *init_data;
71 struct device_node *np;
72
73 np = of_get_child_by_name(dev->parent->of_node, "regulator");
74 if (unlikely(!np)) {
75 dev_err(dev, "regulator node not found");
76 return NULL;
77 }
78
79 init_data = of_get_regulator_init_data(dev, np);
80
81 of_node_put(np);
82 return init_data;
83}
84#else
85static struct regulator_init_data *sky81452_reg_parse_dt(struct device *dev)
86{
87 return ERR_PTR(-EINVAL);
88}
89#endif
90
91static int sky81452_reg_probe(struct platform_device *pdev)
92{
93 struct device *dev = &pdev->dev;
94 const struct regulator_init_data *init_data = dev_get_platdata(dev);
95 struct regulator_config config = { };
96 struct regulator_dev *rdev;
97
98 if (!init_data) {
99 init_data = sky81452_reg_parse_dt(dev);
100 if (IS_ERR(init_data))
101 return PTR_ERR(init_data);
102 }
103
104 config.dev = dev;
105 config.init_data = init_data;
106 config.of_node = dev->of_node;
107 config.regmap = dev_get_drvdata(dev->parent);
108
109 rdev = devm_regulator_register(dev, &sky81452_reg, &config);
110 if (IS_ERR(rdev))
111 return PTR_ERR(rdev);
112
113 platform_set_drvdata(pdev, rdev);
114
115 return 0;
116}
117
118static struct platform_driver sky81452_reg_driver = {
119 .driver = {
120 .name = "sky81452-regulator",
121 },
122 .probe = sky81452_reg_probe,
123};
124
125module_platform_driver(sky81452_reg_driver);
126
127MODULE_DESCRIPTION("Skyworks SKY81452 Regulator driver");
128MODULE_AUTHOR("Gyungoh Yoo <jack.yoo@skyworksinc.com>");
129MODULE_LICENSE("GPL");
130MODULE_VERSION("1.0");