get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

GET /api/patches/2196211/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 2196211,
    "url": "http://patchwork.ozlabs.org/api/patches/2196211/?format=api",
    "web_url": "http://patchwork.ozlabs.org/project/uboot/patch/20260213051556.1247716-1-s-vadapalli@ti.com/",
    "project": {
        "id": 18,
        "url": "http://patchwork.ozlabs.org/api/projects/18/?format=api",
        "name": "U-Boot",
        "link_name": "uboot",
        "list_id": "u-boot.lists.denx.de",
        "list_email": "u-boot@lists.denx.de",
        "web_url": null,
        "scm_url": null,
        "webscm_url": null,
        "list_archive_url": "",
        "list_archive_url_format": "",
        "commit_url_format": ""
    },
    "msgid": "<20260213051556.1247716-1-s-vadapalli@ti.com>",
    "list_archive_url": null,
    "date": "2026-02-13T05:15:55",
    "name": "[v2] usb: cdns3: use VBUS Valid to determine role for dr_mode OTG",
    "commit_ref": null,
    "pull_url": null,
    "state": "changes-requested",
    "archived": false,
    "hash": "5882deee3d2a0225c161cddfa7d3ef77d5be361e",
    "submitter": {
        "id": 84157,
        "url": "http://patchwork.ozlabs.org/api/people/84157/?format=api",
        "name": "Siddharth Vadapalli",
        "email": "s-vadapalli@ti.com"
    },
    "delegate": {
        "id": 1699,
        "url": "http://patchwork.ozlabs.org/api/users/1699/?format=api",
        "username": "marex",
        "first_name": "Marek",
        "last_name": "Vasut",
        "email": "marek.vasut@gmail.com"
    },
    "mbox": "http://patchwork.ozlabs.org/project/uboot/patch/20260213051556.1247716-1-s-vadapalli@ti.com/mbox/",
    "series": [
        {
            "id": 492057,
            "url": "http://patchwork.ozlabs.org/api/series/492057/?format=api",
            "web_url": "http://patchwork.ozlabs.org/project/uboot/list/?series=492057",
            "date": "2026-02-13T05:15:55",
            "name": "[v2] usb: cdns3: use VBUS Valid to determine role for dr_mode OTG",
            "version": 2,
            "mbox": "http://patchwork.ozlabs.org/series/492057/mbox/"
        }
    ],
    "comments": "http://patchwork.ozlabs.org/api/patches/2196211/comments/",
    "check": "pending",
    "checks": "http://patchwork.ozlabs.org/api/patches/2196211/checks/",
    "tags": {},
    "related": [],
    "headers": {
        "Return-Path": "<u-boot-bounces@lists.denx.de>",
        "X-Original-To": "incoming@patchwork.ozlabs.org",
        "Delivered-To": "patchwork-incoming@legolas.ozlabs.org",
        "Authentication-Results": [
            "legolas.ozlabs.org;\n\tdkim=pass (1024-bit key;\n unprotected) header.d=ti.com header.i=@ti.com header.a=rsa-sha256\n header.s=selector1 header.b=uhaAcBpw;\n\tdkim-atps=neutral",
            "legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de\n (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de;\n envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org)",
            "phobos.denx.de;\n dmarc=pass (p=quarantine dis=none) header.from=ti.com",
            "phobos.denx.de;\n spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de",
            "phobos.denx.de;\n\tdkim=pass (1024-bit key;\n unprotected) header.d=ti.com header.i=@ti.com header.b=\"uhaAcBpw\";\n\tdkim-atps=neutral",
            "phobos.denx.de;\n dmarc=pass (p=quarantine dis=none) header.from=ti.com",
            "phobos.denx.de;\n spf=pass smtp.mailfrom=s-vadapalli@ti.com"
        ],
        "Received": [
            "from phobos.denx.de (phobos.denx.de\n [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519 server-signature ECDSA (secp384r1) server-digest SHA384)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4fC0j04Jpkz1xvQ\n\tfor <incoming@patchwork.ozlabs.org>; Fri, 13 Feb 2026 16:14:44 +1100 (AEDT)",
            "from h2850616.stratoserver.net (localhost [IPv6:::1])\n\tby phobos.denx.de (Postfix) with ESMTP id 72F9983015;\n\tFri, 13 Feb 2026 06:14:41 +0100 (CET)",
            "by phobos.denx.de (Postfix, from userid 109)\n id CC86483936; Fri, 13 Feb 2026 06:14:39 +0100 (CET)",
            "from DM5PR21CU001.outbound.protection.outlook.com\n (mail-centralusazlp170110009.outbound.protection.outlook.com\n [IPv6:2a01:111:f403:c111::9])\n (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits))\n (No client certificate requested)\n by phobos.denx.de (Postfix) with ESMTPS id 2E52180FA1\n for <u-boot@lists.denx.de>; Fri, 13 Feb 2026 06:14:37 +0100 (CET)",
            "from MN0P220CA0012.NAMP220.PROD.OUTLOOK.COM (2603:10b6:208:52e::35)\n by LV3PR10MB8034.namprd10.prod.outlook.com (2603:10b6:408:28e::19)\n with Microsoft SMTP Server (version=TLS1_2,\n cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9611.13; Fri, 13 Feb\n 2026 05:14:33 +0000",
            "from BN2PEPF000055DD.namprd21.prod.outlook.com\n (2603:10b6:208:52e:cafe::cc) by MN0P220CA0012.outlook.office365.com\n (2603:10b6:208:52e::35) with Microsoft SMTP Server (version=TLS1_3,\n cipher=TLS_AES_256_GCM_SHA384) id 15.20.9611.12 via Frontend Transport; Fri,\n 13 Feb 2026 05:14:29 +0000",
            "from lewvzet200.ext.ti.com (198.47.23.194) by\n BN2PEPF000055DD.mail.protection.outlook.com (10.167.245.7) with Microsoft\n SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id\n 15.20.9632.0 via Frontend Transport; Fri, 13 Feb 2026 05:14:32 +0000",
            "from DLEE205.ent.ti.com (157.170.170.85) by lewvzet200.ext.ti.com\n (10.4.14.103) with Microsoft SMTP Server (version=TLS1_2,\n cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.20; Thu, 12 Feb\n 2026 23:14:32 -0600",
            "from DLEE206.ent.ti.com (157.170.170.90) by DLEE205.ent.ti.com\n (157.170.170.85) with Microsoft SMTP Server (version=TLS1_2,\n cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.20; Thu, 12 Feb\n 2026 23:14:32 -0600",
            "from lelvem-mr05.itg.ti.com (10.180.75.9) by DLEE206.ent.ti.com\n (157.170.170.90) with Microsoft SMTP Server (version=TLS1_2,\n cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.20 via Frontend\n Transport; Thu, 12 Feb 2026 23:14:32 -0600",
            "from toolbox.dhcp.ti.com (uda0492258.dhcp.ti.com [10.24.73.74])\n by lelvem-mr05.itg.ti.com (8.18.1/8.18.1) with ESMTP id 61D5ETKC587663;\n Thu, 12 Feb 2026 23:14:30 -0600"
        ],
        "X-Spam-Checker-Version": "SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de",
        "X-Spam-Level": "",
        "X-Spam-Status": "No, score=-1.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,\n DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FORGED_SPF_HELO,\n RCVD_IN_DNSWL_BLOCKED,SPF_HELO_PASS,T_SPF_PERMERROR autolearn=no\n autolearn_force=no version=3.4.2",
        "ARC-Seal": "i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none;\n b=QPq5ERFZcghn4XaFo2mde7jlHJD1kol8mcMVnttz+CDZPjoVTiKUy3USxWl9JIWzP0s3FrmlwOHq2Fshu9kLDF7oLd1+nT6ESe2ZXMmWRFtjrDFmUuZLHASZxQPLQvjNH90GTNkt2DPvW4yclIz2wpD32qD0rRGZGktOWkxbEUeaR46mFl2DWzMvJ2Ld9P6V4nPeXxbmMfQ+7RUpbqnQqLAHLyW21qfPcjivvrnwNbExnLkMjnHC6M0oBRDG6uBDFSnwGis3anUN5eav4P0worl6KRfsdrmHthueKbP+ASc4HwNvWk0oVoKzPCdsA1Yf87znDf9imXqbV0R0vsc3UA==",
        "ARC-Message-Signature": "i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com;\n s=arcselector10001;\n h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1;\n bh=R5q6P7/PhEtvNTjTr0sVDgSD9aAgmZ8kiPOKsrCSLGs=;\n b=yGlZXdaizv/Vtvmy3DlLVFEtpmgTWqa2QLIaqCsMa1dp8U5rpPsARxylaUYiwASi0hbtjIPTqD6Rwdl+0BJjCr2Q+mKyX0g5zxvrN7khdvjB4t0btsVgSCVEpAuUCooFhsdrUPYiPBZiQmgZXwya5wf1rzQ56XrLVfy+hQO/ZwDqFO3Vg9El3ZEkOQ7qQNQ0Px/VYr4Bg98Fy9sbAhd3pES9oElzkOUPphyxEYm5l7FUJoKHh//PcOmnLc5eOa4SOix+PZLHI/CBWnHIpuA2E3WerPoqRI+t5itD1j0GHKUr3/ceYkdVlToWZ7So9UGsqGPetpn5vRf9Od/BlNAIlg==",
        "ARC-Authentication-Results": "i=1; mx.microsoft.com 1; spf=pass (sender ip is\n 198.47.23.194) smtp.rcpttodomain=lists.denx.de smtp.mailfrom=ti.com;\n dmarc=pass (p=quarantine sp=none pct=100) action=none header.from=ti.com;\n dkim=none (message not signed); arc=none (0)",
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=selector1;\n h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck;\n bh=R5q6P7/PhEtvNTjTr0sVDgSD9aAgmZ8kiPOKsrCSLGs=;\n b=uhaAcBpwVcGOUaEpHHr6FWY6F9Y8EZfDL69fM1kUV42dUJ77Y8CGTVhcIhlptGPQd7LigAchoJBOEiKtxSMFrNHKtQBe91WZVxs4R8JfzIvEOp+J/xC8Yq1icQ/eLHhANedFU36xmh10YVgpJGLGew9gwCcP7MeiZHNZ5XHZviE=",
        "X-MS-Exchange-Authentication-Results": "spf=pass (sender IP is 198.47.23.194)\n smtp.mailfrom=ti.com; dkim=none (message not signed) header.d=none;\n dmarc=pass\n action=none header.from=ti.com;",
        "Received-SPF": "Pass (protection.outlook.com: domain of ti.com designates\n 198.47.23.194 as permitted sender) receiver=protection.outlook.com;\n client-ip=198.47.23.194; helo=lewvzet200.ext.ti.com; pr=C",
        "From": "Siddharth Vadapalli <s-vadapalli@ti.com>",
        "To": "<marex@denx.de>, <trini@konsulko.com>, <minda.chen@starfivetech.com>",
        "CC": "<marek.vasut@mailbox.org>, <u-boot@lists.denx.de>, <srk@ti.com>,\n <s-vadapalli@ti.com>",
        "Subject": "[PATCH v2] usb: cdns3: use VBUS Valid to determine role for dr_mode\n OTG",
        "Date": "Fri, 13 Feb 2026 10:45:55 +0530",
        "Message-ID": "<20260213051556.1247716-1-s-vadapalli@ti.com>",
        "X-Mailer": "git-send-email 2.51.1",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Content-Type": "text/plain",
        "X-C2ProcessedOrg": "333ef613-75bf-4e12-a4b1-8e3623f5dcea",
        "X-EOPAttributedMessage": "0",
        "X-MS-PublicTrafficType": "Email",
        "X-MS-TrafficTypeDiagnostic": "BN2PEPF000055DD:EE_|LV3PR10MB8034:EE_",
        "X-MS-Office365-Filtering-Correlation-Id": "9bd28665-3dd8-464f-da50-08de6abec5f2",
        "X-MS-Exchange-SenderADCheck": "1",
        "X-MS-Exchange-AntiSpam-Relay": "0",
        "X-Microsoft-Antispam": "BCL:0;\n ARA:13230040|82310400026|1800799024|36860700013|376014;",
        "X-Microsoft-Antispam-Message-Info": "\n Qk3+W9UHIGwDEJuIU2sviUEziVZrOS3wF10q1FlNFnA2O192i9I4Nt2cwFZ1Pmct7lQDflw2vBrM5/qxDzj6wyMpTN46XzGCam0OG0DR9gjx6tlhmPHuvr0xuGEw/9YYzBYpujBCh4t/+aI3cqzyCbDTYwDQHu8PxO9KGPZTwoYdtaRo/NAlwsnLv7AC0ZlDh9Gw3rpHyJsmHMdr8Ts/RBvbu/xgL1gX0nkbbxO5cSoFFz5klyAFCTkhfKAB2LdKwQctMjKr+M5R3bimBPnzicDUJh4nuVCpsjhNYOfqGOvxJQyicnpwD3482PBmKsXQH2yBbza1MBEE5NXLwLFa52jpQ0cP5fieNpQ06GcxA+E74ofAlPDhJZeO720uf1JhCzB4j+qnV1K7gZqPl8aWmK3qANNXXHAgtA5DJ72gN7Gu5ok5dyin640QdUYGwCsgZ4vQQbY+wfDLvCQefpDWjSCrVN2VrtRbb2FsVfT4pq4+zyQaL0fd9Jkb+gMXoWYy4KD26Vw8CaaSi76EbAw+plJbBXoIoHXtbIGqAgKRCHg/MnyrEoFjM2tJOuCBEqGYUYqhdsQX4xEO29Y7mYE465Wl+dmEUx6FW3Q2w0C9HGXni76EfP9Vz/SoseN20FMavsqAObN/D1Ty8eCDPO4bHtIfrE1IvT1bkkxK+laC5oPKohlcIKc/XPqvbPIckYvIgXICSaK/If/m5o5dqd7IFKyMztnrMnamh877qMxpqv/cGkPlSAGh2VsM4U/EaQYygWFbzoSpPVHafKwm8/Q6CmL4L/hiTCW5kaCMy93IFtfigYjOmG++yIqlSwVp2NmeDFunDGLYxZas5pw0EcNWT/nzv3LWwIlQo8+5EOq/JIEFVWKhyli6jE8ogaItcHTpj6S/yvtIU0DfXR6rGcyefBkeZmvk9j5VxHodoys8PWkHC72mm4udx/2cG5xnJIfhROhr4GWkP3NLV3x5pHPTgEPwxwQxL+FXiOEMIbzVwZVNaSm0KHbqWefKjfZ1zpgAshPMRnS1KnWN807P4C/Kf9aRmSs90ITFXosQUjXHwcCp93hQmiJYnq7FU1WYJC1tKtYc72V00FVv2zgGGTwP36Cq6IbZMeADpFSNySNwF5+vw7MJiTmdoFPF4XdT6WwrpwF6ZfV1HqaPINIR986lk2A305USoK+lmUvKl2iWFRQeQi78KFWjJdJgpVYz1NiaDPHh2qGC2fpzj80+6HWDm+KRYVQ7mhgBm5/NXDvWoYq0G1sF3yOBE/9X9Ow1VJPuOvUHZLHawvUQBVA5oPGryk18bpsu+ly88bDUPE6UvF0/v5O4zRhC+eRITzLIyQkeL8aWHFbLkXj2jTNcXu9zSqEJiO501I8oWEwKuikQYXRpDs7T9OGCxfdbsnbF2I4uUn/Fd1Z/XNMtLET4ssPJiaz2o4FDQ+tQSoMD7iuiMtcN3NCVB94rTCpvm9cDVDeObDKX/UvD3ITjTFh+gNOq96H/39MFeAH3LAtcoR9ECCCpWH1ZWO5GojtX6ES1HsETFyQgm/qSn0SR57e3857A2gcoMdMfb7k8qiZdPUKWiM67R+pqfwUyYmfpwdmY5/1v3Mw4lQRTUutNnsJNt4a7sQ==",
        "X-Forefront-Antispam-Report": "CIP:198.47.23.194; CTRY:US; LANG:en; SCL:1; SRV:;\n IPV:NLI; SFV:NSPM; H:lewvzet200.ext.ti.com; PTR:InfoDomainNonexistent;\n CAT:NONE; SFS:(13230040)(82310400026)(1800799024)(36860700013)(376014);\n DIR:OUT; SFP:1101;",
        "X-MS-Exchange-AntiSpam-MessageData-ChunkCount": "1",
        "X-MS-Exchange-AntiSpam-MessageData-0": "\n u5dn5lGa170DL7K9zneeRjGN7Kdw1Ko+ZvznnKoh3A4EoX+iJt0lsQN4LbuMeifs3EnqIwEztxOeotVmnVlh3dSrfxgDt/eXZbDN4C9YsNaFJr18t4SdEtZ7ZyAShjhX3lggILUMknWSL4OhgcdxHxyyzk5+H89k2QHKQu4DHTRGvFVIzvuKR0MKmf8/g1f0IShTObjAY4heoqIDFlu01LDycTWVD5XKjTpOelD41NZxoLx5WLfLQ8IGuPQ/13NY4k708GpY1+K7EtC0rlS1aWrJhcGZcRsfM1JcSsxpjYxtOoRXFFEW9oN6gLqGpCD9QF+bFRC69gpnYirGeRmzNjqTRELwu6iOKRcv2k4FMzd0ByPUlmBOfYx0bvwKtLZlFH+QThe8fZxeYuKLlIaqbtoK0h6HhNbAwEvuEt2a4tP1XUnT6JJxxuSzhHQf49a+",
        "X-OriginatorOrg": "ti.com",
        "X-MS-Exchange-CrossTenant-OriginalArrivalTime": "13 Feb 2026 05:14:32.9324 (UTC)",
        "X-MS-Exchange-CrossTenant-Network-Message-Id": "\n 9bd28665-3dd8-464f-da50-08de6abec5f2",
        "X-MS-Exchange-CrossTenant-Id": "e5b49634-450b-4709-8abb-1e2b19b982b7",
        "X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp": "\n TenantId=e5b49634-450b-4709-8abb-1e2b19b982b7; Ip=[198.47.23.194];\n Helo=[lewvzet200.ext.ti.com]",
        "X-MS-Exchange-CrossTenant-AuthSource": "\n BN2PEPF000055DD.namprd21.prod.outlook.com",
        "X-MS-Exchange-CrossTenant-AuthAs": "Anonymous",
        "X-MS-Exchange-CrossTenant-FromEntityHeader": "HybridOnPrem",
        "X-MS-Exchange-Transport-CrossTenantHeadersStamped": "LV3PR10MB8034",
        "X-BeenThere": "u-boot@lists.denx.de",
        "X-Mailman-Version": "2.1.39",
        "Precedence": "list",
        "List-Id": "U-Boot discussion <u-boot.lists.denx.de>",
        "List-Unsubscribe": "<https://lists.denx.de/options/u-boot>,\n <mailto:u-boot-request@lists.denx.de?subject=unsubscribe>",
        "List-Archive": "<https://lists.denx.de/pipermail/u-boot/>",
        "List-Post": "<mailto:u-boot@lists.denx.de>",
        "List-Help": "<mailto:u-boot-request@lists.denx.de?subject=help>",
        "List-Subscribe": "<https://lists.denx.de/listinfo/u-boot>,\n <mailto:u-boot-request@lists.denx.de?subject=subscribe>",
        "Errors-To": "u-boot-bounces@lists.denx.de",
        "Sender": "\"U-Boot\" <u-boot-bounces@lists.denx.de>",
        "X-Virus-Scanned": "clamav-milter 0.103.8 at phobos.denx.de",
        "X-Virus-Status": "Clean"
    },
    "content": "The cdns3_bind() function is responsible for identifying the appropriate\ndriver to bind to the USB Controller's device-tree node. If the device-tree\nnode has the 'dr_mode' property set to 'otg', the existing approach fails\nto bind a driver, leading to loss of functionality.\n\nTo address this, use the VBUS Valid field of the OTG Status register to\ndetermine the role as follows:\n- If VBUS Valid field is set, it indicates that a USB Host is supplying\n  power and the Controller should assume the Peripheral role.\n- If VBUS Valid field is clear, it indicates the absence of a USB Host and\n  the Controller should assume the Host role.\n\nAdditionally, when 'dr_mode' happens to be 'otg' and the STRAP settings\nare not specified, use VBUS Valid to determine the role in cdns3_drd_init()\nand assign it to cdns->dr_mode.\n\nSigned-off-by: Siddharth Vadapalli <s-vadapalli@ti.com>\n---\n\nHello,\n\nThis patch is based on commit\nf9ffeec4bdc board: toradex: Make A53 get RAM size from DT in K3 boards\nof the master branch of U-Boot.\n\nv1 of this patch is at:\nhttps://patchwork.ozlabs.org/project/uboot/patch/20260204121245.2105523-1-s-vadapalli@ti.com/\nChanges since v1:\n- Addressed feedback from Marek by updating cdns3_get_otg_mode() to:\n  i) Return an error code (or zero in case of success) instead of returning dr_mode\n  ii) Fill in the mode in a parameter passed to the function\n  and updating cdns3_bind() to return an error when cdns3_get_otg_mode()\n  fails, instead of continuing.\n\nPatch has been tested on the J784S4 EVM in the context of USB DFU Boot\nwith dr_mode set to 'otg' in the device-tree. Logs:\nhttps://gist.github.com/Siddharth-Vadapalli-at-TI/7a696ba0a4871317361c54003ab75360\n\nRegards,\nSiddharth.\n\n drivers/usb/cdns3/core.c | 64 ++++++++++++++++++++++++++++++++++++++++\n drivers/usb/cdns3/drd.c  | 11 +++++++\n 2 files changed, 75 insertions(+)",
    "diff": "diff --git a/drivers/usb/cdns3/core.c b/drivers/usb/cdns3/core.c\nindex 4434dc15bec..801c4f1091f 100644\n--- a/drivers/usb/cdns3/core.c\n+++ b/drivers/usb/cdns3/core.c\n@@ -392,6 +392,63 @@ static const struct udevice_id cdns3_ids[] = {\n \t{ },\n };\n \n+/*\n+ * The VBUS Valid Bit in the OTG Status register can be used to determine\n+ * the role. When VBUS Valid is set, it indicates that a USB Host is supplying\n+ * power, so the Controller should assume the PERIPHERAL role. If it isn't set,\n+ * it indicates the absence of a USB Host, so the Controller should assume the\n+ * HOST role. If the OTG Status register is inaccessible, return an error.\n+ */\n+static int cdns3_get_otg_mode(ofnode node, enum usb_dr_mode *mode)\n+{\n+\tstruct cdns3 cdns, *cdnsp;\n+\tvoid __iomem *otg_regs;\n+\tfdt_addr_t otg_addr;\n+\tint otg_reg_index;\n+\tint vbus;\n+\n+\totg_reg_index = ofnode_stringlist_search(node, \"reg-names\", \"otg\");\n+\tif (otg_reg_index < 0) {\n+\t\tprintf(\"%s: dr_mode is otg but otg register name is missing\\n\", __func__);\n+\t\treturn -ENOENT;\n+\t}\n+\n+\totg_addr = ofnode_get_addr_index(node, otg_reg_index);\n+\tif (otg_addr == FDT_ADDR_T_NONE) {\n+\t\tprintf(\"%s: address of otg registers is unspecified\\n\", __func__);\n+\t\treturn -ENOENT;\n+\t}\n+\n+\totg_regs = map_physmem(otg_addr, 0, MAP_NOCACHE);\n+\tif (!otg_regs) {\n+\t\tprintf(\"%s: failed to map otg registers\\n\", __func__);\n+\t\treturn -EINVAL;\n+\t}\n+\n+\t/*\n+\t * As mentioned in drivers/usb/cdns3/drd.c, there are two versions\n+\t * of the Controller. The following logic detects the version of the\n+\t * Controller and interprets the register layout accordingly.\n+\t */\n+\tcdnsp = &cdns;\n+\tcdnsp->otg_v0_regs = otg_regs;\n+\tif (!readl(&cdnsp->otg_v0_regs->cmd)) {\n+\t\tcdnsp->otg_regs = otg_regs;\n+\t} else {\n+\t\tcdnsp->otg_v1_regs = otg_regs;\n+\t\tcdnsp->otg_regs = (void *)&cdnsp->otg_v1_regs->cmd;\n+\t}\n+\n+\t/* Use VBUS Valid to determine role */\n+\tvbus = !!(readl(&cdnsp->otg_regs->sts) & OTGSTS_VBUS_VALID);\n+\tif (vbus)\n+\t\t*mode = USB_DR_MODE_PERIPHERAL;\n+\telse\n+\t\t*mode = USB_DR_MODE_HOST;\n+\n+\treturn 0;\n+}\n+\n int cdns3_bind(struct udevice *parent)\n {\n \tenum usb_dr_mode dr_mode;\n@@ -413,6 +470,13 @@ int cdns3_bind(struct udevice *parent)\n \tif (dr_mode == USB_DR_MODE_UNKNOWN)\n \t\tdr_mode = usb_get_dr_mode(dev_ofnode(parent));\n \n+\t/* Use VBUS Valid to determine role */\n+\tif (dr_mode == USB_DR_MODE_OTG) {\n+\t\tret = cdns3_get_otg_mode(node, &dr_mode);\n+\t\tif (ret < 0)\n+\t\t\treturn ret;\n+\t}\n+\n \tswitch (dr_mode) {\n #if defined(CONFIG_SPL_USB_HOST) || \\\n \t(!defined(CONFIG_XPL_BUILD) && defined(CONFIG_USB_HOST))\ndiff --git a/drivers/usb/cdns3/drd.c b/drivers/usb/cdns3/drd.c\nindex cbb13342343..0ca40a5cc8d 100644\n--- a/drivers/usb/cdns3/drd.c\n+++ b/drivers/usb/cdns3/drd.c\n@@ -301,6 +301,17 @@ int cdns3_drd_init(struct cdns3 *cdns)\n \t\tcdns->dr_mode = USB_DR_MODE_PERIPHERAL;\n \t}\n \n+\t/*\n+\t * In the absence of STRAP configuration, use VBUS Valid to\n+\t * determine the appropriate role to be assigned to dr_mode.\n+\t */\n+\tif (cdns->dr_mode == USB_DR_MODE_OTG) {\n+\t\tif (cdns3_get_vbus(cdns))\n+\t\t\tcdns->dr_mode = USB_DR_MODE_PERIPHERAL;\n+\t\telse\n+\t\t\tcdns->dr_mode = USB_DR_MODE_HOST;\n+\t}\n+\n \tstate = readl(&cdns->otg_regs->sts);\n \tif (OTGSTS_OTG_NRDY(state) != 0) {\n \t\tdev_err(cdns->dev, \"Cadence USB3 OTG device not ready\\n\");\n",
    "prefixes": [
        "v2"
    ]
}