1 --- a/arch/arm/mach-s3c2410/include/mach/spi-gpio.h
2 +++ b/arch/arm/mach-s3c2410/include/mach/spi-gpio.h
3 @@ -21,7 +21,8 @@ struct s3c2410_spigpio_info {
7 - void (*chip_select)(struct s3c2410_spigpio_info *spi, int cs);
8 + int non_blocking_transfer;
9 + void (*chip_select)(struct s3c2410_spigpio_info *spi, int csid, int cs);
13 --- a/drivers/spi/spi_bitbang.c
14 +++ b/drivers/spi/spi_bitbang.c
15 @@ -264,6 +264,123 @@ static int spi_bitbang_bufs(struct spi_d
16 * Drivers can provide word-at-a-time i/o primitives, or provide
17 * transfer-at-a-time ones to leverage dma or fifo hardware.
20 +/* Synchronous non blocking transfer */
22 +spi_bitbang_transfer_sync(struct spi_device *spi, struct spi_message *m)
24 + struct spi_bitbang *bitbang = spi_master_get_devdata(spi->master);
25 + struct spi_transfer *t;
26 + unsigned long flags;
30 + int (*setup_transfer)(struct spi_device *, struct spi_transfer *);
32 + /* FIXME this is made-up ... the correct value is known to
33 + * word-at-a-time bitbang code, and presumably chipselect()
34 + * should enforce these requirements too?
39 + setup_transfer = NULL;
41 + local_irq_save(flags);
42 + list_for_each_entry (t, &m->transfers, transfer_list) {
43 + /* override or restore speed and wordsize */
44 + if (t->speed_hz || t->bits_per_word) {
45 + setup_transfer = bitbang->setup_transfer;
46 + if (!setup_transfer) {
47 + status = -ENOPROTOOPT;
51 + if (setup_transfer) {
52 + status = setup_transfer(spi, t);
57 + /* set up default clock polarity, and activate chip;
58 + * this implicitly updates clock and spi modes as
59 + * previously recorded for this device via setup().
60 + * (and also deselects any other chip that might be
65 + bitbang->chipselect(spi, BITBANG_CS_ACTIVE);
69 + cs_change = t->cs_change;
70 + if (!t->tx_buf && !t->rx_buf && t->len) {
75 + /* transfer data. the lower level code handles any
76 + * new dma mappings it needs. our caller always gave
77 + * us dma-safe buffers.
80 + /* REVISIT dma API still needs a designated
81 + * DMA_ADDR_INVALID; ~0 might be better.
83 + if (!m->is_dma_mapped)
84 + t->rx_dma = t->tx_dma = 0;
85 + status = bitbang->txrx_bufs(spi, t);
89 + m->actual_length += status;
90 + if (status != t->len) {
91 + /* always report some kind of error */
93 + status = -EREMOTEIO;
97 + /* protocol tweaks before next transfer */
99 + udelay(t->delay_usecs);
102 + if (t->transfer_list.next == &m->transfers)
104 + /* sometimes a short mid-message deselect of the chip
105 + * may be needed to terminate a mode or command
108 + bitbang->chipselect(spi, BITBANG_CS_INACTIVE);
112 + m->status = status;
114 + m->complete(m->context);
116 + /* restore speed and wordsize */
117 + if (setup_transfer)
118 + setup_transfer(spi, NULL);
120 + /* normally deactivate chipselect ... unless no error and
121 + * cs_change has hinted that the next message will probably
122 + * be for this chip too.
124 + if (!(status == 0 && cs_change)) {
126 + bitbang->chipselect(spi, BITBANG_CS_INACTIVE);
130 + local_irq_restore(flags);
134 +EXPORT_SYMBOL_GPL(spi_bitbang_transfer_sync);
136 static void bitbang_work(struct work_struct *work)
138 struct spi_bitbang *bitbang =
139 @@ -274,120 +391,13 @@ static void bitbang_work(struct work_str
141 while (!list_empty(&bitbang->queue)) {
142 struct spi_message *m;
143 - struct spi_device *spi;
145 - struct spi_transfer *t = NULL;
147 - unsigned cs_change;
149 - int (*setup_transfer)(struct spi_device *,
150 - struct spi_transfer *);
152 m = container_of(bitbang->queue.next, struct spi_message,
154 list_del_init(&m->queue);
155 - spin_unlock_irqrestore(&bitbang->lock, flags);
157 - /* FIXME this is made-up ... the correct value is known to
158 - * word-at-a-time bitbang code, and presumably chipselect()
159 - * should enforce these requirements too?
167 - setup_transfer = NULL;
169 - list_for_each_entry (t, &m->transfers, transfer_list) {
171 - /* override or restore speed and wordsize */
172 - if (t->speed_hz || t->bits_per_word) {
173 - setup_transfer = bitbang->setup_transfer;
174 - if (!setup_transfer) {
175 - status = -ENOPROTOOPT;
179 - if (setup_transfer) {
180 - status = setup_transfer(spi, t);
185 - /* set up default clock polarity, and activate chip;
186 - * this implicitly updates clock and spi modes as
187 - * previously recorded for this device via setup().
188 - * (and also deselects any other chip that might be
192 - bitbang->chipselect(spi, BITBANG_CS_ACTIVE);
195 - cs_change = t->cs_change;
196 - if (!t->tx_buf && !t->rx_buf && t->len) {
201 - /* transfer data. the lower level code handles any
202 - * new dma mappings it needs. our caller always gave
203 - * us dma-safe buffers.
206 - /* REVISIT dma API still needs a designated
207 - * DMA_ADDR_INVALID; ~0 might be better.
209 - if (!m->is_dma_mapped)
210 - t->rx_dma = t->tx_dma = 0;
211 - status = bitbang->txrx_bufs(spi, t);
214 - m->actual_length += status;
215 - if (status != t->len) {
216 - /* always report some kind of error */
218 - status = -EREMOTEIO;
223 - /* protocol tweaks before next transfer */
224 - if (t->delay_usecs)
225 - udelay(t->delay_usecs);
229 - if (t->transfer_list.next == &m->transfers)
232 - /* sometimes a short mid-message deselect of the chip
233 - * may be needed to terminate a mode or command
236 - bitbang->chipselect(spi, BITBANG_CS_INACTIVE);
240 - m->status = status;
241 - m->complete(m->context);
243 - /* restore speed and wordsize */
244 - if (setup_transfer)
245 - setup_transfer(spi, NULL);
247 - /* normally deactivate chipselect ... unless no error and
248 - * cs_change has hinted that the next message will probably
249 - * be for this chip too.
251 - if (!(status == 0 && cs_change)) {
253 - bitbang->chipselect(spi, BITBANG_CS_INACTIVE);
257 + spin_unlock_irqrestore(&bitbang->lock, flags);
258 + spi_bitbang_transfer_sync(m->spi, m);
259 spin_lock_irqsave(&bitbang->lock, flags);
262 @@ -459,6 +469,9 @@ int spi_bitbang_start(struct spi_bitbang
264 if (!bitbang->master->transfer)
265 bitbang->master->transfer = spi_bitbang_transfer;
266 + if (!bitbang->master->transfer_sync && bitbang->non_blocking_transfer)
267 + bitbang->master->transfer_sync = spi_bitbang_transfer_sync;
269 if (!bitbang->txrx_bufs) {
270 bitbang->use_dma = 0;
271 bitbang->txrx_bufs = spi_bitbang_bufs;
272 --- a/drivers/spi/spi_s3c24xx_gpio.c
273 +++ b/drivers/spi/spi_s3c24xx_gpio.c
274 @@ -91,7 +91,7 @@ static void s3c2410_spigpio_chipselect(s
275 struct s3c2410_spigpio *sg = spidev_to_sg(dev);
277 if (sg->info && sg->info->chip_select)
278 - (sg->info->chip_select)(sg->info, value);
279 + (sg->info->chip_select)(sg->info, dev->chip_select, value);
282 static int s3c2410_spigpio_probe(struct platform_device *dev)
283 @@ -112,14 +112,17 @@ static int s3c2410_spigpio_probe(struct
285 platform_set_drvdata(dev, sp);
287 - /* copy in the plkatform data */
288 + /* copy in the platform data */
289 info = sp->info = dev->dev.platform_data;
291 + master->num_chipselect = info->num_chipselect;
293 /* setup spi bitbang adaptor */
294 sp->bitbang.master = spi_master_get(master);
295 sp->bitbang.master->bus_num = info->bus_num;
296 sp->bitbang.master->num_chipselect = info->num_chipselect;
297 sp->bitbang.chipselect = s3c2410_spigpio_chipselect;
298 + sp->bitbang.non_blocking_transfer = info->non_blocking_transfer;
300 sp->bitbang.txrx_word[SPI_MODE_0] = s3c2410_spigpio_txrx_mode0;
301 sp->bitbang.txrx_word[SPI_MODE_1] = s3c2410_spigpio_txrx_mode1;
302 --- a/include/linux/mmc/core.h
303 +++ b/include/linux/mmc/core.h
304 @@ -129,6 +129,8 @@ struct mmc_request {
308 +extern void mmc_flush_scheduled_work(void);
310 extern void mmc_wait_for_req(struct mmc_host *, struct mmc_request *);
311 extern int mmc_wait_for_cmd(struct mmc_host *, struct mmc_command *, int);
312 extern int mmc_wait_for_app_cmd(struct mmc_host *, struct mmc_card *,
313 --- a/include/linux/mmc/sdio_ids.h
314 +++ b/include/linux/mmc/sdio_ids.h
317 #define SDIO_VENDOR_ID_MARVELL 0x02df
318 #define SDIO_DEVICE_ID_MARVELL_LIBERTAS 0x9103
319 +#define SDIO_DEVICE_ID_MARVELL_88W8688 0x9104
320 +#define SDIO_VENDOR_ID_ATHEROS 0x0271
321 +#define SDIO_DEVICE_ID_ATHEROS_AR6001 0x0100
322 +#define SDIO_DEVICE_ID_ATHEROS_AR6002 0x0200
325 --- a/include/linux/spi/spi_bitbang.h
326 +++ b/include/linux/spi/spi_bitbang.h
327 @@ -31,6 +31,9 @@ struct spi_bitbang {
329 u8 flags; /* extra spi->mode support */
331 + /* Support for synchronous non blocking transfers */
332 + int non_blocking_transfer;
334 struct spi_master *master;
336 /* setup_transfer() changes clock and/or wordsize to match settings
337 @@ -62,6 +65,8 @@ extern void spi_bitbang_cleanup(struct s
338 extern int spi_bitbang_transfer(struct spi_device *spi, struct spi_message *m);
339 extern int spi_bitbang_setup_transfer(struct spi_device *spi,
340 struct spi_transfer *t);
341 +extern int spi_bitbang_transfer_sync(struct spi_device *spi,
342 + struct spi_message *m);
344 /* start or stop queue processing */
345 extern int spi_bitbang_start(struct spi_bitbang *spi);
346 --- a/include/linux/spi/spi.h
347 +++ b/include/linux/spi/spi.h
348 @@ -204,7 +204,6 @@ static inline void spi_unregister_driver
349 * SPI slaves, and are numbered from zero to num_chipselects.
350 * each slave has a chipselect signal, but it's common that not
351 * every chipselect is connected to a slave.
352 - * @dma_alignment: SPI controller constraint on DMA buffers alignment.
353 * @setup: updates the device mode and clocking records used by a
354 * device's SPI controller; protocol code may call this. This
355 * must fail if an unrecognized or unsupported mode is requested.
356 @@ -240,17 +239,7 @@ struct spi_master {
360 - /* some SPI controllers pose alignment requirements on DMAable
361 - * buffers; let protocol drivers know about these requirements.
365 - /* Setup mode and clock, etc (spi driver may call many times).
367 - * IMPORTANT: this may be called when transfers to another
368 - * device are active. DO NOT UPDATE SHARED REGISTERS in ways
369 - * which could break those transfers.
371 + /* setup mode and clock, etc (spi driver may call many times) */
372 int (*setup)(struct spi_device *spi);
374 /* bidirectional bulk transfers
375 @@ -275,6 +264,13 @@ struct spi_master {
376 int (*transfer)(struct spi_device *spi,
377 struct spi_message *mesg);
380 + * Synchronous non blocking transfer function. Should guarantee
381 + * data availability when it returns
383 + int (*transfer_sync)(struct spi_device *spi,
384 + struct spi_message *mesg);
386 /* called on release() to free memory provided by spi_master */
387 void (*cleanup)(struct spi_device *spi);
389 @@ -584,6 +580,29 @@ spi_async(struct spi_device *spi, struct
390 return spi->master->transfer(spi, message);
394 + * spi_non_blocking_transfer - Synchronous, non blocking transfer
395 + * @spi: device with which data will be exchanged
396 + * @message: describes the data transfers with optional completion handlers
397 + * Context: any (irqs may be blocked, etc)
399 + * Data is guaranteed to be written or read when this function returns.
401 + * Note : This may not be supported by all spi masters.
405 +spi_non_blocking_transfer(struct spi_device *spi, struct spi_message *message)
407 + if (unlikely(!spi->master->transfer_sync)) {
408 + dev_err(&spi->master->dev,
409 + "non-blocking transfers not supported\n");
413 + return spi->master->transfer_sync(spi, message);
416 /*---------------------------------------------------------------------------*/
418 /* All these synchronous SPI transfer routines are utilities layered