Revert "MMC: Merge two patches from UMG 2.6.35"
authorChuanxiao Dong <chuanxiao.dong@intel.com>
Wed, 19 Oct 2011 09:47:35 +0000 (17:47 +0800)
committermgross <mark.gross@intel.com>
Wed, 9 Nov 2011 21:15:45 +0000 (13:15 -0800)
This reverts commit c435aacac11c4c54e45ad25a8dea6d81d7f5e835.

Change-Id: Icc5525c3d432868c2e36e2d0cc639c7919f8b953

drivers/mmc/host/sdhci-pci.c
drivers/mmc/host/sdhci.c
include/linux/mmc/sdhci.h

index e5d2b87..29e6b7c 100644 (file)
@@ -21,7 +21,6 @@
 #include <linux/mmc/host.h>
 #include <linux/scatterlist.h>
 #include <linux/io.h>
-#include <asm/intel_scu_ipc.h>
 #include <linux/pm_runtime.h>
 
 #include "sdhci.h"
@@ -40,8 +39,6 @@
 
 #define MAX_SLOTS                      8
 
-#define IPC_EMMC_MUTEX_CMD             0xEE
-
 struct sdhci_pci_chip;
 struct sdhci_pci_slot;
 
@@ -169,62 +166,10 @@ static int mrst_hc_probe(struct sdhci_pci_chip *chip)
 
 static int mfd_emmc_probe_slot(struct sdhci_pci_slot *slot)
 {
-       int ret;
-       u32 mutex_var_addr[3];
-       struct pci_dev *pdev;
-
        slot->host->mmc->caps |= MMC_CAP_8_BIT_DATA;
-       /*
-        * for some card, it is should be none removable, e.g.eMMC card
-        * So if we are a eMMC slot, the mmc host capability can be set
-        * by MMC_CAP_NONREMOVABLE
-        */
-       slot->host->mmc->caps |= MMC_CAP_NONREMOVABLE;
-
-       pdev = slot->chip->pdev;
-       if (pdev->device != PCI_DEVICE_ID_INTEL_MFD_EMMC0)
-               return 0;
-
-       ret = intel_scu_ipc_command(IPC_EMMC_MUTEX_CMD, 0,
-                       NULL, 0, mutex_var_addr, 3);
-       if (ret) {
-               dev_err(&slot->chip->pdev->dev, "IPC error: %d\n", ret);
-               slot->host->sram_addr = 0;
-       } else {
-               /* 3 housekeeping mutex variables, 12 bytes length */
-               slot->host->sram_addr = ioremap_nocache(mutex_var_addr[0], 16);
-               if (!slot->host->sram_addr) {
-                       dev_err(&slot->chip->pdev->dev, "ioremap failed!\n");
-               } else {
-                       dev_info(&slot->chip->pdev->dev, "mapped addr: %p\n",
-                               slot->host->sram_addr);
-                       dev_info(&slot->chip->pdev->dev, "current eMMC owner:"
-                               " %d, IA req: %d, SCU req: %d\n",
-                               readl(slot->host->sram_addr +
-                                       DEKKER_EMMC_OWNER_OFFSET),
-                               readl(slot->host->sram_addr +
-                                       DEKKER_IA_REQ_OFFSET),
-                               readl(slot->host->sram_addr +
-                                       DEKKER_SCU_REQ_OFFSET));
-               }
-       }
-
        return 0;
 }
 
