Commit eff8f2f5 authored by Lars-Peter Clausen's avatar Lars-Peter Clausen Committed by Ulf Hansson

mmc: dw_mmc: Use core to handle absent write protect line

Use the new MMC_CAP2_NO_WRITE_PROTECT to let the core handle the case where
no write protect line is present instead of having custom driver code to
handle it.

dw_mci_of_get_slot_quirks() is slightly refactored to directly modify the
mmc_host capabilities instead of returning a quirk mask.
Signed-off-by: default avatarLars-Peter Clausen <lars@metafoo.de>
Signed-off-by: default avatarJaehoon Chung <jh80.chung@samsung.com>
Signed-off-by: default avatarUlf Hansson <ulf.hansson@linaro.org>
parent 0293efdd
...@@ -1282,10 +1282,7 @@ static int dw_mci_get_ro(struct mmc_host *mmc) ...@@ -1282,10 +1282,7 @@ static int dw_mci_get_ro(struct mmc_host *mmc)
int gpio_ro = mmc_gpio_get_ro(mmc); int gpio_ro = mmc_gpio_get_ro(mmc);
/* Use platform get_ro function, else try on board write protect */ /* Use platform get_ro function, else try on board write protect */
if ((slot->quirks & DW_MCI_SLOT_QUIRK_NO_WRITE_PROTECT) || if (!IS_ERR_VALUE(gpio_ro))
(slot->host->quirks & DW_MCI_QUIRK_NO_WRITE_PROTECT))
read_only = 0;
else if (!IS_ERR_VALUE(gpio_ro))
read_only = gpio_ro; read_only = gpio_ro;
else else
read_only = read_only =
...@@ -2284,9 +2281,10 @@ static irqreturn_t dw_mci_interrupt(int irq, void *dev_id) ...@@ -2284,9 +2281,10 @@ static irqreturn_t dw_mci_interrupt(int irq, void *dev_id)
} }
#ifdef CONFIG_OF #ifdef CONFIG_OF
/* given a slot id, find out the device node representing that slot */ /* given a slot, find out the device node representing that slot */
static struct device_node *dw_mci_of_find_slot_node(struct device *dev, u8 slot) static struct device_node *dw_mci_of_find_slot_node(struct dw_mci_slot *slot)
{ {
struct device *dev = slot->mmc->parent;
struct device_node *np; struct device_node *np;
const __be32 *addr; const __be32 *addr;
int len; int len;
...@@ -2298,42 +2296,28 @@ static struct device_node *dw_mci_of_find_slot_node(struct device *dev, u8 slot) ...@@ -2298,42 +2296,28 @@ static struct device_node *dw_mci_of_find_slot_node(struct device *dev, u8 slot)
addr = of_get_property(np, "reg", &len); addr = of_get_property(np, "reg", &len);
if (!addr || (len < sizeof(int))) if (!addr || (len < sizeof(int)))
continue; continue;
if (be32_to_cpup(addr) == slot) if (be32_to_cpup(addr) == slot->id)
return np; return np;
} }
return NULL; return NULL;
} }
static struct dw_mci_of_slot_quirks { static void dw_mci_slot_of_parse(struct dw_mci_slot *slot)
char *quirk;
int id;
} of_slot_quirks[] = {
{
.quirk = "disable-wp",
.id = DW_MCI_SLOT_QUIRK_NO_WRITE_PROTECT,
},
};
static int dw_mci_of_get_slot_quirks(struct device *dev, u8 slot)
{ {
struct device_node *np = dw_mci_of_find_slot_node(dev, slot); struct device_node *np = dw_mci_of_find_slot_node(slot);
int quirks = 0;
int idx;
/* get quirks */ if (!np)
for (idx = 0; idx < ARRAY_SIZE(of_slot_quirks); idx++) return;
if (of_get_property(np, of_slot_quirks[idx].quirk, NULL)) {
dev_warn(dev, "Slot quirk %s is deprecated\n",
of_slot_quirks[idx].quirk);
quirks |= of_slot_quirks[idx].id;
}
return quirks; if (of_property_read_bool(np, "disable-wp")) {
slot->mmc->caps2 |= MMC_CAP2_NO_WRITE_PROTECT;
dev_warn(slot->mmc->parent,
"Slot quirk 'disable-wp' is deprecated\n");
}
} }
#else /* CONFIG_OF */ #else /* CONFIG_OF */
static int dw_mci_of_get_slot_quirks(struct device *dev, u8 slot) static void dw_mci_slot_of_parse(struct dw_mci_slot *slot)
{ {
return 0;
} }
#endif /* CONFIG_OF */ #endif /* CONFIG_OF */
...@@ -2356,8 +2340,6 @@ static int dw_mci_init_slot(struct dw_mci *host, unsigned int id) ...@@ -2356,8 +2340,6 @@ static int dw_mci_init_slot(struct dw_mci *host, unsigned int id)
slot->host = host; slot->host = host;
host->slot[id] = slot; host->slot[id] = slot;
slot->quirks = dw_mci_of_get_slot_quirks(host->dev, slot->id);
mmc->ops = &dw_mci_ops; mmc->ops = &dw_mci_ops;
if (of_property_read_u32_array(host->dev->of_node, if (of_property_read_u32_array(host->dev->of_node,
"clock-freq-min-max", freq, 2)) { "clock-freq-min-max", freq, 2)) {
...@@ -2395,6 +2377,8 @@ static int dw_mci_init_slot(struct dw_mci *host, unsigned int id) ...@@ -2395,6 +2377,8 @@ static int dw_mci_init_slot(struct dw_mci *host, unsigned int id)
if (host->pdata->caps2) if (host->pdata->caps2)
mmc->caps2 = host->pdata->caps2; mmc->caps2 = host->pdata->caps2;
dw_mci_slot_of_parse(slot);
ret = mmc_of_parse(mmc); ret = mmc_of_parse(mmc);
if (ret) if (ret)
goto err_host_allocated; goto err_host_allocated;
...@@ -2622,9 +2606,6 @@ static struct dw_mci_of_quirks { ...@@ -2622,9 +2606,6 @@ static struct dw_mci_of_quirks {
{ {
.quirk = "broken-cd", .quirk = "broken-cd",
.id = DW_MCI_QUIRK_BROKEN_CARD_DETECTION, .id = DW_MCI_QUIRK_BROKEN_CARD_DETECTION,
}, {
.quirk = "disable-wp",
.id = DW_MCI_QUIRK_NO_WRITE_PROTECT,
}, },
}; };
......
...@@ -227,7 +227,6 @@ extern int dw_mci_resume(struct dw_mci *host); ...@@ -227,7 +227,6 @@ extern int dw_mci_resume(struct dw_mci *host);
* struct dw_mci_slot - MMC slot state * struct dw_mci_slot - MMC slot state
* @mmc: The mmc_host representing this slot. * @mmc: The mmc_host representing this slot.
* @host: The MMC controller this slot is using. * @host: The MMC controller this slot is using.
* @quirks: Slot-level quirks (DW_MCI_SLOT_QUIRK_XXX)
* @ctype: Card type for this slot. * @ctype: Card type for this slot.
* @mrq: mmc_request currently being processed or waiting to be * @mrq: mmc_request currently being processed or waiting to be
* processed, or NULL when the slot is idle. * processed, or NULL when the slot is idle.
...@@ -245,8 +244,6 @@ struct dw_mci_slot { ...@@ -245,8 +244,6 @@ struct dw_mci_slot {
struct mmc_host *mmc; struct mmc_host *mmc;
struct dw_mci *host; struct dw_mci *host;
int quirks;
u32 ctype; u32 ctype;
struct mmc_request *mrq; struct mmc_request *mrq;
......
...@@ -226,12 +226,6 @@ struct dw_mci_dma_ops { ...@@ -226,12 +226,6 @@ struct dw_mci_dma_ops {
#define DW_MCI_QUIRK_HIGHSPEED BIT(2) #define DW_MCI_QUIRK_HIGHSPEED BIT(2)
/* Unreliable card detection */ /* Unreliable card detection */
#define DW_MCI_QUIRK_BROKEN_CARD_DETECTION BIT(3) #define DW_MCI_QUIRK_BROKEN_CARD_DETECTION BIT(3)
/* No write protect */
#define DW_MCI_QUIRK_NO_WRITE_PROTECT BIT(4)
/* Slot level quirks */
/* This slot has no write protect */
#define DW_MCI_SLOT_QUIRK_NO_WRITE_PROTECT BIT(0)
struct dma_pdata; struct dma_pdata;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment