1 #ifndef __TI_SYSC_DATA_H__
2 #define __TI_SYSC_DATA_H__
3 
4 enum ti_sysc_module_type {
5 	TI_SYSC_OMAP2,
6 	TI_SYSC_OMAP2_TIMER,
7 	TI_SYSC_OMAP3_SHAM,
8 	TI_SYSC_OMAP3_AES,
9 	TI_SYSC_OMAP4,
10 	TI_SYSC_OMAP4_TIMER,
11 	TI_SYSC_OMAP4_SIMPLE,
12 	TI_SYSC_OMAP34XX_SR,
13 	TI_SYSC_OMAP36XX_SR,
14 	TI_SYSC_OMAP4_SR,
15 	TI_SYSC_OMAP4_MCASP,
16 	TI_SYSC_OMAP4_USB_HOST_FS,
17 	TI_SYSC_DRA7_MCAN,
18 };
19 
20 struct ti_sysc_cookie {
21 	void *data;
22 	void *clkdm;
23 };
24 
25 /**
26  * struct sysc_regbits - TI OCP_SYSCONFIG register field offsets
27  * @midle_shift: Offset of the midle bit
28  * @clkact_shift: Offset of the clockactivity bit
29  * @sidle_shift: Offset of the sidle bit
30  * @enwkup_shift: Offset of the enawakeup bit
31  * @srst_shift: Offset of the softreset bit
32  * @autoidle_shift: Offset of the autoidle bit
33  * @dmadisable_shift: Offset of the dmadisable bit
34  * @emufree_shift; Offset of the emufree bit
35  *
36  * Note that 0 is a valid shift, and for ti-sysc.c -ENODEV can be used if a
37  * feature is not available.
38  */
39 struct sysc_regbits {
40 	s8 midle_shift;
41 	s8 clkact_shift;
42 	s8 sidle_shift;
43 	s8 enwkup_shift;
44 	s8 srst_shift;
45 	s8 autoidle_shift;
46 	s8 dmadisable_shift;
47 	s8 emufree_shift;
48 };
49 
50 #define SYSC_QUIRK_SWSUP_MSTANDBY	BIT(13)
51 #define SYSC_QUIRK_SWSUP_SIDLE_ACT	BIT(12)
52 #define SYSC_QUIRK_SWSUP_SIDLE		BIT(11)
53 #define SYSC_QUIRK_EXT_OPT_CLOCK	BIT(10)
54 #define SYSC_QUIRK_LEGACY_IDLE		BIT(9)
55 #define SYSC_QUIRK_RESET_STATUS		BIT(8)
56 #define SYSC_QUIRK_NO_IDLE		BIT(7)
57 #define SYSC_QUIRK_NO_IDLE_ON_INIT	BIT(6)
58 #define SYSC_QUIRK_NO_RESET_ON_INIT	BIT(5)
59 #define SYSC_QUIRK_OPT_CLKS_NEEDED	BIT(4)
60 #define SYSC_QUIRK_OPT_CLKS_IN_RESET	BIT(3)
61 #define SYSC_QUIRK_16BIT		BIT(2)
62 #define SYSC_QUIRK_UNCACHED		BIT(1)
63 #define SYSC_QUIRK_USE_CLOCKACT		BIT(0)
64 
65 #define SYSC_NR_IDLEMODES		4
66 
67 /**
68  * struct sysc_capabilities - capabilities for an interconnect target module
69  *
70  * @sysc_mask: bitmask of supported SYSCONFIG register bits
71  * @regbits: bitmask of SYSCONFIG register bits
72  * @mod_quirks: bitmask of module specific quirks
73  */
74 struct sysc_capabilities {
75 	const enum ti_sysc_module_type type;
76 	const u32 sysc_mask;
77 	const struct sysc_regbits *regbits;
78 	const u32 mod_quirks;
79 };
80 
81 /**
82  * struct sysc_config - configuration for an interconnect target module
83  * @sysc_val: configured value for sysc register
84  * @midlemodes: bitmask of supported master idle modes
85  * @sidlemodes: bitmask of supported master idle modes
86  * @srst_udelay: optional delay needed after OCP soft reset
87  * @quirks: bitmask of enabled quirks
88  */
89 struct sysc_config {
90 	u32 sysc_val;
91 	u32 syss_mask;
92 	u8 midlemodes;
93 	u8 sidlemodes;
94 	u8 srst_udelay;
95 	u32 quirks;
96 };
97 
98 enum sysc_registers {
99 	SYSC_REVISION,
100 	SYSC_SYSCONFIG,
101 	SYSC_SYSSTATUS,
102 	SYSC_MAX_REGS,
103 };
104 
105 /**
106  * struct ti_sysc_module_data - ti-sysc to hwmod translation data for a module
107  * @name: legacy "ti,hwmods" module name
108  * @module_pa: physical address of the interconnect target module
109  * @module_size: size of the interconnect target module
110  * @offsets: array of register offsets as listed in enum sysc_registers
111  * @nr_offsets: number of registers
112  * @cap: interconnect target module capabilities
113  * @cfg: interconnect target module configuration
114  *
115  * This data is enough to allocate a new struct omap_hwmod_class_sysconfig
116  * based on device tree data parsed by ti-sysc driver.
117  */
118 struct ti_sysc_module_data {
119 	const char *name;
120 	u64 module_pa;
121 	u32 module_size;
122 	int *offsets;
123 	int nr_offsets;
124 	const struct sysc_capabilities *cap;
125 	struct sysc_config *cfg;
126 };
127 
128 struct device;
129 struct clk;
130 
131 struct ti_sysc_platform_data {
132 	struct of_dev_auxdata *auxdata;
133 	int (*init_clockdomain)(struct device *dev, struct clk *fck,
134 				struct clk *ick, struct ti_sysc_cookie *cookie);
135 	void (*clkdm_deny_idle)(struct device *dev,
136 				const struct ti_sysc_cookie *cookie);
137 	void (*clkdm_allow_idle)(struct device *dev,
138 				 const struct ti_sysc_cookie *cookie);
139 	int (*init_module)(struct device *dev,
140 			   const struct ti_sysc_module_data *data,
141 			   struct ti_sysc_cookie *cookie);
142 	int (*enable_module)(struct device *dev,
143 			     const struct ti_sysc_cookie *cookie);
144 	int (*idle_module)(struct device *dev,
145 			   const struct ti_sysc_cookie *cookie);
146 	int (*shutdown_module)(struct device *dev,
147 			       const struct ti_sysc_cookie *cookie);
148 };
149 
150 #endif	/* __TI_SYSC_DATA_H__ */
151