spi.h 1.8 KB

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