From patchwork Fri Oct 1 22:45:50 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Philip Rakity X-Patchwork-Id: 225992 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id o91Mko7u005751 for ; Fri, 1 Oct 2010 22:46:50 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752900Ab0JAWqt (ORCPT ); Fri, 1 Oct 2010 18:46:49 -0400 Received: from na3sys009aog114.obsmtp.com ([74.125.149.211]:42974 "HELO na3sys009aog114.obsmtp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1751466Ab0JAWqt convert rfc822-to-8bit (ORCPT ); Fri, 1 Oct 2010 18:46:49 -0400 Received: from source ([65.219.4.130]) (using TLSv1) by na3sys009aob114.postini.com ([74.125.148.12]) with SMTP ID DSNKTKZk2VsX34Y8Jz5CuBzkRjFyc1pY6Aj9@postini.com; Fri, 01 Oct 2010 15:46:49 PDT Received: from SC-vEXCH3.marvell.com ([10.93.76.133]) by sc-owa02.marvell.com ([10.93.76.22]) with mapi; Fri, 1 Oct 2010 15:45:51 -0700 From: Philip Rakity To: "linux-mmc@vger.kernel.org" Date: Fri, 1 Oct 2010 15:45:50 -0700 Subject: [RFC] sdhci: 8 bit bus width changes Thread-Topic: [RFC] sdhci: 8 bit bus width changes Thread-Index: ActhumXiEdpBl/HvTtO7gLE3BsfZdw== Message-ID: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: acceptlanguage: en-US MIME-Version: 1.0 Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter1.kernel.org [140.211.167.41]); Fri, 01 Oct 2010 22:46:50 +0000 (UTC) ======================================= platform_8bit_width is used to support 8 bit mode using our v2 sd controller. We have private registers that are used for 8 bit support v2 - v3 controller and 8 bit support (SDHCI_QUIRK_SLOT_CAN_DO_8_BITS) ===================================================================== The quirk is needed since we support multiple SD controllers and on the board sometimes 8 data lines are brought out and sometimes only 4. The SD controller indicates it can support 8 bit (v3 controller) via the capability field but has no knowledge of how the pins were configured in the board design. There are only so many pins and the pins are multiplexed. Signed-off-by: Philip Rakity --- drivers/mmc/host/sdhci.c | 44 +++++++++++++++++++++++++++++++++----------- drivers/mmc/host/sdhci.h | 7 ++++++- 2 files changed, 39 insertions(+), 12 deletions(-) diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c index 73a94fe..ec103c3 100644 --- a/drivers/mmc/host/sdhci.c +++ b/drivers/mmc/host/sdhci.c @@ -1182,17 +1182,31 @@ static void sdhci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios) else sdhci_set_power(host, ios->vdd); - ctrl = sdhci_readb(host, SDHCI_HOST_CONTROL); - if (ios->bus_width == MMC_BUS_WIDTH_8) - ctrl |= SDHCI_CTRL_8BITBUS; - else - ctrl &= ~SDHCI_CTRL_8BITBUS; + /* + * use platform_8_bit_width if not v3 controller + * or if special hw/board specific processing is needed + */ + if (host->ops->platform_8bit_width) + host->ops->platform_8bit_width(host, ios->bus_width); + else { + ctrl = sdhci_readb(host, SDHCI_HOST_CONTROL); + if (ios->bus_width == MMC_BUS_WIDTH_8) { + ctrl &= ~SDHCI_CTRL_4BITBUS; + if (host->version >= SDHCI_SPEC_300) + ctrl |= SDHCI_CTRL_8BITBUS; + } else { + if (host->version >= SDHCI_SPEC_300) + ctrl &= ~SDHCI_CTRL_8BITBUS; + if (ios->bus_width == MMC_BUS_WIDTH_4) + ctrl |= SDHCI_CTRL_4BITBUS; + else + ctrl &= ~SDHCI_CTRL_4BITBUS; + } + sdhci_writeb(host, ctrl, SDHCI_HOST_CONTROL); + } - if (ios->bus_width == MMC_BUS_WIDTH_4) - ctrl |= SDHCI_CTRL_4BITBUS; - else - ctrl &= ~SDHCI_CTRL_4BITBUS; + ctrl = sdhci_readb(host, SDHCI_HOST_CONTROL); if (ios->timing == MMC_TIMING_SD_HS && !(host->quirks & SDHCI_QUIRK_NO_HISPD_BIT)) @@ -1838,11 +1852,19 @@ int sdhci_add_host(struct sdhci_host *host) mmc->f_min = host->max_clk / SDHCI_MAX_DIV_SPEC_300; else mmc->f_min = host->max_clk / SDHCI_MAX_DIV_SPEC_200; + mmc->f_max = host->max_clk; mmc->caps |= MMC_CAP_SDIO_IRQ; - if (!(host->quirks & SDHCI_QUIRK_FORCE_1_BIT_DATA)) - mmc->caps |= MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA; + /* 8 bit width may be supported by v3 controller but not board + * so the safest thing is to let the adaption layer decide + * what to do by using the quirk + */ + if (!(host->quirks & SDHCI_QUIRK_FORCE_1_BIT_DATA)) { + mmc->caps |= MMC_CAP_4_BIT_DATA; + if (host->quirks & SDHCI_QUIRK_SLOT_CAN_DO_8_BITS) + mmc->caps |= MMC_CAP_8_BIT_DATA; + } if (caps & SDHCI_CAN_DO_HISPD) mmc->caps |= MMC_CAP_SD_HIGHSPEED | MMC_CAP_MMC_HIGHSPEED; diff --git a/drivers/mmc/host/sdhci.h b/drivers/mmc/host/sdhci.h index 112543a..b3288fd 100644 --- a/drivers/mmc/host/sdhci.h +++ b/drivers/mmc/host/sdhci.h @@ -72,7 +72,7 @@ #define SDHCI_CTRL_ADMA1 0x08 #define SDHCI_CTRL_ADMA32 0x10 #define SDHCI_CTRL_ADMA64 0x18 -#define SDHCI_CTRL_8BITBUS 0x20 +#define SDHCI_CTRL_8BITBUS 0x20 #define SDHCI_POWER_CONTROL 0x29 #define SDHCI_POWER_ON 0x01 @@ -148,6 +148,7 @@ #define SDHCI_CLOCK_BASE_SHIFT 8 #define SDHCI_MAX_BLOCK_MASK 0x00030000 #define SDHCI_MAX_BLOCK_SHIFT 16 +#define SDHCI_CAN_DO_8BIT 0x00040000 #define SDHCI_CAN_DO_ADMA2 0x00080000 #define SDHCI_CAN_DO_ADMA1 0x00100000 #define SDHCI_CAN_DO_HISPD 0x00200000 @@ -260,6 +261,8 @@ struct sdhci_host { #define SDHCI_QUIRK_MULTIBLOCK_READ_ACMD12 (1<<28) /* Controller doesn't have HISPD bit field in HI-SPEED SD card */ #define SDHCI_QUIRK_NO_HISPD_BIT (1<<29) +/* slot has 8 data pins going to eMMC/mmc card */ +#define SDHCI_QUIRK_SLOT_CAN_DO_8_BITS (1<<30) int irq; /* Device IRQ */ void __iomem * ioaddr; /* Mapped address */ @@ -336,6 +339,8 @@ struct sdhci_ops { unsigned int (*get_max_clock)(struct sdhci_host *host); unsigned int (*get_min_clock)(struct sdhci_host *host); unsigned int (*get_timeout_clock)(struct sdhci_host *host); + int (*platform_8bit_width)(struct sdhci_host *host, + int width); }; #ifdef CONFIG_MMC_SDHCI_IO_ACCESSORS