Patchwork [U-Boot] nand/spl: Assuming a static nand page size to reduce code size

login
register
mail settings
Submitter Matthew McClintock
Date April 5, 2011, 3:30 p.m.
Message ID <1302017445-29331-1-git-send-email-msm@freescale.com>
Download mbox | patch
Permalink /patch/89897/
State Superseded
Headers show

Comments

Matthew McClintock - April 5, 2011, 3:30 p.m.
Change variables to const to reduce code size, these values are
hardcoded via defines anyways so we might as well assume they
are constants

Signed-off-by: Matthew McClintock <msm@freescale.com>
cc: Scott Wood <scottwood@freescale.com>
---
With this change we can reduce the size of the nand_spl by
148 bytes with my particular board/compiler

 nand_spl/nand_boot_fsl_elbc.c |   10 +++++-----
 1 files changed, 5 insertions(+), 5 deletions(-)
Scott Wood - April 5, 2011, 6:48 p.m.
On Tue, Apr 05, 2011 at 10:30:45AM -0500, Matthew McClintock wrote:
> Change variables to const to reduce code size, these values are
> hardcoded via defines anyways so we might as well assume they
> are constants
> 
> Signed-off-by: Matthew McClintock <msm@freescale.com>
> cc: Scott Wood <scottwood@freescale.com>
> ---
> With this change we can reduce the size of the nand_spl by
> 148 bytes with my particular board/compiler

When building for MPC8315ERDB_NAND, I get:

nand_boot_fsl_elbc.c: In function 'nand_load':
nand_boot_fsl_elbc.c:54:20: error: 'CONFIG_NAND_OR_PRELIM' undeclared (first use in this function)
nand_boot_fsl_elbc.c:54:20: note: each undeclared identifier is reported only once for each function it appears in

It appears 85xx calls it CONFIG_NAND_OR_PRELIM, and 83xx calls it
CONFIG_SYS_NAND_OR_PRELIM.  The latter seems like what we should be
using.

I can't figure out what's "prelim" about it either, but that's another
matter.  :-)

-Scott
McClintock Matthew-B29882 - April 5, 2011, 7 p.m.
On Tue, Apr 5, 2011 at 1:48 PM, Scott Wood <scottwood@freescale.com> wrote:
> When building for MPC8315ERDB_NAND, I get:
>
> nand_boot_fsl_elbc.c: In function 'nand_load':
> nand_boot_fsl_elbc.c:54:20: error: 'CONFIG_NAND_OR_PRELIM' undeclared (first use in this function)
> nand_boot_fsl_elbc.c:54:20: note: each undeclared identifier is reported only once for each function it appears in
>
> It appears 85xx calls it CONFIG_NAND_OR_PRELIM, and 83xx calls it
> CONFIG_SYS_NAND_OR_PRELIM.  The latter seems like what we should be
> using.
>
> I can't figure out what's "prelim" about it either, but that's another
> matter.  :-)

I'll submit a follow up patch renaming CONFIG_NAND_OR_PRELIM to
CONFIG_SYS_NAND_OR_PRELIM and CONFIG_NAND_BR_PRELIM to
CONFIG_SYS_NAND_BR_PRELIM? Should I go ahead and drop the PRELIM as
well?

-M
Scott Wood - April 5, 2011, 7:03 p.m.
On Tue, 5 Apr 2011 14:00:23 -0500
McClintock Matthew-B29882 <B29882@freescale.com> wrote:

> On Tue, Apr 5, 2011 at 1:48 PM, Scott Wood <scottwood@freescale.com> wrote:
> > When building for MPC8315ERDB_NAND, I get:
> >
> > nand_boot_fsl_elbc.c: In function 'nand_load':
> > nand_boot_fsl_elbc.c:54:20: error: 'CONFIG_NAND_OR_PRELIM' undeclared (first use in this function)
> > nand_boot_fsl_elbc.c:54:20: note: each undeclared identifier is reported only once for each function it appears in
> >
> > It appears 85xx calls it CONFIG_NAND_OR_PRELIM, and 83xx calls it
> > CONFIG_SYS_NAND_OR_PRELIM.  The latter seems like what we should be
> > using.
> >
> > I can't figure out what's "prelim" about it either, but that's another
> > matter.  :-)
> 
> I'll submit a follow up patch renaming CONFIG_NAND_OR_PRELIM to
> CONFIG_SYS_NAND_OR_PRELIM and CONFIG_NAND_BR_PRELIM to
> CONFIG_SYS_NAND_BR_PRELIM? Should I go ahead and drop the PRELIM as
> well?

Just add the SYS, dropping PRELIM everywhere would be a bigger rename and
should be done separately if we decide to do that.

-Scott

Patch

diff --git a/nand_spl/nand_boot_fsl_elbc.c b/nand_spl/nand_boot_fsl_elbc.c
index 9547d44..922284f 100644
--- a/nand_spl/nand_boot_fsl_elbc.c
+++ b/nand_spl/nand_boot_fsl_elbc.c
@@ -51,11 +51,11 @@  static void nand_load(unsigned int offs, int uboot_size, uchar *dst)
 {
 	fsl_lbc_t *regs = LBC_BASE_ADDR;
 	uchar *buf = (uchar *)CONFIG_SYS_NAND_BASE;
-	int large = in_be32(&regs->bank[0].or) & OR_FCM_PGS;
-	int block_shift = large ? 17 : 14;
-	int block_size = 1 << block_shift;
-	int page_size = large ? 2048 : 512;
-	int bad_marker = large ? page_size + 0 : page_size + 5;
+	const int large = CONFIG_NAND_OR_PRELIM & OR_FCM_PGS;
+	const int block_shift = large ? 17 : 14;
+	const int block_size = 1 << block_shift;
+	const int page_size = large ? 2048 : 512;
+	const int bad_marker = large ? page_size + 0 : page_size + 5;
 	int fmr = (15 << FMR_CWTO_SHIFT) | (2 << FMR_AL_SHIFT) | 2;
 	int pos = 0;