Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp831425imu; Thu, 22 Nov 2018 06:05:31 -0800 (PST) X-Google-Smtp-Source: AFSGD/VA0FrNHmBPj5UxP35bGza09nN5/2a93AdOCdDY0573FihTxpMRkUIQBue+4d7NG3LKWrNg X-Received: by 2002:a17:902:7e44:: with SMTP id a4mr11457103pln.338.1542895531514; Thu, 22 Nov 2018 06:05:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542895531; cv=none; d=google.com; s=arc-20160816; b=myAMCAw6IrerDdWc1XF6NtrS94XuDDFA/fyKNvmpjhoVUg0ti3sWq3m8ZpHXgiaSg2 dno25YvMLEl80+yjlQmLfC3R57KblcD1pK2Y0IOsGm6yat/Af8O3arCpushbfveC+SLH cR4JVad642D8f1F575/IVvsXE8CdmRPoIYaLmQGucG+Js2ej89E9TKDjyD1DKiaVi4mG fuGVT987oIXziSZA4vR1ketNgfaDIy7o+i/JOAv0T9jlYlTBPHV1jWKWCURupP6CrpRX 1szHeXCDR+XXxs32UBUFv0rUNM3NzwLicLv5w+21rdlQURfL+jxWkGSwSxXWXe2DHDCj wkgg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=38gnDxVNisst+NZVILfXbRJzrIBvmOWnNHNWYc6lwuA=; b=JBW0vdvKWnyPdd9j9kYMog5r6epcLvYSJIbk8Q7l22hhZ+M8lB4SJm+PWbB2nKYn5p JfJ7kdwOYk3VFn8LlE1b83k3LqII0WgKii901Rsiw95ZCYkvwH7lrmu0ipiz/snXlnLt f1VA1XvRx+/bgHm6BodryJ+TGjk2zlGBtAVha1DGA6mlwNJrfi9AOel9gSholtKL6cpA fr9aUnuDxeKOHAMBcChrxlDG2quPA814t8NPkJYrsEwhhRCd3zDPkwrciFOzl3vUxPFr Nz9iLNIGvEqECNkvCXTeMCRQO6VeUFOQjkOWJd5SQSOcxrSU99g86rD54Xc+/4o8YsRN qoYA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k62si12438879pfc.208.2018.11.22.06.05.14; Thu, 22 Nov 2018 06:05:31 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732876AbeKVNBI (ORCPT + 99 others); Thu, 22 Nov 2018 08:01:08 -0500 Received: from mx.socionext.com ([202.248.49.38]:26315 "EHLO mx.socionext.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732781AbeKVNBI (ORCPT ); Thu, 22 Nov 2018 08:01:08 -0500 Received: from unknown (HELO iyokan-ex.css.socionext.com) ([172.31.9.54]) by mx.socionext.com with ESMTP; 22 Nov 2018 11:23:56 +0900 Received: from mail.mfilter.local (m-filter-2 [10.213.24.62]) by iyokan-ex.css.socionext.com (Postfix) with ESMTP id 97CDE60062; Thu, 22 Nov 2018 11:23:56 +0900 (JST) Received: from 172.31.9.53 (172.31.9.53) by m-FILTER with ESMTP; Thu, 22 Nov 2018 11:23:56 +0900 Received: from yuzu.css.socionext.com (yuzu [172.31.8.45]) by iyokan.css.socionext.com (Postfix) with ESMTP id E650E40361; Thu, 22 Nov 2018 11:23:55 +0900 (JST) Received: from [127.0.0.1] (unknown [10.213.119.83]) by yuzu.css.socionext.com (Postfix) with ESMTP id C271B120304; Thu, 22 Nov 2018 11:23:55 +0900 (JST) Subject: Re: [PATCH 05/14] clocksource/drivers/timer-milbeaut: Add Milbeaut M10V timer To: Daniel Lezcano , linux-clk@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org Cc: Michael Turquette , Stephen Boyd , Rob Herring , Mark Rutland , Greg Kroah-Hartman , Thomas Gleixner , Russell King , Jiri Slaby , Masami Hiramatsu , Jassi Brar References: <1542589274-13878-1-git-send-email-sugaya.taichi@socionext.com> <1542589274-13878-6-git-send-email-sugaya.taichi@socionext.com> From: "Sugaya, Taichi" Message-ID: <07d26609-e10c-70f1-1360-63ed0e214d7e@socionext.com> Date: Thu, 22 Nov 2018 11:23:54 +0900 User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:60.0) Gecko/20100101 Thunderbird/60.3.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Daniel Thank you for your comments. On 2018/11/21 19:08, Daniel Lezcano wrote: > Hi Sugaya, > > > On 19/11/2018 02:01, Sugaya Taichi wrote: >> Add Milbeaut M10V timer using 32bit timer in peripheral. > Give a better description of the timer as it is new timer introduced. I got it. Add more description. >> Signed-off-by: Sugaya Taichi >> --- >> drivers/clocksource/Kconfig | 8 +++ >> drivers/clocksource/Makefile | 1 + >> drivers/clocksource/timer-m10v.c | 146 +++++++++++++++++++++++++++++++++++++++ >> 3 files changed, 155 insertions(+) >> create mode 100644 drivers/clocksource/timer-m10v.c >> >> diff --git a/drivers/clocksource/Kconfig b/drivers/clocksource/Kconfig >> index 55c77e4..a278d72 100644 >> --- a/drivers/clocksource/Kconfig >> +++ b/drivers/clocksource/Kconfig >> @@ -638,4 +638,12 @@ config GX6605S_TIMER >> help >> This option enables support for gx6605s SOC's timer. >> >> +config M10V_TIMER >> + bool "Milbeaut M10V timer driver" if COMPILE_TEST >> + depends on OF >> + depends on ARM >> + select TIMER_OF >> + help >> + Enables the support for Milbeaut M10V timer driver. >> + >> endmenu >> diff --git a/drivers/clocksource/Makefile b/drivers/clocksource/Makefile >> index dd91381..8e908b4 100644 >> --- a/drivers/clocksource/Makefile >> +++ b/drivers/clocksource/Makefile >> @@ -55,6 +55,7 @@ obj-$(CONFIG_CLKSRC_TI_32K) += timer-ti-32k.o >> obj-$(CONFIG_CLKSRC_NPS) += timer-nps.o >> obj-$(CONFIG_OXNAS_RPS_TIMER) += timer-oxnas-rps.o >> obj-$(CONFIG_OWL_TIMER) += timer-owl.o >> +obj-$(CONFIG_M10V_TIMER) += timer-m10v.o >> obj-$(CONFIG_SPRD_TIMER) += timer-sprd.o >> obj-$(CONFIG_NPCM7XX_TIMER) += timer-npcm7xx.o >> >> diff --git a/drivers/clocksource/timer-m10v.c b/drivers/clocksource/timer-m10v.c >> new file mode 100644 >> index 0000000..ff97c23 >> --- /dev/null >> +++ b/drivers/clocksource/timer-m10v.c >> @@ -0,0 +1,146 @@ >> +// SPDX-License-Identifier: GPL-2.0 >> +/* >> + * Copyright (C) 2018 Socionext Inc. >> + */ >> + >> +#include > -------> > >> +#include > It is included from timer-of.h > > <------- OK. Remove it. > >> +#include >> +#include >> +#include > -------> > >> +#include >> +#include >> +#include >> +#include > Those are not needed IMO. > > <--------- OK, remove these. > > >> +#include "timer-of.h" >> + >> +#define FSL_TMR_TMCSR_OFS 0x0 >> +#define FSL_TMR_TMR_OFS 0x4 >> +#define FSL_TMR_TMRLR1_OFS 0x8 >> +#define FSL_TMR_TMRLR2_OFS 0xc >> +#define FSL_RMT_REGSZPCH 0x10 >> + >> +#define FSL_TMR_TMCSR_OUTL BIT(5) >> +#define FSL_TMR_TMCSR_RELD BIT(4) >> +#define FSL_TMR_TMCSR_INTE BIT(3) >> +#define FSL_TMR_TMCSR_UF BIT(2) >> +#define FSL_TMR_TMCSR_CNTE BIT(1) >> +#define FSL_TMR_TMCSR_TRG BIT(0) >> + >> +#define FSL_TMR_TMCSR_CSL_DIV2 0 >> +#define FSL_TMR_TMCSR_CSL BIT(10) >> + >> +#define M10V_TIMER_RATING 500 >> + >> +static irqreturn_t m10v_timer_interrupt(int irq, void *dev_id) >> +{ >> + struct clock_event_device *clk = dev_id; >> + struct timer_of *to = to_timer_of(clk); >> + u32 val; >> + >> + val = readl_relaxed(timer_of_base(to) + FSL_TMR_TMCSR_OFS); >> + val &= ~FSL_TMR_TMCSR_UF; >> + writel_relaxed(val, timer_of_base(to) + FSL_TMR_TMCSR_OFS); >> + >> + clk->event_handler(clk); >> + >> + return IRQ_HANDLED; >> +} >> + >> +static int m10v_set_state_periodic(struct clock_event_device *clk) >> +{ >> + struct timer_of *to = to_timer_of(clk); >> + u32 val = (FSL_TMR_TMCSR_CSL_DIV2 * FSL_TMR_TMCSR_CSL); > FSL_TMR_TMCSR_CSL_DIV2 is zero, so val is always zero. Ah, yes. The FSL_TMR_TMCSR is the 10th bit field of the register, so it would be better to bit-shift. I will use it as simply 0. > >> + writel_relaxed(val, timer_of_base(to) + FSL_TMR_TMCSR_OFS); >> + >> + writel_relaxed(to->of_clk.period, timer_of_base(to) + >> + FSL_TMR_TMRLR1_OFS); >> + val |= FSL_TMR_TMCSR_RELD | FSL_TMR_TMCSR_CNTE | >> + FSL_TMR_TMCSR_TRG | FSL_TMR_TMCSR_INTE; >> + writel_relaxed(val, timer_of_base(to) + FSL_TMR_TMCSR_OFS); >> + return 0; >> +} >> + >> +static int m10v_set_state_oneshot(struct clock_event_device *clk) >> +{ >> + struct timer_of *to = to_timer_of(clk); >> + u32 val = (FSL_TMR_TMCSR_CSL_DIV2 * FSL_TMR_TMCSR_CSL); >> + >> + writel_relaxed(val, timer_of_base(to) + FSL_TMR_TMCSR_OFS); >> + return 0; >> +} >> + >> +static int m10v_clkevt_next_event(unsigned long event, >> + struct clock_event_device *clk) >> +{ >> + struct timer_of *to = to_timer_of(clk); >> + >> + writel_relaxed(event, timer_of_base(to) + FSL_TMR_TMRLR1_OFS); >> + writel_relaxed((FSL_TMR_TMCSR_CSL_DIV2 * FSL_TMR_TMCSR_CSL) | > Same comment here. I got it. >> + FSL_TMR_TMCSR_CNTE | FSL_TMR_TMCSR_INTE | >> + FSL_TMR_TMCSR_TRG, timer_of_base(to) + >> + FSL_TMR_TMCSR_OFS); >> + return 0; >> +} >> + >> +static int m10v_config_clock_source(struct timer_of *to) >> +{ >> + writel_relaxed(0, timer_of_base(to) + FSL_TMR_TMCSR_OFS); >> + writel_relaxed(~0, timer_of_base(to) + FSL_TMR_TMR_OFS); >> + writel_relaxed(~0, timer_of_base(to) + FSL_TMR_TMRLR1_OFS); >> + writel_relaxed(~0, timer_of_base(to) + FSL_TMR_TMRLR2_OFS); >> + writel_relaxed(BIT(4) | BIT(1) | BIT(0), timer_of_base(to) + >> + FSL_TMR_TMCSR_OFS); >> + return 0; >> +} >> + >> +static int m10v_config_clock_event(struct timer_of *to) >> +{ >> + writel_relaxed(0, timer_of_base(to) + FSL_TMR_TMCSR_OFS); >> + return 0; >> +} >> + >> +static struct timer_of to = { >> + .flags = TIMER_OF_IRQ | TIMER_OF_BASE | TIMER_OF_CLOCK, >> + >> + .clkevt = { >> + .name = "m10v-clkevt", >> + .rating = M10V_TIMER_RATING, >> + .cpumask = cpu_possible_mask, >> + }, >> + >> + .of_irq = { >> + .flags = IRQF_TIMER | IRQF_IRQPOLL, >> + }, >> +}; >> + >> +static int __init m10v_timer_init(struct device_node *node) >> +{ >> + int ret; >> + >> + to.clkevt.features = CLOCK_EVT_FEAT_DYNIRQ | CLOCK_EVT_FEAT_ONESHOT; >> + to.clkevt.set_state_oneshot = m10v_set_state_oneshot; >> + to.clkevt.set_state_periodic = m10v_set_state_periodic; >> + to.clkevt.set_next_event = m10v_clkevt_next_event; >> + to.of_irq.handler = m10v_timer_interrupt; > Move the initialization in the timer_of structure above. Okay. > >> + ret = timer_of_init(node, &to); >> + if (ret) >> + goto err; > You should return directly, rollback is done in the timer_of_init(). OK. > >> + >> + m10v_config_clock_source(&to); >> + clocksource_mmio_init(timer_of_base(&to) + FSL_TMR_TMR_OFS, >> + node->name, timer_of_rate(&to), M10V_TIMER_RATING, 32, >> + clocksource_mmio_readl_down); > May be you can add the sched_clock also ? OK. Add it and confirm. Thanks Sugaya Taichi > >> + m10v_config_clock_event(&to); >> + clockevents_config_and_register(&to.clkevt, timer_of_rate(&to), >> + 15, 0xffffffff); >> + >> + return 0; >> +err: >> + timer_of_cleanup(&to); >> + return ret; >> +} >> +TIMER_OF_DECLARE(m10v_peritimer, "socionext,milbeaut-m10v-timer", >> + m10v_timer_init); >> >