nios-io.h 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. /*
  2. * (C) Copyright 2003, Psyent Corporation <www.psyent.com>
  3. * Scott McNutt <smcnutt@psyent.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. /*************************************************************************
  24. * Altera Nios Standard Peripherals
  25. ************************************************************************/
  26. #ifndef __NIOSIO_H__
  27. #define __NIOSIO_H__
  28. /*------------------------------------------------------------------------
  29. * UART (http://www.altera.com/literature/ds/ds_nios_uart.pdf)
  30. *----------------------------------------------------------------------*/
  31. typedef volatile struct nios_uart_t {
  32. unsigned rxdata; /* Rx data reg */
  33. unsigned txdata; /* Tx data reg */
  34. unsigned status; /* Status reg */
  35. unsigned control; /* Control reg */
  36. unsigned divisor; /* Baud rate divisor reg */
  37. unsigned endofpacket; /* End-of-packet reg */
  38. }nios_uart_t;
  39. /* status register */
  40. #define NIOS_UART_PE (1 << 0) /* parity error */
  41. #define NIOS_UART_FE (1 << 1) /* frame error */
  42. #define NIOS_UART_BRK (1 << 2) /* break detect */
  43. #define NIOS_UART_ROE (1 << 3) /* rx overrun */
  44. #define NIOS_UART_TOE (1 << 4) /* tx overrun */
  45. #define NIOS_UART_TMT (1 << 5) /* tx empty */
  46. #define NIOS_UART_TRDY (1 << 6) /* tx ready */
  47. #define NIOS_UART_RRDY (1 << 7) /* rx ready */
  48. #define NIOS_UART_E (1 << 8) /* exception */
  49. #define NIOS_UART_DCTS (1 << 10) /* cts change */
  50. #define NIOS_UART_CTS (1 << 11) /* cts */
  51. #define NIOS_UART_EOP (1 << 12) /* eop detected */
  52. /* control register */
  53. #define NIOS_UART_IPE (1 << 0) /* parity error int ena*/
  54. #define NIOS_UART_IFE (1 << 1) /* frame error int ena */
  55. #define NIOS_UART_IBRK (1 << 2) /* break detect int ena */
  56. #define NIOS_UART_IROE (1 << 3) /* rx overrun int ena */
  57. #define NIOS_UART_ITOE (1 << 4) /* tx overrun int ena */
  58. #define NIOS_UART_ITMT (1 << 5) /* tx empty int ena */
  59. #define NIOS_UART_ITRDY (1 << 6) /* tx ready int ena */
  60. #define NIOS_UART_IRRDY (1 << 7) /* rx ready int ena */
  61. #define NIOS_UART_IE (1 << 8) /* exception int ena */
  62. #define NIOS_UART_TBRK (1 << 9) /* transmit break */
  63. #define NIOS_UART_IDCTS (1 << 10) /* cts change int ena */
  64. #define NIOS_UART_RTS (1 << 11) /* rts */
  65. #define NIOS_UART_IEOP (1 << 12) /* eop detected int ena */
  66. /*------------------------------------------------------------------------
  67. * TIMER (http://www.altera.com/literature/ds/ds_nios_timer.pdf)
  68. *----------------------------------------------------------------------*/
  69. typedef volatile struct nios_timer_t {
  70. unsigned status; /* Timer status reg */
  71. unsigned control; /* Timer control reg */
  72. unsigned periodl; /* Timeout period low */
  73. unsigned periodh; /* Timeout period high */
  74. unsigned snapl; /* Snapshot low */
  75. unsigned snaph; /* Snapshot high */
  76. }nios_timer_t;
  77. /* status register */
  78. #define NIOS_TIMER_TO (1 << 0) /* Timeout */
  79. #define NIOS_TIMER_RUN (1 << 1) /* Timer running */
  80. /* control register */
  81. #define NIOS_TIMER_ITO (1 << 0) /* Timeout int ena */
  82. #define NIOS_TIMER_CONT (1 << 1) /* Continuous mode */
  83. #define NIOS_TIMER_START (1 << 2) /* Start timer */
  84. #define NIOS_TIMER_STOP (1 << 3) /* Stop timer */
  85. /*------------------------------------------------------------------------
  86. * PIO (http://www.altera.com/literature/ds/ds_nios_pio.pdf)
  87. *----------------------------------------------------------------------*/
  88. typedef volatile struct nios_pio_t {
  89. unsigned int data; /* Data value at each PIO in/out */
  90. unsigned int direction; /* Data direct. for each PIO bit */
  91. unsigned int interruptmask; /* Per-bit IRQ enable/disable */
  92. unsigned int edgecapture; /* Per-bit sync. edge detect & hold */
  93. }nios_pio_t;
  94. /* direction register */
  95. #define NIOS_PIO_OUT (1) /* PIO bit is output */
  96. #define NIOS_PIO_IN (0) /* PIO bit is input */
  97. /*------------------------------------------------------------------------
  98. * SPI (http://www.altera.com/literature/ds/ds_nios_spi.pdf)
  99. *----------------------------------------------------------------------*/
  100. typedef volatile struct nios_spi_t {
  101. unsigned rxdata; /* Rx data reg */
  102. unsigned txdata; /* Tx data reg */
  103. unsigned status; /* Status reg */
  104. unsigned control; /* Control reg */
  105. unsigned reserved; /* (master only) */
  106. unsigned slaveselect; /* SPI slave select mask (master only) */
  107. }nios_spi_t;
  108. /* status register */
  109. #define NIOS_SPI_ROE (1 << 3) /* rx overrun */
  110. #define NIOS_SPI_TOE (1 << 4) /* tx overrun */
  111. #define NIOS_SPI_TMT (1 << 5) /* tx empty */
  112. #define NIOS_SPI_TRDY (1 << 6) /* tx ready */
  113. #define NIOS_SPI_RRDY (1 << 7) /* rx ready */
  114. #define NIOS_SPI_E (1 << 8) /* exception */
  115. /* control register */
  116. #define NIOS_SPI_IROE (1 << 3) /* rx overrun int ena */
  117. #define NIOS_SPI_ITOE (1 << 4) /* tx overrun int ena */
  118. #define NIOS_SPI_ITRDY (1 << 6) /* tx ready int ena */
  119. #define NIOS_SPI_IRRDY (1 << 7) /* rx ready int ena */
  120. #define NIOS_SPI_IE (1 << 8) /* exception int ena */
  121. #define NIOS_SPI_SSO (1 << 10) /* override SS_n output */
  122. /*------------------------------------------------------------------------
  123. * ASMI
  124. *----------------------------------------------------------------------*/
  125. typedef volatile struct nios_asmi_t {
  126. unsigned rxdata; /* Rx data reg */
  127. unsigned txdata; /* Tx data reg */
  128. unsigned status; /* Status reg */
  129. unsigned control; /* Control reg */
  130. unsigned reserved;
  131. unsigned slavesel; /* Slave select */
  132. unsigned endofpacket; /* End-of-packet reg */
  133. }nios_asmi_t;
  134. /* status register */
  135. #define NIOS_ASMI_ROE (1 << 3) /* rx overrun */
  136. #define NIOS_ASMI_TOE (1 << 4) /* tx overrun */
  137. #define NIOS_ASMI_TMT (1 << 5) /* tx empty */
  138. #define NIOS_ASMI_TRDY (1 << 6) /* tx ready */
  139. #define NIOS_ASMI_RRDY (1 << 7) /* rx ready */
  140. #define NIOS_ASMI_E (1 << 8) /* exception */
  141. #define NIOS_ASMI_EOP (1 << 9) /* eop detected */
  142. /* control register */
  143. #define NIOS_ASMI_IROE (1 << 3) /* rx overrun int ena */
  144. #define NIOS_ASMI_ITOE (1 << 4) /* tx overrun int ena */
  145. #define NIOS_ASMI_ITRDY (1 << 6) /* tx ready int ena */
  146. #define NIOS_ASMI_IRRDY (1 << 7) /* rx ready int ena */
  147. #define NIOS_ASMI_IE (1 << 8) /* exception int ena */
  148. #define NIOS_ASMI_IEOP (1 << 9) /* rx eop int ena */
  149. #define NIOS_ASMI_SSO (1 << 10) /* slave select enable */
  150. /*------------------------------------------------------------------------
  151. * JTAG UART
  152. *----------------------------------------------------------------------*/
  153. typedef volatile struct nios_jtag_t {
  154. unsigned short rxcntl; /* Rx data/cntl reg */
  155. unsigned short txcntl; /* Tx data/cntl reg */
  156. unsigned short errcntl; /* Err dta/cntl reg */
  157. }nios_jtag_t;
  158. /* status register */
  159. #define NIOS_JTAG_TRDY (1 << 8) /* tx ready bit */
  160. #define NIOS_JTAG_RRDY (1 << 8) /* rx ready bit */
  161. #endif /* __NIOSIO_H__ */