]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
MFD,mmc: tmio_mmc: make HCLK configurable
authorPhilipp Zabel <philipp.zabel@gmail.com>
Thu, 4 Jun 2009 18:12:31 +0000 (20:12 +0200)
committerPierre Ossman <pierre@ossman.eu>
Sat, 13 Jun 2009 20:42:59 +0000 (22:42 +0200)
The Toshiba parts all have a 24 MHz HCLK, but HTC ASIC3 has a 24.576 MHz HCLK
and AMD Imageon w228x's HCLK is 80 MHz. With this patch, the MFD driver
provides the HCLK frequency to tmio_mmc via mfd_cell->driver_data.

Signed-off-by: Philipp Zabel <philipp.zabel@gmail.com>
Acked-by: Ian Molton <ian@mnementh.co.uk>
Acked-by: Samuel Ortiz <sameo@openedhand.com>
Signed-off-by: Pierre Ossman <pierre@ossman.eu>
drivers/mfd/t7l66xb.c
drivers/mfd/tc6387xb.c
drivers/mfd/tc6393xb.c
drivers/mmc/host/tmio_mmc.c
include/linux/mfd/tmio.h

index e9f4323dd2cb4ea67e6263ec75059b3c5604cc85..875f7a875734252cd868996ec048a53793e9deb3 100644 (file)
@@ -108,6 +108,10 @@ static int t7l66xb_mmc_disable(struct platform_device *mmc)
 
 /*--------------------------------------------------------------------------*/
 
+static const struct tmio_mmc_data t7166xb_mmc_data = {
+       .hclk = 24000000,
+};
+
 static const struct resource t7l66xb_mmc_resources[] = {
        {
                .start = 0x800,
@@ -149,6 +153,7 @@ static struct mfd_cell t7l66xb_cells[] = {
                .name = "tmio-mmc",
                .enable = t7l66xb_mmc_enable,
                .disable = t7l66xb_mmc_disable,
+               .driver_data = &t7166xb_mmc_data,
                .num_resources = ARRAY_SIZE(t7l66xb_mmc_resources),
                .resources = t7l66xb_mmc_resources,
        },
index 43222c12fec14fc906993322c31f3cbad89f3e41..c3993ac20542db00bdc2e5e6a8c54a244d3a3e4a 100644 (file)
@@ -75,6 +75,10 @@ static int tc6387xb_mmc_disable(struct platform_device *mmc)
 
 /*--------------------------------------------------------------------------*/
 
+const static struct tmio_mmc_data tc6387xb_mmc_data = {
+       .hclk = 24000000,
+};
+
 static struct resource tc6387xb_mmc_resources[] = {
        {
                .start = 0x800,
@@ -98,6 +102,7 @@ static struct mfd_cell tc6387xb_cells[] = {
                .name = "tmio-mmc",
                .enable = tc6387xb_mmc_enable,
                .disable = tc6387xb_mmc_disable,
+               .driver_data = &tc6387xb_mmc_data,
                .num_resources = ARRAY_SIZE(tc6387xb_mmc_resources),
                .resources = tc6387xb_mmc_resources,
        },
index 77a12fc8045e4367fff065f861237035e658f597..9d2abb5d6e2cd4c69f4b535583b41fa89fce2242 100644 (file)
@@ -136,6 +136,10 @@ static int tc6393xb_nand_enable(struct platform_device *nand)
        return 0;
 }
 
+const static struct tmio_mmc_data tc6393xb_mmc_data = {
+       .hclk = 24000000,
+};
+
 static struct resource __devinitdata tc6393xb_nand_resources[] = {
        {
                .start  = 0x1000,
@@ -351,6 +355,7 @@ static struct mfd_cell __devinitdata tc6393xb_cells[] = {
        },
        [TC6393XB_CELL_MMC] = {
                .name = "tmio-mmc",
+               .driver_data = &tc6393xb_mmc_data,
                .num_resources = ARRAY_SIZE(tc6393xb_mmc_resources),
                .resources = tc6393xb_mmc_resources,
        },
index 63fbd5b7d312b503e285a68a1895af709c134027..49df71e6be178d77039c375d97067c0198177d1e 100644 (file)
 
 #include "tmio_mmc.h"
 
-/*
- * Fixme - documentation conflicts on what the clock values are for the
- * various dividers.
- * One document I have says that its a divisor of a 24MHz clock, another 33.
- * This probably depends on HCLK for a given platform, so we may need to
- * require HCLK be passed to us from the MFD core.
- *
- */
-
 static void tmio_mmc_set_clock(struct tmio_mmc_host *host, int new_clock)
 {
        void __iomem *cnf = host->cnf;
        void __iomem *ctl = host->ctl;
-       u32 clk = 0, clock;
+       u32 clk = 0, clock, f_min = host->mmc->f_min;
 
        if (new_clock) {
-               for (clock = 46875, clk = 0x100; new_clock >= (clock<<1); ) {
+               for (clock = f_min, clk = 0x100; new_clock >= (clock<<1); ) {
                        clock <<= 1;
                        clk >>= 1;
                }
@@ -545,6 +536,7 @@ static int tmio_mmc_resume(struct platform_device *dev)
 static int __devinit tmio_mmc_probe(struct platform_device *dev)
 {
        struct mfd_cell *cell = (struct mfd_cell *)dev->dev.platform_data;
+       struct tmio_mmc_data *pdata;
        struct resource *res_ctl, *res_cnf;
        struct tmio_mmc_host *host;
        struct mmc_host *mmc;
@@ -560,6 +552,12 @@ static int __devinit tmio_mmc_probe(struct platform_device *dev)
                goto out;
        }
 
+       pdata = cell->driver_data;
+       if (!pdata || !pdata->hclk) {
+               ret = -EINVAL;
+               goto out;
+       }
+
        mmc = mmc_alloc_host(sizeof(struct tmio_mmc_host), &dev->dev);
        if (!mmc)
                goto out;
@@ -578,8 +576,8 @@ static int __devinit tmio_mmc_probe(struct platform_device *dev)
 
        mmc->ops = &tmio_mmc_ops;
        mmc->caps = MMC_CAP_4_BIT_DATA;
-       mmc->f_min = 46875; /* 24000000 / 512 */
-       mmc->f_max = 24000000;
+       mmc->f_max = pdata->hclk;
+       mmc->f_min = mmc->f_max / 512;
        mmc->ocr_avail = MMC_VDD_32_33 | MMC_VDD_33_34;
 
        /* Enable the MMC/SD Control registers */
index 516d955ab8a1bb9e63120a3bb79c0f0d4e08e297..c377118884e66bd61fd87d5ffaa247effd5fb5ae 100644 (file)
        writew((val) >> 16, (addr) + 2); \
        } while (0)
 
+/*
+ * data for the MMC controller
+ */
+struct tmio_mmc_data {
+       unsigned int            hclk;
+};
+
 /*
  * data for the NAND controller
  */