From patchwork Wed Mar 5 08:20:37 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jjian Zhou X-Patchwork-Id: 14002178 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 2FBCFC19F32 for ; Wed, 5 Mar 2025 09:29:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type: Content-Transfer-Encoding:MIME-Version:Message-ID:Date:Subject:CC:To:From: Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender :Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=GFxWueo3Q7D0lqnHm7zaaDzy31RkGxj9+qLmZ+0IIcM=; b=2wJJGLR6rK5wYic107t7TTXRUF yvSSfG8gEY/Q9IsyIfD0piqm1b1touCQGEIbvubjaNCHRYQCjIwwllyyNmVAeFMhG9K8VDnwfUyex DAT/GDDjVLAWlhAXly1BkgEXrrDPN0qFeP4J8VOyQF9Q2hj1oG2fSYfRboRosWO8m9Vprb6178vhK 6+SRpvV3v2b+GJb07mYGuddAomytfWhyWsF7aUM1cFXxbWcQnq/21BGSbBhUIRMLK1Oo+P4wlGkg7 q5EOsCGbxGnIXkHbZL+E+/SDYv5s41KwfYqvcptqcQ20x/b5dJ86fSu/GzCtPkIftRAoK44nz5Fe8 GQQ88hsg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tpl4e-00000007Vo9-2n5c; Wed, 05 Mar 2025 09:29:56 +0000 Received: from mailgw02.mediatek.com ([216.200.240.185]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tpjzu-00000007Lwo-0PDg; Wed, 05 Mar 2025 08:20:59 +0000 X-UUID: c0e18426f99a11efa1e849db4cc18d44-20250305 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Type:Content-Transfer-Encoding:MIME-Version:Message-ID:Date:Subject:CC:To:From; bh=GFxWueo3Q7D0lqnHm7zaaDzy31RkGxj9+qLmZ+0IIcM=; b=kVU0y0iJ1+0wStsj/S44pJwmWI3j954AP+9dA5t7YJ3MuOraAF4DCjIHdw7TpE5cljyMlOdhaDJczDbN6tuM6Zqp5274MOyw5genNDNVmfAPPQmDirTiVnV6PI4E4WjpEUN69OskZaksE/Ci79frisJ68wxa2tmnA6d1wC0aUjg=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.2.1,REQID:37e59852-d241-4208-a67d-56c312e568b6,IP:0,UR L:0,TC:0,Content:0,EDM:0,RT:0,SF:0,FILE:0,BULK:0,RULE:Release_Ham,ACTION:r elease,TS:0 X-CID-META: VersionHash:0ef645f,CLOUDID:29caf1c5-16da-468a-87f7-8ca8d6b3b9f7,B ulkID:nil,BulkQuantity:0,Recheck:0,SF:102,TC:nil,Content:0|50,EDM:-3,IP:ni l,URL:0,File:nil,RT:nil,Bulk:nil,QS:nil,BEC:nil,COL:0,OSI:0,OSA:0,AV:0,LES :1,SPR:NO,DKR:0,DKP:0,BRR:0,BRE:0,ARC:0 X-CID-BVR: 0,NGT X-CID-BAS: 0,NGT,0,_ X-CID-FACTOR: TF_CID_SPAM_SNR X-UUID: c0e18426f99a11efa1e849db4cc18d44-20250305 Received: from mtkmbs09n2.mediatek.inc [(172.21.101.94)] by mailgw02.mediatek.com (envelope-from ) (musrelay.mediatek.com ESMTP with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 600151970; Wed, 05 Mar 2025 01:20:52 -0700 Received: from mtkmbs13n1.mediatek.inc (172.21.101.193) by mtkmbs13n1.mediatek.inc (172.21.101.193) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1258.28; Wed, 5 Mar 2025 16:20:49 +0800 Received: from mhfsdcap04.gcn.mediatek.inc (10.17.3.154) by mtkmbs13n1.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.2.1258.28 via Frontend Transport; Wed, 5 Mar 2025 16:20:49 +0800 From: Jjian Zhou To: Jassi Brar , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Matthias Brugger , AngeloGioacchino Del Regno CC: , , , , , Jason-ch Chen , Jjian Zhou Subject: [PATCH RFC 0/3] add VCP mailbox and IPC driver Date: Wed, 5 Mar 2025 16:20:37 +0800 Message-ID: <20250305082047.15746-1-jjian.zhou@mediatek.com> X-Mailer: git-send-email 2.46.0 MIME-Version: 1.0 X-MTK: N X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250305_002058_146411_52BDC1BB X-CRM114-Status: GOOD ( 13.03 ) X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org The VCP mailbox has 5 groups. Each group has corresponding interrupts, registers, and 64 slots (each slot is 4 bytes). Since different features share one of the mailbox groups, the VCP mailbox needs to establish a send table and a receive table. The send table is used to record the feature ID, mailbox ID, and the number of slots occupied. The receive table is used to record the feature ID, mailbox ID, the number of slots occupied, and the receive options. The API setup_mbox_table in mtk-vcp-ipc.c calculates the slot offset and pin index for each feature ID based on the mailbox ID and slot number in the send and receive tables (several slots form a pin, and each pin can trigger an interrupt). These descriptions are written in the mtk-vcp-ipc.c file -- we call it the IPC layer. We have two questions: How should we describe the mailbox and IPI? Can the intermediate IPC layer be rewritten as a virtual mailbox layer? Example of send and recve table: Operation | mbox_id | ipi_id | msg_size | align_size | slot_ofs | pin_index | notes send 0 0 18 18 0 0 recv 0 1 18 18 18 9 send 1 15 8 8 0 0 send 1 16 18 18 8 4 send 1 9 2 2 26 13 recv 1 15 8 8 28 14 ack of send ipi_id=15 recv 1 17 18 18 36 18 recv 1 10 2 2 54 27 ack of send ipi_id=2 send 2 11 18 18 0 0 send 2 2 2 2 18 9 send 2 3 3 4 20 10 send 2 32 2 2 24 12 recv 2 12 18 18 26 13 recv 2 5 1 2 44 22 recv 2 2 1 2 46 23 Recv ipi_id=2 is the ack of send ipi_id=2(The ipi_id=15 is the same.) Jjian Zhou (3): mailbox: mediatek: Add mtk-vcp-mailbox driver firmware: mediatek: Add vcp ipc protocol interface dt-bindings: mailbox: mtk,vcp-mbox: add mtk vcp-mbox document .../bindings/mailbox/mtk,vcp-mbox.yaml | 49 ++ drivers/firmware/Kconfig | 9 + drivers/firmware/Makefile | 1 + drivers/firmware/mtk-vcp-ipc.c | 481 ++++++++++++++++++ drivers/mailbox/Kconfig | 9 + drivers/mailbox/Makefile | 2 + drivers/mailbox/mtk-vcp-mailbox.c | 179 +++++++ include/linux/firmware/mediatek/mtk-vcp-ipc.h | 151 ++++++ include/linux/mailbox/mtk-vcp-mailbox.h | 34 ++ 9 files changed, 915 insertions(+) create mode 100644 Documentation/devicetree/bindings/mailbox/mtk,vcp-mbox.yaml create mode 100644 drivers/firmware/mtk-vcp-ipc.c create mode 100644 drivers/mailbox/mtk-vcp-mailbox.c create mode 100644 include/linux/firmware/mediatek/mtk-vcp-ipc.h create mode 100644 include/linux/mailbox/mtk-vcp-mailbox.h --- 2.45.2