From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 529A3C7115B for ; Fri, 20 Jun 2025 18:31:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type:Cc:To:From: Subject:Message-ID:References:Mime-Version:In-Reply-To:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=gIL6fhkHdPNft8maVBpSOO544g+cE+WjCmwBaVe/EH4=; b=c5oTZw0CUYinWYwiX9zxa1Z0Sj p6G9BWrMHusqhb7PHxzy7fpDxfBkTrG4ofJUYiQi8nnse9TBUwCPJSzUFGA2RLyulVC5rG8QPS3K5 fWniXTO5Z7ar5AwPskszImwIxRh61gpeyLGzIqHvh1CLV7GY51ahi3WNo8ryGH3nmm92kHmahol0g xWhfhgEmhFLoQMtlrAh79RzwoxckPo/Jbx0S6k4Ahe5IzW6YTYhkOWYUuOyEVeZ86WXdj5j8Foy+B qKx28f/BWahYR/+vB4ZH9HcOxiHaLVYo7VYRvfLcgGe1x8D5xMEiyuWJ4nN41hnNitrVPV4XGIsKh Ppmx1u9g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98.2 #2 (Red Hat Linux)) id 1uSgWJ-0000000GMqd-3S5j; Fri, 20 Jun 2025 18:31:23 +0000 Received: from mail-pf1-x449.google.com ([2607:f8b0:4864:20::449]) by bombadil.infradead.org with esmtps (Exim 4.98.2 #2 (Red Hat Linux)) id 1uSgJF-0000000GLNI-1PGT for linux-arm-kernel@lists.infradead.org; Fri, 20 Jun 2025 18:17:54 +0000 Received: by mail-pf1-x449.google.com with SMTP id d2e1a72fcca58-7489ac848f3so3182180b3a.1 for ; Fri, 20 Jun 2025 11:17:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1750443472; x=1751048272; darn=lists.infradead.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=gIL6fhkHdPNft8maVBpSOO544g+cE+WjCmwBaVe/EH4=; b=GboRhULncYp75V9+1NkIGEZX3wJn4J7kGCX3ayi8OtvcBHIGctLx/xarNn3JmzsvDD t5ndg8g5GEsu2xvQPaX3pU3LGLWiDpuW7aYEYAQnJJ1VUBA9QsPrE6Woo4s25yOetKHt 6x92m24J1ShO1N96R2Zy/EWePrjJGwCp+EqgpUujgLKRnWfVhgbArYhEEcA7RRTrvsrG Ifu5+8N6K0t8OLRug4HoIOtkZ/PRdNPpKT73OChUd3plDuZzc+6cGcuJ4Y9bDRxcBpL0 T8QhsKlNJ3QhMDEeUmQJbfMZ5OIFBZ3iSMkhtYd2vEC0pVQ4eJuiFTIrwVLo27PtaUmx jCOQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1750443472; x=1751048272; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=gIL6fhkHdPNft8maVBpSOO544g+cE+WjCmwBaVe/EH4=; b=NU26crijdTNeqPVwbHRvqdLC1pr159dYndRlbumF7f6gE8DOtnVlkO/snddxX7tiHE Y2XBFZ4VHh9H9ndnEYXKflWJKfFSUcI35sXor67yc5GG0+k6ti5Qbh9pKRZqjILoCdVz IJnD7Jyq3gT/ygyI4HYllH8VOP/gVi8ScSPtxlDOL5KrEIMef6Q8kt7hzL+5W7/ZPvt1 kEU65YPpaDZY2Ppx+VkuQF0k11CiOc3iv7Dzqj2XNjm1M5F1bQGeWdkJvSD28j+2Lhvh yUYsCP4Og1mqKu0hze9XGR5FmY+oHkMx2fv2GLxHjCEXtHrLH1AA0jNJic7FHNDZGmay 3RWw== X-Forwarded-Encrypted: i=1; AJvYcCW+7Jys4kW1viDeGASC7GFXZu2Oxp3wrI85HyJxx4y3OKBP07ANl5/aTniXE7i67bDlMFAM+MKv2gu5WIHL0Dyi@lists.infradead.org X-Gm-Message-State: AOJu0YyOGXBET9A631VtcLs0oV26LMsc2TPQTnhYvy4lH3TRBNxy5D4H s41T/v6gTenMfFyBbPrrn5YLa9ouElatG2vGc+jgOoVLveUifCsrDxx/w2j0ydZ042JfeAsm/73 XeCpXQBFdVUKTlNu6hdgKPc1UDy5CUw== X-Google-Smtp-Source: AGHT+IHhcpS8jQBHaCeQUGg91BpHtXl20Xrh3qifc5fqLmdTGkugLkpf6jc5U6PsrNzkrlwp5dWtop0DbjdaRfbq1xg= X-Received: from pfwy15.prod.google.com ([2002:a05:6a00:1c8f:b0:739:8cd6:c16c]) (user=willmcvicker job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6a20:b40b:b0:215:da29:149f with SMTP id adf61e73a8af0-22026e95593mr6335474637.25.1750443471998; Fri, 20 Jun 2025 11:17:51 -0700 (PDT) Date: Fri, 20 Jun 2025 11:17:08 -0700 In-Reply-To: <20250620181719.1399856-1-willmcvicker@google.com> Mime-Version: 1.0 References: <20250620181719.1399856-1-willmcvicker@google.com> X-Mailer: git-send-email 2.50.0.rc2.761.g2dc52ea45b-goog Message-ID: <20250620181719.1399856-6-willmcvicker@google.com> Subject: [PATCH v4 5/6] clocksource/drivers/exynos_mct: Add module support From: Will McVicker To: Catalin Marinas , Will Deacon , Daniel Lezcano , Thomas Gleixner , Krzysztof Kozlowski , Alim Akhtar , Rob Herring , Saravana Kannan Cc: Will McVicker , Donghoon Yu , Hosung Kim , kernel-team@android.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, John Stultz , Youngmin Nam , Peter Griffin , Tudor Ambarus , "=?UTF-8?q?Andr=C3=A9=20Draszik?=" , Conor Dooley , linux-samsung-soc@vger.kernel.org, devicetree@vger.kernel.org Content-Type: text/plain; charset="UTF-8" X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250620_111753_367729_1B0D454E X-CRM114-Status: GOOD ( 22.56 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Donghoon Yu On Arm64 platforms the Exynos MCT driver can be built as a module. On boot (and even after boot) the arch_timer is used as the clocksource and tick timer. Once the MCT driver is loaded, it can be used as the wakeup source for the arch_timer. Signed-off-by: Donghoon Yu Signed-off-by: Youngmin Nam [original commit from https://android.googlesource.com/kernel/gs/+/8a52a8288ec7d88ff78f0b37480dbb0e9c65bbfd] Reviewed-by: Youngmin Nam Tested-by: Youngmin Nam Signed-off-by: Will McVicker --- drivers/clocksource/Kconfig | 3 +- drivers/clocksource/exynos_mct.c | 51 ++++++++++++++++++++++++++------ 2 files changed, 44 insertions(+), 10 deletions(-) diff --git a/drivers/clocksource/Kconfig b/drivers/clocksource/Kconfig index 645f517a1ac2..d657c8ddc96b 100644 --- a/drivers/clocksource/Kconfig +++ b/drivers/clocksource/Kconfig @@ -451,7 +451,8 @@ config ATMEL_TCB_CLKSRC Support for Timer Counter Blocks on Atmel SoCs. config CLKSRC_EXYNOS_MCT - bool "Exynos multi core timer driver" if COMPILE_TEST + tristate "Exynos multi core timer driver" if ARM64 + default y if ARCH_EXYNOS || COMPILE_TEST depends on ARM || ARM64 depends on ARCH_ARTPEC || ARCH_EXYNOS || COMPILE_TEST help diff --git a/drivers/clocksource/exynos_mct.c b/drivers/clocksource/exynos_mct.c index 62febeb4e1de..5075ebe052a7 100644 --- a/drivers/clocksource/exynos_mct.c +++ b/drivers/clocksource/exynos_mct.c @@ -15,9 +15,11 @@ #include #include #include +#include #include #include #include +#include #include #include @@ -217,6 +219,7 @@ static struct clocksource mct_frc = { .mask = CLOCKSOURCE_MASK(32), .flags = CLOCK_SOURCE_IS_CONTINUOUS, .resume = exynos4_frc_resume, + .owner = THIS_MODULE, }; /* @@ -241,7 +244,7 @@ static cycles_t exynos4_read_current_timer(void) } #endif -static int __init exynos4_clocksource_init(bool frc_shared) +static int exynos4_clocksource_init(bool frc_shared) { /* * When the frc is shared, the main processor should have already @@ -336,6 +339,7 @@ static struct clock_event_device mct_comp_device = { .set_state_oneshot = mct_set_state_shutdown, .set_state_oneshot_stopped = mct_set_state_shutdown, .tick_resume = mct_set_state_shutdown, + .owner = THIS_MODULE, }; static irqreturn_t exynos4_mct_comp_isr(int irq, void *dev_id) @@ -476,6 +480,7 @@ static int exynos4_mct_starting_cpu(unsigned int cpu) evt->features = CLOCK_EVT_FEAT_PERIODIC | CLOCK_EVT_FEAT_ONESHOT | CLOCK_EVT_FEAT_PERCPU; evt->rating = MCT_CLKEVENTS_RATING; + evt->owner = THIS_MODULE; exynos4_mct_write(TICK_BASE_CNT, mevt->base + MCT_L_TCNTB_OFFSET); @@ -511,7 +516,7 @@ static int exynos4_mct_dying_cpu(unsigned int cpu) return 0; } -static int __init exynos4_timer_resources(struct device_node *np) +static int exynos4_timer_resources(struct device_node *np) { struct clk *mct_clk, *tick_clk; @@ -539,7 +544,7 @@ static int __init exynos4_timer_resources(struct device_node *np) * @local_idx: array mapping CPU numbers to local timer indices * @nr_local: size of @local_idx array */ -static int __init exynos4_timer_interrupts(struct device_node *np, +static int exynos4_timer_interrupts(struct device_node *np, unsigned int int_type, const u32 *local_idx, size_t nr_local) @@ -652,7 +657,7 @@ static int __init exynos4_timer_interrupts(struct device_node *np, return err; } -static int __init mct_init_dt(struct device_node *np, unsigned int int_type) +static int mct_init_dt(struct device_node *np, unsigned int int_type) { bool frc_shared = of_property_read_bool(np, "samsung,frc-shared"); u32 local_idx[MCT_NR_LOCAL] = {0}; @@ -700,15 +705,43 @@ static int __init mct_init_dt(struct device_node *np, unsigned int int_type) return exynos4_clockevent_init(); } - -static int __init mct_init_spi(struct device_node *np) +static int mct_init_spi(struct device_node *np) { return mct_init_dt(np, MCT_INT_SPI); } -static int __init mct_init_ppi(struct device_node *np) +static int mct_init_ppi(struct device_node *np) { return mct_init_dt(np, MCT_INT_PPI); } -TIMER_OF_DECLARE(exynos4210, "samsung,exynos4210-mct", mct_init_spi); -TIMER_OF_DECLARE(exynos4412, "samsung,exynos4412-mct", mct_init_ppi); + +static int exynos4_mct_probe(struct platform_device *pdev) +{ + struct device *dev = &pdev->dev; + int (*mct_init)(struct device_node *np); + + mct_init = of_device_get_match_data(dev); + if (!mct_init) + return -EINVAL; + + return mct_init(dev->of_node); +} + +static const struct of_device_id exynos4_mct_match_table[] = { + { .compatible = "samsung,exynos4210-mct", .data = &mct_init_spi, }, + { .compatible = "samsung,exynos4412-mct", .data = &mct_init_ppi, }, + {} +}; +MODULE_DEVICE_TABLE(of, exynos4_mct_match_table); + +static struct platform_driver exynos4_mct_driver = { + .probe = exynos4_mct_probe, + .driver = { + .name = "exynos-mct", + .of_match_table = exynos4_mct_match_table, + }, +}; +module_platform_driver(exynos4_mct_driver); + +MODULE_DESCRIPTION("Exynos Multi Core Timer Driver"); +MODULE_LICENSE("GPL"); -- 2.50.0.rc2.761.g2dc52ea45b-goog