Skip to contentSkip to conversation

usb: Add driver for USB signal re-mapper

PATCH Superseded Al Cooper 2 participants 4 messages Oct 9, 2020

Subsystems (4)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Al Cooper

author maintainer
#0 lore raw

v2 cover usb: Add driver for USB signal re-mapper

v2
- Move file from drivers/usb/host to drivers/usb/misc
- Combine Kconfig/Makefile patch and new driver patch
- Fixed bindings .yaml document based on feedback from Rob Herring
- NOTE: There were suggestions to use a pinmux driver or GPIO aggregator, but I think agreement was reached that they weren't a good fit.

Al Cooper (2):
dt-bindings: Add support for Broadcom USB pin map driver
usb: Add driver to allow any GPIO to be used for 7211 USB signals

 .../bindings/usb/brcm,usb-pinmap.yaml         |  70 ++++
 MAINTAINERS                                   |   8 +
 drivers/usb/misc/Kconfig                      |   9 +
 drivers/usb/misc/Makefile                     |   1 +
 drivers/usb/misc/brcmstb-usb-pinmap.c         | 348 ++++++++++++++++++
 5 files changed, 436 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/usb/brcm,usb-pinmap.yaml
 create mode 100644 drivers/usb/misc/brcmstb-usb-pinmap.c
Signature · 1 line
2.17.1
author maintainer
#1 lore raw

PATCH v2 1/2 dt-bindings: Add support for Broadcom USB pin map driver

Add DT bindings for the Broadcom USB pin map driver. This driver allows some USB input and output signals to be mapped to any GPIO instead of the normal dedicated pins to/from the XHCI controller.

---
 .../bindings/usb/brcm,usb-pinmap.yaml         | 70 +++++++++++++++++++
 1 file changed, 70 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/usb/brcm,usb-pinmap.yaml
Documentation/devicetree/bindings/usb/brcm,usb-pinmap.yaml new file +70 -0
new file mode 100644
index 000000000000..ffa148b9eaa8
@@ -0,0 +1,70 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/usb/brcm,usb-pinmap.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Broadcom USB pin map Controller Device Tree Bindings
+
+maintainers:
+  - Al Cooper <[email protected]>
+
+properties:
+  compatible:
+    items:
+      - const: brcm,usb-pinmap
+
+  reg:
+    maxItems: 1
+
+  interrupts:
+    maxItems: 1
+    description: Interrupt for signals mirrored to out-gpios.
+
+  in-gpios:
+    description: Array of one or two GPIO pins used for input signals.
+
+  brcm,in-functions:
+    $ref: /schemas/types.yaml#/definitions/string-array
+    description: Array of input signal names, one per gpio in in-gpios.
+
+  brcm,in-masks:
+    $ref: /schemas/types.yaml#/definitions/uint32-array
+    description: Array of enable and mask pairs, one per gpio in-gpios.
+
+  out-gpios:
+    description: Array of one GPIO pin used for output signals.
+
+  brcm,out-functions:
+    $ref: /schemas/types.yaml#/definitions/string-array
+    description: Array of output signal names, one per gpio in out-gpios.
+
+  brcm,out-masks:
+    $ref: /schemas/types.yaml#/definitions/uint32-array
+    description: Array of enable, value, changed and clear masks, one
+      per gpio in out-gpios.
+
+required:
+  - compatible
+  - reg
+
+additionalProperties: false
+
+dependencies:
+  in-gpios: [ interrupts ]
+
+examples:
+  - |
+    usb_pinmap: usb-pinmap@22000d0 {
+        compatible = "brcm,usb-pinmap";
+        reg = <0x22000d0 0x4>;
+        in-gpios = <&gpio 18 0>, <&gpio 19 0>;
+        brcm,in-functions = "VBUS", "PWRFLT";
+        brcm,in-masks = <0x8000 0x40000 0x10000 0x80000>;
+        out-gpios = <&gpio 20 0>;
+        brcm,out-functions = "PWRON";
+        brcm,out-masks = <0x20000 0x800000 0x400000 0x200000>;
+        interrupts = <0x0 0xb2 0x4>;
+    };
+
+...
Signature · 1 line
2.17.1
author maintainer
#2 lore raw

PATCH v2 2/2 usb: Add driver to allow any GPIO to be used for 7211 USB signals

In reply to Al Cooper

The Broadcom 7211 has new functionality that allows some USB low speed side band signals, that go from the XHCI host controller to pins on the chip, to be remapped to use any GPIO pin instead of the limited set selectable by hardware. This can be done without changing the standard driver for the host controller. There is currently support for three USB signals, PWRON, VBUS_PRESENT and PWRFLT. This driver will allow the remapping of any of these three signals based on settings in the Device Tree node for the driver. The driver was written so that it could handle additional signals added in the future by just adding the correct properties to the DT node.

Below is an example of a DT node that would remap all three signals:

