提交 6ea808ef 编写于 作者: P Piotr Ziecik 提交者: Stefan Roese

cfi_flash: Add interface for flash verbosity control

Add interface for flash verbosity control. It allows
to disable output from low-level flash API. It is useful
when calling these low-level functions from context other
than flash commands (for example the MTD/CFI interface
implmentation).
Signed-off-by: NPiotr Ziecik <kosmo@semihalf.com>
Signed-off-by: NStefan Roese <sr@denx.de>
上级 ebc9784c
...@@ -158,6 +158,7 @@ typedef union { ...@@ -158,6 +158,7 @@ typedef union {
#define NUM_ERASE_REGIONS 4 /* max. number of erase regions */ #define NUM_ERASE_REGIONS 4 /* max. number of erase regions */
static uint flash_offset_cfi[2] = { FLASH_OFFSET_CFI, FLASH_OFFSET_CFI_ALT }; static uint flash_offset_cfi[2] = { FLASH_OFFSET_CFI, FLASH_OFFSET_CFI_ALT };
static uint flash_verbose = 1;
/* use CONFIG_SYS_MAX_FLASH_BANKS_DETECT if defined */ /* use CONFIG_SYS_MAX_FLASH_BANKS_DETECT if defined */
#ifdef CONFIG_SYS_MAX_FLASH_BANKS_DETECT #ifdef CONFIG_SYS_MAX_FLASH_BANKS_DETECT
...@@ -1070,7 +1071,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) ...@@ -1070,7 +1071,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last)
if (prot) { if (prot) {
printf ("- Warning: %d protected sectors will not be erased!\n", printf ("- Warning: %d protected sectors will not be erased!\n",
prot); prot);
} else { } else if (flash_verbose) {
putc ('\n'); putc ('\n');
} }
...@@ -1117,11 +1118,14 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) ...@@ -1117,11 +1118,14 @@ int flash_erase (flash_info_t * info, int s_first, int s_last)
if (flash_full_status_check if (flash_full_status_check
(info, sect, info->erase_blk_tout, "erase")) { (info, sect, info->erase_blk_tout, "erase")) {
rcode = 1; rcode = 1;
} else } else if (flash_verbose)
putc ('.'); putc ('.');
} }
} }
puts (" done\n");
if (flash_verbose)
puts (" done\n");
return rcode; return rcode;
} }
...@@ -1233,14 +1237,16 @@ void flash_print_info (flash_info_t * info) ...@@ -1233,14 +1237,16 @@ void flash_print_info (flash_info_t * info)
*/ */
#ifdef CONFIG_FLASH_SHOW_PROGRESS #ifdef CONFIG_FLASH_SHOW_PROGRESS
#define FLASH_SHOW_PROGRESS(scale, dots, digit, dots_sub) \ #define FLASH_SHOW_PROGRESS(scale, dots, digit, dots_sub) \
dots -= dots_sub; \ if (flash_verbose) { \
if ((scale > 0) && (dots <= 0)) { \ dots -= dots_sub; \
if ((digit % 5) == 0) \ if ((scale > 0) && (dots <= 0)) { \
printf ("%d", digit / 5); \ if ((digit % 5) == 0) \
else \ printf ("%d", digit / 5); \
putc ('.'); \ else \
digit--; \ putc ('.'); \
dots += scale; \ digit--; \
dots += scale; \
} \
} }
#else #else
#define FLASH_SHOW_PROGRESS(scale, dots, digit, dots_sub) #define FLASH_SHOW_PROGRESS(scale, dots, digit, dots_sub)
...@@ -1958,6 +1964,11 @@ ulong flash_get_size (ulong base, int banknum) ...@@ -1958,6 +1964,11 @@ ulong flash_get_size (ulong base, int banknum)
return (info->size); return (info->size);
} }
void flash_set_verbose(uint v)
{
flash_verbose = v;
}
/*----------------------------------------------------------------------- /*-----------------------------------------------------------------------
*/ */
unsigned long flash_init (void) unsigned long flash_init (void)
......
...@@ -95,6 +95,7 @@ extern int flash_sect_erase (ulong addr_first, ulong addr_last); ...@@ -95,6 +95,7 @@ extern int flash_sect_erase (ulong addr_first, ulong addr_last);
extern int flash_sect_protect (int flag, ulong addr_first, ulong addr_last); extern int flash_sect_protect (int flag, ulong addr_first, ulong addr_last);
extern int flash_sect_roundb (ulong *addr); extern int flash_sect_roundb (ulong *addr);
extern unsigned long flash_sector_size(flash_info_t *info, flash_sect_t sect); extern unsigned long flash_sector_size(flash_info_t *info, flash_sect_t sect);
extern void flash_set_verbose(uint);
/* common/flash.c */ /* common/flash.c */
extern void flash_protect (int flag, ulong from, ulong to, flash_info_t *info); extern void flash_protect (int flag, ulong from, ulong to, flash_info_t *info);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册