staticstruct pci_dev *cdnsp_get_second_fun(struct pci_dev *pdev)
{ /* * Gets the second function. * Platform has two function. The fist keeps resources for * Host/Device while the secon keeps resources for DRD/OTG.
*/ if (pdev->device == PCI_DEVICE_ID_CDNS_USBSSP) return pci_get_device(pdev->vendor, PCI_DEVICE_ID_CDNS_USBSS, NULL); if (pdev->device == PCI_DEVICE_ID_CDNS_USBSS) return pci_get_device(pdev->vendor, PCI_DEVICE_ID_CDNS_USBSSP, NULL);
/* * For GADGET/HOST PCI (devfn) function number is 0, * for OTG PCI (devfn) function number is 1.
*/ if (!id || (pdev->devfn != PCI_DEV_FN_HOST_DEVICE &&
pdev->devfn != PCI_DEV_FN_OTG)) return -EINVAL;
func = cdnsp_get_second_fun(pdev); if (!func) return -EINVAL;
if (func->class == PCI_CLASS_SERIAL_USB_XHCI ||
pdev->class == PCI_CLASS_SERIAL_USB_XHCI) {
ret = -EINVAL; goto put_pci;
}
ret = pcim_enable_device(pdev); if (ret) {
dev_err(&pdev->dev, "Enabling PCI device has failed %d\n", ret); goto put_pci;
}
pci_set_master(pdev); if (pci_is_enabled(func)) {
cdnsp = pci_get_drvdata(func);
} else {
cdnsp = kzalloc(sizeof(*cdnsp), GFP_KERNEL); if (!cdnsp) {
ret = -ENOMEM; goto put_pci;
}
}
/* For GADGET device function number is 0. */ if (pdev->devfn == 0) {
resource_size_t rsrc_start, rsrc_len;
/* Function 0: host(BAR_0) + device(BAR_1).*/
dev_dbg(dev, "Initialize resources\n");
rsrc_start = pci_resource_start(pdev, PCI_BAR_DEV);
rsrc_len = pci_resource_len(pdev, PCI_BAR_DEV);
res = devm_request_mem_region(dev, rsrc_start, rsrc_len, "dev"); if (!res) {
dev_dbg(dev, "controller already in use\n");
ret = -EBUSY; goto free_cdnsp;
}
cdnsp->dev_regs = devm_ioremap(dev, rsrc_start, rsrc_len); if (!cdnsp->dev_regs) {
dev_dbg(dev, "error mapping memory\n");
ret = -EFAULT; goto free_cdnsp;
}
cdnsp->dev_irq = pdev->irq;
dev_dbg(dev, "USBSS-DEV physical base addr: %pa\n",
&rsrc_start);
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.