diff options
author | Kevin Wells <wellsk40@gmail.com> | 2010-09-16 09:18:50 -0400 |
---|---|---|
committer | Grant Likely <grant.likely@secretlab.ca> | 2010-10-12 23:37:37 -0400 |
commit | bde435a9ca376d0b7809768ca803dbf14416b9c1 (patch) | |
tree | dd9678beb7c219922ad9b94db0e8f0a804ae2ab4 | |
parent | fadcf49b9bd7ec5fb69befbf477e747d5b6a0328 (diff) |
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>
-rw-r--r-- | arch/arm/mach-lpc32xx/phy3250.c | 7 | ||||
-rw-r--r-- | arch/arm/mach-u300/dummyspichip.c | 5 | ||||
-rw-r--r-- | arch/arm/mach-u300/spi.c | 10 | ||||
-rw-r--r-- | arch/arm/mach-ux500/board-mop500.c | 8 | ||||
-rw-r--r-- | drivers/mfd/ab8500-spi.c | 5 | ||||
-rw-r--r-- | drivers/spi/amba-pl022.c | 121 | ||||
-rw-r--r-- | include/linux/amba/pl022.h | 6 |
7 files changed, 63 insertions, 99 deletions
diff --git a/arch/arm/mach-lpc32xx/phy3250.c b/arch/arm/mach-lpc32xx/phy3250.c index bc9a42da2145..0c936cf5675a 100644 --- a/arch/arm/mach-lpc32xx/phy3250.c +++ b/arch/arm/mach-lpc32xx/phy3250.c | |||
@@ -172,18 +172,12 @@ static void phy3250_spi_cs_set(u32 control) | |||
172 | } | 172 | } |
173 | 173 | ||
174 | static struct pl022_config_chip spi0_chip_info = { | 174 | static struct pl022_config_chip spi0_chip_info = { |
175 | .lbm = LOOPBACK_DISABLED, | ||
176 | .com_mode = INTERRUPT_TRANSFER, | 175 | .com_mode = INTERRUPT_TRANSFER, |
177 | .iface = SSP_INTERFACE_MOTOROLA_SPI, | 176 | .iface = SSP_INTERFACE_MOTOROLA_SPI, |
178 | .hierarchy = SSP_MASTER, | 177 | .hierarchy = SSP_MASTER, |
179 | .slave_tx_disable = 0, | 178 | .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, | 179 | .rx_lev_trig = SSP_RX_4_OR_MORE_ELEM, |
184 | .tx_lev_trig = SSP_TX_4_OR_MORE_EMPTY_LOC, | 180 | .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, | 181 | .ctrl_len = SSP_BITS_8, |
188 | .wait_state = SSP_MWIRE_WAIT_ZERO, | 182 | .wait_state = SSP_MWIRE_WAIT_ZERO, |
189 | .duplex = SSP_MICROWIRE_CHANNEL_FULL_DUPLEX, | 183 | .duplex = SSP_MICROWIRE_CHANNEL_FULL_DUPLEX, |
@@ -239,6 +233,7 @@ static int __init phy3250_spi_board_register(void) | |||
239 | .max_speed_hz = 5000000, | 233 | .max_speed_hz = 5000000, |
240 | .bus_num = 0, | 234 | .bus_num = 0, |
241 | .chip_select = 0, | 235 | .chip_select = 0, |
236 | .mode = SPI_MODE_0, | ||
242 | .platform_data = &eeprom, | 237 | .platform_data = &eeprom, |
243 | .controller_data = &spi0_chip_info, | 238 | .controller_data = &spi0_chip_info, |
244 | }, | 239 | }, |
diff --git a/arch/arm/mach-u300/dummyspichip.c b/arch/arm/mach-u300/dummyspichip.c index 5f55012b7c9e..03f793612594 100644 --- a/arch/arm/mach-u300/dummyspichip.c +++ b/arch/arm/mach-u300/dummyspichip.c | |||
@@ -46,7 +46,6 @@ static ssize_t dummy_looptest(struct device *dev, | |||
46 | * struct, this is just used here to alter the behaviour of the chip | 46 | * struct, this is just used here to alter the behaviour of the chip |
47 | * in order to perform tests. | 47 | * in order to perform tests. |
48 | */ | 48 | */ |
49 | struct pl022_config_chip *chip_info = spi->controller_data; | ||
50 | int status; | 49 | int status; |
51 | u8 txbuf[14] = {0xDE, 0xAD, 0xBE, 0xEF, 0x2B, 0xAD, | 50 | u8 txbuf[14] = {0xDE, 0xAD, 0xBE, 0xEF, 0x2B, 0xAD, |
52 | 0xCA, 0xFE, 0xBA, 0xBE, 0xB1, 0x05, | 51 | 0xCA, 0xFE, 0xBA, 0xBE, 0xB1, 0x05, |
@@ -72,7 +71,7 @@ static ssize_t dummy_looptest(struct device *dev, | |||
72 | * Force chip to 8 bit mode | 71 | * Force chip to 8 bit mode |
73 | * WARNING: NEVER DO THIS IN REAL DRIVER CODE, THIS SHOULD BE STATIC! | 72 | * WARNING: NEVER DO THIS IN REAL DRIVER CODE, THIS SHOULD BE STATIC! |
74 | */ | 73 | */ |
75 | chip_info->data_size = SSP_DATA_BITS_8; | 74 | spi->bits_per_word = 8; |
76 | /* You should NOT DO THIS EITHER */ | 75 | /* You should NOT DO THIS EITHER */ |
77 | spi->master->setup(spi); | 76 | spi->master->setup(spi); |
78 | 77 | ||
@@ -159,7 +158,7 @@ static ssize_t dummy_looptest(struct device *dev, | |||
159 | * Force chip to 16 bit mode | 158 | * Force chip to 16 bit mode |
160 | * WARNING: NEVER DO THIS IN REAL DRIVER CODE, THIS SHOULD BE STATIC! | 159 | * WARNING: NEVER DO THIS IN REAL DRIVER CODE, THIS SHOULD BE STATIC! |
161 | */ | 160 | */ |
162 | chip_info->data_size = SSP_DATA_BITS_16; | 161 | spi->bits_per_word = 16; |
163 | /* You should NOT DO THIS EITHER */ | 162 | /* You should NOT DO THIS EITHER */ |
164 | spi->master->setup(spi); | 163 | spi->master->setup(spi); |
165 | 164 | ||
diff --git a/arch/arm/mach-u300/spi.c b/arch/arm/mach-u300/spi.c index f0e887bea30e..edb2c0d255c2 100644 --- a/arch/arm/mach-u300/spi.c +++ b/arch/arm/mach-u300/spi.c | |||
@@ -30,8 +30,6 @@ static void select_dummy_chip(u32 chipselect) | |||
30 | } | 30 | } |
31 | 31 | ||
32 | struct pl022_config_chip dummy_chip_info = { | 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 | /* | 33 | /* |
36 | * available POLLING_TRANSFER and INTERRUPT_TRANSFER, | 34 | * available POLLING_TRANSFER and INTERRUPT_TRANSFER, |
37 | * DMA_TRANSFER does not work | 35 | * DMA_TRANSFER does not work |
@@ -42,14 +40,8 @@ struct pl022_config_chip dummy_chip_info = { | |||
42 | .hierarchy = SSP_MASTER, | 40 | .hierarchy = SSP_MASTER, |
43 | /* 0 = drive TX even as slave, 1 = do not drive TX as slave */ | 41 | /* 0 = drive TX even as slave, 1 = do not drive TX as slave */ |
44 | .slave_tx_disable = 0, | 42 | .slave_tx_disable = 0, |
45 | /* LSB first */ | ||
46 | .endian_tx = SSP_TX_LSB, | ||
47 | .endian_rx = SSP_RX_LSB, | ||
48 | .data_size = SSP_DATA_BITS_8, /* used to be 12 in some default */ | ||
49 | .rx_lev_trig = SSP_RX_1_OR_MORE_ELEM, | 43 | .rx_lev_trig = SSP_RX_1_OR_MORE_ELEM, |
50 | .tx_lev_trig = SSP_TX_1_OR_MORE_EMPTY_LOC, | 44 | .tx_lev_trig = SSP_TX_1_OR_MORE_EMPTY_LOC, |
51 | .clk_phase = SSP_CLK_SECOND_EDGE, | ||
52 | .clk_pol = SSP_CLK_POL_IDLE_LOW, | ||
53 | .ctrl_len = SSP_BITS_12, | 45 | .ctrl_len = SSP_BITS_12, |
54 | .wait_state = SSP_MWIRE_WAIT_ZERO, | 46 | .wait_state = SSP_MWIRE_WAIT_ZERO, |
55 | .duplex = SSP_MICROWIRE_CHANNEL_FULL_DUPLEX, | 47 | .duplex = SSP_MICROWIRE_CHANNEL_FULL_DUPLEX, |
@@ -75,7 +67,7 @@ static struct spi_board_info u300_spi_devices[] = { | |||
75 | .bus_num = 0, /* Only one bus on this chip */ | 67 | .bus_num = 0, /* Only one bus on this chip */ |
76 | .chip_select = 0, | 68 | .chip_select = 0, |
77 | /* Means SPI_CS_HIGH, change if e.g low CS */ | 69 | /* Means SPI_CS_HIGH, change if e.g low CS */ |
78 | .mode = 0, | 70 | .mode = SPI_MODE_1 | SPI_LSB_FIRST | SPI_LOOP, |
79 | }, | 71 | }, |
80 | #endif | 72 | #endif |
81 | }; | 73 | }; |
diff --git a/arch/arm/mach-ux500/board-mop500.c b/arch/arm/mach-ux500/board-mop500.c index 0e8fd135a57d..219ae0ca4eef 100644 --- a/arch/arm/mach-ux500/board-mop500.c +++ b/arch/arm/mach-ux500/board-mop500.c | |||
@@ -55,19 +55,13 @@ static void ab4500_spi_cs_control(u32 command) | |||
55 | } | 55 | } |
56 | 56 | ||
57 | struct pl022_config_chip ab4500_chip_info = { | 57 | struct pl022_config_chip ab4500_chip_info = { |
58 | .lbm = LOOPBACK_DISABLED, | ||
59 | .com_mode = INTERRUPT_TRANSFER, | 58 | .com_mode = INTERRUPT_TRANSFER, |
60 | .iface = SSP_INTERFACE_MOTOROLA_SPI, | 59 | .iface = SSP_INTERFACE_MOTOROLA_SPI, |
61 | /* we can act as master only */ | 60 | /* we can act as master only */ |
62 | .hierarchy = SSP_MASTER, | 61 | .hierarchy = SSP_MASTER, |
63 | .slave_tx_disable = 0, | 62 | .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, | 63 | .rx_lev_trig = SSP_RX_1_OR_MORE_ELEM, |
68 | .tx_lev_trig = SSP_TX_1_OR_MORE_EMPTY_LOC, | 64 | .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, | 65 | .cs_control = ab4500_spi_cs_control, |
72 | }; | 66 | }; |
73 | 67 | ||
@@ -83,7 +77,7 @@ static struct spi_board_info u8500_spi_devices[] = { | |||
83 | .max_speed_hz = 12000000, | 77 | .max_speed_hz = 12000000, |
84 | .bus_num = 0, | 78 | .bus_num = 0, |
85 | .chip_select = 0, | 79 | .chip_select = 0, |
86 | .mode = SPI_MODE_0, | 80 | .mode = SPI_MODE_3, |
87 | .irq = IRQ_DB8500_AB8500, | 81 | .irq = IRQ_DB8500_AB8500, |
88 | }, | 82 | }, |
89 | }; | 83 | }; |
diff --git a/drivers/mfd/ab8500-spi.c b/drivers/mfd/ab8500-spi.c index e1c8b62b086d..01b6d584442c 100644 --- a/drivers/mfd/ab8500-spi.c +++ b/drivers/mfd/ab8500-spi.c | |||
@@ -83,6 +83,11 @@ static int __devinit ab8500_spi_probe(struct spi_device *spi) | |||
83 | struct ab8500 *ab8500; | 83 | struct ab8500 *ab8500; |
84 | int ret; | 84 | int ret; |
85 | 85 | ||
86 | spi->bits_per_word = 24; | ||
87 | ret = spi_setup(spi); | ||
88 | if (ret < 0) | ||
89 | return ret; | ||
90 | |||
86 | ab8500 = kzalloc(sizeof *ab8500, GFP_KERNEL); | 91 | ab8500 = kzalloc(sizeof *ab8500, GFP_KERNEL); |
87 | if (!ab8500) | 92 | if (!ab8500) |
88 | return -ENOMEM; | 93 | return -ENOMEM; |
diff --git a/drivers/spi/amba-pl022.c b/drivers/spi/amba-pl022.c index db0c67908d2b..59c90f3ccc26 100644 --- a/drivers/spi/amba-pl022.c +++ b/drivers/spi/amba-pl022.c | |||
@@ -1595,12 +1595,6 @@ static int destroy_queue(struct pl022 *pl022) | |||
1595 | static int verify_controller_parameters(struct pl022 *pl022, | 1595 | static int verify_controller_parameters(struct pl022 *pl022, |
1596 | struct pl022_config_chip *chip_info) | 1596 | struct pl022_config_chip *chip_info) |
1597 | { | 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) | 1598 | if ((chip_info->iface < SSP_INTERFACE_MOTOROLA_SPI) |
1605 | || (chip_info->iface > SSP_INTERFACE_UNIDIRECTIONAL)) { | 1599 | || (chip_info->iface > SSP_INTERFACE_UNIDIRECTIONAL)) { |
1606 | dev_err(chip_info->dev, | 1600 | dev_err(chip_info->dev, |
@@ -1626,24 +1620,6 @@ static int verify_controller_parameters(struct pl022 *pl022, | |||
1626 | "cpsdvsr is configured incorrectly\n"); | 1620 | "cpsdvsr is configured incorrectly\n"); |
1627 | return -EINVAL; | 1621 | return -EINVAL; |
1628 | } | 1622 | } |
1629 | if ((chip_info->endian_rx != SSP_RX_MSB) | ||
1630 | && (chip_info->endian_rx != SSP_RX_LSB)) { | ||
1631 | dev_err(chip_info->dev, | ||
1632 | "RX FIFO endianess is configured incorrectly\n"); | ||
1633 | return -EINVAL; | ||
1634 | } | ||
1635 | if ((chip_info->endian_tx != SSP_TX_MSB) | ||
1636 | && (chip_info->endian_tx != SSP_TX_LSB)) { | ||
1637 | dev_err(chip_info->dev, | ||
1638 | "TX FIFO endianess is configured incorrectly\n"); | ||
1639 | return -EINVAL; | ||
1640 | } | ||
1641 | if ((chip_info->data_size < SSP_DATA_BITS_4) | ||
1642 | || (chip_info->data_size > SSP_DATA_BITS_32)) { | ||
1643 | dev_err(chip_info->dev, | ||
1644 | "DATA Size is configured incorrectly\n"); | ||
1645 | return -EINVAL; | ||
1646 | } | ||
1647 | if ((chip_info->com_mode != INTERRUPT_TRANSFER) | 1623 | if ((chip_info->com_mode != INTERRUPT_TRANSFER) |
1648 | && (chip_info->com_mode != DMA_TRANSFER) | 1624 | && (chip_info->com_mode != DMA_TRANSFER) |
1649 | && (chip_info->com_mode != POLLING_TRANSFER)) { | 1625 | && (chip_info->com_mode != POLLING_TRANSFER)) { |
@@ -1663,20 +1639,6 @@ static int verify_controller_parameters(struct pl022 *pl022, | |||
1663 | "TX FIFO Trigger Level is configured incorrectly\n"); | 1639 | "TX FIFO Trigger Level is configured incorrectly\n"); |
1664 | return -EINVAL; | 1640 | return -EINVAL; |
1665 | } | 1641 | } |
1666 | if (chip_info->iface == SSP_INTERFACE_MOTOROLA_SPI) { | ||
1667 | if ((chip_info->clk_phase != SSP_CLK_FIRST_EDGE) | ||
1668 | && (chip_info->clk_phase != SSP_CLK_SECOND_EDGE)) { | ||
1669 | dev_err(chip_info->dev, | ||
1670 | "Clock Phase is configured incorrectly\n"); | ||
1671 | return -EINVAL; | ||
1672 | } | ||
1673 | if ((chip_info->clk_pol != SSP_CLK_POL_IDLE_LOW) | ||
1674 | && (chip_info->clk_pol != SSP_CLK_POL_IDLE_HIGH)) { | ||
1675 | dev_err(chip_info->dev, | ||
1676 | "Clock Polarity is configured incorrectly\n"); | ||
1677 | return -EINVAL; | ||
1678 | } | ||
1679 | } | ||
1680 | if (chip_info->iface == SSP_INTERFACE_NATIONAL_MICROWIRE) { | 1642 | if (chip_info->iface == SSP_INTERFACE_NATIONAL_MICROWIRE) { |
1681 | if ((chip_info->ctrl_len < SSP_BITS_4) | 1643 | if ((chip_info->ctrl_len < SSP_BITS_4) |
1682 | || (chip_info->ctrl_len > SSP_BITS_32)) { | 1644 | || (chip_info->ctrl_len > SSP_BITS_32)) { |
@@ -1825,23 +1787,14 @@ static int calculate_effective_freq(struct pl022 *pl022, | |||
1825 | * controller hardware here, that is not done until the actual transfer | 1787 | * controller hardware here, that is not done until the actual transfer |
1826 | * commence. | 1788 | * commence. |
1827 | */ | 1789 | */ |
1828 | |||
1829 | /* FIXME: JUST GUESSING the spi->mode bits understood by this driver */ | ||
1830 | #define MODEBITS (SPI_CPOL | SPI_CPHA | SPI_CS_HIGH \ | ||
1831 | | SPI_LSB_FIRST | SPI_LOOP) | ||
1832 | |||
1833 | static int pl022_setup(struct spi_device *spi) | 1790 | static int pl022_setup(struct spi_device *spi) |
1834 | { | 1791 | { |
1835 | struct pl022_config_chip *chip_info; | 1792 | struct pl022_config_chip *chip_info; |
1836 | struct chip_data *chip; | 1793 | struct chip_data *chip; |
1837 | int status = 0; | 1794 | int status = 0; |
1838 | struct pl022 *pl022 = spi_master_get_devdata(spi->master); | 1795 | struct pl022 *pl022 = spi_master_get_devdata(spi->master); |
1839 | 1796 | unsigned int bits = spi->bits_per_word; | |
1840 | if (spi->mode & ~MODEBITS) { | 1797 | u32 tmp; |
1841 | dev_dbg(&spi->dev, "unsupported mode bits %x\n", | ||
1842 | spi->mode & ~MODEBITS); | ||
1843 | return -EINVAL; | ||
1844 | } | ||
1845 | 1798 | ||
1846 | if (!spi->max_speed_hz) | 1799 | if (!spi->max_speed_hz) |
1847 | return -EINVAL; | 1800 | return -EINVAL; |
@@ -1884,18 +1837,12 @@ static int pl022_setup(struct spi_device *spi) | |||
1884 | * Set controller data default values: | 1837 | * Set controller data default values: |
1885 | * Polling is supported by default | 1838 | * Polling is supported by default |
1886 | */ | 1839 | */ |
1887 | chip_info->lbm = LOOPBACK_DISABLED; | ||
1888 | chip_info->com_mode = POLLING_TRANSFER; | 1840 | chip_info->com_mode = POLLING_TRANSFER; |
1889 | chip_info->iface = SSP_INTERFACE_MOTOROLA_SPI; | 1841 | chip_info->iface = SSP_INTERFACE_MOTOROLA_SPI; |
1890 | chip_info->hierarchy = SSP_SLAVE; | 1842 | chip_info->hierarchy = SSP_SLAVE; |
1891 | chip_info->slave_tx_disable = DO_NOT_DRIVE_TX; | 1843 | chip_info->slave_tx_disable = DO_NOT_DRIVE_TX; |
1892 | chip_info->endian_tx = SSP_TX_LSB; | ||
1893 | chip_info->endian_rx = SSP_RX_LSB; | ||
1894 | chip_info->data_size = SSP_DATA_BITS_12; | ||
1895 | chip_info->rx_lev_trig = SSP_RX_1_OR_MORE_ELEM; | 1844 | chip_info->rx_lev_trig = SSP_RX_1_OR_MORE_ELEM; |
1896 | chip_info->tx_lev_trig = SSP_TX_1_OR_MORE_EMPTY_LOC; | 1845 | chip_info->tx_lev_trig = SSP_TX_1_OR_MORE_EMPTY_LOC; |
1897 | chip_info->clk_phase = SSP_CLK_SECOND_EDGE; | ||
1898 | chip_info->clk_pol = SSP_CLK_POL_IDLE_LOW; | ||
1899 | chip_info->ctrl_len = SSP_BITS_8; | 1846 | chip_info->ctrl_len = SSP_BITS_8; |
1900 | chip_info->wait_state = SSP_MWIRE_WAIT_ZERO; | 1847 | chip_info->wait_state = SSP_MWIRE_WAIT_ZERO; |
1901 | chip_info->duplex = SSP_MICROWIRE_CHANNEL_FULL_DUPLEX; | 1848 | chip_info->duplex = SSP_MICROWIRE_CHANNEL_FULL_DUPLEX; |
@@ -1933,12 +1880,16 @@ static int pl022_setup(struct spi_device *spi) | |||
1933 | chip->xfer_type = chip_info->com_mode; | 1880 | chip->xfer_type = chip_info->com_mode; |
1934 | chip->cs_control = chip_info->cs_control; | 1881 | chip->cs_control = chip_info->cs_control; |
1935 | 1882 | ||
1936 | if (chip_info->data_size <= 8) { | 1883 | if (bits <= 3) { |
1937 | dev_dbg(&spi->dev, "1 <= n <=8 bits per word\n"); | 1884 | /* PL022 doesn't support less than 4-bits */ |
1885 | status = -ENOTSUPP; | ||
1886 | goto err_config_params; | ||
1887 | } else if (bits <= 8) { | ||
1888 | dev_dbg(&spi->dev, "4 <= n <=8 bits per word\n"); | ||
1938 | chip->n_bytes = 1; | 1889 | chip->n_bytes = 1; |
1939 | chip->read = READING_U8; | 1890 | chip->read = READING_U8; |
1940 | chip->write = WRITING_U8; | 1891 | chip->write = WRITING_U8; |
1941 | } else if (chip_info->data_size <= 16) { | 1892 | } else if (bits <= 16) { |
1942 | dev_dbg(&spi->dev, "9 <= n <= 16 bits per word\n"); | 1893 | dev_dbg(&spi->dev, "9 <= n <= 16 bits per word\n"); |
1943 | chip->n_bytes = 2; | 1894 | chip->n_bytes = 2; |
1944 | chip->read = READING_U16; | 1895 | chip->read = READING_U16; |
@@ -1955,6 +1906,7 @@ static int pl022_setup(struct spi_device *spi) | |||
1955 | dev_err(&spi->dev, | 1906 | dev_err(&spi->dev, |
1956 | "a standard pl022 can only handle " | 1907 | "a standard pl022 can only handle " |
1957 | "1 <= n <= 16 bit words\n"); | 1908 | "1 <= n <= 16 bit words\n"); |
1909 | status = -ENOTSUPP; | ||
1958 | goto err_config_params; | 1910 | goto err_config_params; |
1959 | } | 1911 | } |
1960 | } | 1912 | } |
@@ -1987,6 +1939,8 @@ static int pl022_setup(struct spi_device *spi) | |||
1987 | 1939 | ||
1988 | /* Special setup for the ST micro extended control registers */ | 1940 | /* Special setup for the ST micro extended control registers */ |
1989 | if (pl022->vendor->extended_cr) { | 1941 | if (pl022->vendor->extended_cr) { |
1942 | u32 etx; | ||
1943 | |||
1990 | if (pl022->vendor->pl023) { | 1944 | if (pl022->vendor->pl023) { |
1991 | /* These bits are only in the PL023 */ | 1945 | /* These bits are only in the PL023 */ |
1992 | SSP_WRITE_BITS(chip->cr1, chip_info->clkdelay, | 1946 | SSP_WRITE_BITS(chip->cr1, chip_info->clkdelay, |
@@ -2002,29 +1956,51 @@ static int pl022_setup(struct spi_device *spi) | |||
2002 | SSP_WRITE_BITS(chip->cr1, chip_info->wait_state, | 1956 | SSP_WRITE_BITS(chip->cr1, chip_info->wait_state, |
2003 | SSP_CR1_MASK_MWAIT_ST, 6); | 1957 | SSP_CR1_MASK_MWAIT_ST, 6); |
2004 | } | 1958 | } |
2005 | SSP_WRITE_BITS(chip->cr0, chip_info->data_size, | 1959 | SSP_WRITE_BITS(chip->cr0, bits - 1, |
2006 | SSP_CR0_MASK_DSS_ST, 0); | 1960 | SSP_CR0_MASK_DSS_ST, 0); |
2007 | SSP_WRITE_BITS(chip->cr1, chip_info->endian_rx, | 1961 | |
2008 | SSP_CR1_MASK_RENDN_ST, 4); | 1962 | if (spi->mode & SPI_LSB_FIRST) { |
2009 | SSP_WRITE_BITS(chip->cr1, chip_info->endian_tx, | 1963 | tmp = SSP_RX_LSB; |
2010 | SSP_CR1_MASK_TENDN_ST, 5); | 1964 | etx = SSP_TX_LSB; |
1965 | } else { | ||
1966 | tmp = SSP_RX_MSB; | ||
1967 | etx = SSP_TX_MSB; | ||
1968 | } | ||
1969 | SSP_WRITE_BITS(chip->cr1, tmp, SSP_CR1_MASK_RENDN_ST, 4); | ||
1970 | SSP_WRITE_BITS(chip->cr1, etx, SSP_CR1_MASK_TENDN_ST, 5); | ||
2011 | SSP_WRITE_BITS(chip->cr1, chip_info->rx_lev_trig, | 1971 | SSP_WRITE_BITS(chip->cr1, chip_info->rx_lev_trig, |
2012 | SSP_CR1_MASK_RXIFLSEL_ST, 7); | 1972 | SSP_CR1_MASK_RXIFLSEL_ST, 7); |
2013 | SSP_WRITE_BITS(chip->cr1, chip_info->tx_lev_trig, | 1973 | SSP_WRITE_BITS(chip->cr1, chip_info->tx_lev_trig, |
2014 | SSP_CR1_MASK_TXIFLSEL_ST, 10); | 1974 | SSP_CR1_MASK_TXIFLSEL_ST, 10); |
2015 | } else { | 1975 | } else { |
2016 | SSP_WRITE_BITS(chip->cr0, chip_info->data_size, | 1976 | SSP_WRITE_BITS(chip->cr0, bits - 1, |
2017 | SSP_CR0_MASK_DSS, 0); | 1977 | SSP_CR0_MASK_DSS, 0); |
2018 | SSP_WRITE_BITS(chip->cr0, chip_info->iface, | 1978 | SSP_WRITE_BITS(chip->cr0, chip_info->iface, |
2019 | SSP_CR0_MASK_FRF, 4); | 1979 | SSP_CR0_MASK_FRF, 4); |
2020 | } | 1980 | } |
1981 | |||
2021 | /* Stuff that is common for all versions */ | 1982 | /* Stuff that is common for all versions */ |
2022 | SSP_WRITE_BITS(chip->cr0, chip_info->clk_pol, SSP_CR0_MASK_SPO, 6); | 1983 | if (spi->mode & SPI_CPOL) |
2023 | SSP_WRITE_BITS(chip->cr0, chip_info->clk_phase, SSP_CR0_MASK_SPH, 7); | 1984 | tmp = SSP_CLK_POL_IDLE_HIGH; |
1985 | else | ||
1986 | tmp = SSP_CLK_POL_IDLE_LOW; | ||
1987 | SSP_WRITE_BITS(chip->cr0, tmp, SSP_CR0_MASK_SPO, 6); | ||
1988 | |||
1989 | if (spi->mode & SPI_CPHA) | ||
1990 | tmp = SSP_CLK_SECOND_EDGE; | ||
1991 | else | ||
1992 | tmp = SSP_CLK_FIRST_EDGE; | ||
1993 | SSP_WRITE_BITS(chip->cr0, tmp, SSP_CR0_MASK_SPH, 7); | ||
1994 | |||
2024 | SSP_WRITE_BITS(chip->cr0, chip_info->clk_freq.scr, SSP_CR0_MASK_SCR, 8); | 1995 | SSP_WRITE_BITS(chip->cr0, chip_info->clk_freq.scr, SSP_CR0_MASK_SCR, 8); |
2025 | /* Loopback is available on all versions except PL023 */ | 1996 | /* Loopback is available on all versions except PL023 */ |
2026 | if (!pl022->vendor->pl023) | 1997 | if (!pl022->vendor->pl023) { |
2027 | SSP_WRITE_BITS(chip->cr1, chip_info->lbm, SSP_CR1_MASK_LBM, 0); | 1998 | if (spi->mode & SPI_LOOP) |
1999 | tmp = LOOPBACK_ENABLED; | ||
2000 | else | ||
2001 | tmp = LOOPBACK_DISABLED; | ||
2002 | SSP_WRITE_BITS(chip->cr1, tmp, SSP_CR1_MASK_LBM, 0); | ||
2003 | } | ||
2028 | SSP_WRITE_BITS(chip->cr1, SSP_DISABLED, SSP_CR1_MASK_SSE, 1); | 2004 | SSP_WRITE_BITS(chip->cr1, SSP_DISABLED, SSP_CR1_MASK_SSE, 1); |
2029 | SSP_WRITE_BITS(chip->cr1, chip_info->hierarchy, SSP_CR1_MASK_MS, 2); | 2005 | SSP_WRITE_BITS(chip->cr1, chip_info->hierarchy, SSP_CR1_MASK_MS, 2); |
2030 | SSP_WRITE_BITS(chip->cr1, chip_info->slave_tx_disable, SSP_CR1_MASK_SOD, 3); | 2006 | SSP_WRITE_BITS(chip->cr1, chip_info->slave_tx_disable, SSP_CR1_MASK_SOD, 3); |
@@ -2033,6 +2009,7 @@ static int pl022_setup(struct spi_device *spi) | |||
2033 | spi_set_ctldata(spi, chip); | 2009 | spi_set_ctldata(spi, chip); |
2034 | return status; | 2010 | return status; |
2035 | err_config_params: | 2011 | err_config_params: |
2012 | spi_set_ctldata(spi, NULL); | ||
2036 | err_first_setup: | 2013 | err_first_setup: |
2037 | kfree(chip); | 2014 | kfree(chip); |
2038 | return status; | 2015 | return status; |
@@ -2095,6 +2072,14 @@ pl022_probe(struct amba_device *adev, struct amba_id *id) | |||
2095 | master->setup = pl022_setup; | 2072 | master->setup = pl022_setup; |
2096 | master->transfer = pl022_transfer; | 2073 | master->transfer = pl022_transfer; |
2097 | 2074 | ||
2075 | /* | ||
2076 | * Supports mode 0-3, loopback, and active low CS. Transfers are | ||
2077 | * always MS bit first on the original pl022. | ||
2078 | */ | ||
2079 | master->mode_bits = SPI_CPOL | SPI_CPHA | SPI_CS_HIGH | SPI_LOOP; | ||
2080 | if (pl022->vendor->extended_cr) | ||
2081 | master->mode_bits |= SPI_LSB_FIRST; | ||
2082 | |||
2098 | dev_dbg(&adev->dev, "BUSNO: %d\n", master->bus_num); | 2083 | dev_dbg(&adev->dev, "BUSNO: %d\n", master->bus_num); |
2099 | 2084 | ||
2100 | status = amba_request_regions(adev, NULL); | 2085 | status = amba_request_regions(adev, NULL); |
diff --git a/include/linux/amba/pl022.h b/include/linux/amba/pl022.h index db6a191ddcf7..bf143663df81 100644 --- a/include/linux/amba/pl022.h +++ b/include/linux/amba/pl022.h | |||
@@ -277,19 +277,13 @@ struct pl022_ssp_controller { | |||
277 | */ | 277 | */ |
278 | struct pl022_config_chip { | 278 | struct pl022_config_chip { |
279 | struct device *dev; | 279 | struct device *dev; |
280 | enum ssp_loopback lbm; | ||
281 | enum ssp_interface iface; | 280 | enum ssp_interface iface; |
282 | enum ssp_hierarchy hierarchy; | 281 | enum ssp_hierarchy hierarchy; |
283 | bool slave_tx_disable; | 282 | bool slave_tx_disable; |
284 | struct ssp_clock_params clk_freq; | 283 | 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; | 284 | enum ssp_mode com_mode; |
289 | enum ssp_rx_level_trig rx_lev_trig; | 285 | enum ssp_rx_level_trig rx_lev_trig; |
290 | enum ssp_tx_level_trig tx_lev_trig; | 286 | 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; | 287 | enum ssp_microwire_ctrl_len ctrl_len; |
294 | enum ssp_microwire_wait_state wait_state; | 288 | enum ssp_microwire_wait_state wait_state; |
295 | enum ssp_duplex duplex; | 289 | enum ssp_duplex duplex; |