The Broadcom NS2 SoC has a AHCI compliant SATA3 controller with
two ports.
This patchset adds common Broadcom SATA3 PHY driver and related
DT bindings document. It also adds appropriate DT nodes in NS2 DT.
The patchset is based on v4.6-rc1 tag and is available in branch
ns2_sata3_v2 of https://github.com/Broadcom/arm64-linux.git
All patches have been tested on Broadcom NS2 SVK.
Changes since v1:
- Added ACKed by Rob for DT bindings related patches
Anup Patel (5):
phy: Rename phy-brcmstb-sata driver to phy-brcm-sata driver
phy: Add support for NS2 SATA3 PHY in Broadcom SATA3 PHY driver
dt-bindings: phy: bindings document for common Broadcom SATA3 PHY
driver
dt-bindings: ata: add compatible string for iProc AHCI controller
arm64: dts: Add SATA3 AHCI and SATA3 PHY DT nodes for NS2
.../devicetree/bindings/ata/ahci-platform.txt | 1 +
...brcm,brcmstb-sata-phy.txt => brcm-sata-phy.txt} | 15 +-
arch/arm64/boot/dts/broadcom/ns2-svk.dts | 12 +
arch/arm64/boot/dts/broadcom/ns2.dtsi | 43 +++
drivers/phy/Kconfig | 18 +-
drivers/phy/Makefile | 2 +-
drivers/phy/phy-brcm-sata.c | 412 +++++++++++++++++++++
drivers/phy/phy-brcmstb-sata.c | 250 -------------
8 files changed, 487 insertions(+), 266 deletions(-)
rename Documentation/devicetree/bindings/phy/{brcm,brcmstb-sata-phy.txt => brcm-sata-phy.txt} (69%)
create mode 100644 drivers/phy/phy-brcm-sata.c
delete mode 100644 drivers/phy/phy-brcmstb-sata.c
--
1.9.1
Currently, we have a common SATA3 PHY driver for all Broadcom
STB SoCs. This driver can be extended and re-used for Broadcom
iProc SoCs having same SATA3 PHY.
This patch renames existing Broadcom STB SATA3 PHY driver to
common Broadcom SATA3 PHY driver to share this PHY driver across
Broadcom SoCs.
Signed-off-by: Anup Patel <[email protected]>
---
drivers/phy/Kconfig | 18 +++++++++---------
drivers/phy/Makefile | 2 +-
drivers/phy/{phy-brcmstb-sata.c => phy-brcm-sata.c} | 8 ++++----
3 files changed, 14 insertions(+), 14 deletions(-)
rename drivers/phy/{phy-brcmstb-sata.c => phy-brcm-sata.c} (97%)
diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig
index 26566db..c0187a7 100644
--- a/drivers/phy/Kconfig
+++ b/drivers/phy/Kconfig
@@ -403,15 +403,6 @@ config PHY_TUSB1210
help
Support for TI TUSB1210 USB ULPI PHY.
-config PHY_BRCMSTB_SATA
- tristate "Broadcom STB SATA PHY driver"
- depends on ARCH_BRCMSTB || BMIPS_GENERIC
- depends on OF
- select GENERIC_PHY
- help
- Enable this to support the SATA3 PHY on 28nm or 40nm Broadcom STB SoCs.
- Likely useful only with CONFIG_SATA_BRCMSTB enabled.
-
config PHY_CYGNUS_PCIE
tristate "Broadcom Cygnus PCIe PHY driver"
depends on OF && (ARCH_BCM_CYGNUS || COMPILE_TEST)
@@ -421,4 +412,13 @@ config PHY_CYGNUS_PCIE
Enable this to support the Broadcom Cygnus PCIe PHY.
If unsure, say N.
+config PHY_BRCM_SATA
+ tristate "Broadcom SATA PHY driver"
+ depends on ARCH_BRCMSTB || ARCH_BCM_IPROC || BMIPS_GENERIC || COMPILE_TEST
+ depends on OF
+ select GENERIC_PHY
+ default ARCH_BCM_IPROC
+ help
+ Enable this to support the Broadcom SATA PHY.
+ If unsure, say N.
endmenu
diff --git a/drivers/phy/Makefile b/drivers/phy/Makefile
index 24596a9..596fae9 100644
--- a/drivers/phy/Makefile
+++ b/drivers/phy/Makefile
@@ -49,6 +49,6 @@ obj-$(CONFIG_PHY_QCOM_UFS) += phy-qcom-ufs.o
obj-$(CONFIG_PHY_QCOM_UFS) += phy-qcom-ufs-qmp-20nm.o
obj-$(CONFIG_PHY_QCOM_UFS) += phy-qcom-ufs-qmp-14nm.o
obj-$(CONFIG_PHY_TUSB1210) += phy-tusb1210.o
-obj-$(CONFIG_PHY_BRCMSTB_SATA) += phy-brcmstb-sata.o
obj-$(CONFIG_PHY_PISTACHIO_USB) += phy-pistachio-usb.o
obj-$(CONFIG_PHY_CYGNUS_PCIE) += phy-bcm-cygnus-pcie.o
+obj-$(CONFIG_PHY_BRCM_SATA) += phy-brcm-sata.o
diff --git a/drivers/phy/phy-brcmstb-sata.c b/drivers/phy/phy-brcm-sata.c
similarity index 97%
rename from drivers/phy/phy-brcmstb-sata.c
rename to drivers/phy/phy-brcm-sata.c
index a23172f..c97b9d6 100644
--- a/drivers/phy/phy-brcmstb-sata.c
+++ b/drivers/phy/phy-brcm-sata.c
@@ -1,7 +1,7 @@
/*
* Broadcom SATA3 AHCI Controller PHY Driver
*
- * Copyright © 2009-2015 Broadcom Corporation
+ * Copyright (C) 2016 Broadcom
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -238,13 +238,13 @@ static struct platform_driver brcm_sata_phy_driver = {
.probe = brcm_sata_phy_probe,
.driver = {
.of_match_table = brcm_sata_phy_of_match,
- .name = "brcmstb-sata-phy",
+ .name = "brcm-sata-phy",
}
};
module_platform_driver(brcm_sata_phy_driver);
-MODULE_DESCRIPTION("Broadcom STB SATA PHY driver");
+MODULE_DESCRIPTION("Broadcom SATA PHY driver");
MODULE_LICENSE("GPL");
MODULE_AUTHOR("Marc Carino");
MODULE_AUTHOR("Brian Norris");
-MODULE_ALIAS("platform:phy-brcmstb-sata");
+MODULE_ALIAS("platform:phy-brcm-sata");
--
1.9.1
We have one dual-port SATA3 AHCI controller present in
NS2 SoC.
This patch enables SATA3 AHCI controller and SATA3 PHY
for NS2 SoC in NS2 DT.
Signed-off-by: Anup Patel <[email protected]>
Reviewed-by: Ray Jui <[email protected]>
Reviewed-by: Scott Branden <[email protected]>
---
arch/arm64/boot/dts/broadcom/ns2-svk.dts | 12 +++++++++
arch/arm64/boot/dts/broadcom/ns2.dtsi | 43 ++++++++++++++++++++++++++++++++
2 files changed, 55 insertions(+)
diff --git a/arch/arm64/boot/dts/broadcom/ns2-svk.dts b/arch/arm64/boot/dts/broadcom/ns2-svk.dts
index ce0ab84..06cf9c5 100644
--- a/arch/arm64/boot/dts/broadcom/ns2-svk.dts
+++ b/arch/arm64/boot/dts/broadcom/ns2-svk.dts
@@ -72,6 +72,18 @@
status = "ok";
};
+&sata_phy0 {
+ status = "ok";
+};
+
+&sata_phy1 {
+ status = "ok";
+};
+
+&sata {
+ status = "ok";
+};
+
&sdio0 {
status = "ok";
};
diff --git a/arch/arm64/boot/dts/broadcom/ns2.dtsi b/arch/arm64/boot/dts/broadcom/ns2.dtsi
index 6f81c9d..c8dccf8 100644
--- a/arch/arm64/boot/dts/broadcom/ns2.dtsi
+++ b/arch/arm64/boot/dts/broadcom/ns2.dtsi
@@ -413,6 +413,49 @@
reg = <0x66220000 0x28>;
};
+ sata_phy: sata_phy@663f0100 {
+ compatible = "brcm,iproc-ns2-sata-phy";
+ reg = <0x663f0100 0x1f00>,
+ <0x663f004c 0x10>;
+ reg-names = "phy", "phy-ctrl";
+ #address-cells = <1>;
+ #size-cells = <0>;
+
+ sata_phy0: sata-phy@0 {
+ reg = <0>;
+ #phy-cells = <0>;
+ status = "disabled";
+ };
+
+ sata_phy1: sata-phy@1 {
+ reg = <1>;
+ #phy-cells = <0>;
+ status = "disabled";
+ };
+ };
+
+ sata: ahci@663f2000 {
+ compatible = "brcm,iproc-ahci", "generic-ahci";
+ reg = <0x663f2000 0x1000>;
+ reg-names = "ahci";
+ interrupts = <GIC_SPI 438 IRQ_TYPE_LEVEL_HIGH>;
+ #address-cells = <1>;
+ #size-cells = <0>;
+ status = "disabled";
+
+ sata0: sata-port@0 {
+ reg = <0>;
+ phys = <&sata_phy0>;
+ phy-names = "sata-phy";
+ };
+
+ sata1: sata-port@1 {
+ reg = <1>;
+ phys = <&sata_phy1>;
+ phy-names = "sata-phy";
+ };
+ };
+
sdio0: sdhci@66420000 {
compatible = "brcm,sdhci-iproc-cygnus";
reg = <0x66420000 0x100>;
--
1.9.1
The Broadcom iProc SoCs have AHCI compliant SATA controller. This
patch adds common compatible string for AHCI SATA controller on
iProc SoCs.
Signed-off-by: Anup Patel <[email protected]>
Acked-by: Rob Herring <[email protected]>
---
Documentation/devicetree/bindings/ata/ahci-platform.txt | 1 +
1 file changed, 1 insertion(+)
diff --git a/Documentation/devicetree/bindings/ata/ahci-platform.txt b/Documentation/devicetree/bindings/ata/ahci-platform.txt
index 30df832..3990348 100644
--- a/Documentation/devicetree/bindings/ata/ahci-platform.txt
+++ b/Documentation/devicetree/bindings/ata/ahci-platform.txt
@@ -10,6 +10,7 @@ PHYs.
Required properties:
- compatible : compatible string, one of:
- "allwinner,sun4i-a10-ahci"
+ - "brcm,iproc-ahci"
- "hisilicon,hisi-ahci"
- "cavium,octeon-7130-ahci"
- "ibm,476gtr-ahci"
--
1.9.1
This patch adds support for Broadcom NS2 SATA3 PHY in existing
Broadcom SATA3 PHY driver.
Signed-off-by: Anup Patel <[email protected]>
---
drivers/phy/phy-brcm-sata.c | 238 +++++++++++++++++++++++++++++++++++++-------
1 file changed, 200 insertions(+), 38 deletions(-)
diff --git a/drivers/phy/phy-brcm-sata.c b/drivers/phy/phy-brcm-sata.c
index c97b9d6..6c4c5cb 100644
--- a/drivers/phy/phy-brcm-sata.c
+++ b/drivers/phy/phy-brcm-sata.c
@@ -14,6 +14,7 @@
* GNU General Public License for more details.
*/
+#include <linux/delay.h>
#include <linux/device.h>
#include <linux/init.h>
#include <linux/interrupt.h>
@@ -24,22 +25,26 @@
#include <linux/phy/phy.h>
#include <linux/platform_device.h>
-#define SATA_MDIO_BANK_OFFSET 0x23c
-#define SATA_MDIO_REG_OFFSET(ofs) ((ofs) * 4)
+#define SATA_PCB_BANK_OFFSET 0x23c
+#define SATA_PCB_REG_OFFSET(ofs) ((ofs) * 4)
#define MAX_PORTS 2
/* Register offset between PHYs in PCB space */
-#define SATA_MDIO_REG_28NM_SPACE_SIZE 0x1000
+#define SATA_PCB_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
+#define SATA_PCB_REG_40NM_SPACE_SIZE 0x10
+
+/* Register offset between PHYs in PHY control space */
+#define SATA_PHY_CTRL_REG_28NM_SPACE_SIZE 0x8
enum brcm_sata_phy_version {
- BRCM_SATA_PHY_28NM,
- BRCM_SATA_PHY_40NM,
+ BRCM_SATA_PHY_STB_28NM,
+ BRCM_SATA_PHY_STB_40NM,
+ BRCM_SATA_PHY_IPROC_NS2,
};
struct brcm_sata_port {
@@ -52,15 +57,48 @@ struct brcm_sata_port {
struct brcm_sata_phy {
struct device *dev;
void __iomem *phy_base;
+ void __iomem *ctrl_base;
enum brcm_sata_phy_version version;
struct brcm_sata_port phys[MAX_PORTS];
};
-enum sata_mdio_phy_regs {
- PLL_REG_BANK_0 = 0x50,
+enum sata_phy_regs {
+ BLOCK0_REG_BANK = 0x000,
+ BLOCK0_XGXSSTATUS = 0x81,
+ BLOCK0_XGXSSTATUS_PLL_LOCK = BIT(12),
+ BLOCK0_SPARE = 0x8d,
+ BLOCK0_SPARE_OOB_CLK_SEL_MASK = 0x3,
+ BLOCK0_SPARE_OOB_CLK_SEL_REFBY2 = 0x1,
+
+ PLL_REG_BANK_0 = 0x050,
PLL_REG_BANK_0_PLLCONTROL_0 = 0x81,
+ PLL1_REG_BANK = 0x060,
+ PLL1_ACTRL2 = 0x82,
+ PLL1_ACTRL3 = 0x83,
+ PLL1_ACTRL4 = 0x84,
+
+ OOB_REG_BANK = 0x150,
+ OOB_CTRL1 = 0x80,
+ OOB_CTRL1_BURST_MAX_MASK = 0xf,
+ OOB_CTRL1_BURST_MAX_SHIFT = 12,
+ OOB_CTRL1_BURST_MIN_MASK = 0xf,
+ OOB_CTRL1_BURST_MIN_SHIFT = 8,
+ OOB_CTRL1_WAKE_IDLE_MAX_MASK = 0xf,
+ OOB_CTRL1_WAKE_IDLE_MAX_SHIFT = 4,
+ OOB_CTRL1_WAKE_IDLE_MIN_MASK = 0xf,
+ OOB_CTRL1_WAKE_IDLE_MIN_SHIFT = 0,
+ OOB_CTRL2 = 0x81,
+ OOB_CTRL2_SEL_ENA_SHIFT = 15,
+ OOB_CTRL2_SEL_ENA_RC_SHIFT = 14,
+ OOB_CTRL2_RESET_IDLE_MAX_MASK = 0x3f,
+ OOB_CTRL2_RESET_IDLE_MAX_SHIFT = 8,
+ OOB_CTRL2_BURST_CNT_MASK = 0x3,
+ OOB_CTRL2_BURST_CNT_SHIFT = 6,
+ OOB_CTRL2_RESET_IDLE_MIN_MASK = 0x3f,
+ OOB_CTRL2_RESET_IDLE_MIN_SHIFT = 0,
+
TXPMD_REG_BANK = 0x1a0,
TXPMD_CONTROL1 = 0x81,
TXPMD_CONTROL1_TX_SSC_EN_FRC = BIT(0),
@@ -72,69 +110,183 @@ enum sata_mdio_phy_regs {
TXPMD_TX_FREQ_CTRL_CONTROL3_FMAX_MASK = 0x3ff,
};
-static inline void __iomem *brcm_sata_phy_base(struct brcm_sata_port *port)
+enum sata_phy_ctrl_regs {
+ PHY_CTRL_1 = 0x0,
+ PHY_CTRL_1_RESET = BIT(0),
+};
+
+static inline void __iomem *brcm_sata_pcb_base(struct brcm_sata_port *port)
{
struct brcm_sata_phy *priv = port->phy_priv;
- u32 offset = 0;
+ u32 size = 0;
+
+ switch (priv->version) {
+ case BRCM_SATA_PHY_STB_28NM:
+ case BRCM_SATA_PHY_IPROC_NS2:
+ size = SATA_PCB_REG_28NM_SPACE_SIZE;
+ break;
+ case BRCM_SATA_PHY_STB_40NM:
+ size = SATA_PCB_REG_40NM_SPACE_SIZE;
+ break;
+ default:
+ dev_err(priv->dev, "invalid phy version\n");
+ break;
+ };
- 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
+ return priv->phy_base + (port->portnum * size);
+}
+
+static inline void __iomem *brcm_sata_ctrl_base(struct brcm_sata_port *port)
+{
+ struct brcm_sata_phy *priv = port->phy_priv;
+ u32 size = 0;
+
+ switch (priv->version) {
+ case BRCM_SATA_PHY_IPROC_NS2:
+ size = SATA_PHY_CTRL_REG_28NM_SPACE_SIZE;
+ break;
+ default:
dev_err(priv->dev, "invalid phy version\n");
+ break;
+ };
- return priv->phy_base + (port->portnum * offset);
+ return priv->ctrl_base + (port->portnum * size);
}
-static void brcm_sata_mdio_wr(void __iomem *addr, u32 bank, u32 ofs,
- u32 msk, u32 value)
+static void brcm_sata_phy_wr(void __iomem *pcb_base, u32 bank,
+ u32 ofs, u32 msk, u32 value)
{
u32 tmp;
- writel(bank, addr + SATA_MDIO_BANK_OFFSET);
- tmp = readl(addr + SATA_MDIO_REG_OFFSET(ofs));
+ writel(bank, pcb_base + SATA_PCB_BANK_OFFSET);
+ tmp = readl(pcb_base + SATA_PCB_REG_OFFSET(ofs));
tmp = (tmp & msk) | value;
- writel(tmp, addr + SATA_MDIO_REG_OFFSET(ofs));
+ writel(tmp, pcb_base + SATA_PCB_REG_OFFSET(ofs));
+}
+
+static u32 brcm_sata_phy_rd(void __iomem *pcb_base, u32 bank, u32 ofs)
+{
+ writel(bank, pcb_base + SATA_PCB_BANK_OFFSET);
+ return readl(pcb_base + SATA_PCB_REG_OFFSET(ofs));
}
/* These defaults were characterized by H/W group */
-#define FMIN_VAL_DEFAULT 0x3df
-#define FMAX_VAL_DEFAULT 0x3df
-#define FMAX_VAL_SSC 0x83
+#define STB_FMIN_VAL_DEFAULT 0x3df
+#define STB_FMAX_VAL_DEFAULT 0x3df
+#define STB_FMAX_VAL_SSC 0x83
-static void brcm_sata_cfg_ssc(struct brcm_sata_port *port)
+static int brcm_stb_sata_init(struct brcm_sata_port *port)
{
- void __iomem *base = brcm_sata_phy_base(port);
+ void __iomem *base = brcm_sata_pcb_base(port);
struct brcm_sata_phy *priv = port->phy_priv;
u32 tmp;
/* override the TX spread spectrum setting */
tmp = TXPMD_CONTROL1_TX_SSC_EN_FRC_VAL | TXPMD_CONTROL1_TX_SSC_EN_FRC;
- brcm_sata_mdio_wr(base, TXPMD_REG_BANK, TXPMD_CONTROL1, ~tmp, tmp);
+ brcm_sata_phy_wr(base, TXPMD_REG_BANK, TXPMD_CONTROL1, ~tmp, tmp);
/* set fixed min freq */
- brcm_sata_mdio_wr(base, TXPMD_REG_BANK, TXPMD_TX_FREQ_CTRL_CONTROL2,
- ~TXPMD_TX_FREQ_CTRL_CONTROL2_FMIN_MASK,
- FMIN_VAL_DEFAULT);
+ brcm_sata_phy_wr(base, TXPMD_REG_BANK, TXPMD_TX_FREQ_CTRL_CONTROL2,
+ ~TXPMD_TX_FREQ_CTRL_CONTROL2_FMIN_MASK,
+ STB_FMIN_VAL_DEFAULT);
/* set fixed max freq depending on SSC config */
if (port->ssc_en) {
- dev_info(priv->dev, "enabling SSC on port %d\n", port->portnum);
- tmp = FMAX_VAL_SSC;
+ dev_info(priv->dev, "enabling SSC on port%d\n", port->portnum);
+ tmp = STB_FMAX_VAL_SSC;
} else {
- tmp = FMAX_VAL_DEFAULT;
+ tmp = STB_FMAX_VAL_DEFAULT;
}
- brcm_sata_mdio_wr(base, TXPMD_REG_BANK, TXPMD_TX_FREQ_CTRL_CONTROL3,
+ brcm_sata_phy_wr(base, TXPMD_REG_BANK, TXPMD_TX_FREQ_CTRL_CONTROL3,
~TXPMD_TX_FREQ_CTRL_CONTROL3_FMAX_MASK, tmp);
+
+ return 0;
+}
+
+/* NS2 SATA PLL1 defaults were characterized by H/W group */
+#define NS2_PLL1_ACTRL2_MAGIC 0x1df8
+#define NS2_PLL1_ACTRL3_MAGIC 0x2b00
+#define NS2_PLL1_ACTRL4_MAGIC 0x8824
+
+static int brcm_ns2_sata_init(struct brcm_sata_port *port)
+{
+ int try;
+ unsigned int val;
+ void __iomem *base = brcm_sata_pcb_base(port);
+ void __iomem *ctrl_base = brcm_sata_ctrl_base(port);
+ struct device *dev = port->phy_priv->dev;
+
+ /* Configure OOB control */
+ val = 0x0;
+ val |= (0xc << OOB_CTRL1_BURST_MAX_SHIFT);
+ val |= (0x4 << OOB_CTRL1_BURST_MIN_SHIFT);
+ val |= (0x9 << OOB_CTRL1_WAKE_IDLE_MAX_SHIFT);
+ val |= (0x3 << OOB_CTRL1_WAKE_IDLE_MIN_SHIFT);
+ brcm_sata_phy_wr(base, OOB_REG_BANK, OOB_CTRL1, 0x0, val);
+ val = 0x0;
+ val |= (0x1b << OOB_CTRL2_RESET_IDLE_MAX_SHIFT);
+ val |= (0x2 << OOB_CTRL2_BURST_CNT_SHIFT);
+ val |= (0x9 << OOB_CTRL2_RESET_IDLE_MIN_SHIFT);
+ brcm_sata_phy_wr(base, OOB_REG_BANK, OOB_CTRL2, 0x0, val);
+
+ /* Configure PHY PLL register bank 1 */
+ val = NS2_PLL1_ACTRL2_MAGIC;
+ brcm_sata_phy_wr(base, PLL1_REG_BANK, PLL1_ACTRL2, 0x0, val);
+ val = NS2_PLL1_ACTRL3_MAGIC;
+ brcm_sata_phy_wr(base, PLL1_REG_BANK, PLL1_ACTRL3, 0x0, val);
+ val = NS2_PLL1_ACTRL4_MAGIC;
+ brcm_sata_phy_wr(base, PLL1_REG_BANK, PLL1_ACTRL4, 0x0, val);
+
+ /* Configure PHY BLOCK0 register bank */
+ /* Set oob_clk_sel to refclk/2 */
+ brcm_sata_phy_wr(base, BLOCK0_REG_BANK, BLOCK0_SPARE,
+ ~BLOCK0_SPARE_OOB_CLK_SEL_MASK,
+ BLOCK0_SPARE_OOB_CLK_SEL_REFBY2);
+
+ /* Strobe PHY reset using PHY control register */
+ writel(PHY_CTRL_1_RESET, ctrl_base + PHY_CTRL_1);
+ mdelay(1);
+ writel(0x0, ctrl_base + PHY_CTRL_1);
+ mdelay(1);
+
+ /* Wait for PHY PLL lock by polling pll_lock bit */
+ try = 50;
+ while (try) {
+ val = brcm_sata_phy_rd(base, BLOCK0_REG_BANK,
+ BLOCK0_XGXSSTATUS);
+ if (val & BLOCK0_XGXSSTATUS_PLL_LOCK)
+ break;
+ msleep(20);
+ try--;
+ }
+ if (!try) {
+ /* PLL did not lock; give up */
+ dev_err(dev, "port%d PLL did not lock\n", port->portnum);
+ return -ETIMEDOUT;
+ }
+
+ dev_dbg(dev, "port%d initialized\n", port->portnum);
+
+ return 0;
}
static int brcm_sata_phy_init(struct phy *phy)
{
+ int rc;
struct brcm_sata_port *port = phy_get_drvdata(phy);
- brcm_sata_cfg_ssc(port);
+ switch (port->phy_priv->version) {
+ case BRCM_SATA_PHY_STB_28NM:
+ case BRCM_SATA_PHY_STB_40NM:
+ rc = brcm_stb_sata_init(port);
+ break;
+ case BRCM_SATA_PHY_IPROC_NS2:
+ rc = brcm_ns2_sata_init(port);
+ break;
+ default:
+ rc = -ENODEV;
+ };
return 0;
}
@@ -146,9 +298,11 @@ static const struct phy_ops phy_ops = {
static const struct of_device_id brcm_sata_phy_of_match[] = {
{ .compatible = "brcm,bcm7445-sata-phy",
- .data = (void *)BRCM_SATA_PHY_28NM },
+ .data = (void *)BRCM_SATA_PHY_STB_28NM },
{ .compatible = "brcm,bcm7425-sata-phy",
- .data = (void *)BRCM_SATA_PHY_40NM },
+ .data = (void *)BRCM_SATA_PHY_STB_40NM },
+ { .compatible = "brcm,iproc-ns2-sata-phy",
+ .data = (void *)BRCM_SATA_PHY_IPROC_NS2 },
{},
};
MODULE_DEVICE_TABLE(of, brcm_sata_phy_of_match);
@@ -181,7 +335,15 @@ static int brcm_sata_phy_probe(struct platform_device *pdev)
if (of_id)
priv->version = (enum brcm_sata_phy_version)of_id->data;
else
- priv->version = BRCM_SATA_PHY_28NM;
+ priv->version = BRCM_SATA_PHY_STB_28NM;
+
+ if (priv->version == BRCM_SATA_PHY_IPROC_NS2) {
+ res = platform_get_resource_byname(pdev, IORESOURCE_MEM,
+ "phy-ctrl");
+ priv->ctrl_base = devm_ioremap_resource(dev, res);
+ if (IS_ERR(priv->ctrl_base))
+ return PTR_ERR(priv->ctrl_base);
+ }
for_each_available_child_of_node(dn, child) {
unsigned int id;
--
1.9.1
This patch:
1. Renames DT bindings document of Broadcom STB SATA3 PHY driver to
common Broadcom SATA3 PHY driver bindings document
2. Adds bindings info for NS2 SATA3 PHY
Signed-off-by: Anup Patel <[email protected]>
Acked-by: Rob Herring <[email protected]>
---
.../phy/{brcm,brcmstb-sata-phy.txt => brcm-sata-phy.txt} | 15 +++++++++------
1 file changed, 9 insertions(+), 6 deletions(-)
rename Documentation/devicetree/bindings/phy/{brcm,brcmstb-sata-phy.txt => brcm-sata-phy.txt} (69%)
diff --git a/Documentation/devicetree/bindings/phy/brcm,brcmstb-sata-phy.txt b/Documentation/devicetree/bindings/phy/brcm-sata-phy.txt
similarity index 69%
rename from Documentation/devicetree/bindings/phy/brcm,brcmstb-sata-phy.txt
rename to Documentation/devicetree/bindings/phy/brcm-sata-phy.txt
index d87ab7c..d023120 100644
--- a/Documentation/devicetree/bindings/phy/brcm,brcmstb-sata-phy.txt
+++ b/Documentation/devicetree/bindings/phy/brcm-sata-phy.txt
@@ -1,14 +1,17 @@
-* Broadcom SATA3 PHY for STB
+* Broadcom SATA3 PHY
Required properties:
- compatible: should be one or more of
"brcm,bcm7425-sata-phy"
"brcm,bcm7445-sata-phy"
+ "brcm,iproc-ns2-sata-phy"
"brcm,phy-sata3"
- address-cells: should be 1
- size-cells: should be 0
-- reg: register range for the PHY PCB interface
-- reg-names: should be "phy"
+- reg: register ranges for the PHY PCB interface
+- reg-names: should be "phy" and "phy-ctrl"
+ The "phy-ctrl" registers are only required for
+ "brcm,iproc-ns2-sata-phy".
Sub-nodes:
Each port's PHY should be represented as a sub-node.
@@ -16,12 +19,12 @@ Sub-nodes:
Sub-nodes required properties:
- reg: the PHY number
- phy-cells: generic PHY binding; must be 0
-Optional:
-- brcm,enable-ssc: use spread spectrum clocking (SSC) on this port
+Sub-nodes optional properties:
+- brcm,enable-ssc: use spread spectrum clocking (SSC) on this port
+ This property is not applicable for "brcm,iproc-ns2-sata-phy".
Example:
-
sata-phy@f0458100 {
compatible = "brcm,bcm7445-sata-phy", "brcm,phy-sata3";
reg = <0xf0458100 0x1e00>, <0xf045804c 0x10>;
--
1.9.1
Le 27/03/2016 21:48, Anup Patel a écrit :
> Currently, we have a common SATA3 PHY driver for all Broadcom
> STB SoCs. This driver can be extended and re-used for Broadcom
> iProc SoCs having same SATA3 PHY.
>
> This patch renames existing Broadcom STB SATA3 PHY driver to
> common Broadcom SATA3 PHY driver to share this PHY driver across
> Broadcom SoCs.
>
> Signed-off-by: Anup Patel <[email protected]>
> ---
[snip]
> +config PHY_BRCM_SATA
> + tristate "Broadcom SATA PHY driver"
> + depends on ARCH_BRCMSTB || ARCH_BCM_IPROC || BMIPS_GENERIC || COMPILE_TEST
> + depends on OF
> + select GENERIC_PHY
> + default ARCH_BCM_IPROC
This could be a separate patch of its own, but I do not think it matters
that much.
Acked-by: Florian Fainelli <[email protected]>
--
Florian
Le 27/03/2016 21:48, Anup Patel a écrit :
> Required properties:
> - compatible: should be one or more of
> "brcm,bcm7425-sata-phy"
> "brcm,bcm7445-sata-phy"
> + "brcm,iproc-ns2-sata-phy"
> "brcm,phy-sata3"
> - address-cells: should be 1
> - size-cells: should be 0
> -- reg: register range for the PHY PCB interface
> -- reg-names: should be "phy"
> +- reg: register ranges for the PHY PCB interface
> +- reg-names: should be "phy" and "phy-ctrl"
> + The "phy-ctrl" registers are only required for
> + "brcm,iproc-ns2-sata-phy".
I objected to adding another register during the internal review, which,
in the case of the STB chips is dealt with at the AHCI controller level
as was requested when Brian got the driver sent, but if that is the only
point here, then let's get your patches merged as-is.
The rest of the changes look fine so:
Acked-by: Florian Fainelli <[email protected]>
--
Florian
Le 27/03/2016 21:48, Anup Patel a écrit :
> The Broadcom iProc SoCs have AHCI compliant SATA controller. This
> patch adds common compatible string for AHCI SATA controller on
> iProc SoCs.
>
> Signed-off-by: Anup Patel <[email protected]>
> Acked-by: Rob Herring <[email protected]>
Acked-by: Florian Fainelli <[email protected]>
Tejun, should I queue this one through an arm-soc pull request or do you
want to take it via libata? Thanks!
--
Florian
Le 27/03/2016 21:48, Anup Patel a écrit :
> This patch adds support for Broadcom NS2 SATA3 PHY in existing
> Broadcom SATA3 PHY driver.
>
> Signed-off-by: Anup Patel <[email protected]>
As mentioned before during the internal review, there is a lot of churn
done here to add NS2 support, which in itself could be a good 2-3
independent preliminary patches. I tested v1 on a 7445 and did not see
any issues with it so and convinced myself your transformation is
correct so:
Acked-by: Florian Fainelli <[email protected]>
--
Florian
Hello, Florian.
On Mon, Mar 28, 2016 at 06:28:51PM -0700, Florian Fainelli wrote:
> Tejun, should I queue this one through an arm-soc pull request or do you
> want to take it via libata? Thanks!
Please feel free to route the changes through arm-soc.
Thanks!
--
tejun
Hi,
On Monday 28 March 2016 10:18 AM, Anup Patel wrote:
> Currently, we have a common SATA3 PHY driver for all Broadcom
> STB SoCs. This driver can be extended and re-used for Broadcom
> iProc SoCs having same SATA3 PHY.
>
> This patch renames existing Broadcom STB SATA3 PHY driver to
> common Broadcom SATA3 PHY driver to share this PHY driver across
> Broadcom SoCs.
>
> Signed-off-by: Anup Patel <[email protected]>
> ---
> drivers/phy/Kconfig | 18 +++++++++---------
> drivers/phy/Makefile | 2 +-
> drivers/phy/{phy-brcmstb-sata.c => phy-brcm-sata.c} | 8 ++++----
> 3 files changed, 14 insertions(+), 14 deletions(-)
> rename drivers/phy/{phy-brcmstb-sata.c => phy-brcm-sata.c} (97%)
>
> diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig
> index 26566db..c0187a7 100644
> --- a/drivers/phy/Kconfig
> +++ b/drivers/phy/Kconfig
> @@ -403,15 +403,6 @@ config PHY_TUSB1210
> help
> Support for TI TUSB1210 USB ULPI PHY.
>
> -config PHY_BRCMSTB_SATA
> - tristate "Broadcom STB SATA PHY driver"
> - depends on ARCH_BRCMSTB || BMIPS_GENERIC
> - depends on OF
> - select GENERIC_PHY
> - help
> - Enable this to support the SATA3 PHY on 28nm or 40nm Broadcom STB SoCs.
> - Likely useful only with CONFIG_SATA_BRCMSTB enabled.
> -
> config PHY_CYGNUS_PCIE
> tristate "Broadcom Cygnus PCIe PHY driver"
> depends on OF && (ARCH_BCM_CYGNUS || COMPILE_TEST)
> @@ -421,4 +412,13 @@ config PHY_CYGNUS_PCIE
> Enable this to support the Broadcom Cygnus PCIe PHY.
> If unsure, say N.
>
> +config PHY_BRCM_SATA
changing config name should be done with utmost care as it might break
oldconfig users.
Has this been fixed in all the defconfigs where it is included?
Thanks
Kishon
> + tristate "Broadcom SATA PHY driver"
> + depends on ARCH_BRCMSTB || ARCH_BCM_IPROC || BMIPS_GENERIC || COMPILE_TEST
> + depends on OF
> + select GENERIC_PHY
> + default ARCH_BCM_IPROC
> + help
> + Enable this to support the Broadcom SATA PHY.
> + If unsure, say N.
> endmenu
> diff --git a/drivers/phy/Makefile b/drivers/phy/Makefile
> index 24596a9..596fae9 100644
> --- a/drivers/phy/Makefile
> +++ b/drivers/phy/Makefile
> @@ -49,6 +49,6 @@ obj-$(CONFIG_PHY_QCOM_UFS) += phy-qcom-ufs.o
> obj-$(CONFIG_PHY_QCOM_UFS) += phy-qcom-ufs-qmp-20nm.o
> obj-$(CONFIG_PHY_QCOM_UFS) += phy-qcom-ufs-qmp-14nm.o
> obj-$(CONFIG_PHY_TUSB1210) += phy-tusb1210.o
> -obj-$(CONFIG_PHY_BRCMSTB_SATA) += phy-brcmstb-sata.o
> obj-$(CONFIG_PHY_PISTACHIO_USB) += phy-pistachio-usb.o
> obj-$(CONFIG_PHY_CYGNUS_PCIE) += phy-bcm-cygnus-pcie.o
> +obj-$(CONFIG_PHY_BRCM_SATA) += phy-brcm-sata.o
> diff --git a/drivers/phy/phy-brcmstb-sata.c b/drivers/phy/phy-brcm-sata.c
> similarity index 97%
> rename from drivers/phy/phy-brcmstb-sata.c
> rename to drivers/phy/phy-brcm-sata.c
> index a23172f..c97b9d6 100644
> --- a/drivers/phy/phy-brcmstb-sata.c
> +++ b/drivers/phy/phy-brcm-sata.c
> @@ -1,7 +1,7 @@
> /*
> * Broadcom SATA3 AHCI Controller PHY Driver
> *
> - * Copyright © 2009-2015 Broadcom Corporation
> + * Copyright (C) 2016 Broadcom
> *
> * This program is free software; you can redistribute it and/or modify
> * it under the terms of the GNU General Public License as published by
> @@ -238,13 +238,13 @@ static struct platform_driver brcm_sata_phy_driver = {
> .probe = brcm_sata_phy_probe,
> .driver = {
> .of_match_table = brcm_sata_phy_of_match,
> - .name = "brcmstb-sata-phy",
> + .name = "brcm-sata-phy",
> }
> };
> module_platform_driver(brcm_sata_phy_driver);
>
> -MODULE_DESCRIPTION("Broadcom STB SATA PHY driver");
> +MODULE_DESCRIPTION("Broadcom SATA PHY driver");
> MODULE_LICENSE("GPL");
> MODULE_AUTHOR("Marc Carino");
> MODULE_AUTHOR("Brian Norris");
> -MODULE_ALIAS("platform:phy-brcmstb-sata");
> +MODULE_ALIAS("platform:phy-brcm-sata");
>
Hi Kishon,
On Wed, Apr 13, 2016 at 7:28 PM, Kishon Vijay Abraham I <[email protected]> wrote:
> Hi,
>
> On Monday 28 March 2016 10:18 AM, Anup Patel wrote:
>> Currently, we have a common SATA3 PHY driver for all Broadcom
>> STB SoCs. This driver can be extended and re-used for Broadcom
>> iProc SoCs having same SATA3 PHY.
>>
>> This patch renames existing Broadcom STB SATA3 PHY driver to
>> common Broadcom SATA3 PHY driver to share this PHY driver across
>> Broadcom SoCs.
>>
>> Signed-off-by: Anup Patel <[email protected]>
>> ---
>> drivers/phy/Kconfig | 18 +++++++++---------
>> drivers/phy/Makefile | 2 +-
>> drivers/phy/{phy-brcmstb-sata.c => phy-brcm-sata.c} | 8 ++++----
>> 3 files changed, 14 insertions(+), 14 deletions(-)
>> rename drivers/phy/{phy-brcmstb-sata.c => phy-brcm-sata.c} (97%)
>>
>> diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig
>> index 26566db..c0187a7 100644
>> --- a/drivers/phy/Kconfig
>> +++ b/drivers/phy/Kconfig
>> @@ -403,15 +403,6 @@ config PHY_TUSB1210
>> help
>> Support for TI TUSB1210 USB ULPI PHY.
>>
>> -config PHY_BRCMSTB_SATA
>> - tristate "Broadcom STB SATA PHY driver"
>> - depends on ARCH_BRCMSTB || BMIPS_GENERIC
>> - depends on OF
>> - select GENERIC_PHY
>> - help
>> - Enable this to support the SATA3 PHY on 28nm or 40nm Broadcom STB SoCs.
>> - Likely useful only with CONFIG_SATA_BRCMSTB enabled.
>> -
>> config PHY_CYGNUS_PCIE
>> tristate "Broadcom Cygnus PCIe PHY driver"
>> depends on OF && (ARCH_BCM_CYGNUS || COMPILE_TEST)
>> @@ -421,4 +412,13 @@ config PHY_CYGNUS_PCIE
>> Enable this to support the Broadcom Cygnus PCIe PHY.
>> If unsure, say N.
>>
>> +config PHY_BRCM_SATA
>
> changing config name should be done with utmost care as it might break
> oldconfig users.
> Has this been fixed in all the defconfigs where it is included?
None of the existing defconfigs have PHY_BRCMSTB_SATA enabled. In fact,
no other Kconfig option currently selects PHY_BRCMSTB_SATA. I think we
are safe here.
Regards,
Anup
Hi,
On Monday 28 March 2016 10:18 AM, Anup Patel wrote:
> The Broadcom NS2 SoC has a AHCI compliant SATA3 controller with
> two ports.
>
> This patchset adds common Broadcom SATA3 PHY driver and related
> DT bindings document. It also adds appropriate DT nodes in NS2 DT.
>
> The patchset is based on v4.6-rc1 tag and is available in branch
> ns2_sata3_v2 of https://github.com/Broadcom/arm64-linux.git
>
> All patches have been tested on Broadcom NS2 SVK.
merged the first 3 patches to linux-phy tree.
Thanks
Kishon
>
> Changes since v1:
> - Added ACKed by Rob for DT bindings related patches
>
> Anup Patel (5):
> phy: Rename phy-brcmstb-sata driver to phy-brcm-sata driver
> phy: Add support for NS2 SATA3 PHY in Broadcom SATA3 PHY driver
> dt-bindings: phy: bindings document for common Broadcom SATA3 PHY
> driver
> dt-bindings: ata: add compatible string for iProc AHCI controller
> arm64: dts: Add SATA3 AHCI and SATA3 PHY DT nodes for NS2
>
> .../devicetree/bindings/ata/ahci-platform.txt | 1 +
> ...brcm,brcmstb-sata-phy.txt => brcm-sata-phy.txt} | 15 +-
> arch/arm64/boot/dts/broadcom/ns2-svk.dts | 12 +
> arch/arm64/boot/dts/broadcom/ns2.dtsi | 43 +++
> drivers/phy/Kconfig | 18 +-
> drivers/phy/Makefile | 2 +-
> drivers/phy/phy-brcm-sata.c | 412 +++++++++++++++++++++
> drivers/phy/phy-brcmstb-sata.c | 250 -------------
> 8 files changed, 487 insertions(+), 266 deletions(-)
> rename Documentation/devicetree/bindings/phy/{brcm,brcmstb-sata-phy.txt => brcm-sata-phy.txt} (69%)
> create mode 100644 drivers/phy/phy-brcm-sata.c
> delete mode 100644 drivers/phy/phy-brcmstb-sata.c
>
On 29/04/16 01:36, Kishon Vijay Abraham I wrote:
> Hi,
>
> On Monday 28 March 2016 10:18 AM, Anup Patel wrote:
>> The Broadcom NS2 SoC has a AHCI compliant SATA3 controller with
>> two ports.
>>
>> This patchset adds common Broadcom SATA3 PHY driver and related
>> DT bindings document. It also adds appropriate DT nodes in NS2 DT.
>>
>> The patchset is based on v4.6-rc1 tag and is available in branch
>> ns2_sata3_v2 of https://github.com/Broadcom/arm64-linux.git
>>
>> All patches have been tested on Broadcom NS2 SVK.
>
> merged the first 3 patches to linux-phy tree.
And applied patches 4-5 to devicetree-arm64/next, thanks!
--
Florian