xref: /linux/include/linux/platform_data/ti-sysc.h (revision e275d2109cdaea8b4554b9eb8a828bdb8f8ba068)
154d66222SSuman Anna /* SPDX-License-Identifier: GPL-2.0 */
254d66222SSuman Anna 
349a0a3d8STony Lindgren #ifndef __TI_SYSC_DATA_H__
449a0a3d8STony Lindgren #define __TI_SYSC_DATA_H__
549a0a3d8STony Lindgren 
670a65240STony Lindgren enum ti_sysc_module_type {
770a65240STony Lindgren 	TI_SYSC_OMAP2,
870a65240STony Lindgren 	TI_SYSC_OMAP2_TIMER,
970a65240STony Lindgren 	TI_SYSC_OMAP3_SHAM,
1070a65240STony Lindgren 	TI_SYSC_OMAP3_AES,
1170a65240STony Lindgren 	TI_SYSC_OMAP4,
1270a65240STony Lindgren 	TI_SYSC_OMAP4_TIMER,
1370a65240STony Lindgren 	TI_SYSC_OMAP4_SIMPLE,
1470a65240STony Lindgren 	TI_SYSC_OMAP34XX_SR,
1570a65240STony Lindgren 	TI_SYSC_OMAP36XX_SR,
1670a65240STony Lindgren 	TI_SYSC_OMAP4_SR,
1770a65240STony Lindgren 	TI_SYSC_OMAP4_MCASP,
1870a65240STony Lindgren 	TI_SYSC_OMAP4_USB_HOST_FS,
197f35e63dSFaiz Abbas 	TI_SYSC_DRA7_MCAN,
20b2745d92SSuman Anna 	TI_SYSC_PRUSS,
2170a65240STony Lindgren };
2270a65240STony Lindgren 
23ef70b0bdSTony Lindgren struct ti_sysc_cookie {
24ef70b0bdSTony Lindgren 	void *data;
252b2f7defSTony Lindgren 	void *clkdm;
26ef70b0bdSTony Lindgren };
27ef70b0bdSTony Lindgren 
2849a0a3d8STony Lindgren /**
2949a0a3d8STony Lindgren  * struct sysc_regbits - TI OCP_SYSCONFIG register field offsets
3049a0a3d8STony Lindgren  * @midle_shift: Offset of the midle bit
3149a0a3d8STony Lindgren  * @clkact_shift: Offset of the clockactivity bit
3249a0a3d8STony Lindgren  * @sidle_shift: Offset of the sidle bit
3349a0a3d8STony Lindgren  * @enwkup_shift: Offset of the enawakeup bit
3449a0a3d8STony Lindgren  * @srst_shift: Offset of the softreset bit
3549a0a3d8STony Lindgren  * @autoidle_shift: Offset of the autoidle bit
3649a0a3d8STony Lindgren  * @dmadisable_shift: Offset of the dmadisable bit
3749a0a3d8STony Lindgren  * @emufree_shift; Offset of the emufree bit
3849a0a3d8STony Lindgren  *
3949a0a3d8STony Lindgren  * Note that 0 is a valid shift, and for ti-sysc.c -ENODEV can be used if a
4049a0a3d8STony Lindgren  * feature is not available.
4149a0a3d8STony Lindgren  */
4249a0a3d8STony Lindgren struct sysc_regbits {
4349a0a3d8STony Lindgren 	s8 midle_shift;
4449a0a3d8STony Lindgren 	s8 clkact_shift;
4549a0a3d8STony Lindgren 	s8 sidle_shift;
4649a0a3d8STony Lindgren 	s8 enwkup_shift;
4749a0a3d8STony Lindgren 	s8 srst_shift;
4849a0a3d8STony Lindgren 	s8 autoidle_shift;
4949a0a3d8STony Lindgren 	s8 dmadisable_shift;
5049a0a3d8STony Lindgren 	s8 emufree_shift;
5149a0a3d8STony Lindgren };
5249a0a3d8STony Lindgren 
53*e275d210STony Lindgren #define SYSC_MODULE_QUIRK_ENA_RESETDONE	BIT(25)
54b2745d92SSuman Anna #define SYSC_MODULE_QUIRK_PRUSS		BIT(24)
557324a7a0STony Lindgren #define SYSC_MODULE_QUIRK_DSS_RESET	BIT(23)
56e8639e1cSTony Lindgren #define SYSC_MODULE_QUIRK_RTC_UNLOCK	BIT(22)
5794f63457STony Lindgren #define SYSC_QUIRK_CLKDM_NOAUTO		BIT(21)
5893c60483STony Lindgren #define SYSC_QUIRK_FORCE_MSTANDBY	BIT(20)
59020003f7STony Lindgren #define SYSC_MODULE_QUIRK_AESS		BIT(19)
60d7f563dbSTony Lindgren #define SYSC_MODULE_QUIRK_SGX		BIT(18)
614e23be47STony Lindgren #define SYSC_MODULE_QUIRK_HDQ1W		BIT(17)
624e23be47STony Lindgren #define SYSC_MODULE_QUIRK_I2C		BIT(16)
634e23be47STony Lindgren #define SYSC_MODULE_QUIRK_WDT		BIT(15)
64e0db94feSTony Lindgren #define SYSS_QUIRK_RESETDONE_INVERTED	BIT(14)
65b4a9a7a3STony Lindgren #define SYSC_QUIRK_SWSUP_MSTANDBY	BIT(13)
66b4a9a7a3STony Lindgren #define SYSC_QUIRK_SWSUP_SIDLE_ACT	BIT(12)
67b4a9a7a3STony Lindgren #define SYSC_QUIRK_SWSUP_SIDLE		BIT(11)
68a54275f4STony Lindgren #define SYSC_QUIRK_EXT_OPT_CLOCK	BIT(10)
69386cb766STony Lindgren #define SYSC_QUIRK_LEGACY_IDLE		BIT(9)
70386cb766STony Lindgren #define SYSC_QUIRK_RESET_STATUS		BIT(8)
71386cb766STony Lindgren #define SYSC_QUIRK_NO_IDLE		BIT(7)
72566a9b05STony Lindgren #define SYSC_QUIRK_NO_IDLE_ON_INIT	BIT(6)
73566a9b05STony Lindgren #define SYSC_QUIRK_NO_RESET_ON_INIT	BIT(5)
74566a9b05STony Lindgren #define SYSC_QUIRK_OPT_CLKS_NEEDED	BIT(4)
75566a9b05STony Lindgren #define SYSC_QUIRK_OPT_CLKS_IN_RESET	BIT(3)
76a7199e2bSTony Lindgren #define SYSC_QUIRK_16BIT		BIT(2)
7770a65240STony Lindgren #define SYSC_QUIRK_UNCACHED		BIT(1)
7870a65240STony Lindgren #define SYSC_QUIRK_USE_CLOCKACT		BIT(0)
7970a65240STony Lindgren 
80c5a2de97STony Lindgren #define SYSC_NR_IDLEMODES		4
81c5a2de97STony Lindgren 
8270a65240STony Lindgren /**
8370a65240STony Lindgren  * struct sysc_capabilities - capabilities for an interconnect target module
84b58056daSSuman Anna  * @type: sysc type identifier for the module
8570a65240STony Lindgren  * @sysc_mask: bitmask of supported SYSCONFIG register bits
8670a65240STony Lindgren  * @regbits: bitmask of SYSCONFIG register bits
8770a65240STony Lindgren  * @mod_quirks: bitmask of module specific quirks
8870a65240STony Lindgren  */
8970a65240STony Lindgren struct sysc_capabilities {
9070a65240STony Lindgren 	const enum ti_sysc_module_type type;
9170a65240STony Lindgren 	const u32 sysc_mask;
9270a65240STony Lindgren 	const struct sysc_regbits *regbits;
9370a65240STony Lindgren 	const u32 mod_quirks;
9470a65240STony Lindgren };
9570a65240STony Lindgren 
9670a65240STony Lindgren /**
9770a65240STony Lindgren  * struct sysc_config - configuration for an interconnect target module
98c5a2de97STony Lindgren  * @sysc_val: configured value for sysc register
99b58056daSSuman Anna  * @syss_mask: configured mask value for SYSSTATUS register
100c5a2de97STony Lindgren  * @midlemodes: bitmask of supported master idle modes
101b58056daSSuman Anna  * @sidlemodes: bitmask of supported slave idle modes
102566a9b05STony Lindgren  * @srst_udelay: optional delay needed after OCP soft reset
10370a65240STony Lindgren  * @quirks: bitmask of enabled quirks
10470a65240STony Lindgren  */
10570a65240STony Lindgren struct sysc_config {
106c5a2de97STony Lindgren 	u32 sysc_val;
107c5a2de97STony Lindgren 	u32 syss_mask;
108c5a2de97STony Lindgren 	u8 midlemodes;
109c5a2de97STony Lindgren 	u8 sidlemodes;
110566a9b05STony Lindgren 	u8 srst_udelay;
11170a65240STony Lindgren 	u32 quirks;
11270a65240STony Lindgren };
11370a65240STony Lindgren 
114ef70b0bdSTony Lindgren enum sysc_registers {
115ef70b0bdSTony Lindgren 	SYSC_REVISION,
116ef70b0bdSTony Lindgren 	SYSC_SYSCONFIG,
117ef70b0bdSTony Lindgren 	SYSC_SYSSTATUS,
118ef70b0bdSTony Lindgren 	SYSC_MAX_REGS,
119ef70b0bdSTony Lindgren };
120ef70b0bdSTony Lindgren 
121ef70b0bdSTony Lindgren /**
122ef70b0bdSTony Lindgren  * struct ti_sysc_module_data - ti-sysc to hwmod translation data for a module
123ef70b0bdSTony Lindgren  * @name: legacy "ti,hwmods" module name
124ef70b0bdSTony Lindgren  * @module_pa: physical address of the interconnect target module
125ef70b0bdSTony Lindgren  * @module_size: size of the interconnect target module
126ef70b0bdSTony Lindgren  * @offsets: array of register offsets as listed in enum sysc_registers
127ef70b0bdSTony Lindgren  * @nr_offsets: number of registers
128ef70b0bdSTony Lindgren  * @cap: interconnect target module capabilities
129ef70b0bdSTony Lindgren  * @cfg: interconnect target module configuration
130ef70b0bdSTony Lindgren  *
131ef70b0bdSTony Lindgren  * This data is enough to allocate a new struct omap_hwmod_class_sysconfig
132ef70b0bdSTony Lindgren  * based on device tree data parsed by ti-sysc driver.
133ef70b0bdSTony Lindgren  */
134ef70b0bdSTony Lindgren struct ti_sysc_module_data {
135ef70b0bdSTony Lindgren 	const char *name;
136ef70b0bdSTony Lindgren 	u64 module_pa;
137ef70b0bdSTony Lindgren 	u32 module_size;
138ef70b0bdSTony Lindgren 	int *offsets;
139ef70b0bdSTony Lindgren 	int nr_offsets;
140ef70b0bdSTony Lindgren 	const struct sysc_capabilities *cap;
141ef70b0bdSTony Lindgren 	struct sysc_config *cfg;
142ef70b0bdSTony Lindgren };
143ef70b0bdSTony Lindgren 
144ef70b0bdSTony Lindgren struct device;
1452b2f7defSTony Lindgren struct clk;
146ef70b0bdSTony Lindgren 
147ef70b0bdSTony Lindgren struct ti_sysc_platform_data {
148ef70b0bdSTony Lindgren 	struct of_dev_auxdata *auxdata;
149feaa8baeSTony Lindgren 	bool (*soc_type_gp)(void);
1502b2f7defSTony Lindgren 	int (*init_clockdomain)(struct device *dev, struct clk *fck,
1512b2f7defSTony Lindgren 				struct clk *ick, struct ti_sysc_cookie *cookie);
1522b2f7defSTony Lindgren 	void (*clkdm_deny_idle)(struct device *dev,
1532b2f7defSTony Lindgren 				const struct ti_sysc_cookie *cookie);
1542b2f7defSTony Lindgren 	void (*clkdm_allow_idle)(struct device *dev,
1552b2f7defSTony Lindgren 				 const struct ti_sysc_cookie *cookie);
156ef70b0bdSTony Lindgren 	int (*init_module)(struct device *dev,
157ef70b0bdSTony Lindgren 			   const struct ti_sysc_module_data *data,
158ef70b0bdSTony Lindgren 			   struct ti_sysc_cookie *cookie);
159ef70b0bdSTony Lindgren 	int (*enable_module)(struct device *dev,
160ef70b0bdSTony Lindgren 			     const struct ti_sysc_cookie *cookie);
161ef70b0bdSTony Lindgren 	int (*idle_module)(struct device *dev,
162ef70b0bdSTony Lindgren 			   const struct ti_sysc_cookie *cookie);
163ef70b0bdSTony Lindgren 	int (*shutdown_module)(struct device *dev,
164ef70b0bdSTony Lindgren 			       const struct ti_sysc_cookie *cookie);
165ef70b0bdSTony Lindgren };
166ef70b0bdSTony Lindgren 
16749a0a3d8STony Lindgren #endif	/* __TI_SYSC_DATA_H__ */
168