[PATCH 4.4.y-cip 2/9] ARM: dts: r8a7742: Add USB 2.0 host support
Biju Das <biju.das.jz@...>
From: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
commit 4bb19c91d38e36b81e92de3d9b4e61d9b8928b54 upstream. Describe internal PCI bridge devices, USB phy device and link PCI USB devices to USB phy. Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com> Reviewed-by: Marian-Cristian Rotariu <marian-cristian.rotariu.rb@bp.renesas.com> Link: https://lore.kernel.org/r/1590356277-19993-7-git-send-email-prabhakar.mahadev-lad.rj@bp.renesas.com Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> [biju: changed clocks and power-domain properties, removed resets property] Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com> --- arch/arm/boot/dts/r8a7742.dtsi | 111 +++++++++++++++++++++++++++++++++ 1 file changed, 111 insertions(+) diff --git a/arch/arm/boot/dts/r8a7742.dtsi b/arch/arm/boot/dts/r8a7742.dtsi index d326602bee3f..b25b719fbd2b 100644 --- a/arch/arm/boot/dts/r8a7742.dtsi +++ b/arch/arm/boot/dts/r8a7742.dtsi @@ -964,6 +964,27 @@ status = "disabled"; }; + usbphy: usb-phy@e6590100 { + compatible = "renesas,usb-phy-r8a7742", + "renesas,rcar-gen2-usb-phy"; + reg = <0 0xe6590100 0 0x100>; + #address-cells = <1>; + #size-cells = <0>; + clocks = <&mstp7_clks R8A7742_CLK_HSUSB>; + clock-names = "usbhs"; + power-domains = <&cpg_clocks>; + status = "disabled"; + + usb0: usb-channel@0 { + reg = <0>; + #phy-cells = <1>; + }; + usb2: usb-channel@2 { + reg = <2>; + #phy-cells = <1>; + }; + }; + dmac0: dma-controller@e6700000 { compatible = "renesas,dmac-r8a7742", "renesas,rcar-dmac"; @@ -1549,6 +1570,96 @@ dma-channels = <13>; }; + pci0: pci@ee090000 { + compatible = "renesas,pci-r8a7742", + "renesas,pci-rcar-gen2"; + device_type = "pci"; + reg = <0 0xee090000 0 0xc00>, + <0 0xee080000 0 0x1100>; + interrupts = <GIC_SPI 108 IRQ_TYPE_LEVEL_HIGH>; + clocks = <&mstp7_clks R8A7742_CLK_EHCI>; + power-domains = <&cpg_clocks>; + status = "disabled"; + + bus-range = <0 0>; + #address-cells = <3>; + #size-cells = <2>; + #interrupt-cells = <1>; + ranges = <0x02000000 0 0xee080000 0 0xee080000 0 0x00010000>; + interrupt-map-mask = <0xf800 0 0 0x7>; + interrupt-map = <0x0000 0 0 1 &gic GIC_SPI 108 IRQ_TYPE_LEVEL_HIGH>, + <0x0800 0 0 1 &gic GIC_SPI 108 IRQ_TYPE_LEVEL_HIGH>, + <0x1000 0 0 2 &gic GIC_SPI 108 IRQ_TYPE_LEVEL_HIGH>; + + usb@1,0 { + reg = <0x800 0 0 0 0>; + phys = <&usb0 0>; + phy-names = "usb"; + }; + + usb@2,0 { + reg = <0x1000 0 0 0 0>; + phys = <&usb0 0>; + phy-names = "usb"; + }; + }; + + pci1: pci@ee0b0000 { + compatible = "renesas,pci-r8a7742", + "renesas,pci-rcar-gen2"; + device_type = "pci"; + reg = <0 0xee0b0000 0 0xc00>, + <0 0xee0a0000 0 0x1100>; + interrupts = <GIC_SPI 112 IRQ_TYPE_LEVEL_HIGH>; + clocks = <&mstp7_clks R8A7742_CLK_EHCI>; + power-domains = <&cpg_clocks>; + status = "disabled"; + + bus-range = <1 1>; + #address-cells = <3>; + #size-cells = <2>; + #interrupt-cells = <1>; + ranges = <0x02000000 0 0xee0a0000 0 0xee0a0000 0 0x00010000>; + interrupt-map-mask = <0xf800 0 0 0x7>; + interrupt-map = <0x0000 0 0 1 &gic GIC_SPI 112 IRQ_TYPE_LEVEL_HIGH>, + <0x0800 0 0 1 &gic GIC_SPI 112 IRQ_TYPE_LEVEL_HIGH>, + <0x1000 0 0 2 &gic GIC_SPI 112 IRQ_TYPE_LEVEL_HIGH>; + }; + + pci2: pci@ee0d0000 { + compatible = "renesas,pci-r8a7742", + "renesas,pci-rcar-gen2"; + device_type = "pci"; + clocks = <&mstp7_clks R8A7742_CLK_EHCI>; + power-domains = <&cpg_clocks>; + reg = <0 0xee0d0000 0 0xc00>, + <0 0xee0c0000 0 0x1100>; + interrupts = <GIC_SPI 113 IRQ_TYPE_LEVEL_HIGH>; + status = "disabled"; + + bus-range = <2 2>; + #address-cells = <3>; + #size-cells = <2>; + #interrupt-cells = <1>; + ranges = <0x02000000 0 0xee0c0000 0 0xee0c0000 0 0x00010000>; + interrupt-map-mask = <0xf800 0 0 0x7>; + interrupt-map = <0x0000 0 0 1 &gic GIC_SPI 113 IRQ_TYPE_LEVEL_HIGH>, + <0x0800 0 0 1 &gic GIC_SPI 113 IRQ_TYPE_LEVEL_HIGH>, + <0x1000 0 0 2 &gic GIC_SPI 113 IRQ_TYPE_LEVEL_HIGH>; + + usb@1,0 { + reg = <0x20800 0 0 0 0>; + phys = <&usb2 0>; + phy-names = "usb"; + }; + + usb@2,0 { + reg = <0x21000 0 0 0 0>; + phys = <&usb2 0>; + phy-names = "usb"; + }; + }; + sdhi0: mmc@ee100000 { compatible = "renesas,sdhi-r8a7742", "renesas,rcar-gen2-sdhi"; -- 2.17.1
|
|
[PATCH 4.4.y-cip 1/9] dt-bindings: phy: rcar-gen2: Add r8a7742 support
Biju Das <biju.das.jz@...>
From: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
commit 9184450a95f6f446dc435cad9c5409c06373eaf1 upstream. Add USB PHY support for r8a7742 SoC. Renesas RZ/G1H (R8A7742) USB PHY is identical to the R-Car Gen2 family. Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com> Reviewed-by: Marian-Cristian Rotariu <marian-cristian.rotariu.rb@bp.renesas.com> Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be> Signed-off-by: Rob Herring <robh@kernel.org> Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com> --- Documentation/devicetree/bindings/phy/rcar-gen2-phy.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Documentation/devicetree/bindings/phy/rcar-gen2-phy.txt b/Documentation/devicetree/bindings/phy/rcar-gen2-phy.txt index 35c51d8bcd56..7b1672fb360f 100644 --- a/Documentation/devicetree/bindings/phy/rcar-gen2-phy.txt +++ b/Documentation/devicetree/bindings/phy/rcar-gen2-phy.txt @@ -4,7 +4,8 @@ This file provides information on what the device node for the R-Car generation 2 USB PHY contains. Required properties: -- compatible: "renesas,usb-phy-r8a7743" if the device is a part of R8A7743 SoC. +- compatible: "renesas,usb-phy-r8a7742" if the device is a part of R8A7742 SoC. + "renesas,usb-phy-r8a7743" if the device is a part of R8A7743 SoC. "renesas,usb-phy-r8a7744" if the device is a part of R8A7744 SoC. "renesas,usb-phy-r8a7745" if the device is a part of R8A7745 SoC. "renesas,usb-phy-r8a77470" if the device is a part of R8A77470 SoC. -- 2.17.1
|
|
[PATCH 4.4.y-cip 0/9] Add USB[2.0|3.0] support
Biju Das <biju.das.jz@...>
This patch series aims to add USB2.0/USB3.0 support for iWave
RZ/G1H platform. All the patches in this series are cherrypicked from mainline and it is based linux-4.4.y-cip. Biju Das (1): usb: host: xhci-plat: Add r8a7742 support Lad Prabhakar (8): dt-bindings: phy: rcar-gen2: Add r8a7742 support ARM: dts: r8a7742: Add USB 2.0 host support dt-bindings: usb: renesas,usbhs: Add support for r8a7742 ARM: dts: r8a7742: Add USB-DMAC and HSUSB device nodes dt-bindings: usb: usb-xhci: Document r8a7742 support ARM: dts: r8a7742: Add XHCI support pinctrl: sh-pfc: r8a7790: Add USB1 PWEN pin and group ARM: dts: r8a7742-iwg21d-q7: Enable HSUSB, USB2.0 and xHCI .../devicetree/bindings/phy/rcar-gen2-phy.txt | 3 +- .../devicetree/bindings/usb/renesas_usbhs.txt | 1 + .../devicetree/bindings/usb/usb-xhci.txt | 4 +- arch/arm/boot/dts/r8a7742-iwg21d-q7.dts | 42 +++++ arch/arm/boot/dts/r8a7742.dtsi | 165 ++++++++++++++++++ drivers/pinctrl/sh-pfc/pfc-r8a7790.c | 11 +- drivers/usb/host/xhci-plat.c | 3 + 7 files changed, 225 insertions(+), 4 deletions(-) -- 2.17.1
|
|
Re: [PATCH 4.19.y-cip 0/2] Add sound support to R8A774E1 SoC
Lad Prabhakar
Hi Pavel,
toggle quoted messageShow quoted text
-----Original Message-----Thank you. Cheers, Prabhakar Best regards,
|
|
Re: [PATCH 4.19.y-cip 0/2] Add sound support to R8A774E1 SoC
Pavel Machek
Hi!
This patch series adds sound support to Renesas R8A774E1 SoC.Thanks, applied and pushed out. Best regards, Pavel -- DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
|
|
Re: [PATCH 4.19.y-cip 2/7] memory: add Renesas RPC-IF driver
Pavel Machek
Hi!
For this series, maybe squashing is not neccessary. It is pretty goodWould be nice will make them inline and squash it in the current+void rpcif_enable_rpm(struct rpcif *rpc)Should these go to header as static inlines? as-is. Okay, that's some rather evil code. It should really beThird parameter in regmap_read_poll_timeout() is the variable in which value is read and the fourth parameter condition has to be tied with the third parameter (there are similar instance in the kernel).+static int wait_msg_xfer_end(struct rpcif *rpc)This can't be right. sts is used uninitialized here. REGMAP_READ_POLL_TIMEOUT, because it is macro with weird semantics. Best regards, Pavel -- DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
|
|
Re: [PATCH 4.19.y-cip 7/7] spi: add Renesas RPC-IF driver
Lad Prabhakar
Hi Pavel,
toggle quoted messageShow quoted text
Thank you for the review.
-----Original Message-----Will do. Agreed shall fix that.+ error = spi_register_controller(ctlr);With just one user of the error exit, I'd avoid the goto. Agreed will replace that.+#ifdef CONFIG_PM_SLEEPCan you just add "__maybe_unused" annotation and avoid the ifdefs, Cheers, Prabhakar Best regards,
|
|
Re: [PATCH 4.19.y-cip 6/7] spi: spi-mem: Add a new API to support direct mapping
Lad Prabhakar
Hi Pavel,
toggle quoted messageShow quoted text
Thank you for the review.
-----Original Message-----Agreed. Ditto.+ } else if (ctlr->mem_ops && ctlr->mem_ops->dirmap_read) {and here. Agreed will fix that and squash the changes in current patch and post it as part of v2.+ } else {To help with if/else nesting. spi_mem_dirmap_write could use same Cheers, Prabhakar Best regards,
|
|
Re: [PATCH 4.19.y-cip 5/7] spi: spi-mem: Split spi_mem_exec_op() code
Lad Prabhakar
Hi Pavel,
toggle quoted messageShow quoted text
Thank you for the review.
-----Original Message-----Agreed (pm_runtime_put_noidle()). 😊+ mutex_lock(&ctlr->bus_lock_mutex);Plus hiding locking into function like this ... is quite Cheers, Prabhakar Best regards,
|
|
Re: [PATCH 4.19.y-cip 2/7] memory: add Renesas RPC-IF driver
Lad Prabhakar
Hi Pavel,
toggle quoted messageShow quoted text
Thank you for the review.
-----Original Message-----Agreed not sure why checkpatch failed to catch this for upstream. Cheers, Prabhakar Best regards,
|
|
Re: [PATCH 4.19.y-cip 2/7] memory: add Renesas RPC-IF driver
Lad Prabhakar
Hi Pavel,
toggle quoted messageShow quoted text
Thank you for the review.
-----Original Message-----Agreed will fix that and squash that in the current patch. Would be nice will make them inline and squash it in the current patch.+void rpcif_enable_rpm(struct rpcif *rpc)Should these go to header as static inlines? Third parameter in regmap_read_poll_timeout() is the variable in which value is read and the fourth parameter condition has to be tied with the third parameter (there are similar instance in the kernel).+static int wait_msg_xfer_end(struct rpcif *rpc)This can't be right. sts is used uninitialized here. Good catch this needs fixing (upstream too).+int rpcif_manual_xfer(struct rpcif *rpc)So we get failure in wait_msg_xfer_end(rpc); but then Agreed this needs fixing (upstream too).+static int rpcif_probe(struct platform_device *pdev)Does this need corresponding of_node_put()? Agreed will fix that.+struct rpcif_op {Weird formatting; we normally use spaces (not tabs) for this. Should be OK as this driver is intended only on R-Car Gen3 and RZ/G2x (arm64).+ struct {... Cheers, Prabhakar Best regards,
|
|
Re: [PATCH 4.19.y-cip 7/7] spi: add Renesas RPC-IF driver
Pavel Machek
Hi!
commit eb8d6d464a27850498dced21a8450e85d4a02009 upstream.Few lines here explaining the acronyms etc. would be nice. + error = spi_register_controller(ctlr);With just one user of the error exit, I'd avoid the goto. +#ifdef CONFIG_PM_SLEEPCan you just add "__maybe_unused" annotation and avoid the ifdefs, like atmel-quadspi.c does? Best regards, Pavel -- DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
|
|
Re: [PATCH 4.19.y-cip 6/7] spi: spi-mem: Add a new API to support direct mapping
Pavel Machek
Hi!
commit aa167f3fed0c37e0e4c707d4331d827661f46644 upstream. + * Return: the amount of data read from the memory device or a negative errorI'd do return ... here. + } else if (ctlr->mem_ops && ctlr->mem_ops->dirmap_read) {and here. + } else {To help with if/else nesting. spi_mem_dirmap_write could use same treatment. Best regards, Pavel -- DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
|
|
Re: [PATCH 4.19.y-cip 5/7] spi: spi-mem: Split spi_mem_exec_op() code
Pavel Machek
Hi!
From: Boris Brezillon <boris.brezillon@bootlin.com> +++ b/drivers/spi/spi-mem.c... + if (ctlr->auto_runtime_pm) {This misses pm_runtime_put() in the error case. + mutex_lock(&ctlr->bus_lock_mutex);Plus hiding locking into function like this ... is quite "interesting". Best regards, Pavel -- DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
|
|
Re: [PATCH 4.19.y-cip 2/7] memory: add Renesas RPC-IF driver
Pavel Machek
Hi!
From: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com> +int rpcif_manual_xfer(struct rpcif *rpc);Oh and I'd use normal C comment here. Best regards, Pavel -- DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
|
|
Re: [PATCH 4.19.y-cip 2/7] memory: add Renesas RPC-IF driver
Pavel Machek
Hi!
+EXPORT_SYMBOL(rpcif_sw_init);EXPORT_SYMBOL_GPL? +void rpcif_enable_rpm(struct rpcif *rpc)Should these go to header as static inlines? +static int wait_msg_xfer_end(struct rpcif *rpc)This can't be right. sts is used uninitialized here. +int rpcif_manual_xfer(struct rpcif *rpc)So we get failure in wait_msg_xfer_end(rpc); but then reset_control_reset(rpc->rstc); returns success and whole function returns success. Is that ok? +static int rpcif_probe(struct platform_device *pdev)Does this need corresponding of_node_put()? +struct rpcif_op {Weird formatting; we normally use spaces (not tabs) for this. + struct {... + struct {Are you sure this will be consistent accross architectures? Should the structure be marked attribute packed or something? Best regards, Pavel -- DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
|
|
A lot of compiles failing
Pavel Machek
Hi!
This is going on for a few days now, but today it seems worse than usual: https://gitlab.com/cip-project/cip-kernel/linux-cip/-/pipelines/220169843 builds are failing, 'HTTP 500 curl 22' error, so not a real build problem. I can probably just click restart... 6 times. But something is not there, and it is getting worse. Best regards, Pavel g for pod gitlab/runner-bcrayztp-project-2678032-concurrent-7hmhsr to be running, status is Pending 74Running on runner-bcrayztp-project-2678032-concurrent-7hmhsr via cip-project-v3-gitlab-runner-6dbd79945f-wdqqw... 76 Fetching changes with git depth set to 10... 00:18 77Initialized empty Git repository in /builds/cip-project/cip-kernel/linux-cip/.git/ 78Created fresh repository. 79error: RPC failed; HTTP 500 curl 22 The requested URL returned error: 500 80fatal: the remote end hung up unexpectedly 82 Uploading artifacts... 00:00 83WARNING: output: no matching files 84ERROR: No files to upload 86ERROR: Job failed: command terminated with exit code 1 -- DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
|
|
Re: [PATCH 4.19.y-cip 0/2] Add sound support to R8A774E1 SoC
Pavel Machek
Hi!
This patch series adds sound support to Renesas R8A774E1 SoC.I don't see any problems here. If there are no other comments, I can apply it. Best regards, Pavel -- DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
|
|
Re: [PATCH 4.19.y-cip 0/7] Add RPC-IF driver for RZ/G2x SoC's
Lad Prabhakar
Hi,
toggle quoted messageShow quoted text
-----Original Message-----Attached are the test results for RZ/G2{EM}. Cheers, Prabhakar Currently we are upstreaming clock [2] and pinctrl [3] changes
|
|
[PATCH 4.19.y-cip 7/7] spi: add Renesas RPC-IF driver
Lad Prabhakar
From: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
commit eb8d6d464a27850498dced21a8450e85d4a02009 upstream. Add the SPI driver for the Renesas RPC-IF. It's the "front end" driver using the "back end" APIs in the main driver to talk to the real hardware. We only implement the 'spi-mem' interface -- there's no need to implement the usual SPI driver methods... Based on the original patch by Mason Yang <masonccyang@mxic.com.tw>. Signed-off-by: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com> Link: https://lore.kernel.org/r/1ece0e6c-71af-f0f1-709e-571f4b0b4853@cogentembedded.com Signed-off-by: Mark Brown <broonie@kernel.org> Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com> --- drivers/spi/Kconfig | 6 ++ drivers/spi/Makefile | 1 + drivers/spi/spi-rpc-if.c | 216 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 223 insertions(+) create mode 100644 drivers/spi/spi-rpc-if.c diff --git a/drivers/spi/Kconfig b/drivers/spi/Kconfig index 0a7fd56c1ed9..461315967f96 100644 --- a/drivers/spi/Kconfig +++ b/drivers/spi/Kconfig @@ -514,6 +514,12 @@ config SPI_RB4XX help SPI controller driver for the Mikrotik RB4xx series boards. +config SPI_RPCIF + tristate "Renesas RPC-IF SPI driver" + depends on RENESAS_RPCIF + help + SPI driver for Renesas R-Car Gen3 RPC-IF. + config SPI_RSPI tristate "Renesas RSPI/QSPI controller" depends on SUPERH || ARCH_RENESAS || COMPILE_TEST diff --git a/drivers/spi/Makefile b/drivers/spi/Makefile index a90d55970036..e0b5478fde62 100644 --- a/drivers/spi/Makefile +++ b/drivers/spi/Makefile @@ -77,6 +77,7 @@ obj-$(CONFIG_SPI_PXA2XX_PCI) += spi-pxa2xx-pci.o obj-$(CONFIG_SPI_QUP) += spi-qup.o obj-$(CONFIG_SPI_ROCKCHIP) += spi-rockchip.o obj-$(CONFIG_SPI_RB4XX) += spi-rb4xx.o +obj-$(CONFIG_SPI_RPCIF) += spi-rpc-if.o obj-$(CONFIG_SPI_RSPI) += spi-rspi.o obj-$(CONFIG_SPI_S3C24XX) += spi-s3c24xx-hw.o spi-s3c24xx-hw-y := spi-s3c24xx.o diff --git a/drivers/spi/spi-rpc-if.c b/drivers/spi/spi-rpc-if.c new file mode 100644 index 000000000000..ed3e548227f4 --- /dev/null +++ b/drivers/spi/spi-rpc-if.c @@ -0,0 +1,216 @@ +// SPDX-License-Identifier: GPL-2.0 +// +// RPC-IF SPI/QSPI/Octa driver +// +// Copyright (C) 2018 ~ 2019 Renesas Solutions Corp. +// Copyright (C) 2019 Macronix International Co., Ltd. +// Copyright (C) 2019 - 2020 Cogent Embedded, Inc. +// + +#include <linux/module.h> +#include <linux/platform_device.h> +#include <linux/spi/spi.h> +#include <linux/spi/spi-mem.h> + +#include <memory/renesas-rpc-if.h> + +#include <asm/unaligned.h> + +static void rpcif_spi_mem_prepare(struct spi_device *spi_dev, + const struct spi_mem_op *spi_op, + u64 *offs, size_t *len) +{ + struct rpcif *rpc = spi_controller_get_devdata(spi_dev->controller); + struct rpcif_op rpc_op = { }; + + rpc_op.cmd.opcode = spi_op->cmd.opcode; + rpc_op.cmd.buswidth = spi_op->cmd.buswidth; + + if (spi_op->addr.nbytes) { + rpc_op.addr.buswidth = spi_op->addr.buswidth; + rpc_op.addr.nbytes = spi_op->addr.nbytes; + rpc_op.addr.val = spi_op->addr.val; + } + + if (spi_op->dummy.nbytes) { + rpc_op.dummy.buswidth = spi_op->dummy.buswidth; + rpc_op.dummy.ncycles = spi_op->dummy.nbytes * 8 / + spi_op->dummy.buswidth; + } + + if (spi_op->data.nbytes || (offs && len)) { + rpc_op.data.buswidth = spi_op->data.buswidth; + rpc_op.data.nbytes = spi_op->data.nbytes; + switch (spi_op->data.dir) { + case SPI_MEM_DATA_IN: + rpc_op.data.dir = RPCIF_DATA_IN; + rpc_op.data.buf.in = spi_op->data.buf.in; + break; + case SPI_MEM_DATA_OUT: + rpc_op.data.dir = RPCIF_DATA_OUT; + rpc_op.data.buf.out = spi_op->data.buf.out; + break; + case SPI_MEM_NO_DATA: + rpc_op.data.dir = RPCIF_NO_DATA; + break; + } + } else { + rpc_op.data.dir = RPCIF_NO_DATA; + } + + rpcif_prepare(rpc, &rpc_op, offs, len); +} + +static bool rpcif_spi_mem_supports_op(struct spi_mem *mem, + const struct spi_mem_op *op) +{ + if (!spi_mem_default_supports_op(mem, op)) + return false; + + if (op->data.buswidth > 4 || op->addr.buswidth > 4 || + op->dummy.buswidth > 4 || op->cmd.buswidth > 4 || + op->addr.nbytes > 4) + return false; + + return true; +} + +static ssize_t rpcif_spi_mem_dirmap_read(struct spi_mem_dirmap_desc *desc, + u64 offs, size_t len, void *buf) +{ + struct rpcif *rpc = + spi_controller_get_devdata(desc->mem->spi->controller); + + if (offs + desc->info.offset + len > U32_MAX) + return -EINVAL; + + rpcif_spi_mem_prepare(desc->mem->spi, &desc->info.op_tmpl, &offs, &len); + + return rpcif_dirmap_read(rpc, offs, len, buf); +} + +static int rpcif_spi_mem_dirmap_create(struct spi_mem_dirmap_desc *desc) +{ + struct rpcif *rpc = + spi_controller_get_devdata(desc->mem->spi->controller); + + if (desc->info.offset + desc->info.length > U32_MAX) + return -ENOTSUPP; + + if (!rpcif_spi_mem_supports_op(desc->mem, &desc->info.op_tmpl)) + return -ENOTSUPP; + + if (!rpc->dirmap && desc->info.op_tmpl.data.dir == SPI_MEM_DATA_IN) + return -ENOTSUPP; + + if (desc->info.op_tmpl.data.dir == SPI_MEM_DATA_OUT) + return -ENOTSUPP; + + return 0; +} + +static int rpcif_spi_mem_exec_op(struct spi_mem *mem, + const struct spi_mem_op *op) +{ + struct rpcif *rpc = + spi_controller_get_devdata(mem->spi->controller); + + rpcif_spi_mem_prepare(mem->spi, op, NULL, NULL); + + return rpcif_manual_xfer(rpc); +} + +static const struct spi_controller_mem_ops rpcif_spi_mem_ops = { + .supports_op = rpcif_spi_mem_supports_op, + .exec_op = rpcif_spi_mem_exec_op, + .dirmap_create = rpcif_spi_mem_dirmap_create, + .dirmap_read = rpcif_spi_mem_dirmap_read, +}; + +static int rpcif_spi_probe(struct platform_device *pdev) +{ + struct device *parent = pdev->dev.parent; + struct spi_controller *ctlr; + struct rpcif *rpc; + int error; + + ctlr = spi_alloc_master(&pdev->dev, sizeof(*rpc)); + if (!ctlr) + return -ENOMEM; + + rpc = spi_controller_get_devdata(ctlr); + rpcif_sw_init(rpc, parent); + + platform_set_drvdata(pdev, ctlr); + + ctlr->dev.of_node = parent->of_node; + + rpcif_enable_rpm(rpc); + + ctlr->num_chipselect = 1; + ctlr->mem_ops = &rpcif_spi_mem_ops; + + ctlr->bits_per_word_mask = SPI_BPW_MASK(8); + ctlr->mode_bits = SPI_CPOL | SPI_CPHA | SPI_TX_QUAD | SPI_RX_QUAD; + ctlr->flags = SPI_CONTROLLER_HALF_DUPLEX; + + rpcif_hw_init(rpc, false); + + error = spi_register_controller(ctlr); + if (error) { + dev_err(&pdev->dev, "spi_register_controller failed\n"); + goto err_put_ctlr; + } + return 0; + +err_put_ctlr: + rpcif_disable_rpm(rpc); + spi_controller_put(ctlr); + + return error; +} + +static int rpcif_spi_remove(struct platform_device *pdev) +{ + struct spi_controller *ctlr = platform_get_drvdata(pdev); + struct rpcif *rpc = spi_controller_get_devdata(ctlr); + + spi_unregister_controller(ctlr); + rpcif_disable_rpm(rpc); + + return 0; +} + +#ifdef CONFIG_PM_SLEEP +static int rpcif_spi_suspend(struct device *dev) +{ + struct spi_controller *ctlr = dev_get_drvdata(dev); + + return spi_controller_suspend(ctlr); +} + +static int rpcif_spi_resume(struct device *dev) +{ + struct spi_controller *ctlr = dev_get_drvdata(dev); + + return spi_controller_resume(ctlr); +} + +static SIMPLE_DEV_PM_OPS(rpcif_spi_pm_ops, rpcif_spi_suspend, rpcif_spi_resume); +#define DEV_PM_OPS (&rpcif_spi_pm_ops) +#else +#define DEV_PM_OPS NULL +#endif + +static struct platform_driver rpcif_spi_driver = { + .probe = rpcif_spi_probe, + .remove = rpcif_spi_remove, + .driver = { + .name = "rpc-if-spi", + .pm = DEV_PM_OPS, + }, +}; +module_platform_driver(rpcif_spi_driver); + +MODULE_DESCRIPTION("Renesas RPC-IF SPI driver"); +MODULE_LICENSE("GPL v2"); -- 2.17.1
|
|