Anuj Aggarwal | 3fa5b8e | 2009-08-21 00:39:39 +0530 | [diff] [blame] | 1 | /* |
| 2 | * tps6507x-regulator.c |
| 3 | * |
| 4 | * Regulator driver for TPS65073 PMIC |
| 5 | * |
| 6 | * Copyright (C) 2009 Texas Instrument Incorporated - http://www.ti.com/ |
| 7 | * |
| 8 | * This program is free software; you can redistribute it and/or |
| 9 | * modify it under the terms of the GNU General Public License as |
| 10 | * published by the Free Software Foundation version 2. |
| 11 | * |
| 12 | * This program is distributed "as is" WITHOUT ANY WARRANTY of any kind, |
| 13 | * whether express or implied; 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 | |
| 18 | #include <linux/kernel.h> |
| 19 | #include <linux/module.h> |
| 20 | #include <linux/init.h> |
| 21 | #include <linux/err.h> |
| 22 | #include <linux/platform_device.h> |
| 23 | #include <linux/regulator/driver.h> |
| 24 | #include <linux/regulator/machine.h> |
Anuj Aggarwal | 3fa5b8e | 2009-08-21 00:39:39 +0530 | [diff] [blame] | 25 | #include <linux/delay.h> |
Tejun Heo | 5a0e3ad | 2010-03-24 17:04:11 +0900 | [diff] [blame] | 26 | #include <linux/slab.h> |
Todd Fischer | d183fcc | 2010-04-05 20:23:56 -0600 | [diff] [blame] | 27 | #include <linux/mfd/tps6507x.h> |
Anuj Aggarwal | 3fa5b8e | 2009-08-21 00:39:39 +0530 | [diff] [blame] | 28 | |
| 29 | /* DCDC's */ |
| 30 | #define TPS6507X_DCDC_1 0 |
| 31 | #define TPS6507X_DCDC_2 1 |
| 32 | #define TPS6507X_DCDC_3 2 |
| 33 | /* LDOs */ |
| 34 | #define TPS6507X_LDO_1 3 |
| 35 | #define TPS6507X_LDO_2 4 |
| 36 | |
| 37 | #define TPS6507X_MAX_REG_ID TPS6507X_LDO_2 |
| 38 | |
| 39 | /* Number of step-down converters available */ |
| 40 | #define TPS6507X_NUM_DCDC 3 |
| 41 | /* Number of LDO voltage regulators available */ |
| 42 | #define TPS6507X_NUM_LDO 2 |
| 43 | /* Number of total regulators available */ |
| 44 | #define TPS6507X_NUM_REGULATOR (TPS6507X_NUM_DCDC + TPS6507X_NUM_LDO) |
| 45 | |
| 46 | /* Supported voltage values for regulators (in milliVolts) */ |
| 47 | static const u16 VDCDCx_VSEL_table[] = { |
| 48 | 725, 750, 775, 800, |
| 49 | 825, 850, 875, 900, |
| 50 | 925, 950, 975, 1000, |
| 51 | 1025, 1050, 1075, 1100, |
| 52 | 1125, 1150, 1175, 1200, |
| 53 | 1225, 1250, 1275, 1300, |
| 54 | 1325, 1350, 1375, 1400, |
| 55 | 1425, 1450, 1475, 1500, |
| 56 | 1550, 1600, 1650, 1700, |
| 57 | 1750, 1800, 1850, 1900, |
| 58 | 1950, 2000, 2050, 2100, |
| 59 | 2150, 2200, 2250, 2300, |
| 60 | 2350, 2400, 2450, 2500, |
| 61 | 2550, 2600, 2650, 2700, |
| 62 | 2750, 2800, 2850, 2900, |
| 63 | 3000, 3100, 3200, 3300, |
| 64 | }; |
| 65 | |
| 66 | static const u16 LDO1_VSEL_table[] = { |
| 67 | 1000, 1100, 1200, 1250, |
| 68 | 1300, 1350, 1400, 1500, |
| 69 | 1600, 1800, 2500, 2750, |
| 70 | 2800, 3000, 3100, 3300, |
| 71 | }; |
| 72 | |
| 73 | static const u16 LDO2_VSEL_table[] = { |
| 74 | 725, 750, 775, 800, |
| 75 | 825, 850, 875, 900, |
| 76 | 925, 950, 975, 1000, |
| 77 | 1025, 1050, 1075, 1100, |
| 78 | 1125, 1150, 1175, 1200, |
| 79 | 1225, 1250, 1275, 1300, |
| 80 | 1325, 1350, 1375, 1400, |
| 81 | 1425, 1450, 1475, 1500, |
| 82 | 1550, 1600, 1650, 1700, |
| 83 | 1750, 1800, 1850, 1900, |
| 84 | 1950, 2000, 2050, 2100, |
| 85 | 2150, 2200, 2250, 2300, |
| 86 | 2350, 2400, 2450, 2500, |
| 87 | 2550, 2600, 2650, 2700, |
| 88 | 2750, 2800, 2850, 2900, |
| 89 | 3000, 3100, 3200, 3300, |
| 90 | }; |
| 91 | |
| 92 | static unsigned int num_voltages[] = {ARRAY_SIZE(VDCDCx_VSEL_table), |
| 93 | ARRAY_SIZE(VDCDCx_VSEL_table), |
| 94 | ARRAY_SIZE(VDCDCx_VSEL_table), |
| 95 | ARRAY_SIZE(LDO1_VSEL_table), |
| 96 | ARRAY_SIZE(LDO2_VSEL_table)}; |
| 97 | |
| 98 | struct tps_info { |
| 99 | const char *name; |
| 100 | unsigned min_uV; |
| 101 | unsigned max_uV; |
| 102 | u8 table_len; |
| 103 | const u16 *table; |
| 104 | }; |
| 105 | |
Todd Fischer | 31dd6a2 | 2010-04-08 09:04:55 +0200 | [diff] [blame] | 106 | static const struct tps_info tps6507x_pmic_regs[] = { |
| 107 | { |
| 108 | .name = "VDCDC1", |
| 109 | .min_uV = 725000, |
| 110 | .max_uV = 3300000, |
| 111 | .table_len = ARRAY_SIZE(VDCDCx_VSEL_table), |
| 112 | .table = VDCDCx_VSEL_table, |
| 113 | }, |
| 114 | { |
| 115 | .name = "VDCDC2", |
| 116 | .min_uV = 725000, |
| 117 | .max_uV = 3300000, |
| 118 | .table_len = ARRAY_SIZE(VDCDCx_VSEL_table), |
| 119 | .table = VDCDCx_VSEL_table, |
| 120 | }, |
| 121 | { |
| 122 | .name = "VDCDC3", |
| 123 | .min_uV = 725000, |
| 124 | .max_uV = 3300000, |
| 125 | .table_len = ARRAY_SIZE(VDCDCx_VSEL_table), |
| 126 | .table = VDCDCx_VSEL_table, |
| 127 | }, |
| 128 | { |
| 129 | .name = "LDO1", |
| 130 | .min_uV = 1000000, |
| 131 | .max_uV = 3300000, |
| 132 | .table_len = ARRAY_SIZE(LDO1_VSEL_table), |
| 133 | .table = LDO1_VSEL_table, |
| 134 | }, |
| 135 | { |
| 136 | .name = "LDO2", |
| 137 | .min_uV = 725000, |
| 138 | .max_uV = 3300000, |
| 139 | .table_len = ARRAY_SIZE(LDO2_VSEL_table), |
| 140 | .table = LDO2_VSEL_table, |
| 141 | }, |
| 142 | }; |
| 143 | |
Todd Fischer | 4ce5ba5 | 2010-04-05 20:23:58 -0600 | [diff] [blame] | 144 | struct tps6507x_pmic { |
Anuj Aggarwal | 3fa5b8e | 2009-08-21 00:39:39 +0530 | [diff] [blame] | 145 | struct regulator_desc desc[TPS6507X_NUM_REGULATOR]; |
Todd Fischer | 31dd6a2 | 2010-04-08 09:04:55 +0200 | [diff] [blame] | 146 | struct tps6507x_dev *mfd; |
Anuj Aggarwal | 3fa5b8e | 2009-08-21 00:39:39 +0530 | [diff] [blame] | 147 | struct regulator_dev *rdev[TPS6507X_NUM_REGULATOR]; |
| 148 | const struct tps_info *info[TPS6507X_NUM_REGULATOR]; |
| 149 | struct mutex io_lock; |
| 150 | }; |
Todd Fischer | 4ce5ba5 | 2010-04-05 20:23:58 -0600 | [diff] [blame] | 151 | static inline int tps6507x_pmic_read(struct tps6507x_pmic *tps, u8 reg) |
Anuj Aggarwal | 3fa5b8e | 2009-08-21 00:39:39 +0530 | [diff] [blame] | 152 | { |
Todd Fischer | 31dd6a2 | 2010-04-08 09:04:55 +0200 | [diff] [blame] | 153 | u8 val; |
| 154 | int err; |
| 155 | |
| 156 | err = tps->mfd->read_dev(tps->mfd, reg, 1, &val); |
| 157 | |
| 158 | if (err) |
| 159 | return err; |
| 160 | |
| 161 | return val; |
Anuj Aggarwal | 3fa5b8e | 2009-08-21 00:39:39 +0530 | [diff] [blame] | 162 | } |
| 163 | |
Todd Fischer | 4ce5ba5 | 2010-04-05 20:23:58 -0600 | [diff] [blame] | 164 | static inline int tps6507x_pmic_write(struct tps6507x_pmic *tps, u8 reg, u8 val) |
Anuj Aggarwal | 3fa5b8e | 2009-08-21 00:39:39 +0530 | [diff] [blame] | 165 | { |
Todd Fischer | 31dd6a2 | 2010-04-08 09:04:55 +0200 | [diff] [blame] | 166 | return tps->mfd->write_dev(tps->mfd, reg, 1, &val); |
Anuj Aggarwal | 3fa5b8e | 2009-08-21 00:39:39 +0530 | [diff] [blame] | 167 | } |
| 168 | |
Todd Fischer | 4ce5ba5 | 2010-04-05 20:23:58 -0600 | [diff] [blame] | 169 | static int tps6507x_pmic_set_bits(struct tps6507x_pmic *tps, u8 reg, u8 mask) |
Anuj Aggarwal | 3fa5b8e | 2009-08-21 00:39:39 +0530 | [diff] [blame] | 170 | { |
| 171 | int err, data; |
| 172 | |
| 173 | mutex_lock(&tps->io_lock); |
| 174 | |
Todd Fischer | 4ce5ba5 | 2010-04-05 20:23:58 -0600 | [diff] [blame] | 175 | data = tps6507x_pmic_read(tps, reg); |
Anuj Aggarwal | 3fa5b8e | 2009-08-21 00:39:39 +0530 | [diff] [blame] | 176 | if (data < 0) { |
Todd Fischer | 31dd6a2 | 2010-04-08 09:04:55 +0200 | [diff] [blame] | 177 | dev_err(tps->mfd->dev, "Read from reg 0x%x failed\n", reg); |
Anuj Aggarwal | 3fa5b8e | 2009-08-21 00:39:39 +0530 | [diff] [blame] | 178 | err = data; |
| 179 | goto out; |
| 180 | } |
| 181 | |
| 182 | data |= mask; |
Todd Fischer | 4ce5ba5 | 2010-04-05 20:23:58 -0600 | [diff] [blame] | 183 | err = tps6507x_pmic_write(tps, reg, data); |
Anuj Aggarwal | 3fa5b8e | 2009-08-21 00:39:39 +0530 | [diff] [blame] | 184 | if (err) |
Todd Fischer | 31dd6a2 | 2010-04-08 09:04:55 +0200 | [diff] [blame] | 185 | dev_err(tps->mfd->dev, "Write for reg 0x%x failed\n", reg); |
Anuj Aggarwal | 3fa5b8e | 2009-08-21 00:39:39 +0530 | [diff] [blame] | 186 | |
| 187 | out: |
| 188 | mutex_unlock(&tps->io_lock); |
| 189 | return err; |
| 190 | } |
| 191 | |
Todd Fischer | 4ce5ba5 | 2010-04-05 20:23:58 -0600 | [diff] [blame] | 192 | static int tps6507x_pmic_clear_bits(struct tps6507x_pmic *tps, u8 reg, u8 mask) |
Anuj Aggarwal | 3fa5b8e | 2009-08-21 00:39:39 +0530 | [diff] [blame] | 193 | { |
| 194 | int err, data; |
| 195 | |
| 196 | mutex_lock(&tps->io_lock); |
| 197 | |
Todd Fischer | 4ce5ba5 | 2010-04-05 20:23:58 -0600 | [diff] [blame] | 198 | data = tps6507x_pmic_read(tps, reg); |
Anuj Aggarwal | 3fa5b8e | 2009-08-21 00:39:39 +0530 | [diff] [blame] | 199 | if (data < 0) { |
Todd Fischer | 31dd6a2 | 2010-04-08 09:04:55 +0200 | [diff] [blame] | 200 | dev_err(tps->mfd->dev, "Read from reg 0x%x failed\n", reg); |
Anuj Aggarwal | 3fa5b8e | 2009-08-21 00:39:39 +0530 | [diff] [blame] | 201 | err = data; |
| 202 | goto out; |
| 203 | } |
| 204 | |
| 205 | data &= ~mask; |
Todd Fischer | 4ce5ba5 | 2010-04-05 20:23:58 -0600 | [diff] [blame] | 206 | err = tps6507x_pmic_write(tps, reg, data); |
Anuj Aggarwal | 3fa5b8e | 2009-08-21 00:39:39 +0530 | [diff] [blame] | 207 | if (err) |
Todd Fischer | 31dd6a2 | 2010-04-08 09:04:55 +0200 | [diff] [blame] | 208 | dev_err(tps->mfd->dev, "Write for reg 0x%x failed\n", reg); |
Anuj Aggarwal | 3fa5b8e | 2009-08-21 00:39:39 +0530 | [diff] [blame] | 209 | |
| 210 | out: |
| 211 | mutex_unlock(&tps->io_lock); |
| 212 | return err; |
| 213 | } |
| 214 | |
Todd Fischer | 4ce5ba5 | 2010-04-05 20:23:58 -0600 | [diff] [blame] | 215 | static int tps6507x_pmic_reg_read(struct tps6507x_pmic *tps, u8 reg) |
Anuj Aggarwal | 3fa5b8e | 2009-08-21 00:39:39 +0530 | [diff] [blame] | 216 | { |
| 217 | int data; |
| 218 | |
| 219 | mutex_lock(&tps->io_lock); |
| 220 | |
Todd Fischer | 4ce5ba5 | 2010-04-05 20:23:58 -0600 | [diff] [blame] | 221 | data = tps6507x_pmic_read(tps, reg); |
Anuj Aggarwal | 3fa5b8e | 2009-08-21 00:39:39 +0530 | [diff] [blame] | 222 | if (data < 0) |
Todd Fischer | 31dd6a2 | 2010-04-08 09:04:55 +0200 | [diff] [blame] | 223 | dev_err(tps->mfd->dev, "Read from reg 0x%x failed\n", reg); |
Anuj Aggarwal | 3fa5b8e | 2009-08-21 00:39:39 +0530 | [diff] [blame] | 224 | |
| 225 | mutex_unlock(&tps->io_lock); |
| 226 | return data; |
| 227 | } |
| 228 | |
Todd Fischer | 4ce5ba5 | 2010-04-05 20:23:58 -0600 | [diff] [blame] | 229 | static int tps6507x_pmic_reg_write(struct tps6507x_pmic *tps, u8 reg, u8 val) |
Anuj Aggarwal | 3fa5b8e | 2009-08-21 00:39:39 +0530 | [diff] [blame] | 230 | { |
| 231 | int err; |
| 232 | |
| 233 | mutex_lock(&tps->io_lock); |
| 234 | |
Todd Fischer | 4ce5ba5 | 2010-04-05 20:23:58 -0600 | [diff] [blame] | 235 | err = tps6507x_pmic_write(tps, reg, val); |
Anuj Aggarwal | 3fa5b8e | 2009-08-21 00:39:39 +0530 | [diff] [blame] | 236 | if (err < 0) |
Todd Fischer | 31dd6a2 | 2010-04-08 09:04:55 +0200 | [diff] [blame] | 237 | dev_err(tps->mfd->dev, "Write for reg 0x%x failed\n", reg); |
Anuj Aggarwal | 3fa5b8e | 2009-08-21 00:39:39 +0530 | [diff] [blame] | 238 | |
| 239 | mutex_unlock(&tps->io_lock); |
| 240 | return err; |
| 241 | } |
| 242 | |
Todd Fischer | 4ce5ba5 | 2010-04-05 20:23:58 -0600 | [diff] [blame] | 243 | static int tps6507x_pmic_dcdc_is_enabled(struct regulator_dev *dev) |
Anuj Aggarwal | 3fa5b8e | 2009-08-21 00:39:39 +0530 | [diff] [blame] | 244 | { |
Todd Fischer | 4ce5ba5 | 2010-04-05 20:23:58 -0600 | [diff] [blame] | 245 | struct tps6507x_pmic *tps = rdev_get_drvdata(dev); |
Anuj Aggarwal | 3fa5b8e | 2009-08-21 00:39:39 +0530 | [diff] [blame] | 246 | int data, dcdc = rdev_get_id(dev); |
| 247 | u8 shift; |
| 248 | |
| 249 | if (dcdc < TPS6507X_DCDC_1 || dcdc > TPS6507X_DCDC_3) |
| 250 | return -EINVAL; |
| 251 | |
| 252 | shift = TPS6507X_MAX_REG_ID - dcdc; |
Todd Fischer | 4ce5ba5 | 2010-04-05 20:23:58 -0600 | [diff] [blame] | 253 | data = tps6507x_pmic_reg_read(tps, TPS6507X_REG_CON_CTRL1); |
Anuj Aggarwal | 3fa5b8e | 2009-08-21 00:39:39 +0530 | [diff] [blame] | 254 | |
| 255 | if (data < 0) |
| 256 | return data; |
| 257 | else |
| 258 | return (data & 1<<shift) ? 1 : 0; |
| 259 | } |
| 260 | |
Todd Fischer | 4ce5ba5 | 2010-04-05 20:23:58 -0600 | [diff] [blame] | 261 | static int tps6507x_pmic_ldo_is_enabled(struct regulator_dev *dev) |
Anuj Aggarwal | 3fa5b8e | 2009-08-21 00:39:39 +0530 | [diff] [blame] | 262 | { |
Todd Fischer | 4ce5ba5 | 2010-04-05 20:23:58 -0600 | [diff] [blame] | 263 | struct tps6507x_pmic *tps = rdev_get_drvdata(dev); |
Anuj Aggarwal | 3fa5b8e | 2009-08-21 00:39:39 +0530 | [diff] [blame] | 264 | int data, ldo = rdev_get_id(dev); |
| 265 | u8 shift; |
| 266 | |
| 267 | if (ldo < TPS6507X_LDO_1 || ldo > TPS6507X_LDO_2) |
| 268 | return -EINVAL; |
| 269 | |
| 270 | shift = TPS6507X_MAX_REG_ID - ldo; |
Todd Fischer | 4ce5ba5 | 2010-04-05 20:23:58 -0600 | [diff] [blame] | 271 | data = tps6507x_pmic_reg_read(tps, TPS6507X_REG_CON_CTRL1); |
Anuj Aggarwal | 3fa5b8e | 2009-08-21 00:39:39 +0530 | [diff] [blame] | 272 | |
| 273 | if (data < 0) |
| 274 | return data; |
| 275 | else |
| 276 | return (data & 1<<shift) ? 1 : 0; |
| 277 | } |
| 278 | |
Todd Fischer | 4ce5ba5 | 2010-04-05 20:23:58 -0600 | [diff] [blame] | 279 | static int tps6507x_pmic_dcdc_enable(struct regulator_dev *dev) |
Anuj Aggarwal | 3fa5b8e | 2009-08-21 00:39:39 +0530 | [diff] [blame] | 280 | { |
Todd Fischer | 4ce5ba5 | 2010-04-05 20:23:58 -0600 | [diff] [blame] | 281 | struct tps6507x_pmic *tps = rdev_get_drvdata(dev); |
Anuj Aggarwal | 3fa5b8e | 2009-08-21 00:39:39 +0530 | [diff] [blame] | 282 | int dcdc = rdev_get_id(dev); |
| 283 | u8 shift; |
| 284 | |
| 285 | if (dcdc < TPS6507X_DCDC_1 || dcdc > TPS6507X_DCDC_3) |
| 286 | return -EINVAL; |
| 287 | |
| 288 | shift = TPS6507X_MAX_REG_ID - dcdc; |
Todd Fischer | 4ce5ba5 | 2010-04-05 20:23:58 -0600 | [diff] [blame] | 289 | return tps6507x_pmic_set_bits(tps, TPS6507X_REG_CON_CTRL1, 1 << shift); |
Anuj Aggarwal | 3fa5b8e | 2009-08-21 00:39:39 +0530 | [diff] [blame] | 290 | } |
| 291 | |
Todd Fischer | 4ce5ba5 | 2010-04-05 20:23:58 -0600 | [diff] [blame] | 292 | static int tps6507x_pmic_dcdc_disable(struct regulator_dev *dev) |
Anuj Aggarwal | 3fa5b8e | 2009-08-21 00:39:39 +0530 | [diff] [blame] | 293 | { |
Todd Fischer | 4ce5ba5 | 2010-04-05 20:23:58 -0600 | [diff] [blame] | 294 | struct tps6507x_pmic *tps = rdev_get_drvdata(dev); |
Anuj Aggarwal | 3fa5b8e | 2009-08-21 00:39:39 +0530 | [diff] [blame] | 295 | int dcdc = rdev_get_id(dev); |
| 296 | u8 shift; |
| 297 | |
| 298 | if (dcdc < TPS6507X_DCDC_1 || dcdc > TPS6507X_DCDC_3) |
| 299 | return -EINVAL; |
| 300 | |
| 301 | shift = TPS6507X_MAX_REG_ID - dcdc; |
Todd Fischer | 4ce5ba5 | 2010-04-05 20:23:58 -0600 | [diff] [blame] | 302 | return tps6507x_pmic_clear_bits(tps, TPS6507X_REG_CON_CTRL1, |
| 303 | 1 << shift); |
Anuj Aggarwal | 3fa5b8e | 2009-08-21 00:39:39 +0530 | [diff] [blame] | 304 | } |
| 305 | |
Todd Fischer | 4ce5ba5 | 2010-04-05 20:23:58 -0600 | [diff] [blame] | 306 | static int tps6507x_pmic_ldo_enable(struct regulator_dev *dev) |
Anuj Aggarwal | 3fa5b8e | 2009-08-21 00:39:39 +0530 | [diff] [blame] | 307 | { |
Todd Fischer | 4ce5ba5 | 2010-04-05 20:23:58 -0600 | [diff] [blame] | 308 | struct tps6507x_pmic *tps = rdev_get_drvdata(dev); |
Anuj Aggarwal | 3fa5b8e | 2009-08-21 00:39:39 +0530 | [diff] [blame] | 309 | int ldo = rdev_get_id(dev); |
| 310 | u8 shift; |
| 311 | |
| 312 | if (ldo < TPS6507X_LDO_1 || ldo > TPS6507X_LDO_2) |
| 313 | return -EINVAL; |
| 314 | |
| 315 | shift = TPS6507X_MAX_REG_ID - ldo; |
Todd Fischer | 4ce5ba5 | 2010-04-05 20:23:58 -0600 | [diff] [blame] | 316 | return tps6507x_pmic_set_bits(tps, TPS6507X_REG_CON_CTRL1, 1 << shift); |
Anuj Aggarwal | 3fa5b8e | 2009-08-21 00:39:39 +0530 | [diff] [blame] | 317 | } |
| 318 | |
Todd Fischer | 4ce5ba5 | 2010-04-05 20:23:58 -0600 | [diff] [blame] | 319 | static int tps6507x_pmic_ldo_disable(struct regulator_dev *dev) |
Anuj Aggarwal | 3fa5b8e | 2009-08-21 00:39:39 +0530 | [diff] [blame] | 320 | { |
Todd Fischer | 4ce5ba5 | 2010-04-05 20:23:58 -0600 | [diff] [blame] | 321 | struct tps6507x_pmic *tps = rdev_get_drvdata(dev); |
Anuj Aggarwal | 3fa5b8e | 2009-08-21 00:39:39 +0530 | [diff] [blame] | 322 | int ldo = rdev_get_id(dev); |
| 323 | u8 shift; |
| 324 | |
| 325 | if (ldo < TPS6507X_LDO_1 || ldo > TPS6507X_LDO_2) |
| 326 | return -EINVAL; |
| 327 | |
| 328 | shift = TPS6507X_MAX_REG_ID - ldo; |
Todd Fischer | 4ce5ba5 | 2010-04-05 20:23:58 -0600 | [diff] [blame] | 329 | return tps6507x_pmic_clear_bits(tps, TPS6507X_REG_CON_CTRL1, |
| 330 | 1 << shift); |
Anuj Aggarwal | 3fa5b8e | 2009-08-21 00:39:39 +0530 | [diff] [blame] | 331 | } |
| 332 | |
Todd Fischer | 4ce5ba5 | 2010-04-05 20:23:58 -0600 | [diff] [blame] | 333 | static int tps6507x_pmic_dcdc_get_voltage(struct regulator_dev *dev) |
Anuj Aggarwal | 3fa5b8e | 2009-08-21 00:39:39 +0530 | [diff] [blame] | 334 | { |
Todd Fischer | 4ce5ba5 | 2010-04-05 20:23:58 -0600 | [diff] [blame] | 335 | struct tps6507x_pmic *tps = rdev_get_drvdata(dev); |
Anuj Aggarwal | 3fa5b8e | 2009-08-21 00:39:39 +0530 | [diff] [blame] | 336 | int data, dcdc = rdev_get_id(dev); |
| 337 | u8 reg; |
| 338 | |
| 339 | switch (dcdc) { |
| 340 | case TPS6507X_DCDC_1: |
| 341 | reg = TPS6507X_REG_DEFDCDC1; |
| 342 | break; |
| 343 | case TPS6507X_DCDC_2: |
| 344 | reg = TPS6507X_REG_DEFDCDC2_LOW; |
| 345 | break; |
| 346 | case TPS6507X_DCDC_3: |
| 347 | reg = TPS6507X_REG_DEFDCDC3_LOW; |
| 348 | break; |
| 349 | default: |
| 350 | return -EINVAL; |
| 351 | } |
| 352 | |
Todd Fischer | 4ce5ba5 | 2010-04-05 20:23:58 -0600 | [diff] [blame] | 353 | data = tps6507x_pmic_reg_read(tps, reg); |
Anuj Aggarwal | 3fa5b8e | 2009-08-21 00:39:39 +0530 | [diff] [blame] | 354 | if (data < 0) |
| 355 | return data; |
| 356 | |
| 357 | data &= TPS6507X_DEFDCDCX_DCDC_MASK; |
| 358 | return tps->info[dcdc]->table[data] * 1000; |
| 359 | } |
| 360 | |
Todd Fischer | 4ce5ba5 | 2010-04-05 20:23:58 -0600 | [diff] [blame] | 361 | static int tps6507x_pmic_dcdc_set_voltage(struct regulator_dev *dev, |
Anuj Aggarwal | 3fa5b8e | 2009-08-21 00:39:39 +0530 | [diff] [blame] | 362 | int min_uV, int max_uV) |
| 363 | { |
Todd Fischer | 4ce5ba5 | 2010-04-05 20:23:58 -0600 | [diff] [blame] | 364 | struct tps6507x_pmic *tps = rdev_get_drvdata(dev); |
Anuj Aggarwal | 3fa5b8e | 2009-08-21 00:39:39 +0530 | [diff] [blame] | 365 | int data, vsel, dcdc = rdev_get_id(dev); |
| 366 | u8 reg; |
| 367 | |
| 368 | switch (dcdc) { |
| 369 | case TPS6507X_DCDC_1: |
| 370 | reg = TPS6507X_REG_DEFDCDC1; |
| 371 | break; |
| 372 | case TPS6507X_DCDC_2: |
| 373 | reg = TPS6507X_REG_DEFDCDC2_LOW; |
| 374 | break; |
| 375 | case TPS6507X_DCDC_3: |
| 376 | reg = TPS6507X_REG_DEFDCDC3_LOW; |
| 377 | break; |
| 378 | default: |
| 379 | return -EINVAL; |
| 380 | } |
| 381 | |
| 382 | if (min_uV < tps->info[dcdc]->min_uV |
| 383 | || min_uV > tps->info[dcdc]->max_uV) |
| 384 | return -EINVAL; |
| 385 | if (max_uV < tps->info[dcdc]->min_uV |
| 386 | || max_uV > tps->info[dcdc]->max_uV) |
| 387 | return -EINVAL; |
| 388 | |
| 389 | for (vsel = 0; vsel < tps->info[dcdc]->table_len; vsel++) { |
| 390 | int mV = tps->info[dcdc]->table[vsel]; |
| 391 | int uV = mV * 1000; |
| 392 | |
| 393 | /* Break at the first in-range value */ |
| 394 | if (min_uV <= uV && uV <= max_uV) |
| 395 | break; |
| 396 | } |
| 397 | |
| 398 | /* write to the register in case we found a match */ |
| 399 | if (vsel == tps->info[dcdc]->table_len) |
| 400 | return -EINVAL; |
| 401 | |
Todd Fischer | 4ce5ba5 | 2010-04-05 20:23:58 -0600 | [diff] [blame] | 402 | data = tps6507x_pmic_reg_read(tps, reg); |
Anuj Aggarwal | 3fa5b8e | 2009-08-21 00:39:39 +0530 | [diff] [blame] | 403 | if (data < 0) |
| 404 | return data; |
| 405 | |
| 406 | data &= ~TPS6507X_DEFDCDCX_DCDC_MASK; |
| 407 | data |= vsel; |
| 408 | |
Todd Fischer | 4ce5ba5 | 2010-04-05 20:23:58 -0600 | [diff] [blame] | 409 | return tps6507x_pmic_reg_write(tps, reg, data); |
Anuj Aggarwal | 3fa5b8e | 2009-08-21 00:39:39 +0530 | [diff] [blame] | 410 | } |
| 411 | |
Todd Fischer | 4ce5ba5 | 2010-04-05 20:23:58 -0600 | [diff] [blame] | 412 | static int tps6507x_pmic_ldo_get_voltage(struct regulator_dev *dev) |
Anuj Aggarwal | 3fa5b8e | 2009-08-21 00:39:39 +0530 | [diff] [blame] | 413 | { |
Todd Fischer | 4ce5ba5 | 2010-04-05 20:23:58 -0600 | [diff] [blame] | 414 | struct tps6507x_pmic *tps = rdev_get_drvdata(dev); |
Anuj Aggarwal | 3fa5b8e | 2009-08-21 00:39:39 +0530 | [diff] [blame] | 415 | int data, ldo = rdev_get_id(dev); |
| 416 | u8 reg, mask; |
| 417 | |
| 418 | if (ldo < TPS6507X_LDO_1 || ldo > TPS6507X_LDO_2) |
| 419 | return -EINVAL; |
| 420 | else { |
| 421 | reg = (ldo == TPS6507X_LDO_1 ? |
| 422 | TPS6507X_REG_LDO_CTRL1 : TPS6507X_REG_DEFLDO2); |
| 423 | mask = (ldo == TPS6507X_LDO_1 ? |
| 424 | TPS6507X_REG_LDO_CTRL1_LDO1_MASK : |
| 425 | TPS6507X_REG_DEFLDO2_LDO2_MASK); |
| 426 | } |
| 427 | |
Todd Fischer | 4ce5ba5 | 2010-04-05 20:23:58 -0600 | [diff] [blame] | 428 | data = tps6507x_pmic_reg_read(tps, reg); |
Anuj Aggarwal | 3fa5b8e | 2009-08-21 00:39:39 +0530 | [diff] [blame] | 429 | if (data < 0) |
| 430 | return data; |
| 431 | |
| 432 | data &= mask; |
| 433 | return tps->info[ldo]->table[data] * 1000; |
| 434 | } |
| 435 | |
Todd Fischer | 4ce5ba5 | 2010-04-05 20:23:58 -0600 | [diff] [blame] | 436 | static int tps6507x_pmic_ldo_set_voltage(struct regulator_dev *dev, |
Anuj Aggarwal | 3fa5b8e | 2009-08-21 00:39:39 +0530 | [diff] [blame] | 437 | int min_uV, int max_uV) |
| 438 | { |
Todd Fischer | 4ce5ba5 | 2010-04-05 20:23:58 -0600 | [diff] [blame] | 439 | struct tps6507x_pmic *tps = rdev_get_drvdata(dev); |
Anuj Aggarwal | 3fa5b8e | 2009-08-21 00:39:39 +0530 | [diff] [blame] | 440 | int data, vsel, ldo = rdev_get_id(dev); |
| 441 | u8 reg, mask; |
| 442 | |
| 443 | if (ldo < TPS6507X_LDO_1 || ldo > TPS6507X_LDO_2) |
| 444 | return -EINVAL; |
| 445 | else { |
| 446 | reg = (ldo == TPS6507X_LDO_1 ? |
| 447 | TPS6507X_REG_LDO_CTRL1 : TPS6507X_REG_DEFLDO2); |
| 448 | mask = (ldo == TPS6507X_LDO_1 ? |
| 449 | TPS6507X_REG_LDO_CTRL1_LDO1_MASK : |
| 450 | TPS6507X_REG_DEFLDO2_LDO2_MASK); |
| 451 | } |
| 452 | |
| 453 | if (min_uV < tps->info[ldo]->min_uV || min_uV > tps->info[ldo]->max_uV) |
| 454 | return -EINVAL; |
| 455 | if (max_uV < tps->info[ldo]->min_uV || max_uV > tps->info[ldo]->max_uV) |
| 456 | return -EINVAL; |
| 457 | |
| 458 | for (vsel = 0; vsel < tps->info[ldo]->table_len; vsel++) { |
| 459 | int mV = tps->info[ldo]->table[vsel]; |
| 460 | int uV = mV * 1000; |
| 461 | |
| 462 | /* Break at the first in-range value */ |
| 463 | if (min_uV <= uV && uV <= max_uV) |
| 464 | break; |
| 465 | } |
| 466 | |
| 467 | if (vsel == tps->info[ldo]->table_len) |
| 468 | return -EINVAL; |
| 469 | |
Todd Fischer | 4ce5ba5 | 2010-04-05 20:23:58 -0600 | [diff] [blame] | 470 | data = tps6507x_pmic_reg_read(tps, reg); |
Anuj Aggarwal | 3fa5b8e | 2009-08-21 00:39:39 +0530 | [diff] [blame] | 471 | if (data < 0) |
| 472 | return data; |
| 473 | |
| 474 | data &= ~mask; |
| 475 | data |= vsel; |
| 476 | |
Todd Fischer | 4ce5ba5 | 2010-04-05 20:23:58 -0600 | [diff] [blame] | 477 | return tps6507x_pmic_reg_write(tps, reg, data); |
Anuj Aggarwal | 3fa5b8e | 2009-08-21 00:39:39 +0530 | [diff] [blame] | 478 | } |
| 479 | |
Todd Fischer | 4ce5ba5 | 2010-04-05 20:23:58 -0600 | [diff] [blame] | 480 | static int tps6507x_pmic_dcdc_list_voltage(struct regulator_dev *dev, |
Anuj Aggarwal | 3fa5b8e | 2009-08-21 00:39:39 +0530 | [diff] [blame] | 481 | unsigned selector) |
| 482 | { |
Todd Fischer | 4ce5ba5 | 2010-04-05 20:23:58 -0600 | [diff] [blame] | 483 | struct tps6507x_pmic *tps = rdev_get_drvdata(dev); |
Anuj Aggarwal | 3fa5b8e | 2009-08-21 00:39:39 +0530 | [diff] [blame] | 484 | int dcdc = rdev_get_id(dev); |
| 485 | |
| 486 | if (dcdc < TPS6507X_DCDC_1 || dcdc > TPS6507X_DCDC_3) |
| 487 | return -EINVAL; |
| 488 | |
| 489 | if (selector >= tps->info[dcdc]->table_len) |
| 490 | return -EINVAL; |
| 491 | else |
| 492 | return tps->info[dcdc]->table[selector] * 1000; |
| 493 | } |
| 494 | |
Todd Fischer | 4ce5ba5 | 2010-04-05 20:23:58 -0600 | [diff] [blame] | 495 | static int tps6507x_pmic_ldo_list_voltage(struct regulator_dev *dev, |
Anuj Aggarwal | 3fa5b8e | 2009-08-21 00:39:39 +0530 | [diff] [blame] | 496 | unsigned selector) |
| 497 | { |
Todd Fischer | 4ce5ba5 | 2010-04-05 20:23:58 -0600 | [diff] [blame] | 498 | struct tps6507x_pmic *tps = rdev_get_drvdata(dev); |
Anuj Aggarwal | 3fa5b8e | 2009-08-21 00:39:39 +0530 | [diff] [blame] | 499 | int ldo = rdev_get_id(dev); |
| 500 | |
| 501 | if (ldo < TPS6507X_LDO_1 || ldo > TPS6507X_LDO_2) |
| 502 | return -EINVAL; |
| 503 | |
| 504 | if (selector >= tps->info[ldo]->table_len) |
| 505 | return -EINVAL; |
| 506 | else |
| 507 | return tps->info[ldo]->table[selector] * 1000; |
| 508 | } |
| 509 | |
| 510 | /* Operations permitted on VDCDCx */ |
Todd Fischer | 4ce5ba5 | 2010-04-05 20:23:58 -0600 | [diff] [blame] | 511 | static struct regulator_ops tps6507x_pmic_dcdc_ops = { |
| 512 | .is_enabled = tps6507x_pmic_dcdc_is_enabled, |
| 513 | .enable = tps6507x_pmic_dcdc_enable, |
| 514 | .disable = tps6507x_pmic_dcdc_disable, |
| 515 | .get_voltage = tps6507x_pmic_dcdc_get_voltage, |
| 516 | .set_voltage = tps6507x_pmic_dcdc_set_voltage, |
| 517 | .list_voltage = tps6507x_pmic_dcdc_list_voltage, |
Anuj Aggarwal | 3fa5b8e | 2009-08-21 00:39:39 +0530 | [diff] [blame] | 518 | }; |
| 519 | |
| 520 | /* Operations permitted on LDOx */ |
Todd Fischer | 4ce5ba5 | 2010-04-05 20:23:58 -0600 | [diff] [blame] | 521 | static struct regulator_ops tps6507x_pmic_ldo_ops = { |
| 522 | .is_enabled = tps6507x_pmic_ldo_is_enabled, |
| 523 | .enable = tps6507x_pmic_ldo_enable, |
| 524 | .disable = tps6507x_pmic_ldo_disable, |
| 525 | .get_voltage = tps6507x_pmic_ldo_get_voltage, |
| 526 | .set_voltage = tps6507x_pmic_ldo_set_voltage, |
| 527 | .list_voltage = tps6507x_pmic_ldo_list_voltage, |
Anuj Aggarwal | 3fa5b8e | 2009-08-21 00:39:39 +0530 | [diff] [blame] | 528 | }; |
| 529 | |
Todd Fischer | 31dd6a2 | 2010-04-08 09:04:55 +0200 | [diff] [blame] | 530 | static __devinit |
| 531 | int tps6507x_pmic_probe(struct platform_device *pdev) |
Anuj Aggarwal | 3fa5b8e | 2009-08-21 00:39:39 +0530 | [diff] [blame] | 532 | { |
Todd Fischer | 31dd6a2 | 2010-04-08 09:04:55 +0200 | [diff] [blame] | 533 | struct tps6507x_dev *tps6507x_dev = dev_get_drvdata(pdev->dev.parent); |
Anuj Aggarwal | 3fa5b8e | 2009-08-21 00:39:39 +0530 | [diff] [blame] | 534 | static int desc_id; |
Todd Fischer | 31dd6a2 | 2010-04-08 09:04:55 +0200 | [diff] [blame] | 535 | const struct tps_info *info = &tps6507x_pmic_regs[0]; |
Anuj Aggarwal | 3fa5b8e | 2009-08-21 00:39:39 +0530 | [diff] [blame] | 536 | struct regulator_init_data *init_data; |
| 537 | struct regulator_dev *rdev; |
Todd Fischer | 4ce5ba5 | 2010-04-05 20:23:58 -0600 | [diff] [blame] | 538 | struct tps6507x_pmic *tps; |
Todd Fischer | 0bc20bb | 2010-04-05 20:23:57 -0600 | [diff] [blame] | 539 | struct tps6507x_board *tps_board; |
Anuj Aggarwal | 3fa5b8e | 2009-08-21 00:39:39 +0530 | [diff] [blame] | 540 | int i; |
Dmitry Torokhov | 56c2349 | 2010-02-23 23:38:12 -0800 | [diff] [blame] | 541 | int error; |
Anuj Aggarwal | 3fa5b8e | 2009-08-21 00:39:39 +0530 | [diff] [blame] | 542 | |
Anuj Aggarwal | 3fa5b8e | 2009-08-21 00:39:39 +0530 | [diff] [blame] | 543 | /** |
Todd Fischer | 0bc20bb | 2010-04-05 20:23:57 -0600 | [diff] [blame] | 544 | * tps_board points to pmic related constants |
| 545 | * coming from the board-evm file. |
| 546 | */ |
| 547 | |
Todd Fischer | 31dd6a2 | 2010-04-08 09:04:55 +0200 | [diff] [blame] | 548 | tps_board = dev_get_platdata(tps6507x_dev->dev); |
Todd Fischer | 0bc20bb | 2010-04-05 20:23:57 -0600 | [diff] [blame] | 549 | if (!tps_board) |
| 550 | return -EINVAL; |
| 551 | |
| 552 | /** |
Anuj Aggarwal | 3fa5b8e | 2009-08-21 00:39:39 +0530 | [diff] [blame] | 553 | * init_data points to array of regulator_init structures |
| 554 | * coming from the board-evm file. |
| 555 | */ |
Todd Fischer | 0bc20bb | 2010-04-05 20:23:57 -0600 | [diff] [blame] | 556 | init_data = tps_board->tps6507x_pmic_init_data; |
Anuj Aggarwal | 3fa5b8e | 2009-08-21 00:39:39 +0530 | [diff] [blame] | 557 | if (!init_data) |
Todd Fischer | 0bc20bb | 2010-04-05 20:23:57 -0600 | [diff] [blame] | 558 | return -EINVAL; |
Anuj Aggarwal | 3fa5b8e | 2009-08-21 00:39:39 +0530 | [diff] [blame] | 559 | |
| 560 | tps = kzalloc(sizeof(*tps), GFP_KERNEL); |
| 561 | if (!tps) |
| 562 | return -ENOMEM; |
| 563 | |
| 564 | mutex_init(&tps->io_lock); |
| 565 | |
| 566 | /* common for all regulators */ |
Todd Fischer | 31dd6a2 | 2010-04-08 09:04:55 +0200 | [diff] [blame] | 567 | tps->mfd = tps6507x_dev; |
Anuj Aggarwal | 3fa5b8e | 2009-08-21 00:39:39 +0530 | [diff] [blame] | 568 | |
| 569 | for (i = 0; i < TPS6507X_NUM_REGULATOR; i++, info++, init_data++) { |
| 570 | /* Register the regulators */ |
| 571 | tps->info[i] = info; |
| 572 | tps->desc[i].name = info->name; |
| 573 | tps->desc[i].id = desc_id++; |
| 574 | tps->desc[i].n_voltages = num_voltages[i]; |
| 575 | tps->desc[i].ops = (i > TPS6507X_DCDC_3 ? |
Todd Fischer | 4ce5ba5 | 2010-04-05 20:23:58 -0600 | [diff] [blame] | 576 | &tps6507x_pmic_ldo_ops : &tps6507x_pmic_dcdc_ops); |
Anuj Aggarwal | 3fa5b8e | 2009-08-21 00:39:39 +0530 | [diff] [blame] | 577 | tps->desc[i].type = REGULATOR_VOLTAGE; |
| 578 | tps->desc[i].owner = THIS_MODULE; |
| 579 | |
| 580 | rdev = regulator_register(&tps->desc[i], |
Todd Fischer | 31dd6a2 | 2010-04-08 09:04:55 +0200 | [diff] [blame] | 581 | tps6507x_dev->dev, init_data, tps); |
Anuj Aggarwal | 3fa5b8e | 2009-08-21 00:39:39 +0530 | [diff] [blame] | 582 | if (IS_ERR(rdev)) { |
Todd Fischer | 31dd6a2 | 2010-04-08 09:04:55 +0200 | [diff] [blame] | 583 | dev_err(tps6507x_dev->dev, |
| 584 | "failed to register %s regulator\n", |
| 585 | pdev->name); |
Dmitry Torokhov | 56c2349 | 2010-02-23 23:38:12 -0800 | [diff] [blame] | 586 | error = PTR_ERR(rdev); |
| 587 | goto fail; |
Anuj Aggarwal | 3fa5b8e | 2009-08-21 00:39:39 +0530 | [diff] [blame] | 588 | } |
| 589 | |
| 590 | /* Save regulator for cleanup */ |
| 591 | tps->rdev[i] = rdev; |
| 592 | } |
| 593 | |
Todd Fischer | 31dd6a2 | 2010-04-08 09:04:55 +0200 | [diff] [blame] | 594 | tps6507x_dev->pmic = tps; |
Anuj Aggarwal | 3fa5b8e | 2009-08-21 00:39:39 +0530 | [diff] [blame] | 595 | |
| 596 | return 0; |
Dmitry Torokhov | 56c2349 | 2010-02-23 23:38:12 -0800 | [diff] [blame] | 597 | |
| 598 | fail: |
| 599 | while (--i >= 0) |
| 600 | regulator_unregister(tps->rdev[i]); |
| 601 | |
| 602 | kfree(tps); |
| 603 | return error; |
Anuj Aggarwal | 3fa5b8e | 2009-08-21 00:39:39 +0530 | [diff] [blame] | 604 | } |
| 605 | |
| 606 | /** |
Todd Fischer | 4ce5ba5 | 2010-04-05 20:23:58 -0600 | [diff] [blame] | 607 | * tps6507x_remove - TPS6507x driver i2c remove handler |
Anuj Aggarwal | 3fa5b8e | 2009-08-21 00:39:39 +0530 | [diff] [blame] | 608 | * @client: i2c driver client device structure |
| 609 | * |
| 610 | * Unregister TPS driver as an i2c client device driver |
| 611 | */ |
Todd Fischer | 31dd6a2 | 2010-04-08 09:04:55 +0200 | [diff] [blame] | 612 | static int __devexit tps6507x_pmic_remove(struct platform_device *pdev) |
Anuj Aggarwal | 3fa5b8e | 2009-08-21 00:39:39 +0530 | [diff] [blame] | 613 | { |
Todd Fischer | 31dd6a2 | 2010-04-08 09:04:55 +0200 | [diff] [blame] | 614 | struct tps6507x_dev *tps6507x_dev = platform_get_drvdata(pdev); |
| 615 | struct tps6507x_pmic *tps = tps6507x_dev->pmic; |
Anuj Aggarwal | 3fa5b8e | 2009-08-21 00:39:39 +0530 | [diff] [blame] | 616 | int i; |
| 617 | |
| 618 | for (i = 0; i < TPS6507X_NUM_REGULATOR; i++) |
| 619 | regulator_unregister(tps->rdev[i]); |
| 620 | |
Anuj Aggarwal | 3fa5b8e | 2009-08-21 00:39:39 +0530 | [diff] [blame] | 621 | kfree(tps); |
| 622 | |
| 623 | return 0; |
| 624 | } |
| 625 | |
Todd Fischer | 31dd6a2 | 2010-04-08 09:04:55 +0200 | [diff] [blame] | 626 | static struct platform_driver tps6507x_pmic_driver = { |
Anuj Aggarwal | 3fa5b8e | 2009-08-21 00:39:39 +0530 | [diff] [blame] | 627 | .driver = { |
Todd Fischer | 31dd6a2 | 2010-04-08 09:04:55 +0200 | [diff] [blame] | 628 | .name = "tps6507x-pmic", |
Anuj Aggarwal | 3fa5b8e | 2009-08-21 00:39:39 +0530 | [diff] [blame] | 629 | .owner = THIS_MODULE, |
| 630 | }, |
Todd Fischer | 4ce5ba5 | 2010-04-05 20:23:58 -0600 | [diff] [blame] | 631 | .probe = tps6507x_pmic_probe, |
| 632 | .remove = __devexit_p(tps6507x_pmic_remove), |
Anuj Aggarwal | 3fa5b8e | 2009-08-21 00:39:39 +0530 | [diff] [blame] | 633 | }; |
| 634 | |
| 635 | /** |
Todd Fischer | 4ce5ba5 | 2010-04-05 20:23:58 -0600 | [diff] [blame] | 636 | * tps6507x_pmic_init |
Anuj Aggarwal | 3fa5b8e | 2009-08-21 00:39:39 +0530 | [diff] [blame] | 637 | * |
| 638 | * Module init function |
| 639 | */ |
Todd Fischer | 4ce5ba5 | 2010-04-05 20:23:58 -0600 | [diff] [blame] | 640 | static int __init tps6507x_pmic_init(void) |
Anuj Aggarwal | 3fa5b8e | 2009-08-21 00:39:39 +0530 | [diff] [blame] | 641 | { |
Todd Fischer | 31dd6a2 | 2010-04-08 09:04:55 +0200 | [diff] [blame] | 642 | return platform_driver_register(&tps6507x_pmic_driver); |
Anuj Aggarwal | 3fa5b8e | 2009-08-21 00:39:39 +0530 | [diff] [blame] | 643 | } |
Todd Fischer | 4ce5ba5 | 2010-04-05 20:23:58 -0600 | [diff] [blame] | 644 | subsys_initcall(tps6507x_pmic_init); |
Anuj Aggarwal | 3fa5b8e | 2009-08-21 00:39:39 +0530 | [diff] [blame] | 645 | |
| 646 | /** |
Todd Fischer | 4ce5ba5 | 2010-04-05 20:23:58 -0600 | [diff] [blame] | 647 | * tps6507x_pmic_cleanup |
Anuj Aggarwal | 3fa5b8e | 2009-08-21 00:39:39 +0530 | [diff] [blame] | 648 | * |
| 649 | * Module exit function |
| 650 | */ |
Todd Fischer | 4ce5ba5 | 2010-04-05 20:23:58 -0600 | [diff] [blame] | 651 | static void __exit tps6507x_pmic_cleanup(void) |
Anuj Aggarwal | 3fa5b8e | 2009-08-21 00:39:39 +0530 | [diff] [blame] | 652 | { |
Todd Fischer | 31dd6a2 | 2010-04-08 09:04:55 +0200 | [diff] [blame] | 653 | platform_driver_unregister(&tps6507x_pmic_driver); |
Anuj Aggarwal | 3fa5b8e | 2009-08-21 00:39:39 +0530 | [diff] [blame] | 654 | } |
Todd Fischer | 4ce5ba5 | 2010-04-05 20:23:58 -0600 | [diff] [blame] | 655 | module_exit(tps6507x_pmic_cleanup); |
Anuj Aggarwal | 3fa5b8e | 2009-08-21 00:39:39 +0530 | [diff] [blame] | 656 | |
| 657 | MODULE_AUTHOR("Texas Instruments"); |
| 658 | MODULE_DESCRIPTION("TPS6507x voltage regulator driver"); |
Liam Girdwood | 9e108d3 | 2009-08-24 10:31:34 +0100 | [diff] [blame] | 659 | MODULE_LICENSE("GPL v2"); |
Todd Fischer | 31dd6a2 | 2010-04-08 09:04:55 +0200 | [diff] [blame] | 660 | MODULE_ALIAS("platform:tps6507x-pmic"); |