spi.h 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. /*
  2. * (C) Copyright 2012 SAMSUNG Electronics
  3. * Padmavathi Venna <padma.v@samsung.com>
  4. *
  5. * SPDX-License-Identifier: GPL-2.0+
  6. */
  7. #ifndef __ASM_ARCH_EXYNOS_COMMON_SPI_H_
  8. #define __ASM_ARCH_EXYNOS_COMMON_SPI_H_
  9. #ifndef __ASSEMBLY__
  10. /* SPI peripheral register map; padded to 64KB */
  11. struct exynos_spi {
  12. unsigned int ch_cfg; /* 0x00 */
  13. unsigned char reserved0[4];
  14. unsigned int mode_cfg; /* 0x08 */
  15. unsigned int cs_reg; /* 0x0c */
  16. unsigned char reserved1[4];
  17. unsigned int spi_sts; /* 0x14 */
  18. unsigned int tx_data; /* 0x18 */
  19. unsigned int rx_data; /* 0x1c */
  20. unsigned int pkt_cnt; /* 0x20 */
  21. unsigned char reserved2[4];
  22. unsigned int swap_cfg; /* 0x28 */
  23. unsigned int fb_clk; /* 0x2c */
  24. unsigned char padding[0xffd0];
  25. };
  26. #define EXYNOS_SPI_MAX_FREQ 50000000
  27. #define SPI_TIMEOUT_MS 10
  28. #define SF_READ_DATA_CMD 0x3
  29. /* SPI_CHCFG */
  30. #define SPI_CH_HS_EN (1 << 6)
  31. #define SPI_CH_RST (1 << 5)
  32. #define SPI_SLAVE_MODE (1 << 4)
  33. #define SPI_CH_CPOL_L (1 << 3)
  34. #define SPI_CH_CPHA_B (1 << 2)
  35. #define SPI_RX_CH_ON (1 << 1)
  36. #define SPI_TX_CH_ON (1 << 0)
  37. /* SPI_MODECFG */
  38. #define SPI_MODE_CH_WIDTH_WORD (0x2 << 29)
  39. #define SPI_MODE_BUS_WIDTH_WORD (0x2 << 17)
  40. /* SPI_CSREG */
  41. #define SPI_SLAVE_SIG_INACT (1 << 0)
  42. /* SPI_STS */
  43. #define SPI_ST_TX_DONE (1 << 25)
  44. #define SPI_FIFO_LVL_MASK 0x1ff
  45. #define SPI_TX_LVL_OFFSET 6
  46. #define SPI_RX_LVL_OFFSET 15
  47. /* Feedback Delay */
  48. #define SPI_CLK_BYPASS (0 << 0)
  49. #define SPI_FB_DELAY_90 (1 << 0)
  50. #define SPI_FB_DELAY_180 (2 << 0)
  51. #define SPI_FB_DELAY_270 (3 << 0)
  52. /* Packet Count */
  53. #define SPI_PACKET_CNT_EN (1 << 16)
  54. /* Swap config */
  55. #define SPI_TX_SWAP_EN (1 << 0)
  56. #define SPI_TX_BYTE_SWAP (1 << 2)
  57. #define SPI_TX_HWORD_SWAP (1 << 3)
  58. #define SPI_TX_BYTE_SWAP (1 << 2)
  59. #define SPI_RX_SWAP_EN (1 << 4)
  60. #define SPI_RX_BYTE_SWAP (1 << 6)
  61. #define SPI_RX_HWORD_SWAP (1 << 7)
  62. #endif /* __ASSEMBLY__ */
  63. #endif