usb: Add driver for USB signal re-mapper
Subsystems (4)
Al Cooper
maintainerPATCH v3 2/2 usb: Add driver to allow any GPIO to be used for 7211 USB signals
In reply to Al CooperThe 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 | 351 ++++++++++++++++++++++++++ 4 files changed, 369 insertions(+) create mode 100644 drivers/usb/misc/brcmstb-usb-pinmap.c
MAINTAINERS +8 -0
@@ -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
@@ -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 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
@@ -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 +351 -0
351 lines not on this page · raw message
Signature · 1 line
2.17.1
Al Cooper
maintainerPATCH v3 1/2 dt-bindings: Add support for Broadcom USB pin map driver
In reply to Al CooperAdd 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
@@ -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
Al Cooper
maintainerv3 cover usb: Add driver for USB signal re-mapper
v3
- Add MODULE_AUTHOR(), LICENSE and DESCRIPTION() so the driver can be built as a module.
- Improve Kconfig default entry
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.
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.
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 | 351 ++++++++++++++++++ 5 files changed, 439 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
kernel test robot
build botRe: [PATCH v3 2/2] usb: Add driver to allow any GPIO to be used for 7211 USB signals
In reply to Al CooperI love your patch! Perhaps something to improve:
Hi Al,
I love your patch! Perhaps something to improve:
[auto build test WARNING on usb/usb-testing]
[also build test WARNING on linus/master linux/master v5.9 next-20201012] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]
url: https://github.com/0day-ci/linux/commits/Al-Cooper/usb-Add-driver-for-USB-signal-re-mapper/20201013-040257 base: https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git usb-testing config: arm64-randconfig-r032-20201012 (attached as .config) compiler: clang version 12.0.0 (https://github.com/llvm/llvm-project 9e72d3eaf38f217698f72cb8fdc969a6e72dad3a)
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# install arm64 cross compiling tool for clang build
# apt-get install binutils-aarch64-linux-gnu
# https://github.com/0day-ci/linux/commit/96c8d52dbcdf6606c03aa54bcb5aece99b9328de
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Al-Cooper/usb-Add-driver-for-USB-signal-re-mapper/20201013-040257 git checkout 96c8d52dbcdf6606c03aa54bcb5aece99b9328de
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=arm64
If you fix the issue, kindly add following tag as appropriate
All warnings (new ones prefixed by >>):
>> drivers/usb/misc/brcmstb-usb-pinmap.c:219:6: warning: no previous prototype for function 'sync_all_pins' [-Wmissing-prototypes]
void sync_all_pins(struct brcmstb_usb_pinmap_data *pdata)
^ drivers/usb/misc/brcmstb-usb-pinmap.c:219:1: note: declare 'static' if the function is not intended to be used outside of this translation unit void sync_all_pins(struct brcmstb_usb_pinmap_data *pdata)
^
static
1 warning generated.
vim +/sync_all_pins +219 drivers/usb/misc/brcmstb-usb-pinmap.c
218
> 219 void sync_all_pins(struct brcmstb_usb_pinmap_data *pdata)
220 {
221 struct out_pin *pout;
222 struct in_pin *pin;
223 int val;
224 int x;
225
226 /*
227 * Enable the override, clear any changed condition and
228 * propagate the state to the GPIO for all out pins.
229 */
230 pout = pdata->out_pins;
231 for (x = 0; x < pdata->out_count; x++) {
232 pinmap_set(pdata->regs, pout->enable_mask);
233 pinmap_set(pdata->regs, pout->clr_changed_mask);
234 pinmap_unset(pdata->regs, pout->clr_changed_mask);
235 val = readl(pdata->regs) & pout->value_mask;
236 gpiod_set_value(pout->gpiod, val ? 1 : 0);
237 pout++;
238 }
239
240 /* sync and enable all in pins. */
241 pin = pdata->in_pins;
242 for (x = 0; x < pdata->in_count; x++) {
243 sync_in_pin(pin);
244 pinmap_set(pdata->regs, pin->enable_mask);
245 pin++;
246 }
247 }
248
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
Re: [PATCH v3 1/2] dt-bindings: Add support for Broadcom USB pin map driver
In reply to Al CooperQuoted 10 lines · Al Cooper
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.
Signed-off-by Al Cooper <[email protected]>--- .../bindings/usb/brcm,usb-pinmap.yaml | 70 +++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 Documentation/devicetree/bindings/usb/brcm,usb-pinmap.yaml