2 * MFD driver for TWL6040 audio device
4 * Authors: Misael Lopez Cruz <misael.lopez@ti.com>
5 * Jorge Eduardo Candelaria <jorge.candelaria@ti.com>
6 * Peter Ujfalusi <peter.ujfalusi@ti.com>
8 * Copyright: (C) 2011 Texas Instruments, Inc.
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.
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.
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
26 #include <linux/module.h>
27 #include <linux/types.h>
28 #include <linux/slab.h>
29 #include <linux/kernel.h>
30 #include <linux/err.h>
31 #include <linux/platform_device.h>
33 #include <linux/of_irq.h>
34 #include <linux/of_gpio.h>
35 #include <linux/of_platform.h>
36 #include <linux/gpio.h>
37 #include <linux/delay.h>
38 #include <linux/i2c.h>
39 #include <linux/regmap.h>
40 #include <linux/mfd/core.h>
41 #include <linux/mfd/twl6040.h>
42 #include <linux/regulator/consumer.h>
44 #define VIBRACTRL_MEMBER(reg) ((reg == TWL6040_REG_VIBCTLL) ? 0 : 1)
45 #define TWL6040_NUM_SUPPLIES (2)
47 static const struct reg_default twl6040_defaults
[] = {
48 { 0x01, 0x4B }, /* REG_ASICID (ro) */
49 { 0x02, 0x00 }, /* REG_ASICREV (ro) */
50 { 0x03, 0x00 }, /* REG_INTID */
51 { 0x04, 0x00 }, /* REG_INTMR */
52 { 0x05, 0x00 }, /* REG_NCPCTRL */
53 { 0x06, 0x00 }, /* REG_LDOCTL */
54 { 0x07, 0x60 }, /* REG_HPPLLCTL */
55 { 0x08, 0x00 }, /* REG_LPPLLCTL */
56 { 0x09, 0x4A }, /* REG_LPPLLDIV */
57 { 0x0A, 0x00 }, /* REG_AMICBCTL */
58 { 0x0B, 0x00 }, /* REG_DMICBCTL */
59 { 0x0C, 0x00 }, /* REG_MICLCTL */
60 { 0x0D, 0x00 }, /* REG_MICRCTL */
61 { 0x0E, 0x00 }, /* REG_MICGAIN */
62 { 0x0F, 0x1B }, /* REG_LINEGAIN */
63 { 0x10, 0x00 }, /* REG_HSLCTL */
64 { 0x11, 0x00 }, /* REG_HSRCTL */
65 { 0x12, 0x00 }, /* REG_HSGAIN */
66 { 0x13, 0x00 }, /* REG_EARCTL */
67 { 0x14, 0x00 }, /* REG_HFLCTL */
68 { 0x15, 0x00 }, /* REG_HFLGAIN */
69 { 0x16, 0x00 }, /* REG_HFRCTL */
70 { 0x17, 0x00 }, /* REG_HFRGAIN */
71 { 0x18, 0x00 }, /* REG_VIBCTLL */
72 { 0x19, 0x00 }, /* REG_VIBDATL */
73 { 0x1A, 0x00 }, /* REG_VIBCTLR */
74 { 0x1B, 0x00 }, /* REG_VIBDATR */
75 { 0x1C, 0x00 }, /* REG_HKCTL1 */
76 { 0x1D, 0x00 }, /* REG_HKCTL2 */
77 { 0x1E, 0x00 }, /* REG_GPOCTL */
78 { 0x1F, 0x00 }, /* REG_ALB */
79 { 0x20, 0x00 }, /* REG_DLB */
83 /* 0x2B, REG_HSOTRIM */
84 /* 0x2C, REG_HFOTRIM */
85 { 0x2D, 0x08 }, /* REG_ACCCTL */
86 { 0x2E, 0x00 }, /* REG_STATUS (ro) */
89 static struct reg_sequence twl6040_patch
[] = {
91 * Select I2C bus access to dual access registers
92 * Interrupt register is cleared on read
93 * Select fast mode for i2c (400KHz)
96 TWL6040_I2CSEL
| TWL6040_INTCLRMODE
| TWL6040_I2CMODE(1) },
100 static bool twl6040_has_vibra(struct device_node
*parent
)
102 struct device_node
*node
;
104 node
= of_get_child_by_name(parent
, "vibra");
113 int twl6040_reg_read(struct twl6040
*twl6040
, unsigned int reg
)
118 ret
= regmap_read(twl6040
->regmap
, reg
, &val
);
124 EXPORT_SYMBOL(twl6040_reg_read
);
126 int twl6040_reg_write(struct twl6040
*twl6040
, unsigned int reg
, u8 val
)
130 ret
= regmap_write(twl6040
->regmap
, reg
, val
);
134 EXPORT_SYMBOL(twl6040_reg_write
);
136 int twl6040_set_bits(struct twl6040
*twl6040
, unsigned int reg
, u8 mask
)
138 return regmap_update_bits(twl6040
->regmap
, reg
, mask
, mask
);
140 EXPORT_SYMBOL(twl6040_set_bits
);
142 int twl6040_clear_bits(struct twl6040
*twl6040
, unsigned int reg
, u8 mask
)
144 return regmap_update_bits(twl6040
->regmap
, reg
, mask
, 0);
146 EXPORT_SYMBOL(twl6040_clear_bits
);
148 /* twl6040 codec manual power-up sequence */
149 static int twl6040_power_up_manual(struct twl6040
*twl6040
)
151 u8 ldoctl
, ncpctl
, lppllctl
;
154 /* enable high-side LDO, reference system and internal oscillator */
155 ldoctl
= TWL6040_HSLDOENA
| TWL6040_REFENA
| TWL6040_OSCENA
;
156 ret
= twl6040_reg_write(twl6040
, TWL6040_REG_LDOCTL
, ldoctl
);
159 usleep_range(10000, 10500);
161 /* enable negative charge pump */
162 ncpctl
= TWL6040_NCPENA
;
163 ret
= twl6040_reg_write(twl6040
, TWL6040_REG_NCPCTL
, ncpctl
);
166 usleep_range(1000, 1500);
168 /* enable low-side LDO */
169 ldoctl
|= TWL6040_LSLDOENA
;
170 ret
= twl6040_reg_write(twl6040
, TWL6040_REG_LDOCTL
, ldoctl
);
173 usleep_range(1000, 1500);
175 /* enable low-power PLL */
176 lppllctl
= TWL6040_LPLLENA
;
177 ret
= twl6040_reg_write(twl6040
, TWL6040_REG_LPPLLCTL
, lppllctl
);
180 usleep_range(5000, 5500);
182 /* disable internal oscillator */
183 ldoctl
&= ~TWL6040_OSCENA
;
184 ret
= twl6040_reg_write(twl6040
, TWL6040_REG_LDOCTL
, ldoctl
);
191 lppllctl
&= ~TWL6040_LPLLENA
;
192 twl6040_reg_write(twl6040
, TWL6040_REG_LPPLLCTL
, lppllctl
);
194 ldoctl
&= ~TWL6040_LSLDOENA
;
195 twl6040_reg_write(twl6040
, TWL6040_REG_LDOCTL
, ldoctl
);
197 ncpctl
&= ~TWL6040_NCPENA
;
198 twl6040_reg_write(twl6040
, TWL6040_REG_NCPCTL
, ncpctl
);
200 ldoctl
&= ~(TWL6040_HSLDOENA
| TWL6040_REFENA
| TWL6040_OSCENA
);
201 twl6040_reg_write(twl6040
, TWL6040_REG_LDOCTL
, ldoctl
);
203 dev_err(twl6040
->dev
, "manual power-up failed\n");
207 /* twl6040 manual power-down sequence */
208 static void twl6040_power_down_manual(struct twl6040
*twl6040
)
210 u8 ncpctl
, ldoctl
, lppllctl
;
212 ncpctl
= twl6040_reg_read(twl6040
, TWL6040_REG_NCPCTL
);
213 ldoctl
= twl6040_reg_read(twl6040
, TWL6040_REG_LDOCTL
);
214 lppllctl
= twl6040_reg_read(twl6040
, TWL6040_REG_LPPLLCTL
);
216 /* enable internal oscillator */
217 ldoctl
|= TWL6040_OSCENA
;
218 twl6040_reg_write(twl6040
, TWL6040_REG_LDOCTL
, ldoctl
);
219 usleep_range(1000, 1500);
221 /* disable low-power PLL */
222 lppllctl
&= ~TWL6040_LPLLENA
;
223 twl6040_reg_write(twl6040
, TWL6040_REG_LPPLLCTL
, lppllctl
);
225 /* disable low-side LDO */
226 ldoctl
&= ~TWL6040_LSLDOENA
;
227 twl6040_reg_write(twl6040
, TWL6040_REG_LDOCTL
, ldoctl
);
229 /* disable negative charge pump */
230 ncpctl
&= ~TWL6040_NCPENA
;
231 twl6040_reg_write(twl6040
, TWL6040_REG_NCPCTL
, ncpctl
);
233 /* disable high-side LDO, reference system and internal oscillator */
234 ldoctl
&= ~(TWL6040_HSLDOENA
| TWL6040_REFENA
| TWL6040_OSCENA
);
235 twl6040_reg_write(twl6040
, TWL6040_REG_LDOCTL
, ldoctl
);
238 static irqreturn_t
twl6040_readyint_handler(int irq
, void *data
)
240 struct twl6040
*twl6040
= data
;
242 complete(&twl6040
->ready
);
247 static irqreturn_t
twl6040_thint_handler(int irq
, void *data
)
249 struct twl6040
*twl6040
= data
;
252 status
= twl6040_reg_read(twl6040
, TWL6040_REG_STATUS
);
253 if (status
& TWL6040_TSHUTDET
) {
254 dev_warn(twl6040
->dev
, "Thermal shutdown, powering-off");
255 twl6040_power(twl6040
, 0);
257 dev_warn(twl6040
->dev
, "Leaving thermal shutdown, powering-on");
258 twl6040_power(twl6040
, 1);
264 static int twl6040_power_up_automatic(struct twl6040
*twl6040
)
268 gpio_set_value(twl6040
->audpwron
, 1);
270 time_left
= wait_for_completion_timeout(&twl6040
->ready
,
271 msecs_to_jiffies(144));
275 dev_warn(twl6040
->dev
, "timeout waiting for READYINT\n");
276 intid
= twl6040_reg_read(twl6040
, TWL6040_REG_INTID
);
277 if (!(intid
& TWL6040_READYINT
)) {
278 dev_err(twl6040
->dev
, "automatic power-up failed\n");
279 gpio_set_value(twl6040
->audpwron
, 0);
287 int twl6040_power(struct twl6040
*twl6040
, int on
)
291 mutex_lock(&twl6040
->mutex
);
294 /* already powered-up */
295 if (twl6040
->power_count
++)
298 clk_prepare_enable(twl6040
->clk32k
);
300 /* Allow writes to the chip */
301 regcache_cache_only(twl6040
->regmap
, false);
303 if (gpio_is_valid(twl6040
->audpwron
)) {
304 /* use automatic power-up sequence */
305 ret
= twl6040_power_up_automatic(twl6040
);
307 twl6040
->power_count
= 0;
311 /* use manual power-up sequence */
312 ret
= twl6040_power_up_manual(twl6040
);
314 twl6040
->power_count
= 0;
319 /* Sync with the HW */
320 regcache_sync(twl6040
->regmap
);
322 /* Default PLL configuration after power up */
323 twl6040
->pll
= TWL6040_SYSCLK_SEL_LPPLL
;
324 twl6040
->sysclk
= 19200000;
325 twl6040
->mclk
= 32768;
327 /* already powered-down */
328 if (!twl6040
->power_count
) {
329 dev_err(twl6040
->dev
,
330 "device is already powered-off\n");
335 if (--twl6040
->power_count
)
338 if (gpio_is_valid(twl6040
->audpwron
)) {
339 /* use AUDPWRON line */
340 gpio_set_value(twl6040
->audpwron
, 0);
342 /* power-down sequence latency */
343 usleep_range(500, 700);
345 /* use manual power-down sequence */
346 twl6040_power_down_manual(twl6040
);
349 /* Set regmap to cache only and mark it as dirty */
350 regcache_cache_only(twl6040
->regmap
, true);
351 regcache_mark_dirty(twl6040
->regmap
);
356 clk_disable_unprepare(twl6040
->clk32k
);
360 mutex_unlock(&twl6040
->mutex
);
363 EXPORT_SYMBOL(twl6040_power
);
365 int twl6040_set_pll(struct twl6040
*twl6040
, int pll_id
,
366 unsigned int freq_in
, unsigned int freq_out
)
368 u8 hppllctl
, lppllctl
;
371 mutex_lock(&twl6040
->mutex
);
373 hppllctl
= twl6040_reg_read(twl6040
, TWL6040_REG_HPPLLCTL
);
374 lppllctl
= twl6040_reg_read(twl6040
, TWL6040_REG_LPPLLCTL
);
376 /* Force full reconfiguration when switching between PLL */
377 if (pll_id
!= twl6040
->pll
) {
383 case TWL6040_SYSCLK_SEL_LPPLL
:
384 /* low-power PLL divider */
385 /* Change the sysclk configuration only if it has been canged */
386 if (twl6040
->sysclk
!= freq_out
) {
389 lppllctl
|= TWL6040_LPLLFIN
;
392 lppllctl
&= ~TWL6040_LPLLFIN
;
395 dev_err(twl6040
->dev
,
396 "freq_out %d not supported\n",
401 twl6040_reg_write(twl6040
, TWL6040_REG_LPPLLCTL
,
405 /* The PLL in use has not been change, we can exit */
406 if (twl6040
->pll
== pll_id
)
411 lppllctl
|= TWL6040_LPLLENA
;
412 twl6040_reg_write(twl6040
, TWL6040_REG_LPPLLCTL
,
415 lppllctl
&= ~TWL6040_HPLLSEL
;
416 twl6040_reg_write(twl6040
, TWL6040_REG_LPPLLCTL
,
418 hppllctl
&= ~TWL6040_HPLLENA
;
419 twl6040_reg_write(twl6040
, TWL6040_REG_HPPLLCTL
,
423 dev_err(twl6040
->dev
,
424 "freq_in %d not supported\n", freq_in
);
429 case TWL6040_SYSCLK_SEL_HPPLL
:
430 /* high-performance PLL can provide only 19.2 MHz */
431 if (freq_out
!= 19200000) {
432 dev_err(twl6040
->dev
,
433 "freq_out %d not supported\n", freq_out
);
438 if (twl6040
->mclk
!= freq_in
) {
439 hppllctl
&= ~TWL6040_MCLK_MSK
;
443 /* PLL enabled, active mode */
444 hppllctl
|= TWL6040_MCLK_12000KHZ
|
448 /* PLL enabled, bypass mode */
449 hppllctl
|= TWL6040_MCLK_19200KHZ
|
450 TWL6040_HPLLBP
| TWL6040_HPLLENA
;
453 /* PLL enabled, active mode */
454 hppllctl
|= TWL6040_MCLK_26000KHZ
|
458 /* PLL enabled, bypass mode */
459 hppllctl
|= TWL6040_MCLK_38400KHZ
|
460 TWL6040_HPLLBP
| TWL6040_HPLLENA
;
463 dev_err(twl6040
->dev
,
464 "freq_in %d not supported\n", freq_in
);
470 * enable clock slicer to ensure input waveform is
473 hppllctl
|= TWL6040_HPLLSQRENA
;
475 twl6040_reg_write(twl6040
, TWL6040_REG_HPPLLCTL
,
477 usleep_range(500, 700);
478 lppllctl
|= TWL6040_HPLLSEL
;
479 twl6040_reg_write(twl6040
, TWL6040_REG_LPPLLCTL
,
481 lppllctl
&= ~TWL6040_LPLLENA
;
482 twl6040_reg_write(twl6040
, TWL6040_REG_LPPLLCTL
,
487 dev_err(twl6040
->dev
, "unknown pll id %d\n", pll_id
);
492 twl6040
->sysclk
= freq_out
;
493 twl6040
->mclk
= freq_in
;
494 twl6040
->pll
= pll_id
;
497 mutex_unlock(&twl6040
->mutex
);
500 EXPORT_SYMBOL(twl6040_set_pll
);
502 int twl6040_get_pll(struct twl6040
*twl6040
)
504 if (twl6040
->power_count
)
509 EXPORT_SYMBOL(twl6040_get_pll
);
511 unsigned int twl6040_get_sysclk(struct twl6040
*twl6040
)
513 return twl6040
->sysclk
;
515 EXPORT_SYMBOL(twl6040_get_sysclk
);
517 /* Get the combined status of the vibra control register */
518 int twl6040_get_vibralr_status(struct twl6040
*twl6040
)
524 ret
= regmap_read(twl6040
->regmap
, TWL6040_REG_VIBCTLL
, ®
);
529 ret
= regmap_read(twl6040
->regmap
, TWL6040_REG_VIBCTLR
, ®
);
534 status
&= (TWL6040_VIBENA
| TWL6040_VIBSEL
);
538 EXPORT_SYMBOL(twl6040_get_vibralr_status
);
540 static struct resource twl6040_vibra_rsrc
[] = {
542 .flags
= IORESOURCE_IRQ
,
546 static struct resource twl6040_codec_rsrc
[] = {
548 .flags
= IORESOURCE_IRQ
,
552 static bool twl6040_readable_reg(struct device
*dev
, unsigned int reg
)
554 /* Register 0 is not readable */
560 static bool twl6040_volatile_reg(struct device
*dev
, unsigned int reg
)
563 case TWL6040_REG_ASICID
:
564 case TWL6040_REG_ASICREV
:
565 case TWL6040_REG_INTID
:
566 case TWL6040_REG_LPPLLCTL
:
567 case TWL6040_REG_HPPLLCTL
:
568 case TWL6040_REG_STATUS
:
575 static bool twl6040_writeable_reg(struct device
*dev
, unsigned int reg
)
578 case TWL6040_REG_ASICID
:
579 case TWL6040_REG_ASICREV
:
580 case TWL6040_REG_STATUS
:
587 static const struct regmap_config twl6040_regmap_config
= {
591 .reg_defaults
= twl6040_defaults
,
592 .num_reg_defaults
= ARRAY_SIZE(twl6040_defaults
),
594 .max_register
= TWL6040_REG_STATUS
, /* 0x2e */
596 .readable_reg
= twl6040_readable_reg
,
597 .volatile_reg
= twl6040_volatile_reg
,
598 .writeable_reg
= twl6040_writeable_reg
,
600 .cache_type
= REGCACHE_RBTREE
,
603 static const struct regmap_irq twl6040_irqs
[] = {
604 { .reg_offset
= 0, .mask
= TWL6040_THINT
, },
605 { .reg_offset
= 0, .mask
= TWL6040_PLUGINT
| TWL6040_UNPLUGINT
, },
606 { .reg_offset
= 0, .mask
= TWL6040_HOOKINT
, },
607 { .reg_offset
= 0, .mask
= TWL6040_HFINT
, },
608 { .reg_offset
= 0, .mask
= TWL6040_VIBINT
, },
609 { .reg_offset
= 0, .mask
= TWL6040_READYINT
, },
612 static struct regmap_irq_chip twl6040_irq_chip
= {
614 .irqs
= twl6040_irqs
,
615 .num_irqs
= ARRAY_SIZE(twl6040_irqs
),
618 .status_base
= TWL6040_REG_INTID
,
619 .mask_base
= TWL6040_REG_INTMR
,
622 static int twl6040_probe(struct i2c_client
*client
,
623 const struct i2c_device_id
*id
)
625 struct device_node
*node
= client
->dev
.of_node
;
626 struct twl6040
*twl6040
;
627 struct mfd_cell
*cell
= NULL
;
628 int irq
, ret
, children
= 0;
631 dev_err(&client
->dev
, "of node is missing\n");
635 /* In order to operate correctly we need valid interrupt config */
637 dev_err(&client
->dev
, "Invalid IRQ configuration\n");
641 twl6040
= devm_kzalloc(&client
->dev
, sizeof(struct twl6040
),
646 twl6040
->regmap
= devm_regmap_init_i2c(client
, &twl6040_regmap_config
);
647 if (IS_ERR(twl6040
->regmap
))
648 return PTR_ERR(twl6040
->regmap
);
650 i2c_set_clientdata(client
, twl6040
);
652 twl6040
->clk32k
= devm_clk_get(&client
->dev
, "clk32k");
653 if (IS_ERR(twl6040
->clk32k
)) {
654 if (PTR_ERR(twl6040
->clk32k
) == -EPROBE_DEFER
)
655 return -EPROBE_DEFER
;
656 dev_info(&client
->dev
, "clk32k is not handled\n");
657 twl6040
->clk32k
= NULL
;
660 twl6040
->supplies
[0].supply
= "vio";
661 twl6040
->supplies
[1].supply
= "v2v1";
662 ret
= devm_regulator_bulk_get(&client
->dev
, TWL6040_NUM_SUPPLIES
,
665 dev_err(&client
->dev
, "Failed to get supplies: %d\n", ret
);
669 ret
= regulator_bulk_enable(TWL6040_NUM_SUPPLIES
, twl6040
->supplies
);
671 dev_err(&client
->dev
, "Failed to enable supplies: %d\n", ret
);
675 twl6040
->dev
= &client
->dev
;
676 twl6040
->irq
= client
->irq
;
678 mutex_init(&twl6040
->mutex
);
679 init_completion(&twl6040
->ready
);
681 regmap_register_patch(twl6040
->regmap
, twl6040_patch
,
682 ARRAY_SIZE(twl6040_patch
));
684 twl6040
->rev
= twl6040_reg_read(twl6040
, TWL6040_REG_ASICREV
);
685 if (twl6040
->rev
< 0) {
686 dev_err(&client
->dev
, "Failed to read revision register: %d\n",
692 /* ERRATA: Automatic power-up is not possible in ES1.0 */
693 if (twl6040_get_revid(twl6040
) > TWL6040_REV_ES1_0
)
694 twl6040
->audpwron
= of_get_named_gpio(node
,
695 "ti,audpwron-gpio", 0);
697 twl6040
->audpwron
= -EINVAL
;
699 if (gpio_is_valid(twl6040
->audpwron
)) {
700 ret
= devm_gpio_request_one(&client
->dev
, twl6040
->audpwron
,
701 GPIOF_OUT_INIT_LOW
, "audpwron");
705 /* Clear any pending interrupt */
706 twl6040_reg_read(twl6040
, TWL6040_REG_INTID
);
709 ret
= regmap_add_irq_chip(twl6040
->regmap
, twl6040
->irq
, IRQF_ONESHOT
,
710 0, &twl6040_irq_chip
, &twl6040
->irq_data
);
714 twl6040
->irq_ready
= regmap_irq_get_virq(twl6040
->irq_data
,
716 twl6040
->irq_th
= regmap_irq_get_virq(twl6040
->irq_data
,
719 ret
= devm_request_threaded_irq(twl6040
->dev
, twl6040
->irq_ready
, NULL
,
720 twl6040_readyint_handler
, IRQF_ONESHOT
,
721 "twl6040_irq_ready", twl6040
);
723 dev_err(twl6040
->dev
, "READY IRQ request failed: %d\n", ret
);
727 ret
= devm_request_threaded_irq(twl6040
->dev
, twl6040
->irq_th
, NULL
,
728 twl6040_thint_handler
, IRQF_ONESHOT
,
729 "twl6040_irq_th", twl6040
);
731 dev_err(twl6040
->dev
, "Thermal IRQ request failed: %d\n", ret
);
736 * The main functionality of twl6040 to provide audio on OMAP4+ systems.
737 * We can add the ASoC codec child whenever this driver has been loaded.
739 irq
= regmap_irq_get_virq(twl6040
->irq_data
, TWL6040_IRQ_PLUG
);
740 cell
= &twl6040
->cells
[children
];
741 cell
->name
= "twl6040-codec";
742 twl6040_codec_rsrc
[0].start
= irq
;
743 twl6040_codec_rsrc
[0].end
= irq
;
744 cell
->resources
= twl6040_codec_rsrc
;
745 cell
->num_resources
= ARRAY_SIZE(twl6040_codec_rsrc
);
748 /* Vibra input driver support */
749 if (twl6040_has_vibra(node
)) {
750 irq
= regmap_irq_get_virq(twl6040
->irq_data
, TWL6040_IRQ_VIB
);
752 cell
= &twl6040
->cells
[children
];
753 cell
->name
= "twl6040-vibra";
754 twl6040_vibra_rsrc
[0].start
= irq
;
755 twl6040_vibra_rsrc
[0].end
= irq
;
756 cell
->resources
= twl6040_vibra_rsrc
;
757 cell
->num_resources
= ARRAY_SIZE(twl6040_vibra_rsrc
);
762 cell
= &twl6040
->cells
[children
];
763 cell
->name
= "twl6040-gpo";
766 /* The chip is powered down so mark regmap to cache only and dirty */
767 regcache_cache_only(twl6040
->regmap
, true);
768 regcache_mark_dirty(twl6040
->regmap
);
770 ret
= mfd_add_devices(&client
->dev
, -1, twl6040
->cells
, children
,
778 regmap_del_irq_chip(twl6040
->irq
, twl6040
->irq_data
);
780 regulator_bulk_disable(TWL6040_NUM_SUPPLIES
, twl6040
->supplies
);
784 static int twl6040_remove(struct i2c_client
*client
)
786 struct twl6040
*twl6040
= i2c_get_clientdata(client
);
788 if (twl6040
->power_count
)
789 twl6040_power(twl6040
, 0);
791 regmap_del_irq_chip(twl6040
->irq
, twl6040
->irq_data
);
793 mfd_remove_devices(&client
->dev
);
795 regulator_bulk_disable(TWL6040_NUM_SUPPLIES
, twl6040
->supplies
);
800 static const struct i2c_device_id twl6040_i2c_id
[] = {
805 MODULE_DEVICE_TABLE(i2c
, twl6040_i2c_id
);
807 static struct i2c_driver twl6040_driver
= {
811 .probe
= twl6040_probe
,
812 .remove
= twl6040_remove
,
813 .id_table
= twl6040_i2c_id
,
816 module_i2c_driver(twl6040_driver
);
818 MODULE_DESCRIPTION("TWL6040 MFD");
819 MODULE_AUTHOR("Misael Lopez Cruz <misael.lopez@ti.com>");
820 MODULE_AUTHOR("Jorge Eduardo Candelaria <jorge.candelaria@ti.com>");
821 MODULE_LICENSE("GPL");