Skip to contentSkip to conversation

Add USB driver for HPE GXP Architecture

PATCH Superseded [email protected] 4 participants 16 messages Jul 6, 2023 – Aug 24, 2023

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover Add USB driver for HPE GXP Architecture

From: Richard Yu <[email protected]>

The GXP vEHCI controller presents a four port EHCI compatible PCI function to host software. Each EHCI port is logically connected to a corresponding set of virtual device registers.

Richard Yu (3):
dt-bindings: usb: Add HPE GXP UDCG Controller
usb: gadget: udc: gxp-udc: add HPE GXP USB support
MAINTAINERS: add USB support to GXP

 .../devicetree/bindings/usb/hpe,gxp-udcg.yaml |   70 +
 MAINTAINERS                                   |    2 +
 drivers/usb/gadget/udc/Kconfig                |    6 +
 drivers/usb/gadget/udc/Makefile               |    1 +
 drivers/usb/gadget/udc/gxp-udc.c              | 1401 +++++++++++++++++
 5 files changed, 1480 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/usb/hpe,gxp-udcg.yaml
 create mode 100644 drivers/usb/gadget/udc/gxp-udc.c
Signature · 1 line
2.17.1
#1 lore raw

PATCH 1/3 dt-bindings: usb: Add HPE GXP UDCG Controller

From: Richard Yu <[email protected]>

Provide access to the two register regions for GXP Virtual EHCI controller through the hpe,gxp-udcg binding.

---
 .../devicetree/bindings/usb/hpe,gxp-udcg.yaml | 70 +++++++++++++++++++
 1 file changed, 70 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/usb/hpe,gxp-udcg.yaml
Documentation/devicetree/bindings/usb/hpe,gxp-udcg.yaml new file +70 -0
new file mode 100644
index 000000000000..e6746374f97d
@@ -0,0 +1,70 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/usb/hpe,gxp-udcg.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: HPE GXP USB Virtual EHCI controller
+
+maintainers:
+  - Nick Hawkins <[email protected]>
+  - Richard Yu <[email protected]>
+
+description: |+
+  The HPE GXP USB Virtual EHCI Controller implements 1 set of USB EHCI
+  register and several sets of device and endpoint registers to support
+  the virtual EHCI's downstream USB devices.
+
+properties:
+  compatible:
+    enum:
+      - hpe,gxp-udcg
+
+  reg:
+    items:
+      - description: UDC Global (UDCG) config controller
+      - description: UDC Invidual config/interrupt controllers
+
+  reg-names:
+    items:
+      - const: udcg
+      - const: udc
+
+  interrupts:
+    maxItems: 1
+
+  hpe,vehci-downstream-ports:
+    description: Number of downstream ports supported by the GXP
+    $ref: /schemas/types.yaml#/definitions/uint32
+    default: 4
+    minimum: 1
+    maximum: 8
+
+  hpe,vehci-generic-endpoints:
+    description: Number of generic endpoints supported by the GXP
+    $ref: /schemas/types.yaml#/definitions/uint32
+    default: 16
+    minimum: 1
+    maximum: 16
+
+required:
+  - compatible
+  - reg
+  - reg-names
+  - interrupts
+  - hpe,vehci-downstream-ports
+  - hpe,vehci-generic-endpoints
+
+additionalProperties: false
+
+examples:
+  - |
+    udcg@80400800 {
+        compatible = "hpe,gxp-udcg";
+        reg = <0x80400800 0x0200>, <0x80401000 0x8000>;
+        reg-names = "udcg", "udc";
+        interrupts = <13>;
+        interrupt-parent = <&vic1>;
+        hpe,vehci-downstream-ports = <4>;
+        hpe,vehci-generic-endpoints = <16>;
+    };
Signature · 1 line
2.17.1
#15 lore raw

PATCH 3/3 MAINTAINERS: add USB support to GXP

In reply to [email protected]

From: Richard Yu <[email protected]>

Add the usb driver and dt-bindinng documents.

---
 MAINTAINERS | 2 ++
 1 file changed, 2 insertions(+)
MAINTAINERS +2 -0
index 27ef11624748..17a806469a18 100644
@@ -2245,6 +2245,7 @@ F:	Documentation/devicetree/bindings/hwmon/hpe,gxp-fan-ctrl.yaml
 F:	Documentation/devicetree/bindings/i2c/hpe,gxp-i2c.yaml
 F:	Documentation/devicetree/bindings/spi/hpe,gxp-spifi.yaml
 F:	Documentation/devicetree/bindings/timer/hpe,gxp-timer.yaml
+F:	Documentation/devicetree/bindings/usb/hpe,gxp-udcg.yaml
 F:	Documentation/hwmon/gxp-fan-ctrl.rst
 F:	arch/arm/boot/dts/hpe-bmc*
 F:	arch/arm/boot/dts/hpe-gxp*
@@ -2253,6 +2254,7 @@ F:	drivers/clocksource/timer-gxp.c
 F:	drivers/hwmon/gxp-fan-ctrl.c
 F:	drivers/i2c/busses/i2c-gxp.c
 F:	drivers/spi/spi-gxp.c
+F:	drivers/usb/gadget/udc/gxp-udc.c
 F:	drivers/watchdog/gxp-wdt.c
 
 ARM/IGEP MACHINE SUPPORT
Signature · 1 line
2.17.1
#9 lore raw

PATCH 2/3 usb: gadget: udc: gxp-udc: add HPE GXP USB support

In reply to [email protected]

From: Richard Yu <[email protected]>

The HPE GXP vEHCI controller presents a four port EHCI compatible PCI function to host software. Each vEHCI port is logically connected to a corresponding set of virtual device registers.

---
 drivers/usb/gadget/udc/Kconfig   |    6 +
 drivers/usb/gadget/udc/Makefile  |    1 +
 drivers/usb/gadget/udc/gxp-udc.c | 1401 ++++++++++++++++++++++++++++++
 3 files changed, 1408 insertions(+)
 create mode 100644 drivers/usb/gadget/udc/gxp-udc.c
drivers/usb/gadget/udc/Kconfig +6 -0
index 83cae6bb12eb..c01eb2a2c7db 100644
@@ -461,6 +461,12 @@ config USB_ASPEED_UDC
 	  dynamically linked module called "aspeed_udc" and force all
 	  gadget drivers to also be dynamically linked.
 
+config USB_GXP_UDC
+        bool "GXP UDC Driver"
+        depends on ARCH_HPE_GXP || COMPILE_TEST
+        help
+          Say "y" to add support for GXP UDC driver
+
 source "drivers/usb/gadget/udc/aspeed-vhub/Kconfig"
 
 #
