[PATCH] mtd: sf: Set SF parameters as env variables

Jagan Teki jagan at amarulasolutions.com
Thu Dec 2 06:57:08 CET 2021


On Thu, Dec 2, 2021 at 11:19 AM Marek Vasut <marex at denx.de> wrote:
>
> On 12/2/21 06:47, Jagan Teki wrote:
> > On Tue, Sep 14, 2021 at 8:59 AM Marek Vasut <marex at denx.de> wrote:
> >>
> >> Set the SF page size, erase block size and total size as an environment
> >> variable after "sf probe". This lets us discern boards with multiple
> >> distinct SPI flash options and also e.g. set mtdparts accordingly.
> >>
> >> Signed-off-by: Marek Vasut <marex at denx.de>
> >> Cc: Jagan Teki <jagan at amarulasolutions.com>
> >> Cc: Vignesh R <vigneshr at ti.com>
> >> ---
> >>   drivers/mtd/spi/spi-nor-core.c | 4 ++++
> >>   1 file changed, 4 insertions(+)
> >>
> >> diff --git a/drivers/mtd/spi/spi-nor-core.c b/drivers/mtd/spi/spi-nor-core.c
> >> index d5d905fa5a1..448653b9931 100644
> >> --- a/drivers/mtd/spi/spi-nor-core.c
> >> +++ b/drivers/mtd/spi/spi-nor-core.c
> >> @@ -15,6 +15,7 @@
> >>   #include <dm.h>
> >>   #include <dm/device_compat.h>
> >>   #include <dm/devres.h>
> >> +#include <env.h>
> >>   #include <linux/bitops.h>
> >>   #include <linux/err.h>
> >>   #include <linux/errno.h>
> >> @@ -3829,8 +3830,11 @@ int spi_nor_scan(struct spi_nor *nor)
> >>   #ifndef CONFIG_SPL_BUILD
> >>          printf("SF: Detected %s with page size ", nor->name);
> >>          print_size(nor->page_size, ", erase size ");
> >> +       env_set_hex("sf_pagesize", nor->page_size);
> >>          print_size(nor->erase_size, ", total ");
> >> +       env_set_hex("sf_erasesize", nor->erase_size);
> >>          print_size(nor->size, "");
> >> +       env_set_hex("sf_size", nor->size);
> >>          puts("\n");
> >
> > I feel this unnecessarily add env variables which are not needed for
> > those SF enabled boards, isn't it?
>
> So, how do you determine current SPI NOR size from U-Boot shell ?

I think we need to know the size for those who enabled mtd command (or
mtdparts), any way to preserve it via mtd command or set the env via
mtd command side.

Jagan.


More information about the U-Boot mailing list