All of lore.kernel.org
 help / color / mirror / Atom feed
From: Tim Harvey <tharvey@gateworks.com>
To: "Peng Fan (OSS)" <peng.fan@oss.nxp.com>
Cc: Stefano Babic <sbabic@denx.de>,
	Fabio Estevam <festevam@gmail.com>, u-boot <u-boot@lists.denx.de>,
	 dl-uboot-imx <uboot-imx@nxp.com>, Peng Fan <peng.fan@nxp.com>
Subject: Re: [PATCH V2 20/26] imx: dynamic setting mmcdev and mmcroot
Date: Mon, 25 Apr 2022 12:58:26 -0700	[thread overview]
Message-ID: <CAJ+vNU3Yg07La5b2bqY9NX=xUSy=m0OPEQdtEjmvF=L51DfYFQ@mail.gmail.com> (raw)
In-Reply-To: <20220406063031.21960-21-peng.fan@oss.nxp.com>

On Tue, Apr 5, 2022 at 10:56 PM Peng Fan (OSS) <peng.fan@oss.nxp.com> wrote:
>
> From: Peng Fan <peng.fan@nxp.com>
>
> Dynamic setting mmcdev and mmcroot.
> Then when boot linux, we can have correct "root=/dev/mmcblk[x]p2"
>
> Signed-off-by: Peng Fan <peng.fan@nxp.com>
> ---
>  arch/arm/include/asm/mach-imx/sys_proto.h |  2 +
>  board/freescale/common/Makefile           |  3 ++
>  board/freescale/common/mmc.c              | 49 +++++++++++++++++++++++
>  3 files changed, 54 insertions(+)
>  create mode 100644 board/freescale/common/mmc.c
>
> diff --git a/arch/arm/include/asm/mach-imx/sys_proto.h b/arch/arm/include/asm/mach-imx/sys_proto.h
> index 0c0c7814fb2..37fd427cc00 100644
> --- a/arch/arm/include/asm/mach-imx/sys_proto.h
> +++ b/arch/arm/include/asm/mach-imx/sys_proto.h
> @@ -228,6 +228,8 @@ int mxs_reset_block(struct mxs_register_32 *reg);
>  int mxs_wait_mask_set(struct mxs_register_32 *reg, u32 mask, u32 timeout);
>  int mxs_wait_mask_clr(struct mxs_register_32 *reg, u32 mask, u32 timeout);
>
> +void board_late_mmc_env_init(void);
> +
>  unsigned long call_imx_sip(unsigned long id, unsigned long reg0,
>                            unsigned long reg1, unsigned long reg2,
>                            unsigned long reg3);
> diff --git a/board/freescale/common/Makefile b/board/freescale/common/Makefile
> index f13965daf2e..4df484935f4 100644
> --- a/board/freescale/common/Makefile
> +++ b/board/freescale/common/Makefile
> @@ -63,6 +63,9 @@ obj-$(CONFIG_ZM7300)          += zm7300.o
>  obj-$(CONFIG_POWER_PFUZE100)   += pfuze.o
>  obj-$(CONFIG_DM_PMIC_PFUZE100) += pfuze.o
>  obj-$(CONFIG_POWER_MC34VR500)  += mc34vr500.o
> +ifneq (,$(filter $(SOC), imx8ulp))
> +obj-y                          += mmc.o
> +endif
>
>  obj-$(CONFIG_LS102XA_STREAM_ID)        += ls102xa_stream_id.o
>
> diff --git a/board/freescale/common/mmc.c b/board/freescale/common/mmc.c
> new file mode 100644
> index 00000000000..8cd5079f962
> --- /dev/null
> +++ b/board/freescale/common/mmc.c
> @@ -0,0 +1,49 @@
> +// SPDX-License-Identifier: GPL-2.0+
> +/*
> + * Copyright 2016 Freescale Semiconductor, Inc.
> + * Copyright 2018-2022 NXP
> + */
> +
> +#include <common.h>
> +#include <command.h>
> +#include <asm/arch/sys_proto.h>
> +#include <linux/errno.h>
> +#include <asm/io.h>
> +#include <stdbool.h>
> +#include <mmc.h>
> +#include <env.h>
> +
> +static int check_mmc_autodetect(void)
> +{
> +       char *autodetect_str = env_get("mmcautodetect");
> +
> +       if (autodetect_str && !strcmp(autodetect_str, "yes"))
> +               return 1;
> +
> +       return 0;
> +}
> +
> +/* This should be defined for each board */
> +__weak int mmc_map_to_kernel_blk(int dev_no)
> +{
> +       return dev_no;
> +}
> +
> +void board_late_mmc_env_init(void)
> +{
> +       char cmd[32];
> +       char mmcblk[32];
> +       u32 dev_no = mmc_get_env_dev();
> +
> +       if (!check_mmc_autodetect())
> +               return;
> +
> +       env_set_ulong("mmcdev", dev_no);
> +
> +       /* Set mmcblk env */
> +       sprintf(mmcblk, "/dev/mmcblk%dp2 rootwait rw", mmc_map_to_kernel_blk(dev_no));
> +       env_set("mmcroot", mmcblk);
> +
> +       sprintf(cmd, "mmc dev %d", dev_no);
> +       run_command(cmd, 0);
> +}
> --
> 2.35.1
>

