1 Index: linux-2.6.23.17/drivers/ssb/Kconfig
2 ===================================================================
3 --- linux-2.6.23.17.orig/drivers/ssb/Kconfig
4 +++ linux-2.6.23.17/drivers/ssb/Kconfig
5 @@ -120,4 +120,13 @@ config SSB_DRIVER_EXTIF
9 +config SSB_DRIVER_GIGE
10 + bool "SSB Broadcom Gigabit Ethernet driver"
11 + depends on SSB_PCIHOST_POSSIBLE && SSB_EMBEDDED && MIPS
13 + Driver for the Sonics Silicon Backplane attached
14 + Broadcom Gigabit Ethernet.
19 Index: linux-2.6.23.17/drivers/ssb/Makefile
20 ===================================================================
21 --- linux-2.6.23.17.orig/drivers/ssb/Makefile
22 +++ linux-2.6.23.17/drivers/ssb/Makefile
23 @@ -11,6 +11,7 @@ ssb-y += driver_chipcommon.o
24 ssb-$(CONFIG_SSB_DRIVER_MIPS) += driver_mipscore.o
25 ssb-$(CONFIG_SSB_DRIVER_EXTIF) += driver_extif.o
26 ssb-$(CONFIG_SSB_DRIVER_PCICORE) += driver_pcicore.o
27 +ssb-$(CONFIG_SSB_DRIVER_GIGE) += driver_gige.o
29 # b43 pci-ssb-bridge driver
30 # Not strictly a part of SSB, but kept here for convenience
31 Index: linux-2.6.23.17/drivers/ssb/driver_gige.c
32 ===================================================================
34 +++ linux-2.6.23.17/drivers/ssb/driver_gige.c
37 + * Sonics Silicon Backplane
38 + * Broadcom Gigabit Ethernet core driver
40 + * Copyright 2008, Broadcom Corporation
41 + * Copyright 2008, Michael Buesch <mb@bu3sch.de>
43 + * Licensed under the GNU/GPL. See COPYING for details.
46 +#include <linux/ssb/ssb.h>
47 +#include <linux/ssb/ssb_driver_gige.h>
48 +#include <linux/pci.h>
49 +#include <linux/pci_regs.h>
53 +MODULE_DESCRIPTION("SSB Broadcom Gigabit Ethernet driver");
54 +MODULE_AUTHOR("Michael Buesch");
55 +MODULE_LICENSE("GPL");
58 +static const struct ssb_device_id ssb_gige_tbl[] = {
59 + SSB_DEVICE(SSB_VENDOR_BROADCOM, SSB_DEV_ETHERNET_GBIT, SSB_ANY_REV),
62 +/* MODULE_DEVICE_TABLE(ssb, ssb_gige_tbl); */
65 +static inline u8 gige_read8(struct ssb_gige *dev, u16 offset)
67 + return ssb_read8(dev->dev, offset);
70 +static inline u16 gige_read16(struct ssb_gige *dev, u16 offset)
72 + return ssb_read16(dev->dev, offset);
75 +static inline u32 gige_read32(struct ssb_gige *dev, u16 offset)
77 + return ssb_read32(dev->dev, offset);
80 +static inline void gige_write8(struct ssb_gige *dev,
81 + u16 offset, u8 value)
83 + ssb_write8(dev->dev, offset, value);
86 +static inline void gige_write16(struct ssb_gige *dev,
87 + u16 offset, u16 value)
89 + ssb_write16(dev->dev, offset, value);
92 +static inline void gige_write32(struct ssb_gige *dev,
93 + u16 offset, u32 value)
95 + ssb_write32(dev->dev, offset, value);
99 +u8 gige_pcicfg_read8(struct ssb_gige *dev, unsigned int offset)
101 + BUG_ON(offset >= 256);
102 + return gige_read8(dev, SSB_GIGE_PCICFG + offset);
106 +u16 gige_pcicfg_read16(struct ssb_gige *dev, unsigned int offset)
108 + BUG_ON(offset >= 256);
109 + return gige_read16(dev, SSB_GIGE_PCICFG + offset);
113 +u32 gige_pcicfg_read32(struct ssb_gige *dev, unsigned int offset)
115 + BUG_ON(offset >= 256);
116 + return gige_read32(dev, SSB_GIGE_PCICFG + offset);
120 +void gige_pcicfg_write8(struct ssb_gige *dev,
121 + unsigned int offset, u8 value)
123 + BUG_ON(offset >= 256);
124 + gige_write8(dev, SSB_GIGE_PCICFG + offset, value);
128 +void gige_pcicfg_write16(struct ssb_gige *dev,
129 + unsigned int offset, u16 value)
131 + BUG_ON(offset >= 256);
132 + gige_write16(dev, SSB_GIGE_PCICFG + offset, value);
136 +void gige_pcicfg_write32(struct ssb_gige *dev,
137 + unsigned int offset, u32 value)
139 + BUG_ON(offset >= 256);
140 + gige_write32(dev, SSB_GIGE_PCICFG + offset, value);
143 +static int ssb_gige_pci_read_config(struct pci_bus *bus, unsigned int devfn,
144 + int reg, int size, u32 *val)
146 + struct ssb_gige *dev = container_of(bus->ops, struct ssb_gige, pci_ops);
147 + unsigned long flags;
149 + if ((PCI_SLOT(devfn) > 0) || (PCI_FUNC(devfn) > 0))
150 + return PCIBIOS_DEVICE_NOT_FOUND;
152 + return PCIBIOS_DEVICE_NOT_FOUND;
154 + spin_lock_irqsave(&dev->lock, flags);
157 + *val = gige_pcicfg_read8(dev, reg);
160 + *val = gige_pcicfg_read16(dev, reg);
163 + *val = gige_pcicfg_read32(dev, reg);
168 + spin_unlock_irqrestore(&dev->lock, flags);
170 + return PCIBIOS_SUCCESSFUL;
173 +static int ssb_gige_pci_write_config(struct pci_bus *bus, unsigned int devfn,
174 + int reg, int size, u32 val)
176 + struct ssb_gige *dev = container_of(bus->ops, struct ssb_gige, pci_ops);
177 + unsigned long flags;
179 + if ((PCI_SLOT(devfn) > 0) || (PCI_FUNC(devfn) > 0))
180 + return PCIBIOS_DEVICE_NOT_FOUND;
182 + return PCIBIOS_DEVICE_NOT_FOUND;
184 + spin_lock_irqsave(&dev->lock, flags);
187 + gige_pcicfg_write8(dev, reg, val);
190 + gige_pcicfg_write16(dev, reg, val);
193 + gige_pcicfg_write32(dev, reg, val);
198 + spin_unlock_irqrestore(&dev->lock, flags);
200 + return PCIBIOS_SUCCESSFUL;
203 +static int ssb_gige_probe(struct ssb_device *sdev, const struct ssb_device_id *id)
205 + struct ssb_gige *dev;
206 + u32 base, tmslow, tmshigh;
208 + dev = kzalloc(sizeof(*dev), GFP_KERNEL);
213 + spin_lock_init(&dev->lock);
214 + dev->pci_controller.pci_ops = &dev->pci_ops;
215 + dev->pci_controller.io_resource = &dev->io_resource;
216 + dev->pci_controller.mem_resource = &dev->mem_resource;
217 + dev->pci_controller.io_map_base = 0x800;
218 + dev->pci_ops.read = ssb_gige_pci_read_config;
219 + dev->pci_ops.write = ssb_gige_pci_write_config;
221 + dev->io_resource.name = SSB_GIGE_IO_RES_NAME;
222 + dev->io_resource.start = 0x800;
223 + dev->io_resource.end = 0x8FF;
224 + dev->io_resource.flags = IORESOURCE_IO | IORESOURCE_PCI_FIXED;
226 + if (!ssb_device_is_enabled(sdev))
227 + ssb_device_enable(sdev, 0);
229 + /* Setup BAR0. This is a 64k MMIO region. */
230 + base = ssb_admatch_base(ssb_read32(sdev, SSB_ADMATCH1));
231 + gige_pcicfg_write32(dev, PCI_BASE_ADDRESS_0, base);
232 + gige_pcicfg_write32(dev, PCI_BASE_ADDRESS_1, 0);
234 + dev->mem_resource.name = SSB_GIGE_MEM_RES_NAME;
235 + dev->mem_resource.start = base;
236 + dev->mem_resource.end = base + 0x10000 - 1;
237 + dev->mem_resource.flags = IORESOURCE_MEM | IORESOURCE_PCI_FIXED;
239 + /* Enable the memory region. */
240 + gige_pcicfg_write16(dev, PCI_COMMAND,
241 + gige_pcicfg_read16(dev, PCI_COMMAND)
242 + | PCI_COMMAND_MEMORY);
244 + /* Write flushing is controlled by the Flush Status Control register.
245 + * We want to flush every register write with a timeout and we want
246 + * to disable the IRQ mask while flushing to avoid concurrency.
247 + * Note that automatic write flushing does _not_ work from
248 + * an IRQ handler. The driver must flush manually by reading a register.
250 + gige_write32(dev, SSB_GIGE_SHIM_FLUSHSTAT, 0x00000068);
252 + /* Check if we have an RGMII or GMII PHY-bus.
253 + * On RGMII do not bypass the DLLs */
254 + tmslow = ssb_read32(sdev, SSB_TMSLOW);
255 + tmshigh = ssb_read32(sdev, SSB_TMSHIGH);
256 + if (tmshigh & SSB_GIGE_TMSHIGH_RGMII) {
257 + tmslow &= ~SSB_GIGE_TMSLOW_TXBYPASS;
258 + tmslow &= ~SSB_GIGE_TMSLOW_RXBYPASS;
259 + dev->has_rgmii = 1;
261 + tmslow |= SSB_GIGE_TMSLOW_TXBYPASS;
262 + tmslow |= SSB_GIGE_TMSLOW_RXBYPASS;
263 + dev->has_rgmii = 0;
265 + tmslow |= SSB_GIGE_TMSLOW_DLLEN;
266 + ssb_write32(sdev, SSB_TMSLOW, tmslow);
268 + ssb_set_drvdata(sdev, dev);
269 + register_pci_controller(&dev->pci_controller);
274 +bool pdev_is_ssb_gige_core(struct pci_dev *pdev)
276 + if (!pdev->resource[0].name)
278 + return (strcmp(pdev->resource[0].name, SSB_GIGE_MEM_RES_NAME) == 0);
280 +EXPORT_SYMBOL(pdev_is_ssb_gige_core);
282 +int ssb_gige_pcibios_plat_dev_init(struct ssb_device *sdev,
283 + struct pci_dev *pdev)
285 + struct ssb_gige *dev = ssb_get_drvdata(sdev);
286 + struct resource *res;
288 + if (pdev->bus->ops != &dev->pci_ops) {
289 + /* The PCI device is not on this SSB GigE bridge device. */
293 + /* Fixup the PCI resources. */
294 + res = &(pdev->resource[0]);
295 + res->flags = IORESOURCE_MEM | IORESOURCE_PCI_FIXED;
296 + res->name = dev->mem_resource.name;
297 + res->start = dev->mem_resource.start;
298 + res->end = dev->mem_resource.end;
300 + /* Fixup interrupt lines. */
301 + pdev->irq = ssb_mips_irq(sdev) + 2;
302 + pci_write_config_byte(pdev, PCI_INTERRUPT_LINE, pdev->irq);
307 +int ssb_gige_map_irq(struct ssb_device *sdev,
308 + const struct pci_dev *pdev)
310 + struct ssb_gige *dev = ssb_get_drvdata(sdev);
312 + if (pdev->bus->ops != &dev->pci_ops) {
313 + /* The PCI device is not on this SSB GigE bridge device. */
317 + return ssb_mips_irq(sdev) + 2;
320 +static struct ssb_driver ssb_gige_driver = {
321 + .name = "BCM-GigE",
322 + .id_table = ssb_gige_tbl,
323 + .probe = ssb_gige_probe,
326 +int ssb_gige_init(void)
328 + return ssb_driver_register(&ssb_gige_driver);
330 Index: linux-2.6.23.17/include/linux/ssb/ssb_driver_gige.h
331 ===================================================================
333 +++ linux-2.6.23.17/include/linux/ssb/ssb_driver_gige.h
335 +#ifndef LINUX_SSB_DRIVER_GIGE_H_
336 +#define LINUX_SSB_DRIVER_GIGE_H_
338 +#include <linux/ssb/ssb.h>
339 +#include <linux/pci.h>
340 +#include <linux/spinlock.h>
343 +#ifdef CONFIG_SSB_DRIVER_GIGE
346 +#define SSB_GIGE_PCIIO 0x0000 /* PCI I/O Registers (1024 bytes) */
347 +#define SSB_GIGE_RESERVED 0x0400 /* Reserved (1024 bytes) */
348 +#define SSB_GIGE_PCICFG 0x0800 /* PCI config space (256 bytes) */
349 +#define SSB_GIGE_SHIM_FLUSHSTAT 0x0C00 /* PCI to OCP: Flush status control (32bit) */
350 +#define SSB_GIGE_SHIM_FLUSHRDA 0x0C04 /* PCI to OCP: Flush read address (32bit) */
351 +#define SSB_GIGE_SHIM_FLUSHTO 0x0C08 /* PCI to OCP: Flush timeout counter (32bit) */
352 +#define SSB_GIGE_SHIM_BARRIER 0x0C0C /* PCI to OCP: Barrier register (32bit) */
353 +#define SSB_GIGE_SHIM_MAOCPSI 0x0C10 /* PCI to OCP: MaocpSI Control (32bit) */
354 +#define SSB_GIGE_SHIM_SIOCPMA 0x0C14 /* PCI to OCP: SiocpMa Control (32bit) */
356 +/* TM Status High flags */
357 +#define SSB_GIGE_TMSHIGH_RGMII 0x00010000 /* Have an RGMII PHY-bus */
358 +/* TM Status Low flags */
359 +#define SSB_GIGE_TMSLOW_TXBYPASS 0x00080000 /* TX bypass (no delay) */
360 +#define SSB_GIGE_TMSLOW_RXBYPASS 0x00100000 /* RX bypass (no delay) */
361 +#define SSB_GIGE_TMSLOW_DLLEN 0x01000000 /* Enable DLL controls */
363 +/* Boardflags (low) */
364 +#define SSB_GIGE_BFL_ROBOSWITCH 0x0010
367 +#define SSB_GIGE_MEM_RES_NAME "SSB Broadcom 47xx GigE memory"
368 +#define SSB_GIGE_IO_RES_NAME "SSB Broadcom 47xx GigE I/O"
371 + struct ssb_device *dev;
375 + /* True, if the device has an RGMII bus.
376 + * False, if the device has a GMII bus. */
379 + /* The PCI controller device. */
380 + struct pci_controller pci_controller;
381 + struct pci_ops pci_ops;
382 + struct resource mem_resource;
383 + struct resource io_resource;
386 +/* Check whether a PCI device is a SSB Gigabit Ethernet core. */
387 +extern bool pdev_is_ssb_gige_core(struct pci_dev *pdev);
389 +/* Convert a pci_dev pointer to a ssb_gige pointer. */
390 +static inline struct ssb_gige * pdev_to_ssb_gige(struct pci_dev *pdev)
392 + if (!pdev_is_ssb_gige_core(pdev))
394 + return container_of(pdev->bus->ops, struct ssb_gige, pci_ops);
397 +/* Returns whether the PHY is connected by an RGMII bus. */
398 +static inline bool ssb_gige_is_rgmii(struct pci_dev *pdev)
400 + struct ssb_gige *dev = pdev_to_ssb_gige(pdev);
401 + return (dev ? dev->has_rgmii : 0);
404 +/* Returns whether we have a Roboswitch. */
405 +static inline bool ssb_gige_have_roboswitch(struct pci_dev *pdev)
407 + struct ssb_gige *dev = pdev_to_ssb_gige(pdev);
409 + return !!(dev->dev->bus->sprom.boardflags_lo &
410 + SSB_GIGE_BFL_ROBOSWITCH);
414 +/* Returns whether we can only do one DMA at once. */
415 +static inline bool ssb_gige_one_dma_at_once(struct pci_dev *pdev)
417 + struct ssb_gige *dev = pdev_to_ssb_gige(pdev);
419 + return ((dev->dev->bus->chip_id == 0x4785) &&
420 + (dev->dev->bus->chip_rev < 2));
424 +/* Returns whether we must flush posted writes. */
425 +static inline bool ssb_gige_must_flush_posted_writes(struct pci_dev *pdev)
427 + struct ssb_gige *dev = pdev_to_ssb_gige(pdev);
429 + return (dev->dev->bus->chip_id == 0x4785);
433 +extern char * nvram_get(const char *name);
434 +/* Get the device MAC address */
435 +static inline void ssb_gige_get_macaddr(struct pci_dev *pdev, u8 *macaddr)
437 +#ifdef CONFIG_BCM947XX
438 + char *res = nvram_get("et0macaddr");
440 + memcpy(macaddr, res, 6);
444 +extern int ssb_gige_pcibios_plat_dev_init(struct ssb_device *sdev,
445 + struct pci_dev *pdev);
446 +extern int ssb_gige_map_irq(struct ssb_device *sdev,
447 + const struct pci_dev *pdev);
449 +/* The GigE driver is not a standalone module, because we don't have support
450 + * for unregistering the driver. So we could not unload the module anyway. */
451 +extern int ssb_gige_init(void);
452 +static inline void ssb_gige_exit(void)
454 + /* Currently we can not unregister the GigE driver,
455 + * because we can not unregister the PCI bridge. */
460 +#else /* CONFIG_SSB_DRIVER_GIGE */
461 +/* Gigabit Ethernet driver disabled */
464 +static inline int ssb_gige_pcibios_plat_dev_init(struct ssb_device *sdev,
465 + struct pci_dev *pdev)
469 +static inline int ssb_gige_map_irq(struct ssb_device *sdev,
470 + const struct pci_dev *pdev)
474 +static inline int ssb_gige_init(void)
478 +static inline void ssb_gige_exit(void)
482 +static inline bool pdev_is_ssb_gige_core(struct pci_dev *pdev)
486 +static inline struct ssb_gige * pdev_to_ssb_gige(struct pci_dev *pdev)
490 +static inline bool ssb_gige_is_rgmii(struct pci_dev *pdev)
494 +static inline bool ssb_gige_have_roboswitch(struct pci_dev *pdev)
498 +static inline bool ssb_gige_one_dma_at_once(struct pci_dev *pdev)
502 +static inline bool ssb_gige_must_flush_posted_writes(struct pci_dev *pdev)
507 +#endif /* CONFIG_SSB_DRIVER_GIGE */
508 +#endif /* LINUX_SSB_DRIVER_GIGE_H_ */
509 Index: linux-2.6.23.17/drivers/ssb/driver_pcicore.c
510 ===================================================================
511 --- linux-2.6.23.17.orig/drivers/ssb/driver_pcicore.c
512 +++ linux-2.6.23.17/drivers/ssb/driver_pcicore.c
513 @@ -60,74 +60,6 @@ static DEFINE_SPINLOCK(cfgspace_lock);
514 /* Core to access the external PCI config space. Can only have one. */
515 static struct ssb_pcicore *extpci_core;
517 -static u32 ssb_pcicore_pcibus_iobase = 0x100;
518 -static u32 ssb_pcicore_pcibus_membase = SSB_PCI_DMA;
520 -int pcibios_plat_dev_init(struct pci_dev *d)
522 - struct resource *res;
526 - ssb_printk(KERN_INFO "PCI: Fixing up device %s\n",
529 - /* Fix up resource bases */
530 - for (pos = 0; pos < 6; pos++) {
531 - res = &d->resource[pos];
532 - if (res->flags & IORESOURCE_IO)
533 - base = &ssb_pcicore_pcibus_iobase;
535 - base = &ssb_pcicore_pcibus_membase;
536 - res->flags |= IORESOURCE_PCI_FIXED;
538 - size = res->end - res->start + 1;
539 - if (*base & (size - 1))
540 - *base = (*base + size) & ~(size - 1);
541 - res->start = *base;
542 - res->end = res->start + size - 1;
544 - pci_write_config_dword(d, PCI_BASE_ADDRESS_0 + (pos << 2), res->start);
546 - /* Fix up PCI bridge BAR0 only */
547 - if (d->bus->number == 0 && PCI_SLOT(d->devfn) == 0)
550 - /* Fix up interrupt lines */
551 - d->irq = ssb_mips_irq(extpci_core->dev) + 2;
552 - pci_write_config_byte(d, PCI_INTERRUPT_LINE, d->irq);
557 -static void __init ssb_fixup_pcibridge(struct pci_dev *dev)
561 - if (dev->bus->number != 0 || PCI_SLOT(dev->devfn) != 0)
564 - ssb_printk(KERN_INFO "PCI: Fixing up bridge %s\n", pci_name(dev));
566 - /* Enable PCI bridge bus mastering and memory space */
567 - pci_set_master(dev);
568 - pcibios_enable_device(dev, ~0);
570 - /* Enable PCI bridge BAR1 prefetch and burst */
571 - pci_write_config_dword(dev, SSB_BAR1_CONTROL, 3);
573 - /* Make sure our latency is high enough to handle the devices behind us */
575 - ssb_printk(KERN_INFO "PCI: Fixing latency timer of device %s to %u\n",
576 - pci_name(dev), lat);
577 - pci_write_config_byte(dev, PCI_LATENCY_TIMER, lat);
579 -DECLARE_PCI_FIXUP_EARLY(PCI_ANY_ID, PCI_ANY_ID, ssb_fixup_pcibridge);
581 -int __init pcibios_map_irq(const struct pci_dev *dev, u8 slot, u8 pin)
583 - return ssb_mips_irq(extpci_core->dev) + 2;
586 static u32 get_cfgspace_addr(struct ssb_pcicore *pc,
587 unsigned int bus, unsigned int dev,
588 @@ -317,6 +249,92 @@ static struct pci_controller ssb_pcicore
589 .mem_offset = 0x24000000,
592 +static u32 ssb_pcicore_pcibus_iobase = 0x100;
593 +static u32 ssb_pcicore_pcibus_membase = SSB_PCI_DMA;
595 +/* This function is called when doing a pci_enable_device().
596 + * We must first check if the device is a device on the PCI-core bridge. */
597 +int ssb_pcicore_plat_dev_init(struct pci_dev *d)
599 + struct resource *res;
603 + if (d->bus->ops != &ssb_pcicore_pciops) {
604 + /* This is not a device on the PCI-core bridge. */
608 + ssb_printk(KERN_INFO "PCI: Fixing up device %s\n",
611 + /* Fix up resource bases */
612 + for (pos = 0; pos < 6; pos++) {
613 + res = &d->resource[pos];
614 + if (res->flags & IORESOURCE_IO)
615 + base = &ssb_pcicore_pcibus_iobase;
617 + base = &ssb_pcicore_pcibus_membase;
618 + res->flags |= IORESOURCE_PCI_FIXED;
620 + size = res->end - res->start + 1;
621 + if (*base & (size - 1))
622 + *base = (*base + size) & ~(size - 1);
623 + res->start = *base;
624 + res->end = res->start + size - 1;
626 + pci_write_config_dword(d, PCI_BASE_ADDRESS_0 + (pos << 2), res->start);
628 + /* Fix up PCI bridge BAR0 only */
629 + if (d->bus->number == 0 && PCI_SLOT(d->devfn) == 0)
632 + /* Fix up interrupt lines */
633 + d->irq = ssb_mips_irq(extpci_core->dev) + 2;
634 + pci_write_config_byte(d, PCI_INTERRUPT_LINE, d->irq);
639 +/* Early PCI fixup for a device on the PCI-core bridge. */
640 +static void ssb_pcicore_fixup_pcibridge(struct pci_dev *dev)
644 + if (dev->bus->ops != &ssb_pcicore_pciops) {
645 + /* This is not a device on the PCI-core bridge. */
648 + if (dev->bus->number != 0 || PCI_SLOT(dev->devfn) != 0)
651 + ssb_printk(KERN_INFO "PCI: Fixing up bridge %s\n", pci_name(dev));
653 + /* Enable PCI bridge bus mastering and memory space */
654 + pci_set_master(dev);
655 + pcibios_enable_device(dev, ~0);
657 + /* Enable PCI bridge BAR1 prefetch and burst */
658 + pci_write_config_dword(dev, SSB_BAR1_CONTROL, 3);
660 + /* Make sure our latency is high enough to handle the devices behind us */
662 + ssb_printk(KERN_INFO "PCI: Fixing latency timer of device %s to %u\n",
663 + pci_name(dev), lat);
664 + pci_write_config_byte(dev, PCI_LATENCY_TIMER, lat);
666 +DECLARE_PCI_FIXUP_EARLY(PCI_ANY_ID, PCI_ANY_ID, ssb_pcicore_fixup_pcibridge);
668 +/* PCI device IRQ mapping. */
669 +int ssb_pcicore_pcibios_map_irq(const struct pci_dev *dev, u8 slot, u8 pin)
671 + if (dev->bus->ops != &ssb_pcicore_pciops) {
672 + /* This is not a device on the PCI-core bridge. */
675 + return ssb_mips_irq(extpci_core->dev) + 2;
678 static void ssb_pcicore_init_hostmode(struct ssb_pcicore *pc)
681 Index: linux-2.6.23.17/drivers/ssb/embedded.c
682 ===================================================================
683 --- linux-2.6.23.17.orig/drivers/ssb/embedded.c
684 +++ linux-2.6.23.17/drivers/ssb/embedded.c
687 #include <linux/ssb/ssb.h>
688 #include <linux/ssb/ssb_embedded.h>
689 +#include <linux/ssb/ssb_driver_pci.h>
690 +#include <linux/ssb/ssb_driver_gige.h>
691 +#include <linux/pci.h>
693 #include "ssb_private.h"
695 @@ -130,3 +133,90 @@ u32 ssb_gpio_polarity(struct ssb_bus *bu
698 EXPORT_SYMBOL(ssb_gpio_polarity);
700 +#ifdef CONFIG_SSB_DRIVER_GIGE
701 +static int gige_pci_init_callback(struct ssb_bus *bus, unsigned long data)
703 + struct pci_dev *pdev = (struct pci_dev *)data;
704 + struct ssb_device *dev;
708 + for (i = 0; i < bus->nr_devices; i++) {
709 + dev = &(bus->devices[i]);
710 + if (dev->id.coreid != SSB_DEV_ETHERNET_GBIT)
713 + !dev->dev->driver ||
714 + !device_is_registered(dev->dev))
716 + res = ssb_gige_pcibios_plat_dev_init(dev, pdev);
723 +#endif /* CONFIG_SSB_DRIVER_GIGE */
725 +int ssb_pcibios_plat_dev_init(struct pci_dev *dev)
729 + err = ssb_pcicore_plat_dev_init(dev);
732 +#ifdef CONFIG_SSB_DRIVER_GIGE
733 + err = ssb_for_each_bus_call((unsigned long)dev, gige_pci_init_callback);
737 + /* This is not a PCI device on any SSB device. */
742 +#ifdef CONFIG_SSB_DRIVER_GIGE
743 +static int gige_map_irq_callback(struct ssb_bus *bus, unsigned long data)
745 + const struct pci_dev *pdev = (const struct pci_dev *)data;
746 + struct ssb_device *dev;
750 + for (i = 0; i < bus->nr_devices; i++) {
751 + dev = &(bus->devices[i]);
752 + if (dev->id.coreid != SSB_DEV_ETHERNET_GBIT)
755 + !dev->dev->driver ||
756 + !device_is_registered(dev->dev))
758 + res = ssb_gige_map_irq(dev, pdev);
765 +#endif /* CONFIG_SSB_DRIVER_GIGE */
767 +int ssb_pcibios_map_irq(const struct pci_dev *dev, u8 slot, u8 pin)
771 + /* Check if this PCI device is a device on a SSB bus or device
772 + * and return the IRQ number for it. */
774 + res = ssb_pcicore_pcibios_map_irq(dev, slot, pin);
777 +#ifdef CONFIG_SSB_DRIVER_GIGE
778 + res = ssb_for_each_bus_call((unsigned long)dev, gige_map_irq_callback);
782 + /* This is not a PCI device on any SSB device. */
786 Index: linux-2.6.23.17/include/linux/ssb/ssb.h
787 ===================================================================
788 --- linux-2.6.23.17.orig/include/linux/ssb/ssb.h
789 +++ linux-2.6.23.17/include/linux/ssb/ssb.h
790 @@ -422,5 +422,12 @@ extern int ssb_bus_powerup(struct ssb_bu
791 extern u32 ssb_admatch_base(u32 adm);
792 extern u32 ssb_admatch_size(u32 adm);
794 +/* PCI device mapping and fixup routines.
795 + * Called from the architecture pcibios init code.
796 + * These are only available on SSB_EMBEDDED configurations. */
797 +#ifdef CONFIG_SSB_EMBEDDED
798 +int ssb_pcibios_plat_dev_init(struct pci_dev *dev);
799 +int ssb_pcibios_map_irq(const struct pci_dev *dev, u8 slot, u8 pin);
800 +#endif /* CONFIG_SSB_EMBEDDED */
802 #endif /* LINUX_SSB_H_ */
803 Index: linux-2.6.23.17/include/linux/ssb/ssb_driver_pci.h
804 ===================================================================
805 --- linux-2.6.23.17.orig/include/linux/ssb/ssb_driver_pci.h
806 +++ linux-2.6.23.17/include/linux/ssb/ssb_driver_pci.h
808 #ifndef LINUX_SSB_PCICORE_H_
809 #define LINUX_SSB_PCICORE_H_
811 +#include <linux/types.h>
816 #ifdef CONFIG_SSB_DRIVER_PCICORE
818 /* PCI core registers. */
819 @@ -88,6 +93,9 @@ extern void ssb_pcicore_init(struct ssb_
820 extern int ssb_pcicore_dev_irqvecs_enable(struct ssb_pcicore *pc,
821 struct ssb_device *dev);
823 +int ssb_pcicore_plat_dev_init(struct pci_dev *d);
824 +int ssb_pcicore_pcibios_map_irq(const struct pci_dev *dev, u8 slot, u8 pin);
827 #else /* CONFIG_SSB_DRIVER_PCICORE */
829 @@ -107,5 +115,16 @@ int ssb_pcicore_dev_irqvecs_enable(struc
834 +int ssb_pcicore_plat_dev_init(struct pci_dev *d)
839 +int ssb_pcicore_pcibios_map_irq(const struct pci_dev *dev, u8 slot, u8 pin)
844 #endif /* CONFIG_SSB_DRIVER_PCICORE */
845 #endif /* LINUX_SSB_PCICORE_H_ */
846 Index: linux-2.6.23.17/drivers/ssb/main.c
847 ===================================================================
848 --- linux-2.6.23.17.orig/drivers/ssb/main.c
849 +++ linux-2.6.23.17/drivers/ssb/main.c
851 #include <linux/io.h>
852 #include <linux/ssb/ssb.h>
853 #include <linux/ssb/ssb_regs.h>
854 +#include <linux/ssb/ssb_driver_gige.h>
855 #include <linux/dma-mapping.h>
856 #include <linux/pci.h>
858 @@ -68,6 +69,25 @@ found:
860 #endif /* CONFIG_SSB_PCIHOST */
862 +int ssb_for_each_bus_call(unsigned long data,
863 + int (*func)(struct ssb_bus *bus, unsigned long data))
865 + struct ssb_bus *bus;
869 + list_for_each_entry(bus, &buses, list) {
870 + res = func(bus, data);
872 + ssb_buses_unlock();
876 + ssb_buses_unlock();
881 static struct ssb_device *ssb_device_get(struct ssb_device *dev)
884 @@ -1175,7 +1195,14 @@ static int __init ssb_modinit(void)
885 err = b43_pci_ssb_bridge_init();
887 ssb_printk(KERN_ERR "Broadcom 43xx PCI-SSB-bridge "
888 - "initialization failed");
889 + "initialization failed\n");
890 + /* don't fail SSB init because of this */
893 + err = ssb_gige_init();
895 + ssb_printk(KERN_ERR "SSB Broadcom Gigabit Ethernet "
896 + "driver initialization failed\n");
897 /* don't fail SSB init because of this */
900 @@ -1189,6 +1216,7 @@ fs_initcall(ssb_modinit);
902 static void __exit ssb_modexit(void)
905 b43_pci_ssb_bridge_exit();
906 bus_unregister(&ssb_bustype);
908 Index: linux-2.6.23.17/drivers/ssb/ssb_private.h
909 ===================================================================
910 --- linux-2.6.23.17.orig/drivers/ssb/ssb_private.h
911 +++ linux-2.6.23.17/drivers/ssb/ssb_private.h
912 @@ -118,6 +118,8 @@ extern u32 ssb_calc_clock_rate(u32 pllty
913 extern int ssb_devices_freeze(struct ssb_bus *bus);
914 extern int ssb_devices_thaw(struct ssb_bus *bus);
915 extern struct ssb_bus *ssb_pci_dev_to_bus(struct pci_dev *pdev);
916 +int ssb_for_each_bus_call(unsigned long data,
917 + int (*func)(struct ssb_bus *bus, unsigned long data));
919 /* b43_pci_bridge.c */
920 #ifdef CONFIG_SSB_PCIHOST
921 Index: linux-2.6.23.17/drivers/net/tg3.c
922 ===================================================================
923 --- linux-2.6.23.17.orig/drivers/net/tg3.c
924 +++ linux-2.6.23.17/drivers/net/tg3.c
926 #include <linux/workqueue.h>
927 #include <linux/prefetch.h>
928 #include <linux/dma-mapping.h>
929 +#include <linux/ssb/ssb_driver_gige.h>
931 #include <net/checksum.h>
933 @@ -410,8 +411,9 @@ static void _tw32_flush(struct tg3 *tp,
934 static inline void tw32_mailbox_flush(struct tg3 *tp, u32 off, u32 val)
936 tp->write32_mbox(tp, off, val);
937 - if (!(tp->tg3_flags & TG3_FLAG_MBOX_WRITE_REORDER) &&
938 - !(tp->tg3_flags2 & TG3_FLG2_ICH_WORKAROUND))
939 + if ((tp->tg3_flags3 & TG3_FLG3_FLUSH_POSTED_WRITES) ||
940 + (!(tp->tg3_flags & TG3_FLAG_MBOX_WRITE_REORDER) &&
941 + !(tp->tg3_flags2 & TG3_FLG2_ICH_WORKAROUND)))
942 tp->read32_mbox(tp, off);
945 @@ -623,7 +625,7 @@ static void tg3_switch_clocks(struct tg3
947 #define PHY_BUSY_LOOPS 5000
949 -static int tg3_readphy(struct tg3 *tp, int reg, u32 *val)
950 +static int __tg3_readphy(struct tg3 *tp, unsigned int phy_addr, int reg, u32 *val)
954 @@ -637,7 +639,7 @@ static int tg3_readphy(struct tg3 *tp, i
958 - frame_val = ((PHY_ADDR << MI_COM_PHY_ADDR_SHIFT) &
959 + frame_val = ((phy_addr << MI_COM_PHY_ADDR_SHIFT) &
960 MI_COM_PHY_ADDR_MASK);
961 frame_val |= ((reg << MI_COM_REG_ADDR_SHIFT) &
962 MI_COM_REG_ADDR_MASK);
963 @@ -672,7 +674,12 @@ static int tg3_readphy(struct tg3 *tp, i
967 -static int tg3_writephy(struct tg3 *tp, int reg, u32 val)
968 +static int tg3_readphy(struct tg3 *tp, int reg, u32 *val)
970 + return __tg3_readphy(tp, PHY_ADDR, reg, val);
973 +static int __tg3_writephy(struct tg3 *tp, unsigned int phy_addr, int reg, u32 val)
977 @@ -688,7 +695,7 @@ static int tg3_writephy(struct tg3 *tp,
981 - frame_val = ((PHY_ADDR << MI_COM_PHY_ADDR_SHIFT) &
982 + frame_val = ((phy_addr << MI_COM_PHY_ADDR_SHIFT) &
983 MI_COM_PHY_ADDR_MASK);
984 frame_val |= ((reg << MI_COM_REG_ADDR_SHIFT) &
985 MI_COM_REG_ADDR_MASK);
986 @@ -721,6 +728,11 @@ static int tg3_writephy(struct tg3 *tp,
990 +static int tg3_writephy(struct tg3 *tp, int reg, u32 val)
992 + return __tg3_writephy(tp, PHY_ADDR, reg, val);
995 static void tg3_phy_toggle_automdix(struct tg3 *tp, int enable)
998 @@ -1988,6 +2000,14 @@ static int tg3_setup_copper_phy(struct t
999 tp->link_config.active_duplex = current_duplex;
1002 + if (tp->tg3_flags3 & TG3_FLG3_ROBOSWITCH) {
1003 + current_link_up = 1;
1004 + current_speed = SPEED_1000; //FIXME
1005 + current_duplex = DUPLEX_FULL;
1006 + tp->link_config.active_speed = current_speed;
1007 + tp->link_config.active_duplex = current_duplex;
1010 if (current_link_up == 1 &&
1011 (tp->link_config.active_duplex == DUPLEX_FULL) &&
1012 (tp->link_config.autoneg == AUTONEG_ENABLE)) {
1013 @@ -4813,6 +4833,11 @@ static int tg3_poll_fw(struct tg3 *tp)
1017 + if (tp->tg3_flags3 & TG3_FLG3_IS_SSB_CORE) {
1018 + /* We don't use firmware. */
1022 if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5906) {
1023 /* Wait up to 20ms for init done. */
1024 for (i = 0; i < 200; i++) {
1025 @@ -5040,6 +5065,14 @@ static int tg3_chip_reset(struct tg3 *tp
1026 tw32(0x5000, 0x400);
1029 + if (tp->tg3_flags3 & TG3_FLG3_IS_SSB_CORE) {
1030 + /* BCM4785: In order to avoid repercussions from using potentially
1031 + * defective internal ROM, stop the Rx RISC CPU, which is not
1034 + tg3_halt_cpu(tp, RX_CPU_BASE);
1037 tw32(GRC_MODE, tp->grc_mode);
1039 if (tp->pci_chip_rev_id == CHIPREV_ID_5705_A0) {
1040 @@ -5308,9 +5341,12 @@ static int tg3_halt_cpu(struct tg3 *tp,
1044 - /* Clear firmware's nvram arbitration. */
1045 - if (tp->tg3_flags & TG3_FLAG_NVRAM)
1046 - tw32(NVRAM_SWARB, SWARB_REQ_CLR0);
1047 + if (!(tp->tg3_flags3 & TG3_FLG3_IS_SSB_CORE)) {
1048 + /* Clear firmware's nvram arbitration. */
1049 + if (tp->tg3_flags & TG3_FLAG_NVRAM)
1050 + tw32(NVRAM_SWARB, SWARB_REQ_CLR0);
1056 @@ -5391,6 +5427,11 @@ static int tg3_load_5701_a0_firmware_fix
1057 struct fw_info info;
1060 + if (tp->tg3_flags3 & TG3_FLG3_IS_SSB_CORE) {
1061 + /* We don't use firmware. */
1065 info.text_base = TG3_FW_TEXT_ADDR;
1066 info.text_len = TG3_FW_TEXT_LEN;
1067 info.text_data = &tg3FwText[0];
1068 @@ -5949,6 +5990,11 @@ static int tg3_load_tso_firmware(struct
1069 unsigned long cpu_base, cpu_scratch_base, cpu_scratch_size;
1072 + if (tp->tg3_flags3 & TG3_FLG3_IS_SSB_CORE) {
1073 + /* We don't use firmware. */
1077 if (tp->tg3_flags2 & TG3_FLG2_HW_TSO)
1080 @@ -6850,6 +6896,11 @@ static void tg3_timer(unsigned long __op
1082 spin_lock(&tp->lock);
1084 + if (tp->tg3_flags3 & TG3_FLG3_FLUSH_POSTED_WRITES) {
1085 + /* BCM4785: Flush posted writes from GbE to host memory. */
1086 + tr32(HOSTCC_MODE);
1089 if (!(tp->tg3_flags & TG3_FLAG_TAGGED_STATUS)) {
1090 /* All of this garbage is because when using non-tagged
1091 * IRQ status the mailbox/status_block protocol the chip
1092 @@ -8432,6 +8483,11 @@ static int tg3_test_nvram(struct tg3 *tp
1093 u32 *buf, csum, magic;
1094 int i, j, err = 0, size;
1096 + if (tp->tg3_flags3 & TG3_FLG3_IS_SSB_CORE) {
1097 + /* We don't have NVRAM. */
1101 if (tg3_nvram_read_swab(tp, 0, &magic) != 0)
1104 @@ -9154,7 +9210,7 @@ static int tg3_ioctl(struct net_device *
1107 spin_lock_bh(&tp->lock);
1108 - err = tg3_readphy(tp, data->reg_num & 0x1f, &mii_regval);
1109 + err = __tg3_readphy(tp, data->phy_id & 0x1f, data->reg_num & 0x1f, &mii_regval);
1110 spin_unlock_bh(&tp->lock);
1112 data->val_out = mii_regval;
1113 @@ -9173,7 +9229,7 @@ static int tg3_ioctl(struct net_device *
1116 spin_lock_bh(&tp->lock);
1117 - err = tg3_writephy(tp, data->reg_num & 0x1f, data->val_in);
1118 + err = __tg3_writephy(tp, data->phy_id & 0x1f, data->reg_num & 0x1f, data->val_in);
1119 spin_unlock_bh(&tp->lock);
1122 @@ -9571,6 +9627,12 @@ static void __devinit tg3_get_5906_nvram
1123 /* Chips other than 5700/5701 use the NVRAM for fetching info. */
1124 static void __devinit tg3_nvram_init(struct tg3 *tp)
1126 + if (tp->tg3_flags3 & TG3_FLG3_IS_SSB_CORE) {
1127 + /* No NVRAM and EEPROM on the SSB Broadcom GigE core. */
1128 + tp->tg3_flags &= ~(TG3_FLAG_NVRAM | TG3_FLAG_NVRAM_BUFFERED);
1132 tw32_f(GRC_EEPROM_ADDR,
1133 (EEPROM_ADDR_FSM_RESET |
1134 (EEPROM_DEFAULT_CLOCK_PERIOD <<
1135 @@ -9706,6 +9768,9 @@ static int tg3_nvram_read(struct tg3 *tp
1139 + if (tp->tg3_flags3 & TG3_FLG3_IS_SSB_CORE)
1142 if (!(tp->tg3_flags & TG3_FLAG_NVRAM))
1143 return tg3_nvram_read_using_eeprom(tp, offset, val);
1145 @@ -9938,6 +10003,9 @@ static int tg3_nvram_write_block(struct
1149 + if (tp->tg3_flags3 & TG3_FLG3_IS_SSB_CORE)
1152 if (tp->tg3_flags & TG3_FLAG_EEPROM_WRITE_PROT) {
1153 tw32_f(GRC_LOCAL_CTRL, tp->grc_local_ctrl &
1154 ~GRC_LCLCTRL_GPIO_OUTPUT1);
1155 @@ -10804,7 +10872,6 @@ static int __devinit tg3_get_invariants(
1156 tp->write32 = tg3_write_flush_reg32;
1160 if ((tp->tg3_flags & TG3_FLAG_TXD_MBOX_HWBUG) ||
1161 (tp->tg3_flags & TG3_FLAG_MBOX_WRITE_REORDER)) {
1162 tp->write32_tx_mbox = tg3_write32_tx_mbox;
1163 @@ -10840,6 +10907,11 @@ static int __devinit tg3_get_invariants(
1164 GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5701)))
1165 tp->tg3_flags |= TG3_FLAG_SRAM_USE_CONFIG;
1167 + if (tp->tg3_flags3 & TG3_FLG3_FLUSH_POSTED_WRITES) {
1168 + tp->write32_tx_mbox = tg3_write_flush_reg32;
1169 + tp->write32_rx_mbox = tg3_write_flush_reg32;
1172 /* Get eeprom hw config before calling tg3_set_power_state().
1173 * In particular, the TG3_FLG2_IS_NIC flag must be
1174 * determined before calling tg3_set_power_state() so that
1175 @@ -11184,6 +11256,10 @@ static int __devinit tg3_get_device_addr
1178 if (!is_valid_ether_addr(&dev->dev_addr[0])) {
1179 + if (tp->tg3_flags3 & TG3_FLG3_IS_SSB_CORE)
1180 + ssb_gige_get_macaddr(tp->pdev, &dev->dev_addr[0]);
1182 + if (!is_valid_ether_addr(&dev->dev_addr[0])) {
1183 #ifdef CONFIG_SPARC64
1184 if (!tg3_get_default_macaddr_sparc(tp))
1186 @@ -11675,6 +11751,7 @@ static char * __devinit tg3_phy_string(s
1187 case PHY_ID_BCM5704: return "5704";
1188 case PHY_ID_BCM5705: return "5705";
1189 case PHY_ID_BCM5750: return "5750";
1190 + case PHY_ID_BCM5750_2: return "5750-2";
1191 case PHY_ID_BCM5752: return "5752";
1192 case PHY_ID_BCM5714: return "5714";
1193 case PHY_ID_BCM5780: return "5780";
1194 @@ -11859,6 +11936,13 @@ static int __devinit tg3_init_one(struct
1195 tp->msg_enable = tg3_debug;
1197 tp->msg_enable = TG3_DEF_MSG_ENABLE;
1198 + if (pdev_is_ssb_gige_core(pdev)) {
1199 + tp->tg3_flags3 |= TG3_FLG3_IS_SSB_CORE;
1200 + if (ssb_gige_must_flush_posted_writes(pdev))
1201 + tp->tg3_flags3 |= TG3_FLG3_FLUSH_POSTED_WRITES;
1202 + if (ssb_gige_have_roboswitch(pdev))
1203 + tp->tg3_flags3 |= TG3_FLG3_ROBOSWITCH;
1206 /* The word/byte swap controls here control register access byte
1207 * swapping. DMA data byte swapping is controlled in the GRC_MODE
1208 Index: linux-2.6.23.17/drivers/net/tg3.h
1209 ===================================================================
1210 --- linux-2.6.23.17.orig/drivers/net/tg3.h
1211 +++ linux-2.6.23.17/drivers/net/tg3.h
1212 @@ -2279,6 +2279,10 @@ struct tg3 {
1213 #define TG3_FLG2_PHY_JITTER_BUG 0x20000000
1214 #define TG3_FLG2_NO_FWARE_REPORTED 0x40000000
1215 #define TG3_FLG2_PHY_ADJUST_TRIM 0x80000000
1217 +#define TG3_FLG3_IS_SSB_CORE 0x00000001
1218 +#define TG3_FLG3_FLUSH_POSTED_WRITES 0x00000002
1219 +#define TG3_FLG3_ROBOSWITCH 0x00000004
1221 struct timer_list timer;
1223 @@ -2333,6 +2337,7 @@ struct tg3 {
1224 #define PHY_ID_BCM5714 0x60008340
1225 #define PHY_ID_BCM5780 0x60008350
1226 #define PHY_ID_BCM5755 0xbc050cc0
1227 +#define PHY_ID_BCM5750_2 0xbc050cd0
1228 #define PHY_ID_BCM5787 0xbc050ce0
1229 #define PHY_ID_BCM5756 0xbc050ed0
1230 #define PHY_ID_BCM5906 0xdc00ac40
1231 @@ -2364,7 +2369,8 @@ struct tg3 {
1232 (X) == PHY_ID_BCM5752 || (X) == PHY_ID_BCM5714 || \
1233 (X) == PHY_ID_BCM5780 || (X) == PHY_ID_BCM5787 || \
1234 (X) == PHY_ID_BCM5755 || (X) == PHY_ID_BCM5756 || \
1235 - (X) == PHY_ID_BCM5906 || (X) == PHY_ID_BCM8002)
1236 + (X) == PHY_ID_BCM5906 || (X) == PHY_ID_BCM8002 || \
1237 + (X) == PHY_ID_BCM5750_2)
1239 struct tg3_hw_stats *hw_stats;
1240 dma_addr_t stats_mapping;
1241 Index: linux-2.6.23.17/drivers/ssb/driver_mipscore.c
1242 ===================================================================
1243 --- linux-2.6.23.17.orig/drivers/ssb/driver_mipscore.c
1244 +++ linux-2.6.23.17/drivers/ssb/driver_mipscore.c
1245 @@ -212,6 +212,7 @@ void ssb_mipscore_init(struct ssb_mipsco
1248 case SSB_DEV_ETHERNET:
1249 + case SSB_DEV_ETHERNET_GBIT:
1251 case SSB_DEV_USB20_HOST:
1252 /* These devices get their own IRQ line if available, the rest goes on IRQ0 */