From patchwork Tue Nov 29 03:09:23 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yinbo Zhu X-Patchwork-Id: 27055 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp102352wrr; Mon, 28 Nov 2022 19:23:30 -0800 (PST) X-Google-Smtp-Source: AA0mqf4IntsHg9e5fHslCDZkdYW4MJg1KQrSr72UbSpJQOZzXIlkRpPdWnlHBZSXwwQkDG1+R0i+ X-Received: by 2002:a17:906:f896:b0:7bb:cdd8:94e7 with SMTP id lg22-20020a170906f89600b007bbcdd894e7mr18905784ejb.369.1669692210231; Mon, 28 Nov 2022 19:23:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669692210; cv=none; d=google.com; s=arc-20160816; b=PLcznryQOkEW0Z3Hkt+JZgtFIaBqYt6JYfwPzvNvUGre+PwzDPRXe22+FlyyRVWc9M viSj+L5N56rH4NBgOVSpH3Q8iZ6ugynBW2z3eapSI+GiI1+S24a5eR1y3fdvnaMcg38V TE2JhjPfQDDYN/FnBWc16prLErYYslrKo1A/t1KSRVKtT1GimMM5jC6SRuYv/4l9UETV sh1j6fiJq8fibXNedTuzaJw3qZJTb5eMuRTPVsxT12AOhHW8YrJ8MbZcW08pYJgmyaol fY/OqkaCCpefAYk218Bz1475CETFdg1ZFOgTqWAL2t15tbi2dvjpT4Zt+2GwQI0/Z8Lm GB2g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:to:from; bh=kQkxL2yzoiPszDAQtvURcHmgCsJVUfXsgK6Z9YPR09E=; b=vB7wdwQT+ZPA3gBUyEZcUfFw8yL7m7Fanc7xNqzDYKDCkhbpZbybBu1c2vhuL6IIxM dRxZTIYOO/RuG6ApsEqMdLktRgXLt5IIVGbrNfHQ2Q5wOlJEIDkwKJQM4BN/cghpxA0o sPsS+MITGltqXCtoZ20eRCi6bQtnpD+CD92i4f9hPwF6ya5oLe4NIp/+2vbebUyB+cWE AHeeiNHVM5rAR+swv+Cuauxc7SkPlV9D5VFck0h9vKwfhVVI/NdmzYmrz5G3mQ/96CLh TOpNEoUhnEm5nlb6dp1Ev57wBssPHPw8groPGVmCnMxNujD6IS6ze1QLNQoLUr1dGJNP EO/A== ARC-Authentication-Results: i=1; mx.google.com; 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id xh13-20020a170906da8d00b007b8b7da6490si11784363ejb.660.2022.11.28.19.23.07; Mon, 28 Nov 2022 19:23:30 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235420AbiK2DJh (ORCPT + 99 others); Mon, 28 Nov 2022 22:09:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36910 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235176AbiK2DJg (ORCPT ); Mon, 28 Nov 2022 22:09:36 -0500 Received: from loongson.cn (mail.loongson.cn [114.242.206.163]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 5C0712D765; Mon, 28 Nov 2022 19:09:34 -0800 (PST) Received: from loongson.cn (unknown [10.180.13.64]) by gateway (Coremail) with SMTP id _____8Axz+vtd4VjROYBAA--.4498S3; Tue, 29 Nov 2022 11:09:33 +0800 (CST) Received: from localhost.localdomain (unknown [10.180.13.64]) by localhost.localdomain (Coremail) with SMTP id AQAAf8CxZ1fmd4VjE+QdAA--.57759S2; Tue, 29 Nov 2022 11:09:30 +0800 (CST) From: Yinbo Zhu To: Daniel Lezcano , Thomas Gleixner , Rob Herring , Krzysztof Kozlowski , Huacai Chen , WANG Xuerui , Jiaxun Yang , Jianmin Lv , Yun Liu , Yang Li , linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, loongarch@lists.linux.dev, Yinbo Zhu Subject: [PATCH v11 1/3] clocksource: loongson2_hpet: add hpet driver support Date: Tue, 29 Nov 2022 11:09:23 +0800 Message-Id: <20221129030925.14074-1-zhuyinbo@loongson.cn> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 X-CM-TRANSID: AQAAf8CxZ1fmd4VjE+QdAA--.57759S2 X-CM-SenderInfo: 52kx5xhqerqz5rrqw2lrqou0/ X-Coremail-Antispam: 1Uk129KBjvAXoWfJFyxZFWrGF4rZF43uF4xXrb_yoW8JrWruo WfCFZIvr1rXryjvFWvgw13JFyaqFykGFWYyrs8Zwn5JFn8Kr1UWry7G3sxAa47AF1rCFyv v39aqan3CF43t3Z3n29KB7ZKAUJUUUUx529EdanIXcx71UUUUU7KY7ZEXasCq-sGcSsGvf J3Ic02F40EFcxC0VAKzVAqx4xG6I80ebIjqfuFe4nvWSU5nxnvy29KBjDU0xBIdaVrnRJU UUBF1xkIjI8I6I8E6xAIw20EY4v20xvaj40_Wr0E3s1l1IIY67AEw4v_JF0_JFyl8cAvFV AK0II2c7xJM28CjxkF64kEwVA0rcxSw2x7M28EF7xvwVC0I7IYx2IY67AKxVW5JVW7JwA2 z4x0Y4vE2Ix0cI8IcVCY1x0267AKxVW8JVWxJwA2z4x0Y4vEx4A2jsIE14v26r4UJVWxJr 1l84ACjcxK6I8E87Iv6xkF7I0E14v26r4UJVWxJr1ln4kS14v26r126r1DM2AIxVAIcxkE cVAq07x20xvEncxIr21l57IF6xkI12xvs2x26I8E6xACxx1l5I8CrVACY4xI64kE6c02F4 0Ex7xfMcIj6xIIjxv20xvE14v26r1q6rW5McIj6I8E87Iv67AKxVW8JVWxJwAm72CE4IkC 6x0Yz7v_Jr0_Gr1lF7xvr2IYc2Ij64vIr41lc7CjxVAaw2AFwI0_JF0_Jw1l42xK82IYc2 Ij64vIr41l42xK82IY6x8ErcxFaVAv8VWrMxC20s026xCaFVCjc4AY6r1j6r4UMxCIbckI 1I0E14v26r126r1DMI8I3I0E5I8CrVAFwI0_Jr0_Jr4lx2IqxVCjr7xvwVAFwI0_JrI_Jr Wlx4CE17CEb7AF67AKxVWUtVW8ZwCIc40Y0x0EwIxGrwCI42IY6xIIjxv20xvE14v26r4j 6ryUMIIF0xvE2Ix0cI8IcVCY1x0267AKxVW8JVWxJwCI42IY6xAIw20EY4v20xvaj40_Jr 0_JF4lIxAIcVC2z280aVAFwI0_Cr0_Gr1UMIIF0xvEx4A2jsIEc7CjxVAFwI0_Gr0_Gr1U YxBIdaVFxhVjvjDU0xZFpf9x07jeGQDUUUUU= X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_PASS, SPF_PASS 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?1750799179282153899?= X-GMAIL-MSGID: =?utf-8?q?1750799179282153899?= HPET (High Precision Event Timer) defines a new set of timers, which are used by the operating system to schedule threads, interrupt the kernel and interrupt the multimedia timer server. The operating system can assign different timers to different applications. By configuration, each timer can generate interrupt independently. The Loongson-2 HPET module includes a main count and three comparators, all of which are 32 bits wide. Among the three comparators, only one comparator supports periodic interrupt, all three comparators support non periodic interrupts. Signed-off-by: Yinbo Zhu --- Change in v11: 1. Detach timer_probe to another patch. 2. Remove the #ifdef in timer_probe context. Change in v10: 1. Replace "goto err" with "return -ENOMEM" if of_iomap fail. 2. This patch need rely on clock patch, which patchwork link was "https://patchwork.kernel.org/project/linux-clk/list/?series=691497". Change in v9: 1. Replace string "register" with "request" in hpet_request_irq. 2. Move the varible "ret" to the begining position in loongson2_hpet_init and initialized it. 3. Adjust if judgement in clk_get_rate context, there was less less indentation in the normal path. 4. This patch need rely on clock patch, which patchwork link was "https://patchwork.kernel.org/project/linux-clk/list/?series=691497". Change in v8: 1. Add all history change log information. Change in v7: 1. Replace setup_irq with request_irq. Change in v6: 1. Move comma to the end of the previous line if that comma at the beginning of the line. Change in v5: 1. Replace string loongson2 with Loongson-2 in commit message and Kconfig file. 2. Replace string LOONGSON2 with LOONGSON-2 in MAINTAINERS. 3. Make include asm headers after all linux headers. 4. Add blank place before comma if comma when the comma is at the beginning of the line. Change in v4: 1. Use common clock framework ops to gain apb clock. 2. This patch need rely on clock patch, which patchwork link was "https://patchwork.kernel.org/project/linux-clk/list/?series=688892". Change in v3: 1. NO change, but other patch in this series of patches set has changes Change in v2: 1. NO change, but other patch in this series of patches set has changes MAINTAINERS | 6 + drivers/clocksource/Kconfig | 9 + drivers/clocksource/Makefile | 1 + drivers/clocksource/loongson2_hpet.c | 334 +++++++++++++++++++++++++++ 4 files changed, 350 insertions(+) create mode 100644 drivers/clocksource/loongson2_hpet.c diff --git a/MAINTAINERS b/MAINTAINERS index 0cdd1437c093..5d5967f55c36 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -12029,6 +12029,12 @@ F: Documentation/devicetree/bindings/clock/loongson,ls2k-clk.yaml F: drivers/clk/clk-loongson2.c F: include/dt-bindings/clock/loongson,ls2k-clk.h +LOONGSON-2 SOC SERIES HPET DRIVER +M: Yinbo Zhu +L: linux-kernel@vger.kernel.org +S: Maintained +F: drivers/clocksource/loongson2_hpet.c + LSILOGIC MPT FUSION DRIVERS (FC/SAS/SPI) M: Sathya Prakash M: Sreekanth Reddy diff --git a/drivers/clocksource/Kconfig b/drivers/clocksource/Kconfig index 4469e7f555e9..f114ee47e6f7 100644 --- a/drivers/clocksource/Kconfig +++ b/drivers/clocksource/Kconfig @@ -721,4 +721,13 @@ config GOLDFISH_TIMER help Support for the timer/counter of goldfish-rtc +config LOONGSON2_HPET + bool "Loongson-2 High Precision Event Timer (HPET)" + select TIMER_PROBE + select TIMER_OF + help + This option enables Loongson-2 High Precision Event Timer + (HPET) module driver. It supports the oneshot, the periodic + modes and high resolution. It is used as a clocksource and + a clockevent. endmenu diff --git a/drivers/clocksource/Makefile b/drivers/clocksource/Makefile index 64ab547de97b..1a3abb770f11 100644 --- a/drivers/clocksource/Makefile +++ b/drivers/clocksource/Makefile @@ -88,3 +88,4 @@ obj-$(CONFIG_MICROCHIP_PIT64B) += timer-microchip-pit64b.o obj-$(CONFIG_MSC313E_TIMER) += timer-msc313e.o obj-$(CONFIG_GOLDFISH_TIMER) += timer-goldfish.o obj-$(CONFIG_GXP_TIMER) += timer-gxp.o +obj-$(CONFIG_LOONGSON2_HPET) += loongson2_hpet.o diff --git a/drivers/clocksource/loongson2_hpet.c b/drivers/clocksource/loongson2_hpet.c new file mode 100644 index 000000000000..9b828f9728ca --- /dev/null +++ b/drivers/clocksource/loongson2_hpet.c @@ -0,0 +1,334 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Author: Yinbo Zhu + * Copyright (C) 2022-2023 Loongson Technology Corporation Limited + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/* HPET regs */ +#define HPET_CFG 0x010 +#define HPET_STATUS 0x020 +#define HPET_COUNTER 0x0f0 +#define HPET_T0_IRS 0x001 +#define HPET_T0_CFG 0x100 +#define HPET_T0_CMP 0x108 +#define HPET_CFG_ENABLE 0x001 +#define HPET_TN_LEVEL 0x0002 +#define HPET_TN_ENABLE 0x0004 +#define HPET_TN_PERIODIC 0x0008 +#define HPET_TN_SETVAL 0x0040 +#define HPET_TN_32BIT 0x0100 + +#define HPET_MIN_CYCLES 16 +#define HPET_MIN_PROG_DELTA (HPET_MIN_CYCLES * 12) +#define HPET_COMPARE_VAL ((hpet_freq + HZ / 2) / HZ) + +void __iomem *hpet_mmio_base; +unsigned int hpet_freq; +unsigned int hpet_t0_irq; +unsigned int hpet_irq_flags; +unsigned int hpet_t0_cfg; + +static DEFINE_SPINLOCK(hpet_lock); +DEFINE_PER_CPU(struct clock_event_device, hpet_clockevent_device); + +static int hpet_read(int offset) +{ + return readl(hpet_mmio_base + offset); +} + +static void hpet_write(int offset, int data) +{ + writel(data, hpet_mmio_base + offset); +} + +static void hpet_start_counter(void) +{ + unsigned int cfg = hpet_read(HPET_CFG); + + cfg |= HPET_CFG_ENABLE; + hpet_write(HPET_CFG, cfg); +} + +static void hpet_stop_counter(void) +{ + unsigned int cfg = hpet_read(HPET_CFG); + + cfg &= ~HPET_CFG_ENABLE; + hpet_write(HPET_CFG, cfg); +} + +static void hpet_reset_counter(void) +{ + hpet_write(HPET_COUNTER, 0); + hpet_write(HPET_COUNTER + 4, 0); +} + +static void hpet_restart_counter(void) +{ + hpet_stop_counter(); + hpet_reset_counter(); + hpet_start_counter(); +} + +static void hpet_enable_legacy_int(void) +{ + /* Do nothing on Loongson2 */ +} + +static int hpet_set_state_periodic(struct clock_event_device *evt) +{ + int cfg; + + spin_lock(&hpet_lock); + + pr_info("set clock event to periodic mode!\n"); + /* stop counter */ + hpet_stop_counter(); + hpet_reset_counter(); + hpet_write(HPET_T0_CMP, 0); + + /* enables the timer0 to generate a periodic interrupt */ + cfg = hpet_read(HPET_T0_CFG); + cfg &= ~HPET_TN_LEVEL; + cfg |= HPET_TN_ENABLE | HPET_TN_PERIODIC | HPET_TN_SETVAL | + HPET_TN_32BIT | hpet_irq_flags; + hpet_write(HPET_T0_CFG, cfg); + + /* set the comparator */ + hpet_write(HPET_T0_CMP, HPET_COMPARE_VAL); + udelay(1); + hpet_write(HPET_T0_CMP, HPET_COMPARE_VAL); + + /* start counter */ + hpet_start_counter(); + + spin_unlock(&hpet_lock); + return 0; +} + +static int hpet_set_state_shutdown(struct clock_event_device *evt) +{ + int cfg; + + spin_lock(&hpet_lock); + + cfg = hpet_read(HPET_T0_CFG); + cfg &= ~HPET_TN_ENABLE; + hpet_write(HPET_T0_CFG, cfg); + + spin_unlock(&hpet_lock); + return 0; +} + +static int hpet_set_state_oneshot(struct clock_event_device *evt) +{ + int cfg; + + spin_lock(&hpet_lock); + + pr_info("set clock event to one shot mode!\n"); + cfg = hpet_read(HPET_T0_CFG); + /* + * set timer0 type + * 1 : periodic interrupt + * 0 : non-periodic(oneshot) interrupt + */ + cfg &= ~HPET_TN_PERIODIC; + cfg |= HPET_TN_ENABLE | HPET_TN_32BIT | + hpet_irq_flags; + hpet_write(HPET_T0_CFG, cfg); + + /* start counter */ + hpet_start_counter(); + + spin_unlock(&hpet_lock); + return 0; +} + +static int hpet_tick_resume(struct clock_event_device *evt) +{ + spin_lock(&hpet_lock); + hpet_enable_legacy_int(); + spin_unlock(&hpet_lock); + + return 0; +} + +static int hpet_next_event(unsigned long delta, + struct clock_event_device *evt) +{ + u32 cnt; + s32 res; + + cnt = hpet_read(HPET_COUNTER); + cnt += (u32) delta; + hpet_write(HPET_T0_CMP, cnt); + + res = (s32)(cnt - hpet_read(HPET_COUNTER)); + + return res < HPET_MIN_CYCLES ? -ETIME : 0; +} + +static irqreturn_t hpet_irq_handler(int irq, void *data) +{ + int is_irq; + struct clock_event_device *cd; + unsigned int cpu = smp_processor_id(); + + is_irq = hpet_read(HPET_STATUS); + if (is_irq & HPET_T0_IRS) { + /* clear the TIMER0 irq status register */ + hpet_write(HPET_STATUS, HPET_T0_IRS); + cd = &per_cpu(hpet_clockevent_device, cpu); + cd->event_handler(cd); + return IRQ_HANDLED; + } + return IRQ_NONE; +} + +/* + * HPET address assignation and irq setting should be done in bios. + * But, sometimes bios don't do this, we just setup here directly. + */ +static void hpet_setup(void) +{ + hpet_enable_legacy_int(); +} + +static int hpet_request_irq(struct clock_event_device *cd) +{ + unsigned long flags = IRQD_NO_BALANCING | IRQF_TIMER; + + if (request_irq(cd->irq, hpet_irq_handler, flags, "hpet", NULL)) { + pr_err("Failed to request hpet interrupt\n"); + return -1; + } + + disable_irq(cd->irq); + irq_set_affinity(cd->irq, cd->cpumask); + enable_irq(cd->irq); + + return 0; +} + +static int __init loongson2_hpet_clockevent_init(void) +{ + unsigned int cpu = smp_processor_id(); + struct clock_event_device *cd; + + hpet_setup(); + + cd = &per_cpu(hpet_clockevent_device, cpu); + cd->name = "hpet"; + cd->rating = 300; + cd->features = CLOCK_EVT_FEAT_PERIODIC | CLOCK_EVT_FEAT_ONESHOT; + cd->set_state_shutdown = hpet_set_state_shutdown; + cd->set_state_periodic = hpet_set_state_periodic; + cd->set_state_oneshot = hpet_set_state_oneshot; + cd->tick_resume = hpet_tick_resume; + cd->set_next_event = hpet_next_event; + cd->irq = hpet_t0_irq; + cd->cpumask = cpumask_of(cpu); + clockevent_set_clock(cd, hpet_freq); + cd->max_delta_ns = clockevent_delta2ns(0x7fffffff, cd); + cd->max_delta_ticks = 0x7fffffff; + cd->min_delta_ns = clockevent_delta2ns(HPET_MIN_PROG_DELTA, cd); + cd->min_delta_ticks = HPET_MIN_PROG_DELTA; + + clockevents_register_device(cd); + if (hpet_request_irq(cd)) + return -1; + + pr_info("hpet clock event device register\n"); + + return 0; +} + +static u64 hpet_read_counter(struct clocksource *cs) +{ + return (u64)hpet_read(HPET_COUNTER); +} + +static void hpet_suspend(struct clocksource *cs) +{ + hpet_t0_cfg = hpet_read(HPET_T0_CFG); +} + +static void hpet_resume(struct clocksource *cs) +{ + hpet_write(HPET_T0_CFG, hpet_t0_cfg); + hpet_setup(); + hpet_restart_counter(); +} + +struct clocksource csrc_hpet = { + .name = "hpet", + .rating = 300, + .read = hpet_read_counter, + .mask = CLOCKSOURCE_MASK(32), + /* oneshot mode work normal with this flag */ + .flags = CLOCK_SOURCE_IS_CONTINUOUS, + .suspend = hpet_suspend, + .resume = hpet_resume, + .mult = 0, + .shift = 10, +}; + +static int __init loongson2_hpet_clocksource_init(void) +{ + csrc_hpet.mult = clocksource_hz2mult(hpet_freq, csrc_hpet.shift); + + /* start counter */ + hpet_start_counter(); + + return clocksource_register_hz(&csrc_hpet, hpet_freq); +} + +static int __init loongson2_hpet_init(struct device_node *np) +{ + struct clk *clk; + int ret = -EINVAL; + + hpet_mmio_base = of_iomap(np, 0); + if (!hpet_mmio_base) { + pr_err("hpet: unable to map loongson2 hpet registers\n"); + return -ENOMEM; + } + + hpet_t0_irq = irq_of_parse_and_map(np, 0); + if (hpet_t0_irq <= 0) { + pr_err("hpet: unable to get IRQ from DT, %d\n", hpet_t0_irq); + goto err; + } + + clk = of_clk_get(np, 0); + if (IS_ERR(clk)) + goto err; + + hpet_freq = clk_get_rate(clk); + clk_put(clk); + + hpet_irq_flags = HPET_TN_LEVEL; + + loongson2_hpet_clocksource_init(); + + loongson2_hpet_clockevent_init(); + + return 0; + +err: + iounmap(hpet_mmio_base); + return ret; +} + +TIMER_OF_DECLARE(loongson2_hpet, "loongson,ls2k-hpet", loongson2_hpet_init); From patchwork Tue Nov 29 03:09:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yinbo Zhu X-Patchwork-Id: 27056 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp102706wrr; Mon, 28 Nov 2022 19:24:31 -0800 (PST) X-Google-Smtp-Source: AA0mqf6yQzg1sKLUtgPiiZxhGFu22aLasuTbm3Dovp537Au71/EXSEGVMveXbK04xL66bSyIkYR5 X-Received: by 2002:a05:6402:548a:b0:468:e8e2:31c9 with SMTP id fg10-20020a056402548a00b00468e8e231c9mr24296676edb.310.1669692271528; Mon, 28 Nov 2022 19:24:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669692271; cv=none; d=google.com; s=arc-20160816; b=I8g3sCbVsuU/XDk6tUSGuzcyM9rkb0P7uanuVyBaKAuIGXUpH5gmg8NhMZ53HlLKjQ Yo1xCRfx/v1qqDlZriOnzR6hpZ7Ol2UsjTehKJV+iTXZIoGsWW1WB+O/17VuYFKod1/Q g3MKueQL1k63UPIvZP9seG6kIfd4GLXrUeP2mVsRyZe+YauFuZSRH5yQ7XG27+nXpS+B Uw8bha4Q21IF09QTdOIHNRNnRoQ/f1nZPizQDKT/H8KWghrdgkJ8PBwZ57syFEWRY2Id t9bxc+PaJN5XxcTzy7GELjsr/9uO9acmc8FE8ye4eYnGHbqxncTEVqEFbPdjjlpvbUyV UYBw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:to:from; bh=lIUTgyXtNy/te0g30chEKKSrnu7QwJu+YGfdkyi+qTA=; b=whKIwZsjZV8MR/lZxJJbz/tNv0c/KCADG2MUcEHg/4AlI3LBQxrkWNnEhXkKWicDVI brvO1bKlYYk1nQ9SlOC0Qe/R3wre3x+GkS2PGTJmJB3Ne88AFZ6Cgd81dKbsGs/+PD/t LirBhzgE2CKmPCZmNv/B8FTnRyCUivqg2ifCxLZUbqHV/cNUzqgo+H4qT8cQmcbMxZnj EIbDasQ/OdhLYbuf0Kc8RwrhPjwr43f24btBm3dM3gmG1Fo3XhUIsPr6SLfdrt0jS0pu 6bxat076j11PsxuBUWMFc+X9Tk/7TAwpTt8n0oumtE6ZNY1htizNK8KuU87nZ49Ppqsj 23ig== ARC-Authentication-Results: i=1; mx.google.com; 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id es25-20020a056402381900b0046b850c39eesi428477edb.347.2022.11.28.19.24.08; Mon, 28 Nov 2022 19:24:31 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235434AbiK2DJk (ORCPT + 99 others); Mon, 28 Nov 2022 22:09:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36912 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235190AbiK2DJg (ORCPT ); Mon, 28 Nov 2022 22:09:36 -0500 Received: from loongson.cn (mail.loongson.cn [114.242.206.163]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 5C1CA2EF41; Mon, 28 Nov 2022 19:09:34 -0800 (PST) Received: from loongson.cn (unknown [10.180.13.64]) by gateway (Coremail) with SMTP id _____8Dxfevtd4VjQeYBAA--.4390S3; Tue, 29 Nov 2022 11:09:33 +0800 (CST) Received: from localhost.localdomain (unknown [10.180.13.64]) by localhost.localdomain (Coremail) with SMTP id AQAAf8CxZ1fmd4VjE+QdAA--.57759S3; Tue, 29 Nov 2022 11:09:32 +0800 (CST) From: Yinbo Zhu To: Daniel Lezcano , Thomas Gleixner , Rob Herring , Krzysztof Kozlowski , Huacai Chen , WANG Xuerui , Jiaxun Yang , Jianmin Lv , Yun Liu , Yang Li , linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, loongarch@lists.linux.dev, Yinbo Zhu Subject: [PATCH v11 2/3] LoongArch: time: add timer_probe in time_init Date: Tue, 29 Nov 2022 11:09:24 +0800 Message-Id: <20221129030925.14074-2-zhuyinbo@loongson.cn> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20221129030925.14074-1-zhuyinbo@loongson.cn> References: <20221129030925.14074-1-zhuyinbo@loongson.cn> MIME-Version: 1.0 X-CM-TRANSID: AQAAf8CxZ1fmd4VjE+QdAA--.57759S3 X-CM-SenderInfo: 52kx5xhqerqz5rrqw2lrqou0/ X-Coremail-Antispam: 1Uk129KBjvdXoW7Xry5uF48tr45Kr4xtw1DZFb_yoW3JFc_ua 47Ga4kWryrGa9a934DXa15Xw10vw48tFyFy3srZFy7Gw17J3WUCw47Zw13Zr90gayxKFZ8 ZrW5JF93Cr13KjkaLaAFLSUrUUUUnb8apTn2vfkv8UJUUUU8wcxFpf9Il3svdxBIdaVrn0 xqx4xG64xvF2IEw4CE5I8CrVC2j2Jv73VFW2AGmfu7bjvjm3AaLaJ3UjIYCTnIWjp_UUUY X7CY07I20VC2zVCF04k26cxKx2IYs7xG6rWj6s0DM7CIcVAFz4kK6r126r13M28lY4IEw2 IIxxk0rwA2F7IY1VAKz4vEj48ve4kI8wA2z4x0Y4vE2Ix0cI8IcVAFwI0_Gr0_Xr1l84AC jcxK6xIIjxv20xvEc7CjxVAFwI0_Gr0_Cr1l84ACjcxK6I8E87Iv67AKxVW8Jr0_Cr1UM2 8EF7xvwVC2z280aVCY1x0267AKxVW8Jr0_Cr1UM2kKe7AKxVWUAVWUtwAS0I0E0xvYzxvE 52x082IY62kv0487Mc804VCY07AIYIkI8VC2zVCFFI0UMc02F40EFcxC0VAKzVAqx4xG6I 80ewAv7VC0I7IYx2IY67AKxVWUtVWrXwAv7VC2z280aVAFwI0_Gr0_Cr1lOx8S6xCaFVCj c4AY6r1j6r4UM4x0Y48IcxkI7VAKI48JMxkF7I0En4kS14v26r126r1DMxAIw28IcxkI7V AKI48JMxAIw28IcVCjz48v1sIEY20_WwCFx2IqxVCFs4IE7xkEbVWUJVW8JwCFI7km07C2 67AKxVWUAVWUtwC20s026c02F40E14v26r1j6r18MI8I3I0E7480Y4vE14v26r106r1rMI 8E67AF67kF1VAFwI0_Jw0_GFylIxkGc2Ij64vIr41lIxAIcVC0I7IYx2IY67AKxVW8JVW5 JwCI42IY6xIIjxv20xvEc7CjxVAFwI0_Gr0_Cr1lIxAIcVCF04k26cxKx2IYs7xG6r1j6r 1xMIIF0xvEx4A2jsIE14v26r4j6F4UMIIF0xvEx4A2jsIEc7CjxVAFwI0_Gr0_Gr1UYxBI daVFxhVjvjDU0xZFpf9x07jeGQDUUUUU= X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_PASS, SPF_PASS 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?1750799243026982143?= X-GMAIL-MSGID: =?utf-8?q?1750799243026982143?= The Loongson-2 hpet clocksource driver used TIMER_OF_DECLARE to register clocksource subsystem that ask timer_probe was called in time_init and this patch was to addd such support. Signed-off-by: Yinbo Zhu --- arch/loongarch/kernel/time.c | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/loongarch/kernel/time.c b/arch/loongarch/kernel/time.c index 09f20bc81798..658c1fcce4c7 100644 --- a/arch/loongarch/kernel/time.c +++ b/arch/loongarch/kernel/time.c @@ -216,6 +216,7 @@ int __init constant_clocksource_init(void) void __init time_init(void) { of_clk_init(NULL); + timer_probe(); if (!cpu_has_cpucfg) const_clock_freq = cpu_clock_freq; From patchwork Tue Nov 29 03:09:25 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yinbo Zhu X-Patchwork-Id: 27057 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp103265wrr; Mon, 28 Nov 2022 19:26:07 -0800 (PST) X-Google-Smtp-Source: AA0mqf7e01T+bmJ7wCDJRVKFhS+lRZmilTO3B+9N/BRbE2KhXkgd7akZ9PkuLXElqam4zTdehzx2 X-Received: by 2002:aa7:dbc7:0:b0:45f:b80f:1fe8 with SMTP id v7-20020aa7dbc7000000b0045fb80f1fe8mr48196192edt.118.1669692366917; Mon, 28 Nov 2022 19:26:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669692366; cv=none; d=google.com; s=arc-20160816; b=NvFsjg3AeMyKT8SkekJ2Pev9EbGBxUaue2tEIR9uwjZDYHEVFuM3eyo7L+4/9rGirU zyfnKYzBmLT6mOnvxHZoiVuVM2Z2hkAtIVZ7ZXU82KwWT5XlGijipawomSloZVnUZ2HQ /YoWt/LoJy6KF+AjpwGG/38X/ih37HYGxxwGMWLUzA5Q7BSzf0DCe91PDDKE8e0nfHuQ JgPVVTUVac2NLIKbc7tcvia7DdvNZWo05UhgSdQbfH1oSc+hKzC/jWRZb8owVU9zJ3ha ikOn4kkhOWe2l2kkPhWN6gaQ6vpG8PqqMqCNGAS7vDgH97vH8xAdVlqR5H6TZ1y9NasX MXBA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=4tifjT/+V8WFb0CimE1tUhTsug3UjGUTXlw8biFkQpU=; b=0uKzJxR22tnmNxnMtfJ5yxgizlrrnbxXhsd1THkh+nPK9cjcERI0OHlcEGUtjR1468 6AWqDhOp5teLOHCGvcqWwJi1cmbyHJxIiCogcVEyo19Qrk2PmPhOmPG9Wws0L1Kzr8aj oES67/G5EAGXyKcfRtK3NAvvl5R2I6drkTipLYV3cTM+gG0h/EkkwjwF2ABGcmaLsbWg CDzmypi9WVFVUwSR0rlWsdSlLnF3KJ4VXUxSe082JT1BzUlaDn2Pk7eHw8dCGYSlkt2O XBC/Yy3eMTM0Q3pufQBQpDCwCSz7t6+a8voZOaz6KCS80SxegirFTqFGtlTIwAmEQUIC K1hA== ARC-Authentication-Results: i=1; mx.google.com; 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id es25-20020a056402381900b0046b850c39eesi428477edb.347.2022.11.28.19.25.43; Mon, 28 Nov 2022 19:26:06 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235295AbiK2DJo (ORCPT + 99 others); Mon, 28 Nov 2022 22:09:44 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36918 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235408AbiK2DJh (ORCPT ); Mon, 28 Nov 2022 22:09:37 -0500 Received: from loongson.cn (mail.loongson.cn [114.242.206.163]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id F34802EF5F; Mon, 28 Nov 2022 19:09:35 -0800 (PST) Received: from loongson.cn (unknown [10.180.13.64]) by gateway (Coremail) with SMTP id _____8Bx1vDud4VjTOYBAA--.4454S3; Tue, 29 Nov 2022 11:09:34 +0800 (CST) Received: from localhost.localdomain (unknown [10.180.13.64]) by localhost.localdomain (Coremail) with SMTP id AQAAf8CxZ1fmd4VjE+QdAA--.57759S4; Tue, 29 Nov 2022 11:09:32 +0800 (CST) From: Yinbo Zhu To: Daniel Lezcano , Thomas Gleixner , Rob Herring , Krzysztof Kozlowski , Huacai Chen , WANG Xuerui , Jiaxun Yang , Jianmin Lv , Yun Liu , Yang Li , linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, loongarch@lists.linux.dev, Yinbo Zhu Cc: Krzysztof Kozlowski Subject: [PATCH v11 3/3] dt-bindings: hpet: add loongson-2 hpet Date: Tue, 29 Nov 2022 11:09:25 +0800 Message-Id: <20221129030925.14074-3-zhuyinbo@loongson.cn> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20221129030925.14074-1-zhuyinbo@loongson.cn> References: <20221129030925.14074-1-zhuyinbo@loongson.cn> MIME-Version: 1.0 X-CM-TRANSID: AQAAf8CxZ1fmd4VjE+QdAA--.57759S4 X-CM-SenderInfo: 52kx5xhqerqz5rrqw2lrqou0/ X-Coremail-Antispam: 1Uk129KBjvJXoWxXF47tF4fWFWxJF1xCrW5GFg_yoWrGF4fpF s7CF95Jr47tF1fu39xKFyI9Fn5Za4DAF9rWr17tw1UAryDX3W5XFn2ga4DurW3GrWxWay7 XFySkw18Ka1jvr7anT9S1TB71UUUUjDqnTZGkaVYY2UrUUUUj1kv1TuYvTs0mT0YCTnIWj qI5I8CrVACY4xI64kE6c02F40Ex7xfYxn0WfASr-VFAUDa7-sFnT9fnUUIcSsGvfJTRUUU bS8Fc2x0x2IEx4CE42xK8VAvwI8IcIk0rVWrJVCq3wAFIxvE14AKwVWUXVWUAwA2ocxC64 kIII0Yj41l84x0c7CEw4AK67xGY2AK021l84ACjcxK6xIIjxv20xvE14v26ryj6F1UM28E F7xvwVC0I7IYx2IY6xkF7I0E14v26F4j6r4UJwA2z4x0Y4vEx4A2jsIE14v26r4UJVWxJr 1l84ACjcxK6I8E87Iv6xkF7I0E14v26r4UJVWxJr1ln4kS14v26r126r1DM2AIxVAIcxkE cVAq07x20xvEncxIr21l57IF6xkI12xvs2x26I8E6xACxx1l5I8CrVACY4xI64kE6c02F4 0Ex7xfMcIj6xIIjxv20xvE14v26r1q6rW5McIj6I8E87Iv67AKxVW8JVWxJwAm72CE4IkC 6x0Yz7v_Jr0_Gr1lF7xvr2IYc2Ij64vIr41lc7CjxVAaw2AFwI0_Jw0_GFyl42xK82IYc2 Ij64vIr41l42xK82IY6x8ErcxFaVAv8VWrMxC20s026xCaFVCjc4AY6r1j6r4UMxCIbckI 1I0E14v26r126r1DMI8I3I0E5I8CrVAFwI0_Jr0_Jr4lx2IqxVCjr7xvwVAFwI0_JrI_Jr Wlx4CE17CEb7AF67AKxVWUtVW8ZwCIc40Y0x0EwIxGrwCI42IY6xIIjxv20xvE14v26ryj 6F1UMIIF0xvE2Ix0cI8IcVCY1x0267AKxVW8JVWxJwCI42IY6xAIw20EY4v20xvaj40_Jr 0_JF4lIxAIcVC2z280aVAFwI0_Cr0_Gr1UMIIF0xvEx4A2jsIEc7CjxVAFwI0_Gr0_Gr1U YxBIdaVFxhVjvjDU0xZFpf9x07jetC7UUUUU= X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_PASS, SPF_PASS 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?1750799343667818189?= X-GMAIL-MSGID: =?utf-8?q?1750799343667818189?= Add the Loongson-2 High Precision Event Timer (HPET) binding with DT schema format using json-schema. Signed-off-by: Yinbo Zhu Reviewed-by: Krzysztof Kozlowski --- Change in v11: 1. NO change, but other patch in this series of patches set has changes. 2. This patch need rely on clock patch, which patchwork link was "https://patchwork.kernel.org/project/linux-clk/list/?series=691497". Change in v10: 1. NO change, but other patch in this series of patches set has changes. 2. This patch need rely on clock patch, which patchwork link was "https://patchwork.kernel.org/project/linux-clk/list/?series=691497". Change in v9: 1. This patch need rely on clock patch, which patchwork link was "https://patchwork.kernel.org/project/linux-clk/list/?series=691497". 2. NO change, but other patch in this series of patches set has changes. Change in v8: 1. This patch need rely on clock patch, which patchwork link was "https://patchwork.kernel.org/project/linux-clk/list/?series=691497". 2. Add all history change log information. Change in v7: 1. NO change, but other patch in this series of patches set has changes. Change in v6: 1. NO change, but other patch in this series of patches set has changes. Change in v5: 1. Replace string loongson2/Loongson2 with Loongson-2/loongson-2. 2. Add the patch review information. Change in v4: 1. Fixup the clock-names that replace apb-clk with apb. 2. This patch need rely on clock patch, which patchwork link was "https://patchwork.kernel.org/project/linux-clk/list/?series=688892". Change in v3: 1. Update dts that base on common clock framework. Change in v2: 1. Drop the "hpet0" label. 2. Modify the hpet node name to timer. .../bindings/timer/loongson,ls2k-hpet.yaml | 50 +++++++++++++++++++ MAINTAINERS | 1 + 2 files changed, 51 insertions(+) create mode 100644 Documentation/devicetree/bindings/timer/loongson,ls2k-hpet.yaml diff --git a/Documentation/devicetree/bindings/timer/loongson,ls2k-hpet.yaml b/Documentation/devicetree/bindings/timer/loongson,ls2k-hpet.yaml new file mode 100644 index 000000000000..30685c8fbead --- /dev/null +++ b/Documentation/devicetree/bindings/timer/loongson,ls2k-hpet.yaml @@ -0,0 +1,50 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/timer/loongson,ls2k-hpet.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Loongson-2 High Precision Event Timer (HPET) + +maintainers: + - Yinbo Zhu + +properties: + compatible: + const: loongson,ls2k-hpet + + reg: + maxItems: 1 + + clocks: + items: + - description: SoC apb clock + + clock-names: + items: + - const: apb + + interrupts: + maxItems: 1 + +required: + - compatible + - reg + - clocks + - clock-names + - interrupts + +additionalProperties: false + +examples: + - | + #include + #include + timer@1fe24000 { + compatible = "loongson,ls2k-hpet"; + reg = <0x1fe24000 0x15f>; + clocks = <&clk LOONGSON2_APB_CLK>; + clock-names = "apb"; + interrupt-parent = <&liointc0>; + interrupts = <21 IRQ_TYPE_LEVEL_LOW>; + }; diff --git a/MAINTAINERS b/MAINTAINERS index 5d5967f55c36..5b04e37a1bd2 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -12033,6 +12033,7 @@ LOONGSON-2 SOC SERIES HPET DRIVER M: Yinbo Zhu L: linux-kernel@vger.kernel.org S: Maintained +F: Documentation/devicetree/bindings/timer/loongson,ls2k-hpet.yaml F: drivers/clocksource/loongson2_hpet.c LSILOGIC MPT FUSION DRIVERS (FC/SAS/SPI)