Venu Byravarasu | 452534e | 2012-03-22 18:34:09 +0530 | [diff] [blame] | 1 | /* |
| 2 | * Regulator driver for tps65090 power management chip. |
| 3 | * |
| 4 | * Copyright (c) 2012, NVIDIA CORPORATION. All rights reserved. |
| 5 | |
| 6 | * This program is free software; you can redistribute it and/or modify it |
| 7 | * under the terms and conditions of the GNU General Public License, |
| 8 | * version 2, as published by the Free Software Foundation. |
| 9 | |
| 10 | * This program is distributed in the hope it will be useful, but WITHOUT |
| 11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| 12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for |
| 13 | * more details. |
| 14 | |
| 15 | * You should have received a copy of the GNU General Public License |
| 16 | * along with this program. If not, see <http://www.gnu.org/licenses/> |
| 17 | */ |
| 18 | |
| 19 | #include <linux/module.h> |
Venu Byravarasu | 452534e | 2012-03-22 18:34:09 +0530 | [diff] [blame] | 20 | #include <linux/init.h> |
Laxman Dewangan | f329b17 | 2012-10-09 15:19:02 +0530 | [diff] [blame] | 21 | #include <linux/gpio.h> |
Laxman Dewangan | 6c7a7a0 | 2013-01-29 14:35:16 +0530 | [diff] [blame] | 22 | #include <linux/of_gpio.h> |
Venu Byravarasu | 452534e | 2012-03-22 18:34:09 +0530 | [diff] [blame] | 23 | #include <linux/slab.h> |
| 24 | #include <linux/err.h> |
| 25 | #include <linux/platform_device.h> |
| 26 | #include <linux/regulator/driver.h> |
| 27 | #include <linux/regulator/machine.h> |
Laxman Dewangan | 6c7a7a0 | 2013-01-29 14:35:16 +0530 | [diff] [blame] | 28 | #include <linux/regulator/of_regulator.h> |
Venu Byravarasu | 452534e | 2012-03-22 18:34:09 +0530 | [diff] [blame] | 29 | #include <linux/mfd/tps65090.h> |
Venu Byravarasu | 452534e | 2012-03-22 18:34:09 +0530 | [diff] [blame] | 30 | |
| 31 | struct tps65090_regulator { |
Venu Byravarasu | 452534e | 2012-03-22 18:34:09 +0530 | [diff] [blame] | 32 | struct device *dev; |
Laxman Dewangan | 24282a1 | 2012-10-09 15:18:59 +0530 | [diff] [blame] | 33 | struct regulator_desc *desc; |
| 34 | struct regulator_dev *rdev; |
Venu Byravarasu | 452534e | 2012-03-22 18:34:09 +0530 | [diff] [blame] | 35 | }; |
| 36 | |
Laxman Dewangan | f329b17 | 2012-10-09 15:19:02 +0530 | [diff] [blame] | 37 | static struct regulator_ops tps65090_ext_control_ops = { |
| 38 | }; |
| 39 | |
| 40 | static struct regulator_ops tps65090_reg_contol_ops = { |
| 41 | .enable = regulator_enable_regmap, |
| 42 | .disable = regulator_disable_regmap, |
| 43 | .is_enabled = regulator_is_enabled_regmap, |
Venu Byravarasu | 452534e | 2012-03-22 18:34:09 +0530 | [diff] [blame] | 44 | }; |
| 45 | |
Laxman Dewangan | 3a81ef8 | 2012-10-09 15:19:01 +0530 | [diff] [blame] | 46 | static struct regulator_ops tps65090_ldo_ops = { |
| 47 | }; |
| 48 | |
Laxman Dewangan | 24282a1 | 2012-10-09 15:18:59 +0530 | [diff] [blame] | 49 | #define tps65090_REG_DESC(_id, _sname, _en_reg, _ops) \ |
Venu Byravarasu | 452534e | 2012-03-22 18:34:09 +0530 | [diff] [blame] | 50 | { \ |
Laxman Dewangan | 24282a1 | 2012-10-09 15:18:59 +0530 | [diff] [blame] | 51 | .name = "TPS65090_RAILS"#_id, \ |
| 52 | .supply_name = _sname, \ |
Laxman Dewangan | 8620ca9 | 2012-10-09 15:19:00 +0530 | [diff] [blame] | 53 | .id = TPS65090_REGULATOR_##_id, \ |
Laxman Dewangan | 24282a1 | 2012-10-09 15:18:59 +0530 | [diff] [blame] | 54 | .ops = &_ops, \ |
| 55 | .enable_reg = _en_reg, \ |
| 56 | .enable_mask = BIT(0), \ |
| 57 | .type = REGULATOR_VOLTAGE, \ |
| 58 | .owner = THIS_MODULE, \ |
Venu Byravarasu | 452534e | 2012-03-22 18:34:09 +0530 | [diff] [blame] | 59 | } |
| 60 | |
Laxman Dewangan | 24282a1 | 2012-10-09 15:18:59 +0530 | [diff] [blame] | 61 | static struct regulator_desc tps65090_regulator_desc[] = { |
Laxman Dewangan | f329b17 | 2012-10-09 15:19:02 +0530 | [diff] [blame] | 62 | tps65090_REG_DESC(DCDC1, "vsys1", 0x0C, tps65090_reg_contol_ops), |
| 63 | tps65090_REG_DESC(DCDC2, "vsys2", 0x0D, tps65090_reg_contol_ops), |
| 64 | tps65090_REG_DESC(DCDC3, "vsys3", 0x0E, tps65090_reg_contol_ops), |
| 65 | tps65090_REG_DESC(FET1, "infet1", 0x0F, tps65090_reg_contol_ops), |
| 66 | tps65090_REG_DESC(FET2, "infet2", 0x10, tps65090_reg_contol_ops), |
| 67 | tps65090_REG_DESC(FET3, "infet3", 0x11, tps65090_reg_contol_ops), |
| 68 | tps65090_REG_DESC(FET4, "infet4", 0x12, tps65090_reg_contol_ops), |
| 69 | tps65090_REG_DESC(FET5, "infet5", 0x13, tps65090_reg_contol_ops), |
| 70 | tps65090_REG_DESC(FET6, "infet6", 0x14, tps65090_reg_contol_ops), |
| 71 | tps65090_REG_DESC(FET7, "infet7", 0x15, tps65090_reg_contol_ops), |
Laxman Dewangan | 6c7a7a0 | 2013-01-29 14:35:16 +0530 | [diff] [blame] | 72 | tps65090_REG_DESC(LDO1, "vsys-l1", 0, tps65090_ldo_ops), |
| 73 | tps65090_REG_DESC(LDO2, "vsys-l2", 0, tps65090_ldo_ops), |
Venu Byravarasu | 452534e | 2012-03-22 18:34:09 +0530 | [diff] [blame] | 74 | }; |
| 75 | |
Laxman Dewangan | 24282a1 | 2012-10-09 15:18:59 +0530 | [diff] [blame] | 76 | static inline bool is_dcdc(int id) |
Venu Byravarasu | 452534e | 2012-03-22 18:34:09 +0530 | [diff] [blame] | 77 | { |
Laxman Dewangan | 24282a1 | 2012-10-09 15:18:59 +0530 | [diff] [blame] | 78 | switch (id) { |
Laxman Dewangan | 8620ca9 | 2012-10-09 15:19:00 +0530 | [diff] [blame] | 79 | case TPS65090_REGULATOR_DCDC1: |
| 80 | case TPS65090_REGULATOR_DCDC2: |
| 81 | case TPS65090_REGULATOR_DCDC3: |
Laxman Dewangan | 24282a1 | 2012-10-09 15:18:59 +0530 | [diff] [blame] | 82 | return true; |
| 83 | default: |
| 84 | return false; |
Venu Byravarasu | 452534e | 2012-03-22 18:34:09 +0530 | [diff] [blame] | 85 | } |
Laxman Dewangan | 24282a1 | 2012-10-09 15:18:59 +0530 | [diff] [blame] | 86 | } |
| 87 | |
Bill Pemberton | a502357 | 2012-11-19 13:22:22 -0500 | [diff] [blame] | 88 | static int tps65090_config_ext_control( |
Laxman Dewangan | 24282a1 | 2012-10-09 15:18:59 +0530 | [diff] [blame] | 89 | struct tps65090_regulator *ri, bool enable) |
| 90 | { |
| 91 | int ret; |
| 92 | struct device *parent = ri->dev->parent; |
| 93 | unsigned int reg_en_reg = ri->desc->enable_reg; |
| 94 | |
| 95 | if (enable) |
| 96 | ret = tps65090_set_bits(parent, reg_en_reg, 1); |
| 97 | else |
| 98 | ret = tps65090_clr_bits(parent, reg_en_reg, 1); |
| 99 | if (ret < 0) |
| 100 | dev_err(ri->dev, "Error in updating reg 0x%x\n", reg_en_reg); |
| 101 | return ret; |
| 102 | } |
| 103 | |
Bill Pemberton | a502357 | 2012-11-19 13:22:22 -0500 | [diff] [blame] | 104 | static int tps65090_regulator_disable_ext_control( |
Laxman Dewangan | 24282a1 | 2012-10-09 15:18:59 +0530 | [diff] [blame] | 105 | struct tps65090_regulator *ri, |
| 106 | struct tps65090_regulator_plat_data *tps_pdata) |
| 107 | { |
| 108 | int ret = 0; |
| 109 | struct device *parent = ri->dev->parent; |
| 110 | unsigned int reg_en_reg = ri->desc->enable_reg; |
| 111 | |
| 112 | /* |
| 113 | * First enable output for internal control if require. |
| 114 | * And then disable external control. |
| 115 | */ |
| 116 | if (tps_pdata->reg_init_data->constraints.always_on || |
| 117 | tps_pdata->reg_init_data->constraints.boot_on) { |
| 118 | ret = tps65090_set_bits(parent, reg_en_reg, 0); |
| 119 | if (ret < 0) { |
| 120 | dev_err(ri->dev, "Error in set reg 0x%x\n", reg_en_reg); |
| 121 | return ret; |
| 122 | } |
| 123 | } |
| 124 | return tps65090_config_ext_control(ri, false); |
Venu Byravarasu | 452534e | 2012-03-22 18:34:09 +0530 | [diff] [blame] | 125 | } |
| 126 | |
Bill Pemberton | a502357 | 2012-11-19 13:22:22 -0500 | [diff] [blame] | 127 | static void tps65090_configure_regulator_config( |
Laxman Dewangan | f329b17 | 2012-10-09 15:19:02 +0530 | [diff] [blame] | 128 | struct tps65090_regulator_plat_data *tps_pdata, |
| 129 | struct regulator_config *config) |
| 130 | { |
| 131 | if (gpio_is_valid(tps_pdata->gpio)) { |
| 132 | int gpio_flag = GPIOF_OUT_INIT_LOW; |
| 133 | |
| 134 | if (tps_pdata->reg_init_data->constraints.always_on || |
| 135 | tps_pdata->reg_init_data->constraints.boot_on) |
| 136 | gpio_flag = GPIOF_OUT_INIT_HIGH; |
| 137 | |
| 138 | config->ena_gpio = tps_pdata->gpio; |
| 139 | config->ena_gpio_flags = gpio_flag; |
| 140 | } |
| 141 | } |
| 142 | |
Laxman Dewangan | 6c7a7a0 | 2013-01-29 14:35:16 +0530 | [diff] [blame] | 143 | #ifdef CONFIG_OF |
| 144 | static struct of_regulator_match tps65090_matches[] = { |
| 145 | { .name = "dcdc1", }, |
| 146 | { .name = "dcdc2", }, |
| 147 | { .name = "dcdc3", }, |
| 148 | { .name = "fet1", }, |
| 149 | { .name = "fet2", }, |
| 150 | { .name = "fet3", }, |
| 151 | { .name = "fet4", }, |
| 152 | { .name = "fet5", }, |
| 153 | { .name = "fet6", }, |
| 154 | { .name = "fet7", }, |
| 155 | { .name = "ldo1", }, |
| 156 | { .name = "ldo2", }, |
| 157 | }; |
| 158 | |
| 159 | static struct tps65090_platform_data *tps65090_parse_dt_reg_data( |
| 160 | struct platform_device *pdev, |
| 161 | struct of_regulator_match **tps65090_reg_matches) |
| 162 | { |
| 163 | struct tps65090_platform_data *tps65090_pdata; |
| 164 | struct device_node *np = pdev->dev.parent->of_node; |
| 165 | struct device_node *regulators; |
| 166 | int idx = 0, ret; |
| 167 | struct tps65090_regulator_plat_data *reg_pdata; |
| 168 | |
| 169 | tps65090_pdata = devm_kzalloc(&pdev->dev, sizeof(*tps65090_pdata), |
| 170 | GFP_KERNEL); |
Sachin Kamat | 0ad91c6 | 2014-02-20 14:23:15 +0530 | [diff] [blame] | 171 | if (!tps65090_pdata) |
Laxman Dewangan | 6c7a7a0 | 2013-01-29 14:35:16 +0530 | [diff] [blame] | 172 | return ERR_PTR(-ENOMEM); |
Laxman Dewangan | 6c7a7a0 | 2013-01-29 14:35:16 +0530 | [diff] [blame] | 173 | |
| 174 | reg_pdata = devm_kzalloc(&pdev->dev, TPS65090_REGULATOR_MAX * |
| 175 | sizeof(*reg_pdata), GFP_KERNEL); |
Sachin Kamat | 0ad91c6 | 2014-02-20 14:23:15 +0530 | [diff] [blame] | 176 | if (!reg_pdata) |
Laxman Dewangan | 6c7a7a0 | 2013-01-29 14:35:16 +0530 | [diff] [blame] | 177 | return ERR_PTR(-ENOMEM); |
Laxman Dewangan | 6c7a7a0 | 2013-01-29 14:35:16 +0530 | [diff] [blame] | 178 | |
Laxman Dewangan | 4c850ea | 2013-10-08 19:31:02 +0530 | [diff] [blame] | 179 | regulators = of_get_child_by_name(np, "regulators"); |
Laxman Dewangan | 6c7a7a0 | 2013-01-29 14:35:16 +0530 | [diff] [blame] | 180 | if (!regulators) { |
| 181 | dev_err(&pdev->dev, "regulator node not found\n"); |
| 182 | return ERR_PTR(-ENODEV); |
| 183 | } |
| 184 | |
Axel Lin | 09a228e | 2013-01-30 20:28:20 +0800 | [diff] [blame] | 185 | ret = of_regulator_match(&pdev->dev, regulators, tps65090_matches, |
Laxman Dewangan | 6c7a7a0 | 2013-01-29 14:35:16 +0530 | [diff] [blame] | 186 | ARRAY_SIZE(tps65090_matches)); |
Sachin Kamat | 026cdfe | 2014-02-17 14:33:37 +0530 | [diff] [blame] | 187 | of_node_put(regulators); |
Laxman Dewangan | 6c7a7a0 | 2013-01-29 14:35:16 +0530 | [diff] [blame] | 188 | if (ret < 0) { |
| 189 | dev_err(&pdev->dev, |
| 190 | "Error parsing regulator init data: %d\n", ret); |
| 191 | return ERR_PTR(ret); |
| 192 | } |
| 193 | |
| 194 | *tps65090_reg_matches = tps65090_matches; |
| 195 | for (idx = 0; idx < ARRAY_SIZE(tps65090_matches); idx++) { |
| 196 | struct regulator_init_data *ri_data; |
| 197 | struct tps65090_regulator_plat_data *rpdata; |
| 198 | |
| 199 | rpdata = ®_pdata[idx]; |
| 200 | ri_data = tps65090_matches[idx].init_data; |
| 201 | if (!ri_data || !tps65090_matches[idx].of_node) |
| 202 | continue; |
| 203 | |
| 204 | rpdata->reg_init_data = ri_data; |
| 205 | rpdata->enable_ext_control = of_property_read_bool( |
| 206 | tps65090_matches[idx].of_node, |
| 207 | "ti,enable-ext-control"); |
| 208 | if (rpdata->enable_ext_control) |
| 209 | rpdata->gpio = of_get_named_gpio(np, |
| 210 | "dcdc-ext-control-gpios", 0); |
| 211 | |
| 212 | tps65090_pdata->reg_pdata[idx] = rpdata; |
| 213 | } |
| 214 | return tps65090_pdata; |
| 215 | } |
| 216 | #else |
| 217 | static inline struct tps65090_platform_data *tps65090_parse_dt_reg_data( |
| 218 | struct platform_device *pdev, |
| 219 | struct of_regulator_match **tps65090_reg_matches) |
| 220 | { |
| 221 | *tps65090_reg_matches = NULL; |
| 222 | return NULL; |
| 223 | } |
| 224 | #endif |
| 225 | |
Bill Pemberton | a502357 | 2012-11-19 13:22:22 -0500 | [diff] [blame] | 226 | static int tps65090_regulator_probe(struct platform_device *pdev) |
Venu Byravarasu | 452534e | 2012-03-22 18:34:09 +0530 | [diff] [blame] | 227 | { |
Axel Lin | 06c4998 | 2012-04-17 17:08:56 +0800 | [diff] [blame] | 228 | struct tps65090 *tps65090_mfd = dev_get_drvdata(pdev->dev.parent); |
Venu Byravarasu | 452534e | 2012-03-22 18:34:09 +0530 | [diff] [blame] | 229 | struct tps65090_regulator *ri = NULL; |
Mark Brown | c172708 | 2012-04-04 00:50:22 +0100 | [diff] [blame] | 230 | struct regulator_config config = { }; |
Venu Byravarasu | 452534e | 2012-03-22 18:34:09 +0530 | [diff] [blame] | 231 | struct regulator_dev *rdev; |
Laxman Dewangan | 24282a1 | 2012-10-09 15:18:59 +0530 | [diff] [blame] | 232 | struct tps65090_regulator_plat_data *tps_pdata; |
| 233 | struct tps65090_regulator *pmic; |
| 234 | struct tps65090_platform_data *tps65090_pdata; |
Laxman Dewangan | 6c7a7a0 | 2013-01-29 14:35:16 +0530 | [diff] [blame] | 235 | struct of_regulator_match *tps65090_reg_matches = NULL; |
Laxman Dewangan | 24282a1 | 2012-10-09 15:18:59 +0530 | [diff] [blame] | 236 | int num; |
| 237 | int ret; |
Venu Byravarasu | 452534e | 2012-03-22 18:34:09 +0530 | [diff] [blame] | 238 | |
Laxman Dewangan | 24282a1 | 2012-10-09 15:18:59 +0530 | [diff] [blame] | 239 | dev_dbg(&pdev->dev, "Probing regulator\n"); |
Venu Byravarasu | 452534e | 2012-03-22 18:34:09 +0530 | [diff] [blame] | 240 | |
Laxman Dewangan | 24282a1 | 2012-10-09 15:18:59 +0530 | [diff] [blame] | 241 | tps65090_pdata = dev_get_platdata(pdev->dev.parent); |
Laxman Dewangan | 6c7a7a0 | 2013-01-29 14:35:16 +0530 | [diff] [blame] | 242 | if (!tps65090_pdata && tps65090_mfd->dev->of_node) |
| 243 | tps65090_pdata = tps65090_parse_dt_reg_data(pdev, |
| 244 | &tps65090_reg_matches); |
| 245 | if (IS_ERR_OR_NULL(tps65090_pdata)) { |
Laxman Dewangan | 24282a1 | 2012-10-09 15:18:59 +0530 | [diff] [blame] | 246 | dev_err(&pdev->dev, "Platform data missing\n"); |
Laxman Dewangan | 6c7a7a0 | 2013-01-29 14:35:16 +0530 | [diff] [blame] | 247 | return tps65090_pdata ? PTR_ERR(tps65090_pdata) : -EINVAL; |
Venu Byravarasu | 452534e | 2012-03-22 18:34:09 +0530 | [diff] [blame] | 248 | } |
Venu Byravarasu | 452534e | 2012-03-22 18:34:09 +0530 | [diff] [blame] | 249 | |
Laxman Dewangan | 8620ca9 | 2012-10-09 15:19:00 +0530 | [diff] [blame] | 250 | pmic = devm_kzalloc(&pdev->dev, TPS65090_REGULATOR_MAX * sizeof(*pmic), |
Laxman Dewangan | 24282a1 | 2012-10-09 15:18:59 +0530 | [diff] [blame] | 251 | GFP_KERNEL); |
Sachin Kamat | 0ad91c6 | 2014-02-20 14:23:15 +0530 | [diff] [blame] | 252 | if (!pmic) |
Laxman Dewangan | 24282a1 | 2012-10-09 15:18:59 +0530 | [diff] [blame] | 253 | return -ENOMEM; |
Venu Byravarasu | 452534e | 2012-03-22 18:34:09 +0530 | [diff] [blame] | 254 | |
Laxman Dewangan | 8620ca9 | 2012-10-09 15:19:00 +0530 | [diff] [blame] | 255 | for (num = 0; num < TPS65090_REGULATOR_MAX; num++) { |
Laxman Dewangan | 24282a1 | 2012-10-09 15:18:59 +0530 | [diff] [blame] | 256 | tps_pdata = tps65090_pdata->reg_pdata[num]; |
| 257 | |
| 258 | ri = &pmic[num]; |
| 259 | ri->dev = &pdev->dev; |
| 260 | ri->desc = &tps65090_regulator_desc[num]; |
| 261 | |
| 262 | /* |
| 263 | * TPS5090 DCDC support the control from external digital input. |
Laxman Dewangan | f329b17 | 2012-10-09 15:19:02 +0530 | [diff] [blame] | 264 | * Configure it as per platform data. |
Laxman Dewangan | 24282a1 | 2012-10-09 15:18:59 +0530 | [diff] [blame] | 265 | */ |
| 266 | if (tps_pdata && is_dcdc(num) && tps_pdata->reg_init_data) { |
Laxman Dewangan | f329b17 | 2012-10-09 15:19:02 +0530 | [diff] [blame] | 267 | if (tps_pdata->enable_ext_control) { |
| 268 | tps65090_configure_regulator_config( |
| 269 | tps_pdata, &config); |
| 270 | ri->desc->ops = &tps65090_ext_control_ops; |
| 271 | } else { |
| 272 | ret = tps65090_regulator_disable_ext_control( |
Laxman Dewangan | 24282a1 | 2012-10-09 15:18:59 +0530 | [diff] [blame] | 273 | ri, tps_pdata); |
Laxman Dewangan | f329b17 | 2012-10-09 15:19:02 +0530 | [diff] [blame] | 274 | if (ret < 0) { |
| 275 | dev_err(&pdev->dev, |
Laxman Dewangan | 24282a1 | 2012-10-09 15:18:59 +0530 | [diff] [blame] | 276 | "failed disable ext control\n"); |
Sachin Kamat | 9738efa | 2013-09-04 17:17:48 +0530 | [diff] [blame] | 277 | return ret; |
Laxman Dewangan | f329b17 | 2012-10-09 15:19:02 +0530 | [diff] [blame] | 278 | } |
Laxman Dewangan | 24282a1 | 2012-10-09 15:18:59 +0530 | [diff] [blame] | 279 | } |
| 280 | } |
Laxman Dewangan | f329b17 | 2012-10-09 15:19:02 +0530 | [diff] [blame] | 281 | |
Laxman Dewangan | 6c7a7a0 | 2013-01-29 14:35:16 +0530 | [diff] [blame] | 282 | config.dev = pdev->dev.parent; |
Laxman Dewangan | 24282a1 | 2012-10-09 15:18:59 +0530 | [diff] [blame] | 283 | config.driver_data = ri; |
| 284 | config.regmap = tps65090_mfd->rmap; |
| 285 | if (tps_pdata) |
| 286 | config.init_data = tps_pdata->reg_init_data; |
| 287 | else |
| 288 | config.init_data = NULL; |
Laxman Dewangan | 6c7a7a0 | 2013-01-29 14:35:16 +0530 | [diff] [blame] | 289 | if (tps65090_reg_matches) |
| 290 | config.of_node = tps65090_reg_matches[num].of_node; |
| 291 | else |
| 292 | config.of_node = NULL; |
Laxman Dewangan | 24282a1 | 2012-10-09 15:18:59 +0530 | [diff] [blame] | 293 | |
Sachin Kamat | 9738efa | 2013-09-04 17:17:48 +0530 | [diff] [blame] | 294 | rdev = devm_regulator_register(&pdev->dev, ri->desc, &config); |
Laxman Dewangan | 24282a1 | 2012-10-09 15:18:59 +0530 | [diff] [blame] | 295 | if (IS_ERR(rdev)) { |
| 296 | dev_err(&pdev->dev, "failed to register regulator %s\n", |
| 297 | ri->desc->name); |
Sachin Kamat | 9738efa | 2013-09-04 17:17:48 +0530 | [diff] [blame] | 298 | return PTR_ERR(rdev); |
Laxman Dewangan | 24282a1 | 2012-10-09 15:18:59 +0530 | [diff] [blame] | 299 | } |
| 300 | ri->rdev = rdev; |
Laxman Dewangan | f329b17 | 2012-10-09 15:19:02 +0530 | [diff] [blame] | 301 | |
| 302 | /* Enable external control if it is require */ |
| 303 | if (tps_pdata && is_dcdc(num) && tps_pdata->reg_init_data && |
| 304 | tps_pdata->enable_ext_control) { |
| 305 | ret = tps65090_config_ext_control(ri, true); |
Sachin Kamat | 9738efa | 2013-09-04 17:17:48 +0530 | [diff] [blame] | 306 | if (ret < 0) |
| 307 | return ret; |
Laxman Dewangan | f329b17 | 2012-10-09 15:19:02 +0530 | [diff] [blame] | 308 | } |
Laxman Dewangan | 24282a1 | 2012-10-09 15:18:59 +0530 | [diff] [blame] | 309 | } |
| 310 | |
| 311 | platform_set_drvdata(pdev, pmic); |
Venu Byravarasu | 452534e | 2012-03-22 18:34:09 +0530 | [diff] [blame] | 312 | return 0; |
Venu Byravarasu | 452534e | 2012-03-22 18:34:09 +0530 | [diff] [blame] | 313 | } |
| 314 | |
| 315 | static struct platform_driver tps65090_regulator_driver = { |
| 316 | .driver = { |
Laxman Dewangan | 8620ca9 | 2012-10-09 15:19:00 +0530 | [diff] [blame] | 317 | .name = "tps65090-pmic", |
Venu Byravarasu | 452534e | 2012-03-22 18:34:09 +0530 | [diff] [blame] | 318 | .owner = THIS_MODULE, |
| 319 | }, |
| 320 | .probe = tps65090_regulator_probe, |
Venu Byravarasu | 452534e | 2012-03-22 18:34:09 +0530 | [diff] [blame] | 321 | }; |
| 322 | |
| 323 | static int __init tps65090_regulator_init(void) |
| 324 | { |
| 325 | return platform_driver_register(&tps65090_regulator_driver); |
| 326 | } |
| 327 | subsys_initcall(tps65090_regulator_init); |
| 328 | |
| 329 | static void __exit tps65090_regulator_exit(void) |
| 330 | { |
| 331 | platform_driver_unregister(&tps65090_regulator_driver); |
| 332 | } |
| 333 | module_exit(tps65090_regulator_exit); |
| 334 | |
| 335 | MODULE_DESCRIPTION("tps65090 regulator driver"); |
| 336 | MODULE_AUTHOR("Venu Byravarasu <vbyravarasu@nvidia.com>"); |
| 337 | MODULE_LICENSE("GPL v2"); |
Axel Lin | d95420b | 2012-11-23 23:47:16 +0800 | [diff] [blame] | 338 | MODULE_ALIAS("platform:tps65090-pmic"); |