Skip to contentSkip to conversation

mmc: host: sdhci-pci: Add Genesys Logic GL975x support

PATCH Superseded Ben Chuang 3 participants 5 messages Aug 30, 2019 – Sep 5, 2019

Subsystems (2)

v7 of 9 Superseded Latest is v9 →

lore
Share & tools
lore

Ben Chuang

author
#0 lore raw

PATCH v7 5/5 mmc: host: sdhci-pci: Add Genesys Logic GL975x support

From: Ben Chuang <[email protected]>

Add support for the GL9750 and GL9755 chipsets.

Enable v4 mode and wait 5ms after set 1.8V signal enable for GL9750/ GL9755. Fix the value of SDHCI_MAX_CURRENT register and use the vendor tuning flow for GL9750.

---
 drivers/mmc/host/Kconfig          |   1 +
 drivers/mmc/host/Makefile         |   2 +-
 drivers/mmc/host/sdhci-pci-core.c |   2 +
 drivers/mmc/host/sdhci-pci-gli.c  | 350 ++++++++++++++++++++++++++++++
 drivers/mmc/host/sdhci-pci.h      |   5 +
 5 files changed, 359 insertions(+), 1 deletion(-)
 create mode 100644 drivers/mmc/host/sdhci-pci-gli.c
drivers/mmc/host/Kconfig +1 -0
index 931770f17087..9fbfff514d6c 100644
@@ -94,6 +94,7 @@ config MMC_SDHCI_PCI
 	depends on MMC_SDHCI && PCI
 	select MMC_CQHCI
 	select IOSF_MBI if X86
+	select MMC_SDHCI_IO_ACCESSORS
 	help
 	  This selects the PCI Secure Digital Host Controller Interface.
 	  Most controllers found today are PCI devices.
drivers/mmc/host/Makefile +1 -1
index 73578718f119..661445415090 100644
@@ -13,7 +13,7 @@ obj-$(CONFIG_MMC_MXS)		+= mxs-mmc.o
 obj-$(CONFIG_MMC_SDHCI)		+= sdhci.o
 obj-$(CONFIG_MMC_SDHCI_PCI)	+= sdhci-pci.o
 sdhci-pci-y			+= sdhci-pci-core.o sdhci-pci-o2micro.o sdhci-pci-arasan.o \
-				   sdhci-pci-dwc-mshc.o
+				   sdhci-pci-dwc-mshc.o sdhci-pci-gli.o
 obj-$(subst m,y,$(CONFIG_MMC_SDHCI_PCI))	+= sdhci-pci-data.o
 obj-$(CONFIG_MMC_SDHCI_ACPI)	+= sdhci-acpi.o
 obj-$(CONFIG_MMC_SDHCI_PXAV3)	+= sdhci-pxav3.o
