21 #include <linux/kernel.h>
22 #include <linux/module.h>
24 #include <linux/slab.h>
25 #include <linux/i2c.h>
32 #define TOTAL_NUM_REG 0x18
35 #define TPS65090_INT_STS 0x0
36 #define TPS65090_INT_STS2 0x1
39 #define TPS65090_INT_MSK 0x2
40 #define TPS65090_INT_MSK2 0x3
47 #define TPS65090_IRQ(_reg, _mask_pos) \
50 .mask_pos = (_mask_pos), \
72 static struct mfd_cell tps65090s[] = {
74 .name =
"tps65090-pmic",
77 .name =
"tps65090-regulator",
91 unsigned int temp_val;
124 unsigned int __irq = irq_data->
hwirq;
134 unsigned int __irq = irq_data->
irq - tps65090->
irq_base;
141 static void tps65090_irq_sync_unlock(
struct irq_data *
data)
153 unsigned long int acks = 0;
160 "failed to read mask reg [addr:%d]\n",
168 "failed to read status reg [addr:%d]\n",
179 "failed to write interrupt status\n");
182 acks |= (status << (i * 8));
191 static
int __devinit tps65090_irq_init(
struct tps65090 *tps65090,
int irq,
197 dev_err(tps65090->dev,
"IRQ base not set\n");
210 tps65090->irq_chip.name =
"tps65090";
211 tps65090->irq_chip.irq_mask = tps65090_irq_mask;
212 tps65090->irq_chip.irq_unmask = tps65090_irq_unmask;
213 tps65090->irq_chip.irq_bus_lock = tps65090_irq_lock;
214 tps65090->irq_chip.irq_bus_sync_unlock = tps65090_irq_sync_unlock;
216 for (i = 0; i <
ARRAY_SIZE(tps65090_irqs); i++) {
217 int __irq = i + tps65090->irq_base;
219 irq_set_chip_and_handler(__irq, &tps65090->irq_chip,
221 irq_set_nested_thread(__irq, 1);
228 "tps65090", tps65090);
231 enable_irq_wake(irq);
237 static bool is_volatile_reg(
struct device *
dev,
unsigned int reg)
245 static const struct regmap_config tps65090_regmap_config = {
251 .volatile_reg = is_volatile_reg,
258 struct tps65090 *tps65090;
262 dev_err(&client->
dev,
"tps65090 requires platform data\n");
268 if (tps65090 ==
NULL)
272 tps65090->
dev = &client->
dev;
273 i2c_set_clientdata(client, tps65090);
278 ret = tps65090_irq_init(tps65090, client->
irq, pdata->
irq_base);
280 dev_err(&client->
dev,
"IRQ init failed with err: %d\n",
287 &tps65090_regmap_config);
288 if (IS_ERR(tps65090->
rmap)) {
289 ret = PTR_ERR(tps65090->
rmap);
290 dev_err(&client->
dev,
"regmap_init failed with err: %d\n", ret);
297 dev_err(&client->
dev,
"add mfd devices failed with err: %d\n",
313 struct tps65090 *tps65090 = i2c_get_clientdata(client);
322 #ifdef CONFIG_PM_SLEEP
323 static int tps65090_suspend(
struct device *dev)
331 static int tps65090_resume(
struct device *dev)
340 static const struct dev_pm_ops tps65090_pm_ops = {
354 .pm = &tps65090_pm_ops,
356 .probe = tps65090_i2c_probe,
358 .id_table = tps65090_id_table,
361 static int __init tps65090_init(
void)
363 return i2c_add_driver(&tps65090_driver);
367 static void __exit tps65090_exit(
void)