Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp2407108rdg; Mon, 16 Oct 2023 03:41:42 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEGFciQbT0w8tfafXcn6YKrcDy3LoCS4CFb25KCzpj3y0ZYRZQEX5dhaH08vCbSe/uxLx/S X-Received: by 2002:a05:6a20:96c1:b0:163:a3ce:a699 with SMTP id hq1-20020a056a2096c100b00163a3cea699mr26099908pzc.57.1697452901783; Mon, 16 Oct 2023 03:41:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697452901; cv=none; d=google.com; s=arc-20160816; b=aUAi8gEgMHsuevnH9VhWgWRZVZfHEH9V/3hOtrihqL6pSJdPMdQy292AXZOWvRZCZ5 DqPq5kpqimv/1LrgSdBbP4t7dyZ7v+Zqrdp86JwpHLeMdHL+fjdDsvqPVjlfkvX8nwpk wLQBHnY517lIoZSIHCMuJ4NJc1VO07o46alE7yWW4PfZfTrY8omVFecJ4AVvx0pJSsqk 5XQhFH55rWa2c1HvqHCw7Z+XN34QiNua0MH9JIEvE/d7rjDr1kKViWkehLHn7vhOoLFj brVpwvkCszikEchzVgKbh9FT0YapP8vh8B732jnkhTpmc8ujMuN+vU44zcTZjkwpa3Sc VEwg== 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=1WBWcHWYD8j2TuV0GiR1HO0vyjP9ZDrU1nnjtFA3zjg=; fh=8kgzifk4orktq6sICAh9UkMBfxIdH2rYYHr6dIOIt3w=; b=ubM813adUWQBxwcekdq4ZgS+iT5uJ0BbGDR21YRvGUlTmGCRdYVV9zZ9cjb2fzHoko OS4lPqbxAbn8JLsFhcQyFkt9L0WdrfWej9eWaSsghsuA0N65Dzs//AfYYaXgbZVxbSj7 f0cvZmAWoC9JUs2zCfGzuAmBY0LVNaziLd4plbsfJOrgHdhADIBTjGuJeUCtfAXOgzxh Slwbh+0MHRsYpObAnD7Bf7vwOy6zybnumM0nMZ8m20sBbQIMU/bspVuNWdz5DJdge/YM +XC/f1NdPNUZ17BebCqCmIaEpptwxJnMMYpz/hRvR3CO5kRuZWjUcW/hCSYjrBzgSRVy cwFg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b=VLCkrsEG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=mediatek.com Return-Path: Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id f7-20020a17090274c700b001b9ea0f0e25si10041158plt.607.2023.10.16.03.41.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Oct 2023 03:41:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b=VLCkrsEG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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 snail.vger.email (Postfix) with ESMTP id 8132880657FF; Mon, 16 Oct 2023 03:41:28 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233131AbjJPKlH (ORCPT + 99 others); Mon, 16 Oct 2023 06:41:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39622 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232633AbjJPKk3 (ORCPT ); Mon, 16 Oct 2023 06:40:29 -0400 Received: from mailgw02.mediatek.com (unknown [210.61.82.184]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B91E3AC; Mon, 16 Oct 2023 03:40:22 -0700 (PDT) X-UUID: 63edf6146c1011ee8051498923ad61e6-20231016 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=1WBWcHWYD8j2TuV0GiR1HO0vyjP9ZDrU1nnjtFA3zjg=; b=VLCkrsEGyWHyjvY/ypWUya1nFj5g6mE4VaVEqTg/jOOXX+bX7csTUSdrc/7zfxhoBiYM929ze0msAs+hIXMpAxdOgPgPt4Ru9MMKqGuiKdAlBzdlFRrwruz+vVK5sn3o/JQRT3Tu02byE9hquwwDSTBik20SrjqJSwPZM4Uzvgc=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.32,REQID:e85e2045-2f59-4e0e-b9a0-631a7adc2afb,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:5f78ec9,CLOUDID:cdd91615-4929-4845-9571-38c601e9c3c9,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: 63edf6146c1011ee8051498923ad61e6-20231016 Received: from mtkmbs14n1.mediatek.inc [(172.21.101.75)] by mailgw02.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 949260631; Mon, 16 Oct 2023 18:40:14 +0800 Received: from mtkmbs11n2.mediatek.inc (172.21.101.187) by mtkmbs13n2.mediatek.inc (172.21.101.108) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.26; Mon, 16 Oct 2023 18:40:14 +0800 Received: from mtksdccf07.mediatek.inc (172.21.84.99) by mtkmbs11n2.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.2.1118.26 via Frontend Transport; Mon, 16 Oct 2023 18:40:14 +0800 From: Hsiao Chien Sung To: AngeloGioacchino Del Regno , CK Hu , Krzysztof Kozlowski , Matthias Brugger , Rob Herring CC: Chun-Kuang Hu , Philipp Zabel , David Airlie , Daniel Vetter , Fei Shao , Sean Paul , Johnson Wang , "Nancy . Lin" , Moudy Ho , "Jason-JH . Lin" , Nathan Lu , Hsiao Chien Sung , Yongqiang Niu , Hans Verkuil , Mauro Carvalho Chehab , , , , , Subject: [PATCH v8 09/23] soc: mediatek: Support reset bit mapping in mmsys driver Date: Mon, 16 Oct 2023 18:39:56 +0800 Message-ID: <20231016104010.3270-10-shawn.sung@mediatek.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20231016104010.3270-1-shawn.sung@mediatek.com> References: <20231016104010.3270-1-shawn.sung@mediatek.com> MIME-Version: 1.0 Content-Type: text/plain X-MTK: N X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED,RDNS_NONE, SPF_HELO_PASS,T_SPF_TEMPERROR,UNPARSEABLE_RELAY autolearn=no 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-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Mon, 16 Oct 2023 03:41:28 -0700 (PDT) - 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 b1db09e19905..3a7108eefe9d 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 49851bc7aa9e..c90419c96a7d 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; -- 2.18.0