From nobody Tue Nov 26 06:48:50 2024 Received: from SEYPR02CU001.outbound.protection.outlook.com (mail-koreacentralazon11023138.outbound.protection.outlook.com [40.107.44.138]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B0D6A1F8EE6; Mon, 21 Oct 2024 12:20:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.44.138 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729513212; cv=fail; b=dyXZnR0L5m0o7Y2ESzXalJDOqLcDUseMXi1ChVD/QpIQAOkvuKWHLCaj3pMr5AXms4sR9ne2v+16h1cxIWUYH0ELliLF1Nlo1YaojwCDtoXUtBQkC/LYv+hPyyCinxA2VG2Po1jZCr3OZjFVfAJXNhIc4QsdU5JVgJ0ciNBV0yM= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729513212; c=relaxed/simple; bh=4iGeHZ4xFAEd+YPtvQeJvJgE4PUldCHgeBr2PduMYLE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=r+9hDOSQUlktpfbh/JjuzoTpF63z/oQFhINUpmXdHzX2j7RWkpcnbDGeLGYG7S+FUtK0PppbMJXKvm4CYH8QMfUZl9HIwXYdbp0NK/490jsMlF1iX33vyMONbrsMfGx+SYodmyP/vWLj1SbZTwb5flUus3PlUJWRtTmorcSde1Y= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=fibocom.com; spf=pass smtp.mailfrom=fibocom.com; dkim=pass (1024-bit key) header.d=fibocomcorp.onmicrosoft.com header.i=@fibocomcorp.onmicrosoft.com header.b=XK3f9ePh; arc=fail smtp.client-ip=40.107.44.138 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=fibocom.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=fibocom.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=fibocomcorp.onmicrosoft.com header.i=@fibocomcorp.onmicrosoft.com header.b="XK3f9ePh" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=ahDP7u568XmfkhR98Br7CDnsk7M9JRbhwQ+jTdmtDg10W2fIldmj4rlVJgYTQakdTQE4NARCPigHQ1QxuJ7pf9xgTLBrqBwyNzoP3wXzJlmxlZa7pZT4Q/kN2LSsKPn1rEoH9wOZbleoenEJbUKYjj/6isNP4+P9eDhPDHVw/6bIhJfzdUd07ruAP24YvJpnkaaF18AgJsa0a7x7LsZbAAmeK3rC6ZbX/L+lGlPEdpAz/WZMK2Pl+eVL4JK16v2t8JleJVudHFS8C7/Z7vi7OcPw2KPOn3wLdgPm7NEh6fx9MZRlb/HU+1dxEGDE3ZsK7xe8BvmWmpWNB86HF0934Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=gGXffHZ85k+1NwpCqPZHM4x00JUjsTeCP7wMz64KX9E=; b=ajge8TlZ/XhV9iCqxxGi4zEXicp7x0Juzm9U0F/Fk3uFcmUS5AI7lV7HlEBFNv4U+Lcec70eRgbzKSLOfVDyCSRqauf6vVMUv9Tu9o38+ILyZVu1+2BW/iBo/Y7M1ZdqGdPmgxSKmiWVM+1F41JrYHfBaEIZNVoXsaA4majYjHYx84UnfV5d0A0VAAq9cpfyTau52yDn9ZISd2WsvtaI3WyGD3Uvst2V/FRFWpl641CIzKmr85SlWlifDOa/6sUBhEJeZF0ryBRVwURk6Keaithoc5XKgZ/b4HgULVHE4l/RLK6tnJql/etrbjOM5ldjZaMUZ7uU92gaKmwbQ3KDMg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=fibocom.com; dmarc=pass action=none header.from=fibocom.com; dkim=pass header.d=fibocom.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fibocomcorp.onmicrosoft.com; s=selector1-fibocomcorp-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=gGXffHZ85k+1NwpCqPZHM4x00JUjsTeCP7wMz64KX9E=; b=XK3f9ePhnk1oNHvSEhpjXfsYQQUs/kj+ZoMeRoJpfhX1JM8EsThuCbU7VvyBVBhzRUca0CLcE97pV0lgMAs6zWnoCyRAM1KKff+BM58BHjNzY/ojJqTEcZeamSP+SVKs4gm9GkBrHYpHcsKTs+lI3H/8s7D0YKoSkf6y1PxW+ps= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=fibocom.com; Received: from TY0PR02MB5766.apcprd02.prod.outlook.com (2603:1096:400:1b5::6) by SEYPR02MB6268.apcprd02.prod.outlook.com (2603:1096:101:d1::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.28; Mon, 21 Oct 2024 12:20:06 +0000 Received: from TY0PR02MB5766.apcprd02.prod.outlook.com ([fe80::f53d:47b:3b04:9a8b]) by TY0PR02MB5766.apcprd02.prod.outlook.com ([fe80::f53d:47b:3b04:9a8b%4]) with mapi id 15.20.8069.027; Mon, 21 Oct 2024 12:20:06 +0000 From: Jinjian Song To: chandrashekar.devegowda@intel.com, chiranjeevi.rapolu@linux.intel.com, haijun.liu@mediatek.com, m.chetan.kumar@linux.intel.com, ricardo.martinez@linux.intel.com, loic.poulain@linaro.org, ryazanov.s.a@gmail.com, johannes@sipsolutions.net, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com Cc: linux-kernel@vger.kernel.org, netdev@vger.kernel.org, linux-doc@vger.kernel.org, angelogioacchino.delregno@collabora.com, linux-arm-kernel@lists.infradead.org, matthias.bgg@gmail.com, corbet@lwn.net, linux-mediatek@lists.infradead.org, helgaas@kernel.org, danielwinkler@google.com, korneld@google.com, Jinjian Song , Jinjian Song Subject: [net-next,RESEND v6 2/2] net: wwan: t7xx: Add debug port Date: Mon, 21 Oct 2024 20:19:34 +0800 Message-Id: <20241021121934.16317-3-jinjian.song@fibocom.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241021121934.16317-1-jinjian.song@fibocom.com> References: <20241021121934.16317-1-jinjian.song@fibocom.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: TYCP286CA0139.JPNP286.PROD.OUTLOOK.COM (2603:1096:400:31b::7) To TY0PR02MB5766.apcprd02.prod.outlook.com (2603:1096:400:1b5::6) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: TY0PR02MB5766:EE_|SEYPR02MB6268:EE_ X-MS-Office365-Filtering-Correlation-Id: b173c1dd-1eb7-4c42-ce23-08dcf1cab277 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|366016|376014|7416014|52116014|921020|38350700014; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?zLnCYAnxxmk72i4z+kth1EZUQNGykOSD5D2bm8RBXLa4vlo0UXPcWBZ5g8D8?= =?us-ascii?Q?iSdCKhtfSi3ogrsNfxdv+pWKTYvQNw11SLfdV32GEDS7tVp7anWPlDfPNrek?= =?us-ascii?Q?T97yGS/+UBGL0HpY6G2qMNCnkrx9gIdZweshICg2OBta/xx7fX0vWY1KBdj1?= =?us-ascii?Q?ZwnWytecaRl+CZF6xOXguD894wlcKfyHdEqWbziOHLj5LcaGcSqzlMzObg7M?= =?us-ascii?Q?V2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AVOOwMiijqAFXz9K7c0IMM?= =?us-ascii?Q?pIlnubB/Rs3X/IFRSh7OMXkzzsBe+hhyWc31IVys3q9zMDDwuBo8QYgkFXY5?= =?us-ascii?Q?Gn/0LsEU6e4sc8++c1q/ukSu42acGPUcc08JAweY3rAUAzc7aP0Xxqb8cMTz?= =?us-ascii?Q?8nw4W5sZTZLQZ+jIzMV6rDgbIEIbZa7C/KRRbcu67KZJuxfncV0f+AQzPYFB?= =?us-ascii?Q?17ox5g0QdAoa/dgSdvPRIon/5IajWvqP6k1elo616fCogg=3D=3D?= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:TY0PR02MB5766.apcprd02.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(1800799024)(366016)(376014)(7416014)(52116014)(921020)(38350700014);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?eReUs5RKpDOGfKh5M29NllIMq+O8mMzPLnN0SHkbH+v00y2YMcKqrsWUIm0L?= =?us-ascii?Q?UgLfiXoYKjZN/C/d03T7xuMlyVZq++h+UyxfMCQyf7H+F2iLb40Itlj/e2Dl?= =?us-ascii?Q?ORFjnHCXyrYrHaXGr5x8GyRulLLo/gUQ4tXuM+u3yCOIJ6KOrmOOfEbmrcZT?= =?us-ascii?Q?GRjsnY5bHG2gOVmtxZdDB5PDh2WH5FaekAOoJJWSFUE+1FNQA6mar4HgEQs1?= =?us-ascii?Q?otK4tHuDDbwAJ5aP758a3Ao7nimv2l2TTz8VyhP+deR0CYmop5/SCsHLB0Gp?= =?us-ascii?Q?/Ly8bldfqzWvY95QlJ5a6NuibNi29wWkrpcaEFnkIX7CwFxLwjhFNbDqYMb/?= =?us-ascii?Q?Z0xvbr8SRMxAupV9FM2krQfnSf26rKfRdEorGGBYQ6Vsx7+vCyRse15eLirm?= =?us-ascii?Q?dv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F6S+oVMBaghmPG2?= =?us-ascii?Q?zZeclm+m6ZLaQlnp4ZDLZNhUTVd+eXFrw6pqm3v3y0+Uxl8yr35WE2f52BFh?= =?us-ascii?Q?f/bZvVa9dpLiwYZ4JfzVQDqo3/8H5rGUT2wcKnyMJEZ/ttqUVLxsQJDQF/Jc?= =?us-ascii?Q?qke15yfuuFrILfQ3c7ubRscJeCWI6KEWnyLqvjW/Ey3I43EJdU2BXfFIFeCE?= =?us-ascii?Q?TC0PoT7L917a4CL31moExVl0lcw+4a1YV6YxO207xq/+i0Ot289wJiMBoBvM?= =?us-ascii?Q?Nh79cADex30uhdq/jonLpZs7KWo/ygBJdyy+RpIXqNsqeJzw/hNFSGPggQOe?= =?us-ascii?Q?sQ=3D=3D?= X-OriginatorOrg: fibocom.com X-MS-Exchange-CrossTenant-Network-Message-Id: b173c1dd-1eb7-4c42-ce23-08dcf1cab277 X-MS-Exchange-CrossTenant-AuthSource: TY0PR02MB5766.apcprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Oct 2024 12:20:06.5128 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 889bfe61-8c21-436b-bc07-3908050c8236 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: Mwb/wFkMiQumiv4E6rtJWikvtIR68Y3QxOu6c7KIY112aY1BhF1c0bGJht82aV9eo/aNOgbQpRmaZVmcnFdlWhsJEa9vKd2t4J2z0KSqLqU= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SEYPR02MB6268 Content-Type: text/plain; charset="utf-8" From: Jinjian Song Add support for userspace to switch on the debug port(ADB,MIPC). - ADB port: /dev/wwan0adb0 - MIPC port: /dev/wwan0mipc0 Application can use ADB (Android Debg Bridge) port to implement functions (shell, pull, push ...) by ADB protocol commands. E.g., ADB commands: - A_OPEN: OPEN(local-id, 0, "destination") - A_WRTE: WRITE(local-id, remote-id, "data") - A_OKEY: READY(local-id, remote-id, "") - A_CLSE: CLOSE(local-id, remote-id, "") Link: https://android.googlesource.com/platform/packages/modules/adb/+/refs= /heads/main/README.md Application can use MIPC (Modem Information Process Center) port to debug antenna tunner or noise profiling through this MTK modem diagnostic interface. By default, debug ports are not exposed, so using the command to enable or disable debug ports. Switch on debug port: - debug: 'echo debug > /sys/bus/pci/devices/${bdf}/t7xx_mode Switch off debug port: - normal: 'echo normal > /sys/bus/pci/devices/${bdf}/t7xx_mode Signed-off-by: Jinjian Song --- v5: * modify line length warning in t7xx_proxy_port_debug() v4: * modify commit message t7xx_mode to t7xx_port_mode v3: * add sysfs interface t7xx_port_mode * delete spin_lock_init in t7xx_proxy_port_debug() * modify document t7xx.rst v2: * add WWAN ADB and MIPC port --- .../networking/device_drivers/wwan/t7xx.rst | 47 +++++++++++++ drivers/net/wwan/t7xx/t7xx_pci.c | 67 +++++++++++++++++-- drivers/net/wwan/t7xx/t7xx_pci.h | 7 ++ drivers/net/wwan/t7xx/t7xx_port.h | 3 + drivers/net/wwan/t7xx/t7xx_port_proxy.c | 44 +++++++++++- drivers/net/wwan/t7xx/t7xx_port_proxy.h | 1 + drivers/net/wwan/t7xx/t7xx_port_wwan.c | 8 ++- 7 files changed, 167 insertions(+), 10 deletions(-) diff --git a/Documentation/networking/device_drivers/wwan/t7xx.rst b/Docume= ntation/networking/device_drivers/wwan/t7xx.rst index f346f5f85f15..02c8a47c2328 100644 --- a/Documentation/networking/device_drivers/wwan/t7xx.rst +++ b/Documentation/networking/device_drivers/wwan/t7xx.rst @@ -67,6 +67,28 @@ Write from userspace to set the device mode. :: $ echo fastboot_switching > /sys/bus/pci/devices/${bdf}/t7xx_mode =20 +t7xx_port_mode +-------------- +The sysfs interface provides userspace with access to the port mode, this = interface +supports read and write operations. + +Port mode: + +- ``normal`` represents switching off debug ports +- ``debug`` represents switching on debug ports + +Currently supported debug ports (ADB/MIPC). + +Read from userspace to get the current port mode. + +:: + $ cat /sys/bus/pci/devices/${bdf}/t7xx_port_mode + +Write from userspace to set the port mode. + +:: + $ echo debug > /sys/bus/pci/devices/${bdf}/t7xx_port_mode + Management application development =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D The driver and userspace interfaces are described below. The MBIM protocol= is @@ -139,6 +161,25 @@ Please note that driver needs to be reloaded to export= /dev/wwan0fastboot0 port, because device needs a cold reset after enter ``fastboot_switching`` mode. =20 +ADB port userspace ABI +---------------------- + +/dev/wwan0adb0 character device +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +The driver exposes a ADB protocol interface by implementing ADB WWAN Port. +The userspace end of the ADB channel pipe is a /dev/wwan0adb0 character de= vice. +Application shall use this interface for ADB protocol communication. + +MIPC port userspace ABI +----------------------- + +/dev/wwan0mipc0 character device +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +The driver exposes a diagnostic interface by implementing MIPC (Modem +Information Process Center) WWAN Port. The userspace end of the MIPC chann= el +pipe is a /dev/wwan0mipc0 character device. +Application shall use this interface for MTK modem diagnostic communicatio= n. + The MediaTek's T700 modem supports the 3GPP TS 27.007 [4] specification. =20 References @@ -164,3 +205,9 @@ speak the Mobile Interface Broadband Model (MBIM) proto= col"* [5] *fastboot "a mechanism for communicating with bootloaders"* =20 - https://android.googlesource.com/platform/system/core/+/refs/heads/main/= fastboot/README.md + +[6] *ADB (Android Debug Bridge) "a mechanism to keep track of Android devi= ces and +emulators instances connected to or running on a given host developer mach= ine with +ADB protocol"* + +- https://android.googlesource.com/platform/packages/modules/adb/+/refs/he= ads/main/README.md diff --git a/drivers/net/wwan/t7xx/t7xx_pci.c b/drivers/net/wwan/t7xx/t7xx_= pci.c index 625f5679c3b0..f1abdfaa6418 100644 --- a/drivers/net/wwan/t7xx/t7xx_pci.c +++ b/drivers/net/wwan/t7xx/t7xx_pci.c @@ -41,6 +41,7 @@ #include "t7xx_pcie_mac.h" #include "t7xx_reg.h" #include "t7xx_state_monitor.h" +#include "t7xx_port_proxy.h" =20 #define T7XX_PCI_IREG_BASE 0 #define T7XX_PCI_EREG_BASE 2 @@ -61,7 +62,13 @@ static const char * const t7xx_mode_names[] =3D { [T7XX_FASTBOOT_DUMP] =3D "fastboot_dump", }; =20 +static const char * const t7xx_port_mode_names[] =3D { + [T7XX_DEBUG] =3D "debug", + [T7XX_NORMAL] =3D "normal", +}; + static_assert(ARRAY_SIZE(t7xx_mode_names) =3D=3D T7XX_MODE_LAST); +static_assert(ARRAY_SIZE(t7xx_port_mode_names) =3D=3D T7XX_PORT_MODE_LAST); =20 static ssize_t t7xx_mode_store(struct device *dev, struct device_attribute *attr, @@ -120,13 +127,61 @@ static ssize_t t7xx_mode_show(struct device *dev, =20 static DEVICE_ATTR_RW(t7xx_mode); =20 -static struct attribute *t7xx_mode_attr[] =3D { +static ssize_t t7xx_port_mode_store(struct device *dev, + struct device_attribute *attr, + const char *buf, size_t count) +{ + struct t7xx_pci_dev *t7xx_dev; + struct pci_dev *pdev; + int index =3D 0; + + pdev =3D to_pci_dev(dev); + t7xx_dev =3D pci_get_drvdata(pdev); + if (!t7xx_dev) + return -ENODEV; + + index =3D sysfs_match_string(t7xx_port_mode_names, buf); + if (index =3D=3D T7XX_DEBUG) { + t7xx_proxy_port_debug(t7xx_dev, true); + WRITE_ONCE(t7xx_dev->port_mode, T7XX_DEBUG); + } else if (index =3D=3D T7XX_NORMAL) { + t7xx_proxy_port_debug(t7xx_dev, false); + WRITE_ONCE(t7xx_dev->port_mode, T7XX_NORMAL); + } + + return count; +}; + +static ssize_t t7xx_port_mode_show(struct device *dev, + struct device_attribute *attr, + char *buf) +{ + enum t7xx_port_mode port_mode =3D T7XX_NORMAL; + struct t7xx_pci_dev *t7xx_dev; + struct pci_dev *pdev; + + pdev =3D to_pci_dev(dev); + t7xx_dev =3D pci_get_drvdata(pdev); + if (!t7xx_dev) + return -ENODEV; + + port_mode =3D READ_ONCE(t7xx_dev->port_mode); + if (port_mode < T7XX_PORT_MODE_LAST) + return sysfs_emit(buf, "%s\n", t7xx_port_mode_names[port_mode]); + + return sysfs_emit(buf, "%s\n", t7xx_port_mode_names[T7XX_NORMAL]); +} + +static DEVICE_ATTR_RW(t7xx_port_mode); + +static struct attribute *t7xx_attr[] =3D { &dev_attr_t7xx_mode.attr, + &dev_attr_t7xx_port_mode.attr, NULL }; =20 -static const struct attribute_group t7xx_mode_attribute_group =3D { - .attrs =3D t7xx_mode_attr, +static const struct attribute_group t7xx_attribute_group =3D { + .attrs =3D t7xx_attr, }; =20 void t7xx_mode_update(struct t7xx_pci_dev *t7xx_dev, enum t7xx_mode mode) @@ -840,7 +895,7 @@ static int t7xx_pci_probe(struct pci_dev *pdev, const s= truct pci_device_id *id) t7xx_pcie_mac_interrupts_dis(t7xx_dev); =20 ret =3D sysfs_create_group(&t7xx_dev->pdev->dev.kobj, - &t7xx_mode_attribute_group); + &t7xx_attribute_group); if (ret) goto err_md_exit; =20 @@ -856,7 +911,7 @@ static int t7xx_pci_probe(struct pci_dev *pdev, const s= truct pci_device_id *id) =20 err_remove_group: sysfs_remove_group(&t7xx_dev->pdev->dev.kobj, - &t7xx_mode_attribute_group); + &t7xx_attribute_group); =20 err_md_exit: t7xx_md_exit(t7xx_dev); @@ -871,7 +926,7 @@ static void t7xx_pci_remove(struct pci_dev *pdev) t7xx_dev =3D pci_get_drvdata(pdev); =20 sysfs_remove_group(&t7xx_dev->pdev->dev.kobj, - &t7xx_mode_attribute_group); + &t7xx_attribute_group); t7xx_md_exit(t7xx_dev); =20 for (i =3D 0; i < EXT_INT_NUM; i++) { diff --git a/drivers/net/wwan/t7xx/t7xx_pci.h b/drivers/net/wwan/t7xx/t7xx_= pci.h index cd8ea17c2644..1d632405c89b 100644 --- a/drivers/net/wwan/t7xx/t7xx_pci.h +++ b/drivers/net/wwan/t7xx/t7xx_pci.h @@ -53,6 +53,12 @@ enum t7xx_mode { T7XX_MODE_LAST, /* must always be last */ }; =20 +enum t7xx_port_mode { + T7XX_NORMAL, + T7XX_DEBUG, + T7XX_PORT_MODE_LAST, /* must always be last */ +}; + /* struct t7xx_pci_dev - MTK device context structure * @intr_handler: array of handler function for request_threaded_irq * @intr_thread: array of thread_fn for request_threaded_irq @@ -94,6 +100,7 @@ struct t7xx_pci_dev { struct dentry *debugfs_dir; #endif u32 mode; + u32 port_mode; }; =20 enum t7xx_pm_id { diff --git a/drivers/net/wwan/t7xx/t7xx_port.h b/drivers/net/wwan/t7xx/t7xx= _port.h index f74d3bab810d..9f5d6d288c97 100644 --- a/drivers/net/wwan/t7xx/t7xx_port.h +++ b/drivers/net/wwan/t7xx/t7xx_port.h @@ -42,6 +42,8 @@ enum port_ch { /* to AP */ PORT_CH_AP_CONTROL_RX =3D 0x1000, PORT_CH_AP_CONTROL_TX =3D 0x1001, + PORT_CH_AP_ADB_RX =3D 0x100a, + PORT_CH_AP_ADB_TX =3D 0x100b, =20 /* to MD */ PORT_CH_CONTROL_RX =3D 0x2000, @@ -100,6 +102,7 @@ struct t7xx_port_conf { struct port_ops *ops; char *name; enum wwan_port_type port_type; + bool debug; }; =20 struct t7xx_port { diff --git a/drivers/net/wwan/t7xx/t7xx_port_proxy.c b/drivers/net/wwan/t7x= x/t7xx_port_proxy.c index 35743e7de0c3..26d3f57732cc 100644 --- a/drivers/net/wwan/t7xx/t7xx_port_proxy.c +++ b/drivers/net/wwan/t7xx/t7xx_port_proxy.c @@ -39,6 +39,8 @@ =20 #define Q_IDX_CTRL 0 #define Q_IDX_MBIM 2 +#define Q_IDX_MIPC 2 +#define Q_IDX_ADB 3 #define Q_IDX_AT_CMD 5 =20 #define INVALID_SEQ_NUM GENMASK(15, 0) @@ -100,7 +102,27 @@ static const struct t7xx_port_conf t7xx_port_conf[] = =3D { .path_id =3D CLDMA_ID_AP, .ops =3D &ctl_port_ops, .name =3D "t7xx_ap_ctrl", - }, + }, { + .tx_ch =3D PORT_CH_AP_ADB_TX, + .rx_ch =3D PORT_CH_AP_ADB_RX, + .txq_index =3D Q_IDX_ADB, + .rxq_index =3D Q_IDX_ADB, + .path_id =3D CLDMA_ID_AP, + .ops =3D &wwan_sub_port_ops, + .name =3D "adb", + .port_type =3D WWAN_PORT_ADB, + .debug =3D true, + }, { + .tx_ch =3D PORT_CH_MIPC_TX, + .rx_ch =3D PORT_CH_MIPC_RX, + .txq_index =3D Q_IDX_MIPC, + .rxq_index =3D Q_IDX_MIPC, + .path_id =3D CLDMA_ID_MD, + .ops =3D &wwan_sub_port_ops, + .name =3D "mipc", + .port_type =3D WWAN_PORT_MIPC, + .debug =3D true, + } }; =20 static const struct t7xx_port_conf t7xx_early_port_conf[] =3D { @@ -505,13 +527,31 @@ static void t7xx_proxy_init_all_ports(struct t7xx_mod= em *md) spin_lock_init(&port->port_update_lock); port->chan_enable =3D false; =20 - if (port_conf->ops && port_conf->ops->init) + if (!port_conf->debug && port_conf->ops && port_conf->ops->init) port_conf->ops->init(port); } =20 t7xx_proxy_setup_ch_mapping(port_prox); } =20 +void t7xx_proxy_port_debug(struct t7xx_pci_dev *t7xx_dev, bool show) +{ + struct port_proxy *port_prox =3D t7xx_dev->md->port_prox; + struct t7xx_port *port; + int i; + + for_each_proxy_port(i, port, port_prox) { + const struct t7xx_port_conf *port_conf =3D port->port_conf; + + if (port_conf->debug && port_conf->ops && port_conf->ops->init) { + if (show) + port_conf->ops->init(port); + else + port_conf->ops->uninit(port); + } + } +} + void t7xx_port_proxy_set_cfg(struct t7xx_modem *md, enum port_cfg_id cfg_i= d) { struct port_proxy *port_prox =3D md->port_prox; diff --git a/drivers/net/wwan/t7xx/t7xx_port_proxy.h b/drivers/net/wwan/t7x= x/t7xx_port_proxy.h index 7f5706811445..a9c19c1253e6 100644 --- a/drivers/net/wwan/t7xx/t7xx_port_proxy.h +++ b/drivers/net/wwan/t7xx/t7xx_port_proxy.h @@ -98,6 +98,7 @@ extern struct port_ops ctl_port_ops; extern struct port_ops t7xx_trace_port_ops; #endif =20 +void t7xx_proxy_port_debug(struct t7xx_pci_dev *t7xx_dev, bool show); void t7xx_port_proxy_reset(struct port_proxy *port_prox); void t7xx_port_proxy_uninit(struct port_proxy *port_prox); int t7xx_port_proxy_init(struct t7xx_modem *md); diff --git a/drivers/net/wwan/t7xx/t7xx_port_wwan.c b/drivers/net/wwan/t7xx= /t7xx_port_wwan.c index 4b23ba693f3f..7fc569565ff9 100644 --- a/drivers/net/wwan/t7xx/t7xx_port_wwan.c +++ b/drivers/net/wwan/t7xx/t7xx_port_wwan.c @@ -169,7 +169,9 @@ static int t7xx_port_wwan_init(struct t7xx_port *port) { const struct t7xx_port_conf *port_conf =3D port->port_conf; =20 - if (port_conf->port_type =3D=3D WWAN_PORT_FASTBOOT) + if (port_conf->port_type =3D=3D WWAN_PORT_FASTBOOT || + port_conf->port_type =3D=3D WWAN_PORT_ADB || + port_conf->port_type =3D=3D WWAN_PORT_MIPC) t7xx_port_wwan_create(port); =20 port->rx_length_th =3D RX_QUEUE_MAXLEN; @@ -224,7 +226,9 @@ static void t7xx_port_wwan_md_state_notify(struct t7xx_= port *port, unsigned int { const struct t7xx_port_conf *port_conf =3D port->port_conf; =20 - if (port_conf->port_type =3D=3D WWAN_PORT_FASTBOOT) + if (port_conf->port_type =3D=3D WWAN_PORT_FASTBOOT || + port_conf->port_type =3D=3D WWAN_PORT_ADB || + port_conf->port_type =3D=3D WWAN_PORT_MIPC) return; =20 if (state !=3D MD_STATE_READY) --=20 2.34.1