drivers/usb/gadget/udc/Makefile +1 -0
index ee569f63c74a..63fa262f31c5 100644
@@ -42,3 +42,4 @@ obj-$(CONFIG_USB_ASPEED_VHUB)	+= aspeed-vhub/
 obj-$(CONFIG_USB_ASPEED_UDC)	+= aspeed_udc.o
 obj-$(CONFIG_USB_BDC_UDC)	+= bdc/
 obj-$(CONFIG_USB_MAX3420_UDC)	+= max3420_udc.o
+obj-$(CONFIG_USB_GXP_UDC)	+= gxp-udc.o
drivers/usb/gadget/udc/gxp-udc.c new file +1401 -0

1,401 lines not on this page · raw message

Signature · 1 line
2.17.1
#10 lore raw

Re: [PATCH v1 2/3] usb: gadget: udc: gxp-udc: add HPE GXP USB support

Quoted 5 lines · On Thu, Jul 06, 2023 at 04:59:09PM -0500, [email protected] wrote:

From: Richard Yu <[email protected]>

The HPE GXP vEHCI controller presents a four port EHCI compatible PCI function to host software. Each vEHCI port is logically connected to a corresponding set of virtual device registers.

What makes the vEHCI controller virtual? Presenting a "PCI function" certainly seems to indicate it is a physical device, indeed, a PCI device.

Quoted 14 lines
---
 drivers/usb/gadget/udc/Kconfig   |    6 +
 drivers/usb/gadget/udc/Makefile  |    1 +
 drivers/usb/gadget/udc/gxp-udc.c | 1401 ++++++++++++++++++++++++++++++
 3 files changed, 1408 insertions(+)
 create mode 100644 drivers/usb/gadget/udc/gxp-udc.c
drivers/usb/gadget/udc/Kconfig +0 -0
index 83cae6bb12eb..c01eb2a2c7db 100644

drivers/usb/gadget/udc/Kconfig config USB_ASPEED_UDC · line 468

Quoted 8 lines
drivers/usb/gadget/udc/Kconfig +5 -0
@@ -461,6 +461,12 @@ config USB_ASPEED_UDC
 	  dynamically linked module called "aspeed_udc" and force all
 	  gadget drivers to also be dynamically linked.
 
+config USB_GXP_UDC
+        bool "GXP UDC Driver"
+        depends on ARCH_HPE_GXP || COMPILE_TEST
+        help
+          Say "y" to add support for GXP UDC driver

Now hang on a second. What sort of driver is this patch adding support
for: a GXP vEHCI controller driver or a GXP UDC controller driver? The patch description says the first, but the code says the second.

It sounds like this thing actually is a PCI device that appears to the OS as an actual EHCI controller, but with virtual (rather than physical) downstream ports, and it includes a virtual UDC for each port. As such, it requires a driver for the virtual UDCs, which is what this patch provides. (No new driver is needed for the EHCI controller part, since the kernel already has an EHCI driver.)

Is that a correct description? And if it is, what is the purpose of this device? To act as a testing ground for gadget drivers?

Alan Stern

maintainer
#12 lore raw

Re: [PATCH v1 2/3] usb: gadget: udc: gxp-udc: add HPE GXP USB support

In reply to [email protected]
Quoted 5 lines · On Thu, Jul 06, 2023 at 04:59:09PM -0500, [email protected] wrote:
drivers/usb/gadget/udc/Kconfig +0 -0
index 83cae6bb12eb..c01eb2a2c7db 100644

drivers/usb/gadget/udc/Kconfig config USB_ASPEED_UDC · line 469

Quoted 9 lines
drivers/usb/gadget/udc/Kconfig +6 -0
@@ -461,6 +461,12 @@ config USB_ASPEED_UDC
 	  dynamically linked module called "aspeed_udc" and force all
 	  gadget drivers to also be dynamically linked.
 
+config USB_GXP_UDC
+        bool "GXP UDC Driver"
+        depends on ARCH_HPE_GXP || COMPILE_TEST
+        help
+          Say "y" to add support for GXP UDC driver
+

You need a real help text here please fix this up.

thanks,

greg k-h

#2 lore raw

Re: [PATCH v1 1/3] dt-bindings: usb: Add HPE GXP UDCG Controller

In reply to [email protected]
Quoted 4 lines · On 06/07/2023 23:59, [email protected] wrote:

From: Richard Yu <[email protected]>

Provide access to the two register regions for GXP Virtual EHCI controller through the hpe,gxp-udcg binding.

Thank you for your patch. There is something to discuss/improve.

Quoted 13 lines
---
 .../devicetree/bindings/usb/hpe,gxp-udcg.yaml | 70 +++++++++++++++++++
 1 file changed, 70 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/usb/hpe,gxp-udcg.yaml
Documentation/devicetree/bindings/usb/hpe,gxp-udcg.yaml new file +0 -0
new file mode 100644
index 000000000000..e6746374f97d

Documentation/devicetree/bindings/usb/hpe,gxp-udcg.yaml line 7

Quoted 7 lines
Documentation/devicetree/bindings/usb/hpe,gxp-udcg.yaml new file +7 -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/hpe,gxp-udcg.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: HPE GXP USB Virtual EHCI controller

The word "virtual" in bindings pretty often raises questions, because we describe usually real hardware, not virtual. Some explanation in description would be useful.

Documentation/devicetree/bindings/usb/hpe,gxp-udcg.yaml line 13

Quoted 6 lines
Documentation/devicetree/bindings/usb/hpe,gxp-udcg.yaml new file +6 -0
+
+maintainers:
+  - Nick Hawkins <[email protected]>
+  - Richard Yu <[email protected]>
+
+description: |+

Drop |+

Documentation/devicetree/bindings/usb/hpe,gxp-udcg.yaml line 17

Quoted 4 lines
Documentation/devicetree/bindings/usb/hpe,gxp-udcg.yaml new file +4 -0
+  The HPE GXP USB Virtual EHCI Controller implements 1 set of USB EHCI
+  register and several sets of device and endpoint registers to support
+  the virtual EHCI's downstream USB devices.
+

If this is EHCI controller, then I would expect here reference to usb-hcd.

Quoted 10 lines
Documentation/devicetree/bindings/usb/hpe,gxp-udcg.yaml new file +10 -0
+properties:
+  compatible:
+    enum:
+      - hpe,gxp-udcg
+
+  reg:
+    items:
+      - description: UDC Global (UDCG) config controller
+      - description: UDC Invidual config/interrupt controllers
+

