Message ID | 1389278112-7099-2-git-send-email-zhangfei.gao@linaro.org (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
On Thursday 09 January 2014, Zhangfei Gao wrote: > Suggested by Jaehoon: Use slot-gpio to handle cd-gpio > Add function dw_mci_of_get_cd_gpio to check "cd-gpios" from dts. > mmc_gpio_request_cd and mmc_gpio_get_cd are used to handle cd pin > > Signed-off-by: Zhangfei Gao <zhangfei.gao@linaro.org> > Acked-by: Jaehoon Chung <jh80.chung@samsung.com> > --- > drivers/mmc/host/dw_mmc.c | 48 +++++++++++++++++++++++++++++++++------------ > 1 file changed, 35 insertions(+), 13 deletions(-) Acked-by: Arnd Bergmann <arnd@arndb.de> -- To unsubscribe from this list: send the line "unsubscribe linux-mmc" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On Thu, Jan 9, 2014 at 6:35 AM, Zhangfei Gao <zhangfei.gao@linaro.org> wrote: > Suggested by Jaehoon: Use slot-gpio to handle cd-gpio > Add function dw_mci_of_get_cd_gpio to check "cd-gpios" from dts. > mmc_gpio_request_cd and mmc_gpio_get_cd are used to handle cd pin > > Signed-off-by: Zhangfei Gao <zhangfei.gao@linaro.org> > Acked-by: Jaehoon Chung <jh80.chung@samsung.com> The Samsung Arndale board started failing boot from MMC root tests starting with next-20140113 and I bisected it down to this patch. Reverting this patch on top of next-20140114 gets Arndale booting again from MMC. Is there some supporting DT data that's missing for Arndale? Kevin -- To unsubscribe from this list: send the line "unsubscribe linux-mmc" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On Tue, Jan 14, 2014 at 7:58 AM, Kevin Hilman <khilman@linaro.org> wrote: > On Thu, Jan 9, 2014 at 6:35 AM, Zhangfei Gao <zhangfei.gao@linaro.org> wrote: >> Suggested by Jaehoon: Use slot-gpio to handle cd-gpio >> Add function dw_mci_of_get_cd_gpio to check "cd-gpios" from dts. >> mmc_gpio_request_cd and mmc_gpio_get_cd are used to handle cd pin >> >> Signed-off-by: Zhangfei Gao <zhangfei.gao@linaro.org> >> Acked-by: Jaehoon Chung <jh80.chung@samsung.com> > > The Samsung Arndale board started failing boot from MMC root tests > starting with next-20140113 and I bisected it down to this patch. > Reverting this patch on top of next-20140114 gets Arndale booting > again from MMC. Is there some supporting DT data that's missing for > Arndale? Rather, it looks like this patch changes behaviour and no longer uses dw_mci_get_cd() to find out if there's a card attached -- it switches to rely only on GPIO (see the last chunk in the patch). That seems broken? -Olof -- To unsubscribe from this list: send the line "unsubscribe linux-mmc" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On 01/15/2014 01:23 AM, Olof Johansson wrote: > On Tue, Jan 14, 2014 at 7:58 AM, Kevin Hilman <khilman@linaro.org> wrote: >> On Thu, Jan 9, 2014 at 6:35 AM, Zhangfei Gao <zhangfei.gao@linaro.org> wrote: >>> Suggested by Jaehoon: Use slot-gpio to handle cd-gpio >>> Add function dw_mci_of_get_cd_gpio to check "cd-gpios" from dts. >>> mmc_gpio_request_cd and mmc_gpio_get_cd are used to handle cd pin >>> >>> Signed-off-by: Zhangfei Gao <zhangfei.gao@linaro.org> >>> Acked-by: Jaehoon Chung <jh80.chung@samsung.com> >> >> The Samsung Arndale board started failing boot from MMC root tests >> starting with next-20140113 and I bisected it down to this patch. >> Reverting this patch on top of next-20140114 gets Arndale booting >> again from MMC. Is there some supporting DT data that's missing for >> Arndale? > > Rather, it looks like this patch changes behaviour and no longer uses > dw_mci_get_cd() to find out if there's a card attached -- it switches > to rely only on GPIO (see the last chunk in the patch). That seems > broken? > Oops, Change using dw_mci_get_cd set flag DW_MMC_CARD_PRESENT. And dw_mci_get_cd is called from mmc_rescan, a litter later than dw_mci_probe. Is that too late? Thanks -- To unsubscribe from this list: send the line "unsubscribe linux-mmc" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
diff --git a/drivers/mmc/host/dw_mmc.c b/drivers/mmc/host/dw_mmc.c index 4bce0deec362..a776f24f4311 100644 --- a/drivers/mmc/host/dw_mmc.c +++ b/drivers/mmc/host/dw_mmc.c @@ -36,6 +36,7 @@ #include <linux/workqueue.h> #include <linux/of.h> #include <linux/of_gpio.h> +#include <linux/mmc/slot-gpio.h> #include "dw_mmc.h" @@ -1032,20 +1033,26 @@ static int dw_mci_get_cd(struct mmc_host *mmc) int present; struct dw_mci_slot *slot = mmc_priv(mmc); struct dw_mci_board *brd = slot->host->pdata; + int gpio_cd = !mmc_gpio_get_cd(mmc); /* Use platform get_cd function, else try onboard card detect */ if (brd->quirks & DW_MCI_QUIRK_BROKEN_CARD_DETECTION) present = 1; else if (brd->get_cd) present = !brd->get_cd(slot->id); + else if (!IS_ERR_VALUE(gpio_cd)) + present = !!gpio_cd; else present = (mci_readl(slot->host, CDETECT) & (1 << slot->id)) == 0 ? 1 : 0; - if (present) + if (present) { + set_bit(DW_MMC_CARD_PRESENT, &slot->flags); dev_dbg(&mmc->class_dev, "card is present\n"); - else + } else { + clear_bit(DW_MMC_CARD_PRESENT, &slot->flags); dev_dbg(&mmc->class_dev, "card is not present\n"); + } return present; } @@ -1926,10 +1933,6 @@ static void dw_mci_work_routine_card(struct work_struct *work) /* Card change detected */ slot->last_detect_state = present; - /* Mark card as present if applicable */ - if (present != 0) - set_bit(DW_MMC_CARD_PRESENT, &slot->flags); - /* Clean up queue if present */ mrq = slot->mrq; if (mrq) { @@ -1977,8 +1980,6 @@ static void dw_mci_work_routine_card(struct work_struct *work) /* Power down slot */ if (present == 0) { - clear_bit(DW_MMC_CARD_PRESENT, &slot->flags); - /* Clear down the FIFO */ dw_mci_fifo_reset(host); #ifdef CONFIG_MMC_DW_IDMAC @@ -2079,6 +2080,26 @@ static int dw_mci_of_get_wp_gpio(struct device *dev, u8 slot) return gpio; } + +/* find the cd gpio for a given slot; or -1 if none specified */ +static void dw_mci_of_get_cd_gpio(struct device *dev, u8 slot, + struct mmc_host *mmc) +{ + struct device_node *np = dw_mci_of_find_slot_node(dev, slot); + int gpio; + + if (!np) + return; + + gpio = of_get_named_gpio(np, "cd-gpios", 0); + + /* Having a missing entry is valid; return silently */ + if (!gpio_is_valid(gpio)) + return; + + if (mmc_gpio_request_cd(mmc, gpio, 0)) + dev_warn(dev, "gpio [%d] request failed\n", gpio); +} #else /* CONFIG_OF */ static int dw_mci_of_get_slot_quirks(struct device *dev, u8 slot) { @@ -2096,6 +2117,11 @@ static int dw_mci_of_get_wp_gpio(struct device *dev, u8 slot) { return -EINVAL; } +static void dw_mci_of_get_cd_gpio(struct device *dev, u8 slot, + struct mmc_host *mmc) +{ + return; +} #endif /* CONFIG_OF */ static int dw_mci_init_slot(struct dw_mci *host, unsigned int id) @@ -2197,12 +2223,8 @@ static int dw_mci_init_slot(struct dw_mci *host, unsigned int id) #endif /* CONFIG_MMC_DW_IDMAC */ } - if (dw_mci_get_cd(mmc)) - set_bit(DW_MMC_CARD_PRESENT, &slot->flags); - else - clear_bit(DW_MMC_CARD_PRESENT, &slot->flags); - slot->wp_gpio = dw_mci_of_get_wp_gpio(host->dev, slot->id); + dw_mci_of_get_cd_gpio(host->dev, slot->id, mmc); ret = mmc_add_host(mmc); if (ret)