All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH 1/2] env_mmc: Allow board code to override the environment address
@ 2011-01-29 23:29 Kumar Gala
  2011-01-29 23:29 ` [U-Boot] [PATCH 2/2] powerpc/85xx: Enable eSDHC boot support on P2020 DS Kumar Gala
                   ` (3 more replies)
  0 siblings, 4 replies; 8+ messages in thread
From: Kumar Gala @ 2011-01-29 23:29 UTC (permalink / raw)
  To: u-boot

From: Mingkai Hu <Mingkai.hu@freescale.com>

On some boards the environment may not be located at a fixed address in
the MMC/SDHC card.  This allows those boards to implement their own
means to report what address the environment is located at.

Signed-off-by: Mingkai Hu <Mingkai.hu@freescale.com>
Signed-off-by: Jerry Huang <Chang-Ming.Huang@freescale.com>
Signed-off-by: Zhao Chenhui <b35336@freescale.com>
Signed-off-by: Kumar Gala <galak@kernel.crashing.org>
---
 common/env_mmc.c |   31 +++++++++++++++++++++++++++----
 1 files changed, 27 insertions(+), 4 deletions(-)

diff --git a/common/env_mmc.c b/common/env_mmc.c
index 71dcc4c..83f40f4 100644
--- a/common/env_mmc.c
+++ b/common/env_mmc.c
@@ -1,5 +1,5 @@
 /*
- * (C) Copyright 2008-2010 Freescale Semiconductor, Inc.
+ * (C) Copyright 2008-2011 Freescale Semiconductor, Inc.
  *
  * See file CREDITS for list of people who contributed to this
  * project.
@@ -51,6 +51,19 @@ static void use_default(void);
 
 DECLARE_GLOBAL_DATA_PTR;
 
+#if !defined(CONFIG_ENV_OFFSET)
+#define CONFIG_ENV_OFFSET 0
+#endif
+
+static int __mmc_get_env_addr(struct mmc *mmc, u32 *env_addr)
+{
+	*env_addr = CONFIG_ENV_OFFSET;
+	return 0;
+}
+__attribute__((weak, alias("__mmc_get_env_addr")))
+int mmc_get_env_addr(struct mmc *mmc, u32 *env_addr);
+
+
 uchar env_get_char_spec(int index)
 {
 	return *((uchar *)(gd->env_addr + index));
@@ -102,10 +115,14 @@ int saveenv(void)
 	ssize_t	len;
 	char	*res;
 	struct mmc *mmc = find_mmc_device(CONFIG_SYS_MMC_ENV_DEV);
+	u32 offset;
 
 	if (init_mmc_for_env(mmc))
 		return 1;
 
+	if(mmc_get_env_addr(mmc, &offset))
+		return 1;
+
 	res = (char *)&env_new.data;
 	len = hexport_r(&env_htab, '\0', &res, ENV_SIZE);
 	if (len < 0) {
@@ -114,7 +131,7 @@ int saveenv(void)
 	}
 	env_new.crc   = crc32(0, env_new.data, ENV_SIZE);
 	printf("Writing to MMC(%d)... ", CONFIG_SYS_MMC_ENV_DEV);
-	if (write_env(mmc, CONFIG_ENV_SIZE, CONFIG_ENV_OFFSET, (u_char *)&env_new)) {
+	if (write_env(mmc, CONFIG_ENV_SIZE, offset, (u_char *)&env_new)) {
 		puts("failed\n");
 		return 1;
 	}
@@ -141,16 +158,22 @@ inline int read_env(struct mmc *mmc, unsigned long size,
 void env_relocate_spec(void)
 {
 #if !defined(ENV_IS_EMBEDDED)
-       char buf[CONFIG_ENV_SIZE];
+	char buf[CONFIG_ENV_SIZE];
 
 	struct mmc *mmc = find_mmc_device(CONFIG_SYS_MMC_ENV_DEV);
+	u32 offset;
 
 	if (init_mmc_for_env(mmc)) {
 		use_default();
 		return;
 	}
 
-	if (read_env(mmc, CONFIG_ENV_SIZE, CONFIG_ENV_OFFSET, buf)) {
+	if(mmc_get_env_addr(mmc, &offset)) {
+		use_default();
+		return ;
+	}
+
+	if (read_env(mmc, CONFIG_ENV_SIZE, offset, buf)) {
 		use_default();
 		return;
 	}
-- 
1.7.2.3

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [U-Boot] [PATCH 2/2] powerpc/85xx: Enable eSDHC boot support on P2020 DS
  2011-01-29 23:29 [U-Boot] [PATCH 1/2] env_mmc: Allow board code to override the environment address Kumar Gala
@ 2011-01-29 23:29 ` Kumar Gala
  2011-04-05  3:32   ` Kumar Gala
  2011-02-10  6:15 ` [U-Boot] [PATCH 1/2] env_mmc: Allow board code to override the environment address Kumar Gala
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 8+ messages in thread
From: Kumar Gala @ 2011-01-29 23:29 UTC (permalink / raw)
  To: u-boot

From: Jerry Huang <Chang-Ming.Huang@freescale.com>

We implement our own mmc_get_env_addr since the environment variables are
written to just after the u-boot image on SDCard, so we must read the MBR
to get the start address and code length of the u-boot image, then
calculate the address of the env.

Signed-off-by: Jerry Huang <Chang-Ming.Huang@freescale.com>
Signed-off-by: Zhao Chenhui <b35336@freescale.com>
Signed-off-by: Kumar Gala <galak@kernel.crashing.org>
---
 board/freescale/common/Makefile    |    1 +
 board/freescale/common/sdhc_boot.c |   64 ++++++++++++++++++++++++++++++++++++
 board/freescale/p2020ds/tlb.c      |   13 +++++++-
 boards.cfg                         |    1 +
 include/configs/P2020DS.h          |   25 ++++++++++++++
 5 files changed, 103 insertions(+), 1 deletions(-)
 create mode 100644 board/freescale/common/sdhc_boot.c

diff --git a/board/freescale/common/Makefile b/board/freescale/common/Makefile
index 1abd3e5..8ea5acb 100644
--- a/board/freescale/common/Makefile
+++ b/board/freescale/common/Makefile
@@ -36,6 +36,7 @@ COBJS-$(CONFIG_FSL_NGPIXIS)	+= ngpixis.o
 COBJS-$(CONFIG_PQ_MDS_PIB)	+= pq-mds-pib.o
 COBJS-$(CONFIG_ID_EEPROM)	+= sys_eeprom.o
 COBJS-$(CONFIG_FSL_SGMII_RISER)	+= sgmii_riser.o
+COBJS-$(CONFIG_ENV_IS_IN_MMC)	+= sdhc_boot.o
 
 COBJS-$(CONFIG_MPC8541CDS)	+= cds_pci_ft.o
 COBJS-$(CONFIG_MPC8548CDS)	+= cds_pci_ft.o
diff --git a/board/freescale/common/sdhc_boot.c b/board/freescale/common/sdhc_boot.c
new file mode 100644
index 0000000..964c6b8
--- /dev/null
+++ b/board/freescale/common/sdhc_boot.c
@@ -0,0 +1,64 @@
+/*
+ * Copyright 2011 Freescale Semiconductor, Inc.
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#include <common.h>
+#include <mmc.h>
+#include <malloc.h>
+
+/*
+ * The environment variables are written to just after the u-boot image
+ * on SDCard, so we must read the MBR to get the start address and code
+ * length of the u-boot image, then calculate the address of the env.
+ */
+#define ESDHC_BOOT_IMAGE_SIZE	0x48
+#define ESDHC_BOOT_IMAGE_ADDR	0x50
+
+int mmc_get_env_addr(struct mmc *mmc, u32 *env_addr)
+{
+	u8 *tmp_buf;
+	u32 blklen, code_offset, code_len, n;
+
+	blklen = mmc->read_bl_len;
+	tmp_buf = malloc(blklen);
+	if (!tmp_buf)
+		return 1;
+
+	/* read out the first block, get the config data information */
+	n = mmc->block_dev.block_read(mmc->block_dev.dev, 0, 1, tmp_buf);
+	if (!n) {
+		free(tmp_buf);
+		return 1;
+	}
+
+	/* Get the Source Address, from offset 0x50 */
+	code_offset = *(u32 *)(tmp_buf + ESDHC_BOOT_IMAGE_ADDR);
+
+	/* Get the code size from offset 0x48 */
+	code_len = *(u32 *)(tmp_buf + ESDHC_BOOT_IMAGE_SIZE);
+
+	*env_addr = code_offset + code_len;
+
+	free(tmp_buf);
+
+	return 0;
+}
+
diff --git a/board/freescale/p2020ds/tlb.c b/board/freescale/p2020ds/tlb.c
index 824b3b2..fd914a1 100644
--- a/board/freescale/p2020ds/tlb.c
+++ b/board/freescale/p2020ds/tlb.c
@@ -1,5 +1,5 @@
 /*
- * Copyright 2008-2009 Freescale Semiconductor, Inc.
+ * Copyright 2008-2011 Freescale Semiconductor, Inc.
  *
  * (C) Copyright 2000
  * Wolfgang Denk, DENX Software Engineering, wd at denx.de.
@@ -90,6 +90,17 @@ struct fsl_e_tlb_entry tlb_table[] = {
 	SET_TLB_ENTRY(1, PIXIS_BASE, PIXIS_BASE_PHYS,
 		      MAS3_SX|MAS3_SW|MAS3_SR, MAS2_I|MAS2_G,
 		      0, 8, BOOKE_PAGESZ_4K, 1),
+
+#if defined(CONFIG_SYS_RAMBOOT) && defined(CONFIG_SYS_INIT_L2_ADDR)
+	/* *I*G - L2SRAM */
+	SET_TLB_ENTRY(1, CONFIG_SYS_INIT_L2_ADDR, CONFIG_SYS_INIT_L2_ADDR_PHYS,
+		      MAS3_SX|MAS3_SW|MAS3_SR, MAS2_I|MAS2_G,
+		      0, 9, BOOKE_PAGESZ_256K, 1),
+	SET_TLB_ENTRY(1, CONFIG_SYS_INIT_L2_ADDR + 0x40000,
+		      CONFIG_SYS_INIT_L2_ADDR_PHYS + 0x40000,
+		      MAS3_SX|MAS3_SW|MAS3_SR, MAS2_I|MAS2_G,
+		      0, 10, BOOKE_PAGESZ_256K, 1),
+#endif
 };
 
 int num_tlb_entries = ARRAY_SIZE(tlb_table);
diff --git a/boards.cfg b/boards.cfg
index 141b143..312b841 100644
--- a/boards.cfg
+++ b/boards.cfg
@@ -491,6 +491,7 @@ P2010RDB_SPIFLASH            powerpc     mpc85xx     p1_p2_rdb           freesca
 P2020DS                      powerpc     mpc85xx     p2020ds             freescale
 P2020DS_36BIT                powerpc     mpc85xx     p2020ds             freescale      -           P2020DS:36BIT
 P2020DS_DDR2                 powerpc     mpc85xx     p2020ds             freescale      -           P2020DS:DDR2
+P2020DS_SDCARD               powerpc     mpc85xx     p2020ds             freescale      -           P2020DS:SDCARD
 P2020RDB                     powerpc     mpc85xx     p1_p2_rdb           freescale      -           P1_P2_RDB:P2020
 P2020RDB_NAND                powerpc     mpc85xx     p1_p2_rdb           freescale      -           P1_P2_RDB:P2020,NAND
 P2020RDB_SDCARD              powerpc     mpc85xx     p1_p2_rdb           freescale      -           P1_P2_RDB:P2020,SDCARD
diff --git a/include/configs/P2020DS.h b/include/configs/P2020DS.h
index 6648d6e..b971e7f 100644
--- a/include/configs/P2020DS.h
+++ b/include/configs/P2020DS.h
@@ -33,6 +33,13 @@
 #define CONFIG_PHYS_64BIT
 #endif
 
