From mboxrd@z Thu Jan 1 00:00:00 1970 From: Kim Phillips Date: Mon, 20 Aug 2012 19:18:59 -0500 Subject: [U-Boot] [PATCH 25/37] arm: rmobile: Add support TMU base timer function In-Reply-To: References: <1344582973-25165-1-git-send-email-nobuhiro.iwamatsu.yj@renesas.com> <1344582973-25165-6-git-send-email-nobuhiro.iwamatsu.yj@renesas.com> <20120813182613.cfd8a101d22f9d3455059887@freescale.com> Message-ID: <20120820191859.8068b1b54ed57551b1310952@freescale.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de On Mon, 20 Aug 2012 00:21:10 +0900 Nobuhiro Iwamatsu wrote: > On Tue, Aug 14, 2012 at 8:26 AM, Kim Phillips > wrote: > > On Fri, 10 Aug 2012 16:16:12 +0900 > > Nobuhiro Iwamatsu wrote: > > > >> Some rmobile SoC has TMU base timer function. This supports TMU. > >> > >> Signed-off-by: Nobuhiro Iwamatsu > >> --- > >> V2: Set COBJS one object per line, and sort the list. > >> > >> arch/arm/cpu/armv7/rmobile/Makefile | 4 +- > >> arch/arm/cpu/armv7/rmobile/timer_tmu.c | 161 +++++++++++++++++++++++++ > > > > this is a copy of arch/sh/lib/time.c but with proper struct tmu_regs > > instead of #defines; is it not possible to refactor & merge the two? > > I am going to merge next work. not sure what this means, but usually u-boot development favours initially refactoring common code rather than duplicating it, and then refactoring it (although I wouldn't know where common timer code across arches could live). > >> +int timer_init(void) > >> +{ > >> + /* Divide clock by CONFIG_SYS_TMU_CLK_DIV */ > >> + u16 bit = 0; > >> + > >> + switch (CONFIG_SYS_TMU_CLK_DIV) { > >> + case 1024: > >> + bit = 4; > >> + break; > >> + case 256: > >> + bit = 3; > >> + break; > >> + case 64: > >> + bit = 2; > >> + break; > >> + case 16: > >> + bit = 1; > >> + break; > >> + case 4: > >> + default: > >> + break; > >> + } > > > > Can this be broken down into a shift operation? > > Sorry, I can not understand this. > This means not using swtich but using shift operation? Sorry, I meant this: (ffs(CONFIG_SYS_TMU_CLK_DIV) >> 1) - 1 Kim