Received: by 2002:ab2:1149:0:b0:1f3:1f8c:d0c6 with SMTP id z9csp2528343lqz; Tue, 2 Apr 2024 23:58:24 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVD/pqE2Z2ZtIDE5vFKGpiJiEvAy69xx499pXnY5/GvNPxloOv4hTPrb0LZC8efsflLnIP7rjXrZLXygFKDfrCoL0IS+2PKmkDJdAB/Wg== X-Google-Smtp-Source: AGHT+IGW5cZkE41p/tdEG9DFodleTtoqMTCMGwveOfwHFlzmWO+jy1XmvFXIovmvY7dXEr2D50am X-Received: by 2002:a05:620a:a8a:b0:789:fec9:6f51 with SMTP id v10-20020a05620a0a8a00b00789fec96f51mr14550692qkg.57.1712127504016; Tue, 02 Apr 2024 23:58:24 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712127504; cv=pass; d=google.com; s=arc-20160816; b=vzHKzKYSJLJMUzMbAfRcQPHFpSznnMOYBbFht3TM8UxY9EQGsAEPCSArudLX9Reh5+ MowcU6KHqYAcCUnT9hlx4Pxe2wfUSkn8UE4p9Lg80h1KG8IN2xmtwugx6FN58XFCF3tY l2MvBU2z/RkVVhO8Hgq6e5JcREUspvcW5lqC4b9Ib4mjEuMl82k+aQzdfn/Zi1OU0QRw DGaxPQ8Bqi7Tn+PQkByRtA5reCMSpHTPjYmcX95exP8P2/s+zjs7L49xK9AxlC3oEH6H tEMNJkqFUeGYnC6ss7QrlUXROpoihambdIkmvOilN2730vveqiEPB8Wqjiq1Cnt1cNvM z78Q== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=URfUMiQT17lJh/yOODBv4ku3XEJlT+WvGvldzqruyDc=; fh=tIGUu/tS8clb6eJPLiL5PWTs4hLnmMTnIPhkNYRWhig=; b=ZMxQo0AnEQz23A/gGjoQhkAkDk/F9kaGXk0DKtmta0aqcl64dwROaiqeKzVmoWCf9z YpH1VF3yfZORc03GXXLnfenSVHnaqcZ0PqSstW5Q7Jds7JECzM452IVzI1G3zkbJLlBH YQk4QGAtswD938jXp+vyLkPKDyMgZ29o4r2LJjWz01EFDOerX9XhwWb7btK5xY7K4O+Y G4f2hEOeHgc7cZKJH1idRD/eWrZYsdMrTlMuKhGiqlkOj8AlOu2REfmxwQZ6DdvOJt34 mtWBNHkVydYjcg/jL8JJ++zfra7xnNVMSAGNYzTQywGHut3W7QWorAsXbGCGIyiWKR5/ 8zlQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b=MvQXH+EQ; arc=pass (i=1 spf=pass spfdomain=mediatek.com dkim=pass dkdomain=mediatek.com dmarc=pass fromdomain=mediatek.com); spf=pass (google.com: domain of linux-kernel+bounces-129111-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-129111-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=mediatek.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id i9-20020ae9ee09000000b00788263f69afsi12905547qkg.313.2024.04.02.23.58.23 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Apr 2024 23:58:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-129111-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b=MvQXH+EQ; arc=pass (i=1 spf=pass spfdomain=mediatek.com dkim=pass dkdomain=mediatek.com dmarc=pass fromdomain=mediatek.com); spf=pass (google.com: domain of linux-kernel+bounces-129111-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-129111-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=mediatek.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id A971F1C21A0B for ; Wed, 3 Apr 2024 06:58:23 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 601E86E2A3; Wed, 3 Apr 2024 06:56:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=mediatek.com header.i=@mediatek.com header.b="MvQXH+EQ" Received: from mailgw01.mediatek.com (unknown [60.244.123.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 662AE60266; Wed, 3 Apr 2024 06:56:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=60.244.123.138 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712127383; cv=none; b=SgcmIR7W23mqNiCtNRsH/kmP13jtsWUF3iC6zTgNSmlg35lLNmwXymde3knVEAHlHZy/pzD52ljBh+XWQQ38aK9rUBYtQNNmbOldTH3QrXheF5/683vbUBdk/wG3xXWarbN/ud151h1fNj1vJc4rP+dcf/9b18xBEw8bhCn0wGo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712127383; c=relaxed/simple; bh=oBdA26JmC8YuT8Vwkgv3Oggk4xOJFs5mJ4Xhy4EhZMo=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=qEoa0ey+RU22esVOXwbSyFhFhr31l0q401aybhWFGnhog2Yli2cBVwmfrAdBvlrANFLir2nCkh1j6WFSzUifB6gwSiNxRBeNW14gnpMeRvleIvP7exhINHZgcMEFptyToLLA72fYXlZCR4rpYo/AkXNNrdetKBEnJkx5X0ltwkE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=mediatek.com; spf=pass smtp.mailfrom=mediatek.com; dkim=pass (1024-bit key) header.d=mediatek.com header.i=@mediatek.com header.b=MvQXH+EQ; arc=none smtp.client-ip=60.244.123.138 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=mediatek.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=mediatek.com X-UUID: 3ed8f944f18711eeb8927bc1f75efef4-20240403 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Type:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:CC:To:From; bh=URfUMiQT17lJh/yOODBv4ku3XEJlT+WvGvldzqruyDc=; b=MvQXH+EQUco0AVb0iTokZwyqSSkPnDD91UyriLdyjvlyyPmyADNuC3lZUXsbIohiuy4j2fmknBUBGKutLAwFhwW+tSbCYDHqykCYsWWRsnMUUCFUosSX/9eSkr5Weih3HoPaLfybbJs84vecjy/dAkvRVwM8965TOjc+pLaeYfo=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.37,REQID:3c06e590-296b-4225-a28c-ba313df12fdd,IP:0,U RL:0,TC:0,Content:-5,EDM:0,RT:0,SF:0,FILE:0,BULK:0,RULE:Release_Ham,ACTION :release,TS:-5 X-CID-META: VersionHash:6f543d0,CLOUDID:62e5a700-c26b-4159-a099-3b9d0558e447,B ulkID:nil,BulkQuantity:0,Recheck:0,SF:102,TC:nil,Content:0,EDM:-3,IP:nil,U RL: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 X-CID-BVR: 0 X-CID-BAS: 0,_,0,_ X-CID-FACTOR: TF_CID_SPAM_SNR X-UUID: 3ed8f944f18711eeb8927bc1f75efef4-20240403 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 1260599551; Wed, 03 Apr 2024 14:56:07 +0800 Received: from mtkmbs11n1.mediatek.inc (172.21.101.185) by MTKMBS14N2.mediatek.inc (172.21.101.76) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.26; Wed, 3 Apr 2024 14:56:06 +0800 Received: from mtksdccf07.mediatek.inc (172.21.84.99) by mtkmbs11n1.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.2.1118.26 via Frontend Transport; Wed, 3 Apr 2024 14:56:06 +0800 From: Shawn Sung To: CK Hu , Jassi Brar , AngeloGioacchino Del Regno CC: Rob Herring , Krzysztof Kozlowski , Conor Dooley , Matthias Brugger , Hsiao Chien Sung , "Jason-JH . Lin" , Houlong Wei , , , , Subject: [PATCH v4 9/9] mailbox: mediatek: Add secure CMDQ driver support for CMDQ driver Date: Wed, 3 Apr 2024 14:56:03 +0800 Message-ID: <20240403065603.21920-10-shawn.sung@mediatek.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20240403065603.21920-1-shawn.sung@mediatek.com> References: <20240403065603.21920-1-shawn.sung@mediatek.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain X-TM-AS-Product-Ver: SMEX-14.0.0.3152-9.1.1006-23728.005 X-TM-AS-Result: No-10--5.381100-8.000000 X-TMASE-MatchedRID: 4YoTATPIqSwlen1U/pCyekKcYi5Qw/RVCt59Uh3p/NVZps+y1VXzqUY/ auwRJnMLb1ikhugskqP8Qxx3otU4NmJZXQNDzktShK8o4aoss8quiRuR9mCaugqiCYa6w8tv235 yFjo/J+U1Wb8n14I41eXQHI6jQlB9DPIzF4wRfrAURSScn+QSXt0H8LFZNFG7hqz53n/yPnq6Sb mHE/H1FlFBnyH44vf3KT6JGY05QCPJJ6OKxZ1HqboOfFLgUu3n X-TM-AS-User-Approved-Sender: No X-TM-AS-User-Blocked-Sender: No X-TMASE-Result: 10--5.381100-8.000000 X-TMASE-Version: SMEX-14.0.0.3152-9.1.1006-23728.005 X-TM-SNTS-SMTP: B592F25D7C28CDD7C62ED6832DD71E7793473CC29696CB18FC5E8E1456399C762000:8 X-MTK: N From: "Jason-JH.Lin" CMDQ driver will probe a secure CMDQ driver when has_sec flag in platform data is true and its device node in dts has defined a event id of CMDQ_SYNC_TOKEN_SEC_EOF. Secure CMDQ driver support on mt8188 and mt8195 currently. So add a has_secure flag to their driver data to probe it. Signed-off-by: Jason-JH.Lin Signed-off-by: Hsiao Chien Sung --- drivers/mailbox/mtk-cmdq-mailbox.c | 38 ++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/drivers/mailbox/mtk-cmdq-mailbox.c b/drivers/mailbox/mtk-cmdq-mailbox.c index e04302ca6ec03..a8a0619baaa5c 100644 --- a/drivers/mailbox/mtk-cmdq-mailbox.c +++ b/drivers/mailbox/mtk-cmdq-mailbox.c @@ -15,6 +15,7 @@ #include #include #include +#include #include #define CMDQ_MBOX_AUTOSUSPEND_DELAY_MS 100 @@ -60,6 +61,9 @@ struct gce_plat { u8 shift; bool control_by_sw; bool sw_ddr_en; + bool has_secure; + u32 secure_thread_nr; + u32 secure_thread_min; u32 gce_num; }; @@ -569,6 +573,7 @@ static int cmdq_probe(struct platform_device *pdev) int alias_id = 0; static const char * const clk_name = "gce"; static const char * const clk_names[] = { "gce0", "gce1" }; + u32 hwid = 0; cmdq = devm_kzalloc(dev, sizeof(*cmdq), GFP_KERNEL); if (!cmdq) @@ -594,6 +599,8 @@ static int cmdq_probe(struct platform_device *pdev) dev, cmdq->base, cmdq->irq); if (cmdq->pdata->gce_num > 1) { + hwid = of_alias_get_id(dev->of_node, clk_name); + for_each_child_of_node(phandle->parent, node) { alias_id = of_alias_get_id(node, clk_name); if (alias_id >= 0 && alias_id < cmdq->pdata->gce_num) { @@ -676,6 +683,31 @@ static int cmdq_probe(struct platform_device *pdev) pm_runtime_set_autosuspend_delay(dev, CMDQ_MBOX_AUTOSUSPEND_DELAY_MS); pm_runtime_use_autosuspend(dev); + if (cmdq->pdata->has_secure) { + struct platform_device *mtk_cmdq_sec; + static struct gce_sec_plat sec_plat = {0}; + + if (of_property_read_u32_index(dev->of_node, "mediatek,gce-events", 0, + &sec_plat.cmdq_event) == 0) { + sec_plat.gce_dev = dev; + sec_plat.hwid = hwid; + sec_plat.gce_num = cmdq->pdata->gce_num; + sec_plat.clocks = cmdq->clocks; + sec_plat.thread_nr = cmdq->pdata->thread_nr; + sec_plat.secure_thread_nr = cmdq->pdata->secure_thread_nr; + sec_plat.secure_thread_min = cmdq->pdata->secure_thread_min; + + mtk_cmdq_sec = platform_device_register_data(dev, "mtk-cmdq-sec", + PLATFORM_DEVID_AUTO, + &sec_plat, + sizeof(sec_plat)); + if (IS_ERR(mtk_cmdq_sec)) { + dev_err(dev, "failed to register platform_device mtk-cmdq-sec\n"); + return PTR_ERR(mtk_cmdq_sec); + } + } + } + return 0; } @@ -719,6 +751,9 @@ static const struct gce_plat gce_plat_mt8188 = { .thread_nr = 32, .shift = 3, .control_by_sw = true, + .has_secure = true, + .secure_thread_nr = 2, + .secure_thread_min = 8, .gce_num = 2 }; @@ -733,6 +768,9 @@ static const struct gce_plat gce_plat_mt8195 = { .thread_nr = 24, .shift = 3, .control_by_sw = true, + .has_secure = true, + .secure_thread_nr = 2, + .secure_thread_min = 8, .gce_num = 2 }; -- 2.18.0