1 // SPDX-License-Identifier: GPL-2.0-only
3 * Core functions for TI TPS65912x PMICs
5 * Copyright (C) 2015 Texas Instruments Incorporated - https://www.ti.com/
6 * Andrew F. Davis <afd@ti.com>
8 * Based on the TPS65218 driver and the previous TPS65912 driver by
9 * Margarita Olaya Cabrera <magi@slimlogic.co.uk>
12 #include <linux/interrupt.h>
13 #include <linux/mfd/core.h>
14 #include <linux/module.h>
16 #include <linux/mfd/tps65912.h>
18 static const struct mfd_cell tps65912_cells
[] = {
19 { .name
= "tps65912-regulator", },
20 { .name
= "tps65912-gpio", },
23 static const struct regmap_irq tps65912_irqs
[] = {
25 REGMAP_IRQ_REG(TPS65912_IRQ_PWRHOLD_F
, 0, TPS65912_INT_STS_PWRHOLD_F
),
26 REGMAP_IRQ_REG(TPS65912_IRQ_VMON
, 0, TPS65912_INT_STS_VMON
),
27 REGMAP_IRQ_REG(TPS65912_IRQ_PWRON
, 0, TPS65912_INT_STS_PWRON
),
28 REGMAP_IRQ_REG(TPS65912_IRQ_PWRON_LP
, 0, TPS65912_INT_STS_PWRON_LP
),
29 REGMAP_IRQ_REG(TPS65912_IRQ_PWRHOLD_R
, 0, TPS65912_INT_STS_PWRHOLD_R
),
30 REGMAP_IRQ_REG(TPS65912_IRQ_HOTDIE
, 0, TPS65912_INT_STS_HOTDIE
),
31 REGMAP_IRQ_REG(TPS65912_IRQ_GPIO1_R
, 0, TPS65912_INT_STS_GPIO1_R
),
32 REGMAP_IRQ_REG(TPS65912_IRQ_GPIO1_F
, 0, TPS65912_INT_STS_GPIO1_F
),
34 REGMAP_IRQ_REG(TPS65912_IRQ_GPIO2_R
, 1, TPS65912_INT_STS2_GPIO2_R
),
35 REGMAP_IRQ_REG(TPS65912_IRQ_GPIO2_F
, 1, TPS65912_INT_STS2_GPIO2_F
),
36 REGMAP_IRQ_REG(TPS65912_IRQ_GPIO3_R
, 1, TPS65912_INT_STS2_GPIO3_R
),
37 REGMAP_IRQ_REG(TPS65912_IRQ_GPIO3_F
, 1, TPS65912_INT_STS2_GPIO3_F
),
38 REGMAP_IRQ_REG(TPS65912_IRQ_GPIO4_R
, 1, TPS65912_INT_STS2_GPIO4_R
),
39 REGMAP_IRQ_REG(TPS65912_IRQ_GPIO4_F
, 1, TPS65912_INT_STS2_GPIO4_F
),
40 REGMAP_IRQ_REG(TPS65912_IRQ_GPIO5_R
, 1, TPS65912_INT_STS2_GPIO5_R
),
41 REGMAP_IRQ_REG(TPS65912_IRQ_GPIO5_F
, 1, TPS65912_INT_STS2_GPIO5_F
),
43 REGMAP_IRQ_REG(TPS65912_IRQ_PGOOD_DCDC1
, 2, TPS65912_INT_STS3_PGOOD_DCDC1
),
44 REGMAP_IRQ_REG(TPS65912_IRQ_PGOOD_DCDC2
, 2, TPS65912_INT_STS3_PGOOD_DCDC2
),
45 REGMAP_IRQ_REG(TPS65912_IRQ_PGOOD_DCDC3
, 2, TPS65912_INT_STS3_PGOOD_DCDC3
),
46 REGMAP_IRQ_REG(TPS65912_IRQ_PGOOD_DCDC4
, 2, TPS65912_INT_STS3_PGOOD_DCDC4
),
47 REGMAP_IRQ_REG(TPS65912_IRQ_PGOOD_LDO1
, 2, TPS65912_INT_STS3_PGOOD_LDO1
),
48 REGMAP_IRQ_REG(TPS65912_IRQ_PGOOD_LDO2
, 2, TPS65912_INT_STS3_PGOOD_LDO2
),
49 REGMAP_IRQ_REG(TPS65912_IRQ_PGOOD_LDO3
, 2, TPS65912_INT_STS3_PGOOD_LDO3
),
50 REGMAP_IRQ_REG(TPS65912_IRQ_PGOOD_LDO4
, 2, TPS65912_INT_STS3_PGOOD_LDO4
),
52 REGMAP_IRQ_REG(TPS65912_IRQ_PGOOD_LDO5
, 3, TPS65912_INT_STS4_PGOOD_LDO5
),
53 REGMAP_IRQ_REG(TPS65912_IRQ_PGOOD_LDO6
, 3, TPS65912_INT_STS4_PGOOD_LDO6
),
54 REGMAP_IRQ_REG(TPS65912_IRQ_PGOOD_LDO7
, 3, TPS65912_INT_STS4_PGOOD_LDO7
),
55 REGMAP_IRQ_REG(TPS65912_IRQ_PGOOD_LDO8
, 3, TPS65912_INT_STS4_PGOOD_LDO8
),
56 REGMAP_IRQ_REG(TPS65912_IRQ_PGOOD_LDO9
, 3, TPS65912_INT_STS4_PGOOD_LDO9
),
57 REGMAP_IRQ_REG(TPS65912_IRQ_PGOOD_LDO10
, 3, TPS65912_INT_STS4_PGOOD_LDO10
),
60 static const struct regmap_irq_chip tps65912_irq_chip
= {
62 .irqs
= tps65912_irqs
,
63 .num_irqs
= ARRAY_SIZE(tps65912_irqs
),
66 .mask_base
= TPS65912_INT_MSK
,
67 .status_base
= TPS65912_INT_STS
,
68 .ack_base
= TPS65912_INT_STS
,
69 .init_ack_masked
= true,
72 static const struct regmap_range tps65912_yes_ranges
[] = {
73 regmap_reg_range(TPS65912_INT_STS
, TPS65912_GPIO5
),
76 static const struct regmap_access_table tps65912_volatile_table
= {
77 .yes_ranges
= tps65912_yes_ranges
,
78 .n_yes_ranges
= ARRAY_SIZE(tps65912_yes_ranges
),
81 const struct regmap_config tps65912_regmap_config
= {
84 .cache_type
= REGCACHE_MAPLE
,
85 .volatile_table
= &tps65912_volatile_table
,
87 EXPORT_SYMBOL_GPL(tps65912_regmap_config
);
89 int tps65912_device_init(struct tps65912
*tps
)
93 ret
= devm_regmap_add_irq_chip(tps
->dev
, tps
->regmap
, tps
->irq
,
94 IRQF_ONESHOT
, 0, &tps65912_irq_chip
,
99 ret
= devm_mfd_add_devices(tps
->dev
, PLATFORM_DEVID_AUTO
, tps65912_cells
,
100 ARRAY_SIZE(tps65912_cells
), NULL
, 0,
101 regmap_irq_get_domain(tps
->irq_data
));
107 EXPORT_SYMBOL_GPL(tps65912_device_init
);
109 MODULE_AUTHOR("Andrew F. Davis <afd@ti.com>");
110 MODULE_DESCRIPTION("TPS65912x MFD Driver");
111 MODULE_LICENSE("GPL v2");