drivers/mmc/host/sdhci-pci-core.c +2 -0
index 4154ee11b47d..e5835fbf73bc 100644
@@ -1682,6 +1682,8 @@ static const struct pci_device_id pci_ids[] = {
 	SDHCI_PCI_DEVICE(O2, SEABIRD1, o2),
 	SDHCI_PCI_DEVICE(ARASAN, PHY_EMMC, arasan),
 	SDHCI_PCI_DEVICE(SYNOPSYS, DWC_MSHC, snps),
+	SDHCI_PCI_DEVICE(GLI, 9750, gl9750),
+	SDHCI_PCI_DEVICE(GLI, 9755, gl9755),
 	SDHCI_PCI_DEVICE_CLASS(AMD, SYSTEM_SDHCI, PCI_CLASS_MASK, amd),
 	/* Generic SD host controller */
 	{PCI_DEVICE_CLASS(SYSTEM_SDHCI, PCI_CLASS_MASK)},
drivers/mmc/host/sdhci-pci-gli.c new file +350 -0

350 lines not on this page · raw message

drivers/mmc/host/sdhci-pci.h +5 -0
index e5dc6e44c7a4..738ba5afcc20 100644
@@ -65,6 +65,9 @@
 
 #define PCI_DEVICE_ID_SYNOPSYS_DWC_MSHC 0xc202
 
+#define PCI_DEVICE_ID_GLI_9755		0x9755
+#define PCI_DEVICE_ID_GLI_9750		0x9750
+
 /*
  * PCI device class and mask
  */
@@ -185,5 +188,7 @@ int sdhci_pci_enable_dma(struct sdhci_host *host);
 extern const struct sdhci_pci_fixes sdhci_arasan;
 extern const struct sdhci_pci_fixes sdhci_snps;
 extern const struct sdhci_pci_fixes sdhci_o2;
+extern const struct sdhci_pci_fixes sdhci_gl9750;
+extern const struct sdhci_pci_fixes sdhci_gl9755;
 
 #endif /* __SDHCI_PCI_H */
Signature · 1 line
2.22.1
#1 lore raw
Quoted 11 lines · Ben Chuang

From: Ben Chuang <[email protected]>

Add support for the GL9750 and GL9755 chipsets.

Enable v4 mode and wait 5ms after set 1.8V signal enable for GL9750/ GL9755. Fix the value of SDHCI_MAX_CURRENT register and use the vendor tuning flow for GL9750.

Usually last one for latest developer / submitter goes on.

Quoted 7 lines
drivers/mmc/host/sdhci-pci-gli.c new file +1 -0
+#define GLI_MAX_TUNING_LOOP 40
 
 

drivers/mmc/host/sdhci-pci-gli.c line 108

Quoted 10 lines
drivers/mmc/host/sdhci-pci-gli.c new file +9 -0
+static void gli_set_9750(struct sdhci_host *host)
+{
+       u32 driving_value = 0;
+       u32 pll_value = 0;
+       u32 sw_ctrl_value = 0;
+       u32 misc_value = 0;
+       u32 parameter_value = 0;
+       u32 control_value = 0;
 
+

Redundant blank line.

Quoted 1 line

+ u16 ctrl2 = 0;

Do you need these all assignments above?

drivers/mmc/host/sdhci-pci-gli.c

Quoted 11 lines
drivers/mmc/host/sdhci-pci-gli.c new file +8 -0
+       driving_value = sdhci_readl(host, SDHCI_GLI_9750_DRIVING);
+       pll_value = sdhci_readl(host, SDHCI_GLI_9750_PLL);
+       sw_ctrl_value = sdhci_readl(host, SDHCI_GLI_9750_SW_CTRL);
+       misc_value = sdhci_readl(host, SDHCI_GLI_9750_MISC);
+       parameter_value = sdhci_readl(host, SDHCI_GLI_9750_TUNING_PARAMETERS);
+       control_value = sdhci_readl(host, SDHCI_GLI_9750_TUNING_CONTROL);
 
 
 
+
+       udelay(1);

This misses the answer to question why. Why this is needed and why timeout is this long?

drivers/mmc/host/sdhci-pci-gli.c line 220

Quoted 9 lines
drivers/mmc/host/sdhci-pci-gli.c new file +7 -0
+
+       gl9750_wt_off(host);
+}
 
+static int __sdhci_execute_tuning_9750(struct sdhci_host *host, u32 opcode)
+{
+       int i;
 
+       int rx_inv = 0;

Duplicate assignment.

drivers/mmc/host/sdhci-pci-gli.c line 226

Quoted 7 lines
drivers/mmc/host/sdhci-pci-gli.c new file +6 -0
+
+       for (rx_inv = 0; rx_inv < 2; rx_inv++) {
 
+               if (rx_inv & 0x1)
+                       gli_set_9750_rx_inv(host, true);
+               else
+                       gli_set_9750_rx_inv(host, false);

gli_set_...(host, !!rx_inv);

drivers/mmc/host/sdhci-pci-gli.c line 236

Quoted 11 lines
drivers/mmc/host/sdhci-pci-gli.c new file +10 -0
+
+               sdhci_start_tuning(host);
+
+               for (i = 0; i < GLI_MAX_TUNING_LOOP; i++) {
+                       u16 ctrl;
+
+                       sdhci_send_tuning(host, opcode);
+
+                       if (!host->tuning_done) {
 
+                               if (rx_inv == 1) {

It's an invariant to the loop. So, you may do this check after outter loop.

drivers/mmc/host/sdhci-pci-gli.c line 239

Quoted 4 lines
drivers/mmc/host/sdhci-pci-gli.c new file +3 -0
+                                       pr_info("%s: Tuning timeout, falling back to fixed sampling clock\n",
+                                               mmc_hostname(host->mmc));
 
+                                       sdhci_abort_tuning(host, opcode);

It will also de-duplicates this call.

Quoted 7 lines
drivers/mmc/host/sdhci-pci-gli.c new file +6 -0
+                                       return -ETIMEDOUT;
+                               }
+                               sdhci_abort_tuning(host, opcode);
+                               break;
+                       }
 
+               }

drivers/mmc/host/sdhci-pci-gli.c line 295

Quoted 10 lines
drivers/mmc/host/sdhci-pci-gli.c new file +9 -0
+       }
+
+       pr_info("%s: Tuning failed, falling back to fixed sampling clock\n",
+               mmc_hostname(host->mmc));
+       sdhci_reset_tuning(host);
+       return -EAGAIN;
+}
 
+static void sdhci_gli_voltage_switch(struct sdhci_host *host)
+{

Any comment why?

drivers/mmc/host/sdhci-pci-gli.c line 313

Quoted 13 lines
drivers/mmc/host/sdhci-pci-gli.c new file +11 -0
+       usleep_range(5000, 5500);
+}
 
+static u32 sdhci_gl9750_readl(struct sdhci_host *host, int reg)
+{
+       u32 value;
+
+       value = readl(host->ioaddr + reg);
 
+       if (unlikely(reg == SDHCI_MAX_CURRENT)) {
+               if (!(value & 0xff))
+                       value |= 0xc8;
+       }

if (a) {
if (b) {
...
}
}

is the same as

if (a && b) {
...
}

Quoted 5 lines
drivers/mmc/host/sdhci-pci.h +4 -0
+       return value;
+}
 
+#define PCI_DEVICE_ID_GLI_9755         0x9755
+#define PCI_DEVICE_ID_GLI_9750         0x9750
Signature · 2 lines
With Best Regards,
Andy Shevchenko
author
#2 lore raw
Quoted 147 lines · Andy Shevchenko
Quoted 11 lines · Ben Chuang

From: Ben Chuang <[email protected]>

Add support for the GL9750 and GL9755 chipsets.

Enable v4 mode and wait 5ms after set 1.8V signal enable for GL9750/ GL9755. Fix the value of SDHCI_MAX_CURRENT register and use the vendor tuning flow for GL9750.

Usually last one for latest developer / submitter goes on.

Quoted 7 lines
drivers/mmc/host/sdhci-pci-gli.c new file +1 -0
+#define GLI_MAX_TUNING_LOOP 40
 
 

drivers/mmc/host/sdhci-pci-gli.c line 108

Quoted 10 lines
drivers/mmc/host/sdhci-pci-gli.c new file +9 -0
+static void gli_set_9750(struct sdhci_host *host)
+{
+       u32 driving_value = 0;
+       u32 pll_value = 0;
+       u32 sw_ctrl_value = 0;
+       u32 misc_value = 0;
+       u32 parameter_value = 0;
+       u32 control_value = 0;
 
+

Redundant blank line.

Quoted 1 line

+ u16 ctrl2 = 0;

Do you need these all assignments above?

drivers/mmc/host/sdhci-pci-gli.c

Quoted 11 lines
drivers/mmc/host/sdhci-pci-gli.c new file +8 -0
+       driving_value = sdhci_readl(host, SDHCI_GLI_9750_DRIVING);
+       pll_value = sdhci_readl(host, SDHCI_GLI_9750_PLL);
+       sw_ctrl_value = sdhci_readl(host, SDHCI_GLI_9750_SW_CTRL);
+       misc_value = sdhci_readl(host, SDHCI_GLI_9750_MISC);
+       parameter_value = sdhci_readl(host, SDHCI_GLI_9750_TUNING_PARAMETERS);
+       control_value = sdhci_readl(host, SDHCI_GLI_9750_TUNING_CONTROL);
 
 
 
+
+       udelay(1);

This misses the answer to question why. Why this is needed and why timeout is this long?

drivers/mmc/host/sdhci-pci-gli.c line 220

Quoted 9 lines
drivers/mmc/host/sdhci-pci-gli.c new file +7 -0
+
+       gl9750_wt_off(host);
+}
 
+static int __sdhci_execute_tuning_9750(struct sdhci_host *host, u32 opcode)
+{
+       int i;
 
+       int rx_inv = 0;

Duplicate assignment.

drivers/mmc/host/sdhci-pci-gli.c line 226

Quoted 7 lines
drivers/mmc/host/sdhci-pci-gli.c new file +6 -0
+
+       for (rx_inv = 0; rx_inv < 2; rx_inv++) {
 
+               if (rx_inv & 0x1)
+                       gli_set_9750_rx_inv(host, true);
+               else
+                       gli_set_9750_rx_inv(host, false);

gli_set_...(host, !!rx_inv);

drivers/mmc/host/sdhci-pci-gli.c line 236

Quoted 11 lines
drivers/mmc/host/sdhci-pci-gli.c new file +10 -0
+
+               sdhci_start_tuning(host);
+
+               for (i = 0; i < GLI_MAX_TUNING_LOOP; i++) {
+                       u16 ctrl;
+
+                       sdhci_send_tuning(host, opcode);
+
+                       if (!host->tuning_done) {
 
+                               if (rx_inv == 1) {

It's an invariant to the loop. So, you may do this check after outter loop.

drivers/mmc/host/sdhci-pci-gli.c line 239

Quoted 4 lines
drivers/mmc/host/sdhci-pci-gli.c new file +3 -0
+                                       pr_info("%s: Tuning timeout, falling back to fixed sampling clock\n",
+                                               mmc_hostname(host->mmc));
 
+                                       sdhci_abort_tuning(host, opcode);

It will also de-duplicates this call.

Quoted 7 lines
drivers/mmc/host/sdhci-pci-gli.c new file +6 -0
+                                       return -ETIMEDOUT;
+                               }
+                               sdhci_abort_tuning(host, opcode);
+                               break;
+                       }
 
+               }

drivers/mmc/host/sdhci-pci-gli.c line 295

Quoted 10 lines
drivers/mmc/host/sdhci-pci-gli.c new file +9 -0
+       }
+
+       pr_info("%s: Tuning failed, falling back to fixed sampling clock\n",
+               mmc_hostname(host->mmc));
+       sdhci_reset_tuning(host);
+       return -EAGAIN;
+}
 
+static void sdhci_gli_voltage_switch(struct sdhci_host *host)
+{

Any comment why?

drivers/mmc/host/sdhci-pci-gli.c line 313

Quoted 13 lines
drivers/mmc/host/sdhci-pci-gli.c new file +11 -0
+       usleep_range(5000, 5500);
+}
 
+static u32 sdhci_gl9750_readl(struct sdhci_host *host, int reg)
+{
+       u32 value;
+
+       value = readl(host->ioaddr + reg);
 
+       if (unlikely(reg == SDHCI_MAX_CURRENT)) {
+               if (!(value & 0xff))
+                       value |= 0xc8;
+       }

if (a) {

 if (b) {
   ...

}
}

is the same as

if (a && b) {
...
}

Quoted 2 lines
drivers/mmc/host/sdhci-pci-gli.c new file +2 -0
+       return value;
+}
Quoted 6 lines

drivers/mmc/host/sdhci-pci.h line 69

Quoted 2 lines
drivers/mmc/host/sdhci-pci.h +2 -0
+#define PCI_DEVICE_ID_GLI_9755         0x9755
+#define PCI_DEVICE_ID_GLI_9750         0x9750

--
With Best Regards,
Andy Shevchenko

Hi, Andy,

Thank you for your comments to make the code better. Waiting to see if Adrian has any other comments.

Best Regards,
Ben Chuang

maintainer
#3 lore raw
Quoted 156 lines · Ben Chuang
Quoted 147 lines · Andy Shevchenko
Quoted 11 lines · Ben Chuang

From: Ben Chuang <[email protected]>

Add support for the GL9750 and GL9755 chipsets.

Enable v4 mode and wait 5ms after set 1.8V signal enable for GL9750/ GL9755. Fix the value of SDHCI_MAX_CURRENT register and use the vendor tuning flow for GL9750.

Usually last one for latest developer / submitter goes on.

Quoted 7 lines
drivers/mmc/host/sdhci-pci-gli.c new file +1 -0
+#define GLI_MAX_TUNING_LOOP 40
 
 

drivers/mmc/host/sdhci-pci-gli.c line 108

Quoted 10 lines
drivers/mmc/host/sdhci-pci-gli.c new file +9 -0
+static void gli_set_9750(struct sdhci_host *host)
+{
+       u32 driving_value = 0;
+       u32 pll_value = 0;
+       u32 sw_ctrl_value = 0;
+       u32 misc_value = 0;
+       u32 parameter_value = 0;
+       u32 control_value = 0;
 
+

Redundant blank line.

Quoted 1 line

+ u16 ctrl2 = 0;

Do you need these all assignments above?

drivers/mmc/host/sdhci-pci-gli.c

Quoted 11 lines
drivers/mmc/host/sdhci-pci-gli.c new file +8 -0
+       driving_value = sdhci_readl(host, SDHCI_GLI_9750_DRIVING);
+       pll_value = sdhci_readl(host, SDHCI_GLI_9750_PLL);
+       sw_ctrl_value = sdhci_readl(host, SDHCI_GLI_9750_SW_CTRL);
+       misc_value = sdhci_readl(host, SDHCI_GLI_9750_MISC);
+       parameter_value = sdhci_readl(host, SDHCI_GLI_9750_TUNING_PARAMETERS);
+       control_value = sdhci_readl(host, SDHCI_GLI_9750_TUNING_CONTROL);
 
 
 
+
+       udelay(1);

This misses the answer to question why. Why this is needed and why timeout is this long?

drivers/mmc/host/sdhci-pci-gli.c line 220

Quoted 9 lines
drivers/mmc/host/sdhci-pci-gli.c new file +7 -0
+
+       gl9750_wt_off(host);
+}
 
+static int __sdhci_execute_tuning_9750(struct sdhci_host *host, u32 opcode)
+{
+       int i;
 
+       int rx_inv = 0;

Duplicate assignment.

drivers/mmc/host/sdhci-pci-gli.c line 226

Quoted 7 lines
drivers/mmc/host/sdhci-pci-gli.c new file +6 -0
+
+       for (rx_inv = 0; rx_inv < 2; rx_inv++) {
 
+               if (rx_inv & 0x1)
+                       gli_set_9750_rx_inv(host, true);
+               else
+                       gli_set_9750_rx_inv(host, false);

gli_set_...(host, !!rx_inv);

drivers/mmc/host/sdhci-pci-gli.c line 236

Quoted 11 lines
drivers/mmc/host/sdhci-pci-gli.c new file +10 -0
+
+               sdhci_start_tuning(host);
+
+               for (i = 0; i < GLI_MAX_TUNING_LOOP; i++) {
+                       u16 ctrl;
+
+                       sdhci_send_tuning(host, opcode);
+
+                       if (!host->tuning_done) {
 
+                               if (rx_inv == 1) {

It's an invariant to the loop. So, you may do this check after outter loop.

drivers/mmc/host/sdhci-pci-gli.c line 239

Quoted 4 lines
drivers/mmc/host/sdhci-pci-gli.c new file +3 -0
+                                       pr_info("%s: Tuning timeout, falling back to fixed sampling clock\n",
+                                               mmc_hostname(host->mmc));
 
+                                       sdhci_abort_tuning(host, opcode);

It will also de-duplicates this call.

Quoted 7 lines
drivers/mmc/host/sdhci-pci-gli.c new file +6 -0
+                                       return -ETIMEDOUT;
+                               }
+                               sdhci_abort_tuning(host, opcode);
+                               break;
+                       }
 
+               }

drivers/mmc/host/sdhci-pci-gli.c line 295

Quoted 10 lines
drivers/mmc/host/sdhci-pci-gli.c new file +9 -0
+       }
+
+       pr_info("%s: Tuning failed, falling back to fixed sampling clock\n",
+               mmc_hostname(host->mmc));
+       sdhci_reset_tuning(host);
+       return -EAGAIN;
+}
 
+static void sdhci_gli_voltage_switch(struct sdhci_host *host)
+{

Any comment why?

drivers/mmc/host/sdhci-pci-gli.c line 313

Quoted 13 lines
drivers/mmc/host/sdhci-pci-gli.c new file +11 -0
+       usleep_range(5000, 5500);
+}
 
+static u32 sdhci_gl9750_readl(struct sdhci_host *host, int reg)
+{
+       u32 value;
+
+       value = readl(host->ioaddr + reg);
 
+       if (unlikely(reg == SDHCI_MAX_CURRENT)) {
+               if (!(value & 0xff))
+                       value |= 0xc8;
+       }

if (a) {

 if (b) {
   ...

}
}

is the same as

if (a && b) {
...
}

Quoted 2 lines
drivers/mmc/host/sdhci-pci-gli.c new file +2 -0
+       return value;
+}
Quoted 6 lines

drivers/mmc/host/sdhci-pci.h line 69

Quoted 2 lines
drivers/mmc/host/sdhci-pci.h +2 -0
+#define PCI_DEVICE_ID_GLI_9755         0x9755
+#define PCI_DEVICE_ID_GLI_9750         0x9750

--
With Best Regards,
Andy Shevchenko

Quoted 4 lines

Hi, Andy,

Thank you for your comments to make the code better. Waiting to see if Adrian has any other comments.

Nope! :-)

