diff options
author | Grant Likely <grant.likely@secretlab.ca> | 2013-02-05 07:30:13 -0500 |
---|---|---|
committer | Grant Likely <grant.likely@secretlab.ca> | 2013-02-05 07:30:13 -0500 |
commit | f305a0a8d7fcd1a600bd0b727cd8137ed223f721 (patch) | |
tree | 982681a7e3c643096b65b9626ae993597155979d /drivers/spi | |
parent | 766ed70447e0a9cfb23d068a4a929e18e54b0022 (diff) | |
parent | d560040f7d6fbe0a2990b8f6edca1815e19e72f5 (diff) |
Merge branch 'broonie/spi-next' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/misc.git
Minor features and bug fixes for PXA, OMAP and GPIO deivce drivers and a
cosmetic change to the bitbang driver.
Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
Diffstat (limited to 'drivers/spi')
-rw-r--r-- | drivers/spi/Kconfig | 4 | ||||
-rw-r--r-- | drivers/spi/spi-bitbang.c | 27 | ||||
-rw-r--r-- | drivers/spi/spi-gpio.c | 23 | ||||
-rw-r--r-- | drivers/spi/spi-omap2-mcspi.c | 34 | ||||
-rw-r--r-- | drivers/spi/spi-pxa2xx-pci.c | 133 | ||||
-rw-r--r-- | drivers/spi/spi-pxa2xx.c | 263 | ||||
-rw-r--r-- | drivers/spi/spi-s3c64xx.c | 2 |
7 files changed, 130 insertions, 356 deletions
diff --git a/drivers/spi/Kconfig b/drivers/spi/Kconfig index 2e188e1127eb..a90393d7f106 100644 --- a/drivers/spi/Kconfig +++ b/drivers/spi/Kconfig | |||
@@ -299,7 +299,7 @@ config SPI_PPC4xx | |||
299 | 299 | ||
300 | config SPI_PXA2XX | 300 | config SPI_PXA2XX |
301 | tristate "PXA2xx SSP SPI master" | 301 | tristate "PXA2xx SSP SPI master" |
302 | depends on (ARCH_PXA || (X86_32 && PCI)) && EXPERIMENTAL | 302 | depends on ARCH_PXA || PCI |
303 | select PXA_SSP if ARCH_PXA | 303 | select PXA_SSP if ARCH_PXA |
304 | help | 304 | help |
305 | This enables using a PXA2xx or Sodaville SSP port as a SPI master | 305 | This enables using a PXA2xx or Sodaville SSP port as a SPI master |
@@ -307,7 +307,7 @@ config SPI_PXA2XX | |||
307 | additional documentation can be found a Documentation/spi/pxa2xx. | 307 | additional documentation can be found a Documentation/spi/pxa2xx. |
308 | 308 | ||
309 | config SPI_PXA2XX_PCI | 309 | config SPI_PXA2XX_PCI |
310 | def_bool SPI_PXA2XX && X86_32 && PCI | 310 | def_tristate SPI_PXA2XX && PCI |
311 | 311 | ||
312 | config SPI_RSPI | 312 | config SPI_RSPI |
313 | tristate "Renesas RSPI controller" | 313 | tristate "Renesas RSPI controller" |
diff --git a/drivers/spi/spi-bitbang.c b/drivers/spi/spi-bitbang.c index 61beaec7cbed..a63d7da3bfe2 100644 --- a/drivers/spi/spi-bitbang.c +++ b/drivers/spi/spi-bitbang.c | |||
@@ -427,40 +427,41 @@ EXPORT_SYMBOL_GPL(spi_bitbang_transfer); | |||
427 | */ | 427 | */ |
428 | int spi_bitbang_start(struct spi_bitbang *bitbang) | 428 | int spi_bitbang_start(struct spi_bitbang *bitbang) |
429 | { | 429 | { |
430 | int status; | 430 | struct spi_master *master = bitbang->master; |
431 | int status; | ||
431 | 432 | ||
432 | if (!bitbang->master || !bitbang->chipselect) | 433 | if (!master || !bitbang->chipselect) |
433 | return -EINVAL; | 434 | return -EINVAL; |
434 | 435 | ||
435 | INIT_WORK(&bitbang->work, bitbang_work); | 436 | INIT_WORK(&bitbang->work, bitbang_work); |
436 | spin_lock_init(&bitbang->lock); | 437 | spin_lock_init(&bitbang->lock); |
437 | INIT_LIST_HEAD(&bitbang->queue); | 438 | INIT_LIST_HEAD(&bitbang->queue); |
438 | 439 | ||
439 | if (!bitbang->master->mode_bits) | 440 | if (!master->mode_bits) |
440 | bitbang->master->mode_bits = SPI_CPOL | SPI_CPHA | bitbang->flags; | 441 | master->mode_bits = SPI_CPOL | SPI_CPHA | bitbang->flags; |
441 | 442 | ||
442 | if (!bitbang->master->transfer) | 443 | if (!master->transfer) |
443 | bitbang->master->transfer = spi_bitbang_transfer; | 444 | master->transfer = spi_bitbang_transfer; |
444 | if (!bitbang->txrx_bufs) { | 445 | if (!bitbang->txrx_bufs) { |
445 | bitbang->use_dma = 0; | 446 | bitbang->use_dma = 0; |
446 | bitbang->txrx_bufs = spi_bitbang_bufs; | 447 | bitbang->txrx_bufs = spi_bitbang_bufs; |
447 | if (!bitbang->master->setup) { | 448 | if (!master->setup) { |
448 | if (!bitbang->setup_transfer) | 449 | if (!bitbang->setup_transfer) |
449 | bitbang->setup_transfer = | 450 | bitbang->setup_transfer = |
450 | spi_bitbang_setup_transfer; | 451 | spi_bitbang_setup_transfer; |
451 | bitbang->master->setup = spi_bitbang_setup; | 452 | master->setup = spi_bitbang_setup; |
452 | bitbang->master->cleanup = spi_bitbang_cleanup; | 453 | master->cleanup = spi_bitbang_cleanup; |
453 | } | 454 | } |
454 | } else if (!bitbang->master->setup) | 455 | } else if (!master->setup) |
455 | return -EINVAL; | 456 | return -EINVAL; |
456 | if (bitbang->master->transfer == spi_bitbang_transfer && | 457 | if (master->transfer == spi_bitbang_transfer && |
457 | !bitbang->setup_transfer) | 458 | !bitbang->setup_transfer) |
458 | return -EINVAL; | 459 | return -EINVAL; |
459 | 460 | ||
460 | /* this task is the only thing to touch the SPI bits */ | 461 | /* this task is the only thing to touch the SPI bits */ |
461 | bitbang->busy = 0; | 462 | bitbang->busy = 0; |
462 | bitbang->workqueue = create_singlethread_workqueue( | 463 | bitbang->workqueue = create_singlethread_workqueue( |
463 | dev_name(bitbang->master->dev.parent)); | 464 | dev_name(master->dev.parent)); |
464 | if (bitbang->workqueue == NULL) { | 465 | if (bitbang->workqueue == NULL) { |
465 | status = -EBUSY; | 466 | status = -EBUSY; |
466 | goto err1; | 467 | goto err1; |
@@ -469,7 +470,7 @@ int spi_bitbang_start(struct spi_bitbang *bitbang) | |||
469 | /* driver may get busy before register() returns, especially | 470 | /* driver may get busy before register() returns, especially |
470 | * if someone registered boardinfo for devices | 471 | * if someone registered boardinfo for devices |
471 | */ | 472 | */ |
472 | status = spi_register_master(bitbang->master); | 473 | status = spi_register_master(master); |
473 | if (status < 0) | 474 | if (status < 0) |
474 | goto err2; | 475 | goto err2; |
475 | 476 | ||
diff --git a/drivers/spi/spi-gpio.c b/drivers/spi/spi-gpio.c index c7cf0b7a069b..9ddef55a7165 100644 --- a/drivers/spi/spi-gpio.c +++ b/drivers/spi/spi-gpio.c | |||
@@ -365,9 +365,26 @@ static int spi_gpio_probe_dt(struct platform_device *pdev) | |||
365 | if (!pdata) | 365 | if (!pdata) |
366 | return -ENOMEM; | 366 | return -ENOMEM; |
367 | 367 | ||
368 | pdata->sck = of_get_named_gpio(np, "gpio-sck", 0); | 368 | ret = of_get_named_gpio(np, "gpio-sck", 0); |
369 | pdata->miso = of_get_named_gpio(np, "gpio-miso", 0); | 369 | if (ret < 0) { |
370 | pdata->mosi = of_get_named_gpio(np, "gpio-mosi", 0); | 370 | dev_err(&pdev->dev, "gpio-sck property not found\n"); |
371 | goto error_free; | ||
372 | } | ||
373 | pdata->sck = ret; | ||
374 | |||
375 | ret = of_get_named_gpio(np, "gpio-miso", 0); | ||
376 | if (ret < 0) { | ||
377 | dev_info(&pdev->dev, "gpio-miso property not found, switching to no-rx mode\n"); | ||
378 | pdata->miso = SPI_GPIO_NO_MISO; | ||
379 | } else | ||
380 | pdata->miso = ret; | ||
381 | |||
382 | ret = of_get_named_gpio(np, "gpio-mosi", 0); | ||
383 | if (ret < 0) { | ||
384 | dev_info(&pdev->dev, "gpio-mosi property not found, switching to no-tx mode\n"); | ||
385 | pdata->mosi = SPI_GPIO_NO_MOSI; | ||
386 | } else | ||
387 | pdata->mosi = ret; | ||
371 | 388 | ||
372 | ret = of_property_read_u32(np, "num-chipselects", &tmp); | 389 | ret = of_property_read_u32(np, "num-chipselects", &tmp); |
373 | if (ret < 0) { | 390 | if (ret < 0) { |
diff --git a/drivers/spi/spi-omap2-mcspi.c b/drivers/spi/spi-omap2-mcspi.c index 68446dbd5545..69945b014c96 100644 --- a/drivers/spi/spi-omap2-mcspi.c +++ b/drivers/spi/spi-omap2-mcspi.c | |||
@@ -927,6 +927,7 @@ static void omap2_mcspi_work(struct omap2_mcspi *mcspi, struct spi_message *m) | |||
927 | 927 | ||
928 | struct spi_device *spi; | 928 | struct spi_device *spi; |
929 | struct spi_transfer *t = NULL; | 929 | struct spi_transfer *t = NULL; |
930 | struct spi_master *master; | ||
930 | int cs_active = 0; | 931 | int cs_active = 0; |
931 | struct omap2_mcspi_cs *cs; | 932 | struct omap2_mcspi_cs *cs; |
932 | struct omap2_mcspi_device_config *cd; | 933 | struct omap2_mcspi_device_config *cd; |
@@ -935,6 +936,7 @@ static void omap2_mcspi_work(struct omap2_mcspi *mcspi, struct spi_message *m) | |||
935 | u32 chconf; | 936 | u32 chconf; |
936 | 937 | ||
937 | spi = m->spi; | 938 | spi = m->spi; |
939 | master = spi->master; | ||
938 | cs = spi->controller_state; | 940 | cs = spi->controller_state; |
939 | cd = spi->controller_data; | 941 | cd = spi->controller_data; |
940 | 942 | ||
@@ -952,6 +954,14 @@ static void omap2_mcspi_work(struct omap2_mcspi *mcspi, struct spi_message *m) | |||
952 | if (!t->speed_hz && !t->bits_per_word) | 954 | if (!t->speed_hz && !t->bits_per_word) |
953 | par_override = 0; | 955 | par_override = 0; |
954 | } | 956 | } |
957 | if (cd && cd->cs_per_word) { | ||
958 | chconf = mcspi->ctx.modulctrl; | ||
959 | chconf &= ~OMAP2_MCSPI_MODULCTRL_SINGLE; | ||
960 | mcspi_write_reg(master, OMAP2_MCSPI_MODULCTRL, chconf); | ||
961 | mcspi->ctx.modulctrl = | ||
962 | mcspi_read_cs_reg(spi, OMAP2_MCSPI_MODULCTRL); | ||
963 | } | ||
964 | |||
955 | 965 | ||
956 | if (!cs_active) { | 966 | if (!cs_active) { |
957 | omap2_mcspi_force_cs(spi, 1); | 967 | omap2_mcspi_force_cs(spi, 1); |
@@ -1013,6 +1023,14 @@ static void omap2_mcspi_work(struct omap2_mcspi *mcspi, struct spi_message *m) | |||
1013 | if (cs_active) | 1023 | if (cs_active) |
1014 | omap2_mcspi_force_cs(spi, 0); | 1024 | omap2_mcspi_force_cs(spi, 0); |
1015 | 1025 | ||
1026 | if (cd && cd->cs_per_word) { | ||
1027 | chconf = mcspi->ctx.modulctrl; | ||
1028 | chconf |= OMAP2_MCSPI_MODULCTRL_SINGLE; | ||
1029 | mcspi_write_reg(master, OMAP2_MCSPI_MODULCTRL, chconf); | ||
1030 | mcspi->ctx.modulctrl = | ||
1031 | mcspi_read_cs_reg(spi, OMAP2_MCSPI_MODULCTRL); | ||
1032 | } | ||
1033 | |||
1016 | omap2_mcspi_set_enable(spi, 0); | 1034 | omap2_mcspi_set_enable(spi, 0); |
1017 | 1035 | ||
1018 | m->status = status; | 1036 | m->status = status; |
@@ -1020,7 +1038,7 @@ static void omap2_mcspi_work(struct omap2_mcspi *mcspi, struct spi_message *m) | |||
1020 | } | 1038 | } |
1021 | 1039 | ||
1022 | static int omap2_mcspi_transfer_one_message(struct spi_master *master, | 1040 | static int omap2_mcspi_transfer_one_message(struct spi_master *master, |
1023 | struct spi_message *m) | 1041 | struct spi_message *m) |
1024 | { | 1042 | { |
1025 | struct omap2_mcspi *mcspi; | 1043 | struct omap2_mcspi *mcspi; |
1026 | struct spi_transfer *t; | 1044 | struct spi_transfer *t; |
@@ -1041,7 +1059,7 @@ static int omap2_mcspi_transfer_one_message(struct spi_master *master, | |||
1041 | || (len && !(rx_buf || tx_buf)) | 1059 | || (len && !(rx_buf || tx_buf)) |
1042 | || (t->bits_per_word && | 1060 | || (t->bits_per_word && |
1043 | ( t->bits_per_word < 4 | 1061 | ( t->bits_per_word < 4 |
1044 | || t->bits_per_word > 32))) { | 1062 | || t->bits_per_word > 32))) { |
1045 | dev_dbg(mcspi->dev, "transfer: %d Hz, %d %s%s, %d bpw\n", | 1063 | dev_dbg(mcspi->dev, "transfer: %d Hz, %d %s%s, %d bpw\n", |
1046 | t->speed_hz, | 1064 | t->speed_hz, |
1047 | len, | 1065 | len, |
@@ -1052,8 +1070,8 @@ static int omap2_mcspi_transfer_one_message(struct spi_master *master, | |||
1052 | } | 1070 | } |
1053 | if (t->speed_hz && t->speed_hz < (OMAP2_MCSPI_MAX_FREQ >> 15)) { | 1071 | if (t->speed_hz && t->speed_hz < (OMAP2_MCSPI_MAX_FREQ >> 15)) { |
1054 | dev_dbg(mcspi->dev, "speed_hz %d below minimum %d Hz\n", | 1072 | dev_dbg(mcspi->dev, "speed_hz %d below minimum %d Hz\n", |
1055 | t->speed_hz, | 1073 | t->speed_hz, |
1056 | OMAP2_MCSPI_MAX_FREQ >> 15); | 1074 | OMAP2_MCSPI_MAX_FREQ >> 15); |
1057 | return -EINVAL; | 1075 | return -EINVAL; |
1058 | } | 1076 | } |
1059 | 1077 | ||
@@ -1099,7 +1117,7 @@ static int omap2_mcspi_master_setup(struct omap2_mcspi *mcspi) | |||
1099 | return ret; | 1117 | return ret; |
1100 | 1118 | ||
1101 | mcspi_write_reg(master, OMAP2_MCSPI_WAKEUPENABLE, | 1119 | mcspi_write_reg(master, OMAP2_MCSPI_WAKEUPENABLE, |
1102 | OMAP2_MCSPI_WAKEUPENABLE_WKEN); | 1120 | OMAP2_MCSPI_WAKEUPENABLE_WKEN); |
1103 | ctx->wakeupenable = OMAP2_MCSPI_WAKEUPENABLE_WKEN; | 1121 | ctx->wakeupenable = OMAP2_MCSPI_WAKEUPENABLE_WKEN; |
1104 | 1122 | ||
1105 | omap2_mcspi_set_master_mode(master); | 1123 | omap2_mcspi_set_master_mode(master); |
@@ -1228,7 +1246,7 @@ static int omap2_mcspi_probe(struct platform_device *pdev) | |||
1228 | 1246 | ||
1229 | sprintf(dma_ch_name, "rx%d", i); | 1247 | sprintf(dma_ch_name, "rx%d", i); |
1230 | dma_res = platform_get_resource_byname(pdev, IORESOURCE_DMA, | 1248 | dma_res = platform_get_resource_byname(pdev, IORESOURCE_DMA, |
1231 | dma_ch_name); | 1249 | dma_ch_name); |
1232 | if (!dma_res) { | 1250 | if (!dma_res) { |
1233 | dev_dbg(&pdev->dev, "cannot get DMA RX channel\n"); | 1251 | dev_dbg(&pdev->dev, "cannot get DMA RX channel\n"); |
1234 | status = -ENODEV; | 1252 | status = -ENODEV; |
@@ -1238,7 +1256,7 @@ static int omap2_mcspi_probe(struct platform_device *pdev) | |||
1238 | mcspi->dma_channels[i].dma_rx_sync_dev = dma_res->start; | 1256 | mcspi->dma_channels[i].dma_rx_sync_dev = dma_res->start; |
1239 | sprintf(dma_ch_name, "tx%d", i); | 1257 | sprintf(dma_ch_name, "tx%d", i); |
1240 | dma_res = platform_get_resource_byname(pdev, IORESOURCE_DMA, | 1258 | dma_res = platform_get_resource_byname(pdev, IORESOURCE_DMA, |
1241 | dma_ch_name); | 1259 | dma_ch_name); |
1242 | if (!dma_res) { | 1260 | if (!dma_res) { |
1243 | dev_dbg(&pdev->dev, "cannot get DMA TX channel\n"); | 1261 | dev_dbg(&pdev->dev, "cannot get DMA TX channel\n"); |
1244 | status = -ENODEV; | 1262 | status = -ENODEV; |
@@ -1254,7 +1272,7 @@ static int omap2_mcspi_probe(struct platform_device *pdev) | |||
1254 | pinctrl = devm_pinctrl_get_select_default(&pdev->dev); | 1272 | pinctrl = devm_pinctrl_get_select_default(&pdev->dev); |
1255 | if (IS_ERR(pinctrl)) | 1273 | if (IS_ERR(pinctrl)) |
1256 | dev_warn(&pdev->dev, | 1274 | dev_warn(&pdev->dev, |
1257 | "pins are not configured from the driver\n"); | 1275 | "pins are not configured from the driver\n"); |
1258 | 1276 | ||
1259 | pm_runtime_use_autosuspend(&pdev->dev); | 1277 | pm_runtime_use_autosuspend(&pdev->dev); |
1260 | pm_runtime_set_autosuspend_delay(&pdev->dev, SPI_AUTOSUSPEND_TIMEOUT); | 1278 | pm_runtime_set_autosuspend_delay(&pdev->dev, SPI_AUTOSUSPEND_TIMEOUT); |
diff --git a/drivers/spi/spi-pxa2xx-pci.c b/drivers/spi/spi-pxa2xx-pci.c index cf95587eefde..364964d2ed04 100644 --- a/drivers/spi/spi-pxa2xx-pci.c +++ b/drivers/spi/spi-pxa2xx-pci.c | |||
@@ -8,147 +8,58 @@ | |||
8 | #include <linux/module.h> | 8 | #include <linux/module.h> |
9 | #include <linux/spi/pxa2xx_spi.h> | 9 | #include <linux/spi/pxa2xx_spi.h> |
10 | 10 | ||
11 | struct ce4100_info { | ||
12 | struct ssp_device ssp; | ||
13 | struct platform_device *spi_pdev; | ||
14 | }; | ||
15 | |||
16 | static DEFINE_MUTEX(ssp_lock); | ||
17 | static LIST_HEAD(ssp_list); | ||
18 | |||
19 | struct ssp_device *pxa_ssp_request(int port, const char *label) | ||
20 | { | ||
21 | struct ssp_device *ssp = NULL; | ||
22 | |||
23 | mutex_lock(&ssp_lock); | ||
24 | |||
25 | list_for_each_entry(ssp, &ssp_list, node) { | ||
26 | if (ssp->port_id == port && ssp->use_count == 0) { | ||
27 | ssp->use_count++; | ||
28 | ssp->label = label; | ||
29 | break; | ||
30 | } | ||
31 | } | ||
32 | |||
33 | mutex_unlock(&ssp_lock); | ||
34 | |||
35 | if (&ssp->node == &ssp_list) | ||
36 | return NULL; | ||
37 | |||
38 | return ssp; | ||
39 | } | ||
40 | EXPORT_SYMBOL_GPL(pxa_ssp_request); | ||
41 | |||
42 | void pxa_ssp_free(struct ssp_device *ssp) | ||
43 | { | ||
44 | mutex_lock(&ssp_lock); | ||
45 | if (ssp->use_count) { | ||
46 | ssp->use_count--; | ||
47 | ssp->label = NULL; | ||
48 | } else | ||
49 | dev_err(&ssp->pdev->dev, "device already free\n"); | ||
50 | mutex_unlock(&ssp_lock); | ||
51 | } | ||
52 | EXPORT_SYMBOL_GPL(pxa_ssp_free); | ||
53 | |||
54 | static int ce4100_spi_probe(struct pci_dev *dev, | 11 | static int ce4100_spi_probe(struct pci_dev *dev, |
55 | const struct pci_device_id *ent) | 12 | const struct pci_device_id *ent) |
56 | { | 13 | { |
14 | struct platform_device_info pi; | ||
57 | int ret; | 15 | int ret; |
58 | resource_size_t phys_beg; | ||
59 | resource_size_t phys_len; | ||
60 | struct ce4100_info *spi_info; | ||
61 | struct platform_device *pdev; | 16 | struct platform_device *pdev; |
62 | struct pxa2xx_spi_master spi_pdata; | 17 | struct pxa2xx_spi_master spi_pdata; |
63 | struct ssp_device *ssp; | 18 | struct ssp_device *ssp; |
64 | 19 | ||
65 | ret = pci_enable_device(dev); | 20 | ret = pcim_enable_device(dev); |
66 | if (ret) | 21 | if (ret) |
67 | return ret; | 22 | return ret; |
68 | 23 | ||
69 | phys_beg = pci_resource_start(dev, 0); | 24 | ret = pcim_iomap_regions(dev, 1 << 0, "PXA2xx SPI"); |
70 | phys_len = pci_resource_len(dev, 0); | 25 | if (!ret) |
71 | |||
72 | if (!request_mem_region(phys_beg, phys_len, | ||
73 | "CE4100 SPI")) { | ||
74 | dev_err(&dev->dev, "Can't request register space.\n"); | ||
75 | ret = -EBUSY; | ||
76 | return ret; | 26 | return ret; |
77 | } | ||
78 | 27 | ||
79 | pdev = platform_device_alloc("pxa2xx-spi", dev->devfn); | ||
80 | spi_info = kzalloc(sizeof(*spi_info), GFP_KERNEL); | ||
81 | if (!pdev || !spi_info ) { | ||
82 | ret = -ENOMEM; | ||
83 | goto err_nomem; | ||
84 | } | ||
85 | memset(&spi_pdata, 0, sizeof(spi_pdata)); | 28 | memset(&spi_pdata, 0, sizeof(spi_pdata)); |
86 | spi_pdata.num_chipselect = dev->devfn; | 29 | spi_pdata.num_chipselect = dev->devfn; |
87 | 30 | ||
88 | ret = platform_device_add_data(pdev, &spi_pdata, sizeof(spi_pdata)); | 31 | ssp = &spi_pdata.ssp; |
89 | if (ret) | ||
90 | goto err_nomem; | ||
91 | |||
92 | pdev->dev.parent = &dev->dev; | ||
93 | pdev->dev.of_node = dev->dev.of_node; | ||
94 | ssp = &spi_info->ssp; | ||
95 | ssp->phys_base = pci_resource_start(dev, 0); | 32 | ssp->phys_base = pci_resource_start(dev, 0); |
96 | ssp->mmio_base = ioremap(phys_beg, phys_len); | 33 | ssp->mmio_base = pcim_iomap_table(dev)[0]; |
97 | if (!ssp->mmio_base) { | 34 | if (!ssp->mmio_base) { |
98 | dev_err(&pdev->dev, "failed to ioremap() registers\n"); | 35 | dev_err(&dev->dev, "failed to ioremap() registers\n"); |
99 | ret = -EIO; | 36 | return -EIO; |
100 | goto err_nomem; | ||
101 | } | 37 | } |
102 | ssp->irq = dev->irq; | 38 | ssp->irq = dev->irq; |
103 | ssp->port_id = pdev->id; | 39 | ssp->port_id = dev->devfn; |
104 | ssp->type = PXA25x_SSP; | 40 | ssp->type = PXA25x_SSP; |
105 | 41 | ||
106 | mutex_lock(&ssp_lock); | 42 | memset(&pi, 0, sizeof(pi)); |
107 | list_add(&ssp->node, &ssp_list); | 43 | pi.parent = &dev->dev; |
108 | mutex_unlock(&ssp_lock); | 44 | pi.name = "pxa2xx-spi"; |
45 | pi.id = ssp->port_id; | ||
46 | pi.data = &spi_pdata; | ||
47 | pi.size_data = sizeof(spi_pdata); | ||
109 | 48 | ||
110 | pci_set_drvdata(dev, spi_info); | 49 | pdev = platform_device_register_full(&pi); |
50 | if (!pdev) | ||
51 | return -ENOMEM; | ||
111 | 52 | ||
112 | ret = platform_device_add(pdev); | 53 | pci_set_drvdata(dev, pdev); |
113 | if (ret) | ||
114 | goto err_dev_add; | ||
115 | 54 | ||
116 | return ret; | 55 | return 0; |
117 | |||
118 | err_dev_add: | ||
119 | pci_set_drvdata(dev, NULL); | ||
120 | mutex_lock(&ssp_lock); | ||
121 | list_del(&ssp->node); | ||
122 | mutex_unlock(&ssp_lock); | ||
123 | iounmap(ssp->mmio_base); | ||
124 | |||
125 | err_nomem: | ||
126 | release_mem_region(phys_beg, phys_len); | ||
127 | platform_device_put(pdev); | ||
128 | kfree(spi_info); | ||
129 | return ret; | ||
130 | } | 56 | } |
131 | 57 | ||
132 | static void ce4100_spi_remove(struct pci_dev *dev) | 58 | static void ce4100_spi_remove(struct pci_dev *dev) |
133 | { | 59 | { |
134 | struct ce4100_info *spi_info; | 60 | struct platform_device *pdev = pci_get_drvdata(dev); |
135 | struct ssp_device *ssp; | ||
136 | |||
137 | spi_info = pci_get_drvdata(dev); | ||
138 | ssp = &spi_info->ssp; | ||
139 | platform_device_unregister(spi_info->spi_pdev); | ||
140 | |||
141 | iounmap(ssp->mmio_base); | ||
142 | release_mem_region(pci_resource_start(dev, 0), | ||
143 | pci_resource_len(dev, 0)); | ||
144 | |||
145 | mutex_lock(&ssp_lock); | ||
146 | list_del(&ssp->node); | ||
147 | mutex_unlock(&ssp_lock); | ||
148 | 61 | ||
149 | pci_set_drvdata(dev, NULL); | 62 | platform_device_unregister(pdev); |
150 | pci_disable_device(dev); | ||
151 | kfree(spi_info); | ||
152 | } | 63 | } |
153 | 64 | ||
154 | static DEFINE_PCI_DEVICE_TABLE(ce4100_spi_devices) = { | 65 | static DEFINE_PCI_DEVICE_TABLE(ce4100_spi_devices) = { |
diff --git a/drivers/spi/spi-pxa2xx.c b/drivers/spi/spi-pxa2xx.c index 5c8c4f5883c4..304cf6eb50e6 100644 --- a/drivers/spi/spi-pxa2xx.c +++ b/drivers/spi/spi-pxa2xx.c | |||
@@ -30,6 +30,7 @@ | |||
30 | #include <linux/delay.h> | 30 | #include <linux/delay.h> |
31 | #include <linux/gpio.h> | 31 | #include <linux/gpio.h> |
32 | #include <linux/slab.h> | 32 | #include <linux/slab.h> |
33 | #include <linux/clk.h> | ||
33 | 34 | ||
34 | #include <asm/io.h> | 35 | #include <asm/io.h> |
35 | #include <asm/irq.h> | 36 | #include <asm/irq.h> |
@@ -47,7 +48,7 @@ MODULE_ALIAS("platform:pxa2xx-spi"); | |||
47 | 48 | ||
48 | #define DMA_INT_MASK (DCSR_ENDINTR | DCSR_STARTINTR | DCSR_BUSERR) | 49 | #define DMA_INT_MASK (DCSR_ENDINTR | DCSR_STARTINTR | DCSR_BUSERR) |
49 | #define RESET_DMA_CHANNEL (DCSR_NODESC | DMA_INT_MASK) | 50 | #define RESET_DMA_CHANNEL (DCSR_NODESC | DMA_INT_MASK) |
50 | #define IS_DMA_ALIGNED(x) ((((u32)(x)) & 0x07) == 0) | 51 | #define IS_DMA_ALIGNED(x) IS_ALIGNED((unsigned long)(x), DMA_ALIGNMENT) |
51 | #define MAX_DMA_LEN 8191 | 52 | #define MAX_DMA_LEN 8191 |
52 | #define DMA_ALIGNMENT 8 | 53 | #define DMA_ALIGNMENT 8 |
53 | 54 | ||
@@ -85,9 +86,6 @@ DEFINE_SSP_REG(SSPSP, 0x2c) | |||
85 | #define DONE_STATE ((void*)2) | 86 | #define DONE_STATE ((void*)2) |
86 | #define ERROR_STATE ((void*)-1) | 87 | #define ERROR_STATE ((void*)-1) |
87 | 88 | ||
88 | #define QUEUE_RUNNING 0 | ||
89 | #define QUEUE_STOPPED 1 | ||
90 | |||
91 | struct driver_data { | 89 | struct driver_data { |
92 | /* Driver model hookup */ | 90 | /* Driver model hookup */ |
93 | struct platform_device *pdev; | 91 | struct platform_device *pdev; |
@@ -117,13 +115,8 @@ struct driver_data { | |||
117 | u32 clear_sr; | 115 | u32 clear_sr; |
118 | u32 mask_sr; | 116 | u32 mask_sr; |
119 | 117 | ||
120 | /* Driver message queue */ | 118 | /* Maximun clock rate */ |
121 | struct workqueue_struct *workqueue; | 119 | unsigned long max_clk_rate; |
122 | struct work_struct pump_messages; | ||
123 | spinlock_t lock; | ||
124 | struct list_head queue; | ||
125 | int busy; | ||
126 | int run; | ||
127 | 120 | ||
128 | /* Message Transfer pump */ | 121 | /* Message Transfer pump */ |
129 | struct tasklet_struct pump_transfers; | 122 | struct tasklet_struct pump_transfers; |
@@ -173,8 +166,6 @@ struct chip_data { | |||
173 | void (*cs_control)(u32 command); | 166 | void (*cs_control)(u32 command); |
174 | }; | 167 | }; |
175 | 168 | ||
176 | static void pump_messages(struct work_struct *work); | ||
177 | |||
178 | static void cs_assert(struct driver_data *drv_data) | 169 | static void cs_assert(struct driver_data *drv_data) |
179 | { | 170 | { |
180 | struct chip_data *chip = drv_data->cur_chip; | 171 | struct chip_data *chip = drv_data->cur_chip; |
@@ -444,15 +435,11 @@ static void unmap_dma_buffers(struct driver_data *drv_data) | |||
444 | static void giveback(struct driver_data *drv_data) | 435 | static void giveback(struct driver_data *drv_data) |
445 | { | 436 | { |
446 | struct spi_transfer* last_transfer; | 437 | struct spi_transfer* last_transfer; |
447 | unsigned long flags; | ||
448 | struct spi_message *msg; | 438 | struct spi_message *msg; |
449 | 439 | ||
450 | spin_lock_irqsave(&drv_data->lock, flags); | ||
451 | msg = drv_data->cur_msg; | 440 | msg = drv_data->cur_msg; |
452 | drv_data->cur_msg = NULL; | 441 | drv_data->cur_msg = NULL; |
453 | drv_data->cur_transfer = NULL; | 442 | drv_data->cur_transfer = NULL; |
454 | queue_work(drv_data->workqueue, &drv_data->pump_messages); | ||
455 | spin_unlock_irqrestore(&drv_data->lock, flags); | ||
456 | 443 | ||
457 | last_transfer = list_entry(msg->transfers.prev, | 444 | last_transfer = list_entry(msg->transfers.prev, |
458 | struct spi_transfer, | 445 | struct spi_transfer, |
@@ -481,13 +468,7 @@ static void giveback(struct driver_data *drv_data) | |||
481 | */ | 468 | */ |
482 | 469 | ||
483 | /* get a pointer to the next message, if any */ | 470 | /* get a pointer to the next message, if any */ |
484 | spin_lock_irqsave(&drv_data->lock, flags); | 471 | next_msg = spi_get_next_queued_message(drv_data->master); |
485 | if (list_empty(&drv_data->queue)) | ||
486 | next_msg = NULL; | ||
487 | else | ||
488 | next_msg = list_entry(drv_data->queue.next, | ||
489 | struct spi_message, queue); | ||
490 | spin_unlock_irqrestore(&drv_data->lock, flags); | ||
491 | 472 | ||
492 | /* see if the next and current messages point | 473 | /* see if the next and current messages point |
493 | * to the same chip | 474 | * to the same chip |
@@ -498,10 +479,7 @@ static void giveback(struct driver_data *drv_data) | |||
498 | cs_deassert(drv_data); | 479 | cs_deassert(drv_data); |
499 | } | 480 | } |
500 | 481 | ||
501 | msg->state = NULL; | 482 | spi_finalize_current_message(drv_data->master); |
502 | if (msg->complete) | ||
503 | msg->complete(msg->context); | ||
504 | |||
505 | drv_data->cur_chip = NULL; | 483 | drv_data->cur_chip = NULL; |
506 | } | 484 | } |
507 | 485 | ||
@@ -917,9 +895,12 @@ static int set_dma_burst_and_threshold(struct chip_data *chip, | |||
917 | return retval; | 895 | return retval; |
918 | } | 896 | } |
919 | 897 | ||
920 | static unsigned int ssp_get_clk_div(struct ssp_device *ssp, int rate) | 898 | static unsigned int ssp_get_clk_div(struct driver_data *drv_data, int rate) |
921 | { | 899 | { |
922 | unsigned long ssp_clk = clk_get_rate(ssp->clk); | 900 | unsigned long ssp_clk = drv_data->max_clk_rate; |
901 | const struct ssp_device *ssp = drv_data->ssp; | ||
902 | |||
903 | rate = min_t(int, ssp_clk, rate); | ||
923 | 904 | ||
924 | if (ssp->type == PXA25x_SSP || ssp->type == CE4100_SSP) | 905 | if (ssp->type == PXA25x_SSP || ssp->type == CE4100_SSP) |
925 | return ((ssp_clk / (2 * rate) - 1) & 0xff) << 8; | 906 | return ((ssp_clk / (2 * rate) - 1) & 0xff) << 8; |
@@ -934,7 +915,6 @@ static void pump_transfers(unsigned long data) | |||
934 | struct spi_transfer *transfer = NULL; | 915 | struct spi_transfer *transfer = NULL; |
935 | struct spi_transfer *previous = NULL; | 916 | struct spi_transfer *previous = NULL; |
936 | struct chip_data *chip = NULL; | 917 | struct chip_data *chip = NULL; |
937 | struct ssp_device *ssp = drv_data->ssp; | ||
938 | void __iomem *reg = drv_data->ioaddr; | 918 | void __iomem *reg = drv_data->ioaddr; |
939 | u32 clk_div = 0; | 919 | u32 clk_div = 0; |
940 | u8 bits = 0; | 920 | u8 bits = 0; |
@@ -1031,7 +1011,7 @@ static void pump_transfers(unsigned long data) | |||
1031 | if (transfer->bits_per_word) | 1011 | if (transfer->bits_per_word) |
1032 | bits = transfer->bits_per_word; | 1012 | bits = transfer->bits_per_word; |
1033 | 1013 | ||
1034 | clk_div = ssp_get_clk_div(ssp, speed); | 1014 | clk_div = ssp_get_clk_div(drv_data, speed); |
1035 | 1015 | ||
1036 | if (bits <= 8) { | 1016 | if (bits <= 8) { |
1037 | drv_data->n_bytes = 1; | 1017 | drv_data->n_bytes = 1; |
@@ -1176,31 +1156,12 @@ static void pump_transfers(unsigned long data) | |||
1176 | write_SSCR1(cr1, reg); | 1156 | write_SSCR1(cr1, reg); |
1177 | } | 1157 | } |
1178 | 1158 | ||
1179 | static void pump_messages(struct work_struct *work) | 1159 | static int pxa2xx_spi_transfer_one_message(struct spi_master *master, |
1160 | struct spi_message *msg) | ||
1180 | { | 1161 | { |
1181 | struct driver_data *drv_data = | 1162 | struct driver_data *drv_data = spi_master_get_devdata(master); |
1182 | container_of(work, struct driver_data, pump_messages); | ||
1183 | unsigned long flags; | ||
1184 | |||
1185 | /* Lock queue and check for queue work */ | ||
1186 | spin_lock_irqsave(&drv_data->lock, flags); | ||
1187 | if (list_empty(&drv_data->queue) || drv_data->run == QUEUE_STOPPED) { | ||
1188 | drv_data->busy = 0; | ||
1189 | spin_unlock_irqrestore(&drv_data->lock, flags); | ||
1190 | return; | ||
1191 | } | ||
1192 | |||
1193 | /* Make sure we are not already running a message */ | ||
1194 | if (drv_data->cur_msg) { | ||
1195 | spin_unlock_irqrestore(&drv_data->lock, flags); | ||
1196 | return; | ||
1197 | } | ||
1198 | |||
1199 | /* Extract head of queue */ | ||
1200 | drv_data->cur_msg = list_entry(drv_data->queue.next, | ||
1201 | struct spi_message, queue); | ||
1202 | list_del_init(&drv_data->cur_msg->queue); | ||
1203 | 1163 | ||
1164 | drv_data->cur_msg = msg; | ||
1204 | /* Initial message state*/ | 1165 | /* Initial message state*/ |
1205 | drv_data->cur_msg->state = START_STATE; | 1166 | drv_data->cur_msg->state = START_STATE; |
1206 | drv_data->cur_transfer = list_entry(drv_data->cur_msg->transfers.next, | 1167 | drv_data->cur_transfer = list_entry(drv_data->cur_msg->transfers.next, |
@@ -1213,34 +1174,6 @@ static void pump_messages(struct work_struct *work) | |||
1213 | 1174 | ||
1214 | /* Mark as busy and launch transfers */ | 1175 | /* Mark as busy and launch transfers */ |
1215 | tasklet_schedule(&drv_data->pump_transfers); | 1176 | tasklet_schedule(&drv_data->pump_transfers); |
1216 | |||
1217 | drv_data->busy = 1; | ||
1218 | spin_unlock_irqrestore(&drv_data->lock, flags); | ||
1219 | } | ||
1220 | |||
1221 | static int transfer(struct spi_device *spi, struct spi_message *msg) | ||
1222 | { | ||
1223 | struct driver_data *drv_data = spi_master_get_devdata(spi->master); | ||
1224 | unsigned long flags; | ||
1225 | |||
1226 | spin_lock_irqsave(&drv_data->lock, flags); | ||
1227 | |||
1228 | if (drv_data->run == QUEUE_STOPPED) { | ||
1229 | spin_unlock_irqrestore(&drv_data->lock, flags); | ||
1230 | return -ESHUTDOWN; | ||
1231 | } | ||
1232 | |||
1233 | msg->actual_length = 0; | ||
1234 | msg->status = -EINPROGRESS; | ||
1235 | msg->state = START_STATE; | ||
1236 | |||
1237 | list_add_tail(&msg->queue, &drv_data->queue); | ||
1238 | |||
1239 | if (drv_data->run == QUEUE_RUNNING && !drv_data->busy) | ||
1240 | queue_work(drv_data->workqueue, &drv_data->pump_messages); | ||
1241 | |||
1242 | spin_unlock_irqrestore(&drv_data->lock, flags); | ||
1243 | |||
1244 | return 0; | 1177 | return 0; |
1245 | } | 1178 | } |
1246 | 1179 | ||
@@ -1287,7 +1220,6 @@ static int setup(struct spi_device *spi) | |||
1287 | struct pxa2xx_spi_chip *chip_info = NULL; | 1220 | struct pxa2xx_spi_chip *chip_info = NULL; |
1288 | struct chip_data *chip; | 1221 | struct chip_data *chip; |
1289 | struct driver_data *drv_data = spi_master_get_devdata(spi->master); | 1222 | struct driver_data *drv_data = spi_master_get_devdata(spi->master); |
1290 | struct ssp_device *ssp = drv_data->ssp; | ||
1291 | unsigned int clk_div; | 1223 | unsigned int clk_div; |
1292 | uint tx_thres = TX_THRESH_DFLT; | 1224 | uint tx_thres = TX_THRESH_DFLT; |
1293 | uint rx_thres = RX_THRESH_DFLT; | 1225 | uint rx_thres = RX_THRESH_DFLT; |
@@ -1369,7 +1301,7 @@ static int setup(struct spi_device *spi) | |||
1369 | } | 1301 | } |
1370 | } | 1302 | } |
1371 | 1303 | ||
1372 | clk_div = ssp_get_clk_div(ssp, spi->max_speed_hz); | 1304 | clk_div = ssp_get_clk_div(drv_data, spi->max_speed_hz); |
1373 | chip->speed_hz = spi->max_speed_hz; | 1305 | chip->speed_hz = spi->max_speed_hz; |
1374 | 1306 | ||
1375 | chip->cr0 = clk_div | 1307 | chip->cr0 = clk_div |
@@ -1385,12 +1317,12 @@ static int setup(struct spi_device *spi) | |||
1385 | /* NOTE: PXA25x_SSP _could_ use external clocking ... */ | 1317 | /* NOTE: PXA25x_SSP _could_ use external clocking ... */ |
1386 | if (!pxa25x_ssp_comp(drv_data)) | 1318 | if (!pxa25x_ssp_comp(drv_data)) |
1387 | dev_dbg(&spi->dev, "%ld Hz actual, %s\n", | 1319 | dev_dbg(&spi->dev, "%ld Hz actual, %s\n", |
1388 | clk_get_rate(ssp->clk) | 1320 | drv_data->max_clk_rate |
1389 | / (1 + ((chip->cr0 & SSCR0_SCR(0xfff)) >> 8)), | 1321 | / (1 + ((chip->cr0 & SSCR0_SCR(0xfff)) >> 8)), |
1390 | chip->enable_dma ? "DMA" : "PIO"); | 1322 | chip->enable_dma ? "DMA" : "PIO"); |
1391 | else | 1323 | else |
1392 | dev_dbg(&spi->dev, "%ld Hz actual, %s\n", | 1324 | dev_dbg(&spi->dev, "%ld Hz actual, %s\n", |
1393 | clk_get_rate(ssp->clk) / 2 | 1325 | drv_data->max_clk_rate / 2 |
1394 | / (1 + ((chip->cr0 & SSCR0_SCR(0x0ff)) >> 8)), | 1326 | / (1 + ((chip->cr0 & SSCR0_SCR(0x0ff)) >> 8)), |
1395 | chip->enable_dma ? "DMA" : "PIO"); | 1327 | chip->enable_dma ? "DMA" : "PIO"); |
1396 | 1328 | ||
@@ -1438,94 +1370,6 @@ static void cleanup(struct spi_device *spi) | |||
1438 | kfree(chip); | 1370 | kfree(chip); |
1439 | } | 1371 | } |
1440 | 1372 | ||
1441 | static int init_queue(struct driver_data *drv_data) | ||
1442 | { | ||
1443 | INIT_LIST_HEAD(&drv_data->queue); | ||
1444 | spin_lock_init(&drv_data->lock); | ||
1445 | |||
1446 | drv_data->run = QUEUE_STOPPED; | ||
1447 | drv_data->busy = 0; | ||
1448 | |||
1449 | tasklet_init(&drv_data->pump_transfers, | ||
1450 | pump_transfers, (unsigned long)drv_data); | ||
1451 | |||
1452 | INIT_WORK(&drv_data->pump_messages, pump_messages); | ||
1453 | drv_data->workqueue = create_singlethread_workqueue( | ||
1454 | dev_name(drv_data->master->dev.parent)); | ||
1455 | if (drv_data->workqueue == NULL) | ||
1456 | return -EBUSY; | ||
1457 | |||
1458 | return 0; | ||
1459 | } | ||
1460 | |||
1461 | static int start_queue(struct driver_data *drv_data) | ||
1462 | { | ||
1463 | unsigned long flags; | ||
1464 | |||
1465 | spin_lock_irqsave(&drv_data->lock, flags); | ||
1466 | |||
1467 | if (drv_data->run == QUEUE_RUNNING || drv_data->busy) { | ||
1468 | spin_unlock_irqrestore(&drv_data->lock, flags); | ||
1469 | return -EBUSY; | ||
1470 | } | ||
1471 | |||
1472 | drv_data->run = QUEUE_RUNNING; | ||
1473 | drv_data->cur_msg = NULL; | ||
1474 | drv_data->cur_transfer = NULL; | ||
1475 | drv_data->cur_chip = NULL; | ||
1476 | spin_unlock_irqrestore(&drv_data->lock, flags); | ||
1477 | |||
1478 | queue_work(drv_data->workqueue, &drv_data->pump_messages); | ||
1479 | |||
1480 | return 0; | ||
1481 | } | ||
1482 | |||
1483 | static int stop_queue(struct driver_data *drv_data) | ||
1484 | { | ||
1485 | unsigned long flags; | ||
1486 | unsigned limit = 500; | ||
1487 | int status = 0; | ||
1488 | |||
1489 | spin_lock_irqsave(&drv_data->lock, flags); | ||
1490 | |||
1491 | /* This is a bit lame, but is optimized for the common execution path. | ||
1492 | * A wait_queue on the drv_data->busy could be used, but then the common | ||
1493 | * execution path (pump_messages) would be required to call wake_up or | ||
1494 | * friends on every SPI message. Do this instead */ | ||
1495 | drv_data->run = QUEUE_STOPPED; | ||
1496 | while ((!list_empty(&drv_data->queue) || drv_data->busy) && limit--) { | ||
1497 | spin_unlock_irqrestore(&drv_data->lock, flags); | ||
1498 | msleep(10); | ||
1499 | spin_lock_irqsave(&drv_data->lock, flags); | ||
1500 | } | ||
1501 | |||
1502 | if (!list_empty(&drv_data->queue) || drv_data->busy) | ||
1503 | status = -EBUSY; | ||
1504 | |||
1505 | spin_unlock_irqrestore(&drv_data->lock, flags); | ||
1506 | |||
1507 | return status; | ||
1508 | } | ||
1509 | |||
1510 | static int destroy_queue(struct driver_data *drv_data) | ||
1511 | { | ||
1512 | int status; | ||
1513 | |||
1514 | status = stop_queue(drv_data); | ||
1515 | /* we are unloading the module or failing to load (only two calls | ||
1516 | * to this routine), and neither call can handle a return value. | ||
1517 | * However, destroy_workqueue calls flush_workqueue, and that will | ||
1518 | * block until all work is done. If the reason that stop_queue | ||
1519 | * timed out is that the work will never finish, then it does no | ||
1520 | * good to call destroy_workqueue, so return anyway. */ | ||
1521 | if (status != 0) | ||
1522 | return status; | ||
1523 | |||
1524 | destroy_workqueue(drv_data->workqueue); | ||
1525 | |||
1526 | return 0; | ||
1527 | } | ||
1528 | |||
1529 | static int pxa2xx_spi_probe(struct platform_device *pdev) | 1373 | static int pxa2xx_spi_probe(struct platform_device *pdev) |
1530 | { | 1374 | { |
1531 | struct device *dev = &pdev->dev; | 1375 | struct device *dev = &pdev->dev; |
@@ -1535,11 +1379,18 @@ static int pxa2xx_spi_probe(struct platform_device *pdev) | |||
1535 | struct ssp_device *ssp; | 1379 | struct ssp_device *ssp; |
1536 | int status; | 1380 | int status; |
1537 | 1381 | ||
1538 | platform_info = dev->platform_data; | 1382 | platform_info = dev_get_platdata(dev); |
1383 | if (!platform_info) { | ||
1384 | dev_err(&pdev->dev, "missing platform data\n"); | ||
1385 | return -ENODEV; | ||
1386 | } | ||
1539 | 1387 | ||
1540 | ssp = pxa_ssp_request(pdev->id, pdev->name); | 1388 | ssp = pxa_ssp_request(pdev->id, pdev->name); |
1541 | if (ssp == NULL) { | 1389 | if (!ssp) |
1542 | dev_err(&pdev->dev, "failed to request SSP%d\n", pdev->id); | 1390 | ssp = &platform_info->ssp; |
1391 | |||
1392 | if (!ssp->mmio_base) { | ||
1393 | dev_err(&pdev->dev, "failed to get ssp\n"); | ||
1543 | return -ENODEV; | 1394 | return -ENODEV; |
1544 | } | 1395 | } |
1545 | 1396 | ||
@@ -1561,16 +1412,15 @@ static int pxa2xx_spi_probe(struct platform_device *pdev) | |||
1561 | /* the spi->mode bits understood by this driver: */ | 1412 | /* the spi->mode bits understood by this driver: */ |
1562 | master->mode_bits = SPI_CPOL | SPI_CPHA | SPI_CS_HIGH; | 1413 | master->mode_bits = SPI_CPOL | SPI_CPHA | SPI_CS_HIGH; |
1563 | 1414 | ||
1564 | master->bus_num = pdev->id; | 1415 | master->bus_num = ssp->port_id; |
1565 | master->num_chipselect = platform_info->num_chipselect; | 1416 | master->num_chipselect = platform_info->num_chipselect; |
1566 | master->dma_alignment = DMA_ALIGNMENT; | 1417 | master->dma_alignment = DMA_ALIGNMENT; |
1567 | master->cleanup = cleanup; | 1418 | master->cleanup = cleanup; |
1568 | master->setup = setup; | 1419 | master->setup = setup; |
1569 | master->transfer = transfer; | 1420 | master->transfer_one_message = pxa2xx_spi_transfer_one_message; |
1570 | 1421 | ||
1571 | drv_data->ssp_type = ssp->type; | 1422 | drv_data->ssp_type = ssp->type; |
1572 | drv_data->null_dma_buf = (u32 *)ALIGN((u32)(drv_data + | 1423 | drv_data->null_dma_buf = (u32 *)PTR_ALIGN(&drv_data[1], DMA_ALIGNMENT); |
1573 | sizeof(struct driver_data)), 8); | ||
1574 | 1424 | ||
1575 | drv_data->ioaddr = ssp->mmio_base; | 1425 | drv_data->ioaddr = ssp->mmio_base; |
1576 | drv_data->ssdr_physical = ssp->phys_base + SSDR; | 1426 | drv_data->ssdr_physical = ssp->phys_base + SSDR; |
@@ -1625,7 +1475,9 @@ static int pxa2xx_spi_probe(struct platform_device *pdev) | |||
1625 | } | 1475 | } |
1626 | 1476 | ||
1627 | /* Enable SOC clock */ | 1477 | /* Enable SOC clock */ |
1628 | clk_enable(ssp->clk); | 1478 | clk_prepare_enable(ssp->clk); |
1479 | |||
1480 | drv_data->max_clk_rate = clk_get_rate(ssp->clk); | ||
1629 | 1481 | ||
1630 | /* Load default SSP configuration */ | 1482 | /* Load default SSP configuration */ |
1631 | write_SSCR0(0, drv_data->ioaddr); | 1483 | write_SSCR0(0, drv_data->ioaddr); |
@@ -1640,33 +1492,21 @@ static int pxa2xx_spi_probe(struct platform_device *pdev) | |||
1640 | write_SSTO(0, drv_data->ioaddr); | 1492 | write_SSTO(0, drv_data->ioaddr); |
1641 | write_SSPSP(0, drv_data->ioaddr); | 1493 | write_SSPSP(0, drv_data->ioaddr); |
1642 | 1494 | ||
1643 | /* Initial and start queue */ | 1495 | tasklet_init(&drv_data->pump_transfers, pump_transfers, |
1644 | status = init_queue(drv_data); | 1496 | (unsigned long)drv_data); |
1645 | if (status != 0) { | ||
1646 | dev_err(&pdev->dev, "problem initializing queue\n"); | ||
1647 | goto out_error_clock_enabled; | ||
1648 | } | ||
1649 | status = start_queue(drv_data); | ||
1650 | if (status != 0) { | ||
1651 | dev_err(&pdev->dev, "problem starting queue\n"); | ||
1652 | goto out_error_clock_enabled; | ||
1653 | } | ||
1654 | 1497 | ||
1655 | /* Register with the SPI framework */ | 1498 | /* Register with the SPI framework */ |
1656 | platform_set_drvdata(pdev, drv_data); | 1499 | platform_set_drvdata(pdev, drv_data); |
1657 | status = spi_register_master(master); | 1500 | status = spi_register_master(master); |
1658 | if (status != 0) { | 1501 | if (status != 0) { |
1659 | dev_err(&pdev->dev, "problem registering spi master\n"); | 1502 | dev_err(&pdev->dev, "problem registering spi master\n"); |
1660 | goto out_error_queue_alloc; | 1503 | goto out_error_clock_enabled; |
1661 | } | 1504 | } |
1662 | 1505 | ||
1663 | return status; | 1506 | return status; |
1664 | 1507 | ||
1665 | out_error_queue_alloc: | ||
1666 | destroy_queue(drv_data); | ||
1667 | |||
1668 | out_error_clock_enabled: | 1508 | out_error_clock_enabled: |
1669 | clk_disable(ssp->clk); | 1509 | clk_disable_unprepare(ssp->clk); |
1670 | 1510 | ||
1671 | out_error_dma_alloc: | 1511 | out_error_dma_alloc: |
1672 | if (drv_data->tx_channel != -1) | 1512 | if (drv_data->tx_channel != -1) |
@@ -1687,29 +1527,14 @@ static int pxa2xx_spi_remove(struct platform_device *pdev) | |||
1687 | { | 1527 | { |
1688 | struct driver_data *drv_data = platform_get_drvdata(pdev); | 1528 | struct driver_data *drv_data = platform_get_drvdata(pdev); |
1689 | struct ssp_device *ssp; | 1529 | struct ssp_device *ssp; |
1690 | int status = 0; | ||
1691 | 1530 | ||
1692 | if (!drv_data) | 1531 | if (!drv_data) |
1693 | return 0; | 1532 | return 0; |
1694 | ssp = drv_data->ssp; | 1533 | ssp = drv_data->ssp; |
1695 | 1534 | ||
1696 | /* Remove the queue */ | ||
1697 | status = destroy_queue(drv_data); | ||
1698 | if (status != 0) | ||
1699 | /* the kernel does not check the return status of this | ||
1700 | * this routine (mod->exit, within the kernel). Therefore | ||
1701 | * nothing is gained by returning from here, the module is | ||
1702 | * going away regardless, and we should not leave any more | ||
1703 | * resources allocated than necessary. We cannot free the | ||
1704 | * message memory in drv_data->queue, but we can release the | ||
1705 | * resources below. I think the kernel should honor -EBUSY | ||
1706 | * returns but... */ | ||
1707 | dev_err(&pdev->dev, "pxa2xx_spi_remove: workqueue will not " | ||
1708 | "complete, message memory not freed\n"); | ||
1709 | |||
1710 | /* Disable the SSP at the peripheral and SOC level */ | 1535 | /* Disable the SSP at the peripheral and SOC level */ |
1711 | write_SSCR0(0, drv_data->ioaddr); | 1536 | write_SSCR0(0, drv_data->ioaddr); |
1712 | clk_disable(ssp->clk); | 1537 | clk_disable_unprepare(ssp->clk); |
1713 | 1538 | ||
1714 | /* Release DMA */ | 1539 | /* Release DMA */ |
1715 | if (drv_data->master_info->enable_dma) { | 1540 | if (drv_data->master_info->enable_dma) { |
@@ -1749,11 +1574,11 @@ static int pxa2xx_spi_suspend(struct device *dev) | |||
1749 | struct ssp_device *ssp = drv_data->ssp; | 1574 | struct ssp_device *ssp = drv_data->ssp; |
1750 | int status = 0; | 1575 | int status = 0; |
1751 | 1576 | ||
1752 | status = stop_queue(drv_data); | 1577 | status = spi_master_suspend(drv_data->master); |
1753 | if (status != 0) | 1578 | if (status != 0) |
1754 | return status; | 1579 | return status; |
1755 | write_SSCR0(0, drv_data->ioaddr); | 1580 | write_SSCR0(0, drv_data->ioaddr); |
1756 | clk_disable(ssp->clk); | 1581 | clk_disable_unprepare(ssp->clk); |
1757 | 1582 | ||
1758 | return 0; | 1583 | return 0; |
1759 | } | 1584 | } |
@@ -1772,10 +1597,10 @@ static int pxa2xx_spi_resume(struct device *dev) | |||
1772 | DRCMR_MAPVLD | drv_data->tx_channel; | 1597 | DRCMR_MAPVLD | drv_data->tx_channel; |
1773 | 1598 | ||
1774 | /* Enable the SSP clock */ | 1599 | /* Enable the SSP clock */ |
1775 | clk_enable(ssp->clk); | 1600 | clk_prepare_enable(ssp->clk); |
1776 | 1601 | ||
1777 | /* Start the queue running */ | 1602 | /* Start the queue running */ |
1778 | status = start_queue(drv_data); | 1603 | status = spi_master_resume(drv_data->master); |
1779 | if (status != 0) { | 1604 | if (status != 0) { |
1780 | dev_err(dev, "problem starting queue (%d)\n", status); | 1605 | dev_err(dev, "problem starting queue (%d)\n", status); |
1781 | return status; | 1606 | return status; |
diff --git a/drivers/spi/spi-s3c64xx.c b/drivers/spi/spi-s3c64xx.c index d77b6560b67f..a82bfa4af601 100644 --- a/drivers/spi/spi-s3c64xx.c +++ b/drivers/spi/spi-s3c64xx.c | |||
@@ -957,6 +957,8 @@ static int s3c64xx_spi_setup(struct spi_device *spi) | |||
957 | if (spi->max_speed_hz >= speed) { | 957 | if (spi->max_speed_hz >= speed) { |
958 | spi->max_speed_hz = speed; | 958 | spi->max_speed_hz = speed; |
959 | } else { | 959 | } else { |
960 | dev_err(&spi->dev, "Can't set %dHz transfer speed\n", | ||
961 | spi->max_speed_hz); | ||
960 | err = -EINVAL; | 962 | err = -EINVAL; |
961 | goto setup_exit; | 963 | goto setup_exit; |
962 | } | 964 | } |