From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751909AbcBHOV7 (ORCPT ); Mon, 8 Feb 2016 09:21:59 -0500 Received: from mail-wm0-f50.google.com ([74.125.82.50]:38886 "EHLO mail-wm0-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750922AbcBHOV5 (ORCPT ); Mon, 8 Feb 2016 09:21:57 -0500 Subject: Re: [PATCH v3 2/3] clocksource: Add NPS400 timers driver To: Noam Camus , linux-kernel@vger.kernel.org References: <1454418899-25500-1-git-send-email-noamc@ezchip.com> <1454775406-25277-3-git-send-email-noamc@ezchip.com> Cc: linux-snps-arc@lists.infradead.org, marc.zyngier@arm.com, cmetcalf@ezchip.com, talz@ezchip.com, giladb@ezchip.com, Rob Herring , Thomas Gleixner , John Stultz From: Daniel Lezcano Message-ID: <56B8A482.8040302@linaro.org> Date: Mon, 8 Feb 2016 15:21:54 +0100 User-Agent: Mozilla/5.0 (X11; Linux i686; rv:38.0) Gecko/20100101 Thunderbird/38.5.1 MIME-Version: 1.0 In-Reply-To: <1454775406-25277-3-git-send-email-noamc@ezchip.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 02/06/2016 05:16 PM, Noam Camus wrote: > From: Noam Camus > > Add internal tick generator which is shared by all cores. > Each cluster of cores view it through dedicated address. > This is used for SMP system where all CPUs synced by same > clock source. > > Signed-off-by: Noam Camus > Cc: Daniel Lezcano > Cc: Rob Herring > Cc: Thomas Gleixner > Cc: John Stultz > Acked-by: Vineet Gupta > --- [ ... ] > +static cycle_t nps_clksrc_read(struct clocksource *clksrc) > +{ > + int cluster = raw_smp_processor_id() >> NPS_CLUSTER_OFFSET; > + > + return (cycle_t)ioread32be(nps_msu_reg_low_addr[cluster]); > +} > + > +static struct clocksource nps_counter = { > + .name = "EZnps-tick", > + .rating = 301, > + .read = nps_clksrc_read, > + .mask = CLOCKSOURCE_MASK(32), > + .flags = CLOCK_SOURCE_IS_CONTINUOUS, > +}; > + > +static void __init nps_setup_clocksource(struct device_node *node, > + struct clk *clk) > +{ > + struct clocksource *clksrc = &nps_counter; > + int ret, cluster; > + > + for (cluster = 0; cluster < NPS_CLUSTER_NUM; cluster++) > + nps_msu_reg_low_addr[cluster] = > + nps_host_reg((cluster << NPS_CLUSTER_OFFSET), > + NPS_MSU_BLKID, NPS_MSU_TICK_LOW); > + > + ret = clk_prepare_enable(clk); > + if (ret) > + pr_err("Couldn't enable parent clock\n"); > + > + nps_timer_rate = clk_get_rate(clk); If there is an error, you continue the execution of the code. I guess you expect the system to hang in any case with the error in the console, right ? > + ret = clocksource_register_hz(clksrc, nps_timer_rate); You can simplify the driver even more by using clocksource_mmio_init. -- Linaro.org │ Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog