xref: /linux/arch/arm/mach-pxa/mfp-pxa2xx.h (revision 4b132aacb0768ac1e652cf517097ea6f237214b9)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef __ASM_ARCH_MFP_PXA2XX_H
3 #define __ASM_ARCH_MFP_PXA2XX_H
4 
5 #include <linux/soc/pxa/mfp.h>
6 
7 /*
8  * the following MFP_xxx bit definitions in mfp.h are re-used for pxa2xx:
9  *
10  *  MFP_PIN(x)
11  *  MFP_AFx
12  *  MFP_LPM_DRIVE_{LOW, HIGH}
13  *  MFP_LPM_EDGE_x
14  *
15  * other MFP_x bit definitions will be ignored
16  *
17  * and adds the below two bits specifically for pxa2xx:
18  *
19  * bit     23 - Input/Output (PXA2xx specific)
20  * bit     24 - Wakeup Enable(PXA2xx specific)
21  * bit     25 - Keep Output  (PXA2xx specific)
22  */
23 
24 #define MFP_DIR_IN		(0x0 << 23)
25 #define MFP_DIR_OUT		(0x1 << 23)
26 #define MFP_DIR_MASK		(0x1 << 23)
27 #define MFP_DIR(x)		(((x) >> 23) & 0x1)
28 
29 #define MFP_LPM_CAN_WAKEUP	(0x1 << 24)
30 
31 /*
32  * MFP_LPM_KEEP_OUTPUT must be specified for pins that need to
33  * retain their last output level (low or high).
34  * Note: MFP_LPM_KEEP_OUTPUT has no effect on pins configured for input.
35  */
36 #define MFP_LPM_KEEP_OUTPUT	(0x1 << 25)
37 
38 #define WAKEUP_ON_EDGE_RISE	(MFP_LPM_CAN_WAKEUP | MFP_LPM_EDGE_RISE)
39 #define WAKEUP_ON_EDGE_FALL	(MFP_LPM_CAN_WAKEUP | MFP_LPM_EDGE_FALL)
40 #define WAKEUP_ON_EDGE_BOTH	(MFP_LPM_CAN_WAKEUP | MFP_LPM_EDGE_BOTH)
41 
42 /* specifically for enabling wakeup on keypad GPIOs */
43 #define WAKEUP_ON_LEVEL_HIGH	(MFP_LPM_CAN_WAKEUP)
44 
45 #define MFP_CFG_IN(pin, af)		\
46 	((MFP_CFG_DEFAULT & ~(MFP_AF_MASK | MFP_DIR_MASK)) |\
47 	 (MFP_PIN(MFP_PIN_##pin) | MFP_##af | MFP_DIR_IN))
48 
49 /* NOTE:  pins configured as output _must_ provide a low power state,
50  * and this state should help to minimize the power dissipation.
51  */
52 #define MFP_CFG_OUT(pin, af, state)	\
53 	((MFP_CFG_DEFAULT & ~(MFP_AF_MASK | MFP_DIR_MASK | MFP_LPM_STATE_MASK)) |\
54 	 (MFP_PIN(MFP_PIN_##pin) | MFP_##af | MFP_DIR_OUT | MFP_LPM_##state))
55 
56 /* Common configurations for pxa25x and pxa27x
57  *
58  * Note: pins configured as GPIO are always initialized to input
59  * so not to cause any side effect
60  */
61 #define GPIO0_GPIO	MFP_CFG_IN(GPIO0, AF0)
62 #define GPIO1_GPIO	MFP_CFG_IN(GPIO1, AF0)
63 #define GPIO9_GPIO	MFP_CFG_IN(GPIO9, AF0)
64 #define GPIO10_GPIO	MFP_CFG_IN(GPIO10, AF0)
65 #define GPIO11_GPIO	MFP_CFG_IN(GPIO11, AF0)
66 #define GPIO12_GPIO	MFP_CFG_IN(GPIO12, AF0)
67 #define GPIO13_GPIO	MFP_CFG_IN(GPIO13, AF0)
68 #define GPIO14_GPIO	MFP_CFG_IN(GPIO14, AF0)
69 #define GPIO15_GPIO	MFP_CFG_IN(GPIO15, AF0)
70 #define GPIO16_GPIO	MFP_CFG_IN(GPIO16, AF0)
71 #define GPIO17_GPIO	MFP_CFG_IN(GPIO17, AF0)
72 #define GPIO18_GPIO	MFP_CFG_IN(GPIO18, AF0)
73 #define GPIO19_GPIO	MFP_CFG_IN(GPIO19, AF0)
74 #define GPIO20_GPIO	MFP_CFG_IN(GPIO20, AF0)
75 #define GPIO21_GPIO	MFP_CFG_IN(GPIO21, AF0)
76 #define GPIO22_GPIO	MFP_CFG_IN(GPIO22, AF0)
77 #define GPIO23_GPIO	MFP_CFG_IN(GPIO23, AF0)
78 #define GPIO24_GPIO	MFP_CFG_IN(GPIO24, AF0)
79 #define GPIO25_GPIO	MFP_CFG_IN(GPIO25, AF0)
80 #define GPIO26_GPIO	MFP_CFG_IN(GPIO26, AF0)
81 #define GPIO27_GPIO	MFP_CFG_IN(GPIO27, AF0)
82 #define GPIO28_GPIO	MFP_CFG_IN(GPIO28, AF0)
83 #define GPIO29_GPIO	MFP_CFG_IN(GPIO29, AF0)
84 #define GPIO30_GPIO	MFP_CFG_IN(GPIO30, AF0)
85 #define GPIO31_GPIO	MFP_CFG_IN(GPIO31, AF0)
86 #define GPIO32_GPIO	MFP_CFG_IN(GPIO32, AF0)
87 #define GPIO33_GPIO	MFP_CFG_IN(GPIO33, AF0)
88 #define GPIO34_GPIO	MFP_CFG_IN(GPIO34, AF0)
89 #define GPIO35_GPIO	MFP_CFG_IN(GPIO35, AF0)
90 #define GPIO36_GPIO	MFP_CFG_IN(GPIO36, AF0)
91 #define GPIO37_GPIO	MFP_CFG_IN(GPIO37, AF0)
92 #define GPIO38_GPIO	MFP_CFG_IN(GPIO38, AF0)
93 #define GPIO39_GPIO	MFP_CFG_IN(GPIO39, AF0)
94 #define GPIO40_GPIO	MFP_CFG_IN(GPIO40, AF0)
95 #define GPIO41_GPIO	MFP_CFG_IN(GPIO41, AF0)
96 #define GPIO42_GPIO	MFP_CFG_IN(GPIO42, AF0)
97 #define GPIO43_GPIO	MFP_CFG_IN(GPIO43, AF0)
98 #define GPIO44_GPIO	MFP_CFG_IN(GPIO44, AF0)
99 #define GPIO45_GPIO	MFP_CFG_IN(GPIO45, AF0)
100 #define GPIO46_GPIO	MFP_CFG_IN(GPIO46, AF0)
101 #define GPIO47_GPIO	MFP_CFG_IN(GPIO47, AF0)
102 #define GPIO48_GPIO	MFP_CFG_IN(GPIO48, AF0)
103 #define GPIO49_GPIO	MFP_CFG_IN(GPIO49, AF0)
104 #define GPIO50_GPIO	MFP_CFG_IN(GPIO50, AF0)
105 #define GPIO51_GPIO	MFP_CFG_IN(GPIO51, AF0)
106 #define GPIO52_GPIO	MFP_CFG_IN(GPIO52, AF0)
107 #define GPIO53_GPIO	MFP_CFG_IN(GPIO53, AF0)
108 #define GPIO54_GPIO	MFP_CFG_IN(GPIO54, AF0)
109 #define GPIO55_GPIO	MFP_CFG_IN(GPIO55, AF0)
110 #define GPIO56_GPIO	MFP_CFG_IN(GPIO56, AF0)
111 #define GPIO57_GPIO	MFP_CFG_IN(GPIO57, AF0)
112 #define GPIO58_GPIO	MFP_CFG_IN(GPIO58, AF0)
113 #define GPIO59_GPIO	MFP_CFG_IN(GPIO59, AF0)
114 #define GPIO60_GPIO	MFP_CFG_IN(GPIO60, AF0)
115 #define GPIO61_GPIO	MFP_CFG_IN(GPIO61, AF0)
116 #define GPIO62_GPIO	MFP_CFG_IN(GPIO62, AF0)
117 #define GPIO63_GPIO	MFP_CFG_IN(GPIO63, AF0)
118 #define GPIO64_GPIO	MFP_CFG_IN(GPIO64, AF0)
119 #define GPIO65_GPIO	MFP_CFG_IN(GPIO65, AF0)
120 #define GPIO66_GPIO	MFP_CFG_IN(GPIO66, AF0)
121 #define GPIO67_GPIO	MFP_CFG_IN(GPIO67, AF0)
122 #define GPIO68_GPIO	MFP_CFG_IN(GPIO68, AF0)
123 #define GPIO69_GPIO	MFP_CFG_IN(GPIO69, AF0)
124 #define GPIO70_GPIO	MFP_CFG_IN(GPIO70, AF0)
125 #define GPIO71_GPIO	MFP_CFG_IN(GPIO71, AF0)
126 #define GPIO72_GPIO	MFP_CFG_IN(GPIO72, AF0)
127 #define GPIO73_GPIO	MFP_CFG_IN(GPIO73, AF0)
128 #define GPIO74_GPIO	MFP_CFG_IN(GPIO74, AF0)
129 #define GPIO75_GPIO	MFP_CFG_IN(GPIO75, AF0)
130 #define GPIO76_GPIO	MFP_CFG_IN(GPIO76, AF0)
131 #define GPIO77_GPIO	MFP_CFG_IN(GPIO77, AF0)
132 #define GPIO78_GPIO	MFP_CFG_IN(GPIO78, AF0)
133 #define GPIO79_GPIO	MFP_CFG_IN(GPIO79, AF0)
134 #define GPIO80_GPIO	MFP_CFG_IN(GPIO80, AF0)
135 #define GPIO81_GPIO	MFP_CFG_IN(GPIO81, AF0)
136 #define GPIO82_GPIO	MFP_CFG_IN(GPIO82, AF0)
137 #define GPIO83_GPIO	MFP_CFG_IN(GPIO83, AF0)
138 #define GPIO84_GPIO	MFP_CFG_IN(GPIO84, AF0)
139 
140 extern void pxa2xx_mfp_config(unsigned long *mfp_cfgs, int num);
141 extern void pxa2xx_mfp_set_lpm(int mfp, unsigned long lpm);
142 extern int gpio_set_wake(unsigned int gpio, unsigned int on);
143 #endif /* __ASM_ARCH_MFP_PXA2XX_H */
144