From patchwork Wed Apr 19 07:49:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?V2FsdGVyIENoYW5nICjlvLXntq3lk7Ip?= X-Patchwork-Id: 85241 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp195038vqo; Wed, 19 Apr 2023 00:55:06 -0700 (PDT) X-Google-Smtp-Source: AKy350YbbNrvrtyjPOy1SE/yH2C0BQoG2bfWoNq7VNwMS6JF4225/LkWa8tn2TPvr2wBeMxQyDV3 X-Received: by 2002:a05:6a20:6a1e:b0:f0:ac6b:379e with SMTP id p30-20020a056a206a1e00b000f0ac6b379emr3139184pzk.4.1681890905879; Wed, 19 Apr 2023 00:55:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681890905; cv=none; d=google.com; s=arc-20160816; b=Xchk5ATnG1u1cxv2Kgcs/uzXXV6iVQx8NXHpGQl+PJtNZJkMscN8JGLuDDn+WuCJOo SAduQMdHb35MMKRZbyEDEYJr7pc2fUM5zep8WvXEImsvpL+U060FnR4zdpJY0PUXh3IO 8xMgK56c/ENukDKLqHIiADSBGkuVSBugL2L5xkQd53LUu5dXmqbQ8YTzZONTlhdUTbB3 WyOVCxD1gGEmgr0anikpwSBCkxPlHxmmGEdLv3Dzdeq8LqsBzYa8s2Ks4sbjHY2QedZp Gv52Fqstx+Wbkd7D/PJfe/8M3WdM/zcuWDvftgSjPHolXIL7n9M3TmMEwJJjM6BJSrWH d69Q== 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=IHhBOfUYeT77YquBREt22vcfy911MiykLSdiMpD9Yo0=; b=N11bWPgrUvUyTuEiMODJ38AwJraL+Cnj6b5S5YV42kn8PkLpqJDKtC/xCGIQATTfjF oAcqi5uTDtCVHue/I0mPXPeF0o2XMnrpXPK14yBStp2Z5bNSyZF6hZb1cuCcG4lilgi8 hLRoeDCPEuogxo+Nu6jl2OsI+3SDjfe7+7IdB8Q+qmtV3R3VVPtKYMnjkOLU1I2dnlKU pV34e6D4kTlHj7cYkwLvnZEDPsTp2DKoPU2cIfJIHd/HuhDcAxq1On1wHWcxQIdEl08Y PCxx4nse1IxQOmOJx3suGupCuQcJMGPO0yBoQjxoACjxYZRsRUyETsdTF2wVeRo0KBey rKkA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b=rFcmb5xM; 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 n6-20020a63ee46000000b0050f55427e3dsi16318509pgk.701.2023.04.19.00.54.54; Wed, 19 Apr 2023 00:55:05 -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=rFcmb5xM; 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 S232321AbjDSHuI (ORCPT + 99 others); Wed, 19 Apr 2023 03:50:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37568 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232526AbjDSHt4 (ORCPT ); Wed, 19 Apr 2023 03:49:56 -0400 Received: from mailgw01.mediatek.com (unknown [60.244.123.138]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 31FE67AB9 for ; Wed, 19 Apr 2023 00:49:54 -0700 (PDT) X-UUID: c34bfc68de8611eda9a90f0bb45854f4-20230419 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=IHhBOfUYeT77YquBREt22vcfy911MiykLSdiMpD9Yo0=; b=rFcmb5xMxej7NRtBhk/SzLJTLmt+c2Cxowdk2S98KjpUHk/hl3u3dgms1J8fArLLXPBArfSgMsIVTmKL8Z/T6KtjEdQ3T2dnc1q2RUzc74U9qW+wGBlDGYxDqGE4PJJ87Q2u3ENhbzzqcwikCgY1EjGD2zsBserZ7wyITvAqafk=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.22,REQID:b47f5395-83c6-4a88-954c-d51b21018799,IP:0,U RL:0,TC:0,Content:-25,EDM:0,RT:0,SF:95,FILE:0,BULK:0,RULE:Release_Ham,ACTI ON:release,TS:70 X-CID-INFO: VERSION:1.1.22,REQID:b47f5395-83c6-4a88-954c-d51b21018799,IP:0,URL :0,TC:0,Content:-25,EDM:0,RT:0,SF:95,FILE:0,BULK:0,RULE:Spam_GS981B3D,ACTI ON:quarantine,TS:70 X-CID-META: VersionHash:120426c,CLOUDID:b0429084-cd9c-45f5-8134-710979e3df0e,B ulkID:23041915495126IH8NNF,BulkQuantity:0,Recheck:0,SF:38|29|28|17|19|48,T C:nil,Content:0,EDM:-3,IP:nil,URL:0,File:nil,Bulk:nil,QS:nil,BEC:nil,COL:0 ,OSI:0,OSA:0,AV:0 X-CID-BVR: 0 X-CID-BAS: 0,_,0,_ X-UUID: c34bfc68de8611eda9a90f0bb45854f4-20230419 Received: from mtkmbs10n1.mediatek.inc [(172.21.101.34)] by mailgw01.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 668331487; Wed, 19 Apr 2023 15:49:50 +0800 Received: from mtkmbs13n2.mediatek.inc (172.21.101.108) 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.25; Wed, 19 Apr 2023 15:49:48 +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.25 via Frontend Transport; Wed, 19 Apr 2023 15:49:48 +0800 From: To: Daniel Lezcano , Thomas Gleixner , Matthias Brugger , AngeloGioacchino Del Regno , "Maciej W . Rozycki" , John Stultz CC: , , , , , Chun-Hung Wu , , , Subject: [PATCH linux-next v3 4/4] clocksource/drivers/timer-mediatek: Make timer-mediatek become loadable module Date: Wed, 19 Apr 2023 15:49:08 +0800 Message-ID: <20230419074910.10809-5-walter.chang@mediatek.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20230419074910.10809-1-walter.chang@mediatek.com> References: <20230419074910.10809-1-walter.chang@mediatek.com> MIME-Version: 1.0 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,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?1763590438538232829?= X-GMAIL-MSGID: =?utf-8?q?1763590438538232829?= From: Chun-Hung Wu Make the timer-mediatek driver which can register an always-on timer as tick_broadcast_device on MediaTek SoCs become loadable module in GKI. Tested-by: Walter Chang Signed-off-by: Chun-Hung Wu --- drivers/clocksource/Kconfig | 2 +- drivers/clocksource/timer-mediatek.c | 39 ++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+), 1 deletion(-) diff --git a/drivers/clocksource/Kconfig b/drivers/clocksource/Kconfig index 526382dc7482..a7413ad7b6ad 100644 --- a/drivers/clocksource/Kconfig +++ b/drivers/clocksource/Kconfig @@ -472,7 +472,7 @@ config SYS_SUPPORTS_SH_CMT bool config MTK_TIMER - bool "Mediatek timer driver" if COMPILE_TEST + tristate "Mediatek timer driver" depends on HAS_IOMEM select TIMER_OF select CLKSRC_MMIO diff --git a/drivers/clocksource/timer-mediatek.c b/drivers/clocksource/timer-mediatek.c index 7bcb4a3f26fb..3448848682c0 100644 --- a/drivers/clocksource/timer-mediatek.c +++ b/drivers/clocksource/timer-mediatek.c @@ -13,6 +13,9 @@ #include #include #include +#include +#include +#include #include #include #include "timer-of.h" @@ -337,5 +340,41 @@ static int __init mtk_gpt_init(struct device_node *node) return 0; } + +#ifdef MODULE +static int mtk_timer_probe(struct platform_device *pdev) +{ + int (*timer_init)(struct device_node *node); + struct device_node *np = pdev->dev.of_node; + + timer_init = of_device_get_match_data(&pdev->dev); + return timer_init(np); +} + +static const struct of_device_id mtk_timer_match_table[] = { + { + .compatible = "mediatek,mt6577-timer", + .data = mtk_gpt_init, + }, + { + .compatible = "mediatek,mt6765-timer", + .data = mtk_syst_init, + }, + {} +}; + +static struct platform_driver mtk_timer_driver = { + .probe = mtk_timer_probe, + .driver = { + .name = "mtk-timer", + .of_match_table = mtk_timer_match_table, + }, +}; +module_platform_driver(mtk_timer_driver); + +MODULE_DESCRIPTION("MediaTek Module Timer driver"); +MODULE_LICENSE("GPL v2"); +#else TIMER_OF_DECLARE(mtk_mt6577, "mediatek,mt6577-timer", mtk_gpt_init); TIMER_OF_DECLARE(mtk_mt6765, "mediatek,mt6765-timer", mtk_syst_init); +#endif