static int imx_pata_probe(struct device_d *dev) { struct ide_port *ide; struct clk *clk; void __iomem *base; int ret; const char *devname = NULL; ide = xzalloc(sizeof(*ide)); base = dev_request_mem_region(dev, 0); clk = clk_get(dev, NULL); if (IS_ERR(clk)) { ret = PTR_ERR(clk); goto out_free; } imx_pata_setup_port(base + PATA_IMX_DRIVE_DATA, base + PATA_IMX_DRIVE_CONTROL, &ide->io, 2); /* deassert resets */ writel(PATA_IMX_ATA_CTRL_FIFO_RST_B | PATA_IMX_ATA_CTRL_ATA_RST_B, base + PATA_IMX_ATA_CONTROL); pata_imx_set_bus_timing(base, clk_get_rate(clk), 4); if (IS_ENABLED(CONFIG_OFDEVICE)) { devname = of_alias_get(dev->device_node); if (devname) devname = xstrdup(devname); } ide->port.dev = dev; ide->port.devname = devname; dev->priv = ide; dev->detect = pata_imx_detect; ret = ide_port_register(ide); if (ret) { dev_err(dev, "Cannot register IDE interface: %s\n", strerror(-ret)); goto out_free_clk; } return 0; out_free_clk: clk_put(clk); out_free: free(ide); return ret; }
static int dw_mmc_probe(struct device_d *dev) { struct resource *iores; struct dwmci_host *host; struct dw_mmc_platform_data *pdata = dev->platform_data; host = xzalloc(sizeof(*host)); host->clk_biu = clk_get(dev, "biu"); if (IS_ERR(host->clk_biu)) return PTR_ERR(host->clk_biu); host->clk_ciu = clk_get(dev, "ciu"); if (IS_ERR(host->clk_ciu)) return PTR_ERR(host->clk_ciu); clk_enable(host->clk_biu); clk_enable(host->clk_ciu); host->dev = dev; iores = dev_request_mem_resource(dev, 0); if (IS_ERR(iores)) return PTR_ERR(iores); host->ioaddr = IOMEM(iores->start); host->idmac = dma_alloc_coherent(sizeof(*host->idmac) * DW_MMC_NUM_IDMACS, DMA_ADDRESS_BROKEN); host->mci.send_cmd = dwmci_cmd; host->mci.set_ios = dwmci_set_ios; host->mci.init = dwmci_init; host->mci.card_present = dwmci_card_present; host->mci.hw_dev = dev; host->mci.voltages = MMC_VDD_32_33 | MMC_VDD_33_34; host->mci.host_caps = MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA; host->mci.host_caps |= MMC_CAP_MMC_HIGHSPEED | MMC_CAP_MMC_HIGHSPEED_52MHZ | MMC_CAP_SD_HIGHSPEED; if (pdata) { host->ciu_div = pdata->ciu_div; host->mci.host_caps &= ~MMC_CAP_BIT_DATA_MASK; host->mci.host_caps |= pdata->bus_width_caps; } else if (dev->device_node) { const char *alias = of_alias_get(dev->device_node); if (alias) host->mci.devname = xstrdup(alias); of_property_read_u32(dev->device_node, "dw-mshc-ciu-div", &host->ciu_div); } /* divider is 0 based in pdata and 1 based in our private struct */ host->ciu_div++; if (of_device_is_compatible(dev->device_node, "rockchip,rk2928-dw-mshc")) host->pwren_value = 0; else host->pwren_value = 1; dev->detect = dw_mmc_detect; host->clkrate = clk_get_rate(host->clk_ciu); host->mci.f_min = host->clkrate / 510 / host->ciu_div; if (host->mci.f_min < 200000) host->mci.f_min = 200000; host->mci.f_max = host->clkrate / host->ciu_div; mci_of_parse(&host->mci); dev->priv = host; return mci_register(&host->mci); }
static int dw_mmc_probe(struct device_d *dev) { struct dwmci_host *host; struct mci_host *mci; struct dw_mmc_platform_data *pdata = dev->platform_data; host = xzalloc(sizeof(*host)); mci = &host->mci; host->clk_biu = clk_get(dev, "biu"); if (IS_ERR(host->clk_biu)) return PTR_ERR(host->clk_biu); host->clk_ciu = clk_get(dev, "ciu"); if (IS_ERR(host->clk_ciu)) return PTR_ERR(host->clk_ciu); clk_enable(host->clk_biu); clk_enable(host->clk_ciu); host->dev = dev; host->ioaddr = dev_request_mem_region(dev, 0); if (!host->ioaddr) return -EBUSY; if (pdata) { mci->devname = pdata->devname; host->ciu_div = pdata->ciu_div; } else if (dev->device_node) { const char *alias = of_alias_get(dev->device_node); if (alias) mci->devname = xstrdup(alias); of_property_read_u32(dev->device_node, "dw-mshc-ciu-div", &host->ciu_div); } /* divider is 0 based in pdata and 1 based in our private struct */ host->ciu_div++; host->idmac = dma_alloc_coherent(sizeof(*host->idmac) * DW_MMC_NUM_IDMACS); host->mci.send_cmd = dwmci_cmd; host->mci.set_ios = dwmci_set_ios; host->mci.init = dwmci_init; host->mci.card_present = dwmci_card_present; host->mci.hw_dev = dev; host->mci.voltages = MMC_VDD_32_33 | MMC_VDD_33_34; host->mci.host_caps = MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA; dev->detect = dw_mmc_detect; host->clkrate = clk_get_rate(host->clk_ciu); host->mci.f_min = host->clkrate / 510 / host->ciu_div; if (host->mci.f_min < 200000) host->mci.f_min = 200000; host->mci.f_max = host->clkrate / host->ciu_div; mci_of_parse(&host->mci); dev->priv = host; return mci_register(&host->mci); }
static int state_probe(struct device_d *dev) { struct device_node *np = dev->device_node; struct device_node *partition_node; struct state *state; const char *alias; const char *backend_type = NULL; int len, ret; const char *of_path; char *path; if (!np) return -EINVAL; alias = of_alias_get(np); if (!alias) alias = np->name; state = state_new_from_node(alias, np); if (IS_ERR(state)) return PTR_ERR(state); of_path = of_get_property(np, "backend", &len); if (!of_path) { ret = -ENODEV; goto out_release; } /* guess if of_path is a path, not a phandle */ if (of_path[0] == '/' && len > 1) { ret = of_find_path(np, "backend", &path, 0); } else { partition_node = of_parse_phandle(np, "backend", 0); if (!partition_node) return -EINVAL; of_path = partition_node->full_name; ret = of_find_path_by_node(partition_node, &path, 0); } if (ret == -ENODEV) ret = -EPROBE_DEFER; if (ret) goto out_release; ret = of_property_read_string(np, "backend-type", &backend_type); if (ret) { goto out_free; } else if (!strcmp(backend_type, "raw")) { ret = state_backend_raw_file(state, of_path, path, 0, 0); } else if (!strcmp(backend_type, "dtb")) { ret = state_backend_dtb_file(state, of_path, path); } else { dev_warn(dev, "invalid backend type: %s\n", backend_type); ret = -ENODEV; goto out_free; } if (ret) goto out_free; dev_info(dev, "backend: %s, path: %s, of_path: %s\n", backend_type, path, of_path); free(path); return 0; out_free: free(path); out_release: state_release(state); return ret; }