Documentation/devicetree/bindings/usb/hpe,gxp-udcg.yaml line 37

Quoted 10 lines
Documentation/devicetree/bindings/usb/hpe,gxp-udcg.yaml new file +10 -0
+  reg-names:
+    items:
+      - const: udcg
+      - const: udc
+
+  interrupts:
+    maxItems: 1
+
+  hpe,vehci-downstream-ports:
+    description: Number of downstream ports supported by the GXP

Why do you need this property in DT and what exactly does it represent? You have one device - EHCI controller - and on some boards it is further customized? Even though it is the same device?

Documentation/devicetree/bindings/usb/hpe,gxp-udcg.yaml line 45

Quoted 8 lines
Documentation/devicetree/bindings/usb/hpe,gxp-udcg.yaml new file +8 -0
+    $ref: /schemas/types.yaml#/definitions/uint32
+    default: 4
+    minimum: 1
+    maximum: 8
+
+  hpe,vehci-generic-endpoints:
+    description: Number of generic endpoints supported by the GXP
+    $ref: /schemas/types.yaml#/definitions/uint32

Same concerns.

Quoted 7 lines
Documentation/devicetree/bindings/usb/hpe,gxp-udcg.yaml new file +7 -0
+    default: 16
+    minimum: 1
+    maximum: 16
+
+required:
+  - compatible
+  - reg

Documentation/devicetree/bindings/usb/hpe,gxp-udcg.yaml line 62

Quoted 10 lines
Documentation/devicetree/bindings/usb/hpe,gxp-udcg.yaml new file +10 -0
+  - reg-names
+  - interrupts
+  - hpe,vehci-downstream-ports
+  - hpe,vehci-generic-endpoints
+
+additionalProperties: false
+
+examples:
+  - |
+    udcg@80400800 {

Node names should be generic. See also an explanation and list of examples (not exhaustive) in DT specification:
https://devicetree-specification.readthedocs.io/en/latest/chapter2-devicetree-basics.html#generic-names-recommendation

Best regards,
Krzysztof

#13 lore raw

Re: [PATCH v1 2/3] usb: gadget: udc: gxp-udc: add HPE GXP USB support

In reply to [email protected]
Quoted 21 lines · On 06/07/2023 23:59, [email protected] wrote:

From: Richard Yu <[email protected]>

The HPE GXP vEHCI controller presents a four port EHCI compatible PCI function to host software. Each vEHCI port is logically connected to a corresponding set of virtual device registers.

---
 drivers/usb/gadget/udc/Kconfig   |    6 +
 drivers/usb/gadget/udc/Makefile  |    1 +
 drivers/usb/gadget/udc/gxp-udc.c | 1401 ++++++++++++++++++++++++++++++
 3 files changed, 1408 insertions(+)
 create mode 100644 drivers/usb/gadget/udc/gxp-udc.c
drivers/usb/gadget/udc/Kconfig +0 -0
index 83cae6bb12eb..c01eb2a2c7db 100644
@@ -461,6 +461,12 @@ config USB_ASPEED_UDC
 	  dynamically linked module called "aspeed_udc" and force all
 	  gadget drivers to also be dynamically linked.

...

Quoted 4 lines
drivers/usb/gadget/udc/Kconfig +4 -0
+
+static void gxp_udc_dev_release(struct device *dev)
+{
+	kfree(dev);

drivers/usb/gadget/udc/Kconfig

Quoted 10 lines
drivers/usb/gadget/udc/Kconfig +10 -0
+}
+
+int gxp_udc_init_dev(struct gxp_udcg_drvdata *udcg, unsigned int idx)
+{
+	struct gxp_udc_drvdata *drvdata;
+	struct device *parent = &udcg->pdev->dev;
+	int rc;
+
+	drvdata = devm_kzalloc(parent, sizeof(struct gxp_udc_drvdata),
+			       GFP_KERNEL);

sizeof(*...)

drivers/usb/gadget/udc/Kconfig

Quoted 5 lines
drivers/usb/gadget/udc/Kconfig +5 -0
+	if (!drvdata)
+		return -ENOMEM;
+
+	udcg->udc_drvdata[idx] = drvdata;
+	drvdata->pdev = udcg->pdev;

Why do you store platform_device? It's usually useless because dev is used.

Quoted 36 lines
drivers/usb/gadget/udc/Kconfig +36 -0
+	drvdata->vdevnum = idx;
+	drvdata->base = udcg->base + 0x1000 * idx;
+	drvdata->udcg_map = udcg->udcg_map;
+	drvdata->irq = udcg->irq;
+
+	/*
+	 * we setup USB device can have up to 4 endpoints besides control
+	 * endpoint 0.
+	 */
+	drvdata->fepnum = min_t(u32, udcg->max_fepnum, 4);
+
+	drvdata->vdevnum = idx;
+
+	/*
+	 * The UDC core really needs us to have separate and uniquely
+	 * named "parent" devices for each port so we create a sub device
+	 * here for that purpose
+	 */
+	drvdata->port_dev = kzalloc(sizeof(*drvdata->port_dev), GFP_KERNEL);
+	if (!drvdata->port_dev) {
+		rc = -ENOMEM;
+		goto fail_alloc;
+	}
+	device_initialize(drvdata->port_dev);
+	drvdata->port_dev->release = gxp_udc_dev_release;
+	drvdata->port_dev->parent = parent;
+	dev_set_name(drvdata->port_dev, "%s:p%d", dev_name(parent), idx + 1);
+
+	/* DMA setting */
+	drvdata->port_dev->dma_mask = parent->dma_mask;
+	drvdata->port_dev->coherent_dma_mask = parent->coherent_dma_mask;
+	drvdata->port_dev->bus_dma_limit = parent->bus_dma_limit;
+	drvdata->port_dev->dma_range_map = parent->dma_range_map;
+	drvdata->port_dev->dma_parms = parent->dma_parms;
+	drvdata->port_dev->dma_pools = parent->dma_pools;
+

drivers/usb/gadget/udc/Kconfig

Quoted 10 lines
drivers/usb/gadget/udc/Kconfig +10 -0
+	rc = device_add(drvdata->port_dev);
+	if (rc)
+		goto fail_add;
+
+	/* Populate gadget */
+	gxp_udc_init(drvdata);
+
+	rc = usb_add_gadget_udc(drvdata->port_dev, &drvdata->gadget);
+	if (rc != 0) {
+		dev_err(drvdata->port_dev, "add gadget failed\n");

return dev_err_probe

drivers/usb/gadget/udc/Kconfig

Quoted 8 lines
drivers/usb/gadget/udc/Kconfig +8 -0
+		goto fail_udc;
+	}
+	rc = devm_request_irq(drvdata->port_dev,
+			      drvdata->irq,
+			      gxp_udc_irq,
+			      IRQF_SHARED,
+			      gxp_udc_name[drvdata->vdevnum],
+			      drvdata);

Shared interrupt usually does not work with devm() and causes later issues. You need to triple check your unbind and error paths, because usually this just does not work. Usually we just don't allow devm for this case. If you are sure this is 100% correct, it could stay...

drivers/usb/gadget/udc/Kconfig

Quoted 3 lines
drivers/usb/gadget/udc/Kconfig +3 -0
+
+	if (rc < 0) {
+		dev_err(drvdata->port_dev, "irq request failed\n");

return dev_err_probe

drivers/usb/gadget/udc/Kconfig

Quoted 11 lines
drivers/usb/gadget/udc/Kconfig +11 -0
+		goto fail_udc;
+	}
+
+	return 0;
+
+fail_udc:
+	device_del(drvdata->port_dev);
+fail_add:
+	put_device(drvdata->port_dev);
+fail_alloc:
+	kfree(drvdata);

Are you sure you tested it? I see here double free.

drivers/usb/gadget/udc/Kconfig

Quoted 13 lines
drivers/usb/gadget/udc/Kconfig +13 -0
+
+	return rc;
+}
+
+static int gxp_udcg_probe(struct platform_device *pdev)
+{
+	struct resource *res;
+	struct gxp_udcg_drvdata *drvdata;
+	int ret, rc, err;
+	u32 vdevnum;
+	u32 fepnum, i;
+
+	drvdata = devm_kzalloc(&pdev->dev, sizeof(struct gxp_udcg_drvdata),

sizeof(*...)

drivers/usb/gadget/udc/Kconfig

Quoted 3 lines
drivers/usb/gadget/udc/Kconfig +3 -0
+			       GFP_KERNEL);
+	platform_set_drvdata(pdev, drvdata);
+	drvdata->pdev = pdev;

Why do you store platform_device? It's usually useless because dev is used.

drivers/usb/gadget/udc/Kconfig

Quoted 5 lines
drivers/usb/gadget/udc/Kconfig +5 -0
+
+	spin_lock_init(&drvdata->lock);
+
+	res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "udcg");
+	drvdata->udcg_base = devm_ioremap_resource(&pdev->dev, res);

Use helper for these two.

drivers/usb/gadget/udc/Kconfig

Quoted 2 lines
drivers/usb/gadget/udc/Kconfig +2 -0
+	if (IS_ERR(drvdata->udcg_base)) {
+		err = PTR_ERR(drvdata->udcg_base);

Drop

drivers/usb/gadget/udc/Kconfig

Quoted 7 lines
drivers/usb/gadget/udc/Kconfig +7 -0
+		return dev_err_probe(&pdev->dev, err, "failed to get udcg resource\n");
+	}
+
+	drvdata->udcg_map = devm_regmap_init_mmio(&pdev->dev, drvdata->udcg_base, &regmap_cfg);
+
+	if (IS_ERR(drvdata->udcg_map)) {
+		dev_err(&pdev->dev, "failed to map udcg regs");

return dev_err_probe

drivers/usb/gadget/udc/Kconfig

Quoted 1 line
drivers/usb/gadget/udc/Kconfig +1 -0
+		return -ENODEV;

Wrong error code

drivers/usb/gadget/udc/Kconfig

Quoted 6 lines
drivers/usb/gadget/udc/Kconfig +6 -0
+	}
+
+	res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "udc");
+	drvdata->base = devm_ioremap_resource(&pdev->dev, res);
+	if (IS_ERR(drvdata->base)) {
+		err = PTR_ERR(drvdata->base);

Drop

drivers/usb/gadget/udc/Kconfig

Quoted 6 lines
drivers/usb/gadget/udc/Kconfig +6 -0
+		return dev_err_probe(&pdev->dev, err, "failed to get udc resource\n");
+	}
+
+	ret = platform_get_irq(pdev, 0);
+	if (ret < 0) {
+		dev_err(&pdev->dev, "unable to obtain IRQ number\n");

return dev_err_probe

Quoted 8 lines
drivers/usb/gadget/udc/Kconfig +8 -0
+		return ret;
+	}
+	drvdata->irq = ret;
+
+	if (of_property_read_u32(pdev->dev.of_node, "hpe,vehci-downstream-ports", &vdevnum)) {
+		dev_err(&pdev->dev, "property ports number is undefined\n");
+		return -EINVAL;
+	}

drivers/usb/gadget/udc/Kconfig

Quoted 10 lines
drivers/usb/gadget/udc/Kconfig +10 -0
+
+	if (vdevnum > GXP_UDC_MAX_NUM_VDEVICE) {
+		dev_err(&pdev->dev, "property max port number(%d) is invalid\n", vdevnum);
+		return -EINVAL;
+	}
+	drvdata->max_vdevnum = vdevnum;
+
+	if (of_property_read_u32(pdev->dev.of_node, "hpe,vehci-generic-endpoints", &fepnum)) {
+		dev_err(&pdev->dev, "property generic endpoints is undefined\n");
+		return -EINVAL;

Why? Bindings stated it has default, so should not be required.

Quoted 18 lines
drivers/usb/gadget/udc/Kconfig +18 -0
+	}
+
+	if (fepnum > GXP_UDC_MAX_NUM_FLEX_EP) {
+		dev_err(&pdev->dev, "property fepnum(%d) is invalid\n", fepnum);
+		return -EINVAL;
+	}
+	drvdata->max_fepnum = fepnum;
+
+	gxp_udcg_init(drvdata);
+
+	/* Init child devices */
+	rc = 0;
+	for (i = 0; i < drvdata->max_vdevnum && rc == 0; i++)
+		rc = gxp_udc_init_dev(drvdata, i);
+
+	return rc;
+}
+

drivers/usb/gadget/udc/Kconfig

Quoted 10 lines
drivers/usb/gadget/udc/Kconfig +10 -0
+static const struct of_device_id gxp_udc_of_match[] = {
+	{ .compatible = "hpe,gxp-udcg" },
+	{},
+};
+MODULE_DEVICE_TABLE(of, gxp_udc_of_match);
+
+static struct platform_driver gxp_udc_driver = {
+	.driver = {
+		.name = "gxp-udc",
+		.of_match_table = of_match_ptr(gxp_udc_of_match),

Drop of_match_ptr(), you will have warnings here.

drivers/usb/gadget/udc/Kconfig

Quoted 8 lines
drivers/usb/gadget/udc/Kconfig +8 -0
+	},
+	.probe = gxp_udcg_probe,
+};
+module_platform_driver(gxp_udc_driver);
+
+MODULE_AUTHOR("Richard Yu <[email protected]>");
+MODULE_DESCRIPTION("HPE GXP vEHCI UDC Driver");
+MODULE_LICENSE("GPL");

