From patchwork Tue Jan 4 11:58:14 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Souradeep Chowdhury X-Patchwork-Id: 529913 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 47F36C433F5 for ; Tue, 4 Jan 2022 11:59:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232728AbiADL7m (ORCPT ); Tue, 4 Jan 2022 06:59:42 -0500 Received: from alexa-out-sd-01.qualcomm.com ([199.106.114.38]:6966 "EHLO alexa-out-sd-01.qualcomm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232731AbiADL7m (ORCPT ); Tue, 4 Jan 2022 06:59:42 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; i=@quicinc.com; q=dns/txt; s=qcdkim; t=1641297582; x=1672833582; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=PfFj0CJ7Z+T4HaxN3nL++olZvDm4hxLT9ASz/R5gqjE=; b=fSvdAZgVOJh9JQSupY+ARuoGOE7+/0tY5Qvk3yo4tiJdjVz2CLkDN+ba f4fb39GJhXsGI4r3k48rek0GPCiJDtzNz6FuZT0fhH/idA01bx4KDkL/1 Txm0aAO0PabaLhLVbh0FmAD/oimubGdLfFRHtiSWGZbbBNtBt0IWTucwz w=; Received: from unknown (HELO ironmsg03-sd.qualcomm.com) ([10.53.140.143]) by alexa-out-sd-01.qualcomm.com with ESMTP; 04 Jan 2022 03:59:41 -0800 X-QCInternal: smtphost Received: from nasanex01c.na.qualcomm.com ([10.47.97.222]) by ironmsg03-sd.qualcomm.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Jan 2022 03:59:40 -0800 Received: from nalasex01a.na.qualcomm.com (10.47.209.196) by nasanex01c.na.qualcomm.com (10.47.97.222) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.922.19; Tue, 4 Jan 2022 03:59:39 -0800 Received: from blr-ubuntu-525.qualcomm.com (10.80.80.8) by nalasex01a.na.qualcomm.com (10.47.209.196) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.922.19; Tue, 4 Jan 2022 03:59:34 -0800 From: Souradeep Chowdhury To: , , , , , CC: , , , , , , , , Subject: [PATCH V3 1/7] dt-bindings: Add the yaml bindings for EUD Date: Tue, 4 Jan 2022 17:28:14 +0530 Message-ID: <5d9491693870b5dde757959f4491296503d22f70.1641288286.git.quic_schowdhu@quicinc.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: References: MIME-Version: 1.0 X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01b.na.qualcomm.com (10.46.141.250) To nalasex01a.na.qualcomm.com (10.47.209.196) Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org Documentation for Embedded USB Debugger(EUD) device tree bindings in yaml format. Signed-off-by: Souradeep Chowdhury --- .../devicetree/bindings/soc/qcom/qcom,eud.yaml | 50 ++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 Documentation/devicetree/bindings/soc/qcom/qcom,eud.yaml diff --git a/Documentation/devicetree/bindings/soc/qcom/qcom,eud.yaml b/Documentation/devicetree/bindings/soc/qcom/qcom,eud.yaml new file mode 100644 index 0000000..3523932 --- /dev/null +++ b/Documentation/devicetree/bindings/soc/qcom/qcom,eud.yaml @@ -0,0 +1,50 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: "http://devicetree.org/schemas/soc/qcom/qcom,eud.yaml#" +$schema: "http://devicetree.org/meta-schemas/core.yaml#" + +title: Qualcomm Embedded USB Debugger + +maintainers: + - Souradeep Chowdhury + +description: + This binding is used to describe the Qualcomm Embedded USB Debugger, which is + mini USB-hub implemented on chip to support USB-based debug capabilities. + +properties: + compatible: + items: + - enum: + - qcom,sc7280-eud + - const: qcom,eud + + reg: + items: + - description: EUD Base Register Region + - description: EUD Mode Manager Register + + interrupts: + description: + EUD interrupt + + port: + description: + This port is to be attached to the endpoint of the connector child of + DWC3 controller node. The controller has the "usb-role-switch" property. + $ref: /schemas/graph.yaml#/properties/port + +required: + - compatible + - reg + +additionalProperties: false + +examples: + - | + eud@88e0000 { + compatible = "qcom,sc7280-eud","qcom,eud"; + reg = <0x88e0000 0x2000>, + <0x88e2000 0x1000>; + }; From patchwork Tue Jan 4 11:58:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Souradeep Chowdhury X-Patchwork-Id: 530233 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5626BC4332F for ; Tue, 4 Jan 2022 11:59:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232767AbiADL7s (ORCPT ); Tue, 4 Jan 2022 06:59:48 -0500 Received: from alexa-out.qualcomm.com ([129.46.98.28]:21895 "EHLO alexa-out.qualcomm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232759AbiADL7q (ORCPT ); Tue, 4 Jan 2022 06:59:46 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; i=@quicinc.com; q=dns/txt; s=qcdkim; t=1641297586; x=1672833586; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=lVRrgO3/VD/GMvGs6tBkbU/ERogIdO6bugaqEJVG5F8=; b=uXGg2Q4bfoR0rpfhac7ZiYcyHDWtuUYFaSh+GQjdFdewdbuZQo2Bahzf AqiI/PXEiotMaeu3Rhz4yiPwMaG34b6sT2dkY8XOH+g4nhd4G7s8i8z9q g8ydzHl3rTHtbzXDBQ/AoKTj7SehgmFyVQ97+eC8u0sFSJU79GFzSp+G1 A=; Received: from ironmsg09-lv.qualcomm.com ([10.47.202.153]) by alexa-out.qualcomm.com with ESMTP; 04 Jan 2022 03:59:45 -0800 X-QCInternal: smtphost Received: from nasanex01c.na.qualcomm.com ([10.47.97.222]) by ironmsg09-lv.qualcomm.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Jan 2022 03:59:45 -0800 Received: from nalasex01a.na.qualcomm.com (10.47.209.196) by nasanex01c.na.qualcomm.com (10.47.97.222) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.922.19; Tue, 4 Jan 2022 03:59:44 -0800 Received: from blr-ubuntu-525.qualcomm.com (10.80.80.8) by nalasex01a.na.qualcomm.com (10.47.209.196) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.922.19; Tue, 4 Jan 2022 03:59:39 -0800 From: Souradeep Chowdhury To: , , , , , CC: , , , , , , , , Subject: [PATCH V3 2/7] dt-bindings: connector: Add property for EUD type-C connector Date: Tue, 4 Jan 2022 17:28:15 +0530 Message-ID: <8194777786be70073a5364fe45ba7ec684019a71.1641288286.git.quic_schowdhu@quicinc.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: References: MIME-Version: 1.0 X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01b.na.qualcomm.com (10.46.141.250) To nalasex01a.na.qualcomm.com (10.47.209.196) Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org Added the property for EUD(Embedded USB Debugger) connector. EUD is a mini usb hub with debug and trace capabilities and it has a type C connector attached to it for role-switching. This connector is attached to EUD via port. Signed-off-by: Souradeep Chowdhury --- Documentation/devicetree/bindings/connector/usb-connector.yaml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Documentation/devicetree/bindings/connector/usb-connector.yaml b/Documentation/devicetree/bindings/connector/usb-connector.yaml index 7eb8659..417d39a 100644 --- a/Documentation/devicetree/bindings/connector/usb-connector.yaml +++ b/Documentation/devicetree/bindings/connector/usb-connector.yaml @@ -30,6 +30,10 @@ properties: - const: samsung,usb-connector-11pin - const: usb-b-connector + - items: + - const: qcom,usb-connector-eud + - const: usb-c-connector + label: description: Symbolic name for the connector. @@ -179,7 +183,8 @@ properties: properties: port@0: $ref: /schemas/graph.yaml#/properties/port - description: High Speed (HS), present in all connectors. + description: High Speed (HS), present in all connectors. Also used as a + port to connect QCOM Embedded USB Debugger(EUD). port@1: $ref: /schemas/graph.yaml#/properties/port From patchwork Tue Jan 4 11:58:16 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Souradeep Chowdhury X-Patchwork-Id: 529912 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 18EB5C4332F for ; Tue, 4 Jan 2022 11:59:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232779AbiADL7v (ORCPT ); Tue, 4 Jan 2022 06:59:51 -0500 Received: from alexa-out-sd-02.qualcomm.com ([199.106.114.39]:3706 "EHLO alexa-out-sd-02.qualcomm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232716AbiADL7u (ORCPT ); Tue, 4 Jan 2022 06:59:50 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; i=@quicinc.com; q=dns/txt; s=qcdkim; t=1641297590; x=1672833590; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=tK9/BaPQbTP4zNp/vSDwy4WaGKZ5z4qtlj5T/6Z1zZc=; b=BLHS4/BDOa06kq80ShejcNBiIeU0NtBxWXogXSmjDq7O6uoz0wxtw5sm aU++vuQf1Njpnymwy2kBLHDUtDyYbPP03WLdSUWITnS016pjAgPX1bFse rMunbaEgmUHGBUHMqszxCA7o/fMfJLh/f73d9BsoUzNvbT7H4bf5J9M36 c=; Received: from unknown (HELO ironmsg04-sd.qualcomm.com) ([10.53.140.144]) by alexa-out-sd-02.qualcomm.com with ESMTP; 04 Jan 2022 03:59:50 -0800 X-QCInternal: smtphost Received: from nasanex01c.na.qualcomm.com ([10.47.97.222]) by ironmsg04-sd.qualcomm.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Jan 2022 03:59:49 -0800 Received: from nalasex01a.na.qualcomm.com (10.47.209.196) by nasanex01c.na.qualcomm.com (10.47.97.222) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.922.19; Tue, 4 Jan 2022 03:59:49 -0800 Received: from blr-ubuntu-525.qualcomm.com (10.80.80.8) by nalasex01a.na.qualcomm.com (10.47.209.196) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.922.19; Tue, 4 Jan 2022 03:59:44 -0800 From: Souradeep Chowdhury To: , , , , , CC: , , , , , , , , Subject: [PATCH V3 3/7] bindings: usb: dwc3: Update dwc3 properties for EUD connector Date: Tue, 4 Jan 2022 17:28:16 +0530 Message-ID: <163f4d977fb6a0d80d8fd8d358991aeeb58d31a6.1641288286.git.quic_schowdhu@quicinc.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: References: MIME-Version: 1.0 X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01b.na.qualcomm.com (10.46.141.250) To nalasex01a.na.qualcomm.com (10.47.209.196) Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org Add the connector property for dwc3 node. This connector can be used to role-switch the controller from device to host and vice versa. Signed-off-by: Souradeep Chowdhury --- Documentation/devicetree/bindings/usb/snps,dwc3.yaml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Documentation/devicetree/bindings/usb/snps,dwc3.yaml b/Documentation/devicetree/bindings/usb/snps,dwc3.yaml index 078fb78..9382168 100644 --- a/Documentation/devicetree/bindings/usb/snps,dwc3.yaml +++ b/Documentation/devicetree/bindings/usb/snps,dwc3.yaml @@ -318,6 +318,12 @@ properties: items: enum: [1, 4, 8, 16, 32, 64, 128, 256] + connector: + type: object + $ref: /connector/usb-connector.yaml# + description: + Connector for dual role switch, especially for "eud-usb-c-connector" + unevaluatedProperties: false required: From patchwork Tue Jan 4 11:58:17 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Souradeep Chowdhury X-Patchwork-Id: 530232 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 27EFAC433F5 for ; Tue, 4 Jan 2022 11:59:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231461AbiADL74 (ORCPT ); Tue, 4 Jan 2022 06:59:56 -0500 Received: from alexa-out-sd-02.qualcomm.com ([199.106.114.39]:3706 "EHLO alexa-out-sd-02.qualcomm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231482AbiADL7z (ORCPT ); Tue, 4 Jan 2022 06:59:55 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; i=@quicinc.com; q=dns/txt; s=qcdkim; t=1641297595; x=1672833595; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=S1tQj5loTZgkOfsBaoamEeb3uRiru2uuIg+PlzsTo0c=; b=BRn40SLwBF0VBet9UvZypYYPfR0krw83mfq98FYCojiaMr1uQ9gZpC3T tvmEGK0ENA363zRiCZdpgM62T0no39ZBftEhf0x3/tUXJE/n42++U9mCp v0T4ZRBYtM/XGDd1ydNvWwvbnBMGo2m0rhXScwVzRwb2I2TbaABq6i5um s=; Received: from unknown (HELO ironmsg04-sd.qualcomm.com) ([10.53.140.144]) by alexa-out-sd-02.qualcomm.com with ESMTP; 04 Jan 2022 03:59:54 -0800 X-QCInternal: smtphost Received: from nasanex01c.na.qualcomm.com ([10.47.97.222]) by ironmsg04-sd.qualcomm.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Jan 2022 03:59:54 -0800 Received: from nalasex01a.na.qualcomm.com (10.47.209.196) by nasanex01c.na.qualcomm.com (10.47.97.222) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.922.19; Tue, 4 Jan 2022 03:59:54 -0800 Received: from blr-ubuntu-525.qualcomm.com (10.80.80.8) by nalasex01a.na.qualcomm.com (10.47.209.196) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.922.19; Tue, 4 Jan 2022 03:59:49 -0800 From: Souradeep Chowdhury To: , , , , , CC: , , , , , , , , Subject: [PATCH V3 4/7] soc: qcom: eud: Add driver support for Embedded USB Debugger(EUD) Date: Tue, 4 Jan 2022 17:28:17 +0530 Message-ID: <654a9529015d2d5cf9ee1c263cdc0a970bbe4f91.1641288286.git.quic_schowdhu@quicinc.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: References: MIME-Version: 1.0 X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01b.na.qualcomm.com (10.46.141.250) To nalasex01a.na.qualcomm.com (10.47.209.196) Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org Add support for control peripheral of EUD (Embedded USB Debugger) to listen to events such as USB attach/detach, pet EUD to indicate software is functional.Reusing the platform device kobj, sysfs entry 'enable' is created to enable or disable EUD. To enable the eud the following needs to be done echo 1 > /sys/bus/platform/.../enable To disable eud, following is the command echo 0 > /sys/bus/platform/.../enable Signed-off-by: Souradeep Chowdhury --- Documentation/ABI/testing/sysfs-driver-eud | 9 + drivers/soc/qcom/Kconfig | 10 ++ drivers/soc/qcom/Makefile | 1 + drivers/soc/qcom/qcom_eud.c | 260 +++++++++++++++++++++++++++++ 4 files changed, 280 insertions(+) create mode 100644 Documentation/ABI/testing/sysfs-driver-eud create mode 100644 drivers/soc/qcom/qcom_eud.c diff --git a/Documentation/ABI/testing/sysfs-driver-eud b/Documentation/ABI/testing/sysfs-driver-eud new file mode 100644 index 0000000..2381552 --- /dev/null +++ b/Documentation/ABI/testing/sysfs-driver-eud @@ -0,0 +1,9 @@ +What: /sys/bus/platform/drivers/eud/.../enable +Date: January 2022 +Contact: Souradeep Chowdhury +Description: + The Enable/Disable sysfs interface for Embedded + USB Debugger(EUD). This enables and disables the + 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. diff --git a/drivers/soc/qcom/Kconfig b/drivers/soc/qcom/Kconfig index 79b568f..a4db41b 100644 --- a/drivers/soc/qcom/Kconfig +++ b/drivers/soc/qcom/Kconfig @@ -42,6 +42,16 @@ config QCOM_CPR To compile this driver as a module, choose M here: the module will be called qcom-cpr +config QCOM_EUD + tristate "QCOM Embedded USB Debugger(EUD) Driver" + select USB_ROLE_SWITCH + help + This module enables support for Qualcomm Technologies, Inc. + Embedded USB Debugger (EUD). The EUD is a control peripheral + which reports VBUS attach/detach events and has USB-based + debug and trace capabilities. On selecting m, the module name + that is built is qcom_eud.ko + config QCOM_GENI_SE tristate "QCOM GENI Serial Engine Driver" depends on ARCH_QCOM || COMPILE_TEST diff --git a/drivers/soc/qcom/Makefile b/drivers/soc/qcom/Makefile index ad675a6..3331a40 100644 --- a/drivers/soc/qcom/Makefile +++ b/drivers/soc/qcom/Makefile @@ -4,6 +4,7 @@ obj-$(CONFIG_QCOM_AOSS_QMP) += qcom_aoss.o obj-$(CONFIG_QCOM_GENI_SE) += qcom-geni-se.o obj-$(CONFIG_QCOM_COMMAND_DB) += cmd-db.o obj-$(CONFIG_QCOM_CPR) += cpr.o +obj-$(CONFIG_QCOM_EUD) += qcom_eud.o obj-$(CONFIG_QCOM_GSBI) += qcom_gsbi.o obj-$(CONFIG_QCOM_MDT_LOADER) += mdt_loader.o obj-$(CONFIG_QCOM_OCMEM) += ocmem.o diff --git a/drivers/soc/qcom/qcom_eud.c b/drivers/soc/qcom/qcom_eud.c new file mode 100644 index 0000000..7c4cc7d --- /dev/null +++ b/drivers/soc/qcom/qcom_eud.c @@ -0,0 +1,260 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Copyright (c) 2015-2021, The Linux Foundation. All rights reserved. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define EUD_REG_INT1_EN_MASK 0x0024 +#define EUD_REG_INT_STATUS_1 0x0044 +#define EUD_REG_CTL_OUT_1 0x0074 +#define EUD_REG_VBUS_INT_CLR 0x0080 +#define EUD_REG_CSR_EUD_EN 0x1014 +#define EUD_REG_SW_ATTACH_DET 0x1018 +#define EUD_REG_EUD_EN2 0x0000 + +#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) + +struct eud_chip { + struct device *dev; + struct usb_role_switch *role_sw; + void __iomem *eud_reg_base; + void __iomem *eud_mode_mgr2_phys_base; + unsigned int int_status; + int eud_irq; + bool enable; + bool usb_attach; + +}; + +static int enable_eud(struct eud_chip *priv) +{ + writel(EUD_ENABLE, priv->eud_reg_base + EUD_REG_CSR_EUD_EN); + writel(EUD_INT_VBUS | EUD_INT_SAFE_MODE, + priv->eud_reg_base + EUD_REG_INT1_EN_MASK); + writel(1, priv->eud_mode_mgr2_phys_base + EUD_REG_EUD_EN2); + + return usb_role_switch_set_role(priv->role_sw, USB_ROLE_DEVICE); +} + +static void disable_eud(struct eud_chip *priv) +{ + writel(0, priv->eud_reg_base + EUD_REG_CSR_EUD_EN); + writel(0, priv->eud_mode_mgr2_phys_base + EUD_REG_EUD_EN2); +} + +static ssize_t enable_show(struct device *dev, + struct device_attribute *attr, char *buf) +{ + struct eud_chip *chip = dev_get_drvdata(dev); + + return sysfs_emit(buf, "%d\n", chip->enable); +} + +static ssize_t enable_store(struct device *dev, + struct device_attribute *attr, + const char *buf, size_t count) +{ + struct eud_chip *chip = dev_get_drvdata(dev); + bool enable; + int ret; + + if (kstrtobool(buf, &enable)) + return -EINVAL; + + if (enable) { + ret = enable_eud(chip); + if (!ret) + chip->enable = enable; + } else { + disable_eud(chip); + } + + return count; +} + +static DEVICE_ATTR_RW(enable); + +static struct attribute *eud_attrs[] = { + &dev_attr_enable.attr, + NULL, +}; +ATTRIBUTE_GROUPS(eud); + +static void usb_attach_detach(struct eud_chip *chip) +{ + u32 reg; + + /* read ctl_out_1[4] to find USB attach or detach event */ + reg = readl(chip->eud_reg_base + EUD_REG_CTL_OUT_1); + if (reg & EUD_INT_SAFE_MODE) + chip->usb_attach = true; + else + chip->usb_attach = false; + + /* set and clear vbus_int_clr[0] to clear interrupt */ + writel(BIT(0), chip->eud_reg_base + EUD_REG_VBUS_INT_CLR); + writel(0, chip->eud_reg_base + EUD_REG_VBUS_INT_CLR); +} + +static void pet_eud(struct eud_chip *chip) +{ + u32 reg; + int ret; + + /* read sw_attach_det[0] to find attach/detach event */ + reg = readl(chip->eud_reg_base + EUD_REG_SW_ATTACH_DET); + if (reg & EUD_INT_PET_EUD) { + /* Detach & Attach pet for EUD */ + writel(0, chip->eud_reg_base + EUD_REG_SW_ATTACH_DET); + /* Delay to make sure detach pet is done before attach pet */ + ret = readl_poll_timeout(chip->eud_reg_base + EUD_REG_SW_ATTACH_DET, + reg, (reg == 0), 1, 100); + if (ret) { + dev_err(chip->dev, "Detach pet failed\n"); + return; + } + + writel(EUD_INT_PET_EUD, chip->eud_reg_base + + EUD_REG_SW_ATTACH_DET); + } else { + /* Attach pet for EUD */ + writel(EUD_INT_PET_EUD, chip->eud_reg_base + + EUD_REG_SW_ATTACH_DET); + } +} + +static irqreturn_t handle_eud_irq(int irq, void *data) +{ + struct eud_chip *chip = data; + u32 reg; + + /* read status register and find out which interrupt triggered */ + reg = readl(chip->eud_reg_base + EUD_REG_INT_STATUS_1); + switch (reg & EUD_INT_ALL) { + case EUD_INT_VBUS: + chip->int_status = EUD_INT_VBUS; + usb_attach_detach(chip); + return IRQ_WAKE_THREAD; + case EUD_INT_SAFE_MODE: + pet_eud(chip); + break; + default: + return IRQ_NONE; + } + return IRQ_HANDLED; +} + +static irqreturn_t handle_eud_irq_thread(int irq, void *data) +{ + struct eud_chip *chip = data; + int ret; + + if (chip->int_status == EUD_INT_VBUS) { + if (chip->usb_attach) + ret = usb_role_switch_set_role(chip->role_sw, USB_ROLE_DEVICE); + else + ret = usb_role_switch_set_role(chip->role_sw, USB_ROLE_HOST); + if (ret) + dev_err(chip->dev, "failed to set role switch\n"); + } + + return IRQ_HANDLED; +} + +static int eud_probe(struct platform_device *pdev) +{ + struct eud_chip *chip; + struct fwnode_handle *fwnode = pdev->dev.fwnode, *ep, *connector; + int ret; + + chip = devm_kzalloc(&pdev->dev, sizeof(*chip), GFP_KERNEL); + if (!chip) + return -ENOMEM; + + chip->dev = &pdev->dev; + + ep = fwnode_graph_get_next_endpoint(fwnode, NULL); + if (!ep) + return -ENODEV; + + connector = fwnode_graph_get_remote_port_parent(ep); + fwnode_handle_put(ep); + if (!connector) + return -ENODEV; + + chip->role_sw = fwnode_usb_role_switch_get(connector); + if (IS_ERR(chip->role_sw)) { + return dev_err_probe(chip->dev, PTR_ERR(chip->role_sw), + "failed to get role switch\n"); + } + + chip->eud_reg_base = devm_platform_ioremap_resource(pdev, 0); + if (IS_ERR(chip->eud_reg_base)) + return PTR_ERR(chip->eud_reg_base); + + chip->eud_mode_mgr2_phys_base = devm_platform_ioremap_resource(pdev, 1); + if (IS_ERR(chip->eud_mode_mgr2_phys_base)) + return PTR_ERR(chip->eud_mode_mgr2_phys_base); + + chip->eud_irq = platform_get_irq(pdev, 0); + ret = devm_request_threaded_irq(&pdev->dev, chip->eud_irq, handle_eud_irq, + handle_eud_irq_thread, IRQF_ONESHOT, NULL, chip); + if (ret) + return dev_err_probe(chip->dev, ret, "failed to allocate irq\n"); + + enable_irq_wake(chip->eud_irq); + + platform_set_drvdata(pdev, chip); + + return 0; +} + +static int eud_remove(struct platform_device *pdev) +{ + struct eud_chip *chip = platform_get_drvdata(pdev); + + if (chip->enable) + disable_eud(chip); + + device_init_wakeup(&pdev->dev, false); + disable_irq_wake(chip->eud_irq); + + return 0; +} + +static const struct of_device_id eud_dt_match[] = { + { .compatible = "qcom,sc7280-eud" }, + { } +}; +MODULE_DEVICE_TABLE(of, eud_dt_match); + +static struct platform_driver eud_driver = { + .probe = eud_probe, + .remove = eud_remove, + .driver = { + .name = "eud", + .dev_groups = eud_groups, + .of_match_table = eud_dt_match, + }, +}; +module_platform_driver(eud_driver); + +MODULE_DESCRIPTION("QTI EUD driver"); +MODULE_LICENSE("GPL v2"); From patchwork Tue Jan 4 11:58:18 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Souradeep Chowdhury X-Patchwork-Id: 529911 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 23674C433F5 for ; Tue, 4 Jan 2022 12:00:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232842AbiADMAC (ORCPT ); Tue, 4 Jan 2022 07:00:02 -0500 Received: from alexa-out-sd-02.qualcomm.com ([199.106.114.39]:3706 "EHLO alexa-out-sd-02.qualcomm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230393AbiADL77 (ORCPT ); Tue, 4 Jan 2022 06:59:59 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; i=@quicinc.com; q=dns/txt; s=qcdkim; t=1641297599; x=1672833599; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=goHvDbPAMT8y7VmBNDYv4n/5GH3eYTMy8N290BUBoig=; b=jhoHEkdPkJDHo/DBRXpt2pTHF9sQZBTGmmxy0f4bwDuMV1jFFft4UYnq 6nT/G1HdClNee18C5TZnzCgW3rzhPoztTt6wZ9qKshSJ/dKulKYq63AS8 HQBmZWo26bUqLNt+9QYIlprweQn9f84O8FJjPdyKyg4DH9n9Gc9Epp1oH s=; Received: from unknown (HELO ironmsg04-sd.qualcomm.com) ([10.53.140.144]) by alexa-out-sd-02.qualcomm.com with ESMTP; 04 Jan 2022 03:59:59 -0800 X-QCInternal: smtphost Received: from nasanex01c.na.qualcomm.com ([10.47.97.222]) by ironmsg04-sd.qualcomm.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Jan 2022 03:59:59 -0800 Received: from nalasex01a.na.qualcomm.com (10.47.209.196) by nasanex01c.na.qualcomm.com (10.47.97.222) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.922.19; Tue, 4 Jan 2022 03:59:58 -0800 Received: from blr-ubuntu-525.qualcomm.com (10.80.80.8) by nalasex01a.na.qualcomm.com (10.47.209.196) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.922.19; Tue, 4 Jan 2022 03:59:54 -0800 From: Souradeep Chowdhury To: , , , , , CC: , , , , , , , , Subject: [PATCH V3 5/7] arm64: dts: qcom: sc7280: Add EUD dt node and dwc3 connector Date: Tue, 4 Jan 2022 17:28:18 +0530 Message-ID: X-Mailer: git-send-email 2.7.4 In-Reply-To: References: MIME-Version: 1.0 X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01b.na.qualcomm.com (10.46.141.250) To nalasex01a.na.qualcomm.com (10.47.209.196) Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org Add the Embedded USB Debugger(EUD) device tree node. The node contains EUD base register region and EUD mode manager register regions along with the interrupt entry. Also add the connector to EUD which is mapped as the child of dwc3. The connector is attached to EUD via port. Also add the role-switch property to dwc3 node. Signed-off-by: Souradeep Chowdhury --- arch/arm64/boot/dts/qcom/sc7280.dtsi | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/arch/arm64/boot/dts/qcom/sc7280.dtsi b/arch/arm64/boot/dts/qcom/sc7280.dtsi index 53a21d0..2d14e5c 100644 --- a/arch/arm64/boot/dts/qcom/sc7280.dtsi +++ b/arch/arm64/boot/dts/qcom/sc7280.dtsi @@ -1315,6 +1315,18 @@ phys = <&usb_2_hsphy>; phy-names = "usb2-phy"; maximum-speed = "high-speed"; + usb-role-switch; + usb_con: eud_usb_connector { + compatible = "qcom,usb-connector-eud", + "usb-c-connector"; + ports { + port@0 { + usb2_role_switch: endpoint { + remote-endpoint = <&eud_ep>; + }; + }; + }; + }; }; }; @@ -1339,6 +1351,19 @@ interrupts = ; }; + eud: eud@88e0000 { + compatible = "qcom,sc7280-eud","qcom,eud"; + reg = <0 0x88e0000 0 0x2000>, + <0 0x88e2000 0 0x1000>; + interrupt-parent = <&pdc>; + interrupts = <11 IRQ_TYPE_LEVEL_HIGH>; + port { + eud_ep: endpoint { + remote-endpoint = <&usb2_role_switch>; + }; + }; + }; + nsp_noc: interconnect@a0c0000 { reg = <0 0x0a0c0000 0 0x10000>; compatible = "qcom,sc7280-nsp-noc"; From patchwork Tue Jan 4 11:58:19 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Souradeep Chowdhury X-Patchwork-Id: 530231 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 69685C433FE for ; Tue, 4 Jan 2022 12:00:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231615AbiADMAK (ORCPT ); Tue, 4 Jan 2022 07:00:10 -0500 Received: from alexa-out-sd-02.qualcomm.com ([199.106.114.39]:3750 "EHLO alexa-out-sd-02.qualcomm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231490AbiADMAK (ORCPT ); Tue, 4 Jan 2022 07:00:10 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; i=@quicinc.com; q=dns/txt; s=qcdkim; t=1641297610; x=1672833610; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=cF/GECuwp1S1UbdJMGwmQpraS1FiRU+LUbq4e6yb5EQ=; b=pCM3nKA0MdRkWGBLaB52HZKw4bM/sIafAdjwgtUVFg/643OrKQB/arrM aoG1r/jhU/fjv55RK31ISRbASxaT6huoTN7izGl6siGOIQ/88q3ag1RFc yH7Ci0HwDefOBEucfyTbLVQi40FpuxnvIR4RDrKsR+i4TZ2vDkrfZifzT k=; Received: from unknown (HELO ironmsg03-sd.qualcomm.com) ([10.53.140.143]) by alexa-out-sd-02.qualcomm.com with ESMTP; 04 Jan 2022 04:00:09 -0800 X-QCInternal: smtphost Received: from nasanex01c.na.qualcomm.com ([10.47.97.222]) by ironmsg03-sd.qualcomm.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Jan 2022 04:00:05 -0800 Received: from nalasex01a.na.qualcomm.com (10.47.209.196) by nasanex01c.na.qualcomm.com (10.47.97.222) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.922.19; Tue, 4 Jan 2022 04:00:03 -0800 Received: from blr-ubuntu-525.qualcomm.com (10.80.80.8) by nalasex01a.na.qualcomm.com (10.47.209.196) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.922.19; Tue, 4 Jan 2022 03:59:59 -0800 From: Souradeep Chowdhury To: , , , , , CC: , , , , , , , , Subject: [PATCH V3 6/7] arm64: dts: qcom: sc7280: Set the default dr_mode for usb2 Date: Tue, 4 Jan 2022 17:28:19 +0530 Message-ID: <9f9458c331d4b144ab796eb00f7a2943edb50558.1641288286.git.quic_schowdhu@quicinc.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: References: MIME-Version: 1.0 X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01b.na.qualcomm.com (10.46.141.250) To nalasex01a.na.qualcomm.com (10.47.209.196) Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org Set the default dr_mode for usb2 node to "otg" to enable. role-switch for EUD(Embedded USB Debugger) connector node. Signed-off-by: Souradeep Chowdhury --- arch/arm64/boot/dts/qcom/sc7280-idp.dts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/arch/arm64/boot/dts/qcom/sc7280-idp.dts b/arch/arm64/boot/dts/qcom/sc7280-idp.dts index 64fc22a..7c69c78 100644 --- a/arch/arm64/boot/dts/qcom/sc7280-idp.dts +++ b/arch/arm64/boot/dts/qcom/sc7280-idp.dts @@ -61,6 +61,10 @@ modem-init; }; +&usb_2_dwc3 { + dr_mode = "otg"; +}; + &pmk8350_vadc { pmr735a_die_temp { reg = ; From patchwork Tue Jan 4 11:58:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Souradeep Chowdhury X-Patchwork-Id: 529910 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id DBDF7C4332F for ; Tue, 4 Jan 2022 12:00:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232849AbiADMAM (ORCPT ); Tue, 4 Jan 2022 07:00:12 -0500 Received: from alexa-out-sd-02.qualcomm.com ([199.106.114.39]:3750 "EHLO alexa-out-sd-02.qualcomm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232800AbiADMAL (ORCPT ); Tue, 4 Jan 2022 07:00:11 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; i=@quicinc.com; q=dns/txt; s=qcdkim; t=1641297610; x=1672833610; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=Z4lRkDztl8kkMzv5y4vn6o4suy5hREey12tivQS1lgQ=; b=SU9KAVtdZdSQ7KKjehkNjExqe+beFzzvc+8t8Ffx4t33TsAPZzViv/3s XbWMOpIRWGhzJWQy8nsKzt53E9Kct1TwTRRxhA3p/LMpGkpgqm0td2Jgv jDmlfazOQnq30Dfi5ZcTj2eVbaVJS91rJmlphrQoq9u74oVJYgZiSMK3g Q=; Received: from unknown (HELO ironmsg03-sd.qualcomm.com) ([10.53.140.143]) by alexa-out-sd-02.qualcomm.com with ESMTP; 04 Jan 2022 04:00:10 -0800 X-QCInternal: smtphost Received: from nasanex01c.na.qualcomm.com ([10.47.97.222]) by ironmsg03-sd.qualcomm.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Jan 2022 04:00:08 -0800 Received: from nalasex01a.na.qualcomm.com (10.47.209.196) by nasanex01c.na.qualcomm.com (10.47.97.222) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.922.19; Tue, 4 Jan 2022 04:00:08 -0800 Received: from blr-ubuntu-525.qualcomm.com (10.80.80.8) by nalasex01a.na.qualcomm.com (10.47.209.196) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.922.19; Tue, 4 Jan 2022 04:00:03 -0800 From: Souradeep Chowdhury To: , , , , , CC: , , , , , , , , Subject: [PATCH V3 7/7] MAINTAINERS: Add maintainer entry for EUD Date: Tue, 4 Jan 2022 17:28:20 +0530 Message-ID: X-Mailer: git-send-email 2.7.4 In-Reply-To: References: MIME-Version: 1.0 X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01b.na.qualcomm.com (10.46.141.250) To nalasex01a.na.qualcomm.com (10.47.209.196) Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org Add the entry for maintainer for EUD driver and other associated files. Signed-off-by: Souradeep Chowdhury --- MAINTAINERS | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/MAINTAINERS b/MAINTAINERS index 0227e15..54f616a 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -7018,6 +7018,14 @@ F: include/trace/events/mdio.h F: include/uapi/linux/mdio.h F: include/uapi/linux/mii.h +EUD-QCOM +M: Souradeep Chowdhury +L: linux-arm-msm@vger.kernel.org +S: Maintained +F: Documentation/ABI/testing/sysfs-driver-eud +F: Documentation/devicetree/bindings/arm/msm/qcom,eud.yaml +F: drivers/usb/common/qcom_eud.c + EXFAT FILE SYSTEM M: Namjae Jeon M: Sungjong Seo