From 43b58b36b7e6554b8a96be6b9f63542c583c06e5 Mon Sep 17 00:00:00 2001 From: Pierre Ossman Date: Wed, 25 Jul 2007 23:15:27 +0200 Subject: mmc: check error bits before command completion Some controllers signal "command complete" even on failures (which they are allowed to do according to the spec). Make sure we check the error bits first so we don't get any false positives. Signed-off-by: Pierre Ossman --- drivers/mmc/host/sdhci.c | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) (limited to 'drivers/mmc') diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c index 4a24db028d8..56de4c48ec8 100644 --- a/drivers/mmc/host/sdhci.c +++ b/drivers/mmc/host/sdhci.c @@ -922,20 +922,17 @@ static void sdhci_cmd_irq(struct sdhci_host *host, u32 intmask) return; } - if (intmask & SDHCI_INT_RESPONSE) - sdhci_finish_command(host); - else { - if (intmask & SDHCI_INT_TIMEOUT) - host->cmd->error = MMC_ERR_TIMEOUT; - else if (intmask & SDHCI_INT_CRC) - host->cmd->error = MMC_ERR_BADCRC; - else if (intmask & (SDHCI_INT_END_BIT | SDHCI_INT_INDEX)) - host->cmd->error = MMC_ERR_FAILED; - else - host->cmd->error = MMC_ERR_INVALID; - + if (intmask & SDHCI_INT_TIMEOUT) + host->cmd->error = MMC_ERR_TIMEOUT; + else if (intmask & SDHCI_INT_CRC) + host->cmd->error = MMC_ERR_BADCRC; + else if (intmask & (SDHCI_INT_END_BIT | SDHCI_INT_INDEX)) + host->cmd->error = MMC_ERR_FAILED; + + if (host->cmd->error != MMC_ERR_NONE) tasklet_schedule(&host->finish_tasklet); - } + else if (intmask & SDHCI_INT_RESPONSE) + sdhci_finish_command(host); } static void sdhci_data_irq(struct sdhci_host *host, u32 intmask) -- cgit v1.2.3 From b8352260d28b30cb2bb2df99814fb9c360e38901 Mon Sep 17 00:00:00 2001 From: Leandro Dorileo Date: Wed, 25 Jul 2007 23:47:04 +0200 Subject: sdhci: add support to ENE-CB714 Added its pci_id and implemented a quirk for it because this controller needs to reset cmd and data when setting ios. Signed-off-by: Leandro Dorileo Signed-off-by: Otavio Salvador Signed-off-by: Pierre Ossman --- drivers/mmc/host/sdhci.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'drivers/mmc') diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c index 56de4c48ec8..dd4bfb59447 100644 --- a/drivers/mmc/host/sdhci.c +++ b/drivers/mmc/host/sdhci.c @@ -34,6 +34,7 @@ static unsigned int debug_quirks = 0; /* Controller doesn't like some resets when there is no card inserted. */ #define SDHCI_QUIRK_NO_CARD_NO_RESET (1<<2) #define SDHCI_QUIRK_SINGLE_POWER_WRITE (1<<3) +#define SDHCI_QUIRK_RESET_CMD_DATA_ON_IOS (1<<4) static const struct pci_device_id pci_ids[] __devinitdata = { { @@ -78,6 +79,24 @@ static const struct pci_device_id pci_ids[] __devinitdata = { .driver_data = SDHCI_QUIRK_SINGLE_POWER_WRITE, }, + { + .vendor = PCI_VENDOR_ID_ENE, + .device = PCI_DEVICE_ID_ENE_CB714_SD, + .subvendor = PCI_ANY_ID, + .subdevice = PCI_ANY_ID, + .driver_data = SDHCI_QUIRK_SINGLE_POWER_WRITE | + SDHCI_QUIRK_RESET_CMD_DATA_ON_IOS, + }, + + { + .vendor = PCI_VENDOR_ID_ENE, + .device = PCI_DEVICE_ID_ENE_CB714_SD_2, + .subvendor = PCI_ANY_ID, + .subdevice = PCI_ANY_ID, + .driver_data = SDHCI_QUIRK_SINGLE_POWER_WRITE | + SDHCI_QUIRK_RESET_CMD_DATA_ON_IOS, + }, + { /* Generic SD host controller */ PCI_DEVICE_CLASS((PCI_CLASS_SYSTEM_SDHCI << 8), 0xFFFF00) }, @@ -759,6 +778,14 @@ static void sdhci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios) writeb(ctrl, host->ioaddr + SDHCI_HOST_CONTROL); + /* + * Some (ENE) controllers go apeshit on some ios operation, + * signalling timeout and CRC errors even on CMD0. Resetting + * it on each ios seems to solve the problem. + */ + if(host->chip->quirks & SDHCI_QUIRK_RESET_CMD_DATA_ON_IOS) + sdhci_reset(host, SDHCI_RESET_CMD | SDHCI_RESET_DATA); + mmiowb(); spin_unlock_irqrestore(&host->lock, flags); } -- cgit v1.2.3 From 70f10482c668301c483acded13bf68780ad352b9 Mon Sep 17 00:00:00 2001 From: Pierre Ossman Date: Wed, 11 Jul 2007 20:04:50 +0200 Subject: mmc: update header file paths Make sure all headers in the files reflect their true position in the tree. Signed-off-by: Pierre Ossman --- drivers/mmc/card/queue.c | 2 +- drivers/mmc/core/mmc.c | 2 +- drivers/mmc/core/mmc_ops.c | 2 +- drivers/mmc/core/mmc_ops.h | 2 +- drivers/mmc/core/sd.c | 2 +- drivers/mmc/core/sd_ops.c | 2 +- drivers/mmc/core/sd_ops.h | 2 +- drivers/mmc/host/at91_mci.c | 2 +- drivers/mmc/host/au1xmmc.c | 2 +- drivers/mmc/host/imxmmc.c | 2 +- drivers/mmc/host/mmci.c | 2 +- drivers/mmc/host/mmci.h | 2 +- drivers/mmc/host/omap.c | 2 +- drivers/mmc/host/pxamci.c | 2 +- drivers/mmc/host/sdhci.c | 2 +- drivers/mmc/host/sdhci.h | 2 +- drivers/mmc/host/wbsd.c | 2 +- drivers/mmc/host/wbsd.h | 2 +- 18 files changed, 18 insertions(+), 18 deletions(-) (limited to 'drivers/mmc') diff --git a/drivers/mmc/card/queue.c b/drivers/mmc/card/queue.c index b53dac8d1b6..9f2b20fd9ab 100644 --- a/drivers/mmc/card/queue.c +++ b/drivers/mmc/card/queue.c @@ -1,5 +1,5 @@ /* - * linux/drivers/mmc/queue.c + * linux/drivers/mmc/card/queue.c * * Copyright (C) 2003 Russell King, All Rights Reserved. * Copyright 2006-2007 Pierre Ossman diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c index 66f85bfa8db..1a889e9c531 100644 --- a/drivers/mmc/core/mmc.c +++ b/drivers/mmc/core/mmc.c @@ -1,5 +1,5 @@ /* - * linux/drivers/mmc/mmc.c + * linux/drivers/mmc/core/mmc.c * * Copyright (C) 2003-2004 Russell King, All Rights Reserved. * Copyright (C) 2005-2007 Pierre Ossman, All Rights Reserved. diff --git a/drivers/mmc/core/mmc_ops.c b/drivers/mmc/core/mmc_ops.c index 7dd720fa589..913e75f0084 100644 --- a/drivers/mmc/core/mmc_ops.c +++ b/drivers/mmc/core/mmc_ops.c @@ -1,5 +1,5 @@ /* - * linux/drivers/mmc/mmc_ops.h + * linux/drivers/mmc/core/mmc_ops.h * * Copyright 2006-2007 Pierre Ossman * diff --git a/drivers/mmc/core/mmc_ops.h b/drivers/mmc/core/mmc_ops.h index 7a481e8ca5e..76d09a93c5d 100644 --- a/drivers/mmc/core/mmc_ops.h +++ b/drivers/mmc/core/mmc_ops.h @@ -1,5 +1,5 @@ /* - * linux/drivers/mmc/mmc_ops.h + * linux/drivers/mmc/core/mmc_ops.h * * Copyright 2006-2007 Pierre Ossman * diff --git a/drivers/mmc/core/sd.c b/drivers/mmc/core/sd.c index 1240684083f..df3bbfea226 100644 --- a/drivers/mmc/core/sd.c +++ b/drivers/mmc/core/sd.c @@ -1,5 +1,5 @@ /* - * linux/drivers/mmc/sd.c + * linux/drivers/mmc/core/sd.c * * Copyright (C) 2003-2004 Russell King, All Rights Reserved. * SD support Copyright (C) 2004 Ian Molton, All Rights Reserved. diff --git a/drivers/mmc/core/sd_ops.c b/drivers/mmc/core/sd_ops.c index 9697ce58110..848b5f5c234 100644 --- a/drivers/mmc/core/sd_ops.c +++ b/drivers/mmc/core/sd_ops.c @@ -1,5 +1,5 @@ /* - * linux/drivers/mmc/sd_ops.h + * linux/drivers/mmc/core/sd_ops.h * * Copyright 2006-2007 Pierre Ossman * diff --git a/drivers/mmc/core/sd_ops.h b/drivers/mmc/core/sd_ops.h index 1240fddba5e..09ca52fca2f 100644 --- a/drivers/mmc/core/sd_ops.h +++ b/drivers/mmc/core/sd_ops.h @@ -1,5 +1,5 @@ /* - * linux/drivers/mmc/sd_ops.h + * linux/drivers/mmc/core/sd_ops.h * * Copyright 2006-2007 Pierre Ossman * diff --git a/drivers/mmc/host/at91_mci.c b/drivers/mmc/host/at91_mci.c index 15aab374127..62564ccde03 100644 --- a/drivers/mmc/host/at91_mci.c +++ b/drivers/mmc/host/at91_mci.c @@ -1,5 +1,5 @@ /* - * linux/drivers/mmc/at91_mci.c - ATMEL AT91 MCI Driver + * linux/drivers/mmc/host/at91_mci.c - ATMEL AT91 MCI Driver * * Copyright (C) 2005 Cougar Creek Computing Devices Ltd, All Rights Reserved * diff --git a/drivers/mmc/host/au1xmmc.c b/drivers/mmc/host/au1xmmc.c index 52b63f11ddd..34c99d4ea04 100644 --- a/drivers/mmc/host/au1xmmc.c +++ b/drivers/mmc/host/au1xmmc.c @@ -1,5 +1,5 @@ /* - * linux/drivers/mmc/au1xmmc.c - AU1XX0 MMC driver + * linux/drivers/mmc/host/au1xmmc.c - AU1XX0 MMC driver * * Copyright (c) 2005, Advanced Micro Devices, Inc. * diff --git a/drivers/mmc/host/imxmmc.c b/drivers/mmc/host/imxmmc.c index 7ee2045acbe..54bfc9f2559 100644 --- a/drivers/mmc/host/imxmmc.c +++ b/drivers/mmc/host/imxmmc.c @@ -1,5 +1,5 @@ /* - * linux/drivers/mmc/imxmmc.c - Motorola i.MX MMCI driver + * linux/drivers/mmc/host/imxmmc.c - Motorola i.MX MMCI driver * * Copyright (C) 2004 Sascha Hauer, Pengutronix * Copyright (C) 2006 Pavel Pisa, PiKRON diff --git a/drivers/mmc/host/mmci.c b/drivers/mmc/host/mmci.c index d11c2d23cee..be730c0a035 100644 --- a/drivers/mmc/host/mmci.c +++ b/drivers/mmc/host/mmci.c @@ -1,5 +1,5 @@ /* - * linux/drivers/mmc/mmci.c - ARM PrimeCell MMCI PL180/1 driver + * linux/drivers/mmc/host/mmci.c - ARM PrimeCell MMCI PL180/1 driver * * Copyright (C) 2003 Deep Blue Solutions, Ltd, All Rights Reserved. * diff --git a/drivers/mmc/host/mmci.h b/drivers/mmc/host/mmci.h index 6d7eadc9a67..000e6a91978 100644 --- a/drivers/mmc/host/mmci.h +++ b/drivers/mmc/host/mmci.h @@ -1,5 +1,5 @@ /* - * linux/drivers/mmc/mmci.h - ARM PrimeCell MMCI PL180/1 driver + * linux/drivers/mmc/host/mmci.h - ARM PrimeCell MMCI PL180/1 driver * * Copyright (C) 2003 Deep Blue Solutions, Ltd, All Rights Reserved. * diff --git a/drivers/mmc/host/omap.c b/drivers/mmc/host/omap.c index b0824a38f42..0cf97edc5f5 100644 --- a/drivers/mmc/host/omap.c +++ b/drivers/mmc/host/omap.c @@ -1,5 +1,5 @@ /* - * linux/drivers/media/mmc/omap.c + * linux/drivers/mmc/host/omap.c * * Copyright (C) 2004 Nokia Corporation * Written by Tuukka Tikkanen and Juha Yrjölä diff --git a/drivers/mmc/host/pxamci.c b/drivers/mmc/host/pxamci.c index f8985c508bb..ff960334b33 100644 --- a/drivers/mmc/host/pxamci.c +++ b/drivers/mmc/host/pxamci.c @@ -1,5 +1,5 @@ /* - * linux/drivers/mmc/pxa.c - PXA MMCI driver + * linux/drivers/mmc/host/pxa.c - PXA MMCI driver * * Copyright (C) 2003 Russell King, All Rights Reserved. * diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c index dd4bfb59447..9fd633a6f93 100644 --- a/drivers/mmc/host/sdhci.c +++ b/drivers/mmc/host/sdhci.c @@ -1,5 +1,5 @@ /* - * linux/drivers/mmc/sdhci.c - Secure Digital Host Controller Interface driver + * linux/drivers/mmc/host/sdhci.c - Secure Digital Host Controller Interface driver * * Copyright (C) 2005-2007 Pierre Ossman, All Rights Reserved. * diff --git a/drivers/mmc/host/sdhci.h b/drivers/mmc/host/sdhci.h index a6c870480b8..d157776c114 100644 --- a/drivers/mmc/host/sdhci.h +++ b/drivers/mmc/host/sdhci.h @@ -1,5 +1,5 @@ /* - * linux/drivers/mmc/sdhci.h - Secure Digital Host Controller Interface driver + * linux/drivers/mmc/host/sdhci.h - Secure Digital Host Controller Interface driver * * Copyright (C) 2005-2007 Pierre Ossman, All Rights Reserved. * diff --git a/drivers/mmc/host/wbsd.c b/drivers/mmc/host/wbsd.c index 867ca6a6929..1d7ebf35355 100644 --- a/drivers/mmc/host/wbsd.c +++ b/drivers/mmc/host/wbsd.c @@ -1,5 +1,5 @@ /* - * linux/drivers/mmc/wbsd.c - Winbond W83L51xD SD/MMC driver + * linux/drivers/mmc/host/wbsd.c - Winbond W83L51xD SD/MMC driver * * Copyright (C) 2004-2007 Pierre Ossman, All Rights Reserved. * diff --git a/drivers/mmc/host/wbsd.h b/drivers/mmc/host/wbsd.h index 873bda1e59b..0877866f8d2 100644 --- a/drivers/mmc/host/wbsd.h +++ b/drivers/mmc/host/wbsd.h @@ -1,5 +1,5 @@ /* - * linux/drivers/mmc/wbsd.h - Winbond W83L51xD SD/MMC driver + * linux/drivers/mmc/host/wbsd.h - Winbond W83L51xD SD/MMC driver * * Copyright (C) 2004-2007 Pierre Ossman, All Rights Reserved. * -- cgit v1.2.3 From 67a61c484735de9bf4f099830ecb4ef2eca95c38 Mon Sep 17 00:00:00 2001 From: Pierre Ossman Date: Wed, 11 Jul 2007 20:22:11 +0200 Subject: mmc: update kerneldoc Make sure the kerneldoc comments are up to date and relevant. Signed-off-by: Pierre Ossman --- drivers/mmc/core/core.c | 31 +++++++++++++++++++------------ drivers/mmc/core/host.c | 7 ++++++- drivers/mmc/core/sd_ops.c | 2 +- 3 files changed, 26 insertions(+), 14 deletions(-) (limited to 'drivers/mmc') diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c index b5d8a6d90cc..e08aa352bd5 100644 --- a/drivers/mmc/core/core.c +++ b/drivers/mmc/core/core.c @@ -140,7 +140,16 @@ static void mmc_wait_done(struct mmc_request *mrq) complete(mrq->done_data); } -int mmc_wait_for_req(struct mmc_host *host, struct mmc_request *mrq) +/** + * mmc_wait_for_req - start a request and wait for completion + * @host: MMC host to start command + * @mrq: MMC request to start + * + * Start a new MMC custom command request for a host, and wait + * for the command to complete. Does not attempt to parse the + * response. + */ +void mmc_wait_for_req(struct mmc_host *host, struct mmc_request *mrq) { DECLARE_COMPLETION_ONSTACK(complete); @@ -150,8 +159,6 @@ int mmc_wait_for_req(struct mmc_host *host, struct mmc_request *mrq) mmc_start_request(host, mrq); wait_for_completion(&complete); - - return 0; } EXPORT_SYMBOL(mmc_wait_for_req); @@ -192,6 +199,9 @@ EXPORT_SYMBOL(mmc_wait_for_cmd); * @data: data phase for command * @card: the MMC card associated with the data transfer * @write: flag to differentiate reads from writes + * + * Computes the data timeout parameters according to the + * correct algorithm given the card type. */ void mmc_set_data_timeout(struct mmc_data *data, const struct mmc_card *card, int write) @@ -240,15 +250,10 @@ void mmc_set_data_timeout(struct mmc_data *data, const struct mmc_card *card, EXPORT_SYMBOL(mmc_set_data_timeout); /** - * __mmc_claim_host - exclusively claim a host + * mmc_claim_host - exclusively claim a host * @host: mmc host to claim - * @card: mmc card to claim host for - * - * Claim a host for a set of operations. If a valid card - * is passed and this wasn't the last card selected, select - * the card before returning. * - * Note: you should use mmc_card_claim_host or mmc_claim_host. + * Claim a host for a set of operations. */ void mmc_claim_host(struct mmc_host *host) { @@ -498,8 +503,10 @@ void __mmc_release_bus(struct mmc_host *host) * @host: host which changed state. * @delay: optional delay to wait before detection (jiffies) * - * All we know is that card(s) have been inserted or removed - * from the socket(s). We don't know which socket or cards. + * MMC drivers should call this when they detect a card has been + * inserted or removed. The MMC layer will confirm that any + * present card is still functional, and initialize any newly + * inserted. */ void mmc_detect_change(struct mmc_host *host, unsigned long delay) { diff --git a/drivers/mmc/core/host.c b/drivers/mmc/core/host.c index 1433d95c40b..6a7e2984960 100644 --- a/drivers/mmc/core/host.c +++ b/drivers/mmc/core/host.c @@ -93,6 +93,10 @@ EXPORT_SYMBOL(mmc_alloc_host); /** * mmc_add_host - initialise host hardware * @host: mmc host + * + * Register the host with the driver model. The host must be + * prepared to start servicing requests before this function + * completes. */ int mmc_add_host(struct mmc_host *host) { @@ -126,7 +130,8 @@ EXPORT_SYMBOL(mmc_add_host); * @host: mmc host * * Unregister and remove all cards associated with this host, - * and power down the MMC bus. + * and power down the MMC bus. No new requests will be issued + * after this function has returned. */ void mmc_remove_host(struct mmc_host *host) { diff --git a/drivers/mmc/core/sd_ops.c b/drivers/mmc/core/sd_ops.c index 848b5f5c234..ee9a1b9f599 100644 --- a/drivers/mmc/core/sd_ops.c +++ b/drivers/mmc/core/sd_ops.c @@ -25,7 +25,7 @@ * mmc_wait_for_app_cmd - start an application command and wait for completion * @host: MMC host to start command - * @rca: RCA to send MMC_APP_CMD to + * @card: Card to send MMC_APP_CMD to * @cmd: MMC command to start * @retries: maximum number of retries * -- cgit v1.2.3 From cf795bfb3ad4e2f8f6bb346aa8edb8272d4c70a2 Mon Sep 17 00:00:00 2001 From: Pierre Ossman Date: Wed, 11 Jul 2007 20:28:02 +0200 Subject: mmc: add a might_sleep() to mmc_claim_host() In the normal case, the host lock can be claimed directly. When it cannot, the caller will sleep. Make sure we don't have any latent bugs by always calling might_sleep(). Signed-off-by: Pierre Ossman --- drivers/mmc/core/core.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'drivers/mmc') diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c index e08aa352bd5..3208890b10b 100644 --- a/drivers/mmc/core/core.c +++ b/drivers/mmc/core/core.c @@ -260,6 +260,8 @@ void mmc_claim_host(struct mmc_host *host) DECLARE_WAITQUEUE(wait, current); unsigned long flags; + might_sleep(); + add_wait_queue(&host->wq, &wait); spin_lock_irqsave(&host->lock, flags); while (1) { -- cgit v1.2.3 From 2986d0bf23d97d68804ccfa80965073ccf1af242 Mon Sep 17 00:00:00 2001 From: Pierre Ossman Date: Sun, 22 Jul 2007 17:52:06 +0200 Subject: mmc: Don't hold lock when releasing an added card When the card has been added to the device model, it might be bound to a card driver. Therefore, we have to release the host lock when trying to remove it as we otherwise might deadlock with the driver. Signed-off-by: Pierre Ossman --- drivers/mmc/core/mmc.c | 13 ++++++++----- drivers/mmc/core/sd.c | 13 ++++++++----- 2 files changed, 16 insertions(+), 10 deletions(-) (limited to 'drivers/mmc') diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c index 1a889e9c531..cd0c6b246fe 100644 --- a/drivers/mmc/core/mmc.c +++ b/drivers/mmc/core/mmc.c @@ -499,14 +499,17 @@ static void mmc_resume(struct mmc_host *host) BUG_ON(!host->card); mmc_claim_host(host); - err = mmc_init_card(host, host->ocr, host->card); + mmc_release_host(host); + if (err != MMC_ERR_NONE) { mmc_remove(host); + + mmc_claim_host(host); mmc_detach_bus(host); + mmc_release_host(host); } - mmc_release_host(host); } #else @@ -567,14 +570,14 @@ int mmc_attach_mmc(struct mmc_host *host, u32 ocr) err = mmc_add_card(host->card); if (err) - goto reclaim_host; + goto remove_card; return 0; -reclaim_host: - mmc_claim_host(host); +remove_card: mmc_remove_card(host->card); host->card = NULL; + mmc_claim_host(host); err: mmc_detach_bus(host); mmc_release_host(host); diff --git a/drivers/mmc/core/sd.c b/drivers/mmc/core/sd.c index df3bbfea226..0b478de48ac 100644 --- a/drivers/mmc/core/sd.c +++ b/drivers/mmc/core/sd.c @@ -573,14 +573,17 @@ static void mmc_sd_resume(struct mmc_host *host) BUG_ON(!host->card); mmc_claim_host(host); - err = mmc_sd_init_card(host, host->ocr, host->card); + mmc_release_host(host); + if (err != MMC_ERR_NONE) { mmc_sd_remove(host); + + mmc_claim_host(host); mmc_detach_bus(host); + mmc_release_host(host); } - mmc_release_host(host); } #else @@ -648,14 +651,14 @@ int mmc_attach_sd(struct mmc_host *host, u32 ocr) err = mmc_add_card(host->card); if (err) - goto reclaim_host; + goto remove_card; return 0; -reclaim_host: - mmc_claim_host(host); +remove_card: mmc_remove_card(host->card); host->card = NULL; + mmc_claim_host(host); err: mmc_detach_bus(host); mmc_release_host(host); -- cgit v1.2.3 From 109b5bed18441599b5ab0e1f3623efa5715a4703 Mon Sep 17 00:00:00 2001 From: Pierre Ossman Date: Mon, 23 Jul 2007 00:12:10 +0200 Subject: mmc: be more verbose about card insertions/removal Let the user know that the kernel actually detected the card by printing some basic information in dmesg. Signed-off-by: Pierre Ossman --- drivers/mmc/core/bus.c | 23 +++++++++++++++++++++++ drivers/mmc/core/mmc.c | 7 ++++++- drivers/mmc/core/sd.c | 7 ++++++- 3 files changed, 35 insertions(+), 2 deletions(-) (limited to 'drivers/mmc') diff --git a/drivers/mmc/core/bus.c b/drivers/mmc/core/bus.c index 348b566bf4f..fe0e785ed7d 100644 --- a/drivers/mmc/core/bus.c +++ b/drivers/mmc/core/bus.c @@ -209,10 +209,30 @@ struct mmc_card *mmc_alloc_card(struct mmc_host *host) int mmc_add_card(struct mmc_card *card) { int ret; + const char *type; snprintf(card->dev.bus_id, sizeof(card->dev.bus_id), "%s:%04x", mmc_hostname(card->host), card->rca); + switch (card->type) { + case MMC_TYPE_MMC: + type = "MMC"; + break; + case MMC_TYPE_SD: + type = "SD"; + if (mmc_card_blockaddr(card)) + type = "SDHC"; + break; + default: + type = "?"; + break; + } + + printk(KERN_INFO "%s: new %s%s card at address %04x\n", + mmc_hostname(card->host), + mmc_card_highspeed(card) ? "high speed " : "", + type, card->rca); + card->dev.uevent_suppress = 1; ret = device_add(&card->dev); @@ -243,6 +263,9 @@ int mmc_add_card(struct mmc_card *card) void mmc_remove_card(struct mmc_card *card) { if (mmc_card_present(card)) { + printk(KERN_INFO "%s: card %04x removed\n", + mmc_hostname(card->host), card->rca); + if (card->host->bus_ops->sysfs_remove) card->host->bus_ops->sysfs_remove(card->host, card); device_del(&card->dev); diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c index cd0c6b246fe..f606b6678b0 100644 --- a/drivers/mmc/core/mmc.c +++ b/drivers/mmc/core/mmc.c @@ -556,8 +556,10 @@ int mmc_attach_mmc(struct mmc_host *host, u32 ocr) /* * Can we support the voltage of the card? */ - if (!host->ocr) + if (!host->ocr) { + err = -EINVAL; goto err; + } /* * Detect and init the card. @@ -582,6 +584,9 @@ err: mmc_detach_bus(host); mmc_release_host(host); + printk(KERN_ERR "%s: error %d whilst initialising MMC card\n", + mmc_hostname(host), err); + return 0; } diff --git a/drivers/mmc/core/sd.c b/drivers/mmc/core/sd.c index 0b478de48ac..b6a2e53c921 100644 --- a/drivers/mmc/core/sd.c +++ b/drivers/mmc/core/sd.c @@ -637,8 +637,10 @@ int mmc_attach_sd(struct mmc_host *host, u32 ocr) /* * Can we support the voltage(s) of the card(s)? */ - if (!host->ocr) + if (!host->ocr) { + err = -EINVAL; goto err; + } /* * Detect and init the card. @@ -663,6 +665,9 @@ err: mmc_detach_bus(host); mmc_release_host(host); + printk(KERN_ERR "%s: error %d whilst initialising SD card\n", + mmc_hostname(host), err); + return 0; } -- cgit v1.2.3 From e4d217087458914a6d5d9fd034d7237e6530c619 Mon Sep 17 00:00:00 2001 From: Pierre Ossman Date: Tue, 24 Jul 2007 21:46:49 +0200 Subject: mmc: proper debugging output in core Make sure that the debugging output in the core is complete. This should allow us to clean up all the extra debug output that each and every other host driver seems to contain. Signed-off-by: Pierre Ossman --- drivers/mmc/core/core.c | 48 ++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 40 insertions(+), 8 deletions(-) (limited to 'drivers/mmc') diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c index 3208890b10b..d08968470c4 100644 --- a/drivers/mmc/core/core.c +++ b/drivers/mmc/core/core.c @@ -68,18 +68,35 @@ void mmc_request_done(struct mmc_host *host, struct mmc_request *mrq) struct mmc_command *cmd = mrq->cmd; int err = cmd->error; - pr_debug("%s: req done (CMD%u): %d/%d/%d: %08x %08x %08x %08x\n", - mmc_hostname(host), cmd->opcode, err, - mrq->data ? mrq->data->error : 0, - mrq->stop ? mrq->stop->error : 0, - cmd->resp[0], cmd->resp[1], cmd->resp[2], cmd->resp[3]); - if (err && cmd->retries) { + pr_debug("%s: req failed (CMD%u): %d, retrying...\n", + mmc_hostname(host), cmd->opcode, err); + cmd->retries--; cmd->error = 0; host->ops->request(host, mrq); - } else if (mrq->done) { - mrq->done(mrq); + } else { + pr_debug("%s: req done (CMD%u): %d: %08x %08x %08x %08x\n", + mmc_hostname(host), cmd->opcode, err, + cmd->resp[0], cmd->resp[1], + cmd->resp[2], cmd->resp[3]); + + if (mrq->data) { + pr_debug("%s: %d bytes transferred: %d\n", + mmc_hostname(host), + mrq->data->bytes_xfered, mrq->data->error); + } + + if (mrq->stop) { + pr_debug("%s: (CMD%u): %d: %08x %08x %08x %08x\n", + mmc_hostname(host), mrq->stop->opcode, + mrq->stop->error, + mrq->stop->resp[0], mrq->stop->resp[1], + mrq->stop->resp[2], mrq->stop->resp[3]); + } + + if (mrq->done) + mrq->done(mrq); } } @@ -104,6 +121,21 @@ mmc_start_request(struct mmc_host *host, struct mmc_request *mrq) mmc_hostname(host), mrq->cmd->opcode, mrq->cmd->arg, mrq->cmd->flags); + if (mrq->data) { + pr_debug("%s: blksz %d blocks %d flags %08x " + "tsac %d ms nsac %d\n", + mmc_hostname(host), mrq->data->blksz, + mrq->data->blocks, mrq->data->flags, + mrq->data->timeout_ns / 10000000, + mrq->data->timeout_clks); + } + + if (mrq->stop) { + pr_debug("%s: CMD%u arg %08x flags %08x\n", + mmc_hostname(host), mrq->stop->opcode, + mrq->stop->arg, mrq->stop->flags); + } + WARN_ON(!host->claimed); mrq->cmd->error = 0; -- cgit v1.2.3 From 462f104ba6a65ea2128462e2ef0c3adb18609954 Mon Sep 17 00:00:00 2001 From: Pierre Ossman Date: Tue, 24 Jul 2007 21:47:47 +0200 Subject: mmc: remove redundant debug information from sdhci and wbsd Remove the extra debugging output that now is properly printed by the core. Signed-off-by: Pierre Ossman --- drivers/mmc/host/sdhci.c | 13 ------------- drivers/mmc/host/wbsd.c | 13 ------------- 2 files changed, 26 deletions(-) (limited to 'drivers/mmc') diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c index 9fd633a6f93..f2bc87ac24f 100644 --- a/drivers/mmc/host/sdhci.c +++ b/drivers/mmc/host/sdhci.c @@ -380,11 +380,6 @@ static void sdhci_prepare_data(struct sdhci_host *host, struct mmc_data *data) if (data == NULL) return; - DBG("blksz %04x blks %04x flags %08x\n", - data->blksz, data->blocks, data->flags); - DBG("tsac %d ms nsac %d clk\n", - data->timeout_ns / 1000000, data->timeout_clks); - /* Sanity checks */ BUG_ON(data->blksz * data->blocks > 524288); BUG_ON(data->blksz > host->mmc->max_blk_size); @@ -495,8 +490,6 @@ static void sdhci_finish_data(struct sdhci_host *host) data->error = MMC_ERR_FAILED; } - DBG("Ending data transfer (%d bytes)\n", data->bytes_xfered); - if (data->stop) { /* * The controller needs a reset of internal state machines @@ -520,8 +513,6 @@ static void sdhci_send_command(struct sdhci_host *host, struct mmc_command *cmd) WARN_ON(host->cmd); - DBG("Sending cmd (%x)\n", cmd->opcode); - /* Wait max 10 ms */ timeout = 10; @@ -609,8 +600,6 @@ static void sdhci_finish_command(struct sdhci_host *host) host->cmd->error = MMC_ERR_NONE; - DBG("Ending cmd (%x)\n", host->cmd->opcode); - if (host->cmd->data) host->data = host->cmd->data; else @@ -862,8 +851,6 @@ static void sdhci_tasklet_finish(unsigned long param) mrq = host->mrq; - DBG("Ending request, cmd (%x)\n", mrq->cmd->opcode); - /* * The controller needs a reset of internal state machines * upon error conditions. diff --git a/drivers/mmc/host/wbsd.c b/drivers/mmc/host/wbsd.c index 1d7ebf35355..e0c9808fd42 100644 --- a/drivers/mmc/host/wbsd.c +++ b/drivers/mmc/host/wbsd.c @@ -207,8 +207,6 @@ static void wbsd_request_end(struct wbsd_host *host, struct mmc_request *mrq) { unsigned long dmaflags; - DBGF("Ending request, cmd (%x)\n", mrq->cmd->opcode); - if (host->dma >= 0) { /* * Release ISA DMA controller. @@ -360,8 +358,6 @@ static void wbsd_send_command(struct wbsd_host *host, struct mmc_command *cmd) int i; u8 status, isr; - DBGF("Sending cmd (%x)\n", cmd->opcode); - /* * Clear accumulated ISR. The interrupt routine * will fill this one with events that occur during @@ -411,8 +407,6 @@ static void wbsd_send_command(struct wbsd_host *host, struct mmc_command *cmd) wbsd_get_short_reply(host, cmd); } } - - DBGF("Sent cmd (%x), res %d\n", cmd->opcode, cmd->error); } /* @@ -550,11 +544,6 @@ static void wbsd_prepare_data(struct wbsd_host *host, struct mmc_data *data) unsigned long dmaflags; unsigned int size; - DBGF("blksz %04x blks %04x flags %08x\n", - data->blksz, data->blocks, data->flags); - DBGF("tsac %d ms nsac %d clk\n", - data->timeout_ns / 1000000, data->timeout_clks); - /* * Calculate size. */ @@ -752,8 +741,6 @@ static void wbsd_finish_data(struct wbsd_host *host, struct mmc_data *data) } } - DBGF("Ending data transfer (%d bytes)\n", data->bytes_xfered); - wbsd_request_end(host, host->mrq); } -- cgit v1.2.3 From facba9179e3cd5fa91ff40bbc555c5cd4c101092 Mon Sep 17 00:00:00 2001 From: Pierre Ossman Date: Tue, 24 Jul 2007 21:53:43 +0200 Subject: mmc: add missing printk levels Some printk:s were missing an explicit level. Signed-off-by: Pierre Ossman --- drivers/mmc/core/mmc.c | 4 ++-- drivers/mmc/core/sd.c | 14 ++++++-------- 2 files changed, 8 insertions(+), 10 deletions(-) (limited to 'drivers/mmc') diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c index f606b6678b0..21d7f48e1d4 100644 --- a/drivers/mmc/core/mmc.c +++ b/drivers/mmc/core/mmc.c @@ -100,7 +100,7 @@ static int mmc_decode_cid(struct mmc_card *card) break; default: - printk("%s: card has unknown MMCA version %d\n", + printk(KERN_ERR "%s: card has unknown MMCA version %d\n", mmc_hostname(card->host), card->csd.mmca_vsn); return -EINVAL; } @@ -123,7 +123,7 @@ static int mmc_decode_csd(struct mmc_card *card) */ csd_struct = UNSTUFF_BITS(resp, 126, 2); if (csd_struct != 1 && csd_struct != 2) { - printk("%s: unrecognised CSD structure version %d\n", + printk(KERN_ERR "%s: unrecognised CSD structure version %d\n", mmc_hostname(card->host), csd_struct); return -EINVAL; } diff --git a/drivers/mmc/core/sd.c b/drivers/mmc/core/sd.c index b6a2e53c921..1edc62b1e5c 100644 --- a/drivers/mmc/core/sd.c +++ b/drivers/mmc/core/sd.c @@ -149,7 +149,7 @@ static int mmc_decode_csd(struct mmc_card *card) csd->write_partial = 0; break; default: - printk("%s: unrecognised CSD structure version %d\n", + printk(KERN_ERR "%s: unrecognised CSD structure version %d\n", mmc_hostname(card->host), csd_struct); return -EINVAL; } @@ -173,7 +173,7 @@ static int mmc_decode_scr(struct mmc_card *card) scr_struct = UNSTUFF_BITS(resp, 60, 4); if (scr_struct != 0) { - printk("%s: unrecognised SCR structure version %d\n", + printk(KERN_ERR "%s: unrecognised SCR structure version %d\n", mmc_hostname(card->host), scr_struct); return -EINVAL; } @@ -206,9 +206,8 @@ static int mmc_read_switch(struct mmc_card *card) status = kmalloc(64, GFP_KERNEL); if (!status) { - printk("%s: could not allocate a buffer for switch " - "capabilities.\n", - mmc_hostname(card->host)); + printk(KERN_ERR "%s: could not allocate a buffer for " + "switch capabilities.\n", mmc_hostname(card->host)); return err; } @@ -254,9 +253,8 @@ static int mmc_switch_hs(struct mmc_card *card) status = kmalloc(64, GFP_KERNEL); if (!status) { - printk("%s: could not allocate a buffer for switch " - "capabilities.\n", - mmc_hostname(card->host)); + printk(KERN_ERR "%s: could not allocate a buffer for " + "switch capabilities.\n", mmc_hostname(card->host)); return err; } -- cgit v1.2.3 From 393618510d5349e07d71dc28fb6fc49baf0d96a0 Mon Sep 17 00:00:00 2001 From: Adrian Bunk Date: Wed, 25 Jul 2007 00:40:58 +0200 Subject: drivers/mmc/core/: make 3 functions static This patch makes the following needlessly global functions static: - sd_ops.c: mmc_app_cmd() - core.c: __mmc_release_bus() - core.c: mmc_start_request() Signed-off-by: Adrian Bunk Signed-off-by: Pierre Ossman --- drivers/mmc/core/core.c | 63 ++++++++++++++++++++++++++++++----------------- drivers/mmc/core/core.h | 22 ----------------- drivers/mmc/core/sd_ops.c | 58 +++++++++++++++++++++---------------------- drivers/mmc/core/sd_ops.h | 1 - 4 files changed, 69 insertions(+), 75 deletions(-) (limited to 'drivers/mmc') diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c index d08968470c4..bfd2ae5bd66 100644 --- a/drivers/mmc/core/core.c +++ b/drivers/mmc/core/core.c @@ -102,15 +102,7 @@ void mmc_request_done(struct mmc_host *host, struct mmc_request *mrq) EXPORT_SYMBOL(mmc_request_done); -/** - * mmc_start_request - start a command on a host - * @host: MMC host to start command on - * @mrq: MMC request to start - * - * Queue a command on the specified host. We expect the - * caller to be holding the host lock with interrupts disabled. - */ -void +static void mmc_start_request(struct mmc_host *host, struct mmc_request *mrq) { #ifdef CONFIG_MMC_DEBUG @@ -165,8 +157,6 @@ mmc_start_request(struct mmc_host *host, struct mmc_request *mrq) host->ops->request(host, mrq); } -EXPORT_SYMBOL(mmc_start_request); - static void mmc_wait_done(struct mmc_request *mrq) { complete(mrq->done_data); @@ -471,6 +461,45 @@ static void mmc_power_off(struct mmc_host *host) mmc_set_ios(host); } +/* + * Cleanup when the last reference to the bus operator is dropped. + */ +void __mmc_release_bus(struct mmc_host *host) +{ + BUG_ON(!host); + BUG_ON(host->bus_refs); + BUG_ON(!host->bus_dead); + + host->bus_ops = NULL; +} + +/* + * Increase reference count of bus operator + */ +static inline void mmc_bus_get(struct mmc_host *host) +{ + unsigned long flags; + + spin_lock_irqsave(&host->lock, flags); + host->bus_refs++; + spin_unlock_irqrestore(&host->lock, flags); +} + +/* + * Decrease reference count of bus operator and free it if + * it is the last reference. + */ +static inline void mmc_bus_put(struct mmc_host *host) +{ + unsigned long flags; + + spin_lock_irqsave(&host->lock, flags); + host->bus_refs--; + if ((host->bus_refs == 0) && host->bus_ops) + __mmc_release_bus(host); + spin_unlock_irqrestore(&host->lock, flags); +} + /* * Assign a mmc bus handler to a host. Only one bus handler may control a * host at any given time. @@ -520,18 +549,6 @@ void mmc_detach_bus(struct mmc_host *host) mmc_bus_put(host); } -/* - * Cleanup when the last reference to the bus operator is dropped. - */ -void __mmc_release_bus(struct mmc_host *host) -{ - BUG_ON(!host); - BUG_ON(host->bus_refs); - BUG_ON(!host->bus_dead); - - host->bus_ops = NULL; -} - /** * mmc_detect_change - process change of state on a MMC socket * @host: host which changed state. diff --git a/drivers/mmc/core/core.h b/drivers/mmc/core/core.h index ae006b30dd8..bb2774af9ea 100644 --- a/drivers/mmc/core/core.h +++ b/drivers/mmc/core/core.h @@ -27,28 +27,6 @@ struct mmc_bus_ops { void mmc_attach_bus(struct mmc_host *host, const struct mmc_bus_ops *ops); void mmc_detach_bus(struct mmc_host *host); -void __mmc_release_bus(struct mmc_host *host); - -static inline void mmc_bus_get(struct mmc_host *host) -{ - unsigned long flags; - - spin_lock_irqsave(&host->lock, flags); - host->bus_refs++; - spin_unlock_irqrestore(&host->lock, flags); -} - -static inline void mmc_bus_put(struct mmc_host *host) -{ - unsigned long flags; - - spin_lock_irqsave(&host->lock, flags); - host->bus_refs--; - if ((host->bus_refs == 0) && host->bus_ops) - __mmc_release_bus(host); - spin_unlock_irqrestore(&host->lock, flags); -} - void mmc_set_chip_select(struct mmc_host *host, int mode); void mmc_set_clock(struct mmc_host *host, unsigned int hz); void mmc_set_bus_mode(struct mmc_host *host, unsigned int mode); diff --git a/drivers/mmc/core/sd_ops.c b/drivers/mmc/core/sd_ops.c index ee9a1b9f599..342f340ebc2 100644 --- a/drivers/mmc/core/sd_ops.c +++ b/drivers/mmc/core/sd_ops.c @@ -21,6 +21,35 @@ #include "core.h" #include "sd_ops.h" +static int mmc_app_cmd(struct mmc_host *host, struct mmc_card *card) +{ + int err; + struct mmc_command cmd; + + BUG_ON(!host); + BUG_ON(card && (card->host != host)); + + cmd.opcode = MMC_APP_CMD; + + if (card) { + cmd.arg = card->rca << 16; + cmd.flags = MMC_RSP_R1 | MMC_CMD_AC; + } else { + cmd.arg = 0; + cmd.flags = MMC_RSP_R1 | MMC_CMD_BCR; + } + + err = mmc_wait_for_cmd(host, &cmd, 0); + if (err != MMC_ERR_NONE) + return err; + + /* Check that card supported application commands */ + if (!(cmd.resp[0] & R1_APP_CMD)) + return MMC_ERR_FAILED; + + return MMC_ERR_NONE; +} + /** * mmc_wait_for_app_cmd - start an application command and wait for completion @@ -77,35 +106,6 @@ int mmc_wait_for_app_cmd(struct mmc_host *host, struct mmc_card *card, EXPORT_SYMBOL(mmc_wait_for_app_cmd); -int mmc_app_cmd(struct mmc_host *host, struct mmc_card *card) -{ - int err; - struct mmc_command cmd; - - BUG_ON(!host); - BUG_ON(card && (card->host != host)); - - cmd.opcode = MMC_APP_CMD; - - if (card) { - cmd.arg = card->rca << 16; - cmd.flags = MMC_RSP_R1 | MMC_CMD_AC; - } else { - cmd.arg = 0; - cmd.flags = MMC_RSP_R1 | MMC_CMD_BCR; - } - - err = mmc_wait_for_cmd(host, &cmd, 0); - if (err != MMC_ERR_NONE) - return err; - - /* Check that card supported application commands */ - if (!(cmd.resp[0] & R1_APP_CMD)) - return MMC_ERR_FAILED; - - return MMC_ERR_NONE; -} - int mmc_app_set_bus_width(struct mmc_card *card, int width) { int err; diff --git a/drivers/mmc/core/sd_ops.h b/drivers/mmc/core/sd_ops.h index 09ca52fca2f..9742d8a3066 100644 --- a/drivers/mmc/core/sd_ops.h +++ b/drivers/mmc/core/sd_ops.h @@ -12,7 +12,6 @@ #ifndef _MMC_SD_OPS_H #define _MMC_SD_OPS_H -int mmc_app_cmd(struct mmc_host *host, struct mmc_card *card); int mmc_app_set_bus_width(struct mmc_card *card, int width); int mmc_send_app_op_cond(struct mmc_host *host, u32 ocr, u32 *rocr); int mmc_send_if_cond(struct mmc_host *host, u32 ocr); -- cgit v1.2.3