1*c942fddfSThomas Gleixner /* SPDX-License-Identifier: GPL-2.0-or-later */ 2b43d65f7SLinus Walleij /* 3b43d65f7SLinus Walleij * include/linux/amba/pl022.h 4b43d65f7SLinus Walleij * 5b43d65f7SLinus Walleij * Copyright (C) 2008-2009 ST-Ericsson AB 6b43d65f7SLinus Walleij * Copyright (C) 2006 STMicroelectronics Pvt. Ltd. 7b43d65f7SLinus Walleij * 8b43d65f7SLinus Walleij * Author: Linus Walleij <[email protected]> 9b43d65f7SLinus Walleij * 10b43d65f7SLinus Walleij * Initial version inspired by: 11b43d65f7SLinus Walleij * linux-2.6.17-rc3-mm1/drivers/spi/pxa2xx_spi.c 12b43d65f7SLinus Walleij * Initial adoption to PL022 by: 13b43d65f7SLinus Walleij * Sachin Verma <[email protected]> 14b43d65f7SLinus Walleij */ 15b43d65f7SLinus Walleij 16b43d65f7SLinus Walleij #ifndef _SSP_PL022_H 17b43d65f7SLinus Walleij #define _SSP_PL022_H 18b43d65f7SLinus Walleij 19327ef2e9SViresh Kumar #include <linux/types.h> 20327ef2e9SViresh Kumar 21b43d65f7SLinus Walleij /** 22b43d65f7SLinus Walleij * whether SSP is in loopback mode or not 23b43d65f7SLinus Walleij */ 24b43d65f7SLinus Walleij enum ssp_loopback { 25b43d65f7SLinus Walleij LOOPBACK_DISABLED, 26b43d65f7SLinus Walleij LOOPBACK_ENABLED 27b43d65f7SLinus Walleij }; 28b43d65f7SLinus Walleij 29b43d65f7SLinus Walleij /** 30b43d65f7SLinus Walleij * enum ssp_interface - interfaces allowed for this SSP Controller 31b43d65f7SLinus Walleij * @SSP_INTERFACE_MOTOROLA_SPI: Motorola Interface 32b43d65f7SLinus Walleij * @SSP_INTERFACE_TI_SYNC_SERIAL: Texas Instrument Synchronous Serial 33b43d65f7SLinus Walleij * interface 34b43d65f7SLinus Walleij * @SSP_INTERFACE_NATIONAL_MICROWIRE: National Semiconductor Microwire 35b43d65f7SLinus Walleij * interface 36b43d65f7SLinus Walleij * @SSP_INTERFACE_UNIDIRECTIONAL: Unidirectional interface (STn8810 37b43d65f7SLinus Walleij * &STn8815 only) 38b43d65f7SLinus Walleij */ 39b43d65f7SLinus Walleij enum ssp_interface { 40b43d65f7SLinus Walleij SSP_INTERFACE_MOTOROLA_SPI, 41b43d65f7SLinus Walleij SSP_INTERFACE_TI_SYNC_SERIAL, 42b43d65f7SLinus Walleij SSP_INTERFACE_NATIONAL_MICROWIRE, 43b43d65f7SLinus Walleij SSP_INTERFACE_UNIDIRECTIONAL 44b43d65f7SLinus Walleij }; 45b43d65f7SLinus Walleij 46b43d65f7SLinus Walleij /** 47b43d65f7SLinus Walleij * enum ssp_hierarchy - whether SSP is configured as Master or Slave 48b43d65f7SLinus Walleij */ 49b43d65f7SLinus Walleij enum ssp_hierarchy { 50b43d65f7SLinus Walleij SSP_MASTER, 51b43d65f7SLinus Walleij SSP_SLAVE 52b43d65f7SLinus Walleij }; 53b43d65f7SLinus Walleij 54b43d65f7SLinus Walleij /** 55b43d65f7SLinus Walleij * enum ssp_clock_params - clock parameters, to set SSP clock at a 56b43d65f7SLinus Walleij * desired freq 57b43d65f7SLinus Walleij */ 58b43d65f7SLinus Walleij struct ssp_clock_params { 59b43d65f7SLinus Walleij u8 cpsdvsr; /* value from 2 to 254 (even only!) */ 60b43d65f7SLinus Walleij u8 scr; /* value from 0 to 255 */ 61b43d65f7SLinus Walleij }; 62b43d65f7SLinus Walleij 63b43d65f7SLinus Walleij /** 64b43d65f7SLinus Walleij * enum ssp_rx_endian - endianess of Rx FIFO Data 65556f4aebSLinus Walleij * this feature is only available in ST versionf of PL022 66b43d65f7SLinus Walleij */ 67b43d65f7SLinus Walleij enum ssp_rx_endian { 68b43d65f7SLinus Walleij SSP_RX_MSB, 69b43d65f7SLinus Walleij SSP_RX_LSB 70b43d65f7SLinus Walleij }; 71b43d65f7SLinus Walleij 72b43d65f7SLinus Walleij /** 73b43d65f7SLinus Walleij * enum ssp_tx_endian - endianess of Tx FIFO Data 74b43d65f7SLinus Walleij */ 75b43d65f7SLinus Walleij enum ssp_tx_endian { 76b43d65f7SLinus Walleij SSP_TX_MSB, 77b43d65f7SLinus Walleij SSP_TX_LSB 78b43d65f7SLinus Walleij }; 79b43d65f7SLinus Walleij 80b43d65f7SLinus Walleij /** 81b43d65f7SLinus Walleij * enum ssp_data_size - number of bits in one data element 82b43d65f7SLinus Walleij */ 83b43d65f7SLinus Walleij enum ssp_data_size { 84b43d65f7SLinus Walleij SSP_DATA_BITS_4 = 0x03, SSP_DATA_BITS_5, SSP_DATA_BITS_6, 85b43d65f7SLinus Walleij SSP_DATA_BITS_7, SSP_DATA_BITS_8, SSP_DATA_BITS_9, 86b43d65f7SLinus Walleij SSP_DATA_BITS_10, SSP_DATA_BITS_11, SSP_DATA_BITS_12, 87b43d65f7SLinus Walleij SSP_DATA_BITS_13, SSP_DATA_BITS_14, SSP_DATA_BITS_15, 88b43d65f7SLinus Walleij SSP_DATA_BITS_16, SSP_DATA_BITS_17, SSP_DATA_BITS_18, 89b43d65f7SLinus Walleij SSP_DATA_BITS_19, SSP_DATA_BITS_20, SSP_DATA_BITS_21, 90b43d65f7SLinus Walleij SSP_DATA_BITS_22, SSP_DATA_BITS_23, SSP_DATA_BITS_24, 91b43d65f7SLinus Walleij SSP_DATA_BITS_25, SSP_DATA_BITS_26, SSP_DATA_BITS_27, 92b43d65f7SLinus Walleij SSP_DATA_BITS_28, SSP_DATA_BITS_29, SSP_DATA_BITS_30, 93b43d65f7SLinus Walleij SSP_DATA_BITS_31, SSP_DATA_BITS_32 94b43d65f7SLinus Walleij }; 95b43d65f7SLinus Walleij 96b43d65f7SLinus Walleij /** 97b43d65f7SLinus Walleij * enum ssp_mode - SSP mode of operation (Communication modes) 98b43d65f7SLinus Walleij */ 99b43d65f7SLinus Walleij enum ssp_mode { 100b43d65f7SLinus Walleij INTERRUPT_TRANSFER, 101b43d65f7SLinus Walleij POLLING_TRANSFER, 102b43d65f7SLinus Walleij DMA_TRANSFER 103b43d65f7SLinus Walleij }; 104b43d65f7SLinus Walleij 105b43d65f7SLinus Walleij /** 106b43d65f7SLinus Walleij * enum ssp_rx_level_trig - receive FIFO watermark level which triggers 107b43d65f7SLinus Walleij * IT: Interrupt fires when _N_ or more elements in RX FIFO. 108b43d65f7SLinus Walleij */ 109b43d65f7SLinus Walleij enum ssp_rx_level_trig { 110b43d65f7SLinus Walleij SSP_RX_1_OR_MORE_ELEM, 111b43d65f7SLinus Walleij SSP_RX_4_OR_MORE_ELEM, 112b43d65f7SLinus Walleij SSP_RX_8_OR_MORE_ELEM, 113b43d65f7SLinus Walleij SSP_RX_16_OR_MORE_ELEM, 114b43d65f7SLinus Walleij SSP_RX_32_OR_MORE_ELEM 115b43d65f7SLinus Walleij }; 116b43d65f7SLinus Walleij 117b43d65f7SLinus Walleij /** 118b43d65f7SLinus Walleij * Transmit FIFO watermark level which triggers (IT Interrupt fires 119b43d65f7SLinus Walleij * when _N_ or more empty locations in TX FIFO) 120b43d65f7SLinus Walleij */ 121b43d65f7SLinus Walleij enum ssp_tx_level_trig { 122b43d65f7SLinus Walleij SSP_TX_1_OR_MORE_EMPTY_LOC, 123b43d65f7SLinus Walleij SSP_TX_4_OR_MORE_EMPTY_LOC, 124b43d65f7SLinus Walleij SSP_TX_8_OR_MORE_EMPTY_LOC, 125b43d65f7SLinus Walleij SSP_TX_16_OR_MORE_EMPTY_LOC, 126b43d65f7SLinus Walleij SSP_TX_32_OR_MORE_EMPTY_LOC 127b43d65f7SLinus Walleij }; 128b43d65f7SLinus Walleij 129b43d65f7SLinus Walleij /** 130b43d65f7SLinus Walleij * enum SPI Clock Phase - clock phase (Motorola SPI interface only) 131ee2b805cSLinus Walleij * @SSP_CLK_FIRST_EDGE: Receive data on first edge transition (actual direction depends on polarity) 132ee2b805cSLinus Walleij * @SSP_CLK_SECOND_EDGE: Receive data on second edge transition (actual direction depends on polarity) 133b43d65f7SLinus Walleij */ 134b43d65f7SLinus Walleij enum ssp_spi_clk_phase { 135ee2b805cSLinus Walleij SSP_CLK_FIRST_EDGE, 136ee2b805cSLinus Walleij SSP_CLK_SECOND_EDGE 137b43d65f7SLinus Walleij }; 138b43d65f7SLinus Walleij 139b43d65f7SLinus Walleij /** 140b43d65f7SLinus Walleij * enum SPI Clock Polarity - clock polarity (Motorola SPI interface only) 141b43d65f7SLinus Walleij * @SSP_CLK_POL_IDLE_LOW: Low inactive level 142b43d65f7SLinus Walleij * @SSP_CLK_POL_IDLE_HIGH: High inactive level 143b43d65f7SLinus Walleij */ 144b43d65f7SLinus Walleij enum ssp_spi_clk_pol { 145b43d65f7SLinus Walleij SSP_CLK_POL_IDLE_LOW, 146b43d65f7SLinus Walleij SSP_CLK_POL_IDLE_HIGH 147b43d65f7SLinus Walleij }; 148b43d65f7SLinus Walleij 149b43d65f7SLinus Walleij /** 150b43d65f7SLinus Walleij * Microwire Conrol Lengths Command size in microwire format 151b43d65f7SLinus Walleij */ 152b43d65f7SLinus Walleij enum ssp_microwire_ctrl_len { 153b43d65f7SLinus Walleij SSP_BITS_4 = 0x03, SSP_BITS_5, SSP_BITS_6, 154b43d65f7SLinus Walleij SSP_BITS_7, SSP_BITS_8, SSP_BITS_9, 155b43d65f7SLinus Walleij SSP_BITS_10, SSP_BITS_11, SSP_BITS_12, 156b43d65f7SLinus Walleij SSP_BITS_13, SSP_BITS_14, SSP_BITS_15, 157b43d65f7SLinus Walleij SSP_BITS_16, SSP_BITS_17, SSP_BITS_18, 158b43d65f7SLinus Walleij SSP_BITS_19, SSP_BITS_20, SSP_BITS_21, 159b43d65f7SLinus Walleij SSP_BITS_22, SSP_BITS_23, SSP_BITS_24, 160b43d65f7SLinus Walleij SSP_BITS_25, SSP_BITS_26, SSP_BITS_27, 161b43d65f7SLinus Walleij SSP_BITS_28, SSP_BITS_29, SSP_BITS_30, 162b43d65f7SLinus Walleij SSP_BITS_31, SSP_BITS_32 163b43d65f7SLinus Walleij }; 164b43d65f7SLinus Walleij 165b43d65f7SLinus Walleij /** 166b43d65f7SLinus Walleij * enum Microwire Wait State 167b43d65f7SLinus Walleij * @SSP_MWIRE_WAIT_ZERO: No wait state inserted after last command bit 168b43d65f7SLinus Walleij * @SSP_MWIRE_WAIT_ONE: One wait state inserted after last command bit 169b43d65f7SLinus Walleij */ 170b43d65f7SLinus Walleij enum ssp_microwire_wait_state { 171b43d65f7SLinus Walleij SSP_MWIRE_WAIT_ZERO, 172b43d65f7SLinus Walleij SSP_MWIRE_WAIT_ONE 173b43d65f7SLinus Walleij }; 174b43d65f7SLinus Walleij 175b43d65f7SLinus Walleij /** 176781c7b12SLinus Walleij * enum ssp_duplex - whether Full/Half Duplex on microwire, only 177781c7b12SLinus Walleij * available in the ST Micro variant. 178b43d65f7SLinus Walleij * @SSP_MICROWIRE_CHANNEL_FULL_DUPLEX: SSPTXD becomes bi-directional, 179b43d65f7SLinus Walleij * SSPRXD not used 180b43d65f7SLinus Walleij * @SSP_MICROWIRE_CHANNEL_HALF_DUPLEX: SSPTXD is an output, SSPRXD is 181b43d65f7SLinus Walleij * an input. 182b43d65f7SLinus Walleij */ 183b43d65f7SLinus Walleij enum ssp_duplex { 184b43d65f7SLinus Walleij SSP_MICROWIRE_CHANNEL_FULL_DUPLEX, 185b43d65f7SLinus Walleij SSP_MICROWIRE_CHANNEL_HALF_DUPLEX 186b43d65f7SLinus Walleij }; 187b43d65f7SLinus Walleij 188b43d65f7SLinus Walleij /** 189781c7b12SLinus Walleij * enum ssp_clkdelay - an optional clock delay on the feedback clock 190781c7b12SLinus Walleij * only available in the ST Micro PL023 variant. 191781c7b12SLinus Walleij * @SSP_FEEDBACK_CLK_DELAY_NONE: no delay, the data coming in from the 192781c7b12SLinus Walleij * slave is sampled directly 193781c7b12SLinus Walleij * @SSP_FEEDBACK_CLK_DELAY_1T: the incoming slave data is sampled with 194781c7b12SLinus Walleij * a delay of T-dt 195781c7b12SLinus Walleij * @SSP_FEEDBACK_CLK_DELAY_2T: dito with a delay if 2T-dt 196781c7b12SLinus Walleij * @SSP_FEEDBACK_CLK_DELAY_3T: dito with a delay if 3T-dt 197781c7b12SLinus Walleij * @SSP_FEEDBACK_CLK_DELAY_4T: dito with a delay if 4T-dt 198781c7b12SLinus Walleij * @SSP_FEEDBACK_CLK_DELAY_5T: dito with a delay if 5T-dt 199781c7b12SLinus Walleij * @SSP_FEEDBACK_CLK_DELAY_6T: dito with a delay if 6T-dt 200781c7b12SLinus Walleij * @SSP_FEEDBACK_CLK_DELAY_7T: dito with a delay if 7T-dt 201781c7b12SLinus Walleij */ 202781c7b12SLinus Walleij enum ssp_clkdelay { 203781c7b12SLinus Walleij SSP_FEEDBACK_CLK_DELAY_NONE, 204781c7b12SLinus Walleij SSP_FEEDBACK_CLK_DELAY_1T, 205781c7b12SLinus Walleij SSP_FEEDBACK_CLK_DELAY_2T, 206781c7b12SLinus Walleij SSP_FEEDBACK_CLK_DELAY_3T, 207781c7b12SLinus Walleij SSP_FEEDBACK_CLK_DELAY_4T, 208781c7b12SLinus Walleij SSP_FEEDBACK_CLK_DELAY_5T, 209781c7b12SLinus Walleij SSP_FEEDBACK_CLK_DELAY_6T, 210781c7b12SLinus Walleij SSP_FEEDBACK_CLK_DELAY_7T 211781c7b12SLinus Walleij }; 212781c7b12SLinus Walleij 213781c7b12SLinus Walleij /** 214b43d65f7SLinus Walleij * CHIP select/deselect commands 215b43d65f7SLinus Walleij */ 216b43d65f7SLinus Walleij enum ssp_chip_select { 217b43d65f7SLinus Walleij SSP_CHIP_SELECT, 218b43d65f7SLinus Walleij SSP_CHIP_DESELECT 219b43d65f7SLinus Walleij }; 220b43d65f7SLinus Walleij 221b43d65f7SLinus Walleij 222b1b6b9aaSLinus Walleij struct dma_chan; 223b43d65f7SLinus Walleij /** 224b43d65f7SLinus Walleij * struct pl022_ssp_master - device.platform_data for SPI controller devices. 2255b063b87SAlexandre Pereira da Silva * @bus_id: identifier for this bus 226b43d65f7SLinus Walleij * @num_chipselect: chipselects are used to distinguish individual 227b43d65f7SLinus Walleij * SPI slaves, and are numbered from zero to num_chipselects - 1. 228b43d65f7SLinus Walleij * each slave has a chipselect signal, but it's common that not 229b43d65f7SLinus Walleij * every chipselect is connected to a slave. 230b43d65f7SLinus Walleij * @enable_dma: if true enables DMA driven transfers. 231b1b6b9aaSLinus Walleij * @dma_rx_param: parameter to locate an RX DMA channel. 232b1b6b9aaSLinus Walleij * @dma_tx_param: parameter to locate a TX DMA channel. 23353e4aceaSChris Blair * @autosuspend_delay: delay in ms following transfer completion before the 23453e4aceaSChris Blair * runtime power management system suspends the device. A setting of 0 23553e4aceaSChris Blair * indicates no delay and the device will be suspended immediately. 23614af60b6SChris Blair * @rt: indicates the controller should run the message pump with realtime 23714af60b6SChris Blair * priority to minimise the transfer latency on the bus. 238f6f46de1SRoland Stigge * @chipselects: list of <num_chipselects> chip select gpios 239b43d65f7SLinus Walleij */ 240b43d65f7SLinus Walleij struct pl022_ssp_controller { 241b43d65f7SLinus Walleij u16 bus_id; 242b43d65f7SLinus Walleij u8 num_chipselect; 243b43d65f7SLinus Walleij u8 enable_dma:1; 244b1b6b9aaSLinus Walleij bool (*dma_filter)(struct dma_chan *chan, void *filter_param); 245b1b6b9aaSLinus Walleij void *dma_rx_param; 246b1b6b9aaSLinus Walleij void *dma_tx_param; 24753e4aceaSChris Blair int autosuspend_delay; 24814af60b6SChris Blair bool rt; 249f6f46de1SRoland Stigge int *chipselects; 250b43d65f7SLinus Walleij }; 251b43d65f7SLinus Walleij 252b43d65f7SLinus Walleij /** 253b43d65f7SLinus Walleij * struct ssp_config_chip - spi_board_info.controller_data for SPI 254b43d65f7SLinus Walleij * slave devices, copied to spi_device.controller_data. 255b43d65f7SLinus Walleij * 256b43d65f7SLinus Walleij * @iface: Interface type(Motorola, TI, Microwire, Universal) 257b43d65f7SLinus Walleij * @hierarchy: sets whether interface is master or slave 258b43d65f7SLinus Walleij * @slave_tx_disable: SSPTXD is disconnected (in slave mode only) 259b43d65f7SLinus Walleij * @clk_freq: Tune freq parameters of SSP(when in master mode) 260b43d65f7SLinus Walleij * @com_mode: communication mode: polling, Interrupt or DMA 261b43d65f7SLinus Walleij * @rx_lev_trig: Rx FIFO watermark level (for IT & DMA mode) 262b43d65f7SLinus Walleij * @tx_lev_trig: Tx FIFO watermark level (for IT & DMA mode) 263b43d65f7SLinus Walleij * @ctrl_len: Microwire interface: Control length 264b43d65f7SLinus Walleij * @wait_state: Microwire interface: Wait state 265b43d65f7SLinus Walleij * @duplex: Microwire interface: Full/Half duplex 266781c7b12SLinus Walleij * @clkdelay: on the PL023 variant, the delay in feeback clock cycles 267781c7b12SLinus Walleij * before sampling the incoming line 268b43d65f7SLinus Walleij * @cs_control: function pointer to board-specific function to 269b43d65f7SLinus Walleij * assert/deassert I/O port to control HW generation of devices chip-select. 270b43d65f7SLinus Walleij */ 271b43d65f7SLinus Walleij struct pl022_config_chip { 272b43d65f7SLinus Walleij enum ssp_interface iface; 273b43d65f7SLinus Walleij enum ssp_hierarchy hierarchy; 274b43d65f7SLinus Walleij bool slave_tx_disable; 275b43d65f7SLinus Walleij struct ssp_clock_params clk_freq; 276b43d65f7SLinus Walleij enum ssp_mode com_mode; 277b43d65f7SLinus Walleij enum ssp_rx_level_trig rx_lev_trig; 278b43d65f7SLinus Walleij enum ssp_tx_level_trig tx_lev_trig; 279b43d65f7SLinus Walleij enum ssp_microwire_ctrl_len ctrl_len; 280b43d65f7SLinus Walleij enum ssp_microwire_wait_state wait_state; 281b43d65f7SLinus Walleij enum ssp_duplex duplex; 282781c7b12SLinus Walleij enum ssp_clkdelay clkdelay; 283b43d65f7SLinus Walleij void (*cs_control) (u32 control); 284b43d65f7SLinus Walleij }; 285b43d65f7SLinus Walleij 286b43d65f7SLinus Walleij #endif /* _SSP_PL022_H */ 287