Carlo Caione | cfb61a4 | 2014-05-01 14:29:27 +0200 | [diff] [blame] | 1 | /* |
Chen-Yu Tsai | 4fd4115 | 2016-02-12 10:02:42 +0800 | [diff] [blame] | 2 | * MFD core driver for the X-Powers' Power Management ICs |
Carlo Caione | cfb61a4 | 2014-05-01 14:29:27 +0200 | [diff] [blame] | 3 | * |
Jacob Pan | af7e906 | 2014-10-06 21:17:14 -0700 | [diff] [blame] | 4 | * AXP20x typically comprises an adaptive USB-Compatible PWM charger, BUCK DC-DC |
| 5 | * converters, LDOs, multiple 12-bit ADCs of voltage, current and temperature |
| 6 | * as well as configurable GPIOs. |
Carlo Caione | cfb61a4 | 2014-05-01 14:29:27 +0200 | [diff] [blame] | 7 | * |
Chen-Yu Tsai | 4fd4115 | 2016-02-12 10:02:42 +0800 | [diff] [blame] | 8 | * This file contains the interface independent core functions. |
| 9 | * |
Chen-Yu Tsai | e740235 | 2016-02-12 10:02:41 +0800 | [diff] [blame] | 10 | * Copyright (C) 2014 Carlo Caione |
| 11 | * |
Carlo Caione | cfb61a4 | 2014-05-01 14:29:27 +0200 | [diff] [blame] | 12 | * Author: Carlo Caione <carlo@caione.org> |
| 13 | * |
| 14 | * This program is free software; you can redistribute it and/or modify |
| 15 | * it under the terms of the GNU General Public License version 2 as |
| 16 | * published by the Free Software Foundation. |
| 17 | */ |
| 18 | |
| 19 | #include <linux/err.h> |
Hans de Goede | 179dc63 | 2016-06-05 15:50:48 +0200 | [diff] [blame] | 20 | #include <linux/delay.h> |
Carlo Caione | cfb61a4 | 2014-05-01 14:29:27 +0200 | [diff] [blame] | 21 | #include <linux/interrupt.h> |
| 22 | #include <linux/kernel.h> |
| 23 | #include <linux/module.h> |
| 24 | #include <linux/pm_runtime.h> |
| 25 | #include <linux/regmap.h> |
Carlo Caione | cfb61a4 | 2014-05-01 14:29:27 +0200 | [diff] [blame] | 26 | #include <linux/regulator/consumer.h> |
| 27 | #include <linux/mfd/axp20x.h> |
| 28 | #include <linux/mfd/core.h> |
| 29 | #include <linux/of_device.h> |
Jacob Pan | af7e906 | 2014-10-06 21:17:14 -0700 | [diff] [blame] | 30 | #include <linux/acpi.h> |
Carlo Caione | cfb61a4 | 2014-05-01 14:29:27 +0200 | [diff] [blame] | 31 | |
| 32 | #define AXP20X_OFF 0x80 |
| 33 | |
Rask Ingemann Lambertsen | c036969 | 2017-02-22 20:42:02 +0100 | [diff] [blame] | 34 | #define AXP806_REG_ADDR_EXT_ADDR_MASTER_MODE 0 |
Chen-Yu Tsai | 696f0b3 | 2017-01-05 12:01:03 +0800 | [diff] [blame] | 35 | #define AXP806_REG_ADDR_EXT_ADDR_SLAVE_MODE BIT(4) |
| 36 | |
Krzysztof Kozlowski | c31e858 | 2015-03-24 11:21:17 +0100 | [diff] [blame] | 37 | static const char * const axp20x_model_names[] = { |
Michal Suchanek | d8d79f8 | 2015-07-11 14:59:56 +0200 | [diff] [blame] | 38 | "AXP152", |
Jacob Pan | af7e906 | 2014-10-06 21:17:14 -0700 | [diff] [blame] | 39 | "AXP202", |
| 40 | "AXP209", |
Boris BREZILLON | f05be58 | 2015-04-10 12:09:01 +0800 | [diff] [blame] | 41 | "AXP221", |
Chen-Yu Tsai | 02071f0 | 2016-02-12 10:02:44 +0800 | [diff] [blame] | 42 | "AXP223", |
Jacob Pan | af7e906 | 2014-10-06 21:17:14 -0700 | [diff] [blame] | 43 | "AXP288", |
Icenowy Zheng | 1578353 | 2017-04-17 19:57:40 +0800 | [diff] [blame] | 44 | "AXP803", |
Chen-Yu Tsai | 8824ee8 | 2016-08-27 15:55:38 +0800 | [diff] [blame] | 45 | "AXP806", |
Chen-Yu Tsai | 20147f0 | 2016-03-29 17:22:26 +0800 | [diff] [blame] | 46 | "AXP809", |
Chen-Yu Tsai | 7303733 | 2017-07-26 16:28:26 +0800 | [diff] [blame] | 47 | "AXP813", |
Jacob Pan | af7e906 | 2014-10-06 21:17:14 -0700 | [diff] [blame] | 48 | }; |
| 49 | |
Michal Suchanek | d8d79f8 | 2015-07-11 14:59:56 +0200 | [diff] [blame] | 50 | static const struct regmap_range axp152_writeable_ranges[] = { |
| 51 | regmap_reg_range(AXP152_LDO3456_DC1234_CTRL, AXP152_IRQ3_STATE), |
| 52 | regmap_reg_range(AXP152_DCDC_MODE, AXP152_PWM1_DUTY_CYCLE), |
| 53 | }; |
| 54 | |
| 55 | static const struct regmap_range axp152_volatile_ranges[] = { |
| 56 | regmap_reg_range(AXP152_PWR_OP_MODE, AXP152_PWR_OP_MODE), |
| 57 | regmap_reg_range(AXP152_IRQ1_EN, AXP152_IRQ3_STATE), |
| 58 | regmap_reg_range(AXP152_GPIO_INPUT, AXP152_GPIO_INPUT), |
| 59 | }; |
| 60 | |
| 61 | static const struct regmap_access_table axp152_writeable_table = { |
| 62 | .yes_ranges = axp152_writeable_ranges, |
| 63 | .n_yes_ranges = ARRAY_SIZE(axp152_writeable_ranges), |
| 64 | }; |
| 65 | |
| 66 | static const struct regmap_access_table axp152_volatile_table = { |
| 67 | .yes_ranges = axp152_volatile_ranges, |
| 68 | .n_yes_ranges = ARRAY_SIZE(axp152_volatile_ranges), |
| 69 | }; |
| 70 | |
Carlo Caione | cfb61a4 | 2014-05-01 14:29:27 +0200 | [diff] [blame] | 71 | static const struct regmap_range axp20x_writeable_ranges[] = { |
| 72 | regmap_reg_range(AXP20X_DATACACHE(0), AXP20X_IRQ5_STATE), |
Quentin Schulz | 9760237 | 2017-03-20 09:16:53 +0100 | [diff] [blame] | 73 | regmap_reg_range(AXP20X_CHRG_CTRL1, AXP20X_CHRG_CTRL2), |
Carlo Caione | cfb61a4 | 2014-05-01 14:29:27 +0200 | [diff] [blame] | 74 | regmap_reg_range(AXP20X_DCDC_MODE, AXP20X_FG_RES), |
Bruno Prémont | 553ed4b | 2015-08-08 17:58:40 +0200 | [diff] [blame] | 75 | regmap_reg_range(AXP20X_RDC_H, AXP20X_OCV(AXP20X_OCV_MAX)), |
Carlo Caione | cfb61a4 | 2014-05-01 14:29:27 +0200 | [diff] [blame] | 76 | }; |
| 77 | |
| 78 | static const struct regmap_range axp20x_volatile_ranges[] = { |
Bruno Prémont | 553ed4b | 2015-08-08 17:58:40 +0200 | [diff] [blame] | 79 | regmap_reg_range(AXP20X_PWR_INPUT_STATUS, AXP20X_USB_OTG_STATUS), |
| 80 | regmap_reg_range(AXP20X_CHRG_CTRL1, AXP20X_CHRG_CTRL2), |
Carlo Caione | cfb61a4 | 2014-05-01 14:29:27 +0200 | [diff] [blame] | 81 | regmap_reg_range(AXP20X_IRQ1_EN, AXP20X_IRQ5_STATE), |
Bruno Prémont | 553ed4b | 2015-08-08 17:58:40 +0200 | [diff] [blame] | 82 | regmap_reg_range(AXP20X_ACIN_V_ADC_H, AXP20X_IPSOUT_V_HIGH_L), |
| 83 | regmap_reg_range(AXP20X_GPIO20_SS, AXP20X_GPIO3_CTRL), |
| 84 | regmap_reg_range(AXP20X_FG_RES, AXP20X_RDC_L), |
Carlo Caione | cfb61a4 | 2014-05-01 14:29:27 +0200 | [diff] [blame] | 85 | }; |
| 86 | |
| 87 | static const struct regmap_access_table axp20x_writeable_table = { |
| 88 | .yes_ranges = axp20x_writeable_ranges, |
| 89 | .n_yes_ranges = ARRAY_SIZE(axp20x_writeable_ranges), |
| 90 | }; |
| 91 | |
| 92 | static const struct regmap_access_table axp20x_volatile_table = { |
| 93 | .yes_ranges = axp20x_volatile_ranges, |
| 94 | .n_yes_ranges = ARRAY_SIZE(axp20x_volatile_ranges), |
| 95 | }; |
| 96 | |
Chen-Yu Tsai | 20147f0 | 2016-03-29 17:22:26 +0800 | [diff] [blame] | 97 | /* AXP22x ranges are shared with the AXP809, as they cover the same range */ |
Boris BREZILLON | f05be58 | 2015-04-10 12:09:01 +0800 | [diff] [blame] | 98 | static const struct regmap_range axp22x_writeable_ranges[] = { |
| 99 | regmap_reg_range(AXP20X_DATACACHE(0), AXP20X_IRQ5_STATE), |
Quentin Schulz | 9760237 | 2017-03-20 09:16:53 +0100 | [diff] [blame] | 100 | regmap_reg_range(AXP20X_CHRG_CTRL1, AXP22X_CHRG_CTRL3), |
Boris BREZILLON | f05be58 | 2015-04-10 12:09:01 +0800 | [diff] [blame] | 101 | regmap_reg_range(AXP20X_DCDC_MODE, AXP22X_BATLOW_THRES1), |
| 102 | }; |
| 103 | |
| 104 | static const struct regmap_range axp22x_volatile_ranges[] = { |
Hans de Goede | 1509325 | 2016-05-14 19:51:28 +0200 | [diff] [blame] | 105 | regmap_reg_range(AXP20X_PWR_INPUT_STATUS, AXP20X_PWR_OP_MODE), |
Boris BREZILLON | f05be58 | 2015-04-10 12:09:01 +0800 | [diff] [blame] | 106 | regmap_reg_range(AXP20X_IRQ1_EN, AXP20X_IRQ5_STATE), |
Hans de Goede | 1509325 | 2016-05-14 19:51:28 +0200 | [diff] [blame] | 107 | regmap_reg_range(AXP22X_GPIO_STATE, AXP22X_GPIO_STATE), |
Quentin Schulz | ed7311f | 2017-03-20 09:16:45 +0100 | [diff] [blame] | 108 | regmap_reg_range(AXP22X_PMIC_TEMP_H, AXP20X_IPSOUT_V_HIGH_L), |
Hans de Goede | 1509325 | 2016-05-14 19:51:28 +0200 | [diff] [blame] | 109 | regmap_reg_range(AXP20X_FG_RES, AXP20X_FG_RES), |
Boris BREZILLON | f05be58 | 2015-04-10 12:09:01 +0800 | [diff] [blame] | 110 | }; |
| 111 | |
| 112 | static const struct regmap_access_table axp22x_writeable_table = { |
| 113 | .yes_ranges = axp22x_writeable_ranges, |
| 114 | .n_yes_ranges = ARRAY_SIZE(axp22x_writeable_ranges), |
| 115 | }; |
| 116 | |
| 117 | static const struct regmap_access_table axp22x_volatile_table = { |
| 118 | .yes_ranges = axp22x_volatile_ranges, |
| 119 | .n_yes_ranges = ARRAY_SIZE(axp22x_volatile_ranges), |
| 120 | }; |
| 121 | |
Icenowy Zheng | 1578353 | 2017-04-17 19:57:40 +0800 | [diff] [blame] | 122 | /* AXP288 ranges are shared with the AXP803, as they cover the same range */ |
Jacob Pan | af7e906 | 2014-10-06 21:17:14 -0700 | [diff] [blame] | 123 | static const struct regmap_range axp288_writeable_ranges[] = { |
| 124 | regmap_reg_range(AXP20X_DATACACHE(0), AXP20X_IRQ6_STATE), |
| 125 | regmap_reg_range(AXP20X_DCDC_MODE, AXP288_FG_TUNE5), |
| 126 | }; |
| 127 | |
| 128 | static const struct regmap_range axp288_volatile_ranges[] = { |
Hans de Goede | cd53216 | 2016-12-16 21:09:06 +0100 | [diff] [blame] | 129 | regmap_reg_range(AXP20X_PWR_INPUT_STATUS, AXP288_POWER_REASON), |
| 130 | regmap_reg_range(AXP288_BC_GLOBAL, AXP288_BC_GLOBAL), |
| 131 | regmap_reg_range(AXP288_BC_DET_STAT, AXP288_BC_DET_STAT), |
Hans de Goede | 0c384fc | 2017-12-22 13:35:09 +0100 | [diff] [blame] | 132 | regmap_reg_range(AXP20X_CHRG_BAK_CTRL, AXP20X_CHRG_BAK_CTRL), |
Jacob Pan | af7e906 | 2014-10-06 21:17:14 -0700 | [diff] [blame] | 133 | regmap_reg_range(AXP20X_IRQ1_EN, AXP20X_IPSOUT_V_HIGH_L), |
Hans de Goede | cd53216 | 2016-12-16 21:09:06 +0100 | [diff] [blame] | 134 | regmap_reg_range(AXP20X_TIMER_CTRL, AXP20X_TIMER_CTRL), |
| 135 | regmap_reg_range(AXP22X_GPIO_STATE, AXP22X_GPIO_STATE), |
| 136 | regmap_reg_range(AXP288_RT_BATT_V_H, AXP288_RT_BATT_V_L), |
| 137 | regmap_reg_range(AXP20X_FG_RES, AXP288_FG_CC_CAP_REG), |
Jacob Pan | af7e906 | 2014-10-06 21:17:14 -0700 | [diff] [blame] | 138 | }; |
| 139 | |
| 140 | static const struct regmap_access_table axp288_writeable_table = { |
| 141 | .yes_ranges = axp288_writeable_ranges, |
| 142 | .n_yes_ranges = ARRAY_SIZE(axp288_writeable_ranges), |
| 143 | }; |
| 144 | |
| 145 | static const struct regmap_access_table axp288_volatile_table = { |
| 146 | .yes_ranges = axp288_volatile_ranges, |
| 147 | .n_yes_ranges = ARRAY_SIZE(axp288_volatile_ranges), |
| 148 | }; |
| 149 | |
Chen-Yu Tsai | 8824ee8 | 2016-08-27 15:55:38 +0800 | [diff] [blame] | 150 | static const struct regmap_range axp806_writeable_ranges[] = { |
| 151 | regmap_reg_range(AXP20X_DATACACHE(0), AXP20X_DATACACHE(3)), |
| 152 | regmap_reg_range(AXP806_PWR_OUT_CTRL1, AXP806_CLDO3_V_CTRL), |
| 153 | regmap_reg_range(AXP20X_IRQ1_EN, AXP20X_IRQ2_EN), |
| 154 | regmap_reg_range(AXP20X_IRQ1_STATE, AXP20X_IRQ2_STATE), |
Chen-Yu Tsai | 34d9030 | 2016-11-11 11:29:52 +0800 | [diff] [blame] | 155 | regmap_reg_range(AXP806_REG_ADDR_EXT, AXP806_REG_ADDR_EXT), |
Chen-Yu Tsai | 8824ee8 | 2016-08-27 15:55:38 +0800 | [diff] [blame] | 156 | }; |
| 157 | |
| 158 | static const struct regmap_range axp806_volatile_ranges[] = { |
| 159 | regmap_reg_range(AXP20X_IRQ1_STATE, AXP20X_IRQ2_STATE), |
| 160 | }; |
| 161 | |
| 162 | static const struct regmap_access_table axp806_writeable_table = { |
| 163 | .yes_ranges = axp806_writeable_ranges, |
| 164 | .n_yes_ranges = ARRAY_SIZE(axp806_writeable_ranges), |
| 165 | }; |
| 166 | |
| 167 | static const struct regmap_access_table axp806_volatile_table = { |
| 168 | .yes_ranges = axp806_volatile_ranges, |
| 169 | .n_yes_ranges = ARRAY_SIZE(axp806_volatile_ranges), |
| 170 | }; |
| 171 | |
Michal Suchanek | d8d79f8 | 2015-07-11 14:59:56 +0200 | [diff] [blame] | 172 | static struct resource axp152_pek_resources[] = { |
| 173 | DEFINE_RES_IRQ_NAMED(AXP152_IRQ_PEK_RIS_EDGE, "PEK_DBR"), |
| 174 | DEFINE_RES_IRQ_NAMED(AXP152_IRQ_PEK_FAL_EDGE, "PEK_DBF"), |
| 175 | }; |
| 176 | |
Michael Haas | cd7cf27 | 2016-05-06 07:19:49 +0200 | [diff] [blame] | 177 | static struct resource axp20x_ac_power_supply_resources[] = { |
| 178 | DEFINE_RES_IRQ_NAMED(AXP20X_IRQ_ACIN_PLUGIN, "ACIN_PLUGIN"), |
| 179 | DEFINE_RES_IRQ_NAMED(AXP20X_IRQ_ACIN_REMOVAL, "ACIN_REMOVAL"), |
| 180 | DEFINE_RES_IRQ_NAMED(AXP20X_IRQ_ACIN_OVER_V, "ACIN_OVER_V"), |
| 181 | }; |
| 182 | |
Carlo Caione | cfb61a4 | 2014-05-01 14:29:27 +0200 | [diff] [blame] | 183 | static struct resource axp20x_pek_resources[] = { |
| 184 | { |
| 185 | .name = "PEK_DBR", |
| 186 | .start = AXP20X_IRQ_PEK_RIS_EDGE, |
| 187 | .end = AXP20X_IRQ_PEK_RIS_EDGE, |
| 188 | .flags = IORESOURCE_IRQ, |
| 189 | }, { |
| 190 | .name = "PEK_DBF", |
| 191 | .start = AXP20X_IRQ_PEK_FAL_EDGE, |
| 192 | .end = AXP20X_IRQ_PEK_FAL_EDGE, |
| 193 | .flags = IORESOURCE_IRQ, |
| 194 | }, |
| 195 | }; |
| 196 | |
Hans de Goede | 8de4efd | 2015-08-08 17:58:41 +0200 | [diff] [blame] | 197 | static struct resource axp20x_usb_power_supply_resources[] = { |
| 198 | DEFINE_RES_IRQ_NAMED(AXP20X_IRQ_VBUS_PLUGIN, "VBUS_PLUGIN"), |
| 199 | DEFINE_RES_IRQ_NAMED(AXP20X_IRQ_VBUS_REMOVAL, "VBUS_REMOVAL"), |
| 200 | DEFINE_RES_IRQ_NAMED(AXP20X_IRQ_VBUS_VALID, "VBUS_VALID"), |
| 201 | DEFINE_RES_IRQ_NAMED(AXP20X_IRQ_VBUS_NOT_VALID, "VBUS_NOT_VALID"), |
| 202 | }; |
| 203 | |
Hans de Goede | ecd98cc | 2016-06-02 19:18:55 +0200 | [diff] [blame] | 204 | static struct resource axp22x_usb_power_supply_resources[] = { |
| 205 | DEFINE_RES_IRQ_NAMED(AXP22X_IRQ_VBUS_PLUGIN, "VBUS_PLUGIN"), |
| 206 | DEFINE_RES_IRQ_NAMED(AXP22X_IRQ_VBUS_REMOVAL, "VBUS_REMOVAL"), |
| 207 | }; |
| 208 | |
Boris BREZILLON | f05be58 | 2015-04-10 12:09:01 +0800 | [diff] [blame] | 209 | static struct resource axp22x_pek_resources[] = { |
| 210 | { |
| 211 | .name = "PEK_DBR", |
| 212 | .start = AXP22X_IRQ_PEK_RIS_EDGE, |
| 213 | .end = AXP22X_IRQ_PEK_RIS_EDGE, |
| 214 | .flags = IORESOURCE_IRQ, |
| 215 | }, { |
| 216 | .name = "PEK_DBF", |
| 217 | .start = AXP22X_IRQ_PEK_FAL_EDGE, |
| 218 | .end = AXP22X_IRQ_PEK_FAL_EDGE, |
| 219 | .flags = IORESOURCE_IRQ, |
| 220 | }, |
| 221 | }; |
| 222 | |
Borun Fu | e56e5ad | 2015-10-14 16:16:26 +0800 | [diff] [blame] | 223 | static struct resource axp288_power_button_resources[] = { |
| 224 | { |
| 225 | .name = "PEK_DBR", |
Hans de Goede | 1af468e | 2016-12-14 14:52:07 +0100 | [diff] [blame] | 226 | .start = AXP288_IRQ_POKP, |
| 227 | .end = AXP288_IRQ_POKP, |
Borun Fu | e56e5ad | 2015-10-14 16:16:26 +0800 | [diff] [blame] | 228 | .flags = IORESOURCE_IRQ, |
| 229 | }, |
| 230 | { |
| 231 | .name = "PEK_DBF", |
Hans de Goede | 1af468e | 2016-12-14 14:52:07 +0100 | [diff] [blame] | 232 | .start = AXP288_IRQ_POKN, |
| 233 | .end = AXP288_IRQ_POKN, |
Borun Fu | e56e5ad | 2015-10-14 16:16:26 +0800 | [diff] [blame] | 234 | .flags = IORESOURCE_IRQ, |
| 235 | }, |
| 236 | }; |
| 237 | |
Todd Brandt | d6387874 | 2015-02-02 15:41:41 -0800 | [diff] [blame] | 238 | static struct resource axp288_fuel_gauge_resources[] = { |
Jacob Pan | af7e906 | 2014-10-06 21:17:14 -0700 | [diff] [blame] | 239 | { |
| 240 | .start = AXP288_IRQ_QWBTU, |
| 241 | .end = AXP288_IRQ_QWBTU, |
| 242 | .flags = IORESOURCE_IRQ, |
| 243 | }, |
| 244 | { |
| 245 | .start = AXP288_IRQ_WBTU, |
| 246 | .end = AXP288_IRQ_WBTU, |
| 247 | .flags = IORESOURCE_IRQ, |
| 248 | }, |
| 249 | { |
| 250 | .start = AXP288_IRQ_QWBTO, |
| 251 | .end = AXP288_IRQ_QWBTO, |
| 252 | .flags = IORESOURCE_IRQ, |
| 253 | }, |
| 254 | { |
| 255 | .start = AXP288_IRQ_WBTO, |
| 256 | .end = AXP288_IRQ_WBTO, |
| 257 | .flags = IORESOURCE_IRQ, |
| 258 | }, |
| 259 | { |
| 260 | .start = AXP288_IRQ_WL2, |
| 261 | .end = AXP288_IRQ_WL2, |
| 262 | .flags = IORESOURCE_IRQ, |
| 263 | }, |
| 264 | { |
| 265 | .start = AXP288_IRQ_WL1, |
| 266 | .end = AXP288_IRQ_WL1, |
| 267 | .flags = IORESOURCE_IRQ, |
| 268 | }, |
| 269 | }; |
| 270 | |
Icenowy Zheng | 1578353 | 2017-04-17 19:57:40 +0800 | [diff] [blame] | 271 | static struct resource axp803_pek_resources[] = { |
| 272 | { |
| 273 | .name = "PEK_DBR", |
| 274 | .start = AXP803_IRQ_PEK_RIS_EDGE, |
| 275 | .end = AXP803_IRQ_PEK_RIS_EDGE, |
| 276 | .flags = IORESOURCE_IRQ, |
| 277 | }, { |
| 278 | .name = "PEK_DBF", |
| 279 | .start = AXP803_IRQ_PEK_FAL_EDGE, |
| 280 | .end = AXP803_IRQ_PEK_FAL_EDGE, |
| 281 | .flags = IORESOURCE_IRQ, |
| 282 | }, |
| 283 | }; |
| 284 | |
Chen-Yu Tsai | 20147f0 | 2016-03-29 17:22:26 +0800 | [diff] [blame] | 285 | static struct resource axp809_pek_resources[] = { |
| 286 | { |
| 287 | .name = "PEK_DBR", |
| 288 | .start = AXP809_IRQ_PEK_RIS_EDGE, |
| 289 | .end = AXP809_IRQ_PEK_RIS_EDGE, |
| 290 | .flags = IORESOURCE_IRQ, |
| 291 | }, { |
| 292 | .name = "PEK_DBF", |
| 293 | .start = AXP809_IRQ_PEK_FAL_EDGE, |
| 294 | .end = AXP809_IRQ_PEK_FAL_EDGE, |
| 295 | .flags = IORESOURCE_IRQ, |
| 296 | }, |
| 297 | }; |
| 298 | |
Michal Suchanek | d8d79f8 | 2015-07-11 14:59:56 +0200 | [diff] [blame] | 299 | static const struct regmap_config axp152_regmap_config = { |
| 300 | .reg_bits = 8, |
| 301 | .val_bits = 8, |
| 302 | .wr_table = &axp152_writeable_table, |
| 303 | .volatile_table = &axp152_volatile_table, |
| 304 | .max_register = AXP152_PWM1_DUTY_CYCLE, |
| 305 | .cache_type = REGCACHE_RBTREE, |
| 306 | }; |
| 307 | |
Carlo Caione | cfb61a4 | 2014-05-01 14:29:27 +0200 | [diff] [blame] | 308 | static const struct regmap_config axp20x_regmap_config = { |
| 309 | .reg_bits = 8, |
| 310 | .val_bits = 8, |
| 311 | .wr_table = &axp20x_writeable_table, |
| 312 | .volatile_table = &axp20x_volatile_table, |
Bruno Prémont | 553ed4b | 2015-08-08 17:58:40 +0200 | [diff] [blame] | 313 | .max_register = AXP20X_OCV(AXP20X_OCV_MAX), |
Carlo Caione | cfb61a4 | 2014-05-01 14:29:27 +0200 | [diff] [blame] | 314 | .cache_type = REGCACHE_RBTREE, |
| 315 | }; |
| 316 | |
Boris BREZILLON | f05be58 | 2015-04-10 12:09:01 +0800 | [diff] [blame] | 317 | static const struct regmap_config axp22x_regmap_config = { |
| 318 | .reg_bits = 8, |
| 319 | .val_bits = 8, |
| 320 | .wr_table = &axp22x_writeable_table, |
| 321 | .volatile_table = &axp22x_volatile_table, |
| 322 | .max_register = AXP22X_BATLOW_THRES1, |
| 323 | .cache_type = REGCACHE_RBTREE, |
| 324 | }; |
| 325 | |
Jacob Pan | af7e906 | 2014-10-06 21:17:14 -0700 | [diff] [blame] | 326 | static const struct regmap_config axp288_regmap_config = { |
| 327 | .reg_bits = 8, |
| 328 | .val_bits = 8, |
| 329 | .wr_table = &axp288_writeable_table, |
| 330 | .volatile_table = &axp288_volatile_table, |
| 331 | .max_register = AXP288_FG_TUNE5, |
| 332 | .cache_type = REGCACHE_RBTREE, |
| 333 | }; |
| 334 | |
Chen-Yu Tsai | 8824ee8 | 2016-08-27 15:55:38 +0800 | [diff] [blame] | 335 | static const struct regmap_config axp806_regmap_config = { |
| 336 | .reg_bits = 8, |
| 337 | .val_bits = 8, |
| 338 | .wr_table = &axp806_writeable_table, |
| 339 | .volatile_table = &axp806_volatile_table, |
Chen-Yu Tsai | 34d9030 | 2016-11-11 11:29:52 +0800 | [diff] [blame] | 340 | .max_register = AXP806_REG_ADDR_EXT, |
Chen-Yu Tsai | 8824ee8 | 2016-08-27 15:55:38 +0800 | [diff] [blame] | 341 | .cache_type = REGCACHE_RBTREE, |
| 342 | }; |
| 343 | |
Jacob Pan | af7e906 | 2014-10-06 21:17:14 -0700 | [diff] [blame] | 344 | #define INIT_REGMAP_IRQ(_variant, _irq, _off, _mask) \ |
| 345 | [_variant##_IRQ_##_irq] = { .reg_offset = (_off), .mask = BIT(_mask) } |
Carlo Caione | cfb61a4 | 2014-05-01 14:29:27 +0200 | [diff] [blame] | 346 | |
Michal Suchanek | d8d79f8 | 2015-07-11 14:59:56 +0200 | [diff] [blame] | 347 | static const struct regmap_irq axp152_regmap_irqs[] = { |
| 348 | INIT_REGMAP_IRQ(AXP152, LDO0IN_CONNECT, 0, 6), |
| 349 | INIT_REGMAP_IRQ(AXP152, LDO0IN_REMOVAL, 0, 5), |
| 350 | INIT_REGMAP_IRQ(AXP152, ALDO0IN_CONNECT, 0, 3), |
| 351 | INIT_REGMAP_IRQ(AXP152, ALDO0IN_REMOVAL, 0, 2), |
| 352 | INIT_REGMAP_IRQ(AXP152, DCDC1_V_LOW, 1, 5), |
| 353 | INIT_REGMAP_IRQ(AXP152, DCDC2_V_LOW, 1, 4), |
| 354 | INIT_REGMAP_IRQ(AXP152, DCDC3_V_LOW, 1, 3), |
| 355 | INIT_REGMAP_IRQ(AXP152, DCDC4_V_LOW, 1, 2), |
| 356 | INIT_REGMAP_IRQ(AXP152, PEK_SHORT, 1, 1), |
| 357 | INIT_REGMAP_IRQ(AXP152, PEK_LONG, 1, 0), |
| 358 | INIT_REGMAP_IRQ(AXP152, TIMER, 2, 7), |
| 359 | INIT_REGMAP_IRQ(AXP152, PEK_RIS_EDGE, 2, 6), |
| 360 | INIT_REGMAP_IRQ(AXP152, PEK_FAL_EDGE, 2, 5), |
| 361 | INIT_REGMAP_IRQ(AXP152, GPIO3_INPUT, 2, 3), |
| 362 | INIT_REGMAP_IRQ(AXP152, GPIO2_INPUT, 2, 2), |
| 363 | INIT_REGMAP_IRQ(AXP152, GPIO1_INPUT, 2, 1), |
| 364 | INIT_REGMAP_IRQ(AXP152, GPIO0_INPUT, 2, 0), |
| 365 | }; |
| 366 | |
Carlo Caione | cfb61a4 | 2014-05-01 14:29:27 +0200 | [diff] [blame] | 367 | static const struct regmap_irq axp20x_regmap_irqs[] = { |
Jacob Pan | af7e906 | 2014-10-06 21:17:14 -0700 | [diff] [blame] | 368 | INIT_REGMAP_IRQ(AXP20X, ACIN_OVER_V, 0, 7), |
| 369 | INIT_REGMAP_IRQ(AXP20X, ACIN_PLUGIN, 0, 6), |
| 370 | INIT_REGMAP_IRQ(AXP20X, ACIN_REMOVAL, 0, 5), |
| 371 | INIT_REGMAP_IRQ(AXP20X, VBUS_OVER_V, 0, 4), |
| 372 | INIT_REGMAP_IRQ(AXP20X, VBUS_PLUGIN, 0, 3), |
| 373 | INIT_REGMAP_IRQ(AXP20X, VBUS_REMOVAL, 0, 2), |
| 374 | INIT_REGMAP_IRQ(AXP20X, VBUS_V_LOW, 0, 1), |
| 375 | INIT_REGMAP_IRQ(AXP20X, BATT_PLUGIN, 1, 7), |
| 376 | INIT_REGMAP_IRQ(AXP20X, BATT_REMOVAL, 1, 6), |
| 377 | INIT_REGMAP_IRQ(AXP20X, BATT_ENT_ACT_MODE, 1, 5), |
| 378 | INIT_REGMAP_IRQ(AXP20X, BATT_EXIT_ACT_MODE, 1, 4), |
| 379 | INIT_REGMAP_IRQ(AXP20X, CHARG, 1, 3), |
| 380 | INIT_REGMAP_IRQ(AXP20X, CHARG_DONE, 1, 2), |
| 381 | INIT_REGMAP_IRQ(AXP20X, BATT_TEMP_HIGH, 1, 1), |
| 382 | INIT_REGMAP_IRQ(AXP20X, BATT_TEMP_LOW, 1, 0), |
| 383 | INIT_REGMAP_IRQ(AXP20X, DIE_TEMP_HIGH, 2, 7), |
| 384 | INIT_REGMAP_IRQ(AXP20X, CHARG_I_LOW, 2, 6), |
| 385 | INIT_REGMAP_IRQ(AXP20X, DCDC1_V_LONG, 2, 5), |
| 386 | INIT_REGMAP_IRQ(AXP20X, DCDC2_V_LONG, 2, 4), |
| 387 | INIT_REGMAP_IRQ(AXP20X, DCDC3_V_LONG, 2, 3), |
| 388 | INIT_REGMAP_IRQ(AXP20X, PEK_SHORT, 2, 1), |
| 389 | INIT_REGMAP_IRQ(AXP20X, PEK_LONG, 2, 0), |
| 390 | INIT_REGMAP_IRQ(AXP20X, N_OE_PWR_ON, 3, 7), |
| 391 | INIT_REGMAP_IRQ(AXP20X, N_OE_PWR_OFF, 3, 6), |
| 392 | INIT_REGMAP_IRQ(AXP20X, VBUS_VALID, 3, 5), |
| 393 | INIT_REGMAP_IRQ(AXP20X, VBUS_NOT_VALID, 3, 4), |
| 394 | INIT_REGMAP_IRQ(AXP20X, VBUS_SESS_VALID, 3, 3), |
| 395 | INIT_REGMAP_IRQ(AXP20X, VBUS_SESS_END, 3, 2), |
| 396 | INIT_REGMAP_IRQ(AXP20X, LOW_PWR_LVL1, 3, 1), |
| 397 | INIT_REGMAP_IRQ(AXP20X, LOW_PWR_LVL2, 3, 0), |
| 398 | INIT_REGMAP_IRQ(AXP20X, TIMER, 4, 7), |
| 399 | INIT_REGMAP_IRQ(AXP20X, PEK_RIS_EDGE, 4, 6), |
| 400 | INIT_REGMAP_IRQ(AXP20X, PEK_FAL_EDGE, 4, 5), |
| 401 | INIT_REGMAP_IRQ(AXP20X, GPIO3_INPUT, 4, 3), |
| 402 | INIT_REGMAP_IRQ(AXP20X, GPIO2_INPUT, 4, 2), |
| 403 | INIT_REGMAP_IRQ(AXP20X, GPIO1_INPUT, 4, 1), |
| 404 | INIT_REGMAP_IRQ(AXP20X, GPIO0_INPUT, 4, 0), |
| 405 | }; |
| 406 | |
Boris BREZILLON | f05be58 | 2015-04-10 12:09:01 +0800 | [diff] [blame] | 407 | static const struct regmap_irq axp22x_regmap_irqs[] = { |
| 408 | INIT_REGMAP_IRQ(AXP22X, ACIN_OVER_V, 0, 7), |
| 409 | INIT_REGMAP_IRQ(AXP22X, ACIN_PLUGIN, 0, 6), |
| 410 | INIT_REGMAP_IRQ(AXP22X, ACIN_REMOVAL, 0, 5), |
| 411 | INIT_REGMAP_IRQ(AXP22X, VBUS_OVER_V, 0, 4), |
| 412 | INIT_REGMAP_IRQ(AXP22X, VBUS_PLUGIN, 0, 3), |
| 413 | INIT_REGMAP_IRQ(AXP22X, VBUS_REMOVAL, 0, 2), |
| 414 | INIT_REGMAP_IRQ(AXP22X, VBUS_V_LOW, 0, 1), |
| 415 | INIT_REGMAP_IRQ(AXP22X, BATT_PLUGIN, 1, 7), |
| 416 | INIT_REGMAP_IRQ(AXP22X, BATT_REMOVAL, 1, 6), |
| 417 | INIT_REGMAP_IRQ(AXP22X, BATT_ENT_ACT_MODE, 1, 5), |
| 418 | INIT_REGMAP_IRQ(AXP22X, BATT_EXIT_ACT_MODE, 1, 4), |
| 419 | INIT_REGMAP_IRQ(AXP22X, CHARG, 1, 3), |
| 420 | INIT_REGMAP_IRQ(AXP22X, CHARG_DONE, 1, 2), |
| 421 | INIT_REGMAP_IRQ(AXP22X, BATT_TEMP_HIGH, 1, 1), |
| 422 | INIT_REGMAP_IRQ(AXP22X, BATT_TEMP_LOW, 1, 0), |
| 423 | INIT_REGMAP_IRQ(AXP22X, DIE_TEMP_HIGH, 2, 7), |
| 424 | INIT_REGMAP_IRQ(AXP22X, PEK_SHORT, 2, 1), |
| 425 | INIT_REGMAP_IRQ(AXP22X, PEK_LONG, 2, 0), |
| 426 | INIT_REGMAP_IRQ(AXP22X, LOW_PWR_LVL1, 3, 1), |
| 427 | INIT_REGMAP_IRQ(AXP22X, LOW_PWR_LVL2, 3, 0), |
| 428 | INIT_REGMAP_IRQ(AXP22X, TIMER, 4, 7), |
| 429 | INIT_REGMAP_IRQ(AXP22X, PEK_RIS_EDGE, 4, 6), |
| 430 | INIT_REGMAP_IRQ(AXP22X, PEK_FAL_EDGE, 4, 5), |
| 431 | INIT_REGMAP_IRQ(AXP22X, GPIO1_INPUT, 4, 1), |
| 432 | INIT_REGMAP_IRQ(AXP22X, GPIO0_INPUT, 4, 0), |
| 433 | }; |
| 434 | |
Jacob Pan | af7e906 | 2014-10-06 21:17:14 -0700 | [diff] [blame] | 435 | /* some IRQs are compatible with axp20x models */ |
| 436 | static const struct regmap_irq axp288_regmap_irqs[] = { |
Jacob Pan | ff3bbc5 | 2014-11-11 11:30:09 -0800 | [diff] [blame] | 437 | INIT_REGMAP_IRQ(AXP288, VBUS_FALL, 0, 2), |
| 438 | INIT_REGMAP_IRQ(AXP288, VBUS_RISE, 0, 3), |
| 439 | INIT_REGMAP_IRQ(AXP288, OV, 0, 4), |
Hans de Goede | 8b44e67 | 2016-12-14 14:52:06 +0100 | [diff] [blame] | 440 | INIT_REGMAP_IRQ(AXP288, FALLING_ALT, 0, 5), |
| 441 | INIT_REGMAP_IRQ(AXP288, RISING_ALT, 0, 6), |
| 442 | INIT_REGMAP_IRQ(AXP288, OV_ALT, 0, 7), |
Jacob Pan | af7e906 | 2014-10-06 21:17:14 -0700 | [diff] [blame] | 443 | |
Jacob Pan | ff3bbc5 | 2014-11-11 11:30:09 -0800 | [diff] [blame] | 444 | INIT_REGMAP_IRQ(AXP288, DONE, 1, 2), |
| 445 | INIT_REGMAP_IRQ(AXP288, CHARGING, 1, 3), |
Jacob Pan | af7e906 | 2014-10-06 21:17:14 -0700 | [diff] [blame] | 446 | INIT_REGMAP_IRQ(AXP288, SAFE_QUIT, 1, 4), |
| 447 | INIT_REGMAP_IRQ(AXP288, SAFE_ENTER, 1, 5), |
Jacob Pan | ff3bbc5 | 2014-11-11 11:30:09 -0800 | [diff] [blame] | 448 | INIT_REGMAP_IRQ(AXP288, ABSENT, 1, 6), |
| 449 | INIT_REGMAP_IRQ(AXP288, APPEND, 1, 7), |
Jacob Pan | af7e906 | 2014-10-06 21:17:14 -0700 | [diff] [blame] | 450 | |
| 451 | INIT_REGMAP_IRQ(AXP288, QWBTU, 2, 0), |
| 452 | INIT_REGMAP_IRQ(AXP288, WBTU, 2, 1), |
| 453 | INIT_REGMAP_IRQ(AXP288, QWBTO, 2, 2), |
Jacob Pan | ff3bbc5 | 2014-11-11 11:30:09 -0800 | [diff] [blame] | 454 | INIT_REGMAP_IRQ(AXP288, WBTO, 2, 3), |
Jacob Pan | af7e906 | 2014-10-06 21:17:14 -0700 | [diff] [blame] | 455 | INIT_REGMAP_IRQ(AXP288, QCBTU, 2, 4), |
| 456 | INIT_REGMAP_IRQ(AXP288, CBTU, 2, 5), |
| 457 | INIT_REGMAP_IRQ(AXP288, QCBTO, 2, 6), |
| 458 | INIT_REGMAP_IRQ(AXP288, CBTO, 2, 7), |
| 459 | |
| 460 | INIT_REGMAP_IRQ(AXP288, WL2, 3, 0), |
| 461 | INIT_REGMAP_IRQ(AXP288, WL1, 3, 1), |
| 462 | INIT_REGMAP_IRQ(AXP288, GPADC, 3, 2), |
| 463 | INIT_REGMAP_IRQ(AXP288, OT, 3, 7), |
| 464 | |
| 465 | INIT_REGMAP_IRQ(AXP288, GPIO0, 4, 0), |
| 466 | INIT_REGMAP_IRQ(AXP288, GPIO1, 4, 1), |
| 467 | INIT_REGMAP_IRQ(AXP288, POKO, 4, 2), |
| 468 | INIT_REGMAP_IRQ(AXP288, POKL, 4, 3), |
| 469 | INIT_REGMAP_IRQ(AXP288, POKS, 4, 4), |
| 470 | INIT_REGMAP_IRQ(AXP288, POKN, 4, 5), |
| 471 | INIT_REGMAP_IRQ(AXP288, POKP, 4, 6), |
Jacob Pan | ff3bbc5 | 2014-11-11 11:30:09 -0800 | [diff] [blame] | 472 | INIT_REGMAP_IRQ(AXP288, TIMER, 4, 7), |
Jacob Pan | af7e906 | 2014-10-06 21:17:14 -0700 | [diff] [blame] | 473 | |
| 474 | INIT_REGMAP_IRQ(AXP288, MV_CHNG, 5, 0), |
| 475 | INIT_REGMAP_IRQ(AXP288, BC_USB_CHNG, 5, 1), |
Carlo Caione | cfb61a4 | 2014-05-01 14:29:27 +0200 | [diff] [blame] | 476 | }; |
| 477 | |
Icenowy Zheng | 1578353 | 2017-04-17 19:57:40 +0800 | [diff] [blame] | 478 | static const struct regmap_irq axp803_regmap_irqs[] = { |
| 479 | INIT_REGMAP_IRQ(AXP803, ACIN_OVER_V, 0, 7), |
| 480 | INIT_REGMAP_IRQ(AXP803, ACIN_PLUGIN, 0, 6), |
| 481 | INIT_REGMAP_IRQ(AXP803, ACIN_REMOVAL, 0, 5), |
| 482 | INIT_REGMAP_IRQ(AXP803, VBUS_OVER_V, 0, 4), |
| 483 | INIT_REGMAP_IRQ(AXP803, VBUS_PLUGIN, 0, 3), |
| 484 | INIT_REGMAP_IRQ(AXP803, VBUS_REMOVAL, 0, 2), |
| 485 | INIT_REGMAP_IRQ(AXP803, BATT_PLUGIN, 1, 7), |
| 486 | INIT_REGMAP_IRQ(AXP803, BATT_REMOVAL, 1, 6), |
| 487 | INIT_REGMAP_IRQ(AXP803, BATT_ENT_ACT_MODE, 1, 5), |
| 488 | INIT_REGMAP_IRQ(AXP803, BATT_EXIT_ACT_MODE, 1, 4), |
| 489 | INIT_REGMAP_IRQ(AXP803, CHARG, 1, 3), |
| 490 | INIT_REGMAP_IRQ(AXP803, CHARG_DONE, 1, 2), |
| 491 | INIT_REGMAP_IRQ(AXP803, BATT_CHG_TEMP_HIGH, 2, 7), |
| 492 | INIT_REGMAP_IRQ(AXP803, BATT_CHG_TEMP_HIGH_END, 2, 6), |
| 493 | INIT_REGMAP_IRQ(AXP803, BATT_CHG_TEMP_LOW, 2, 5), |
| 494 | INIT_REGMAP_IRQ(AXP803, BATT_CHG_TEMP_LOW_END, 2, 4), |
| 495 | INIT_REGMAP_IRQ(AXP803, BATT_ACT_TEMP_HIGH, 2, 3), |
| 496 | INIT_REGMAP_IRQ(AXP803, BATT_ACT_TEMP_HIGH_END, 2, 2), |
| 497 | INIT_REGMAP_IRQ(AXP803, BATT_ACT_TEMP_LOW, 2, 1), |
| 498 | INIT_REGMAP_IRQ(AXP803, BATT_ACT_TEMP_LOW_END, 2, 0), |
| 499 | INIT_REGMAP_IRQ(AXP803, DIE_TEMP_HIGH, 3, 7), |
| 500 | INIT_REGMAP_IRQ(AXP803, GPADC, 3, 2), |
| 501 | INIT_REGMAP_IRQ(AXP803, LOW_PWR_LVL1, 3, 1), |
| 502 | INIT_REGMAP_IRQ(AXP803, LOW_PWR_LVL2, 3, 0), |
| 503 | INIT_REGMAP_IRQ(AXP803, TIMER, 4, 7), |
| 504 | INIT_REGMAP_IRQ(AXP803, PEK_RIS_EDGE, 4, 6), |
| 505 | INIT_REGMAP_IRQ(AXP803, PEK_FAL_EDGE, 4, 5), |
| 506 | INIT_REGMAP_IRQ(AXP803, PEK_SHORT, 4, 4), |
| 507 | INIT_REGMAP_IRQ(AXP803, PEK_LONG, 4, 3), |
| 508 | INIT_REGMAP_IRQ(AXP803, PEK_OVER_OFF, 4, 2), |
| 509 | INIT_REGMAP_IRQ(AXP803, GPIO1_INPUT, 4, 1), |
| 510 | INIT_REGMAP_IRQ(AXP803, GPIO0_INPUT, 4, 0), |
| 511 | INIT_REGMAP_IRQ(AXP803, BC_USB_CHNG, 5, 1), |
| 512 | INIT_REGMAP_IRQ(AXP803, MV_CHNG, 5, 0), |
| 513 | }; |
| 514 | |
Chen-Yu Tsai | 8824ee8 | 2016-08-27 15:55:38 +0800 | [diff] [blame] | 515 | static const struct regmap_irq axp806_regmap_irqs[] = { |
| 516 | INIT_REGMAP_IRQ(AXP806, DIE_TEMP_HIGH_LV1, 0, 0), |
| 517 | INIT_REGMAP_IRQ(AXP806, DIE_TEMP_HIGH_LV2, 0, 1), |
| 518 | INIT_REGMAP_IRQ(AXP806, DCDCA_V_LOW, 0, 3), |
| 519 | INIT_REGMAP_IRQ(AXP806, DCDCB_V_LOW, 0, 4), |
| 520 | INIT_REGMAP_IRQ(AXP806, DCDCC_V_LOW, 0, 5), |
| 521 | INIT_REGMAP_IRQ(AXP806, DCDCD_V_LOW, 0, 6), |
| 522 | INIT_REGMAP_IRQ(AXP806, DCDCE_V_LOW, 0, 7), |
| 523 | INIT_REGMAP_IRQ(AXP806, PWROK_LONG, 1, 0), |
| 524 | INIT_REGMAP_IRQ(AXP806, PWROK_SHORT, 1, 1), |
| 525 | INIT_REGMAP_IRQ(AXP806, WAKEUP, 1, 4), |
| 526 | INIT_REGMAP_IRQ(AXP806, PWROK_FALL, 1, 5), |
| 527 | INIT_REGMAP_IRQ(AXP806, PWROK_RISE, 1, 6), |
| 528 | }; |
| 529 | |
Chen-Yu Tsai | 20147f0 | 2016-03-29 17:22:26 +0800 | [diff] [blame] | 530 | static const struct regmap_irq axp809_regmap_irqs[] = { |
| 531 | INIT_REGMAP_IRQ(AXP809, ACIN_OVER_V, 0, 7), |
| 532 | INIT_REGMAP_IRQ(AXP809, ACIN_PLUGIN, 0, 6), |
| 533 | INIT_REGMAP_IRQ(AXP809, ACIN_REMOVAL, 0, 5), |
| 534 | INIT_REGMAP_IRQ(AXP809, VBUS_OVER_V, 0, 4), |
| 535 | INIT_REGMAP_IRQ(AXP809, VBUS_PLUGIN, 0, 3), |
| 536 | INIT_REGMAP_IRQ(AXP809, VBUS_REMOVAL, 0, 2), |
| 537 | INIT_REGMAP_IRQ(AXP809, VBUS_V_LOW, 0, 1), |
| 538 | INIT_REGMAP_IRQ(AXP809, BATT_PLUGIN, 1, 7), |
| 539 | INIT_REGMAP_IRQ(AXP809, BATT_REMOVAL, 1, 6), |
| 540 | INIT_REGMAP_IRQ(AXP809, BATT_ENT_ACT_MODE, 1, 5), |
| 541 | INIT_REGMAP_IRQ(AXP809, BATT_EXIT_ACT_MODE, 1, 4), |
| 542 | INIT_REGMAP_IRQ(AXP809, CHARG, 1, 3), |
| 543 | INIT_REGMAP_IRQ(AXP809, CHARG_DONE, 1, 2), |
| 544 | INIT_REGMAP_IRQ(AXP809, BATT_CHG_TEMP_HIGH, 2, 7), |
| 545 | INIT_REGMAP_IRQ(AXP809, BATT_CHG_TEMP_HIGH_END, 2, 6), |
| 546 | INIT_REGMAP_IRQ(AXP809, BATT_CHG_TEMP_LOW, 2, 5), |
| 547 | INIT_REGMAP_IRQ(AXP809, BATT_CHG_TEMP_LOW_END, 2, 4), |
| 548 | INIT_REGMAP_IRQ(AXP809, BATT_ACT_TEMP_HIGH, 2, 3), |
| 549 | INIT_REGMAP_IRQ(AXP809, BATT_ACT_TEMP_HIGH_END, 2, 2), |
| 550 | INIT_REGMAP_IRQ(AXP809, BATT_ACT_TEMP_LOW, 2, 1), |
| 551 | INIT_REGMAP_IRQ(AXP809, BATT_ACT_TEMP_LOW_END, 2, 0), |
| 552 | INIT_REGMAP_IRQ(AXP809, DIE_TEMP_HIGH, 3, 7), |
| 553 | INIT_REGMAP_IRQ(AXP809, LOW_PWR_LVL1, 3, 1), |
| 554 | INIT_REGMAP_IRQ(AXP809, LOW_PWR_LVL2, 3, 0), |
| 555 | INIT_REGMAP_IRQ(AXP809, TIMER, 4, 7), |
| 556 | INIT_REGMAP_IRQ(AXP809, PEK_RIS_EDGE, 4, 6), |
| 557 | INIT_REGMAP_IRQ(AXP809, PEK_FAL_EDGE, 4, 5), |
| 558 | INIT_REGMAP_IRQ(AXP809, PEK_SHORT, 4, 4), |
| 559 | INIT_REGMAP_IRQ(AXP809, PEK_LONG, 4, 3), |
| 560 | INIT_REGMAP_IRQ(AXP809, PEK_OVER_OFF, 4, 2), |
| 561 | INIT_REGMAP_IRQ(AXP809, GPIO1_INPUT, 4, 1), |
| 562 | INIT_REGMAP_IRQ(AXP809, GPIO0_INPUT, 4, 0), |
| 563 | }; |
| 564 | |
Michal Suchanek | d8d79f8 | 2015-07-11 14:59:56 +0200 | [diff] [blame] | 565 | static const struct regmap_irq_chip axp152_regmap_irq_chip = { |
| 566 | .name = "axp152_irq_chip", |
| 567 | .status_base = AXP152_IRQ1_STATE, |
| 568 | .ack_base = AXP152_IRQ1_STATE, |
| 569 | .mask_base = AXP152_IRQ1_EN, |
| 570 | .mask_invert = true, |
| 571 | .init_ack_masked = true, |
| 572 | .irqs = axp152_regmap_irqs, |
| 573 | .num_irqs = ARRAY_SIZE(axp152_regmap_irqs), |
| 574 | .num_regs = 3, |
| 575 | }; |
| 576 | |
Carlo Caione | cfb61a4 | 2014-05-01 14:29:27 +0200 | [diff] [blame] | 577 | static const struct regmap_irq_chip axp20x_regmap_irq_chip = { |
| 578 | .name = "axp20x_irq_chip", |
| 579 | .status_base = AXP20X_IRQ1_STATE, |
| 580 | .ack_base = AXP20X_IRQ1_STATE, |
| 581 | .mask_base = AXP20X_IRQ1_EN, |
Carlo Caione | cfb61a4 | 2014-05-01 14:29:27 +0200 | [diff] [blame] | 582 | .mask_invert = true, |
| 583 | .init_ack_masked = true, |
Jacob Pan | af7e906 | 2014-10-06 21:17:14 -0700 | [diff] [blame] | 584 | .irqs = axp20x_regmap_irqs, |
| 585 | .num_irqs = ARRAY_SIZE(axp20x_regmap_irqs), |
| 586 | .num_regs = 5, |
| 587 | |
| 588 | }; |
| 589 | |
Boris BREZILLON | f05be58 | 2015-04-10 12:09:01 +0800 | [diff] [blame] | 590 | static const struct regmap_irq_chip axp22x_regmap_irq_chip = { |
| 591 | .name = "axp22x_irq_chip", |
| 592 | .status_base = AXP20X_IRQ1_STATE, |
| 593 | .ack_base = AXP20X_IRQ1_STATE, |
| 594 | .mask_base = AXP20X_IRQ1_EN, |
| 595 | .mask_invert = true, |
| 596 | .init_ack_masked = true, |
| 597 | .irqs = axp22x_regmap_irqs, |
| 598 | .num_irqs = ARRAY_SIZE(axp22x_regmap_irqs), |
| 599 | .num_regs = 5, |
| 600 | }; |
| 601 | |
Jacob Pan | af7e906 | 2014-10-06 21:17:14 -0700 | [diff] [blame] | 602 | static const struct regmap_irq_chip axp288_regmap_irq_chip = { |
| 603 | .name = "axp288_irq_chip", |
| 604 | .status_base = AXP20X_IRQ1_STATE, |
| 605 | .ack_base = AXP20X_IRQ1_STATE, |
| 606 | .mask_base = AXP20X_IRQ1_EN, |
| 607 | .mask_invert = true, |
| 608 | .init_ack_masked = true, |
| 609 | .irqs = axp288_regmap_irqs, |
| 610 | .num_irqs = ARRAY_SIZE(axp288_regmap_irqs), |
| 611 | .num_regs = 6, |
| 612 | |
Carlo Caione | cfb61a4 | 2014-05-01 14:29:27 +0200 | [diff] [blame] | 613 | }; |
| 614 | |
Icenowy Zheng | 1578353 | 2017-04-17 19:57:40 +0800 | [diff] [blame] | 615 | static const struct regmap_irq_chip axp803_regmap_irq_chip = { |
| 616 | .name = "axp803", |
| 617 | .status_base = AXP20X_IRQ1_STATE, |
| 618 | .ack_base = AXP20X_IRQ1_STATE, |
| 619 | .mask_base = AXP20X_IRQ1_EN, |
| 620 | .mask_invert = true, |
| 621 | .init_ack_masked = true, |
| 622 | .irqs = axp803_regmap_irqs, |
| 623 | .num_irqs = ARRAY_SIZE(axp803_regmap_irqs), |
| 624 | .num_regs = 6, |
| 625 | }; |
| 626 | |
Chen-Yu Tsai | 8824ee8 | 2016-08-27 15:55:38 +0800 | [diff] [blame] | 627 | static const struct regmap_irq_chip axp806_regmap_irq_chip = { |
| 628 | .name = "axp806", |
| 629 | .status_base = AXP20X_IRQ1_STATE, |
| 630 | .ack_base = AXP20X_IRQ1_STATE, |
| 631 | .mask_base = AXP20X_IRQ1_EN, |
| 632 | .mask_invert = true, |
| 633 | .init_ack_masked = true, |
| 634 | .irqs = axp806_regmap_irqs, |
| 635 | .num_irqs = ARRAY_SIZE(axp806_regmap_irqs), |
| 636 | .num_regs = 2, |
| 637 | }; |
| 638 | |
Chen-Yu Tsai | 20147f0 | 2016-03-29 17:22:26 +0800 | [diff] [blame] | 639 | static const struct regmap_irq_chip axp809_regmap_irq_chip = { |
| 640 | .name = "axp809", |
| 641 | .status_base = AXP20X_IRQ1_STATE, |
| 642 | .ack_base = AXP20X_IRQ1_STATE, |
| 643 | .mask_base = AXP20X_IRQ1_EN, |
| 644 | .mask_invert = true, |
| 645 | .init_ack_masked = true, |
| 646 | .irqs = axp809_regmap_irqs, |
| 647 | .num_irqs = ARRAY_SIZE(axp809_regmap_irqs), |
| 648 | .num_regs = 5, |
| 649 | }; |
| 650 | |
Carlo Caione | cfb61a4 | 2014-05-01 14:29:27 +0200 | [diff] [blame] | 651 | static struct mfd_cell axp20x_cells[] = { |
| 652 | { |
Maxime Ripard | b419c16 | 2016-07-20 16:11:37 +0200 | [diff] [blame] | 653 | .name = "axp20x-gpio", |
| 654 | .of_compatible = "x-powers,axp209-gpio", |
| 655 | }, { |
Hans de Goede | 8de4efd | 2015-08-08 17:58:41 +0200 | [diff] [blame] | 656 | .name = "axp20x-pek", |
| 657 | .num_resources = ARRAY_SIZE(axp20x_pek_resources), |
| 658 | .resources = axp20x_pek_resources, |
Carlo Caione | cfb61a4 | 2014-05-01 14:29:27 +0200 | [diff] [blame] | 659 | }, { |
Hans de Goede | 8de4efd | 2015-08-08 17:58:41 +0200 | [diff] [blame] | 660 | .name = "axp20x-regulator", |
| 661 | }, { |
Quentin Schulz | 4d5e5c3 | 2017-03-20 09:16:47 +0100 | [diff] [blame] | 662 | .name = "axp20x-adc", |
Quentin Schulz | 034c3c9 | 2018-02-28 11:35:56 +0100 | [diff] [blame^] | 663 | .of_compatible = "x-powers,axp209-adc", |
Quentin Schulz | 4d5e5c3 | 2017-03-20 09:16:47 +0100 | [diff] [blame] | 664 | }, { |
Quentin Schulz | b4aeceb | 2017-04-05 10:10:55 +0200 | [diff] [blame] | 665 | .name = "axp20x-battery-power-supply", |
| 666 | .of_compatible = "x-powers,axp209-battery-power-supply", |
| 667 | }, { |
Michael Haas | cd7cf27 | 2016-05-06 07:19:49 +0200 | [diff] [blame] | 668 | .name = "axp20x-ac-power-supply", |
| 669 | .of_compatible = "x-powers,axp202-ac-power-supply", |
| 670 | .num_resources = ARRAY_SIZE(axp20x_ac_power_supply_resources), |
| 671 | .resources = axp20x_ac_power_supply_resources, |
| 672 | }, { |
Hans de Goede | 8de4efd | 2015-08-08 17:58:41 +0200 | [diff] [blame] | 673 | .name = "axp20x-usb-power-supply", |
| 674 | .of_compatible = "x-powers,axp202-usb-power-supply", |
| 675 | .num_resources = ARRAY_SIZE(axp20x_usb_power_supply_resources), |
| 676 | .resources = axp20x_usb_power_supply_resources, |
Carlo Caione | cfb61a4 | 2014-05-01 14:29:27 +0200 | [diff] [blame] | 677 | }, |
| 678 | }; |
| 679 | |
Quentin Schulz | 4c65056 | 2016-12-09 12:04:14 +0100 | [diff] [blame] | 680 | static struct mfd_cell axp221_cells[] = { |
| 681 | { |
Quentin Schulz | f446363 | 2017-07-26 16:28:27 +0800 | [diff] [blame] | 682 | .name = "axp221-pek", |
Quentin Schulz | 4c65056 | 2016-12-09 12:04:14 +0100 | [diff] [blame] | 683 | .num_resources = ARRAY_SIZE(axp22x_pek_resources), |
| 684 | .resources = axp22x_pek_resources, |
| 685 | }, { |
| 686 | .name = "axp20x-regulator", |
| 687 | }, { |
Quentin Schulz | 034c3c9 | 2018-02-28 11:35:56 +0100 | [diff] [blame^] | 688 | .name = "axp22x-adc", |
| 689 | .of_compatible = "x-powers,axp221-adc", |
Quentin Schulz | 4d5e5c3 | 2017-03-20 09:16:47 +0100 | [diff] [blame] | 690 | }, { |
Quentin Schulz | 95c4f53 | 2017-03-20 09:16:48 +0100 | [diff] [blame] | 691 | .name = "axp20x-ac-power-supply", |
| 692 | .of_compatible = "x-powers,axp221-ac-power-supply", |
| 693 | .num_resources = ARRAY_SIZE(axp20x_ac_power_supply_resources), |
| 694 | .resources = axp20x_ac_power_supply_resources, |
| 695 | }, { |
Quentin Schulz | b4aeceb | 2017-04-05 10:10:55 +0200 | [diff] [blame] | 696 | .name = "axp20x-battery-power-supply", |
| 697 | .of_compatible = "x-powers,axp221-battery-power-supply", |
| 698 | }, { |
Quentin Schulz | 4c65056 | 2016-12-09 12:04:14 +0100 | [diff] [blame] | 699 | .name = "axp20x-usb-power-supply", |
| 700 | .of_compatible = "x-powers,axp221-usb-power-supply", |
| 701 | .num_resources = ARRAY_SIZE(axp22x_usb_power_supply_resources), |
| 702 | .resources = axp22x_usb_power_supply_resources, |
| 703 | }, |
| 704 | }; |
| 705 | |
| 706 | static struct mfd_cell axp223_cells[] = { |
Boris BREZILLON | f05be58 | 2015-04-10 12:09:01 +0800 | [diff] [blame] | 707 | { |
Quentin Schulz | f446363 | 2017-07-26 16:28:27 +0800 | [diff] [blame] | 708 | .name = "axp221-pek", |
Boris BREZILLON | f05be58 | 2015-04-10 12:09:01 +0800 | [diff] [blame] | 709 | .num_resources = ARRAY_SIZE(axp22x_pek_resources), |
| 710 | .resources = axp22x_pek_resources, |
Chen-Yu Tsai | 6d4fa89 | 2015-04-10 12:09:06 +0800 | [diff] [blame] | 711 | }, { |
Quentin Schulz | 4d5e5c3 | 2017-03-20 09:16:47 +0100 | [diff] [blame] | 712 | .name = "axp22x-adc", |
Quentin Schulz | 034c3c9 | 2018-02-28 11:35:56 +0100 | [diff] [blame^] | 713 | .of_compatible = "x-powers,axp221-adc", |
Quentin Schulz | 4d5e5c3 | 2017-03-20 09:16:47 +0100 | [diff] [blame] | 714 | }, { |
Quentin Schulz | b4aeceb | 2017-04-05 10:10:55 +0200 | [diff] [blame] | 715 | .name = "axp20x-battery-power-supply", |
| 716 | .of_compatible = "x-powers,axp221-battery-power-supply", |
| 717 | }, { |
Chen-Yu Tsai | 6d4fa89 | 2015-04-10 12:09:06 +0800 | [diff] [blame] | 718 | .name = "axp20x-regulator", |
Hans de Goede | ecd98cc | 2016-06-02 19:18:55 +0200 | [diff] [blame] | 719 | }, { |
Quentin Schulz | 95c4f53 | 2017-03-20 09:16:48 +0100 | [diff] [blame] | 720 | .name = "axp20x-ac-power-supply", |
| 721 | .of_compatible = "x-powers,axp221-ac-power-supply", |
| 722 | .num_resources = ARRAY_SIZE(axp20x_ac_power_supply_resources), |
| 723 | .resources = axp20x_ac_power_supply_resources, |
| 724 | }, { |
Hans de Goede | ecd98cc | 2016-06-02 19:18:55 +0200 | [diff] [blame] | 725 | .name = "axp20x-usb-power-supply", |
Quentin Schulz | 4c65056 | 2016-12-09 12:04:14 +0100 | [diff] [blame] | 726 | .of_compatible = "x-powers,axp223-usb-power-supply", |
Hans de Goede | ecd98cc | 2016-06-02 19:18:55 +0200 | [diff] [blame] | 727 | .num_resources = ARRAY_SIZE(axp22x_usb_power_supply_resources), |
| 728 | .resources = axp22x_usb_power_supply_resources, |
Boris BREZILLON | f05be58 | 2015-04-10 12:09:01 +0800 | [diff] [blame] | 729 | }, |
| 730 | }; |
| 731 | |
Michal Suchanek | d8d79f8 | 2015-07-11 14:59:56 +0200 | [diff] [blame] | 732 | static struct mfd_cell axp152_cells[] = { |
| 733 | { |
| 734 | .name = "axp20x-pek", |
| 735 | .num_resources = ARRAY_SIZE(axp152_pek_resources), |
| 736 | .resources = axp152_pek_resources, |
| 737 | }, |
| 738 | }; |
| 739 | |
Jacob Pan | af7e906 | 2014-10-06 21:17:14 -0700 | [diff] [blame] | 740 | static struct resource axp288_adc_resources[] = { |
| 741 | { |
| 742 | .name = "GPADC", |
| 743 | .start = AXP288_IRQ_GPADC, |
| 744 | .end = AXP288_IRQ_GPADC, |
| 745 | .flags = IORESOURCE_IRQ, |
| 746 | }, |
| 747 | }; |
| 748 | |
Ramakrishna Pallala | bdb01f7 | 2015-04-03 00:49:47 +0530 | [diff] [blame] | 749 | static struct resource axp288_extcon_resources[] = { |
| 750 | { |
| 751 | .start = AXP288_IRQ_VBUS_FALL, |
| 752 | .end = AXP288_IRQ_VBUS_FALL, |
| 753 | .flags = IORESOURCE_IRQ, |
| 754 | }, |
| 755 | { |
| 756 | .start = AXP288_IRQ_VBUS_RISE, |
| 757 | .end = AXP288_IRQ_VBUS_RISE, |
| 758 | .flags = IORESOURCE_IRQ, |
| 759 | }, |
| 760 | { |
| 761 | .start = AXP288_IRQ_MV_CHNG, |
| 762 | .end = AXP288_IRQ_MV_CHNG, |
| 763 | .flags = IORESOURCE_IRQ, |
| 764 | }, |
| 765 | { |
| 766 | .start = AXP288_IRQ_BC_USB_CHNG, |
| 767 | .end = AXP288_IRQ_BC_USB_CHNG, |
| 768 | .flags = IORESOURCE_IRQ, |
| 769 | }, |
| 770 | }; |
| 771 | |
Jacob Pan | af7e906 | 2014-10-06 21:17:14 -0700 | [diff] [blame] | 772 | static struct resource axp288_charger_resources[] = { |
| 773 | { |
| 774 | .start = AXP288_IRQ_OV, |
| 775 | .end = AXP288_IRQ_OV, |
| 776 | .flags = IORESOURCE_IRQ, |
| 777 | }, |
| 778 | { |
| 779 | .start = AXP288_IRQ_DONE, |
| 780 | .end = AXP288_IRQ_DONE, |
| 781 | .flags = IORESOURCE_IRQ, |
| 782 | }, |
| 783 | { |
| 784 | .start = AXP288_IRQ_CHARGING, |
| 785 | .end = AXP288_IRQ_CHARGING, |
| 786 | .flags = IORESOURCE_IRQ, |
| 787 | }, |
| 788 | { |
| 789 | .start = AXP288_IRQ_SAFE_QUIT, |
| 790 | .end = AXP288_IRQ_SAFE_QUIT, |
| 791 | .flags = IORESOURCE_IRQ, |
| 792 | }, |
| 793 | { |
| 794 | .start = AXP288_IRQ_SAFE_ENTER, |
| 795 | .end = AXP288_IRQ_SAFE_ENTER, |
| 796 | .flags = IORESOURCE_IRQ, |
| 797 | }, |
| 798 | { |
| 799 | .start = AXP288_IRQ_QCBTU, |
| 800 | .end = AXP288_IRQ_QCBTU, |
| 801 | .flags = IORESOURCE_IRQ, |
| 802 | }, |
| 803 | { |
| 804 | .start = AXP288_IRQ_CBTU, |
| 805 | .end = AXP288_IRQ_CBTU, |
| 806 | .flags = IORESOURCE_IRQ, |
| 807 | }, |
| 808 | { |
| 809 | .start = AXP288_IRQ_QCBTO, |
| 810 | .end = AXP288_IRQ_QCBTO, |
| 811 | .flags = IORESOURCE_IRQ, |
| 812 | }, |
| 813 | { |
| 814 | .start = AXP288_IRQ_CBTO, |
| 815 | .end = AXP288_IRQ_CBTO, |
| 816 | .flags = IORESOURCE_IRQ, |
| 817 | }, |
| 818 | }; |
| 819 | |
| 820 | static struct mfd_cell axp288_cells[] = { |
| 821 | { |
| 822 | .name = "axp288_adc", |
| 823 | .num_resources = ARRAY_SIZE(axp288_adc_resources), |
| 824 | .resources = axp288_adc_resources, |
| 825 | }, |
| 826 | { |
Ramakrishna Pallala | bdb01f7 | 2015-04-03 00:49:47 +0530 | [diff] [blame] | 827 | .name = "axp288_extcon", |
| 828 | .num_resources = ARRAY_SIZE(axp288_extcon_resources), |
| 829 | .resources = axp288_extcon_resources, |
| 830 | }, |
| 831 | { |
Jacob Pan | af7e906 | 2014-10-06 21:17:14 -0700 | [diff] [blame] | 832 | .name = "axp288_charger", |
| 833 | .num_resources = ARRAY_SIZE(axp288_charger_resources), |
| 834 | .resources = axp288_charger_resources, |
| 835 | }, |
| 836 | { |
Todd Brandt | d6387874 | 2015-02-02 15:41:41 -0800 | [diff] [blame] | 837 | .name = "axp288_fuel_gauge", |
| 838 | .num_resources = ARRAY_SIZE(axp288_fuel_gauge_resources), |
| 839 | .resources = axp288_fuel_gauge_resources, |
Jacob Pan | af7e906 | 2014-10-06 21:17:14 -0700 | [diff] [blame] | 840 | }, |
Aaron Lu | d8139f6 | 2014-11-24 17:24:47 +0800 | [diff] [blame] | 841 | { |
Quentin Schulz | f446363 | 2017-07-26 16:28:27 +0800 | [diff] [blame] | 842 | .name = "axp221-pek", |
Borun Fu | e56e5ad | 2015-10-14 16:16:26 +0800 | [diff] [blame] | 843 | .num_resources = ARRAY_SIZE(axp288_power_button_resources), |
| 844 | .resources = axp288_power_button_resources, |
| 845 | }, |
| 846 | { |
Aaron Lu | d8139f6 | 2014-11-24 17:24:47 +0800 | [diff] [blame] | 847 | .name = "axp288_pmic_acpi", |
| 848 | }, |
Jacob Pan | af7e906 | 2014-10-06 21:17:14 -0700 | [diff] [blame] | 849 | }; |
| 850 | |
Icenowy Zheng | 1578353 | 2017-04-17 19:57:40 +0800 | [diff] [blame] | 851 | static struct mfd_cell axp803_cells[] = { |
| 852 | { |
Quentin Schulz | f446363 | 2017-07-26 16:28:27 +0800 | [diff] [blame] | 853 | .name = "axp221-pek", |
Icenowy Zheng | 1578353 | 2017-04-17 19:57:40 +0800 | [diff] [blame] | 854 | .num_resources = ARRAY_SIZE(axp803_pek_resources), |
| 855 | .resources = axp803_pek_resources, |
Icenowy Zheng | 9b79ff1 | 2017-05-18 15:16:50 +0800 | [diff] [blame] | 856 | }, |
| 857 | { .name = "axp20x-regulator" }, |
Icenowy Zheng | 1578353 | 2017-04-17 19:57:40 +0800 | [diff] [blame] | 858 | }; |
| 859 | |
Chen-Yu Tsai | 8824ee8 | 2016-08-27 15:55:38 +0800 | [diff] [blame] | 860 | static struct mfd_cell axp806_cells[] = { |
| 861 | { |
| 862 | .id = 2, |
| 863 | .name = "axp20x-regulator", |
| 864 | }, |
| 865 | }; |
| 866 | |
Chen-Yu Tsai | 20147f0 | 2016-03-29 17:22:26 +0800 | [diff] [blame] | 867 | static struct mfd_cell axp809_cells[] = { |
| 868 | { |
Quentin Schulz | f446363 | 2017-07-26 16:28:27 +0800 | [diff] [blame] | 869 | .name = "axp221-pek", |
Chen-Yu Tsai | 20147f0 | 2016-03-29 17:22:26 +0800 | [diff] [blame] | 870 | .num_resources = ARRAY_SIZE(axp809_pek_resources), |
| 871 | .resources = axp809_pek_resources, |
| 872 | }, { |
Chen-Yu Tsai | 8824ee8 | 2016-08-27 15:55:38 +0800 | [diff] [blame] | 873 | .id = 1, |
Chen-Yu Tsai | 20147f0 | 2016-03-29 17:22:26 +0800 | [diff] [blame] | 874 | .name = "axp20x-regulator", |
| 875 | }, |
| 876 | }; |
| 877 | |
Chen-Yu Tsai | 7303733 | 2017-07-26 16:28:26 +0800 | [diff] [blame] | 878 | static struct mfd_cell axp813_cells[] = { |
| 879 | { |
Quentin Schulz | f446363 | 2017-07-26 16:28:27 +0800 | [diff] [blame] | 880 | .name = "axp221-pek", |
Chen-Yu Tsai | 7303733 | 2017-07-26 16:28:26 +0800 | [diff] [blame] | 881 | .num_resources = ARRAY_SIZE(axp803_pek_resources), |
| 882 | .resources = axp803_pek_resources, |
Chen-Yu Tsai | 9a43206 | 2017-10-18 16:31:31 +0800 | [diff] [blame] | 883 | }, { |
| 884 | .name = "axp20x-regulator", |
Quentin Schulz | 2bb3253 | 2017-12-05 15:46:47 +0100 | [diff] [blame] | 885 | }, { |
| 886 | .name = "axp20x-gpio", |
| 887 | .of_compatible = "x-powers,axp813-gpio", |
Chen-Yu Tsai | 7303733 | 2017-07-26 16:28:26 +0800 | [diff] [blame] | 888 | } |
| 889 | }; |
| 890 | |
Carlo Caione | cfb61a4 | 2014-05-01 14:29:27 +0200 | [diff] [blame] | 891 | static struct axp20x_dev *axp20x_pm_power_off; |
| 892 | static void axp20x_power_off(void) |
| 893 | { |
Jacob Pan | af7e906 | 2014-10-06 21:17:14 -0700 | [diff] [blame] | 894 | if (axp20x_pm_power_off->variant == AXP288_ID) |
| 895 | return; |
| 896 | |
Carlo Caione | cfb61a4 | 2014-05-01 14:29:27 +0200 | [diff] [blame] | 897 | regmap_write(axp20x_pm_power_off->regmap, AXP20X_OFF_CTRL, |
| 898 | AXP20X_OFF); |
Hans de Goede | 179dc63 | 2016-06-05 15:50:48 +0200 | [diff] [blame] | 899 | |
| 900 | /* Give capacitors etc. time to drain to avoid kernel panic msg. */ |
| 901 | msleep(500); |
Carlo Caione | cfb61a4 | 2014-05-01 14:29:27 +0200 | [diff] [blame] | 902 | } |
| 903 | |
Chen-Yu Tsai | 4fd4115 | 2016-02-12 10:02:42 +0800 | [diff] [blame] | 904 | int axp20x_match_device(struct axp20x_dev *axp20x) |
Jacob Pan | af7e906 | 2014-10-06 21:17:14 -0700 | [diff] [blame] | 905 | { |
Chen-Yu Tsai | e47a3cf | 2016-02-12 10:02:39 +0800 | [diff] [blame] | 906 | struct device *dev = axp20x->dev; |
Jacob Pan | af7e906 | 2014-10-06 21:17:14 -0700 | [diff] [blame] | 907 | const struct acpi_device_id *acpi_id; |
| 908 | const struct of_device_id *of_id; |
| 909 | |
| 910 | if (dev->of_node) { |
Chen-Yu Tsai | af7acc3 | 2016-02-12 10:02:40 +0800 | [diff] [blame] | 911 | of_id = of_match_device(dev->driver->of_match_table, dev); |
Jacob Pan | af7e906 | 2014-10-06 21:17:14 -0700 | [diff] [blame] | 912 | if (!of_id) { |
| 913 | dev_err(dev, "Unable to match OF ID\n"); |
| 914 | return -ENODEV; |
| 915 | } |
Chen-Yu Tsai | 2260a45 | 2016-02-12 10:02:43 +0800 | [diff] [blame] | 916 | axp20x->variant = (long)of_id->data; |
Jacob Pan | af7e906 | 2014-10-06 21:17:14 -0700 | [diff] [blame] | 917 | } else { |
| 918 | acpi_id = acpi_match_device(dev->driver->acpi_match_table, dev); |
| 919 | if (!acpi_id || !acpi_id->driver_data) { |
| 920 | dev_err(dev, "Unable to match ACPI ID and data\n"); |
| 921 | return -ENODEV; |
| 922 | } |
Chen-Yu Tsai | 2260a45 | 2016-02-12 10:02:43 +0800 | [diff] [blame] | 923 | axp20x->variant = (long)acpi_id->driver_data; |
Jacob Pan | af7e906 | 2014-10-06 21:17:14 -0700 | [diff] [blame] | 924 | } |
| 925 | |
| 926 | switch (axp20x->variant) { |
Michal Suchanek | d8d79f8 | 2015-07-11 14:59:56 +0200 | [diff] [blame] | 927 | case AXP152_ID: |
| 928 | axp20x->nr_cells = ARRAY_SIZE(axp152_cells); |
| 929 | axp20x->cells = axp152_cells; |
| 930 | axp20x->regmap_cfg = &axp152_regmap_config; |
| 931 | axp20x->regmap_irq_chip = &axp152_regmap_irq_chip; |
| 932 | break; |
Jacob Pan | af7e906 | 2014-10-06 21:17:14 -0700 | [diff] [blame] | 933 | case AXP202_ID: |
| 934 | case AXP209_ID: |
| 935 | axp20x->nr_cells = ARRAY_SIZE(axp20x_cells); |
| 936 | axp20x->cells = axp20x_cells; |
| 937 | axp20x->regmap_cfg = &axp20x_regmap_config; |
| 938 | axp20x->regmap_irq_chip = &axp20x_regmap_irq_chip; |
| 939 | break; |
Boris BREZILLON | f05be58 | 2015-04-10 12:09:01 +0800 | [diff] [blame] | 940 | case AXP221_ID: |
Quentin Schulz | 4c65056 | 2016-12-09 12:04:14 +0100 | [diff] [blame] | 941 | axp20x->nr_cells = ARRAY_SIZE(axp221_cells); |
| 942 | axp20x->cells = axp221_cells; |
| 943 | axp20x->regmap_cfg = &axp22x_regmap_config; |
| 944 | axp20x->regmap_irq_chip = &axp22x_regmap_irq_chip; |
| 945 | break; |
Chen-Yu Tsai | 02071f0 | 2016-02-12 10:02:44 +0800 | [diff] [blame] | 946 | case AXP223_ID: |
Quentin Schulz | 4c65056 | 2016-12-09 12:04:14 +0100 | [diff] [blame] | 947 | axp20x->nr_cells = ARRAY_SIZE(axp223_cells); |
| 948 | axp20x->cells = axp223_cells; |
Boris BREZILLON | f05be58 | 2015-04-10 12:09:01 +0800 | [diff] [blame] | 949 | axp20x->regmap_cfg = &axp22x_regmap_config; |
| 950 | axp20x->regmap_irq_chip = &axp22x_regmap_irq_chip; |
| 951 | break; |
Jacob Pan | af7e906 | 2014-10-06 21:17:14 -0700 | [diff] [blame] | 952 | case AXP288_ID: |
| 953 | axp20x->cells = axp288_cells; |
| 954 | axp20x->nr_cells = ARRAY_SIZE(axp288_cells); |
| 955 | axp20x->regmap_cfg = &axp288_regmap_config; |
| 956 | axp20x->regmap_irq_chip = &axp288_regmap_irq_chip; |
Hans de Goede | 0a5454c | 2016-12-14 14:52:05 +0100 | [diff] [blame] | 957 | axp20x->irq_flags = IRQF_TRIGGER_LOW; |
Jacob Pan | af7e906 | 2014-10-06 21:17:14 -0700 | [diff] [blame] | 958 | break; |
Icenowy Zheng | 1578353 | 2017-04-17 19:57:40 +0800 | [diff] [blame] | 959 | case AXP803_ID: |
| 960 | axp20x->nr_cells = ARRAY_SIZE(axp803_cells); |
| 961 | axp20x->cells = axp803_cells; |
| 962 | axp20x->regmap_cfg = &axp288_regmap_config; |
| 963 | axp20x->regmap_irq_chip = &axp803_regmap_irq_chip; |
| 964 | break; |
Chen-Yu Tsai | 8824ee8 | 2016-08-27 15:55:38 +0800 | [diff] [blame] | 965 | case AXP806_ID: |
| 966 | axp20x->nr_cells = ARRAY_SIZE(axp806_cells); |
| 967 | axp20x->cells = axp806_cells; |
| 968 | axp20x->regmap_cfg = &axp806_regmap_config; |
| 969 | axp20x->regmap_irq_chip = &axp806_regmap_irq_chip; |
| 970 | break; |
Chen-Yu Tsai | 20147f0 | 2016-03-29 17:22:26 +0800 | [diff] [blame] | 971 | case AXP809_ID: |
| 972 | axp20x->nr_cells = ARRAY_SIZE(axp809_cells); |
| 973 | axp20x->cells = axp809_cells; |
| 974 | axp20x->regmap_cfg = &axp22x_regmap_config; |
| 975 | axp20x->regmap_irq_chip = &axp809_regmap_irq_chip; |
| 976 | break; |
Chen-Yu Tsai | 7303733 | 2017-07-26 16:28:26 +0800 | [diff] [blame] | 977 | case AXP813_ID: |
| 978 | axp20x->nr_cells = ARRAY_SIZE(axp813_cells); |
| 979 | axp20x->cells = axp813_cells; |
| 980 | axp20x->regmap_cfg = &axp288_regmap_config; |
| 981 | /* |
| 982 | * The IRQ table given in the datasheet is incorrect. |
| 983 | * In IRQ enable/status registers 1, there are separate |
| 984 | * IRQs for ACIN and VBUS, instead of bits [7:5] being |
| 985 | * the same as bits [4:2]. So it shares the same IRQs |
| 986 | * as the AXP803, rather than the AXP288. |
| 987 | */ |
| 988 | axp20x->regmap_irq_chip = &axp803_regmap_irq_chip; |
| 989 | break; |
Jacob Pan | af7e906 | 2014-10-06 21:17:14 -0700 | [diff] [blame] | 990 | default: |
| 991 | dev_err(dev, "unsupported AXP20X ID %lu\n", axp20x->variant); |
| 992 | return -EINVAL; |
| 993 | } |
| 994 | dev_info(dev, "AXP20x variant %s found\n", |
Chen-Yu Tsai | 2260a45 | 2016-02-12 10:02:43 +0800 | [diff] [blame] | 995 | axp20x_model_names[axp20x->variant]); |
Jacob Pan | af7e906 | 2014-10-06 21:17:14 -0700 | [diff] [blame] | 996 | |
| 997 | return 0; |
| 998 | } |
Chen-Yu Tsai | 4fd4115 | 2016-02-12 10:02:42 +0800 | [diff] [blame] | 999 | EXPORT_SYMBOL(axp20x_match_device); |
Jacob Pan | af7e906 | 2014-10-06 21:17:14 -0700 | [diff] [blame] | 1000 | |
Chen-Yu Tsai | 4fd4115 | 2016-02-12 10:02:42 +0800 | [diff] [blame] | 1001 | int axp20x_device_probe(struct axp20x_dev *axp20x) |
Carlo Caione | cfb61a4 | 2014-05-01 14:29:27 +0200 | [diff] [blame] | 1002 | { |
Carlo Caione | cfb61a4 | 2014-05-01 14:29:27 +0200 | [diff] [blame] | 1003 | int ret; |
| 1004 | |
Chen-Yu Tsai | 696f0b3 | 2017-01-05 12:01:03 +0800 | [diff] [blame] | 1005 | /* |
| 1006 | * The AXP806 supports either master/standalone or slave mode. |
| 1007 | * Slave mode allows sharing the serial bus, even with multiple |
| 1008 | * AXP806 which all have the same hardware address. |
| 1009 | * |
| 1010 | * This is done with extra "serial interface address extension", |
| 1011 | * or AXP806_BUS_ADDR_EXT, and "register address extension", or |
| 1012 | * AXP806_REG_ADDR_EXT, registers. The former is read-only, with |
| 1013 | * 1 bit customizable at the factory, and 1 bit depending on the |
| 1014 | * state of an external pin. The latter is writable. The device |
| 1015 | * will only respond to operations to its other registers when |
| 1016 | * the these device addressing bits (in the upper 4 bits of the |
| 1017 | * registers) match. |
| 1018 | * |
Rask Ingemann Lambertsen | c036969 | 2017-02-22 20:42:02 +0100 | [diff] [blame] | 1019 | * By default we support an AXP806 chained to an AXP809 in slave |
| 1020 | * mode. Boards which use an AXP806 in master mode can set the |
| 1021 | * property "x-powers,master-mode" to override the default. |
Chen-Yu Tsai | 696f0b3 | 2017-01-05 12:01:03 +0800 | [diff] [blame] | 1022 | */ |
Rask Ingemann Lambertsen | c036969 | 2017-02-22 20:42:02 +0100 | [diff] [blame] | 1023 | if (axp20x->variant == AXP806_ID) { |
| 1024 | if (of_property_read_bool(axp20x->dev->of_node, |
| 1025 | "x-powers,master-mode")) |
| 1026 | regmap_write(axp20x->regmap, AXP806_REG_ADDR_EXT, |
| 1027 | AXP806_REG_ADDR_EXT_ADDR_MASTER_MODE); |
| 1028 | else |
| 1029 | regmap_write(axp20x->regmap, AXP806_REG_ADDR_EXT, |
| 1030 | AXP806_REG_ADDR_EXT_ADDR_SLAVE_MODE); |
| 1031 | } |
Chen-Yu Tsai | 696f0b3 | 2017-01-05 12:01:03 +0800 | [diff] [blame] | 1032 | |
Chen-Yu Tsai | 4fd4115 | 2016-02-12 10:02:42 +0800 | [diff] [blame] | 1033 | ret = regmap_add_irq_chip(axp20x->regmap, axp20x->irq, |
Hans de Goede | 0a5454c | 2016-12-14 14:52:05 +0100 | [diff] [blame] | 1034 | IRQF_ONESHOT | IRQF_SHARED | axp20x->irq_flags, |
| 1035 | -1, axp20x->regmap_irq_chip, &axp20x->regmap_irqc); |
Carlo Caione | cfb61a4 | 2014-05-01 14:29:27 +0200 | [diff] [blame] | 1036 | if (ret) { |
Chen-Yu Tsai | 4fd4115 | 2016-02-12 10:02:42 +0800 | [diff] [blame] | 1037 | dev_err(axp20x->dev, "failed to add irq chip: %d\n", ret); |
Carlo Caione | cfb61a4 | 2014-05-01 14:29:27 +0200 | [diff] [blame] | 1038 | return ret; |
| 1039 | } |
| 1040 | |
Jacob Pan | af7e906 | 2014-10-06 21:17:14 -0700 | [diff] [blame] | 1041 | ret = mfd_add_devices(axp20x->dev, -1, axp20x->cells, |
Chen-Yu Tsai | 2260a45 | 2016-02-12 10:02:43 +0800 | [diff] [blame] | 1042 | axp20x->nr_cells, NULL, 0, NULL); |
Carlo Caione | cfb61a4 | 2014-05-01 14:29:27 +0200 | [diff] [blame] | 1043 | |
| 1044 | if (ret) { |
Chen-Yu Tsai | 4fd4115 | 2016-02-12 10:02:42 +0800 | [diff] [blame] | 1045 | dev_err(axp20x->dev, "failed to add MFD devices: %d\n", ret); |
| 1046 | regmap_del_irq_chip(axp20x->irq, axp20x->regmap_irqc); |
Carlo Caione | cfb61a4 | 2014-05-01 14:29:27 +0200 | [diff] [blame] | 1047 | return ret; |
| 1048 | } |
| 1049 | |
| 1050 | if (!pm_power_off) { |
| 1051 | axp20x_pm_power_off = axp20x; |
| 1052 | pm_power_off = axp20x_power_off; |
| 1053 | } |
| 1054 | |
Chen-Yu Tsai | 4fd4115 | 2016-02-12 10:02:42 +0800 | [diff] [blame] | 1055 | dev_info(axp20x->dev, "AXP20X driver loaded\n"); |
Carlo Caione | cfb61a4 | 2014-05-01 14:29:27 +0200 | [diff] [blame] | 1056 | |
| 1057 | return 0; |
| 1058 | } |
Chen-Yu Tsai | 4fd4115 | 2016-02-12 10:02:42 +0800 | [diff] [blame] | 1059 | EXPORT_SYMBOL(axp20x_device_probe); |
Carlo Caione | cfb61a4 | 2014-05-01 14:29:27 +0200 | [diff] [blame] | 1060 | |
Chen-Yu Tsai | 4fd4115 | 2016-02-12 10:02:42 +0800 | [diff] [blame] | 1061 | int axp20x_device_remove(struct axp20x_dev *axp20x) |
Carlo Caione | cfb61a4 | 2014-05-01 14:29:27 +0200 | [diff] [blame] | 1062 | { |
Carlo Caione | cfb61a4 | 2014-05-01 14:29:27 +0200 | [diff] [blame] | 1063 | if (axp20x == axp20x_pm_power_off) { |
| 1064 | axp20x_pm_power_off = NULL; |
| 1065 | pm_power_off = NULL; |
| 1066 | } |
| 1067 | |
| 1068 | mfd_remove_devices(axp20x->dev); |
Chen-Yu Tsai | 4fd4115 | 2016-02-12 10:02:42 +0800 | [diff] [blame] | 1069 | regmap_del_irq_chip(axp20x->irq, axp20x->regmap_irqc); |
Carlo Caione | cfb61a4 | 2014-05-01 14:29:27 +0200 | [diff] [blame] | 1070 | |
| 1071 | return 0; |
| 1072 | } |
Chen-Yu Tsai | 4fd4115 | 2016-02-12 10:02:42 +0800 | [diff] [blame] | 1073 | EXPORT_SYMBOL(axp20x_device_remove); |
Carlo Caione | cfb61a4 | 2014-05-01 14:29:27 +0200 | [diff] [blame] | 1074 | |
| 1075 | MODULE_DESCRIPTION("PMIC MFD core driver for AXP20X"); |
| 1076 | MODULE_AUTHOR("Carlo Caione <carlo@caione.org>"); |
| 1077 | MODULE_LICENSE("GPL"); |