David Brownell | fa16a5c | 2009-02-08 10:37:06 -0800 | [diff] [blame] | 1 | /* |
Rajendra Nayak | c4aa6f3 | 2009-12-13 21:36:49 +0100 | [diff] [blame] | 2 | * twl-regulator.c -- support regulators in twl4030/twl6030 family chips |
David Brownell | fa16a5c | 2009-02-08 10:37:06 -0800 | [diff] [blame] | 3 | * |
| 4 | * Copyright (C) 2008 David Brownell |
| 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 | |
| 12 | #include <linux/module.h> |
| 13 | #include <linux/init.h> |
| 14 | #include <linux/err.h> |
Juha Keski-Saari | 53b8a9d | 2009-12-16 14:55:26 +0200 | [diff] [blame] | 15 | #include <linux/delay.h> |
David Brownell | fa16a5c | 2009-02-08 10:37:06 -0800 | [diff] [blame] | 16 | #include <linux/platform_device.h> |
| 17 | #include <linux/regulator/driver.h> |
| 18 | #include <linux/regulator/machine.h> |
Santosh Shilimkar | b07682b | 2009-12-13 20:05:51 +0100 | [diff] [blame] | 19 | #include <linux/i2c/twl.h> |
David Brownell | fa16a5c | 2009-02-08 10:37:06 -0800 | [diff] [blame] | 20 | |
| 21 | |
| 22 | /* |
Rajendra Nayak | c4aa6f3 | 2009-12-13 21:36:49 +0100 | [diff] [blame] | 23 | * The TWL4030/TW5030/TPS659x0/TWL6030 family chips include power management, a |
David Brownell | fa16a5c | 2009-02-08 10:37:06 -0800 | [diff] [blame] | 24 | * USB OTG transceiver, an RTC, ADC, PWM, and lots more. Some versions |
| 25 | * include an audio codec, battery charger, and more voltage regulators. |
| 26 | * These chips are often used in OMAP-based systems. |
| 27 | * |
| 28 | * This driver implements software-based resource control for various |
| 29 | * voltage regulators. This is usually augmented with state machine |
| 30 | * based control. |
| 31 | */ |
| 32 | |
| 33 | struct twlreg_info { |
| 34 | /* start of regulator's PM_RECEIVER control register bank */ |
| 35 | u8 base; |
| 36 | |
Rajendra Nayak | c4aa6f3 | 2009-12-13 21:36:49 +0100 | [diff] [blame] | 37 | /* twl resource ID, for resource control state machine */ |
David Brownell | fa16a5c | 2009-02-08 10:37:06 -0800 | [diff] [blame] | 38 | u8 id; |
| 39 | |
| 40 | /* voltage in mV = table[VSEL]; table_len must be a power-of-two */ |
| 41 | u8 table_len; |
| 42 | const u16 *table; |
| 43 | |
Juha Keski-Saari | 045f972 | 2009-12-16 14:49:52 +0200 | [diff] [blame] | 44 | /* regulator specific turn-on delay */ |
| 45 | u16 delay; |
| 46 | |
| 47 | /* State REMAP default configuration */ |
| 48 | u8 remap; |
| 49 | |
David Brownell | fa16a5c | 2009-02-08 10:37:06 -0800 | [diff] [blame] | 50 | /* chip constraints on regulator behavior */ |
| 51 | u16 min_mV; |
Rajendra Nayak | 3e3d3be | 2010-04-22 14:18:32 +0530 | [diff] [blame] | 52 | u16 max_mV; |
David Brownell | fa16a5c | 2009-02-08 10:37:06 -0800 | [diff] [blame] | 53 | |
| 54 | /* used by regulator core */ |
| 55 | struct regulator_desc desc; |
| 56 | }; |
| 57 | |
| 58 | |
| 59 | /* LDO control registers ... offset is from the base of its register bank. |
| 60 | * The first three registers of all power resource banks help hardware to |
| 61 | * manage the various resource groups. |
| 62 | */ |
Rajendra Nayak | 441a450 | 2009-12-13 22:19:23 +0100 | [diff] [blame] | 63 | /* Common offset in TWL4030/6030 */ |
David Brownell | fa16a5c | 2009-02-08 10:37:06 -0800 | [diff] [blame] | 64 | #define VREG_GRP 0 |
Rajendra Nayak | 441a450 | 2009-12-13 22:19:23 +0100 | [diff] [blame] | 65 | /* TWL4030 register offsets */ |
David Brownell | fa16a5c | 2009-02-08 10:37:06 -0800 | [diff] [blame] | 66 | #define VREG_TYPE 1 |
| 67 | #define VREG_REMAP 2 |
| 68 | #define VREG_DEDICATED 3 /* LDO control */ |
Rajendra Nayak | 441a450 | 2009-12-13 22:19:23 +0100 | [diff] [blame] | 69 | /* TWL6030 register offsets */ |
| 70 | #define VREG_TRANS 1 |
| 71 | #define VREG_STATE 2 |
| 72 | #define VREG_VOLTAGE 3 |
| 73 | /* TWL6030 Misc register offsets */ |
| 74 | #define VREG_BC_ALL 1 |
| 75 | #define VREG_BC_REF 2 |
| 76 | #define VREG_BC_PROC 3 |
| 77 | #define VREG_BC_CLK_RST 4 |
David Brownell | fa16a5c | 2009-02-08 10:37:06 -0800 | [diff] [blame] | 78 | |
| 79 | static inline int |
Rajendra Nayak | 441a450 | 2009-12-13 22:19:23 +0100 | [diff] [blame] | 80 | twlreg_read(struct twlreg_info *info, unsigned slave_subgp, unsigned offset) |
David Brownell | fa16a5c | 2009-02-08 10:37:06 -0800 | [diff] [blame] | 81 | { |
| 82 | u8 value; |
| 83 | int status; |
| 84 | |
Rajendra Nayak | 441a450 | 2009-12-13 22:19:23 +0100 | [diff] [blame] | 85 | status = twl_i2c_read_u8(slave_subgp, |
David Brownell | fa16a5c | 2009-02-08 10:37:06 -0800 | [diff] [blame] | 86 | &value, info->base + offset); |
| 87 | return (status < 0) ? status : value; |
| 88 | } |
| 89 | |
| 90 | static inline int |
Rajendra Nayak | 441a450 | 2009-12-13 22:19:23 +0100 | [diff] [blame] | 91 | twlreg_write(struct twlreg_info *info, unsigned slave_subgp, unsigned offset, |
| 92 | u8 value) |
David Brownell | fa16a5c | 2009-02-08 10:37:06 -0800 | [diff] [blame] | 93 | { |
Rajendra Nayak | 441a450 | 2009-12-13 22:19:23 +0100 | [diff] [blame] | 94 | return twl_i2c_write_u8(slave_subgp, |
David Brownell | fa16a5c | 2009-02-08 10:37:06 -0800 | [diff] [blame] | 95 | value, info->base + offset); |
| 96 | } |
| 97 | |
| 98 | /*----------------------------------------------------------------------*/ |
| 99 | |
| 100 | /* generic power resource operations, which work on all regulators */ |
| 101 | |
Rajendra Nayak | c4aa6f3 | 2009-12-13 21:36:49 +0100 | [diff] [blame] | 102 | static int twlreg_grp(struct regulator_dev *rdev) |
David Brownell | fa16a5c | 2009-02-08 10:37:06 -0800 | [diff] [blame] | 103 | { |
Rajendra Nayak | 441a450 | 2009-12-13 22:19:23 +0100 | [diff] [blame] | 104 | return twlreg_read(rdev_get_drvdata(rdev), TWL_MODULE_PM_RECEIVER, |
| 105 | VREG_GRP); |
David Brownell | fa16a5c | 2009-02-08 10:37:06 -0800 | [diff] [blame] | 106 | } |
| 107 | |
| 108 | /* |
| 109 | * Enable/disable regulators by joining/leaving the P1 (processor) group. |
| 110 | * We assume nobody else is updating the DEV_GRP registers. |
| 111 | */ |
Rajendra Nayak | 441a450 | 2009-12-13 22:19:23 +0100 | [diff] [blame] | 112 | /* definition for 4030 family */ |
| 113 | #define P3_GRP_4030 BIT(7) /* "peripherals" */ |
| 114 | #define P2_GRP_4030 BIT(6) /* secondary processor, modem, etc */ |
| 115 | #define P1_GRP_4030 BIT(5) /* CPU/Linux */ |
| 116 | /* definition for 6030 family */ |
| 117 | #define P3_GRP_6030 BIT(2) /* secondary processor, modem, etc */ |
| 118 | #define P2_GRP_6030 BIT(1) /* "peripherals" */ |
| 119 | #define P1_GRP_6030 BIT(0) /* CPU/Linux */ |
David Brownell | fa16a5c | 2009-02-08 10:37:06 -0800 | [diff] [blame] | 120 | |
Rajendra Nayak | c4aa6f3 | 2009-12-13 21:36:49 +0100 | [diff] [blame] | 121 | static int twlreg_is_enabled(struct regulator_dev *rdev) |
David Brownell | fa16a5c | 2009-02-08 10:37:06 -0800 | [diff] [blame] | 122 | { |
Rajendra Nayak | c4aa6f3 | 2009-12-13 21:36:49 +0100 | [diff] [blame] | 123 | int state = twlreg_grp(rdev); |
David Brownell | fa16a5c | 2009-02-08 10:37:06 -0800 | [diff] [blame] | 124 | |
| 125 | if (state < 0) |
| 126 | return state; |
| 127 | |
Rajendra Nayak | 441a450 | 2009-12-13 22:19:23 +0100 | [diff] [blame] | 128 | if (twl_class_is_4030()) |
| 129 | state &= P1_GRP_4030; |
| 130 | else |
| 131 | state &= P1_GRP_6030; |
| 132 | return state; |
David Brownell | fa16a5c | 2009-02-08 10:37:06 -0800 | [diff] [blame] | 133 | } |
| 134 | |
Rajendra Nayak | c4aa6f3 | 2009-12-13 21:36:49 +0100 | [diff] [blame] | 135 | static int twlreg_enable(struct regulator_dev *rdev) |
David Brownell | fa16a5c | 2009-02-08 10:37:06 -0800 | [diff] [blame] | 136 | { |
| 137 | struct twlreg_info *info = rdev_get_drvdata(rdev); |
| 138 | int grp; |
Juha Keski-Saari | 53b8a9d | 2009-12-16 14:55:26 +0200 | [diff] [blame] | 139 | int ret; |
David Brownell | fa16a5c | 2009-02-08 10:37:06 -0800 | [diff] [blame] | 140 | |
Rajendra Nayak | 441a450 | 2009-12-13 22:19:23 +0100 | [diff] [blame] | 141 | grp = twlreg_read(info, TWL_MODULE_PM_RECEIVER, VREG_GRP); |
David Brownell | fa16a5c | 2009-02-08 10:37:06 -0800 | [diff] [blame] | 142 | if (grp < 0) |
| 143 | return grp; |
| 144 | |
Rajendra Nayak | 441a450 | 2009-12-13 22:19:23 +0100 | [diff] [blame] | 145 | if (twl_class_is_4030()) |
| 146 | grp |= P1_GRP_4030; |
| 147 | else |
| 148 | grp |= P1_GRP_6030; |
| 149 | |
Juha Keski-Saari | 53b8a9d | 2009-12-16 14:55:26 +0200 | [diff] [blame] | 150 | ret = twlreg_write(info, TWL_MODULE_PM_RECEIVER, VREG_GRP, grp); |
| 151 | |
| 152 | udelay(info->delay); |
| 153 | |
| 154 | return ret; |
David Brownell | fa16a5c | 2009-02-08 10:37:06 -0800 | [diff] [blame] | 155 | } |
| 156 | |
Rajendra Nayak | c4aa6f3 | 2009-12-13 21:36:49 +0100 | [diff] [blame] | 157 | static int twlreg_disable(struct regulator_dev *rdev) |
David Brownell | fa16a5c | 2009-02-08 10:37:06 -0800 | [diff] [blame] | 158 | { |
| 159 | struct twlreg_info *info = rdev_get_drvdata(rdev); |
| 160 | int grp; |
| 161 | |
Rajendra Nayak | 441a450 | 2009-12-13 22:19:23 +0100 | [diff] [blame] | 162 | grp = twlreg_read(info, TWL_MODULE_PM_RECEIVER, VREG_GRP); |
David Brownell | fa16a5c | 2009-02-08 10:37:06 -0800 | [diff] [blame] | 163 | if (grp < 0) |
| 164 | return grp; |
| 165 | |
Rajendra Nayak | 441a450 | 2009-12-13 22:19:23 +0100 | [diff] [blame] | 166 | if (twl_class_is_4030()) |
Juha Keski-Saari | cf9836f | 2009-12-16 15:28:00 +0200 | [diff] [blame] | 167 | grp &= ~(P1_GRP_4030 | P2_GRP_4030 | P3_GRP_4030); |
Rajendra Nayak | 441a450 | 2009-12-13 22:19:23 +0100 | [diff] [blame] | 168 | else |
Juha Keski-Saari | cf9836f | 2009-12-16 15:28:00 +0200 | [diff] [blame] | 169 | grp &= ~(P1_GRP_6030 | P2_GRP_6030 | P3_GRP_6030); |
Rajendra Nayak | 441a450 | 2009-12-13 22:19:23 +0100 | [diff] [blame] | 170 | |
| 171 | return twlreg_write(info, TWL_MODULE_PM_RECEIVER, VREG_GRP, grp); |
David Brownell | fa16a5c | 2009-02-08 10:37:06 -0800 | [diff] [blame] | 172 | } |
| 173 | |
Rajendra Nayak | c4aa6f3 | 2009-12-13 21:36:49 +0100 | [diff] [blame] | 174 | static int twlreg_get_status(struct regulator_dev *rdev) |
David Brownell | fa16a5c | 2009-02-08 10:37:06 -0800 | [diff] [blame] | 175 | { |
Rajendra Nayak | c4aa6f3 | 2009-12-13 21:36:49 +0100 | [diff] [blame] | 176 | int state = twlreg_grp(rdev); |
David Brownell | fa16a5c | 2009-02-08 10:37:06 -0800 | [diff] [blame] | 177 | |
Rajendra Nayak | 441a450 | 2009-12-13 22:19:23 +0100 | [diff] [blame] | 178 | if (twl_class_is_6030()) |
| 179 | return 0; /* FIXME return for 6030 regulator */ |
| 180 | |
David Brownell | fa16a5c | 2009-02-08 10:37:06 -0800 | [diff] [blame] | 181 | if (state < 0) |
| 182 | return state; |
| 183 | state &= 0x0f; |
| 184 | |
| 185 | /* assume state != WARM_RESET; we'd not be running... */ |
| 186 | if (!state) |
| 187 | return REGULATOR_STATUS_OFF; |
| 188 | return (state & BIT(3)) |
| 189 | ? REGULATOR_STATUS_NORMAL |
| 190 | : REGULATOR_STATUS_STANDBY; |
| 191 | } |
| 192 | |
Rajendra Nayak | c4aa6f3 | 2009-12-13 21:36:49 +0100 | [diff] [blame] | 193 | static int twlreg_set_mode(struct regulator_dev *rdev, unsigned mode) |
David Brownell | fa16a5c | 2009-02-08 10:37:06 -0800 | [diff] [blame] | 194 | { |
| 195 | struct twlreg_info *info = rdev_get_drvdata(rdev); |
| 196 | unsigned message; |
| 197 | int status; |
| 198 | |
Rajendra Nayak | 441a450 | 2009-12-13 22:19:23 +0100 | [diff] [blame] | 199 | if (twl_class_is_6030()) |
| 200 | return 0; /* FIXME return for 6030 regulator */ |
| 201 | |
David Brownell | fa16a5c | 2009-02-08 10:37:06 -0800 | [diff] [blame] | 202 | /* We can only set the mode through state machine commands... */ |
| 203 | switch (mode) { |
| 204 | case REGULATOR_MODE_NORMAL: |
| 205 | message = MSG_SINGULAR(DEV_GRP_P1, info->id, RES_STATE_ACTIVE); |
| 206 | break; |
| 207 | case REGULATOR_MODE_STANDBY: |
| 208 | message = MSG_SINGULAR(DEV_GRP_P1, info->id, RES_STATE_SLEEP); |
| 209 | break; |
| 210 | default: |
| 211 | return -EINVAL; |
| 212 | } |
| 213 | |
| 214 | /* Ensure the resource is associated with some group */ |
Rajendra Nayak | c4aa6f3 | 2009-12-13 21:36:49 +0100 | [diff] [blame] | 215 | status = twlreg_grp(rdev); |
David Brownell | fa16a5c | 2009-02-08 10:37:06 -0800 | [diff] [blame] | 216 | if (status < 0) |
| 217 | return status; |
Rajendra Nayak | 441a450 | 2009-12-13 22:19:23 +0100 | [diff] [blame] | 218 | if (!(status & (P3_GRP_4030 | P2_GRP_4030 | P1_GRP_4030))) |
David Brownell | fa16a5c | 2009-02-08 10:37:06 -0800 | [diff] [blame] | 219 | return -EACCES; |
| 220 | |
Rajendra Nayak | c4aa6f3 | 2009-12-13 21:36:49 +0100 | [diff] [blame] | 221 | status = twl_i2c_write_u8(TWL_MODULE_PM_MASTER, |
David Brownell | fa16a5c | 2009-02-08 10:37:06 -0800 | [diff] [blame] | 222 | message >> 8, 0x15 /* PB_WORD_MSB */ ); |
| 223 | if (status >= 0) |
| 224 | return status; |
| 225 | |
Rajendra Nayak | c4aa6f3 | 2009-12-13 21:36:49 +0100 | [diff] [blame] | 226 | return twl_i2c_write_u8(TWL_MODULE_PM_MASTER, |
David Brownell | fa16a5c | 2009-02-08 10:37:06 -0800 | [diff] [blame] | 227 | message, 0x16 /* PB_WORD_LSB */ ); |
| 228 | } |
| 229 | |
| 230 | /*----------------------------------------------------------------------*/ |
| 231 | |
| 232 | /* |
| 233 | * Support for adjustable-voltage LDOs uses a four bit (or less) voltage |
| 234 | * select field in its control register. We use tables indexed by VSEL |
| 235 | * to record voltages in milliVolts. (Accuracy is about three percent.) |
| 236 | * |
| 237 | * Note that VSEL values for VAUX2 changed in twl5030 and newer silicon; |
| 238 | * currently handled by listing two slightly different VAUX2 regulators, |
| 239 | * only one of which will be configured. |
| 240 | * |
| 241 | * VSEL values documented as "TI cannot support these values" are flagged |
| 242 | * in these tables as UNSUP() values; we normally won't assign them. |
Adrian Hunter | d6bb69c | 2009-03-06 14:51:30 +0200 | [diff] [blame] | 243 | * |
| 244 | * VAUX3 at 3V is incorrectly listed in some TI manuals as unsupported. |
| 245 | * TI are revising the twl5030/tps659x0 specs to support that 3.0V setting. |
David Brownell | fa16a5c | 2009-02-08 10:37:06 -0800 | [diff] [blame] | 246 | */ |
| 247 | #ifdef CONFIG_TWL4030_ALLOW_UNSUPPORTED |
| 248 | #define UNSUP_MASK 0x0000 |
| 249 | #else |
| 250 | #define UNSUP_MASK 0x8000 |
| 251 | #endif |
| 252 | |
| 253 | #define UNSUP(x) (UNSUP_MASK | (x)) |
| 254 | #define IS_UNSUP(x) (UNSUP_MASK & (x)) |
| 255 | #define LDO_MV(x) (~UNSUP_MASK & (x)) |
| 256 | |
| 257 | |
| 258 | static const u16 VAUX1_VSEL_table[] = { |
| 259 | UNSUP(1500), UNSUP(1800), 2500, 2800, |
| 260 | 3000, 3000, 3000, 3000, |
| 261 | }; |
| 262 | static const u16 VAUX2_4030_VSEL_table[] = { |
| 263 | UNSUP(1000), UNSUP(1000), UNSUP(1200), 1300, |
| 264 | 1500, 1800, UNSUP(1850), 2500, |
| 265 | UNSUP(2600), 2800, UNSUP(2850), UNSUP(3000), |
| 266 | UNSUP(3150), UNSUP(3150), UNSUP(3150), UNSUP(3150), |
| 267 | }; |
| 268 | static const u16 VAUX2_VSEL_table[] = { |
| 269 | 1700, 1700, 1900, 1300, |
| 270 | 1500, 1800, 2000, 2500, |
| 271 | 2100, 2800, 2200, 2300, |
| 272 | 2400, 2400, 2400, 2400, |
| 273 | }; |
| 274 | static const u16 VAUX3_VSEL_table[] = { |
| 275 | 1500, 1800, 2500, 2800, |
Adrian Hunter | d6bb69c | 2009-03-06 14:51:30 +0200 | [diff] [blame] | 276 | 3000, 3000, 3000, 3000, |
David Brownell | fa16a5c | 2009-02-08 10:37:06 -0800 | [diff] [blame] | 277 | }; |
| 278 | static const u16 VAUX4_VSEL_table[] = { |
| 279 | 700, 1000, 1200, UNSUP(1300), |
| 280 | 1500, 1800, UNSUP(1850), 2500, |
David Brownell | 1897e74 | 2009-03-10 11:51:15 -0800 | [diff] [blame] | 281 | UNSUP(2600), 2800, UNSUP(2850), UNSUP(3000), |
| 282 | UNSUP(3150), UNSUP(3150), UNSUP(3150), UNSUP(3150), |
David Brownell | fa16a5c | 2009-02-08 10:37:06 -0800 | [diff] [blame] | 283 | }; |
| 284 | static const u16 VMMC1_VSEL_table[] = { |
| 285 | 1850, 2850, 3000, 3150, |
| 286 | }; |
| 287 | static const u16 VMMC2_VSEL_table[] = { |
| 288 | UNSUP(1000), UNSUP(1000), UNSUP(1200), UNSUP(1300), |
| 289 | UNSUP(1500), UNSUP(1800), 1850, UNSUP(2500), |
| 290 | 2600, 2800, 2850, 3000, |
| 291 | 3150, 3150, 3150, 3150, |
| 292 | }; |
| 293 | static const u16 VPLL1_VSEL_table[] = { |
| 294 | 1000, 1200, 1300, 1800, |
| 295 | UNSUP(2800), UNSUP(3000), UNSUP(3000), UNSUP(3000), |
| 296 | }; |
| 297 | static const u16 VPLL2_VSEL_table[] = { |
| 298 | 700, 1000, 1200, 1300, |
| 299 | UNSUP(1500), 1800, UNSUP(1850), UNSUP(2500), |
| 300 | UNSUP(2600), UNSUP(2800), UNSUP(2850), UNSUP(3000), |
| 301 | UNSUP(3150), UNSUP(3150), UNSUP(3150), UNSUP(3150), |
| 302 | }; |
| 303 | static const u16 VSIM_VSEL_table[] = { |
| 304 | UNSUP(1000), UNSUP(1200), UNSUP(1300), 1800, |
| 305 | 2800, 3000, 3000, 3000, |
| 306 | }; |
| 307 | static const u16 VDAC_VSEL_table[] = { |
| 308 | 1200, 1300, 1800, 1800, |
| 309 | }; |
Juha Keski-Saari | 07fc493 | 2009-12-16 15:27:55 +0200 | [diff] [blame] | 310 | static const u16 VDD1_VSEL_table[] = { |
| 311 | 800, 1450, |
| 312 | }; |
| 313 | static const u16 VDD2_VSEL_table[] = { |
| 314 | 800, 1450, 1500, |
| 315 | }; |
| 316 | static const u16 VIO_VSEL_table[] = { |
| 317 | 1800, 1850, |
| 318 | }; |
| 319 | static const u16 VINTANA2_VSEL_table[] = { |
| 320 | 2500, 2750, |
| 321 | }; |
David Brownell | fa16a5c | 2009-02-08 10:37:06 -0800 | [diff] [blame] | 322 | |
Rajendra Nayak | 3e3d3be | 2010-04-22 14:18:32 +0530 | [diff] [blame] | 323 | static int twl4030ldo_list_voltage(struct regulator_dev *rdev, unsigned index) |
David Brownell | 66b659e | 2009-02-26 11:50:14 -0800 | [diff] [blame] | 324 | { |
| 325 | struct twlreg_info *info = rdev_get_drvdata(rdev); |
| 326 | int mV = info->table[index]; |
| 327 | |
| 328 | return IS_UNSUP(mV) ? 0 : (LDO_MV(mV) * 1000); |
| 329 | } |
| 330 | |
David Brownell | fa16a5c | 2009-02-08 10:37:06 -0800 | [diff] [blame] | 331 | static int |
Rajendra Nayak | 3e3d3be | 2010-04-22 14:18:32 +0530 | [diff] [blame] | 332 | twl4030ldo_set_voltage(struct regulator_dev *rdev, int min_uV, int max_uV) |
David Brownell | fa16a5c | 2009-02-08 10:37:06 -0800 | [diff] [blame] | 333 | { |
| 334 | struct twlreg_info *info = rdev_get_drvdata(rdev); |
| 335 | int vsel; |
| 336 | |
| 337 | for (vsel = 0; vsel < info->table_len; vsel++) { |
| 338 | int mV = info->table[vsel]; |
| 339 | int uV; |
| 340 | |
| 341 | if (IS_UNSUP(mV)) |
| 342 | continue; |
| 343 | uV = LDO_MV(mV) * 1000; |
| 344 | |
David Brownell | 66b659e | 2009-02-26 11:50:14 -0800 | [diff] [blame] | 345 | /* REVISIT for VAUX2, first match may not be best/lowest */ |
| 346 | |
David Brownell | fa16a5c | 2009-02-08 10:37:06 -0800 | [diff] [blame] | 347 | /* use the first in-range value */ |
| 348 | if (min_uV <= uV && uV <= max_uV) |
Rajendra Nayak | 441a450 | 2009-12-13 22:19:23 +0100 | [diff] [blame] | 349 | return twlreg_write(info, TWL_MODULE_PM_RECEIVER, |
| 350 | VREG_VOLTAGE, vsel); |
David Brownell | fa16a5c | 2009-02-08 10:37:06 -0800 | [diff] [blame] | 351 | } |
| 352 | |
| 353 | return -EDOM; |
| 354 | } |
| 355 | |
Rajendra Nayak | 3e3d3be | 2010-04-22 14:18:32 +0530 | [diff] [blame] | 356 | static int twl4030ldo_get_voltage(struct regulator_dev *rdev) |
David Brownell | fa16a5c | 2009-02-08 10:37:06 -0800 | [diff] [blame] | 357 | { |
| 358 | struct twlreg_info *info = rdev_get_drvdata(rdev); |
Rajendra Nayak | 441a450 | 2009-12-13 22:19:23 +0100 | [diff] [blame] | 359 | int vsel = twlreg_read(info, TWL_MODULE_PM_RECEIVER, |
| 360 | VREG_VOLTAGE); |
David Brownell | fa16a5c | 2009-02-08 10:37:06 -0800 | [diff] [blame] | 361 | |
| 362 | if (vsel < 0) |
| 363 | return vsel; |
| 364 | |
| 365 | vsel &= info->table_len - 1; |
| 366 | return LDO_MV(info->table[vsel]) * 1000; |
| 367 | } |
| 368 | |
Rajendra Nayak | 3e3d3be | 2010-04-22 14:18:32 +0530 | [diff] [blame] | 369 | static struct regulator_ops twl4030ldo_ops = { |
| 370 | .list_voltage = twl4030ldo_list_voltage, |
David Brownell | 66b659e | 2009-02-26 11:50:14 -0800 | [diff] [blame] | 371 | |
Rajendra Nayak | 3e3d3be | 2010-04-22 14:18:32 +0530 | [diff] [blame] | 372 | .set_voltage = twl4030ldo_set_voltage, |
| 373 | .get_voltage = twl4030ldo_get_voltage, |
| 374 | |
| 375 | .enable = twlreg_enable, |
| 376 | .disable = twlreg_disable, |
| 377 | .is_enabled = twlreg_is_enabled, |
| 378 | |
| 379 | .set_mode = twlreg_set_mode, |
| 380 | |
| 381 | .get_status = twlreg_get_status, |
| 382 | }; |
| 383 | |
| 384 | static int twl6030ldo_list_voltage(struct regulator_dev *rdev, unsigned index) |
| 385 | { |
| 386 | struct twlreg_info *info = rdev_get_drvdata(rdev); |
| 387 | |
| 388 | return ((info->min_mV + (index * 100)) * 1000); |
| 389 | } |
| 390 | |
| 391 | static int |
| 392 | twl6030ldo_set_voltage(struct regulator_dev *rdev, int min_uV, int max_uV) |
| 393 | { |
| 394 | struct twlreg_info *info = rdev_get_drvdata(rdev); |
| 395 | int vsel; |
| 396 | |
| 397 | if ((min_uV/1000 < info->min_mV) || (max_uV/1000 > info->max_mV)) |
| 398 | return -EDOM; |
| 399 | |
| 400 | /* |
| 401 | * Use the below formula to calculate vsel |
| 402 | * mV = 1000mv + 100mv * (vsel - 1) |
| 403 | */ |
| 404 | vsel = (min_uV/1000 - 1000)/100 + 1; |
| 405 | return twlreg_write(info, TWL_MODULE_PM_RECEIVER, VREG_VOLTAGE, vsel); |
| 406 | |
| 407 | } |
| 408 | |
| 409 | static int twl6030ldo_get_voltage(struct regulator_dev *rdev) |
| 410 | { |
| 411 | struct twlreg_info *info = rdev_get_drvdata(rdev); |
| 412 | int vsel = twlreg_read(info, TWL_MODULE_PM_RECEIVER, |
| 413 | VREG_VOLTAGE); |
| 414 | |
| 415 | if (vsel < 0) |
| 416 | return vsel; |
| 417 | |
| 418 | /* |
| 419 | * Use the below formula to calculate vsel |
| 420 | * mV = 1000mv + 100mv * (vsel - 1) |
| 421 | */ |
| 422 | return (1000 + (100 * (vsel - 1))) * 1000; |
| 423 | } |
| 424 | |
| 425 | static struct regulator_ops twl6030ldo_ops = { |
| 426 | .list_voltage = twl6030ldo_list_voltage, |
| 427 | |
| 428 | .set_voltage = twl6030ldo_set_voltage, |
| 429 | .get_voltage = twl6030ldo_get_voltage, |
David Brownell | fa16a5c | 2009-02-08 10:37:06 -0800 | [diff] [blame] | 430 | |
Rajendra Nayak | c4aa6f3 | 2009-12-13 21:36:49 +0100 | [diff] [blame] | 431 | .enable = twlreg_enable, |
| 432 | .disable = twlreg_disable, |
| 433 | .is_enabled = twlreg_is_enabled, |
David Brownell | fa16a5c | 2009-02-08 10:37:06 -0800 | [diff] [blame] | 434 | |
Rajendra Nayak | c4aa6f3 | 2009-12-13 21:36:49 +0100 | [diff] [blame] | 435 | .set_mode = twlreg_set_mode, |
David Brownell | fa16a5c | 2009-02-08 10:37:06 -0800 | [diff] [blame] | 436 | |
Rajendra Nayak | c4aa6f3 | 2009-12-13 21:36:49 +0100 | [diff] [blame] | 437 | .get_status = twlreg_get_status, |
David Brownell | fa16a5c | 2009-02-08 10:37:06 -0800 | [diff] [blame] | 438 | }; |
| 439 | |
| 440 | /*----------------------------------------------------------------------*/ |
| 441 | |
| 442 | /* |
| 443 | * Fixed voltage LDOs don't have a VSEL field to update. |
| 444 | */ |
Rajendra Nayak | c4aa6f3 | 2009-12-13 21:36:49 +0100 | [diff] [blame] | 445 | static int twlfixed_list_voltage(struct regulator_dev *rdev, unsigned index) |
David Brownell | 66b659e | 2009-02-26 11:50:14 -0800 | [diff] [blame] | 446 | { |
| 447 | struct twlreg_info *info = rdev_get_drvdata(rdev); |
| 448 | |
| 449 | return info->min_mV * 1000; |
| 450 | } |
| 451 | |
Rajendra Nayak | c4aa6f3 | 2009-12-13 21:36:49 +0100 | [diff] [blame] | 452 | static int twlfixed_get_voltage(struct regulator_dev *rdev) |
David Brownell | fa16a5c | 2009-02-08 10:37:06 -0800 | [diff] [blame] | 453 | { |
| 454 | struct twlreg_info *info = rdev_get_drvdata(rdev); |
| 455 | |
| 456 | return info->min_mV * 1000; |
| 457 | } |
| 458 | |
Rajendra Nayak | c4aa6f3 | 2009-12-13 21:36:49 +0100 | [diff] [blame] | 459 | static struct regulator_ops twlfixed_ops = { |
| 460 | .list_voltage = twlfixed_list_voltage, |
David Brownell | 66b659e | 2009-02-26 11:50:14 -0800 | [diff] [blame] | 461 | |
Rajendra Nayak | c4aa6f3 | 2009-12-13 21:36:49 +0100 | [diff] [blame] | 462 | .get_voltage = twlfixed_get_voltage, |
David Brownell | fa16a5c | 2009-02-08 10:37:06 -0800 | [diff] [blame] | 463 | |
Rajendra Nayak | c4aa6f3 | 2009-12-13 21:36:49 +0100 | [diff] [blame] | 464 | .enable = twlreg_enable, |
| 465 | .disable = twlreg_disable, |
| 466 | .is_enabled = twlreg_is_enabled, |
David Brownell | fa16a5c | 2009-02-08 10:37:06 -0800 | [diff] [blame] | 467 | |
Rajendra Nayak | c4aa6f3 | 2009-12-13 21:36:49 +0100 | [diff] [blame] | 468 | .set_mode = twlreg_set_mode, |
David Brownell | fa16a5c | 2009-02-08 10:37:06 -0800 | [diff] [blame] | 469 | |
Rajendra Nayak | c4aa6f3 | 2009-12-13 21:36:49 +0100 | [diff] [blame] | 470 | .get_status = twlreg_get_status, |
David Brownell | fa16a5c | 2009-02-08 10:37:06 -0800 | [diff] [blame] | 471 | }; |
| 472 | |
| 473 | /*----------------------------------------------------------------------*/ |
| 474 | |
Juha Keski-Saari | 045f972 | 2009-12-16 14:49:52 +0200 | [diff] [blame] | 475 | #define TWL4030_FIXED_LDO(label, offset, mVolts, num, turnon_delay, \ |
| 476 | remap_conf) \ |
| 477 | TWL_FIXED_LDO(label, offset, mVolts, num, turnon_delay, \ |
| 478 | remap_conf, TWL4030) |
Juha Keski-Saari | 045f972 | 2009-12-16 14:49:52 +0200 | [diff] [blame] | 479 | #define TWL6030_FIXED_LDO(label, offset, mVolts, num, turnon_delay, \ |
| 480 | remap_conf) \ |
| 481 | TWL_FIXED_LDO(label, offset, mVolts, num, turnon_delay, \ |
| 482 | remap_conf, TWL6030) |
Rajendra Nayak | c4aa6f3 | 2009-12-13 21:36:49 +0100 | [diff] [blame] | 483 | |
Rajendra Nayak | 3e3d3be | 2010-04-22 14:18:32 +0530 | [diff] [blame] | 484 | #define TWL4030_ADJUSTABLE_LDO(label, offset, num, turnon_delay, remap_conf) { \ |
David Brownell | fa16a5c | 2009-02-08 10:37:06 -0800 | [diff] [blame] | 485 | .base = offset, \ |
| 486 | .id = num, \ |
| 487 | .table_len = ARRAY_SIZE(label##_VSEL_table), \ |
| 488 | .table = label##_VSEL_table, \ |
Juha Keski-Saari | 045f972 | 2009-12-16 14:49:52 +0200 | [diff] [blame] | 489 | .delay = turnon_delay, \ |
| 490 | .remap = remap_conf, \ |
David Brownell | fa16a5c | 2009-02-08 10:37:06 -0800 | [diff] [blame] | 491 | .desc = { \ |
| 492 | .name = #label, \ |
Rajendra Nayak | 3e3d3be | 2010-04-22 14:18:32 +0530 | [diff] [blame] | 493 | .id = TWL4030_REG_##label, \ |
David Brownell | 66b659e | 2009-02-26 11:50:14 -0800 | [diff] [blame] | 494 | .n_voltages = ARRAY_SIZE(label##_VSEL_table), \ |
Rajendra Nayak | 3e3d3be | 2010-04-22 14:18:32 +0530 | [diff] [blame] | 495 | .ops = &twl4030ldo_ops, \ |
David Brownell | fa16a5c | 2009-02-08 10:37:06 -0800 | [diff] [blame] | 496 | .type = REGULATOR_VOLTAGE, \ |
| 497 | .owner = THIS_MODULE, \ |
| 498 | }, \ |
| 499 | } |
| 500 | |
Rajendra Nayak | 3e3d3be | 2010-04-22 14:18:32 +0530 | [diff] [blame] | 501 | #define TWL6030_ADJUSTABLE_LDO(label, offset, min_mVolts, max_mVolts, num, \ |
| 502 | remap_conf) { \ |
| 503 | .base = offset, \ |
| 504 | .id = num, \ |
| 505 | .min_mV = min_mVolts, \ |
| 506 | .max_mV = max_mVolts, \ |
| 507 | .remap = remap_conf, \ |
| 508 | .desc = { \ |
| 509 | .name = #label, \ |
| 510 | .id = TWL6030_REG_##label, \ |
| 511 | .n_voltages = (max_mVolts - min_mVolts)/100, \ |
| 512 | .ops = &twl6030ldo_ops, \ |
| 513 | .type = REGULATOR_VOLTAGE, \ |
| 514 | .owner = THIS_MODULE, \ |
| 515 | }, \ |
| 516 | } |
| 517 | |
| 518 | |
Juha Keski-Saari | 045f972 | 2009-12-16 14:49:52 +0200 | [diff] [blame] | 519 | #define TWL_FIXED_LDO(label, offset, mVolts, num, turnon_delay, remap_conf, \ |
| 520 | family) { \ |
David Brownell | fa16a5c | 2009-02-08 10:37:06 -0800 | [diff] [blame] | 521 | .base = offset, \ |
| 522 | .id = num, \ |
| 523 | .min_mV = mVolts, \ |
Juha Keski-Saari | 045f972 | 2009-12-16 14:49:52 +0200 | [diff] [blame] | 524 | .delay = turnon_delay, \ |
| 525 | .remap = remap_conf, \ |
David Brownell | fa16a5c | 2009-02-08 10:37:06 -0800 | [diff] [blame] | 526 | .desc = { \ |
| 527 | .name = #label, \ |
Rajendra Nayak | c4aa6f3 | 2009-12-13 21:36:49 +0100 | [diff] [blame] | 528 | .id = family##_REG_##label, \ |
David Brownell | 66b659e | 2009-02-26 11:50:14 -0800 | [diff] [blame] | 529 | .n_voltages = 1, \ |
Rajendra Nayak | c4aa6f3 | 2009-12-13 21:36:49 +0100 | [diff] [blame] | 530 | .ops = &twlfixed_ops, \ |
David Brownell | fa16a5c | 2009-02-08 10:37:06 -0800 | [diff] [blame] | 531 | .type = REGULATOR_VOLTAGE, \ |
| 532 | .owner = THIS_MODULE, \ |
| 533 | }, \ |
| 534 | } |
| 535 | |
| 536 | /* |
| 537 | * We list regulators here if systems need some level of |
| 538 | * software control over them after boot. |
| 539 | */ |
Rajendra Nayak | c4aa6f3 | 2009-12-13 21:36:49 +0100 | [diff] [blame] | 540 | static struct twlreg_info twl_regs[] = { |
Juha Keski-Saari | 045f972 | 2009-12-16 14:49:52 +0200 | [diff] [blame] | 541 | TWL4030_ADJUSTABLE_LDO(VAUX1, 0x17, 1, 100, 0x08), |
| 542 | TWL4030_ADJUSTABLE_LDO(VAUX2_4030, 0x1b, 2, 100, 0x08), |
| 543 | TWL4030_ADJUSTABLE_LDO(VAUX2, 0x1b, 2, 100, 0x08), |
| 544 | TWL4030_ADJUSTABLE_LDO(VAUX3, 0x1f, 3, 100, 0x08), |
| 545 | TWL4030_ADJUSTABLE_LDO(VAUX4, 0x23, 4, 100, 0x08), |
| 546 | TWL4030_ADJUSTABLE_LDO(VMMC1, 0x27, 5, 100, 0x08), |
| 547 | TWL4030_ADJUSTABLE_LDO(VMMC2, 0x2b, 6, 100, 0x08), |
| 548 | TWL4030_ADJUSTABLE_LDO(VPLL1, 0x2f, 7, 100, 0x00), |
| 549 | TWL4030_ADJUSTABLE_LDO(VPLL2, 0x33, 8, 100, 0x08), |
| 550 | TWL4030_ADJUSTABLE_LDO(VSIM, 0x37, 9, 100, 0x00), |
| 551 | TWL4030_ADJUSTABLE_LDO(VDAC, 0x3b, 10, 100, 0x08), |
| 552 | TWL4030_FIXED_LDO(VINTANA1, 0x3f, 1500, 11, 100, 0x08), |
| 553 | TWL4030_ADJUSTABLE_LDO(VINTANA2, 0x43, 12, 100, 0x08), |
| 554 | TWL4030_FIXED_LDO(VINTDIG, 0x47, 1500, 13, 100, 0x08), |
| 555 | TWL4030_ADJUSTABLE_LDO(VIO, 0x4b, 14, 1000, 0x08), |
| 556 | TWL4030_ADJUSTABLE_LDO(VDD1, 0x55, 15, 1000, 0x08), |
| 557 | TWL4030_ADJUSTABLE_LDO(VDD2, 0x63, 16, 1000, 0x08), |
| 558 | TWL4030_FIXED_LDO(VUSB1V5, 0x71, 1500, 17, 100, 0x08), |
| 559 | TWL4030_FIXED_LDO(VUSB1V8, 0x74, 1800, 18, 100, 0x08), |
| 560 | TWL4030_FIXED_LDO(VUSB3V1, 0x77, 3100, 19, 150, 0x08), |
David Brownell | fa16a5c | 2009-02-08 10:37:06 -0800 | [diff] [blame] | 561 | /* VUSBCP is managed *only* by the USB subchip */ |
Rajendra Nayak | 441a450 | 2009-12-13 22:19:23 +0100 | [diff] [blame] | 562 | |
| 563 | /* 6030 REG with base as PMC Slave Misc : 0x0030 */ |
Juha Keski-Saari | 045f972 | 2009-12-16 14:49:52 +0200 | [diff] [blame] | 564 | /* Turnon-delay and remap configuration values for 6030 are not |
| 565 | verified since the specification is not public */ |
Rajendra Nayak | 3e3d3be | 2010-04-22 14:18:32 +0530 | [diff] [blame] | 566 | TWL6030_ADJUSTABLE_LDO(VAUX1_6030, 0x54, 1000, 3300, 1, 0x21), |
| 567 | TWL6030_ADJUSTABLE_LDO(VAUX2_6030, 0x58, 1000, 3300, 2, 0x21), |
| 568 | TWL6030_ADJUSTABLE_LDO(VAUX3_6030, 0x5c, 1000, 3300, 3, 0x21), |
| 569 | TWL6030_ADJUSTABLE_LDO(VMMC, 0x68, 1000, 3300, 4, 0x21), |
| 570 | TWL6030_ADJUSTABLE_LDO(VPP, 0x6c, 1000, 3300, 5, 0x21), |
| 571 | TWL6030_ADJUSTABLE_LDO(VUSIM, 0x74, 1000, 3300, 7, 0x21), |
Rajendra Nayak | 2ebcf63 | 2010-02-17 20:54:15 +0530 | [diff] [blame] | 572 | TWL6030_FIXED_LDO(VANA, 0x50, 2100, 15, 0, 0x21), |
| 573 | TWL6030_FIXED_LDO(VCXIO, 0x60, 1800, 16, 0, 0x21), |
| 574 | TWL6030_FIXED_LDO(VDAC, 0x64, 1800, 17, 0, 0x21), |
| 575 | TWL6030_FIXED_LDO(VUSB, 0x70, 3300, 18, 0, 0x21) |
David Brownell | fa16a5c | 2009-02-08 10:37:06 -0800 | [diff] [blame] | 576 | }; |
| 577 | |
Dmitry Torokhov | 24c2902 | 2010-02-23 23:38:01 -0800 | [diff] [blame] | 578 | static int __devinit twlreg_probe(struct platform_device *pdev) |
David Brownell | fa16a5c | 2009-02-08 10:37:06 -0800 | [diff] [blame] | 579 | { |
| 580 | int i; |
| 581 | struct twlreg_info *info; |
| 582 | struct regulator_init_data *initdata; |
| 583 | struct regulation_constraints *c; |
| 584 | struct regulator_dev *rdev; |
David Brownell | fa16a5c | 2009-02-08 10:37:06 -0800 | [diff] [blame] | 585 | |
Rajendra Nayak | c4aa6f3 | 2009-12-13 21:36:49 +0100 | [diff] [blame] | 586 | for (i = 0, info = NULL; i < ARRAY_SIZE(twl_regs); i++) { |
| 587 | if (twl_regs[i].desc.id != pdev->id) |
David Brownell | fa16a5c | 2009-02-08 10:37:06 -0800 | [diff] [blame] | 588 | continue; |
Rajendra Nayak | c4aa6f3 | 2009-12-13 21:36:49 +0100 | [diff] [blame] | 589 | info = twl_regs + i; |
David Brownell | fa16a5c | 2009-02-08 10:37:06 -0800 | [diff] [blame] | 590 | break; |
| 591 | } |
| 592 | if (!info) |
| 593 | return -ENODEV; |
| 594 | |
| 595 | initdata = pdev->dev.platform_data; |
| 596 | if (!initdata) |
| 597 | return -EINVAL; |
| 598 | |
| 599 | /* Constrain board-specific capabilities according to what |
| 600 | * this driver and the chip itself can actually do. |
| 601 | */ |
| 602 | c = &initdata->constraints; |
David Brownell | fa16a5c | 2009-02-08 10:37:06 -0800 | [diff] [blame] | 603 | c->valid_modes_mask &= REGULATOR_MODE_NORMAL | REGULATOR_MODE_STANDBY; |
| 604 | c->valid_ops_mask &= REGULATOR_CHANGE_VOLTAGE |
| 605 | | REGULATOR_CHANGE_MODE |
| 606 | | REGULATOR_CHANGE_STATUS; |
Juha Keski-Saari | 205e5cd | 2009-12-16 15:27:56 +0200 | [diff] [blame] | 607 | switch (pdev->id) { |
| 608 | case TWL4030_REG_VIO: |
| 609 | case TWL4030_REG_VDD1: |
| 610 | case TWL4030_REG_VDD2: |
| 611 | case TWL4030_REG_VPLL1: |
| 612 | case TWL4030_REG_VINTANA1: |
| 613 | case TWL4030_REG_VINTANA2: |
| 614 | case TWL4030_REG_VINTDIG: |
| 615 | c->always_on = true; |
| 616 | break; |
| 617 | default: |
| 618 | break; |
| 619 | } |
David Brownell | fa16a5c | 2009-02-08 10:37:06 -0800 | [diff] [blame] | 620 | |
| 621 | rdev = regulator_register(&info->desc, &pdev->dev, initdata, info); |
| 622 | if (IS_ERR(rdev)) { |
| 623 | dev_err(&pdev->dev, "can't register %s, %ld\n", |
| 624 | info->desc.name, PTR_ERR(rdev)); |
| 625 | return PTR_ERR(rdev); |
| 626 | } |
| 627 | platform_set_drvdata(pdev, rdev); |
| 628 | |
Juha Keski-Saari | 30010fa | 2009-12-16 15:27:58 +0200 | [diff] [blame] | 629 | twlreg_write(info, TWL_MODULE_PM_RECEIVER, VREG_REMAP, |
| 630 | info->remap); |
| 631 | |
David Brownell | fa16a5c | 2009-02-08 10:37:06 -0800 | [diff] [blame] | 632 | /* NOTE: many regulators support short-circuit IRQs (presentable |
| 633 | * as REGULATOR_OVER_CURRENT notifications?) configured via: |
| 634 | * - SC_CONFIG |
| 635 | * - SC_DETECT1 (vintana2, vmmc1/2, vaux1/2/3/4) |
| 636 | * - SC_DETECT2 (vusb, vdac, vio, vdd1/2, vpll2) |
| 637 | * - IT_CONFIG |
| 638 | */ |
| 639 | |
| 640 | return 0; |
| 641 | } |
| 642 | |
Rajendra Nayak | c4aa6f3 | 2009-12-13 21:36:49 +0100 | [diff] [blame] | 643 | static int __devexit twlreg_remove(struct platform_device *pdev) |
David Brownell | fa16a5c | 2009-02-08 10:37:06 -0800 | [diff] [blame] | 644 | { |
| 645 | regulator_unregister(platform_get_drvdata(pdev)); |
| 646 | return 0; |
| 647 | } |
| 648 | |
Rajendra Nayak | c4aa6f3 | 2009-12-13 21:36:49 +0100 | [diff] [blame] | 649 | MODULE_ALIAS("platform:twl_reg"); |
David Brownell | fa16a5c | 2009-02-08 10:37:06 -0800 | [diff] [blame] | 650 | |
Rajendra Nayak | c4aa6f3 | 2009-12-13 21:36:49 +0100 | [diff] [blame] | 651 | static struct platform_driver twlreg_driver = { |
| 652 | .probe = twlreg_probe, |
| 653 | .remove = __devexit_p(twlreg_remove), |
David Brownell | fa16a5c | 2009-02-08 10:37:06 -0800 | [diff] [blame] | 654 | /* NOTE: short name, to work around driver model truncation of |
Rajendra Nayak | c4aa6f3 | 2009-12-13 21:36:49 +0100 | [diff] [blame] | 655 | * "twl_regulator.12" (and friends) to "twl_regulator.1". |
David Brownell | fa16a5c | 2009-02-08 10:37:06 -0800 | [diff] [blame] | 656 | */ |
Rajendra Nayak | c4aa6f3 | 2009-12-13 21:36:49 +0100 | [diff] [blame] | 657 | .driver.name = "twl_reg", |
David Brownell | fa16a5c | 2009-02-08 10:37:06 -0800 | [diff] [blame] | 658 | .driver.owner = THIS_MODULE, |
| 659 | }; |
| 660 | |
Rajendra Nayak | c4aa6f3 | 2009-12-13 21:36:49 +0100 | [diff] [blame] | 661 | static int __init twlreg_init(void) |
David Brownell | fa16a5c | 2009-02-08 10:37:06 -0800 | [diff] [blame] | 662 | { |
Rajendra Nayak | c4aa6f3 | 2009-12-13 21:36:49 +0100 | [diff] [blame] | 663 | return platform_driver_register(&twlreg_driver); |
David Brownell | fa16a5c | 2009-02-08 10:37:06 -0800 | [diff] [blame] | 664 | } |
Rajendra Nayak | c4aa6f3 | 2009-12-13 21:36:49 +0100 | [diff] [blame] | 665 | subsys_initcall(twlreg_init); |
David Brownell | fa16a5c | 2009-02-08 10:37:06 -0800 | [diff] [blame] | 666 | |
Rajendra Nayak | c4aa6f3 | 2009-12-13 21:36:49 +0100 | [diff] [blame] | 667 | static void __exit twlreg_exit(void) |
David Brownell | fa16a5c | 2009-02-08 10:37:06 -0800 | [diff] [blame] | 668 | { |
Rajendra Nayak | c4aa6f3 | 2009-12-13 21:36:49 +0100 | [diff] [blame] | 669 | platform_driver_unregister(&twlreg_driver); |
David Brownell | fa16a5c | 2009-02-08 10:37:06 -0800 | [diff] [blame] | 670 | } |
Rajendra Nayak | c4aa6f3 | 2009-12-13 21:36:49 +0100 | [diff] [blame] | 671 | module_exit(twlreg_exit) |
David Brownell | fa16a5c | 2009-02-08 10:37:06 -0800 | [diff] [blame] | 672 | |
Rajendra Nayak | c4aa6f3 | 2009-12-13 21:36:49 +0100 | [diff] [blame] | 673 | MODULE_DESCRIPTION("TWL regulator driver"); |
David Brownell | fa16a5c | 2009-02-08 10:37:06 -0800 | [diff] [blame] | 674 | MODULE_LICENSE("GPL"); |