From patchwork Sat Feb 11 08:37:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?WWFuY2hhbyBZYW5nICjmnajlvabotoUp?= X-Patchwork-Id: 5275 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp1398779wrn; Sat, 11 Feb 2023 00:41:01 -0800 (PST) X-Google-Smtp-Source: AK7set9TxS+GU0diSEVqAsDMOp3qMvdoMoFaKFYZG8Aytkd9R5j5999xOGbOTVzHJvduHyph6fbY X-Received: by 2002:a17:906:2b0e:b0:7d3:c516:6ef4 with SMTP id a14-20020a1709062b0e00b007d3c5166ef4mr18233846ejg.20.1676104860889; Sat, 11 Feb 2023 00:41:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676104860; cv=none; d=google.com; s=arc-20160816; b=bIqHisOKvjwvtqNyWQnBrfU0uHsUs6VGqk8prUTO9zNDTRvxwnogGyqFHomqOQeyr5 Pk/hqWXkfotCZvL6bFpkaBra9CxXAiLCPtd0o2WluWahsZGd6Et0Trq2R1yn8XDHvzok KzvFK9AC6+rsoaLQ2wdrg6gxkCfxRs7AvXjRxIuAOCjbkV0nT0u/d8tjA33pjyzxvg5+ yQssDrtdBxXLZObJ7mb2QGPMsFc+Ku+EeI0tDnnjSyqQEJhKR6wMSGKnEenBZ6wZMGQX dXDMHVeMYOAXZsvMJu8BF2biAgaUYsFVleIE9r/6DY59pI4YMnRUQhRmUDP8biOqaS8D NlBA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:subject:cc:to:from :dkim-signature; bh=is5HxIGHiSBZmzvYR12/E0E9eNG1192q4XorVD2IRPE=; b=lgfVJtCwe5pVZR+gFFbqOWPnSziT+I9PGwfPqOStXiyMpTkQG7m1IPsGOVk1cCcxPQ O4hDzyqIUe197m+rooJqYVpU6WDqxpzIEbvorFozE0VL/2Xt66KRxOZ0iAnuN/J6auOT nZnSoxv/Qywkb6nbKP0XKSRDSX38V4N2kyizuiN4D3X7qIBmMbYpyaUfVitIXIfboitB k8e5NDSn9/dULyAC0SLqxYbGHjkWa5Ja9NBSQdmyn9vlHWDbZ9evTE8uOrD25S+etE9S s16KwHdweBpjHxfMFqqVnrvY/pL+WB0fQVzcQZZcK5PmxJSn16+C/zIfnhorGM3wxp1j 0siw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b=g2itCT+s; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=mediatek.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id bf19-20020a170906c51300b007a087ccd275si7982548ejb.384.2023.02.11.00.40.38; Sat, 11 Feb 2023 00:41:00 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b=g2itCT+s; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=mediatek.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229571AbjBKIiB (ORCPT + 99 others); Sat, 11 Feb 2023 03:38:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34698 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229447AbjBKIh7 (ORCPT ); Sat, 11 Feb 2023 03:37:59 -0500 Received: from mailgw01.mediatek.com (unknown [60.244.123.138]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E57015BA65; Sat, 11 Feb 2023 00:37:52 -0800 (PST) X-UUID: 5cf995aca9e711eda06fc9ecc4dadd91-20230211 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Type:MIME-Version:Message-ID:Date:Subject:CC:To:From; bh=is5HxIGHiSBZmzvYR12/E0E9eNG1192q4XorVD2IRPE=; b=g2itCT+skil6ixswmiR/Nm9N+tRwGuDeH2dMS4lMnctdhjcJsIC4/pN9NPr9s8T3wJ1Rz6oeuL+uguJePzro8zVk0x2dI4vnbZ7Eo6mXabPFurud5eyQ47Nb9nSlGxqfrUPXQ5PgLEjPjZM2q9/v/dC7dMi3Q/zzranult4oF1Y=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.19,REQID:6a9156bd-618e-4380-b0e7-03401525ff51,IP:0,U RL:0,TC:0,Content:-25,EDM:0,RT:0,SF:95,FILE:0,BULK:0,RULE:Release_Ham,ACTI ON:release,TS:70 X-CID-INFO: VERSION:1.1.19,REQID:6a9156bd-618e-4380-b0e7-03401525ff51,IP:0,URL :0,TC:0,Content:-25,EDM:0,RT:0,SF:95,FILE:0,BULK:0,RULE:Spam_GS981B3D,ACTI ON:quarantine,TS:70 X-CID-META: VersionHash:885ddb2,CLOUDID:3482f756-dd49-462e-a4be-2143a3ddc739,B ulkID:230211163750VFBXGMRY,BulkQuantity:0,Recheck:0,SF:38|29|28|17|19|48,T C:nil,Content:0,EDM:-3,IP:nil,URL:11|1,File:nil,Bulk:nil,QS:nil,BEC:nil,CO L:0,OSI:0,OSA:0,AV:0 X-CID-BVR: 0,NGT X-UUID: 5cf995aca9e711eda06fc9ecc4dadd91-20230211 Received: from mtkmbs13n1.mediatek.inc [(172.21.101.193)] by mailgw01.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 343936643; Sat, 11 Feb 2023 16:37:48 +0800 Received: from mtkmbs13n1.mediatek.inc (172.21.101.193) by mtkmbs11n2.mediatek.inc (172.21.101.187) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.792.15; Sat, 11 Feb 2023 16:37:46 +0800 Received: from mcddlt001.gcn.mediatek.inc (10.19.240.15) by mtkmbs13n1.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.2.792.15 via Frontend Transport; Sat, 11 Feb 2023 16:37:44 +0800 From: Yanchao Yang To: Loic Poulain , Sergey Ryazanov , Johannes Berg , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , netdev ML , kernel ML CC: Intel experts , Chetan , MTK ML , Liang Lu , Haijun Liu , Hua Yang , Ting Wang , Felix Chen , Mingliang Xu , Min Dong , Aiden Wang , Guohao Zhang , Chris Feng , Yanchao Yang , Lambert Wang , Mingchuang Qiao , Xiayu Zhang , Haozhe Chang Subject: [PATCH net-next v3 00/10] net: wwan: tmi: PCIe driver for MediaTek M.2 modem Date: Sat, 11 Feb 2023 16:37:22 +0800 Message-ID: <20230211083732.193650-1-yanchao.yang@mediatek.com> X-Mailer: git-send-email 2.18.0 MIME-Version: 1.0 X-MTK: N X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS, T_SPF_TEMPERROR,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1757523330513758231?= X-GMAIL-MSGID: =?utf-8?q?1757523330513758231?= TMI(T-series Modem Interface) is the PCIe host device driver for MediaTek's modem. The driver uses the WWAN framework infrastructure to create the following control ports and network interfaces for data transactions. * /dev/wwan0at0 - Interface that supports AT commands. * /dev/wwan0mbim0 - Interface conforming to the MBIM protocol. * wwan0-X - Primary network interface for IP traffic. The main blocks in the TMI driver are: * HW layer - Abstracts the hardware bus operations for the device, and provides generic interfaces for the transaction layer to get the device's information and control the device's behavior. It includes: * PCIe - Implements probe, removal and interrupt handling. * MHCCIF (Modem Host Cross-Core Interface) - Provides interrupt channels for bidirectional event notification such as handshake and port enumeration. * Transaction layer - Implements data transactions for the control plane and the data plane. It includes: * DPMAIF (Data Plane Modem AP Interface) - Controls the hardware that provides uplink and downlink queues for the data path. The data exchange takes place using circular buffers to share data buffer addresses and metadata to describe the packets. * CLDMA (Cross Layer DMA) - Manages the hardware used by the port layer to send control messages to the device using MediaTek's CCCI (Cross-Core Communication Interface) protocol. * TX Services - Dispatch packets from the port layer to the device. * RX Services - Dispatch packets to the port layer when receiving packets from the device. * Port layer - Provides control plane and data plane interfaces to userspace. It includes: * Control Plane - Provides device node interfaces for controlling data transactions. * Data Plane - Provides network link interfaces wwanX (0, 1, 2...) for IP data transactions. * Core logic - Contains the core logic to keep the device working. It includes: * FSM (Finite State Machine) - Monitors the state of the device, and notifies each module when the state changes. The compilation of the TMI driver is enabled by the CONFIG_MTK_TMI config option which depends on CONFIG_WWAN. List of contributors: Min Dong Ting Wang Hua Yang Mingliang Xu Felix Chen Aiden Wang Guohao Zhang Chris Feng Yanchao Yang Michael Cai Lambert Wang Mingchuang Qiao Xiayu Zhang Haozhe Chang V3: - Remove exception handling and power management modules, and reduce data plane's features, etc. V2: - Remove wrapper function, use kernel interfaces instead, ex, dma_map_single, dma_pool_zalloc, ... - Refine comments to meet kerneldoc format specification. - Use interfaces in bitfield.h to perform bitmask related operations. - Remove unused functions from patch-1. - Remove patch2 (net: wwan: tmi: Add buffer management). Yanchao Yang (10): net: wwan: tmi: Add PCIe core net: wwan: tmi: Add control plane transaction layer net: wwan: tmi: Add control DMA interface net: wwan: tmi: Add control port net: wwan: tmi: Add FSM thread net: wwan: tmi: Add AT & MBIM WWAN ports net: wwan: tmi: Introduce data plane hardware interface net: wwan: tmi: Add data plane transaction layer net: wwan: tmi: Introduce WWAN interface net: wwan: tmi: Add maintainers and documentation .../networking/device_drivers/wwan/index.rst | 1 + .../networking/device_drivers/wwan/tmi.rst | 48 + MAINTAINERS | 11 + drivers/net/wwan/Kconfig | 14 + drivers/net/wwan/Makefile | 1 + drivers/net/wwan/mediatek/Makefile | 21 + drivers/net/wwan/mediatek/mtk_cldma.c | 280 ++ drivers/net/wwan/mediatek/mtk_cldma.h | 160 + drivers/net/wwan/mediatek/mtk_common.h | 30 + drivers/net/wwan/mediatek/mtk_ctrl_plane.c | 441 +++ drivers/net/wwan/mediatek/mtk_ctrl_plane.h | 111 + drivers/net/wwan/mediatek/mtk_data_plane.h | 103 + drivers/net/wwan/mediatek/mtk_dev.c | 50 + drivers/net/wwan/mediatek/mtk_dev.h | 382 ++ drivers/net/wwan/mediatek/mtk_dpmaif.c | 3093 +++++++++++++++++ drivers/net/wwan/mediatek/mtk_dpmaif_drv.h | 201 ++ drivers/net/wwan/mediatek/mtk_fsm.c | 998 ++++++ drivers/net/wwan/mediatek/mtk_fsm.h | 153 + drivers/net/wwan/mediatek/mtk_port.c | 1256 +++++++ drivers/net/wwan/mediatek/mtk_port.h | 299 ++ drivers/net/wwan/mediatek/mtk_port_io.c | 625 ++++ drivers/net/wwan/mediatek/mtk_port_io.h | 45 + drivers/net/wwan/mediatek/mtk_wwan.c | 589 ++++ .../wwan/mediatek/pcie/mtk_cldma_drv_t800.c | 939 +++++ .../wwan/mediatek/pcie/mtk_cldma_drv_t800.h | 22 + .../wwan/mediatek/pcie/mtk_dpmaif_drv_t800.c | 1622 +++++++++ .../wwan/mediatek/pcie/mtk_dpmaif_reg_t800.h | 357 ++ drivers/net/wwan/mediatek/pcie/mtk_pci.c | 1020 ++++++ drivers/net/wwan/mediatek/pcie/mtk_pci.h | 148 + drivers/net/wwan/mediatek/pcie/mtk_reg.h | 80 + 30 files changed, 13100 insertions(+) create mode 100644 Documentation/networking/device_drivers/wwan/tmi.rst create mode 100644 drivers/net/wwan/mediatek/Makefile create mode 100644 drivers/net/wwan/mediatek/mtk_cldma.c create mode 100644 drivers/net/wwan/mediatek/mtk_cldma.h create mode 100644 drivers/net/wwan/mediatek/mtk_common.h create mode 100644 drivers/net/wwan/mediatek/mtk_ctrl_plane.c create mode 100644 drivers/net/wwan/mediatek/mtk_ctrl_plane.h create mode 100644 drivers/net/wwan/mediatek/mtk_data_plane.h create mode 100644 drivers/net/wwan/mediatek/mtk_dev.c create mode 100644 drivers/net/wwan/mediatek/mtk_dev.h create mode 100644 drivers/net/wwan/mediatek/mtk_dpmaif.c create mode 100644 drivers/net/wwan/mediatek/mtk_dpmaif_drv.h create mode 100644 drivers/net/wwan/mediatek/mtk_fsm.c create mode 100644 drivers/net/wwan/mediatek/mtk_fsm.h create mode 100644 drivers/net/wwan/mediatek/mtk_port.c create mode 100644 drivers/net/wwan/mediatek/mtk_port.h create mode 100644 drivers/net/wwan/mediatek/mtk_port_io.c create mode 100644 drivers/net/wwan/mediatek/mtk_port_io.h create mode 100644 drivers/net/wwan/mediatek/mtk_wwan.c create mode 100644 drivers/net/wwan/mediatek/pcie/mtk_cldma_drv_t800.c create mode 100644 drivers/net/wwan/mediatek/pcie/mtk_cldma_drv_t800.h create mode 100644 drivers/net/wwan/mediatek/pcie/mtk_dpmaif_drv_t800.c create mode 100644 drivers/net/wwan/mediatek/pcie/mtk_dpmaif_reg_t800.h create mode 100644 drivers/net/wwan/mediatek/pcie/mtk_pci.c create mode 100644 drivers/net/wwan/mediatek/pcie/mtk_pci.h create mode 100644 drivers/net/wwan/mediatek/pcie/mtk_reg.h