Blame view

board/gen860t/ioport.c 10.8 KB
c609719b8   wdenk   Initial revision
1
2
3
4
  /*
   * (C) Copyright 2000
   * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
   *
1a4596601   Wolfgang Denk   Add GPL-2.0+ SPDX...
5
   * SPDX-License-Identifier:	GPL-2.0+
c609719b8   wdenk   Initial revision
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
   */
  
  #include <common.h>
  #include <mpc8xx.h>
  #include <asm/8xx_immap.h>
  #include "ioport.h"
  
  #if 0
  #define IOPORT_DEBUG
  #endif
  
  #ifdef  IOPORT_DEBUG
  #define PRINTF(fmt,args...) printf (fmt ,##args)
  #else
  #define PRINTF(fmt,args...)
  #endif
  
  /*
   * The ioport configuration table.
   */
  const mpc8xx_iop_conf_t iop_conf_tab[NUM_PORTS][PORT_BITS] = {
      /*
  	 * Port A configuration
7aa786147   wdenk   * Add support for...
29
  	 * Pin	Signal					Type	Active	Initial state
53677ef18   Wolfgang Denk   Big white-space c...
30
31
  	 * PA7	fpgaProgramLowOut		Out		Low			High
  	 * PA1	fpgaCoreVoltageFailLow	In		Low			N/A
c609719b8   wdenk   Initial revision
32
  	 */
53677ef18   Wolfgang Denk   Big white-space c...
33
      {	/*	    conf ppar psor pdir podr pdat pint	   function		*/
c609719b8   wdenk   Initial revision
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
  	/* N/A  */ { 0,   0,   0,   0,   0,   0,   0 }, /* No pin			*/
  	/* N/A  */ { 0,   0,   0,   0,   0,   0,   0 }, /* No pin			*/
  	/* PA15 */ { 0,   0,   0,   0,   0,   0,   0 }, /*	*/
  	/* PA14 */ { 0,   0,   0,   0,   0,   0,   0 }, /*	*/
  	/* PA13 */ { 0,   0,   0,   0,   0,   0,   0 }, /*	*/
  	/* PA12 */ { 0,   0,   0,   0,   0,   0,   0 }, /*	*/
  	/* PA11 */ { 0,   0,   0,   0,   0,   0,   0 }, /*	*/
  	/* PA10 */ { 0,   0,   0,   0,   0,   0,   0 }, /*	*/
  	/* PA9  */ { 1,   0,   0,   1,   0,   0,   0 }, /* grn bicolor LED 1*/
  	/* PA8  */ { 1,   0,   0,   1,   0,   0,   0 }, /* red bicolor LED 1*/
  	/* PA7  */ { 1,   0,   0,   1,   0,   1,   0 }, /* fpgaProgramLow	*/
  	/* PA6  */ { 0,   0,   0,   0,   0,   0,   0 }, /*	*/
  	/* PA5  */ { 1,   0,   0,   1,   0,   0,   0 }, /* grn bicolor LED 0*/
  	/* PA4  */ { 1,   0,   0,   1,   0,   0,   0 }, /* red bicolor LED 0*/
  	/* PA3  */ { 0,   0,   0,   0,   0,   0,   0 }, /*	*/
  	/* PA2  */ { 0,   0,   0,   0,   0,   0,   0 }, /*	*/
7aa786147   wdenk   * Add support for...
50
51
52
  #if !defined(CONFIG_SC)
  	/* PA1  */ { 1,   0,   0,   0,   0,   0,   0 }, /*	fpgaCoreVoltageFail*/
  #else
c609719b8   wdenk   Initial revision
53
  	/* PA1  */ { 0,   0,   0,   0,   0,   0,   0 }, /*	*/
7aa786147   wdenk   * Add support for...
54
  #endif
c609719b8   wdenk   Initial revision
55
56
57
58
  	/* PA0  */ { 0,   0,   0,   0,   0,   0,   0 }  /*	*/
      },
  
  	/*
7aa786147   wdenk   * Add support for...
59
  	 * Port B configuration
c609719b8   wdenk   Initial revision
60
61
62
63
  	 * Pin		Signal			Type		Active		Initial state
  	 * PB14		docBusyLowIn	In			Low			X
  	 * PB15		gpio1Sig		Out			High		Low
  	 * PB16		fpgaDoneBi		In			High		X
7aa786147   wdenk   * Add support for...
64
  	 * PB17		swBitOkLowOut	Out			Low			High
c609719b8   wdenk   Initial revision
65
66
67
  	 * PB19		speakerVolSig	Out/Hi-Z	High/Low	High (Hi-Z)
  	 * PB22		fpgaInitLowBi	In			Low			X
  	 * PB23		batteryOkSig	In			High		X
7aa786147   wdenk   * Add support for...
68
69
  	 * PB31		pulseCatcherClr	Out			High		0
  	 */
53677ef18   Wolfgang Denk   Big white-space c...
70
  	{	/*	    conf ppar psor pdir podr pdat pint	  function			*/
7aa786147   wdenk   * Add support for...
71
72
73
74
75
  #if !defined(CONFIG_SC)
  	/* PB31 */ { 0,	  0,   0,   0,   0,   0,   0 }, /*	*/
  #else
  	/* PB31 */ { 1,   0,   0,   1,   0,   0,   0 }, /* pulseCatcherClr	*/
  #endif
c609719b8   wdenk   Initial revision
76
77
78
79
80
81
82
  	/* PB30 */ { 0,   0,   0,   0,   0,   0,   0 }, /*	*/
  	/* PB29 */ { 0,   0,   0,   0,   0,   0,   0 }, /*	*/
  	/* PB28 */ { 0,   0,   0,   0,   0,   0,   0 }, /*	*/
  	/* PB27 */ { 0,   0,   0,   0,   0,   0,   0 }, /*	*/
  	/* PB26 */ { 0,   0,   0,   0,   0,   0,   0 }, /*	*/
  	/* PB25 */ { 0,   0,   0,   0,   0,   0,   0 }, /*	*/
  	/* PB24 */ { 0,   0,   0,   0,   0,   0,   0 }, /*	*/
7aa786147   wdenk   * Add support for...
83
  #if !defined(CONFIG_SC)
c609719b8   wdenk   Initial revision
84
  	/* PB23 */ { 1,   0,   0,   0,   0,   0,   0 }, /* batteryOk		*/
7aa786147   wdenk   * Add support for...
85
86
87
  #else
  	/* PB23 */ { 0,   0,   0,   0,   0,   0,   0 }, /*	*/
  #endif
c609719b8   wdenk   Initial revision
88
89
90
  	/* PB22 */ { 1,   0,   0,   0,   0,   0,   0 }, /* fpgaInitLowBi	*/
  	/* PB21 */ { 0,   0,   0,   0,   0,   0,   0 }, /*	*/
  	/* PB20 */ { 0,   0,   0,   0,   0,   0,   0 }, /*	*/
7aa786147   wdenk   * Add support for...
91
  #if !defined(CONFIG_SC)
c609719b8   wdenk   Initial revision
92
  	/* PB19 */ { 1,   0,   0,   1,   1,   1,   0 }, /* speakerVol		*/
7aa786147   wdenk   * Add support for...
93
94
95
  #else
  	/* PB19 */ { 0,   0,   0,   1,   1,   1,   0 }, /*	*/
  #endif
c609719b8   wdenk   Initial revision
96
  	/* PB18 */ { 0,   0,   0,   0,   0,   0,   0 }, /*	*/
7aa786147   wdenk   * Add support for...
97
  	/* PB17 */ { 1,   0,   0,   1,   0,   1,   0 }, /* swBitOkLow		*/
c609719b8   wdenk   Initial revision
98
99
  	/* PB16 */ { 1,   0,   0,   0,   0,   0,   0 }, /* fpgaDone			*/
  	/* PB15 */ { 1,   0,   0,   1,   0,   0,   0 }, /* gpio1			*/
7aa786147   wdenk   * Add support for...
100
  #if !defined(CONFIG_SC)
c609719b8   wdenk   Initial revision
101
  	/* PB14 */ { 1,   0,   0,   0,   0,   0,   0 }  /* docBusyLow		*/
7aa786147   wdenk   * Add support for...
102
  #else
53677ef18   Wolfgang Denk   Big white-space c...
103
  	/* PB14 */ { 0,   0,   0,   0,   0,   0,   0 }  /*	*/
7aa786147   wdenk   * Add support for...
104
105
  #endif
  	},
c609719b8   wdenk   Initial revision
106
107
  
  	/*
7aa786147   wdenk   * Add support for...
108
  	 * Port C configuration
c609719b8   wdenk   Initial revision
109
110
111
112
113
114
115
116
117
118
  	 * Pin		Signal				Type	Active		Initial state
  	 * PC4		i2cBus1EnSig		Out		High		High
  	 * PC5		i2cBus2EnSig		Out		High		High
  	 * PC6		gpio0Sig			Out		High		Low
  	 * PC8		i2cBus3EnSig		Out		High		High
  	 * PC10		i2cBus4EnSig		Out		High		High
  	 * PC11		fpgaResetLowOut		Out		Low			High
  	 * PC12		systemBitOkIn		In		High		X
  	 * PC15		selfDreqLow			In		Low			X
  	 */
53677ef18   Wolfgang Denk   Big white-space c...
119
  	{	/*	    conf ppar psor pdir podr pdat pint	  function			*/
c609719b8   wdenk   Initial revision
120
121
122
123
124
  	/* N/A	*/ { 0,   0,   0,   0,   0,   0,   0 }, /*	*/
  	/* N/A	*/ { 0,   0,   0,   0,   0,   0,   0 }, /*	*/
  	/* PC15 */ { 1,   0,   0,   0,   0,   0,   0 }, /* selfDreqLowIn	*/
  	/* PC14 */ { 0,   0,   0,   0,   0,   0,   0 }, /*	*/
  	/* PC13 */ { 0,   0,   0,   0,   0,   0,   0 }, /*	*/
7aa786147   wdenk   * Add support for...
125
  #if !defined(CONFIG_SC)
c609719b8   wdenk   Initial revision
126
  	/* PC12 */ { 1,   0,   0,   0,   0,   0,   0 }, /* systemBitOkIn	*/
7aa786147   wdenk   * Add support for...
127
  #else
53677ef18   Wolfgang Denk   Big white-space c...
128
  	/* PC12 */ { 0,   0,   0,   0,   0,   0,   0 }, /*	*/
7aa786147   wdenk   * Add support for...
129
  #endif
c609719b8   wdenk   Initial revision
130
  	/* PC11 */ { 1,   0,   0,   1,   0,   1,   0 }, /* fpgaResetLowOut	*/
7aa786147   wdenk   * Add support for...
131
  #if !defined(CONFIG_SC)
c609719b8   wdenk   Initial revision
132
  	/* PC10 */ { 1,   0,   0,   1,   0,   1,   0 }, /* i2cBus4EnSig		*/
7aa786147   wdenk   * Add support for...
133
134
135
  #else
  	/* PC10 */ { 0,   0,   0,   1,   0,   1,   0 }, /*	*/
  #endif
c609719b8   wdenk   Initial revision
136
  	/* PC9  */ { 0,   0,   0,   0,   0,   0,   0 }, /*	*/
7aa786147   wdenk   * Add support for...
137
  #if !defined(CONFIG_SC)
c609719b8   wdenk   Initial revision
138
  	/* PC8  */ { 1,   0,   0,   1,   0,   1,   0 }, /* i2cBus3EnSig		*/
7aa786147   wdenk   * Add support for...
139
140
141
  #else
  	/* PC8  */ { 0,   0,   0,   1,   0,   1,   0 }, /*	*/
  #endif
c609719b8   wdenk   Initial revision
142
143
  	/* PC7  */ { 0,   0,   0,   0,   0,   0,   0 }, /*	*/
  	/* PC6  */ { 1,   0,   0,   1,   0,   1,   0 }, /* gpio0			*/
7aa786147   wdenk   * Add support for...
144
  #if !defined(CONFIG_SC)
c609719b8   wdenk   Initial revision
145
146
  	/* PC5  */ { 1,   0,   0,   1,   0,   1,   0 }, /* i2cBus2EnSig		*/
  	/* PC4  */ { 1,   0,   0,   1,   0,   1,   0 }, /* i2cBus1EnSig		*/
7aa786147   wdenk   * Add support for...
147
148
149
150
  #else
  	/* PC5  */ { 0,   0,   0,   1,   0,   1,   0 }, /*	*/
  	/* PC4  */ { 0,   0,   0,   1,   0,   1,   0 }, /*	*/
  #endif
c609719b8   wdenk   Initial revision
151
152
153
154
  	/* N/A  */ { 0,   0,   0,   0,   0,   0,   0 }, /*	*/
  	/* N/A  */ { 0,   0,   0,   0,   0,   0,   0 }, /*	*/
  	/* N/A  */ { 0,   0,   0,   0,   0,   0,   0 }, /*	*/
  	/* N/A  */ { 0,   0,   0,   0,   0,   0,   0 }  /*	*/
7aa786147   wdenk   * Add support for...
155
  	},
c609719b8   wdenk   Initial revision
156

7aa786147   wdenk   * Add support for...
157
158
159
  	/*
  	 * Port D configuration
  	 */
53677ef18   Wolfgang Denk   Big white-space c...
160
  	{	/*	    conf ppar psor pdir podr pdat pint	   function			*/
c609719b8   wdenk   Initial revision
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
  	/* N/A  */ { 0,   0,   0,   0,   0,   0,   0 }, /*	*/
  	/* N/A  */ { 0,   0,   0,   0,   0,   0,   0 }, /*	*/
  	/* PD15 */ { 0,   0,   0,   0,   0,   0,   0 }, /*	*/
  	/* PD14 */ { 0,   0,   0,   0,   0,   0,   0 }, /*	*/
  	/* PD13 */ { 0,   0,   0,   0,   0,   0,   0 }, /*	*/
  	/* PD12 */ { 0,   0,   0,   0,   0,   0,   0 }, /*	*/
  	/* PD11 */ { 0,   0,   0,   0,   0,   0,   0 }, /*	*/
  	/* PD10 */ { 0,   0,   0,   0,   0,   0,   0 }, /*	*/
  	/* PD9  */ { 0,   0,   0,   0,   0,   0,   0 }, /*	*/
  	/* PD8  */ { 0,   0,   0,   0,   0,   0,   0 }, /*	*/
  	/* PD7  */ { 0,   0,   0,   0,   0,   0,   0 }, /*	*/
  	/* PD6  */ { 0,   0,   0,   0,   0,   0,   0 }, /*	*/
  	/* PD5  */ { 0,   0,   0,   0,   0,   0,   0 }, /*	*/
  	/* PD4  */ { 0,   0,   0,   0,   0,   0,   0 }, /*	*/
  	/* PD3  */ { 0,   0,   0,   0,   0,   0,   0 }, /*	*/
  	/* N/A  */ { 0,   0,   0,   0,   0,   0,   0 }, /*	*/
  	/* N/A  */ { 0,   0,   0,   0,   0,   0,   0 }, /*	*/
  	/* N/A  */ { 0,   0,   0,   0,   0,   0,   0 }  /*	*/
7aa786147   wdenk   * Add support for...
179
  	}
c609719b8   wdenk   Initial revision
180
181
182
183
  };
  
  /*
   * Configure the MPC8XX I/O ports per the ioport configuration table
a47a12bec   Stefan Roese   Move arch/ppc to ...
184
   * (taken from ./arch/powerpc/cpu/mpc8260/cpu_init.c)
c609719b8   wdenk   Initial revision
185
   */
