Skip to contentSkip to conversation

Add Broadcom STB USB phy driver

PATCH Superseded Al Cooper 5 participants 15 messages Aug 25, 2017 – Sep 22, 2017

Subsystems (4)

v5 of 6 Superseded Latest is v6 →

lore
Share & tools
lore

Al Cooper

author maintainer
#0 lore raw

v5 cover Add Broadcom STB USB phy driver

Add a new USB Phy driver for Broadcom STB SoCs. This driver supports Broadcom STB ARM SoCs. This driver in combination with the Broadcom STB ohci, ehci and xhci drivers will enable USB1.1, USB2.0 and USB3.0 support. This Phy driver also supports the Broadcom BDC gadget driver.

Changes since v4:
- MIPS support was dropped, so remove MIPS specific code in the brcmusb_readl/brcmusb_writel routines.
- Use readl/writel instead of readl_relaxed/writel_relaxed.
- Remove double blank lines between some functions.
- Remove support for obselete phy phandle argument.

Changes since v3:
- Removed MIPS support because there is such a small amount of code that is common to both ARM and MIPS. I'll create a separate MIPS driver in the future.
- Have the Kconfig selection for this driver also select "CONFIG_SOC_BRCMSTB" which contains needed functions.
- Change device tree properties to use "brcm,has_xhci" and "brcm,has_eohci" to determine if the phy contains a xhci phy, and e/ohci phy or both.
- Change the phy xlate routine to return an error instead of NULL for a requested phy that doesn't exist.
- Moved some probe functionality into it's own funtion to simplify the many "if (has_xhci)" statements.

Changes since v2:
- Fix kbuild errors by changing Kconfig so the driver only builds for ARCH_BRCMSTB || BMIPS_GENERIC systems

Changes since v1:
- Rebased to next
- Add Kconfig entry to build the driver
- Commented all delays
- Split out sysfs functionality in separate patch
- Removed parsing of old obselete device tree properties
- Changed device property "device" to "dr_mode" using standard values "host" and "peripheral" along with new values "drd" and "typec-pd"
- Add ability to handle the standard PHY_TYPE_USB2 and PHY_TYPE_USB3 arguments passed in by phy consumers.
- Moved phy_provider_register() to end of probe routine

Al Cooper (4):
soc: brcmstb: Add Product ID and Family ID helper functions
dt-bindings: Add Broadcom STB USB PHY binding document
phy: usb: phy-brcm-usb: Add Broadcom STB USB phy driver
phy: usb: phy-brcm-usb: Add ability to force DRD mode to host or
device

 .../bindings/phy/brcm,brcmstb-usb-phy.txt          |   43 +
 MAINTAINERS                                        |    7 +
 drivers/phy/broadcom/Kconfig                       |   13 +
 drivers/phy/broadcom/Makefile                      |    3 +
 drivers/phy/broadcom/phy-brcm-usb-init.c           | 1007 ++++++++++++++++++++
 drivers/phy/broadcom/phy-brcm-usb-init.h           |   50 +
 drivers/phy/broadcom/phy-brcm-usb.c                |  458 +++++++++
 drivers/soc/bcm/brcmstb/common.c                   |   12 +
 include/linux/soc/brcmstb/brcmstb.h                |   10 +
 9 files changed, 1603 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/phy/brcm,brcmstb-usb-phy.txt
 create mode 100644 drivers/phy/broadcom/phy-brcm-usb-init.c
 create mode 100644 drivers/phy/broadcom/phy-brcm-usb-init.h
 create mode 100644 drivers/phy/broadcom/phy-brcm-usb.c
Signature · 1 line
1.9.0.138.g2de3478
author maintainer
#1 lore raw

PATCH v5 1/4 soc: brcmstb: Add Product ID and Family ID helper functions

---
 drivers/soc/bcm/brcmstb/common.c    | 12 ++++++++++++
 include/linux/soc/brcmstb/brcmstb.h | 10 ++++++++++
 2 files changed, 22 insertions(+)
drivers/soc/bcm/brcmstb/common.c +12 -0
index b6195fd..184dbf5 100644
@@ -40,6 +40,18 @@ bool soc_is_brcmstb(void)
 	return of_match_node(brcmstb_machine_match, root) != NULL;
 }
 
