ssb: add place for serial flash driver
RFC PATCH 1/1 ssb: add place for serial flash driver
--- drivers/ssb/Kconfig | 5 +++++ drivers/ssb/Makefile | 1 + drivers/ssb/driver_chipcommon_sflash.c | 22 ++++++++++++++++++++++ drivers/ssb/driver_mipscore.c | 3 ++- drivers/ssb/ssb_private.h | 11 +++++++++++ include/linux/ssb/ssb_driver_chipcommon.h | 10 ++++++++++ 6 files changed, 51 insertions(+), 1 deletions(-) create mode 100644 drivers/ssb/driver_chipcommon_sflash.c
drivers/ssb/Kconfig +5 -0
@@ -137,6 +137,11 @@ config SSB_DRIVER_MIPS If unsure, say N +config SSB_SFLASH + bool "SSB serial flash support" + depends on SSB_DRIVER_MIPS && BROKEN + default y + # Assumption: We are on embedded, if we compile the MIPS core. config SSB_EMBEDDED bool
drivers/ssb/Makefile +1 -0
@@ -11,6 +11,7 @@ ssb-$(CONFIG_SSB_SDIOHOST) += sdio.o # built-in drivers ssb-y += driver_chipcommon.o ssb-y += driver_chipcommon_pmu.o +ssb-$(CONFIG_SSB_SFLASH) += driver_chipcommon_sflash.o ssb-$(CONFIG_SSB_DRIVER_MIPS) += driver_mipscore.o ssb-$(CONFIG_SSB_DRIVER_EXTIF) += driver_extif.o ssb-$(CONFIG_SSB_DRIVER_PCICORE) += driver_pcicore.o
drivers/ssb/driver_chipcommon_sflash.c new file +22 -0
@@ -0,0 +1,22 @@ +/* +* Sonics Silicon Backplane +* ChipCommon serial flash interface +* +* Licensed under the GNU/GPL. See COPYING for details. +*/ + +#include <linux/ssb/ssb.h> + +#include "ssb_private.h" + +/* Initialize serial flash access */ +int ssb_sflash_init (struct ssb_chipcommon *cc) +{ +struct ssb_sflash *sflash = &cc->sflash; + +pr_err ("Serial flash support is not implemented yet!\n" ); + + sflash->present = true; + +return -ENOTSUPP ; +}
drivers/ssb/driver_mipscore.c +2 -1
@@ -203,7 +203,8 @@ static void ssb_mips_flash_detect(struct ssb_mipscore *mcore)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" ); +pr_debug ("Found serial flash\n" ); +ssb_sflash_init (&bus->chipco);break ;case SSB_CHIPCO_FLASHT_PARA :pr_debug ("Found parallel flash\n" );
drivers/ssb/ssb_private.h +11 -0
@@ -217,6 +217,17 @@ extern u32 ssb_chipco_watchdog_timer_set_wdt(struct bcm47xx_wdt *wdt, u32 ticks);extern u32 ssb_chipco_watchdog_timer_set_ms (struct bcm47xx_wdt *wdt,u32 ms); +/* driver_chipcommon_sflash.c */ +#ifdef CONFIG_SSB_SFLASH +int ssb_sflash_init (struct ssb_chipcommon *cc); +#else +static inline int ssb_sflash_init (struct ssb_chipcommon *cc) +{ +pr_err ("Serial flash not supported\n" ); +return 0 ; +} +#endif /* CONFIG_SSB_SFLASH */ +#ifdef CONFIG_SSB_DRIVER_EXTIF extern u32 ssb_extif_watchdog_timer_set_wdt (struct bcm47xx_wdt *wdt,u32 ticks);extern u32 ssb_extif_watchdog_timer_set_ms (struct bcm47xx_wdt *wdt,u32 ms);
include/linux/ssb/ssb_driver_chipcommon.h +10 -0
@@ -584,6 +584,12 @@ struct ssb_chipcommon_pmu {u32 crystalfreq;/* The active crystal frequency (in kHz) */ }; +#ifdef CONFIG_SSB_SFLASH +struct ssb_sflash { +bool present; +}; +#endif +struct ssb_chipcommon {struct ssb_device *dev;u32 capabilities;
@@ -594,6 +600,10 @@ struct ssb_chipcommon {struct ssb_chipcommon_pmu pmu;u32 ticks_per_ms;u32 max_timer_ms; + +#ifdef CONFIG_SSB_SFLASH +struct ssb_sflash sflash; +#endif };static inline bool ssb_chipco_available (struct ssb_chipcommon *cc)
Signature · 1 line
1.7.7
Quoted 109 lines · Rafał Miłecki
Signed-off-by Rafał Miłecki <[email protected]>--- drivers/ssb/Kconfig | 5 +++++ drivers/ssb/Makefile | 1 + drivers/ssb/driver_chipcommon_sflash.c | 22 ++++++++++++++++++++++ drivers/ssb/driver_mipscore.c | 3 ++- drivers/ssb/ssb_private.h | 11 +++++++++++ include/linux/ssb/ssb_driver_chipcommon.h | 10 ++++++++++ 6 files changed, 51 insertions(+), 1 deletions(-) create mode 100644 drivers/ssb/driver_chipcommon_sflash.cdrivers/ssb/Kconfig +5
-0@@ -137,6 +137,11 @@ config SSB_DRIVER_MIPS If unsure, say N +config SSB_SFLASH + bool "SSB serial flash support" + depends on SSB_DRIVER_MIPS && BROKEN + default y + # Assumption: We are on embedded, if we compile the MIPS core. config SSB_EMBEDDED booldrivers/ssb/Makefile +1
-0@@ -11,6 +11,7 @@ ssb-$(CONFIG_SSB_SDIOHOST) += sdio.o # built-in drivers ssb-y += driver_chipcommon.o ssb-y += driver_chipcommon_pmu.o +ssb-$(CONFIG_SSB_SFLASH) += driver_chipcommon_sflash.o ssb-$(CONFIG_SSB_DRIVER_MIPS) += driver_mipscore.o ssb-$(CONFIG_SSB_DRIVER_EXTIF) += driver_extif.o ssb-$(CONFIG_SSB_DRIVER_PCICORE) += driver_pcicore.odrivers/ssb/driver_chipcommon_sflash.c new file +22
-0@@ -0,0 +1,22 @@ +/* +* Sonics Silicon Backplane +* ChipCommon serial flash interface +* +* Licensed under the GNU/GPL. See COPYING for details. +*/ + +#include <linux/ssb/ssb.h> + +#include "ssb_private.h" + +/* Initialize serial flash access */ +int ssb_sflash_init (struct ssb_chipcommon *cc) +{ +struct ssb_sflash *sflash = &cc->sflash; + +pr_err ("Serial flash support is not implemented yet!\n" ); + + sflash->present = true; + +return -ENOTSUPP ; +}drivers/ssb/driver_mipscore.c +2
-1@@ -203,7 +203,8 @@ static void ssb_mips_flash_detect(struct ssb_mipscore *mcore)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" ); +pr_debug ("Found serial flash\n" ); +ssb_sflash_init (&bus->chipco);break ;case SSB_CHIPCO_FLASHT_PARA :pr_debug ("Found parallel flash\n" );drivers/ssb/ssb_private.h +11
-0@@ -217,6 +217,17 @@ extern u32 ssb_chipco_watchdog_timer_set_wdt(struct bcm47xx_wdt *wdt, u32 ticks);extern u32 ssb_chipco_watchdog_timer_set_ms (struct bcm47xx_wdt *wdt,u32 ms); +/* driver_chipcommon_sflash.c */ +#ifdef CONFIG_SSB_SFLASH +int ssb_sflash_init (struct ssb_chipcommon *cc); +#else +static inline int ssb_sflash_init (struct ssb_chipcommon *cc) +{ +pr_err ("Serial flash not supported\n" ); +return 0 ; +} +#endif /* CONFIG_SSB_SFLASH */ +#ifdef CONFIG_SSB_DRIVER_EXTIF extern u32 ssb_extif_watchdog_timer_set_wdt (struct bcm47xx_wdt *wdt,u32 ticks);extern u32 ssb_extif_watchdog_timer_set_ms (struct bcm47xx_wdt *wdt,u32 ms);include/linux/ssb/ssb_driver_chipcommon.h +0
-0
include/linux/ssb/ssb_driver_chipcommon.h struct ssb_chipcommon_pmu { · line 591
Quoted 8 lines
include/linux/ssb/ssb_driver_chipcommon.h +5
-0@@ -584,6 +584,12 @@ struct ssb_chipcommon_pmu {u32 crystalfreq;/* The active crystal frequency (in kHz) */ }; +#ifdef CONFIG_SSB_SFLASH +struct ssb_sflash { +bool present; +}; +#endif
I assume you want to share some of the code for the serial flash driver between bcma and ssb. You should create a file with the structure in include/linux/platform_data/ and share that between bcma and ssb.
Quoted 16 lines
include/linux/ssb/ssb_driver_chipcommon.h +5
-0+struct ssb_chipcommon {struct ssb_device *dev;u32 capabilities;@@ -594,6 +600,10 @@ struct ssb_chipcommon {struct ssb_chipcommon_pmu pmu;u32 ticks_per_ms;u32 max_timer_ms; + +#ifdef CONFIG_SSB_SFLASH +struct ssb_sflash sflash; +#endif };static inline bool ssb_chipco_available (struct ssb_chipcommon *cc)
2012/12/26 Hauke Mehrtens <[email protected]>:
Quoted 10 lines · Rafał Miłecki
include/linux/ssb/ssb_driver_chipcommon.h struct ssb_chipcommon_pmu { · line 591
Quoted 5 lines
include/linux/ssb/ssb_driver_chipcommon.h +5
-0+#ifdef CONFIG_SSB_SFLASH +struct ssb_sflash { +bool present; +}; +#endif I assume you want to share some of the code for the serial flash driver between bcma and ssb. You should create a file with the structure in
include/linux/platform_data/and share that between bcma and ssb.
It's a small struct having about 5 trivial fields. We don't share sturcts for any other drivers (chipcommon/mips/pcie) so I think they should stay separated here as well.
Plus the mtd driver will have to implement bus abstraction anyway.
Signature · 1 line
Rafał
Quoted 12 lines · Rafał Miłecki
2012/12/26 Hauke Mehrtens <[email protected]>:
Quoted 10 lines · Rafał Miłecki
include/linux/ssb/ssb_driver_chipcommon.h struct ssb_chipcommon_pmu { · line 591
Quoted 5 lines
include/linux/ssb/ssb_driver_chipcommon.h +5
-0+#ifdef CONFIG_SSB_SFLASH +struct ssb_sflash { +bool present; +}; +#endif I assume you want to share some of the code for the serial flash driver between bcma and ssb. You should create a file with the structure in
include/linux/platform_data/and share that between bcma and ssb.
Quoted 3 lines
It's a small struct having about 5 trivial fields. We don't share sturcts for any other drivers (chipcommon/mips/pcie) so I think they should stay separated here as well.
When this structure is just used in ssb or bcma and in the nvram code of arch/mips/bcm47x I would also prefer two structures one for bcma and one for ssb.
Quoted 1 line
Plus the mtd driver will have to implement bus abstraction anyway.
If you have a structure describing the needs of the serial flash driver in drivers/mtd/ you could write the flash driver without any ifdef BCMA_* or SSB_* and if does not have to include linux/ssb/ssb.h or linu/bcma/bcma.h, like I did this with the watchdog driver include/linux/bcm47xx_wdt.h
Hauke
2012/12/26 Hauke Mehrtens <[email protected]>:
Quoted 21 lines · Rafał Miłecki
Quoted 12 lines
2012/12/26 Hauke Mehrtens <[email protected]>:
Quoted 10 lines · Rafał Miłecki
include/linux/ssb/ssb_driver_chipcommon.h struct ssb_chipcommon_pmu { · line 591
Quoted 5 lines
include/linux/ssb/ssb_driver_chipcommon.h +5
-0+#ifdef CONFIG_SSB_SFLASH +struct ssb_sflash { +bool present; +}; +#endif I assume you want to share some of the code for the serial flash driver between bcma and ssb. You should create a file with the structure in
include/linux/platform_data/and share that between bcma and ssb.Quoted 3 lines
It's a small struct having about 5 trivial fields. We don't share sturcts for any other drivers (chipcommon/mips/pcie) so I think they should stay separated here as well.
When this structure is just used in ssb or bcma and in the nvram code of
arch/mips/bcm47xI would also prefer two structures one for bcma and one for ssb.
Quoted 7 lines
Quoted 1 line
Plus the mtd driver will have to implement bus abstraction anyway.
If you have a structure describing the needs of the serial flash driver in
drivers/mtd/you could write the flash driver without any ifdef BCMA_* or SSB_* and if does not have to includelinux/ssb/ssb.horlinu/bcma/bcma.h, like I did this with the watchdog driverinclude/linux/bcm47xx_wdt.h
OK, I've analyzed your bcm47xx_wdt. I can see you abstract bus here and implement some simple ops.
We could add similar extra layer for sflash, but I wonder what we could put in that. For full sflash support we need 2 things:
1) Hardware info (u32 window, u32 blocksize, u16 numblocks)
2) Chipcommon access (read32, write32)
In total that are only ~5 fields in some struct. I wonder if it makes sense to move that abstracting code to an extra layer? Maybe we can just do that in bcm47xxsflash with few ifdefs?
Signature · 1 line
Rafał
2012/12/26 Rafał Miłecki <[email protected]>:
Quoted 33 lines
2012/12/26 Hauke Mehrtens <[email protected]>:
Quoted 21 lines · Rafał Miłecki
Quoted 12 lines
2012/12/26 Hauke Mehrtens <[email protected]>:
Quoted 10 lines · Rafał Miłecki
include/linux/ssb/ssb_driver_chipcommon.h struct ssb_chipcommon_pmu { · line 591
Quoted 5 lines
include/linux/ssb/ssb_driver_chipcommon.h +5
-0+#ifdef CONFIG_SSB_SFLASH +struct ssb_sflash { +bool present; +}; +#endif I assume you want to share some of the code for the serial flash driver between bcma and ssb. You should create a file with the structure in
include/linux/platform_data/and share that between bcma and ssb.Quoted 3 lines
It's a small struct having about 5 trivial fields. We don't share sturcts for any other drivers (chipcommon/mips/pcie) so I think they should stay separated here as well.
When this structure is just used in ssb or bcma and in the nvram code of
arch/mips/bcm47xI would also prefer two structures one for bcma and one for ssb.Quoted 7 lines
Quoted 1 line
Plus the mtd driver will have to implement bus abstraction anyway.
If you have a structure describing the needs of the serial flash driver in
drivers/mtd/you could write the flash driver without any ifdef BCMA_* or SSB_* and if does not have to includelinux/ssb/ssb.horlinu/bcma/bcma.h, like I did this with the watchdog driverinclude/linux/bcm47xx_wdt.hOK, I've analyzed your
bcm47xx_wdt. I can see you abstract bus here and implement some simple ops.
Quoted 8 lines
We could add similar extra layer for sflash, but I wonder what we could put in that. For full sflash support we need 2 things:
1) Hardware info (u32 window, u32 blocksize, u16 numblocks)
2) Chipcommon access (read32, write32)In total that are only ~5 fields in some struct. I wonder if it makes sense to move that abstracting code to an extra layer? Maybe we can just do that in bcm47xxsflash with few ifdefs?
Hm, the advantage is that we could fill that struct directly instead copying values in bcm47xxsflash probe function. Still not sure which path to follow.
Signature · 1 line
Rafał