Fix SATA support for NSP SoCs
v4 cover Fix SATA support for NSP SoCs
This patch series fixes SATA on the Northstar Plus (BCM58xxx/8831x) which was broken due to a number of things:
- the SATA PHY assumed separate PCB windows when a shared one is used for this generation of SoCs
- the clock/reset (IDM) was not being configured by the driver which meant that depending upon what the boot loader did, or did not, we could have had the AHCI controller still in reset by then
- on some reference boards, the AHCI controller is not DMA coherent, assuming so leads to all sorts of timeouts, data corruption, etc.
Since this touches several subsystems: DT, PHY, AHCI and DTS, I would be keen on having Damien merge all of those via his tree if acceptable by the DT and PHY maintainers, I am OK either way for Broadcom SoC.
Thanks!
Changes in v4:
- move entire allOf to the bottom, before "unevaluatedProperties" per Krzysztof's feedback
Changes in v3:
- actually submit the addressed feedback
Changes in v2:
- addressed Damien's comment: comment line too long, imbalanced IDM call sequence in suspend/resume compared to probe
Florian Fainelli (6):
phy: broadcom: brcm-sata: Keep NSP ports in the shared PCB window
dt-bindings: ata: sata-brcm: Describe the NSP IDM registers
ata: ahci_brcm: Initialize the NSP interface clock and reset
ARM: dts: broadcom: Add the NSP SATA IDM registers
ARM: dts: broadcom: Use noncoherent SATA DMA on BCM958625HR
ARM: dts: broadcom: Enable SATA on BCM958625HR
.../bindings/ata/brcm,sata-brcm.yaml | 57 ++++++++++++------- arch/arm/boot/dts/broadcom/bcm-nsp.dtsi | 7 ++- arch/arm/boot/dts/broadcom/bcm958625hr.dts | 5 ++ drivers/ata/ahci_brcm.c | 36 ++++++++++++ drivers/phy/broadcom/phy-brcm-sata.c | 5 +- 5 files changed, 85 insertions(+), 25 deletions(-)
Signature · 1 line
2.53.0
PATCH v4 1/6 phy: broadcom: brcm-sata: Keep NSP ports in the shared PCB window
Northstar Plus has one PCB register aperture for both SATA ports. Its per-port OOB settings use separate banks, while the PLL registers are shared.
The 40nm MDIO refactor made all non-40nm platforms use a 0x1000 per-port stride. NSP previously passed the shared base directly to the helpers. For port 1, the new stride moves the bank selector from 0x1804033c to 0x1804133c in the AHCI register window, outside the PHY resource, and prevents the second PHY from being initialized correctly.
Exclude NSP from the per-port aperture offset in both read and write helpers, preserving its existing bank selection.
--- drivers/phy/broadcom/phy-brcm-sata.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/phy/broadcom/phy-brcm-sata.c +3 -2
@@ -215,9 +215,10 @@ static void brcm_sata_phy_wr(struct brcm_sata_port *port, u32 bank,void __iomem *pcb_base = priv->phy_base;u32 tmp; +/* NSP has one shared PCB window; its per-port OOB banks are selected below. */ if (priv->version ==BRCM_SATA_PHY_STB_40NM ) bank += (port->portnum *SATA_PCB_REG_40NM_SPACE_SIZE ); -else +else if (priv->version !=BRCM_SATA_PHY_IPROC_NSP ) pcb_base += (port->portnum *SATA_PCB_REG_28NM_SPACE_SIZE );writel (bank, pcb_base +SATA_PCB_BANK_OFFSET );
@@ -233,7 +234,7 @@ static u32 brcm_sata_phy_rd(struct brcm_sata_port *port, u32 bank, u32 ofs)if (priv->version ==BRCM_SATA_PHY_STB_40NM ) bank += (port->portnum *SATA_PCB_REG_40NM_SPACE_SIZE ); -else +else if (priv->version !=BRCM_SATA_PHY_IPROC_NSP ) pcb_base += (port->portnum *SATA_PCB_REG_28NM_SPACE_SIZE );writel (bank, pcb_base +SATA_PCB_BANK_OFFSET );
Signature · 1 line
2.53.0
Re: [PATCH v4 1/6] phy: broadcom: brcm-sata: Keep NSP ports in the shared PCB window
Quoted 36 lines · Florian Fainelli
Northstar Plus has one PCB register aperture for both SATA ports. Its per-port OOB settings use separate banks, while the PLL registers are shared.
The 40nm MDIO refactor made all non-40nm platforms use a
0x1000per-port stride. NSP previously passed the shared base directly to the helpers. For port 1, the new stride moves the bank selector from0x1804033cto0x1804133cin the AHCI register window, outside the PHY resource, and prevents the second PHY from being initialized correctly.Exclude NSP from the per-port aperture offset in both read and write helpers, preserving its existing bank selection.
Fixes 0ed41b33882c ("phy: brcm-sata: Correct MDIO operations for 40nm platforms")Signed-off-by Florian Fainelli <[email protected]>--- drivers/phy/broadcom/phy-brcm-sata.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)drivers/phy/broadcom/phy-brcm-sata.c +2
-1@@ -215,9 +215,10 @@ static void brcm_sata_phy_wr(struct brcm_sata_port *port, u32 bank,void __iomem *pcb_base = priv->phy_base;u32 tmp; +/* NSP has one shared PCB window; its per-port OOB banks are selected below. */ if (priv->version ==BRCM_SATA_PHY_STB_40NM ) bank += (port->portnum *SATA_PCB_REG_40NM_SPACE_SIZE ); -else +else if (priv->version !=BRCM_SATA_PHY_IPROC_NSP ) pcb_base += (port->portnum *SATA_PCB_REG_28NM_SPACE_SIZE );writel (bank, pcb_base +SATA_PCB_BANK_OFFSET );
drivers/phy/broadcom/phy-brcm-sata.c static u32 brcm_sata_phy_rd(struct brcm_sata_port *port, u32 bank, u32 ofs) · line 240
Quoted 8 lines
drivers/phy/broadcom/phy-brcm-sata.c +1
-1@@ -233,7 +234,7 @@ static u32 brcm_sata_phy_rd(struct brcm_sata_port *port, u32 bank, u32 ofs)if (priv->version ==BRCM_SATA_PHY_STB_40NM ) bank += (port->portnum *SATA_PCB_REG_40NM_SPACE_SIZE ); -else +else if (priv->version !=BRCM_SATA_PHY_IPROC_NSP ) pcb_base += (port->portnum *SATA_PCB_REG_28NM_SPACE_SIZE );writel (bank, pcb_base +SATA_PCB_BANK_OFFSET );
Vinod, can you apply this patch now since the other 5 went through their respective trees? Thanks!
Signature · 1 line
Florian
PATCH v4 2/6 dt-bindings: ata: sata-brcm: Describe the NSP IDM registers
In reply to Florian FainelliNorthstar Plus uses the SATA IDM block to enable the interface clock and deassert the core reset before accessing the controller registers.
Allow an optional third register region named "idm" for the NSP controller. Keep other compatibles limited to their existing two register regions and allow older NSP descriptions without the IDM.
--- .../bindings/ata/brcm,sata-brcm.yaml | 57 ++++++++++++------- 1 file changed, 37 insertions(+), 20 deletions(-)
Documentation/devicetree/bindings/ata/brcm,sata-brcm.yaml +37 -20
@@ -13,9 +13,6 @@ description: maintainers: - Florian Fainelli <[email protected]> -allOf: - - $ref: ahci-common.yaml# - properties: compatible: oneOf:
@@ -30,32 +27,19 @@ properties: - const: brcm,bcm-nsp-ahci reg: - maxItems: 2 + minItems: 2 + maxItems: 3 reg-names: + minItems: 2 items: - const: ahci - const: top-ctrl + - const: idm interrupts: maxItems: 1 -if: - properties: - compatible: - contains: - enum: - - brcm,bcm7216-ahci - - brcm,bcm63138-ahci -then: - properties: - resets: - maxItems: 1 - reset-names: - enum: - - rescal - - ahci - required: - compatible - reg
@@ -63,6 +47,39 @@ required: - "#address-cells" - "#size-cells" +allOf: + - $ref: ahci-common.yaml# + - if: + properties: + compatible: + contains: + const: brcm,bcm-nsp-ahci + then: + properties: + reg: + description: AHCI, top control and optional IDM register regions + else: + properties: + reg: + maxItems: 2 + reg-names: + maxItems: 2 + - if: + properties: + compatible: + contains: + enum: + - brcm,bcm7216-ahci + - brcm,bcm63138-ahci + then: + properties: + resets: + maxItems: 1 + reset-names: + enum: + - rescal + - ahci + unevaluatedProperties: false examples:
Signature · 1 line
2.53.0
Re: [PATCH v4 2/6] dt-bindings: ata: sata-brcm: Describe the NSP IDM registers
Quoted 11 lines · Florian Fainelli
Northstar Plus uses the SATA IDM block to enable the interface clock and deassert the core reset before accessing the controller registers.
Allow an optional third register region named "idm" for the NSP controller. Keep other compatibles limited to their existing two register regions and allow older NSP descriptions without the IDM.
Signed-off-by Florian Fainelli <[email protected]>--- .../bindings/ata/brcm,sata-brcm.yaml | 57 ++++++++++++------- 1 file changed, 37 insertions(+), 20 deletions(-)
Best regards,
Krzysztof
PATCH v4 3/6 ata: ahci_brcm: Initialize the NSP interface clock and reset
In reply to Florian FainelliThe NSP probe path assumes firmware has enabled the SATA IDM interface clock and released the core reset. The downstream iProc config_AHCI() sequence explicitly performs both operations before accessing AHCI. Without that setup, a cold boot can access an inactive controller.
Map the optional NSP IDM register region and enable the interface clock before releasing reset, retaining the downstream settling intervals. Perform the sequence at probe and resume before reconfiguring SATA.
Keep the resource optional so older device trees continue to rely on firmware initialization.
--- drivers/ata/ahci_brcm.c | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+)
drivers/ata/ahci_brcm.c +36 -0
@@ -6,7 +6,9 @@*/ #include <linux/ahci_platform.h> +#include <linux/bcma/bcma_regs.h> #include <linux/compiler.h> +#include <linux/delay.h> #include <linux/device.h> #include <linux/init.h> #include <linux/interrupt.h>
@@ -83,6 +85,7 @@ enum brcm_ahci_quirks {struct brcm_ahci_priv {struct device *dev;void __iomem *top_ctrl; +void __iomem *idm;u32 port_mask;u32 quirks;enum brcm_ahci_version version;
@@ -230,6 +233,25 @@ static u32 brcm_ahci_get_portmask(struct ahci_host_priv *hpriv,return impl; } +static void brcm_sata_init_idm (struct brcm_ahci_priv *priv) +{ +u32 data; + +if (!priv->idm) +return ; + +/* Enable the interface clock before releasing the SATA core reset. */ + data =readl (priv->idm +BCMA_IOCTL ); +writel (data |BCMA_IOCTL_CLK , priv->idm +BCMA_IOCTL ); +readl (priv->idm +BCMA_IOCTL ); +usleep_range (1000 ,2000 ); + + data =readl (priv->idm +BCMA_RESET_CTL ); +writel (data & ~BCMA_RESET_CTL_RESET , priv->idm +BCMA_RESET_CTL ); +readl (priv->idm +BCMA_RESET_CTL ); +usleep_range (1000 ,2000 ); +} +static void brcm_sata_init (struct brcm_ahci_priv *priv) {void __iomem *ctrl = priv->top_ctrl +SATA_TOP_CTRL_BUS_CTRL ;
@@ -376,6 +398,9 @@ static int __maybe_unused brcm_ahci_resume(struct device *dev)if (ret)return ret; +/* Initialize the IDM before enabling the controller clocks. */ +brcm_sata_init_idm (priv); +/* Make sure clocks are turned on before re-configuration */ ret =ahci_platform_enable_clks (hpriv);if (ret)
@@ -453,6 +478,14 @@ static int brcm_ahci_probe(struct platform_device *pdev) priv->version = (unsigned long )of_id->data; priv->dev = dev; +/* Older NSP device trees rely on firmware to initialize the IDM. */ +if (priv->version ==BRCM_SATA_NSP && +platform_get_resource_byname (pdev,IORESOURCE_MEM ,"idm" )) { + priv->idm =devm_platform_ioremap_resource_byname (pdev,"idm" ); +if (IS_ERR (priv->idm)) +return PTR_ERR (priv->idm); + } + priv->top_ctrl =devm_platform_ioremap_resource_byname (pdev,"top-ctrl" );if (IS_ERR (priv->top_ctrl))return PTR_ERR (priv->top_ctrl);
@@ -493,6 +526,9 @@ static int brcm_ahci_probe(struct platform_device *pdev)if (ret)return ret; +/* Initialize the IDM before enabling the controller clocks. */ +brcm_sata_init_idm (priv); + ret =ahci_platform_enable_clks (hpriv);if (ret) goto out_reset;
Signature · 1 line
2.53.0
PATCH v4 4/6 ARM: dts: broadcom: Add the NSP SATA IDM registers
In reply to Florian FainelliThe NSP SATA description omits the IDM block at 0x1811e000, leaving the interface clock and core reset dependent on firmware initialization.
Supply the IDM as the third controller register region so ahci_brcm can perform the downstream clock/reset sequence. Extend the AXI bus range to cover the complete IDM aperture.
--- arch/arm/boot/dts/broadcom/bcm-nsp.dtsi | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
arch/arm/boot/dts/broadcom/bcm-nsp.dtsi +4 -3
@@ -168,7 +168,7 @@ periph_clk: periph_clk { axi: axi@18000000 { compatible = "simple-bus"; - ranges = <0x00000000 0x18000000 0x0011c40c>; + ranges = <0x00000000 0x18000000 0x0011f000>; #address-cells = <1>; #size-cells = <1>;
@@ -538,8 +538,9 @@ sata_phy1: sata-phy@1 { sata: sata@41000 { compatible = "brcm,bcm-nsp-ahci"; - reg-names = "ahci", "top-ctrl"; - reg = <0x41000 0x1000>, <0x40020 0x1c>; + reg-names = "ahci", "top-ctrl", "idm"; + reg = <0x41000 0x1000>, <0x40020 0x1c>, + <0x11e000 0x1000>; interrupts = <GIC_SPI 159 IRQ_TYPE_LEVEL_HIGH>; #address-cells = <1>; #size-cells = <0>;
Signature · 1 line
2.53.0
Florian Fainelli
AppliedRe: [PATCH v4 4/6] ARM: dts: broadcom: Add the NSP SATA IDM registers
From: Florian Fainelli <[email protected]>
Quoted 10 lines · Florian Fainelli
The NSP SATA description omits the IDM block at
0x1811e000, leaving the interface clock and core reset dependent on firmware initialization.Supply the IDM as the third controller register region so
ahci_brcmcan perform the downstream clock/reset sequence. Extend the AXI bus range to cover the complete IDM aperture.Fixes 8dbcad020f2e ("ARM: dts: nsp: Add sata device tree entry")Signed-off-by Florian Fainelli <[email protected]>---
Applied to https://github.com/Broadcom/stblinux/commits/devicetree/next, thanks! --
Florian
PATCH v4 5/6 ARM: dts: broadcom: Use noncoherent SATA DMA on BCM958625HR
In reply to Florian FainelliThe AHCI controller on BCM958625HR fails with the dma-coherent property inherited from bcm-nsp.dtsi. Soft reset times out waiting for the first FIS command, subsequent engine resets fail, and the disk is not detected.
AHCI allocates its command tables and received-FIS buffers with the DMA API. Declaring the controller coherent bypasses the cache handling that these buffers require on this board. Removing the property restores hard disk detection and operation, as confirmed with a diagnostic DTB that changed only this property.
Use noncoherent DMA for SATA on BCM958625HR, matching the downstream SDK.
--- arch/arm/boot/dts/broadcom/bcm958625hr.dts | 4 ++++ 1 file changed, 4 insertions(+)
arch/arm/boot/dts/broadcom/bcm958625hr.dts +4 -0
@@ -182,6 +182,10 @@ partition@700000 { }; }; +&sata { + /delete-property/ dma-coherent; +}; + &sata_phy0 { status = "okay"; };
Signature · 1 line
2.53.0
Florian Fainelli
AppliedRe: [PATCH v4 5/6] ARM: dts: broadcom: Use noncoherent SATA DMA on BCM958625HR
From: Florian Fainelli <[email protected]>
Quoted 10 lines · Florian Fainelli
The AHCI controller on BCM958625HR fails with the dma-coherent property inherited from
bcm-nsp.dtsi. Soft reset times out waiting for the first FIS command, subsequent engine resets fail, and the disk is not detected.AHCI allocates its command tables and received-FIS buffers with the DMA API. Declaring the controller coherent bypasses the cache handling that these buffers require on this board. Removing the property restores hard disk detection and operation, as confirmed with a diagnostic DTB that changed only this property.
Quoted 5 lines
Use noncoherent DMA for SATA on BCM958625HR, matching the downstream SDK.
Fixes 56e2ff0346a3 ("ARM: dts: NSP: Add dma-coherent to relevant DT entries")Signed-off-by Florian Fainelli <[email protected]>---
Applied to https://github.com/Broadcom/stblinux/commits/devicetree/next, thanks! --
Florian
PATCH v4 6/6 ARM: dts: broadcom: Enable SATA on BCM958625HR
In reply to Florian FainelliCommit 77416ab35f57 ("ARM: dts: NSP: Disable AHCI controller for HR NSP boards") disabled AHCI after reports of boot hangs. Both SATA PHYs remain enabled, but the disabled controller leaves the eSATA ports unavailable.
With explicit IDM clock/reset setup and the corrected shared PHY register aperture in place, enable the controller on BCM958625HR.
--- arch/arm/boot/dts/broadcom/bcm958625hr.dts | 1 + 1 file changed, 1 insertion(+)
arch/arm/boot/dts/broadcom/bcm958625hr.dts +1 -0
@@ -184,6 +184,7 @@ partition@700000 { &sata { /delete-property/ dma-coherent; + status = "okay"; }; &sata_phy0 {
Signature · 1 line
2.53.0
Florian Fainelli
AppliedRe: [PATCH v4 6/6] ARM: dts: broadcom: Enable SATA on BCM958625HR
From: Florian Fainelli <[email protected]>
Quoted 10 lines · Florian Fainelli
Commit
77416ab35f57("ARM: dts: NSP: Disable AHCI controller for HR NSP boards") disabled AHCI after reports of boot hangs. Both SATA PHYs remain enabled, but the disabled controller leaves the eSATA ports unavailable.With explicit IDM clock/reset setup and the corrected shared PHY register aperture in place, enable the controller on BCM958625HR.
Signed-off-by Florian Fainelli <[email protected]>---
Applied to https://github.com/Broadcom/stblinux/commits/devicetree/next, thanks! --
Florian
Niklas Cassel
maintainerHello Florian,
Quoted 11 lines · Florian Fainelli
This patch series fixes SATA on the Northstar Plus (BCM58xxx/8831x) which was broken due to a number of things:
- the SATA PHY assumed separate PCB windows when a shared one is used for this generation of SoCs
- the clock/reset (IDM) was not being configured by the driver which meant that depending upon what the boot loader did, or did not, we could have had the AHCI controller still in reset by then
- on some reference boards, the AHCI controller is not DMA coherent, assuming so leads to all sorts of timeouts, data corruption, etc.
Quoted 3 lines
Since this touches several subsystems: DT, PHY, AHCI and DTS, I would be keen on having Damien merge all of those via his tree if acceptable by the DT and PHY maintainers, I am OK either way for Broadcom SoC.
Patch 2 (after we get an R-b from DT maintainers) and patch 3 can go via libata tree, but the normal way would be for phy changes to go via PHY tree and device tree changes usually go via arm-soc (and lately it seems to go via a broadcom specific tree first).
Kind regards,
Niklas
Re: (subset) [PATCH v4 0/6] Fix SATA support for NSP SoCs
In reply to Florian FainelliQuoted 11 lines · Florian Fainelli
This patch series fixes SATA on the Northstar Plus (BCM58xxx/8831x) which was broken due to a number of things:
- the SATA PHY assumed separate PCB windows when a shared one is used for this generation of SoCs
- the clock/reset (IDM) was not being configured by the driver which meant that depending upon what the boot loader did, or did not, we could have had the AHCI controller still in reset by then
- on some reference boards, the AHCI controller is not DMA coherent, assuming so leads to all sorts of timeouts, data corruption, etc.
Quoted 1 line
[...]
Applied to libata/linux.git (for-7.5), thanks!
[2/6] dt-bindings: ata: sata-brcm: Describe the NSP IDM registers
https://git.kernel.org/libata/linux/c/262e3bbc [3/6] ata: ahci_brcm: Initialize the NSP interface clock and reset https://git.kernel.org/libata/linux/c/14d30246
Kind regards,
Niklas
Re: (subset) [PATCH v4 0/6] Fix SATA support for NSP SoCs
Quoted 12 lines · Niklas Cassel
Quoted 11 lines · Florian Fainelli
This patch series fixes SATA on the Northstar Plus (BCM58xxx/8831x) which was broken due to a number of things:
- the SATA PHY assumed separate PCB windows when a shared one is used for this generation of SoCs
- the clock/reset (IDM) was not being configured by the driver which meant that depending upon what the boot loader did, or did not, we could have had the AHCI controller still in reset by then
- on some reference boards, the AHCI controller is not DMA coherent, assuming so leads to all sorts of timeouts, data corruption, etc.
Quoted 8 lines
Quoted 1 line
[...]
Applied to libata/linux.git (for-7.5), thanks!
[2/6] dt-bindings: ata: sata-brcm: Describe the NSP IDM registers
https://git.kernel.org/libata/linux/c/262e3bbc [3/6] ata: ahci_brcm: Initialize the NSP interface clock and reset https://git.kernel.org/libata/linux/c/14d30246
Thank you Niklas, Kishon, can you take patch #1 through your PHY tree and I will take patches 4-6 through the broadcom ARM SoC trees. Thanks!
Signature · 1 line
Florian