From: Maxime Ripard Date: Mon, 20 Aug 2018 13:45:47 +0200 Subject: [U-Boot] [PATCH v3 29/58] sunxi: Get fat device wrt boot device, 'auto' partition In-Reply-To: <20180819135715.15799-30-jagan@amarulasolutions.com> References: <20180819135715.15799-1-jagan@amarulasolutions.com> <20180819135715.15799-30-jagan@amarulasolutions.com> Message-ID: <20180820114547.zkry4u7ekyffprou@flea> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de On Sun, Aug 19, 2018 at 07:26:46PM +0530, Jagan Teki wrote: > Setting fat device, partition using CONFIG_ENV_FAT_DEVICE_AND_PART > via Kconfig option is difficult to maintain since Allwinner > support more than one mmc controllers with SD and eMMC. > > So, add dynamic function to get the device based on the > boot device source with 'auto' partition. > > Signed-off-by: Jagan Teki > --- > arch/arm/mach-sunxi/board.c | 50 +++++++++++++++++++++++++++++++++++++ > 1 file changed, 50 insertions(+) > > diff --git a/arch/arm/mach-sunxi/board.c b/arch/arm/mach-sunxi/board.c > index d22a84ea6b..cf174bd0a3 100644 > --- a/arch/arm/mach-sunxi/board.c > +++ b/arch/arm/mach-sunxi/board.c > @@ -10,6 +10,7 @@ > */ > > #include > +#include > #include > #include > #include > @@ -253,6 +254,55 @@ uint32_t sunxi_get_boot_device(void) > return -1; /* Never reached */ > } > > +#if CONFIG_IS_ENABLED(ENV_IS_IN_FAT) > +static int find_first_sd_device(void) > +{ > + struct mmc *mmc; > + int i; > + > + for (i = 0; (mmc = find_mmc_device(i)); i++) { > + if (!mmc_init(mmc) && IS_SD(mmc)) > + return i; > + } > + > + return -ENODEV; > +} > + > +static int find_first_mmc_device(void) > +{ > + struct mmc *mmc; > + int i; > + > + for (i = 0; (mmc = find_mmc_device(i)); i++) { > + if (!mmc_init(mmc) && IS_MMC(mmc)) > + return i; > + } > + > + return -ENODEV; > +} > + > +char *get_env_fat_dev_part(void) > +{ > + int devno, boot_source; > + static char dev_part[10]; > + > + boot_source = readb(SPL_ADDR + 0x28); > + switch (boot_source) { > + case SUNXI_BOOTED_FROM_MMC0: > + devno = find_first_sd_device(); > + break; > + case SUNXI_BOOTED_FROM_MMC2: > + devno = find_first_mmc_device(); > + break; You're changing the behaviour from having the environment fixed in a particular device to detecting that device at runtime. Again, can't we use a DT property for this instead? Maxime -- Maxime Ripard, Bootlin (formerly Free Electrons) Embedded Linux and Kernel engineering https://bootlin.com -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 833 bytes Desc: not available URL: