Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp1714454rwr; Thu, 20 Apr 2023 21:05:47 -0700 (PDT) X-Google-Smtp-Source: AKy350Yph8qxtfIQFsc9rrP6PRkOYs5zejX4ZG18JtAaNqY/zDjdOS7H1MwyeM8N98WWTzVEqiQI X-Received: by 2002:a05:6a00:138a:b0:63d:3a18:49ed with SMTP id t10-20020a056a00138a00b0063d3a1849edmr4979377pfg.15.1682049947336; Thu, 20 Apr 2023 21:05:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682049947; cv=none; d=google.com; s=arc-20160816; b=PrmS4b9omTl9aHK3Hw4l+f0qyS4+oCfqtgqJwDupWLaDhjST1bkdiTEbdfFD13yTGT q20At1V4jCOJ3QiNADnMKAFv4c0ZUROjh+RoQP/ZfCjV/jsplInIEYCFoO4UAjS2mAZf EEj9wYPxrNAM4idJSVaXIbRQ2BKf8TNvdd33h2/0WiocGp4aAcjW0XHmA0bZ49TKRAFs qYwwcMwb6klr+yJJuH+O1xhqjUk70bCFCm0FTqJ81g4ETkzU3KKxvXuPPmwcp8I/5UHr KXb++HV+IHrDYs3MSA3HvCsEjihYD/3+nI4JIxh8ihufLmD0p2pEenXiGBDcRx3UwNAv rw6w== 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=hW3Yiugr1dOuuygEOQHIaICWfvXy8XK0+7DIe1YW0hI=; b=w0uRVV8T8NLb7QN+VSjwmJhR0CyjOMkMeFc8/Cs5ri9+VroBkxei2uAKEyn1m2Ph+B GajacX3tbdbbNwZfE5dSJ6seQjL0JcZFPCktfnyuQFSBnUxLkAS4ZBjnByHv+WKOMyrK ooRV3lUApYUvu/TI8U974SgDAYhtwD+L9DfmwuqnxkiFd3ZhQgpGA/VqAS08FaKFMM/a R50WoQmhu40khpKwn6ZhhXtxHqRvAItioj4KzSZaLF3NRp8flzxLWiu9HITImaf3JPmr 2jz2H6UmpAbr0N/BjzFQV5ZD5lqT7M6teW92Zx+rxlT6dYsUSRXLfBEifX90IgkmKut/ ffKA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b=RCHViPe0; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d1-20020a621d01000000b0062794514e85si3242779pfd.376.2023.04.20.21.05.32; Thu, 20 Apr 2023 21:05:47 -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=RCHViPe0; 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 S233909AbjDUDsT (ORCPT + 99 others); Thu, 20 Apr 2023 23:48:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45764 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233725AbjDUDsH (ORCPT ); Thu, 20 Apr 2023 23:48:07 -0400 Received: from mailgw02.mediatek.com (unknown [210.61.82.184]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 87E4F524B for ; Thu, 20 Apr 2023 20:48:00 -0700 (PDT) X-UUID: 4c1a34eedff711edb6b9f13eb10bd0fe-20230421 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=hW3Yiugr1dOuuygEOQHIaICWfvXy8XK0+7DIe1YW0hI=; b=RCHViPe0DAhNC5dSYdiCzHZn9kafdbxwfpUubyT8YnE0oF48qifxIYwAYggTUudo3ZRPHlGe3Z5DIBV1BsP4itrTeQlQWYTsUteeI+mGZTt0Ssh6Cm9/1SotREDcujq5+Pdw8Gx72O7qWRe8xJC0rHikLKYZqWbAOhPafH7qGRk=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.22,REQID:0c772ebf-4f46-4173-8ab2-43c6b5613f6b,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:120426c,CLOUDID:6399c684-cd9c-45f5-8134-710979e3df0e,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 X-CID-BAS: 0,_,0,_ X-UUID: 4c1a34eedff711edb6b9f13eb10bd0fe-20230421 Received: from mtkmbs13n2.mediatek.inc [(172.21.101.108)] by mailgw02.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 479279796; Fri, 21 Apr 2023 11:47:54 +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; Fri, 21 Apr 2023 11:47:53 +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; Fri, 21 Apr 2023 11:47:53 +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 v4 4/4] clocksource/drivers/timer-mediatek: Make timer-mediatek become loadable module Date: Fri, 21 Apr 2023 11:46:49 +0800 Message-ID: <20230421034649.15247-5-walter.chang@mediatek.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20230421034649.15247-1-walter.chang@mediatek.com> References: <20230421034649.15247-1-walter.chang@mediatek.com> MIME-Version: 1.0 Content-Type: text/plain 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 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. Signed-off-by: Chun-Hung Wu Signed-off-by: Walter Chang Tested-by: Walter Chang --- drivers/clocksource/Kconfig | 2 +- drivers/clocksource/timer-mediatek.c | 33 ++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/drivers/clocksource/Kconfig b/drivers/clocksource/Kconfig index 526382dc7482..62103c0807f7 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..afeacb509481 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,35 @@ static int __init mtk_gpt_init(struct device_node *node) return 0; } + +#ifndef MODULE TIMER_OF_DECLARE(mtk_mt6577, "mediatek,mt6577-timer", mtk_gpt_init); TIMER_OF_DECLARE(mtk_mt6765, "mediatek,mt6765-timer", mtk_syst_init); +#else +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 }, + { /* sentinel */ } +}; + +static struct platform_driver mtk_timer_driver = { + .probe = mtk_timer_probe, + .driver = { + .name = "mediatek-timer", + .of_match_table = mtk_timer_match_table, + }, +}; +module_platform_driver(mtk_timer_driver); + +MODULE_DESCRIPTION("MediaTek Timer driver"); +MODULE_LICENSE("GPL v2"); +#endif -- 2.18.0