Ying-Chun Liu (PaulLiu) | e3e5aff | 2012-03-14 10:29:12 +0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2011 Freescale Semiconductor, Inc. All Rights Reserved. |
| 3 | */ |
| 4 | |
| 5 | /* |
| 6 | * This program is free software; you can redistribute it and/or modify |
| 7 | * it under the terms of the GNU General Public License as published by |
| 8 | * the Free Software Foundation; either version 2 of the License, or |
| 9 | * (at your option) any later version. |
| 10 | |
| 11 | * This program is distributed in the hope that it will be useful, |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | * GNU General Public License for more details. |
| 15 | |
| 16 | * You should have received a copy of the GNU General Public License along |
| 17 | * with this program; if not, write to the Free Software Foundation, Inc., |
| 18 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
| 19 | */ |
| 20 | |
| 21 | #include <linux/slab.h> |
| 22 | #include <linux/device.h> |
| 23 | #include <linux/module.h> |
Dong Aisheng | baa6415 | 2012-09-05 10:57:15 +0800 | [diff] [blame] | 24 | #include <linux/mfd/syscon.h> |
Ying-Chun Liu (PaulLiu) | e3e5aff | 2012-03-14 10:29:12 +0800 | [diff] [blame] | 25 | #include <linux/err.h> |
| 26 | #include <linux/io.h> |
| 27 | #include <linux/platform_device.h> |
| 28 | #include <linux/of.h> |
| 29 | #include <linux/of_address.h> |
Dong Aisheng | baa6415 | 2012-09-05 10:57:15 +0800 | [diff] [blame] | 30 | #include <linux/regmap.h> |
Ying-Chun Liu (PaulLiu) | e3e5aff | 2012-03-14 10:29:12 +0800 | [diff] [blame] | 31 | #include <linux/regulator/driver.h> |
| 32 | #include <linux/regulator/of_regulator.h> |
Sascha Hauer | 0d19208 | 2015-10-13 12:45:30 +0200 | [diff] [blame] | 33 | #include <linux/regulator/machine.h> |
Ying-Chun Liu (PaulLiu) | e3e5aff | 2012-03-14 10:29:12 +0800 | [diff] [blame] | 34 | |
Anson Huang | 9ee417c | 2013-01-31 11:23:53 -0500 | [diff] [blame] | 35 | #define LDO_RAMP_UP_UNIT_IN_CYCLES 64 /* 64 cycles per step */ |
| 36 | #define LDO_RAMP_UP_FREQ_IN_MHZ 24 /* cycle based on 24M OSC */ |
| 37 | |
Philipp Zabel | 605ebd3 | 2014-02-11 14:43:44 +0100 | [diff] [blame] | 38 | #define LDO_POWER_GATE 0x00 |
Philipp Zabel | d38018f | 2014-02-11 14:43:45 +0100 | [diff] [blame] | 39 | #define LDO_FET_FULL_ON 0x1f |
Philipp Zabel | 605ebd3 | 2014-02-11 14:43:44 +0100 | [diff] [blame] | 40 | |
Ying-Chun Liu (PaulLiu) | e3e5aff | 2012-03-14 10:29:12 +0800 | [diff] [blame] | 41 | struct anatop_regulator { |
| 42 | const char *name; |
| 43 | u32 control_reg; |
Dong Aisheng | baa6415 | 2012-09-05 10:57:15 +0800 | [diff] [blame] | 44 | struct regmap *anatop; |
Ying-Chun Liu (PaulLiu) | e3e5aff | 2012-03-14 10:29:12 +0800 | [diff] [blame] | 45 | int vol_bit_shift; |
| 46 | int vol_bit_width; |
Anson Huang | 9ee417c | 2013-01-31 11:23:53 -0500 | [diff] [blame] | 47 | u32 delay_reg; |
| 48 | int delay_bit_shift; |
| 49 | int delay_bit_width; |
Ying-Chun Liu (PaulLiu) | e3e5aff | 2012-03-14 10:29:12 +0800 | [diff] [blame] | 50 | int min_bit_val; |
| 51 | int min_voltage; |
| 52 | int max_voltage; |
| 53 | struct regulator_desc rdesc; |
| 54 | struct regulator_init_data *initdata; |
Philipp Zabel | d38018f | 2014-02-11 14:43:45 +0100 | [diff] [blame] | 55 | bool bypass; |
Philipp Zabel | 605ebd3 | 2014-02-11 14:43:44 +0100 | [diff] [blame] | 56 | int sel; |
Ying-Chun Liu (PaulLiu) | e3e5aff | 2012-03-14 10:29:12 +0800 | [diff] [blame] | 57 | }; |
| 58 | |
Anson Huang | 9ee417c | 2013-01-31 11:23:53 -0500 | [diff] [blame] | 59 | static int anatop_regmap_set_voltage_time_sel(struct regulator_dev *reg, |
| 60 | unsigned int old_sel, |
| 61 | unsigned int new_sel) |
| 62 | { |
| 63 | struct anatop_regulator *anatop_reg = rdev_get_drvdata(reg); |
| 64 | u32 val; |
| 65 | int ret = 0; |
| 66 | |
| 67 | /* check whether need to care about LDO ramp up speed */ |
| 68 | if (anatop_reg->delay_bit_width && new_sel > old_sel) { |
| 69 | /* |
| 70 | * the delay for LDO ramp up time is |
| 71 | * based on the register setting, we need |
| 72 | * to calculate how many steps LDO need to |
| 73 | * ramp up, and how much delay needed. (us) |
| 74 | */ |
| 75 | regmap_read(anatop_reg->anatop, anatop_reg->delay_reg, &val); |
| 76 | val = (val >> anatop_reg->delay_bit_shift) & |
| 77 | ((1 << anatop_reg->delay_bit_width) - 1); |
Shawn Guo | ff1ce05 | 2013-02-04 10:21:32 +0800 | [diff] [blame] | 78 | ret = (new_sel - old_sel) * (LDO_RAMP_UP_UNIT_IN_CYCLES << |
| 79 | val) / LDO_RAMP_UP_FREQ_IN_MHZ + 1; |
Anson Huang | 9ee417c | 2013-01-31 11:23:53 -0500 | [diff] [blame] | 80 | } |
| 81 | |
| 82 | return ret; |
| 83 | } |
| 84 | |
Philipp Zabel | 605ebd3 | 2014-02-11 14:43:44 +0100 | [diff] [blame] | 85 | static int anatop_regmap_enable(struct regulator_dev *reg) |
| 86 | { |
| 87 | struct anatop_regulator *anatop_reg = rdev_get_drvdata(reg); |
Philipp Zabel | d38018f | 2014-02-11 14:43:45 +0100 | [diff] [blame] | 88 | int sel; |
Philipp Zabel | 605ebd3 | 2014-02-11 14:43:44 +0100 | [diff] [blame] | 89 | |
Philipp Zabel | d38018f | 2014-02-11 14:43:45 +0100 | [diff] [blame] | 90 | sel = anatop_reg->bypass ? LDO_FET_FULL_ON : anatop_reg->sel; |
| 91 | return regulator_set_voltage_sel_regmap(reg, sel); |
Philipp Zabel | 605ebd3 | 2014-02-11 14:43:44 +0100 | [diff] [blame] | 92 | } |
| 93 | |
| 94 | static int anatop_regmap_disable(struct regulator_dev *reg) |
| 95 | { |
| 96 | return regulator_set_voltage_sel_regmap(reg, LDO_POWER_GATE); |
| 97 | } |
| 98 | |
| 99 | static int anatop_regmap_is_enabled(struct regulator_dev *reg) |
| 100 | { |
| 101 | return regulator_get_voltage_sel_regmap(reg) != LDO_POWER_GATE; |
| 102 | } |
| 103 | |
| 104 | static int anatop_regmap_core_set_voltage_sel(struct regulator_dev *reg, |
| 105 | unsigned selector) |
| 106 | { |
| 107 | struct anatop_regulator *anatop_reg = rdev_get_drvdata(reg); |
| 108 | int ret; |
| 109 | |
Philipp Zabel | d38018f | 2014-02-11 14:43:45 +0100 | [diff] [blame] | 110 | if (anatop_reg->bypass || !anatop_regmap_is_enabled(reg)) { |
Philipp Zabel | 605ebd3 | 2014-02-11 14:43:44 +0100 | [diff] [blame] | 111 | anatop_reg->sel = selector; |
| 112 | return 0; |
| 113 | } |
| 114 | |
| 115 | ret = regulator_set_voltage_sel_regmap(reg, selector); |
| 116 | if (!ret) |
| 117 | anatop_reg->sel = selector; |
| 118 | return ret; |
| 119 | } |
| 120 | |
| 121 | static int anatop_regmap_core_get_voltage_sel(struct regulator_dev *reg) |
| 122 | { |
| 123 | struct anatop_regulator *anatop_reg = rdev_get_drvdata(reg); |
| 124 | |
Philipp Zabel | d38018f | 2014-02-11 14:43:45 +0100 | [diff] [blame] | 125 | if (anatop_reg->bypass || !anatop_regmap_is_enabled(reg)) |
Philipp Zabel | 605ebd3 | 2014-02-11 14:43:44 +0100 | [diff] [blame] | 126 | return anatop_reg->sel; |
| 127 | |
| 128 | return regulator_get_voltage_sel_regmap(reg); |
| 129 | } |
| 130 | |
Philipp Zabel | d38018f | 2014-02-11 14:43:45 +0100 | [diff] [blame] | 131 | static int anatop_regmap_get_bypass(struct regulator_dev *reg, bool *enable) |
| 132 | { |
| 133 | struct anatop_regulator *anatop_reg = rdev_get_drvdata(reg); |
| 134 | int sel; |
| 135 | |
| 136 | sel = regulator_get_voltage_sel_regmap(reg); |
| 137 | if (sel == LDO_FET_FULL_ON) |
| 138 | WARN_ON(!anatop_reg->bypass); |
| 139 | else if (sel != LDO_POWER_GATE) |
| 140 | WARN_ON(anatop_reg->bypass); |
| 141 | |
| 142 | *enable = anatop_reg->bypass; |
| 143 | return 0; |
| 144 | } |
| 145 | |
| 146 | static int anatop_regmap_set_bypass(struct regulator_dev *reg, bool enable) |
| 147 | { |
| 148 | struct anatop_regulator *anatop_reg = rdev_get_drvdata(reg); |
| 149 | int sel; |
| 150 | |
| 151 | if (enable == anatop_reg->bypass) |
| 152 | return 0; |
| 153 | |
| 154 | sel = enable ? LDO_FET_FULL_ON : anatop_reg->sel; |
| 155 | anatop_reg->bypass = enable; |
| 156 | |
| 157 | return regulator_set_voltage_sel_regmap(reg, sel); |
| 158 | } |
| 159 | |
Ying-Chun Liu (PaulLiu) | e3e5aff | 2012-03-14 10:29:12 +0800 | [diff] [blame] | 160 | static struct regulator_ops anatop_rops = { |
Axel Lin | 114c574 | 2014-02-22 12:53:18 +0800 | [diff] [blame] | 161 | .set_voltage_sel = regulator_set_voltage_sel_regmap, |
| 162 | .get_voltage_sel = regulator_get_voltage_sel_regmap, |
Axel Lin | d01c3a1 | 2012-06-03 23:02:34 +0800 | [diff] [blame] | 163 | .list_voltage = regulator_list_voltage_linear, |
| 164 | .map_voltage = regulator_map_voltage_linear, |
Ying-Chun Liu (PaulLiu) | e3e5aff | 2012-03-14 10:29:12 +0800 | [diff] [blame] | 165 | }; |
| 166 | |
Philipp Zabel | 605ebd3 | 2014-02-11 14:43:44 +0100 | [diff] [blame] | 167 | static struct regulator_ops anatop_core_rops = { |
| 168 | .enable = anatop_regmap_enable, |
| 169 | .disable = anatop_regmap_disable, |
| 170 | .is_enabled = anatop_regmap_is_enabled, |
| 171 | .set_voltage_sel = anatop_regmap_core_set_voltage_sel, |
| 172 | .set_voltage_time_sel = anatop_regmap_set_voltage_time_sel, |
| 173 | .get_voltage_sel = anatop_regmap_core_get_voltage_sel, |
| 174 | .list_voltage = regulator_list_voltage_linear, |
| 175 | .map_voltage = regulator_map_voltage_linear, |
Philipp Zabel | d38018f | 2014-02-11 14:43:45 +0100 | [diff] [blame] | 176 | .get_bypass = anatop_regmap_get_bypass, |
| 177 | .set_bypass = anatop_regmap_set_bypass, |
Philipp Zabel | 605ebd3 | 2014-02-11 14:43:44 +0100 | [diff] [blame] | 178 | }; |
| 179 | |
Bill Pemberton | a502357 | 2012-11-19 13:22:22 -0500 | [diff] [blame] | 180 | static int anatop_regulator_probe(struct platform_device *pdev) |
Ying-Chun Liu (PaulLiu) | e3e5aff | 2012-03-14 10:29:12 +0800 | [diff] [blame] | 181 | { |
| 182 | struct device *dev = &pdev->dev; |
| 183 | struct device_node *np = dev->of_node; |
Dong Aisheng | baa6415 | 2012-09-05 10:57:15 +0800 | [diff] [blame] | 184 | struct device_node *anatop_np; |
Ying-Chun Liu (PaulLiu) | e3e5aff | 2012-03-14 10:29:12 +0800 | [diff] [blame] | 185 | struct regulator_desc *rdesc; |
| 186 | struct regulator_dev *rdev; |
| 187 | struct anatop_regulator *sreg; |
| 188 | struct regulator_init_data *initdata; |
Axel Lin | d914d81 | 2012-04-10 22:45:01 +0800 | [diff] [blame] | 189 | struct regulator_config config = { }; |
Ying-Chun Liu (PaulLiu) | e3e5aff | 2012-03-14 10:29:12 +0800 | [diff] [blame] | 190 | int ret = 0; |
Philipp Zabel | 605ebd3 | 2014-02-11 14:43:44 +0100 | [diff] [blame] | 191 | u32 val; |
Ying-Chun Liu (PaulLiu) | e3e5aff | 2012-03-14 10:29:12 +0800 | [diff] [blame] | 192 | |
Ying-Chun Liu (PaulLiu) | e3e5aff | 2012-03-14 10:29:12 +0800 | [diff] [blame] | 193 | sreg = devm_kzalloc(dev, sizeof(*sreg), GFP_KERNEL); |
| 194 | if (!sreg) |
| 195 | return -ENOMEM; |
Dong Aisheng | 5062e04 | 2017-04-12 09:58:44 +0800 | [diff] [blame^] | 196 | |
| 197 | of_property_read_string(np, "regulator-name", &sreg->name); |
Ying-Chun Liu (PaulLiu) | e3e5aff | 2012-03-14 10:29:12 +0800 | [diff] [blame] | 198 | rdesc = &sreg->rdesc; |
Ying-Chun Liu (PaulLiu) | e3e5aff | 2012-03-14 10:29:12 +0800 | [diff] [blame] | 199 | rdesc->name = sreg->name; |
Ying-Chun Liu (PaulLiu) | e3e5aff | 2012-03-14 10:29:12 +0800 | [diff] [blame] | 200 | rdesc->type = REGULATOR_VOLTAGE; |
| 201 | rdesc->owner = THIS_MODULE; |
Dong Aisheng | baa6415 | 2012-09-05 10:57:15 +0800 | [diff] [blame] | 202 | |
Javier Martinez Canillas | 072e78b | 2014-11-10 14:43:53 +0100 | [diff] [blame] | 203 | initdata = of_get_regulator_init_data(dev, np, rdesc); |
Dong Aisheng | 7f51cf2 | 2017-04-12 09:58:42 +0800 | [diff] [blame] | 204 | if (!initdata) |
| 205 | return -ENOMEM; |
| 206 | |
Sascha Hauer | 0d19208 | 2015-10-13 12:45:30 +0200 | [diff] [blame] | 207 | initdata->supply_regulator = "vin"; |
Javier Martinez Canillas | 072e78b | 2014-11-10 14:43:53 +0100 | [diff] [blame] | 208 | sreg->initdata = initdata; |
| 209 | |
Dong Aisheng | baa6415 | 2012-09-05 10:57:15 +0800 | [diff] [blame] | 210 | anatop_np = of_get_parent(np); |
| 211 | if (!anatop_np) |
| 212 | return -ENODEV; |
| 213 | sreg->anatop = syscon_node_to_regmap(anatop_np); |
| 214 | of_node_put(anatop_np); |
| 215 | if (IS_ERR(sreg->anatop)) |
| 216 | return PTR_ERR(sreg->anatop); |
| 217 | |
Ying-Chun Liu (PaulLiu) | 2f2cc27 | 2012-03-27 15:54:01 +0800 | [diff] [blame] | 218 | ret = of_property_read_u32(np, "anatop-reg-offset", |
| 219 | &sreg->control_reg); |
Ying-Chun Liu (PaulLiu) | e3e5aff | 2012-03-14 10:29:12 +0800 | [diff] [blame] | 220 | if (ret) { |
Ying-Chun Liu (PaulLiu) | 2f2cc27 | 2012-03-27 15:54:01 +0800 | [diff] [blame] | 221 | dev_err(dev, "no anatop-reg-offset property set\n"); |
Fabio Estevam | f2b269b | 2014-01-06 10:13:15 -0200 | [diff] [blame] | 222 | return ret; |
Ying-Chun Liu (PaulLiu) | e3e5aff | 2012-03-14 10:29:12 +0800 | [diff] [blame] | 223 | } |
| 224 | ret = of_property_read_u32(np, "anatop-vol-bit-width", |
| 225 | &sreg->vol_bit_width); |
| 226 | if (ret) { |
| 227 | dev_err(dev, "no anatop-vol-bit-width property set\n"); |
Fabio Estevam | f2b269b | 2014-01-06 10:13:15 -0200 | [diff] [blame] | 228 | return ret; |
Ying-Chun Liu (PaulLiu) | e3e5aff | 2012-03-14 10:29:12 +0800 | [diff] [blame] | 229 | } |
| 230 | ret = of_property_read_u32(np, "anatop-vol-bit-shift", |
| 231 | &sreg->vol_bit_shift); |
| 232 | if (ret) { |
| 233 | dev_err(dev, "no anatop-vol-bit-shift property set\n"); |
Fabio Estevam | f2b269b | 2014-01-06 10:13:15 -0200 | [diff] [blame] | 234 | return ret; |
Ying-Chun Liu (PaulLiu) | e3e5aff | 2012-03-14 10:29:12 +0800 | [diff] [blame] | 235 | } |
| 236 | ret = of_property_read_u32(np, "anatop-min-bit-val", |
| 237 | &sreg->min_bit_val); |
| 238 | if (ret) { |
| 239 | dev_err(dev, "no anatop-min-bit-val property set\n"); |
Fabio Estevam | f2b269b | 2014-01-06 10:13:15 -0200 | [diff] [blame] | 240 | return ret; |
Ying-Chun Liu (PaulLiu) | e3e5aff | 2012-03-14 10:29:12 +0800 | [diff] [blame] | 241 | } |
| 242 | ret = of_property_read_u32(np, "anatop-min-voltage", |
| 243 | &sreg->min_voltage); |
| 244 | if (ret) { |
| 245 | dev_err(dev, "no anatop-min-voltage property set\n"); |
Fabio Estevam | f2b269b | 2014-01-06 10:13:15 -0200 | [diff] [blame] | 246 | return ret; |
Ying-Chun Liu (PaulLiu) | e3e5aff | 2012-03-14 10:29:12 +0800 | [diff] [blame] | 247 | } |
| 248 | ret = of_property_read_u32(np, "anatop-max-voltage", |
| 249 | &sreg->max_voltage); |
| 250 | if (ret) { |
| 251 | dev_err(dev, "no anatop-max-voltage property set\n"); |
Fabio Estevam | f2b269b | 2014-01-06 10:13:15 -0200 | [diff] [blame] | 252 | return ret; |
Ying-Chun Liu (PaulLiu) | e3e5aff | 2012-03-14 10:29:12 +0800 | [diff] [blame] | 253 | } |
| 254 | |
Anson Huang | 9ee417c | 2013-01-31 11:23:53 -0500 | [diff] [blame] | 255 | /* read LDO ramp up setting, only for core reg */ |
| 256 | of_property_read_u32(np, "anatop-delay-reg-offset", |
| 257 | &sreg->delay_reg); |
| 258 | of_property_read_u32(np, "anatop-delay-bit-width", |
| 259 | &sreg->delay_bit_width); |
| 260 | of_property_read_u32(np, "anatop-delay-bit-shift", |
| 261 | &sreg->delay_bit_shift); |
| 262 | |
Axel Lin | 985884d | 2012-12-09 08:05:45 +0800 | [diff] [blame] | 263 | rdesc->n_voltages = (sreg->max_voltage - sreg->min_voltage) / 25000 + 1 |
| 264 | + sreg->min_bit_val; |
Axel Lin | 0713e6a | 2012-05-14 11:06:44 +0800 | [diff] [blame] | 265 | rdesc->min_uV = sreg->min_voltage; |
| 266 | rdesc->uV_step = 25000; |
Axel Lin | 985884d | 2012-12-09 08:05:45 +0800 | [diff] [blame] | 267 | rdesc->linear_min_sel = sreg->min_bit_val; |
Axel Lin | e1b0144 | 2012-12-09 08:07:43 +0800 | [diff] [blame] | 268 | rdesc->vsel_reg = sreg->control_reg; |
| 269 | rdesc->vsel_mask = ((1 << sreg->vol_bit_width) - 1) << |
| 270 | sreg->vol_bit_shift; |
Sascha Hauer | 0d19208 | 2015-10-13 12:45:30 +0200 | [diff] [blame] | 271 | rdesc->min_dropout_uV = 125000; |
Ying-Chun Liu (PaulLiu) | e3e5aff | 2012-03-14 10:29:12 +0800 | [diff] [blame] | 272 | |
Axel Lin | d914d81 | 2012-04-10 22:45:01 +0800 | [diff] [blame] | 273 | config.dev = &pdev->dev; |
| 274 | config.init_data = initdata; |
| 275 | config.driver_data = sreg; |
| 276 | config.of_node = pdev->dev.of_node; |
Axel Lin | e1b0144 | 2012-12-09 08:07:43 +0800 | [diff] [blame] | 277 | config.regmap = sreg->anatop; |
Axel Lin | d914d81 | 2012-04-10 22:45:01 +0800 | [diff] [blame] | 278 | |
Philipp Zabel | 605ebd3 | 2014-02-11 14:43:44 +0100 | [diff] [blame] | 279 | /* Only core regulators have the ramp up delay configuration. */ |
| 280 | if (sreg->control_reg && sreg->delay_bit_width) { |
| 281 | rdesc->ops = &anatop_core_rops; |
| 282 | |
| 283 | ret = regmap_read(config.regmap, rdesc->vsel_reg, &val); |
| 284 | if (ret) { |
| 285 | dev_err(dev, "failed to read initial state\n"); |
| 286 | return ret; |
| 287 | } |
| 288 | |
| 289 | sreg->sel = (val & rdesc->vsel_mask) >> sreg->vol_bit_shift; |
Philipp Zabel | d38018f | 2014-02-11 14:43:45 +0100 | [diff] [blame] | 290 | if (sreg->sel == LDO_FET_FULL_ON) { |
| 291 | sreg->sel = 0; |
| 292 | sreg->bypass = true; |
| 293 | } |
Markus Pargmann | fe08be3 | 2014-10-06 21:33:36 +0200 | [diff] [blame] | 294 | |
| 295 | /* |
| 296 | * In case vddpu was disabled by the bootloader, we need to set |
| 297 | * a sane default until imx6-cpufreq was probed and changes the |
| 298 | * voltage to the correct value. In this case we set 1.25V. |
| 299 | */ |
| 300 | if (!sreg->sel && !strcmp(sreg->name, "vddpu")) |
| 301 | sreg->sel = 22; |
Markus Pargmann | da0607c | 2014-10-06 21:33:37 +0200 | [diff] [blame] | 302 | |
Mika Båtsman | 8a092e6 | 2016-06-17 13:31:37 +0300 | [diff] [blame] | 303 | if (!sreg->bypass && !sreg->sel) { |
Markus Pargmann | da0607c | 2014-10-06 21:33:37 +0200 | [diff] [blame] | 304 | dev_err(&pdev->dev, "Failed to read a valid default voltage selector.\n"); |
| 305 | return -EINVAL; |
| 306 | } |
Philipp Zabel | 605ebd3 | 2014-02-11 14:43:44 +0100 | [diff] [blame] | 307 | } else { |
| 308 | rdesc->ops = &anatop_rops; |
| 309 | } |
| 310 | |
Ying-Chun Liu (PaulLiu) | e3e5aff | 2012-03-14 10:29:12 +0800 | [diff] [blame] | 311 | /* register regulator */ |
Sachin Kamat | be1221e | 2013-09-04 12:00:57 +0530 | [diff] [blame] | 312 | rdev = devm_regulator_register(dev, rdesc, &config); |
Ying-Chun Liu (PaulLiu) | e3e5aff | 2012-03-14 10:29:12 +0800 | [diff] [blame] | 313 | if (IS_ERR(rdev)) { |
| 314 | dev_err(dev, "failed to register %s\n", |
| 315 | rdesc->name); |
Fabio Estevam | f2b269b | 2014-01-06 10:13:15 -0200 | [diff] [blame] | 316 | return PTR_ERR(rdev); |
Ying-Chun Liu (PaulLiu) | e3e5aff | 2012-03-14 10:29:12 +0800 | [diff] [blame] | 317 | } |
| 318 | |
| 319 | platform_set_drvdata(pdev, rdev); |
| 320 | |
Ying-Chun Liu (PaulLiu) | e3e5aff | 2012-03-14 10:29:12 +0800 | [diff] [blame] | 321 | return 0; |
| 322 | } |
| 323 | |
Jingoo Han | a799baa | 2014-05-07 16:55:10 +0900 | [diff] [blame] | 324 | static const struct of_device_id of_anatop_regulator_match_tbl[] = { |
Ying-Chun Liu (PaulLiu) | e3e5aff | 2012-03-14 10:29:12 +0800 | [diff] [blame] | 325 | { .compatible = "fsl,anatop-regulator", }, |
| 326 | { /* end */ } |
| 327 | }; |
Luis de Bethencourt | d702ffd | 2015-09-18 19:09:07 +0200 | [diff] [blame] | 328 | MODULE_DEVICE_TABLE(of, of_anatop_regulator_match_tbl); |
Ying-Chun Liu (PaulLiu) | e3e5aff | 2012-03-14 10:29:12 +0800 | [diff] [blame] | 329 | |
Shawn Guo | c0d78c2 | 2012-04-02 14:57:01 +0800 | [diff] [blame] | 330 | static struct platform_driver anatop_regulator_driver = { |
Ying-Chun Liu (PaulLiu) | e3e5aff | 2012-03-14 10:29:12 +0800 | [diff] [blame] | 331 | .driver = { |
| 332 | .name = "anatop_regulator", |
Ying-Chun Liu (PaulLiu) | e3e5aff | 2012-03-14 10:29:12 +0800 | [diff] [blame] | 333 | .of_match_table = of_anatop_regulator_match_tbl, |
| 334 | }, |
| 335 | .probe = anatop_regulator_probe, |
Ying-Chun Liu (PaulLiu) | e3e5aff | 2012-03-14 10:29:12 +0800 | [diff] [blame] | 336 | }; |
| 337 | |
| 338 | static int __init anatop_regulator_init(void) |
| 339 | { |
Shawn Guo | c0d78c2 | 2012-04-02 14:57:01 +0800 | [diff] [blame] | 340 | return platform_driver_register(&anatop_regulator_driver); |
Ying-Chun Liu (PaulLiu) | e3e5aff | 2012-03-14 10:29:12 +0800 | [diff] [blame] | 341 | } |
| 342 | postcore_initcall(anatop_regulator_init); |
| 343 | |
| 344 | static void __exit anatop_regulator_exit(void) |
| 345 | { |
Shawn Guo | c0d78c2 | 2012-04-02 14:57:01 +0800 | [diff] [blame] | 346 | platform_driver_unregister(&anatop_regulator_driver); |
Ying-Chun Liu (PaulLiu) | e3e5aff | 2012-03-14 10:29:12 +0800 | [diff] [blame] | 347 | } |
| 348 | module_exit(anatop_regulator_exit); |
| 349 | |
Jingoo Han | 34f7568 | 2013-10-14 17:45:51 +0900 | [diff] [blame] | 350 | MODULE_AUTHOR("Nancy Chen <Nancy.Chen@freescale.com>"); |
| 351 | MODULE_AUTHOR("Ying-Chun Liu (PaulLiu) <paul.liu@linaro.org>"); |
Ying-Chun Liu (PaulLiu) | e3e5aff | 2012-03-14 10:29:12 +0800 | [diff] [blame] | 352 | MODULE_DESCRIPTION("ANATOP Regulator driver"); |
| 353 | MODULE_LICENSE("GPL v2"); |
Fabio Estevam | 89705b9 | 2013-12-31 10:56:00 -0200 | [diff] [blame] | 354 | MODULE_ALIAS("platform:anatop_regulator"); |