Skip to contentSkip to conversation

Add Combo PHY driver for HiSilicon STB SoCs

PATCH Superseded Shawn Guo 1 participant 4 messages Oct 25, 2017 – Oct 26, 2017

Subsystems (2)

v3 of 5 Superseded Latest is v5 →

lore
Share & tools
lore

Shawn Guo

author
#0 lore raw

v3 cover Add Combo PHY driver for HiSilicon STB SoCs

From: Shawn Guo <[email protected]>

It adds device tree bindings and driver support for Combo PHY device which can be found on HiSilicon STB SoCs.

Changes for v3:
- Make combphy device be child of peripheral controller and use 'reg' property for mapping combphy configuration registers.
- Kill "hisilicon,peripheral-syscon" property, since parent node is just the syscon controller now.
- Check combphy id to handle the quirk that combphy0 can not configure mode but always works in USB3 mode.
- Unify phy .init and .exit hooks for different combphy instances and work modes, as the only quirk we need to handle is that combphy0 can only work in USB3 mode.
- Better naming for clock and reset, 'ref' to 'ref_clk', 'por' to 'por_rst'.

Changes for v2:
- Move DT bindings into a separate patch.
- Drop the spurious newline from drivers/phy/Makefile.
- Use the phy type defines in dt-bindings/phy/phy.h.
- Use PTR_ERR_OR_ZERO() for checking return from devm_of_phy_provider_register().
- Add USB3 phy support.

Jianguo Sun (2):
dt-bindings: add bindings doc for hi3798cv200 combphy
phy: add combo phy driver for HiSilicon STB SoCs

 .../bindings/phy/phy-hi3798cv200-combphy.txt       |  50 ++++
 drivers/phy/hisilicon/Kconfig                      |   9 +
 drivers/phy/hisilicon/Makefile                     |   1 +
 drivers/phy/hisilicon/phy-histb-combphy.c          | 253 +++++++++++++++++++++
 4 files changed, 313 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/phy/phy-hi3798cv200-combphy.txt
 create mode 100644 drivers/phy/hisilicon/phy-histb-combphy.c
Signature · 1 line
1.9.1
author
#1 lore raw

PATCH v3 1/2 dt-bindings: add bindings doc for hi3798cv200 combphy

From: Jianguo Sun <[email protected]>

It adds the device tree bindings for PCIE/SATA/USB3 combo PHY found on HiSilicon STB SoCs.

---
 .../bindings/phy/phy-hi3798cv200-combphy.txt       | 50 ++++++++++++++++++++++
 1 file changed, 50 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/phy/phy-hi3798cv200-combphy.txt
Documentation/devicetree/bindings/phy/phy-hi3798cv200-combphy.txt new file +50 -0
new file mode 100644
index 000000000000..b4041e33a804
@@ -0,0 +1,50 @@
+HiSilicon STB PCIE/SATA/USB3 PHY
+
+Required properties:
+- compatible: Should be "hisilicon,hi3798cv200-combphy"
+- reg: Should be the address space for COMBPHY configuration and state
+  registers in peripheral controller, e.g. PERI_COMBPHY0_CFG and
+  PERI_COMBPHY0_STATE for COMBPHY0 Hi3798cv200 SoC.
+- #phy-cells: Should be 1.  The cell number is used to select the phy mode
+  as defined in <dt-bindings/phy/phy.h>.
+- clocks: The phandle to clock provider and clock specifier pair.
+- resets: The phandle to reset controller and reset specifier pair.
+
+Refer to phy/phy-bindings.txt for the generic PHY binding properties
+
+Note:
+- The device node should be a child of peripheral controller that contains
+  COMBPHY configuration/state and PERI_CTRL register used to select PHY mode.
+- The combphy devices should have aliases defined.
+
+Example:
+
+aliases {
+	combphy0 = &combphy0;
+	combphy1 = &combphy1;
+};
+
+peri_ctrl: peri_ctrl at 8a20000 {
+	compatible = "hisilicon,hi3798cv200-perictrl", "syscon",
+		     "simple-mfd";
+	reg = <0x8a20000 0x1000>;
+	#address-cells = <1>;
+	#size-cells = <1>;
+	ranges = <0x0 0x8a20000 0x1000>;
+
+	combphy0: phy at 850 {
+		compatible = "hisilicon,hi3798cv200-combphy";
+		reg = <0x850 0x8>;
+		#phy-cells = <1>;
+		clocks = <&crg HISTB_COMBPHY0_CLK>;
+		resets = <&crg 0x188 4>;
+	};
+
+	combphy1: phy at 858 {
+		compatible = "hisilicon,hi3798cv200-combphy";
+		reg = <0x858 0x8>;
+		#phy-cells = <1>;
+		clocks = <&crg HISTB_COMBPHY1_CLK>;
+		resets = <&crg 0x188 12>;
+	};
+};
Signature · 1 line
1.9.1
author
#2 lore raw

