include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit...
[safe/jmp/linux-2.6] / arch / arm / mach-u300 / mmc.c
index 585cc01..77fbb1e 100644 (file)
 #include <linux/regulator/consumer.h>
 #include <linux/regulator/machine.h>
 #include <linux/gpio.h>
+#include <linux/amba/mmci.h>
+#include <linux/slab.h>
 
-#include <asm/mach/mmc.h>
 #include "mmc.h"
+#include "padmux.h"
 
 struct mmci_card_event {
        struct input_dev *mmc_input;
        int mmc_inserted;
        struct work_struct workq;
-       struct mmc_platform_data mmc0_plat_data;
+       struct mmci_platform_data mmc0_plat_data;
 };
 
 static unsigned int mmc_status(struct device *dev)
@@ -39,64 +41,6 @@ static unsigned int mmc_status(struct device *dev)
        return mmci_card->mmc_inserted;
 }
 
-/*
- * Here follows a large chunk of code which will only be enabled if you
- * have both the AB3100 chip mounted and the MMC subsystem activated.
- */
-
-static u32 mmc_translate_vdd(struct device *dev, unsigned int voltage)
-{
-       int v;
-
-       /*
-        * MMC Spec:
-        * bit 7:       1.70 - 1.95V
-        * bit 8 - 14:  2.0 - 2.6V
-        * bit 15 - 23: 2.7 - 3.6V
-        *
-        * ab3100 voltages:
-        * 000 - 2.85V
-        * 001 - 2.75V
-        * 010 - 1.8V
-        * 011 - 1.5V
-        */
-       switch (voltage) {
-       case 8:
-               v = 3;
-               break;
-       case 9:
-       case 10:
-       case 11:
-       case 12:
-       case 13:
-       case 14:
-       case 15:
-               v = 1;
-               break;
-       case 16:
-               v = 1;
-               break;
-       case 17:
-       case 18:
-       case 19:
-       case 20:
-       case 21:
-       case 22:
-       case 23:
-       case 24:
-               v = 0;
-               break;
-       default:
-               v = 0;
-               break;
-       }
-
-       /* PL180 voltage register bits */
-       return v << 2;
-}
-
-
-
 static int mmci_callback(void *data)
 {
        struct mmci_card_event *mmci_card = data;
@@ -146,18 +90,23 @@ int __devinit mmc_init(struct amba_device *adev)
 {
        struct mmci_card_event *mmci_card;
        struct device *mmcsd_device = &adev->dev;
+       struct pmx *pmx;
        int ret = 0;
 
        mmci_card = kzalloc(sizeof(struct mmci_card_event), GFP_KERNEL);
        if (!mmci_card)
                return -ENOMEM;
 
+       /*
+        * Do not set ocr_mask or voltage translation function,
+        * we have a regulator we can control instead.
+        */
        /* Nominally 2.85V on our platform */
-       mmci_card->mmc0_plat_data.ocr_mask = MMC_VDD_28_29;
-       mmci_card->mmc0_plat_data.translate_vdd = mmc_translate_vdd;
        mmci_card->mmc0_plat_data.status = mmc_status;
        mmci_card->mmc0_plat_data.gpio_wp = -1;
        mmci_card->mmc0_plat_data.gpio_cd = -1;
+       mmci_card->mmc0_plat_data.capabilities = MMC_CAP_MMC_HIGHSPEED |
+               MMC_CAP_SD_HIGHSPEED | MMC_CAP_4_BIT_DATA;
 
        mmcsd_device->platform_data = (void *) &mmci_card->mmc0_plat_data;
 
@@ -207,6 +156,20 @@ int __devinit mmc_init(struct amba_device *adev)
 
        input_set_drvdata(mmci_card->mmc_input, mmci_card);
 
+       /*
+        * Setup padmuxing for MMC. Since this must always be
+        * compiled into the kernel, pmx is never released.
+        */
+       pmx = pmx_get(mmcsd_device, U300_APP_PMX_MMC_SETTING);
+
+       if (IS_ERR(pmx))
+               pr_warning("Could not get padmux handle\n");
+       else {
+               ret = pmx_activate(mmcsd_device, pmx);
+               if (IS_ERR_VALUE(ret))
+                       pr_warning("Could not activate padmuxing\n");
+       }
+
        ret = gpio_register_callback(U300_GPIO_PIN_MMC_CD, mmci_callback,
                                     mmci_card);