From patchwork Wed Jun 21 03:19: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: 110751 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp4099774vqr; Tue, 20 Jun 2023 20:42:58 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5GRXqjaSZV/4Gj8SQFuDopTMNdC9/SBMU0fkacBRaBQXZoIH7mxm63m2WTXo3l0edcpTmc X-Received: by 2002:a05:6a00:1741:b0:66a:2ff1:dee1 with SMTP id j1-20020a056a00174100b0066a2ff1dee1mr2562580pfc.19.1687318977668; Tue, 20 Jun 2023 20:42:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687318977; cv=none; d=google.com; s=arc-20160816; b=SEt3Ltux+ezA8JPP1GTqHDutreU4UtHFI4/OqbgKSEIG4FFxhMpcFOjv91xYdyRqmM WFM/kCL1R2R7HwfbF6qvO4fFLJTVkIQWBPbhoDjQgn0vpu8gZJKtm+lX/FrjRsbH9MKs +AWtuv4FYjKeHFWu+iuaEnOtcOlUpuN03mRJGIWqrRsOSEmm4QFT2YTO2vPDCkQKe5qw 7zuSi/sNmniyZJ5OqBAZAZPNCwEV5pMFejH8+DCr/eRgh5cKrZRK4M3ADqULiP+eGdBM 7VmyTqYhiyfIV0pNVa8pOMVv0INA9LnjbzzfS0am6tf0MYsohHz0Q9LsYfXT7JQXM51O Ab9g== 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=fqkjDL820tUu24kbWNzLcQN7WV0ZNAZdb3EuP8pPd8g=; b=x1bd/0b3+nKWShLnoJiTRxzXVKg6bvhkevl5Osz1bhcJK9KALDqqEx8CWerA66EwY9 iJGKUclS8+BMM2qoMfTFvOvvNbBoAd3+sS+S7ddBntpIe1iGrb2Swm6C+fvMiUHCoJKa AiKj5f+tG0c9WQvWCsTeVCFhM99YJxtvQ/QSC1m/P6/CUN90VxYes/SzZw00/+KxE/U3 w9m+s2GcfUdu+1uSpkws5ki5/8jyzau6IGRHKzsozZ7WXiiTSU7kirM1Bd64ZZZBqbCo nBCKXFJ8uAdBUC2iDeKkh6KFb9dmAO7myBm/O3rXmatg+3gmIwtE4Vf/dGRyA9o+Emzc GZEA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b=UVaxF2Bj; 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 199-20020a6301d0000000b00553813c2df0si3061145pgb.513.2023.06.20.20.42.42; Tue, 20 Jun 2023 20:42:57 -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=UVaxF2Bj; 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 S230253AbjFUDVH (ORCPT + 99 others); Tue, 20 Jun 2023 23:21:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60352 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230088AbjFUDTy (ORCPT ); Tue, 20 Jun 2023 23:19:54 -0400 Received: from mailgw02.mediatek.com (unknown [210.61.82.184]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 20EED1985; Tue, 20 Jun 2023 20:19:51 -0700 (PDT) X-UUID: 768849a80fe211eeb20a276fd37b9834-20230621 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=fqkjDL820tUu24kbWNzLcQN7WV0ZNAZdb3EuP8pPd8g=; b=UVaxF2BjhZqaHDht3fENREx5COz4ykT2OYDxqwnYdFxgG54LrpM51PtOOT2s7AbDgFZyESqAGOhtNIZYdHLpGRH6kqSdjzft2Z9SmWk3S4xy4IzLQu+Yig9z98h3qgb/j9SYT5dYy79BFxS96psdOcFVWUoGrnRWNQGhczrpM10=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.27,REQID:846de374-28a7-4bc3-9a4f-164a9a05cbc5,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:01c9525,CLOUDID:9bf4473f-7aa7-41f3-a6bd-0433bee822f3,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 X-CID-BVR: 0 X-CID-BAS: 0,_,0,_ X-CID-FACTOR: TF_CID_SPAM_SNR X-UUID: 768849a80fe211eeb20a276fd37b9834-20230621 Received: from mtkmbs10n2.mediatek.inc [(172.21.101.183)] by mailgw02.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 1706530602; Wed, 21 Jun 2023 11:19:42 +0800 Received: from mtkmbs13n2.mediatek.inc (172.21.101.108) 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; Wed, 21 Jun 2023 11:19:40 +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; Wed, 21 Jun 2023 11:19:40 +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 v4 09/14] soc: mediatek: Support reset bit mapping in mmsys driver Date: Wed, 21 Jun 2023 11:19:33 +0800 Message-ID: <20230621031938.5884-10-shawn.sung@mediatek.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20230621031938.5884-1-shawn.sung@mediatek.com> References: <20230621031938.5884-1-shawn.sung@mediatek.com> MIME-Version: 1.0 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,RDNS_NONE,SPF_HELO_PASS, SPF_PASS,T_SCC_BODY_TEXT_LINE,UNPARSEABLE_RELAY,URIBL_BLOCKED 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-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1769282184368570142?= X-GMAIL-MSGID: =?utf-8?q?1769282184368570142?= - 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 Signed-off-by: Hsiao Chien Sung Reviewed-by: AngeloGioacchino Del Regno --- 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 680dff5f89ec..ace71cc714c4 100644 --- a/drivers/soc/mediatek/mtk-mmsys.c +++ b/drivers/soc/mediatek/mtk-mmsys.c @@ -311,6 +311,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..c4c19fcd4b62 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;