From patchwork Wed May 17 02:25:48 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: 95010 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp839758vqo; Tue, 16 May 2023 19:56:56 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4pcIyeULPHppiFO2708BXV9p57VNQ5x/UiS61+n0AsEbbiFlMjMP6FFCI4KfZTX8o7rdec X-Received: by 2002:a05:6a20:5481:b0:101:7ccd:e195 with SMTP id i1-20020a056a20548100b001017ccde195mr38449690pzk.8.1684292215979; Tue, 16 May 2023 19:56:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684292215; cv=none; d=google.com; s=arc-20160816; b=MizRpebuLM+bcMkhYwZbG0zyZzb9HwfH/yFlDpfMBLzNDdHsZv8wfLMe2IP48ex2LI UcmJGfN7OR7NAFtlZWw+KxBuCvsir5ifU1A8hI8GcAFP8h4wM/7v+CutKKwNRmxuUFTb NNnfL0dlcsEBoB35C0+yBg7SO3cWlaZg/QKwz0q7N0GX4F2RmMYLeBpKKBTcGni5YM3w sUX/mRIpI87D69dl0MGnd9hRwM6+p5pEuCjs5kjezBrk+zm7Ci5NbRd64dttKGcvQMlo 4ehbdOoXhG5tOMmg23sdGL/mWOSBOO3Cwn+hfThF1yDJTVJbBeGBqVg156jrF+s2Y9Y3 xgvw== 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=nYcNa1U2hxMXAsaheDvMwQHpaoPx+7Gfb4BUUDZeS7c=; b=rRyXRJV9qXQtKv07Eb75xP+BVHBZnQ2aAbBREq94WHN0tKZdxCvRIO7h62XNydrIFq vkI0HpHm8mApkJKKrBPMEaAXibZ2eAuRbJBNOrkeunjOwil1D8+M2momjD4bYXaEyo/5 KeAFEKTUqops2ycSNLTHkz8Gv8/Vvf/8YR50/sRff5+PAgcqoB4BJW1S99vQxTu5gZDS wAgCCN5GtDN+zK45uGjCqRqnk/cOEzraOYePKt8avsgM6A2uJxnq0eVPkYEBwLC6g83g bYLn4NPtla8LBiWTVMKPI0yTuNRNqJAj5AYeYhkUoRN14RqqDjXJoydAKwflBbJvLvv2 U9Nw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b=buUUs8YA; 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 l69-20020a633e48000000b0053045acfebbsi18962132pga.48.2023.05.16.19.56.44; Tue, 16 May 2023 19:56:55 -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=buUUs8YA; 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 S232045AbjEQC1v (ORCPT + 99 others); Tue, 16 May 2023 22:27:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50800 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231653AbjEQC1s (ORCPT ); Tue, 16 May 2023 22:27:48 -0400 Received: from mailgw02.mediatek.com (unknown [210.61.82.184]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8ADD8268A for ; Tue, 16 May 2023 19:27:20 -0700 (PDT) X-UUID: 404bf158f45a11edb20a276fd37b9834-20230517 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=nYcNa1U2hxMXAsaheDvMwQHpaoPx+7Gfb4BUUDZeS7c=; b=buUUs8YAV65neXQs4VTk7q1d5RjgDEE/q9cykVv4Wbj08iJuiHL2FpEG4DvWmTRqiZxS00mzjYMvZKJd3jXVNtGFRRLjQVvMCT6A1xmkX7Jsatj25tGh3GqXj0TohSeUMcqwPFnNTpO7R6pkBEZZ49I9FtDbP1LNCiREk6Fd1Is=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.25,REQID:c52d6a5e-cf6a-4bd1-a663-6ec42fd28490,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:d5b0ae3,CLOUDID:1fc10c6c-2f20-4998-991c-3b78627e4938,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: 404bf158f45a11edb20a276fd37b9834-20230517 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 1405807776; Wed, 17 May 2023 10:26:38 +0800 Received: from mtkmbs13n2.mediatek.inc (172.21.101.194) 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.1118.26; Wed, 17 May 2023 10:26:36 +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.26 via Frontend Transport; Wed, 17 May 2023 10:26:36 +0800 From: To: Daniel Lezcano , Thomas Gleixner , Matthias Brugger , AngeloGioacchino Del Regno , "Maciej W . Rozycki" , John Stultz CC: , , , , , Chun-Hung Wu , , , Subject: [PATCH v5 4/4] clocksource/drivers/timer-mediatek: Make timer-mediatek become loadable module Date: Wed, 17 May 2023 10:25:48 +0800 Message-ID: <20230517022557.24388-5-walter.chang@mediatek.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20230517022557.24388-1-walter.chang@mediatek.com> References: <20230517022557.24388-1-walter.chang@mediatek.com> MIME-Version: 1.0 X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_MSPIKE_H2,RDNS_NONE, SPF_HELO_PASS,SPF_PASS,T_SCC_BODY_TEXT_LINE,UNPARSEABLE_RELAY, URIBL_BLOCKED autolearn=no 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?1766108395003947605?= X-GMAIL-MSGID: =?utf-8?q?1766108395003947605?= 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 Reviewed-by: AngeloGioacchino Del Regno Reviewed-by: Alexandre Mergnat --- 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