usb_pinmap: usb-pinmap@22000d0 {
	compatible = "brcm,usb-pinmap";
	reg = <0x22000d0 0x4>;
	in-gpios = <&gpio 18 0>, <&gpio 19 0>;
	brcm,in-functions = "VBUS", "PWRFLT";
	brcm,in-masks = <0x8000 0x40000 0x10000 0x80000>;
	out-gpios = <&gpio 20 0>;
	brcm,out-functions = "PWRON";
	brcm,out-masks = <0x20000 0x800000 0x400000 0x200000>;
	interrupts = <0x0 0xb2 0x4>;
};
---
 MAINTAINERS                           |   8 +
 drivers/usb/misc/Kconfig              |   9 +
 drivers/usb/misc/Makefile             |   1 +
 drivers/usb/misc/brcmstb-usb-pinmap.c | 348 ++++++++++++++++++++++++++
 4 files changed, 366 insertions(+)
 create mode 100644 drivers/usb/misc/brcmstb-usb-pinmap.c
MAINTAINERS +8 -0
index cd2aea603e03..1198acd71534 100644
@@ -3567,6 +3567,14 @@ S:	Maintained
 F:	Documentation/devicetree/bindings/usb/brcm,bcm7445-ehci.yaml
 F:	drivers/usb/host/ehci-brcm.*
 
+BROADCOM BRCMSTB USB PIN MAP DRIVER
+M:	Al Cooper <[email protected]>
+L:	[email protected]
+L:	[email protected]
+S:	Maintained
+F:	Documentation/devicetree/bindings/usb/brcm,usb-pinmap.yaml
+F:	drivers/usb/misc/brcmstb-usb-pinmap.c
+
 BROADCOM BRCMSTB USB2 and USB3 PHY DRIVER
 M:	Al Cooper <[email protected]>
 L:	[email protected]
drivers/usb/misc/Kconfig +9 -0
index 6818ea689cd9..22e8a44fd2b2 100644
@@ -275,3 +275,12 @@ config USB_CHAOSKEY
 
 	  To compile this driver as a module, choose M here: the
 	  module will be called chaoskey.
+
+config BRCM_USB_PINMAP
+	tristate "Broadcom pinmap driver support"
+	depends on (ARCH_BRCMSTB && PHY_BRCM_USB) || COMPILE_TEST
+	default y if (ARCH_BRCMSTB && PHY_BRCM_USB)
+	help
+	  This option enables support for remapping some USB external
+	  signals, which are typically on dedicated pins on the chip,
+	  to any gpio.
drivers/usb/misc/Makefile +1 -0
index da39bddb0604..5f4e598573ab 100644
@@ -31,3 +31,4 @@ obj-$(CONFIG_USB_CHAOSKEY)		+= chaoskey.o
 
 obj-$(CONFIG_USB_SISUSBVGA)		+= sisusbvga/
 obj-$(CONFIG_USB_LINK_LAYER_TEST)	+= lvstest.o
+obj-$(CONFIG_BRCM_USB_PINMAP)		+= brcmstb-usb-pinmap.o
drivers/usb/misc/brcmstb-usb-pinmap.c new file +348 -0

348 lines not on this page · raw message

Signature · 1 line
2.17.1
#3 lore raw

Re: [PATCH v2 2/2] usb: Add driver to allow any GPIO to be used for 7211 USB signals

Quoted 28 lines · Al Cooper

The Broadcom 7211 has new functionality that allows some USB low speed side band signals, that go from the XHCI host controller to pins on the chip, to be remapped to use any GPIO pin instead of the limited set selectable by hardware. This can be done without changing the standard driver for the host controller. There is currently support for three USB signals, PWRON, VBUS_PRESENT and PWRFLT. This driver will allow the remapping of any of these three signals based on settings in the Device Tree node for the driver. The driver was written so that it could handle additional signals added in the future by just adding the correct properties to the DT node.

Below is an example of a DT node that would remap all three signals:

usb_pinmap: usb-pinmap@22000d0 {
	compatible = "brcm,usb-pinmap";
	reg = <0x22000d0 0x4>;
	in-gpios = <&gpio 18 0>, <&gpio 19 0>;
	brcm,in-functions = "VBUS", "PWRFLT";
	brcm,in-masks = <0x8000 0x40000 0x10000 0x80000>;
	out-gpios = <&gpio 20 0>;
	brcm,out-functions = "PWRON";
	brcm,out-masks = <0x20000 0x800000 0x400000 0x200000>;
	interrupts = <0x0 0xb2 0x4>;
};

---

[snip]

drivers/usb/misc/Kconfig config USB_CHAOSKEY · line 282

Quoted 4 lines
drivers/usb/misc/Kconfig +4 -0
+config BRCM_USB_PINMAP
+	tristate "Broadcom pinmap driver support"
+	depends on (ARCH_BRCMSTB && PHY_BRCM_USB) || COMPILE_TEST
+	default y if (ARCH_BRCMSTB && PHY_BRCM_USB)

default ARCH_BRCMSTB && PHY_BRCM_USB should work as well.

drivers/usb/misc/brcmstb-usb-pinmap.c line 348

Quoted 7 lines
drivers/usb/misc/brcmstb-usb-pinmap.c new file +7 -0
+static int __init brcmstb_usb_pinmap_init(void)
+{
+	return platform_driver_probe(&brcmstb_usb_pinmap_driver,
+				     brcmstb_usb_pinmap_probe);
+}
+
+module_init(brcmstb_usb_pinmap_init);

You would need MODULE_AUTHOR(), LICENSE and DESCRIPTION() in case you make this modular.

Signature · 6 lines
Florian

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel