* [RFT][PATCH 0/3] ssb: Flash memory improvements
@ 2012-07-22 16:51 Rafał Miłecki
2012-07-22 16:51 ` [RFT][PATCH 1/3] ssb: update defines Rafał Miłecki
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Rafał Miłecki @ 2012-07-22 16:51 UTC (permalink / raw)
To: linux-wireless, Hauke Mehrtens; +Cc: Rafał Miłecki
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(-)
--
1.7.7
^ permalink raw reply [flat|nested] 5+ messages in thread* [RFT][PATCH 1/3] ssb: update defines 2012-07-22 16:51 [RFT][PATCH 0/3] ssb: Flash memory improvements Rafał Miłecki @ 2012-07-22 16:51 ` Rafał Miłecki 2012-07-22 16:51 ` [RFT][PATCH 2/3] ssb: move flash info to ChipCommon driver Rafał Miłecki 2012-07-22 16:51 ` [RFT][PATCH 3/3] ssb: check for flash presentence Rafał Miłecki 2 siblings, 0 replies; 5+ messages in thread From: Rafał Miłecki @ 2012-07-22 16:51 UTC (permalink / raw) To: linux-wireless, Hauke Mehrtens; +Cc: Rafał Miłecki Signed-off-by: Rafał Miłecki <zajec5@gmail.com> --- drivers/ssb/driver_mipscore.c | 8 ++++---- include/linux/ssb/ssb_driver_chipcommon.h | 4 +++- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/drivers/ssb/driver_mipscore.c b/drivers/ssb/driver_mipscore.c index 7e2ddc0..f8813f8 100644 --- a/drivers/ssb/driver_mipscore.c +++ b/drivers/ssb/driver_mipscore.c @@ -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; } } diff --git a/include/linux/ssb/ssb_driver_chipcommon.h b/include/linux/ssb/ssb_driver_chipcommon.h index 1a6b004..c2b02a5 100644 --- a/include/linux/ssb/ssb_driver_chipcommon.h +++ b/include/linux/ssb/ssb_driver_chipcommon.h @@ -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 */ -- 1.7.7 ^ permalink raw reply related [flat|nested] 5+ messages in thread
* [RFT][PATCH 2/3] ssb: move flash info to ChipCommon driver 2012-07-22 16:51 [RFT][PATCH 0/3] ssb: Flash memory improvements Rafał Miłecki 2012-07-22 16:51 ` [RFT][PATCH 1/3] ssb: update defines Rafał Miłecki @ 2012-07-22 16:51 ` Rafał Miłecki 2012-07-25 12:18 ` Hauke Mehrtens 2012-07-22 16:51 ` [RFT][PATCH 3/3] ssb: check for flash presentence Rafał Miłecki 2 siblings, 1 reply; 5+ messages in thread From: Rafał Miłecki @ 2012-07-22 16:51 UTC (permalink / raw) To: linux-wireless, Hauke Mehrtens; +Cc: Rafał Miłecki Signed-off-by: Rafał Miłecki <zajec5@gmail.com> --- 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(-) diff --git a/arch/mips/bcm47xx/nvram.c b/arch/mips/bcm47xx/nvram.c index d43ceff..53822db 100644 --- a/arch/mips/bcm47xx/nvram.c +++ b/arch/mips/bcm47xx/nvram.c @@ -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 diff --git a/arch/mips/bcm47xx/wgt634u.c b/arch/mips/bcm47xx/wgt634u.c index e9f9ec8..616da92 100644 --- a/arch/mips/bcm47xx/wgt634u.c +++ b/arch/mips/bcm47xx/wgt634u.c @@ -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)); diff --git a/drivers/ssb/driver_mipscore.c b/drivers/ssb/driver_mipscore.c index f8813f8..873bc0a 100644 --- a/drivers/ssb/driver_mipscore.c +++ b/drivers/ssb/driver_mipscore.c @@ -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; } } diff --git a/include/linux/ssb/ssb_driver_chipcommon.h b/include/linux/ssb/ssb_driver_chipcommon.h index c2b02a5..ccb51d1 100644 --- a/include/linux/ssb/ssb_driver_chipcommon.h +++ b/include/linux/ssb/ssb_driver_chipcommon.h @@ -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) diff --git a/include/linux/ssb/ssb_driver_mips.h b/include/linux/ssb/ssb_driver_mips.h index 5f44e97..7e707ff 100644 --- a/include/linux/ssb/ssb_driver_mips.h +++ b/include/linux/ssb/ssb_driver_mips.h @@ -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); -- 1.7.7 ^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [RFT][PATCH 2/3] ssb: move flash info to ChipCommon driver 2012-07-22 16:51 ` [RFT][PATCH 2/3] ssb: move flash info to ChipCommon driver Rafał Miłecki @ 2012-07-25 12:18 ` Hauke Mehrtens 0 siblings, 0 replies; 5+ messages in thread From: Hauke Mehrtens @ 2012-07-25 12:18 UTC (permalink / raw) To: Rafał Miłecki; +Cc: linux-wireless 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 On 07/22/2012 06:51 PM, Rafał Miłecki wrote: > > Signed-off-by: Rafał Miłecki <zajec5@gmail.com> > --- > 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(-) > > diff --git a/arch/mips/bcm47xx/nvram.c b/arch/mips/bcm47xx/nvram.c > index d43ceff..53822db 100644 > --- a/arch/mips/bcm47xx/nvram.c > +++ b/arch/mips/bcm47xx/nvram.c > @@ -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 > diff --git a/arch/mips/bcm47xx/wgt634u.c b/arch/mips/bcm47xx/wgt634u.c > index e9f9ec8..616da92 100644 > --- a/arch/mips/bcm47xx/wgt634u.c > +++ b/arch/mips/bcm47xx/wgt634u.c > @@ -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)); > diff --git a/drivers/ssb/driver_mipscore.c b/drivers/ssb/driver_mipscore.c > index f8813f8..873bc0a 100644 > --- a/drivers/ssb/driver_mipscore.c > +++ b/drivers/ssb/driver_mipscore.c > @@ -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; > } > } > > diff --git a/include/linux/ssb/ssb_driver_chipcommon.h b/include/linux/ssb/ssb_driver_chipcommon.h > index c2b02a5..ccb51d1 100644 > --- a/include/linux/ssb/ssb_driver_chipcommon.h > +++ b/include/linux/ssb/ssb_driver_chipcommon.h > @@ -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) > diff --git a/include/linux/ssb/ssb_driver_mips.h b/include/linux/ssb/ssb_driver_mips.h > index 5f44e97..7e707ff 100644 > --- a/include/linux/ssb/ssb_driver_mips.h > +++ b/include/linux/ssb/ssb_driver_mips.h > @@ -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); > ^ permalink raw reply [flat|nested] 5+ messages in thread
* [RFT][PATCH 3/3] ssb: check for flash presentence 2012-07-22 16:51 [RFT][PATCH 0/3] ssb: Flash memory improvements Rafał Miłecki 2012-07-22 16:51 ` [RFT][PATCH 1/3] ssb: update defines Rafał Miłecki 2012-07-22 16:51 ` [RFT][PATCH 2/3] ssb: move flash info to ChipCommon driver Rafał Miłecki @ 2012-07-22 16:51 ` Rafał Miłecki 2 siblings, 0 replies; 5+ messages in thread From: Rafał Miłecki @ 2012-07-22 16:51 UTC (permalink / raw) To: linux-wireless, Hauke Mehrtens; +Cc: 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. Signed-off-by: Rafał Miłecki <zajec5@gmail.com> --- drivers/ssb/driver_mipscore.c | 28 ++++++++++++++++++++++------ 1 files changed, 22 insertions(+), 6 deletions(-) diff --git a/drivers/ssb/driver_mipscore.c b/drivers/ssb/driver_mipscore.c index 873bc0a..266a4c8 100644 --- a/drivers/ssb/driver_mipscore.c +++ b/drivers/ssb/driver_mipscore.c @@ -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"); } } -- 1.7.7 ^ permalink raw reply related [flat|nested] 5+ messages in thread
end of thread, other threads:[~2012-07-25 12:18 UTC | newest] Thread overview: 5+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2012-07-22 16:51 [RFT][PATCH 0/3] ssb: Flash memory improvements Rafał Miłecki 2012-07-22 16:51 ` [RFT][PATCH 1/3] ssb: update defines Rafał Miłecki 2012-07-22 16:51 ` [RFT][PATCH 2/3] ssb: move flash info to ChipCommon driver Rafał Miłecki 2012-07-25 12:18 ` Hauke Mehrtens 2012-07-22 16:51 ` [RFT][PATCH 3/3] ssb: check for flash presentence Rafał Miłecki
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).