From: taehyun.cho Date: Tue, 29 May 2018 06:10:20 +0000 (+0900) Subject: [COMMON] usb: add typec driver for VTS test X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=856a87e3eef86e2be1509cff7fa72baabb1c4e19;p=GitHub%2FLineageOS%2Fandroid_kernel_motorola_exynos9610.git [COMMON] usb: add typec driver for VTS test Change-Id: I24f9a351bdde65d4e6cbe32487c499f562d3385f Signed-off-by: taehyun.cho --- diff --git a/drivers/usb/dwc3/Kconfig b/drivers/usb/dwc3/Kconfig index 4c9e56d8776a..ee895c6de837 100644 --- a/drivers/usb/dwc3/Kconfig +++ b/drivers/usb/dwc3/Kconfig @@ -64,6 +64,7 @@ config USB_DWC3_EXYNOS tristate "Samsung Exynos Platform" depends on (ARCH_EXYNOS || COMPILE_TEST) && OF default USB_DWC3 + select TYPEC help Recent Exynos5 SoCs ship with one DesignWare Core USB3 IP inside, say 'Y' or 'M' if you have one such device. diff --git a/drivers/usb/dwc3/dwc3-exynos.c b/drivers/usb/dwc3/dwc3-exynos.c index d2fb09da3e40..7e46b6547204 100644 --- a/drivers/usb/dwc3/dwc3-exynos.c +++ b/drivers/usb/dwc3/dwc3-exynos.c @@ -30,6 +30,9 @@ #include #include #include +#if defined(CONFIG_TYPEC) +#include +#endif #include #include @@ -45,6 +48,16 @@ struct dwc3_exynos_rsw { struct work_struct work; }; +#if defined(CONFIG_TYPEC) +struct intf_typec { + /* struct mutex lock; */ /* device lock */ + struct device *dev; + struct typec_port *port; + struct typec_capability cap; + struct typec_partner *partner; +}; +#endif + struct dwc3_exynos { struct platform_device *usb2_phy; struct platform_device *usb3_phy; @@ -58,6 +71,9 @@ struct dwc3_exynos { int idle_ip_index; struct dwc3_exynos_rsw rsw; +#if defined(CONFIG_TYPEC) + struct intf_typec *typec; +#endif }; void dwc3_otg_run_sm(struct otg_fsm *fsm); @@ -407,8 +423,10 @@ static int dwc3_exynos_probe(struct platform_device *pdev) struct dwc3_exynos *exynos; struct device *dev = &pdev->dev; struct device_node *node = dev->of_node; - int ret; +#if defined(CONFIG_TYPEC) + struct intf_typec *typec; +#endif pr_info("%s: +++\n", __func__); exynos = devm_kzalloc(dev, sizeof(*exynos), GFP_KERNEL); @@ -491,6 +509,28 @@ static int dwc3_exynos_probe(struct platform_device *pdev) goto populate_err; } +#if defined(CONFIG_TYPEC) + typec = devm_kzalloc(dev, sizeof(*typec), GFP_KERNEL); + if (!typec) + return -ENOMEM; + + /* mutex_init(&md05->lock); */ + typec->dev = dev; + + typec->cap.type = TYPEC_PORT_DRP; + typec->cap.revision = USB_TYPEC_REV_1_1; + typec->cap.prefer_role = TYPEC_NO_PREFERRED_ROLE; + + typec->port = typec_register_port(dev, &typec->cap); + if (!typec->port) + return -ENODEV; + + typec_set_data_role(typec->port, TYPEC_DEVICE); + typec_set_pwr_role(typec->port, TYPEC_SINK); + typec_set_pwr_opmode(typec->port, TYPEC_PWR_MODE_USB); + exynos->typec = typec; +#endif + pr_info("%s: ---\n", __func__); return 0; @@ -532,6 +572,11 @@ static int dwc3_exynos_remove(struct platform_device *pdev) if (exynos->vdd10) regulator_disable(exynos->vdd10); +#if defined(CONFIG_TYPEC) + typec_unregister_partner(exynos->typec->partner); + typec_unregister_port(exynos->typec->port); +#endif + return 0; }