3 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
5 * SPDX-License-Identifier: GPL-2.0+
10 #include <asm/8xx_immap.h>
18 #define PRINTF(fmt,args...) printf (fmt ,##args)
20 #define PRINTF(fmt,args...)
24 * The ioport configuration table.
26 const mpc8xx_iop_conf_t iop_conf_tab[NUM_PORTS][PORT_BITS] = {
28 * Port A configuration
29 * Pin Signal Type Active Initial state
30 * PA7 fpgaProgramLowOut Out Low High
31 * PA1 fpgaCoreVoltageFailLow In Low N/A
33 { /* conf ppar psor pdir podr pdat pint function */
34 /* N/A */ { 0, 0, 0, 0, 0, 0, 0 }, /* No pin */
35 /* N/A */ { 0, 0, 0, 0, 0, 0, 0 }, /* No pin */
36 /* PA15 */ { 0, 0, 0, 0, 0, 0, 0 }, /* */
37 /* PA14 */ { 0, 0, 0, 0, 0, 0, 0 }, /* */
38 /* PA13 */ { 0, 0, 0, 0, 0, 0, 0 }, /* */
39 /* PA12 */ { 0, 0, 0, 0, 0, 0, 0 }, /* */
40 /* PA11 */ { 0, 0, 0, 0, 0, 0, 0 }, /* */
41 /* PA10 */ { 0, 0, 0, 0, 0, 0, 0 }, /* */
42 /* PA9 */ { 1, 0, 0, 1, 0, 0, 0 }, /* grn bicolor LED 1*/
43 /* PA8 */ { 1, 0, 0, 1, 0, 0, 0 }, /* red bicolor LED 1*/
44 /* PA7 */ { 1, 0, 0, 1, 0, 1, 0 }, /* fpgaProgramLow */
45 /* PA6 */ { 0, 0, 0, 0, 0, 0, 0 }, /* */
46 /* PA5 */ { 1, 0, 0, 1, 0, 0, 0 }, /* grn bicolor LED 0*/
47 /* PA4 */ { 1, 0, 0, 1, 0, 0, 0 }, /* red bicolor LED 0*/
48 /* PA3 */ { 0, 0, 0, 0, 0, 0, 0 }, /* */
49 /* PA2 */ { 0, 0, 0, 0, 0, 0, 0 }, /* */
50 #if !defined(CONFIG_SC)
51 /* PA1 */ { 1, 0, 0, 0, 0, 0, 0 }, /* fpgaCoreVoltageFail*/
53 /* PA1 */ { 0, 0, 0, 0, 0, 0, 0 }, /* */
55 /* PA0 */ { 0, 0, 0, 0, 0, 0, 0 } /* */
59 * Port B configuration
60 * Pin Signal Type Active Initial state
61 * PB14 docBusyLowIn In Low X
62 * PB15 gpio1Sig Out High Low
63 * PB16 fpgaDoneBi In High X
64 * PB17 swBitOkLowOut Out Low High
65 * PB19 speakerVolSig Out/Hi-Z High/Low High (Hi-Z)
66 * PB22 fpgaInitLowBi In Low X
67 * PB23 batteryOkSig In High X
68 * PB31 pulseCatcherClr Out High 0
70 { /* conf ppar psor pdir podr pdat pint function */
71 #if !defined(CONFIG_SC)
72 /* PB31 */ { 0, 0, 0, 0, 0, 0, 0 }, /* */
74 /* PB31 */ { 1, 0, 0, 1, 0, 0, 0 }, /* pulseCatcherClr */
76 /* PB30 */ { 0, 0, 0, 0, 0, 0, 0 }, /* */
77 /* PB29 */ { 0, 0, 0, 0, 0, 0, 0 }, /* */
78 /* PB28 */ { 0, 0, 0, 0, 0, 0, 0 }, /* */
79 /* PB27 */ { 0, 0, 0, 0, 0, 0, 0 }, /* */
80 /* PB26 */ { 0, 0, 0, 0, 0, 0, 0 }, /* */
81 /* PB25 */ { 0, 0, 0, 0, 0, 0, 0 }, /* */
82 /* PB24 */ { 0, 0, 0, 0, 0, 0, 0 }, /* */
83 #if !defined(CONFIG_SC)
84 /* PB23 */ { 1, 0, 0, 0, 0, 0, 0 }, /* batteryOk */
86 /* PB23 */ { 0, 0, 0, 0, 0, 0, 0 }, /* */
88 /* PB22 */ { 1, 0, 0, 0, 0, 0, 0 }, /* fpgaInitLowBi */
89 /* PB21 */ { 0, 0, 0, 0, 0, 0, 0 }, /* */
90 /* PB20 */ { 0, 0, 0, 0, 0, 0, 0 }, /* */
91 #if !defined(CONFIG_SC)
92 /* PB19 */ { 1, 0, 0, 1, 1, 1, 0 }, /* speakerVol */
94 /* PB19 */ { 0, 0, 0, 1, 1, 1, 0 }, /* */
96 /* PB18 */ { 0, 0, 0, 0, 0, 0, 0 }, /* */
97 /* PB17 */ { 1, 0, 0, 1, 0, 1, 0 }, /* swBitOkLow */
98 /* PB16 */ { 1, 0, 0, 0, 0, 0, 0 }, /* fpgaDone */
99 /* PB15 */ { 1, 0, 0, 1, 0, 0, 0 }, /* gpio1 */
100 #if !defined(CONFIG_SC)
101 /* PB14 */ { 1, 0, 0, 0, 0, 0, 0 } /* docBusyLow */
103 /* PB14 */ { 0, 0, 0, 0, 0, 0, 0 } /* */
108 * Port C configuration
109 * Pin Signal Type Active Initial state
110 * PC4 i2cBus1EnSig Out High High
111 * PC5 i2cBus2EnSig Out High High
112 * PC6 gpio0Sig Out High Low
113 * PC8 i2cBus3EnSig Out High High
114 * PC10 i2cBus4EnSig Out High High
115 * PC11 fpgaResetLowOut Out Low High
116 * PC12 systemBitOkIn In High X
117 * PC15 selfDreqLow In Low X
119 { /* conf ppar psor pdir podr pdat pint function */
120 /* N/A */ { 0, 0, 0, 0, 0, 0, 0 }, /* */
121 /* N/A */ { 0, 0, 0, 0, 0, 0, 0 }, /* */
122 /* PC15 */ { 1, 0, 0, 0, 0, 0, 0 }, /* selfDreqLowIn */
123 /* PC14 */ { 0, 0, 0, 0, 0, 0, 0 }, /* */
124 /* PC13 */ { 0, 0, 0, 0, 0, 0, 0 }, /* */
125 #if !defined(CONFIG_SC)
126 /* PC12 */ { 1, 0, 0, 0, 0, 0, 0 }, /* systemBitOkIn */
128 /* PC12 */ { 0, 0, 0, 0, 0, 0, 0 }, /* */
130 /* PC11 */ { 1, 0, 0, 1, 0, 1, 0 }, /* fpgaResetLowOut */
131 #if !defined(CONFIG_SC)
132 /* PC10 */ { 1, 0, 0, 1, 0, 1, 0 }, /* i2cBus4EnSig */
134 /* PC10 */ { 0, 0, 0, 1, 0, 1, 0 }, /* */
136 /* PC9 */ { 0, 0, 0, 0, 0, 0, 0 }, /* */
137 #if !defined(CONFIG_SC)
138 /* PC8 */ { 1, 0, 0, 1, 0, 1, 0 }, /* i2cBus3EnSig */
140 /* PC8 */ { 0, 0, 0, 1, 0, 1, 0 }, /* */
142 /* PC7 */ { 0, 0, 0, 0, 0, 0, 0 }, /* */
143 /* PC6 */ { 1, 0, 0, 1, 0, 1, 0 }, /* gpio0 */
144 #if !defined(CONFIG_SC)
145 /* PC5 */ { 1, 0, 0, 1, 0, 1, 0 }, /* i2cBus2EnSig */
146 /* PC4 */ { 1, 0, 0, 1, 0, 1, 0 }, /* i2cBus1EnSig */
148 /* PC5 */ { 0, 0, 0, 1, 0, 1, 0 }, /* */
149 /* PC4 */ { 0, 0, 0, 1, 0, 1, 0 }, /* */
151 /* N/A */ { 0, 0, 0, 0, 0, 0, 0 }, /* */
152 /* N/A */ { 0, 0, 0, 0, 0, 0, 0 }, /* */
153 /* N/A */ { 0, 0, 0, 0, 0, 0, 0 }, /* */
154 /* N/A */ { 0, 0, 0, 0, 0, 0, 0 } /* */
158 * Port D configuration
160 { /* conf ppar psor pdir podr pdat pint function */
161 /* N/A */ { 0, 0, 0, 0, 0, 0, 0 }, /* */
162 /* N/A */ { 0, 0, 0, 0, 0, 0, 0 }, /* */
163 /* PD15 */ { 0, 0, 0, 0, 0, 0, 0 }, /* */
164 /* PD14 */ { 0, 0, 0, 0, 0, 0, 0 }, /* */
165 /* PD13 */ { 0, 0, 0, 0, 0, 0, 0 }, /* */
166 /* PD12 */ { 0, 0, 0, 0, 0, 0, 0 }, /* */
167 /* PD11 */ { 0, 0, 0, 0, 0, 0, 0 }, /* */
168 /* PD10 */ { 0, 0, 0, 0, 0, 0, 0 }, /* */
169 /* PD9 */ { 0, 0, 0, 0, 0, 0, 0 }, /* */
170 /* PD8 */ { 0, 0, 0, 0, 0, 0, 0 }, /* */
171 /* PD7 */ { 0, 0, 0, 0, 0, 0, 0 }, /* */
172 /* PD6 */ { 0, 0, 0, 0, 0, 0, 0 }, /* */
173 /* PD5 */ { 0, 0, 0, 0, 0, 0, 0 }, /* */
174 /* PD4 */ { 0, 0, 0, 0, 0, 0, 0 }, /* */
175 /* PD3 */ { 0, 0, 0, 0, 0, 0, 0 }, /* */
176 /* N/A */ { 0, 0, 0, 0, 0, 0, 0 }, /* */
177 /* N/A */ { 0, 0, 0, 0, 0, 0, 0 }, /* */
178 /* N/A */ { 0, 0, 0, 0, 0, 0, 0 } /* */
183 * Configure the MPC8XX I/O ports per the ioport configuration table
184 * (taken from ./arch/powerpc/cpu/mpc8260/cpu_init.c)
186 void config_mpc8xx_ioports (volatile immap_t * immr)
190 for (portnum = 0; portnum < NUM_PORTS; portnum++) {
191 uint pmsk = 0, ppar = 0, psor = 0, pdir = 0;
192 uint podr = 0, pdat = 0, pint = 0;
194 mpc8xx_iop_conf_t *iopc =
195 (mpc8xx_iop_conf_t *) & iop_conf_tab[portnum][0];
196 mpc8xx_iop_conf_t *eiopc = iopc + PORT_BITS;
199 * For all ports except port B, ignore the two don't care entries
200 * in the configuration tables.
203 iopc = (mpc8xx_iop_conf_t *) &
204 iop_conf_tab[portnum][2];
208 * NOTE: index 0 refers to pin 17, index 17 refers to pin 0
210 while (iopc < eiopc) {
230 PRINTF ("%s:%d:\n portnum=%d ", __FUNCTION__, __LINE__,
251 PRINTF (" ppar=0x%.8x pdir=0x%.8x podr=0x%.8x\n"
252 " pdat=0x%.8x psor=0x%.8x pint=0x%.8x pmsk=0x%.8x\n",
253 ppar, pdir, podr, pdat, psor, pint, pmsk);
256 * Have to handle the ioports on a port-by-port basis since there
257 * are three different flavors.
262 if (0 == portnum) { /* port A */
263 immr->im_ioport.iop_papar &= tpmsk;
264 immr->im_ioport.iop_padat =
266 iop_padat & tpmsk) | pdat;
267 immr->im_ioport.iop_padir =
269 iop_padir & tpmsk) | pdir;
270 immr->im_ioport.iop_paodr =
272 iop_paodr & tpmsk) | podr;
273 immr->im_ioport.iop_papar |= ppar;
274 } else if (1 == portnum) { /* port B */
275 immr->im_cpm.cp_pbpar &= tpmsk;
276 immr->im_cpm.cp_pbdat =
278 cp_pbdat & tpmsk) | pdat;
279 immr->im_cpm.cp_pbdir =
281 cp_pbdir & tpmsk) | pdir;
282 immr->im_cpm.cp_pbodr =
284 cp_pbodr & tpmsk) | podr;
285 immr->im_cpm.cp_pbpar |= ppar;
286 } else if (2 == portnum) { /* port C */
287 immr->im_ioport.iop_pcpar &= tpmsk;
288 immr->im_ioport.iop_pcdat =
290 iop_pcdat & tpmsk) | pdat;
291 immr->im_ioport.iop_pcdir =
293 iop_pcdir & tpmsk) | pdir;
294 immr->im_ioport.iop_pcint =
296 iop_pcint & tpmsk) | pint;
297 immr->im_ioport.iop_pcso =
299 iop_pcso & tpmsk) | psor;
300 immr->im_ioport.iop_pcpar |= ppar;
301 } else if (3 == portnum) { /* port D */
302 immr->im_ioport.iop_pdpar &= tpmsk;
303 immr->im_ioport.iop_pddat =
305 iop_pddat & tpmsk) | pdat;
306 immr->im_ioport.iop_pddir =
308 iop_pddir & tpmsk) | pdir;
309 immr->im_ioport.iop_pdpar |= ppar;
314 PRINTF ("%s:%d: Port A:\n papar=0x%.4x padir=0x%.4x"
315 " paodr=0x%.4x\n padat=0x%.4x\n", __FUNCTION__, __LINE__,
316 immr->im_ioport.iop_papar, immr->im_ioport.iop_padir,
317 immr->im_ioport.iop_paodr, immr->im_ioport.iop_padat);
318 PRINTF ("%s:%d: Port B:\n pbpar=0x%.8x pbdir=0x%.8x"
319 " pbodr=0x%.8x\n pbdat=0x%.8x\n", __FUNCTION__, __LINE__,
320 immr->im_cpm.cp_pbpar, immr->im_cpm.cp_pbdir,
321 immr->im_cpm.cp_pbodr, immr->im_cpm.cp_pbdat);
322 PRINTF ("%s:%d: Port C:\n pcpar=0x%.4x pcdir=0x%.4x"
323 " pcdat=0x%.4x\n pcso=0x%.4x pcint=0x%.4x\n ",
324 __FUNCTION__, __LINE__, immr->im_ioport.iop_pcpar,
325 immr->im_ioport.iop_pcdir, immr->im_ioport.iop_pcdat,
326 immr->im_ioport.iop_pcso, immr->im_ioport.iop_pcint);
327 PRINTF ("%s:%d: Port D:\n pdpar=0x%.4x pddir=0x%.4x"
328 " pddat=0x%.4x\n", __FUNCTION__, __LINE__,
329 immr->im_ioport.iop_pdpar, immr->im_ioport.iop_pddir,
330 immr->im_ioport.iop_pddat);