PATCH v3 2/2 phy: add combo phy driver for HiSilicon STB SoCs

In reply to Shawn Guo

From: Jianguo Sun <[email protected]>

Add combo phy driver for HiSilicon STB SoCs. This phy can be used as pcie-phy, sata-phy or usb-phy.

---
 drivers/phy/hisilicon/Kconfig             |   9 ++
 drivers/phy/hisilicon/Makefile            |   1 +
 drivers/phy/hisilicon/phy-histb-combphy.c | 253 ++++++++++++++++++++++++++++++
 3 files changed, 263 insertions(+)
 create mode 100644 drivers/phy/hisilicon/phy-histb-combphy.c
drivers/phy/hisilicon/Kconfig +9 -0
index 6164c4cd0f65..d9afe2b12827 100644
@@ -11,6 +11,15 @@ config PHY_HI6220_USB
 
 	  To compile this driver as a module, choose M here.
 
+config PHY_HISTB_COMBPHY
+	tristate "HiSilicon STB SoCs COMBPHY support"
+	depends on (ARCH_HISI && ARM64) || COMPILE_TEST
+	select GENERIC_PHY
+	select MFD_SYSCON
+	help
+	  Enable this to support the HISILICON STB SoCs COMBPHY.
+	  If unsure, say N.
+
 config PHY_HIX5HD2_SATA
 	tristate "HIX5HD2 SATA PHY Driver"
 	depends on ARCH_HIX5HD2 && OF && HAS_IOMEM
drivers/phy/hisilicon/Makefile +1 -0
index 541b348187a8..5e8e2dfa8c37 100644
@@ -1,2 +1,3 @@
 obj-$(CONFIG_PHY_HI6220_USB)		+= phy-hi6220-usb.o
+obj-$(CONFIG_PHY_HISTB_COMBPHY)		+= phy-histb-combphy.o
 obj-$(CONFIG_PHY_HIX5HD2_SATA)		+= phy-hix5hd2-sata.o
drivers/phy/hisilicon/phy-histb-combphy.c new file +253 -0

253 lines not on this page · raw message

Signature · 1 line
1.9.1
author
#3 lore raw

PATCH v3 2/2 phy: add combo phy driver for HiSilicon STB SoCs

drivers/phy/hisilicon/phy-histb-combphy.c line 102

Quoted 8 lines · Shawn Guo
drivers/phy/hisilicon/phy-histb-combphy.c new file +8 -0
+static int histb_combphy_init(struct phy *phy)
+{
+	struct histb_combphy_priv *priv = phy_get_drvdata(phy);
+	u32 val;
+	int ret;
+
+	/* PHY0 doesn't support mode setting */
+	if (priv->phy_id != 0) {

With a bit more think on this, I admit it might not scale for future SoCs which could reasonably support mode select for combphy0. So instead of hard checking device id, I will repost with a new property added for this.

Shawn

Quoted 4 lines
drivers/phy/hisilicon/phy-histb-combphy.c new file +4 -0
+		ret = histb_combphy_set_mode(priv);
+		if (ret)
+			return ret;
+	}