Please go ahead and address Andy's comments.

author
#4 lore raw
Quoted 158 lines · Adrian Hunter
Quoted 156 lines · Ben Chuang
Quoted 153 lines · Andy Shevchenko
Quoted 11 lines · Ben Chuang

From: Ben Chuang <[email protected]>

Add support for the GL9750 and GL9755 chipsets.

Enable v4 mode and wait 5ms after set 1.8V signal enable for GL9750/ GL9755. Fix the value of SDHCI_MAX_CURRENT register and use the vendor tuning flow for GL9750.

Usually last one for latest developer / submitter goes on.

Quoted 7 lines
drivers/mmc/host/sdhci-pci-gli.c new file +1 -0
+#define GLI_MAX_TUNING_LOOP 40
 
 

drivers/mmc/host/sdhci-pci-gli.c line 108

Quoted 10 lines
drivers/mmc/host/sdhci-pci-gli.c new file +9 -0
+static void gli_set_9750(struct sdhci_host *host)
+{
+       u32 driving_value = 0;
+       u32 pll_value = 0;
+       u32 sw_ctrl_value = 0;
+       u32 misc_value = 0;
+       u32 parameter_value = 0;
+       u32 control_value = 0;
 
+

Redundant blank line.

Quoted 1 line

+ u16 ctrl2 = 0;

Do you need these all assignments above?

drivers/mmc/host/sdhci-pci-gli.c

Quoted 11 lines
drivers/mmc/host/sdhci-pci-gli.c new file +8 -0
+       driving_value = sdhci_readl(host, SDHCI_GLI_9750_DRIVING);
+       pll_value = sdhci_readl(host, SDHCI_GLI_9750_PLL);
+       sw_ctrl_value = sdhci_readl(host, SDHCI_GLI_9750_SW_CTRL);
+       misc_value = sdhci_readl(host, SDHCI_GLI_9750_MISC);
+       parameter_value = sdhci_readl(host, SDHCI_GLI_9750_TUNING_PARAMETERS);
+       control_value = sdhci_readl(host, SDHCI_GLI_9750_TUNING_CONTROL);
 
 
 
+
+       udelay(1);

This misses the answer to question why. Why this is needed and why timeout is this long?

drivers/mmc/host/sdhci-pci-gli.c line 220

Quoted 9 lines
drivers/mmc/host/sdhci-pci-gli.c new file +7 -0
+
+       gl9750_wt_off(host);
+}
 
