Misael Lopez Cruz | f19b282 | 2011-04-27 02:14:07 -0500 | [diff] [blame] | 1 | /* |
| 2 | * MFD driver for TWL6040 audio device |
| 3 | * |
| 4 | * Authors: Misael Lopez Cruz <misael.lopez@ti.com> |
| 5 | * Jorge Eduardo Candelaria <jorge.candelaria@ti.com> |
| 6 | * Peter Ujfalusi <peter.ujfalusi@ti.com> |
| 7 | * |
| 8 | * Copyright: (C) 2011 Texas Instruments, Inc. |
| 9 | * |
| 10 | * This program is free software; you can redistribute it and/or modify |
| 11 | * it under the terms of the GNU General Public License version 2 as |
| 12 | * published by the Free Software Foundation. |
| 13 | * |
| 14 | * This program is distributed in the hope that it will be useful, but |
| 15 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
| 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 17 | * General Public License for more details. |
| 18 | * |
| 19 | * You should have received a copy of the GNU General Public License |
| 20 | * along with this program; if not, write to the Free Software |
| 21 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA |
| 22 | * 02110-1301 USA |
| 23 | * |
| 24 | */ |
| 25 | |
| 26 | #include <linux/module.h> |
| 27 | #include <linux/types.h> |
| 28 | #include <linux/slab.h> |
| 29 | #include <linux/kernel.h> |
Peter Ujfalusi | 5af7df6 | 2012-05-02 16:54:42 +0300 | [diff] [blame] | 30 | #include <linux/err.h> |
Misael Lopez Cruz | f19b282 | 2011-04-27 02:14:07 -0500 | [diff] [blame] | 31 | #include <linux/platform_device.h> |
Peter Ujfalusi | 37e13ce | 2012-05-16 14:11:58 +0300 | [diff] [blame] | 32 | #include <linux/of.h> |
| 33 | #include <linux/of_irq.h> |
| 34 | #include <linux/of_gpio.h> |
| 35 | #include <linux/of_platform.h> |
Misael Lopez Cruz | f19b282 | 2011-04-27 02:14:07 -0500 | [diff] [blame] | 36 | #include <linux/gpio.h> |
| 37 | #include <linux/delay.h> |
Peter Ujfalusi | 8eaeb93 | 2012-04-03 11:56:51 +0300 | [diff] [blame] | 38 | #include <linux/i2c.h> |
| 39 | #include <linux/regmap.h> |
| 40 | #include <linux/err.h> |
Misael Lopez Cruz | f19b282 | 2011-04-27 02:14:07 -0500 | [diff] [blame] | 41 | #include <linux/mfd/core.h> |
| 42 | #include <linux/mfd/twl6040.h> |
Peter Ujfalusi | 5af7df6 | 2012-05-02 16:54:42 +0300 | [diff] [blame] | 43 | #include <linux/regulator/consumer.h> |
Misael Lopez Cruz | f19b282 | 2011-04-27 02:14:07 -0500 | [diff] [blame] | 44 | |
Peter Ujfalusi | 31b402e | 2011-10-12 11:57:54 +0300 | [diff] [blame] | 45 | #define VIBRACTRL_MEMBER(reg) ((reg == TWL6040_REG_VIBCTLL) ? 0 : 1) |
Peter Ujfalusi | 5af7df6 | 2012-05-02 16:54:42 +0300 | [diff] [blame] | 46 | #define TWL6040_NUM_SUPPLIES (2) |
Peter Ujfalusi | 31b402e | 2011-10-12 11:57:54 +0300 | [diff] [blame] | 47 | |
Samuel Ortiz | ca2cad6 | 2012-05-23 16:23:21 +0200 | [diff] [blame] | 48 | static bool twl6040_has_vibra(struct twl6040_platform_data *pdata, |
| 49 | struct device_node *node) |
| 50 | { |
| 51 | if (pdata && pdata->vibra) |
| 52 | return true; |
| 53 | |
| 54 | #ifdef CONFIG_OF |
| 55 | if (of_find_node_by_name(node, "vibra")) |
| 56 | return true; |
| 57 | #endif |
| 58 | |
| 59 | return false; |
| 60 | } |
| 61 | |
Misael Lopez Cruz | f19b282 | 2011-04-27 02:14:07 -0500 | [diff] [blame] | 62 | int twl6040_reg_read(struct twl6040 *twl6040, unsigned int reg) |
| 63 | { |
| 64 | int ret; |
Peter Ujfalusi | 8eaeb93 | 2012-04-03 11:56:51 +0300 | [diff] [blame] | 65 | unsigned int val; |
Misael Lopez Cruz | f19b282 | 2011-04-27 02:14:07 -0500 | [diff] [blame] | 66 | |
| 67 | mutex_lock(&twl6040->io_mutex); |
Peter Ujfalusi | 31b402e | 2011-10-12 11:57:54 +0300 | [diff] [blame] | 68 | /* Vibra control registers from cache */ |
| 69 | if (unlikely(reg == TWL6040_REG_VIBCTLL || |
| 70 | reg == TWL6040_REG_VIBCTLR)) { |
| 71 | val = twl6040->vibra_ctrl_cache[VIBRACTRL_MEMBER(reg)]; |
| 72 | } else { |
Peter Ujfalusi | 8eaeb93 | 2012-04-03 11:56:51 +0300 | [diff] [blame] | 73 | ret = regmap_read(twl6040->regmap, reg, &val); |
Peter Ujfalusi | 31b402e | 2011-10-12 11:57:54 +0300 | [diff] [blame] | 74 | if (ret < 0) { |
| 75 | mutex_unlock(&twl6040->io_mutex); |
| 76 | return ret; |
| 77 | } |
Misael Lopez Cruz | f19b282 | 2011-04-27 02:14:07 -0500 | [diff] [blame] | 78 | } |
| 79 | mutex_unlock(&twl6040->io_mutex); |
| 80 | |
| 81 | return val; |
| 82 | } |
| 83 | EXPORT_SYMBOL(twl6040_reg_read); |
| 84 | |
| 85 | int twl6040_reg_write(struct twl6040 *twl6040, unsigned int reg, u8 val) |
| 86 | { |
| 87 | int ret; |
| 88 | |
| 89 | mutex_lock(&twl6040->io_mutex); |
Peter Ujfalusi | 8eaeb93 | 2012-04-03 11:56:51 +0300 | [diff] [blame] | 90 | ret = regmap_write(twl6040->regmap, reg, val); |
Peter Ujfalusi | 31b402e | 2011-10-12 11:57:54 +0300 | [diff] [blame] | 91 | /* Cache the vibra control registers */ |
| 92 | if (reg == TWL6040_REG_VIBCTLL || reg == TWL6040_REG_VIBCTLR) |
| 93 | twl6040->vibra_ctrl_cache[VIBRACTRL_MEMBER(reg)] = val; |
Misael Lopez Cruz | f19b282 | 2011-04-27 02:14:07 -0500 | [diff] [blame] | 94 | mutex_unlock(&twl6040->io_mutex); |
| 95 | |
| 96 | return ret; |
| 97 | } |
| 98 | EXPORT_SYMBOL(twl6040_reg_write); |
| 99 | |
| 100 | int twl6040_set_bits(struct twl6040 *twl6040, unsigned int reg, u8 mask) |
| 101 | { |
| 102 | int ret; |
Misael Lopez Cruz | f19b282 | 2011-04-27 02:14:07 -0500 | [diff] [blame] | 103 | |
| 104 | mutex_lock(&twl6040->io_mutex); |
Peter Ujfalusi | 8eaeb93 | 2012-04-03 11:56:51 +0300 | [diff] [blame] | 105 | ret = regmap_update_bits(twl6040->regmap, reg, mask, mask); |
Misael Lopez Cruz | f19b282 | 2011-04-27 02:14:07 -0500 | [diff] [blame] | 106 | mutex_unlock(&twl6040->io_mutex); |
| 107 | return ret; |
| 108 | } |
| 109 | EXPORT_SYMBOL(twl6040_set_bits); |
| 110 | |
| 111 | int twl6040_clear_bits(struct twl6040 *twl6040, unsigned int reg, u8 mask) |
| 112 | { |
| 113 | int ret; |
Misael Lopez Cruz | f19b282 | 2011-04-27 02:14:07 -0500 | [diff] [blame] | 114 | |
| 115 | mutex_lock(&twl6040->io_mutex); |
Peter Ujfalusi | 8eaeb93 | 2012-04-03 11:56:51 +0300 | [diff] [blame] | 116 | ret = regmap_update_bits(twl6040->regmap, reg, mask, 0); |
Misael Lopez Cruz | f19b282 | 2011-04-27 02:14:07 -0500 | [diff] [blame] | 117 | mutex_unlock(&twl6040->io_mutex); |
| 118 | return ret; |
| 119 | } |
| 120 | EXPORT_SYMBOL(twl6040_clear_bits); |
| 121 | |
| 122 | /* twl6040 codec manual power-up sequence */ |
| 123 | static int twl6040_power_up(struct twl6040 *twl6040) |
| 124 | { |
| 125 | u8 ldoctl, ncpctl, lppllctl; |
| 126 | int ret; |
| 127 | |
| 128 | /* enable high-side LDO, reference system and internal oscillator */ |
| 129 | ldoctl = TWL6040_HSLDOENA | TWL6040_REFENA | TWL6040_OSCENA; |
| 130 | ret = twl6040_reg_write(twl6040, TWL6040_REG_LDOCTL, ldoctl); |
| 131 | if (ret) |
| 132 | return ret; |
| 133 | usleep_range(10000, 10500); |
| 134 | |
| 135 | /* enable negative charge pump */ |
| 136 | ncpctl = TWL6040_NCPENA; |
| 137 | ret = twl6040_reg_write(twl6040, TWL6040_REG_NCPCTL, ncpctl); |
| 138 | if (ret) |
| 139 | goto ncp_err; |
| 140 | usleep_range(1000, 1500); |
| 141 | |
| 142 | /* enable low-side LDO */ |
| 143 | ldoctl |= TWL6040_LSLDOENA; |
| 144 | ret = twl6040_reg_write(twl6040, TWL6040_REG_LDOCTL, ldoctl); |
| 145 | if (ret) |
| 146 | goto lsldo_err; |
| 147 | usleep_range(1000, 1500); |
| 148 | |
| 149 | /* enable low-power PLL */ |
| 150 | lppllctl = TWL6040_LPLLENA; |
| 151 | ret = twl6040_reg_write(twl6040, TWL6040_REG_LPPLLCTL, lppllctl); |
| 152 | if (ret) |
| 153 | goto lppll_err; |
| 154 | usleep_range(5000, 5500); |
| 155 | |
| 156 | /* disable internal oscillator */ |
| 157 | ldoctl &= ~TWL6040_OSCENA; |
| 158 | ret = twl6040_reg_write(twl6040, TWL6040_REG_LDOCTL, ldoctl); |
| 159 | if (ret) |
| 160 | goto osc_err; |
| 161 | |
| 162 | return 0; |
| 163 | |
| 164 | osc_err: |
| 165 | lppllctl &= ~TWL6040_LPLLENA; |
| 166 | twl6040_reg_write(twl6040, TWL6040_REG_LPPLLCTL, lppllctl); |
| 167 | lppll_err: |
| 168 | ldoctl &= ~TWL6040_LSLDOENA; |
| 169 | twl6040_reg_write(twl6040, TWL6040_REG_LDOCTL, ldoctl); |
| 170 | lsldo_err: |
| 171 | ncpctl &= ~TWL6040_NCPENA; |
| 172 | twl6040_reg_write(twl6040, TWL6040_REG_NCPCTL, ncpctl); |
| 173 | ncp_err: |
| 174 | ldoctl &= ~(TWL6040_HSLDOENA | TWL6040_REFENA | TWL6040_OSCENA); |
| 175 | twl6040_reg_write(twl6040, TWL6040_REG_LDOCTL, ldoctl); |
| 176 | |
| 177 | return ret; |
| 178 | } |
| 179 | |
| 180 | /* twl6040 manual power-down sequence */ |
| 181 | static void twl6040_power_down(struct twl6040 *twl6040) |
| 182 | { |
| 183 | u8 ncpctl, ldoctl, lppllctl; |
| 184 | |
| 185 | ncpctl = twl6040_reg_read(twl6040, TWL6040_REG_NCPCTL); |
| 186 | ldoctl = twl6040_reg_read(twl6040, TWL6040_REG_LDOCTL); |
| 187 | lppllctl = twl6040_reg_read(twl6040, TWL6040_REG_LPPLLCTL); |
| 188 | |
| 189 | /* enable internal oscillator */ |
| 190 | ldoctl |= TWL6040_OSCENA; |
| 191 | twl6040_reg_write(twl6040, TWL6040_REG_LDOCTL, ldoctl); |
| 192 | usleep_range(1000, 1500); |
| 193 | |
| 194 | /* disable low-power PLL */ |
| 195 | lppllctl &= ~TWL6040_LPLLENA; |
| 196 | twl6040_reg_write(twl6040, TWL6040_REG_LPPLLCTL, lppllctl); |
| 197 | |
| 198 | /* disable low-side LDO */ |
| 199 | ldoctl &= ~TWL6040_LSLDOENA; |
| 200 | twl6040_reg_write(twl6040, TWL6040_REG_LDOCTL, ldoctl); |
| 201 | |
| 202 | /* disable negative charge pump */ |
| 203 | ncpctl &= ~TWL6040_NCPENA; |
| 204 | twl6040_reg_write(twl6040, TWL6040_REG_NCPCTL, ncpctl); |
| 205 | |
| 206 | /* disable high-side LDO, reference system and internal oscillator */ |
| 207 | ldoctl &= ~(TWL6040_HSLDOENA | TWL6040_REFENA | TWL6040_OSCENA); |
| 208 | twl6040_reg_write(twl6040, TWL6040_REG_LDOCTL, ldoctl); |
| 209 | } |
| 210 | |
| 211 | static irqreturn_t twl6040_naudint_handler(int irq, void *data) |
| 212 | { |
| 213 | struct twl6040 *twl6040 = data; |
| 214 | u8 intid, status; |
| 215 | |
| 216 | intid = twl6040_reg_read(twl6040, TWL6040_REG_INTID); |
| 217 | |
| 218 | if (intid & TWL6040_READYINT) |
| 219 | complete(&twl6040->ready); |
| 220 | |
| 221 | if (intid & TWL6040_THINT) { |
| 222 | status = twl6040_reg_read(twl6040, TWL6040_REG_STATUS); |
| 223 | if (status & TWL6040_TSHUTDET) { |
Peter Ujfalusi | 2d7c957 | 2011-09-15 15:39:23 +0300 | [diff] [blame] | 224 | dev_warn(twl6040->dev, |
Misael Lopez Cruz | f19b282 | 2011-04-27 02:14:07 -0500 | [diff] [blame] | 225 | "Thermal shutdown, powering-off"); |
| 226 | twl6040_power(twl6040, 0); |
| 227 | } else { |
Peter Ujfalusi | 2d7c957 | 2011-09-15 15:39:23 +0300 | [diff] [blame] | 228 | dev_warn(twl6040->dev, |
Misael Lopez Cruz | f19b282 | 2011-04-27 02:14:07 -0500 | [diff] [blame] | 229 | "Leaving thermal shutdown, powering-on"); |
| 230 | twl6040_power(twl6040, 1); |
| 231 | } |
| 232 | } |
| 233 | |
| 234 | return IRQ_HANDLED; |
| 235 | } |
| 236 | |
| 237 | static int twl6040_power_up_completion(struct twl6040 *twl6040, |
| 238 | int naudint) |
| 239 | { |
| 240 | int time_left; |
| 241 | u8 intid; |
| 242 | |
| 243 | time_left = wait_for_completion_timeout(&twl6040->ready, |
| 244 | msecs_to_jiffies(144)); |
| 245 | if (!time_left) { |
| 246 | intid = twl6040_reg_read(twl6040, TWL6040_REG_INTID); |
| 247 | if (!(intid & TWL6040_READYINT)) { |
Peter Ujfalusi | 2d7c957 | 2011-09-15 15:39:23 +0300 | [diff] [blame] | 248 | dev_err(twl6040->dev, |
Misael Lopez Cruz | f19b282 | 2011-04-27 02:14:07 -0500 | [diff] [blame] | 249 | "timeout waiting for READYINT\n"); |
| 250 | return -ETIMEDOUT; |
| 251 | } |
| 252 | } |
| 253 | |
| 254 | return 0; |
| 255 | } |
| 256 | |
| 257 | int twl6040_power(struct twl6040 *twl6040, int on) |
| 258 | { |
| 259 | int audpwron = twl6040->audpwron; |
| 260 | int naudint = twl6040->irq; |
| 261 | int ret = 0; |
| 262 | |
| 263 | mutex_lock(&twl6040->mutex); |
| 264 | |
| 265 | if (on) { |
| 266 | /* already powered-up */ |
| 267 | if (twl6040->power_count++) |
| 268 | goto out; |
| 269 | |
| 270 | if (gpio_is_valid(audpwron)) { |
| 271 | /* use AUDPWRON line */ |
| 272 | gpio_set_value(audpwron, 1); |
| 273 | /* wait for power-up completion */ |
| 274 | ret = twl6040_power_up_completion(twl6040, naudint); |
| 275 | if (ret) { |
Peter Ujfalusi | 2d7c957 | 2011-09-15 15:39:23 +0300 | [diff] [blame] | 276 | dev_err(twl6040->dev, |
Misael Lopez Cruz | f19b282 | 2011-04-27 02:14:07 -0500 | [diff] [blame] | 277 | "automatic power-down failed\n"); |
| 278 | twl6040->power_count = 0; |
| 279 | goto out; |
| 280 | } |
| 281 | } else { |
| 282 | /* use manual power-up sequence */ |
| 283 | ret = twl6040_power_up(twl6040); |
| 284 | if (ret) { |
Peter Ujfalusi | 2d7c957 | 2011-09-15 15:39:23 +0300 | [diff] [blame] | 285 | dev_err(twl6040->dev, |
Misael Lopez Cruz | f19b282 | 2011-04-27 02:14:07 -0500 | [diff] [blame] | 286 | "manual power-up failed\n"); |
| 287 | twl6040->power_count = 0; |
| 288 | goto out; |
| 289 | } |
| 290 | } |
Peter Ujfalusi | cfb7a33 | 2011-07-04 10:28:28 +0300 | [diff] [blame] | 291 | /* Default PLL configuration after power up */ |
| 292 | twl6040->pll = TWL6040_SYSCLK_SEL_LPPLL; |
Misael Lopez Cruz | f19b282 | 2011-04-27 02:14:07 -0500 | [diff] [blame] | 293 | twl6040->sysclk = 19200000; |
Peter Ujfalusi | f8447d6 | 2012-01-14 20:58:43 +0100 | [diff] [blame] | 294 | twl6040->mclk = 32768; |
Misael Lopez Cruz | f19b282 | 2011-04-27 02:14:07 -0500 | [diff] [blame] | 295 | } else { |
| 296 | /* already powered-down */ |
| 297 | if (!twl6040->power_count) { |
Peter Ujfalusi | 2d7c957 | 2011-09-15 15:39:23 +0300 | [diff] [blame] | 298 | dev_err(twl6040->dev, |
Misael Lopez Cruz | f19b282 | 2011-04-27 02:14:07 -0500 | [diff] [blame] | 299 | "device is already powered-off\n"); |
| 300 | ret = -EPERM; |
| 301 | goto out; |
| 302 | } |
| 303 | |
| 304 | if (--twl6040->power_count) |
| 305 | goto out; |
| 306 | |
| 307 | if (gpio_is_valid(audpwron)) { |
| 308 | /* use AUDPWRON line */ |
| 309 | gpio_set_value(audpwron, 0); |
| 310 | |
| 311 | /* power-down sequence latency */ |
| 312 | usleep_range(500, 700); |
| 313 | } else { |
| 314 | /* use manual power-down sequence */ |
| 315 | twl6040_power_down(twl6040); |
| 316 | } |
Misael Lopez Cruz | f19b282 | 2011-04-27 02:14:07 -0500 | [diff] [blame] | 317 | twl6040->sysclk = 0; |
Peter Ujfalusi | f8447d6 | 2012-01-14 20:58:43 +0100 | [diff] [blame] | 318 | twl6040->mclk = 0; |
Misael Lopez Cruz | f19b282 | 2011-04-27 02:14:07 -0500 | [diff] [blame] | 319 | } |
| 320 | |
| 321 | out: |
| 322 | mutex_unlock(&twl6040->mutex); |
| 323 | return ret; |
| 324 | } |
| 325 | EXPORT_SYMBOL(twl6040_power); |
| 326 | |
Peter Ujfalusi | cfb7a33 | 2011-07-04 10:28:28 +0300 | [diff] [blame] | 327 | int twl6040_set_pll(struct twl6040 *twl6040, int pll_id, |
Misael Lopez Cruz | f19b282 | 2011-04-27 02:14:07 -0500 | [diff] [blame] | 328 | unsigned int freq_in, unsigned int freq_out) |
| 329 | { |
| 330 | u8 hppllctl, lppllctl; |
| 331 | int ret = 0; |
| 332 | |
| 333 | mutex_lock(&twl6040->mutex); |
| 334 | |
| 335 | hppllctl = twl6040_reg_read(twl6040, TWL6040_REG_HPPLLCTL); |
| 336 | lppllctl = twl6040_reg_read(twl6040, TWL6040_REG_LPPLLCTL); |
| 337 | |
Peter Ujfalusi | 2bd05db | 2012-01-14 20:58:44 +0100 | [diff] [blame] | 338 | /* Force full reconfiguration when switching between PLL */ |
| 339 | if (pll_id != twl6040->pll) { |
| 340 | twl6040->sysclk = 0; |
| 341 | twl6040->mclk = 0; |
| 342 | } |
| 343 | |
Peter Ujfalusi | cfb7a33 | 2011-07-04 10:28:28 +0300 | [diff] [blame] | 344 | switch (pll_id) { |
| 345 | case TWL6040_SYSCLK_SEL_LPPLL: |
Misael Lopez Cruz | f19b282 | 2011-04-27 02:14:07 -0500 | [diff] [blame] | 346 | /* low-power PLL divider */ |
Peter Ujfalusi | 2bd05db | 2012-01-14 20:58:44 +0100 | [diff] [blame] | 347 | /* Change the sysclk configuration only if it has been canged */ |
| 348 | if (twl6040->sysclk != freq_out) { |
| 349 | switch (freq_out) { |
| 350 | case 17640000: |
| 351 | lppllctl |= TWL6040_LPLLFIN; |
| 352 | break; |
| 353 | case 19200000: |
| 354 | lppllctl &= ~TWL6040_LPLLFIN; |
| 355 | break; |
| 356 | default: |
| 357 | dev_err(twl6040->dev, |
| 358 | "freq_out %d not supported\n", |
| 359 | freq_out); |
| 360 | ret = -EINVAL; |
| 361 | goto pll_out; |
| 362 | } |
| 363 | twl6040_reg_write(twl6040, TWL6040_REG_LPPLLCTL, |
| 364 | lppllctl); |
Misael Lopez Cruz | f19b282 | 2011-04-27 02:14:07 -0500 | [diff] [blame] | 365 | } |
Peter Ujfalusi | 2bd05db | 2012-01-14 20:58:44 +0100 | [diff] [blame] | 366 | |
| 367 | /* The PLL in use has not been change, we can exit */ |
| 368 | if (twl6040->pll == pll_id) |
| 369 | break; |
Misael Lopez Cruz | f19b282 | 2011-04-27 02:14:07 -0500 | [diff] [blame] | 370 | |
| 371 | switch (freq_in) { |
| 372 | case 32768: |
| 373 | lppllctl |= TWL6040_LPLLENA; |
| 374 | twl6040_reg_write(twl6040, TWL6040_REG_LPPLLCTL, |
| 375 | lppllctl); |
| 376 | mdelay(5); |
| 377 | lppllctl &= ~TWL6040_HPLLSEL; |
| 378 | twl6040_reg_write(twl6040, TWL6040_REG_LPPLLCTL, |
| 379 | lppllctl); |
| 380 | hppllctl &= ~TWL6040_HPLLENA; |
| 381 | twl6040_reg_write(twl6040, TWL6040_REG_HPPLLCTL, |
| 382 | hppllctl); |
| 383 | break; |
| 384 | default: |
Peter Ujfalusi | 2d7c957 | 2011-09-15 15:39:23 +0300 | [diff] [blame] | 385 | dev_err(twl6040->dev, |
Misael Lopez Cruz | f19b282 | 2011-04-27 02:14:07 -0500 | [diff] [blame] | 386 | "freq_in %d not supported\n", freq_in); |
| 387 | ret = -EINVAL; |
| 388 | goto pll_out; |
| 389 | } |
Misael Lopez Cruz | f19b282 | 2011-04-27 02:14:07 -0500 | [diff] [blame] | 390 | break; |
Peter Ujfalusi | cfb7a33 | 2011-07-04 10:28:28 +0300 | [diff] [blame] | 391 | case TWL6040_SYSCLK_SEL_HPPLL: |
Misael Lopez Cruz | f19b282 | 2011-04-27 02:14:07 -0500 | [diff] [blame] | 392 | /* high-performance PLL can provide only 19.2 MHz */ |
| 393 | if (freq_out != 19200000) { |
Peter Ujfalusi | 2d7c957 | 2011-09-15 15:39:23 +0300 | [diff] [blame] | 394 | dev_err(twl6040->dev, |
Misael Lopez Cruz | f19b282 | 2011-04-27 02:14:07 -0500 | [diff] [blame] | 395 | "freq_out %d not supported\n", freq_out); |
| 396 | ret = -EINVAL; |
| 397 | goto pll_out; |
| 398 | } |
| 399 | |
Peter Ujfalusi | 2bd05db | 2012-01-14 20:58:44 +0100 | [diff] [blame] | 400 | if (twl6040->mclk != freq_in) { |
| 401 | hppllctl &= ~TWL6040_MCLK_MSK; |
Misael Lopez Cruz | f19b282 | 2011-04-27 02:14:07 -0500 | [diff] [blame] | 402 | |
Peter Ujfalusi | 2bd05db | 2012-01-14 20:58:44 +0100 | [diff] [blame] | 403 | switch (freq_in) { |
| 404 | case 12000000: |
| 405 | /* PLL enabled, active mode */ |
| 406 | hppllctl |= TWL6040_MCLK_12000KHZ | |
| 407 | TWL6040_HPLLENA; |
| 408 | break; |
| 409 | case 19200000: |
| 410 | /* |
| 411 | * PLL disabled |
| 412 | * (enable PLL if MCLK jitter quality |
| 413 | * doesn't meet specification) |
| 414 | */ |
| 415 | hppllctl |= TWL6040_MCLK_19200KHZ; |
| 416 | break; |
| 417 | case 26000000: |
| 418 | /* PLL enabled, active mode */ |
| 419 | hppllctl |= TWL6040_MCLK_26000KHZ | |
| 420 | TWL6040_HPLLENA; |
| 421 | break; |
| 422 | case 38400000: |
| 423 | /* PLL enabled, active mode */ |
| 424 | hppllctl |= TWL6040_MCLK_38400KHZ | |
| 425 | TWL6040_HPLLENA; |
| 426 | break; |
| 427 | default: |
| 428 | dev_err(twl6040->dev, |
| 429 | "freq_in %d not supported\n", freq_in); |
| 430 | ret = -EINVAL; |
| 431 | goto pll_out; |
| 432 | } |
| 433 | |
Misael Lopez Cruz | f19b282 | 2011-04-27 02:14:07 -0500 | [diff] [blame] | 434 | /* |
Peter Ujfalusi | 2bd05db | 2012-01-14 20:58:44 +0100 | [diff] [blame] | 435 | * enable clock slicer to ensure input waveform is |
| 436 | * square |
Misael Lopez Cruz | f19b282 | 2011-04-27 02:14:07 -0500 | [diff] [blame] | 437 | */ |
Peter Ujfalusi | 2bd05db | 2012-01-14 20:58:44 +0100 | [diff] [blame] | 438 | hppllctl |= TWL6040_HPLLSQRENA; |
| 439 | |
| 440 | twl6040_reg_write(twl6040, TWL6040_REG_HPPLLCTL, |
| 441 | hppllctl); |
| 442 | usleep_range(500, 700); |
| 443 | lppllctl |= TWL6040_HPLLSEL; |
| 444 | twl6040_reg_write(twl6040, TWL6040_REG_LPPLLCTL, |
| 445 | lppllctl); |
| 446 | lppllctl &= ~TWL6040_LPLLENA; |
| 447 | twl6040_reg_write(twl6040, TWL6040_REG_LPPLLCTL, |
| 448 | lppllctl); |
Misael Lopez Cruz | f19b282 | 2011-04-27 02:14:07 -0500 | [diff] [blame] | 449 | } |
Misael Lopez Cruz | f19b282 | 2011-04-27 02:14:07 -0500 | [diff] [blame] | 450 | break; |
| 451 | default: |
Peter Ujfalusi | 2d7c957 | 2011-09-15 15:39:23 +0300 | [diff] [blame] | 452 | dev_err(twl6040->dev, "unknown pll id %d\n", pll_id); |
Misael Lopez Cruz | f19b282 | 2011-04-27 02:14:07 -0500 | [diff] [blame] | 453 | ret = -EINVAL; |
| 454 | goto pll_out; |
| 455 | } |
| 456 | |
| 457 | twl6040->sysclk = freq_out; |
Peter Ujfalusi | f8447d6 | 2012-01-14 20:58:43 +0100 | [diff] [blame] | 458 | twl6040->mclk = freq_in; |
Peter Ujfalusi | cfb7a33 | 2011-07-04 10:28:28 +0300 | [diff] [blame] | 459 | twl6040->pll = pll_id; |
Misael Lopez Cruz | f19b282 | 2011-04-27 02:14:07 -0500 | [diff] [blame] | 460 | |
| 461 | pll_out: |
| 462 | mutex_unlock(&twl6040->mutex); |
| 463 | return ret; |
| 464 | } |
| 465 | EXPORT_SYMBOL(twl6040_set_pll); |
| 466 | |
Peter Ujfalusi | cfb7a33 | 2011-07-04 10:28:28 +0300 | [diff] [blame] | 467 | int twl6040_get_pll(struct twl6040 *twl6040) |
Misael Lopez Cruz | f19b282 | 2011-04-27 02:14:07 -0500 | [diff] [blame] | 468 | { |
Peter Ujfalusi | cfb7a33 | 2011-07-04 10:28:28 +0300 | [diff] [blame] | 469 | if (twl6040->power_count) |
| 470 | return twl6040->pll; |
| 471 | else |
| 472 | return -ENODEV; |
Misael Lopez Cruz | f19b282 | 2011-04-27 02:14:07 -0500 | [diff] [blame] | 473 | } |
| 474 | EXPORT_SYMBOL(twl6040_get_pll); |
| 475 | |
| 476 | unsigned int twl6040_get_sysclk(struct twl6040 *twl6040) |
| 477 | { |
| 478 | return twl6040->sysclk; |
| 479 | } |
| 480 | EXPORT_SYMBOL(twl6040_get_sysclk); |
| 481 | |
Peter Ujfalusi | 70601ec | 2011-10-12 11:57:55 +0300 | [diff] [blame] | 482 | /* Get the combined status of the vibra control register */ |
| 483 | int twl6040_get_vibralr_status(struct twl6040 *twl6040) |
| 484 | { |
| 485 | u8 status; |
| 486 | |
| 487 | status = twl6040->vibra_ctrl_cache[0] | twl6040->vibra_ctrl_cache[1]; |
| 488 | status &= (TWL6040_VIBENA | TWL6040_VIBSEL); |
| 489 | |
| 490 | return status; |
| 491 | } |
| 492 | EXPORT_SYMBOL(twl6040_get_vibralr_status); |
| 493 | |
Peter Ujfalusi | 0f962ae | 2011-07-05 11:40:33 +0300 | [diff] [blame] | 494 | static struct resource twl6040_vibra_rsrc[] = { |
| 495 | { |
| 496 | .flags = IORESOURCE_IRQ, |
| 497 | }, |
| 498 | }; |
| 499 | |
| 500 | static struct resource twl6040_codec_rsrc[] = { |
| 501 | { |
| 502 | .flags = IORESOURCE_IRQ, |
| 503 | }, |
| 504 | }; |
| 505 | |
Peter Ujfalusi | 8eaeb93 | 2012-04-03 11:56:51 +0300 | [diff] [blame] | 506 | static bool twl6040_readable_reg(struct device *dev, unsigned int reg) |
Misael Lopez Cruz | f19b282 | 2011-04-27 02:14:07 -0500 | [diff] [blame] | 507 | { |
Peter Ujfalusi | 8eaeb93 | 2012-04-03 11:56:51 +0300 | [diff] [blame] | 508 | /* Register 0 is not readable */ |
| 509 | if (!reg) |
| 510 | return false; |
| 511 | return true; |
| 512 | } |
| 513 | |
| 514 | static struct regmap_config twl6040_regmap_config = { |
| 515 | .reg_bits = 8, |
| 516 | .val_bits = 8, |
| 517 | .max_register = TWL6040_REG_STATUS, /* 0x2e */ |
| 518 | |
| 519 | .readable_reg = twl6040_readable_reg, |
| 520 | }; |
| 521 | |
| 522 | static int __devinit twl6040_probe(struct i2c_client *client, |
| 523 | const struct i2c_device_id *id) |
| 524 | { |
| 525 | struct twl6040_platform_data *pdata = client->dev.platform_data; |
Peter Ujfalusi | 37e13ce | 2012-05-16 14:11:58 +0300 | [diff] [blame] | 526 | struct device_node *node = client->dev.of_node; |
Misael Lopez Cruz | f19b282 | 2011-04-27 02:14:07 -0500 | [diff] [blame] | 527 | struct twl6040 *twl6040; |
| 528 | struct mfd_cell *cell = NULL; |
Peter Ujfalusi | 1f01d60 | 2012-05-16 14:11:57 +0300 | [diff] [blame] | 529 | int irq, ret, children = 0; |
Misael Lopez Cruz | f19b282 | 2011-04-27 02:14:07 -0500 | [diff] [blame] | 530 | |
Peter Ujfalusi | 37e13ce | 2012-05-16 14:11:58 +0300 | [diff] [blame] | 531 | if (!pdata && !node) { |
Peter Ujfalusi | 8eaeb93 | 2012-04-03 11:56:51 +0300 | [diff] [blame] | 532 | dev_err(&client->dev, "Platform data is missing\n"); |
Misael Lopez Cruz | f19b282 | 2011-04-27 02:14:07 -0500 | [diff] [blame] | 533 | return -EINVAL; |
| 534 | } |
| 535 | |
Peter Ujfalusi | d20e1d2 | 2011-07-04 20:15:19 +0300 | [diff] [blame] | 536 | /* In order to operate correctly we need valid interrupt config */ |
Peter Ujfalusi | 6712419 | 2012-05-16 14:11:56 +0300 | [diff] [blame] | 537 | if (!client->irq) { |
Peter Ujfalusi | 8eaeb93 | 2012-04-03 11:56:51 +0300 | [diff] [blame] | 538 | dev_err(&client->dev, "Invalid IRQ configuration\n"); |
Peter Ujfalusi | d20e1d2 | 2011-07-04 20:15:19 +0300 | [diff] [blame] | 539 | return -EINVAL; |
| 540 | } |
| 541 | |
Peter Ujfalusi | 8eaeb93 | 2012-04-03 11:56:51 +0300 | [diff] [blame] | 542 | twl6040 = devm_kzalloc(&client->dev, sizeof(struct twl6040), |
| 543 | GFP_KERNEL); |
| 544 | if (!twl6040) { |
| 545 | ret = -ENOMEM; |
| 546 | goto err; |
| 547 | } |
Misael Lopez Cruz | f19b282 | 2011-04-27 02:14:07 -0500 | [diff] [blame] | 548 | |
Axel Lin | bbf6adc | 2012-04-25 10:09:46 +0800 | [diff] [blame] | 549 | twl6040->regmap = devm_regmap_init_i2c(client, &twl6040_regmap_config); |
Peter Ujfalusi | 8eaeb93 | 2012-04-03 11:56:51 +0300 | [diff] [blame] | 550 | if (IS_ERR(twl6040->regmap)) { |
| 551 | ret = PTR_ERR(twl6040->regmap); |
| 552 | goto err; |
| 553 | } |
Misael Lopez Cruz | f19b282 | 2011-04-27 02:14:07 -0500 | [diff] [blame] | 554 | |
Peter Ujfalusi | 8eaeb93 | 2012-04-03 11:56:51 +0300 | [diff] [blame] | 555 | i2c_set_clientdata(client, twl6040); |
| 556 | |
Peter Ujfalusi | 5af7df6 | 2012-05-02 16:54:42 +0300 | [diff] [blame] | 557 | twl6040->supplies[0].supply = "vio"; |
| 558 | twl6040->supplies[1].supply = "v2v1"; |
| 559 | ret = regulator_bulk_get(&client->dev, TWL6040_NUM_SUPPLIES, |
| 560 | twl6040->supplies); |
| 561 | if (ret != 0) { |
| 562 | dev_err(&client->dev, "Failed to get supplies: %d\n", ret); |
| 563 | goto regulator_get_err; |
| 564 | } |
| 565 | |
| 566 | ret = regulator_bulk_enable(TWL6040_NUM_SUPPLIES, twl6040->supplies); |
| 567 | if (ret != 0) { |
| 568 | dev_err(&client->dev, "Failed to enable supplies: %d\n", ret); |
| 569 | goto power_err; |
| 570 | } |
| 571 | |
Peter Ujfalusi | 8eaeb93 | 2012-04-03 11:56:51 +0300 | [diff] [blame] | 572 | twl6040->dev = &client->dev; |
| 573 | twl6040->irq = client->irq; |
Misael Lopez Cruz | f19b282 | 2011-04-27 02:14:07 -0500 | [diff] [blame] | 574 | |
| 575 | mutex_init(&twl6040->mutex); |
| 576 | mutex_init(&twl6040->io_mutex); |
| 577 | init_completion(&twl6040->ready); |
| 578 | |
| 579 | twl6040->rev = twl6040_reg_read(twl6040, TWL6040_REG_ASICREV); |
| 580 | |
Peter Ujfalusi | 77f63e0 | 2011-09-15 15:39:26 +0300 | [diff] [blame] | 581 | /* ERRATA: Automatic power-up is not possible in ES1.0 */ |
Peter Ujfalusi | 37e13ce | 2012-05-16 14:11:58 +0300 | [diff] [blame] | 582 | if (twl6040_get_revid(twl6040) > TWL6040_REV_ES1_0) { |
| 583 | if (pdata) |
| 584 | twl6040->audpwron = pdata->audpwron_gpio; |
| 585 | else |
| 586 | twl6040->audpwron = of_get_named_gpio(node, |
| 587 | "ti,audpwron-gpio", 0); |
| 588 | } else |
Peter Ujfalusi | 77f63e0 | 2011-09-15 15:39:26 +0300 | [diff] [blame] | 589 | twl6040->audpwron = -EINVAL; |
| 590 | |
Misael Lopez Cruz | f19b282 | 2011-04-27 02:14:07 -0500 | [diff] [blame] | 591 | if (gpio_is_valid(twl6040->audpwron)) { |
Axel Lin | b04edb9 | 2011-12-01 09:55:07 +0800 | [diff] [blame] | 592 | ret = gpio_request_one(twl6040->audpwron, GPIOF_OUT_INIT_LOW, |
| 593 | "audpwron"); |
Misael Lopez Cruz | f19b282 | 2011-04-27 02:14:07 -0500 | [diff] [blame] | 594 | if (ret) |
Peter Ujfalusi | 5af7df6 | 2012-05-02 16:54:42 +0300 | [diff] [blame] | 595 | goto gpio_err; |
Misael Lopez Cruz | f19b282 | 2011-04-27 02:14:07 -0500 | [diff] [blame] | 596 | } |
| 597 | |
Peter Ujfalusi | d20e1d2 | 2011-07-04 20:15:19 +0300 | [diff] [blame] | 598 | /* codec interrupt */ |
| 599 | ret = twl6040_irq_init(twl6040); |
| 600 | if (ret) |
Peter Ujfalusi | 5af7df6 | 2012-05-02 16:54:42 +0300 | [diff] [blame] | 601 | goto irq_init_err; |
Misael Lopez Cruz | f19b282 | 2011-04-27 02:14:07 -0500 | [diff] [blame] | 602 | |
Peter Ujfalusi | 1b7c472 | 2011-07-04 20:16:23 +0300 | [diff] [blame] | 603 | ret = request_threaded_irq(twl6040->irq_base + TWL6040_IRQ_READY, |
| 604 | NULL, twl6040_naudint_handler, 0, |
| 605 | "twl6040_irq_ready", twl6040); |
Peter Ujfalusi | d20e1d2 | 2011-07-04 20:15:19 +0300 | [diff] [blame] | 606 | if (ret) { |
| 607 | dev_err(twl6040->dev, "READY IRQ request failed: %d\n", |
| 608 | ret); |
| 609 | goto irq_err; |
Misael Lopez Cruz | f19b282 | 2011-04-27 02:14:07 -0500 | [diff] [blame] | 610 | } |
| 611 | |
| 612 | /* dual-access registers controlled by I2C only */ |
| 613 | twl6040_set_bits(twl6040, TWL6040_REG_ACCCTL, TWL6040_I2CSEL); |
| 614 | |
Peter Ujfalusi | 1f01d60 | 2012-05-16 14:11:57 +0300 | [diff] [blame] | 615 | /* |
| 616 | * The main functionality of twl6040 to provide audio on OMAP4+ systems. |
| 617 | * We can add the ASoC codec child whenever this driver has been loaded. |
| 618 | * The ASoC codec can work without pdata, pass the platform_data only if |
| 619 | * it has been provided. |
| 620 | */ |
| 621 | irq = twl6040->irq_base + TWL6040_IRQ_PLUG; |
| 622 | cell = &twl6040->cells[children]; |
| 623 | cell->name = "twl6040-codec"; |
| 624 | twl6040_codec_rsrc[0].start = irq; |
| 625 | twl6040_codec_rsrc[0].end = irq; |
| 626 | cell->resources = twl6040_codec_rsrc; |
| 627 | cell->num_resources = ARRAY_SIZE(twl6040_codec_rsrc); |
Peter Ujfalusi | 37e13ce | 2012-05-16 14:11:58 +0300 | [diff] [blame] | 628 | if (pdata && pdata->codec) { |
Peter Ujfalusi | 6c44863 | 2011-06-01 13:05:10 +0300 | [diff] [blame] | 629 | cell->platform_data = pdata->codec; |
| 630 | cell->pdata_size = sizeof(*pdata->codec); |
Misael Lopez Cruz | f19b282 | 2011-04-27 02:14:07 -0500 | [diff] [blame] | 631 | } |
Peter Ujfalusi | 1f01d60 | 2012-05-16 14:11:57 +0300 | [diff] [blame] | 632 | children++; |
Misael Lopez Cruz | f19b282 | 2011-04-27 02:14:07 -0500 | [diff] [blame] | 633 | |
Samuel Ortiz | ca2cad6 | 2012-05-23 16:23:21 +0200 | [diff] [blame] | 634 | if (twl6040_has_vibra(pdata, node)) { |
Peter Ujfalusi | 1f01d60 | 2012-05-16 14:11:57 +0300 | [diff] [blame] | 635 | irq = twl6040->irq_base + TWL6040_IRQ_VIB; |
Peter Ujfalusi | 0f962ae | 2011-07-05 11:40:33 +0300 | [diff] [blame] | 636 | |
Misael Lopez Cruz | f19b282 | 2011-04-27 02:14:07 -0500 | [diff] [blame] | 637 | cell = &twl6040->cells[children]; |
| 638 | cell->name = "twl6040-vibra"; |
Peter Ujfalusi | 0f962ae | 2011-07-05 11:40:33 +0300 | [diff] [blame] | 639 | twl6040_vibra_rsrc[0].start = irq; |
| 640 | twl6040_vibra_rsrc[0].end = irq; |
| 641 | cell->resources = twl6040_vibra_rsrc; |
| 642 | cell->num_resources = ARRAY_SIZE(twl6040_vibra_rsrc); |
| 643 | |
Peter Ujfalusi | 37e13ce | 2012-05-16 14:11:58 +0300 | [diff] [blame] | 644 | if (pdata && pdata->vibra) { |
| 645 | cell->platform_data = pdata->vibra; |
| 646 | cell->pdata_size = sizeof(*pdata->vibra); |
| 647 | } |
Misael Lopez Cruz | f19b282 | 2011-04-27 02:14:07 -0500 | [diff] [blame] | 648 | children++; |
| 649 | } |
| 650 | |
Peter Ujfalusi | 1f01d60 | 2012-05-16 14:11:57 +0300 | [diff] [blame] | 651 | ret = mfd_add_devices(&client->dev, -1, twl6040->cells, children, |
| 652 | NULL, 0); |
| 653 | if (ret) |
Misael Lopez Cruz | f19b282 | 2011-04-27 02:14:07 -0500 | [diff] [blame] | 654 | goto mfd_err; |
Misael Lopez Cruz | f19b282 | 2011-04-27 02:14:07 -0500 | [diff] [blame] | 655 | |
| 656 | return 0; |
| 657 | |
| 658 | mfd_err: |
Peter Ujfalusi | 1b7c472 | 2011-07-04 20:16:23 +0300 | [diff] [blame] | 659 | free_irq(twl6040->irq_base + TWL6040_IRQ_READY, twl6040); |
Misael Lopez Cruz | f19b282 | 2011-04-27 02:14:07 -0500 | [diff] [blame] | 660 | irq_err: |
Peter Ujfalusi | d20e1d2 | 2011-07-04 20:15:19 +0300 | [diff] [blame] | 661 | twl6040_irq_exit(twl6040); |
Peter Ujfalusi | 5af7df6 | 2012-05-02 16:54:42 +0300 | [diff] [blame] | 662 | irq_init_err: |
Misael Lopez Cruz | f19b282 | 2011-04-27 02:14:07 -0500 | [diff] [blame] | 663 | if (gpio_is_valid(twl6040->audpwron)) |
| 664 | gpio_free(twl6040->audpwron); |
Peter Ujfalusi | 5af7df6 | 2012-05-02 16:54:42 +0300 | [diff] [blame] | 665 | gpio_err: |
| 666 | regulator_bulk_disable(TWL6040_NUM_SUPPLIES, twl6040->supplies); |
| 667 | power_err: |
| 668 | regulator_bulk_free(TWL6040_NUM_SUPPLIES, twl6040->supplies); |
| 669 | regulator_get_err: |
Peter Ujfalusi | 8eaeb93 | 2012-04-03 11:56:51 +0300 | [diff] [blame] | 670 | i2c_set_clientdata(client, NULL); |
Peter Ujfalusi | 8eaeb93 | 2012-04-03 11:56:51 +0300 | [diff] [blame] | 671 | err: |
Misael Lopez Cruz | f19b282 | 2011-04-27 02:14:07 -0500 | [diff] [blame] | 672 | return ret; |
| 673 | } |
| 674 | |
Peter Ujfalusi | 8eaeb93 | 2012-04-03 11:56:51 +0300 | [diff] [blame] | 675 | static int __devexit twl6040_remove(struct i2c_client *client) |
Misael Lopez Cruz | f19b282 | 2011-04-27 02:14:07 -0500 | [diff] [blame] | 676 | { |
Peter Ujfalusi | 8eaeb93 | 2012-04-03 11:56:51 +0300 | [diff] [blame] | 677 | struct twl6040 *twl6040 = i2c_get_clientdata(client); |
Misael Lopez Cruz | f19b282 | 2011-04-27 02:14:07 -0500 | [diff] [blame] | 678 | |
| 679 | if (twl6040->power_count) |
| 680 | twl6040_power(twl6040, 0); |
| 681 | |
| 682 | if (gpio_is_valid(twl6040->audpwron)) |
| 683 | gpio_free(twl6040->audpwron); |
| 684 | |
Peter Ujfalusi | 1b7c472 | 2011-07-04 20:16:23 +0300 | [diff] [blame] | 685 | free_irq(twl6040->irq_base + TWL6040_IRQ_READY, twl6040); |
Peter Ujfalusi | d20e1d2 | 2011-07-04 20:15:19 +0300 | [diff] [blame] | 686 | twl6040_irq_exit(twl6040); |
Misael Lopez Cruz | f19b282 | 2011-04-27 02:14:07 -0500 | [diff] [blame] | 687 | |
Peter Ujfalusi | 8eaeb93 | 2012-04-03 11:56:51 +0300 | [diff] [blame] | 688 | mfd_remove_devices(&client->dev); |
| 689 | i2c_set_clientdata(client, NULL); |
Misael Lopez Cruz | f19b282 | 2011-04-27 02:14:07 -0500 | [diff] [blame] | 690 | |
Peter Ujfalusi | 5af7df6 | 2012-05-02 16:54:42 +0300 | [diff] [blame] | 691 | regulator_bulk_disable(TWL6040_NUM_SUPPLIES, twl6040->supplies); |
| 692 | regulator_bulk_free(TWL6040_NUM_SUPPLIES, twl6040->supplies); |
| 693 | |
Misael Lopez Cruz | f19b282 | 2011-04-27 02:14:07 -0500 | [diff] [blame] | 694 | return 0; |
| 695 | } |
| 696 | |
Peter Ujfalusi | 8eaeb93 | 2012-04-03 11:56:51 +0300 | [diff] [blame] | 697 | static const struct i2c_device_id twl6040_i2c_id[] = { |
| 698 | { "twl6040", 0, }, |
| 699 | { }, |
| 700 | }; |
| 701 | MODULE_DEVICE_TABLE(i2c, twl6040_i2c_id); |
| 702 | |
| 703 | static struct i2c_driver twl6040_driver = { |
| 704 | .driver = { |
| 705 | .name = "twl6040", |
| 706 | .owner = THIS_MODULE, |
| 707 | }, |
Misael Lopez Cruz | f19b282 | 2011-04-27 02:14:07 -0500 | [diff] [blame] | 708 | .probe = twl6040_probe, |
| 709 | .remove = __devexit_p(twl6040_remove), |
Peter Ujfalusi | 8eaeb93 | 2012-04-03 11:56:51 +0300 | [diff] [blame] | 710 | .id_table = twl6040_i2c_id, |
Misael Lopez Cruz | f19b282 | 2011-04-27 02:14:07 -0500 | [diff] [blame] | 711 | }; |
| 712 | |
Peter Ujfalusi | 8eaeb93 | 2012-04-03 11:56:51 +0300 | [diff] [blame] | 713 | module_i2c_driver(twl6040_driver); |
Misael Lopez Cruz | f19b282 | 2011-04-27 02:14:07 -0500 | [diff] [blame] | 714 | |
| 715 | MODULE_DESCRIPTION("TWL6040 MFD"); |
| 716 | MODULE_AUTHOR("Misael Lopez Cruz <misael.lopez@ti.com>"); |
| 717 | MODULE_AUTHOR("Jorge Eduardo Candelaria <jorge.candelaria@ti.com>"); |
| 718 | MODULE_LICENSE("GPL"); |
| 719 | MODULE_ALIAS("platform:twl6040"); |