-static void mfd_emmc_remove_slot(struct sdhci_pci_slot *slot, int dead)
-{
-       struct pci_dev *pdev;
-       if (dead)
-               return;
-
-       pdev = slot->chip->pdev;
-       if (pdev->device == PCI_DEVICE_ID_INTEL_MFD_EMMC0) {
-               if (slot->host->sram_addr)
-                       iounmap(slot->host->sram_addr);
-       }
-}
-
 static const struct sdhci_pci_fixes sdhci_intel_mrst_hc0 = {
        .quirks         = SDHCI_QUIRK_BROKEN_ADMA | SDHCI_QUIRK_NO_HISPD_BIT,
        .probe_slot     = mrst_hc_probe_slot,
@@ -246,7 +191,6 @@ static const struct sdhci_pci_fixes sdhci_intel_mfd_sdio = {
 static const struct sdhci_pci_fixes sdhci_intel_mfd_emmc = {
        .quirks         = SDHCI_QUIRK_NO_ENDATTR_IN_NOPDESC,
        .probe_slot     = mfd_emmc_probe_slot,
-       .remove_slot    = mfd_emmc_remove_slot,
 };
 
 /* O2Micro extra registers */
index 4a4de9e..b0dd6d7 100644 (file)
@@ -197,7 +197,7 @@ static void sdhci_reset(struct sdhci_host *host, u8 mask)
                sdhci_clear_set_irqs(host, SDHCI_INT_ALL_MASK, ier);
 }
 
-static void __sdhci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios);
+static void sdhci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios);
 
 static void sdhci_init(struct sdhci_host *host, int soft)
 {
@@ -215,7 +215,7 @@ static void sdhci_init(struct sdhci_host *host, int soft)
        if (soft) {
                /* force clock reconfiguration */
                host->clock = 0;
-               __sdhci_set_ios(host->mmc, &host->mmc->ios);
+               sdhci_set_ios(host->mmc, &host->mmc->ios);
        }
 }
 