Best regards,
Krzysztof

maintainer
#14 lore raw

Re: [PATCH v1 2/3] usb: gadget: udc: gxp-udc: add HPE GXP USB support

In reply to [email protected]
Quoted 57 lines · On Thu, Jul 06, 2023 at 04:59:09PM -0500, [email protected] wrote:

From: Richard Yu <[email protected]>

The HPE GXP vEHCI controller presents a four port EHCI compatible PCI function to host software. Each vEHCI port is logically connected to a corresponding set of virtual device registers.

---
 drivers/usb/gadget/udc/Kconfig   |    6 +
 drivers/usb/gadget/udc/Makefile  |    1 +
 drivers/usb/gadget/udc/gxp-udc.c | 1401 ++++++++++++++++++++++++++++++
 3 files changed, 1408 insertions(+)
 create mode 100644 drivers/usb/gadget/udc/gxp-udc.c
drivers/usb/gadget/udc/Kconfig +6 -0
index 83cae6bb12eb..c01eb2a2c7db 100644
@@ -461,6 +461,12 @@ config USB_ASPEED_UDC
 	  dynamically linked module called "aspeed_udc" and force all
 	  gadget drivers to also be dynamically linked.
 
+config USB_GXP_UDC
+        bool "GXP UDC Driver"
+        depends on ARCH_HPE_GXP || COMPILE_TEST
+        help
+          Say "y" to add support for GXP UDC driver
+
 source "drivers/usb/gadget/udc/aspeed-vhub/Kconfig"
 
 #
drivers/usb/gadget/udc/Makefile +1 -0
index ee569f63c74a..63fa262f31c5 100644
@@ -42,3 +42,4 @@ obj-$(CONFIG_USB_ASPEED_VHUB)	+= aspeed-vhub/
 obj-$(CONFIG_USB_ASPEED_UDC)	+= aspeed_udc.o
 obj-$(CONFIG_USB_BDC_UDC)	+= bdc/
 obj-$(CONFIG_USB_MAX3420_UDC)	+= max3420_udc.o
+obj-$(CONFIG_USB_GXP_UDC)	+= gxp-udc.o
drivers/usb/gadget/udc/gxp-udc.c new file +11 -0
new file mode 100644
index 000000000000..97d198128c06
@@ -0,0 +1,1401 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/* Copyright (C) 2023 Hewlett-Packard Enterprise Development Company, L.P. */
+
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/spinlock.h>
+#include <linux/interrupt.h>
+#include <linux/platform_device.h>
+#include <linux/of_platform.h>
+#include <linux/dma-mapping.h>
+#include <linux/delay.h>

drivers/usb/gadget/udc/gxp-udc.c line 21

Quoted 10 lines
drivers/usb/gadget/udc/gxp-udc.c new file +10 -0
+#include <linux/io.h>
+#include <linux/slab.h>
+#include <linux/clk.h>
+#include <linux/err.h>
+#include <linux/usb/ch9.h>
+#include <linux/usb/gadget.h>
+#include <linux/usb/otg.h>
+#include <linux/prefetch.h>
+#include <linux/regmap.h>
+#include <linux/mfd/syscon.h>

Are you sure you need all of these? I don't see any syscon_* calls in this file. Please audit the list of includes here and remove all unneeded ones.

thanks,

greg k-h

#3 lore raw

RE: [PATCH v1 1/3] dt-bindings: usb: Add HPE GXP UDCG Controller

In reply to Krzysztof Kozlowski
Quoted 6 lines
Quoted 2 lines

+title: HPE GXP USB Virtual EHCI controller

The word "virtual" in bindings pretty often raises questions, because we describe usually real hardware, not virtual. Some explanation in description would be useful.

Here we are working with virtual devices that are created and have no physical presence. We have modeled our code off of ASPEED's VHUB implementation to comply with the implementation in OpenBMC.

Quoted 7 lines
Quoted 4 lines

+ The HPE GXP USB Virtual EHCI Controller implements 1 set of USB EHCI
+ register and several sets of device and endpoint registers to support
+ the virtual EHCI's downstream USB devices.
+

If this is EHCI controller, then I would expect here reference to usb-hcd.

We will remove references to EHCI in code and documentation. It has been modeled to following ASPEEDs approach as mentioned above.

Quoted 7 lines
Quoted 2 lines

+ hpe,vehci-downstream-ports:
+ description: Number of downstream ports supported by the GXP

Why do you need this property in DT and what exactly does it represent? You have one device - EHCI controller - and on some boards it is further customized? Even though it is the same device?

That is correct. We can configure this VHUB Controller to have one to 8 virtual ports. This is similar to the aspeed virtual USB HUB "aspeed,vhub-downstream-ports" moving forward in the next patch we are going to use "hpe,vhub-downstream-ports"

Quoted 11 lines
Quoted 8 lines

+ $ref: /schemas/types.yaml#/definitions/uint32
+ default: 4
+ minimum: 1
+ maximum: 8
+
+ hpe,vehci-generic-endpoints:
+ description: Number of generic endpoints supported by the GXP
+ $ref: /schemas/types.yaml#/definitions/uint32

Same concerns.

We intend to change this to "hpe,vhub-generic-endpoints" following ASPEED's "aspeed,vhub-generic-endpoints"

Quoted 6 lines
Quoted 3 lines

+examples:
+ - |
+ udcg@80400800 {

Node names should be generic. See also an explanation and list of

...
We will use usb-hub.

Thank you for your feedback,
Richard Yu

#11 lore raw

RE: [PATCH v1 2/3] usb: gadget: udc: gxp-udc: add HPE GXP USB support

In reply to Alan Stern

-----Original Message-----
From: Alan Stern <[email protected]>
Sent: Thursday, July 6, 2023 9:17 PM
To: Yu, Richard <[email protected]>
Cc: Verdun, Jean-Marie <[email protected]>; Hawkins, Nick <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH v1 2/3] usb: gadget: udc: gxp-udc: add HPE GXP USB support

Quoted 8 lines · On Thu, Jul 06, 2023 at 04:59:09PM -0500, [email protected] wrote:
Quoted 5 lines

From: Richard Yu <[email protected]>

