diff mbox

[U-Boot,v2,7/8] cmd_mmc.c: Add bootbus mmc sub-command

Message ID 1391117520-21868-7-git-send-email-trini@ti.com
State Superseded
Delegated to: Pantelis Antoniou
Headers show

Commit Message

Tom Rini Jan. 30, 2014, 9:31 p.m. UTC
Add a bootbus sub-command to the mmc command to allow for setting
the boot_bus_width, reset_boot_bus_width and boot_mode fields of
BOOT_BUS_WIDTH (EXT_CSD[177]).

Signed-off-by: Tom Rini <trini@ti.com>
---
 common/cmd_mmc.c  |   29 +++++++++++++++++++++++++++++
 drivers/mmc/mmc.c |   21 +++++++++++++++++++++
 include/mmc.h     |    5 +++++
 3 files changed, 55 insertions(+)

Comments

Jaehoon Chung Feb. 4, 2014, 12:59 a.m. UTC | #1
Acked-by: Jaehoon Chung <jh80.chung@samsung.com>

On 01/31/2014 06:31 AM, Tom Rini wrote:
> Add a bootbus sub-command to the mmc command to allow for setting
> the boot_bus_width, reset_boot_bus_width and boot_mode fields of
> BOOT_BUS_WIDTH (EXT_CSD[177]).
> 
> Signed-off-by: Tom Rini <trini@ti.com>
> ---
>  common/cmd_mmc.c  |   29 +++++++++++++++++++++++++++++
>  drivers/mmc/mmc.c |   21 +++++++++++++++++++++
>  include/mmc.h     |    5 +++++
>  3 files changed, 55 insertions(+)
> 
> diff --git a/common/cmd_mmc.c b/common/cmd_mmc.c
> index 5842e85..a028149 100644
> --- a/common/cmd_mmc.c
> +++ b/common/cmd_mmc.c
> @@ -338,6 +338,33 @@ static int do_mmcops(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
>  
>  		/* acknowledge to be sent during boot operation */
>  		return mmc_set_part_conf(mmc, ack, part_num, access);
> +	} else if (strcmp(argv[1], "bootbus") == 0) {
> +		int dev;
> +		struct mmc *mmc;
> +		u8 width, reset, mode;
> +
> +		if (argc == 6) {
> +			dev = simple_strtoul(argv[2], NULL, 10);
> +			width = simple_strtoul(argv[3], NULL, 10);
> +			reset = simple_strtoul(argv[4], NULL, 10);
> +			mode = simple_strtoul(argv[5], NULL, 10);
> +		} else {
> +			return CMD_RET_USAGE;
> +		}
> +
> +		mmc = find_mmc_device(dev);
> +		if (!mmc) {
> +			printf("no mmc device at slot %x\n", dev);
> +			return 1;
> +		}
> +
> +		if (IS_SD(mmc)) {
> +			puts("BOOT_BUS_WIDTH only exists on eMMC\n");
> +			return 1;
> +		}
> +
> +		/* acknowledge to be sent during boot operation */
> +		return mmc_set_boot_bus_width(mmc, width, reset, mode);
>  	} else if (strcmp(argv[1], "bootpart-resize") == 0) {
>  		int dev;
>  		struct mmc *mmc;
> @@ -475,6 +502,8 @@ U_BOOT_CMD(
>  	" - Enable boot_part for booting and enable R/W access of boot_part\n"
>  	"mmc close <dev> <boot_partition>\n"
>  	" - Enable boot_part for booting and disable access to boot_part\n"
> +	"mmc bootbus dev boot_bus_width reset_boot_bus_width boot_mode\n"
> +	" - Set the BOOT_BUS_WIDTH field of the specified device\n"
>  	"mmc bootpart-resize <dev> <boot part size MB> <RPMB part size MB>\n"
>  	" - Change sizes of boot and RPMB partitions of specified device\n"
>  	"mmc partconf dev boot_ack boot_partition partition_access\n"
> diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c
> index 1591fce..fc1c1dc 100644
> --- a/drivers/mmc/mmc.c
> +++ b/drivers/mmc/mmc.c
> @@ -1507,6 +1507,27 @@ int mmc_boot_part_access(struct mmc *mmc, u8 ack, u8 part_num, u8 access)
>  }
>  
>  /*
> + * Modify EXT_CSD[177] which is BOOT_BUS_WIDTH
> + * based on the passed in values for BOOT_BUS_WIDTH, RESET_BOOT_BUS_WIDTH
> + * and BOOT_MODE.
> + *
> + * Returns 0 on success.
> + */
> +int mmc_set_boot_bus_width(struct mmc *mmc, u8 width, u8 reset, u8 mode)
> +{
> +	int err;
> +
> +	err = mmc_switch(mmc, EXT_CSD_CMD_SET_NORMAL, EXT_CSD_BOOT_BUS_WIDTH,
> +			 EXT_CSD_BOOT_BUS_WIDTH_MODE(mode) |
> +			 EXT_CSD_BOOT_BUS_WIDTH_RESET(reset) |
> +			 EXT_CSD_BOOT_BUS_WIDTH_WIDTH(width));
> +
> +	if (err)
> +		return err;
> +	return 0;
> +}
> +
> +/*
>   * Modify EXT_CSD[179] which is PARTITION_CONFIG (formerly BOOT_CONFIG)
>   * based on the passed in values for BOOT_ACK, BOOT_PARTITION_ENABLE and
>   * PARTITION_ACCESS.
> diff --git a/include/mmc.h b/include/mmc.h
> index 7e026da..3594286 100644
> --- a/include/mmc.h
> +++ b/include/mmc.h
> @@ -187,6 +187,9 @@
>  #define EXT_CSD_BOOT_PART_NUM(x)	(x << 3)
>  #define EXT_CSD_PARTITION_ACCESS(x)	(x << 0)
>  
> +#define EXT_CSD_BOOT_BUS_WIDTH_MODE(x)	(x << 3)
> +#define EXT_CSD_BOOT_BUS_WIDTH_RESET(x)	(x << 2)
> +#define EXT_CSD_BOOT_BUS_WIDTH_WIDTH(x)	(x)
>  
>  #define R1_ILLEGAL_COMMAND		(1 << 22)
>  #define R1_APP_CMD			(1 << 5)
> @@ -314,6 +317,8 @@ int mmc_boot_partition_size_change(struct mmc *mmc, unsigned long bootsize,
>  int mmc_boot_part_access(struct mmc *mmc, u8 ack, u8 part_num, u8 access);
>  /* Function to modify the PARTITION_CONFIG field of EXT_CSD */
>  int mmc_set_part_conf(struct mmc *mmc, u8 ack, u8 part_num, u8 access);
> +/* Function to modify the BOOT_BUS_WIDTH field of EXT_CSD */
> +int mmc_set_boot_bus_width(struct mmc *mmc, u8 width, u8 reset, u8 mode);
>  
>  /**
>   * Start device initialization and return immediately; it does not block on
>
Michael Nazzareno Trimarchi April 18, 2014, 9:25 a.m. UTC | #2
Hi Tom

On Thu, Jan 30, 2014 at 10:31 PM, Tom Rini <trini@ti.com> wrote:
> Add a bootbus sub-command to the mmc command to allow for setting
> the boot_bus_width, reset_boot_bus_width and boot_mode fields of
> BOOT_BUS_WIDTH (EXT_CSD[177]).
>
> Signed-off-by: Tom Rini <trini@ti.com>
> ---

Can I ask if does it work even for OMAP4 device?
So can I flash on boot0 and let omap4 bootrom to load from that?

Michael

>  common/cmd_mmc.c  |   29 +++++++++++++++++++++++++++++
>  drivers/mmc/mmc.c |   21 +++++++++++++++++++++
>  include/mmc.h     |    5 +++++
>  3 files changed, 55 insertions(+)
>
> diff --git a/common/cmd_mmc.c b/common/cmd_mmc.c
> index 5842e85..a028149 100644
> --- a/common/cmd_mmc.c
> +++ b/common/cmd_mmc.c
> @@ -338,6 +338,33 @@ static int do_mmcops(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
>
>                 /* acknowledge to be sent during boot operation */
>                 return mmc_set_part_conf(mmc, ack, part_num, access);
> +       } else if (strcmp(argv[1], "bootbus") == 0) {
> +               int dev;
> +               struct mmc *mmc;
> +               u8 width, reset, mode;
> +
> +               if (argc == 6) {
> +                       dev = simple_strtoul(argv[2], NULL, 10);
> +                       width = simple_strtoul(argv[3], NULL, 10);
> +                       reset = simple_strtoul(argv[4], NULL, 10);
> +                       mode = simple_strtoul(argv[5], NULL, 10);
> +               } else {
> +                       return CMD_RET_USAGE;
> +               }
> +
> +               mmc = find_mmc_device(dev);
> +               if (!mmc) {
> +                       printf("no mmc device at slot %x\n", dev);
> +                       return 1;
> +               }
> +
> +               if (IS_SD(mmc)) {
> +                       puts("BOOT_BUS_WIDTH only exists on eMMC\n");
> +                       return 1;
> +               }
> +
> +               /* acknowledge to be sent during boot operation */
> +               return mmc_set_boot_bus_width(mmc, width, reset, mode);
>         } else if (strcmp(argv[1], "bootpart-resize") == 0) {
>                 int dev;
>                 struct mmc *mmc;
> @@ -475,6 +502,8 @@ U_BOOT_CMD(
>         " - Enable boot_part for booting and enable R/W access of boot_part\n"
>         "mmc close <dev> <boot_partition>\n"
>         " - Enable boot_part for booting and disable access to boot_part\n"
> +       "mmc bootbus dev boot_bus_width reset_boot_bus_width boot_mode\n"
> +       " - Set the BOOT_BUS_WIDTH field of the specified device\n"
>         "mmc bootpart-resize <dev> <boot part size MB> <RPMB part size MB>\n"
>         " - Change sizes of boot and RPMB partitions of specified device\n"
>         "mmc partconf dev boot_ack boot_partition partition_access\n"
> diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c
> index 1591fce..fc1c1dc 100644
> --- a/drivers/mmc/mmc.c
> +++ b/drivers/mmc/mmc.c
> @@ -1507,6 +1507,27 @@ int mmc_boot_part_access(struct mmc *mmc, u8 ack, u8 part_num, u8 access)
>  }
>
>  /*
> + * Modify EXT_CSD[177] which is BOOT_BUS_WIDTH
> + * based on the passed in values for BOOT_BUS_WIDTH, RESET_BOOT_BUS_WIDTH
> + * and BOOT_MODE.
> + *
> + * Returns 0 on success.
> + */
> +int mmc_set_boot_bus_width(struct mmc *mmc, u8 width, u8 reset, u8 mode)
> +{
> +       int err;
> +
> +       err = mmc_switch(mmc, EXT_CSD_CMD_SET_NORMAL, EXT_CSD_BOOT_BUS_WIDTH,
> +                        EXT_CSD_BOOT_BUS_WIDTH_MODE(mode) |
> +                        EXT_CSD_BOOT_BUS_WIDTH_RESET(reset) |
> +                        EXT_CSD_BOOT_BUS_WIDTH_WIDTH(width));
> +
> +       if (err)
> +               return err;
> +       return 0;
> +}
> +
> +/*
>   * Modify EXT_CSD[179] which is PARTITION_CONFIG (formerly BOOT_CONFIG)
>   * based on the passed in values for BOOT_ACK, BOOT_PARTITION_ENABLE and
>   * PARTITION_ACCESS.
> diff --git a/include/mmc.h b/include/mmc.h
> index 7e026da..3594286 100644
> --- a/include/mmc.h
> +++ b/include/mmc.h
> @@ -187,6 +187,9 @@
>  #define EXT_CSD_BOOT_PART_NUM(x)       (x << 3)
>  #define EXT_CSD_PARTITION_ACCESS(x)    (x << 0)
>
> +#define EXT_CSD_BOOT_BUS_WIDTH_MODE(x) (x << 3)
> +#define EXT_CSD_BOOT_BUS_WIDTH_RESET(x)        (x << 2)
> +#define EXT_CSD_BOOT_BUS_WIDTH_WIDTH(x)        (x)
>
>  #define R1_ILLEGAL_COMMAND             (1 << 22)
>  #define R1_APP_CMD                     (1 << 5)
> @@ -314,6 +317,8 @@ int mmc_boot_partition_size_change(struct mmc *mmc, unsigned long bootsize,
>  int mmc_boot_part_access(struct mmc *mmc, u8 ack, u8 part_num, u8 access);
>  /* Function to modify the PARTITION_CONFIG field of EXT_CSD */
>  int mmc_set_part_conf(struct mmc *mmc, u8 ack, u8 part_num, u8 access);
> +/* Function to modify the BOOT_BUS_WIDTH field of EXT_CSD */
> +int mmc_set_boot_bus_width(struct mmc *mmc, u8 width, u8 reset, u8 mode);
>
>  /**
>   * Start device initialization and return immediately; it does not block on
> --
> 1.7.9.5
>
> _______________________________________________
> U-Boot mailing list
> U-Boot@lists.denx.de
> http://lists.denx.de/mailman/listinfo/u-boot
Tom Rini April 22, 2014, 3:41 p.m. UTC | #3
On Fri, Apr 18, 2014 at 11:25:23AM +0200, Michael Trimarchi wrote:

> Hi Tom
> 
> On Thu, Jan 30, 2014 at 10:31 PM, Tom Rini <trini@ti.com> wrote:
> > Add a bootbus sub-command to the mmc command to allow for setting
> > the boot_bus_width, reset_boot_bus_width and boot_mode fields of
> > BOOT_BUS_WIDTH (EXT_CSD[177]).
> >
> > Signed-off-by: Tom Rini <trini@ti.com>
> > ---
> 
> Can I ask if does it work even for OMAP4 device?
> So can I flash on boot0 and let omap4 bootrom to load from that?

In theory, yes.  I don't have hardware around in that exact setup, but
if the OMAP4 TRM talks about booting from the boot partition then yes,
this should let you set all the right bits.
diff mbox

Patch

diff --git a/common/cmd_mmc.c b/common/cmd_mmc.c
index 5842e85..a028149 100644
--- a/common/cmd_mmc.c
+++ b/common/cmd_mmc.c
@@ -338,6 +338,33 @@  static int do_mmcops(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 
 		/* acknowledge to be sent during boot operation */
 		return mmc_set_part_conf(mmc, ack, part_num, access);
+	} else if (strcmp(argv[1], "bootbus") == 0) {
+		int dev;
+		struct mmc *mmc;
+		u8 width, reset, mode;
+
+		if (argc == 6) {
+			dev = simple_strtoul(argv[2], NULL, 10);
+			width = simple_strtoul(argv[3], NULL, 10);
+			reset = simple_strtoul(argv[4], NULL, 10);
+			mode = simple_strtoul(argv[5], NULL, 10);
+		} else {
+			return CMD_RET_USAGE;
+		}
+
+		mmc = find_mmc_device(dev);
+		if (!mmc) {
+			printf("no mmc device at slot %x\n", dev);
+			return 1;
+		}
+
+		if (IS_SD(mmc)) {
+			puts("BOOT_BUS_WIDTH only exists on eMMC\n");
+			return 1;
+		}
+
+		/* acknowledge to be sent during boot operation */
+		return mmc_set_boot_bus_width(mmc, width, reset, mode);
 	} else if (strcmp(argv[1], "bootpart-resize") == 0) {
 		int dev;
 		struct mmc *mmc;
@@ -475,6 +502,8 @@  U_BOOT_CMD(
 	" - Enable boot_part for booting and enable R/W access of boot_part\n"
 	"mmc close <dev> <boot_partition>\n"
 	" - Enable boot_part for booting and disable access to boot_part\n"
+	"mmc bootbus dev boot_bus_width reset_boot_bus_width boot_mode\n"
+	" - Set the BOOT_BUS_WIDTH field of the specified device\n"
 	"mmc bootpart-resize <dev> <boot part size MB> <RPMB part size MB>\n"
 	" - Change sizes of boot and RPMB partitions of specified device\n"
 	"mmc partconf dev boot_ack boot_partition partition_access\n"
diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c
index 1591fce..fc1c1dc 100644
--- a/drivers/mmc/mmc.c
+++ b/drivers/mmc/mmc.c
@@ -1507,6 +1507,27 @@  int mmc_boot_part_access(struct mmc *mmc, u8 ack, u8 part_num, u8 access)
 }
 
 /*
+ * Modify EXT_CSD[177] which is BOOT_BUS_WIDTH
+ * based on the passed in values for BOOT_BUS_WIDTH, RESET_BOOT_BUS_WIDTH
+ * and BOOT_MODE.
+ *
+ * Returns 0 on success.
+ */
+int mmc_set_boot_bus_width(struct mmc *mmc, u8 width, u8 reset, u8 mode)
+{
+	int err;
+
+	err = mmc_switch(mmc, EXT_CSD_CMD_SET_NORMAL, EXT_CSD_BOOT_BUS_WIDTH,
+			 EXT_CSD_BOOT_BUS_WIDTH_MODE(mode) |
+			 EXT_CSD_BOOT_BUS_WIDTH_RESET(reset) |
+			 EXT_CSD_BOOT_BUS_WIDTH_WIDTH(width));
+
+	if (err)
+		return err;
+	return 0;
+}
+
+/*
  * Modify EXT_CSD[179] which is PARTITION_CONFIG (formerly BOOT_CONFIG)
  * based on the passed in values for BOOT_ACK, BOOT_PARTITION_ENABLE and
  * PARTITION_ACCESS.
diff --git a/include/mmc.h b/include/mmc.h
index 7e026da..3594286 100644
--- a/include/mmc.h
+++ b/include/mmc.h
@@ -187,6 +187,9 @@ 
 #define EXT_CSD_BOOT_PART_NUM(x)	(x << 3)
 #define EXT_CSD_PARTITION_ACCESS(x)	(x << 0)
 
+#define EXT_CSD_BOOT_BUS_WIDTH_MODE(x)	(x << 3)
+#define EXT_CSD_BOOT_BUS_WIDTH_RESET(x)	(x << 2)
+#define EXT_CSD_BOOT_BUS_WIDTH_WIDTH(x)	(x)
 
 #define R1_ILLEGAL_COMMAND		(1 << 22)
 #define R1_APP_CMD			(1 << 5)
@@ -314,6 +317,8 @@  int mmc_boot_partition_size_change(struct mmc *mmc, unsigned long bootsize,
 int mmc_boot_part_access(struct mmc *mmc, u8 ack, u8 part_num, u8 access);
 /* Function to modify the PARTITION_CONFIG field of EXT_CSD */
 int mmc_set_part_conf(struct mmc *mmc, u8 ack, u8 part_num, u8 access);
+/* Function to modify the BOOT_BUS_WIDTH field of EXT_CSD */
+int mmc_set_boot_bus_width(struct mmc *mmc, u8 width, u8 reset, u8 mode);
 
 /**
  * Start device initialization and return immediately; it does not block on