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