pmc440.h 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. /*
  2. * (C) Copyright 2007-2008
  3. * Matthias Fuchs, esd gmbh, matthias.fuchs@esd-electronics.com.
  4. *
  5. * See file CREDITS for list of people who contributed to this
  6. * project.
  7. *
  8. * This program is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU General Public License as
  10. * published by the Free Software Foundation; either version 2 of
  11. * the License, or (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, write to the Free Software
  20. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  21. * MA 02111-1307 USA
  22. */
  23. #ifndef __PMC440_H__
  24. #define __PMC440_H__
  25. /*
  26. * GPIOs
  27. */
  28. #define GPIO1_INTA_FAKE (0x80000000 >> (45-32)) /* GPIO45 OD */
  29. #define GPIO1_NONMONARCH (0x80000000 >> (63-32)) /* GPIO63 I */
  30. #define GPIO1_PPC_EREADY (0x80000000 >> (62-32)) /* GPIO62 I/O */
  31. #define GPIO1_M66EN (0x80000000 >> (61-32)) /* GPIO61 I */
  32. #define GPIO1_POST_N (0x80000000 >> (60-32)) /* GPIO60 O */
  33. #define GPIO1_IOEN_N (0x80000000 >> (50-32)) /* GPIO50 O */
  34. #define GPIO1_HWID_MASK (0xf0000000 >> (56-32)) /* GPIO56..59 I */
  35. #define GPIO1_USB_PWR_N (0x80000000 >> (32-32)) /* GPIO32 I */
  36. #define GPIO0_LED_RUN_N (0x80000000 >> 30) /* GPIO30 O */
  37. #define GPIO0_EP_EEP (0x80000000 >> 23) /* GPIO23 O */
  38. #define GPIO0_USB_ID (0x80000000 >> 21) /* GPIO21 I */
  39. #define GPIO0_USB_PRSNT (0x80000000 >> 20) /* GPIO20 I */
  40. /*
  41. * FPGA programming pin configuration
  42. */
  43. #define GPIO1_FPGA_PRG (0x80000000 >> (53-32)) /* FPGA program pin (ppc output) */
  44. #define GPIO1_FPGA_CLK (0x80000000 >> (51-32)) /* FPGA clk pin (ppc output) */
  45. #define GPIO1_FPGA_DATA (0x80000000 >> (52-32)) /* FPGA data pin (ppc output) */
  46. #define GPIO1_FPGA_DONE (0x80000000 >> (55-32)) /* FPGA done pin (ppc input) */
  47. #define GPIO1_FPGA_INIT (0x80000000 >> (54-32)) /* FPGA init pin (ppc input) */
  48. #define GPIO0_FPGA_FORCEINIT (0x80000000 >> 27) /* low: force INIT# low */
  49. /*
  50. * FPGA interface
  51. */
  52. #define FPGA_BA CONFIG_SYS_FPGA_BASE0
  53. #define FPGA_OUT32(p,v) out_be32(((void*)(p)), (v))
  54. #define FPGA_IN32(p) in_be32((void*)(p))
  55. #define FPGA_SETBITS(p,v) out_be32(((void*)(p)), in_be32((void*)(p)) | (v))
  56. #define FPGA_CLRBITS(p,v) out_be32(((void*)(p)), in_be32((void*)(p)) & ~(v))
  57. struct pmc440_fifo_s {
  58. u32 data;
  59. u32 ctrl;
  60. };
  61. /* fifo ctrl register */
  62. #define FIFO_IE (1 << 15)
  63. #define FIFO_OVERFLOW (1 << 10)
  64. #define FIFO_EMPTY (1 << 9)
  65. #define FIFO_FULL (1 << 8)
  66. #define FIFO_LEVEL_MASK 0x000000ff
  67. #define FIFO_COUNT 4
  68. struct pmc440_fpga_s {
  69. u32 ctrla;
  70. u32 status;
  71. u32 ctrlb;
  72. u32 pad1[0x40 / sizeof(u32) - 3];
  73. u32 irig_time; /* offset: 0x0040 */
  74. u32 irig_tod;
  75. u32 irig_cf;
  76. u32 pad2;
  77. u32 irig_rx_time; /* offset: 0x0050 */
  78. u32 pad3[3];
  79. u32 hostctrl; /* offset: 0x0060 */
  80. u32 pad4[0x20 / sizeof(u32) - 1];
  81. struct pmc440_fifo_s fifo[FIFO_COUNT]; /* 0x0080..0x009f */
  82. };
  83. typedef struct pmc440_fpga_s pmc440_fpga_t;
  84. /* ctrl register */
  85. #define CTRL_HOST_IE (1 << 8)
  86. /* outputs */
  87. #define RESET_EN (1 << 31)
  88. #define CLOCK_EN (1 << 30)
  89. #define RESET_OUT (1 << 19)
  90. #define CLOCK_OUT (1 << 22)
  91. #define RESET_OUT (1 << 19)
  92. #define IRIGB_R_OUT (1 << 14)
  93. /* status register */
  94. #define STATUS_VERSION_SHIFT 24
  95. #define STATUS_VERSION_MASK 0xff000000
  96. #define STATUS_HWREV_SHIFT 20
  97. #define STATUS_HWREV_MASK 0x00f00000
  98. #define STATUS_CAN_ISF (1 << 11)
  99. #define STATUS_CSTM_ISF (1 << 10)
  100. #define STATUS_FIFO_ISF (1 << 9)
  101. #define STATUS_HOST_ISF (1 << 8)
  102. /* inputs */
  103. #define RESET_IN (1 << 0)
  104. #define CLOCK_IN (1 << 1)
  105. #define IRIGB_R_IN (1 << 5)
  106. /* hostctrl register */
  107. #define HOSTCTRL_PMCRSTOUT_GATE (1 << 17)
  108. #define HOSTCTRL_PMCRSTOUT_FLAG (1 << 16)
  109. #define HOSTCTRL_CSTM1IE_GATE (1 << 7)
  110. #define HOSTCTRL_CSTM1IW_FLAG (1 << 6)
  111. #define HOSTCTRL_CSTM0IE_GATE (1 << 5)
  112. #define HOSTCTRL_CSTM0IW_FLAG (1 << 4)
  113. #define HOSTCTRL_FIFOIE_GATE (1 << 3)
  114. #define HOSTCTRL_FIFOIE_FLAG (1 << 2)
  115. #define HOSTCTRL_HCINT_GATE (1 << 1)
  116. #define HOSTCTRL_HCINT_FLAG (1 << 0)
  117. #define NGCC_CTRL_BASE (CONFIG_SYS_FPGA_BASE0 + 0x80000)
  118. #define NGCC_CTRL_FPGARST_N (1 << 2)
  119. /*
  120. * FPGA to PPC interrupt
  121. */
  122. #define IRQ0_FPGA (32+28) /* UIC1 - FPGA internal */
  123. #define IRQ1_FPGA (32+30) /* UIC1 - custom module */
  124. #define IRQ2_FPGA (64+ 3) /* UIC2 - custom module / CAN */
  125. #define IRQ_ETH0 (64+ 4) /* UIC2 */
  126. #define IRQ_ETH1 ( 27) /* UIC0 */
  127. #define IRQ_RTC (64+ 0) /* UIC2 */
  128. #define IRQ_PCIA (64+ 1) /* UIC2 */
  129. #define IRQ_PCIB (32+18) /* UIC1 */
  130. #define IRQ_PCIC (32+19) /* UIC1 */
  131. #define IRQ_PCID (32+20) /* UIC1 */
  132. #endif /* __PMC440_H__ */