Skip to contentSkip to conversation

Various clean-ups for a4m072 board support

U-Boot New Ilya Yanok 3 participants 14 messages Oct 21, 2010 – Oct 23, 2010 Memory technology devices (MTD)

lore
Share & tools
lore

Ilya Yanok

author
#0 lore raw

Hello,

these patches clean up the support for a4m072 board and related things. Fourth patch is pretty generic actually but as it's only needed for a4m072 AFAIK I post it in these series.

Patches:
[PATCH 1/5] a4m072: changes to the default environment
[PATCH 2/5] a4m072: change 'display' command implementation [PATCH 3/5] led_display: remove unused DISPLAY_MARK define [PATCH 4/5] cfi_flash: handle 'chip size exceeds address window' situation [PATCH 5/5] a4m072: add CONFIG_SYS_FLASH_BANKS_SIZES define

Regards, Ilya.

author
#1 lore raw

PATCH 1/5 a4m072: changes to the default environment

The default values for 'addip' and 'norargs' changed per customer request. Everything else cleaned up to fit into 80 symbol line.

---
 include/configs/a4m072.h |   58 +++++++++++++++++++++++++++++----------------
 1 files changed, 37 insertions(+), 21 deletions(-)
include/configs/a4m072.h +37 -21
index 24a04eb..a24b304 100644
@@ -147,27 +147,43 @@
 #define CONFIG_PREBOOT				"run try_update"
 
 #define	CONFIG_EXTRA_ENV_SETTINGS					\
