18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0-only
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci * Copyright (c) 2014 MediaTek Inc.
48c2ecf20Sopenharmony_ci * Author: Flora Fu, MediaTek
58c2ecf20Sopenharmony_ci */
68c2ecf20Sopenharmony_ci#include <linux/clk.h>
78c2ecf20Sopenharmony_ci#include <linux/interrupt.h>
88c2ecf20Sopenharmony_ci#include <linux/io.h>
98c2ecf20Sopenharmony_ci#include <linux/kernel.h>
108c2ecf20Sopenharmony_ci#include <linux/module.h>
118c2ecf20Sopenharmony_ci#include <linux/of_device.h>
128c2ecf20Sopenharmony_ci#include <linux/platform_device.h>
138c2ecf20Sopenharmony_ci#include <linux/regmap.h>
148c2ecf20Sopenharmony_ci#include <linux/reset.h>
158c2ecf20Sopenharmony_ci
168c2ecf20Sopenharmony_ci#define PWRAP_MT8135_BRIDGE_IORD_ARB_EN		0x4
178c2ecf20Sopenharmony_ci#define PWRAP_MT8135_BRIDGE_WACS3_EN		0x10
188c2ecf20Sopenharmony_ci#define PWRAP_MT8135_BRIDGE_INIT_DONE3		0x14
198c2ecf20Sopenharmony_ci#define PWRAP_MT8135_BRIDGE_WACS4_EN		0x24
208c2ecf20Sopenharmony_ci#define PWRAP_MT8135_BRIDGE_INIT_DONE4		0x28
218c2ecf20Sopenharmony_ci#define PWRAP_MT8135_BRIDGE_INT_EN		0x38
228c2ecf20Sopenharmony_ci#define PWRAP_MT8135_BRIDGE_TIMER_EN		0x48
238c2ecf20Sopenharmony_ci#define PWRAP_MT8135_BRIDGE_WDT_UNIT		0x50
248c2ecf20Sopenharmony_ci#define PWRAP_MT8135_BRIDGE_WDT_SRC_EN		0x54
258c2ecf20Sopenharmony_ci
268c2ecf20Sopenharmony_ci/* macro for wrapper status */
278c2ecf20Sopenharmony_ci#define PWRAP_GET_WACS_RDATA(x)		(((x) >> 0) & 0x0000ffff)
288c2ecf20Sopenharmony_ci#define PWRAP_GET_WACS_FSM(x)		(((x) >> 16) & 0x00000007)
298c2ecf20Sopenharmony_ci#define PWRAP_GET_WACS_REQ(x)		(((x) >> 19) & 0x00000001)
308c2ecf20Sopenharmony_ci#define PWRAP_STATE_SYNC_IDLE0		(1 << 20)
318c2ecf20Sopenharmony_ci#define PWRAP_STATE_INIT_DONE0		(1 << 21)
328c2ecf20Sopenharmony_ci
338c2ecf20Sopenharmony_ci/* macro for WACS FSM */
348c2ecf20Sopenharmony_ci#define PWRAP_WACS_FSM_IDLE		0x00
358c2ecf20Sopenharmony_ci#define PWRAP_WACS_FSM_REQ		0x02
368c2ecf20Sopenharmony_ci#define PWRAP_WACS_FSM_WFDLE		0x04
378c2ecf20Sopenharmony_ci#define PWRAP_WACS_FSM_WFVLDCLR		0x06
388c2ecf20Sopenharmony_ci#define PWRAP_WACS_INIT_DONE		0x01
398c2ecf20Sopenharmony_ci#define PWRAP_WACS_WACS_SYNC_IDLE	0x01
408c2ecf20Sopenharmony_ci#define PWRAP_WACS_SYNC_BUSY		0x00
418c2ecf20Sopenharmony_ci
428c2ecf20Sopenharmony_ci/* macro for device wrapper default value */
438c2ecf20Sopenharmony_ci#define PWRAP_DEW_READ_TEST_VAL		0x5aa5
448c2ecf20Sopenharmony_ci#define PWRAP_DEW_WRITE_TEST_VAL	0xa55a
458c2ecf20Sopenharmony_ci
468c2ecf20Sopenharmony_ci/* macro for manual command */
478c2ecf20Sopenharmony_ci#define PWRAP_MAN_CMD_SPI_WRITE_NEW	(1 << 14)
488c2ecf20Sopenharmony_ci#define PWRAP_MAN_CMD_SPI_WRITE		(1 << 13)
498c2ecf20Sopenharmony_ci#define PWRAP_MAN_CMD_OP_CSH		(0x0 << 8)
508c2ecf20Sopenharmony_ci#define PWRAP_MAN_CMD_OP_CSL		(0x1 << 8)
518c2ecf20Sopenharmony_ci#define PWRAP_MAN_CMD_OP_CK		(0x2 << 8)
528c2ecf20Sopenharmony_ci#define PWRAP_MAN_CMD_OP_OUTS		(0x8 << 8)
538c2ecf20Sopenharmony_ci#define PWRAP_MAN_CMD_OP_OUTD		(0x9 << 8)
548c2ecf20Sopenharmony_ci#define PWRAP_MAN_CMD_OP_OUTQ		(0xa << 8)
558c2ecf20Sopenharmony_ci
568c2ecf20Sopenharmony_ci/* macro for Watch Dog Timer Source */
578c2ecf20Sopenharmony_ci#define PWRAP_WDT_SRC_EN_STAUPD_TRIG		(1 << 25)
588c2ecf20Sopenharmony_ci#define PWRAP_WDT_SRC_EN_HARB_STAUPD_DLE	(1 << 20)
598c2ecf20Sopenharmony_ci#define PWRAP_WDT_SRC_EN_HARB_STAUPD_ALE	(1 << 6)
608c2ecf20Sopenharmony_ci#define PWRAP_WDT_SRC_MASK_ALL			0xffffffff
618c2ecf20Sopenharmony_ci#define PWRAP_WDT_SRC_MASK_NO_STAUPD	~(PWRAP_WDT_SRC_EN_STAUPD_TRIG | \
628c2ecf20Sopenharmony_ci					  PWRAP_WDT_SRC_EN_HARB_STAUPD_DLE | \
638c2ecf20Sopenharmony_ci					  PWRAP_WDT_SRC_EN_HARB_STAUPD_ALE)
648c2ecf20Sopenharmony_ci
658c2ecf20Sopenharmony_ci/* Group of bits used for shown slave capability */
668c2ecf20Sopenharmony_ci#define PWRAP_SLV_CAP_SPI	BIT(0)
678c2ecf20Sopenharmony_ci#define PWRAP_SLV_CAP_DUALIO	BIT(1)
688c2ecf20Sopenharmony_ci#define PWRAP_SLV_CAP_SECURITY	BIT(2)
698c2ecf20Sopenharmony_ci#define HAS_CAP(_c, _x)	(((_c) & (_x)) == (_x))
708c2ecf20Sopenharmony_ci
718c2ecf20Sopenharmony_ci/* Group of bits used for shown pwrap capability */
728c2ecf20Sopenharmony_ci#define PWRAP_CAP_BRIDGE	BIT(0)
738c2ecf20Sopenharmony_ci#define PWRAP_CAP_RESET		BIT(1)
748c2ecf20Sopenharmony_ci#define PWRAP_CAP_DCM		BIT(2)
758c2ecf20Sopenharmony_ci#define PWRAP_CAP_INT1_EN	BIT(3)
768c2ecf20Sopenharmony_ci#define PWRAP_CAP_WDT_SRC1	BIT(4)
778c2ecf20Sopenharmony_ci
788c2ecf20Sopenharmony_ci/* defines for slave device wrapper registers */
798c2ecf20Sopenharmony_cienum dew_regs {
808c2ecf20Sopenharmony_ci	PWRAP_DEW_BASE,
818c2ecf20Sopenharmony_ci	PWRAP_DEW_DIO_EN,
828c2ecf20Sopenharmony_ci	PWRAP_DEW_READ_TEST,
838c2ecf20Sopenharmony_ci	PWRAP_DEW_WRITE_TEST,
848c2ecf20Sopenharmony_ci	PWRAP_DEW_CRC_EN,
858c2ecf20Sopenharmony_ci	PWRAP_DEW_CRC_VAL,
868c2ecf20Sopenharmony_ci	PWRAP_DEW_MON_GRP_SEL,
878c2ecf20Sopenharmony_ci	PWRAP_DEW_CIPHER_KEY_SEL,
888c2ecf20Sopenharmony_ci	PWRAP_DEW_CIPHER_IV_SEL,
898c2ecf20Sopenharmony_ci	PWRAP_DEW_CIPHER_RDY,
908c2ecf20Sopenharmony_ci	PWRAP_DEW_CIPHER_MODE,
918c2ecf20Sopenharmony_ci	PWRAP_DEW_CIPHER_SWRST,
928c2ecf20Sopenharmony_ci
938c2ecf20Sopenharmony_ci	/* MT6323 only regs */
948c2ecf20Sopenharmony_ci	PWRAP_DEW_CIPHER_EN,
958c2ecf20Sopenharmony_ci	PWRAP_DEW_RDDMY_NO,
968c2ecf20Sopenharmony_ci
978c2ecf20Sopenharmony_ci	/* MT6358 only regs */
988c2ecf20Sopenharmony_ci	PWRAP_SMT_CON1,
998c2ecf20Sopenharmony_ci	PWRAP_DRV_CON1,
1008c2ecf20Sopenharmony_ci	PWRAP_FILTER_CON0,
1018c2ecf20Sopenharmony_ci	PWRAP_GPIO_PULLEN0_CLR,
1028c2ecf20Sopenharmony_ci	PWRAP_RG_SPI_CON0,
1038c2ecf20Sopenharmony_ci	PWRAP_RG_SPI_RECORD0,
1048c2ecf20Sopenharmony_ci	PWRAP_RG_SPI_CON2,
1058c2ecf20Sopenharmony_ci	PWRAP_RG_SPI_CON3,
1068c2ecf20Sopenharmony_ci	PWRAP_RG_SPI_CON4,
1078c2ecf20Sopenharmony_ci	PWRAP_RG_SPI_CON5,
1088c2ecf20Sopenharmony_ci	PWRAP_RG_SPI_CON6,
1098c2ecf20Sopenharmony_ci	PWRAP_RG_SPI_CON7,
1108c2ecf20Sopenharmony_ci	PWRAP_RG_SPI_CON8,
1118c2ecf20Sopenharmony_ci	PWRAP_RG_SPI_CON13,
1128c2ecf20Sopenharmony_ci	PWRAP_SPISLV_KEY,
1138c2ecf20Sopenharmony_ci
1148c2ecf20Sopenharmony_ci	/* MT6359 only regs */
1158c2ecf20Sopenharmony_ci	PWRAP_DEW_CRC_SWRST,
1168c2ecf20Sopenharmony_ci	PWRAP_DEW_RG_EN_RECORD,
1178c2ecf20Sopenharmony_ci	PWRAP_DEW_RECORD_CMD0,
1188c2ecf20Sopenharmony_ci	PWRAP_DEW_RECORD_CMD1,
1198c2ecf20Sopenharmony_ci	PWRAP_DEW_RECORD_CMD2,
1208c2ecf20Sopenharmony_ci	PWRAP_DEW_RECORD_CMD3,
1218c2ecf20Sopenharmony_ci	PWRAP_DEW_RECORD_CMD4,
1228c2ecf20Sopenharmony_ci	PWRAP_DEW_RECORD_CMD5,
1238c2ecf20Sopenharmony_ci	PWRAP_DEW_RECORD_WDATA0,
1248c2ecf20Sopenharmony_ci	PWRAP_DEW_RECORD_WDATA1,
1258c2ecf20Sopenharmony_ci	PWRAP_DEW_RECORD_WDATA2,
1268c2ecf20Sopenharmony_ci	PWRAP_DEW_RECORD_WDATA3,
1278c2ecf20Sopenharmony_ci	PWRAP_DEW_RECORD_WDATA4,
1288c2ecf20Sopenharmony_ci	PWRAP_DEW_RECORD_WDATA5,
1298c2ecf20Sopenharmony_ci	PWRAP_DEW_RG_ADDR_TARGET,
1308c2ecf20Sopenharmony_ci	PWRAP_DEW_RG_ADDR_MASK,
1318c2ecf20Sopenharmony_ci	PWRAP_DEW_RG_WDATA_TARGET,
1328c2ecf20Sopenharmony_ci	PWRAP_DEW_RG_WDATA_MASK,
1338c2ecf20Sopenharmony_ci	PWRAP_DEW_RG_SPI_RECORD_CLR,
1348c2ecf20Sopenharmony_ci	PWRAP_DEW_RG_CMD_ALERT_CLR,
1358c2ecf20Sopenharmony_ci
1368c2ecf20Sopenharmony_ci	/* MT6397 only regs */
1378c2ecf20Sopenharmony_ci	PWRAP_DEW_EVENT_OUT_EN,
1388c2ecf20Sopenharmony_ci	PWRAP_DEW_EVENT_SRC_EN,
1398c2ecf20Sopenharmony_ci	PWRAP_DEW_EVENT_SRC,
1408c2ecf20Sopenharmony_ci	PWRAP_DEW_EVENT_FLAG,
1418c2ecf20Sopenharmony_ci	PWRAP_DEW_MON_FLAG_SEL,
1428c2ecf20Sopenharmony_ci	PWRAP_DEW_EVENT_TEST,
1438c2ecf20Sopenharmony_ci	PWRAP_DEW_CIPHER_LOAD,
1448c2ecf20Sopenharmony_ci	PWRAP_DEW_CIPHER_START,
1458c2ecf20Sopenharmony_ci};
1468c2ecf20Sopenharmony_ci
1478c2ecf20Sopenharmony_cistatic const u32 mt6323_regs[] = {
1488c2ecf20Sopenharmony_ci	[PWRAP_DEW_BASE] =		0x0000,
1498c2ecf20Sopenharmony_ci	[PWRAP_DEW_DIO_EN] =		0x018a,
1508c2ecf20Sopenharmony_ci	[PWRAP_DEW_READ_TEST] =		0x018c,
1518c2ecf20Sopenharmony_ci	[PWRAP_DEW_WRITE_TEST] =	0x018e,
1528c2ecf20Sopenharmony_ci	[PWRAP_DEW_CRC_EN] =		0x0192,
1538c2ecf20Sopenharmony_ci	[PWRAP_DEW_CRC_VAL] =		0x0194,
1548c2ecf20Sopenharmony_ci	[PWRAP_DEW_MON_GRP_SEL] =	0x0196,
1558c2ecf20Sopenharmony_ci	[PWRAP_DEW_CIPHER_KEY_SEL] =	0x0198,
1568c2ecf20Sopenharmony_ci	[PWRAP_DEW_CIPHER_IV_SEL] =	0x019a,
1578c2ecf20Sopenharmony_ci	[PWRAP_DEW_CIPHER_EN] =		0x019c,
1588c2ecf20Sopenharmony_ci	[PWRAP_DEW_CIPHER_RDY] =	0x019e,
1598c2ecf20Sopenharmony_ci	[PWRAP_DEW_CIPHER_MODE] =	0x01a0,
1608c2ecf20Sopenharmony_ci	[PWRAP_DEW_CIPHER_SWRST] =	0x01a2,
1618c2ecf20Sopenharmony_ci	[PWRAP_DEW_RDDMY_NO] =		0x01a4,
1628c2ecf20Sopenharmony_ci};
1638c2ecf20Sopenharmony_ci
1648c2ecf20Sopenharmony_cistatic const u32 mt6351_regs[] = {
1658c2ecf20Sopenharmony_ci	[PWRAP_DEW_DIO_EN] =		0x02F2,
1668c2ecf20Sopenharmony_ci	[PWRAP_DEW_READ_TEST] =		0x02F4,
1678c2ecf20Sopenharmony_ci	[PWRAP_DEW_WRITE_TEST] =	0x02F6,
1688c2ecf20Sopenharmony_ci	[PWRAP_DEW_CRC_EN] =		0x02FA,
1698c2ecf20Sopenharmony_ci	[PWRAP_DEW_CRC_VAL] =		0x02FC,
1708c2ecf20Sopenharmony_ci	[PWRAP_DEW_CIPHER_KEY_SEL] =	0x0300,
1718c2ecf20Sopenharmony_ci	[PWRAP_DEW_CIPHER_IV_SEL] =	0x0302,
1728c2ecf20Sopenharmony_ci	[PWRAP_DEW_CIPHER_EN] =		0x0304,
1738c2ecf20Sopenharmony_ci	[PWRAP_DEW_CIPHER_RDY] =	0x0306,
1748c2ecf20Sopenharmony_ci	[PWRAP_DEW_CIPHER_MODE] =	0x0308,
1758c2ecf20Sopenharmony_ci	[PWRAP_DEW_CIPHER_SWRST] =	0x030A,
1768c2ecf20Sopenharmony_ci	[PWRAP_DEW_RDDMY_NO] =		0x030C,
1778c2ecf20Sopenharmony_ci};
1788c2ecf20Sopenharmony_ci
1798c2ecf20Sopenharmony_cistatic const u32 mt6357_regs[] = {
1808c2ecf20Sopenharmony_ci	[PWRAP_DEW_DIO_EN] =            0x040A,
1818c2ecf20Sopenharmony_ci	[PWRAP_DEW_READ_TEST] =         0x040C,
1828c2ecf20Sopenharmony_ci	[PWRAP_DEW_WRITE_TEST] =        0x040E,
1838c2ecf20Sopenharmony_ci	[PWRAP_DEW_CRC_EN] =            0x0412,
1848c2ecf20Sopenharmony_ci	[PWRAP_DEW_CRC_VAL] =           0x0414,
1858c2ecf20Sopenharmony_ci	[PWRAP_DEW_CIPHER_KEY_SEL] =    0x0418,
1868c2ecf20Sopenharmony_ci	[PWRAP_DEW_CIPHER_IV_SEL] =     0x041A,
1878c2ecf20Sopenharmony_ci	[PWRAP_DEW_CIPHER_EN] =         0x041C,
1888c2ecf20Sopenharmony_ci	[PWRAP_DEW_CIPHER_RDY] =        0x041E,
1898c2ecf20Sopenharmony_ci	[PWRAP_DEW_CIPHER_MODE] =       0x0420,
1908c2ecf20Sopenharmony_ci	[PWRAP_DEW_CIPHER_SWRST] =      0x0422,
1918c2ecf20Sopenharmony_ci	[PWRAP_DEW_RDDMY_NO] =          0x0424,
1928c2ecf20Sopenharmony_ci};
1938c2ecf20Sopenharmony_ci
1948c2ecf20Sopenharmony_cistatic const u32 mt6358_regs[] = {
1958c2ecf20Sopenharmony_ci	[PWRAP_SMT_CON1] =		0x0030,
1968c2ecf20Sopenharmony_ci	[PWRAP_DRV_CON1] =		0x0038,
1978c2ecf20Sopenharmony_ci	[PWRAP_FILTER_CON0] =		0x0040,
1988c2ecf20Sopenharmony_ci	[PWRAP_GPIO_PULLEN0_CLR] =	0x0098,
1998c2ecf20Sopenharmony_ci	[PWRAP_RG_SPI_CON0] =		0x0408,
2008c2ecf20Sopenharmony_ci	[PWRAP_RG_SPI_RECORD0] =	0x040a,
2018c2ecf20Sopenharmony_ci	[PWRAP_DEW_DIO_EN] =		0x040c,
2028c2ecf20Sopenharmony_ci	[PWRAP_DEW_READ_TEST]	=	0x040e,
2038c2ecf20Sopenharmony_ci	[PWRAP_DEW_WRITE_TEST]	=	0x0410,
2048c2ecf20Sopenharmony_ci	[PWRAP_DEW_CRC_EN] =		0x0414,
2058c2ecf20Sopenharmony_ci	[PWRAP_DEW_CIPHER_KEY_SEL] =	0x041a,
2068c2ecf20Sopenharmony_ci	[PWRAP_DEW_CIPHER_IV_SEL] =	0x041c,
2078c2ecf20Sopenharmony_ci	[PWRAP_DEW_CIPHER_EN]	=	0x041e,
2088c2ecf20Sopenharmony_ci	[PWRAP_DEW_CIPHER_RDY] =	0x0420,
2098c2ecf20Sopenharmony_ci	[PWRAP_DEW_CIPHER_MODE] =	0x0422,
2108c2ecf20Sopenharmony_ci	[PWRAP_DEW_CIPHER_SWRST] =	0x0424,
2118c2ecf20Sopenharmony_ci	[PWRAP_RG_SPI_CON2] =		0x0432,
2128c2ecf20Sopenharmony_ci	[PWRAP_RG_SPI_CON3] =		0x0434,
2138c2ecf20Sopenharmony_ci	[PWRAP_RG_SPI_CON4] =		0x0436,
2148c2ecf20Sopenharmony_ci	[PWRAP_RG_SPI_CON5] =		0x0438,
2158c2ecf20Sopenharmony_ci	[PWRAP_RG_SPI_CON6] =		0x043a,
2168c2ecf20Sopenharmony_ci	[PWRAP_RG_SPI_CON7] =		0x043c,
2178c2ecf20Sopenharmony_ci	[PWRAP_RG_SPI_CON8] =		0x043e,
2188c2ecf20Sopenharmony_ci	[PWRAP_RG_SPI_CON13] =		0x0448,
2198c2ecf20Sopenharmony_ci	[PWRAP_SPISLV_KEY] =		0x044a,
2208c2ecf20Sopenharmony_ci};
2218c2ecf20Sopenharmony_ci
2228c2ecf20Sopenharmony_cistatic const u32 mt6359_regs[] = {
2238c2ecf20Sopenharmony_ci	[PWRAP_DEW_RG_EN_RECORD] =	0x040a,
2248c2ecf20Sopenharmony_ci	[PWRAP_DEW_DIO_EN] =		0x040c,
2258c2ecf20Sopenharmony_ci	[PWRAP_DEW_READ_TEST] =		0x040e,
2268c2ecf20Sopenharmony_ci	[PWRAP_DEW_WRITE_TEST] =	0x0410,
2278c2ecf20Sopenharmony_ci	[PWRAP_DEW_CRC_SWRST] =		0x0412,
2288c2ecf20Sopenharmony_ci	[PWRAP_DEW_CRC_EN] =		0x0414,
2298c2ecf20Sopenharmony_ci	[PWRAP_DEW_CRC_VAL] =		0x0416,
2308c2ecf20Sopenharmony_ci	[PWRAP_DEW_CIPHER_KEY_SEL] =	0x0418,
2318c2ecf20Sopenharmony_ci	[PWRAP_DEW_CIPHER_IV_SEL] =	0x041a,
2328c2ecf20Sopenharmony_ci	[PWRAP_DEW_CIPHER_EN] =		0x041c,
2338c2ecf20Sopenharmony_ci	[PWRAP_DEW_CIPHER_RDY] =	0x041e,
2348c2ecf20Sopenharmony_ci	[PWRAP_DEW_CIPHER_MODE] =	0x0420,
2358c2ecf20Sopenharmony_ci	[PWRAP_DEW_CIPHER_SWRST] =	0x0422,
2368c2ecf20Sopenharmony_ci	[PWRAP_DEW_RDDMY_NO] =		0x0424,
2378c2ecf20Sopenharmony_ci	[PWRAP_DEW_RECORD_CMD0] =	0x0428,
2388c2ecf20Sopenharmony_ci	[PWRAP_DEW_RECORD_CMD1] =	0x042a,
2398c2ecf20Sopenharmony_ci	[PWRAP_DEW_RECORD_CMD2] =	0x042c,
2408c2ecf20Sopenharmony_ci	[PWRAP_DEW_RECORD_CMD3] =	0x042e,
2418c2ecf20Sopenharmony_ci	[PWRAP_DEW_RECORD_CMD4] =	0x0430,
2428c2ecf20Sopenharmony_ci	[PWRAP_DEW_RECORD_CMD5] =	0x0432,
2438c2ecf20Sopenharmony_ci	[PWRAP_DEW_RECORD_WDATA0] =	0x0434,
2448c2ecf20Sopenharmony_ci	[PWRAP_DEW_RECORD_WDATA1] =	0x0436,
2458c2ecf20Sopenharmony_ci	[PWRAP_DEW_RECORD_WDATA2] =	0x0438,
2468c2ecf20Sopenharmony_ci	[PWRAP_DEW_RECORD_WDATA3] =	0x043a,
2478c2ecf20Sopenharmony_ci	[PWRAP_DEW_RECORD_WDATA4] =	0x043c,
2488c2ecf20Sopenharmony_ci	[PWRAP_DEW_RECORD_WDATA5] =	0x043e,
2498c2ecf20Sopenharmony_ci	[PWRAP_DEW_RG_ADDR_TARGET] =	0x0440,
2508c2ecf20Sopenharmony_ci	[PWRAP_DEW_RG_ADDR_MASK] =	0x0442,
2518c2ecf20Sopenharmony_ci	[PWRAP_DEW_RG_WDATA_TARGET] =	0x0444,
2528c2ecf20Sopenharmony_ci	[PWRAP_DEW_RG_WDATA_MASK] =	0x0446,
2538c2ecf20Sopenharmony_ci	[PWRAP_DEW_RG_SPI_RECORD_CLR] =	0x0448,
2548c2ecf20Sopenharmony_ci	[PWRAP_DEW_RG_CMD_ALERT_CLR] =	0x0448,
2558c2ecf20Sopenharmony_ci	[PWRAP_SPISLV_KEY] =		0x044a,
2568c2ecf20Sopenharmony_ci};
2578c2ecf20Sopenharmony_ci
2588c2ecf20Sopenharmony_cistatic const u32 mt6397_regs[] = {
2598c2ecf20Sopenharmony_ci	[PWRAP_DEW_BASE] =		0xbc00,
2608c2ecf20Sopenharmony_ci	[PWRAP_DEW_EVENT_OUT_EN] =	0xbc00,
2618c2ecf20Sopenharmony_ci	[PWRAP_DEW_DIO_EN] =		0xbc02,
2628c2ecf20Sopenharmony_ci	[PWRAP_DEW_EVENT_SRC_EN] =	0xbc04,
2638c2ecf20Sopenharmony_ci	[PWRAP_DEW_EVENT_SRC] =		0xbc06,
2648c2ecf20Sopenharmony_ci	[PWRAP_DEW_EVENT_FLAG] =	0xbc08,
2658c2ecf20Sopenharmony_ci	[PWRAP_DEW_READ_TEST] =		0xbc0a,
2668c2ecf20Sopenharmony_ci	[PWRAP_DEW_WRITE_TEST] =	0xbc0c,
2678c2ecf20Sopenharmony_ci	[PWRAP_DEW_CRC_EN] =		0xbc0e,
2688c2ecf20Sopenharmony_ci	[PWRAP_DEW_CRC_VAL] =		0xbc10,
2698c2ecf20Sopenharmony_ci	[PWRAP_DEW_MON_GRP_SEL] =	0xbc12,
2708c2ecf20Sopenharmony_ci	[PWRAP_DEW_MON_FLAG_SEL] =	0xbc14,
2718c2ecf20Sopenharmony_ci	[PWRAP_DEW_EVENT_TEST] =	0xbc16,
2728c2ecf20Sopenharmony_ci	[PWRAP_DEW_CIPHER_KEY_SEL] =	0xbc18,
2738c2ecf20Sopenharmony_ci	[PWRAP_DEW_CIPHER_IV_SEL] =	0xbc1a,
2748c2ecf20Sopenharmony_ci	[PWRAP_DEW_CIPHER_LOAD] =	0xbc1c,
2758c2ecf20Sopenharmony_ci	[PWRAP_DEW_CIPHER_START] =	0xbc1e,
2768c2ecf20Sopenharmony_ci	[PWRAP_DEW_CIPHER_RDY] =	0xbc20,
2778c2ecf20Sopenharmony_ci	[PWRAP_DEW_CIPHER_MODE] =	0xbc22,
2788c2ecf20Sopenharmony_ci	[PWRAP_DEW_CIPHER_SWRST] =	0xbc24,
2798c2ecf20Sopenharmony_ci};
2808c2ecf20Sopenharmony_ci
2818c2ecf20Sopenharmony_cienum pwrap_regs {
2828c2ecf20Sopenharmony_ci	PWRAP_MUX_SEL,
2838c2ecf20Sopenharmony_ci	PWRAP_WRAP_EN,
2848c2ecf20Sopenharmony_ci	PWRAP_DIO_EN,
2858c2ecf20Sopenharmony_ci	PWRAP_SIDLY,
2868c2ecf20Sopenharmony_ci	PWRAP_CSHEXT_WRITE,
2878c2ecf20Sopenharmony_ci	PWRAP_CSHEXT_READ,
2888c2ecf20Sopenharmony_ci	PWRAP_CSLEXT_START,
2898c2ecf20Sopenharmony_ci	PWRAP_CSLEXT_END,
2908c2ecf20Sopenharmony_ci	PWRAP_STAUPD_PRD,
2918c2ecf20Sopenharmony_ci	PWRAP_STAUPD_GRPEN,
2928c2ecf20Sopenharmony_ci	PWRAP_STAUPD_MAN_TRIG,
2938c2ecf20Sopenharmony_ci	PWRAP_STAUPD_STA,
2948c2ecf20Sopenharmony_ci	PWRAP_WRAP_STA,
2958c2ecf20Sopenharmony_ci	PWRAP_HARB_INIT,
2968c2ecf20Sopenharmony_ci	PWRAP_HARB_HPRIO,
2978c2ecf20Sopenharmony_ci	PWRAP_HIPRIO_ARB_EN,
2988c2ecf20Sopenharmony_ci	PWRAP_HARB_STA0,
2998c2ecf20Sopenharmony_ci	PWRAP_HARB_STA1,
3008c2ecf20Sopenharmony_ci	PWRAP_MAN_EN,
3018c2ecf20Sopenharmony_ci	PWRAP_MAN_CMD,
3028c2ecf20Sopenharmony_ci	PWRAP_MAN_RDATA,
3038c2ecf20Sopenharmony_ci	PWRAP_MAN_VLDCLR,
3048c2ecf20Sopenharmony_ci	PWRAP_WACS0_EN,
3058c2ecf20Sopenharmony_ci	PWRAP_INIT_DONE0,
3068c2ecf20Sopenharmony_ci	PWRAP_WACS0_CMD,
3078c2ecf20Sopenharmony_ci	PWRAP_WACS0_RDATA,
3088c2ecf20Sopenharmony_ci	PWRAP_WACS0_VLDCLR,
3098c2ecf20Sopenharmony_ci	PWRAP_WACS1_EN,
3108c2ecf20Sopenharmony_ci	PWRAP_INIT_DONE1,
3118c2ecf20Sopenharmony_ci	PWRAP_WACS1_CMD,
3128c2ecf20Sopenharmony_ci	PWRAP_WACS1_RDATA,
3138c2ecf20Sopenharmony_ci	PWRAP_WACS1_VLDCLR,
3148c2ecf20Sopenharmony_ci	PWRAP_WACS2_EN,
3158c2ecf20Sopenharmony_ci	PWRAP_INIT_DONE2,
3168c2ecf20Sopenharmony_ci	PWRAP_WACS2_CMD,
3178c2ecf20Sopenharmony_ci	PWRAP_WACS2_RDATA,
3188c2ecf20Sopenharmony_ci	PWRAP_WACS2_VLDCLR,
3198c2ecf20Sopenharmony_ci	PWRAP_INT_EN,
3208c2ecf20Sopenharmony_ci	PWRAP_INT_FLG_RAW,
3218c2ecf20Sopenharmony_ci	PWRAP_INT_FLG,
3228c2ecf20Sopenharmony_ci	PWRAP_INT_CLR,
3238c2ecf20Sopenharmony_ci	PWRAP_SIG_ADR,
3248c2ecf20Sopenharmony_ci	PWRAP_SIG_MODE,
3258c2ecf20Sopenharmony_ci	PWRAP_SIG_VALUE,
3268c2ecf20Sopenharmony_ci	PWRAP_SIG_ERRVAL,
3278c2ecf20Sopenharmony_ci	PWRAP_CRC_EN,
3288c2ecf20Sopenharmony_ci	PWRAP_TIMER_EN,
3298c2ecf20Sopenharmony_ci	PWRAP_TIMER_STA,
3308c2ecf20Sopenharmony_ci	PWRAP_WDT_UNIT,
3318c2ecf20Sopenharmony_ci	PWRAP_WDT_SRC_EN,
3328c2ecf20Sopenharmony_ci	PWRAP_WDT_FLG,
3338c2ecf20Sopenharmony_ci	PWRAP_DEBUG_INT_SEL,
3348c2ecf20Sopenharmony_ci	PWRAP_CIPHER_KEY_SEL,
3358c2ecf20Sopenharmony_ci	PWRAP_CIPHER_IV_SEL,
3368c2ecf20Sopenharmony_ci	PWRAP_CIPHER_RDY,
3378c2ecf20Sopenharmony_ci	PWRAP_CIPHER_MODE,
3388c2ecf20Sopenharmony_ci	PWRAP_CIPHER_SWRST,
3398c2ecf20Sopenharmony_ci	PWRAP_DCM_EN,
3408c2ecf20Sopenharmony_ci	PWRAP_DCM_DBC_PRD,
3418c2ecf20Sopenharmony_ci	PWRAP_EINT_STA0_ADR,
3428c2ecf20Sopenharmony_ci	PWRAP_EINT_STA1_ADR,
3438c2ecf20Sopenharmony_ci
3448c2ecf20Sopenharmony_ci	/* MT2701 only regs */
3458c2ecf20Sopenharmony_ci	PWRAP_ADC_CMD_ADDR,
3468c2ecf20Sopenharmony_ci	PWRAP_PWRAP_ADC_CMD,
3478c2ecf20Sopenharmony_ci	PWRAP_ADC_RDY_ADDR,
3488c2ecf20Sopenharmony_ci	PWRAP_ADC_RDATA_ADDR1,
3498c2ecf20Sopenharmony_ci	PWRAP_ADC_RDATA_ADDR2,
3508c2ecf20Sopenharmony_ci
3518c2ecf20Sopenharmony_ci	/* MT7622 only regs */
3528c2ecf20Sopenharmony_ci	PWRAP_STA,
3538c2ecf20Sopenharmony_ci	PWRAP_CLR,
3548c2ecf20Sopenharmony_ci	PWRAP_DVFS_ADR8,
3558c2ecf20Sopenharmony_ci	PWRAP_DVFS_WDATA8,
3568c2ecf20Sopenharmony_ci	PWRAP_DVFS_ADR9,
3578c2ecf20Sopenharmony_ci	PWRAP_DVFS_WDATA9,
3588c2ecf20Sopenharmony_ci	PWRAP_DVFS_ADR10,
3598c2ecf20Sopenharmony_ci	PWRAP_DVFS_WDATA10,
3608c2ecf20Sopenharmony_ci	PWRAP_DVFS_ADR11,
3618c2ecf20Sopenharmony_ci	PWRAP_DVFS_WDATA11,
3628c2ecf20Sopenharmony_ci	PWRAP_DVFS_ADR12,
3638c2ecf20Sopenharmony_ci	PWRAP_DVFS_WDATA12,
3648c2ecf20Sopenharmony_ci	PWRAP_DVFS_ADR13,
3658c2ecf20Sopenharmony_ci	PWRAP_DVFS_WDATA13,
3668c2ecf20Sopenharmony_ci	PWRAP_DVFS_ADR14,
3678c2ecf20Sopenharmony_ci	PWRAP_DVFS_WDATA14,
3688c2ecf20Sopenharmony_ci	PWRAP_DVFS_ADR15,
3698c2ecf20Sopenharmony_ci	PWRAP_DVFS_WDATA15,
3708c2ecf20Sopenharmony_ci	PWRAP_EXT_CK,
3718c2ecf20Sopenharmony_ci	PWRAP_ADC_RDATA_ADDR,
3728c2ecf20Sopenharmony_ci	PWRAP_GPS_STA,
3738c2ecf20Sopenharmony_ci	PWRAP_SW_RST,
3748c2ecf20Sopenharmony_ci	PWRAP_DVFS_STEP_CTRL0,
3758c2ecf20Sopenharmony_ci	PWRAP_DVFS_STEP_CTRL1,
3768c2ecf20Sopenharmony_ci	PWRAP_DVFS_STEP_CTRL2,
3778c2ecf20Sopenharmony_ci	PWRAP_SPI2_CTRL,
3788c2ecf20Sopenharmony_ci
3798c2ecf20Sopenharmony_ci	/* MT8135 only regs */
3808c2ecf20Sopenharmony_ci	PWRAP_CSHEXT,
3818c2ecf20Sopenharmony_ci	PWRAP_EVENT_IN_EN,
3828c2ecf20Sopenharmony_ci	PWRAP_EVENT_DST_EN,
3838c2ecf20Sopenharmony_ci	PWRAP_RRARB_INIT,
3848c2ecf20Sopenharmony_ci	PWRAP_RRARB_EN,
3858c2ecf20Sopenharmony_ci	PWRAP_RRARB_STA0,
3868c2ecf20Sopenharmony_ci	PWRAP_RRARB_STA1,
3878c2ecf20Sopenharmony_ci	PWRAP_EVENT_STA,
3888c2ecf20Sopenharmony_ci	PWRAP_EVENT_STACLR,
3898c2ecf20Sopenharmony_ci	PWRAP_CIPHER_LOAD,
3908c2ecf20Sopenharmony_ci	PWRAP_CIPHER_START,
3918c2ecf20Sopenharmony_ci
3928c2ecf20Sopenharmony_ci	/* MT8173 only regs */
3938c2ecf20Sopenharmony_ci	PWRAP_RDDMY,
3948c2ecf20Sopenharmony_ci	PWRAP_SI_CK_CON,
3958c2ecf20Sopenharmony_ci	PWRAP_DVFS_ADR0,
3968c2ecf20Sopenharmony_ci	PWRAP_DVFS_WDATA0,
3978c2ecf20Sopenharmony_ci	PWRAP_DVFS_ADR1,
3988c2ecf20Sopenharmony_ci	PWRAP_DVFS_WDATA1,
3998c2ecf20Sopenharmony_ci	PWRAP_DVFS_ADR2,
4008c2ecf20Sopenharmony_ci	PWRAP_DVFS_WDATA2,
4018c2ecf20Sopenharmony_ci	PWRAP_DVFS_ADR3,
4028c2ecf20Sopenharmony_ci	PWRAP_DVFS_WDATA3,
4038c2ecf20Sopenharmony_ci	PWRAP_DVFS_ADR4,
4048c2ecf20Sopenharmony_ci	PWRAP_DVFS_WDATA4,
4058c2ecf20Sopenharmony_ci	PWRAP_DVFS_ADR5,
4068c2ecf20Sopenharmony_ci	PWRAP_DVFS_WDATA5,
4078c2ecf20Sopenharmony_ci	PWRAP_DVFS_ADR6,
4088c2ecf20Sopenharmony_ci	PWRAP_DVFS_WDATA6,
4098c2ecf20Sopenharmony_ci	PWRAP_DVFS_ADR7,
4108c2ecf20Sopenharmony_ci	PWRAP_DVFS_WDATA7,
4118c2ecf20Sopenharmony_ci	PWRAP_SPMINF_STA,
4128c2ecf20Sopenharmony_ci	PWRAP_CIPHER_EN,
4138c2ecf20Sopenharmony_ci
4148c2ecf20Sopenharmony_ci	/* MT8183 only regs */
4158c2ecf20Sopenharmony_ci	PWRAP_SI_SAMPLE_CTRL,
4168c2ecf20Sopenharmony_ci	PWRAP_CSLEXT_WRITE,
4178c2ecf20Sopenharmony_ci	PWRAP_CSLEXT_READ,
4188c2ecf20Sopenharmony_ci	PWRAP_EXT_CK_WRITE,
4198c2ecf20Sopenharmony_ci	PWRAP_STAUPD_CTRL,
4208c2ecf20Sopenharmony_ci	PWRAP_WACS_P2P_EN,
4218c2ecf20Sopenharmony_ci	PWRAP_INIT_DONE_P2P,
4228c2ecf20Sopenharmony_ci	PWRAP_WACS_MD32_EN,
4238c2ecf20Sopenharmony_ci	PWRAP_INIT_DONE_MD32,
4248c2ecf20Sopenharmony_ci	PWRAP_INT1_EN,
4258c2ecf20Sopenharmony_ci	PWRAP_INT1_FLG,
4268c2ecf20Sopenharmony_ci	PWRAP_INT1_CLR,
4278c2ecf20Sopenharmony_ci	PWRAP_WDT_SRC_EN_1,
4288c2ecf20Sopenharmony_ci	PWRAP_INT_GPS_AUXADC_CMD_ADDR,
4298c2ecf20Sopenharmony_ci	PWRAP_INT_GPS_AUXADC_CMD,
4308c2ecf20Sopenharmony_ci	PWRAP_INT_GPS_AUXADC_RDATA_ADDR,
4318c2ecf20Sopenharmony_ci	PWRAP_EXT_GPS_AUXADC_RDATA_ADDR,
4328c2ecf20Sopenharmony_ci	PWRAP_GPSINF_0_STA,
4338c2ecf20Sopenharmony_ci	PWRAP_GPSINF_1_STA,
4348c2ecf20Sopenharmony_ci
4358c2ecf20Sopenharmony_ci	/* MT8516 only regs */
4368c2ecf20Sopenharmony_ci	PWRAP_OP_TYPE,
4378c2ecf20Sopenharmony_ci	PWRAP_MSB_FIRST,
4388c2ecf20Sopenharmony_ci};
4398c2ecf20Sopenharmony_ci
4408c2ecf20Sopenharmony_cistatic int mt2701_regs[] = {
4418c2ecf20Sopenharmony_ci	[PWRAP_MUX_SEL] =		0x0,
4428c2ecf20Sopenharmony_ci	[PWRAP_WRAP_EN] =		0x4,
4438c2ecf20Sopenharmony_ci	[PWRAP_DIO_EN] =		0x8,
4448c2ecf20Sopenharmony_ci	[PWRAP_SIDLY] =			0xc,
4458c2ecf20Sopenharmony_ci	[PWRAP_RDDMY] =			0x18,
4468c2ecf20Sopenharmony_ci	[PWRAP_SI_CK_CON] =		0x1c,
4478c2ecf20Sopenharmony_ci	[PWRAP_CSHEXT_WRITE] =		0x20,
4488c2ecf20Sopenharmony_ci	[PWRAP_CSHEXT_READ] =		0x24,
4498c2ecf20Sopenharmony_ci	[PWRAP_CSLEXT_START] =		0x28,
4508c2ecf20Sopenharmony_ci	[PWRAP_CSLEXT_END] =		0x2c,
4518c2ecf20Sopenharmony_ci	[PWRAP_STAUPD_PRD] =		0x30,
4528c2ecf20Sopenharmony_ci	[PWRAP_STAUPD_GRPEN] =		0x34,
4538c2ecf20Sopenharmony_ci	[PWRAP_STAUPD_MAN_TRIG] =	0x38,
4548c2ecf20Sopenharmony_ci	[PWRAP_STAUPD_STA] =		0x3c,
4558c2ecf20Sopenharmony_ci	[PWRAP_WRAP_STA] =		0x44,
4568c2ecf20Sopenharmony_ci	[PWRAP_HARB_INIT] =		0x48,
4578c2ecf20Sopenharmony_ci	[PWRAP_HARB_HPRIO] =		0x4c,
4588c2ecf20Sopenharmony_ci	[PWRAP_HIPRIO_ARB_EN] =		0x50,
4598c2ecf20Sopenharmony_ci	[PWRAP_HARB_STA0] =		0x54,
4608c2ecf20Sopenharmony_ci	[PWRAP_HARB_STA1] =		0x58,
4618c2ecf20Sopenharmony_ci	[PWRAP_MAN_EN] =		0x5c,
4628c2ecf20Sopenharmony_ci	[PWRAP_MAN_CMD] =		0x60,
4638c2ecf20Sopenharmony_ci	[PWRAP_MAN_RDATA] =		0x64,
4648c2ecf20Sopenharmony_ci	[PWRAP_MAN_VLDCLR] =		0x68,
4658c2ecf20Sopenharmony_ci	[PWRAP_WACS0_EN] =		0x6c,
4668c2ecf20Sopenharmony_ci	[PWRAP_INIT_DONE0] =		0x70,
4678c2ecf20Sopenharmony_ci	[PWRAP_WACS0_CMD] =		0x74,
4688c2ecf20Sopenharmony_ci	[PWRAP_WACS0_RDATA] =		0x78,
4698c2ecf20Sopenharmony_ci	[PWRAP_WACS0_VLDCLR] =		0x7c,
4708c2ecf20Sopenharmony_ci	[PWRAP_WACS1_EN] =		0x80,
4718c2ecf20Sopenharmony_ci	[PWRAP_INIT_DONE1] =		0x84,
4728c2ecf20Sopenharmony_ci	[PWRAP_WACS1_CMD] =		0x88,
4738c2ecf20Sopenharmony_ci	[PWRAP_WACS1_RDATA] =		0x8c,
4748c2ecf20Sopenharmony_ci	[PWRAP_WACS1_VLDCLR] =		0x90,
4758c2ecf20Sopenharmony_ci	[PWRAP_WACS2_EN] =		0x94,
4768c2ecf20Sopenharmony_ci	[PWRAP_INIT_DONE2] =		0x98,
4778c2ecf20Sopenharmony_ci	[PWRAP_WACS2_CMD] =		0x9c,
4788c2ecf20Sopenharmony_ci	[PWRAP_WACS2_RDATA] =		0xa0,
4798c2ecf20Sopenharmony_ci	[PWRAP_WACS2_VLDCLR] =		0xa4,
4808c2ecf20Sopenharmony_ci	[PWRAP_INT_EN] =		0xa8,
4818c2ecf20Sopenharmony_ci	[PWRAP_INT_FLG_RAW] =		0xac,
4828c2ecf20Sopenharmony_ci	[PWRAP_INT_FLG] =		0xb0,
4838c2ecf20Sopenharmony_ci	[PWRAP_INT_CLR] =		0xb4,
4848c2ecf20Sopenharmony_ci	[PWRAP_SIG_ADR] =		0xb8,
4858c2ecf20Sopenharmony_ci	[PWRAP_SIG_MODE] =		0xbc,
4868c2ecf20Sopenharmony_ci	[PWRAP_SIG_VALUE] =		0xc0,
4878c2ecf20Sopenharmony_ci	[PWRAP_SIG_ERRVAL] =		0xc4,
4888c2ecf20Sopenharmony_ci	[PWRAP_CRC_EN] =		0xc8,
4898c2ecf20Sopenharmony_ci	[PWRAP_TIMER_EN] =		0xcc,
4908c2ecf20Sopenharmony_ci	[PWRAP_TIMER_STA] =		0xd0,
4918c2ecf20Sopenharmony_ci	[PWRAP_WDT_UNIT] =		0xd4,
4928c2ecf20Sopenharmony_ci	[PWRAP_WDT_SRC_EN] =		0xd8,
4938c2ecf20Sopenharmony_ci	[PWRAP_WDT_FLG] =		0xdc,
4948c2ecf20Sopenharmony_ci	[PWRAP_DEBUG_INT_SEL] =		0xe0,
4958c2ecf20Sopenharmony_ci	[PWRAP_DVFS_ADR0] =		0xe4,
4968c2ecf20Sopenharmony_ci	[PWRAP_DVFS_WDATA0] =		0xe8,
4978c2ecf20Sopenharmony_ci	[PWRAP_DVFS_ADR1] =		0xec,
4988c2ecf20Sopenharmony_ci	[PWRAP_DVFS_WDATA1] =		0xf0,
4998c2ecf20Sopenharmony_ci	[PWRAP_DVFS_ADR2] =		0xf4,
5008c2ecf20Sopenharmony_ci	[PWRAP_DVFS_WDATA2] =		0xf8,
5018c2ecf20Sopenharmony_ci	[PWRAP_DVFS_ADR3] =		0xfc,
5028c2ecf20Sopenharmony_ci	[PWRAP_DVFS_WDATA3] =		0x100,
5038c2ecf20Sopenharmony_ci	[PWRAP_DVFS_ADR4] =		0x104,
5048c2ecf20Sopenharmony_ci	[PWRAP_DVFS_WDATA4] =		0x108,
5058c2ecf20Sopenharmony_ci	[PWRAP_DVFS_ADR5] =		0x10c,
5068c2ecf20Sopenharmony_ci	[PWRAP_DVFS_WDATA5] =		0x110,
5078c2ecf20Sopenharmony_ci	[PWRAP_DVFS_ADR6] =		0x114,
5088c2ecf20Sopenharmony_ci	[PWRAP_DVFS_WDATA6] =		0x118,
5098c2ecf20Sopenharmony_ci	[PWRAP_DVFS_ADR7] =		0x11c,
5108c2ecf20Sopenharmony_ci	[PWRAP_DVFS_WDATA7] =		0x120,
5118c2ecf20Sopenharmony_ci	[PWRAP_CIPHER_KEY_SEL] =	0x124,
5128c2ecf20Sopenharmony_ci	[PWRAP_CIPHER_IV_SEL] =		0x128,
5138c2ecf20Sopenharmony_ci	[PWRAP_CIPHER_EN] =		0x12c,
5148c2ecf20Sopenharmony_ci	[PWRAP_CIPHER_RDY] =		0x130,
5158c2ecf20Sopenharmony_ci	[PWRAP_CIPHER_MODE] =		0x134,
5168c2ecf20Sopenharmony_ci	[PWRAP_CIPHER_SWRST] =		0x138,
5178c2ecf20Sopenharmony_ci	[PWRAP_DCM_EN] =		0x13c,
5188c2ecf20Sopenharmony_ci	[PWRAP_DCM_DBC_PRD] =		0x140,
5198c2ecf20Sopenharmony_ci	[PWRAP_ADC_CMD_ADDR] =		0x144,
5208c2ecf20Sopenharmony_ci	[PWRAP_PWRAP_ADC_CMD] =		0x148,
5218c2ecf20Sopenharmony_ci	[PWRAP_ADC_RDY_ADDR] =		0x14c,
5228c2ecf20Sopenharmony_ci	[PWRAP_ADC_RDATA_ADDR1] =	0x150,
5238c2ecf20Sopenharmony_ci	[PWRAP_ADC_RDATA_ADDR2] =	0x154,
5248c2ecf20Sopenharmony_ci};
5258c2ecf20Sopenharmony_ci
5268c2ecf20Sopenharmony_cistatic int mt6765_regs[] = {
5278c2ecf20Sopenharmony_ci	[PWRAP_MUX_SEL] =		0x0,
5288c2ecf20Sopenharmony_ci	[PWRAP_WRAP_EN] =		0x4,
5298c2ecf20Sopenharmony_ci	[PWRAP_DIO_EN] =		0x8,
5308c2ecf20Sopenharmony_ci	[PWRAP_RDDMY] =			0x20,
5318c2ecf20Sopenharmony_ci	[PWRAP_CSHEXT_WRITE] =		0x24,
5328c2ecf20Sopenharmony_ci	[PWRAP_CSHEXT_READ] =		0x28,
5338c2ecf20Sopenharmony_ci	[PWRAP_CSLEXT_START] =		0x2C,
5348c2ecf20Sopenharmony_ci	[PWRAP_CSLEXT_END] =		0x30,
5358c2ecf20Sopenharmony_ci	[PWRAP_STAUPD_PRD] =		0x3C,
5368c2ecf20Sopenharmony_ci	[PWRAP_HARB_HPRIO] =		0x68,
5378c2ecf20Sopenharmony_ci	[PWRAP_HIPRIO_ARB_EN] =		0x6C,
5388c2ecf20Sopenharmony_ci	[PWRAP_MAN_EN] =		0x7C,
5398c2ecf20Sopenharmony_ci	[PWRAP_MAN_CMD] =		0x80,
5408c2ecf20Sopenharmony_ci	[PWRAP_WACS0_EN] =		0x8C,
5418c2ecf20Sopenharmony_ci	[PWRAP_WACS1_EN] =		0x94,
5428c2ecf20Sopenharmony_ci	[PWRAP_WACS2_EN] =		0x9C,
5438c2ecf20Sopenharmony_ci	[PWRAP_INIT_DONE2] =		0xA0,
5448c2ecf20Sopenharmony_ci	[PWRAP_WACS2_CMD] =		0xC20,
5458c2ecf20Sopenharmony_ci	[PWRAP_WACS2_RDATA] =		0xC24,
5468c2ecf20Sopenharmony_ci	[PWRAP_WACS2_VLDCLR] =		0xC28,
5478c2ecf20Sopenharmony_ci	[PWRAP_INT_EN] =		0xB4,
5488c2ecf20Sopenharmony_ci	[PWRAP_INT_FLG_RAW] =		0xB8,
5498c2ecf20Sopenharmony_ci	[PWRAP_INT_FLG] =		0xBC,
5508c2ecf20Sopenharmony_ci	[PWRAP_INT_CLR] =		0xC0,
5518c2ecf20Sopenharmony_ci	[PWRAP_TIMER_EN] =		0xE8,
5528c2ecf20Sopenharmony_ci	[PWRAP_WDT_UNIT] =		0xF0,
5538c2ecf20Sopenharmony_ci	[PWRAP_WDT_SRC_EN] =		0xF4,
5548c2ecf20Sopenharmony_ci	[PWRAP_DCM_EN] =		0x1DC,
5558c2ecf20Sopenharmony_ci	[PWRAP_DCM_DBC_PRD] =		0x1E0,
5568c2ecf20Sopenharmony_ci};
5578c2ecf20Sopenharmony_ci
5588c2ecf20Sopenharmony_cistatic int mt6779_regs[] = {
5598c2ecf20Sopenharmony_ci	[PWRAP_MUX_SEL] =		0x0,
5608c2ecf20Sopenharmony_ci	[PWRAP_WRAP_EN] =		0x4,
5618c2ecf20Sopenharmony_ci	[PWRAP_DIO_EN] =		0x8,
5628c2ecf20Sopenharmony_ci	[PWRAP_RDDMY] =			0x20,
5638c2ecf20Sopenharmony_ci	[PWRAP_CSHEXT_WRITE] =		0x24,
5648c2ecf20Sopenharmony_ci	[PWRAP_CSHEXT_READ] =		0x28,
5658c2ecf20Sopenharmony_ci	[PWRAP_CSLEXT_WRITE] =		0x2C,
5668c2ecf20Sopenharmony_ci	[PWRAP_CSLEXT_READ] =		0x30,
5678c2ecf20Sopenharmony_ci	[PWRAP_EXT_CK_WRITE] =		0x34,
5688c2ecf20Sopenharmony_ci	[PWRAP_STAUPD_CTRL] =		0x3C,
5698c2ecf20Sopenharmony_ci	[PWRAP_STAUPD_GRPEN] =		0x40,
5708c2ecf20Sopenharmony_ci	[PWRAP_EINT_STA0_ADR] =		0x44,
5718c2ecf20Sopenharmony_ci	[PWRAP_HARB_HPRIO] =		0x68,
5728c2ecf20Sopenharmony_ci	[PWRAP_HIPRIO_ARB_EN] =		0x6C,
5738c2ecf20Sopenharmony_ci	[PWRAP_MAN_EN] =		0x7C,
5748c2ecf20Sopenharmony_ci	[PWRAP_MAN_CMD] =		0x80,
5758c2ecf20Sopenharmony_ci	[PWRAP_WACS0_EN] =		0x8C,
5768c2ecf20Sopenharmony_ci	[PWRAP_INIT_DONE0] =		0x90,
5778c2ecf20Sopenharmony_ci	[PWRAP_WACS1_EN] =		0x94,
5788c2ecf20Sopenharmony_ci	[PWRAP_WACS2_EN] =		0x9C,
5798c2ecf20Sopenharmony_ci	[PWRAP_INIT_DONE1] =		0x98,
5808c2ecf20Sopenharmony_ci	[PWRAP_INIT_DONE2] =		0xA0,
5818c2ecf20Sopenharmony_ci	[PWRAP_INT_EN] =		0xBC,
5828c2ecf20Sopenharmony_ci	[PWRAP_INT_FLG_RAW] =		0xC0,
5838c2ecf20Sopenharmony_ci	[PWRAP_INT_FLG] =		0xC4,
5848c2ecf20Sopenharmony_ci	[PWRAP_INT_CLR] =		0xC8,
5858c2ecf20Sopenharmony_ci	[PWRAP_INT1_EN] =		0xCC,
5868c2ecf20Sopenharmony_ci	[PWRAP_INT1_FLG] =		0xD4,
5878c2ecf20Sopenharmony_ci	[PWRAP_INT1_CLR] =		0xD8,
5888c2ecf20Sopenharmony_ci	[PWRAP_TIMER_EN] =		0xF0,
5898c2ecf20Sopenharmony_ci	[PWRAP_WDT_UNIT] =		0xF8,
5908c2ecf20Sopenharmony_ci	[PWRAP_WDT_SRC_EN] =		0xFC,
5918c2ecf20Sopenharmony_ci	[PWRAP_WDT_SRC_EN_1] =		0x100,
5928c2ecf20Sopenharmony_ci	[PWRAP_WACS2_CMD] =		0xC20,
5938c2ecf20Sopenharmony_ci	[PWRAP_WACS2_RDATA] =		0xC24,
5948c2ecf20Sopenharmony_ci	[PWRAP_WACS2_VLDCLR] =		0xC28,
5958c2ecf20Sopenharmony_ci};
5968c2ecf20Sopenharmony_ci
5978c2ecf20Sopenharmony_cistatic int mt6797_regs[] = {
5988c2ecf20Sopenharmony_ci	[PWRAP_MUX_SEL] =		0x0,
5998c2ecf20Sopenharmony_ci	[PWRAP_WRAP_EN] =		0x4,
6008c2ecf20Sopenharmony_ci	[PWRAP_DIO_EN] =		0x8,
6018c2ecf20Sopenharmony_ci	[PWRAP_SIDLY] =			0xC,
6028c2ecf20Sopenharmony_ci	[PWRAP_RDDMY] =			0x10,
6038c2ecf20Sopenharmony_ci	[PWRAP_CSHEXT_WRITE] =		0x18,
6048c2ecf20Sopenharmony_ci	[PWRAP_CSHEXT_READ] =		0x1C,
6058c2ecf20Sopenharmony_ci	[PWRAP_CSLEXT_START] =		0x20,
6068c2ecf20Sopenharmony_ci	[PWRAP_CSLEXT_END] =		0x24,
6078c2ecf20Sopenharmony_ci	[PWRAP_STAUPD_PRD] =		0x28,
6088c2ecf20Sopenharmony_ci	[PWRAP_HARB_HPRIO] =		0x50,
6098c2ecf20Sopenharmony_ci	[PWRAP_HIPRIO_ARB_EN] =		0x54,
6108c2ecf20Sopenharmony_ci	[PWRAP_MAN_EN] =		0x60,
6118c2ecf20Sopenharmony_ci	[PWRAP_MAN_CMD] =		0x64,
6128c2ecf20Sopenharmony_ci	[PWRAP_WACS0_EN] =		0x70,
6138c2ecf20Sopenharmony_ci	[PWRAP_WACS1_EN] =		0x84,
6148c2ecf20Sopenharmony_ci	[PWRAP_WACS2_EN] =		0x98,
6158c2ecf20Sopenharmony_ci	[PWRAP_INIT_DONE2] =		0x9C,
6168c2ecf20Sopenharmony_ci	[PWRAP_WACS2_CMD] =		0xA0,
6178c2ecf20Sopenharmony_ci	[PWRAP_WACS2_RDATA] =		0xA4,
6188c2ecf20Sopenharmony_ci	[PWRAP_WACS2_VLDCLR] =		0xA8,
6198c2ecf20Sopenharmony_ci	[PWRAP_INT_EN] =		0xC0,
6208c2ecf20Sopenharmony_ci	[PWRAP_INT_FLG_RAW] =		0xC4,
6218c2ecf20Sopenharmony_ci	[PWRAP_INT_FLG] =		0xC8,
6228c2ecf20Sopenharmony_ci	[PWRAP_INT_CLR] =		0xCC,
6238c2ecf20Sopenharmony_ci	[PWRAP_TIMER_EN] =		0xF4,
6248c2ecf20Sopenharmony_ci	[PWRAP_WDT_UNIT] =		0xFC,
6258c2ecf20Sopenharmony_ci	[PWRAP_WDT_SRC_EN] =		0x100,
6268c2ecf20Sopenharmony_ci	[PWRAP_DCM_EN] =		0x1CC,
6278c2ecf20Sopenharmony_ci	[PWRAP_DCM_DBC_PRD] =		0x1D4,
6288c2ecf20Sopenharmony_ci};
6298c2ecf20Sopenharmony_ci
6308c2ecf20Sopenharmony_cistatic int mt7622_regs[] = {
6318c2ecf20Sopenharmony_ci	[PWRAP_MUX_SEL] =		0x0,
6328c2ecf20Sopenharmony_ci	[PWRAP_WRAP_EN] =		0x4,
6338c2ecf20Sopenharmony_ci	[PWRAP_DIO_EN] =		0x8,
6348c2ecf20Sopenharmony_ci	[PWRAP_SIDLY] =			0xC,
6358c2ecf20Sopenharmony_ci	[PWRAP_RDDMY] =			0x10,
6368c2ecf20Sopenharmony_ci	[PWRAP_SI_CK_CON] =		0x14,
6378c2ecf20Sopenharmony_ci	[PWRAP_CSHEXT_WRITE] =		0x18,
6388c2ecf20Sopenharmony_ci	[PWRAP_CSHEXT_READ] =		0x1C,
6398c2ecf20Sopenharmony_ci	[PWRAP_CSLEXT_START] =		0x20,
6408c2ecf20Sopenharmony_ci	[PWRAP_CSLEXT_END] =		0x24,
6418c2ecf20Sopenharmony_ci	[PWRAP_STAUPD_PRD] =		0x28,
6428c2ecf20Sopenharmony_ci	[PWRAP_STAUPD_GRPEN] =		0x2C,
6438c2ecf20Sopenharmony_ci	[PWRAP_EINT_STA0_ADR] =		0x30,
6448c2ecf20Sopenharmony_ci	[PWRAP_EINT_STA1_ADR] =		0x34,
6458c2ecf20Sopenharmony_ci	[PWRAP_STA] =			0x38,
6468c2ecf20Sopenharmony_ci	[PWRAP_CLR] =			0x3C,
6478c2ecf20Sopenharmony_ci	[PWRAP_STAUPD_MAN_TRIG] =	0x40,
6488c2ecf20Sopenharmony_ci	[PWRAP_STAUPD_STA] =		0x44,
6498c2ecf20Sopenharmony_ci	[PWRAP_WRAP_STA] =		0x48,
6508c2ecf20Sopenharmony_ci	[PWRAP_HARB_INIT] =		0x4C,
6518c2ecf20Sopenharmony_ci	[PWRAP_HARB_HPRIO] =		0x50,
6528c2ecf20Sopenharmony_ci	[PWRAP_HIPRIO_ARB_EN] =		0x54,
6538c2ecf20Sopenharmony_ci	[PWRAP_HARB_STA0] =		0x58,
6548c2ecf20Sopenharmony_ci	[PWRAP_HARB_STA1] =		0x5C,
6558c2ecf20Sopenharmony_ci	[PWRAP_MAN_EN] =		0x60,
6568c2ecf20Sopenharmony_ci	[PWRAP_MAN_CMD] =		0x64,
6578c2ecf20Sopenharmony_ci	[PWRAP_MAN_RDATA] =		0x68,
6588c2ecf20Sopenharmony_ci	[PWRAP_MAN_VLDCLR] =		0x6C,
6598c2ecf20Sopenharmony_ci	[PWRAP_WACS0_EN] =		0x70,
6608c2ecf20Sopenharmony_ci	[PWRAP_INIT_DONE0] =		0x74,
6618c2ecf20Sopenharmony_ci	[PWRAP_WACS0_CMD] =		0x78,
6628c2ecf20Sopenharmony_ci	[PWRAP_WACS0_RDATA] =		0x7C,
6638c2ecf20Sopenharmony_ci	[PWRAP_WACS0_VLDCLR] =		0x80,
6648c2ecf20Sopenharmony_ci	[PWRAP_WACS1_EN] =		0x84,
6658c2ecf20Sopenharmony_ci	[PWRAP_INIT_DONE1] =		0x88,
6668c2ecf20Sopenharmony_ci	[PWRAP_WACS1_CMD] =		0x8C,
6678c2ecf20Sopenharmony_ci	[PWRAP_WACS1_RDATA] =		0x90,
6688c2ecf20Sopenharmony_ci	[PWRAP_WACS1_VLDCLR] =		0x94,
6698c2ecf20Sopenharmony_ci	[PWRAP_WACS2_EN] =		0x98,
6708c2ecf20Sopenharmony_ci	[PWRAP_INIT_DONE2] =		0x9C,
6718c2ecf20Sopenharmony_ci	[PWRAP_WACS2_CMD] =		0xA0,
6728c2ecf20Sopenharmony_ci	[PWRAP_WACS2_RDATA] =		0xA4,
6738c2ecf20Sopenharmony_ci	[PWRAP_WACS2_VLDCLR] =		0xA8,
6748c2ecf20Sopenharmony_ci	[PWRAP_INT_EN] =		0xAC,
6758c2ecf20Sopenharmony_ci	[PWRAP_INT_FLG_RAW] =		0xB0,
6768c2ecf20Sopenharmony_ci	[PWRAP_INT_FLG] =		0xB4,
6778c2ecf20Sopenharmony_ci	[PWRAP_INT_CLR] =		0xB8,
6788c2ecf20Sopenharmony_ci	[PWRAP_SIG_ADR] =		0xBC,
6798c2ecf20Sopenharmony_ci	[PWRAP_SIG_MODE] =		0xC0,
6808c2ecf20Sopenharmony_ci	[PWRAP_SIG_VALUE] =		0xC4,
6818c2ecf20Sopenharmony_ci	[PWRAP_SIG_ERRVAL] =		0xC8,
6828c2ecf20Sopenharmony_ci	[PWRAP_CRC_EN] =		0xCC,
6838c2ecf20Sopenharmony_ci	[PWRAP_TIMER_EN] =		0xD0,
6848c2ecf20Sopenharmony_ci	[PWRAP_TIMER_STA] =		0xD4,
6858c2ecf20Sopenharmony_ci	[PWRAP_WDT_UNIT] =		0xD8,
6868c2ecf20Sopenharmony_ci	[PWRAP_WDT_SRC_EN] =		0xDC,
6878c2ecf20Sopenharmony_ci	[PWRAP_WDT_FLG] =		0xE0,
6888c2ecf20Sopenharmony_ci	[PWRAP_DEBUG_INT_SEL] =		0xE4,
6898c2ecf20Sopenharmony_ci	[PWRAP_DVFS_ADR0] =		0xE8,
6908c2ecf20Sopenharmony_ci	[PWRAP_DVFS_WDATA0] =		0xEC,
6918c2ecf20Sopenharmony_ci	[PWRAP_DVFS_ADR1] =		0xF0,
6928c2ecf20Sopenharmony_ci	[PWRAP_DVFS_WDATA1] =		0xF4,
6938c2ecf20Sopenharmony_ci	[PWRAP_DVFS_ADR2] =		0xF8,
6948c2ecf20Sopenharmony_ci	[PWRAP_DVFS_WDATA2] =		0xFC,
6958c2ecf20Sopenharmony_ci	[PWRAP_DVFS_ADR3] =		0x100,
6968c2ecf20Sopenharmony_ci	[PWRAP_DVFS_WDATA3] =		0x104,
6978c2ecf20Sopenharmony_ci	[PWRAP_DVFS_ADR4] =		0x108,
6988c2ecf20Sopenharmony_ci	[PWRAP_DVFS_WDATA4] =		0x10C,
6998c2ecf20Sopenharmony_ci	[PWRAP_DVFS_ADR5] =		0x110,
7008c2ecf20Sopenharmony_ci	[PWRAP_DVFS_WDATA5] =		0x114,
7018c2ecf20Sopenharmony_ci	[PWRAP_DVFS_ADR6] =		0x118,
7028c2ecf20Sopenharmony_ci	[PWRAP_DVFS_WDATA6] =		0x11C,
7038c2ecf20Sopenharmony_ci	[PWRAP_DVFS_ADR7] =		0x120,
7048c2ecf20Sopenharmony_ci	[PWRAP_DVFS_WDATA7] =		0x124,
7058c2ecf20Sopenharmony_ci	[PWRAP_DVFS_ADR8] =		0x128,
7068c2ecf20Sopenharmony_ci	[PWRAP_DVFS_WDATA8] =		0x12C,
7078c2ecf20Sopenharmony_ci	[PWRAP_DVFS_ADR9] =		0x130,
7088c2ecf20Sopenharmony_ci	[PWRAP_DVFS_WDATA9] =		0x134,
7098c2ecf20Sopenharmony_ci	[PWRAP_DVFS_ADR10] =		0x138,
7108c2ecf20Sopenharmony_ci	[PWRAP_DVFS_WDATA10] =		0x13C,
7118c2ecf20Sopenharmony_ci	[PWRAP_DVFS_ADR11] =		0x140,
7128c2ecf20Sopenharmony_ci	[PWRAP_DVFS_WDATA11] =		0x144,
7138c2ecf20Sopenharmony_ci	[PWRAP_DVFS_ADR12] =		0x148,
7148c2ecf20Sopenharmony_ci	[PWRAP_DVFS_WDATA12] =		0x14C,
7158c2ecf20Sopenharmony_ci	[PWRAP_DVFS_ADR13] =		0x150,
7168c2ecf20Sopenharmony_ci	[PWRAP_DVFS_WDATA13] =		0x154,
7178c2ecf20Sopenharmony_ci	[PWRAP_DVFS_ADR14] =		0x158,
7188c2ecf20Sopenharmony_ci	[PWRAP_DVFS_WDATA14] =		0x15C,
7198c2ecf20Sopenharmony_ci	[PWRAP_DVFS_ADR15] =		0x160,
7208c2ecf20Sopenharmony_ci	[PWRAP_DVFS_WDATA15] =		0x164,
7218c2ecf20Sopenharmony_ci	[PWRAP_SPMINF_STA] =		0x168,
7228c2ecf20Sopenharmony_ci	[PWRAP_CIPHER_KEY_SEL] =	0x16C,
7238c2ecf20Sopenharmony_ci	[PWRAP_CIPHER_IV_SEL] =		0x170,
7248c2ecf20Sopenharmony_ci	[PWRAP_CIPHER_EN] =		0x174,
7258c2ecf20Sopenharmony_ci	[PWRAP_CIPHER_RDY] =		0x178,
7268c2ecf20Sopenharmony_ci	[PWRAP_CIPHER_MODE] =		0x17C,
7278c2ecf20Sopenharmony_ci	[PWRAP_CIPHER_SWRST] =		0x180,
7288c2ecf20Sopenharmony_ci	[PWRAP_DCM_EN] =		0x184,
7298c2ecf20Sopenharmony_ci	[PWRAP_DCM_DBC_PRD] =		0x188,
7308c2ecf20Sopenharmony_ci	[PWRAP_EXT_CK] =		0x18C,
7318c2ecf20Sopenharmony_ci	[PWRAP_ADC_CMD_ADDR] =		0x190,
7328c2ecf20Sopenharmony_ci	[PWRAP_PWRAP_ADC_CMD] =		0x194,
7338c2ecf20Sopenharmony_ci	[PWRAP_ADC_RDATA_ADDR] =	0x198,
7348c2ecf20Sopenharmony_ci	[PWRAP_GPS_STA] =		0x19C,
7358c2ecf20Sopenharmony_ci	[PWRAP_SW_RST] =		0x1A0,
7368c2ecf20Sopenharmony_ci	[PWRAP_DVFS_STEP_CTRL0] =	0x238,
7378c2ecf20Sopenharmony_ci	[PWRAP_DVFS_STEP_CTRL1] =	0x23C,
7388c2ecf20Sopenharmony_ci	[PWRAP_DVFS_STEP_CTRL2] =	0x240,
7398c2ecf20Sopenharmony_ci	[PWRAP_SPI2_CTRL] =		0x244,
7408c2ecf20Sopenharmony_ci};
7418c2ecf20Sopenharmony_ci
7428c2ecf20Sopenharmony_cistatic int mt8135_regs[] = {
7438c2ecf20Sopenharmony_ci	[PWRAP_MUX_SEL] =		0x0,
7448c2ecf20Sopenharmony_ci	[PWRAP_WRAP_EN] =		0x4,
7458c2ecf20Sopenharmony_ci	[PWRAP_DIO_EN] =		0x8,
7468c2ecf20Sopenharmony_ci	[PWRAP_SIDLY] =			0xc,
7478c2ecf20Sopenharmony_ci	[PWRAP_CSHEXT] =		0x10,
7488c2ecf20Sopenharmony_ci	[PWRAP_CSHEXT_WRITE] =		0x14,
7498c2ecf20Sopenharmony_ci	[PWRAP_CSHEXT_READ] =		0x18,
7508c2ecf20Sopenharmony_ci	[PWRAP_CSLEXT_START] =		0x1c,
7518c2ecf20Sopenharmony_ci	[PWRAP_CSLEXT_END] =		0x20,
7528c2ecf20Sopenharmony_ci	[PWRAP_STAUPD_PRD] =		0x24,
7538c2ecf20Sopenharmony_ci	[PWRAP_STAUPD_GRPEN] =		0x28,
7548c2ecf20Sopenharmony_ci	[PWRAP_STAUPD_MAN_TRIG] =	0x2c,
7558c2ecf20Sopenharmony_ci	[PWRAP_STAUPD_STA] =		0x30,
7568c2ecf20Sopenharmony_ci	[PWRAP_EVENT_IN_EN] =		0x34,
7578c2ecf20Sopenharmony_ci	[PWRAP_EVENT_DST_EN] =		0x38,
7588c2ecf20Sopenharmony_ci	[PWRAP_WRAP_STA] =		0x3c,
7598c2ecf20Sopenharmony_ci	[PWRAP_RRARB_INIT] =		0x40,
7608c2ecf20Sopenharmony_ci	[PWRAP_RRARB_EN] =		0x44,
7618c2ecf20Sopenharmony_ci	[PWRAP_RRARB_STA0] =		0x48,
7628c2ecf20Sopenharmony_ci	[PWRAP_RRARB_STA1] =		0x4c,
7638c2ecf20Sopenharmony_ci	[PWRAP_HARB_INIT] =		0x50,
7648c2ecf20Sopenharmony_ci	[PWRAP_HARB_HPRIO] =		0x54,
7658c2ecf20Sopenharmony_ci	[PWRAP_HIPRIO_ARB_EN] =		0x58,
7668c2ecf20Sopenharmony_ci	[PWRAP_HARB_STA0] =		0x5c,
7678c2ecf20Sopenharmony_ci	[PWRAP_HARB_STA1] =		0x60,
7688c2ecf20Sopenharmony_ci	[PWRAP_MAN_EN] =		0x64,
7698c2ecf20Sopenharmony_ci	[PWRAP_MAN_CMD] =		0x68,
7708c2ecf20Sopenharmony_ci	[PWRAP_MAN_RDATA] =		0x6c,
7718c2ecf20Sopenharmony_ci	[PWRAP_MAN_VLDCLR] =		0x70,
7728c2ecf20Sopenharmony_ci	[PWRAP_WACS0_EN] =		0x74,
7738c2ecf20Sopenharmony_ci	[PWRAP_INIT_DONE0] =		0x78,
7748c2ecf20Sopenharmony_ci	[PWRAP_WACS0_CMD] =		0x7c,
7758c2ecf20Sopenharmony_ci	[PWRAP_WACS0_RDATA] =		0x80,
7768c2ecf20Sopenharmony_ci	[PWRAP_WACS0_VLDCLR] =		0x84,
7778c2ecf20Sopenharmony_ci	[PWRAP_WACS1_EN] =		0x88,
7788c2ecf20Sopenharmony_ci	[PWRAP_INIT_DONE1] =		0x8c,
7798c2ecf20Sopenharmony_ci	[PWRAP_WACS1_CMD] =		0x90,
7808c2ecf20Sopenharmony_ci	[PWRAP_WACS1_RDATA] =		0x94,
7818c2ecf20Sopenharmony_ci	[PWRAP_WACS1_VLDCLR] =		0x98,
7828c2ecf20Sopenharmony_ci	[PWRAP_WACS2_EN] =		0x9c,
7838c2ecf20Sopenharmony_ci	[PWRAP_INIT_DONE2] =		0xa0,
7848c2ecf20Sopenharmony_ci	[PWRAP_WACS2_CMD] =		0xa4,
7858c2ecf20Sopenharmony_ci	[PWRAP_WACS2_RDATA] =		0xa8,
7868c2ecf20Sopenharmony_ci	[PWRAP_WACS2_VLDCLR] =		0xac,
7878c2ecf20Sopenharmony_ci	[PWRAP_INT_EN] =		0xb0,
7888c2ecf20Sopenharmony_ci	[PWRAP_INT_FLG_RAW] =		0xb4,
7898c2ecf20Sopenharmony_ci	[PWRAP_INT_FLG] =		0xb8,
7908c2ecf20Sopenharmony_ci	[PWRAP_INT_CLR] =		0xbc,
7918c2ecf20Sopenharmony_ci	[PWRAP_SIG_ADR] =		0xc0,
7928c2ecf20Sopenharmony_ci	[PWRAP_SIG_MODE] =		0xc4,
7938c2ecf20Sopenharmony_ci	[PWRAP_SIG_VALUE] =		0xc8,
7948c2ecf20Sopenharmony_ci	[PWRAP_SIG_ERRVAL] =		0xcc,
7958c2ecf20Sopenharmony_ci	[PWRAP_CRC_EN] =		0xd0,
7968c2ecf20Sopenharmony_ci	[PWRAP_EVENT_STA] =		0xd4,
7978c2ecf20Sopenharmony_ci	[PWRAP_EVENT_STACLR] =		0xd8,
7988c2ecf20Sopenharmony_ci	[PWRAP_TIMER_EN] =		0xdc,
7998c2ecf20Sopenharmony_ci	[PWRAP_TIMER_STA] =		0xe0,
8008c2ecf20Sopenharmony_ci	[PWRAP_WDT_UNIT] =		0xe4,
8018c2ecf20Sopenharmony_ci	[PWRAP_WDT_SRC_EN] =		0xe8,
8028c2ecf20Sopenharmony_ci	[PWRAP_WDT_FLG] =		0xec,
8038c2ecf20Sopenharmony_ci	[PWRAP_DEBUG_INT_SEL] =		0xf0,
8048c2ecf20Sopenharmony_ci	[PWRAP_CIPHER_KEY_SEL] =	0x134,
8058c2ecf20Sopenharmony_ci	[PWRAP_CIPHER_IV_SEL] =		0x138,
8068c2ecf20Sopenharmony_ci	[PWRAP_CIPHER_LOAD] =		0x13c,
8078c2ecf20Sopenharmony_ci	[PWRAP_CIPHER_START] =		0x140,
8088c2ecf20Sopenharmony_ci	[PWRAP_CIPHER_RDY] =		0x144,
8098c2ecf20Sopenharmony_ci	[PWRAP_CIPHER_MODE] =		0x148,
8108c2ecf20Sopenharmony_ci	[PWRAP_CIPHER_SWRST] =		0x14c,
8118c2ecf20Sopenharmony_ci	[PWRAP_DCM_EN] =		0x15c,
8128c2ecf20Sopenharmony_ci	[PWRAP_DCM_DBC_PRD] =		0x160,
8138c2ecf20Sopenharmony_ci};
8148c2ecf20Sopenharmony_ci
8158c2ecf20Sopenharmony_cistatic int mt8173_regs[] = {
8168c2ecf20Sopenharmony_ci	[PWRAP_MUX_SEL] =		0x0,
8178c2ecf20Sopenharmony_ci	[PWRAP_WRAP_EN] =		0x4,
8188c2ecf20Sopenharmony_ci	[PWRAP_DIO_EN] =		0x8,
8198c2ecf20Sopenharmony_ci	[PWRAP_SIDLY] =			0xc,
8208c2ecf20Sopenharmony_ci	[PWRAP_RDDMY] =			0x10,
8218c2ecf20Sopenharmony_ci	[PWRAP_SI_CK_CON] =		0x14,
8228c2ecf20Sopenharmony_ci	[PWRAP_CSHEXT_WRITE] =		0x18,
8238c2ecf20Sopenharmony_ci	[PWRAP_CSHEXT_READ] =		0x1c,
8248c2ecf20Sopenharmony_ci	[PWRAP_CSLEXT_START] =		0x20,
8258c2ecf20Sopenharmony_ci	[PWRAP_CSLEXT_END] =		0x24,
8268c2ecf20Sopenharmony_ci	[PWRAP_STAUPD_PRD] =		0x28,
8278c2ecf20Sopenharmony_ci	[PWRAP_STAUPD_GRPEN] =		0x2c,
8288c2ecf20Sopenharmony_ci	[PWRAP_STAUPD_MAN_TRIG] =	0x40,
8298c2ecf20Sopenharmony_ci	[PWRAP_STAUPD_STA] =		0x44,
8308c2ecf20Sopenharmony_ci	[PWRAP_WRAP_STA] =		0x48,
8318c2ecf20Sopenharmony_ci	[PWRAP_HARB_INIT] =		0x4c,
8328c2ecf20Sopenharmony_ci	[PWRAP_HARB_HPRIO] =		0x50,
8338c2ecf20Sopenharmony_ci	[PWRAP_HIPRIO_ARB_EN] =		0x54,
8348c2ecf20Sopenharmony_ci	[PWRAP_HARB_STA0] =		0x58,
8358c2ecf20Sopenharmony_ci	[PWRAP_HARB_STA1] =		0x5c,
8368c2ecf20Sopenharmony_ci	[PWRAP_MAN_EN] =		0x60,
8378c2ecf20Sopenharmony_ci	[PWRAP_MAN_CMD] =		0x64,
8388c2ecf20Sopenharmony_ci	[PWRAP_MAN_RDATA] =		0x68,
8398c2ecf20Sopenharmony_ci	[PWRAP_MAN_VLDCLR] =		0x6c,
8408c2ecf20Sopenharmony_ci	[PWRAP_WACS0_EN] =		0x70,
8418c2ecf20Sopenharmony_ci	[PWRAP_INIT_DONE0] =		0x74,
8428c2ecf20Sopenharmony_ci	[PWRAP_WACS0_CMD] =		0x78,
8438c2ecf20Sopenharmony_ci	[PWRAP_WACS0_RDATA] =		0x7c,
8448c2ecf20Sopenharmony_ci	[PWRAP_WACS0_VLDCLR] =		0x80,
8458c2ecf20Sopenharmony_ci	[PWRAP_WACS1_EN] =		0x84,
8468c2ecf20Sopenharmony_ci	[PWRAP_INIT_DONE1] =		0x88,
8478c2ecf20Sopenharmony_ci	[PWRAP_WACS1_CMD] =		0x8c,
8488c2ecf20Sopenharmony_ci	[PWRAP_WACS1_RDATA] =		0x90,
8498c2ecf20Sopenharmony_ci	[PWRAP_WACS1_VLDCLR] =		0x94,
8508c2ecf20Sopenharmony_ci	[PWRAP_WACS2_EN] =		0x98,
8518c2ecf20Sopenharmony_ci	[PWRAP_INIT_DONE2] =		0x9c,
8528c2ecf20Sopenharmony_ci	[PWRAP_WACS2_CMD] =		0xa0,
8538c2ecf20Sopenharmony_ci	[PWRAP_WACS2_RDATA] =		0xa4,
8548c2ecf20Sopenharmony_ci	[PWRAP_WACS2_VLDCLR] =		0xa8,
8558c2ecf20Sopenharmony_ci	[PWRAP_INT_EN] =		0xac,
8568c2ecf20Sopenharmony_ci	[PWRAP_INT_FLG_RAW] =		0xb0,
8578c2ecf20Sopenharmony_ci	[PWRAP_INT_FLG] =		0xb4,
8588c2ecf20Sopenharmony_ci	[PWRAP_INT_CLR] =		0xb8,
8598c2ecf20Sopenharmony_ci	[PWRAP_SIG_ADR] =		0xbc,
8608c2ecf20Sopenharmony_ci	[PWRAP_SIG_MODE] =		0xc0,
8618c2ecf20Sopenharmony_ci	[PWRAP_SIG_VALUE] =		0xc4,
8628c2ecf20Sopenharmony_ci	[PWRAP_SIG_ERRVAL] =		0xc8,
8638c2ecf20Sopenharmony_ci	[PWRAP_CRC_EN] =		0xcc,
8648c2ecf20Sopenharmony_ci	[PWRAP_TIMER_EN] =		0xd0,
8658c2ecf20Sopenharmony_ci	[PWRAP_TIMER_STA] =		0xd4,
8668c2ecf20Sopenharmony_ci	[PWRAP_WDT_UNIT] =		0xd8,
8678c2ecf20Sopenharmony_ci	[PWRAP_WDT_SRC_EN] =		0xdc,
8688c2ecf20Sopenharmony_ci	[PWRAP_WDT_FLG] =		0xe0,
8698c2ecf20Sopenharmony_ci	[PWRAP_DEBUG_INT_SEL] =		0xe4,
8708c2ecf20Sopenharmony_ci	[PWRAP_DVFS_ADR0] =		0xe8,
8718c2ecf20Sopenharmony_ci	[PWRAP_DVFS_WDATA0] =		0xec,
8728c2ecf20Sopenharmony_ci	[PWRAP_DVFS_ADR1] =		0xf0,
8738c2ecf20Sopenharmony_ci	[PWRAP_DVFS_WDATA1] =		0xf4,
8748c2ecf20Sopenharmony_ci	[PWRAP_DVFS_ADR2] =		0xf8,
8758c2ecf20Sopenharmony_ci	[PWRAP_DVFS_WDATA2] =		0xfc,
8768c2ecf20Sopenharmony_ci	[PWRAP_DVFS_ADR3] =		0x100,
8778c2ecf20Sopenharmony_ci	[PWRAP_DVFS_WDATA3] =		0x104,
8788c2ecf20Sopenharmony_ci	[PWRAP_DVFS_ADR4] =		0x108,
8798c2ecf20Sopenharmony_ci	[PWRAP_DVFS_WDATA4] =		0x10c,
8808c2ecf20Sopenharmony_ci	[PWRAP_DVFS_ADR5] =		0x110,
8818c2ecf20Sopenharmony_ci	[PWRAP_DVFS_WDATA5] =		0x114,
8828c2ecf20Sopenharmony_ci	[PWRAP_DVFS_ADR6] =		0x118,
8838c2ecf20Sopenharmony_ci	[PWRAP_DVFS_WDATA6] =		0x11c,
8848c2ecf20Sopenharmony_ci	[PWRAP_DVFS_ADR7] =		0x120,
8858c2ecf20Sopenharmony_ci	[PWRAP_DVFS_WDATA7] =		0x124,
8868c2ecf20Sopenharmony_ci	[PWRAP_SPMINF_STA] =		0x128,
8878c2ecf20Sopenharmony_ci	[PWRAP_CIPHER_KEY_SEL] =	0x12c,
8888c2ecf20Sopenharmony_ci	[PWRAP_CIPHER_IV_SEL] =		0x130,
8898c2ecf20Sopenharmony_ci	[PWRAP_CIPHER_EN] =		0x134,
8908c2ecf20Sopenharmony_ci	[PWRAP_CIPHER_RDY] =		0x138,
8918c2ecf20Sopenharmony_ci	[PWRAP_CIPHER_MODE] =		0x13c,
8928c2ecf20Sopenharmony_ci	[PWRAP_CIPHER_SWRST] =		0x140,
8938c2ecf20Sopenharmony_ci	[PWRAP_DCM_EN] =		0x144,
8948c2ecf20Sopenharmony_ci	[PWRAP_DCM_DBC_PRD] =		0x148,
8958c2ecf20Sopenharmony_ci};
8968c2ecf20Sopenharmony_ci
8978c2ecf20Sopenharmony_cistatic int mt8183_regs[] = {
8988c2ecf20Sopenharmony_ci	[PWRAP_MUX_SEL] =			0x0,
8998c2ecf20Sopenharmony_ci	[PWRAP_WRAP_EN] =			0x4,
9008c2ecf20Sopenharmony_ci	[PWRAP_DIO_EN] =			0x8,
9018c2ecf20Sopenharmony_ci	[PWRAP_SI_SAMPLE_CTRL] =		0xC,
9028c2ecf20Sopenharmony_ci	[PWRAP_RDDMY] =				0x14,
9038c2ecf20Sopenharmony_ci	[PWRAP_CSHEXT_WRITE] =			0x18,
9048c2ecf20Sopenharmony_ci	[PWRAP_CSHEXT_READ] =			0x1C,
9058c2ecf20Sopenharmony_ci	[PWRAP_CSLEXT_WRITE] =			0x20,
9068c2ecf20Sopenharmony_ci	[PWRAP_CSLEXT_READ] =			0x24,
9078c2ecf20Sopenharmony_ci	[PWRAP_EXT_CK_WRITE] =			0x28,
9088c2ecf20Sopenharmony_ci	[PWRAP_STAUPD_CTRL] =			0x30,
9098c2ecf20Sopenharmony_ci	[PWRAP_STAUPD_GRPEN] =			0x34,
9108c2ecf20Sopenharmony_ci	[PWRAP_EINT_STA0_ADR] =			0x38,
9118c2ecf20Sopenharmony_ci	[PWRAP_HARB_HPRIO] =			0x5C,
9128c2ecf20Sopenharmony_ci	[PWRAP_HIPRIO_ARB_EN] =			0x60,
9138c2ecf20Sopenharmony_ci	[PWRAP_MAN_EN] =			0x70,
9148c2ecf20Sopenharmony_ci	[PWRAP_MAN_CMD] =			0x74,
9158c2ecf20Sopenharmony_ci	[PWRAP_WACS0_EN] =			0x80,
9168c2ecf20Sopenharmony_ci	[PWRAP_INIT_DONE0] =			0x84,
9178c2ecf20Sopenharmony_ci	[PWRAP_WACS1_EN] =			0x88,
9188c2ecf20Sopenharmony_ci	[PWRAP_INIT_DONE1] =			0x8C,
9198c2ecf20Sopenharmony_ci	[PWRAP_WACS2_EN] =			0x90,
9208c2ecf20Sopenharmony_ci	[PWRAP_INIT_DONE2] =			0x94,
9218c2ecf20Sopenharmony_ci	[PWRAP_WACS_P2P_EN] =			0xA0,
9228c2ecf20Sopenharmony_ci	[PWRAP_INIT_DONE_P2P] =			0xA4,
9238c2ecf20Sopenharmony_ci	[PWRAP_WACS_MD32_EN] =			0xA8,
9248c2ecf20Sopenharmony_ci	[PWRAP_INIT_DONE_MD32] =		0xAC,
9258c2ecf20Sopenharmony_ci	[PWRAP_INT_EN] =			0xB0,
9268c2ecf20Sopenharmony_ci	[PWRAP_INT_FLG] =			0xB8,
9278c2ecf20Sopenharmony_ci	[PWRAP_INT_CLR] =			0xBC,
9288c2ecf20Sopenharmony_ci	[PWRAP_INT1_EN] =			0xC0,
9298c2ecf20Sopenharmony_ci	[PWRAP_INT1_FLG] =			0xC8,
9308c2ecf20Sopenharmony_ci	[PWRAP_INT1_CLR] =			0xCC,
9318c2ecf20Sopenharmony_ci	[PWRAP_SIG_ADR] =			0xD0,
9328c2ecf20Sopenharmony_ci	[PWRAP_CRC_EN] =			0xE0,
9338c2ecf20Sopenharmony_ci	[PWRAP_TIMER_EN] =			0xE4,
9348c2ecf20Sopenharmony_ci	[PWRAP_WDT_UNIT] =			0xEC,
9358c2ecf20Sopenharmony_ci	[PWRAP_WDT_SRC_EN] =			0xF0,
9368c2ecf20Sopenharmony_ci	[PWRAP_WDT_SRC_EN_1] =			0xF4,
9378c2ecf20Sopenharmony_ci	[PWRAP_INT_GPS_AUXADC_CMD_ADDR] =	0x1DC,
9388c2ecf20Sopenharmony_ci	[PWRAP_INT_GPS_AUXADC_CMD] =		0x1E0,
9398c2ecf20Sopenharmony_ci	[PWRAP_INT_GPS_AUXADC_RDATA_ADDR] =	0x1E4,
9408c2ecf20Sopenharmony_ci	[PWRAP_EXT_GPS_AUXADC_RDATA_ADDR] =	0x1E8,
9418c2ecf20Sopenharmony_ci	[PWRAP_GPSINF_0_STA] =			0x1EC,
9428c2ecf20Sopenharmony_ci	[PWRAP_GPSINF_1_STA] =			0x1F0,
9438c2ecf20Sopenharmony_ci	[PWRAP_WACS2_CMD] =			0xC20,
9448c2ecf20Sopenharmony_ci	[PWRAP_WACS2_RDATA] =			0xC24,
9458c2ecf20Sopenharmony_ci	[PWRAP_WACS2_VLDCLR] =			0xC28,
9468c2ecf20Sopenharmony_ci};
9478c2ecf20Sopenharmony_ci
9488c2ecf20Sopenharmony_cistatic int mt8516_regs[] = {
9498c2ecf20Sopenharmony_ci	[PWRAP_MUX_SEL] =		0x0,
9508c2ecf20Sopenharmony_ci	[PWRAP_WRAP_EN] =		0x4,
9518c2ecf20Sopenharmony_ci	[PWRAP_DIO_EN] =		0x8,
9528c2ecf20Sopenharmony_ci	[PWRAP_SIDLY] =			0xc,
9538c2ecf20Sopenharmony_ci	[PWRAP_RDDMY] =			0x10,
9548c2ecf20Sopenharmony_ci	[PWRAP_SI_CK_CON] =		0x14,
9558c2ecf20Sopenharmony_ci	[PWRAP_CSHEXT_WRITE] =		0x18,
9568c2ecf20Sopenharmony_ci	[PWRAP_CSHEXT_READ] =		0x1c,
9578c2ecf20Sopenharmony_ci	[PWRAP_CSLEXT_START] =		0x20,
9588c2ecf20Sopenharmony_ci	[PWRAP_CSLEXT_END] =		0x24,
9598c2ecf20Sopenharmony_ci	[PWRAP_STAUPD_PRD] =		0x28,
9608c2ecf20Sopenharmony_ci	[PWRAP_STAUPD_GRPEN] =		0x2c,
9618c2ecf20Sopenharmony_ci	[PWRAP_STAUPD_MAN_TRIG] =	0x40,
9628c2ecf20Sopenharmony_ci	[PWRAP_STAUPD_STA] =		0x44,
9638c2ecf20Sopenharmony_ci	[PWRAP_WRAP_STA] =		0x48,
9648c2ecf20Sopenharmony_ci	[PWRAP_HARB_INIT] =		0x4c,
9658c2ecf20Sopenharmony_ci	[PWRAP_HARB_HPRIO] =		0x50,
9668c2ecf20Sopenharmony_ci	[PWRAP_HIPRIO_ARB_EN] =		0x54,
9678c2ecf20Sopenharmony_ci	[PWRAP_HARB_STA0] =		0x58,
9688c2ecf20Sopenharmony_ci	[PWRAP_HARB_STA1] =		0x5c,
9698c2ecf20Sopenharmony_ci	[PWRAP_MAN_EN] =		0x60,
9708c2ecf20Sopenharmony_ci	[PWRAP_MAN_CMD] =		0x64,
9718c2ecf20Sopenharmony_ci	[PWRAP_MAN_RDATA] =		0x68,
9728c2ecf20Sopenharmony_ci	[PWRAP_MAN_VLDCLR] =		0x6c,
9738c2ecf20Sopenharmony_ci	[PWRAP_WACS0_EN] =		0x70,
9748c2ecf20Sopenharmony_ci	[PWRAP_INIT_DONE0] =		0x74,
9758c2ecf20Sopenharmony_ci	[PWRAP_WACS0_CMD] =		0x78,
9768c2ecf20Sopenharmony_ci	[PWRAP_WACS0_RDATA] =		0x7c,
9778c2ecf20Sopenharmony_ci	[PWRAP_WACS0_VLDCLR] =		0x80,
9788c2ecf20Sopenharmony_ci	[PWRAP_WACS1_EN] =		0x84,
9798c2ecf20Sopenharmony_ci	[PWRAP_INIT_DONE1] =		0x88,
9808c2ecf20Sopenharmony_ci	[PWRAP_WACS1_CMD] =		0x8c,
9818c2ecf20Sopenharmony_ci	[PWRAP_WACS1_RDATA] =		0x90,
9828c2ecf20Sopenharmony_ci	[PWRAP_WACS1_VLDCLR] =		0x94,
9838c2ecf20Sopenharmony_ci	[PWRAP_WACS2_EN] =		0x98,
9848c2ecf20Sopenharmony_ci	[PWRAP_INIT_DONE2] =		0x9c,
9858c2ecf20Sopenharmony_ci	[PWRAP_WACS2_CMD] =		0xa0,
9868c2ecf20Sopenharmony_ci	[PWRAP_WACS2_RDATA] =		0xa4,
9878c2ecf20Sopenharmony_ci	[PWRAP_WACS2_VLDCLR] =		0xa8,
9888c2ecf20Sopenharmony_ci	[PWRAP_INT_EN] =		0xac,
9898c2ecf20Sopenharmony_ci	[PWRAP_INT_FLG_RAW] =		0xb0,
9908c2ecf20Sopenharmony_ci	[PWRAP_INT_FLG] =		0xb4,
9918c2ecf20Sopenharmony_ci	[PWRAP_INT_CLR] =		0xb8,
9928c2ecf20Sopenharmony_ci	[PWRAP_SIG_ADR] =		0xbc,
9938c2ecf20Sopenharmony_ci	[PWRAP_SIG_MODE] =		0xc0,
9948c2ecf20Sopenharmony_ci	[PWRAP_SIG_VALUE] =		0xc4,
9958c2ecf20Sopenharmony_ci	[PWRAP_SIG_ERRVAL] =		0xc8,
9968c2ecf20Sopenharmony_ci	[PWRAP_CRC_EN] =		0xcc,
9978c2ecf20Sopenharmony_ci	[PWRAP_TIMER_EN] =		0xd0,
9988c2ecf20Sopenharmony_ci	[PWRAP_TIMER_STA] =		0xd4,
9998c2ecf20Sopenharmony_ci	[PWRAP_WDT_UNIT] =		0xd8,
10008c2ecf20Sopenharmony_ci	[PWRAP_WDT_SRC_EN] =		0xdc,
10018c2ecf20Sopenharmony_ci	[PWRAP_WDT_FLG] =		0xe0,
10028c2ecf20Sopenharmony_ci	[PWRAP_DEBUG_INT_SEL] =		0xe4,
10038c2ecf20Sopenharmony_ci	[PWRAP_DVFS_ADR0] =		0xe8,
10048c2ecf20Sopenharmony_ci	[PWRAP_DVFS_WDATA0] =		0xec,
10058c2ecf20Sopenharmony_ci	[PWRAP_DVFS_ADR1] =		0xf0,
10068c2ecf20Sopenharmony_ci	[PWRAP_DVFS_WDATA1] =		0xf4,
10078c2ecf20Sopenharmony_ci	[PWRAP_DVFS_ADR2] =		0xf8,
10088c2ecf20Sopenharmony_ci	[PWRAP_DVFS_WDATA2] =		0xfc,
10098c2ecf20Sopenharmony_ci	[PWRAP_DVFS_ADR3] =		0x100,
10108c2ecf20Sopenharmony_ci	[PWRAP_DVFS_WDATA3] =		0x104,
10118c2ecf20Sopenharmony_ci	[PWRAP_DVFS_ADR4] =		0x108,
10128c2ecf20Sopenharmony_ci	[PWRAP_DVFS_WDATA4] =		0x10c,
10138c2ecf20Sopenharmony_ci	[PWRAP_DVFS_ADR5] =		0x110,
10148c2ecf20Sopenharmony_ci	[PWRAP_DVFS_WDATA5] =		0x114,
10158c2ecf20Sopenharmony_ci	[PWRAP_DVFS_ADR6] =		0x118,
10168c2ecf20Sopenharmony_ci	[PWRAP_DVFS_WDATA6] =		0x11c,
10178c2ecf20Sopenharmony_ci	[PWRAP_DVFS_ADR7] =		0x120,
10188c2ecf20Sopenharmony_ci	[PWRAP_DVFS_WDATA7] =		0x124,
10198c2ecf20Sopenharmony_ci	[PWRAP_SPMINF_STA] =		0x128,
10208c2ecf20Sopenharmony_ci	[PWRAP_CIPHER_KEY_SEL] =	0x12c,
10218c2ecf20Sopenharmony_ci	[PWRAP_CIPHER_IV_SEL] =		0x130,
10228c2ecf20Sopenharmony_ci	[PWRAP_CIPHER_EN] =		0x134,
10238c2ecf20Sopenharmony_ci	[PWRAP_CIPHER_RDY] =		0x138,
10248c2ecf20Sopenharmony_ci	[PWRAP_CIPHER_MODE] =		0x13c,
10258c2ecf20Sopenharmony_ci	[PWRAP_CIPHER_SWRST] =		0x140,
10268c2ecf20Sopenharmony_ci	[PWRAP_DCM_EN] =		0x144,
10278c2ecf20Sopenharmony_ci	[PWRAP_DCM_DBC_PRD] =		0x148,
10288c2ecf20Sopenharmony_ci	[PWRAP_SW_RST] =		0x168,
10298c2ecf20Sopenharmony_ci	[PWRAP_OP_TYPE] =		0x16c,
10308c2ecf20Sopenharmony_ci	[PWRAP_MSB_FIRST] =		0x170,
10318c2ecf20Sopenharmony_ci};
10328c2ecf20Sopenharmony_ci
10338c2ecf20Sopenharmony_cienum pmic_type {
10348c2ecf20Sopenharmony_ci	PMIC_MT6323,
10358c2ecf20Sopenharmony_ci	PMIC_MT6351,
10368c2ecf20Sopenharmony_ci	PMIC_MT6357,
10378c2ecf20Sopenharmony_ci	PMIC_MT6358,
10388c2ecf20Sopenharmony_ci	PMIC_MT6359,
10398c2ecf20Sopenharmony_ci	PMIC_MT6380,
10408c2ecf20Sopenharmony_ci	PMIC_MT6397,
10418c2ecf20Sopenharmony_ci};
10428c2ecf20Sopenharmony_ci
10438c2ecf20Sopenharmony_cienum pwrap_type {
10448c2ecf20Sopenharmony_ci	PWRAP_MT2701,
10458c2ecf20Sopenharmony_ci	PWRAP_MT6765,
10468c2ecf20Sopenharmony_ci	PWRAP_MT6779,
10478c2ecf20Sopenharmony_ci	PWRAP_MT6797,
10488c2ecf20Sopenharmony_ci	PWRAP_MT7622,
10498c2ecf20Sopenharmony_ci	PWRAP_MT8135,
10508c2ecf20Sopenharmony_ci	PWRAP_MT8173,
10518c2ecf20Sopenharmony_ci	PWRAP_MT8183,
10528c2ecf20Sopenharmony_ci	PWRAP_MT8516,
10538c2ecf20Sopenharmony_ci};
10548c2ecf20Sopenharmony_ci
10558c2ecf20Sopenharmony_cistruct pmic_wrapper;
10568c2ecf20Sopenharmony_cistruct pwrap_slv_type {
10578c2ecf20Sopenharmony_ci	const u32 *dew_regs;
10588c2ecf20Sopenharmony_ci	enum pmic_type type;
10598c2ecf20Sopenharmony_ci	const struct regmap_config *regmap;
10608c2ecf20Sopenharmony_ci	/* Flags indicating the capability for the target slave */
10618c2ecf20Sopenharmony_ci	u32 caps;
10628c2ecf20Sopenharmony_ci	/*
10638c2ecf20Sopenharmony_ci	 * pwrap operations are highly associated with the PMIC types,
10648c2ecf20Sopenharmony_ci	 * so the pointers added increases flexibility allowing determination
10658c2ecf20Sopenharmony_ci	 * which type is used by the detection through device tree.
10668c2ecf20Sopenharmony_ci	 */
10678c2ecf20Sopenharmony_ci	int (*pwrap_read)(struct pmic_wrapper *wrp, u32 adr, u32 *rdata);
10688c2ecf20Sopenharmony_ci	int (*pwrap_write)(struct pmic_wrapper *wrp, u32 adr, u32 wdata);
10698c2ecf20Sopenharmony_ci};
10708c2ecf20Sopenharmony_ci
10718c2ecf20Sopenharmony_cistruct pmic_wrapper {
10728c2ecf20Sopenharmony_ci	struct device *dev;
10738c2ecf20Sopenharmony_ci	void __iomem *base;
10748c2ecf20Sopenharmony_ci	struct regmap *regmap;
10758c2ecf20Sopenharmony_ci	const struct pmic_wrapper_type *master;
10768c2ecf20Sopenharmony_ci	const struct pwrap_slv_type *slave;
10778c2ecf20Sopenharmony_ci	struct clk *clk_spi;
10788c2ecf20Sopenharmony_ci	struct clk *clk_wrap;
10798c2ecf20Sopenharmony_ci	struct reset_control *rstc;
10808c2ecf20Sopenharmony_ci
10818c2ecf20Sopenharmony_ci	struct reset_control *rstc_bridge;
10828c2ecf20Sopenharmony_ci	void __iomem *bridge_base;
10838c2ecf20Sopenharmony_ci};
10848c2ecf20Sopenharmony_ci
10858c2ecf20Sopenharmony_cistruct pmic_wrapper_type {
10868c2ecf20Sopenharmony_ci	int *regs;
10878c2ecf20Sopenharmony_ci	enum pwrap_type type;
10888c2ecf20Sopenharmony_ci	u32 arb_en_all;
10898c2ecf20Sopenharmony_ci	u32 int_en_all;
10908c2ecf20Sopenharmony_ci	u32 int1_en_all;
10918c2ecf20Sopenharmony_ci	u32 spi_w;
10928c2ecf20Sopenharmony_ci	u32 wdt_src;
10938c2ecf20Sopenharmony_ci	/* Flags indicating the capability for the target pwrap */
10948c2ecf20Sopenharmony_ci	u32 caps;
10958c2ecf20Sopenharmony_ci	int (*init_reg_clock)(struct pmic_wrapper *wrp);
10968c2ecf20Sopenharmony_ci	int (*init_soc_specific)(struct pmic_wrapper *wrp);
10978c2ecf20Sopenharmony_ci};
10988c2ecf20Sopenharmony_ci
10998c2ecf20Sopenharmony_cistatic u32 pwrap_readl(struct pmic_wrapper *wrp, enum pwrap_regs reg)
11008c2ecf20Sopenharmony_ci{
11018c2ecf20Sopenharmony_ci	return readl(wrp->base + wrp->master->regs[reg]);
11028c2ecf20Sopenharmony_ci}
11038c2ecf20Sopenharmony_ci
11048c2ecf20Sopenharmony_cistatic void pwrap_writel(struct pmic_wrapper *wrp, u32 val, enum pwrap_regs reg)
11058c2ecf20Sopenharmony_ci{
11068c2ecf20Sopenharmony_ci	writel(val, wrp->base + wrp->master->regs[reg]);
11078c2ecf20Sopenharmony_ci}
11088c2ecf20Sopenharmony_ci
11098c2ecf20Sopenharmony_cistatic bool pwrap_is_fsm_idle(struct pmic_wrapper *wrp)
11108c2ecf20Sopenharmony_ci{
11118c2ecf20Sopenharmony_ci	u32 val = pwrap_readl(wrp, PWRAP_WACS2_RDATA);
11128c2ecf20Sopenharmony_ci
11138c2ecf20Sopenharmony_ci	return PWRAP_GET_WACS_FSM(val) == PWRAP_WACS_FSM_IDLE;
11148c2ecf20Sopenharmony_ci}
11158c2ecf20Sopenharmony_ci
11168c2ecf20Sopenharmony_cistatic bool pwrap_is_fsm_vldclr(struct pmic_wrapper *wrp)
11178c2ecf20Sopenharmony_ci{
11188c2ecf20Sopenharmony_ci	u32 val = pwrap_readl(wrp, PWRAP_WACS2_RDATA);
11198c2ecf20Sopenharmony_ci
11208c2ecf20Sopenharmony_ci	return PWRAP_GET_WACS_FSM(val) == PWRAP_WACS_FSM_WFVLDCLR;
11218c2ecf20Sopenharmony_ci}
11228c2ecf20Sopenharmony_ci
11238c2ecf20Sopenharmony_ci/*
11248c2ecf20Sopenharmony_ci * Timeout issue sometimes caused by the last read command
11258c2ecf20Sopenharmony_ci * failed because pmic wrap could not got the FSM_VLDCLR
11268c2ecf20Sopenharmony_ci * in time after finishing WACS2_CMD. It made state machine
11278c2ecf20Sopenharmony_ci * still on FSM_VLDCLR and timeout next time.
11288c2ecf20Sopenharmony_ci * Check the status of FSM and clear the vldclr to recovery the
11298c2ecf20Sopenharmony_ci * error.
11308c2ecf20Sopenharmony_ci */
11318c2ecf20Sopenharmony_cistatic inline void pwrap_leave_fsm_vldclr(struct pmic_wrapper *wrp)
11328c2ecf20Sopenharmony_ci{
11338c2ecf20Sopenharmony_ci	if (pwrap_is_fsm_vldclr(wrp))
11348c2ecf20Sopenharmony_ci		pwrap_writel(wrp, 1, PWRAP_WACS2_VLDCLR);
11358c2ecf20Sopenharmony_ci}
11368c2ecf20Sopenharmony_ci
11378c2ecf20Sopenharmony_cistatic bool pwrap_is_sync_idle(struct pmic_wrapper *wrp)
11388c2ecf20Sopenharmony_ci{
11398c2ecf20Sopenharmony_ci	return pwrap_readl(wrp, PWRAP_WACS2_RDATA) & PWRAP_STATE_SYNC_IDLE0;
11408c2ecf20Sopenharmony_ci}
11418c2ecf20Sopenharmony_ci
11428c2ecf20Sopenharmony_cistatic bool pwrap_is_fsm_idle_and_sync_idle(struct pmic_wrapper *wrp)
11438c2ecf20Sopenharmony_ci{
11448c2ecf20Sopenharmony_ci	u32 val = pwrap_readl(wrp, PWRAP_WACS2_RDATA);
11458c2ecf20Sopenharmony_ci
11468c2ecf20Sopenharmony_ci	return (PWRAP_GET_WACS_FSM(val) == PWRAP_WACS_FSM_IDLE) &&
11478c2ecf20Sopenharmony_ci		(val & PWRAP_STATE_SYNC_IDLE0);
11488c2ecf20Sopenharmony_ci}
11498c2ecf20Sopenharmony_ci
11508c2ecf20Sopenharmony_cistatic int pwrap_wait_for_state(struct pmic_wrapper *wrp,
11518c2ecf20Sopenharmony_ci		bool (*fp)(struct pmic_wrapper *))
11528c2ecf20Sopenharmony_ci{
11538c2ecf20Sopenharmony_ci	unsigned long timeout;
11548c2ecf20Sopenharmony_ci
11558c2ecf20Sopenharmony_ci	timeout = jiffies + usecs_to_jiffies(10000);
11568c2ecf20Sopenharmony_ci
11578c2ecf20Sopenharmony_ci	do {
11588c2ecf20Sopenharmony_ci		if (time_after(jiffies, timeout))
11598c2ecf20Sopenharmony_ci			return fp(wrp) ? 0 : -ETIMEDOUT;
11608c2ecf20Sopenharmony_ci		if (fp(wrp))
11618c2ecf20Sopenharmony_ci			return 0;
11628c2ecf20Sopenharmony_ci	} while (1);
11638c2ecf20Sopenharmony_ci}
11648c2ecf20Sopenharmony_ci
11658c2ecf20Sopenharmony_cistatic int pwrap_read16(struct pmic_wrapper *wrp, u32 adr, u32 *rdata)
11668c2ecf20Sopenharmony_ci{
11678c2ecf20Sopenharmony_ci	int ret;
11688c2ecf20Sopenharmony_ci
11698c2ecf20Sopenharmony_ci	ret = pwrap_wait_for_state(wrp, pwrap_is_fsm_idle);
11708c2ecf20Sopenharmony_ci	if (ret) {
11718c2ecf20Sopenharmony_ci		pwrap_leave_fsm_vldclr(wrp);
11728c2ecf20Sopenharmony_ci		return ret;
11738c2ecf20Sopenharmony_ci	}
11748c2ecf20Sopenharmony_ci
11758c2ecf20Sopenharmony_ci	pwrap_writel(wrp, (adr >> 1) << 16, PWRAP_WACS2_CMD);
11768c2ecf20Sopenharmony_ci
11778c2ecf20Sopenharmony_ci	ret = pwrap_wait_for_state(wrp, pwrap_is_fsm_vldclr);
11788c2ecf20Sopenharmony_ci	if (ret)
11798c2ecf20Sopenharmony_ci		return ret;
11808c2ecf20Sopenharmony_ci
11818c2ecf20Sopenharmony_ci	*rdata = PWRAP_GET_WACS_RDATA(pwrap_readl(wrp, PWRAP_WACS2_RDATA));
11828c2ecf20Sopenharmony_ci
11838c2ecf20Sopenharmony_ci	pwrap_writel(wrp, 1, PWRAP_WACS2_VLDCLR);
11848c2ecf20Sopenharmony_ci
11858c2ecf20Sopenharmony_ci	return 0;
11868c2ecf20Sopenharmony_ci}
11878c2ecf20Sopenharmony_ci
11888c2ecf20Sopenharmony_cistatic int pwrap_read32(struct pmic_wrapper *wrp, u32 adr, u32 *rdata)
11898c2ecf20Sopenharmony_ci{
11908c2ecf20Sopenharmony_ci	int ret, msb;
11918c2ecf20Sopenharmony_ci
11928c2ecf20Sopenharmony_ci	*rdata = 0;
11938c2ecf20Sopenharmony_ci	for (msb = 0; msb < 2; msb++) {
11948c2ecf20Sopenharmony_ci		ret = pwrap_wait_for_state(wrp, pwrap_is_fsm_idle);
11958c2ecf20Sopenharmony_ci		if (ret) {
11968c2ecf20Sopenharmony_ci			pwrap_leave_fsm_vldclr(wrp);
11978c2ecf20Sopenharmony_ci			return ret;
11988c2ecf20Sopenharmony_ci		}
11998c2ecf20Sopenharmony_ci
12008c2ecf20Sopenharmony_ci		pwrap_writel(wrp, ((msb << 30) | (adr << 16)),
12018c2ecf20Sopenharmony_ci			     PWRAP_WACS2_CMD);
12028c2ecf20Sopenharmony_ci
12038c2ecf20Sopenharmony_ci		ret = pwrap_wait_for_state(wrp, pwrap_is_fsm_vldclr);
12048c2ecf20Sopenharmony_ci		if (ret)
12058c2ecf20Sopenharmony_ci			return ret;
12068c2ecf20Sopenharmony_ci
12078c2ecf20Sopenharmony_ci		*rdata += (PWRAP_GET_WACS_RDATA(pwrap_readl(wrp,
12088c2ecf20Sopenharmony_ci			   PWRAP_WACS2_RDATA)) << (16 * msb));
12098c2ecf20Sopenharmony_ci
12108c2ecf20Sopenharmony_ci		pwrap_writel(wrp, 1, PWRAP_WACS2_VLDCLR);
12118c2ecf20Sopenharmony_ci	}
12128c2ecf20Sopenharmony_ci
12138c2ecf20Sopenharmony_ci	return 0;
12148c2ecf20Sopenharmony_ci}
12158c2ecf20Sopenharmony_ci
12168c2ecf20Sopenharmony_cistatic int pwrap_read(struct pmic_wrapper *wrp, u32 adr, u32 *rdata)
12178c2ecf20Sopenharmony_ci{
12188c2ecf20Sopenharmony_ci	return wrp->slave->pwrap_read(wrp, adr, rdata);
12198c2ecf20Sopenharmony_ci}
12208c2ecf20Sopenharmony_ci
12218c2ecf20Sopenharmony_cistatic int pwrap_write16(struct pmic_wrapper *wrp, u32 adr, u32 wdata)
12228c2ecf20Sopenharmony_ci{
12238c2ecf20Sopenharmony_ci	int ret;
12248c2ecf20Sopenharmony_ci
12258c2ecf20Sopenharmony_ci	ret = pwrap_wait_for_state(wrp, pwrap_is_fsm_idle);
12268c2ecf20Sopenharmony_ci	if (ret) {
12278c2ecf20Sopenharmony_ci		pwrap_leave_fsm_vldclr(wrp);
12288c2ecf20Sopenharmony_ci		return ret;
12298c2ecf20Sopenharmony_ci	}
12308c2ecf20Sopenharmony_ci
12318c2ecf20Sopenharmony_ci	pwrap_writel(wrp, (1 << 31) | ((adr >> 1) << 16) | wdata,
12328c2ecf20Sopenharmony_ci		     PWRAP_WACS2_CMD);
12338c2ecf20Sopenharmony_ci
12348c2ecf20Sopenharmony_ci	return 0;
12358c2ecf20Sopenharmony_ci}
12368c2ecf20Sopenharmony_ci
12378c2ecf20Sopenharmony_cistatic int pwrap_write32(struct pmic_wrapper *wrp, u32 adr, u32 wdata)
12388c2ecf20Sopenharmony_ci{
12398c2ecf20Sopenharmony_ci	int ret, msb, rdata;
12408c2ecf20Sopenharmony_ci
12418c2ecf20Sopenharmony_ci	for (msb = 0; msb < 2; msb++) {
12428c2ecf20Sopenharmony_ci		ret = pwrap_wait_for_state(wrp, pwrap_is_fsm_idle);
12438c2ecf20Sopenharmony_ci		if (ret) {
12448c2ecf20Sopenharmony_ci			pwrap_leave_fsm_vldclr(wrp);
12458c2ecf20Sopenharmony_ci			return ret;
12468c2ecf20Sopenharmony_ci		}
12478c2ecf20Sopenharmony_ci
12488c2ecf20Sopenharmony_ci		pwrap_writel(wrp, (1 << 31) | (msb << 30) | (adr << 16) |
12498c2ecf20Sopenharmony_ci			     ((wdata >> (msb * 16)) & 0xffff),
12508c2ecf20Sopenharmony_ci			     PWRAP_WACS2_CMD);
12518c2ecf20Sopenharmony_ci
12528c2ecf20Sopenharmony_ci		/*
12538c2ecf20Sopenharmony_ci		 * The pwrap_read operation is the requirement of hardware used
12548c2ecf20Sopenharmony_ci		 * for the synchronization between two successive 16-bit
12558c2ecf20Sopenharmony_ci		 * pwrap_writel operations composing one 32-bit bus writing.
12568c2ecf20Sopenharmony_ci		 * Otherwise, we'll find the result fails on the lower 16-bit
12578c2ecf20Sopenharmony_ci		 * pwrap writing.
12588c2ecf20Sopenharmony_ci		 */
12598c2ecf20Sopenharmony_ci		if (!msb)
12608c2ecf20Sopenharmony_ci			pwrap_read(wrp, adr, &rdata);
12618c2ecf20Sopenharmony_ci	}
12628c2ecf20Sopenharmony_ci
12638c2ecf20Sopenharmony_ci	return 0;
12648c2ecf20Sopenharmony_ci}
12658c2ecf20Sopenharmony_ci
12668c2ecf20Sopenharmony_cistatic int pwrap_write(struct pmic_wrapper *wrp, u32 adr, u32 wdata)
12678c2ecf20Sopenharmony_ci{
12688c2ecf20Sopenharmony_ci	return wrp->slave->pwrap_write(wrp, adr, wdata);
12698c2ecf20Sopenharmony_ci}
12708c2ecf20Sopenharmony_ci
12718c2ecf20Sopenharmony_cistatic int pwrap_regmap_read(void *context, u32 adr, u32 *rdata)
12728c2ecf20Sopenharmony_ci{
12738c2ecf20Sopenharmony_ci	return pwrap_read(context, adr, rdata);
12748c2ecf20Sopenharmony_ci}
12758c2ecf20Sopenharmony_ci
12768c2ecf20Sopenharmony_cistatic int pwrap_regmap_write(void *context, u32 adr, u32 wdata)
12778c2ecf20Sopenharmony_ci{
12788c2ecf20Sopenharmony_ci	return pwrap_write(context, adr, wdata);
12798c2ecf20Sopenharmony_ci}
12808c2ecf20Sopenharmony_ci
12818c2ecf20Sopenharmony_cistatic int pwrap_reset_spislave(struct pmic_wrapper *wrp)
12828c2ecf20Sopenharmony_ci{
12838c2ecf20Sopenharmony_ci	int ret, i;
12848c2ecf20Sopenharmony_ci
12858c2ecf20Sopenharmony_ci	pwrap_writel(wrp, 0, PWRAP_HIPRIO_ARB_EN);
12868c2ecf20Sopenharmony_ci	pwrap_writel(wrp, 0, PWRAP_WRAP_EN);
12878c2ecf20Sopenharmony_ci	pwrap_writel(wrp, 1, PWRAP_MUX_SEL);
12888c2ecf20Sopenharmony_ci	pwrap_writel(wrp, 1, PWRAP_MAN_EN);
12898c2ecf20Sopenharmony_ci	pwrap_writel(wrp, 0, PWRAP_DIO_EN);
12908c2ecf20Sopenharmony_ci
12918c2ecf20Sopenharmony_ci	pwrap_writel(wrp, wrp->master->spi_w | PWRAP_MAN_CMD_OP_CSL,
12928c2ecf20Sopenharmony_ci			PWRAP_MAN_CMD);
12938c2ecf20Sopenharmony_ci	pwrap_writel(wrp, wrp->master->spi_w | PWRAP_MAN_CMD_OP_OUTS,
12948c2ecf20Sopenharmony_ci			PWRAP_MAN_CMD);
12958c2ecf20Sopenharmony_ci	pwrap_writel(wrp, wrp->master->spi_w | PWRAP_MAN_CMD_OP_CSH,
12968c2ecf20Sopenharmony_ci			PWRAP_MAN_CMD);
12978c2ecf20Sopenharmony_ci
12988c2ecf20Sopenharmony_ci	for (i = 0; i < 4; i++)
12998c2ecf20Sopenharmony_ci		pwrap_writel(wrp, wrp->master->spi_w | PWRAP_MAN_CMD_OP_OUTS,
13008c2ecf20Sopenharmony_ci				PWRAP_MAN_CMD);
13018c2ecf20Sopenharmony_ci
13028c2ecf20Sopenharmony_ci	ret = pwrap_wait_for_state(wrp, pwrap_is_sync_idle);
13038c2ecf20Sopenharmony_ci	if (ret) {
13048c2ecf20Sopenharmony_ci		dev_err(wrp->dev, "%s fail, ret=%d\n", __func__, ret);
13058c2ecf20Sopenharmony_ci		return ret;
13068c2ecf20Sopenharmony_ci	}
13078c2ecf20Sopenharmony_ci
13088c2ecf20Sopenharmony_ci	pwrap_writel(wrp, 0, PWRAP_MAN_EN);
13098c2ecf20Sopenharmony_ci	pwrap_writel(wrp, 0, PWRAP_MUX_SEL);
13108c2ecf20Sopenharmony_ci
13118c2ecf20Sopenharmony_ci	return 0;
13128c2ecf20Sopenharmony_ci}
13138c2ecf20Sopenharmony_ci
13148c2ecf20Sopenharmony_ci/*
13158c2ecf20Sopenharmony_ci * pwrap_init_sidly - configure serial input delay
13168c2ecf20Sopenharmony_ci *
13178c2ecf20Sopenharmony_ci * This configures the serial input delay. We can configure 0, 2, 4 or 6ns
13188c2ecf20Sopenharmony_ci * delay. Do a read test with all possible values and chose the best delay.
13198c2ecf20Sopenharmony_ci */
13208c2ecf20Sopenharmony_cistatic int pwrap_init_sidly(struct pmic_wrapper *wrp)
13218c2ecf20Sopenharmony_ci{
13228c2ecf20Sopenharmony_ci	u32 rdata;
13238c2ecf20Sopenharmony_ci	u32 i;
13248c2ecf20Sopenharmony_ci	u32 pass = 0;
13258c2ecf20Sopenharmony_ci	signed char dly[16] = {
13268c2ecf20Sopenharmony_ci		-1, 0, 1, 0, 2, -1, 1, 1, 3, -1, -1, -1, 3, -1, 2, 1
13278c2ecf20Sopenharmony_ci	};
13288c2ecf20Sopenharmony_ci
13298c2ecf20Sopenharmony_ci	for (i = 0; i < 4; i++) {
13308c2ecf20Sopenharmony_ci		pwrap_writel(wrp, i, PWRAP_SIDLY);
13318c2ecf20Sopenharmony_ci		pwrap_read(wrp, wrp->slave->dew_regs[PWRAP_DEW_READ_TEST],
13328c2ecf20Sopenharmony_ci			   &rdata);
13338c2ecf20Sopenharmony_ci		if (rdata == PWRAP_DEW_READ_TEST_VAL) {
13348c2ecf20Sopenharmony_ci			dev_dbg(wrp->dev, "[Read Test] pass, SIDLY=%x\n", i);
13358c2ecf20Sopenharmony_ci			pass |= 1 << i;
13368c2ecf20Sopenharmony_ci		}
13378c2ecf20Sopenharmony_ci	}
13388c2ecf20Sopenharmony_ci
13398c2ecf20Sopenharmony_ci	if (dly[pass] < 0) {
13408c2ecf20Sopenharmony_ci		dev_err(wrp->dev, "sidly pass range 0x%x not continuous\n",
13418c2ecf20Sopenharmony_ci				pass);
13428c2ecf20Sopenharmony_ci		return -EIO;
13438c2ecf20Sopenharmony_ci	}
13448c2ecf20Sopenharmony_ci
13458c2ecf20Sopenharmony_ci	pwrap_writel(wrp, dly[pass], PWRAP_SIDLY);
13468c2ecf20Sopenharmony_ci
13478c2ecf20Sopenharmony_ci	return 0;
13488c2ecf20Sopenharmony_ci}
13498c2ecf20Sopenharmony_ci
13508c2ecf20Sopenharmony_cistatic int pwrap_init_dual_io(struct pmic_wrapper *wrp)
13518c2ecf20Sopenharmony_ci{
13528c2ecf20Sopenharmony_ci	int ret;
13538c2ecf20Sopenharmony_ci	u32 rdata;
13548c2ecf20Sopenharmony_ci
13558c2ecf20Sopenharmony_ci	/* Enable dual IO mode */
13568c2ecf20Sopenharmony_ci	pwrap_write(wrp, wrp->slave->dew_regs[PWRAP_DEW_DIO_EN], 1);
13578c2ecf20Sopenharmony_ci
13588c2ecf20Sopenharmony_ci	/* Check IDLE & INIT_DONE in advance */
13598c2ecf20Sopenharmony_ci	ret = pwrap_wait_for_state(wrp,
13608c2ecf20Sopenharmony_ci				   pwrap_is_fsm_idle_and_sync_idle);
13618c2ecf20Sopenharmony_ci	if (ret) {
13628c2ecf20Sopenharmony_ci		dev_err(wrp->dev, "%s fail, ret=%d\n", __func__, ret);
13638c2ecf20Sopenharmony_ci		return ret;
13648c2ecf20Sopenharmony_ci	}
13658c2ecf20Sopenharmony_ci
13668c2ecf20Sopenharmony_ci	pwrap_writel(wrp, 1, PWRAP_DIO_EN);
13678c2ecf20Sopenharmony_ci
13688c2ecf20Sopenharmony_ci	/* Read Test */
13698c2ecf20Sopenharmony_ci	pwrap_read(wrp,
13708c2ecf20Sopenharmony_ci		   wrp->slave->dew_regs[PWRAP_DEW_READ_TEST], &rdata);
13718c2ecf20Sopenharmony_ci	if (rdata != PWRAP_DEW_READ_TEST_VAL) {
13728c2ecf20Sopenharmony_ci		dev_err(wrp->dev,
13738c2ecf20Sopenharmony_ci			"Read failed on DIO mode: 0x%04x!=0x%04x\n",
13748c2ecf20Sopenharmony_ci			PWRAP_DEW_READ_TEST_VAL, rdata);
13758c2ecf20Sopenharmony_ci		return -EFAULT;
13768c2ecf20Sopenharmony_ci	}
13778c2ecf20Sopenharmony_ci
13788c2ecf20Sopenharmony_ci	return 0;
13798c2ecf20Sopenharmony_ci}
13808c2ecf20Sopenharmony_ci
13818c2ecf20Sopenharmony_ci/*
13828c2ecf20Sopenharmony_ci * pwrap_init_chip_select_ext is used to configure CS extension time for each
13838c2ecf20Sopenharmony_ci * phase during data transactions on the pwrap bus.
13848c2ecf20Sopenharmony_ci */
13858c2ecf20Sopenharmony_cistatic void pwrap_init_chip_select_ext(struct pmic_wrapper *wrp, u8 hext_write,
13868c2ecf20Sopenharmony_ci				       u8 hext_read, u8 lext_start,
13878c2ecf20Sopenharmony_ci				       u8 lext_end)
13888c2ecf20Sopenharmony_ci{
13898c2ecf20Sopenharmony_ci	/*
13908c2ecf20Sopenharmony_ci	 * After finishing a write and read transaction, extends CS high time
13918c2ecf20Sopenharmony_ci	 * to be at least xT of BUS CLK as hext_write and hext_read specifies
13928c2ecf20Sopenharmony_ci	 * respectively.
13938c2ecf20Sopenharmony_ci	 */
13948c2ecf20Sopenharmony_ci	pwrap_writel(wrp, hext_write, PWRAP_CSHEXT_WRITE);
13958c2ecf20Sopenharmony_ci	pwrap_writel(wrp, hext_read, PWRAP_CSHEXT_READ);
13968c2ecf20Sopenharmony_ci
13978c2ecf20Sopenharmony_ci	/*
13988c2ecf20Sopenharmony_ci	 * Extends CS low time after CSL and before CSH command to be at
13998c2ecf20Sopenharmony_ci	 * least xT of BUS CLK as lext_start and lext_end specifies
14008c2ecf20Sopenharmony_ci	 * respectively.
14018c2ecf20Sopenharmony_ci	 */
14028c2ecf20Sopenharmony_ci	pwrap_writel(wrp, lext_start, PWRAP_CSLEXT_START);
14038c2ecf20Sopenharmony_ci	pwrap_writel(wrp, lext_end, PWRAP_CSLEXT_END);
14048c2ecf20Sopenharmony_ci}
14058c2ecf20Sopenharmony_ci
14068c2ecf20Sopenharmony_cistatic int pwrap_common_init_reg_clock(struct pmic_wrapper *wrp)
14078c2ecf20Sopenharmony_ci{
14088c2ecf20Sopenharmony_ci	switch (wrp->master->type) {
14098c2ecf20Sopenharmony_ci	case PWRAP_MT8173:
14108c2ecf20Sopenharmony_ci		pwrap_init_chip_select_ext(wrp, 0, 4, 2, 2);
14118c2ecf20Sopenharmony_ci		break;
14128c2ecf20Sopenharmony_ci	case PWRAP_MT8135:
14138c2ecf20Sopenharmony_ci		pwrap_writel(wrp, 0x4, PWRAP_CSHEXT);
14148c2ecf20Sopenharmony_ci		pwrap_init_chip_select_ext(wrp, 0, 4, 0, 0);
14158c2ecf20Sopenharmony_ci		break;
14168c2ecf20Sopenharmony_ci	default:
14178c2ecf20Sopenharmony_ci		break;
14188c2ecf20Sopenharmony_ci	}
14198c2ecf20Sopenharmony_ci
14208c2ecf20Sopenharmony_ci	return 0;
14218c2ecf20Sopenharmony_ci}
14228c2ecf20Sopenharmony_ci
14238c2ecf20Sopenharmony_cistatic int pwrap_mt2701_init_reg_clock(struct pmic_wrapper *wrp)
14248c2ecf20Sopenharmony_ci{
14258c2ecf20Sopenharmony_ci	switch (wrp->slave->type) {
14268c2ecf20Sopenharmony_ci	case PMIC_MT6397:
14278c2ecf20Sopenharmony_ci		pwrap_writel(wrp, 0xc, PWRAP_RDDMY);
14288c2ecf20Sopenharmony_ci		pwrap_init_chip_select_ext(wrp, 4, 0, 2, 2);
14298c2ecf20Sopenharmony_ci		break;
14308c2ecf20Sopenharmony_ci
14318c2ecf20Sopenharmony_ci	case PMIC_MT6323:
14328c2ecf20Sopenharmony_ci		pwrap_writel(wrp, 0x8, PWRAP_RDDMY);
14338c2ecf20Sopenharmony_ci		pwrap_write(wrp, wrp->slave->dew_regs[PWRAP_DEW_RDDMY_NO],
14348c2ecf20Sopenharmony_ci			    0x8);
14358c2ecf20Sopenharmony_ci		pwrap_init_chip_select_ext(wrp, 5, 0, 2, 2);
14368c2ecf20Sopenharmony_ci		break;
14378c2ecf20Sopenharmony_ci	default:
14388c2ecf20Sopenharmony_ci		break;
14398c2ecf20Sopenharmony_ci	}
14408c2ecf20Sopenharmony_ci
14418c2ecf20Sopenharmony_ci	return 0;
14428c2ecf20Sopenharmony_ci}
14438c2ecf20Sopenharmony_ci
14448c2ecf20Sopenharmony_cistatic bool pwrap_is_cipher_ready(struct pmic_wrapper *wrp)
14458c2ecf20Sopenharmony_ci{
14468c2ecf20Sopenharmony_ci	return pwrap_readl(wrp, PWRAP_CIPHER_RDY) & 1;
14478c2ecf20Sopenharmony_ci}
14488c2ecf20Sopenharmony_ci
14498c2ecf20Sopenharmony_cistatic bool pwrap_is_pmic_cipher_ready(struct pmic_wrapper *wrp)
14508c2ecf20Sopenharmony_ci{
14518c2ecf20Sopenharmony_ci	u32 rdata;
14528c2ecf20Sopenharmony_ci	int ret;
14538c2ecf20Sopenharmony_ci
14548c2ecf20Sopenharmony_ci	ret = pwrap_read(wrp, wrp->slave->dew_regs[PWRAP_DEW_CIPHER_RDY],
14558c2ecf20Sopenharmony_ci			 &rdata);
14568c2ecf20Sopenharmony_ci	if (ret)
14578c2ecf20Sopenharmony_ci		return false;
14588c2ecf20Sopenharmony_ci
14598c2ecf20Sopenharmony_ci	return rdata == 1;
14608c2ecf20Sopenharmony_ci}
14618c2ecf20Sopenharmony_ci
14628c2ecf20Sopenharmony_cistatic int pwrap_init_cipher(struct pmic_wrapper *wrp)
14638c2ecf20Sopenharmony_ci{
14648c2ecf20Sopenharmony_ci	int ret;
14658c2ecf20Sopenharmony_ci	u32 rdata = 0;
14668c2ecf20Sopenharmony_ci
14678c2ecf20Sopenharmony_ci	pwrap_writel(wrp, 0x1, PWRAP_CIPHER_SWRST);
14688c2ecf20Sopenharmony_ci	pwrap_writel(wrp, 0x0, PWRAP_CIPHER_SWRST);
14698c2ecf20Sopenharmony_ci	pwrap_writel(wrp, 0x1, PWRAP_CIPHER_KEY_SEL);
14708c2ecf20Sopenharmony_ci	pwrap_writel(wrp, 0x2, PWRAP_CIPHER_IV_SEL);
14718c2ecf20Sopenharmony_ci
14728c2ecf20Sopenharmony_ci	switch (wrp->master->type) {
14738c2ecf20Sopenharmony_ci	case PWRAP_MT8135:
14748c2ecf20Sopenharmony_ci		pwrap_writel(wrp, 1, PWRAP_CIPHER_LOAD);
14758c2ecf20Sopenharmony_ci		pwrap_writel(wrp, 1, PWRAP_CIPHER_START);
14768c2ecf20Sopenharmony_ci		break;
14778c2ecf20Sopenharmony_ci	case PWRAP_MT2701:
14788c2ecf20Sopenharmony_ci	case PWRAP_MT6765:
14798c2ecf20Sopenharmony_ci	case PWRAP_MT6779:
14808c2ecf20Sopenharmony_ci	case PWRAP_MT6797:
14818c2ecf20Sopenharmony_ci	case PWRAP_MT8173:
14828c2ecf20Sopenharmony_ci	case PWRAP_MT8516:
14838c2ecf20Sopenharmony_ci		pwrap_writel(wrp, 1, PWRAP_CIPHER_EN);
14848c2ecf20Sopenharmony_ci		break;
14858c2ecf20Sopenharmony_ci	case PWRAP_MT7622:
14868c2ecf20Sopenharmony_ci		pwrap_writel(wrp, 0, PWRAP_CIPHER_EN);
14878c2ecf20Sopenharmony_ci		break;
14888c2ecf20Sopenharmony_ci	case PWRAP_MT8183:
14898c2ecf20Sopenharmony_ci		break;
14908c2ecf20Sopenharmony_ci	}
14918c2ecf20Sopenharmony_ci
14928c2ecf20Sopenharmony_ci	/* Config cipher mode @PMIC */
14938c2ecf20Sopenharmony_ci	pwrap_write(wrp, wrp->slave->dew_regs[PWRAP_DEW_CIPHER_SWRST], 0x1);
14948c2ecf20Sopenharmony_ci	pwrap_write(wrp, wrp->slave->dew_regs[PWRAP_DEW_CIPHER_SWRST], 0x0);
14958c2ecf20Sopenharmony_ci	pwrap_write(wrp, wrp->slave->dew_regs[PWRAP_DEW_CIPHER_KEY_SEL], 0x1);
14968c2ecf20Sopenharmony_ci	pwrap_write(wrp, wrp->slave->dew_regs[PWRAP_DEW_CIPHER_IV_SEL], 0x2);
14978c2ecf20Sopenharmony_ci
14988c2ecf20Sopenharmony_ci	switch (wrp->slave->type) {
14998c2ecf20Sopenharmony_ci	case PMIC_MT6397:
15008c2ecf20Sopenharmony_ci		pwrap_write(wrp, wrp->slave->dew_regs[PWRAP_DEW_CIPHER_LOAD],
15018c2ecf20Sopenharmony_ci			    0x1);
15028c2ecf20Sopenharmony_ci		pwrap_write(wrp, wrp->slave->dew_regs[PWRAP_DEW_CIPHER_START],
15038c2ecf20Sopenharmony_ci			    0x1);
15048c2ecf20Sopenharmony_ci		break;
15058c2ecf20Sopenharmony_ci	case PMIC_MT6323:
15068c2ecf20Sopenharmony_ci	case PMIC_MT6351:
15078c2ecf20Sopenharmony_ci	case PMIC_MT6357:
15088c2ecf20Sopenharmony_ci		pwrap_write(wrp, wrp->slave->dew_regs[PWRAP_DEW_CIPHER_EN],
15098c2ecf20Sopenharmony_ci			    0x1);
15108c2ecf20Sopenharmony_ci		break;
15118c2ecf20Sopenharmony_ci	default:
15128c2ecf20Sopenharmony_ci		break;
15138c2ecf20Sopenharmony_ci	}
15148c2ecf20Sopenharmony_ci
15158c2ecf20Sopenharmony_ci	/* wait for cipher data ready@AP */
15168c2ecf20Sopenharmony_ci	ret = pwrap_wait_for_state(wrp, pwrap_is_cipher_ready);
15178c2ecf20Sopenharmony_ci	if (ret) {
15188c2ecf20Sopenharmony_ci		dev_err(wrp->dev, "cipher data ready@AP fail, ret=%d\n", ret);
15198c2ecf20Sopenharmony_ci		return ret;
15208c2ecf20Sopenharmony_ci	}
15218c2ecf20Sopenharmony_ci
15228c2ecf20Sopenharmony_ci	/* wait for cipher data ready@PMIC */
15238c2ecf20Sopenharmony_ci	ret = pwrap_wait_for_state(wrp, pwrap_is_pmic_cipher_ready);
15248c2ecf20Sopenharmony_ci	if (ret) {
15258c2ecf20Sopenharmony_ci		dev_err(wrp->dev,
15268c2ecf20Sopenharmony_ci			"timeout waiting for cipher data ready@PMIC\n");
15278c2ecf20Sopenharmony_ci		return ret;
15288c2ecf20Sopenharmony_ci	}
15298c2ecf20Sopenharmony_ci
15308c2ecf20Sopenharmony_ci	/* wait for cipher mode idle */
15318c2ecf20Sopenharmony_ci	pwrap_write(wrp, wrp->slave->dew_regs[PWRAP_DEW_CIPHER_MODE], 0x1);
15328c2ecf20Sopenharmony_ci	ret = pwrap_wait_for_state(wrp, pwrap_is_fsm_idle_and_sync_idle);
15338c2ecf20Sopenharmony_ci	if (ret) {
15348c2ecf20Sopenharmony_ci		dev_err(wrp->dev, "cipher mode idle fail, ret=%d\n", ret);
15358c2ecf20Sopenharmony_ci		return ret;
15368c2ecf20Sopenharmony_ci	}
15378c2ecf20Sopenharmony_ci
15388c2ecf20Sopenharmony_ci	pwrap_writel(wrp, 1, PWRAP_CIPHER_MODE);
15398c2ecf20Sopenharmony_ci
15408c2ecf20Sopenharmony_ci	/* Write Test */
15418c2ecf20Sopenharmony_ci	if (pwrap_write(wrp, wrp->slave->dew_regs[PWRAP_DEW_WRITE_TEST],
15428c2ecf20Sopenharmony_ci			PWRAP_DEW_WRITE_TEST_VAL) ||
15438c2ecf20Sopenharmony_ci	    pwrap_read(wrp, wrp->slave->dew_regs[PWRAP_DEW_WRITE_TEST],
15448c2ecf20Sopenharmony_ci		       &rdata) ||
15458c2ecf20Sopenharmony_ci	    (rdata != PWRAP_DEW_WRITE_TEST_VAL)) {
15468c2ecf20Sopenharmony_ci		dev_err(wrp->dev, "rdata=0x%04X\n", rdata);
15478c2ecf20Sopenharmony_ci		return -EFAULT;
15488c2ecf20Sopenharmony_ci	}
15498c2ecf20Sopenharmony_ci
15508c2ecf20Sopenharmony_ci	return 0;
15518c2ecf20Sopenharmony_ci}
15528c2ecf20Sopenharmony_ci
15538c2ecf20Sopenharmony_cistatic int pwrap_init_security(struct pmic_wrapper *wrp)
15548c2ecf20Sopenharmony_ci{
15558c2ecf20Sopenharmony_ci	int ret;
15568c2ecf20Sopenharmony_ci
15578c2ecf20Sopenharmony_ci	/* Enable encryption */
15588c2ecf20Sopenharmony_ci	ret = pwrap_init_cipher(wrp);
15598c2ecf20Sopenharmony_ci	if (ret)
15608c2ecf20Sopenharmony_ci		return ret;
15618c2ecf20Sopenharmony_ci
15628c2ecf20Sopenharmony_ci	/* Signature checking - using CRC */
15638c2ecf20Sopenharmony_ci	if (pwrap_write(wrp,
15648c2ecf20Sopenharmony_ci			wrp->slave->dew_regs[PWRAP_DEW_CRC_EN], 0x1))
15658c2ecf20Sopenharmony_ci		return -EFAULT;
15668c2ecf20Sopenharmony_ci
15678c2ecf20Sopenharmony_ci	pwrap_writel(wrp, 0x1, PWRAP_CRC_EN);
15688c2ecf20Sopenharmony_ci	pwrap_writel(wrp, 0x0, PWRAP_SIG_MODE);
15698c2ecf20Sopenharmony_ci	pwrap_writel(wrp, wrp->slave->dew_regs[PWRAP_DEW_CRC_VAL],
15708c2ecf20Sopenharmony_ci		     PWRAP_SIG_ADR);
15718c2ecf20Sopenharmony_ci	pwrap_writel(wrp,
15728c2ecf20Sopenharmony_ci		     wrp->master->arb_en_all, PWRAP_HIPRIO_ARB_EN);
15738c2ecf20Sopenharmony_ci
15748c2ecf20Sopenharmony_ci	return 0;
15758c2ecf20Sopenharmony_ci}
15768c2ecf20Sopenharmony_ci
15778c2ecf20Sopenharmony_cistatic int pwrap_mt8135_init_soc_specific(struct pmic_wrapper *wrp)
15788c2ecf20Sopenharmony_ci{
15798c2ecf20Sopenharmony_ci	/* enable pwrap events and pwrap bridge in AP side */
15808c2ecf20Sopenharmony_ci	pwrap_writel(wrp, 0x1, PWRAP_EVENT_IN_EN);
15818c2ecf20Sopenharmony_ci	pwrap_writel(wrp, 0xffff, PWRAP_EVENT_DST_EN);
15828c2ecf20Sopenharmony_ci	writel(0x7f, wrp->bridge_base + PWRAP_MT8135_BRIDGE_IORD_ARB_EN);
15838c2ecf20Sopenharmony_ci	writel(0x1, wrp->bridge_base + PWRAP_MT8135_BRIDGE_WACS3_EN);
15848c2ecf20Sopenharmony_ci	writel(0x1, wrp->bridge_base + PWRAP_MT8135_BRIDGE_WACS4_EN);
15858c2ecf20Sopenharmony_ci	writel(0x1, wrp->bridge_base + PWRAP_MT8135_BRIDGE_WDT_UNIT);
15868c2ecf20Sopenharmony_ci	writel(0xffff, wrp->bridge_base + PWRAP_MT8135_BRIDGE_WDT_SRC_EN);
15878c2ecf20Sopenharmony_ci	writel(0x1, wrp->bridge_base + PWRAP_MT8135_BRIDGE_TIMER_EN);
15888c2ecf20Sopenharmony_ci	writel(0x7ff, wrp->bridge_base + PWRAP_MT8135_BRIDGE_INT_EN);
15898c2ecf20Sopenharmony_ci
15908c2ecf20Sopenharmony_ci	/* enable PMIC event out and sources */
15918c2ecf20Sopenharmony_ci	if (pwrap_write(wrp, wrp->slave->dew_regs[PWRAP_DEW_EVENT_OUT_EN],
15928c2ecf20Sopenharmony_ci			0x1) ||
15938c2ecf20Sopenharmony_ci	    pwrap_write(wrp, wrp->slave->dew_regs[PWRAP_DEW_EVENT_SRC_EN],
15948c2ecf20Sopenharmony_ci			0xffff)) {
15958c2ecf20Sopenharmony_ci		dev_err(wrp->dev, "enable dewrap fail\n");
15968c2ecf20Sopenharmony_ci		return -EFAULT;
15978c2ecf20Sopenharmony_ci	}
15988c2ecf20Sopenharmony_ci
15998c2ecf20Sopenharmony_ci	return 0;
16008c2ecf20Sopenharmony_ci}
16018c2ecf20Sopenharmony_ci
16028c2ecf20Sopenharmony_cistatic int pwrap_mt8173_init_soc_specific(struct pmic_wrapper *wrp)
16038c2ecf20Sopenharmony_ci{
16048c2ecf20Sopenharmony_ci	/* PMIC_DEWRAP enables */
16058c2ecf20Sopenharmony_ci	if (pwrap_write(wrp, wrp->slave->dew_regs[PWRAP_DEW_EVENT_OUT_EN],
16068c2ecf20Sopenharmony_ci			0x1) ||
16078c2ecf20Sopenharmony_ci	    pwrap_write(wrp, wrp->slave->dew_regs[PWRAP_DEW_EVENT_SRC_EN],
16088c2ecf20Sopenharmony_ci			0xffff)) {
16098c2ecf20Sopenharmony_ci		dev_err(wrp->dev, "enable dewrap fail\n");
16108c2ecf20Sopenharmony_ci		return -EFAULT;
16118c2ecf20Sopenharmony_ci	}
16128c2ecf20Sopenharmony_ci
16138c2ecf20Sopenharmony_ci	return 0;
16148c2ecf20Sopenharmony_ci}
16158c2ecf20Sopenharmony_ci
16168c2ecf20Sopenharmony_cistatic int pwrap_mt2701_init_soc_specific(struct pmic_wrapper *wrp)
16178c2ecf20Sopenharmony_ci{
16188c2ecf20Sopenharmony_ci	/* GPS_INTF initialization */
16198c2ecf20Sopenharmony_ci	switch (wrp->slave->type) {
16208c2ecf20Sopenharmony_ci	case PMIC_MT6323:
16218c2ecf20Sopenharmony_ci		pwrap_writel(wrp, 0x076c, PWRAP_ADC_CMD_ADDR);
16228c2ecf20Sopenharmony_ci		pwrap_writel(wrp, 0x8000, PWRAP_PWRAP_ADC_CMD);
16238c2ecf20Sopenharmony_ci		pwrap_writel(wrp, 0x072c, PWRAP_ADC_RDY_ADDR);
16248c2ecf20Sopenharmony_ci		pwrap_writel(wrp, 0x072e, PWRAP_ADC_RDATA_ADDR1);
16258c2ecf20Sopenharmony_ci		pwrap_writel(wrp, 0x0730, PWRAP_ADC_RDATA_ADDR2);
16268c2ecf20Sopenharmony_ci		break;
16278c2ecf20Sopenharmony_ci	default:
16288c2ecf20Sopenharmony_ci		break;
16298c2ecf20Sopenharmony_ci	}
16308c2ecf20Sopenharmony_ci
16318c2ecf20Sopenharmony_ci	return 0;
16328c2ecf20Sopenharmony_ci}
16338c2ecf20Sopenharmony_ci
16348c2ecf20Sopenharmony_cistatic int pwrap_mt7622_init_soc_specific(struct pmic_wrapper *wrp)
16358c2ecf20Sopenharmony_ci{
16368c2ecf20Sopenharmony_ci	pwrap_writel(wrp, 0, PWRAP_STAUPD_PRD);
16378c2ecf20Sopenharmony_ci	/* enable 2wire SPI master */
16388c2ecf20Sopenharmony_ci	pwrap_writel(wrp, 0x8000000, PWRAP_SPI2_CTRL);
16398c2ecf20Sopenharmony_ci
16408c2ecf20Sopenharmony_ci	return 0;
16418c2ecf20Sopenharmony_ci}
16428c2ecf20Sopenharmony_ci
16438c2ecf20Sopenharmony_cistatic int pwrap_mt8183_init_soc_specific(struct pmic_wrapper *wrp)
16448c2ecf20Sopenharmony_ci{
16458c2ecf20Sopenharmony_ci	pwrap_writel(wrp, 0xf5, PWRAP_STAUPD_GRPEN);
16468c2ecf20Sopenharmony_ci
16478c2ecf20Sopenharmony_ci	pwrap_write(wrp, wrp->slave->dew_regs[PWRAP_DEW_CRC_EN], 0x1);
16488c2ecf20Sopenharmony_ci	pwrap_writel(wrp, 1, PWRAP_CRC_EN);
16498c2ecf20Sopenharmony_ci	pwrap_writel(wrp, 0x416, PWRAP_SIG_ADR);
16508c2ecf20Sopenharmony_ci	pwrap_writel(wrp, 0x42e, PWRAP_EINT_STA0_ADR);
16518c2ecf20Sopenharmony_ci
16528c2ecf20Sopenharmony_ci	pwrap_writel(wrp, 1, PWRAP_WACS_P2P_EN);
16538c2ecf20Sopenharmony_ci	pwrap_writel(wrp, 1, PWRAP_WACS_MD32_EN);
16548c2ecf20Sopenharmony_ci	pwrap_writel(wrp, 1, PWRAP_INIT_DONE_P2P);
16558c2ecf20Sopenharmony_ci	pwrap_writel(wrp, 1, PWRAP_INIT_DONE_MD32);
16568c2ecf20Sopenharmony_ci
16578c2ecf20Sopenharmony_ci	return 0;
16588c2ecf20Sopenharmony_ci}
16598c2ecf20Sopenharmony_ci
16608c2ecf20Sopenharmony_cistatic int pwrap_init(struct pmic_wrapper *wrp)
16618c2ecf20Sopenharmony_ci{
16628c2ecf20Sopenharmony_ci	int ret;
16638c2ecf20Sopenharmony_ci
16648c2ecf20Sopenharmony_ci	if (wrp->rstc)
16658c2ecf20Sopenharmony_ci		reset_control_reset(wrp->rstc);
16668c2ecf20Sopenharmony_ci	if (wrp->rstc_bridge)
16678c2ecf20Sopenharmony_ci		reset_control_reset(wrp->rstc_bridge);
16688c2ecf20Sopenharmony_ci
16698c2ecf20Sopenharmony_ci	if (wrp->master->type == PWRAP_MT8173) {
16708c2ecf20Sopenharmony_ci		/* Enable DCM */
16718c2ecf20Sopenharmony_ci		pwrap_writel(wrp, 3, PWRAP_DCM_EN);
16728c2ecf20Sopenharmony_ci		pwrap_writel(wrp, 0, PWRAP_DCM_DBC_PRD);
16738c2ecf20Sopenharmony_ci	}
16748c2ecf20Sopenharmony_ci
16758c2ecf20Sopenharmony_ci	if (HAS_CAP(wrp->slave->caps, PWRAP_SLV_CAP_SPI)) {
16768c2ecf20Sopenharmony_ci		/* Reset SPI slave */
16778c2ecf20Sopenharmony_ci		ret = pwrap_reset_spislave(wrp);
16788c2ecf20Sopenharmony_ci		if (ret)
16798c2ecf20Sopenharmony_ci			return ret;
16808c2ecf20Sopenharmony_ci	}
16818c2ecf20Sopenharmony_ci
16828c2ecf20Sopenharmony_ci	pwrap_writel(wrp, 1, PWRAP_WRAP_EN);
16838c2ecf20Sopenharmony_ci
16848c2ecf20Sopenharmony_ci	pwrap_writel(wrp, wrp->master->arb_en_all, PWRAP_HIPRIO_ARB_EN);
16858c2ecf20Sopenharmony_ci
16868c2ecf20Sopenharmony_ci	pwrap_writel(wrp, 1, PWRAP_WACS2_EN);
16878c2ecf20Sopenharmony_ci
16888c2ecf20Sopenharmony_ci	ret = wrp->master->init_reg_clock(wrp);
16898c2ecf20Sopenharmony_ci	if (ret)
16908c2ecf20Sopenharmony_ci		return ret;
16918c2ecf20Sopenharmony_ci
16928c2ecf20Sopenharmony_ci	if (HAS_CAP(wrp->slave->caps, PWRAP_SLV_CAP_SPI)) {
16938c2ecf20Sopenharmony_ci		/* Setup serial input delay */
16948c2ecf20Sopenharmony_ci		ret = pwrap_init_sidly(wrp);
16958c2ecf20Sopenharmony_ci		if (ret)
16968c2ecf20Sopenharmony_ci			return ret;
16978c2ecf20Sopenharmony_ci	}
16988c2ecf20Sopenharmony_ci
16998c2ecf20Sopenharmony_ci	if (HAS_CAP(wrp->slave->caps, PWRAP_SLV_CAP_DUALIO)) {
17008c2ecf20Sopenharmony_ci		/* Enable dual I/O mode */
17018c2ecf20Sopenharmony_ci		ret = pwrap_init_dual_io(wrp);
17028c2ecf20Sopenharmony_ci		if (ret)
17038c2ecf20Sopenharmony_ci			return ret;
17048c2ecf20Sopenharmony_ci	}
17058c2ecf20Sopenharmony_ci
17068c2ecf20Sopenharmony_ci	if (HAS_CAP(wrp->slave->caps, PWRAP_SLV_CAP_SECURITY)) {
17078c2ecf20Sopenharmony_ci		/* Enable security on bus */
17088c2ecf20Sopenharmony_ci		ret = pwrap_init_security(wrp);
17098c2ecf20Sopenharmony_ci		if (ret)
17108c2ecf20Sopenharmony_ci			return ret;
17118c2ecf20Sopenharmony_ci	}
17128c2ecf20Sopenharmony_ci
17138c2ecf20Sopenharmony_ci	if (wrp->master->type == PWRAP_MT8135)
17148c2ecf20Sopenharmony_ci		pwrap_writel(wrp, 0x7, PWRAP_RRARB_EN);
17158c2ecf20Sopenharmony_ci
17168c2ecf20Sopenharmony_ci	pwrap_writel(wrp, 0x1, PWRAP_WACS0_EN);
17178c2ecf20Sopenharmony_ci	pwrap_writel(wrp, 0x1, PWRAP_WACS1_EN);
17188c2ecf20Sopenharmony_ci	pwrap_writel(wrp, 0x1, PWRAP_WACS2_EN);
17198c2ecf20Sopenharmony_ci	pwrap_writel(wrp, 0x5, PWRAP_STAUPD_PRD);
17208c2ecf20Sopenharmony_ci	pwrap_writel(wrp, 0xff, PWRAP_STAUPD_GRPEN);
17218c2ecf20Sopenharmony_ci
17228c2ecf20Sopenharmony_ci	if (wrp->master->init_soc_specific) {
17238c2ecf20Sopenharmony_ci		ret = wrp->master->init_soc_specific(wrp);
17248c2ecf20Sopenharmony_ci		if (ret)
17258c2ecf20Sopenharmony_ci			return ret;
17268c2ecf20Sopenharmony_ci	}
17278c2ecf20Sopenharmony_ci
17288c2ecf20Sopenharmony_ci	/* Setup the init done registers */
17298c2ecf20Sopenharmony_ci	pwrap_writel(wrp, 1, PWRAP_INIT_DONE2);
17308c2ecf20Sopenharmony_ci	pwrap_writel(wrp, 1, PWRAP_INIT_DONE0);
17318c2ecf20Sopenharmony_ci	pwrap_writel(wrp, 1, PWRAP_INIT_DONE1);
17328c2ecf20Sopenharmony_ci
17338c2ecf20Sopenharmony_ci	if (HAS_CAP(wrp->master->caps, PWRAP_CAP_BRIDGE)) {
17348c2ecf20Sopenharmony_ci		writel(1, wrp->bridge_base + PWRAP_MT8135_BRIDGE_INIT_DONE3);
17358c2ecf20Sopenharmony_ci		writel(1, wrp->bridge_base + PWRAP_MT8135_BRIDGE_INIT_DONE4);
17368c2ecf20Sopenharmony_ci	}
17378c2ecf20Sopenharmony_ci
17388c2ecf20Sopenharmony_ci	return 0;
17398c2ecf20Sopenharmony_ci}
17408c2ecf20Sopenharmony_ci
17418c2ecf20Sopenharmony_cistatic irqreturn_t pwrap_interrupt(int irqno, void *dev_id)
17428c2ecf20Sopenharmony_ci{
17438c2ecf20Sopenharmony_ci	u32 rdata;
17448c2ecf20Sopenharmony_ci	struct pmic_wrapper *wrp = dev_id;
17458c2ecf20Sopenharmony_ci
17468c2ecf20Sopenharmony_ci	rdata = pwrap_readl(wrp, PWRAP_INT_FLG);
17478c2ecf20Sopenharmony_ci	dev_err(wrp->dev, "unexpected interrupt int=0x%x\n", rdata);
17488c2ecf20Sopenharmony_ci	pwrap_writel(wrp, 0xffffffff, PWRAP_INT_CLR);
17498c2ecf20Sopenharmony_ci
17508c2ecf20Sopenharmony_ci	if (HAS_CAP(wrp->master->caps, PWRAP_CAP_INT1_EN)) {
17518c2ecf20Sopenharmony_ci		rdata = pwrap_readl(wrp, PWRAP_INT1_FLG);
17528c2ecf20Sopenharmony_ci		dev_err(wrp->dev, "unexpected interrupt int1=0x%x\n", rdata);
17538c2ecf20Sopenharmony_ci		pwrap_writel(wrp, 0xffffffff, PWRAP_INT1_CLR);
17548c2ecf20Sopenharmony_ci	}
17558c2ecf20Sopenharmony_ci
17568c2ecf20Sopenharmony_ci	return IRQ_HANDLED;
17578c2ecf20Sopenharmony_ci}
17588c2ecf20Sopenharmony_ci
17598c2ecf20Sopenharmony_cistatic const struct regmap_config pwrap_regmap_config16 = {
17608c2ecf20Sopenharmony_ci	.reg_bits = 16,
17618c2ecf20Sopenharmony_ci	.val_bits = 16,
17628c2ecf20Sopenharmony_ci	.reg_stride = 2,
17638c2ecf20Sopenharmony_ci	.reg_read = pwrap_regmap_read,
17648c2ecf20Sopenharmony_ci	.reg_write = pwrap_regmap_write,
17658c2ecf20Sopenharmony_ci	.max_register = 0xffff,
17668c2ecf20Sopenharmony_ci};
17678c2ecf20Sopenharmony_ci
17688c2ecf20Sopenharmony_cistatic const struct regmap_config pwrap_regmap_config32 = {
17698c2ecf20Sopenharmony_ci	.reg_bits = 32,
17708c2ecf20Sopenharmony_ci	.val_bits = 32,
17718c2ecf20Sopenharmony_ci	.reg_stride = 4,
17728c2ecf20Sopenharmony_ci	.reg_read = pwrap_regmap_read,
17738c2ecf20Sopenharmony_ci	.reg_write = pwrap_regmap_write,
17748c2ecf20Sopenharmony_ci	.max_register = 0xffff,
17758c2ecf20Sopenharmony_ci};
17768c2ecf20Sopenharmony_ci
17778c2ecf20Sopenharmony_cistatic const struct pwrap_slv_type pmic_mt6323 = {
17788c2ecf20Sopenharmony_ci	.dew_regs = mt6323_regs,
17798c2ecf20Sopenharmony_ci	.type = PMIC_MT6323,
17808c2ecf20Sopenharmony_ci	.regmap = &pwrap_regmap_config16,
17818c2ecf20Sopenharmony_ci	.caps = PWRAP_SLV_CAP_SPI | PWRAP_SLV_CAP_DUALIO |
17828c2ecf20Sopenharmony_ci		PWRAP_SLV_CAP_SECURITY,
17838c2ecf20Sopenharmony_ci	.pwrap_read = pwrap_read16,
17848c2ecf20Sopenharmony_ci	.pwrap_write = pwrap_write16,
17858c2ecf20Sopenharmony_ci};
17868c2ecf20Sopenharmony_ci
17878c2ecf20Sopenharmony_cistatic const struct pwrap_slv_type pmic_mt6351 = {
17888c2ecf20Sopenharmony_ci	.dew_regs = mt6351_regs,
17898c2ecf20Sopenharmony_ci	.type = PMIC_MT6351,
17908c2ecf20Sopenharmony_ci	.regmap = &pwrap_regmap_config16,
17918c2ecf20Sopenharmony_ci	.caps = 0,
17928c2ecf20Sopenharmony_ci	.pwrap_read = pwrap_read16,
17938c2ecf20Sopenharmony_ci	.pwrap_write = pwrap_write16,
17948c2ecf20Sopenharmony_ci};
17958c2ecf20Sopenharmony_ci
17968c2ecf20Sopenharmony_cistatic const struct pwrap_slv_type pmic_mt6357 = {
17978c2ecf20Sopenharmony_ci	.dew_regs = mt6357_regs,
17988c2ecf20Sopenharmony_ci	.type = PMIC_MT6357,
17998c2ecf20Sopenharmony_ci	.regmap = &pwrap_regmap_config16,
18008c2ecf20Sopenharmony_ci	.caps = 0,
18018c2ecf20Sopenharmony_ci	.pwrap_read = pwrap_read16,
18028c2ecf20Sopenharmony_ci	.pwrap_write = pwrap_write16,
18038c2ecf20Sopenharmony_ci};
18048c2ecf20Sopenharmony_ci
18058c2ecf20Sopenharmony_cistatic const struct pwrap_slv_type pmic_mt6358 = {
18068c2ecf20Sopenharmony_ci	.dew_regs = mt6358_regs,
18078c2ecf20Sopenharmony_ci	.type = PMIC_MT6358,
18088c2ecf20Sopenharmony_ci	.regmap = &pwrap_regmap_config16,
18098c2ecf20Sopenharmony_ci	.caps = PWRAP_SLV_CAP_SPI | PWRAP_SLV_CAP_DUALIO,
18108c2ecf20Sopenharmony_ci	.pwrap_read = pwrap_read16,
18118c2ecf20Sopenharmony_ci	.pwrap_write = pwrap_write16,
18128c2ecf20Sopenharmony_ci};
18138c2ecf20Sopenharmony_ci
18148c2ecf20Sopenharmony_cistatic const struct pwrap_slv_type pmic_mt6359 = {
18158c2ecf20Sopenharmony_ci	.dew_regs = mt6359_regs,
18168c2ecf20Sopenharmony_ci	.type = PMIC_MT6359,
18178c2ecf20Sopenharmony_ci	.regmap = &pwrap_regmap_config16,
18188c2ecf20Sopenharmony_ci	.caps = PWRAP_SLV_CAP_DUALIO,
18198c2ecf20Sopenharmony_ci	.pwrap_read = pwrap_read16,
18208c2ecf20Sopenharmony_ci	.pwrap_write = pwrap_write16,
18218c2ecf20Sopenharmony_ci};
18228c2ecf20Sopenharmony_ci
18238c2ecf20Sopenharmony_cistatic const struct pwrap_slv_type pmic_mt6380 = {
18248c2ecf20Sopenharmony_ci	.dew_regs = NULL,
18258c2ecf20Sopenharmony_ci	.type = PMIC_MT6380,
18268c2ecf20Sopenharmony_ci	.regmap = &pwrap_regmap_config32,
18278c2ecf20Sopenharmony_ci	.caps = 0,
18288c2ecf20Sopenharmony_ci	.pwrap_read = pwrap_read32,
18298c2ecf20Sopenharmony_ci	.pwrap_write = pwrap_write32,
18308c2ecf20Sopenharmony_ci};
18318c2ecf20Sopenharmony_ci
18328c2ecf20Sopenharmony_cistatic const struct pwrap_slv_type pmic_mt6397 = {
18338c2ecf20Sopenharmony_ci	.dew_regs = mt6397_regs,
18348c2ecf20Sopenharmony_ci	.type = PMIC_MT6397,
18358c2ecf20Sopenharmony_ci	.regmap = &pwrap_regmap_config16,
18368c2ecf20Sopenharmony_ci	.caps = PWRAP_SLV_CAP_SPI | PWRAP_SLV_CAP_DUALIO |
18378c2ecf20Sopenharmony_ci		PWRAP_SLV_CAP_SECURITY,
18388c2ecf20Sopenharmony_ci	.pwrap_read = pwrap_read16,
18398c2ecf20Sopenharmony_ci	.pwrap_write = pwrap_write16,
18408c2ecf20Sopenharmony_ci};
18418c2ecf20Sopenharmony_ci
18428c2ecf20Sopenharmony_cistatic const struct of_device_id of_slave_match_tbl[] = {
18438c2ecf20Sopenharmony_ci	{
18448c2ecf20Sopenharmony_ci		.compatible = "mediatek,mt6323",
18458c2ecf20Sopenharmony_ci		.data = &pmic_mt6323,
18468c2ecf20Sopenharmony_ci	}, {
18478c2ecf20Sopenharmony_ci		.compatible = "mediatek,mt6351",
18488c2ecf20Sopenharmony_ci		.data = &pmic_mt6351,
18498c2ecf20Sopenharmony_ci	}, {
18508c2ecf20Sopenharmony_ci		.compatible = "mediatek,mt6357",
18518c2ecf20Sopenharmony_ci		.data = &pmic_mt6357,
18528c2ecf20Sopenharmony_ci	}, {
18538c2ecf20Sopenharmony_ci		.compatible = "mediatek,mt6358",
18548c2ecf20Sopenharmony_ci		.data = &pmic_mt6358,
18558c2ecf20Sopenharmony_ci	}, {
18568c2ecf20Sopenharmony_ci		.compatible = "mediatek,mt6359",
18578c2ecf20Sopenharmony_ci		.data = &pmic_mt6359,
18588c2ecf20Sopenharmony_ci	}, {
18598c2ecf20Sopenharmony_ci		/* The MT6380 PMIC only implements a regulator, so we bind it
18608c2ecf20Sopenharmony_ci		 * directly instead of using a MFD.
18618c2ecf20Sopenharmony_ci		 */
18628c2ecf20Sopenharmony_ci		.compatible = "mediatek,mt6380-regulator",
18638c2ecf20Sopenharmony_ci		.data = &pmic_mt6380,
18648c2ecf20Sopenharmony_ci	}, {
18658c2ecf20Sopenharmony_ci		.compatible = "mediatek,mt6397",
18668c2ecf20Sopenharmony_ci		.data = &pmic_mt6397,
18678c2ecf20Sopenharmony_ci	}, {
18688c2ecf20Sopenharmony_ci		/* sentinel */
18698c2ecf20Sopenharmony_ci	}
18708c2ecf20Sopenharmony_ci};
18718c2ecf20Sopenharmony_ciMODULE_DEVICE_TABLE(of, of_slave_match_tbl);
18728c2ecf20Sopenharmony_ci
18738c2ecf20Sopenharmony_cistatic const struct pmic_wrapper_type pwrap_mt2701 = {
18748c2ecf20Sopenharmony_ci	.regs = mt2701_regs,
18758c2ecf20Sopenharmony_ci	.type = PWRAP_MT2701,
18768c2ecf20Sopenharmony_ci	.arb_en_all = 0x3f,
18778c2ecf20Sopenharmony_ci	.int_en_all = ~(u32)(BIT(31) | BIT(2)),
18788c2ecf20Sopenharmony_ci	.int1_en_all = 0,
18798c2ecf20Sopenharmony_ci	.spi_w = PWRAP_MAN_CMD_SPI_WRITE_NEW,
18808c2ecf20Sopenharmony_ci	.wdt_src = PWRAP_WDT_SRC_MASK_ALL,
18818c2ecf20Sopenharmony_ci	.caps = PWRAP_CAP_RESET | PWRAP_CAP_DCM,
18828c2ecf20Sopenharmony_ci	.init_reg_clock = pwrap_mt2701_init_reg_clock,
18838c2ecf20Sopenharmony_ci	.init_soc_specific = pwrap_mt2701_init_soc_specific,
18848c2ecf20Sopenharmony_ci};
18858c2ecf20Sopenharmony_ci
18868c2ecf20Sopenharmony_cistatic const struct pmic_wrapper_type pwrap_mt6765 = {
18878c2ecf20Sopenharmony_ci	.regs = mt6765_regs,
18888c2ecf20Sopenharmony_ci	.type = PWRAP_MT6765,
18898c2ecf20Sopenharmony_ci	.arb_en_all = 0x3fd35,
18908c2ecf20Sopenharmony_ci	.int_en_all = 0xffffffff,
18918c2ecf20Sopenharmony_ci	.spi_w = PWRAP_MAN_CMD_SPI_WRITE,
18928c2ecf20Sopenharmony_ci	.wdt_src = PWRAP_WDT_SRC_MASK_ALL,
18938c2ecf20Sopenharmony_ci	.caps = PWRAP_CAP_RESET | PWRAP_CAP_DCM,
18948c2ecf20Sopenharmony_ci	.init_reg_clock = pwrap_common_init_reg_clock,
18958c2ecf20Sopenharmony_ci	.init_soc_specific = NULL,
18968c2ecf20Sopenharmony_ci};
18978c2ecf20Sopenharmony_ci
18988c2ecf20Sopenharmony_cistatic const struct pmic_wrapper_type pwrap_mt6779 = {
18998c2ecf20Sopenharmony_ci	.regs = mt6779_regs,
19008c2ecf20Sopenharmony_ci	.type = PWRAP_MT6779,
19018c2ecf20Sopenharmony_ci	.arb_en_all = 0xfbb7f,
19028c2ecf20Sopenharmony_ci	.int_en_all = 0xfffffffe,
19038c2ecf20Sopenharmony_ci	.int1_en_all = 0,
19048c2ecf20Sopenharmony_ci	.spi_w = PWRAP_MAN_CMD_SPI_WRITE,
19058c2ecf20Sopenharmony_ci	.wdt_src = PWRAP_WDT_SRC_MASK_ALL,
19068c2ecf20Sopenharmony_ci	.caps = 0,
19078c2ecf20Sopenharmony_ci	.init_reg_clock = pwrap_common_init_reg_clock,
19088c2ecf20Sopenharmony_ci	.init_soc_specific = NULL,
19098c2ecf20Sopenharmony_ci};
19108c2ecf20Sopenharmony_ci
19118c2ecf20Sopenharmony_cistatic const struct pmic_wrapper_type pwrap_mt6797 = {
19128c2ecf20Sopenharmony_ci	.regs = mt6797_regs,
19138c2ecf20Sopenharmony_ci	.type = PWRAP_MT6797,
19148c2ecf20Sopenharmony_ci	.arb_en_all = 0x01fff,
19158c2ecf20Sopenharmony_ci	.int_en_all = 0xffffffc6,
19168c2ecf20Sopenharmony_ci	.int1_en_all = 0,
19178c2ecf20Sopenharmony_ci	.spi_w = PWRAP_MAN_CMD_SPI_WRITE,
19188c2ecf20Sopenharmony_ci	.wdt_src = PWRAP_WDT_SRC_MASK_ALL,
19198c2ecf20Sopenharmony_ci	.caps = PWRAP_CAP_RESET | PWRAP_CAP_DCM,
19208c2ecf20Sopenharmony_ci	.init_reg_clock = pwrap_common_init_reg_clock,
19218c2ecf20Sopenharmony_ci	.init_soc_specific = NULL,
19228c2ecf20Sopenharmony_ci};
19238c2ecf20Sopenharmony_ci
19248c2ecf20Sopenharmony_cistatic const struct pmic_wrapper_type pwrap_mt7622 = {
19258c2ecf20Sopenharmony_ci	.regs = mt7622_regs,
19268c2ecf20Sopenharmony_ci	.type = PWRAP_MT7622,
19278c2ecf20Sopenharmony_ci	.arb_en_all = 0xff,
19288c2ecf20Sopenharmony_ci	.int_en_all = ~(u32)BIT(31),
19298c2ecf20Sopenharmony_ci	.int1_en_all = 0,
19308c2ecf20Sopenharmony_ci	.spi_w = PWRAP_MAN_CMD_SPI_WRITE,
19318c2ecf20Sopenharmony_ci	.wdt_src = PWRAP_WDT_SRC_MASK_ALL,
19328c2ecf20Sopenharmony_ci	.caps = PWRAP_CAP_RESET | PWRAP_CAP_DCM,
19338c2ecf20Sopenharmony_ci	.init_reg_clock = pwrap_common_init_reg_clock,
19348c2ecf20Sopenharmony_ci	.init_soc_specific = pwrap_mt7622_init_soc_specific,
19358c2ecf20Sopenharmony_ci};
19368c2ecf20Sopenharmony_ci
19378c2ecf20Sopenharmony_cistatic const struct pmic_wrapper_type pwrap_mt8135 = {
19388c2ecf20Sopenharmony_ci	.regs = mt8135_regs,
19398c2ecf20Sopenharmony_ci	.type = PWRAP_MT8135,
19408c2ecf20Sopenharmony_ci	.arb_en_all = 0x1ff,
19418c2ecf20Sopenharmony_ci	.int_en_all = ~(u32)(BIT(31) | BIT(1)),
19428c2ecf20Sopenharmony_ci	.int1_en_all = 0,
19438c2ecf20Sopenharmony_ci	.spi_w = PWRAP_MAN_CMD_SPI_WRITE,
19448c2ecf20Sopenharmony_ci	.wdt_src = PWRAP_WDT_SRC_MASK_ALL,
19458c2ecf20Sopenharmony_ci	.caps = PWRAP_CAP_BRIDGE | PWRAP_CAP_RESET | PWRAP_CAP_DCM,
19468c2ecf20Sopenharmony_ci	.init_reg_clock = pwrap_common_init_reg_clock,
19478c2ecf20Sopenharmony_ci	.init_soc_specific = pwrap_mt8135_init_soc_specific,
19488c2ecf20Sopenharmony_ci};
19498c2ecf20Sopenharmony_ci
19508c2ecf20Sopenharmony_cistatic const struct pmic_wrapper_type pwrap_mt8173 = {
19518c2ecf20Sopenharmony_ci	.regs = mt8173_regs,
19528c2ecf20Sopenharmony_ci	.type = PWRAP_MT8173,
19538c2ecf20Sopenharmony_ci	.arb_en_all = 0x3f,
19548c2ecf20Sopenharmony_ci	.int_en_all = ~(u32)(BIT(31) | BIT(1)),
19558c2ecf20Sopenharmony_ci	.int1_en_all = 0,
19568c2ecf20Sopenharmony_ci	.spi_w = PWRAP_MAN_CMD_SPI_WRITE,
19578c2ecf20Sopenharmony_ci	.wdt_src = PWRAP_WDT_SRC_MASK_NO_STAUPD,
19588c2ecf20Sopenharmony_ci	.caps = PWRAP_CAP_RESET | PWRAP_CAP_DCM,
19598c2ecf20Sopenharmony_ci	.init_reg_clock = pwrap_common_init_reg_clock,
19608c2ecf20Sopenharmony_ci	.init_soc_specific = pwrap_mt8173_init_soc_specific,
19618c2ecf20Sopenharmony_ci};
19628c2ecf20Sopenharmony_ci
19638c2ecf20Sopenharmony_cistatic const struct pmic_wrapper_type pwrap_mt8183 = {
19648c2ecf20Sopenharmony_ci	.regs = mt8183_regs,
19658c2ecf20Sopenharmony_ci	.type = PWRAP_MT8183,
19668c2ecf20Sopenharmony_ci	.arb_en_all = 0x3fa75,
19678c2ecf20Sopenharmony_ci	.int_en_all = 0xffffffff,
19688c2ecf20Sopenharmony_ci	.int1_en_all = 0xeef7ffff,
19698c2ecf20Sopenharmony_ci	.spi_w = PWRAP_MAN_CMD_SPI_WRITE,
19708c2ecf20Sopenharmony_ci	.wdt_src = PWRAP_WDT_SRC_MASK_ALL,
19718c2ecf20Sopenharmony_ci	.caps = PWRAP_CAP_INT1_EN | PWRAP_CAP_WDT_SRC1,
19728c2ecf20Sopenharmony_ci	.init_reg_clock = pwrap_common_init_reg_clock,
19738c2ecf20Sopenharmony_ci	.init_soc_specific = pwrap_mt8183_init_soc_specific,
19748c2ecf20Sopenharmony_ci};
19758c2ecf20Sopenharmony_ci
19768c2ecf20Sopenharmony_cistatic struct pmic_wrapper_type pwrap_mt8516 = {
19778c2ecf20Sopenharmony_ci	.regs = mt8516_regs,
19788c2ecf20Sopenharmony_ci	.type = PWRAP_MT8516,
19798c2ecf20Sopenharmony_ci	.arb_en_all = 0xff,
19808c2ecf20Sopenharmony_ci	.int_en_all = ~(u32)(BIT(31) | BIT(2)),
19818c2ecf20Sopenharmony_ci	.spi_w = PWRAP_MAN_CMD_SPI_WRITE,
19828c2ecf20Sopenharmony_ci	.wdt_src = PWRAP_WDT_SRC_MASK_ALL,
19838c2ecf20Sopenharmony_ci	.caps = PWRAP_CAP_DCM,
19848c2ecf20Sopenharmony_ci	.init_reg_clock = pwrap_mt2701_init_reg_clock,
19858c2ecf20Sopenharmony_ci	.init_soc_specific = NULL,
19868c2ecf20Sopenharmony_ci};
19878c2ecf20Sopenharmony_ci
19888c2ecf20Sopenharmony_cistatic const struct of_device_id of_pwrap_match_tbl[] = {
19898c2ecf20Sopenharmony_ci	{
19908c2ecf20Sopenharmony_ci		.compatible = "mediatek,mt2701-pwrap",
19918c2ecf20Sopenharmony_ci		.data = &pwrap_mt2701,
19928c2ecf20Sopenharmony_ci	}, {
19938c2ecf20Sopenharmony_ci		.compatible = "mediatek,mt6765-pwrap",
19948c2ecf20Sopenharmony_ci		.data = &pwrap_mt6765,
19958c2ecf20Sopenharmony_ci	}, {
19968c2ecf20Sopenharmony_ci		.compatible = "mediatek,mt6779-pwrap",
19978c2ecf20Sopenharmony_ci		.data = &pwrap_mt6779,
19988c2ecf20Sopenharmony_ci	}, {
19998c2ecf20Sopenharmony_ci		.compatible = "mediatek,mt6797-pwrap",
20008c2ecf20Sopenharmony_ci		.data = &pwrap_mt6797,
20018c2ecf20Sopenharmony_ci	}, {
20028c2ecf20Sopenharmony_ci		.compatible = "mediatek,mt7622-pwrap",
20038c2ecf20Sopenharmony_ci		.data = &pwrap_mt7622,
20048c2ecf20Sopenharmony_ci	}, {
20058c2ecf20Sopenharmony_ci		.compatible = "mediatek,mt8135-pwrap",
20068c2ecf20Sopenharmony_ci		.data = &pwrap_mt8135,
20078c2ecf20Sopenharmony_ci	}, {
20088c2ecf20Sopenharmony_ci		.compatible = "mediatek,mt8173-pwrap",
20098c2ecf20Sopenharmony_ci		.data = &pwrap_mt8173,
20108c2ecf20Sopenharmony_ci	}, {
20118c2ecf20Sopenharmony_ci		.compatible = "mediatek,mt8183-pwrap",
20128c2ecf20Sopenharmony_ci		.data = &pwrap_mt8183,
20138c2ecf20Sopenharmony_ci	}, {
20148c2ecf20Sopenharmony_ci		.compatible = "mediatek,mt8516-pwrap",
20158c2ecf20Sopenharmony_ci		.data = &pwrap_mt8516,
20168c2ecf20Sopenharmony_ci	}, {
20178c2ecf20Sopenharmony_ci		/* sentinel */
20188c2ecf20Sopenharmony_ci	}
20198c2ecf20Sopenharmony_ci};
20208c2ecf20Sopenharmony_ciMODULE_DEVICE_TABLE(of, of_pwrap_match_tbl);
20218c2ecf20Sopenharmony_ci
20228c2ecf20Sopenharmony_cistatic int pwrap_probe(struct platform_device *pdev)
20238c2ecf20Sopenharmony_ci{
20248c2ecf20Sopenharmony_ci	int ret, irq;
20258c2ecf20Sopenharmony_ci	struct pmic_wrapper *wrp;
20268c2ecf20Sopenharmony_ci	struct device_node *np = pdev->dev.of_node;
20278c2ecf20Sopenharmony_ci	const struct of_device_id *of_slave_id = NULL;
20288c2ecf20Sopenharmony_ci	struct resource *res;
20298c2ecf20Sopenharmony_ci
20308c2ecf20Sopenharmony_ci	if (np->child)
20318c2ecf20Sopenharmony_ci		of_slave_id = of_match_node(of_slave_match_tbl, np->child);
20328c2ecf20Sopenharmony_ci
20338c2ecf20Sopenharmony_ci	if (!of_slave_id) {
20348c2ecf20Sopenharmony_ci		dev_dbg(&pdev->dev, "slave pmic should be defined in dts\n");
20358c2ecf20Sopenharmony_ci		return -EINVAL;
20368c2ecf20Sopenharmony_ci	}
20378c2ecf20Sopenharmony_ci
20388c2ecf20Sopenharmony_ci	wrp = devm_kzalloc(&pdev->dev, sizeof(*wrp), GFP_KERNEL);
20398c2ecf20Sopenharmony_ci	if (!wrp)
20408c2ecf20Sopenharmony_ci		return -ENOMEM;
20418c2ecf20Sopenharmony_ci
20428c2ecf20Sopenharmony_ci	platform_set_drvdata(pdev, wrp);
20438c2ecf20Sopenharmony_ci
20448c2ecf20Sopenharmony_ci	wrp->master = of_device_get_match_data(&pdev->dev);
20458c2ecf20Sopenharmony_ci	wrp->slave = of_slave_id->data;
20468c2ecf20Sopenharmony_ci	wrp->dev = &pdev->dev;
20478c2ecf20Sopenharmony_ci
20488c2ecf20Sopenharmony_ci	res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "pwrap");
20498c2ecf20Sopenharmony_ci	wrp->base = devm_ioremap_resource(wrp->dev, res);
20508c2ecf20Sopenharmony_ci	if (IS_ERR(wrp->base))
20518c2ecf20Sopenharmony_ci		return PTR_ERR(wrp->base);
20528c2ecf20Sopenharmony_ci
20538c2ecf20Sopenharmony_ci	if (HAS_CAP(wrp->master->caps, PWRAP_CAP_RESET)) {
20548c2ecf20Sopenharmony_ci		wrp->rstc = devm_reset_control_get(wrp->dev, "pwrap");
20558c2ecf20Sopenharmony_ci		if (IS_ERR(wrp->rstc)) {
20568c2ecf20Sopenharmony_ci			ret = PTR_ERR(wrp->rstc);
20578c2ecf20Sopenharmony_ci			dev_dbg(wrp->dev, "cannot get pwrap reset: %d\n", ret);
20588c2ecf20Sopenharmony_ci			return ret;
20598c2ecf20Sopenharmony_ci		}
20608c2ecf20Sopenharmony_ci	}
20618c2ecf20Sopenharmony_ci
20628c2ecf20Sopenharmony_ci	if (HAS_CAP(wrp->master->caps, PWRAP_CAP_BRIDGE)) {
20638c2ecf20Sopenharmony_ci		res = platform_get_resource_byname(pdev, IORESOURCE_MEM,
20648c2ecf20Sopenharmony_ci				"pwrap-bridge");
20658c2ecf20Sopenharmony_ci		wrp->bridge_base = devm_ioremap_resource(wrp->dev, res);
20668c2ecf20Sopenharmony_ci		if (IS_ERR(wrp->bridge_base))
20678c2ecf20Sopenharmony_ci			return PTR_ERR(wrp->bridge_base);
20688c2ecf20Sopenharmony_ci
20698c2ecf20Sopenharmony_ci		wrp->rstc_bridge = devm_reset_control_get(wrp->dev,
20708c2ecf20Sopenharmony_ci							  "pwrap-bridge");
20718c2ecf20Sopenharmony_ci		if (IS_ERR(wrp->rstc_bridge)) {
20728c2ecf20Sopenharmony_ci			ret = PTR_ERR(wrp->rstc_bridge);
20738c2ecf20Sopenharmony_ci			dev_dbg(wrp->dev,
20748c2ecf20Sopenharmony_ci				"cannot get pwrap-bridge reset: %d\n", ret);
20758c2ecf20Sopenharmony_ci			return ret;
20768c2ecf20Sopenharmony_ci		}
20778c2ecf20Sopenharmony_ci	}
20788c2ecf20Sopenharmony_ci
20798c2ecf20Sopenharmony_ci	wrp->clk_spi = devm_clk_get(wrp->dev, "spi");
20808c2ecf20Sopenharmony_ci	if (IS_ERR(wrp->clk_spi)) {
20818c2ecf20Sopenharmony_ci		dev_dbg(wrp->dev, "failed to get clock: %ld\n",
20828c2ecf20Sopenharmony_ci			PTR_ERR(wrp->clk_spi));
20838c2ecf20Sopenharmony_ci		return PTR_ERR(wrp->clk_spi);
20848c2ecf20Sopenharmony_ci	}
20858c2ecf20Sopenharmony_ci
20868c2ecf20Sopenharmony_ci	wrp->clk_wrap = devm_clk_get(wrp->dev, "wrap");
20878c2ecf20Sopenharmony_ci	if (IS_ERR(wrp->clk_wrap)) {
20888c2ecf20Sopenharmony_ci		dev_dbg(wrp->dev, "failed to get clock: %ld\n",
20898c2ecf20Sopenharmony_ci			PTR_ERR(wrp->clk_wrap));
20908c2ecf20Sopenharmony_ci		return PTR_ERR(wrp->clk_wrap);
20918c2ecf20Sopenharmony_ci	}
20928c2ecf20Sopenharmony_ci
20938c2ecf20Sopenharmony_ci	ret = clk_prepare_enable(wrp->clk_spi);
20948c2ecf20Sopenharmony_ci	if (ret)
20958c2ecf20Sopenharmony_ci		return ret;
20968c2ecf20Sopenharmony_ci
20978c2ecf20Sopenharmony_ci	ret = clk_prepare_enable(wrp->clk_wrap);
20988c2ecf20Sopenharmony_ci	if (ret)
20998c2ecf20Sopenharmony_ci		goto err_out1;
21008c2ecf20Sopenharmony_ci
21018c2ecf20Sopenharmony_ci	/* Enable internal dynamic clock */
21028c2ecf20Sopenharmony_ci	if (HAS_CAP(wrp->master->caps, PWRAP_CAP_DCM)) {
21038c2ecf20Sopenharmony_ci		pwrap_writel(wrp, 1, PWRAP_DCM_EN);
21048c2ecf20Sopenharmony_ci		pwrap_writel(wrp, 0, PWRAP_DCM_DBC_PRD);
21058c2ecf20Sopenharmony_ci	}
21068c2ecf20Sopenharmony_ci
21078c2ecf20Sopenharmony_ci	/*
21088c2ecf20Sopenharmony_ci	 * The PMIC could already be initialized by the bootloader.
21098c2ecf20Sopenharmony_ci	 * Skip initialization here in this case.
21108c2ecf20Sopenharmony_ci	 */
21118c2ecf20Sopenharmony_ci	if (!pwrap_readl(wrp, PWRAP_INIT_DONE2)) {
21128c2ecf20Sopenharmony_ci		ret = pwrap_init(wrp);
21138c2ecf20Sopenharmony_ci		if (ret) {
21148c2ecf20Sopenharmony_ci			dev_dbg(wrp->dev, "init failed with %d\n", ret);
21158c2ecf20Sopenharmony_ci			goto err_out2;
21168c2ecf20Sopenharmony_ci		}
21178c2ecf20Sopenharmony_ci	}
21188c2ecf20Sopenharmony_ci
21198c2ecf20Sopenharmony_ci	if (!(pwrap_readl(wrp, PWRAP_WACS2_RDATA) & PWRAP_STATE_INIT_DONE0)) {
21208c2ecf20Sopenharmony_ci		dev_dbg(wrp->dev, "initialization isn't finished\n");
21218c2ecf20Sopenharmony_ci		ret = -ENODEV;
21228c2ecf20Sopenharmony_ci		goto err_out2;
21238c2ecf20Sopenharmony_ci	}
21248c2ecf20Sopenharmony_ci
21258c2ecf20Sopenharmony_ci	/* Initialize watchdog, may not be done by the bootloader */
21268c2ecf20Sopenharmony_ci	pwrap_writel(wrp, 0xf, PWRAP_WDT_UNIT);
21278c2ecf20Sopenharmony_ci	/*
21288c2ecf20Sopenharmony_ci	 * Since STAUPD was not used on mt8173 platform,
21298c2ecf20Sopenharmony_ci	 * so STAUPD of WDT_SRC which should be turned off
21308c2ecf20Sopenharmony_ci	 */
21318c2ecf20Sopenharmony_ci	pwrap_writel(wrp, wrp->master->wdt_src, PWRAP_WDT_SRC_EN);
21328c2ecf20Sopenharmony_ci	if (HAS_CAP(wrp->master->caps, PWRAP_CAP_WDT_SRC1))
21338c2ecf20Sopenharmony_ci		pwrap_writel(wrp, wrp->master->wdt_src, PWRAP_WDT_SRC_EN_1);
21348c2ecf20Sopenharmony_ci
21358c2ecf20Sopenharmony_ci	pwrap_writel(wrp, 0x1, PWRAP_TIMER_EN);
21368c2ecf20Sopenharmony_ci	pwrap_writel(wrp, wrp->master->int_en_all, PWRAP_INT_EN);
21378c2ecf20Sopenharmony_ci	/*
21388c2ecf20Sopenharmony_ci	 * We add INT1 interrupt to handle starvation and request exception
21398c2ecf20Sopenharmony_ci	 * If we support it, we should enable it here.
21408c2ecf20Sopenharmony_ci	 */
21418c2ecf20Sopenharmony_ci	if (HAS_CAP(wrp->master->caps, PWRAP_CAP_INT1_EN))
21428c2ecf20Sopenharmony_ci		pwrap_writel(wrp, wrp->master->int1_en_all, PWRAP_INT1_EN);
21438c2ecf20Sopenharmony_ci
21448c2ecf20Sopenharmony_ci	irq = platform_get_irq(pdev, 0);
21458c2ecf20Sopenharmony_ci	ret = devm_request_irq(wrp->dev, irq, pwrap_interrupt,
21468c2ecf20Sopenharmony_ci			       IRQF_TRIGGER_HIGH,
21478c2ecf20Sopenharmony_ci			       "mt-pmic-pwrap", wrp);
21488c2ecf20Sopenharmony_ci	if (ret)
21498c2ecf20Sopenharmony_ci		goto err_out2;
21508c2ecf20Sopenharmony_ci
21518c2ecf20Sopenharmony_ci	wrp->regmap = devm_regmap_init(wrp->dev, NULL, wrp, wrp->slave->regmap);
21528c2ecf20Sopenharmony_ci	if (IS_ERR(wrp->regmap)) {
21538c2ecf20Sopenharmony_ci		ret = PTR_ERR(wrp->regmap);
21548c2ecf20Sopenharmony_ci		goto err_out2;
21558c2ecf20Sopenharmony_ci	}
21568c2ecf20Sopenharmony_ci
21578c2ecf20Sopenharmony_ci	ret = of_platform_populate(np, NULL, NULL, wrp->dev);
21588c2ecf20Sopenharmony_ci	if (ret) {
21598c2ecf20Sopenharmony_ci		dev_dbg(wrp->dev, "failed to create child devices at %pOF\n",
21608c2ecf20Sopenharmony_ci				np);
21618c2ecf20Sopenharmony_ci		goto err_out2;
21628c2ecf20Sopenharmony_ci	}
21638c2ecf20Sopenharmony_ci
21648c2ecf20Sopenharmony_ci	return 0;
21658c2ecf20Sopenharmony_ci
21668c2ecf20Sopenharmony_cierr_out2:
21678c2ecf20Sopenharmony_ci	clk_disable_unprepare(wrp->clk_wrap);
21688c2ecf20Sopenharmony_cierr_out1:
21698c2ecf20Sopenharmony_ci	clk_disable_unprepare(wrp->clk_spi);
21708c2ecf20Sopenharmony_ci
21718c2ecf20Sopenharmony_ci	return ret;
21728c2ecf20Sopenharmony_ci}
21738c2ecf20Sopenharmony_ci
21748c2ecf20Sopenharmony_cistatic struct platform_driver pwrap_drv = {
21758c2ecf20Sopenharmony_ci	.driver = {
21768c2ecf20Sopenharmony_ci		.name = "mt-pmic-pwrap",
21778c2ecf20Sopenharmony_ci		.of_match_table = of_match_ptr(of_pwrap_match_tbl),
21788c2ecf20Sopenharmony_ci	},
21798c2ecf20Sopenharmony_ci	.probe = pwrap_probe,
21808c2ecf20Sopenharmony_ci};
21818c2ecf20Sopenharmony_ci
21828c2ecf20Sopenharmony_cimodule_platform_driver(pwrap_drv);
21838c2ecf20Sopenharmony_ci
21848c2ecf20Sopenharmony_ciMODULE_AUTHOR("Flora Fu, MediaTek");
21858c2ecf20Sopenharmony_ciMODULE_DESCRIPTION("MediaTek MT8135 PMIC Wrapper Driver");
21868c2ecf20Sopenharmony_ciMODULE_LICENSE("GPL v2");
2187