18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci * Marvell 88PM80x Interface
48c2ecf20Sopenharmony_ci *
58c2ecf20Sopenharmony_ci * Copyright (C) 2012 Marvell International Ltd.
68c2ecf20Sopenharmony_ci * Qiao Zhou <zhouqiao@marvell.com>
78c2ecf20Sopenharmony_ci */
88c2ecf20Sopenharmony_ci
98c2ecf20Sopenharmony_ci#ifndef __LINUX_MFD_88PM80X_H
108c2ecf20Sopenharmony_ci#define __LINUX_MFD_88PM80X_H
118c2ecf20Sopenharmony_ci
128c2ecf20Sopenharmony_ci#include <linux/platform_device.h>
138c2ecf20Sopenharmony_ci#include <linux/interrupt.h>
148c2ecf20Sopenharmony_ci#include <linux/regmap.h>
158c2ecf20Sopenharmony_ci#include <linux/atomic.h>
168c2ecf20Sopenharmony_ci
178c2ecf20Sopenharmony_cienum {
188c2ecf20Sopenharmony_ci	CHIP_INVALID = 0,
198c2ecf20Sopenharmony_ci	CHIP_PM800,
208c2ecf20Sopenharmony_ci	CHIP_PM805,
218c2ecf20Sopenharmony_ci	CHIP_PM860,
228c2ecf20Sopenharmony_ci	CHIP_MAX,
238c2ecf20Sopenharmony_ci};
248c2ecf20Sopenharmony_ci
258c2ecf20Sopenharmony_cienum {
268c2ecf20Sopenharmony_ci	PM800_ID_BUCK1 = 0,
278c2ecf20Sopenharmony_ci	PM800_ID_BUCK2,
288c2ecf20Sopenharmony_ci	PM800_ID_BUCK3,
298c2ecf20Sopenharmony_ci	PM800_ID_BUCK4,
308c2ecf20Sopenharmony_ci	PM800_ID_BUCK5,
318c2ecf20Sopenharmony_ci
328c2ecf20Sopenharmony_ci	PM800_ID_LDO1,
338c2ecf20Sopenharmony_ci	PM800_ID_LDO2,
348c2ecf20Sopenharmony_ci	PM800_ID_LDO3,
358c2ecf20Sopenharmony_ci	PM800_ID_LDO4,
368c2ecf20Sopenharmony_ci	PM800_ID_LDO5,
378c2ecf20Sopenharmony_ci	PM800_ID_LDO6,
388c2ecf20Sopenharmony_ci	PM800_ID_LDO7,
398c2ecf20Sopenharmony_ci	PM800_ID_LDO8,
408c2ecf20Sopenharmony_ci	PM800_ID_LDO9,
418c2ecf20Sopenharmony_ci	PM800_ID_LDO10,
428c2ecf20Sopenharmony_ci	PM800_ID_LDO11,
438c2ecf20Sopenharmony_ci	PM800_ID_LDO12,
448c2ecf20Sopenharmony_ci	PM800_ID_LDO13,
458c2ecf20Sopenharmony_ci	PM800_ID_LDO14,
468c2ecf20Sopenharmony_ci	PM800_ID_LDO15,
478c2ecf20Sopenharmony_ci	PM800_ID_LDO16,
488c2ecf20Sopenharmony_ci	PM800_ID_LDO17,
498c2ecf20Sopenharmony_ci	PM800_ID_LDO18,
508c2ecf20Sopenharmony_ci	PM800_ID_LDO19,
518c2ecf20Sopenharmony_ci
528c2ecf20Sopenharmony_ci	PM800_ID_RG_MAX,
538c2ecf20Sopenharmony_ci};
548c2ecf20Sopenharmony_ci#define PM800_MAX_REGULATOR	PM800_ID_RG_MAX	/* 5 Bucks, 19 LDOs */
558c2ecf20Sopenharmony_ci#define PM800_NUM_BUCK (5)	/*5 Bucks */
568c2ecf20Sopenharmony_ci#define PM800_NUM_LDO (19)	/*19 Bucks */
578c2ecf20Sopenharmony_ci
588c2ecf20Sopenharmony_ci/* page 0 basic: slave adder 0x60 */
598c2ecf20Sopenharmony_ci
608c2ecf20Sopenharmony_ci#define PM800_STATUS_1			(0x01)
618c2ecf20Sopenharmony_ci#define PM800_ONKEY_STS1		BIT(0)
628c2ecf20Sopenharmony_ci#define PM800_EXTON_STS1		BIT(1)
638c2ecf20Sopenharmony_ci#define PM800_CHG_STS1			BIT(2)
648c2ecf20Sopenharmony_ci#define PM800_BAT_STS1			BIT(3)
658c2ecf20Sopenharmony_ci#define PM800_VBUS_STS1			BIT(4)
668c2ecf20Sopenharmony_ci#define PM800_LDO_PGOOD_STS1		BIT(5)
678c2ecf20Sopenharmony_ci#define PM800_BUCK_PGOOD_STS1		BIT(6)
688c2ecf20Sopenharmony_ci
698c2ecf20Sopenharmony_ci#define PM800_STATUS_2			(0x02)
708c2ecf20Sopenharmony_ci#define PM800_RTC_ALARM_STS2		BIT(0)
718c2ecf20Sopenharmony_ci
728c2ecf20Sopenharmony_ci/* Wakeup Registers */
738c2ecf20Sopenharmony_ci#define PM800_WAKEUP1			(0x0D)
748c2ecf20Sopenharmony_ci
758c2ecf20Sopenharmony_ci#define PM800_WAKEUP2			(0x0E)
768c2ecf20Sopenharmony_ci#define PM800_WAKEUP2_INV_INT		BIT(0)
778c2ecf20Sopenharmony_ci#define PM800_WAKEUP2_INT_CLEAR		BIT(1)
788c2ecf20Sopenharmony_ci#define PM800_WAKEUP2_INT_MASK		BIT(2)
798c2ecf20Sopenharmony_ci
808c2ecf20Sopenharmony_ci#define PM800_POWER_UP_LOG		(0x10)
818c2ecf20Sopenharmony_ci
828c2ecf20Sopenharmony_ci/* Referance and low power registers */
838c2ecf20Sopenharmony_ci#define PM800_LOW_POWER1		(0x20)
848c2ecf20Sopenharmony_ci#define PM800_LOW_POWER2		(0x21)
858c2ecf20Sopenharmony_ci#define PM800_LOW_POWER_CONFIG3		(0x22)
868c2ecf20Sopenharmony_ci#define PM800_LOW_POWER_CONFIG4		(0x23)
878c2ecf20Sopenharmony_ci
888c2ecf20Sopenharmony_ci/* GPIO register */
898c2ecf20Sopenharmony_ci#define PM800_GPIO_0_1_CNTRL		(0x30)
908c2ecf20Sopenharmony_ci#define PM800_GPIO0_VAL			BIT(0)
918c2ecf20Sopenharmony_ci#define PM800_GPIO0_GPIO_MODE(x)	(x << 1)
928c2ecf20Sopenharmony_ci#define PM800_GPIO1_VAL			BIT(4)
938c2ecf20Sopenharmony_ci#define PM800_GPIO1_GPIO_MODE(x)	(x << 5)
948c2ecf20Sopenharmony_ci
958c2ecf20Sopenharmony_ci#define PM800_GPIO_2_3_CNTRL		(0x31)
968c2ecf20Sopenharmony_ci#define PM800_GPIO2_VAL			BIT(0)
978c2ecf20Sopenharmony_ci#define PM800_GPIO2_GPIO_MODE(x)	(x << 1)
988c2ecf20Sopenharmony_ci#define PM800_GPIO3_VAL			BIT(4)
998c2ecf20Sopenharmony_ci#define PM800_GPIO3_GPIO_MODE(x)	(x << 5)
1008c2ecf20Sopenharmony_ci#define PM800_GPIO3_MODE_MASK		0x1F
1018c2ecf20Sopenharmony_ci#define PM800_GPIO3_HEADSET_MODE	PM800_GPIO3_GPIO_MODE(6)
1028c2ecf20Sopenharmony_ci
1038c2ecf20Sopenharmony_ci#define PM800_GPIO_4_CNTRL		(0x32)
1048c2ecf20Sopenharmony_ci#define PM800_GPIO4_VAL			BIT(0)
1058c2ecf20Sopenharmony_ci#define PM800_GPIO4_GPIO_MODE(x)	(x << 1)
1068c2ecf20Sopenharmony_ci
1078c2ecf20Sopenharmony_ci#define PM800_HEADSET_CNTRL		(0x38)
1088c2ecf20Sopenharmony_ci#define PM800_HEADSET_DET_EN		BIT(7)
1098c2ecf20Sopenharmony_ci#define PM800_HSDET_SLP			BIT(1)
1108c2ecf20Sopenharmony_ci/* PWM register */
1118c2ecf20Sopenharmony_ci#define PM800_PWM1			(0x40)
1128c2ecf20Sopenharmony_ci#define PM800_PWM2			(0x41)
1138c2ecf20Sopenharmony_ci#define PM800_PWM3			(0x42)
1148c2ecf20Sopenharmony_ci#define PM800_PWM4			(0x43)
1158c2ecf20Sopenharmony_ci
1168c2ecf20Sopenharmony_ci/* RTC Registers */
1178c2ecf20Sopenharmony_ci#define PM800_RTC_CONTROL		(0xD0)
1188c2ecf20Sopenharmony_ci#define PM800_RTC_MISC1			(0xE1)
1198c2ecf20Sopenharmony_ci#define PM800_RTC_MISC2			(0xE2)
1208c2ecf20Sopenharmony_ci#define PM800_RTC_MISC3			(0xE3)
1218c2ecf20Sopenharmony_ci#define PM800_RTC_MISC4			(0xE4)
1228c2ecf20Sopenharmony_ci#define PM800_RTC_MISC5			(0xE7)
1238c2ecf20Sopenharmony_ci/* bit definitions of RTC Register 1 (0xD0) */
1248c2ecf20Sopenharmony_ci#define PM800_ALARM1_EN			BIT(0)
1258c2ecf20Sopenharmony_ci#define PM800_ALARM_WAKEUP		BIT(4)
1268c2ecf20Sopenharmony_ci#define PM800_ALARM			BIT(5)
1278c2ecf20Sopenharmony_ci#define PM800_RTC1_USE_XO		BIT(7)
1288c2ecf20Sopenharmony_ci
1298c2ecf20Sopenharmony_ci/* Regulator Control Registers: BUCK1,BUCK5,LDO1 have DVC */
1308c2ecf20Sopenharmony_ci
1318c2ecf20Sopenharmony_ci/* buck registers */
1328c2ecf20Sopenharmony_ci#define PM800_SLEEP_BUCK1		(0x30)
1338c2ecf20Sopenharmony_ci
1348c2ecf20Sopenharmony_ci/* BUCK Sleep Mode Register 1: BUCK[1..4] */
1358c2ecf20Sopenharmony_ci#define PM800_BUCK_SLP1			(0x5A)
1368c2ecf20Sopenharmony_ci#define PM800_BUCK1_SLP1_SHIFT		0
1378c2ecf20Sopenharmony_ci#define PM800_BUCK1_SLP1_MASK		(0x3 << PM800_BUCK1_SLP1_SHIFT)
1388c2ecf20Sopenharmony_ci
1398c2ecf20Sopenharmony_ci/* page 2 GPADC: slave adder 0x02 */
1408c2ecf20Sopenharmony_ci#define PM800_GPADC_MEAS_EN1		(0x01)
1418c2ecf20Sopenharmony_ci#define PM800_MEAS_EN1_VBAT		BIT(2)
1428c2ecf20Sopenharmony_ci#define PM800_GPADC_MEAS_EN2		(0x02)
1438c2ecf20Sopenharmony_ci#define PM800_MEAS_EN2_RFTMP		BIT(0)
1448c2ecf20Sopenharmony_ci#define PM800_MEAS_GP0_EN		BIT(2)
1458c2ecf20Sopenharmony_ci#define PM800_MEAS_GP1_EN		BIT(3)
1468c2ecf20Sopenharmony_ci#define PM800_MEAS_GP2_EN		BIT(4)
1478c2ecf20Sopenharmony_ci#define PM800_MEAS_GP3_EN		BIT(5)
1488c2ecf20Sopenharmony_ci#define PM800_MEAS_GP4_EN		BIT(6)
1498c2ecf20Sopenharmony_ci
1508c2ecf20Sopenharmony_ci#define PM800_GPADC_MISC_CONFIG1	(0x05)
1518c2ecf20Sopenharmony_ci#define PM800_GPADC_MISC_CONFIG2	(0x06)
1528c2ecf20Sopenharmony_ci#define PM800_GPADC_MISC_GPFSM_EN	BIT(0)
1538c2ecf20Sopenharmony_ci#define PM800_GPADC_SLOW_MODE(x)	(x << 3)
1548c2ecf20Sopenharmony_ci
1558c2ecf20Sopenharmony_ci#define PM800_GPADC_MISC_CONFIG3	(0x09)
1568c2ecf20Sopenharmony_ci#define PM800_GPADC_MISC_CONFIG4	(0x0A)
1578c2ecf20Sopenharmony_ci
1588c2ecf20Sopenharmony_ci#define PM800_GPADC_PREBIAS1		(0x0F)
1598c2ecf20Sopenharmony_ci#define PM800_GPADC0_GP_PREBIAS_TIME(x)	(x << 0)
1608c2ecf20Sopenharmony_ci#define PM800_GPADC_PREBIAS2		(0x10)
1618c2ecf20Sopenharmony_ci
1628c2ecf20Sopenharmony_ci#define PM800_GP_BIAS_ENA1		(0x14)
1638c2ecf20Sopenharmony_ci#define PM800_GPADC_GP_BIAS_EN0		BIT(0)
1648c2ecf20Sopenharmony_ci#define PM800_GPADC_GP_BIAS_EN1		BIT(1)
1658c2ecf20Sopenharmony_ci#define PM800_GPADC_GP_BIAS_EN2		BIT(2)
1668c2ecf20Sopenharmony_ci#define PM800_GPADC_GP_BIAS_EN3		BIT(3)
1678c2ecf20Sopenharmony_ci
1688c2ecf20Sopenharmony_ci#define PM800_GP_BIAS_OUT1		(0x15)
1698c2ecf20Sopenharmony_ci#define PM800_BIAS_OUT_GP0		BIT(0)
1708c2ecf20Sopenharmony_ci#define PM800_BIAS_OUT_GP1		BIT(1)
1718c2ecf20Sopenharmony_ci#define PM800_BIAS_OUT_GP2		BIT(2)
1728c2ecf20Sopenharmony_ci#define PM800_BIAS_OUT_GP3		BIT(3)
1738c2ecf20Sopenharmony_ci
1748c2ecf20Sopenharmony_ci#define PM800_GPADC0_LOW_TH		0x20
1758c2ecf20Sopenharmony_ci#define PM800_GPADC1_LOW_TH		0x21
1768c2ecf20Sopenharmony_ci#define PM800_GPADC2_LOW_TH		0x22
1778c2ecf20Sopenharmony_ci#define PM800_GPADC3_LOW_TH		0x23
1788c2ecf20Sopenharmony_ci#define PM800_GPADC4_LOW_TH		0x24
1798c2ecf20Sopenharmony_ci
1808c2ecf20Sopenharmony_ci#define PM800_GPADC0_UPP_TH		0x30
1818c2ecf20Sopenharmony_ci#define PM800_GPADC1_UPP_TH		0x31
1828c2ecf20Sopenharmony_ci#define PM800_GPADC2_UPP_TH		0x32
1838c2ecf20Sopenharmony_ci#define PM800_GPADC3_UPP_TH		0x33
1848c2ecf20Sopenharmony_ci#define PM800_GPADC4_UPP_TH		0x34
1858c2ecf20Sopenharmony_ci
1868c2ecf20Sopenharmony_ci#define PM800_VBBAT_MEAS1		0x40
1878c2ecf20Sopenharmony_ci#define PM800_VBBAT_MEAS2		0x41
1888c2ecf20Sopenharmony_ci#define PM800_VBAT_MEAS1		0x42
1898c2ecf20Sopenharmony_ci#define PM800_VBAT_MEAS2		0x43
1908c2ecf20Sopenharmony_ci#define PM800_VSYS_MEAS1		0x44
1918c2ecf20Sopenharmony_ci#define PM800_VSYS_MEAS2		0x45
1928c2ecf20Sopenharmony_ci#define PM800_VCHG_MEAS1		0x46
1938c2ecf20Sopenharmony_ci#define PM800_VCHG_MEAS2		0x47
1948c2ecf20Sopenharmony_ci#define PM800_TINT_MEAS1		0x50
1958c2ecf20Sopenharmony_ci#define PM800_TINT_MEAS2		0x51
1968c2ecf20Sopenharmony_ci#define PM800_PMOD_MEAS1		0x52
1978c2ecf20Sopenharmony_ci#define PM800_PMOD_MEAS2		0x53
1988c2ecf20Sopenharmony_ci
1998c2ecf20Sopenharmony_ci#define PM800_GPADC0_MEAS1		0x54
2008c2ecf20Sopenharmony_ci#define PM800_GPADC0_MEAS2		0x55
2018c2ecf20Sopenharmony_ci#define PM800_GPADC1_MEAS1		0x56
2028c2ecf20Sopenharmony_ci#define PM800_GPADC1_MEAS2		0x57
2038c2ecf20Sopenharmony_ci#define PM800_GPADC2_MEAS1		0x58
2048c2ecf20Sopenharmony_ci#define PM800_GPADC2_MEAS2		0x59
2058c2ecf20Sopenharmony_ci#define PM800_GPADC3_MEAS1		0x5A
2068c2ecf20Sopenharmony_ci#define PM800_GPADC3_MEAS2		0x5B
2078c2ecf20Sopenharmony_ci#define PM800_GPADC4_MEAS1		0x5C
2088c2ecf20Sopenharmony_ci#define PM800_GPADC4_MEAS2		0x5D
2098c2ecf20Sopenharmony_ci
2108c2ecf20Sopenharmony_ci#define PM800_GPADC4_AVG1		0xA8
2118c2ecf20Sopenharmony_ci#define PM800_GPADC4_AVG2		0xA9
2128c2ecf20Sopenharmony_ci
2138c2ecf20Sopenharmony_ci/* 88PM805 Registers */
2148c2ecf20Sopenharmony_ci#define PM805_MAIN_POWERUP		(0x01)
2158c2ecf20Sopenharmony_ci#define PM805_INT_STATUS0		(0x02)	/* for ena/dis all interrupts */
2168c2ecf20Sopenharmony_ci
2178c2ecf20Sopenharmony_ci#define PM805_STATUS0_INT_CLEAR		(1 << 0)
2188c2ecf20Sopenharmony_ci#define PM805_STATUS0_INV_INT		(1 << 1)
2198c2ecf20Sopenharmony_ci#define PM800_STATUS0_INT_MASK		(1 << 2)
2208c2ecf20Sopenharmony_ci
2218c2ecf20Sopenharmony_ci#define PM805_INT_STATUS1		(0x03)
2228c2ecf20Sopenharmony_ci
2238c2ecf20Sopenharmony_ci#define PM805_INT1_HP1_SHRT		BIT(0)
2248c2ecf20Sopenharmony_ci#define PM805_INT1_HP2_SHRT		BIT(1)
2258c2ecf20Sopenharmony_ci#define PM805_INT1_MIC_CONFLICT		BIT(2)
2268c2ecf20Sopenharmony_ci#define PM805_INT1_CLIP_FAULT		BIT(3)
2278c2ecf20Sopenharmony_ci#define PM805_INT1_LDO_OFF		BIT(4)
2288c2ecf20Sopenharmony_ci#define PM805_INT1_SRC_DPLL_LOCK	BIT(5)
2298c2ecf20Sopenharmony_ci
2308c2ecf20Sopenharmony_ci#define PM805_INT_STATUS2		(0x04)
2318c2ecf20Sopenharmony_ci
2328c2ecf20Sopenharmony_ci#define PM805_INT2_MIC_DET		BIT(0)
2338c2ecf20Sopenharmony_ci#define PM805_INT2_SHRT_BTN_DET		BIT(1)
2348c2ecf20Sopenharmony_ci#define PM805_INT2_VOLM_BTN_DET		BIT(2)
2358c2ecf20Sopenharmony_ci#define PM805_INT2_VOLP_BTN_DET		BIT(3)
2368c2ecf20Sopenharmony_ci#define PM805_INT2_RAW_PLL_FAULT	BIT(4)
2378c2ecf20Sopenharmony_ci#define PM805_INT2_FINE_PLL_FAULT	BIT(5)
2388c2ecf20Sopenharmony_ci
2398c2ecf20Sopenharmony_ci#define PM805_INT_MASK1			(0x05)
2408c2ecf20Sopenharmony_ci#define PM805_INT_MASK2			(0x06)
2418c2ecf20Sopenharmony_ci#define PM805_SHRT_BTN_DET		BIT(1)
2428c2ecf20Sopenharmony_ci
2438c2ecf20Sopenharmony_ci/* number of status and int reg in a row */
2448c2ecf20Sopenharmony_ci#define PM805_INT_REG_NUM		(2)
2458c2ecf20Sopenharmony_ci
2468c2ecf20Sopenharmony_ci#define PM805_MIC_DET1			(0x07)
2478c2ecf20Sopenharmony_ci#define PM805_MIC_DET_EN_MIC_DET	BIT(0)
2488c2ecf20Sopenharmony_ci#define PM805_MIC_DET2			(0x08)
2498c2ecf20Sopenharmony_ci#define PM805_MIC_DET_STATUS1		(0x09)
2508c2ecf20Sopenharmony_ci
2518c2ecf20Sopenharmony_ci#define PM805_MIC_DET_STATUS3		(0x0A)
2528c2ecf20Sopenharmony_ci#define PM805_AUTO_SEQ_STATUS1		(0x0B)
2538c2ecf20Sopenharmony_ci#define PM805_AUTO_SEQ_STATUS2		(0x0C)
2548c2ecf20Sopenharmony_ci
2558c2ecf20Sopenharmony_ci#define PM805_ADC_SETTING1		(0x10)
2568c2ecf20Sopenharmony_ci#define PM805_ADC_SETTING2		(0x11)
2578c2ecf20Sopenharmony_ci#define PM805_ADC_SETTING3		(0x11)
2588c2ecf20Sopenharmony_ci#define PM805_ADC_GAIN1			(0x12)
2598c2ecf20Sopenharmony_ci#define PM805_ADC_GAIN2			(0x13)
2608c2ecf20Sopenharmony_ci#define PM805_DMIC_SETTING		(0x15)
2618c2ecf20Sopenharmony_ci#define PM805_DWS_SETTING		(0x16)
2628c2ecf20Sopenharmony_ci#define PM805_MIC_CONFLICT_STS		(0x17)
2638c2ecf20Sopenharmony_ci
2648c2ecf20Sopenharmony_ci#define PM805_PDM_SETTING1		(0x20)
2658c2ecf20Sopenharmony_ci#define PM805_PDM_SETTING2		(0x21)
2668c2ecf20Sopenharmony_ci#define PM805_PDM_SETTING3		(0x22)
2678c2ecf20Sopenharmony_ci#define PM805_PDM_CONTROL1		(0x23)
2688c2ecf20Sopenharmony_ci#define PM805_PDM_CONTROL2		(0x24)
2698c2ecf20Sopenharmony_ci#define PM805_PDM_CONTROL3		(0x25)
2708c2ecf20Sopenharmony_ci
2718c2ecf20Sopenharmony_ci#define PM805_HEADPHONE_SETTING		(0x26)
2728c2ecf20Sopenharmony_ci#define PM805_HEADPHONE_GAIN_A2A	(0x27)
2738c2ecf20Sopenharmony_ci#define PM805_HEADPHONE_SHORT_STATE	(0x28)
2748c2ecf20Sopenharmony_ci#define PM805_EARPHONE_SETTING		(0x29)
2758c2ecf20Sopenharmony_ci#define PM805_AUTO_SEQ_SETTING		(0x2A)
2768c2ecf20Sopenharmony_ci
2778c2ecf20Sopenharmony_cistruct pm80x_rtc_pdata {
2788c2ecf20Sopenharmony_ci	int		vrtc;
2798c2ecf20Sopenharmony_ci	int		rtc_wakeup;
2808c2ecf20Sopenharmony_ci};
2818c2ecf20Sopenharmony_ci
2828c2ecf20Sopenharmony_cistruct pm80x_subchip {
2838c2ecf20Sopenharmony_ci	struct i2c_client *power_page;	/* chip client for power page */
2848c2ecf20Sopenharmony_ci	struct i2c_client *gpadc_page;	/* chip client for gpadc page */
2858c2ecf20Sopenharmony_ci	struct regmap *regmap_power;
2868c2ecf20Sopenharmony_ci	struct regmap *regmap_gpadc;
2878c2ecf20Sopenharmony_ci	unsigned short power_page_addr;	/* power page I2C address */
2888c2ecf20Sopenharmony_ci	unsigned short gpadc_page_addr;	/* gpadc page I2C address */
2898c2ecf20Sopenharmony_ci};
2908c2ecf20Sopenharmony_ci
2918c2ecf20Sopenharmony_cistruct pm80x_chip {
2928c2ecf20Sopenharmony_ci	struct pm80x_subchip *subchip;
2938c2ecf20Sopenharmony_ci	struct device *dev;
2948c2ecf20Sopenharmony_ci	struct i2c_client *client;
2958c2ecf20Sopenharmony_ci	struct i2c_client *companion;
2968c2ecf20Sopenharmony_ci	struct regmap *regmap;
2978c2ecf20Sopenharmony_ci	struct regmap_irq_chip *regmap_irq_chip;
2988c2ecf20Sopenharmony_ci	struct regmap_irq_chip_data *irq_data;
2998c2ecf20Sopenharmony_ci	int type;
3008c2ecf20Sopenharmony_ci	int irq;
3018c2ecf20Sopenharmony_ci	int irq_mode;
3028c2ecf20Sopenharmony_ci	unsigned long wu_flag;
3038c2ecf20Sopenharmony_ci	spinlock_t lock;
3048c2ecf20Sopenharmony_ci};
3058c2ecf20Sopenharmony_ci
3068c2ecf20Sopenharmony_cistruct pm80x_platform_data {
3078c2ecf20Sopenharmony_ci	struct pm80x_rtc_pdata *rtc;
3088c2ecf20Sopenharmony_ci	/*
3098c2ecf20Sopenharmony_ci	 * For the regulator not defined, set regulators[not_defined] to be
3108c2ecf20Sopenharmony_ci	 * NULL. num_regulators are the number of regulators supposed to be
3118c2ecf20Sopenharmony_ci	 * initialized. If all regulators are not defined, set num_regulators
3128c2ecf20Sopenharmony_ci	 * to be 0.
3138c2ecf20Sopenharmony_ci	 */
3148c2ecf20Sopenharmony_ci	struct regulator_init_data *regulators[PM800_ID_RG_MAX];
3158c2ecf20Sopenharmony_ci	unsigned int num_regulators;
3168c2ecf20Sopenharmony_ci	int irq_mode;		/* Clear interrupt by read/write(0/1) */
3178c2ecf20Sopenharmony_ci	int batt_det;		/* enable/disable */
3188c2ecf20Sopenharmony_ci	int (*plat_config)(struct pm80x_chip *chip,
3198c2ecf20Sopenharmony_ci				struct pm80x_platform_data *pdata);
3208c2ecf20Sopenharmony_ci};
3218c2ecf20Sopenharmony_ci
3228c2ecf20Sopenharmony_ciextern const struct dev_pm_ops pm80x_pm_ops;
3238c2ecf20Sopenharmony_ciextern const struct regmap_config pm80x_regmap_config;
3248c2ecf20Sopenharmony_ci
3258c2ecf20Sopenharmony_cistatic inline int pm80x_request_irq(struct pm80x_chip *pm80x, int irq,
3268c2ecf20Sopenharmony_ci				     irq_handler_t handler, unsigned long flags,
3278c2ecf20Sopenharmony_ci				     const char *name, void *data)
3288c2ecf20Sopenharmony_ci{
3298c2ecf20Sopenharmony_ci	if (!pm80x->irq_data)
3308c2ecf20Sopenharmony_ci		return -EINVAL;
3318c2ecf20Sopenharmony_ci	return request_threaded_irq(regmap_irq_get_virq(pm80x->irq_data, irq),
3328c2ecf20Sopenharmony_ci				    NULL, handler, flags, name, data);
3338c2ecf20Sopenharmony_ci}
3348c2ecf20Sopenharmony_ci
3358c2ecf20Sopenharmony_cistatic inline void pm80x_free_irq(struct pm80x_chip *pm80x, int irq, void *data)
3368c2ecf20Sopenharmony_ci{
3378c2ecf20Sopenharmony_ci	if (!pm80x->irq_data)
3388c2ecf20Sopenharmony_ci		return;
3398c2ecf20Sopenharmony_ci	free_irq(regmap_irq_get_virq(pm80x->irq_data, irq), data);
3408c2ecf20Sopenharmony_ci}
3418c2ecf20Sopenharmony_ci
3428c2ecf20Sopenharmony_ci#ifdef CONFIG_PM
3438c2ecf20Sopenharmony_cistatic inline int pm80x_dev_suspend(struct device *dev)
3448c2ecf20Sopenharmony_ci{
3458c2ecf20Sopenharmony_ci	struct platform_device *pdev = to_platform_device(dev);
3468c2ecf20Sopenharmony_ci	struct pm80x_chip *chip = dev_get_drvdata(pdev->dev.parent);
3478c2ecf20Sopenharmony_ci	int irq = platform_get_irq(pdev, 0);
3488c2ecf20Sopenharmony_ci
3498c2ecf20Sopenharmony_ci	if (device_may_wakeup(dev))
3508c2ecf20Sopenharmony_ci		set_bit(irq, &chip->wu_flag);
3518c2ecf20Sopenharmony_ci
3528c2ecf20Sopenharmony_ci	return 0;
3538c2ecf20Sopenharmony_ci}
3548c2ecf20Sopenharmony_ci
3558c2ecf20Sopenharmony_cistatic inline int pm80x_dev_resume(struct device *dev)
3568c2ecf20Sopenharmony_ci{
3578c2ecf20Sopenharmony_ci	struct platform_device *pdev = to_platform_device(dev);
3588c2ecf20Sopenharmony_ci	struct pm80x_chip *chip = dev_get_drvdata(pdev->dev.parent);
3598c2ecf20Sopenharmony_ci	int irq = platform_get_irq(pdev, 0);
3608c2ecf20Sopenharmony_ci
3618c2ecf20Sopenharmony_ci	if (device_may_wakeup(dev))
3628c2ecf20Sopenharmony_ci		clear_bit(irq, &chip->wu_flag);
3638c2ecf20Sopenharmony_ci
3648c2ecf20Sopenharmony_ci	return 0;
3658c2ecf20Sopenharmony_ci}
3668c2ecf20Sopenharmony_ci#endif
3678c2ecf20Sopenharmony_ci
3688c2ecf20Sopenharmony_ciextern int pm80x_init(struct i2c_client *client);
3698c2ecf20Sopenharmony_ciextern int pm80x_deinit(void);
3708c2ecf20Sopenharmony_ci#endif /* __LINUX_MFD_88PM80X_H */
371