static int wl_glue_ssb_probe(struct ssb_device *dev, const struct ssb_device_id *id) { void *mmio; void *wldev; if (!attach_cb) { pr_err("No attach callback registered\n"); return -ENOSYS; } if (dev->bus->bustype != SSB_BUSTYPE_SSB) { pr_err("Attaching to SSB behind PCI is not supported. Please remove the b43 ssb bridge\n"); return -EINVAL; } mmio = (void *) 0x18000000 + dev->core_index * 0x1000; wldev = attach_cb(id->vendor, id->coreid, (ulong)mmio, dev, dev->irq); if (!wldev) { pr_err("The attach callback failed, SSB probe aborted\n"); return -ENODEV; } ssb_set_drvdata(dev, wldev); return 0; }
static int __devinit ssb_hcd_probe(struct ssb_device *dev, const struct ssb_device_id *id) { int err, tmp; int start, len; u16 chipid_top; u16 coreid = dev->id.coreid; struct ssb_hcd_device *usb_dev; /* USBcores are only connected on embedded devices. */ chipid_top = (dev->bus->chip_id & 0xFF00); if (chipid_top != 0x4700 && chipid_top != 0x5300) return -ENODEV; /* TODO: Probably need checks here; is the core connected? */ if (dma_set_mask(dev->dma_dev, DMA_BIT_MASK(32)) || dma_set_coherent_mask(dev->dma_dev, DMA_BIT_MASK(32))) return -EOPNOTSUPP; usb_dev = kzalloc(sizeof(struct ssb_hcd_device), GFP_KERNEL); if (!usb_dev) return -ENOMEM; /* We currently always attach SSB_DEV_USB11_HOSTDEV * as HOST OHCI. If we want to attach it as Client device, * we must branch here and call into the (yet to * be written) Client mode driver. Same for remove(). */ usb_dev->enable_flags = ssb_hcd_init_chip(dev); tmp = ssb_read32(dev, SSB_ADMATCH0); start = ssb_admatch_base(tmp); len = (coreid == SSB_DEV_USB20_HOST) ? 0x800 : ssb_admatch_size(tmp); usb_dev->ohci_dev = ssb_hcd_create_pdev(dev, true, start, len); if (IS_ERR(usb_dev->ohci_dev)) { err = PTR_ERR(usb_dev->ohci_dev); goto err_free_usb_dev; } if (coreid == SSB_DEV_USB20_HOST) { start = ssb_admatch_base(tmp) + 0x800; /* ehci core offset */ usb_dev->ehci_dev = ssb_hcd_create_pdev(dev, false, start, len); if (IS_ERR(usb_dev->ehci_dev)) { err = PTR_ERR(usb_dev->ehci_dev); goto err_unregister_ohci_dev; } } ssb_set_drvdata(dev, usb_dev); return 0; err_unregister_ohci_dev: platform_device_unregister(usb_dev->ohci_dev); err_free_usb_dev: kfree(usb_dev); return err; }
static void wl_glue_ssb_remove(struct ssb_device *dev) { void *wldev = ssb_get_drvdata(dev); if (remove_cb) remove_cb(wldev); ssb_set_drvdata(dev, NULL); }
void b43_bus_set_wldev(struct b43_bus_dev *dev, void *wldev) { switch (dev->bus_type) { #ifdef CONFIG_B43_BCMA case B43_BUS_BCMA: bcma_set_drvdata(dev->bdev, wldev); break; #endif #ifdef CONFIG_B43_SSB case B43_BUS_SSB: ssb_set_drvdata(dev->sdev, wldev); break; #endif } }
static int ssb_ohci_attach(struct ssb_device *dev) { struct ssb_ohci_device *ohcidev; struct usb_hcd *hcd; int err = -ENOMEM; u32 tmp, flags = 0; if (dev->id.coreid == SSB_DEV_USB11_HOSTDEV) flags |= SSB_OHCI_TMSLOW_HOSTMODE; ssb_device_enable(dev, flags); hcd = usb_create_hcd(&ssb_ohci_hc_driver, dev->dev, dev_name(dev->dev)); if (!hcd) goto err_dev_disable; ohcidev = hcd_to_ssb_ohci(hcd); ohcidev->enable_flags = flags; tmp = ssb_read32(dev, SSB_ADMATCH0); hcd->rsrc_start = ssb_admatch_base(tmp); hcd->rsrc_len = ssb_admatch_size(tmp); hcd->regs = ioremap_nocache(hcd->rsrc_start, hcd->rsrc_len); if (!hcd->regs) goto err_put_hcd; err = usb_add_hcd(hcd, dev->irq, IRQF_DISABLED | IRQF_SHARED); if (err) goto err_iounmap; ssb_set_drvdata(dev, hcd); return err; err_iounmap: iounmap(hcd->regs); err_put_hcd: usb_put_hcd(hcd); err_dev_disable: ssb_device_disable(dev, flags); return err; }
static int ssb_ohci_attach(struct ssb_device *dev) { struct ssb_ohci_device *ohcidev; struct usb_hcd *hcd; int err = -ENOMEM; u32 tmp, flags = 0; if (dma_set_mask(dev->dma_dev, DMA_BIT_MASK(32)) || dma_set_coherent_mask(dev->dma_dev, DMA_BIT_MASK(32))) return -EOPNOTSUPP; if (dev->id.coreid == SSB_DEV_USB11_HOSTDEV) { /* Put the device into host-mode. */ flags |= SSB_OHCI_TMSLOW_HOSTMODE; ssb_device_enable(dev, flags); } else if (dev->id.coreid == SSB_DEV_USB20_HOST) { /* * USB 2.0 special considerations: * * In addition to the standard SSB reset sequence, the Host * Control Register must be programmed to bring the USB core * and various phy components out of reset. */ ssb_device_enable(dev, 0); ssb_write32(dev, 0x200, 0x7ff); /* Change Flush control reg */ tmp = ssb_read32(dev, 0x400); tmp &= ~8; ssb_write32(dev, 0x400, tmp); tmp = ssb_read32(dev, 0x400); /* Change Shim control reg */ tmp = ssb_read32(dev, 0x304); tmp &= ~0x100; ssb_write32(dev, 0x304, tmp); tmp = ssb_read32(dev, 0x304); udelay(1); /* Work around for 5354 failures */ if (dev->id.revision == 2 && dev->bus->chip_id == 0x5354) { /* Change syn01 reg */ tmp = 0x00fe00fe; ssb_write32(dev, 0x894, tmp); /* Change syn03 reg */ tmp = ssb_read32(dev, 0x89c); tmp |= 0x1; ssb_write32(dev, 0x89c, tmp); } } else ssb_device_enable(dev, 0); hcd = usb_create_hcd(&ssb_ohci_hc_driver, dev->dev, dev_name(dev->dev)); if (!hcd) goto err_dev_disable; ohcidev = hcd_to_ssb_ohci(hcd); ohcidev->enable_flags = flags; tmp = ssb_read32(dev, SSB_ADMATCH0); hcd->rsrc_start = ssb_admatch_base(tmp); hcd->rsrc_len = ssb_admatch_size(tmp); hcd->regs = ioremap_nocache(hcd->rsrc_start, hcd->rsrc_len); if (!hcd->regs) goto err_put_hcd; err = usb_add_hcd(hcd, dev->irq, IRQF_SHARED); if (err) goto err_iounmap; ssb_set_drvdata(dev, hcd); return err; err_iounmap: iounmap(hcd->regs); err_put_hcd: usb_put_hcd(hcd); err_dev_disable: ssb_device_disable(dev, flags); return err; }
static int ssb_gige_probe(struct ssb_device *sdev, const struct ssb_device_id *id) { struct ssb_gige *dev; u32 base, tmslow, tmshigh; dev = kzalloc(sizeof(*dev), GFP_KERNEL); if (!dev) return -ENOMEM; dev->dev = sdev; spin_lock_init(&dev->lock); dev->pci_controller.pci_ops = &dev->pci_ops; dev->pci_controller.io_resource = &dev->io_resource; dev->pci_controller.mem_resource = &dev->mem_resource; dev->pci_controller.io_map_base = 0x800; dev->pci_ops.read = ssb_gige_pci_read_config; dev->pci_ops.write = ssb_gige_pci_write_config; dev->io_resource.name = SSB_GIGE_IO_RES_NAME; dev->io_resource.start = 0x800; dev->io_resource.end = 0x8FF; dev->io_resource.flags = IORESOURCE_IO | IORESOURCE_PCI_FIXED; if (!ssb_device_is_enabled(sdev)) ssb_device_enable(sdev, 0); /* Setup BAR0. This is a 64k MMIO region. */ base = ssb_admatch_base(ssb_read32(sdev, SSB_ADMATCH1)); gige_pcicfg_write32(dev, PCI_BASE_ADDRESS_0, base); gige_pcicfg_write32(dev, PCI_BASE_ADDRESS_1, 0); dev->mem_resource.name = SSB_GIGE_MEM_RES_NAME; dev->mem_resource.start = base; dev->mem_resource.end = base + 0x10000 - 1; dev->mem_resource.flags = IORESOURCE_MEM | IORESOURCE_PCI_FIXED; /* Enable the memory region. */ gige_pcicfg_write16(dev, PCI_COMMAND, gige_pcicfg_read16(dev, PCI_COMMAND) | PCI_COMMAND_MEMORY); /* Write flushing is controlled by the Flush Status Control register. * We want to flush every register write with a timeout and we want * to disable the IRQ mask while flushing to avoid concurrency. * Note that automatic write flushing does _not_ work from * an IRQ handler. The driver must flush manually by reading a register. */ gige_write32(dev, SSB_GIGE_SHIM_FLUSHSTAT, 0x00000068); /* Check if we have an RGMII or GMII PHY-bus. * On RGMII do not bypass the DLLs */ tmslow = ssb_read32(sdev, SSB_TMSLOW); tmshigh = ssb_read32(sdev, SSB_TMSHIGH); if (tmshigh & SSB_GIGE_TMSHIGH_RGMII) { tmslow &= ~SSB_GIGE_TMSLOW_TXBYPASS; tmslow &= ~SSB_GIGE_TMSLOW_RXBYPASS; dev->has_rgmii = 1; } else { tmslow |= SSB_GIGE_TMSLOW_TXBYPASS; tmslow |= SSB_GIGE_TMSLOW_RXBYPASS; dev->has_rgmii = 0; } tmslow |= SSB_GIGE_TMSLOW_DLLEN; ssb_write32(sdev, SSB_TMSLOW, tmslow); ssb_set_drvdata(sdev, dev); register_pci_controller(&dev->pci_controller); return 0; }
static int __devinit ssb_gige_probe(struct ssb_device *sdev, const struct ssb_device_id *id) { struct ssb_gige *dev; u32 base, tmslow, tmshigh; dev = kzalloc(sizeof(*dev), GFP_KERNEL); if (!dev) return -ENOMEM; dev->dev = sdev; spin_lock_init(&dev->lock); dev->pci_controller.pci_ops = &dev->pci_ops; dev->pci_controller.io_resource = &dev->io_resource; dev->pci_controller.mem_resource = &dev->mem_resource; dev->pci_controller.io_map_base = 0x800; dev->pci_ops.read = ssb_gige_pci_read_config; dev->pci_ops.write = ssb_gige_pci_write_config; dev->io_resource.name = SSB_GIGE_IO_RES_NAME; dev->io_resource.start = 0x800; dev->io_resource.end = 0x8FF; dev->io_resource.flags = IORESOURCE_IO | IORESOURCE_PCI_FIXED; if (!ssb_device_is_enabled(sdev)) ssb_device_enable(sdev, 0); base = ssb_admatch_base(ssb_read32(sdev, SSB_ADMATCH1)); gige_pcicfg_write32(dev, PCI_BASE_ADDRESS_0, base); gige_pcicfg_write32(dev, PCI_BASE_ADDRESS_1, 0); dev->mem_resource.name = SSB_GIGE_MEM_RES_NAME; dev->mem_resource.start = base; dev->mem_resource.end = base + 0x10000 - 1; dev->mem_resource.flags = IORESOURCE_MEM | IORESOURCE_PCI_FIXED; gige_pcicfg_write16(dev, PCI_COMMAND, gige_pcicfg_read16(dev, PCI_COMMAND) | PCI_COMMAND_MEMORY); gige_write32(dev, SSB_GIGE_SHIM_FLUSHSTAT, 0x00000068); tmslow = ssb_read32(sdev, SSB_TMSLOW); tmshigh = ssb_read32(sdev, SSB_TMSHIGH); if (tmshigh & SSB_GIGE_TMSHIGH_RGMII) { tmslow &= ~SSB_GIGE_TMSLOW_TXBYPASS; tmslow &= ~SSB_GIGE_TMSLOW_RXBYPASS; dev->has_rgmii = 1; } else { tmslow |= SSB_GIGE_TMSLOW_TXBYPASS; tmslow |= SSB_GIGE_TMSLOW_RXBYPASS; dev->has_rgmii = 0; } tmslow |= SSB_GIGE_TMSLOW_DLLEN; ssb_write32(sdev, SSB_TMSLOW, tmslow); ssb_set_drvdata(sdev, dev); register_pci_controller(&dev->pci_controller); return 0; }