ioports.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. /*
  2. * definitions for MPC8xxx I/O Ports
  3. *
  4. * Murray.Jensen@cmst.csiro.au, 20-Oct-00
  5. */
  6. /*
  7. * this structure mirrors the layout of the five port registers in
  8. * the internal memory map
  9. */
  10. typedef struct {
  11. unsigned int pdir; /* Port Data Direction Register (35-3) */
  12. unsigned int ppar; /* Port Pin Assignment Register (35-4) */
  13. unsigned int psor; /* Port Special Options Register (35-5) */
  14. unsigned int podr; /* Port Open Drain Register (35-2) */
  15. unsigned int pdat; /* Port Data Register (35-3) */
  16. } ioport_t;
  17. /*
  18. * this macro calculates the address within the internal
  19. * memory map (im) of the set of registers for a port (idx)
  20. *
  21. * the internal memory map aligns the above structure on
  22. * a 0x20 byte boundary
  23. */
  24. #ifdef CONFIG_MPC85xx
  25. #define ioport_addr(im, idx) (ioport_t *)((uint)&(im->im_cpm_iop) + ((idx)*0x20))
  26. #else
  27. #define ioport_addr(im, idx) (ioport_t *)((uint)&(im)->im_ioport + ((idx)*0x20))
  28. #endif
  29. /*
  30. * this structure provides configuration
  31. * information for one port pin
  32. */
  33. typedef struct {
  34. unsigned char conf:1; /* if 1, configure this port */
  35. unsigned char ppar:1; /* Port Pin Assignment Register (35-4) */
  36. unsigned char psor:1; /* Port Special Options Register (35-2) */
  37. unsigned char pdir:1; /* Port Data Direction Register (35-3) */
  38. unsigned char podr:1; /* Port Open Drain Register (35-2) */
  39. unsigned char pdat:1; /* Port Data Register (35-2) */
  40. } iop_conf_t;
  41. /*
  42. * a table that contains configuration information for all 32 pins
  43. *
  44. * NOTE: in the second dimension of this table, index 0 refers to pin 31
  45. * and index 31 refers to pin 0. this made the code in the table look more
  46. * like the table in the 8260UM (and in the hymod manuals).
  47. */
  48. extern const iop_conf_t iop_conf_tab[4][32];
  49. typedef struct {
  50. unsigned char port;
  51. unsigned char pin;
  52. int dir;
  53. int open_drain;
  54. int assign;
  55. } qe_iop_conf_t;
  56. #define QE_IOP_TAB_END (-1)