@@ -1029,6 +1029,7 @@ static void sdhci_finish_command(struct sdhci_host *host)
                host->cmd = NULL;
                sdhci_send_command(host, host->mrq->cmd);
        } else {
+
                /* Processed actual command. */
                if (host->data && host->data_early)
                        sdhci_finish_data(host);
@@ -1201,201 +1202,6 @@ static void sdhci_set_power(struct sdhci_host *host, unsigned short power)
  *                                                                           *
 \*****************************************************************************/
 
-/*
- * One of the Medfield eMMC controller (PCI device id 0x0823, SDIO3) is
- * a shared resource used by the SCU and the IA processors. SCU primarily
- * uses the eMMC host controller to access the eMMC device's Boot Partition,
- * while the IA CPU uses the eMMC host controller to access the eMMC device's
- * User Partition.
- *
- * After the SCU hands off the system to the IA processor, the IA processor
- * assumes ownership to the eMMC host controller. Due to absence of any
- * arbitration at the eMMC host controller, this could result in concurrent
- * eMMC host accesses resulting in bus contention and garbage data ending up
- * in either of the partitions.
- * To circumvent this from happening, eMMC host controller locking mechanism
- * is employed, where at any one given time, only one agent, SCU or IA, may be
- * allowed to access the host. This is achieved by implementing Dekker's
- * Algorithm (http://en.wikipedia.org/wiki/Dekker's_algorithm) between the
- * two processors.
- *
- * Before handing off the system to the IA processor, SCU must set up three
- * housekeeping mutex variables allocated in the shared SRAM as follows:
- *
- * eMMC_Owner = IA (SCU and IA processors - RW, 32bit)
- * IA_Req = FALSE (IA -RW, SCU - RO, 32bit)
- * SCU_Req = FALSE (IA - RO, SCU - R/W, 32bit)
- *
- * There is no hardware based access control to these variables and so code
- * executing on SCU and IA processors must follow below access rules
- * (Dekker's algorithm):
- *
- * -----------------------------------------
- * SCU Processor Implementation
- * -----------------------------------------
- * SCU_Req = TRUE;
- * while (IA_Req == TRUE) {
- *     if (eMMC_Owner != SCU){
- *         SCU_Req = FALSE;
- *         while (eMMC_Owner != SCU);
- *         SCU_Req = TRUE;
- *     }
- * }
- * // SCU now performs eMMC transactions here
- * ...
- * // When done, relinquish control to IA
- * eMMC_Owner = IA;
- * SCU_Req = FALSE;
- *
- * -----------------------------------------
- * IA Processor Implementation
- * -----------------------------------------
- * IA_Req = TRUE;
- * while (SCU_Req == TRUE) {
- *     if (eMMC_Owner != IA){
- *         IA_Req = FALSE;
- *         while (eMMC_Owner != IA);
- *         IA_Req = TRUE;
- *     }
- * }
- * //IA now performs eMMC transactions here
- * ...
- * //When done, relinquish control to SCU
- * eMMC_Owner = SCU;
- * IA_Req = FALSE;
- *
- * ----------------------------------------
-*/
-/**
- * __sdhci_acquire_ownership- implement the Dekker's algorithm on IA side
- * This function is only used for acquire ownership, not to re-cofnig host
- * controller. Since in some scenarios, re-config is not useless. We can
- * save some unused expenses.
- * @mmc: mmc host
- *
- * @return return value:
- * 0 - Acquried the ownership successfully. The last owner is IA
- * 1 - Acquried the ownership succesffully. The last owenr is SCU
- * -EBUSY - failed to acquire ownership within the timeout period
- */
-static int __sdhci_acquire_ownership(struct mmc_host *mmc)
-{
-       struct sdhci_host *host;
-       unsigned long t1, t2;
-
-       host = mmc_priv(mmc);
-
-       if (!host->sram_addr)
-               return 0;
-
-       atomic_inc(&host->usage_cnt);
-
-       /* If IA has already hold the eMMC mutex, then just exit */
-       if (readl(host->sram_addr + DEKKER_IA_REQ_OFFSET))
-               return 0;
-
-       DBG("Acquire ownership - eMMC owner: %d, IA req: %d, SCU req: %d\n",
-               readl(host->sram_addr + DEKKER_EMMC_OWNER_OFFSET),
-               readl(host->sram_addr + DEKKER_IA_REQ_OFFSET),
-               readl(host->sram_addr + DEKKER_SCU_REQ_OFFSET));
-
-       writel(1, host->sram_addr + DEKKER_IA_REQ_OFFSET);
-
-       t1 = jiffies + 10 * HZ;
-       t2 = 500;
-
-       while (readl(host->sram_addr + DEKKER_SCU_REQ_OFFSET)) {
-               if (readl(host->sram_addr + DEKKER_EMMC_OWNER_OFFSET) !=
-                               DEKKER_OWNER_IA) {
-                       writel(0, host->sram_addr + DEKKER_IA_REQ_OFFSET);
-                       while (t2) {
-                               if (readl(host->sram_addr +
-                                       DEKKER_EMMC_OWNER_OFFSET) ==
-                                       DEKKER_OWNER_IA)
-                                       break;
-                               msleep(10);
-                               t2--;
-                       }
-                       if (t2)
-                               writel(1, host->sram_addr +
-                                               DEKKER_IA_REQ_OFFSET);
-                       else
-                               goto timeout;
-               }
-               if (time_after(jiffies, t1))
-                       goto timeout;
-
-               cpu_relax();
-       }
-
-       /*
-        * if the last owner is SCU, will do the re-config host controller
-        * in the next
-        */
-       return (readl(host->sram_addr + DEKKER_EMMC_OWNER_OFFSET) ==
-               DEKKER_OWNER_IA) ? 1 : 0;
-
-timeout:
-       printk(KERN_ERR "eMMC mutex timeout!\n"
-               "Dump Dekker's house keeping variables -"
-               "eMMC owner: %d, IA req: %d, SCU req: %d\n",
-               readl(host->sram_addr + DEKKER_EMMC_OWNER_OFFSET),
-               readl(host->sram_addr + DEKKER_IA_REQ_OFFSET),
-               readl(host->sram_addr + DEKKER_SCU_REQ_OFFSET));
-
-       /* Release eMMC mutex anyway */
-       writel(DEKKER_OWNER_SCU, host->sram_addr + DEKKER_EMMC_OWNER_OFFSET);
-       writel(0, host->sram_addr + DEKKER_IA_REQ_OFFSET);
-
-       return -EBUSY;
-}
-
-static int sdhci_acquire_ownership(struct mmc_host *mmc)
-{
-       int ret;
-
-       ret = __sdhci_acquire_ownership(mmc);
-       if (ret) {
-               struct sdhci_host *host;
-               host = mmc_priv(mmc);
-               /* Re-config HC in case SCU has changed HC reg already */
-               pm_runtime_get_sync(mmc->parent);
-               /*
-                * reinit host registers.
-                * include reset host controller all,
-                * reconfigure clock, pwr and other registers.
-                */
-               sdhci_init(host, 0);
-               host->clock = 0;
-               host->pwr = 0;
-               __sdhci_set_ios(host->mmc, &host->mmc->ios);
-               pm_runtime_put(mmc->parent);
-       }
-
-       return ret;
-}
-
-static void sdhci_release_ownership(struct mmc_host *mmc)
-{
-       struct sdhci_host *host;
-
-       host = mmc_priv(mmc);
-
-       if (!host->sram_addr)
-               return;
-
-       if (atomic_dec_and_test(&host->usage_cnt)) {
-               writel(DEKKER_OWNER_SCU,
-                      host->sram_addr + DEKKER_EMMC_OWNER_OFFSET);
-               writel(0, host->sram_addr + DEKKER_IA_REQ_OFFSET);
-               DBG("Exit ownership - "
-                   "eMMC owner: %d, IA req: %d, SCU req: %d\n",
-                   readl(host->sram_addr + DEKKER_EMMC_OWNER_OFFSET),
-                   readl(host->sram_addr + DEKKER_IA_REQ_OFFSET),
-                   readl(host->sram_addr + DEKKER_SCU_REQ_OFFSET));
-       }
-}
-
 static void sdhci_request(struct mmc_host *mmc, struct mmc_request *mrq)
 {
        struct sdhci_host *host;
@@ -1464,7 +1270,7 @@ static void sdhci_request(struct mmc_host *mmc, struct mmc_request *mrq)
        spin_unlock_irqrestore(&host->lock, flags);
 }
 
-static void __sdhci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
+static void sdhci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
 {
        struct sdhci_host *host;
        unsigned long flags;
@@ -1638,19 +1444,6 @@ out:
        spin_unlock_irqrestore(&host->lock, flags);
 }
 
-static void sdhci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
-{
-       sdhci_acquire_ownership(mmc);
-
-       pm_runtime_get_sync(mmc->parent);
-
-       __sdhci_set_ios(mmc, ios);
-
-       pm_runtime_put(mmc->parent);
-
-       sdhci_release_ownership(mmc);
-}
-
 static int check_ro(struct sdhci_host *host)
 {
        unsigned long flags;
@@ -2079,10 +1872,10 @@ static void sdhci_tasklet_finish(unsigned long param)
 
        host = (struct sdhci_host*)param;
 
-       /*
-        * If this tasklet gets rescheduled while running, it will
-        * be run again afterwards but without any active request.
-        */
+        /*
+         * If this tasklet gets rescheduled while running, it will
+         * be run again afterwards but without any active request.
+         */
        if (!host->mrq)
                return;
 
@@ -2130,8 +1923,6 @@ static void sdhci_tasklet_finish(unsigned long param)
        spin_unlock_irqrestore(&host->lock, flags);
 
        mmc_request_done(host->mmc, mrq);
-
-       sdhci_release_ownership(host->mmc);
 }
 
 static void sdhci_timeout_timer(unsigned long data)
@@ -2468,8 +2259,6 @@ int sdhci_suspend_host(struct sdhci_host *host, pm_message_t state)
 {
        int ret;
 
-       sdhci_acquire_ownership(host->mmc);
-
        sdhci_disable_card_detection(host);
 
        /* Disable tuning since we are suspending */
@@ -2482,14 +2271,13 @@ int sdhci_suspend_host(struct sdhci_host *host, pm_message_t state)
 
        ret = mmc_suspend_host(host->mmc);
        if (ret)
-               goto out;
+               return ret;
 
        free_irq(host->irq, host);
 
        if (host->vmmc)
                ret = regulator_disable(host->vmmc);
-out:
-       sdhci_release_ownership(host->mmc);
+
        return ret;
 }
 
@@ -2499,16 +2287,10 @@ int sdhci_resume_host(struct sdhci_host *host)
 {
        int ret;
 
-       /*
-        * needn't to reconfigure host registers
-        * since in the next, host will be re-configured
-        */
-       __sdhci_acquire_ownership(host->mmc);
-
        if (host->vmmc) {
-               ret = regulator_enable(host->vmmc);
+               int ret = regulator_enable(host->vmmc);
                if (ret)
-                       goto out;
+                       return ret;
        }
 
 
@@ -2520,7 +2302,7 @@ int sdhci_resume_host(struct sdhci_host *host)
        ret = request_irq(host->irq, sdhci_irq, IRQF_SHARED,
                          mmc_hostname(host->mmc), host);
        if (ret)
-               goto out;
+               return ret;
 
        sdhci_init(host, (host->mmc->pm_flags & MMC_PM_KEEP_POWER));
        mmiowb();
@@ -2532,8 +2314,7 @@ int sdhci_resume_host(struct sdhci_host *host)
        if ((host->version >= SDHCI_SPEC_300) && host->tuning_count &&
            (host->tuning_mode == SDHCI_TUNING_MODE_1))
                host->flags |= SDHCI_NEEDS_RETUNING;
-out:
-       sdhci_release_ownership(host->mmc);
+
        return ret;
 }
 
@@ -2571,20 +2352,6 @@ int sdhci_runtime_resume_host(struct sdhci_host *host)
                if ((ret = regulator_enable(host->vmmc)))
                        return ret;
 
-       __sdhci_acquire_ownership(host->mmc);
-
-       if (host->flags & (SDHCI_USE_SDMA | SDHCI_USE_ADMA)) {
-               if (host->ops->enable_dma)
-                       host->ops->enable_dma(host);
-       }
-
-       sdhci_init(host, (host->mmc->pm_flags & MMC_PM_KEEP_POWER));
-       host->pwr = 0; /* force power reprogram */
-       host->clock = 0; /* force clock reprogram */
-       mmiowb();
-
-       sdhci_release_ownership(host->mmc);
-
        return ret;
 }
 EXPORT_SYMBOL_GPL(sdhci_runtime_resume_host);
