From mboxrd@z Thu Jan 1 00:00:00 1970 From: Albert ARIBAUD Date: Fri, 12 Aug 2011 11:38:39 +0200 Subject: [U-Boot] [PATCH] AT91: Defer Dataflash access to env_relocate_spec In-Reply-To: <4E38FA8D.9080203@atmel.com> References: <1312354896-24951-1-git-send-email-hong.xu@atmel.com> <4E38F6D0.4080807@emk-elektronik.de> <4E38FA8D.9080203@atmel.com> Message-ID: <4E44F49F.3060102@aribaud.net> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de On 03/08/2011 09:36, Hong Xu wrote: > Hi Reinhard, > > On 08/03/2011 03:20 PM, Reinhard Meyer wrote: >> Dear Hong Xu, >> > When env_init is called, the SPI is not actually initialized in U-Boot. >> > So that we can not read Dataflash for its content. >> > We simply mark it OK for now, and defer the real work to >> > `env_relocate_spec'. (Idealy from env_nand.c) >> > >> > Signed-off-by: Hong Xu >> > --- >> > common/env_dataflash.c | 83 >> ++++++++++++++++++++++++++---------------------- >> > 1 files changed, 45 insertions(+), 38 deletions(-) >> >> I cannot really decide if that is a good approach. Where would be >> the issue if SPI/dataflash were initialized at this point (before >> relocation)? > > Currently the SPI is initialized in board_init which is called in > board_init_r, but env_init is called in board_init_f. So actually the > original code needs the SPI to be initialized before env_init, not > before relocation. > > An alternative way is to put SPI initialization code in > board_early_init_f. But I'm not sure if it's the correct way. I guess this is a general issue: if some driver is needed to get access to environment, then it must be initialized before relocation. But not all boards need initialization this early, and conversively, for each board-specific case where environment reading requires driver X, this adds a *general* constraint of initializing X before relocation -- and we'll end up initializing just about anything before reloc on boards that do not actually need initializations this early. Now this may not be feasible, but I think the idea is more "initialize what is needed for relocation, then relocate, then initialize the rest. Does anyone else here see this problem as I see it, or am I just being over-nit-picking? If it *is* a problem, then the only way I see to solve this is, for each driver that *might* be initialized before reloc, to provide a configuration option to select between initializing before or after relocation (possibly with variations in the driver initialization code based on this config option). Or am I also over-engineering here? Amicalement, -- Albert.