pxa2xx_spi.h 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. /*
  2. * Copyright (C) 2005 Stephen Street / StreetFire Sound Labs
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation; either version 2 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program; if not, write to the Free Software
  16. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  17. */
  18. #ifndef __linux_pxa2xx_spi_h
  19. #define __linux_pxa2xx_spi_h
  20. #include <linux/pxa2xx_ssp.h>
  21. #define PXA2XX_CS_ASSERT (0x01)
  22. #define PXA2XX_CS_DEASSERT (0x02)
  23. /* device.platform_data for SSP controller devices */
  24. struct pxa2xx_spi_master {
  25. u32 clock_enable;
  26. u16 num_chipselect;
  27. u8 enable_dma;
  28. };
  29. /* spi_board_info.controller_data for SPI slave devices,
  30. * copied to spi_device.platform_data ... mostly for dma tuning
  31. */
  32. struct pxa2xx_spi_chip {
  33. u8 tx_threshold;
  34. u8 rx_threshold;
  35. u8 dma_burst_size;
  36. u32 timeout;
  37. u8 enable_loopback;
  38. int gpio_cs;
  39. void (*cs_control)(u32 command);
  40. };
  41. #ifdef CONFIG_ARCH_PXA
  42. #include <linux/clk.h>
  43. #include <mach/dma.h>
  44. extern void pxa2xx_set_spi_info(unsigned id, struct pxa2xx_spi_master *info);
  45. #else
  46. /*
  47. * This is the implemtation for CE4100 on x86. ARM defines them in mach/ or
  48. * plat/ include path.
  49. * The CE4100 does not provide DMA support. This bits are here to let the driver
  50. * compile and will never be used. Maybe we get DMA support at a later point in
  51. * time.
  52. */
  53. #define DCSR(n) (n)
  54. #define DSADR(n) (n)
  55. #define DTADR(n) (n)
  56. #define DCMD(n) (n)
  57. #define DRCMR(n) (n)
  58. #define DCSR_RUN (1 << 31) /* Run Bit */
  59. #define DCSR_NODESC (1 << 30) /* No-Descriptor Fetch */
  60. #define DCSR_STOPIRQEN (1 << 29) /* Stop Interrupt Enable */
  61. #define DCSR_REQPEND (1 << 8) /* Request Pending (read-only) */
  62. #define DCSR_STOPSTATE (1 << 3) /* Stop State (read-only) */
  63. #define DCSR_ENDINTR (1 << 2) /* End Interrupt */
  64. #define DCSR_STARTINTR (1 << 1) /* Start Interrupt */
  65. #define DCSR_BUSERR (1 << 0) /* Bus Error Interrupt */
  66. #define DCSR_EORIRQEN (1 << 28) /* End of Receive Interrupt Enable */
  67. #define DCSR_EORJMPEN (1 << 27) /* Jump to next descriptor on EOR */
  68. #define DCSR_EORSTOPEN (1 << 26) /* STOP on an EOR */
  69. #define DCSR_SETCMPST (1 << 25) /* Set Descriptor Compare Status */
  70. #define DCSR_CLRCMPST (1 << 24) /* Clear Descriptor Compare Status */
  71. #define DCSR_CMPST (1 << 10) /* The Descriptor Compare Status */
  72. #define DCSR_EORINTR (1 << 9) /* The end of Receive */
  73. #define DRCMR_MAPVLD (1 << 7) /* Map Valid */
  74. #define DRCMR_CHLNUM 0x1f /* mask for Channel Number */
  75. #define DDADR_DESCADDR 0xfffffff0 /* Address of next descriptor */
  76. #define DDADR_STOP (1 << 0) /* Stop */
  77. #define DCMD_INCSRCADDR (1 << 31) /* Source Address Increment Setting. */
  78. #define DCMD_INCTRGADDR (1 << 30) /* Target Address Increment Setting. */
  79. #define DCMD_FLOWSRC (1 << 29) /* Flow Control by the source. */
  80. #define DCMD_FLOWTRG (1 << 28) /* Flow Control by the target. */
  81. #define DCMD_STARTIRQEN (1 << 22) /* Start Interrupt Enable */
  82. #define DCMD_ENDIRQEN (1 << 21) /* End Interrupt Enable */
  83. #define DCMD_ENDIAN (1 << 18) /* Device Endian-ness. */
  84. #define DCMD_BURST8 (1 << 16) /* 8 byte burst */
  85. #define DCMD_BURST16 (2 << 16) /* 16 byte burst */
  86. #define DCMD_BURST32 (3 << 16) /* 32 byte burst */
  87. #define DCMD_WIDTH1 (1 << 14) /* 1 byte width */
  88. #define DCMD_WIDTH2 (2 << 14) /* 2 byte width (HalfWord) */
  89. #define DCMD_WIDTH4 (3 << 14) /* 4 byte width (Word) */
  90. #define DCMD_LENGTH 0x01fff /* length mask (max = 8K - 1) */
  91. /*
  92. * Descriptor structure for PXA's DMA engine
  93. * Note: this structure must always be aligned to a 16-byte boundary.
  94. */
  95. typedef enum {
  96. DMA_PRIO_HIGH = 0,
  97. DMA_PRIO_MEDIUM = 1,
  98. DMA_PRIO_LOW = 2
  99. } pxa_dma_prio;
  100. /*
  101. * DMA registration
  102. */
  103. static inline int pxa_request_dma(char *name,
  104. pxa_dma_prio prio,
  105. void (*irq_handler)(int, void *),
  106. void *data)
  107. {
  108. return -ENODEV;
  109. }
  110. static inline void pxa_free_dma(int dma_ch)
  111. {
  112. }
  113. /*
  114. * The CE4100 does not have the clk framework implemented and SPI clock can
  115. * not be switched on/off or the divider changed.
  116. */
  117. static inline void clk_disable(struct clk *clk)
  118. {
  119. }
  120. static inline int clk_enable(struct clk *clk)
  121. {
  122. return 0;
  123. }
  124. static inline unsigned long clk_get_rate(struct clk *clk)
  125. {
  126. return 3686400;
  127. }
  128. #endif
  129. #endif