+u32 brcmstb_get_family_id(void)
+{
+	return family_id;
+}
+EXPORT_SYMBOL(brcmstb_get_family_id);
+
+u32 brcmstb_get_product_id(void)
+{
+	return product_id;
+}
+EXPORT_SYMBOL(brcmstb_get_product_id);
+
 static const struct of_device_id sun_top_ctrl_match[] = {
 	{ .compatible = "brcm,bcm7125-sun-top-ctrl", },
 	{ .compatible = "brcm,bcm7346-sun-top-ctrl", },
include/linux/soc/brcmstb/brcmstb.h +10 -0
index 337ce41..23e4dc9 100644
@@ -1,10 +1,20 @@
 #ifndef __BRCMSTB_SOC_H
 #define __BRCMSTB_SOC_H
 
+#define BRCM_ID(reg)	((u32)reg >> 28 ? (u32)reg >> 16 : (u32)reg >> 8)
+#define BRCM_REV(reg)	((u32)reg & 0xff)
+
 /*
  * Bus Interface Unit control register setup, must happen early during boot,
  * before SMP is brought up, called by machine entry point.
  */
 void brcmstb_biuctrl_init(void);
 
+/*
+ * Helper functions for getting family or product id from the
+ * SoC driver.
+ */
+u32 brcmstb_get_family_id(void);
+u32 brcmstb_get_product_id(void);
+
 #endif /* __BRCMSTB_SOC_H */
Signature · 1 line
1.9.0.138.g2de3478
Acked-by on v5 1/4
#2 lore raw

Re: [PATCH V5 1/4] soc: brcmstb: Add Product ID and Family ID helper functions

Quoted 1 line · Al Cooper
Quoted 54 lines
---
 drivers/soc/bcm/brcmstb/common.c    | 12 ++++++++++++
 include/linux/soc/brcmstb/brcmstb.h | 10 ++++++++++
 2 files changed, 22 insertions(+)
drivers/soc/bcm/brcmstb/common.c +12 -0
index b6195fd..184dbf5 100644
@@ -40,6 +40,18 @@ bool soc_is_brcmstb(void)
 	return of_match_node(brcmstb_machine_match, root) != NULL;
 }
 
+u32 brcmstb_get_family_id(void)
+{
+	return family_id;
+}
+EXPORT_SYMBOL(brcmstb_get_family_id);
+
+u32 brcmstb_get_product_id(void)
+{
+	return product_id;
+}
+EXPORT_SYMBOL(brcmstb_get_product_id);
+
 static const struct of_device_id sun_top_ctrl_match[] = {
 	{ .compatible = "brcm,bcm7125-sun-top-ctrl", },
 	{ .compatible = "brcm,bcm7346-sun-top-ctrl", },
include/linux/soc/brcmstb/brcmstb.h +10 -0
index 337ce41..23e4dc9 100644
@@ -1,10 +1,20 @@
 #ifndef __BRCMSTB_SOC_H
 #define __BRCMSTB_SOC_H
 
+#define BRCM_ID(reg)	((u32)reg >> 28 ? (u32)reg >> 16 : (u32)reg >> 8)
+#define BRCM_REV(reg)	((u32)reg & 0xff)
+
 /*
  * Bus Interface Unit control register setup, must happen early during boot,
  * before SMP is brought up, called by machine entry point.
  */
 void brcmstb_biuctrl_init(void);
 
+/*
+ * Helper functions for getting family or product id from the
+ * SoC driver.
+ */
+u32 brcmstb_get_family_id(void);
+u32 brcmstb_get_product_id(void);
+
 #endif /* __BRCMSTB_SOC_H */
Signature · 1 line
Florian
#3 lore raw

Re: [PATCH V5 1/4] soc: brcmstb: Add Product ID and Family ID helper functions

Hi,

Quoted 6 lines · Florian Fainelli
Quoted 1 line · Al Cooper

I get the following checkpatch warning
CHECK: Macro argument reuse 'reg' - possible side-effects? #110: FILE: include/linux/soc/brcmstb/brcmstb.h:4:
+#define BRCM_ID(reg) ((u32)reg >> 28 ? (u32)reg >> 16 : (u32)reg >> 8)

Can you fix it and resend. While at that also add commmit log.

Thanks
Kishon

Quoted 56 lines
Quoted 55 lines
---
 drivers/soc/bcm/brcmstb/common.c    | 12 ++++++++++++
 include/linux/soc/brcmstb/brcmstb.h | 10 ++++++++++
 2 files changed, 22 insertions(+)
drivers/soc/bcm/brcmstb/common.c +12 -0
index b6195fd..184dbf5 100644
@@ -40,6 +40,18 @@ bool soc_is_brcmstb(void)
 	return of_match_node(brcmstb_machine_match, root) != NULL;
 }
 