-	"bk=run add_mtd ; run add_consolespec ; bootm 200000\0"	\
-	"cf1=diskboot 200000 0:1\0"	\
-	"bootcmd_cf1=run bcf1\0"	\
-	"bcf=setenv bootargs root=/dev/hda3\0"	\
-	"bootcmd_nfs=run bnfs\0"	\
-	"norargs=setenv bootargs root=/dev/mtdblock3 rootfstype=cramfs\0"	\
-	"bootcmd_nor=cp.b ${kernel_addr} 200000 100000; run norargs addip; run bk\0"	\
-	"bnfs=nfs 200000 ${rootpath}/boot/uImage ; run nfsargs addip ; run bk\0"	\
-	"nfsargs=setenv bootargs root=/dev/nfs rw nfsroot=${serverip}:${rootpath}\0"	\
-	"try_update=usb start;sleep 2;usb start;sleep 1;fatload usb 0 2F0000 PCPUUPDT 2FF;usb stop;source 2F0000\0"	\
-	"env_addr=FE060000\0"	\
-	"kernel_addr=FE100000\0"	\
-	"rootfs_addr=FE200000\0"	\
-	"add_mtd=setenv bootargs ${bootargs} mtdparts=phys_mapped_flash:384k(u),640k(e),1m(k),30m(r)\0"	\
-	"bcf1=run cf1; run bcf; run addip; run bk\0"	\
-	"add_consolespec=setenv bootargs ${bootargs} console=/dev/null quiet\0"	\
-	"addip=if test \"${ethaddr}\" != \"00:00:00:00:00:00\" ; then if test -n ${ipaddr}; then setenv bootargs ${bootargs} ip=${ipaddr}:${serverip}:${gatewayip}:${netmask}:${hostname}:${netdev}:off panic=1; fi ; fi\0"	\
-	"hostname=CPUP0\0"	\
-	"ethaddr=00:00:00:00:00:00\0"	\
-	"netdev=eth0\0"	\
-	"bootcmd=run bootcmd_nor\0" \
+	"bk=run add_mtd ; run add_consolespec ; bootm 200000\0"		\
+	"cf1=diskboot 200000 0:1\0"					\
+	"bootcmd_cf1=run bcf1\0"					\
+	"bcf=setenv bootargs root=/dev/hda3\0"				\
+	"bootcmd_nfs=run bnfs\0"					\
+	"norargs=setenv bootargs root=/dev/mtdblock3 rootfstype=cramfs "\
+		"panic=1\0"						\
+	"bootcmd_nor=cp.b ${kernel_addr} 200000 100000;"		\
+			"run norargs addip; run bk\0"			\
+	"bnfs=nfs 200000 ${rootpath}/boot/uImage;"			\
+			"run nfsargs addip ; run bk\0"			\
+	"nfsargs=setenv bootargs root=/dev/nfs rw "			\
+				"nfsroot=${serverip}:${rootpath}\0"	\
+	"try_update=usb start;sleep 2;usb start;sleep 1;"		\
+			"fatload usb 0 2F0000 PCPUUPDT 2FF;usb stop;"	\
+			"source 2F0000\0"				\
+	"env_addr=FE060000\0"						\
+	"kernel_addr=FE100000\0"					\
+	"rootfs_addr=FE200000\0"					\
+	"add_mtd=setenv bootargs ${bootargs} mtdparts="			\
+		"phys_mapped_flash:384k(u),640k(e),1m(k),30m(r)\0"	\
+	"bcf1=run cf1; run bcf; run addip; run bk\0"			\
+	"add_consolespec=setenv bootargs ${bootargs} "			\
+				"console=/dev/null quiet\0"		\
+	"addip=if test -n ${ethaddr};"					\
+		"then if test -n ${ipaddr};"				\
+			"then setenv bootargs ${bootargs} "		\
+				"ip=${ipaddr}:${serverip}:${gatewayip}:"\
+				"${netmask}:${hostname}:${netdev}:off;"	\
+			"fi;"						\
+		"else;"							\
+			"setenv bootargs ${bootargs} no_ethaddr;"	\
+		"fi\0"							\
+	"hostname=CPUP0\0"						\
+	"ethaddr=00:00:00:00:00:00\0"					\
+	"netdev=eth0\0"							\
+	"bootcmd=run bootcmd_nor\0" 					\
 	""
 /*
  * IPB Bus clocking configuration.
Signature · 1 line
1.7.2.3
#2 lore raw

PATCH 1/5 a4m072: changes to the default environment

Dear Ilya Yanok,

Quoted 7 lines · In message <[email protected]> you wrote:

The default values for 'addip' and 'norargs' changed per customer request. Everything else cleaned up to fit into 80 symbol line.

---
 include/configs/a4m072.h |   58 +++++++++++++++++++++++++++++----------------
 1 files changed, 37 insertions(+), 21 deletions(-)

Applied, thanks.

Best regards,

Wolfgang Denk

Signature · 5 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
"Everything should be made as simple as possible, but not simpler."
                                                    - Albert Einstein
author
#3 lore raw

PATCH 2/5 a4m072: change 'display' command implementation

In reply to Ilya Yanok

This patch changes implementation of 'display' command for a4m072 that uses 7-segment LED display as customer requested:

a) The "display" command shall _not_ turn on the decimal point.

b) Exception: "display ." shall turn on (only) the decimal point.

c) Hex digits (0-9, A-F, a-f) shall be displayed as usual.

d) Letters U, P, Y, L, S, T, H shall be displayed as usual (lower case letters identical to upper case letters)

e) 'I' (and 'i') shall be displayed like '1'

f) 'O' (and 'o') shall be displayed like '0'

g) all other Characters shall be displayed like ' ' (all segments off).

---
 board/a4m072/a4m072.c |   62 ++++++++++++++++++------------------------------
 1 files changed, 23 insertions(+), 39 deletions(-)
board/a4m072/a4m072.c +23 -39
index ae7ccbb..09a5a51 100644
@@ -270,8 +270,6 @@ static u8 display_buf[DISPLAY_BUF_SIZE];
 static u8 display_putc_pos;
 static u8 display_out_pos;
 
-static u8 display_dot_enable;
-
 void display_set(int cmd) {
 
 	if (cmd & DISPLAY_CLEAR) {
@@ -281,12 +279,6 @@ void display_set(int cmd) {
 	if (cmd & DISPLAY_HOME) {
 		display_putc_pos = 0;
 	}
-
-	if (cmd & DISPLAY_MARK) {
-		display_dot_enable = 1;
-	} else {
-		display_dot_enable = 0;
-	}
 }
 
 #define SEG_A    (1<<0)
@@ -314,10 +306,12 @@ void display_set(int cmd) {
  * A..Z		index 10..35
  * -		index 36
  * _		index 37
+ * .		index 38
  */
 
 #define SYMBOL_DASH		(36)
 #define SYMBOL_UNDERLINE	(37)
+#define SYMBOL_DOT		(38)
 
 static u8 display_char2seg7_tbl[]=
 {
@@ -337,28 +331,29 @@ static u8 display_char2seg7_tbl[]=
 	SEG_B | SEG_C | SEG_D | SEG_E | SEG_G,			/* d */
 	SEG_A | SEG_D | SEG_E | SEG_F | SEG_G,			/* E */
 	SEG_A | SEG_E | SEG_F | SEG_G,				/* F */
-	SEG_A | SEG_B | SEG_C | SEG_D | SEG_F | SEG_G,		/* g */
+	0,					/* g - not displayed */
 	SEG_B | SEG_C | SEG_E | SEG_F | SEG_G,			/* H */
-	SEG_E | SEG_F,						/* I */
-	SEG_B | SEG_C | SEG_D | SEG_E,				/* J */
-	SEG_A,						/* K - special 1 */
+	SEG_B | SEG_C,						/* I */
+	0,					/* J - not displayed */
+	0,					/* K - not displayed */
 	SEG_D | SEG_E | SEG_F,					/* L */
-	SEG_B,						/* m - special 2 */
-	SEG_C | SEG_E | SEG_G,					/* n */
-	SEG_C | SEG_D | SEG_E | SEG_G,				/* o */
+	0,					/* m - not displayed */
+	0,					/* n - not displayed */
+	SEG_A | SEG_B | SEG_C | SEG_D | SEG_E | SEG_F,		/* O */
 	SEG_A | SEG_B | SEG_E | SEG_F | SEG_G,			/* P */
-	SEG_A | SEG_B | SEG_C | SEG_F | SEG_G,			/* q */
-	SEG_E | SEG_G,						/* r */
+	0,					/* q - not displayed */
+	0,					/* r - not displayed */
 	SEG_A | SEG_C | SEG_D | SEG_F | SEG_G,			/* S */
 	SEG_D | SEG_E | SEG_F | SEG_G,				/* t */
 	SEG_B | SEG_C | SEG_D | SEG_E | SEG_F,			/* U */
-	SEG_C | SEG_D | SEG_E | SEG_F,				/* V */
-	SEG_C,						/* w - special 3 */
-	SEG_B | SEG_C | SEG_E | SEG_F | SEG_G,			/* X */
+	0,					/* V - not displayed */
+	0,					/* w - not displayed */
+	0,					/* X - not displayed */
 	SEG_B | SEG_C | SEG_D | SEG_F | SEG_G,			/* Y */
-	SEG_A | SEG_B | SEG_D | SEG_E | SEG_G,			/* Z */
+	0,					/* Z - not displayed */
 	SEG_G,							/* - */
-	SEG_D							/* _ */
+	SEG_D,							/* _ */
+	SEG_P							/* . */
 };
 
 /* Convert char to the LED segments representation */
@@ -374,23 +369,20 @@ static u8 display_char2seg7(char c)
 		c -= 'A' - 10;
 	else if (c == '-')
 		c = SYMBOL_DASH;
-	else if ((c == '_') || (c == '.'))
+	else if (c == '_')
 		c = SYMBOL_UNDERLINE;
+	else if (c == '.')
+		c = SYMBOL_DOT;
 	else
 		c = ' ';	/* display unsupported symbols as space */
 
 	if (c != ' ')
 		val = display_char2seg7_tbl[(int)c];
 
-	/* Handle DP LED here */
-	if (display_dot_enable) {
-		val |= SEG_P;
-	}
-
 	return val;
 }
 
-static inline int display_putc_nomark(char c)
+int display_putc(char c)
 {
 	if (display_putc_pos >= DISPLAY_BUF_SIZE)
 		return -1;
@@ -403,13 +395,6 @@ static inline int display_putc_nomark(char c)
 	return c;
 }
 
-int display_putc(char c)
-{
-	/* Mark the codes from the "display" command with the DP LED */
-	display_set(DISPLAY_MARK);
-	return display_putc_nomark(c);
-}
-
 /*
  * Flush current symbol to the LED display hardware
  */
@@ -493,9 +478,8 @@ void show_boot_progress(int status)
 	if (a4m072_status2code(status, buf) < 0)
 		return;
 
