From patchwork Tue Jun 27 06:39:41 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: 113245 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp7990495vqr; Mon, 26 Jun 2023 23:41:47 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5YxvE0FpctUIlqZwB2bSpX4UTIBA8Wx0+pLVA72CCL2+yPo7KJpS8hAjQsj0WZZUK9MVQq X-Received: by 2002:a05:6359:a14:b0:132:da7e:1078 with SMTP id el20-20020a0563590a1400b00132da7e1078mr5643101rwb.23.1687848107460; Mon, 26 Jun 2023 23:41:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687848107; cv=none; d=google.com; s=arc-20160816; b=aqwa7HKNZD003uSRzcHPfRqOq8+xz//hYVIyWTziqXoHI00zWE8RIsGuPZs/c6x9P1 4ccb7u5sYA1xtFcux+8zPkb0HLFb3lszDkS0en8P8CsJ2rL4uOW6rKtbVa303RTakr6d pYkxMSyvvBXKcUOUcWHli7efc9U0e5b30+D1TxUxKd6qjGMNj4enAvVcXPrUUsBIq2nt xvQ9UB1eqhoBQ01mqWYWrkXPkldWjkJtgUERemXMquRKi92RL3QXQHTrU83ynVxud/k0 o4eohZIk+qT30yKeGz2sdkqWamM3hp+A38j1SKt56Yfq3uPy9i9cZte/ktk3TVDKPtYT 2tFA== 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=z8zL/tMj6ZU0jCH2maGtMUGXC5yMFUYAvn6bFT2xq0c=; fh=eGT9imnITysaZP7qqwDR6mqUkV/i49Ro5oyELgOcwP4=; b=jpP0xlT02g17NzcVsR2l6UIJiSaGwggAemjfn6hnQKJxqyLl4Jns/qxopyEueqlSD7 uhj4ca/cefHJiXGytUD9sPUdT66moJi/9WQ+96vMbl/MCGX118n1FdSosQzgPoD49hDw EJAQjAA/0HV/wIfxoKaQWlfKtGGFlJx9VXzN5ZKmw+NQdEeFC1FEW1uirkn3SE6fKsED OhLerKVxhKViyYn5XeWamnUrCvYoJ+8xZBCPMkce60oHBZ/qCxHy9FF755nT8Yerc3ah C5InlayIu0YQRkFL8B52CoiCVvP0QvYt2Xrptr1k4tda/tTHZRDSVafDX8qlt3C2+xdU nmlw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b=pjt8zezO; 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 a4-20020a634d04000000b005533db5fbb0si6574959pgb.379.2023.06.26.23.41.34; Mon, 26 Jun 2023 23:41:47 -0700 (PDT) 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=pjt8zezO; 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 S231247AbjF0Gkf (ORCPT + 99 others); Tue, 27 Jun 2023 02:40:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40252 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229790AbjF0GkG (ORCPT ); Tue, 27 Jun 2023 02:40:06 -0400 Received: from mailgw02.mediatek.com (unknown [210.61.82.184]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7B21C1FD7; Mon, 26 Jun 2023 23:40:04 -0700 (PDT) X-UUID: 6dd44a3c14b511eeb20a276fd37b9834-20230627 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=z8zL/tMj6ZU0jCH2maGtMUGXC5yMFUYAvn6bFT2xq0c=; b=pjt8zezOsnADgUhLOIx4MQncWyWZ761JO78e6jv8mD41fX/99fnOgCs1LL4S/16RBSR/QUN3n5RI/8/5ILEDx8Lw2k9ls0sAqDgvAkajpcXGT0EO27zYS/5h1GesLKIuVi/7+LfZ7Mzu7Jw5pN8L5UKqhqADuXCZs4DTGLKFNOc=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.27,REQID:57e57ac1-bd99-45b2-9317-068945ba9b35,IP:0,U RL:0,TC:0,Content:-25,EDM:25,RT:0,SF:95,FILE:0,BULK:0,RULE:Release_Ham,ACT ION:release,TS:95 X-CID-INFO: VERSION:1.1.27,REQID:57e57ac1-bd99-45b2-9317-068945ba9b35,IP:0,URL :0,TC:0,Content:-25,EDM:25,RT:0,SF:95,FILE:0,BULK:0,RULE:Spam_GS981B3D,ACT ION:quarantine,TS:95 X-CID-META: VersionHash:01c9525,CLOUDID:cd5b5b82-5a99-42ae-a2dd-e4afb731b474,B ulkID:2306271439577U48IHVF,BulkQuantity:0,Recheck:0,SF:38|29|28|17|19|48,T C:nil,Content:0,EDM:5,IP:nil,URL:0,File:nil,Bulk:nil,QS:nil,BEC:nil,COL:0, OSI:0,OSA:0,AV:0,LES:1,SPR:NO X-CID-BVR: 0 X-CID-BAS: 0,_,0,_ X-CID-FACTOR: TF_CID_SPAM_SDM,TF_CID_SPAM_ASC,TF_CID_SPAM_FAS,TF_CID_SPAM_FSD, TF_CID_SPAM_SNR X-UUID: 6dd44a3c14b511eeb20a276fd37b9834-20230627 Received: from mtkmbs13n1.mediatek.inc [(172.21.101.193)] by mailgw02.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 1854773069; Tue, 27 Jun 2023 14:39:55 +0800 Received: from mtkmbs13n1.mediatek.inc (172.21.101.193) by mtkmbs10n1.mediatek.inc (172.21.101.34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.26; Tue, 27 Jun 2023 14:39:55 +0800 Received: from mtksdccf07.mediatek.inc (172.21.84.99) by mtkmbs13n1.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.2.1118.26 via Frontend Transport; Tue, 27 Jun 2023 14:39:55 +0800 From: Hsiao Chien Sung To: AngeloGioacchino Del Regno , Chun-Kuang Hu , Krzysztof Kozlowski , Matthias Brugger , Philipp Zabel , Rob Herring CC: , , , , , Singo Chang , Nancy Lin , Jason-JH Lin , Shawn Sung Subject: [PATCH v5 09/14] soc: mediatek: Support reset bit mapping in mmsys driver Date: Tue, 27 Jun 2023 14:39:41 +0800 Message-ID: <20230627063946.14935-10-shawn.sung@mediatek.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20230627063946.14935-1-shawn.sung@mediatek.com> References: <20230627063946.14935-1-shawn.sung@mediatek.com> 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_H5, RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_PASS,T_SCC_BODY_TEXT_LINE, UNPARSEABLE_RELAY,URIBL_BLOCKED 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?1769837016704797475?= X-GMAIL-MSGID: =?utf-8?q?1769837016704797475?= - 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 af4235f7a35f..a7d2a21c11b2 100644 --- a/drivers/soc/mediatek/mtk-mmsys.c +++ b/drivers/soc/mediatek/mtk-mmsys.c @@ -310,6 +310,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 964b5449d672..dfbb742eaa11 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;