diff mbox

[v2,03/15] mmc: mmci: Don't pretend all variants to have OPENDRAIN bit

Message ID 1516105859-3525-4-git-send-email-patrice.chotard@st.com (mailing list archive)
State New, archived
Headers show

Commit Message

Patrice CHOTARD Jan. 16, 2018, 12:30 p.m. UTC
From: Patrice Chotard <patrice.chotard@st.com>

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>
---

v2: _ Replace opendrain bool type by u32
    _ Clean opendrain bit management code

 drivers/mmc/host/mmci.c | 27 +++++++++++++++++----------
 1 file changed, 17 insertions(+), 10 deletions(-)

Comments

Ulf Hansson Jan. 17, 2018, 9:33 a.m. UTC | #1
[...]

>  /* Busy detection for the ST Micro variant */
> @@ -1455,16 +1465,13 @@ 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 &&
> +           host->variant->opendrain) {

A few nitpicks (because I anyway had some comment on patch4):

The above can be written on one line and the brackets isn't needed.

Replace host->variant->opendrain with variant->opendrain. The same
applies to the below change.

> +               /*
> +                * The ST Micro variant use the ROD bit for
> +                * something else and only has OD (Open Drain).
> +                */

I think we can remove this comment, as this information becomes
implicit when we start using the variant data.

> +               pwr |= host->variant->opendrain;
>         }
>
>         /*
> --
> 1.9.1
>

Kind regards
Uffe
--
To unsubscribe from this list: send the line "unsubscribe linux-mmc" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Patrice CHOTARD Jan. 18, 2018, 1:24 p.m. UTC | #2
Hi Ulf

On 01/17/2018 10:33 AM, Ulf Hansson wrote:
> [...]

> 

>>   /* Busy detection for the ST Micro variant */

>> @@ -1455,16 +1465,13 @@ 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 &&

>> +           host->variant->opendrain) {

> 

> A few nitpicks (because I anyway had some comment on patch4):

> 

> The above can be written on one line and the brackets isn't needed.

> 

> Replace host->variant->opendrain with variant->opendrain. The same

> applies to the below change.


Ah yes, i will fix it

> 

>> +               /*

>> +                * The ST Micro variant use the ROD bit for

>> +                * something else and only has OD (Open Drain).

>> +                */

> 

> I think we can remove this comment, as this information becomes

> implicit when we start using the variant data.


Ok

Thanks

Patrice

> 

>> +               pwr |= host->variant->opendrain;

>>          }

>>

>>          /*

>> --

>> 1.9.1

>>

> 

> Kind regards

> Uffe

>
diff mbox

Patch

diff --git a/drivers/mmc/host/mmci.c b/drivers/mmc/host/mmci.c
index 8a4fbc2..eb5fcfe 100644
--- a/drivers/mmc/host/mmci.c
+++ b/drivers/mmc/host/mmci.c
@@ -85,6 +85,7 @@ 
  * @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 @@  struct variant_data {
 	.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 @@  struct variant_data {
 	.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 @@  struct variant_data {
 	.f_max			= 100000000,
 	.mmcimask1		= true,
 	.start_err		= MCI_STARTBITERR,
+	.opendrain		= MCI_ROD,
 };
 
 static struct variant_data variant_u300 = {
@@ -165,6 +170,7 @@  struct variant_data {
 	.pwrreg_nopower		= true,
 	.mmcimask1		= true,
 	.start_err		= MCI_STARTBITERR,
+	.opendrain		= MCI_OD,
 };
 
 static struct variant_data variant_nomadik = {
@@ -183,6 +189,7 @@  struct variant_data {
 	.pwrreg_nopower		= true,
 	.mmcimask1		= true,
 	.start_err		= MCI_STARTBITERR,
+	.opendrain		= MCI_OD,
 };
 
 static struct variant_data variant_ux500 = {
@@ -207,6 +214,7 @@  struct variant_data {
 	.pwrreg_nopower		= true,
 	.mmcimask1		= true,
 	.start_err		= MCI_STARTBITERR,
+	.opendrain		= MCI_OD,
 };
 
 static struct variant_data variant_ux500v2 = {
@@ -233,6 +241,7 @@  struct variant_data {
 	.pwrreg_nopower		= true,
 	.mmcimask1		= true,
 	.start_err		= MCI_STARTBITERR,
+	.opendrain		= MCI_OD,
 };
 
 static struct variant_data variant_qcom = {
@@ -253,6 +262,7 @@  struct variant_data {
 	.qcom_dml		= true,
 	.mmcimask1		= true,
 	.start_err		= MCI_STARTBITERR,
+	.opendrain		= MCI_ROD,
 };
 
 /* Busy detection for the ST Micro variant */
@@ -1455,16 +1465,13 @@  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 &&
+	    host->variant->opendrain) {
+		/*
+		 * The ST Micro variant use the ROD bit for
+		 * something else and only has OD (Open Drain).
+		 */
+		pwr |= host->variant->opendrain;
 	}
 
 	/*