bf9e3b38f   wdenk   * Some code cleanup
186
  void config_mpc8xx_ioports (volatile immap_t * immr)
c609719b8   wdenk   Initial revision
187
  {
bf9e3b38f   wdenk   * Some code cleanup
188
  	int portnum;
c609719b8   wdenk   Initial revision
189

bf9e3b38f   wdenk   * Some code cleanup
190
  	for (portnum = 0; portnum < NUM_PORTS; portnum++) {
c609719b8   wdenk   Initial revision
191
192
193
  		uint pmsk = 0, ppar = 0, psor = 0, pdir = 0;
  		uint podr = 0, pdat = 0, pint = 0;
  		uint msk = 1;
bf9e3b38f   wdenk   * Some code cleanup
194
195
  		mpc8xx_iop_conf_t *iopc =
  			(mpc8xx_iop_conf_t *) & iop_conf_tab[portnum][0];
c609719b8   wdenk   Initial revision
196
197
198
199
200
201
202
  		mpc8xx_iop_conf_t *eiopc = iopc + PORT_BITS;
  
  		/*
  		 * For all ports except port B, ignore the two don't care entries
  		 * in the configuration tables.
  		 */
  		if (portnum != 1) {
bf9e3b38f   wdenk   * Some code cleanup
203
204
  			iopc = (mpc8xx_iop_conf_t *) &
  				iop_conf_tab[portnum][2];
c609719b8   wdenk   Initial revision
205
206
207
208
209
210
  		}
  
  		/*
  		 * NOTE: index 0 refers to pin 17, index 17 refers to pin 0
  		 */
  		while (iopc < eiopc) {
bf9e3b38f   wdenk   * Some code cleanup
211
  			if (iopc->conf) {
c609719b8   wdenk   Initial revision
212
  				pmsk |= msk;
bf9e3b38f   wdenk   * Some code cleanup
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
  				if (iopc->ppar)
  					ppar |= msk;
  				if (iopc->psor)
  					psor |= msk;
  				if (iopc->pdir)
  					pdir |= msk;
  				if (iopc->podr)
  					podr |= msk;
  				if (iopc->pdat)
  					pdat |= msk;
  				if (iopc->pint)
  					pint |= msk;
  			}
  			msk <<= 1;
  			iopc++;
c609719b8   wdenk   Initial revision
228
  		}
bf9e3b38f   wdenk   * Some code cleanup
229
230
231
  		PRINTF ("%s:%d:
    portnum=%d ", __FUNCTION__, __LINE__,
  			portnum);
c609719b8   wdenk   Initial revision
232
  #ifdef IOPORT_DEBUG
bf9e3b38f   wdenk   * Some code cleanup
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
  		switch (portnum) {
  		case 0:
  			printf ("(A)
  ");
  			break;
  		case 1:
  			printf ("(B)
  ");
  			break;
  		case 2:
  			printf ("(C)
  ");
  			break;
  		case 3:
  			printf ("(D)
  ");
  			break;
  		default:
  			printf ("(?)
  ");
  			break;
c609719b8   wdenk   Initial revision
254
255
  		}
  #endif
bf9e3b38f   wdenk   * Some code cleanup
256
257
258
259
260
  		PRINTF ("  ppar=0x%.8x  pdir=0x%.8x  podr=0x%.8x
  "
  			"  pdat=0x%.8x  psor=0x%.8x  pint=0x%.8x  pmsk=0x%.8x
  ",
  			ppar, pdir, podr, pdat, psor, pint, pmsk);
c609719b8   wdenk   Initial revision
261
262
263
264
265
266
  
  		/*
  		 * Have to handle the ioports on a port-by-port basis since there
  		 * are three different flavors.
  		 */
  		if (pmsk != 0) {
bf9e3b38f   wdenk   * Some code cleanup
267
  			uint tpmsk = ~pmsk;
c609719b8   wdenk   Initial revision
268

bf9e3b38f   wdenk   * Some code cleanup
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
  			if (0 == portnum) {	/* port A */
  				immr->im_ioport.iop_papar &= tpmsk;
  				immr->im_ioport.iop_padat =
  					(immr->im_ioport.
  					 iop_padat & tpmsk) | pdat;
  				immr->im_ioport.iop_padir =
  					(immr->im_ioport.
  					 iop_padir & tpmsk) | pdir;
  				immr->im_ioport.iop_paodr =
  					(immr->im_ioport.
  					 iop_paodr & tpmsk) | podr;
  				immr->im_ioport.iop_papar |= ppar;
  			} else if (1 == portnum) {	/* port B */
  				immr->im_cpm.cp_pbpar &= tpmsk;
  				immr->im_cpm.cp_pbdat =
  					(immr->im_cpm.
  					 cp_pbdat & tpmsk) | pdat;
  				immr->im_cpm.cp_pbdir =
  					(immr->im_cpm.
  					 cp_pbdir & tpmsk) | pdir;
  				immr->im_cpm.cp_pbodr =
  					(immr->im_cpm.
  					 cp_pbodr & tpmsk) | podr;
  				immr->im_cpm.cp_pbpar |= ppar;
  			} else if (2 == portnum) {	/* port C */
  				immr->im_ioport.iop_pcpar &= tpmsk;
  				immr->im_ioport.iop_pcdat =
  					(immr->im_ioport.
  					 iop_pcdat & tpmsk) | pdat;
  				immr->im_ioport.iop_pcdir =
  					(immr->im_ioport.
  					 iop_pcdir & tpmsk) | pdir;
  				immr->im_ioport.iop_pcint =
  					(immr->im_ioport.
  					 iop_pcint & tpmsk) | pint;
  				immr->im_ioport.iop_pcso =
  					(immr->im_ioport.
  					 iop_pcso & tpmsk) | psor;
  				immr->im_ioport.iop_pcpar |= ppar;
  			} else if (3 == portnum) {	/* port D */
  				immr->im_ioport.iop_pdpar &= tpmsk;
  				immr->im_ioport.iop_pddat =
  					(immr->im_ioport.
  					 iop_pddat & tpmsk) | pdat;
  				immr->im_ioport.iop_pddir =
  					(immr->im_ioport.
  					 iop_pddir & tpmsk) | pdir;
  				immr->im_ioport.iop_pdpar |= ppar;
c609719b8   wdenk   Initial revision
317
318
  			}
  		}
bf9e3b38f   wdenk   * Some code cleanup
319
  	}
c609719b8   wdenk   Initial revision
320

bf9e3b38f   wdenk   * Some code cleanup
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
  	PRINTF ("%s:%d: Port A:
    papar=0x%.4x  padir=0x%.4x"
  		"  paodr=0x%.4x
    padat=0x%.4x
  ", __FUNCTION__, __LINE__,
  		immr->im_ioport.iop_papar, immr->im_ioport.iop_padir,
  		immr->im_ioport.iop_paodr, immr->im_ioport.iop_padat);
  	PRINTF ("%s:%d: Port B:
    pbpar=0x%.8x  pbdir=0x%.8x"
  		"  pbodr=0x%.8x
    pbdat=0x%.8x
  ", __FUNCTION__, __LINE__,
  		immr->im_cpm.cp_pbpar, immr->im_cpm.cp_pbdir,
  		immr->im_cpm.cp_pbodr, immr->im_cpm.cp_pbdat);
  	PRINTF ("%s:%d: Port C:
    pcpar=0x%.4x  pcdir=0x%.4x"
  		"  pcdat=0x%.4x
    pcso=0x%.4x  pcint=0x%.4x
    ",
  		__FUNCTION__, __LINE__, immr->im_ioport.iop_pcpar,
  		immr->im_ioport.iop_pcdir, immr->im_ioport.iop_pcdat,
  		immr->im_ioport.iop_pcso, immr->im_ioport.iop_pcint);
  	PRINTF ("%s:%d: Port D:
    pdpar=0x%.4x  pddir=0x%.4x"
  		"  pddat=0x%.4x
  ", __FUNCTION__, __LINE__,
  		immr->im_ioport.iop_pdpar, immr->im_ioport.iop_pddir,
  		immr->im_ioport.iop_pddat);
c609719b8   wdenk   Initial revision
349
  }