davinci_spi.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. /*
  2. * Copyright (C) 2009 Texas Instruments Incorporated - http://www.ti.com/
  3. *
  4. * Register definitions for the DaVinci SPI Controller
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU General Public License as
  8. * published by the Free Software Foundation; either version 2 of
  9. * the License, or (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program; if not, write to the Free Software
  18. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  19. * MA 02111-1307 USA
  20. */
  21. #ifndef _DAVINCI_SPI_H_
  22. #define _DAVINCI_SPI_H_
  23. struct davinci_spi_regs {
  24. dv_reg gcr0; /* 0x00 */
  25. dv_reg gcr1; /* 0x04 */
  26. dv_reg int0; /* 0x08 */
  27. dv_reg lvl; /* 0x0c */
  28. dv_reg flg; /* 0x10 */
  29. dv_reg pc0; /* 0x14 */
  30. dv_reg pc1; /* 0x18 */
  31. dv_reg pc2; /* 0x1c */
  32. dv_reg pc3; /* 0x20 */
  33. dv_reg pc4; /* 0x24 */
  34. dv_reg pc5; /* 0x28 */
  35. dv_reg rsvd[3];
  36. dv_reg dat0; /* 0x38 */
  37. dv_reg dat1; /* 0x3c */
  38. dv_reg buf; /* 0x40 */
  39. dv_reg emu; /* 0x44 */
  40. dv_reg delay; /* 0x48 */
  41. dv_reg def; /* 0x4c */
  42. dv_reg fmt0; /* 0x50 */
  43. dv_reg fmt1; /* 0x54 */
  44. dv_reg fmt2; /* 0x58 */
  45. dv_reg fmt3; /* 0x5c */
  46. dv_reg intvec0; /* 0x60 */
  47. dv_reg intvec1; /* 0x64 */
  48. };
  49. #define BIT(x) (1 << (x))
  50. /* SPIGCR0 */
  51. #define SPIGCR0_SPIENA_MASK 0x1
  52. #define SPIGCR0_SPIRST_MASK 0x0
  53. /* SPIGCR0 */
  54. #define SPIGCR1_CLKMOD_MASK BIT(1)
  55. #define SPIGCR1_MASTER_MASK BIT(0)
  56. #define SPIGCR1_SPIENA_MASK BIT(24)
  57. /* SPIPC0 */
  58. #define SPIPC0_DIFUN_MASK BIT(11) /* SIMO */
  59. #define SPIPC0_DOFUN_MASK BIT(10) /* SOMI */
  60. #define SPIPC0_CLKFUN_MASK BIT(9) /* CLK */
  61. #define SPIPC0_EN0FUN_MASK BIT(0)
  62. /* SPIFMT0 */
  63. #define SPIFMT_SHIFTDIR_SHIFT 20
  64. #define SPIFMT_POLARITY_SHIFT 17
  65. #define SPIFMT_PHASE_SHIFT 16
  66. #define SPIFMT_PRESCALE_SHIFT 8
  67. /* SPIDAT1 */
  68. #define SPIDAT1_CSHOLD_SHIFT 28
  69. #define SPIDAT1_CSNR_SHIFT 16
  70. /* SPIDELAY */
  71. #define SPI_C2TDELAY_SHIFT 24
  72. #define SPI_T2CDELAY_SHIFT 16
  73. /* SPIBUF */
  74. #define SPIBUF_RXEMPTY_MASK BIT(31)
  75. #define SPIBUF_TXFULL_MASK BIT(29)
  76. /* SPIDEF */
  77. #define SPIDEF_CSDEF0_MASK BIT(0)
  78. struct davinci_spi_slave {
  79. struct spi_slave slave;
  80. struct davinci_spi_regs *regs;
  81. unsigned int freq;
  82. };
  83. static inline struct davinci_spi_slave *to_davinci_spi(struct spi_slave *slave)
  84. {
  85. return container_of(slave, struct davinci_spi_slave, slave);
  86. }
  87. #endif /* _DAVINCI_SPI_H_ */