diff --git a/arch/arm/mach-socfpga/xload.c b/arch/arm/mach-socfpga/xload.c index 272896b..cf05ff3 100644 --- a/arch/arm/mach-socfpga/xload.c +++ b/arch/arm/mach-socfpga/xload.c @@ -10,6 +10,7 @@ #include #include #include +#include #include #include @@ -33,6 +34,7 @@ static struct clk *clks[clk_max]; static struct dw_mmc_platform_data mmc_pdata = { + .bus_width_caps = MMC_CAP_4_BIT_DATA, .ciu_div = 3, }; diff --git a/drivers/mci/dw_mmc.c b/drivers/mci/dw_mmc.c index acdf795..cbd3f00 100644 --- a/drivers/mci/dw_mmc.c +++ b/drivers/mci/dw_mmc.c @@ -676,11 +676,9 @@ 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,20 +696,6 @@ if (IS_ERR(host->ioaddr)) return PTR_ERR(host->ioaddr); - 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, DMA_ADDRESS_BROKEN); @@ -722,6 +706,23 @@ 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")) diff --git a/drivers/mci/mci-core.c b/drivers/mci/mci-core.c index 29c0d54..4e6b83b 100644 --- a/drivers/mci/mci-core.c +++ b/drivers/mci/mci-core.c @@ -1819,23 +1819,29 @@ /* "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 */ diff --git a/include/mci.h b/include/mci.h index 41a757e..174d150 100644 --- a/include/mci.h +++ b/include/mci.h @@ -56,6 +56,8 @@ #define MMC_CAP_SD_HIGHSPEED (1 << 3) #define MMC_CAP_MMC_HIGHSPEED (1 << 4) #define MMC_CAP_MMC_HIGHSPEED_52MHZ (1 << 5) +/* Mask of all caps for bus width */ +#define MMC_CAP_BIT_DATA_MASK (MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA) #define SD_DATA_4BIT 0x00040000 diff --git a/include/platform_data/dw_mmc.h b/include/platform_data/dw_mmc.h index 48faa76..4325a4f 100644 --- a/include/platform_data/dw_mmc.h +++ b/include/platform_data/dw_mmc.h @@ -2,7 +2,7 @@ #define __INCLUDE_PLATFORM_DATA_DW_MMC_H struct dw_mmc_platform_data { - char *devname; + unsigned int bus_width_caps; int ciu_div; };