@@ -3026,8 +2793,6 @@ int sdhci_add_host(struct sdhci_host *host)
                regulator_enable(host->vmmc);
        }
 
-       __sdhci_acquire_ownership(mmc);
-
        sdhci_init(host, 0);
        host->iosclock = 1; /* default clk_gate is 0 */
        pm_runtime_get_noresume(host->mmc->parent);
@@ -3060,14 +2825,11 @@ int sdhci_add_host(struct sdhci_host *host)
 
        sdhci_enable_card_detection(host);
 
-       sdhci_release_ownership(mmc);
-
        return 0;
 
 #ifdef SDHCI_USE_LEDS_CLASS
 reset:
        sdhci_reset(host, SDHCI_RESET_ALL);
-       sdhci_release_ownership(mmc);
        free_irq(host->irq, host);
 #endif
 untasklet:
index fbbd3b4..47d44e4 100644 (file)
@@ -91,17 +91,6 @@ struct sdhci_host {
        int irq;                /* Device IRQ */
        void __iomem *ioaddr;   /* Mapped address */
 
-       /* XXX: SCU/X86 mutex variables base address in shared SRAM */
-       void __iomem *sram_addr;        /* Shared SRAM address */
-
-       #define DEKKER_EMMC_OWNER_OFFSET        0
-       #define DEKKER_IA_REQ_OFFSET            0x04
-       #define DEKKER_SCU_REQ_OFFSET           0x08
-       #define DEKKER_OWNER_IA                 0
-       #define DEKKER_OWNER_SCU                1
-
-       atomic_t usage_cnt; /* eMMC mutex usage count */
-
        const struct sdhci_ops *ops;    /* Low level hw interface */
 
        struct regulator *vmmc; /* Power regulator */