Skip to content

Commit fdaff15

Browse files
committed
Merge remote-tracking branch 'regulator/topic/sky81452' into regulator-drivers
Conflicts: drivers/regulator/Kconfig drivers/regulator/Makefile
2 parents d1c3f7c + 9839d62 commit fdaff15

4 files changed

Lines changed: 158 additions & 0 deletions

File tree

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
SKY81452 voltage regulator
2+
3+
Required properties:
4+
- any required generic properties defined in regulator.txt
5+
6+
Optional properties:
7+
- any available generic properties defined in regulator.txt
8+
9+
Example:
10+
11+
regulator {
12+
/* generic regulator properties */
13+
regulator-name = "touch_en";
14+
regulator-min-microvolt = <4500000>;
15+
regulator-max-microvolt = <8000000>;
16+
};

‎drivers/regulator/Kconfig‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -502,6 +502,17 @@ config REGULATOR_S5M8767
502502
via I2C bus. S5M8767A have 9 Bucks and 28 LDOs output and
503503
supports DVS mode with 8bits of output voltage control.
504504

505+
config 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+
505516
config REGULATOR_TI_ABB
506517
tristate "TI Adaptive Body Bias on-chip LDO"
507518
depends on ARCH_OMAP

‎drivers/regulator/Makefile‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ obj-$(CONFIG_REGULATOR_RC5T583) += rc5t583-regulator.o
6767
obj-$(CONFIG_REGULATOR_S2MPA01) += s2mpa01.o
6868
obj-$(CONFIG_REGULATOR_S2MPS11) += s2mps11.o
6969
obj-$(CONFIG_REGULATOR_S5M8767) += s5m8767.o
70+
obj-$(CONFIG_REGULATOR_SKY81452) += sky81452-regulator.o
7071
obj-$(CONFIG_REGULATOR_STW481X_VMMC) += stw481x-vmmc.o
7172
obj-$(CONFIG_REGULATOR_TI_ABB) += ti-abb-regulator.o
7273
obj-$(CONFIG_REGULATOR_TPS6105X) += tps6105x-regulator.o
Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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+
38+
static 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+
48+
static 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+
53+
static 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
68+
static 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
85+
static struct regulator_init_data *sky81452_reg_parse_dt(struct device *dev)
86+
{
87+
return ERR_PTR(-EINVAL);
88+
}
89+
#endif
90+
91+
static 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+
118+
static struct platform_driver sky81452_reg_driver = {
119+
.driver = {
120+
.name = "sky81452-regulator",
121+
},
122+
.probe = sky81452_reg_probe,
123+
};
124+
125+
module_platform_driver(sky81452_reg_driver);
126+
127+
MODULE_DESCRIPTION("Skyworks SKY81452 Regulator driver");
128+
MODULE_AUTHOR("Gyungoh Yoo <jack.yoo@skyworksinc.com>");
129+
MODULE_LICENSE("GPL");
130+
MODULE_VERSION("1.0");

0 commit comments

Comments
 (0)