]> git.ipfire.org Git - people/ms/u-boot.git/blobdiff - drivers/mmc/mxsmmc.c
mmc: Remove ops from struct mmc and put in mmc_ops
[people/ms/u-boot.git] / drivers / mmc / mxsmmc.c
index a72f66cc7aa301aa51a0686c4ecc1699bf91042f..97c9ee8fb6e4669bbc7494ecbaca7bd5dd08f4cc 100644 (file)
  * (C) Copyright 2003
  * Kyle Harris, Nexus Technologies, Inc. kharris@nexus-tech.net
  *
- * See file CREDITS for list of people who contributed to this
- * project.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
- * MA 02111-1307 USA
+ * SPDX-License-Identifier:    GPL-2.0+
  */
 #include <common.h>
 #include <malloc.h>
@@ -41,7 +25,7 @@
 #include <asm/arch/clock.h>
 #include <asm/arch/imx-regs.h>
 #include <asm/arch/sys_proto.h>
-#include <asm/arch/dma.h>
+#include <asm/imx-common/dma.h>
 #include <bouncebuf.h>
 
 struct mxsmmc_priv {
@@ -53,12 +37,6 @@ struct mxsmmc_priv {
        struct mxs_dma_desc     *desc;
 };
 
-#if defined(CONFIG_MX23)
-static const unsigned int mxsmmc_id_offset = 1;
-#elif defined(CONFIG_MX28)
-static const unsigned int mxsmmc_id_offset = 0;
-#endif
-
 #define        MXSMMC_MAX_TIMEOUT      10000
 #define MXSMMC_SMALL_TRANSFER  512
 
@@ -137,7 +115,7 @@ static int mxsmmc_send_cmd_dma(struct mxsmmc_priv *priv, struct mmc_data *data)
        priv->desc->cmd.data |= MXS_DMA_DESC_IRQ | MXS_DMA_DESC_DEC_SEM |
                                (data_count << MXS_DMA_DESC_BYTES_OFFSET);
 
-       dmach = MXS_DMA_CHANNEL_AHB_APBH_SSP0 + priv->id + mxsmmc_id_offset;
+       dmach = MXS_DMA_CHANNEL_AHB_APBH_SSP0 + priv->id;
        mxs_dma_desc_append(dmach, priv->desc);
        if (mxs_dma_go(dmach)) {
                bounce_buffer_stop(&bbstate);
@@ -385,20 +363,20 @@ static int mxsmmc_init(struct mmc *mmc)
        return 0;
 }
 
+static const struct mmc_ops mxsmmc_ops = {
+       .send_cmd       = mxsmmc_send_cmd,
+       .set_ios        = mxsmmc_set_ios,
+       .init           = mxsmmc_init,
+};
+
 int mxsmmc_initialize(bd_t *bis, int id, int (*wp)(int), int (*cd)(int))
 {
        struct mmc *mmc = NULL;
        struct mxsmmc_priv *priv = NULL;
        int ret;
-#if defined(CONFIG_MX23)
-       const unsigned int mxsmmc_max_id = 2;
-       const unsigned int mxsmmc_clk_id = 0;
-#elif defined(CONFIG_MX28)
-       const unsigned int mxsmmc_max_id = 4;
-       const unsigned int mxsmmc_clk_id = id;
-#endif
+       const unsigned int mxsmmc_clk_id = mxs_ssp_clock_by_bus(id);
 
-       if (id >= mxsmmc_max_id)
+       if (!mxs_ssp_bus_id_valid(id))
                return -ENODEV;
 
        mmc = malloc(sizeof(struct mmc));
@@ -418,7 +396,7 @@ int mxsmmc_initialize(bd_t *bis, int id, int (*wp)(int), int (*cd)(int))
                return -ENOMEM;
        }
 
-       ret = mxs_dma_init_channel(id + mxsmmc_id_offset);
+       ret = mxs_dma_init_channel(MXS_DMA_CHANNEL_AHB_APBH_SSP0 + id);
        if (ret)
                return ret;
 
@@ -428,16 +406,14 @@ int mxsmmc_initialize(bd_t *bis, int id, int (*wp)(int), int (*cd)(int))
        priv->regs = mxs_ssp_regs_by_bus(id);
 
        sprintf(mmc->name, "MXS MMC");
-       mmc->send_cmd = mxsmmc_send_cmd;
-       mmc->set_ios = mxsmmc_set_ios;
-       mmc->init = mxsmmc_init;
-       mmc->getcd = NULL;
+       mmc->ops = &mxsmmc_ops;
        mmc->priv = priv;
 
        mmc->voltages = MMC_VDD_32_33 | MMC_VDD_33_34;
 
        mmc->host_caps = MMC_MODE_4BIT | MMC_MODE_8BIT |
-                        MMC_MODE_HS_52MHz | MMC_MODE_HS;
+                        MMC_MODE_HS_52MHz | MMC_MODE_HS |
+                        MMC_MODE_HC;
 
        /*
         * SSPCLK = 480 * 18 / 29 / 1 = 297.731 MHz