From nobody Tue Nov 24 11:35:55 2026 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=205.220.180.131 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795458533; b=ACesIod7bwpIl9X/ifxsrgUQz0lqLYQJfimpbUsrgGTEaDkIWvS6SvGC4jgVT2zJAxjD Tv7Eb9WgpZN38zfbK7QPnXV3UitNmtDJ3BsXn8h4rWP+f4TIIWDufOowzLKKw74fxqyk3 QhJRG6YAvq6kTVC7GJ3XKteMuwcmLDrB6uA6yxKFvw03bicRHhN3y6w1enP1lRbFUUpIA AbixW0RsdSKIynX4Hz4ZA0a53PMX9JvFHSuHXslRx6vsQAvh5plCoKTvl60p3MlDWn4Jk TJaBI19+cuPqEhAWuNXqKq0Bhj9vMB9TUAIjqky5ahRIc0sy6uyIaFjXLUqCAe0Qtbg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795458533; h=DMARC-Filter:Received:DKIM-Signature:Received:Received: DKIM-Signature:X-Google-DKIM-Signature:X-Forwarded-Encrypted: X-Gm-Message-State:X-Gm-Gg:X-Received:X-Received:Received:From:To:Cc: Subject:Date:Message-Id:X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding:X-Proofpoint-Spam-Details-Enc: X-Proofpoint-ORIG-GUID:X-Authority-Analysis:X-Proofpoint-GUID: X-Proofpoint-Spam-Info:X-Proofpoint-Virus-Version: X-Proofpoint-Spam-Details; bh=mjs3rlDnLUkN31VdHb88E8QJ4KDT+KUi0fn1sZoUpDA=; b=U3sA2XkYv9JxChybRtRrkwXj6+1SCKUKNHNiNsyZ6qouIxllOogyAqwISmD6zcj3Tz+l ZppOTRCadk2Og8tDTVv6E9nc6N5hIhT/utj2yLpZen0cu3Jz0ytBE7mBraVfaZZuOx+HV xNM+xLW+UfS/ewYptLhqmjMxqgYytiXwPFmlRxJsH8vIQleiHAs50QdqoQI+7rzAI5FyG +QYsWt0B+ZqSYEhzAXCrblBkAcEnwVHooiLnTcX4H0HiwcOHY7VhtWLk6TMLfpPT9hVKC DbFqZKqjXaVpalT94TLPkMuKffk4wh59wk6OEPeJhgrQ59xYAm3eihvRsJzc7k8ACAw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=oss.qualcomm.com; spf=pass smtp.mailfrom=oss.qualcomm.com; dkim=pass header.d=qualcomm.com header.i=@qualcomm.com header.a=rsa-sha256 header.s=qcppdkim1 header.b=jrs0eb9y; dkim=pass header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.a=rsa-sha256 header.s=google header.b=IQwjKs8d; arc=none smtp.remote-ip=205.220.180.131 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 202CA606A682 for ; Mon, 23 Nov 2026 18:28:52 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 202CA606A682 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.a=rsa-sha256 header.s=qcppdkim1 header.b=jrs0eb9y; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.a=rsa-sha256 header.s=google header.b=IQwjKs8d Received: from pps.filterd (m0279868.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 6ANGH8602487483 for ; Mon, 23 Nov 2026 18:28:52 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=qcppdkim1; bh=mjs3rlDnLUk N31VdHb88E8QJ4KDT+KUi0fn1sZoUpDA=; b=jrs0eb9yNOPRhUgP+oR3l6ZbbnA XB8+idsJKDEa7iqJD7cM08ya5idCY31w0TC4sx1eOIbdKn4zwDsYyXnUBF+CEh8P WsYPBDT53QOTRtlXkgUHBqp/xeF8WYGzYpTXRj50EDNij6ucnnlHWYpUhVz1Tf9H avtew+NWAJJT0GVd+SiXxQ7JiTQjDfIjPNYU/UQyfHdrqmfnrXc8L8wxpQkfLKDZ 9lFKYSZOiiqvWUAycaZ2151OkR/vaywddhtMflhLR2MkV5wIjNbHaU2ru5bYPMmx YS3RsrvJAnZL1daxaLOJDoHyAfOlRFatZAH/zF97x78EiYb70uqp+CIkM7A== Received: from mail-dy1-f197.google.com (mail-dy1-f197.google.com [74.125.82.197]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4j4fy02v30-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Mon, 23 Nov 2026 18:28:51 +0000 (GMT) Received: by mail-dy1-f197.google.com with SMTP id 5a478bee46e88-375bac6bd21so4030883eec.0 for ; Mon, 23 Nov 2026 10:28:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1795458531; x=1796063331; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=mjs3rlDnLUkN31VdHb88E8QJ4KDT+KUi0fn1sZoUpDA=; b=IQwjKs8dahs3/GxFhjLsN5QmRRRvrFQsCKgmPenRMU63mw9FyN+TU1Pv6c7tQaX7+z LmgTADiVMXLIr5jIlH9xYRXrt7jmUI702c48w5Lb89LCTcixBeCDi0BZ+jalCJrFlRc9 y0qBdqWaBZJmMQmz24Xw7kQUatkQrK0kvoEICJLgjM6CsUK6+d8ilCgKrQa7UWBYKXIA 94m4W1YKfX+1WTZPr9/vuBXa/7QSoZ3/1jd6FiD92cOxnmjxzLUcOhvglWLD04Yjs02k AkKI3IQDDzM5B1YlbT5qJCRw5aKavS7O0eT8GLE4+jIpOzCXlGOjiJoaGUZf/8OTi8jA 1ULQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1795458531; x=1796063331; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=mjs3rlDnLUkN31VdHb88E8QJ4KDT+KUi0fn1sZoUpDA=; b=ZF3N+zEXTKaNdkqosW37v7q/48tJoV/s8RQV/63N5osKoxzG/StxrjhunJWjVPRHqp SPmg4dLG5pcZB/gR4j58zJMWdir/L90wkTO9X4T1G6blfqd9llDmWRsP6raX8GB23lMu HVg32aesVqxJk8yIMsCMOFCIDJz6YlskZUOvV9gyB9k89adtrb+X/ICxcwf0aq5rxdTU 3r1hOZd5gKOx3mPTR++kc2omb7cIWjtM9pj5TF66IG7lLJEnOabnYgkZ94/OyXxhjlQZ xg48TO5HKV5WnvEZP0CC6bGs7/0hrK7ww+vUgu17kQpHvJY9tBMNaj+5int7OyyA8pUN 92Pg== X-Forwarded-Encrypted: i=1; AL+hErErJD4UthkmKsqp8XMBCBNEZ41FT5hx7rLuRYAW7LRDtVnAzj1efK+DdiZd+2EJ1xFeZfCsHIKbmIyLdQI=@vger.kernel.org X-Gm-Message-State: APuU4Z8FuNxnoOMBI5rZL9FgKpptfkDBKkv43KX3th4iitQltqzTLkBU Tus9MD2bvElIst4f/ii9+UivqdHxS0G/mroxOK4C/9IzkjSzNsUX32wtbhFUQmGENH1LxKftQ6q hAMpd78e4c5nHM2Lkyk5EWhkDFoN5hbhWswiSuLCLqrHE6YW2s7etoNkDvSa4CTHb1Ew= X-Gm-Gg: AZFdTZd3cr59eMc9rphjQwix4sM61elqG0DKSibFojF2RpAI8uhh+syhDPVLF3LkDTf uCrg8ZX+BfHSL1a0VglMGF3FCNPhh0s1+NBaFfrvssgXFy/82t2ZPOUuVR+qKpzNt+HD962O5+o HTzDH+4bakVwE6h7PPZZXbgFKFdFhK1UcQKuUPyw2X57fBjN17OD6bY2ZgBvxImWNMGV8nw8V+x Vstllo/O3+KxTqtzT1lTr5u6cJ1KOM42n9YdEYKHWvDozxtTDub/StMkn+wGOPj8OOBYlKkCWW/ Qidscvp1lfdYjY/8q6wNy8bW1EthFw+YCd9NXwO+ELkUJiR76pHcNrLtfQeGeK7LdGH3egMlBKN QL16h3AdzgR40KQmbOCsfN0KRpDHIZen5n588hDmjXlV975ugbuWdzwBdMePCWRIUEGmaYqgEYK qQhy154MNZ03en5uNnmz/c12PZtg== X-Received: by 2002:a05:7301:d18b:b0:386:b4f1:dab0 with SMTP id 5a478bee46e88-386b4f1e04fmr3217101eec.1.1795458530756; Mon, 23 Nov 2026 10:28:50 -0800 (PST) X-Received: by 2002:a05:7301:d18b:b0:386:b4f1:dab0 with SMTP id 5a478bee46e88-386b4f1e04fmr3217073eec.1.1795458530113; Mon, 23 Nov 2026 10:28:50 -0800 (PST) Received: from hu-eserrao-lv.qualcomm.com (Global_NAT1.qualcomm.com. [129.46.96.20]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-385666e99fdsm47697986eec.5.2026.11.23.10.28.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Nov 2026 10:28:49 -0800 (PST) From: Elson Serrao To: Bjorn Andersson , Conor Dooley , Greg Kroah-Hartman , Konrad Dybcio , Krzysztof Kozlowski , Rob Herring Cc: linux-arm-msm@vger.kernel.org, devicetree@vger.kernel.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Krzysztof Kozlowski Subject: [PATCH v10 1/7] dt-bindings: soc: qcom: eud: Add per-path child nodes for UTMI routing Date: Mon, 23 Nov 2026 10:28:41 -0800 Message-Id: <20261123182847.143892-2-elson.serrao@oss.qualcomm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20261123182847.143892-1-elson.serrao@oss.qualcomm.com> References: <20261123182847.143892-1-elson.serrao@oss.qualcomm.com> X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYxMTIzMDA3MyBTYWx0ZWRfX8mPaznwWu1sT OsY8y+qlhR+4Q+qNe86/45q5Fz6VO8kogD42NCzuqnV7GRYfaUIrifgM712Ja2vcVAWwLI3FBmt Y7JOaX9V/obHV5wstW7sMERL1nZy9P98YOvdTr/4xLS672zHqZ6X3vvqLRLgD5Iu028iMdHc2Ow hGcMbjyNRnXoL+1FddUvAsmZceFRILTMH6SAiI26Kp+iXYBsjKoev4O6ecWdOrjwa8rMF2tviiz hzMWkNmnHqU1C9uTQEwsXTVEcqkArFowVsLOnZulVaEvvHXRtaEqqwbCUoYla0ovJUsZ5hnoKCJ W401mkJueyyHOSeDR835FkXazR9JLxyatGPd1LajEzQtPtQuZhx8Z/P5nESQXn4b9KBNiE4ssUD nXFZSSTwiD8qnYx2h0lS01ijFXNjaldbSe/j6V/HS2VTXm5bxjMGgtIghe3W0DIId9s+eI3AUKV TWSu1NwGKFB62Iptxtg== X-Proofpoint-ORIG-GUID: ukQJFQYdC5dWd5wOYVo0bRd5A1ySWCra X-Authority-Analysis: v=2.4 cv=QrXLTlyd c=1 sm=1 tr=0 ts=6b0485e3 cx=c_pps a=Uww141gWH0fZj/3QKPojxA==:117 a=ouPCqIW2jiPt+lZRy3xVPw==:17 a=zJRp6_cAMcgA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=ZpdpYltYx_vBUK5n70dp:22 a=EUspDBNiAAAA:8 a=VwQbUJbxAAAA:8 a=RJ9lep_nkaVUh_m6BXgA:9 a=PxkB5W3o20Ba91AHUih5:22 X-Proofpoint-GUID: ukQJFQYdC5dWd5wOYVo0bRd5A1ySWCra X-Proofpoint-Spam-Info: AW1haW4tMjYxMTIzMDA3MyBTYWx0ZWRfX09COe8F6UjX3 bIlSedmzuX9mVfHhCkaSyN34JOzvfZtdm0HHHrgIcBVSzhETacw6zOhPFcsH1sV5ltc7gybqURI 8X2wIwjt0fhkVFtjSjTucRM6lmY/0XY= X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.138,FMLib:17.12.100.49 definitions=2026-11-23_04,2026-11-23_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 impostorscore=0 suspectscore=0 phishscore=0 spamscore=0 lowpriorityscore=0 adultscore=0 clxscore=1015 malwarescore=0 bulkscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2611040001 definitions=main-2611230073 Content-Type: text/plain; charset="utf-8" The Qualcomm Embedded USB Debugger (EUD) can intercept one or two High-Speed UTMI paths depending on the SoC. For example, SC7280 supports EUD on the primary UTMI path only, while SM8350 supports EUD on both primary and secondary UTMI paths. Each UTMI path connects an independent USB controller/connector pair and forms its own role-switch domain. EUD routes traffic based on USB role. In device role the debug hub is inserted, while in host role it is bypassed. The existing binding models EUD using a flattened ports representation. While sufficient for fixed device-role configurations, it cannot naturally associate a controller, connector, and role switch with a specific EUD-routable path. This is problematic for role-switch capable ports and becomes more pronounced on SoCs with multiple paths. In such cases, each path forms an independent role-switch domain and requires per-path role awareness. Model each UTMI path as a separate child node with its own OF graph. This representation is used for role-aware EUD routing regardless of whether a SoC exposes one or two UTMI paths. Add an SM8350 compatible for dual-path EUD topologies. Retain support for the legacy flat ports representation on SC7280 for backward compatibility. Reviewed-by: Krzysztof Kozlowski Acked-by: Bjorn Andersson Signed-off-by: Elson Serrao --- .../bindings/soc/qcom/qcom,eud.yaml | 138 +++++++++++++++++- 1 file changed, 137 insertions(+), 1 deletion(-) diff --git a/Documentation/devicetree/bindings/soc/qcom/qcom,eud.yaml b/Doc= umentation/devicetree/bindings/soc/qcom/qcom,eud.yaml index 84218636c0d8..90dc104e4475 100644 --- a/Documentation/devicetree/bindings/soc/qcom/qcom,eud.yaml +++ b/Documentation/devicetree/bindings/soc/qcom/qcom,eud.yaml @@ -18,6 +18,7 @@ properties: items: - enum: - qcom,sc7280-eud + - qcom,sm8350-eud - const: qcom,eud =20 reg: @@ -45,10 +46,92 @@ properties: $ref: /schemas/graph.yaml#/properties/port description: This port is to be attached to the type C connector. =20 + '#address-cells': + const: 1 + + '#size-cells': + const: 0 + +patternProperties: + "^eud-path@[0-1]$": + type: object + description: + Represents one High-Speed UTMI path that EUD intercepts. Use eud-pat= h nodes + to associate role-switching behavior with specific port connections,= allowing + EUD to manage role transitions independently for each UTMI path. + + properties: + reg: + maxItems: 1 + description: Path number + + usb-role-switch: + type: boolean + description: + Indicates that EUD relays USB role-switch events for this path a= nd + performs role-dependent UTMI routing accordingly. In device role, + the EUD hub is inserted into this path to enable debug + functionality. In host role, the EUD hub is bypassed and UTMI + traffic flows directly between the PHY and the USB controller. + + ports: + $ref: /schemas/graph.yaml#/properties/ports + description: + These ports are to be attached to the endpoint of the USB contro= ller node + and USB connector node. + + properties: + port@0: + $ref: /schemas/graph.yaml#/properties/port + description: This port is to be attached to the USB controller. + + port@1: + $ref: /schemas/graph.yaml#/properties/port + description: This port is to be attached to the USB connector. + + required: + - reg + - ports + + additionalProperties: false + required: - compatible - reg - - ports + +allOf: + - if: + properties: + compatible: + contains: + const: qcom,sc7280-eud + then: + oneOf: + - required: + - ports + properties: + eud-path@0: false + eud-path@1: false + - required: + - eud-path@0 + - '#address-cells' + - '#size-cells' + properties: + ports: false + eud-path@1: false + - if: + properties: + compatible: + contains: + const: qcom,sm8350-eud + then: + required: + - eud-path@0 + - eud-path@1 + - '#address-cells' + - '#size-cells' + properties: + ports: false =20 additionalProperties: false =20 @@ -77,3 +160,56 @@ examples: }; }; }; + - | + eud@88e0000 { + compatible =3D "qcom,sm8350-eud", "qcom,eud"; + reg =3D <0x88e0000 0x2000>, + <0x88e2000 0x1000>; + #address-cells =3D <1>; + #size-cells =3D <0>; + + eud-path@0 { + reg =3D <0>; + usb-role-switch; + + ports { + #address-cells =3D <1>; + #size-cells =3D <0>; + port@0 { + reg =3D <0>; + eud_usb0: endpoint { + remote-endpoint =3D <&usb_1_dwc3_hs>; + }; + }; + + port@1 { + reg =3D <1>; + eud_con0: endpoint { + remote-endpoint =3D <&pmic_glink_hs_in>; + }; + }; + }; + }; + + eud-path@1 { + reg =3D <1>; + + ports { + #address-cells =3D <1>; + #size-cells =3D <0>; + port@0 { + reg =3D <0>; + eud_usb1: endpoint { + remote-endpoint =3D <&usb_2_dwc3_hs>; + }; + }; + + port@1 { + reg =3D <1>; + eud_con1: endpoint { + remote-endpoint =3D <&conn_2_hs_in>; + }; + }; + }; + }; + }; --=20 2.34.1 From nobody Tue Nov 24 11:35:55 2026 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=205.220.180.131 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795458534; b=pTFdZtjxTX8dDC3eBXlRBDKHTgorj1JJieeybhNvUjpzRxpP4J/3I+1pa8PngyFc4UtX N1+pR1qr6FuJFg1OY0oLz9i+ZJuqsJR/8aWaC/keAGlpmhUY13K0d9GT5elAu4Ttjudem Qgx98Fmsx/WytTWTzbXd50WuTbe5+fFOCTS/QiLXyNiV/1A/pQCl7VS0d+0Rsp4Ygh/nD 8x34HVRT1oN8hNjL/lEhYVB/gCzZtTGq6gw/qKh/KhESkgD5cnwrrkDKlnkQBqR0gbebo OJlAuD6+k/Z19orXh+x5li5kMse/8hs2aA0nHW9IYagXcIXCojMPKuhhiH0H5a713zg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795458534; h=DMARC-Filter:Received:DKIM-Signature:Received:Received: DKIM-Signature:X-Google-DKIM-Signature:X-Forwarded-Encrypted: X-Gm-Message-State:X-Gm-Gg:X-Received:X-Received:Received:From:To:Cc: Subject:Date:Message-Id:X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding:X-Authority-Analysis: X-Proofpoint-Spam-Details-Enc:X-Proofpoint-GUID: X-Proofpoint-Spam-Info:X-Proofpoint-ORIG-GUID: X-Proofpoint-Virus-Version:X-Proofpoint-Spam-Details; bh=Lq2ckgeFeyG4ruGkCS4DwzZ4m7ssUVEezBWNCadpNus=; b=rbTEXS8KcrKbTu7WdKIKzuY0f+BYNGchJxM/0qLmNHD7sutUAR3OwgN7I04orumXaw1D qUxyJ1/l93n+BGvh02XhfcHjRKHIkFpZIIuW0WT+ZFDgqJ1OJW8byBB+kkxQbf+GoGNf6 TT90LDGhDCOhTFrlGkAQL3l238/7JfIqoRpddRwJklrbjcCEqspp+3xWaSI6LJZNOaisI A+glBxFsdPfPja5HLMzXO73v44a16ZwBxE+kDXSnk3Mqtn1WY6s9V7Ye3J5Iz86dvGkGz WcCm1tLKgbVN1ZGlwA1Fhaiz2bO1IWXh+BsmeL7fdSnVsffMkmsTrTTX91A41a1q+1w== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=oss.qualcomm.com; spf=pass smtp.mailfrom=oss.qualcomm.com; dkim=pass header.d=qualcomm.com header.i=@qualcomm.com header.a=rsa-sha256 header.s=qcppdkim1 header.b=QgmcNHRw; dkim=pass header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.a=rsa-sha256 header.s=google header.b=PVfKytR7; arc=none smtp.remote-ip=205.220.180.131 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 669DC606A6A2 for ; Mon, 23 Nov 2026 18:28:54 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 669DC606A6A2 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.a=rsa-sha256 header.s=qcppdkim1 header.b=QgmcNHRw; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.a=rsa-sha256 header.s=google header.b=PVfKytR7 Received: from pps.filterd (m0279869.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 6ANGH3PD3475231 for ; Mon, 23 Nov 2026 18:28:53 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=qcppdkim1; bh=Lq2ckgeFeyG 4ruGkCS4DwzZ4m7ssUVEezBWNCadpNus=; b=QgmcNHRwOTYFltbEnU8CT6eWZm4 WXkbo1fYHF5B6WuTtNV2ePmUKqi/DuCVN3/pVec9kVHtH65Mc+wbqHnDno2lAZmz hoYYCMciPSTtJ2ZV44G+YejYZKwrGjjc/0rPGuDm9MlAF+Xmfe+CdG7mkSMresh+ 1YHX5ztPz6VE8AMXQU7/G7JXDePrPCDcUe+0UD4Ajd62YKiPFuswrEC53TSj1W6T zBSyB/dF7BO88Ucssq62fXRYMNeRNSafS/CrAFcdBtyyqu6OtoMW2Z4Ztddvd+x/ sg8dcebxjggFGd1GnTBiDla8MUhhRinwCf4bGrNoC0EANF5WXcRmqAmnIkA== Received: from mail-dy1-f197.google.com (mail-dy1-f197.google.com [74.125.82.197]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4j4hn7tg5f-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Mon, 23 Nov 2026 18:28:53 +0000 (GMT) Received: by mail-dy1-f197.google.com with SMTP id 5a478bee46e88-386177b0516so9766176eec.1 for ; Mon, 23 Nov 2026 10:28:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1795458532; x=1796063332; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=Lq2ckgeFeyG4ruGkCS4DwzZ4m7ssUVEezBWNCadpNus=; b=PVfKytR7uyik7EOhP3PMKvv2wSoWbchKb7P5srh9XzqXBy+D4JROiV7AP/Eaf6zJXk d+ac3+FpunoRRZ+FYoRUEvDqQTTbe+/4NeWVNbMNpSGUq+xTtQvLBhmd4b4iT/ssPRHa LUeGqC0NKd7OmsbhunKBDGznH3+3Jzi8pAy9lkyDC/qyf93ZcRAq80q28fvlHNIwf22L C0qTc6RkUVoWuHIal+Inm+yS4CaElGhhnFSDrjX4VCPvFduVdfk5qk43kb9Ytr0FkVik QbkJVcjLJJ7d/LQUnqNGzPvejSF4txn6besl++DXs+Is6yz7OgzjSAiGWLBINy9RYJQg 1TEw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1795458532; x=1796063332; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=Lq2ckgeFeyG4ruGkCS4DwzZ4m7ssUVEezBWNCadpNus=; b=mRvBA/b7xmx3/Zd+JcDZsfzcbDq/SA/8NR6Bo3HjJFBc2wcccle6DkyEYoMAN+xUQR 8+SJdGr37rsIm8Gl6vV118tfyTk+91sbJHQfJslu7TrCSc5nxvHWEujdO6eovo6O42kH 2qKMdojov/+c62C2LujHM1WbHx2xrcO8q+GMC8Fd9O3bg2+CbftU5KovokMKXT8qI5pb ecYHO2z1nN46Wx/A4j1oBRAcTCiybig2DfFnu60NGREeejfz0xvWnapON+Qc4qVuyJ+o wNAwJL18ZjLw2GZjv5AFLntunPXZ3/4XriwyOTBYc4eLiLOJyLuD9CzKsq4wrm5i1wiN 1a+A== X-Forwarded-Encrypted: i=1; AL+hErFqbGz/B3I1ORcmivXHl5wXK2N289MGdLK89alae3Tkash0LqN4SBE8dkm+zt3NWY7SOOqcYhWmGsL8RaE=@vger.kernel.org X-Gm-Message-State: APuU4Z9drz8LdeSPu7rLvzrdRTkiFN/H2bDC/Tq1RvEppzX2cEBjkXvV Q/9Le9/MaRD80RO1mMZR/8YXvhJR5/bPqwBQO4oDcGku3LbuC7oatopxDBpePE5edOzDoqDAdwB MFDuViab+1EWCuSGg0Nz4YU+9hD2sKGaE62DPW0xBymq0Sm2PHFTNQfKDU4lCK84LpBY= X-Gm-Gg: AZFdTZecx8k2tAsf3pz2P8nBTmuIm7YKS9dNVN4bKRm+KlSrt88vbJAgWngevKKaKtz WWsYclgM3W/vlGbdXgrDa6ztDrVlyeHvAx6g/7CTvJIYtMnjqiWcsvrhNUmT7j0wIu5qzdRojhh 6KLyvjOuFJpudIiODblNiLwhYT/JHTWoJIaG2IcjY5RuPXvbJd59xp+VCQy1d/QZp8/mOKoXkk3 frNkUufKnWEtsh8BRpCDFnxM8Y8kz7qL5ILeV9mlXoOjxD8QtLfD94LXA4+Z09venfvJChWbhL3 eqjCTBj2AfHpTfdYsmT7MMglIt6VhbxUZ82A7/MzMcQPXpM0ZS9GZBoTpvJNjJF7ZNNi9Hick96 uCHa7bDNGknl/nB3HVi21ATsyIH9ndaEXiETmwgT+jXGEk7teRjx+6bNGkQ9xF8D0T90TyeRyvt lBO/NpDGE0PHrMLL3S4+mgj6/CcQ== X-Received: by 2002:a05:7300:2209:b0:386:8d2:929b with SMTP id 5a478bee46e88-38608d2945emr17643555eec.23.1795458532086; Mon, 23 Nov 2026 10:28:52 -0800 (PST) X-Received: by 2002:a05:7300:2209:b0:386:8d2:929b with SMTP id 5a478bee46e88-38608d2945emr17643507eec.23.1795458531488; Mon, 23 Nov 2026 10:28:51 -0800 (PST) Received: from hu-eserrao-lv.qualcomm.com (Global_NAT1.qualcomm.com. [129.46.96.20]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-385666e99fdsm47697986eec.5.2026.11.23.10.28.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Nov 2026 10:28:50 -0800 (PST) From: Elson Serrao To: Bjorn Andersson , Conor Dooley , Greg Kroah-Hartman , Konrad Dybcio , Krzysztof Kozlowski , Rob Herring Cc: linux-arm-msm@vger.kernel.org, devicetree@vger.kernel.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Peter Chen , Konrad Dybcio , Gopikrishna Garmidi Subject: [PATCH v10 2/7] usb: misc: qcom_eud: add sysfs attribute for port selection Date: Mon, 23 Nov 2026 10:28:42 -0800 Message-Id: <20261123182847.143892-3-elson.serrao@oss.qualcomm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20261123182847.143892-1-elson.serrao@oss.qualcomm.com> References: <20261123182847.143892-1-elson.serrao@oss.qualcomm.com> X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Authority-Analysis: v=2.4 cv=Ls0HWXdc c=1 sm=1 tr=0 ts=6b0485e5 cx=c_pps a=Uww141gWH0fZj/3QKPojxA==:117 a=ouPCqIW2jiPt+lZRy3xVPw==:17 a=zJRp6_cAMcgA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=_glEPmIy2e8OvE2BGh3C:22 a=VwQbUJbxAAAA:8 a=EUspDBNiAAAA:8 a=qXh0dugIJu6lbCvlF8UA:9 a=PxkB5W3o20Ba91AHUih5:22 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYxMTIzMDA3MyBTYWx0ZWRfX6mjbieaG8kAV pB2ppKIQ9JF4Bz993W3IvmA3SDpY+08SKaE/AYik7+HHN8AWGPe88IP15Qlhc3rY3V+e2kWpmPv TTjeJJ7B1mfxxztDd3QZUHFuZlDa551cTYY+wxm6a0Qp2yg5OiA9I5yrKGv9BTFNLIXj5Tw1UNq VWHIjsj7+BRwpvJ7KbDkRHlhnjUqYmYiLqOLuuiHNdRv9PmECnrbcVf9gagY1EsDTvrnHOr8Wv4 c9kkPDlJ5BNG+KPizHGnOamCqE+QZjUkRKFYjpdBxag5h1TfNoPeF4cIrYqJTXXRwFVbSOz8F1x BkupkdLG+FS6ivEHi5Qm06w7ehzUcF/Px8O7g5fuzbe+0M6+eh6+nRb2PZfMzyvederhcvLp47j ygraOqpQpBIUONEHsj96otMpCWXKY6CvWdT5D3UuypO+OZG3LNkVb0uY/JXM9A/0ADpOh7sD6NW kVB0THVBh7ImBQp4UIg== X-Proofpoint-GUID: c0J-xKhnU797YgJVQkq8ts2mI2t8Jzby X-Proofpoint-Spam-Info: AW1haW4tMjYxMTIzMDA3MyBTYWx0ZWRfXy5+B4UebawN/ 2CBLtZW8toN6bVjmXDxBD6+mF6I8pUgGvoQFqse6n05lqU1IPyyJvcxeMKyAlmFKfmJpIYlQneJ +t1aD0Qt0aasegsdi0FDT3gsT3z4NEg= X-Proofpoint-ORIG-GUID: c0J-xKhnU797YgJVQkq8ts2mI2t8Jzby X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.138,FMLib:17.12.100.49 definitions=2026-11-23_04,2026-11-23_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 impostorscore=0 malwarescore=0 suspectscore=0 priorityscore=1501 spamscore=0 phishscore=0 lowpriorityscore=0 adultscore=0 bulkscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2611040001 definitions=main-2611230073 Content-Type: text/plain; charset="utf-8" EUD can be mapped to either the primary USB port or the secondary USB port depending on the value of the EUD_PORT_SEL register. Add a 'port' sysfs attribute to allow userspace to select which port EUD should operate on and update the ABI documentation. This is needed for systems with dual USB ports where EUD needs to be accessible on either port depending on the system configuration and use case. Reviewed-by: Peter Chen Reviewed-by: Konrad Dybcio Tested-by: Gopikrishna Garmidi Signed-off-by: Elson Serrao --- Documentation/ABI/testing/sysfs-driver-eud | 18 ++++++++++ drivers/usb/misc/qcom_eud.c | 42 ++++++++++++++++++++++ 2 files changed, 60 insertions(+) diff --git a/Documentation/ABI/testing/sysfs-driver-eud b/Documentation/ABI= /testing/sysfs-driver-eud index 2bab0db2d2f0..fb927a003596 100644 --- a/Documentation/ABI/testing/sysfs-driver-eud +++ b/Documentation/ABI/testing/sysfs-driver-eud @@ -7,3 +7,21 @@ Description: EUD based on a 1 or a 0 value. By enabling EUD, the user is able to activate the mini-usb hub of EUD for debug and trace capabilities. + +What: /sys/bus/platform/drivers/qcom_eud/.../port +Date: January 2026 +Contact: Elson Serrao +Description: + Selects which USB port the Embedded USB Debugger (EUD) + is mapped to on platforms providing multiple High-Speed + USB ports. + + Valid values: + primary - Primary USB port + secondary - Secondary USB port + + Writing any other value returns -EINVAL. + + The attribute is writable only while EUD is disabled. + Writing it while EUD is enabled returns -EBUSY. Reading + the attribute returns the currently selected USB port. diff --git a/drivers/usb/misc/qcom_eud.c b/drivers/usb/misc/qcom_eud.c index 73f9fac22e19..3e4647acd5aa 100644 --- a/drivers/usb/misc/qcom_eud.c +++ b/drivers/usb/misc/qcom_eud.c @@ -23,13 +23,22 @@ #define EUD_REG_VBUS_INT_CLR 0x0080 #define EUD_REG_CSR_EUD_EN 0x1014 #define EUD_REG_SW_ATTACH_DET 0x1018 +#define EUD_REG_PORT_SEL 0x1028 #define EUD_REG_EUD_EN2 0x0000 =20 +#define EUD_MAX_PORTS 2 + #define EUD_ENABLE BIT(0) #define EUD_INT_PET_EUD BIT(0) #define EUD_INT_VBUS BIT(2) #define EUD_INT_SAFE_MODE BIT(4) #define EUD_INT_ALL (EUD_INT_VBUS | EUD_INT_SAFE_MODE) +#define EUD_PORT_SEL_MASK BIT(0) + +static const char * const eud_port_names[] =3D { + "primary", + "secondary", +}; =20 struct eud_chip { struct device *dev; @@ -40,6 +49,7 @@ struct eud_chip { int irq; bool enabled; bool usb_attached; + u8 port_idx; }; =20 static int enable_eud(struct eud_chip *priv) @@ -104,8 +114,38 @@ static ssize_t enable_store(struct device *dev, =20 static DEVICE_ATTR_RW(enable); =20 +static ssize_t port_show(struct device *dev, struct device_attribute *attr= , char *buf) +{ + struct eud_chip *chip =3D dev_get_drvdata(dev); + + return sysfs_emit(buf, "%s\n", eud_port_names[chip->port_idx]); +} + +static ssize_t port_store(struct device *dev, struct device_attribute *att= r, + const char *buf, size_t count) +{ + struct eud_chip *chip =3D dev_get_drvdata(dev); + int port; + + port =3D sysfs_match_string(eud_port_names, buf); + if (port < 0) + return port; + + /* Port selection must be done before enabling EUD */ + if (chip->enabled) + return -EBUSY; + + writel(port, chip->base + EUD_REG_PORT_SEL); + chip->port_idx =3D port; + + return count; +} + +static DEVICE_ATTR_RW(port); + static struct attribute *eud_attrs[] =3D { &dev_attr_enable.attr, + &dev_attr_port.attr, NULL, }; ATTRIBUTE_GROUPS(eud); @@ -218,6 +258,8 @@ static int eud_probe(struct platform_device *pdev) return -ENODEV; chip->mode_mgr =3D res->start; =20 + chip->port_idx =3D readl(chip->base + EUD_REG_PORT_SEL) & EUD_PORT_SEL_MA= SK; + chip->irq =3D platform_get_irq(pdev, 0); if (chip->irq < 0) return chip->irq; --=20 2.34.1 From nobody Tue Nov 24 11:35:55 2026 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=205.220.168.131 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795458535; b=UyqHjzcq4fiRUCMX3EHnSuWHHCdOZva/QyixeSM5ka5J91sOPlQpVx3N/wV27q8jtajG 1GTiZdTjGwouSTdoqUSaNrPsd8MXSzBzu776ssHsqujvp4kp73QgCrTx9U6gNgBH8IV7n 1x12B6PEwWbyvRzm9uAn6fYZWTClLudhZUqttNrROyI9zUUzPDq3ezAq1uQKtDoZTnG34 ze3yW1qL4uiSvM1264XZ2tjaXi69IchK6k9lG+4YMiU4dQk0cK3RRqIqHdv591BZDBSEu D9ckGobjc2QPVg2MG+UYgOLG5EWe7KIgToCBBHMMEqjefgA7GO4dg3gDotvy3dbRfcw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795458535; h=DMARC-Filter:Received:DKIM-Signature:Received:Received: DKIM-Signature:X-Google-DKIM-Signature:X-Forwarded-Encrypted: X-Gm-Message-State:X-Gm-Gg:X-Received:X-Received:Received:From:To:Cc: Subject:Date:Message-Id:X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding:X-Proofpoint-GUID:X-Authority-Analysis: X-Proofpoint-Spam-Info:X-Proofpoint-ORIG-GUID: X-Proofpoint-Spam-Details-Enc:X-Proofpoint-Virus-Version: X-Proofpoint-Spam-Details; bh=mHv6aWy9+lFZys5gIfbcsPXQP8IxkSSS6gptCgTCzY8=; b=LpQlYGsCg4vSW3vBoajsG+MR6nxyex7thTyG/6mKJmOJHSHQSZceB/OOwe1fB1QX4MKe +IVBuPvyEsfqkw0IJ/zTVH4IVcrzRmX1VOsHdu17cHMM0Nq8mNOBjvo8UkzWAcj3mU0tA u7622VdEU8jX7v7b8axd5D1kwrNCnYEWHrwdJm3zK4x5ujjWISgaO4BA90XKxKpYNbkDc 5T4qqIBN9huZNZSJayxkidEXP9VMc+cCb1guJ8DuKfw/J+67/6CNe1GXhYHAyg5RHbeAM zyYeEJlt+wbUlf5kUA3kMVIa4tHRvpkv06Qg+dJXInprOLOSRw+0WksVcxU23HBUdvQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=oss.qualcomm.com; spf=pass smtp.mailfrom=oss.qualcomm.com; dkim=pass header.d=qualcomm.com header.i=@qualcomm.com header.a=rsa-sha256 header.s=qcppdkim1 header.b="HTazO0L/"; dkim=pass header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.a=rsa-sha256 header.s=google header.b=ad7lawWC; arc=none smtp.remote-ip=205.220.168.131 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A46BE606A33A for ; Mon, 23 Nov 2026 18:28:54 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org A46BE606A33A Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.a=rsa-sha256 header.s=qcppdkim1 header.b=HTazO0L/; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.a=rsa-sha256 header.s=google header.b=ad7lawWC Received: from pps.filterd (m0279865.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 6ANGGnRl3025350 for ; Mon, 23 Nov 2026 18:28:54 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=qcppdkim1; bh=mHv6aWy9+lF Zys5gIfbcsPXQP8IxkSSS6gptCgTCzY8=; b=HTazO0L/4xlBhQ6odS5L8MGOK+C arZ5a1Aqn1dfk+LQujZz99ozwUsdHsPLukuDsQr6wrsIecKVr+5fKGI6VYsWBoUu UElYVXk9/SVBbHthdoLfN8xTK2SDNJkV955aM3xkDV95tEisEOzbQ5olgOOLsEOV zEHvrF3mCX33gXStixKEBCDd6r27iUjLRxI6vu0yXJgSRMRscnmYS9sj8L+5Tx0/ BUjzJtoxeaNMlt9SKPrSFDjQzUvwU9aS+Dk3h7mV/f80JiNj3DQfj0PSskNJv5pb f2M0cjOgMb5Tj3nBzN97dwyXlv9UZh/uni/ZfDmLAUcTwTDINm957Athp8w== Received: from mail-dy1-f198.google.com (mail-dy1-f198.google.com [74.125.82.198]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4j4g1pauy7-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Mon, 23 Nov 2026 18:28:53 +0000 (GMT) Received: by mail-dy1-f198.google.com with SMTP id 5a478bee46e88-38355b03cb8so3625222eec.0 for ; Mon, 23 Nov 2026 10:28:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1795458533; x=1796063333; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=mHv6aWy9+lFZys5gIfbcsPXQP8IxkSSS6gptCgTCzY8=; b=ad7lawWCPxHl7Hs8uQeqfZBmzeiLC3sPBGvYokv2jwEcy61oekTUcposrd9mx8zNPq KUcshBSurYF7npYAxHkjiyBqX3OcBfUDdVpu57y574EC+HeiVsATcbrfjNhZEpqYpnGY IW4JRUzODEZc29wCnGKpzUmL6aAQ3UHOhpW6TitSLBPTRaE70VPjrubh+k72HdqAYT7x aItWWxWf2ShE6nXiKeAiBdbKxWSI7AEx+t/YE2Qvim518F59f57SpI1Hrg3HeRP5wQcZ 9uu9yFGEzD1uCydUnvWEkQXwejbL5aLaLT9mWMxI+STqNrbxIiMFiJbDJ7/GECgO1bfB 8teQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1795458533; x=1796063333; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=mHv6aWy9+lFZys5gIfbcsPXQP8IxkSSS6gptCgTCzY8=; b=ANDYrZdM/sLaDY3LNatY1lX2Tj0ueXEgvIAp0aSjF42aZDk76BXBY9HT52sXLZmMq2 jDMfvaApEFwWZgYZfolvvEqXC9ZOhb/GYwDR7MbAXP5Q+W3lBUzLZJt8/dKkZ290yjHO 5lk32LrHUzp+FQplZ6HPWTmV3DHIWuVlrwV75lIr+0fbe5UejgQ7QjuVL4QGUKsI7EQk CTzLbi+PbIXovoGgs6y/GjuV0Stctlobks3TduHExGhrOV3VOM7zX0qZA5LDt7pY+Zm2 Dr9Kn8MMll1/9jYDQycYEYniuyKHXG+HnYdyf9cMYYNvoJ7NYmRlCOAlEGv3pesb1lel NFtQ== X-Forwarded-Encrypted: i=1; AL+hErE2rLyKrN3ZUQwc9gKRsyhzUj+eS3D6o3fD/9ooOnP/zuyRYbkEP3Vka+Mra6eCvtZE4NV/2zHGYtu6Iz0=@vger.kernel.org X-Gm-Message-State: APuU4Z/x+OxEpy/4RbwIEU/Jf+bTBjMcHrj745mA6tt7zXg5oZJYJlrb 2CB44L5JqMqjf+24JTWJDm+ChF616ThbkI3kGK8DaB6ppOP71xftwFlI6C/oxkFra0d0dyoWXcA unreigiVx8qhpwr/KAfkFVkG7vz81vjseKSqWkGSM3HtOG5aejiBnzD+ugP7njgvP+P8= X-Gm-Gg: AZFdTZeRIA+VT2DzNODFO/T01UTvvCbwmTHETStuxy7LRZXZ2YI+MEnd4g6XdQqjRxG XngZmRhYAbJ4a3LMB855BqERC/LaK2dNP3ILVulo4+LohTshhBDuCi2/AktWLKHhB+GDNmNyACY 0GbHi5rOeyGlzA/WRkKZbza1BP4YwcmZUD+/9jJkM5ei89kJSIc55LtSnq0Mnrs1jJjDsXm3sLh hDquXNqF1ZW0Jrj+AQOFHtw+dWrDJ4Uec9OC4Q24Myn51L06i9rtoJMTIaS/VjtC63ZAXn99oTw VKG5O89qFycztLrron+Ioph2gABfo7FL0P2U/7QMFNxEAckLHZAtXPg7D99ZUmN+bMIGx8EsgEF YJDDpofS2ma8qsYmwlZStFN5ViT2YlI9qRjap57ou/v/eZYF/GJUWwSqdLfKz9vR1i+fIb0yAmp 5zMIStMUDPTel22biNYSHnclAOSA== X-Received: by 2002:a05:7300:a9c:b0:386:a8a1:9855 with SMTP id 5a478bee46e88-386a8a1ade6mr5145935eec.1.1795458533219; Mon, 23 Nov 2026 10:28:53 -0800 (PST) X-Received: by 2002:a05:7300:a9c:b0:386:a8a1:9855 with SMTP id 5a478bee46e88-386a8a1ade6mr5145913eec.1.1795458532595; Mon, 23 Nov 2026 10:28:52 -0800 (PST) Received: from hu-eserrao-lv.qualcomm.com (Global_NAT1.qualcomm.com. [129.46.96.20]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-385666e99fdsm47697986eec.5.2026.11.23.10.28.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Nov 2026 10:28:52 -0800 (PST) From: Elson Serrao To: Bjorn Andersson , Conor Dooley , Greg Kroah-Hartman , Konrad Dybcio , Krzysztof Kozlowski , Rob Herring Cc: linux-arm-msm@vger.kernel.org, devicetree@vger.kernel.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Peter Chen , Konrad Dybcio , Gopikrishna Garmidi Subject: [PATCH v10 3/7] usb: misc: qcom_eud: add per-path High-Speed PHY control Date: Mon, 23 Nov 2026 10:28:43 -0800 Message-Id: <20261123182847.143892-4-elson.serrao@oss.qualcomm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20261123182847.143892-1-elson.serrao@oss.qualcomm.com> References: <20261123182847.143892-1-elson.serrao@oss.qualcomm.com> X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-GUID: 4p6Uuaz-gaukro9g8XyfAz-K9Ar7R2BG X-Authority-Analysis: v=2.4 cv=K+O3jCWI c=1 sm=1 tr=0 ts=6b0485e6 cx=c_pps a=wEP8DlPgTf/vqF+yE6f9lg==:117 a=ouPCqIW2jiPt+lZRy3xVPw==:17 a=zJRp6_cAMcgA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=Um2Pa8k9VHT-vaBCBUpS:22 a=VwQbUJbxAAAA:8 a=EUspDBNiAAAA:8 a=OKkk4dbWoaB1VCfbt-4A:9 a=bBxd6f-gb0O0v-kibOvt:22 X-Proofpoint-Spam-Info: AW1haW4tMjYxMTIzMDA3MyBTYWx0ZWRfX7hoxA3hjL4zi mYvUiaJ5Ig2sKuJ3Vx0QIlekfvE3qpRDdALq2FdTGrTwcOAwMUNuRD3iQsZJxA8ynVeaqT8USwx uxscZpYXhzekMG+kzyMU+8YgBvJDdRk= X-Proofpoint-ORIG-GUID: 4p6Uuaz-gaukro9g8XyfAz-K9Ar7R2BG X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYxMTIzMDA3MyBTYWx0ZWRfX9GGvCufk0y6g wyDJdYW+Kn79JP5Ds1/yzePj4yfH5MLFoxGrP/dgLMuG0DMBw36/btG1a9zJLBm9FUmQprhdcaa fqS2UHJh3BkJZo4tr2zp1semzaK6GxYB75baLA3WgUO4vmOtELDV0CoYt2eXM9jJ+hlO3gD95/X Zt4/oTL1uqVQew2u3eepTtLFn8X5ky0HtE/WRAYfuuJiFvPO4359s+7YDf7JC8E2qoIm3aFT8qE 9ggJpQ8SMQHenk56ShqB7n0+uneVzzI4oFaV0+E6S0SFUHiiDlBRivvUfXe4iivC9t5gacAr9Lb VRYB0UL+2ikJp5ot3QxYTx2Yvcs/Jrn01OIN1YUDJR8zARG29Q4w3O7S9dkjUVbChuHA2Dc4xuU sYafbq/8vwiUgjn7zrDOOs8MCUx04NVC9uDS95VThWT5Jc6kmJ0CPNXz9THz3rwrbSEdMRuWc+1 LagKG536GEmjmP/WSKw== X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.138,FMLib:17.12.100.49 definitions=2026-11-23_04,2026-11-23_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 malwarescore=0 spamscore=0 adultscore=0 clxscore=1015 lowpriorityscore=0 priorityscore=1501 bulkscore=0 suspectscore=0 impostorscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2611040001 definitions=main-2611230073 Content-Type: text/plain; charset="utf-8" EUD hardware can support multiple High-Speed USB paths, each routed through its own PHY. The active path is selected in hardware via the EUD_PORT_SEL register. As a High-Speed hub, EUD requires access to the High-Speed PHY associated with the active path. To support this multi-path capability, the driver must manage PHY resources on a per-path basis, ensuring that the PHY for the currently selected path is properly initialized and powered. This patch restructures the driver to implement per-path PHY management. The driver now powers the appropriate PHY based on the selected and enabled UTMI path, ensuring correct operation when EUD is enabled. Historically, EUD appeared to work on single-path systems because the USB controller kept the PHY initialized. However, EUD is designed to operate independently of the USB controller and therefore requires explicit PHY control for proper operation. Reviewed-by: Peter Chen Reviewed-by: Konrad Dybcio Tested-by: Gopikrishna Garmidi Signed-off-by: Elson Serrao --- Documentation/ABI/testing/sysfs-driver-eud | 3 +- drivers/usb/misc/qcom_eud.c | 129 ++++++++++++++++++++- 2 files changed, 130 insertions(+), 2 deletions(-) diff --git a/Documentation/ABI/testing/sysfs-driver-eud b/Documentation/ABI= /testing/sysfs-driver-eud index fb927a003596..f20b82b5a38a 100644 --- a/Documentation/ABI/testing/sysfs-driver-eud +++ b/Documentation/ABI/testing/sysfs-driver-eud @@ -20,7 +20,8 @@ Description: primary - Primary USB port secondary - Secondary USB port =20 - Writing any other value returns -EINVAL. + Writing any other value returns -EINVAL. Writing a port + not supported on the current platform returns -EOPNOTSUPP. =20 The attribute is writable only while EUD is disabled. Writing it while EUD is enabled returns -EBUSY. Reading diff --git a/drivers/usb/misc/qcom_eud.c b/drivers/usb/misc/qcom_eud.c index 3e4647acd5aa..037b074318a5 100644 --- a/drivers/usb/misc/qcom_eud.c +++ b/drivers/usb/misc/qcom_eud.c @@ -11,6 +11,8 @@ #include #include #include +#include +#include #include #include #include @@ -40,26 +42,84 @@ static const char * const eud_port_names[] =3D { "secondary", }; =20 +struct eud_path { + struct eud_chip *chip; + struct phy *phy; + u8 num; +}; + struct eud_chip { struct device *dev; struct usb_role_switch *role_sw; void __iomem *base; + struct eud_path *paths[EUD_MAX_PORTS]; phys_addr_t mode_mgr; unsigned int int_status; int irq; bool enabled; bool usb_attached; + bool phy_enabled; u8 port_idx; }; =20 +static int eud_phy_enable(struct eud_chip *chip) +{ + struct phy *phy; + int ret; + + if (chip->phy_enabled) + return 0; + + phy =3D chip->paths[chip->port_idx]->phy; + + ret =3D phy_init(phy); + if (ret) { + dev_err(chip->dev, "Failed to initialize USB2 PHY for port %u: %d\n", + chip->port_idx, ret); + return ret; + } + + ret =3D phy_power_on(phy); + if (ret) { + dev_err(chip->dev, "Failed to power on USB2 PHY for port %u: %d\n", + chip->port_idx, ret); + phy_exit(phy); + return ret; + } + + chip->phy_enabled =3D true; + + return 0; +} + +static void eud_phy_disable(struct eud_chip *chip) +{ + struct phy *phy; + + if (!chip->phy_enabled) + return; + + phy =3D chip->paths[chip->port_idx]->phy; + + phy_power_off(phy); + phy_exit(phy); + chip->phy_enabled =3D false; +} + static int enable_eud(struct eud_chip *priv) { int ret; =20 - ret =3D qcom_scm_io_writel(priv->mode_mgr + EUD_REG_EUD_EN2, 1); + ret =3D eud_phy_enable(priv); if (ret) return ret; =20 + ret =3D qcom_scm_io_writel(priv->mode_mgr + EUD_REG_EUD_EN2, 1); + if (ret) { + eud_phy_disable(priv); + return ret; + } + writel(EUD_ENABLE, priv->base + EUD_REG_CSR_EUD_EN); writel(EUD_INT_VBUS | EUD_INT_SAFE_MODE, priv->base + EUD_REG_INT1_EN_MASK); @@ -76,6 +136,8 @@ static int disable_eud(struct eud_chip *priv) return ret; =20 writel(0, priv->base + EUD_REG_CSR_EUD_EN); + eud_phy_disable(priv); + return 0; } =20 @@ -131,6 +193,10 @@ static ssize_t port_store(struct device *dev, struct d= evice_attribute *attr, if (port < 0) return port; =20 + /* Check if the corresponding path is available */ + if (!chip->paths[port]) + return -EOPNOTSUPP; + /* Port selection must be done before enabling EUD */ if (chip->enabled) return -EBUSY; @@ -228,8 +294,54 @@ static void eud_role_switch_release(void *data) usb_role_switch_put(chip->role_sw); } =20 +static int eud_init_path(struct eud_chip *chip, struct device_node *np) +{ + struct device_node *controller_node; + struct eud_path *path; + u32 path_num; + int ret; + + ret =3D of_property_read_u32(np, "reg", &path_num); + if (ret) { + /* Legacy DT uses 'ports' node without 'reg' property; treat as path 0 */ + if (of_node_name_eq(np, "ports")) + path_num =3D 0; + else + return dev_err_probe(chip->dev, ret, "unexpected child node '%s'\n", + np->name); + } + + if (path_num >=3D EUD_MAX_PORTS) + return dev_err_probe(chip->dev, -EINVAL, "invalid path number: %u (max %= d)\n", + path_num, EUD_MAX_PORTS - 1); + + path =3D devm_kzalloc(chip->dev, sizeof(*path), GFP_KERNEL); + if (!path) + return -ENOMEM; + + path->chip =3D chip; + path->num =3D path_num; + + controller_node =3D of_graph_get_remote_node(np, 0, -1); + if (!controller_node) + return dev_err_probe(chip->dev, -ENODEV, + "failed to get controller node for path %u\n", path_num); + + path->phy =3D devm_of_phy_get_by_index(chip->dev, controller_node, 0); + of_node_put(controller_node); + + if (IS_ERR(path->phy)) + return dev_err_probe(chip->dev, PTR_ERR(path->phy), + "failed to get PHY for path %d\n", path_num); + + chip->paths[path_num] =3D path; + + return 0; +} + static int eud_probe(struct platform_device *pdev) { + struct device_node *np =3D pdev->dev.of_node; struct eud_chip *chip; struct resource *res; int ret; @@ -258,7 +370,22 @@ static int eud_probe(struct platform_device *pdev) return -ENODEV; chip->mode_mgr =3D res->start; =20 + for_each_child_of_node_scoped(np, child) { + ret =3D eud_init_path(chip, child); + if (ret) + return ret; + } + + /* Primary path is mandatory. Secondary is optional */ + if (!chip->paths[0]) + return dev_err_probe(chip->dev, -ENODEV, "primary path not found\n"); + chip->port_idx =3D readl(chip->base + EUD_REG_PORT_SEL) & EUD_PORT_SEL_MA= SK; + if (!chip->paths[chip->port_idx]) { + dev_info(chip->dev, "secondary path not available, falling back to prima= ry\n"); + chip->port_idx =3D 0; + writel(chip->port_idx, chip->base + EUD_REG_PORT_SEL); + } =20 chip->irq =3D platform_get_irq(pdev, 0); if (chip->irq < 0) --=20 2.34.1 From nobody Tue Nov 24 11:35:55 2026 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=205.220.180.131 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795458537; b=vBCpFrNLuWAbwYGbaMv7qU4FnlfBSe1573ZwuZ6Ohe8+6fJFYIaqEHA2vpx+F+0h5o4G 4qzhqXxZMntGPLpVNASGE2nlID0xiPqNUkmuMfP6h6YdOHxmNoIWHOf4oy25qsdXdH8Xb nPgKeEaHWw7oDXHlAbKHTXMPRmS9HBLZMW9vqks09GJLvdv7hr5KGRmEEbSVphqfH3Wl5 asJUtgQir/98EXFSvXdYmBiEr1SxmvLieAfk0DHI4mzAPsyfmAIVRlBty2H1pVH0lo0GO 3U7nGAfC73X379bOe4Wob2mMxuZRHezk9+WTOWK1e9mpofIk3RSCEunCQ41h2NWtgqA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795458537; h=DMARC-Filter:Received:DKIM-Signature:Received:Received: DKIM-Signature:X-Google-DKIM-Signature:X-Forwarded-Encrypted: X-Gm-Message-State:X-Gm-Gg:X-Received:X-Received:Received:From:To:Cc: Subject:Date:Message-Id:X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding:X-Authority-Analysis: X-Proofpoint-Spam-Details-Enc:X-Proofpoint-GUID: X-Proofpoint-Spam-Info:X-Proofpoint-ORIG-GUID: X-Proofpoint-Virus-Version:X-Proofpoint-Spam-Details; bh=aa7OB9HEV8D+Gu4UfkUF0JaU4DkwJz3OCjuYsIDpC3s=; b=D2N7usFfuZpIJ9gZrJBtVr0HK/u36Aji6Te4f/+Qg89Z/aVTdsecJk781dQD4u1IOeKk Qp8TFql+rtUxbed3Ahs3FH4liivht1rlRj9xqfZkb/EEd8GC8XUQmdV0g8dX774Lqe44c stHIPGY9yt5CS8x1hq39Jm0vUa1MZOa/f3kUFybBgRLx29no9VrPVIMA2JfO11Ra8MEYp nft3kiRPqmWZJbl4+3zlEPRoFJBX8CRGZlSh6dpfGTb5USscJtu0O3nZH6pYgNrshxJVj ORaq7D3w2IB5F4EVSCjT9cJVw7fjoE3aLZCSAcV+FLj5MdWA7/EIrs5Sx/iPMqGTNwA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=oss.qualcomm.com; spf=pass smtp.mailfrom=oss.qualcomm.com; dkim=pass header.d=qualcomm.com header.i=@qualcomm.com header.a=rsa-sha256 header.s=qcppdkim1 header.b=D+1jT3ii; dkim=pass header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.a=rsa-sha256 header.s=google header.b=QppwnUDk; arc=none smtp.remote-ip=205.220.180.131 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8D52B606A6A1 for ; Mon, 23 Nov 2026 18:28:56 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 8D52B606A6A1 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.a=rsa-sha256 header.s=qcppdkim1 header.b=D+1jT3ii; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.a=rsa-sha256 header.s=google header.b=QppwnUDk Received: from pps.filterd (m0279869.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 6ANGH1wp3475177 for ; Mon, 23 Nov 2026 18:28:55 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=qcppdkim1; bh=aa7OB9HEV8D +Gu4UfkUF0JaU4DkwJz3OCjuYsIDpC3s=; b=D+1jT3iifaVHiQAkCPuNCBnVaZq K+khS3asIjvpXDEoJ38583Pwk491KA9v9PPudCxmYkC+mW+A2kqgVxme3FF24dB5 ZBFtpbl3bUGvdaPs+9Kx/FWN14xll1nUHTQIyqFVIXiNeaQijkmrY9XfbD6KW/mN mwQ2qqPZwy9S1Dig4i0cJNHxbDmySlBm9bq2G7/Toty4q8JAJQasNIBxyl6oaKln lMotTdxigcmspQ87TUr3LhvNV9xJvdsnBjlTthXBE5m7DUx5mCdM+DDIof2TmTze y8whsIbfQ2aEEQQyFwIBDfwJA6Vlo4FURGyPPbc2m/jjXtI0dOYE0Q4cVGA== Received: from mail-dy1-f199.google.com (mail-dy1-f199.google.com [74.125.82.199]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4j4hn7tg5k-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Mon, 23 Nov 2026 18:28:55 +0000 (GMT) Received: by mail-dy1-f199.google.com with SMTP id 5a478bee46e88-382af5cfc58so1498529eec.0 for ; Mon, 23 Nov 2026 10:28:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1795458534; x=1796063334; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=aa7OB9HEV8D+Gu4UfkUF0JaU4DkwJz3OCjuYsIDpC3s=; b=QppwnUDkS5f9AEL5lm6M5g+/YJjmA/eLFTUzaRAztqRRUUPYPJHggUSkaZJza/cG9I P2pNwYAnTRIDOD/W6R+4lP5uUMANaIjoxwePuRjZFMi2AREN+rVh2Sktb48KyzaGbn1q fMFB1+OuwODfdEMEhuLCjq4md1yxG26GFzB6HPSR6GzdCv84XK8045tSTbDD+Lduv0bP LxasFJGQWPuHSkmU957TbwrIwief1q/fjcew8qnl3qkGLNVC0aOK9UIn0W1DlqnkIUPY SqH6KuWd/C0pvJaSd6hDb1dhXWjlwyOJ0sVA7LQIpEV08APGQYr95F7UAz1jZqQjT6mI IAWw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1795458534; x=1796063334; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=aa7OB9HEV8D+Gu4UfkUF0JaU4DkwJz3OCjuYsIDpC3s=; b=HPtsvVyMT+SB7fAjth0knRjUgH0VvZocNxQjyQFeVkjxVqhZLPqqpkNqL9alK9Mvvc 35zDi4y8lVM/siUNqr+G0GSTGR236lgbRHRmQlxjmp5poTtEOdL6uIPGqPVueV1DTlV+ EJhN+nQla6aq7gGBc+sh6QVvyiVoTDzZZKjJaWJQalbd0rFEbnRu/Yb4ERiS5Ths8gLY VycSRL8nJp8uXLy+jFr3av03wuuv0chDULj4gWF0nMBpWoCzb3R/qhco8h1df4e8xGBC Xra+m+qvQl4zwLYnTGvhnnfnomKSZcXoUNsHoZ/6afRuHOEdveFzEGJUp3KKGlb+DlzB 78ZQ== X-Forwarded-Encrypted: i=1; AL+hErEFwUG/ID388Qlt11pQG0qhuHiRdie8h+7iBydWFSoQ71s42x4X6nZCRxwhyZ+jW8rUMlkGObGCcgftw+0=@vger.kernel.org X-Gm-Message-State: APuU4Z/M7eQPJVOT8WqiFMv5yKM2UCA6JHQWjEIFYB47ECFL6eR82m43 oW4/+WcAcZrAmsK19bEOK1OOO84KkZXChWyYo4ZgHSVlYJyvJMOUiXFTe7NK7Avvp7g+8MJNu7d zYLPqfPWSGz8U1G6t4FRY2sPRzuFvQ+OdtkP5FC3vRvtDpAenyUHbrsztYWcoGl6VeBs= X-Gm-Gg: AZFdTZdLHHEHmj4qWb5rjS72skOt7S2U52GJK+SG2bx9FVt8E8evT8K75l6gCsklSCF 1iSpfX6dwXcZOhLkURhJxHalz+ClBHjGplYVzzu0QsExyKMB9WqK5RyZpUnTHblUysfVXFwH4i8 pxudrGxgwec5lunEylhArz8lRYjEU8czMYFBeCjASbRRWx5T4qMmVrQIyj0bo8XbAYgUmnGXiIs MWEinwBlCcoY+g3BdPD8QqMt8y6Q+RGh5OFTvmQhl8ho5443w31CcP4XSUTNA4jvTNBBg9u9aQX q+gjoXGyy5R/DMQ4fjGCKhK/geYA3TL16ebu+6JPpiFAEr53Gw+lseYsomFiW5d4qrGAFftPK/g imkzYsJI3DvPN+PabMdVEfs2eYwo+Xt+iLZSjivkQ72AAW3ePaTTcvit9i5LLOhVE5sOkLYRW4H pJHASkzL2bSsb4TI9Xxv9gQjiYmA== X-Received: by 2002:a05:7300:ce11:b0:381:a037:b060 with SMTP id 5a478bee46e88-3856e63b3dfmr13527200eec.9.1795458534283; Mon, 23 Nov 2026 10:28:54 -0800 (PST) X-Received: by 2002:a05:7300:ce11:b0:381:a037:b060 with SMTP id 5a478bee46e88-3856e63b3dfmr13527176eec.9.1795458533724; Mon, 23 Nov 2026 10:28:53 -0800 (PST) Received: from hu-eserrao-lv.qualcomm.com (Global_NAT1.qualcomm.com. [129.46.96.20]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-385666e99fdsm47697986eec.5.2026.11.23.10.28.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Nov 2026 10:28:53 -0800 (PST) From: Elson Serrao To: Bjorn Andersson , Conor Dooley , Greg Kroah-Hartman , Konrad Dybcio , Krzysztof Kozlowski , Rob Herring Cc: linux-arm-msm@vger.kernel.org, devicetree@vger.kernel.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Peter Chen , Gopikrishna Garmidi Subject: [PATCH v10 4/7] usb: misc: qcom_eud: add per-path role switch support Date: Mon, 23 Nov 2026 10:28:44 -0800 Message-Id: <20261123182847.143892-5-elson.serrao@oss.qualcomm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20261123182847.143892-1-elson.serrao@oss.qualcomm.com> References: <20261123182847.143892-1-elson.serrao@oss.qualcomm.com> X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Authority-Analysis: v=2.4 cv=Ls0HWXdc c=1 sm=1 tr=0 ts=6b0485e7 cx=c_pps a=cFYjgdjTJScbgFmBucgdfQ==:117 a=ouPCqIW2jiPt+lZRy3xVPw==:17 a=zJRp6_cAMcgA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=_glEPmIy2e8OvE2BGh3C:22 a=VwQbUJbxAAAA:8 a=EUspDBNiAAAA:8 a=KEXfGuhMotGc95kIUyEA:9 a=scEy_gLbYbu1JhEsrz4S:22 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYxMTIzMDA3MyBTYWx0ZWRfX6vWX499nNV6R zdaBj7k7PHOBm+ZkTcbIdyCUXD4r5ru3cYyu/GgjL5A/KKtx/Lq1jXePu42nWhH00HhPMifnN9H 9Ij7V35zFsQhJeN75kImV0hX3/eMoul0Ew9T7vMNsifuwsiu7K2tM9ZVxPUNsxaTf90170sivu3 u+m4MpPaPLfLcg95iktZ1ncf4W+uoqzkKM1M0b8KYf9zolUHGMGG+dFFP6nNf+s2PYo9D7etnmp /VxcQpGXd9VAvtcqgM/0le/NepH8SK9GOAktG6qU0ZYeriBpPnY+PNvR1PBDC0yLW862lKp4EQk 6Mrzxy9NLbAlbgg7Q4lo1MnUisAzWHGheCvG7gpYaFam/2M9tGJo2SI8U4FY6PfLD86Ixy05k5B 1zEb/rqWUIlkXNdGBMO8L21yg4sCUhEUpojVk9ZxlkYItAq9I88T7qLi8msfz1AoeloeE1bpvgO rtG89aIS0ajLsG/crRg== X-Proofpoint-GUID: Av7KrYQrQVP591xcM0aaQrKPG0jA5aUk X-Proofpoint-Spam-Info: AW1haW4tMjYxMTIzMDA3MyBTYWx0ZWRfX59o01Od3xCQe 4gPQ2hyZ80d5CcWWi9ZE/h6a0PquUmZ8trdkD6uMQiPUJx+kYHygJir5fpQK8VGAcE67A4J6P88 WiGnoWhafb+gzIkYKSP6O8cscHvY1Ko= X-Proofpoint-ORIG-GUID: Av7KrYQrQVP591xcM0aaQrKPG0jA5aUk X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.138,FMLib:17.12.100.49 definitions=2026-11-23_04,2026-11-23_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 impostorscore=0 malwarescore=0 suspectscore=0 priorityscore=1501 spamscore=0 phishscore=0 lowpriorityscore=0 adultscore=0 bulkscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2611040001 definitions=main-2611230073 Content-Type: text/plain; charset="utf-8" The EUD hardware can support multiple High-Speed USB paths, each connected to different USB controllers. The current implementation uses a single chip-level role switch, which cannot properly handle multi-path configurations where each path needs independent role management. Since EUD is physically present between the USB connector and the controller, it should also relay the role change requests from the connector. Restructure the driver to support per-path role switches and remove the chip-level role switch. Additionally, as EUD need not modify the USB role upon enabling, remove the unnecessary role switch call from enable_eud(). Reviewed-by: Peter Chen Tested-by: Gopikrishna Garmidi Signed-off-by: Elson Serrao --- drivers/usb/misc/qcom_eud.c | 107 +++++++++++++++++++++++++++++------- 1 file changed, 88 insertions(+), 19 deletions(-) diff --git a/drivers/usb/misc/qcom_eud.c b/drivers/usb/misc/qcom_eud.c index 037b074318a5..2304402fc90d 100644 --- a/drivers/usb/misc/qcom_eud.c +++ b/drivers/usb/misc/qcom_eud.c @@ -45,12 +45,16 @@ static const char * const eud_port_names[] =3D { struct eud_path { struct eud_chip *chip; struct phy *phy; + struct usb_role_switch *controller_sw; + struct usb_role_switch *eud_sw; + struct device_node *np; + enum usb_role curr_role; + char name[16]; u8 num; }; =20 struct eud_chip { struct device *dev; - struct usb_role_switch *role_sw; void __iomem *base; struct eud_path *paths[EUD_MAX_PORTS]; phys_addr_t mode_mgr; @@ -124,7 +128,7 @@ static int enable_eud(struct eud_chip *priv) writel(EUD_INT_VBUS | EUD_INT_SAFE_MODE, priv->base + EUD_REG_INT1_EN_MASK); =20 - return usb_role_switch_set_role(priv->role_sw, USB_ROLE_DEVICE); + return 0; } =20 static int disable_eud(struct eud_chip *priv) @@ -271,12 +275,15 @@ static irqreturn_t handle_eud_irq(int irq, void *data) static irqreturn_t handle_eud_irq_thread(int irq, void *data) { struct eud_chip *chip =3D data; + struct eud_path *path; int ret; =20 + path =3D chip->paths[chip->port_idx]; + if (chip->usb_attached) - ret =3D usb_role_switch_set_role(chip->role_sw, USB_ROLE_DEVICE); + ret =3D usb_role_switch_set_role(path->controller_sw, USB_ROLE_DEVICE); else - ret =3D usb_role_switch_set_role(chip->role_sw, USB_ROLE_HOST); + ret =3D usb_role_switch_set_role(path->controller_sw, USB_ROLE_HOST); if (ret) dev_err(chip->dev, "failed to set role switch\n"); =20 @@ -287,17 +294,41 @@ static irqreturn_t handle_eud_irq_thread(int irq, voi= d *data) return IRQ_HANDLED; } =20 -static void eud_role_switch_release(void *data) +static int eud_role_switch_set(struct usb_role_switch *sw, enum usb_role r= ole) { - struct eud_chip *chip =3D data; + struct eud_path *path =3D usb_role_switch_get_drvdata(sw); + int ret; + + /* curr_role tracks the role from EUD's point of view */ + path->curr_role =3D role; + + /* Forward the role request to the USB controller */ + ret =3D usb_role_switch_set_role(path->controller_sw, role); + if (ret) { + dev_err(path->chip->dev, "failed to set role %s for port %u: %d\n", + usb_role_string(role), path->num, ret); + return ret; + } =20 - usb_role_switch_put(chip->role_sw); + return 0; +} + +static void eud_path_role_switch_release(void *data) +{ + struct eud_path *path =3D data; + + usb_role_switch_unregister(path->eud_sw); + usb_role_switch_put(path->controller_sw); + of_node_put(path->np); } =20 static int eud_init_path(struct eud_chip *chip, struct device_node *np) { + struct usb_role_switch_desc role_sw_desc =3D {NULL}; + struct usb_role_switch *sw; struct device_node *controller_node; struct eud_path *path; + const char *dr_mode =3D ""; u32 path_num; int ret; =20 @@ -328,14 +359,61 @@ static int eud_init_path(struct eud_chip *chip, struc= t device_node *np) "failed to get controller node for path %u\n", path_num); =20 path->phy =3D devm_of_phy_get_by_index(chip->dev, controller_node, 0); - of_node_put(controller_node); - - if (IS_ERR(path->phy)) + if (IS_ERR(path->phy)) { + of_node_put(controller_node); return dev_err_probe(chip->dev, PTR_ERR(path->phy), "failed to get PHY for path %d\n", path_num); + } =20 chip->paths[path_num] =3D path; =20 + of_property_read_string(controller_node, "dr_mode", &dr_mode); + + /* No role switch needed for fixed role controllers */ + if (!strcmp(dr_mode, "host")) { + path->curr_role =3D USB_ROLE_HOST; + of_node_put(controller_node); + return 0; + } + + if (!strcmp(dr_mode, "peripheral")) { + path->curr_role =3D USB_ROLE_DEVICE; + of_node_put(controller_node); + return 0; + } + + path->curr_role =3D USB_ROLE_NONE; + + sw =3D usb_role_switch_find_by_fwnode(of_fwnode_handle(controller_node)); + if (!sw) { + of_node_put(controller_node); + return dev_err_probe(chip->dev, -EPROBE_DEFER, + "Failed to get controller role switch for path %d\n", + path_num); + } + path->controller_sw =3D sw; + + of_node_put(controller_node); + + path->np =3D of_node_get(np); + role_sw_desc.fwnode =3D of_fwnode_handle(path->np); + role_sw_desc.set =3D eud_role_switch_set; + role_sw_desc.driver_data =3D path; + snprintf(path->name, sizeof(path->name), "eud-path%u", path_num); + role_sw_desc.name =3D path->name; + + path->eud_sw =3D usb_role_switch_register(chip->dev, &role_sw_desc); + if (IS_ERR(path->eud_sw)) { + usb_role_switch_put(path->controller_sw); + of_node_put(path->np); + return dev_err_probe(chip->dev, PTR_ERR(path->eud_sw), + "Failed to register EUD role switch for path %d\n", path_num); + } + + ret =3D devm_add_action_or_reset(chip->dev, eud_path_role_switch_release,= path); + if (ret) + return ret; + return 0; } =20 @@ -352,15 +430,6 @@ static int eud_probe(struct platform_device *pdev) =20 chip->dev =3D &pdev->dev; =20 - chip->role_sw =3D usb_role_switch_get(&pdev->dev); - if (IS_ERR(chip->role_sw)) - return dev_err_probe(chip->dev, PTR_ERR(chip->role_sw), - "failed to get role switch\n"); - - ret =3D devm_add_action_or_reset(chip->dev, eud_role_switch_release, chip= ); - if (ret) - return ret; - chip->base =3D devm_platform_ioremap_resource(pdev, 0); if (IS_ERR(chip->base)) return PTR_ERR(chip->base); --=20 2.34.1 From nobody Tue Nov 24 11:35:55 2026 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=205.220.180.131 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795458538; b=lvcjUcymbHLZl18WUDEBFfe1PVu8t6KnrPA0RLui/ajbvEH6b9DmOGMeV7N54q8/sxhc Loc0l2p4D1bliFBw2jluS3R6cLjjEBQDabVM+J/k2it60Yx00thbse7w16kVGLSxEOseR c/jdbuK/yRhg0iwuGCwY0vJYOxkDZRqe5GWDw6linnG1s0Vq5VcahKAOai9gak6/cgVHG l7o5S9dBCgK/N+8LbA9/h+pCpgWip7V2IzVnA6ckWN5XIdObnwukEQke6Kt3eTcnuwvQ0 F6dmJpYP8P+0HpGe1WmIxUP+qV55kgTldsHbLFYp7mparHFMgxPcTtE8kQxkIUVVxDQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795458538; h=DMARC-Filter:Received:DKIM-Signature:Received:Received: DKIM-Signature:X-Google-DKIM-Signature:X-Forwarded-Encrypted: X-Gm-Message-State:X-Gm-Gg:X-Received:X-Received:Received:From:To:Cc: Subject:Date:Message-Id:X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding:X-Proofpoint-Spam-Info:X-Proofpoint-GUID: X-Proofpoint-Spam-Details-Enc:X-Proofpoint-ORIG-GUID: X-Authority-Analysis:X-Proofpoint-Virus-Version: X-Proofpoint-Spam-Details; bh=nhfcchwZrq5HVAFa+r5LC2cvCNyvuS6jjcv2doVhkDU=; b=BnHeWocgCpOkS7NhfWyKcT9e9bOV6nEXCcmtEBfI8HRGfHnHDq5NrLpzarbLYwyvp24Y 3Bspz185KQI6cycvF1pYQWAP7NfWyyXIcUQM4A7SYmujs8rduu3y/82iMUYT1BUpp6TUk /qDT3eAFV4j5MMXDUPAyDF3c4xLR96l2bEqVbjm96fvMZP9AUHU5gVca7eQpZIKgWsrQw kKRqMKWfQi1Hd3ebX0rWFmAm4Aqc28zDcpObRaGqRfIidmd9r2slm1CHB/ZgmB90eGln4 HSVXf6g1aBt3OAO03bR1mWCGIM79kx7CQaBIH5SrGmpvkvXA9iOyzUS7mxDexRej+9A== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=oss.qualcomm.com; spf=pass smtp.mailfrom=oss.qualcomm.com; dkim=pass header.d=qualcomm.com header.i=@qualcomm.com header.a=rsa-sha256 header.s=qcppdkim1 header.b=M9BSbVdI; dkim=pass header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.a=rsa-sha256 header.s=google header.b=fK0KR2ha; arc=none smtp.remote-ip=205.220.180.131 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9DEE560A261B for ; Mon, 23 Nov 2026 18:28:57 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 9DEE560A261B Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.a=rsa-sha256 header.s=qcppdkim1 header.b=M9BSbVdI; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.a=rsa-sha256 header.s=google header.b=fK0KR2ha Received: from pps.filterd (m0279870.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 6ANGGvej2844360 for ; Mon, 23 Nov 2026 18:28:56 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=qcppdkim1; bh=nhfcchwZrq5 HVAFa+r5LC2cvCNyvuS6jjcv2doVhkDU=; b=M9BSbVdI1BAMdhptdNQDL4nVZz1 rEjTTxVHCT5UZS1IIOs9jPja/Wot9/8SjIdyJuhZLgAWVvb+tVuWe38LOjR8+4s8 LiKBvrfdpOvoVmv9sgREwPpttVAP9lEzuPLQNmnNU1lAN2BV+BfFMqNKlVOI6WMk dYDQb1z1EV1nW9jj0QGcfbWkydajRhwDmB6w4AES8WlaS10GqaA1yM1USBsHILog F1OtBUMeau5y19Jn11LA35R7XwbCc/v+dQCyattQZsIjK3YFWStkjZn8121fLEdV E8EaGNkR/EdtxUjqnFF+WaLuF28qadDHDxrHwKAMm8yHjzglgm2VDPRlB+w== Received: from mail-dy1-f197.google.com (mail-dy1-f197.google.com [74.125.82.197]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4j4g1k2v0m-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Mon, 23 Nov 2026 18:28:56 +0000 (GMT) Received: by mail-dy1-f197.google.com with SMTP id 5a478bee46e88-384c78aa0dbso5048659eec.0 for ; Mon, 23 Nov 2026 10:28:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1795458535; x=1796063335; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=nhfcchwZrq5HVAFa+r5LC2cvCNyvuS6jjcv2doVhkDU=; b=fK0KR2haXbhjn09icUiF5k5tTPdJ+GtC7WJPAsIQcQ3vH6BbWYGdTTfAtnkA2F9qGd wNeidrgdPseOKYSouPW3sc+Yt7zjrlJmufbnOIPyMXKITvYPLF1pVZS+Yyqv8RyfpuLt bISwVR2gLFexPq2O28sq7gildWcryuFtXcSOh8eFVnxTL49GHvKc/bwZID3qzrJjKVfW Iu8xYGHGS5vS9DH4OHBpPtsWaNq3gL8Zbm4yM0ZXWTtMYGv+3kO90gwTtGx0zWbNqp/x ZrsIz+KqAnaNS21+iXpNunlzLRtjQ2bl9uJgB3Y5dvyfvmTOFMnpfpuOuHK4GnCpDSdh 0Iiw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1795458535; x=1796063335; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=nhfcchwZrq5HVAFa+r5LC2cvCNyvuS6jjcv2doVhkDU=; b=SyO2wzzzwUHlvTPiu0D6QozCTWKT5NnKSTfYw74MMEBPTF/fl0H0QUQARm2cCkeXW/ vNB1isc6KpdGS+kuc0Y2kRRw/Tt/c499Tum+SX+1VmQGUgUQ3JH+gdfoZhtiUHxwrn84 jVnSYZ6V6NQW0oxr473pN2f3kYoFpflH2B+IeonwUxlBr/olo74+92Z1gXleeHrqm/CN JFc5Tty/OI3h2rL+WnJmrSWbVkIVGCilNRp/A1AuuNbZUuJmyd3AxoUOWtIlw1l2kdFo M6ayHooSI5V8bF3g61dIbXkxRng9Yym2ZQjFjp00L18enXsQf+P2VixtPqD/gyaB0L9+ cQDA== X-Forwarded-Encrypted: i=1; AL+hErHf21D9ATfu0eQdQXICgT2O6jR+LQTZem228tlLH/ttJp3YlRKQpouUBRjDr4NcPxQgqW0JhyKnOdzs7O8=@vger.kernel.org X-Gm-Message-State: APuU4Z8t18chENbtuIl4bx+6ezZSSwZPggGaF1U0QjiOqV3HWsC25O9y crLTULgQNOtWmRu1kqthf4ZqhJJofbFH0mILl4fvM2iKwlhIg/H3mC84f1QVigSJnfdjnyQYUYR ujdrHXDonTxRIZWg304Dg7MppSrdzU3wlZVvVU81X8w76i+2qpqJGu1ZQ7Ur04ebp2to= X-Gm-Gg: AZFdTZcUoAKT0+mi4O0Pss84XRu7Ll0IpxThNQM0SLWY1aQuZcVbsPKGltIOkgsZiGb 4WSEfIu9/X4+olFnqUluuQ+Jig7YmjKTLsXP9a0bQyqmNM4G38X0V486P9L55Ppui8qczTawRCy IzxApjRs93CYKsB1Y8RyCGAbBJdF/e1L+TsahretemDk0EP1VYOhCzh6AHv1Di7+3DMcDvx2t7d LFKrOIJVF0ebc4vC+Zl51A7qOdEq/StPwB9/uBh+5tNZtrvYu64K78s0IGAIbU6I0YZC3PcpIHn MsayIfV8p9f9SUSYFNtaUF2ppXEgIJ5xJrjzR3E2cRruEHtrmsNrmW0ec0+dN9VyVifNEY/zQtM jnDvBTyIwC7bqdrVjiox4blH9/zyMGP0x9vBen+ybplSvRnWe9+QVO8Ls3Egr35SsxtluWMVhDJ w5HC7NLJuhxYMpuVQujKCN7QzecA== X-Received: by 2002:a05:693c:638d:20b0:375:c862:31c with SMTP id 5a478bee46e88-38571816d35mr12339167eec.40.1795458535492; Mon, 23 Nov 2026 10:28:55 -0800 (PST) X-Received: by 2002:a05:693c:638d:20b0:375:c862:31c with SMTP id 5a478bee46e88-38571816d35mr12339143eec.40.1795458534987; Mon, 23 Nov 2026 10:28:54 -0800 (PST) Received: from hu-eserrao-lv.qualcomm.com (Global_NAT1.qualcomm.com. [129.46.96.20]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-385666e99fdsm47697986eec.5.2026.11.23.10.28.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Nov 2026 10:28:54 -0800 (PST) From: Elson Serrao To: Bjorn Andersson , Conor Dooley , Greg Kroah-Hartman , Konrad Dybcio , Krzysztof Kozlowski , Rob Herring Cc: linux-arm-msm@vger.kernel.org, devicetree@vger.kernel.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Konrad Dybcio , Peter Chen , Gopikrishna Garmidi Subject: [PATCH v10 5/7] usb: misc: qcom_eud: improve enable_store API Date: Mon, 23 Nov 2026 10:28:45 -0800 Message-Id: <20261123182847.143892-6-elson.serrao@oss.qualcomm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20261123182847.143892-1-elson.serrao@oss.qualcomm.com> References: <20261123182847.143892-1-elson.serrao@oss.qualcomm.com> X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-Spam-Info: AW1haW4tMjYxMTIzMDA3MyBTYWx0ZWRfX5eZpqeiewLPf v0Soq8FZHqNCWE7qo5dGOY/acaBLSDw0V12UEc/sY6IpXDUdOJvOn1fNbnEyWruiKHA9S7yRuB6 9wX0D7H4TXdn8UPx4XlFYVpPIVJ9yBw= X-Proofpoint-GUID: e65812-3HO1LXRy7OcTcW4KHBmc23Imq X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYxMTIzMDA3MyBTYWx0ZWRfX8Fln+XzTFUwF ANyrnGA1saYilJqNJDMsaKTO1kHSI33H/ykd3j7FrCaokRM5rfWYBYOVUQKH7LlPSkmyZA38VWR KTwXwKeAN+5AdjkkSacpiHvtymraedyxvjwdqDIKxUqSOgRyrX8Vo3UdNq0qGrMAUSDB2mt0ke1 0cj91lu/FTrVL3cj7yG4U2K7ENNjUngk1Yzx44m8MXHLB211biJgs3AxjbTixQEh4mQ7K/+6Pe3 M+2N6ZSxvIGiWNBVdQLRo11HcxKANakYlMcsi/+q2SJ0SyHWiMh29ZkESbWlbU9/kp30X+8/Lvj kb2A/lX3GNMaIjEc7pCaVv9x3Rh4VEvm/Joq7AYyYmj9oPIKB6QTu2rzdNe+mcuXqPbL/yLu/RA lU0soMcbuVqBGBFFgk+JTwELPwAGTuIYxm1Grir5tJi3QjLfQ9NiGAVBh9YBNYnVZrov+1uvyin yeA2WDpdM8o1FJ06gpw== X-Proofpoint-ORIG-GUID: e65812-3HO1LXRy7OcTcW4KHBmc23Imq X-Authority-Analysis: v=2.4 cv=cpIOAF4i c=1 sm=1 tr=0 ts=6b0485e8 cx=c_pps a=Uww141gWH0fZj/3QKPojxA==:117 a=ouPCqIW2jiPt+lZRy3xVPw==:17 a=zJRp6_cAMcgA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=gowsoOTTUOVcmtlkKump:22 a=EUspDBNiAAAA:8 a=VwQbUJbxAAAA:8 a=iEam2xx7WbKG8qDqzoQA:9 a=PxkB5W3o20Ba91AHUih5:22 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.138,FMLib:17.12.100.49 definitions=2026-11-23_04,2026-11-23_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 lowpriorityscore=0 adultscore=0 impostorscore=0 suspectscore=0 bulkscore=0 spamscore=0 clxscore=1015 priorityscore=1501 phishscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2611040001 definitions=main-2611230073 Content-Type: text/plain; charset="utf-8" Currently enable_store() allows operations irrespective of the EUD state, which can result in redundant operations. Avoid this by adding duplicate state checks to skip requests when EUD is already in the desired state. Additionally, improve error handling with explicit logging to provide better feedback. Reviewed-by: Konrad Dybcio Reviewed-by: Peter Chen Tested-by: Gopikrishna Garmidi Signed-off-by: Elson Serrao --- drivers/usb/misc/qcom_eud.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/drivers/usb/misc/qcom_eud.c b/drivers/usb/misc/qcom_eud.c index 2304402fc90d..9f26231b6648 100644 --- a/drivers/usb/misc/qcom_eud.c +++ b/drivers/usb/misc/qcom_eud.c @@ -164,18 +164,27 @@ static ssize_t enable_store(struct device *dev, if (kstrtobool(buf, &enable)) return -EINVAL; =20 + /* Skip operation if already in desired state */ + if (chip->enabled =3D=3D enable) + return count; + if (enable) { ret =3D enable_eud(chip); - if (!ret) - chip->enabled =3D enable; - else - disable_eud(chip); - + if (ret) { + dev_err(chip->dev, "failed to enable eud\n"); + return ret; + } } else { ret =3D disable_eud(chip); + if (ret) { + dev_err(chip->dev, "failed to disable eud\n"); + return ret; + } } =20 - return ret < 0 ? ret : count; + chip->enabled =3D enable; + + return count; } =20 static DEVICE_ATTR_RW(enable); --=20 2.34.1 From nobody Tue Nov 24 11:35:55 2026 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=205.220.180.131 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795458538; b=0fIRkeCJRVY2XdVUVbDP6UQmKWlm4ofYo2bnA1x8R0Kk6BYkUyzY4HalMVw+6DXD5Iz4 M2gtM4Y/bzl93canVaDBgivx83uhk8aSDZTbQtp7ZTQib2Ishj73tFfxGhs/0G9m4D9IY BTFBbUqy/D2sXq0JIuBKIdvm0/DJyXjvJsLUUw0mLKrb2qea7G7uUx6zLlCiFyp/DXxWr i1d4yq1kl6IlAz5ZHqXARzzL/lpIF5+VEMf4cC4ANTcf0Nv3YSsuNjGMsN/moA6AsrWsh He3M7ocMKrVOWvZx10O21vbVruS87lzc5/KoxYGGehQM0G0j92qooVhbba4mFSxeFsw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795458538; h=DMARC-Filter:Received:DKIM-Signature:Received:Received: DKIM-Signature:X-Google-DKIM-Signature:X-Forwarded-Encrypted: X-Gm-Message-State:X-Gm-Gg:X-Received:X-Received:Received:From:To:Cc: Subject:Date:Message-Id:X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding:X-Proofpoint-Spam-Info:X-Proofpoint-GUID: X-Proofpoint-Spam-Details-Enc:X-Proofpoint-ORIG-GUID: X-Authority-Analysis:X-Proofpoint-Virus-Version: X-Proofpoint-Spam-Details; bh=/JIMNzd1d/PnQF2mlgIJ7k4900jCYz2iwph5AnTrVXE=; b=FrevGuMYNc69nOjrjgfo4JUR6vQKSa/+oUUgDrQHYOfvUlOet4LpFGoZglT9c9/nceWq xi1E1wvXxeCSm5Y4nnGuLhgvCBO/RljUhKXqoB4monZbXupaCVdVQK7jQ6yJJm2sr4tnv /4StAjVaRgUgLgYvTI7cpHR3lrOfy+3DfjGhiPPGxg4ytaBQP2enHU9UGcE/7IrFsD8+6 rDg7TIH0jE52xO8s1ySbmbcIjojePbJk3GDuLTwrRjGDvsGRIjszs8PgtNYS44szVucXS v9vIiuX8v+cjHISQZr2GapFouR6bchW/QViLlAwtXPreBOJH5O28wBi3M4jFK2FQbMg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=oss.qualcomm.com; spf=pass smtp.mailfrom=oss.qualcomm.com; dkim=pass header.d=qualcomm.com header.i=@qualcomm.com header.a=rsa-sha256 header.s=qcppdkim1 header.b="Ox9I/lp4"; dkim=pass header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.a=rsa-sha256 header.s=google header.b=LMxIRIos; arc=none smtp.remote-ip=205.220.180.131 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 74C3860A261A for ; Mon, 23 Nov 2026 18:28:58 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 74C3860A261A Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.a=rsa-sha256 header.s=qcppdkim1 header.b=Ox9I/lp4; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.a=rsa-sha256 header.s=google header.b=LMxIRIos Received: from pps.filterd (m0279870.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 6ANGH1I62844425 for ; Mon, 23 Nov 2026 18:28:57 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=qcppdkim1; bh=/JIMNzd1d/P nQF2mlgIJ7k4900jCYz2iwph5AnTrVXE=; b=Ox9I/lp4PWHFSxmIOZ+GxV80YH8 7L99/xEhj0cdIP3C68Qaqbe/rqXO9+uEBnPJp3TyGRk+jlLHF0tgI79ttKvpKrSF iSAMOIS88CZG/K8DlfoOcb4FzijuTaS0JBnA/5CDuaC6dxezDfMv22+xwhFfqKmX rmm2ZEI7NceGgaPomiNnLZky5IZadDA+755q8QX2y0r5dPHmPFdVlEhCUTAegAwv EZBgokAVzZ+Dvpc+eSflfYhQt4cyPpmibAszRB36NRL5NGfpNqfBHJEDVF8mm4Cz yVwLKg2xHd7vDwsQHPQFP6Jxa1YMqMv7/cTKeUvIIPnYH4Ol19KhNoL9oLA== Received: from mail-dy1-f197.google.com (mail-dy1-f197.google.com [74.125.82.197]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4j4g1k2v0p-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Mon, 23 Nov 2026 18:28:57 +0000 (GMT) Received: by mail-dy1-f197.google.com with SMTP id 5a478bee46e88-383ec96a7deso4109843eec.1 for ; Mon, 23 Nov 2026 10:28:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1795458537; x=1796063337; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=/JIMNzd1d/PnQF2mlgIJ7k4900jCYz2iwph5AnTrVXE=; b=LMxIRIosMCjDuYCROLVgnVnLXB9cVntONOsD75/0Lebvd3lUkioSkCq9Jhbuqt0z/k 2TfA6I1xay9oVqfOgv/iSGbWemrVMgbW6Sm3gcg5i/vgDqzeAENWNO6Gpz/yJX0L7z2q Yo2ceG4/wBDmiBA2hZJ+nc03eVO0ztjp5dN5iiXf9BpcuoZXZyTyknBB1wrDjzpFbkBK VTodmr/V4mESGdB7tKu0+j3wxXSDcUBFI4qdfEtNqPCa88eMvqK/sAy7GWB6R1mGVDKm vWm+N3WmArjTz2fCf2c0vmwIV9SjCOOgQC9iX8ZYTXkOXVX+2cWEuJZ7wke6dRisZXSR 7oZw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1795458537; x=1796063337; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=/JIMNzd1d/PnQF2mlgIJ7k4900jCYz2iwph5AnTrVXE=; b=vqfHpO/jUJwgH/T0Grj6TNdaw6+6qDCr8e3Q5WKQHsNcvvReQ0d2xPtmOC8RvP5oSa 9XfGFJc3BjwUZAUB+C86sICcCl8egKnp69C2QisBSIw5XmwkzFsd7dnxdOt7CWiGA+JC HubW7z6h7t650PiXUJ2oklYd30kWmGc2v8LbNd6wiS9wEqCejlCohwzJeG/a0aH/D70p Bi0CFb30q17pzU862r9TmeB3a1ImIwEKc2Q7F7iZsrzER60CaUtS1pUeERb5VRzwOA9O H7dpZT+BZon7pvFyjyTb1ElN3n5XR1FLsW/xHeRdUkSRTPK0pToWTej5kxQ7NRmi5RtE t5xg== X-Forwarded-Encrypted: i=1; AL+hErEHdWaA4tkLlXl+EPxAaIQRVUwxUTG+ZMqOfq6kNTs3+ewHY2GsplVsmJ6R00nyAlWLG8dWOXpAzpx95U0=@vger.kernel.org X-Gm-Message-State: APuU4Z+VOiYdkp7eXKwniP8bkverZLoanPMqiwp851viQcMS3R5OjI/v lXxHTl7dyYUNZ1MQ4trqGojbscd3sAHxCqL3m29bDULYwrK0wZd3fLdYV273GQj/7P7WE3/2gJv zWxFxNbnobKfuhzvJ6p0S3dzqe0dC8vmi4Fhh/Dy53IwODxPG4DQOGUg7YI3Z0h63INM= X-Gm-Gg: AZFdTZfD3bNCg5vQhH0MyeyezO26DEqWLOwa5CBhkgxRupxkfZhagGmivAVpxDpI6e2 QHGxYB3r6pBhfaUeG7An/0p9XmSehrE/dosKBjSZ6vuJl/tQK+Wv6TI6P+0N3IwObkzwbqgJqpM sw0+Jvv7QEGz19X5ZFZyQPrXCBDydOggNKJfzIShuC+/fCntrqyHoiDeW9wkdDOqyqK06t7guMB TAudAh2udubkQZagi96a0ZxY2gy7SBtxbGLEHS5oW3sn9V/VAV7tMuyxqEnh065JakiucpdhwE7 Jgm9kC1WqgDolW7w5NKwKzs5FIfbd5lnT1vvYnsSxeerFBh/VgFSIwTI8uEf96dDOOlwyMoOPa+ ahk+5tAfXSCGKVE3D2q1wDzePo1GN8zAyw8YRem5qCVDVSYhT0Gzs/JEG3s7IfjTxOKJqHMnq8y enHmYqBFWBt+Inmez8MyLzFzdtAA== X-Received: by 2002:a05:7301:6405:b0:381:a3bb:f945 with SMTP id 5a478bee46e88-38570254ec3mr14795678eec.22.1795458536464; Mon, 23 Nov 2026 10:28:56 -0800 (PST) X-Received: by 2002:a05:7301:6405:b0:381:a3bb:f945 with SMTP id 5a478bee46e88-38570254ec3mr14795656eec.22.1795458535965; Mon, 23 Nov 2026 10:28:55 -0800 (PST) Received: from hu-eserrao-lv.qualcomm.com (Global_NAT1.qualcomm.com. [129.46.96.20]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-385666e99fdsm47697986eec.5.2026.11.23.10.28.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Nov 2026 10:28:55 -0800 (PST) From: Elson Serrao To: Bjorn Andersson , Conor Dooley , Greg Kroah-Hartman , Konrad Dybcio , Krzysztof Kozlowski , Rob Herring Cc: linux-arm-msm@vger.kernel.org, devicetree@vger.kernel.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Peter Chen , Konrad Dybcio , Gopikrishna Garmidi Subject: [PATCH v10 6/7] usb: misc: qcom_eud: add role-based EUD control Date: Mon, 23 Nov 2026 10:28:46 -0800 Message-Id: <20261123182847.143892-7-elson.serrao@oss.qualcomm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20261123182847.143892-1-elson.serrao@oss.qualcomm.com> References: <20261123182847.143892-1-elson.serrao@oss.qualcomm.com> X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-Spam-Info: AW1haW4tMjYxMTIzMDA3MyBTYWx0ZWRfXxlNZJu4vvj+N B5aRnp4AfGkUE51wE7bxT1vjaAlarI8FSrCy8g1DaoRhvlZH8J6AFrOCDbp6sLkw7AVRmDZ5Mj2 Dq1taJ8R/pUCovBV+dY/wMBH1V3cJhM= X-Proofpoint-GUID: s8NcENvWQcgndn40bQpyvDhUyB7f7pxV X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYxMTIzMDA3MyBTYWx0ZWRfX+nIKDUBbND5X Oxbms3ThbHTaQgq+3bBVp4UKz3WfYN8ZuRWw9Ot5kNE7Sbics/T77Xnz9nnfpDlKkGMqQ2jvF00 qSPqDg8/U7Rmb4DiZBCt1EuBqBhHthsx6cbtZarARAEFKt4mWK2Y6z/b9ALwRzdu6arVV3ecftQ ygSZp1dIScbgBDNooVuv70GeUQOcG9vAYjRRVFoW4XV0Zqq+rNU3Xrm5fueuFb8Cz5u4wtnMdQ1 qFUyMjH2NOG4HVR6+NlK7jco/NvIM6Zu/IYbHFK4Zo3pjr0J75ERR+0HFExE7UbVX6yoxcrxGsu 1ceZRH+A8CT5H961uuk1deZk8Mwf1IdcmRqP/LJ83FXjqHzVkKfk/z8b3RNIBXPQ2UGYkHKUeN9 t68yXcCIiNUr+tlVBL4N/0Pb9mNA5StOX/HZuMYI2a2mbWe2TC8xHN3UOE4jG0KiavX4KLl9QaZ KKp7TGXAaisCJhtGnbQ== X-Proofpoint-ORIG-GUID: s8NcENvWQcgndn40bQpyvDhUyB7f7pxV X-Authority-Analysis: v=2.4 cv=cpIOAF4i c=1 sm=1 tr=0 ts=6b0485e9 cx=c_pps a=Uww141gWH0fZj/3QKPojxA==:117 a=ouPCqIW2jiPt+lZRy3xVPw==:17 a=zJRp6_cAMcgA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=gowsoOTTUOVcmtlkKump:22 a=VwQbUJbxAAAA:8 a=EUspDBNiAAAA:8 a=YKK-c5bBAu3nLoGgrlsA:9 a=PxkB5W3o20Ba91AHUih5:22 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.138,FMLib:17.12.100.49 definitions=2026-11-23_04,2026-11-23_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 lowpriorityscore=0 adultscore=0 impostorscore=0 suspectscore=0 bulkscore=0 spamscore=0 clxscore=1015 priorityscore=1501 phishscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2611040001 definitions=main-2611230073 Content-Type: text/plain; charset="utf-8" EUD functions by presenting itself as a USB device to the host PC and is therefore only applicable when the port operates in device role. Keeping EUD enabled in other roles provides no benefit and unnecessarily keeps the associated PHY resources enabled. Furthermore, enabling EUD in host role can cause the USB controller to misbehave because the EUD hub supports only a single upstream-facing port. Address this by treating EUD as usable only in device role. The role-switch callback enables or disables EUD as the port enters or leaves device role. A sysfs enable request made outside device role is recorded and honored when the port subsequently switches to device role. Additionally, synchronize EUD state management across different paths to avoid races and maintain consistent hardware state. Reviewed-by: Peter Chen Reviewed-by: Konrad Dybcio Tested-by: Gopikrishna Garmidi Signed-off-by: Elson Serrao --- drivers/usb/misc/qcom_eud.c | 70 ++++++++++++++++++++++++++++++++----- 1 file changed, 62 insertions(+), 8 deletions(-) diff --git a/drivers/usb/misc/qcom_eud.c b/drivers/usb/misc/qcom_eud.c index 9f26231b6648..b434b0447613 100644 --- a/drivers/usb/misc/qcom_eud.c +++ b/drivers/usb/misc/qcom_eud.c @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include @@ -57,6 +58,8 @@ struct eud_chip { struct device *dev; void __iomem *base; struct eud_path *paths[EUD_MAX_PORTS]; + /* serializes EUD control operations */ + struct mutex state_lock; phys_addr_t mode_mgr; unsigned int int_status; int irq; @@ -158,17 +161,33 @@ static ssize_t enable_store(struct device *dev, const char *buf, size_t count) { struct eud_chip *chip =3D dev_get_drvdata(dev); + struct eud_path *path; bool enable; int ret; =20 if (kstrtobool(buf, &enable)) return -EINVAL; =20 + guard(mutex)(&chip->state_lock); + /* Skip operation if already in desired state */ if (chip->enabled =3D=3D enable) return count; =20 if (enable) { + path =3D chip->paths[chip->port_idx]; + + /* + * If not yet in device role, honor the userspace request and defer + * EUD enablement until the port transitions to device role in the + * set_role callback. + */ + if (path->curr_role !=3D USB_ROLE_DEVICE) { + dev_info(chip->dev, "Deferring EUD enable until port enters device mode= \n"); + chip->enabled =3D enable; + return count; + } + ret =3D enable_eud(chip); if (ret) { dev_err(chip->dev, "failed to enable eud\n"); @@ -206,6 +225,8 @@ static ssize_t port_store(struct device *dev, struct de= vice_attribute *attr, if (port < 0) return port; =20 + guard(mutex)(&chip->state_lock); + /* Check if the corresponding path is available */ if (!chip->paths[port]) return -EOPNOTSUPP; @@ -287,14 +308,18 @@ static irqreturn_t handle_eud_irq_thread(int irq, voi= d *data) struct eud_path *path; int ret; =20 + guard(mutex)(&chip->state_lock); + path =3D chip->paths[chip->port_idx]; =20 - if (chip->usb_attached) - ret =3D usb_role_switch_set_role(path->controller_sw, USB_ROLE_DEVICE); - else - ret =3D usb_role_switch_set_role(path->controller_sw, USB_ROLE_HOST); - if (ret) - dev_err(chip->dev, "failed to set role switch\n"); + if (chip->enabled && path->curr_role =3D=3D USB_ROLE_DEVICE) { + if (chip->usb_attached) + ret =3D usb_role_switch_set_role(path->controller_sw, USB_ROLE_DEVICE); + else + ret =3D usb_role_switch_set_role(path->controller_sw, USB_ROLE_HOST); + if (ret) + dev_err(chip->dev, "failed to set role switch\n"); + } =20 /* set and clear vbus_int_clr[0] to clear interrupt */ writel(BIT(0), chip->base + EUD_REG_VBUS_INT_CLR); @@ -306,7 +331,30 @@ static irqreturn_t handle_eud_irq_thread(int irq, void= *data) static int eud_role_switch_set(struct usb_role_switch *sw, enum usb_role r= ole) { struct eud_path *path =3D usb_role_switch_get_drvdata(sw); - int ret; + struct eud_chip *chip =3D path->chip; + int ret =3D 0; + + guard(mutex)(&chip->state_lock); + + /* + * EUD is usable only in device role. Power it down for every other + * role to avoid keeping an unusable module 'ON'. chip->enabled + * preserves user's sysfs configuration and is not modified across + * role transitions. + */ + if (chip->enabled && path->num =3D=3D chip->port_idx && role !=3D path->c= urr_role) { + if (role =3D=3D USB_ROLE_DEVICE) + ret =3D enable_eud(chip); + else if (path->curr_role =3D=3D USB_ROLE_DEVICE) + ret =3D disable_eud(chip); + + if (ret) { + dev_err(chip->dev, "failed to %s EUD for role %s: %d\n", + str_enable_disable(role =3D=3D USB_ROLE_DEVICE), + usb_role_string(role), ret); + return ret; + } + } =20 /* curr_role tracks the role from EUD's point of view */ path->curr_role =3D role; @@ -439,6 +487,8 @@ static int eud_probe(struct platform_device *pdev) =20 chip->dev =3D &pdev->dev; =20 + mutex_init(&chip->state_lock); + chip->base =3D devm_platform_ioremap_resource(pdev, 0); if (IS_ERR(chip->base)) return PTR_ERR(chip->base); @@ -485,8 +535,12 @@ static void eud_remove(struct platform_device *pdev) { struct eud_chip *chip =3D platform_get_drvdata(pdev); =20 - if (chip->enabled) + mutex_lock(&chip->state_lock); + if (chip->enabled) { disable_eud(chip); + chip->enabled =3D false; + } + mutex_unlock(&chip->state_lock); =20 device_init_wakeup(&pdev->dev, false); disable_irq_wake(chip->irq); --=20 2.34.1 From nobody Tue Nov 24 11:35:55 2026 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=205.220.168.131 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795458539; b=J6dnqBvWepvgplCZFIKRKsoCoj0iPridt3XOPZYYulgUaMxz4GxWKTB3/xkAOD1hRoAe 47XAKP9yJdgvf4ThxCJz+e91QncU2F9m47qTKM91chsfqO3QXjfBnTXevTugBG0n0asSN KUjsezoK4en8Eox4AqaL+5bErxXovTezJIb6QoZHXGVcLENWgWpA5gOrVKcw4y9vpgY3M n0im+krxFqFDXPVeMhOuniKC1j2pPWTzSB/9wMMQr/Pri58rsgfsxJaBy8YECi57lmKVN lDcqiSSIce3Oq7spmpo3ymlezRyZKd2Zp0xMT3vQOhlbzdS9j/nndABu+rOv5fIHf7Q== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795458539; h=DMARC-Filter:Received:DKIM-Signature:Received:Received: DKIM-Signature:X-Google-DKIM-Signature:X-Forwarded-Encrypted: X-Gm-Message-State:X-Gm-Gg:X-Received:X-Received:Received:From:To:Cc: Subject:Date:Message-Id:X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding:X-Proofpoint-Spam-Info: X-Proofpoint-Spam-Details-Enc:X-Proofpoint-ORIG-GUID: X-Authority-Analysis:X-Proofpoint-GUID:X-Proofpoint-Virus-Version: X-Proofpoint-Spam-Details; bh=Sm66atK5a1c4jXuGmjJn9AG8ISnOiMI7T154hnwnUtc=; b=GyLIxY51ord/cM8aKQtijrw3Q0+STxQSalSBURKXKkXGLgm6YOYzfob8gXc6YMQatrHh fwHCOXN4gm3IGlCV0d7AEcx89NZcnO9QwiQF758IfrZBjXuCrTDfZnIHV7HfATHU0q0ac CeTg8xNP7x0RyCxwysv7eH8k7K1BCs6v0mdwtRv4O77rLqkAOMMiEnG05F+yOUq5cL3iB PnF9WA1WwocoLeQKNM69cl+ITgJSAnSXeYwi3NjfSBRJ18u26aVXm2bpFPhDozYQ8qpQT WwxTMr/KnRdjn5jGAZzF1hOYP1KIyHARDBFD80MIuyEXyp0D2sMgJZmXzOoKX2bv6OA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=oss.qualcomm.com; spf=pass smtp.mailfrom=oss.qualcomm.com; dkim=pass header.d=qualcomm.com header.i=@qualcomm.com header.a=rsa-sha256 header.s=qcppdkim1 header.b=KiNeKvG9; dkim=pass header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.a=rsa-sha256 header.s=google header.b=EGk2KU6r; arc=none smtp.remote-ip=205.220.168.131 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1634760A2635 for ; Mon, 23 Nov 2026 18:28:59 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 1634760A2635 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.a=rsa-sha256 header.s=qcppdkim1 header.b=KiNeKvG9; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.a=rsa-sha256 header.s=google header.b=EGk2KU6r Received: from pps.filterd (m0279866.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 6ANGGl1v1861144 for ; Mon, 23 Nov 2026 18:28:58 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=qcppdkim1; bh=Sm66atK5a1c 4jXuGmjJn9AG8ISnOiMI7T154hnwnUtc=; b=KiNeKvG9EQ/jqrIVLDZML9PSqFd DNln8baOvDpLn3OJB8cmnRSbWdB76Y3WnUVYt7iT2v26U/LoPivaZJVSQkW2Vhmq x8+m5MHoWNRp9LL51wywzfrXMTUuMBL6+ECaYVwe9Aa/x+dKrdH6dCkaNnnrTqih JapZSD3wCa5ZEPuRj2Rcjc2uewnxQGWCuNeMTJatoZg49Tka9EVhT+ej3eqp+rRI P6kTw5AHzuP1+Lvp3/w5KjlTweYLT64qLI3fC//U+qPOw3vwITERqqnO5iS3QtRl G6Dyr7WppUu0eJtNnsdQRtkbNYe6qqNuzVQwq1eD7NemUWUNFJSsvxJBxSQ== Received: from mail-dy1-f197.google.com (mail-dy1-f197.google.com [74.125.82.197]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4j4g9a2tbj-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Mon, 23 Nov 2026 18:28:58 +0000 (GMT) Received: by mail-dy1-f197.google.com with SMTP id 5a478bee46e88-3846d5f54c1so4505180eec.1 for ; Mon, 23 Nov 2026 10:28:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1795458538; x=1796063338; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=Sm66atK5a1c4jXuGmjJn9AG8ISnOiMI7T154hnwnUtc=; b=EGk2KU6r5LIh2u7O7gspDdqBhQ1Ebauh3zYfmahEihwkVZGnoLEh0yDxMFyWnYdxvh V/Jhdv65eSLYPd8z5Zha90GmCy+6+2BsTNMD/ty1ni+2kBtDRV31qSDzMZTPEB682fZd A2obY7dMgScrh+D6v7aIBBdLLpcYGAsiaD4qF89Zqy4zM4XLAbhtSSIGU4HkC23Eqr8K 4LIbVN+cZdxCN38e5k5uweHAO6/ccQInT9yJDMzQaD2czvo7+U+fCGjZd3GgD1xo/S9g 7uirdMMDUMLN0ipJdPKMadHeXmGV/LQ+TUOTONlOQVD+B+LiYeS9QWGJ9yDXo4RxEAUj kFNw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1795458538; x=1796063338; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=Sm66atK5a1c4jXuGmjJn9AG8ISnOiMI7T154hnwnUtc=; b=VUzYzYtEcAkvzuqUQ2DaTZA4IErAdTYKNiIm532CtoUtW6+D5ppjTpXAFBN+dt43F1 R+p4UqUOPHI087dD9asyicUVHAnhUYzfJXmxmH9jR3lc8RUfOeqITD3n7y5EvMWPPnhp 4qV+7Z43HxuFFkcb3Sztf66Cjg97t/Cb3XB0yEnI+q/8RLl4sr7JrNuyiNbKhmsyPknd EAfIZQT0aL9hV9phRfXvSVh+abmIyHMla4XIr67khwERnZegXJqhgLV2cUoi+Jt1XuMv 52dhjUfBPUpZtRepPA73IS3D5626he4ZMjesEnad/c92bPLC/v6OlitaeSnqdqLI1nd7 UClQ== X-Forwarded-Encrypted: i=1; AL+hErGHB2a7cKhtsQSh5IX6ZQkSGNJjFpBCWR1eb7dGs2E6xEqTXI+ZxfvXO5343W/dv6FrduEU6cZLyYKTOFM=@vger.kernel.org X-Gm-Message-State: APuU4Z/4dNC+qAIy2vhkhSvH80ynTVrawStdIsYVq1lI/g2HYRnGKQkg beX4T9YeFsahjr5BE/fEnqHhAz9cEh6DHzHIs7Z7h63TIA8gR1UzX/eOiejFz06085G/KA8ndMV r3Tz4mHCxut96kO261rjo4cNnhzsxeJWDMBweesI3SfvpRRgLaJlR0/dJ9A1lVr8pWmQ= X-Gm-Gg: AZFdTZda4jQyKv0nxZJx42uUApsBXcyuk5nqy9lwNvLeZXcH+gzHkSk7iFg2ZE5dPf6 YPNDsaark7w3Dq7CmffScDPC0AnSJPAjUuXgD7I4sdQx4LQDpM4cS+OqM2IuA4nwgdPcyhCyRcO KhwPXxC3iSi4LqaIAhf7XhjtYsm2nHrFbBU/hYFyluQM9EN5idAQVmDNwnxQuZ6uGmLlA095pIb HXOkwJH8eYHNW0BNIDAeAb81el7S0/RM1BQjlZsCG3h/reLcRdOQli0ZmFLAXlOuiVQne4t3zAs CvX6hjQezRwfq/oa2njRmw6np40PxClLIfrDVrdhWFhxt4X1xYxtKVSSivBT8Iuqb/01ekBHKCF UY1TXEJ9O6IMbFa6h1uIj2/nFraPhiNFRJUUCHzBizD4pP7dEprQQn/Ofl4EyfVfKfEMyFB9avl SdUtqySd1wZ3KQMijznOunBZ8eNg== X-Received: by 2002:a05:7301:6181:10b0:386:b2ac:1f17 with SMTP id 5a478bee46e88-386b2ac2832mr3423228eec.7.1795458537727; Mon, 23 Nov 2026 10:28:57 -0800 (PST) X-Received: by 2002:a05:7301:6181:10b0:386:b2ac:1f17 with SMTP id 5a478bee46e88-386b2ac2832mr3423204eec.7.1795458537235; Mon, 23 Nov 2026 10:28:57 -0800 (PST) Received: from hu-eserrao-lv.qualcomm.com (Global_NAT1.qualcomm.com. [129.46.96.20]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-385666e99fdsm47697986eec.5.2026.11.23.10.28.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Nov 2026 10:28:56 -0800 (PST) From: Elson Serrao To: Bjorn Andersson , Conor Dooley , Greg Kroah-Hartman , Konrad Dybcio , Krzysztof Kozlowski , Rob Herring Cc: linux-arm-msm@vger.kernel.org, devicetree@vger.kernel.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Konrad Dybcio , Peter Chen , Gopikrishna Garmidi Subject: [PATCH v10 7/7] usb: misc: qcom_eud: fix virtual attach/detach event handling Date: Mon, 23 Nov 2026 10:28:47 -0800 Message-Id: <20261123182847.143892-8-elson.serrao@oss.qualcomm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20261123182847.143892-1-elson.serrao@oss.qualcomm.com> References: <20261123182847.143892-1-elson.serrao@oss.qualcomm.com> X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-Spam-Info: AW1haW4tMjYxMTIzMDA3MyBTYWx0ZWRfXyUYl1ERb6765 wAxSmpqqqO4qKBy+jBiBPCF6fviVNqNfHzCNXS1KYi9ypfQfL3Y34bGWlmJ9JPuNRqrSZ5y69o/ 82HKIBzzLG4KgvUYDx28f8YbietIbZE= X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYxMTIzMDA3MyBTYWx0ZWRfX58jta5NX9RPx nLGm3mrN2WB70uQG4dQOp297lhD5kUV7tM23u1RknG1finP6zVwq9nsk1ol9NrFuOKWIlM7D4nD qP37Jq3/4+xqPlouun2Xo4Anfam1eStlB6Q7OxNyVK1smbe5VPf0tgHweXvIvUzay5DdXyYk1MB AaxLqoGoq2bjPfjmuRi33Ti3coxoaGOd2PLz0mk9wAkpRgCj80J5u35lGyILDnA7FObzd8S38Ft hCXOwIRdG9Bpm9ENcPCkFzROtmMsXO6QBH/TLSmVSxCxbT0V73JnIzv+e1qLjaU3sxd+lcV4IRk Q4kh/nDP5Io7t9M/x3KmB/d61F+wsqEgNWxcHBuTNArigbrm5rjP8aTJNuKM7yhoQwPui73xmwn IX8GIwWAZCtKSBPXzB99JyBF5G2HG3ARE/e9Rbqly9Him1oQZEd++gqLZzRRnkMpE1+vGSnrZ76 mlLyG2FqUil7VBwoheQ== X-Proofpoint-ORIG-GUID: 7vXWRFQH86mJ-9mvk2vMwcfDxkf72BfW X-Authority-Analysis: v=2.4 cv=cYJHPXDM c=1 sm=1 tr=0 ts=6b0485ea cx=c_pps a=Uww141gWH0fZj/3QKPojxA==:117 a=ouPCqIW2jiPt+lZRy3xVPw==:17 a=zJRp6_cAMcgA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=YMgV9FUhrdKAYTUUvYB2:22 a=EUspDBNiAAAA:8 a=VwQbUJbxAAAA:8 a=dOwNoGVJVf10FbPJOZQA:9 a=PxkB5W3o20Ba91AHUih5:22 X-Proofpoint-GUID: 7vXWRFQH86mJ-9mvk2vMwcfDxkf72BfW X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.138,FMLib:17.12.100.49 definitions=2026-11-23_04,2026-11-23_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 clxscore=1015 malwarescore=0 spamscore=0 bulkscore=0 priorityscore=1501 adultscore=0 suspectscore=0 impostorscore=0 lowpriorityscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2611040001 definitions=main-2611230073 Content-Type: text/plain; charset="utf-8" EUD provides virtual USB attach/detach events to simulate cable plug/unplug while maintaining the physical debug connection. However, the current implementation incorrectly sets the USB role to HOST on virtual detach, which doesn't represent the disconnected state. Fix the virtual detach handling by setting the USB role to NONE instead of HOST, correctly representing the disconnected state. Reviewed-by: Konrad Dybcio Reviewed-by: Peter Chen Tested-by: Gopikrishna Garmidi Signed-off-by: Elson Serrao --- drivers/usb/misc/qcom_eud.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/drivers/usb/misc/qcom_eud.c b/drivers/usb/misc/qcom_eud.c index b434b0447613..eba2ace4f3a1 100644 --- a/drivers/usb/misc/qcom_eud.c +++ b/drivers/usb/misc/qcom_eud.c @@ -313,10 +313,26 @@ static irqreturn_t handle_eud_irq_thread(int irq, voi= d *data) path =3D chip->paths[chip->port_idx]; =20 if (chip->enabled && path->curr_role =3D=3D USB_ROLE_DEVICE) { + /* + * EUD virtual attach/detach event handling for low power debugging: + * + * When EUD is enabled in debug mode, the device remains physically + * connected to the PC throughout the debug session, keeping the USB + * controller active. This prevents testing of low power scenarios that + * require USB disconnection. + * + * EUD solves this by providing virtual USB attach/detach events while + * maintaining the physical connection. These events are triggered from + * the Host PC via the enumerated EUD control interface and delivered + * to the EUD driver as interrupts. + * + * These notifications are forwarded to the USB controller through role + * switch framework. + */ if (chip->usb_attached) ret =3D usb_role_switch_set_role(path->controller_sw, USB_ROLE_DEVICE); else - ret =3D usb_role_switch_set_role(path->controller_sw, USB_ROLE_HOST); + ret =3D usb_role_switch_set_role(path->controller_sw, USB_ROLE_NONE); if (ret) dev_err(chip->dev, "failed to set role switch\n"); } --=20 2.34.1