From nobody Fri Jun 12 11:32:19 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6DCC444D685; Fri, 15 May 2026 11:08:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778843336; cv=none; b=ELYMfsasZ4xPxrKafUiJxWlbGZWUVLwtqGUG6Ir28Ueqkz6JZ6RVtlZHI3pDCUj9SML05ltcUee3FD/RGeLcmDU5/lfMZ1/A7PuGTX8m1YsLRT8kvNwzBTk8Oh+i/u/F6dAhHE9gxJZ0sjrWztUQxBQLRTWgFMXUMvIBnYS/4MU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778843336; c=relaxed/simple; bh=r0iKObg1kHEbK/CoY9Tc79Jo1GDSrvLTJNtqhQKmugY=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=h50vs4Gt2QaihiO9Tb1DYDOsHuJ69rjv9MP6GMz0ko0nosS0RAXlOk+16MMMa/KFPEDfZ54WIeIBm6NlbFr9ySBpjXP008HXE3HONwhgCC//l8Lb72e9jZwX3PaIeiWJoATP1HdRkVyN4omJ1MDo4PS4SOAk211A87EkG7jkefY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=scfxYMLU; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="scfxYMLU" Received: by smtp.kernel.org (Postfix) with ESMTPS id 18E1FC2BCB7; Fri, 15 May 2026 11:08:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1778843336; bh=r0iKObg1kHEbK/CoY9Tc79Jo1GDSrvLTJNtqhQKmugY=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=scfxYMLUZ+7KJHAsnGGT0ZFV1jBUyQcnQ3g6MYHvMBcNH7qwjeqByxvQG1ZglFjJH 4nzjo9akLGRA0rfu7q8GZQcoGeHdMicr0ys6DEdfrP+d9TxaCZapHZo7TWFb8JLrfM VZUpMkYWPiPr6HN5EQ+8AGHlfAcfNQnuDs/qw19x44eykveyZtYKfN+xGvT+lJBgZP SeDgijHbg0iflG2uxk9fQFUoN3lwaA0sCg64A+VbJoFXZhLawJNtozrSFU4f9AQY0j 4PdvjBme8m46lrVWMmo8c+k1rub/FvtVmZVnrZIdHJ/7pNCbc3PaIQMOArgirCkJ0u +PfaBqE934fXQ== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0A04FCD343F; Fri, 15 May 2026 11:08:56 +0000 (UTC) From: Pawel Laszczak via B4 Relay Date: Fri, 15 May 2026 13:24:38 +0200 Subject: [PATCH v8 1/2] dt-bindings: usb: cdns3: Add cdns,cdnsp-no-drd compatible string Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260515-b4-no_drd_config-v8-1-75cb05317679@cadence.com> References: <20260515-b4-no_drd_config-v8-0-75cb05317679@cadence.com> In-Reply-To: <20260515-b4-no_drd_config-v8-0-75cb05317679@cadence.com> To: Peter Chen , Roger Quadros , Greg Kroah-Hartman , Rob Herring , Krzysztof Kozlowski , Conor Dooley Cc: linux-usb@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Pawel Laszczak X-Mailer: b4 0.15.1 X-Developer-Signature: v=1; a=ed25519-sha256; t=1778844286; l=4748; i=pawell@cadence.com; h=from:subject:message-id; bh=9OjoKia9GP/4VD0yZsSfoVSr7ysfUvwbj1KOdwE6clY=; b=qttmCHxFnq4qkLQdhHjrB2G23Xp7tir4LGrvyp0zwBJIHZG/TYVBRAgn7ZY7DYWUzPQBxjg5z 50tPC07bKXCDAhQRM11HbMsNsIzLLH9MknfH77tXbpIC2O0lxV6eztJ X-Developer-Key: i=pawell@cadence.com; a=ed25519; pk=EUPBvLO9CDg7j6defeDl2iqi+z5Ivqu4Z46aiqe7dYc= X-Endpoint-Received: by B4 Relay for pawell@cadence.com/default with auth_id=707 X-Original-From: Pawel Laszczak Reply-To: pawell@cadence.com From: Pawel Laszczak Introduce a new compatible string 'cdns,cdnsp-no-drd' for Cadence USBSS/USBSSP controllers to support hardware configurations where the Dual-Role Device (DRD) register block is missing or inaccessible. This change follows the recommendation to imply hardware limitations directly from the compatible string rather than using a dedicated boolean property. When 'cdns,cdnsp-no-drd' is used: - The 'otg' register and interrupt resources are not required. - The 'reg' and 'interrupts' properties are restricted to 2 items (host and device). - 'dr_mode' must be explicitly set to either 'host' or 'peripheral'. The standard 'cdns,usb3' compatible remains unchanged, maintaining backward compatibility by requiring all 3 resource sets (otg, host, dev). Signed-off-by: Pawel Laszczak --- v8: - Update commit message to reflect schema changes. - Removed 'cdns,no-drd' boolean property as per Rob Herring's suggestion. - Introduced a new compatible string 'cdns,cdnsp-no-drd' for controller variants that lack the DRD/OTG register block. v7: - Rename 'no_drd' to 'cdns,no-drd'. - Update commit message to reflect property renaming and schema changes. - Simplify 'reg-names' using a single enum. - Revert 'interrupt-names' to a list of constants. - Move 'reg' item descriptions to if/else blocks for accuracy. - Clean up 'if/then' logic (remove redundant checks). - Add explicit 'items' list for 'interrupt-names' in the 'else' block. v6: - Fixed validation error for 'interrupt-names' by correcting the items definition. - Adjusted 'minItems'/'maxItems' to properly support the optional 'wakeup' interrupt. - Fixed 'too long' schema error in examples. v5: - Implemented strict conditional validation using if-then-else logic. - Enforced 2 register/interrupt items and required 'dr_mode' (host or peripheral) when 'no_drd' is present. - Enforced the standard 3 register/interrupt items (otg, host, dev) when 'no_drd' is absent to ensure backward compatibility. - Updated 'reg-names' and 'interrupt-names' to use enums in the main properties section to support flexible resource ordering during validation. --- --- .../devicetree/bindings/usb/cdns,usb3.yaml | 60 ++++++++++++++++++= ---- 1 file changed, 50 insertions(+), 10 deletions(-) diff --git a/Documentation/devicetree/bindings/usb/cdns,usb3.yaml b/Documen= tation/devicetree/bindings/usb/cdns,usb3.yaml index 2d95fb7321af..7b0aa9c4a2bd 100644 --- a/Documentation/devicetree/bindings/usb/cdns,usb3.yaml +++ b/Documentation/devicetree/bindings/usb/cdns,usb3.yaml @@ -17,22 +17,22 @@ description: =20 properties: compatible: - const: cdns,usb3 + enum: + - cdns,usb3 + - cdns,cdnsp-no-drd =20 reg: - items: - - description: OTG controller registers - - description: XHCI Host controller registers - - description: DEVICE controller registers + minItems: 2 + maxItems: 3 =20 reg-names: + minItems: 2 + maxItems: 3 items: - - const: otg - - const: xhci - - const: dev + enum: [ otg, xhci, dev ] =20 interrupts: - minItems: 3 + minItems: 2 items: - description: XHCI host controller interrupt - description: Device controller interrupt @@ -41,7 +41,7 @@ properties: cleared by xhci core, this interrupt is optional =20 interrupt-names: - minItems: 3 + minItems: 2 items: - const: host - const: peripheral @@ -93,6 +93,46 @@ allOf: - $ref: usb-drd.yaml# - $ref: usb-xhci.yaml# =20 + - if: + properties: + compatible: + const: cdns,cdnsp-no-drd + then: + properties: + reg: + items: + - description: XHCI Host controller registers + - description: DEVICE controller registers + reg-names: + items: + - const: xhci + - const: dev + interrupts: + maxItems: 2 + interrupt-names: + items: + - const: host + - const: peripheral + dr_mode: + enum: [host, peripheral] + else: + properties: + reg: + items: + - description: OTG controller registers + - description: XHCI Host controller registers + - description: DEVICE controller registers + reg-names: + items: + - const: otg + - const: xhci + - const: dev + interrupts: + minItems: 3 + maxItems: 4 + interrupt-names: + minItems: 3 + unevaluatedProperties: false =20 examples: --=20 2.43.0 From nobody Fri Jun 12 11:32:19 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5A72F3D1AA6; Fri, 15 May 2026 11:08:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778843336; cv=none; b=ojVwCarG84uFE1OXhXbtECs61gF4bxeGgOu0Cdx1RwlrIA1VYsABOQU9YqPvOMR6j7Wp3AoRFTcGVhD+3SL9PPy4yj0JQjzH1c3QLQio3fMqPS2rh9547AIssSo3IrUZS5edvGcyTp/tSbxNviB+p6yfDuXuFmkV0v4h8KX4tNg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778843336; c=relaxed/simple; bh=/163JRlDUQNu7P550ZUpi8LItIk1xBh1t7R/7iFETok=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=JPDpyYJNHCmnvQ2TOTR9tbfBwciC+DzPAegWAH/38ZvYbvTP0fDMejLGb5Rd1LKpMMagj0zDNPZ+an8k3sIvD3gr7vbtpGDb+IaRPnr+63NzjnFbKZO75Z9CDxD3QRdlQNs7cNHHyjCVq533oicPmwBk8mvPvw0HtoS6vbb5+bQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=VyZ5/prP; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="VyZ5/prP" Received: by smtp.kernel.org (Postfix) with ESMTPS id 2998FC2BCB8; Fri, 15 May 2026 11:08:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1778843336; bh=/163JRlDUQNu7P550ZUpi8LItIk1xBh1t7R/7iFETok=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=VyZ5/prP5w44SqK59ie9kC+Udxf4tZ03c3z8mvesqhLOr5DxbOwHX2qv8Yk+v6yre 5/c5U2RoA/ZGtVw1tlzO/XnvXXUxJ4cteKEl1wUB+Vxma8UOdBvwaM/HF/ba1VgvbM mid+niQVg61KevvCCTzo8FgSpn+fLBYrtXhqnINwvAsceCl0vTCIY3D7LTNmUZRnsL wazc1TlUTIrMsf61qJoxSl5kfOXEpTydPi3UOFdDDtXZuy32T6nfWBS3YdNJ9S/KO0 WdxvPBfVtytGLyUPbQsOf1xrgVF9XwIXyBAPimunzGSAohqULcqpwWXNwWZixnvilY v5G11f8EpEcNA== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1CE37CD4F3D; Fri, 15 May 2026 11:08:56 +0000 (UTC) From: Pawel Laszczak via B4 Relay Date: Fri, 15 May 2026 13:24:39 +0200 Subject: [PATCH v8 2/2] usb: cdnsp: Add support for device-only configuration Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260515-b4-no_drd_config-v8-2-75cb05317679@cadence.com> References: <20260515-b4-no_drd_config-v8-0-75cb05317679@cadence.com> In-Reply-To: <20260515-b4-no_drd_config-v8-0-75cb05317679@cadence.com> To: Peter Chen , Roger Quadros , Greg Kroah-Hartman , Rob Herring , Krzysztof Kozlowski , Conor Dooley Cc: linux-usb@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Pawel Laszczak , Bjorn Helgaas , kernel test robot X-Mailer: b4 0.15.1 X-Developer-Signature: v=1; a=ed25519-sha256; t=1778844286; l=13694; i=pawell@cadence.com; h=from:subject:message-id; bh=Gzu9SgEXlUMKHCY5Kq/x02JpU0OHGqAEWUR9QGLTu0k=; b=XJg2ntLTZ1Q78e6NAv7YNhp16tFa3wciFWDmfv4rTcn1oRAmP83B9MZV7TYjPDUI8aYWXrwdT Z9WQ+QK78neDQ6jc3XciIsCAPHJJPeWVFFhNGYjZk91yTHiQRheLxW5 X-Developer-Key: i=pawell@cadence.com; a=ed25519; pk=EUPBvLO9CDg7j6defeDl2iqi+z5Ivqu4Z46aiqe7dYc= X-Endpoint-Received: by B4 Relay for pawell@cadence.com/default with auth_id=707 X-Original-From: Pawel Laszczak Reply-To: pawell@cadence.com From: Pawel Laszczak This patch introduces support for the Cadence USBSSP (cdnsp) controller in hardware configurations where the Dual-Role Device (DRD) register block is not implemented or is inaccessible. In such cases, the driver cannot rely on the DRD logic to manage roles and must operate exclusively in a fixed peripheral/host mode. The change in BAR indexing (from BAR 2 to BAR 1) is a direct consequence of the 32-bit addressing used in this specific DRD-disabled hardware layout, compared to the 64-bit addressing used in DRD-enabled configurations. Tested on a PCI platform with a hardware configuration that lacks DRD support. Platform-side changes are included to support the PCI glue layer's property injection to handle this specific layout. Acked-by: Peter Chen Acked-by: Bjorn Helgaas Signed-off-by: Pawel Laszczak Reported-by: kernel test robot Closes: https://lore.kernel.org/oe-kbuild-all/202605141023.18vWXyw3-lkp@int= el.com/ --- v8: - Use 'cdns,cdnsp-no-drd' compatible string to trigger no-DRD logic. - Update PCI glue layer to inject the new compatible string. v7: - Use 'cdns,no-drd' instead of 'no_drd' to match updated bindings. - Fix "uninitialized variable" warning in cdns_drd_host_on() by initializing 'ret' to 0. --- drivers/usb/cdns3/cdns3-plat.c | 30 ++++++++++++++++---------- drivers/usb/cdns3/cdnsp-pci.c | 48 ++++++++++++++++++++++++++++++++++----= ---- drivers/usb/cdns3/core.c | 3 ++- drivers/usb/cdns3/core.h | 4 ++++ drivers/usb/cdns3/drd.c | 45 ++++++++++++++++++++++++++++++++++++--- 5 files changed, 106 insertions(+), 24 deletions(-) diff --git a/drivers/usb/cdns3/cdns3-plat.c b/drivers/usb/cdns3/cdns3-plat.c index 3fe3109a3688..303f7c1431dc 100644 --- a/drivers/usb/cdns3/cdns3-plat.c +++ b/drivers/usb/cdns3/cdns3-plat.c @@ -81,6 +81,12 @@ static int cdns3_plat_probe(struct platform_device *pdev) if (cdns->pdata && cdns->pdata->override_apb_timeout) cdns->override_apb_timeout =3D cdns->pdata->override_apb_timeout; =20 + if (device_is_compatible(dev, "cdns,cdnsp-no-drd")) { + cdns->no_drd =3D true; + cdns->version =3D CDNSP_CONTROLLER_V2; + dev_dbg(dev, "No DRD support\n"); + } + platform_set_drvdata(pdev, cdns); =20 ret =3D platform_get_irq_byname(pdev, "host"); @@ -113,21 +119,22 @@ static int cdns3_plat_probe(struct platform_device *p= dev) =20 cdns->dev_regs =3D regs; =20 - cdns->otg_irq =3D platform_get_irq_byname(pdev, "otg"); - if (cdns->otg_irq < 0) - return dev_err_probe(dev, cdns->otg_irq, - "Failed to get otg IRQ\n"); - - res =3D platform_get_resource_byname(pdev, IORESOURCE_MEM, "otg"); - if (!res) { - dev_err(dev, "couldn't get otg resource\n"); - return -ENXIO; + if (!cdns->no_drd) { + cdns->otg_irq =3D platform_get_irq_byname(pdev, "otg"); + if (cdns->otg_irq < 0) + return dev_err_probe(dev, cdns->otg_irq, + "Failed to get otg IRQ\n"); + + res =3D platform_get_resource_byname(pdev, IORESOURCE_MEM, "otg"); + if (!res) { + dev_err(dev, "couldn't get otg resource\n"); + return -ENXIO; + } + cdns->otg_res =3D *res; } =20 cdns->phyrst_a_enable =3D device_property_read_bool(dev, "cdns,phyrst-a-e= nable"); =20 - cdns->otg_res =3D *res; - cdns->wakeup_irq =3D platform_get_irq_byname_optional(pdev, "wakeup"); if (cdns->wakeup_irq =3D=3D -EPROBE_DEFER) return cdns->wakeup_irq; @@ -338,6 +345,7 @@ static const struct dev_pm_ops cdns3_pm_ops =3D { #ifdef CONFIG_OF static const struct of_device_id of_cdns3_match[] =3D { { .compatible =3D "cdns,usb3" }, + { .compatible =3D "cdns,cdnsp-no-drd" }, { }, }; MODULE_DEVICE_TABLE(of, of_cdns3_match); diff --git a/drivers/usb/cdns3/cdnsp-pci.c b/drivers/usb/cdns3/cdnsp-pci.c index 432007cfe695..1a71dee5044c 100644 --- a/drivers/usb/cdns3/cdnsp-pci.c +++ b/drivers/usb/cdns3/cdnsp-pci.c @@ -19,6 +19,7 @@ =20 struct cdnsp_wrap { struct platform_device *plat_dev; + struct property_entry prop[3]; struct resource dev_res[6]; int devfn; }; @@ -29,10 +30,15 @@ struct cdnsp_wrap { #define RES_HOST_ID 3 #define RES_DEV_ID 4 #define RES_DRD_ID 5 - +/* DRD PCI configuration - 64-bit addressing */ +/* First PCI function */ #define PCI_BAR_HOST 0 -#define PCI_BAR_OTG 0 #define PCI_BAR_DEV 2 +/* Second PCI function */ +#define PCI_BAR_OTG 0 +/* Device only PCI configuration - 32-bit addressing */ +/* First PCI function */ +#define PCI_BAR_ONLY_DEV 1 =20 #define PCI_DEV_FN_HOST_DEVICE 0 #define PCI_DEV_FN_OTG 1 @@ -40,6 +46,7 @@ struct cdnsp_wrap { #define PCI_DRIVER_NAME "cdns-pci-usbssp" #define PLAT_DRIVER_NAME "cdns-usb3" =20 +#define PCI_DEVICE_ID_CDNS_UDC_USBSSP 0x0400 #define CHICKEN_APB_TIMEOUT_VALUE 0x1C20 =20 static struct pci_dev *cdnsp_get_second_fun(struct pci_dev *pdev) @@ -65,6 +72,7 @@ static int cdnsp_pci_probe(struct pci_dev *pdev, struct cdnsp_wrap *wrap; struct resource *res; struct pci_dev *func; + bool no_drd =3D false; int ret =3D 0; =20 /* @@ -75,11 +83,14 @@ static int cdnsp_pci_probe(struct pci_dev *pdev, pdev->devfn !=3D PCI_DEV_FN_OTG)) return -EINVAL; =20 + if (pdev->device =3D=3D PCI_DEVICE_ID_CDNS_UDC_USBSSP) + no_drd =3D true; + func =3D cdnsp_get_second_fun(pdev); - if (!func) + if (!func && !no_drd) return -EINVAL; =20 - if (func->class =3D=3D PCI_CLASS_SERIAL_USB_XHCI || + if ((func && func->class =3D=3D PCI_CLASS_SERIAL_USB_XHCI) || pdev->class =3D=3D PCI_CLASS_SERIAL_USB_XHCI) { ret =3D -EINVAL; goto put_pci; @@ -93,7 +104,7 @@ static int cdnsp_pci_probe(struct pci_dev *pdev, =20 pci_set_master(pdev); =20 - if (pci_is_enabled(func)) { + if (func && pci_is_enabled(func)) { wrap =3D pci_get_drvdata(func); } else { wrap =3D kzalloc_obj(*wrap); @@ -106,10 +117,12 @@ static int cdnsp_pci_probe(struct pci_dev *pdev, res =3D wrap->dev_res; =20 if (pdev->devfn =3D=3D PCI_DEV_FN_HOST_DEVICE) { + int bar_dev =3D no_drd ? PCI_BAR_ONLY_DEV : PCI_BAR_DEV; + /* Function 0: host(BAR_0) + device(BAR_2). */ dev_dbg(&pdev->dev, "Initialize Device resources\n"); - res[RES_DEV_ID].start =3D pci_resource_start(pdev, PCI_BAR_DEV); - res[RES_DEV_ID].end =3D pci_resource_end(pdev, PCI_BAR_DEV); + res[RES_DEV_ID].start =3D pci_resource_start(pdev, bar_dev); + res[RES_DEV_ID].end =3D pci_resource_end(pdev, bar_dev); res[RES_DEV_ID].name =3D "dev"; res[RES_DEV_ID].flags =3D IORESOURCE_MEM; dev_dbg(&pdev->dev, "USBSSP-DEV physical base addr: %pa\n", @@ -145,9 +158,21 @@ static int cdnsp_pci_probe(struct pci_dev *pdev, wrap->dev_res[RES_IRQ_OTG_ID].flags =3D IORESOURCE_IRQ; } =20 - if (pci_is_enabled(func)) { + if (no_drd || pci_is_enabled(func)) { + u8 idx =3D 0; + /* set up platform device info */ pdata.override_apb_timeout =3D CHICKEN_APB_TIMEOUT_VALUE; + + if (no_drd) { + wrap->prop[idx++] =3D PROPERTY_ENTRY_STRING("compatible", + "cdns,cdnsp-no-drd"); + wrap->prop[idx++] =3D PROPERTY_ENTRY_STRING("dr_mode", "peripheral"); + } else { + wrap->prop[idx++] =3D PROPERTY_ENTRY_STRING("dr_mode", "otg"); + wrap->prop[idx++] =3D PROPERTY_ENTRY_BOOL("usb-role-switch"); + } + memset(&plat_info, 0, sizeof(plat_info)); plat_info.parent =3D &pdev->dev; plat_info.fwnode =3D pdev->dev.fwnode; @@ -158,6 +183,7 @@ static int cdnsp_pci_probe(struct pci_dev *pdev, plat_info.dma_mask =3D pdev->dma_mask; plat_info.data =3D &pdata; plat_info.size_data =3D sizeof(pdata); + plat_info.properties =3D wrap->prop; wrap->devfn =3D pdev->devfn; /* register platform device */ wrap->plat_dev =3D platform_device_register_full(&plat_info); @@ -185,13 +211,17 @@ static void cdnsp_pci_remove(struct pci_dev *pdev) if (wrap->devfn =3D=3D pdev->devfn) platform_device_unregister(wrap->plat_dev); =20 - if (!pci_is_enabled(func)) + if (!func || !pci_is_enabled(func)) kfree(wrap); =20 pci_dev_put(func); } =20 static const struct pci_device_id cdnsp_pci_ids[] =3D { + { PCI_DEVICE(PCI_VENDOR_ID_CDNS, PCI_DEVICE_ID_CDNS_UDC_USBSSP), + .class =3D PCI_CLASS_SERIAL_USB_DEVICE }, + { PCI_DEVICE(PCI_VENDOR_ID_CDNS, PCI_DEVICE_ID_CDNS_UDC_USBSSP), + .class =3D PCI_CLASS_SERIAL_USB_CDNS }, { PCI_DEVICE(PCI_VENDOR_ID_CDNS, PCI_DEVICE_ID_CDNS_USBSSP), .class =3D PCI_CLASS_SERIAL_USB_DEVICE }, { PCI_DEVICE(PCI_VENDOR_ID_CDNS, PCI_DEVICE_ID_CDNS_USBSSP), diff --git a/drivers/usb/cdns3/core.c b/drivers/usb/cdns3/core.c index 6a8d1fefbc0d..504bdf13ea80 100644 --- a/drivers/usb/cdns3/core.c +++ b/drivers/usb/cdns3/core.c @@ -70,7 +70,8 @@ static void cdns_role_stop(struct cdns *cdns) static void cdns_exit_roles(struct cdns *cdns) { cdns_role_stop(cdns); - cdns_drd_exit(cdns); + if (!cdns->no_drd) + cdns_drd_exit(cdns); } =20 /** diff --git a/drivers/usb/cdns3/core.h b/drivers/usb/cdns3/core.h index bca973b999a4..8c492fda924c 100644 --- a/drivers/usb/cdns3/core.h +++ b/drivers/usb/cdns3/core.h @@ -84,6 +84,9 @@ struct cdns3_platform_data { * value in CHICKEN_BITS_3 will be preserved. * @gadget_init: pointer to gadget initialization function * @host_init: pointer to host initialization function + * @no_drd: DRD register block is inaccessible. The controller is hardwire= d to + * single role (host or device) or the logic for role switching is + * missing. */ struct cdns { struct device *dev; @@ -124,6 +127,7 @@ struct cdns { u32 override_apb_timeout; int (*gadget_init)(struct cdns *cdns); int (*host_init)(struct cdns *cdns); + bool no_drd; }; =20 int cdns_hw_role_switch(struct cdns *cdns); diff --git a/drivers/usb/cdns3/drd.c b/drivers/usb/cdns3/drd.c index 84fb38a5723a..d2bb682e4552 100644 --- a/drivers/usb/cdns3/drd.c +++ b/drivers/usb/cdns3/drd.c @@ -87,6 +87,9 @@ int cdns_get_id(struct cdns *cdns) { int id; =20 + if (cdns->no_drd) + return 0; + id =3D readl(&cdns->otg_regs->sts) & OTGSTS_ID_VALUE; dev_dbg(cdns->dev, "OTG ID: %d", id); =20 @@ -107,7 +110,7 @@ void cdns_clear_vbus(struct cdns *cdns) { u32 reg; =20 - if (cdns->version !=3D CDNSP_CONTROLLER_V2) + if (cdns->version !=3D CDNSP_CONTROLLER_V2 || cdns->no_drd) return; =20 reg =3D readl(&cdns->otg_cdnsp_regs->override); @@ -120,7 +123,7 @@ void cdns_set_vbus(struct cdns *cdns) { u32 reg; =20 - if (cdns->version !=3D CDNSP_CONTROLLER_V2) + if (cdns->version !=3D CDNSP_CONTROLLER_V2 || cdns->no_drd) return; =20 reg =3D readl(&cdns->otg_cdnsp_regs->override); @@ -179,7 +182,10 @@ static void cdns_otg_enable_irq(struct cdns *cdns) int cdns_drd_host_on(struct cdns *cdns) { u32 val, ready_bit; - int ret; + int ret =3D 0; + + if (cdns->no_drd) + goto phy_set; =20 /* Enable host mode. */ writel(OTGCMD_HOST_BUS_REQ | OTGCMD_OTG_DIS, @@ -197,6 +203,7 @@ int cdns_drd_host_on(struct cdns *cdns) if (ret) dev_err(cdns->dev, "timeout waiting for xhci_ready\n"); =20 +phy_set: phy_set_mode(cdns->usb2_phy, PHY_MODE_USB_HOST); phy_set_mode(cdns->usb3_phy, PHY_MODE_USB_HOST); return ret; @@ -210,6 +217,9 @@ void cdns_drd_host_off(struct cdns *cdns) { u32 val; =20 + if (cdns->no_drd) + goto phy_set; + writel(OTGCMD_HOST_BUS_DROP | OTGCMD_DEV_BUS_DROP | OTGCMD_DEV_POWER_OFF | OTGCMD_HOST_POWER_OFF, &cdns->otg_regs->cmd); @@ -218,6 +228,8 @@ void cdns_drd_host_off(struct cdns *cdns) readl_poll_timeout_atomic(&cdns->otg_regs->state, val, !(val & OTGSTATE_HOST_STATE_MASK), 1, 2000000); + +phy_set: phy_set_mode(cdns->usb2_phy, PHY_MODE_INVALID); phy_set_mode(cdns->usb3_phy, PHY_MODE_INVALID); } @@ -234,6 +246,9 @@ int cdns_drd_gadget_on(struct cdns *cdns) u32 ready_bit; int ret, val; =20 + if (cdns->no_drd) + goto phy_set; + /* switch OTG core */ writel(OTGCMD_DEV_BUS_REQ | reg, &cdns->otg_regs->cmd); =20 @@ -251,6 +266,7 @@ int cdns_drd_gadget_on(struct cdns *cdns) return ret; } =20 +phy_set: phy_set_mode(cdns->usb2_phy, PHY_MODE_USB_DEVICE); phy_set_mode(cdns->usb3_phy, PHY_MODE_USB_DEVICE); return 0; @@ -265,6 +281,9 @@ void cdns_drd_gadget_off(struct cdns *cdns) { u32 val; =20 + if (cdns->no_drd) + goto phy_set; + /* * Driver should wait at least 10us after disabling Device * before turning-off Device (DEV_BUS_DROP). @@ -277,6 +296,8 @@ void cdns_drd_gadget_off(struct cdns *cdns) readl_poll_timeout_atomic(&cdns->otg_regs->state, val, !(val & OTGSTATE_DEV_STATE_MASK), 1, 2000000); + +phy_set: phy_set_mode(cdns->usb2_phy, PHY_MODE_INVALID); phy_set_mode(cdns->usb3_phy, PHY_MODE_INVALID); } @@ -392,6 +413,18 @@ int cdns_drd_init(struct cdns *cdns) u32 state, reg; int ret; =20 + if (cdns->no_drd) { + cdns->dr_mode =3D usb_get_dr_mode(cdns->dev); + + if (cdns->dr_mode !=3D USB_DR_MODE_HOST && + cdns->dr_mode !=3D USB_DR_MODE_PERIPHERAL) { + dev_err(cdns->dev, "Incorrect dr_mode\n"); + return -EINVAL; + } + + return 0; + } + regs =3D devm_ioremap_resource(cdns->dev, &cdns->otg_res); if (IS_ERR(regs)) return PTR_ERR(regs); @@ -492,6 +525,9 @@ int cdns_drd_init(struct cdns *cdns) =20 int cdns_drd_exit(struct cdns *cdns) { + if (cdns->no_drd) + return 0; + cdns_otg_disable_irq(cdns); =20 return 0; @@ -500,6 +536,9 @@ int cdns_drd_exit(struct cdns *cdns) /* Indicate the cdns3 core was power lost before */ bool cdns_power_is_lost(struct cdns *cdns) { + if (cdns->no_drd) + return false; + if (cdns->version =3D=3D CDNS3_CONTROLLER_V0) { if (!(readl(&cdns->otg_v0_regs->simulate) & BIT(0))) return true; --=20 2.43.0