From patchwork Fri Feb 10 10:00:38 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: 55368 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp870936wrn; Fri, 10 Feb 2023 02:21:55 -0800 (PST) X-Google-Smtp-Source: AK7set9XuJ/lo9brS9YiGlzAIFUzp4IahUsV8v/s3eQiXq8VJpEoi5P9wnXf0NYByfaFfNby3aqp X-Received: by 2002:a17:907:3f14:b0:889:33ca:70c6 with SMTP id hq20-20020a1709073f1400b0088933ca70c6mr19160107ejc.2.1676024515304; Fri, 10 Feb 2023 02:21:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676024515; cv=none; d=google.com; s=arc-20160816; b=y7jl9IrwMrlYE57N60biMjKnOiEtqxSX9ahj4I/D+t8sO/ViGlFfOuD9oIEYpBGaLE 9LpUsLL9DTIgZ2adreSRSKqtvAHwMfvIwfG8T1JDXmzW0m11FrtGqzavVGIy3ZpZIx5P TM913yWfvbT8k0RkxhAqikr8FCwv0HwgtrekO0w4o5tifHJK8/NymCnPFTl2FkpCsleP Zx1B8XOP249s98SA/pRIx3fUrEUc77bVgHXX2TaQ/DmzqzmBMZZhyycC1D0D+Lzbmeee KUVlW1/o92PO+YOTmd8+sIThdfYD8KX0ew66RUaBVK6hUhapyTaw+Ubjz88actxKG5YF dfMQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:subject:cc:to:from :dkim-signature; bh=tEBK+dfkMrtcAvCvX7B7AQ5v86sSP8H5vx6IKOoo8Hs=; b=yL1ZNpeX+P3jnsDQkr8HiJL0hNrrsV/79qtTrXDUu+MI6+tR1baW2MgieYmkmenUls mMNbB++nCqrD8PngXrzDQ0iq0ombMuXhNE6wdW2V0wla9+FsMdrI/umPuMvjDxi1RbHk yOall+OwZLRXlDm+p7XWEIDL8sB7BoHFZWikuPnJvUB41xhWFbORqDgXtuVDVP2PhtzF jq9skvMx+oj2YiwC5IChibPazsjoIGTZWZiX/eYfUjrhplg+q0s42XvirvcIevbMi5nY +UxmClNF+/WbQnEjGL04Os0jAiFoUH25Hsn6E3jHPNdhWGZdKL35RVm+uVeh25ob6DvM wrBQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b=Hfv+BiSv; 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 iy6-20020a170907818600b0087329ff5934si4489072ejc.0.2023.02.10.02.21.32; Fri, 10 Feb 2023 02:21:55 -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=Hfv+BiSv; 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 S231389AbjBJKCu (ORCPT + 99 others); Fri, 10 Feb 2023 05:02:50 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54156 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231924AbjBJKCY (ORCPT ); Fri, 10 Feb 2023 05:02:24 -0500 Received: from mailgw01.mediatek.com (unknown [60.244.123.138]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EC6001CF77 for ; Fri, 10 Feb 2023 02:02:09 -0800 (PST) X-UUID: f8392898a92911eda06fc9ecc4dadd91-20230210 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Type:MIME-Version:Message-ID:Date:Subject:CC:To:From; bh=tEBK+dfkMrtcAvCvX7B7AQ5v86sSP8H5vx6IKOoo8Hs=; b=Hfv+BiSvQ/M8R0hP3zWaZ6z+/zed/2xh3QyKXfuaGa4dZKMV/mpCeSTZiCC2xz/jCJ13Sb18iiB7gxXr7DZ1s1SMh4eXRmdvzKicyE+sLnkUy4OJXdufFA5yBnNy9WQyYsrzi4JUOOQlgbwmB03PTBNqc7KgJfDq7XiGUMXnCq4=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.19,REQID:fcea576d-2f70-4d16-8ef4-fa44227623b9,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:7eb211f8-ff42-4fb0-b929-626456a83c14,B ulkID:nil,BulkQuantity:0,Recheck:0,SF:102,TC:nil,Content:0,EDM:-3,IP:nil,U RL:1,File:nil,Bulk:nil,QS:nil,BEC:nil,COL:0,OSI:0,OSA:0,AV:0 X-CID-BVR: 0 X-UUID: f8392898a92911eda06fc9ecc4dadd91-20230210 Received: from mtkmbs11n2.mediatek.inc [(172.21.101.187)] by mailgw01.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 937610339; Fri, 10 Feb 2023 18:02:04 +0800 Received: from mtkmbs13n1.mediatek.inc (172.21.101.193) by mtkmbs10n2.mediatek.inc (172.21.101.183) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.792.3; Fri, 10 Feb 2023 18:02:02 +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.792.15 via Frontend Transport; Fri, 10 Feb 2023 18:02:02 +0800 From: To: Daniel Lezcano , Thomas Gleixner , Matthias Brugger , AngeloGioacchino Del Regno , "Maciej W . Rozycki" , John Stultz , "Krzysztof Kozlowski" CC: , , , , Chun-Hung Wu , , , Subject: [PATCH] clocksource/drivers/timer-mediatek: Make timer-mediatek become loadable module Date: Fri, 10 Feb 2023 18:00:38 +0800 Message-ID: <20230210100058.19861-1-walter.chang@mediatek.com> X-Mailer: git-send-email 2.18.0 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,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?1757439082450825981?= X-GMAIL-MSGID: =?utf-8?q?1757439082062473898?= From: Chun-Hung Wu This patch makes the timer-mediatek driver which can register an always-on timer as tick_broadcast_device on MediaTek SoCs become loadable module in GKI. This patch depends on the previous patch. https://lore.kernel.org/lkml/20230208094813.20874-1-walter.chang@mediatek.com/T/#t Signed-off-by: Chun-Hung Wu --- drivers/clocksource/Kconfig | 2 +- drivers/clocksource/timer-mediatek.c | 43 ++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+), 1 deletion(-) diff --git a/drivers/clocksource/Kconfig b/drivers/clocksource/Kconfig index 4469e7f555e9..41345827055b 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 d5b29fd03ca2..806044ef391c 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" @@ -450,6 +453,46 @@ 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, + }, + { + .compatible = "mediatek,mt6795-systimer", + .data = mtk_cpux_init, + }, + {} +}; + +static struct platform_driver mtk_timer_driver = { + .probe = mtk_timer_probe, + .driver = { + .name = "mtk-timer", + .of_match_table = mtk_timer_match_table, + }, +}; +MODULE_DESCRIPTION("MEDIATEK Module Timer driver"); +MODULE_LICENSE("GPL v2"); + +module_platform_driver(mtk_timer_driver); +#else TIMER_OF_DECLARE(mtk_mt6577, "mediatek,mt6577-timer", mtk_gpt_init); TIMER_OF_DECLARE(mtk_mt6765, "mediatek,mt6765-timer", mtk_syst_init); TIMER_OF_DECLARE(mtk_mt6795, "mediatek,mt6795-systimer", mtk_cpux_init); +#endif