Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge tag 'spi-v5.5' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi

Pull spi updates from Mark Brown:
"Lots of stuff going on in the core for SPI this time around, the two
big changes both being around time in different forms:

- A rework of delay times from Alexandru Ardelean which makes the
ways in which they are specified more consistent between drivers so
that what's available to clients is less dependent on the hardware
implementation.

- Support for PTP timestamping of transfers from Vladimir Oltean,
useful for use with precision clocks with SPI control interfaces.

- Big cleanups for the Atmel, PXA2xx and Zynq QSPI drivers"

* tag 'spi-v5.5' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi: (119 commits)
dt-bindings: spi: Convert stm32 QSPI bindings to json-schema
spi: pic32: Retire dma_request_slave_channel_compat()
spi: Fix Kconfig indentation
spi: mediatek: add SPI_CS_HIGH support
spi: st-ssc4: add missed pm_runtime_disable
spi: tegra20-slink: add missed clk_unprepare
spi: tegra20-slink: Use dma_request_chan() directly for channel request
spi: tegra114: Use dma_request_chan() directly for channel request
spi: s3c64xx: Use dma_request_chan() directly for channel request
spi: qup: Use dma_request_chan() directly for channel request
spi: pl022: Use dma_request_chan() directly for channel request
spi: imx: Use dma_request_chan() directly for channel request
spi: fsl-lpspi: Use dma_request_chan() directly for channel request
spi: atmel: Use dma_request_chan() directly for channel request
spi: at91-usart: Use dma_request_chan() directly for channel request
spi: fsl-cpm: Correct the free:ing
spi: Fix regression to return zero on success instead of positive value
spi: pxa2xx: Add missed security checks
spi: nxp-fspi: Use devm API to fix missed unregistration of controller
spi: omap2-mcspi: Remove redundant checks
...

