/** * ufshcd_pci_probe - probe routine of the driver * @pdev: pointer to PCI device handle * @id: PCI device id * * Returns 0 on success, non-zero value on failure */ static int ufshcd_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id) { struct ufs_hba *hba; void __iomem *mmio_base; int err; err = pcim_enable_device(pdev); if (err) { dev_err(&pdev->dev, "pcim_enable_device failed\n"); return err; } pci_set_master(pdev); err = pcim_iomap_regions(pdev, 1 << 0, UFSHCD); if (err < 0) { dev_err(&pdev->dev, "request and iomap failed\n"); return err; } mmio_base = pcim_iomap_table(pdev)[0]; err = ufshcd_alloc_host(&pdev->dev, &hba); if (err) { dev_err(&pdev->dev, "Allocation failed\n"); return err; } INIT_LIST_HEAD(&hba->clk_list_head); err = ufshcd_init(hba, mmio_base, pdev->irq); if (err) { dev_err(&pdev->dev, "Initialization failed\n"); ufshcd_dealloc_host(hba); return err; } pci_set_drvdata(pdev, hba); pm_runtime_put_noidle(&pdev->dev); pm_runtime_allow(&pdev->dev); return 0; }
/** * ufshcd_pltfrm_init - probe routine of the driver * @pdev: pointer to Platform device handle * @vops: pointer to variant ops * * Returns 0 on success, non-zero value on failure */ int ufshcd_pltfrm_init(struct platform_device *pdev, struct ufs_hba_variant_ops *vops) { struct ufs_hba *hba; void __iomem *mmio_base; struct resource *mem_res; int irq, err; struct device *dev = &pdev->dev; mem_res = platform_get_resource(pdev, IORESOURCE_MEM, 0); mmio_base = devm_ioremap_resource(dev, mem_res); if (IS_ERR(*(void **)&mmio_base)) { err = PTR_ERR(*(void **)&mmio_base); goto out; } irq = platform_get_irq(pdev, 0); if (irq < 0) { dev_err(dev, "IRQ resource not available\n"); err = -ENODEV; goto out; } err = ufshcd_alloc_host(dev, &hba); if (err) { dev_err(&pdev->dev, "Allocation failed\n"); goto out; } hba->vops = vops; err = ufshcd_parse_clock_info(hba); if (err) { dev_err(&pdev->dev, "%s: clock parse failed %d\n", __func__, err); goto dealloc_host; } err = ufshcd_parse_regulator_info(hba); if (err) { dev_err(&pdev->dev, "%s: regulator init failed %d\n", __func__, err); goto dealloc_host; } pm_runtime_set_active(&pdev->dev); pm_runtime_enable(&pdev->dev); ufshcd_init_lanes_per_dir(hba); err = ufshcd_init(hba, mmio_base, irq); if (err) { dev_err(dev, "Initialization failed\n"); goto out_disable_rpm; } platform_set_drvdata(pdev, hba); return 0; out_disable_rpm: pm_runtime_disable(&pdev->dev); pm_runtime_set_suspended(&pdev->dev); dealloc_host: ufshcd_dealloc_host(hba); out: return err; }