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 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; }