bcm63xx_dev_spi.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. #ifndef BCM63XX_DEV_SPI_H
  2. #define BCM63XX_DEV_SPI_H
  3. #include <linux/types.h>
  4. #include <bcm63xx_io.h>
  5. #include <bcm63xx_regs.h>
  6. int __init bcm63xx_spi_register(void);
  7. struct bcm63xx_spi_pdata {
  8. unsigned int fifo_size;
  9. unsigned int msg_type_shift;
  10. unsigned int msg_ctl_width;
  11. int bus_num;
  12. int num_chipselect;
  13. };
  14. enum bcm63xx_regs_spi {
  15. SPI_CMD,
  16. SPI_INT_STATUS,
  17. SPI_INT_MASK_ST,
  18. SPI_INT_MASK,
  19. SPI_ST,
  20. SPI_CLK_CFG,
  21. SPI_FILL_BYTE,
  22. SPI_MSG_TAIL,
  23. SPI_RX_TAIL,
  24. SPI_MSG_CTL,
  25. SPI_MSG_DATA,
  26. SPI_RX_DATA,
  27. };
  28. #define __GEN_SPI_RSET_BASE(__cpu, __rset) \
  29. case SPI_## __rset: \
  30. return SPI_## __cpu ##_## __rset;
  31. #define __GEN_SPI_RSET(__cpu) \
  32. switch (reg) { \
  33. __GEN_SPI_RSET_BASE(__cpu, CMD) \
  34. __GEN_SPI_RSET_BASE(__cpu, INT_STATUS) \
  35. __GEN_SPI_RSET_BASE(__cpu, INT_MASK_ST) \
  36. __GEN_SPI_RSET_BASE(__cpu, INT_MASK) \
  37. __GEN_SPI_RSET_BASE(__cpu, ST) \
  38. __GEN_SPI_RSET_BASE(__cpu, CLK_CFG) \
  39. __GEN_SPI_RSET_BASE(__cpu, FILL_BYTE) \
  40. __GEN_SPI_RSET_BASE(__cpu, MSG_TAIL) \
  41. __GEN_SPI_RSET_BASE(__cpu, RX_TAIL) \
  42. __GEN_SPI_RSET_BASE(__cpu, MSG_CTL) \
  43. __GEN_SPI_RSET_BASE(__cpu, MSG_DATA) \
  44. __GEN_SPI_RSET_BASE(__cpu, RX_DATA) \
  45. }
  46. #define __GEN_SPI_REGS_TABLE(__cpu) \
  47. [SPI_CMD] = SPI_## __cpu ##_CMD, \
  48. [SPI_INT_STATUS] = SPI_## __cpu ##_INT_STATUS, \
  49. [SPI_INT_MASK_ST] = SPI_## __cpu ##_INT_MASK_ST, \
  50. [SPI_INT_MASK] = SPI_## __cpu ##_INT_MASK, \
  51. [SPI_ST] = SPI_## __cpu ##_ST, \
  52. [SPI_CLK_CFG] = SPI_## __cpu ##_CLK_CFG, \
  53. [SPI_FILL_BYTE] = SPI_## __cpu ##_FILL_BYTE, \
  54. [SPI_MSG_TAIL] = SPI_## __cpu ##_MSG_TAIL, \
  55. [SPI_RX_TAIL] = SPI_## __cpu ##_RX_TAIL, \
  56. [SPI_MSG_CTL] = SPI_## __cpu ##_MSG_CTL, \
  57. [SPI_MSG_DATA] = SPI_## __cpu ##_MSG_DATA, \
  58. [SPI_RX_DATA] = SPI_## __cpu ##_RX_DATA,
  59. static inline unsigned long bcm63xx_spireg(enum bcm63xx_regs_spi reg)
  60. {
  61. #ifdef BCMCPU_RUNTIME_DETECT
  62. extern const unsigned long *bcm63xx_regs_spi;
  63. return bcm63xx_regs_spi[reg];
  64. #else
  65. #ifdef CONFIG_BCM63XX_CPU_6338
  66. __GEN_SPI_RSET(6338)
  67. #endif
  68. #ifdef CONFIG_BCM63XX_CPU_6348
  69. __GEN_SPI_RSET(6348)
  70. #endif
  71. #ifdef CONFIG_BCM63XX_CPU_6358
  72. __GEN_SPI_RSET(6358)
  73. #endif
  74. #ifdef CONFIG_BCM63XX_CPU_6368
  75. __GEN_SPI_RSET(6368)
  76. #endif
  77. #endif
  78. return 0;
  79. }
  80. #endif /* BCM63XX_DEV_SPI_H */