From mboxrd@z Thu Jan 1 00:00:00 1970 From: =?UTF-8?Q?=c5=81ukasz_Majewski?= Date: Sun, 24 Sep 2017 00:40:22 +0200 Subject: [U-Boot] [PATCH] sf: bar: Clean BA24 Bank Address Register bit after read/write/erase operation In-Reply-To: References: <1505295574-14294-1-git-send-email-lukma@denx.de> Message-ID: <559bac8b-ef3c-5929-8a91-0ddd5cce79e1@denx.de> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de Hi Fabio, Jagan, > Hi Lukasz, > > On Wed, Sep 13, 2017 at 6:39 AM, Lukasz Majewski wrote: > >> #ifdef CONFIG_SPI_FLASH_BAR >> +/* >> + * This "cleanup" is necessary in a situation when one was accessing >> + * spi flash memory > 16 MiB by using Bank Address Register's BA24 bit. >> + * >> + * After it the BA24 bit shall be cleared to allow access to correct >> + * memory region after SW reset (by calling "reset" command). >> + * >> + * Otherwise, the BA24 bit may be left set and then after reset, the >> + * ROM would seek for SPL from 0x1000000, not 0x0. >> + */ >> +static int cleanup_bar(struct spi_flash *flash) >> +{ >> + u8 cmd, bank_sel = 0; >> + >> + if (flash->bank_curr == 0) >> + return 0; >> + cmd = flash->bank_write_cmd; >> + >> + return spi_flash_write_common(flash, &cmd, 1, &bank_sel, 1); >> +} >> + > > What about defining an empty stub for this function when > CONFIG_SPI_FLASH_BAR is not defined? > >> static int write_bar(struct spi_flash *flash, u32 offset) >> { >> u8 cmd, bank_sel; >> @@ -339,6 +360,10 @@ int spi_flash_cmd_erase_ops(struct spi_flash *flash, u32 offset, size_t len) >> len -= erase_size; >> } >> >> +#ifdef CONFIG_SPI_FLASH_BAR >> + ret = cleanup_bar(flash); >> +#endif > > Then you don't need to add the ifdefs when calling cleanup_bar(). > Jagan, could you look into this patch? I would prefer to keep the coding style similar to the one already present in this file. -- Best regards, Lukasz Majewski -- DENX Software Engineering GmbH, Managing Director: Wolfgang Denk 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