18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0-only
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci * MFD core driver for the X-Powers' Power Management ICs
48c2ecf20Sopenharmony_ci *
58c2ecf20Sopenharmony_ci * AXP20x typically comprises an adaptive USB-Compatible PWM charger, BUCK DC-DC
68c2ecf20Sopenharmony_ci * converters, LDOs, multiple 12-bit ADCs of voltage, current and temperature
78c2ecf20Sopenharmony_ci * as well as configurable GPIOs.
88c2ecf20Sopenharmony_ci *
98c2ecf20Sopenharmony_ci * This file contains the interface independent core functions.
108c2ecf20Sopenharmony_ci *
118c2ecf20Sopenharmony_ci * Copyright (C) 2014 Carlo Caione
128c2ecf20Sopenharmony_ci *
138c2ecf20Sopenharmony_ci * Author: Carlo Caione <carlo@caione.org>
148c2ecf20Sopenharmony_ci */
158c2ecf20Sopenharmony_ci
168c2ecf20Sopenharmony_ci#include <linux/acpi.h>
178c2ecf20Sopenharmony_ci#include <linux/bitops.h>
188c2ecf20Sopenharmony_ci#include <linux/delay.h>
198c2ecf20Sopenharmony_ci#include <linux/err.h>
208c2ecf20Sopenharmony_ci#include <linux/interrupt.h>
218c2ecf20Sopenharmony_ci#include <linux/kernel.h>
228c2ecf20Sopenharmony_ci#include <linux/mfd/axp20x.h>
238c2ecf20Sopenharmony_ci#include <linux/mfd/core.h>
248c2ecf20Sopenharmony_ci#include <linux/module.h>
258c2ecf20Sopenharmony_ci#include <linux/of_device.h>
268c2ecf20Sopenharmony_ci#include <linux/pm_runtime.h>
278c2ecf20Sopenharmony_ci#include <linux/regmap.h>
288c2ecf20Sopenharmony_ci#include <linux/regulator/consumer.h>
298c2ecf20Sopenharmony_ci
308c2ecf20Sopenharmony_ci#define AXP20X_OFF	BIT(7)
318c2ecf20Sopenharmony_ci
328c2ecf20Sopenharmony_ci#define AXP806_REG_ADDR_EXT_ADDR_MASTER_MODE	0
338c2ecf20Sopenharmony_ci#define AXP806_REG_ADDR_EXT_ADDR_SLAVE_MODE	BIT(4)
348c2ecf20Sopenharmony_ci
358c2ecf20Sopenharmony_cistatic const char * const axp20x_model_names[] = {
368c2ecf20Sopenharmony_ci	"AXP152",
378c2ecf20Sopenharmony_ci	"AXP202",
388c2ecf20Sopenharmony_ci	"AXP209",
398c2ecf20Sopenharmony_ci	"AXP221",
408c2ecf20Sopenharmony_ci	"AXP223",
418c2ecf20Sopenharmony_ci	"AXP288",
428c2ecf20Sopenharmony_ci	"AXP803",
438c2ecf20Sopenharmony_ci	"AXP806",
448c2ecf20Sopenharmony_ci	"AXP809",
458c2ecf20Sopenharmony_ci	"AXP813",
468c2ecf20Sopenharmony_ci};
478c2ecf20Sopenharmony_ci
488c2ecf20Sopenharmony_cistatic const struct regmap_range axp152_writeable_ranges[] = {
498c2ecf20Sopenharmony_ci	regmap_reg_range(AXP152_LDO3456_DC1234_CTRL, AXP152_IRQ3_STATE),
508c2ecf20Sopenharmony_ci	regmap_reg_range(AXP152_DCDC_MODE, AXP152_PWM1_DUTY_CYCLE),
518c2ecf20Sopenharmony_ci};
528c2ecf20Sopenharmony_ci
538c2ecf20Sopenharmony_cistatic const struct regmap_range axp152_volatile_ranges[] = {
548c2ecf20Sopenharmony_ci	regmap_reg_range(AXP152_PWR_OP_MODE, AXP152_PWR_OP_MODE),
558c2ecf20Sopenharmony_ci	regmap_reg_range(AXP152_IRQ1_EN, AXP152_IRQ3_STATE),
568c2ecf20Sopenharmony_ci	regmap_reg_range(AXP152_GPIO_INPUT, AXP152_GPIO_INPUT),
578c2ecf20Sopenharmony_ci};
588c2ecf20Sopenharmony_ci
598c2ecf20Sopenharmony_cistatic const struct regmap_access_table axp152_writeable_table = {
608c2ecf20Sopenharmony_ci	.yes_ranges	= axp152_writeable_ranges,
618c2ecf20Sopenharmony_ci	.n_yes_ranges	= ARRAY_SIZE(axp152_writeable_ranges),
628c2ecf20Sopenharmony_ci};
638c2ecf20Sopenharmony_ci
648c2ecf20Sopenharmony_cistatic const struct regmap_access_table axp152_volatile_table = {
658c2ecf20Sopenharmony_ci	.yes_ranges	= axp152_volatile_ranges,
668c2ecf20Sopenharmony_ci	.n_yes_ranges	= ARRAY_SIZE(axp152_volatile_ranges),
678c2ecf20Sopenharmony_ci};
688c2ecf20Sopenharmony_ci
698c2ecf20Sopenharmony_cistatic const struct regmap_range axp20x_writeable_ranges[] = {
708c2ecf20Sopenharmony_ci	regmap_reg_range(AXP20X_DATACACHE(0), AXP20X_IRQ5_STATE),
718c2ecf20Sopenharmony_ci	regmap_reg_range(AXP20X_CHRG_CTRL1, AXP20X_CHRG_CTRL2),
728c2ecf20Sopenharmony_ci	regmap_reg_range(AXP20X_DCDC_MODE, AXP20X_FG_RES),
738c2ecf20Sopenharmony_ci	regmap_reg_range(AXP20X_RDC_H, AXP20X_OCV(AXP20X_OCV_MAX)),
748c2ecf20Sopenharmony_ci};
758c2ecf20Sopenharmony_ci
768c2ecf20Sopenharmony_cistatic const struct regmap_range axp20x_volatile_ranges[] = {
778c2ecf20Sopenharmony_ci	regmap_reg_range(AXP20X_PWR_INPUT_STATUS, AXP20X_USB_OTG_STATUS),
788c2ecf20Sopenharmony_ci	regmap_reg_range(AXP20X_CHRG_CTRL1, AXP20X_CHRG_CTRL2),
798c2ecf20Sopenharmony_ci	regmap_reg_range(AXP20X_IRQ1_EN, AXP20X_IRQ5_STATE),
808c2ecf20Sopenharmony_ci	regmap_reg_range(AXP20X_ACIN_V_ADC_H, AXP20X_IPSOUT_V_HIGH_L),
818c2ecf20Sopenharmony_ci	regmap_reg_range(AXP20X_GPIO20_SS, AXP20X_GPIO3_CTRL),
828c2ecf20Sopenharmony_ci	regmap_reg_range(AXP20X_FG_RES, AXP20X_RDC_L),
838c2ecf20Sopenharmony_ci};
848c2ecf20Sopenharmony_ci
858c2ecf20Sopenharmony_cistatic const struct regmap_access_table axp20x_writeable_table = {
868c2ecf20Sopenharmony_ci	.yes_ranges	= axp20x_writeable_ranges,
878c2ecf20Sopenharmony_ci	.n_yes_ranges	= ARRAY_SIZE(axp20x_writeable_ranges),
888c2ecf20Sopenharmony_ci};
898c2ecf20Sopenharmony_ci
908c2ecf20Sopenharmony_cistatic const struct regmap_access_table axp20x_volatile_table = {
918c2ecf20Sopenharmony_ci	.yes_ranges	= axp20x_volatile_ranges,
928c2ecf20Sopenharmony_ci	.n_yes_ranges	= ARRAY_SIZE(axp20x_volatile_ranges),
938c2ecf20Sopenharmony_ci};
948c2ecf20Sopenharmony_ci
958c2ecf20Sopenharmony_ci/* AXP22x ranges are shared with the AXP809, as they cover the same range */
968c2ecf20Sopenharmony_cistatic const struct regmap_range axp22x_writeable_ranges[] = {
978c2ecf20Sopenharmony_ci	regmap_reg_range(AXP20X_DATACACHE(0), AXP20X_IRQ5_STATE),
988c2ecf20Sopenharmony_ci	regmap_reg_range(AXP20X_CHRG_CTRL1, AXP22X_CHRG_CTRL3),
998c2ecf20Sopenharmony_ci	regmap_reg_range(AXP20X_DCDC_MODE, AXP22X_BATLOW_THRES1),
1008c2ecf20Sopenharmony_ci};
1018c2ecf20Sopenharmony_ci
1028c2ecf20Sopenharmony_cistatic const struct regmap_range axp22x_volatile_ranges[] = {
1038c2ecf20Sopenharmony_ci	regmap_reg_range(AXP20X_PWR_INPUT_STATUS, AXP20X_PWR_OP_MODE),
1048c2ecf20Sopenharmony_ci	regmap_reg_range(AXP20X_IRQ1_EN, AXP20X_IRQ5_STATE),
1058c2ecf20Sopenharmony_ci	regmap_reg_range(AXP22X_GPIO_STATE, AXP22X_GPIO_STATE),
1068c2ecf20Sopenharmony_ci	regmap_reg_range(AXP22X_PMIC_TEMP_H, AXP20X_IPSOUT_V_HIGH_L),
1078c2ecf20Sopenharmony_ci	regmap_reg_range(AXP20X_FG_RES, AXP20X_FG_RES),
1088c2ecf20Sopenharmony_ci};
1098c2ecf20Sopenharmony_ci
1108c2ecf20Sopenharmony_cistatic const struct regmap_access_table axp22x_writeable_table = {
1118c2ecf20Sopenharmony_ci	.yes_ranges	= axp22x_writeable_ranges,
1128c2ecf20Sopenharmony_ci	.n_yes_ranges	= ARRAY_SIZE(axp22x_writeable_ranges),
1138c2ecf20Sopenharmony_ci};
1148c2ecf20Sopenharmony_ci
1158c2ecf20Sopenharmony_cistatic const struct regmap_access_table axp22x_volatile_table = {
1168c2ecf20Sopenharmony_ci	.yes_ranges	= axp22x_volatile_ranges,
1178c2ecf20Sopenharmony_ci	.n_yes_ranges	= ARRAY_SIZE(axp22x_volatile_ranges),
1188c2ecf20Sopenharmony_ci};
1198c2ecf20Sopenharmony_ci
1208c2ecf20Sopenharmony_ci/* AXP288 ranges are shared with the AXP803, as they cover the same range */
1218c2ecf20Sopenharmony_cistatic const struct regmap_range axp288_writeable_ranges[] = {
1228c2ecf20Sopenharmony_ci	regmap_reg_range(AXP20X_DATACACHE(0), AXP20X_IRQ6_STATE),
1238c2ecf20Sopenharmony_ci	regmap_reg_range(AXP20X_DCDC_MODE, AXP288_FG_TUNE5),
1248c2ecf20Sopenharmony_ci};
1258c2ecf20Sopenharmony_ci
1268c2ecf20Sopenharmony_cistatic const struct regmap_range axp288_volatile_ranges[] = {
1278c2ecf20Sopenharmony_ci	regmap_reg_range(AXP20X_PWR_INPUT_STATUS, AXP288_POWER_REASON),
1288c2ecf20Sopenharmony_ci	regmap_reg_range(AXP22X_PWR_OUT_CTRL1, AXP22X_ALDO3_V_OUT),
1298c2ecf20Sopenharmony_ci	regmap_reg_range(AXP288_BC_GLOBAL, AXP288_BC_GLOBAL),
1308c2ecf20Sopenharmony_ci	regmap_reg_range(AXP288_BC_DET_STAT, AXP20X_VBUS_IPSOUT_MGMT),
1318c2ecf20Sopenharmony_ci	regmap_reg_range(AXP20X_CHRG_BAK_CTRL, AXP20X_CHRG_BAK_CTRL),
1328c2ecf20Sopenharmony_ci	regmap_reg_range(AXP20X_IRQ1_EN, AXP20X_IPSOUT_V_HIGH_L),
1338c2ecf20Sopenharmony_ci	regmap_reg_range(AXP20X_TIMER_CTRL, AXP20X_TIMER_CTRL),
1348c2ecf20Sopenharmony_ci	regmap_reg_range(AXP20X_GPIO1_CTRL, AXP22X_GPIO_STATE),
1358c2ecf20Sopenharmony_ci	regmap_reg_range(AXP288_RT_BATT_V_H, AXP288_RT_BATT_V_L),
1368c2ecf20Sopenharmony_ci	regmap_reg_range(AXP20X_FG_RES, AXP288_FG_CC_CAP_REG),
1378c2ecf20Sopenharmony_ci};
1388c2ecf20Sopenharmony_ci
1398c2ecf20Sopenharmony_cistatic const struct regmap_access_table axp288_writeable_table = {
1408c2ecf20Sopenharmony_ci	.yes_ranges	= axp288_writeable_ranges,
1418c2ecf20Sopenharmony_ci	.n_yes_ranges	= ARRAY_SIZE(axp288_writeable_ranges),
1428c2ecf20Sopenharmony_ci};
1438c2ecf20Sopenharmony_ci
1448c2ecf20Sopenharmony_cistatic const struct regmap_access_table axp288_volatile_table = {
1458c2ecf20Sopenharmony_ci	.yes_ranges	= axp288_volatile_ranges,
1468c2ecf20Sopenharmony_ci	.n_yes_ranges	= ARRAY_SIZE(axp288_volatile_ranges),
1478c2ecf20Sopenharmony_ci};
1488c2ecf20Sopenharmony_ci
1498c2ecf20Sopenharmony_cistatic const struct regmap_range axp806_writeable_ranges[] = {
1508c2ecf20Sopenharmony_ci	regmap_reg_range(AXP20X_DATACACHE(0), AXP20X_DATACACHE(3)),
1518c2ecf20Sopenharmony_ci	regmap_reg_range(AXP806_PWR_OUT_CTRL1, AXP806_CLDO3_V_CTRL),
1528c2ecf20Sopenharmony_ci	regmap_reg_range(AXP20X_IRQ1_EN, AXP20X_IRQ2_EN),
1538c2ecf20Sopenharmony_ci	regmap_reg_range(AXP20X_IRQ1_STATE, AXP20X_IRQ2_STATE),
1548c2ecf20Sopenharmony_ci	regmap_reg_range(AXP806_REG_ADDR_EXT, AXP806_REG_ADDR_EXT),
1558c2ecf20Sopenharmony_ci};
1568c2ecf20Sopenharmony_ci
1578c2ecf20Sopenharmony_cistatic const struct regmap_range axp806_volatile_ranges[] = {
1588c2ecf20Sopenharmony_ci	regmap_reg_range(AXP20X_IRQ1_STATE, AXP20X_IRQ2_STATE),
1598c2ecf20Sopenharmony_ci};
1608c2ecf20Sopenharmony_ci
1618c2ecf20Sopenharmony_cistatic const struct regmap_access_table axp806_writeable_table = {
1628c2ecf20Sopenharmony_ci	.yes_ranges	= axp806_writeable_ranges,
1638c2ecf20Sopenharmony_ci	.n_yes_ranges	= ARRAY_SIZE(axp806_writeable_ranges),
1648c2ecf20Sopenharmony_ci};
1658c2ecf20Sopenharmony_ci
1668c2ecf20Sopenharmony_cistatic const struct regmap_access_table axp806_volatile_table = {
1678c2ecf20Sopenharmony_ci	.yes_ranges	= axp806_volatile_ranges,
1688c2ecf20Sopenharmony_ci	.n_yes_ranges	= ARRAY_SIZE(axp806_volatile_ranges),
1698c2ecf20Sopenharmony_ci};
1708c2ecf20Sopenharmony_ci
1718c2ecf20Sopenharmony_cistatic const struct resource axp152_pek_resources[] = {
1728c2ecf20Sopenharmony_ci	DEFINE_RES_IRQ_NAMED(AXP152_IRQ_PEK_RIS_EDGE, "PEK_DBR"),
1738c2ecf20Sopenharmony_ci	DEFINE_RES_IRQ_NAMED(AXP152_IRQ_PEK_FAL_EDGE, "PEK_DBF"),
1748c2ecf20Sopenharmony_ci};
1758c2ecf20Sopenharmony_ci
1768c2ecf20Sopenharmony_cistatic const struct resource axp20x_ac_power_supply_resources[] = {
1778c2ecf20Sopenharmony_ci	DEFINE_RES_IRQ_NAMED(AXP20X_IRQ_ACIN_PLUGIN, "ACIN_PLUGIN"),
1788c2ecf20Sopenharmony_ci	DEFINE_RES_IRQ_NAMED(AXP20X_IRQ_ACIN_REMOVAL, "ACIN_REMOVAL"),
1798c2ecf20Sopenharmony_ci	DEFINE_RES_IRQ_NAMED(AXP20X_IRQ_ACIN_OVER_V, "ACIN_OVER_V"),
1808c2ecf20Sopenharmony_ci};
1818c2ecf20Sopenharmony_ci
1828c2ecf20Sopenharmony_cistatic const struct resource axp20x_pek_resources[] = {
1838c2ecf20Sopenharmony_ci	DEFINE_RES_IRQ_NAMED(AXP20X_IRQ_PEK_RIS_EDGE, "PEK_DBR"),
1848c2ecf20Sopenharmony_ci	DEFINE_RES_IRQ_NAMED(AXP20X_IRQ_PEK_FAL_EDGE, "PEK_DBF"),
1858c2ecf20Sopenharmony_ci};
1868c2ecf20Sopenharmony_ci
1878c2ecf20Sopenharmony_cistatic const struct resource axp20x_usb_power_supply_resources[] = {
1888c2ecf20Sopenharmony_ci	DEFINE_RES_IRQ_NAMED(AXP20X_IRQ_VBUS_PLUGIN, "VBUS_PLUGIN"),
1898c2ecf20Sopenharmony_ci	DEFINE_RES_IRQ_NAMED(AXP20X_IRQ_VBUS_REMOVAL, "VBUS_REMOVAL"),
1908c2ecf20Sopenharmony_ci	DEFINE_RES_IRQ_NAMED(AXP20X_IRQ_VBUS_VALID, "VBUS_VALID"),
1918c2ecf20Sopenharmony_ci	DEFINE_RES_IRQ_NAMED(AXP20X_IRQ_VBUS_NOT_VALID, "VBUS_NOT_VALID"),
1928c2ecf20Sopenharmony_ci};
1938c2ecf20Sopenharmony_ci
1948c2ecf20Sopenharmony_cistatic const struct resource axp22x_usb_power_supply_resources[] = {
1958c2ecf20Sopenharmony_ci	DEFINE_RES_IRQ_NAMED(AXP22X_IRQ_VBUS_PLUGIN, "VBUS_PLUGIN"),
1968c2ecf20Sopenharmony_ci	DEFINE_RES_IRQ_NAMED(AXP22X_IRQ_VBUS_REMOVAL, "VBUS_REMOVAL"),
1978c2ecf20Sopenharmony_ci};
1988c2ecf20Sopenharmony_ci
1998c2ecf20Sopenharmony_ci/* AXP803 and AXP813/AXP818 share the same interrupts */
2008c2ecf20Sopenharmony_cistatic const struct resource axp803_usb_power_supply_resources[] = {
2018c2ecf20Sopenharmony_ci	DEFINE_RES_IRQ_NAMED(AXP803_IRQ_VBUS_PLUGIN, "VBUS_PLUGIN"),
2028c2ecf20Sopenharmony_ci	DEFINE_RES_IRQ_NAMED(AXP803_IRQ_VBUS_REMOVAL, "VBUS_REMOVAL"),
2038c2ecf20Sopenharmony_ci};
2048c2ecf20Sopenharmony_ci
2058c2ecf20Sopenharmony_cistatic const struct resource axp22x_pek_resources[] = {
2068c2ecf20Sopenharmony_ci	DEFINE_RES_IRQ_NAMED(AXP22X_IRQ_PEK_RIS_EDGE, "PEK_DBR"),
2078c2ecf20Sopenharmony_ci	DEFINE_RES_IRQ_NAMED(AXP22X_IRQ_PEK_FAL_EDGE, "PEK_DBF"),
2088c2ecf20Sopenharmony_ci};
2098c2ecf20Sopenharmony_ci
2108c2ecf20Sopenharmony_cistatic const struct resource axp288_power_button_resources[] = {
2118c2ecf20Sopenharmony_ci	DEFINE_RES_IRQ_NAMED(AXP288_IRQ_POKP, "PEK_DBR"),
2128c2ecf20Sopenharmony_ci	DEFINE_RES_IRQ_NAMED(AXP288_IRQ_POKN, "PEK_DBF"),
2138c2ecf20Sopenharmony_ci};
2148c2ecf20Sopenharmony_ci
2158c2ecf20Sopenharmony_cistatic const struct resource axp288_fuel_gauge_resources[] = {
2168c2ecf20Sopenharmony_ci	DEFINE_RES_IRQ(AXP288_IRQ_QWBTU),
2178c2ecf20Sopenharmony_ci	DEFINE_RES_IRQ(AXP288_IRQ_WBTU),
2188c2ecf20Sopenharmony_ci	DEFINE_RES_IRQ(AXP288_IRQ_QWBTO),
2198c2ecf20Sopenharmony_ci	DEFINE_RES_IRQ(AXP288_IRQ_WBTO),
2208c2ecf20Sopenharmony_ci	DEFINE_RES_IRQ(AXP288_IRQ_WL2),
2218c2ecf20Sopenharmony_ci	DEFINE_RES_IRQ(AXP288_IRQ_WL1),
2228c2ecf20Sopenharmony_ci};
2238c2ecf20Sopenharmony_ci
2248c2ecf20Sopenharmony_cistatic const struct resource axp803_pek_resources[] = {
2258c2ecf20Sopenharmony_ci	DEFINE_RES_IRQ_NAMED(AXP803_IRQ_PEK_RIS_EDGE, "PEK_DBR"),
2268c2ecf20Sopenharmony_ci	DEFINE_RES_IRQ_NAMED(AXP803_IRQ_PEK_FAL_EDGE, "PEK_DBF"),
2278c2ecf20Sopenharmony_ci};
2288c2ecf20Sopenharmony_ci
2298c2ecf20Sopenharmony_cistatic const struct resource axp806_pek_resources[] = {
2308c2ecf20Sopenharmony_ci	DEFINE_RES_IRQ_NAMED(AXP806_IRQ_POK_RISE, "PEK_DBR"),
2318c2ecf20Sopenharmony_ci	DEFINE_RES_IRQ_NAMED(AXP806_IRQ_POK_FALL, "PEK_DBF"),
2328c2ecf20Sopenharmony_ci};
2338c2ecf20Sopenharmony_ci
2348c2ecf20Sopenharmony_cistatic const struct resource axp809_pek_resources[] = {
2358c2ecf20Sopenharmony_ci	DEFINE_RES_IRQ_NAMED(AXP809_IRQ_PEK_RIS_EDGE, "PEK_DBR"),
2368c2ecf20Sopenharmony_ci	DEFINE_RES_IRQ_NAMED(AXP809_IRQ_PEK_FAL_EDGE, "PEK_DBF"),
2378c2ecf20Sopenharmony_ci};
2388c2ecf20Sopenharmony_ci
2398c2ecf20Sopenharmony_cistatic const struct regmap_config axp152_regmap_config = {
2408c2ecf20Sopenharmony_ci	.reg_bits	= 8,
2418c2ecf20Sopenharmony_ci	.val_bits	= 8,
2428c2ecf20Sopenharmony_ci	.wr_table	= &axp152_writeable_table,
2438c2ecf20Sopenharmony_ci	.volatile_table	= &axp152_volatile_table,
2448c2ecf20Sopenharmony_ci	.max_register	= AXP152_PWM1_DUTY_CYCLE,
2458c2ecf20Sopenharmony_ci	.cache_type	= REGCACHE_RBTREE,
2468c2ecf20Sopenharmony_ci};
2478c2ecf20Sopenharmony_ci
2488c2ecf20Sopenharmony_cistatic const struct regmap_config axp20x_regmap_config = {
2498c2ecf20Sopenharmony_ci	.reg_bits	= 8,
2508c2ecf20Sopenharmony_ci	.val_bits	= 8,
2518c2ecf20Sopenharmony_ci	.wr_table	= &axp20x_writeable_table,
2528c2ecf20Sopenharmony_ci	.volatile_table	= &axp20x_volatile_table,
2538c2ecf20Sopenharmony_ci	.max_register	= AXP20X_OCV(AXP20X_OCV_MAX),
2548c2ecf20Sopenharmony_ci	.cache_type	= REGCACHE_RBTREE,
2558c2ecf20Sopenharmony_ci};
2568c2ecf20Sopenharmony_ci
2578c2ecf20Sopenharmony_cistatic const struct regmap_config axp22x_regmap_config = {
2588c2ecf20Sopenharmony_ci	.reg_bits	= 8,
2598c2ecf20Sopenharmony_ci	.val_bits	= 8,
2608c2ecf20Sopenharmony_ci	.wr_table	= &axp22x_writeable_table,
2618c2ecf20Sopenharmony_ci	.volatile_table	= &axp22x_volatile_table,
2628c2ecf20Sopenharmony_ci	.max_register	= AXP22X_BATLOW_THRES1,
2638c2ecf20Sopenharmony_ci	.cache_type	= REGCACHE_RBTREE,
2648c2ecf20Sopenharmony_ci};
2658c2ecf20Sopenharmony_ci
2668c2ecf20Sopenharmony_cistatic const struct regmap_config axp288_regmap_config = {
2678c2ecf20Sopenharmony_ci	.reg_bits	= 8,
2688c2ecf20Sopenharmony_ci	.val_bits	= 8,
2698c2ecf20Sopenharmony_ci	.wr_table	= &axp288_writeable_table,
2708c2ecf20Sopenharmony_ci	.volatile_table	= &axp288_volatile_table,
2718c2ecf20Sopenharmony_ci	.max_register	= AXP288_FG_TUNE5,
2728c2ecf20Sopenharmony_ci	.cache_type	= REGCACHE_RBTREE,
2738c2ecf20Sopenharmony_ci};
2748c2ecf20Sopenharmony_ci
2758c2ecf20Sopenharmony_cistatic const struct regmap_config axp806_regmap_config = {
2768c2ecf20Sopenharmony_ci	.reg_bits	= 8,
2778c2ecf20Sopenharmony_ci	.val_bits	= 8,
2788c2ecf20Sopenharmony_ci	.wr_table	= &axp806_writeable_table,
2798c2ecf20Sopenharmony_ci	.volatile_table	= &axp806_volatile_table,
2808c2ecf20Sopenharmony_ci	.max_register	= AXP806_REG_ADDR_EXT,
2818c2ecf20Sopenharmony_ci	.cache_type	= REGCACHE_RBTREE,
2828c2ecf20Sopenharmony_ci};
2838c2ecf20Sopenharmony_ci
2848c2ecf20Sopenharmony_ci#define INIT_REGMAP_IRQ(_variant, _irq, _off, _mask)			\
2858c2ecf20Sopenharmony_ci	[_variant##_IRQ_##_irq] = { .reg_offset = (_off), .mask = BIT(_mask) }
2868c2ecf20Sopenharmony_ci
2878c2ecf20Sopenharmony_cistatic const struct regmap_irq axp152_regmap_irqs[] = {
2888c2ecf20Sopenharmony_ci	INIT_REGMAP_IRQ(AXP152, LDO0IN_CONNECT,		0, 6),
2898c2ecf20Sopenharmony_ci	INIT_REGMAP_IRQ(AXP152, LDO0IN_REMOVAL,		0, 5),
2908c2ecf20Sopenharmony_ci	INIT_REGMAP_IRQ(AXP152, ALDO0IN_CONNECT,	0, 3),
2918c2ecf20Sopenharmony_ci	INIT_REGMAP_IRQ(AXP152, ALDO0IN_REMOVAL,	0, 2),
2928c2ecf20Sopenharmony_ci	INIT_REGMAP_IRQ(AXP152, DCDC1_V_LOW,		1, 5),
2938c2ecf20Sopenharmony_ci	INIT_REGMAP_IRQ(AXP152, DCDC2_V_LOW,		1, 4),
2948c2ecf20Sopenharmony_ci	INIT_REGMAP_IRQ(AXP152, DCDC3_V_LOW,		1, 3),
2958c2ecf20Sopenharmony_ci	INIT_REGMAP_IRQ(AXP152, DCDC4_V_LOW,		1, 2),
2968c2ecf20Sopenharmony_ci	INIT_REGMAP_IRQ(AXP152, PEK_SHORT,		1, 1),
2978c2ecf20Sopenharmony_ci	INIT_REGMAP_IRQ(AXP152, PEK_LONG,		1, 0),
2988c2ecf20Sopenharmony_ci	INIT_REGMAP_IRQ(AXP152, TIMER,			2, 7),
2998c2ecf20Sopenharmony_ci	INIT_REGMAP_IRQ(AXP152, PEK_RIS_EDGE,		2, 6),
3008c2ecf20Sopenharmony_ci	INIT_REGMAP_IRQ(AXP152, PEK_FAL_EDGE,		2, 5),
3018c2ecf20Sopenharmony_ci	INIT_REGMAP_IRQ(AXP152, GPIO3_INPUT,		2, 3),
3028c2ecf20Sopenharmony_ci	INIT_REGMAP_IRQ(AXP152, GPIO2_INPUT,		2, 2),
3038c2ecf20Sopenharmony_ci	INIT_REGMAP_IRQ(AXP152, GPIO1_INPUT,		2, 1),
3048c2ecf20Sopenharmony_ci	INIT_REGMAP_IRQ(AXP152, GPIO0_INPUT,		2, 0),
3058c2ecf20Sopenharmony_ci};
3068c2ecf20Sopenharmony_ci
3078c2ecf20Sopenharmony_cistatic const struct regmap_irq axp20x_regmap_irqs[] = {
3088c2ecf20Sopenharmony_ci	INIT_REGMAP_IRQ(AXP20X, ACIN_OVER_V,		0, 7),
3098c2ecf20Sopenharmony_ci	INIT_REGMAP_IRQ(AXP20X, ACIN_PLUGIN,		0, 6),
3108c2ecf20Sopenharmony_ci	INIT_REGMAP_IRQ(AXP20X, ACIN_REMOVAL,	        0, 5),
3118c2ecf20Sopenharmony_ci	INIT_REGMAP_IRQ(AXP20X, VBUS_OVER_V,		0, 4),
3128c2ecf20Sopenharmony_ci	INIT_REGMAP_IRQ(AXP20X, VBUS_PLUGIN,		0, 3),
3138c2ecf20Sopenharmony_ci	INIT_REGMAP_IRQ(AXP20X, VBUS_REMOVAL,	        0, 2),
3148c2ecf20Sopenharmony_ci	INIT_REGMAP_IRQ(AXP20X, VBUS_V_LOW,		0, 1),
3158c2ecf20Sopenharmony_ci	INIT_REGMAP_IRQ(AXP20X, BATT_PLUGIN,		1, 7),
3168c2ecf20Sopenharmony_ci	INIT_REGMAP_IRQ(AXP20X, BATT_REMOVAL,	        1, 6),
3178c2ecf20Sopenharmony_ci	INIT_REGMAP_IRQ(AXP20X, BATT_ENT_ACT_MODE,	1, 5),
3188c2ecf20Sopenharmony_ci	INIT_REGMAP_IRQ(AXP20X, BATT_EXIT_ACT_MODE,	1, 4),
3198c2ecf20Sopenharmony_ci	INIT_REGMAP_IRQ(AXP20X, CHARG,		        1, 3),
3208c2ecf20Sopenharmony_ci	INIT_REGMAP_IRQ(AXP20X, CHARG_DONE,		1, 2),
3218c2ecf20Sopenharmony_ci	INIT_REGMAP_IRQ(AXP20X, BATT_TEMP_HIGH,	        1, 1),
3228c2ecf20Sopenharmony_ci	INIT_REGMAP_IRQ(AXP20X, BATT_TEMP_LOW,	        1, 0),
3238c2ecf20Sopenharmony_ci	INIT_REGMAP_IRQ(AXP20X, DIE_TEMP_HIGH,	        2, 7),
3248c2ecf20Sopenharmony_ci	INIT_REGMAP_IRQ(AXP20X, CHARG_I_LOW,		2, 6),
3258c2ecf20Sopenharmony_ci	INIT_REGMAP_IRQ(AXP20X, DCDC1_V_LONG,	        2, 5),
3268c2ecf20Sopenharmony_ci	INIT_REGMAP_IRQ(AXP20X, DCDC2_V_LONG,	        2, 4),
3278c2ecf20Sopenharmony_ci	INIT_REGMAP_IRQ(AXP20X, DCDC3_V_LONG,	        2, 3),
3288c2ecf20Sopenharmony_ci	INIT_REGMAP_IRQ(AXP20X, PEK_SHORT,		2, 1),
3298c2ecf20Sopenharmony_ci	INIT_REGMAP_IRQ(AXP20X, PEK_LONG,		2, 0),
3308c2ecf20Sopenharmony_ci	INIT_REGMAP_IRQ(AXP20X, N_OE_PWR_ON,		3, 7),
3318c2ecf20Sopenharmony_ci	INIT_REGMAP_IRQ(AXP20X, N_OE_PWR_OFF,	        3, 6),
3328c2ecf20Sopenharmony_ci	INIT_REGMAP_IRQ(AXP20X, VBUS_VALID,		3, 5),
3338c2ecf20Sopenharmony_ci	INIT_REGMAP_IRQ(AXP20X, VBUS_NOT_VALID,	        3, 4),
3348c2ecf20Sopenharmony_ci	INIT_REGMAP_IRQ(AXP20X, VBUS_SESS_VALID,	3, 3),
3358c2ecf20Sopenharmony_ci	INIT_REGMAP_IRQ(AXP20X, VBUS_SESS_END,	        3, 2),
3368c2ecf20Sopenharmony_ci	INIT_REGMAP_IRQ(AXP20X, LOW_PWR_LVL1,	        3, 1),
3378c2ecf20Sopenharmony_ci	INIT_REGMAP_IRQ(AXP20X, LOW_PWR_LVL2,	        3, 0),
3388c2ecf20Sopenharmony_ci	INIT_REGMAP_IRQ(AXP20X, TIMER,		        4, 7),
3398c2ecf20Sopenharmony_ci	INIT_REGMAP_IRQ(AXP20X, PEK_RIS_EDGE,	        4, 6),
3408c2ecf20Sopenharmony_ci	INIT_REGMAP_IRQ(AXP20X, PEK_FAL_EDGE,	        4, 5),
3418c2ecf20Sopenharmony_ci	INIT_REGMAP_IRQ(AXP20X, GPIO3_INPUT,		4, 3),
3428c2ecf20Sopenharmony_ci	INIT_REGMAP_IRQ(AXP20X, GPIO2_INPUT,		4, 2),
3438c2ecf20Sopenharmony_ci	INIT_REGMAP_IRQ(AXP20X, GPIO1_INPUT,		4, 1),
3448c2ecf20Sopenharmony_ci	INIT_REGMAP_IRQ(AXP20X, GPIO0_INPUT,		4, 0),
3458c2ecf20Sopenharmony_ci};
3468c2ecf20Sopenharmony_ci
3478c2ecf20Sopenharmony_cistatic const struct regmap_irq axp22x_regmap_irqs[] = {
3488c2ecf20Sopenharmony_ci	INIT_REGMAP_IRQ(AXP22X, ACIN_OVER_V,		0, 7),
3498c2ecf20Sopenharmony_ci	INIT_REGMAP_IRQ(AXP22X, ACIN_PLUGIN,		0, 6),
3508c2ecf20Sopenharmony_ci	INIT_REGMAP_IRQ(AXP22X, ACIN_REMOVAL,	        0, 5),
3518c2ecf20Sopenharmony_ci	INIT_REGMAP_IRQ(AXP22X, VBUS_OVER_V,		0, 4),
3528c2ecf20Sopenharmony_ci	INIT_REGMAP_IRQ(AXP22X, VBUS_PLUGIN,		0, 3),
3538c2ecf20Sopenharmony_ci	INIT_REGMAP_IRQ(AXP22X, VBUS_REMOVAL,	        0, 2),
3548c2ecf20Sopenharmony_ci	INIT_REGMAP_IRQ(AXP22X, VBUS_V_LOW,		0, 1),
3558c2ecf20Sopenharmony_ci	INIT_REGMAP_IRQ(AXP22X, BATT_PLUGIN,		1, 7),
3568c2ecf20Sopenharmony_ci	INIT_REGMAP_IRQ(AXP22X, BATT_REMOVAL,	        1, 6),
3578c2ecf20Sopenharmony_ci	INIT_REGMAP_IRQ(AXP22X, BATT_ENT_ACT_MODE,	1, 5),
3588c2ecf20Sopenharmony_ci	INIT_REGMAP_IRQ(AXP22X, BATT_EXIT_ACT_MODE,	1, 4),
3598c2ecf20Sopenharmony_ci	INIT_REGMAP_IRQ(AXP22X, CHARG,		        1, 3),
3608c2ecf20Sopenharmony_ci	INIT_REGMAP_IRQ(AXP22X, CHARG_DONE,		1, 2),
3618c2ecf20Sopenharmony_ci	INIT_REGMAP_IRQ(AXP22X, BATT_TEMP_HIGH,	        1, 1),
3628c2ecf20Sopenharmony_ci	INIT_REGMAP_IRQ(AXP22X, BATT_TEMP_LOW,	        1, 0),
3638c2ecf20Sopenharmony_ci	INIT_REGMAP_IRQ(AXP22X, DIE_TEMP_HIGH,	        2, 7),
3648c2ecf20Sopenharmony_ci	INIT_REGMAP_IRQ(AXP22X, PEK_SHORT,		2, 1),
3658c2ecf20Sopenharmony_ci	INIT_REGMAP_IRQ(AXP22X, PEK_LONG,		2, 0),
3668c2ecf20Sopenharmony_ci	INIT_REGMAP_IRQ(AXP22X, LOW_PWR_LVL1,	        3, 1),
3678c2ecf20Sopenharmony_ci	INIT_REGMAP_IRQ(AXP22X, LOW_PWR_LVL2,	        3, 0),
3688c2ecf20Sopenharmony_ci	INIT_REGMAP_IRQ(AXP22X, TIMER,		        4, 7),
3698c2ecf20Sopenharmony_ci	INIT_REGMAP_IRQ(AXP22X, PEK_RIS_EDGE,	        4, 6),
3708c2ecf20Sopenharmony_ci	INIT_REGMAP_IRQ(AXP22X, PEK_FAL_EDGE,	        4, 5),
3718c2ecf20Sopenharmony_ci	INIT_REGMAP_IRQ(AXP22X, GPIO1_INPUT,		4, 1),
3728c2ecf20Sopenharmony_ci	INIT_REGMAP_IRQ(AXP22X, GPIO0_INPUT,		4, 0),
3738c2ecf20Sopenharmony_ci};
3748c2ecf20Sopenharmony_ci
3758c2ecf20Sopenharmony_ci/* some IRQs are compatible with axp20x models */
3768c2ecf20Sopenharmony_cistatic const struct regmap_irq axp288_regmap_irqs[] = {
3778c2ecf20Sopenharmony_ci	INIT_REGMAP_IRQ(AXP288, VBUS_FALL,              0, 2),
3788c2ecf20Sopenharmony_ci	INIT_REGMAP_IRQ(AXP288, VBUS_RISE,              0, 3),
3798c2ecf20Sopenharmony_ci	INIT_REGMAP_IRQ(AXP288, OV,                     0, 4),
3808c2ecf20Sopenharmony_ci	INIT_REGMAP_IRQ(AXP288, FALLING_ALT,            0, 5),
3818c2ecf20Sopenharmony_ci	INIT_REGMAP_IRQ(AXP288, RISING_ALT,             0, 6),
3828c2ecf20Sopenharmony_ci	INIT_REGMAP_IRQ(AXP288, OV_ALT,                 0, 7),
3838c2ecf20Sopenharmony_ci
3848c2ecf20Sopenharmony_ci	INIT_REGMAP_IRQ(AXP288, DONE,                   1, 2),
3858c2ecf20Sopenharmony_ci	INIT_REGMAP_IRQ(AXP288, CHARGING,               1, 3),
3868c2ecf20Sopenharmony_ci	INIT_REGMAP_IRQ(AXP288, SAFE_QUIT,              1, 4),
3878c2ecf20Sopenharmony_ci	INIT_REGMAP_IRQ(AXP288, SAFE_ENTER,             1, 5),
3888c2ecf20Sopenharmony_ci	INIT_REGMAP_IRQ(AXP288, ABSENT,                 1, 6),
3898c2ecf20Sopenharmony_ci	INIT_REGMAP_IRQ(AXP288, APPEND,                 1, 7),
3908c2ecf20Sopenharmony_ci
3918c2ecf20Sopenharmony_ci	INIT_REGMAP_IRQ(AXP288, QWBTU,                  2, 0),
3928c2ecf20Sopenharmony_ci	INIT_REGMAP_IRQ(AXP288, WBTU,                   2, 1),
3938c2ecf20Sopenharmony_ci	INIT_REGMAP_IRQ(AXP288, QWBTO,                  2, 2),
3948c2ecf20Sopenharmony_ci	INIT_REGMAP_IRQ(AXP288, WBTO,                   2, 3),
3958c2ecf20Sopenharmony_ci	INIT_REGMAP_IRQ(AXP288, QCBTU,                  2, 4),
3968c2ecf20Sopenharmony_ci	INIT_REGMAP_IRQ(AXP288, CBTU,                   2, 5),
3978c2ecf20Sopenharmony_ci	INIT_REGMAP_IRQ(AXP288, QCBTO,                  2, 6),
3988c2ecf20Sopenharmony_ci	INIT_REGMAP_IRQ(AXP288, CBTO,                   2, 7),
3998c2ecf20Sopenharmony_ci
4008c2ecf20Sopenharmony_ci	INIT_REGMAP_IRQ(AXP288, WL2,                    3, 0),
4018c2ecf20Sopenharmony_ci	INIT_REGMAP_IRQ(AXP288, WL1,                    3, 1),
4028c2ecf20Sopenharmony_ci	INIT_REGMAP_IRQ(AXP288, GPADC,                  3, 2),
4038c2ecf20Sopenharmony_ci	INIT_REGMAP_IRQ(AXP288, OT,                     3, 7),
4048c2ecf20Sopenharmony_ci
4058c2ecf20Sopenharmony_ci	INIT_REGMAP_IRQ(AXP288, GPIO0,                  4, 0),
4068c2ecf20Sopenharmony_ci	INIT_REGMAP_IRQ(AXP288, GPIO1,                  4, 1),
4078c2ecf20Sopenharmony_ci	INIT_REGMAP_IRQ(AXP288, POKO,                   4, 2),
4088c2ecf20Sopenharmony_ci	INIT_REGMAP_IRQ(AXP288, POKL,                   4, 3),
4098c2ecf20Sopenharmony_ci	INIT_REGMAP_IRQ(AXP288, POKS,                   4, 4),
4108c2ecf20Sopenharmony_ci	INIT_REGMAP_IRQ(AXP288, POKN,                   4, 5),
4118c2ecf20Sopenharmony_ci	INIT_REGMAP_IRQ(AXP288, POKP,                   4, 6),
4128c2ecf20Sopenharmony_ci	INIT_REGMAP_IRQ(AXP288, TIMER,                  4, 7),
4138c2ecf20Sopenharmony_ci
4148c2ecf20Sopenharmony_ci	INIT_REGMAP_IRQ(AXP288, MV_CHNG,                5, 0),
4158c2ecf20Sopenharmony_ci	INIT_REGMAP_IRQ(AXP288, BC_USB_CHNG,            5, 1),
4168c2ecf20Sopenharmony_ci};
4178c2ecf20Sopenharmony_ci
4188c2ecf20Sopenharmony_cistatic const struct regmap_irq axp803_regmap_irqs[] = {
4198c2ecf20Sopenharmony_ci	INIT_REGMAP_IRQ(AXP803, ACIN_OVER_V,		0, 7),
4208c2ecf20Sopenharmony_ci	INIT_REGMAP_IRQ(AXP803, ACIN_PLUGIN,		0, 6),
4218c2ecf20Sopenharmony_ci	INIT_REGMAP_IRQ(AXP803, ACIN_REMOVAL,	        0, 5),
4228c2ecf20Sopenharmony_ci	INIT_REGMAP_IRQ(AXP803, VBUS_OVER_V,		0, 4),
4238c2ecf20Sopenharmony_ci	INIT_REGMAP_IRQ(AXP803, VBUS_PLUGIN,		0, 3),
4248c2ecf20Sopenharmony_ci	INIT_REGMAP_IRQ(AXP803, VBUS_REMOVAL,	        0, 2),
4258c2ecf20Sopenharmony_ci	INIT_REGMAP_IRQ(AXP803, BATT_PLUGIN,		1, 7),
4268c2ecf20Sopenharmony_ci	INIT_REGMAP_IRQ(AXP803, BATT_REMOVAL,	        1, 6),
4278c2ecf20Sopenharmony_ci	INIT_REGMAP_IRQ(AXP803, BATT_ENT_ACT_MODE,	1, 5),
4288c2ecf20Sopenharmony_ci	INIT_REGMAP_IRQ(AXP803, BATT_EXIT_ACT_MODE,	1, 4),
4298c2ecf20Sopenharmony_ci	INIT_REGMAP_IRQ(AXP803, CHARG,		        1, 3),
4308c2ecf20Sopenharmony_ci	INIT_REGMAP_IRQ(AXP803, CHARG_DONE,		1, 2),
4318c2ecf20Sopenharmony_ci	INIT_REGMAP_IRQ(AXP803, BATT_CHG_TEMP_HIGH,	2, 7),
4328c2ecf20Sopenharmony_ci	INIT_REGMAP_IRQ(AXP803, BATT_CHG_TEMP_HIGH_END,	2, 6),
4338c2ecf20Sopenharmony_ci	INIT_REGMAP_IRQ(AXP803, BATT_CHG_TEMP_LOW,	2, 5),
4348c2ecf20Sopenharmony_ci	INIT_REGMAP_IRQ(AXP803, BATT_CHG_TEMP_LOW_END,	2, 4),
4358c2ecf20Sopenharmony_ci	INIT_REGMAP_IRQ(AXP803, BATT_ACT_TEMP_HIGH,	2, 3),
4368c2ecf20Sopenharmony_ci	INIT_REGMAP_IRQ(AXP803, BATT_ACT_TEMP_HIGH_END,	2, 2),
4378c2ecf20Sopenharmony_ci	INIT_REGMAP_IRQ(AXP803, BATT_ACT_TEMP_LOW,	2, 1),
4388c2ecf20Sopenharmony_ci	INIT_REGMAP_IRQ(AXP803, BATT_ACT_TEMP_LOW_END,	2, 0),
4398c2ecf20Sopenharmony_ci	INIT_REGMAP_IRQ(AXP803, DIE_TEMP_HIGH,	        3, 7),
4408c2ecf20Sopenharmony_ci	INIT_REGMAP_IRQ(AXP803, GPADC,		        3, 2),
4418c2ecf20Sopenharmony_ci	INIT_REGMAP_IRQ(AXP803, LOW_PWR_LVL1,	        3, 1),
4428c2ecf20Sopenharmony_ci	INIT_REGMAP_IRQ(AXP803, LOW_PWR_LVL2,	        3, 0),
4438c2ecf20Sopenharmony_ci	INIT_REGMAP_IRQ(AXP803, TIMER,		        4, 7),
4448c2ecf20Sopenharmony_ci	INIT_REGMAP_IRQ(AXP803, PEK_RIS_EDGE,	        4, 6),
4458c2ecf20Sopenharmony_ci	INIT_REGMAP_IRQ(AXP803, PEK_FAL_EDGE,	        4, 5),
4468c2ecf20Sopenharmony_ci	INIT_REGMAP_IRQ(AXP803, PEK_SHORT,		4, 4),
4478c2ecf20Sopenharmony_ci	INIT_REGMAP_IRQ(AXP803, PEK_LONG,		4, 3),
4488c2ecf20Sopenharmony_ci	INIT_REGMAP_IRQ(AXP803, PEK_OVER_OFF,		4, 2),
4498c2ecf20Sopenharmony_ci	INIT_REGMAP_IRQ(AXP803, GPIO1_INPUT,		4, 1),
4508c2ecf20Sopenharmony_ci	INIT_REGMAP_IRQ(AXP803, GPIO0_INPUT,		4, 0),
4518c2ecf20Sopenharmony_ci	INIT_REGMAP_IRQ(AXP803, BC_USB_CHNG,            5, 1),
4528c2ecf20Sopenharmony_ci	INIT_REGMAP_IRQ(AXP803, MV_CHNG,                5, 0),
4538c2ecf20Sopenharmony_ci};
4548c2ecf20Sopenharmony_ci
4558c2ecf20Sopenharmony_cistatic const struct regmap_irq axp806_regmap_irqs[] = {
4568c2ecf20Sopenharmony_ci	INIT_REGMAP_IRQ(AXP806, DIE_TEMP_HIGH_LV1,	0, 0),
4578c2ecf20Sopenharmony_ci	INIT_REGMAP_IRQ(AXP806, DIE_TEMP_HIGH_LV2,	0, 1),
4588c2ecf20Sopenharmony_ci	INIT_REGMAP_IRQ(AXP806, DCDCA_V_LOW,		0, 3),
4598c2ecf20Sopenharmony_ci	INIT_REGMAP_IRQ(AXP806, DCDCB_V_LOW,		0, 4),
4608c2ecf20Sopenharmony_ci	INIT_REGMAP_IRQ(AXP806, DCDCC_V_LOW,		0, 5),
4618c2ecf20Sopenharmony_ci	INIT_REGMAP_IRQ(AXP806, DCDCD_V_LOW,		0, 6),
4628c2ecf20Sopenharmony_ci	INIT_REGMAP_IRQ(AXP806, DCDCE_V_LOW,		0, 7),
4638c2ecf20Sopenharmony_ci	INIT_REGMAP_IRQ(AXP806, POK_LONG,		1, 0),
4648c2ecf20Sopenharmony_ci	INIT_REGMAP_IRQ(AXP806, POK_SHORT,		1, 1),
4658c2ecf20Sopenharmony_ci	INIT_REGMAP_IRQ(AXP806, WAKEUP,			1, 4),
4668c2ecf20Sopenharmony_ci	INIT_REGMAP_IRQ(AXP806, POK_FALL,		1, 5),
4678c2ecf20Sopenharmony_ci	INIT_REGMAP_IRQ(AXP806, POK_RISE,		1, 6),
4688c2ecf20Sopenharmony_ci};
4698c2ecf20Sopenharmony_ci
4708c2ecf20Sopenharmony_cistatic const struct regmap_irq axp809_regmap_irqs[] = {
4718c2ecf20Sopenharmony_ci	INIT_REGMAP_IRQ(AXP809, ACIN_OVER_V,		0, 7),
4728c2ecf20Sopenharmony_ci	INIT_REGMAP_IRQ(AXP809, ACIN_PLUGIN,		0, 6),
4738c2ecf20Sopenharmony_ci	INIT_REGMAP_IRQ(AXP809, ACIN_REMOVAL,	        0, 5),
4748c2ecf20Sopenharmony_ci	INIT_REGMAP_IRQ(AXP809, VBUS_OVER_V,		0, 4),
4758c2ecf20Sopenharmony_ci	INIT_REGMAP_IRQ(AXP809, VBUS_PLUGIN,		0, 3),
4768c2ecf20Sopenharmony_ci	INIT_REGMAP_IRQ(AXP809, VBUS_REMOVAL,	        0, 2),
4778c2ecf20Sopenharmony_ci	INIT_REGMAP_IRQ(AXP809, VBUS_V_LOW,		0, 1),
4788c2ecf20Sopenharmony_ci	INIT_REGMAP_IRQ(AXP809, BATT_PLUGIN,		1, 7),
4798c2ecf20Sopenharmony_ci	INIT_REGMAP_IRQ(AXP809, BATT_REMOVAL,	        1, 6),
4808c2ecf20Sopenharmony_ci	INIT_REGMAP_IRQ(AXP809, BATT_ENT_ACT_MODE,	1, 5),
4818c2ecf20Sopenharmony_ci	INIT_REGMAP_IRQ(AXP809, BATT_EXIT_ACT_MODE,	1, 4),
4828c2ecf20Sopenharmony_ci	INIT_REGMAP_IRQ(AXP809, CHARG,		        1, 3),
4838c2ecf20Sopenharmony_ci	INIT_REGMAP_IRQ(AXP809, CHARG_DONE,		1, 2),
4848c2ecf20Sopenharmony_ci	INIT_REGMAP_IRQ(AXP809, BATT_CHG_TEMP_HIGH,	2, 7),
4858c2ecf20Sopenharmony_ci	INIT_REGMAP_IRQ(AXP809, BATT_CHG_TEMP_HIGH_END,	2, 6),
4868c2ecf20Sopenharmony_ci	INIT_REGMAP_IRQ(AXP809, BATT_CHG_TEMP_LOW,	2, 5),
4878c2ecf20Sopenharmony_ci	INIT_REGMAP_IRQ(AXP809, BATT_CHG_TEMP_LOW_END,	2, 4),
4888c2ecf20Sopenharmony_ci	INIT_REGMAP_IRQ(AXP809, BATT_ACT_TEMP_HIGH,	2, 3),
4898c2ecf20Sopenharmony_ci	INIT_REGMAP_IRQ(AXP809, BATT_ACT_TEMP_HIGH_END,	2, 2),
4908c2ecf20Sopenharmony_ci	INIT_REGMAP_IRQ(AXP809, BATT_ACT_TEMP_LOW,	2, 1),
4918c2ecf20Sopenharmony_ci	INIT_REGMAP_IRQ(AXP809, BATT_ACT_TEMP_LOW_END,	2, 0),
4928c2ecf20Sopenharmony_ci	INIT_REGMAP_IRQ(AXP809, DIE_TEMP_HIGH,	        3, 7),
4938c2ecf20Sopenharmony_ci	INIT_REGMAP_IRQ(AXP809, LOW_PWR_LVL1,	        3, 1),
4948c2ecf20Sopenharmony_ci	INIT_REGMAP_IRQ(AXP809, LOW_PWR_LVL2,	        3, 0),
4958c2ecf20Sopenharmony_ci	INIT_REGMAP_IRQ(AXP809, TIMER,		        4, 7),
4968c2ecf20Sopenharmony_ci	INIT_REGMAP_IRQ(AXP809, PEK_RIS_EDGE,	        4, 6),
4978c2ecf20Sopenharmony_ci	INIT_REGMAP_IRQ(AXP809, PEK_FAL_EDGE,	        4, 5),
4988c2ecf20Sopenharmony_ci	INIT_REGMAP_IRQ(AXP809, PEK_SHORT,		4, 4),
4998c2ecf20Sopenharmony_ci	INIT_REGMAP_IRQ(AXP809, PEK_LONG,		4, 3),
5008c2ecf20Sopenharmony_ci	INIT_REGMAP_IRQ(AXP809, PEK_OVER_OFF,		4, 2),
5018c2ecf20Sopenharmony_ci	INIT_REGMAP_IRQ(AXP809, GPIO1_INPUT,		4, 1),
5028c2ecf20Sopenharmony_ci	INIT_REGMAP_IRQ(AXP809, GPIO0_INPUT,		4, 0),
5038c2ecf20Sopenharmony_ci};
5048c2ecf20Sopenharmony_ci
5058c2ecf20Sopenharmony_cistatic const struct regmap_irq_chip axp152_regmap_irq_chip = {
5068c2ecf20Sopenharmony_ci	.name			= "axp152_irq_chip",
5078c2ecf20Sopenharmony_ci	.status_base		= AXP152_IRQ1_STATE,
5088c2ecf20Sopenharmony_ci	.ack_base		= AXP152_IRQ1_STATE,
5098c2ecf20Sopenharmony_ci	.mask_base		= AXP152_IRQ1_EN,
5108c2ecf20Sopenharmony_ci	.mask_invert		= true,
5118c2ecf20Sopenharmony_ci	.init_ack_masked	= true,
5128c2ecf20Sopenharmony_ci	.irqs			= axp152_regmap_irqs,
5138c2ecf20Sopenharmony_ci	.num_irqs		= ARRAY_SIZE(axp152_regmap_irqs),
5148c2ecf20Sopenharmony_ci	.num_regs		= 3,
5158c2ecf20Sopenharmony_ci};
5168c2ecf20Sopenharmony_ci
5178c2ecf20Sopenharmony_cistatic const struct regmap_irq_chip axp20x_regmap_irq_chip = {
5188c2ecf20Sopenharmony_ci	.name			= "axp20x_irq_chip",
5198c2ecf20Sopenharmony_ci	.status_base		= AXP20X_IRQ1_STATE,
5208c2ecf20Sopenharmony_ci	.ack_base		= AXP20X_IRQ1_STATE,
5218c2ecf20Sopenharmony_ci	.mask_base		= AXP20X_IRQ1_EN,
5228c2ecf20Sopenharmony_ci	.mask_invert		= true,
5238c2ecf20Sopenharmony_ci	.init_ack_masked	= true,
5248c2ecf20Sopenharmony_ci	.irqs			= axp20x_regmap_irqs,
5258c2ecf20Sopenharmony_ci	.num_irqs		= ARRAY_SIZE(axp20x_regmap_irqs),
5268c2ecf20Sopenharmony_ci	.num_regs		= 5,
5278c2ecf20Sopenharmony_ci
5288c2ecf20Sopenharmony_ci};
5298c2ecf20Sopenharmony_ci
5308c2ecf20Sopenharmony_cistatic const struct regmap_irq_chip axp22x_regmap_irq_chip = {
5318c2ecf20Sopenharmony_ci	.name			= "axp22x_irq_chip",
5328c2ecf20Sopenharmony_ci	.status_base		= AXP20X_IRQ1_STATE,
5338c2ecf20Sopenharmony_ci	.ack_base		= AXP20X_IRQ1_STATE,
5348c2ecf20Sopenharmony_ci	.mask_base		= AXP20X_IRQ1_EN,
5358c2ecf20Sopenharmony_ci	.mask_invert		= true,
5368c2ecf20Sopenharmony_ci	.init_ack_masked	= true,
5378c2ecf20Sopenharmony_ci	.irqs			= axp22x_regmap_irqs,
5388c2ecf20Sopenharmony_ci	.num_irqs		= ARRAY_SIZE(axp22x_regmap_irqs),
5398c2ecf20Sopenharmony_ci	.num_regs		= 5,
5408c2ecf20Sopenharmony_ci};
5418c2ecf20Sopenharmony_ci
5428c2ecf20Sopenharmony_cistatic const struct regmap_irq_chip axp288_regmap_irq_chip = {
5438c2ecf20Sopenharmony_ci	.name			= "axp288_irq_chip",
5448c2ecf20Sopenharmony_ci	.status_base		= AXP20X_IRQ1_STATE,
5458c2ecf20Sopenharmony_ci	.ack_base		= AXP20X_IRQ1_STATE,
5468c2ecf20Sopenharmony_ci	.mask_base		= AXP20X_IRQ1_EN,
5478c2ecf20Sopenharmony_ci	.mask_invert		= true,
5488c2ecf20Sopenharmony_ci	.init_ack_masked	= true,
5498c2ecf20Sopenharmony_ci	.irqs			= axp288_regmap_irqs,
5508c2ecf20Sopenharmony_ci	.num_irqs		= ARRAY_SIZE(axp288_regmap_irqs),
5518c2ecf20Sopenharmony_ci	.num_regs		= 6,
5528c2ecf20Sopenharmony_ci
5538c2ecf20Sopenharmony_ci};
5548c2ecf20Sopenharmony_ci
5558c2ecf20Sopenharmony_cistatic const struct regmap_irq_chip axp803_regmap_irq_chip = {
5568c2ecf20Sopenharmony_ci	.name			= "axp803",
5578c2ecf20Sopenharmony_ci	.status_base		= AXP20X_IRQ1_STATE,
5588c2ecf20Sopenharmony_ci	.ack_base		= AXP20X_IRQ1_STATE,
5598c2ecf20Sopenharmony_ci	.mask_base		= AXP20X_IRQ1_EN,
5608c2ecf20Sopenharmony_ci	.mask_invert		= true,
5618c2ecf20Sopenharmony_ci	.init_ack_masked	= true,
5628c2ecf20Sopenharmony_ci	.irqs			= axp803_regmap_irqs,
5638c2ecf20Sopenharmony_ci	.num_irqs		= ARRAY_SIZE(axp803_regmap_irqs),
5648c2ecf20Sopenharmony_ci	.num_regs		= 6,
5658c2ecf20Sopenharmony_ci};
5668c2ecf20Sopenharmony_ci
5678c2ecf20Sopenharmony_cistatic const struct regmap_irq_chip axp806_regmap_irq_chip = {
5688c2ecf20Sopenharmony_ci	.name			= "axp806",
5698c2ecf20Sopenharmony_ci	.status_base		= AXP20X_IRQ1_STATE,
5708c2ecf20Sopenharmony_ci	.ack_base		= AXP20X_IRQ1_STATE,
5718c2ecf20Sopenharmony_ci	.mask_base		= AXP20X_IRQ1_EN,
5728c2ecf20Sopenharmony_ci	.mask_invert		= true,
5738c2ecf20Sopenharmony_ci	.init_ack_masked	= true,
5748c2ecf20Sopenharmony_ci	.irqs			= axp806_regmap_irqs,
5758c2ecf20Sopenharmony_ci	.num_irqs		= ARRAY_SIZE(axp806_regmap_irqs),
5768c2ecf20Sopenharmony_ci	.num_regs		= 2,
5778c2ecf20Sopenharmony_ci};
5788c2ecf20Sopenharmony_ci
5798c2ecf20Sopenharmony_cistatic const struct regmap_irq_chip axp809_regmap_irq_chip = {
5808c2ecf20Sopenharmony_ci	.name			= "axp809",
5818c2ecf20Sopenharmony_ci	.status_base		= AXP20X_IRQ1_STATE,
5828c2ecf20Sopenharmony_ci	.ack_base		= AXP20X_IRQ1_STATE,
5838c2ecf20Sopenharmony_ci	.mask_base		= AXP20X_IRQ1_EN,
5848c2ecf20Sopenharmony_ci	.mask_invert		= true,
5858c2ecf20Sopenharmony_ci	.init_ack_masked	= true,
5868c2ecf20Sopenharmony_ci	.irqs			= axp809_regmap_irqs,
5878c2ecf20Sopenharmony_ci	.num_irqs		= ARRAY_SIZE(axp809_regmap_irqs),
5888c2ecf20Sopenharmony_ci	.num_regs		= 5,
5898c2ecf20Sopenharmony_ci};
5908c2ecf20Sopenharmony_ci
5918c2ecf20Sopenharmony_cistatic const struct mfd_cell axp20x_cells[] = {
5928c2ecf20Sopenharmony_ci	{
5938c2ecf20Sopenharmony_ci		.name		= "axp20x-gpio",
5948c2ecf20Sopenharmony_ci		.of_compatible	= "x-powers,axp209-gpio",
5958c2ecf20Sopenharmony_ci	}, {
5968c2ecf20Sopenharmony_ci		.name		= "axp20x-pek",
5978c2ecf20Sopenharmony_ci		.num_resources	= ARRAY_SIZE(axp20x_pek_resources),
5988c2ecf20Sopenharmony_ci		.resources	= axp20x_pek_resources,
5998c2ecf20Sopenharmony_ci	}, {
6008c2ecf20Sopenharmony_ci		.name		= "axp20x-regulator",
6018c2ecf20Sopenharmony_ci	}, {
6028c2ecf20Sopenharmony_ci		.name		= "axp20x-adc",
6038c2ecf20Sopenharmony_ci		.of_compatible	= "x-powers,axp209-adc",
6048c2ecf20Sopenharmony_ci	}, {
6058c2ecf20Sopenharmony_ci		.name		= "axp20x-battery-power-supply",
6068c2ecf20Sopenharmony_ci		.of_compatible	= "x-powers,axp209-battery-power-supply",
6078c2ecf20Sopenharmony_ci	}, {
6088c2ecf20Sopenharmony_ci		.name		= "axp20x-ac-power-supply",
6098c2ecf20Sopenharmony_ci		.of_compatible	= "x-powers,axp202-ac-power-supply",
6108c2ecf20Sopenharmony_ci		.num_resources	= ARRAY_SIZE(axp20x_ac_power_supply_resources),
6118c2ecf20Sopenharmony_ci		.resources	= axp20x_ac_power_supply_resources,
6128c2ecf20Sopenharmony_ci	}, {
6138c2ecf20Sopenharmony_ci		.name		= "axp20x-usb-power-supply",
6148c2ecf20Sopenharmony_ci		.of_compatible	= "x-powers,axp202-usb-power-supply",
6158c2ecf20Sopenharmony_ci		.num_resources	= ARRAY_SIZE(axp20x_usb_power_supply_resources),
6168c2ecf20Sopenharmony_ci		.resources	= axp20x_usb_power_supply_resources,
6178c2ecf20Sopenharmony_ci	},
6188c2ecf20Sopenharmony_ci};
6198c2ecf20Sopenharmony_ci
6208c2ecf20Sopenharmony_cistatic const struct mfd_cell axp221_cells[] = {
6218c2ecf20Sopenharmony_ci	{
6228c2ecf20Sopenharmony_ci		.name		= "axp221-pek",
6238c2ecf20Sopenharmony_ci		.num_resources	= ARRAY_SIZE(axp22x_pek_resources),
6248c2ecf20Sopenharmony_ci		.resources	= axp22x_pek_resources,
6258c2ecf20Sopenharmony_ci	}, {
6268c2ecf20Sopenharmony_ci		.name		= "axp20x-regulator",
6278c2ecf20Sopenharmony_ci	}, {
6288c2ecf20Sopenharmony_ci		.name		= "axp22x-adc",
6298c2ecf20Sopenharmony_ci		.of_compatible	= "x-powers,axp221-adc",
6308c2ecf20Sopenharmony_ci	}, {
6318c2ecf20Sopenharmony_ci		.name		= "axp20x-ac-power-supply",
6328c2ecf20Sopenharmony_ci		.of_compatible	= "x-powers,axp221-ac-power-supply",
6338c2ecf20Sopenharmony_ci		.num_resources	= ARRAY_SIZE(axp20x_ac_power_supply_resources),
6348c2ecf20Sopenharmony_ci		.resources	= axp20x_ac_power_supply_resources,
6358c2ecf20Sopenharmony_ci	}, {
6368c2ecf20Sopenharmony_ci		.name		= "axp20x-battery-power-supply",
6378c2ecf20Sopenharmony_ci		.of_compatible	= "x-powers,axp221-battery-power-supply",
6388c2ecf20Sopenharmony_ci	}, {
6398c2ecf20Sopenharmony_ci		.name		= "axp20x-usb-power-supply",
6408c2ecf20Sopenharmony_ci		.of_compatible	= "x-powers,axp221-usb-power-supply",
6418c2ecf20Sopenharmony_ci		.num_resources	= ARRAY_SIZE(axp22x_usb_power_supply_resources),
6428c2ecf20Sopenharmony_ci		.resources	= axp22x_usb_power_supply_resources,
6438c2ecf20Sopenharmony_ci	},
6448c2ecf20Sopenharmony_ci};
6458c2ecf20Sopenharmony_ci
6468c2ecf20Sopenharmony_cistatic const struct mfd_cell axp223_cells[] = {
6478c2ecf20Sopenharmony_ci	{
6488c2ecf20Sopenharmony_ci		.name		= "axp221-pek",
6498c2ecf20Sopenharmony_ci		.num_resources	= ARRAY_SIZE(axp22x_pek_resources),
6508c2ecf20Sopenharmony_ci		.resources	= axp22x_pek_resources,
6518c2ecf20Sopenharmony_ci	}, {
6528c2ecf20Sopenharmony_ci		.name		= "axp22x-adc",
6538c2ecf20Sopenharmony_ci		.of_compatible	= "x-powers,axp221-adc",
6548c2ecf20Sopenharmony_ci	}, {
6558c2ecf20Sopenharmony_ci		.name		= "axp20x-battery-power-supply",
6568c2ecf20Sopenharmony_ci		.of_compatible	= "x-powers,axp221-battery-power-supply",
6578c2ecf20Sopenharmony_ci	}, {
6588c2ecf20Sopenharmony_ci		.name		= "axp20x-regulator",
6598c2ecf20Sopenharmony_ci	}, {
6608c2ecf20Sopenharmony_ci		.name		= "axp20x-ac-power-supply",
6618c2ecf20Sopenharmony_ci		.of_compatible	= "x-powers,axp221-ac-power-supply",
6628c2ecf20Sopenharmony_ci		.num_resources	= ARRAY_SIZE(axp20x_ac_power_supply_resources),
6638c2ecf20Sopenharmony_ci		.resources	= axp20x_ac_power_supply_resources,
6648c2ecf20Sopenharmony_ci	}, {
6658c2ecf20Sopenharmony_ci		.name		= "axp20x-usb-power-supply",
6668c2ecf20Sopenharmony_ci		.of_compatible	= "x-powers,axp223-usb-power-supply",
6678c2ecf20Sopenharmony_ci		.num_resources	= ARRAY_SIZE(axp22x_usb_power_supply_resources),
6688c2ecf20Sopenharmony_ci		.resources	= axp22x_usb_power_supply_resources,
6698c2ecf20Sopenharmony_ci	},
6708c2ecf20Sopenharmony_ci};
6718c2ecf20Sopenharmony_ci
6728c2ecf20Sopenharmony_cistatic const struct mfd_cell axp152_cells[] = {
6738c2ecf20Sopenharmony_ci	{
6748c2ecf20Sopenharmony_ci		.name		= "axp20x-pek",
6758c2ecf20Sopenharmony_ci		.num_resources	= ARRAY_SIZE(axp152_pek_resources),
6768c2ecf20Sopenharmony_ci		.resources	= axp152_pek_resources,
6778c2ecf20Sopenharmony_ci	},
6788c2ecf20Sopenharmony_ci};
6798c2ecf20Sopenharmony_ci
6808c2ecf20Sopenharmony_cistatic const struct resource axp288_adc_resources[] = {
6818c2ecf20Sopenharmony_ci	DEFINE_RES_IRQ_NAMED(AXP288_IRQ_GPADC, "GPADC"),
6828c2ecf20Sopenharmony_ci};
6838c2ecf20Sopenharmony_ci
6848c2ecf20Sopenharmony_cistatic const struct resource axp288_extcon_resources[] = {
6858c2ecf20Sopenharmony_ci	DEFINE_RES_IRQ(AXP288_IRQ_VBUS_FALL),
6868c2ecf20Sopenharmony_ci	DEFINE_RES_IRQ(AXP288_IRQ_VBUS_RISE),
6878c2ecf20Sopenharmony_ci	DEFINE_RES_IRQ(AXP288_IRQ_MV_CHNG),
6888c2ecf20Sopenharmony_ci	DEFINE_RES_IRQ(AXP288_IRQ_BC_USB_CHNG),
6898c2ecf20Sopenharmony_ci};
6908c2ecf20Sopenharmony_ci
6918c2ecf20Sopenharmony_cistatic const struct resource axp288_charger_resources[] = {
6928c2ecf20Sopenharmony_ci	DEFINE_RES_IRQ(AXP288_IRQ_OV),
6938c2ecf20Sopenharmony_ci	DEFINE_RES_IRQ(AXP288_IRQ_DONE),
6948c2ecf20Sopenharmony_ci	DEFINE_RES_IRQ(AXP288_IRQ_CHARGING),
6958c2ecf20Sopenharmony_ci	DEFINE_RES_IRQ(AXP288_IRQ_SAFE_QUIT),
6968c2ecf20Sopenharmony_ci	DEFINE_RES_IRQ(AXP288_IRQ_SAFE_ENTER),
6978c2ecf20Sopenharmony_ci	DEFINE_RES_IRQ(AXP288_IRQ_QCBTU),
6988c2ecf20Sopenharmony_ci	DEFINE_RES_IRQ(AXP288_IRQ_CBTU),
6998c2ecf20Sopenharmony_ci	DEFINE_RES_IRQ(AXP288_IRQ_QCBTO),
7008c2ecf20Sopenharmony_ci	DEFINE_RES_IRQ(AXP288_IRQ_CBTO),
7018c2ecf20Sopenharmony_ci};
7028c2ecf20Sopenharmony_ci
7038c2ecf20Sopenharmony_cistatic const struct mfd_cell axp288_cells[] = {
7048c2ecf20Sopenharmony_ci	{
7058c2ecf20Sopenharmony_ci		.name		= "axp288_adc",
7068c2ecf20Sopenharmony_ci		.num_resources	= ARRAY_SIZE(axp288_adc_resources),
7078c2ecf20Sopenharmony_ci		.resources	= axp288_adc_resources,
7088c2ecf20Sopenharmony_ci	}, {
7098c2ecf20Sopenharmony_ci		.name		= "axp288_extcon",
7108c2ecf20Sopenharmony_ci		.num_resources	= ARRAY_SIZE(axp288_extcon_resources),
7118c2ecf20Sopenharmony_ci		.resources	= axp288_extcon_resources,
7128c2ecf20Sopenharmony_ci	}, {
7138c2ecf20Sopenharmony_ci		.name		= "axp288_charger",
7148c2ecf20Sopenharmony_ci		.num_resources	= ARRAY_SIZE(axp288_charger_resources),
7158c2ecf20Sopenharmony_ci		.resources	= axp288_charger_resources,
7168c2ecf20Sopenharmony_ci	}, {
7178c2ecf20Sopenharmony_ci		.name		= "axp288_fuel_gauge",
7188c2ecf20Sopenharmony_ci		.num_resources	= ARRAY_SIZE(axp288_fuel_gauge_resources),
7198c2ecf20Sopenharmony_ci		.resources	= axp288_fuel_gauge_resources,
7208c2ecf20Sopenharmony_ci	}, {
7218c2ecf20Sopenharmony_ci		.name		= "axp221-pek",
7228c2ecf20Sopenharmony_ci		.num_resources	= ARRAY_SIZE(axp288_power_button_resources),
7238c2ecf20Sopenharmony_ci		.resources	= axp288_power_button_resources,
7248c2ecf20Sopenharmony_ci	}, {
7258c2ecf20Sopenharmony_ci		.name		= "axp288_pmic_acpi",
7268c2ecf20Sopenharmony_ci	},
7278c2ecf20Sopenharmony_ci};
7288c2ecf20Sopenharmony_ci
7298c2ecf20Sopenharmony_cistatic const struct mfd_cell axp803_cells[] = {
7308c2ecf20Sopenharmony_ci	{
7318c2ecf20Sopenharmony_ci		.name		= "axp221-pek",
7328c2ecf20Sopenharmony_ci		.num_resources	= ARRAY_SIZE(axp803_pek_resources),
7338c2ecf20Sopenharmony_ci		.resources	= axp803_pek_resources,
7348c2ecf20Sopenharmony_ci	}, {
7358c2ecf20Sopenharmony_ci		.name		= "axp20x-gpio",
7368c2ecf20Sopenharmony_ci		.of_compatible	= "x-powers,axp813-gpio",
7378c2ecf20Sopenharmony_ci	}, {
7388c2ecf20Sopenharmony_ci		.name		= "axp813-adc",
7398c2ecf20Sopenharmony_ci		.of_compatible	= "x-powers,axp813-adc",
7408c2ecf20Sopenharmony_ci	}, {
7418c2ecf20Sopenharmony_ci		.name		= "axp20x-battery-power-supply",
7428c2ecf20Sopenharmony_ci		.of_compatible	= "x-powers,axp813-battery-power-supply",
7438c2ecf20Sopenharmony_ci	}, {
7448c2ecf20Sopenharmony_ci		.name		= "axp20x-ac-power-supply",
7458c2ecf20Sopenharmony_ci		.of_compatible	= "x-powers,axp813-ac-power-supply",
7468c2ecf20Sopenharmony_ci		.num_resources	= ARRAY_SIZE(axp20x_ac_power_supply_resources),
7478c2ecf20Sopenharmony_ci		.resources	= axp20x_ac_power_supply_resources,
7488c2ecf20Sopenharmony_ci	}, {
7498c2ecf20Sopenharmony_ci		.name		= "axp20x-usb-power-supply",
7508c2ecf20Sopenharmony_ci		.num_resources	= ARRAY_SIZE(axp803_usb_power_supply_resources),
7518c2ecf20Sopenharmony_ci		.resources	= axp803_usb_power_supply_resources,
7528c2ecf20Sopenharmony_ci		.of_compatible	= "x-powers,axp813-usb-power-supply",
7538c2ecf20Sopenharmony_ci	},
7548c2ecf20Sopenharmony_ci	{	.name		= "axp20x-regulator" },
7558c2ecf20Sopenharmony_ci};
7568c2ecf20Sopenharmony_ci
7578c2ecf20Sopenharmony_cistatic const struct mfd_cell axp806_self_working_cells[] = {
7588c2ecf20Sopenharmony_ci	{
7598c2ecf20Sopenharmony_ci		.name		= "axp221-pek",
7608c2ecf20Sopenharmony_ci		.num_resources	= ARRAY_SIZE(axp806_pek_resources),
7618c2ecf20Sopenharmony_ci		.resources	= axp806_pek_resources,
7628c2ecf20Sopenharmony_ci	},
7638c2ecf20Sopenharmony_ci	{	.name		= "axp20x-regulator" },
7648c2ecf20Sopenharmony_ci};
7658c2ecf20Sopenharmony_ci
7668c2ecf20Sopenharmony_cistatic const struct mfd_cell axp806_cells[] = {
7678c2ecf20Sopenharmony_ci	{
7688c2ecf20Sopenharmony_ci		.id		= 2,
7698c2ecf20Sopenharmony_ci		.name		= "axp20x-regulator",
7708c2ecf20Sopenharmony_ci	},
7718c2ecf20Sopenharmony_ci};
7728c2ecf20Sopenharmony_ci
7738c2ecf20Sopenharmony_cistatic const struct mfd_cell axp809_cells[] = {
7748c2ecf20Sopenharmony_ci	{
7758c2ecf20Sopenharmony_ci		.name		= "axp221-pek",
7768c2ecf20Sopenharmony_ci		.num_resources	= ARRAY_SIZE(axp809_pek_resources),
7778c2ecf20Sopenharmony_ci		.resources	= axp809_pek_resources,
7788c2ecf20Sopenharmony_ci	}, {
7798c2ecf20Sopenharmony_ci		.id		= 1,
7808c2ecf20Sopenharmony_ci		.name		= "axp20x-regulator",
7818c2ecf20Sopenharmony_ci	},
7828c2ecf20Sopenharmony_ci};
7838c2ecf20Sopenharmony_ci
7848c2ecf20Sopenharmony_cistatic const struct mfd_cell axp813_cells[] = {
7858c2ecf20Sopenharmony_ci	{
7868c2ecf20Sopenharmony_ci		.name		= "axp221-pek",
7878c2ecf20Sopenharmony_ci		.num_resources	= ARRAY_SIZE(axp803_pek_resources),
7888c2ecf20Sopenharmony_ci		.resources	= axp803_pek_resources,
7898c2ecf20Sopenharmony_ci	}, {
7908c2ecf20Sopenharmony_ci		.name		= "axp20x-regulator",
7918c2ecf20Sopenharmony_ci	}, {
7928c2ecf20Sopenharmony_ci		.name		= "axp20x-gpio",
7938c2ecf20Sopenharmony_ci		.of_compatible	= "x-powers,axp813-gpio",
7948c2ecf20Sopenharmony_ci	}, {
7958c2ecf20Sopenharmony_ci		.name		= "axp813-adc",
7968c2ecf20Sopenharmony_ci		.of_compatible	= "x-powers,axp813-adc",
7978c2ecf20Sopenharmony_ci	}, {
7988c2ecf20Sopenharmony_ci		.name		= "axp20x-battery-power-supply",
7998c2ecf20Sopenharmony_ci		.of_compatible	= "x-powers,axp813-battery-power-supply",
8008c2ecf20Sopenharmony_ci	}, {
8018c2ecf20Sopenharmony_ci		.name		= "axp20x-ac-power-supply",
8028c2ecf20Sopenharmony_ci		.of_compatible	= "x-powers,axp813-ac-power-supply",
8038c2ecf20Sopenharmony_ci		.num_resources	= ARRAY_SIZE(axp20x_ac_power_supply_resources),
8048c2ecf20Sopenharmony_ci		.resources	= axp20x_ac_power_supply_resources,
8058c2ecf20Sopenharmony_ci	}, {
8068c2ecf20Sopenharmony_ci		.name		= "axp20x-usb-power-supply",
8078c2ecf20Sopenharmony_ci		.num_resources	= ARRAY_SIZE(axp803_usb_power_supply_resources),
8088c2ecf20Sopenharmony_ci		.resources	= axp803_usb_power_supply_resources,
8098c2ecf20Sopenharmony_ci		.of_compatible	= "x-powers,axp813-usb-power-supply",
8108c2ecf20Sopenharmony_ci	},
8118c2ecf20Sopenharmony_ci};
8128c2ecf20Sopenharmony_ci
8138c2ecf20Sopenharmony_cistatic struct axp20x_dev *axp20x_pm_power_off;
8148c2ecf20Sopenharmony_cistatic void axp20x_power_off(void)
8158c2ecf20Sopenharmony_ci{
8168c2ecf20Sopenharmony_ci	if (axp20x_pm_power_off->variant == AXP288_ID)
8178c2ecf20Sopenharmony_ci		return;
8188c2ecf20Sopenharmony_ci
8198c2ecf20Sopenharmony_ci	regmap_write(axp20x_pm_power_off->regmap, AXP20X_OFF_CTRL,
8208c2ecf20Sopenharmony_ci		     AXP20X_OFF);
8218c2ecf20Sopenharmony_ci
8228c2ecf20Sopenharmony_ci	/* Give capacitors etc. time to drain to avoid kernel panic msg. */
8238c2ecf20Sopenharmony_ci	msleep(500);
8248c2ecf20Sopenharmony_ci}
8258c2ecf20Sopenharmony_ci
8268c2ecf20Sopenharmony_ciint axp20x_match_device(struct axp20x_dev *axp20x)
8278c2ecf20Sopenharmony_ci{
8288c2ecf20Sopenharmony_ci	struct device *dev = axp20x->dev;
8298c2ecf20Sopenharmony_ci	const struct acpi_device_id *acpi_id;
8308c2ecf20Sopenharmony_ci	const struct of_device_id *of_id;
8318c2ecf20Sopenharmony_ci
8328c2ecf20Sopenharmony_ci	if (dev->of_node) {
8338c2ecf20Sopenharmony_ci		of_id = of_match_device(dev->driver->of_match_table, dev);
8348c2ecf20Sopenharmony_ci		if (!of_id) {
8358c2ecf20Sopenharmony_ci			dev_err(dev, "Unable to match OF ID\n");
8368c2ecf20Sopenharmony_ci			return -ENODEV;
8378c2ecf20Sopenharmony_ci		}
8388c2ecf20Sopenharmony_ci		axp20x->variant = (long)of_id->data;
8398c2ecf20Sopenharmony_ci	} else {
8408c2ecf20Sopenharmony_ci		acpi_id = acpi_match_device(dev->driver->acpi_match_table, dev);
8418c2ecf20Sopenharmony_ci		if (!acpi_id || !acpi_id->driver_data) {
8428c2ecf20Sopenharmony_ci			dev_err(dev, "Unable to match ACPI ID and data\n");
8438c2ecf20Sopenharmony_ci			return -ENODEV;
8448c2ecf20Sopenharmony_ci		}
8458c2ecf20Sopenharmony_ci		axp20x->variant = (long)acpi_id->driver_data;
8468c2ecf20Sopenharmony_ci	}
8478c2ecf20Sopenharmony_ci
8488c2ecf20Sopenharmony_ci	switch (axp20x->variant) {
8498c2ecf20Sopenharmony_ci	case AXP152_ID:
8508c2ecf20Sopenharmony_ci		axp20x->nr_cells = ARRAY_SIZE(axp152_cells);
8518c2ecf20Sopenharmony_ci		axp20x->cells = axp152_cells;
8528c2ecf20Sopenharmony_ci		axp20x->regmap_cfg = &axp152_regmap_config;
8538c2ecf20Sopenharmony_ci		axp20x->regmap_irq_chip = &axp152_regmap_irq_chip;
8548c2ecf20Sopenharmony_ci		break;
8558c2ecf20Sopenharmony_ci	case AXP202_ID:
8568c2ecf20Sopenharmony_ci	case AXP209_ID:
8578c2ecf20Sopenharmony_ci		axp20x->nr_cells = ARRAY_SIZE(axp20x_cells);
8588c2ecf20Sopenharmony_ci		axp20x->cells = axp20x_cells;
8598c2ecf20Sopenharmony_ci		axp20x->regmap_cfg = &axp20x_regmap_config;
8608c2ecf20Sopenharmony_ci		axp20x->regmap_irq_chip = &axp20x_regmap_irq_chip;
8618c2ecf20Sopenharmony_ci		break;
8628c2ecf20Sopenharmony_ci	case AXP221_ID:
8638c2ecf20Sopenharmony_ci		axp20x->nr_cells = ARRAY_SIZE(axp221_cells);
8648c2ecf20Sopenharmony_ci		axp20x->cells = axp221_cells;
8658c2ecf20Sopenharmony_ci		axp20x->regmap_cfg = &axp22x_regmap_config;
8668c2ecf20Sopenharmony_ci		axp20x->regmap_irq_chip = &axp22x_regmap_irq_chip;
8678c2ecf20Sopenharmony_ci		break;
8688c2ecf20Sopenharmony_ci	case AXP223_ID:
8698c2ecf20Sopenharmony_ci		axp20x->nr_cells = ARRAY_SIZE(axp223_cells);
8708c2ecf20Sopenharmony_ci		axp20x->cells = axp223_cells;
8718c2ecf20Sopenharmony_ci		axp20x->regmap_cfg = &axp22x_regmap_config;
8728c2ecf20Sopenharmony_ci		axp20x->regmap_irq_chip = &axp22x_regmap_irq_chip;
8738c2ecf20Sopenharmony_ci		break;
8748c2ecf20Sopenharmony_ci	case AXP288_ID:
8758c2ecf20Sopenharmony_ci		axp20x->cells = axp288_cells;
8768c2ecf20Sopenharmony_ci		axp20x->nr_cells = ARRAY_SIZE(axp288_cells);
8778c2ecf20Sopenharmony_ci		axp20x->regmap_cfg = &axp288_regmap_config;
8788c2ecf20Sopenharmony_ci		axp20x->regmap_irq_chip = &axp288_regmap_irq_chip;
8798c2ecf20Sopenharmony_ci		axp20x->irq_flags = IRQF_TRIGGER_LOW;
8808c2ecf20Sopenharmony_ci		break;
8818c2ecf20Sopenharmony_ci	case AXP803_ID:
8828c2ecf20Sopenharmony_ci		axp20x->nr_cells = ARRAY_SIZE(axp803_cells);
8838c2ecf20Sopenharmony_ci		axp20x->cells = axp803_cells;
8848c2ecf20Sopenharmony_ci		axp20x->regmap_cfg = &axp288_regmap_config;
8858c2ecf20Sopenharmony_ci		axp20x->regmap_irq_chip = &axp803_regmap_irq_chip;
8868c2ecf20Sopenharmony_ci		break;
8878c2ecf20Sopenharmony_ci	case AXP806_ID:
8888c2ecf20Sopenharmony_ci		if (of_property_read_bool(axp20x->dev->of_node,
8898c2ecf20Sopenharmony_ci					  "x-powers,self-working-mode")) {
8908c2ecf20Sopenharmony_ci			axp20x->nr_cells = ARRAY_SIZE(axp806_self_working_cells);
8918c2ecf20Sopenharmony_ci			axp20x->cells = axp806_self_working_cells;
8928c2ecf20Sopenharmony_ci		} else {
8938c2ecf20Sopenharmony_ci			axp20x->nr_cells = ARRAY_SIZE(axp806_cells);
8948c2ecf20Sopenharmony_ci			axp20x->cells = axp806_cells;
8958c2ecf20Sopenharmony_ci		}
8968c2ecf20Sopenharmony_ci		axp20x->regmap_cfg = &axp806_regmap_config;
8978c2ecf20Sopenharmony_ci		axp20x->regmap_irq_chip = &axp806_regmap_irq_chip;
8988c2ecf20Sopenharmony_ci		break;
8998c2ecf20Sopenharmony_ci	case AXP809_ID:
9008c2ecf20Sopenharmony_ci		axp20x->nr_cells = ARRAY_SIZE(axp809_cells);
9018c2ecf20Sopenharmony_ci		axp20x->cells = axp809_cells;
9028c2ecf20Sopenharmony_ci		axp20x->regmap_cfg = &axp22x_regmap_config;
9038c2ecf20Sopenharmony_ci		axp20x->regmap_irq_chip = &axp809_regmap_irq_chip;
9048c2ecf20Sopenharmony_ci		break;
9058c2ecf20Sopenharmony_ci	case AXP813_ID:
9068c2ecf20Sopenharmony_ci		axp20x->nr_cells = ARRAY_SIZE(axp813_cells);
9078c2ecf20Sopenharmony_ci		axp20x->cells = axp813_cells;
9088c2ecf20Sopenharmony_ci		axp20x->regmap_cfg = &axp288_regmap_config;
9098c2ecf20Sopenharmony_ci		/*
9108c2ecf20Sopenharmony_ci		 * The IRQ table given in the datasheet is incorrect.
9118c2ecf20Sopenharmony_ci		 * In IRQ enable/status registers 1, there are separate
9128c2ecf20Sopenharmony_ci		 * IRQs for ACIN and VBUS, instead of bits [7:5] being
9138c2ecf20Sopenharmony_ci		 * the same as bits [4:2]. So it shares the same IRQs
9148c2ecf20Sopenharmony_ci		 * as the AXP803, rather than the AXP288.
9158c2ecf20Sopenharmony_ci		 */
9168c2ecf20Sopenharmony_ci		axp20x->regmap_irq_chip = &axp803_regmap_irq_chip;
9178c2ecf20Sopenharmony_ci		break;
9188c2ecf20Sopenharmony_ci	default:
9198c2ecf20Sopenharmony_ci		dev_err(dev, "unsupported AXP20X ID %lu\n", axp20x->variant);
9208c2ecf20Sopenharmony_ci		return -EINVAL;
9218c2ecf20Sopenharmony_ci	}
9228c2ecf20Sopenharmony_ci	dev_info(dev, "AXP20x variant %s found\n",
9238c2ecf20Sopenharmony_ci		 axp20x_model_names[axp20x->variant]);
9248c2ecf20Sopenharmony_ci
9258c2ecf20Sopenharmony_ci	return 0;
9268c2ecf20Sopenharmony_ci}
9278c2ecf20Sopenharmony_ciEXPORT_SYMBOL(axp20x_match_device);
9288c2ecf20Sopenharmony_ci
9298c2ecf20Sopenharmony_ciint axp20x_device_probe(struct axp20x_dev *axp20x)
9308c2ecf20Sopenharmony_ci{
9318c2ecf20Sopenharmony_ci	int ret;
9328c2ecf20Sopenharmony_ci
9338c2ecf20Sopenharmony_ci	/*
9348c2ecf20Sopenharmony_ci	 * The AXP806 supports either master/standalone or slave mode.
9358c2ecf20Sopenharmony_ci	 * Slave mode allows sharing the serial bus, even with multiple
9368c2ecf20Sopenharmony_ci	 * AXP806 which all have the same hardware address.
9378c2ecf20Sopenharmony_ci	 *
9388c2ecf20Sopenharmony_ci	 * This is done with extra "serial interface address extension",
9398c2ecf20Sopenharmony_ci	 * or AXP806_BUS_ADDR_EXT, and "register address extension", or
9408c2ecf20Sopenharmony_ci	 * AXP806_REG_ADDR_EXT, registers. The former is read-only, with
9418c2ecf20Sopenharmony_ci	 * 1 bit customizable at the factory, and 1 bit depending on the
9428c2ecf20Sopenharmony_ci	 * state of an external pin. The latter is writable. The device
9438c2ecf20Sopenharmony_ci	 * will only respond to operations to its other registers when
9448c2ecf20Sopenharmony_ci	 * the these device addressing bits (in the upper 4 bits of the
9458c2ecf20Sopenharmony_ci	 * registers) match.
9468c2ecf20Sopenharmony_ci	 *
9478c2ecf20Sopenharmony_ci	 * By default we support an AXP806 chained to an AXP809 in slave
9488c2ecf20Sopenharmony_ci	 * mode. Boards which use an AXP806 in master mode can set the
9498c2ecf20Sopenharmony_ci	 * property "x-powers,master-mode" to override the default.
9508c2ecf20Sopenharmony_ci	 */
9518c2ecf20Sopenharmony_ci	if (axp20x->variant == AXP806_ID) {
9528c2ecf20Sopenharmony_ci		if (of_property_read_bool(axp20x->dev->of_node,
9538c2ecf20Sopenharmony_ci					  "x-powers,master-mode") ||
9548c2ecf20Sopenharmony_ci		    of_property_read_bool(axp20x->dev->of_node,
9558c2ecf20Sopenharmony_ci					  "x-powers,self-working-mode"))
9568c2ecf20Sopenharmony_ci			regmap_write(axp20x->regmap, AXP806_REG_ADDR_EXT,
9578c2ecf20Sopenharmony_ci				     AXP806_REG_ADDR_EXT_ADDR_MASTER_MODE);
9588c2ecf20Sopenharmony_ci		else
9598c2ecf20Sopenharmony_ci			regmap_write(axp20x->regmap, AXP806_REG_ADDR_EXT,
9608c2ecf20Sopenharmony_ci				     AXP806_REG_ADDR_EXT_ADDR_SLAVE_MODE);
9618c2ecf20Sopenharmony_ci	}
9628c2ecf20Sopenharmony_ci
9638c2ecf20Sopenharmony_ci	ret = regmap_add_irq_chip(axp20x->regmap, axp20x->irq,
9648c2ecf20Sopenharmony_ci			  IRQF_ONESHOT | IRQF_SHARED | axp20x->irq_flags,
9658c2ecf20Sopenharmony_ci			   -1, axp20x->regmap_irq_chip, &axp20x->regmap_irqc);
9668c2ecf20Sopenharmony_ci	if (ret) {
9678c2ecf20Sopenharmony_ci		dev_err(axp20x->dev, "failed to add irq chip: %d\n", ret);
9688c2ecf20Sopenharmony_ci		return ret;
9698c2ecf20Sopenharmony_ci	}
9708c2ecf20Sopenharmony_ci
9718c2ecf20Sopenharmony_ci	ret = mfd_add_devices(axp20x->dev, -1, axp20x->cells,
9728c2ecf20Sopenharmony_ci			      axp20x->nr_cells, NULL, 0, NULL);
9738c2ecf20Sopenharmony_ci
9748c2ecf20Sopenharmony_ci	if (ret) {
9758c2ecf20Sopenharmony_ci		dev_err(axp20x->dev, "failed to add MFD devices: %d\n", ret);
9768c2ecf20Sopenharmony_ci		regmap_del_irq_chip(axp20x->irq, axp20x->regmap_irqc);
9778c2ecf20Sopenharmony_ci		return ret;
9788c2ecf20Sopenharmony_ci	}
9798c2ecf20Sopenharmony_ci
9808c2ecf20Sopenharmony_ci	if (!pm_power_off) {
9818c2ecf20Sopenharmony_ci		axp20x_pm_power_off = axp20x;
9828c2ecf20Sopenharmony_ci		pm_power_off = axp20x_power_off;
9838c2ecf20Sopenharmony_ci	}
9848c2ecf20Sopenharmony_ci
9858c2ecf20Sopenharmony_ci	dev_info(axp20x->dev, "AXP20X driver loaded\n");
9868c2ecf20Sopenharmony_ci
9878c2ecf20Sopenharmony_ci	return 0;
9888c2ecf20Sopenharmony_ci}
9898c2ecf20Sopenharmony_ciEXPORT_SYMBOL(axp20x_device_probe);
9908c2ecf20Sopenharmony_ci
9918c2ecf20Sopenharmony_ciint axp20x_device_remove(struct axp20x_dev *axp20x)
9928c2ecf20Sopenharmony_ci{
9938c2ecf20Sopenharmony_ci	if (axp20x == axp20x_pm_power_off) {
9948c2ecf20Sopenharmony_ci		axp20x_pm_power_off = NULL;
9958c2ecf20Sopenharmony_ci		pm_power_off = NULL;
9968c2ecf20Sopenharmony_ci	}
9978c2ecf20Sopenharmony_ci
9988c2ecf20Sopenharmony_ci	mfd_remove_devices(axp20x->dev);
9998c2ecf20Sopenharmony_ci	regmap_del_irq_chip(axp20x->irq, axp20x->regmap_irqc);
10008c2ecf20Sopenharmony_ci
10018c2ecf20Sopenharmony_ci	return 0;
10028c2ecf20Sopenharmony_ci}
10038c2ecf20Sopenharmony_ciEXPORT_SYMBOL(axp20x_device_remove);
10048c2ecf20Sopenharmony_ci
10058c2ecf20Sopenharmony_ciMODULE_DESCRIPTION("PMIC MFD core driver for AXP20X");
10068c2ecf20Sopenharmony_ciMODULE_AUTHOR("Carlo Caione <carlo@caione.org>");
10078c2ecf20Sopenharmony_ciMODULE_LICENSE("GPL");
1008