+static int __sdhci_execute_tuning_9750(struct sdhci_host *host, u32 opcode)
+{
+       int i;
 
+       int rx_inv = 0;

Duplicate assignment.

drivers/mmc/host/sdhci-pci-gli.c line 226

Quoted 7 lines
drivers/mmc/host/sdhci-pci-gli.c new file +6 -0
+
+       for (rx_inv = 0; rx_inv < 2; rx_inv++) {
 
+               if (rx_inv & 0x1)
+                       gli_set_9750_rx_inv(host, true);
+               else
+                       gli_set_9750_rx_inv(host, false);

gli_set_...(host, !!rx_inv);

drivers/mmc/host/sdhci-pci-gli.c line 236

Quoted 11 lines
drivers/mmc/host/sdhci-pci-gli.c new file +10 -0
+
+               sdhci_start_tuning(host);
+
+               for (i = 0; i < GLI_MAX_TUNING_LOOP; i++) {
+                       u16 ctrl;
+
+                       sdhci_send_tuning(host, opcode);
+
+                       if (!host->tuning_done) {
 
+                               if (rx_inv == 1) {

It's an invariant to the loop. So, you may do this check after outter loop.

drivers/mmc/host/sdhci-pci-gli.c line 239

Quoted 4 lines
drivers/mmc/host/sdhci-pci-gli.c new file +3 -0
+                                       pr_info("%s: Tuning timeout, falling back to fixed sampling clock\n",
+                                               mmc_hostname(host->mmc));
 
+                                       sdhci_abort_tuning(host, opcode);

It will also de-duplicates this call.

Quoted 7 lines
drivers/mmc/host/sdhci-pci-gli.c new file +6 -0
+                                       return -ETIMEDOUT;
+                               }
+                               sdhci_abort_tuning(host, opcode);
+                               break;
+                       }
 
+               }

drivers/mmc/host/sdhci-pci-gli.c line 295

Quoted 10 lines
drivers/mmc/host/sdhci-pci-gli.c new file +9 -0
+       }
+
+       pr_info("%s: Tuning failed, falling back to fixed sampling clock\n",
+               mmc_hostname(host->mmc));
+       sdhci_reset_tuning(host);
+       return -EAGAIN;
+}
 
