spi/pl022: Add spi->mode support to AMBA SPI driver

This patch adds spi->mode support for the AMBA pl022 driver and
allows spidev to correctly alter SPI modes. Unused fields used in
the pl022 header file for the pl022_config_chip have been removed.

The ab8500 client driver selects the data transfer size instead
of the platform data.

For platforms that use the amba pl022 driver, the unused fields
in the controller data structure have been removed and the .mode
field in the SPI board info structure is used instead.

Signed-off-by: Kevin Wells <wellsk40@gmail.com>
Tested-by: Linus Walleij <linus.walleij@stericsson.com>
Acked-by: Linus Walleij <linus.walleij@stericsson.com>
Signed-off-by: Grant Likely <grant.likely@secretlab.ca>

authored by

Kevin Wells and committed by
Grant Likely
bde435a9 fadcf49b

+63 -99
+1 -6
arch/arm/mach-lpc32xx/phy3250.c
··· 172 } 173 174 static struct pl022_config_chip spi0_chip_info = { 175 - .lbm = LOOPBACK_DISABLED, 176 .com_mode = INTERRUPT_TRANSFER, 177 .iface = SSP_INTERFACE_MOTOROLA_SPI, 178 .hierarchy = SSP_MASTER, 179 .slave_tx_disable = 0, 180 - .endian_tx = SSP_TX_LSB, 181 - .endian_rx = SSP_RX_LSB, 182 - .data_size = SSP_DATA_BITS_8, 183 .rx_lev_trig = SSP_RX_4_OR_MORE_ELEM, 184 .tx_lev_trig = SSP_TX_4_OR_MORE_EMPTY_LOC, 185 - .clk_phase = SSP_CLK_FIRST_EDGE, 186 - .clk_pol = SSP_CLK_POL_IDLE_LOW, 187 .ctrl_len = SSP_BITS_8, 188 .wait_state = SSP_MWIRE_WAIT_ZERO, 189 .duplex = SSP_MICROWIRE_CHANNEL_FULL_DUPLEX, ··· 233 .max_speed_hz = 5000000, 234 .bus_num = 0, 235 .chip_select = 0, 236 .platform_data = &eeprom, 237 .controller_data = &spi0_chip_info, 238 },
··· 172 } 173 174 static struct pl022_config_chip spi0_chip_info = { 175 .com_mode = INTERRUPT_TRANSFER, 176 .iface = SSP_INTERFACE_MOTOROLA_SPI, 177 .hierarchy = SSP_MASTER, 178 .slave_tx_disable = 0, 179 .rx_lev_trig = SSP_RX_4_OR_MORE_ELEM, 180 .tx_lev_trig = SSP_TX_4_OR_MORE_EMPTY_LOC, 181 .ctrl_len = SSP_BITS_8, 182 .wait_state = SSP_MWIRE_WAIT_ZERO, 183 .duplex = SSP_MICROWIRE_CHANNEL_FULL_DUPLEX, ··· 239 .max_speed_hz = 5000000, 240 .bus_num = 0, 241 .chip_select = 0, 242 + .mode = SPI_MODE_0, 243 .platform_data = &eeprom, 244 .controller_data = &spi0_chip_info, 245 },
+2 -3
arch/arm/mach-u300/dummyspichip.c
··· 46 * struct, this is just used here to alter the behaviour of the chip 47 * in order to perform tests. 48 */ 49 - struct pl022_config_chip *chip_info = spi->controller_data; 50 int status; 51 u8 txbuf[14] = {0xDE, 0xAD, 0xBE, 0xEF, 0x2B, 0xAD, 52 0xCA, 0xFE, 0xBA, 0xBE, 0xB1, 0x05, ··· 71 * Force chip to 8 bit mode 72 * WARNING: NEVER DO THIS IN REAL DRIVER CODE, THIS SHOULD BE STATIC! 73 */ 74 - chip_info->data_size = SSP_DATA_BITS_8; 75 /* You should NOT DO THIS EITHER */ 76 spi->master->setup(spi); 77 ··· 158 * Force chip to 16 bit mode 159 * WARNING: NEVER DO THIS IN REAL DRIVER CODE, THIS SHOULD BE STATIC! 160 */ 161 - chip_info->data_size = SSP_DATA_BITS_16; 162 /* You should NOT DO THIS EITHER */ 163 spi->master->setup(spi); 164
··· 46 * struct, this is just used here to alter the behaviour of the chip 47 * in order to perform tests. 48 */ 49 int status; 50 u8 txbuf[14] = {0xDE, 0xAD, 0xBE, 0xEF, 0x2B, 0xAD, 51 0xCA, 0xFE, 0xBA, 0xBE, 0xB1, 0x05, ··· 72 * Force chip to 8 bit mode 73 * WARNING: NEVER DO THIS IN REAL DRIVER CODE, THIS SHOULD BE STATIC! 74 */ 75 + spi->bits_per_word = 8; 76 /* You should NOT DO THIS EITHER */ 77 spi->master->setup(spi); 78 ··· 159 * Force chip to 16 bit mode 160 * WARNING: NEVER DO THIS IN REAL DRIVER CODE, THIS SHOULD BE STATIC! 161 */ 162 + spi->bits_per_word = 16; 163 /* You should NOT DO THIS EITHER */ 164 spi->master->setup(spi); 165
+1 -9
arch/arm/mach-u300/spi.c
··· 30 } 31 32 struct pl022_config_chip dummy_chip_info = { 33 - /* Nominally this is LOOPBACK_DISABLED, but this is our dummy chip! */ 34 - .lbm = LOOPBACK_ENABLED, 35 /* 36 * available POLLING_TRANSFER and INTERRUPT_TRANSFER, 37 * DMA_TRANSFER does not work ··· 40 .hierarchy = SSP_MASTER, 41 /* 0 = drive TX even as slave, 1 = do not drive TX as slave */ 42 .slave_tx_disable = 0, 43 - /* LSB first */ 44 - .endian_tx = SSP_TX_LSB, 45 - .endian_rx = SSP_RX_LSB, 46 - .data_size = SSP_DATA_BITS_8, /* used to be 12 in some default */ 47 .rx_lev_trig = SSP_RX_1_OR_MORE_ELEM, 48 .tx_lev_trig = SSP_TX_1_OR_MORE_EMPTY_LOC, 49 - .clk_phase = SSP_CLK_SECOND_EDGE, 50 - .clk_pol = SSP_CLK_POL_IDLE_LOW, 51 .ctrl_len = SSP_BITS_12, 52 .wait_state = SSP_MWIRE_WAIT_ZERO, 53 .duplex = SSP_MICROWIRE_CHANNEL_FULL_DUPLEX, ··· 67 .bus_num = 0, /* Only one bus on this chip */ 68 .chip_select = 0, 69 /* Means SPI_CS_HIGH, change if e.g low CS */ 70 - .mode = 0, 71 }, 72 #endif 73 };
··· 30 } 31 32 struct pl022_config_chip dummy_chip_info = { 33 /* 34 * available POLLING_TRANSFER and INTERRUPT_TRANSFER, 35 * DMA_TRANSFER does not work ··· 42 .hierarchy = SSP_MASTER, 43 /* 0 = drive TX even as slave, 1 = do not drive TX as slave */ 44 .slave_tx_disable = 0, 45 .rx_lev_trig = SSP_RX_1_OR_MORE_ELEM, 46 .tx_lev_trig = SSP_TX_1_OR_MORE_EMPTY_LOC, 47 .ctrl_len = SSP_BITS_12, 48 .wait_state = SSP_MWIRE_WAIT_ZERO, 49 .duplex = SSP_MICROWIRE_CHANNEL_FULL_DUPLEX, ··· 75 .bus_num = 0, /* Only one bus on this chip */ 76 .chip_select = 0, 77 /* Means SPI_CS_HIGH, change if e.g low CS */ 78 + .mode = SPI_MODE_1 | SPI_LSB_FIRST | SPI_LOOP, 79 }, 80 #endif 81 };
+1 -7
arch/arm/mach-ux500/board-mop500.c
··· 55 } 56 57 struct pl022_config_chip ab4500_chip_info = { 58 - .lbm = LOOPBACK_DISABLED, 59 .com_mode = INTERRUPT_TRANSFER, 60 .iface = SSP_INTERFACE_MOTOROLA_SPI, 61 /* we can act as master only */ 62 .hierarchy = SSP_MASTER, 63 .slave_tx_disable = 0, 64 - .endian_rx = SSP_RX_MSB, 65 - .endian_tx = SSP_TX_MSB, 66 - .data_size = SSP_DATA_BITS_24, 67 .rx_lev_trig = SSP_RX_1_OR_MORE_ELEM, 68 .tx_lev_trig = SSP_TX_1_OR_MORE_EMPTY_LOC, 69 - .clk_phase = SSP_CLK_SECOND_EDGE, 70 - .clk_pol = SSP_CLK_POL_IDLE_HIGH, 71 .cs_control = ab4500_spi_cs_control, 72 }; 73 ··· 77 .max_speed_hz = 12000000, 78 .bus_num = 0, 79 .chip_select = 0, 80 - .mode = SPI_MODE_0, 81 .irq = IRQ_DB8500_AB8500, 82 }, 83 };
··· 55 } 56 57 struct pl022_config_chip ab4500_chip_info = { 58 .com_mode = INTERRUPT_TRANSFER, 59 .iface = SSP_INTERFACE_MOTOROLA_SPI, 60 /* we can act as master only */ 61 .hierarchy = SSP_MASTER, 62 .slave_tx_disable = 0, 63 .rx_lev_trig = SSP_RX_1_OR_MORE_ELEM, 64 .tx_lev_trig = SSP_TX_1_OR_MORE_EMPTY_LOC, 65 .cs_control = ab4500_spi_cs_control, 66 }; 67 ··· 83 .max_speed_hz = 12000000, 84 .bus_num = 0, 85 .chip_select = 0, 86 + .mode = SPI_MODE_3, 87 .irq = IRQ_DB8500_AB8500, 88 }, 89 };
+5
drivers/mfd/ab8500-spi.c
··· 83 struct ab8500 *ab8500; 84 int ret; 85 86 ab8500 = kzalloc(sizeof *ab8500, GFP_KERNEL); 87 if (!ab8500) 88 return -ENOMEM;
··· 83 struct ab8500 *ab8500; 84 int ret; 85 86 + spi->bits_per_word = 24; 87 + ret = spi_setup(spi); 88 + if (ret < 0) 89 + return ret; 90 + 91 ab8500 = kzalloc(sizeof *ab8500, GFP_KERNEL); 92 if (!ab8500) 93 return -ENOMEM;
+53 -68
drivers/spi/amba-pl022.c
··· 1595 static int verify_controller_parameters(struct pl022 *pl022, 1596 struct pl022_config_chip *chip_info) 1597 { 1598 - if ((chip_info->lbm != LOOPBACK_ENABLED) 1599 - && (chip_info->lbm != LOOPBACK_DISABLED)) { 1600 - dev_err(chip_info->dev, 1601 - "loopback Mode is configured incorrectly\n"); 1602 - return -EINVAL; 1603 - } 1604 if ((chip_info->iface < SSP_INTERFACE_MOTOROLA_SPI) 1605 || (chip_info->iface > SSP_INTERFACE_UNIDIRECTIONAL)) { 1606 dev_err(chip_info->dev, ··· 1620 "cpsdvsr is configured incorrectly\n"); 1621 return -EINVAL; 1622 } 1623 - if ((chip_info->endian_rx != SSP_RX_MSB) 1624 - && (chip_info->endian_rx != SSP_RX_LSB)) { 1625 - dev_err(chip_info->dev, 1626 - "RX FIFO endianess is configured incorrectly\n"); 1627 - return -EINVAL; 1628 - } 1629 - if ((chip_info->endian_tx != SSP_TX_MSB) 1630 - && (chip_info->endian_tx != SSP_TX_LSB)) { 1631 - dev_err(chip_info->dev, 1632 - "TX FIFO endianess is configured incorrectly\n"); 1633 - return -EINVAL; 1634 - } 1635 - if ((chip_info->data_size < SSP_DATA_BITS_4) 1636 - || (chip_info->data_size > SSP_DATA_BITS_32)) { 1637 - dev_err(chip_info->dev, 1638 - "DATA Size is configured incorrectly\n"); 1639 - return -EINVAL; 1640 - } 1641 if ((chip_info->com_mode != INTERRUPT_TRANSFER) 1642 && (chip_info->com_mode != DMA_TRANSFER) 1643 && (chip_info->com_mode != POLLING_TRANSFER)) { ··· 1638 dev_err(chip_info->dev, 1639 "TX FIFO Trigger Level is configured incorrectly\n"); 1640 return -EINVAL; 1641 - } 1642 - if (chip_info->iface == SSP_INTERFACE_MOTOROLA_SPI) { 1643 - if ((chip_info->clk_phase != SSP_CLK_FIRST_EDGE) 1644 - && (chip_info->clk_phase != SSP_CLK_SECOND_EDGE)) { 1645 - dev_err(chip_info->dev, 1646 - "Clock Phase is configured incorrectly\n"); 1647 - return -EINVAL; 1648 - } 1649 - if ((chip_info->clk_pol != SSP_CLK_POL_IDLE_LOW) 1650 - && (chip_info->clk_pol != SSP_CLK_POL_IDLE_HIGH)) { 1651 - dev_err(chip_info->dev, 1652 - "Clock Polarity is configured incorrectly\n"); 1653 - return -EINVAL; 1654 - } 1655 } 1656 if (chip_info->iface == SSP_INTERFACE_NATIONAL_MICROWIRE) { 1657 if ((chip_info->ctrl_len < SSP_BITS_4) ··· 1787 * controller hardware here, that is not done until the actual transfer 1788 * commence. 1789 */ 1790 - 1791 - /* FIXME: JUST GUESSING the spi->mode bits understood by this driver */ 1792 - #define MODEBITS (SPI_CPOL | SPI_CPHA | SPI_CS_HIGH \ 1793 - | SPI_LSB_FIRST | SPI_LOOP) 1794 - 1795 static int pl022_setup(struct spi_device *spi) 1796 { 1797 struct pl022_config_chip *chip_info; 1798 struct chip_data *chip; 1799 int status = 0; 1800 struct pl022 *pl022 = spi_master_get_devdata(spi->master); 1801 - 1802 - if (spi->mode & ~MODEBITS) { 1803 - dev_dbg(&spi->dev, "unsupported mode bits %x\n", 1804 - spi->mode & ~MODEBITS); 1805 - return -EINVAL; 1806 - } 1807 1808 if (!spi->max_speed_hz) 1809 return -EINVAL; ··· 1837 * Set controller data default values: 1838 * Polling is supported by default 1839 */ 1840 - chip_info->lbm = LOOPBACK_DISABLED; 1841 chip_info->com_mode = POLLING_TRANSFER; 1842 chip_info->iface = SSP_INTERFACE_MOTOROLA_SPI; 1843 chip_info->hierarchy = SSP_SLAVE; 1844 chip_info->slave_tx_disable = DO_NOT_DRIVE_TX; 1845 - chip_info->endian_tx = SSP_TX_LSB; 1846 - chip_info->endian_rx = SSP_RX_LSB; 1847 - chip_info->data_size = SSP_DATA_BITS_12; 1848 chip_info->rx_lev_trig = SSP_RX_1_OR_MORE_ELEM; 1849 chip_info->tx_lev_trig = SSP_TX_1_OR_MORE_EMPTY_LOC; 1850 - chip_info->clk_phase = SSP_CLK_SECOND_EDGE; 1851 - chip_info->clk_pol = SSP_CLK_POL_IDLE_LOW; 1852 chip_info->ctrl_len = SSP_BITS_8; 1853 chip_info->wait_state = SSP_MWIRE_WAIT_ZERO; 1854 chip_info->duplex = SSP_MICROWIRE_CHANNEL_FULL_DUPLEX; ··· 1880 chip->xfer_type = chip_info->com_mode; 1881 chip->cs_control = chip_info->cs_control; 1882 1883 - if (chip_info->data_size <= 8) { 1884 - dev_dbg(&spi->dev, "1 <= n <=8 bits per word\n"); 1885 chip->n_bytes = 1; 1886 chip->read = READING_U8; 1887 chip->write = WRITING_U8; 1888 - } else if (chip_info->data_size <= 16) { 1889 dev_dbg(&spi->dev, "9 <= n <= 16 bits per word\n"); 1890 chip->n_bytes = 2; 1891 chip->read = READING_U16; ··· 1906 dev_err(&spi->dev, 1907 "a standard pl022 can only handle " 1908 "1 <= n <= 16 bit words\n"); 1909 goto err_config_params; 1910 } 1911 } ··· 1939 1940 /* Special setup for the ST micro extended control registers */ 1941 if (pl022->vendor->extended_cr) { 1942 if (pl022->vendor->pl023) { 1943 /* These bits are only in the PL023 */ 1944 SSP_WRITE_BITS(chip->cr1, chip_info->clkdelay, ··· 1956 SSP_WRITE_BITS(chip->cr1, chip_info->wait_state, 1957 SSP_CR1_MASK_MWAIT_ST, 6); 1958 } 1959 - SSP_WRITE_BITS(chip->cr0, chip_info->data_size, 1960 SSP_CR0_MASK_DSS_ST, 0); 1961 - SSP_WRITE_BITS(chip->cr1, chip_info->endian_rx, 1962 - SSP_CR1_MASK_RENDN_ST, 4); 1963 - SSP_WRITE_BITS(chip->cr1, chip_info->endian_tx, 1964 - SSP_CR1_MASK_TENDN_ST, 5); 1965 SSP_WRITE_BITS(chip->cr1, chip_info->rx_lev_trig, 1966 SSP_CR1_MASK_RXIFLSEL_ST, 7); 1967 SSP_WRITE_BITS(chip->cr1, chip_info->tx_lev_trig, 1968 SSP_CR1_MASK_TXIFLSEL_ST, 10); 1969 } else { 1970 - SSP_WRITE_BITS(chip->cr0, chip_info->data_size, 1971 SSP_CR0_MASK_DSS, 0); 1972 SSP_WRITE_BITS(chip->cr0, chip_info->iface, 1973 SSP_CR0_MASK_FRF, 4); 1974 } 1975 /* Stuff that is common for all versions */ 1976 - SSP_WRITE_BITS(chip->cr0, chip_info->clk_pol, SSP_CR0_MASK_SPO, 6); 1977 - SSP_WRITE_BITS(chip->cr0, chip_info->clk_phase, SSP_CR0_MASK_SPH, 7); 1978 SSP_WRITE_BITS(chip->cr0, chip_info->clk_freq.scr, SSP_CR0_MASK_SCR, 8); 1979 /* Loopback is available on all versions except PL023 */ 1980 - if (!pl022->vendor->pl023) 1981 - SSP_WRITE_BITS(chip->cr1, chip_info->lbm, SSP_CR1_MASK_LBM, 0); 1982 SSP_WRITE_BITS(chip->cr1, SSP_DISABLED, SSP_CR1_MASK_SSE, 1); 1983 SSP_WRITE_BITS(chip->cr1, chip_info->hierarchy, SSP_CR1_MASK_MS, 2); 1984 SSP_WRITE_BITS(chip->cr1, chip_info->slave_tx_disable, SSP_CR1_MASK_SOD, 3); ··· 2009 spi_set_ctldata(spi, chip); 2010 return status; 2011 err_config_params: 2012 err_first_setup: 2013 kfree(chip); 2014 return status; ··· 2071 master->cleanup = pl022_cleanup; 2072 master->setup = pl022_setup; 2073 master->transfer = pl022_transfer; 2074 2075 dev_dbg(&adev->dev, "BUSNO: %d\n", master->bus_num); 2076
··· 1595 static int verify_controller_parameters(struct pl022 *pl022, 1596 struct pl022_config_chip *chip_info) 1597 { 1598 if ((chip_info->iface < SSP_INTERFACE_MOTOROLA_SPI) 1599 || (chip_info->iface > SSP_INTERFACE_UNIDIRECTIONAL)) { 1600 dev_err(chip_info->dev, ··· 1626 "cpsdvsr is configured incorrectly\n"); 1627 return -EINVAL; 1628 } 1629 if ((chip_info->com_mode != INTERRUPT_TRANSFER) 1630 && (chip_info->com_mode != DMA_TRANSFER) 1631 && (chip_info->com_mode != POLLING_TRANSFER)) { ··· 1662 dev_err(chip_info->dev, 1663 "TX FIFO Trigger Level is configured incorrectly\n"); 1664 return -EINVAL; 1665 } 1666 if (chip_info->iface == SSP_INTERFACE_NATIONAL_MICROWIRE) { 1667 if ((chip_info->ctrl_len < SSP_BITS_4) ··· 1825 * controller hardware here, that is not done until the actual transfer 1826 * commence. 1827 */ 1828 static int pl022_setup(struct spi_device *spi) 1829 { 1830 struct pl022_config_chip *chip_info; 1831 struct chip_data *chip; 1832 int status = 0; 1833 struct pl022 *pl022 = spi_master_get_devdata(spi->master); 1834 + unsigned int bits = spi->bits_per_word; 1835 + u32 tmp; 1836 1837 if (!spi->max_speed_hz) 1838 return -EINVAL; ··· 1884 * Set controller data default values: 1885 * Polling is supported by default 1886 */ 1887 chip_info->com_mode = POLLING_TRANSFER; 1888 chip_info->iface = SSP_INTERFACE_MOTOROLA_SPI; 1889 chip_info->hierarchy = SSP_SLAVE; 1890 chip_info->slave_tx_disable = DO_NOT_DRIVE_TX; 1891 chip_info->rx_lev_trig = SSP_RX_1_OR_MORE_ELEM; 1892 chip_info->tx_lev_trig = SSP_TX_1_OR_MORE_EMPTY_LOC; 1893 chip_info->ctrl_len = SSP_BITS_8; 1894 chip_info->wait_state = SSP_MWIRE_WAIT_ZERO; 1895 chip_info->duplex = SSP_MICROWIRE_CHANNEL_FULL_DUPLEX; ··· 1933 chip->xfer_type = chip_info->com_mode; 1934 chip->cs_control = chip_info->cs_control; 1935 1936 + if (bits <= 3) { 1937 + /* PL022 doesn't support less than 4-bits */ 1938 + status = -ENOTSUPP; 1939 + goto err_config_params; 1940 + } else if (bits <= 8) { 1941 + dev_dbg(&spi->dev, "4 <= n <=8 bits per word\n"); 1942 chip->n_bytes = 1; 1943 chip->read = READING_U8; 1944 chip->write = WRITING_U8; 1945 + } else if (bits <= 16) { 1946 dev_dbg(&spi->dev, "9 <= n <= 16 bits per word\n"); 1947 chip->n_bytes = 2; 1948 chip->read = READING_U16; ··· 1955 dev_err(&spi->dev, 1956 "a standard pl022 can only handle " 1957 "1 <= n <= 16 bit words\n"); 1958 + status = -ENOTSUPP; 1959 goto err_config_params; 1960 } 1961 } ··· 1987 1988 /* Special setup for the ST micro extended control registers */ 1989 if (pl022->vendor->extended_cr) { 1990 + u32 etx; 1991 + 1992 if (pl022->vendor->pl023) { 1993 /* These bits are only in the PL023 */ 1994 SSP_WRITE_BITS(chip->cr1, chip_info->clkdelay, ··· 2002 SSP_WRITE_BITS(chip->cr1, chip_info->wait_state, 2003 SSP_CR1_MASK_MWAIT_ST, 6); 2004 } 2005 + SSP_WRITE_BITS(chip->cr0, bits - 1, 2006 SSP_CR0_MASK_DSS_ST, 0); 2007 + 2008 + if (spi->mode & SPI_LSB_FIRST) { 2009 + tmp = SSP_RX_LSB; 2010 + etx = SSP_TX_LSB; 2011 + } else { 2012 + tmp = SSP_RX_MSB; 2013 + etx = SSP_TX_MSB; 2014 + } 2015 + SSP_WRITE_BITS(chip->cr1, tmp, SSP_CR1_MASK_RENDN_ST, 4); 2016 + SSP_WRITE_BITS(chip->cr1, etx, SSP_CR1_MASK_TENDN_ST, 5); 2017 SSP_WRITE_BITS(chip->cr1, chip_info->rx_lev_trig, 2018 SSP_CR1_MASK_RXIFLSEL_ST, 7); 2019 SSP_WRITE_BITS(chip->cr1, chip_info->tx_lev_trig, 2020 SSP_CR1_MASK_TXIFLSEL_ST, 10); 2021 } else { 2022 + SSP_WRITE_BITS(chip->cr0, bits - 1, 2023 SSP_CR0_MASK_DSS, 0); 2024 SSP_WRITE_BITS(chip->cr0, chip_info->iface, 2025 SSP_CR0_MASK_FRF, 4); 2026 } 2027 + 2028 /* Stuff that is common for all versions */ 2029 + if (spi->mode & SPI_CPOL) 2030 + tmp = SSP_CLK_POL_IDLE_HIGH; 2031 + else 2032 + tmp = SSP_CLK_POL_IDLE_LOW; 2033 + SSP_WRITE_BITS(chip->cr0, tmp, SSP_CR0_MASK_SPO, 6); 2034 + 2035 + if (spi->mode & SPI_CPHA) 2036 + tmp = SSP_CLK_SECOND_EDGE; 2037 + else 2038 + tmp = SSP_CLK_FIRST_EDGE; 2039 + SSP_WRITE_BITS(chip->cr0, tmp, SSP_CR0_MASK_SPH, 7); 2040 + 2041 SSP_WRITE_BITS(chip->cr0, chip_info->clk_freq.scr, SSP_CR0_MASK_SCR, 8); 2042 /* Loopback is available on all versions except PL023 */ 2043 + if (!pl022->vendor->pl023) { 2044 + if (spi->mode & SPI_LOOP) 2045 + tmp = LOOPBACK_ENABLED; 2046 + else 2047 + tmp = LOOPBACK_DISABLED; 2048 + SSP_WRITE_BITS(chip->cr1, tmp, SSP_CR1_MASK_LBM, 0); 2049 + } 2050 SSP_WRITE_BITS(chip->cr1, SSP_DISABLED, SSP_CR1_MASK_SSE, 1); 2051 SSP_WRITE_BITS(chip->cr1, chip_info->hierarchy, SSP_CR1_MASK_MS, 2); 2052 SSP_WRITE_BITS(chip->cr1, chip_info->slave_tx_disable, SSP_CR1_MASK_SOD, 3); ··· 2033 spi_set_ctldata(spi, chip); 2034 return status; 2035 err_config_params: 2036 + spi_set_ctldata(spi, NULL); 2037 err_first_setup: 2038 kfree(chip); 2039 return status; ··· 2094 master->cleanup = pl022_cleanup; 2095 master->setup = pl022_setup; 2096 master->transfer = pl022_transfer; 2097 + 2098 + /* 2099 + * Supports mode 0-3, loopback, and active low CS. Transfers are 2100 + * always MS bit first on the original pl022. 2101 + */ 2102 + master->mode_bits = SPI_CPOL | SPI_CPHA | SPI_CS_HIGH | SPI_LOOP; 2103 + if (pl022->vendor->extended_cr) 2104 + master->mode_bits |= SPI_LSB_FIRST; 2105 2106 dev_dbg(&adev->dev, "BUSNO: %d\n", master->bus_num); 2107
-6
include/linux/amba/pl022.h
··· 277 */ 278 struct pl022_config_chip { 279 struct device *dev; 280 - enum ssp_loopback lbm; 281 enum ssp_interface iface; 282 enum ssp_hierarchy hierarchy; 283 bool slave_tx_disable; 284 struct ssp_clock_params clk_freq; 285 - enum ssp_rx_endian endian_rx; 286 - enum ssp_tx_endian endian_tx; 287 - enum ssp_data_size data_size; 288 enum ssp_mode com_mode; 289 enum ssp_rx_level_trig rx_lev_trig; 290 enum ssp_tx_level_trig tx_lev_trig; 291 - enum ssp_spi_clk_phase clk_phase; 292 - enum ssp_spi_clk_pol clk_pol; 293 enum ssp_microwire_ctrl_len ctrl_len; 294 enum ssp_microwire_wait_state wait_state; 295 enum ssp_duplex duplex;
··· 277 */ 278 struct pl022_config_chip { 279 struct device *dev; 280 enum ssp_interface iface; 281 enum ssp_hierarchy hierarchy; 282 bool slave_tx_disable; 283 struct ssp_clock_params clk_freq; 284 enum ssp_mode com_mode; 285 enum ssp_rx_level_trig rx_lev_trig; 286 enum ssp_tx_level_trig tx_lev_trig; 287 enum ssp_microwire_ctrl_len ctrl_len; 288 enum ssp_microwire_wait_state wait_state; 289 enum ssp_duplex duplex;