Skip to contentSkip to conversation

ssb: Flash memory improvements

PATCH In review Rafał Miłecki 2 participants 5 messages Jul 22, 2012 – Jul 25, 2012

Subsystems (3)
lore
Share & tools
lore

Rafał Miłecki

author maintainer
#0 lore raw

cover ssb: Flash memory improvements

This patchset provides some minor improvements to the flash memory support. That is based on the OpenWRT tree, recent bcma changes and some bits from myself.

I don't have any SSB-based embedded device, so it's compile tested only. And to be honest, I didn't even compile bcm47xx after that changes.

Hauke: I believe you have some SSB SoC, could you give this code a try, please? I'm doing my best to mainline some random stuff, but I don't have hardware to test everything.

Rafał Miłecki (3):
ssb: update defines
ssb: move flash info to ChipCommon driver
ssb: check for flash presentence

 arch/mips/bcm47xx/nvram.c                 |    8 +++---
 arch/mips/bcm47xx/wgt634u.c               |   14 ++++++------
 drivers/ssb/driver_mipscore.c             |   34 +++++++++++++++++++++-------
 include/linux/ssb/ssb_driver_chipcommon.h |   15 ++++++++++++-
 include/linux/ssb/ssb_driver_mips.h       |    4 ---
 5 files changed, 50 insertions(+), 25 deletions(-)
Signature · 1 line
1.7.7
author maintainer
#1 lore raw

PATCH 1/3 ssb: update defines

---
 drivers/ssb/driver_mipscore.c             |    8 ++++----
 include/linux/ssb/ssb_driver_chipcommon.h |    4 +++-
 2 files changed, 7 insertions(+), 5 deletions(-)
drivers/ssb/driver_mipscore.c +4 -4
index 7e2ddc0..f8813f8 100644
@@ -192,14 +192,14 @@ static void ssb_mips_flash_detect(struct ssb_mipscore *mcore)
 
 	mcore->flash_buswidth = 2;
 	if (bus->chipco.dev) {
-		mcore->flash_window = 0x1c000000;
-		mcore->flash_window_size = 0x02000000;
+		mcore->flash_window = SSB_FLASH2;
+		mcore->flash_window_size = SSB_FLASH2_SZ;
 		if ((ssb_read32(bus->chipco.dev, SSB_CHIPCO_FLASH_CFG)
 		               & SSB_CHIPCO_CFG_DS16) == 0)
 			mcore->flash_buswidth = 1;
 	} else {
-		mcore->flash_window = 0x1fc00000;
-		mcore->flash_window_size = 0x00400000;
+		mcore->flash_window = SSB_FLASH1;
+		mcore->flash_window_size = SSB_FLASH1_SZ;
 	}
 }
 
include/linux/ssb/ssb_driver_chipcommon.h +3 -1
index 1a6b004..c2b02a5 100644
@@ -504,7 +504,9 @@
 #define SSB_CHIPCO_FLASHCTL_ST_SE	0x02D8		/* Sector Erase */
 #define SSB_CHIPCO_FLASHCTL_ST_BE	0x00C7		/* Bulk Erase */
 #define SSB_CHIPCO_FLASHCTL_ST_DP	0x00B9		/* Deep Power-down */
-#define SSB_CHIPCO_FLASHCTL_ST_RSIG	0x03AB		/* Read Electronic Signature */
+#define SSB_CHIPCO_FLASHCTL_ST_RES	0x03AB		/* Read Electronic Signature */
+#define SSB_CHIPCO_FLASHCTL_ST_CSA	0x1000		/* Keep chip select asserted */
+#define SSB_CHIPCO_FLASHCTL_ST_SSE	0x0220		/* Sub-sector Erase */
 
 /* Status register bits for ST flashes */
 #define SSB_CHIPCO_FLASHSTA_ST_WIP	0x01		/* Write In Progress */
Signature · 1 line
1.7.7
author maintainer
#2 lore raw

PATCH 2/3 ssb: move flash info to ChipCommon driver

