pl022.h 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264
  1. /*
  2. * include/linux/amba/pl022.h
  3. *
  4. * Copyright (C) 2008-2009 ST-Ericsson AB
  5. * Copyright (C) 2006 STMicroelectronics Pvt. Ltd.
  6. *
  7. * Author: Linus Walleij <linus.walleij@stericsson.com>
  8. *
  9. * Initial version inspired by:
  10. * linux-2.6.17-rc3-mm1/drivers/spi/pxa2xx_spi.c
  11. * Initial adoption to PL022 by:
  12. * Sachin Verma <sachin.verma@st.com>
  13. *
  14. * This program is free software; you can redistribute it and/or modify
  15. * it under the terms of the GNU General Public License as published by
  16. * the Free Software Foundation; either version 2 of the License, or
  17. * (at your option) any later version.
  18. *
  19. * This program is distributed in the hope that it will be useful,
  20. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  21. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  22. * GNU General Public License for more details.
  23. */
  24. #ifndef _SSP_PL022_H
  25. #define _SSP_PL022_H
  26. #include <linux/device.h>
  27. /**
  28. * whether SSP is in loopback mode or not
  29. */
  30. enum ssp_loopback {
  31. LOOPBACK_DISABLED,
  32. LOOPBACK_ENABLED
  33. };
  34. /**
  35. * enum ssp_interface - interfaces allowed for this SSP Controller
  36. * @SSP_INTERFACE_MOTOROLA_SPI: Motorola Interface
  37. * @SSP_INTERFACE_TI_SYNC_SERIAL: Texas Instrument Synchronous Serial
  38. * interface
  39. * @SSP_INTERFACE_NATIONAL_MICROWIRE: National Semiconductor Microwire
  40. * interface
  41. * @SSP_INTERFACE_UNIDIRECTIONAL: Unidirectional interface (STn8810
  42. * &STn8815 only)
  43. */
  44. enum ssp_interface {
  45. SSP_INTERFACE_MOTOROLA_SPI,
  46. SSP_INTERFACE_TI_SYNC_SERIAL,
  47. SSP_INTERFACE_NATIONAL_MICROWIRE,
  48. SSP_INTERFACE_UNIDIRECTIONAL
  49. };
  50. /**
  51. * enum ssp_hierarchy - whether SSP is configured as Master or Slave
  52. */
  53. enum ssp_hierarchy {
  54. SSP_MASTER,
  55. SSP_SLAVE
  56. };
  57. /**
  58. * enum ssp_clock_params - clock parameters, to set SSP clock at a
  59. * desired freq
  60. */
  61. struct ssp_clock_params {
  62. u8 cpsdvsr; /* value from 2 to 254 (even only!) */
  63. u8 scr; /* value from 0 to 255 */
  64. };
  65. /**
  66. * enum ssp_rx_endian - endianess of Rx FIFO Data
  67. */
  68. enum ssp_rx_endian {
  69. SSP_RX_MSB,
  70. SSP_RX_LSB
  71. };
  72. /**
  73. * enum ssp_tx_endian - endianess of Tx FIFO Data
  74. */
  75. enum ssp_tx_endian {
  76. SSP_TX_MSB,
  77. SSP_TX_LSB
  78. };
  79. /**
  80. * enum ssp_data_size - number of bits in one data element
  81. */
  82. enum ssp_data_size {
  83. SSP_DATA_BITS_4 = 0x03, SSP_DATA_BITS_5, SSP_DATA_BITS_6,
  84. SSP_DATA_BITS_7, SSP_DATA_BITS_8, SSP_DATA_BITS_9,
  85. SSP_DATA_BITS_10, SSP_DATA_BITS_11, SSP_DATA_BITS_12,
  86. SSP_DATA_BITS_13, SSP_DATA_BITS_14, SSP_DATA_BITS_15,
  87. SSP_DATA_BITS_16, SSP_DATA_BITS_17, SSP_DATA_BITS_18,
  88. SSP_DATA_BITS_19, SSP_DATA_BITS_20, SSP_DATA_BITS_21,
  89. SSP_DATA_BITS_22, SSP_DATA_BITS_23, SSP_DATA_BITS_24,
  90. SSP_DATA_BITS_25, SSP_DATA_BITS_26, SSP_DATA_BITS_27,
  91. SSP_DATA_BITS_28, SSP_DATA_BITS_29, SSP_DATA_BITS_30,
  92. SSP_DATA_BITS_31, SSP_DATA_BITS_32
  93. };
  94. /**
  95. * enum ssp_mode - SSP mode of operation (Communication modes)
  96. */
  97. enum ssp_mode {
  98. INTERRUPT_TRANSFER,
  99. POLLING_TRANSFER,
  100. DMA_TRANSFER
  101. };
  102. /**
  103. * enum ssp_rx_level_trig - receive FIFO watermark level which triggers
  104. * IT: Interrupt fires when _N_ or more elements in RX FIFO.
  105. */
  106. enum ssp_rx_level_trig {
  107. SSP_RX_1_OR_MORE_ELEM,
  108. SSP_RX_4_OR_MORE_ELEM,
  109. SSP_RX_8_OR_MORE_ELEM,
  110. SSP_RX_16_OR_MORE_ELEM,
  111. SSP_RX_32_OR_MORE_ELEM
  112. };
  113. /**
  114. * Transmit FIFO watermark level which triggers (IT Interrupt fires
  115. * when _N_ or more empty locations in TX FIFO)
  116. */
  117. enum ssp_tx_level_trig {
  118. SSP_TX_1_OR_MORE_EMPTY_LOC,
  119. SSP_TX_4_OR_MORE_EMPTY_LOC,
  120. SSP_TX_8_OR_MORE_EMPTY_LOC,
  121. SSP_TX_16_OR_MORE_EMPTY_LOC,
  122. SSP_TX_32_OR_MORE_EMPTY_LOC
  123. };
  124. /**
  125. * enum SPI Clock Phase - clock phase (Motorola SPI interface only)
  126. * @SSP_CLK_RISING_EDGE: Receive data on rising edge
  127. * @SSP_CLK_FALLING_EDGE: Receive data on falling edge
  128. */
  129. enum ssp_spi_clk_phase {
  130. SSP_CLK_RISING_EDGE,
  131. SSP_CLK_FALLING_EDGE
  132. };
  133. /**
  134. * enum SPI Clock Polarity - clock polarity (Motorola SPI interface only)
  135. * @SSP_CLK_POL_IDLE_LOW: Low inactive level
  136. * @SSP_CLK_POL_IDLE_HIGH: High inactive level
  137. */
  138. enum ssp_spi_clk_pol {
  139. SSP_CLK_POL_IDLE_LOW,
  140. SSP_CLK_POL_IDLE_HIGH
  141. };
  142. /**
  143. * Microwire Conrol Lengths Command size in microwire format
  144. */
  145. enum ssp_microwire_ctrl_len {
  146. SSP_BITS_4 = 0x03, SSP_BITS_5, SSP_BITS_6,
  147. SSP_BITS_7, SSP_BITS_8, SSP_BITS_9,
  148. SSP_BITS_10, SSP_BITS_11, SSP_BITS_12,
  149. SSP_BITS_13, SSP_BITS_14, SSP_BITS_15,
  150. SSP_BITS_16, SSP_BITS_17, SSP_BITS_18,
  151. SSP_BITS_19, SSP_BITS_20, SSP_BITS_21,
  152. SSP_BITS_22, SSP_BITS_23, SSP_BITS_24,
  153. SSP_BITS_25, SSP_BITS_26, SSP_BITS_27,
  154. SSP_BITS_28, SSP_BITS_29, SSP_BITS_30,
  155. SSP_BITS_31, SSP_BITS_32
  156. };
  157. /**
  158. * enum Microwire Wait State
  159. * @SSP_MWIRE_WAIT_ZERO: No wait state inserted after last command bit
  160. * @SSP_MWIRE_WAIT_ONE: One wait state inserted after last command bit
  161. */
  162. enum ssp_microwire_wait_state {
  163. SSP_MWIRE_WAIT_ZERO,
  164. SSP_MWIRE_WAIT_ONE
  165. };
  166. /**
  167. * enum Microwire - whether Full/Half Duplex
  168. * @SSP_MICROWIRE_CHANNEL_FULL_DUPLEX: SSPTXD becomes bi-directional,
  169. * SSPRXD not used
  170. * @SSP_MICROWIRE_CHANNEL_HALF_DUPLEX: SSPTXD is an output, SSPRXD is
  171. * an input.
  172. */
  173. enum ssp_duplex {
  174. SSP_MICROWIRE_CHANNEL_FULL_DUPLEX,
  175. SSP_MICROWIRE_CHANNEL_HALF_DUPLEX
  176. };
  177. /**
  178. * CHIP select/deselect commands
  179. */
  180. enum ssp_chip_select {
  181. SSP_CHIP_SELECT,
  182. SSP_CHIP_DESELECT
  183. };
  184. /**
  185. * struct pl022_ssp_master - device.platform_data for SPI controller devices.
  186. * @num_chipselect: chipselects are used to distinguish individual
  187. * SPI slaves, and are numbered from zero to num_chipselects - 1.
  188. * each slave has a chipselect signal, but it's common that not
  189. * every chipselect is connected to a slave.
  190. * @enable_dma: if true enables DMA driven transfers.
  191. */
  192. struct pl022_ssp_controller {
  193. u16 bus_id;
  194. u8 num_chipselect;
  195. u8 enable_dma:1;
  196. };
  197. /**
  198. * struct ssp_config_chip - spi_board_info.controller_data for SPI
  199. * slave devices, copied to spi_device.controller_data.
  200. *
  201. * @lbm: used for test purpose to internally connect RX and TX
  202. * @iface: Interface type(Motorola, TI, Microwire, Universal)
  203. * @hierarchy: sets whether interface is master or slave
  204. * @slave_tx_disable: SSPTXD is disconnected (in slave mode only)
  205. * @clk_freq: Tune freq parameters of SSP(when in master mode)
  206. * @endian_rx: Endianess of Data in Rx FIFO
  207. * @endian_tx: Endianess of Data in Tx FIFO
  208. * @data_size: Width of data element(4 to 32 bits)
  209. * @com_mode: communication mode: polling, Interrupt or DMA
  210. * @rx_lev_trig: Rx FIFO watermark level (for IT & DMA mode)
  211. * @tx_lev_trig: Tx FIFO watermark level (for IT & DMA mode)
  212. * @clk_phase: Motorola SPI interface Clock phase
  213. * @clk_pol: Motorola SPI interface Clock polarity
  214. * @ctrl_len: Microwire interface: Control length
  215. * @wait_state: Microwire interface: Wait state
  216. * @duplex: Microwire interface: Full/Half duplex
  217. * @cs_control: function pointer to board-specific function to
  218. * assert/deassert I/O port to control HW generation of devices chip-select.
  219. * @dma_xfer_type: Type of DMA xfer (Mem-to-periph or Periph-to-Periph)
  220. * @dma_config: DMA configuration for SSP controller and peripheral
  221. */
  222. struct pl022_config_chip {
  223. struct device *dev;
  224. enum ssp_loopback lbm;
  225. enum ssp_interface iface;
  226. enum ssp_hierarchy hierarchy;
  227. bool slave_tx_disable;
  228. struct ssp_clock_params clk_freq;
  229. enum ssp_rx_endian endian_rx;
  230. enum ssp_tx_endian endian_tx;
  231. enum ssp_data_size data_size;
  232. enum ssp_mode com_mode;
  233. enum ssp_rx_level_trig rx_lev_trig;
  234. enum ssp_tx_level_trig tx_lev_trig;
  235. enum ssp_spi_clk_phase clk_phase;
  236. enum ssp_spi_clk_pol clk_pol;
  237. enum ssp_microwire_ctrl_len ctrl_len;
  238. enum ssp_microwire_wait_state wait_state;
  239. enum ssp_duplex duplex;
  240. void (*cs_control) (u32 control);
  241. };
  242. #endif /* _SSP_PL022_H */