+#ifdef CONFIG_SDCARD
+#define CONFIG_SYS_RAMBOOT
+#define CONFIG_SYS_EXTRA_ENV_RELOC
+#define CONFIG_SYS_TEXT_BASE		0xf8f80000
+#define CONFIG_RESET_VECTOR_ADDRESS	0xf8fffffc
+#endif
+
 /* High Level Configuration Options */
 #define CONFIG_BOOKE		1	/* BOOKE */
 #define CONFIG_E500		1	/* BOOKE e500 family */
@@ -93,6 +100,18 @@
 #define CONFIG_PANIC_HANG	/* do not reset board on panic */
 
 /*
+ * Config the L2 Cache
+ */
+#define CONFIG_SYS_INIT_L2_ADDR		0xf8f80000
+#ifdef CONFIG_PHYS_64BIT
+#define CONFIG_SYS_INIT_L2_ADDR_PHYS	0xff8f80000ull
+#else
+#define CONFIG_SYS_INIT_L2_ADDR_PHYS	CONFIG_SYS_INIT_L2_ADDR
+#endif
+#define CONFIG_SYS_L2_SIZE		(512 << 10)
+#define CONFIG_SYS_INIT_L2_END	(CONFIG_SYS_INIT_L2_ADDR + CONFIG_SYS_L2_SIZE)
+
+/*
  * Base addresses -- Note these are effective addresses where the
  * actual resources get mapped (not physical addresses)
  */