+static void sdhci_gli_voltage_switch(struct sdhci_host *host)
+{

Any comment why?

drivers/mmc/host/sdhci-pci-gli.c line 313

Quoted 13 lines
drivers/mmc/host/sdhci-pci-gli.c new file +11 -0
+       usleep_range(5000, 5500);
+}
 
+static u32 sdhci_gl9750_readl(struct sdhci_host *host, int reg)
+{
+       u32 value;
+
+       value = readl(host->ioaddr + reg);
 
+       if (unlikely(reg == SDHCI_MAX_CURRENT)) {
+               if (!(value & 0xff))
+                       value |= 0xc8;
+       }

if (a) {

 if (b) {
   ...

}
}

is the same as

if (a && b) {
...
}

drivers/mmc/host/sdhci-pci.h line 69

Quoted 5 lines
drivers/mmc/host/sdhci-pci.h +4 -0
+       return value;
+}
 
+#define PCI_DEVICE_ID_GLI_9755         0x9755
+#define PCI_DEVICE_ID_GLI_9750         0x9750

--
With Best Regards,
Andy Shevchenko

Quoted 8 lines
Quoted 4 lines

Hi, Andy,

Thank you for your comments to make the code better. Waiting to see if Adrian has any other comments.

Nope! :-)

Please go ahead and address Andy's comments.

OK, refine the code and let it better.