static int ci_hdrc_msm_probe(struct platform_device *pdev) { struct platform_device *plat_ci; struct usb_phy *phy; dev_dbg(&pdev->dev, "ci_hdrc_msm_probe\n"); /* * OTG(PHY) driver takes care of PHY initialization, clock management, * powering up VBUS, mapping of registers address space and power * management. */ phy = devm_usb_get_phy_by_phandle(&pdev->dev, "usb-phy", 0); if (IS_ERR(phy)) return PTR_ERR(phy); ci_hdrc_msm_platdata.phy = phy; plat_ci = ci_hdrc_add_device(&pdev->dev, pdev->resource, pdev->num_resources, &ci_hdrc_msm_platdata); if (IS_ERR(plat_ci)) { dev_err(&pdev->dev, "ci_hdrc_add_device failed!\n"); return PTR_ERR(plat_ci); } platform_set_drvdata(pdev, plat_ci); pm_runtime_no_callbacks(&pdev->dev); pm_runtime_enable(&pdev->dev); return 0; }
static int ci_hdrc_zevio_probe(struct platform_device *pdev) { struct platform_device *ci_pdev; dev_dbg(&pdev->dev, "ci_hdrc_zevio_probe\n"); ci_pdev = ci_hdrc_add_device(&pdev->dev, pdev->resource, pdev->num_resources, &ci_hdrc_zevio_platdata); if (IS_ERR(ci_pdev)) { dev_err(&pdev->dev, "ci_hdrc_add_device failed!\n"); return PTR_ERR(ci_pdev); } platform_set_drvdata(pdev, ci_pdev); return 0; }
/** * ci_hdrc_pci_probe: PCI probe * @pdev: USB device controller being probed * @id: PCI hotplug ID connecting controller to UDC framework * * This function returns an error code * Allocates basic PCI resources for this USB device controller, and then * invokes the udc_probe() method to start the UDC associated with it */ static int ci_hdrc_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id) { struct ci_hdrc_platform_data *platdata = (void *)id->driver_data; struct platform_device *plat_ci; struct resource res[3]; int retval = 0, nres = 2; if (!platdata) { dev_err(&pdev->dev, "device doesn't provide driver data\n"); return -ENODEV; } retval = pcim_enable_device(pdev); if (retval) return retval; if (!pdev->irq) { dev_err(&pdev->dev, "No IRQ, check BIOS/PCI setup!"); return -ENODEV; } pci_set_master(pdev); pci_try_set_mwi(pdev); memset(res, 0, sizeof(res)); res[0].start = pci_resource_start(pdev, 0); res[0].end = pci_resource_end(pdev, 0); res[0].flags = IORESOURCE_MEM; res[1].start = pdev->irq; res[1].flags = IORESOURCE_IRQ; plat_ci = ci_hdrc_add_device(&pdev->dev, res, nres, platdata); if (IS_ERR(plat_ci)) { dev_err(&pdev->dev, "ci_hdrc_add_device failed!\n"); return PTR_ERR(plat_ci); } pci_set_drvdata(pdev, plat_ci); return 0; }
static int ci_hdrc_imx_probe(struct platform_device *pdev) { struct ci_hdrc_imx_data *data; struct ci_hdrc_platform_data pdata = { .name = "ci_hdrc_imx", .capoffset = DEF_CAPOFFSET, .flags = CI_HDRC_REQUIRE_TRANSCEIVER | CI_HDRC_DISABLE_STREAMING, }; int ret; data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL); if (!data) { dev_err(&pdev->dev, "Failed to allocate ci_hdrc-imx data!\n"); return -ENOMEM; } data->usbmisc_data = usbmisc_get_init_data(&pdev->dev); if (IS_ERR(data->usbmisc_data)) return PTR_ERR(data->usbmisc_data); data->clk = devm_clk_get(&pdev->dev, NULL); if (IS_ERR(data->clk)) { dev_err(&pdev->dev, "Failed to get clock, err=%ld\n", PTR_ERR(data->clk)); return PTR_ERR(data->clk); } ret = clk_prepare_enable(data->clk); if (ret) { dev_err(&pdev->dev, "Failed to prepare or enable clock, err=%d\n", ret); return ret; } data->phy = devm_usb_get_phy_by_phandle(&pdev->dev, "fsl,usbphy", 0); if (IS_ERR(data->phy)) { ret = PTR_ERR(data->phy); goto err_clk; } pdata.phy = data->phy; ret = dma_coerce_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32)); if (ret) goto err_clk; if (data->usbmisc_data) { ret = imx_usbmisc_init(data->usbmisc_data); if (ret) { dev_err(&pdev->dev, "usbmisc init failed, ret=%d\n", ret); goto err_clk; } } data->ci_pdev = ci_hdrc_add_device(&pdev->dev, pdev->resource, pdev->num_resources, &pdata); if (IS_ERR(data->ci_pdev)) { ret = PTR_ERR(data->ci_pdev); dev_err(&pdev->dev, "Can't register ci_hdrc platform device, err=%d\n", ret); goto err_clk; } if (data->usbmisc_data) { ret = imx_usbmisc_init_post(data->usbmisc_data); if (ret) { dev_err(&pdev->dev, "usbmisc post failed, ret=%d\n", ret); goto disable_device; } } platform_set_drvdata(pdev, data); pm_runtime_no_callbacks(&pdev->dev); pm_runtime_enable(&pdev->dev); return 0; disable_device: ci_hdrc_remove_device(data->ci_pdev); err_clk: clk_disable_unprepare(data->clk); return ret; } static int ci_hdrc_imx_remove(struct platform_device *pdev) { struct ci_hdrc_imx_data *data = platform_get_drvdata(pdev); pm_runtime_disable(&pdev->dev); ci_hdrc_remove_device(data->ci_pdev); clk_disable_unprepare(data->clk); return 0; } static const struct of_device_id ci_hdrc_imx_dt_ids[] = { { .compatible = "fsl,imx27-usb", }, { /* sentinel */ } };