[PATCH v2 2/3] mci: imx-esdhc-pbl: support eMMC boot partitions on i.MX8MP

Sascha Hauer sha at pengutronix.de
Mon Oct 4 04:41:59 PDT 2021


On Mon, Oct 04, 2021 at 01:00:19PM +0200, Ahmad Fatoum wrote:
> Hello Sascha,
> 
> On 04.10.21 12:56, Sascha Hauer wrote:
> > On Mon, Aug 30, 2021 at 01:51:55PM +0200, Ahmad Fatoum wrote:
> >> The i.MX header for SD/MMC starts at an offset to allow for a partition
> >> table at offset 0. i.MX8MN/P bootrom did away with the offset for eMMC
> >> boot partitions, which usually lack on-disk partition tables, but kept a
> >> 32-byte offset for SD and eMMC user partitions.
> >>
> >> The i.MX8MN/P also introduced a ROM API that allows chainloading from
> >> boot medium by calling back into ROM. This likely handles that
> >> difference for us, but as we don't support it yet and we already have
> >> the PBL eSDHC driver, teach it to detect whether boot is from eMMC boot
> >> partition or not and use the appropriate offset.
> >>
> >> Signed-off-by: Ahmad Fatoum <a.fatoum at pengutronix.de>
> >> ---
> >> v1 -> v2:
> >>   - new patch. Without, barebox can be written, but not booted.
> >>     Tested on i.MX8MN.
> >> ---
> >>  drivers/mci/imx-esdhc-pbl.c | 39 ++++++++++++++++++++++++++++++++++++-
> >>  1 file changed, 38 insertions(+), 1 deletion(-)
> >>
> >> diff --git a/drivers/mci/imx-esdhc-pbl.c b/drivers/mci/imx-esdhc-pbl.c
> >> index e649eb8bbafb..66df4f6dfc74 100644
> >> --- a/drivers/mci/imx-esdhc-pbl.c
> >> +++ b/drivers/mci/imx-esdhc-pbl.c
> >> @@ -25,6 +25,40 @@
> >>  
> >>  #define esdhc_send_cmd	__esdhc_send_cmd
> >>  
> >> +static u8 ext_csd[512] __aligned(64);
> >> +
> >> +static int esdhc_send_ext_csd(struct fsl_esdhc_host *host)
> >> +{
> >> +	struct mci_cmd cmd;
> >> +	struct mci_data data;
> >> +
> >> +	cmd.cmdidx = MMC_CMD_SEND_EXT_CSD;
> >> +	cmd.cmdarg = 0;
> >> +	cmd.resp_type = MMC_RSP_R1;
> >> +
> >> +	data.dest = ext_csd;
> >> +	data.blocks = 1;
> >> +	data.blocksize = sizeof(ext_csd);
> >> +	data.flags = MMC_DATA_READ;
> >> +
> >> +	return esdhc_send_cmd(host, &cmd, &data);
> >> +}
> > 
> > Is this operation valid for SD cards as well? If not we would first have
> > to know if we have a SD or eMMC card.
> 
> This has been tested on both SD and eMMC cards.
> In SD case, esdhc_send_cmd will fail and esdhc_bootpart_active will
> return false. In MMC case, it will succeed and result will be
> evaluated.

Ok, applied then.

Sascha


-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |



More information about the barebox mailing list