ssb: generate modaliases for modules
Subsystems (2)
PATCH 1/7 ssb: generate modaliases for modules
In reply to a message not in the archiveThis makes the build system magic generate the appropriate modaliases for MODULE_DEVICE_TABLE(ssb, ...)
include/linux/mod_devicetable.h +15 -0
@@ -339,4 +339,19 @@ struct parisc_device_id {#define PA_HVERSION_ANY_ID 0xffff#define PA_SVERSION_ANY_ID 0xffffffff +/* SSB core, see drivers/ssb/ */ +struct ssb_device_id { +__u16 vendor; +__u16 coreid; +__u8 revision; +}; +#define SSB_DEVICE (_vendor, _coreid, _revision) \ + { .vendor = _vendor, .coreid = _coreid, .revision = _revision, } +#define SSB_DEVTABLE_END \ + { 0, }, + +#define SSB_ANY_VENDOR 0xFFFF +#define SSB_ANY_ID 0xFFFF +#define SSB_ANY_REV 0xFF +#endif /* LINUX_MOD_DEVICETABLE_H */
include/linux/ssb/ssb.h +1 -14
@@ -6,6 +6,7 @@#include <linux/types.h> #include <linux/spinlock.h> #include <linux/pci.h> +#include <linux/mod_devicetable.h> #include <linux/ssb/ssb_regs.h>
@@ -153,20 +154,6 @@ struct ssb_bus_ops {/* Vendor-ID values */ #define SSB_VENDOR_BROADCOM 0x4243 -struct ssb_device_id { -u16 vendor; -u16 coreid; -u8 revision; -}; -#define SSB_DEVICE (_vendor, _coreid, _revision) \ - { .vendor = _vendor, .coreid = _coreid, .revision = _revision, } -#define SSB_DEVTABLE_END \ - { 0, }, - -#define SSB_ANY_VENDOR 0xFFFF -#define SSB_ANY_ID 0xFFFF -#define SSB_ANY_REV 0xFF -/* Some kernel subsystems poke with dev->drvdata, so we must use the * following ugly workaround to get from struct device to struct ssb_device */ struct __ssb_dev_wrapper {
scripts/mod/file2alias.c +19 -0
@@ -484,6 +484,21 @@ static int do_parisc_entry(const char *freturn 1 ; } +/* Looks like: ssb:vNidNrevN. */ +static int do_ssb_entry (const char *filename, +struct ssb_device_id *id,char *alias) +{ + id->vendor =TO_NATIVE (id->vendor); + id->coreid =TO_NATIVE (id->coreid); + id->revision =TO_NATIVE (id->revision); + +strcpy (alias,"ssb:" ); +ADD (alias,"v" , id->vendor !=SSB_ANY_VENDOR , id->vendor); +ADD (alias,"id" , id->coreid !=SSB_ANY_ID , id->coreid); +ADD (alias,"rev" , id->revision !=SSB_ANY_REV , id->revision); +return 1 ; +} +/* Ignore any prefix, eg. v850 prepends _ */ static inline int sym_is (const char *symbol,const char *name) {
@@ -599,6 +614,10 @@ void handle_moddevtable(struct module *mdo_table (symval, sym->st_size,sizeof (struct parisc_device_id ),"parisc" , do_parisc_entry, mod); + else if (sym_is(symname, "__mod_ssb_device_table")) + do_table(symval, sym->st_size, + sizeof(struct ssb_device_id), "ssb", + do_ssb_entry, mod); }/* Now add out buffered information to the generated C source */
PATCH 2/7 ssb: include modalias in uevent for core
In reply to a message not in the archivedrivers/ssb/main.c +19 -0
@@ -317,6 +317,24 @@ static int ssb_bus_match(struct device *return 0 ; } +static int ssb_device_uevent (struct device *dev,char **envp,int num_envp, +char *buffer,int buffer_size) +{ +struct ssb_device *ssb_dev =dev_to_ssb_dev (dev); +int ret, i =0 , length =0 ; + +if (!dev) +return -ENODEV ; + + ret =add_uevent_var (envp, num_envp, &i, + buffer, buffer_size, &length, +"MODALIAS=ssb:v%.4xid%.4xrev%.2x" , + ssb_dev->id.vendor, ssb_dev->id.coreid, + ssb_dev->id.revision); + envp[i] =NULL ; +return ret; +} +static struct bus_type ssb_bustype = { .name ="ssb" , .match = ssb_bus_match,
@@ -325,6 +343,7 @@ static struct bus_type ssb_bustype = { .shutdown = ssb_device_shutdown, .suspend = ssb_device_suspend, .resume = ssb_device_resume, + .uevent = ssb_device_uevent, };static void ssb_buses_lock (void )
PATCH 3/7 ssb: Add GPIO support to Chip Common and PCI core drivers
In reply to a message not in the archiveFrom: Aurelien Jarno <[email protected]>
The patch below adds a functions to Chip Common and PCI core drivers to access the GPIO lines.
drivers/ssb/driver_chipcommon.c +23 -0
@@ -39,6 +39,14 @@ static inline void chipco_write32(structssb_write32 (cc->dev, offset, value); } +static inline void chipco_write32_masked (struct ssb_chipcommon *cc,u16 offset, +u32 mask,u32 value) +{ + value &= mask; + value |=chipco_read32 (cc, offset) & ~mask; +chipco_write32 (cc, offset, value); +} +void ssb_chipco_set_clockmode (struct ssb_chipcommon *cc,enum ssb_clkmode mode) {
@@ -344,6 +352,21 @@ ssb_chipco_watchdog_timer_set(struct ssbchipco_write32 (cc,SSB_CHIPCO_WATCHDOG , ticks); } +u32 ssb_chipco_gpio_in (struct ssb_chipcommon *cc,u32 mask) +{ +return chipco_read32 (cc,SSB_CHIPCO_GPIOIN ) & mask; +} + +void ssb_chipco_gpio_out (struct ssb_chipcommon *cc,u32 mask,u32 value) +{ +return chipco_write32_masked (cc,SSB_CHIPCO_GPIOOUT , mask, value); +} + +void ssb_chipco_gpio_outen (struct ssb_chipcommon *cc,u32 mask,u32 value) +{ +return chipco_write32_masked (cc,SSB_CHIPCO_GPIOOUTEN , mask, value); +} +#ifdef CONFIG_SSB_SERIAL int ssb_chipco_serial_init (struct ssb_chipcommon *cc,struct ssb_serial_port *ports)
drivers/ssb/driver_extif.c +25 -0
@@ -27,6 +27,14 @@ static inline void extif_write32(structssb_write32 (extif->dev, offset, value); } +static inline void extif_write32_masked (struct ssb_extif *extif,u16 offset, +u32 mask,u32 value) +{ + value &= mask; + value |=extif_read32 (extif, offset) & ~mask; +extif_write32 (extif, offset, value); +} +#ifdef CONFIG_SSB_SERIAL static bool serial_exists (u8 *regs) {
@@ -102,3 +110,20 @@ void ssb_extif_get_clockcontrol(struct s *m =extif_read32 (extif,SSB_EXTIF_CLOCK_SB ); } +u32 ssb_extif_gpio_in (struct ssb_extif *extif,u32 mask) +{ +return extif_read32 (extif,SSB_EXTIF_GPIO_IN ) & mask; +} + +void ssb_extif_gpio_out (struct ssb_extif *extif,u32 mask,u32 value) +{ +return extif_write32_masked (extif,SSB_EXTIF_GPIO_OUT (0 ), + mask, value); +} + +void ssb_extif_gpio_outen (struct ssb_extif *extif,u32 mask,u32 value) +{ +return extif_write32_masked (extif,SSB_EXTIF_GPIO_OUTEN (0 ), + mask, value); +} +
include/linux/ssb/ssb_driver_chipcommon.h +6 -0
@@ -382,6 +382,12 @@ extern void ssb_chipco_set_clockmode(strextern void ssb_chipco_watchdog_timer_set (struct ssb_chipcommon *cc,u32 ticks); +u32 ssb_chipco_gpio_in (struct ssb_chipcommon *cc,u32 mask); + +void ssb_chipco_gpio_out (struct ssb_chipcommon *cc,u32 mask,u32 value); + +void ssb_chipco_gpio_outen (struct ssb_chipcommon *cc,u32 mask,u32 value); +#ifdef CONFIG_SSB_SERIAL extern int ssb_chipco_serial_init (struct ssb_chipcommon *cc,struct ssb_serial_port *ports);
include/linux/ssb/ssb_driver_extif.h +6 -0
@@ -171,6 +171,12 @@ extern void ssb_extif_get_clockcontrol(sextern void ssb_extif_timing_init (struct ssb_extif *extif,unsigned long ns); +u32 ssb_extif_gpio_in (struct ssb_extif *extif,u32 mask); + +void ssb_extif_gpio_out (struct ssb_extif *extif,u32 mask,u32 value); + +void ssb_extif_gpio_outen (struct ssb_extif *extif,u32 mask,u32 value); +#ifdef CONFIG_SSB_SERIAL extern int ssb_extif_serial_init (struct ssb_extif *extif,struct ssb_serial_port *ports);
PATCH 4/7 ssb: Fix a warning in PCI core driver
In reply to a message not in the archiveFrom: Aurelien Jarno <[email protected]>
The patch below fixes a warning spotted a few days ago by Andrew Morton while releasing 2.6.23-rc2-mm1.
include/linux/ssb/ssb_regs.h +18 -18
@@ -5,24 +5,24 @@/* SiliconBackplane Address Map. * All regions may not exist on all chips. */ -#define SSB_SDRAM_BASE 0x00000000/* Physical SDRAM */ -#define SSB_PCI_MEM 0x08000000/* Host Mode sb2pcitranslation0 (64 MB) */ -#define SSB_PCI_CFG 0x0c000000/* Host Mode sb2pcitranslation1 (64 MB) */ -#define SSB_SDRAM_SWAPPED 0x10000000/* Byteswapped Physical SDRAM */ -#define SSB_ENUM_BASE 0x18000000/* Enumeration space base */ -#define SSB_ENUM_LIMIT 0x18010000/* Enumeration space limit */ - -#define SSB_FLASH2 0x1c000000/* Flash Region 2 (region 1 shadowed here) */ -#define SSB_FLASH2_SZ 0x02000000/* Size of Flash Region 2 */ - -#define SSB_EXTIF_BASE 0x1f000000/* External Interface region base address */ -#define SSB_FLASH1 0x1fc00000/* Flash Region 1 */ -#define SSB_FLASH1_SZ 0x00400000/* Size of Flash Region 1 */ - -#define SSB_PCI_DMA 0x40000000/* Client Mode sb2pcitranslation2 (1 GB) */ -#define SSB_PCI_DMA_SZ 0x40000000/* Client Mode sb2pcitranslation2 size in bytes */ -#define SSB_PCIE_DMA_L32 0x00000000/* PCIE Client Mode sb2pcitranslation2 (2 ZettaBytes), low 32 bits */ -#define SSB_PCIE_DMA_H32 0x80000000/* PCIE Client Mode sb2pcitranslation2 (2 ZettaBytes), high 32 bits */ +#define SSB_SDRAM_BASE 0x00000000U/* Physical SDRAM */ +#define SSB_PCI_MEM 0x08000000U/* Host Mode sb2pcitranslation0 (64 MB) */ +#define SSB_PCI_CFG 0x0c000000U/* Host Mode sb2pcitranslation1 (64 MB) */ +#define SSB_SDRAM_SWAPPED 0x10000000U/* Byteswapped Physical SDRAM */ +#define SSB_ENUM_BASE 0x18000000U/* Enumeration space base */ +#define SSB_ENUM_LIMIT 0x18010000U/* Enumeration space limit */ + +#define SSB_FLASH2 0x1c000000U/* Flash Region 2 (region 1 shadowed here) */ +#define SSB_FLASH2_SZ 0x02000000U/* Size of Flash Region 2 */ + +#define SSB_EXTIF_BASE 0x1f000000U/* External Interface region base address */ +#define SSB_FLASH1 0x1fc00000U/* Flash Region 1 */ +#define SSB_FLASH1_SZ 0x00400000U/* Size of Flash Region 1 */ + +#define SSB_PCI_DMA 0x40000000U/* Client Mode sb2pcitranslation2 (1 GB) */ +#define SSB_PCI_DMA_SZ 0x40000000U/* Client Mode sb2pcitranslation2 size in bytes */ +#define SSB_PCIE_DMA_L32 0x00000000U/* PCIE Client Mode sb2pcitranslation2 (2 ZettaBytes), low 32 bits */ +#define SSB_PCIE_DMA_H32 0x80000000U/* PCIE Client Mode sb2pcitranslation2 (2 ZettaBytes), high 32 bits */ #define SSB_EUART (SSB_EXTIF_BASE + 0x00800000)#define SSB_LED (SSB_EXTIF_BASE + 0x00900000)
PATCH 5/7 ssb: Add Broadcom 43xx PCI to SSB bridge
In reply to a message not in the archivedrivers/ssb/Makefile +4 -0
@@ -11,4 +11,8 @@ ssb-$(CONFIG_SSB_DRIVER_MIPS) += driver ssb-$(CONFIG_SSB_DRIVER_EXTIF) += driver_extif.o ssb-$(CONFIG_SSB_DRIVER_PCICORE) += driver_pcicore.o +# b43 pci-ssb-bridge driver +# Not strictly a part of SSB, but kept here for convenience +ssb-$(CONFIG_SSB_PCIHOST) += b43_pci_bridge.o + obj-$(CONFIG_SSB) += ssb.o
drivers/ssb/b43_pci_bridge.c new file +45 -0
45 lines not on this page · raw message
drivers/ssb/main.c +9 -0
@@ -1121,12 +1121,21 @@ static int __init ssb_modinit(void)if (err)bus_unregister (&ssb_bustype); + err =b43_pci_ssb_bridge_init (); +if (err) { +ssb_printk (KERN_ERR "Broadcom 43xx PCI-SSB-bridge " +"initialization failed" ); +/* don't fail SSB init because of this */ + err =0 ; + } +return err; }subsys_initcall (ssb_modinit); static void __exit ssb_modexit(void) { +b43_pci_ssb_bridge_exit ();bus_unregister (&ssb_bustype); }module_exit (ssb_modexit)
drivers/ssb/ssb_private.h +14 -0
@@ -119,4 +119,18 @@ extern int ssb_devices_freeze(struct ssbextern int ssb_devices_thaw (struct ssb_bus *bus);extern struct ssb_bus *ssb_pci_dev_to_bus (struct pci_dev *pdev); +/* b43_pci_bridge.c */ +#ifdef CONFIG_SSB_PCIHOST +extern int __init b43_pci_ssb_bridge_init (void ); +extern void __exit b43_pci_ssb_bridge_exit(void); +#else /* CONFIG_SSB_PCIHOST */ +static inline int b43_pci_ssb_bridge_init (void ) +{ +return 0 ; +} +static inline void b43_pci_ssb_bridge_exit (void ) +{ +} +#endif /* CONFIG_SSB_PCIHOST */ +#endif /* LINUX_SSB_PRIVATE_H_ */
PATCH 6/7 ssb: Add debugging for buspower
In reply to a message not in the archiveAlways make sure buspower is applied, when accessing the PCI MMIO space. Otherwise this can result in crashes.
drivers/ssb/main.c +26 -6
@@ -131,6 +131,9 @@ static void ssb_bus_suspend(struct ssb_b#ifdef CONFIG_SSB_DRIVER_PCICORE bus->pcicore.setup_done =0 ;#endif +#ifdef CONFIG_SSB_DEBUG + bus->powered_up =0 ; +#endif }static int ssb_device_suspend (struct device *dev,pm_message_t state)
@@ -486,9 +489,14 @@ static int ssb_attach_queued_buses(void)* is too early in boot for embedded systems * (no udelay() available). So do it here in attach stage. */ + err =ssb_bus_powerup (bus,0 ); +if (err) + goto error;ssb_pcicore_init (&bus->pcicore); +ssb_bus_may_powerdown (bus); err =ssb_devices_register (bus); +error:if (err) { drop_them_all =1 ;list_del (&bus->list);
@@ -586,11 +594,17 @@ static int ssb_bus_register(struct ssb_b goto err_pci_exit;/* Initialize basic system devices (if available) */ + err =ssb_bus_powerup (bus,0 ); +if (err) + goto err_pcmcia_exit;ssb_chipcommon_init (&bus->chipco);ssb_mipscore_init (&bus->mipscore); err =ssb_fetch_invariants (bus, get_invariants); -if (err) +if (err) { +ssb_bus_may_powerdown (bus); goto err_pcmcia_exit; + } +ssb_bus_may_powerdown (bus);/* Queue it for attach. * See the comment at the ssb_is_early_boot definition. */
@@ -1012,24 +1026,27 @@ EXPORT_SYMBOL(ssb_dma_set_mask);int ssb_bus_may_powerdown (struct ssb_bus *bus) {struct ssb_chipcommon *cc; -int err; +int err =0 ;/* On buses where more than one core may be working * at a time, we must not powerdown stuff if there are * still cores that may want to run. */ if (bus->bustype ==SSB_BUSTYPE_SSB ) -return 0 ; + goto out; cc = &bus->chipco;ssb_chipco_set_clockmode (cc,SSB_CLKMODE_SLOW ); err =ssb_pci_xtal (bus,SSB_GPIO_XTAL |SSB_GPIO_PLL ,0 );if (err) goto error; - -return 0 ; +out: +#ifdef CONFIG_SSB_DEBUG + bus->powered_up =0 ; +#endif +return err; error: ssb_printk(KERN_ERR PFX "Bus powerdown failed\n"); -return err; + goto out; }EXPORT_SYMBOL (ssb_bus_may_powerdown);
@@ -1046,6 +1063,9 @@ int ssb_bus_powerup(struct ssb_bus *bus, mode = dynamic_pctl ?SSB_CLKMODE_DYNAMIC :SSB_CLKMODE_FAST ;ssb_chipco_set_clockmode (cc, mode); +#ifdef CONFIG_SSB_DEBUG + bus->powered_up =1 ; +#endif return 0 ; error: ssb_printk(KERN_ERR PFX "Bus powerup failed\n");
drivers/ssb/pci.c +30 -0
@@ -499,10 +499,34 @@ out:return err; } +#ifdef CONFIG_SSB_DEBUG +static int ssb_pci_assert_buspower (struct ssb_bus *bus) +{ +if (likely (bus->powered_up)) +return 0 ; + + printk(KERN_ERR PFX "FATAL ERROR: Bus powered down " + "while accessing PCI MMIO space\n"); +if (bus->power_warn_count <=10 ) { + bus->power_warn_count++; +dump_stack (); + } + +return -ENODEV ; +} +#else /* DEBUG */ +static inline int ssb_pci_assert_buspower (struct ssb_bus *bus) +{ +return 0 ; +} +#endif /* DEBUG */ +static u16 ssb_pci_read16 (struct ssb_device *dev,u16 offset) {struct ssb_bus *bus = dev->bus; +if (unlikely (ssb_pci_assert_buspower (bus))) +return 0xFFFF ;if (unlikely (bus->mapped_device != dev)) {if (unlikely (ssb_pci_switch_core (bus, dev)))return 0xFFFF ;
@@ -514,6 +538,8 @@ static u32 ssb_pci_read32(struct ssb_dev {struct ssb_bus *bus = dev->bus; +if (unlikely (ssb_pci_assert_buspower (bus))) +return 0xFFFFFFFF ;if (unlikely (bus->mapped_device != dev)) {if (unlikely (ssb_pci_switch_core (bus, dev)))return 0xFFFFFFFF ;
@@ -525,6 +551,8 @@ static void ssb_pci_write16(struct ssb_d {struct ssb_bus *bus = dev->bus; +if (unlikely (ssb_pci_assert_buspower (bus))) +return ;if (unlikely (bus->mapped_device != dev)) {if (unlikely (ssb_pci_switch_core (bus, dev)))return ;
@@ -536,6 +564,8 @@ static void ssb_pci_write32(struct ssb_d {struct ssb_bus *bus = dev->bus; +if (unlikely (ssb_pci_assert_buspower (bus))) +return ;if (unlikely (bus->mapped_device != dev)) {if (unlikely (ssb_pci_switch_core (bus, dev)))return ;
include/linux/ssb/ssb.h +6 -1
@@ -319,8 +319,13 @@ struct ssb_bus {/* Contents of the SPROM. */ struct ssb_sprom sprom; -/* Internal. */ +/* Internal-only stuff follows. Do not touch. */ struct list_head list; +#ifdef CONFIG_SSB_DEBUG +/* Is the bus already powered up? */ +bool powered_up; +int power_warn_count; +#endif /* DEBUG */ };/* The initialization-invariants. */
PATCH 7/7 ssb: Add kconfig SELECT workaround
In reply to a message not in the archivedrivers/ssb/Kconfig +33 -8
@@ -1,18 +1,33 @@ menu "Sonics Silicon Backplane" +config SSB_POSSIBLE + bool + depends on HAS_IOMEM + default y + config SSB tristate "Sonics Silicon Backplane support" - depends on HAS_IOMEM + depends on SSB_POSSIBLE help - Support for the Sonics Silicon Backplane bus + Support for the Sonics Silicon Backplane bus. + You only need to enable this option, if you are + configuring a kernel for an embedded system with + this bus. + It will be auto-selected if needed in other + environments. - The module will be called ssb + The module will be called ssb. - If unsure, say M + If unsure, say N. + +config SSB_PCIHOST_POSSIBLE + bool + depends on SSB && PCI + default y config SSB_PCIHOST bool "Support for SSB on PCI-bus host" - depends on SSB && PCI + depends on SSB_PCIHOST_POSSIBLE default y help Support for a Sonics Silicon Backplane on top
@@ -20,9 +35,14 @@ config SSB_PCIHOST If unsure, say Y +config SSB_PCMCIAHOST_POSSIBLE + bool + depends on SSB && PCMCIA && EXPERIMENTAL + default y + config SSB_PCMCIAHOST bool "Support for SSB on PCMCIA-bus host (EXPERIMENTAL)" - depends on SSB && PCMCIA && EXPERIMENTAL + depends on SSB_PCMCIAHOST_POSSIBLE help Support for a Sonics Silicon Backplane on top of a PCMCIA device.
@@ -31,7 +51,7 @@ config SSB_PCMCIAHOST config SSB_SILENT bool "No SSB kernel messages" - depends on SSB + depends on SSB && EMBEDDED help This option turns off all Sonics Silicon Backplane printks. Note that you won't be able to identify problems, once
@@ -55,9 +75,14 @@ config SSB_SERIAL depends on SSB # ChipCommon and ExtIf serial support routines. +config SSB_DRIVER_PCICORE_POSSIBLE + bool + depends on SSB_PCIHOST + default y + config SSB_DRIVER_PCICORE bool "SSB PCI core driver" - depends on SSB && SSB_PCIHOST + depends on SSB_DRIVER_PCICORE_POSSIBLE help Driver for the Sonics Silicon Backplane attached Broadcom PCI core.