+1323 -762
+57
Documentation/devicetree/bindings/spi/renesas,hspi.yaml
··· 1 + # SPDX-License-Identifier: GPL-2.0 2 + %YAML 1.2 3 + --- 4 + $id: http://devicetree.org/schemas/spi/renesas,hspi.yaml# 5 + $schema: http://devicetree.org/meta-schemas/core.yaml# 6 + 7 + title: Renesas HSPI 8 + 9 + maintainers: 10 + - Geert Uytterhoeven <geert+renesas@glider.be> 11 + 12 + allOf: 13 + - $ref: spi-controller.yaml# 14 + 15 + properties: 16 + compatible: 17 + items: 18 + - enum: 19 + - renesas,hspi-r8a7778 # R-Car M1A 20 + - renesas,hspi-r8a7779 # R-Car H1 21 + - const: renesas,hspi 22 + 23 + reg: 24 + maxItems: 1 25 + 26 + interrupts: 27 + maxItems: 1 28 + 29 + clocks: 30 + maxItems: 1 31 + 32 + power-domains: 33 + maxItems: 1 34 + 35 + required: 36 + - compatible 37 + - reg 38 + - interrupts 39 + - clocks 40 + - '#address-cells' 41 + - '#size-cells' 42 + 43 + examples: 44 + - | 45 + #include <dt-bindings/clock/r8a7778-clock.h> 46 + #include <dt-bindings/interrupt-controller/irq.h> 47 + 48 + hspi0: spi@fffc7000 { 49 + compatible = "renesas,hspi-r8a7778", "renesas,hspi"; 50 + reg = <0xfffc7000 0x18>; 51 + interrupts = <0 63 IRQ_TYPE_LEVEL_HIGH>; 52 + clocks = <&mstp0_clks R8A7778_CLK_HSPI>; 53 + power-domains = <&cpg_clocks>; 54 + #address-cells = <1>; 55 + #size-cells = <0>; 56 + }; 57 +
+11
Documentation/devicetree/bindings/spi/renesas,rzn1-spi.txt
··· 1 + Renesas RZ/N1 SPI Controller 2 + 3 + This controller is based on the Synopsys DW Synchronous Serial Interface and 4 + inherits all properties defined in snps,dw-apb-ssi.txt except for the 5 + compatible property. 6 + 7 + Required properties: 8 + - compatible : The device specific string followed by the generic RZ/N1 string. 9 + Therefore it must be one of: 10 + "renesas,r9a06g032-spi", "renesas,rzn1-spi" 11 + "renesas,r9a06g033-spi", "renesas,rzn1-spi"
+159
Documentation/devicetree/bindings/spi/renesas,sh-msiof.yaml
··· 1 + # SPDX-License-Identifier: GPL-2.0 2 + %YAML 1.2 3 + --- 4 + $id: http://devicetree.org/schemas/spi/renesas,sh-msiof.yaml# 5 + $schema: http://devicetree.org/meta-schemas/core.yaml# 6 + 7 + title: Renesas MSIOF SPI controller 8 + 9 + maintainers: 10 + - Geert Uytterhoeven <geert+renesas@glider.be> 11 + 12 + allOf: 13 + - $ref: spi-controller.yaml# 14 + 15 + properties: 16 + compatible: 17 + oneOf: 18 + - items: 19 + - const: renesas,msiof-sh73a0 # SH-Mobile AG5 20 + - const: renesas,sh-mobile-msiof # generic SH-Mobile compatible 21 + # device 22 + - items: 23 + - enum: 24 + - renesas,msiof-r8a7743 # RZ/G1M 25 + - renesas,msiof-r8a7744 # RZ/G1N 26 + - renesas,msiof-r8a7745 # RZ/G1E 27 + - renesas,msiof-r8a77470 # RZ/G1C 28 + - renesas,msiof-r8a7790 # R-Car H2 29 + - renesas,msiof-r8a7791 # R-Car M2-W 30 + - renesas,msiof-r8a7792 # R-Car V2H 31 + - renesas,msiof-r8a7793 # R-Car M2-N 32 + - renesas,msiof-r8a7794 # R-Car E2 33 + - const: renesas,rcar-gen2-msiof # generic R-Car Gen2 and RZ/G1 34 + # compatible device 35 + - items: 36 + - enum: 37 + - renesas,msiof-r8a774a1 # RZ/G2M 38 + - renesas,msiof-r8a774b1 # RZ/G2N 39 + - renesas,msiof-r8a774c0 # RZ/G2E 40 + - renesas,msiof-r8a7795 # R-Car H3 41 + - renesas,msiof-r8a7796 # R-Car M3-W 42 + - renesas,msiof-r8a77965 # R-Car M3-N 43 + - renesas,msiof-r8a77970 # R-Car V3M 44 + - renesas,msiof-r8a77980 # R-Car V3H 45 + - renesas,msiof-r8a77990 # R-Car E3 46 + - renesas,msiof-r8a77995 # R-Car D3 47 + - const: renesas,rcar-gen3-msiof # generic R-Car Gen3 and RZ/G2 48 + # compatible device 49 + - items: 50 + - const: renesas,sh-msiof # deprecated 51 + 52 + reg: 53 + minItems: 1 54 + maxItems: 2 55 + oneOf: 56 + - items: 57 + - description: CPU and DMA engine registers 58 + - items: 59 + - description: CPU registers 60 + - description: DMA engine registers 61 + 62 + interrupts: 63 + maxItems: 1 64 + 65 + clocks: 66 + maxItems: 1 67 + 68 + num-cs: 69 + description: | 70 + Total number of chip selects (default is 1). 71 + Up to 3 native chip selects are supported: 72 + 0: MSIOF_SYNC 73 + 1: MSIOF_SS1 74 + 2: MSIOF_SS2 75 + Hardware limitations related to chip selects: 76 + - Native chip selects are always deasserted in between transfers 77 + that are part of the same message. Use cs-gpios to work around 78 + this. 79 + - All slaves using native chip selects must use the same spi-cs-high 80 + configuration. Use cs-gpios to work around this. 81 + - When using GPIO chip selects, at least one native chip select must 82 + be left unused, as it will be driven anyway. 83 + minimum: 1 84 + maximum: 3 85 + default: 1 86 + 87 + dmas: 88 + minItems: 2 89 + maxItems: 4 90 + 91 + dma-names: 92 + minItems: 2 93 + maxItems: 4 94 + items: 95 + enum: [ tx, rx ] 96 + 97 + renesas,dtdl: 98 + description: delay sync signal (setup) in transmit mode. 99 + allOf: 100 + - $ref: /schemas/types.yaml#/definitions/uint32 101 + - enum: 102 + - 0 # no bit delay 103 + - 50 # 0.5-clock-cycle delay 104 + - 100 # 1-clock-cycle delay 105 + - 150 # 1.5-clock-cycle delay 106 + - 200 # 2-clock-cycle delay 107 + 108 + renesas,syncdl: 109 + description: delay sync signal (hold) in transmit mode 110 + allOf: 111 + - $ref: /schemas/types.yaml#/definitions/uint32 112 + - enum: 113 + - 0 # no bit delay 114 + - 50 # 0.5-clock-cycle delay 115 + - 100 # 1-clock-cycle delay 116 + - 150 # 1.5-clock-cycle delay 117 + - 200 # 2-clock-cycle delay 118 + - 300 # 3-clock-cycle delay 119 + 120 + renesas,tx-fifo-size: 121 + # deprecated for soctype-specific bindings 122 + description: | 123 + Override the default TX fifo size. Unit is words. Ignored if 0. 124 + allOf: 125 + - $ref: /schemas/types.yaml#/definitions/uint32 126 + - maxItems: 1 127 + default: 64 128 + 129 + renesas,rx-fifo-size: 130 + # deprecated for soctype-specific bindings 131 + description: | 132 + Override the default RX fifo size. Unit is words. Ignored if 0. 133 + allOf: 134 + - $ref: /schemas/types.yaml#/definitions/uint32 135 + - maxItems: 1 136 + default: 64 137 + 138 + required: 139 + - compatible 140 + - reg 141 + - interrupts 142 + - '#address-cells' 143 + - '#size-cells' 144 + 145 + examples: 146 + - | 147 + #include <dt-bindings/clock/r8a7791-clock.h> 148 + #include <dt-bindings/interrupt-controller/irq.h> 149 + 150 + msiof0: spi@e6e20000 { 151 + compatible = "renesas,msiof-r8a7791", "renesas,rcar-gen2-msiof"; 152 + reg = <0 0xe6e20000 0 0x0064>; 153 + interrupts = <0 156 IRQ_TYPE_LEVEL_HIGH>; 154 + clocks = <&mstp0_clks R8A7791_CLK_MSIOF0>; 155 + dmas = <&dmac0 0x51>, <&dmac0 0x52>; 156 + dma-names = "tx", "rx"; 157 + #address-cells = <1>; 158 + #size-cells = <0>; 159 + };
-26
Documentation/devicetree/bindings/spi/sh-hspi.txt
··· 1 - Renesas HSPI. 2 - 3 - Required properties: 4 - - compatible : "renesas,hspi-<soctype>", "renesas,hspi" as fallback. 5 - Examples with soctypes are: 6 - - "renesas,hspi-r8a7778" (R-Car M1) 7 - - "renesas,hspi-r8a7779" (R-Car H1) 8 - - reg : Offset and length of the register set for the device 9 - - interrupts : Interrupt specifier 10 - - #address-cells : Must be <1> 11 - - #size-cells : Must be <0> 12 - 13 - Pinctrl properties might be needed, too. See 14 - Documentation/devicetree/bindings/pinctrl/renesas,*. 15 - 16 - Example: 17 - 18 - hspi0: spi@fffc7000 { 19 - compatible = "renesas,hspi-r8a7778", "renesas,hspi"; 20 - reg = <0xfffc7000 0x18>; 21 - interrupt-parent = <&gic>; 22 - interrupts = <0 63 IRQ_TYPE_LEVEL_HIGH>; 23 - #address-cells = <1>; 24 - #size-cells = <0>; 25 - }; 26 -
-105
Documentation/devicetree/bindings/spi/sh-msiof.txt
··· 1 - Renesas MSIOF spi controller 2 - 3 - Required properties: 4 - - compatible : "renesas,msiof-r8a7743" (RZ/G1M) 5 - "renesas,msiof-r8a7744" (RZ/G1N) 6 - "renesas,msiof-r8a7745" (RZ/G1E) 7 - "renesas,msiof-r8a77470" (RZ/G1C) 8 - "renesas,msiof-r8a774a1" (RZ/G2M) 9 - "renesas,msiof-r8a774c0" (RZ/G2E) 10 - "renesas,msiof-r8a7790" (R-Car H2) 11 - "renesas,msiof-r8a7791" (R-Car M2-W) 12 - "renesas,msiof-r8a7792" (R-Car V2H) 13 - "renesas,msiof-r8a7793" (R-Car M2-N) 14 - "renesas,msiof-r8a7794" (R-Car E2) 15 - "renesas,msiof-r8a7795" (R-Car H3) 16 - "renesas,msiof-r8a7796" (R-Car M3-W) 17 - "renesas,msiof-r8a77965" (R-Car M3-N) 18 - "renesas,msiof-r8a77970" (R-Car V3M) 19 - "renesas,msiof-r8a77980" (R-Car V3H) 20 - "renesas,msiof-r8a77990" (R-Car E3) 21 - "renesas,msiof-r8a77995" (R-Car D3) 22 - "renesas,msiof-sh73a0" (SH-Mobile AG5) 23 - "renesas,sh-mobile-msiof" (generic SH-Mobile compatibile device) 24 - "renesas,rcar-gen2-msiof" (generic R-Car Gen2 and RZ/G1 compatible device) 25 - "renesas,rcar-gen3-msiof" (generic R-Car Gen3 and RZ/G2 compatible device) 26 - "renesas,sh-msiof" (deprecated) 27 - 28 - When compatible with the generic version, nodes 29 - must list the SoC-specific version corresponding 30 - to the platform first followed by the generic 31 - version. 32 - 33 - - reg : A list of offsets and lengths of the register sets for 34 - the device. 35 - If only one register set is present, it is to be used 36 - by both the CPU and the DMA engine. 37 - If two register sets are present, the first is to be 38 - used by the CPU, and the second is to be used by the 39 - DMA engine. 40 - - interrupts : Interrupt specifier 41 - - #address-cells : Must be <1> 42 - - #size-cells : Must be <0> 43 - 44 - Optional properties: 45 - - clocks : Must contain a reference to the functional clock. 46 - - num-cs : Total number of chip selects (default is 1). 47 - Up to 3 native chip selects are supported: 48 - 0: MSIOF_SYNC 49 - 1: MSIOF_SS1 50 - 2: MSIOF_SS2 51 - Hardware limitations related to chip selects: 52 - - Native chip selects are always deasserted in 53 - between transfers that are part of the same 54 - message. Use cs-gpios to work around this. 55 - - All slaves using native chip selects must use the 56 - same spi-cs-high configuration. Use cs-gpios to 57 - work around this. 58 - - When using GPIO chip selects, at least one native 59 - chip select must be left unused, as it will be 60 - driven anyway. 61 - - dmas : Must contain a list of two references to DMA 62 - specifiers, one for transmission, and one for 63 - reception. 64 - - dma-names : Must contain a list of two DMA names, "tx" and "rx". 65 - - spi-slave : Empty property indicating the SPI controller is used 66 - in slave mode. 67 - - renesas,dtdl : delay sync signal (setup) in transmit mode. 68 - Must contain one of the following values: 69 - 0 (no bit delay) 70 - 50 (0.5-clock-cycle delay) 71 - 100 (1-clock-cycle delay) 72 - 150 (1.5-clock-cycle delay) 73 - 200 (2-clock-cycle delay) 74 - 75 - - renesas,syncdl : delay sync signal (hold) in transmit mode. 76 - Must contain one of the following values: 77 - 0 (no bit delay) 78 - 50 (0.5-clock-cycle delay) 79 - 100 (1-clock-cycle delay) 80 - 150 (1.5-clock-cycle delay) 81 - 200 (2-clock-cycle delay) 82 - 300 (3-clock-cycle delay) 83 - 84 - Optional properties, deprecated for soctype-specific bindings: 85 - - renesas,tx-fifo-size : Overrides the default tx fifo size given in words 86 - (default is 64) 87 - - renesas,rx-fifo-size : Overrides the default rx fifo size given in words 88 - (default is 64) 89 - 90 - Pinctrl properties might be needed, too. See 91 - Documentation/devicetree/bindings/pinctrl/renesas,*. 92 - 93 - Example: 94 - 95 - msiof0: spi@e6e20000 { 96 - compatible = "renesas,msiof-r8a7791", 97 - "renesas,rcar-gen2-msiof"; 98 - reg = <0 0xe6e20000 0 0x0064>; 99 - interrupts = <0 156 IRQ_TYPE_LEVEL_HIGH>; 100 - clocks = <&mstp0_clks R8A7791_CLK_MSIOF0>; 101 - dmas = <&dmac0 0x51>, <&dmac0 0x52>; 102 - dma-names = "tx", "rx"; 103 - #address-cells = <1>; 104 - #size-cells = <0>; 105 - };
+2 -1
Documentation/devicetree/bindings/spi/snps,dw-apb-ssi.txt
··· 16 16 Optional properties: 17 17 - clock-names : Contains the names of the clocks: 18 18 "ssi_clk", for the core clock used to generate the external SPI clock. 19 - "pclk", the interface clock, required for register access. 19 + "pclk", the interface clock, required for register access. If a clock domain 20 + used to enable this clock then it should be named "pclk_clkdomain". 20 21 - cs-gpios : Specifies the gpio pins to be used for chipselects. 21 22 - num-cs : The number of chipselects. If omitted, this will default to 4. 22 23 - reg-io-width : The I/O register width (in bytes) implemented by this
-37
Documentation/devicetree/bindings/spi/spi-sifive.txt
··· 1 - SiFive SPI controller Device Tree Bindings 2 - ------------------------------------------ 3 - 4 - Required properties: 5 - - compatible : Should be "sifive,<chip>-spi" and "sifive,spi<version>". 6 - Supported compatible strings are: 7 - "sifive,fu540-c000-spi" for the SiFive SPI v0 as integrated 8 - onto the SiFive FU540 chip, and "sifive,spi0" for the SiFive 9 - SPI v0 IP block with no chip integration tweaks. 10 - Please refer to sifive-blocks-ip-versioning.txt for details 11 - - reg : Physical base address and size of SPI registers map 12 - A second (optional) range can indicate memory mapped flash 13 - - interrupts : Must contain one entry 14 - - interrupt-parent : Must be core interrupt controller 15 - - clocks : Must reference the frequency given to the controller 16 - - #address-cells : Must be '1', indicating which CS to use 17 - - #size-cells : Must be '0' 18 - 19 - Optional properties: 20 - - sifive,fifo-depth : Depth of hardware queues; defaults to 8 21 - - sifive,max-bits-per-word : Maximum bits per word; defaults to 8 22 - 23 - SPI RTL that corresponds to the IP block version numbers can be found here: 24 - https://github.com/sifive/sifive-blocks/tree/master/src/main/scala/devices/spi 25 - 26 - Example: 27 - spi: spi@10040000 { 28 - compatible = "sifive,fu540-c000-spi", "sifive,spi0"; 29 - reg = <0x0 0x10040000 0x0 0x1000 0x0 0x20000000 0x0 0x10000000>; 30 - interrupt-parent = <&plic>; 31 - interrupts = <51>; 32 - clocks = <&tlclk>; 33 - #address-cells = <1>; 34 - #size-cells = <0>; 35 - sifive,fifo-depth = <8>; 36 - sifive,max-bits-per-word = <8>; 37 - };
+86
Documentation/devicetree/bindings/spi/spi-sifive.yaml
··· 1 + # SPDX-License-Identifier: GPL-2.0 2 + %YAML 1.2 3 + --- 4 + $id: http://devicetree.org/schemas/spi/spi-sifive.yaml# 5 + $schema: http://devicetree.org/meta-schemas/core.yaml# 6 + 7 + title: SiFive SPI controller 8 + 9 + maintainers: 10 + - Pragnesh Patel <pragnesh.patel@sifive.com> 11 + - Paul Walmsley <paul.walmsley@sifive.com> 12 + - Palmer Dabbelt <palmer@sifive.com> 13 + 14 + allOf: 15 + - $ref: "spi-controller.yaml#" 16 + 17 + properties: 18 + compatible: 19 + items: 20 + - const: sifive,fu540-c000-spi 21 + - const: sifive,spi0 22 + 23 + description: 24 + Should be "sifive,<chip>-spi" and "sifive,spi<version>". 25 + Supported compatible strings are - 26 + "sifive,fu540-c000-spi" for the SiFive SPI v0 as integrated 27 + onto the SiFive FU540 chip, and "sifive,spi0" for the SiFive 28 + SPI v0 IP block with no chip integration tweaks. 29 + Please refer to sifive-blocks-ip-versioning.txt for details 30 + 31 + SPI RTL that corresponds to the IP block version numbers can be found here - 32 + https://github.com/sifive/sifive-blocks/tree/master/src/main/scala/devices/spi 33 + 34 + reg: 35 + maxItems: 1 36 + 37 + description: 38 + Physical base address and size of SPI registers map 39 + A second (optional) range can indicate memory mapped flash 40 + 41 + interrupts: 42 + maxItems: 1 43 + 44 + clocks: 45 + maxItems: 1 46 + 47 + description: 48 + Must reference the frequency given to the controller 49 + 50 + sifive,fifo-depth: 51 + description: 52 + Depth of hardware queues; defaults to 8 53 + allOf: 54 + - $ref: "/schemas/types.yaml#/definitions/uint32" 55 + - enum: [ 8 ] 56 + - default: 8 57 + 58 + sifive,max-bits-per-word: 59 + description: 60 + Maximum bits per word; defaults to 8 61 + allOf: 62 + - $ref: "/schemas/types.yaml#/definitions/uint32" 63 + - enum: [ 0, 1, 2, 3, 4, 5, 6, 7, 8 ] 64 + - default: 8 65 + 66 + required: 67 + - compatible 68 + - reg 69 + - interrupts 70 + - clocks 71 + 72 + examples: 73 + - | 74 + spi: spi@10040000 { 75 + compatible = "sifive,fu540-c000-spi", "sifive,spi0"; 76 + reg = <0x0 0x10040000 0x0 0x1000 0x0 0x20000000 0x0 0x10000000>; 77 + interrupt-parent = <&plic>; 78 + interrupts = <51>; 79 + clocks = <&tlclk>; 80 + #address-cells = <1>; 81 + #size-cells = <0>; 82 + sifive,fifo-depth = <8>; 83 + sifive,max-bits-per-word = <8>; 84 + }; 85 + 86 + ...
-47
Documentation/devicetree/bindings/spi/spi-stm32-qspi.txt
··· 1 - * STMicroelectronics Quad Serial Peripheral Interface(QSPI) 2 - 3 - Required properties: 4 - - compatible: should be "st,stm32f469-qspi" 5 - - reg: the first contains the register location and length. 6 - the second contains the memory mapping address and length 7 - - reg-names: should contain the reg names "qspi" "qspi_mm" 8 - - interrupts: should contain the interrupt for the device 9 - - clocks: the phandle of the clock needed by the QSPI controller 10 - - A pinctrl must be defined to set pins in mode of operation for QSPI transfer 11 - 12 - Optional properties: 13 - - resets: must contain the phandle to the reset controller. 14 - 15 - A spi flash (NOR/NAND) must be a child of spi node and could have some 16 - properties. Also see jedec,spi-nor.txt. 17 - 18 - Required properties: 19 - - reg: chip-Select number (QSPI controller may connect 2 flashes) 20 - - spi-max-frequency: max frequency of spi bus 21 - 22 - Optional properties: 23 - - spi-rx-bus-width: see ./spi-bus.txt for the description 24 - - dmas: DMA specifiers for tx and rx dma. See the DMA client binding, 25 - Documentation/devicetree/bindings/dma/dma.txt. 26 - - dma-names: DMA request names should include "tx" and "rx" if present. 27 - 28 - Example: 29 - 30 - qspi: spi@a0001000 { 31 - compatible = "st,stm32f469-qspi"; 32 - reg = <0xa0001000 0x1000>, <0x90000000 0x10000000>; 33 - reg-names = "qspi", "qspi_mm"; 34 - interrupts = <91>; 35 - resets = <&rcc STM32F4_AHB3_RESET(QSPI)>; 36 - clocks = <&rcc 0 STM32F4_AHB3_CLOCK(QSPI)>; 37 - pinctrl-names = "default"; 38 - pinctrl-0 = <&pinctrl_qspi0>; 39 - 40 - flash@0 { 41 - compatible = "jedec,spi-nor"; 42 - reg = <0>; 43 - spi-rx-bus-width = <4>; 44 - spi-max-frequency = <108000000>; 45 - ... 46 - }; 47 - };
+3 -1
Documentation/devicetree/bindings/spi/spi-xilinx.txt
··· 8 8 number. 9 9 10 10 Optional properties: 11 - - xlnx,num-ss-bits : Number of chip selects used. 11 + - xlnx,num-ss-bits : Number of chip selects used. 12 + - xlnx,num-transfer-bits : Number of bits per transfer. This will be 8 if not specified 12 13 13 14 Example: 14 15 axi_quad_spi@41e00000 { ··· 18 17 interrupts = <0 31 1>; 19 18 reg = <0x41e00000 0x10000>; 20 19 xlnx,num-ss-bits = <0x1>; 20 + xlnx,num-transfer-bits = <32>; 21 21 }; 22 22
+83
Documentation/devicetree/bindings/spi/st,stm32-qspi.yaml
··· 1 + # SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) 2 + %YAML 1.2 3 + --- 4 + $id: http://devicetree.org/schemas/spi/st,stm32-qspi.yaml# 5 + $schema: http://devicetree.org/meta-schemas/core.yaml# 6 + 7 + title: STMicroelectronics STM32 Quad Serial Peripheral Interface (QSPI) bindings 8 + 9 + maintainers: 10 + - Christophe Kerello <christophe.kerello@st.com> 11 + - Patrice Chotard <patrice.chotard@st.com> 12 + 13 + allOf: 14 + - $ref: "spi-controller.yaml#" 15 + 16 + properties: 17 + compatible: 18 + const: st,stm32f469-qspi 19 + 20 + reg: 21 + items: 22 + - description: registers 23 + - description: memory mapping 24 + 25 + reg-names: 26 + items: 27 + - const: qspi 28 + - const: qspi_mm 29 + 30 + clocks: 31 + maxItems: 1 32 + 33 + interrupts: 34 + maxItems: 1 35 + 36 + resets: 37 + maxItems: 1 38 + 39 + dmas: 40 + items: 41 + - description: tx DMA channel 42 + - description: rx DMA channel 43 + 44 + dma-names: 45 + items: 46 + - const: tx 47 + - const: rx 48 + 49 + required: 50 + - compatible 51 + - reg 52 + - reg-names 53 + - clocks 54 + - interrupts 55 + 56 + examples: 57 + - | 58 + #include <dt-bindings/interrupt-controller/arm-gic.h> 59 + #include <dt-bindings/clock/stm32mp1-clks.h> 60 + #include <dt-bindings/reset/stm32mp1-resets.h> 61 + spi@58003000 { 62 + compatible = "st,stm32f469-qspi"; 63 + reg = <0x58003000 0x1000>, <0x70000000 0x10000000>; 64 + reg-names = "qspi", "qspi_mm"; 65 + interrupts = <GIC_SPI 92 IRQ_TYPE_LEVEL_HIGH>; 66 + dmas = <&mdma1 22 0x10 0x100002 0x0 0x0>, 67 + <&mdma1 22 0x10 0x100008 0x0 0x0>; 68 + dma-names = "tx", "rx"; 69 + clocks = <&rcc QSPI_K>; 70 + resets = <&rcc QSPI_R>; 71 + 72 + #address-cells = <1>; 73 + #size-cells = <0>; 74 + 75 + flash@0 { 76 + compatible = "jedec,spi-nor"; 77 + reg = <0>; 78 + spi-rx-bus-width = <4>; 79 + spi-max-frequency = <108000000>; 80 + }; 81 + }; 82 + 83 + ...
+2 -2
arch/arm/plat-pxa/ssp.c
··· 89 89 ssp->use_count--; 90 90 ssp->label = NULL; 91 91 } else 92 - dev_err(&ssp->pdev->dev, "device already free\n"); 92 + dev_err(ssp->dev, "device already free\n"); 93 93 mutex_unlock(&ssp_lock); 94 94 } 95 95 EXPORT_SYMBOL(pxa_ssp_free); ··· 118 118 if (ssp == NULL) 119 119 return -ENOMEM; 120 120 121 - ssp->pdev = pdev; 121 + ssp->dev = dev; 122 122 123 123 ssp->clk = devm_clk_get(dev, NULL); 124 124 if (IS_ERR(ssp->clk))
+12 -12
drivers/iio/imu/adis.c
··· 39 39 .len = 2, 40 40 .cs_change = 1, 41 41 .delay_usecs = adis->data->write_delay, 42 - .cs_change_delay = adis->data->cs_change_delay, 43 - .cs_change_delay_unit = SPI_DELAY_UNIT_USECS, 42 + .cs_change_delay.value = adis->data->cs_change_delay, 43 + .cs_change_delay.unit = SPI_DELAY_UNIT_USECS, 44 44 }, { 45 45 .tx_buf = adis->tx + 2, 46 46 .bits_per_word = 8, 47 47 .len = 2, 48 48 .cs_change = 1, 49 49 .delay_usecs = adis->data->write_delay, 50 - .cs_change_delay = adis->data->cs_change_delay, 51 - .cs_change_delay_unit = SPI_DELAY_UNIT_USECS, 50 + .cs_change_delay.value = adis->data->cs_change_delay, 51 + .cs_change_delay.unit = SPI_DELAY_UNIT_USECS, 52 52 }, { 53 53 .tx_buf = adis->tx + 4, 54 54 .bits_per_word = 8, 55 55 .len = 2, 56 56 .cs_change = 1, 57 57 .delay_usecs = adis->data->write_delay, 58 - .cs_change_delay = adis->data->cs_change_delay, 59 - .cs_change_delay_unit = SPI_DELAY_UNIT_USECS, 58 + .cs_change_delay.value = adis->data->cs_change_delay, 59 + .cs_change_delay.unit = SPI_DELAY_UNIT_USECS, 60 60 }, { 61 61 .tx_buf = adis->tx + 6, 62 62 .bits_per_word = 8, ··· 139 139 .len = 2, 140 140 .cs_change = 1, 141 141 .delay_usecs = adis->data->write_delay, 142 - .cs_change_delay = adis->data->cs_change_delay, 143 - .cs_change_delay_unit = SPI_DELAY_UNIT_USECS, 142 + .cs_change_delay.value = adis->data->cs_change_delay, 143 + .cs_change_delay.unit = SPI_DELAY_UNIT_USECS, 144 144 }, { 145 145 .tx_buf = adis->tx + 2, 146 146 .bits_per_word = 8, 147 147 .len = 2, 148 148 .cs_change = 1, 149 149 .delay_usecs = adis->data->read_delay, 150 - .cs_change_delay = adis->data->cs_change_delay, 151 - .cs_change_delay_unit = SPI_DELAY_UNIT_USECS, 150 + .cs_change_delay.value = adis->data->cs_change_delay, 151 + .cs_change_delay.unit = SPI_DELAY_UNIT_USECS, 152 152 }, { 153 153 .tx_buf = adis->tx + 4, 154 154 .rx_buf = adis->rx, ··· 156 156 .len = 2, 157 157 .cs_change = 1, 158 158 .delay_usecs = adis->data->read_delay, 159 - .cs_change_delay = adis->data->cs_change_delay, 160 - .cs_change_delay_unit = SPI_DELAY_UNIT_USECS, 159 + .cs_change_delay.value = adis->data->cs_change_delay, 160 + .cs_change_delay.unit = SPI_DELAY_UNIT_USECS, 161 161 }, { 162 162 .rx_buf = adis->rx + 2, 163 163 .bits_per_word = 8,
+10 -9
drivers/spi/Kconfig
··· 80 80 config SPI_ATMEL 81 81 tristate "Atmel SPI Controller" 82 82 depends on ARCH_AT91 || COMPILE_TEST 83 + depends on OF 83 84 help 84 85 This selects a driver for the Atmel SPI Controller, present on 85 86 many AT91 ARM chips. ··· 144 143 tristate "Broadcom BCM63xx SPI controller" 145 144 depends on BCM63XX || COMPILE_TEST 146 145 help 147 - Enable support for the SPI controller on the Broadcom BCM63xx SoCs. 146 + Enable support for the SPI controller on the Broadcom BCM63xx SoCs. 148 147 149 148 config SPI_BCM63XX_HSSPI 150 149 tristate "Broadcom BCM63XX HS SPI controller driver" ··· 235 234 tristate "Diolan DLN-2 USB SPI adapter" 236 235 depends on MFD_DLN2 237 236 help 238 - If you say yes to this option, support will be included for Diolan 239 - DLN2, a USB to SPI interface. 237 + If you say yes to this option, support will be included for Diolan 238 + DLN2, a USB to SPI interface. 240 239 241 - This driver can also be built as a module. If so, the module 242 - will be called spi-dln2. 240 + This driver can also be built as a module. If so, the module 241 + will be called spi-dln2. 243 242 244 243 config SPI_EFM32 245 244 tristate "EFM32 SPI controller" ··· 748 747 It also supports the new dual-bit and quad-bit SPI protocol. 749 748 750 749 config SPI_MXIC 751 - tristate "Macronix MX25F0A SPI controller" 752 - depends on SPI_MASTER 753 - help 754 - This selects the Macronix MX25F0A SPI controller driver. 750 + tristate "Macronix MX25F0A SPI controller" 751 + depends on SPI_MASTER 752 + help 753 + This selects the Macronix MX25F0A SPI controller driver. 755 754 756 755 config SPI_MXS 757 756 tristate "Freescale MXS SPI controller"
+2 -2
drivers/spi/spi-at91-usart.c
··· 132 132 dma_cap_zero(mask); 133 133 dma_cap_set(DMA_SLAVE, mask); 134 134 135 - ctlr->dma_tx = dma_request_slave_channel_reason(dev, "tx"); 135 + ctlr->dma_tx = dma_request_chan(dev, "tx"); 136 136 if (IS_ERR_OR_NULL(ctlr->dma_tx)) { 137 137 if (IS_ERR(ctlr->dma_tx)) { 138 138 err = PTR_ERR(ctlr->dma_tx); ··· 145 145 goto at91_usart_spi_error_clear; 146 146 } 147 147 148 - ctlr->dma_rx = dma_request_slave_channel_reason(dev, "rx"); 148 + ctlr->dma_rx = dma_request_chan(dev, "rx"); 149 149 if (IS_ERR_OR_NULL(ctlr->dma_rx)) { 150 150 if (IS_ERR(ctlr->dma_rx)) { 151 151 err = PTR_ERR(ctlr->dma_rx);
+120 -99
drivers/spi/spi-atmel.c
··· 222 222 | SPI_BF(name, value)) 223 223 224 224 /* Register access macros */ 225 - #ifdef CONFIG_AVR32 226 - #define spi_readl(port, reg) \ 227 - __raw_readl((port)->regs + SPI_##reg) 228 - #define spi_writel(port, reg, value) \ 229 - __raw_writel((value), (port)->regs + SPI_##reg) 230 - 231 - #define spi_readw(port, reg) \ 232 - __raw_readw((port)->regs + SPI_##reg) 233 - #define spi_writew(port, reg, value) \ 234 - __raw_writew((value), (port)->regs + SPI_##reg) 235 - 236 - #define spi_readb(port, reg) \ 237 - __raw_readb((port)->regs + SPI_##reg) 238 - #define spi_writeb(port, reg, value) \ 239 - __raw_writeb((value), (port)->regs + SPI_##reg) 240 - #else 241 225 #define spi_readl(port, reg) \ 242 226 readl_relaxed((port)->regs + SPI_##reg) 243 227 #define spi_writel(port, reg, value) \ 244 228 writel_relaxed((value), (port)->regs + SPI_##reg) 245 - 246 - #define spi_readw(port, reg) \ 247 - readw_relaxed((port)->regs + SPI_##reg) 248 229 #define spi_writew(port, reg, value) \ 249 230 writew_relaxed((value), (port)->regs + SPI_##reg) 250 231 251 - #define spi_readb(port, reg) \ 252 - readb_relaxed((port)->regs + SPI_##reg) 253 - #define spi_writeb(port, reg, value) \ 254 - writeb_relaxed((value), (port)->regs + SPI_##reg) 255 - #endif 256 232 /* use PIO for small transfers, avoiding DMA setup/teardown overhead and 257 233 * cache operations; better heuristics consider wordsize and bitrate. 258 234 */ ··· 275 299 276 300 bool use_dma; 277 301 bool use_pdc; 278 - bool use_cs_gpios; 279 302 280 303 bool keep_cs; 281 - bool cs_active; 282 304 283 305 u32 fifo_size; 306 + u8 native_cs_free; 307 + u8 native_cs_for_gpio; 284 308 }; 285 309 286 310 /* Controller-specific per-slave state */ 287 311 struct atmel_spi_device { 288 - struct gpio_desc *npcs_pin; 289 312 u32 csr; 290 313 }; 291 314 ··· 311 336 * transmitted") Not so! Workaround uses nCSx pins as GPIOs; or newer 312 337 * controllers have CSAAT and friends. 313 338 * 314 - * Since the CSAAT functionality is a bit weird on newer controllers as 315 - * well, we use GPIO to control nCSx pins on all controllers, updating 316 - * MR.PCS to avoid confusing the controller. Using GPIOs also lets us 317 - * support active-high chipselects despite the controller's belief that 318 - * only active-low devices/systems exists. 339 + * Even controller newer than ar91rm9200, using GPIOs can make sens as 340 + * it lets us support active-high chipselects despite the controller's 341 + * belief that only active-low devices/systems exists. 319 342 * 320 343 * However, at91rm9200 has a second erratum whereby nCS0 doesn't work 321 344 * right when driven with GPIO. ("Mode Fault does not allow more than one ··· 325 352 static void cs_activate(struct atmel_spi *as, struct spi_device *spi) 326 353 { 327 354 struct atmel_spi_device *asd = spi->controller_state; 355 + int chip_select; 328 356 u32 mr; 329 357 358 + if (spi->cs_gpiod) 359 + chip_select = as->native_cs_for_gpio; 360 + else 361 + chip_select = spi->chip_select; 362 + 330 363 if (atmel_spi_is_v2(as)) { 331 - spi_writel(as, CSR0 + 4 * spi->chip_select, asd->csr); 364 + spi_writel(as, CSR0 + 4 * chip_select, asd->csr); 332 365 /* For the low SPI version, there is a issue that PDC transfer 333 366 * on CS1,2,3 needs SPI_CSR0.BITS config as SPI_CSR1,2,3.BITS 334 367 */ 335 368 spi_writel(as, CSR0, asd->csr); 336 369 if (as->caps.has_wdrbt) { 337 370 spi_writel(as, MR, 338 - SPI_BF(PCS, ~(0x01 << spi->chip_select)) 371 + SPI_BF(PCS, ~(0x01 << chip_select)) 339 372 | SPI_BIT(WDRBT) 340 373 | SPI_BIT(MODFDIS) 341 374 | SPI_BIT(MSTR)); 342 375 } else { 343 376 spi_writel(as, MR, 344 - SPI_BF(PCS, ~(0x01 << spi->chip_select)) 377 + SPI_BF(PCS, ~(0x01 << chip_select)) 345 378 | SPI_BIT(MODFDIS) 346 379 | SPI_BIT(MSTR)); 347 380 } 348 381 349 382 mr = spi_readl(as, MR); 350 - if (as->use_cs_gpios) 351 - gpiod_set_value(asd->npcs_pin, 1); 383 + if (spi->cs_gpiod) 384 + gpiod_set_value(spi->cs_gpiod, 1); 352 385 } else { 353 386 u32 cpol = (spi->mode & SPI_CPOL) ? SPI_BIT(CPOL) : 0; 354 387 int i; ··· 369 390 } 370 391 371 392 mr = spi_readl(as, MR); 372 - mr = SPI_BFINS(PCS, ~(1 << spi->chip_select), mr); 373 - if (as->use_cs_gpios && spi->chip_select != 0) 374 - gpiod_set_value(asd->npcs_pin, 1); 393 + mr = SPI_BFINS(PCS, ~(1 << chip_select), mr); 394 + if (spi->cs_gpiod) 395 + gpiod_set_value(spi->cs_gpiod, 1); 375 396 spi_writel(as, MR, mr); 376 397 } 377 398 ··· 380 401 381 402 static void cs_deactivate(struct atmel_spi *as, struct spi_device *spi) 382 403 { 383 - struct atmel_spi_device *asd = spi->controller_state; 404 + int chip_select; 384 405 u32 mr; 406 + 407 + if (spi->cs_gpiod) 408 + chip_select = as->native_cs_for_gpio; 409 + else 410 + chip_select = spi->chip_select; 385 411 386 412 /* only deactivate *this* device; sometimes transfers to 387 413 * another device may be active when this routine is called. 388 414 */ 389 415 mr = spi_readl(as, MR); 390 - if (~SPI_BFEXT(PCS, mr) & (1 << spi->chip_select)) { 416 + if (~SPI_BFEXT(PCS, mr) & (1 << chip_select)) { 391 417 mr = SPI_BFINS(PCS, 0xf, mr); 392 418 spi_writel(as, MR, mr); 393 419 } 394 420 395 421 dev_dbg(&spi->dev, "DEactivate NPCS, mr %08x\n", mr); 396 422 397 - if (!as->use_cs_gpios) 423 + if (!spi->cs_gpiod) 398 424 spi_writel(as, CR, SPI_BIT(LASTXFER)); 399 - else if (atmel_spi_is_v2(as) || spi->chip_select != 0) 400 - gpiod_set_value(asd->npcs_pin, 0); 425 + else 426 + gpiod_set_value(spi->cs_gpiod, 0); 401 427 } 402 428 403 429 static void atmel_spi_lock(struct atmel_spi *as) __acquires(&as->lock) ··· 511 527 dma_cap_zero(mask); 512 528 dma_cap_set(DMA_SLAVE, mask); 513 529 514 - master->dma_tx = dma_request_slave_channel_reason(dev, "tx"); 530 + master->dma_tx = dma_request_chan(dev, "tx"); 515 531 if (IS_ERR(master->dma_tx)) { 516 532 err = PTR_ERR(master->dma_tx); 517 533 if (err == -EPROBE_DEFER) { ··· 828 844 { 829 845 u32 scbr, csr; 830 846 unsigned long bus_hz; 847 + int chip_select; 848 + 849 + if (spi->cs_gpiod) 850 + chip_select = as->native_cs_for_gpio; 851 + else 852 + chip_select = spi->chip_select; 831 853 832 854 /* v1 chips start out at half the peripheral bus speed. */ 833 855 bus_hz = as->spi_clk; ··· 862 872 xfer->speed_hz, scbr, bus_hz); 863 873 return -EINVAL; 864 874 } 865 - csr = spi_readl(as, CSR0 + 4 * spi->chip_select); 875 + csr = spi_readl(as, CSR0 + 4 * chip_select); 866 876 csr = SPI_BFINS(SCBR, scbr, csr); 867 - spi_writel(as, CSR0 + 4 * spi->chip_select, csr); 877 + spi_writel(as, CSR0 + 4 * chip_select, csr); 868 878 869 879 return 0; 870 880 } ··· 1163 1173 return ret; 1164 1174 } 1165 1175 1176 + static int atmel_word_delay_csr(struct spi_device *spi, struct atmel_spi *as) 1177 + { 1178 + struct spi_delay *delay = &spi->word_delay; 1179 + u32 value = delay->value; 1180 + 1181 + switch (delay->unit) { 1182 + case SPI_DELAY_UNIT_NSECS: 1183 + value /= 1000; 1184 + break; 1185 + case SPI_DELAY_UNIT_USECS: 1186 + break; 1187 + default: 1188 + return -EINVAL; 1189 + } 1190 + 1191 + return (as->spi_clk / 1000000 * value) >> 5; 1192 + } 1193 + 1194 + static void initialize_native_cs_for_gpio(struct atmel_spi *as) 1195 + { 1196 + int i; 1197 + struct spi_master *master = platform_get_drvdata(as->pdev); 1198 + 1199 + if (!as->native_cs_free) 1200 + return; /* already initialized */ 1201 + 1202 + if (!master->cs_gpiods) 1203 + return; /* No CS GPIO */ 1204 + 1205 + /* 1206 + * On the first version of the controller (AT91RM9200), CS0 1207 + * can't be used associated with GPIO 1208 + */ 1209 + if (atmel_spi_is_v2(as)) 1210 + i = 0; 1211 + else 1212 + i = 1; 1213 + 1214 + for (; i < 4; i++) 1215 + if (master->cs_gpiods[i]) 1216 + as->native_cs_free |= BIT(i); 1217 + 1218 + if (as->native_cs_free) 1219 + as->native_cs_for_gpio = ffs(as->native_cs_free); 1220 + } 1221 + 1166 1222 static int atmel_spi_setup(struct spi_device *spi) 1167 1223 { 1168 1224 struct atmel_spi *as; 1169 1225 struct atmel_spi_device *asd; 1170 1226 u32 csr; 1171 1227 unsigned int bits = spi->bits_per_word; 1228 + int chip_select; 1229 + int word_delay_csr; 1172 1230 1173 1231 as = spi_master_get_devdata(spi->master); 1174 1232 1175 1233 /* see notes above re chipselect */ 1176 - if (!atmel_spi_is_v2(as) 1177 - && spi->chip_select == 0 1178 - && (spi->mode & SPI_CS_HIGH)) { 1179 - dev_dbg(&spi->dev, "setup: can't be active-high\n"); 1234 + if (!spi->cs_gpiod && (spi->mode & SPI_CS_HIGH)) { 1235 + dev_warn(&spi->dev, "setup: non GPIO CS can't be active-high\n"); 1180 1236 return -EINVAL; 1181 1237 } 1238 + 1239 + /* Setup() is called during spi_register_controller(aka 1240 + * spi_register_master) but after all membmers of the cs_gpiod 1241 + * array have been filled, so we can looked for which native 1242 + * CS will be free for using with GPIO 1243 + */ 1244 + initialize_native_cs_for_gpio(as); 1245 + 1246 + if (spi->cs_gpiod && as->native_cs_free) { 1247 + dev_err(&spi->dev, 1248 + "No native CS available to support this GPIO CS\n"); 1249 + return -EBUSY; 1250 + } 1251 + 1252 + if (spi->cs_gpiod) 1253 + chip_select = as->native_cs_for_gpio; 1254 + else 1255 + chip_select = spi->chip_select; 1182 1256 1183 1257 csr = SPI_BF(BITS, bits - 8); 1184 1258 if (spi->mode & SPI_CPOL) 1185 1259 csr |= SPI_BIT(CPOL); 1186 1260 if (!(spi->mode & SPI_CPHA)) 1187 1261 csr |= SPI_BIT(NCPHA); 1188 - if (!as->use_cs_gpios) 1189 - csr |= SPI_BIT(CSAAT); 1190 1262 1191 - /* DLYBS is mostly irrelevant since we manage chipselect using GPIOs. 1192 - */ 1263 + if (!spi->cs_gpiod) 1264 + csr |= SPI_BIT(CSAAT); 1193 1265 csr |= SPI_BF(DLYBS, 0); 1266 + 1267 + word_delay_csr = atmel_word_delay_csr(spi, as); 1268 + if (word_delay_csr < 0) 1269 + return word_delay_csr; 1194 1270 1195 1271 /* DLYBCT adds delays between words. This is useful for slow devices 1196 1272 * that need a bit of time to setup the next transfer. 1197 1273 */ 1198 - csr |= SPI_BF(DLYBCT, 1199 - (as->spi_clk / 1000000 * spi->word_delay_usecs) >> 5); 1274 + csr |= SPI_BF(DLYBCT, word_delay_csr); 1200 1275 1201 1276 asd = spi->controller_state; 1202 1277 if (!asd) { 1203 1278 asd = kzalloc(sizeof(struct atmel_spi_device), GFP_KERNEL); 1204 1279 if (!asd) 1205 1280 return -ENOMEM; 1206 - 1207 - /* 1208 - * If use_cs_gpios is true this means that we have "cs-gpios" 1209 - * defined in the device tree node so we should have 1210 - * gotten the GPIO lines from the device tree inside the 1211 - * SPI core. Warn if this is not the case but continue since 1212 - * CS GPIOs are after all optional. 1213 - */ 1214 - if (as->use_cs_gpios) { 1215 - if (!spi->cs_gpiod) { 1216 - dev_err(&spi->dev, 1217 - "host claims to use CS GPIOs but no CS found in DT by the SPI core\n"); 1218 - } 1219 - asd->npcs_pin = spi->cs_gpiod; 1220 - } 1221 1281 1222 1282 spi->controller_state = asd; 1223 1283 } ··· 1279 1239 bits, spi->mode, spi->chip_select, csr); 1280 1240 1281 1241 if (!atmel_spi_is_v2(as)) 1282 - spi_writel(as, CSR0 + 4 * spi->chip_select, csr); 1242 + spi_writel(as, CSR0 + 4 * chip_select, csr); 1283 1243 1284 1244 return 0; 1285 1245 } ··· 1408 1368 && as->use_pdc) 1409 1369 atmel_spi_dma_unmap_xfer(master, xfer); 1410 1370 1411 - if (xfer->delay_usecs) 1412 - udelay(xfer->delay_usecs); 1371 + spi_transfer_delay_exec(xfer); 1413 1372 1414 1373 if (xfer->cs_change) { 1415 1374 if (list_is_last(&xfer->transfer_list, 1416 1375 &msg->transfers)) { 1417 1376 as->keep_cs = true; 1418 1377 } else { 1419 - as->cs_active = !as->cs_active; 1420 - if (as->cs_active) 1421 - cs_activate(as, msg->spi); 1422 - else 1423 - cs_deactivate(as, msg->spi); 1378 + cs_deactivate(as, msg->spi); 1379 + udelay(10); 1380 + cs_activate(as, msg->spi); 1424 1381 } 1425 1382 } 1426 1383 ··· 1440 1403 atmel_spi_lock(as); 1441 1404 cs_activate(as, spi); 1442 1405 1443 - as->cs_active = true; 1444 1406 as->keep_cs = false; 1445 1407 1446 1408 msg->status = 0; ··· 1563 1527 master->bits_per_word_mask = SPI_BPW_RANGE_MASK(8, 16); 1564 1528 master->dev.of_node = pdev->dev.of_node; 1565 1529 master->bus_num = pdev->id; 1566 - master->num_chipselect = master->dev.of_node ? 0 : 4; 1530 + master->num_chipselect = 4; 1567 1531 master->setup = atmel_spi_setup; 1568 1532 master->flags = (SPI_MASTER_MUST_RX | SPI_MASTER_MUST_TX); 1569 1533 master->transfer_one_message = atmel_spi_transfer_one_message; ··· 1590 1554 init_completion(&as->xfer_completion); 1591 1555 1592 1556 atmel_get_caps(as); 1593 - 1594 - /* 1595 - * If there are chip selects in the device tree, those will be 1596 - * discovered by the SPI core when registering the SPI master 1597 - * and assigned to each SPI device. 1598 - */ 1599 - as->use_cs_gpios = true; 1600 - if (atmel_spi_is_v2(as) && 1601 - pdev->dev.of_node && 1602 - !of_get_property(pdev->dev.of_node, "cs-gpios", NULL)) { 1603 - as->use_cs_gpios = false; 1604 - master->num_chipselect = 4; 1605 - } 1606 1557 1607 1558 as->use_dma = false; 1608 1559 as->use_pdc = false; ··· 1798 1775 #define ATMEL_SPI_PM_OPS NULL 1799 1776 #endif 1800 1777 1801 - #if defined(CONFIG_OF) 1802 1778 static const struct of_device_id atmel_spi_dt_ids[] = { 1803 1779 { .compatible = "atmel,at91rm9200-spi" }, 1804 1780 { /* sentinel */ } 1805 1781 }; 1806 1782 1807 1783 MODULE_DEVICE_TABLE(of, atmel_spi_dt_ids); 1808 - #endif 1809 1784 1810 1785 static struct platform_driver atmel_spi_driver = { 1811 1786 .driver = { 1812 1787 .name = "atmel_spi", 1813 1788 .pm = ATMEL_SPI_PM_OPS, 1814 - .of_match_table = of_match_ptr(atmel_spi_dt_ids), 1789 + .of_match_table = atmel_spi_dt_ids, 1815 1790 }, 1816 1791 .probe = atmel_spi_probe, 1817 1792 .remove = atmel_spi_remove,
+13 -3
drivers/spi/spi-axi-spi-engine.c
··· 163 163 } 164 164 165 165 static void spi_engine_gen_sleep(struct spi_engine_program *p, bool dry, 166 - struct spi_engine *spi_engine, unsigned int clk_div, unsigned int delay) 166 + struct spi_engine *spi_engine, unsigned int clk_div, 167 + struct spi_transfer *xfer) 167 168 { 168 169 unsigned int spi_clk = clk_get_rate(spi_engine->ref_clk); 169 170 unsigned int t; 171 + int delay; 172 + 173 + if (xfer->delay_usecs) { 174 + delay = xfer->delay_usecs; 175 + } else { 176 + delay = spi_delay_to_ns(&xfer->delay, xfer); 177 + if (delay < 0) 178 + return; 179 + delay /= 1000; 180 + } 170 181 171 182 if (delay == 0) 172 183 return; ··· 229 218 spi_engine_gen_cs(p, dry, spi, true); 230 219 231 220 spi_engine_gen_xfer(p, dry, xfer); 232 - spi_engine_gen_sleep(p, dry, spi_engine, clk_div, 233 - xfer->delay_usecs); 221 + spi_engine_gen_sleep(p, dry, spi_engine, clk_div, xfer); 234 222 235 223 cs_change = xfer->cs_change; 236 224 if (list_is_last(&xfer->transfer_list, &msg->transfers))
+5 -2
drivers/spi/spi-bcm-qspi.c
··· 803 803 return -EIO; 804 804 805 805 from = op->addr.val; 806 - bcm_qspi_chip_select(qspi, spi->chip_select); 806 + if (!spi->cs_gpiod) 807 + bcm_qspi_chip_select(qspi, spi->chip_select); 807 808 bcm_qspi_write(qspi, MSPI, MSPI_WRITE_LOCK, 0); 808 809 809 810 /* ··· 883 882 int slots; 884 883 unsigned long timeo = msecs_to_jiffies(100); 885 884 886 - bcm_qspi_chip_select(qspi, spi->chip_select); 885 + if (!spi->cs_gpiod) 886 + bcm_qspi_chip_select(qspi, spi->chip_select); 887 887 qspi->trans_pos.trans = trans; 888 888 qspi->trans_pos.byte = 0; 889 889 ··· 1236 1234 master->cleanup = bcm_qspi_cleanup; 1237 1235 master->dev.of_node = dev->of_node; 1238 1236 master->num_chipselect = NUM_CHIPSELECT; 1237 + master->use_gpio_descriptors = true; 1239 1238 1240 1239 qspi->big_endian = of_device_is_big_endian(dev->of_node); 1241 1240
+1 -1
drivers/spi/spi-bcm2835.c
··· 1248 1248 /* 1249 1249 * Retrieve the corresponding GPIO line used for CS. 1250 1250 * The inversion semantics will be handled by the GPIO core 1251 - * code, so we pass GPIOS_OUT_LOW for "unasserted" and 1251 + * code, so we pass GPIOD_OUT_LOW for "unasserted" and 1252 1252 * the correct flag for inversion semantics. The SPI_CS_HIGH 1253 1253 * on spi->mode cannot be checked for polarity in this case 1254 1254 * as the flag use_gpio_descriptors enforces SPI_CS_HIGH.
+1 -2
drivers/spi/spi-bcm63xx-hsspi.c
··· 291 291 292 292 msg->actual_length += t->len; 293 293 294 - if (t->delay_usecs) 295 - udelay(t->delay_usecs); 294 + spi_transfer_delay_exec(t); 296 295 297 296 if (t->cs_change) 298 297 bcm63xx_hsspi_set_cs(bs, spi->chip_select, false);
+1 -1
drivers/spi/spi-bcm63xx.c
··· 368 368 } 369 369 370 370 /* CS will be deasserted directly after transfer */ 371 - if (t->delay_usecs) { 371 + if (t->delay_usecs || t->delay.value) { 372 372 dev_err(&spi->dev, "unable to keep CS asserted after transfer\n"); 373 373 status = -EINVAL; 374 374 goto exit;
+1 -2
drivers/spi/spi-cavium.c
··· 119 119 *rx_buf++ = (u8)v; 120 120 } 121 121 122 - if (xfer->delay_usecs) 123 - udelay(xfer->delay_usecs); 122 + spi_transfer_delay_exec(xfer); 124 123 125 124 return xfer->len; 126 125 }
+6
drivers/spi/spi-dw-mmio.c
··· 9 9 #include <linux/err.h> 10 10 #include <linux/interrupt.h> 11 11 #include <linux/platform_device.h> 12 + #include <linux/pm_runtime.h> 12 13 #include <linux/slab.h> 13 14 #include <linux/spi/spi.h> 14 15 #include <linux/scatterlist.h> ··· 194 193 goto out; 195 194 } 196 195 196 + pm_runtime_enable(&pdev->dev); 197 + 197 198 ret = dw_spi_add_host(&pdev->dev, dws); 198 199 if (ret) 199 200 goto out; ··· 204 201 return 0; 205 202 206 203 out: 204 + pm_runtime_disable(&pdev->dev); 207 205 clk_disable_unprepare(dwsmmio->pclk); 208 206 out_clk: 209 207 clk_disable_unprepare(dwsmmio->clk); ··· 216 212 struct dw_spi_mmio *dwsmmio = platform_get_drvdata(pdev); 217 213 218 214 dw_spi_remove_host(&dwsmmio->dws); 215 + pm_runtime_disable(&pdev->dev); 219 216 clk_disable_unprepare(dwsmmio->pclk); 220 217 clk_disable_unprepare(dwsmmio->clk); 221 218 ··· 228 223 { .compatible = "mscc,ocelot-spi", .data = dw_spi_mscc_ocelot_init}, 229 224 { .compatible = "mscc,jaguar2-spi", .data = dw_spi_mscc_jaguar2_init}, 230 225 { .compatible = "amazon,alpine-dw-apb-ssi", .data = dw_spi_alpine_init}, 226 + { .compatible = "renesas,rzn1-spi", }, 231 227 { /* end of table */} 232 228 }; 233 229 MODULE_DEVICE_TABLE(of, dw_spi_mmio_of_match);
+21 -3
drivers/spi/spi-dw-pci.c
··· 7 7 8 8 #include <linux/interrupt.h> 9 9 #include <linux/pci.h> 10 + #include <linux/pm_runtime.h> 10 11 #include <linux/slab.h> 11 12 #include <linux/spi/spi.h> 12 13 #include <linux/module.h> ··· 36 35 }; 37 36 38 37 static struct spi_pci_desc spi_pci_ehl_desc = { 39 - .num_cs = 1, 38 + .num_cs = 2, 40 39 .bus_num = -1, 41 40 .max_freq = 100000000, 42 41 }; ··· 58 57 59 58 /* Get basic io resource and map it */ 60 59 dws->paddr = pci_resource_start(pdev, pci_bar); 60 + pci_set_master(pdev); 61 61 62 62 ret = pcim_iomap_regions(pdev, 1 << pci_bar, pci_name(pdev)); 63 63 if (ret) 64 64 return ret; 65 65 66 + ret = pci_alloc_irq_vectors(pdev, 1, 1, PCI_IRQ_ALL_TYPES); 67 + if (ret < 0) 68 + return ret; 69 + 66 70 dws->regs = pcim_iomap_table(pdev)[pci_bar]; 67 - dws->irq = pdev->irq; 71 + dws->irq = pci_irq_vector(pdev, 0); 68 72 69 73 /* 70 74 * Specific handling for platforms, like dma setup, ··· 86 80 return ret; 87 81 } 88 82 } else { 83 + pci_free_irq_vectors(pdev); 89 84 return -ENODEV; 90 85 } 91 86 92 87 ret = dw_spi_add_host(&pdev->dev, dws); 93 - if (ret) 88 + if (ret) { 89 + pci_free_irq_vectors(pdev); 94 90 return ret; 91 + } 95 92 96 93 /* PCI hook and SPI hook use the same drv data */ 97 94 pci_set_drvdata(pdev, dws); 98 95 99 96 dev_info(&pdev->dev, "found PCI SPI controller(ID: %04x:%04x)\n", 100 97 pdev->vendor, pdev->device); 98 + 99 + pm_runtime_set_autosuspend_delay(&pdev->dev, 1000); 100 + pm_runtime_use_autosuspend(&pdev->dev); 101 + pm_runtime_put_autosuspend(&pdev->dev); 102 + pm_runtime_allow(&pdev->dev); 101 103 102 104 return 0; 103 105 } ··· 114 100 { 115 101 struct dw_spi *dws = pci_get_drvdata(pdev); 116 102 103 + pm_runtime_forbid(&pdev->dev); 104 + pm_runtime_get_noresume(&pdev->dev); 105 + 117 106 dw_spi_remove_host(dws); 107 + pci_free_irq_vectors(pdev); 118 108 } 119 109 120 110 #ifdef CONFIG_PM_SLEEP
+3 -1
drivers/spi/spi-dw.c
··· 308 308 cr0 = (transfer->bits_per_word - 1) 309 309 | (chip->type << SPI_FRF_OFFSET) 310 310 | ((((spi->mode & SPI_CPOL) ? 1 : 0) << SPI_SCOL_OFFSET) | 311 - (((spi->mode & SPI_CPHA) ? 1 : 0) << SPI_SCPH_OFFSET)) 311 + (((spi->mode & SPI_CPHA) ? 1 : 0) << SPI_SCPH_OFFSET) | 312 + (((spi->mode & SPI_LOOP) ? 1 : 0) << SPI_SRL_OFFSET)) 312 313 | (chip->tmode << SPI_TMOD_OFFSET); 313 314 314 315 /* ··· 494 493 master->dev.of_node = dev->of_node; 495 494 master->dev.fwnode = dev->fwnode; 496 495 master->flags = SPI_MASTER_GPIO_SS; 496 + master->auto_runtime_pm = true; 497 497 498 498 if (dws->set_cs) 499 499 master->set_cs = dws->set_cs;
-1
drivers/spi/spi-dw.h
··· 4 4 5 5 #include <linux/io.h> 6 6 #include <linux/scatterlist.h> 7 - #include <linux/gpio.h> 8 7 9 8 /* Register offsets */ 10 9 #define DW_SPI_CTRL0 0x00
+1 -1
drivers/spi/spi-falcon.c
··· 377 377 378 378 m->actual_length += t->len; 379 379 380 - WARN_ON(t->delay_usecs || t->cs_change); 380 + WARN_ON(t->delay_usecs || t->delay.value || t->cs_change); 381 381 spi_flags = 0; 382 382 } 383 383
+2 -1
drivers/spi/spi-fsl-cpm.c
··· 392 392 dma_unmap_single(dev, mspi->dma_dummy_rx, SPI_MRBLR, DMA_FROM_DEVICE); 393 393 dma_unmap_single(dev, mspi->dma_dummy_tx, PAGE_SIZE, DMA_TO_DEVICE); 394 394 cpm_muram_free(cpm_muram_offset(mspi->tx_bd)); 395 - cpm_muram_free(cpm_muram_offset(mspi->pram)); 395 + if (!(mspi->flags & SPI_CPM1)) 396 + cpm_muram_free(cpm_muram_offset(mspi->pram)); 396 397 fsl_spi_free_dummy_rx(); 397 398 } 398 399 EXPORT_SYMBOL_GPL(fsl_spi_cpm_free);
+40 -3
drivers/spi/spi-fsl-dspi.c
··· 129 129 struct fsl_dspi_devtype_data { 130 130 enum dspi_trans_mode trans_mode; 131 131 u8 max_clock_factor; 132 + bool ptp_sts_supported; 132 133 bool xspi_mode; 133 134 }; 134 135 ··· 141 140 static const struct fsl_dspi_devtype_data ls1021a_v1_data = { 142 141 .trans_mode = DSPI_TCFQ_MODE, 143 142 .max_clock_factor = 8, 143 + .ptp_sts_supported = true, 144 144 .xspi_mode = true, 145 145 }; 146 146 147 147 static const struct fsl_dspi_devtype_data ls2085a_data = { 148 148 .trans_mode = DSPI_TCFQ_MODE, 149 149 .max_clock_factor = 8, 150 + .ptp_sts_supported = true, 150 151 }; 151 152 152 153 static const struct fsl_dspi_devtype_data coldfire_data = { ··· 657 654 u16 spi_tcnt; 658 655 u32 spi_tcr; 659 656 657 + spi_take_timestamp_post(dspi->ctlr, dspi->cur_transfer, 658 + dspi->tx - dspi->bytes_per_word, !dspi->irq); 659 + 660 660 /* Get transfer counter (in number of SPI transfers). It was 661 661 * reset to 0 when transfer(s) were started. 662 662 */ ··· 677 671 if (!dspi->len) 678 672 /* Success! */ 679 673 return 0; 674 + 675 + spi_take_timestamp_pre(dspi->ctlr, dspi->cur_transfer, 676 + dspi->tx, !dspi->irq); 680 677 681 678 if (trans_mode == DSPI_EOQ_MODE) 682 679 dspi_eoq_write(dspi); ··· 716 707 regmap_read(dspi->regmap, SPI_SR, &spi_sr); 717 708 regmap_write(dspi->regmap, SPI_SR, spi_sr); 718 709 719 - if (!(spi_sr & (SPI_SR_EOQF | SPI_SR_TCFQF))) 710 + if (!(spi_sr & SPI_SR_EOQF)) 720 711 return IRQ_NONE; 721 712 722 713 if (dspi_rxtx(dspi) == 0) { ··· 788 779 SPI_FRAME_EBITS(transfer->bits_per_word) | 789 780 SPI_CTARE_DTCP(1)); 790 781 782 + spi_take_timestamp_pre(dspi->ctlr, dspi->cur_transfer, 783 + dspi->tx, !dspi->irq); 784 + 791 785 trans_mode = dspi->devtype_data->trans_mode; 792 786 switch (trans_mode) { 793 787 case DSPI_EOQ_MODE: ··· 827 815 dev_err(&dspi->pdev->dev, 828 816 "Waiting for transfer to complete failed!\n"); 829 817 830 - if (transfer->delay_usecs) 831 - udelay(transfer->delay_usecs); 818 + spi_transfer_delay_exec(transfer); 832 819 } 833 820 834 821 out: ··· 1017 1006 SPI_CTARE_FMSZE(0) | SPI_CTARE_DTCP(1)); 1018 1007 } 1019 1008 1009 + static int dspi_slave_abort(struct spi_master *master) 1010 + { 1011 + struct fsl_dspi *dspi = spi_master_get_devdata(master); 1012 + 1013 + /* 1014 + * Terminate all pending DMA transactions for the SPI working 1015 + * in SLAVE mode. 1016 + */ 1017 + dmaengine_terminate_sync(dspi->dma->chan_rx); 1018 + dmaengine_terminate_sync(dspi->dma->chan_tx); 1019 + 1020 + /* Clear the internal DSPI RX and TX FIFO buffers */ 1021 + regmap_update_bits(dspi->regmap, SPI_MCR, 1022 + SPI_MCR_CLR_TXF | SPI_MCR_CLR_RXF, 1023 + SPI_MCR_CLR_TXF | SPI_MCR_CLR_RXF); 1024 + 1025 + return 0; 1026 + } 1027 + 1020 1028 static int dspi_probe(struct platform_device *pdev) 1021 1029 { 1022 1030 struct device_node *np = pdev->dev.of_node; ··· 1060 1030 ctlr->dev.of_node = pdev->dev.of_node; 1061 1031 1062 1032 ctlr->cleanup = dspi_cleanup; 1033 + ctlr->slave_abort = dspi_slave_abort; 1063 1034 ctlr->mode_bits = SPI_CPOL | SPI_CPHA | SPI_LSB_FIRST; 1064 1035 1065 1036 pdata = dev_get_platdata(&pdev->dev); ··· 1145 1114 1146 1115 dspi_init(dspi); 1147 1116 1117 + if (dspi->devtype_data->trans_mode == DSPI_TCFQ_MODE) 1118 + goto poll_mode; 1119 + 1148 1120 dspi->irq = platform_get_irq(pdev, 0); 1149 1121 if (dspi->irq <= 0) { 1150 1122 dev_info(&pdev->dev, ··· 1166 1132 init_waitqueue_head(&dspi->waitq); 1167 1133 1168 1134 poll_mode: 1135 + 1169 1136 if (dspi->devtype_data->trans_mode == DSPI_DMA_MODE) { 1170 1137 ret = dspi_request_dma(dspi, res->start); 1171 1138 if (ret < 0) { ··· 1177 1142 1178 1143 ctlr->max_speed_hz = 1179 1144 clk_get_rate(dspi->clk) / dspi->devtype_data->max_clock_factor; 1145 + 1146 + ctlr->ptp_sts_supported = dspi->devtype_data->ptp_sts_supported; 1180 1147 1181 1148 platform_set_drvdata(pdev, ctlr); 1182 1149
+14 -5
drivers/spi/spi-fsl-espi.c
··· 427 427 428 428 ret = fsl_espi_bufs(spi, trans); 429 429 430 - if (trans->delay_usecs) 431 - udelay(trans->delay_usecs); 430 + spi_transfer_delay_exec(trans); 432 431 433 432 return ret; 434 433 } ··· 436 437 struct spi_message *m) 437 438 { 438 439 unsigned int delay_usecs = 0, rx_nbits = 0; 440 + unsigned int delay_nsecs = 0, delay_nsecs1 = 0; 439 441 struct spi_transfer *t, trans = {}; 440 442 int ret; 441 443 ··· 445 445 goto out; 446 446 447 447 list_for_each_entry(t, &m->transfers, transfer_list) { 448 - if (t->delay_usecs > delay_usecs) 449 - delay_usecs = t->delay_usecs; 448 + if (t->delay_usecs) { 449 + if (t->delay_usecs > delay_usecs) { 450 + delay_usecs = t->delay_usecs; 451 + delay_nsecs = delay_usecs * 1000; 452 + } 453 + } else { 454 + delay_nsecs1 = spi_delay_to_ns(&t->delay, t); 455 + if (delay_nsecs1 > delay_nsecs) 456 + delay_nsecs = delay_nsecs1; 457 + } 450 458 if (t->rx_nbits > rx_nbits) 451 459 rx_nbits = t->rx_nbits; 452 460 } ··· 465 457 trans.len = m->frame_length; 466 458 trans.speed_hz = t->speed_hz; 467 459 trans.bits_per_word = t->bits_per_word; 468 - trans.delay_usecs = delay_usecs; 460 + trans.delay.value = delay_nsecs; 461 + trans.delay.unit = SPI_DELAY_UNIT_NSECS; 469 462 trans.rx_nbits = rx_nbits; 470 463 471 464 if (trans.len)
+4 -4
drivers/spi/spi-fsl-lpspi.c
··· 675 675 int ret; 676 676 677 677 /* Prepare for TX DMA: */ 678 - controller->dma_tx = dma_request_slave_channel_reason(dev, "tx"); 678 + controller->dma_tx = dma_request_chan(dev, "tx"); 679 679 if (IS_ERR(controller->dma_tx)) { 680 680 ret = PTR_ERR(controller->dma_tx); 681 681 dev_dbg(dev, "can't get the TX DMA channel, error %d!\n", ret); ··· 684 684 } 685 685 686 686 /* Prepare for RX DMA: */ 687 - controller->dma_rx = dma_request_slave_channel_reason(dev, "rx"); 687 + controller->dma_rx = dma_request_chan(dev, "rx"); 688 688 if (IS_ERR(controller->dma_rx)) { 689 689 ret = PTR_ERR(controller->dma_rx); 690 690 dev_dbg(dev, "can't get the RX DMA channel, error %d\n", ret); ··· 779 779 780 780 if (temp_SR & SR_FCF && (temp_IER & IER_FCIE)) { 781 781 writel(SR_FCF, fsl_lpspi->base + IMX7ULP_SR); 782 - complete(&fsl_lpspi->xfer_done); 782 + complete(&fsl_lpspi->xfer_done); 783 783 return IRQ_HANDLED; 784 784 } 785 785 ··· 938 938 ret = pm_runtime_get_sync(fsl_lpspi->dev); 939 939 if (ret < 0) { 940 940 dev_err(fsl_lpspi->dev, "failed to enable clock\n"); 941 - return ret; 941 + goto out_controller_put; 942 942 } 943 943 944 944 temp = readl(fsl_lpspi->base + IMX7ULP_PARAM);
+50 -5
drivers/spi/spi-fsl-qspi.c
··· 63 63 #define QUADSPI_IPCR 0x08 64 64 #define QUADSPI_IPCR_SEQID(x) ((x) << 24) 65 65 66 + #define QUADSPI_FLSHCR 0x0c 67 + #define QUADSPI_FLSHCR_TCSS_MASK GENMASK(3, 0) 68 + #define QUADSPI_FLSHCR_TCSH_MASK GENMASK(11, 8) 69 + #define QUADSPI_FLSHCR_TDH_MASK GENMASK(17, 16) 70 + 71 + #define QUADSPI_BUF0CR 0x10 72 + #define QUADSPI_BUF1CR 0x14 73 + #define QUADSPI_BUF2CR 0x18 74 + #define QUADSPI_BUFXCR_INVALID_MSTRID 0xe 75 + 66 76 #define QUADSPI_BUF3CR 0x1c 67 77 #define QUADSPI_BUF3CR_ALLMST_MASK BIT(31) 68 78 #define QUADSPI_BUF3CR_ADATSZ(x) ((x) << 8) ··· 105 95 #define QUADSPI_FR 0x160 106 96 #define QUADSPI_FR_TFF_MASK BIT(0) 107 97 98 + #define QUADSPI_RSER 0x164 99 + #define QUADSPI_RSER_TFIE BIT(0) 100 + 108 101 #define QUADSPI_SPTRCLR 0x16c 109 102 #define QUADSPI_SPTRCLR_IPPTRC BIT(8) 110 103 #define QUADSPI_SPTRCLR_BFPTRC BIT(0) ··· 124 111 #define QUADSPI_LCKCR 0x304 125 112 #define QUADSPI_LCKER_LOCK BIT(0) 126 113 #define QUADSPI_LCKER_UNLOCK BIT(1) 127 - 128 - #define QUADSPI_RSER 0x164 129 - #define QUADSPI_RSER_TFIE BIT(0) 130 114 131 115 #define QUADSPI_LUT_BASE 0x310 132 116 #define QUADSPI_LUT_OFFSET (SEQID_LUT * 4 * 4) ··· 191 181 */ 192 182 #define QUADSPI_QUIRK_BASE_INTERNAL BIT(4) 193 183 184 + /* 185 + * Controller uses TDH bits in register QUADSPI_FLSHCR. 186 + * They need to be set in accordance with the DDR/SDR mode. 187 + */ 188 + #define QUADSPI_QUIRK_USE_TDH_SETTING BIT(5) 189 + 194 190 struct fsl_qspi_devtype_data { 195 191 unsigned int rxfifo; 196 192 unsigned int txfifo; 193 + int invalid_mstrid; 197 194 unsigned int ahb_buf_size; 198 195 unsigned int quirks; 199 196 bool little_endian; ··· 209 192 static const struct fsl_qspi_devtype_data vybrid_data = { 210 193 .rxfifo = SZ_128, 211 194 .txfifo = SZ_64, 195 + .invalid_mstrid = QUADSPI_BUFXCR_INVALID_MSTRID, 212 196 .ahb_buf_size = SZ_1K, 213 197 .quirks = QUADSPI_QUIRK_SWAP_ENDIAN, 214 198 .little_endian = true, ··· 218 200 static const struct fsl_qspi_devtype_data imx6sx_data = { 219 201 .rxfifo = SZ_128, 220 202 .txfifo = SZ_512, 203 + .invalid_mstrid = QUADSPI_BUFXCR_INVALID_MSTRID, 221 204 .ahb_buf_size = SZ_1K, 222 205 .quirks = QUADSPI_QUIRK_4X_INT_CLK | QUADSPI_QUIRK_TKT245618, 223 206 .little_endian = true, ··· 227 208 static const struct fsl_qspi_devtype_data imx7d_data = { 228 209 .rxfifo = SZ_128, 229 210 .txfifo = SZ_512, 211 + .invalid_mstrid = QUADSPI_BUFXCR_INVALID_MSTRID, 230 212 .ahb_buf_size = SZ_1K, 231 - .quirks = QUADSPI_QUIRK_TKT253890 | QUADSPI_QUIRK_4X_INT_CLK, 213 + .quirks = QUADSPI_QUIRK_TKT253890 | QUADSPI_QUIRK_4X_INT_CLK | 214 + QUADSPI_QUIRK_USE_TDH_SETTING, 232 215 .little_endian = true, 233 216 }; 234 217 235 218 static const struct fsl_qspi_devtype_data imx6ul_data = { 236 219 .rxfifo = SZ_128, 237 220 .txfifo = SZ_512, 221 + .invalid_mstrid = QUADSPI_BUFXCR_INVALID_MSTRID, 238 222 .ahb_buf_size = SZ_1K, 239 - .quirks = QUADSPI_QUIRK_TKT253890 | QUADSPI_QUIRK_4X_INT_CLK, 223 + .quirks = QUADSPI_QUIRK_TKT253890 | QUADSPI_QUIRK_4X_INT_CLK | 224 + QUADSPI_QUIRK_USE_TDH_SETTING, 240 225 .little_endian = true, 241 226 }; 242 227 243 228 static const struct fsl_qspi_devtype_data ls1021a_data = { 244 229 .rxfifo = SZ_128, 245 230 .txfifo = SZ_64, 231 + .invalid_mstrid = QUADSPI_BUFXCR_INVALID_MSTRID, 246 232 .ahb_buf_size = SZ_1K, 247 233 .quirks = 0, 248 234 .little_endian = false, ··· 257 233 .rxfifo = SZ_128, 258 234 .txfifo = SZ_64, 259 235 .ahb_buf_size = SZ_1K, 236 + .invalid_mstrid = 0x0, 260 237 .quirks = QUADSPI_QUIRK_TKT253890 | QUADSPI_QUIRK_BASE_INTERNAL, 261 238 .little_endian = true, 262 239 }; ··· 298 273 static inline int needs_amba_base_offset(struct fsl_qspi *q) 299 274 { 300 275 return !(q->devtype_data->quirks & QUADSPI_QUIRK_BASE_INTERNAL); 276 + } 277 + 278 + static inline int needs_tdh_setting(struct fsl_qspi *q) 279 + { 280 + return q->devtype_data->quirks & QUADSPI_QUIRK_USE_TDH_SETTING; 301 281 } 302 282 303 283 /* ··· 645 615 void __iomem *base = q->iobase; 646 616 u32 addr_offset = 0; 647 617 int err = 0; 618 + int invalid_mstrid = q->devtype_data->invalid_mstrid; 648 619 649 620 mutex_lock(&q->lock); 650 621 ··· 668 637 669 638 qspi_writel(q, QUADSPI_SPTRCLR_BFPTRC | QUADSPI_SPTRCLR_IPPTRC, 670 639 base + QUADSPI_SPTRCLR); 640 + 641 + qspi_writel(q, invalid_mstrid, base + QUADSPI_BUF0CR); 642 + qspi_writel(q, invalid_mstrid, base + QUADSPI_BUF1CR); 643 + qspi_writel(q, invalid_mstrid, base + QUADSPI_BUF2CR); 671 644 672 645 fsl_qspi_prepare_lut(q, op); 673 646 ··· 744 709 /* Disable the module */ 745 710 qspi_writel(q, QUADSPI_MCR_MDIS_MASK | QUADSPI_MCR_RESERVED_MASK, 746 711 base + QUADSPI_MCR); 712 + 713 + /* 714 + * Previous boot stages (BootROM, bootloader) might have used DDR 715 + * mode and did not clear the TDH bits. As we currently use SDR mode 716 + * only, clear the TDH bits if necessary. 717 + */ 718 + if (needs_tdh_setting(q)) 719 + qspi_writel(q, qspi_readl(q, base + QUADSPI_FLSHCR) & 720 + ~QUADSPI_FLSHCR_TDH_MASK, 721 + base + QUADSPI_FLSHCR); 747 722 748 723 reg = qspi_readl(q, base + QUADSPI_SMPR); 749 724 qspi_writel(q, reg & ~(QUADSPI_SMPR_FSDLY_MASK
+1 -2
drivers/spi/spi-fsl-spi.c
··· 416 416 } 417 417 m->actual_length += t->len; 418 418 419 - if (t->delay_usecs) 420 - udelay(t->delay_usecs); 419 + spi_transfer_delay_exec(t); 421 420 422 421 if (cs_change) { 423 422 ndelay(nsecs);
+4 -5
drivers/spi/spi-gpio.c
··· 362 362 struct spi_gpio *spi_gpio; 363 363 struct device *dev = &pdev->dev; 364 364 struct spi_bitbang *bb; 365 - const struct of_device_id *of_id; 366 - 367 - of_id = of_match_device(spi_gpio_dt_ids, &pdev->dev); 368 365 369 366 master = spi_alloc_master(dev, sizeof(*spi_gpio)); 370 367 if (!master) 371 368 return -ENOMEM; 372 369 373 370 status = devm_add_action_or_reset(&pdev->dev, spi_gpio_put, master); 374 - if (status) 371 + if (status) { 372 + spi_master_put(master); 375 373 return status; 374 + } 376 375 377 - if (of_id) 376 + if (pdev->dev.of_node) 378 377 status = spi_gpio_probe_dt(pdev, master); 379 378 else 380 379 status = spi_gpio_probe_pdata(pdev, master);
+2
drivers/spi/spi-img-spfi.c
··· 673 673 dma_release_channel(spfi->tx_ch); 674 674 if (spfi->rx_ch) 675 675 dma_release_channel(spfi->rx_ch); 676 + spfi->tx_ch = NULL; 677 + spfi->rx_ch = NULL; 676 678 dev_warn(spfi->dev, "Failed to get DMA channels, falling back to PIO mode\n"); 677 679 } else { 678 680 master->dma_tx = spfi->tx_ch;
+2 -2
drivers/spi/spi-imx.c
··· 1272 1272 spi_imx->wml = spi_imx->devtype_data->fifo_size / 2; 1273 1273 1274 1274 /* Prepare for TX DMA: */ 1275 - master->dma_tx = dma_request_slave_channel_reason(dev, "tx"); 1275 + master->dma_tx = dma_request_chan(dev, "tx"); 1276 1276 if (IS_ERR(master->dma_tx)) { 1277 1277 ret = PTR_ERR(master->dma_tx); 1278 1278 dev_dbg(dev, "can't get the TX DMA channel, error %d!\n", ret); ··· 1281 1281 } 1282 1282 1283 1283 /* Prepare for RX : */ 1284 - master->dma_rx = dma_request_slave_channel_reason(dev, "rx"); 1284 + master->dma_rx = dma_request_chan(dev, "rx"); 1285 1285 if (IS_ERR(master->dma_rx)) { 1286 1286 ret = PTR_ERR(master->dma_rx); 1287 1287 dev_dbg(dev, "can't get the RX DMA channel, error %d\n", ret);
+1 -9
drivers/spi/spi-lantiq-ssc.c
··· 797 797 { 798 798 struct device *dev = &pdev->dev; 799 799 struct spi_master *master; 800 - struct resource *res; 801 800 struct lantiq_ssc_spi *spi; 802 801 const struct lantiq_ssc_hwcfg *hwcfg; 803 802 const struct of_device_id *match; ··· 810 811 return -EINVAL; 811 812 } 812 813 hwcfg = match->data; 813 - 814 - res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 815 - if (!res) { 816 - dev_err(dev, "failed to get resources\n"); 817 - return -ENXIO; 818 - } 819 814 820 815 rx_irq = platform_get_irq_byname(pdev, LTQ_SPI_RX_IRQ_NAME); 821 816 if (rx_irq < 0) ··· 832 839 spi->dev = dev; 833 840 spi->hwcfg = hwcfg; 834 841 platform_set_drvdata(pdev, spi); 835 - 836 - spi->regbase = devm_ioremap_resource(dev, res); 842 + spi->regbase = devm_platform_ioremap_resource(pdev, 0); 837 843 if (IS_ERR(spi->regbase)) { 838 844 err = PTR_ERR(spi->regbase); 839 845 goto err_master_put;
+9 -3
drivers/spi/spi-loopback-test.c
··· 298 298 { 299 299 .tx_buf = TX(0), 300 300 .rx_buf = RX(0), 301 - .delay_usecs = 1000, 301 + .delay = { 302 + .value = 1000, 303 + .unit = SPI_DELAY_UNIT_USECS, 304 + }, 302 305 }, 303 306 { 304 307 .tx_buf = TX(0), 305 308 .rx_buf = RX(0), 306 - .delay_usecs = 1000, 309 + .delay = { 310 + .value = 1000, 311 + .unit = SPI_DELAY_UNIT_USECS, 312 + }, 307 313 }, 308 314 }, 309 315 }, ··· 543 537 unsigned long long nbits = (unsigned long long)BITS_PER_BYTE * 544 538 xfer->len; 545 539 546 - delay_usecs += xfer->delay_usecs; 540 + delay_usecs += xfer->delay.value; 547 541 if (!xfer->speed_hz) 548 542 continue; 549 543 estimated_time += div_u64(nbits * NSEC_PER_SEC, xfer->speed_hz);
+1 -1
drivers/spi/spi-mem.c
··· 286 286 if (!spi_mem_internal_supports_op(mem, op)) 287 287 return -ENOTSUPP; 288 288 289 - if (ctlr->mem_ops) { 289 + if (ctlr->mem_ops && !mem->spi->cs_gpiod) { 290 290 ret = spi_mem_access_start(mem); 291 291 if (ret) 292 292 return ret;
+1 -2
drivers/spi/spi-mpc512x-psc.c
··· 311 311 break; 312 312 m->actual_length += t->len; 313 313 314 - if (t->delay_usecs) 315 - udelay(t->delay_usecs); 314 + spi_transfer_delay_exec(t); 316 315 317 316 if (cs_change) 318 317 mpc512x_psc_spi_deactivate_cs(spi);
+1 -2
drivers/spi/spi-mpc52xx-psc.c
··· 234 234 break; 235 235 m->actual_length += t->len; 236 236 237 - if (t->delay_usecs) 238 - udelay(t->delay_usecs); 237 + spi_transfer_delay_exec(t); 239 238 240 239 if (cs_change) 241 240 mpc52xx_psc_spi_deactivate_cs(spi);
+11 -12
drivers/spi/spi-mt65xx.c
··· 139 139 * supplies it. 140 140 */ 141 141 static const struct mtk_chip_config mtk_default_chip_info = { 142 - .cs_pol = 0, 143 142 .sample_sel = 0, 144 143 }; 145 144 ··· 229 230 #endif 230 231 231 232 if (mdata->dev_comp->enhance_timing) { 232 - if (chip_config->cs_pol) 233 + /* set CS polarity */ 234 + if (spi->mode & SPI_CS_HIGH) 233 235 reg_val |= SPI_CMD_CS_POL; 234 236 else 235 237 reg_val &= ~SPI_CMD_CS_POL; 238 + 236 239 if (chip_config->sample_sel) 237 240 reg_val |= SPI_CMD_SAMPLE_SEL; 238 241 else ··· 264 263 { 265 264 u32 reg_val; 266 265 struct mtk_spi *mdata = spi_master_get_devdata(spi->master); 266 + 267 + if (spi->mode & SPI_CS_HIGH) 268 + enable = !enable; 267 269 268 270 reg_val = readl(mdata->base + SPI_CMD_REG); 269 271 if (!enable) { ··· 623 619 struct spi_master *master; 624 620 struct mtk_spi *mdata; 625 621 const struct of_device_id *of_id; 626 - struct resource *res; 627 622 int i, irq, ret, addr_bits; 628 623 629 624 master = spi_alloc_master(&pdev->dev, sizeof(*mdata)); ··· 650 647 651 648 mdata = spi_master_get_devdata(master); 652 649 mdata->dev_comp = of_id->data; 650 + 651 + if (mdata->dev_comp->enhance_timing) 652 + master->mode_bits |= SPI_CS_HIGH; 653 + 653 654 if (mdata->dev_comp->must_tx) 654 655 master->flags = SPI_MASTER_MUST_TX; 655 656 ··· 689 682 } 690 683 691 684 platform_set_drvdata(pdev, master); 692 - 693 - res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 694 - if (!res) { 695 - ret = -ENODEV; 696 - dev_err(&pdev->dev, "failed to determine base address\n"); 697 - goto err_put_master; 698 - } 699 - 700 - mdata->base = devm_ioremap_resource(&pdev->dev, res); 685 + mdata->base = devm_platform_ioremap_resource(pdev, 0); 701 686 if (IS_ERR(mdata->base)) { 702 687 ret = PTR_ERR(mdata->base); 703 688 goto err_put_master;
+4 -4
drivers/spi/spi-mxic.c
··· 145 145 #define LWR_SUSP_CTRL_EN BIT(31) 146 146 147 147 #define DMAS_CTRL 0x9c 148 - #define DMAS_CTRL_DIR_READ BIT(31) 149 - #define DMAS_CTRL_EN BIT(30) 148 + #define DMAS_CTRL_EN BIT(31) 149 + #define DMAS_CTRL_DIR_READ BIT(30) 150 150 151 151 #define DATA_STROB 0xa0 152 152 #define DATA_STROB_EDO_EN BIT(2) ··· 275 275 writel(0, mxic->regs + HC_EN); 276 276 writel(0, mxic->regs + LRD_CFG); 277 277 writel(0, mxic->regs + LRD_CTRL); 278 - writel(HC_CFG_NIO(1) | HC_CFG_TYPE(0, HC_CFG_TYPE_SPI_NAND) | 278 + writel(HC_CFG_NIO(1) | HC_CFG_TYPE(0, HC_CFG_TYPE_SPI_NOR) | 279 279 HC_CFG_SLV_ACT(0) | HC_CFG_MAN_CS_EN | HC_CFG_IDLE_SIO_LVL(1), 280 280 mxic->regs + HC_CFG); 281 281 } ··· 346 346 if (op->addr.nbytes > 7) 347 347 return false; 348 348 349 - return true; 349 + return spi_mem_default_supports_op(mem, op); 350 350 } 351 351 352 352 static int mxic_spi_mem_exec_op(struct spi_mem *mem,
+1 -2
drivers/spi/spi-npcm-pspi.c
··· 293 293 static irqreturn_t npcm_pspi_handler(int irq, void *dev_id) 294 294 { 295 295 struct npcm_pspi *priv = dev_id; 296 - u16 val; 297 296 u8 stat; 298 297 299 298 stat = ioread8(priv->base + NPCM_PSPI_STAT); ··· 302 303 303 304 if (priv->tx_buf) { 304 305 if (stat & NPCM_PSPI_STAT_RBF) { 305 - val = ioread8(NPCM_PSPI_DATA + priv->base); 306 + ioread8(NPCM_PSPI_DATA + priv->base); 306 307 if (priv->tx_bytes == 0) { 307 308 npcm_pspi_disable(priv); 308 309 complete(&priv->xfer_done);
+1 -1
drivers/spi/spi-nxp-fspi.c
··· 1027 1027 1028 1028 ctlr->dev.of_node = np; 1029 1029 1030 - ret = spi_register_controller(ctlr); 1030 + ret = devm_spi_register_controller(&pdev->dev, ctlr); 1031 1031 if (ret) 1032 1032 goto err_destroy_mutex; 1033 1033
+3 -4
drivers/spi/spi-omap-100k.c
··· 128 128 129 129 static int spi100k_read_data(struct spi_master *master, int len) 130 130 { 131 - int dataH, dataL; 131 + int dataL; 132 132 struct omap1_spi100k *spi100k = spi_master_get_devdata(master); 133 133 134 134 /* Always do at least 16 bits */ ··· 146 146 udelay(1000); 147 147 148 148 dataL = readw(spi100k->base + SPI_RX_LSB); 149 - dataH = readw(spi100k->base + SPI_RX_MSB); 149 + readw(spi100k->base + SPI_RX_MSB); 150 150 spi100k_disable_clock(master); 151 151 152 152 return dataL; ··· 321 321 } 322 322 } 323 323 324 - if (t->delay_usecs) 325 - udelay(t->delay_usecs); 324 + spi_transfer_delay_exec(t); 326 325 327 326 /* ignore the "leave it on after last xfer" hint */ 328 327
+47 -58
drivers/spi/spi-omap2-mcspi.c
··· 397 397 { 398 398 struct omap2_mcspi *mcspi; 399 399 struct omap2_mcspi_dma *mcspi_dma; 400 + struct dma_async_tx_descriptor *tx; 400 401 401 402 mcspi = spi_master_get_devdata(spi->master); 402 403 mcspi_dma = &mcspi->dma_channels[spi->chip_select]; 403 404 404 - if (mcspi_dma->dma_tx) { 405 - struct dma_async_tx_descriptor *tx; 405 + dmaengine_slave_config(mcspi_dma->dma_tx, &cfg); 406 406 407 - dmaengine_slave_config(mcspi_dma->dma_tx, &cfg); 408 - 409 - tx = dmaengine_prep_slave_sg(mcspi_dma->dma_tx, xfer->tx_sg.sgl, 410 - xfer->tx_sg.nents, 411 - DMA_MEM_TO_DEV, 412 - DMA_PREP_INTERRUPT | DMA_CTRL_ACK); 413 - if (tx) { 414 - tx->callback = omap2_mcspi_tx_callback; 415 - tx->callback_param = spi; 416 - dmaengine_submit(tx); 417 - } else { 418 - /* FIXME: fall back to PIO? */ 419 - } 407 + tx = dmaengine_prep_slave_sg(mcspi_dma->dma_tx, xfer->tx_sg.sgl, 408 + xfer->tx_sg.nents, 409 + DMA_MEM_TO_DEV, 410 + DMA_PREP_INTERRUPT | DMA_CTRL_ACK); 411 + if (tx) { 412 + tx->callback = omap2_mcspi_tx_callback; 413 + tx->callback_param = spi; 414 + dmaengine_submit(tx); 415 + } else { 416 + /* FIXME: fall back to PIO? */ 420 417 } 421 418 dma_async_issue_pending(mcspi_dma->dma_tx); 422 419 omap2_mcspi_set_dma_req(spi, 0, 1); 423 - 424 420 } 425 421 426 422 static unsigned ··· 435 439 int word_len, element_count; 436 440 struct omap2_mcspi_cs *cs = spi->controller_state; 437 441 void __iomem *chstat_reg = cs->base + OMAP2_MCSPI_CHSTAT0; 442 + struct dma_async_tx_descriptor *tx; 438 443 439 444 mcspi = spi_master_get_devdata(spi->master); 440 445 mcspi_dma = &mcspi->dma_channels[spi->chip_select]; ··· 459 462 else /* word_len <= 32 */ 460 463 element_count = count >> 2; 461 464 462 - if (mcspi_dma->dma_rx) { 463 - struct dma_async_tx_descriptor *tx; 464 465 465 - dmaengine_slave_config(mcspi_dma->dma_rx, &cfg); 466 + dmaengine_slave_config(mcspi_dma->dma_rx, &cfg); 466 467 468 + /* 469 + * Reduce DMA transfer length by one more if McSPI is 470 + * configured in turbo mode. 471 + */ 472 + if ((l & OMAP2_MCSPI_CHCONF_TURBO) && mcspi->fifo_depth == 0) 473 + transfer_reduction += es; 474 + 475 + if (transfer_reduction) { 476 + /* Split sgl into two. The second sgl won't be used. */ 477 + sizes[0] = count - transfer_reduction; 478 + sizes[1] = transfer_reduction; 479 + nb_sizes = 2; 480 + } else { 467 481 /* 468 - * Reduce DMA transfer length by one more if McSPI is 469 - * configured in turbo mode. 482 + * Don't bother splitting the sgl. This essentially 483 + * clones the original sgl. 470 484 */ 471 - if ((l & OMAP2_MCSPI_CHCONF_TURBO) && mcspi->fifo_depth == 0) 472 - transfer_reduction += es; 485 + sizes[0] = count; 486 + nb_sizes = 1; 487 + } 473 488 474 - if (transfer_reduction) { 475 - /* Split sgl into two. The second sgl won't be used. */ 476 - sizes[0] = count - transfer_reduction; 477 - sizes[1] = transfer_reduction; 478 - nb_sizes = 2; 479 - } else { 480 - /* 481 - * Don't bother splitting the sgl. This essentially 482 - * clones the original sgl. 483 - */ 484 - sizes[0] = count; 485 - nb_sizes = 1; 486 - } 489 + ret = sg_split(xfer->rx_sg.sgl, xfer->rx_sg.nents, 0, nb_sizes, 490 + sizes, sg_out, out_mapped_nents, GFP_KERNEL); 487 491 488 - ret = sg_split(xfer->rx_sg.sgl, xfer->rx_sg.nents, 489 - 0, nb_sizes, 490 - sizes, 491 - sg_out, out_mapped_nents, 492 - GFP_KERNEL); 492 + if (ret < 0) { 493 + dev_err(&spi->dev, "sg_split failed\n"); 494 + return 0; 495 + } 493 496 494 - if (ret < 0) { 495 - dev_err(&spi->dev, "sg_split failed\n"); 496 - return 0; 497 - } 498 - 499 - tx = dmaengine_prep_slave_sg(mcspi_dma->dma_rx, 500 - sg_out[0], 501 - out_mapped_nents[0], 502 - DMA_DEV_TO_MEM, 503 - DMA_PREP_INTERRUPT | DMA_CTRL_ACK); 504 - if (tx) { 505 - tx->callback = omap2_mcspi_rx_callback; 506 - tx->callback_param = spi; 507 - dmaengine_submit(tx); 508 - } else { 509 - /* FIXME: fall back to PIO? */ 510 - } 497 + tx = dmaengine_prep_slave_sg(mcspi_dma->dma_rx, sg_out[0], 498 + out_mapped_nents[0], DMA_DEV_TO_MEM, 499 + DMA_PREP_INTERRUPT | DMA_CTRL_ACK); 500 + if (tx) { 501 + tx->callback = omap2_mcspi_rx_callback; 502 + tx->callback_param = spi; 503 + dmaengine_submit(tx); 504 + } else { 505 + /* FIXME: fall back to PIO? */ 511 506 } 512 507 513 508 dma_async_issue_pending(mcspi_dma->dma_rx);
+2 -7
drivers/spi/spi-orion.c
··· 467 467 if (orion_spi_write_read_8bit(spi, &tx, &rx) < 0) 468 468 goto out; 469 469 count--; 470 - if (xfer->word_delay_usecs) 471 - udelay(xfer->word_delay_usecs); 470 + spi_delay_exec(&xfer->word_delay, xfer); 472 471 } while (count); 473 472 } else if (word_len == 16) { 474 473 const u16 *tx = xfer->tx_buf; ··· 477 478 if (orion_spi_write_read_16bit(spi, &tx, &rx) < 0) 478 479 goto out; 479 480 count -= 2; 480 - if (xfer->word_delay_usecs) 481 - udelay(xfer->word_delay_usecs); 481 + spi_delay_exec(&xfer->word_delay, xfer); 482 482 } while (count); 483 483 } 484 484 ··· 769 771 status = orion_spi_reset(spi); 770 772 if (status < 0) 771 773 goto out_rel_pm; 772 - 773 - pm_runtime_mark_last_busy(&pdev->dev); 774 - pm_runtime_put_autosuspend(&pdev->dev); 775 774 776 775 master->dev.of_node = pdev->dev.of_node; 777 776 status = spi_register_master(master);
+30 -16
drivers/spi/spi-pic32.c
··· 606 606 gpio_direction_output(spi->cs_gpio, !(spi->mode & SPI_CS_HIGH)); 607 607 } 608 608 609 - static void pic32_spi_dma_prep(struct pic32_spi *pic32s, struct device *dev) 609 + static int pic32_spi_dma_prep(struct pic32_spi *pic32s, struct device *dev) 610 610 { 611 611 struct spi_master *master = pic32s->master; 612 - dma_cap_mask_t mask; 612 + int ret = 0; 613 613 614 - dma_cap_zero(mask); 615 - dma_cap_set(DMA_SLAVE, mask); 614 + master->dma_rx = dma_request_chan(dev, "spi-rx"); 615 + if (IS_ERR(master->dma_rx)) { 616 + if (PTR_ERR(master->dma_rx) == -EPROBE_DEFER) 617 + ret = -EPROBE_DEFER; 618 + else 619 + dev_warn(dev, "RX channel not found.\n"); 616 620 617 - master->dma_rx = dma_request_slave_channel_compat(mask, NULL, NULL, 618 - dev, "spi-rx"); 619 - if (!master->dma_rx) { 620 - dev_warn(dev, "RX channel not found.\n"); 621 + master->dma_rx = NULL; 621 622 goto out_err; 622 623 } 623 624 624 - master->dma_tx = dma_request_slave_channel_compat(mask, NULL, NULL, 625 - dev, "spi-tx"); 626 - if (!master->dma_tx) { 627 - dev_warn(dev, "TX channel not found.\n"); 625 + master->dma_tx = dma_request_chan(dev, "spi-tx"); 626 + if (IS_ERR(master->dma_tx)) { 627 + if (PTR_ERR(master->dma_tx) == -EPROBE_DEFER) 628 + ret = -EPROBE_DEFER; 629 + else 630 + dev_warn(dev, "TX channel not found.\n"); 631 + 632 + master->dma_tx = NULL; 628 633 goto out_err; 629 634 } 630 635 ··· 639 634 /* DMA chnls allocated and prepared */ 640 635 set_bit(PIC32F_DMA_PREP, &pic32s->flags); 641 636 642 - return; 637 + return 0; 643 638 644 639 out_err: 645 - if (master->dma_rx) 640 + if (master->dma_rx) { 646 641 dma_release_channel(master->dma_rx); 642 + master->dma_rx = NULL; 643 + } 647 644 648 - if (master->dma_tx) 645 + if (master->dma_tx) { 649 646 dma_release_channel(master->dma_tx); 647 + master->dma_tx = NULL; 648 + } 649 + 650 + return ret; 650 651 } 651 652 652 653 static void pic32_spi_dma_unprep(struct pic32_spi *pic32s) ··· 787 776 master->unprepare_transfer_hardware = pic32_spi_unprepare_hardware; 788 777 789 778 /* optional DMA support */ 790 - pic32_spi_dma_prep(pic32s, &pdev->dev); 779 + ret = pic32_spi_dma_prep(pic32s, &pdev->dev); 780 + if (ret) 781 + goto err_bailout; 782 + 791 783 if (test_bit(PIC32F_DMA_PREP, &pic32s->flags)) 792 784 master->can_dma = pic32_spi_can_dma; 793 785
+13 -16
drivers/spi/spi-pl022.c
··· 485 485 struct spi_transfer, transfer_list); 486 486 487 487 /* Delay if requested before any change in chip select */ 488 - if (last_transfer->delay_usecs) 489 - /* 490 - * FIXME: This runs in interrupt context. 491 - * Is this really smart? 492 - */ 493 - udelay(last_transfer->delay_usecs); 488 + /* 489 + * FIXME: This runs in interrupt context. 490 + * Is this really smart? 491 + */ 492 + spi_transfer_delay_exec(last_transfer); 494 493 495 494 if (!last_transfer->cs_change) { 496 495 struct spi_message *next_msg; ··· 1158 1159 int err; 1159 1160 1160 1161 /* automatically configure DMA channels from platform, normally using DT */ 1161 - chan = dma_request_slave_channel_reason(dev, "rx"); 1162 + chan = dma_request_chan(dev, "rx"); 1162 1163 if (IS_ERR(chan)) { 1163 1164 err = PTR_ERR(chan); 1164 1165 goto err_no_rxchan; ··· 1166 1167 1167 1168 pl022->dma_rx_channel = chan; 1168 1169 1169 - chan = dma_request_slave_channel_reason(dev, "tx"); 1170 + chan = dma_request_chan(dev, "tx"); 1170 1171 if (IS_ERR(chan)) { 1171 1172 err = PTR_ERR(chan); 1172 1173 goto err_no_txchan; ··· 1400 1401 previous = list_entry(transfer->transfer_list.prev, 1401 1402 struct spi_transfer, 1402 1403 transfer_list); 1403 - if (previous->delay_usecs) 1404 - /* 1405 - * FIXME: This runs in interrupt context. 1406 - * Is this really smart? 1407 - */ 1408 - udelay(previous->delay_usecs); 1404 + /* 1405 + * FIXME: This runs in interrupt context. 1406 + * Is this really smart? 1407 + */ 1408 + spi_transfer_delay_exec(previous); 1409 1409 1410 1410 /* Reselect chip select only if cs_change was requested */ 1411 1411 if (previous->cs_change) ··· 1518 1520 previous = 1519 1521 list_entry(transfer->transfer_list.prev, 1520 1522 struct spi_transfer, transfer_list); 1521 - if (previous->delay_usecs) 1522 - udelay(previous->delay_usecs); 1523 + spi_transfer_delay_exec(previous); 1523 1524 if (previous->cs_change) 1524 1525 pl022_cs_control(pl022, SSP_CHIP_SELECT); 1525 1526 } else {
+53 -46
drivers/spi/spi-pxa2xx.c
··· 4 4 * Copyright (C) 2013, Intel Corporation 5 5 */ 6 6 7 + #include <linux/acpi.h> 7 8 #include <linux/bitops.h> 8 - #include <linux/init.h> 9 - #include <linux/module.h> 9 + #include <linux/clk.h> 10 + #include <linux/delay.h> 10 11 #include <linux/device.h> 11 - #include <linux/ioport.h> 12 - #include <linux/errno.h> 13 12 #include <linux/err.h> 13 + #include <linux/errno.h> 14 + #include <linux/gpio/consumer.h> 15 + #include <linux/gpio.h> 16 + #include <linux/init.h> 14 17 #include <linux/interrupt.h> 18 + #include <linux/ioport.h> 15 19 #include <linux/kernel.h> 20 + #include <linux/module.h> 21 + #include <linux/mod_devicetable.h> 22 + #include <linux/of.h> 16 23 #include <linux/pci.h> 17 24 #include <linux/platform_device.h> 25 + #include <linux/pm_runtime.h> 26 + #include <linux/property.h> 27 + #include <linux/slab.h> 18 28 #include <linux/spi/pxa2xx_spi.h> 19 29 #include <linux/spi/spi.h> 20 - #include <linux/delay.h> 21 - #include <linux/gpio.h> 22 - #include <linux/gpio/consumer.h> 23 - #include <linux/slab.h> 24 - #include <linux/clk.h> 25 - #include <linux/pm_runtime.h> 26 - #include <linux/acpi.h> 27 - #include <linux/of_device.h> 28 30 29 31 #include "spi-pxa2xx.h" 30 32 ··· 1459 1457 { PCI_VDEVICE(INTEL, 0x02aa), LPSS_CNL_SSP }, 1460 1458 { PCI_VDEVICE(INTEL, 0x02ab), LPSS_CNL_SSP }, 1461 1459 { PCI_VDEVICE(INTEL, 0x02fb), LPSS_CNL_SSP }, 1460 + /* CML-H */ 1461 + { PCI_VDEVICE(INTEL, 0x06aa), LPSS_CNL_SSP }, 1462 + { PCI_VDEVICE(INTEL, 0x06ab), LPSS_CNL_SSP }, 1463 + { PCI_VDEVICE(INTEL, 0x06fb), LPSS_CNL_SSP }, 1462 1464 /* TGL-LP */ 1463 1465 { PCI_VDEVICE(INTEL, 0xa0aa), LPSS_CNL_SSP }, 1464 1466 { PCI_VDEVICE(INTEL, 0xa0ab), LPSS_CNL_SSP }, ··· 1482 1476 1483 1477 #ifdef CONFIG_ACPI 1484 1478 1485 - static int pxa2xx_spi_get_port_id(struct acpi_device *adev) 1479 + static int pxa2xx_spi_get_port_id(struct device *dev) 1486 1480 { 1481 + struct acpi_device *adev; 1487 1482 unsigned int devid; 1488 1483 int port_id = -1; 1489 1484 1485 + adev = ACPI_COMPANION(dev); 1490 1486 if (adev && adev->pnp.unique_id && 1491 1487 !kstrtouint(adev->pnp.unique_id, 0, &devid)) 1492 1488 port_id = devid; ··· 1497 1489 1498 1490 #else /* !CONFIG_ACPI */ 1499 1491 1500 - static int pxa2xx_spi_get_port_id(struct acpi_device *adev) 1492 + static int pxa2xx_spi_get_port_id(struct device *dev) 1501 1493 { 1502 1494 return -1; 1503 1495 } ··· 1518 1510 pxa2xx_spi_init_pdata(struct platform_device *pdev) 1519 1511 { 1520 1512 struct pxa2xx_spi_controller *pdata; 1521 - struct acpi_device *adev; 1522 1513 struct ssp_device *ssp; 1523 1514 struct resource *res; 1524 - const struct acpi_device_id *adev_id = NULL; 1515 + struct device *parent = pdev->dev.parent; 1516 + struct pci_dev *pcidev = dev_is_pci(parent) ? to_pci_dev(parent) : NULL; 1525 1517 const struct pci_device_id *pcidev_id = NULL; 1526 - const struct of_device_id *of_id = NULL; 1527 1518 enum pxa_ssp_type type; 1519 + const void *match; 1528 1520 1529 - adev = ACPI_COMPANION(&pdev->dev); 1521 + if (pcidev) 1522 + pcidev_id = pci_match_id(pxa2xx_spi_pci_compound_match, pcidev); 1530 1523 1531 - if (pdev->dev.of_node) 1532 - of_id = of_match_device(pdev->dev.driver->of_match_table, 1533 - &pdev->dev); 1534 - else if (dev_is_pci(pdev->dev.parent)) 1535 - pcidev_id = pci_match_id(pxa2xx_spi_pci_compound_match, 1536 - to_pci_dev(pdev->dev.parent)); 1537 - else if (adev) 1538 - adev_id = acpi_match_device(pdev->dev.driver->acpi_match_table, 1539 - &pdev->dev); 1540 - else 1541 - return NULL; 1542 - 1543 - if (adev_id) 1544 - type = (enum pxa_ssp_type)adev_id->driver_data; 1524 + match = device_get_match_data(&pdev->dev); 1525 + if (match) 1526 + type = (enum pxa_ssp_type)match; 1545 1527 else if (pcidev_id) 1546 1528 type = (enum pxa_ssp_type)pcidev_id->driver_data; 1547 - else if (of_id) 1548 - type = (enum pxa_ssp_type)of_id->data; 1549 1529 else 1550 1530 return NULL; 1551 1531 ··· 1541 1545 if (!pdata) 1542 1546 return NULL; 1543 1547 1544 - res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 1545 - if (!res) 1546 - return NULL; 1547 - 1548 1548 ssp = &pdata->ssp; 1549 1549 1550 - ssp->phys_base = res->start; 1550 + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 1551 1551 ssp->mmio_base = devm_ioremap_resource(&pdev->dev, res); 1552 1552 if (IS_ERR(ssp->mmio_base)) 1553 1553 return NULL; 1554 1554 1555 + ssp->phys_base = res->start; 1556 + 1555 1557 #ifdef CONFIG_PCI 1556 1558 if (pcidev_id) { 1557 - pdata->tx_param = pdev->dev.parent; 1558 - pdata->rx_param = pdev->dev.parent; 1559 + pdata->tx_param = parent; 1560 + pdata->rx_param = parent; 1559 1561 pdata->dma_filter = pxa2xx_spi_idma_filter; 1560 1562 } 1561 1563 #endif 1562 1564 1563 1565 ssp->clk = devm_clk_get(&pdev->dev, NULL); 1564 - ssp->irq = platform_get_irq(pdev, 0); 1565 - ssp->type = type; 1566 - ssp->pdev = pdev; 1567 - ssp->port_id = pxa2xx_spi_get_port_id(adev); 1566 + if (IS_ERR(ssp->clk)) 1567 + return NULL; 1568 1568 1569 - pdata->is_slave = of_property_read_bool(pdev->dev.of_node, "spi-slave"); 1569 + ssp->irq = platform_get_irq(pdev, 0); 1570 + if (ssp->irq < 0) 1571 + return NULL; 1572 + 1573 + ssp->type = type; 1574 + ssp->dev = &pdev->dev; 1575 + ssp->port_id = pxa2xx_spi_get_port_id(&pdev->dev); 1576 + 1577 + pdata->is_slave = device_property_read_bool(&pdev->dev, "spi-slave"); 1570 1578 pdata->num_chipselect = 1; 1571 1579 pdata->enable_dma = true; 1572 1580 pdata->dma_burst_size = 1; ··· 1600 1600 } 1601 1601 1602 1602 return cs; 1603 + } 1604 + 1605 + static size_t pxa2xx_spi_max_dma_transfer_size(struct spi_device *spi) 1606 + { 1607 + return MAX_DMA_LEN; 1603 1608 } 1604 1609 1605 1610 static int pxa2xx_spi_probe(struct platform_device *pdev) ··· 1712 1707 } else { 1713 1708 controller->can_dma = pxa2xx_spi_can_dma; 1714 1709 controller->max_dma_len = MAX_DMA_LEN; 1710 + controller->max_transfer_size = 1711 + pxa2xx_spi_max_dma_transfer_size; 1715 1712 } 1716 1713 } 1717 1714
+2 -2
drivers/spi/spi-qup.c
··· 932 932 int ret; 933 933 934 934 /* allocate dma resources, if available */ 935 - master->dma_rx = dma_request_slave_channel_reason(dev, "rx"); 935 + master->dma_rx = dma_request_chan(dev, "rx"); 936 936 if (IS_ERR(master->dma_rx)) 937 937 return PTR_ERR(master->dma_rx); 938 938 939 - master->dma_tx = dma_request_slave_channel_reason(dev, "tx"); 939 + master->dma_tx = dma_request_chan(dev, "tx"); 940 940 if (IS_ERR(master->dma_tx)) { 941 941 ret = PTR_ERR(master->dma_tx); 942 942 goto err_tx;
+2 -6
drivers/spi/spi-rspi.c
··· 1257 1257 ctlr->flags = ops->flags; 1258 1258 ctlr->dev.of_node = pdev->dev.of_node; 1259 1259 1260 - ret = platform_get_irq_byname(pdev, "rx"); 1260 + ret = platform_get_irq_byname_optional(pdev, "rx"); 1261 1261 if (ret < 0) { 1262 - ret = platform_get_irq_byname(pdev, "mux"); 1262 + ret = platform_get_irq_byname_optional(pdev, "mux"); 1263 1263 if (ret < 0) 1264 1264 ret = platform_get_irq(pdev, 0); 1265 1265 if (ret >= 0) ··· 1269 1269 ret = platform_get_irq_byname(pdev, "tx"); 1270 1270 if (ret >= 0) 1271 1271 rspi->tx_irq = ret; 1272 - } 1273 - if (ret < 0) { 1274 - dev_err(&pdev->dev, "platform_get_irq error\n"); 1275 - goto error2; 1276 1272 } 1277 1273 1278 1274 if (rspi->rx_irq == rspi->tx_irq) {
+2 -4
drivers/spi/spi-s3c64xx.c
··· 1154 1154 1155 1155 if (!is_polling(sdd)) { 1156 1156 /* Acquire DMA channels */ 1157 - sdd->rx_dma.ch = dma_request_slave_channel_reason(&pdev->dev, 1158 - "rx"); 1157 + sdd->rx_dma.ch = dma_request_chan(&pdev->dev, "rx"); 1159 1158 if (IS_ERR(sdd->rx_dma.ch)) { 1160 1159 dev_err(&pdev->dev, "Failed to get RX DMA channel\n"); 1161 1160 ret = PTR_ERR(sdd->rx_dma.ch); 1162 1161 goto err_disable_io_clk; 1163 1162 } 1164 - sdd->tx_dma.ch = dma_request_slave_channel_reason(&pdev->dev, 1165 - "tx"); 1163 + sdd->tx_dma.ch = dma_request_chan(&pdev->dev, "tx"); 1166 1164 if (IS_ERR(sdd->tx_dma.ch)) { 1167 1165 dev_err(&pdev->dev, "Failed to get TX DMA channel\n"); 1168 1166 ret = PTR_ERR(sdd->tx_dma.ch);
+1 -2
drivers/spi/spi-sc18is602.c
··· 211 211 } 212 212 status = 0; 213 213 214 - if (t->delay_usecs) 215 - udelay(t->delay_usecs); 214 + spi_transfer_delay_exec(t); 216 215 } 217 216 m->status = status; 218 217 spi_finalize_current_message(master);
+1 -2
drivers/spi/spi-sh-hspi.c
··· 190 190 191 191 msg->actual_length += t->len; 192 192 193 - if (t->delay_usecs) 194 - udelay(t->delay_usecs); 193 + spi_transfer_delay_exec(t); 195 194 196 195 if (cs_change) { 197 196 ndelay(nsecs);
+7 -4
drivers/spi/spi-sifive.c
··· 357 357 if (!cs_bits) { 358 358 dev_err(&pdev->dev, "Could not auto probe CS lines\n"); 359 359 ret = -EINVAL; 360 - goto put_master; 360 + goto disable_clk; 361 361 } 362 362 363 363 num_cs = ilog2(cs_bits) + 1; 364 364 if (num_cs > SIFIVE_SPI_MAX_CS) { 365 365 dev_err(&pdev->dev, "Invalid number of spi slaves\n"); 366 366 ret = -EINVAL; 367 - goto put_master; 367 + goto disable_clk; 368 368 } 369 369 370 370 /* Define our master */ ··· 393 393 dev_name(&pdev->dev), spi); 394 394 if (ret) { 395 395 dev_err(&pdev->dev, "Unable to bind to interrupt\n"); 396 - goto put_master; 396 + goto disable_clk; 397 397 } 398 398 399 399 dev_info(&pdev->dev, "mapped; irq=%d, cs=%d\n", ··· 402 402 ret = devm_spi_register_master(&pdev->dev, master); 403 403 if (ret < 0) { 404 404 dev_err(&pdev->dev, "spi_register_master failed\n"); 405 - goto put_master; 405 + goto disable_clk; 406 406 } 407 407 408 408 return 0; 409 409 410 + disable_clk: 411 + clk_disable_unprepare(spi->clk); 410 412 put_master: 411 413 spi_master_put(master); 412 414 ··· 422 420 423 421 /* Disable all the interrupts just in case */ 424 422 sifive_spi_write(spi, SIFIVE_SPI_REG_IE, 0); 423 + clk_disable_unprepare(spi->clk); 425 424 426 425 return 0; 427 426 }
+1 -11
drivers/spi/spi-slave-mt27xx.c
··· 368 368 { 369 369 struct spi_controller *ctlr; 370 370 struct mtk_spi_slave *mdata; 371 - struct resource *res; 372 371 int irq, ret; 373 372 374 373 ctlr = spi_alloc_slave(&pdev->dev, sizeof(*mdata)); ··· 391 392 platform_set_drvdata(pdev, ctlr); 392 393 393 394 init_completion(&mdata->xfer_done); 394 - 395 - res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 396 - if (!res) { 397 - ret = -ENODEV; 398 - dev_err(&pdev->dev, "failed to determine base address\n"); 399 - goto err_put_ctlr; 400 - } 401 - 402 395 mdata->dev = &pdev->dev; 403 - 404 - mdata->base = devm_ioremap_resource(&pdev->dev, res); 396 + mdata->base = devm_platform_ioremap_resource(pdev, 0); 405 397 if (IS_ERR(mdata->base)) { 406 398 ret = PTR_ERR(mdata->base); 407 399 goto err_put_ctlr;
+8
drivers/spi/spi-sprd-adi.c
··· 77 77 78 78 /* Bits definitions for register REG_WDG_CTRL */ 79 79 #define BIT_WDG_RUN BIT(1) 80 + #define BIT_WDG_NEW BIT(2) 80 81 #define BIT_WDG_RST BIT(3) 81 82 82 83 /* Registers definitions for PMIC */ ··· 384 383 /* Unlock the watchdog */ 385 384 sprd_adi_write(sadi, sadi->slave_pbase + REG_WDG_LOCK, WDG_UNLOCK_KEY); 386 385 386 + sprd_adi_read(sadi, sadi->slave_pbase + REG_WDG_CTRL, &val); 387 + val |= BIT_WDG_NEW; 388 + sprd_adi_write(sadi, sadi->slave_pbase + REG_WDG_CTRL, val); 389 + 387 390 /* Load the watchdog timeout value, 50ms is always enough. */ 388 391 sprd_adi_write(sadi, sadi->slave_pbase + REG_WDG_LOAD_LOW, 389 392 WDG_LOAD_VAL & WDG_LOAD_MASK); ··· 397 392 sprd_adi_read(sadi, sadi->slave_pbase + REG_WDG_CTRL, &val); 398 393 val |= BIT_WDG_RUN | BIT_WDG_RST; 399 394 sprd_adi_write(sadi, sadi->slave_pbase + REG_WDG_CTRL, val); 395 + 396 + /* Lock the watchdog */ 397 + sprd_adi_write(sadi, sadi->slave_pbase + REG_WDG_LOCK, ~WDG_UNLOCK_KEY); 400 398 401 399 mdelay(1000); 402 400
+12 -3
drivers/spi/spi-sprd.c
··· 669 669 writel_relaxed(clk_div, ss->base + SPRD_SPI_CLKD); 670 670 } 671 671 672 - static void sprd_spi_init_hw(struct sprd_spi *ss, struct spi_transfer *t) 672 + static int sprd_spi_init_hw(struct sprd_spi *ss, struct spi_transfer *t) 673 673 { 674 + struct spi_delay *d = &t->word_delay; 674 675 u16 word_delay, interval; 675 676 u32 val; 677 + 678 + if (d->unit != SPI_DELAY_UNIT_SCK) 679 + return -EINVAL; 676 680 677 681 val = readl_relaxed(ss->base + SPRD_SPI_CTL7); 678 682 val &= ~(SPRD_SPI_SCK_REV | SPRD_SPI_NG_TX | SPRD_SPI_NG_RX); ··· 690 686 * formula as below per datasheet: 691 687 * interval time (source clock cycles) = interval * 4 + 10. 692 688 */ 693 - word_delay = clamp_t(u16, t->word_delay, SPRD_SPI_MIN_DELAY_CYCLE, 689 + word_delay = clamp_t(u16, d->value, SPRD_SPI_MIN_DELAY_CYCLE, 694 690 SPRD_SPI_MAX_DELAY_CYCLE); 695 691 interval = DIV_ROUND_UP(word_delay - 10, 4); 696 692 ss->word_delay = interval * 4 + 10; ··· 715 711 val &= ~SPRD_SPI_DATA_LINE2_EN; 716 712 717 713 writel_relaxed(val, ss->base + SPRD_SPI_CTL7); 714 + 715 + return 0; 718 716 } 719 717 720 718 static int sprd_spi_setup_transfer(struct spi_device *sdev, ··· 725 719 struct sprd_spi *ss = spi_controller_get_devdata(sdev->controller); 726 720 u8 bits_per_word = t->bits_per_word; 727 721 u32 val, mode = 0; 722 + int ret; 728 723 729 724 ss->len = t->len; 730 725 ss->tx_buf = t->tx_buf; 731 726 ss->rx_buf = t->rx_buf; 732 727 733 728 ss->hw_mode = sdev->mode; 734 - sprd_spi_init_hw(ss, t); 729 + ret = sprd_spi_init_hw(ss, t); 730 + if (ret) 731 + return ret; 735 732 736 733 /* Set tansfer speed and valid bits */ 737 734 sprd_spi_set_speed(ss, t->speed_hz);
+3
drivers/spi/spi-st-ssc4.c
··· 381 381 return 0; 382 382 383 383 clk_disable: 384 + pm_runtime_disable(&pdev->dev); 384 385 clk_disable_unprepare(spi_st->clk); 385 386 put_master: 386 387 spi_master_put(master); ··· 392 391 { 393 392 struct spi_master *master = platform_get_drvdata(pdev); 394 393 struct spi_st *spi_st = spi_master_get_devdata(master); 394 + 395 + pm_runtime_disable(&pdev->dev); 395 396 396 397 clk_disable_unprepare(spi_st->clk); 397 398
+2 -1
drivers/spi/spi-stm32-qspi.c
··· 528 528 stm32_qspi_dma_free(qspi); 529 529 mutex_destroy(&qspi->lock); 530 530 clk_disable_unprepare(qspi->clk); 531 - spi_master_put(qspi->ctrl); 532 531 } 533 532 534 533 static int stm32_qspi_probe(struct platform_device *pdev) ··· 625 626 626 627 err: 627 628 stm32_qspi_release(qspi); 629 + spi_master_put(qspi->ctrl); 630 + 628 631 return ret; 629 632 } 630 633
+24 -18
drivers/spi/spi-tegra114.c
··· 666 666 dma_addr_t dma_phys; 667 667 int ret; 668 668 669 - dma_chan = dma_request_slave_channel_reason(tspi->dev, 670 - dma_to_memory ? "rx" : "tx"); 669 + dma_chan = dma_request_chan(tspi->dev, dma_to_memory ? "rx" : "tx"); 671 670 if (IS_ERR(dma_chan)) { 672 671 ret = PTR_ERR(dma_chan); 673 672 if (ret != -EPROBE_DEFER) ··· 722 723 dma_release_channel(dma_chan); 723 724 } 724 725 725 - static void tegra_spi_set_hw_cs_timing(struct spi_device *spi, u8 setup_dly, 726 - u8 hold_dly, u8 inactive_dly) 726 + static int tegra_spi_set_hw_cs_timing(struct spi_device *spi, 727 + struct spi_delay *setup, 728 + struct spi_delay *hold, 729 + struct spi_delay *inactive) 727 730 { 728 731 struct tegra_spi_data *tspi = spi_master_get_devdata(spi->master); 732 + u8 setup_dly, hold_dly, inactive_dly; 729 733 u32 setup_hold; 730 734 u32 spi_cs_timing; 731 735 u32 inactive_cycles; 732 736 u8 cs_state; 737 + 738 + if ((setup && setup->unit != SPI_DELAY_UNIT_SCK) || 739 + (hold && hold->unit != SPI_DELAY_UNIT_SCK) || 740 + (inactive && inactive->unit != SPI_DELAY_UNIT_SCK)) { 741 + dev_err(&spi->dev, 742 + "Invalid delay unit %d, should be SPI_DELAY_UNIT_SCK\n", 743 + SPI_DELAY_UNIT_SCK); 744 + return -EINVAL; 745 + } 746 + 747 + setup_dly = setup ? setup->value : 0; 748 + hold_dly = hold ? hold->value : 0; 749 + inactive_dly = inactive ? inactive->value : 0; 733 750 734 751 setup_dly = min_t(u8, setup_dly, MAX_SETUP_HOLD_CYCLES); 735 752 hold_dly = min_t(u8, hold_dly, MAX_SETUP_HOLD_CYCLES); ··· 773 758 tspi->spi_cs_timing2 = spi_cs_timing; 774 759 tegra_spi_writel(tspi, spi_cs_timing, SPI_CS_TIMING2); 775 760 } 761 + 762 + return 0; 776 763 } 777 764 778 765 static u32 tegra_spi_setup_transfer_one(struct spi_device *spi, ··· 1001 984 return 0; 1002 985 } 1003 986 1004 - static void tegra_spi_transfer_delay(int delay) 1005 - { 1006 - if (!delay) 1007 - return; 1008 - 1009 - if (delay >= 1000) 1010 - mdelay(delay / 1000); 1011 - 1012 - udelay(delay % 1000); 1013 - } 1014 - 1015 987 static void tegra_spi_transfer_end(struct spi_device *spi) 1016 988 { 1017 989 struct tegra_spi_data *tspi = spi_master_get_devdata(spi->master); ··· 1104 1098 complete_xfer: 1105 1099 if (ret < 0 || skip) { 1106 1100 tegra_spi_transfer_end(spi); 1107 - tegra_spi_transfer_delay(xfer->delay_usecs); 1101 + spi_transfer_delay_exec(xfer); 1108 1102 goto exit; 1109 1103 } else if (list_is_last(&xfer->transfer_list, 1110 1104 &msg->transfers)) { ··· 1112 1106 tspi->cs_control = spi; 1113 1107 else { 1114 1108 tegra_spi_transfer_end(spi); 1115 - tegra_spi_transfer_delay(xfer->delay_usecs); 1109 + spi_transfer_delay_exec(xfer); 1116 1110 } 1117 1111 } else if (xfer->cs_change) { 1118 1112 tegra_spi_transfer_end(spi); 1119 - tegra_spi_transfer_delay(xfer->delay_usecs); 1113 + spi_transfer_delay_exec(xfer); 1120 1114 } 1121 1115 1122 1116 }
+3 -2
drivers/spi/spi-tegra20-sflash.c
··· 341 341 goto exit; 342 342 } 343 343 msg->actual_length += xfer->len; 344 - if (xfer->cs_change && xfer->delay_usecs) { 344 + if (xfer->cs_change && 345 + (xfer->delay_usecs || xfer->delay.value)) { 345 346 tegra_sflash_writel(tsd, tsd->def_command_reg, 346 347 SPI_COMMAND); 347 - udelay(xfer->delay_usecs); 348 + spi_transfer_delay_exec(xfer); 348 349 } 349 350 } 350 351 ret = 0;
+5 -3
drivers/spi/spi-tegra20-slink.c
··· 599 599 int ret; 600 600 struct dma_slave_config dma_sconfig; 601 601 602 - dma_chan = dma_request_slave_channel_reason(tspi->dev, 603 - dma_to_memory ? "rx" : "tx"); 602 + dma_chan = dma_request_chan(tspi->dev, dma_to_memory ? "rx" : "tx"); 604 603 if (IS_ERR(dma_chan)) { 605 604 ret = PTR_ERR(dma_chan); 606 605 if (ret != -EPROBE_DEFER) ··· 1072 1073 ret = clk_enable(tspi->clk); 1073 1074 if (ret < 0) { 1074 1075 dev_err(&pdev->dev, "Clock enable failed %d\n", ret); 1075 - goto exit_free_master; 1076 + goto exit_clk_unprepare; 1076 1077 } 1077 1078 1078 1079 spi_irq = platform_get_irq(pdev, 0); ··· 1145 1146 free_irq(spi_irq, tspi); 1146 1147 exit_clk_disable: 1147 1148 clk_disable(tspi->clk); 1149 + exit_clk_unprepare: 1150 + clk_unprepare(tspi->clk); 1148 1151 exit_free_master: 1149 1152 spi_master_put(master); 1150 1153 return ret; ··· 1160 1159 free_irq(tspi->irq, tspi); 1161 1160 1162 1161 clk_disable(tspi->clk); 1162 + clk_unprepare(tspi->clk); 1163 1163 1164 1164 if (tspi->tx_dma_chan) 1165 1165 tegra_slink_deinit_dma_param(tspi, false);
+1 -6
drivers/spi/spi-topcliff-pch.c
··· 1229 1229 "%s:data->current_msg->actual_length=%d\n", 1230 1230 __func__, data->current_msg->actual_length); 1231 1231 1232 - /* check for delay */ 1233 - if (data->cur_trans->delay_usecs) { 1234 - dev_dbg(&data->master->dev, "%s:delay in usec=%d\n", 1235 - __func__, data->cur_trans->delay_usecs); 1236 - udelay(data->cur_trans->delay_usecs); 1237 - } 1232 + spi_transfer_delay_exec(data->cur_trans); 1238 1233 1239 1234 spin_lock(&data->lock); 1240 1235
+59 -19
drivers/spi/spi-txx9.c
··· 26 26 #include <linux/clk.h> 27 27 #include <linux/io.h> 28 28 #include <linux/module.h> 29 - #include <linux/gpio.h> 29 + #include <linux/gpio/machine.h> 30 + #include <linux/gpio/consumer.h> 30 31 31 32 32 33 #define SPI_FIFO_SIZE 4 ··· 80 79 void __iomem *membase; 81 80 int baseclk; 82 81 struct clk *clk; 83 - int last_chipselect; 82 + struct gpio_desc *last_chipselect; 84 83 int last_chipselect_val; 85 84 }; 86 85 ··· 96 95 static void txx9spi_cs_func(struct spi_device *spi, struct txx9spi *c, 97 96 int on, unsigned int cs_delay) 98 97 { 99 - int val = (spi->mode & SPI_CS_HIGH) ? on : !on; 100 - 98 + /* 99 + * The GPIO descriptor will track polarity inversion inside 100 + * gpiolib. 101 + */ 101 102 if (on) { 102 103 /* deselect the chip with cs_change hint in last transfer */ 103 - if (c->last_chipselect >= 0) 104 - gpio_set_value(c->last_chipselect, 104 + if (c->last_chipselect) 105 + gpiod_set_value(c->last_chipselect, 105 106 !c->last_chipselect_val); 106 - c->last_chipselect = spi->chip_select; 107 - c->last_chipselect_val = val; 107 + c->last_chipselect = spi->cs_gpiod; 108 + c->last_chipselect_val = on; 108 109 } else { 109 - c->last_chipselect = -1; 110 + c->last_chipselect = NULL; 110 111 ndelay(cs_delay); /* CS Hold Time */ 111 112 } 112 - gpio_set_value(spi->chip_select, val); 113 + gpiod_set_value(spi->cs_gpiod, on); 113 114 ndelay(cs_delay); /* CS Setup Time / CS Recovery Time */ 114 115 } 115 116 ··· 121 118 122 119 if (!spi->max_speed_hz) 123 120 return -EINVAL; 124 - 125 - if (gpio_direction_output(spi->chip_select, 126 - !(spi->mode & SPI_CS_HIGH))) { 127 - dev_err(&spi->dev, "Cannot setup GPIO for chipselect.\n"); 128 - return -EINVAL; 129 - } 130 121 131 122 /* deselect chip */ 132 123 spin_lock(&c->lock); ··· 245 248 len -= count * wsize; 246 249 } 247 250 m->actual_length += t->len; 248 - if (t->delay_usecs) 249 - udelay(t->delay_usecs); 251 + spi_transfer_delay_exec(t); 250 252 251 253 if (!cs_change) 252 254 continue; ··· 316 320 return 0; 317 321 } 318 322 323 + /* 324 + * Chip select uses GPIO only, further the driver is using the chip select 325 + * numer (from the device tree "reg" property, and this can only come from 326 + * device tree since this i MIPS and there is no way to pass platform data) as 327 + * the GPIO number. As the platform has only one GPIO controller (the txx9 GPIO 328 + * chip) it is thus using the chip select number as an offset into that chip. 329 + * This chip has a maximum of 16 GPIOs 0..15 and this is what all platforms 330 + * register. 331 + * 332 + * We modernized this behaviour by explicitly converting that offset to an 333 + * offset on the GPIO chip using a GPIO descriptor machine table of the same 334 + * size as the txx9 GPIO chip with a 1-to-1 mapping of chip select to GPIO 335 + * offset. 336 + * 337 + * This is admittedly a hack, but it is countering the hack of using "reg" to 338 + * contain a GPIO offset when it should be using "cs-gpios" as the SPI bindings 339 + * state. 340 + */ 341 + static struct gpiod_lookup_table txx9spi_cs_gpio_table = { 342 + .dev_id = "spi0", 343 + .table = { 344 + GPIO_LOOKUP_IDX("TXx9", 0, "cs", 0, GPIO_ACTIVE_LOW), 345 + GPIO_LOOKUP_IDX("TXx9", 1, "cs", 1, GPIO_ACTIVE_LOW), 346 + GPIO_LOOKUP_IDX("TXx9", 2, "cs", 2, GPIO_ACTIVE_LOW), 347 + GPIO_LOOKUP_IDX("TXx9", 3, "cs", 3, GPIO_ACTIVE_LOW), 348 + GPIO_LOOKUP_IDX("TXx9", 4, "cs", 4, GPIO_ACTIVE_LOW), 349 + GPIO_LOOKUP_IDX("TXx9", 5, "cs", 5, GPIO_ACTIVE_LOW), 350 + GPIO_LOOKUP_IDX("TXx9", 6, "cs", 6, GPIO_ACTIVE_LOW), 351 + GPIO_LOOKUP_IDX("TXx9", 7, "cs", 7, GPIO_ACTIVE_LOW), 352 + GPIO_LOOKUP_IDX("TXx9", 8, "cs", 8, GPIO_ACTIVE_LOW), 353 + GPIO_LOOKUP_IDX("TXx9", 9, "cs", 9, GPIO_ACTIVE_LOW), 354 + GPIO_LOOKUP_IDX("TXx9", 10, "cs", 10, GPIO_ACTIVE_LOW), 355 + GPIO_LOOKUP_IDX("TXx9", 11, "cs", 11, GPIO_ACTIVE_LOW), 356 + GPIO_LOOKUP_IDX("TXx9", 12, "cs", 12, GPIO_ACTIVE_LOW), 357 + GPIO_LOOKUP_IDX("TXx9", 13, "cs", 13, GPIO_ACTIVE_LOW), 358 + GPIO_LOOKUP_IDX("TXx9", 14, "cs", 14, GPIO_ACTIVE_LOW), 359 + GPIO_LOOKUP_IDX("TXx9", 15, "cs", 15, GPIO_ACTIVE_LOW), 360 + { }, 361 + }, 362 + }; 363 + 319 364 static int txx9spi_probe(struct platform_device *dev) 320 365 { 321 366 struct spi_master *master; ··· 410 373 if (ret) 411 374 goto exit; 412 375 413 - c->last_chipselect = -1; 376 + c->last_chipselect = NULL; 414 377 415 378 dev_info(&dev->dev, "at %#llx, irq %d, %dMHz\n", 416 379 (unsigned long long)res->start, irq, 417 380 (c->baseclk + 500000) / 1000000); 381 + 382 + gpiod_add_lookup_table(&txx9spi_cs_gpio_table); 418 383 419 384 /* the spi->mode bits understood by this driver: */ 420 385 master->mode_bits = SPI_CS_HIGH | SPI_CPOL | SPI_CPHA; ··· 426 387 master->transfer = txx9spi_transfer; 427 388 master->num_chipselect = (u16)UINT_MAX; /* any GPIO numbers */ 428 389 master->bits_per_word_mask = SPI_BPW_MASK(8) | SPI_BPW_MASK(16); 390 + master->use_gpio_descriptors = true; 429 391 430 392 ret = devm_spi_register_master(&dev->dev, master); 431 393 if (ret)
+1 -2
drivers/spi/spi-xcomm.c
··· 188 188 } 189 189 status = 0; 190 190 191 - if (t->delay_usecs) 192 - udelay(t->delay_usecs); 191 + spi_transfer_delay_exec(t); 193 192 194 193 is_first = false; 195 194 }
+6 -1
drivers/spi/spi-xilinx.c
··· 391 391 struct xilinx_spi *xspi; 392 392 struct xspi_platform_data *pdata; 393 393 struct resource *res; 394 - int ret, num_cs = 0, bits_per_word = 8; 394 + int ret, num_cs = 0, bits_per_word; 395 395 struct spi_master *master; 396 396 u32 tmp; 397 397 u8 i; ··· 403 403 } else { 404 404 of_property_read_u32(pdev->dev.of_node, "xlnx,num-ss-bits", 405 405 &num_cs); 406 + ret = of_property_read_u32(pdev->dev.of_node, 407 + "xlnx,num-transfer-bits", 408 + &bits_per_word); 409 + if (ret) 410 + bits_per_word = 8; 406 411 } 407 412 408 413 if (!num_cs) {
+1 -9
drivers/spi/spi-xtensa-xtfpga.c
··· 80 80 static int xtfpga_spi_probe(struct platform_device *pdev) 81 81 { 82 82 struct xtfpga_spi *xspi; 83 - struct resource *mem; 84 83 int ret; 85 84 struct spi_master *master; 86 85 ··· 96 97 xspi->bitbang.master = master; 97 98 xspi->bitbang.chipselect = xtfpga_spi_chipselect; 98 99 xspi->bitbang.txrx_word[SPI_MODE_0] = xtfpga_spi_txrx_word; 99 - 100 - mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); 101 - if (!mem) { 102 - dev_err(&pdev->dev, "No memory resource\n"); 103 - ret = -ENODEV; 104 - goto err; 105 - } 106 - xspi->regs = devm_ioremap_resource(&pdev->dev, mem); 100 + xspi->regs = devm_platform_ioremap_resource(pdev, 0); 107 101 if (IS_ERR(xspi->regs)) { 108 102 ret = PTR_ERR(xspi->regs); 109 103 goto err;
+50 -34
drivers/spi/spi-zynq-qspi.c
··· 7 7 8 8 #include <linux/clk.h> 9 9 #include <linux/delay.h> 10 - #include <linux/gpio.h> 11 10 #include <linux/interrupt.h> 12 11 #include <linux/io.h> 13 12 #include <linux/module.h> ··· 50 51 #define ZYNQ_QSPI_CONFIG_BDRATE_MASK GENMASK(5, 3) /* Baud Rate Mask */ 51 52 #define ZYNQ_QSPI_CONFIG_CPHA_MASK BIT(2) /* Clock Phase Control */ 52 53 #define ZYNQ_QSPI_CONFIG_CPOL_MASK BIT(1) /* Clock Polarity Control */ 53 - #define ZYNQ_QSPI_CONFIG_SSCTRL_MASK BIT(10) /* Slave Select Mask */ 54 54 #define ZYNQ_QSPI_CONFIG_FWIDTH_MASK GENMASK(7, 6) /* FIFO width */ 55 55 #define ZYNQ_QSPI_CONFIG_MSTREN_MASK BIT(0) /* Master Mode */ 56 56 ··· 59 61 * These are the values used in the calculation of baud rate divisor and 60 62 * setting the slave select. 61 63 */ 62 - #define ZYNQ_QSPI_BAUD_DIV_MAX GENMASK(2, 0) /* Baud rate maximum */ 63 - #define ZYNQ_QSPI_BAUD_DIV_SHIFT 3 /* Baud rate divisor shift in CR */ 64 - #define ZYNQ_QSPI_SS_SHIFT 10 /* Slave Select field shift in CR */ 64 + #define ZYNQ_QSPI_CONFIG_BAUD_DIV_MAX GENMASK(2, 0) /* Baud rate maximum */ 65 + #define ZYNQ_QSPI_CONFIG_BAUD_DIV_SHIFT 3 /* Baud rate divisor shift */ 66 + #define ZYNQ_QSPI_CONFIG_PCS BIT(10) /* Peripheral Chip Select */ 65 67 66 68 /* 67 69 * QSPI Interrupt Registers bit Masks ··· 97 99 * It is named Linear Configuration but it controls other modes when not in 98 100 * linear mode also. 99 101 */ 100 - #define ZYNQ_QSPI_LCFG_TWO_MEM_MASK BIT(30) /* LQSPI Two memories Mask */ 101 - #define ZYNQ_QSPI_LCFG_SEP_BUS_MASK BIT(29) /* LQSPI Separate bus Mask */ 102 - #define ZYNQ_QSPI_LCFG_U_PAGE_MASK BIT(28) /* LQSPI Upper Page Mask */ 102 + #define ZYNQ_QSPI_LCFG_TWO_MEM BIT(30) /* LQSPI Two memories */ 103 + #define ZYNQ_QSPI_LCFG_SEP_BUS BIT(29) /* LQSPI Separate bus */ 104 + #define ZYNQ_QSPI_LCFG_U_PAGE BIT(28) /* LQSPI Upper Page */ 103 105 104 106 #define ZYNQ_QSPI_LCFG_DUMMY_SHIFT 8 105 107 ··· 114 116 */ 115 117 #define ZYNQ_QSPI_MODEBITS (SPI_CPOL | SPI_CPHA) 116 118 117 - /* Default number of chip selects */ 118 - #define ZYNQ_QSPI_DEFAULT_NUM_CS 1 119 + /* Maximum number of chip selects */ 120 + #define ZYNQ_QSPI_MAX_NUM_CS 2 119 121 120 122 /** 121 123 * struct zynq_qspi - Defines qspi driver instance ··· 159 161 /** 160 162 * zynq_qspi_init_hw - Initialize the hardware 161 163 * @xqspi: Pointer to the zynq_qspi structure 164 + * @num_cs: Number of connected CS (to enable dual memories if needed) 162 165 * 163 166 * The default settings of the QSPI controller's configurable parameters on 164 167 * reset are ··· 177 178 * - Set the little endian mode of TX FIFO and 178 179 * - Enable the QSPI controller 179 180 */ 180 - static void zynq_qspi_init_hw(struct zynq_qspi *xqspi) 181 + static void zynq_qspi_init_hw(struct zynq_qspi *xqspi, unsigned int num_cs) 181 182 { 182 183 u32 config_reg; 183 184 ··· 185 186 zynq_qspi_write(xqspi, ZYNQ_QSPI_IDIS_OFFSET, ZYNQ_QSPI_IXR_ALL_MASK); 186 187 187 188 /* Disable linear mode as the boot loader may have used it */ 188 - zynq_qspi_write(xqspi, ZYNQ_QSPI_LINEAR_CFG_OFFSET, 0); 189 + config_reg = 0; 190 + /* At the same time, enable dual mode if more than 1 CS is available */ 191 + if (num_cs > 1) 192 + config_reg |= ZYNQ_QSPI_LCFG_TWO_MEM; 193 + 194 + zynq_qspi_write(xqspi, ZYNQ_QSPI_LINEAR_CFG_OFFSET, config_reg); 189 195 190 196 /* Clear the RX FIFO */ 191 197 while (zynq_qspi_read(xqspi, ZYNQ_QSPI_STATUS_OFFSET) & ··· 288 284 */ 289 285 static void zynq_qspi_chipselect(struct spi_device *spi, bool assert) 290 286 { 291 - struct spi_controller *ctrl = spi->master; 292 - struct zynq_qspi *xqspi = spi_controller_get_devdata(ctrl); 287 + struct spi_controller *ctlr = spi->master; 288 + struct zynq_qspi *xqspi = spi_controller_get_devdata(ctlr); 293 289 u32 config_reg; 294 290 295 - config_reg = zynq_qspi_read(xqspi, ZYNQ_QSPI_CONFIG_OFFSET); 296 - if (assert) { 297 - /* Select the slave */ 298 - config_reg &= ~ZYNQ_QSPI_CONFIG_SSCTRL_MASK; 299 - config_reg |= (((~(BIT(spi->chip_select))) << 300 - ZYNQ_QSPI_SS_SHIFT) & 301 - ZYNQ_QSPI_CONFIG_SSCTRL_MASK); 302 - } else { 303 - config_reg |= ZYNQ_QSPI_CONFIG_SSCTRL_MASK; 291 + /* Select the lower (CS0) or upper (CS1) memory */ 292 + if (ctlr->num_chipselect > 1) { 293 + config_reg = zynq_qspi_read(xqspi, ZYNQ_QSPI_LINEAR_CFG_OFFSET); 294 + if (!spi->chip_select) 295 + config_reg &= ~ZYNQ_QSPI_LCFG_U_PAGE; 296 + else 297 + config_reg |= ZYNQ_QSPI_LCFG_U_PAGE; 298 + 299 + zynq_qspi_write(xqspi, ZYNQ_QSPI_LINEAR_CFG_OFFSET, config_reg); 304 300 } 301 + 302 + /* Ground the line to assert the CS */ 303 + config_reg = zynq_qspi_read(xqspi, ZYNQ_QSPI_CONFIG_OFFSET); 304 + if (assert) 305 + config_reg &= ~ZYNQ_QSPI_CONFIG_PCS; 306 + else 307 + config_reg |= ZYNQ_QSPI_CONFIG_PCS; 305 308 306 309 zynq_qspi_write(xqspi, ZYNQ_QSPI_CONFIG_OFFSET, config_reg); 307 310 } ··· 343 332 * ---------------- 344 333 * 111 - divide by 256 345 334 */ 346 - while ((baud_rate_val < ZYNQ_QSPI_BAUD_DIV_MAX) && 335 + while ((baud_rate_val < ZYNQ_QSPI_CONFIG_BAUD_DIV_MAX) && 347 336 (clk_get_rate(xqspi->refclk) / (2 << baud_rate_val)) > 348 337 spi->max_speed_hz) 349 338 baud_rate_val++; ··· 359 348 config_reg |= ZYNQ_QSPI_CONFIG_CPOL_MASK; 360 349 361 350 config_reg &= ~ZYNQ_QSPI_CONFIG_BDRATE_MASK; 362 - config_reg |= (baud_rate_val << ZYNQ_QSPI_BAUD_DIV_SHIFT); 351 + config_reg |= (baud_rate_val << ZYNQ_QSPI_CONFIG_BAUD_DIV_SHIFT); 363 352 zynq_qspi_write(xqspi, ZYNQ_QSPI_CONFIG_OFFSET, config_reg); 364 353 365 354 return 0; ··· 376 365 */ 377 366 static int zynq_qspi_setup_op(struct spi_device *spi) 378 367 { 379 - struct spi_controller *ctrl = spi->master; 380 - struct zynq_qspi *qspi = spi_controller_get_devdata(ctrl); 368 + struct spi_controller *ctlr = spi->master; 369 + struct zynq_qspi *qspi = spi_controller_get_devdata(ctlr); 381 370 382 - if (ctrl->busy) 371 + if (ctlr->busy) 383 372 return -EBUSY; 384 373 385 374 clk_enable(qspi->refclk); ··· 674 663 goto clk_dis_pclk; 675 664 } 676 665 677 - /* QSPI controller initializations */ 678 - zynq_qspi_init_hw(xqspi); 679 - 680 666 xqspi->irq = platform_get_irq(pdev, 0); 681 667 if (xqspi->irq <= 0) { 682 668 ret = -ENXIO; ··· 689 681 690 682 ret = of_property_read_u32(np, "num-cs", 691 683 &num_cs); 692 - if (ret < 0) 693 - ctlr->num_chipselect = ZYNQ_QSPI_DEFAULT_NUM_CS; 694 - else 684 + if (ret < 0) { 685 + ctlr->num_chipselect = 1; 686 + } else if (num_cs > ZYNQ_QSPI_MAX_NUM_CS) { 687 + dev_err(&pdev->dev, "only 2 chip selects are available\n"); 688 + goto remove_master; 689 + } else { 695 690 ctlr->num_chipselect = num_cs; 691 + } 696 692 697 693 ctlr->mode_bits = SPI_RX_DUAL | SPI_RX_QUAD | 698 694 SPI_TX_DUAL | SPI_TX_QUAD; ··· 704 692 ctlr->setup = zynq_qspi_setup_op; 705 693 ctlr->max_speed_hz = clk_get_rate(xqspi->refclk) / 2; 706 694 ctlr->dev.of_node = np; 695 + 696 + /* QSPI controller initializations */ 697 + zynq_qspi_init_hw(xqspi, ctlr->num_chipselect); 698 + 707 699 ret = devm_spi_register_controller(&pdev->dev, ctlr); 708 700 if (ret) { 709 701 dev_err(&pdev->dev, "spi_register_master failed\n");
+166 -39
drivers/spi/spi.c
··· 92 92 if (len) { 93 93 spi->driver_override = driver_override; 94 94 } else { 95 - /* Emptry string, disable driver override */ 95 + /* Empty string, disable driver override */ 96 96 spi->driver_override = NULL; 97 97 kfree(driver_override); 98 98 } ··· 469 469 static LIST_HEAD(spi_controller_list); 470 470 471 471 /* 472 - * Used to protect add/del opertion for board_info list and 472 + * Used to protect add/del operation for board_info list and 473 473 * spi_controller list, and their matching process 474 474 * also used to protect object of type struct idr 475 475 */ ··· 775 775 776 776 static void spi_set_cs(struct spi_device *spi, bool enable) 777 777 { 778 + bool enable1 = enable; 779 + 780 + if (!spi->controller->set_cs_timing) { 781 + if (enable1) 782 + spi_delay_exec(&spi->controller->cs_setup, NULL); 783 + else 784 + spi_delay_exec(&spi->controller->cs_hold, NULL); 785 + } 786 + 778 787 if (spi->mode & SPI_CS_HIGH) 779 788 enable = !enable; 780 789 ··· 808 799 spi->controller->set_cs(spi, !enable); 809 800 } else if (spi->controller->set_cs) { 810 801 spi->controller->set_cs(spi, !enable); 802 + } 803 + 804 + if (!spi->controller->set_cs_timing) { 805 + if (!enable1) 806 + spi_delay_exec(&spi->controller->cs_inactive, NULL); 811 807 } 812 808 } 813 809 ··· 1120 1106 } 1121 1107 } 1122 1108 1123 - static void _spi_transfer_cs_change_delay(struct spi_message *msg, 1124 - struct spi_transfer *xfer) 1109 + int spi_delay_to_ns(struct spi_delay *_delay, struct spi_transfer *xfer) 1125 1110 { 1126 - u32 delay = xfer->cs_change_delay; 1127 - u32 unit = xfer->cs_change_delay_unit; 1111 + u32 delay = _delay->value; 1112 + u32 unit = _delay->unit; 1128 1113 u32 hz; 1129 1114 1130 - /* return early on "fast" mode - for everything but USECS */ 1131 - if (!delay && unit != SPI_DELAY_UNIT_USECS) 1132 - return; 1115 + if (!delay) 1116 + return 0; 1133 1117 1134 1118 switch (unit) { 1135 1119 case SPI_DELAY_UNIT_USECS: 1136 - /* for compatibility use default of 10us */ 1137 - if (!delay) 1138 - delay = 10000; 1139 - else 1140 - delay *= 1000; 1120 + delay *= 1000; 1141 1121 break; 1142 1122 case SPI_DELAY_UNIT_NSECS: /* nothing to do here */ 1143 1123 break; 1144 1124 case SPI_DELAY_UNIT_SCK: 1125 + /* clock cycles need to be obtained from spi_transfer */ 1126 + if (!xfer) 1127 + return -EINVAL; 1145 1128 /* if there is no effective speed know, then approximate 1146 1129 * by underestimating with half the requested hz 1147 1130 */ 1148 1131 hz = xfer->effective_speed_hz ?: xfer->speed_hz / 2; 1132 + if (!hz) 1133 + return -EINVAL; 1149 1134 delay *= DIV_ROUND_UP(1000000000, hz); 1150 1135 break; 1151 1136 default: 1137 + return -EINVAL; 1138 + } 1139 + 1140 + return delay; 1141 + } 1142 + EXPORT_SYMBOL_GPL(spi_delay_to_ns); 1143 + 1144 + int spi_delay_exec(struct spi_delay *_delay, struct spi_transfer *xfer) 1145 + { 1146 + int delay; 1147 + 1148 + if (!_delay) 1149 + return -EINVAL; 1150 + 1151 + delay = spi_delay_to_ns(_delay, xfer); 1152 + if (delay < 0) 1153 + return delay; 1154 + 1155 + _spi_transfer_delay_ns(delay); 1156 + 1157 + return 0; 1158 + } 1159 + EXPORT_SYMBOL_GPL(spi_delay_exec); 1160 + 1161 + static void _spi_transfer_cs_change_delay(struct spi_message *msg, 1162 + struct spi_transfer *xfer) 1163 + { 1164 + u32 delay = xfer->cs_change_delay.value; 1165 + u32 unit = xfer->cs_change_delay.unit; 1166 + int ret; 1167 + 1168 + /* return early on "fast" mode - for everything but USECS */ 1169 + if (!delay) { 1170 + if (unit == SPI_DELAY_UNIT_USECS) 1171 + _spi_transfer_delay_ns(10000); 1172 + return; 1173 + } 1174 + 1175 + ret = spi_delay_exec(&xfer->cs_change_delay, xfer); 1176 + if (ret) { 1152 1177 dev_err_once(&msg->spi->dev, 1153 1178 "Use of unsupported delay unit %i, using default of 10us\n", 1154 - xfer->cs_change_delay_unit); 1155 - delay = 10000; 1179 + unit); 1180 + _spi_transfer_delay_ns(10000); 1156 1181 } 1157 - /* now sleep for the requested amount of time */ 1158 - _spi_transfer_delay_ns(delay); 1159 1182 } 1160 1183 1161 1184 /* ··· 1263 1212 if (msg->status != -EINPROGRESS) 1264 1213 goto out; 1265 1214 1266 - if (xfer->delay_usecs) 1267 - _spi_transfer_delay_ns(xfer->delay_usecs * 1000); 1215 + spi_transfer_delay_exec(xfer); 1268 1216 1269 1217 if (xfer->cs_change) { 1270 1218 if (list_is_last(&xfer->transfer_list, ··· 1880 1830 spi->mode |= SPI_3WIRE; 1881 1831 if (of_property_read_bool(nc, "spi-lsb-first")) 1882 1832 spi->mode |= SPI_LSB_FIRST; 1883 - 1884 - /* 1885 - * For descriptors associated with the device, polarity inversion is 1886 - * handled in the gpiolib, so all chip selects are "active high" in 1887 - * the logical sense, the gpiolib will invert the line if need be. 1888 - */ 1889 - if (ctlr->use_gpio_descriptors) 1890 - spi->mode |= SPI_CS_HIGH; 1891 - else if (of_property_read_bool(nc, "spi-cs-high")) 1833 + if (of_property_read_bool(nc, "spi-cs-high")) 1892 1834 spi->mode |= SPI_CS_HIGH; 1893 1835 1894 1836 /* Device DUAL/QUAD mode */ ··· 1943 1901 return rc; 1944 1902 } 1945 1903 spi->chip_select = value; 1904 + 1905 + /* 1906 + * For descriptors associated with the device, polarity inversion is 1907 + * handled in the gpiolib, so all gpio chip selects are "active high" 1908 + * in the logical sense, the gpiolib will invert the line if need be. 1909 + */ 1910 + if ((ctlr->use_gpio_descriptors) && ctlr->cs_gpiods && 1911 + ctlr->cs_gpiods[spi->chip_select]) 1912 + spi->mode |= SPI_CS_HIGH; 1946 1913 1947 1914 /* Device speed */ 1948 1915 rc = of_property_read_u32(nc, "spi-max-frequency", &value); ··· 3041 2990 /* add to list */ 3042 2991 list_add(&xfer->transfer_list, rxfer->replaced_after); 3043 2992 3044 - /* clear cs_change and delay_usecs for all but the last */ 2993 + /* clear cs_change and delay for all but the last */ 3045 2994 if (i) { 3046 2995 xfer->cs_change = false; 3047 2996 xfer->delay_usecs = 0; 2997 + xfer->delay.value = 0; 3048 2998 } 3049 2999 } 3050 3000 ··· 3262 3210 if (spi->controller->setup) 3263 3211 status = spi->controller->setup(spi); 3264 3212 3265 - spi_set_cs(spi, false); 3213 + if (spi->controller->auto_runtime_pm && spi->controller->set_cs) { 3214 + status = pm_runtime_get_sync(spi->controller->dev.parent); 3215 + if (status < 0) { 3216 + pm_runtime_put_noidle(spi->controller->dev.parent); 3217 + dev_err(&spi->controller->dev, "Failed to power device: %d\n", 3218 + status); 3219 + return status; 3220 + } 3221 + 3222 + /* 3223 + * We do not want to return positive value from pm_runtime_get, 3224 + * there are many instances of devices calling spi_setup() and 3225 + * checking for a non-zero return value instead of a negative 3226 + * return value. 3227 + */ 3228 + status = 0; 3229 + 3230 + spi_set_cs(spi, false); 3231 + pm_runtime_mark_last_busy(spi->controller->dev.parent); 3232 + pm_runtime_put_autosuspend(spi->controller->dev.parent); 3233 + } else { 3234 + spi_set_cs(spi, false); 3235 + } 3266 3236 3267 3237 if (spi->rt && !spi->controller->rt) { 3268 3238 spi->controller->rt = true; ··· 3307 3233 /** 3308 3234 * spi_set_cs_timing - configure CS setup, hold, and inactive delays 3309 3235 * @spi: the device that requires specific CS timing configuration 3310 - * @setup: CS setup time in terms of clock count 3311 - * @hold: CS hold time in terms of clock count 3312 - * @inactive_dly: CS inactive delay between transfers in terms of clock count 3236 + * @setup: CS setup time specified via @spi_delay 3237 + * @hold: CS hold time specified via @spi_delay 3238 + * @inactive: CS inactive delay between transfers specified via @spi_delay 3239 + * 3240 + * Return: zero on success, else a negative error code. 3313 3241 */ 3314 - void spi_set_cs_timing(struct spi_device *spi, u8 setup, u8 hold, 3315 - u8 inactive_dly) 3242 + int spi_set_cs_timing(struct spi_device *spi, struct spi_delay *setup, 3243 + struct spi_delay *hold, struct spi_delay *inactive) 3316 3244 { 3245 + size_t len; 3246 + 3317 3247 if (spi->controller->set_cs_timing) 3318 - spi->controller->set_cs_timing(spi, setup, hold, inactive_dly); 3248 + return spi->controller->set_cs_timing(spi, setup, hold, 3249 + inactive); 3250 + 3251 + if ((setup && setup->unit == SPI_DELAY_UNIT_SCK) || 3252 + (hold && hold->unit == SPI_DELAY_UNIT_SCK) || 3253 + (inactive && inactive->unit == SPI_DELAY_UNIT_SCK)) { 3254 + dev_err(&spi->dev, 3255 + "Clock-cycle delays for CS not supported in SW mode\n"); 3256 + return -ENOTSUPP; 3257 + } 3258 + 3259 + len = sizeof(struct spi_delay); 3260 + 3261 + /* copy delays to controller */ 3262 + if (setup) 3263 + memcpy(&spi->controller->cs_setup, setup, len); 3264 + else 3265 + memset(&spi->controller->cs_setup, 0, len); 3266 + 3267 + if (hold) 3268 + memcpy(&spi->controller->cs_hold, hold, len); 3269 + else 3270 + memset(&spi->controller->cs_hold, 0, len); 3271 + 3272 + if (inactive) 3273 + memcpy(&spi->controller->cs_inactive, inactive, len); 3274 + else 3275 + memset(&spi->controller->cs_inactive, 0, len); 3276 + 3277 + return 0; 3319 3278 } 3320 3279 EXPORT_SYMBOL_GPL(spi_set_cs_timing); 3280 + 3281 + static int _spi_xfer_word_delay_update(struct spi_transfer *xfer, 3282 + struct spi_device *spi) 3283 + { 3284 + int delay1, delay2; 3285 + 3286 + delay1 = spi_delay_to_ns(&xfer->word_delay, xfer); 3287 + if (delay1 < 0) 3288 + return delay1; 3289 + 3290 + delay2 = spi_delay_to_ns(&spi->word_delay, xfer); 3291 + if (delay2 < 0) 3292 + return delay2; 3293 + 3294 + if (delay1 < delay2) 3295 + memcpy(&xfer->word_delay, &spi->word_delay, 3296 + sizeof(xfer->word_delay)); 3297 + 3298 + return 0; 3299 + } 3321 3300 3322 3301 static int __spi_validate(struct spi_device *spi, struct spi_message *message) 3323 3302 { ··· 3507 3380 return -EINVAL; 3508 3381 } 3509 3382 3510 - if (xfer->word_delay_usecs < spi->word_delay_usecs) 3511 - xfer->word_delay_usecs = spi->word_delay_usecs; 3383 + if (_spi_xfer_word_delay_update(xfer, spi)) 3384 + return -EINVAL; 3512 3385 } 3513 3386 3514 3387 message->status = -EINPROGRESS;
+7 -2
drivers/spi/spidev.c
··· 265 265 k_tmp->tx_nbits = u_tmp->tx_nbits; 266 266 k_tmp->rx_nbits = u_tmp->rx_nbits; 267 267 k_tmp->bits_per_word = u_tmp->bits_per_word; 268 - k_tmp->delay_usecs = u_tmp->delay_usecs; 268 + k_tmp->delay.value = u_tmp->delay_usecs; 269 + k_tmp->delay.unit = SPI_DELAY_UNIT_USECS; 269 270 k_tmp->speed_hz = u_tmp->speed_hz; 270 - k_tmp->word_delay_usecs = u_tmp->word_delay_usecs; 271 + k_tmp->word_delay.value = u_tmp->word_delay_usecs; 272 + k_tmp->word_delay.unit = SPI_DELAY_UNIT_USECS; 271 273 if (!k_tmp->speed_hz) 272 274 k_tmp->speed_hz = spidev->speed_hz; 273 275 #ifdef VERBOSE ··· 629 627 if (dofree) 630 628 kfree(spidev); 631 629 } 630 + #ifdef CONFIG_SPI_SLAVE 631 + spi_slave_abort(spidev->spi); 632 + #endif 632 633 mutex_unlock(&device_list_lock); 633 634 634 635 return 0;
-1
include/linux/platform_data/spi-mt65xx.h
··· 11 11 12 12 /* Board specific platform_data */ 13 13 struct mtk_chip_config { 14 - u32 cs_pol; 15 14 u32 sample_sel; 16 15 }; 17 16 #endif
+1 -1
include/linux/pxa2xx_ssp.h
··· 206 206 }; 207 207 208 208 struct ssp_device { 209 - struct platform_device *pdev; 209 + struct device *dev; 210 210 struct list_head node; 211 211 212 212 struct clk *clk;
+55 -16
include/linux/spi/spi.h
··· 91 91 SPI_STATISTICS_ADD_TO_FIELD(stats, field, 1) 92 92 93 93 /** 94 + * struct spi_delay - SPI delay information 95 + * @value: Value for the delay 96 + * @unit: Unit for the delay 97 + */ 98 + struct spi_delay { 99 + #define SPI_DELAY_UNIT_USECS 0 100 + #define SPI_DELAY_UNIT_NSECS 1 101 + #define SPI_DELAY_UNIT_SCK 2 102 + u16 value; 103 + u8 unit; 104 + }; 105 + 106 + extern int spi_delay_to_ns(struct spi_delay *_delay, struct spi_transfer *xfer); 107 + extern int spi_delay_exec(struct spi_delay *_delay, struct spi_transfer *xfer); 108 + 109 + /** 94 110 * struct spi_device - Controller side proxy for an SPI slave device 95 111 * @dev: Driver model representation of the device. 96 112 * @controller: SPI controller used with the device. ··· 140 124 * the spi_master. 141 125 * @cs_gpiod: gpio descriptor of the chipselect line (optional, NULL when 142 126 * not using a GPIO line) 143 - * @word_delay_usecs: microsecond delay to be inserted between consecutive 127 + * @word_delay: delay to be inserted between consecutive 144 128 * words of a transfer 145 129 * 146 130 * @statistics: statistics for the spi_device ··· 190 174 const char *driver_override; 191 175 int cs_gpio; /* LEGACY: chip select gpio */ 192 176 struct gpio_desc *cs_gpiod; /* chip select gpio desc */ 193 - uint8_t word_delay_usecs; /* inter-word delay */ 177 + struct spi_delay word_delay; /* inter-word delay */ 194 178 195 179 /* the statistics */ 196 180 struct spi_statistics statistics; ··· 407 391 * controller has native support for memory like operations. 408 392 * @unprepare_message: undo any work done by prepare_message(). 409 393 * @slave_abort: abort the ongoing transfer request on an SPI slave controller 394 + * @cs_setup: delay to be introduced by the controller after CS is asserted 395 + * @cs_hold: delay to be introduced by the controller before CS is deasserted 396 + * @cs_inactive: delay to be introduced by the controller after CS is 397 + * deasserted. If @cs_change_delay is used from @spi_transfer, then the 398 + * two delays will be added up. 410 399 * @cs_gpios: LEGACY: array of GPIO descs to use as chip select lines; one per 411 400 * CS number. Any individual value may be -ENOENT for CS lines that 412 401 * are not GPIOs (driven by the SPI controller itself). Use the cs_gpiods ··· 530 509 * to configure specific CS timing through spi_set_cs_timing() after 531 510 * spi_setup(). 532 511 */ 533 - void (*set_cs_timing)(struct spi_device *spi, u8 setup_clk_cycles, 534 - u8 hold_clk_cycles, u8 inactive_clk_cycles); 512 + int (*set_cs_timing)(struct spi_device *spi, struct spi_delay *setup, 513 + struct spi_delay *hold, struct spi_delay *inactive); 535 514 536 515 /* bidirectional bulk transfers 537 516 * ··· 614 593 615 594 /* Optimized handlers for SPI memory-like operations. */ 616 595 const struct spi_controller_mem_ops *mem_ops; 596 + 597 + /* CS delays */ 598 + struct spi_delay cs_setup; 599 + struct spi_delay cs_hold; 600 + struct spi_delay cs_inactive; 617 601 618 602 /* gpio chip select */ 619 603 int *cs_gpios; ··· 789 763 * @cs_change: affects chipselect after this transfer completes 790 764 * @cs_change_delay: delay between cs deassert and assert when 791 765 * @cs_change is set and @spi_transfer is not the last in @spi_message 792 - * @cs_change_delay_unit: unit of cs_change_delay 766 + * @delay: delay to be introduced after this transfer before 767 + * (optionally) changing the chipselect status, then starting 768 + * the next transfer or completing this @spi_message. 793 769 * @delay_usecs: microseconds to delay after this transfer before 794 770 * (optionally) changing the chipselect status, then starting 795 771 * the next transfer or completing this @spi_message. 796 - * @word_delay_usecs: microseconds to inter word delay after each word size 797 - * (set by bits_per_word) transmission. 798 - * @word_delay: clock cycles to inter word delay after each word size 772 + * @word_delay: inter word delay to be introduced after each word size 799 773 * (set by bits_per_word) transmission. 800 774 * @effective_speed_hz: the effective SCK-speed that was used to 801 775 * transfer this transfer. Set to 0 if the spi bus driver does ··· 909 883 #define SPI_NBITS_DUAL 0x02 /* 2bits transfer */ 910 884 #define SPI_NBITS_QUAD 0x04 /* 4bits transfer */ 911 885 u8 bits_per_word; 912 - u8 word_delay_usecs; 913 886 u16 delay_usecs; 914 - u16 cs_change_delay; 915 - u8 cs_change_delay_unit; 916 - #define SPI_DELAY_UNIT_USECS 0 917 - #define SPI_DELAY_UNIT_NSECS 1 918 - #define SPI_DELAY_UNIT_SCK 2 887 + struct spi_delay delay; 888 + struct spi_delay cs_change_delay; 889 + struct spi_delay word_delay; 919 890 u32 speed_hz; 920 - u16 word_delay; 921 891 922 892 u32 effective_speed_hz; 923 893 ··· 1018 996 list_del(&t->transfer_list); 1019 997 } 1020 998 999 + static inline int 1000 + spi_transfer_delay_exec(struct spi_transfer *t) 1001 + { 1002 + struct spi_delay d; 1003 + 1004 + if (t->delay_usecs) { 1005 + d.value = t->delay_usecs; 1006 + d.unit = SPI_DELAY_UNIT_USECS; 1007 + return spi_delay_exec(&d, NULL); 1008 + } 1009 + 1010 + return spi_delay_exec(&t->delay, t); 1011 + } 1012 + 1021 1013 /** 1022 1014 * spi_message_init_with_transfers - Initialize spi_message and append transfers 1023 1015 * @m: spi_message to be initialized ··· 1079 1043 kfree(m); 1080 1044 } 1081 1045 1082 - extern void spi_set_cs_timing(struct spi_device *spi, u8 setup, u8 hold, u8 inactive_dly); 1046 + extern int spi_set_cs_timing(struct spi_device *spi, 1047 + struct spi_delay *setup, 1048 + struct spi_delay *hold, 1049 + struct spi_delay *inactive); 1083 1050 1084 1051 extern int spi_setup(struct spi_device *spi); 1085 1052 extern int spi_async(struct spi_device *spi, struct spi_message *message);
+1 -1
sound/soc/pxa/mmp-sspa.c
··· 177 177 /* we can only change the settings if the port is not in use */ 178 178 if ((mmp_sspa_read_reg(sspa, SSPA_TXSP) & SSPA_SP_S_EN) || 179 179 (mmp_sspa_read_reg(sspa, SSPA_RXSP) & SSPA_SP_S_EN)) { 180 - dev_err(&sspa->pdev->dev, 180 + dev_err(sspa->dev, 181 181 "can't change hardware dai format: stream is in use\n"); 182 182 return -EINVAL; 183 183 }
+5 -5
sound/soc/pxa/pxa-ssp.c
··· 52 52 53 53 static void dump_registers(struct ssp_device *ssp) 54 54 { 55 - dev_dbg(&ssp->pdev->dev, "SSCR0 0x%08x SSCR1 0x%08x SSTO 0x%08x\n", 55 + dev_dbg(ssp->dev, "SSCR0 0x%08x SSCR1 0x%08x SSTO 0x%08x\n", 56 56 pxa_ssp_read_reg(ssp, SSCR0), pxa_ssp_read_reg(ssp, SSCR1), 57 57 pxa_ssp_read_reg(ssp, SSTO)); 58 58 59 - dev_dbg(&ssp->pdev->dev, "SSPSP 0x%08x SSSR 0x%08x SSACD 0x%08x\n", 59 + dev_dbg(ssp->dev, "SSPSP 0x%08x SSSR 0x%08x SSACD 0x%08x\n", 60 60 pxa_ssp_read_reg(ssp, SSPSP), pxa_ssp_read_reg(ssp, SSSR), 61 61 pxa_ssp_read_reg(ssp, SSACD)); 62 62 } ··· 223 223 clk_id = PXA_SSP_CLK_EXT; 224 224 } 225 225 226 - dev_dbg(&ssp->pdev->dev, 226 + dev_dbg(ssp->dev, 227 227 "pxa_ssp_set_dai_sysclk id: %d, clk_id %d, freq %u\n", 228 228 cpu_dai->id, clk_id, freq); 229 229 ··· 316 316 317 317 ssacd |= (0x6 << 4); 318 318 319 - dev_dbg(&ssp->pdev->dev, 319 + dev_dbg(ssp->dev, 320 320 "Using SSACDD %x to supply %uHz\n", 321 321 val, freq); 322 322 break; ··· 687 687 * - complain loudly and fail if they've not been set up yet. 688 688 */ 689 689 if ((sscr0 & SSCR0_MOD) && !ttsa) { 690 - dev_err(&ssp->pdev->dev, "No TDM timeslot configured\n"); 690 + dev_err(ssp->dev, "No TDM timeslot configured\n"); 691 691 return -EINVAL; 692 692 } 693 693