1 Index: linux-2.6.23.16/drivers/ssb/Kconfig
2 ===================================================================
3 --- linux-2.6.23.16.orig/drivers/ssb/Kconfig 2008-02-22 19:40:57.000000000 +0100
4 +++ linux-2.6.23.16/drivers/ssb/Kconfig 2008-02-22 19:42:52.000000000 +0100
5 @@ -120,4 +120,13 @@ config SSB_DRIVER_EXTIF
9 +config SSB_DRIVER_GIGE
10 + bool "SSB Broadcom Gigabit Ethernet driver (EXPERIMENTAL)"
11 + depends on SSB_PCIHOST_POSSIBLE && SSB_EMBEDDED && MIPS && EXPERIMENTAL
13 + Driver the the Sonics Silicon Backplane attached
14 + Broadcom Gigabit Ethernet.
19 Index: linux-2.6.23.16/drivers/ssb/Makefile
20 ===================================================================
21 --- linux-2.6.23.16.orig/drivers/ssb/Makefile 2008-02-22 19:40:57.000000000 +0100
22 +++ linux-2.6.23.16/drivers/ssb/Makefile 2008-02-22 19:42:52.000000000 +0100
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.16/drivers/ssb/driver_gige.c
32 ===================================================================
33 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
34 +++ linux-2.6.23.16/drivers/ssb/driver_gige.c 2008-02-22 20:59:46.000000000 +0100
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/pci.h>
48 +#include <linux/pci_regs.h>
49 +#include <linux/ssb/ssb_driver_gige.h>
52 +MODULE_DESCRIPTION("SSB Broadcom Gigabit Ethernet driver");
53 +MODULE_AUTHOR("Michael Buesch");
54 +MODULE_LICENSE("GPL");
57 +static const struct ssb_device_id ssb_gige_tbl[] = {
58 + SSB_DEVICE(SSB_VENDOR_BROADCOM, SSB_DEV_ETHERNET_GBIT, SSB_ANY_REV),
61 +MODULE_DEVICE_TABLE(ssb, ssb_gige_tbl);
64 +static inline u8 gige_read8(struct ssb_gige *dev, u16 offset)
66 + return ssb_read8(dev->dev, offset);
69 +static inline u16 gige_read16(struct ssb_gige *dev, u16 offset)
71 + return ssb_read16(dev->dev, offset);
74 +static inline u32 gige_read32(struct ssb_gige *dev, u16 offset)
76 + return ssb_read32(dev->dev, offset);
79 +static inline void gige_write8(struct ssb_gige *dev,
80 + u16 offset, u8 value)
82 + ssb_write8(dev->dev, offset, value);
85 +static inline void gige_write16(struct ssb_gige *dev,
86 + u16 offset, u16 value)
88 + ssb_write16(dev->dev, offset, value);
91 +static inline void gige_write32(struct ssb_gige *dev,
92 + u16 offset, u32 value)
94 + ssb_write32(dev->dev, offset, value);
98 +u8 gige_pcicfg_read8(struct ssb_gige *dev, unsigned int offset)
100 + BUG_ON(offset >= 256);
101 + return gige_read8(dev, SSB_GIGE_PCICFG + offset);
105 +u16 gige_pcicfg_read16(struct ssb_gige *dev, unsigned int offset)
107 + BUG_ON(offset >= 256);
108 + return gige_read16(dev, SSB_GIGE_PCICFG + offset);
112 +u32 gige_pcicfg_read32(struct ssb_gige *dev, unsigned int offset)
114 + BUG_ON(offset >= 256);
115 + return gige_read32(dev, SSB_GIGE_PCICFG + offset);
119 +void gige_pcicfg_write8(struct ssb_gige *dev,
120 + unsigned int offset, u8 value)
122 + BUG_ON(offset >= 256);
123 + gige_write8(dev, SSB_GIGE_PCICFG + offset, value);
127 +void gige_pcicfg_write16(struct ssb_gige *dev,
128 + unsigned int offset, u16 value)
130 + BUG_ON(offset >= 256);
131 + gige_write16(dev, SSB_GIGE_PCICFG + offset, value);
135 +void gige_pcicfg_write32(struct ssb_gige *dev,
136 + unsigned int offset, u32 value)
138 + BUG_ON(offset >= 256);
139 + gige_write32(dev, SSB_GIGE_PCICFG + offset, value);
142 +static int ssb_gige_pci_read_config(struct pci_bus *bus, unsigned int devfn,
143 + int reg, int size, u32 *val)
145 + struct ssb_gige *dev = container_of(bus->ops, struct ssb_gige, pci_ops);
146 + unsigned long flags;
148 + if ((PCI_SLOT(devfn) > 0) || (PCI_FUNC(devfn) > 0))
149 + return PCIBIOS_DEVICE_NOT_FOUND;
151 + return PCIBIOS_DEVICE_NOT_FOUND;
153 + spin_lock_irqsave(&dev->lock, flags);
156 + *val = gige_pcicfg_read8(dev, reg);
159 + *val = gige_pcicfg_read16(dev, reg);
162 + *val = gige_pcicfg_read32(dev, reg);
167 + spin_unlock_irqrestore(&dev->lock, flags);
169 + return PCIBIOS_SUCCESSFUL;
172 +static int ssb_gige_pci_write_config(struct pci_bus *bus, unsigned int devfn,
173 + int reg, int size, u32 val)
175 + struct ssb_gige *dev = container_of(bus->ops, struct ssb_gige, pci_ops);
176 + unsigned long flags;
178 + if ((PCI_SLOT(devfn) > 0) || (PCI_FUNC(devfn) > 0))
179 + return PCIBIOS_DEVICE_NOT_FOUND;
181 + return PCIBIOS_DEVICE_NOT_FOUND;
183 + spin_lock_irqsave(&dev->lock, flags);
186 + gige_pcicfg_write8(dev, reg, val);
189 + gige_pcicfg_write16(dev, reg, val);
192 + gige_pcicfg_write32(dev, reg, val);
197 + spin_unlock_irqrestore(&dev->lock, flags);
199 + return PCIBIOS_SUCCESSFUL;
202 +static int ssb_gige_probe(struct ssb_device *sdev, const struct ssb_device_id *id)
204 + struct ssb_gige *dev;
205 + u32 base, tmslow, tmshigh;
207 + dev = kzalloc(sizeof(*dev), GFP_KERNEL);
212 + spin_lock_init(&dev->lock);
213 + dev->pci_controller.pci_ops = &dev->pci_ops;
214 + dev->pci_controller.io_resource = &dev->io_resource;
215 + dev->pci_controller.mem_resource = &dev->mem_resource;
216 + dev->pci_controller.io_map_base = 0x800;
217 + dev->pci_ops.read = ssb_gige_pci_read_config;
218 + dev->pci_ops.write = ssb_gige_pci_write_config;
220 + dev->io_resource.name = SSB_GIGE_IO_RES_NAME;
221 + dev->io_resource.start = 0x800;
222 + dev->io_resource.end = 0x8FF;
223 + dev->io_resource.flags = IORESOURCE_IO | IORESOURCE_PCI_FIXED;
225 + if (!ssb_device_is_enabled(sdev))
226 + ssb_device_enable(sdev, 0);
228 + /* Setup BAR0. This is a 64k MMIO region. */
229 + base = ssb_admatch_base(ssb_read32(sdev, SSB_ADMATCH1));
230 + gige_pcicfg_write32(dev, PCI_BASE_ADDRESS_0, base);
231 + gige_pcicfg_write32(dev, PCI_BASE_ADDRESS_1, 0);
233 + dev->mem_resource.name = SSB_GIGE_MEM_RES_NAME;
234 + dev->mem_resource.start = base;
235 + dev->mem_resource.end = base + 0x10000 - 1;
236 + dev->mem_resource.flags = IORESOURCE_MEM | IORESOURCE_PCI_FIXED;
238 + /* Enable the memory region. */
239 + gige_pcicfg_write16(dev, PCI_COMMAND,
240 + gige_pcicfg_read16(dev, PCI_COMMAND)
241 + | PCI_COMMAND_MEMORY);
243 + /* Write flushing is controlled by the Flush Status Control register.
244 + * We want to flush every register write with a timeout and we want
245 + * to disable the IRQ mask while flushing to avoid concurrency.
246 + * Note that automatic write flushing does _not_ work from
247 + * an IRQ handler. The driver must flush manually by reading a register.
249 + gige_write32(dev, SSB_GIGE_SHIM_FLUSHSTAT, 0x00000068);
251 + /* Check if we have an RGMII or GMII PHY-bus.
252 + * On RGMII do not bypass the DLLs */
253 + tmslow = ssb_read32(sdev, SSB_TMSLOW);
254 + tmshigh = ssb_read32(sdev, SSB_TMSHIGH);
255 + if (tmshigh & SSB_GIGE_TMSHIGH_RGMII) {
256 + tmslow &= ~SSB_GIGE_TMSLOW_TXBYPASS;
257 + tmslow &= ~SSB_GIGE_TMSLOW_RXBYPASS;
258 + dev->has_rgmii = 1;
260 + tmslow |= SSB_GIGE_TMSLOW_TXBYPASS;
261 + tmslow |= SSB_GIGE_TMSLOW_RXBYPASS;
262 + dev->has_rgmii = 0;
264 + tmslow |= SSB_GIGE_TMSLOW_DLLEN;
265 + ssb_write32(sdev, SSB_TMSLOW, tmslow);
267 + ssb_set_drvdata(sdev, dev);
268 + register_pci_controller(&dev->pci_controller);
273 +int ssb_gige_pcibios_plat_dev_init(struct ssb_device *sdev,
274 + struct pci_dev *pdev)
276 + struct ssb_gige *dev = ssb_get_drvdata(sdev);
277 + struct resource *res;
279 + if (pdev->bus->ops != &dev->pci_ops) {
280 + /* The PCI device is not on this SSB GigE bridge device. */
284 + /* Fixup the PCI resources. */
285 + res = &(pdev->resource[0]);
286 + res->flags = IORESOURCE_MEM | IORESOURCE_PCI_FIXED;
287 + res->name = dev->mem_resource.name;
288 + res->start = dev->mem_resource.start;
289 + res->end = dev->mem_resource.end;
294 +int ssb_gige_map_irq(struct ssb_device *sdev,
295 + const struct pci_dev *pdev)
297 + struct ssb_gige *dev = ssb_get_drvdata(sdev);
299 + if (pdev->bus->ops != &dev->pci_ops) {
300 + /* The PCI device is not on this SSB GigE bridge device. */
304 + return ssb_mips_irq(sdev) + 2;
307 +static struct ssb_driver ssb_gige_driver = {
308 + .name = "BCM-GigE",
309 + .id_table = ssb_gige_tbl,
310 + .probe = ssb_gige_probe,
313 +int ssb_gige_init(void)
315 + return ssb_driver_register(&ssb_gige_driver);
317 Index: linux-2.6.23.16/include/linux/ssb/ssb_driver_gige.h
318 ===================================================================
319 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
320 +++ linux-2.6.23.16/include/linux/ssb/ssb_driver_gige.h 2008-02-22 20:47:58.000000000 +0100
322 +#ifndef LINUX_SSB_DRIVER_GIGE_H_
323 +#define LINUX_SSB_DRIVER_GIGE_H_
325 +#include <linux/ssb/ssb.h>
326 +#include <linux/pci.h>
327 +#include <linux/spinlock.h>
330 +#ifdef CONFIG_SSB_DRIVER_GIGE
333 +#define SSB_GIGE_PCIIO 0x0000 /* PCI I/O Registers (1024 bytes) */
334 +#define SSB_GIGE_RESERVED 0x0400 /* Reserved (1024 bytes) */
335 +#define SSB_GIGE_PCICFG 0x0800 /* PCI config space (256 bytes) */
336 +#define SSB_GIGE_SHIM_FLUSHSTAT 0x0C00 /* PCI to OCP: Flush status control (32bit) */
337 +#define SSB_GIGE_SHIM_FLUSHRDA 0x0C04 /* PCI to OCP: Flush read address (32bit) */
338 +#define SSB_GIGE_SHIM_FLUSHTO 0x0C08 /* PCI to OCP: Flush timeout counter (32bit) */
339 +#define SSB_GIGE_SHIM_BARRIER 0x0C0C /* PCI to OCP: Barrier register (32bit) */
340 +#define SSB_GIGE_SHIM_MAOCPSI 0x0C10 /* PCI to OCP: MaocpSI Control (32bit) */
341 +#define SSB_GIGE_SHIM_SIOCPMA 0x0C14 /* PCI to OCP: SiocpMa Control (32bit) */
343 +/* TM Status High flags */
344 +#define SSB_GIGE_TMSHIGH_RGMII 0x00010000 /* Have an RGMII PHY-bus */
345 +/* TM Status Low flags */
346 +#define SSB_GIGE_TMSLOW_TXBYPASS 0x00080000 /* TX bypass (no delay) */
347 +#define SSB_GIGE_TMSLOW_RXBYPASS 0x00100000 /* RX bypass (no delay) */
348 +#define SSB_GIGE_TMSLOW_DLLEN 0x01000000 /* Enable DLL controls */
350 +/* Boardflags (low) */
351 +#define SSB_GIGE_BFL_ROBOSWITCH 0x0010
354 +#define SSB_GIGE_MEM_RES_NAME "SSB Broadcom 47xx GigE memory"
355 +#define SSB_GIGE_IO_RES_NAME "SSB Broadcom 47xx GigE I/O"
358 + struct ssb_device *dev;
362 + /* True, if the device has an RGMII bus.
363 + * False, if the device has a GMII bus. */
366 + /* The PCI controller device. */
367 + struct pci_controller pci_controller;
368 + struct pci_ops pci_ops;
369 + struct resource mem_resource;
370 + struct resource io_resource;
373 +/* Check whether a PCI device is a SSB Gigabit Ethernet core. */
374 +static inline bool pdev_is_ssb_gige_core(struct pci_dev *pdev)
376 + return (pdev->resource[0].name &&
377 + strcmp(pdev->resource[0].name, SSB_GIGE_MEM_RES_NAME) == 0);
380 +/* Convert a pci_dev pointer to a ssb_gige pointer. */
381 +static inline struct ssb_gige * pdev_to_ssb_gige(struct pci_dev *pdev)
383 + if (!pdev_is_ssb_gige_core(pdev))
385 + return container_of(pdev->bus->ops, struct ssb_gige, pci_ops);
388 +/* Returns whether the PHY is connected by an RGMII bus. */
389 +static inline bool ssb_gige_is_rgmii(struct pci_dev *pdev)
391 + struct ssb_gige *dev = pdev_to_ssb_gige(pdev);
392 + return (dev ? dev->has_rgmii : 0);
395 +/* Returns whether we have a Roboswitch. */
396 +static inline bool ssb_gige_have_roboswitch(struct pci_dev *pdev)
398 + struct ssb_gige *dev = pdev_to_ssb_gige(pdev);
400 + return !!(dev->dev->bus->sprom.boardflags_lo &
401 + SSB_GIGE_BFL_ROBOSWITCH);
405 +/* Returns whether we can only do one DMA at once. */
406 +static inline bool ssb_gige_one_dma_at_once(struct pci_dev *pdev)
408 + struct ssb_gige *dev = pdev_to_ssb_gige(pdev);
410 + return ((dev->dev->bus->chip_id == 0x4785) &&
411 + (dev->dev->bus->chip_rev < 2));
415 +/* Returns whether we must flush posted writes. */
416 +static inline bool ssb_gige_must_flush_posted_writes(struct pci_dev *pdev)
418 + struct ssb_gige *dev = pdev_to_ssb_gige(pdev);
420 + return (dev->dev->bus->chip_id == 0x4785);
424 +extern char * nvram_get(const char *name); //FIXME
425 +/* Get the device MAC address */
426 +static inline void ssb_gige_get_macaddr(struct pci_dev *pdev, u8 *macaddr)
428 +#ifdef CONFIG_BCM947XX
429 + char *res = nvram_get("et0macaddr"); //FIXME
431 + memcpy(macaddr, res, 6);
435 +extern int ssb_gige_pcibios_plat_dev_init(struct ssb_device *sdev,
436 + struct pci_dev *pdev);
437 +extern int ssb_gige_map_irq(struct ssb_device *sdev,
438 + const struct pci_dev *pdev);
440 +/* The GigE driver is not a standalone module, because we don't have support
441 + * for unregistering the driver. So we could not unload the module anyway. */
442 +extern int ssb_gige_init(void);
443 +static inline void ssb_gige_exit(void)
445 + /* Currently we can not unregister the GigE driver,
446 + * because we can not unregister the PCI bridge. */
451 +#else /* CONFIG_SSB_DRIVER_GIGE */
452 +/* Gigabit Ethernet driver disabled */
455 +static inline int ssb_gige_pcibios_plat_dev_init(struct ssb_device *sdev,
456 + struct pci_dev *pdev)
460 +static inline int ssb_gige_map_irq(struct ssb_device *sdev,
461 + const struct pci_dev *pdev)
465 +static inline int ssb_gige_init(void)
469 +static inline void ssb_gige_exit(void)
473 +static inline bool pdev_is_ssb_gige_core(struct pci_dev *pdev)
477 +static inline struct ssb_gige * pdev_to_ssb_gige(struct pci_dev *pdev)
481 +static inline bool ssb_gige_is_rgmii(struct pci_dev *pdev)
485 +static inline bool ssb_gige_have_roboswitch(struct pci_dev *pdev)
489 +static inline bool ssb_gige_one_dma_at_once(struct pci_dev *pdev)
493 +static inline bool ssb_gige_must_flush_posted_writes(struct pci_dev *pdev)
498 +#endif /* CONFIG_SSB_DRIVER_GIGE */
499 +#endif /* LINUX_SSB_DRIVER_GIGE_H_ */
500 Index: linux-2.6.23.16/drivers/ssb/driver_pcicore.c
501 ===================================================================
502 --- linux-2.6.23.16.orig/drivers/ssb/driver_pcicore.c 2008-02-22 19:40:57.000000000 +0100
503 +++ linux-2.6.23.16/drivers/ssb/driver_pcicore.c 2008-02-22 19:42:52.000000000 +0100
504 @@ -60,74 +60,6 @@ static DEFINE_SPINLOCK(cfgspace_lock);
505 /* Core to access the external PCI config space. Can only have one. */
506 static struct ssb_pcicore *extpci_core;
508 -static u32 ssb_pcicore_pcibus_iobase = 0x100;
509 -static u32 ssb_pcicore_pcibus_membase = SSB_PCI_DMA;
511 -int pcibios_plat_dev_init(struct pci_dev *d)
513 - struct resource *res;
517 - ssb_printk(KERN_INFO "PCI: Fixing up device %s\n",
520 - /* Fix up resource bases */
521 - for (pos = 0; pos < 6; pos++) {
522 - res = &d->resource[pos];
523 - if (res->flags & IORESOURCE_IO)
524 - base = &ssb_pcicore_pcibus_iobase;
526 - base = &ssb_pcicore_pcibus_membase;
527 - res->flags |= IORESOURCE_PCI_FIXED;
529 - size = res->end - res->start + 1;
530 - if (*base & (size - 1))
531 - *base = (*base + size) & ~(size - 1);
532 - res->start = *base;
533 - res->end = res->start + size - 1;
535 - pci_write_config_dword(d, PCI_BASE_ADDRESS_0 + (pos << 2), res->start);
537 - /* Fix up PCI bridge BAR0 only */
538 - if (d->bus->number == 0 && PCI_SLOT(d->devfn) == 0)
541 - /* Fix up interrupt lines */
542 - d->irq = ssb_mips_irq(extpci_core->dev) + 2;
543 - pci_write_config_byte(d, PCI_INTERRUPT_LINE, d->irq);
548 -static void __init ssb_fixup_pcibridge(struct pci_dev *dev)
552 - if (dev->bus->number != 0 || PCI_SLOT(dev->devfn) != 0)
555 - ssb_printk(KERN_INFO "PCI: Fixing up bridge %s\n", pci_name(dev));
557 - /* Enable PCI bridge bus mastering and memory space */
558 - pci_set_master(dev);
559 - pcibios_enable_device(dev, ~0);
561 - /* Enable PCI bridge BAR1 prefetch and burst */
562 - pci_write_config_dword(dev, SSB_BAR1_CONTROL, 3);
564 - /* Make sure our latency is high enough to handle the devices behind us */
566 - ssb_printk(KERN_INFO "PCI: Fixing latency timer of device %s to %u\n",
567 - pci_name(dev), lat);
568 - pci_write_config_byte(dev, PCI_LATENCY_TIMER, lat);
570 -DECLARE_PCI_FIXUP_EARLY(PCI_ANY_ID, PCI_ANY_ID, ssb_fixup_pcibridge);
572 -int __init pcibios_map_irq(const struct pci_dev *dev, u8 slot, u8 pin)
574 - return ssb_mips_irq(extpci_core->dev) + 2;
577 static u32 get_cfgspace_addr(struct ssb_pcicore *pc,
578 unsigned int bus, unsigned int dev,
579 @@ -317,6 +249,92 @@ static struct pci_controller ssb_pcicore
580 .mem_offset = 0x24000000,
583 +static u32 ssb_pcicore_pcibus_iobase = 0x100;
584 +static u32 ssb_pcicore_pcibus_membase = SSB_PCI_DMA;
586 +/* This function is called when doing a pci_enable_device().
587 + * We must first check if the device is a device on the PCI-core bridge. */
588 +int ssb_pcicore_plat_dev_init(struct pci_dev *d)
590 + struct resource *res;
594 + if (d->bus->ops != &ssb_pcicore_pciops) {
595 + /* This is not a device on the PCI-core bridge. */
599 + ssb_printk(KERN_INFO "PCI: Fixing up device %s\n",
602 + /* Fix up resource bases */
603 + for (pos = 0; pos < 6; pos++) {
604 + res = &d->resource[pos];
605 + if (res->flags & IORESOURCE_IO)
606 + base = &ssb_pcicore_pcibus_iobase;
608 + base = &ssb_pcicore_pcibus_membase;
609 + res->flags |= IORESOURCE_PCI_FIXED;
611 + size = res->end - res->start + 1;
612 + if (*base & (size - 1))
613 + *base = (*base + size) & ~(size - 1);
614 + res->start = *base;
615 + res->end = res->start + size - 1;
617 + pci_write_config_dword(d, PCI_BASE_ADDRESS_0 + (pos << 2), res->start);
619 + /* Fix up PCI bridge BAR0 only */
620 + if (d->bus->number == 0 && PCI_SLOT(d->devfn) == 0)
623 + /* Fix up interrupt lines */
624 + d->irq = ssb_mips_irq(extpci_core->dev) + 2;
625 + pci_write_config_byte(d, PCI_INTERRUPT_LINE, d->irq);
630 +/* Early PCI fixup for a device on the PCI-core bridge. */
631 +static void ssb_pcicore_fixup_pcibridge(struct pci_dev *dev)
635 + if (dev->bus->ops != &ssb_pcicore_pciops) {
636 + /* This is not a device on the PCI-core bridge. */
639 + if (dev->bus->number != 0 || PCI_SLOT(dev->devfn) != 0)
642 + ssb_printk(KERN_INFO "PCI: Fixing up bridge %s\n", pci_name(dev));
644 + /* Enable PCI bridge bus mastering and memory space */
645 + pci_set_master(dev);
646 + pcibios_enable_device(dev, ~0);
648 + /* Enable PCI bridge BAR1 prefetch and burst */
649 + pci_write_config_dword(dev, SSB_BAR1_CONTROL, 3);
651 + /* Make sure our latency is high enough to handle the devices behind us */
653 + ssb_printk(KERN_INFO "PCI: Fixing latency timer of device %s to %u\n",
654 + pci_name(dev), lat);
655 + pci_write_config_byte(dev, PCI_LATENCY_TIMER, lat);
657 +DECLARE_PCI_FIXUP_EARLY(PCI_ANY_ID, PCI_ANY_ID, ssb_pcicore_fixup_pcibridge);
659 +/* PCI device IRQ mapping. */
660 +int ssb_pcicore_pcibios_map_irq(const struct pci_dev *dev, u8 slot, u8 pin)
662 + if (dev->bus->ops != &ssb_pcicore_pciops) {
663 + /* This is not a device on the PCI-core bridge. */
666 + return ssb_mips_irq(extpci_core->dev) + 2;
669 static void ssb_pcicore_init_hostmode(struct ssb_pcicore *pc)
672 Index: linux-2.6.23.16/drivers/ssb/embedded.c
673 ===================================================================
674 --- linux-2.6.23.16.orig/drivers/ssb/embedded.c 2008-02-22 19:40:57.000000000 +0100
675 +++ linux-2.6.23.16/drivers/ssb/embedded.c 2008-02-22 19:42:52.000000000 +0100
678 #include <linux/ssb/ssb.h>
679 #include <linux/ssb/ssb_embedded.h>
680 +#include <linux/ssb/ssb_driver_pci.h>
681 +#include <linux/ssb/ssb_driver_gige.h>
682 +#include <linux/pci.h>
684 #include "ssb_private.h"
686 @@ -130,3 +133,90 @@ u32 ssb_gpio_polarity(struct ssb_bus *bu
689 EXPORT_SYMBOL(ssb_gpio_polarity);
691 +#ifdef CONFIG_SSB_DRIVER_GIGE
692 +static int gige_pci_init_callback(struct ssb_bus *bus, unsigned long data)
694 + struct pci_dev *pdev = (struct pci_dev *)data;
695 + struct ssb_device *dev;
699 + for (i = 0; i < bus->nr_devices; i++) {
700 + dev = &(bus->devices[i]);
701 + if (dev->id.coreid != SSB_DEV_ETHERNET_GBIT)
704 + !dev->dev->driver ||
705 + !device_is_registered(dev->dev))
707 + res = ssb_gige_pcibios_plat_dev_init(dev, pdev);
714 +#endif /* CONFIG_SSB_DRIVER_GIGE */
716 +int ssb_pcibios_plat_dev_init(struct pci_dev *dev)
720 + err = ssb_pcicore_plat_dev_init(dev);
723 +#ifdef CONFIG_SSB_DRIVER_GIGE
724 + err = ssb_for_each_bus_call((unsigned long)dev, gige_pci_init_callback);
728 + /* This is not a PCI device on any SSB device. */
733 +#ifdef CONFIG_SSB_DRIVER_GIGE
734 +static int gige_map_irq_callback(struct ssb_bus *bus, unsigned long data)
736 + const struct pci_dev *pdev = (const struct pci_dev *)data;
737 + struct ssb_device *dev;
741 + for (i = 0; i < bus->nr_devices; i++) {
742 + dev = &(bus->devices[i]);
743 + if (dev->id.coreid != SSB_DEV_ETHERNET_GBIT)
746 + !dev->dev->driver ||
747 + !device_is_registered(dev->dev))
749 + res = ssb_gige_map_irq(dev, pdev);
756 +#endif /* CONFIG_SSB_DRIVER_GIGE */
758 +int ssb_pcibios_map_irq(const struct pci_dev *dev, u8 slot, u8 pin)
762 + /* Check if this PCI device is a device on a SSB bus or device
763 + * and return the IRQ number for it. */
765 + res = ssb_pcicore_pcibios_map_irq(dev, slot, pin);
768 +#ifdef CONFIG_SSB_DRIVER_GIGE
769 + res = ssb_for_each_bus_call((unsigned long)dev, gige_map_irq_callback);
773 + /* This is not a PCI device on any SSB device. */
777 Index: linux-2.6.23.16/include/linux/ssb/ssb.h
778 ===================================================================
779 --- linux-2.6.23.16.orig/include/linux/ssb/ssb.h 2008-02-22 19:40:57.000000000 +0100
780 +++ linux-2.6.23.16/include/linux/ssb/ssb.h 2008-02-22 19:42:52.000000000 +0100
781 @@ -422,5 +422,12 @@ extern int ssb_bus_powerup(struct ssb_bu
782 extern u32 ssb_admatch_base(u32 adm);
783 extern u32 ssb_admatch_size(u32 adm);
785 +/* PCI device mapping and fixup routines.
786 + * Called from the architecture pcibios init code.
787 + * These are only available on SSB_EMBEDDED configurations. */
788 +#ifdef CONFIG_SSB_EMBEDDED
789 +int ssb_pcibios_plat_dev_init(struct pci_dev *dev);
790 +int ssb_pcibios_map_irq(const struct pci_dev *dev, u8 slot, u8 pin);
791 +#endif /* CONFIG_SSB_EMBEDDED */
793 #endif /* LINUX_SSB_H_ */
794 Index: linux-2.6.23.16/include/linux/ssb/ssb_driver_pci.h
795 ===================================================================
796 --- linux-2.6.23.16.orig/include/linux/ssb/ssb_driver_pci.h 2008-02-22 19:40:57.000000000 +0100
797 +++ linux-2.6.23.16/include/linux/ssb/ssb_driver_pci.h 2008-02-22 19:42:52.000000000 +0100
799 #ifndef LINUX_SSB_PCICORE_H_
800 #define LINUX_SSB_PCICORE_H_
802 +#include <linux/types.h>
807 #ifdef CONFIG_SSB_DRIVER_PCICORE
809 /* PCI core registers. */
810 @@ -88,6 +93,9 @@ extern void ssb_pcicore_init(struct ssb_
811 extern int ssb_pcicore_dev_irqvecs_enable(struct ssb_pcicore *pc,
812 struct ssb_device *dev);
814 +int ssb_pcicore_plat_dev_init(struct pci_dev *d);
815 +int ssb_pcicore_pcibios_map_irq(const struct pci_dev *dev, u8 slot, u8 pin);
818 #else /* CONFIG_SSB_DRIVER_PCICORE */
820 @@ -107,5 +115,16 @@ int ssb_pcicore_dev_irqvecs_enable(struc
825 +int ssb_pcicore_plat_dev_init(struct pci_dev *d)
830 +int ssb_pcicore_pcibios_map_irq(const struct pci_dev *dev, u8 slot, u8 pin)
835 #endif /* CONFIG_SSB_DRIVER_PCICORE */
836 #endif /* LINUX_SSB_PCICORE_H_ */
837 Index: linux-2.6.23.16/drivers/ssb/main.c
838 ===================================================================
839 --- linux-2.6.23.16.orig/drivers/ssb/main.c 2008-02-22 19:40:57.000000000 +0100
840 +++ linux-2.6.23.16/drivers/ssb/main.c 2008-02-22 19:42:52.000000000 +0100
842 #include <linux/io.h>
843 #include <linux/ssb/ssb.h>
844 #include <linux/ssb/ssb_regs.h>
845 +#include <linux/ssb/ssb_driver_gige.h>
846 #include <linux/dma-mapping.h>
847 #include <linux/pci.h>
849 @@ -68,6 +69,25 @@ found:
851 #endif /* CONFIG_SSB_PCIHOST */
853 +int ssb_for_each_bus_call(unsigned long data,
854 + int (*func)(struct ssb_bus *bus, unsigned long data))
856 + struct ssb_bus *bus;
860 + list_for_each_entry(bus, &buses, list) {
861 + res = func(bus, data);
863 + ssb_buses_unlock();
867 + ssb_buses_unlock();
872 static struct ssb_device *ssb_device_get(struct ssb_device *dev)
875 @@ -1175,7 +1195,14 @@ static int __init ssb_modinit(void)
876 err = b43_pci_ssb_bridge_init();
878 ssb_printk(KERN_ERR "Broadcom 43xx PCI-SSB-bridge "
879 - "initialization failed");
880 + "initialization failed\n");
881 + /* don't fail SSB init because of this */
884 + err = ssb_gige_init();
886 + ssb_printk(KERN_ERR "SSB Broadcom Gigabit Ethernet "
887 + "driver initialization failed\n");
888 /* don't fail SSB init because of this */
891 @@ -1189,6 +1216,7 @@ fs_initcall(ssb_modinit);
893 static void __exit ssb_modexit(void)
896 b43_pci_ssb_bridge_exit();
897 bus_unregister(&ssb_bustype);
899 Index: linux-2.6.23.16/drivers/ssb/ssb_private.h
900 ===================================================================
901 --- linux-2.6.23.16.orig/drivers/ssb/ssb_private.h 2008-02-22 19:40:57.000000000 +0100
902 +++ linux-2.6.23.16/drivers/ssb/ssb_private.h 2008-02-22 19:42:52.000000000 +0100
903 @@ -118,6 +118,8 @@ extern u32 ssb_calc_clock_rate(u32 pllty
904 extern int ssb_devices_freeze(struct ssb_bus *bus);
905 extern int ssb_devices_thaw(struct ssb_bus *bus);
906 extern struct ssb_bus *ssb_pci_dev_to_bus(struct pci_dev *pdev);
907 +int ssb_for_each_bus_call(unsigned long data,
908 + int (*func)(struct ssb_bus *bus, unsigned long data));
910 /* b43_pci_bridge.c */
911 #ifdef CONFIG_SSB_PCIHOST
912 Index: linux-2.6.23.16/drivers/net/tg3.c
913 ===================================================================
914 --- linux-2.6.23.16.orig/drivers/net/tg3.c 2008-02-22 19:40:57.000000000 +0100
915 +++ linux-2.6.23.16/drivers/net/tg3.c 2008-02-27 23:18:31.000000000 +0100
917 #include <linux/workqueue.h>
918 #include <linux/prefetch.h>
919 #include <linux/dma-mapping.h>
920 +#include <linux/ssb/ssb_driver_gige.h>
922 #include <net/checksum.h>
924 @@ -410,8 +411,9 @@ static void _tw32_flush(struct tg3 *tp,
925 static inline void tw32_mailbox_flush(struct tg3 *tp, u32 off, u32 val)
927 tp->write32_mbox(tp, off, val);
928 - if (!(tp->tg3_flags & TG3_FLAG_MBOX_WRITE_REORDER) &&
929 - !(tp->tg3_flags2 & TG3_FLG2_ICH_WORKAROUND))
930 + if ((tp->tg3_flags3 & TG3_FLG3_FLUSH_POSTED_WRITES) ||
931 + (!(tp->tg3_flags & TG3_FLAG_MBOX_WRITE_REORDER) &&
932 + !(tp->tg3_flags2 & TG3_FLG2_ICH_WORKAROUND)))
933 tp->read32_mbox(tp, off);
936 @@ -623,7 +625,7 @@ static void tg3_switch_clocks(struct tg3
938 #define PHY_BUSY_LOOPS 5000
940 -static int tg3_readphy(struct tg3 *tp, int reg, u32 *val)
941 +static int __tg3_readphy(struct tg3 *tp, unsigned int phy_addr, int reg, u32 *val)
945 @@ -637,7 +639,7 @@ static int tg3_readphy(struct tg3 *tp, i
949 - frame_val = ((PHY_ADDR << MI_COM_PHY_ADDR_SHIFT) &
950 + frame_val = ((phy_addr << MI_COM_PHY_ADDR_SHIFT) &
951 MI_COM_PHY_ADDR_MASK);
952 frame_val |= ((reg << MI_COM_REG_ADDR_SHIFT) &
953 MI_COM_REG_ADDR_MASK);
954 @@ -672,7 +674,12 @@ static int tg3_readphy(struct tg3 *tp, i
958 -static int tg3_writephy(struct tg3 *tp, int reg, u32 val)
959 +static int tg3_readphy(struct tg3 *tp, int reg, u32 *val)
961 + return __tg3_readphy(tp, PHY_ADDR, reg, val);
964 +static int __tg3_writephy(struct tg3 *tp, unsigned int phy_addr, int reg, u32 val)
968 @@ -688,7 +695,7 @@ static int tg3_writephy(struct tg3 *tp,
972 - frame_val = ((PHY_ADDR << MI_COM_PHY_ADDR_SHIFT) &
973 + frame_val = ((phy_addr << MI_COM_PHY_ADDR_SHIFT) &
974 MI_COM_PHY_ADDR_MASK);
975 frame_val |= ((reg << MI_COM_REG_ADDR_SHIFT) &
976 MI_COM_REG_ADDR_MASK);
977 @@ -721,6 +728,11 @@ static int tg3_writephy(struct tg3 *tp,
981 +static int tg3_writephy(struct tg3 *tp, int reg, u32 val)
983 + return __tg3_writephy(tp, PHY_ADDR, reg, val);
986 static void tg3_phy_toggle_automdix(struct tg3 *tp, int enable)
989 @@ -1988,6 +2000,14 @@ static int tg3_setup_copper_phy(struct t
990 tp->link_config.active_duplex = current_duplex;
993 + if (tp->tg3_flags3 & TG3_FLG3_ROBOSWITCH) {
994 + current_link_up = 1;
995 + current_speed = SPEED_1000; //FIXME
996 + current_duplex = DUPLEX_FULL;
997 + tp->link_config.active_speed = current_speed;
998 + tp->link_config.active_duplex = current_duplex;
1001 if (current_link_up == 1 &&
1002 (tp->link_config.active_duplex == DUPLEX_FULL) &&
1003 (tp->link_config.autoneg == AUTONEG_ENABLE)) {
1004 @@ -4813,6 +4833,11 @@ static int tg3_poll_fw(struct tg3 *tp)
1008 + if (tp->tg3_flags3 & TG3_FLG3_IS_SSB_CORE) {
1009 + /* We don't use firmware. */
1013 if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5906) {
1014 /* Wait up to 20ms for init done. */
1015 for (i = 0; i < 200; i++) {
1016 @@ -5040,6 +5065,14 @@ static int tg3_chip_reset(struct tg3 *tp
1017 tw32(0x5000, 0x400);
1020 + if (tp->tg3_flags3 & TG3_FLG3_IS_SSB_CORE) {
1021 + /* BCM4785: In order to avoid repercussions from using potentially
1022 + * defective internal ROM, stop the Rx RISC CPU, which is not
1025 + tg3_halt_cpu(tp, RX_CPU_BASE);
1028 tw32(GRC_MODE, tp->grc_mode);
1030 if (tp->pci_chip_rev_id == CHIPREV_ID_5705_A0) {
1031 @@ -5308,9 +5341,12 @@ static int tg3_halt_cpu(struct tg3 *tp,
1035 - /* Clear firmware's nvram arbitration. */
1036 - if (tp->tg3_flags & TG3_FLAG_NVRAM)
1037 - tw32(NVRAM_SWARB, SWARB_REQ_CLR0);
1038 + if (!(tp->tg3_flags3 & TG3_FLG3_IS_SSB_CORE)) {
1039 + /* Clear firmware's nvram arbitration. */
1040 + if (tp->tg3_flags & TG3_FLAG_NVRAM)
1041 + tw32(NVRAM_SWARB, SWARB_REQ_CLR0);
1047 @@ -5391,6 +5427,11 @@ static int tg3_load_5701_a0_firmware_fix
1048 struct fw_info info;
1051 + if (tp->tg3_flags3 & TG3_FLG3_IS_SSB_CORE) {
1052 + /* We don't use firmware. */
1056 info.text_base = TG3_FW_TEXT_ADDR;
1057 info.text_len = TG3_FW_TEXT_LEN;
1058 info.text_data = &tg3FwText[0];
1059 @@ -5949,6 +5990,11 @@ static int tg3_load_tso_firmware(struct
1060 unsigned long cpu_base, cpu_scratch_base, cpu_scratch_size;
1063 + if (tp->tg3_flags3 & TG3_FLG3_IS_SSB_CORE) {
1064 + /* We don't use firmware. */
1068 if (tp->tg3_flags2 & TG3_FLG2_HW_TSO)
1071 @@ -6850,6 +6896,11 @@ static void tg3_timer(unsigned long __op
1073 spin_lock(&tp->lock);
1075 + if (tp->tg3_flags3 & TG3_FLG3_FLUSH_POSTED_WRITES) {
1076 + /* BCM4785: Flush posted writes from GbE to host memory. */
1077 + tr32(HOSTCC_MODE);
1080 if (!(tp->tg3_flags & TG3_FLAG_TAGGED_STATUS)) {
1081 /* All of this garbage is because when using non-tagged
1082 * IRQ status the mailbox/status_block protocol the chip
1083 @@ -8432,6 +8483,11 @@ static int tg3_test_nvram(struct tg3 *tp
1084 u32 *buf, csum, magic;
1085 int i, j, err = 0, size;
1087 + if (tp->tg3_flags3 & TG3_FLG3_IS_SSB_CORE) {
1088 + /* We don't have NVRAM. */
1092 if (tg3_nvram_read_swab(tp, 0, &magic) != 0)
1095 @@ -9154,7 +9210,7 @@ static int tg3_ioctl(struct net_device *
1098 spin_lock_bh(&tp->lock);
1099 - err = tg3_readphy(tp, data->reg_num & 0x1f, &mii_regval);
1100 + err = __tg3_readphy(tp, data->phy_id & 0x1f, data->reg_num & 0x1f, &mii_regval);
1101 spin_unlock_bh(&tp->lock);
1103 data->val_out = mii_regval;
1104 @@ -9173,7 +9229,7 @@ static int tg3_ioctl(struct net_device *
1107 spin_lock_bh(&tp->lock);
1108 - err = tg3_writephy(tp, data->reg_num & 0x1f, data->val_in);
1109 + err = __tg3_writephy(tp, data->phy_id & 0x1f, data->reg_num & 0x1f, data->val_in);
1110 spin_unlock_bh(&tp->lock);
1113 @@ -9571,6 +9627,12 @@ static void __devinit tg3_get_5906_nvram
1114 /* Chips other than 5700/5701 use the NVRAM for fetching info. */
1115 static void __devinit tg3_nvram_init(struct tg3 *tp)
1117 + if (tp->tg3_flags3 & TG3_FLG3_IS_SSB_CORE) {
1118 + /* No NVRAM and EEPROM on the SSB Broadcom GigE core. */
1119 + tp->tg3_flags &= ~(TG3_FLAG_NVRAM | TG3_FLAG_NVRAM_BUFFERED);
1123 tw32_f(GRC_EEPROM_ADDR,
1124 (EEPROM_ADDR_FSM_RESET |
1125 (EEPROM_DEFAULT_CLOCK_PERIOD <<
1126 @@ -9706,6 +9768,9 @@ static int tg3_nvram_read(struct tg3 *tp
1130 + if (tp->tg3_flags3 & TG3_FLG3_IS_SSB_CORE)
1133 if (!(tp->tg3_flags & TG3_FLAG_NVRAM))
1134 return tg3_nvram_read_using_eeprom(tp, offset, val);
1136 @@ -9938,6 +10003,9 @@ static int tg3_nvram_write_block(struct
1140 + if (tp->tg3_flags3 & TG3_FLG3_IS_SSB_CORE)
1143 if (tp->tg3_flags & TG3_FLAG_EEPROM_WRITE_PROT) {
1144 tw32_f(GRC_LOCAL_CTRL, tp->grc_local_ctrl &
1145 ~GRC_LCLCTRL_GPIO_OUTPUT1);
1146 @@ -10804,7 +10872,6 @@ static int __devinit tg3_get_invariants(
1147 tp->write32 = tg3_write_flush_reg32;
1151 if ((tp->tg3_flags & TG3_FLAG_TXD_MBOX_HWBUG) ||
1152 (tp->tg3_flags & TG3_FLAG_MBOX_WRITE_REORDER)) {
1153 tp->write32_tx_mbox = tg3_write32_tx_mbox;
1154 @@ -10840,6 +10907,11 @@ static int __devinit tg3_get_invariants(
1155 GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5701)))
1156 tp->tg3_flags |= TG3_FLAG_SRAM_USE_CONFIG;
1158 + if (tp->tg3_flags3 & TG3_FLG3_FLUSH_POSTED_WRITES) {
1159 + tp->write32_tx_mbox = tg3_write_flush_reg32;
1160 + tp->write32_rx_mbox = tg3_write_flush_reg32;
1163 /* Get eeprom hw config before calling tg3_set_power_state().
1164 * In particular, the TG3_FLG2_IS_NIC flag must be
1165 * determined before calling tg3_set_power_state() so that
1166 @@ -11184,6 +11256,10 @@ static int __devinit tg3_get_device_addr
1169 if (!is_valid_ether_addr(&dev->dev_addr[0])) {
1170 + if (tp->tg3_flags3 & TG3_FLG3_IS_SSB_CORE)
1171 + ssb_gige_get_macaddr(tp->pdev, &dev->dev_addr[0]);
1173 + if (!is_valid_ether_addr(&dev->dev_addr[0])) {
1174 #ifdef CONFIG_SPARC64
1175 if (!tg3_get_default_macaddr_sparc(tp))
1177 @@ -11675,6 +11751,7 @@ static char * __devinit tg3_phy_string(s
1178 case PHY_ID_BCM5704: return "5704";
1179 case PHY_ID_BCM5705: return "5705";
1180 case PHY_ID_BCM5750: return "5750";
1181 + case PHY_ID_BCM5750_2: return "5750-2";
1182 case PHY_ID_BCM5752: return "5752";
1183 case PHY_ID_BCM5714: return "5714";
1184 case PHY_ID_BCM5780: return "5780";
1185 @@ -11859,6 +11936,13 @@ static int __devinit tg3_init_one(struct
1186 tp->msg_enable = tg3_debug;
1188 tp->msg_enable = TG3_DEF_MSG_ENABLE;
1189 + if (pdev_is_ssb_gige_core(pdev)) {
1190 + tp->tg3_flags3 |= TG3_FLG3_IS_SSB_CORE;
1191 + if (ssb_gige_must_flush_posted_writes(pdev))
1192 + tp->tg3_flags3 |= TG3_FLG3_FLUSH_POSTED_WRITES;
1193 + if (ssb_gige_have_roboswitch(pdev))
1194 + tp->tg3_flags3 |= TG3_FLG3_ROBOSWITCH;
1197 /* The word/byte swap controls here control register access byte
1198 * swapping. DMA data byte swapping is controlled in the GRC_MODE
1199 Index: linux-2.6.23.16/drivers/net/tg3.h
1200 ===================================================================
1201 --- linux-2.6.23.16.orig/drivers/net/tg3.h 2008-02-22 19:40:57.000000000 +0100
1202 +++ linux-2.6.23.16/drivers/net/tg3.h 2008-02-23 20:56:08.000000000 +0100
1203 @@ -2279,6 +2279,10 @@ struct tg3 {
1204 #define TG3_FLG2_PHY_JITTER_BUG 0x20000000
1205 #define TG3_FLG2_NO_FWARE_REPORTED 0x40000000
1206 #define TG3_FLG2_PHY_ADJUST_TRIM 0x80000000
1208 +#define TG3_FLG3_IS_SSB_CORE 0x00000001
1209 +#define TG3_FLG3_FLUSH_POSTED_WRITES 0x00000002
1210 +#define TG3_FLG3_ROBOSWITCH 0x00000004
1212 struct timer_list timer;
1214 @@ -2333,6 +2337,7 @@ struct tg3 {
1215 #define PHY_ID_BCM5714 0x60008340
1216 #define PHY_ID_BCM5780 0x60008350
1217 #define PHY_ID_BCM5755 0xbc050cc0
1218 +#define PHY_ID_BCM5750_2 0xbc050cd0
1219 #define PHY_ID_BCM5787 0xbc050ce0
1220 #define PHY_ID_BCM5756 0xbc050ed0
1221 #define PHY_ID_BCM5906 0xdc00ac40
1222 @@ -2364,7 +2369,8 @@ struct tg3 {
1223 (X) == PHY_ID_BCM5752 || (X) == PHY_ID_BCM5714 || \
1224 (X) == PHY_ID_BCM5780 || (X) == PHY_ID_BCM5787 || \
1225 (X) == PHY_ID_BCM5755 || (X) == PHY_ID_BCM5756 || \
1226 - (X) == PHY_ID_BCM5906 || (X) == PHY_ID_BCM8002)
1227 + (X) == PHY_ID_BCM5906 || (X) == PHY_ID_BCM8002 || \
1228 + (X) == PHY_ID_BCM5750_2)
1230 struct tg3_hw_stats *hw_stats;
1231 dma_addr_t stats_mapping;