From patchwork Thu Dec 14 05:58:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?U2hhd24gU3VuZyAo5a6L5a2d6KyZKQ==?= X-Patchwork-Id: 178478 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:3b04:b0:fb:cd0c:d3e with SMTP id c4csp8343007dys; Wed, 13 Dec 2023 22:01:41 -0800 (PST) X-Google-Smtp-Source: AGHT+IFfcjOcA85+0L8PM367qO1qRJ9AD0HbTJ2xo6wTo1PAlcuq9RYTXYNa917GuZ0PCXr9h7Sx X-Received: by 2002:a05:6808:1307:b0:3b8:3442:8d99 with SMTP id y7-20020a056808130700b003b834428d99mr11659642oiv.20.1702533701687; Wed, 13 Dec 2023 22:01:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702533701; cv=none; d=google.com; s=arc-20160816; b=BfUrzsENHotPkReSOajPEfTcag1lz+VyHcGBnUqVuiQ7bdFg/twhIEVNs4Z7HbCaaj IssbhbMF70Ah2YPlIGoqLz+scTabKAgHPXX2fNzTBRAnYGjppZaOhHwFaQq9DoGlMZVY 2phCBNFWTwX7OykiSP9Ip5UrdDU/fmCEFRYGyrXic+TFQjXwxAkni4ws81DMooEhn4Ck kOdF7bMlAuKZg0nheu5Z0oB32EJrC5TYBRLxPst6Gv248RaasX2jsgrDeCL9SUSVbjp8 x/7n7R9ecpEyImRr0MGkDmOB+bPaV0x5wMBSAIglevWxMg0m8YcggtaW5eP+jZsVInOA VtMQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=o+uFOxS7n5grSNHrAFSx8XCQRvD6lGHMhzCBfr8ABok=; fh=3sxgsd2Uw0IiS0u77AMxpPqPOsrCjkgXK0HsUFuBxjc=; b=NWkP/KvgYQcIaeiT1a5by9Bga7hsPW0A5MBFk7nVZewVqSzZEkZlI3hB1CmBGeSUd1 zaOihtJgbGIOHW/c/SPLGeNGyTK/68hN/g7SFALOBUpir4FG5QkCopbiBN+qhjYkUP9D 7giaXU9BzMVLeoR0ZKAED/F4XzsnmOyqML+H5cK00e2Kov8YhQoSKNnpYoZebgk109OM TpYuTcB1H1fySdOIlra+SkCPYZAMy3BtWVKkTcjlHRE0NVzRAFD5/ywqMuaZGy4rgOKt tbZsFmkacA2rLeFaVs7tkHkhqp9SZEfoopg5MMGadoorgMq1Zw6OI6EMhxw3yDOgTiF+ gTHQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b=HQei70Yy; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 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 howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id r2-20020a17090a940200b00286861858e1si11850428pjo.26.2023.12.13.22.01.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Dec 2023 22:01:41 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b=HQei70Yy; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 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 (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id 16EF5806E159; Wed, 13 Dec 2023 22:00:22 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1443181AbjLNGAG (ORCPT + 99 others); Thu, 14 Dec 2023 01:00:06 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48634 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235409AbjLNF7q (ORCPT ); Thu, 14 Dec 2023 00:59:46 -0500 Received: from mailgw01.mediatek.com (unknown [60.244.123.138]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 009A919AE; Wed, 13 Dec 2023 21:58:54 -0800 (PST) X-UUID: da1827989a4511eea5db2bebc7c28f94-20231214 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=o+uFOxS7n5grSNHrAFSx8XCQRvD6lGHMhzCBfr8ABok=; b=HQei70YyMsCagpVWBBq+9XOlgy7sf2MXe7+oqmZkCfUDaTk1X4JZL1gX6LDuBmgquRaDeavYBXYSbCSLumeiNh0siIc5tyIufEojckSrQfsnRZNyeGlDjqB6Hhz6rGOdReVpucoMVCBy1IF34U+wVxQWAg5PK3ghYUlRZardJAM=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.35,REQID:a4f865f1-1354-440c-a352-6b0b32c5d865,IP:0,U RL:0,TC:0,Content:-25,EDM:0,RT:0,SF:0,FILE:0,BULK:0,RULE:Release_Ham,ACTIO N:release,TS:-25 X-CID-META: VersionHash:5d391d7,CLOUDID:b8fc2e61-c89d-4129-91cb-8ebfae4653fc,B ulkID:nil,BulkQuantity:0,Recheck:0,SF:102,TC:nil,Content:0,EDM:-3,IP:nil,U RL:0,File: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: da1827989a4511eea5db2bebc7c28f94-20231214 Received: from mtkmbs11n2.mediatek.inc [(172.21.101.187)] by mailgw01.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 371681131; Thu, 14 Dec 2023 13:58:49 +0800 Received: from mtkmbs13n2.mediatek.inc (172.21.101.108) by mtkmbs11n1.mediatek.inc (172.21.101.185) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.26; Thu, 14 Dec 2023 13:58:49 +0800 Received: from mtksdccf07.mediatek.inc (172.21.84.99) by mtkmbs13n2.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.2.1118.26 via Frontend Transport; Thu, 14 Dec 2023 13:58:49 +0800 From: Hsiao Chien Sung To: AngeloGioacchino Del Regno , CK Hu CC: Rob Herring , Krzysztof Kozlowski , Conor Dooley , Chun-Kuang Hu , Philipp Zabel , David Airlie , Daniel Vetter , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , Matthias Brugger , Moudy Ho , Hsiao Chien Sung , Nathan Lu , "Nancy . Lin" , "Roy-CW . Yeh" , "Jason-JH . Lin" , xinlei lee , , , , , Subject: [PATCH v12 09/23] soc: mediatek: Support reset bit mapping in mmsys driver Date: Thu, 14 Dec 2023 13:58:33 +0800 Message-ID: <20231214055847.4936-10-shawn.sung@mediatek.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20231214055847.4936-1-shawn.sung@mediatek.com> References: <20231214055847.4936-1-shawn.sung@mediatek.com> MIME-Version: 1.0 X-MTK: N X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,UNPARSEABLE_RELAY autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on howler.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Wed, 13 Dec 2023 22:00:22 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785235979048571946 X-GMAIL-MSGID: 1785235979048571946 - Reset ID must starts from 0 and be consecutive, but the reset bits in our hardware design is not continuous, some bits are left unused, we need a map to solve the problem - Use old style 1-to-1 mapping if .rst_tb is not defined Reviewed-by: AngeloGioacchino Del Regno Signed-off-by: Hsiao Chien Sung --- drivers/soc/mediatek/mtk-mmsys.c | 9 +++++++++ drivers/soc/mediatek/mtk-mmsys.h | 3 +++ 2 files changed, 12 insertions(+) diff --git a/drivers/soc/mediatek/mtk-mmsys.c b/drivers/soc/mediatek/mtk-mmsys.c index 1b160fcc1d27..fee958d0b8a6 100644 --- a/drivers/soc/mediatek/mtk-mmsys.c +++ b/drivers/soc/mediatek/mtk-mmsys.c @@ -314,6 +314,15 @@ static int mtk_mmsys_reset_update(struct reset_controller_dev *rcdev, unsigned l u32 offset; u32 reg; + if (mmsys->data->rst_tb) { + if (id >= mmsys->data->num_resets) { + dev_err(rcdev->dev, "Invalid reset ID: %lu (>=%u)\n", + id, mmsys->data->num_resets); + return -EINVAL; + } + id = mmsys->data->rst_tb[id]; + } + offset = (id / MMSYS_SW_RESET_PER_REG) * sizeof(u32); id = id % MMSYS_SW_RESET_PER_REG; reg = mmsys->data->sw0_rst_offset + offset; diff --git a/drivers/soc/mediatek/mtk-mmsys.h b/drivers/soc/mediatek/mtk-mmsys.h index 9d8507f98b7a..d370192737ca 100644 --- a/drivers/soc/mediatek/mtk-mmsys.h +++ b/drivers/soc/mediatek/mtk-mmsys.h @@ -78,6 +78,8 @@ #define DSI_SEL_IN_RDMA 0x1 #define DSI_SEL_IN_MASK 0x1 +#define MMSYS_RST_NR(bank, bit) (((bank) * 32) + (bit)) + struct mtk_mmsys_routes { u32 from_comp; u32 to_comp; @@ -119,6 +121,7 @@ struct mtk_mmsys_driver_data { const struct mtk_mmsys_routes *routes; const unsigned int num_routes; const u16 sw0_rst_offset; + const u8 *rst_tb; const u32 num_resets; const bool is_vppsys; const u8 vsync_len;