+u32 brcmstb_get_family_id(void)
+{
+	return family_id;
+}
+EXPORT_SYMBOL(brcmstb_get_family_id);
+
+u32 brcmstb_get_product_id(void)
+{
+	return product_id;
+}
+EXPORT_SYMBOL(brcmstb_get_product_id);
+
 static const struct of_device_id sun_top_ctrl_match[] = {
 	{ .compatible = "brcm,bcm7125-sun-top-ctrl", },
 	{ .compatible = "brcm,bcm7346-sun-top-ctrl", },
include/linux/soc/brcmstb/brcmstb.h +10 -0
index 337ce41..23e4dc9 100644
@@ -1,10 +1,20 @@
 #ifndef __BRCMSTB_SOC_H
 #define __BRCMSTB_SOC_H
 
+#define BRCM_ID(reg)	((u32)reg >> 28 ? (u32)reg >> 16 : (u32)reg >> 8)
+#define BRCM_REV(reg)	((u32)reg & 0xff)
+
 /*
  * Bus Interface Unit control register setup, must happen early during boot,
  * before SMP is brought up, called by machine entry point.
  */
 void brcmstb_biuctrl_init(void);
 
+/*
+ * Helper functions for getting family or product id from the
+ * SoC driver.
+ */
+u32 brcmstb_get_family_id(void);
+u32 brcmstb_get_product_id(void);
+
 #endif /* __BRCMSTB_SOC_H */
#4 lore raw

Re: [PATCH V5 1/4] soc: brcmstb: Add Product ID and Family ID helper functions

Kishon,

I ran checkpatch on all my patches before submitting them and didn't get any warnings. It looks like you may be running checkpatch with the "--subjective" option. Is this a requirement and if so are there any other checkpatch options I should be using?

Thanks
Al

Quoted 76 lines · Kishon Vijay Abraham I' via BCM-KERNEL-FEEDBACK-LIST,PDL

Hi,

Quoted 6 lines · Florian Fainelli
Quoted 1 line · Al Cooper

I get the following checkpatch warning
CHECK: Macro argument reuse 'reg' - possible side-effects? #110: FILE: include/linux/soc/brcmstb/brcmstb.h:4:
+#define BRCM_ID(reg) ((u32)reg >> 28 ? (u32)reg >> 16 : (u32)reg >> 8)

Can you fix it and resend. While at that also add commmit log.

Thanks
Kishon

Quoted 56 lines
Quoted 55 lines
---
 drivers/soc/bcm/brcmstb/common.c    | 12 ++++++++++++
 include/linux/soc/brcmstb/brcmstb.h | 10 ++++++++++
 2 files changed, 22 insertions(+)
drivers/soc/bcm/brcmstb/common.c +12 -0
index b6195fd..184dbf5 100644
@@ -40,6 +40,18 @@ bool soc_is_brcmstb(void)
     return of_match_node(brcmstb_machine_match, root) != NULL;
 }
 
