[U-Boot-Users] [PATCH/review] Blackfin: setup a sane default EBIU_SDBCTL for SDRAM controllers

Wolfgang Denk wd at denx.de
Sun Jun 1 21:54:57 CEST 2008


In message <1212298724-15152-8-git-send-email-vapier at gentoo.org> you wrote:
> If the board config does not specify an explicit EBIU_SDBCTL value, set it
> up with sane values based on other configuration options.
...
> +#ifndef EBIU_RSTCTL
> +/* Blackfin with SDRAM */
> +#ifndef CONFIG_EBIU_SDBCTL_VAL
> +# if CONFIG_MEM_SIZE == 16
> +#  define CONFIG_EBSZ_VAL EBSZ_16
> +# elif CONFIG_MEM_SIZE == 32
> +#  define CONFIG_EBSZ_VAL EBSZ_32
> +# elif CONFIG_MEM_SIZE == 64
> +#  define CONFIG_EBSZ_VAL EBSZ_64
> +# elif CONFIG_MEM_SIZE == 128
> +#  define CONFIG_EBSZ_VAL EBSZ_128
> +# elif CONFIG_MEM_SIZE == 256
> +#  define CONFIG_EBSZ_VAL EBSZ_256
> +# elif CONFIG_MEM_SIZE == 512
> +#  define CONFIG_EBSZ_VAL EBSZ_512
> +# else
> +#  error You need to define CONFIG_EBIU_SDBCTL_VAL or CONFIG_MEM_SIZE
> +# endif
> +# if CONFIG_MEM_ADD_WDTH == 8
> +#  define CONFIG_EBCAW_VAL EBCAW_8
> +# elif CONFIG_MEM_ADD_WDTH == 9
> +#  define CONFIG_EBCAW_VAL EBCAW_9
> +# elif CONFIG_MEM_ADD_WDTH == 10
> +#  define CONFIG_EBCAW_VAL EBCAW_10
> +# elif CONFIG_MEM_ADD_WDTH == 11
> +#  define CONFIG_EBCAW_VAL EBCAW_11

This is pretty ugly code.

Why do you need the numeric values for CONFIG_MEM_SIZE and
CONFIG_MEM_ADD_WDTH at all? If you change for example

	#define CONFIG_MEM_ADD_WDTH       9

in your board config file into

	#define CONFIG_MEM_ADD_WDTH       EBCAW_9

this is barely less readable, but allow for much simpler code.
Actually, it immediately triggers the question why
CONFIG_MEM_ADD_WDTH and CONFIG_MEM_SIZE are needed at all - why don;t
you jst add the corresponding #defines for CONFIG_EBSZ_VAL resp.
CONFIG_EBCAW_VAL to the board config files?

Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
The human mind treats a new idea the way the body  treats  a  strange
protein - it rejects it.                                 - P. Medawar




More information about the U-Boot mailing list