In reply to Rafał Miłecki
---
 arch/mips/bcm47xx/nvram.c                 |    8 ++++----
 arch/mips/bcm47xx/wgt634u.c               |   14 +++++++-------
 drivers/ssb/driver_mipscore.c             |   12 ++++++------
 include/linux/ssb/ssb_driver_chipcommon.h |   11 +++++++++++
 include/linux/ssb/ssb_driver_mips.h       |    4 ----
 5 files changed, 28 insertions(+), 21 deletions(-)
arch/mips/bcm47xx/nvram.c +4 -4
index d43ceff..53822db 100644
@@ -27,7 +27,7 @@ static char nvram_buf[NVRAM_SPACE];
 static void early_nvram_init(void)
 {
 #ifdef CONFIG_BCM47XX_SSB
-	struct ssb_mipscore *mcore_ssb;
+	struct ssb_chipcommon *ssb_cc;
 #endif
 #ifdef CONFIG_BCM47XX_BCMA
 	struct bcma_drv_cc *bcma_cc;
@@ -42,9 +42,9 @@ static void early_nvram_init(void)
 	switch (bcm47xx_bus_type) {
 #ifdef CONFIG_BCM47XX_SSB
 	case BCM47XX_BUS_TYPE_SSB:
-		mcore_ssb = &bcm47xx_bus.ssb.mipscore;
-		base = mcore_ssb->flash_window;
-		lim = mcore_ssb->flash_window_size;
+		ssb_cc = &bcm47xx_bus.ssb.chipco;
+		base = ssb_cc->pflash.window;
+		lim = ssb_cc->pflash.window_size;
 		break;
 #endif
 #ifdef CONFIG_BCM47XX_BCMA
arch/mips/bcm47xx/wgt634u.c +7 -7
index e9f9ec8..616da92 100644
@@ -142,24 +142,24 @@ static int __init wgt634u_init(void)
 	if (et0mac[0] == 0x00 &&
 	    ((et0mac[1] == 0x09 && et0mac[2] == 0x5b) ||
 	     (et0mac[1] == 0x0f && et0mac[2] == 0xb5))) {
-		struct ssb_mipscore *mcore = &bcm47xx_bus.ssb.mipscore;
+		struct ssb_chipcommon *cc = &bcm47xx_bus.ssb.chipco;
 
 		printk(KERN_INFO "WGT634U machine detected.\n");
 
 		if (!request_irq(gpio_to_irq(WGT634U_GPIO_RESET),
 				 gpio_interrupt, IRQF_SHARED,
-				 "WGT634U GPIO", &bcm47xx_bus.ssb.chipco)) {
+				 "WGT634U GPIO", cc)) {
 			gpio_direction_input(WGT634U_GPIO_RESET);
 			gpio_intmask(WGT634U_GPIO_RESET, 1);
-			ssb_chipco_irq_mask(&bcm47xx_bus.ssb.chipco,
+			ssb_chipco_irq_mask(cc,
 					    SSB_CHIPCO_IRQ_GPIO,
 					    SSB_CHIPCO_IRQ_GPIO);
 		}
 
-		wgt634u_flash_data.width = mcore->flash_buswidth;
-		wgt634u_flash_resource.start = mcore->flash_window;
-		wgt634u_flash_resource.end = mcore->flash_window
-					   + mcore->flash_window_size
+		wgt634u_flash_data.width = cc->pflash.buswidth;
+		wgt634u_flash_resource.start = cc->pflash.window;
+		wgt634u_flash_resource.end = cc->pflash.window
+					   + cc->pflash.window_size
 					   - 1;
 		return platform_add_devices(wgt634u_devices,
 					    ARRAY_SIZE(wgt634u_devices));
drivers/ssb/driver_mipscore.c +6 -6
index f8813f8..873bc0a 100644
@@ -190,16 +190,16 @@ static void ssb_mips_flash_detect(struct ssb_mipscore *mcore)
 {
 	struct ssb_bus *bus = mcore->dev->bus;
 
-	mcore->flash_buswidth = 2;
+	bus->chipco.pflash.buswidth = 2;
 	if (bus->chipco.dev) {
-		mcore->flash_window = SSB_FLASH2;
-		mcore->flash_window_size = SSB_FLASH2_SZ;
+		bus->chipco.pflash.window = SSB_FLASH2;
+		bus->chipco.pflash.window_size = SSB_FLASH2_SZ;
 		if ((ssb_read32(bus->chipco.dev, SSB_CHIPCO_FLASH_CFG)
 		               & SSB_CHIPCO_CFG_DS16) == 0)
-			mcore->flash_buswidth = 1;
+			bus->chipco.pflash.buswidth = 1;
 	} else {
-		mcore->flash_window = SSB_FLASH1;
-		mcore->flash_window_size = SSB_FLASH1_SZ;
+		bus->chipco.pflash.window = SSB_FLASH1;
+		bus->chipco.pflash.window_size = SSB_FLASH1_SZ;
 	}
 }
 
include/linux/ssb/ssb_driver_chipcommon.h +11 -0
index c2b02a5..ccb51d1 100644
@@ -584,6 +584,14 @@ struct ssb_chipcommon_pmu {
 	u32 crystalfreq;	/* The active crystal frequency (in kHz) */
 };
 
+#ifdef CONFIG_SSB_DRIVER_MIPS
+struct ssb_pflash {
+	u8 buswidth;
+	u32 window;
+	u32 window_size;
+};
+#endif /* CONFIG_SSB_DRIVER_MIPS */
+
 struct ssb_chipcommon {
 	struct ssb_device *dev;
 	u32 capabilities;
@@ -591,6 +599,9 @@ struct ssb_chipcommon {
 	/* Fast Powerup Delay constant */
 	u16 fast_pwrup_delay;
 	struct ssb_chipcommon_pmu pmu;
+#ifdef CONFIG_SSB_DRIVER_MIPS
+	struct ssb_pflash pflash;
+#endif /* CONFIG_SSB_DRIVER_MIPS */
 };
 
 static inline bool ssb_chipco_available(struct ssb_chipcommon *cc)
include/linux/ssb/ssb_driver_mips.h +0 -4
index 5f44e97..7e707ff 100644
@@ -19,10 +19,6 @@ struct ssb_mipscore {
 
 	int nr_serial_ports;
 	struct ssb_serial_port serial_ports[4];
-
-	u8 flash_buswidth;
-	u32 flash_window;
-	u32 flash_window_size;
 };
 
 extern void ssb_mipscore_init(struct ssb_mipscore *mcore);
Signature · 1 line
1.7.7
author maintainer
#4 lore raw

PATCH 3/3 ssb: check for flash presentence

In reply to Rafał Miłecki

We can not assume parallel flash is always present, there are boards with *serial* flash and probably some without flash at all.

---
 drivers/ssb/driver_mipscore.c |   28 ++++++++++++++++++++++------
 1 files changed, 22 insertions(+), 6 deletions(-)
drivers/ssb/driver_mipscore.c +22 -6
index 873bc0a..266a4c8 100644
@@ -190,16 +190,32 @@ static void ssb_mips_flash_detect(struct ssb_mipscore *mcore)
 {
 	struct ssb_bus *bus = mcore->dev->bus;
 
-	bus->chipco.pflash.buswidth = 2;
-	if (bus->chipco.dev) {
+	/* When there is no chipcommon on the bus there is 4MB flash */
+	if (!bus->chipco.dev) {
+		bus->chipco.pflash.buswidth = 2;
+		bus->chipco.pflash.window = SSB_FLASH1;
+		bus->chipco.pflash.window_size = SSB_FLASH1_SZ;
+		return;
+	}
+
+	/* Read info about flash from the ChipCommon */
+	switch (bus->chipco.capabilities & SSB_CHIPCO_CAP_FLASHT) {
+	case SSB_CHIPCO_FLASHT_STSER:
+	case SSB_CHIPCO_FLASHT_ATSER:
+		pr_err("Serial flash not supported\n");
+		break;
+	case SSB_CHIPCO_FLASHT_PARA:
+		pr_info("Found parallel flash\n");
 		bus->chipco.pflash.window = SSB_FLASH2;
 		bus->chipco.pflash.window_size = SSB_FLASH2_SZ;
 		if ((ssb_read32(bus->chipco.dev, SSB_CHIPCO_FLASH_CFG)
-		               & SSB_CHIPCO_CFG_DS16) == 0)
+		     & SSB_CHIPCO_CFG_DS16) == 0)
 			bus->chipco.pflash.buswidth = 1;
-	} else {
-		bus->chipco.pflash.window = SSB_FLASH1;
-		bus->chipco.pflash.window_size = SSB_FLASH1_SZ;
+		else
+			bus->chipco.pflash.buswidth = 2;
+		break;
+	default:
+		pr_err("Flash type not supported\n");
 	}
 }
 
Signature · 1 line
1.7.7
maintainer
#3 lore raw

Re: [RFT][PATCH 2/3] ssb: move flash info to ChipCommon driver

In reply to Rafał Miłecki

Moving the structure for parallel flash into chipCommon sturct is not right, because there are some old SoCs out there without a ChipCommon core, but with an extif core and they have parallel flash. Serial flash is just available on SoCs with a ChipCommon core.

My original plan was to move the structures for parallel and serial flash into a union, because I have never seen a SoC with both flash types, but as this saves so little memory I would not do that any more. What about putting the struct directly into the bus struct?

We still need an incicator if and which flash type was found on the device or we register it directly from ssb and not in the platform code under arch/mips/.

The last two points are also affecting bcma.

Hauke

Quoted 144 lines · Rafał Miłecki
---
 arch/mips/bcm47xx/nvram.c                 |    8 ++++----
 arch/mips/bcm47xx/wgt634u.c               |   14 +++++++-------
 drivers/ssb/driver_mipscore.c             |   12 ++++++------
 include/linux/ssb/ssb_driver_chipcommon.h |   11 +++++++++++
 include/linux/ssb/ssb_driver_mips.h       |    4 ----
 5 files changed, 28 insertions(+), 21 deletions(-)
arch/mips/bcm47xx/nvram.c +4 -4
index d43ceff..53822db 100644
@@ -27,7 +27,7 @@ static char nvram_buf[NVRAM_SPACE];
 static void early_nvram_init(void)
 {
 #ifdef CONFIG_BCM47XX_SSB
-	struct ssb_mipscore *mcore_ssb;
+	struct ssb_chipcommon *ssb_cc;
 #endif
 #ifdef CONFIG_BCM47XX_BCMA
 	struct bcma_drv_cc *bcma_cc;
@@ -42,9 +42,9 @@ static void early_nvram_init(void)
 	switch (bcm47xx_bus_type) {
 #ifdef CONFIG_BCM47XX_SSB
 	case BCM47XX_BUS_TYPE_SSB:
-		mcore_ssb = &bcm47xx_bus.ssb.mipscore;
-		base = mcore_ssb->flash_window;
-		lim = mcore_ssb->flash_window_size;
+		ssb_cc = &bcm47xx_bus.ssb.chipco;
+		base = ssb_cc->pflash.window;
+		lim = ssb_cc->pflash.window_size;
 		break;
 #endif
 #ifdef CONFIG_BCM47XX_BCMA
arch/mips/bcm47xx/wgt634u.c +7 -7
index e9f9ec8..616da92 100644
@@ -142,24 +142,24 @@ static int __init wgt634u_init(void)
 	if (et0mac[0] == 0x00 &&
 	    ((et0mac[1] == 0x09 && et0mac[2] == 0x5b) ||
 	     (et0mac[1] == 0x0f && et0mac[2] == 0xb5))) {
-		struct ssb_mipscore *mcore = &bcm47xx_bus.ssb.mipscore;
+		struct ssb_chipcommon *cc = &bcm47xx_bus.ssb.chipco;
 
 		printk(KERN_INFO "WGT634U machine detected.\n");
 
 		if (!request_irq(gpio_to_irq(WGT634U_GPIO_RESET),
 				 gpio_interrupt, IRQF_SHARED,
-				 "WGT634U GPIO", &bcm47xx_bus.ssb.chipco)) {
+				 "WGT634U GPIO", cc)) {
 			gpio_direction_input(WGT634U_GPIO_RESET);
 			gpio_intmask(WGT634U_GPIO_RESET, 1);
-			ssb_chipco_irq_mask(&bcm47xx_bus.ssb.chipco,
+			ssb_chipco_irq_mask(cc,
 					    SSB_CHIPCO_IRQ_GPIO,
 					    SSB_CHIPCO_IRQ_GPIO);
 		}
 
-		wgt634u_flash_data.width = mcore->flash_buswidth;
-		wgt634u_flash_resource.start = mcore->flash_window;
-		wgt634u_flash_resource.end = mcore->flash_window
-					   + mcore->flash_window_size
+		wgt634u_flash_data.width = cc->pflash.buswidth;
+		wgt634u_flash_resource.start = cc->pflash.window;
+		wgt634u_flash_resource.end = cc->pflash.window
+					   + cc->pflash.window_size
 					   - 1;
 		return platform_add_devices(wgt634u_devices,
 					    ARRAY_SIZE(wgt634u_devices));
drivers/ssb/driver_mipscore.c +6 -6
index f8813f8..873bc0a 100644
@@ -190,16 +190,16 @@ static void ssb_mips_flash_detect(struct ssb_mipscore *mcore)
 {
 	struct ssb_bus *bus = mcore->dev->bus;
 
-	mcore->flash_buswidth = 2;
+	bus->chipco.pflash.buswidth = 2;
 	if (bus->chipco.dev) {
-		mcore->flash_window = SSB_FLASH2;
-		mcore->flash_window_size = SSB_FLASH2_SZ;
+		bus->chipco.pflash.window = SSB_FLASH2;
+		bus->chipco.pflash.window_size = SSB_FLASH2_SZ;
 		if ((ssb_read32(bus->chipco.dev, SSB_CHIPCO_FLASH_CFG)
 		               & SSB_CHIPCO_CFG_DS16) == 0)
-			mcore->flash_buswidth = 1;
+			bus->chipco.pflash.buswidth = 1;
 	} else {
-		mcore->flash_window = SSB_FLASH1;
-		mcore->flash_window_size = SSB_FLASH1_SZ;
+		bus->chipco.pflash.window = SSB_FLASH1;
+		bus->chipco.pflash.window_size = SSB_FLASH1_SZ;
 	}
 }
 
include/linux/ssb/ssb_driver_chipcommon.h +11 -0
index c2b02a5..ccb51d1 100644
@@ -584,6 +584,14 @@ struct ssb_chipcommon_pmu {
 	u32 crystalfreq;	/* The active crystal frequency (in kHz) */
 };
 
+#ifdef CONFIG_SSB_DRIVER_MIPS
+struct ssb_pflash {
+	u8 buswidth;
+	u32 window;
+	u32 window_size;
+};
+#endif /* CONFIG_SSB_DRIVER_MIPS */
+
 struct ssb_chipcommon {
 	struct ssb_device *dev;
 	u32 capabilities;
@@ -591,6 +599,9 @@ struct ssb_chipcommon {
 	/* Fast Powerup Delay constant */
 	u16 fast_pwrup_delay;
 	struct ssb_chipcommon_pmu pmu;
+#ifdef CONFIG_SSB_DRIVER_MIPS
+	struct ssb_pflash pflash;
+#endif /* CONFIG_SSB_DRIVER_MIPS */
 };
 
 static inline bool ssb_chipco_available(struct ssb_chipcommon *cc)
include/linux/ssb/ssb_driver_mips.h +0 -4
index 5f44e97..7e707ff 100644
@@ -19,10 +19,6 @@ struct ssb_mipscore {
 
 	int nr_serial_ports;
 	struct ssb_serial_port serial_ports[4];
-
-	u8 flash_buswidth;
-	u32 flash_window;
-	u32 flash_window_size;
 };
 
 extern void ssb_mipscore_init(struct ssb_mipscore *mcore);