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); }