omap3_spi.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. /*
  2. * Register definitions for the OMAP3 McSPI Controller
  3. *
  4. * Copyright (C) 2010 Dirk Behme <dirk.behme@googlemail.com>
  5. *
  6. * Parts taken from linux/drivers/spi/omap2_mcspi.c
  7. * Copyright (C) 2005, 2006 Nokia Corporation
  8. *
  9. * Modified by Ruslan Araslanov <ruslan.araslanov@vitecmm.com>
  10. *
  11. * SPDX-License-Identifier: GPL-2.0+
  12. */
  13. #ifndef _OMAP3_SPI_H_
  14. #define _OMAP3_SPI_H_
  15. #if defined(CONFIG_AM33XX) || defined(CONFIG_AM43XX)
  16. #define OMAP3_MCSPI1_BASE 0x48030100
  17. #define OMAP3_MCSPI2_BASE 0x481A0100
  18. #else
  19. #define OMAP3_MCSPI1_BASE 0x48098000
  20. #define OMAP3_MCSPI2_BASE 0x4809A000
  21. #define OMAP3_MCSPI3_BASE 0x480B8000
  22. #define OMAP3_MCSPI4_BASE 0x480BA000
  23. #endif
  24. #define OMAP3_MCSPI_MAX_FREQ 48000000
  25. /* OMAP3 McSPI registers */
  26. struct mcspi_channel {
  27. unsigned int chconf; /* 0x2C, 0x40, 0x54, 0x68 */
  28. unsigned int chstat; /* 0x30, 0x44, 0x58, 0x6C */
  29. unsigned int chctrl; /* 0x34, 0x48, 0x5C, 0x70 */
  30. unsigned int tx; /* 0x38, 0x4C, 0x60, 0x74 */
  31. unsigned int rx; /* 0x3C, 0x50, 0x64, 0x78 */
  32. };
  33. struct mcspi {
  34. unsigned char res1[0x10];
  35. unsigned int sysconfig; /* 0x10 */
  36. unsigned int sysstatus; /* 0x14 */
  37. unsigned int irqstatus; /* 0x18 */
  38. unsigned int irqenable; /* 0x1C */
  39. unsigned int wakeupenable; /* 0x20 */
  40. unsigned int syst; /* 0x24 */
  41. unsigned int modulctrl; /* 0x28 */
  42. struct mcspi_channel channel[4]; /* channel0: 0x2C - 0x3C, bus 0 & 1 & 2 & 3 */
  43. /* channel1: 0x40 - 0x50, bus 0 & 1 */
  44. /* channel2: 0x54 - 0x64, bus 0 & 1 */
  45. /* channel3: 0x68 - 0x78, bus 0 */
  46. };
  47. /* per-register bitmasks */
  48. #define OMAP3_MCSPI_SYSCONFIG_SMARTIDLE (2 << 3)
  49. #define OMAP3_MCSPI_SYSCONFIG_ENAWAKEUP BIT(2)
  50. #define OMAP3_MCSPI_SYSCONFIG_AUTOIDLE BIT(0)
  51. #define OMAP3_MCSPI_SYSCONFIG_SOFTRESET BIT(1)
  52. #define OMAP3_MCSPI_SYSSTATUS_RESETDONE BIT(0)
  53. #define OMAP3_MCSPI_MODULCTRL_SINGLE BIT(0)
  54. #define OMAP3_MCSPI_MODULCTRL_MS BIT(2)
  55. #define OMAP3_MCSPI_MODULCTRL_STEST BIT(3)
  56. #define OMAP3_MCSPI_CHCONF_PHA BIT(0)
  57. #define OMAP3_MCSPI_CHCONF_POL BIT(1)
  58. #define OMAP3_MCSPI_CHCONF_CLKD_MASK GENMASK(5, 2)
  59. #define OMAP3_MCSPI_CHCONF_EPOL BIT(6)
  60. #define OMAP3_MCSPI_CHCONF_WL_MASK GENMASK(11, 7)
  61. #define OMAP3_MCSPI_CHCONF_TRM_RX_ONLY BIT(12)
  62. #define OMAP3_MCSPI_CHCONF_TRM_TX_ONLY BIT(13)
  63. #define OMAP3_MCSPI_CHCONF_TRM_MASK GENMASK(13, 12)
  64. #define OMAP3_MCSPI_CHCONF_DMAW BIT(14)
  65. #define OMAP3_MCSPI_CHCONF_DMAR BIT(15)
  66. #define OMAP3_MCSPI_CHCONF_DPE0 BIT(16)
  67. #define OMAP3_MCSPI_CHCONF_DPE1 BIT(17)
  68. #define OMAP3_MCSPI_CHCONF_IS BIT(18)
  69. #define OMAP3_MCSPI_CHCONF_TURBO BIT(19)
  70. #define OMAP3_MCSPI_CHCONF_FORCE BIT(20)
  71. #define OMAP3_MCSPI_CHSTAT_RXS BIT(0)
  72. #define OMAP3_MCSPI_CHSTAT_TXS BIT(1)
  73. #define OMAP3_MCSPI_CHSTAT_EOT BIT(2)
  74. #define OMAP3_MCSPI_CHCTRL_EN BIT(0)
  75. #define OMAP3_MCSPI_CHCTRL_DIS (0 << 0)
  76. #define OMAP3_MCSPI_WAKEUPENABLE_WKEN BIT(0)
  77. struct omap3_spi_slave {
  78. struct spi_slave slave;
  79. struct mcspi *regs;
  80. unsigned int freq;
  81. unsigned int mode;
  82. };
  83. static inline struct omap3_spi_slave *to_omap3_spi(struct spi_slave *slave)
  84. {
  85. return container_of(slave, struct omap3_spi_slave, slave);
  86. }
  87. int omap3_spi_txrx(struct spi_slave *slave, unsigned int len, const void *txp,
  88. void *rxp, unsigned long flags);
  89. int omap3_spi_write(struct spi_slave *slave, unsigned int len, const void *txp,
  90. unsigned long flags);
  91. int omap3_spi_read(struct spi_slave *slave, unsigned int len, void *rxp,
  92. unsigned long flags);
  93. #endif /* _OMAP3_SPI_H_ */