[U-Boot] [PATCH v3 29/58] sunxi: Get fat device wrt boot device, 'auto' partition
Maxime Ripard
maxime.ripard at bootlin.com
Mon Aug 20 11:45:47 UTC 2018
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 <jagan at amarulasolutions.com>
> ---
> 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 <common.h>
> +#include <fat.h>
> #include <mmc.h>
> #include <i2c.h>
> #include <serial.h>
> @@ -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: <http://lists.denx.de/pipermail/u-boot/attachments/20180820/6a377049/attachment.sig>
More information about the U-Boot
mailing list