-	display_set(0);	/* Clear DP Led */
-	display_putc_nomark(buf[0]);
-	display_putc_nomark(buf[1]);
+	display_putc(buf[0]);
+	display_putc(buf[1]);
 	display_set(DISPLAY_HOME);
 	display_out_pos = 0;	/* reset output position */
 
Signature · 1 line
1.7.2.3
#4 lore raw

PATCH 2/5 a4m072: change 'display' command implementation

Dear Ilya Yanok,

Quoted 14 lines · In message <[email protected]> you wrote:

This patch changes implementation of 'display' command for a4m072 that uses 7-segment LED display as customer requested:

a) The "display" command shall _not_ turn on the decimal point.

b) Exception: "display ." shall turn on (only) the decimal point.

c) Hex digits (0-9, A-F, a-f) shall be displayed as usual.

d) Letters U, P, Y, L, S, T, H shall be displayed as usual (lower case letters identical to upper case letters)

e) 'I' (and 'i') shall be displayed like '1'

Quoted 8 lines

f) 'O' (and 'o') shall be displayed like '0'

g) all other Characters shall be displayed like ' ' (all segments off).

---
 board/a4m072/a4m072.c |   62 ++++++++++++++++++------------------------------
 1 files changed, 23 insertions(+), 39 deletions(-)

Applied, thanks.

Best regards,

Wolfgang Denk

Signature · 6 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
What kind of love is that?  Not to be loved; never to have shown love.
	-- Commissioner Nancy Hedford, "Metamorphosis",
	   stardate 3219.8
author
#5 lore raw

PATCH 3/5 led_display: remove unused DISPLAY_MARK define

In reply to Ilya Yanok

DISPLAY_MARK subcommand of display_set() is not used anywhere so we can remove it safely.

---
 doc/README.LED_display |    1 -
 include/led-display.h  |    1 -
 2 files changed, 0 insertions(+), 2 deletions(-)
doc/README.LED_display +0 -1
index 521746e..19977ea 100644
@@ -14,7 +14,6 @@ This function should control the state of the LED display. Argument is
 an ORed combination of the following values:
  DISPLAY_CLEAR	-- clear the display
  DISPLAY_HOME	-- set the position to the beginning of display
- DISPLAY_MARK	-- enable mark (decimal point), if implemented
 
 int display_putc(char c);
 
include/led-display.h +0 -1
index 41c3744..eaa0f40 100644
@@ -29,7 +29,6 @@
 /* Display Commands */
 #define DISPLAY_CLEAR	0x1 /* Clear the display */
 #define DISPLAY_HOME	0x2 /* Set cursor at home position */
-#define DISPLAY_MARK	0x4 /* Enable the decimal point led, if implemented */
 
 void display_set(int cmd);
 int display_putc(char c);
Signature · 1 line
1.7.2.3
#6 lore raw

PATCH 3/5 led_display: remove unused DISPLAY_MARK define

Dear Ilya Yanok,

Quoted 8 lines · In message <[email protected]> you wrote:

DISPLAY_MARK subcommand of display_set() is not used anywhere so we can remove it safely.

---
 doc/README.LED_display |    1 -
 include/led-display.h  |    1 -
 2 files changed, 0 insertions(+), 2 deletions(-)

Applied, thanks.

Best regards,

Wolfgang Denk

Signature · 5 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Everyting looks interesting until you do it. Then you find it's  just
another job.                     - Terry Pratchett, _Moving Pictures_
author
#7 lore raw

PATCH 4/5 cfi_flash: handle 'chip size exceeds address window' situation

In reply to Ilya Yanok

