From patchwork Thu Sep 10 12:56:41 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Albert Herranz X-Patchwork-Id: 46609 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n8AD4LmQ016072 for ; Thu, 10 Sep 2009 13:04:21 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755635AbZIJND3 (ORCPT ); Thu, 10 Sep 2009 09:03:29 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1755658AbZIJND0 (ORCPT ); Thu, 10 Sep 2009 09:03:26 -0400 Received: from smtp124.mail.ukl.yahoo.com ([77.238.184.55]:48349 "HELO smtp124.mail.ukl.yahoo.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1755642AbZIJNDZ (ORCPT ); Thu, 10 Sep 2009 09:03:25 -0400 Received: (qmail 26800 invoked from network); 10 Sep 2009 12:56:46 -0000 DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.es; h=Received:X-Yahoo-SMTP:X-YMail-OSG:X-Yahoo-Newman-Property:From:To:Cc:Subject:Date:Message-Id:X-Mailer; b=RnYwg8Vf67Z261Dfa4jmDw1LtkIdZsuUYgbKCSydYZyhtxsZ1tuf4MY3FocXHzOGbNR5mW7+AWkZNc48nuFXSzTaeuHeFio/zL8ZRecVXqv7slBCPrKojEMKM1GHT8nKyKvdP4DElXINLgS23AZ/PSUdq3oACxiUUubXQUZxZUE= ; Received: from unknown (HELO localhost.localdomain) (albert_herranz@81.38.33.208 with login) by smtp124.mail.ukl.yahoo.com with SMTP; 10 Sep 2009 12:56:45 -0000 X-Yahoo-SMTP: yzfTu2iswBCrTtVxL1RxVhyxF0Jj1aEHQh0OXhvjVDt_5sQx X-YMail-OSG: nxEkcCMVM1nGLrZ5d.5dQpI96xDMn8Qh3iYODuiFczd7SxSP0uogM9NZhtx_aLWMdFFbRCVnAMsfW5Z30AzuYsQ7W3d7y9lScd.xIgjlaTJLazVwvPaqF26L8zw1mnMJyFoPTS8HVlHwL8LBY5YqLS3uDnpRnIXLNDxoPJkGjgUGXm0pI7f_5u4PMKURHFw0Ds1nb.JG9Bk3i8tk81KB5IvndRJPKdOAzpTnTZZEs3pg3bsoxoPskTeXKnOVQqmXYf0fV1t.xtclCFTdBcwPZeYZp2.03BnyDAxZSg-- X-Yahoo-Newman-Property: ymail-3 From: Albert Herranz To: akpm@linux-foundation.org, linux-mmc@vger.kernel.org Cc: bcm43xx-dev@lists.berlios.de, linux-wireless@vger.kernel.org, Albert Herranz Subject: [PATCH] sdio: recognize io card without powercycle Date: Thu, 10 Sep 2009 14:56:41 +0200 Message-Id: <1252587402-7382-1-git-send-email-albert_herranz@yahoo.es> X-Mailer: git-send-email 1.6.0.4 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org SDIO Simplified Specification V2.00 states that it is strongly recommended that the host executes either a power reset or issues a CMD52 (I/O Reset) to re-initialize an I/O only card or the I/O portion of a combo card. Additionally, the CMD52 must be issued first because it cannot be issued after a CMD0. With this patch the Nintendo Wii SDIO-based WLAN card is detected after a system reset, without requiring a complete system powercycle. Signed-off-by: Albert Herranz --- v1 - reworded commit message - CC'd akpm as suggested by mb drivers/mmc/core/core.c | 1 + drivers/mmc/core/sdio_ops.c | 36 ++++++++++++++++++++++++++++++------ drivers/mmc/core/sdio_ops.h | 1 + 3 files changed, 32 insertions(+), 6 deletions(-) diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c index d84c880..c768f70 100644 --- a/drivers/mmc/core/core.c +++ b/drivers/mmc/core/core.c @@ -890,6 +890,7 @@ void mmc_rescan(struct work_struct *work) mmc_claim_host(host); mmc_power_up(host); + sdio_go_idle(host); mmc_go_idle(host); mmc_send_if_cond(host, host->ocr_avail); diff --git a/drivers/mmc/core/sdio_ops.c b/drivers/mmc/core/sdio_ops.c index 4eb7825..14d3204 100644 --- a/drivers/mmc/core/sdio_ops.c +++ b/drivers/mmc/core/sdio_ops.c @@ -67,13 +67,13 @@ int mmc_send_io_op_cond(struct mmc_host *host, u32 ocr, u32 *rocr) return err; } -int mmc_io_rw_direct(struct mmc_card *card, int write, unsigned fn, - unsigned addr, u8 in, u8* out) +static int mmc_io_rw_direct_host(struct mmc_host *host, int write, unsigned fn, + unsigned addr, u8 in, u8 *out) { struct mmc_command cmd; int err; - BUG_ON(!card); + BUG_ON(!host); BUG_ON(fn > 7); /* sanity check */ @@ -90,11 +90,11 @@ int mmc_io_rw_direct(struct mmc_card *card, int write, unsigned fn, cmd.arg |= in; cmd.flags = MMC_RSP_SPI_R5 | MMC_RSP_R5 | MMC_CMD_AC; - err = mmc_wait_for_cmd(card->host, &cmd, 0); + err = mmc_wait_for_cmd(host, &cmd, 0); if (err) return err; - if (mmc_host_is_spi(card->host)) { + if (mmc_host_is_spi(host)) { /* host driver already reported errors */ } else { if (cmd.resp[0] & R5_ERROR) @@ -106,7 +106,7 @@ int mmc_io_rw_direct(struct mmc_card *card, int write, unsigned fn, } if (out) { - if (mmc_host_is_spi(card->host)) + if (mmc_host_is_spi(host)) *out = (cmd.resp[0] >> 8) & 0xFF; else *out = cmd.resp[0] & 0xFF; @@ -115,6 +115,13 @@ int mmc_io_rw_direct(struct mmc_card *card, int write, unsigned fn, return 0; } +int mmc_io_rw_direct(struct mmc_card *card, int write, unsigned fn, + unsigned addr, u8 in, u8 *out) +{ + BUG_ON(!card); + return mmc_io_rw_direct_host(card->host, write, fn, addr, in, out); +} + int mmc_io_rw_extended(struct mmc_card *card, int write, unsigned fn, unsigned addr, int incr_addr, u8 *buf, unsigned blocks, unsigned blksz) { @@ -182,3 +189,20 @@ int mmc_io_rw_extended(struct mmc_card *card, int write, unsigned fn, return 0; } +int sdio_go_idle(struct mmc_host *host) +{ + int ret; + u8 abort; + + /* SDIO Simplified Specification V2.0, 4.4 Reset for SDIO */ + + ret = mmc_io_rw_direct_host(host, 0, 0, SDIO_CCCR_ABORT, 0, &abort); + if (ret) + abort = 0x08; + else + abort |= 0x08; + + ret = mmc_io_rw_direct_host(host, 1, 0, SDIO_CCCR_ABORT, abort, NULL); + return ret; +} + diff --git a/drivers/mmc/core/sdio_ops.h b/drivers/mmc/core/sdio_ops.h index e2e74b0..9b546c7 100644 --- a/drivers/mmc/core/sdio_ops.h +++ b/drivers/mmc/core/sdio_ops.h @@ -17,6 +17,7 @@ int mmc_io_rw_direct(struct mmc_card *card, int write, unsigned fn, unsigned addr, u8 in, u8* out); int mmc_io_rw_extended(struct mmc_card *card, int write, unsigned fn, unsigned addr, int incr_addr, u8 *buf, unsigned blocks, unsigned blksz); +int sdio_go_idle(struct mmc_host *host); #endif