The HPE GXP vEHCI controller presents a four port EHCI compatible PCI function to host software. Each vEHCI port is logically connected to a corresponding set of virtual device registers.

What makes the vEHCI controller virtual? Presenting a "PCI function" certainly seems to indicate it is a physical device, indeed, a PCI device.

To the host and system OS, GXP is indeed to present a physical standard EHCI controller. The standard Linux EHCI driver will be used. What virtual Here are the ports. We will remove references to EHCI in code and Documentation. It has been modeled to following ASPEEDs v-hub approach.

Quoted 9 lines

drivers/usb/gadget/udc/Kconfig config USB_ASPEED_UDC · line 468

Quoted 5 lines
drivers/usb/gadget/udc/Kconfig +5 -0
+config USB_GXP_UDC
+        bool "GXP UDC Driver"
+        depends on ARCH_HPE_GXP || COMPILE_TEST
+        help
+          Say "y" to add support for GXP UDC driver

Now hang on a second. What sort of driver is this patch adding support
for: a GXP vEHCI controller driver or a GXP UDC controller driver? The patch description says the first, but the code says the second.

I will modify the patch description as a GXP virtual UDC driver.

Quoted 8 lines

It sounds like this thing actually is a PCI device that appears to the OS as
an actual EHCI controller, but with virtual (rather than physical) downstream ports, and it includes a virtual UDC for each port. As such, it requires a driver for the virtual UDCs, which is what this patch provides. (No new driver is needed for the EHCI controller part, since the kernel already has an EHCI driver.)

Is that a correct description? And if it is, what is the purpose of this device? To act as a testing ground for gadget drivers?

That is a correct description. The purpose of this device is for us to create virtual USB devices, such as virtual keyboard/ mouse using in OpenBmc KVM, virtual CD, virtual NIC...

Quoted 1 line

Alan Stern

Thank you very much for your feedback.

Richard.

#4 lore raw

Re: [PATCH v1 1/3] dt-bindings: usb: Add HPE GXP UDCG Controller

In reply to Yu, Richard
Quoted 8 lines · Richard
Quoted 6 lines
Quoted 2 lines

+title: HPE GXP USB Virtual EHCI controller

The word "virtual" in bindings pretty often raises questions, because we describe usually real hardware, not virtual. Some explanation in description would be useful.

Here we are working with virtual devices that are created and have no

Unfortunately I do not know what are virtual devices which do not exist physically. I have serious doubts that they fit Devicetree purpose...

Quoted 18 lines

physical presence. We have modeled our code off of ASPEED's VHUB implementation to comply with the implementation in OpenBMC.

Quoted 7 lines
Quoted 4 lines

+ The HPE GXP USB Virtual EHCI Controller implements 1 set of USB EHCI
+ register and several sets of device and endpoint registers to support
+ the virtual EHCI's downstream USB devices.
+

If this is EHCI controller, then I would expect here reference to usb-hcd.

We will remove references to EHCI in code and documentation. It has been modeled to following ASPEEDs approach as mentioned above.

Quoted 2 lines
Quoted 2 lines

+ hpe,vehci-downstream-ports:
+ description: Number of downstream ports supported by the GXP

Quoted 8 lines
Quoted 3 lines

Why do you need this property in DT and what exactly does it represent? You have one device - EHCI controller - and on some boards it is further customized? Even though it is the same device?

That is correct. We can configure this VHUB Controller to have one to 8 virtual ports. This is similar to the aspeed virtual USB HUB "aspeed,vhub-downstream-ports" moving forward in the next patch we are going to use "hpe,vhub-downstream-ports"

Moving forward you need to address this lack of physical presence... Aren't these different devices and you just forgot to customize the compatible?

Best regards,
Krzysztof

#5 lore raw

RE: [PATCH v1 1/3] dt-bindings: usb: Add HPE GXP UDCG Controller

Thank you, Mr. Kozlowski, for your feedback.

-----Original Message-----
From: Krzysztof Kozlowski <[email protected]>
Sent: Saturday, August 5, 2023 2:09 PM
To: Yu, Richard <[email protected]>; Verdun, Jean-Marie <[email protected]>; Hawkins, Nick <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH v1 1/3] dt-bindings: usb: Add HPE GXP UDCG Controller

Quoted 11 lines · Richard
Quoted 8 lines
Quoted 6 lines
Quoted 2 lines

+title: HPE GXP USB Virtual EHCI controller

The word "virtual" in bindings pretty often raises questions, because we describe usually real hardware, not virtual. Some explanation in description would be useful.

Here we are working with virtual devices that are created and have no

Unfortunately I do not know what are virtual devices which do not exist physically. I have serious doubts that they fit Devicetree purpose...

In our HPE gxp, we have an EHCI device which it is present to host as standard EHCI controller. However, this EHCI controller does not have any physical port. Users can figure this EHCI controller to have 1 to 8 ports (we call it as virtual ports) and attached 1 to 8 UDC devices (we call them as virtual devices). User can figure each port/device to
have 1 to 16 endpoints.

I am writing his driver to create the device descriptor entry for each port/UDC.
/sys/bus/platform/devices/80400800.vhub/80400800.vhub:p1 .... Thus,
the OpenBmc KVM can use them as virtual mouse/keyboard, virtual NIC ....

I am implementing this driver using the Aspeed virtual hub driver as example.

Just like the Aspeed virtual hub is in the Devicetree:

vhub: usb-vhub@1e6a0000 {
	compatible = "aspeed,ast2600-usb-vhub";
	reg = <0x1e6a0000 0x350>;
	interrupts = <GIC_SPI 5 IRQ_TYPE_LEVEL_HIGH>;
	clocks = <&syscon ASPEED_CLK_GATE_USBPORT1CLK>;
	aspeed,vhub-downstream-ports = <7>;
	aspeed,vhub-generic-endpoints = <21>;
	pinctrl-names = "default";
	pinctrl-0 = <&pinctrl_usb2ad_default>;
	status = "disabled";
};

In my case: (I am replacing "udcg" with "vhub" and remove the vehci reference).

 vhub: usb-vhub@80400800 {
	compatible = "hpe,gxp-vhub";
	reg = <0x80400800 0x0200>, <0x80401000 0x8000>;
	reg-names = "vhub", "udc";
	interrupts = <13>;
	interrupt-parent = <&vic1>;
	hpe,vhub-downstream-ports = <4>;
	hpe,vhub-generic-endpoints = <16>;
};
Quoted 22 lines
Quoted 22 lines

physical presence. We have modeled our code off of ASPEED's VHUB implementation to comply with the implementation in OpenBMC.

Quoted 7 lines
Quoted 4 lines

