|
31 | 31 |
|
32 | 32 | #include "io.h" |
33 | 33 |
|
34 | | -#ifdef CONFIG_B4860G100 |
35 | | -static struct gpiobus gbus; |
36 | | -#endif /* CONFIG_B4860G100 */ |
37 | | - |
38 | 34 | static inline void byte0_out(unsigned char data); |
39 | 35 | static inline void byte1_out(unsigned char data); |
40 | 36 | static inline void xl_cclk_b(int32_t i); |
@@ -92,163 +88,6 @@ static inline unsigned char bitswap(unsigned char s) |
92 | 88 | return d; |
93 | 89 | } |
94 | 90 |
|
95 | | -#ifdef CONFIG_B4860G100 |
96 | | -/* |
97 | | - * ====================================================================== |
98 | | - * board specific configuration |
99 | | - */ |
100 | | - |
101 | | -static inline void mpc85xx_gpio_set_dir( |
102 | | - int32_t port, |
103 | | - uint32_t mask, |
104 | | - uint32_t dir) |
105 | | -{ |
106 | | - dir |= (in_be32(gbus.r[port]+GPDIR) & ~mask); |
107 | | - out_be32(gbus.r[port]+GPDIR, dir); |
108 | | -} |
109 | | - |
110 | | -static inline void mpc85xx_gpio_set(int32_t port, uint32_t mask, uint32_t val) |
111 | | -{ |
112 | | - /* First mask off the unwanted parts of "dir" and "val" */ |
113 | | - val &= mask; |
114 | | - |
115 | | - /* Now read in the values we're supposed to preserve */ |
116 | | - val |= (in_be32(gbus.r[port]+GPDAT) & ~mask); |
117 | | - |
118 | | - out_be32(gbus.r[port]+GPDAT, val); |
119 | | -} |
120 | | - |
121 | | -static inline uint32_t mpc85xx_gpio_get(int32_t port, uint32_t mask) |
122 | | -{ |
123 | | - /* Read the requested values */ |
124 | | - return in_be32(gbus.r[port]+GPDAT) & mask; |
125 | | -} |
126 | | - |
127 | | -static inline void mpc85xx_gpio_set_low(int32_t port, uint32_t gpios) |
128 | | -{ |
129 | | - mpc85xx_gpio_set(port, gpios, 0x00000000); |
130 | | -} |
131 | | - |
132 | | -static inline void mpc85xx_gpio_set_high(int32_t port, uint32_t gpios) |
133 | | -{ |
134 | | - mpc85xx_gpio_set(port, gpios, 0xFFFFFFFF); |
135 | | -} |
136 | | - |
137 | | -static inline void gpio_set_value(int32_t port, uint32_t gpio, uint32_t value) |
138 | | -{ |
139 | | - int32_t g; |
140 | | - |
141 | | - g = 31 - gpio; |
142 | | - if (value) |
143 | | - mpc85xx_gpio_set_high(port, 1U << g); |
144 | | - else |
145 | | - mpc85xx_gpio_set_low(port, 1U << g); |
146 | | -} |
147 | | - |
148 | | -static inline int gpio_get_value(int32_t port, uint32_t gpio) |
149 | | -{ |
150 | | - int32_t g; |
151 | | - |
152 | | - g = 31 - gpio; |
153 | | - return !!mpc85xx_gpio_get(port, 1U << g); |
154 | | -} |
155 | | - |
156 | | -static inline void xl_cclk_b(int32_t i) |
157 | | -{ |
158 | | - gpio_set_value(XL_CCLK_PORT, XL_CCLK_PIN, i); |
159 | | -} |
160 | | - |
161 | | -void xl_program_b(int32_t i) |
162 | | -{ |
163 | | - gpio_set_value(XL_PROGN_PORT, XL_PROGN_PIN, i); |
164 | | -} |
165 | | - |
166 | | -void xl_rdwr_b(int32_t i) |
167 | | -{ |
168 | | - gpio_set_value(XL_RDWRN_PORT, XL_RDWRN_PIN, i); |
169 | | -} |
170 | | - |
171 | | -void xl_csi_b(int32_t i) |
172 | | -{ |
173 | | - gpio_set_value(XL_CSIN_PORT, XL_CSIN_PIN, i); |
174 | | -} |
175 | | - |
176 | | -int xl_get_init_b(void) |
177 | | -{ |
178 | | - return gpio_get_value(XL_INITN_PORT, XL_INITN_PIN); |
179 | | -} |
180 | | - |
181 | | -int xl_get_done_b(void) |
182 | | -{ |
183 | | - return gpio_get_value(XL_DONE_PORT, XL_DONE_PIN); |
184 | | -} |
185 | | - |
186 | | - |
187 | | -/* G100 specific bit swap and remmap (to gpio pins) for byte 0 */ |
188 | | -static inline uint32_t bit_remap_byte0(uint32_t s) |
189 | | -{ |
190 | | - uint32_t d; |
191 | | - |
192 | | - d = (((s&0x80)>>7) | ((s&0x40)>>5) | ((s&0x20)>>3) | ((s&0x10)>>1) | |
193 | | - ((s&0x08)<<1) | ((s&0x04)<<3) | ((s&0x02)<<6) | ((s&0x01)<<9)); |
194 | | - return d; |
195 | | -} |
196 | | - |
197 | | -/* |
198 | | - * G100 specific MSB, in this order [byte0 | byte1], out |
199 | | - */ |
200 | | -static inline void byte0_out(unsigned char data) |
201 | | -{ |
202 | | - uint32_t swap32; |
203 | | - |
204 | | - swap32 = bit_remap_byte0((uint32_t) data) << 8; |
205 | | - |
206 | | - mpc85xx_gpio_set(0, 0x0002BF00, (uint32_t) swap32); |
207 | | -} |
208 | | - |
209 | | -/* |
210 | | - * G100 specific LSB, in this order [byte0 | byte1], out |
211 | | - */ |
212 | | -static inline void byte1_out(unsigned char data) |
213 | | -{ |
214 | | - mpc85xx_gpio_set(0, 0x000000FF, (uint32_t) bitswap(data)); |
215 | | -} |
216 | | - |
217 | | -/* |
218 | | - * configurable per device type for different I/O config |
219 | | - */ |
220 | | -int xl_init_io(void) |
221 | | -{ |
222 | | - struct device_node *np; |
223 | | - const u32 *p_reg; |
224 | | - int reg, cnt; |
225 | | - |
226 | | - cnt = 0; |
227 | | - memset(&gbus, 0, sizeof(struct gpiobus)); |
228 | | - for_each_compatible_node(np, NULL, "fsl,qoriq-gpio") { |
229 | | - p_reg = of_get_property(np, "reg", NULL); |
230 | | - if (p_reg == NULL) |
231 | | - break; |
232 | | - reg = (int) *p_reg; |
233 | | - gbus.r[cnt] = of_iomap(np, 0); |
234 | | - |
235 | | - if (!gbus.r[cnt]) { |
236 | | - pr_err("not findding gpio cell-index %d\n", cnt); |
237 | | - return -ENODEV; |
238 | | - } |
239 | | - cnt++; |
240 | | - } |
241 | | - mpc85xx_gpio_set_dir(0, 0x0002BFFF, 0x0002BFFF); |
242 | | - mpc85xx_gpio_set_dir(1, 0x00240060, 0x00240060); |
243 | | - |
244 | | - gbus.ngpio = cnt; |
245 | | - |
246 | | - return 0; |
247 | | -} |
248 | | - |
249 | | - |
250 | | -#else /* placeholder for boards with different config */ |
251 | | - |
252 | 91 | void xl_program_b(int32_t i) |
253 | 92 | { |
254 | 93 | } |
@@ -290,5 +129,3 @@ int xl_init_io(void) |
290 | 129 | { |
291 | 130 | return -1; |
292 | 131 | } |
293 | | - |
294 | | -#endif /* CONFIG_B4860G100 */ |
0 commit comments