diff options
-rw-r--r-- | Documentation/devicetree/bindings/spi/sh-msiof.txt | 23 | ||||
-rw-r--r-- | Documentation/devicetree/bindings/spi/spi-rspi.txt | 10 | ||||
-rw-r--r-- | drivers/spi/Kconfig | 2 | ||||
-rw-r--r-- | drivers/spi/spi-pl022.c | 64 | ||||
-rw-r--r-- | drivers/spi/spi-pxa2xx-pci.c | 20 | ||||
-rw-r--r-- | drivers/spi/spi-rspi.c | 55 | ||||
-rw-r--r-- | drivers/spi/spi-sh-msiof.c | 51 | ||||
-rw-r--r-- | drivers/spi/spi-sirf.c | 109 | ||||
-rw-r--r-- | include/linux/amba/bus.h | 5 |
9 files changed, 226 insertions, 113 deletions
diff --git a/Documentation/devicetree/bindings/spi/sh-msiof.txt b/Documentation/devicetree/bindings/spi/sh-msiof.txt index f24baf3b6cc1..d11c3721e7cd 100644 --- a/Documentation/devicetree/bindings/spi/sh-msiof.txt +++ b/Documentation/devicetree/bindings/spi/sh-msiof.txt | |||
@@ -6,8 +6,17 @@ Required properties: | |||
6 | "renesas,sh-mobile-msiof" for SH Mobile series. | 6 | "renesas,sh-mobile-msiof" for SH Mobile series. |
7 | Examples with soctypes are: | 7 | Examples with soctypes are: |
8 | "renesas,msiof-r8a7790" (R-Car H2) | 8 | "renesas,msiof-r8a7790" (R-Car H2) |
9 | "renesas,msiof-r8a7791" (R-Car M2) | 9 | "renesas,msiof-r8a7791" (R-Car M2-W) |
10 | - reg : Offset and length of the register set for the device | 10 | "renesas,msiof-r8a7792" (R-Car V2H) |
11 | "renesas,msiof-r8a7793" (R-Car M2-N) | ||
12 | "renesas,msiof-r8a7794" (R-Car E2) | ||
13 | - reg : A list of offsets and lengths of the register sets for | ||
14 | the device. | ||
15 | If only one register set is present, it is to be used | ||
16 | by both the CPU and the DMA engine. | ||
17 | If two register sets are present, the first is to be | ||
18 | used by the CPU, and the second is to be used by the | ||
19 | DMA engine. | ||
11 | - interrupt-parent : The phandle for the interrupt controller that | 20 | - interrupt-parent : The phandle for the interrupt controller that |
12 | services interrupts for this device | 21 | services interrupts for this device |
13 | - interrupts : Interrupt specifier | 22 | - interrupts : Interrupt specifier |
@@ -17,12 +26,16 @@ Required properties: | |||
17 | Optional properties: | 26 | Optional properties: |
18 | - clocks : Must contain a reference to the functional clock. | 27 | - clocks : Must contain a reference to the functional clock. |
19 | - num-cs : Total number of chip-selects (default is 1) | 28 | - num-cs : Total number of chip-selects (default is 1) |
29 | - dmas : Must contain a list of two references to DMA | ||
30 | specifiers, one for transmission, and one for | ||
31 | reception. | ||
32 | - dma-names : Must contain a list of two DMA names, "tx" and "rx". | ||
20 | 33 | ||
21 | Optional properties, deprecated for soctype-specific bindings: | 34 | Optional properties, deprecated for soctype-specific bindings: |
22 | - renesas,tx-fifo-size : Overrides the default tx fifo size given in words | 35 | - renesas,tx-fifo-size : Overrides the default tx fifo size given in words |
23 | (default is 64) | 36 | (default is 64) |
24 | - renesas,rx-fifo-size : Overrides the default rx fifo size given in words | 37 | - renesas,rx-fifo-size : Overrides the default rx fifo size given in words |
25 | (default is 64, or 256 on R-Car H2 and M2) | 38 | (default is 64, or 256 on R-Car Gen2) |
26 | 39 | ||
27 | Pinctrl properties might be needed, too. See | 40 | Pinctrl properties might be needed, too. See |
28 | Documentation/devicetree/bindings/pinctrl/renesas,*. | 41 | Documentation/devicetree/bindings/pinctrl/renesas,*. |
@@ -31,9 +44,11 @@ Example: | |||
31 | 44 | ||
32 | msiof0: spi@e6e20000 { | 45 | msiof0: spi@e6e20000 { |
33 | compatible = "renesas,msiof-r8a7791"; | 46 | compatible = "renesas,msiof-r8a7791"; |
34 | reg = <0 0xe6e20000 0 0x0064>; | 47 | reg = <0 0xe6e20000 0 0x0064>, <0 0xe7e20000 0 0x0064>; |
35 | interrupts = <0 156 IRQ_TYPE_LEVEL_HIGH>; | 48 | interrupts = <0 156 IRQ_TYPE_LEVEL_HIGH>; |
36 | clocks = <&mstp0_clks R8A7791_CLK_MSIOF0>; | 49 | clocks = <&mstp0_clks R8A7791_CLK_MSIOF0>; |
50 | dmas = <&dmac0 0x51>, <&dmac0 0x52>; | ||
51 | dma-names = "tx", "rx"; | ||
37 | #address-cells = <1>; | 52 | #address-cells = <1>; |
38 | #size-cells = <0>; | 53 | #size-cells = <0>; |
39 | status = "disabled"; | 54 | status = "disabled"; |
diff --git a/Documentation/devicetree/bindings/spi/spi-rspi.txt b/Documentation/devicetree/bindings/spi/spi-rspi.txt index d57d82a74054..8f4169f63936 100644 --- a/Documentation/devicetree/bindings/spi/spi-rspi.txt +++ b/Documentation/devicetree/bindings/spi/spi-rspi.txt | |||
@@ -11,7 +11,10 @@ Required properties: | |||
11 | - "renesas,rspi-sh7757" (SH) | 11 | - "renesas,rspi-sh7757" (SH) |
12 | - "renesas,rspi-r7s72100" (RZ/A1H) | 12 | - "renesas,rspi-r7s72100" (RZ/A1H) |
13 | - "renesas,qspi-r8a7790" (R-Car H2) | 13 | - "renesas,qspi-r8a7790" (R-Car H2) |
14 | - "renesas,qspi-r8a7791" (R-Car M2) | 14 | - "renesas,qspi-r8a7791" (R-Car M2-W) |
15 | - "renesas,qspi-r8a7792" (R-Car V2H) | ||
16 | - "renesas,qspi-r8a7793" (R-Car M2-N) | ||
17 | - "renesas,qspi-r8a7794" (R-Car E2) | ||
15 | - reg : Address start and address range size of the device | 18 | - reg : Address start and address range size of the device |
16 | - interrupts : A list of interrupt-specifiers, one for each entry in | 19 | - interrupts : A list of interrupt-specifiers, one for each entry in |
17 | interrupt-names. | 20 | interrupt-names. |
@@ -30,6 +33,9 @@ Required properties: | |||
30 | 33 | ||
31 | Optional properties: | 34 | Optional properties: |
32 | - clocks : Must contain a reference to the functional clock. | 35 | - clocks : Must contain a reference to the functional clock. |
36 | - dmas : Must contain a list of two references to DMA specifiers, | ||
37 | one for transmission, and one for reception. | ||
38 | - dma-names : Must contain a list of two DMA names, "tx" and "rx". | ||
33 | 39 | ||
34 | Pinctrl properties might be needed, too. See | 40 | Pinctrl properties might be needed, too. See |
35 | Documentation/devicetree/bindings/pinctrl/renesas,*. | 41 | Documentation/devicetree/bindings/pinctrl/renesas,*. |
@@ -58,4 +64,6 @@ Examples: | |||
58 | num-cs = <1>; | 64 | num-cs = <1>; |
59 | #address-cells = <1>; | 65 | #address-cells = <1>; |
60 | #size-cells = <0>; | 66 | #size-cells = <0>; |
67 | dmas = <&dmac0 0x17>, <&dmac0 0x18>; | ||
68 | dma-names = "tx", "rx"; | ||
61 | }; | 69 | }; |
diff --git a/drivers/spi/Kconfig b/drivers/spi/Kconfig index c4f19887987b..84e7c9e6ccef 100644 --- a/drivers/spi/Kconfig +++ b/drivers/spi/Kconfig | |||
@@ -391,7 +391,7 @@ config SPI_PXA2XX | |||
391 | additional documentation can be found a Documentation/spi/pxa2xx. | 391 | additional documentation can be found a Documentation/spi/pxa2xx. |
392 | 392 | ||
393 | config SPI_PXA2XX_PCI | 393 | config SPI_PXA2XX_PCI |
394 | def_tristate SPI_PXA2XX && PCI | 394 | def_tristate SPI_PXA2XX && PCI && COMMON_CLK |
395 | 395 | ||
396 | config SPI_ROCKCHIP | 396 | config SPI_ROCKCHIP |
397 | tristate "Rockchip SPI controller driver" | 397 | tristate "Rockchip SPI controller driver" |
diff --git a/drivers/spi/spi-pl022.c b/drivers/spi/spi-pl022.c index f1f0a587e4fc..f35f723816ea 100644 --- a/drivers/spi/spi-pl022.c +++ b/drivers/spi/spi-pl022.c | |||
@@ -82,6 +82,7 @@ | |||
82 | #define SSP_MIS(r) (r + 0x01C) | 82 | #define SSP_MIS(r) (r + 0x01C) |
83 | #define SSP_ICR(r) (r + 0x020) | 83 | #define SSP_ICR(r) (r + 0x020) |
84 | #define SSP_DMACR(r) (r + 0x024) | 84 | #define SSP_DMACR(r) (r + 0x024) |
85 | #define SSP_CSR(r) (r + 0x030) /* vendor extension */ | ||
85 | #define SSP_ITCR(r) (r + 0x080) | 86 | #define SSP_ITCR(r) (r + 0x080) |
86 | #define SSP_ITIP(r) (r + 0x084) | 87 | #define SSP_ITIP(r) (r + 0x084) |
87 | #define SSP_ITOP(r) (r + 0x088) | 88 | #define SSP_ITOP(r) (r + 0x088) |
@@ -198,6 +199,12 @@ | |||
198 | #define SSP_DMACR_MASK_TXDMAE (0x1UL << 1) | 199 | #define SSP_DMACR_MASK_TXDMAE (0x1UL << 1) |
199 | 200 | ||
200 | /* | 201 | /* |
202 | * SSP Chip Select Control Register - SSP_CSR | ||
203 | * (vendor extension) | ||
204 | */ | ||
205 | #define SSP_CSR_CSVALUE_MASK (0x1FUL << 0) | ||
206 | |||
207 | /* | ||
201 | * SSP Integration Test control Register - SSP_ITCR | 208 | * SSP Integration Test control Register - SSP_ITCR |
202 | */ | 209 | */ |
203 | #define SSP_ITCR_MASK_ITEN (0x1UL << 0) | 210 | #define SSP_ITCR_MASK_ITEN (0x1UL << 0) |
@@ -313,6 +320,7 @@ enum ssp_writing { | |||
313 | * @extended_cr: 32 bit wide control register 0 with extra | 320 | * @extended_cr: 32 bit wide control register 0 with extra |
314 | * features and extra features in CR1 as found in the ST variants | 321 | * features and extra features in CR1 as found in the ST variants |
315 | * @pl023: supports a subset of the ST extensions called "PL023" | 322 | * @pl023: supports a subset of the ST extensions called "PL023" |
323 | * @internal_cs_ctrl: supports chip select control register | ||
316 | */ | 324 | */ |
317 | struct vendor_data { | 325 | struct vendor_data { |
318 | int fifodepth; | 326 | int fifodepth; |
@@ -321,6 +329,7 @@ struct vendor_data { | |||
321 | bool extended_cr; | 329 | bool extended_cr; |
322 | bool pl023; | 330 | bool pl023; |
323 | bool loopback; | 331 | bool loopback; |
332 | bool internal_cs_ctrl; | ||
324 | }; | 333 | }; |
325 | 334 | ||
326 | /** | 335 | /** |
@@ -440,9 +449,32 @@ static void null_cs_control(u32 command) | |||
440 | pr_debug("pl022: dummy chip select control, CS=0x%x\n", command); | 449 | pr_debug("pl022: dummy chip select control, CS=0x%x\n", command); |
441 | } | 450 | } |
442 | 451 | ||
452 | /** | ||
453 | * internal_cs_control - Control chip select signals via SSP_CSR. | ||
454 | * @pl022: SSP driver private data structure | ||
455 | * @command: select/delect the chip | ||
456 | * | ||
457 | * Used on controller with internal chip select control via SSP_CSR register | ||
458 | * (vendor extension). Each of the 5 LSB in the register controls one chip | ||
459 | * select signal. | ||
460 | */ | ||
461 | static void internal_cs_control(struct pl022 *pl022, u32 command) | ||
462 | { | ||
463 | u32 tmp; | ||
464 | |||
465 | tmp = readw(SSP_CSR(pl022->virtbase)); | ||
466 | if (command == SSP_CHIP_SELECT) | ||
467 | tmp &= ~BIT(pl022->cur_cs); | ||
468 | else | ||
469 | tmp |= BIT(pl022->cur_cs); | ||
470 | writew(tmp, SSP_CSR(pl022->virtbase)); | ||
471 | } | ||
472 | |||
443 | static void pl022_cs_control(struct pl022 *pl022, u32 command) | 473 | static void pl022_cs_control(struct pl022 *pl022, u32 command) |
444 | { | 474 | { |
445 | if (gpio_is_valid(pl022->cur_cs)) | 475 | if (pl022->vendor->internal_cs_ctrl) |
476 | internal_cs_control(pl022, command); | ||
477 | else if (gpio_is_valid(pl022->cur_cs)) | ||
446 | gpio_set_value(pl022->cur_cs, command); | 478 | gpio_set_value(pl022->cur_cs, command); |
447 | else | 479 | else |
448 | pl022->cur_chip->cs_control(command); | 480 | pl022->cur_chip->cs_control(command); |
@@ -2100,6 +2132,10 @@ static int pl022_probe(struct amba_device *adev, const struct amba_id *id) | |||
2100 | pl022->vendor = id->data; | 2132 | pl022->vendor = id->data; |
2101 | pl022->chipselects = devm_kzalloc(dev, num_cs * sizeof(int), | 2133 | pl022->chipselects = devm_kzalloc(dev, num_cs * sizeof(int), |
2102 | GFP_KERNEL); | 2134 | GFP_KERNEL); |
2135 | if (!pl022->chipselects) { | ||
2136 | status = -ENOMEM; | ||
2137 | goto err_no_mem; | ||
2138 | } | ||
2103 | 2139 | ||
2104 | /* | 2140 | /* |
2105 | * Bus Number Which has been Assigned to this SSP controller | 2141 | * Bus Number Which has been Assigned to this SSP controller |
@@ -2118,6 +2154,9 @@ static int pl022_probe(struct amba_device *adev, const struct amba_id *id) | |||
2118 | if (platform_info->num_chipselect && platform_info->chipselects) { | 2154 | if (platform_info->num_chipselect && platform_info->chipselects) { |
2119 | for (i = 0; i < num_cs; i++) | 2155 | for (i = 0; i < num_cs; i++) |
2120 | pl022->chipselects[i] = platform_info->chipselects[i]; | 2156 | pl022->chipselects[i] = platform_info->chipselects[i]; |
2157 | } else if (pl022->vendor->internal_cs_ctrl) { | ||
2158 | for (i = 0; i < num_cs; i++) | ||
2159 | pl022->chipselects[i] = i; | ||
2121 | } else if (IS_ENABLED(CONFIG_OF)) { | 2160 | } else if (IS_ENABLED(CONFIG_OF)) { |
2122 | for (i = 0; i < num_cs; i++) { | 2161 | for (i = 0; i < num_cs; i++) { |
2123 | int cs_gpio = of_get_named_gpio(np, "cs-gpios", i); | 2162 | int cs_gpio = of_get_named_gpio(np, "cs-gpios", i); |
@@ -2241,6 +2280,7 @@ static int pl022_probe(struct amba_device *adev, const struct amba_id *id) | |||
2241 | amba_release_regions(adev); | 2280 | amba_release_regions(adev); |
2242 | err_no_ioregion: | 2281 | err_no_ioregion: |
2243 | err_no_gpio: | 2282 | err_no_gpio: |
2283 | err_no_mem: | ||
2244 | spi_master_put(master); | 2284 | spi_master_put(master); |
2245 | return status; | 2285 | return status; |
2246 | } | 2286 | } |
@@ -2347,6 +2387,7 @@ static struct vendor_data vendor_arm = { | |||
2347 | .extended_cr = false, | 2387 | .extended_cr = false, |
2348 | .pl023 = false, | 2388 | .pl023 = false, |
2349 | .loopback = true, | 2389 | .loopback = true, |
2390 | .internal_cs_ctrl = false, | ||
2350 | }; | 2391 | }; |
2351 | 2392 | ||
2352 | static struct vendor_data vendor_st = { | 2393 | static struct vendor_data vendor_st = { |
@@ -2356,6 +2397,7 @@ static struct vendor_data vendor_st = { | |||
2356 | .extended_cr = true, | 2397 | .extended_cr = true, |
2357 | .pl023 = false, | 2398 | .pl023 = false, |
2358 | .loopback = true, | 2399 | .loopback = true, |
2400 | .internal_cs_ctrl = false, | ||
2359 | }; | 2401 | }; |
2360 | 2402 | ||
2361 | static struct vendor_data vendor_st_pl023 = { | 2403 | static struct vendor_data vendor_st_pl023 = { |
@@ -2365,6 +2407,17 @@ static struct vendor_data vendor_st_pl023 = { | |||
2365 | .extended_cr = true, | 2407 | .extended_cr = true, |
2366 | .pl023 = true, | 2408 | .pl023 = true, |
2367 | .loopback = false, | 2409 | .loopback = false, |
2410 | .internal_cs_ctrl = false, | ||
2411 | }; | ||
2412 | |||
2413 | static struct vendor_data vendor_lsi = { | ||
2414 | .fifodepth = 8, | ||
2415 | .max_bpw = 16, | ||
2416 | .unidir = false, | ||
2417 | .extended_cr = false, | ||
2418 | .pl023 = false, | ||
2419 | .loopback = true, | ||
2420 | .internal_cs_ctrl = true, | ||
2368 | }; | 2421 | }; |
2369 | 2422 | ||
2370 | static struct amba_id pl022_ids[] = { | 2423 | static struct amba_id pl022_ids[] = { |
@@ -2398,6 +2451,15 @@ static struct amba_id pl022_ids[] = { | |||
2398 | .mask = 0xffffffff, | 2451 | .mask = 0xffffffff, |
2399 | .data = &vendor_st_pl023, | 2452 | .data = &vendor_st_pl023, |
2400 | }, | 2453 | }, |
2454 | { | ||
2455 | /* | ||
2456 | * PL022 variant that has a chip select control register whih | ||
2457 | * allows control of 5 output signals nCS[0:4]. | ||
2458 | */ | ||
2459 | .id = 0x000b6022, | ||
2460 | .mask = 0x000fffff, | ||
2461 | .data = &vendor_lsi, | ||
2462 | }, | ||
2401 | { 0, 0 }, | 2463 | { 0, 0 }, |
2402 | }; | 2464 | }; |
2403 | 2465 | ||
diff --git a/drivers/spi/spi-pxa2xx-pci.c b/drivers/spi/spi-pxa2xx-pci.c index c1865c92ccb9..536c863bebf1 100644 --- a/drivers/spi/spi-pxa2xx-pci.c +++ b/drivers/spi/spi-pxa2xx-pci.c | |||
@@ -7,6 +7,8 @@ | |||
7 | #include <linux/of_device.h> | 7 | #include <linux/of_device.h> |
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 | #include <linux/clk.h> | ||
11 | #include <linux/clk-provider.h> | ||
10 | 12 | ||
11 | enum { | 13 | enum { |
12 | PORT_CE4100, | 14 | PORT_CE4100, |
@@ -21,6 +23,7 @@ struct pxa_spi_info { | |||
21 | int tx_chan_id; | 23 | int tx_chan_id; |
22 | int rx_slave_id; | 24 | int rx_slave_id; |
23 | int rx_chan_id; | 25 | int rx_chan_id; |
26 | unsigned long max_clk_rate; | ||
24 | }; | 27 | }; |
25 | 28 | ||
26 | static struct pxa_spi_info spi_info_configs[] = { | 29 | static struct pxa_spi_info spi_info_configs[] = { |
@@ -32,6 +35,7 @@ static struct pxa_spi_info spi_info_configs[] = { | |||
32 | .tx_chan_id = -1, | 35 | .tx_chan_id = -1, |
33 | .rx_slave_id = -1, | 36 | .rx_slave_id = -1, |
34 | .rx_chan_id = -1, | 37 | .rx_chan_id = -1, |
38 | .max_clk_rate = 3686400, | ||
35 | }, | 39 | }, |
36 | [PORT_BYT] = { | 40 | [PORT_BYT] = { |
37 | .type = LPSS_SSP, | 41 | .type = LPSS_SSP, |
@@ -41,6 +45,7 @@ static struct pxa_spi_info spi_info_configs[] = { | |||
41 | .tx_chan_id = 0, | 45 | .tx_chan_id = 0, |
42 | .rx_slave_id = 1, | 46 | .rx_slave_id = 1, |
43 | .rx_chan_id = 1, | 47 | .rx_chan_id = 1, |
48 | .max_clk_rate = 50000000, | ||
44 | }, | 49 | }, |
45 | }; | 50 | }; |
46 | 51 | ||
@@ -53,6 +58,7 @@ static int pxa2xx_spi_pci_probe(struct pci_dev *dev, | |||
53 | struct pxa2xx_spi_master spi_pdata; | 58 | struct pxa2xx_spi_master spi_pdata; |
54 | struct ssp_device *ssp; | 59 | struct ssp_device *ssp; |
55 | struct pxa_spi_info *c; | 60 | struct pxa_spi_info *c; |
61 | char buf[40]; | ||
56 | 62 | ||
57 | ret = pcim_enable_device(dev); | 63 | ret = pcim_enable_device(dev); |
58 | if (ret) | 64 | if (ret) |
@@ -84,6 +90,12 @@ static int pxa2xx_spi_pci_probe(struct pci_dev *dev, | |||
84 | ssp->port_id = (c->port_id >= 0) ? c->port_id : dev->devfn; | 90 | ssp->port_id = (c->port_id >= 0) ? c->port_id : dev->devfn; |
85 | ssp->type = c->type; | 91 | ssp->type = c->type; |
86 | 92 | ||
93 | snprintf(buf, sizeof(buf), "pxa2xx-spi.%d", ssp->port_id); | ||
94 | ssp->clk = clk_register_fixed_rate(&dev->dev, buf , NULL, | ||
95 | CLK_IS_ROOT, c->max_clk_rate); | ||
96 | if (IS_ERR(ssp->clk)) | ||
97 | return PTR_ERR(ssp->clk); | ||
98 | |||
87 | memset(&pi, 0, sizeof(pi)); | 99 | memset(&pi, 0, sizeof(pi)); |
88 | pi.parent = &dev->dev; | 100 | pi.parent = &dev->dev; |
89 | pi.name = "pxa2xx-spi"; | 101 | pi.name = "pxa2xx-spi"; |
@@ -92,8 +104,10 @@ static int pxa2xx_spi_pci_probe(struct pci_dev *dev, | |||
92 | pi.size_data = sizeof(spi_pdata); | 104 | pi.size_data = sizeof(spi_pdata); |
93 | 105 | ||
94 | pdev = platform_device_register_full(&pi); | 106 | pdev = platform_device_register_full(&pi); |
95 | if (IS_ERR(pdev)) | 107 | if (IS_ERR(pdev)) { |
108 | clk_unregister(ssp->clk); | ||
96 | return PTR_ERR(pdev); | 109 | return PTR_ERR(pdev); |
110 | } | ||
97 | 111 | ||
98 | pci_set_drvdata(dev, pdev); | 112 | pci_set_drvdata(dev, pdev); |
99 | 113 | ||
@@ -103,8 +117,12 @@ static int pxa2xx_spi_pci_probe(struct pci_dev *dev, | |||
103 | static void pxa2xx_spi_pci_remove(struct pci_dev *dev) | 117 | static void pxa2xx_spi_pci_remove(struct pci_dev *dev) |
104 | { | 118 | { |
105 | struct platform_device *pdev = pci_get_drvdata(dev); | 119 | struct platform_device *pdev = pci_get_drvdata(dev); |
120 | struct pxa2xx_spi_master *spi_pdata; | ||
121 | |||
122 | spi_pdata = dev_get_platdata(&pdev->dev); | ||
106 | 123 | ||
107 | platform_device_unregister(pdev); | 124 | platform_device_unregister(pdev); |
125 | clk_unregister(spi_pdata->ssp.clk); | ||
108 | } | 126 | } |
109 | 127 | ||
110 | static const struct pci_device_id pxa2xx_spi_pci_devices[] = { | 128 | static const struct pci_device_id pxa2xx_spi_pci_devices[] = { |
diff --git a/drivers/spi/spi-rspi.c b/drivers/spi/spi-rspi.c index ad87a98f8f68..54bb0faec155 100644 --- a/drivers/spi/spi-rspi.c +++ b/drivers/spi/spi-rspi.c | |||
@@ -87,7 +87,7 @@ | |||
87 | /* RSPI on SH only */ | 87 | /* RSPI on SH only */ |
88 | #define SPCR_TXMD 0x02 /* TX Only Mode (vs. Full Duplex) */ | 88 | #define SPCR_TXMD 0x02 /* TX Only Mode (vs. Full Duplex) */ |
89 | #define SPCR_SPMS 0x01 /* 3-wire Mode (vs. 4-wire) */ | 89 | #define SPCR_SPMS 0x01 /* 3-wire Mode (vs. 4-wire) */ |
90 | /* QSPI on R-Car M2 only */ | 90 | /* QSPI on R-Car Gen2 only */ |
91 | #define SPCR_WSWAP 0x02 /* Word Swap of read-data for DMAC */ | 91 | #define SPCR_WSWAP 0x02 /* Word Swap of read-data for DMAC */ |
92 | #define SPCR_BSWAP 0x01 /* Byte Swap of read-data for DMAC */ | 92 | #define SPCR_BSWAP 0x01 /* Byte Swap of read-data for DMAC */ |
93 | 93 | ||
@@ -909,20 +909,24 @@ static struct dma_chan *rspi_request_dma_chan(struct device *dev, | |||
909 | dma_cap_zero(mask); | 909 | dma_cap_zero(mask); |
910 | dma_cap_set(DMA_SLAVE, mask); | 910 | dma_cap_set(DMA_SLAVE, mask); |
911 | 911 | ||
912 | chan = dma_request_channel(mask, shdma_chan_filter, | 912 | chan = dma_request_slave_channel_compat(mask, shdma_chan_filter, |
913 | (void *)(unsigned long)id); | 913 | (void *)(unsigned long)id, dev, |
914 | dir == DMA_MEM_TO_DEV ? "tx" : "rx"); | ||
914 | if (!chan) { | 915 | if (!chan) { |
915 | dev_warn(dev, "dma_request_channel failed\n"); | 916 | dev_warn(dev, "dma_request_slave_channel_compat failed\n"); |
916 | return NULL; | 917 | return NULL; |
917 | } | 918 | } |
918 | 919 | ||
919 | memset(&cfg, 0, sizeof(cfg)); | 920 | memset(&cfg, 0, sizeof(cfg)); |
920 | cfg.slave_id = id; | 921 | cfg.slave_id = id; |
921 | cfg.direction = dir; | 922 | cfg.direction = dir; |
922 | if (dir == DMA_MEM_TO_DEV) | 923 | if (dir == DMA_MEM_TO_DEV) { |
923 | cfg.dst_addr = port_addr; | 924 | cfg.dst_addr = port_addr; |
924 | else | 925 | cfg.dst_addr_width = DMA_SLAVE_BUSWIDTH_1_BYTE; |
926 | } else { | ||
925 | cfg.src_addr = port_addr; | 927 | cfg.src_addr = port_addr; |
928 | cfg.src_addr_width = DMA_SLAVE_BUSWIDTH_1_BYTE; | ||
929 | } | ||
926 | 930 | ||
927 | ret = dmaengine_slave_config(chan, &cfg); | 931 | ret = dmaengine_slave_config(chan, &cfg); |
928 | if (ret) { | 932 | if (ret) { |
@@ -938,22 +942,30 @@ static int rspi_request_dma(struct device *dev, struct spi_master *master, | |||
938 | const struct resource *res) | 942 | const struct resource *res) |
939 | { | 943 | { |
940 | const struct rspi_plat_data *rspi_pd = dev_get_platdata(dev); | 944 | const struct rspi_plat_data *rspi_pd = dev_get_platdata(dev); |
945 | unsigned int dma_tx_id, dma_rx_id; | ||
946 | |||
947 | if (dev->of_node) { | ||
948 | /* In the OF case we will get the slave IDs from the DT */ | ||
949 | dma_tx_id = 0; | ||
950 | dma_rx_id = 0; | ||
951 | } else if (rspi_pd && rspi_pd->dma_tx_id && rspi_pd->dma_rx_id) { | ||
952 | dma_tx_id = rspi_pd->dma_tx_id; | ||
953 | dma_rx_id = rspi_pd->dma_rx_id; | ||
954 | } else { | ||
955 | /* The driver assumes no error. */ | ||
956 | return 0; | ||
957 | } | ||
941 | 958 | ||
942 | if (!rspi_pd || !rspi_pd->dma_rx_id || !rspi_pd->dma_tx_id) | 959 | master->dma_tx = rspi_request_dma_chan(dev, DMA_MEM_TO_DEV, dma_tx_id, |
943 | return 0; /* The driver assumes no error. */ | ||
944 | |||
945 | master->dma_rx = rspi_request_dma_chan(dev, DMA_DEV_TO_MEM, | ||
946 | rspi_pd->dma_rx_id, | ||
947 | res->start + RSPI_SPDR); | 960 | res->start + RSPI_SPDR); |
948 | if (!master->dma_rx) | 961 | if (!master->dma_tx) |
949 | return -ENODEV; | 962 | return -ENODEV; |
950 | 963 | ||
951 | master->dma_tx = rspi_request_dma_chan(dev, DMA_MEM_TO_DEV, | 964 | master->dma_rx = rspi_request_dma_chan(dev, DMA_DEV_TO_MEM, dma_rx_id, |
952 | rspi_pd->dma_tx_id, | ||
953 | res->start + RSPI_SPDR); | 965 | res->start + RSPI_SPDR); |
954 | if (!master->dma_tx) { | 966 | if (!master->dma_rx) { |
955 | dma_release_channel(master->dma_rx); | 967 | dma_release_channel(master->dma_tx); |
956 | master->dma_rx = NULL; | 968 | master->dma_tx = NULL; |
957 | return -ENODEV; | 969 | return -ENODEV; |
958 | } | 970 | } |
959 | 971 | ||
@@ -1046,12 +1058,11 @@ static int rspi_request_irq(struct device *dev, unsigned int irq, | |||
1046 | irq_handler_t handler, const char *suffix, | 1058 | irq_handler_t handler, const char *suffix, |
1047 | void *dev_id) | 1059 | void *dev_id) |
1048 | { | 1060 | { |
1049 | const char *base = dev_name(dev); | 1061 | const char *name = devm_kasprintf(dev, GFP_KERNEL, "%s:%s", |
1050 | size_t len = strlen(base) + strlen(suffix) + 2; | 1062 | dev_name(dev), suffix); |
1051 | char *name = devm_kzalloc(dev, len, GFP_KERNEL); | ||
1052 | if (!name) | 1063 | if (!name) |
1053 | return -ENOMEM; | 1064 | return -ENOMEM; |
1054 | snprintf(name, len, "%s:%s", base, suffix); | 1065 | |
1055 | return devm_request_irq(dev, irq, handler, 0, name, dev_id); | 1066 | return devm_request_irq(dev, irq, handler, 0, name, dev_id); |
1056 | } | 1067 | } |
1057 | 1068 | ||
@@ -1084,7 +1095,7 @@ static int rspi_probe(struct platform_device *pdev) | |||
1084 | master->num_chipselect = rspi_pd->num_chipselect; | 1095 | master->num_chipselect = rspi_pd->num_chipselect; |
1085 | else | 1096 | else |
1086 | master->num_chipselect = 2; /* default */ | 1097 | master->num_chipselect = 2; /* default */ |
1087 | }; | 1098 | } |
1088 | 1099 | ||
1089 | /* ops parameter check */ | 1100 | /* ops parameter check */ |
1090 | if (!ops->set_config_register) { | 1101 | if (!ops->set_config_register) { |
diff --git a/drivers/spi/spi-sh-msiof.c b/drivers/spi/spi-sh-msiof.c index 543075b80f16..3f365402fcc0 100644 --- a/drivers/spi/spi-sh-msiof.c +++ b/drivers/spi/spi-sh-msiof.c | |||
@@ -642,18 +642,14 @@ static int sh_msiof_dma_once(struct sh_msiof_spi_priv *p, const void *tx, | |||
642 | desc_rx = dmaengine_prep_slave_single(p->master->dma_rx, | 642 | desc_rx = dmaengine_prep_slave_single(p->master->dma_rx, |
643 | p->rx_dma_addr, len, DMA_FROM_DEVICE, | 643 | p->rx_dma_addr, len, DMA_FROM_DEVICE, |
644 | DMA_PREP_INTERRUPT | DMA_CTRL_ACK); | 644 | DMA_PREP_INTERRUPT | DMA_CTRL_ACK); |
645 | if (!desc_rx) { | 645 | if (!desc_rx) |
646 | ret = -EAGAIN; | 646 | return -EAGAIN; |
647 | goto no_dma_rx; | ||
648 | } | ||
649 | 647 | ||
650 | desc_rx->callback = sh_msiof_dma_complete; | 648 | desc_rx->callback = sh_msiof_dma_complete; |
651 | desc_rx->callback_param = p; | 649 | desc_rx->callback_param = p; |
652 | cookie = dmaengine_submit(desc_rx); | 650 | cookie = dmaengine_submit(desc_rx); |
653 | if (dma_submit_error(cookie)) { | 651 | if (dma_submit_error(cookie)) |
654 | ret = cookie; | 652 | return cookie; |
655 | goto no_dma_rx; | ||
656 | } | ||
657 | } | 653 | } |
658 | 654 | ||
659 | if (tx) { | 655 | if (tx) { |
@@ -738,7 +734,6 @@ no_dma_tx: | |||
738 | if (rx) | 734 | if (rx) |
739 | dmaengine_terminate_all(p->master->dma_rx); | 735 | dmaengine_terminate_all(p->master->dma_rx); |
740 | sh_msiof_write(p, IER, 0); | 736 | sh_msiof_write(p, IER, 0); |
741 | no_dma_rx: | ||
742 | return ret; | 737 | return ret; |
743 | } | 738 | } |
744 | 739 | ||
@@ -933,6 +928,9 @@ static const struct of_device_id sh_msiof_match[] = { | |||
933 | { .compatible = "renesas,sh-mobile-msiof", .data = &sh_data }, | 928 | { .compatible = "renesas,sh-mobile-msiof", .data = &sh_data }, |
934 | { .compatible = "renesas,msiof-r8a7790", .data = &r8a779x_data }, | 929 | { .compatible = "renesas,msiof-r8a7790", .data = &r8a779x_data }, |
935 | { .compatible = "renesas,msiof-r8a7791", .data = &r8a779x_data }, | 930 | { .compatible = "renesas,msiof-r8a7791", .data = &r8a779x_data }, |
931 | { .compatible = "renesas,msiof-r8a7792", .data = &r8a779x_data }, | ||
932 | { .compatible = "renesas,msiof-r8a7793", .data = &r8a779x_data }, | ||
933 | { .compatible = "renesas,msiof-r8a7794", .data = &r8a779x_data }, | ||
936 | {}, | 934 | {}, |
937 | }; | 935 | }; |
938 | MODULE_DEVICE_TABLE(of, sh_msiof_match); | 936 | MODULE_DEVICE_TABLE(of, sh_msiof_match); |
@@ -977,20 +975,24 @@ static struct dma_chan *sh_msiof_request_dma_chan(struct device *dev, | |||
977 | dma_cap_zero(mask); | 975 | dma_cap_zero(mask); |
978 | dma_cap_set(DMA_SLAVE, mask); | 976 | dma_cap_set(DMA_SLAVE, mask); |
979 | 977 | ||
980 | chan = dma_request_channel(mask, shdma_chan_filter, | 978 | chan = dma_request_slave_channel_compat(mask, shdma_chan_filter, |
981 | (void *)(unsigned long)id); | 979 | (void *)(unsigned long)id, dev, |
980 | dir == DMA_MEM_TO_DEV ? "tx" : "rx"); | ||
982 | if (!chan) { | 981 | if (!chan) { |
983 | dev_warn(dev, "dma_request_channel failed\n"); | 982 | dev_warn(dev, "dma_request_slave_channel_compat failed\n"); |
984 | return NULL; | 983 | return NULL; |
985 | } | 984 | } |
986 | 985 | ||
987 | memset(&cfg, 0, sizeof(cfg)); | 986 | memset(&cfg, 0, sizeof(cfg)); |
988 | cfg.slave_id = id; | 987 | cfg.slave_id = id; |
989 | cfg.direction = dir; | 988 | cfg.direction = dir; |
990 | if (dir == DMA_MEM_TO_DEV) | 989 | if (dir == DMA_MEM_TO_DEV) { |
991 | cfg.dst_addr = port_addr; | 990 | cfg.dst_addr = port_addr; |
992 | else | 991 | cfg.dst_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES; |
992 | } else { | ||
993 | cfg.src_addr = port_addr; | 993 | cfg.src_addr = port_addr; |
994 | cfg.src_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES; | ||
995 | } | ||
994 | 996 | ||
995 | ret = dmaengine_slave_config(chan, &cfg); | 997 | ret = dmaengine_slave_config(chan, &cfg); |
996 | if (ret) { | 998 | if (ret) { |
@@ -1007,12 +1009,22 @@ static int sh_msiof_request_dma(struct sh_msiof_spi_priv *p) | |||
1007 | struct platform_device *pdev = p->pdev; | 1009 | struct platform_device *pdev = p->pdev; |
1008 | struct device *dev = &pdev->dev; | 1010 | struct device *dev = &pdev->dev; |
1009 | const struct sh_msiof_spi_info *info = dev_get_platdata(dev); | 1011 | const struct sh_msiof_spi_info *info = dev_get_platdata(dev); |
1012 | unsigned int dma_tx_id, dma_rx_id; | ||
1010 | const struct resource *res; | 1013 | const struct resource *res; |
1011 | struct spi_master *master; | 1014 | struct spi_master *master; |
1012 | struct device *tx_dev, *rx_dev; | 1015 | struct device *tx_dev, *rx_dev; |
1013 | 1016 | ||
1014 | if (!info || !info->dma_tx_id || !info->dma_rx_id) | 1017 | if (dev->of_node) { |
1015 | return 0; /* The driver assumes no error */ | 1018 | /* In the OF case we will get the slave IDs from the DT */ |
1019 | dma_tx_id = 0; | ||
1020 | dma_rx_id = 0; | ||
1021 | } else if (info && info->dma_tx_id && info->dma_rx_id) { | ||
1022 | dma_tx_id = info->dma_tx_id; | ||
1023 | dma_rx_id = info->dma_rx_id; | ||
1024 | } else { | ||
1025 | /* The driver assumes no error */ | ||
1026 | return 0; | ||
1027 | } | ||
1016 | 1028 | ||
1017 | /* The DMA engine uses the second register set, if present */ | 1029 | /* The DMA engine uses the second register set, if present */ |
1018 | res = platform_get_resource(pdev, IORESOURCE_MEM, 1); | 1030 | res = platform_get_resource(pdev, IORESOURCE_MEM, 1); |
@@ -1021,13 +1033,13 @@ static int sh_msiof_request_dma(struct sh_msiof_spi_priv *p) | |||
1021 | 1033 | ||
1022 | master = p->master; | 1034 | master = p->master; |
1023 | master->dma_tx = sh_msiof_request_dma_chan(dev, DMA_MEM_TO_DEV, | 1035 | master->dma_tx = sh_msiof_request_dma_chan(dev, DMA_MEM_TO_DEV, |
1024 | info->dma_tx_id, | 1036 | dma_tx_id, |
1025 | res->start + TFDR); | 1037 | res->start + TFDR); |
1026 | if (!master->dma_tx) | 1038 | if (!master->dma_tx) |
1027 | return -ENODEV; | 1039 | return -ENODEV; |
1028 | 1040 | ||
1029 | master->dma_rx = sh_msiof_request_dma_chan(dev, DMA_DEV_TO_MEM, | 1041 | master->dma_rx = sh_msiof_request_dma_chan(dev, DMA_DEV_TO_MEM, |
1030 | info->dma_rx_id, | 1042 | dma_rx_id, |
1031 | res->start + RFDR); | 1043 | res->start + RFDR); |
1032 | if (!master->dma_rx) | 1044 | if (!master->dma_rx) |
1033 | goto free_tx_chan; | 1045 | goto free_tx_chan; |
@@ -1210,6 +1222,9 @@ static struct platform_device_id spi_driver_ids[] = { | |||
1210 | { "spi_sh_msiof", (kernel_ulong_t)&sh_data }, | 1222 | { "spi_sh_msiof", (kernel_ulong_t)&sh_data }, |
1211 | { "spi_r8a7790_msiof", (kernel_ulong_t)&r8a779x_data }, | 1223 | { "spi_r8a7790_msiof", (kernel_ulong_t)&r8a779x_data }, |
1212 | { "spi_r8a7791_msiof", (kernel_ulong_t)&r8a779x_data }, | 1224 | { "spi_r8a7791_msiof", (kernel_ulong_t)&r8a779x_data }, |
1225 | { "spi_r8a7792_msiof", (kernel_ulong_t)&r8a779x_data }, | ||
1226 | { "spi_r8a7793_msiof", (kernel_ulong_t)&r8a779x_data }, | ||
1227 | { "spi_r8a7794_msiof", (kernel_ulong_t)&r8a779x_data }, | ||
1213 | {}, | 1228 | {}, |
1214 | }; | 1229 | }; |
1215 | MODULE_DEVICE_TABLE(platform, spi_driver_ids); | 1230 | MODULE_DEVICE_TABLE(platform, spi_driver_ids); |
diff --git a/drivers/spi/spi-sirf.c b/drivers/spi/spi-sirf.c index 6f0602fd7401..39e2c0a55a28 100644 --- a/drivers/spi/spi-sirf.c +++ b/drivers/spi/spi-sirf.c | |||
@@ -62,15 +62,15 @@ | |||
62 | #define SIRFSOC_SPI_TRAN_DAT_FORMAT_12 (1 << 26) | 62 | #define SIRFSOC_SPI_TRAN_DAT_FORMAT_12 (1 << 26) |
63 | #define SIRFSOC_SPI_TRAN_DAT_FORMAT_16 (2 << 26) | 63 | #define SIRFSOC_SPI_TRAN_DAT_FORMAT_16 (2 << 26) |
64 | #define SIRFSOC_SPI_TRAN_DAT_FORMAT_32 (3 << 26) | 64 | #define SIRFSOC_SPI_TRAN_DAT_FORMAT_32 (3 << 26) |
65 | #define SIRFSOC_SPI_CMD_BYTE_NUM(x) ((x & 3) << 28) | 65 | #define SIRFSOC_SPI_CMD_BYTE_NUM(x) ((x & 3) << 28) |
66 | #define SIRFSOC_SPI_ENA_AUTO_CLR BIT(30) | 66 | #define SIRFSOC_SPI_ENA_AUTO_CLR BIT(30) |
67 | #define SIRFSOC_SPI_MUL_DAT_MODE BIT(31) | 67 | #define SIRFSOC_SPI_MUL_DAT_MODE BIT(31) |
68 | 68 | ||
69 | /* Interrupt Enable */ | 69 | /* Interrupt Enable */ |
70 | #define SIRFSOC_SPI_RX_DONE_INT_EN BIT(0) | 70 | #define SIRFSOC_SPI_RX_DONE_INT_EN BIT(0) |
71 | #define SIRFSOC_SPI_TX_DONE_INT_EN BIT(1) | 71 | #define SIRFSOC_SPI_TX_DONE_INT_EN BIT(1) |
72 | #define SIRFSOC_SPI_RX_OFLOW_INT_EN BIT(2) | 72 | #define SIRFSOC_SPI_RX_OFLOW_INT_EN BIT(2) |
73 | #define SIRFSOC_SPI_TX_UFLOW_INT_EN BIT(3) | 73 | #define SIRFSOC_SPI_TX_UFLOW_INT_EN BIT(3) |
74 | #define SIRFSOC_SPI_RX_IO_DMA_INT_EN BIT(4) | 74 | #define SIRFSOC_SPI_RX_IO_DMA_INT_EN BIT(4) |
75 | #define SIRFSOC_SPI_TX_IO_DMA_INT_EN BIT(5) | 75 | #define SIRFSOC_SPI_TX_IO_DMA_INT_EN BIT(5) |
76 | #define SIRFSOC_SPI_RXFIFO_FULL_INT_EN BIT(6) | 76 | #define SIRFSOC_SPI_RXFIFO_FULL_INT_EN BIT(6) |
@@ -79,7 +79,7 @@ | |||
79 | #define SIRFSOC_SPI_TXFIFO_THD_INT_EN BIT(9) | 79 | #define SIRFSOC_SPI_TXFIFO_THD_INT_EN BIT(9) |
80 | #define SIRFSOC_SPI_FRM_END_INT_EN BIT(10) | 80 | #define SIRFSOC_SPI_FRM_END_INT_EN BIT(10) |
81 | 81 | ||
82 | #define SIRFSOC_SPI_INT_MASK_ALL 0x1FFF | 82 | #define SIRFSOC_SPI_INT_MASK_ALL 0x1FFF |
83 | 83 | ||
84 | /* Interrupt status */ | 84 | /* Interrupt status */ |
85 | #define SIRFSOC_SPI_RX_DONE BIT(0) | 85 | #define SIRFSOC_SPI_RX_DONE BIT(0) |
@@ -170,8 +170,7 @@ struct sirfsoc_spi { | |||
170 | * command model | 170 | * command model |
171 | */ | 171 | */ |
172 | bool tx_by_cmd; | 172 | bool tx_by_cmd; |
173 | 173 | bool hw_cs; | |
174 | int chipselect[0]; | ||
175 | }; | 174 | }; |
176 | 175 | ||
177 | static void spi_sirfsoc_rx_word_u8(struct sirfsoc_spi *sspi) | 176 | static void spi_sirfsoc_rx_word_u8(struct sirfsoc_spi *sspi) |
@@ -304,7 +303,7 @@ static void spi_sirfsoc_dma_fini_callback(void *data) | |||
304 | complete(dma_complete); | 303 | complete(dma_complete); |
305 | } | 304 | } |
306 | 305 | ||
307 | static int spi_sirfsoc_cmd_transfer(struct spi_device *spi, | 306 | static void spi_sirfsoc_cmd_transfer(struct spi_device *spi, |
308 | struct spi_transfer *t) | 307 | struct spi_transfer *t) |
309 | { | 308 | { |
310 | struct sirfsoc_spi *sspi; | 309 | struct sirfsoc_spi *sspi; |
@@ -328,10 +327,9 @@ static int spi_sirfsoc_cmd_transfer(struct spi_device *spi, | |||
328 | sspi->base + SIRFSOC_SPI_TX_RX_EN); | 327 | sspi->base + SIRFSOC_SPI_TX_RX_EN); |
329 | if (wait_for_completion_timeout(&sspi->tx_done, timeout) == 0) { | 328 | if (wait_for_completion_timeout(&sspi->tx_done, timeout) == 0) { |
330 | dev_err(&spi->dev, "cmd transfer timeout\n"); | 329 | dev_err(&spi->dev, "cmd transfer timeout\n"); |
331 | return 0; | 330 | return; |
332 | } | 331 | } |
333 | 332 | sspi->left_rx_word -= t->len; | |
334 | return t->len; | ||
335 | } | 333 | } |
336 | 334 | ||
337 | static void spi_sirfsoc_dma_transfer(struct spi_device *spi, | 335 | static void spi_sirfsoc_dma_transfer(struct spi_device *spi, |
@@ -487,7 +485,7 @@ static void spi_sirfsoc_chipselect(struct spi_device *spi, int value) | |||
487 | { | 485 | { |
488 | struct sirfsoc_spi *sspi = spi_master_get_devdata(spi->master); | 486 | struct sirfsoc_spi *sspi = spi_master_get_devdata(spi->master); |
489 | 487 | ||
490 | if (sspi->chipselect[spi->chip_select] == 0) { | 488 | if (sspi->hw_cs) { |
491 | u32 regval = readl(sspi->base + SIRFSOC_SPI_CTRL); | 489 | u32 regval = readl(sspi->base + SIRFSOC_SPI_CTRL); |
492 | switch (value) { | 490 | switch (value) { |
493 | case BITBANG_CS_ACTIVE: | 491 | case BITBANG_CS_ACTIVE: |
@@ -505,14 +503,13 @@ static void spi_sirfsoc_chipselect(struct spi_device *spi, int value) | |||
505 | } | 503 | } |
506 | writel(regval, sspi->base + SIRFSOC_SPI_CTRL); | 504 | writel(regval, sspi->base + SIRFSOC_SPI_CTRL); |
507 | } else { | 505 | } else { |
508 | int gpio = sspi->chipselect[spi->chip_select]; | ||
509 | switch (value) { | 506 | switch (value) { |
510 | case BITBANG_CS_ACTIVE: | 507 | case BITBANG_CS_ACTIVE: |
511 | gpio_direction_output(gpio, | 508 | gpio_direction_output(spi->cs_gpio, |
512 | spi->mode & SPI_CS_HIGH ? 1 : 0); | 509 | spi->mode & SPI_CS_HIGH ? 1 : 0); |
513 | break; | 510 | break; |
514 | case BITBANG_CS_INACTIVE: | 511 | case BITBANG_CS_INACTIVE: |
515 | gpio_direction_output(gpio, | 512 | gpio_direction_output(spi->cs_gpio, |
516 | spi->mode & SPI_CS_HIGH ? 0 : 1); | 513 | spi->mode & SPI_CS_HIGH ? 0 : 1); |
517 | break; | 514 | break; |
518 | } | 515 | } |
@@ -606,8 +603,8 @@ spi_sirfsoc_setup_transfer(struct spi_device *spi, struct spi_transfer *t) | |||
606 | sspi->tx_by_cmd = false; | 603 | sspi->tx_by_cmd = false; |
607 | } | 604 | } |
608 | /* | 605 | /* |
609 | * set spi controller in RISC chipselect mode, we are controlling CS by | 606 | * it should never set to hardware cs mode because in hardware cs mode, |
610 | * software BITBANG_CS_ACTIVE and BITBANG_CS_INACTIVE. | 607 | * cs signal can't controlled by driver. |
611 | */ | 608 | */ |
612 | regval |= SIRFSOC_SPI_CS_IO_MODE; | 609 | regval |= SIRFSOC_SPI_CS_IO_MODE; |
613 | writel(regval, sspi->base + SIRFSOC_SPI_CTRL); | 610 | writel(regval, sspi->base + SIRFSOC_SPI_CTRL); |
@@ -630,9 +627,17 @@ spi_sirfsoc_setup_transfer(struct spi_device *spi, struct spi_transfer *t) | |||
630 | 627 | ||
631 | static int spi_sirfsoc_setup(struct spi_device *spi) | 628 | static int spi_sirfsoc_setup(struct spi_device *spi) |
632 | { | 629 | { |
630 | struct sirfsoc_spi *sspi; | ||
631 | |||
633 | if (!spi->max_speed_hz) | 632 | if (!spi->max_speed_hz) |
634 | return -EINVAL; | 633 | return -EINVAL; |
635 | 634 | ||
635 | sspi = spi_master_get_devdata(spi->master); | ||
636 | |||
637 | if (spi->cs_gpio == -ENOENT) | ||
638 | sspi->hw_cs = true; | ||
639 | else | ||
640 | sspi->hw_cs = false; | ||
636 | return spi_sirfsoc_setup_transfer(spi, NULL); | 641 | return spi_sirfsoc_setup_transfer(spi, NULL); |
637 | } | 642 | } |
638 | 643 | ||
@@ -641,19 +646,10 @@ static int spi_sirfsoc_probe(struct platform_device *pdev) | |||
641 | struct sirfsoc_spi *sspi; | 646 | struct sirfsoc_spi *sspi; |
642 | struct spi_master *master; | 647 | struct spi_master *master; |
643 | struct resource *mem_res; | 648 | struct resource *mem_res; |
644 | int num_cs, cs_gpio, irq; | 649 | int irq; |
645 | int i; | 650 | int i, ret; |
646 | int ret; | ||
647 | |||
648 | ret = of_property_read_u32(pdev->dev.of_node, | ||
649 | "sirf,spi-num-chipselects", &num_cs); | ||
650 | if (ret < 0) { | ||
651 | dev_err(&pdev->dev, "Unable to get chip select number\n"); | ||
652 | goto err_cs; | ||
653 | } | ||
654 | 651 | ||
655 | master = spi_alloc_master(&pdev->dev, | 652 | master = spi_alloc_master(&pdev->dev, sizeof(*sspi)); |
656 | sizeof(*sspi) + sizeof(int) * num_cs); | ||
657 | if (!master) { | 653 | if (!master) { |
658 | dev_err(&pdev->dev, "Unable to allocate SPI master\n"); | 654 | dev_err(&pdev->dev, "Unable to allocate SPI master\n"); |
659 | return -ENOMEM; | 655 | return -ENOMEM; |
@@ -661,32 +657,6 @@ static int spi_sirfsoc_probe(struct platform_device *pdev) | |||
661 | platform_set_drvdata(pdev, master); | 657 | platform_set_drvdata(pdev, master); |
662 | sspi = spi_master_get_devdata(master); | 658 | sspi = spi_master_get_devdata(master); |
663 | 659 | ||
664 | master->num_chipselect = num_cs; | ||
665 | |||
666 | for (i = 0; i < master->num_chipselect; i++) { | ||
667 | cs_gpio = of_get_named_gpio(pdev->dev.of_node, "cs-gpios", i); | ||
668 | if (cs_gpio < 0) { | ||
669 | dev_err(&pdev->dev, "can't get cs gpio from DT\n"); | ||
670 | ret = -ENODEV; | ||
671 | goto free_master; | ||
672 | } | ||
673 | |||
674 | sspi->chipselect[i] = cs_gpio; | ||
675 | if (cs_gpio == 0) | ||
676 | continue; /* use cs from spi controller */ | ||
677 | |||
678 | ret = gpio_request(cs_gpio, DRIVER_NAME); | ||
679 | if (ret) { | ||
680 | while (i > 0) { | ||
681 | i--; | ||
682 | if (sspi->chipselect[i] > 0) | ||
683 | gpio_free(sspi->chipselect[i]); | ||
684 | } | ||
685 | dev_err(&pdev->dev, "fail to request cs gpios\n"); | ||
686 | goto free_master; | ||
687 | } | ||
688 | } | ||
689 | |||
690 | mem_res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 660 | mem_res = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
691 | sspi->base = devm_ioremap_resource(&pdev->dev, mem_res); | 661 | sspi->base = devm_ioremap_resource(&pdev->dev, mem_res); |
692 | if (IS_ERR(sspi->base)) { | 662 | if (IS_ERR(sspi->base)) { |
@@ -756,7 +726,21 @@ static int spi_sirfsoc_probe(struct platform_device *pdev) | |||
756 | ret = spi_bitbang_start(&sspi->bitbang); | 726 | ret = spi_bitbang_start(&sspi->bitbang); |
757 | if (ret) | 727 | if (ret) |
758 | goto free_dummypage; | 728 | goto free_dummypage; |
759 | 729 | for (i = 0; master->cs_gpios && i < master->num_chipselect; i++) { | |
730 | if (master->cs_gpios[i] == -ENOENT) | ||
731 | continue; | ||
732 | if (!gpio_is_valid(master->cs_gpios[i])) { | ||
733 | dev_err(&pdev->dev, "no valid gpio\n"); | ||
734 | ret = -EINVAL; | ||
735 | goto free_dummypage; | ||
736 | } | ||
737 | ret = devm_gpio_request(&pdev->dev, | ||
738 | master->cs_gpios[i], DRIVER_NAME); | ||
739 | if (ret) { | ||
740 | dev_err(&pdev->dev, "failed to request gpio\n"); | ||
741 | goto free_dummypage; | ||
742 | } | ||
743 | } | ||
760 | dev_info(&pdev->dev, "registerred, bus number = %d\n", master->bus_num); | 744 | dev_info(&pdev->dev, "registerred, bus number = %d\n", master->bus_num); |
761 | 745 | ||
762 | return 0; | 746 | return 0; |
@@ -771,7 +755,7 @@ free_rx_dma: | |||
771 | dma_release_channel(sspi->rx_chan); | 755 | dma_release_channel(sspi->rx_chan); |
772 | free_master: | 756 | free_master: |
773 | spi_master_put(master); | 757 | spi_master_put(master); |
774 | err_cs: | 758 | |
775 | return ret; | 759 | return ret; |
776 | } | 760 | } |
777 | 761 | ||
@@ -779,16 +763,11 @@ static int spi_sirfsoc_remove(struct platform_device *pdev) | |||
779 | { | 763 | { |
780 | struct spi_master *master; | 764 | struct spi_master *master; |
781 | struct sirfsoc_spi *sspi; | 765 | struct sirfsoc_spi *sspi; |
782 | int i; | ||
783 | 766 | ||
784 | master = platform_get_drvdata(pdev); | 767 | master = platform_get_drvdata(pdev); |
785 | sspi = spi_master_get_devdata(master); | 768 | sspi = spi_master_get_devdata(master); |
786 | 769 | ||
787 | spi_bitbang_stop(&sspi->bitbang); | 770 | spi_bitbang_stop(&sspi->bitbang); |
788 | for (i = 0; i < master->num_chipselect; i++) { | ||
789 | if (sspi->chipselect[i] > 0) | ||
790 | gpio_free(sspi->chipselect[i]); | ||
791 | } | ||
792 | kfree(sspi->dummypage); | 771 | kfree(sspi->dummypage); |
793 | clk_disable_unprepare(sspi->clk); | 772 | clk_disable_unprepare(sspi->clk); |
794 | clk_put(sspi->clk); | 773 | clk_put(sspi->clk); |
diff --git a/include/linux/amba/bus.h b/include/linux/amba/bus.h index fdd7e1b61f60..c324f5700d1a 100644 --- a/include/linux/amba/bus.h +++ b/include/linux/amba/bus.h | |||
@@ -44,10 +44,15 @@ struct amba_driver { | |||
44 | const struct amba_id *id_table; | 44 | const struct amba_id *id_table; |
45 | }; | 45 | }; |
46 | 46 | ||
47 | /* | ||
48 | * Constants for the designer field of the Peripheral ID register. When bit 7 | ||
49 | * is set to '1', bits [6:0] should be the JEP106 manufacturer identity code. | ||
50 | */ | ||
47 | enum amba_vendor { | 51 | enum amba_vendor { |
48 | AMBA_VENDOR_ARM = 0x41, | 52 | AMBA_VENDOR_ARM = 0x41, |
49 | AMBA_VENDOR_ST = 0x80, | 53 | AMBA_VENDOR_ST = 0x80, |
50 | AMBA_VENDOR_QCOM = 0x51, | 54 | AMBA_VENDOR_QCOM = 0x51, |
55 | AMBA_VENDOR_LSI = 0xb6, | ||
51 | }; | 56 | }; |
52 | 57 | ||
53 | extern struct bus_type amba_bustype; | 58 | extern struct bus_type amba_bustype; |