162306a36Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0-only
262306a36Sopenharmony_ci/*
362306a36Sopenharmony_ci * Copyright (c) 2014 MediaTek Inc.
462306a36Sopenharmony_ci * Author: Flora Fu, MediaTek
562306a36Sopenharmony_ci */
662306a36Sopenharmony_ci#include <linux/clk.h>
762306a36Sopenharmony_ci#include <linux/interrupt.h>
862306a36Sopenharmony_ci#include <linux/io.h>
962306a36Sopenharmony_ci#include <linux/kernel.h>
1062306a36Sopenharmony_ci#include <linux/module.h>
1162306a36Sopenharmony_ci#include <linux/of.h>
1262306a36Sopenharmony_ci#include <linux/of_platform.h>
1362306a36Sopenharmony_ci#include <linux/platform_device.h>
1462306a36Sopenharmony_ci#include <linux/regmap.h>
1562306a36Sopenharmony_ci#include <linux/reset.h>
1662306a36Sopenharmony_ci
1762306a36Sopenharmony_ci#define PWRAP_POLL_DELAY_US	10
1862306a36Sopenharmony_ci#define PWRAP_POLL_TIMEOUT_US	10000
1962306a36Sopenharmony_ci
2062306a36Sopenharmony_ci#define PWRAP_MT8135_BRIDGE_IORD_ARB_EN		0x4
2162306a36Sopenharmony_ci#define PWRAP_MT8135_BRIDGE_WACS3_EN		0x10
2262306a36Sopenharmony_ci#define PWRAP_MT8135_BRIDGE_INIT_DONE3		0x14
2362306a36Sopenharmony_ci#define PWRAP_MT8135_BRIDGE_WACS4_EN		0x24
2462306a36Sopenharmony_ci#define PWRAP_MT8135_BRIDGE_INIT_DONE4		0x28
2562306a36Sopenharmony_ci#define PWRAP_MT8135_BRIDGE_INT_EN		0x38
2662306a36Sopenharmony_ci#define PWRAP_MT8135_BRIDGE_TIMER_EN		0x48
2762306a36Sopenharmony_ci#define PWRAP_MT8135_BRIDGE_WDT_UNIT		0x50
2862306a36Sopenharmony_ci#define PWRAP_MT8135_BRIDGE_WDT_SRC_EN		0x54
2962306a36Sopenharmony_ci
3062306a36Sopenharmony_ci/* macro for wrapper status */
3162306a36Sopenharmony_ci#define PWRAP_GET_WACS_RDATA(x)		(((x) >> 0) & 0x0000ffff)
3262306a36Sopenharmony_ci#define PWRAP_GET_WACS_ARB_FSM(x)	(((x) >> 1) & 0x00000007)
3362306a36Sopenharmony_ci#define PWRAP_GET_WACS_FSM(x)		(((x) >> 16) & 0x00000007)
3462306a36Sopenharmony_ci#define PWRAP_GET_WACS_REQ(x)		(((x) >> 19) & 0x00000001)
3562306a36Sopenharmony_ci#define PWRAP_STATE_SYNC_IDLE0		BIT(20)
3662306a36Sopenharmony_ci#define PWRAP_STATE_INIT_DONE0		BIT(21)
3762306a36Sopenharmony_ci#define PWRAP_STATE_INIT_DONE0_MT8186	BIT(22)
3862306a36Sopenharmony_ci#define PWRAP_STATE_INIT_DONE1		BIT(15)
3962306a36Sopenharmony_ci
4062306a36Sopenharmony_ci/* macro for WACS FSM */
4162306a36Sopenharmony_ci#define PWRAP_WACS_FSM_IDLE		0x00
4262306a36Sopenharmony_ci#define PWRAP_WACS_FSM_REQ		0x02
4362306a36Sopenharmony_ci#define PWRAP_WACS_FSM_WFDLE		0x04
4462306a36Sopenharmony_ci#define PWRAP_WACS_FSM_WFVLDCLR		0x06
4562306a36Sopenharmony_ci#define PWRAP_WACS_INIT_DONE		0x01
4662306a36Sopenharmony_ci#define PWRAP_WACS_WACS_SYNC_IDLE	0x01
4762306a36Sopenharmony_ci#define PWRAP_WACS_SYNC_BUSY		0x00
4862306a36Sopenharmony_ci
4962306a36Sopenharmony_ci/* macro for device wrapper default value */
5062306a36Sopenharmony_ci#define PWRAP_DEW_READ_TEST_VAL		0x5aa5
5162306a36Sopenharmony_ci#define PWRAP_DEW_COMP_READ_TEST_VAL	0xa55a
5262306a36Sopenharmony_ci#define PWRAP_DEW_WRITE_TEST_VAL	0xa55a
5362306a36Sopenharmony_ci
5462306a36Sopenharmony_ci/* macro for manual command */
5562306a36Sopenharmony_ci#define PWRAP_MAN_CMD_SPI_WRITE_NEW	(1 << 14)
5662306a36Sopenharmony_ci#define PWRAP_MAN_CMD_SPI_WRITE		(1 << 13)
5762306a36Sopenharmony_ci#define PWRAP_MAN_CMD_OP_CSH		(0x0 << 8)
5862306a36Sopenharmony_ci#define PWRAP_MAN_CMD_OP_CSL		(0x1 << 8)
5962306a36Sopenharmony_ci#define PWRAP_MAN_CMD_OP_CK		(0x2 << 8)
6062306a36Sopenharmony_ci#define PWRAP_MAN_CMD_OP_OUTS		(0x8 << 8)
6162306a36Sopenharmony_ci#define PWRAP_MAN_CMD_OP_OUTD		(0x9 << 8)
6262306a36Sopenharmony_ci#define PWRAP_MAN_CMD_OP_OUTQ		(0xa << 8)
6362306a36Sopenharmony_ci
6462306a36Sopenharmony_ci/* macro for Watch Dog Timer Source */
6562306a36Sopenharmony_ci#define PWRAP_WDT_SRC_EN_STAUPD_TRIG		(1 << 25)
6662306a36Sopenharmony_ci#define PWRAP_WDT_SRC_EN_HARB_STAUPD_DLE	(1 << 20)
6762306a36Sopenharmony_ci#define PWRAP_WDT_SRC_EN_HARB_STAUPD_ALE	(1 << 6)
6862306a36Sopenharmony_ci#define PWRAP_WDT_SRC_MASK_ALL			0xffffffff
6962306a36Sopenharmony_ci#define PWRAP_WDT_SRC_MASK_NO_STAUPD	~(PWRAP_WDT_SRC_EN_STAUPD_TRIG | \
7062306a36Sopenharmony_ci					  PWRAP_WDT_SRC_EN_HARB_STAUPD_DLE | \
7162306a36Sopenharmony_ci					  PWRAP_WDT_SRC_EN_HARB_STAUPD_ALE)
7262306a36Sopenharmony_ci
7362306a36Sopenharmony_ci/* Group of bits used for shown slave capability */
7462306a36Sopenharmony_ci#define PWRAP_SLV_CAP_SPI	BIT(0)
7562306a36Sopenharmony_ci#define PWRAP_SLV_CAP_DUALIO	BIT(1)
7662306a36Sopenharmony_ci#define PWRAP_SLV_CAP_SECURITY	BIT(2)
7762306a36Sopenharmony_ci#define HAS_CAP(_c, _x)	(((_c) & (_x)) == (_x))
7862306a36Sopenharmony_ci
7962306a36Sopenharmony_ci/* Group of bits used for shown pwrap capability */
8062306a36Sopenharmony_ci#define PWRAP_CAP_BRIDGE	BIT(0)
8162306a36Sopenharmony_ci#define PWRAP_CAP_RESET		BIT(1)
8262306a36Sopenharmony_ci#define PWRAP_CAP_DCM		BIT(2)
8362306a36Sopenharmony_ci#define PWRAP_CAP_INT1_EN	BIT(3)
8462306a36Sopenharmony_ci#define PWRAP_CAP_WDT_SRC1	BIT(4)
8562306a36Sopenharmony_ci#define PWRAP_CAP_ARB		BIT(5)
8662306a36Sopenharmony_ci#define PWRAP_CAP_ARB_MT8186	BIT(8)
8762306a36Sopenharmony_ci
8862306a36Sopenharmony_ci/* defines for slave device wrapper registers */
8962306a36Sopenharmony_cienum dew_regs {
9062306a36Sopenharmony_ci	PWRAP_DEW_BASE,
9162306a36Sopenharmony_ci	PWRAP_DEW_DIO_EN,
9262306a36Sopenharmony_ci	PWRAP_DEW_READ_TEST,
9362306a36Sopenharmony_ci	PWRAP_DEW_WRITE_TEST,
9462306a36Sopenharmony_ci	PWRAP_DEW_CRC_EN,
9562306a36Sopenharmony_ci	PWRAP_DEW_CRC_VAL,
9662306a36Sopenharmony_ci	PWRAP_DEW_MON_GRP_SEL,
9762306a36Sopenharmony_ci	PWRAP_DEW_CIPHER_KEY_SEL,
9862306a36Sopenharmony_ci	PWRAP_DEW_CIPHER_IV_SEL,
9962306a36Sopenharmony_ci	PWRAP_DEW_CIPHER_RDY,
10062306a36Sopenharmony_ci	PWRAP_DEW_CIPHER_MODE,
10162306a36Sopenharmony_ci	PWRAP_DEW_CIPHER_SWRST,
10262306a36Sopenharmony_ci
10362306a36Sopenharmony_ci	/* MT6323 only regs */
10462306a36Sopenharmony_ci	PWRAP_DEW_CIPHER_EN,
10562306a36Sopenharmony_ci	PWRAP_DEW_RDDMY_NO,
10662306a36Sopenharmony_ci
10762306a36Sopenharmony_ci	/* MT6358 only regs */
10862306a36Sopenharmony_ci	PWRAP_SMT_CON1,
10962306a36Sopenharmony_ci	PWRAP_DRV_CON1,
11062306a36Sopenharmony_ci	PWRAP_FILTER_CON0,
11162306a36Sopenharmony_ci	PWRAP_GPIO_PULLEN0_CLR,
11262306a36Sopenharmony_ci	PWRAP_RG_SPI_CON0,
11362306a36Sopenharmony_ci	PWRAP_RG_SPI_RECORD0,
11462306a36Sopenharmony_ci	PWRAP_RG_SPI_CON2,
11562306a36Sopenharmony_ci	PWRAP_RG_SPI_CON3,
11662306a36Sopenharmony_ci	PWRAP_RG_SPI_CON4,
11762306a36Sopenharmony_ci	PWRAP_RG_SPI_CON5,
11862306a36Sopenharmony_ci	PWRAP_RG_SPI_CON6,
11962306a36Sopenharmony_ci	PWRAP_RG_SPI_CON7,
12062306a36Sopenharmony_ci	PWRAP_RG_SPI_CON8,
12162306a36Sopenharmony_ci	PWRAP_RG_SPI_CON13,
12262306a36Sopenharmony_ci	PWRAP_SPISLV_KEY,
12362306a36Sopenharmony_ci
12462306a36Sopenharmony_ci	/* MT6359 only regs */
12562306a36Sopenharmony_ci	PWRAP_DEW_CRC_SWRST,
12662306a36Sopenharmony_ci	PWRAP_DEW_RG_EN_RECORD,
12762306a36Sopenharmony_ci	PWRAP_DEW_RECORD_CMD0,
12862306a36Sopenharmony_ci	PWRAP_DEW_RECORD_CMD1,
12962306a36Sopenharmony_ci	PWRAP_DEW_RECORD_CMD2,
13062306a36Sopenharmony_ci	PWRAP_DEW_RECORD_CMD3,
13162306a36Sopenharmony_ci	PWRAP_DEW_RECORD_CMD4,
13262306a36Sopenharmony_ci	PWRAP_DEW_RECORD_CMD5,
13362306a36Sopenharmony_ci	PWRAP_DEW_RECORD_WDATA0,
13462306a36Sopenharmony_ci	PWRAP_DEW_RECORD_WDATA1,
13562306a36Sopenharmony_ci	PWRAP_DEW_RECORD_WDATA2,
13662306a36Sopenharmony_ci	PWRAP_DEW_RECORD_WDATA3,
13762306a36Sopenharmony_ci	PWRAP_DEW_RECORD_WDATA4,
13862306a36Sopenharmony_ci	PWRAP_DEW_RECORD_WDATA5,
13962306a36Sopenharmony_ci	PWRAP_DEW_RG_ADDR_TARGET,
14062306a36Sopenharmony_ci	PWRAP_DEW_RG_ADDR_MASK,
14162306a36Sopenharmony_ci	PWRAP_DEW_RG_WDATA_TARGET,
14262306a36Sopenharmony_ci	PWRAP_DEW_RG_WDATA_MASK,
14362306a36Sopenharmony_ci	PWRAP_DEW_RG_SPI_RECORD_CLR,
14462306a36Sopenharmony_ci	PWRAP_DEW_RG_CMD_ALERT_CLR,
14562306a36Sopenharmony_ci
14662306a36Sopenharmony_ci	/* MT6397 only regs */
14762306a36Sopenharmony_ci	PWRAP_DEW_EVENT_OUT_EN,
14862306a36Sopenharmony_ci	PWRAP_DEW_EVENT_SRC_EN,
14962306a36Sopenharmony_ci	PWRAP_DEW_EVENT_SRC,
15062306a36Sopenharmony_ci	PWRAP_DEW_EVENT_FLAG,
15162306a36Sopenharmony_ci	PWRAP_DEW_MON_FLAG_SEL,
15262306a36Sopenharmony_ci	PWRAP_DEW_EVENT_TEST,
15362306a36Sopenharmony_ci	PWRAP_DEW_CIPHER_LOAD,
15462306a36Sopenharmony_ci	PWRAP_DEW_CIPHER_START,
15562306a36Sopenharmony_ci};
15662306a36Sopenharmony_ci
15762306a36Sopenharmony_cistatic const u32 mt6323_regs[] = {
15862306a36Sopenharmony_ci	[PWRAP_DEW_BASE] =		0x0000,
15962306a36Sopenharmony_ci	[PWRAP_DEW_DIO_EN] =		0x018a,
16062306a36Sopenharmony_ci	[PWRAP_DEW_READ_TEST] =		0x018c,
16162306a36Sopenharmony_ci	[PWRAP_DEW_WRITE_TEST] =	0x018e,
16262306a36Sopenharmony_ci	[PWRAP_DEW_CRC_EN] =		0x0192,
16362306a36Sopenharmony_ci	[PWRAP_DEW_CRC_VAL] =		0x0194,
16462306a36Sopenharmony_ci	[PWRAP_DEW_MON_GRP_SEL] =	0x0196,
16562306a36Sopenharmony_ci	[PWRAP_DEW_CIPHER_KEY_SEL] =	0x0198,
16662306a36Sopenharmony_ci	[PWRAP_DEW_CIPHER_IV_SEL] =	0x019a,
16762306a36Sopenharmony_ci	[PWRAP_DEW_CIPHER_EN] =		0x019c,
16862306a36Sopenharmony_ci	[PWRAP_DEW_CIPHER_RDY] =	0x019e,
16962306a36Sopenharmony_ci	[PWRAP_DEW_CIPHER_MODE] =	0x01a0,
17062306a36Sopenharmony_ci	[PWRAP_DEW_CIPHER_SWRST] =	0x01a2,
17162306a36Sopenharmony_ci	[PWRAP_DEW_RDDMY_NO] =		0x01a4,
17262306a36Sopenharmony_ci};
17362306a36Sopenharmony_ci
17462306a36Sopenharmony_cistatic const u32 mt6331_regs[] = {
17562306a36Sopenharmony_ci	[PWRAP_DEW_DIO_EN] =		0x018c,
17662306a36Sopenharmony_ci	[PWRAP_DEW_READ_TEST] =		0x018e,
17762306a36Sopenharmony_ci	[PWRAP_DEW_WRITE_TEST] =	0x0190,
17862306a36Sopenharmony_ci	[PWRAP_DEW_CRC_SWRST] =		0x0192,
17962306a36Sopenharmony_ci	[PWRAP_DEW_CRC_EN] =		0x0194,
18062306a36Sopenharmony_ci	[PWRAP_DEW_CRC_VAL] =		0x0196,
18162306a36Sopenharmony_ci	[PWRAP_DEW_MON_GRP_SEL] =	0x0198,
18262306a36Sopenharmony_ci	[PWRAP_DEW_CIPHER_KEY_SEL] =	0x019a,
18362306a36Sopenharmony_ci	[PWRAP_DEW_CIPHER_IV_SEL] =	0x019c,
18462306a36Sopenharmony_ci	[PWRAP_DEW_CIPHER_EN] =		0x019e,
18562306a36Sopenharmony_ci	[PWRAP_DEW_CIPHER_RDY] =	0x01a0,
18662306a36Sopenharmony_ci	[PWRAP_DEW_CIPHER_MODE] =	0x01a2,
18762306a36Sopenharmony_ci	[PWRAP_DEW_CIPHER_SWRST] =	0x01a4,
18862306a36Sopenharmony_ci	[PWRAP_DEW_RDDMY_NO] =		0x01a6,
18962306a36Sopenharmony_ci};
19062306a36Sopenharmony_ci
19162306a36Sopenharmony_cistatic const u32 mt6332_regs[] = {
19262306a36Sopenharmony_ci	[PWRAP_DEW_DIO_EN] =		0x80f6,
19362306a36Sopenharmony_ci	[PWRAP_DEW_READ_TEST] =		0x80f8,
19462306a36Sopenharmony_ci	[PWRAP_DEW_WRITE_TEST] =	0x80fa,
19562306a36Sopenharmony_ci	[PWRAP_DEW_CRC_SWRST] =		0x80fc,
19662306a36Sopenharmony_ci	[PWRAP_DEW_CRC_EN] =		0x80fe,
19762306a36Sopenharmony_ci	[PWRAP_DEW_CRC_VAL] =		0x8100,
19862306a36Sopenharmony_ci	[PWRAP_DEW_MON_GRP_SEL] =	0x8102,
19962306a36Sopenharmony_ci	[PWRAP_DEW_CIPHER_KEY_SEL] =	0x8104,
20062306a36Sopenharmony_ci	[PWRAP_DEW_CIPHER_IV_SEL] =	0x8106,
20162306a36Sopenharmony_ci	[PWRAP_DEW_CIPHER_EN] =		0x8108,
20262306a36Sopenharmony_ci	[PWRAP_DEW_CIPHER_RDY] =	0x810a,
20362306a36Sopenharmony_ci	[PWRAP_DEW_CIPHER_MODE] =	0x810c,
20462306a36Sopenharmony_ci	[PWRAP_DEW_CIPHER_SWRST] =	0x810e,
20562306a36Sopenharmony_ci	[PWRAP_DEW_RDDMY_NO] =		0x8110,
20662306a36Sopenharmony_ci};
20762306a36Sopenharmony_ci
20862306a36Sopenharmony_cistatic const u32 mt6351_regs[] = {
20962306a36Sopenharmony_ci	[PWRAP_DEW_DIO_EN] =		0x02F2,
21062306a36Sopenharmony_ci	[PWRAP_DEW_READ_TEST] =		0x02F4,
21162306a36Sopenharmony_ci	[PWRAP_DEW_WRITE_TEST] =	0x02F6,
21262306a36Sopenharmony_ci	[PWRAP_DEW_CRC_EN] =		0x02FA,
21362306a36Sopenharmony_ci	[PWRAP_DEW_CRC_VAL] =		0x02FC,
21462306a36Sopenharmony_ci	[PWRAP_DEW_CIPHER_KEY_SEL] =	0x0300,
21562306a36Sopenharmony_ci	[PWRAP_DEW_CIPHER_IV_SEL] =	0x0302,
21662306a36Sopenharmony_ci	[PWRAP_DEW_CIPHER_EN] =		0x0304,
21762306a36Sopenharmony_ci	[PWRAP_DEW_CIPHER_RDY] =	0x0306,
21862306a36Sopenharmony_ci	[PWRAP_DEW_CIPHER_MODE] =	0x0308,
21962306a36Sopenharmony_ci	[PWRAP_DEW_CIPHER_SWRST] =	0x030A,
22062306a36Sopenharmony_ci	[PWRAP_DEW_RDDMY_NO] =		0x030C,
22162306a36Sopenharmony_ci};
22262306a36Sopenharmony_ci
22362306a36Sopenharmony_cistatic const u32 mt6357_regs[] = {
22462306a36Sopenharmony_ci	[PWRAP_DEW_DIO_EN] =            0x040A,
22562306a36Sopenharmony_ci	[PWRAP_DEW_READ_TEST] =         0x040C,
22662306a36Sopenharmony_ci	[PWRAP_DEW_WRITE_TEST] =        0x040E,
22762306a36Sopenharmony_ci	[PWRAP_DEW_CRC_EN] =            0x0412,
22862306a36Sopenharmony_ci	[PWRAP_DEW_CRC_VAL] =           0x0414,
22962306a36Sopenharmony_ci	[PWRAP_DEW_CIPHER_KEY_SEL] =    0x0418,
23062306a36Sopenharmony_ci	[PWRAP_DEW_CIPHER_IV_SEL] =     0x041A,
23162306a36Sopenharmony_ci	[PWRAP_DEW_CIPHER_EN] =         0x041C,
23262306a36Sopenharmony_ci	[PWRAP_DEW_CIPHER_RDY] =        0x041E,
23362306a36Sopenharmony_ci	[PWRAP_DEW_CIPHER_MODE] =       0x0420,
23462306a36Sopenharmony_ci	[PWRAP_DEW_CIPHER_SWRST] =      0x0422,
23562306a36Sopenharmony_ci	[PWRAP_DEW_RDDMY_NO] =          0x0424,
23662306a36Sopenharmony_ci};
23762306a36Sopenharmony_ci
23862306a36Sopenharmony_cistatic const u32 mt6358_regs[] = {
23962306a36Sopenharmony_ci	[PWRAP_SMT_CON1] =		0x0030,
24062306a36Sopenharmony_ci	[PWRAP_DRV_CON1] =		0x0038,
24162306a36Sopenharmony_ci	[PWRAP_FILTER_CON0] =		0x0040,
24262306a36Sopenharmony_ci	[PWRAP_GPIO_PULLEN0_CLR] =	0x0098,
24362306a36Sopenharmony_ci	[PWRAP_RG_SPI_CON0] =		0x0408,
24462306a36Sopenharmony_ci	[PWRAP_RG_SPI_RECORD0] =	0x040a,
24562306a36Sopenharmony_ci	[PWRAP_DEW_DIO_EN] =		0x040c,
24662306a36Sopenharmony_ci	[PWRAP_DEW_READ_TEST]	=	0x040e,
24762306a36Sopenharmony_ci	[PWRAP_DEW_WRITE_TEST]	=	0x0410,
24862306a36Sopenharmony_ci	[PWRAP_DEW_CRC_EN] =		0x0414,
24962306a36Sopenharmony_ci	[PWRAP_DEW_CIPHER_KEY_SEL] =	0x041a,
25062306a36Sopenharmony_ci	[PWRAP_DEW_CIPHER_IV_SEL] =	0x041c,
25162306a36Sopenharmony_ci	[PWRAP_DEW_CIPHER_EN]	=	0x041e,
25262306a36Sopenharmony_ci	[PWRAP_DEW_CIPHER_RDY] =	0x0420,
25362306a36Sopenharmony_ci	[PWRAP_DEW_CIPHER_MODE] =	0x0422,
25462306a36Sopenharmony_ci	[PWRAP_DEW_CIPHER_SWRST] =	0x0424,
25562306a36Sopenharmony_ci	[PWRAP_RG_SPI_CON2] =		0x0432,
25662306a36Sopenharmony_ci	[PWRAP_RG_SPI_CON3] =		0x0434,
25762306a36Sopenharmony_ci	[PWRAP_RG_SPI_CON4] =		0x0436,
25862306a36Sopenharmony_ci	[PWRAP_RG_SPI_CON5] =		0x0438,
25962306a36Sopenharmony_ci	[PWRAP_RG_SPI_CON6] =		0x043a,
26062306a36Sopenharmony_ci	[PWRAP_RG_SPI_CON7] =		0x043c,
26162306a36Sopenharmony_ci	[PWRAP_RG_SPI_CON8] =		0x043e,
26262306a36Sopenharmony_ci	[PWRAP_RG_SPI_CON13] =		0x0448,
26362306a36Sopenharmony_ci	[PWRAP_SPISLV_KEY] =		0x044a,
26462306a36Sopenharmony_ci};
26562306a36Sopenharmony_ci
26662306a36Sopenharmony_cistatic const u32 mt6359_regs[] = {
26762306a36Sopenharmony_ci	[PWRAP_DEW_RG_EN_RECORD] =	0x040a,
26862306a36Sopenharmony_ci	[PWRAP_DEW_DIO_EN] =		0x040c,
26962306a36Sopenharmony_ci	[PWRAP_DEW_READ_TEST] =		0x040e,
27062306a36Sopenharmony_ci	[PWRAP_DEW_WRITE_TEST] =	0x0410,
27162306a36Sopenharmony_ci	[PWRAP_DEW_CRC_SWRST] =		0x0412,
27262306a36Sopenharmony_ci	[PWRAP_DEW_CRC_EN] =		0x0414,
27362306a36Sopenharmony_ci	[PWRAP_DEW_CRC_VAL] =		0x0416,
27462306a36Sopenharmony_ci	[PWRAP_DEW_CIPHER_KEY_SEL] =	0x0418,
27562306a36Sopenharmony_ci	[PWRAP_DEW_CIPHER_IV_SEL] =	0x041a,
27662306a36Sopenharmony_ci	[PWRAP_DEW_CIPHER_EN] =		0x041c,
27762306a36Sopenharmony_ci	[PWRAP_DEW_CIPHER_RDY] =	0x041e,
27862306a36Sopenharmony_ci	[PWRAP_DEW_CIPHER_MODE] =	0x0420,
27962306a36Sopenharmony_ci	[PWRAP_DEW_CIPHER_SWRST] =	0x0422,
28062306a36Sopenharmony_ci	[PWRAP_DEW_RDDMY_NO] =		0x0424,
28162306a36Sopenharmony_ci	[PWRAP_DEW_RECORD_CMD0] =	0x0428,
28262306a36Sopenharmony_ci	[PWRAP_DEW_RECORD_CMD1] =	0x042a,
28362306a36Sopenharmony_ci	[PWRAP_DEW_RECORD_CMD2] =	0x042c,
28462306a36Sopenharmony_ci	[PWRAP_DEW_RECORD_CMD3] =	0x042e,
28562306a36Sopenharmony_ci	[PWRAP_DEW_RECORD_CMD4] =	0x0430,
28662306a36Sopenharmony_ci	[PWRAP_DEW_RECORD_CMD5] =	0x0432,
28762306a36Sopenharmony_ci	[PWRAP_DEW_RECORD_WDATA0] =	0x0434,
28862306a36Sopenharmony_ci	[PWRAP_DEW_RECORD_WDATA1] =	0x0436,
28962306a36Sopenharmony_ci	[PWRAP_DEW_RECORD_WDATA2] =	0x0438,
29062306a36Sopenharmony_ci	[PWRAP_DEW_RECORD_WDATA3] =	0x043a,
29162306a36Sopenharmony_ci	[PWRAP_DEW_RECORD_WDATA4] =	0x043c,
29262306a36Sopenharmony_ci	[PWRAP_DEW_RECORD_WDATA5] =	0x043e,
29362306a36Sopenharmony_ci	[PWRAP_DEW_RG_ADDR_TARGET] =	0x0440,
29462306a36Sopenharmony_ci	[PWRAP_DEW_RG_ADDR_MASK] =	0x0442,
29562306a36Sopenharmony_ci	[PWRAP_DEW_RG_WDATA_TARGET] =	0x0444,
29662306a36Sopenharmony_ci	[PWRAP_DEW_RG_WDATA_MASK] =	0x0446,
29762306a36Sopenharmony_ci	[PWRAP_DEW_RG_SPI_RECORD_CLR] =	0x0448,
29862306a36Sopenharmony_ci	[PWRAP_DEW_RG_CMD_ALERT_CLR] =	0x0448,
29962306a36Sopenharmony_ci	[PWRAP_SPISLV_KEY] =		0x044a,
30062306a36Sopenharmony_ci};
30162306a36Sopenharmony_ci
30262306a36Sopenharmony_cistatic const u32 mt6397_regs[] = {
30362306a36Sopenharmony_ci	[PWRAP_DEW_BASE] =		0xbc00,
30462306a36Sopenharmony_ci	[PWRAP_DEW_EVENT_OUT_EN] =	0xbc00,
30562306a36Sopenharmony_ci	[PWRAP_DEW_DIO_EN] =		0xbc02,
30662306a36Sopenharmony_ci	[PWRAP_DEW_EVENT_SRC_EN] =	0xbc04,
30762306a36Sopenharmony_ci	[PWRAP_DEW_EVENT_SRC] =		0xbc06,
30862306a36Sopenharmony_ci	[PWRAP_DEW_EVENT_FLAG] =	0xbc08,
30962306a36Sopenharmony_ci	[PWRAP_DEW_READ_TEST] =		0xbc0a,
31062306a36Sopenharmony_ci	[PWRAP_DEW_WRITE_TEST] =	0xbc0c,
31162306a36Sopenharmony_ci	[PWRAP_DEW_CRC_EN] =		0xbc0e,
31262306a36Sopenharmony_ci	[PWRAP_DEW_CRC_VAL] =		0xbc10,
31362306a36Sopenharmony_ci	[PWRAP_DEW_MON_GRP_SEL] =	0xbc12,
31462306a36Sopenharmony_ci	[PWRAP_DEW_MON_FLAG_SEL] =	0xbc14,
31562306a36Sopenharmony_ci	[PWRAP_DEW_EVENT_TEST] =	0xbc16,
31662306a36Sopenharmony_ci	[PWRAP_DEW_CIPHER_KEY_SEL] =	0xbc18,
31762306a36Sopenharmony_ci	[PWRAP_DEW_CIPHER_IV_SEL] =	0xbc1a,
31862306a36Sopenharmony_ci	[PWRAP_DEW_CIPHER_LOAD] =	0xbc1c,
31962306a36Sopenharmony_ci	[PWRAP_DEW_CIPHER_START] =	0xbc1e,
32062306a36Sopenharmony_ci	[PWRAP_DEW_CIPHER_RDY] =	0xbc20,
32162306a36Sopenharmony_ci	[PWRAP_DEW_CIPHER_MODE] =	0xbc22,
32262306a36Sopenharmony_ci	[PWRAP_DEW_CIPHER_SWRST] =	0xbc24,
32362306a36Sopenharmony_ci};
32462306a36Sopenharmony_ci
32562306a36Sopenharmony_cienum pwrap_regs {
32662306a36Sopenharmony_ci	PWRAP_MUX_SEL,
32762306a36Sopenharmony_ci	PWRAP_WRAP_EN,
32862306a36Sopenharmony_ci	PWRAP_DIO_EN,
32962306a36Sopenharmony_ci	PWRAP_SIDLY,
33062306a36Sopenharmony_ci	PWRAP_CSHEXT_WRITE,
33162306a36Sopenharmony_ci	PWRAP_CSHEXT_READ,
33262306a36Sopenharmony_ci	PWRAP_CSLEXT_START,
33362306a36Sopenharmony_ci	PWRAP_CSLEXT_END,
33462306a36Sopenharmony_ci	PWRAP_STAUPD_PRD,
33562306a36Sopenharmony_ci	PWRAP_STAUPD_GRPEN,
33662306a36Sopenharmony_ci	PWRAP_STAUPD_MAN_TRIG,
33762306a36Sopenharmony_ci	PWRAP_STAUPD_STA,
33862306a36Sopenharmony_ci	PWRAP_WRAP_STA,
33962306a36Sopenharmony_ci	PWRAP_HARB_INIT,
34062306a36Sopenharmony_ci	PWRAP_HARB_HPRIO,
34162306a36Sopenharmony_ci	PWRAP_HIPRIO_ARB_EN,
34262306a36Sopenharmony_ci	PWRAP_HARB_STA0,
34362306a36Sopenharmony_ci	PWRAP_HARB_STA1,
34462306a36Sopenharmony_ci	PWRAP_MAN_EN,
34562306a36Sopenharmony_ci	PWRAP_MAN_CMD,
34662306a36Sopenharmony_ci	PWRAP_MAN_RDATA,
34762306a36Sopenharmony_ci	PWRAP_MAN_VLDCLR,
34862306a36Sopenharmony_ci	PWRAP_WACS0_EN,
34962306a36Sopenharmony_ci	PWRAP_INIT_DONE0,
35062306a36Sopenharmony_ci	PWRAP_WACS0_CMD,
35162306a36Sopenharmony_ci	PWRAP_WACS0_RDATA,
35262306a36Sopenharmony_ci	PWRAP_WACS0_VLDCLR,
35362306a36Sopenharmony_ci	PWRAP_WACS1_EN,
35462306a36Sopenharmony_ci	PWRAP_INIT_DONE1,
35562306a36Sopenharmony_ci	PWRAP_WACS1_CMD,
35662306a36Sopenharmony_ci	PWRAP_WACS1_RDATA,
35762306a36Sopenharmony_ci	PWRAP_WACS1_VLDCLR,
35862306a36Sopenharmony_ci	PWRAP_WACS2_EN,
35962306a36Sopenharmony_ci	PWRAP_INIT_DONE2,
36062306a36Sopenharmony_ci	PWRAP_WACS2_CMD,
36162306a36Sopenharmony_ci	PWRAP_WACS2_RDATA,
36262306a36Sopenharmony_ci	PWRAP_WACS2_VLDCLR,
36362306a36Sopenharmony_ci	PWRAP_INT_EN,
36462306a36Sopenharmony_ci	PWRAP_INT_FLG_RAW,
36562306a36Sopenharmony_ci	PWRAP_INT_FLG,
36662306a36Sopenharmony_ci	PWRAP_INT_CLR,
36762306a36Sopenharmony_ci	PWRAP_SIG_ADR,
36862306a36Sopenharmony_ci	PWRAP_SIG_MODE,
36962306a36Sopenharmony_ci	PWRAP_SIG_VALUE,
37062306a36Sopenharmony_ci	PWRAP_SIG_ERRVAL,
37162306a36Sopenharmony_ci	PWRAP_CRC_EN,
37262306a36Sopenharmony_ci	PWRAP_TIMER_EN,
37362306a36Sopenharmony_ci	PWRAP_TIMER_STA,
37462306a36Sopenharmony_ci	PWRAP_WDT_UNIT,
37562306a36Sopenharmony_ci	PWRAP_WDT_SRC_EN,
37662306a36Sopenharmony_ci	PWRAP_WDT_FLG,
37762306a36Sopenharmony_ci	PWRAP_DEBUG_INT_SEL,
37862306a36Sopenharmony_ci	PWRAP_CIPHER_KEY_SEL,
37962306a36Sopenharmony_ci	PWRAP_CIPHER_IV_SEL,
38062306a36Sopenharmony_ci	PWRAP_CIPHER_RDY,
38162306a36Sopenharmony_ci	PWRAP_CIPHER_MODE,
38262306a36Sopenharmony_ci	PWRAP_CIPHER_SWRST,
38362306a36Sopenharmony_ci	PWRAP_DCM_EN,
38462306a36Sopenharmony_ci	PWRAP_DCM_DBC_PRD,
38562306a36Sopenharmony_ci	PWRAP_EINT_STA0_ADR,
38662306a36Sopenharmony_ci	PWRAP_EINT_STA1_ADR,
38762306a36Sopenharmony_ci	PWRAP_SWINF_2_WDATA_31_0,
38862306a36Sopenharmony_ci	PWRAP_SWINF_2_RDATA_31_0,
38962306a36Sopenharmony_ci
39062306a36Sopenharmony_ci	/* MT2701 only regs */
39162306a36Sopenharmony_ci	PWRAP_ADC_CMD_ADDR,
39262306a36Sopenharmony_ci	PWRAP_PWRAP_ADC_CMD,
39362306a36Sopenharmony_ci	PWRAP_ADC_RDY_ADDR,
39462306a36Sopenharmony_ci	PWRAP_ADC_RDATA_ADDR1,
39562306a36Sopenharmony_ci	PWRAP_ADC_RDATA_ADDR2,
39662306a36Sopenharmony_ci
39762306a36Sopenharmony_ci	/* MT7622 only regs */
39862306a36Sopenharmony_ci	PWRAP_STA,
39962306a36Sopenharmony_ci	PWRAP_CLR,
40062306a36Sopenharmony_ci	PWRAP_DVFS_ADR8,
40162306a36Sopenharmony_ci	PWRAP_DVFS_WDATA8,
40262306a36Sopenharmony_ci	PWRAP_DVFS_ADR9,
40362306a36Sopenharmony_ci	PWRAP_DVFS_WDATA9,
40462306a36Sopenharmony_ci	PWRAP_DVFS_ADR10,
40562306a36Sopenharmony_ci	PWRAP_DVFS_WDATA10,
40662306a36Sopenharmony_ci	PWRAP_DVFS_ADR11,
40762306a36Sopenharmony_ci	PWRAP_DVFS_WDATA11,
40862306a36Sopenharmony_ci	PWRAP_DVFS_ADR12,
40962306a36Sopenharmony_ci	PWRAP_DVFS_WDATA12,
41062306a36Sopenharmony_ci	PWRAP_DVFS_ADR13,
41162306a36Sopenharmony_ci	PWRAP_DVFS_WDATA13,
41262306a36Sopenharmony_ci	PWRAP_DVFS_ADR14,
41362306a36Sopenharmony_ci	PWRAP_DVFS_WDATA14,
41462306a36Sopenharmony_ci	PWRAP_DVFS_ADR15,
41562306a36Sopenharmony_ci	PWRAP_DVFS_WDATA15,
41662306a36Sopenharmony_ci	PWRAP_EXT_CK,
41762306a36Sopenharmony_ci	PWRAP_ADC_RDATA_ADDR,
41862306a36Sopenharmony_ci	PWRAP_GPS_STA,
41962306a36Sopenharmony_ci	PWRAP_SW_RST,
42062306a36Sopenharmony_ci	PWRAP_DVFS_STEP_CTRL0,
42162306a36Sopenharmony_ci	PWRAP_DVFS_STEP_CTRL1,
42262306a36Sopenharmony_ci	PWRAP_DVFS_STEP_CTRL2,
42362306a36Sopenharmony_ci	PWRAP_SPI2_CTRL,
42462306a36Sopenharmony_ci
42562306a36Sopenharmony_ci	/* MT8135 only regs */
42662306a36Sopenharmony_ci	PWRAP_CSHEXT,
42762306a36Sopenharmony_ci	PWRAP_EVENT_IN_EN,
42862306a36Sopenharmony_ci	PWRAP_EVENT_DST_EN,
42962306a36Sopenharmony_ci	PWRAP_RRARB_INIT,
43062306a36Sopenharmony_ci	PWRAP_RRARB_EN,
43162306a36Sopenharmony_ci	PWRAP_RRARB_STA0,
43262306a36Sopenharmony_ci	PWRAP_RRARB_STA1,
43362306a36Sopenharmony_ci	PWRAP_EVENT_STA,
43462306a36Sopenharmony_ci	PWRAP_EVENT_STACLR,
43562306a36Sopenharmony_ci	PWRAP_CIPHER_LOAD,
43662306a36Sopenharmony_ci	PWRAP_CIPHER_START,
43762306a36Sopenharmony_ci
43862306a36Sopenharmony_ci	/* MT8173 only regs */
43962306a36Sopenharmony_ci	PWRAP_RDDMY,
44062306a36Sopenharmony_ci	PWRAP_SI_CK_CON,
44162306a36Sopenharmony_ci	PWRAP_DVFS_ADR0,
44262306a36Sopenharmony_ci	PWRAP_DVFS_WDATA0,
44362306a36Sopenharmony_ci	PWRAP_DVFS_ADR1,
44462306a36Sopenharmony_ci	PWRAP_DVFS_WDATA1,
44562306a36Sopenharmony_ci	PWRAP_DVFS_ADR2,
44662306a36Sopenharmony_ci	PWRAP_DVFS_WDATA2,
44762306a36Sopenharmony_ci	PWRAP_DVFS_ADR3,
44862306a36Sopenharmony_ci	PWRAP_DVFS_WDATA3,
44962306a36Sopenharmony_ci	PWRAP_DVFS_ADR4,
45062306a36Sopenharmony_ci	PWRAP_DVFS_WDATA4,
45162306a36Sopenharmony_ci	PWRAP_DVFS_ADR5,
45262306a36Sopenharmony_ci	PWRAP_DVFS_WDATA5,
45362306a36Sopenharmony_ci	PWRAP_DVFS_ADR6,
45462306a36Sopenharmony_ci	PWRAP_DVFS_WDATA6,
45562306a36Sopenharmony_ci	PWRAP_DVFS_ADR7,
45662306a36Sopenharmony_ci	PWRAP_DVFS_WDATA7,
45762306a36Sopenharmony_ci	PWRAP_SPMINF_STA,
45862306a36Sopenharmony_ci	PWRAP_CIPHER_EN,
45962306a36Sopenharmony_ci
46062306a36Sopenharmony_ci	/* MT8183 only regs */
46162306a36Sopenharmony_ci	PWRAP_SI_SAMPLE_CTRL,
46262306a36Sopenharmony_ci	PWRAP_CSLEXT_WRITE,
46362306a36Sopenharmony_ci	PWRAP_CSLEXT_READ,
46462306a36Sopenharmony_ci	PWRAP_EXT_CK_WRITE,
46562306a36Sopenharmony_ci	PWRAP_STAUPD_CTRL,
46662306a36Sopenharmony_ci	PWRAP_WACS_P2P_EN,
46762306a36Sopenharmony_ci	PWRAP_INIT_DONE_P2P,
46862306a36Sopenharmony_ci	PWRAP_WACS_MD32_EN,
46962306a36Sopenharmony_ci	PWRAP_INIT_DONE_MD32,
47062306a36Sopenharmony_ci	PWRAP_INT1_EN,
47162306a36Sopenharmony_ci	PWRAP_INT1_FLG,
47262306a36Sopenharmony_ci	PWRAP_INT1_CLR,
47362306a36Sopenharmony_ci	PWRAP_WDT_SRC_EN_1,
47462306a36Sopenharmony_ci	PWRAP_INT_GPS_AUXADC_CMD_ADDR,
47562306a36Sopenharmony_ci	PWRAP_INT_GPS_AUXADC_CMD,
47662306a36Sopenharmony_ci	PWRAP_INT_GPS_AUXADC_RDATA_ADDR,
47762306a36Sopenharmony_ci	PWRAP_EXT_GPS_AUXADC_RDATA_ADDR,
47862306a36Sopenharmony_ci	PWRAP_GPSINF_0_STA,
47962306a36Sopenharmony_ci	PWRAP_GPSINF_1_STA,
48062306a36Sopenharmony_ci
48162306a36Sopenharmony_ci	/* MT8516 only regs */
48262306a36Sopenharmony_ci	PWRAP_OP_TYPE,
48362306a36Sopenharmony_ci	PWRAP_MSB_FIRST,
48462306a36Sopenharmony_ci};
48562306a36Sopenharmony_ci
48662306a36Sopenharmony_cistatic int mt2701_regs[] = {
48762306a36Sopenharmony_ci	[PWRAP_MUX_SEL] =		0x0,
48862306a36Sopenharmony_ci	[PWRAP_WRAP_EN] =		0x4,
48962306a36Sopenharmony_ci	[PWRAP_DIO_EN] =		0x8,
49062306a36Sopenharmony_ci	[PWRAP_SIDLY] =			0xc,
49162306a36Sopenharmony_ci	[PWRAP_RDDMY] =			0x18,
49262306a36Sopenharmony_ci	[PWRAP_SI_CK_CON] =		0x1c,
49362306a36Sopenharmony_ci	[PWRAP_CSHEXT_WRITE] =		0x20,
49462306a36Sopenharmony_ci	[PWRAP_CSHEXT_READ] =		0x24,
49562306a36Sopenharmony_ci	[PWRAP_CSLEXT_START] =		0x28,
49662306a36Sopenharmony_ci	[PWRAP_CSLEXT_END] =		0x2c,
49762306a36Sopenharmony_ci	[PWRAP_STAUPD_PRD] =		0x30,
49862306a36Sopenharmony_ci	[PWRAP_STAUPD_GRPEN] =		0x34,
49962306a36Sopenharmony_ci	[PWRAP_STAUPD_MAN_TRIG] =	0x38,
50062306a36Sopenharmony_ci	[PWRAP_STAUPD_STA] =		0x3c,
50162306a36Sopenharmony_ci	[PWRAP_WRAP_STA] =		0x44,
50262306a36Sopenharmony_ci	[PWRAP_HARB_INIT] =		0x48,
50362306a36Sopenharmony_ci	[PWRAP_HARB_HPRIO] =		0x4c,
50462306a36Sopenharmony_ci	[PWRAP_HIPRIO_ARB_EN] =		0x50,
50562306a36Sopenharmony_ci	[PWRAP_HARB_STA0] =		0x54,
50662306a36Sopenharmony_ci	[PWRAP_HARB_STA1] =		0x58,
50762306a36Sopenharmony_ci	[PWRAP_MAN_EN] =		0x5c,
50862306a36Sopenharmony_ci	[PWRAP_MAN_CMD] =		0x60,
50962306a36Sopenharmony_ci	[PWRAP_MAN_RDATA] =		0x64,
51062306a36Sopenharmony_ci	[PWRAP_MAN_VLDCLR] =		0x68,
51162306a36Sopenharmony_ci	[PWRAP_WACS0_EN] =		0x6c,
51262306a36Sopenharmony_ci	[PWRAP_INIT_DONE0] =		0x70,
51362306a36Sopenharmony_ci	[PWRAP_WACS0_CMD] =		0x74,
51462306a36Sopenharmony_ci	[PWRAP_WACS0_RDATA] =		0x78,
51562306a36Sopenharmony_ci	[PWRAP_WACS0_VLDCLR] =		0x7c,
51662306a36Sopenharmony_ci	[PWRAP_WACS1_EN] =		0x80,
51762306a36Sopenharmony_ci	[PWRAP_INIT_DONE1] =		0x84,
51862306a36Sopenharmony_ci	[PWRAP_WACS1_CMD] =		0x88,
51962306a36Sopenharmony_ci	[PWRAP_WACS1_RDATA] =		0x8c,
52062306a36Sopenharmony_ci	[PWRAP_WACS1_VLDCLR] =		0x90,
52162306a36Sopenharmony_ci	[PWRAP_WACS2_EN] =		0x94,
52262306a36Sopenharmony_ci	[PWRAP_INIT_DONE2] =		0x98,
52362306a36Sopenharmony_ci	[PWRAP_WACS2_CMD] =		0x9c,
52462306a36Sopenharmony_ci	[PWRAP_WACS2_RDATA] =		0xa0,
52562306a36Sopenharmony_ci	[PWRAP_WACS2_VLDCLR] =		0xa4,
52662306a36Sopenharmony_ci	[PWRAP_INT_EN] =		0xa8,
52762306a36Sopenharmony_ci	[PWRAP_INT_FLG_RAW] =		0xac,
52862306a36Sopenharmony_ci	[PWRAP_INT_FLG] =		0xb0,
52962306a36Sopenharmony_ci	[PWRAP_INT_CLR] =		0xb4,
53062306a36Sopenharmony_ci	[PWRAP_SIG_ADR] =		0xb8,
53162306a36Sopenharmony_ci	[PWRAP_SIG_MODE] =		0xbc,
53262306a36Sopenharmony_ci	[PWRAP_SIG_VALUE] =		0xc0,
53362306a36Sopenharmony_ci	[PWRAP_SIG_ERRVAL] =		0xc4,
53462306a36Sopenharmony_ci	[PWRAP_CRC_EN] =		0xc8,
53562306a36Sopenharmony_ci	[PWRAP_TIMER_EN] =		0xcc,
53662306a36Sopenharmony_ci	[PWRAP_TIMER_STA] =		0xd0,
53762306a36Sopenharmony_ci	[PWRAP_WDT_UNIT] =		0xd4,
53862306a36Sopenharmony_ci	[PWRAP_WDT_SRC_EN] =		0xd8,
53962306a36Sopenharmony_ci	[PWRAP_WDT_FLG] =		0xdc,
54062306a36Sopenharmony_ci	[PWRAP_DEBUG_INT_SEL] =		0xe0,
54162306a36Sopenharmony_ci	[PWRAP_DVFS_ADR0] =		0xe4,
54262306a36Sopenharmony_ci	[PWRAP_DVFS_WDATA0] =		0xe8,
54362306a36Sopenharmony_ci	[PWRAP_DVFS_ADR1] =		0xec,
54462306a36Sopenharmony_ci	[PWRAP_DVFS_WDATA1] =		0xf0,
54562306a36Sopenharmony_ci	[PWRAP_DVFS_ADR2] =		0xf4,
54662306a36Sopenharmony_ci	[PWRAP_DVFS_WDATA2] =		0xf8,
54762306a36Sopenharmony_ci	[PWRAP_DVFS_ADR3] =		0xfc,
54862306a36Sopenharmony_ci	[PWRAP_DVFS_WDATA3] =		0x100,
54962306a36Sopenharmony_ci	[PWRAP_DVFS_ADR4] =		0x104,
55062306a36Sopenharmony_ci	[PWRAP_DVFS_WDATA4] =		0x108,
55162306a36Sopenharmony_ci	[PWRAP_DVFS_ADR5] =		0x10c,
55262306a36Sopenharmony_ci	[PWRAP_DVFS_WDATA5] =		0x110,
55362306a36Sopenharmony_ci	[PWRAP_DVFS_ADR6] =		0x114,
55462306a36Sopenharmony_ci	[PWRAP_DVFS_WDATA6] =		0x118,
55562306a36Sopenharmony_ci	[PWRAP_DVFS_ADR7] =		0x11c,
55662306a36Sopenharmony_ci	[PWRAP_DVFS_WDATA7] =		0x120,
55762306a36Sopenharmony_ci	[PWRAP_CIPHER_KEY_SEL] =	0x124,
55862306a36Sopenharmony_ci	[PWRAP_CIPHER_IV_SEL] =		0x128,
55962306a36Sopenharmony_ci	[PWRAP_CIPHER_EN] =		0x12c,
56062306a36Sopenharmony_ci	[PWRAP_CIPHER_RDY] =		0x130,
56162306a36Sopenharmony_ci	[PWRAP_CIPHER_MODE] =		0x134,
56262306a36Sopenharmony_ci	[PWRAP_CIPHER_SWRST] =		0x138,
56362306a36Sopenharmony_ci	[PWRAP_DCM_EN] =		0x13c,
56462306a36Sopenharmony_ci	[PWRAP_DCM_DBC_PRD] =		0x140,
56562306a36Sopenharmony_ci	[PWRAP_ADC_CMD_ADDR] =		0x144,
56662306a36Sopenharmony_ci	[PWRAP_PWRAP_ADC_CMD] =		0x148,
56762306a36Sopenharmony_ci	[PWRAP_ADC_RDY_ADDR] =		0x14c,
56862306a36Sopenharmony_ci	[PWRAP_ADC_RDATA_ADDR1] =	0x150,
56962306a36Sopenharmony_ci	[PWRAP_ADC_RDATA_ADDR2] =	0x154,
57062306a36Sopenharmony_ci};
57162306a36Sopenharmony_ci
57262306a36Sopenharmony_cistatic int mt6765_regs[] = {
57362306a36Sopenharmony_ci	[PWRAP_MUX_SEL] =		0x0,
57462306a36Sopenharmony_ci	[PWRAP_WRAP_EN] =		0x4,
57562306a36Sopenharmony_ci	[PWRAP_DIO_EN] =		0x8,
57662306a36Sopenharmony_ci	[PWRAP_RDDMY] =			0x20,
57762306a36Sopenharmony_ci	[PWRAP_CSHEXT_WRITE] =		0x24,
57862306a36Sopenharmony_ci	[PWRAP_CSHEXT_READ] =		0x28,
57962306a36Sopenharmony_ci	[PWRAP_CSLEXT_START] =		0x2C,
58062306a36Sopenharmony_ci	[PWRAP_CSLEXT_END] =		0x30,
58162306a36Sopenharmony_ci	[PWRAP_STAUPD_PRD] =		0x3C,
58262306a36Sopenharmony_ci	[PWRAP_HARB_HPRIO] =		0x68,
58362306a36Sopenharmony_ci	[PWRAP_HIPRIO_ARB_EN] =		0x6C,
58462306a36Sopenharmony_ci	[PWRAP_MAN_EN] =		0x7C,
58562306a36Sopenharmony_ci	[PWRAP_MAN_CMD] =		0x80,
58662306a36Sopenharmony_ci	[PWRAP_WACS0_EN] =		0x8C,
58762306a36Sopenharmony_ci	[PWRAP_WACS1_EN] =		0x94,
58862306a36Sopenharmony_ci	[PWRAP_WACS2_EN] =		0x9C,
58962306a36Sopenharmony_ci	[PWRAP_INIT_DONE2] =		0xA0,
59062306a36Sopenharmony_ci	[PWRAP_WACS2_CMD] =		0xC20,
59162306a36Sopenharmony_ci	[PWRAP_WACS2_RDATA] =		0xC24,
59262306a36Sopenharmony_ci	[PWRAP_WACS2_VLDCLR] =		0xC28,
59362306a36Sopenharmony_ci	[PWRAP_INT_EN] =		0xB4,
59462306a36Sopenharmony_ci	[PWRAP_INT_FLG_RAW] =		0xB8,
59562306a36Sopenharmony_ci	[PWRAP_INT_FLG] =		0xBC,
59662306a36Sopenharmony_ci	[PWRAP_INT_CLR] =		0xC0,
59762306a36Sopenharmony_ci	[PWRAP_TIMER_EN] =		0xE8,
59862306a36Sopenharmony_ci	[PWRAP_WDT_UNIT] =		0xF0,
59962306a36Sopenharmony_ci	[PWRAP_WDT_SRC_EN] =		0xF4,
60062306a36Sopenharmony_ci	[PWRAP_DCM_EN] =		0x1DC,
60162306a36Sopenharmony_ci	[PWRAP_DCM_DBC_PRD] =		0x1E0,
60262306a36Sopenharmony_ci};
60362306a36Sopenharmony_ci
60462306a36Sopenharmony_cistatic int mt6779_regs[] = {
60562306a36Sopenharmony_ci	[PWRAP_MUX_SEL] =		0x0,
60662306a36Sopenharmony_ci	[PWRAP_WRAP_EN] =		0x4,
60762306a36Sopenharmony_ci	[PWRAP_DIO_EN] =		0x8,
60862306a36Sopenharmony_ci	[PWRAP_RDDMY] =			0x20,
60962306a36Sopenharmony_ci	[PWRAP_CSHEXT_WRITE] =		0x24,
61062306a36Sopenharmony_ci	[PWRAP_CSHEXT_READ] =		0x28,
61162306a36Sopenharmony_ci	[PWRAP_CSLEXT_WRITE] =		0x2C,
61262306a36Sopenharmony_ci	[PWRAP_CSLEXT_READ] =		0x30,
61362306a36Sopenharmony_ci	[PWRAP_EXT_CK_WRITE] =		0x34,
61462306a36Sopenharmony_ci	[PWRAP_STAUPD_CTRL] =		0x3C,
61562306a36Sopenharmony_ci	[PWRAP_STAUPD_GRPEN] =		0x40,
61662306a36Sopenharmony_ci	[PWRAP_EINT_STA0_ADR] =		0x44,
61762306a36Sopenharmony_ci	[PWRAP_HARB_HPRIO] =		0x68,
61862306a36Sopenharmony_ci	[PWRAP_HIPRIO_ARB_EN] =		0x6C,
61962306a36Sopenharmony_ci	[PWRAP_MAN_EN] =		0x7C,
62062306a36Sopenharmony_ci	[PWRAP_MAN_CMD] =		0x80,
62162306a36Sopenharmony_ci	[PWRAP_WACS0_EN] =		0x8C,
62262306a36Sopenharmony_ci	[PWRAP_INIT_DONE0] =		0x90,
62362306a36Sopenharmony_ci	[PWRAP_WACS1_EN] =		0x94,
62462306a36Sopenharmony_ci	[PWRAP_WACS2_EN] =		0x9C,
62562306a36Sopenharmony_ci	[PWRAP_INIT_DONE1] =		0x98,
62662306a36Sopenharmony_ci	[PWRAP_INIT_DONE2] =		0xA0,
62762306a36Sopenharmony_ci	[PWRAP_INT_EN] =		0xBC,
62862306a36Sopenharmony_ci	[PWRAP_INT_FLG_RAW] =		0xC0,
62962306a36Sopenharmony_ci	[PWRAP_INT_FLG] =		0xC4,
63062306a36Sopenharmony_ci	[PWRAP_INT_CLR] =		0xC8,
63162306a36Sopenharmony_ci	[PWRAP_INT1_EN] =		0xCC,
63262306a36Sopenharmony_ci	[PWRAP_INT1_FLG] =		0xD4,
63362306a36Sopenharmony_ci	[PWRAP_INT1_CLR] =		0xD8,
63462306a36Sopenharmony_ci	[PWRAP_TIMER_EN] =		0xF0,
63562306a36Sopenharmony_ci	[PWRAP_WDT_UNIT] =		0xF8,
63662306a36Sopenharmony_ci	[PWRAP_WDT_SRC_EN] =		0xFC,
63762306a36Sopenharmony_ci	[PWRAP_WDT_SRC_EN_1] =		0x100,
63862306a36Sopenharmony_ci	[PWRAP_WACS2_CMD] =		0xC20,
63962306a36Sopenharmony_ci	[PWRAP_WACS2_RDATA] =		0xC24,
64062306a36Sopenharmony_ci	[PWRAP_WACS2_VLDCLR] =		0xC28,
64162306a36Sopenharmony_ci};
64262306a36Sopenharmony_ci
64362306a36Sopenharmony_cistatic int mt6795_regs[] = {
64462306a36Sopenharmony_ci	[PWRAP_MUX_SEL] =		0x0,
64562306a36Sopenharmony_ci	[PWRAP_WRAP_EN] =		0x4,
64662306a36Sopenharmony_ci	[PWRAP_DIO_EN] =		0x8,
64762306a36Sopenharmony_ci	[PWRAP_SIDLY] =			0xc,
64862306a36Sopenharmony_ci	[PWRAP_RDDMY] =			0x10,
64962306a36Sopenharmony_ci	[PWRAP_SI_CK_CON] =		0x14,
65062306a36Sopenharmony_ci	[PWRAP_CSHEXT_WRITE] =		0x18,
65162306a36Sopenharmony_ci	[PWRAP_CSHEXT_READ] =		0x1c,
65262306a36Sopenharmony_ci	[PWRAP_CSLEXT_START] =		0x20,
65362306a36Sopenharmony_ci	[PWRAP_CSLEXT_END] =		0x24,
65462306a36Sopenharmony_ci	[PWRAP_STAUPD_PRD] =		0x28,
65562306a36Sopenharmony_ci	[PWRAP_STAUPD_GRPEN] =		0x2c,
65662306a36Sopenharmony_ci	[PWRAP_EINT_STA0_ADR] =		0x30,
65762306a36Sopenharmony_ci	[PWRAP_EINT_STA1_ADR] =		0x34,
65862306a36Sopenharmony_ci	[PWRAP_STAUPD_MAN_TRIG] =	0x40,
65962306a36Sopenharmony_ci	[PWRAP_STAUPD_STA] =		0x44,
66062306a36Sopenharmony_ci	[PWRAP_WRAP_STA] =		0x48,
66162306a36Sopenharmony_ci	[PWRAP_HARB_INIT] =		0x4c,
66262306a36Sopenharmony_ci	[PWRAP_HARB_HPRIO] =		0x50,
66362306a36Sopenharmony_ci	[PWRAP_HIPRIO_ARB_EN] =		0x54,
66462306a36Sopenharmony_ci	[PWRAP_HARB_STA0] =		0x58,
66562306a36Sopenharmony_ci	[PWRAP_HARB_STA1] =		0x5c,
66662306a36Sopenharmony_ci	[PWRAP_MAN_EN] =		0x60,
66762306a36Sopenharmony_ci	[PWRAP_MAN_CMD] =		0x64,
66862306a36Sopenharmony_ci	[PWRAP_MAN_RDATA] =		0x68,
66962306a36Sopenharmony_ci	[PWRAP_MAN_VLDCLR] =		0x6c,
67062306a36Sopenharmony_ci	[PWRAP_WACS0_EN] =		0x70,
67162306a36Sopenharmony_ci	[PWRAP_INIT_DONE0] =		0x74,
67262306a36Sopenharmony_ci	[PWRAP_WACS0_CMD] =		0x78,
67362306a36Sopenharmony_ci	[PWRAP_WACS0_RDATA] =		0x7c,
67462306a36Sopenharmony_ci	[PWRAP_WACS0_VLDCLR] =		0x80,
67562306a36Sopenharmony_ci	[PWRAP_WACS1_EN] =		0x84,
67662306a36Sopenharmony_ci	[PWRAP_INIT_DONE1] =		0x88,
67762306a36Sopenharmony_ci	[PWRAP_WACS1_CMD] =		0x8c,
67862306a36Sopenharmony_ci	[PWRAP_WACS1_RDATA] =		0x90,
67962306a36Sopenharmony_ci	[PWRAP_WACS1_VLDCLR] =		0x94,
68062306a36Sopenharmony_ci	[PWRAP_WACS2_EN] =		0x98,
68162306a36Sopenharmony_ci	[PWRAP_INIT_DONE2] =		0x9c,
68262306a36Sopenharmony_ci	[PWRAP_WACS2_CMD] =		0xa0,
68362306a36Sopenharmony_ci	[PWRAP_WACS2_RDATA] =		0xa4,
68462306a36Sopenharmony_ci	[PWRAP_WACS2_VLDCLR] =		0xa8,
68562306a36Sopenharmony_ci	[PWRAP_INT_EN] =		0xac,
68662306a36Sopenharmony_ci	[PWRAP_INT_FLG_RAW] =		0xb0,
68762306a36Sopenharmony_ci	[PWRAP_INT_FLG] =		0xb4,
68862306a36Sopenharmony_ci	[PWRAP_INT_CLR] =		0xb8,
68962306a36Sopenharmony_ci	[PWRAP_SIG_ADR] =		0xbc,
69062306a36Sopenharmony_ci	[PWRAP_SIG_MODE] =		0xc0,
69162306a36Sopenharmony_ci	[PWRAP_SIG_VALUE] =		0xc4,
69262306a36Sopenharmony_ci	[PWRAP_SIG_ERRVAL] =		0xc8,
69362306a36Sopenharmony_ci	[PWRAP_CRC_EN] =		0xcc,
69462306a36Sopenharmony_ci	[PWRAP_TIMER_EN] =		0xd0,
69562306a36Sopenharmony_ci	[PWRAP_TIMER_STA] =		0xd4,
69662306a36Sopenharmony_ci	[PWRAP_WDT_UNIT] =		0xd8,
69762306a36Sopenharmony_ci	[PWRAP_WDT_SRC_EN] =		0xdc,
69862306a36Sopenharmony_ci	[PWRAP_WDT_FLG] =		0xe0,
69962306a36Sopenharmony_ci	[PWRAP_DEBUG_INT_SEL] =		0xe4,
70062306a36Sopenharmony_ci	[PWRAP_DVFS_ADR0] =		0xe8,
70162306a36Sopenharmony_ci	[PWRAP_DVFS_WDATA0] =		0xec,
70262306a36Sopenharmony_ci	[PWRAP_DVFS_ADR1] =		0xf0,
70362306a36Sopenharmony_ci	[PWRAP_DVFS_WDATA1] =		0xf4,
70462306a36Sopenharmony_ci	[PWRAP_DVFS_ADR2] =		0xf8,
70562306a36Sopenharmony_ci	[PWRAP_DVFS_WDATA2] =		0xfc,
70662306a36Sopenharmony_ci	[PWRAP_DVFS_ADR3] =		0x100,
70762306a36Sopenharmony_ci	[PWRAP_DVFS_WDATA3] =		0x104,
70862306a36Sopenharmony_ci	[PWRAP_DVFS_ADR4] =		0x108,
70962306a36Sopenharmony_ci	[PWRAP_DVFS_WDATA4] =		0x10c,
71062306a36Sopenharmony_ci	[PWRAP_DVFS_ADR5] =		0x110,
71162306a36Sopenharmony_ci	[PWRAP_DVFS_WDATA5] =		0x114,
71262306a36Sopenharmony_ci	[PWRAP_DVFS_ADR6] =		0x118,
71362306a36Sopenharmony_ci	[PWRAP_DVFS_WDATA6] =		0x11c,
71462306a36Sopenharmony_ci	[PWRAP_DVFS_ADR7] =		0x120,
71562306a36Sopenharmony_ci	[PWRAP_DVFS_WDATA7] =		0x124,
71662306a36Sopenharmony_ci	[PWRAP_SPMINF_STA] =		0x128,
71762306a36Sopenharmony_ci	[PWRAP_CIPHER_KEY_SEL] =	0x12c,
71862306a36Sopenharmony_ci	[PWRAP_CIPHER_IV_SEL] =		0x130,
71962306a36Sopenharmony_ci	[PWRAP_CIPHER_EN] =		0x134,
72062306a36Sopenharmony_ci	[PWRAP_CIPHER_RDY] =		0x138,
72162306a36Sopenharmony_ci	[PWRAP_CIPHER_MODE] =		0x13c,
72262306a36Sopenharmony_ci	[PWRAP_CIPHER_SWRST] =		0x140,
72362306a36Sopenharmony_ci	[PWRAP_DCM_EN] =		0x144,
72462306a36Sopenharmony_ci	[PWRAP_DCM_DBC_PRD] =		0x148,
72562306a36Sopenharmony_ci	[PWRAP_EXT_CK] =		0x14c,
72662306a36Sopenharmony_ci};
72762306a36Sopenharmony_ci
72862306a36Sopenharmony_cistatic int mt6797_regs[] = {
72962306a36Sopenharmony_ci	[PWRAP_MUX_SEL] =		0x0,
73062306a36Sopenharmony_ci	[PWRAP_WRAP_EN] =		0x4,
73162306a36Sopenharmony_ci	[PWRAP_DIO_EN] =		0x8,
73262306a36Sopenharmony_ci	[PWRAP_SIDLY] =			0xC,
73362306a36Sopenharmony_ci	[PWRAP_RDDMY] =			0x10,
73462306a36Sopenharmony_ci	[PWRAP_CSHEXT_WRITE] =		0x18,
73562306a36Sopenharmony_ci	[PWRAP_CSHEXT_READ] =		0x1C,
73662306a36Sopenharmony_ci	[PWRAP_CSLEXT_START] =		0x20,
73762306a36Sopenharmony_ci	[PWRAP_CSLEXT_END] =		0x24,
73862306a36Sopenharmony_ci	[PWRAP_STAUPD_PRD] =		0x28,
73962306a36Sopenharmony_ci	[PWRAP_HARB_HPRIO] =		0x50,
74062306a36Sopenharmony_ci	[PWRAP_HIPRIO_ARB_EN] =		0x54,
74162306a36Sopenharmony_ci	[PWRAP_MAN_EN] =		0x60,
74262306a36Sopenharmony_ci	[PWRAP_MAN_CMD] =		0x64,
74362306a36Sopenharmony_ci	[PWRAP_WACS0_EN] =		0x70,
74462306a36Sopenharmony_ci	[PWRAP_WACS1_EN] =		0x84,
74562306a36Sopenharmony_ci	[PWRAP_WACS2_EN] =		0x98,
74662306a36Sopenharmony_ci	[PWRAP_INIT_DONE2] =		0x9C,
74762306a36Sopenharmony_ci	[PWRAP_WACS2_CMD] =		0xA0,
74862306a36Sopenharmony_ci	[PWRAP_WACS2_RDATA] =		0xA4,
74962306a36Sopenharmony_ci	[PWRAP_WACS2_VLDCLR] =		0xA8,
75062306a36Sopenharmony_ci	[PWRAP_INT_EN] =		0xC0,
75162306a36Sopenharmony_ci	[PWRAP_INT_FLG_RAW] =		0xC4,
75262306a36Sopenharmony_ci	[PWRAP_INT_FLG] =		0xC8,
75362306a36Sopenharmony_ci	[PWRAP_INT_CLR] =		0xCC,
75462306a36Sopenharmony_ci	[PWRAP_TIMER_EN] =		0xF4,
75562306a36Sopenharmony_ci	[PWRAP_WDT_UNIT] =		0xFC,
75662306a36Sopenharmony_ci	[PWRAP_WDT_SRC_EN] =		0x100,
75762306a36Sopenharmony_ci	[PWRAP_DCM_EN] =		0x1CC,
75862306a36Sopenharmony_ci	[PWRAP_DCM_DBC_PRD] =		0x1D4,
75962306a36Sopenharmony_ci};
76062306a36Sopenharmony_ci
76162306a36Sopenharmony_cistatic int mt6873_regs[] = {
76262306a36Sopenharmony_ci	[PWRAP_INIT_DONE2] =		0x0,
76362306a36Sopenharmony_ci	[PWRAP_TIMER_EN] =		0x3E0,
76462306a36Sopenharmony_ci	[PWRAP_INT_EN] =		0x448,
76562306a36Sopenharmony_ci	[PWRAP_WACS2_CMD] =		0xC80,
76662306a36Sopenharmony_ci	[PWRAP_SWINF_2_WDATA_31_0] =	0xC84,
76762306a36Sopenharmony_ci	[PWRAP_SWINF_2_RDATA_31_0] =	0xC94,
76862306a36Sopenharmony_ci	[PWRAP_WACS2_VLDCLR] =		0xCA4,
76962306a36Sopenharmony_ci	[PWRAP_WACS2_RDATA] =		0xCA8,
77062306a36Sopenharmony_ci};
77162306a36Sopenharmony_ci
77262306a36Sopenharmony_cistatic int mt7622_regs[] = {
77362306a36Sopenharmony_ci	[PWRAP_MUX_SEL] =		0x0,
77462306a36Sopenharmony_ci	[PWRAP_WRAP_EN] =		0x4,
77562306a36Sopenharmony_ci	[PWRAP_DIO_EN] =		0x8,
77662306a36Sopenharmony_ci	[PWRAP_SIDLY] =			0xC,
77762306a36Sopenharmony_ci	[PWRAP_RDDMY] =			0x10,
77862306a36Sopenharmony_ci	[PWRAP_SI_CK_CON] =		0x14,
77962306a36Sopenharmony_ci	[PWRAP_CSHEXT_WRITE] =		0x18,
78062306a36Sopenharmony_ci	[PWRAP_CSHEXT_READ] =		0x1C,
78162306a36Sopenharmony_ci	[PWRAP_CSLEXT_START] =		0x20,
78262306a36Sopenharmony_ci	[PWRAP_CSLEXT_END] =		0x24,
78362306a36Sopenharmony_ci	[PWRAP_STAUPD_PRD] =		0x28,
78462306a36Sopenharmony_ci	[PWRAP_STAUPD_GRPEN] =		0x2C,
78562306a36Sopenharmony_ci	[PWRAP_EINT_STA0_ADR] =		0x30,
78662306a36Sopenharmony_ci	[PWRAP_EINT_STA1_ADR] =		0x34,
78762306a36Sopenharmony_ci	[PWRAP_STA] =			0x38,
78862306a36Sopenharmony_ci	[PWRAP_CLR] =			0x3C,
78962306a36Sopenharmony_ci	[PWRAP_STAUPD_MAN_TRIG] =	0x40,
79062306a36Sopenharmony_ci	[PWRAP_STAUPD_STA] =		0x44,
79162306a36Sopenharmony_ci	[PWRAP_WRAP_STA] =		0x48,
79262306a36Sopenharmony_ci	[PWRAP_HARB_INIT] =		0x4C,
79362306a36Sopenharmony_ci	[PWRAP_HARB_HPRIO] =		0x50,
79462306a36Sopenharmony_ci	[PWRAP_HIPRIO_ARB_EN] =		0x54,
79562306a36Sopenharmony_ci	[PWRAP_HARB_STA0] =		0x58,
79662306a36Sopenharmony_ci	[PWRAP_HARB_STA1] =		0x5C,
79762306a36Sopenharmony_ci	[PWRAP_MAN_EN] =		0x60,
79862306a36Sopenharmony_ci	[PWRAP_MAN_CMD] =		0x64,
79962306a36Sopenharmony_ci	[PWRAP_MAN_RDATA] =		0x68,
80062306a36Sopenharmony_ci	[PWRAP_MAN_VLDCLR] =		0x6C,
80162306a36Sopenharmony_ci	[PWRAP_WACS0_EN] =		0x70,
80262306a36Sopenharmony_ci	[PWRAP_INIT_DONE0] =		0x74,
80362306a36Sopenharmony_ci	[PWRAP_WACS0_CMD] =		0x78,
80462306a36Sopenharmony_ci	[PWRAP_WACS0_RDATA] =		0x7C,
80562306a36Sopenharmony_ci	[PWRAP_WACS0_VLDCLR] =		0x80,
80662306a36Sopenharmony_ci	[PWRAP_WACS1_EN] =		0x84,
80762306a36Sopenharmony_ci	[PWRAP_INIT_DONE1] =		0x88,
80862306a36Sopenharmony_ci	[PWRAP_WACS1_CMD] =		0x8C,
80962306a36Sopenharmony_ci	[PWRAP_WACS1_RDATA] =		0x90,
81062306a36Sopenharmony_ci	[PWRAP_WACS1_VLDCLR] =		0x94,
81162306a36Sopenharmony_ci	[PWRAP_WACS2_EN] =		0x98,
81262306a36Sopenharmony_ci	[PWRAP_INIT_DONE2] =		0x9C,
81362306a36Sopenharmony_ci	[PWRAP_WACS2_CMD] =		0xA0,
81462306a36Sopenharmony_ci	[PWRAP_WACS2_RDATA] =		0xA4,
81562306a36Sopenharmony_ci	[PWRAP_WACS2_VLDCLR] =		0xA8,
81662306a36Sopenharmony_ci	[PWRAP_INT_EN] =		0xAC,
81762306a36Sopenharmony_ci	[PWRAP_INT_FLG_RAW] =		0xB0,
81862306a36Sopenharmony_ci	[PWRAP_INT_FLG] =		0xB4,
81962306a36Sopenharmony_ci	[PWRAP_INT_CLR] =		0xB8,
82062306a36Sopenharmony_ci	[PWRAP_SIG_ADR] =		0xBC,
82162306a36Sopenharmony_ci	[PWRAP_SIG_MODE] =		0xC0,
82262306a36Sopenharmony_ci	[PWRAP_SIG_VALUE] =		0xC4,
82362306a36Sopenharmony_ci	[PWRAP_SIG_ERRVAL] =		0xC8,
82462306a36Sopenharmony_ci	[PWRAP_CRC_EN] =		0xCC,
82562306a36Sopenharmony_ci	[PWRAP_TIMER_EN] =		0xD0,
82662306a36Sopenharmony_ci	[PWRAP_TIMER_STA] =		0xD4,
82762306a36Sopenharmony_ci	[PWRAP_WDT_UNIT] =		0xD8,
82862306a36Sopenharmony_ci	[PWRAP_WDT_SRC_EN] =		0xDC,
82962306a36Sopenharmony_ci	[PWRAP_WDT_FLG] =		0xE0,
83062306a36Sopenharmony_ci	[PWRAP_DEBUG_INT_SEL] =		0xE4,
83162306a36Sopenharmony_ci	[PWRAP_DVFS_ADR0] =		0xE8,
83262306a36Sopenharmony_ci	[PWRAP_DVFS_WDATA0] =		0xEC,
83362306a36Sopenharmony_ci	[PWRAP_DVFS_ADR1] =		0xF0,
83462306a36Sopenharmony_ci	[PWRAP_DVFS_WDATA1] =		0xF4,
83562306a36Sopenharmony_ci	[PWRAP_DVFS_ADR2] =		0xF8,
83662306a36Sopenharmony_ci	[PWRAP_DVFS_WDATA2] =		0xFC,
83762306a36Sopenharmony_ci	[PWRAP_DVFS_ADR3] =		0x100,
83862306a36Sopenharmony_ci	[PWRAP_DVFS_WDATA3] =		0x104,
83962306a36Sopenharmony_ci	[PWRAP_DVFS_ADR4] =		0x108,
84062306a36Sopenharmony_ci	[PWRAP_DVFS_WDATA4] =		0x10C,
84162306a36Sopenharmony_ci	[PWRAP_DVFS_ADR5] =		0x110,
84262306a36Sopenharmony_ci	[PWRAP_DVFS_WDATA5] =		0x114,
84362306a36Sopenharmony_ci	[PWRAP_DVFS_ADR6] =		0x118,
84462306a36Sopenharmony_ci	[PWRAP_DVFS_WDATA6] =		0x11C,
84562306a36Sopenharmony_ci	[PWRAP_DVFS_ADR7] =		0x120,
84662306a36Sopenharmony_ci	[PWRAP_DVFS_WDATA7] =		0x124,
84762306a36Sopenharmony_ci	[PWRAP_DVFS_ADR8] =		0x128,
84862306a36Sopenharmony_ci	[PWRAP_DVFS_WDATA8] =		0x12C,
84962306a36Sopenharmony_ci	[PWRAP_DVFS_ADR9] =		0x130,
85062306a36Sopenharmony_ci	[PWRAP_DVFS_WDATA9] =		0x134,
85162306a36Sopenharmony_ci	[PWRAP_DVFS_ADR10] =		0x138,
85262306a36Sopenharmony_ci	[PWRAP_DVFS_WDATA10] =		0x13C,
85362306a36Sopenharmony_ci	[PWRAP_DVFS_ADR11] =		0x140,
85462306a36Sopenharmony_ci	[PWRAP_DVFS_WDATA11] =		0x144,
85562306a36Sopenharmony_ci	[PWRAP_DVFS_ADR12] =		0x148,
85662306a36Sopenharmony_ci	[PWRAP_DVFS_WDATA12] =		0x14C,
85762306a36Sopenharmony_ci	[PWRAP_DVFS_ADR13] =		0x150,
85862306a36Sopenharmony_ci	[PWRAP_DVFS_WDATA13] =		0x154,
85962306a36Sopenharmony_ci	[PWRAP_DVFS_ADR14] =		0x158,
86062306a36Sopenharmony_ci	[PWRAP_DVFS_WDATA14] =		0x15C,
86162306a36Sopenharmony_ci	[PWRAP_DVFS_ADR15] =		0x160,
86262306a36Sopenharmony_ci	[PWRAP_DVFS_WDATA15] =		0x164,
86362306a36Sopenharmony_ci	[PWRAP_SPMINF_STA] =		0x168,
86462306a36Sopenharmony_ci	[PWRAP_CIPHER_KEY_SEL] =	0x16C,
86562306a36Sopenharmony_ci	[PWRAP_CIPHER_IV_SEL] =		0x170,
86662306a36Sopenharmony_ci	[PWRAP_CIPHER_EN] =		0x174,
86762306a36Sopenharmony_ci	[PWRAP_CIPHER_RDY] =		0x178,
86862306a36Sopenharmony_ci	[PWRAP_CIPHER_MODE] =		0x17C,
86962306a36Sopenharmony_ci	[PWRAP_CIPHER_SWRST] =		0x180,
87062306a36Sopenharmony_ci	[PWRAP_DCM_EN] =		0x184,
87162306a36Sopenharmony_ci	[PWRAP_DCM_DBC_PRD] =		0x188,
87262306a36Sopenharmony_ci	[PWRAP_EXT_CK] =		0x18C,
87362306a36Sopenharmony_ci	[PWRAP_ADC_CMD_ADDR] =		0x190,
87462306a36Sopenharmony_ci	[PWRAP_PWRAP_ADC_CMD] =		0x194,
87562306a36Sopenharmony_ci	[PWRAP_ADC_RDATA_ADDR] =	0x198,
87662306a36Sopenharmony_ci	[PWRAP_GPS_STA] =		0x19C,
87762306a36Sopenharmony_ci	[PWRAP_SW_RST] =		0x1A0,
87862306a36Sopenharmony_ci	[PWRAP_DVFS_STEP_CTRL0] =	0x238,
87962306a36Sopenharmony_ci	[PWRAP_DVFS_STEP_CTRL1] =	0x23C,
88062306a36Sopenharmony_ci	[PWRAP_DVFS_STEP_CTRL2] =	0x240,
88162306a36Sopenharmony_ci	[PWRAP_SPI2_CTRL] =		0x244,
88262306a36Sopenharmony_ci};
88362306a36Sopenharmony_ci
88462306a36Sopenharmony_cistatic int mt8135_regs[] = {
88562306a36Sopenharmony_ci	[PWRAP_MUX_SEL] =		0x0,
88662306a36Sopenharmony_ci	[PWRAP_WRAP_EN] =		0x4,
88762306a36Sopenharmony_ci	[PWRAP_DIO_EN] =		0x8,
88862306a36Sopenharmony_ci	[PWRAP_SIDLY] =			0xc,
88962306a36Sopenharmony_ci	[PWRAP_CSHEXT] =		0x10,
89062306a36Sopenharmony_ci	[PWRAP_CSHEXT_WRITE] =		0x14,
89162306a36Sopenharmony_ci	[PWRAP_CSHEXT_READ] =		0x18,
89262306a36Sopenharmony_ci	[PWRAP_CSLEXT_START] =		0x1c,
89362306a36Sopenharmony_ci	[PWRAP_CSLEXT_END] =		0x20,
89462306a36Sopenharmony_ci	[PWRAP_STAUPD_PRD] =		0x24,
89562306a36Sopenharmony_ci	[PWRAP_STAUPD_GRPEN] =		0x28,
89662306a36Sopenharmony_ci	[PWRAP_STAUPD_MAN_TRIG] =	0x2c,
89762306a36Sopenharmony_ci	[PWRAP_STAUPD_STA] =		0x30,
89862306a36Sopenharmony_ci	[PWRAP_EVENT_IN_EN] =		0x34,
89962306a36Sopenharmony_ci	[PWRAP_EVENT_DST_EN] =		0x38,
90062306a36Sopenharmony_ci	[PWRAP_WRAP_STA] =		0x3c,
90162306a36Sopenharmony_ci	[PWRAP_RRARB_INIT] =		0x40,
90262306a36Sopenharmony_ci	[PWRAP_RRARB_EN] =		0x44,
90362306a36Sopenharmony_ci	[PWRAP_RRARB_STA0] =		0x48,
90462306a36Sopenharmony_ci	[PWRAP_RRARB_STA1] =		0x4c,
90562306a36Sopenharmony_ci	[PWRAP_HARB_INIT] =		0x50,
90662306a36Sopenharmony_ci	[PWRAP_HARB_HPRIO] =		0x54,
90762306a36Sopenharmony_ci	[PWRAP_HIPRIO_ARB_EN] =		0x58,
90862306a36Sopenharmony_ci	[PWRAP_HARB_STA0] =		0x5c,
90962306a36Sopenharmony_ci	[PWRAP_HARB_STA1] =		0x60,
91062306a36Sopenharmony_ci	[PWRAP_MAN_EN] =		0x64,
91162306a36Sopenharmony_ci	[PWRAP_MAN_CMD] =		0x68,
91262306a36Sopenharmony_ci	[PWRAP_MAN_RDATA] =		0x6c,
91362306a36Sopenharmony_ci	[PWRAP_MAN_VLDCLR] =		0x70,
91462306a36Sopenharmony_ci	[PWRAP_WACS0_EN] =		0x74,
91562306a36Sopenharmony_ci	[PWRAP_INIT_DONE0] =		0x78,
91662306a36Sopenharmony_ci	[PWRAP_WACS0_CMD] =		0x7c,
91762306a36Sopenharmony_ci	[PWRAP_WACS0_RDATA] =		0x80,
91862306a36Sopenharmony_ci	[PWRAP_WACS0_VLDCLR] =		0x84,
91962306a36Sopenharmony_ci	[PWRAP_WACS1_EN] =		0x88,
92062306a36Sopenharmony_ci	[PWRAP_INIT_DONE1] =		0x8c,
92162306a36Sopenharmony_ci	[PWRAP_WACS1_CMD] =		0x90,
92262306a36Sopenharmony_ci	[PWRAP_WACS1_RDATA] =		0x94,
92362306a36Sopenharmony_ci	[PWRAP_WACS1_VLDCLR] =		0x98,
92462306a36Sopenharmony_ci	[PWRAP_WACS2_EN] =		0x9c,
92562306a36Sopenharmony_ci	[PWRAP_INIT_DONE2] =		0xa0,
92662306a36Sopenharmony_ci	[PWRAP_WACS2_CMD] =		0xa4,
92762306a36Sopenharmony_ci	[PWRAP_WACS2_RDATA] =		0xa8,
92862306a36Sopenharmony_ci	[PWRAP_WACS2_VLDCLR] =		0xac,
92962306a36Sopenharmony_ci	[PWRAP_INT_EN] =		0xb0,
93062306a36Sopenharmony_ci	[PWRAP_INT_FLG_RAW] =		0xb4,
93162306a36Sopenharmony_ci	[PWRAP_INT_FLG] =		0xb8,
93262306a36Sopenharmony_ci	[PWRAP_INT_CLR] =		0xbc,
93362306a36Sopenharmony_ci	[PWRAP_SIG_ADR] =		0xc0,
93462306a36Sopenharmony_ci	[PWRAP_SIG_MODE] =		0xc4,
93562306a36Sopenharmony_ci	[PWRAP_SIG_VALUE] =		0xc8,
93662306a36Sopenharmony_ci	[PWRAP_SIG_ERRVAL] =		0xcc,
93762306a36Sopenharmony_ci	[PWRAP_CRC_EN] =		0xd0,
93862306a36Sopenharmony_ci	[PWRAP_EVENT_STA] =		0xd4,
93962306a36Sopenharmony_ci	[PWRAP_EVENT_STACLR] =		0xd8,
94062306a36Sopenharmony_ci	[PWRAP_TIMER_EN] =		0xdc,
94162306a36Sopenharmony_ci	[PWRAP_TIMER_STA] =		0xe0,
94262306a36Sopenharmony_ci	[PWRAP_WDT_UNIT] =		0xe4,
94362306a36Sopenharmony_ci	[PWRAP_WDT_SRC_EN] =		0xe8,
94462306a36Sopenharmony_ci	[PWRAP_WDT_FLG] =		0xec,
94562306a36Sopenharmony_ci	[PWRAP_DEBUG_INT_SEL] =		0xf0,
94662306a36Sopenharmony_ci	[PWRAP_CIPHER_KEY_SEL] =	0x134,
94762306a36Sopenharmony_ci	[PWRAP_CIPHER_IV_SEL] =		0x138,
94862306a36Sopenharmony_ci	[PWRAP_CIPHER_LOAD] =		0x13c,
94962306a36Sopenharmony_ci	[PWRAP_CIPHER_START] =		0x140,
95062306a36Sopenharmony_ci	[PWRAP_CIPHER_RDY] =		0x144,
95162306a36Sopenharmony_ci	[PWRAP_CIPHER_MODE] =		0x148,
95262306a36Sopenharmony_ci	[PWRAP_CIPHER_SWRST] =		0x14c,
95362306a36Sopenharmony_ci	[PWRAP_DCM_EN] =		0x15c,
95462306a36Sopenharmony_ci	[PWRAP_DCM_DBC_PRD] =		0x160,
95562306a36Sopenharmony_ci};
95662306a36Sopenharmony_ci
95762306a36Sopenharmony_cistatic int mt8173_regs[] = {
95862306a36Sopenharmony_ci	[PWRAP_MUX_SEL] =		0x0,
95962306a36Sopenharmony_ci	[PWRAP_WRAP_EN] =		0x4,
96062306a36Sopenharmony_ci	[PWRAP_DIO_EN] =		0x8,
96162306a36Sopenharmony_ci	[PWRAP_SIDLY] =			0xc,
96262306a36Sopenharmony_ci	[PWRAP_RDDMY] =			0x10,
96362306a36Sopenharmony_ci	[PWRAP_SI_CK_CON] =		0x14,
96462306a36Sopenharmony_ci	[PWRAP_CSHEXT_WRITE] =		0x18,
96562306a36Sopenharmony_ci	[PWRAP_CSHEXT_READ] =		0x1c,
96662306a36Sopenharmony_ci	[PWRAP_CSLEXT_START] =		0x20,
96762306a36Sopenharmony_ci	[PWRAP_CSLEXT_END] =		0x24,
96862306a36Sopenharmony_ci	[PWRAP_STAUPD_PRD] =		0x28,
96962306a36Sopenharmony_ci	[PWRAP_STAUPD_GRPEN] =		0x2c,
97062306a36Sopenharmony_ci	[PWRAP_STAUPD_MAN_TRIG] =	0x40,
97162306a36Sopenharmony_ci	[PWRAP_STAUPD_STA] =		0x44,
97262306a36Sopenharmony_ci	[PWRAP_WRAP_STA] =		0x48,
97362306a36Sopenharmony_ci	[PWRAP_HARB_INIT] =		0x4c,
97462306a36Sopenharmony_ci	[PWRAP_HARB_HPRIO] =		0x50,
97562306a36Sopenharmony_ci	[PWRAP_HIPRIO_ARB_EN] =		0x54,
97662306a36Sopenharmony_ci	[PWRAP_HARB_STA0] =		0x58,
97762306a36Sopenharmony_ci	[PWRAP_HARB_STA1] =		0x5c,
97862306a36Sopenharmony_ci	[PWRAP_MAN_EN] =		0x60,
97962306a36Sopenharmony_ci	[PWRAP_MAN_CMD] =		0x64,
98062306a36Sopenharmony_ci	[PWRAP_MAN_RDATA] =		0x68,
98162306a36Sopenharmony_ci	[PWRAP_MAN_VLDCLR] =		0x6c,
98262306a36Sopenharmony_ci	[PWRAP_WACS0_EN] =		0x70,
98362306a36Sopenharmony_ci	[PWRAP_INIT_DONE0] =		0x74,
98462306a36Sopenharmony_ci	[PWRAP_WACS0_CMD] =		0x78,
98562306a36Sopenharmony_ci	[PWRAP_WACS0_RDATA] =		0x7c,
98662306a36Sopenharmony_ci	[PWRAP_WACS0_VLDCLR] =		0x80,
98762306a36Sopenharmony_ci	[PWRAP_WACS1_EN] =		0x84,
98862306a36Sopenharmony_ci	[PWRAP_INIT_DONE1] =		0x88,
98962306a36Sopenharmony_ci	[PWRAP_WACS1_CMD] =		0x8c,
99062306a36Sopenharmony_ci	[PWRAP_WACS1_RDATA] =		0x90,
99162306a36Sopenharmony_ci	[PWRAP_WACS1_VLDCLR] =		0x94,
99262306a36Sopenharmony_ci	[PWRAP_WACS2_EN] =		0x98,
99362306a36Sopenharmony_ci	[PWRAP_INIT_DONE2] =		0x9c,
99462306a36Sopenharmony_ci	[PWRAP_WACS2_CMD] =		0xa0,
99562306a36Sopenharmony_ci	[PWRAP_WACS2_RDATA] =		0xa4,
99662306a36Sopenharmony_ci	[PWRAP_WACS2_VLDCLR] =		0xa8,
99762306a36Sopenharmony_ci	[PWRAP_INT_EN] =		0xac,
99862306a36Sopenharmony_ci	[PWRAP_INT_FLG_RAW] =		0xb0,
99962306a36Sopenharmony_ci	[PWRAP_INT_FLG] =		0xb4,
100062306a36Sopenharmony_ci	[PWRAP_INT_CLR] =		0xb8,
100162306a36Sopenharmony_ci	[PWRAP_SIG_ADR] =		0xbc,
100262306a36Sopenharmony_ci	[PWRAP_SIG_MODE] =		0xc0,
100362306a36Sopenharmony_ci	[PWRAP_SIG_VALUE] =		0xc4,
100462306a36Sopenharmony_ci	[PWRAP_SIG_ERRVAL] =		0xc8,
100562306a36Sopenharmony_ci	[PWRAP_CRC_EN] =		0xcc,
100662306a36Sopenharmony_ci	[PWRAP_TIMER_EN] =		0xd0,
100762306a36Sopenharmony_ci	[PWRAP_TIMER_STA] =		0xd4,
100862306a36Sopenharmony_ci	[PWRAP_WDT_UNIT] =		0xd8,
100962306a36Sopenharmony_ci	[PWRAP_WDT_SRC_EN] =		0xdc,
101062306a36Sopenharmony_ci	[PWRAP_WDT_FLG] =		0xe0,
101162306a36Sopenharmony_ci	[PWRAP_DEBUG_INT_SEL] =		0xe4,
101262306a36Sopenharmony_ci	[PWRAP_DVFS_ADR0] =		0xe8,
101362306a36Sopenharmony_ci	[PWRAP_DVFS_WDATA0] =		0xec,
101462306a36Sopenharmony_ci	[PWRAP_DVFS_ADR1] =		0xf0,
101562306a36Sopenharmony_ci	[PWRAP_DVFS_WDATA1] =		0xf4,
101662306a36Sopenharmony_ci	[PWRAP_DVFS_ADR2] =		0xf8,
101762306a36Sopenharmony_ci	[PWRAP_DVFS_WDATA2] =		0xfc,
101862306a36Sopenharmony_ci	[PWRAP_DVFS_ADR3] =		0x100,
101962306a36Sopenharmony_ci	[PWRAP_DVFS_WDATA3] =		0x104,
102062306a36Sopenharmony_ci	[PWRAP_DVFS_ADR4] =		0x108,
102162306a36Sopenharmony_ci	[PWRAP_DVFS_WDATA4] =		0x10c,
102262306a36Sopenharmony_ci	[PWRAP_DVFS_ADR5] =		0x110,
102362306a36Sopenharmony_ci	[PWRAP_DVFS_WDATA5] =		0x114,
102462306a36Sopenharmony_ci	[PWRAP_DVFS_ADR6] =		0x118,
102562306a36Sopenharmony_ci	[PWRAP_DVFS_WDATA6] =		0x11c,
102662306a36Sopenharmony_ci	[PWRAP_DVFS_ADR7] =		0x120,
102762306a36Sopenharmony_ci	[PWRAP_DVFS_WDATA7] =		0x124,
102862306a36Sopenharmony_ci	[PWRAP_SPMINF_STA] =		0x128,
102962306a36Sopenharmony_ci	[PWRAP_CIPHER_KEY_SEL] =	0x12c,
103062306a36Sopenharmony_ci	[PWRAP_CIPHER_IV_SEL] =		0x130,
103162306a36Sopenharmony_ci	[PWRAP_CIPHER_EN] =		0x134,
103262306a36Sopenharmony_ci	[PWRAP_CIPHER_RDY] =		0x138,
103362306a36Sopenharmony_ci	[PWRAP_CIPHER_MODE] =		0x13c,
103462306a36Sopenharmony_ci	[PWRAP_CIPHER_SWRST] =		0x140,
103562306a36Sopenharmony_ci	[PWRAP_DCM_EN] =		0x144,
103662306a36Sopenharmony_ci	[PWRAP_DCM_DBC_PRD] =		0x148,
103762306a36Sopenharmony_ci};
103862306a36Sopenharmony_ci
103962306a36Sopenharmony_cistatic int mt8183_regs[] = {
104062306a36Sopenharmony_ci	[PWRAP_MUX_SEL] =			0x0,
104162306a36Sopenharmony_ci	[PWRAP_WRAP_EN] =			0x4,
104262306a36Sopenharmony_ci	[PWRAP_DIO_EN] =			0x8,
104362306a36Sopenharmony_ci	[PWRAP_SI_SAMPLE_CTRL] =		0xC,
104462306a36Sopenharmony_ci	[PWRAP_RDDMY] =				0x14,
104562306a36Sopenharmony_ci	[PWRAP_CSHEXT_WRITE] =			0x18,
104662306a36Sopenharmony_ci	[PWRAP_CSHEXT_READ] =			0x1C,
104762306a36Sopenharmony_ci	[PWRAP_CSLEXT_WRITE] =			0x20,
104862306a36Sopenharmony_ci	[PWRAP_CSLEXT_READ] =			0x24,
104962306a36Sopenharmony_ci	[PWRAP_EXT_CK_WRITE] =			0x28,
105062306a36Sopenharmony_ci	[PWRAP_STAUPD_CTRL] =			0x30,
105162306a36Sopenharmony_ci	[PWRAP_STAUPD_GRPEN] =			0x34,
105262306a36Sopenharmony_ci	[PWRAP_EINT_STA0_ADR] =			0x38,
105362306a36Sopenharmony_ci	[PWRAP_HARB_HPRIO] =			0x5C,
105462306a36Sopenharmony_ci	[PWRAP_HIPRIO_ARB_EN] =			0x60,
105562306a36Sopenharmony_ci	[PWRAP_MAN_EN] =			0x70,
105662306a36Sopenharmony_ci	[PWRAP_MAN_CMD] =			0x74,
105762306a36Sopenharmony_ci	[PWRAP_WACS0_EN] =			0x80,
105862306a36Sopenharmony_ci	[PWRAP_INIT_DONE0] =			0x84,
105962306a36Sopenharmony_ci	[PWRAP_WACS1_EN] =			0x88,
106062306a36Sopenharmony_ci	[PWRAP_INIT_DONE1] =			0x8C,
106162306a36Sopenharmony_ci	[PWRAP_WACS2_EN] =			0x90,
106262306a36Sopenharmony_ci	[PWRAP_INIT_DONE2] =			0x94,
106362306a36Sopenharmony_ci	[PWRAP_WACS_P2P_EN] =			0xA0,
106462306a36Sopenharmony_ci	[PWRAP_INIT_DONE_P2P] =			0xA4,
106562306a36Sopenharmony_ci	[PWRAP_WACS_MD32_EN] =			0xA8,
106662306a36Sopenharmony_ci	[PWRAP_INIT_DONE_MD32] =		0xAC,
106762306a36Sopenharmony_ci	[PWRAP_INT_EN] =			0xB0,
106862306a36Sopenharmony_ci	[PWRAP_INT_FLG] =			0xB8,
106962306a36Sopenharmony_ci	[PWRAP_INT_CLR] =			0xBC,
107062306a36Sopenharmony_ci	[PWRAP_INT1_EN] =			0xC0,
107162306a36Sopenharmony_ci	[PWRAP_INT1_FLG] =			0xC8,
107262306a36Sopenharmony_ci	[PWRAP_INT1_CLR] =			0xCC,
107362306a36Sopenharmony_ci	[PWRAP_SIG_ADR] =			0xD0,
107462306a36Sopenharmony_ci	[PWRAP_CRC_EN] =			0xE0,
107562306a36Sopenharmony_ci	[PWRAP_TIMER_EN] =			0xE4,
107662306a36Sopenharmony_ci	[PWRAP_WDT_UNIT] =			0xEC,
107762306a36Sopenharmony_ci	[PWRAP_WDT_SRC_EN] =			0xF0,
107862306a36Sopenharmony_ci	[PWRAP_WDT_SRC_EN_1] =			0xF4,
107962306a36Sopenharmony_ci	[PWRAP_INT_GPS_AUXADC_CMD_ADDR] =	0x1DC,
108062306a36Sopenharmony_ci	[PWRAP_INT_GPS_AUXADC_CMD] =		0x1E0,
108162306a36Sopenharmony_ci	[PWRAP_INT_GPS_AUXADC_RDATA_ADDR] =	0x1E4,
108262306a36Sopenharmony_ci	[PWRAP_EXT_GPS_AUXADC_RDATA_ADDR] =	0x1E8,
108362306a36Sopenharmony_ci	[PWRAP_GPSINF_0_STA] =			0x1EC,
108462306a36Sopenharmony_ci	[PWRAP_GPSINF_1_STA] =			0x1F0,
108562306a36Sopenharmony_ci	[PWRAP_WACS2_CMD] =			0xC20,
108662306a36Sopenharmony_ci	[PWRAP_WACS2_RDATA] =			0xC24,
108762306a36Sopenharmony_ci	[PWRAP_WACS2_VLDCLR] =			0xC28,
108862306a36Sopenharmony_ci};
108962306a36Sopenharmony_ci
109062306a36Sopenharmony_cistatic int mt8195_regs[] = {
109162306a36Sopenharmony_ci	[PWRAP_INIT_DONE2] =		0x0,
109262306a36Sopenharmony_ci	[PWRAP_STAUPD_CTRL] =		0x4C,
109362306a36Sopenharmony_ci	[PWRAP_TIMER_EN] =		0x3E4,
109462306a36Sopenharmony_ci	[PWRAP_INT_EN] =		0x420,
109562306a36Sopenharmony_ci	[PWRAP_INT_FLG] =		0x428,
109662306a36Sopenharmony_ci	[PWRAP_INT_CLR] =		0x42C,
109762306a36Sopenharmony_ci	[PWRAP_INT1_EN] =		0x450,
109862306a36Sopenharmony_ci	[PWRAP_INT1_FLG] =		0x458,
109962306a36Sopenharmony_ci	[PWRAP_INT1_CLR] =		0x45C,
110062306a36Sopenharmony_ci	[PWRAP_WACS2_CMD] =		0x880,
110162306a36Sopenharmony_ci	[PWRAP_SWINF_2_WDATA_31_0] =	0x884,
110262306a36Sopenharmony_ci	[PWRAP_SWINF_2_RDATA_31_0] =	0x894,
110362306a36Sopenharmony_ci	[PWRAP_WACS2_VLDCLR] =		0x8A4,
110462306a36Sopenharmony_ci	[PWRAP_WACS2_RDATA] =		0x8A8,
110562306a36Sopenharmony_ci};
110662306a36Sopenharmony_ci
110762306a36Sopenharmony_cistatic int mt8365_regs[] = {
110862306a36Sopenharmony_ci	[PWRAP_MUX_SEL] =		0x0,
110962306a36Sopenharmony_ci	[PWRAP_WRAP_EN] =		0x4,
111062306a36Sopenharmony_ci	[PWRAP_DIO_EN] =		0x8,
111162306a36Sopenharmony_ci	[PWRAP_CSHEXT_WRITE] =		0x24,
111262306a36Sopenharmony_ci	[PWRAP_CSHEXT_READ] =		0x28,
111362306a36Sopenharmony_ci	[PWRAP_STAUPD_PRD] =		0x3c,
111462306a36Sopenharmony_ci	[PWRAP_STAUPD_GRPEN] =		0x40,
111562306a36Sopenharmony_ci	[PWRAP_STAUPD_MAN_TRIG] =	0x58,
111662306a36Sopenharmony_ci	[PWRAP_STAUPD_STA] =		0x5c,
111762306a36Sopenharmony_ci	[PWRAP_WRAP_STA] =		0x60,
111862306a36Sopenharmony_ci	[PWRAP_HARB_INIT] =		0x64,
111962306a36Sopenharmony_ci	[PWRAP_HARB_HPRIO] =		0x68,
112062306a36Sopenharmony_ci	[PWRAP_HIPRIO_ARB_EN] =		0x6c,
112162306a36Sopenharmony_ci	[PWRAP_HARB_STA0] =		0x70,
112262306a36Sopenharmony_ci	[PWRAP_HARB_STA1] =		0x74,
112362306a36Sopenharmony_ci	[PWRAP_MAN_EN] =		0x7c,
112462306a36Sopenharmony_ci	[PWRAP_MAN_CMD] =		0x80,
112562306a36Sopenharmony_ci	[PWRAP_MAN_RDATA] =		0x84,
112662306a36Sopenharmony_ci	[PWRAP_MAN_VLDCLR] =		0x88,
112762306a36Sopenharmony_ci	[PWRAP_WACS0_EN] =		0x8c,
112862306a36Sopenharmony_ci	[PWRAP_INIT_DONE0] =		0x90,
112962306a36Sopenharmony_ci	[PWRAP_WACS0_CMD] =		0xc00,
113062306a36Sopenharmony_ci	[PWRAP_WACS0_RDATA] =		0xc04,
113162306a36Sopenharmony_ci	[PWRAP_WACS0_VLDCLR] =		0xc08,
113262306a36Sopenharmony_ci	[PWRAP_WACS1_EN] =		0x94,
113362306a36Sopenharmony_ci	[PWRAP_INIT_DONE1] =		0x98,
113462306a36Sopenharmony_ci	[PWRAP_WACS2_EN] =		0x9c,
113562306a36Sopenharmony_ci	[PWRAP_INIT_DONE2] =		0xa0,
113662306a36Sopenharmony_ci	[PWRAP_WACS2_CMD] =		0xc20,
113762306a36Sopenharmony_ci	[PWRAP_WACS2_RDATA] =		0xc24,
113862306a36Sopenharmony_ci	[PWRAP_WACS2_VLDCLR] =		0xc28,
113962306a36Sopenharmony_ci	[PWRAP_INT_EN] =		0xb4,
114062306a36Sopenharmony_ci	[PWRAP_INT_FLG_RAW] =		0xb8,
114162306a36Sopenharmony_ci	[PWRAP_INT_FLG] =		0xbc,
114262306a36Sopenharmony_ci	[PWRAP_INT_CLR] =		0xc0,
114362306a36Sopenharmony_ci	[PWRAP_SIG_ADR] =		0xd4,
114462306a36Sopenharmony_ci	[PWRAP_SIG_MODE] =		0xd8,
114562306a36Sopenharmony_ci	[PWRAP_SIG_VALUE] =		0xdc,
114662306a36Sopenharmony_ci	[PWRAP_SIG_ERRVAL] =		0xe0,
114762306a36Sopenharmony_ci	[PWRAP_CRC_EN] =		0xe4,
114862306a36Sopenharmony_ci	[PWRAP_TIMER_EN] =		0xe8,
114962306a36Sopenharmony_ci	[PWRAP_TIMER_STA] =		0xec,
115062306a36Sopenharmony_ci	[PWRAP_WDT_UNIT] =		0xf0,
115162306a36Sopenharmony_ci	[PWRAP_WDT_SRC_EN] =		0xf4,
115262306a36Sopenharmony_ci	[PWRAP_WDT_FLG] =		0xfc,
115362306a36Sopenharmony_ci	[PWRAP_DEBUG_INT_SEL] =		0x104,
115462306a36Sopenharmony_ci	[PWRAP_CIPHER_KEY_SEL] =	0x1c4,
115562306a36Sopenharmony_ci	[PWRAP_CIPHER_IV_SEL] =		0x1c8,
115662306a36Sopenharmony_ci	[PWRAP_CIPHER_RDY] =		0x1d0,
115762306a36Sopenharmony_ci	[PWRAP_CIPHER_MODE] =		0x1d4,
115862306a36Sopenharmony_ci	[PWRAP_CIPHER_SWRST] =		0x1d8,
115962306a36Sopenharmony_ci	[PWRAP_DCM_EN] =		0x1dc,
116062306a36Sopenharmony_ci	[PWRAP_DCM_DBC_PRD] =		0x1e0,
116162306a36Sopenharmony_ci	[PWRAP_EINT_STA0_ADR] =		0x44,
116262306a36Sopenharmony_ci	[PWRAP_EINT_STA1_ADR] =		0x48,
116362306a36Sopenharmony_ci	[PWRAP_INT1_EN] =		0xc4,
116462306a36Sopenharmony_ci	[PWRAP_INT1_FLG] =		0xcc,
116562306a36Sopenharmony_ci	[PWRAP_INT1_CLR] =		0xd0,
116662306a36Sopenharmony_ci	[PWRAP_WDT_SRC_EN_1] =		0xf8,
116762306a36Sopenharmony_ci};
116862306a36Sopenharmony_ci
116962306a36Sopenharmony_cistatic int mt8516_regs[] = {
117062306a36Sopenharmony_ci	[PWRAP_MUX_SEL] =		0x0,
117162306a36Sopenharmony_ci	[PWRAP_WRAP_EN] =		0x4,
117262306a36Sopenharmony_ci	[PWRAP_DIO_EN] =		0x8,
117362306a36Sopenharmony_ci	[PWRAP_SIDLY] =			0xc,
117462306a36Sopenharmony_ci	[PWRAP_RDDMY] =			0x10,
117562306a36Sopenharmony_ci	[PWRAP_SI_CK_CON] =		0x14,
117662306a36Sopenharmony_ci	[PWRAP_CSHEXT_WRITE] =		0x18,
117762306a36Sopenharmony_ci	[PWRAP_CSHEXT_READ] =		0x1c,
117862306a36Sopenharmony_ci	[PWRAP_CSLEXT_START] =		0x20,
117962306a36Sopenharmony_ci	[PWRAP_CSLEXT_END] =		0x24,
118062306a36Sopenharmony_ci	[PWRAP_STAUPD_PRD] =		0x28,
118162306a36Sopenharmony_ci	[PWRAP_STAUPD_GRPEN] =		0x2c,
118262306a36Sopenharmony_ci	[PWRAP_STAUPD_MAN_TRIG] =	0x40,
118362306a36Sopenharmony_ci	[PWRAP_STAUPD_STA] =		0x44,
118462306a36Sopenharmony_ci	[PWRAP_WRAP_STA] =		0x48,
118562306a36Sopenharmony_ci	[PWRAP_HARB_INIT] =		0x4c,
118662306a36Sopenharmony_ci	[PWRAP_HARB_HPRIO] =		0x50,
118762306a36Sopenharmony_ci	[PWRAP_HIPRIO_ARB_EN] =		0x54,
118862306a36Sopenharmony_ci	[PWRAP_HARB_STA0] =		0x58,
118962306a36Sopenharmony_ci	[PWRAP_HARB_STA1] =		0x5c,
119062306a36Sopenharmony_ci	[PWRAP_MAN_EN] =		0x60,
119162306a36Sopenharmony_ci	[PWRAP_MAN_CMD] =		0x64,
119262306a36Sopenharmony_ci	[PWRAP_MAN_RDATA] =		0x68,
119362306a36Sopenharmony_ci	[PWRAP_MAN_VLDCLR] =		0x6c,
119462306a36Sopenharmony_ci	[PWRAP_WACS0_EN] =		0x70,
119562306a36Sopenharmony_ci	[PWRAP_INIT_DONE0] =		0x74,
119662306a36Sopenharmony_ci	[PWRAP_WACS0_CMD] =		0x78,
119762306a36Sopenharmony_ci	[PWRAP_WACS0_RDATA] =		0x7c,
119862306a36Sopenharmony_ci	[PWRAP_WACS0_VLDCLR] =		0x80,
119962306a36Sopenharmony_ci	[PWRAP_WACS1_EN] =		0x84,
120062306a36Sopenharmony_ci	[PWRAP_INIT_DONE1] =		0x88,
120162306a36Sopenharmony_ci	[PWRAP_WACS1_CMD] =		0x8c,
120262306a36Sopenharmony_ci	[PWRAP_WACS1_RDATA] =		0x90,
120362306a36Sopenharmony_ci	[PWRAP_WACS1_VLDCLR] =		0x94,
120462306a36Sopenharmony_ci	[PWRAP_WACS2_EN] =		0x98,
120562306a36Sopenharmony_ci	[PWRAP_INIT_DONE2] =		0x9c,
120662306a36Sopenharmony_ci	[PWRAP_WACS2_CMD] =		0xa0,
120762306a36Sopenharmony_ci	[PWRAP_WACS2_RDATA] =		0xa4,
120862306a36Sopenharmony_ci	[PWRAP_WACS2_VLDCLR] =		0xa8,
120962306a36Sopenharmony_ci	[PWRAP_INT_EN] =		0xac,
121062306a36Sopenharmony_ci	[PWRAP_INT_FLG_RAW] =		0xb0,
121162306a36Sopenharmony_ci	[PWRAP_INT_FLG] =		0xb4,
121262306a36Sopenharmony_ci	[PWRAP_INT_CLR] =		0xb8,
121362306a36Sopenharmony_ci	[PWRAP_SIG_ADR] =		0xbc,
121462306a36Sopenharmony_ci	[PWRAP_SIG_MODE] =		0xc0,
121562306a36Sopenharmony_ci	[PWRAP_SIG_VALUE] =		0xc4,
121662306a36Sopenharmony_ci	[PWRAP_SIG_ERRVAL] =		0xc8,
121762306a36Sopenharmony_ci	[PWRAP_CRC_EN] =		0xcc,
121862306a36Sopenharmony_ci	[PWRAP_TIMER_EN] =		0xd0,
121962306a36Sopenharmony_ci	[PWRAP_TIMER_STA] =		0xd4,
122062306a36Sopenharmony_ci	[PWRAP_WDT_UNIT] =		0xd8,
122162306a36Sopenharmony_ci	[PWRAP_WDT_SRC_EN] =		0xdc,
122262306a36Sopenharmony_ci	[PWRAP_WDT_FLG] =		0xe0,
122362306a36Sopenharmony_ci	[PWRAP_DEBUG_INT_SEL] =		0xe4,
122462306a36Sopenharmony_ci	[PWRAP_DVFS_ADR0] =		0xe8,
122562306a36Sopenharmony_ci	[PWRAP_DVFS_WDATA0] =		0xec,
122662306a36Sopenharmony_ci	[PWRAP_DVFS_ADR1] =		0xf0,
122762306a36Sopenharmony_ci	[PWRAP_DVFS_WDATA1] =		0xf4,
122862306a36Sopenharmony_ci	[PWRAP_DVFS_ADR2] =		0xf8,
122962306a36Sopenharmony_ci	[PWRAP_DVFS_WDATA2] =		0xfc,
123062306a36Sopenharmony_ci	[PWRAP_DVFS_ADR3] =		0x100,
123162306a36Sopenharmony_ci	[PWRAP_DVFS_WDATA3] =		0x104,
123262306a36Sopenharmony_ci	[PWRAP_DVFS_ADR4] =		0x108,
123362306a36Sopenharmony_ci	[PWRAP_DVFS_WDATA4] =		0x10c,
123462306a36Sopenharmony_ci	[PWRAP_DVFS_ADR5] =		0x110,
123562306a36Sopenharmony_ci	[PWRAP_DVFS_WDATA5] =		0x114,
123662306a36Sopenharmony_ci	[PWRAP_DVFS_ADR6] =		0x118,
123762306a36Sopenharmony_ci	[PWRAP_DVFS_WDATA6] =		0x11c,
123862306a36Sopenharmony_ci	[PWRAP_DVFS_ADR7] =		0x120,
123962306a36Sopenharmony_ci	[PWRAP_DVFS_WDATA7] =		0x124,
124062306a36Sopenharmony_ci	[PWRAP_SPMINF_STA] =		0x128,
124162306a36Sopenharmony_ci	[PWRAP_CIPHER_KEY_SEL] =	0x12c,
124262306a36Sopenharmony_ci	[PWRAP_CIPHER_IV_SEL] =		0x130,
124362306a36Sopenharmony_ci	[PWRAP_CIPHER_EN] =		0x134,
124462306a36Sopenharmony_ci	[PWRAP_CIPHER_RDY] =		0x138,
124562306a36Sopenharmony_ci	[PWRAP_CIPHER_MODE] =		0x13c,
124662306a36Sopenharmony_ci	[PWRAP_CIPHER_SWRST] =		0x140,
124762306a36Sopenharmony_ci	[PWRAP_DCM_EN] =		0x144,
124862306a36Sopenharmony_ci	[PWRAP_DCM_DBC_PRD] =		0x148,
124962306a36Sopenharmony_ci	[PWRAP_SW_RST] =		0x168,
125062306a36Sopenharmony_ci	[PWRAP_OP_TYPE] =		0x16c,
125162306a36Sopenharmony_ci	[PWRAP_MSB_FIRST] =		0x170,
125262306a36Sopenharmony_ci};
125362306a36Sopenharmony_ci
125462306a36Sopenharmony_cistatic int mt8186_regs[] = {
125562306a36Sopenharmony_ci	[PWRAP_MUX_SEL] =		0x0,
125662306a36Sopenharmony_ci	[PWRAP_WRAP_EN] =		0x4,
125762306a36Sopenharmony_ci	[PWRAP_DIO_EN] =		0x8,
125862306a36Sopenharmony_ci	[PWRAP_RDDMY] =			0x20,
125962306a36Sopenharmony_ci	[PWRAP_CSHEXT_WRITE] =		0x24,
126062306a36Sopenharmony_ci	[PWRAP_CSHEXT_READ] =		0x28,
126162306a36Sopenharmony_ci	[PWRAP_CSLEXT_WRITE] =		0x2C,
126262306a36Sopenharmony_ci	[PWRAP_CSLEXT_READ] =		0x30,
126362306a36Sopenharmony_ci	[PWRAP_EXT_CK_WRITE] =		0x34,
126462306a36Sopenharmony_ci	[PWRAP_STAUPD_CTRL] =		0x3C,
126562306a36Sopenharmony_ci	[PWRAP_STAUPD_GRPEN] =		0x40,
126662306a36Sopenharmony_ci	[PWRAP_EINT_STA0_ADR] =		0x44,
126762306a36Sopenharmony_ci	[PWRAP_EINT_STA1_ADR] =		0x48,
126862306a36Sopenharmony_ci	[PWRAP_INT_CLR] =		0xC8,
126962306a36Sopenharmony_ci	[PWRAP_INT_FLG] =		0xC4,
127062306a36Sopenharmony_ci	[PWRAP_MAN_EN] =		0x7C,
127162306a36Sopenharmony_ci	[PWRAP_MAN_CMD] =		0x80,
127262306a36Sopenharmony_ci	[PWRAP_WACS0_EN] =		0x8C,
127362306a36Sopenharmony_ci	[PWRAP_WACS1_EN] =		0x94,
127462306a36Sopenharmony_ci	[PWRAP_WACS2_EN] =		0x9C,
127562306a36Sopenharmony_ci	[PWRAP_INIT_DONE0] =		0x90,
127662306a36Sopenharmony_ci	[PWRAP_INIT_DONE1] =		0x98,
127762306a36Sopenharmony_ci	[PWRAP_INIT_DONE2] =		0xA0,
127862306a36Sopenharmony_ci	[PWRAP_INT_EN] =		0xBC,
127962306a36Sopenharmony_ci	[PWRAP_INT1_EN] =		0xCC,
128062306a36Sopenharmony_ci	[PWRAP_INT1_FLG] =		0xD4,
128162306a36Sopenharmony_ci	[PWRAP_INT1_CLR] =		0xD8,
128262306a36Sopenharmony_ci	[PWRAP_TIMER_EN] =		0xF0,
128362306a36Sopenharmony_ci	[PWRAP_WDT_UNIT] =		0xF8,
128462306a36Sopenharmony_ci	[PWRAP_WDT_SRC_EN] =		0xFC,
128562306a36Sopenharmony_ci	[PWRAP_WDT_SRC_EN_1] =		0x100,
128662306a36Sopenharmony_ci	[PWRAP_WDT_FLG] =		0x104,
128762306a36Sopenharmony_ci	[PWRAP_SPMINF_STA] =		0x1B4,
128862306a36Sopenharmony_ci	[PWRAP_DCM_EN] =		0x1EC,
128962306a36Sopenharmony_ci	[PWRAP_DCM_DBC_PRD] =		0x1F0,
129062306a36Sopenharmony_ci	[PWRAP_GPSINF_0_STA] =		0x204,
129162306a36Sopenharmony_ci	[PWRAP_GPSINF_1_STA] =		0x208,
129262306a36Sopenharmony_ci	[PWRAP_WACS0_CMD] =		0xC00,
129362306a36Sopenharmony_ci	[PWRAP_WACS0_RDATA] =		0xC04,
129462306a36Sopenharmony_ci	[PWRAP_WACS0_VLDCLR] =		0xC08,
129562306a36Sopenharmony_ci	[PWRAP_WACS1_CMD] =		0xC10,
129662306a36Sopenharmony_ci	[PWRAP_WACS1_RDATA] =		0xC14,
129762306a36Sopenharmony_ci	[PWRAP_WACS1_VLDCLR] =		0xC18,
129862306a36Sopenharmony_ci	[PWRAP_WACS2_CMD] =		0xC20,
129962306a36Sopenharmony_ci	[PWRAP_WACS2_RDATA] =		0xC24,
130062306a36Sopenharmony_ci	[PWRAP_WACS2_VLDCLR] =		0xC28,
130162306a36Sopenharmony_ci};
130262306a36Sopenharmony_ci
130362306a36Sopenharmony_cienum pmic_type {
130462306a36Sopenharmony_ci	PMIC_MT6323,
130562306a36Sopenharmony_ci	PMIC_MT6331,
130662306a36Sopenharmony_ci	PMIC_MT6332,
130762306a36Sopenharmony_ci	PMIC_MT6351,
130862306a36Sopenharmony_ci	PMIC_MT6357,
130962306a36Sopenharmony_ci	PMIC_MT6358,
131062306a36Sopenharmony_ci	PMIC_MT6359,
131162306a36Sopenharmony_ci	PMIC_MT6380,
131262306a36Sopenharmony_ci	PMIC_MT6397,
131362306a36Sopenharmony_ci};
131462306a36Sopenharmony_ci
131562306a36Sopenharmony_cienum pwrap_type {
131662306a36Sopenharmony_ci	PWRAP_MT2701,
131762306a36Sopenharmony_ci	PWRAP_MT6765,
131862306a36Sopenharmony_ci	PWRAP_MT6779,
131962306a36Sopenharmony_ci	PWRAP_MT6795,
132062306a36Sopenharmony_ci	PWRAP_MT6797,
132162306a36Sopenharmony_ci	PWRAP_MT6873,
132262306a36Sopenharmony_ci	PWRAP_MT7622,
132362306a36Sopenharmony_ci	PWRAP_MT8135,
132462306a36Sopenharmony_ci	PWRAP_MT8173,
132562306a36Sopenharmony_ci	PWRAP_MT8183,
132662306a36Sopenharmony_ci	PWRAP_MT8186,
132762306a36Sopenharmony_ci	PWRAP_MT8195,
132862306a36Sopenharmony_ci	PWRAP_MT8365,
132962306a36Sopenharmony_ci	PWRAP_MT8516,
133062306a36Sopenharmony_ci};
133162306a36Sopenharmony_ci
133262306a36Sopenharmony_cistruct pmic_wrapper;
133362306a36Sopenharmony_ci
133462306a36Sopenharmony_cistruct pwrap_slv_regops {
133562306a36Sopenharmony_ci	const struct regmap_config *regmap;
133662306a36Sopenharmony_ci	/*
133762306a36Sopenharmony_ci	 * pwrap operations are highly associated with the PMIC types,
133862306a36Sopenharmony_ci	 * so the pointers added increases flexibility allowing determination
133962306a36Sopenharmony_ci	 * which type is used by the detection through device tree.
134062306a36Sopenharmony_ci	 */
134162306a36Sopenharmony_ci	int (*pwrap_read)(struct pmic_wrapper *wrp, u32 adr, u32 *rdata);
134262306a36Sopenharmony_ci	int (*pwrap_write)(struct pmic_wrapper *wrp, u32 adr, u32 wdata);
134362306a36Sopenharmony_ci};
134462306a36Sopenharmony_ci
134562306a36Sopenharmony_ci/**
134662306a36Sopenharmony_ci * struct pwrap_slv_type - PMIC device wrapper definitions
134762306a36Sopenharmony_ci * @dew_regs:      Device Wrapper (DeW) register offsets
134862306a36Sopenharmony_ci * @type:          PMIC Type (model)
134962306a36Sopenharmony_ci * @comp_dew_regs: Device Wrapper (DeW) register offsets for companion device
135062306a36Sopenharmony_ci * @comp_type:     Companion PMIC Type (model)
135162306a36Sopenharmony_ci * @regops:        Register R/W ops
135262306a36Sopenharmony_ci * @caps:          Capability flags for the target device
135362306a36Sopenharmony_ci */
135462306a36Sopenharmony_cistruct pwrap_slv_type {
135562306a36Sopenharmony_ci	const u32 *dew_regs;
135662306a36Sopenharmony_ci	enum pmic_type type;
135762306a36Sopenharmony_ci	const u32 *comp_dew_regs;
135862306a36Sopenharmony_ci	enum pmic_type comp_type;
135962306a36Sopenharmony_ci	const struct pwrap_slv_regops *regops;
136062306a36Sopenharmony_ci	u32 caps;
136162306a36Sopenharmony_ci};
136262306a36Sopenharmony_ci
136362306a36Sopenharmony_cistruct pmic_wrapper {
136462306a36Sopenharmony_ci	struct device *dev;
136562306a36Sopenharmony_ci	void __iomem *base;
136662306a36Sopenharmony_ci	struct regmap *regmap;
136762306a36Sopenharmony_ci	const struct pmic_wrapper_type *master;
136862306a36Sopenharmony_ci	const struct pwrap_slv_type *slave;
136962306a36Sopenharmony_ci	struct clk *clk_spi;
137062306a36Sopenharmony_ci	struct clk *clk_wrap;
137162306a36Sopenharmony_ci	struct clk *clk_sys;
137262306a36Sopenharmony_ci	struct clk *clk_tmr;
137362306a36Sopenharmony_ci	struct reset_control *rstc;
137462306a36Sopenharmony_ci
137562306a36Sopenharmony_ci	struct reset_control *rstc_bridge;
137662306a36Sopenharmony_ci	void __iomem *bridge_base;
137762306a36Sopenharmony_ci};
137862306a36Sopenharmony_ci
137962306a36Sopenharmony_cistruct pmic_wrapper_type {
138062306a36Sopenharmony_ci	int *regs;
138162306a36Sopenharmony_ci	enum pwrap_type type;
138262306a36Sopenharmony_ci	u32 arb_en_all;
138362306a36Sopenharmony_ci	u32 int_en_all;
138462306a36Sopenharmony_ci	u32 int1_en_all;
138562306a36Sopenharmony_ci	u32 spi_w;
138662306a36Sopenharmony_ci	u32 wdt_src;
138762306a36Sopenharmony_ci	/* Flags indicating the capability for the target pwrap */
138862306a36Sopenharmony_ci	u32 caps;
138962306a36Sopenharmony_ci	int (*init_reg_clock)(struct pmic_wrapper *wrp);
139062306a36Sopenharmony_ci	int (*init_soc_specific)(struct pmic_wrapper *wrp);
139162306a36Sopenharmony_ci};
139262306a36Sopenharmony_ci
139362306a36Sopenharmony_cistatic u32 pwrap_readl(struct pmic_wrapper *wrp, enum pwrap_regs reg)
139462306a36Sopenharmony_ci{
139562306a36Sopenharmony_ci	return readl(wrp->base + wrp->master->regs[reg]);
139662306a36Sopenharmony_ci}
139762306a36Sopenharmony_ci
139862306a36Sopenharmony_cistatic void pwrap_writel(struct pmic_wrapper *wrp, u32 val, enum pwrap_regs reg)
139962306a36Sopenharmony_ci{
140062306a36Sopenharmony_ci	writel(val, wrp->base + wrp->master->regs[reg]);
140162306a36Sopenharmony_ci}
140262306a36Sopenharmony_ci
140362306a36Sopenharmony_cistatic u32 pwrap_get_fsm_state(struct pmic_wrapper *wrp)
140462306a36Sopenharmony_ci{
140562306a36Sopenharmony_ci	u32 val;
140662306a36Sopenharmony_ci
140762306a36Sopenharmony_ci	val = pwrap_readl(wrp, PWRAP_WACS2_RDATA);
140862306a36Sopenharmony_ci	if (HAS_CAP(wrp->master->caps, PWRAP_CAP_ARB))
140962306a36Sopenharmony_ci		return PWRAP_GET_WACS_ARB_FSM(val);
141062306a36Sopenharmony_ci	else
141162306a36Sopenharmony_ci		return PWRAP_GET_WACS_FSM(val);
141262306a36Sopenharmony_ci}
141362306a36Sopenharmony_ci
141462306a36Sopenharmony_cistatic bool pwrap_is_fsm_idle(struct pmic_wrapper *wrp)
141562306a36Sopenharmony_ci{
141662306a36Sopenharmony_ci	return pwrap_get_fsm_state(wrp) == PWRAP_WACS_FSM_IDLE;
141762306a36Sopenharmony_ci}
141862306a36Sopenharmony_ci
141962306a36Sopenharmony_cistatic bool pwrap_is_fsm_vldclr(struct pmic_wrapper *wrp)
142062306a36Sopenharmony_ci{
142162306a36Sopenharmony_ci	return pwrap_get_fsm_state(wrp) == PWRAP_WACS_FSM_WFVLDCLR;
142262306a36Sopenharmony_ci}
142362306a36Sopenharmony_ci
142462306a36Sopenharmony_ci/*
142562306a36Sopenharmony_ci * Timeout issue sometimes caused by the last read command
142662306a36Sopenharmony_ci * failed because pmic wrap could not got the FSM_VLDCLR
142762306a36Sopenharmony_ci * in time after finishing WACS2_CMD. It made state machine
142862306a36Sopenharmony_ci * still on FSM_VLDCLR and timeout next time.
142962306a36Sopenharmony_ci * Check the status of FSM and clear the vldclr to recovery the
143062306a36Sopenharmony_ci * error.
143162306a36Sopenharmony_ci */
143262306a36Sopenharmony_cistatic inline void pwrap_leave_fsm_vldclr(struct pmic_wrapper *wrp)
143362306a36Sopenharmony_ci{
143462306a36Sopenharmony_ci	if (pwrap_is_fsm_vldclr(wrp))
143562306a36Sopenharmony_ci		pwrap_writel(wrp, 1, PWRAP_WACS2_VLDCLR);
143662306a36Sopenharmony_ci}
143762306a36Sopenharmony_ci
143862306a36Sopenharmony_cistatic bool pwrap_is_sync_idle(struct pmic_wrapper *wrp)
143962306a36Sopenharmony_ci{
144062306a36Sopenharmony_ci	return pwrap_readl(wrp, PWRAP_WACS2_RDATA) & PWRAP_STATE_SYNC_IDLE0;
144162306a36Sopenharmony_ci}
144262306a36Sopenharmony_ci
144362306a36Sopenharmony_cistatic bool pwrap_is_fsm_idle_and_sync_idle(struct pmic_wrapper *wrp)
144462306a36Sopenharmony_ci{
144562306a36Sopenharmony_ci	u32 val = pwrap_readl(wrp, PWRAP_WACS2_RDATA);
144662306a36Sopenharmony_ci
144762306a36Sopenharmony_ci	return (PWRAP_GET_WACS_FSM(val) == PWRAP_WACS_FSM_IDLE) &&
144862306a36Sopenharmony_ci		(val & PWRAP_STATE_SYNC_IDLE0);
144962306a36Sopenharmony_ci}
145062306a36Sopenharmony_ci
145162306a36Sopenharmony_cistatic int pwrap_read16(struct pmic_wrapper *wrp, u32 adr, u32 *rdata)
145262306a36Sopenharmony_ci{
145362306a36Sopenharmony_ci	bool tmp;
145462306a36Sopenharmony_ci	int ret;
145562306a36Sopenharmony_ci	u32 val;
145662306a36Sopenharmony_ci
145762306a36Sopenharmony_ci	ret = readx_poll_timeout(pwrap_is_fsm_idle, wrp, tmp, tmp,
145862306a36Sopenharmony_ci				 PWRAP_POLL_DELAY_US, PWRAP_POLL_TIMEOUT_US);
145962306a36Sopenharmony_ci	if (ret) {
146062306a36Sopenharmony_ci		pwrap_leave_fsm_vldclr(wrp);
146162306a36Sopenharmony_ci		return ret;
146262306a36Sopenharmony_ci	}
146362306a36Sopenharmony_ci
146462306a36Sopenharmony_ci	if (HAS_CAP(wrp->master->caps, PWRAP_CAP_ARB))
146562306a36Sopenharmony_ci		val = adr;
146662306a36Sopenharmony_ci	else
146762306a36Sopenharmony_ci		val = (adr >> 1) << 16;
146862306a36Sopenharmony_ci	pwrap_writel(wrp, val, PWRAP_WACS2_CMD);
146962306a36Sopenharmony_ci
147062306a36Sopenharmony_ci	ret = readx_poll_timeout(pwrap_is_fsm_vldclr, wrp, tmp, tmp,
147162306a36Sopenharmony_ci				 PWRAP_POLL_DELAY_US, PWRAP_POLL_TIMEOUT_US);
147262306a36Sopenharmony_ci	if (ret)
147362306a36Sopenharmony_ci		return ret;
147462306a36Sopenharmony_ci
147562306a36Sopenharmony_ci	if (HAS_CAP(wrp->master->caps, PWRAP_CAP_ARB))
147662306a36Sopenharmony_ci		val = pwrap_readl(wrp, PWRAP_SWINF_2_RDATA_31_0);
147762306a36Sopenharmony_ci	else
147862306a36Sopenharmony_ci		val = pwrap_readl(wrp, PWRAP_WACS2_RDATA);
147962306a36Sopenharmony_ci	*rdata = PWRAP_GET_WACS_RDATA(val);
148062306a36Sopenharmony_ci
148162306a36Sopenharmony_ci	pwrap_writel(wrp, 1, PWRAP_WACS2_VLDCLR);
148262306a36Sopenharmony_ci
148362306a36Sopenharmony_ci	return 0;
148462306a36Sopenharmony_ci}
148562306a36Sopenharmony_ci
148662306a36Sopenharmony_cistatic int pwrap_read32(struct pmic_wrapper *wrp, u32 adr, u32 *rdata)
148762306a36Sopenharmony_ci{
148862306a36Sopenharmony_ci	bool tmp;
148962306a36Sopenharmony_ci	int ret, msb;
149062306a36Sopenharmony_ci
149162306a36Sopenharmony_ci	*rdata = 0;
149262306a36Sopenharmony_ci	for (msb = 0; msb < 2; msb++) {
149362306a36Sopenharmony_ci		ret = readx_poll_timeout(pwrap_is_fsm_idle, wrp, tmp, tmp,
149462306a36Sopenharmony_ci					 PWRAP_POLL_DELAY_US, PWRAP_POLL_TIMEOUT_US);
149562306a36Sopenharmony_ci
149662306a36Sopenharmony_ci		if (ret) {
149762306a36Sopenharmony_ci			pwrap_leave_fsm_vldclr(wrp);
149862306a36Sopenharmony_ci			return ret;
149962306a36Sopenharmony_ci		}
150062306a36Sopenharmony_ci
150162306a36Sopenharmony_ci		pwrap_writel(wrp, ((msb << 30) | (adr << 16)),
150262306a36Sopenharmony_ci			     PWRAP_WACS2_CMD);
150362306a36Sopenharmony_ci
150462306a36Sopenharmony_ci		ret = readx_poll_timeout(pwrap_is_fsm_vldclr, wrp, tmp, tmp,
150562306a36Sopenharmony_ci					 PWRAP_POLL_DELAY_US, PWRAP_POLL_TIMEOUT_US);
150662306a36Sopenharmony_ci		if (ret)
150762306a36Sopenharmony_ci			return ret;
150862306a36Sopenharmony_ci
150962306a36Sopenharmony_ci		*rdata += (PWRAP_GET_WACS_RDATA(pwrap_readl(wrp,
151062306a36Sopenharmony_ci			   PWRAP_WACS2_RDATA)) << (16 * msb));
151162306a36Sopenharmony_ci
151262306a36Sopenharmony_ci		pwrap_writel(wrp, 1, PWRAP_WACS2_VLDCLR);
151362306a36Sopenharmony_ci	}
151462306a36Sopenharmony_ci
151562306a36Sopenharmony_ci	return 0;
151662306a36Sopenharmony_ci}
151762306a36Sopenharmony_ci
151862306a36Sopenharmony_cistatic int pwrap_read(struct pmic_wrapper *wrp, u32 adr, u32 *rdata)
151962306a36Sopenharmony_ci{
152062306a36Sopenharmony_ci	return wrp->slave->regops->pwrap_read(wrp, adr, rdata);
152162306a36Sopenharmony_ci}
152262306a36Sopenharmony_ci
152362306a36Sopenharmony_cistatic int pwrap_write16(struct pmic_wrapper *wrp, u32 adr, u32 wdata)
152462306a36Sopenharmony_ci{
152562306a36Sopenharmony_ci	bool tmp;
152662306a36Sopenharmony_ci	int ret;
152762306a36Sopenharmony_ci
152862306a36Sopenharmony_ci	ret = readx_poll_timeout(pwrap_is_fsm_idle, wrp, tmp, tmp,
152962306a36Sopenharmony_ci				 PWRAP_POLL_DELAY_US, PWRAP_POLL_TIMEOUT_US);
153062306a36Sopenharmony_ci	if (ret) {
153162306a36Sopenharmony_ci		pwrap_leave_fsm_vldclr(wrp);
153262306a36Sopenharmony_ci		return ret;
153362306a36Sopenharmony_ci	}
153462306a36Sopenharmony_ci
153562306a36Sopenharmony_ci	if (HAS_CAP(wrp->master->caps, PWRAP_CAP_ARB)) {
153662306a36Sopenharmony_ci		pwrap_writel(wrp, wdata, PWRAP_SWINF_2_WDATA_31_0);
153762306a36Sopenharmony_ci		pwrap_writel(wrp, BIT(29) | adr, PWRAP_WACS2_CMD);
153862306a36Sopenharmony_ci	} else {
153962306a36Sopenharmony_ci		pwrap_writel(wrp, BIT(31) | ((adr >> 1) << 16) | wdata,
154062306a36Sopenharmony_ci			     PWRAP_WACS2_CMD);
154162306a36Sopenharmony_ci	}
154262306a36Sopenharmony_ci
154362306a36Sopenharmony_ci	return 0;
154462306a36Sopenharmony_ci}
154562306a36Sopenharmony_ci
154662306a36Sopenharmony_cistatic int pwrap_write32(struct pmic_wrapper *wrp, u32 adr, u32 wdata)
154762306a36Sopenharmony_ci{
154862306a36Sopenharmony_ci	bool tmp;
154962306a36Sopenharmony_ci	int ret, msb, rdata;
155062306a36Sopenharmony_ci
155162306a36Sopenharmony_ci	for (msb = 0; msb < 2; msb++) {
155262306a36Sopenharmony_ci		ret = readx_poll_timeout(pwrap_is_fsm_idle, wrp, tmp, tmp,
155362306a36Sopenharmony_ci					 PWRAP_POLL_DELAY_US, PWRAP_POLL_TIMEOUT_US);
155462306a36Sopenharmony_ci		if (ret) {
155562306a36Sopenharmony_ci			pwrap_leave_fsm_vldclr(wrp);
155662306a36Sopenharmony_ci			return ret;
155762306a36Sopenharmony_ci		}
155862306a36Sopenharmony_ci
155962306a36Sopenharmony_ci		pwrap_writel(wrp, (1 << 31) | (msb << 30) | (adr << 16) |
156062306a36Sopenharmony_ci			     ((wdata >> (msb * 16)) & 0xffff),
156162306a36Sopenharmony_ci			     PWRAP_WACS2_CMD);
156262306a36Sopenharmony_ci
156362306a36Sopenharmony_ci		/*
156462306a36Sopenharmony_ci		 * The pwrap_read operation is the requirement of hardware used
156562306a36Sopenharmony_ci		 * for the synchronization between two successive 16-bit
156662306a36Sopenharmony_ci		 * pwrap_writel operations composing one 32-bit bus writing.
156762306a36Sopenharmony_ci		 * Otherwise, we'll find the result fails on the lower 16-bit
156862306a36Sopenharmony_ci		 * pwrap writing.
156962306a36Sopenharmony_ci		 */
157062306a36Sopenharmony_ci		if (!msb)
157162306a36Sopenharmony_ci			pwrap_read(wrp, adr, &rdata);
157262306a36Sopenharmony_ci	}
157362306a36Sopenharmony_ci
157462306a36Sopenharmony_ci	return 0;
157562306a36Sopenharmony_ci}
157662306a36Sopenharmony_ci
157762306a36Sopenharmony_cistatic int pwrap_write(struct pmic_wrapper *wrp, u32 adr, u32 wdata)
157862306a36Sopenharmony_ci{
157962306a36Sopenharmony_ci	return wrp->slave->regops->pwrap_write(wrp, adr, wdata);
158062306a36Sopenharmony_ci}
158162306a36Sopenharmony_ci
158262306a36Sopenharmony_cistatic int pwrap_regmap_read(void *context, u32 adr, u32 *rdata)
158362306a36Sopenharmony_ci{
158462306a36Sopenharmony_ci	return pwrap_read(context, adr, rdata);
158562306a36Sopenharmony_ci}
158662306a36Sopenharmony_ci
158762306a36Sopenharmony_cistatic int pwrap_regmap_write(void *context, u32 adr, u32 wdata)
158862306a36Sopenharmony_ci{
158962306a36Sopenharmony_ci	return pwrap_write(context, adr, wdata);
159062306a36Sopenharmony_ci}
159162306a36Sopenharmony_ci
159262306a36Sopenharmony_cistatic bool pwrap_pmic_read_test(struct pmic_wrapper *wrp, const u32 *dew_regs,
159362306a36Sopenharmony_ci				 u16 read_test_val)
159462306a36Sopenharmony_ci{
159562306a36Sopenharmony_ci	bool is_success;
159662306a36Sopenharmony_ci	u32 rdata;
159762306a36Sopenharmony_ci
159862306a36Sopenharmony_ci	pwrap_read(wrp, dew_regs[PWRAP_DEW_READ_TEST], &rdata);
159962306a36Sopenharmony_ci	is_success = ((rdata & U16_MAX) == read_test_val);
160062306a36Sopenharmony_ci
160162306a36Sopenharmony_ci	return is_success;
160262306a36Sopenharmony_ci}
160362306a36Sopenharmony_ci
160462306a36Sopenharmony_cistatic int pwrap_reset_spislave(struct pmic_wrapper *wrp)
160562306a36Sopenharmony_ci{
160662306a36Sopenharmony_ci	bool tmp;
160762306a36Sopenharmony_ci	int ret, i;
160862306a36Sopenharmony_ci
160962306a36Sopenharmony_ci	pwrap_writel(wrp, 0, PWRAP_HIPRIO_ARB_EN);
161062306a36Sopenharmony_ci	pwrap_writel(wrp, 0, PWRAP_WRAP_EN);
161162306a36Sopenharmony_ci	pwrap_writel(wrp, 1, PWRAP_MUX_SEL);
161262306a36Sopenharmony_ci	pwrap_writel(wrp, 1, PWRAP_MAN_EN);
161362306a36Sopenharmony_ci	pwrap_writel(wrp, 0, PWRAP_DIO_EN);
161462306a36Sopenharmony_ci
161562306a36Sopenharmony_ci	pwrap_writel(wrp, wrp->master->spi_w | PWRAP_MAN_CMD_OP_CSL,
161662306a36Sopenharmony_ci			PWRAP_MAN_CMD);
161762306a36Sopenharmony_ci	pwrap_writel(wrp, wrp->master->spi_w | PWRAP_MAN_CMD_OP_OUTS,
161862306a36Sopenharmony_ci			PWRAP_MAN_CMD);
161962306a36Sopenharmony_ci	pwrap_writel(wrp, wrp->master->spi_w | PWRAP_MAN_CMD_OP_CSH,
162062306a36Sopenharmony_ci			PWRAP_MAN_CMD);
162162306a36Sopenharmony_ci
162262306a36Sopenharmony_ci	for (i = 0; i < 4; i++)
162362306a36Sopenharmony_ci		pwrap_writel(wrp, wrp->master->spi_w | PWRAP_MAN_CMD_OP_OUTS,
162462306a36Sopenharmony_ci				PWRAP_MAN_CMD);
162562306a36Sopenharmony_ci
162662306a36Sopenharmony_ci	ret = readx_poll_timeout(pwrap_is_sync_idle, wrp, tmp, tmp,
162762306a36Sopenharmony_ci				 PWRAP_POLL_DELAY_US, PWRAP_POLL_TIMEOUT_US);
162862306a36Sopenharmony_ci	if (ret) {
162962306a36Sopenharmony_ci		dev_err(wrp->dev, "%s fail, ret=%d\n", __func__, ret);
163062306a36Sopenharmony_ci		return ret;
163162306a36Sopenharmony_ci	}
163262306a36Sopenharmony_ci
163362306a36Sopenharmony_ci	pwrap_writel(wrp, 0, PWRAP_MAN_EN);
163462306a36Sopenharmony_ci	pwrap_writel(wrp, 0, PWRAP_MUX_SEL);
163562306a36Sopenharmony_ci
163662306a36Sopenharmony_ci	return 0;
163762306a36Sopenharmony_ci}
163862306a36Sopenharmony_ci
163962306a36Sopenharmony_ci/*
164062306a36Sopenharmony_ci * pwrap_init_sidly - configure serial input delay
164162306a36Sopenharmony_ci *
164262306a36Sopenharmony_ci * This configures the serial input delay. We can configure 0, 2, 4 or 6ns
164362306a36Sopenharmony_ci * delay. Do a read test with all possible values and chose the best delay.
164462306a36Sopenharmony_ci */
164562306a36Sopenharmony_cistatic int pwrap_init_sidly(struct pmic_wrapper *wrp)
164662306a36Sopenharmony_ci{
164762306a36Sopenharmony_ci	u32 i;
164862306a36Sopenharmony_ci	u32 pass = 0;
164962306a36Sopenharmony_ci	bool read_ok;
165062306a36Sopenharmony_ci	signed char dly[16] = {
165162306a36Sopenharmony_ci		-1, 0, 1, 0, 2, -1, 1, 1, 3, -1, -1, -1, 3, -1, 2, 1
165262306a36Sopenharmony_ci	};
165362306a36Sopenharmony_ci
165462306a36Sopenharmony_ci	for (i = 0; i < 4; i++) {
165562306a36Sopenharmony_ci		pwrap_writel(wrp, i, PWRAP_SIDLY);
165662306a36Sopenharmony_ci		read_ok = pwrap_pmic_read_test(wrp, wrp->slave->dew_regs,
165762306a36Sopenharmony_ci					       PWRAP_DEW_READ_TEST_VAL);
165862306a36Sopenharmony_ci		if (read_ok) {
165962306a36Sopenharmony_ci			dev_dbg(wrp->dev, "[Read Test] pass, SIDLY=%x\n", i);
166062306a36Sopenharmony_ci			pass |= 1 << i;
166162306a36Sopenharmony_ci		}
166262306a36Sopenharmony_ci	}
166362306a36Sopenharmony_ci
166462306a36Sopenharmony_ci	if (dly[pass] < 0) {
166562306a36Sopenharmony_ci		dev_err(wrp->dev, "sidly pass range 0x%x not continuous\n",
166662306a36Sopenharmony_ci				pass);
166762306a36Sopenharmony_ci		return -EIO;
166862306a36Sopenharmony_ci	}
166962306a36Sopenharmony_ci
167062306a36Sopenharmony_ci	pwrap_writel(wrp, dly[pass], PWRAP_SIDLY);
167162306a36Sopenharmony_ci
167262306a36Sopenharmony_ci	return 0;
167362306a36Sopenharmony_ci}
167462306a36Sopenharmony_ci
167562306a36Sopenharmony_cistatic int pwrap_init_dual_io(struct pmic_wrapper *wrp)
167662306a36Sopenharmony_ci{
167762306a36Sopenharmony_ci	int ret;
167862306a36Sopenharmony_ci	bool read_ok, tmp;
167962306a36Sopenharmony_ci	bool comp_read_ok = true;
168062306a36Sopenharmony_ci
168162306a36Sopenharmony_ci	/* Enable dual IO mode */
168262306a36Sopenharmony_ci	pwrap_write(wrp, wrp->slave->dew_regs[PWRAP_DEW_DIO_EN], 1);
168362306a36Sopenharmony_ci	if (wrp->slave->comp_dew_regs)
168462306a36Sopenharmony_ci		pwrap_write(wrp, wrp->slave->comp_dew_regs[PWRAP_DEW_DIO_EN], 1);
168562306a36Sopenharmony_ci
168662306a36Sopenharmony_ci	/* Check IDLE & INIT_DONE in advance */
168762306a36Sopenharmony_ci	ret = readx_poll_timeout(pwrap_is_fsm_idle_and_sync_idle, wrp, tmp, tmp,
168862306a36Sopenharmony_ci				 PWRAP_POLL_DELAY_US, PWRAP_POLL_TIMEOUT_US);
168962306a36Sopenharmony_ci	if (ret) {
169062306a36Sopenharmony_ci		dev_err(wrp->dev, "%s fail, ret=%d\n", __func__, ret);
169162306a36Sopenharmony_ci		return ret;
169262306a36Sopenharmony_ci	}
169362306a36Sopenharmony_ci
169462306a36Sopenharmony_ci	pwrap_writel(wrp, 1, PWRAP_DIO_EN);
169562306a36Sopenharmony_ci
169662306a36Sopenharmony_ci	/* Read Test */
169762306a36Sopenharmony_ci	read_ok = pwrap_pmic_read_test(wrp, wrp->slave->dew_regs, PWRAP_DEW_READ_TEST_VAL);
169862306a36Sopenharmony_ci	if (wrp->slave->comp_dew_regs)
169962306a36Sopenharmony_ci		comp_read_ok = pwrap_pmic_read_test(wrp, wrp->slave->comp_dew_regs,
170062306a36Sopenharmony_ci						    PWRAP_DEW_COMP_READ_TEST_VAL);
170162306a36Sopenharmony_ci	if (!read_ok || !comp_read_ok) {
170262306a36Sopenharmony_ci		dev_err(wrp->dev, "Read failed on DIO mode. Main PMIC %s%s\n",
170362306a36Sopenharmony_ci			!read_ok ? "fail" : "success",
170462306a36Sopenharmony_ci			wrp->slave->comp_dew_regs && !comp_read_ok ?
170562306a36Sopenharmony_ci			", Companion PMIC fail" : "");
170662306a36Sopenharmony_ci		return -EFAULT;
170762306a36Sopenharmony_ci	}
170862306a36Sopenharmony_ci
170962306a36Sopenharmony_ci	return 0;
171062306a36Sopenharmony_ci}
171162306a36Sopenharmony_ci
171262306a36Sopenharmony_ci/*
171362306a36Sopenharmony_ci * pwrap_init_chip_select_ext is used to configure CS extension time for each
171462306a36Sopenharmony_ci * phase during data transactions on the pwrap bus.
171562306a36Sopenharmony_ci */
171662306a36Sopenharmony_cistatic void pwrap_init_chip_select_ext(struct pmic_wrapper *wrp, u8 hext_write,
171762306a36Sopenharmony_ci				       u8 hext_read, u8 lext_start,
171862306a36Sopenharmony_ci				       u8 lext_end)
171962306a36Sopenharmony_ci{
172062306a36Sopenharmony_ci	/*
172162306a36Sopenharmony_ci	 * After finishing a write and read transaction, extends CS high time
172262306a36Sopenharmony_ci	 * to be at least xT of BUS CLK as hext_write and hext_read specifies
172362306a36Sopenharmony_ci	 * respectively.
172462306a36Sopenharmony_ci	 */
172562306a36Sopenharmony_ci	pwrap_writel(wrp, hext_write, PWRAP_CSHEXT_WRITE);
172662306a36Sopenharmony_ci	pwrap_writel(wrp, hext_read, PWRAP_CSHEXT_READ);
172762306a36Sopenharmony_ci
172862306a36Sopenharmony_ci	/*
172962306a36Sopenharmony_ci	 * Extends CS low time after CSL and before CSH command to be at
173062306a36Sopenharmony_ci	 * least xT of BUS CLK as lext_start and lext_end specifies
173162306a36Sopenharmony_ci	 * respectively.
173262306a36Sopenharmony_ci	 */
173362306a36Sopenharmony_ci	pwrap_writel(wrp, lext_start, PWRAP_CSLEXT_START);
173462306a36Sopenharmony_ci	pwrap_writel(wrp, lext_end, PWRAP_CSLEXT_END);
173562306a36Sopenharmony_ci}
173662306a36Sopenharmony_ci
173762306a36Sopenharmony_cistatic int pwrap_common_init_reg_clock(struct pmic_wrapper *wrp)
173862306a36Sopenharmony_ci{
173962306a36Sopenharmony_ci	switch (wrp->master->type) {
174062306a36Sopenharmony_ci	case PWRAP_MT6795:
174162306a36Sopenharmony_ci		if (wrp->slave->type == PMIC_MT6331) {
174262306a36Sopenharmony_ci			const u32 *dew_regs = wrp->slave->dew_regs;
174362306a36Sopenharmony_ci
174462306a36Sopenharmony_ci			pwrap_write(wrp, dew_regs[PWRAP_DEW_RDDMY_NO], 0x8);
174562306a36Sopenharmony_ci
174662306a36Sopenharmony_ci			if (wrp->slave->comp_type == PMIC_MT6332) {
174762306a36Sopenharmony_ci				dew_regs = wrp->slave->comp_dew_regs;
174862306a36Sopenharmony_ci				pwrap_write(wrp, dew_regs[PWRAP_DEW_RDDMY_NO], 0x8);
174962306a36Sopenharmony_ci			}
175062306a36Sopenharmony_ci		}
175162306a36Sopenharmony_ci		pwrap_writel(wrp, 0x88, PWRAP_RDDMY);
175262306a36Sopenharmony_ci		pwrap_init_chip_select_ext(wrp, 15, 15, 15, 15);
175362306a36Sopenharmony_ci		break;
175462306a36Sopenharmony_ci	case PWRAP_MT8173:
175562306a36Sopenharmony_ci		pwrap_init_chip_select_ext(wrp, 0, 4, 2, 2);
175662306a36Sopenharmony_ci		break;
175762306a36Sopenharmony_ci	case PWRAP_MT8135:
175862306a36Sopenharmony_ci		pwrap_writel(wrp, 0x4, PWRAP_CSHEXT);
175962306a36Sopenharmony_ci		pwrap_init_chip_select_ext(wrp, 0, 4, 0, 0);
176062306a36Sopenharmony_ci		break;
176162306a36Sopenharmony_ci	default:
176262306a36Sopenharmony_ci		break;
176362306a36Sopenharmony_ci	}
176462306a36Sopenharmony_ci
176562306a36Sopenharmony_ci	return 0;
176662306a36Sopenharmony_ci}
176762306a36Sopenharmony_ci
176862306a36Sopenharmony_cistatic int pwrap_mt2701_init_reg_clock(struct pmic_wrapper *wrp)
176962306a36Sopenharmony_ci{
177062306a36Sopenharmony_ci	switch (wrp->slave->type) {
177162306a36Sopenharmony_ci	case PMIC_MT6397:
177262306a36Sopenharmony_ci		pwrap_writel(wrp, 0xc, PWRAP_RDDMY);
177362306a36Sopenharmony_ci		pwrap_init_chip_select_ext(wrp, 4, 0, 2, 2);
177462306a36Sopenharmony_ci		break;
177562306a36Sopenharmony_ci
177662306a36Sopenharmony_ci	case PMIC_MT6323:
177762306a36Sopenharmony_ci		pwrap_writel(wrp, 0x8, PWRAP_RDDMY);
177862306a36Sopenharmony_ci		pwrap_write(wrp, wrp->slave->dew_regs[PWRAP_DEW_RDDMY_NO],
177962306a36Sopenharmony_ci			    0x8);
178062306a36Sopenharmony_ci		pwrap_init_chip_select_ext(wrp, 5, 0, 2, 2);
178162306a36Sopenharmony_ci		break;
178262306a36Sopenharmony_ci	default:
178362306a36Sopenharmony_ci		break;
178462306a36Sopenharmony_ci	}
178562306a36Sopenharmony_ci
178662306a36Sopenharmony_ci	return 0;
178762306a36Sopenharmony_ci}
178862306a36Sopenharmony_ci
178962306a36Sopenharmony_cistatic bool pwrap_is_cipher_ready(struct pmic_wrapper *wrp)
179062306a36Sopenharmony_ci{
179162306a36Sopenharmony_ci	return pwrap_readl(wrp, PWRAP_CIPHER_RDY) & 1;
179262306a36Sopenharmony_ci}
179362306a36Sopenharmony_ci
179462306a36Sopenharmony_cistatic bool __pwrap_is_pmic_cipher_ready(struct pmic_wrapper *wrp, const u32 *dew_regs)
179562306a36Sopenharmony_ci{
179662306a36Sopenharmony_ci	u32 rdata;
179762306a36Sopenharmony_ci	int ret;
179862306a36Sopenharmony_ci
179962306a36Sopenharmony_ci	ret = pwrap_read(wrp, dew_regs[PWRAP_DEW_CIPHER_RDY], &rdata);
180062306a36Sopenharmony_ci	if (ret)
180162306a36Sopenharmony_ci		return false;
180262306a36Sopenharmony_ci
180362306a36Sopenharmony_ci	return rdata == 1;
180462306a36Sopenharmony_ci}
180562306a36Sopenharmony_ci
180662306a36Sopenharmony_ci
180762306a36Sopenharmony_cistatic bool pwrap_is_pmic_cipher_ready(struct pmic_wrapper *wrp)
180862306a36Sopenharmony_ci{
180962306a36Sopenharmony_ci	bool ret = __pwrap_is_pmic_cipher_ready(wrp, wrp->slave->dew_regs);
181062306a36Sopenharmony_ci
181162306a36Sopenharmony_ci	if (!ret)
181262306a36Sopenharmony_ci		return ret;
181362306a36Sopenharmony_ci
181462306a36Sopenharmony_ci	/* If there's any companion, wait for it to be ready too */
181562306a36Sopenharmony_ci	if (wrp->slave->comp_dew_regs)
181662306a36Sopenharmony_ci		ret = __pwrap_is_pmic_cipher_ready(wrp, wrp->slave->comp_dew_regs);
181762306a36Sopenharmony_ci
181862306a36Sopenharmony_ci	return ret;
181962306a36Sopenharmony_ci}
182062306a36Sopenharmony_ci
182162306a36Sopenharmony_cistatic void pwrap_config_cipher(struct pmic_wrapper *wrp, const u32 *dew_regs)
182262306a36Sopenharmony_ci{
182362306a36Sopenharmony_ci	pwrap_write(wrp, dew_regs[PWRAP_DEW_CIPHER_SWRST], 0x1);
182462306a36Sopenharmony_ci	pwrap_write(wrp, dew_regs[PWRAP_DEW_CIPHER_SWRST], 0x0);
182562306a36Sopenharmony_ci	pwrap_write(wrp, dew_regs[PWRAP_DEW_CIPHER_KEY_SEL], 0x1);
182662306a36Sopenharmony_ci	pwrap_write(wrp, dew_regs[PWRAP_DEW_CIPHER_IV_SEL], 0x2);
182762306a36Sopenharmony_ci}
182862306a36Sopenharmony_ci
182962306a36Sopenharmony_cistatic int pwrap_init_cipher(struct pmic_wrapper *wrp)
183062306a36Sopenharmony_ci{
183162306a36Sopenharmony_ci	int ret;
183262306a36Sopenharmony_ci	bool tmp;
183362306a36Sopenharmony_ci	u32 rdata = 0;
183462306a36Sopenharmony_ci
183562306a36Sopenharmony_ci	pwrap_writel(wrp, 0x1, PWRAP_CIPHER_SWRST);
183662306a36Sopenharmony_ci	pwrap_writel(wrp, 0x0, PWRAP_CIPHER_SWRST);
183762306a36Sopenharmony_ci	pwrap_writel(wrp, 0x1, PWRAP_CIPHER_KEY_SEL);
183862306a36Sopenharmony_ci	pwrap_writel(wrp, 0x2, PWRAP_CIPHER_IV_SEL);
183962306a36Sopenharmony_ci
184062306a36Sopenharmony_ci	switch (wrp->master->type) {
184162306a36Sopenharmony_ci	case PWRAP_MT8135:
184262306a36Sopenharmony_ci		pwrap_writel(wrp, 1, PWRAP_CIPHER_LOAD);
184362306a36Sopenharmony_ci		pwrap_writel(wrp, 1, PWRAP_CIPHER_START);
184462306a36Sopenharmony_ci		break;
184562306a36Sopenharmony_ci	case PWRAP_MT2701:
184662306a36Sopenharmony_ci	case PWRAP_MT6765:
184762306a36Sopenharmony_ci	case PWRAP_MT6779:
184862306a36Sopenharmony_ci	case PWRAP_MT6795:
184962306a36Sopenharmony_ci	case PWRAP_MT6797:
185062306a36Sopenharmony_ci	case PWRAP_MT8173:
185162306a36Sopenharmony_ci	case PWRAP_MT8186:
185262306a36Sopenharmony_ci	case PWRAP_MT8365:
185362306a36Sopenharmony_ci	case PWRAP_MT8516:
185462306a36Sopenharmony_ci		pwrap_writel(wrp, 1, PWRAP_CIPHER_EN);
185562306a36Sopenharmony_ci		break;
185662306a36Sopenharmony_ci	case PWRAP_MT7622:
185762306a36Sopenharmony_ci		pwrap_writel(wrp, 0, PWRAP_CIPHER_EN);
185862306a36Sopenharmony_ci		break;
185962306a36Sopenharmony_ci	case PWRAP_MT6873:
186062306a36Sopenharmony_ci	case PWRAP_MT8183:
186162306a36Sopenharmony_ci	case PWRAP_MT8195:
186262306a36Sopenharmony_ci		break;
186362306a36Sopenharmony_ci	}
186462306a36Sopenharmony_ci
186562306a36Sopenharmony_ci	/* Config cipher mode @PMIC */
186662306a36Sopenharmony_ci	pwrap_config_cipher(wrp, wrp->slave->dew_regs);
186762306a36Sopenharmony_ci
186862306a36Sopenharmony_ci	/* If there is any companion PMIC, configure cipher mode there too */
186962306a36Sopenharmony_ci	if (wrp->slave->comp_type > 0)
187062306a36Sopenharmony_ci		pwrap_config_cipher(wrp, wrp->slave->comp_dew_regs);
187162306a36Sopenharmony_ci
187262306a36Sopenharmony_ci	switch (wrp->slave->type) {
187362306a36Sopenharmony_ci	case PMIC_MT6397:
187462306a36Sopenharmony_ci		pwrap_write(wrp, wrp->slave->dew_regs[PWRAP_DEW_CIPHER_LOAD],
187562306a36Sopenharmony_ci			    0x1);
187662306a36Sopenharmony_ci		pwrap_write(wrp, wrp->slave->dew_regs[PWRAP_DEW_CIPHER_START],
187762306a36Sopenharmony_ci			    0x1);
187862306a36Sopenharmony_ci		break;
187962306a36Sopenharmony_ci	case PMIC_MT6323:
188062306a36Sopenharmony_ci	case PMIC_MT6351:
188162306a36Sopenharmony_ci	case PMIC_MT6357:
188262306a36Sopenharmony_ci		pwrap_write(wrp, wrp->slave->dew_regs[PWRAP_DEW_CIPHER_EN],
188362306a36Sopenharmony_ci			    0x1);
188462306a36Sopenharmony_ci		break;
188562306a36Sopenharmony_ci	default:
188662306a36Sopenharmony_ci		break;
188762306a36Sopenharmony_ci	}
188862306a36Sopenharmony_ci
188962306a36Sopenharmony_ci	/* wait for cipher data ready@AP */
189062306a36Sopenharmony_ci	ret = readx_poll_timeout(pwrap_is_cipher_ready, wrp, tmp, tmp,
189162306a36Sopenharmony_ci				 PWRAP_POLL_DELAY_US, PWRAP_POLL_TIMEOUT_US);
189262306a36Sopenharmony_ci	if (ret) {
189362306a36Sopenharmony_ci		dev_err(wrp->dev, "cipher data ready@AP fail, ret=%d\n", ret);
189462306a36Sopenharmony_ci		return ret;
189562306a36Sopenharmony_ci	}
189662306a36Sopenharmony_ci
189762306a36Sopenharmony_ci	/* wait for cipher data ready@PMIC */
189862306a36Sopenharmony_ci	ret = readx_poll_timeout(pwrap_is_pmic_cipher_ready, wrp, tmp, tmp,
189962306a36Sopenharmony_ci				 PWRAP_POLL_DELAY_US, PWRAP_POLL_TIMEOUT_US);
190062306a36Sopenharmony_ci	if (ret) {
190162306a36Sopenharmony_ci		dev_err(wrp->dev,
190262306a36Sopenharmony_ci			"timeout waiting for cipher data ready@PMIC\n");
190362306a36Sopenharmony_ci		return ret;
190462306a36Sopenharmony_ci	}
190562306a36Sopenharmony_ci
190662306a36Sopenharmony_ci	/* wait for cipher mode idle */
190762306a36Sopenharmony_ci	pwrap_write(wrp, wrp->slave->dew_regs[PWRAP_DEW_CIPHER_MODE], 0x1);
190862306a36Sopenharmony_ci	ret = readx_poll_timeout(pwrap_is_fsm_idle_and_sync_idle, wrp, tmp, tmp,
190962306a36Sopenharmony_ci				 PWRAP_POLL_DELAY_US, PWRAP_POLL_TIMEOUT_US);
191062306a36Sopenharmony_ci	if (ret) {
191162306a36Sopenharmony_ci		dev_err(wrp->dev, "cipher mode idle fail, ret=%d\n", ret);
191262306a36Sopenharmony_ci		return ret;
191362306a36Sopenharmony_ci	}
191462306a36Sopenharmony_ci
191562306a36Sopenharmony_ci	pwrap_writel(wrp, 1, PWRAP_CIPHER_MODE);
191662306a36Sopenharmony_ci
191762306a36Sopenharmony_ci	/* Write Test */
191862306a36Sopenharmony_ci	if (pwrap_write(wrp, wrp->slave->dew_regs[PWRAP_DEW_WRITE_TEST],
191962306a36Sopenharmony_ci			PWRAP_DEW_WRITE_TEST_VAL) ||
192062306a36Sopenharmony_ci	    pwrap_read(wrp, wrp->slave->dew_regs[PWRAP_DEW_WRITE_TEST],
192162306a36Sopenharmony_ci		       &rdata) ||
192262306a36Sopenharmony_ci	    (rdata != PWRAP_DEW_WRITE_TEST_VAL)) {
192362306a36Sopenharmony_ci		dev_err(wrp->dev, "rdata=0x%04X\n", rdata);
192462306a36Sopenharmony_ci		return -EFAULT;
192562306a36Sopenharmony_ci	}
192662306a36Sopenharmony_ci
192762306a36Sopenharmony_ci	return 0;
192862306a36Sopenharmony_ci}
192962306a36Sopenharmony_ci
193062306a36Sopenharmony_cistatic int pwrap_init_security(struct pmic_wrapper *wrp)
193162306a36Sopenharmony_ci{
193262306a36Sopenharmony_ci	u32 crc_val;
193362306a36Sopenharmony_ci	int ret;
193462306a36Sopenharmony_ci
193562306a36Sopenharmony_ci	/* Enable encryption */
193662306a36Sopenharmony_ci	ret = pwrap_init_cipher(wrp);
193762306a36Sopenharmony_ci	if (ret)
193862306a36Sopenharmony_ci		return ret;
193962306a36Sopenharmony_ci
194062306a36Sopenharmony_ci	/* Signature checking - using CRC */
194162306a36Sopenharmony_ci	ret = pwrap_write(wrp, wrp->slave->dew_regs[PWRAP_DEW_CRC_EN], 0x1);
194262306a36Sopenharmony_ci	if (ret == 0 && wrp->slave->comp_dew_regs)
194362306a36Sopenharmony_ci		ret = pwrap_write(wrp, wrp->slave->comp_dew_regs[PWRAP_DEW_CRC_EN], 0x1);
194462306a36Sopenharmony_ci
194562306a36Sopenharmony_ci	pwrap_writel(wrp, 0x1, PWRAP_CRC_EN);
194662306a36Sopenharmony_ci	pwrap_writel(wrp, 0x0, PWRAP_SIG_MODE);
194762306a36Sopenharmony_ci
194862306a36Sopenharmony_ci	/* CRC value */
194962306a36Sopenharmony_ci	crc_val = wrp->slave->dew_regs[PWRAP_DEW_CRC_VAL];
195062306a36Sopenharmony_ci	if (wrp->slave->comp_dew_regs)
195162306a36Sopenharmony_ci		crc_val |= wrp->slave->comp_dew_regs[PWRAP_DEW_CRC_VAL] << 16;
195262306a36Sopenharmony_ci
195362306a36Sopenharmony_ci	pwrap_writel(wrp, crc_val, PWRAP_SIG_ADR);
195462306a36Sopenharmony_ci
195562306a36Sopenharmony_ci	/* PMIC Wrapper Arbiter priority */
195662306a36Sopenharmony_ci	pwrap_writel(wrp,
195762306a36Sopenharmony_ci		     wrp->master->arb_en_all, PWRAP_HIPRIO_ARB_EN);
195862306a36Sopenharmony_ci
195962306a36Sopenharmony_ci	return 0;
196062306a36Sopenharmony_ci}
196162306a36Sopenharmony_ci
196262306a36Sopenharmony_cistatic int pwrap_mt8135_init_soc_specific(struct pmic_wrapper *wrp)
196362306a36Sopenharmony_ci{
196462306a36Sopenharmony_ci	/* enable pwrap events and pwrap bridge in AP side */
196562306a36Sopenharmony_ci	pwrap_writel(wrp, 0x1, PWRAP_EVENT_IN_EN);
196662306a36Sopenharmony_ci	pwrap_writel(wrp, 0xffff, PWRAP_EVENT_DST_EN);
196762306a36Sopenharmony_ci	writel(0x7f, wrp->bridge_base + PWRAP_MT8135_BRIDGE_IORD_ARB_EN);
196862306a36Sopenharmony_ci	writel(0x1, wrp->bridge_base + PWRAP_MT8135_BRIDGE_WACS3_EN);
196962306a36Sopenharmony_ci	writel(0x1, wrp->bridge_base + PWRAP_MT8135_BRIDGE_WACS4_EN);
197062306a36Sopenharmony_ci	writel(0x1, wrp->bridge_base + PWRAP_MT8135_BRIDGE_WDT_UNIT);
197162306a36Sopenharmony_ci	writel(0xffff, wrp->bridge_base + PWRAP_MT8135_BRIDGE_WDT_SRC_EN);
197262306a36Sopenharmony_ci	writel(0x1, wrp->bridge_base + PWRAP_MT8135_BRIDGE_TIMER_EN);
197362306a36Sopenharmony_ci	writel(0x7ff, wrp->bridge_base + PWRAP_MT8135_BRIDGE_INT_EN);
197462306a36Sopenharmony_ci
197562306a36Sopenharmony_ci	/* enable PMIC event out and sources */
197662306a36Sopenharmony_ci	if (pwrap_write(wrp, wrp->slave->dew_regs[PWRAP_DEW_EVENT_OUT_EN],
197762306a36Sopenharmony_ci			0x1) ||
197862306a36Sopenharmony_ci	    pwrap_write(wrp, wrp->slave->dew_regs[PWRAP_DEW_EVENT_SRC_EN],
197962306a36Sopenharmony_ci			0xffff)) {
198062306a36Sopenharmony_ci		dev_err(wrp->dev, "enable dewrap fail\n");
198162306a36Sopenharmony_ci		return -EFAULT;
198262306a36Sopenharmony_ci	}
198362306a36Sopenharmony_ci
198462306a36Sopenharmony_ci	return 0;
198562306a36Sopenharmony_ci}
198662306a36Sopenharmony_ci
198762306a36Sopenharmony_cistatic int pwrap_mt8173_init_soc_specific(struct pmic_wrapper *wrp)
198862306a36Sopenharmony_ci{
198962306a36Sopenharmony_ci	/* PMIC_DEWRAP enables */
199062306a36Sopenharmony_ci	if (pwrap_write(wrp, wrp->slave->dew_regs[PWRAP_DEW_EVENT_OUT_EN],
199162306a36Sopenharmony_ci			0x1) ||
199262306a36Sopenharmony_ci	    pwrap_write(wrp, wrp->slave->dew_regs[PWRAP_DEW_EVENT_SRC_EN],
199362306a36Sopenharmony_ci			0xffff)) {
199462306a36Sopenharmony_ci		dev_err(wrp->dev, "enable dewrap fail\n");
199562306a36Sopenharmony_ci		return -EFAULT;
199662306a36Sopenharmony_ci	}
199762306a36Sopenharmony_ci
199862306a36Sopenharmony_ci	return 0;
199962306a36Sopenharmony_ci}
200062306a36Sopenharmony_ci
200162306a36Sopenharmony_cistatic int pwrap_mt2701_init_soc_specific(struct pmic_wrapper *wrp)
200262306a36Sopenharmony_ci{
200362306a36Sopenharmony_ci	/* GPS_INTF initialization */
200462306a36Sopenharmony_ci	switch (wrp->slave->type) {
200562306a36Sopenharmony_ci	case PMIC_MT6323:
200662306a36Sopenharmony_ci		pwrap_writel(wrp, 0x076c, PWRAP_ADC_CMD_ADDR);
200762306a36Sopenharmony_ci		pwrap_writel(wrp, 0x8000, PWRAP_PWRAP_ADC_CMD);
200862306a36Sopenharmony_ci		pwrap_writel(wrp, 0x072c, PWRAP_ADC_RDY_ADDR);
200962306a36Sopenharmony_ci		pwrap_writel(wrp, 0x072e, PWRAP_ADC_RDATA_ADDR1);
201062306a36Sopenharmony_ci		pwrap_writel(wrp, 0x0730, PWRAP_ADC_RDATA_ADDR2);
201162306a36Sopenharmony_ci		break;
201262306a36Sopenharmony_ci	default:
201362306a36Sopenharmony_ci		break;
201462306a36Sopenharmony_ci	}
201562306a36Sopenharmony_ci
201662306a36Sopenharmony_ci	return 0;
201762306a36Sopenharmony_ci}
201862306a36Sopenharmony_ci
201962306a36Sopenharmony_cistatic int pwrap_mt6795_init_soc_specific(struct pmic_wrapper *wrp)
202062306a36Sopenharmony_ci{
202162306a36Sopenharmony_ci	pwrap_writel(wrp, 0xf, PWRAP_STAUPD_GRPEN);
202262306a36Sopenharmony_ci
202362306a36Sopenharmony_ci	if (wrp->slave->type == PMIC_MT6331)
202462306a36Sopenharmony_ci		pwrap_writel(wrp, 0x1b4, PWRAP_EINT_STA0_ADR);
202562306a36Sopenharmony_ci
202662306a36Sopenharmony_ci	if (wrp->slave->comp_type == PMIC_MT6332)
202762306a36Sopenharmony_ci		pwrap_writel(wrp, 0x8112, PWRAP_EINT_STA1_ADR);
202862306a36Sopenharmony_ci
202962306a36Sopenharmony_ci	return 0;
203062306a36Sopenharmony_ci}
203162306a36Sopenharmony_ci
203262306a36Sopenharmony_cistatic int pwrap_mt7622_init_soc_specific(struct pmic_wrapper *wrp)
203362306a36Sopenharmony_ci{
203462306a36Sopenharmony_ci	pwrap_writel(wrp, 0, PWRAP_STAUPD_PRD);
203562306a36Sopenharmony_ci	/* enable 2wire SPI master */
203662306a36Sopenharmony_ci	pwrap_writel(wrp, 0x8000000, PWRAP_SPI2_CTRL);
203762306a36Sopenharmony_ci
203862306a36Sopenharmony_ci	return 0;
203962306a36Sopenharmony_ci}
204062306a36Sopenharmony_ci
204162306a36Sopenharmony_cistatic int pwrap_mt8183_init_soc_specific(struct pmic_wrapper *wrp)
204262306a36Sopenharmony_ci{
204362306a36Sopenharmony_ci	pwrap_writel(wrp, 0xf5, PWRAP_STAUPD_GRPEN);
204462306a36Sopenharmony_ci
204562306a36Sopenharmony_ci	pwrap_write(wrp, wrp->slave->dew_regs[PWRAP_DEW_CRC_EN], 0x1);
204662306a36Sopenharmony_ci	pwrap_writel(wrp, 1, PWRAP_CRC_EN);
204762306a36Sopenharmony_ci	pwrap_writel(wrp, 0x416, PWRAP_SIG_ADR);
204862306a36Sopenharmony_ci	pwrap_writel(wrp, 0x42e, PWRAP_EINT_STA0_ADR);
204962306a36Sopenharmony_ci
205062306a36Sopenharmony_ci	pwrap_writel(wrp, 1, PWRAP_WACS_P2P_EN);
205162306a36Sopenharmony_ci	pwrap_writel(wrp, 1, PWRAP_WACS_MD32_EN);
205262306a36Sopenharmony_ci	pwrap_writel(wrp, 1, PWRAP_INIT_DONE_P2P);
205362306a36Sopenharmony_ci	pwrap_writel(wrp, 1, PWRAP_INIT_DONE_MD32);
205462306a36Sopenharmony_ci
205562306a36Sopenharmony_ci	return 0;
205662306a36Sopenharmony_ci}
205762306a36Sopenharmony_ci
205862306a36Sopenharmony_cistatic int pwrap_init(struct pmic_wrapper *wrp)
205962306a36Sopenharmony_ci{
206062306a36Sopenharmony_ci	int ret;
206162306a36Sopenharmony_ci
206262306a36Sopenharmony_ci	if (wrp->rstc)
206362306a36Sopenharmony_ci		reset_control_reset(wrp->rstc);
206462306a36Sopenharmony_ci	if (wrp->rstc_bridge)
206562306a36Sopenharmony_ci		reset_control_reset(wrp->rstc_bridge);
206662306a36Sopenharmony_ci
206762306a36Sopenharmony_ci	switch (wrp->master->type) {
206862306a36Sopenharmony_ci	case PWRAP_MT6795:
206962306a36Sopenharmony_ci		fallthrough;
207062306a36Sopenharmony_ci	case PWRAP_MT8173:
207162306a36Sopenharmony_ci		/* Enable DCM */
207262306a36Sopenharmony_ci		pwrap_writel(wrp, 3, PWRAP_DCM_EN);
207362306a36Sopenharmony_ci		pwrap_writel(wrp, 0, PWRAP_DCM_DBC_PRD);
207462306a36Sopenharmony_ci		break;
207562306a36Sopenharmony_ci	default:
207662306a36Sopenharmony_ci		break;
207762306a36Sopenharmony_ci	}
207862306a36Sopenharmony_ci
207962306a36Sopenharmony_ci	if (HAS_CAP(wrp->slave->caps, PWRAP_SLV_CAP_SPI)) {
208062306a36Sopenharmony_ci		/* Reset SPI slave */
208162306a36Sopenharmony_ci		ret = pwrap_reset_spislave(wrp);
208262306a36Sopenharmony_ci		if (ret)
208362306a36Sopenharmony_ci			return ret;
208462306a36Sopenharmony_ci	}
208562306a36Sopenharmony_ci
208662306a36Sopenharmony_ci	pwrap_writel(wrp, 1, PWRAP_WRAP_EN);
208762306a36Sopenharmony_ci
208862306a36Sopenharmony_ci	pwrap_writel(wrp, wrp->master->arb_en_all, PWRAP_HIPRIO_ARB_EN);
208962306a36Sopenharmony_ci
209062306a36Sopenharmony_ci	pwrap_writel(wrp, 1, PWRAP_WACS2_EN);
209162306a36Sopenharmony_ci
209262306a36Sopenharmony_ci	ret = wrp->master->init_reg_clock(wrp);
209362306a36Sopenharmony_ci	if (ret)
209462306a36Sopenharmony_ci		return ret;
209562306a36Sopenharmony_ci
209662306a36Sopenharmony_ci	if (HAS_CAP(wrp->slave->caps, PWRAP_SLV_CAP_SPI)) {
209762306a36Sopenharmony_ci		/* Setup serial input delay */
209862306a36Sopenharmony_ci		ret = pwrap_init_sidly(wrp);
209962306a36Sopenharmony_ci		if (ret)
210062306a36Sopenharmony_ci			return ret;
210162306a36Sopenharmony_ci	}
210262306a36Sopenharmony_ci
210362306a36Sopenharmony_ci	if (HAS_CAP(wrp->slave->caps, PWRAP_SLV_CAP_DUALIO)) {
210462306a36Sopenharmony_ci		/* Enable dual I/O mode */
210562306a36Sopenharmony_ci		ret = pwrap_init_dual_io(wrp);
210662306a36Sopenharmony_ci		if (ret)
210762306a36Sopenharmony_ci			return ret;
210862306a36Sopenharmony_ci	}
210962306a36Sopenharmony_ci
211062306a36Sopenharmony_ci	if (HAS_CAP(wrp->slave->caps, PWRAP_SLV_CAP_SECURITY)) {
211162306a36Sopenharmony_ci		/* Enable security on bus */
211262306a36Sopenharmony_ci		ret = pwrap_init_security(wrp);
211362306a36Sopenharmony_ci		if (ret)
211462306a36Sopenharmony_ci			return ret;
211562306a36Sopenharmony_ci	}
211662306a36Sopenharmony_ci
211762306a36Sopenharmony_ci	if (wrp->master->type == PWRAP_MT8135)
211862306a36Sopenharmony_ci		pwrap_writel(wrp, 0x7, PWRAP_RRARB_EN);
211962306a36Sopenharmony_ci
212062306a36Sopenharmony_ci	pwrap_writel(wrp, 0x1, PWRAP_WACS0_EN);
212162306a36Sopenharmony_ci	pwrap_writel(wrp, 0x1, PWRAP_WACS1_EN);
212262306a36Sopenharmony_ci	pwrap_writel(wrp, 0x1, PWRAP_WACS2_EN);
212362306a36Sopenharmony_ci	pwrap_writel(wrp, 0x5, PWRAP_STAUPD_PRD);
212462306a36Sopenharmony_ci	pwrap_writel(wrp, 0xff, PWRAP_STAUPD_GRPEN);
212562306a36Sopenharmony_ci
212662306a36Sopenharmony_ci	if (wrp->master->init_soc_specific) {
212762306a36Sopenharmony_ci		ret = wrp->master->init_soc_specific(wrp);
212862306a36Sopenharmony_ci		if (ret)
212962306a36Sopenharmony_ci			return ret;
213062306a36Sopenharmony_ci	}
213162306a36Sopenharmony_ci
213262306a36Sopenharmony_ci	/* Setup the init done registers */
213362306a36Sopenharmony_ci	pwrap_writel(wrp, 1, PWRAP_INIT_DONE2);
213462306a36Sopenharmony_ci	pwrap_writel(wrp, 1, PWRAP_INIT_DONE0);
213562306a36Sopenharmony_ci	pwrap_writel(wrp, 1, PWRAP_INIT_DONE1);
213662306a36Sopenharmony_ci
213762306a36Sopenharmony_ci	if (HAS_CAP(wrp->master->caps, PWRAP_CAP_BRIDGE)) {
213862306a36Sopenharmony_ci		writel(1, wrp->bridge_base + PWRAP_MT8135_BRIDGE_INIT_DONE3);
213962306a36Sopenharmony_ci		writel(1, wrp->bridge_base + PWRAP_MT8135_BRIDGE_INIT_DONE4);
214062306a36Sopenharmony_ci	}
214162306a36Sopenharmony_ci
214262306a36Sopenharmony_ci	return 0;
214362306a36Sopenharmony_ci}
214462306a36Sopenharmony_ci
214562306a36Sopenharmony_cistatic irqreturn_t pwrap_interrupt(int irqno, void *dev_id)
214662306a36Sopenharmony_ci{
214762306a36Sopenharmony_ci	u32 rdata;
214862306a36Sopenharmony_ci	struct pmic_wrapper *wrp = dev_id;
214962306a36Sopenharmony_ci
215062306a36Sopenharmony_ci	rdata = pwrap_readl(wrp, PWRAP_INT_FLG);
215162306a36Sopenharmony_ci	dev_err(wrp->dev, "unexpected interrupt int=0x%x\n", rdata);
215262306a36Sopenharmony_ci	pwrap_writel(wrp, 0xffffffff, PWRAP_INT_CLR);
215362306a36Sopenharmony_ci
215462306a36Sopenharmony_ci	if (HAS_CAP(wrp->master->caps, PWRAP_CAP_INT1_EN)) {
215562306a36Sopenharmony_ci		rdata = pwrap_readl(wrp, PWRAP_INT1_FLG);
215662306a36Sopenharmony_ci		dev_err(wrp->dev, "unexpected interrupt int1=0x%x\n", rdata);
215762306a36Sopenharmony_ci		pwrap_writel(wrp, 0xffffffff, PWRAP_INT1_CLR);
215862306a36Sopenharmony_ci	}
215962306a36Sopenharmony_ci
216062306a36Sopenharmony_ci	return IRQ_HANDLED;
216162306a36Sopenharmony_ci}
216262306a36Sopenharmony_ci
216362306a36Sopenharmony_cistatic const struct regmap_config pwrap_regmap_config16 = {
216462306a36Sopenharmony_ci	.reg_bits = 16,
216562306a36Sopenharmony_ci	.val_bits = 16,
216662306a36Sopenharmony_ci	.reg_stride = 2,
216762306a36Sopenharmony_ci	.reg_read = pwrap_regmap_read,
216862306a36Sopenharmony_ci	.reg_write = pwrap_regmap_write,
216962306a36Sopenharmony_ci	.max_register = 0xffff,
217062306a36Sopenharmony_ci};
217162306a36Sopenharmony_ci
217262306a36Sopenharmony_cistatic const struct regmap_config pwrap_regmap_config32 = {
217362306a36Sopenharmony_ci	.reg_bits = 32,
217462306a36Sopenharmony_ci	.val_bits = 32,
217562306a36Sopenharmony_ci	.reg_stride = 4,
217662306a36Sopenharmony_ci	.reg_read = pwrap_regmap_read,
217762306a36Sopenharmony_ci	.reg_write = pwrap_regmap_write,
217862306a36Sopenharmony_ci	.max_register = 0xffff,
217962306a36Sopenharmony_ci};
218062306a36Sopenharmony_ci
218162306a36Sopenharmony_cistatic const struct pwrap_slv_regops pwrap_regops16 = {
218262306a36Sopenharmony_ci	.pwrap_read = pwrap_read16,
218362306a36Sopenharmony_ci	.pwrap_write = pwrap_write16,
218462306a36Sopenharmony_ci	.regmap = &pwrap_regmap_config16,
218562306a36Sopenharmony_ci};
218662306a36Sopenharmony_ci
218762306a36Sopenharmony_cistatic const struct pwrap_slv_regops pwrap_regops32 = {
218862306a36Sopenharmony_ci	.pwrap_read = pwrap_read32,
218962306a36Sopenharmony_ci	.pwrap_write = pwrap_write32,
219062306a36Sopenharmony_ci	.regmap = &pwrap_regmap_config32,
219162306a36Sopenharmony_ci};
219262306a36Sopenharmony_ci
219362306a36Sopenharmony_cistatic const struct pwrap_slv_type pmic_mt6323 = {
219462306a36Sopenharmony_ci	.dew_regs = mt6323_regs,
219562306a36Sopenharmony_ci	.type = PMIC_MT6323,
219662306a36Sopenharmony_ci	.regops = &pwrap_regops16,
219762306a36Sopenharmony_ci	.caps = PWRAP_SLV_CAP_SPI | PWRAP_SLV_CAP_DUALIO |
219862306a36Sopenharmony_ci		PWRAP_SLV_CAP_SECURITY,
219962306a36Sopenharmony_ci};
220062306a36Sopenharmony_ci
220162306a36Sopenharmony_cistatic const struct pwrap_slv_type pmic_mt6331 = {
220262306a36Sopenharmony_ci	.dew_regs = mt6331_regs,
220362306a36Sopenharmony_ci	.type = PMIC_MT6331,
220462306a36Sopenharmony_ci	.comp_dew_regs = mt6332_regs,
220562306a36Sopenharmony_ci	.comp_type = PMIC_MT6332,
220662306a36Sopenharmony_ci	.regops = &pwrap_regops16,
220762306a36Sopenharmony_ci	.caps = PWRAP_SLV_CAP_SPI | PWRAP_SLV_CAP_DUALIO |
220862306a36Sopenharmony_ci		PWRAP_SLV_CAP_SECURITY,
220962306a36Sopenharmony_ci};
221062306a36Sopenharmony_ci
221162306a36Sopenharmony_cistatic const struct pwrap_slv_type pmic_mt6351 = {
221262306a36Sopenharmony_ci	.dew_regs = mt6351_regs,
221362306a36Sopenharmony_ci	.type = PMIC_MT6351,
221462306a36Sopenharmony_ci	.regops = &pwrap_regops16,
221562306a36Sopenharmony_ci	.caps = 0,
221662306a36Sopenharmony_ci};
221762306a36Sopenharmony_ci
221862306a36Sopenharmony_cistatic const struct pwrap_slv_type pmic_mt6357 = {
221962306a36Sopenharmony_ci	.dew_regs = mt6357_regs,
222062306a36Sopenharmony_ci	.type = PMIC_MT6357,
222162306a36Sopenharmony_ci	.regops = &pwrap_regops16,
222262306a36Sopenharmony_ci	.caps = 0,
222362306a36Sopenharmony_ci};
222462306a36Sopenharmony_ci
222562306a36Sopenharmony_cistatic const struct pwrap_slv_type pmic_mt6358 = {
222662306a36Sopenharmony_ci	.dew_regs = mt6358_regs,
222762306a36Sopenharmony_ci	.type = PMIC_MT6358,
222862306a36Sopenharmony_ci	.regops = &pwrap_regops16,
222962306a36Sopenharmony_ci	.caps = PWRAP_SLV_CAP_SPI | PWRAP_SLV_CAP_DUALIO,
223062306a36Sopenharmony_ci};
223162306a36Sopenharmony_ci
223262306a36Sopenharmony_cistatic const struct pwrap_slv_type pmic_mt6359 = {
223362306a36Sopenharmony_ci	.dew_regs = mt6359_regs,
223462306a36Sopenharmony_ci	.type = PMIC_MT6359,
223562306a36Sopenharmony_ci	.regops = &pwrap_regops16,
223662306a36Sopenharmony_ci	.caps = PWRAP_SLV_CAP_DUALIO,
223762306a36Sopenharmony_ci};
223862306a36Sopenharmony_ci
223962306a36Sopenharmony_cistatic const struct pwrap_slv_type pmic_mt6380 = {
224062306a36Sopenharmony_ci	.dew_regs = NULL,
224162306a36Sopenharmony_ci	.type = PMIC_MT6380,
224262306a36Sopenharmony_ci	.regops = &pwrap_regops32,
224362306a36Sopenharmony_ci	.caps = 0,
224462306a36Sopenharmony_ci};
224562306a36Sopenharmony_ci
224662306a36Sopenharmony_cistatic const struct pwrap_slv_type pmic_mt6397 = {
224762306a36Sopenharmony_ci	.dew_regs = mt6397_regs,
224862306a36Sopenharmony_ci	.type = PMIC_MT6397,
224962306a36Sopenharmony_ci	.regops = &pwrap_regops16,
225062306a36Sopenharmony_ci	.caps = PWRAP_SLV_CAP_SPI | PWRAP_SLV_CAP_DUALIO |
225162306a36Sopenharmony_ci		PWRAP_SLV_CAP_SECURITY,
225262306a36Sopenharmony_ci};
225362306a36Sopenharmony_ci
225462306a36Sopenharmony_cistatic const struct of_device_id of_slave_match_tbl[] = {
225562306a36Sopenharmony_ci	{ .compatible = "mediatek,mt6323", .data = &pmic_mt6323 },
225662306a36Sopenharmony_ci	{ .compatible = "mediatek,mt6331", .data = &pmic_mt6331 },
225762306a36Sopenharmony_ci	{ .compatible = "mediatek,mt6351", .data = &pmic_mt6351 },
225862306a36Sopenharmony_ci	{ .compatible = "mediatek,mt6357", .data = &pmic_mt6357 },
225962306a36Sopenharmony_ci	{ .compatible = "mediatek,mt6358", .data = &pmic_mt6358 },
226062306a36Sopenharmony_ci	{ .compatible = "mediatek,mt6359", .data = &pmic_mt6359 },
226162306a36Sopenharmony_ci
226262306a36Sopenharmony_ci	/* The MT6380 PMIC only implements a regulator, so we bind it
226362306a36Sopenharmony_ci	 * directly instead of using a MFD.
226462306a36Sopenharmony_ci	 */
226562306a36Sopenharmony_ci	{ .compatible = "mediatek,mt6380-regulator", .data = &pmic_mt6380 },
226662306a36Sopenharmony_ci	{ .compatible = "mediatek,mt6397", .data = &pmic_mt6397 },
226762306a36Sopenharmony_ci	{ /* sentinel */ }
226862306a36Sopenharmony_ci};
226962306a36Sopenharmony_ciMODULE_DEVICE_TABLE(of, of_slave_match_tbl);
227062306a36Sopenharmony_ci
227162306a36Sopenharmony_cistatic const struct pmic_wrapper_type pwrap_mt2701 = {
227262306a36Sopenharmony_ci	.regs = mt2701_regs,
227362306a36Sopenharmony_ci	.type = PWRAP_MT2701,
227462306a36Sopenharmony_ci	.arb_en_all = 0x3f,
227562306a36Sopenharmony_ci	.int_en_all = ~(u32)(BIT(31) | BIT(2)),
227662306a36Sopenharmony_ci	.int1_en_all = 0,
227762306a36Sopenharmony_ci	.spi_w = PWRAP_MAN_CMD_SPI_WRITE_NEW,
227862306a36Sopenharmony_ci	.wdt_src = PWRAP_WDT_SRC_MASK_ALL,
227962306a36Sopenharmony_ci	.caps = PWRAP_CAP_RESET | PWRAP_CAP_DCM,
228062306a36Sopenharmony_ci	.init_reg_clock = pwrap_mt2701_init_reg_clock,
228162306a36Sopenharmony_ci	.init_soc_specific = pwrap_mt2701_init_soc_specific,
228262306a36Sopenharmony_ci};
228362306a36Sopenharmony_ci
228462306a36Sopenharmony_cistatic const struct pmic_wrapper_type pwrap_mt6765 = {
228562306a36Sopenharmony_ci	.regs = mt6765_regs,
228662306a36Sopenharmony_ci	.type = PWRAP_MT6765,
228762306a36Sopenharmony_ci	.arb_en_all = 0x3fd35,
228862306a36Sopenharmony_ci	.int_en_all = 0xffffffff,
228962306a36Sopenharmony_ci	.spi_w = PWRAP_MAN_CMD_SPI_WRITE,
229062306a36Sopenharmony_ci	.wdt_src = PWRAP_WDT_SRC_MASK_ALL,
229162306a36Sopenharmony_ci	.caps = PWRAP_CAP_RESET | PWRAP_CAP_DCM,
229262306a36Sopenharmony_ci	.init_reg_clock = pwrap_common_init_reg_clock,
229362306a36Sopenharmony_ci	.init_soc_specific = NULL,
229462306a36Sopenharmony_ci};
229562306a36Sopenharmony_ci
229662306a36Sopenharmony_cistatic const struct pmic_wrapper_type pwrap_mt6779 = {
229762306a36Sopenharmony_ci	.regs = mt6779_regs,
229862306a36Sopenharmony_ci	.type = PWRAP_MT6779,
229962306a36Sopenharmony_ci	.arb_en_all = 0xfbb7f,
230062306a36Sopenharmony_ci	.int_en_all = 0xfffffffe,
230162306a36Sopenharmony_ci	.int1_en_all = 0,
230262306a36Sopenharmony_ci	.spi_w = PWRAP_MAN_CMD_SPI_WRITE,
230362306a36Sopenharmony_ci	.wdt_src = PWRAP_WDT_SRC_MASK_ALL,
230462306a36Sopenharmony_ci	.caps = 0,
230562306a36Sopenharmony_ci	.init_reg_clock = pwrap_common_init_reg_clock,
230662306a36Sopenharmony_ci	.init_soc_specific = NULL,
230762306a36Sopenharmony_ci};
230862306a36Sopenharmony_ci
230962306a36Sopenharmony_cistatic const struct pmic_wrapper_type pwrap_mt6795 = {
231062306a36Sopenharmony_ci	.regs = mt6795_regs,
231162306a36Sopenharmony_ci	.type = PWRAP_MT6795,
231262306a36Sopenharmony_ci	.arb_en_all = 0x3f,
231362306a36Sopenharmony_ci	.int_en_all = ~(u32)(BIT(31) | BIT(2) | BIT(1)),
231462306a36Sopenharmony_ci	.int1_en_all = 0,
231562306a36Sopenharmony_ci	.spi_w = PWRAP_MAN_CMD_SPI_WRITE,
231662306a36Sopenharmony_ci	.wdt_src = PWRAP_WDT_SRC_MASK_NO_STAUPD,
231762306a36Sopenharmony_ci	.caps = PWRAP_CAP_RESET | PWRAP_CAP_DCM,
231862306a36Sopenharmony_ci	.init_reg_clock = pwrap_common_init_reg_clock,
231962306a36Sopenharmony_ci	.init_soc_specific = pwrap_mt6795_init_soc_specific,
232062306a36Sopenharmony_ci};
232162306a36Sopenharmony_ci
232262306a36Sopenharmony_cistatic const struct pmic_wrapper_type pwrap_mt6797 = {
232362306a36Sopenharmony_ci	.regs = mt6797_regs,
232462306a36Sopenharmony_ci	.type = PWRAP_MT6797,
232562306a36Sopenharmony_ci	.arb_en_all = 0x01fff,
232662306a36Sopenharmony_ci	.int_en_all = 0xffffffc6,
232762306a36Sopenharmony_ci	.int1_en_all = 0,
232862306a36Sopenharmony_ci	.spi_w = PWRAP_MAN_CMD_SPI_WRITE,
232962306a36Sopenharmony_ci	.wdt_src = PWRAP_WDT_SRC_MASK_ALL,
233062306a36Sopenharmony_ci	.caps = PWRAP_CAP_RESET | PWRAP_CAP_DCM,
233162306a36Sopenharmony_ci	.init_reg_clock = pwrap_common_init_reg_clock,
233262306a36Sopenharmony_ci	.init_soc_specific = NULL,
233362306a36Sopenharmony_ci};
233462306a36Sopenharmony_ci
233562306a36Sopenharmony_cistatic const struct pmic_wrapper_type pwrap_mt6873 = {
233662306a36Sopenharmony_ci	.regs = mt6873_regs,
233762306a36Sopenharmony_ci	.type = PWRAP_MT6873,
233862306a36Sopenharmony_ci	.arb_en_all = 0x777f,
233962306a36Sopenharmony_ci	.int_en_all = BIT(4) | BIT(5),
234062306a36Sopenharmony_ci	.int1_en_all = 0,
234162306a36Sopenharmony_ci	.spi_w = PWRAP_MAN_CMD_SPI_WRITE,
234262306a36Sopenharmony_ci	.wdt_src = PWRAP_WDT_SRC_MASK_ALL,
234362306a36Sopenharmony_ci	.caps = PWRAP_CAP_ARB,
234462306a36Sopenharmony_ci	.init_reg_clock = pwrap_common_init_reg_clock,
234562306a36Sopenharmony_ci	.init_soc_specific = NULL,
234662306a36Sopenharmony_ci};
234762306a36Sopenharmony_ci
234862306a36Sopenharmony_cistatic const struct pmic_wrapper_type pwrap_mt7622 = {
234962306a36Sopenharmony_ci	.regs = mt7622_regs,
235062306a36Sopenharmony_ci	.type = PWRAP_MT7622,
235162306a36Sopenharmony_ci	.arb_en_all = 0xff,
235262306a36Sopenharmony_ci	.int_en_all = ~(u32)BIT(31),
235362306a36Sopenharmony_ci	.int1_en_all = 0,
235462306a36Sopenharmony_ci	.spi_w = PWRAP_MAN_CMD_SPI_WRITE,
235562306a36Sopenharmony_ci	.wdt_src = PWRAP_WDT_SRC_MASK_ALL,
235662306a36Sopenharmony_ci	.caps = PWRAP_CAP_RESET | PWRAP_CAP_DCM,
235762306a36Sopenharmony_ci	.init_reg_clock = pwrap_common_init_reg_clock,
235862306a36Sopenharmony_ci	.init_soc_specific = pwrap_mt7622_init_soc_specific,
235962306a36Sopenharmony_ci};
236062306a36Sopenharmony_ci
236162306a36Sopenharmony_cistatic const struct pmic_wrapper_type pwrap_mt8135 = {
236262306a36Sopenharmony_ci	.regs = mt8135_regs,
236362306a36Sopenharmony_ci	.type = PWRAP_MT8135,
236462306a36Sopenharmony_ci	.arb_en_all = 0x1ff,
236562306a36Sopenharmony_ci	.int_en_all = ~(u32)(BIT(31) | BIT(1)),
236662306a36Sopenharmony_ci	.int1_en_all = 0,
236762306a36Sopenharmony_ci	.spi_w = PWRAP_MAN_CMD_SPI_WRITE,
236862306a36Sopenharmony_ci	.wdt_src = PWRAP_WDT_SRC_MASK_ALL,
236962306a36Sopenharmony_ci	.caps = PWRAP_CAP_BRIDGE | PWRAP_CAP_RESET | PWRAP_CAP_DCM,
237062306a36Sopenharmony_ci	.init_reg_clock = pwrap_common_init_reg_clock,
237162306a36Sopenharmony_ci	.init_soc_specific = pwrap_mt8135_init_soc_specific,
237262306a36Sopenharmony_ci};
237362306a36Sopenharmony_ci
237462306a36Sopenharmony_cistatic const struct pmic_wrapper_type pwrap_mt8173 = {
237562306a36Sopenharmony_ci	.regs = mt8173_regs,
237662306a36Sopenharmony_ci	.type = PWRAP_MT8173,
237762306a36Sopenharmony_ci	.arb_en_all = 0x3f,
237862306a36Sopenharmony_ci	.int_en_all = ~(u32)(BIT(31) | BIT(1)),
237962306a36Sopenharmony_ci	.int1_en_all = 0,
238062306a36Sopenharmony_ci	.spi_w = PWRAP_MAN_CMD_SPI_WRITE,
238162306a36Sopenharmony_ci	.wdt_src = PWRAP_WDT_SRC_MASK_NO_STAUPD,
238262306a36Sopenharmony_ci	.caps = PWRAP_CAP_RESET | PWRAP_CAP_DCM,
238362306a36Sopenharmony_ci	.init_reg_clock = pwrap_common_init_reg_clock,
238462306a36Sopenharmony_ci	.init_soc_specific = pwrap_mt8173_init_soc_specific,
238562306a36Sopenharmony_ci};
238662306a36Sopenharmony_ci
238762306a36Sopenharmony_cistatic const struct pmic_wrapper_type pwrap_mt8183 = {
238862306a36Sopenharmony_ci	.regs = mt8183_regs,
238962306a36Sopenharmony_ci	.type = PWRAP_MT8183,
239062306a36Sopenharmony_ci	.arb_en_all = 0x3fa75,
239162306a36Sopenharmony_ci	.int_en_all = 0xffffffff,
239262306a36Sopenharmony_ci	.int1_en_all = 0xeef7ffff,
239362306a36Sopenharmony_ci	.spi_w = PWRAP_MAN_CMD_SPI_WRITE,
239462306a36Sopenharmony_ci	.wdt_src = PWRAP_WDT_SRC_MASK_ALL,
239562306a36Sopenharmony_ci	.caps = PWRAP_CAP_INT1_EN | PWRAP_CAP_WDT_SRC1,
239662306a36Sopenharmony_ci	.init_reg_clock = pwrap_common_init_reg_clock,
239762306a36Sopenharmony_ci	.init_soc_specific = pwrap_mt8183_init_soc_specific,
239862306a36Sopenharmony_ci};
239962306a36Sopenharmony_ci
240062306a36Sopenharmony_cistatic struct pmic_wrapper_type pwrap_mt8195 = {
240162306a36Sopenharmony_ci	.regs = mt8195_regs,
240262306a36Sopenharmony_ci	.type = PWRAP_MT8195,
240362306a36Sopenharmony_ci	.arb_en_all = 0x777f, /* NEED CONFIRM */
240462306a36Sopenharmony_ci	.int_en_all = 0x180000, /* NEED CONFIRM */
240562306a36Sopenharmony_ci	.int1_en_all = 0,
240662306a36Sopenharmony_ci	.spi_w = PWRAP_MAN_CMD_SPI_WRITE,
240762306a36Sopenharmony_ci	.wdt_src = PWRAP_WDT_SRC_MASK_ALL,
240862306a36Sopenharmony_ci	.caps = PWRAP_CAP_INT1_EN | PWRAP_CAP_ARB,
240962306a36Sopenharmony_ci	.init_reg_clock = pwrap_common_init_reg_clock,
241062306a36Sopenharmony_ci	.init_soc_specific = NULL,
241162306a36Sopenharmony_ci};
241262306a36Sopenharmony_ci
241362306a36Sopenharmony_cistatic const struct pmic_wrapper_type pwrap_mt8365 = {
241462306a36Sopenharmony_ci	.regs = mt8365_regs,
241562306a36Sopenharmony_ci	.type = PWRAP_MT8365,
241662306a36Sopenharmony_ci	.arb_en_all = 0x3ffff,
241762306a36Sopenharmony_ci	.int_en_all = 0x7f1fffff,
241862306a36Sopenharmony_ci	.int1_en_all = 0x0,
241962306a36Sopenharmony_ci	.spi_w = PWRAP_MAN_CMD_SPI_WRITE,
242062306a36Sopenharmony_ci	.wdt_src = PWRAP_WDT_SRC_MASK_ALL,
242162306a36Sopenharmony_ci	.caps = PWRAP_CAP_INT1_EN | PWRAP_CAP_WDT_SRC1,
242262306a36Sopenharmony_ci	.init_reg_clock = pwrap_common_init_reg_clock,
242362306a36Sopenharmony_ci	.init_soc_specific = NULL,
242462306a36Sopenharmony_ci};
242562306a36Sopenharmony_ci
242662306a36Sopenharmony_cistatic struct pmic_wrapper_type pwrap_mt8516 = {
242762306a36Sopenharmony_ci	.regs = mt8516_regs,
242862306a36Sopenharmony_ci	.type = PWRAP_MT8516,
242962306a36Sopenharmony_ci	.arb_en_all = 0xff,
243062306a36Sopenharmony_ci	.int_en_all = ~(u32)(BIT(31) | BIT(2)),
243162306a36Sopenharmony_ci	.spi_w = PWRAP_MAN_CMD_SPI_WRITE,
243262306a36Sopenharmony_ci	.wdt_src = PWRAP_WDT_SRC_MASK_ALL,
243362306a36Sopenharmony_ci	.caps = PWRAP_CAP_DCM,
243462306a36Sopenharmony_ci	.init_reg_clock = pwrap_mt2701_init_reg_clock,
243562306a36Sopenharmony_ci	.init_soc_specific = NULL,
243662306a36Sopenharmony_ci};
243762306a36Sopenharmony_ci
243862306a36Sopenharmony_cistatic struct pmic_wrapper_type pwrap_mt8186 = {
243962306a36Sopenharmony_ci	.regs = mt8186_regs,
244062306a36Sopenharmony_ci	.type = PWRAP_MT8186,
244162306a36Sopenharmony_ci	.arb_en_all = 0xfb27f,
244262306a36Sopenharmony_ci	.int_en_all = 0xfffffffe, /* disable WatchDog Timeout for bit 1 */
244362306a36Sopenharmony_ci	.int1_en_all =  0x000017ff, /* disable Matching interrupt for bit 13 */
244462306a36Sopenharmony_ci	.spi_w = PWRAP_MAN_CMD_SPI_WRITE,
244562306a36Sopenharmony_ci	.wdt_src = PWRAP_WDT_SRC_MASK_ALL,
244662306a36Sopenharmony_ci	.caps = PWRAP_CAP_INT1_EN | PWRAP_CAP_ARB_MT8186,
244762306a36Sopenharmony_ci	.init_reg_clock = pwrap_common_init_reg_clock,
244862306a36Sopenharmony_ci	.init_soc_specific = NULL,
244962306a36Sopenharmony_ci};
245062306a36Sopenharmony_ci
245162306a36Sopenharmony_cistatic const struct of_device_id of_pwrap_match_tbl[] = {
245262306a36Sopenharmony_ci	{ .compatible = "mediatek,mt2701-pwrap", .data = &pwrap_mt2701 },
245362306a36Sopenharmony_ci	{ .compatible = "mediatek,mt6765-pwrap", .data = &pwrap_mt6765 },
245462306a36Sopenharmony_ci	{ .compatible = "mediatek,mt6779-pwrap", .data = &pwrap_mt6779 },
245562306a36Sopenharmony_ci	{ .compatible = "mediatek,mt6795-pwrap", .data = &pwrap_mt6795 },
245662306a36Sopenharmony_ci	{ .compatible = "mediatek,mt6797-pwrap", .data = &pwrap_mt6797 },
245762306a36Sopenharmony_ci	{ .compatible = "mediatek,mt6873-pwrap", .data = &pwrap_mt6873 },
245862306a36Sopenharmony_ci	{ .compatible = "mediatek,mt7622-pwrap", .data = &pwrap_mt7622 },
245962306a36Sopenharmony_ci	{ .compatible = "mediatek,mt8135-pwrap", .data = &pwrap_mt8135 },
246062306a36Sopenharmony_ci	{ .compatible = "mediatek,mt8173-pwrap", .data = &pwrap_mt8173 },
246162306a36Sopenharmony_ci	{ .compatible = "mediatek,mt8183-pwrap", .data = &pwrap_mt8183 },
246262306a36Sopenharmony_ci	{ .compatible = "mediatek,mt8186-pwrap", .data = &pwrap_mt8186 },
246362306a36Sopenharmony_ci	{ .compatible = "mediatek,mt8195-pwrap", .data = &pwrap_mt8195 },
246462306a36Sopenharmony_ci	{ .compatible = "mediatek,mt8365-pwrap", .data = &pwrap_mt8365 },
246562306a36Sopenharmony_ci	{ .compatible = "mediatek,mt8516-pwrap", .data = &pwrap_mt8516 },
246662306a36Sopenharmony_ci	{ /* sentinel */ }
246762306a36Sopenharmony_ci};
246862306a36Sopenharmony_ciMODULE_DEVICE_TABLE(of, of_pwrap_match_tbl);
246962306a36Sopenharmony_ci
247062306a36Sopenharmony_cistatic int pwrap_probe(struct platform_device *pdev)
247162306a36Sopenharmony_ci{
247262306a36Sopenharmony_ci	int ret, irq;
247362306a36Sopenharmony_ci	u32 mask_done;
247462306a36Sopenharmony_ci	struct pmic_wrapper *wrp;
247562306a36Sopenharmony_ci	struct device_node *np = pdev->dev.of_node;
247662306a36Sopenharmony_ci	const struct of_device_id *of_slave_id = NULL;
247762306a36Sopenharmony_ci
247862306a36Sopenharmony_ci	if (np->child)
247962306a36Sopenharmony_ci		of_slave_id = of_match_node(of_slave_match_tbl, np->child);
248062306a36Sopenharmony_ci
248162306a36Sopenharmony_ci	if (!of_slave_id) {
248262306a36Sopenharmony_ci		dev_dbg(&pdev->dev, "slave pmic should be defined in dts\n");
248362306a36Sopenharmony_ci		return -EINVAL;
248462306a36Sopenharmony_ci	}
248562306a36Sopenharmony_ci
248662306a36Sopenharmony_ci	wrp = devm_kzalloc(&pdev->dev, sizeof(*wrp), GFP_KERNEL);
248762306a36Sopenharmony_ci	if (!wrp)
248862306a36Sopenharmony_ci		return -ENOMEM;
248962306a36Sopenharmony_ci
249062306a36Sopenharmony_ci	platform_set_drvdata(pdev, wrp);
249162306a36Sopenharmony_ci
249262306a36Sopenharmony_ci	wrp->master = of_device_get_match_data(&pdev->dev);
249362306a36Sopenharmony_ci	wrp->slave = of_slave_id->data;
249462306a36Sopenharmony_ci	wrp->dev = &pdev->dev;
249562306a36Sopenharmony_ci
249662306a36Sopenharmony_ci	wrp->base = devm_platform_ioremap_resource_byname(pdev, "pwrap");
249762306a36Sopenharmony_ci	if (IS_ERR(wrp->base))
249862306a36Sopenharmony_ci		return PTR_ERR(wrp->base);
249962306a36Sopenharmony_ci
250062306a36Sopenharmony_ci	if (HAS_CAP(wrp->master->caps, PWRAP_CAP_RESET)) {
250162306a36Sopenharmony_ci		wrp->rstc = devm_reset_control_get(wrp->dev, "pwrap");
250262306a36Sopenharmony_ci		if (IS_ERR(wrp->rstc)) {
250362306a36Sopenharmony_ci			ret = PTR_ERR(wrp->rstc);
250462306a36Sopenharmony_ci			dev_dbg(wrp->dev, "cannot get pwrap reset: %d\n", ret);
250562306a36Sopenharmony_ci			return ret;
250662306a36Sopenharmony_ci		}
250762306a36Sopenharmony_ci	}
250862306a36Sopenharmony_ci
250962306a36Sopenharmony_ci	if (HAS_CAP(wrp->master->caps, PWRAP_CAP_BRIDGE)) {
251062306a36Sopenharmony_ci		wrp->bridge_base = devm_platform_ioremap_resource_byname(pdev, "pwrap-bridge");
251162306a36Sopenharmony_ci		if (IS_ERR(wrp->bridge_base))
251262306a36Sopenharmony_ci			return PTR_ERR(wrp->bridge_base);
251362306a36Sopenharmony_ci
251462306a36Sopenharmony_ci		wrp->rstc_bridge = devm_reset_control_get(wrp->dev,
251562306a36Sopenharmony_ci							  "pwrap-bridge");
251662306a36Sopenharmony_ci		if (IS_ERR(wrp->rstc_bridge)) {
251762306a36Sopenharmony_ci			ret = PTR_ERR(wrp->rstc_bridge);
251862306a36Sopenharmony_ci			dev_dbg(wrp->dev,
251962306a36Sopenharmony_ci				"cannot get pwrap-bridge reset: %d\n", ret);
252062306a36Sopenharmony_ci			return ret;
252162306a36Sopenharmony_ci		}
252262306a36Sopenharmony_ci	}
252362306a36Sopenharmony_ci
252462306a36Sopenharmony_ci	wrp->clk_spi = devm_clk_get(wrp->dev, "spi");
252562306a36Sopenharmony_ci	if (IS_ERR(wrp->clk_spi)) {
252662306a36Sopenharmony_ci		dev_dbg(wrp->dev, "failed to get clock: %ld\n",
252762306a36Sopenharmony_ci			PTR_ERR(wrp->clk_spi));
252862306a36Sopenharmony_ci		return PTR_ERR(wrp->clk_spi);
252962306a36Sopenharmony_ci	}
253062306a36Sopenharmony_ci
253162306a36Sopenharmony_ci	wrp->clk_wrap = devm_clk_get(wrp->dev, "wrap");
253262306a36Sopenharmony_ci	if (IS_ERR(wrp->clk_wrap)) {
253362306a36Sopenharmony_ci		dev_dbg(wrp->dev, "failed to get clock: %ld\n",
253462306a36Sopenharmony_ci			PTR_ERR(wrp->clk_wrap));
253562306a36Sopenharmony_ci		return PTR_ERR(wrp->clk_wrap);
253662306a36Sopenharmony_ci	}
253762306a36Sopenharmony_ci
253862306a36Sopenharmony_ci	wrp->clk_sys = devm_clk_get_optional(wrp->dev, "sys");
253962306a36Sopenharmony_ci	if (IS_ERR(wrp->clk_sys)) {
254062306a36Sopenharmony_ci		return dev_err_probe(wrp->dev, PTR_ERR(wrp->clk_sys),
254162306a36Sopenharmony_ci				     "failed to get clock: %pe\n",
254262306a36Sopenharmony_ci				     wrp->clk_sys);
254362306a36Sopenharmony_ci	}
254462306a36Sopenharmony_ci
254562306a36Sopenharmony_ci	wrp->clk_tmr = devm_clk_get_optional(wrp->dev, "tmr");
254662306a36Sopenharmony_ci	if (IS_ERR(wrp->clk_tmr)) {
254762306a36Sopenharmony_ci		return dev_err_probe(wrp->dev, PTR_ERR(wrp->clk_tmr),
254862306a36Sopenharmony_ci				     "failed to get clock: %pe\n",
254962306a36Sopenharmony_ci				     wrp->clk_tmr);
255062306a36Sopenharmony_ci	}
255162306a36Sopenharmony_ci
255262306a36Sopenharmony_ci	ret = clk_prepare_enable(wrp->clk_spi);
255362306a36Sopenharmony_ci	if (ret)
255462306a36Sopenharmony_ci		return ret;
255562306a36Sopenharmony_ci
255662306a36Sopenharmony_ci	ret = clk_prepare_enable(wrp->clk_wrap);
255762306a36Sopenharmony_ci	if (ret)
255862306a36Sopenharmony_ci		goto err_out1;
255962306a36Sopenharmony_ci
256062306a36Sopenharmony_ci	ret = clk_prepare_enable(wrp->clk_sys);
256162306a36Sopenharmony_ci	if (ret)
256262306a36Sopenharmony_ci		goto err_out2;
256362306a36Sopenharmony_ci
256462306a36Sopenharmony_ci	ret = clk_prepare_enable(wrp->clk_tmr);
256562306a36Sopenharmony_ci	if (ret)
256662306a36Sopenharmony_ci		goto err_out3;
256762306a36Sopenharmony_ci
256862306a36Sopenharmony_ci	/* Enable internal dynamic clock */
256962306a36Sopenharmony_ci	if (HAS_CAP(wrp->master->caps, PWRAP_CAP_DCM)) {
257062306a36Sopenharmony_ci		pwrap_writel(wrp, 1, PWRAP_DCM_EN);
257162306a36Sopenharmony_ci		pwrap_writel(wrp, 0, PWRAP_DCM_DBC_PRD);
257262306a36Sopenharmony_ci	}
257362306a36Sopenharmony_ci
257462306a36Sopenharmony_ci	/*
257562306a36Sopenharmony_ci	 * The PMIC could already be initialized by the bootloader.
257662306a36Sopenharmony_ci	 * Skip initialization here in this case.
257762306a36Sopenharmony_ci	 */
257862306a36Sopenharmony_ci	if (!pwrap_readl(wrp, PWRAP_INIT_DONE2)) {
257962306a36Sopenharmony_ci		ret = pwrap_init(wrp);
258062306a36Sopenharmony_ci		if (ret) {
258162306a36Sopenharmony_ci			dev_dbg(wrp->dev, "init failed with %d\n", ret);
258262306a36Sopenharmony_ci			goto err_out4;
258362306a36Sopenharmony_ci		}
258462306a36Sopenharmony_ci	}
258562306a36Sopenharmony_ci
258662306a36Sopenharmony_ci	if (HAS_CAP(wrp->master->caps, PWRAP_CAP_ARB))
258762306a36Sopenharmony_ci		mask_done = PWRAP_STATE_INIT_DONE1;
258862306a36Sopenharmony_ci	else if (HAS_CAP(wrp->master->caps, PWRAP_CAP_ARB_MT8186))
258962306a36Sopenharmony_ci		mask_done = PWRAP_STATE_INIT_DONE0_MT8186;
259062306a36Sopenharmony_ci	else
259162306a36Sopenharmony_ci		mask_done = PWRAP_STATE_INIT_DONE0;
259262306a36Sopenharmony_ci
259362306a36Sopenharmony_ci	if (!(pwrap_readl(wrp, PWRAP_WACS2_RDATA) & mask_done)) {
259462306a36Sopenharmony_ci		dev_dbg(wrp->dev, "initialization isn't finished\n");
259562306a36Sopenharmony_ci		ret = -ENODEV;
259662306a36Sopenharmony_ci		goto err_out4;
259762306a36Sopenharmony_ci	}
259862306a36Sopenharmony_ci
259962306a36Sopenharmony_ci	/* Initialize watchdog, may not be done by the bootloader */
260062306a36Sopenharmony_ci	if (!HAS_CAP(wrp->master->caps, PWRAP_CAP_ARB))
260162306a36Sopenharmony_ci		pwrap_writel(wrp, 0xf, PWRAP_WDT_UNIT);
260262306a36Sopenharmony_ci
260362306a36Sopenharmony_ci	/*
260462306a36Sopenharmony_ci	 * Since STAUPD was not used on mt8173 platform,
260562306a36Sopenharmony_ci	 * so STAUPD of WDT_SRC which should be turned off
260662306a36Sopenharmony_ci	 */
260762306a36Sopenharmony_ci	pwrap_writel(wrp, wrp->master->wdt_src, PWRAP_WDT_SRC_EN);
260862306a36Sopenharmony_ci	if (HAS_CAP(wrp->master->caps, PWRAP_CAP_WDT_SRC1))
260962306a36Sopenharmony_ci		pwrap_writel(wrp, wrp->master->wdt_src, PWRAP_WDT_SRC_EN_1);
261062306a36Sopenharmony_ci
261162306a36Sopenharmony_ci	if (HAS_CAP(wrp->master->caps, PWRAP_CAP_ARB))
261262306a36Sopenharmony_ci		pwrap_writel(wrp, 0x3, PWRAP_TIMER_EN);
261362306a36Sopenharmony_ci	else
261462306a36Sopenharmony_ci		pwrap_writel(wrp, 0x1, PWRAP_TIMER_EN);
261562306a36Sopenharmony_ci
261662306a36Sopenharmony_ci	pwrap_writel(wrp, wrp->master->int_en_all, PWRAP_INT_EN);
261762306a36Sopenharmony_ci	/*
261862306a36Sopenharmony_ci	 * We add INT1 interrupt to handle starvation and request exception
261962306a36Sopenharmony_ci	 * If we support it, we should enable it here.
262062306a36Sopenharmony_ci	 */
262162306a36Sopenharmony_ci	if (HAS_CAP(wrp->master->caps, PWRAP_CAP_INT1_EN))
262262306a36Sopenharmony_ci		pwrap_writel(wrp, wrp->master->int1_en_all, PWRAP_INT1_EN);
262362306a36Sopenharmony_ci
262462306a36Sopenharmony_ci	irq = platform_get_irq(pdev, 0);
262562306a36Sopenharmony_ci	if (irq < 0) {
262662306a36Sopenharmony_ci		ret = irq;
262762306a36Sopenharmony_ci		goto err_out2;
262862306a36Sopenharmony_ci	}
262962306a36Sopenharmony_ci
263062306a36Sopenharmony_ci	ret = devm_request_irq(wrp->dev, irq, pwrap_interrupt,
263162306a36Sopenharmony_ci			       IRQF_TRIGGER_HIGH,
263262306a36Sopenharmony_ci			       "mt-pmic-pwrap", wrp);
263362306a36Sopenharmony_ci	if (ret)
263462306a36Sopenharmony_ci		goto err_out4;
263562306a36Sopenharmony_ci
263662306a36Sopenharmony_ci	wrp->regmap = devm_regmap_init(wrp->dev, NULL, wrp, wrp->slave->regops->regmap);
263762306a36Sopenharmony_ci	if (IS_ERR(wrp->regmap)) {
263862306a36Sopenharmony_ci		ret = PTR_ERR(wrp->regmap);
263962306a36Sopenharmony_ci		goto err_out2;
264062306a36Sopenharmony_ci	}
264162306a36Sopenharmony_ci
264262306a36Sopenharmony_ci	ret = of_platform_populate(np, NULL, NULL, wrp->dev);
264362306a36Sopenharmony_ci	if (ret) {
264462306a36Sopenharmony_ci		dev_dbg(wrp->dev, "failed to create child devices at %pOF\n",
264562306a36Sopenharmony_ci				np);
264662306a36Sopenharmony_ci		goto err_out4;
264762306a36Sopenharmony_ci	}
264862306a36Sopenharmony_ci
264962306a36Sopenharmony_ci	return 0;
265062306a36Sopenharmony_ci
265162306a36Sopenharmony_cierr_out4:
265262306a36Sopenharmony_ci	clk_disable_unprepare(wrp->clk_tmr);
265362306a36Sopenharmony_cierr_out3:
265462306a36Sopenharmony_ci	clk_disable_unprepare(wrp->clk_sys);
265562306a36Sopenharmony_cierr_out2:
265662306a36Sopenharmony_ci	clk_disable_unprepare(wrp->clk_wrap);
265762306a36Sopenharmony_cierr_out1:
265862306a36Sopenharmony_ci	clk_disable_unprepare(wrp->clk_spi);
265962306a36Sopenharmony_ci
266062306a36Sopenharmony_ci	return ret;
266162306a36Sopenharmony_ci}
266262306a36Sopenharmony_ci
266362306a36Sopenharmony_cistatic struct platform_driver pwrap_drv = {
266462306a36Sopenharmony_ci	.driver = {
266562306a36Sopenharmony_ci		.name = "mt-pmic-pwrap",
266662306a36Sopenharmony_ci		.of_match_table = of_pwrap_match_tbl,
266762306a36Sopenharmony_ci	},
266862306a36Sopenharmony_ci	.probe = pwrap_probe,
266962306a36Sopenharmony_ci};
267062306a36Sopenharmony_ci
267162306a36Sopenharmony_cimodule_platform_driver(pwrap_drv);
267262306a36Sopenharmony_ci
267362306a36Sopenharmony_ciMODULE_AUTHOR("Flora Fu, MediaTek");
267462306a36Sopenharmony_ciMODULE_DESCRIPTION("MediaTek MT8135 PMIC Wrapper Driver");
267562306a36Sopenharmony_ciMODULE_LICENSE("GPL v2");
2676