Peng,

I see Stefano already applied this but I'm not sure I agree with it.
Why should you assume that U-Boot and Linux have the same device
mapping? The kernel device mapping is not guaranteed to be consistent.
Every time I have asked about this I've been told the standard was to
use a boot script that used 'part' to determine the UUID of the boot
device from U-Boot's perspective then use root=PARTUUID= to match that
from the kernel's perspective.

For example if using CONFIG_DISTRO_DEFAULTS=y (which I think everyone
should be using) your bootscript would look like this:
part uuid ${devtype} ${devnum}:${distro_bootpart} uuid
setenv bootargs "root=PARTUUID=${uuid} rootwait $bootargs"

Best Regards,

Tim

  parent reply	other threads:[~2022-04-25 19:58 UTC|newest]

Thread overview: 57+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-06  6:30 [PATCH V2 00/26] imx: imx8ulp: misc update from downstream Peng Fan (OSS)
2022-04-06  6:30 ` [PATCH V2 01/26] imx: imx8ulp: Set COUNTER_FREQUENCY to 1Mhz Peng Fan (OSS)
2022-04-12 18:43   ` sbabic
2022-04-06  6:30 ` [PATCH V2 02/26] imx: imx8ulp: include pcc/cgc header in clock header Peng Fan (OSS)
2022-04-12 18:46   ` sbabic
2022-04-06  6:30 ` [PATCH V2 03/26] imx: imx8ulp: Add M33 handshake functions Peng Fan (OSS)
2022-04-12 18:46   ` sbabic
2022-04-06  6:30 ` [PATCH V2 04/26] imx: imx8ulp: clock: Add clock support for i3c controller Peng Fan (OSS)
2022-04-12 18:44   ` sbabic
2022-04-06  6:30 ` [PATCH V2 05/26] imx: imx8ulp: add CAAM clock entry Peng Fan (OSS)
2022-04-12 18:43   ` sbabic
2022-04-06  6:30 ` [PATCH V2 06/26] imx: imx8ulp_evk: Remove PMIC Bucks PWM mode settings Peng Fan (OSS)
2022-04-12 18:42   ` sbabic
2022-04-06  6:30 ` [PATCH V2 07/26] imx: imx8ulp: add ND/LD clock Peng Fan (OSS)
2022-04-12 18:43   ` sbabic
2022-04-06  6:30 ` [PATCH V2 08/26] imx: imx8ulp_evk: Skip init DDR for reboot in dual boot mode Peng Fan (OSS)
2022-04-12 18:45   ` sbabic
2022-04-06  6:30 ` [PATCH V2 09/26] imx: imx8ulp: cgc: Switch to NICLPAV to FRO192 before PLL4 init Peng Fan (OSS)
2022-04-12 18:45   ` sbabic
2022-04-06  6:30 ` [PATCH V2 10/26] imx: imx8ulp: enable MU0_B clk by default Peng Fan (OSS)
2022-04-12 18:46   ` sbabic
2022-04-06  6:30 ` [PATCH V2 11/26] misc: imx8ulp: Add OEM SRK Hash fuse support Peng Fan (OSS)
2022-04-12 18:46   ` sbabic
2022-04-06  6:30 ` [PATCH V2 12/26] imx: imx8ulp: Change LPAV assignment for dual boot Peng Fan (OSS)
2022-04-12 18:42   ` sbabic
2022-04-06  6:30 ` [PATCH V2 13/26] imx: imx8ulp: Load the lposc fuse " Peng Fan (OSS)
2022-04-12 18:47   ` sbabic
2022-04-06  6:30 ` [PATCH V2 14/26] misc: S400_API: add ahab_release_caam Peng Fan (OSS)
2022-04-12 18:41   ` sbabic
2022-04-06  6:30 ` [PATCH V2 15/26] misc: S400_API: Update S400 API for buffer dump Peng Fan (OSS)
2022-04-12 18:47   ` sbabic
2022-04-06  6:30 ` [PATCH V2 16/26] imx: imx8ulp: release CAAM for the Cortex-A35 Peng Fan (OSS)
2022-04-12 18:47   ` sbabic
2022-04-06  6:30 ` [PATCH V2 17/26] imx: imx8ulp_evk: Update LPDDR4 PHY settings Peng Fan (OSS)
2022-04-12 18:42   ` sbabic
2022-04-06  6:30 ` [PATCH V2 18/26] imx: imx8ulp_evk: call the handshake with M33 Peng Fan (OSS)
2022-04-12 18:47   ` sbabic
2022-04-06  6:30 ` [PATCH V2 19/26] imx: imx8ulp_evk: Power down the domains may used in u-boot Peng Fan (OSS)
2022-04-12 17:10   ` Stefano Babic
2022-04-13  3:00     ` Peng Fan (OSS)
2022-04-13  7:45       ` Stefano Babic
2022-04-06  6:30 ` [PATCH V2 20/26] imx: dynamic setting mmcdev and mmcroot Peng Fan (OSS)
2022-04-12 18:45   ` sbabic
2022-04-25 19:58   ` Tim Harvey [this message]
2022-04-26 11:24     ` Peng Fan (OSS)
2022-04-06  6:30 ` [PATCH V2 21/26] imx: imx8ulp_evk: Enable SD/MMC port auto detect Peng Fan (OSS)
2022-04-12 18:46   ` sbabic
2022-04-06  6:30 ` [PATCH V2 22/26] imx: imx8ulp: enable wdog_ad interrupt in CMC1 Peng Fan (OSS)
2022-04-12 18:47   ` sbabic
2022-04-06  6:30 ` [PATCH V2 23/26] imx: imx8ulp: reserve tee memory Peng Fan (OSS)
2022-04-12 18:43   ` sbabic
2022-04-06  6:30 ` [PATCH V2 24/26] imx: imx8ulp_evk: enlarge CONFIG_NR_DRAM_BANKS Peng Fan (OSS)
2022-04-12 18:43   ` sbabic
2022-04-06  6:30 ` [PATCH V2 25/26] imx: imx8ulp_evk: Enable multiple env storage devices Peng Fan (OSS)
2022-04-12 18:43   ` sbabic
2022-04-06  6:30 ` [PATCH V2 26/26] misc: imx8ulp: Update fuse driver Peng Fan (OSS)
2022-04-12 18:46   ` sbabic

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAJ+vNU3Yg07La5b2bqY9NX=xUSy=m0OPEQdtEjmvF=L51DfYFQ@mail.gmail.com' \
    --to=tharvey@gateworks.com \
    --cc=festevam@gmail.com \
    --cc=peng.fan@nxp.com \
    --cc=peng.fan@oss.nxp.com \
    --cc=sbabic@denx.de \
    --cc=u-boot@lists.denx.de \
    --cc=uboot-imx@nxp.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.