spi.h 3.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. /*
  2. * (C) Copyright 2011
  3. * eInfochips Ltd. <www.einfochips.com>
  4. * Written-by: Ajay Bhargav <ajay.bhargav@einfochips.com>
  5. *
  6. * (C) Copyright 2010
  7. * Marvell Semiconductor <www.marvell.com>
  8. *
  9. * See file CREDITS for list of people who contributed to this
  10. * project.
  11. *
  12. * This program is free software; you can redistribute it and/or
  13. * modify it under the terms of the GNU General Public License as
  14. * published by the Free Software Foundation; either version 2 of
  15. * the License, or (at your option) any later version.
  16. *
  17. * This program is distributed in the hope that it will be useful,
  18. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  20. * GNU General Public License for more details.
  21. *
  22. * You should have received a copy of the GNU General Public License
  23. * along with this program; if not, write to the Free Software
  24. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
  25. * MA 02110-1301 USA
  26. */
  27. #ifndef __ARMADA100_SPI_H_
  28. #define __ARMADA100_SPI_H_
  29. #include <asm/arch/armada100.h>
  30. #define CAT_BASE_ADDR(x) ARMD1_SSP ## x ## _BASE
  31. #define SSP_REG_BASE(x) CAT_BASE_ADDR(x)
  32. /*
  33. * SSP Serial Port Registers
  34. * refer Appendix A.26
  35. */
  36. struct ssp_reg {
  37. u32 sscr0; /* SSP Control Register 0 - 0x000 */
  38. u32 sscr1; /* SSP Control Register 1 - 0x004 */
  39. u32 sssr; /* SSP Status Register - 0x008 */
  40. u32 ssitr; /* SSP Interrupt Test Register - 0x00C */
  41. u32 ssdr; /* SSP Data Register - 0x010 */
  42. u32 pad1[5];
  43. u32 ssto; /* SSP Timeout Register - 0x028 */
  44. u32 sspsp; /* SSP Programmable Serial Protocol Register - 0x02C */
  45. u32 sstsa; /* SSP TX Timeslot Active Register - 0x030 */
  46. u32 ssrsa; /* SSP RX Timeslot Active Register - 0x034 */
  47. u32 sstss; /* SSP Timeslot Status Register - 0x038 */
  48. };
  49. #define DEFAULT_WORD_LEN 8
  50. #define SSP_FLUSH_NUM 0x2000
  51. #define RX_THRESH_DEF 8
  52. #define TX_THRESH_DEF 8
  53. #define TIMEOUT_DEF 1000
  54. #define SSCR1_RIE (1 << 0) /* Receive FIFO Interrupt Enable */
  55. #define SSCR1_TIE (1 << 1) /* Transmit FIFO Interrupt Enable */
  56. #define SSCR1_LBM (1 << 2) /* Loop-Back Mode */
  57. #define SSCR1_SPO (1 << 3) /* Motorola SPI SSPSCLK polarity
  58. setting */
  59. #define SSCR1_SPH (1 << 4) /* Motorola SPI SSPSCLK phase setting */
  60. #define SSCR1_MWDS (1 << 5) /* Microwire Transmit Data Size */
  61. #define SSCR1_TFT 0x03c0 /* Transmit FIFO Threshold (mask) */
  62. #define SSCR1_RFT 0x3c00 /* Receive FIFO Threshold (mask) */
  63. #define SSCR1_TXTRESH(x) ((x - 1) << 6) /* level [1..16] */
  64. #define SSCR1_RXTRESH(x) ((x - 1) << 10) /* level [1..16] */
  65. #define SSCR1_TINTE (1 << 19) /* Receiver Time-out
  66. Interrupt enable */
  67. #define SSCR0_DSS 0x0f /* Data Size Select (mask) */
  68. #define SSCR0_DATASIZE(x) (x - 1) /* Data Size Select [4..16] */
  69. #define SSCR0_FRF 0x30 /* FRame Format (mask) */
  70. #define SSCR0_MOTO (0x0 << 4) /* Motorola's Serial
  71. Peripheral Interface */
  72. #define SSCR0_TI (0x1 << 4) /* TI's Synchronous
  73. Serial Protocol (SSP) */
  74. #define SSCR0_NATIONAL (0x2 << 4) /* National Microwire */
  75. #define SSCR0_ECS (1 << 6) /* External clock select */
  76. #define SSCR0_SSE (1 << 7) /* Synchronous Serial Port
  77. Enable */
  78. #define SSSR_TNF (1 << 2) /* Transmit FIFO Not Full */
  79. #define SSSR_RNE (1 << 3) /* Receive FIFO Not Empty */
  80. #define SSSR_BSY (1 << 4) /* SSP Busy */
  81. #define SSSR_TFS (1 << 5) /* Transmit FIFO Service Request */
  82. #define SSSR_RFS (1 << 6) /* Receive FIFO Service Request */
  83. #define SSSR_ROR (1 << 7) /* Receive FIFO Overrun */
  84. #define SSSR_TINT (1 << 19) /* Receiver Time-out Interrupt */
  85. #endif /* __ARMADA100_SPI_H_ */