Skip to contentSkip to conversation

Add MTD support to Aspeed Flash driver

PATCH In review Adriana Kobylak 3 participants 4 messages Aug 7, 2017 – Aug 24, 2017

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Add MTD support to Aspeed Flash driver

Add support to the aspeed flash driver to enable the common mtd layer through CONFIG_FLASH_CFI_MTD.

This enables the flash to be used by u-boot mtd drivers including the mtdparts and ubi commands.

---
 arch/arm/mach-aspeed/flash.c | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)
arch/arm/mach-aspeed/flash.c +20 -0
index 9c5ead6..e1e3cf8 100644
@@ -124,6 +124,22 @@ flash_info_t flash_info[CONFIG_SYS_MAX_FLASH_BANKS];		/* FLASH chips info */
 /* specificspi */
 #define SpecificSPI_N25Q512	0x00000001
 
+#ifdef CONFIG_FLASH_CFI_MTD
+static uint flash_verbose=1;
+void flash_set_verbose(uint v)
+{
+	flash_verbose = v;
+}
+
+unsigned long flash_sector_size(flash_info_t *info, flash_sect_t sect)
+{
+	if (sect != (info->sector_count - 1))
+		return info->start[sect + 1] - info->start[sect];
+	else
+		return info->start[0] + info->size - info->start[sect];
+}
+#endif
+
 /*-----------------------------------------------------------------------*/
 static u32 ast_spi_calculate_divisor(u32 max_speed_hz)
 {
@@ -1372,6 +1388,10 @@ unsigned long flash_init (void)
 		       flash_get_info(CONFIG_ENV_ADDR_REDUND));
 #endif
 
+#ifdef CONFIG_FLASH_CFI_MTD
+	cfi_mtd_init();
+#endif
+
 	return (size);
 }
 
Signature · 1 line
1.8.2.2
maintainer
#1 lore raw
Quoted 24 lines · Adriana Kobylak

Add support to the aspeed flash driver to enable the common mtd layer through CONFIG_FLASH_CFI_MTD.

This enables the flash to be used by u-boot mtd drivers including the mtdparts and ubi commands.

---
 arch/arm/mach-aspeed/flash.c | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)
arch/arm/mach-aspeed/flash.c +4 -0
index 9c5ead6..e1e3cf8 100644
@@ -124,6 +124,22 @@ flash_info_t flash_info[CONFIG_SYS_MAX_FLASH_BANKS];               /* FLASH chips info */
 /* specificspi */
 #define SpecificSPI_N25Q512    0x00000001
 
+#ifdef CONFIG_FLASH_CFI_MTD
+static uint flash_verbose=1;
+void flash_set_verbose(uint v)
+{

arch/arm/mach-aspeed/flash.c flash_info_t flash_info[CONFIG_SYS_MAX_FLASH_BANKS]; /* FLASH chips info */ · line 140

Quoted 10 lines
arch/arm/mach-aspeed/flash.c +10 -0
+       flash_verbose = v;
+}
+
+unsigned long flash_sector_size(flash_info_t *info, flash_sect_t sect)
+{
+       if (sect != (info->sector_count - 1))
+               return info->start[sect + 1] - info->start[sect];
+       else
+               return info->start[0] + info->size - info->start[sect];
+}

This function looks like it's copied from cfi_flash.c (line 197).

Can you explain why we're duplicating it here?

Quoted 19 lines
arch/arm/mach-aspeed/flash.c +6 -1
+#endif
+
 /*-----------------------------------------------------------------------*/
 static u32 ast_spi_calculate_divisor(u32 max_speed_hz)
 {
@@ -1372,6 +1388,10 @@ unsigned long flash_init (void)
                       flash_get_info(CONFIG_ENV_ADDR_REDUND));
 #endif
 
+#ifdef CONFIG_FLASH_CFI_MTD
+       cfi_mtd_init();
+#endif
+
        return (size);
 }
 
--

1.8.2.2

author
#2 lore raw
Quoted 41 lines · Joel Stanley
Quoted 35 lines · Adriana Kobylak

Add support to the aspeed flash driver to enable the common mtd layer through CONFIG_FLASH_CFI_MTD.

This enables the flash to be used by u-boot mtd drivers including the mtdparts and ubi commands.

---
 arch/arm/mach-aspeed/flash.c | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)
arch/arm/mach-aspeed/flash.c +0 -0
index 9c5ead6..e1e3cf8 100644
@@ -124,6 +124,22 @@ flash_info_t 

flash_info[CONFIG_SYS_MAX_FLASH_BANKS]; /* FLASH chips info */
/* specificspi */
#define SpecificSPI_N25Q512 0x00000001

