Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp1663958imj; Fri, 8 Feb 2019 05:25:30 -0800 (PST) X-Google-Smtp-Source: AHgI3IY7tLdxa9heAm519QI1IBtKjPrOlxFpsbsPZehYrTtQba0SQQ+u5osGG9HmEXAtCYyBib3U X-Received: by 2002:a63:e915:: with SMTP id i21mr20065263pgh.409.1549632330549; Fri, 08 Feb 2019 05:25:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549632330; cv=none; d=google.com; s=arc-20160816; b=U1lhKKGbbPo3tw+z0Ri3qq68zjB1I8Bzz5umduWyRWCkK/qyDGze2XRHKzVnbMR+7V 7h/uCjJN8p6I1S544eHT4TgG63IaN8tGq1vtytC8Xd21tkPDPi7cpAFmZBmw6UPmhcTz +jqGW6J++f6Co9vSwTZaijl7dnRB57nUk1gc/4/SNfOPkMmXclTrMC1JDTQUeKX1uxwi DSq2bhaXHUqOBb/tAcN2qmJLw+wm2GA1RKrPszYF1ZfT0ijzUqkpQD+SBEsoc/6+n6Gk PDonHEPTqGaEGv3xeHL/9xO7pxaOq8KB2DiFnSZgOUbG2CqLvI5FjI/oBYkIreOkqqb2 6ijg== 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=KN27eVrW9tG745rWB5gGx4GSDgsoCpJZfglRGskOQBI=; b=pkI/Y6qHE53OoW7pZXcJd2CI1+nciAXgWVqpwJmwRUU9gc38xs7vWxauOIvZE9Og6U fCBw14MRN3Ys71CttXumRWgqkT5R/P+cOPXE3b3jzZ7YBvY4kg/KeRwpoD/67V35eRH/ R8utxw00Jj3fhW1hyt1FomceQRI5DGyJnW5wp+pTrp+3X0uC1uvqQsRBx17Rq27UCRqL dA7tiBXMgSpAd+k/z9Mt5cF8pgZktTIzXeLIoi7PmYLQJ5CWybbYuFRqO7w1i1O2fLq0 446K9Ua+JtLsYe3kb5KqXKNkWj9TXVZvXmAcCW6JBMGFLTCd8P2XtXVZJ/BlKdccMkbb ugdg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=P+lAusm9; 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=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h188si2288226pfg.44.2019.02.08.05.25.14; Fri, 08 Feb 2019 05:25:30 -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=@ti.com header.s=ti-com-17Q1 header.b=P+lAusm9; 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=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727887AbfBHNYe (ORCPT + 99 others); Fri, 8 Feb 2019 08:24:34 -0500 Received: from fllv0015.ext.ti.com ([198.47.19.141]:33690 "EHLO fllv0015.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726944AbfBHNYe (ORCPT ); Fri, 8 Feb 2019 08:24:34 -0500 Received: from lelv0265.itg.ti.com ([10.180.67.224]) by fllv0015.ext.ti.com (8.15.2/8.15.2) with ESMTP id x18DOH69020334; Fri, 8 Feb 2019 07:24:17 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1549632257; bh=KN27eVrW9tG745rWB5gGx4GSDgsoCpJZfglRGskOQBI=; h=Subject:To:CC:References:From:Date:In-Reply-To; b=P+lAusm9BLTzDk8nbFCw328u49Da5fae4BHImqSTMOGwKmWiqOwAevya63TqXCdE1 QhItZkjpyZcJCF/dLp3Mpvn2kpa42i/OleBnbAEChph/Qsn8uVENU3SZRfx/f88l+7 /Y2S6z0Ecs8RvGzMUj8I5tT1K8Yi5zOW7QJLEjEM= Received: from DLEE102.ent.ti.com (dlee102.ent.ti.com [157.170.170.32]) by lelv0265.itg.ti.com (8.15.2/8.15.2) with ESMTPS id x18DOHGM056066 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Fri, 8 Feb 2019 07:24:17 -0600 Received: from DLEE106.ent.ti.com (157.170.170.36) by DLEE102.ent.ti.com (157.170.170.32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1591.10; Fri, 8 Feb 2019 07:24:17 -0600 Received: from dflp32.itg.ti.com (10.64.6.15) by DLEE106.ent.ti.com (157.170.170.36) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.1591.10 via Frontend Transport; Fri, 8 Feb 2019 07:24:17 -0600 Received: from [172.24.190.172] (ileax41-snat.itg.ti.com [10.172.224.153]) by dflp32.itg.ti.com (8.14.3/8.13.8) with ESMTP id x18DODlT007996; Fri, 8 Feb 2019 07:24:14 -0600 Subject: Re: [PATCH v2 02/12] clocksource: davinci-timer: new driver To: Bartosz Golaszewski , Kevin Hilman , Daniel Lezcano , Rob Herring , Mark Rutland , Thomas Gleixner CC: , , , Bartosz Golaszewski References: <20190204171757.32073-1-brgl@bgdev.pl> <20190204171757.32073-3-brgl@bgdev.pl> From: Sekhar Nori Message-ID: <7243573a-884d-cce2-380b-1be73636fafb@ti.com> Date: Fri, 8 Feb 2019 18:54:12 +0530 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: <20190204171757.32073-3-brgl@bgdev.pl> Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 04/02/19 10:47 PM, Bartosz Golaszewski wrote: > +static unsigned int davinci_timer_read(struct davinci_timer_data *timer, > + unsigned int reg) > +{ > + return __raw_readl(timer->base + reg); > +} > + > +static void davinci_timer_write(struct davinci_timer_data *timer, > + unsigned int reg, unsigned int val) > +{ > + __raw_writel(val, timer->base + reg); > +} Since its a new driver, please use readl_relaxed() and writel_relaxed(). > +static void davinci_timer_init(void __iomem *base) > +{ > + /* Set clock to internal mode and disable it. */ > + __raw_writel(0x0, base + DAVINCI_TIMER_REG_TCR); > + /* > + * Reset both 32-bit timers, set no prescaler for timer 34, set the > + * timer to dual 32-bit unchained mode, unreset both 32-bit timers. > + */ > + __raw_writel(DAVINCI_TIMER_TGCR_DEFAULT, base + DAVINCI_TIMER_REG_TGCR); > + /* Init both counters to zero. */ > + __raw_writel(0x0, base + DAVINCI_TIMER_REG_TIM12); > + __raw_writel(0x0, base + DAVINCI_TIMER_REG_TIM34); here too. > +} > + > +int __init davinci_timer_register(struct clk *clk, > + const struct davinci_timer_cfg *timer_cfg) > +{ [...] > + clocksource = kzalloc(sizeof(*clocksource), GFP_KERNEL); > + if (!clocksource) { > + pr_err("%s: Error allocating memory for clocksource data\n", > + __func__); > + return -ENOMEM; > + } > + > + clocksource->dev.name = "tim34"; > + clocksource->dev.rating = 300; > + clocksource->dev.read = davinci_timer_clksrc_read; > + clocksource->dev.mask = CLOCKSOURCE_MASK(DAVINCI_TIMER_CLKSRC_BITS); > + clocksource->dev.flags = CLOCK_SOURCE_IS_CONTINUOUS; > + clocksource->timer.set_period = davinci_timer_set_period_std; > + clocksource->timer.mode = DAVINCI_TIMER_MODE_PERIODIC; > + clocksource->timer.base = base; > + > + if (timer_cfg->cmp_off) > + clocksource->timer.regs = &davinci_timer_tim12_regs; > + else > + clocksource->timer.regs = &davinci_timer_tim34_regs; We should set clocksource->dev.name based on cmp_off too, otherwise it will be confusing to have a device called "tim34" using tim12 registers. > +/** > + * struct davinci_timer_cfg - davinci clocksource driver configuration struct > + * @reg: register range resource > + * @irq: clockevent and clocksource interrupt resources > + * @cmp_off: if set - it specifies the compare register used for clockevent > + * > + * Note: if the compare register is specified, the driver will use the bottom > + * clock half for both clocksource and clockevent and the compare register > + * to generate event irqs. The user must supply the correct compare register > + * interrupt number. > + * > + * This is only used by da830 the DSP of which uses the top half. The timer > + * driver still configures the top half to run in free-run mode. This note helps. Thanks! Regards, Sekhar