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 struct platform_device * lpe_audio_platdev_create(struct drm_i915_private *dev_priv) { struct drm_device *dev = &dev_priv->drm; struct platform_device_info pinfo = {}; struct resource *rsc; struct platform_device *platdev; struct intel_hdmi_lpe_audio_pdata *pdata; pdata = kzalloc(sizeof(*pdata), GFP_KERNEL); if (!pdata) return ERR_PTR(-ENOMEM); rsc = kcalloc(2, sizeof(*rsc), GFP_KERNEL); if (!rsc) { kfree(pdata); return ERR_PTR(-ENOMEM); } rsc[0].start = rsc[0].end = dev_priv->lpe_audio.irq; rsc[0].flags = IORESOURCE_IRQ; rsc[0].name = "hdmi-lpe-audio-irq"; rsc[1].start = pci_resource_start(dev->pdev, 0) + I915_HDMI_LPE_AUDIO_BASE; rsc[1].end = pci_resource_start(dev->pdev, 0) + I915_HDMI_LPE_AUDIO_BASE + I915_HDMI_LPE_AUDIO_SIZE - 1; rsc[1].flags = IORESOURCE_MEM; rsc[1].name = "hdmi-lpe-audio-mmio"; pinfo.parent = dev->dev; pinfo.name = "hdmi-lpe-audio"; pinfo.id = -1; pinfo.res = rsc; pinfo.num_res = 2; pinfo.data = pdata; pinfo.size_data = sizeof(*pdata); pinfo.dma_mask = DMA_BIT_MASK(32); pdata->num_pipes = INTEL_INFO(dev_priv)->num_pipes; pdata->num_ports = IS_CHERRYVIEW(dev_priv) ? 3 : 2; /* B,C,D or B,C */ pdata->port[0].pipe = -1; pdata->port[1].pipe = -1; pdata->port[2].pipe = -1; spin_lock_init(&pdata->lpe_audio_slock); platdev = platform_device_register_full(&pinfo); kfree(rsc); kfree(pdata); if (IS_ERR(platdev)) { DRM_ERROR("Failed to allocate LPE audio platform device\n"); return platdev; } pm_runtime_no_callbacks(&platdev->dev); return platdev; }
/** * tb_domain_add() - Add domain to the system * @tb: Domain to add * * Starts the domain and adds it to the system. Hotplugging devices will * work after this has been returned successfully. In order to remove * and release the domain after this function has been called, call * tb_domain_remove(). * * Return: %0 in case of success and negative errno in case of error */ int tb_domain_add(struct tb *tb) { int ret; if (WARN_ON(!tb->cm_ops)) return -EINVAL; mutex_lock(&tb->lock); tb->ctl = tb_ctl_alloc(tb->nhi, tb_domain_event_cb, tb); if (!tb->ctl) { ret = -ENOMEM; goto err_unlock; } /* * tb_schedule_hotplug_handler may be called as soon as the config * channel is started. Thats why we have to hold the lock here. */ tb_ctl_start(tb->ctl); if (tb->cm_ops->driver_ready) { ret = tb->cm_ops->driver_ready(tb); if (ret) goto err_ctl_stop; } ret = device_add(&tb->dev); if (ret) goto err_ctl_stop; /* Start the domain */ if (tb->cm_ops->start) { ret = tb->cm_ops->start(tb); if (ret) goto err_domain_del; } /* This starts event processing */ mutex_unlock(&tb->lock); pm_runtime_no_callbacks(&tb->dev); pm_runtime_set_active(&tb->dev); pm_runtime_enable(&tb->dev); pm_runtime_set_autosuspend_delay(&tb->dev, TB_AUTOSUSPEND_DELAY); pm_runtime_mark_last_busy(&tb->dev); pm_runtime_use_autosuspend(&tb->dev); return 0; err_domain_del: device_del(&tb->dev); err_ctl_stop: tb_ctl_stop(tb->ctl); err_unlock: mutex_unlock(&tb->lock); return ret; }
static int ci13xxx_msm_probe(struct platform_device *pdev) { struct resource *res; struct usb_info *ui; void __iomem *regs; int irq; int ret; dev_dbg(&pdev->dev, "ci13xxx_msm_probe\n"); ui = kzalloc(sizeof(struct usb_info), GFP_KERNEL); if (!ui) return -ENOMEM; the_usb_info = ui; res = platform_get_resource(pdev, IORESOURCE_MEM, 0); if (!res) { dev_err(&pdev->dev, "failed to get platform resource mem\n"); return -ENXIO; } regs = ioremap(res->start, resource_size(res)); if (!regs) { dev_err(&pdev->dev, "ioremap failed\n"); return -ENOMEM; } ret = udc_probe(&ci13xxx_msm_udc_driver, &pdev->dev, regs); if (ret < 0) { dev_err(&pdev->dev, "udc_probe failed\n"); goto iounmap; } irq = platform_get_irq(pdev, 0); if (irq < 0) { dev_err(&pdev->dev, "IRQ not found\n"); ret = -ENXIO; goto udc_remove; } ret = request_irq(irq, msm_udc_irq, IRQF_SHARED, pdev->name, pdev); if (ret < 0) { dev_err(&pdev->dev, "request_irq failed\n"); goto udc_remove; } pm_runtime_no_callbacks(&pdev->dev); pm_runtime_enable(&pdev->dev); return 0; udc_remove: udc_remove(); iounmap: iounmap(regs); return ret; }
static int sprd_sdio_card_probe(struct mmc_card *card) { struct mmc_host *host = card->host; if (mmc_card_sdio(card)) { if(host->caps & MMC_CAP_POWER_OFF_CARD) { pm_runtime_no_callbacks(&card->dev); // avoid default sdio bus runtime calling pm_suspend_ignore_children(mmc_classdev(host), false); // paired with remove function } return 0; } return -EINVAL; }
static int sprd_sdio_card_probe(struct mmc_card *card) { struct mmc_host *host = card->host; if (mmc_card_sdio(card)) { if(host->caps & MMC_CAP_POWER_OFF_CARD) { pm_runtime_no_callbacks(&card->dev); pm_suspend_ignore_children(mmc_classdev(host), false); return 0; } } return -EINVAL; }
static int ci13xxx_msm_probe(struct platform_device *pdev) { struct ci13xxx_msm_context *ctx; struct platform_device *plat_ci; struct resource *res; int ret, rc; struct ci13xxx_platform_data *pdata = pdev->dev.platform_data; dev_dbg(&pdev->dev, "ci13xxx_msm_probe\n"); ctx = devm_kzalloc(&pdev->dev, sizeof(*ctx), GFP_KERNEL); if (!ctx) return -ENOMEM; if (pdata) { /* Acceptable values for nz_itc are: 0,1,2,4,8,16,32,64 */ if (pdata->log2_itc > CI13XXX_MSM_MAX_LOG2_ITC || pdata->log2_itc <= 0) ci13xxx_msm_platdata.nz_itc = 0; else ci13xxx_msm_platdata.nz_itc = 1 << (pdata->log2_itc-1); ci13xxx_msm_platdata.l1_supported = pdata->l1_supported; } res = platform_get_resource_byname(pdev, IORESOURCE_IO, "USB_RESUME"); if (res) { ret = ci13xxx_msm_install_wake_gpio(pdev, res); if (ret < 0) { dev_err(&pdev->dev, "gpio irq install failed\n"); return ret; } } plat_ci = ci13xxx_add_device(&pdev->dev, pdev->resource, pdev->num_resources, &ci13xxx_msm_platdata); if (IS_ERR(plat_ci)) { dev_err(&pdev->dev, "ci13xxx_add_device failed!\n"); goto gpio_uninstall; } platform_set_drvdata(pdev, ctx); pm_runtime_no_callbacks(&pdev->dev); pm_runtime_enable(&pdev->dev); return 0; gpio_uninstall: ci13xxx_msm_uninstall_wake_gpio(pdev); return PTR_ERR(plat_ci); }
static int intel_th_probe(struct device *dev) { struct intel_th_driver *thdrv = to_intel_th_driver(dev->driver); struct intel_th_device *thdev = to_intel_th_device(dev); struct intel_th_driver *hubdrv; struct intel_th_device *hub = NULL; int ret; if (thdev->type == INTEL_TH_SWITCH) hub = thdev; else if (dev->parent) hub = to_intel_th_device(dev->parent); if (!hub || !hub->dev.driver) return -EPROBE_DEFER; hubdrv = to_intel_th_driver(hub->dev.driver); pm_runtime_set_active(dev); pm_runtime_no_callbacks(dev); pm_runtime_enable(dev); ret = thdrv->probe(to_intel_th_device(dev)); if (ret) goto out_pm; if (thdrv->attr_group) { ret = sysfs_create_group(&thdev->dev.kobj, thdrv->attr_group); if (ret) goto out; } if (thdev->type == INTEL_TH_OUTPUT && !intel_th_output_assigned(thdev)) /* does not talk to hardware */ ret = hubdrv->assign(hub, thdev); out: if (ret) thdrv->remove(thdev); out_pm: if (ret) pm_runtime_disable(dev); return ret; }
static int __devinit ci13xxx_msm_probe(struct platform_device *pdev) { struct platform_device *plat_ci; dev_dbg(&pdev->dev, "ci13xxx_msm_probe\n"); plat_ci = ci13xxx_add_device(&pdev->dev, pdev->resource, pdev->num_resources, &ci13xxx_msm_platdata); if (IS_ERR(plat_ci)) { dev_err(&pdev->dev, "ci13xxx_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 ci13xxx_msm_probe(struct platform_device *pdev) { struct resource *res; int ret; dev_dbg(&pdev->dev, "ci13xxx_msm_probe\n"); res = platform_get_resource(pdev, IORESOURCE_MEM, 0); if (!res) { dev_err(&pdev->dev, "failed to get platform resource mem\n"); return -ENXIO; } _udc_ctxt.regs = ioremap(res->start, resource_size(res)); if (!_udc_ctxt.regs) { dev_err(&pdev->dev, "ioremap failed\n"); return -ENOMEM; } ret = udc_probe(&ci13xxx_msm_udc_driver, &pdev->dev, _udc_ctxt.regs); if (ret < 0) { dev_err(&pdev->dev, "udc_probe failed\n"); goto iounmap; } _udc_ctxt.irq = platform_get_irq(pdev, 0); if (_udc_ctxt.irq < 0) { dev_err(&pdev->dev, "IRQ not found\n"); ret = -ENXIO; goto udc_remove; } res = platform_get_resource_byname(pdev, IORESOURCE_IO, "USB_RESUME"); if (res) { ret = ci13xxx_msm_install_wake_gpio(pdev, res); if (ret < 0) { dev_err(&pdev->dev, "gpio irq install failed\n"); goto udc_remove; } } ret = request_irq(_udc_ctxt.irq, msm_udc_irq, IRQF_SHARED, pdev->name, pdev); if (ret < 0) { dev_err(&pdev->dev, "request_irq failed\n"); goto gpio_uninstall; } pm_runtime_no_callbacks(&pdev->dev); pm_runtime_enable(&pdev->dev); return 0; gpio_uninstall: ci13xxx_msm_uninstall_wake_gpio(pdev); udc_remove: udc_remove(); iounmap: iounmap(_udc_ctxt.regs); return ret; }
static int __devinit dwc3_probe(struct platform_device *pdev) { struct device_node *node = pdev->dev.of_node; struct resource *res; struct dwc3 *dwc; struct device *dev = &pdev->dev; int ret = -ENOMEM; void __iomem *regs; void *mem; u8 mode; mem = devm_kzalloc(dev, sizeof(*dwc) + DWC3_ALIGN_MASK, GFP_KERNEL); if (!mem) { dev_err(dev, "not enough memory\n"); return -ENOMEM; } dwc = PTR_ALIGN(mem, DWC3_ALIGN_MASK + 1); dwc->mem = mem; res = platform_get_resource(pdev, IORESOURCE_IRQ, 0); if (!res) { dev_err(dev, "missing IRQ\n"); return -ENODEV; } dwc->xhci_resources[1] = *res; res = platform_get_resource(pdev, IORESOURCE_MEM, 0); if (!res) { dev_err(dev, "missing memory resource\n"); return -ENODEV; } dwc->xhci_resources[0] = *res; dwc->xhci_resources[0].end = dwc->xhci_resources[0].start + DWC3_XHCI_REGS_END; /* * Request memory region but exclude xHCI regs, * since it will be requested by the xhci-plat driver. */ res = devm_request_mem_region(dev, res->start + DWC3_GLOBALS_REGS_START, resource_size(res) - DWC3_GLOBALS_REGS_START, dev_name(dev)); if (!res) { dev_err(dev, "can't request mem region\n"); return -ENOMEM; } regs = devm_ioremap(dev, res->start, resource_size(res)); if (!regs) { dev_err(dev, "ioremap failed\n"); return -ENOMEM; } spin_lock_init(&dwc->lock); platform_set_drvdata(pdev, dwc); dwc->regs = regs; dwc->regs_size = resource_size(res); dwc->dev = dev; if (!strncmp("super", maximum_speed, 5)) dwc->maximum_speed = DWC3_DCFG_SUPERSPEED; else if (!strncmp("high", maximum_speed, 4)) dwc->maximum_speed = DWC3_DCFG_HIGHSPEED; else if (!strncmp("full", maximum_speed, 4)) dwc->maximum_speed = DWC3_DCFG_FULLSPEED1; else if (!strncmp("low", maximum_speed, 3)) dwc->maximum_speed = DWC3_DCFG_LOWSPEED; else dwc->maximum_speed = DWC3_DCFG_SUPERSPEED; if (of_get_property(node, "tx-fifo-resize", NULL)) dwc->needs_fifo_resize = true; pm_runtime_no_callbacks(dev); pm_runtime_set_active(dev); pm_runtime_enable(dev); ret = dwc3_core_init(dwc); if (ret) { dev_err(dev, "failed to initialize core\n"); return ret; } mode = DWC3_MODE(dwc->hwparams.hwparams0); switch (mode) { case DWC3_MODE_DEVICE: dwc3_set_mode(dwc, DWC3_GCTL_PRTCAP_DEVICE); ret = dwc3_gadget_init(dwc); if (ret) { dev_err(dev, "failed to initialize gadget\n"); goto err1; } break; case DWC3_MODE_HOST: dwc3_set_mode(dwc, DWC3_GCTL_PRTCAP_HOST); ret = dwc3_host_init(dwc); if (ret) { dev_err(dev, "failed to initialize host\n"); goto err1; } break; case DWC3_MODE_DRD: dwc3_set_mode(dwc, DWC3_GCTL_PRTCAP_OTG); ret = dwc3_otg_init(dwc); if (ret) { dev_err(dev, "failed to initialize otg\n"); goto err1; } ret = dwc3_host_init(dwc); if (ret) { dev_err(dev, "failed to initialize host\n"); dwc3_otg_exit(dwc); goto err1; } ret = dwc3_gadget_init(dwc); if (ret) { dev_err(dev, "failed to initialize gadget\n"); dwc3_host_exit(dwc); dwc3_otg_exit(dwc); goto err1; } break; default: dev_err(dev, "Unsupported mode of operation %d\n", mode); goto err1; } dwc->mode = mode; ret = dwc3_debugfs_init(dwc); if (ret) { dev_err(dev, "failed to initialize debugfs\n"); goto err2; } return 0; err2: switch (mode) { case DWC3_MODE_DEVICE: dwc3_gadget_exit(dwc); break; case DWC3_MODE_HOST: dwc3_host_exit(dwc); break; case DWC3_MODE_DRD: dwc3_gadget_exit(dwc); dwc3_host_exit(dwc); dwc3_otg_exit(dwc); break; default: /* do nothing */ break; } err1: dwc3_core_exit(dwc); return ret; }
static int __devinit sdhci_sprd_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; struct sdhci_host *host; struct resource *res; int ret, irq; #ifdef CONFIG_MMC_CARD_HOTPLUG int sd_detect_gpio; int detect_irq; #endif struct sprd_host_data *host_data; irq = platform_get_irq(pdev, 0); if (irq < 0) { dev_err(dev, "no irq specified\n"); return irq; } res = platform_get_resource(pdev, IORESOURCE_MEM, 0); if (!res) { dev_err(dev, "no memory specified\n"); return -ENOENT; } if(pdev->id == 0) { sd_buffer_pre_alloc(); } host = sdhci_alloc_host(dev, sizeof(struct sprd_host_data)); if (IS_ERR(host)) { dev_err(dev, "sdhci_alloc_host() failed\n"); return PTR_ERR(host); } host_data = sdhci_priv(host); host_data->platdata = dev_get_platdata(dev); host_data->clk_enable = 0; BUG_ON(NULL == host_data->platdata); printk("sdio probe %s, vdd %s (%d), clk %s parent %s\n", host_data->platdata->hw_name, host_data->platdata->vdd_name, host_data->platdata->volt_level, host_data->platdata->clk_name, host_data->platdata->clk_parent); platform_set_drvdata(pdev, host); host->vmmc = NULL; host->vmmc_ext = NULL; host->ioaddr = (void __iomem *)res->start; printk("sdio: host->ioaddr:0x%x\n", (u32)host->ioaddr); host->hw_name = (host_data->platdata->hw_name)? host_data->platdata->hw_name:pdev->name; host->ops = &sdhci_sprd_ops; host->quirks = SDHCI_QUIRK_BROKEN_TIMEOUT_VAL |\ SDHCI_QUIRK_DATA_TIMEOUT_USES_SDCLK |\ SDHCI_QUIRK_BROKEN_CARD_DETECTION|\ SDHCI_QUIRK_INVERTED_WRITE_PROTECT; host->irq = irq; #ifdef CONFIG_MMC_CARD_HOTPLUG sd_detect_gpio = host_data->platdata->detect_gpio; if(sd_detect_gpio > 0){ pr_info("%s, sd_detect_gpio:%d\n", __func__, sd_detect_gpio); if (0 == pdev->id){ ret = gpio_request(sd_detect_gpio, "sdio0_detect"); }else{ ret = gpio_request(sd_detect_gpio, "sdio1_detect"); } if (ret) { dev_err(dev, "cannot request gpio\n"); return -1; } ret = gpio_direction_input(sd_detect_gpio); if (ret) { dev_err(dev, "gpio can not change to input\n"); return -1; } detect_irq = gpio_to_irq(sd_detect_gpio); if (detect_irq < 0){ dev_err(dev, "cannot alloc detect irq\n"); return -1; } host_data->detect_irq = detect_irq; }else if (host_data->platdata->register_status_notify) { host_data->platdata->register_status_notify(sdhci_status_notify_cb, host); } else if (!host_data->platdata->status) { printk("%s: No card detect facilities available\n", mmc_hostname(host->mmc)); }else{ printk("%s, sd_detect_gpio == 0 \n", __func__ ); } #endif if(host_data->platdata->vdd_name) { host->vmmc = regulator_get(NULL, host_data->platdata->vdd_name); BUG_ON(IS_ERR(host->vmmc)); if(!is_sd_slot(host)) regulator_enable(host->vmmc); } if(host_data->platdata->vdd_ext_name) { host->vmmc_ext = regulator_get(NULL, host_data->platdata->vdd_ext_name); BUG_ON(IS_ERR(host->vmmc_ext)); regulator_enable(host->vmmc_ext); } host->clk = NULL; sdhci_module_init(host); switch(pdev->id) { case 0: host->mmc->pm_flags |= MMC_PM_ONLY_USED_SDIO0_SHARK; host->caps = sdhci_readl(host, SDHCI_CAPABILITIES) & (~(SDHCI_CAN_VDD_330 | SDHCI_CAN_VDD_180)); host->quirks |= SDHCI_QUIRK_MISSING_CAPS; host->mmc->pm_flags |= MMC_PM_IGNORE_PM_NOTIFY; break; case 1: host->mmc->pm_flags |= MMC_PM_IGNORE_PM_NOTIFY|MMC_PM_KEEP_POWER |MMC_PM_DISABLE_TIMEOUT_IRQ; host->mmc->pm_caps |= MMC_PM_KEEP_POWER |MMC_PM_DISABLE_TIMEOUT_IRQ; #ifdef CONFIG_SDIO_CARD host->mmc->caps |= MMC_CAP_4_BIT_DATA |MMC_CAP_NONREMOVABLE | MMC_CAP_POWER_OFF_CARD; #else host->mmc->caps |= MMC_CAP_4_BIT_DATA |MMC_CAP_NONREMOVABLE; #endif break; case 2: host->mmc->pm_flags |= MMC_PM_IGNORE_PM_NOTIFY | MMC_PM_KEEP_POWER; host->mmc->caps |= MMC_CAP_4_BIT_DATA | MMC_CAP_POWER_OFF_CARD; break; case 3: host->caps = sdhci_readl(host, SDHCI_CAPABILITIES) & (~(SDHCI_CAN_VDD_330 | SDHCI_CAN_VDD_300)); host->quirks |= SDHCI_QUIRK_MISSING_CAPS; host->mmc->pm_flags |= MMC_PM_IGNORE_PM_NOTIFY | MMC_PM_KEEP_POWER; host->mmc->caps |= MMC_CAP_NONREMOVABLE | MMC_CAP_8_BIT_DATA | MMC_CAP_HW_RESET; break; default: BUG(); break; } #ifdef CONFIG_PM_RUNTIME switch(pdev->id) { case 1: case 2: #ifdef CONFIG_SDIO_CARD pm_runtime_set_active(&pdev->dev); pm_runtime_set_autosuspend_delay(&pdev->dev, 100); pm_runtime_use_autosuspend(&pdev->dev); pm_runtime_enable(&pdev->dev); pm_runtime_no_callbacks(mmc_classdev(host->mmc)); pm_suspend_ignore_children(mmc_classdev(host->mmc), true); pm_runtime_set_active(mmc_classdev(host->mmc)); pm_runtime_enable(mmc_classdev(host->mmc)); #endif break; case 3: case 0: pm_suspend_ignore_children(&pdev->dev, true); pm_runtime_set_active(&pdev->dev); pm_runtime_set_autosuspend_delay(&pdev->dev, 100); pm_runtime_use_autosuspend(&pdev->dev); pm_runtime_enable(&pdev->dev); default: break; } #endif ret = sdhci_add_host(host); if (ret) { dev_err(dev, "sdhci_add_host() failed\n"); goto err_add_host; } #ifdef CONFIG_MMC_BUS_SCAN if (pdev->id == 1) sdhci_host_g = host; #endif return 0; err_add_host: #ifdef CONFIG_PM_RUNTIME pm_runtime_disable(&(pdev)->dev); pm_runtime_set_suspended(&(pdev)->dev); #endif if (host_data->clk_enable) { clk_disable(host->clk); host_data->clk_enable = 0; } sdhci_free_host(host); return ret; }
static int __devinit dwc3_probe(struct platform_device *pdev) { struct device_node *node = pdev->dev.of_node; struct resource *res; struct dwc3 *dwc; struct device *dev = &pdev->dev; int ret = -ENOMEM; void __iomem *regs; void *mem; u8 mode; bool host_only_mode; mem = devm_kzalloc(dev, sizeof(*dwc) + DWC3_ALIGN_MASK, GFP_KERNEL); if (!mem) { dev_err(dev, "not enough memory\n"); return -ENOMEM; } dwc = PTR_ALIGN(mem, DWC3_ALIGN_MASK + 1); dwc->mem = mem; if (!dev->dma_mask) dev->dma_mask = &dwc3_dma_mask; if (!dev->coherent_dma_mask) dev->coherent_dma_mask = DMA_BIT_MASK(64); dwc->notify_event = notify_event; res = platform_get_resource(pdev, IORESOURCE_IRQ, 0); if (!res) { dev_err(dev, "missing IRQ\n"); return -ENODEV; } dwc->xhci_resources[1].start = res->start; dwc->xhci_resources[1].end = res->end; dwc->xhci_resources[1].flags = res->flags; dwc->xhci_resources[1].name = res->name; res = platform_get_resource(pdev, IORESOURCE_MEM, 0); if (!res) { dev_err(dev, "missing memory resource\n"); return -ENODEV; } dwc->xhci_resources[0].start = res->start; dwc->xhci_resources[0].end = dwc->xhci_resources[0].start + DWC3_XHCI_REGS_END; dwc->xhci_resources[0].flags = res->flags; dwc->xhci_resources[0].name = res->name; /* * Request memory region but exclude xHCI regs, * since it will be requested by the xhci-plat driver. */ res = devm_request_mem_region(dev, res->start + DWC3_GLOBALS_REGS_START, resource_size(res) - DWC3_GLOBALS_REGS_START, dev_name(dev)); if (!res) { dev_err(dev, "can't request mem region\n"); return -ENOMEM; } regs = devm_ioremap_nocache(dev, res->start, resource_size(res)); if (!regs) { dev_err(dev, "ioremap failed\n"); return -ENOMEM; } spin_lock_init(&dwc->lock); platform_set_drvdata(pdev, dwc); dwc->regs = regs; dwc->regs_size = resource_size(res); dwc->dev = dev; if (!strncmp("super", maximum_speed, 5)) dwc->maximum_speed = DWC3_DCFG_SUPERSPEED; else if (!strncmp("high", maximum_speed, 4)) dwc->maximum_speed = DWC3_DCFG_HIGHSPEED; else if (!strncmp("full", maximum_speed, 4)) dwc->maximum_speed = DWC3_DCFG_FULLSPEED1; else if (!strncmp("low", maximum_speed, 3)) dwc->maximum_speed = DWC3_DCFG_LOWSPEED; else dwc->maximum_speed = DWC3_DCFG_SUPERSPEED; dwc->needs_fifo_resize = of_property_read_bool(node, "tx-fifo-resize"); host_only_mode = of_property_read_bool(node, "host-only-mode"); dwc->no_set_vbus_power = of_property_read_bool(node, "no-set-vbus-power"); pm_runtime_no_callbacks(dev); pm_runtime_set_active(dev); pm_runtime_enable(dev); ret = dwc3_core_init(dwc); if (ret) { dev_err(dev, "failed to initialize core\n"); return ret; } mode = DWC3_MODE(dwc->hwparams.hwparams0); /* Override mode if user selects host-only config with DRD core */ if (host_only_mode && (mode == DWC3_MODE_DRD)) { dev_dbg(dev, "host only mode selected\n"); mode = DWC3_MODE_HOST; } switch (mode) { case DWC3_MODE_DEVICE: dwc3_set_mode(dwc, DWC3_GCTL_PRTCAP_DEVICE); ret = dwc3_gadget_init(dwc); if (ret) { dev_err(dev, "failed to initialize gadget\n"); goto err1; } break; case DWC3_MODE_HOST: dwc3_set_mode(dwc, DWC3_GCTL_PRTCAP_HOST); ret = dwc3_host_init(dwc); if (ret) { dev_err(dev, "failed to initialize host\n"); goto err1; } break; case DWC3_MODE_DRD: dwc3_set_mode(dwc, DWC3_GCTL_PRTCAP_OTG); ret = dwc3_otg_init(dwc); if (ret) { dev_err(dev, "failed to initialize otg\n"); goto err1; } ret = dwc3_host_init(dwc); if (ret) { dev_err(dev, "failed to initialize host\n"); dwc3_otg_exit(dwc); goto err1; } ret = dwc3_gadget_init(dwc); if (ret) { dev_err(dev, "failed to initialize gadget\n"); dwc3_host_exit(dwc); dwc3_otg_exit(dwc); goto err1; } break; default: dev_err(dev, "Unsupported mode of operation %d\n", mode); goto err1; } dwc->mode = mode; ret = dwc3_debugfs_init(dwc); if (ret) { dev_err(dev, "failed to initialize debugfs\n"); goto err2; } dwc3_notify_event(dwc, DWC3_CONTROLLER_POST_INITIALIZATION_EVENT); return 0; err2: switch (mode) { case DWC3_MODE_DEVICE: dwc3_gadget_exit(dwc); break; case DWC3_MODE_HOST: dwc3_host_exit(dwc); break; case DWC3_MODE_DRD: dwc3_gadget_exit(dwc); dwc3_host_exit(dwc); dwc3_otg_exit(dwc); break; default: /* do nothing */ break; } err1: dwc3_core_exit(dwc); return ret; }
static int mfd_add_device(struct device *parent, int id, const struct mfd_cell *cell, struct resource *mem_base, int irq_base) { struct resource *res; struct platform_device *pdev; int ret = -ENOMEM; int r; pdev = platform_device_alloc(cell->name, id + cell->id); if (!pdev) goto fail_alloc; res = kzalloc(sizeof(*res) * cell->num_resources, GFP_KERNEL); if (!res) goto fail_device; pdev->dev.parent = parent; pdev->dev.type = &mfd_dev_type; if (cell->pdata_size) { ret = platform_device_add_data(pdev, cell->platform_data, cell->pdata_size); if (ret) goto fail_res; } ret = mfd_platform_add_cell(pdev, cell); if (ret) goto fail_res; for (r = 0; r < cell->num_resources; r++) { res[r].name = cell->resources[r].name; res[r].flags = cell->resources[r].flags; /* Find out base to use */ if ((cell->resources[r].flags & IORESOURCE_MEM) && mem_base) { res[r].parent = mem_base; res[r].start = mem_base->start + cell->resources[r].start; res[r].end = mem_base->start + cell->resources[r].end; } else if (cell->resources[r].flags & IORESOURCE_IRQ) { res[r].start = irq_base + cell->resources[r].start; res[r].end = irq_base + cell->resources[r].end; } else { res[r].parent = cell->resources[r].parent; res[r].start = cell->resources[r].start; res[r].end = cell->resources[r].end; } if (!cell->ignore_resource_conflicts) { ret = acpi_check_resource_conflict(&res[r]); if (ret) goto fail_res; } } ret = platform_device_add_resources(pdev, res, cell->num_resources); if (ret) goto fail_res; ret = platform_device_add(pdev); if (ret) goto fail_res; if (cell->pm_runtime_no_callbacks) pm_runtime_no_callbacks(&pdev->dev); kfree(res); return 0; fail_res: kfree(res); fail_device: platform_device_put(pdev); fail_alloc: return ret; }
static int ci13xxx_msm_probe(struct platform_device *pdev) { struct resource *res; int ret, rc; int itc_level = 0; dev_dbg(&pdev->dev, "ci13xxx_msm_probe\n"); if (pdev->dev.of_node) { rc = of_property_read_u32(pdev->dev.of_node, "qcom,itc-level", &itc_level); /* Acceptable values for nz_itc are: 0,1,2,4,8,16,32,64 */ if (itc_level > CI13XXX_MSM_MAX_ITC_LEVEL || rc) ci13xxx_msm_udc_driver.nz_itc = 0; else ci13xxx_msm_udc_driver.nz_itc = 1 << itc_level; } res = platform_get_resource(pdev, IORESOURCE_MEM, 0); if (!res) { dev_err(&pdev->dev, "failed to get platform resource mem\n"); return -ENXIO; } _udc_ctxt.regs = ioremap(res->start, resource_size(res)); if (!_udc_ctxt.regs) { dev_err(&pdev->dev, "ioremap failed\n"); return -ENOMEM; } ret = udc_probe(&ci13xxx_msm_udc_driver, &pdev->dev, _udc_ctxt.regs); if (ret < 0) { dev_err(&pdev->dev, "udc_probe failed\n"); goto iounmap; } _udc_ctxt.irq = platform_get_irq(pdev, 0); if (_udc_ctxt.irq < 0) { dev_err(&pdev->dev, "IRQ not found\n"); ret = -ENXIO; goto udc_remove; } res = platform_get_resource_byname(pdev, IORESOURCE_IO, "USB_RESUME"); if (res) { ret = ci13xxx_msm_install_wake_gpio(pdev, res); if (ret < 0) { dev_err(&pdev->dev, "gpio irq install failed\n"); goto udc_remove; } } ret = request_irq(_udc_ctxt.irq, msm_udc_irq, IRQF_SHARED, pdev->name, pdev); if (ret < 0) { dev_err(&pdev->dev, "request_irq failed\n"); goto gpio_uninstall; } pm_runtime_no_callbacks(&pdev->dev); pm_runtime_enable(&pdev->dev); return 0; gpio_uninstall: ci13xxx_msm_uninstall_wake_gpio(pdev); udc_remove: udc_remove(); iounmap: iounmap(_udc_ctxt.regs); return ret; }
static int xhci_plat_probe(struct platform_device *pdev) { const struct hc_driver *driver; struct xhci_hcd *xhci; struct resource *res; struct usb_hcd *hcd; int ret; int irq; if (usb_disabled()) return -ENODEV; driver = &xhci_plat_xhci_driver; irq = platform_get_irq(pdev, 0); if (irq < 0) return -ENODEV; res = platform_get_resource(pdev, IORESOURCE_MEM, 0); if (!res) return -ENODEV; hcd = usb_create_hcd(driver, &pdev->dev, dev_name(&pdev->dev)); if (!hcd) return -ENOMEM; hcd_to_bus(hcd)->skip_resume = true; hcd->rsrc_start = res->start; hcd->rsrc_len = resource_size(res); if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len, driver->description)) { dev_dbg(&pdev->dev, "controller already in use\n"); ret = -EBUSY; goto put_hcd; } hcd->regs = ioremap_nocache(hcd->rsrc_start, hcd->rsrc_len); if (!hcd->regs) { dev_dbg(&pdev->dev, "error mapping memory\n"); ret = -EFAULT; goto release_mem_region; } pm_runtime_set_active(&pdev->dev); pm_runtime_enable(&pdev->dev); pm_runtime_get_sync(&pdev->dev); ret = usb_add_hcd(hcd, irq, IRQF_SHARED); if (ret) goto unmap_registers; /* USB 2.0 roothub is stored in the platform_device now. */ hcd = dev_get_drvdata(&pdev->dev); xhci = hcd_to_xhci(hcd); xhci->shared_hcd = usb_create_shared_hcd(driver, &pdev->dev, dev_name(&pdev->dev), hcd); if (!xhci->shared_hcd) { ret = -ENOMEM; goto dealloc_usb2_hcd; } hcd_to_bus(xhci->shared_hcd)->skip_resume = true; /* * Set the xHCI pointer before xhci_plat_setup() (aka hcd_driver.reset) * is called by usb_add_hcd(). */ *((struct xhci_hcd **) xhci->shared_hcd->hcd_priv) = xhci; ret = usb_add_hcd(xhci->shared_hcd, irq, IRQF_SHARED); if (ret) goto put_usb3_hcd; phy = usb_get_transceiver(); /* Register with OTG if present, ignore USB2 OTG using other PHY */ if (phy && phy->otg && !(phy->flags & ENABLE_SECONDARY_PHY)) { dev_dbg(&pdev->dev, "%s otg support available\n", __func__); ret = otg_set_host(phy->otg, &hcd->self); if (ret) { dev_err(&pdev->dev, "%s otg_set_host failed\n", __func__); usb_put_transceiver(phy); goto put_usb3_hcd; } } else { pm_runtime_no_callbacks(&pdev->dev); } pm_runtime_put(&pdev->dev); return 0; put_usb3_hcd: usb_put_hcd(xhci->shared_hcd); dealloc_usb2_hcd: usb_remove_hcd(hcd); unmap_registers: iounmap(hcd->regs); release_mem_region: release_mem_region(hcd->rsrc_start, hcd->rsrc_len); put_hcd: usb_put_hcd(hcd); return ret; }
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 */ } };
static int ci13xxx_msm_probe(struct platform_device *pdev) { struct resource *res; int ret; struct ci13xxx_platform_data *pdata = pdev->dev.platform_data; bool is_l1_supported = false; dev_dbg(&pdev->dev, "ci13xxx_msm_probe\n"); if (pdata) { /* Acceptable values for nz_itc are: 0,1,2,4,8,16,32,64 */ if (pdata->log2_itc > CI13XXX_MSM_MAX_LOG2_ITC || pdata->log2_itc <= 0) ci13xxx_msm_udc_driver.nz_itc = 0; else ci13xxx_msm_udc_driver.nz_itc = 1 << (pdata->log2_itc-1); is_l1_supported = pdata->l1_supported; /* Set ahb2ahb bypass flag if it is requested. */ if (pdata->enable_ahb2ahb_bypass) ci13xxx_msm_udc_driver.flags |= CI13XXX_ENABLE_AHB2AHB_BYPASS; /* Clear disable streaming flag if is requested. */ if (pdata->enable_streaming) ci13xxx_msm_udc_driver.flags &= ~CI13XXX_DISABLE_STREAMING; } res = platform_get_resource(pdev, IORESOURCE_MEM, 0); if (!res) { dev_err(&pdev->dev, "failed to get platform resource mem\n"); return -ENXIO; } _udc_ctxt.regs = ioremap(res->start, resource_size(res)); if (!_udc_ctxt.regs) { dev_err(&pdev->dev, "ioremap failed\n"); return -ENOMEM; } ret = udc_probe(&ci13xxx_msm_udc_driver, &pdev->dev, _udc_ctxt.regs); if (ret < 0) { dev_err(&pdev->dev, "udc_probe failed\n"); goto iounmap; } _udc->gadget.l1_supported = is_l1_supported; _udc_ctxt.irq = platform_get_irq(pdev, 0); if (_udc_ctxt.irq < 0) { dev_err(&pdev->dev, "IRQ not found\n"); ret = -ENXIO; goto udc_remove; } res = platform_get_resource_byname(pdev, IORESOURCE_IO, "USB_RESUME"); /* Get pinctrl if target uses pinctrl */ _udc_ctxt.ci13xxx_pinctrl = devm_pinctrl_get(&pdev->dev); if (IS_ERR(_udc_ctxt.ci13xxx_pinctrl)) { if (of_property_read_bool(pdev->dev.of_node, "pinctrl-names")) { dev_err(&pdev->dev, "Error encountered while getting pinctrl"); ret = PTR_ERR(_udc_ctxt.ci13xxx_pinctrl); goto udc_remove; } dev_dbg(&pdev->dev, "Target does not use pinctrl\n"); _udc_ctxt.ci13xxx_pinctrl = NULL; } if (res) { ret = ci13xxx_msm_install_wake_gpio(pdev, res); if (ret < 0) { dev_err(&pdev->dev, "gpio irq install failed\n"); goto udc_remove; } } ret = request_irq(_udc_ctxt.irq, msm_udc_irq, IRQF_SHARED, pdev->name, pdev); if (ret < 0) { dev_err(&pdev->dev, "request_irq failed\n"); goto gpio_uninstall; } setup_timer(&_udc_ctxt.irq_enable_timer, enable_usb_irq_timer_func, (unsigned long)NULL); pm_runtime_no_callbacks(&pdev->dev); pm_runtime_set_active(&pdev->dev); pm_runtime_enable(&pdev->dev); return 0; gpio_uninstall: ci13xxx_msm_uninstall_wake_gpio(pdev); udc_remove: udc_remove(); iounmap: iounmap(_udc_ctxt.regs); return ret; }
static int ci13xxx_msm_probe(struct platform_device *pdev) { struct resource *res; int ret; #ifdef CONFIG_MACH_HTC struct usb_info *ui; #endif dev_dbg(&pdev->dev, "ci13xxx_msm_probe\n"); #ifdef CONFIG_MACH_HTC ui = kzalloc(sizeof(struct usb_info), GFP_KERNEL); if (!ui) return -ENOMEM; the_usb_info = ui; #endif res = platform_get_resource(pdev, IORESOURCE_MEM, 0); if (!res) { dev_err(&pdev->dev, "failed to get platform resource mem\n"); return -ENXIO; } _udc_ctxt.regs = ioremap(res->start, resource_size(res)); if (!_udc_ctxt.regs) { dev_err(&pdev->dev, "ioremap failed\n"); return -ENOMEM; } ret = udc_probe(&ci13xxx_msm_udc_driver, &pdev->dev, _udc_ctxt.regs); if (ret < 0) { dev_err(&pdev->dev, "udc_probe failed\n"); goto iounmap; } _udc_ctxt.irq = platform_get_irq(pdev, 0); if (_udc_ctxt.irq < 0) { dev_err(&pdev->dev, "IRQ not found\n"); ret = -ENXIO; goto udc_remove; } res = platform_get_resource_byname(pdev, IORESOURCE_IO, "USB_RESUME"); if (res) { ret = ci13xxx_msm_install_wake_gpio(pdev, res); if (ret < 0) { dev_err(&pdev->dev, "gpio irq install failed\n"); goto udc_remove; } } ret = request_irq(_udc_ctxt.irq, msm_udc_irq, IRQF_SHARED, pdev->name, pdev); if (ret < 0) { dev_err(&pdev->dev, "request_irq failed\n"); goto gpio_uninstall; } #ifdef CONFIG_MACH_HTC INIT_DELAYED_WORK(&ui->chg_stop, usb_chg_stop); #endif pm_runtime_no_callbacks(&pdev->dev); pm_runtime_enable(&pdev->dev); return 0; gpio_uninstall: ci13xxx_msm_uninstall_wake_gpio(pdev); udc_remove: udc_remove(); iounmap: iounmap(_udc_ctxt.regs); return ret; }
static int ci13xxx_msm_probe(struct platform_device *pdev) { struct resource *res; int ret; struct ci13xxx_platform_data *pdata = pdev->dev.platform_data; bool is_l1_supported = false; dev_dbg(&pdev->dev, "ci13xxx_msm_probe\n"); if (pdata) { /* Acceptable values for nz_itc are: 0,1,2,4,8,16,32,64 */ if (pdata->log2_itc > CI13XXX_MSM_MAX_LOG2_ITC || pdata->log2_itc <= 0) ci13xxx_msm_udc_driver.nz_itc = 0; else ci13xxx_msm_udc_driver.nz_itc = 1 << (pdata->log2_itc-1); is_l1_supported = pdata->l1_supported; } res = platform_get_resource(pdev, IORESOURCE_MEM, 0); if (!res) { dev_err(&pdev->dev, "failed to get platform resource mem\n"); return -ENXIO; } _udc_ctxt.regs = ioremap(res->start, resource_size(res)); if (!_udc_ctxt.regs) { dev_err(&pdev->dev, "ioremap failed\n"); return -ENOMEM; } ret = udc_probe(&ci13xxx_msm_udc_driver, &pdev->dev, _udc_ctxt.regs); if (ret < 0) { dev_err(&pdev->dev, "udc_probe failed\n"); goto iounmap; } _udc->gadget.l1_supported = is_l1_supported; _udc_ctxt.irq = platform_get_irq(pdev, 0); if (_udc_ctxt.irq < 0) { dev_err(&pdev->dev, "IRQ not found\n"); ret = -ENXIO; goto udc_remove; } res = platform_get_resource_byname(pdev, IORESOURCE_IO, "USB_RESUME"); if (res) { ret = ci13xxx_msm_install_wake_gpio(pdev, res); if (ret < 0) { dev_err(&pdev->dev, "gpio irq install failed\n"); goto udc_remove; } } ret = request_irq(_udc_ctxt.irq, msm_udc_irq, IRQF_SHARED, pdev->name, pdev); if (ret < 0) { dev_err(&pdev->dev, "request_irq failed\n"); goto gpio_uninstall; } pm_runtime_no_callbacks(&pdev->dev); pm_runtime_enable(&pdev->dev); return 0; gpio_uninstall: ci13xxx_msm_uninstall_wake_gpio(pdev); udc_remove: udc_remove(); iounmap: iounmap(_udc_ctxt.regs); return ret; }
static int ehci_msm_probe(struct platform_device *pdev) { struct usb_hcd *hcd; struct resource *res; struct usb_phy *phy; int ret; dev_dbg(&pdev->dev, "ehci_msm proble\n"); hcd = usb_create_hcd(&msm_hc_driver, &pdev->dev, dev_name(&pdev->dev)); if (!hcd) { dev_err(&pdev->dev, "Unable to create HCD\n"); return -ENOMEM; } hcd->irq = platform_get_irq(pdev, 0); if (hcd->irq < 0) { dev_err(&pdev->dev, "Unable to get IRQ resource\n"); ret = hcd->irq; goto put_hcd; } res = platform_get_resource(pdev, IORESOURCE_MEM, 0); if (!res) { dev_err(&pdev->dev, "Unable to get memory resource\n"); ret = -ENODEV; goto put_hcd; } hcd->rsrc_start = res->start; hcd->rsrc_len = resource_size(res); hcd->regs = devm_ioremap(&pdev->dev, hcd->rsrc_start, hcd->rsrc_len); if (!hcd->regs) { dev_err(&pdev->dev, "ioremap failed\n"); ret = -ENOMEM; goto put_hcd; } /* * OTG driver takes care of PHY initialization, clock management, * powering up VBUS, mapping of registers address space and power * management. */ if (pdev->dev.of_node) phy = devm_usb_get_phy_by_phandle(&pdev->dev, "usb-phy", 0); else phy = devm_usb_get_phy(&pdev->dev, USB_PHY_TYPE_USB2); if (IS_ERR(phy)) { dev_err(&pdev->dev, "unable to find transceiver\n"); ret = -EPROBE_DEFER; goto put_hcd; } ret = otg_set_host(phy->otg, &hcd->self); if (ret < 0) { dev_err(&pdev->dev, "unable to register with transceiver\n"); goto put_hcd; } hcd->phy = phy; device_init_wakeup(&pdev->dev, 1); /* * OTG device parent of HCD takes care of putting * hardware into low power mode. */ pm_runtime_no_callbacks(&pdev->dev); pm_runtime_enable(&pdev->dev); /* FIXME: need to call usb_add_hcd() here? */ return 0; put_hcd: usb_put_hcd(hcd); return ret; }
static int ci13xxx_msm_probe(struct platform_device *pdev) { struct resource *res; int ret; struct ci13xxx_platform_data *pdata = pdev->dev.platform_data; bool is_l1_supported = false; dev_dbg(&pdev->dev, "ci13xxx_msm_probe\n"); if (pdata) { /* Acceptable values for nz_itc are: 0,1,2,4,8,16,32,64 */ if (pdata->log2_itc > CI13XXX_MSM_MAX_LOG2_ITC || pdata->log2_itc <= 0) ci13xxx_msm_udc_driver.nz_itc = 0; else ci13xxx_msm_udc_driver.nz_itc = 1 << (pdata->log2_itc-1); is_l1_supported = pdata->l1_supported; /* Set ahb2ahb bypass flag if it is requested. */ if (pdata->enable_ahb2ahb_bypass) ci13xxx_msm_udc_driver.flags |= CI13XXX_ENABLE_AHB2AHB_BYPASS; } res = platform_get_resource(pdev, IORESOURCE_MEM, 0); if (!res) { dev_err(&pdev->dev, "failed to get platform resource mem\n"); return -ENXIO; } _udc_ctxt.regs = ioremap(res->start, resource_size(res)); if (!_udc_ctxt.regs) { dev_err(&pdev->dev, "ioremap failed\n"); return -ENOMEM; } ret = udc_probe(&ci13xxx_msm_udc_driver, &pdev->dev, _udc_ctxt.regs); if (ret < 0) { dev_err(&pdev->dev, "udc_probe failed\n"); goto iounmap; } _udc->gadget.l1_supported = is_l1_supported; _udc_ctxt.irq = platform_get_irq(pdev, 0); if (_udc_ctxt.irq < 0) { dev_err(&pdev->dev, "IRQ not found\n"); ret = -ENXIO; goto udc_remove; } res = platform_get_resource_byname(pdev, IORESOURCE_IO, "USB_RESUME"); if (res) { ret = ci13xxx_msm_install_wake_gpio(pdev, res); if (ret < 0) { dev_err(&pdev->dev, "gpio irq install failed\n"); goto udc_remove; } } ret = request_irq(_udc_ctxt.irq, msm_udc_irq, IRQF_SHARED, pdev->name, pdev); if (ret < 0) { dev_err(&pdev->dev, "request_irq failed\n"); goto gpio_uninstall; } #ifdef CONFIG_USB_G_LGE_ANDROID wake_lock_init(&_udc_ctxt.wlock, WAKE_LOCK_SUSPEND, "usb_bus_active"); INIT_DELAYED_WORK(&_udc_ctxt.wunlock_w, wunlock_w); #endif #ifdef CONFIG_LGE_PM_VZW_FAST_CHG INIT_DELAYED_WORK(&usb_detect_w, usb_detect_work); #endif pm_runtime_no_callbacks(&pdev->dev); pm_runtime_enable(&pdev->dev); return 0; gpio_uninstall: ci13xxx_msm_uninstall_wake_gpio(pdev); udc_remove: udc_remove(); iounmap: iounmap(_udc_ctxt.regs); return ret; }
static int dwc3_probe(struct platform_device *pdev) { struct device_node *node = pdev->dev.of_node; struct resource *res; struct dwc3 *dwc; struct device *dev = &pdev->dev; int ret = -ENOMEM; void __iomem *regs; void *mem; u8 mode; bool host_only_mode; mem = devm_kzalloc(dev, sizeof(*dwc) + DWC3_ALIGN_MASK, GFP_KERNEL); if (!mem) { dev_err(dev, "not enough memory\n"); return -ENOMEM; } dwc = PTR_ALIGN(mem, DWC3_ALIGN_MASK + 1); dwc->mem = mem; dwc->notify_event = notify_event; res = platform_get_resource(pdev, IORESOURCE_IRQ, 0); if (!res) { dev_err(dev, "missing IRQ\n"); return -ENODEV; } dwc->xhci_resources[1].start = res->start; dwc->xhci_resources[1].end = res->end; dwc->xhci_resources[1].flags = res->flags; dwc->xhci_resources[1].name = res->name; res = platform_get_resource(pdev, IORESOURCE_MEM, 0); if (!res) { dev_err(dev, "missing memory resource\n"); return -ENODEV; } dwc->xhci_resources[0].start = res->start; dwc->xhci_resources[0].end = dwc->xhci_resources[0].start + DWC3_XHCI_REGS_END; dwc->xhci_resources[0].flags = res->flags; dwc->xhci_resources[0].name = res->name; /* * Request memory region but exclude xHCI regs, * since it will be requested by the xhci-plat driver. */ res = devm_request_mem_region(dev, res->start + DWC3_GLOBALS_REGS_START, resource_size(res) - DWC3_GLOBALS_REGS_START, dev_name(dev)); if (!res) { dev_err(dev, "can't request mem region\n"); return -ENOMEM; } regs = devm_ioremap_nocache(dev, res->start, resource_size(res)); if (!regs) { dev_err(dev, "ioremap failed\n"); return -ENOMEM; } dwc->core_reset_after_phy_init = of_property_read_bool(node, "core_reset_after_phy_init"); dwc->needs_fifo_resize = of_property_read_bool(node, "tx-fifo-resize"); host_only_mode = of_property_read_bool(node, "host-only-mode"); dwc->maximum_speed = of_usb_get_maximum_speed(node); if (node) { dwc->usb2_phy = devm_usb_get_phy_by_phandle(dev, "usb-phy", 0); dwc->usb3_phy = devm_usb_get_phy_by_phandle(dev, "usb-phy", 1); } else { dwc->usb2_phy = devm_usb_get_phy(dev, USB_PHY_TYPE_USB2); dwc->usb3_phy = devm_usb_get_phy(dev, USB_PHY_TYPE_USB3); } /* default to superspeed if no maximum_speed passed */ if (dwc->maximum_speed == USB_SPEED_UNKNOWN) dwc->maximum_speed = USB_SPEED_SUPER; if (IS_ERR(dwc->usb2_phy)) { ret = PTR_ERR(dwc->usb2_phy); /* * if -ENXIO is returned, it means PHY layer wasn't * enabled, so it makes no sense to return -EPROBE_DEFER * in that case, since no PHY driver will ever probe. */ if (ret == -ENXIO) return ret; dev_err(dev, "no usb2 phy configured\n"); return -EPROBE_DEFER; } if (IS_ERR(dwc->usb3_phy)) { ret = PTR_ERR(dwc->usb2_phy); /* * if -ENXIO is returned, it means PHY layer wasn't * enabled, so it makes no sense to return -EPROBE_DEFER * in that case, since no PHY driver will ever probe. */ if (ret == -ENXIO) return ret; dev_err(dev, "no usb3 phy configured\n"); return -EPROBE_DEFER; } usb_phy_set_suspend(dwc->usb2_phy, 0); usb_phy_set_suspend(dwc->usb3_phy, 0); spin_lock_init(&dwc->lock); platform_set_drvdata(pdev, dwc); dwc->regs = regs; dwc->regs_size = resource_size(res); dwc->dev = dev; dev->dma_mask = dev->parent->dma_mask; dev->dma_parms = dev->parent->dma_parms; dma_set_coherent_mask(dev, dev->parent->coherent_dma_mask); pm_runtime_no_callbacks(dev); pm_runtime_set_active(dev); pm_runtime_enable(dev); dwc3_cache_hwparams(dwc); if (!dwc->ev_buffs) { ret = dwc3_alloc_event_buffers(dwc, DWC3_EVENT_BUFFERS_SIZE); if (ret) { dev_err(dwc->dev, "failed to allocate event buffers\n"); ret = -ENOMEM; goto err0; } } dwc->nominal_elastic_buffer = of_property_read_bool(node, "nominal-elastic-buffer"); ret = dwc3_core_init(dwc); if (ret) { dev_err(dev, "failed to initialize core\n"); goto err0; } ret = dwc3_event_buffers_setup(dwc); if (ret) { dev_err(dwc->dev, "failed to setup event buffers\n"); goto err1; } if (IS_ENABLED(CONFIG_USB_DWC3_HOST)) mode = DWC3_MODE_HOST; else if (IS_ENABLED(CONFIG_USB_DWC3_GADGET)) mode = DWC3_MODE_DEVICE; else mode = DWC3_MODE_DRD; /* Override mode if user selects host-only config with DRD core */ if (host_only_mode && (mode == DWC3_MODE_DRD)) { dev_dbg(dev, "host only mode selected\n"); mode = DWC3_MODE_HOST; } switch (mode) { case DWC3_MODE_DEVICE: dwc3_set_mode(dwc, DWC3_GCTL_PRTCAP_DEVICE); ret = dwc3_gadget_init(dwc); if (ret) { dev_err(dev, "failed to initialize gadget\n"); goto err2; } break; case DWC3_MODE_HOST: dwc3_set_mode(dwc, DWC3_GCTL_PRTCAP_HOST); ret = dwc3_host_init(dwc); if (ret) { dev_err(dev, "failed to initialize host\n"); goto err2; } break; case DWC3_MODE_DRD: dwc3_set_mode(dwc, DWC3_GCTL_PRTCAP_OTG); ret = dwc3_otg_init(dwc); if (ret) { dev_err(dev, "failed to initialize otg\n"); goto err1; } ret = dwc3_host_init(dwc); if (ret) { dev_err(dev, "failed to initialize host\n"); dwc3_otg_exit(dwc); goto err1; } ret = dwc3_gadget_init(dwc); if (ret) { dev_err(dev, "failed to initialize gadget\n"); dwc3_host_exit(dwc); dwc3_otg_exit(dwc); goto err2; } break; default: dev_err(dev, "Unsupported mode of operation %d\n", mode); goto err2; } dwc->mode = mode; ret = dwc3_debugfs_init(dwc); if (ret) { dev_err(dev, "failed to initialize debugfs\n"); goto err3; } dwc3_notify_event(dwc, DWC3_CONTROLLER_POST_INITIALIZATION_EVENT); return 0; err3: switch (mode) { case DWC3_MODE_DEVICE: dwc3_gadget_exit(dwc); break; case DWC3_MODE_HOST: dwc3_host_exit(dwc); break; case DWC3_MODE_DRD: dwc3_gadget_exit(dwc); dwc3_host_exit(dwc); dwc3_otg_exit(dwc); break; default: /* do nothing */ break; } err2: dwc3_event_buffers_cleanup(dwc); err1: dwc3_core_exit(dwc); err0: dwc3_free_event_buffers(dwc); return ret; }
static int __devinit ci13xxx_imx_probe(struct platform_device *pdev) { struct ci13xxx_imx_data *data; struct platform_device *plat_ci, *phy_pdev; struct device_node *phy_np; struct resource *res; struct regulator *reg_vbus; struct pinctrl *pinctrl; int ret; if (of_find_property(pdev->dev.of_node, "fsl,usbmisc", NULL) && !usbmisc_ops) return -EPROBE_DEFER; data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL); if (!data) { dev_err(&pdev->dev, "Failed to allocate CI13xxx-IMX data!\n"); return -ENOMEM; } res = platform_get_resource(pdev, IORESOURCE_MEM, 0); if (!res) { dev_err(&pdev->dev, "Can't get device resources!\n"); return -ENOENT; } pinctrl = devm_pinctrl_get_select_default(&pdev->dev); if (IS_ERR(pinctrl)) dev_warn(&pdev->dev, "pinctrl get/select failed, err=%ld\n", PTR_ERR(pinctrl)); 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; } phy_np = of_parse_phandle(pdev->dev.of_node, "fsl,usbphy", 0); if (phy_np) { data->phy_np = phy_np; phy_pdev = of_find_device_by_node(phy_np); if (phy_pdev) { struct usb_phy *phy; phy = pdev_to_phy(phy_pdev); if (phy && try_module_get(phy_pdev->dev.driver->owner)) { usb_phy_init(phy); data->phy = phy; } } } /* we only support host now, so enable vbus here */ reg_vbus = devm_regulator_get(&pdev->dev, "vbus"); if (!IS_ERR(reg_vbus)) { ret = regulator_enable(reg_vbus); if (ret) { dev_err(&pdev->dev, "Failed to enable vbus regulator, err=%d\n", ret); goto put_np; } data->reg_vbus = reg_vbus; } else { reg_vbus = NULL; } ci13xxx_imx_platdata.phy = data->phy; if (!pdev->dev.dma_mask) { pdev->dev.dma_mask = devm_kzalloc(&pdev->dev, sizeof(*pdev->dev.dma_mask), GFP_KERNEL); if (!pdev->dev.dma_mask) { ret = -ENOMEM; dev_err(&pdev->dev, "Failed to alloc dma_mask!\n"); goto err; } *pdev->dev.dma_mask = DMA_BIT_MASK(32); dma_set_coherent_mask(&pdev->dev, *pdev->dev.dma_mask); } if (usbmisc_ops && usbmisc_ops->init) { ret = usbmisc_ops->init(&pdev->dev); if (ret) { dev_err(&pdev->dev, "usbmisc init failed, ret=%d\n", ret); goto err; } } plat_ci = ci13xxx_add_device(&pdev->dev, pdev->resource, pdev->num_resources, &ci13xxx_imx_platdata); if (IS_ERR(plat_ci)) { ret = PTR_ERR(plat_ci); dev_err(&pdev->dev, "Can't register ci_hdrc platform device, err=%d\n", ret); goto err; } data->ci_pdev = plat_ci; platform_set_drvdata(pdev, data); pm_runtime_no_callbacks(&pdev->dev); pm_runtime_enable(&pdev->dev); return 0; err: if (reg_vbus) regulator_disable(reg_vbus); put_np: if (phy_np) of_node_put(phy_np); clk_disable_unprepare(data->clk); return ret; }
static int xhci_dwc_drv_probe(struct platform_device *pdev) { struct dwc_otg2 *otg; struct usb_phy *usb_phy; struct dwc_device_par *pdata; struct usb_hcd *hcd; struct resource *res; int retval = 0; int ret; if (usb_disabled()) return -ENODEV; pr_debug("initializing FSL-SOC USB Controller\n"); /* Need platform data for setup */ pdata = (struct dwc_device_par *)pdev->dev.platform_data; if (!pdata) { dev_err(&pdev->dev, "No platform data for %s.\n", dev_name(&pdev->dev)); return -ENODEV; } res = platform_get_resource(pdev, IORESOURCE_IRQ, 0); if (!res) { dev_err(&pdev->dev, "Found HC with no IRQ. Check %s setup!\n", dev_name(&pdev->dev)); return -ENODEV; } dwc3_xhci.otg_irqnum = res->start; hcd = usb_create_hcd(&xhci_dwc_hc_driver, &pdev->dev, dev_name(&pdev->dev)); if (!hcd) { retval = -ENOMEM; return retval; } hcd->regs = pdata->io_addr; res = platform_get_resource(pdev, IORESOURCE_MEM, 0); if (!res) { dev_err(&pdev->dev, "Found HC with no IRQ. Check %s setup!\n", dev_name(&pdev->dev)); return -ENODEV; } hcd->rsrc_start = res->start; hcd->rsrc_len = res->end - res->start; usb_phy = usb_get_phy(USB_PHY_TYPE_USB2); if (usb_phy) otg_set_host(usb_phy->otg, &hcd->self); otg = container_of(usb_phy->otg, struct dwc_otg2, otg); if (otg) { otg->start_host = dwc3_start_host; otg->stop_host = dwc3_stop_host; otg->suspend_host = dwc3_suspend_host; otg->resume_host = dwc3_resume_host; } usb_put_phy(usb_phy); /* Enable wakeup irq */ hcd->has_wakeup_irq = 1; INIT_WORK(&dwc3_xhci.reset_hcd, dwc3_host_reset); INIT_WORK(&dwc3_xhci.poll_loopback, dwc3_poll_lp); wake_lock_init(&dwc3_xhci.wakelock, WAKE_LOCK_SUSPEND, "dwc3_host_wakelock"); platform_set_drvdata(pdev, hcd); pm_runtime_no_callbacks(hcd->self.controller); pm_runtime_enable(hcd->self.controller); ret = device_create_file(hcd->self.controller, &dev_attr_host_comp_test); if (ret < 0) dev_err(hcd->self.controller, "Can't register sysfs attribute: %d\n", ret); return retval; }
static int ehci_msm_probe(struct platform_device *pdev) { struct usb_hcd *hcd; struct resource *res; int ret; dev_dbg(&pdev->dev, "ehci_msm proble\n"); hcd = usb_create_hcd(&msm_hc_driver, &pdev->dev, dev_name(&pdev->dev)); if (!hcd) { dev_err(&pdev->dev, "Unable to create HCD\n"); return -ENOMEM; } hcd->irq = platform_get_irq(pdev, 0); if (hcd->irq < 0) { dev_err(&pdev->dev, "Unable to get IRQ resource\n"); ret = hcd->irq; goto put_hcd; } res = platform_get_resource(pdev, IORESOURCE_MEM, 0); if (!res) { dev_err(&pdev->dev, "Unable to get memory resource\n"); ret = -ENODEV; goto put_hcd; } hcd->rsrc_start = res->start; hcd->rsrc_len = resource_size(res); hcd->regs = ioremap(hcd->rsrc_start, hcd->rsrc_len); if (!hcd->regs) { dev_err(&pdev->dev, "ioremap failed\n"); ret = -ENOMEM; goto put_hcd; } /* * OTG driver takes care of PHY initialization, clock management, * powering up VBUS, mapping of registers address space and power * management. */ otg = otg_get_transceiver(); if (!otg) { dev_err(&pdev->dev, "unable to find transceiver\n"); ret = -ENODEV; goto unmap; } ret = otg_set_host(otg, &hcd->self); if (ret < 0) { dev_err(&pdev->dev, "unable to register with transceiver\n"); goto put_transceiver; } device_init_wakeup(&pdev->dev, 1); /* * OTG device parent of HCD takes care of putting * hardware into low power mode. */ pm_runtime_no_callbacks(&pdev->dev); pm_runtime_enable(&pdev->dev); return 0; put_transceiver: otg_put_transceiver(otg); unmap: iounmap(hcd->regs); put_hcd: usb_put_hcd(hcd); return ret; }