add support SATA for BMIPS_GENERIC
Subsystems (6)
v4 cover add support SATA for BMIPS_GENERIC
Hi all,
This patch series add support SATA for BMIPS_GENERIC.
Changes in v4:
- remove unused properties from bcm{7425,7342,7362}.dtsi
Changes in v3:
- fix typo quirk instead of quick
- disable NCQ before initialzing SATA controller endianness
- fix misnomer controlling phy interface
- remove brcm,broken-ncq and brcm,broken-phy properties from devicetree
- use compatible string for quirks
- use list for compatible strings
- add "Acked-by:" tags
Changes in v2:
- adds quirk for ncq
- adds quirk for phy interface control
- remove unused definitions in ahci_brcmstb
- combines compatible string
Jaedon Shin (10):
ata: ahci_brcmstb: add support MIPS-based platforms
ata: ahci_brcmstb: add quirk for broken ncq
ata: ahci_brcmstb: add quirk for different phy
ata: ahci_brcmstb: remove unused definitions
phy: phy_brcmstb_sata: remove duplicate definitions
phy: phy_brcmstb_sata: add data for phy version
phy: phy_brcmstb_sata: add support MIPS-based platforms
MIPS: BMIPS: brcmstb: add SATA/PHY nodes for bcm7425
MIPS: BMIPS: brcmstb: add SATA/PHY nodes for bcm7346
MIPS: BMIPS: brcmstb: add SATA/PHY nodes for bcm7362
.../devicetree/bindings/ata/brcm,sata-brcmstb.txt | 4 +- .../bindings/phy/brcm,brcmstb-sata-phy.txt | 1 + arch/mips/boot/dts/brcm/bcm7346.dtsi | 40 +++++++++++++++ arch/mips/boot/dts/brcm/bcm7362.dtsi | 40 +++++++++++++++ arch/mips/boot/dts/brcm/bcm7425.dtsi | 40 +++++++++++++++ arch/mips/boot/dts/brcm/bcm97346dbsmb.dts | 8 +++ arch/mips/boot/dts/brcm/bcm97362svmb.dts | 8 +++ drivers/ata/Kconfig | 2 +- drivers/ata/ahci_brcmstb.c | 58 +++++++++++++++++++++- drivers/phy/Kconfig | 4 +- drivers/phy/phy-brcmstb-sata.c | 47 ++++++++++++++---- 11 files changed, 236 insertions(+), 16 deletions(-)
Signature · 1 line
2.6.2
PATCH v4 1/10 ata: ahci_brcmstb: add support MIPS-based platforms
The BCM7xxx ARM-based and MIPS-based platforms share a similar hardware block for AHCI SATA3.
The BCM7425 is main chipset of MIPS-based 40nm class. The others have same AHCI block. The compatible string may be use brcm,bcm7425-ahci.
--- Documentation/devicetree/bindings/ata/brcm,sata-brcmstb.txt | 4 +++- drivers/ata/Kconfig | 2 +- drivers/ata/ahci_brcmstb.c | 1 + 3 files changed, 5 insertions(+), 2 deletions(-)
Documentation/devicetree/bindings/ata/brcm,sata-brcmstb.txt +3 -1
@@ -4,7 +4,9 @@ SATA nodes are defined to describe on-chip Serial ATA controllers. Each SATA controller should have its own node. Required properties: -- compatible : compatible list, may contain "brcm,bcm7445-ahci" and/or +- compatible : should be one or more of + "brcm,bcm7425-ahci" + "brcm,bcm7445-ahci" "brcm,sata3-ahci" - reg : register mappings for AHCI and SATA_TOP_CTRL - reg-names : "ahci" and "top-ctrl"
drivers/ata/Kconfig +1 -1
@@ -100,7 +100,7 @@ config SATA_AHCI_PLATFORM config AHCI_BRCMSTB tristate "Broadcom STB AHCI SATA support" - depends on ARCH_BRCMSTB + depends on ARCH_BRCMSTB || BMIPS_GENERIC help This option enables support for the AHCI SATA3 controller found on STB SoC's.
drivers/ata/ahci_brcmstb.c +1 -0
@@ -300,6 +300,7 @@ static int brcm_ahci_remove(struct platform_device *pdev) }static const struct of_device_id ahci_of_match[] = { + {.compatible ="brcm,bcm7425-ahci" }, {.compatible ="brcm,bcm7445-ahci" }, {}, };
Signature · 1 line
2.6.2
PATCH v4 2/10 ata: ahci_brcmstb: add quirk for broken ncq
In reply to Jaedon ShinAdd quirk for broken ncq. Some chipsets (eg. BCM7349A0, BCM7445A0, BCM7445B0, and all 40nm chipsets including BCM7425) need a workaround disabling NCQ.
--- drivers/ata/ahci_brcmstb.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+)
drivers/ata/ahci_brcmstb.c +46 -0
@@ -69,10 +69,15 @@ (DATA_ENDIAN << DMADESC_ENDIAN_SHIFT) | \ (MMIO_ENDIAN << MMIO_ENDIAN_SHIFT)) +enum brcm_ahci_quirks { +BRCM_AHCI_QUIRK_NONCQ =BIT (0 ), +}; +struct brcm_ahci_priv {struct device *dev;void __iomem *top_ctrl;u32 port_mask; +u32 quirks; };static const struct ata_port_info ahci_brcm_port_info = {
@@ -202,6 +207,42 @@ static u32 brcm_ahci_get_portmask(struct platform_device *pdev,return impl; } +static void brcm_sata_quirks (struct platform_device *pdev, +struct brcm_ahci_priv *priv) +{ +if (priv->quirks &BRCM_AHCI_QUIRK_NONCQ ) { +void __iomem *ctrl = priv->top_ctrl +SATA_TOP_CTRL_BUS_CTRL ; +void __iomem *ahci; +struct resource *res; +u32 reg; + + res =platform_get_resource_byname (pdev,IORESOURCE_MEM , +"ahci" ); + ahci =devm_ioremap_resource (&pdev->dev, res); +if (IS_ERR (ahci)) +return ; + + reg =brcm_sata_readreg (ctrl); + reg |=OVERRIDE_HWINIT ; +brcm_sata_writereg (reg, ctrl); + +/* Clear out the NCQ bit so the AHCI driver will not issue +* FPDMA/NCQ commands. +*/ + reg =readl (ahci +HOST_CAP ); + reg &= ~HOST_CAP_NCQ ; +writel (reg, ahci +HOST_CAP ); + + reg =brcm_sata_readreg (ctrl); + reg &= ~OVERRIDE_HWINIT ; +brcm_sata_writereg (reg, ctrl); + +devm_iounmap (&pdev->dev, ahci); +devm_release_mem_region (&pdev->dev, res->start, +resource_size (res)); + } +} +static void brcm_sata_init (struct brcm_ahci_priv *priv) {/* Configure endianness */
@@ -256,6 +297,11 @@ static int brcm_ahci_probe(struct platform_device *pdev)if (IS_ERR (priv->top_ctrl))return PTR_ERR (priv->top_ctrl); +if (of_device_is_compatible (dev->of_node,"brcm,bcm7425-ahci" )) + priv->quirks |=BRCM_AHCI_QUIRK_NONCQ ; + +brcm_sata_quirks (pdev, priv); +brcm_sata_init (priv); priv->port_mask =brcm_ahci_get_portmask (pdev, priv);
Signature · 1 line
2.6.2
Re: [v4 02/10] ata: ahci_brcmstb: add quirk for broken ncq
Hi,
Quoted 48 lines · Jaedon Shin
Add quirk for broken ncq. Some chipsets (eg. BCM7349A0, BCM7445A0, BCM7445B0, and all 40nm chipsets including BCM7425) need a workaround disabling NCQ.
Signed-off-by Jaedon Shin <[email protected]>--- drivers/ata/ahci_brcmstb.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+)drivers/ata/ahci_brcmstb.c +20
-0@@ -69,10 +69,15 @@ (DATA_ENDIAN << DMADESC_ENDIAN_SHIFT) | \ (MMIO_ENDIAN << MMIO_ENDIAN_SHIFT)) +enum brcm_ahci_quirks { +BRCM_AHCI_QUIRK_NONCQ =BIT (0 ), +}; +struct brcm_ahci_priv {struct device *dev;void __iomem *top_ctrl;u32 port_mask; +u32 quirks; };static const struct ata_port_info ahci_brcm_port_info = {@@ -202,6 +207,42 @@ static u32 brcm_ahci_get_portmask(struct platform_device *pdev,return impl; } +static void brcm_sata_quirks (struct platform_device *pdev, +struct brcm_ahci_priv *priv) +{ +if (priv->quirks &BRCM_AHCI_QUIRK_NONCQ ) { +void __iomem *ctrl = priv->top_ctrl +SATA_TOP_CTRL_BUS_CTRL ; +void __iomem *ahci; +struct resource *res; +u32 reg; + + res =platform_get_resource_byname (pdev,IORESOURCE_MEM , +"ahci" ); + ahci =devm_ioremap_resource (&pdev->dev, res); +if (IS_ERR (ahci)) +return ; +
drivers/ata/ahci_brcmstb.c static u32 brcm_ahci_get_portmask(struct platform_device *pdev, · line 234
Quoted 10 lines
drivers/ata/ahci_brcmstb.c +10
-0+ reg =brcm_sata_readreg (ctrl); + reg |=OVERRIDE_HWINIT ; +brcm_sata_writereg (reg, ctrl); + +/* Clear out the NCQ bit so the AHCI driver will not issue +* FPDMA/NCQ commands. +*/ + reg =readl (ahci +HOST_CAP ); + reg &= ~HOST_CAP_NCQ ; +writel (reg, ahci +HOST_CAP );
You're using readl()/writel() to access the AHCI block, but...
Quoted 15 lines
drivers/ata/ahci_brcmstb.c +11
-0+ + reg =brcm_sata_readreg (ctrl); + reg &= ~OVERRIDE_HWINIT ; +brcm_sata_writereg (reg, ctrl); + +devm_iounmap (&pdev->dev, ahci); +devm_release_mem_region (&pdev->dev, res->start, +resource_size (res)); + } +} +static void brcm_sata_init (struct brcm_ahci_priv *priv) {/* Configure endianness */
drivers/ata/ahci_brcmstb.c static int brcm_ahci_probe(struct platform_device *pdev) · line 305
Quoted 9 lines
drivers/ata/ahci_brcmstb.c +5
-0@@ -256,6 +297,11 @@ static int brcm_ahci_probe(struct platform_device *pdev)if (IS_ERR (priv->top_ctrl))return PTR_ERR (priv->top_ctrl); +if (of_device_is_compatible (dev->of_node,"brcm,bcm7425-ahci" )) + priv->quirks |=BRCM_AHCI_QUIRK_NONCQ ; + +brcm_sata_quirks (pdev, priv); +brcm_sata_init (priv);
...the MMIO endianness is only configured in brcm_sata_init(). You won't see this problem on ARM LE, but you should on MIPS BE. Maybe brcm_sata_quirks() should be after brcm_sata_init()?
drivers/ata/ahci_brcmstb.c static int brcm_ahci_probe(struct platform_device *pdev) · line 307
Quoted 2 lines
drivers/ata/ahci_brcmstb.c +0
-0priv->port_mask =brcm_ahci_get_portmask (pdev, priv);
Brian
Re: [v4 02/10] ata: ahci_brcmstb: add quirk for broken ncq
Hi Brian,
Quoted 84 lines · Brian Norris
Hi,
Quoted 48 lines · Jaedon Shin
Add quirk for broken ncq. Some chipsets (eg. BCM7349A0, BCM7445A0, BCM7445B0, and all 40nm chipsets including BCM7425) need a workaround disabling NCQ.
Signed-off-by Jaedon Shin <[email protected]>---
drivers/ata/ahci_brcmstb.c| 46 ++++++++++++++++++++++++++++++++++++++++++++++1 file changed, 46 insertions(+)drivers/ata/ahci_brcmstb.c +20
-0@@ -69,10 +69,15 @@ (DATA_ENDIAN << DMADESC_ENDIAN_SHIFT) | \ (MMIO_ENDIAN << MMIO_ENDIAN_SHIFT)) +enum brcm_ahci_quirks { +BRCM_AHCI_QUIRK_NONCQ =BIT (0 ), +}; +struct brcm_ahci_priv {struct device *dev;void __iomem *top_ctrl;u32 port_mask; +u32 quirks; };static const struct ata_port_info ahci_brcm_port_info = {@@ -202,6 +207,42 @@ static u32 brcm_ahci_get_portmask(struct platform_device *pdev,return impl; } +static void brcm_sata_quirks (struct platform_device *pdev, +struct brcm_ahci_priv *priv) +{ +if (priv->quirks &BRCM_AHCI_QUIRK_NONCQ ) { +void __iomem *ctrl = priv->top_ctrl +SATA_TOP_CTRL_BUS_CTRL ; +void __iomem *ahci; +struct resource *res; +u32 reg; + + res =platform_get_resource_byname (pdev,IORESOURCE_MEM , +"ahci" ); + ahci =devm_ioremap_resource (&pdev->dev, res); +if (IS_ERR (ahci)) +return ; +drivers/ata/ahci_brcmstb.c static u32 brcm_ahci_get_portmask(struct platform_device *pdev, · line 234
Quoted 10 lines
drivers/ata/ahci_brcmstb.c +10
-0+ reg =brcm_sata_readreg (ctrl); + reg |=OVERRIDE_HWINIT ; +brcm_sata_writereg (reg, ctrl); + +/* Clear out the NCQ bit so the AHCI driver will not issue +* FPDMA/NCQ commands. +*/ + reg =readl (ahci +HOST_CAP ); + reg &= ~HOST_CAP_NCQ ; +writel (reg, ahci +HOST_CAP );You're using readl()/writel() to access the AHCI block, but...
Quoted 18 lines
drivers/ata/ahci_brcmstb.c +11
-0+ + reg =brcm_sata_readreg (ctrl); + reg &= ~OVERRIDE_HWINIT ; +brcm_sata_writereg (reg, ctrl); + +devm_iounmap (&pdev->dev, ahci); +devm_release_mem_region (&pdev->dev, res->start, +resource_size (res)); + } +} +static void brcm_sata_init (struct brcm_ahci_priv *priv) {/* Configure endianness */ @@ -256,6 +297,11 @@ static int brcm_ahci_probe(struct platform_device *pdev)if (IS_ERR (priv->top_ctrl))return PTR_ERR (priv->top_ctrl);
Quoted 11 lines
drivers/ata/ahci_brcmstb.c static int brcm_ahci_probe(struct platform_device *pdev) · line 305
Quoted 6 lines
drivers/ata/ahci_brcmstb.c +5
-0+if (of_device_is_compatible (dev->of_node,"brcm,bcm7425-ahci" )) + priv->quirks |=BRCM_AHCI_QUIRK_NONCQ ; + +brcm_sata_quirks (pdev, priv); +brcm_sata_init (priv);...the MMIO endianness is only configured in
brcm_sata_init(). You won't see this problem on ARM LE, but you should on MIPS BE. Maybebrcm_sata_quirks()should be afterbrcm_sata_init()?
Florian already pointed out, the NCQ disabling occurs prior to initializing the SATA controller endianness in the original BSP. Therefore I think it's better to change to brcm_sata_{read,write}reg() instead of {read,write}l() for HOST_CAP overwriting.
Quoted 4 lines
drivers/ata/ahci_brcmstb.c static int brcm_ahci_probe(struct platform_device *pdev) · line 307
Quoted 2 lines
drivers/ata/ahci_brcmstb.c +0
-0priv->port_mask =brcm_ahci_get_portmask (pdev, priv);Brian
Re: [v4 02/10] ata: ahci_brcmstb: add quirk for broken ncq
In reply to Jaedon ShinHello,
Quoted 25 lines · Jaedon Shin
drivers/ata/ahci_brcmstb.c +25
-0+static void brcm_sata_quirks (struct platform_device *pdev, +struct brcm_ahci_priv *priv) +{ +if (priv->quirks &BRCM_AHCI_QUIRK_NONCQ ) { +void __iomem *ctrl = priv->top_ctrl +SATA_TOP_CTRL_BUS_CTRL ; +void __iomem *ahci; +struct resource *res; +u32 reg; + + res =platform_get_resource_byname (pdev,IORESOURCE_MEM , +"ahci" ); + ahci =devm_ioremap_resource (&pdev->dev, res); +if (IS_ERR (ahci)) +return ; + + reg =brcm_sata_readreg (ctrl); + reg |=OVERRIDE_HWINIT ; +brcm_sata_writereg (reg, ctrl); + +/* Clear out the NCQ bit so the AHCI driver will not issue +* FPDMA/NCQ commands. +*/ + reg =readl (ahci +HOST_CAP ); + reg &= ~HOST_CAP_NCQ ; +writel (reg, ahci +HOST_CAP );
drivers/ata/ahci_brcmstb.c static u32 brcm_ahci_get_portmask(struct platform_device *pdev, · line 244
Quoted 10 lines
drivers/ata/ahci_brcmstb.c +10
-0+ + reg =brcm_sata_readreg (ctrl); + reg &= ~OVERRIDE_HWINIT ; +brcm_sata_writereg (reg, ctrl); + +devm_iounmap (&pdev->dev, ahci); +devm_release_mem_region (&pdev->dev, res->start, +resource_size (res)); + } +}
Does the controller actually need HOST_CAP_NCQ bit turned off to work correctly? If the only thing necessary is the host not issuing NCQ commands, setting AHCI_HFLAG_NO_NCQ should do.
drivers/ata/ahci_brcmstb.c static int brcm_ahci_probe(struct platform_device *pdev) · line 303
Quoted 11 lines
static void
brcm_sata_init(struct brcm_ahci_priv *priv){drivers/ata/ahci_brcmstb.c +4
-0/* Configure endianness */ @@ -256,6 +297,11 @@ static int brcm_ahci_probe(struct platform_device *pdev)if (IS_ERR (priv->top_ctrl))return PTR_ERR (priv->top_ctrl); +if (of_device_is_compatible (dev->of_node,"brcm,bcm7425-ahci" )) + priv->quirks |=BRCM_AHCI_QUIRK_NONCQ ; + +brcm_sata_quirks (pdev, priv);
What's the point of "branch - set a bit - test the bit" sequence? Just do
if (of_device_is_compatiable(...)) brcm_ahci_disable_ncq(...);
Thanks.
Signature · 1 line
tejun
A message that is not in the archive (sent off-list or not yet received): 1446213684-2625-1-git-send-email-jaedon.shin-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
PATCH v4 3/10 ata: ahci_brcmstb: add quirk for different phy
Add quirk for phy interface of MIPS-based chipsets. The ARM-based chipsets have four phy interface control registers and each port has two registers but the MIPS-based chipsets have three. There are no information and documentation.
The Broadcom strict-ahci based BSP of legacy version did not control these registers.
--- drivers/ata/ahci_brcmstb.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)
drivers/ata/ahci_brcmstb.c +10 -1
@@ -71,6 +71,7 @@enum brcm_ahci_quirks {BRCM_AHCI_QUIRK_NONCQ =BIT (0 ), +BRCM_AHCI_QUIRK_SKIP_PHY_ENABLE =BIT (1 ), };struct brcm_ahci_priv {
@@ -119,6 +120,9 @@ static void brcm_sata_phy_enable(struct brcm_ahci_priv *priv, int port)void __iomem *p;u32 reg; +if (priv->quirks &BRCM_AHCI_QUIRK_SKIP_PHY_ENABLE ) +return ; +/* clear PHY_DEFAULT_POWER_STATE */ p = phyctrl +SATA_TOP_CTRL_PHY_CTRL_1 ; reg =brcm_sata_readreg (p);
@@ -148,6 +152,9 @@ static void brcm_sata_phy_disable(struct brcm_ahci_priv *priv, int port)void __iomem *p;u32 reg; +if (priv->quirks &BRCM_AHCI_QUIRK_SKIP_PHY_ENABLE ) +return ; +/* power-off the PHY digital logic */ p = phyctrl +SATA_TOP_CTRL_PHY_CTRL_2 ; reg =brcm_sata_readreg (p);
@@ -297,8 +304,10 @@ static int brcm_ahci_probe(struct platform_device *pdev)if (IS_ERR (priv->top_ctrl))return PTR_ERR (priv->top_ctrl); -if (of_device_is_compatible (dev->of_node,"brcm,bcm7425-ahci" )) +if (of_device_is_compatible (dev->of_node,"brcm,bcm7425-ahci" )) { priv->quirks |=BRCM_AHCI_QUIRK_NONCQ ; + priv->quirks |=BRCM_AHCI_QUIRK_SKIP_PHY_ENABLE ; + }brcm_sata_quirks (pdev, priv);
Signature · 6 lines
2.6.2 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
A message that is not in the archive (sent off-list or not yet received): 1446213684-2625-4-git-send-email-jaedon.shin-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
Re: [v4 03/10] ata: ahci_brcmstb: add quirk for different phy
Quoted 7 lines · Jaedon Shin
Add quirk for phy interface of MIPS-based chipsets. The ARM-based chipsets have four phy interface control registers and each port has two registers but the MIPS-based chipsets have three. There are no information and documentation.
The Broadcom strict-ahci based BSP of legacy version did not control these registers.
...
drivers/ata/ahci_brcmstb.c line 75
Quoted 4 lines
enum
brcm_ahci_quirks{drivers/ata/ahci_brcmstb.c +1
-0BRCM_AHCI_QUIRK_NONCQ =BIT (0 ), + BRCM_AHCI_QUIRK_SKIP_PHY_ENABLE = BIT(1), };
I see. There's another quirk flag which actually needs to be persistent. Hmm... I don't know. Ah well, please disregard my previous comment.
Thanks.
Signature · 5 lines
tejun -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH v4 4/10 ata: ahci_brcmstb: remove unused definitions
In reply to a message not in the archiveRemove unused definitions, and this is to avoid confusion with MIPS-based chipsets.
--- drivers/ata/ahci_brcmstb.c | 2 -- 1 file changed, 2 deletions(-)
drivers/ata/ahci_brcmstb.c +0 -2
@@ -52,8 +52,6 @@#define SATA_TOP_CTRL_2_PHY_GLOBAL_RESET BIT(14)#define SATA_TOP_CTRL_PHY_OFFS 0x8#define SATA_TOP_MAX_PHYS 2 -#define SATA_TOP_CTRL_SATA_TP_OUT 0x1c -#define SATA_TOP_CTRL_CLIENT_INIT_CTRL 0x20/* On big-endian MIPS, buses are reversed to big endian, so switch them back */ #if defined(CONFIG_MIPS ) && defined(__BIG_ENDIAN)
Signature · 6 lines
2.6.2 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Brian Norris
Acked-byQuoted 16 lines · Jaedon Shin
Hi all,
This patch series add support SATA for
BMIPS_GENERIC.Changes in v4:
- remove unused properties from bcm{7425,7342,7362}.dtsiChanges in v3:
- fix typo quirk instead of quick
- disable NCQ before initialzing SATA controller endianness
- fix misnomer controlling phy interface
- remove brcm,broken-ncq and brcm,broken-phy properties from devicetree
- use compatible string for quirks
- use list for compatible strings
- add "Acked-by:" tags
Quoted 5 lines
Changes in v2:
- adds quirk for ncq
- adds quirk for phy interface control
- remove unused definitions inahci_brcmstb
- combines compatible string
For the drivers portions (including patch 2, if you fix the error I pointed out):
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH v4 5/10 phy: phy_brcmstb_sata: remove duplicate definitions
In reply to Jaedon ShinRemove duplicate definitions.
--- drivers/phy/phy-brcmstb-sata.c | 2 -- 1 file changed, 2 deletions(-)
drivers/phy/phy-brcmstb-sata.c +0 -2
@@ -26,8 +26,6 @@#define SATA_MDIO_BANK_OFFSET 0x23c#define SATA_MDIO_REG_OFFSET (ofs) ((ofs) * 4) -#define SATA_MDIO_REG_SPACE_SIZE 0x1000 -#define SATA_MDIO_REG_LENGTH 0x1f00#define MAX_PORTS 2
Signature · 1 line
2.6.2
PATCH v4 6/10 phy: phy_brcmstb_sata: add data for phy version
In reply to Jaedon ShinAdd data of device for phy version. and 28nm version is default.
--- drivers/phy/phy-brcmstb-sata.c | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-)
drivers/phy/phy-brcmstb-sata.c +20 -3
@@ -30,7 +30,11 @@#define MAX_PORTS 2/* Register offset between PHYs in PCB space */ -#define SATA_MDIO_REG_SPACE_SIZE 0x1000 +#define SATA_MDIO_REG_28NM_SPACE_SIZE 0x1000 + +enum brcm_sata_phy_version { +BRCM_SATA_PHY_28NM , +};struct brcm_sata_port {int portnum;
@@ -42,6 +46,7 @@ struct brcm_sata_port {struct brcm_sata_phy {struct device *dev;void __iomem *phy_base; +enum brcm_sata_phy_version version;struct brcm_sata_port phys[MAX_PORTS ]; };
@@ -64,8 +69,12 @@ enum sata_mdio_phy_regs_28nm {static inline void __iomem *brcm_sata_phy_base (struct brcm_sata_port *port) {struct brcm_sata_phy *priv = port->phy_priv; +u32 offset; -return priv->phy_base + (port->portnum *SATA_MDIO_REG_SPACE_SIZE ); +if (priv->version ==BRCM_SATA_PHY_28NM ) + offset =SATA_MDIO_REG_28NM_SPACE_SIZE ; + +return priv->phy_base + (port->portnum * offset); } static void brcm_sata_mdio_wr(void __iomem *addr, u32 bank, u32 ofs,
@@ -126,7 +135,8 @@ static const struct phy_ops phy_ops_28nm = { };static const struct of_device_id brcm_sata_phy_of_match[] = { - { .compatible ="brcm,bcm7445-sata-phy" }, + { .compatible ="brcm,bcm7445-sata-phy" , + .data = (void *)BRCM_SATA_PHY_28NM }, {}, };MODULE_DEVICE_TABLE (of, brcm_sata_phy_of_match);
@@ -135,6 +145,7 @@ static int brcm_sata_phy_probe(struct platform_device *pdev) {struct device *dev = &pdev->dev;struct device_node *dn = dev->of_node, *child; +const struct of_device_id *of_id;struct brcm_sata_phy *priv;struct resource *res;struct phy_provider *provider;
@@ -154,6 +165,12 @@ static int brcm_sata_phy_probe(struct platform_device *pdev)if (IS_ERR (priv->phy_base))return PTR_ERR (priv->phy_base); + of_id =of_match_node (brcm_sata_phy_of_match, dn); +if (of_id) + priv->version = (enum brcm_sata_phy_version )of_id->data; +else + priv->version =BRCM_SATA_PHY_28NM ; +for_each_available_child_of_node (dn, child) {unsigned int id;struct brcm_sata_port *port;
Signature · 1 line
2.6.2
PATCH v4 7/10 phy: phy_brcmstb_sata: add support MIPS-based platforms
In reply to Jaedon ShinThe BCM7xxx ARM-based and MIPS-based platforms share a similar hardware block for AHCI SATA3.
The BCM7425 is main chipset of MIPS-based 40nm class. The others have same PHY of AHCI block. The compatible string may use brcm,bcm7425-sata-phy.
--- .../bindings/phy/brcm,brcmstb-sata-phy.txt | 1 + drivers/phy/Kconfig | 4 ++-- drivers/phy/phy-brcmstb-sata.c | 24 ++++++++++++++++------ 3 files changed, 21 insertions(+), 8 deletions(-)
Documentation/devicetree/bindings/phy/brcm,brcmstb-sata-phy.txt +1 -0
@@ -2,6 +2,7 @@ Required properties: - compatible: should be one or more of + "brcm,bcm7425-sata-phy" "brcm,bcm7445-sata-phy" "brcm,phy-sata3" - address-cells: should be 1
drivers/phy/Kconfig +2 -2
@@ -364,11 +364,11 @@ config PHY_TUSB1210 config PHY_BRCMSTB_SATA tristate "Broadcom STB SATA PHY driver" - depends on ARCH_BRCMSTB + depends on ARCH_BRCMSTB || BMIPS_GENERIC depends on OF select GENERIC_PHY help - Enable this to support the SATA3 PHY on 28nm Broadcom STB SoCs. + Enable this to support the SATA3 PHY on 28nm or 40nm Broadcom STB SoCs. Likely useful only with CONFIG_SATA_BRCMSTB enabled. endmenu
drivers/phy/phy-brcmstb-sata.c +18 -6
@@ -32,8 +32,14 @@/* Register offset between PHYs in PCB space */ #define SATA_MDIO_REG_28NM_SPACE_SIZE 0x1000 +/* The older SATA PHY registers duplicated per port registers within the map, +* rather than having a separate map per port. +*/ +#define SATA_MDIO_REG_40NM_SPACE_SIZE 0x10 +enum brcm_sata_phy_version {BRCM_SATA_PHY_28NM , +BRCM_SATA_PHY_40NM , };struct brcm_sata_port {
@@ -51,7 +57,7 @@ struct brcm_sata_phy {struct brcm_sata_port phys[MAX_PORTS ]; }; -enum sata_mdio_phy_regs_28nm { +enum sata_mdio_phy_regs {PLL_REG_BANK_0 =0x50 ,PLL_REG_BANK_0_PLLCONTROL_0 =0x81 ,
@@ -69,10 +75,14 @@ enum sata_mdio_phy_regs_28nm {static inline void __iomem *brcm_sata_phy_base (struct brcm_sata_port *port) {struct brcm_sata_phy *priv = port->phy_priv; -u32 offset; +u32 offset =0 ;if (priv->version ==BRCM_SATA_PHY_28NM ) offset =SATA_MDIO_REG_28NM_SPACE_SIZE ; +else if (priv->version ==BRCM_SATA_PHY_40NM ) + offset =SATA_MDIO_REG_40NM_SPACE_SIZE ; +else +dev_err (priv->dev,"should not happen\n" );return priv->phy_base + (port->portnum * offset); }
@@ -93,7 +103,7 @@ static void brcm_sata_mdio_wr(void __iomem *addr, u32 bank, u32 ofs,#define FMAX_VAL_DEFAULT 0x3df#define FMAX_VAL_SSC 0x83 -static void brcm_sata_cfg_ssc_28nm (struct brcm_sata_port *port) +static void brcm_sata_cfg_ssc (struct brcm_sata_port *port) {void __iomem *base =brcm_sata_phy_base (port);struct brcm_sata_phy *priv = port->phy_priv;
@@ -124,12 +134,12 @@ static int brcm_sata_phy_init(struct phy *phy) {struct brcm_sata_port *port =phy_get_drvdata (phy); -brcm_sata_cfg_ssc_28nm (port); +brcm_sata_cfg_ssc (port);return 0 ; } -static const struct phy_ops phy_ops_28nm = { +static const struct phy_ops phy_ops = { .init = brcm_sata_phy_init, .owner =THIS_MODULE , };
@@ -137,6 +147,8 @@ static const struct phy_ops phy_ops_28nm = {static const struct of_device_id brcm_sata_phy_of_match[] = { { .compatible ="brcm,bcm7445-sata-phy" , .data = (void *)BRCM_SATA_PHY_28NM }, + { .compatible ="brcm,bcm7425-sata-phy" , + .data = (void *)BRCM_SATA_PHY_40NM }, {}, };MODULE_DEVICE_TABLE (of, brcm_sata_phy_of_match);
@@ -193,7 +205,7 @@ static int brcm_sata_phy_probe(struct platform_device *pdev) port = &priv->phys[id]; port->portnum = id; port->phy_priv = priv; - port->phy =devm_phy_create (dev, child, &phy_ops_28nm); + port->phy =devm_phy_create (dev, child, &phy_ops); port->ssc_en =of_property_read_bool (child,"brcm,enable-ssc" );if (IS_ERR (port->phy)) {dev_err (dev,"failed to create PHY\n" );
Signature · 1 line
2.6.2
PATCH v4 8/10 MIPS: BMIPS: brcmstb: add SATA/PHY nodes for bcm7425
In reply to Jaedon ShinAdd AHCI and PHY device nodes to MIPS-based BCM7425 set-top box platform.
--- arch/mips/boot/dts/brcm/bcm7425.dtsi | 40 ++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+)
arch/mips/boot/dts/brcm/bcm7425.dtsi +40 -0
@@ -221,5 +221,45 @@ interrupts = <73>; status = "disabled"; }; + + sata: sata@181000 { + compatible = "brcm,bcm7425-ahci", "brcm,sata3-ahci"; + reg-names = "ahci", "top-ctrl"; + reg = <0x181000 0xa9c>, <0x180020 0x1c>; + interrupt-parent = <&periph_intc>; + interrupts = <40>; + #address-cells = <1>; + #size-cells = <0>; + status = "disabled"; + + sata0: sata-port@0 { + reg = <0>; + phys = <&sata_phy0>; + }; + + sata1: sata-port@1 { + reg = <1>; + phys = <&sata_phy1>; + }; + }; + + sata_phy: sata-phy@1800000 { + compatible = "brcm,bcm7425-sata-phy", "brcm,phy-sata3"; + reg = <0x180100 0x0eff>; + reg-names = "phy"; + #address-cells = <1>; + #size-cells = <0>; + status = "disabled"; + + sata_phy0: sata-phy@0 { + reg = <0>; + #phy-cells = <0>; + }; + + sata_phy1: sata-phy@1 { + reg = <1>; + #phy-cells = <0>; + }; + }; }; };
Signature · 1 line
2.6.2
PATCH v4 9/10 MIPS: BMIPS: brcmstb: add SATA/PHY nodes for bcm7346
In reply to Jaedon ShinAdd AHCI and PHY device nodes to MIPS-based BCM7346 set-top box platform.
--- arch/mips/boot/dts/brcm/bcm7346.dtsi | 40 +++++++++++++++++++++++++++++++ arch/mips/boot/dts/brcm/bcm97346dbsmb.dts | 8 +++++++ 2 files changed, 48 insertions(+)
arch/mips/boot/dts/brcm/bcm7346.dtsi +40 -0
@@ -246,5 +246,45 @@ interrupts = <76>; status = "disabled"; }; + + sata: sata@181000 { + compatible = "brcm,bcm7425-ahci", "brcm,sata3-ahci"; + reg-names = "ahci", "top-ctrl"; + reg = <0x181000 0xa9c>, <0x180020 0x1c>; + interrupt-parent = <&periph_intc>; + interrupts = <40>; + #address-cells = <1>; + #size-cells = <0>; + status = "disabled"; + + sata0: sata-port@0 { + reg = <0>; + phys = <&sata_phy0>; + }; + + sata1: sata-port@1 { + reg = <1>; + phys = <&sata_phy1>; + }; + }; + + sata_phy: sata-phy@1800000 { + compatible = "brcm,bcm7425-sata-phy", "brcm,phy-sata3"; + reg = <0x180100 0x0eff>; + reg-names = "phy"; + #address-cells = <1>; + #size-cells = <0>; + status = "disabled"; + + sata_phy0: sata-phy@0 { + reg = <0>; + #phy-cells = <0>; + }; + + sata_phy1: sata-phy@1 { + reg = <1>; + #phy-cells = <0>; + }; + }; }; };
arch/mips/boot/dts/brcm/bcm97346dbsmb.dts +8 -0
@@ -64,3 +64,11 @@ &ohci3 { status = "okay"; }; + +&sata { + status = "okay"; +}; + +&sata_phy { + status = "okay"; +};
Signature · 1 line
2.6.2
PATCH v4 10/10 MIPS: BMIPS: brcmstb: add SATA/PHY nodes for bcm7362
In reply to Jaedon ShinAdd AHCI and PHY device nodes to MIPS-based BCM7362 set-top box platform.
--- arch/mips/boot/dts/brcm/bcm7362.dtsi | 40 ++++++++++++++++++++++++++++++++ arch/mips/boot/dts/brcm/bcm97362svmb.dts | 8 +++++++ 2 files changed, 48 insertions(+)
arch/mips/boot/dts/brcm/bcm7362.dtsi +40 -0
@@ -189,5 +189,45 @@ interrupts = <66>; status = "disabled"; }; + + sata: sata@181000 { + compatible = "brcm,bcm7425-ahci", "brcm,sata3-ahci"; + reg-names = "ahci", "top-ctrl"; + reg = <0x181000 0xa9c>, <0x180020 0x1c>; + interrupt-parent = <&periph_intc>; + interrupts = <86>; + #address-cells = <1>; + #size-cells = <0>; + status = "disabled"; + + sata0: sata-port@0 { + reg = <0>; + phys = <&sata_phy0>; + }; + + sata1: sata-port@1 { + reg = <1>; + phys = <&sata_phy1>; + }; + }; + + sata_phy: sata-phy@1800000 { + compatible = "brcm,bcm7425-sata-phy", "brcm,phy-sata3"; + reg = <0x180100 0x0eff>; + reg-names = "phy"; + #address-cells = <1>; + #size-cells = <0>; + status = "disabled"; + + sata_phy0: sata-phy@0 { + reg = <0>; + #phy-cells = <0>; + }; + + sata_phy1: sata-phy@1 { + reg = <1>; + #phy-cells = <0>; + }; + }; }; };
arch/mips/boot/dts/brcm/bcm97362svmb.dts +8 -0
@@ -40,3 +40,11 @@ &ohci0 { status = "okay"; }; + +&sata { + status = "okay"; +}; + +&sata_phy { + status = "okay"; +};
Signature · 1 line
2.6.2
Quoted 3 lines · Jaedon Shin
Hi all,
This patch series add support SATA for
BMIPS_GENERIC.
Sorry for the lag.
Tested on 7425b2, there is a small mistake in the interrupt number for the AHCI controller in the 7425.dtsi file (40 -> 41, see below), after fixing that, I get both drives (external and internal ports) to be identified successfully:
# dmesg | grep scsi <6>[ 0.964097] scsi host0: brcm-ahci <6>[ 0.967982] scsi host1: brcm-ahci <5>[ 1.122386] scsi 0:0:0:0: Direct-Access ATA WDC WD2500AAKX-7 1H19 PQ: 0 ANSI: 5 <5>[ 1.124512] sd 0:0:0:0: Attached scsi generic sg0 type 0 <5>[ 1.411546] scsi 1:0:0:0: Direct-Access ATA WDC WD2500AAKX-7 1H19 PQ: 0 ANSI: 5 <5>[ 1.428870] sd 1:0:0:0: Attached scsi generic sg1 type 0 #
And performance looks good:
# hdparm -tT /dev/sda
/dev/sda:
[ 48.557068] random: nonblocking pool is initialized Timing buffer-cache reads: 524 MB in 0.50 seconds = 1052111 kB/s Timing buffered disk reads: 358 MB in 3.00 seconds = 122132 kB/s # hdparm -tT /dev/sdb
/dev/sdb:
Timing buffer-cache reads: 528 MB in 0.50 seconds = 1060559 kB/s Timing buffered disk reads: 374 MB in 3.00 seconds = 127496 kB/s
For interrupt numbers, computing them from the HIF_CPU_INTR1 register works like this this:
HW IRQ# = N * 32 + M
where N ranges from 0->2 and M is the bit within the 32-bits word.
Thanks!
Quoted 44 lines
Changes in v4:
- remove unused properties from bcm{7425,7342,7362}.dtsiChanges in v3:
- fix typo quirk instead of quick
- disable NCQ before initialzing SATA controller endianness
- fix misnomer controlling phy interface
- remove brcm,broken-ncq and brcm,broken-phy properties from devicetree
- use compatible string for quirks
- use list for compatible strings
- add "Acked-by:" tagsChanges in v2:
- adds quirk for ncq
- adds quirk for phy interface control
- remove unused definitions inahci_brcmstb
- combines compatible stringJaedon Shin (10):
ata:ahci_brcmstb: add support MIPS-based platforms
ata:ahci_brcmstb: add quirk for broken ncq
ata:ahci_brcmstb: add quirk for different phy
ata:ahci_brcmstb: remove unused definitions
phy:phy_brcmstb_sata: remove duplicate definitions
phy:phy_brcmstb_sata: add data for phy version
phy:phy_brcmstb_sata: add support MIPS-based platforms
MIPS: BMIPS: brcmstb: add SATA/PHY nodes for bcm7425
MIPS: BMIPS: brcmstb: add SATA/PHY nodes for bcm7346
MIPS: BMIPS: brcmstb: add SATA/PHY nodes for bcm7362.../devicetree/bindings/ata/brcm,sata-brcmstb.txt | 4 +- .../bindings/phy/brcm,brcmstb-sata-phy.txt | 1 + arch/mips/boot/dts/brcm/bcm7346.dtsi | 40 +++++++++++++++ arch/mips/boot/dts/brcm/bcm7362.dtsi | 40 +++++++++++++++ arch/mips/boot/dts/brcm/bcm7425.dtsi | 40 +++++++++++++++ arch/mips/boot/dts/brcm/bcm97346dbsmb.dts | 8 +++ arch/mips/boot/dts/brcm/bcm97362svmb.dts | 8 +++ drivers/ata/Kconfig | 2 +- drivers/ata/ahci_brcmstb.c | 58 +++++++++++++++++++++- drivers/phy/Kconfig | 4 +- drivers/phy/phy-brcmstb-sata.c | 47 ++++++++++++++---- 11 files changed, 236 insertions(+), 16 deletions(-)
Signature · 1 line
Florian
Hi Florian,
Quoted 5 lines · Florian Fainelli
Quoted 2 lines · Jaedon Shin
Hi all,
Quoted 9 lines
Quoted 1 line
This patch series add support SATA for
BMIPS_GENERIC.Sorry for the lag.
Tested on 7425b2, there is a small mistake in the interrupt number for the AHCI controller in the 7425.dtsi file (40 -> 41, see below), after fixing that, I get both drives (external and internal ports) to be identified successfully:
It's a mistake, and your explanation is correct.
The patches of device node are already applied by Ralf. So I'll add a patch to fix the details for applied patches.
Thanks.
Jaedon
Quoted 85 lines
# dmesg | grep scsi <6>[ 0.964097] scsi host0: brcm-ahci <6>[ 0.967982] scsi host1: brcm-ahci <5>[ 1.122386] scsi 0:0:0:0: Direct-Access ATA WDC WD2500AAKX-7 1H19 PQ: 0 ANSI: 5 <5>[ 1.124512] sd 0:0:0:0: Attached scsi generic sg0 type 0 <5>[ 1.411546] scsi 1:0:0:0: Direct-Access ATA WDC WD2500AAKX-7 1H19 PQ: 0 ANSI: 5 <5>[ 1.428870] sd 1:0:0:0: Attached scsi generic sg1 type 0 #And performance looks good:
# hdparm -tT /dev/sda
/dev/sda:[ 48.557068] random: nonblocking pool is initialized Timing buffer-cache reads: 524 MB in 0.50 seconds = 1052111 kB/s Timing buffered disk reads: 358 MB in 3.00 seconds = 122132 kB/s # hdparm -tT /dev/sdb
/dev/sdb:Timing buffer-cache reads: 528 MB in 0.50 seconds = 1060559 kB/s Timing buffered disk reads: 374 MB in 3.00 seconds = 127496 kB/sTested-by Florian Fainelli <[email protected]>For interrupt numbers, computing them from the
HIF_CPU_INTR1register works like this this:HW IRQ# = N * 32 + M
where N ranges from 0->2 and M is the bit within the 32-bits word.
Thanks!
Quoted 44 lines
Changes in v4:
- remove unused properties from bcm{7425,7342,7362}.dtsiChanges in v3:
- fix typo quirk instead of quick
- disable NCQ before initialzing SATA controller endianness
- fix misnomer controlling phy interface
- remove brcm,broken-ncq and brcm,broken-phy properties from devicetree
- use compatible string for quirks
- use list for compatible strings
- add "Acked-by:" tagsChanges in v2:
- adds quirk for ncq
- adds quirk for phy interface control
- remove unused definitions inahci_brcmstb
- combines compatible stringJaedon Shin (10):
ata:ahci_brcmstb: add support MIPS-based platforms
ata:ahci_brcmstb: add quirk for broken ncq
ata:ahci_brcmstb: add quirk for different phy
ata:ahci_brcmstb: remove unused definitions
phy:phy_brcmstb_sata: remove duplicate definitions
phy:phy_brcmstb_sata: add data for phy version
phy:phy_brcmstb_sata: add support MIPS-based platforms
MIPS: BMIPS: brcmstb: add SATA/PHY nodes for bcm7425
MIPS: BMIPS: brcmstb: add SATA/PHY nodes for bcm7346
MIPS: BMIPS: brcmstb: add SATA/PHY nodes for bcm7362.../devicetree/bindings/ata/brcm,sata-brcmstb.txt | 4 +- .../bindings/phy/brcm,brcmstb-sata-phy.txt | 1 + arch/mips/boot/dts/brcm/bcm7346.dtsi | 40 +++++++++++++++ arch/mips/boot/dts/brcm/bcm7362.dtsi | 40 +++++++++++++++ arch/mips/boot/dts/brcm/bcm7425.dtsi | 40 +++++++++++++++ arch/mips/boot/dts/brcm/bcm97346dbsmb.dts | 8 +++ arch/mips/boot/dts/brcm/bcm97362svmb.dts | 8 +++ drivers/ata/Kconfig | 2 +- drivers/ata/ahci_brcmstb.c | 58 +++++++++++++++++++++- drivers/phy/Kconfig | 4 +- drivers/phy/phy-brcmstb-sata.c | 47 ++++++++++++++---- 11 files changed, 236 insertions(+), 16 deletions(-)Signature · 1 line
Florian