diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2014-04-24 15:01:58 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2014-04-24 15:01:58 -0400 |
commit | 76429f1dedbc1815d875c9b68eefd30c95cb8fa9 (patch) | |
tree | 0c7efa089ad10e6c503b9c3a5ccc6735ceb11ad3 | |
parent | ff1e5b447e465da75dfdd0a4f4070cfef86a4155 (diff) | |
parent | 38962571375149626cd282ef9d8e87e8faf21155 (diff) |
Merge tag 'regulator-v3.15-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator
Pull regulator fixes from Mark Brown:
"A couple of things here:
- Fixes for pbias that didn't make it in during the merge window due
to the driver coming in via MMC. The conversion to use helpers is
a fix as it implements list_voltage() which the main user (MMC)
relies on for correct functioning.
- Change the !REGULATOR stub for optional regulators to return an
error rather than a dummy; this is more in keeping with the
intended use of optional regulators and fixes some issues seen MMC
where it got confused by a dummy being provided"
* tag 'regulator-v3.15-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator:
regulator: core: Return error in get optional stub
regulator: pbias: Convert to use regmap helper functions
regulator: pbias: Fix is_enabled callback implementation
-rw-r--r-- | drivers/regulator/pbias-regulator.c | 76 | ||||
-rw-r--r-- | include/linux/regulator/consumer.h | 4 |
2 files changed, 22 insertions, 58 deletions
diff --git a/drivers/regulator/pbias-regulator.c b/drivers/regulator/pbias-regulator.c index ded3b3574209..6d38be3d970c 100644 --- a/drivers/regulator/pbias-regulator.c +++ b/drivers/regulator/pbias-regulator.c | |||
@@ -38,66 +38,24 @@ struct pbias_reg_info { | |||
38 | struct pbias_regulator_data { | 38 | struct pbias_regulator_data { |
39 | struct regulator_desc desc; | 39 | struct regulator_desc desc; |
40 | void __iomem *pbias_addr; | 40 | void __iomem *pbias_addr; |
41 | unsigned int pbias_reg; | ||
42 | struct regulator_dev *dev; | 41 | struct regulator_dev *dev; |
43 | struct regmap *syscon; | 42 | struct regmap *syscon; |
44 | const struct pbias_reg_info *info; | 43 | const struct pbias_reg_info *info; |
45 | int voltage; | 44 | int voltage; |
46 | }; | 45 | }; |
47 | 46 | ||
48 | static int pbias_regulator_set_voltage(struct regulator_dev *dev, | 47 | static const unsigned int pbias_volt_table[] = { |
49 | int min_uV, int max_uV, unsigned *selector) | 48 | 1800000, |
50 | { | 49 | 3000000 |
51 | struct pbias_regulator_data *data = rdev_get_drvdata(dev); | 50 | }; |
52 | const struct pbias_reg_info *info = data->info; | ||
53 | int ret, vmode; | ||
54 | |||
55 | if (min_uV <= 1800000) | ||
56 | vmode = 0; | ||
57 | else if (min_uV > 1800000) | ||
58 | vmode = info->vmode; | ||
59 | |||
60 | ret = regmap_update_bits(data->syscon, data->pbias_reg, | ||
61 | info->vmode, vmode); | ||
62 | |||
63 | return ret; | ||
64 | } | ||
65 | |||
66 | static int pbias_regulator_get_voltage(struct regulator_dev *rdev) | ||
67 | { | ||
68 | struct pbias_regulator_data *data = rdev_get_drvdata(rdev); | ||
69 | const struct pbias_reg_info *info = data->info; | ||
70 | int value, voltage; | ||
71 | |||
72 | regmap_read(data->syscon, data->pbias_reg, &value); | ||
73 | value &= info->vmode; | ||
74 | |||
75 | voltage = value ? 3000000 : 1800000; | ||
76 | |||
77 | return voltage; | ||
78 | } | ||
79 | 51 | ||
80 | static int pbias_regulator_enable(struct regulator_dev *rdev) | 52 | static int pbias_regulator_enable(struct regulator_dev *rdev) |
81 | { | 53 | { |
82 | struct pbias_regulator_data *data = rdev_get_drvdata(rdev); | 54 | struct pbias_regulator_data *data = rdev_get_drvdata(rdev); |
83 | const struct pbias_reg_info *info = data->info; | 55 | const struct pbias_reg_info *info = data->info; |
84 | int ret; | ||
85 | |||
86 | ret = regmap_update_bits(data->syscon, data->pbias_reg, | ||
87 | info->enable_mask, info->enable); | ||
88 | |||
89 | return ret; | ||
90 | } | ||
91 | |||
92 | static int pbias_regulator_disable(struct regulator_dev *rdev) | ||
93 | { | ||
94 | struct pbias_regulator_data *data = rdev_get_drvdata(rdev); | ||
95 | const struct pbias_reg_info *info = data->info; | ||
96 | int ret; | ||
97 | 56 | ||
98 | ret = regmap_update_bits(data->syscon, data->pbias_reg, | 57 | return regmap_update_bits(data->syscon, rdev->desc->enable_reg, |
99 | info->enable_mask, 0); | 58 | info->enable_mask, info->enable); |
100 | return ret; | ||
101 | } | 59 | } |
102 | 60 | ||
103 | static int pbias_regulator_is_enable(struct regulator_dev *rdev) | 61 | static int pbias_regulator_is_enable(struct regulator_dev *rdev) |
@@ -106,17 +64,18 @@ static int pbias_regulator_is_enable(struct regulator_dev *rdev) | |||
106 | const struct pbias_reg_info *info = data->info; | 64 | const struct pbias_reg_info *info = data->info; |
107 | int value; | 65 | int value; |
108 | 66 | ||
109 | regmap_read(data->syscon, data->pbias_reg, &value); | 67 | regmap_read(data->syscon, rdev->desc->enable_reg, &value); |
110 | 68 | ||
111 | return (value & info->enable_mask) == info->enable_mask; | 69 | return (value & info->enable_mask) == info->enable; |
112 | } | 70 | } |
113 | 71 | ||
114 | static struct regulator_ops pbias_regulator_voltage_ops = { | 72 | static struct regulator_ops pbias_regulator_voltage_ops = { |
115 | .set_voltage = pbias_regulator_set_voltage, | 73 | .list_voltage = regulator_list_voltage_table, |
116 | .get_voltage = pbias_regulator_get_voltage, | 74 | .get_voltage_sel = regulator_get_voltage_sel_regmap, |
117 | .enable = pbias_regulator_enable, | 75 | .set_voltage_sel = regulator_set_voltage_sel_regmap, |
118 | .disable = pbias_regulator_disable, | 76 | .enable = pbias_regulator_enable, |
119 | .is_enabled = pbias_regulator_is_enable, | 77 | .disable = regulator_disable_regmap, |
78 | .is_enabled = pbias_regulator_is_enable, | ||
120 | }; | 79 | }; |
121 | 80 | ||
122 | static const struct pbias_reg_info pbias_mmc_omap2430 = { | 81 | static const struct pbias_reg_info pbias_mmc_omap2430 = { |
@@ -192,6 +151,7 @@ static int pbias_regulator_probe(struct platform_device *pdev) | |||
192 | if (IS_ERR(syscon)) | 151 | if (IS_ERR(syscon)) |
193 | return PTR_ERR(syscon); | 152 | return PTR_ERR(syscon); |
194 | 153 | ||
154 | cfg.regmap = syscon; | ||
195 | cfg.dev = &pdev->dev; | 155 | cfg.dev = &pdev->dev; |
196 | 156 | ||
197 | for (idx = 0; idx < PBIAS_NUM_REGS && data_idx < count; idx++) { | 157 | for (idx = 0; idx < PBIAS_NUM_REGS && data_idx < count; idx++) { |
@@ -207,15 +167,19 @@ static int pbias_regulator_probe(struct platform_device *pdev) | |||
207 | if (!res) | 167 | if (!res) |
208 | return -EINVAL; | 168 | return -EINVAL; |
209 | 169 | ||
210 | drvdata[data_idx].pbias_reg = res->start; | ||
211 | drvdata[data_idx].syscon = syscon; | 170 | drvdata[data_idx].syscon = syscon; |
212 | drvdata[data_idx].info = info; | 171 | drvdata[data_idx].info = info; |
213 | drvdata[data_idx].desc.name = info->name; | 172 | drvdata[data_idx].desc.name = info->name; |
214 | drvdata[data_idx].desc.owner = THIS_MODULE; | 173 | drvdata[data_idx].desc.owner = THIS_MODULE; |
215 | drvdata[data_idx].desc.type = REGULATOR_VOLTAGE; | 174 | drvdata[data_idx].desc.type = REGULATOR_VOLTAGE; |
216 | drvdata[data_idx].desc.ops = &pbias_regulator_voltage_ops; | 175 | drvdata[data_idx].desc.ops = &pbias_regulator_voltage_ops; |
176 | drvdata[data_idx].desc.volt_table = pbias_volt_table; | ||
217 | drvdata[data_idx].desc.n_voltages = 2; | 177 | drvdata[data_idx].desc.n_voltages = 2; |
218 | drvdata[data_idx].desc.enable_time = info->enable_time; | 178 | drvdata[data_idx].desc.enable_time = info->enable_time; |
179 | drvdata[data_idx].desc.vsel_reg = res->start; | ||
180 | drvdata[data_idx].desc.vsel_mask = info->vmode; | ||
181 | drvdata[data_idx].desc.enable_reg = res->start; | ||
182 | drvdata[data_idx].desc.enable_mask = info->enable_mask; | ||
219 | 183 | ||
220 | cfg.init_data = pbias_matches[idx].init_data; | 184 | cfg.init_data = pbias_matches[idx].init_data; |
221 | cfg.driver_data = &drvdata[data_idx]; | 185 | cfg.driver_data = &drvdata[data_idx]; |
diff --git a/include/linux/regulator/consumer.h b/include/linux/regulator/consumer.h index e530681bea70..1a4a8c157b31 100644 --- a/include/linux/regulator/consumer.h +++ b/include/linux/regulator/consumer.h | |||
@@ -258,14 +258,14 @@ regulator_get_exclusive(struct device *dev, const char *id) | |||
258 | static inline struct regulator *__must_check | 258 | static inline struct regulator *__must_check |
259 | regulator_get_optional(struct device *dev, const char *id) | 259 | regulator_get_optional(struct device *dev, const char *id) |
260 | { | 260 | { |
261 | return NULL; | 261 | return ERR_PTR(-ENODEV); |
262 | } | 262 | } |
263 | 263 | ||
264 | 264 | ||
265 | static inline struct regulator *__must_check | 265 | static inline struct regulator *__must_check |
266 | devm_regulator_get_optional(struct device *dev, const char *id) | 266 | devm_regulator_get_optional(struct device *dev, const char *id) |
267 | { | 267 | { |
268 | return NULL; | 268 | return ERR_PTR(-ENODEV); |
269 | } | 269 | } |
270 | 270 | ||
271 | static inline void regulator_put(struct regulator *regulator) | 271 | static inline void regulator_put(struct regulator *regulator) |