Fix SATA support for NSP SoCs
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!
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 | 20 ++++++++++- arch/arm/boot/dts/broadcom/bcm-nsp.dtsi | 7 ++-- arch/arm/boot/dts/broadcom/bcm958625hr.dts | 5 +++ drivers/ata/ahci_brcm.c | 34 +++++++++++++++++++ drivers/phy/broadcom/phy-brcm-sata.c | 5 +-- 5 files changed, 65 insertions(+), 6 deletions(-)
Signature · 1 line
2.53.0
PATCH 2/6 dt-bindings: ata: sata-brcm: Describe the NSP IDM registers
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.
--- .../bindings/ata/brcm,sata-brcm.yaml | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-)
Documentation/devicetree/bindings/ata/brcm,sata-brcm.yaml +19 -1
@@ -15,6 +15,21 @@ maintainers: 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 properties: compatible:
@@ -30,12 +45,15 @@ 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
Signature · 1 line
2.53.0
PATCH 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 | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+)
drivers/ata/ahci_brcm.c +34 -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 taking the SATA core out of 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 ;
@@ -369,6 +391,8 @@ static int __maybe_unused brcm_ahci_resume(struct device *dev)struct brcm_ahci_priv *priv = hpriv->plat_data;int ret =0 ; +brcm_sata_init_idm (priv); + ret =reset_control_deassert (priv->rcdev_ahci);if (ret)return ret;
@@ -453,6 +477,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 +525,8 @@ static int brcm_ahci_probe(struct platform_device *pdev)if (ret)return ret; +brcm_sata_init_idm (priv); + ret =ahci_platform_enable_clks (hpriv);if (ret) goto out_reset;
Signature · 1 line
2.53.0
Damien Le Moal
maintainerRe: [PATCH 3/6] ata: ahci_brcm: Initialize the NSP interface clock and reset
Quoted 42 lines · Florian Fainelli
The 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.
Fixes 3ee2e6dcaa35 ("ata: ahci_brcm: Add support for Broadcom NSP SoC")Signed-off-by Florian Fainelli <[email protected]>--- drivers/ata/ahci_brcm.c | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+)drivers/ata/ahci_brcm.c +3
-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;
drivers/ata/ahci_brcm.c static u32 brcm_ahci_get_portmask(struct ahci_host_priv *hpriv, · line 243
Quoted 10 lines
drivers/ata/ahci_brcm.c +8
-0} +static void brcm_sata_init_idm (struct brcm_ahci_priv *priv) +{ +u32 data; + +if (!priv->idm) +return ; + +/* Enable the interface clock before taking the SATA core out of reset. */
Long line. Please split before 80 chars.
Quoted 39 lines
drivers/ata/ahci_brcm.c +21
-0+ 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 ;@@ -369,6 +391,8 @@ static int __maybe_unused brcm_ahci_resume(struct device *dev)struct brcm_ahci_priv *priv = hpriv->plat_data;int ret =0 ; +brcm_sata_init_idm (priv); + ret =reset_control_deassert (priv->rcdev_ahci);if (ret)return ret;@@ -453,6 +477,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);
drivers/ata/ahci_brcm.c static int brcm_ahci_probe(struct platform_device *pdev) · line 528
Quoted 4 lines
drivers/ata/ahci_brcm.c +1
-0@@ -493,6 +525,8 @@ static int brcm_ahci_probe(struct platform_device *pdev)if (ret)return ret; +brcm_sata_init_idm (priv);
Here, this is called *before* the clocks are enabled, but in brcm_ahci_resume(), brcm_sata_init() -> brcm_sata_init_idm(() is called *after* the clocks are enabled. Does this matter?
Quoted 4 lines
drivers/ata/ahci_brcm.c +1
-0+ ret =ahci_platform_enable_clks (hpriv);if (ret) goto out_reset;
Signature · 2 lines
Damien Le Moal Western Digital Research
Re: [PATCH 3/6] ata: ahci_brcm: Initialize the NSP interface clock and reset
Quoted 98 lines · Damien Le Moal
Quoted 42 lines · Florian Fainelli
The 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.
Fixes 3ee2e6dcaa35 ("ata: ahci_brcm: Add support for Broadcom NSP SoC")Signed-off-by Florian Fainelli <[email protected]>--- drivers/ata/ahci_brcm.c | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+)drivers/ata/ahci_brcm.c +3
-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;drivers/ata/ahci_brcm.c static u32 brcm_ahci_get_portmask(struct ahci_host_priv *hpriv, · line 243
Quoted 10 lines
drivers/ata/ahci_brcm.c +8
-0} +static void brcm_sata_init_idm (struct brcm_ahci_priv *priv) +{ +u32 data; + +if (!priv->idm) +return ; + +/* Enable the interface clock before taking the SATA core out of reset. */ Long line. Please split before 80 chars.
Quoted 42 lines
drivers/ata/ahci_brcm.c +21
-0+ 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 ;@@ -369,6 +391,8 @@ static int __maybe_unused brcm_ahci_resume(struct device *dev)struct brcm_ahci_priv *priv = hpriv->plat_data;int ret =0 ; +brcm_sata_init_idm (priv); + ret =reset_control_deassert (priv->rcdev_ahci);if (ret)return ret;@@ -453,6 +477,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 +525,8 @@ static int brcm_ahci_probe(struct platform_device *pdev)if (ret)return ret;
Quoted 5 lines
drivers/ata/ahci_brcm.c static int brcm_ahci_probe(struct platform_device *pdev) · line 528
Quoted 1 line
drivers/ata/ahci_brcm.c +1
-0+brcm_sata_init_idm (priv);Here, this is called *before* the clocks are enabled, but in
brcm_ahci_resume(),brcm_sata_init()-> brcm_sata_init_idm(() is called *after* the clocks are enabled. Does this matter?
The NSP platform does not support suspend/resume but the consistency should be preserved, logically this should be just like during initialization, thanks!
Signature · 1 line
Florian
PATCH 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
PATCH 5/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.
This enablement has been build and schema checked. Cold-boot and eSATA I/O validation on HR hardware are still required to establish whether the original hang is resolved.
--- 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 { + status = "okay"; +}; + &sata_phy0 { status = "okay"; };
Signature · 1 line
2.53.0
PATCH 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 · 7 lines
2.53.0 -- linux-phy mailing list [email protected] https://lists.infradead.org/mailman/listinfo/linux-phy
PATCH 6/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 | 1 + 1 file changed, 1 insertion(+)
arch/arm/boot/dts/broadcom/bcm958625hr.dts +1 -0
@@ -183,6 +183,7 @@ partition@700000 { }; &sata { + /delete-property/ dma-coherent; status = "okay"; };
Signature · 1 line
2.53.0
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.
Argh, looks like I submitted patches 5 and 6 twice after I had re-ordered them, the correct order is in the cover letter:
ARM: dts: broadcom: Use noncoherent SATA DMA on BCM958625HR
ARM: dts: broadcom: Enable SATA on BCM958625HR
Will wait for feedback and resubmit if necessary. Thanks!
Signature · 1 line
Florian