Message ID | 1311682158-15150-3-git-send-email-simonschwarzcor@gmail.com |
---|---|
State | Superseded |
Headers | show |
On Tue, 26 Jul 2011 14:09:15 +0200 Simon Schwarz <simonschwarzcor@googlemail.com> wrote: > +#ifdef CONFIG_SPL_NAND_SUPPORT > +static void nand_load_image(void) > +{ > + gpmc_init(); > + nand_init(); > + nand_copy_image(CONFIG_SYS_NAND_U_BOOT_OFFS, > + CONFIG_SYS_NAND_U_BOOT_SIZE, > + (uchar *)CONFIG_SYS_NAND_U_BOOT_DST); > +#ifdef CONFIG_NAND_ENV_DST > + nand_copy_image(CONFIG_ENV_OFFSET, CONFIG_ENV_SIZE, > + (uchar *)CONFIG_NAND_ENV_DST); > +#ifdef CONFIG_ENV_OFFSET_REDUND > + nand_copy_image(CONFIG_ENV_OFFSET_REDUND, CONFIG_ENV_SIZE, > + (uchar *)CONFIG_NAND_ENV_DST + CONFIG_ENV_SIZE); > +#endif > +#endif > + parse_image_header((struct image_header *)CONFIG_SYS_NAND_U_BOOT_DST); > +} > +#endif /* CONFIG_SPL_NAND_SUPPORT */ I'm not sure that "load" versus "copy" conveys the difference between this function and the low-level nand_copy_image. Where is nand_copy_image() defined? > diff --git a/include/nand.h b/include/nand.h > index 8d94b5c..e0f20f6 100644 > --- a/include/nand.h > +++ b/include/nand.h > @@ -132,6 +132,8 @@ int nand_lock( nand_info_t *meminfo, int tight ); > int nand_unlock( nand_info_t *meminfo, ulong start, ulong length ); > int nand_get_lock_status(nand_info_t *meminfo, loff_t offset); > > +void nand_copy_image(unsigned int offs, unsigned int size, uchar *dst); Use loff_t for offset. Maybe call it "nand_spl_copy_image" or "nand_spl_load_image". -Scott
Dear Scott Wood, On 07/27/2011 11:38 PM, Scott Wood wrote: > On Wed, 27 Jul 2011 10:42:22 +0200 > Simon Schwarz<simonschwarzcor@googlemail.com> wrote: > >> Dear Scott Wood, >> >> On 07/26/2011 08:06 PM, Scott Wood wrote: >>> On Tue, 26 Jul 2011 14:09:15 +0200 >>> Simon Schwarz<simonschwarzcor@googlemail.com> wrote: >>> >>>> +#ifdef CONFIG_SPL_NAND_SUPPORT >>>> +static void nand_load_image(void) >>>> +{ >>>> + gpmc_init(); >>>> + nand_init(); >>>> + nand_copy_image(CONFIG_SYS_NAND_U_BOOT_OFFS, >>>> + CONFIG_SYS_NAND_U_BOOT_SIZE, >>>> + (uchar *)CONFIG_SYS_NAND_U_BOOT_DST); >>>> +#ifdef CONFIG_NAND_ENV_DST >>>> + nand_copy_image(CONFIG_ENV_OFFSET, CONFIG_ENV_SIZE, >>>> + (uchar *)CONFIG_NAND_ENV_DST); >>>> +#ifdef CONFIG_ENV_OFFSET_REDUND >>>> + nand_copy_image(CONFIG_ENV_OFFSET_REDUND, CONFIG_ENV_SIZE, >>>> + (uchar *)CONFIG_NAND_ENV_DST + CONFIG_ENV_SIZE); >>>> +#endif >>>> +#endif >>>> + parse_image_header((struct image_header *)CONFIG_SYS_NAND_U_BOOT_DST); >>>> +} >>>> +#endif /* CONFIG_SPL_NAND_SUPPORT */ >>> >>> I'm not sure that "load" versus "copy" conveys the difference between this >>> function and the low-level nand_copy_image. >> >> The actual difference is that nand_load has an mtd_info struct as >> additional paramter. > > Hmm? nand_load_image() takes no arguments. I don't see a nand_load(). > > The actual difference is that one is a low-level "move this from here to > there" function, and the other is driving hardware init and then performing > a series of calls to the low-level function, supplying the information > about what is to be loaded where. We have different code - sorry for the confusion. see below. > >> The device to use is selected in nand_init and I >> don't see a reason why this should be passed around in the interface - >> in the spl all data is typically loaded from one chip - this also was >> the implementation before. > > Sure. > >>> Where is nand_copy_image() defined? >> It's in drivers/mtd/nand/nand_spl.c > > Where is drivers/mtd/nand/nand_spl.c? It's not in Wolfgang's > current tree, nor in u-boot-ti, and I didn't see it in these patches. Did > you forget to "git add"? arrghh. You are right. I forgot a git add. V6 will change this... > > Note that there will not be one implementation of nand_copy_image suitable > for all hardware, just as currently nand_spl/nand_boot.c is not used for > all NAND SPL targets. Hm. I know that. I just adapated the old nand_boot.c. AFAIK the other implementations use prefixes for the function names - therefore we can just add them to the nand-spl-library and gcc will do the rest. Regards & thx for the review! Simon
On Thu, 28 Jul 2011 09:51:01 +0200 Simon Schwarz <simonschwarzcor@googlemail.com> wrote: > On 07/27/2011 11:38 PM, Scott Wood wrote: > > Note that there will not be one implementation of nand_copy_image suitable > > for all hardware, just as currently nand_spl/nand_boot.c is not used for > > all NAND SPL targets. > > Hm. I know that. I just adapated the old nand_boot.c. While we're moving things around, could we call it something like "nand_spl_simple.c"? > AFAIK the other implementations use prefixes for the function names - > therefore we can just add them to the nand-spl-library and gcc will do > the rest. The other implementations do not have prefixes -- they all are entered via nand_boot(). More importantly, not all implementations are buildable for all targets. They depend on certain #defines that may not be there. This includes the "simple" implementation. -Scott
Hi Scott, On 07/28/2011 08:56 PM, Scott Wood wrote: > On Thu, 28 Jul 2011 09:51:01 +0200 > Simon Schwarz<simonschwarzcor@googlemail.com> wrote: > >> On 07/27/2011 11:38 PM, Scott Wood wrote: >>> Note that there will not be one implementation of nand_copy_image suitable >>> for all hardware, just as currently nand_spl/nand_boot.c is not used for >>> all NAND SPL targets. >> >> Hm. I know that. I just adapated the old nand_boot.c. > > While we're moving things around, could we call it > something like "nand_spl_simple.c"? > Sure, if there are no arguments against -> will do. >> AFAIK the other implementations use prefixes for the function names - >> therefore we can just add them to the nand-spl-library and gcc will do >> the rest. > > The other implementations do not have prefixes -- they all are entered via > nand_boot(). More importantly, not all implementations are buildable for > all targets. They depend on certain #defines that may not be there. This > includes the "simple" implementation. Hm - so adding #ifdefs is inevitable then? Will do if there are no objections. > -Scott > Regards & thx for review! Simon
diff --git a/arch/arm/cpu/armv7/omap-common/spl.c b/arch/arm/cpu/armv7/omap-common/spl.c index d177652..468699d 100644 --- a/arch/arm/cpu/armv7/omap-common/spl.c +++ b/arch/arm/cpu/armv7/omap-common/spl.c @@ -26,6 +26,7 @@ #include <asm/u-boot.h> #include <asm/utils.h> #include <asm/arch/sys_proto.h> +#include <nand.h> #include <mmc.h> #include <fat.h> #include <timestamp_autogenerated.h> @@ -107,6 +108,7 @@ static void parse_image_header(const struct image_header *header) } } +#ifdef CONFIG_SPL_MMC_SUPPORT static void mmc_load_image_raw(struct mmc *mmc) { u32 image_size_sectors, err; @@ -140,7 +142,9 @@ end: hang(); } } +#endif /* CONFIG_SPL_MMC_SUPPORT */ +#ifdef CONFIG_SPL_MMC_SUPPORT static void mmc_load_image_fat(struct mmc *mmc) { s32 err; @@ -173,7 +177,9 @@ end: hang(); } } +#endif /* CONFIG_SPL_MMC_SUPPORT */ +#ifdef CONFIG_SPL_MMC_SUPPORT static void mmc_load_image(void) { struct mmc *mmc; @@ -206,6 +212,27 @@ static void mmc_load_image(void) hang(); } } +#endif /* CONFIG_SPL_MMC_SUPPORT */ + +#ifdef CONFIG_SPL_NAND_SUPPORT +static void nand_load_image(void) +{ + gpmc_init(); + nand_init(); + nand_copy_image(CONFIG_SYS_NAND_U_BOOT_OFFS, + CONFIG_SYS_NAND_U_BOOT_SIZE, + (uchar *)CONFIG_SYS_NAND_U_BOOT_DST); +#ifdef CONFIG_NAND_ENV_DST + nand_copy_image(CONFIG_ENV_OFFSET, CONFIG_ENV_SIZE, + (uchar *)CONFIG_NAND_ENV_DST); +#ifdef CONFIG_ENV_OFFSET_REDUND + nand_copy_image(CONFIG_ENV_OFFSET_REDUND, CONFIG_ENV_SIZE, + (uchar *)CONFIG_NAND_ENV_DST + CONFIG_ENV_SIZE); +#endif +#endif + parse_image_header((struct image_header *)CONFIG_SYS_NAND_U_BOOT_DST); +} +#endif /* CONFIG_SPL_NAND_SUPPORT */ void jump_to_image_no_args(void) { @@ -228,10 +255,17 @@ void board_init_r(gd_t *id, ulong dummy) boot_device = omap_boot_device(); debug("boot device - %d\n", boot_device); switch (boot_device) { +#ifdef CONFIG_SPL_MMC_SUPPORT case BOOT_DEVICE_MMC1: case BOOT_DEVICE_MMC2: mmc_load_image(); break; +#endif +#ifdef CONFIG_SPL_NAND_SUPPORT + case BOOT_DEVICE_NAND: + nand_load_image(); + break; +#endif default: printf("SPL: Un-supported Boot Device - %d!!!\n", boot_device); hang(); @@ -259,7 +293,11 @@ void preloader_console_init(void) gd->flags |= GD_FLG_RELOC; gd->baudrate = CONFIG_BAUDRATE; +/* Console clock for OMAP3 is already initialized by per_clocks_enable() + * called in board.c by s_init() */ +#ifndef CONFIG_OMAP34XX setup_clocks_for_console(); +#endif serial_init(); /* serial communications setup */ /* Avoid a second "U-Boot" coming from this string */ @@ -270,3 +308,11 @@ void preloader_console_init(void) omap_rev_string(rev_string_buffer); printf("Texas Instruments %s\n", rev_string_buffer); } + +int do_reset(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) +{ + debug("resetting cpu..."); + reset_cpu(0); + + return 0; +} diff --git a/arch/arm/include/asm/omap_common.h b/arch/arm/include/asm/omap_common.h index d3cb857..13f6884 100644 --- a/arch/arm/include/asm/omap_common.h +++ b/arch/arm/include/asm/omap_common.h @@ -49,6 +49,7 @@ void preloader_console_init(void); #define MMCSD_MODE_UNDEFINED 0 #define MMCSD_MODE_RAW 1 #define MMCSD_MODE_FAT 2 +#define NAND_MODE_HW_ECC 3 u32 omap_boot_device(void); u32 omap_boot_mode(void); diff --git a/include/nand.h b/include/nand.h index 8d94b5c..e0f20f6 100644 --- a/include/nand.h +++ b/include/nand.h @@ -132,6 +132,8 @@ int nand_lock( nand_info_t *meminfo, int tight ); int nand_unlock( nand_info_t *meminfo, ulong start, ulong length ); int nand_get_lock_status(nand_info_t *meminfo, loff_t offset); +void nand_copy_image(unsigned int offs, unsigned int size, uchar *dst); + #ifdef CONFIG_SYS_NAND_SELECT_DEVICE void board_nand_select_device(struct nand_chip *nand, int chip); #endif
Add NAND support for the new SPL structure. Signed-off-by: Simon Schwarz <simonschwarzcor@gmail.com> --- This patch didn't exist before V2! V2 changes: ADD Some define-barriers for OMAP3 to only use NAND ADD nand_load_image() - inits the OMAP gpmc, loads the images - parses the header CHG cosmetic ADD do_reset() implementation for omap-common spl ADD nand_copy_image to nand.h ADD CPP barriers for mmc and nand support. The parts depending on library support are only compiled if the respective library is included. V3 changes: ADD Comment why setup_clocks_for_console() isn't called for OMAP3 CHG cosmetic (deleted empty line) CHG rename of NAND_MODE_HW to NAND_MODE_HW_ECC DEL NAND_MODE_SW. Not used. V4 changes: CHG cosmetic - style problems Transition from V1 to V2 also includes that this patch is now based on - the new SPL layout by Aneesh V and Daniel Schwierzeck - the OMAP4 SPL patches by Aneesh V --- arch/arm/cpu/armv7/omap-common/spl.c | 46 ++++++++++++++++++++++++++++++++++ arch/arm/include/asm/omap_common.h | 1 + include/nand.h | 2 + 3 files changed, 49 insertions(+), 0 deletions(-)