xref: /rk3399_rockchip-uboot/include/ioports.h (revision 9c4c5ae3e10e4f2ca799aacbb74e1f5adb86e0b5)
10f89ba43Swdenk /*
20f89ba43Swdenk  * definitions for MPC8260 I/O Ports
30f89ba43Swdenk  *
40f89ba43Swdenk  * (in addition to those provided in <asm/immap_8260.h>)
50f89ba43Swdenk  *
60f89ba43Swdenk  * Murray.Jensen@cmst.csiro.au, 20-Oct-00
70f89ba43Swdenk  */
80f89ba43Swdenk 
90f89ba43Swdenk /*
100f89ba43Swdenk  * this structure mirrors the layout of the five port registers in
110f89ba43Swdenk  * the internal memory map - see iop8260_t in <asm/immap_8260.h>
120f89ba43Swdenk  */
130f89ba43Swdenk typedef struct {
140f89ba43Swdenk     unsigned int pdir;		/* Port Data Direction Register (35-3) */
150f89ba43Swdenk     unsigned int ppar;		/* Port Pin Assignment Register (35-4) */
160f89ba43Swdenk     unsigned int psor;		/* Port Special Options Register (35-5) */
170f89ba43Swdenk     unsigned int podr;		/* Port Open Drain Register (35-2) */
180f89ba43Swdenk     unsigned int pdat;		/* Port Data Register (35-3) */
190f89ba43Swdenk } ioport_t;
200f89ba43Swdenk 
210f89ba43Swdenk /*
220f89ba43Swdenk  * this macro calculates the address within the internal
230f89ba43Swdenk  * memory map (im) of the set of registers for a port (idx)
240f89ba43Swdenk  *
250f89ba43Swdenk  * the internal memory map aligns the above structure on
260f89ba43Swdenk  * a 0x20 byte boundary
270f89ba43Swdenk  */
28*9c4c5ae3SJon Loeliger #ifdef CONFIG_MPC85xx
2942d1f039Swdenk #define ioport_addr(im, idx) (ioport_t *)((uint)&((im)->im_cpm.im_cpm_iop) + ((idx)*0x20))
3042d1f039Swdenk #else
310f89ba43Swdenk #define ioport_addr(im, idx) (ioport_t *)((uint)&(im)->im_ioport + ((idx)*0x20))
3242d1f039Swdenk #endif
330f89ba43Swdenk 
340f89ba43Swdenk /*
350f89ba43Swdenk  * this structure provides configuration
360f89ba43Swdenk  * information for one port pin
370f89ba43Swdenk  */
380f89ba43Swdenk typedef struct {
390f89ba43Swdenk     unsigned char conf:1;	/* if 1, configure this port */
400f89ba43Swdenk     unsigned char ppar:1;	/* Port Pin Assignment Register (35-4) */
410f89ba43Swdenk     unsigned char psor:1;	/* Port Special Options Register (35-2) */
420f89ba43Swdenk     unsigned char pdir:1;	/* Port Data Direction Register (35-3) */
430f89ba43Swdenk     unsigned char podr:1;	/* Port Open Drain Register (35-2) */
440f89ba43Swdenk     unsigned char pdat:1;	/* Port Data Register (35-2) */
450f89ba43Swdenk } iop_conf_t;
460f89ba43Swdenk 
470f89ba43Swdenk /*
480f89ba43Swdenk  * a table that contains configuration information for all 32 pins
490f89ba43Swdenk  * of all four MPC8260 I/O ports.
500f89ba43Swdenk  *
510f89ba43Swdenk  * NOTE: in the second dimension of this table, index 0 refers to pin 31
520f89ba43Swdenk  * and index 31 refers to pin 0. this made the code in the table look more
530f89ba43Swdenk  * like the table in the 8260UM (and in the hymod manuals).
540f89ba43Swdenk  */
550f89ba43Swdenk extern const iop_conf_t iop_conf_tab[4][32];
56