1 --- a/drivers/ssb/Kconfig
2 +++ b/drivers/ssb/Kconfig
7 +config SSB_DRIVER_GIGE
8 + bool "SSB Broadcom Gigabit Ethernet driver"
9 + depends on SSB_PCIHOST_POSSIBLE && SSB_EMBEDDED && MIPS
11 + Driver for the Sonics Silicon Backplane attached
12 + Broadcom Gigabit Ethernet.
17 --- a/drivers/ssb/Makefile
18 +++ b/drivers/ssb/Makefile
20 ssb-$(CONFIG_SSB_DRIVER_MIPS) += driver_mipscore.o
21 ssb-$(CONFIG_SSB_DRIVER_EXTIF) += driver_extif.o
22 ssb-$(CONFIG_SSB_DRIVER_PCICORE) += driver_pcicore.o
23 +ssb-$(CONFIG_SSB_DRIVER_GIGE) += driver_gige.o
25 # b43 pci-ssb-bridge driver
26 # Not strictly a part of SSB, but kept here for convenience
28 +++ b/drivers/ssb/driver_gige.c
31 + * Sonics Silicon Backplane
32 + * Broadcom Gigabit Ethernet core driver
34 + * Copyright 2008, Broadcom Corporation
35 + * Copyright 2008, Michael Buesch <mb@bu3sch.de>
37 + * Licensed under the GNU/GPL. See COPYING for details.
40 +#include <linux/ssb/ssb.h>
41 +#include <linux/ssb/ssb_driver_gige.h>
42 +#include <linux/pci.h>
43 +#include <linux/pci_regs.h>
47 +MODULE_DESCRIPTION("SSB Broadcom Gigabit Ethernet driver");
48 +MODULE_AUTHOR("Michael Buesch");
49 +MODULE_LICENSE("GPL");
52 +static const struct ssb_device_id ssb_gige_tbl[] = {
53 + SSB_DEVICE(SSB_VENDOR_BROADCOM, SSB_DEV_ETHERNET_GBIT, SSB_ANY_REV),
56 +/* MODULE_DEVICE_TABLE(ssb, ssb_gige_tbl); */
59 +static inline u8 gige_read8(struct ssb_gige *dev, u16 offset)
61 + return ssb_read8(dev->dev, offset);
64 +static inline u16 gige_read16(struct ssb_gige *dev, u16 offset)
66 + return ssb_read16(dev->dev, offset);
69 +static inline u32 gige_read32(struct ssb_gige *dev, u16 offset)
71 + return ssb_read32(dev->dev, offset);
74 +static inline void gige_write8(struct ssb_gige *dev,
75 + u16 offset, u8 value)
77 + ssb_write8(dev->dev, offset, value);
80 +static inline void gige_write16(struct ssb_gige *dev,
81 + u16 offset, u16 value)
83 + ssb_write16(dev->dev, offset, value);
86 +static inline void gige_write32(struct ssb_gige *dev,
87 + u16 offset, u32 value)
89 + ssb_write32(dev->dev, offset, value);
93 +u8 gige_pcicfg_read8(struct ssb_gige *dev, unsigned int offset)
95 + BUG_ON(offset >= 256);
96 + return gige_read8(dev, SSB_GIGE_PCICFG + offset);
100 +u16 gige_pcicfg_read16(struct ssb_gige *dev, unsigned int offset)
102 + BUG_ON(offset >= 256);
103 + return gige_read16(dev, SSB_GIGE_PCICFG + offset);
107 +u32 gige_pcicfg_read32(struct ssb_gige *dev, unsigned int offset)
109 + BUG_ON(offset >= 256);
110 + return gige_read32(dev, SSB_GIGE_PCICFG + offset);
114 +void gige_pcicfg_write8(struct ssb_gige *dev,
115 + unsigned int offset, u8 value)
117 + BUG_ON(offset >= 256);
118 + gige_write8(dev, SSB_GIGE_PCICFG + offset, value);
122 +void gige_pcicfg_write16(struct ssb_gige *dev,
123 + unsigned int offset, u16 value)
125 + BUG_ON(offset >= 256);
126 + gige_write16(dev, SSB_GIGE_PCICFG + offset, value);
130 +void gige_pcicfg_write32(struct ssb_gige *dev,
131 + unsigned int offset, u32 value)
133 + BUG_ON(offset >= 256);
134 + gige_write32(dev, SSB_GIGE_PCICFG + offset, value);
137 +static int ssb_gige_pci_read_config(struct pci_bus *bus, unsigned int devfn,
138 + int reg, int size, u32 *val)
140 + struct ssb_gige *dev = container_of(bus->ops, struct ssb_gige, pci_ops);
141 + unsigned long flags;
143 + if ((PCI_SLOT(devfn) > 0) || (PCI_FUNC(devfn) > 0))
144 + return PCIBIOS_DEVICE_NOT_FOUND;
146 + return PCIBIOS_DEVICE_NOT_FOUND;
148 + spin_lock_irqsave(&dev->lock, flags);
151 + *val = gige_pcicfg_read8(dev, reg);
154 + *val = gige_pcicfg_read16(dev, reg);
157 + *val = gige_pcicfg_read32(dev, reg);
162 + spin_unlock_irqrestore(&dev->lock, flags);
164 + return PCIBIOS_SUCCESSFUL;
167 +static int ssb_gige_pci_write_config(struct pci_bus *bus, unsigned int devfn,
168 + int reg, int size, u32 val)
170 + struct ssb_gige *dev = container_of(bus->ops, struct ssb_gige, pci_ops);
171 + unsigned long flags;
173 + if ((PCI_SLOT(devfn) > 0) || (PCI_FUNC(devfn) > 0))
174 + return PCIBIOS_DEVICE_NOT_FOUND;
176 + return PCIBIOS_DEVICE_NOT_FOUND;
178 + spin_lock_irqsave(&dev->lock, flags);
181 + gige_pcicfg_write8(dev, reg, val);
184 + gige_pcicfg_write16(dev, reg, val);
187 + gige_pcicfg_write32(dev, reg, val);
192 + spin_unlock_irqrestore(&dev->lock, flags);
194 + return PCIBIOS_SUCCESSFUL;
197 +static int ssb_gige_probe(struct ssb_device *sdev, const struct ssb_device_id *id)
199 + struct ssb_gige *dev;
200 + u32 base, tmslow, tmshigh;
202 + dev = kzalloc(sizeof(*dev), GFP_KERNEL);
207 + spin_lock_init(&dev->lock);
208 + dev->pci_controller.pci_ops = &dev->pci_ops;
209 + dev->pci_controller.io_resource = &dev->io_resource;
210 + dev->pci_controller.mem_resource = &dev->mem_resource;
211 + dev->pci_controller.io_map_base = 0x800;
212 + dev->pci_ops.read = ssb_gige_pci_read_config;
213 + dev->pci_ops.write = ssb_gige_pci_write_config;
215 + dev->io_resource.name = SSB_GIGE_IO_RES_NAME;
216 + dev->io_resource.start = 0x800;
217 + dev->io_resource.end = 0x8FF;
218 + dev->io_resource.flags = IORESOURCE_IO | IORESOURCE_PCI_FIXED;
220 + if (!ssb_device_is_enabled(sdev))
221 + ssb_device_enable(sdev, 0);
223 + /* Setup BAR0. This is a 64k MMIO region. */
224 + base = ssb_admatch_base(ssb_read32(sdev, SSB_ADMATCH1));
225 + gige_pcicfg_write32(dev, PCI_BASE_ADDRESS_0, base);
226 + gige_pcicfg_write32(dev, PCI_BASE_ADDRESS_1, 0);
228 + dev->mem_resource.name = SSB_GIGE_MEM_RES_NAME;
229 + dev->mem_resource.start = base;
230 + dev->mem_resource.end = base + 0x10000 - 1;
231 + dev->mem_resource.flags = IORESOURCE_MEM | IORESOURCE_PCI_FIXED;
233 + /* Enable the memory region. */
234 + gige_pcicfg_write16(dev, PCI_COMMAND,
235 + gige_pcicfg_read16(dev, PCI_COMMAND)
236 + | PCI_COMMAND_MEMORY);
238 + /* Write flushing is controlled by the Flush Status Control register.
239 + * We want to flush every register write with a timeout and we want
240 + * to disable the IRQ mask while flushing to avoid concurrency.
241 + * Note that automatic write flushing does _not_ work from
242 + * an IRQ handler. The driver must flush manually by reading a register.
244 + gige_write32(dev, SSB_GIGE_SHIM_FLUSHSTAT, 0x00000068);
246 + /* Check if we have an RGMII or GMII PHY-bus.
247 + * On RGMII do not bypass the DLLs */
248 + tmslow = ssb_read32(sdev, SSB_TMSLOW);
249 + tmshigh = ssb_read32(sdev, SSB_TMSHIGH);
250 + if (tmshigh & SSB_GIGE_TMSHIGH_RGMII) {
251 + tmslow &= ~SSB_GIGE_TMSLOW_TXBYPASS;
252 + tmslow &= ~SSB_GIGE_TMSLOW_RXBYPASS;
253 + dev->has_rgmii = 1;
255 + tmslow |= SSB_GIGE_TMSLOW_TXBYPASS;
256 + tmslow |= SSB_GIGE_TMSLOW_RXBYPASS;
257 + dev->has_rgmii = 0;
259 + tmslow |= SSB_GIGE_TMSLOW_DLLEN;
260 + ssb_write32(sdev, SSB_TMSLOW, tmslow);
262 + ssb_set_drvdata(sdev, dev);
263 + register_pci_controller(&dev->pci_controller);
268 +bool pdev_is_ssb_gige_core(struct pci_dev *pdev)
270 + if (!pdev->resource[0].name)
272 + return (strcmp(pdev->resource[0].name, SSB_GIGE_MEM_RES_NAME) == 0);
274 +EXPORT_SYMBOL(pdev_is_ssb_gige_core);
276 +int ssb_gige_pcibios_plat_dev_init(struct ssb_device *sdev,
277 + struct pci_dev *pdev)
279 + struct ssb_gige *dev = ssb_get_drvdata(sdev);
280 + struct resource *res;
282 + if (pdev->bus->ops != &dev->pci_ops) {
283 + /* The PCI device is not on this SSB GigE bridge device. */
287 + /* Fixup the PCI resources. */
288 + res = &(pdev->resource[0]);
289 + res->flags = IORESOURCE_MEM | IORESOURCE_PCI_FIXED;
290 + res->name = dev->mem_resource.name;
291 + res->start = dev->mem_resource.start;
292 + res->end = dev->mem_resource.end;
294 + /* Fixup interrupt lines. */
295 + pdev->irq = ssb_mips_irq(sdev) + 2;
296 + pci_write_config_byte(pdev, PCI_INTERRUPT_LINE, pdev->irq);
301 +int ssb_gige_map_irq(struct ssb_device *sdev,
302 + const struct pci_dev *pdev)
304 + struct ssb_gige *dev = ssb_get_drvdata(sdev);
306 + if (pdev->bus->ops != &dev->pci_ops) {
307 + /* The PCI device is not on this SSB GigE bridge device. */
311 + return ssb_mips_irq(sdev) + 2;
314 +static struct ssb_driver ssb_gige_driver = {
315 + .name = "BCM-GigE",
316 + .id_table = ssb_gige_tbl,
317 + .probe = ssb_gige_probe,
320 +int ssb_gige_init(void)
322 + return ssb_driver_register(&ssb_gige_driver);
325 +++ b/include/linux/ssb/ssb_driver_gige.h
327 +#ifndef LINUX_SSB_DRIVER_GIGE_H_
328 +#define LINUX_SSB_DRIVER_GIGE_H_
330 +#include <linux/ssb/ssb.h>
331 +#include <linux/pci.h>
332 +#include <linux/spinlock.h>
335 +#ifdef CONFIG_SSB_DRIVER_GIGE
338 +#define SSB_GIGE_PCIIO 0x0000 /* PCI I/O Registers (1024 bytes) */
339 +#define SSB_GIGE_RESERVED 0x0400 /* Reserved (1024 bytes) */
340 +#define SSB_GIGE_PCICFG 0x0800 /* PCI config space (256 bytes) */
341 +#define SSB_GIGE_SHIM_FLUSHSTAT 0x0C00 /* PCI to OCP: Flush status control (32bit) */
342 +#define SSB_GIGE_SHIM_FLUSHRDA 0x0C04 /* PCI to OCP: Flush read address (32bit) */
343 +#define SSB_GIGE_SHIM_FLUSHTO 0x0C08 /* PCI to OCP: Flush timeout counter (32bit) */
344 +#define SSB_GIGE_SHIM_BARRIER 0x0C0C /* PCI to OCP: Barrier register (32bit) */
345 +#define SSB_GIGE_SHIM_MAOCPSI 0x0C10 /* PCI to OCP: MaocpSI Control (32bit) */
346 +#define SSB_GIGE_SHIM_SIOCPMA 0x0C14 /* PCI to OCP: SiocpMa Control (32bit) */
348 +/* TM Status High flags */
349 +#define SSB_GIGE_TMSHIGH_RGMII 0x00010000 /* Have an RGMII PHY-bus */
350 +/* TM Status Low flags */
351 +#define SSB_GIGE_TMSLOW_TXBYPASS 0x00080000 /* TX bypass (no delay) */
352 +#define SSB_GIGE_TMSLOW_RXBYPASS 0x00100000 /* RX bypass (no delay) */
353 +#define SSB_GIGE_TMSLOW_DLLEN 0x01000000 /* Enable DLL controls */
355 +/* Boardflags (low) */
356 +#define SSB_GIGE_BFL_ROBOSWITCH 0x0010
359 +#define SSB_GIGE_MEM_RES_NAME "SSB Broadcom 47xx GigE memory"
360 +#define SSB_GIGE_IO_RES_NAME "SSB Broadcom 47xx GigE I/O"
363 + struct ssb_device *dev;
367 + /* True, if the device has an RGMII bus.
368 + * False, if the device has a GMII bus. */
371 + /* The PCI controller device. */
372 + struct pci_controller pci_controller;
373 + struct pci_ops pci_ops;
374 + struct resource mem_resource;
375 + struct resource io_resource;
378 +/* Check whether a PCI device is a SSB Gigabit Ethernet core. */
379 +extern bool pdev_is_ssb_gige_core(struct pci_dev *pdev);
381 +/* Convert a pci_dev pointer to a ssb_gige pointer. */
382 +static inline struct ssb_gige * pdev_to_ssb_gige(struct pci_dev *pdev)
384 + if (!pdev_is_ssb_gige_core(pdev))
386 + return container_of(pdev->bus->ops, struct ssb_gige, pci_ops);
389 +/* Returns whether the PHY is connected by an RGMII bus. */
390 +static inline bool ssb_gige_is_rgmii(struct pci_dev *pdev)
392 + struct ssb_gige *dev = pdev_to_ssb_gige(pdev);
393 + return (dev ? dev->has_rgmii : 0);
396 +/* Returns whether we have a Roboswitch. */
397 +static inline bool ssb_gige_have_roboswitch(struct pci_dev *pdev)
399 + struct ssb_gige *dev = pdev_to_ssb_gige(pdev);
401 + return !!(dev->dev->bus->sprom.boardflags_lo &
402 + SSB_GIGE_BFL_ROBOSWITCH);
406 +/* Returns whether we can only do one DMA at once. */
407 +static inline bool ssb_gige_one_dma_at_once(struct pci_dev *pdev)
409 + struct ssb_gige *dev = pdev_to_ssb_gige(pdev);
411 + return ((dev->dev->bus->chip_id == 0x4785) &&
412 + (dev->dev->bus->chip_rev < 2));
416 +/* Returns whether we must flush posted writes. */
417 +static inline bool ssb_gige_must_flush_posted_writes(struct pci_dev *pdev)
419 + struct ssb_gige *dev = pdev_to_ssb_gige(pdev);
421 + return (dev->dev->bus->chip_id == 0x4785);
425 +extern char * nvram_get(const char *name);
426 +/* Get the device MAC address */
427 +static inline void ssb_gige_get_macaddr(struct pci_dev *pdev, u8 *macaddr)
429 +#ifdef CONFIG_BCM947XX
430 + char *res = nvram_get("et0macaddr");
432 + memcpy(macaddr, res, 6);
436 +extern int ssb_gige_pcibios_plat_dev_init(struct ssb_device *sdev,
437 + struct pci_dev *pdev);
438 +extern int ssb_gige_map_irq(struct ssb_device *sdev,
439 + const struct pci_dev *pdev);
441 +/* The GigE driver is not a standalone module, because we don't have support
442 + * for unregistering the driver. So we could not unload the module anyway. */
443 +extern int ssb_gige_init(void);
444 +static inline void ssb_gige_exit(void)
446 + /* Currently we can not unregister the GigE driver,
447 + * because we can not unregister the PCI bridge. */
452 +#else /* CONFIG_SSB_DRIVER_GIGE */
453 +/* Gigabit Ethernet driver disabled */
456 +static inline int ssb_gige_pcibios_plat_dev_init(struct ssb_device *sdev,
457 + struct pci_dev *pdev)
461 +static inline int ssb_gige_map_irq(struct ssb_device *sdev,
462 + const struct pci_dev *pdev)
466 +static inline int ssb_gige_init(void)
470 +static inline void ssb_gige_exit(void)
474 +static inline bool pdev_is_ssb_gige_core(struct pci_dev *pdev)
478 +static inline struct ssb_gige * pdev_to_ssb_gige(struct pci_dev *pdev)
482 +static inline bool ssb_gige_is_rgmii(struct pci_dev *pdev)
486 +static inline bool ssb_gige_have_roboswitch(struct pci_dev *pdev)
490 +static inline bool ssb_gige_one_dma_at_once(struct pci_dev *pdev)
494 +static inline bool ssb_gige_must_flush_posted_writes(struct pci_dev *pdev)
499 +#endif /* CONFIG_SSB_DRIVER_GIGE */
500 +#endif /* LINUX_SSB_DRIVER_GIGE_H_ */
501 --- a/drivers/ssb/driver_pcicore.c
502 +++ b/drivers/ssb/driver_pcicore.c
504 /* Core to access the external PCI config space. Can only have one. */
505 static struct ssb_pcicore *extpci_core;
507 -static u32 ssb_pcicore_pcibus_iobase = 0x100;
508 -static u32 ssb_pcicore_pcibus_membase = SSB_PCI_DMA;
510 -int pcibios_plat_dev_init(struct pci_dev *d)
512 - struct resource *res;
516 - ssb_printk(KERN_INFO "PCI: Fixing up device %s\n",
519 - /* Fix up resource bases */
520 - for (pos = 0; pos < 6; pos++) {
521 - res = &d->resource[pos];
522 - if (res->flags & IORESOURCE_IO)
523 - base = &ssb_pcicore_pcibus_iobase;
525 - base = &ssb_pcicore_pcibus_membase;
526 - res->flags |= IORESOURCE_PCI_FIXED;
528 - size = res->end - res->start + 1;
529 - if (*base & (size - 1))
530 - *base = (*base + size) & ~(size - 1);
531 - res->start = *base;
532 - res->end = res->start + size - 1;
534 - pci_write_config_dword(d, PCI_BASE_ADDRESS_0 + (pos << 2), res->start);
536 - /* Fix up PCI bridge BAR0 only */
537 - if (d->bus->number == 0 && PCI_SLOT(d->devfn) == 0)
540 - /* Fix up interrupt lines */
541 - d->irq = ssb_mips_irq(extpci_core->dev) + 2;
542 - pci_write_config_byte(d, PCI_INTERRUPT_LINE, d->irq);
547 -static void __init ssb_fixup_pcibridge(struct pci_dev *dev)
551 - if (dev->bus->number != 0 || PCI_SLOT(dev->devfn) != 0)
554 - ssb_printk(KERN_INFO "PCI: Fixing up bridge %s\n", pci_name(dev));
556 - /* Enable PCI bridge bus mastering and memory space */
557 - pci_set_master(dev);
558 - pcibios_enable_device(dev, ~0);
560 - /* Enable PCI bridge BAR1 prefetch and burst */
561 - pci_write_config_dword(dev, SSB_BAR1_CONTROL, 3);
563 - /* Make sure our latency is high enough to handle the devices behind us */
565 - ssb_printk(KERN_INFO "PCI: Fixing latency timer of device %s to %u\n",
566 - pci_name(dev), lat);
567 - pci_write_config_byte(dev, PCI_LATENCY_TIMER, lat);
569 -DECLARE_PCI_FIXUP_EARLY(PCI_ANY_ID, PCI_ANY_ID, ssb_fixup_pcibridge);
571 -int __init pcibios_map_irq(const struct pci_dev *dev, u8 slot, u8 pin)
573 - return ssb_mips_irq(extpci_core->dev) + 2;
576 static u32 get_cfgspace_addr(struct ssb_pcicore *pc,
577 unsigned int bus, unsigned int dev,
579 .mem_offset = 0x24000000,
582 +static u32 ssb_pcicore_pcibus_iobase = 0x100;
583 +static u32 ssb_pcicore_pcibus_membase = SSB_PCI_DMA;
585 +/* This function is called when doing a pci_enable_device().
586 + * We must first check if the device is a device on the PCI-core bridge. */
587 +int ssb_pcicore_plat_dev_init(struct pci_dev *d)
589 + struct resource *res;
593 + if (d->bus->ops != &ssb_pcicore_pciops) {
594 + /* This is not a device on the PCI-core bridge. */
598 + ssb_printk(KERN_INFO "PCI: Fixing up device %s\n",
601 + /* Fix up resource bases */
602 + for (pos = 0; pos < 6; pos++) {
603 + res = &d->resource[pos];
604 + if (res->flags & IORESOURCE_IO)
605 + base = &ssb_pcicore_pcibus_iobase;
607 + base = &ssb_pcicore_pcibus_membase;
608 + res->flags |= IORESOURCE_PCI_FIXED;
610 + size = res->end - res->start + 1;
611 + if (*base & (size - 1))
612 + *base = (*base + size) & ~(size - 1);
613 + res->start = *base;
614 + res->end = res->start + size - 1;
616 + pci_write_config_dword(d, PCI_BASE_ADDRESS_0 + (pos << 2), res->start);
618 + /* Fix up PCI bridge BAR0 only */
619 + if (d->bus->number == 0 && PCI_SLOT(d->devfn) == 0)
622 + /* Fix up interrupt lines */
623 + d->irq = ssb_mips_irq(extpci_core->dev) + 2;
624 + pci_write_config_byte(d, PCI_INTERRUPT_LINE, d->irq);
629 +/* Early PCI fixup for a device on the PCI-core bridge. */
630 +static void ssb_pcicore_fixup_pcibridge(struct pci_dev *dev)
634 + if (dev->bus->ops != &ssb_pcicore_pciops) {
635 + /* This is not a device on the PCI-core bridge. */
638 + if (dev->bus->number != 0 || PCI_SLOT(dev->devfn) != 0)
641 + ssb_printk(KERN_INFO "PCI: Fixing up bridge %s\n", pci_name(dev));
643 + /* Enable PCI bridge bus mastering and memory space */
644 + pci_set_master(dev);
645 + pcibios_enable_device(dev, ~0);
647 + /* Enable PCI bridge BAR1 prefetch and burst */
648 + pci_write_config_dword(dev, SSB_BAR1_CONTROL, 3);
650 + /* Make sure our latency is high enough to handle the devices behind us */
652 + ssb_printk(KERN_INFO "PCI: Fixing latency timer of device %s to %u\n",
653 + pci_name(dev), lat);
654 + pci_write_config_byte(dev, PCI_LATENCY_TIMER, lat);
656 +DECLARE_PCI_FIXUP_EARLY(PCI_ANY_ID, PCI_ANY_ID, ssb_pcicore_fixup_pcibridge);
658 +/* PCI device IRQ mapping. */
659 +int ssb_pcicore_pcibios_map_irq(const struct pci_dev *dev, u8 slot, u8 pin)
661 + if (dev->bus->ops != &ssb_pcicore_pciops) {
662 + /* This is not a device on the PCI-core bridge. */
665 + return ssb_mips_irq(extpci_core->dev) + 2;
668 static void ssb_pcicore_init_hostmode(struct ssb_pcicore *pc)
671 --- a/drivers/ssb/embedded.c
672 +++ b/drivers/ssb/embedded.c
675 #include <linux/ssb/ssb.h>
676 #include <linux/ssb/ssb_embedded.h>
677 +#include <linux/ssb/ssb_driver_pci.h>
678 +#include <linux/ssb/ssb_driver_gige.h>
679 +#include <linux/pci.h>
681 #include "ssb_private.h"
686 EXPORT_SYMBOL(ssb_gpio_polarity);
688 +#ifdef CONFIG_SSB_DRIVER_GIGE
689 +static int gige_pci_init_callback(struct ssb_bus *bus, unsigned long data)
691 + struct pci_dev *pdev = (struct pci_dev *)data;
692 + struct ssb_device *dev;
696 + for (i = 0; i < bus->nr_devices; i++) {
697 + dev = &(bus->devices[i]);
698 + if (dev->id.coreid != SSB_DEV_ETHERNET_GBIT)
701 + !dev->dev->driver ||
702 + !device_is_registered(dev->dev))
704 + res = ssb_gige_pcibios_plat_dev_init(dev, pdev);
711 +#endif /* CONFIG_SSB_DRIVER_GIGE */
713 +int ssb_pcibios_plat_dev_init(struct pci_dev *dev)
717 + err = ssb_pcicore_plat_dev_init(dev);
720 +#ifdef CONFIG_SSB_DRIVER_GIGE
721 + err = ssb_for_each_bus_call((unsigned long)dev, gige_pci_init_callback);
725 + /* This is not a PCI device on any SSB device. */
730 +#ifdef CONFIG_SSB_DRIVER_GIGE
731 +static int gige_map_irq_callback(struct ssb_bus *bus, unsigned long data)
733 + const struct pci_dev *pdev = (const struct pci_dev *)data;
734 + struct ssb_device *dev;
738 + for (i = 0; i < bus->nr_devices; i++) {
739 + dev = &(bus->devices[i]);
740 + if (dev->id.coreid != SSB_DEV_ETHERNET_GBIT)
743 + !dev->dev->driver ||
744 + !device_is_registered(dev->dev))
746 + res = ssb_gige_map_irq(dev, pdev);
753 +#endif /* CONFIG_SSB_DRIVER_GIGE */
755 +int ssb_pcibios_map_irq(const struct pci_dev *dev, u8 slot, u8 pin)
759 + /* Check if this PCI device is a device on a SSB bus or device
760 + * and return the IRQ number for it. */
762 + res = ssb_pcicore_pcibios_map_irq(dev, slot, pin);
765 +#ifdef CONFIG_SSB_DRIVER_GIGE
766 + res = ssb_for_each_bus_call((unsigned long)dev, gige_map_irq_callback);
770 + /* This is not a PCI device on any SSB device. */
774 --- a/include/linux/ssb/ssb.h
775 +++ b/include/linux/ssb/ssb.h
777 extern u32 ssb_admatch_base(u32 adm);
778 extern u32 ssb_admatch_size(u32 adm);
780 +/* PCI device mapping and fixup routines.
781 + * Called from the architecture pcibios init code.
782 + * These are only available on SSB_EMBEDDED configurations. */
783 +#ifdef CONFIG_SSB_EMBEDDED
784 +int ssb_pcibios_plat_dev_init(struct pci_dev *dev);
785 +int ssb_pcibios_map_irq(const struct pci_dev *dev, u8 slot, u8 pin);
786 +#endif /* CONFIG_SSB_EMBEDDED */
788 #endif /* LINUX_SSB_H_ */
789 --- a/include/linux/ssb/ssb_driver_pci.h
790 +++ b/include/linux/ssb/ssb_driver_pci.h
792 #ifndef LINUX_SSB_PCICORE_H_
793 #define LINUX_SSB_PCICORE_H_
795 +#include <linux/types.h>
800 #ifdef CONFIG_SSB_DRIVER_PCICORE
802 /* PCI core registers. */
804 extern int ssb_pcicore_dev_irqvecs_enable(struct ssb_pcicore *pc,
805 struct ssb_device *dev);
807 +int ssb_pcicore_plat_dev_init(struct pci_dev *d);
808 +int ssb_pcicore_pcibios_map_irq(const struct pci_dev *dev, u8 slot, u8 pin);
811 #else /* CONFIG_SSB_DRIVER_PCICORE */
818 +int ssb_pcicore_plat_dev_init(struct pci_dev *d)
823 +int ssb_pcicore_pcibios_map_irq(const struct pci_dev *dev, u8 slot, u8 pin)
828 #endif /* CONFIG_SSB_DRIVER_PCICORE */
829 #endif /* LINUX_SSB_PCICORE_H_ */
830 --- a/drivers/ssb/main.c
831 +++ b/drivers/ssb/main.c
833 #include <linux/io.h>
834 #include <linux/ssb/ssb.h>
835 #include <linux/ssb/ssb_regs.h>
836 +#include <linux/ssb/ssb_driver_gige.h>
837 #include <linux/dma-mapping.h>
838 #include <linux/pci.h>
842 #endif /* CONFIG_SSB_PCIHOST */
844 +int ssb_for_each_bus_call(unsigned long data,
845 + int (*func)(struct ssb_bus *bus, unsigned long data))
847 + struct ssb_bus *bus;
851 + list_for_each_entry(bus, &buses, list) {
852 + res = func(bus, data);
854 + ssb_buses_unlock();
858 + ssb_buses_unlock();
863 static struct ssb_device *ssb_device_get(struct ssb_device *dev)
866 @@ -1175,7 +1195,14 @@
867 err = b43_pci_ssb_bridge_init();
869 ssb_printk(KERN_ERR "Broadcom 43xx PCI-SSB-bridge "
870 - "initialization failed");
871 + "initialization failed\n");
872 + /* don't fail SSB init because of this */
875 + err = ssb_gige_init();
877 + ssb_printk(KERN_ERR "SSB Broadcom Gigabit Ethernet "
878 + "driver initialization failed\n");
879 /* don't fail SSB init because of this */
882 @@ -1189,6 +1216,7 @@
884 static void __exit ssb_modexit(void)
887 b43_pci_ssb_bridge_exit();
888 bus_unregister(&ssb_bustype);
890 --- a/drivers/ssb/ssb_private.h
891 +++ b/drivers/ssb/ssb_private.h
893 extern int ssb_devices_freeze(struct ssb_bus *bus);
894 extern int ssb_devices_thaw(struct ssb_bus *bus);
895 extern struct ssb_bus *ssb_pci_dev_to_bus(struct pci_dev *pdev);
896 +int ssb_for_each_bus_call(unsigned long data,
897 + int (*func)(struct ssb_bus *bus, unsigned long data));
899 /* b43_pci_bridge.c */
900 #ifdef CONFIG_SSB_PCIHOST
901 --- a/drivers/net/tg3.c
902 +++ b/drivers/net/tg3.c
904 #include <linux/workqueue.h>
905 #include <linux/prefetch.h>
906 #include <linux/dma-mapping.h>
907 +#include <linux/ssb/ssb_driver_gige.h>
909 #include <net/checksum.h>
912 static inline void tw32_mailbox_flush(struct tg3 *tp, u32 off, u32 val)
914 tp->write32_mbox(tp, off, val);
915 - if (!(tp->tg3_flags & TG3_FLAG_MBOX_WRITE_REORDER) &&
916 - !(tp->tg3_flags2 & TG3_FLG2_ICH_WORKAROUND))
917 + if ((tp->tg3_flags3 & TG3_FLG3_FLUSH_POSTED_WRITES) ||
918 + (!(tp->tg3_flags & TG3_FLAG_MBOX_WRITE_REORDER) &&
919 + !(tp->tg3_flags2 & TG3_FLG2_ICH_WORKAROUND)))
920 tp->read32_mbox(tp, off);
925 #define PHY_BUSY_LOOPS 5000
927 -static int tg3_readphy(struct tg3 *tp, int reg, u32 *val)
928 +static int __tg3_readphy(struct tg3 *tp, unsigned int phy_addr, int reg, u32 *val)
936 - frame_val = ((PHY_ADDR << MI_COM_PHY_ADDR_SHIFT) &
937 + frame_val = ((phy_addr << MI_COM_PHY_ADDR_SHIFT) &
938 MI_COM_PHY_ADDR_MASK);
939 frame_val |= ((reg << MI_COM_REG_ADDR_SHIFT) &
940 MI_COM_REG_ADDR_MASK);
945 -static int tg3_writephy(struct tg3 *tp, int reg, u32 val)
946 +static int tg3_readphy(struct tg3 *tp, int reg, u32 *val)
948 + return __tg3_readphy(tp, PHY_ADDR, reg, val);
951 +static int __tg3_writephy(struct tg3 *tp, unsigned int phy_addr, int reg, u32 val)
959 - frame_val = ((PHY_ADDR << MI_COM_PHY_ADDR_SHIFT) &
960 + frame_val = ((phy_addr << MI_COM_PHY_ADDR_SHIFT) &
961 MI_COM_PHY_ADDR_MASK);
962 frame_val |= ((reg << MI_COM_REG_ADDR_SHIFT) &
963 MI_COM_REG_ADDR_MASK);
968 +static int tg3_writephy(struct tg3 *tp, int reg, u32 val)
970 + return __tg3_writephy(tp, PHY_ADDR, reg, val);
973 static void tg3_phy_toggle_automdix(struct tg3 *tp, int enable)
976 @@ -1988,6 +2000,14 @@
977 tp->link_config.active_duplex = current_duplex;
980 + if (tp->tg3_flags3 & TG3_FLG3_ROBOSWITCH) {
981 + current_link_up = 1;
982 + current_speed = SPEED_1000; //FIXME
983 + current_duplex = DUPLEX_FULL;
984 + tp->link_config.active_speed = current_speed;
985 + tp->link_config.active_duplex = current_duplex;
988 if (current_link_up == 1 &&
989 (tp->link_config.active_duplex == DUPLEX_FULL) &&
990 (tp->link_config.autoneg == AUTONEG_ENABLE)) {
991 @@ -4813,6 +4833,11 @@
995 + if (tp->tg3_flags3 & TG3_FLG3_IS_SSB_CORE) {
996 + /* We don't use firmware. */
1000 if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5906) {
1001 /* Wait up to 20ms for init done. */
1002 for (i = 0; i < 200; i++) {
1003 @@ -5040,6 +5065,14 @@
1004 tw32(0x5000, 0x400);
1007 + if (tp->tg3_flags3 & TG3_FLG3_IS_SSB_CORE) {
1008 + /* BCM4785: In order to avoid repercussions from using potentially
1009 + * defective internal ROM, stop the Rx RISC CPU, which is not
1012 + tg3_halt_cpu(tp, RX_CPU_BASE);
1015 tw32(GRC_MODE, tp->grc_mode);
1017 if (tp->pci_chip_rev_id == CHIPREV_ID_5705_A0) {
1018 @@ -5308,9 +5341,12 @@
1022 - /* Clear firmware's nvram arbitration. */
1023 - if (tp->tg3_flags & TG3_FLAG_NVRAM)
1024 - tw32(NVRAM_SWARB, SWARB_REQ_CLR0);
1025 + if (!(tp->tg3_flags3 & TG3_FLG3_IS_SSB_CORE)) {
1026 + /* Clear firmware's nvram arbitration. */
1027 + if (tp->tg3_flags & TG3_FLAG_NVRAM)
1028 + tw32(NVRAM_SWARB, SWARB_REQ_CLR0);
1034 @@ -5391,6 +5427,11 @@
1035 struct fw_info info;
1038 + if (tp->tg3_flags3 & TG3_FLG3_IS_SSB_CORE) {
1039 + /* We don't use firmware. */
1043 info.text_base = TG3_FW_TEXT_ADDR;
1044 info.text_len = TG3_FW_TEXT_LEN;
1045 info.text_data = &tg3FwText[0];
1046 @@ -5949,6 +5990,11 @@
1047 unsigned long cpu_base, cpu_scratch_base, cpu_scratch_size;
1050 + if (tp->tg3_flags3 & TG3_FLG3_IS_SSB_CORE) {
1051 + /* We don't use firmware. */
1055 if (tp->tg3_flags2 & TG3_FLG2_HW_TSO)
1058 @@ -6850,6 +6896,11 @@
1060 spin_lock(&tp->lock);
1062 + if (tp->tg3_flags3 & TG3_FLG3_FLUSH_POSTED_WRITES) {
1063 + /* BCM4785: Flush posted writes from GbE to host memory. */
1064 + tr32(HOSTCC_MODE);
1067 if (!(tp->tg3_flags & TG3_FLAG_TAGGED_STATUS)) {
1068 /* All of this garbage is because when using non-tagged
1069 * IRQ status the mailbox/status_block protocol the chip
1070 @@ -8432,6 +8483,11 @@
1071 u32 *buf, csum, magic;
1072 int i, j, err = 0, size;
1074 + if (tp->tg3_flags3 & TG3_FLG3_IS_SSB_CORE) {
1075 + /* We don't have NVRAM. */
1079 if (tg3_nvram_read_swab(tp, 0, &magic) != 0)
1082 @@ -9154,7 +9210,7 @@
1085 spin_lock_bh(&tp->lock);
1086 - err = tg3_readphy(tp, data->reg_num & 0x1f, &mii_regval);
1087 + err = __tg3_readphy(tp, data->phy_id & 0x1f, data->reg_num & 0x1f, &mii_regval);
1088 spin_unlock_bh(&tp->lock);
1090 data->val_out = mii_regval;
1091 @@ -9173,7 +9229,7 @@
1094 spin_lock_bh(&tp->lock);
1095 - err = tg3_writephy(tp, data->reg_num & 0x1f, data->val_in);
1096 + err = __tg3_writephy(tp, data->phy_id & 0x1f, data->reg_num & 0x1f, data->val_in);
1097 spin_unlock_bh(&tp->lock);
1100 @@ -9571,6 +9627,12 @@
1101 /* Chips other than 5700/5701 use the NVRAM for fetching info. */
1102 static void __devinit tg3_nvram_init(struct tg3 *tp)
1104 + if (tp->tg3_flags3 & TG3_FLG3_IS_SSB_CORE) {
1105 + /* No NVRAM and EEPROM on the SSB Broadcom GigE core. */
1106 + tp->tg3_flags &= ~(TG3_FLAG_NVRAM | TG3_FLAG_NVRAM_BUFFERED);
1110 tw32_f(GRC_EEPROM_ADDR,
1111 (EEPROM_ADDR_FSM_RESET |
1112 (EEPROM_DEFAULT_CLOCK_PERIOD <<
1113 @@ -9706,6 +9768,9 @@
1117 + if (tp->tg3_flags3 & TG3_FLG3_IS_SSB_CORE)
1120 if (!(tp->tg3_flags & TG3_FLAG_NVRAM))
1121 return tg3_nvram_read_using_eeprom(tp, offset, val);
1123 @@ -9938,6 +10003,9 @@
1127 + if (tp->tg3_flags3 & TG3_FLG3_IS_SSB_CORE)
1130 if (tp->tg3_flags & TG3_FLAG_EEPROM_WRITE_PROT) {
1131 tw32_f(GRC_LOCAL_CTRL, tp->grc_local_ctrl &
1132 ~GRC_LCLCTRL_GPIO_OUTPUT1);
1133 @@ -10804,7 +10872,6 @@
1134 tp->write32 = tg3_write_flush_reg32;
1138 if ((tp->tg3_flags & TG3_FLAG_TXD_MBOX_HWBUG) ||
1139 (tp->tg3_flags & TG3_FLAG_MBOX_WRITE_REORDER)) {
1140 tp->write32_tx_mbox = tg3_write32_tx_mbox;
1141 @@ -10840,6 +10907,11 @@
1142 GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5701)))
1143 tp->tg3_flags |= TG3_FLAG_SRAM_USE_CONFIG;
1145 + if (tp->tg3_flags3 & TG3_FLG3_FLUSH_POSTED_WRITES) {
1146 + tp->write32_tx_mbox = tg3_write_flush_reg32;
1147 + tp->write32_rx_mbox = tg3_write_flush_reg32;
1150 /* Get eeprom hw config before calling tg3_set_power_state().
1151 * In particular, the TG3_FLG2_IS_NIC flag must be
1152 * determined before calling tg3_set_power_state() so that
1153 @@ -11184,6 +11256,10 @@
1156 if (!is_valid_ether_addr(&dev->dev_addr[0])) {
1157 + if (tp->tg3_flags3 & TG3_FLG3_IS_SSB_CORE)
1158 + ssb_gige_get_macaddr(tp->pdev, &dev->dev_addr[0]);
1160 + if (!is_valid_ether_addr(&dev->dev_addr[0])) {
1161 #ifdef CONFIG_SPARC64
1162 if (!tg3_get_default_macaddr_sparc(tp))
1164 @@ -11675,6 +11751,7 @@
1165 case PHY_ID_BCM5704: return "5704";
1166 case PHY_ID_BCM5705: return "5705";
1167 case PHY_ID_BCM5750: return "5750";
1168 + case PHY_ID_BCM5750_2: return "5750-2";
1169 case PHY_ID_BCM5752: return "5752";
1170 case PHY_ID_BCM5714: return "5714";
1171 case PHY_ID_BCM5780: return "5780";
1172 @@ -11859,6 +11936,13 @@
1173 tp->msg_enable = tg3_debug;
1175 tp->msg_enable = TG3_DEF_MSG_ENABLE;
1176 + if (pdev_is_ssb_gige_core(pdev)) {
1177 + tp->tg3_flags3 |= TG3_FLG3_IS_SSB_CORE;
1178 + if (ssb_gige_must_flush_posted_writes(pdev))
1179 + tp->tg3_flags3 |= TG3_FLG3_FLUSH_POSTED_WRITES;
1180 + if (ssb_gige_have_roboswitch(pdev))
1181 + tp->tg3_flags3 |= TG3_FLG3_ROBOSWITCH;
1184 /* The word/byte swap controls here control register access byte
1185 * swapping. DMA data byte swapping is controlled in the GRC_MODE
1186 --- a/drivers/net/tg3.h
1187 +++ b/drivers/net/tg3.h
1188 @@ -2279,6 +2279,10 @@
1189 #define TG3_FLG2_PHY_JITTER_BUG 0x20000000
1190 #define TG3_FLG2_NO_FWARE_REPORTED 0x40000000
1191 #define TG3_FLG2_PHY_ADJUST_TRIM 0x80000000
1193 +#define TG3_FLG3_IS_SSB_CORE 0x00000001
1194 +#define TG3_FLG3_FLUSH_POSTED_WRITES 0x00000002
1195 +#define TG3_FLG3_ROBOSWITCH 0x00000004
1197 struct timer_list timer;
1199 @@ -2333,6 +2337,7 @@
1200 #define PHY_ID_BCM5714 0x60008340
1201 #define PHY_ID_BCM5780 0x60008350
1202 #define PHY_ID_BCM5755 0xbc050cc0
1203 +#define PHY_ID_BCM5750_2 0xbc050cd0
1204 #define PHY_ID_BCM5787 0xbc050ce0
1205 #define PHY_ID_BCM5756 0xbc050ed0
1206 #define PHY_ID_BCM5906 0xdc00ac40
1207 @@ -2364,7 +2369,8 @@
1208 (X) == PHY_ID_BCM5752 || (X) == PHY_ID_BCM5714 || \
1209 (X) == PHY_ID_BCM5780 || (X) == PHY_ID_BCM5787 || \
1210 (X) == PHY_ID_BCM5755 || (X) == PHY_ID_BCM5756 || \
1211 - (X) == PHY_ID_BCM5906 || (X) == PHY_ID_BCM8002)
1212 + (X) == PHY_ID_BCM5906 || (X) == PHY_ID_BCM8002 || \
1213 + (X) == PHY_ID_BCM5750_2)
1215 struct tg3_hw_stats *hw_stats;
1216 dma_addr_t stats_mapping;
1217 --- a/drivers/ssb/driver_mipscore.c
1218 +++ b/drivers/ssb/driver_mipscore.c
1222 case SSB_DEV_ETHERNET:
1223 + case SSB_DEV_ETHERNET_GBIT:
1225 case SSB_DEV_USB20_HOST:
1226 /* These devices get their own IRQ line if available, the rest goes on IRQ0 */