ark-spi.h 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. #ifndef ARK_SPI_H
  2. #define ARK_SPI_H
  3. /*
  4. * CSPI register definitions
  5. */
  6. #define ARK_ECSPI_CTRL_EN (1 << 0)
  7. #define ARK_ECSPI_CTRL_HW (1 << 1)
  8. #define ARK_ECSPI_CTRL_XCH (1 << 2)
  9. #define ARK_ECSPI_CTRL_SMC (1 << 3)
  10. #define ARK_ECSPI_CTRL_MODE(x) (1 << ((x) + 4))
  11. #define ARK_ECSPI_CTRL_BITCOUNT(x) (((x) & 0xfff) << 20)
  12. #define ARK_ECSPI_CTRL_PREDIV(x) (((x) & 0xF) << 12)
  13. #define ARK_ECSPI_CTRL_POSTDIV(x) (((x) & 0xF) << 8)
  14. #define ARK_ECSPI_CTRL_SELCHAN(x) (((x) & 0x3) << 18)
  15. #define ARK_ECSPI_CTRL_MAXBITS 0xfff
  16. #define ARK_ECSPI_CONFIG_SCLKPHA(cs) (1 << ((cs) + 0))
  17. #define ARK_ECSPI_CONFIG_SCLKPOL(cs) (1 << ((cs) + 4))
  18. #define ARK_ECSPI_CONFIG_SBBCTRL(cs) (1 << ((cs) + 8))
  19. #define ARK_ECSPI_CONFIG_SSBPOL(cs) (1 << ((cs) + 12))
  20. #define ARK_ECSPI_STAT_TE (1 << 0)
  21. #define ARK_ECSPI_STAT_TDR (1 << 1)
  22. #define ARK_ECSPI_STAT_TF (1 << 2)
  23. #define ARK_ECSPI_STAT_RR (1 << 3)
  24. #define ARK_ECSPI_STAT_RDR (1 << 4)
  25. #define ARK_ECSPI_STAT_RF (1 << 5)
  26. #define ARK_ECSPI_STAT_RO (1 << 6)
  27. #define ARK_ECSPI_STAT_TC (1 << 7)
  28. #define ARK_ECSPI_STAT_REN (1 << 8)
  29. #define ARK_ECSPI_PERIOD_32KHZ (1 << 15)
  30. #define MAX_SPI_BYTES 32
  31. /* CSPI registers */
  32. struct cspi_regs {
  33. u32 reserve0[2];
  34. u32 ctrl;
  35. u32 cfg;
  36. u32 intr;
  37. u32 dma;
  38. u32 stat;
  39. u32 period;
  40. u32 test;
  41. u32 msg;
  42. u32 reserve1[10];
  43. u32 rxdata;
  44. u32 reserve2[259];
  45. u32 txdata;
  46. };
  47. #endif /* ARK_SPI_H */