This adds an easy way to enable the boot acknowledge function of a eMMC device, without the need to frob the EXT_CSD setting via the mmc_extcsd command. A boot ack is required whenever the boot partitions are read via the fast initialization boot protocol. Signed-off-by: Lucas Stach <l.stach@pengutronix.de> --- drivers/mci/mci-core.c | 33 +++++++++++++++++++++++++++------ include/mci.h | 2 ++ 2 files changed, 29 insertions(+), 6 deletions(-) diff --git a/drivers/mci/mci-core.c b/drivers/mci/mci-core.c index f3718327f18d..d33bc0c1a41e 100644 --- a/drivers/mci/mci-core.c +++ b/drivers/mci/mci-core.c @@ -516,6 +516,7 @@ static int mmc_change_freq(struct mci *mci) mci->ext_csd_part_config = mci->ext_csd[EXT_CSD_PARTITION_CONFIG]; mci->bootpart = (mci->ext_csd_part_config >> 3) & 0x7; + mci->boot_ack_enable = (mci->ext_csd_part_config >> 6) & 0x1; } return 0; @@ -1592,6 +1593,17 @@ static int mci_set_boot(struct param_d *param, void *priv) EXT_CSD_PARTITION_CONFIG, mci->ext_csd_part_config); } +static int mci_set_boot_ack(struct param_d *param, void *priv) +{ + struct mci *mci = priv; + + mci->ext_csd_part_config &= ~(0x1 << 6); + mci->ext_csd_part_config |= mci->boot_ack_enable << 6; + + return mci_switch(mci, + EXT_CSD_PARTITION_CONFIG, mci->ext_csd_part_config); +} + static const char *mci_boot_names[] = { "disabled", "boot0", @@ -1672,6 +1684,7 @@ static int mci_card_probe(struct mci *mci) { struct mci_host *host = mci->host; int i, rc, disknum, ret; + bool has_bootpart = false; if (host->card_present && !host->card_present(host) && !host->non_removable) { @@ -1741,12 +1754,20 @@ static int mci_card_probe(struct mci *mci) rc = mci_register_partition(part); if (IS_ENABLED(CONFIG_MCI_MMC_BOOT_PARTITIONS) && - part->area_type == MMC_BLK_DATA_AREA_BOOT && - !mci->param_boot) { - mci->param_boot = dev_add_param_enum(&mci->dev, "boot", - mci_set_boot, NULL, &mci->bootpart, - mci_boot_names, ARRAY_SIZE(mci_boot_names), mci); - } + part->area_type == MMC_BLK_DATA_AREA_BOOT) + has_bootpart = true; + } + + if (has_bootpart) { + mci->param_boot = + dev_add_param_enum(&mci->dev, "boot", mci_set_boot, + NULL, &mci->bootpart, mci_boot_names, + ARRAY_SIZE(mci_boot_names), mci); + + mci->param_boot_ack = + dev_add_param_bool(&mci->dev, "boot_ack", + mci_set_boot_ack, NULL, + &mci->boot_ack_enable, mci); } dev_dbg(&mci->dev, "SD Card successfully added\n"); diff --git a/include/mci.h b/include/mci.h index cf9d188c5c21..587c76678c96 100644 --- a/include/mci.h +++ b/include/mci.h @@ -462,7 +462,9 @@ struct mci { char *ext_csd; int probe; struct param_d *param_boot; + struct param_d *param_boot_ack; int bootpart; + int boot_ack_enable; struct mci_part part[MMC_NUM_PHY_PARTITION]; int nr_parts; -- 2.20.1 _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox
On Wed, May 13, 2020 at 01:46:36PM +0200, Lucas Stach wrote: > This adds an easy way to enable the boot acknowledge function of > a eMMC device, without the need to frob the EXT_CSD setting via > the mmc_extcsd command. > A boot ack is required whenever the boot partitions are read via > the fast initialization boot protocol. > > Signed-off-by: Lucas Stach <l.stach@pengutronix.de> > --- > drivers/mci/mci-core.c | 33 +++++++++++++++++++++++++++------ > include/mci.h | 2 ++ > 2 files changed, 29 insertions(+), 6 deletions(-) > > diff --git a/drivers/mci/mci-core.c b/drivers/mci/mci-core.c > index f3718327f18d..d33bc0c1a41e 100644 > --- a/drivers/mci/mci-core.c > +++ b/drivers/mci/mci-core.c > @@ -516,6 +516,7 @@ static int mmc_change_freq(struct mci *mci) > > mci->ext_csd_part_config = mci->ext_csd[EXT_CSD_PARTITION_CONFIG]; > mci->bootpart = (mci->ext_csd_part_config >> 3) & 0x7; > + mci->boot_ack_enable = (mci->ext_csd_part_config >> 6) & 0x1; > } > > return 0; > @@ -1592,6 +1593,17 @@ static int mci_set_boot(struct param_d *param, void *priv) > EXT_CSD_PARTITION_CONFIG, mci->ext_csd_part_config); > } > > +static int mci_set_boot_ack(struct param_d *param, void *priv) > +{ > + struct mci *mci = priv; > + > + mci->ext_csd_part_config &= ~(0x1 << 6); > + mci->ext_csd_part_config |= mci->boot_ack_enable << 6; > + > + return mci_switch(mci, > + EXT_CSD_PARTITION_CONFIG, mci->ext_csd_part_config); > +} There's only one correct setting for each board or SoC. Instead of letting the user choose between right and wrong, can't we add a hook to be called from the board/SoC code? A device tree property might be an option as well, something like barebox,enable-boot-ack. There are also bits to change the bus width after power up which might need adjustments which would mean another parameter with the current approach. 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 | _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox
Am Montag, den 18.05.2020, 09:08 +0200 schrieb Sascha Hauer: > On Wed, May 13, 2020 at 01:46:36PM +0200, Lucas Stach wrote: > > This adds an easy way to enable the boot acknowledge function of > > a eMMC device, without the need to frob the EXT_CSD setting via > > the mmc_extcsd command. > > A boot ack is required whenever the boot partitions are read via > > the fast initialization boot protocol. > > > > Signed-off-by: Lucas Stach <l.stach@pengutronix.de> > > --- > > drivers/mci/mci-core.c | 33 +++++++++++++++++++++++++++------ > > include/mci.h | 2 ++ > > 2 files changed, 29 insertions(+), 6 deletions(-) > > > > diff --git a/drivers/mci/mci-core.c b/drivers/mci/mci-core.c > > index f3718327f18d..d33bc0c1a41e 100644 > > --- a/drivers/mci/mci-core.c > > +++ b/drivers/mci/mci-core.c > > @@ -516,6 +516,7 @@ static int mmc_change_freq(struct mci *mci) > > > > mci->ext_csd_part_config = mci->ext_csd[EXT_CSD_PARTITION_CONFIG]; > > mci->bootpart = (mci->ext_csd_part_config >> 3) & 0x7; > > + mci->boot_ack_enable = (mci->ext_csd_part_config >> 6) & 0x1; > > } > > > > return 0; > > @@ -1592,6 +1593,17 @@ static int mci_set_boot(struct param_d *param, void *priv) > > EXT_CSD_PARTITION_CONFIG, mci->ext_csd_part_config); > > } > > > > +static int mci_set_boot_ack(struct param_d *param, void *priv) > > +{ > > + struct mci *mci = priv; > > + > > + mci->ext_csd_part_config &= ~(0x1 << 6); > > + mci->ext_csd_part_config |= mci->boot_ack_enable << 6; > > + > > + return mci_switch(mci, > > + EXT_CSD_PARTITION_CONFIG, mci->ext_csd_part_config); > > +} > > There's only one correct setting for each board or SoC. Instead of > letting the user choose between right and wrong, can't we add a hook to > be called from the board/SoC code? A device tree property might be an > option as well, something like barebox,enable-boot-ack. A DT property might work, but my initial line of thinking was to set this from a platform specific barebox_update call, where having the parameter would certainly help to keep some sort of abstraction. Regards, Lucas _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox
On Mon, 2020-05-18 at 09:08 +0200, Sascha Hauer wrote: > There's only one correct setting for each board or SoC. Instead of > letting the user choose between right and wrong, can't we add a hook > to be called from the board/SoC code? A device tree property might be > an option as well, something like barebox,enable-boot-ack. > > There are also bits to change the bus width after power up which > might need adjustments which would mean another parameter with the > current approach. If I remember the i.MX6 eMMC boot process correctly, there is no single correct configuration, even for a fixed HW layout. The eFUSE and eMMC EXT-CDS configuration just needs to match. Instead of trying to handle all the corner cases correctly (which is hard to test without permanently fusing HW), I'd prefer to just make it straight-forward to set and inspect these values (via a command or device parameters). Then these would be set once during board manufacturing/bring-up. After bring-up, the value in DT would be redundant configuration and could lead to confusion if it conflicts with the FUSEs. Regards, Jan -- Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 | _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox
Hello Sascha, On 18.05.20 09:08, Sascha Hauer wrote: > On Wed, May 13, 2020 at 01:46:36PM +0200, Lucas Stach wrote: >> This adds an easy way to enable the boot acknowledge function of >> a eMMC device, without the need to frob the EXT_CSD setting via >> the mmc_extcsd command. >> A boot ack is required whenever the boot partitions are read via >> the fast initialization boot protocol. >> >> Signed-off-by: Lucas Stach <l.stach@pengutronix.de> >> --- >> drivers/mci/mci-core.c | 33 +++++++++++++++++++++++++++------ >> include/mci.h | 2 ++ >> 2 files changed, 29 insertions(+), 6 deletions(-) >> >> diff --git a/drivers/mci/mci-core.c b/drivers/mci/mci-core.c >> index f3718327f18d..d33bc0c1a41e 100644 >> --- a/drivers/mci/mci-core.c >> +++ b/drivers/mci/mci-core.c >> @@ -516,6 +516,7 @@ static int mmc_change_freq(struct mci *mci) >> >> mci->ext_csd_part_config = mci->ext_csd[EXT_CSD_PARTITION_CONFIG]; >> mci->bootpart = (mci->ext_csd_part_config >> 3) & 0x7; >> + mci->boot_ack_enable = (mci->ext_csd_part_config >> 6) & 0x1; >> } >> >> return 0; >> @@ -1592,6 +1593,17 @@ static int mci_set_boot(struct param_d *param, void *priv) >> EXT_CSD_PARTITION_CONFIG, mci->ext_csd_part_config); >> } >> >> +static int mci_set_boot_ack(struct param_d *param, void *priv) >> +{ >> + struct mci *mci = priv; >> + >> + mci->ext_csd_part_config &= ~(0x1 << 6); >> + mci->ext_csd_part_config |= mci->boot_ack_enable << 6; >> + >> + return mci_switch(mci, >> + EXT_CSD_PARTITION_CONFIG, mci->ext_csd_part_config); >> +} > > There's only one correct setting for each board or SoC. Instead of > letting the user choose between right and wrong, can't we add a hook to > be called from the board/SoC code? A device tree property might be an > option as well, something like barebox,enable-boot-ack. > > There are also bits to change the bus width after power up which might > need adjustments which would mean another parameter with the current > approach. There hasn't been any progress here for 2 years. Sascha, can we just take this patch? Even if we add code in future to have this happen as part of eMMC/SoC init, a device parameter to easily check the current configuration would still be useful. Cheers, Ahmad > > 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 | _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox
On Fri, May 20, 2022 at 06:34:43AM +0200, Ahmad Fatoum wrote: > Hello Sascha, > > On 18.05.20 09:08, Sascha Hauer wrote: > > On Wed, May 13, 2020 at 01:46:36PM +0200, Lucas Stach wrote: > >> This adds an easy way to enable the boot acknowledge function of > >> a eMMC device, without the need to frob the EXT_CSD setting via > >> the mmc_extcsd command. > >> A boot ack is required whenever the boot partitions are read via > >> the fast initialization boot protocol. > >> > >> Signed-off-by: Lucas Stach <l.stach@pengutronix.de> > >> --- > >> drivers/mci/mci-core.c | 33 +++++++++++++++++++++++++++------ > >> include/mci.h | 2 ++ > >> 2 files changed, 29 insertions(+), 6 deletions(-) > >> > >> diff --git a/drivers/mci/mci-core.c b/drivers/mci/mci-core.c > >> index f3718327f18d..d33bc0c1a41e 100644 > >> --- a/drivers/mci/mci-core.c > >> +++ b/drivers/mci/mci-core.c > >> @@ -516,6 +516,7 @@ static int mmc_change_freq(struct mci *mci) > >> > >> mci->ext_csd_part_config = mci->ext_csd[EXT_CSD_PARTITION_CONFIG]; > >> mci->bootpart = (mci->ext_csd_part_config >> 3) & 0x7; > >> + mci->boot_ack_enable = (mci->ext_csd_part_config >> 6) & 0x1; > >> } > >> > >> return 0; > >> @@ -1592,6 +1593,17 @@ static int mci_set_boot(struct param_d *param, void *priv) > >> EXT_CSD_PARTITION_CONFIG, mci->ext_csd_part_config); > >> } > >> > >> +static int mci_set_boot_ack(struct param_d *param, void *priv) > >> +{ > >> + struct mci *mci = priv; > >> + > >> + mci->ext_csd_part_config &= ~(0x1 << 6); > >> + mci->ext_csd_part_config |= mci->boot_ack_enable << 6; > >> + > >> + return mci_switch(mci, > >> + EXT_CSD_PARTITION_CONFIG, mci->ext_csd_part_config); > >> +} > > > > There's only one correct setting for each board or SoC. Instead of > > letting the user choose between right and wrong, can't we add a hook to > > be called from the board/SoC code? A device tree property might be an > > option as well, something like barebox,enable-boot-ack. > > > > There are also bits to change the bus width after power up which might > > need adjustments which would mean another parameter with the current > > approach. > > There hasn't been any progress here for 2 years. Sascha, can we just > take this patch? Even if we add code in future to have this happen as > part of eMMC/SoC init, a device parameter to easily check > the current configuration would still be useful. Ok then, let's go for it. 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 | _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox