From patchwork Wed Mar 14 14:19:59 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 7293 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 191E723E0C for ; Wed, 14 Mar 2012 14:20:12 +0000 (UTC) Received: from mail-iy0-f180.google.com (mail-iy0-f180.google.com [209.85.210.180]) by fiordland.canonical.com (Postfix) with ESMTP id B9D68A18761 for ; Wed, 14 Mar 2012 14:20:11 +0000 (UTC) Received: by iage36 with SMTP id e36so3236838iag.11 for ; Wed, 14 Mar 2012 07:20:11 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-forwarded-to:x-forwarded-for:delivered-to:received-spf:from:to:cc :subject:date:message-id:x-mailer:in-reply-to:references :x-gm-message-state; bh=E5D54BNiJl11oIo4pQD/UrclV8vS2t91vF5INAlj8/E=; b=NgsCEh6dKm7B6CnGMA8B107+qpFmOXnUMagOSnQ1jdcEUD0A5h2M0oqC6NkSCQJiR1 78EyfAqZkBo33efrpqbgTG8pnTCJeRfvR2nr4uoWrivWqnWPZ4boEwPndkUQf5NeSHxr Tnv72HHxakPw3rPwiY8aFRls4kK7NcznU8qONbUZXhM2Nuq5KgHfSXNQmM/6BxGWUtNr qD3WNRNI6HPZTA1lTCuBTTWwxtXG/qjRUC3qIN0PP94HYpgnQg/8D1q2sQVCuR9zlGjR RB6O7fCHcdl9153aLM2gi44we+XjWR86Qpuqr/zHgxlBexaYaUuFb7ESAz5pI3JKCrXm iRiA== Received: by 10.50.45.228 with SMTP id q4mr4724246igm.58.1331734811133; Wed, 14 Mar 2012 07:20:11 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.231.53.18 with SMTP id k18csp11181ibg; Wed, 14 Mar 2012 07:20:10 -0700 (PDT) Received: by 10.180.102.102 with SMTP id fn6mr17500738wib.10.1331734809470; Wed, 14 Mar 2012 07:20:09 -0700 (PDT) Received: from mail-wi0-f172.google.com (mail-wi0-f172.google.com [209.85.212.172]) by mx.google.com with ESMTPS id cr10si5708051wib.34.2012.03.14.07.20.09 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 14 Mar 2012 07:20:09 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.212.172 is neither permitted nor denied by best guess record for domain of lee.jones@linaro.org) client-ip=209.85.212.172; Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.212.172 is neither permitted nor denied by best guess record for domain of lee.jones@linaro.org) smtp.mail=lee.jones@linaro.org Received: by mail-wi0-f172.google.com with SMTP id hj6so5879217wib.13 for ; Wed, 14 Mar 2012 07:20:09 -0700 (PDT) Received: by 10.180.102.100 with SMTP id fn4mr6887825wib.1.1331734808950; Wed, 14 Mar 2012 07:20:08 -0700 (PDT) Received: from localhost.localdomain (cpc1-aztw13-0-0-cust473.18-1.cable.virginmedia.com. [77.102.241.218]) by mx.google.com with ESMTPS id d7sm17077247wiz.6.2012.03.14.07.20.07 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 14 Mar 2012 07:20:08 -0700 (PDT) From: Lee Jones To: linux-arm-kernel@lists.infradead.org Cc: cjb@laptop.org, arnd@arndb.de, niklas.hernaeus@linaro.org, linux-mmc@vger.kernel.org, Lee Jones Subject: [PATCH 1/5] MMC: mmci: Seperate ux500 variants from generic code Date: Wed, 14 Mar 2012 14:19:59 +0000 Message-Id: <1331734803-17954-2-git-send-email-lee.jones@linaro.org> X-Mailer: git-send-email 1.7.5.4 In-Reply-To: <1331734803-17954-1-git-send-email-lee.jones@linaro.org> References: <1331734803-17954-1-git-send-email-lee.jones@linaro.org> X-Gm-Message-State: ALoCoQliQKH9g4KRoxqtFNhPxPjUl3fZU9wMLuwPMPv+AZqGh7OKhjaFb5rOQWWQBa++C4Zb9fFm This is a step in the right direction for future Device Tree support. It will allow variant specific attributes to be collected from a Device Tree without overloading the MMCI core. It will also provide additional future variants a cleaner way to add support. Signed-off-by: Lee Jones --- drivers/mmc/host/Makefile | 2 +- drivers/mmc/host/mmci-ux500.c | 93 +++++++++++++++++++++++++++++++++++++++++ drivers/mmc/host/mmci.c | 90 ++++------------------------------------ drivers/mmc/host/mmci.h | 37 ++++++++++++++++ 4 files changed, 139 insertions(+), 83 deletions(-) create mode 100644 drivers/mmc/host/mmci-ux500.c diff --git a/drivers/mmc/host/Makefile b/drivers/mmc/host/Makefile index 745f8fc..58e2bdc 100644 --- a/drivers/mmc/host/Makefile +++ b/drivers/mmc/host/Makefile @@ -2,7 +2,7 @@ # Makefile for MMC/SD host controller drivers # -obj-$(CONFIG_MMC_ARMMMCI) += mmci.o +obj-$(CONFIG_MMC_ARMMMCI) += mmci.o mmci-ux500.o obj-$(CONFIG_MMC_PXA) += pxamci.o obj-$(CONFIG_MMC_IMX) += imxmmc.o obj-$(CONFIG_MMC_MXC) += mxcmmc.o diff --git a/drivers/mmc/host/mmci-ux500.c b/drivers/mmc/host/mmci-ux500.c new file mode 100644 index 0000000..82e60f9 --- /dev/null +++ b/drivers/mmc/host/mmci-ux500.c @@ -0,0 +1,93 @@ +#include +#include + +/* MMCIPOWER bits */ +#define MCI_DATA2DIREN (1 << 2) +#define MCI_CMDDIREN (1 << 3) +#define MCI_DATA0DIREN (1 << 4) +#define MCI_DATA31DIREN (1 << 5) +#define MCI_FBCLKEN (1 << 7) + +static struct variant_data variant_u300 = { + .fifosize = 16 * 4, + .fifohalfsize = 8 * 4, + .clkreg_enable = MCI_ST_U300_HWFCEN, + .datalength_bits = 16, + .sdio = true, +}; + +static struct variant_data variant_ux500 = { + .fifosize = 30 * 4, + .fifohalfsize = 8 * 4, + .clkreg = MCI_CLK_ENABLE, + .clkreg_enable = MCI_ST_UX500_HWFCEN, + .datalength_bits = 24, + .sdio = true, + .st_clkdiv = true, +}; + +static struct variant_data variant_ux500v2 = { + .fifosize = 30 * 4, + .fifohalfsize = 8 * 4, + .clkreg = MCI_CLK_ENABLE, + .clkreg_enable = MCI_ST_UX500_HWFCEN, + .datalength_bits = 24, + .sdio = true, + .st_clkdiv = true, + .blksz_datactrl16 = true, +}; + +static struct amba_id mmci_ux500_ids[] = { + /* ST Micro variants */ + { + .id = 0x00180180, + .mask = 0x00ffffff, + .data = &variant_u300, + }, + { + .id = 0x00280180, + .mask = 0x00ffffff, + .data = &variant_u300, + }, + { + .id = 0x00480180, + .mask = 0xf0ffffff, + .data = &variant_ux500, + }, + { + .id = 0x10480180, + .mask = 0xf0ffffff, + .data = &variant_ux500v2, + }, + { 0, 0 }, +}; + +MODULE_DEVICE_TABLE(amba, mmci_ux500_ids); + +static struct amba_driver mmci_ux500_driver = { + .drv = { + .name = DRIVER_NAME, + }, + .probe = mmci_probe, + .remove = __devexit_p(mmci_remove), + .suspend = mmci_suspend, + .resume = mmci_resume, + .id_table = mmci_ux500_ids, +}; + +static int __init mmci_ux500_init(void) +{ + return amba_driver_register(&mmci_ux500_driver); +} + +static void __exit mmci_ux500_exit(void) +{ + amba_driver_unregister(&mmci_ux500_driver); +} + +module_init(mmci_ux500_init); +module_exit(mmci_ux500_exit); +module_param(fmax, uint, 0444); + +MODULE_DESCRIPTION("ARM PrimeCell PL180/181 Multimedia Card Interface driver"); +MODULE_LICENSE("GPL"); diff --git a/drivers/mmc/host/mmci.c b/drivers/mmc/host/mmci.c index 304f2f9..ff44586 100644 --- a/drivers/mmc/host/mmci.c +++ b/drivers/mmc/host/mmci.c @@ -37,34 +37,6 @@ #include "mmci.h" -#define DRIVER_NAME "mmci-pl18x" - -static unsigned int fmax = 515633; - -/** - * struct variant_data - MMCI variant-specific quirks - * @clkreg: default value for MCICLOCK register - * @clkreg_enable: enable value for MMCICLOCK register - * @datalength_bits: number of bits in the MMCIDATALENGTH register - * @fifosize: number of bytes that can be written when MMCI_TXFIFOEMPTY - * is asserted (likewise for RX) - * @fifohalfsize: number of bytes that can be written when MCI_TXFIFOHALFEMPTY - * is asserted (likewise for RX) - * @sdio: variant supports SDIO - * @st_clkdiv: true if using a ST-specific clock divider algorithm - * @blksz_datactrl16: true if Block size is at b16..b30 position in datactrl register - */ -struct variant_data { - unsigned int clkreg; - unsigned int clkreg_enable; - unsigned int datalength_bits; - unsigned int fifosize; - unsigned int fifohalfsize; - bool sdio; - bool st_clkdiv; - bool blksz_datactrl16; -}; - static struct variant_data variant_arm = { .fifosize = 16 * 4, .fifohalfsize = 8 * 4, @@ -77,35 +49,6 @@ static struct variant_data variant_arm_extended_fifo = { .datalength_bits = 16, }; -static struct variant_data variant_u300 = { - .fifosize = 16 * 4, - .fifohalfsize = 8 * 4, - .clkreg_enable = MCI_ST_U300_HWFCEN, - .datalength_bits = 16, - .sdio = true, -}; - -static struct variant_data variant_ux500 = { - .fifosize = 30 * 4, - .fifohalfsize = 8 * 4, - .clkreg = MCI_CLK_ENABLE, - .clkreg_enable = MCI_ST_UX500_HWFCEN, - .datalength_bits = 24, - .sdio = true, - .st_clkdiv = true, -}; - -static struct variant_data variant_ux500v2 = { - .fifosize = 30 * 4, - .fifohalfsize = 8 * 4, - .clkreg = MCI_CLK_ENABLE, - .clkreg_enable = MCI_ST_UX500_HWFCEN, - .datalength_bits = 24, - .sdio = true, - .st_clkdiv = true, - .blksz_datactrl16 = true, -}; - /* * This must be called with host->lock held */ @@ -1125,7 +1068,7 @@ static const struct mmc_host_ops mmci_ops = { .get_cd = mmci_get_cd, }; -static int __devinit mmci_probe(struct amba_device *dev, +extern int __devinit mmci_probe(struct amba_device *dev, const struct amba_id *id) { struct mmci_platform_data *plat = dev->dev.platform_data; @@ -1376,8 +1319,9 @@ static int __devinit mmci_probe(struct amba_device *dev, out: return ret; } +EXPORT_SYMBOL_GPL(mmci_probe); -static int __devexit mmci_remove(struct amba_device *dev) +extern int __devexit mmci_remove(struct amba_device *dev) { struct mmc_host *mmc = amba_get_drvdata(dev); @@ -1428,9 +1372,10 @@ static int __devexit mmci_remove(struct amba_device *dev) return 0; } +EXPORT_SYMBOL_GPL(mmci_remove); #ifdef CONFIG_PM -static int mmci_suspend(struct amba_device *dev, pm_message_t state) +extern int mmci_suspend(struct amba_device *dev, pm_message_t state) { struct mmc_host *mmc = amba_get_drvdata(dev); int ret = 0; @@ -1445,8 +1390,9 @@ static int mmci_suspend(struct amba_device *dev, pm_message_t state) return ret; } +EXPORT_SYMBOL_GPL(mmci_suspend); -static int mmci_resume(struct amba_device *dev) +extern int mmci_resume(struct amba_device *dev) { struct mmc_host *mmc = amba_get_drvdata(dev); int ret = 0; @@ -1461,6 +1407,7 @@ static int mmci_resume(struct amba_device *dev) return ret; } +EXPORT_SYMBOL_GPL(mmci_resume); #else #define mmci_suspend NULL #define mmci_resume NULL @@ -1482,27 +1429,6 @@ static struct amba_id mmci_ids[] = { .mask = 0x000fffff, .data = &variant_arm, }, - /* ST Micro variants */ - { - .id = 0x00180180, - .mask = 0x00ffffff, - .data = &variant_u300, - }, - { - .id = 0x00280180, - .mask = 0x00ffffff, - .data = &variant_u300, - }, - { - .id = 0x00480180, - .mask = 0xf0ffffff, - .data = &variant_ux500, - }, - { - .id = 0x10480180, - .mask = 0xf0ffffff, - .data = &variant_ux500v2, - }, { 0, 0 }, }; diff --git a/drivers/mmc/host/mmci.h b/drivers/mmc/host/mmci.h index 79e4143..4ede20d 100644 --- a/drivers/mmc/host/mmci.h +++ b/drivers/mmc/host/mmci.h @@ -7,6 +7,12 @@ * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. */ +#include +#include +#include + +#define DRIVER_NAME "mmci-pl18x" + #define MMCIPOWER 0x000 #define MCI_PWR_OFF 0x00 #define MCI_PWR_UP 0x02 @@ -162,6 +168,8 @@ #define NR_SG 16 +static unsigned int fmax = 515633; + struct clk; struct variant_data; struct dma_chan; @@ -218,3 +226,32 @@ struct mmci_host { #endif }; +/** + * struct variant_data - MMCI variant-specific quirks + * @clkreg: default value for MCICLOCK register + * @clkreg_enable: enable value for MMCICLOCK register + * @datalength_bits: number of bits in the MMCIDATALENGTH register + * @fifosize: number of bytes that can be written when MMCI_TXFIFOEMPTY + * is asserted (likewise for RX) + * @fifohalfsize: number of bytes that can be written when MCI_TXFIFOHALFEMPTY + * is asserted (likewise for RX) + * @sdio: variant supports SDIO + * @st_clkdiv: true if using a ST-specific clock divider algorithm + * @blksz_datactrl16: true if Block size is at b16..b30 position in datactrl register + */ +struct variant_data { + unsigned int clkreg; + unsigned int clkreg_enable; + unsigned int datalength_bits; + unsigned int fifosize; + unsigned int fifohalfsize; + bool sdio; + bool st_clkdiv; + bool blksz_datactrl16; +}; + +extern int __devinit mmci_probe(struct amba_device *dev, + const struct amba_id *id); +extern int __devexit mmci_remove(struct amba_device *dev); +extern int mmci_suspend(struct amba_device *dev, pm_message_t state); +extern int mmci_resume(struct amba_device *dev);