+u32 brcmstb_get_family_id(void)
+{
+    return family_id;
+}
+EXPORT_SYMBOL(brcmstb_get_family_id);
+
+u32 brcmstb_get_product_id(void)
+{
+    return product_id;
+}
+EXPORT_SYMBOL(brcmstb_get_product_id);
+
 static const struct of_device_id sun_top_ctrl_match[] = {
     { .compatible = "brcm,bcm7125-sun-top-ctrl", },
     { .compatible = "brcm,bcm7346-sun-top-ctrl", },
include/linux/soc/brcmstb/brcmstb.h +10 -0
index 337ce41..23e4dc9 100644
@@ -1,10 +1,20 @@
 #ifndef __BRCMSTB_SOC_H
 #define __BRCMSTB_SOC_H
 
+#define BRCM_ID(reg)        ((u32)reg >> 28 ? (u32)reg >> 16 : (u32)reg >> 8)
+#define BRCM_REV(reg)       ((u32)reg & 0xff)
+
 /*
  * Bus Interface Unit control register setup, must happen early during boot,
  * before SMP is brought up, called by machine entry point.
  */
 void brcmstb_biuctrl_init(void);
 
+/*
+ * Helper functions for getting family or product id from the
+ * SoC driver.
+ */
+u32 brcmstb_get_family_id(void);
+u32 brcmstb_get_product_id(void);
+
 #endif /* __BRCMSTB_SOC_H */
#5 lore raw

Re: [PATCH V5 1/4] soc: brcmstb: Add Product ID and Family ID helper functions

Quoted 7 lines · Al Cooper

Kishon,

I ran checkpatch on all my patches before submitting them and didn't get any warnings. It looks like you may be running checkpatch with the "--subjective" option. Is this a requirement and if so are there any other checkpatch options I should be using?

Quoted 10 lines

Thanks
Al

Quoted 4 lines · Kishon Vijay Abraham I' via BCM-KERNEL-FEEDBACK-LIST,PDL

Hi,

Quoted 1 line · Florian Fainelli

On 08/25/2017 10:51 AM, Al Cooper wrote:

[]

Quoted 4 lines
Quoted 4 lines

I get the following checkpatch warning
CHECK: Macro argument reuse 'reg' - possible side-effects? #110: FILE: include/linux/soc/brcmstb/brcmstb.h:4:
+#define BRCM_ID(reg) ((u32)reg >> 28 ? (u32)reg >> 16 : (u32)reg >> 8)

[]

Quoted 10 lines
Quoted 10 lines
Quoted 10 lines

include/linux/soc/brcmstb/brcmstb.h line 5

Quoted 10 lines
include/linux/soc/brcmstb/brcmstb.h +2 -0
index 337ce41..23e4dc9 100644
@@ -1,10 +1,20 @@
 #ifndef __BRCMSTB_SOC_H
 #define __BRCMSTB_SOC_H
 
+#define BRCM_ID(reg)        ((u32)reg >> 28 ? (u32)reg >> 16 : (u32)reg >> 8)
+#define BRCM_REV(reg)       ((u32)reg & 0xff)

These should be (reg) to avoid a possible issue with cast precedence or
maybe a use a statement expression
macro with a temporary to avoid the
reuse message.

author maintainer
#6 lore raw

PATCH v5 2/4 dt-bindings: Add Broadcom STB USB PHY binding document

In reply to Al Cooper

Add DT bindings document for Broadcom STB USB PHYs

---
 .../bindings/phy/brcm,brcmstb-usb-phy.txt          | 43 ++++++++++++++++++++++
 1 file changed, 43 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/phy/brcm,brcmstb-usb-phy.txt
Documentation/devicetree/bindings/phy/brcm,brcmstb-usb-phy.txt new file +43 -0
new file mode 100644
index 0000000..24a0d06
@@ -0,0 +1,43 @@
+Broadcom STB USB PHY
+
+Required properties:
+ - compatible: brcm,brcmstb-usb-phy
+ - reg: two offset and length pairs.
+	The first pair specifies a manditory set of memory mapped
+	registers used for general control of the PHY.
+	The second pair specifies optional registers used by some of
+	the SoCs that support USB 3.x
+ - #phy-cells: Shall be 1 as it expects one argument for setting
+	       the type of the PHY. Possible values are:
+	       - PHY_TYPE_USB2 for USB1.1/2.0 PHY
+	       - PHY_TYPE_USB3 for USB3.x PHY
+
+Optional Properties:
+- clocks : clock phandles.
+- clock-names: String, clock name.
+- brcm,ipp: Boolean, Invert Port Power.
+  Possible values are: 0 (Don't invert), 1 (Invert)
+- brcm,ioc: Boolean, Invert Over Current detection.
+  Possible values are: 0 (Don't invert), 1 (Invert)
+NOTE: one or both of the following two properties must be set
+- brcm,has-xhci: Boolean indicating the phy has an XHCI phy.
+- brcm,has-eohci: Boolean indicating the phy has an EHCI/OHCI phy.
+- dr_mode: String, PHY Device mode.
+  Possible values are: "host", "peripheral ", "drd" or "typec-pd"
+  If this property is not defined, the phy will default to "host" mode.
+
+Example:
+
+usbphy_0: usb-phy at f0470200 {
+	reg = <0xf0470200 0xb8>,
+		<0xf0471940 0x6c0>;
+	compatible = "brcm,brcmstb-usb-phy";
+	#phy-cells = <1>;
+	dr_mode = "host"
+	brcm,ioc = <1>;
+	brcm,ipp = <1>;
+	brcm,has-xhci;
+	brcm,has-eohci;
+	clocks = <&usb20>, <&usb30>;
+	clock-names = "sw_usb", "sw_usb3";
+};
Signature · 1 line
1.9.0.138.g2de3478
author maintainer
#7 lore raw

PATCH v5 3/4 phy: usb: phy-brcm-usb: Add Broadcom STB USB phy driver

In reply to Al Cooper

Add a new USB Phy driver for Broadcom STB SoCs. This driver supports Broadcom STB ARM SoCs. This driver in combination with the Broadcom STB ohci, ehci and xhci drivers will enable USB1.1, USB2.0 and USB3.0 support. This Phy driver also supports the Broadcom BDC gadget driver.

---
 MAINTAINERS                              |    7 +
 drivers/phy/broadcom/Kconfig             |   13 +
 drivers/phy/broadcom/Makefile            |    3 +
 drivers/phy/broadcom/phy-brcm-usb-init.c | 1007 ++++++++++++++++++++++++++++++
 drivers/phy/broadcom/phy-brcm-usb-init.h |   50 ++
 drivers/phy/broadcom/phy-brcm-usb.c      |  373 +++++++++++
 6 files changed, 1453 insertions(+)
 create mode 100644 drivers/phy/broadcom/phy-brcm-usb-init.c
 create mode 100644 drivers/phy/broadcom/phy-brcm-usb-init.h
 create mode 100644 drivers/phy/broadcom/phy-brcm-usb.c
MAINTAINERS +7 -0
index d711d53..63b6f41 100644
@@ -2774,6 +2774,13 @@ L:	linux-pm at vger.kernel.org
 S:	Maintained
 F:	drivers/cpufreq/bmips-cpufreq.c
 
+BROADCOM BRCMSTB USB2 and USB3 PHY DRIVER
+M:	Al Cooper <[email protected]>
+L:	linux-kernel at vger.kernel.org
+L:	bcm-kernel-feedback-list at broadcom.com
+S:	Maintained
+F:	drivers/phy/broadcom/phy-brcm-usb*
+
 BROADCOM TG3 GIGABIT ETHERNET DRIVER
 M:	Siva Reddy Kallam <[email protected]>
 M:	Prashant Sreedharan <[email protected]>
drivers/phy/broadcom/Kconfig +13 -0
index c4b632e..27c71d6 100644
@@ -66,3 +66,16 @@ config PHY_BRCM_SATA
 	help
 	  Enable this to support the Broadcom SATA PHY.
 	  If unsure, say N.
+
+config PHY_BRCM_USB
+	tristate "Broadcom STB USB PHY driver"
+	depends on ARCH_BRCMSTB || BMIPS_GENERIC
+	depends on OF
+	select GENERIC_PHY
+	select SOC_BRCMSTB
+	default ARCH_BRCMSTB || BMIPS_GENERIC
+	help
+	  Enable this to support the Broadcom STB USB PHY.
+	  This driver is required by the USB XHCI, EHCI and OHCI
+	  drivers.
+	  If unsure, say N.
drivers/phy/broadcom/Makefile +3 -0
index 4eb82ec..7c37ba6 100644
@@ -5,3 +5,6 @@ obj-$(CONFIG_PHY_BCM_NS_USB3)		+= phy-bcm-ns-usb3.o
 obj-$(CONFIG_PHY_NS2_PCIE)		+= phy-bcm-ns2-pcie.o
 obj-$(CONFIG_PHY_NS2_USB_DRD)		+= phy-bcm-ns2-usbdrd.o
 obj-$(CONFIG_PHY_BRCM_SATA)		+= phy-brcm-sata.o
+obj-$(CONFIG_PHY_BRCM_USB)		+= phy-brcm-usb-dvr.o
+
+phy-brcm-usb-dvr-objs := phy-brcm-usb.o phy-brcm-usb-init.o
drivers/phy/broadcom/phy-brcm-usb-init.c new file +1007 -0

1,007 lines not on this page · raw message

drivers/phy/broadcom/phy-brcm-usb-init.h new file +50 -0

50 lines not on this page · raw message

drivers/phy/broadcom/phy-brcm-usb.c new file +373 -0

373 lines not on this page · raw message

Signature · 1 line
1.9.0.138.g2de3478
author maintainer
#8 lore raw

PATCH v5 4/4 phy: usb: phy-brcm-usb: Add ability to force DRD mode to host or device

In reply to Al Cooper

From: Al Cooper <[email protected]>

When the usb phy device mode is set to "drd", the USB port will switch between device and host modes depending on what's plugged into the port. Customers have asked for the ability to force host or device mode from software. This commit adds sysfs entries to the phy device that allow this. The sysfs for the phy device can be found at:
/sys/bus/platform/drivers/brcmstb-usb-phy/*.usb-phy

The following sysfs entries were added:
- "dr_mode" (RO) - The current phy "dr_mode" setting. It will be set to one of the following values:
- "host" - host mode
- "peripheral " - device mode
- "drd" - switch between device and host mode based on installed device
- "typec-pd" - device/host mode is controller by the USB Type-C PD protocol.

If "dr_mode" is "drd"
- "drd_select" (RW) -
It will be set to one of the following values:
- "host" - force host mode
- "device" - force device mode
- "auto" - allow normal auto selection of host/device based on inserted USB device

---
 drivers/phy/broadcom/phy-brcm-usb.c | 85 +++++++++++++++++++++++++++++++++++++
 1 file changed, 85 insertions(+)
drivers/phy/broadcom/phy-brcm-usb.c +85 -0
index cda27e0..e30cc1d 100644
@@ -27,6 +27,8 @@
 
 #include "phy-brcm-usb-init.h"
 
+static DEFINE_MUTEX(sysfs_lock);
+
 enum brcm_usb_phy_id {
 	BRCM_USB_PHY_2_0 = 0,
 	BRCM_USB_PHY_3_0,
@@ -45,6 +47,12 @@ struct value_to_name_map {
 	{ USB_CTLR_MODE_TYPEC_PD, "typec-pd" }
 };
 
+static struct value_to_name_map brcm_dual_mode_to_name[] = {
+	{ 0, "host" },
+	{ 1, "device" },
+	{ 2, "auto" },
+};
+
 struct brcm_usb_phy {
 	struct phy *phy;
 	unsigned int id;
@@ -160,6 +168,73 @@ static int name_to_value(struct value_to_name_map *table, int count,
 	return -EINVAL;
 }
 
+static const char *value_to_name(struct value_to_name_map *table, int count,
+				int value)
+{
+	if (value >= count)
+		return "unknown";
+	return table[value].name;
+}
+
+static ssize_t dr_mode_show(struct device *dev,
+				struct device_attribute *attr,
+				char *buf)
+{
+	struct brcm_usb_phy_data *priv = dev_get_drvdata(dev);
+
+	return sprintf(buf, "%s\n",
+		value_to_name(&brcm_dr_mode_to_name[0],
+			ARRAY_SIZE(brcm_dr_mode_to_name),
+			priv->ini.mode));
+}
+static DEVICE_ATTR_RO(dr_mode);
+
+static ssize_t dual_select_store(struct device *dev,
+				struct device_attribute *attr,
+				const char *buf, size_t len)
+{
+	struct brcm_usb_phy_data *priv = dev_get_drvdata(dev);
+	int value;
+	int res;
+
+	mutex_lock(&sysfs_lock);
+	res = name_to_value(&brcm_dual_mode_to_name[0],
+			ARRAY_SIZE(brcm_dual_mode_to_name), buf, &value);
+	if (!res) {
+		brcm_usb_init_set_dual_select(&priv->ini, value);
+		res = len;
+	}
+	mutex_unlock(&sysfs_lock);
+	return res;
+}
+
+static ssize_t dual_select_show(struct device *dev,
+				struct device_attribute *attr,
+				char *buf)
+{
+	struct brcm_usb_phy_data *priv = dev_get_drvdata(dev);
+	int value;
+
+	mutex_lock(&sysfs_lock);
+	value = brcm_usb_init_get_dual_select(&priv->ini);
+	mutex_unlock(&sysfs_lock);
+	return sprintf(buf, "%s\n",
+		value_to_name(&brcm_dual_mode_to_name[0],
+			ARRAY_SIZE(brcm_dual_mode_to_name),
+			value));
+}
+static DEVICE_ATTR_RW(dual_select);
+
+static struct attribute *brcm_usb_phy_attrs[] = {
+	&dev_attr_dr_mode.attr,
+	&dev_attr_dual_select.attr,
+	NULL
+};
+
+static const struct attribute_group brcm_usb_phy_group = {
+	.attrs = brcm_usb_phy_attrs,
+};
+
 static int brcm_usb_phy_dvr_init(struct device *dev,
 				struct brcm_usb_phy_data *priv,
 				struct device_node *dn)
@@ -276,6 +351,16 @@ static int brcm_usb_phy_probe(struct platform_device *pdev)
 	/* make sure invert settings are correct */
 	brcm_usb_init_ipp(&priv->ini);
 
+	/*
+	 * Create sysfs entries for mode.
+	 * Remove "dual_select" attribute if not in dual mode
+	 */
+	if (priv->ini.mode != USB_CTLR_MODE_DRD)
+		brcm_usb_phy_attrs[1] = NULL;
+	err = sysfs_create_group(&dev->kobj, &brcm_usb_phy_group);
+	if (err)
+		dev_warn(dev, "Error creating sysfs attributes\n");
+
 	/* start with everything off */
 	if (priv->has_xhci)
 		brcm_usb_uninit_xhci(&priv->ini);
Signature · 1 line
1.9.0.138.g2de3478
#9 lore raw
In reply to Al Cooper
Quoted 6 lines · Al Cooper

Add a new USB Phy driver for Broadcom STB SoCs. This driver supports Broadcom STB ARM SoCs. This driver in combination with the Broadcom STB ohci, ehci and xhci drivers will enable USB1.1, USB2.0 and USB3.0 support. This Phy driver also supports the Broadcom BDC gadget driver.

Thanks Al! Kishon, feel free to merge everything through your tree there should not be any conflicts with drivers/soc/bcm/brcmstb/common.c and include/linux/soc/brcmstb/brcmstb.h.

Quoted 61 lines

Changes since v4:
- MIPS support was dropped, so remove MIPS specific code in the brcmusb_readl/brcmusb_writel routines.
- Use readl/writel instead of readl_relaxed/writel_relaxed.
- Remove double blank lines between some functions.
- Remove support for obselete phy phandle argument.

Changes since v3:
- Removed MIPS support because there is such a small amount of code that is common to both ARM and MIPS. I'll create a separate MIPS driver in the future.
- Have the Kconfig selection for this driver also select "CONFIG_SOC_BRCMSTB" which contains needed functions.
- Change device tree properties to use "brcm,has_xhci" and "brcm,has_eohci" to determine if the phy contains a xhci phy, and e/ohci phy or both.
- Change the phy xlate routine to return an error instead of NULL for a requested phy that doesn't exist.
- Moved some probe functionality into it's own funtion to simplify the many "if (has_xhci)" statements.

Changes since v2:
- Fix kbuild errors by changing Kconfig so the driver only builds for ARCH_BRCMSTB || BMIPS_GENERIC systems

Changes since v1:
- Rebased to next
- Add Kconfig entry to build the driver
- Commented all delays
- Split out sysfs functionality in separate patch
- Removed parsing of old obselete device tree properties
- Changed device property "device" to "dr_mode" using standard values "host" and "peripheral" along with new values "drd" and "typec-pd"
- Add ability to handle the standard PHY_TYPE_USB2 and PHY_TYPE_USB3 arguments passed in by phy consumers.
- Moved phy_provider_register() to end of probe routine

Al Cooper (4):
soc: brcmstb: Add Product ID and Family ID helper functions
dt-bindings: Add Broadcom STB USB PHY binding document
phy: usb: phy-brcm-usb: Add Broadcom STB USB phy driver
phy: usb: phy-brcm-usb: Add ability to force DRD mode to host or
device

 .../bindings/phy/brcm,brcmstb-usb-phy.txt          |   43 +
 MAINTAINERS                                        |    7 +
 drivers/phy/broadcom/Kconfig                       |   13 +
 drivers/phy/broadcom/Makefile                      |    3 +
 drivers/phy/broadcom/phy-brcm-usb-init.c           | 1007 ++++++++++++++++++++
 drivers/phy/broadcom/phy-brcm-usb-init.h           |   50 +
 drivers/phy/broadcom/phy-brcm-usb.c                |  458 +++++++++
 drivers/soc/bcm/brcmstb/common.c                   |   12 +
 include/linux/soc/brcmstb/brcmstb.h                |   10 +
 9 files changed, 1603 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/phy/brcm,brcmstb-usb-phy.txt
 create mode 100644 drivers/phy/broadcom/phy-brcm-usb-init.c
 create mode 100644 drivers/phy/broadcom/phy-brcm-usb-init.h
 create mode 100644 drivers/phy/broadcom/phy-brcm-usb.c
Signature · 1 line
Florian
#10 lore raw

Florian,

Quoted 10 lines · Florian Fainelli
Quoted 6 lines · Al Cooper

Add a new USB Phy driver for Broadcom STB SoCs. This driver supports Broadcom STB ARM SoCs. This driver in combination with the Broadcom STB ohci, ehci and xhci drivers will enable USB1.1, USB2.0 and USB3.0 support. This Phy driver also supports the Broadcom BDC gadget driver.

Quoted 3 lines

Thanks Al! Kishon, feel free to merge everything through your tree there should not be any conflicts with drivers/soc/bcm/brcmstb/common.c and include/linux/soc/brcmstb/brcmstb.h.

I'll start merging once 4.14 -rc1 is tagged.

Thanks
Kishon

#11 lore raw
Quoted 13 lines · Kishon Vijay Abraham I

Florian,

Quoted 10 lines · Florian Fainelli
Quoted 6 lines · Al Cooper

Add a new USB Phy driver for Broadcom STB SoCs. This driver supports Broadcom STB ARM SoCs. This driver in combination with the Broadcom STB ohci, ehci and xhci drivers will enable USB1.1, USB2.0 and USB3.0 support. This Phy driver also supports the Broadcom BDC gadget driver.

Quoted 6 lines
Quoted 1 line

Thanks Al! Kishon, feel free to merge everything through your tree

there

Quoted 2 lines

should not be any conflicts with drivers/soc/bcm/brcmstb/common.c and include/linux/soc/brcmstb/brcmstb.h.

I'll start merging once 4.14 -rc1 is tagged.

OK, does not that mean we will be missing this driver in 4.14? I suppose that's fine. Thanks! Hi Kishon,

Signature · 1 line
Florian
#12 lore raw

Hi Kishon,

Quoted 14 lines · Florian Fainelli
Quoted 13 lines · Kishon Vijay Abraham I

Florian,

Quoted 10 lines · Florian Fainelli
Quoted 6 lines · Al Cooper

Add a new USB Phy driver for Broadcom STB SoCs. This driver supports Broadcom STB ARM SoCs. This driver in combination with the Broadcom STB ohci, ehci and xhci drivers will enable USB1.1, USB2.0 and USB3.0 support. This Phy driver also supports the Broadcom BDC gadget driver.

Quoted 8 lines
Quoted 6 lines
Quoted 1 line

Thanks Al! Kishon, feel free to merge everything through your tree

there

Quoted 2 lines

should not be any conflicts with drivers/soc/bcm/brcmstb/common.c and include/linux/soc/brcmstb/brcmstb.h.

I'll start merging once 4.14 -rc1 is tagged.

OK, does not that mean we will be missing this driver in 4.14? I suppose that's fine. Thanks!

Gentle ping, v4.14-rc1 is now out, can you let us know if this patch series is good with you? Thanks!

Signature · 1 line
Florian
#13 lore raw

Hi Florian,

Quoted 22 lines · Florian Fainelli

Hi Kishon,

Quoted 19 lines · Florian Fainelli
Quoted 18 lines · Kishon Vijay Abraham I

Florian,

Quoted 11 lines · Florian Fainelli
Quoted 6 lines · Al Cooper

Add a new USB Phy driver for Broadcom STB SoCs. This driver supports Broadcom STB ARM SoCs. This driver in combination with the Broadcom STB ohci, ehci and xhci drivers will enable USB1.1, USB2.0 and USB3.0 support. This Phy driver also supports the Broadcom BDC gadget driver.

Thanks Al! Kishon, feel free to merge everything through your tree

there

Quoted 2 lines

should not be any conflicts with drivers/soc/bcm/brcmstb/common.c and include/linux/soc/brcmstb/brcmstb.h.

Quoted 6 lines
Quoted 3 lines
Quoted 1 line

I'll start merging once 4.14 -rc1 is tagged.

OK, does not that mean we will be missing this driver in 4.14? I suppose that's fine. Thanks!

Gentle ping, v4.14-rc1 is now out, can you let us know if this patch series is good with you? Thanks!

Thank you for reminding. Actually the patch series has quite a few "CHECK" checkpatch warnings. Can that be fixed before merging it?

Thanks
Kishon

#14 lore raw

I'll re-submit with all the CHECK warnings fixed.

Thanks
Al

Quoted 37 lines · Kishon Vijay Abraham I' via BCM-KERNEL-FEEDBACK-LIST,PDL

Hi Florian,

Quoted 22 lines · Florian Fainelli

Hi Kishon,

Quoted 19 lines · Florian Fainelli
Quoted 18 lines · Kishon Vijay Abraham I

Florian,

Quoted 11 lines · Florian Fainelli
Quoted 6 lines · Al Cooper

Add a new USB Phy driver for Broadcom STB SoCs. This driver supports Broadcom STB ARM SoCs. This driver in combination with the Broadcom STB ohci, ehci and xhci drivers will enable USB1.1, USB2.0 and USB3.0 support. This Phy driver also supports the Broadcom BDC gadget driver.

Thanks Al! Kishon, feel free to merge everything through your tree

there

Quoted 2 lines

should not be any conflicts with drivers/soc/bcm/brcmstb/common.c and include/linux/soc/brcmstb/brcmstb.h.

Quoted 6 lines
Quoted 3 lines
Quoted 1 line

I'll start merging once 4.14 -rc1 is tagged.

OK, does not that mean we will be missing this driver in 4.14? I suppose that's fine. Thanks!

Gentle ping, v4.14-rc1 is now out, can you let us know if this patch series is good with you? Thanks!

Thank you for reminding. Actually the patch series has quite a few "CHECK" checkpatch warnings. Can that be fixed before merging it?

Thanks
Kishon