162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */
262306a36Sopenharmony_ci
362306a36Sopenharmony_ci#ifndef __SOC_MEDIATEK_MTK_PM_DOMAINS_H
462306a36Sopenharmony_ci#define __SOC_MEDIATEK_MTK_PM_DOMAINS_H
562306a36Sopenharmony_ci
662306a36Sopenharmony_ci#define MTK_SCPD_ACTIVE_WAKEUP		BIT(0)
762306a36Sopenharmony_ci#define MTK_SCPD_FWAIT_SRAM		BIT(1)
862306a36Sopenharmony_ci#define MTK_SCPD_SRAM_ISO		BIT(2)
962306a36Sopenharmony_ci#define MTK_SCPD_KEEP_DEFAULT_OFF	BIT(3)
1062306a36Sopenharmony_ci#define MTK_SCPD_DOMAIN_SUPPLY		BIT(4)
1162306a36Sopenharmony_ci/* can't set MTK_SCPD_KEEP_DEFAULT_OFF at the same time */
1262306a36Sopenharmony_ci#define MTK_SCPD_ALWAYS_ON		BIT(5)
1362306a36Sopenharmony_ci#define MTK_SCPD_EXT_BUCK_ISO		BIT(6)
1462306a36Sopenharmony_ci#define MTK_SCPD_CAPS(_scpd, _x)	((_scpd)->data->caps & (_x))
1562306a36Sopenharmony_ci
1662306a36Sopenharmony_ci#define SPM_VDE_PWR_CON			0x0210
1762306a36Sopenharmony_ci#define SPM_MFG_PWR_CON			0x0214
1862306a36Sopenharmony_ci#define SPM_VEN_PWR_CON			0x0230
1962306a36Sopenharmony_ci#define SPM_ISP_PWR_CON			0x0238
2062306a36Sopenharmony_ci#define SPM_DIS_PWR_CON			0x023c
2162306a36Sopenharmony_ci#define SPM_CONN_PWR_CON		0x0280
2262306a36Sopenharmony_ci#define SPM_VEN2_PWR_CON		0x0298
2362306a36Sopenharmony_ci#define SPM_AUDIO_PWR_CON		0x029c
2462306a36Sopenharmony_ci#define SPM_MFG_2D_PWR_CON		0x02c0
2562306a36Sopenharmony_ci#define SPM_MFG_ASYNC_PWR_CON		0x02c4
2662306a36Sopenharmony_ci#define SPM_USB_PWR_CON			0x02cc
2762306a36Sopenharmony_ci
2862306a36Sopenharmony_ci#define SPM_PWR_STATUS			0x060c
2962306a36Sopenharmony_ci#define SPM_PWR_STATUS_2ND		0x0610
3062306a36Sopenharmony_ci
3162306a36Sopenharmony_ci#define PWR_STATUS_CONN			BIT(1)
3262306a36Sopenharmony_ci#define PWR_STATUS_DISP			BIT(3)
3362306a36Sopenharmony_ci#define PWR_STATUS_MFG			BIT(4)
3462306a36Sopenharmony_ci#define PWR_STATUS_ISP			BIT(5)
3562306a36Sopenharmony_ci#define PWR_STATUS_VDEC			BIT(7)
3662306a36Sopenharmony_ci#define PWR_STATUS_VENC_LT		BIT(20)
3762306a36Sopenharmony_ci#define PWR_STATUS_VENC			BIT(21)
3862306a36Sopenharmony_ci#define PWR_STATUS_MFG_2D		BIT(22)
3962306a36Sopenharmony_ci#define PWR_STATUS_MFG_ASYNC		BIT(23)
4062306a36Sopenharmony_ci#define PWR_STATUS_AUDIO		BIT(24)
4162306a36Sopenharmony_ci#define PWR_STATUS_USB			BIT(25)
4262306a36Sopenharmony_ci
4362306a36Sopenharmony_ci#define SPM_MAX_BUS_PROT_DATA		6
4462306a36Sopenharmony_ci
4562306a36Sopenharmony_ci#define _BUS_PROT(_mask, _set, _clr, _sta, _update, _ignore) {	\
4662306a36Sopenharmony_ci		.bus_prot_mask = (_mask),			\
4762306a36Sopenharmony_ci		.bus_prot_set = _set,				\
4862306a36Sopenharmony_ci		.bus_prot_clr = _clr,				\
4962306a36Sopenharmony_ci		.bus_prot_sta = _sta,				\
5062306a36Sopenharmony_ci		.bus_prot_reg_update = _update,			\
5162306a36Sopenharmony_ci		.ignore_clr_ack = _ignore,			\
5262306a36Sopenharmony_ci	}
5362306a36Sopenharmony_ci
5462306a36Sopenharmony_ci#define BUS_PROT_WR(_mask, _set, _clr, _sta)			\
5562306a36Sopenharmony_ci		_BUS_PROT(_mask, _set, _clr, _sta, false, false)
5662306a36Sopenharmony_ci
5762306a36Sopenharmony_ci#define BUS_PROT_WR_IGN(_mask, _set, _clr, _sta)		\
5862306a36Sopenharmony_ci		_BUS_PROT(_mask, _set, _clr, _sta, false, true)
5962306a36Sopenharmony_ci
6062306a36Sopenharmony_ci#define BUS_PROT_UPDATE(_mask, _set, _clr, _sta)		\
6162306a36Sopenharmony_ci		_BUS_PROT(_mask, _set, _clr, _sta, true, false)
6262306a36Sopenharmony_ci
6362306a36Sopenharmony_ci#define BUS_PROT_UPDATE_TOPAXI(_mask)				\
6462306a36Sopenharmony_ci		BUS_PROT_UPDATE(_mask,				\
6562306a36Sopenharmony_ci				INFRA_TOPAXI_PROTECTEN,		\
6662306a36Sopenharmony_ci				INFRA_TOPAXI_PROTECTEN,		\
6762306a36Sopenharmony_ci				INFRA_TOPAXI_PROTECTSTA1)
6862306a36Sopenharmony_ci
6962306a36Sopenharmony_cistruct scpsys_bus_prot_data {
7062306a36Sopenharmony_ci	u32 bus_prot_mask;
7162306a36Sopenharmony_ci	u32 bus_prot_set;
7262306a36Sopenharmony_ci	u32 bus_prot_clr;
7362306a36Sopenharmony_ci	u32 bus_prot_sta;
7462306a36Sopenharmony_ci	bool bus_prot_reg_update;
7562306a36Sopenharmony_ci	bool ignore_clr_ack;
7662306a36Sopenharmony_ci};
7762306a36Sopenharmony_ci
7862306a36Sopenharmony_ci/**
7962306a36Sopenharmony_ci * struct scpsys_domain_data - scp domain data for power on/off flow
8062306a36Sopenharmony_ci * @name: The name of the power domain.
8162306a36Sopenharmony_ci * @sta_mask: The mask for power on/off status bit.
8262306a36Sopenharmony_ci * @ctl_offs: The offset for main power control register.
8362306a36Sopenharmony_ci * @sram_pdn_bits: The mask for sram power control bits.
8462306a36Sopenharmony_ci * @sram_pdn_ack_bits: The mask for sram power control acked bits.
8562306a36Sopenharmony_ci * @ext_buck_iso_offs: The offset for external buck isolation
8662306a36Sopenharmony_ci * @ext_buck_iso_mask: The mask for external buck isolation
8762306a36Sopenharmony_ci * @caps: The flag for active wake-up action.
8862306a36Sopenharmony_ci * @bp_infracfg: bus protection for infracfg subsystem
8962306a36Sopenharmony_ci * @bp_smi: bus protection for smi subsystem
9062306a36Sopenharmony_ci */
9162306a36Sopenharmony_cistruct scpsys_domain_data {
9262306a36Sopenharmony_ci	const char *name;
9362306a36Sopenharmony_ci	u32 sta_mask;
9462306a36Sopenharmony_ci	int ctl_offs;
9562306a36Sopenharmony_ci	u32 sram_pdn_bits;
9662306a36Sopenharmony_ci	u32 sram_pdn_ack_bits;
9762306a36Sopenharmony_ci	int ext_buck_iso_offs;
9862306a36Sopenharmony_ci	u32 ext_buck_iso_mask;
9962306a36Sopenharmony_ci	u8 caps;
10062306a36Sopenharmony_ci	const struct scpsys_bus_prot_data bp_infracfg[SPM_MAX_BUS_PROT_DATA];
10162306a36Sopenharmony_ci	const struct scpsys_bus_prot_data bp_smi[SPM_MAX_BUS_PROT_DATA];
10262306a36Sopenharmony_ci	int pwr_sta_offs;
10362306a36Sopenharmony_ci	int pwr_sta2nd_offs;
10462306a36Sopenharmony_ci};
10562306a36Sopenharmony_ci
10662306a36Sopenharmony_cistruct scpsys_soc_data {
10762306a36Sopenharmony_ci	const struct scpsys_domain_data *domains_data;
10862306a36Sopenharmony_ci	int num_domains;
10962306a36Sopenharmony_ci};
11062306a36Sopenharmony_ci
11162306a36Sopenharmony_ci#endif /* __SOC_MEDIATEK_MTK_PM_DOMAINS_H */
112