Add Embedded USB Debugger (EUD) driver
Subsystems (7)
Souradeep Chowdhury
maintainerv2 cover Add Embedded USB Debugger (EUD) driver
This is a series of patches that implements a driver for the control peripheral, EUD (Embedded USB Debugger). The EUD is a mini-USB hub implemented on chip to support the USB-based debug and trace capabilities. Apart from debug capabilities, EUD has a control peripheral. Control Peripheral is on when EUD is on and gets signals like USB attach, pet EUD etc. EUD driver listens to events like USB attach or detach and then informs the USB about these events via ROLE-SWITCH. At regular intervals, the EUD driver receives an interrupt to pet the driver indicating that the software is functional.
Changes in V2
*Fixed the yaml issue and also implemeted comments on yaml in V1.
Changes in V1
* EUD has now been mapped as a separate DT node as it is an independent QCOM IP.
* EUD is attached to the connector child of dwc3 via port end point since EUD driver needs the connector for role-switching.
* EUD driver has been moved now to drivers/soc/qcom/qcom_eud.c.
* All the comments from version 0 of the patch has been implemented.
Souradeep Chowdhury (8):
dt-bindings: Add the yaml bindings for EUD
dt-bindings: connector: Add property for EUD type-C connector
bindings: usb: dwc3: Update dwc3 properties for EUD connector
usb: dwc3: drd: Register the eud connector child node for dwc3
soc: qcom: eud: Add driver support for Embedded USB Debugger(EUD)
arm64: dts: qcom: sc7280: Add EUD dt node and dwc3 connector
arm64: dts: qcom: sc7280: Set the default dr_mode for usb2
MAINTAINERS: Add maintainer entry for EUD
Documentation/ABI/testing/sysfs-driver-eud | 9 + .../bindings/connector/usb-connector.yaml | 4 + .../devicetree/bindings/soc/qcom/qcom,eud.yaml | 50 ++++ .../devicetree/bindings/usb/snps,dwc3.yaml | 6 + MAINTAINERS | 8 + arch/arm64/boot/dts/qcom/sc7280-idp.dts | 4 + arch/arm64/boot/dts/qcom/sc7280.dtsi | 25 ++ drivers/soc/qcom/Kconfig | 10 + drivers/soc/qcom/Makefile | 1 + drivers/soc/qcom/qcom_eud.c | 268 +++++++++++++++++++++ drivers/usb/dwc3/drd.c | 26 ++ 11 files changed, 411 insertions(+) create mode 100644 Documentation/ABI/testing/sysfs-driver-eud create mode 100644 Documentation/devicetree/bindings/soc/qcom/qcom,eud.yaml create mode 100644 drivers/soc/qcom/qcom_eud.c
--
2.7.4
Souradeep Chowdhury
maintainerPATCH v2 1/8 dt-bindings: Add the yaml bindings for EUD
Documentation for Embedded USB Debugger(EUD) device tree bindings in yaml format.
--- .../devicetree/bindings/soc/qcom/qcom,eud.yaml | 50 ++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 Documentation/devicetree/bindings/soc/qcom/qcom,eud.yaml
Documentation/devicetree/bindings/soc/qcom/qcom,eud.yaml new file +50 -0
@@ -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 <[email protected]> + +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>; + };
Signature · 1 line
2.7.4
Souradeep Chowdhury
maintainerPATCH v2 2/8 dt-bindings: connector: Add property for EUD type-C connector
In reply to Souradeep ChowdhuryAdded 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.
--- Documentation/devicetree/bindings/connector/usb-connector.yaml | 4 ++++ 1 file changed, 4 insertions(+)
Documentation/devicetree/bindings/connector/usb-connector.yaml +4 -0
@@ -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.
Signature · 1 line
2.7.4
Souradeep Chowdhury
maintainerPATCH v2 3/8 bindings: usb: dwc3: Update dwc3 properties for EUD connector
In reply to Souradeep ChowdhuryAdd the connector property for dwc3 node. This connector can be used to role-switch the controller from device to host and vice versa.
--- Documentation/devicetree/bindings/usb/snps,dwc3.yaml | 6 ++++++ 1 file changed, 6 insertions(+)
Documentation/devicetree/bindings/usb/snps,dwc3.yaml +6 -0
@@ -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:
Signature · 1 line
2.7.4
Souradeep Chowdhury
maintainerPATCH v2 4/8 usb: dwc3: drd: Register the eud connector child node for dwc3
In reply to Souradeep ChowdhuryRegister the child node for dwc3 which is the "eud_usb_connector". The eud driver will be able to switch the usb role from device to host and vice versa using the role switch property of dwc3 node.
--- drivers/usb/dwc3/drd.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+)
drivers/usb/dwc3/drd.c +26 -0
@@ -8,6 +8,7 @@*/ #include <linux/extcon.h> +#include <linux/of_platform.h> #include <linux/of_graph.h> #include <linux/platform_device.h> #include <linux/property.h>
@@ -164,6 +165,27 @@ static int dwc3_otg_get_irq(struct dwc3 *dwc)return irq; } +static int dwc3_register_eud (struct dwc3 *dwc) +{ +struct device *dev = dwc->dev; +struct device_node *np = dev->of_node; +int ret; + +of_get_child_by_name (np,"eud_usb_connector" ); +if (!np) { +dev_dbg (dev,"no usb_connector child node specified\n" ); +return 0 ; + } + + ret =of_platform_populate (np,NULL ,NULL , dev); +if (ret) { +dev_err (dev,"failed to register usb_connector - %d\n" , ret); +return ret; + } + +return 0 ; +} +void dwc3_otg_init (struct dwc3 *dwc) {u32 reg;
@@ -580,6 +602,10 @@ int dwc3_drd_init(struct dwc3 *dwc) ret =dwc3_setup_role_switch (dwc);if (ret <0 )return ret; + + ret =dwc3_register_eud (dwc); +if (ret <0 ) +return ret; }else if (dwc->edev) { dwc->edev_nb.notifier_call = dwc3_drd_notifier; ret = extcon_register_notifier(dwc->edev, EXTCON_USB_HOST,
Signature · 1 line
2.7.4
Rob Herring
maintainerRe: [PATCH V2 4/8] usb: dwc3: drd: Register the eud connector child node for dwc3
Quoted 22 lines · Souradeep Chowdhury
Register the child node for dwc3 which is the "
eud_usb_connector". The eud driver will be able to switch the usb role from device to host and vice versa using the role switch property of dwc3 node.Signed-off-by Souradeep Chowdhury <[email protected]>--- drivers/usb/dwc3/drd.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+)drivers/usb/dwc3/drd.c +1
-0@@ -8,6 +8,7 @@*/ #include <linux/extcon.h> +#include <linux/of_platform.h> #include <linux/of_graph.h> #include <linux/platform_device.h> #include <linux/property.h>
drivers/usb/dwc3/drd.c static int dwc3_otg_get_irq(struct dwc3 *dwc) · line 174
Quoted 10 lines
drivers/usb/dwc3/drd.c +7
-0@@ -164,6 +165,27 @@ static int dwc3_otg_get_irq(struct dwc3 *dwc)return irq; } +static int dwc3_register_eud (struct dwc3 *dwc) +{ +struct device *dev = dwc->dev; +struct device_node *np = dev->of_node; +int ret; + +of_get_child_by_name (np,"eud_usb_connector" );
Connector nodes are named 'connector' or possibly 'usb-connector'. If you are creating an ABI with the node name, it should be documented. However, it's preferred to use 'compatible' for identifying nodes rather than a node name.
drivers/usb/dwc3/drd.c static int dwc3_otg_get_irq(struct dwc3 *dwc) · line 180
Quoted 6 lines
drivers/usb/dwc3/drd.c +6
-0+if (!np) { +dev_dbg (dev,"no usb_connector child node specified\n" ); +return 0 ; + } + + ret =of_platform_populate (np,NULL ,NULL , dev);
But why is any of this needed. The connector doesn't have a driver (I expect eventually we will) and the EUD device is not a child.
Quoted 26 lines
drivers/usb/dwc3/drd.c +12
-0+if (ret) { +dev_err (dev,"failed to register usb_connector - %d\n" , ret); +return ret; + } + +return 0 ; +} +void dwc3_otg_init (struct dwc3 *dwc) {u32 reg;@@ -580,6 +602,10 @@ int dwc3_drd_init(struct dwc3 *dwc) ret =dwc3_setup_role_switch (dwc);if (ret <0 )return ret; + + ret =dwc3_register_eud (dwc); +if (ret <0 ) +return ret; }else if (dwc->edev) { dwc->edev_nb.notifier_call = dwc3_drd_notifier; ret = extcon_register_notifier(dwc->edev, EXTCON_USB_HOST,Signature · 1 line
2.7.4
Souradeep Chowdhury
maintainerRe: [PATCH V2 4/8] usb: dwc3: drd: Register the eud connector child node for dwc3
Quoted 26 lines · Rob Herring
Quoted 25 lines · Souradeep Chowdhury
Register the child node for dwc3 which is the "
eud_usb_connector". The eud driver will be able to switch the usb role from device to host and vice versa using the role switch property of dwc3 node.Signed-off-by Souradeep Chowdhury <[email protected]>--- drivers/usb/dwc3/drd.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+)drivers/usb/dwc3/drd.c +1
-0@@ -8,6 +8,7 @@*/ #include <linux/extcon.h> +#include <linux/of_platform.h> #include <linux/of_graph.h> #include <linux/platform_device.h> #include <linux/property.h> @@ -164,6 +165,27 @@ static int dwc3_otg_get_irq(struct dwc3 *dwc)return irq; }
Quoted 11 lines
drivers/usb/dwc3/drd.c static int dwc3_otg_get_irq(struct dwc3 *dwc) · line 174
Quoted 7 lines
drivers/usb/dwc3/drd.c +7
-0+static int dwc3_register_eud (struct dwc3 *dwc) +{ +struct device *dev = dwc->dev; +struct device_node *np = dev->of_node; +int ret; + +of_get_child_by_name (np,"eud_usb_connector" );Connector nodes are named 'connector' or possibly 'usb-connector'. If you are creating an ABI with the node name, it should be documented. However, it's preferred to use 'compatible' for identifying nodes rather than a node name.
Ack.
Quoted 8 lines
drivers/usb/dwc3/drd.c static int dwc3_otg_get_irq(struct dwc3 *dwc) · line 180
Quoted 6 lines
drivers/usb/dwc3/drd.c +6
-0+if (!np) { +dev_dbg (dev,"no usb_connector child node specified\n" ); +return 0 ; + } + + ret =of_platform_populate (np,NULL ,NULL , dev);But why is any of this needed. The connector doesn't have a driver (I expect eventually we will) and the EUD device is not a child.
Ack. This can be removed as we are no longer mapping EUD as a type C connector.
Quoted 26 lines
Quoted 26 lines
drivers/usb/dwc3/drd.c +12
-0+if (ret) { +dev_err (dev,"failed to register usb_connector - %d\n" , ret); +return ret; + } + +return 0 ; +} +void dwc3_otg_init (struct dwc3 *dwc) {u32 reg;@@ -580,6 +602,10 @@ int dwc3_drd_init(struct dwc3 *dwc) ret =dwc3_setup_role_switch (dwc);if (ret <0 )return ret; + + ret =dwc3_register_eud (dwc); +if (ret <0 ) +return ret; }else if (dwc->edev) { dwc->edev_nb.notifier_call = dwc3_drd_notifier; ret = extcon_register_notifier(dwc->edev, EXTCON_USB_HOST,Signature · 1 line
2.7.4
Souradeep Chowdhury
maintainerPATCH v2 5/8 soc: qcom: eud: Add driver support for Embedded USB Debugger(EUD)
In reply to Souradeep ChowdhuryAdd 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
--- Documentation/ABI/testing/sysfs-driver-eud | 9 + drivers/soc/qcom/Kconfig | 10 ++ drivers/soc/qcom/Makefile | 1 + drivers/soc/qcom/qcom_eud.c | 268 +++++++++++++++++++++++++++++ 4 files changed, 288 insertions(+) create mode 100644 Documentation/ABI/testing/sysfs-driver-eud create mode 100644 drivers/soc/qcom/qcom_eud.c
Documentation/ABI/testing/sysfs-driver-eud new file +9 -0
@@ -0,0 +1,9 @@ +What: /sys/bus/platform/drivers/eud/.../enable +Date: October 2021 +Contact: Souradeep Chowdhury <[email protected]> +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.
drivers/soc/qcom/Kconfig +10 -0
@@ -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
drivers/soc/qcom/Makefile +1 -0
@@ -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
drivers/soc/qcom/qcom_eud.c new file +268 -0
268 lines not on this page · raw message
--
2.7.4
Re: [PATCH V2 5/8] soc: qcom: eud: Add driver support for Embedded USB Debugger(EUD)
Quoted 27 lines · Souradeep Chowdhury
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/.../enableTo disable eud, following is the command
echo 0 >/sys/bus/platform/.../enableSigned-off-by Souradeep Chowdhury <[email protected]>--- Documentation/ABI/testing/sysfs-driver-eud | 9 + drivers/soc/qcom/Kconfig | 10 ++ drivers/soc/qcom/Makefile | 1 + drivers/soc/qcom/qcom_eud.c | 268 +++++++++++++++++++++++++++++ 4 files changed, 288 insertions(+) create mode 100644 Documentation/ABI/testing/sysfs-driver-eud create mode 100644 drivers/soc/qcom/qcom_eud.cDocumentation/ABI/testing/sysfs-driver-eud new file +0
-0
Documentation/ABI/testing/sysfs-driver-eud line 2
Quoted 2 lines
Documentation/ABI/testing/sysfs-driver-eud new file +2
-0@@ -0,0 +1,9 @@ +What: /sys/bus/platform/drivers/eud/.../enable +Date: October 2021
You sent this patch in December 2021 :(
Quoted 142 lines
Documentation/ABI/testing/sysfs-driver-eud new file +7
-0+Contact: Souradeep Chowdhury <[email protected]> +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.drivers/soc/qcom/Kconfig +10
-0@@ -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_TESTdrivers/soc/qcom/Makefile +1
-0@@ -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.odrivers/soc/qcom/qcom_eud.c new file +96
-0@@ -0,0 +1,268 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* +* Copyright (c) 2015-2021, The Linux Foundation. All rights reserved. +*/ + +#include <linux/bitops.h> +#include <linux/delay.h> +#include <linux/err.h> +#include <linux/interrupt.h> +#include <linux/io.h> +#include <linux/iopoll.h> +#include <linux/kernel.h> +#include <linux/module.h> +#include <linux/of.h> +#include <linux/platform_device.h> +#include <linux/slab.h> +#include <linux/sysfs.h> +#include <linux/usb/role.h> + +#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 ,
drivers/soc/qcom/qcom_eud.c line 106
Quoted 10 lines
drivers/soc/qcom/qcom_eud.c new file +10
-0+}; + +static struct attribute_group attr_group = { + .attrs = eud_attrs, +}; + +static const struct attribute_group *attr_groups[] = { + &attr_group, +NULL +};
ATTRIBUTE_GROUPS()?
thanks,
greg k-h
Souradeep Chowdhury
maintainerRe: [PATCH V2 5/8] soc: qcom: eud: Add driver support for Embedded USB Debugger(EUD)
Quoted 22 lines · Greg KH
Quoted 21 lines · Souradeep Chowdhury
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/.../enableTo disable eud, following is the command
echo 0 >/sys/bus/platform/.../enableSigned-off-by Souradeep Chowdhury <[email protected]>--- Documentation/ABI/testing/sysfs-driver-eud | 9 + drivers/soc/qcom/Kconfig | 10 ++ drivers/soc/qcom/Makefile | 1 + drivers/soc/qcom/qcom_eud.c | 268 +++++++++++++++++++++++++++++ 4 files changed, 288 insertions(+)create mode 100644
Documentation/ABI/testing/sysfs-driver-eudcreate mode 100644drivers/soc/qcom/qcom_eud.c
Quoted 10 lines
Documentation/ABI/testing/sysfs-driver-eud line 2
Quoted 8 lines
Documentation/ABI/testing/sysfs-driver-eud new file +2
-0@@ -0,0 +1,9 @@ +What: /sys/bus/platform/drivers/eud/.../enable +Date: October 2021You sent this patch in December 2021 :(
Ack
Quoted 146 lines
Quoted 146 lines
Documentation/ABI/testing/sysfs-driver-eud new file +7
-0+Contact: Souradeep Chowdhury <[email protected]> +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.drivers/soc/qcom/Kconfig +10
-0@@ -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_TESTdrivers/soc/qcom/Makefile +1
-0@@ -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.odrivers/soc/qcom/qcom_eud.c new file +99
-0@@ -0,0 +1,268 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* +* Copyright (c) 2015-2021, The Linux Foundation. All rights reserved. +*/ + +#include <linux/bitops.h> +#include <linux/delay.h> +#include <linux/err.h> +#include <linux/interrupt.h> +#include <linux/io.h> +#include <linux/iopoll.h> +#include <linux/kernel.h> +#include <linux/module.h> +#include <linux/of.h> +#include <linux/platform_device.h> +#include <linux/slab.h> +#include <linux/sysfs.h> +#include <linux/usb/role.h> + +#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 , +}; + +static struct attribute_group attr_group = {
Quoted 8 lines
drivers/soc/qcom/qcom_eud.c line 106
Quoted 7 lines
drivers/soc/qcom/qcom_eud.c new file +7
-0+ .attrs = eud_attrs, +}; + +static const struct attribute_group *attr_groups[] = { + &attr_group, +NULL +};
ATTRIBUTE_GROUPS()?
Ack
Quoted 4 lines
thanks,
greg k-h
Souradeep Chowdhury
maintainerPATCH v2 6/8 arm64: dts: qcom: sc7280: Add EUD dt node and dwc3 connector
In reply to Souradeep ChowdhuryAdd 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.
--- arch/arm64/boot/dts/qcom/sc7280.dtsi | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+)
arch/arm64/boot/dts/qcom/sc7280.dtsi +25 -0
@@ -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 = <GIC_SPI 582 IRQ_TYPE_LEVEL_HIGH>; }; + 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";
Signature · 1 line
2.7.4
Rob Herring
maintainerRe: [PATCH V2 6/8] arm64: dts: qcom: sc7280: Add EUD dt node and dwc3 connector
Quoted 17 lines · Souradeep Chowdhury
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 <[email protected]>--- arch/arm64/boot/dts/qcom/sc7280.dtsi | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+)arch/arm64/boot/dts/qcom/sc7280.dtsi +0
-0
arch/arm64/boot/dts/qcom/sc7280.dtsi line 1323
Quoted 9 lines
arch/arm64/boot/dts/qcom/sc7280.dtsi +6
-0@@ -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 {
It is already defined that port@0 of the connector is USB HS data. Is that the case here? What about the SS lines?
From the description, it sounds like the data path is DWC3 -> EUD -> connector. The DT structure doesn't match that.
Quoted 33 lines
arch/arm64/boot/dts/qcom/sc7280.dtsi +19
-0+ usb2_role_switch: endpoint { + remote-endpoint = <&eud_ep>; + }; + }; + }; + }; }; };@@ -1339,6 +1351,19 @@ interrupts = <GIC_SPI 582 IRQ_TYPE_LEVEL_HIGH>; }; + 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";Signature · 1 line
2.7.4
Souradeep Chowdhury
maintainerRe: [PATCH V2 6/8] arm64: dts: qcom: sc7280: Add EUD dt node and dwc3 connector
Quoted 13 lines · Rob Herring
Quoted 12 lines · Souradeep Chowdhury
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 <[email protected]>--- arch/arm64/boot/dts/qcom/sc7280.dtsi | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+)
Quoted 16 lines
Quoted 5 lines
arch/arm64/boot/dts/qcom/sc7280.dtsi +0
-0arch/arm64/boot/dts/qcom/sc7280.dtsi line 1323
Quoted 9 lines
arch/arm64/boot/dts/qcom/sc7280.dtsi +6
-0@@ -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 {It is already defined that port@0 of the connector is USB HS data. Is that the case here? What about the SS lines?
As per the yaml documentation this is to be used for USB HS lines but in this case I am using the port to get the connector fwnode from the eud driver and then perform the role switch from the connector parent which is the dwc3 controller. Should I update the yaml file to include this description?
Quoted 2 lines
From the description, it sounds like the data path is DWC3 -> EUD ->
connector. The DT structure doesn't match that.
EUD is an independent QCOM IP , it is a mini usb hub which can only function in device mode. That's why it has been mapped as a separate device tree node connected to the type c connector via port endpoint to perform a role switch when necessary. I have kept EUD and connector at the same level as there is no direct data path from EUD to the connector and both are at a level below the controller.
Quoted 34 lines
Quoted 34 lines
arch/arm64/boot/dts/qcom/sc7280.dtsi +19
-0+ usb2_role_switch: endpoint { + remote-endpoint = <&eud_ep>; + }; + }; + }; + }; }; };@@ -1339,6 +1351,19 @@ interrupts = <GIC_SPI 582 IRQ_TYPE_LEVEL_HIGH>; }; + 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";Signature · 1 line
2.7.4
Souradeep Chowdhury
maintainerPATCH v2 7/8 arm64: dts: qcom: sc7280: Set the default dr_mode for usb2
In reply to Souradeep ChowdhurySet the default dr_mode for usb2 node to "otg" to enable. role-switch for EUD(Embedded USB Debugger) connector node.
--- arch/arm64/boot/dts/qcom/sc7280-idp.dts | 4 ++++ 1 file changed, 4 insertions(+)
arch/arm64/boot/dts/qcom/sc7280-idp.dts +4 -0
@@ -61,6 +61,10 @@ modem-init; }; +&usb_2_dwc3 { + dr_mode = "otg"; +}; + &pmk8350_vadc { pmr735a_die_temp { reg = <PMR735A_ADC7_DIE_TEMP>;
Signature · 1 line
2.7.4
Souradeep Chowdhury
maintainerPATCH v2 8/8 MAINTAINERS: Add maintainer entry for EUD
In reply to Souradeep ChowdhuryAdd the entry for maintainer for EUD driver
and other associated files.
--- MAINTAINERS | 8 ++++++++ 1 file changed, 8 insertions(+)
MAINTAINERS +8 -0
@@ -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 <[email protected]> +L: [email protected] +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 <[email protected]> M: Sungjong Seo <[email protected]>
--
2.7.4