Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp4060860pxj; Mon, 24 May 2021 22:54:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwkVvBVtDZdpVsvy1qXx7IyKxCv4P3FQNTWG09JbSIZrC4QhKf7e2fVDYrvbDmw/uabtIa4 X-Received: by 2002:a05:6e02:1d83:: with SMTP id h3mr888005ila.54.1621922095448; Mon, 24 May 2021 22:54:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621922095; cv=none; d=google.com; s=arc-20160816; b=QownKao0YGdCxZHeZy3Z4oWY5tOrRAHPD72kicVpT0nhXnz4Fh/gEKqxXyaXxWmP8s xo1HMb0/bPcO64IrnaEFIfgCVC6eywadhFLh1MyvsY9kgbvNlwcFOh3admzPIuROCOR7 /1HPoH1e75u7clJt0Q2/vUjT+2V0O3oChZISSplwq+04jDo5pUox31V2++d46HD1Mr9W rvwg/AcT0cH1afBkOzB1m3DSGCF6hAd71F7IcdufKnhRIxZqa+jff6OKjYul4nV322CC IM8PiJHlDunOAxb+EQe0ELlgOMmqGvYzEZXtXePzOslQ1p6x71nDvrOSL5F7lwknViNe cZ7w== 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; bh=EwCd8+LiPWsxGRRPIGSzHkY4OMmcyizAMriCh34J0ak=; b=Orgz88Pneo5DTOktjPfk/LgGh63XBxT783kbc8h9Ppb1jDBH1cSgCO/P/mvqg857ue 4iQSaEDlHtLi7GL1ZvljnyQR8ap2bNypSQj9WyQ6GOJrihXb6XoFlVBrx4FjfThlLL46 glwlwW/fiSteeZDSdxJ5Q/+lJAKOPQBqiYaIynR84NPRT6fOs/P3k36f22AQFiV5QSOa twMllleD6ZeUpczfmc4kBYOUCwu9QSvIFwLnEcBgjv1ht8UUDfoYtGxvthGqR78HxAqz BNPHr05NRMdeQwWdMDIVji/gNhvFJGlChKn8G0N7HF9Z7JJnL8PXfhKkcD/ckz+T6DJH yB3w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mediatek.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c11si16136210jaq.7.2021.05.24.22.54.42; Mon, 24 May 2021 22:54:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mediatek.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231136AbhEYFzF (ORCPT + 99 others); Tue, 25 May 2021 01:55:05 -0400 Received: from mailgw02.mediatek.com ([210.61.82.184]:55390 "EHLO mailgw02.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S231138AbhEYFzD (ORCPT ); Tue, 25 May 2021 01:55:03 -0400 X-UUID: a265f0ac6dfd40e98594ddc3fa590b81-20210525 X-UUID: a265f0ac6dfd40e98594ddc3fa590b81-20210525 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 457525012; Tue, 25 May 2021 13:53:31 +0800 Received: from mtkcas11.mediatek.inc (172.21.101.40) by mtkmbs08n2.mediatek.inc (172.21.101.56) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Tue, 25 May 2021 13:53:29 +0800 Received: from mtksdccf07.mediatek.inc (172.21.84.99) by mtkcas11.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Tue, 25 May 2021 13:53:29 +0800 From: Nina Wu To: Rob Herring , Matthias Brugger CC: Zhen Lei , Nina Wu , , , , , , , Subject: [PATCH v4 2/7] soc: mediatek: devapc: get 'vio_idx_num' info from DT Date: Tue, 25 May 2021 13:53:01 +0800 Message-ID: <1621921986-20578-2-git-send-email-nina-cm.wu@mediatek.com> X-Mailer: git-send-email 2.6.4 In-Reply-To: <1621921986-20578-1-git-send-email-nina-cm.wu@mediatek.com> References: <1621921986-20578-1-git-send-email-nina-cm.wu@mediatek.com> MIME-Version: 1.0 Content-Type: text/plain X-MTK: N Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Nina Wu For new ICs, there are multiple devapc HWs for different subsys. The number of devices controlled by each devapc (i.e. 'vio_idx_num') will be set in DT for per devapc node. On the other hand, for old ICs which have only one devapc HW, the 'vio_idx_num' info is set in compatible data. To be backward compatible, the 'vio_idx_num' in compatible data is set as the default value. Only when the default value is 0 will we get the 'vio_idx_num' from DT. Signed-off-by: Nina Wu --- drivers/soc/mediatek/mtk-devapc.c | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/drivers/soc/mediatek/mtk-devapc.c b/drivers/soc/mediatek/mtk-devapc.c index f1cea04..71643d1 100644 --- a/drivers/soc/mediatek/mtk-devapc.c +++ b/drivers/soc/mediatek/mtk-devapc.c @@ -32,7 +32,7 @@ struct mtk_devapc_vio_dbgs { }; struct mtk_devapc_data { - /* numbers of violation index */ + /* default numbers of violation index */ u32 vio_idx_num; /* reg offset */ @@ -51,6 +51,9 @@ struct mtk_devapc_context { void __iomem *infra_base; struct clk *infra_clk; const struct mtk_devapc_data *data; + + /* numbers of violation index */ + u32 vio_idx_num; }; static void clear_vio_status(struct mtk_devapc_context *ctx) @@ -60,10 +63,10 @@ static void clear_vio_status(struct mtk_devapc_context *ctx) reg = ctx->infra_base + ctx->data->vio_sta_offset; - for (i = 0; i < VIO_MOD_TO_REG_IND(ctx->data->vio_idx_num) - 1; i++) + for (i = 0; i < VIO_MOD_TO_REG_IND(ctx->vio_idx_num) - 1; i++) writel(GENMASK(31, 0), reg + 4 * i); - writel(GENMASK(VIO_MOD_TO_REG_OFF(ctx->data->vio_idx_num) - 1, 0), + writel(GENMASK(VIO_MOD_TO_REG_OFF(ctx->vio_idx_num) - 1, 0), reg + 4 * i); } @@ -80,15 +83,15 @@ static void mask_module_irq(struct mtk_devapc_context *ctx, bool mask) else val = 0; - for (i = 0; i < VIO_MOD_TO_REG_IND(ctx->data->vio_idx_num) - 1; i++) + for (i = 0; i < VIO_MOD_TO_REG_IND(ctx->vio_idx_num) - 1; i++) writel(val, reg + 4 * i); val = readl(reg + 4 * i); if (mask) - val |= GENMASK(VIO_MOD_TO_REG_OFF(ctx->data->vio_idx_num) - 1, + val |= GENMASK(VIO_MOD_TO_REG_OFF(ctx->vio_idx_num) - 1, 0); else - val &= ~GENMASK(VIO_MOD_TO_REG_OFF(ctx->data->vio_idx_num) - 1, + val &= ~GENMASK(VIO_MOD_TO_REG_OFF(ctx->vio_idx_num) - 1, 0); writel(val, reg + 4 * i); @@ -256,6 +259,16 @@ static int mtk_devapc_probe(struct platform_device *pdev) if (!ctx->infra_base) return -EINVAL; + /* Set vio_idx_num to default value. + * If the value is 0, get the info from DT. + */ + ctx->vio_idx_num = ctx->data->vio_idx_num; + if (!ctx->vio_idx_num) + if (of_property_read_u32(node, + "vio-idx-num", + &ctx->vio_idx_num)) + return -EINVAL; + devapc_irq = irq_of_parse_and_map(node, 0); if (!devapc_irq) return -EINVAL; -- 2.6.4