arch/arm/mach-aspeed/flash.c +8 -0
+#ifdef CONFIG_FLASH_CFI_MTD
+static uint flash_verbose=1;
+void flash_set_verbose(uint v)
+{
+       flash_verbose = v;
+}
+
+unsigned long flash_sector_size(flash_info_t *info, flash_sect_t 

sect)

arch/arm/mach-aspeed/flash.c +5 -0
+{
+       if (sect != (info->sector_count - 1))
+               return info->start[sect + 1] - info->start[sect];
+       else
+               return info->start[0] + info->size - 
Quoted 2 lines

info->start[sect];
+}

This function looks like it's copied from cfi_flash.c (line 197).

Quoted 1 line

Can you explain why we're duplicating it here?

Yes, it's duplicated :) . What I understood from Milton is that this function would be available if we enabled the CONFIG_FLASH_CFI_DRIVER, but we don't want to enable the driver as this would cause some collisions, we just want to enable CONFIG_FLASH_CFI_MTD so these functions are the only ones needed that the driver would provide.

Quoted 21 lines
Quoted 21 lines
arch/arm/mach-aspeed/flash.c +2 -0
+#endif
+

/*-----------------------------------------------------------------------*/
static u32 ast_spi_calculate_divisor(u32 max_speed_hz)
{

arch/arm/mach-aspeed/flash.c +4 -1
@@ -1372,6 +1388,10 @@ unsigned long flash_init (void)
                       flash_get_info(CONFIG_ENV_ADDR_REDUND));
 #endif
 
+#ifdef CONFIG_FLASH_CFI_MTD
+       cfi_mtd_init();
+#endif
+
        return (size);
 }
 
--

1.8.2.2

#3 lore raw
In reply to Adriana Kobylak
Quoted 8 lines · Adriana Kobylak

Add support to the aspeed flash driver to enable the common mtd layer through CONFIG_FLASH_CFI_MTD.

This enables the flash to be used by u-boot mtd drivers including the mtdparts and ubi commands.

Quoted 1 line

Hmm, the flash situation looks pretty messy. I guess the duplication is warranted for the moment.

Applied with Milton's ack.

Thanks,

Andrew

Quoted 42 lines

---
 arch/arm/mach-aspeed/flash.c | 20 ++++++++++++++++++++

 1 file changed, 20 insertions(+)
arch/arm/mach-aspeed/flash.c +0 -0
index 9c5ead6..e1e3cf8 100644

Review flash_info_t flash_info[CONFIG_SYS_MAX_FLASH_BANKS]; /* FLASH chips info */

Quoted 1 line
(quoted diff) +0 -0
@@ -124,6 +124,22 @@ flash_info_t flash_info[CONFIG_SYS_MAX_FLASH_BANKS];		/* FLASH chips info */

 /* specificspi */

arch/arm/mach-aspeed/flash.c flash_info_t flash_info[CONFIG_SYS_MAX_FLASH_BANKS]; /* FLASH chips info */ · line 125

Quoted 1 line
arch/arm/mach-aspeed/flash.c +0 -0
  #define SpecificSPI_N25Q512	0x00000001

arch/arm/mach-aspeed/flash.c +4 -0
+#ifdef CONFIG_FLASH_CFI_MTD
+static uint flash_verbose=1;
+void flash_set_verbose(uint v)
+{
Quoted 1 line
arch/arm/mach-aspeed/flash.c +1 -0
+	flash_verbose = v;
arch/arm/mach-aspeed/flash.c +4 -0
+}
+
+unsigned long flash_sector_size(flash_info_t *info, flash_sect_t sect)
+{
Quoted 4 lines
arch/arm/mach-aspeed/flash.c +4 -0
+	if (sect != (info->sector_count - 1))
+		return info->start[sect + 1] - info->start[sect];
+	else
+		return info->start[0] + info->size - info->start[sect];
arch/arm/mach-aspeed/flash.c +3 -0
+}
+#endif
+

 /*-----------------------------------------------------------------------*/ static u32 ast_spi_calculate_divisor(u32 max_speed_hz)
 {

arch/arm/mach-aspeed/flash.c +0 -0
@@ -1372,6 +1388,10 @@ unsigned long flash_init (void)
 >  		       flash_get_info(CONFIG_ENV_ADDR_REDUND));
  #endif


+#ifdef CONFIG_FLASH_CFI_MTD

Quoted 1 line
arch/arm/mach-aspeed/flash.c +1 -0
+	cfi_mtd_init();
arch/arm/mach-aspeed/flash.c +2 -0
+#endif
+

arch/arm/mach-aspeed/flash.c unsigned long flash_init (void) · line 1395

Quoted 1 line
arch/arm/mach-aspeed/flash.c +0 -0
  	return (size);

 }