mmc: mmci: Don't pretend all variants to have OPENDRAIN bit
authorPatrice Chotard <patrice.chotard@st.com>
Thu, 18 Jan 2018 14:34:19 +0000 (15:34 +0100)
committerUlf Hansson <ulf.hansson@linaro.org>
Thu, 18 Jan 2018 17:14:45 +0000 (18:14 +0100)
This patch prepares for supporting STM32 variant which doesn't
have opendrain bit in MMCIPOWER register.
ST others variant (u300, nomadik and ux500) uses MCI_OD bit whereas
others variants uses MCI_ROD bit.

Signed-off-by: Patrice Chotard <patrice.chotard@st.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
drivers/mmc/host/mmci.c

index 91a35b8..c1123f6 100644 (file)
@@ -85,6 +85,7 @@ static unsigned int fmax = 515633;
  * @mmcimask1: true if variant have a MMCIMASK1 register.
  * @start_err: bitmask identifying the STARTBITERR bit inside MMCISTATUS
  *            register.
+ * @opendrain: bitmask identifying the OPENDRAIN bit inside MMCIPOWER register
  */
 struct variant_data {
        unsigned int            clkreg;
@@ -116,6 +117,7 @@ struct variant_data {
        bool                    reversed_irq_handling;
        bool                    mmcimask1;
        u32                     start_err;
+       u32                     opendrain;
 };
 
 static struct variant_data variant_arm = {
@@ -127,6 +129,7 @@ static struct variant_data variant_arm = {
        .reversed_irq_handling  = true,
        .mmcimask1              = true,
        .start_err              = MCI_STARTBITERR,
+       .opendrain              = MCI_ROD,
 };
 
 static struct variant_data variant_arm_extended_fifo = {
@@ -137,6 +140,7 @@ static struct variant_data variant_arm_extended_fifo = {
        .f_max                  = 100000000,
        .mmcimask1              = true,
        .start_err              = MCI_STARTBITERR,
+       .opendrain              = MCI_ROD,
 };
 
 static struct variant_data variant_arm_extended_fifo_hwfc = {
@@ -148,6 +152,7 @@ static struct variant_data variant_arm_extended_fifo_hwfc = {
        .f_max                  = 100000000,
        .mmcimask1              = true,
        .start_err              = MCI_STARTBITERR,
+       .opendrain              = MCI_ROD,
 };
 
 static struct variant_data variant_u300 = {
@@ -165,6 +170,7 @@ static struct variant_data variant_u300 = {
        .pwrreg_nopower         = true,
        .mmcimask1              = true,
        .start_err              = MCI_STARTBITERR,
+       .opendrain              = MCI_OD,
 };
 
 static struct variant_data variant_nomadik = {
@@ -183,6 +189,7 @@ static struct variant_data variant_nomadik = {
        .pwrreg_nopower         = true,
        .mmcimask1              = true,
        .start_err              = MCI_STARTBITERR,
+       .opendrain              = MCI_OD,
 };
 
 static struct variant_data variant_ux500 = {
@@ -207,6 +214,7 @@ static struct variant_data variant_ux500 = {
        .pwrreg_nopower         = true,
        .mmcimask1              = true,
        .start_err              = MCI_STARTBITERR,
+       .opendrain              = MCI_OD,
 };
 
 static struct variant_data variant_ux500v2 = {
@@ -233,6 +241,7 @@ static struct variant_data variant_ux500v2 = {
        .pwrreg_nopower         = true,
        .mmcimask1              = true,
        .start_err              = MCI_STARTBITERR,
+       .opendrain              = MCI_OD,
 };
 
 static struct variant_data variant_qcom = {
@@ -253,6 +262,7 @@ static struct variant_data variant_qcom = {
        .qcom_dml               = true,
        .mmcimask1              = true,
        .start_err              = MCI_STARTBITERR,
+       .opendrain              = MCI_ROD,
 };
 
 /* Busy detection for the ST Micro variant */
@@ -1455,17 +1465,8 @@ static void mmci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
                                ~MCI_ST_DATA2DIREN);
        }
 
-       if (ios->bus_mode == MMC_BUSMODE_OPENDRAIN) {
-               if (host->hw_designer != AMBA_VENDOR_ST)
-                       pwr |= MCI_ROD;
-               else {
-                       /*
-                        * The ST Micro variant use the ROD bit for something
-                        * else and only has OD (Open Drain).
-                        */
-                       pwr |= MCI_OD;
-               }
-       }
+       if (ios->bus_mode == MMC_BUSMODE_OPENDRAIN && variant->opendrain)
+               pwr |= variant->opendrain;
 
        /*
         * If clock = 0 and the variant requires the MMCIPOWER to be used for