Add support for MSCC Ocelot SPI
Subsystems (4)
Alexandre Belloni
maintainerv2 cover Add support for MSCC Ocelot SPI
Hello,
The MSCC MIPS SoC line uses a designware IP for the SPI controller but still requires some special handling to give control of the SPI interface to the IP and also has a specific handling for the chip select.
Changes in v2:
- Removed already applied patches
- separated DT binding changes from the driver patch
Alexandre Belloni (4):
dt-bindings: spi: snps,dw-apb-ssi: document Microsemi integration
spi: dw-mmio: add MSCC Ocelot support
mips: dts: mscc: Add spi on Ocelot
mips: dts: mscc: enable spi and NOR flash support on ocelot PCB123
arch/mips/boot/dts/mscc/ocelot.dtsi | 11 +++ arch/mips/boot/dts/mscc/ocelot_pcb123.dts | 10 +++ drivers/spi/spi-dw-mmio.c | 91 +++++++++++++++++++++++ 3 files changed, 112 insertions(+)
Signature · 1 line
2.18.0
Alexandre Belloni
maintainerPATCH v2 1/4 dt-bindings: spi: snps,dw-apb-ssi: document Microsemi integration
The integration of the Designware SPI controller on Microsemi SoCs requires an extra register set to be able to give the IP control of the SPI interface.
--- Documentation/devicetree/bindings/spi/snps,dw-apb-ssi.txt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
Documentation/devicetree/bindings/spi/snps,dw-apb-ssi.txt +3 -2
@@ -1,8 +1,9 @@ Synopsys DesignWare AMBA 2.0 Synchronous Serial Interface. Required properties: -- compatible : "snps,dw-apb-ssi" -- reg : The register base for the controller. +- compatible : "snps,dw-apb-ssi" or "mscc,<soc>-spi" +- reg : The register base for the controller. For "mscc,<soc>-spi", a second + register set is required (named ICPU_CFG:SPI_MST) - interrupts : One interrupt, used by the controller. - #address-cells : <1>, as required by generic SPI binding. - #size-cells : <0>, also as required by generic SPI binding.
Signature · 1 line
2.18.0
Alexandre Belloni
maintainerPATCH v2 2/4 spi: dw-mmio: add MSCC Ocelot support
In reply to Alexandre BelloniBecause the SPI controller deasserts the chip select when the TX fifo is empty (which may happen in the middle of a transfer), the CS should be handled by linux. Unfortunately, some or all of the first four chip selects are not muxable as GPIOs, depending on the SoC.
There is a way to bitbang those pins by using the SPI boot controller so use it to set the chip selects.
At init time, it is also necessary to give control of the SPI interface to the Designware IP.
---
Change in v2:
- correctly use device_get_match_data to retrieve the init function instead of hardcoding it.
.../bindings/spi/snps,dw-apb-ssi.txt | 5 +- drivers/spi/spi-dw-mmio.c | 91 +++++++++++++++++++ 2 files changed, 93 insertions(+), 3 deletions(-)
Documentation/devicetree/bindings/spi/snps,dw-apb-ssi.txt +2 -3
@@ -1,9 +1,8 @@ Synopsys DesignWare AMBA 2.0 Synchronous Serial Interface. Required properties: -- compatible : "snps,dw-apb-ssi" or "mscc,<soc>-spi" -- reg : The register base for the controller. For "mscc,<soc>-spi", a second - register set is required (named ICPU_CFG:SPI_MST) +- compatible : "snps,dw-apb-ssi" +- reg : The register base for the controller. - interrupts : One interrupt, used by the controller. - #address-cells : <1>, as required by generic SPI binding. - #size-cells : <0>, also as required by generic SPI binding.
drivers/spi/spi-dw-mmio.c +91 -0
124 lines not on this page · raw message
Signature · 1 line
2.18.0
Re: [PATCH v2 2/4] spi: dw-mmio: add MSCC Ocelot support
Quoted 10 lines · Alexandre Belloni
Because the SPI controller deasserts the chip select when the TX fifo is empty (which may happen in the middle of a transfer), the CS should be handled by linux. Unfortunately, some or all of the first four chip selects are not muxable as GPIOs, depending on the SoC.
There is a way to bitbang those pins by using the SPI boot controller so use it to set the chip selects.
At init time, it is also necessary to give control of the SPI interface to the Designware IP.
Thanks for an update! My comments below (most of them just about style).
First of all, can we use 'controller' over the 'master' in the code?
Quoted 8 lines
.../bindings/spi/snps,dw-apb-ssi.txt | 5 +-Required properties:
-- compatible : "snps,dw-apb-ssi" or "mscc,<soc>-spi"
-- reg : The register base for the controller. For "mscc,<soc>-spi", a second
- register set is required (named ICPU_CFG:SPI_MST)+- compatible : "snps,dw-apb-ssi" +- reg : The register base for the controller.
This hunk is odd.
drivers/spi/spi-dw-mmio.c line 45
Quoted 9 lines
struct dw_spi_mmio { struct dw_spi dws; struct clk *clk;drivers/spi/spi-dw-mmio.c +4
-0+void *priv; }; +#define MSCC_SPI_MST_SW_MODE 0x14 +#define MSCC_SPI_MST_SW_MODE_SW_PIN_CTRL_MODE BIT(13) +#define MSCC_SPI_MST_SW_MODE_SW_SPI_CS (x) (x << 5)
+ blank line ?
drivers/spi/spi-dw-mmio.c line 48
Quoted 4 lines
drivers/spi/spi-dw-mmio.c +3
-0+struct dw_spi_mscc { +struct regmap *syscon; +void __iomem *spi_mst;
A nit: do we need to repeat "spi" here?
drivers/spi/spi-dw-mmio.c line 75
Quoted 4 lines
drivers/spi/spi-dw-mmio.c +3
-0+}; +if (!enable) +dw_writel (dws,DW_SPI_SER ,BIT (cs));
This sounds like
dw_set_cs(spi, enable);
drivers/spi/spi-dw-mmio.c line 85
Quoted 2 lines
drivers/spi/spi-dw-mmio.c +2
-0+ dwsmscc =devm_kzalloc (&pdev->dev,sizeof (struct dw_spi_mscc ), +GFP_KERNEL );
sizeof(*dwsmcc) and one line in the result?
drivers/spi/spi-dw-mmio.c line 101
Quoted 2 lines
drivers/spi/spi-dw-mmio.c +2
-0+/* Deassert all CS */ +writel (0 , dwsmscc->spi_mst +MSCC_SPI_MST_SW_MODE );
Hmm... Don't we need to call dw_set_cs() for all of them as well? If yes, perhaps better to call custom set_cs() in a loop?
Signature · 2 lines
With Best Regards, Andy Shevchenko
Alexandre Belloni
maintainerRe: [PATCH v2 2/4] spi: dw-mmio: add MSCC Ocelot support
Quoted 19 lines · Andy Shevchenko
Quoted 10 lines · Alexandre Belloni
Because the SPI controller deasserts the chip select when the TX fifo is empty (which may happen in the middle of a transfer), the CS should be handled by linux. Unfortunately, some or all of the first four chip selects are not muxable as GPIOs, depending on the SoC.
There is a way to bitbang those pins by using the SPI boot controller so use it to set the chip selects.
At init time, it is also necessary to give control of the SPI interface to the Designware IP.
Thanks for an update! My comments below (most of them just about style).
First of all, can we use 'controller' over the 'master' in the code?
Quoted 1 line
.../bindings/spi/snps,dw-apb-ssi.txt | 5 +-
Quoted 9 lines
Quoted 6 lines
Required properties:
-- compatible : "snps,dw-apb-ssi" or "mscc,<soc>-spi"
-- reg : The register base for the controller. For "mscc,<soc>-spi", a second
- register set is required (named ICPU_CFG:SPI_MST)+- compatible : "snps,dw-apb-ssi" +- reg : The register base for the controller.This hunk is odd.
Indeed, I'm not exactly sure what happened. I'll make sure it is removed.
Quoted 12 lines
drivers/spi/spi-dw-mmio.c line 45
Quoted 9 lines
struct dw_spi_mmio { struct dw_spi dws; struct clk *clk;drivers/spi/spi-dw-mmio.c +4
-0+void *priv; }; +#define MSCC_SPI_MST_SW_MODE 0x14 +#define MSCC_SPI_MST_SW_MODE_SW_PIN_CTRL_MODE BIT(13) +#define MSCC_SPI_MST_SW_MODE_SW_SPI_CS (x) (x << 5)+ blank line ?
Quoted 7 lines
drivers/spi/spi-dw-mmio.c line 48
Quoted 4 lines
drivers/spi/spi-dw-mmio.c +3
-0+struct dw_spi_mscc { +struct regmap *syscon; +void __iomem *spi_mst;A nit: do we need to repeat "spi" here?
The register set is named SPI_MST in the datasheet so I would prefer keeping it that way. I don't think this is an issue as it is MSCC specific anyway.
The SI interface can be controlled by three different IPs, their name in the datasheet are SPI boot, SPI slave and SPI master. The DW IP in what is referred to as SPI master. The two other IPs can't be used under linux.
So I'd like to keep spi_mst in the defines and variable but I can probably tweak the comment to avoid the confusion.
Quoted 9 lines
drivers/spi/spi-dw-mmio.c line 75
Quoted 4 lines
drivers/spi/spi-dw-mmio.c +3
-0+}; +if (!enable) +dw_writel (dws,DW_SPI_SER ,BIT (cs));This sounds like
dw_set_cs(spi, enable);
That's right, I can probably use dw_spi_set_cs here
Quoted 11 lines
drivers/spi/spi-dw-mmio.c line 85
Quoted 2 lines
drivers/spi/spi-dw-mmio.c +2
-0+ dwsmscc =devm_kzalloc (&pdev->dev,sizeof (struct dw_spi_mscc ), +GFP_KERNEL );
sizeof(*dwsmcc)and one line in the result?drivers/spi/spi-dw-mmio.c line 101
Quoted 2 lines
drivers/spi/spi-dw-mmio.c +2
-0+/* Deassert all CS */ +writel (0 , dwsmscc->spi_mst +MSCC_SPI_MST_SW_MODE );Hmm... Don't we need to call
dw_set_cs()for all of them as well? If yes, perhaps better to call customset_cs()in a loop?
Most likely not, for the same reason why the common code is not doing it. The FIFO is definitively empty so the CS will be unset.
Signature · 3 lines
Alexandre Belloni, Bootlin (formerly Free Electrons) Embedded Linux and Kernel engineering https://bootlin.com
Alexandre Belloni
maintainerPATCH v2 3/4 mips: dts: mscc: Add spi on Ocelot
In reply to Alexandre BelloniAdd support for the SPI controller
--- arch/mips/boot/dts/mscc/ocelot.dtsi | 11 +++++++++++ 1 file changed, 11 insertions(+)
arch/mips/boot/dts/mscc/ocelot.dtsi +11 -0
@@ -91,6 +91,17 @@ status = "disabled"; }; + spi: spi@101000 { + compatible = "mscc,ocelot-spi", "snps,dw-apb-ssi"; + #address-cells = <1>; + #size-cells = <0>; + reg = <0x101000 0x100>, <0x3c 0x18>; + interrupts = <9>; + clocks = <&ahb_clk>; + + status = "disabled"; + }; + switch@1010000 { compatible = "mscc,vsc7514-switch"; reg = <0x1010000 0x10000>,
Signature · 1 line
2.18.0
Alexandre Belloni
maintainerPATCH v2 4/4 mips: dts: mscc: enable spi and NOR flash support on ocelot PCB123
In reply to Alexandre BelloniOcelot PCB123 has a SPI NOR connected on its SPI bus.
--- arch/mips/boot/dts/mscc/ocelot_pcb123.dts | 10 ++++++++++ 1 file changed, 10 insertions(+)
arch/mips/boot/dts/mscc/ocelot_pcb123.dts +10 -0
@@ -26,6 +26,16 @@ status = "okay"; }; +&spi { + status = "okay"; + + flash@0 { + compatible = "macronix,mx25l25635f", "jedec,spi-nor"; + spi-max-frequency = <20000000>; + reg = <0>; + }; +}; + &mdio0 { status = "okay"; };
Signature · 1 line
2.18.0