Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp3594302imj; Tue, 12 Feb 2019 01:08:44 -0800 (PST) X-Google-Smtp-Source: AHgI3Ibt0ejxVRvkgMcvm6/Bn8lXbWrWAIzowl60rYouyeI+48ukDmFLipifNtJClp3YJYp6/vfh X-Received: by 2002:a63:2164:: with SMTP id s36mr2705190pgm.430.1549962524342; Tue, 12 Feb 2019 01:08:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549962524; cv=none; d=google.com; s=arc-20160816; b=Jl7qifUbv8LyTsSUiT8gfyWD3XGJtBy0eqp5+xAjImuMsuvstm7ssxGdRjGAOY8cvn OTBW6SrzMZDDs7bu4oEb9FuXc0sSOGI6O9NSl4HA5v/EWtCnDPDSjOPzFjJRH8rMdFao QrpkXYZkYbbAG7PxCcwgYZi4ACiDliaj3ZcMq4afhAgeT9NsPF4AFqcjFvCtEUGQ/nUZ vLp6vgHn1UX1OJ79YOIfTDTfMsG62Ov0EbMuY4B9nOoLylhIffaYKA/MFribpdEEhQQn 92Czsz/OkrhEH6YLaC9yUevTJUYq6GQTO3ZqFfsPtlxSMHMHRCoMS9WaSTQ0wQ/VV4TB xMNA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=OOsj5rP0qK8yaK+fW00SckoKIFsWt0RwbpvgFzFULGU=; b=YH0dz9sVu5wN8wxhShQLY3vJVhp6FwewbU8+iibeFC0lxUYmUaUmXoqHZxxLUJAioG DoTj5IT6dWZI49h18gqoxemGMvkN2jFwyGwUbRR7Xppa1WdXohQ1m6RfoRgtdYbyj2gH Q8KMLIOfaodfgaM638lTsO6/4QNiyGqfJ3VqshTNH6k4sgHPsO7l+rcf0ctwv2y9Nolg QCKz/C/Wg7brFvkJRahyXr1aXy09HvKDpb+2d0qfvMH15EHpMdIb6obtgChnFwxhucTI fD/4K5Mzn8R5s7OgUrN9hRENguP5uGfZx0GGd56VS3s8wBozWuNB1Mw5hfISDbbkll6q BQSQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=SYBKsO7B; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a12si11722549pgk.291.2019.02.12.01.08.27; Tue, 12 Feb 2019 01:08:44 -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; dkim=pass header.i=@linaro.org header.s=google header.b=SYBKsO7B; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728737AbfBLJGU (ORCPT + 99 others); Tue, 12 Feb 2019 04:06:20 -0500 Received: from mail-wm1-f67.google.com ([209.85.128.67]:40883 "EHLO mail-wm1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728664AbfBLJGT (ORCPT ); Tue, 12 Feb 2019 04:06:19 -0500 Received: by mail-wm1-f67.google.com with SMTP id q21so2081362wmc.5 for ; Tue, 12 Feb 2019 01:06:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=OOsj5rP0qK8yaK+fW00SckoKIFsWt0RwbpvgFzFULGU=; b=SYBKsO7BU34O3kZ7oAJLjzl5oMZzPPuxg1U5aSrWvqxl/pHNcIBHdGS9wKMsEmNmWD 8tCswthB8oAkMtB8qVBeVaI+Oxy0nGguEONZW3Kchvhu5ZGEIbUoI8Hqil/mL2HgHBpn gEHI2U2Wi/bf0qPVwYzp70AWDuFBnqQ31AmLMUkw23YK+YgNBH7HMGCqsiJ8KEYYGbsu T3SbHTcdm4CFLBWIpcKyCZkndmkSd2QyJMolKYTyOKUMGFg+/MRlU6tS6kZ+jvhvHad8 8ii4uaQiQBd0ob7UlSr6iBnWINDyPxDk3xZidiWm2lWP5H+guH4CQnLSfan5UqzVxt3R cnXg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=OOsj5rP0qK8yaK+fW00SckoKIFsWt0RwbpvgFzFULGU=; b=CCac1W+yTZuN2K8SQSpRfuvC17smlhUse5FQZvdAuGqozHdJoozt1scOjOrMs65hU0 busedv1zp0EG6AMJ+V7UtvQDIOHKkvFaAKUU/P/e1bSITIxN3nqVZaahkQLl5ubQtxmQ DjGpo+nSEjUcv+6Soi8GM93CrUUrr8YfQbMD6vdr/903+9wRUtE84/+g9cvc4jyCBHLE rmnRplpo6i7pGUsywqaQHlaRANy74koZrWQaCCqFjHM1rpUvQoCdOd701pOs0RCzoSHr +OrjSZEKpB2d4VFTpagr07mGSRLNykG/46uKtmiqPco7LgdHEzMZjA0e0eaH8BIeUXIH VGug== X-Gm-Message-State: AHQUAuYyuux3nFfpZL1s5I15qQoRzX4b3FTANYp2oSG93OmujyZtwTlD 63mpbkx7ULio8/5dPImI032SAg== X-Received: by 2002:a1c:4683:: with SMTP id t125mr2099331wma.9.1549962376753; Tue, 12 Feb 2019 01:06:16 -0800 (PST) Received: from [192.168.27.65] (sju31-1-78-210-255-2.fbx.proxad.net. [78.210.255.2]) by smtp.googlemail.com with ESMTPSA id u17sm9195303wrg.71.2019.02.12.01.06.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 12 Feb 2019 01:06:15 -0800 (PST) Subject: Re: [PATCH v2 06/15] clocksource/drivers/timer-milbeaut: Introduce timer for Milbeaut SoCs To: Sugaya Taichi , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: Thomas Gleixner , Takao Orito , Kazuhiro Kasai , Shinji Kanematsu , Jassi Brar , Masami Hiramatsu References: <1549628812-31235-1-git-send-email-sugaya.taichi@socionext.com> From: Daniel Lezcano Message-ID: <80f521e5-6207-a32f-2f79-c2cb81dd1908@linaro.org> Date: Tue, 12 Feb 2019 10:06:13 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.4.0 MIME-Version: 1.0 In-Reply-To: <1549628812-31235-1-git-send-email-sugaya.taichi@socionext.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 08/02/2019 13:26, Sugaya Taichi wrote: > Add timer driver for Milbeaut SoCs series. > > The timer has two 32-bit width down counters, one of which is configured > as a clockevent device and the other is configured as a clock source. > > Signed-off-by: Sugaya Taichi Do want me to take it through my tree? > --- > drivers/clocksource/Kconfig | 9 ++ > drivers/clocksource/Makefile | 1 + > drivers/clocksource/timer-milbeaut.c | 161 +++++++++++++++++++++++++++++++++++ > 3 files changed, 171 insertions(+) > create mode 100644 drivers/clocksource/timer-milbeaut.c > > diff --git a/drivers/clocksource/Kconfig b/drivers/clocksource/Kconfig > index a9e26f6..9101b8f 100644 > --- a/drivers/clocksource/Kconfig > +++ b/drivers/clocksource/Kconfig > @@ -634,4 +634,13 @@ config GX6605S_TIMER > help > This option enables support for gx6605s SOC's timer. > > +config MILBEAUT_TIMER > + bool "Milbeaut timer driver" if COMPILE_TEST > + depends on OF > + depends on ARM > + select TIMER_OF > + select CLKSRC_MMIO > + help > + Enables the support for Milbeaut timer driver. > + > endmenu > diff --git a/drivers/clocksource/Makefile b/drivers/clocksource/Makefile > index cdd210f..6f2543b 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_MILBEAUT_TIMER) += timer-milbeaut.o > obj-$(CONFIG_SPRD_TIMER) += timer-sprd.o > obj-$(CONFIG_NPCM7XX_TIMER) += timer-npcm7xx.o > obj-$(CONFIG_RDA_TIMER) += timer-rda.o > diff --git a/drivers/clocksource/timer-milbeaut.c b/drivers/clocksource/timer-milbeaut.c > new file mode 100644 > index 0000000..f2019a8 > --- /dev/null > +++ b/drivers/clocksource/timer-milbeaut.c > @@ -0,0 +1,161 @@ > +// SPDX-License-Identifier: GPL-2.0 > +/* > + * Copyright (C) 2018 Socionext Inc. > + */ > + > +#include > +#include > +#include > +#include > +#include > +#include "timer-of.h" > + > +#define MLB_TMR_TMCSR_OFS 0x0 > +#define MLB_TMR_TMR_OFS 0x4 > +#define MLB_TMR_TMRLR1_OFS 0x8 > +#define MLB_TMR_TMRLR2_OFS 0xc > +#define MLB_TMR_REGSZPCH 0x10 > + > +#define MLB_TMR_TMCSR_OUTL BIT(5) > +#define MLB_TMR_TMCSR_RELD BIT(4) > +#define MLB_TMR_TMCSR_INTE BIT(3) > +#define MLB_TMR_TMCSR_UF BIT(2) > +#define MLB_TMR_TMCSR_CNTE BIT(1) > +#define MLB_TMR_TMCSR_TRG BIT(0) > + > +#define MLB_TMR_TMCSR_CSL_DIV2 0 > +#define MLB_TMR_DIV_CNT 2 > + > +#define MLB_TMR_SRC_CH (1) > +#define MLB_TMR_EVT_CH (0) > + > +#define MLB_TMR_SRC_CH_OFS (MLB_TMR_REGSZPCH * MLB_TMR_SRC_CH) > +#define MLB_TMR_EVT_CH_OFS (MLB_TMR_REGSZPCH * MLB_TMR_EVT_CH) > + > +#define MLB_TMR_SRC_TMCSR_OFS (MLB_TMR_SRC_CH_OFS + MLB_TMR_TMCSR_OFS) > +#define MLB_TMR_SRC_TMR_OFS (MLB_TMR_SRC_CH_OFS + MLB_TMR_TMR_OFS) > +#define MLB_TMR_SRC_TMRLR1_OFS (MLB_TMR_SRC_CH_OFS + MLB_TMR_TMRLR1_OFS) > +#define MLB_TMR_SRC_TMRLR2_OFS (MLB_TMR_SRC_CH_OFS + MLB_TMR_TMRLR2_OFS) > + > +#define MLB_TMR_EVT_TMCSR_OFS (MLB_TMR_EVT_CH_OFS + MLB_TMR_TMCSR_OFS) > +#define MLB_TMR_EVT_TMR_OFS (MLB_TMR_EVT_CH_OFS + MLB_TMR_TMR_OFS) > +#define MLB_TMR_EVT_TMRLR1_OFS (MLB_TMR_EVT_CH_OFS + MLB_TMR_TMRLR1_OFS) > +#define MLB_TMR_EVT_TMRLR2_OFS (MLB_TMR_EVT_CH_OFS + MLB_TMR_TMRLR2_OFS) > + > +#define MLB_TIMER_RATING 500 > + > +static irqreturn_t mlb_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) + MLB_TMR_EVT_TMCSR_OFS); > + val &= ~MLB_TMR_TMCSR_UF; > + writel_relaxed(val, timer_of_base(to) + MLB_TMR_EVT_TMCSR_OFS); > + > + clk->event_handler(clk); > + > + return IRQ_HANDLED; > +} > + > +static int mlb_set_state_periodic(struct clock_event_device *clk) > +{ > + struct timer_of *to = to_timer_of(clk); > + u32 val = MLB_TMR_TMCSR_CSL_DIV2; > + > + writel_relaxed(val, timer_of_base(to) + MLB_TMR_EVT_TMCSR_OFS); > + > + writel_relaxed(to->of_clk.period, timer_of_base(to) + > + MLB_TMR_EVT_TMRLR1_OFS); > + val |= MLB_TMR_TMCSR_RELD | MLB_TMR_TMCSR_CNTE | > + MLB_TMR_TMCSR_TRG | MLB_TMR_TMCSR_INTE; > + writel_relaxed(val, timer_of_base(to) + MLB_TMR_EVT_TMCSR_OFS); > + return 0; > +} > + > +static int mlb_set_state_oneshot(struct clock_event_device *clk) > +{ > + struct timer_of *to = to_timer_of(clk); > + u32 val = MLB_TMR_TMCSR_CSL_DIV2; > + > + writel_relaxed(val, timer_of_base(to) + MLB_TMR_EVT_TMCSR_OFS); > + return 0; > +} > + > +static int mlb_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) + MLB_TMR_EVT_TMRLR1_OFS); > + writel_relaxed(MLB_TMR_TMCSR_CSL_DIV2 | > + MLB_TMR_TMCSR_CNTE | MLB_TMR_TMCSR_INTE | > + MLB_TMR_TMCSR_TRG, timer_of_base(to) + > + MLB_TMR_EVT_TMCSR_OFS); > + return 0; > +} > + > +static int mlb_config_clock_source(struct timer_of *to) > +{ > + writel_relaxed(0, timer_of_base(to) + MLB_TMR_SRC_TMCSR_OFS); > + writel_relaxed(~0, timer_of_base(to) + MLB_TMR_SRC_TMR_OFS); > + writel_relaxed(~0, timer_of_base(to) + MLB_TMR_SRC_TMRLR1_OFS); > + writel_relaxed(~0, timer_of_base(to) + MLB_TMR_SRC_TMRLR2_OFS); > + writel_relaxed(BIT(4) | BIT(1) | BIT(0), timer_of_base(to) + > + MLB_TMR_SRC_TMCSR_OFS); > + return 0; > +} > + > +static int mlb_config_clock_event(struct timer_of *to) > +{ > + writel_relaxed(0, timer_of_base(to) + MLB_TMR_EVT_TMCSR_OFS); > + return 0; > +} > + > +static struct timer_of to = { > + .flags = TIMER_OF_IRQ | TIMER_OF_BASE | TIMER_OF_CLOCK, > + > + .clkevt = { > + .name = "mlb-clkevt", > + .rating = MLB_TIMER_RATING, > + .cpumask = cpu_possible_mask, > + .features = CLOCK_EVT_FEAT_DYNIRQ | CLOCK_EVT_FEAT_ONESHOT, > + .set_state_oneshot = mlb_set_state_oneshot, > + .set_state_periodic = mlb_set_state_periodic, > + .set_next_event = mlb_clkevt_next_event, > + }, > + > + .of_irq = { > + .flags = IRQF_TIMER | IRQF_IRQPOLL, > + .handler = mlb_timer_interrupt, > + }, > +}; > + > +static u64 notrace mlb_timer_sched_read(void) > +{ > + return ~readl_relaxed(timer_of_base(&to) + MLB_TMR_SRC_TMR_OFS); > +} > + > +static int __init mlb_timer_init(struct device_node *node) > +{ > + int ret; > + unsigned long rate; > + > + ret = timer_of_init(node, &to); > + if (ret) > + return ret; > + > + rate = timer_of_rate(&to) / MLB_TMR_DIV_CNT; > + mlb_config_clock_source(&to); > + clocksource_mmio_init(timer_of_base(&to) + MLB_TMR_SRC_TMR_OFS, > + node->name, rate, MLB_TIMER_RATING, 32, > + clocksource_mmio_readl_down); > + sched_clock_register(mlb_timer_sched_read, 32, rate); > + mlb_config_clock_event(&to); > + clockevents_config_and_register(&to.clkevt, timer_of_rate(&to), 15, > + 0xffffffff); > + return 0; > +} > +TIMER_OF_DECLARE(mlb_peritimer, "socionext,milbeaut-timer", > + mlb_timer_init); > -- Linaro.org │ Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog