diff options
author | Sascha Hauer <s.hauer@pengutronix.de> | 2015-12-08 08:28:20 +0100 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2015-12-08 08:28:20 +0100 |
commit | 4b1430b653d73635ffbd6ac45e39fad891b2d9e2 (patch) | |
tree | 84678671ca24b954833418493c043437f4c67302 /drivers | |
parent | 24f1c994cc7ae61e3eee1b34b114315833a4186f (diff) | |
parent | 9d0ff0aa79ccc40820ce5f581733df08b74e5800 (diff) | |
download | barebox-4b1430b653d73635ffbd6ac45e39fad891b2d9e2.tar.gz barebox-4b1430b653d73635ffbd6ac45e39fad891b2d9e2.tar.xz |
Merge branch 'for-next/mmc'
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/mci/dw_mmc.c | 31 | ||||
-rw-r--r-- | drivers/mci/mci-core.c | 38 |
2 files changed, 38 insertions, 31 deletions
diff --git a/drivers/mci/dw_mmc.c b/drivers/mci/dw_mmc.c index acdf795ac1..cbd3f00646 100644 --- a/drivers/mci/dw_mmc.c +++ b/drivers/mci/dw_mmc.c @@ -676,11 +676,9 @@ static int dw_mmc_detect(struct device_d *dev) 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)) @@ -698,13 +696,27 @@ static int dw_mmc_probe(struct device_d *dev) if (IS_ERR(host->ioaddr)) return PTR_ERR(host->ioaddr); + 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) { - mci->devname = pdata->devname; 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) - mci->devname = xstrdup(alias); + host->mci.devname = xstrdup(alias); of_property_read_u32(dev->device_node, "dw-mshc-ciu-div", &host->ciu_div); } @@ -712,17 +724,6 @@ static int dw_mmc_probe(struct device_d *dev) /* 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, - 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; - if (of_device_is_compatible(dev->device_node, "rockchip,rk2928-dw-mshc")) host->pwren_value = 0; diff --git a/drivers/mci/mci-core.c b/drivers/mci/mci-core.c index 29c0d5474e..4e6b83be5f 100644 --- a/drivers/mci/mci-core.c +++ b/drivers/mci/mci-core.c @@ -1819,23 +1819,29 @@ void mci_of_parse(struct mci_host *host) /* "bus-width" is translated to MMC_CAP_*_BIT_DATA flags */ if (of_property_read_u32(np, "bus-width", &bus_width) < 0) { + /* If bus-width is missing we get the driver's default, which + * is, unfortunately, not consistent from driver to driver. + * Better to specify it in the device tree. */ dev_dbg(host->hw_dev, - "\"bus-width\" property is missing, assuming 1 bit.\n"); - bus_width = 1; - } - - switch (bus_width) { - case 8: - host->host_caps |= MMC_CAP_8_BIT_DATA; - /* Hosts capable of 8-bit transfers can also do 4 bits */ - case 4: - host->host_caps |= MMC_CAP_4_BIT_DATA; - break; - case 1: - break; - default: - dev_err(host->hw_dev, - "Invalid \"bus-width\" value %u!\n", bus_width); + "\"bus-width\" property missing, default is %d\n", + (host->host_caps & MMC_CAP_8_BIT_DATA) ? 8 : + (host->host_caps & MMC_CAP_4_BIT_DATA) ? 4 : 1); + } else { + /* Set data width caps to exactly those specified in the DT. + * bus-width isn't a list, so widths smaller than the specified + * value are implictly supported as well. */ + host->host_caps &= ~MMC_CAP_BIT_DATA_MASK; + switch (bus_width) { + case 8: + host->host_caps |= MMC_CAP_8_BIT_DATA; + case 4: /* note fall through from above */ + host->host_caps |= MMC_CAP_4_BIT_DATA; + case 1: + break; + default: + dev_err(host->hw_dev, + "Invalid \"bus-width\" value %u!\n", bus_width); + } } /* f_max is obtained from the optional "max-frequency" property */ |