From patchwork Wed Feb 8 09:22:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?TW91ZHkgSG8gKOS9leWul+WOnyk=?= X-Patchwork-Id: 54303 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp3352965wrn; Wed, 8 Feb 2023 01:26:32 -0800 (PST) X-Google-Smtp-Source: AK7set8BgEbhqts6kY32iIbsp2amVD9rNdTos+tA0R+E3TipqoCDCtahUuzqwz81u48GAHRHndx+ X-Received: by 2002:a17:902:db07:b0:196:13cd:a49 with SMTP id m7-20020a170902db0700b0019613cd0a49mr6903976plx.27.1675848392322; Wed, 08 Feb 2023 01:26:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675848392; cv=none; d=google.com; s=arc-20160816; b=RlyF3CRxkeiRGQRWGi+5zTt4K+rCB18+TE07fB/Xwzstu1oOtYz9AooWyjTimXkEqY 2msbpPgdWW0aeWjdsDtiEPC+Ym2oSZ/IxuGSMis00GTLwbFouGHkjySEYcDVWxqs02zD Th2DDDKujltpJOSOsMsiUyz22yDrCcAJGMGWx1+HAK3M/qcB+/QN8CJUTHi+RoXQteLO cnUe9o4hWz28oQ4B/1rwe8C2ttrmC9JJwh39wCJ/P6YQhVp1tgytQu+gLna+I5noCRrW TaNdQyo5cCZAq9aSOicv75bRHDOQLBsQsDCk1sy8a/CMAYa0lLrmR8h1w7QFkiqBVqag TYWQ== 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=GTIhlHpcJfdJw4cUgNiKsI/u9C+3bCVYeSiQMTFb1rk=; b=aDlTM8SjAY0cbg5WJjrCSQn5zXko/fulEHfAh5J1NxoRf2CTr7j+/yC4VtFebNJyGt X3st3Tk5N2qv+uhiUgSO6NIlQts4QkNy4/grznjawf7v6J1CZVOTPEAhRv29L1CGHB0o D7jOy0ayJfzbRi1V8Nh2aInnUpHiLN5Va7QNdjZbOF6kbmWwzaK88wlba4mJUg3+9oSe o4S9CYcqIN+puJluAtDhhwcJcuRMWPLE6iWLrSndYUYDIY3XdB41XVGi1CkocCHr3KXK 0EUzcpdX70zIAg013I1/bnnFSvpQ7RpntQaD22kid6+OT42fz4x4NKaHPDNutYeu/ODT UD7Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b=LAdU1nbH; 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 z23-20020a1709028f9700b00189659458a3si17048576plo.455.2023.02.08.01.26.19; Wed, 08 Feb 2023 01:26:32 -0800 (PST) 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=LAdU1nbH; 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 S231195AbjBHJYm (ORCPT + 99 others); Wed, 8 Feb 2023 04:24:42 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39440 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231143AbjBHJX6 (ORCPT ); Wed, 8 Feb 2023 04:23:58 -0500 Received: from mailgw01.mediatek.com (unknown [60.244.123.138]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DC42D460A7; Wed, 8 Feb 2023 01:22:18 -0800 (PST) X-UUID: 12af0b6ea79211eda06fc9ecc4dadd91-20230208 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=GTIhlHpcJfdJw4cUgNiKsI/u9C+3bCVYeSiQMTFb1rk=; b=LAdU1nbHgZmqiJkbSVKLHh7SRVqh35sN2yF2oFcxI1tdRiK00QrdiU/SvanjGIkE2BHYYe01X7Uij+ocTkHwDzFQKJmR/umDwSk60EyoissNLsJ6zY3o6v6CP/XplKYz4BtcNiqCqyKfSAQhf/krWgk8UiqUL9RdVvRbeQxk54o=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.19,REQID:c56616fe-597b-4dba-9118-07db41dd8f80,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:885ddb2,CLOUDID:f998d4f7-ff42-4fb0-b929-626456a83c14,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 X-CID-BVR: 0,NGT X-UUID: 12af0b6ea79211eda06fc9ecc4dadd91-20230208 Received: from mtkmbs11n1.mediatek.inc [(172.21.101.185)] by mailgw01.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 733564053; Wed, 08 Feb 2023 17:22:13 +0800 Received: from mtkmbs11n1.mediatek.inc (172.21.101.185) 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.792.15; Wed, 8 Feb 2023 17:22:11 +0800 Received: from mtksdccf07.mediatek.inc (172.21.84.99) by mtkmbs11n1.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.2.792.15 via Frontend Transport; Wed, 8 Feb 2023 17:22:11 +0800 From: Moudy Ho To: Mauro Carvalho Chehab , Rob Herring , Krzysztof Kozlowski , Matthias Brugger CC: , , , , , , Moudy Ho Subject: [PATCH v4 10/16] media: platform: mtk-mdp3: avoid multiple driver registrations Date: Wed, 8 Feb 2023 17:22:03 +0800 Message-ID: <20230208092209.19472-11-moudy.ho@mediatek.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20230208092209.19472-1-moudy.ho@mediatek.com> References: <20230208092209.19472-1-moudy.ho@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_H2,SPF_HELO_PASS, SPF_PASS,UNPARSEABLE_RELAY 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?1757254403775223911?= X-GMAIL-MSGID: =?utf-8?q?1757254403775223911?= The number of MDP3 driver probes depends on the registered clocks of MMSYS. Because VPPSYS0 and VPPSYS1 are used in MT8195 MDP3, it is necessary to avoid multiple driver registrations. Signed-off-by: Moudy Ho --- drivers/media/platform/mediatek/mdp3/mdp_cfg_data.c | 1 + drivers/media/platform/mediatek/mdp3/mtk-mdp3-core.c | 9 ++++++++- drivers/media/platform/mediatek/mdp3/mtk-mdp3-core.h | 1 + 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/drivers/media/platform/mediatek/mdp3/mdp_cfg_data.c b/drivers/media/platform/mediatek/mdp3/mdp_cfg_data.c index eafd2fbe39a0..0c65b64c6266 100644 --- a/drivers/media/platform/mediatek/mdp3/mdp_cfg_data.c +++ b/drivers/media/platform/mediatek/mdp3/mdp_cfg_data.c @@ -410,6 +410,7 @@ static const struct mdp_pipe_info mt8183_pipe_info[] = { const struct mtk_mdp_driver_data mt8183_mdp_driver_data = { .mdp_plat_id = MT8183, + .mdp_con_res = 0x14001000, .mdp_probe_infra = mt8183_mdp_probe_infra, .mdp_cfg = &mt8183_plat_cfg, .mdp_mutex_table_idx = mt8183_mutex_idx, diff --git a/drivers/media/platform/mediatek/mdp3/mtk-mdp3-core.c b/drivers/media/platform/mediatek/mdp3/mtk-mdp3-core.c index bf64f88c29fe..09cad71aef69 100644 --- a/drivers/media/platform/mediatek/mdp3/mtk-mdp3-core.c +++ b/drivers/media/platform/mediatek/mdp3/mtk-mdp3-core.c @@ -161,6 +161,7 @@ static int mdp_probe(struct platform_device *pdev) struct device *dev = &pdev->dev; struct mdp_dev *mdp; struct platform_device *mm_pdev, *mm2_pdev; + struct resource *res; int ret, i, mutex_id; mdp = kzalloc(sizeof(*mdp), GFP_KERNEL); @@ -172,6 +173,12 @@ static int mdp_probe(struct platform_device *pdev) mdp->pdev = pdev; mdp->mdp_data = of_device_get_match_data(&pdev->dev); + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); + if (res->start != mdp->mdp_data->mdp_con_res) { + platform_set_drvdata(pdev, mdp); + goto success_return; + } + mm_pdev = __get_pdev_by_id(pdev, NULL, MDP_INFRA_MMSYS); if (IS_ERR_OR_NULL(mm_pdev)) { ret = -ENODEV; @@ -209,7 +216,6 @@ static int mdp_probe(struct platform_device *pdev) p = (id && mm2_pdev) ? mm2_pdev : mm_pdev; m = (id && mm2_pdev) ? mdp->mdp_mutex2 : mdp->mdp_mutex; - if (m[mutex_id]) continue; m[mutex_id] = mtk_mutex_get(&p->dev); @@ -278,6 +284,7 @@ static int mdp_probe(struct platform_device *pdev) goto err_unregister_device; } +success_return: dev_dbg(dev, "mdp-%d registered successfully\n", pdev->id); return 0; diff --git a/drivers/media/platform/mediatek/mdp3/mtk-mdp3-core.h b/drivers/media/platform/mediatek/mdp3/mtk-mdp3-core.h index e4ffa25b9271..a063a655248c 100644 --- a/drivers/media/platform/mediatek/mdp3/mtk-mdp3-core.h +++ b/drivers/media/platform/mediatek/mdp3/mtk-mdp3-core.h @@ -61,6 +61,7 @@ enum mdp_pipe_id { struct mtk_mdp_driver_data { const int mdp_plat_id; + const resource_size_t mdp_con_res; const struct of_device_id *mdp_probe_infra; const struct mdp_platform_config *mdp_cfg; const u32 *mdp_mutex_table_idx;