From mboxrd@z Thu Jan 1 00:00:00 1970 From: Scott Wood Date: Mon, 13 Aug 2012 17:56:42 -0500 Subject: [U-Boot] [PATCH 4/6] nand_spl: update udelay for Freescale boards In-Reply-To: <1344881442-22671-4-git-send-email-msm@freescale.com> References: <1344881442-22671-1-git-send-email-msm@freescale.com> <1344881442-22671-4-git-send-email-msm@freescale.com> Message-ID: <5029862A.3080800@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 08/13/2012 01:10 PM, Matthew McClintock wrote: > Let's use the more appropriate udelay for the nand_spl. While we > can't make use of u-boot's full udelay we can atl east use a for > loop that won't get optimized away .Since we have the bus clock > we can use the timebase to calculate wall time. > > Looked at reusing the u-boot udelay functions but it pulls in a lot > of code as well as depends on the gd struct and would require a lot > of rework What's wrong with depending on the gd struct? > +extern u32 bus_clk; Change to gd->bus_clk as mentioned in patch 5/6. > +void udelay(unsigned long usec) { > + u32 ticks_per_usec = bus_clk / (8 * 1000000); > + u32 ticks = ticks_per_usec * usec; > + u32 s = mfspr(SPRN_TBRL); > + > + while ((mfspr(SPRN_TBRL)-s) < ticks); > +} Opening brace goes on its own line for function definitions. Use spaces around that '-'. Dividing the bus clock by 8 only works for e500v1/v2, but this isn't labelled as specific to those cores. > diff --git a/nand_spl/board/freescale/p1010rdb/Makefile b/nand_spl/board/freescale/p1010rdb/Makefile > index 8d240ea..cdbd492 100644 > --- a/nand_spl/board/freescale/p1010rdb/Makefile > +++ b/nand_spl/board/freescale/p1010rdb/Makefile > @@ -39,7 +39,8 @@ CFLAGS += -DCONFIG_NAND_SPL > > SOBJS = start.o resetvec.o ticks.o > COBJS = cache.o cpu_init_early.o cpu_init_nand.o fsl_law.o law.o \ > - nand_boot.o nand_boot_fsl_ifc.o ns16550.o tlb.o tlb_table.o > + nand_boot.o nand_boot_fsl_ifc.o ns16550.o tlb.o tlb_table.o \ > + ../common.o > > SRCS := $(addprefix $(obj),$(SOBJS:.o=.S) $(COBJS:.o=.c)) > OBJS := $(addprefix $(obj),$(SOBJS) $(COBJS)) > @@ -123,6 +124,9 @@ ifneq ($(OBJTREE), $(SRCTREE)) > $(obj)nand_boot.c: > @rm -f $(obj)nand_boot.c > ln -s $(SRCTREE)/nand_spl/board/$(BOARDDIR)/nand_boot.c $(obj)nand_boot.c > +$(obj)../common.c: > + @rm -f $(obj)../common.c > + ln -s $(SRCTREE)/nand_spl/board/freescale/common.c $(obj)../common.c > endif Why are you creating a link in the parent directory? -Scott