Received: by 2002:a05:6358:701b:b0:131:369:b2a3 with SMTP id 27csp103983rwo; Fri, 21 Jul 2023 09:06:32 -0700 (PDT) X-Google-Smtp-Source: APBJJlEmFpXE2yiVdJvmt+SbKAENS+bAgjnmlnDLW8ZIvFfTx2StG99hv+dzhUFu/NyJ/zBxjUKR X-Received: by 2002:a05:6a20:3c89:b0:132:87da:5b57 with SMTP id b9-20020a056a203c8900b0013287da5b57mr2823402pzj.59.1689955592427; Fri, 21 Jul 2023 09:06:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689955592; cv=none; d=google.com; s=arc-20160816; b=RIoplZQunVnES5H74lxUnBiSGV7IFGf3Vzd7jWvwH5dY67sUGuNawy3Y3EVMz1RO08 mFJk9TKj8QszI3CZubSzbi2LKb+k8eA1SS7XSLB+XT0PMAAzERba2UkTl7/Sv9urqcyx HlPmjiOI85V1Ej7/MQgoMSa5fM02WbwEBx888Z8Q5l817QAB5RDLrJN7JGM2bWcy+/MO 1666X8ZXwJS2QzViBh+mRZyw9wQmF/n3cCVN/cSLTUs6H/K1FQQiTMOBXMUHmcR7cQGU WgzVdrnruczdfU0T6+ub+wGrjGGU+1jocQNEagGOmHH6IB/uBb8QZKzKEeMXjLh2ZC2/ crAQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:organization:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=+TxirMMikYBj22osM+tmTdGMukRkjDnj+AlJPvjQvoI=; fh=thJwGOIztJkBzixU3MCKh5ZXDkYcRa6EV7s504ufYIw=; b=1Bpv36KNstcrfW8HWPQ7IIJFRiBl89ysxemwuKhAbrZL3RQD6nFcWfm1z69qeDyMYp 61OTNGcrW0gnzmnQlvL5zoZFCQk1Z4advoiyVxoNLJDsvBL58zDitsEziaLCnTp2octU ysLYPikcRST3krtcw9PwOAwfu8J/0CvhXoH6fp7UeVoJ5kaPs6+yDytnV5Q4TU+LaEuY 2rBJCIej8AFVyiNWJjD1bMTZfK7Q3JbIkDZ9b37uLsN04OkutEL/wTnWIS+JFbEdC7KI ocMfiwWvU3AGPw1e27hRw9dsZ1n6sxFRcFn85ZtPKqmtaGcc2/rY9Z1YKaWgPJ+zeRLO QYTg== 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g13-20020a63be4d000000b0056345699506si3162786pgo.44.2023.07.21.09.06.11; Fri, 21 Jul 2023 09:06:32 -0700 (PDT) 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232295AbjGUP7R (ORCPT + 99 others); Fri, 21 Jul 2023 11:59:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59150 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231893AbjGUP7O (ORCPT ); Fri, 21 Jul 2023 11:59:14 -0400 Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 014492D47; Fri, 21 Jul 2023 08:59:12 -0700 (PDT) X-IronPort-AV: E=McAfee;i="6600,9927,10778"; a="397947175" X-IronPort-AV: E=Sophos;i="6.01,222,1684825200"; d="scan'208";a="397947175" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Jul 2023 08:59:11 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10778"; a="1055599368" X-IronPort-AV: E=Sophos;i="6.01,222,1684825200"; d="scan'208";a="1055599368" Received: from smile.fi.intel.com ([10.237.72.54]) by fmsmga005.fm.intel.com with ESMTP; 21 Jul 2023 08:58:59 -0700 Received: from andy by smile.fi.intel.com with local (Exim 4.96) (envelope-from ) id 1qMsWt-00BQxg-0w; Fri, 21 Jul 2023 18:58:55 +0300 Date: Fri, 21 Jul 2023 18:58:55 +0300 From: Andy Shevchenko To: nikita.shubin@maquefel.me Cc: Hartley Sweeten , Lennert Buytenhek , Alexander Sverdlin , Russell King , Lukasz Majewski , Linus Walleij , Bartosz Golaszewski , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Michael Turquette , Stephen Boyd , Daniel Lezcano , Thomas Gleixner , Alessandro Zummo , Alexandre Belloni , Wim Van Sebroeck , Guenter Roeck , Sebastian Reichel , Thierry Reding , Uwe =?iso-8859-1?Q?Kleine-K=F6nig?= , Mark Brown , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Vinod Koul , Miquel Raynal , Richard Weinberger , Vignesh Raghavendra , Damien Le Moal , Sergey Shtylyov , Dmitry Torokhov , Arnd Bergmann , Olof Johansson , soc@kernel.org, Liam Girdwood , Jaroslav Kysela , Takashi Iwai , Michael Peters , Kris Bahnsen , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org, devicetree@vger.kernel.org, linux-clk@vger.kernel.org, linux-rtc@vger.kernel.org, linux-watchdog@vger.kernel.org, linux-pm@vger.kernel.org, linux-pwm@vger.kernel.org, linux-spi@vger.kernel.org, netdev@vger.kernel.org, dmaengine@vger.kernel.org, linux-mtd@lists.infradead.org, linux-ide@vger.kernel.org, linux-input@vger.kernel.org, alsa-devel@alsa-project.org Subject: Re: [PATCH v3 09/42] clocksource: ep93xx: Add driver for Cirrus Logic EP93xx Message-ID: References: <20230605-ep93xx-v3-0-3d63a5f1103e@maquefel.me> <20230605-ep93xx-v3-9-3d63a5f1103e@maquefel.me> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230605-ep93xx-v3-9-3d63a5f1103e@maquefel.me> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo X-Spam-Status: No, score=-3.5 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_SOFTFAIL, T_SCC_BODY_TEXT_LINE 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 On Thu, Jul 20, 2023 at 02:29:09PM +0300, Nikita Shubin via B4 Relay wrote: > From: Nikita Shubin > > This us a rewrite of EP93xx timer driver in > arch/arm/mach-ep93xx/timer-ep93xx.c trying to do everything > the device tree way: > > - Make every IO-access relative to a base address and dynamic > so we can do a dynamic ioremap and get going. > - Find register range and interrupt from the device tree. ... + bits.h > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include ... > +/************************************************************************* Won't you marc it as a DOC: section? > + * Timer handling for EP93xx > + ************************************************************************* > + * The ep93xx has four internal timers. Timers 1, 2 (both 16 bit) and > + * 3 (32 bit) count down at 508 kHz, are self-reloading, and can generate > + * an interrupt on underflow. Timer 4 (40 bit) counts down at 983.04 kHz, > + * is free-running, and can't generate interrupts. > + * > + * The 508 kHz timers are ideal for use for the timer interrupt, as the > + * most common values of HZ divide 508 kHz nicely. We pick the 32 bit > + * timer (timer 3) to get as long sleep intervals as possible when using > + * CONFIG_NO_HZ. > + * > + * The higher clock rate of timer 4 makes it a better choice than the > + * other timers for use as clock source and for sched_clock(), providing > + * a stable 40 bit time base. > + ************************************************************************* > + */ ... > +/* > + * This read-only register contains the low word of the time stamp debug timer > + * ( Timer4). When this register is read, the high byte of the Timer4 counter is One too many spaces. > + * saved in the Timer4ValueHigh register. > + */ ... > +static irqreturn_t ep93xx_timer_interrupt(int irq, void *dev_id) > +{ > + struct ep93xx_tcu *tcu = ep93xx_tcu; > + struct clock_event_device *evt = dev_id; > + > + /* Writing any value clears the timer interrupt */ > + writel(1, tcu->base + EP93XX_TIMER3_CLEAR); Would 0 suffice? > + evt->event_handler(evt); > + > + return IRQ_HANDLED; > +} ... > +static int __init ep93xx_timer_of_init(struct device_node *np) > +{ > + int irq; > + unsigned long flags = IRQF_TIMER | IRQF_IRQPOLL; > + struct ep93xx_tcu *tcu; > + int ret; > + > + tcu = kzalloc(sizeof(*tcu), GFP_KERNEL); > + if (!tcu) > + return -ENOMEM; > + > + tcu->base = of_iomap(np, 0); fwnode_iomap()? See below why it might make sense. > + if (!tcu->base) { > + pr_err("Can't remap registers\n"); First of all, you may utilize pr_fmt(). Second, you may add %pOF for better user experience. > + ret = -ENXIO; > + goto out_free; > + } > + irq = irq_of_parse_and_map(np, 0); fwnode_irq_get() which is better in terms of error handling. > + if (irq == 0) > + irq = -EINVAL; > + if (irq < 0) { > + pr_err("EP93XX Timer Can't parse IRQ %d", irq); As per above. > + goto out_free; > + } ... > +} -- With Best Regards, Andy Shevchenko