diff options
Diffstat (limited to 'drivers/spi')
-rw-r--r-- | drivers/spi/Kconfig | 45 | ||||
-rw-r--r-- | drivers/spi/atmel_spi.c | 4 | ||||
-rw-r--r-- | drivers/spi/au1550_spi.c | 213 | ||||
-rw-r--r-- | drivers/spi/omap2_mcspi.c | 4 | ||||
-rw-r--r-- | drivers/spi/pxa2xx_spi.c | 4 | ||||
-rw-r--r-- | drivers/spi/spi.c | 6 | ||||
-rw-r--r-- | drivers/spi/spi_imx.c | 6 | ||||
-rw-r--r-- | drivers/spi/spi_mpc83xx.c | 29 | ||||
-rw-r--r-- | drivers/spi/spidev.c | 23 | ||||
-rw-r--r-- | drivers/spi/xilinx_spi.c | 5 |
10 files changed, 196 insertions, 143 deletions
diff --git a/drivers/spi/Kconfig b/drivers/spi/Kconfig index 66ec5d8808de..2303521b4f09 100644 --- a/drivers/spi/Kconfig +++ b/drivers/spi/Kconfig | |||
@@ -49,25 +49,26 @@ config SPI_MASTER | |||
49 | controller and the protocol drivers for the SPI slave chips | 49 | controller and the protocol drivers for the SPI slave chips |
50 | that are connected. | 50 | that are connected. |
51 | 51 | ||
52 | if SPI_MASTER | ||
53 | |||
52 | comment "SPI Master Controller Drivers" | 54 | comment "SPI Master Controller Drivers" |
53 | depends on SPI_MASTER | ||
54 | 55 | ||
55 | config SPI_ATMEL | 56 | config SPI_ATMEL |
56 | tristate "Atmel SPI Controller" | 57 | tristate "Atmel SPI Controller" |
57 | depends on (ARCH_AT91 || AVR32) && SPI_MASTER | 58 | depends on (ARCH_AT91 || AVR32) |
58 | help | 59 | help |
59 | This selects a driver for the Atmel SPI Controller, present on | 60 | This selects a driver for the Atmel SPI Controller, present on |
60 | many AT32 (AVR32) and AT91 (ARM) chips. | 61 | many AT32 (AVR32) and AT91 (ARM) chips. |
61 | 62 | ||
62 | config SPI_BFIN | 63 | config SPI_BFIN |
63 | tristate "SPI controller driver for ADI Blackfin5xx" | 64 | tristate "SPI controller driver for ADI Blackfin5xx" |
64 | depends on SPI_MASTER && BLACKFIN | 65 | depends on BLACKFIN |
65 | help | 66 | help |
66 | This is the SPI controller master driver for Blackfin 5xx processor. | 67 | This is the SPI controller master driver for Blackfin 5xx processor. |
67 | 68 | ||
68 | config SPI_AU1550 | 69 | config SPI_AU1550 |
69 | tristate "Au1550/Au12x0 SPI Controller" | 70 | tristate "Au1550/Au12x0 SPI Controller" |
70 | depends on SPI_MASTER && (SOC_AU1550 || SOC_AU1200) && EXPERIMENTAL | 71 | depends on (SOC_AU1550 || SOC_AU1200) && EXPERIMENTAL |
71 | select SPI_BITBANG | 72 | select SPI_BITBANG |
72 | help | 73 | help |
73 | If you say yes to this option, support will be included for the | 74 | If you say yes to this option, support will be included for the |
@@ -78,7 +79,6 @@ config SPI_AU1550 | |||
78 | 79 | ||
79 | config SPI_BITBANG | 80 | config SPI_BITBANG |
80 | tristate "Bitbanging SPI master" | 81 | tristate "Bitbanging SPI master" |
81 | depends on SPI_MASTER && EXPERIMENTAL | ||
82 | help | 82 | help |
83 | With a few GPIO pins, your system can bitbang the SPI protocol. | 83 | With a few GPIO pins, your system can bitbang the SPI protocol. |
84 | Select this to get SPI support through I/O pins (GPIO, parallel | 84 | Select this to get SPI support through I/O pins (GPIO, parallel |
@@ -92,7 +92,7 @@ config SPI_BITBANG | |||
92 | 92 | ||
93 | config SPI_BUTTERFLY | 93 | config SPI_BUTTERFLY |
94 | tristate "Parallel port adapter for AVR Butterfly (DEVELOPMENT)" | 94 | tristate "Parallel port adapter for AVR Butterfly (DEVELOPMENT)" |
95 | depends on SPI_MASTER && PARPORT && EXPERIMENTAL | 95 | depends on PARPORT |
96 | select SPI_BITBANG | 96 | select SPI_BITBANG |
97 | help | 97 | help |
98 | This uses a custom parallel port cable to connect to an AVR | 98 | This uses a custom parallel port cable to connect to an AVR |
@@ -102,14 +102,14 @@ config SPI_BUTTERFLY | |||
102 | 102 | ||
103 | config SPI_IMX | 103 | config SPI_IMX |
104 | tristate "Freescale iMX SPI controller" | 104 | tristate "Freescale iMX SPI controller" |
105 | depends on SPI_MASTER && ARCH_IMX && EXPERIMENTAL | 105 | depends on ARCH_IMX && EXPERIMENTAL |
106 | help | 106 | help |
107 | This enables using the Freescale iMX SPI controller in master | 107 | This enables using the Freescale iMX SPI controller in master |
108 | mode. | 108 | mode. |
109 | 109 | ||
110 | config SPI_LM70_LLP | 110 | config SPI_LM70_LLP |
111 | tristate "Parallel port adapter for LM70 eval board (DEVELOPMENT)" | 111 | tristate "Parallel port adapter for LM70 eval board (DEVELOPMENT)" |
112 | depends on SPI_MASTER && PARPORT && EXPERIMENTAL | 112 | depends on PARPORT && EXPERIMENTAL |
113 | select SPI_BITBANG | 113 | select SPI_BITBANG |
114 | help | 114 | help |
115 | This driver supports the NS LM70 LLP Evaluation Board, | 115 | This driver supports the NS LM70 LLP Evaluation Board, |
@@ -118,14 +118,14 @@ config SPI_LM70_LLP | |||
118 | 118 | ||
119 | config SPI_MPC52xx_PSC | 119 | config SPI_MPC52xx_PSC |
120 | tristate "Freescale MPC52xx PSC SPI controller" | 120 | tristate "Freescale MPC52xx PSC SPI controller" |
121 | depends on SPI_MASTER && PPC_MPC52xx && EXPERIMENTAL | 121 | depends on PPC_MPC52xx && EXPERIMENTAL |
122 | help | 122 | help |
123 | This enables using the Freescale MPC52xx Programmable Serial | 123 | This enables using the Freescale MPC52xx Programmable Serial |
124 | Controller in master SPI mode. | 124 | Controller in master SPI mode. |
125 | 125 | ||
126 | config SPI_MPC83xx | 126 | config SPI_MPC83xx |
127 | tristate "Freescale MPC83xx/QUICC Engine SPI controller" | 127 | tristate "Freescale MPC83xx/QUICC Engine SPI controller" |
128 | depends on SPI_MASTER && (PPC_83xx || QUICC_ENGINE) && EXPERIMENTAL | 128 | depends on (PPC_83xx || QUICC_ENGINE) && EXPERIMENTAL |
129 | help | 129 | help |
130 | This enables using the Freescale MPC83xx and QUICC Engine SPI | 130 | This enables using the Freescale MPC83xx and QUICC Engine SPI |
131 | controllers in master mode. | 131 | controllers in master mode. |
@@ -137,21 +137,21 @@ config SPI_MPC83xx | |||
137 | 137 | ||
138 | config SPI_OMAP_UWIRE | 138 | config SPI_OMAP_UWIRE |
139 | tristate "OMAP1 MicroWire" | 139 | tristate "OMAP1 MicroWire" |
140 | depends on SPI_MASTER && ARCH_OMAP1 | 140 | depends on ARCH_OMAP1 |
141 | select SPI_BITBANG | 141 | select SPI_BITBANG |
142 | help | 142 | help |
143 | This hooks up to the MicroWire controller on OMAP1 chips. | 143 | This hooks up to the MicroWire controller on OMAP1 chips. |
144 | 144 | ||
145 | config SPI_OMAP24XX | 145 | config SPI_OMAP24XX |
146 | tristate "McSPI driver for OMAP24xx/OMAP34xx" | 146 | tristate "McSPI driver for OMAP24xx/OMAP34xx" |
147 | depends on SPI_MASTER && (ARCH_OMAP24XX || ARCH_OMAP34XX) | 147 | depends on ARCH_OMAP24XX || ARCH_OMAP34XX |
148 | help | 148 | help |
149 | SPI master controller for OMAP24xx/OMAP34xx Multichannel SPI | 149 | SPI master controller for OMAP24xx/OMAP34xx Multichannel SPI |
150 | (McSPI) modules. | 150 | (McSPI) modules. |
151 | 151 | ||
152 | config SPI_PXA2XX | 152 | config SPI_PXA2XX |
153 | tristate "PXA2xx SSP SPI master" | 153 | tristate "PXA2xx SSP SPI master" |
154 | depends on SPI_MASTER && ARCH_PXA && EXPERIMENTAL | 154 | depends on ARCH_PXA && EXPERIMENTAL |
155 | select PXA_SSP | 155 | select PXA_SSP |
156 | help | 156 | help |
157 | This enables using a PXA2xx SSP port as a SPI master controller. | 157 | This enables using a PXA2xx SSP port as a SPI master controller. |
@@ -160,14 +160,14 @@ config SPI_PXA2XX | |||
160 | 160 | ||
161 | config SPI_S3C24XX | 161 | config SPI_S3C24XX |
162 | tristate "Samsung S3C24XX series SPI" | 162 | tristate "Samsung S3C24XX series SPI" |
163 | depends on SPI_MASTER && ARCH_S3C2410 && EXPERIMENTAL | 163 | depends on ARCH_S3C2410 && EXPERIMENTAL |
164 | select SPI_BITBANG | 164 | select SPI_BITBANG |
165 | help | 165 | help |
166 | SPI driver for Samsung S3C24XX series ARM SoCs | 166 | SPI driver for Samsung S3C24XX series ARM SoCs |
167 | 167 | ||
168 | config SPI_S3C24XX_GPIO | 168 | config SPI_S3C24XX_GPIO |
169 | tristate "Samsung S3C24XX series SPI by GPIO" | 169 | tristate "Samsung S3C24XX series SPI by GPIO" |
170 | depends on SPI_MASTER && ARCH_S3C2410 && EXPERIMENTAL | 170 | depends on ARCH_S3C2410 && EXPERIMENTAL |
171 | select SPI_BITBANG | 171 | select SPI_BITBANG |
172 | help | 172 | help |
173 | SPI driver for Samsung S3C24XX series ARM SoCs using | 173 | SPI driver for Samsung S3C24XX series ARM SoCs using |
@@ -177,20 +177,20 @@ config SPI_S3C24XX_GPIO | |||
177 | 177 | ||
178 | config SPI_SH_SCI | 178 | config SPI_SH_SCI |
179 | tristate "SuperH SCI SPI controller" | 179 | tristate "SuperH SCI SPI controller" |
180 | depends on SPI_MASTER && SUPERH | 180 | depends on SUPERH |
181 | select SPI_BITBANG | 181 | select SPI_BITBANG |
182 | help | 182 | help |
183 | SPI driver for SuperH SCI blocks. | 183 | SPI driver for SuperH SCI blocks. |
184 | 184 | ||
185 | config SPI_TXX9 | 185 | config SPI_TXX9 |
186 | tristate "Toshiba TXx9 SPI controller" | 186 | tristate "Toshiba TXx9 SPI controller" |
187 | depends on SPI_MASTER && GENERIC_GPIO && CPU_TX49XX | 187 | depends on GENERIC_GPIO && CPU_TX49XX |
188 | help | 188 | help |
189 | SPI driver for Toshiba TXx9 MIPS SoCs | 189 | SPI driver for Toshiba TXx9 MIPS SoCs |
190 | 190 | ||
191 | config SPI_XILINX | 191 | config SPI_XILINX |
192 | tristate "Xilinx SPI controller" | 192 | tristate "Xilinx SPI controller" |
193 | depends on SPI_MASTER && XILINX_VIRTEX && EXPERIMENTAL | 193 | depends on XILINX_VIRTEX && EXPERIMENTAL |
194 | select SPI_BITBANG | 194 | select SPI_BITBANG |
195 | help | 195 | help |
196 | This exposes the SPI controller IP from the Xilinx EDK. | 196 | This exposes the SPI controller IP from the Xilinx EDK. |
@@ -207,11 +207,10 @@ config SPI_XILINX | |||
207 | # being probably the most widely used ones. | 207 | # being probably the most widely used ones. |
208 | # | 208 | # |
209 | comment "SPI Protocol Masters" | 209 | comment "SPI Protocol Masters" |
210 | depends on SPI_MASTER | ||
211 | 210 | ||
212 | config SPI_AT25 | 211 | config SPI_AT25 |
213 | tristate "SPI EEPROMs from most vendors" | 212 | tristate "SPI EEPROMs from most vendors" |
214 | depends on SPI_MASTER && SYSFS | 213 | depends on SYSFS |
215 | help | 214 | help |
216 | Enable this driver to get read/write support to most SPI EEPROMs, | 215 | Enable this driver to get read/write support to most SPI EEPROMs, |
217 | after you configure the board init code to know about each eeprom | 216 | after you configure the board init code to know about each eeprom |
@@ -222,7 +221,7 @@ config SPI_AT25 | |||
222 | 221 | ||
223 | config SPI_SPIDEV | 222 | config SPI_SPIDEV |
224 | tristate "User mode SPI device driver support" | 223 | tristate "User mode SPI device driver support" |
225 | depends on SPI_MASTER && EXPERIMENTAL | 224 | depends on EXPERIMENTAL |
226 | help | 225 | help |
227 | This supports user mode SPI protocol drivers. | 226 | This supports user mode SPI protocol drivers. |
228 | 227 | ||
@@ -231,7 +230,7 @@ config SPI_SPIDEV | |||
231 | 230 | ||
232 | config SPI_TLE62X0 | 231 | config SPI_TLE62X0 |
233 | tristate "Infineon TLE62X0 (for power switching)" | 232 | tristate "Infineon TLE62X0 (for power switching)" |
234 | depends on SPI_MASTER && SYSFS | 233 | depends on SYSFS |
235 | help | 234 | help |
236 | SPI driver for Infineon TLE62X0 series line driver chips, | 235 | SPI driver for Infineon TLE62X0 series line driver chips, |
237 | such as the TLE6220, TLE6230 and TLE6240. This provides a | 236 | such as the TLE6220, TLE6230 and TLE6240. This provides a |
@@ -242,6 +241,8 @@ config SPI_TLE62X0 | |||
242 | # Add new SPI protocol masters in alphabetical order above this line | 241 | # Add new SPI protocol masters in alphabetical order above this line |
243 | # | 242 | # |
244 | 243 | ||
244 | endif # SPI_MASTER | ||
245 | |||
245 | # (slave support would go here) | 246 | # (slave support would go here) |
246 | 247 | ||
247 | endif # SPI | 248 | endif # SPI |
diff --git a/drivers/spi/atmel_spi.c b/drivers/spi/atmel_spi.c index e81d59d78910..0c7165660853 100644 --- a/drivers/spi/atmel_spi.c +++ b/drivers/spi/atmel_spi.c | |||
@@ -313,14 +313,14 @@ atmel_spi_dma_map_xfer(struct atmel_spi *as, struct spi_transfer *xfer) | |||
313 | xfer->tx_dma = dma_map_single(dev, | 313 | xfer->tx_dma = dma_map_single(dev, |
314 | (void *) xfer->tx_buf, xfer->len, | 314 | (void *) xfer->tx_buf, xfer->len, |
315 | DMA_TO_DEVICE); | 315 | DMA_TO_DEVICE); |
316 | if (dma_mapping_error(xfer->tx_dma)) | 316 | if (dma_mapping_error(dev, xfer->tx_dma)) |
317 | return -ENOMEM; | 317 | return -ENOMEM; |
318 | } | 318 | } |
319 | if (xfer->rx_buf) { | 319 | if (xfer->rx_buf) { |
320 | xfer->rx_dma = dma_map_single(dev, | 320 | xfer->rx_dma = dma_map_single(dev, |
321 | xfer->rx_buf, xfer->len, | 321 | xfer->rx_buf, xfer->len, |
322 | DMA_FROM_DEVICE); | 322 | DMA_FROM_DEVICE); |
323 | if (dma_mapping_error(xfer->rx_dma)) { | 323 | if (dma_mapping_error(dev, xfer->rx_dma)) { |
324 | if (xfer->tx_buf) | 324 | if (xfer->tx_buf) |
325 | dma_unmap_single(dev, | 325 | dma_unmap_single(dev, |
326 | xfer->tx_dma, xfer->len, | 326 | xfer->tx_dma, xfer->len, |
diff --git a/drivers/spi/au1550_spi.c b/drivers/spi/au1550_spi.c index 072c4a595334..87b73e0169c5 100644 --- a/drivers/spi/au1550_spi.c +++ b/drivers/spi/au1550_spi.c | |||
@@ -26,6 +26,7 @@ | |||
26 | #include <linux/errno.h> | 26 | #include <linux/errno.h> |
27 | #include <linux/device.h> | 27 | #include <linux/device.h> |
28 | #include <linux/platform_device.h> | 28 | #include <linux/platform_device.h> |
29 | #include <linux/resource.h> | ||
29 | #include <linux/spi/spi.h> | 30 | #include <linux/spi/spi.h> |
30 | #include <linux/spi/spi_bitbang.h> | 31 | #include <linux/spi/spi_bitbang.h> |
31 | #include <linux/dma-mapping.h> | 32 | #include <linux/dma-mapping.h> |
@@ -81,6 +82,7 @@ struct au1550_spi { | |||
81 | struct spi_master *master; | 82 | struct spi_master *master; |
82 | struct device *dev; | 83 | struct device *dev; |
83 | struct au1550_spi_info *pdata; | 84 | struct au1550_spi_info *pdata; |
85 | struct resource *ioarea; | ||
84 | }; | 86 | }; |
85 | 87 | ||
86 | 88 | ||
@@ -96,6 +98,8 @@ static dbdev_tab_t au1550_spi_mem_dbdev = | |||
96 | .dev_intpolarity = 0 | 98 | .dev_intpolarity = 0 |
97 | }; | 99 | }; |
98 | 100 | ||
101 | static int ddma_memid; /* id to above mem dma device */ | ||
102 | |||
99 | static void au1550_spi_bits_handlers_set(struct au1550_spi *hw, int bpw); | 103 | static void au1550_spi_bits_handlers_set(struct au1550_spi *hw, int bpw); |
100 | 104 | ||
101 | 105 | ||
@@ -330,7 +334,7 @@ static int au1550_spi_dma_rxtmp_alloc(struct au1550_spi *hw, unsigned size) | |||
330 | hw->dma_rx_tmpbuf_size = size; | 334 | hw->dma_rx_tmpbuf_size = size; |
331 | hw->dma_rx_tmpbuf_addr = dma_map_single(hw->dev, hw->dma_rx_tmpbuf, | 335 | hw->dma_rx_tmpbuf_addr = dma_map_single(hw->dev, hw->dma_rx_tmpbuf, |
332 | size, DMA_FROM_DEVICE); | 336 | size, DMA_FROM_DEVICE); |
333 | if (dma_mapping_error(hw->dma_rx_tmpbuf_addr)) { | 337 | if (dma_mapping_error(hw->dev, hw->dma_rx_tmpbuf_addr)) { |
334 | kfree(hw->dma_rx_tmpbuf); | 338 | kfree(hw->dma_rx_tmpbuf); |
335 | hw->dma_rx_tmpbuf = 0; | 339 | hw->dma_rx_tmpbuf = 0; |
336 | hw->dma_rx_tmpbuf_size = 0; | 340 | hw->dma_rx_tmpbuf_size = 0; |
@@ -374,7 +378,7 @@ static int au1550_spi_dma_txrxb(struct spi_device *spi, struct spi_transfer *t) | |||
374 | dma_rx_addr = dma_map_single(hw->dev, | 378 | dma_rx_addr = dma_map_single(hw->dev, |
375 | (void *)t->rx_buf, | 379 | (void *)t->rx_buf, |
376 | t->len, DMA_FROM_DEVICE); | 380 | t->len, DMA_FROM_DEVICE); |
377 | if (dma_mapping_error(dma_rx_addr)) | 381 | if (dma_mapping_error(hw->dev, dma_rx_addr)) |
378 | dev_err(hw->dev, "rx dma map error\n"); | 382 | dev_err(hw->dev, "rx dma map error\n"); |
379 | } | 383 | } |
380 | } else { | 384 | } else { |
@@ -397,7 +401,7 @@ static int au1550_spi_dma_txrxb(struct spi_device *spi, struct spi_transfer *t) | |||
397 | dma_tx_addr = dma_map_single(hw->dev, | 401 | dma_tx_addr = dma_map_single(hw->dev, |
398 | (void *)t->tx_buf, | 402 | (void *)t->tx_buf, |
399 | t->len, DMA_TO_DEVICE); | 403 | t->len, DMA_TO_DEVICE); |
400 | if (dma_mapping_error(dma_tx_addr)) | 404 | if (dma_mapping_error(hw->dev, dma_tx_addr)) |
401 | dev_err(hw->dev, "tx dma map error\n"); | 405 | dev_err(hw->dev, "tx dma map error\n"); |
402 | } | 406 | } |
403 | } else { | 407 | } else { |
@@ -480,9 +484,13 @@ static irqreturn_t au1550_spi_dma_irq_callback(struct au1550_spi *hw) | |||
480 | au1xxx_dbdma_reset(hw->dma_tx_ch); | 484 | au1xxx_dbdma_reset(hw->dma_tx_ch); |
481 | au1550_spi_reset_fifos(hw); | 485 | au1550_spi_reset_fifos(hw); |
482 | 486 | ||
483 | dev_err(hw->dev, | 487 | if (evnt == PSC_SPIEVNT_RO) |
484 | "Unexpected SPI error: event=0x%x stat=0x%x!\n", | 488 | dev_err(hw->dev, |
485 | evnt, stat); | 489 | "dma transfer: receive FIFO overflow!\n"); |
490 | else | ||
491 | dev_err(hw->dev, | ||
492 | "dma transfer: unexpected SPI error " | ||
493 | "(event=0x%x stat=0x%x)!\n", evnt, stat); | ||
486 | 494 | ||
487 | complete(&hw->master_done); | 495 | complete(&hw->master_done); |
488 | return IRQ_HANDLED; | 496 | return IRQ_HANDLED; |
@@ -592,17 +600,17 @@ static irqreturn_t au1550_spi_pio_irq_callback(struct au1550_spi *hw) | |||
592 | 600 | ||
593 | if ((evnt & (PSC_SPIEVNT_MM | PSC_SPIEVNT_RO | 601 | if ((evnt & (PSC_SPIEVNT_MM | PSC_SPIEVNT_RO |
594 | | PSC_SPIEVNT_RU | PSC_SPIEVNT_TO | 602 | | PSC_SPIEVNT_RU | PSC_SPIEVNT_TO |
595 | | PSC_SPIEVNT_TU | PSC_SPIEVNT_SD)) | 603 | | PSC_SPIEVNT_SD)) |
596 | != 0) { | 604 | != 0) { |
597 | dev_err(hw->dev, | ||
598 | "Unexpected SPI error: event=0x%x stat=0x%x!\n", | ||
599 | evnt, stat); | ||
600 | /* | 605 | /* |
601 | * due to an error we consider transfer as done, | 606 | * due to an error we consider transfer as done, |
602 | * so mask all events until before next transfer start | 607 | * so mask all events until before next transfer start |
603 | */ | 608 | */ |
604 | au1550_spi_mask_ack_all(hw); | 609 | au1550_spi_mask_ack_all(hw); |
605 | au1550_spi_reset_fifos(hw); | 610 | au1550_spi_reset_fifos(hw); |
611 | dev_err(hw->dev, | ||
612 | "pio transfer: unexpected SPI error " | ||
613 | "(event=0x%x stat=0x%x)!\n", evnt, stat); | ||
606 | complete(&hw->master_done); | 614 | complete(&hw->master_done); |
607 | return IRQ_HANDLED; | 615 | return IRQ_HANDLED; |
608 | } | 616 | } |
@@ -616,27 +624,50 @@ static irqreturn_t au1550_spi_pio_irq_callback(struct au1550_spi *hw) | |||
616 | stat = hw->regs->psc_spistat; | 624 | stat = hw->regs->psc_spistat; |
617 | au_sync(); | 625 | au_sync(); |
618 | 626 | ||
619 | if ((stat & PSC_SPISTAT_RE) == 0 && hw->rx_count < hw->len) { | 627 | /* |
628 | * Take care to not let the Rx FIFO overflow. | ||
629 | * | ||
630 | * We only write a byte if we have read one at least. Initially, | ||
631 | * the write fifo is full, so we should read from the read fifo | ||
632 | * first. | ||
633 | * In case we miss a word from the read fifo, we should get a | ||
634 | * RO event and should back out. | ||
635 | */ | ||
636 | if (!(stat & PSC_SPISTAT_RE) && hw->rx_count < hw->len) { | ||
620 | hw->rx_word(hw); | 637 | hw->rx_word(hw); |
621 | /* ack the receive request event */ | ||
622 | hw->regs->psc_spievent = PSC_SPIEVNT_RR; | ||
623 | au_sync(); | ||
624 | busy = 1; | 638 | busy = 1; |
625 | } | ||
626 | 639 | ||
627 | if ((stat & PSC_SPISTAT_TF) == 0 && hw->tx_count < hw->len) { | 640 | if (!(stat & PSC_SPISTAT_TF) && hw->tx_count < hw->len) |
628 | hw->tx_word(hw); | 641 | hw->tx_word(hw); |
629 | /* ack the transmit request event */ | ||
630 | hw->regs->psc_spievent = PSC_SPIEVNT_TR; | ||
631 | au_sync(); | ||
632 | busy = 1; | ||
633 | } | 642 | } |
634 | } while (busy); | 643 | } while (busy); |
635 | 644 | ||
636 | evnt = hw->regs->psc_spievent; | 645 | hw->regs->psc_spievent = PSC_SPIEVNT_RR | PSC_SPIEVNT_TR; |
637 | au_sync(); | 646 | au_sync(); |
638 | 647 | ||
639 | if (hw->rx_count >= hw->len || (evnt & PSC_SPIEVNT_MD) != 0) { | 648 | /* |
649 | * Restart the SPI transmission in case of a transmit underflow. | ||
650 | * This seems to work despite the notes in the Au1550 data book | ||
651 | * of Figure 8-4 with flowchart for SPI master operation: | ||
652 | * | ||
653 | * """Note 1: An XFR Error Interrupt occurs, unless masked, | ||
654 | * for any of the following events: Tx FIFO Underflow, | ||
655 | * Rx FIFO Overflow, or Multiple-master Error | ||
656 | * Note 2: In case of a Tx Underflow Error, all zeroes are | ||
657 | * transmitted.""" | ||
658 | * | ||
659 | * By simply restarting the spi transfer on Tx Underflow Error, | ||
660 | * we assume that spi transfer was paused instead of zeroes | ||
661 | * transmittion mentioned in the Note 2 of Au1550 data book. | ||
662 | */ | ||
663 | if (evnt & PSC_SPIEVNT_TU) { | ||
664 | hw->regs->psc_spievent = PSC_SPIEVNT_TU | PSC_SPIEVNT_MD; | ||
665 | au_sync(); | ||
666 | hw->regs->psc_spipcr = PSC_SPIPCR_MS; | ||
667 | au_sync(); | ||
668 | } | ||
669 | |||
670 | if (hw->rx_count >= hw->len) { | ||
640 | /* transfer completed successfully */ | 671 | /* transfer completed successfully */ |
641 | au1550_spi_mask_ack_all(hw); | 672 | au1550_spi_mask_ack_all(hw); |
642 | complete(&hw->master_done); | 673 | complete(&hw->master_done); |
@@ -725,6 +756,8 @@ static void __init au1550_spi_setup_psc_as_spi(struct au1550_spi *hw) | |||
725 | stat = hw->regs->psc_spistat; | 756 | stat = hw->regs->psc_spistat; |
726 | au_sync(); | 757 | au_sync(); |
727 | } while ((stat & PSC_SPISTAT_DR) == 0); | 758 | } while ((stat & PSC_SPISTAT_DR) == 0); |
759 | |||
760 | au1550_spi_reset_fifos(hw); | ||
728 | } | 761 | } |
729 | 762 | ||
730 | 763 | ||
@@ -732,6 +765,7 @@ static int __init au1550_spi_probe(struct platform_device *pdev) | |||
732 | { | 765 | { |
733 | struct au1550_spi *hw; | 766 | struct au1550_spi *hw; |
734 | struct spi_master *master; | 767 | struct spi_master *master; |
768 | struct resource *r; | ||
735 | int err = 0; | 769 | int err = 0; |
736 | 770 | ||
737 | master = spi_alloc_master(&pdev->dev, sizeof(struct au1550_spi)); | 771 | master = spi_alloc_master(&pdev->dev, sizeof(struct au1550_spi)); |
@@ -753,76 +787,64 @@ static int __init au1550_spi_probe(struct platform_device *pdev) | |||
753 | goto err_no_pdata; | 787 | goto err_no_pdata; |
754 | } | 788 | } |
755 | 789 | ||
756 | platform_set_drvdata(pdev, hw); | 790 | r = platform_get_resource(pdev, IORESOURCE_IRQ, 0); |
757 | 791 | if (!r) { | |
758 | init_completion(&hw->master_done); | 792 | dev_err(&pdev->dev, "no IRQ\n"); |
759 | 793 | err = -ENODEV; | |
760 | hw->bitbang.master = hw->master; | 794 | goto err_no_iores; |
761 | hw->bitbang.setup_transfer = au1550_spi_setupxfer; | 795 | } |
762 | hw->bitbang.chipselect = au1550_spi_chipsel; | 796 | hw->irq = r->start; |
763 | hw->bitbang.master->setup = au1550_spi_setup; | 797 | |
764 | hw->bitbang.txrx_bufs = au1550_spi_txrx_bufs; | 798 | hw->usedma = 0; |
799 | r = platform_get_resource(pdev, IORESOURCE_DMA, 0); | ||
800 | if (r) { | ||
801 | hw->dma_tx_id = r->start; | ||
802 | r = platform_get_resource(pdev, IORESOURCE_DMA, 1); | ||
803 | if (r) { | ||
804 | hw->dma_rx_id = r->start; | ||
805 | if (usedma && ddma_memid) { | ||
806 | if (pdev->dev.dma_mask == NULL) | ||
807 | dev_warn(&pdev->dev, "no dma mask\n"); | ||
808 | else | ||
809 | hw->usedma = 1; | ||
810 | } | ||
811 | } | ||
812 | } | ||
765 | 813 | ||
766 | switch (hw->pdata->bus_num) { | 814 | r = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
767 | case 0: | 815 | if (!r) { |
768 | hw->irq = AU1550_PSC0_INT; | 816 | dev_err(&pdev->dev, "no mmio resource\n"); |
769 | hw->regs = (volatile psc_spi_t *)PSC0_BASE_ADDR; | 817 | err = -ENODEV; |
770 | hw->dma_rx_id = DSCR_CMD0_PSC0_RX; | 818 | goto err_no_iores; |
771 | hw->dma_tx_id = DSCR_CMD0_PSC0_TX; | ||
772 | break; | ||
773 | case 1: | ||
774 | hw->irq = AU1550_PSC1_INT; | ||
775 | hw->regs = (volatile psc_spi_t *)PSC1_BASE_ADDR; | ||
776 | hw->dma_rx_id = DSCR_CMD0_PSC1_RX; | ||
777 | hw->dma_tx_id = DSCR_CMD0_PSC1_TX; | ||
778 | break; | ||
779 | case 2: | ||
780 | hw->irq = AU1550_PSC2_INT; | ||
781 | hw->regs = (volatile psc_spi_t *)PSC2_BASE_ADDR; | ||
782 | hw->dma_rx_id = DSCR_CMD0_PSC2_RX; | ||
783 | hw->dma_tx_id = DSCR_CMD0_PSC2_TX; | ||
784 | break; | ||
785 | case 3: | ||
786 | hw->irq = AU1550_PSC3_INT; | ||
787 | hw->regs = (volatile psc_spi_t *)PSC3_BASE_ADDR; | ||
788 | hw->dma_rx_id = DSCR_CMD0_PSC3_RX; | ||
789 | hw->dma_tx_id = DSCR_CMD0_PSC3_TX; | ||
790 | break; | ||
791 | default: | ||
792 | dev_err(&pdev->dev, "Wrong bus_num of SPI\n"); | ||
793 | err = -ENOENT; | ||
794 | goto err_no_pdata; | ||
795 | } | 819 | } |
796 | 820 | ||
797 | if (request_mem_region((unsigned long)hw->regs, sizeof(psc_spi_t), | 821 | hw->ioarea = request_mem_region(r->start, sizeof(psc_spi_t), |
798 | pdev->name) == NULL) { | 822 | pdev->name); |
823 | if (!hw->ioarea) { | ||
799 | dev_err(&pdev->dev, "Cannot reserve iomem region\n"); | 824 | dev_err(&pdev->dev, "Cannot reserve iomem region\n"); |
800 | err = -ENXIO; | 825 | err = -ENXIO; |
801 | goto err_no_iores; | 826 | goto err_no_iores; |
802 | } | 827 | } |
803 | 828 | ||
804 | 829 | hw->regs = (psc_spi_t __iomem *)ioremap(r->start, sizeof(psc_spi_t)); | |
805 | if (usedma) { | 830 | if (!hw->regs) { |
806 | if (pdev->dev.dma_mask == NULL) | 831 | dev_err(&pdev->dev, "cannot ioremap\n"); |
807 | dev_warn(&pdev->dev, "no dma mask\n"); | 832 | err = -ENXIO; |
808 | else | 833 | goto err_ioremap; |
809 | hw->usedma = 1; | ||
810 | } | 834 | } |
811 | 835 | ||
812 | if (hw->usedma) { | 836 | platform_set_drvdata(pdev, hw); |
813 | /* | 837 | |
814 | * create memory device with 8 bits dev_devwidth | 838 | init_completion(&hw->master_done); |
815 | * needed for proper byte ordering to spi fifo | 839 | |
816 | */ | 840 | hw->bitbang.master = hw->master; |
817 | int memid = au1xxx_ddma_add_device(&au1550_spi_mem_dbdev); | 841 | hw->bitbang.setup_transfer = au1550_spi_setupxfer; |
818 | if (!memid) { | 842 | hw->bitbang.chipselect = au1550_spi_chipsel; |
819 | dev_err(&pdev->dev, | 843 | hw->bitbang.master->setup = au1550_spi_setup; |
820 | "Cannot create dma 8 bit mem device\n"); | 844 | hw->bitbang.txrx_bufs = au1550_spi_txrx_bufs; |
821 | err = -ENXIO; | ||
822 | goto err_dma_add_dev; | ||
823 | } | ||
824 | 845 | ||
825 | hw->dma_tx_ch = au1xxx_dbdma_chan_alloc(memid, | 846 | if (hw->usedma) { |
847 | hw->dma_tx_ch = au1xxx_dbdma_chan_alloc(ddma_memid, | ||
826 | hw->dma_tx_id, NULL, (void *)hw); | 848 | hw->dma_tx_id, NULL, (void *)hw); |
827 | if (hw->dma_tx_ch == 0) { | 849 | if (hw->dma_tx_ch == 0) { |
828 | dev_err(&pdev->dev, | 850 | dev_err(&pdev->dev, |
@@ -841,7 +863,7 @@ static int __init au1550_spi_probe(struct platform_device *pdev) | |||
841 | 863 | ||
842 | 864 | ||
843 | hw->dma_rx_ch = au1xxx_dbdma_chan_alloc(hw->dma_rx_id, | 865 | hw->dma_rx_ch = au1xxx_dbdma_chan_alloc(hw->dma_rx_id, |
844 | memid, NULL, (void *)hw); | 866 | ddma_memid, NULL, (void *)hw); |
845 | if (hw->dma_rx_ch == 0) { | 867 | if (hw->dma_rx_ch == 0) { |
846 | dev_err(&pdev->dev, | 868 | dev_err(&pdev->dev, |
847 | "Cannot allocate rx dma channel\n"); | 869 | "Cannot allocate rx dma channel\n"); |
@@ -874,7 +896,7 @@ static int __init au1550_spi_probe(struct platform_device *pdev) | |||
874 | goto err_no_irq; | 896 | goto err_no_irq; |
875 | } | 897 | } |
876 | 898 | ||
877 | master->bus_num = hw->pdata->bus_num; | 899 | master->bus_num = pdev->id; |
878 | master->num_chipselect = hw->pdata->num_chipselect; | 900 | master->num_chipselect = hw->pdata->num_chipselect; |
879 | 901 | ||
880 | /* | 902 | /* |
@@ -924,8 +946,11 @@ err_no_txdma_descr: | |||
924 | au1xxx_dbdma_chan_free(hw->dma_tx_ch); | 946 | au1xxx_dbdma_chan_free(hw->dma_tx_ch); |
925 | 947 | ||
926 | err_no_txdma: | 948 | err_no_txdma: |
927 | err_dma_add_dev: | 949 | iounmap((void __iomem *)hw->regs); |
928 | release_mem_region((unsigned long)hw->regs, sizeof(psc_spi_t)); | 950 | |
951 | err_ioremap: | ||
952 | release_resource(hw->ioarea); | ||
953 | kfree(hw->ioarea); | ||
929 | 954 | ||
930 | err_no_iores: | 955 | err_no_iores: |
931 | err_no_pdata: | 956 | err_no_pdata: |
@@ -944,7 +969,9 @@ static int __exit au1550_spi_remove(struct platform_device *pdev) | |||
944 | 969 | ||
945 | spi_bitbang_stop(&hw->bitbang); | 970 | spi_bitbang_stop(&hw->bitbang); |
946 | free_irq(hw->irq, hw); | 971 | free_irq(hw->irq, hw); |
947 | release_mem_region((unsigned long)hw->regs, sizeof(psc_spi_t)); | 972 | iounmap((void __iomem *)hw->regs); |
973 | release_resource(hw->ioarea); | ||
974 | kfree(hw->ioarea); | ||
948 | 975 | ||
949 | if (hw->usedma) { | 976 | if (hw->usedma) { |
950 | au1550_spi_dma_rxtmp_free(hw); | 977 | au1550_spi_dma_rxtmp_free(hw); |
@@ -971,12 +998,24 @@ static struct platform_driver au1550_spi_drv = { | |||
971 | 998 | ||
972 | static int __init au1550_spi_init(void) | 999 | static int __init au1550_spi_init(void) |
973 | { | 1000 | { |
1001 | /* | ||
1002 | * create memory device with 8 bits dev_devwidth | ||
1003 | * needed for proper byte ordering to spi fifo | ||
1004 | */ | ||
1005 | if (usedma) { | ||
1006 | ddma_memid = au1xxx_ddma_add_device(&au1550_spi_mem_dbdev); | ||
1007 | if (!ddma_memid) | ||
1008 | printk(KERN_ERR "au1550-spi: cannot add memory" | ||
1009 | "dbdma device\n"); | ||
1010 | } | ||
974 | return platform_driver_probe(&au1550_spi_drv, au1550_spi_probe); | 1011 | return platform_driver_probe(&au1550_spi_drv, au1550_spi_probe); |
975 | } | 1012 | } |
976 | module_init(au1550_spi_init); | 1013 | module_init(au1550_spi_init); |
977 | 1014 | ||
978 | static void __exit au1550_spi_exit(void) | 1015 | static void __exit au1550_spi_exit(void) |
979 | { | 1016 | { |
1017 | if (usedma && ddma_memid) | ||
1018 | au1xxx_ddma_del_device(ddma_memid); | ||
980 | platform_driver_unregister(&au1550_spi_drv); | 1019 | platform_driver_unregister(&au1550_spi_drv); |
981 | } | 1020 | } |
982 | module_exit(au1550_spi_exit); | 1021 | module_exit(au1550_spi_exit); |
diff --git a/drivers/spi/omap2_mcspi.c b/drivers/spi/omap2_mcspi.c index b1cc148036c1..f6f987bb71ca 100644 --- a/drivers/spi/omap2_mcspi.c +++ b/drivers/spi/omap2_mcspi.c | |||
@@ -836,7 +836,7 @@ static int omap2_mcspi_transfer(struct spi_device *spi, struct spi_message *m) | |||
836 | if (tx_buf != NULL) { | 836 | if (tx_buf != NULL) { |
837 | t->tx_dma = dma_map_single(&spi->dev, (void *) tx_buf, | 837 | t->tx_dma = dma_map_single(&spi->dev, (void *) tx_buf, |
838 | len, DMA_TO_DEVICE); | 838 | len, DMA_TO_DEVICE); |
839 | if (dma_mapping_error(t->tx_dma)) { | 839 | if (dma_mapping_error(&spi->dev, t->tx_dma)) { |
840 | dev_dbg(&spi->dev, "dma %cX %d bytes error\n", | 840 | dev_dbg(&spi->dev, "dma %cX %d bytes error\n", |
841 | 'T', len); | 841 | 'T', len); |
842 | return -EINVAL; | 842 | return -EINVAL; |
@@ -845,7 +845,7 @@ static int omap2_mcspi_transfer(struct spi_device *spi, struct spi_message *m) | |||
845 | if (rx_buf != NULL) { | 845 | if (rx_buf != NULL) { |
846 | t->rx_dma = dma_map_single(&spi->dev, rx_buf, t->len, | 846 | t->rx_dma = dma_map_single(&spi->dev, rx_buf, t->len, |
847 | DMA_FROM_DEVICE); | 847 | DMA_FROM_DEVICE); |
848 | if (dma_mapping_error(t->rx_dma)) { | 848 | if (dma_mapping_error(&spi->dev, t->rx_dma)) { |
849 | dev_dbg(&spi->dev, "dma %cX %d bytes error\n", | 849 | dev_dbg(&spi->dev, "dma %cX %d bytes error\n", |
850 | 'R', len); | 850 | 'R', len); |
851 | if (tx_buf != NULL) | 851 | if (tx_buf != NULL) |
diff --git a/drivers/spi/pxa2xx_spi.c b/drivers/spi/pxa2xx_spi.c index 0c452c46ab07..067299d6d192 100644 --- a/drivers/spi/pxa2xx_spi.c +++ b/drivers/spi/pxa2xx_spi.c | |||
@@ -353,7 +353,7 @@ static int map_dma_buffers(struct driver_data *drv_data) | |||
353 | drv_data->rx_dma = dma_map_single(dev, drv_data->rx, | 353 | drv_data->rx_dma = dma_map_single(dev, drv_data->rx, |
354 | drv_data->rx_map_len, | 354 | drv_data->rx_map_len, |
355 | DMA_FROM_DEVICE); | 355 | DMA_FROM_DEVICE); |
356 | if (dma_mapping_error(drv_data->rx_dma)) | 356 | if (dma_mapping_error(dev, drv_data->rx_dma)) |
357 | return 0; | 357 | return 0; |
358 | 358 | ||
359 | /* Stream map the tx buffer */ | 359 | /* Stream map the tx buffer */ |
@@ -361,7 +361,7 @@ static int map_dma_buffers(struct driver_data *drv_data) | |||
361 | drv_data->tx_map_len, | 361 | drv_data->tx_map_len, |
362 | DMA_TO_DEVICE); | 362 | DMA_TO_DEVICE); |
363 | 363 | ||
364 | if (dma_mapping_error(drv_data->tx_dma)) { | 364 | if (dma_mapping_error(dev, drv_data->tx_dma)) { |
365 | dma_unmap_single(dev, drv_data->rx_dma, | 365 | dma_unmap_single(dev, drv_data->rx_dma, |
366 | drv_data->rx_map_len, DMA_FROM_DEVICE); | 366 | drv_data->rx_map_len, DMA_FROM_DEVICE); |
367 | return 0; | 367 | return 0; |
diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c index 1ad12afc6ba0..ecca4a6a6f94 100644 --- a/drivers/spi/spi.c +++ b/drivers/spi/spi.c | |||
@@ -218,6 +218,8 @@ struct spi_device *spi_new_device(struct spi_master *master, | |||
218 | if (!spi_master_get(master)) | 218 | if (!spi_master_get(master)) |
219 | return NULL; | 219 | return NULL; |
220 | 220 | ||
221 | WARN_ON(strlen(chip->modalias) >= sizeof(proxy->modalias)); | ||
222 | |||
221 | proxy = kzalloc(sizeof *proxy, GFP_KERNEL); | 223 | proxy = kzalloc(sizeof *proxy, GFP_KERNEL); |
222 | if (!proxy) { | 224 | if (!proxy) { |
223 | dev_err(dev, "can't alloc dev for cs%d\n", | 225 | dev_err(dev, "can't alloc dev for cs%d\n", |
@@ -229,7 +231,7 @@ struct spi_device *spi_new_device(struct spi_master *master, | |||
229 | proxy->max_speed_hz = chip->max_speed_hz; | 231 | proxy->max_speed_hz = chip->max_speed_hz; |
230 | proxy->mode = chip->mode; | 232 | proxy->mode = chip->mode; |
231 | proxy->irq = chip->irq; | 233 | proxy->irq = chip->irq; |
232 | proxy->modalias = chip->modalias; | 234 | strlcpy(proxy->modalias, chip->modalias, sizeof(proxy->modalias)); |
233 | 235 | ||
234 | snprintf(proxy->dev.bus_id, sizeof proxy->dev.bus_id, | 236 | snprintf(proxy->dev.bus_id, sizeof proxy->dev.bus_id, |
235 | "%s.%u", master->dev.bus_id, | 237 | "%s.%u", master->dev.bus_id, |
@@ -502,7 +504,7 @@ struct spi_master *spi_busnum_to_master(u16 bus_num) | |||
502 | struct device *dev; | 504 | struct device *dev; |
503 | struct spi_master *master = NULL; | 505 | struct spi_master *master = NULL; |
504 | 506 | ||
505 | dev = class_find_device(&spi_master_class, &bus_num, | 507 | dev = class_find_device(&spi_master_class, NULL, &bus_num, |
506 | __spi_master_match); | 508 | __spi_master_match); |
507 | if (dev) | 509 | if (dev) |
508 | master = container_of(dev, struct spi_master, dev); | 510 | master = container_of(dev, struct spi_master, dev); |
diff --git a/drivers/spi/spi_imx.c b/drivers/spi/spi_imx.c index 54ac7bea5f8c..6fb77fcc4971 100644 --- a/drivers/spi/spi_imx.c +++ b/drivers/spi/spi_imx.c | |||
@@ -491,7 +491,7 @@ static int map_dma_buffers(struct driver_data *drv_data) | |||
491 | buf, | 491 | buf, |
492 | drv_data->tx_map_len, | 492 | drv_data->tx_map_len, |
493 | DMA_TO_DEVICE); | 493 | DMA_TO_DEVICE); |
494 | if (dma_mapping_error(drv_data->tx_dma)) | 494 | if (dma_mapping_error(dev, drv_data->tx_dma)) |
495 | return -1; | 495 | return -1; |
496 | 496 | ||
497 | drv_data->tx_dma_needs_unmap = 1; | 497 | drv_data->tx_dma_needs_unmap = 1; |
@@ -516,7 +516,7 @@ static int map_dma_buffers(struct driver_data *drv_data) | |||
516 | buf, | 516 | buf, |
517 | drv_data->len, | 517 | drv_data->len, |
518 | DMA_FROM_DEVICE); | 518 | DMA_FROM_DEVICE); |
519 | if (dma_mapping_error(drv_data->rx_dma)) | 519 | if (dma_mapping_error(dev, drv_data->rx_dma)) |
520 | return -1; | 520 | return -1; |
521 | drv_data->rx_dma_needs_unmap = 1; | 521 | drv_data->rx_dma_needs_unmap = 1; |
522 | } | 522 | } |
@@ -534,7 +534,7 @@ static int map_dma_buffers(struct driver_data *drv_data) | |||
534 | buf, | 534 | buf, |
535 | drv_data->tx_map_len, | 535 | drv_data->tx_map_len, |
536 | DMA_TO_DEVICE); | 536 | DMA_TO_DEVICE); |
537 | if (dma_mapping_error(drv_data->tx_dma)) { | 537 | if (dma_mapping_error(dev, drv_data->tx_dma)) { |
538 | if (drv_data->rx_dma) { | 538 | if (drv_data->rx_dma) { |
539 | dma_unmap_single(dev, | 539 | dma_unmap_single(dev, |
540 | drv_data->rx_dma, | 540 | drv_data->rx_dma, |
diff --git a/drivers/spi/spi_mpc83xx.c b/drivers/spi/spi_mpc83xx.c index 6832da6f7109..070c6219e2d6 100644 --- a/drivers/spi/spi_mpc83xx.c +++ b/drivers/spi/spi_mpc83xx.c | |||
@@ -266,21 +266,24 @@ int mpc83xx_spi_setup_transfer(struct spi_device *spi, struct spi_transfer *t) | |||
266 | 266 | ||
267 | cs->hw_mode |= SPMODE_LEN(bits_per_word); | 267 | cs->hw_mode |= SPMODE_LEN(bits_per_word); |
268 | 268 | ||
269 | if ((mpc83xx_spi->spibrg / hz) >= 64) { | 269 | if ((mpc83xx_spi->spibrg / hz) > 64) { |
270 | pm = mpc83xx_spi->spibrg / (hz * 64) - 1; | 270 | pm = mpc83xx_spi->spibrg / (hz * 64); |
271 | if (pm > 0x0f) { | 271 | if (pm > 16) { |
272 | dev_err(&spi->dev, "Requested speed is too " | 272 | cs->hw_mode |= SPMODE_DIV16; |
273 | "low: %d Hz. Will use %d Hz instead.\n", | 273 | pm /= 16; |
274 | hz, mpc83xx_spi->spibrg / 1024); | 274 | if (pm > 16) { |
275 | pm = 0x0f; | 275 | dev_err(&spi->dev, "Requested speed is too " |
276 | "low: %d Hz. Will use %d Hz instead.\n", | ||
277 | hz, mpc83xx_spi->spibrg / 1024); | ||
278 | pm = 16; | ||
279 | } | ||
276 | } | 280 | } |
277 | cs->hw_mode |= SPMODE_PM(pm) | SPMODE_DIV16; | 281 | } else |
278 | } else { | ||
279 | pm = mpc83xx_spi->spibrg / (hz * 4); | 282 | pm = mpc83xx_spi->spibrg / (hz * 4); |
280 | if (pm) | 283 | if (pm) |
281 | pm--; | 284 | pm--; |
282 | cs->hw_mode |= SPMODE_PM(pm); | 285 | |
283 | } | 286 | cs->hw_mode |= SPMODE_PM(pm); |
284 | regval = mpc83xx_spi_read_reg(&mpc83xx_spi->base->mode); | 287 | regval = mpc83xx_spi_read_reg(&mpc83xx_spi->base->mode); |
285 | if (cs->hw_mode != regval) { | 288 | if (cs->hw_mode != regval) { |
286 | unsigned long flags; | 289 | unsigned long flags; |
diff --git a/drivers/spi/spidev.c b/drivers/spi/spidev.c index ddbe1a5e970e..e5e0cfed5e3b 100644 --- a/drivers/spi/spidev.c +++ b/drivers/spi/spidev.c | |||
@@ -228,7 +228,6 @@ static int spidev_message(struct spidev_data *spidev, | |||
228 | * We walk the array of user-provided transfers, using each one | 228 | * We walk the array of user-provided transfers, using each one |
229 | * to initialize a kernel version of the same transfer. | 229 | * to initialize a kernel version of the same transfer. |
230 | */ | 230 | */ |
231 | mutex_lock(&spidev->buf_lock); | ||
232 | buf = spidev->buffer; | 231 | buf = spidev->buffer; |
233 | total = 0; | 232 | total = 0; |
234 | for (n = n_xfers, k_tmp = k_xfers, u_tmp = u_xfers; | 233 | for (n = n_xfers, k_tmp = k_xfers, u_tmp = u_xfers; |
@@ -296,14 +295,12 @@ static int spidev_message(struct spidev_data *spidev, | |||
296 | status = total; | 295 | status = total; |
297 | 296 | ||
298 | done: | 297 | done: |
299 | mutex_unlock(&spidev->buf_lock); | ||
300 | kfree(k_xfers); | 298 | kfree(k_xfers); |
301 | return status; | 299 | return status; |
302 | } | 300 | } |
303 | 301 | ||
304 | static int | 302 | static long |
305 | spidev_ioctl(struct inode *inode, struct file *filp, | 303 | spidev_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) |
306 | unsigned int cmd, unsigned long arg) | ||
307 | { | 304 | { |
308 | int err = 0; | 305 | int err = 0; |
309 | int retval = 0; | 306 | int retval = 0; |
@@ -341,6 +338,14 @@ spidev_ioctl(struct inode *inode, struct file *filp, | |||
341 | if (spi == NULL) | 338 | if (spi == NULL) |
342 | return -ESHUTDOWN; | 339 | return -ESHUTDOWN; |
343 | 340 | ||
341 | /* use the buffer lock here for triple duty: | ||
342 | * - prevent I/O (from us) so calling spi_setup() is safe; | ||
343 | * - prevent concurrent SPI_IOC_WR_* from morphing | ||
344 | * data fields while SPI_IOC_RD_* reads them; | ||
345 | * - SPI_IOC_MESSAGE needs the buffer locked "normally". | ||
346 | */ | ||
347 | mutex_lock(&spidev->buf_lock); | ||
348 | |||
344 | switch (cmd) { | 349 | switch (cmd) { |
345 | /* read requests */ | 350 | /* read requests */ |
346 | case SPI_IOC_RD_MODE: | 351 | case SPI_IOC_RD_MODE: |
@@ -456,6 +461,8 @@ spidev_ioctl(struct inode *inode, struct file *filp, | |||
456 | kfree(ioc); | 461 | kfree(ioc); |
457 | break; | 462 | break; |
458 | } | 463 | } |
464 | |||
465 | mutex_unlock(&spidev->buf_lock); | ||
459 | spi_dev_put(spi); | 466 | spi_dev_put(spi); |
460 | return retval; | 467 | return retval; |
461 | } | 468 | } |
@@ -533,7 +540,7 @@ static struct file_operations spidev_fops = { | |||
533 | */ | 540 | */ |
534 | .write = spidev_write, | 541 | .write = spidev_write, |
535 | .read = spidev_read, | 542 | .read = spidev_read, |
536 | .ioctl = spidev_ioctl, | 543 | .unlocked_ioctl = spidev_ioctl, |
537 | .open = spidev_open, | 544 | .open = spidev_open, |
538 | .release = spidev_release, | 545 | .release = spidev_release, |
539 | }; | 546 | }; |
@@ -576,7 +583,8 @@ static int spidev_probe(struct spi_device *spi) | |||
576 | struct device *dev; | 583 | struct device *dev; |
577 | 584 | ||
578 | spidev->devt = MKDEV(SPIDEV_MAJOR, minor); | 585 | spidev->devt = MKDEV(SPIDEV_MAJOR, minor); |
579 | dev = device_create(spidev_class, &spi->dev, spidev->devt, | 586 | dev = device_create_drvdata(spidev_class, &spi->dev, |
587 | spidev->devt, spidev, | ||
580 | "spidev%d.%d", | 588 | "spidev%d.%d", |
581 | spi->master->bus_num, spi->chip_select); | 589 | spi->master->bus_num, spi->chip_select); |
582 | status = IS_ERR(dev) ? PTR_ERR(dev) : 0; | 590 | status = IS_ERR(dev) ? PTR_ERR(dev) : 0; |
@@ -586,7 +594,6 @@ static int spidev_probe(struct spi_device *spi) | |||
586 | } | 594 | } |
587 | if (status == 0) { | 595 | if (status == 0) { |
588 | set_bit(minor, minors); | 596 | set_bit(minor, minors); |
589 | spi_set_drvdata(spi, spidev); | ||
590 | list_add(&spidev->device_entry, &device_list); | 597 | list_add(&spidev->device_entry, &device_list); |
591 | } | 598 | } |
592 | mutex_unlock(&device_list_lock); | 599 | mutex_unlock(&device_list_lock); |
diff --git a/drivers/spi/xilinx_spi.c b/drivers/spi/xilinx_spi.c index 113a0468ffcb..68d6f4988fb5 100644 --- a/drivers/spi/xilinx_spi.c +++ b/drivers/spi/xilinx_spi.c | |||
@@ -353,11 +353,12 @@ static int __init xilinx_spi_probe(struct platform_device *dev) | |||
353 | goto put_master; | 353 | goto put_master; |
354 | } | 354 | } |
355 | 355 | ||
356 | xspi->irq = platform_get_irq(dev, 0); | 356 | ret = platform_get_irq(dev, 0); |
357 | if (xspi->irq < 0) { | 357 | if (ret < 0) { |
358 | ret = -ENXIO; | 358 | ret = -ENXIO; |
359 | goto unmap_io; | 359 | goto unmap_io; |
360 | } | 360 | } |
361 | xspi->irq = ret; | ||
361 | 362 | ||
362 | master->bus_num = pdata->bus_num; | 363 | master->bus_num = pdata->bus_num; |
363 | master->num_chipselect = pdata->num_chipselect; | 364 | master->num_chipselect = pdata->num_chipselect; |