On some boards we have flash mapped high in the address space with considerably small window (say 0xFE000000 and 32MB). When we install bigger chip (say 64MB) on such a board strange things happen (flash_write() doesn't work at all, for ex). That's because cfi_flash driver doesn't care about window size at all.
Of course, cleanest solution would probably be to just extend address window to be able to map the whole flash but for legacy/compatibility reasons some people prefer just truncate the flash size and never use the upper part.
This patch adds an option for cfi_flash driver to handle this situation properly. To achieve this we add the new function cfi_flash_bank_size() which can be provided by the board code and weak-aliased to default implementation that returns value from the CONFIG_SYS_FLASH_BANKS_SIZES array if it's defined or 0 otherwise (the last case is added for compatibility).
If non-zero flash bank size is provided and detected chip size is bigger than provided address window size the warning will be displayed and flash chip will be truncated.

---
 drivers/mtd/cfi_flash.c |   28 +++++++++++++++++++++++-----
 1 files changed, 23 insertions(+), 5 deletions(-)
drivers/mtd/cfi_flash.c +23 -5
index 798902f..c444b53 100644
@@ -85,6 +85,17 @@ static phys_addr_t __cfi_flash_bank_addr(int i)
 phys_addr_t cfi_flash_bank_addr(int i)
 	__attribute__((weak, alias("__cfi_flash_bank_addr")));
 
+static phys_addr_t __cfi_flash_bank_size(int i)
+{
+#ifdef CONFIG_SYS_FLASH_BANKS_SIZES
+	return ((unsigned long [])CONFIG_SYS_FLASH_BANKS_SIZES)[i];
+#else
+	return 0;
+#endif
+}
+phys_addr_t cfi_flash_bank_size(int i)
+	__attribute__((weak, alias("__cfi_flash_bank_size")));
+
 static void __flash_write8(u8 value, void *addr)
 {
 	__raw_writeb(value, addr);
@@ -1826,7 +1837,7 @@ static void flash_fixup_stm(flash_info_t *info, struct cfi_qry *qry)
  * The following code cannot be run from FLASH!
  *
  */
-ulong flash_get_size (phys_addr_t base, int banknum)
+ulong flash_get_size (phys_addr_t base, int banknum, unsigned long max_size)
 {
 	flash_info_t *info = &flash_info[banknum];
 	int i, j;
@@ -1915,6 +1926,13 @@ ulong flash_get_size (phys_addr_t base, int banknum)
 		debug ("size_ratio %d port %d bits chip %d bits\n",
 		       size_ratio, info->portwidth << CFI_FLASH_SHIFT_WIDTH,
 		       info->chipwidth << CFI_FLASH_SHIFT_WIDTH);
+		info->size = 1 << qry.dev_size;
+		/* multiply the size by the number of chips */
+		info->size *= size_ratio;
+		if (max_size && (info->size > max_size)) {
+			debug("[truncated from %ldMiB]", info->size >> 20);
+			info->size = max_size;
+		}
 		debug ("found %d erase regions\n", num_erase_regions);
 		sect_cnt = 0;
 		sector = base;
@@ -1935,6 +1953,8 @@ ulong flash_get_size (phys_addr_t base, int banknum)
 			debug ("erase_region_count = %d erase_region_size = %d\n",
 				erase_region_count, erase_region_size);
 			for (j = 0; j < erase_region_count; j++) {
+				if (sector - base >= info->size)
+					break;
 				if (sect_cnt >= CONFIG_SYS_MAX_FLASH_SECT) {
 					printf("ERROR: too many flash sectors\n");
 					break;
@@ -1968,9 +1988,6 @@ ulong flash_get_size (phys_addr_t base, int banknum)
 		}
 
 		info->sector_count = sect_cnt;
-		info->size = 1 << qry.dev_size;
-		/* multiply the size by the number of chips */
-		info->size *= size_ratio;
 		info->buffer_size = 1 << le16_to_cpu(qry.max_buf_write_size);
 		tmp = 1 << qry.block_erase_timeout_typ;
 		info->erase_blk_tout = tmp *
@@ -2026,7 +2043,8 @@ unsigned long flash_init (void)
 		flash_info[i].flash_id = FLASH_UNKNOWN;
 
 		if (!flash_detect_legacy(cfi_flash_bank_addr(i), i))
-			flash_get_size(cfi_flash_bank_addr(i), i);
+			flash_get_size(cfi_flash_bank_addr(i), i,
+					cfi_flash_bank_size(i));
 		size += flash_info[i].size;
 		if (flash_info[i].flash_id == FLASH_UNKNOWN) {
 #ifndef CONFIG_SYS_FLASH_QUIET_TEST
Signature · 1 line
1.7.2.3
#8 lore raw

PATCH 4/5 cfi_flash: handle 'chip size exceeds address window' situation

Dear Stefan,

Quoted 19 lines · In message <[email protected]> you wrote:

On some boards we have flash mapped high in the address space with considerably small window (say 0xFE000000 and 32MB). When we install bigger chip (say 64MB) on such a board strange things happen (flash_write() doesn't work at all, for ex). That's because cfi_flash driver doesn't care about window size at all.
Of course, cleanest solution would probably be to just extend address window to be able to map the whole flash but for legacy/compatibility reasons some people prefer just truncate the flash size and never use the upper part.
This patch adds an option for cfi_flash driver to handle this situation properly. To achieve this we add the new function cfi_flash_bank_size() which can be provided by the board code and weak-aliased to default implementation that returns value from the CONFIG_SYS_FLASH_BANKS_SIZES array if it's defined or 0 otherwise (the last case is added for compatibility).
If non-zero flash bank size is provided and detected chip size is bigger than provided address window size the warning will be displayed and flash chip will be truncated.

Quoted 4 lines
---
 drivers/mtd/cfi_flash.c |   28 +++++++++++++++++++++++-----
 1 files changed, 23 insertions(+), 5 deletions(-)

If this patch looks OK with you, then please ACK it; I suggest I will pull it with the resto of this patch series directly then.

Thanks.

Best regards,

Wolfgang Denk

Signature · 4 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
It's not an optical illusion, it just looks like one.   -- Phil White
#9 lore raw

PATCH 4/5 cfi_flash: handle 'chip size exceeds address window' situation

In reply to Ilya Yanok

Hi Ilya,

Quoted 32 lines · On Thursday 21 October 2010 17:20:12 Ilya Yanok wrote:

On some boards we have flash mapped high in the address space with considerably small window (say 0xFE000000 and 32MB). When we install bigger chip (say 64MB) on such a board strange things happen (flash_write() doesn't work at all, for ex). That's because cfi_flash driver doesn't care about window size at all.
Of course, cleanest solution would probably be to just extend address window to be able to map the whole flash but for legacy/compatibility reasons some people prefer just truncate the flash size and never use the upper part.
This patch adds an option for cfi_flash driver to handle this situation properly. To achieve this we add the new function cfi_flash_bank_size() which can be provided by the board code and weak-aliased to default implementation that returns value from the CONFIG_SYS_FLASH_BANKS_SIZES array if it's defined or 0 otherwise (the last case is added for compatibility).
If non-zero flash bank size is provided and detected chip size is bigger than provided address window size the warning will be displayed and flash chip will be truncated.

---
 drivers/mtd/cfi_flash.c |   28 +++++++++++++++++++++++-----
 1 files changed, 23 insertions(+), 5 deletions(-)
drivers/mtd/cfi_flash.c +0 -0
index 798902f..c444b53 100644
@@ -85,6 +85,17 @@ static phys_addr_t __cfi_flash_bank_addr(int i)
 phys_addr_t cfi_flash_bank_addr(int i)
 	__attribute__((weak, alias("__cfi_flash_bank_addr")));
 

drivers/mtd/cfi_flash.c static phys_addr_t __cfi_flash_bank_addr(int i) · line 97

Quoted 10 lines
drivers/mtd/cfi_flash.c +10 -0
+static phys_addr_t __cfi_flash_bank_size(int i)
+{
+#ifdef CONFIG_SYS_FLASH_BANKS_SIZES
+	return ((unsigned long [])CONFIG_SYS_FLASH_BANKS_SIZES)[i];
+#else
+	return 0;
+#endif
+}
+phys_addr_t cfi_flash_bank_size(int i)
+	__attribute__((weak, alias("__cfi_flash_bank_size")));

Please use a consistent type here (phys_addr_t vs. unsigned long). unsigned long seems to be the correct one looking at the caller function.

Otherwise:

Wolfgang, feel free to pull this directly if you like.

Cheers,
Stefan

--
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-0 Fax: (+49)-8142-66989-80 Email: office at denx.de

#10 lore raw

PATCH 4/5 cfi_flash: handle 'chip size exceeds address window' situation

Dear Stefan Roese,

Quoted 14 lines · In message <[email protected]> you wrote:

drivers/mtd/cfi_flash.c static phys_addr_t __cfi_flash_bank_addr(int i) · line 97

Quoted 11 lines
drivers/mtd/cfi_flash.c +10 -0
+static phys_addr_t __cfi_flash_bank_size(int i)
+{
+#ifdef CONFIG_SYS_FLASH_BANKS_SIZES
+	return ((unsigned long [])CONFIG_SYS_FLASH_BANKS_SIZES)[i];
+#else
+	return 0;
+#endif
+}
+phys_addr_t cfi_flash_bank_size(int i)
+	__attribute__((weak, alias("__cfi_flash_bank_size")));

Please use a consistent type here (phys_addr_t vs. unsigned long). unsigned long seems to be the correct one looking at the caller function.

Well, phys_addr_t would be a more appropriate type for all these arguments, but that would be a bigger change (and as such out of the scope of this patch), so we should use unsigned long here.

Quoted 5 lines

Otherwise:

Wolfgang, feel free to pull this directly if you like.

Will do, thanks.

Ilya, I will make the phys_addr_t => unsigned long change when applying; no need to resubmit.

Best regards,

Wolfgang Denk

Signature · 5 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
"The number  of  Unix  installations  has  grown  to  10,  with  more
expected."    - The Unix Programmer's Manual, 2nd Edition, June, 1972
#11 lore raw

PATCH 4/5 cfi_flash: handle 'chip size exceeds address window' situation

In reply to Ilya Yanok

Dear Ilya Yanok,

Quoted 19 lines · In message <[email protected]> you wrote:

On some boards we have flash mapped high in the address space with considerably small window (say 0xFE000000 and 32MB). When we install bigger chip (say 64MB) on such a board strange things happen (flash_write() doesn't work at all, for ex). That's because cfi_flash driver doesn't care about window size at all.
Of course, cleanest solution would probably be to just extend address window to be able to map the whole flash but for legacy/compatibility reasons some people prefer just truncate the flash size and never use the upper part.
This patch adds an option for cfi_flash driver to handle this situation properly. To achieve this we add the new function cfi_flash_bank_size() which can be provided by the board code and weak-aliased to default implementation that returns value from the CONFIG_SYS_FLASH_BANKS_SIZES array if it's defined or 0 otherwise (the last case is added for compatibility).
If non-zero flash bank size is provided and detected chip size is bigger than provided address window size the warning will be displayed and flash chip will be truncated.

Quoted 4 lines
---
 drivers/mtd/cfi_flash.c |   28 +++++++++++++++++++++++-----
 1 files changed, 23 insertions(+), 5 deletions(-)

Applied, with changes as suggested by Stefan. Thanks.

Best regards,

Wolfgang Denk

Signature · 5 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Every living thing wants to survive.
	-- Spock, "The Ultimate Computer", stardate 4731.3
author
#12 lore raw

PATCH 5/5 a4m072: add CONFIG_SYS_FLASH_BANKS_SIZES define

In reply to Ilya Yanok

This patch adds CONFIG_SYS_FLASH_BANKS_SIZES define to make use of new cfi_flash driver ability to detect flash chips that are bigger than a corresponding address window (we have such situation on some revs of a4m072).

---
 include/configs/a4m072.h |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
include/configs/a4m072.h +1 -0
index a24b304..f18bc45 100644
@@ -228,6 +228,7 @@
 #define CONFIG_SYS_FLASH_CFI
 #define CONFIG_SYS_FLASH_CFI_WIDTH	FLASH_CFI_16BIT
 #define CONFIG_SYS_FLASH_BANKS_LIST	{CONFIG_SYS_CS0_START}
+#define CONFIG_SYS_FLASH_BANKS_SIZES	{CONFIG_SYS_CS0_SIZE}
 
 /*
  * Environment settings
Signature · 1 line
1.7.2.3
#13 lore raw

PATCH 5/5 a4m072: add CONFIG_SYS_FLASH_BANKS_SIZES define

Dear Ilya Yanok,

Quoted 9 lines · In message <[email protected]> you wrote:

This patch adds CONFIG_SYS_FLASH_BANKS_SIZES define to make use of new cfi_flash driver ability to detect flash chips that are bigger than a corresponding address window (we have such situation on some revs of a4m072).

---
 include/configs/a4m072.h |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

Applied, thanks.

Best regards,

Wolfgang Denk

Signature · 5 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
The optimum committee has no members.
                                                   - Norman Augustine