@@ -571,6 +590,11 @@
 /*
  * Environment
  */
+#if defined(CONFIG_SDCARD)
+#define CONFIG_ENV_IS_IN_MMC
+#define CONFIG_ENV_SIZE			0x2000
+#define CONFIG_SYS_MMC_ENV_DEV		0
+#else
 #define CONFIG_ENV_IS_IN_FLASH	1
 #if CONFIG_SYS_MONITOR_BASE > 0xfff80000
 #define CONFIG_ENV_ADDR		0xfff80000
@@ -579,6 +603,7 @@
 #endif
 #define CONFIG_ENV_SIZE		0x2000
 #define CONFIG_ENV_SECT_SIZE	0x20000 /* 128K (one sector) */
+#endif
 
 #define CONFIG_LOADS_ECHO	1	/* echo on for serial download */
 #define CONFIG_SYS_LOADS_BAUD_CHANGE	1	/* allow baudrate change */
-- 
1.7.2.3

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [U-Boot] [PATCH 1/2] env_mmc: Allow board code to override the environment address
  2011-01-29 23:29 [U-Boot] [PATCH 1/2] env_mmc: Allow board code to override the environment address Kumar Gala
  2011-01-29 23:29 ` [U-Boot] [PATCH 2/2] powerpc/85xx: Enable eSDHC boot support on P2020 DS Kumar Gala
@ 2011-02-10  6:15 ` Kumar Gala
  2011-02-22 10:01   ` Kumar Gala
  2011-04-04 21:23 ` Andy Fleming
  2011-04-05  3:32 ` Kumar Gala
  3 siblings, 1 reply; 8+ messages in thread
From: Kumar Gala @ 2011-02-10  6:15 UTC (permalink / raw)
  To: u-boot


On Jan 29, 2011, at 5:29 PM, Kumar Gala wrote:

> From: Mingkai Hu <Mingkai.hu@freescale.com>
> 
> On some boards the environment may not be located at a fixed address in
> the MMC/SDHC card.  This allows those boards to implement their own
> means to report what address the environment is located at.
> 
> Signed-off-by: Mingkai Hu <Mingkai.hu@freescale.com>
> Signed-off-by: Jerry Huang <Chang-Ming.Huang@freescale.com>
> Signed-off-by: Zhao Chenhui <b35336@freescale.com>
> Signed-off-by: Kumar Gala <galak@kernel.crashing.org>
> ---
> common/env_mmc.c |   31 +++++++++++++++++++++++++++----
> 1 files changed, 27 insertions(+), 4 deletions(-)
> 
> diff --git a/common/env_mmc.c b/common/env_mmc.c
> index 71dcc4c..83f40f4 100644
> --- a/common/env_mmc.c
> +++ b/common/env_mmc.c
> @@ -1,5 +1,5 @@
> /*
> - * (C) Copyright 2008-2010 Freescale Semiconductor, Inc.
> + * (C) Copyright 2008-2011 Freescale Semiconductor, Inc.
>  *
>  * See file CREDITS for list of people who contributed to this
>  * project.
> @@ -51,6 +51,19 @@ static void use_default(void);
> 
> DECLARE_GLOBAL_DATA_PTR;
> 
> +#if !defined(CONFIG_ENV_OFFSET)
> +#define CONFIG_ENV_OFFSET 0
> +#endif
> +
> +static int __mmc_get_env_addr(struct mmc *mmc, u32 *env_addr)
> +{
> +	*env_addr = CONFIG_ENV_OFFSET;
> +	return 0;
> +}
> +__attribute__((weak, alias("__mmc_get_env_addr")))
> +int mmc_get_env_addr(struct mmc *mmc, u32 *env_addr);
> +
> +
> uchar env_get_char_spec(int index)
> {
> 	return *((uchar *)(gd->env_addr + index));
> @@ -102,10 +115,14 @@ int saveenv(void)
> 	ssize_t	len;
> 	char	*res;
> 	struct mmc *mmc = find_mmc_device(CONFIG_SYS_MMC_ENV_DEV);
> +	u32 offset;
> 
> 	if (init_mmc_for_env(mmc))
> 		return 1;
> 
> +	if(mmc_get_env_addr(mmc, &offset))
> +		return 1;
> +
> 	res = (char *)&env_new.data;
> 	len = hexport_r(&env_htab, '\0', &res, ENV_SIZE);
> 	if (len < 0) {
> @@ -114,7 +131,7 @@ int saveenv(void)
> 	}
> 	env_new.crc   = crc32(0, env_new.data, ENV_SIZE);
> 	printf("Writing to MMC(%d)... ", CONFIG_SYS_MMC_ENV_DEV);
> -	if (write_env(mmc, CONFIG_ENV_SIZE, CONFIG_ENV_OFFSET, (u_char *)&env_new)) {
> +	if (write_env(mmc, CONFIG_ENV_SIZE, offset, (u_char *)&env_new)) {
> 		puts("failed\n");
> 		return 1;
> 	}
> @@ -141,16 +158,22 @@ inline int read_env(struct mmc *mmc, unsigned long size,
> void env_relocate_spec(void)
> {
> #if !defined(ENV_IS_EMBEDDED)
> -       char buf[CONFIG_ENV_SIZE];
> +	char buf[CONFIG_ENV_SIZE];
> 
> 	struct mmc *mmc = find_mmc_device(CONFIG_SYS_MMC_ENV_DEV);
> +	u32 offset;
> 
> 	if (init_mmc_for_env(mmc)) {
> 		use_default();
> 		return;
> 	}
> 
> -	if (read_env(mmc, CONFIG_ENV_SIZE, CONFIG_ENV_OFFSET, buf)) {
> +	if(mmc_get_env_addr(mmc, &offset)) {
> +		use_default();
> +		return ;
> +	}
> +
> +	if (read_env(mmc, CONFIG_ENV_SIZE, offset, buf)) {
> 		use_default();
> 		return;
> 	}
> -- 

Wolfgang,

Any comments on this?

- k

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [U-Boot] [PATCH 1/2] env_mmc: Allow board code to override the environment address
  2011-02-10  6:15 ` [U-Boot] [PATCH 1/2] env_mmc: Allow board code to override the environment address Kumar Gala
