4 * Copyright 2011-2012 Texas Instruments Inc.
6 * Author: Graeme Gregory <gg@slimlogic.co.uk>
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by the
10 * Free Software Foundation; either version 2 of the License, or (at your
11 * option) any later version.
15 #include <linux/module.h>
16 #include <linux/moduleparam.h>
17 #include <linux/init.h>
18 #include <linux/slab.h>
19 #include <linux/i2c.h>
20 #include <linux/interrupt.h>
21 #include <linux/irq.h>
22 #include <linux/regmap.h>
23 #include <linux/err.h>
24 #include <linux/mfd/core.h>
25 #include <linux/mfd/palmas.h>
26 #include <linux/of_device.h>
28 static const struct regmap_config palmas_regmap_config
[PALMAS_NUM_CLIENTS
] = {
32 .max_register
= PALMAS_BASE_TO_REG(PALMAS_PU_PD_OD_BASE
,
33 PALMAS_PRIMARY_SECONDARY_PAD3
),
38 .max_register
= PALMAS_BASE_TO_REG(PALMAS_GPADC_BASE
,
39 PALMAS_GPADC_SMPS_VSEL_MONITORING
),
44 .max_register
= PALMAS_BASE_TO_REG(PALMAS_TRIM_GPADC_BASE
,
49 static const struct regmap_irq tps65917_irqs
[] = {
51 [TPS65917_RESERVED1
] = {
52 .mask
= TPS65917_RESERVED
,
54 [TPS65917_PWRON_IRQ
] = {
55 .mask
= TPS65917_INT1_STATUS_PWRON
,
57 [TPS65917_LONG_PRESS_KEY_IRQ
] = {
58 .mask
= TPS65917_INT1_STATUS_LONG_PRESS_KEY
,
60 [TPS65917_RESERVED2
] = {
61 .mask
= TPS65917_RESERVED
,
63 [TPS65917_PWRDOWN_IRQ
] = {
64 .mask
= TPS65917_INT1_STATUS_PWRDOWN
,
66 [TPS65917_HOTDIE_IRQ
] = {
67 .mask
= TPS65917_INT1_STATUS_HOTDIE
,
69 [TPS65917_VSYS_MON_IRQ
] = {
70 .mask
= TPS65917_INT1_STATUS_VSYS_MON
,
72 [TPS65917_RESERVED3
] = {
73 .mask
= TPS65917_RESERVED
,
76 [TPS65917_RESERVED4
] = {
77 .mask
= TPS65917_RESERVED
,
80 [TPS65917_OTP_ERROR_IRQ
] = {
81 .mask
= TPS65917_INT2_STATUS_OTP_ERROR
,
84 [TPS65917_WDT_IRQ
] = {
85 .mask
= TPS65917_INT2_STATUS_WDT
,
88 [TPS65917_RESERVED5
] = {
89 .mask
= TPS65917_RESERVED
,
92 [TPS65917_RESET_IN_IRQ
] = {
93 .mask
= TPS65917_INT2_STATUS_RESET_IN
,
96 [TPS65917_FSD_IRQ
] = {
97 .mask
= TPS65917_INT2_STATUS_FSD
,
100 [TPS65917_SHORT_IRQ
] = {
101 .mask
= TPS65917_INT2_STATUS_SHORT
,
104 [TPS65917_RESERVED6
] = {
105 .mask
= TPS65917_RESERVED
,
109 [TPS65917_GPADC_AUTO_0_IRQ
] = {
110 .mask
= TPS65917_INT3_STATUS_GPADC_AUTO_0
,
113 [TPS65917_GPADC_AUTO_1_IRQ
] = {
114 .mask
= TPS65917_INT3_STATUS_GPADC_AUTO_1
,
117 [TPS65917_GPADC_EOC_SW_IRQ
] = {
118 .mask
= TPS65917_INT3_STATUS_GPADC_EOC_SW
,
121 [TPS65917_RESREVED6
] = {
122 .mask
= TPS65917_RESERVED6
,
125 [TPS65917_RESERVED7
] = {
126 .mask
= TPS65917_RESERVED
,
129 [TPS65917_RESERVED8
] = {
130 .mask
= TPS65917_RESERVED
,
133 [TPS65917_RESERVED9
] = {
134 .mask
= TPS65917_RESERVED
,
137 [TPS65917_VBUS_IRQ
] = {
138 .mask
= TPS65917_INT3_STATUS_VBUS
,
142 [TPS65917_GPIO_0_IRQ
] = {
143 .mask
= TPS65917_INT4_STATUS_GPIO_0
,
146 [TPS65917_GPIO_1_IRQ
] = {
147 .mask
= TPS65917_INT4_STATUS_GPIO_1
,
150 [TPS65917_GPIO_2_IRQ
] = {
151 .mask
= TPS65917_INT4_STATUS_GPIO_2
,
154 [TPS65917_GPIO_3_IRQ
] = {
155 .mask
= TPS65917_INT4_STATUS_GPIO_3
,
158 [TPS65917_GPIO_4_IRQ
] = {
159 .mask
= TPS65917_INT4_STATUS_GPIO_4
,
162 [TPS65917_GPIO_5_IRQ
] = {
163 .mask
= TPS65917_INT4_STATUS_GPIO_5
,
166 [TPS65917_GPIO_6_IRQ
] = {
167 .mask
= TPS65917_INT4_STATUS_GPIO_6
,
170 [TPS65917_RESERVED10
] = {
171 .mask
= TPS65917_RESERVED10
,
176 static const struct regmap_irq palmas_irqs
[] = {
178 [PALMAS_CHARG_DET_N_VBUS_OVV_IRQ
] = {
179 .mask
= PALMAS_INT1_STATUS_CHARG_DET_N_VBUS_OVV
,
181 [PALMAS_PWRON_IRQ
] = {
182 .mask
= PALMAS_INT1_STATUS_PWRON
,
184 [PALMAS_LONG_PRESS_KEY_IRQ
] = {
185 .mask
= PALMAS_INT1_STATUS_LONG_PRESS_KEY
,
187 [PALMAS_RPWRON_IRQ
] = {
188 .mask
= PALMAS_INT1_STATUS_RPWRON
,
190 [PALMAS_PWRDOWN_IRQ
] = {
191 .mask
= PALMAS_INT1_STATUS_PWRDOWN
,
193 [PALMAS_HOTDIE_IRQ
] = {
194 .mask
= PALMAS_INT1_STATUS_HOTDIE
,
196 [PALMAS_VSYS_MON_IRQ
] = {
197 .mask
= PALMAS_INT1_STATUS_VSYS_MON
,
199 [PALMAS_VBAT_MON_IRQ
] = {
200 .mask
= PALMAS_INT1_STATUS_VBAT_MON
,
203 [PALMAS_RTC_ALARM_IRQ
] = {
204 .mask
= PALMAS_INT2_STATUS_RTC_ALARM
,
207 [PALMAS_RTC_TIMER_IRQ
] = {
208 .mask
= PALMAS_INT2_STATUS_RTC_TIMER
,
212 .mask
= PALMAS_INT2_STATUS_WDT
,
215 [PALMAS_BATREMOVAL_IRQ
] = {
216 .mask
= PALMAS_INT2_STATUS_BATREMOVAL
,
219 [PALMAS_RESET_IN_IRQ
] = {
220 .mask
= PALMAS_INT2_STATUS_RESET_IN
,
223 [PALMAS_FBI_BB_IRQ
] = {
224 .mask
= PALMAS_INT2_STATUS_FBI_BB
,
227 [PALMAS_SHORT_IRQ
] = {
228 .mask
= PALMAS_INT2_STATUS_SHORT
,
231 [PALMAS_VAC_ACOK_IRQ
] = {
232 .mask
= PALMAS_INT2_STATUS_VAC_ACOK
,
236 [PALMAS_GPADC_AUTO_0_IRQ
] = {
237 .mask
= PALMAS_INT3_STATUS_GPADC_AUTO_0
,
240 [PALMAS_GPADC_AUTO_1_IRQ
] = {
241 .mask
= PALMAS_INT3_STATUS_GPADC_AUTO_1
,
244 [PALMAS_GPADC_EOC_SW_IRQ
] = {
245 .mask
= PALMAS_INT3_STATUS_GPADC_EOC_SW
,
248 [PALMAS_GPADC_EOC_RT_IRQ
] = {
249 .mask
= PALMAS_INT3_STATUS_GPADC_EOC_RT
,
252 [PALMAS_ID_OTG_IRQ
] = {
253 .mask
= PALMAS_INT3_STATUS_ID_OTG
,
257 .mask
= PALMAS_INT3_STATUS_ID
,
260 [PALMAS_VBUS_OTG_IRQ
] = {
261 .mask
= PALMAS_INT3_STATUS_VBUS_OTG
,
264 [PALMAS_VBUS_IRQ
] = {
265 .mask
= PALMAS_INT3_STATUS_VBUS
,
269 [PALMAS_GPIO_0_IRQ
] = {
270 .mask
= PALMAS_INT4_STATUS_GPIO_0
,
273 [PALMAS_GPIO_1_IRQ
] = {
274 .mask
= PALMAS_INT4_STATUS_GPIO_1
,
277 [PALMAS_GPIO_2_IRQ
] = {
278 .mask
= PALMAS_INT4_STATUS_GPIO_2
,
281 [PALMAS_GPIO_3_IRQ
] = {
282 .mask
= PALMAS_INT4_STATUS_GPIO_3
,
285 [PALMAS_GPIO_4_IRQ
] = {
286 .mask
= PALMAS_INT4_STATUS_GPIO_4
,
289 [PALMAS_GPIO_5_IRQ
] = {
290 .mask
= PALMAS_INT4_STATUS_GPIO_5
,
293 [PALMAS_GPIO_6_IRQ
] = {
294 .mask
= PALMAS_INT4_STATUS_GPIO_6
,
297 [PALMAS_GPIO_7_IRQ
] = {
298 .mask
= PALMAS_INT4_STATUS_GPIO_7
,
303 static struct regmap_irq_chip palmas_irq_chip
= {
306 .num_irqs
= ARRAY_SIZE(palmas_irqs
),
310 .status_base
= PALMAS_BASE_TO_REG(PALMAS_INTERRUPT_BASE
,
312 .mask_base
= PALMAS_BASE_TO_REG(PALMAS_INTERRUPT_BASE
,
316 static struct regmap_irq_chip tps65917_irq_chip
= {
318 .irqs
= tps65917_irqs
,
319 .num_irqs
= ARRAY_SIZE(tps65917_irqs
),
323 .status_base
= PALMAS_BASE_TO_REG(PALMAS_INTERRUPT_BASE
,
325 .mask_base
= PALMAS_BASE_TO_REG(PALMAS_INTERRUPT_BASE
,
329 int palmas_ext_control_req_config(struct palmas
*palmas
,
330 enum palmas_external_requestor_id id
, int ext_ctrl
, bool enable
)
332 struct palmas_pmic_driver_data
*pmic_ddata
= palmas
->pmic_ddata
;
333 int preq_mask_bit
= 0;
337 if (!(ext_ctrl
& PALMAS_EXT_REQ
))
340 if (id
>= PALMAS_EXTERNAL_REQSTR_ID_MAX
)
343 if (ext_ctrl
& PALMAS_EXT_CONTROL_NSLEEP
) {
344 reg_add
= PALMAS_NSLEEP_RES_ASSIGN
;
346 } else if (ext_ctrl
& PALMAS_EXT_CONTROL_ENABLE1
) {
347 reg_add
= PALMAS_ENABLE1_RES_ASSIGN
;
349 } else if (ext_ctrl
& PALMAS_EXT_CONTROL_ENABLE2
) {
350 reg_add
= PALMAS_ENABLE2_RES_ASSIGN
;
354 bit_pos
= pmic_ddata
->sleep_req_info
[id
].bit_pos
;
355 reg_add
+= pmic_ddata
->sleep_req_info
[id
].reg_offset
;
357 ret
= palmas_update_bits(palmas
, PALMAS_RESOURCE_BASE
,
358 reg_add
, BIT(bit_pos
), BIT(bit_pos
));
360 ret
= palmas_update_bits(palmas
, PALMAS_RESOURCE_BASE
,
361 reg_add
, BIT(bit_pos
), 0);
363 dev_err(palmas
->dev
, "Resource reg 0x%02x update failed %d\n",
368 /* Unmask the PREQ */
369 ret
= palmas_update_bits(palmas
, PALMAS_PMU_CONTROL_BASE
,
370 PALMAS_POWER_CTRL
, BIT(preq_mask_bit
), 0);
372 dev_err(palmas
->dev
, "POWER_CTRL register update failed %d\n",
378 EXPORT_SYMBOL_GPL(palmas_ext_control_req_config
);
380 static int palmas_set_pdata_irq_flag(struct i2c_client
*i2c
,
381 struct palmas_platform_data
*pdata
)
383 struct irq_data
*irq_data
= irq_get_irq_data(i2c
->irq
);
385 dev_err(&i2c
->dev
, "Invalid IRQ: %d\n", i2c
->irq
);
389 pdata
->irq_flags
= irqd_get_trigger_type(irq_data
);
390 dev_info(&i2c
->dev
, "Irq flag is 0x%08x\n", pdata
->irq_flags
);
394 static void palmas_dt_to_pdata(struct i2c_client
*i2c
,
395 struct palmas_platform_data
*pdata
)
397 struct device_node
*node
= i2c
->dev
.of_node
;
401 ret
= of_property_read_u32(node
, "ti,mux-pad1", &prop
);
403 pdata
->mux_from_pdata
= 1;
407 ret
= of_property_read_u32(node
, "ti,mux-pad2", &prop
);
409 pdata
->mux_from_pdata
= 1;
413 /* The default for this register is all masked */
414 ret
= of_property_read_u32(node
, "ti,power-ctrl", &prop
);
416 pdata
->power_ctrl
= prop
;
418 pdata
->power_ctrl
= PALMAS_POWER_CTRL_NSLEEP_MASK
|
419 PALMAS_POWER_CTRL_ENABLE1_MASK
|
420 PALMAS_POWER_CTRL_ENABLE2_MASK
;
422 palmas_set_pdata_irq_flag(i2c
, pdata
);
424 pdata
->pm_off
= of_property_read_bool(node
,
425 "ti,system-power-controller");
428 static struct palmas
*palmas_dev
;
429 static void palmas_power_off(void)
434 struct device_node
*np
= palmas_dev
->dev
->of_node
;
436 if (of_property_read_bool(np
, "ti,palmas-override-powerhold")) {
437 addr
= PALMAS_BASE_TO_REG(PALMAS_PU_PD_OD_BASE
,
438 PALMAS_PRIMARY_SECONDARY_PAD2
);
439 slave
= PALMAS_BASE_TO_SLAVE(PALMAS_PU_PD_OD_BASE
);
441 if (of_device_is_compatible(np
, "ti,tps65917"))
443 TPS65917_PRIMARY_SECONDARY_PAD2_GPIO_5_MASK
;
446 PALMAS_PRIMARY_SECONDARY_PAD2_GPIO_7_MASK
;
448 ret
= regmap_update_bits(palmas_dev
->regmap
[slave
], addr
,
451 dev_err(palmas_dev
->dev
,
452 "Unable to write PRIMARY_SECONDARY_PAD2 %d\n",
456 slave
= PALMAS_BASE_TO_SLAVE(PALMAS_PMU_CONTROL_BASE
);
457 addr
= PALMAS_BASE_TO_REG(PALMAS_PMU_CONTROL_BASE
, PALMAS_DEV_CTRL
);
459 ret
= regmap_update_bits(
460 palmas_dev
->regmap
[slave
],
462 PALMAS_DEV_CTRL_DEV_ON
,
466 pr_err("%s: Unable to write to DEV_CTRL_DEV_ON: %d\n",
470 static unsigned int palmas_features
= PALMAS_PMIC_FEATURE_SMPS10_BOOST
;
471 static unsigned int tps659038_features
;
473 struct palmas_driver_data
{
474 unsigned int *features
;
475 struct regmap_irq_chip
*irq_chip
;
478 static struct palmas_driver_data palmas_data
= {
479 .features
= &palmas_features
,
480 .irq_chip
= &palmas_irq_chip
,
483 static struct palmas_driver_data tps659038_data
= {
484 .features
= &tps659038_features
,
485 .irq_chip
= &palmas_irq_chip
,
488 static struct palmas_driver_data tps65917_data
= {
489 .features
= &tps659038_features
,
490 .irq_chip
= &tps65917_irq_chip
,
493 static const struct of_device_id of_palmas_match_tbl
[] = {
495 .compatible
= "ti,palmas",
496 .data
= &palmas_data
,
499 .compatible
= "ti,tps659038",
500 .data
= &tps659038_data
,
503 .compatible
= "ti,tps65917",
504 .data
= &tps65917_data
,
508 MODULE_DEVICE_TABLE(of
, of_palmas_match_tbl
);
510 static int palmas_i2c_probe(struct i2c_client
*i2c
,
511 const struct i2c_device_id
*id
)
513 struct palmas
*palmas
;
514 struct palmas_platform_data
*pdata
;
515 struct palmas_driver_data
*driver_data
;
516 struct device_node
*node
= i2c
->dev
.of_node
;
518 unsigned int reg
, addr
;
520 const struct of_device_id
*match
;
522 pdata
= dev_get_platdata(&i2c
->dev
);
524 if (node
&& !pdata
) {
525 pdata
= devm_kzalloc(&i2c
->dev
, sizeof(*pdata
), GFP_KERNEL
);
530 palmas_dt_to_pdata(i2c
, pdata
);
536 palmas
= devm_kzalloc(&i2c
->dev
, sizeof(struct palmas
), GFP_KERNEL
);
540 i2c_set_clientdata(i2c
, palmas
);
541 palmas
->dev
= &i2c
->dev
;
542 palmas
->irq
= i2c
->irq
;
544 match
= of_match_device(of_palmas_match_tbl
, &i2c
->dev
);
549 driver_data
= (struct palmas_driver_data
*)match
->data
;
550 palmas
->features
= *driver_data
->features
;
552 for (i
= 0; i
< PALMAS_NUM_CLIENTS
; i
++) {
554 palmas
->i2c_clients
[i
] = i2c
;
556 palmas
->i2c_clients
[i
] =
557 i2c_new_dummy(i2c
->adapter
,
559 if (!palmas
->i2c_clients
[i
]) {
561 "can't attach client %d\n", i
);
565 palmas
->i2c_clients
[i
]->dev
.of_node
= of_node_get(node
);
567 palmas
->regmap
[i
] = devm_regmap_init_i2c(palmas
->i2c_clients
[i
],
568 &palmas_regmap_config
[i
]);
569 if (IS_ERR(palmas
->regmap
[i
])) {
570 ret
= PTR_ERR(palmas
->regmap
[i
]);
572 "Failed to allocate regmap %d, err: %d\n",
579 dev_warn(palmas
->dev
, "IRQ missing: skipping irq request\n");
583 /* Change interrupt line output polarity */
584 if (pdata
->irq_flags
& IRQ_TYPE_LEVEL_HIGH
)
585 reg
= PALMAS_POLARITY_CTRL_INT_POLARITY
;
588 ret
= palmas_update_bits(palmas
, PALMAS_PU_PD_OD_BASE
,
589 PALMAS_POLARITY_CTRL
, PALMAS_POLARITY_CTRL_INT_POLARITY
,
592 dev_err(palmas
->dev
, "POLARITY_CTRL update failed: %d\n", ret
);
596 /* Change IRQ into clear on read mode for efficiency */
597 slave
= PALMAS_BASE_TO_SLAVE(PALMAS_INTERRUPT_BASE
);
598 addr
= PALMAS_BASE_TO_REG(PALMAS_INTERRUPT_BASE
, PALMAS_INT_CTRL
);
599 reg
= PALMAS_INT_CTRL_INT_CLEAR
;
601 regmap_write(palmas
->regmap
[slave
], addr
, reg
);
603 ret
= regmap_add_irq_chip(palmas
->regmap
[slave
], palmas
->irq
,
604 IRQF_ONESHOT
| pdata
->irq_flags
, 0,
605 driver_data
->irq_chip
, &palmas
->irq_data
);
610 slave
= PALMAS_BASE_TO_SLAVE(PALMAS_PU_PD_OD_BASE
);
611 addr
= PALMAS_BASE_TO_REG(PALMAS_PU_PD_OD_BASE
,
612 PALMAS_PRIMARY_SECONDARY_PAD1
);
614 if (pdata
->mux_from_pdata
) {
616 ret
= regmap_write(palmas
->regmap
[slave
], addr
, reg
);
620 ret
= regmap_read(palmas
->regmap
[slave
], addr
, ®
);
625 if (!(reg
& PALMAS_PRIMARY_SECONDARY_PAD1_GPIO_0
))
626 palmas
->gpio_muxed
|= PALMAS_GPIO_0_MUXED
;
627 if (!(reg
& PALMAS_PRIMARY_SECONDARY_PAD1_GPIO_1_MASK
))
628 palmas
->gpio_muxed
|= PALMAS_GPIO_1_MUXED
;
629 else if ((reg
& PALMAS_PRIMARY_SECONDARY_PAD1_GPIO_1_MASK
) ==
630 (2 << PALMAS_PRIMARY_SECONDARY_PAD1_GPIO_1_SHIFT
))
631 palmas
->led_muxed
|= PALMAS_LED1_MUXED
;
632 else if ((reg
& PALMAS_PRIMARY_SECONDARY_PAD1_GPIO_1_MASK
) ==
633 (3 << PALMAS_PRIMARY_SECONDARY_PAD1_GPIO_1_SHIFT
))
634 palmas
->pwm_muxed
|= PALMAS_PWM1_MUXED
;
635 if (!(reg
& PALMAS_PRIMARY_SECONDARY_PAD1_GPIO_2_MASK
))
636 palmas
->gpio_muxed
|= PALMAS_GPIO_2_MUXED
;
637 else if ((reg
& PALMAS_PRIMARY_SECONDARY_PAD1_GPIO_2_MASK
) ==
638 (2 << PALMAS_PRIMARY_SECONDARY_PAD1_GPIO_2_SHIFT
))
639 palmas
->led_muxed
|= PALMAS_LED2_MUXED
;
640 else if ((reg
& PALMAS_PRIMARY_SECONDARY_PAD1_GPIO_2_MASK
) ==
641 (3 << PALMAS_PRIMARY_SECONDARY_PAD1_GPIO_2_SHIFT
))
642 palmas
->pwm_muxed
|= PALMAS_PWM2_MUXED
;
643 if (!(reg
& PALMAS_PRIMARY_SECONDARY_PAD1_GPIO_3
))
644 palmas
->gpio_muxed
|= PALMAS_GPIO_3_MUXED
;
646 addr
= PALMAS_BASE_TO_REG(PALMAS_PU_PD_OD_BASE
,
647 PALMAS_PRIMARY_SECONDARY_PAD2
);
649 if (pdata
->mux_from_pdata
) {
651 ret
= regmap_write(palmas
->regmap
[slave
], addr
, reg
);
655 ret
= regmap_read(palmas
->regmap
[slave
], addr
, ®
);
660 if (!(reg
& PALMAS_PRIMARY_SECONDARY_PAD2_GPIO_4
))
661 palmas
->gpio_muxed
|= PALMAS_GPIO_4_MUXED
;
662 if (!(reg
& PALMAS_PRIMARY_SECONDARY_PAD2_GPIO_5_MASK
))
663 palmas
->gpio_muxed
|= PALMAS_GPIO_5_MUXED
;
664 if (!(reg
& PALMAS_PRIMARY_SECONDARY_PAD2_GPIO_6
))
665 palmas
->gpio_muxed
|= PALMAS_GPIO_6_MUXED
;
666 if (!(reg
& PALMAS_PRIMARY_SECONDARY_PAD2_GPIO_7_MASK
))
667 palmas
->gpio_muxed
|= PALMAS_GPIO_7_MUXED
;
669 dev_info(palmas
->dev
, "Muxing GPIO %x, PWM %x, LED %x\n",
670 palmas
->gpio_muxed
, palmas
->pwm_muxed
,
673 reg
= pdata
->power_ctrl
;
675 slave
= PALMAS_BASE_TO_SLAVE(PALMAS_PMU_CONTROL_BASE
);
676 addr
= PALMAS_BASE_TO_REG(PALMAS_PMU_CONTROL_BASE
, PALMAS_POWER_CTRL
);
678 ret
= regmap_write(palmas
->regmap
[slave
], addr
, reg
);
683 * If we are probing with DT do this the DT way and return here
684 * otherwise continue and add devices using mfd helpers.
687 ret
= devm_of_platform_populate(&i2c
->dev
);
690 } else if (pdata
->pm_off
&& !pm_power_off
) {
692 pm_power_off
= palmas_power_off
;
699 regmap_del_irq_chip(palmas
->irq
, palmas
->irq_data
);
701 for (i
= 1; i
< PALMAS_NUM_CLIENTS
; i
++) {
702 if (palmas
->i2c_clients
[i
])
703 i2c_unregister_device(palmas
->i2c_clients
[i
]);
708 static int palmas_i2c_remove(struct i2c_client
*i2c
)
710 struct palmas
*palmas
= i2c_get_clientdata(i2c
);
713 regmap_del_irq_chip(palmas
->irq
, palmas
->irq_data
);
715 for (i
= 1; i
< PALMAS_NUM_CLIENTS
; i
++) {
716 if (palmas
->i2c_clients
[i
])
717 i2c_unregister_device(palmas
->i2c_clients
[i
]);
720 if (palmas
== palmas_dev
) {
728 static const struct i2c_device_id palmas_i2c_id
[] = {
735 MODULE_DEVICE_TABLE(i2c
, palmas_i2c_id
);
737 static struct i2c_driver palmas_i2c_driver
= {
740 .of_match_table
= of_palmas_match_tbl
,
742 .probe
= palmas_i2c_probe
,
743 .remove
= palmas_i2c_remove
,
744 .id_table
= palmas_i2c_id
,
747 static int __init
palmas_i2c_init(void)
749 return i2c_add_driver(&palmas_i2c_driver
);
751 /* init early so consumer devices can complete system boot */
752 subsys_initcall(palmas_i2c_init
);
754 static void __exit
palmas_i2c_exit(void)
756 i2c_del_driver(&palmas_i2c_driver
);
758 module_exit(palmas_i2c_exit
);
760 MODULE_AUTHOR("Graeme Gregory <gg@slimlogic.co.uk>");
761 MODULE_DESCRIPTION("Palmas chip family multi-function driver");
762 MODULE_LICENSE("GPL");