diff options
Diffstat (limited to 'drivers/spi')
-rw-r--r-- | drivers/spi/mpc52xx_psc_spi.c | 55 | ||||
-rw-r--r-- | drivers/spi/omap2_mcspi.c | 18 | ||||
-rw-r--r-- | drivers/spi/omap_uwire.c | 23 | ||||
-rw-r--r-- | drivers/spi/orion_spi.c | 5 | ||||
-rw-r--r-- | drivers/spi/pxa2xx_spi.c | 54 | ||||
-rw-r--r-- | drivers/spi/spi.c | 24 | ||||
-rw-r--r-- | drivers/spi/spi_s3c24xx.c | 6 |
7 files changed, 86 insertions, 99 deletions
diff --git a/drivers/spi/mpc52xx_psc_spi.c b/drivers/spi/mpc52xx_psc_spi.c index cdb3d3191719..0debe11b67b4 100644 --- a/drivers/spi/mpc52xx_psc_spi.c +++ b/drivers/spi/mpc52xx_psc_spi.c | |||
@@ -15,13 +15,7 @@ | |||
15 | #include <linux/init.h> | 15 | #include <linux/init.h> |
16 | #include <linux/errno.h> | 16 | #include <linux/errno.h> |
17 | #include <linux/interrupt.h> | 17 | #include <linux/interrupt.h> |
18 | |||
19 | #if defined(CONFIG_PPC_MERGE) | ||
20 | #include <linux/of_platform.h> | 18 | #include <linux/of_platform.h> |
21 | #else | ||
22 | #include <linux/platform_device.h> | ||
23 | #endif | ||
24 | |||
25 | #include <linux/workqueue.h> | 19 | #include <linux/workqueue.h> |
26 | #include <linux/completion.h> | 20 | #include <linux/completion.h> |
27 | #include <linux/io.h> | 21 | #include <linux/io.h> |
@@ -471,53 +465,6 @@ static int __exit mpc52xx_psc_spi_do_remove(struct device *dev) | |||
471 | return 0; | 465 | return 0; |
472 | } | 466 | } |
473 | 467 | ||
474 | #if !defined(CONFIG_PPC_MERGE) | ||
475 | static int __init mpc52xx_psc_spi_probe(struct platform_device *dev) | ||
476 | { | ||
477 | switch(dev->id) { | ||
478 | case 1: | ||
479 | case 2: | ||
480 | case 3: | ||
481 | case 6: | ||
482 | return mpc52xx_psc_spi_do_probe(&dev->dev, | ||
483 | MPC52xx_PA(MPC52xx_PSCx_OFFSET(dev->id)), | ||
484 | MPC52xx_PSC_SIZE, platform_get_irq(dev, 0), dev->id); | ||
485 | default: | ||
486 | return -EINVAL; | ||
487 | } | ||
488 | } | ||
489 | |||
490 | static int __exit mpc52xx_psc_spi_remove(struct platform_device *dev) | ||
491 | { | ||
492 | return mpc52xx_psc_spi_do_remove(&dev->dev); | ||
493 | } | ||
494 | |||
495 | /* work with hotplug and coldplug */ | ||
496 | MODULE_ALIAS("platform:mpc52xx-psc-spi"); | ||
497 | |||
498 | static struct platform_driver mpc52xx_psc_spi_platform_driver = { | ||
499 | .remove = __exit_p(mpc52xx_psc_spi_remove), | ||
500 | .driver = { | ||
501 | .name = "mpc52xx-psc-spi", | ||
502 | .owner = THIS_MODULE, | ||
503 | }, | ||
504 | }; | ||
505 | |||
506 | static int __init mpc52xx_psc_spi_init(void) | ||
507 | { | ||
508 | return platform_driver_probe(&mpc52xx_psc_spi_platform_driver, | ||
509 | mpc52xx_psc_spi_probe); | ||
510 | } | ||
511 | module_init(mpc52xx_psc_spi_init); | ||
512 | |||
513 | static void __exit mpc52xx_psc_spi_exit(void) | ||
514 | { | ||
515 | platform_driver_unregister(&mpc52xx_psc_spi_platform_driver); | ||
516 | } | ||
517 | module_exit(mpc52xx_psc_spi_exit); | ||
518 | |||
519 | #else /* defined(CONFIG_PPC_MERGE) */ | ||
520 | |||
521 | static int __init mpc52xx_psc_spi_of_probe(struct of_device *op, | 468 | static int __init mpc52xx_psc_spi_of_probe(struct of_device *op, |
522 | const struct of_device_id *match) | 469 | const struct of_device_id *match) |
523 | { | 470 | { |
@@ -586,8 +533,6 @@ static void __exit mpc52xx_psc_spi_exit(void) | |||
586 | } | 533 | } |
587 | module_exit(mpc52xx_psc_spi_exit); | 534 | module_exit(mpc52xx_psc_spi_exit); |
588 | 535 | ||
589 | #endif /* defined(CONFIG_PPC_MERGE) */ | ||
590 | |||
591 | MODULE_AUTHOR("Dragos Carp"); | 536 | MODULE_AUTHOR("Dragos Carp"); |
592 | MODULE_DESCRIPTION("MPC52xx PSC SPI Driver"); | 537 | MODULE_DESCRIPTION("MPC52xx PSC SPI Driver"); |
593 | MODULE_LICENSE("GPL"); | 538 | MODULE_LICENSE("GPL"); |
diff --git a/drivers/spi/omap2_mcspi.c b/drivers/spi/omap2_mcspi.c index 9d2186fd74aa..454a2712e629 100644 --- a/drivers/spi/omap2_mcspi.c +++ b/drivers/spi/omap2_mcspi.c | |||
@@ -119,12 +119,14 @@ struct omap2_mcspi { | |||
119 | struct clk *fck; | 119 | struct clk *fck; |
120 | /* Virtual base address of the controller */ | 120 | /* Virtual base address of the controller */ |
121 | void __iomem *base; | 121 | void __iomem *base; |
122 | unsigned long phys; | ||
122 | /* SPI1 has 4 channels, while SPI2 has 2 */ | 123 | /* SPI1 has 4 channels, while SPI2 has 2 */ |
123 | struct omap2_mcspi_dma *dma_channels; | 124 | struct omap2_mcspi_dma *dma_channels; |
124 | }; | 125 | }; |
125 | 126 | ||
126 | struct omap2_mcspi_cs { | 127 | struct omap2_mcspi_cs { |
127 | void __iomem *base; | 128 | void __iomem *base; |
129 | unsigned long phys; | ||
128 | int word_len; | 130 | int word_len; |
129 | }; | 131 | }; |
130 | 132 | ||
@@ -233,7 +235,7 @@ omap2_mcspi_txrx_dma(struct spi_device *spi, struct spi_transfer *xfer) | |||
233 | c = count; | 235 | c = count; |
234 | word_len = cs->word_len; | 236 | word_len = cs->word_len; |
235 | 237 | ||
236 | base = (unsigned long) io_v2p(cs->base); | 238 | base = cs->phys; |
237 | tx_reg = base + OMAP2_MCSPI_TX0; | 239 | tx_reg = base + OMAP2_MCSPI_TX0; |
238 | rx_reg = base + OMAP2_MCSPI_RX0; | 240 | rx_reg = base + OMAP2_MCSPI_RX0; |
239 | rx = xfer->rx_buf; | 241 | rx = xfer->rx_buf; |
@@ -633,6 +635,7 @@ static int omap2_mcspi_setup(struct spi_device *spi) | |||
633 | if (!cs) | 635 | if (!cs) |
634 | return -ENOMEM; | 636 | return -ENOMEM; |
635 | cs->base = mcspi->base + spi->chip_select * 0x14; | 637 | cs->base = mcspi->base + spi->chip_select * 0x14; |
638 | cs->phys = mcspi->phys + spi->chip_select * 0x14; | ||
636 | spi->controller_state = cs; | 639 | spi->controller_state = cs; |
637 | } | 640 | } |
638 | 641 | ||
@@ -1005,7 +1008,13 @@ static int __init omap2_mcspi_probe(struct platform_device *pdev) | |||
1005 | goto err1; | 1008 | goto err1; |
1006 | } | 1009 | } |
1007 | 1010 | ||
1008 | mcspi->base = (void __iomem *) io_p2v(r->start); | 1011 | mcspi->phys = r->start; |
1012 | mcspi->base = ioremap(r->start, r->end - r->start + 1); | ||
1013 | if (!mcspi->base) { | ||
1014 | dev_dbg(&pdev->dev, "can't ioremap MCSPI\n"); | ||
1015 | status = -ENOMEM; | ||
1016 | goto err1aa; | ||
1017 | } | ||
1009 | 1018 | ||
1010 | INIT_WORK(&mcspi->work, omap2_mcspi_work); | 1019 | INIT_WORK(&mcspi->work, omap2_mcspi_work); |
1011 | 1020 | ||
@@ -1055,6 +1064,8 @@ err3: | |||
1055 | err2: | 1064 | err2: |
1056 | clk_put(mcspi->ick); | 1065 | clk_put(mcspi->ick); |
1057 | err1a: | 1066 | err1a: |
1067 | iounmap(mcspi->base); | ||
1068 | err1aa: | ||
1058 | release_mem_region(r->start, (r->end - r->start) + 1); | 1069 | release_mem_region(r->start, (r->end - r->start) + 1); |
1059 | err1: | 1070 | err1: |
1060 | spi_master_put(master); | 1071 | spi_master_put(master); |
@@ -1067,6 +1078,7 @@ static int __exit omap2_mcspi_remove(struct platform_device *pdev) | |||
1067 | struct omap2_mcspi *mcspi; | 1078 | struct omap2_mcspi *mcspi; |
1068 | struct omap2_mcspi_dma *dma_channels; | 1079 | struct omap2_mcspi_dma *dma_channels; |
1069 | struct resource *r; | 1080 | struct resource *r; |
1081 | void __iomem *base; | ||
1070 | 1082 | ||
1071 | master = dev_get_drvdata(&pdev->dev); | 1083 | master = dev_get_drvdata(&pdev->dev); |
1072 | mcspi = spi_master_get_devdata(master); | 1084 | mcspi = spi_master_get_devdata(master); |
@@ -1078,7 +1090,9 @@ static int __exit omap2_mcspi_remove(struct platform_device *pdev) | |||
1078 | r = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 1090 | r = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
1079 | release_mem_region(r->start, (r->end - r->start) + 1); | 1091 | release_mem_region(r->start, (r->end - r->start) + 1); |
1080 | 1092 | ||
1093 | base = mcspi->base; | ||
1081 | spi_unregister_master(master); | 1094 | spi_unregister_master(master); |
1095 | iounmap(base); | ||
1082 | kfree(dma_channels); | 1096 | kfree(dma_channels); |
1083 | 1097 | ||
1084 | return 0; | 1098 | return 0; |
diff --git a/drivers/spi/omap_uwire.c b/drivers/spi/omap_uwire.c index 5515eb97d7c5..bab6ff061e91 100644 --- a/drivers/spi/omap_uwire.c +++ b/drivers/spi/omap_uwire.c | |||
@@ -59,7 +59,6 @@ | |||
59 | * and irqs should show there too... | 59 | * and irqs should show there too... |
60 | */ | 60 | */ |
61 | #define UWIRE_BASE_PHYS 0xFFFB3000 | 61 | #define UWIRE_BASE_PHYS 0xFFFB3000 |
62 | #define UWIRE_BASE ((void *__iomem)IO_ADDRESS(UWIRE_BASE_PHYS)) | ||
63 | 62 | ||
64 | /* uWire Registers: */ | 63 | /* uWire Registers: */ |
65 | #define UWIRE_IO_SIZE 0x20 | 64 | #define UWIRE_IO_SIZE 0x20 |
@@ -103,16 +102,21 @@ struct uwire_state { | |||
103 | }; | 102 | }; |
104 | 103 | ||
105 | /* REVISIT compile time constant for idx_shift? */ | 104 | /* REVISIT compile time constant for idx_shift? */ |
105 | /* | ||
106 | * Or, put it in a structure which is used throughout the driver; | ||
107 | * that avoids having to issue two loads for each bit of static data. | ||
108 | */ | ||
106 | static unsigned int uwire_idx_shift; | 109 | static unsigned int uwire_idx_shift; |
110 | static void __iomem *uwire_base; | ||
107 | 111 | ||
108 | static inline void uwire_write_reg(int idx, u16 val) | 112 | static inline void uwire_write_reg(int idx, u16 val) |
109 | { | 113 | { |
110 | __raw_writew(val, UWIRE_BASE + (idx << uwire_idx_shift)); | 114 | __raw_writew(val, uwire_base + (idx << uwire_idx_shift)); |
111 | } | 115 | } |
112 | 116 | ||
113 | static inline u16 uwire_read_reg(int idx) | 117 | static inline u16 uwire_read_reg(int idx) |
114 | { | 118 | { |
115 | return __raw_readw(UWIRE_BASE + (idx << uwire_idx_shift)); | 119 | return __raw_readw(uwire_base + (idx << uwire_idx_shift)); |
116 | } | 120 | } |
117 | 121 | ||
118 | static inline void omap_uwire_configure_mode(u8 cs, unsigned long flags) | 122 | static inline void omap_uwire_configure_mode(u8 cs, unsigned long flags) |
@@ -492,6 +496,14 @@ static int __init uwire_probe(struct platform_device *pdev) | |||
492 | return -ENODEV; | 496 | return -ENODEV; |
493 | 497 | ||
494 | uwire = spi_master_get_devdata(master); | 498 | uwire = spi_master_get_devdata(master); |
499 | |||
500 | uwire_base = ioremap(UWIRE_BASE_PHYS, UWIRE_IO_SIZE); | ||
501 | if (!uwire_base) { | ||
502 | dev_dbg(&pdev->dev, "can't ioremap UWIRE\n"); | ||
503 | spi_master_put(master); | ||
504 | return -ENOMEM; | ||
505 | } | ||
506 | |||
495 | dev_set_drvdata(&pdev->dev, uwire); | 507 | dev_set_drvdata(&pdev->dev, uwire); |
496 | 508 | ||
497 | uwire->ck = clk_get(&pdev->dev, "armxor_ck"); | 509 | uwire->ck = clk_get(&pdev->dev, "armxor_ck"); |
@@ -520,8 +532,10 @@ static int __init uwire_probe(struct platform_device *pdev) | |||
520 | uwire->bitbang.txrx_bufs = uwire_txrx; | 532 | uwire->bitbang.txrx_bufs = uwire_txrx; |
521 | 533 | ||
522 | status = spi_bitbang_start(&uwire->bitbang); | 534 | status = spi_bitbang_start(&uwire->bitbang); |
523 | if (status < 0) | 535 | if (status < 0) { |
524 | uwire_off(uwire); | 536 | uwire_off(uwire); |
537 | iounmap(uwire_base); | ||
538 | } | ||
525 | return status; | 539 | return status; |
526 | } | 540 | } |
527 | 541 | ||
@@ -534,6 +548,7 @@ static int __exit uwire_remove(struct platform_device *pdev) | |||
534 | 548 | ||
535 | status = spi_bitbang_stop(&uwire->bitbang); | 549 | status = spi_bitbang_stop(&uwire->bitbang); |
536 | uwire_off(uwire); | 550 | uwire_off(uwire); |
551 | iounmap(uwire_base); | ||
537 | return status; | 552 | return status; |
538 | } | 553 | } |
539 | 554 | ||
diff --git a/drivers/spi/orion_spi.c b/drivers/spi/orion_spi.c index b872bfaf4bd2..014becb7d530 100644 --- a/drivers/spi/orion_spi.c +++ b/drivers/spi/orion_spi.c | |||
@@ -364,6 +364,11 @@ static int orion_spi_setup(struct spi_device *spi) | |||
364 | return -EINVAL; | 364 | return -EINVAL; |
365 | } | 365 | } |
366 | 366 | ||
367 | /* Fix ac timing if required. */ | ||
368 | if (orion_spi->spi_info->enable_clock_fix) | ||
369 | orion_spi_setbits(orion_spi, ORION_SPI_IF_CONFIG_REG, | ||
370 | (1 << 14)); | ||
371 | |||
367 | if (spi->bits_per_word == 0) | 372 | if (spi->bits_per_word == 0) |
368 | spi->bits_per_word = 8; | 373 | spi->bits_per_word = 8; |
369 | 374 | ||
diff --git a/drivers/spi/pxa2xx_spi.c b/drivers/spi/pxa2xx_spi.c index d47d3636227f..dae87b1a4c6e 100644 --- a/drivers/spi/pxa2xx_spi.c +++ b/drivers/spi/pxa2xx_spi.c | |||
@@ -47,6 +47,10 @@ MODULE_ALIAS("platform:pxa2xx-spi"); | |||
47 | 47 | ||
48 | #define MAX_BUSES 3 | 48 | #define MAX_BUSES 3 |
49 | 49 | ||
50 | #define RX_THRESH_DFLT 8 | ||
51 | #define TX_THRESH_DFLT 8 | ||
52 | #define TIMOUT_DFLT 1000 | ||
53 | |||
50 | #define DMA_INT_MASK (DCSR_ENDINTR | DCSR_STARTINTR | DCSR_BUSERR) | 54 | #define DMA_INT_MASK (DCSR_ENDINTR | DCSR_STARTINTR | DCSR_BUSERR) |
51 | #define RESET_DMA_CHANNEL (DCSR_NODESC | DMA_INT_MASK) | 55 | #define RESET_DMA_CHANNEL (DCSR_NODESC | DMA_INT_MASK) |
52 | #define IS_DMA_ALIGNED(x) ((((u32)(x)) & 0x07) == 0) | 56 | #define IS_DMA_ALIGNED(x) ((((u32)(x)) & 0x07) == 0) |
@@ -1171,6 +1175,8 @@ static int setup(struct spi_device *spi) | |||
1171 | struct driver_data *drv_data = spi_master_get_devdata(spi->master); | 1175 | struct driver_data *drv_data = spi_master_get_devdata(spi->master); |
1172 | struct ssp_device *ssp = drv_data->ssp; | 1176 | struct ssp_device *ssp = drv_data->ssp; |
1173 | unsigned int clk_div; | 1177 | unsigned int clk_div; |
1178 | uint tx_thres = TX_THRESH_DFLT; | ||
1179 | uint rx_thres = RX_THRESH_DFLT; | ||
1174 | 1180 | ||
1175 | if (!spi->bits_per_word) | 1181 | if (!spi->bits_per_word) |
1176 | spi->bits_per_word = 8; | 1182 | spi->bits_per_word = 8; |
@@ -1209,8 +1215,7 @@ static int setup(struct spi_device *spi) | |||
1209 | 1215 | ||
1210 | chip->cs_control = null_cs_control; | 1216 | chip->cs_control = null_cs_control; |
1211 | chip->enable_dma = 0; | 1217 | chip->enable_dma = 0; |
1212 | chip->timeout = 1000; | 1218 | chip->timeout = TIMOUT_DFLT; |
1213 | chip->threshold = SSCR1_RxTresh(1) | SSCR1_TxTresh(1); | ||
1214 | chip->dma_burst_size = drv_data->master_info->enable_dma ? | 1219 | chip->dma_burst_size = drv_data->master_info->enable_dma ? |
1215 | DCMD_BURST8 : 0; | 1220 | DCMD_BURST8 : 0; |
1216 | } | 1221 | } |
@@ -1224,22 +1229,21 @@ static int setup(struct spi_device *spi) | |||
1224 | if (chip_info) { | 1229 | if (chip_info) { |
1225 | if (chip_info->cs_control) | 1230 | if (chip_info->cs_control) |
1226 | chip->cs_control = chip_info->cs_control; | 1231 | chip->cs_control = chip_info->cs_control; |
1227 | 1232 | if (chip_info->timeout) | |
1228 | chip->timeout = chip_info->timeout; | 1233 | chip->timeout = chip_info->timeout; |
1229 | 1234 | if (chip_info->tx_threshold) | |
1230 | chip->threshold = (SSCR1_RxTresh(chip_info->rx_threshold) & | 1235 | tx_thres = chip_info->tx_threshold; |
1231 | SSCR1_RFT) | | 1236 | if (chip_info->rx_threshold) |
1232 | (SSCR1_TxTresh(chip_info->tx_threshold) & | 1237 | rx_thres = chip_info->rx_threshold; |
1233 | SSCR1_TFT); | 1238 | chip->enable_dma = drv_data->master_info->enable_dma; |
1234 | |||
1235 | chip->enable_dma = chip_info->dma_burst_size != 0 | ||
1236 | && drv_data->master_info->enable_dma; | ||
1237 | chip->dma_threshold = 0; | 1239 | chip->dma_threshold = 0; |
1238 | |||
1239 | if (chip_info->enable_loopback) | 1240 | if (chip_info->enable_loopback) |
1240 | chip->cr1 = SSCR1_LBM; | 1241 | chip->cr1 = SSCR1_LBM; |
1241 | } | 1242 | } |
1242 | 1243 | ||
1244 | chip->threshold = (SSCR1_RxTresh(rx_thres) & SSCR1_RFT) | | ||
1245 | (SSCR1_TxTresh(tx_thres) & SSCR1_TFT); | ||
1246 | |||
1243 | /* set dma burst and threshold outside of chip_info path so that if | 1247 | /* set dma burst and threshold outside of chip_info path so that if |
1244 | * chip_info goes away after setting chip->enable_dma, the | 1248 | * chip_info goes away after setting chip->enable_dma, the |
1245 | * burst and threshold can still respond to changes in bits_per_word */ | 1249 | * burst and threshold can still respond to changes in bits_per_word */ |
@@ -1268,17 +1272,19 @@ static int setup(struct spi_device *spi) | |||
1268 | 1272 | ||
1269 | /* NOTE: PXA25x_SSP _could_ use external clocking ... */ | 1273 | /* NOTE: PXA25x_SSP _could_ use external clocking ... */ |
1270 | if (drv_data->ssp_type != PXA25x_SSP) | 1274 | if (drv_data->ssp_type != PXA25x_SSP) |
1271 | dev_dbg(&spi->dev, "%d bits/word, %ld Hz, mode %d\n", | 1275 | dev_dbg(&spi->dev, "%d bits/word, %ld Hz, mode %d, %s\n", |
1272 | spi->bits_per_word, | 1276 | spi->bits_per_word, |
1273 | clk_get_rate(ssp->clk) | 1277 | clk_get_rate(ssp->clk) |
1274 | / (1 + ((chip->cr0 & SSCR0_SCR) >> 8)), | 1278 | / (1 + ((chip->cr0 & SSCR0_SCR) >> 8)), |
1275 | spi->mode & 0x3); | 1279 | spi->mode & 0x3, |
1280 | chip->enable_dma ? "DMA" : "PIO"); | ||
1276 | else | 1281 | else |
1277 | dev_dbg(&spi->dev, "%d bits/word, %ld Hz, mode %d\n", | 1282 | dev_dbg(&spi->dev, "%d bits/word, %ld Hz, mode %d, %s\n", |
1278 | spi->bits_per_word, | 1283 | spi->bits_per_word, |
1279 | clk_get_rate(ssp->clk) | 1284 | clk_get_rate(ssp->clk) / 2 |
1280 | / (1 + ((chip->cr0 & SSCR0_SCR) >> 8)), | 1285 | / (1 + ((chip->cr0 & SSCR0_SCR) >> 8)), |
1281 | spi->mode & 0x3); | 1286 | spi->mode & 0x3, |
1287 | chip->enable_dma ? "DMA" : "PIO"); | ||
1282 | 1288 | ||
1283 | if (spi->bits_per_word <= 8) { | 1289 | if (spi->bits_per_word <= 8) { |
1284 | chip->n_bytes = 1; | 1290 | chip->n_bytes = 1; |
@@ -1407,9 +1413,9 @@ static int __init pxa2xx_spi_probe(struct platform_device *pdev) | |||
1407 | struct device *dev = &pdev->dev; | 1413 | struct device *dev = &pdev->dev; |
1408 | struct pxa2xx_spi_master *platform_info; | 1414 | struct pxa2xx_spi_master *platform_info; |
1409 | struct spi_master *master; | 1415 | struct spi_master *master; |
1410 | struct driver_data *drv_data = NULL; | 1416 | struct driver_data *drv_data; |
1411 | struct ssp_device *ssp; | 1417 | struct ssp_device *ssp; |
1412 | int status = 0; | 1418 | int status; |
1413 | 1419 | ||
1414 | platform_info = dev->platform_data; | 1420 | platform_info = dev->platform_data; |
1415 | 1421 | ||
@@ -1422,7 +1428,7 @@ static int __init pxa2xx_spi_probe(struct platform_device *pdev) | |||
1422 | /* Allocate master with space for drv_data and null dma buffer */ | 1428 | /* Allocate master with space for drv_data and null dma buffer */ |
1423 | master = spi_alloc_master(dev, sizeof(struct driver_data) + 16); | 1429 | master = spi_alloc_master(dev, sizeof(struct driver_data) + 16); |
1424 | if (!master) { | 1430 | if (!master) { |
1425 | dev_err(&pdev->dev, "can not alloc spi_master\n"); | 1431 | dev_err(&pdev->dev, "cannot alloc spi_master\n"); |
1426 | ssp_free(ssp); | 1432 | ssp_free(ssp); |
1427 | return -ENOMEM; | 1433 | return -ENOMEM; |
1428 | } | 1434 | } |
@@ -1458,7 +1464,7 @@ static int __init pxa2xx_spi_probe(struct platform_device *pdev) | |||
1458 | 1464 | ||
1459 | status = request_irq(ssp->irq, ssp_int, 0, dev->bus_id, drv_data); | 1465 | status = request_irq(ssp->irq, ssp_int, 0, dev->bus_id, drv_data); |
1460 | if (status < 0) { | 1466 | if (status < 0) { |
1461 | dev_err(&pdev->dev, "can not get IRQ\n"); | 1467 | dev_err(&pdev->dev, "cannot get IRQ %d\n", ssp->irq); |
1462 | goto out_error_master_alloc; | 1468 | goto out_error_master_alloc; |
1463 | } | 1469 | } |
1464 | 1470 | ||
@@ -1498,7 +1504,9 @@ static int __init pxa2xx_spi_probe(struct platform_device *pdev) | |||
1498 | 1504 | ||
1499 | /* Load default SSP configuration */ | 1505 | /* Load default SSP configuration */ |
1500 | write_SSCR0(0, drv_data->ioaddr); | 1506 | write_SSCR0(0, drv_data->ioaddr); |
1501 | write_SSCR1(SSCR1_RxTresh(4) | SSCR1_TxTresh(12), drv_data->ioaddr); | 1507 | write_SSCR1(SSCR1_RxTresh(RX_THRESH_DFLT) | |
1508 | SSCR1_TxTresh(TX_THRESH_DFLT), | ||
1509 | drv_data->ioaddr); | ||
1502 | write_SSCR0(SSCR0_SerClkDiv(2) | 1510 | write_SSCR0(SSCR0_SerClkDiv(2) |
1503 | | SSCR0_Motorola | 1511 | | SSCR0_Motorola |
1504 | | SSCR0_DataSize(8), | 1512 | | SSCR0_DataSize(8), |
diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c index 75e86865234c..3734dc9708e1 100644 --- a/drivers/spi/spi.c +++ b/drivers/spi/spi.c | |||
@@ -660,7 +660,7 @@ int spi_write_then_read(struct spi_device *spi, | |||
660 | 660 | ||
661 | int status; | 661 | int status; |
662 | struct spi_message message; | 662 | struct spi_message message; |
663 | struct spi_transfer x[2]; | 663 | struct spi_transfer x; |
664 | u8 *local_buf; | 664 | u8 *local_buf; |
665 | 665 | ||
666 | /* Use preallocated DMA-safe buffer. We can't avoid copying here, | 666 | /* Use preallocated DMA-safe buffer. We can't avoid copying here, |
@@ -671,15 +671,9 @@ int spi_write_then_read(struct spi_device *spi, | |||
671 | return -EINVAL; | 671 | return -EINVAL; |
672 | 672 | ||
673 | spi_message_init(&message); | 673 | spi_message_init(&message); |
674 | memset(x, 0, sizeof x); | 674 | memset(&x, 0, sizeof x); |
675 | if (n_tx) { | 675 | x.len = n_tx + n_rx; |
676 | x[0].len = n_tx; | 676 | spi_message_add_tail(&x, &message); |
677 | spi_message_add_tail(&x[0], &message); | ||
678 | } | ||
679 | if (n_rx) { | ||
680 | x[1].len = n_rx; | ||
681 | spi_message_add_tail(&x[1], &message); | ||
682 | } | ||
683 | 677 | ||
684 | /* ... unless someone else is using the pre-allocated buffer */ | 678 | /* ... unless someone else is using the pre-allocated buffer */ |
685 | if (!mutex_trylock(&lock)) { | 679 | if (!mutex_trylock(&lock)) { |
@@ -690,15 +684,15 @@ int spi_write_then_read(struct spi_device *spi, | |||
690 | local_buf = buf; | 684 | local_buf = buf; |
691 | 685 | ||
692 | memcpy(local_buf, txbuf, n_tx); | 686 | memcpy(local_buf, txbuf, n_tx); |
693 | x[0].tx_buf = local_buf; | 687 | x.tx_buf = local_buf; |
694 | x[1].rx_buf = local_buf + n_tx; | 688 | x.rx_buf = local_buf; |
695 | 689 | ||
696 | /* do the i/o */ | 690 | /* do the i/o */ |
697 | status = spi_sync(spi, &message); | 691 | status = spi_sync(spi, &message); |
698 | if (status == 0) | 692 | if (status == 0) |
699 | memcpy(rxbuf, x[1].rx_buf, n_rx); | 693 | memcpy(rxbuf, x.rx_buf + n_tx, n_rx); |
700 | 694 | ||
701 | if (x[0].tx_buf == buf) | 695 | if (x.tx_buf == buf) |
702 | mutex_unlock(&lock); | 696 | mutex_unlock(&lock); |
703 | else | 697 | else |
704 | kfree(local_buf); | 698 | kfree(local_buf); |
@@ -744,5 +738,5 @@ err0: | |||
744 | * driver registration) _could_ be dynamically linked (modular) ... costs | 738 | * driver registration) _could_ be dynamically linked (modular) ... costs |
745 | * include needing to have boardinfo data structures be much more public. | 739 | * include needing to have boardinfo data structures be much more public. |
746 | */ | 740 | */ |
747 | subsys_initcall(spi_init); | 741 | postcore_initcall(spi_init); |
748 | 742 | ||
diff --git a/drivers/spi/spi_s3c24xx.c b/drivers/spi/spi_s3c24xx.c index 3eb414b84a9d..c252cbac00f1 100644 --- a/drivers/spi/spi_s3c24xx.c +++ b/drivers/spi/spi_s3c24xx.c | |||
@@ -247,6 +247,9 @@ static void s3c24xx_spi_initialsetup(struct s3c24xx_spi *hw) | |||
247 | writeb(0xff, hw->regs + S3C2410_SPPRE); | 247 | writeb(0xff, hw->regs + S3C2410_SPPRE); |
248 | writeb(SPPIN_DEFAULT, hw->regs + S3C2410_SPPIN); | 248 | writeb(SPPIN_DEFAULT, hw->regs + S3C2410_SPPIN); |
249 | writeb(SPCON_DEFAULT, hw->regs + S3C2410_SPCON); | 249 | writeb(SPCON_DEFAULT, hw->regs + S3C2410_SPCON); |
250 | |||
251 | if (hw->pdata && hw->pdata->gpio_setup) | ||
252 | hw->pdata->gpio_setup(hw->pdata, 1); | ||
250 | } | 253 | } |
251 | 254 | ||
252 | static int __init s3c24xx_spi_probe(struct platform_device *pdev) | 255 | static int __init s3c24xx_spi_probe(struct platform_device *pdev) |
@@ -412,6 +415,9 @@ static int s3c24xx_spi_suspend(struct platform_device *pdev, pm_message_t msg) | |||
412 | { | 415 | { |
413 | struct s3c24xx_spi *hw = platform_get_drvdata(pdev); | 416 | struct s3c24xx_spi *hw = platform_get_drvdata(pdev); |
414 | 417 | ||
418 | if (hw->pdata && hw->pdata->gpio_setup) | ||
419 | hw->pdata->gpio_setup(hw->pdata, 0); | ||
420 | |||
415 | clk_disable(hw->clk); | 421 | clk_disable(hw->clk); |
416 | return 0; | 422 | return 0; |
417 | } | 423 | } |