@ 2011-02-22 10:01   ` Kumar Gala
  2011-04-04 14:45     ` Kumar Gala
  0 siblings, 1 reply; 8+ messages in thread
From: Kumar Gala @ 2011-02-22 10:01 UTC (permalink / raw)
  To: u-boot


On Feb 10, 2011, at 12:15 AM, Kumar Gala wrote:

> 
> On Jan 29, 2011, at 5:29 PM, Kumar Gala wrote:
> 
>> From: Mingkai Hu <Mingkai.hu@freescale.com>
>> 
>> On some boards the environment may not be located at a fixed address in
>> the MMC/SDHC card.  This allows those boards to implement their own
>> means to report what address the environment is located at.
>> 
>> Signed-off-by: Mingkai Hu <Mingkai.hu@freescale.com>
>> Signed-off-by: Jerry Huang <Chang-Ming.Huang@freescale.com>
>> Signed-off-by: Zhao Chenhui <b35336@freescale.com>
>> Signed-off-by: Kumar Gala <galak@kernel.crashing.org>
>> ---
>> common/env_mmc.c |   31 +++++++++++++++++++++++++++----
>> 1 files changed, 27 insertions(+), 4 deletions(-)
>> 
>> diff --git a/common/env_mmc.c b/common/env_mmc.c
>> index 71dcc4c..83f40f4 100644
>> --- a/common/env_mmc.c
>> +++ b/common/env_mmc.c
>> @@ -1,5 +1,5 @@
>> /*
>> - * (C) Copyright 2008-2010 Freescale Semiconductor, Inc.
>> + * (C) Copyright 2008-2011 Freescale Semiconductor, Inc.
>> *
>> * See file CREDITS for list of people who contributed to this
>> * project.
>> @@ -51,6 +51,19 @@ static void use_default(void);
>> 
>> DECLARE_GLOBAL_DATA_PTR;
>> 
>> +#if !defined(CONFIG_ENV_OFFSET)
>> +#define CONFIG_ENV_OFFSET 0
>> +#endif
>> +
>> +static int __mmc_get_env_addr(struct mmc *mmc, u32 *env_addr)
>> +{
>> +	*env_addr = CONFIG_ENV_OFFSET;
>> +	return 0;
>> +}
>> +__attribute__((weak, alias("__mmc_get_env_addr")))
>> +int mmc_get_env_addr(struct mmc *mmc, u32 *env_addr);
>> +
>> +
>> uchar env_get_char_spec(int index)
>> {
>> 	return *((uchar *)(gd->env_addr + index));
>> @@ -102,10 +115,14 @@ int saveenv(void)
>> 	ssize_t	len;
>> 	char	*res;
>> 	struct mmc *mmc = find_mmc_device(CONFIG_SYS_MMC_ENV_DEV);
>> +	u32 offset;
>> 
>> 	if (init_mmc_for_env(mmc))
>> 		return 1;
>> 
>> +	if(mmc_get_env_addr(mmc, &offset))
>> +		return 1;
>> +
>> 	res = (char *)&env_new.data;
>> 	len = hexport_r(&env_htab, '\0', &res, ENV_SIZE);
>> 	if (len < 0) {
>> @@ -114,7 +131,7 @@ int saveenv(void)
>> 	}
>> 	env_new.crc   = crc32(0, env_new.data, ENV_SIZE);
>> 	printf("Writing to MMC(%d)... ", CONFIG_SYS_MMC_ENV_DEV);
>> -	if (write_env(mmc, CONFIG_ENV_SIZE, CONFIG_ENV_OFFSET, (u_char *)&env_new)) {
>> +	if (write_env(mmc, CONFIG_ENV_SIZE, offset, (u_char *)&env_new)) {
>> 		puts("failed\n");
>> 		return 1;
>> 	}
>> @@ -141,16 +158,22 @@ inline int read_env(struct mmc *mmc, unsigned long size,
>> void env_relocate_spec(void)
>> {
>> #if !defined(ENV_IS_EMBEDDED)
>> -       char buf[CONFIG_ENV_SIZE];
>> +	char buf[CONFIG_ENV_SIZE];
>> 
>> 	struct mmc *mmc = find_mmc_device(CONFIG_SYS_MMC_ENV_DEV);
>> +	u32 offset;
>> 
>> 	if (init_mmc_for_env(mmc)) {
>> 		use_default();
>> 		return;
>> 	}
>> 
>> -	if (read_env(mmc, CONFIG_ENV_SIZE, CONFIG_ENV_OFFSET, buf)) {
>> +	if(mmc_get_env_addr(mmc, &offset)) {
>> +		use_default();
>> +		return ;
>> +	}
>> +
>> +	if (read_env(mmc, CONFIG_ENV_SIZE, offset, buf)) {
>> 		use_default();
>> 		return;
>> 	}
>> -- 
> 
> Wolfgang,
> 
> Any comments on this?
> 
> - k

ping

- k

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [U-Boot] [PATCH 1/2] env_mmc: Allow board code to override the environment address
  2011-02-22 10:01   ` Kumar Gala
@ 2011-04-04 14:45     ` Kumar Gala
  0 siblings, 0 replies; 8+ messages in thread
From: Kumar Gala @ 2011-04-04 14:45 UTC (permalink / raw)
  To: u-boot


On Feb 22, 2011, at 4:01 AM, Kumar Gala wrote:

> 
> On Feb 10, 2011, at 12:15 AM, Kumar Gala wrote:
> 
>> 
>> On Jan 29, 2011, at 5:29 PM, Kumar Gala wrote:
>> 
>>> From: Mingkai Hu <Mingkai.hu@freescale.com>
>>> 
>>> On some boards the environment may not be located at a fixed address in
>>> the MMC/SDHC card.  This allows those boards to implement their own
>>> means to report what address the environment is located at.
>>> 
>>> Signed-off-by: Mingkai Hu <Mingkai.hu@freescale.com>
>>> Signed-off-by: Jerry Huang <Chang-Ming.Huang@freescale.com>
>>> Signed-off-by: Zhao Chenhui <b35336@freescale.com>
>>> Signed-off-by: Kumar Gala <galak@kernel.crashing.org>
>>> ---
>>> common/env_mmc.c |   31 +++++++++++++++++++++++++++----
>>> 1 files changed, 27 insertions(+), 4 deletions(-)
>>> 
>>> diff --git a/common/env_mmc.c b/common/env_mmc.c
>>> index 71dcc4c..83f40f4 100644
>>> --- a/common/env_mmc.c
>>> +++ b/common/env_mmc.c
>>> @@ -1,5 +1,5 @@
>>> /*
>>> - * (C) Copyright 2008-2010 Freescale Semiconductor, Inc.
>>> + * (C) Copyright 2008-2011 Freescale Semiconductor, Inc.
>>> *
>>> * See file CREDITS for list of people who contributed to this
>>> * project.
>>> @@ -51,6 +51,19 @@ static void use_default(void);
>>> 
>>> DECLARE_GLOBAL_DATA_PTR;
>>> 
>>> +#if !defined(CONFIG_ENV_OFFSET)
>>> +#define CONFIG_ENV_OFFSET 0
>>> +#endif
>>> +
>>> +static int __mmc_get_env_addr(struct mmc *mmc, u32 *env_addr)
>>> +{
>>> +	*env_addr = CONFIG_ENV_OFFSET;
>>> +	return 0;
>>> +}
>>> +__attribute__((weak, alias("__mmc_get_env_addr")))
>>> +int mmc_get_env_addr(struct mmc *mmc, u32 *env_addr);
>>> +
>>> +
>>> uchar env_get_char_spec(int index)
>>> {
>>> 	return *((uchar *)(gd->env_addr + index));
>>> @@ -102,10 +115,14 @@ int saveenv(void)
>>> 	ssize_t	len;
>>> 	char	*res;
>>> 	struct mmc *mmc = find_mmc_device(CONFIG_SYS_MMC_ENV_DEV);
>>> +	u32 offset;
>>> 
>>> 	if (init_mmc_for_env(mmc))
>>> 		return 1;
>>> 
>>> +	if(mmc_get_env_addr(mmc, &offset))
>>> +		return 1;
>>> +
>>> 	res = (char *)&env_new.data;
>>> 	len = hexport_r(&env_htab, '\0', &res, ENV_SIZE);
>>> 	if (len < 0) {
>>> @@ -114,7 +131,7 @@ int saveenv(void)
>>> 	}
>>> 	env_new.crc   = crc32(0, env_new.data, ENV_SIZE);
>>> 	printf("Writing to MMC(%d)... ", CONFIG_SYS_MMC_ENV_DEV);
>>> -	if (write_env(mmc, CONFIG_ENV_SIZE, CONFIG_ENV_OFFSET, (u_char *)&env_new)) {
>>> +	if (write_env(mmc, CONFIG_ENV_SIZE, offset, (u_char *)&env_new)) {
>>> 		puts("failed\n");
>>> 		return 1;
>>> 	}
>>> @@ -141,16 +158,22 @@ inline int read_env(struct mmc *mmc, unsigned long size,
>>> void env_relocate_spec(void)
>>> {
>>> #if !defined(ENV_IS_EMBEDDED)
>>> -       char buf[CONFIG_ENV_SIZE];
>>> +	char buf[CONFIG_ENV_SIZE];
>>> 
>>> 	struct mmc *mmc = find_mmc_device(CONFIG_SYS_MMC_ENV_DEV);
>>> +	u32 offset;
>>> 
>>> 	if (init_mmc_for_env(mmc)) {
>>> 		use_default();
>>> 		return;
>>> 	}
>>> 
>>> -	if (read_env(mmc, CONFIG_ENV_SIZE, CONFIG_ENV_OFFSET, buf)) {
>>> +	if(mmc_get_env_addr(mmc, &offset)) {
>>> +		use_default();
>>> +		return ;
>>> +	}
>>> +
>>> +	if (read_env(mmc, CONFIG_ENV_SIZE, offset, buf)) {
>>> 		use_default();
>>> 		return;
>>> 	}
>>> -- 
>> 
>> Wolfgang,
>> 
>> Any comments on this?
>> 
>> - k
> 
> ping
> 
> - k

ping.

- k

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [U-Boot] [PATCH 1/2] env_mmc: Allow board code to override the environment address
  2011-01-29 23:29 [U-Boot] [PATCH 1/2] env_mmc: Allow board code to override the environment address Kumar Gala
  2011-01-29 23:29 ` [U-Boot] [PATCH 2/2] powerpc/85xx: Enable eSDHC boot support on P2020 DS Kumar Gala
  2011-02-10  6:15 ` [U-Boot] [PATCH 1/2] env_mmc: Allow board code to override the environment address Kumar Gala
@ 2011-04-04 21:23 ` Andy Fleming
  2011-04-05  3:32 ` Kumar Gala
  3 siblings, 0 replies; 8+ messages in thread
From: Andy Fleming @ 2011-04-04 21:23 UTC (permalink / raw)
  To: u-boot

On Sat, Jan 29, 2011 at 5:29 PM, Kumar Gala <galak@kernel.crashing.org> wrote:
> From: Mingkai Hu <Mingkai.hu@freescale.com>
>
> On some boards the environment may not be located at a fixed address in
> the MMC/SDHC card. ?This allows those boards to implement their own
> means to report what address the environment is located at.
>
> Signed-off-by: Mingkai Hu <Mingkai.hu@freescale.com>
> Signed-off-by: Jerry Huang <Chang-Ming.Huang@freescale.com>
> Signed-off-by: Zhao Chenhui <b35336@freescale.com>
> Signed-off-by: Kumar Gala <galak@kernel.crashing.org>

Acked-by: Andy Fleming <afleming@freescale.com>

I just transferred the patchworks "todo" to galak, to make it easier
for the follow-on patch to be applied, and any other board patches
which depend on it.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [U-Boot] [PATCH 2/2] powerpc/85xx: Enable eSDHC boot support on P2020 DS
  2011-01-29 23:29 ` [U-Boot] [PATCH 2/2] powerpc/85xx: Enable eSDHC boot support on P2020 DS Kumar Gala
@ 2011-04-05  3:32   ` Kumar Gala
  0 siblings, 0 replies; 8+ messages in thread
From: Kumar Gala @ 2011-04-05  3:32 UTC (permalink / raw)
  To: u-boot


On Jan 29, 2011, at 5:29 PM, Kumar Gala wrote:

> From: Jerry Huang <Chang-Ming.Huang@freescale.com>
> 
> We implement our own mmc_get_env_addr since the environment variables are
> written to just after the u-boot image on SDCard, so we must read the MBR
> to get the start address and code length of the u-boot image, then
> calculate the address of the env.
> 
> Signed-off-by: Jerry Huang <Chang-Ming.Huang@freescale.com>
> Signed-off-by: Zhao Chenhui <b35336@freescale.com>
> Signed-off-by: Kumar Gala <galak@kernel.crashing.org>
> ---
> board/freescale/common/Makefile    |    1 +
> board/freescale/common/sdhc_boot.c |   64 ++++++++++++++++++++++++++++++++++++
> board/freescale/p2020ds/tlb.c      |   13 +++++++-
> boards.cfg                         |    1 +
> include/configs/P2020DS.h          |   25 ++++++++++++++
> 5 files changed, 103 insertions(+), 1 deletions(-)
> create mode 100644 board/freescale/common/sdhc_boot.c

applied to 85xx

- k

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [U-Boot] [PATCH 1/2] env_mmc: Allow board code to override the environment address
  2011-01-29 23:29 [U-Boot] [PATCH 1/2] env_mmc: Allow board code to override the environment address Kumar Gala
                   ` (2 preceding siblings ...)
  2011-04-04 21:23 ` Andy Fleming
@ 2011-04-05  3:32 ` Kumar Gala
  3 siblings, 0 replies; 8+ messages in thread
From: Kumar Gala @ 2011-04-05  3:32 UTC (permalink / raw)
  To: u-boot


On Jan 29, 2011, at 5:29 PM, Kumar Gala wrote:

> From: Mingkai Hu <Mingkai.hu@freescale.com>
> 
> On some boards the environment may not be located at a fixed address in
> the MMC/SDHC card.  This allows those boards to implement their own
> means to report what address the environment is located at.
> 
> Signed-off-by: Mingkai Hu <Mingkai.hu@freescale.com>
> Signed-off-by: Jerry Huang <Chang-Ming.Huang@freescale.com>
> Signed-off-by: Zhao Chenhui <b35336@freescale.com>
> Signed-off-by: Kumar Gala <galak@kernel.crashing.org>
> ---
> common/env_mmc.c |   31 +++++++++++++++++++++++++++----
> 1 files changed, 27 insertions(+), 4 deletions(-)

applied to 85xx

- k

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2011-04-05  3:32 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-01-29 23:29 [U-Boot] [PATCH 1/2] env_mmc: Allow board code to override the environment address Kumar Gala
2011-01-29 23:29 ` [U-Boot] [PATCH 2/2] powerpc/85xx: Enable eSDHC boot support on P2020 DS Kumar Gala
2011-04-05  3:32   ` Kumar Gala
2011-02-10  6:15 ` [U-Boot] [PATCH 1/2] env_mmc: Allow board code to override the environment address Kumar Gala
2011-02-22 10:01   ` Kumar Gala
2011-04-04 14:45     ` Kumar Gala
2011-04-04 21:23 ` Andy Fleming
2011-04-05  3:32 ` Kumar Gala

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.