Merge tag 'soc-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/arm/arm-soc
[cascardo/linux.git] / drivers / mmc / host / omap_hsmmc.c
index 8a216c9..7c71dcd 100644 (file)
@@ -207,7 +207,6 @@ struct omap_hsmmc_host {
        int                     use_dma, dma_ch;
        struct dma_chan         *tx_chan;
        struct dma_chan         *rx_chan;
-       int                     slot_id;
        int                     response_busy;
        int                     context_loss;
        int                     protect_card;
@@ -221,6 +220,25 @@ struct omap_hsmmc_host {
 #define HSMMC_WAKE_IRQ_ENABLED (1 << 2)
        struct omap_hsmmc_next  next_data;
        struct  omap_hsmmc_platform_data        *pdata;
+
+       /* To handle board related suspend/resume functionality for MMC */
+       int (*suspend)(struct device *dev);
+       int (*resume)(struct device *dev);
+
+       /* return MMC cover switch state, can be NULL if not supported.
+        *
+        * possible return values:
+        *   0 - closed
+        *   1 - open
+        */
+       int (*get_cover_state)(struct device *dev);
+
+       /* Card detection IRQs */
+       int card_detect_irq;
+
+       int (*card_detect)(struct device *dev);
+       int (*get_ro)(struct device *dev);
+
 };
 
 struct omap_mmc_of_data {
@@ -230,7 +248,7 @@ struct omap_mmc_of_data {
 
 static void omap_hsmmc_start_dma_transfer(struct omap_hsmmc_host *host);
 
-static int omap_hsmmc_card_detect(struct device *dev, int slot)
+static int omap_hsmmc_card_detect(struct device *dev)
 {
        struct omap_hsmmc_host *host = dev_get_drvdata(dev);
        struct omap_hsmmc_platform_data *mmc = host->pdata;
@@ -239,7 +257,7 @@ static int omap_hsmmc_card_detect(struct device *dev, int slot)
        return !gpio_get_value_cansleep(mmc->switch_pin);
 }
 
-static int omap_hsmmc_get_wp(struct device *dev, int slot)
+static int omap_hsmmc_get_wp(struct device *dev)
 {
        struct omap_hsmmc_host *host = dev_get_drvdata(dev);
        struct omap_hsmmc_platform_data *mmc = host->pdata;
@@ -248,7 +266,7 @@ static int omap_hsmmc_get_wp(struct device *dev, int slot)
        return gpio_get_value_cansleep(mmc->gpio_wp);
 }
 
-static int omap_hsmmc_get_cover_state(struct device *dev, int slot)
+static int omap_hsmmc_get_cover_state(struct device *dev)
 {
        struct omap_hsmmc_host *host = dev_get_drvdata(dev);
        struct omap_hsmmc_platform_data *mmc = host->pdata;
@@ -259,21 +277,19 @@ static int omap_hsmmc_get_cover_state(struct device *dev, int slot)
 
 #ifdef CONFIG_PM
 
-static int omap_hsmmc_suspend_cdirq(struct device *dev, int slot)
+static int omap_hsmmc_suspend_cdirq(struct device *dev)
 {
        struct omap_hsmmc_host *host = dev_get_drvdata(dev);
-       struct omap_hsmmc_platform_data *mmc = host->pdata;
 
-       disable_irq(mmc->card_detect_irq);
+       disable_irq(host->card_detect_irq);
        return 0;
 }
 
-static int omap_hsmmc_resume_cdirq(struct device *dev, int slot)
+static int omap_hsmmc_resume_cdirq(struct device *dev)
 {
        struct omap_hsmmc_host *host = dev_get_drvdata(dev);
-       struct omap_hsmmc_platform_data *mmc = host->pdata;
 
-       enable_irq(mmc->card_detect_irq);
+       enable_irq(host->card_detect_irq);
        return 0;
 }
 
@@ -286,8 +302,7 @@ static int omap_hsmmc_resume_cdirq(struct device *dev, int slot)
 
 #ifdef CONFIG_REGULATOR
 
-static int omap_hsmmc_set_power(struct device *dev, int slot, int power_on,
-                                  int vdd)
+static int omap_hsmmc_set_power(struct device *dev, int power_on, int vdd)
 {
        struct omap_hsmmc_host *host =
                platform_get_drvdata(to_platform_device(dev));
@@ -301,7 +316,7 @@ static int omap_hsmmc_set_power(struct device *dev, int slot, int power_on,
                return 0;
 
        if (mmc_pdata(host)->before_set_reg)
-               mmc_pdata(host)->before_set_reg(dev, slot, power_on, vdd);
+               mmc_pdata(host)->before_set_reg(dev, power_on, vdd);
 
        if (host->pbias) {
                if (host->pbias_enabled == 1) {
@@ -364,7 +379,7 @@ static int omap_hsmmc_set_power(struct device *dev, int slot, int power_on,
        }
 
        if (mmc_pdata(host)->after_set_reg)
-               mmc_pdata(host)->after_set_reg(dev, slot, power_on, vdd);
+               mmc_pdata(host)->after_set_reg(dev, power_on, vdd);
 
 error_set_power:
        return ret;
@@ -414,8 +429,8 @@ static int omap_hsmmc_reg_get(struct omap_hsmmc_host *host)
            (host->vcc_aux && regulator_is_enabled(host->vcc_aux))) {
                int vdd = ffs(mmc_pdata(host)->ocr_mask) - 1;
 
-               mmc_pdata(host)->set_power(host->dev, host->slot_id, 1, vdd);
-               mmc_pdata(host)->set_power(host->dev, host->slot_id, 0, 0);
+               mmc_pdata(host)->set_power(host->dev, 1, vdd);
+               mmc_pdata(host)->set_power(host->dev, 0, 0);
        }
 
        return 0;
@@ -456,11 +471,11 @@ static int omap_hsmmc_gpio_init(struct omap_hsmmc_host *host,
 
        if (gpio_is_valid(pdata->switch_pin)) {
                if (pdata->cover)
-                       pdata->get_cover_state =
-                                       omap_hsmmc_get_cover_state;
+                       host->get_cover_state =
+                               omap_hsmmc_get_cover_state;
                else
-                       pdata->card_detect = omap_hsmmc_card_detect;
-               pdata->card_detect_irq =
+                       host->card_detect = omap_hsmmc_card_detect;
+               host->card_detect_irq =
                                gpio_to_irq(pdata->switch_pin);
                ret = gpio_request(pdata->switch_pin, "mmc_cd");
                if (ret)
@@ -473,7 +488,7 @@ static int omap_hsmmc_gpio_init(struct omap_hsmmc_host *host,
        }
 
        if (gpio_is_valid(pdata->gpio_wp)) {
-               pdata->get_ro = omap_hsmmc_get_wp;
+               host->get_ro = omap_hsmmc_get_wp;
                ret = gpio_request(pdata->gpio_wp, "mmc_wp");
                if (ret)
                        goto err_free_cd;
@@ -613,6 +628,7 @@ static void omap_hsmmc_set_clock(struct omap_hsmmc_host *host)
         */
        if ((mmc_pdata(host)->features & HSMMC_HAS_HSPE_SUPPORT) &&
            (ios->timing != MMC_TIMING_MMC_DDR52) &&
+           (ios->timing != MMC_TIMING_UHS_DDR50) &&
            ((OMAP_HSMMC_READ(host->base, CAPA) & HSS) == HSS)) {
                regval = OMAP_HSMMC_READ(host->base, HCTL);
                if (clkdiv && (clk_get_rate(host->fclk)/clkdiv) > 25000000)
@@ -632,7 +648,8 @@ static void omap_hsmmc_set_bus_width(struct omap_hsmmc_host *host)
        u32 con;
 
        con = OMAP_HSMMC_READ(host->base, CON);
-       if (ios->timing == MMC_TIMING_MMC_DDR52)
+       if (ios->timing == MMC_TIMING_MMC_DDR52 ||
+           ios->timing == MMC_TIMING_UHS_DDR50)
                con |= DDR;     /* configure in DDR mode */
        else
                con &= ~DDR;
@@ -795,8 +812,8 @@ int omap_hsmmc_cover_is_closed(struct omap_hsmmc_host *host)
 {
        int r = 1;
 
-       if (mmc_pdata(host)->get_cover_state)
-               r = mmc_pdata(host)->get_cover_state(host->dev, host->slot_id);
+       if (host->get_cover_state)
+               r = host->get_cover_state(host->dev);
        return r;
 }
 
@@ -1214,12 +1231,11 @@ static int omap_hsmmc_switch_opcond(struct omap_hsmmc_host *host, int vdd)
                clk_disable_unprepare(host->dbclk);
 
        /* Turn the power off */
-       ret = mmc_pdata(host)->set_power(host->dev, host->slot_id, 0, 0);
+       ret = mmc_pdata(host)->set_power(host->dev, 0, 0);
 
        /* Turn the power ON with given VDD 1.8 or 3.0v */
        if (!ret)
-               ret = mmc_pdata(host)->set_power(host->dev, host->slot_id, 1,
-                                                vdd);
+               ret = mmc_pdata(host)->set_power(host->dev, 1, vdd);
        pm_runtime_get_sync(host->dev);
        if (host->dbclk)
                clk_prepare_enable(host->dbclk);
@@ -1263,11 +1279,11 @@ err:
 /* Protect the card while the cover is open */
 static void omap_hsmmc_protect_card(struct omap_hsmmc_host *host)
 {
-       if (!mmc_pdata(host)->get_cover_state)
+       if (!host->get_cover_state)
                return;
 
        host->reqs_blocked = 0;
-       if (mmc_pdata(host)->get_cover_state(host->dev, host->slot_id)) {
+       if (host->get_cover_state(host->dev)) {
                if (host->protect_card) {
                        dev_info(host->dev, "%s: cover is closed, "
                                         "card is now accessible\n",
@@ -1290,13 +1306,12 @@ static void omap_hsmmc_protect_card(struct omap_hsmmc_host *host)
 static irqreturn_t omap_hsmmc_detect(int irq, void *dev_id)
 {
        struct omap_hsmmc_host *host = dev_id;
-       struct omap_hsmmc_platform_data *pdata = host->pdata;
        int carddetect;
 
        sysfs_notify(&host->mmc->class_dev.kobj, NULL, "cover_switch");
 
-       if (pdata->card_detect)
-               carddetect = pdata->card_detect(host->dev, host->slot_id);
+       if (host->card_detect)
+               carddetect = host->card_detect(host->dev);
        else {
                omap_hsmmc_protect_card(host);
                carddetect = -ENOSYS;
@@ -1622,12 +1637,10 @@ static void omap_hsmmc_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
        if (ios->power_mode != host->power_mode) {
                switch (ios->power_mode) {
                case MMC_POWER_OFF:
-                       mmc_pdata(host)->set_power(host->dev, host->slot_id,
-                                                  0, 0);
+                       mmc_pdata(host)->set_power(host->dev, 0, 0);
                        break;
                case MMC_POWER_UP:
-                       mmc_pdata(host)->set_power(host->dev, host->slot_id,
-                                                  1, ios->vdd);
+                       mmc_pdata(host)->set_power(host->dev, 1, ios->vdd);
                        break;
                case MMC_POWER_ON:
                        do_send_init_stream = 1;
@@ -1672,18 +1685,18 @@ static int omap_hsmmc_get_cd(struct mmc_host *mmc)
 {
        struct omap_hsmmc_host *host = mmc_priv(mmc);
 
-       if (!mmc_pdata(host)->card_detect)
+       if (!host->card_detect)
                return -ENOSYS;
-       return mmc_pdata(host)->card_detect(host->dev, host->slot_id);
+       return host->card_detect(host->dev);
 }
 
 static int omap_hsmmc_get_ro(struct mmc_host *mmc)
 {
        struct omap_hsmmc_host *host = mmc_priv(mmc);
 
-       if (!mmc_pdata(host)->get_ro)
+       if (!host->get_ro)
                return -ENOSYS;
-       return mmc_pdata(host)->get_ro(host->dev, 0);
+       return host->get_ro(host->dev);
 }
 
 static void omap_hsmmc_init_card(struct mmc_host *mmc, struct mmc_card *card)
@@ -1980,8 +1993,6 @@ static struct omap_hsmmc_platform_data *of_get_hsmmc_pdata(struct device *dev)
        if (of_find_property(np, "ti,dual-volt", NULL))
                pdata->controller_flags |= OMAP_HSMMC_SUPPORTS_DUAL_VOLT;
 
-       /* This driver only supports 1 slot */
-       pdata->nr_slots = 1;
        pdata->switch_pin = cd_gpio;
        pdata->gpio_wp = wp_gpio;
 
@@ -2052,11 +2063,6 @@ static int omap_hsmmc_probe(struct platform_device *pdev)
                return -ENXIO;
        }
 
-       if (pdata->nr_slots == 0) {
-               dev_err(&pdev->dev, "No Slots\n");
-               return -ENXIO;
-       }
-
        res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
        irq = platform_get_irq(pdev, 0);
        if (res == NULL || irq < 0)
@@ -2079,7 +2085,6 @@ static int omap_hsmmc_probe(struct platform_device *pdev)
        host->use_dma   = 1;
        host->dma_ch    = -1;
        host->irq       = irq;
-       host->slot_id   = 0;
        host->mapbase   = res->start + pdata->reg_offset;
        host->base      = base + pdata->reg_offset;
        host->power_mode = MMC_POWER_OFF;
@@ -2218,9 +2223,9 @@ static int omap_hsmmc_probe(struct platform_device *pdev)
        mmc->ocr_avail = mmc_pdata(host)->ocr_mask;
 
        /* Request IRQ for card detect */
-       if ((mmc_pdata(host)->card_detect_irq)) {
+       if (host->card_detect_irq) {
                ret = devm_request_threaded_irq(&pdev->dev,
-                                               mmc_pdata(host)->card_detect_irq,
+                                               host->card_detect_irq,
                                                NULL, omap_hsmmc_detect,
                                           IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING | IRQF_ONESHOT,
                                           mmc_hostname(mmc), host);
@@ -2229,8 +2234,8 @@ static int omap_hsmmc_probe(struct platform_device *pdev)
                                "Unable to grab MMC CD IRQ\n");
                        goto err_irq_cd;
                }
-               pdata->suspend = omap_hsmmc_suspend_cdirq;
-               pdata->resume = omap_hsmmc_resume_cdirq;
+               host->suspend = omap_hsmmc_suspend_cdirq;
+               host->resume = omap_hsmmc_resume_cdirq;
        }
 
        omap_hsmmc_disable_irq(host);
@@ -2256,8 +2261,7 @@ static int omap_hsmmc_probe(struct platform_device *pdev)
                if (ret < 0)
                        goto err_slot_name;
        }
-       if (mmc_pdata(host)->card_detect_irq &&
-           mmc_pdata(host)->get_cover_state) {
+       if (host->card_detect_irq && host->get_cover_state) {
                ret = device_create_file(&mmc->class_dev,
                                        &dev_attr_cover_switch);
                if (ret < 0)
@@ -2322,8 +2326,8 @@ static int omap_hsmmc_prepare(struct device *dev)
 {
        struct omap_hsmmc_host *host = dev_get_drvdata(dev);
 
-       if (host->pdata->suspend)
-               return host->pdata->suspend(dev, host->slot_id);
+       if (host->suspend)
+               return host->suspend(dev);
 
        return 0;
 }
@@ -2332,8 +2336,8 @@ static void omap_hsmmc_complete(struct device *dev)
 {
        struct omap_hsmmc_host *host = dev_get_drvdata(dev);
 
-       if (host->pdata->resume)
-               host->pdata->resume(dev, host->slot_id);
+       if (host->resume)
+               host->resume(dev);
 
 }