+ The HPE GXP USB Virtual EHCI Controller implements 1 set of USB
+ EHCI register and several sets of device and endpoint registers to
+ support the virtual EHCI's downstream USB devices.
+

If this is EHCI controller, then I would expect here reference to usb-hcd.

We will remove references to EHCI in code and documentation. It has been modeled to following ASPEEDs approach as mentioned above.

Quoted 7 lines

+ hpe,vehci-downstream-ports:
+ description: Number of downstream ports supported by the GXP

Why do you need this property in DT and what exactly does it represent? You have one device - EHCI controller - and on some boards it is further customized? Even though it is the same device?

Quoted 7 lines
Quoted 4 lines

That is correct. We can configure this VHUB Controller to have one to 8 virtual ports. This is similar to the aspeed virtual USB HUB "aspeed,vhub-downstream-ports" moving forward in the next patch we are going to use "hpe,vhub-downstream-ports"

Moving forward you need to address this lack of physical presence... Aren't these different devices and you just forgot to customize the compatible?

I don’t fully understand here. Isn't the lack of physical presence similar to the Aspeed virtual hub driver?

Quoted 2 lines

Best regards,
Krzysztof

Thank very much.

Richard.

#6 lore raw

Re: [PATCH v1 1/3] dt-bindings: usb: Add HPE GXP UDCG Controller

Quoted 50 lines · Richard

Thank you, Mr. Kozlowski, for your feedback.

-----Original Message-----
From: Krzysztof Kozlowski <[email protected]>
Sent: Saturday, August 5, 2023 2:09 PM
To: Yu, Richard <[email protected]>; Verdun, Jean-Marie <[email protected]>; Hawkins, Nick <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH v1 1/3] dt-bindings: usb: Add HPE GXP UDCG Controller

Quoted 11 lines · Richard
Quoted 8 lines
Quoted 6 lines
Quoted 2 lines

+title: HPE GXP USB Virtual EHCI controller

The word "virtual" in bindings pretty often raises questions, because we describe usually real hardware, not virtual. Some explanation in description would be useful.

Here we are working with virtual devices that are created and have no

Unfortunately I do not know what are virtual devices which do not exist physically. I have serious doubts that they fit Devicetree purpose...

In our HPE gxp, we have an EHCI device which it is present to host as standard EHCI controller. However, this EHCI controller does not have any physical port. Users can figure this EHCI controller to have 1 to 8 ports (we call it as virtual ports) and attached 1 to 8 UDC devices (we call them as virtual devices). User can figure each port/device to
have 1 to 16 endpoints.

I am writing his driver to create the device descriptor entry for each port/UDC.
/sys/bus/platform/devices/80400800.vhub/80400800.vhub:p1 .... Thus,
the OpenBmc KVM can use them as virtual mouse/keyboard, virtual NIC ....

I am implementing this driver using the Aspeed virtual hub driver as example.

Just like the Aspeed virtual hub is in the Devicetree:

vhub: usb-vhub@1e6a0000 {
	compatible = "aspeed,ast2600-usb-vhub";
	reg = <0x1e6a0000 0x350>;
	interrupts = <GIC_SPI 5 IRQ_TYPE_LEVEL_HIGH>;
	clocks = <&syscon ASPEED_CLK_GATE_USBPORT1CLK>;
	aspeed,vhub-downstream-ports = <7>;
	aspeed,vhub-generic-endpoints = <21>;
	pinctrl-names = "default";
	pinctrl-0 = <&pinctrl_usb2ad_default>;
	status = "disabled";
};

In my case: (I am replacing "udcg" with "vhub" and remove the vehci reference).

Quoted 9 lines
 vhub: usb-vhub@80400800 {
	compatible = "hpe,gxp-vhub";
	reg = <0x80400800 0x0200>, <0x80401000 0x8000>;
	reg-names = "vhub", "udc";
	interrupts = <13>;
	interrupt-parent = <&vic1>;
	hpe,vhub-downstream-ports = <4>;
	hpe,vhub-generic-endpoints = <16>;
};

The hub is not virtual, it is real. I understand that it is some software block or FPGA, but still I propose to skip any references to virtual.

Quoted 28 lines
Quoted 27 lines
Quoted 27 lines

physical presence. We have modeled our code off of ASPEED's VHUB implementation to comply with the implementation in OpenBMC.

Quoted 7 lines
Quoted 4 lines

+ The HPE GXP USB Virtual EHCI Controller implements 1 set of USB
+ EHCI register and several sets of device and endpoint registers to
+ support the virtual EHCI's downstream USB devices.
+

If this is EHCI controller, then I would expect here reference to usb-hcd.

We will remove references to EHCI in code and documentation. It has been modeled to following ASPEEDs approach as mentioned above.

Quoted 7 lines

+ hpe,vehci-downstream-ports:
+ description: Number of downstream ports supported by the GXP

Why do you need this property in DT and what exactly does it represent? You have one device - EHCI controller - and on some boards it is further customized? Even though it is the same device?

That is correct. We can configure this VHUB Controller to have one to 8 virtual ports. This is similar to the aspeed virtual USB HUB "aspeed,vhub-downstream-ports" moving forward in the next patch we are going to use "hpe,vhub-downstream-ports"

Quoted 5 lines
Quoted 2 lines

Moving forward you need to address this lack of physical presence... Aren't these different devices and you just forgot to customize the compatible?

I don’t fully understand here. Isn't the lack of physical presence similar to the Aspeed virtual hub driver?

I don't know Aspeed virtual hub driver. In any case, driver is irrelevant to the bindings.

Why setting maximum number of downstream ports or devices would be needed per-board? Do you save some resources that way?

Best regards,
Krzysztof

#7 lore raw

RE: [PATCH v1 1/3] dt-bindings: usb: Add HPE GXP UDCG Controller

Thank you, Mr. Kozlowski.

Quoted 29 lines
Quoted 18 lines

I am implementing this driver using the Aspeed virtual hub driver as example.

Just like the Aspeed virtual hub is in the Devicetree:

vhub: usb-vhub@1e6a0000 {
	compatible = "aspeed,ast2600-usb-vhub";
	reg = <0x1e6a0000 0x350>;
	interrupts = <GIC_SPI 5 IRQ_TYPE_LEVEL_HIGH>;
	clocks = <&syscon ASPEED_CLK_GATE_USBPORT1CLK>;
	aspeed,vhub-downstream-ports = <7>;
	aspeed,vhub-generic-endpoints = <21>;
	pinctrl-names = "default";
	pinctrl-0 = <&pinctrl_usb2ad_default>;
	status = "disabled";
};

