From 70a7fe177dbf7ff4755e1de14cfc06f5f067b20e Mon Sep 17 00:00:00 2001 From: Gustavo Solaira Date: Mon, 9 Jul 2018 19:03:00 -0700 Subject: [PATCH 1/4] diag: Disable the code for diag_smux Disable the diag_smux code to fix the build with diagfwd USB enabled since the dependencies for diag_smux are not available it is deprecated in this kernel version. Change-Id: I6a8bc3a34f67ed5b1ca175cad0b3067e2c2df199 Signed-off-by: Gustavo Solaira --- drivers/char/diag/Makefile | 1 - drivers/char/diag/diag_debugfs.c | 3 +-- drivers/char/diag/diagfwd_bridge.c | 12 +----------- 3 files changed, 2 insertions(+), 14 deletions(-) diff --git a/drivers/char/diag/Makefile b/drivers/char/diag/Makefile index c5ec4f081c55..d57ebd8d671e 100644 --- a/drivers/char/diag/Makefile +++ b/drivers/char/diag/Makefile @@ -1,6 +1,5 @@ obj-$(CONFIG_DIAG_CHAR) := diagchar.o obj-$(CONFIG_DIAGFWD_BRIDGE_CODE) += diagfwd_bridge.o obj-$(CONFIG_USB_QCOM_DIAG_BRIDGE) += diagfwd_hsic.o -obj-$(CONFIG_USB_QCOM_DIAG_BRIDGE) += diagfwd_smux.o obj-$(CONFIG_MSM_MHI) += diagfwd_mhi.o diagchar-objs := diagchar_core.o diagchar_hdlc.o diagfwd.o diagfwd_glink.o diagfwd_peripheral.o diagfwd_smd.o diagfwd_socket.o diag_mux.o diag_memorydevice.o diag_usb.o diagmem.o diagfwd_cntl.o diag_dci.o diag_masks.o diag_debugfs.o diff --git a/drivers/char/diag/diag_debugfs.c b/drivers/char/diag/diag_debugfs.c index 5e455878ac3e..ad370ada335f 100644 --- a/drivers/char/diag/diag_debugfs.c +++ b/drivers/char/diag/diag_debugfs.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2011-2017, The Linux Foundation. All rights reserved. +/* Copyright (c) 2011-2018, The Linux Foundation. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 and @@ -23,7 +23,6 @@ #endif #ifdef CONFIG_USB_QCOM_DIAG_BRIDGE #include "diagfwd_hsic.h" -#include "diagfwd_smux.h" #endif #ifdef CONFIG_MSM_MHI #include "diagfwd_mhi.h" diff --git a/drivers/char/diag/diagfwd_bridge.c b/drivers/char/diag/diagfwd_bridge.c index 3342984eb795..d8e7b39eae8b 100644 --- a/drivers/char/diag/diagfwd_bridge.c +++ b/drivers/char/diag/diagfwd_bridge.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2012-2017, The Linux Foundation. All rights reserved. +/* Copyright (c) 2012-2018, The Linux Foundation. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 and @@ -18,14 +18,10 @@ #include #include #include -#ifdef USB_QCOM_DIAG_BRIDGE -#include -#endif #include "diag_mux.h" #include "diagfwd_bridge.h" #ifdef USB_QCOM_DIAG_BRIDGE #include "diagfwd_hsic.h" -#include "diagfwd_smux.h" #endif #include "diagfwd_mhi.h" #include "diag_dci.h" @@ -272,11 +268,6 @@ int diagfwd_bridge_init() err = diag_mdm_init(); if (err) goto fail; - #ifdef USB_QCOM_DIAG_BRIDGE - err = diag_smux_init(); - if (err) - goto fail; - #endif return 0; fail: @@ -288,7 +279,6 @@ void diagfwd_bridge_exit() { #ifdef USB_QCOM_DIAG_BRIDGE diag_hsic_exit(); - diag_smux_exit(); #endif } From d6edcd0fafd854a2adc331fe7f3d05c77a916968 Mon Sep 17 00:00:00 2001 From: Ajay Agarwal Date: Fri, 22 Jun 2018 10:27:06 +0530 Subject: [PATCH 2/4] defconfig: msm-auto: Enable diag_ipc_bridge driver for msm8996 Enable DIAG and IPC bridge driver on msm8996 auto to support interfacing with DIAG and QMI interfaces. Change-Id: I8b32bdfc6aa29c090b21512e202c2822b9752a48 Signed-off-by: Ajay Agarwal --- arch/arm64/configs/msm-auto-perf_defconfig | 1 + arch/arm64/configs/msm-auto_defconfig | 1 + 2 files changed, 2 insertions(+) diff --git a/arch/arm64/configs/msm-auto-perf_defconfig b/arch/arm64/configs/msm-auto-perf_defconfig index acf8acd6375c..81e18d05b0d0 100644 --- a/arch/arm64/configs/msm-auto-perf_defconfig +++ b/arch/arm64/configs/msm-auto-perf_defconfig @@ -428,6 +428,7 @@ CONFIG_USB_DWC3=y CONFIG_USB_ISP1760=y CONFIG_USB_EHSET_TEST_FIXTURE=y CONFIG_USB_QTI_KS_BRIDGE=y +CONFIG_USB_QCOM_DIAG_BRIDGE=y CONFIG_NOP_USB_XCEIV=y CONFIG_USB_MSM_SSPHY_QMP=y CONFIG_MSM_QUSB_PHY=y diff --git a/arch/arm64/configs/msm-auto_defconfig b/arch/arm64/configs/msm-auto_defconfig index 15b059a621ac..cc1000edbef0 100644 --- a/arch/arm64/configs/msm-auto_defconfig +++ b/arch/arm64/configs/msm-auto_defconfig @@ -432,6 +432,7 @@ CONFIG_USB_DWC3=y CONFIG_USB_ISP1760=y CONFIG_USB_EHSET_TEST_FIXTURE=y CONFIG_USB_QTI_KS_BRIDGE=y +CONFIG_USB_QCOM_DIAG_BRIDGE=y CONFIG_NOP_USB_XCEIV=y CONFIG_USB_MSM_SSPHY_QMP=y CONFIG_MSM_QUSB_PHY=y From 2bd670287772ce6ccd6f154b299e332d6c09df7b Mon Sep 17 00:00:00 2001 From: Gustavo Solaira Date: Mon, 9 Jul 2018 19:06:49 -0700 Subject: [PATCH 3/4] usb: misc: diag_ipc_bridge: Add support for 901D PID Add support for creation of diag traffic channel in case the connected device has 0x05C6 VID and 0x901D PID. 0x901D : DIAG + ADB Change-Id: I6df0aca714f10ea7d854f621e19da1388a7e7d5c Signed-off-by: Gustavo Solaira --- drivers/usb/misc/diag_ipc_bridge.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/usb/misc/diag_ipc_bridge.c b/drivers/usb/misc/diag_ipc_bridge.c index b9ced8d0062d..a652c8f9bab7 100644 --- a/drivers/usb/misc/diag_ipc_bridge.c +++ b/drivers/usb/misc/diag_ipc_bridge.c @@ -730,6 +730,8 @@ static int diag_bridge_resume(struct usb_interface *ifc) static const struct usb_device_id diag_bridge_ids[] = { { USB_DEVICE_INTERFACE_NUMBER(0x5c6, 0x9001, 0), .driver_info = DEV_ID(0), }, + { USB_DEVICE_INTERFACE_NUMBER(0x5c6, 0x901D, 0), + .driver_info = DEV_ID(0), }, { USB_DEVICE_INTERFACE_NUMBER(0x5c6, 0x9034, 0), .driver_info = DEV_ID(0), }, { USB_DEVICE_INTERFACE_NUMBER(0x5c6, 0x9048, 0), From 146820788aab993081e6dd902d51987e1cf8c855 Mon Sep 17 00:00:00 2001 From: Gustavo Solaira Date: Mon, 9 Jul 2018 19:21:00 -0700 Subject: [PATCH 4/4] diag: Enable diagfwd via USB even when MHI is available Some devices need diag via USB even when MHI is used for rmnet and qmi tethering. This is because of lack of support for diagfwd for mhi_dev in Linux. Change-Id: Ie0ec19ee109d49aa409d1df3ad5ca24b75de7102 Signed-off-by: Gustavo Solaira --- .../bindings/arm/msm/diagfwd_usb.txt | 9 +++++ drivers/char/diag/diagchar_core.c | 38 ++++++++++++++++++- drivers/char/diag/diagfwd_bridge.c | 25 ++++++++---- drivers/char/diag/diagfwd_bridge.h | 4 +- 4 files changed, 65 insertions(+), 11 deletions(-) create mode 100644 Documentation/devicetree/bindings/arm/msm/diagfwd_usb.txt diff --git a/Documentation/devicetree/bindings/arm/msm/diagfwd_usb.txt b/Documentation/devicetree/bindings/arm/msm/diagfwd_usb.txt new file mode 100644 index 000000000000..bb72ffe5fe66 --- /dev/null +++ b/Documentation/devicetree/bindings/arm/msm/diagfwd_usb.txt @@ -0,0 +1,9 @@ +QTI Diag Forward USB Driver + +Required properties: +-compatible : should be "qcom,diagfwd-usb". + +Example: + qcom,diag { + compatible = "qcom,diagfwd-usb"; + }; diff --git a/drivers/char/diag/diagchar_core.c b/drivers/char/diag/diagchar_core.c index 6df597dfa750..32f70fa2d37c 100644 --- a/drivers/char/diag/diagchar_core.c +++ b/drivers/char/diag/diagchar_core.c @@ -1160,7 +1160,7 @@ static void diag_remote_exit(void) return; } -int diagfwd_bridge_init(void) +int diagfwd_bridge_init(bool use_mhi) { return 0; } @@ -3743,7 +3743,7 @@ static int diag_mhi_probe(struct platform_device *pdev) diag_remote_exit(); return ret; } - ret = diagfwd_bridge_init(); + ret = diagfwd_bridge_init(true); if (ret) { diagfwd_bridge_exit(); return ret; @@ -3766,6 +3766,39 @@ static struct platform_driver diag_mhi_driver = { }, }; +static int diagfwd_usb_probe(struct platform_device *pdev) +{ + int ret; + + driver->pdev = pdev; + ret = diag_remote_init(); + if (ret) { + diag_remote_exit(); + return ret; + } + ret = diagfwd_bridge_init(false); + if (ret) { + diagfwd_bridge_exit(); + return ret; + } + pr_debug("diag: usb device is ready\n"); + return 0; +} + +static const struct of_device_id diagfwd_usb_table[] = { + {.compatible = "qcom,diagfwd-usb"}, + {}, +}; + +static struct platform_driver diagfwd_usb_driver = { + .probe = diagfwd_usb_probe, + .driver = { + .name = "DIAGFWD USB Platform", + .owner = THIS_MODULE, + .of_match_table = diagfwd_usb_table, + }, +}; + static int __init diagchar_init(void) { dev_t dev; @@ -3892,6 +3925,7 @@ static int __init diagchar_init(void) pr_debug("diagchar initialized now"); platform_driver_register(&diag_mhi_driver); + platform_driver_register(&diagfwd_usb_driver); return 0; fail: diff --git a/drivers/char/diag/diagfwd_bridge.c b/drivers/char/diag/diagfwd_bridge.c index d8e7b39eae8b..ad6203fe5684 100644 --- a/drivers/char/diag/diagfwd_bridge.c +++ b/drivers/char/diag/diagfwd_bridge.c @@ -20,16 +20,24 @@ #include #include "diag_mux.h" #include "diagfwd_bridge.h" -#ifdef USB_QCOM_DIAG_BRIDGE +#ifdef CONFIG_USB_QCOM_DIAG_BRIDGE #include "diagfwd_hsic.h" #endif #include "diagfwd_mhi.h" #include "diag_dci.h" -#ifdef CONFIG_MSM_MHI -#define diag_mdm_init diag_mhi_init -#else -#define diag_mdm_init diag_hsic_init +#ifndef CONFIG_USB_QCOM_DIAG_BRIDGE +static int diag_hsic_init(void) +{ + return -EINVAL; +} +#endif + +#ifndef CONFIG_MSM_MHI +static int diag_mhi_init(void) +{ + return -EINVAL; +} #endif #define BRIDGE_TO_MUX(x) (x + DIAG_MUX_BRIDGE_BASE) @@ -261,11 +269,14 @@ int diag_remote_dev_write_done(int id, unsigned char *buf, int len, int ctxt) return err; } -int diagfwd_bridge_init() +int diagfwd_bridge_init(bool use_mhi) { int err = 0; - err = diag_mdm_init(); + if (use_mhi) + err = diag_mhi_init(); + else + err = diag_hsic_init(); if (err) goto fail; return 0; diff --git a/drivers/char/diag/diagfwd_bridge.h b/drivers/char/diag/diagfwd_bridge.h index 62d6b08b5b89..250ef07b0b04 100644 --- a/drivers/char/diag/diagfwd_bridge.h +++ b/drivers/char/diag/diagfwd_bridge.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2012-2014, The Linux Foundation. All rights reserved. +/* Copyright (c) 2012-2014, 2018, The Linux Foundation. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 and @@ -51,7 +51,7 @@ struct diagfwd_bridge_info { }; extern struct diagfwd_bridge_info bridge_info[NUM_REMOTE_DEV]; -int diagfwd_bridge_init(void); +int diagfwd_bridge_init(bool use_mhi); void diagfwd_bridge_exit(void); int diagfwd_bridge_close(int id); int diagfwd_bridge_write(int id, unsigned char *buf, int len);