aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorMark Brown <broonie@kernel.org>2014-09-28 07:17:00 -0400
committerMark Brown <broonie@kernel.org>2014-09-28 07:17:00 -0400
commitfdaff15ae6cc8745b9b56adab0252729b476ed7e (patch)
tree182eb140d5c71501159fb0d46ffc8b74c766dc13 /drivers
parentd1c3f7ca158e78fa78c9789d836d2a98d5fd25f3 (diff)
parent9839d627c2a2c74facde9a9ee949f2ba0a1363b1 (diff)
Merge remote-tracking branch 'regulator/topic/sky81452' into regulator-drivers
Conflicts: drivers/regulator/Kconfig drivers/regulator/Makefile
Diffstat (limited to 'drivers')
-rw-r--r--drivers/regulator/Kconfig11
-rw-r--r--drivers/regulator/Makefile1
-rw-r--r--drivers/regulator/sky81452-regulator.c130
3 files changed, 142 insertions, 0 deletions
diff --git a/drivers/regulator/Kconfig b/drivers/regulator/Kconfig
index c3ca05cb5c87..72fb9500f410 100644
--- a/drivers/regulator/Kconfig
+++ b/drivers/regulator/Kconfig
@@ -502,6 +502,17 @@ config REGULATOR_S5M8767
502 via I2C bus. S5M8767A have 9 Bucks and 28 LDOs output and 502 via I2C bus. S5M8767A have 9 Bucks and 28 LDOs output and
503 supports DVS mode with 8bits of output voltage control. 503 supports DVS mode with 8bits of output voltage control.
504 504
505config REGULATOR_SKY81452
506 tristate "Skyworks Solutions SKY81452 voltage regulator"
507 depends on SKY81452
508 help
509 This driver supports Skyworks SKY81452 voltage output regulator
510 via I2C bus. SKY81452 has one voltage linear regulator can be
511 programmed from 4.5V to 20V.
512
513 This driver can also be built as a module. If so, the module
514 will be called sky81452-regulator.
515
505config REGULATOR_TI_ABB 516config REGULATOR_TI_ABB
506 tristate "TI Adaptive Body Bias on-chip LDO" 517 tristate "TI Adaptive Body Bias on-chip LDO"
507 depends on ARCH_OMAP 518 depends on ARCH_OMAP
diff --git a/drivers/regulator/Makefile b/drivers/regulator/Makefile
index 2f49356e03a7..a4d81ec024ea 100644
--- a/drivers/regulator/Makefile
+++ b/drivers/regulator/Makefile
@@ -67,6 +67,7 @@ obj-$(CONFIG_REGULATOR_RC5T583) += rc5t583-regulator.o
67obj-$(CONFIG_REGULATOR_S2MPA01) += s2mpa01.o 67obj-$(CONFIG_REGULATOR_S2MPA01) += s2mpa01.o
68obj-$(CONFIG_REGULATOR_S2MPS11) += s2mps11.o 68obj-$(CONFIG_REGULATOR_S2MPS11) += s2mps11.o
69obj-$(CONFIG_REGULATOR_S5M8767) += s5m8767.o 69obj-$(CONFIG_REGULATOR_S5M8767) += s5m8767.o
70obj-$(CONFIG_REGULATOR_SKY81452) += sky81452-regulator.o
70obj-$(CONFIG_REGULATOR_STW481X_VMMC) += stw481x-vmmc.o 71obj-$(CONFIG_REGULATOR_STW481X_VMMC) += stw481x-vmmc.o
71obj-$(CONFIG_REGULATOR_TI_ABB) += ti-abb-regulator.o 72obj-$(CONFIG_REGULATOR_TI_ABB) += ti-abb-regulator.o
72obj-$(CONFIG_REGULATOR_TPS6105X) += tps6105x-regulator.o 73obj-$(CONFIG_REGULATOR_TPS6105X) += tps6105x-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");