In my case: (I am replacing "udcg" with "vhub" and remove the vehci reference).

Quoted 9 lines
 vhub: usb-vhub@80400800 {
	compatible = "hpe,gxp-vhub";
	reg = <0x80400800 0x0200>, <0x80401000 0x8000>;
	reg-names = "vhub", "udc";
	interrupts = <13>;
	interrupt-parent = <&vic1>;
	hpe,vhub-downstream-ports = <4>;
	hpe,vhub-generic-endpoints = <16>;
};
Quoted 1 line

The hub is not virtual, it is real. I understand that it is some software block or FPGA, but still I propose to skip any references to virtual.

I will remove any references to "virtual" in comment and documentation.

Quoted 14 lines
Quoted 14 lines
Quoted 13 lines
Quoted 13 lines
Quoted 7 lines

+ hpe,vehci-downstream-ports:
+ description: Number of downstream ports supported by the GXP

Why do you need this property in DT and what exactly does it represent? You have one device - EHCI controller - and on some boards it is further customized? Even though it is the same device?

That is correct. We can configure this VHUB Controller to have one to
8 virtual ports. This is similar to the aspeed virtual USB HUB "aspeed,vhub-downstream-ports" moving forward in the next patch we are going to use "hpe,vhub-downstream-ports"

Quoted 5 lines
Quoted 5 lines
Quoted 2 lines

Moving forward you need to address this lack of physical presence... Aren't these different devices and you just forgot to customize the compatible?

I don’t fully understand here. Isn't the lack of physical presence similar to the Aspeed virtual hub driver?

.

Quoted 4 lines

I don't know Aspeed virtual hub driver. In any case, driver is irrelevant to the bindings.

Why setting maximum number of downstream ports or devices would be needed per-board? Do you save some resources that way?

That is correct. Each port/devices will have to allocate resources and create device descriptor entry. Currently, I set the number of downstream ports to be 4. Thus, I will have:

/sys/bus/platform/devices/80400800.vhub/80400800.vhub:p1   <=== for kvm keyboard/mouse
/sys/bus/platform/devices/80400800.vhub/80400800.vhub:p2   <=== for virtual CD/DVD/ISO image
/sys/bus/platform/devices/80400800.vhub/80400800.vhub:p3   <=== for virtual USB key
/sys/bus/platform/devices/80400800.vhub/80400800.vhub:p4   <=== for virtual NIC

Just like aspeed:
In g5 (aspeed-g5.dtsi), aspeed,vhub-downstream-ports = <5>; In g6 (aspeed-g6.dtsi), aspeed,vhub-downstream-ports = <7>;

Quoted 2 lines

Best regards,
Krzysztof

Thanks

Richard.

#8 lore raw

Re: [PATCH v1 1/3] dt-bindings: usb: Add HPE GXP UDCG Controller

Quoted 56 lines · Richard

Thank you, Mr. Kozlowski.

Quoted 29 lines
Quoted 18 lines

I am implementing this driver using the Aspeed virtual hub driver as example.

Just like the Aspeed virtual hub is in the Devicetree:

vhub: usb-vhub@1e6a0000 {
	compatible = "aspeed,ast2600-usb-vhub";
	reg = <0x1e6a0000 0x350>;
	interrupts = <GIC_SPI 5 IRQ_TYPE_LEVEL_HIGH>;
	clocks = <&syscon ASPEED_CLK_GATE_USBPORT1CLK>;
	aspeed,vhub-downstream-ports = <7>;
	aspeed,vhub-generic-endpoints = <21>;
	pinctrl-names = "default";
	pinctrl-0 = <&pinctrl_usb2ad_default>;
	status = "disabled";
};

In my case: (I am replacing "udcg" with "vhub" and remove the vehci reference).

Quoted 9 lines
 vhub: usb-vhub@80400800 {
	compatible = "hpe,gxp-vhub";
	reg = <0x80400800 0x0200>, <0x80401000 0x8000>;
	reg-names = "vhub", "udc";
	interrupts = <13>;
	interrupt-parent = <&vic1>;
	hpe,vhub-downstream-ports = <4>;
	hpe,vhub-generic-endpoints = <16>;
};
Quoted 1 line

The hub is not virtual, it is real. I understand that it is some software block or FPGA, but still I propose to skip any references to virtual.

I will remove any references to "virtual" in comment and documentation.

Quoted 14 lines
Quoted 14 lines
Quoted 13 lines
Quoted 13 lines
Quoted 7 lines

+ hpe,vehci-downstream-ports:
+ description: Number of downstream ports supported by the GXP

Why do you need this property in DT and what exactly does it represent? You have one device - EHCI controller - and on some boards it is further customized? Even though it is the same device?

That is correct. We can configure this VHUB Controller to have one to
8 virtual ports. This is similar to the aspeed virtual USB HUB "aspeed,vhub-downstream-ports" moving forward in the next patch we are going to use "hpe,vhub-downstream-ports"

Quoted 5 lines
Quoted 5 lines
Quoted 2 lines

Moving forward you need to address this lack of physical presence... Aren't these different devices and you just forgot to customize the compatible?

I don’t fully understand here. Isn't the lack of physical presence similar to the Aspeed virtual hub driver?

Quoted 7 lines

.

Quoted 4 lines

I don't know Aspeed virtual hub driver. In any case, driver is irrelevant to the bindings.

Why setting maximum number of downstream ports or devices would be needed per-board? Do you save some resources that way?

That is correct. Each port/devices will have to allocate resources and create device descriptor entry.

The answer to "why" is not "that is correct".

Quoted 6 lines

Currently, I set the number of downstream ports to be 4. Thus, I will have:

/sys/bus/platform/devices/80400800.vhub/80400800.vhub:p1   <=== for kvm keyboard/mouse
/sys/bus/platform/devices/80400800.vhub/80400800.vhub:p2   <=== for virtual CD/DVD/ISO image
/sys/bus/platform/devices/80400800.vhub/80400800.vhub:p3   <=== for virtual USB key
/sys/bus/platform/devices/80400800.vhub/80400800.vhub:p4   <=== for virtual NIC

So resources in Linux? That's not really relevant and important. I still do not see the need of this property.

Quoted 4 lines

Just like aspeed:
In g5 (aspeed-g5.dtsi), aspeed,vhub-downstream-ports = <5>; In g6 (aspeed-g6.dtsi), aspeed,vhub-downstream-ports = <7>;

I did not review that. Poor or incorrect example is not an argument. If they introduced obvious bugs or obvious non-DT properties, shall you do the same?

Best regards,
Krzysztof