All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH V7 1/5] mmc: sdhci: Add support for O2 eMMC HS200 mode
@ 2018-07-16  6:26 ernest.zhang
  2018-07-16  6:26 ` [PATCH V7 2/5] mmc: sdhci: Change O2 Host HS200 mode clock frequency to 200MHz ernest.zhang
                   ` (5 more replies)
  0 siblings, 6 replies; 13+ messages in thread
From: ernest.zhang @ 2018-07-16  6:26 UTC (permalink / raw)
  To: Adrian Hunter, Ulf Hansson, linux-mmc, linux-kernel
  Cc: ernest.zhang, chuanjin.pang, mike.li, chevron.li, shirley.her,
	xiaoguang.yu, bobby.wu

When use eMMC as boot device, the eMMC signaling voltage is tied to 1.8v
fixed output voltage, bios can set o2 sd host controller PCI configuration
register 0x308 bit4 to 1 to let driver skip 3.3v signaling voltage and
direct use 1.8v singling voltage in eMMC initialize process.

Signed-off-by: ernest.zhang <ernest.zhang@bayhubtech.com>
---
Changes in V7:
	Move V6 change item 2 to a seperate patch file

Changes in V6:
	1.Move change log to correct place.
	2.Change HS200 mode clock frequency from 208MHz to 200MHz to meet
	Specification.

Changes in V5:
	Modify code format to pass checkpatch.pl check and add a summary
	of what has changed in each version.

Changes in V4:
	Skip SDIO and SD initalization when register 0x308 bit 4 is set,
	and modify some typo.

Changes in V3:
	Rebase the patch on the mmc tree 'next' branch.

Changes in V2:
	Modify code format, and delete unused code path.

Changes in V1:
	Check PCIe register 0x308 bit 4 and skip eMMC 3.3v initialization
	process if it is set to 1.
---
 drivers/mmc/host/sdhci-pci-o2micro.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/drivers/mmc/host/sdhci-pci-o2micro.c b/drivers/mmc/host/sdhci-pci-o2micro.c
index 555970a29c94..ba59db6a126c 100644
--- a/drivers/mmc/host/sdhci-pci-o2micro.c
+++ b/drivers/mmc/host/sdhci-pci-o2micro.c
@@ -3,6 +3,7 @@
  *
  * Authors: Peter Guo <peter.guo@bayhubtech.com>
  *          Adam Lee <adam.lee@canonical.com>
+ *          Ernest Zhang <ernest.zhang@bayhubtech.com>
  *
  * This software is licensed under the terms of the GNU General Public
  * License version 2, as published by the Free Software Foundation, and
@@ -39,6 +40,7 @@
 #define O2_SD_MISC_CTRL4	0xFC
 #define O2_SD_TUNING_CTRL	0x300
 #define O2_SD_PLL_SETTING	0x304
+#define O2_SD_MISC_SETTING	0x308
 #define O2_SD_CLK_SETTING	0x328
 #define O2_SD_CAP_REG2		0x330
 #define O2_SD_CAP_REG0		0x334
@@ -184,6 +186,7 @@ int sdhci_pci_o2_probe_slot(struct sdhci_pci_slot *slot)
 	struct sdhci_pci_chip *chip;
 	struct sdhci_host *host;
 	u32 reg;
+	int ret;
 
 	chip = slot->chip;
 	host = slot->host;
@@ -197,6 +200,21 @@ int sdhci_pci_o2_probe_slot(struct sdhci_pci_slot *slot)
 		if (reg & 0x1)
 			host->quirks |= SDHCI_QUIRK_MULTIBLOCK_READ_ACMD12;
 
+		if (chip->pdev->device == PCI_DEVICE_ID_O2_SEABIRD0) {
+			ret = pci_read_config_dword(chip->pdev,
+						    O2_SD_MISC_SETTING, &reg);
+			if (ret)
+				return -EIO;
+			if (reg & (1 << 4)) {
+				pr_info("%s: emmc 1.8v flag is set, force 1.8v signaling voltage\n",
+					mmc_hostname(host->mmc));
+				host->flags &= ~SDHCI_SIGNALING_330;
+				host->flags |= SDHCI_SIGNALING_180;
+				host->mmc->caps2 |= MMC_CAP2_NO_SD;
+				host->mmc->caps2 |= MMC_CAP2_NO_SDIO;
+			}
+		}
+
 		if (chip->pdev->device != PCI_DEVICE_ID_O2_FUJIN2)
 			break;
 		/* set dll watch dog timer */
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH V7 2/5] mmc: sdhci: Change O2 Host HS200 mode clock frequency to 200MHz
  2018-07-16  6:26 [PATCH V7 1/5] mmc: sdhci: Add support for O2 eMMC HS200 mode ernest.zhang
@ 2018-07-16  6:26 ` ernest.zhang
  2018-07-25  7:45   ` Adrian Hunter
  2018-07-16  6:26 ` [PATCH V7 3/5] mmc: sdhci: Export sdhci tuning function symbol ernest.zhang
                   ` (4 subsequent siblings)
  5 siblings, 1 reply; 13+ messages in thread
From: ernest.zhang @ 2018-07-16  6:26 UTC (permalink / raw)
  To: Adrian Hunter, Ulf Hansson, linux-mmc, linux-kernel
  Cc: ernest.zhang, chuanjin.pang, mike.li, chevron.li, shirley.her,
	xiaoguang.yu, bobby.wu

O2 SD Host HS200 mode clock frequency current is 208MHz, should be changed
to 200MHz to meet specification.

Signed-off-by: ernest.zhang <ernest.zhang@bayhubtech.com>
---
Change in V7:
	Change HS200 mode clock frequency from 208MHz to 200MHz to meet
	Specification.

Change in V1~V6:
	N/A
---
 drivers/mmc/host/sdhci-pci-o2micro.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/mmc/host/sdhci-pci-o2micro.c b/drivers/mmc/host/sdhci-pci-o2micro.c
index ba59db6a126c..94cf3cd75dd3 100644
--- a/drivers/mmc/host/sdhci-pci-o2micro.c
+++ b/drivers/mmc/host/sdhci-pci-o2micro.c
@@ -311,7 +311,7 @@ int sdhci_pci_o2_probe(struct sdhci_pci_chip *chip)
 
 			/* Check Whether subId is 0x11 or 0x12 */
 			if ((scratch_32 == 0x11) || (scratch_32 == 0x12)) {
-				scratch_32 = 0x2c280000;
+				scratch_32 = 0x25100000;
 
 				/* Set Base Clock to 208MZ */
 				o2_pci_set_baseclk(chip, scratch_32);
@@ -406,7 +406,7 @@ int sdhci_pci_o2_probe(struct sdhci_pci_chip *chip)
 					       O2_SD_PLL_SETTING, scratch_32);
 		} else {
 			scratch_32 &= 0x0000FFFF;
-			scratch_32 |= 0x2c280000;
+			scratch_32 |= 0x25100000;
 
 			pci_write_config_dword(chip->pdev,
 					       O2_SD_PLL_SETTING, scratch_32);
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH V7 3/5] mmc: sdhci: Export sdhci tuning function symbol
  2018-07-16  6:26 [PATCH V7 1/5] mmc: sdhci: Add support for O2 eMMC HS200 mode ernest.zhang
  2018-07-16  6:26 ` [PATCH V7 2/5] mmc: sdhci: Change O2 Host HS200 mode clock frequency to 200MHz ernest.zhang
@ 2018-07-16  6:26 ` ernest.zhang
  2018-07-25  7:46   ` Adrian Hunter
  2018-07-16  6:26 ` [PATCH V7 4/5] mmc: sdhci: Add support for O2 hardware tuning ernest.zhang
                   ` (3 subsequent siblings)
  5 siblings, 1 reply; 13+ messages in thread
From: ernest.zhang @ 2018-07-16  6:26 UTC (permalink / raw)
  To: Adrian Hunter, Ulf Hansson, linux-mmc, linux-kernel
  Cc: ernest.zhang, chuanjin.pang, mike.li, chevron.li, shirley.her,
	xiaoguang.yu, bobby.wu

Export sdhci tuning function symbols which are used by other SD Host
controller driver modules.

Signed-off-by: ernest.zhang <ernest.zhang@bayhubtech.com>
---
Changes in V7:
	Export sdhci tuning function symbols

Changes in V1~V6
	N/A
---
 drivers/mmc/host/sdhci.c | 12 ++++++++----
 drivers/mmc/host/sdhci.h |  5 +++++
 2 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
index a7b5602ef6f7..bcea179a8d70 100644
--- a/drivers/mmc/host/sdhci.c
+++ b/drivers/mmc/host/sdhci.c
@@ -2103,7 +2103,7 @@ static int sdhci_prepare_hs400_tuning(struct mmc_host *mmc, struct mmc_ios *ios)
 	return 0;
 }
 
-static void sdhci_start_tuning(struct sdhci_host *host)
+void sdhci_start_tuning(struct sdhci_host *host)
 {
 	u16 ctrl;
 
@@ -2126,14 +2126,16 @@ static void sdhci_start_tuning(struct sdhci_host *host)
 	sdhci_writel(host, SDHCI_INT_DATA_AVAIL, SDHCI_INT_ENABLE);
 	sdhci_writel(host, SDHCI_INT_DATA_AVAIL, SDHCI_SIGNAL_ENABLE);
 }
+EXPORT_SYMBOL_GPL(sdhci_start_tuning);
 
-static void sdhci_end_tuning(struct sdhci_host *host)
+void sdhci_end_tuning(struct sdhci_host *host)
 {
 	sdhci_writel(host, host->ier, SDHCI_INT_ENABLE);
 	sdhci_writel(host, host->ier, SDHCI_SIGNAL_ENABLE);
 }
+EXPORT_SYMBOL_GPL(sdhci_end_tuning);
 
-static void sdhci_reset_tuning(struct sdhci_host *host)
+void sdhci_reset_tuning(struct sdhci_host *host)
 {
 	u16 ctrl;
 
@@ -2142,6 +2144,7 @@ static void sdhci_reset_tuning(struct sdhci_host *host)
 	ctrl &= ~SDHCI_CTRL_EXEC_TUNING;
 	sdhci_writew(host, ctrl, SDHCI_HOST_CONTROL2);
 }
+EXPORT_SYMBOL_GPL(sdhci_reset_tuning);
 
 static void sdhci_abort_tuning(struct sdhci_host *host, u32 opcode)
 {
@@ -2162,7 +2165,7 @@ static void sdhci_abort_tuning(struct sdhci_host *host, u32 opcode)
  * interrupt setup is different to other commands and there is no timeout
  * interrupt so special handling is needed.
  */
-static void sdhci_send_tuning(struct sdhci_host *host, u32 opcode)
+void sdhci_send_tuning(struct sdhci_host *host, u32 opcode)
 {
 	struct mmc_host *mmc = host->mmc;
 	struct mmc_command cmd = {};
@@ -2212,6 +2215,7 @@ static void sdhci_send_tuning(struct sdhci_host *host, u32 opcode)
 			   msecs_to_jiffies(50));
 
 }
+EXPORT_SYMBOL_GPL(sdhci_send_tuning);
 
 static void __sdhci_execute_tuning(struct sdhci_host *host, u32 opcode)
 {
diff --git a/drivers/mmc/host/sdhci.h b/drivers/mmc/host/sdhci.h
index 23966f887da6..f0bd36ce3817 100644
--- a/drivers/mmc/host/sdhci.h
+++ b/drivers/mmc/host/sdhci.h
@@ -748,4 +748,9 @@ bool sdhci_cqe_irq(struct sdhci_host *host, u32 intmask, int *cmd_error,
 
 void sdhci_dumpregs(struct sdhci_host *host);
 
+void sdhci_start_tuning(struct sdhci_host *host);
+void sdhci_end_tuning(struct sdhci_host *host);
+void sdhci_reset_tuning(struct sdhci_host *host);
+void sdhci_send_tuning(struct sdhci_host *host, u32 opcode);
+
 #endif /* __SDHCI_HW_H */
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH V7 4/5] mmc: sdhci: Add support for O2 hardware tuning
  2018-07-16  6:26 [PATCH V7 1/5] mmc: sdhci: Add support for O2 eMMC HS200 mode ernest.zhang
  2018-07-16  6:26 ` [PATCH V7 2/5] mmc: sdhci: Change O2 Host HS200 mode clock frequency to 200MHz ernest.zhang
  2018-07-16  6:26 ` [PATCH V7 3/5] mmc: sdhci: Export sdhci tuning function symbol ernest.zhang
@ 2018-07-16  6:26 ` ernest.zhang
  2018-07-25  7:48   ` Adrian Hunter
  2018-07-16  6:26 ` [PATCH V7 5/5] mmc: sdhci: Add MSI interrupt support for O2 SD host ernest.zhang
                   ` (2 subsequent siblings)
  5 siblings, 1 reply; 13+ messages in thread
From: ernest.zhang @ 2018-07-16  6:26 UTC (permalink / raw)
  To: Adrian Hunter, Ulf Hansson, linux-mmc, linux-kernel
  Cc: ernest.zhang, chuanjin.pang, mike.li, chevron.li, shirley.her,
	xiaoguang.yu, bobby.wu

Add hardware tuning function instead of software tuning because O2/Bayhub
SD host controller support hardware tuning.

Signed-off-by: ernest.zhang <ernest.zhang@bayhubtech.com>
---
Changes in V7:
	Move V6 change item 1 to a seperate patch.

Changes in V6:
	1. From module 'sdhci' export the symbols 'sdhci_start_tuning',
	'sdhci_end_tuning','sdhci_send_tuning' and 'sdhci_reset_tuning'.
	2. Remove local tuning related functions in sdhci-pci-o2-micro.c
	instead of above function exported in sdhci module.
	3. Remove unneeded braces in function sdhci_set_transfer_mode.
	4. Move change log to correct place.

Changes in V5:
	In function sdhci_o2_send_tuning, mrq.data should set to NULL for
	cmd.data has been set to NULL.

Changes in V4:
	Patch V3 delete register SDHCI_TRANSFER_MODE write operation before
	send hardware tuning command in function sdhci_o2_send_tuning. This
	is a mistake. The write operation is essential for tuning command.
	Add it back.

Changes in V3:
	Rebase the patch on the mmc tree 'next' branch.

Changes in V2:
	Modify code format, and delete unused code path.

Changes in V1:
	Add many functions to execute hardware tuning for eMMC 1.8V HS200
	mode, the hardware tuning procedure is based on O2/Bayhub hardware
	tuning spec.
---
 drivers/mmc/host/sdhci-pci-o2micro.c | 81 ++++++++++++++++++++++++++++
 drivers/mmc/host/sdhci.c             |  4 +-
 2 files changed, 84 insertions(+), 1 deletion(-)

diff --git a/drivers/mmc/host/sdhci-pci-o2micro.c b/drivers/mmc/host/sdhci-pci-o2micro.c
index 94cf3cd75dd3..7747e8ba2e3d 100644
--- a/drivers/mmc/host/sdhci-pci-o2micro.c
+++ b/drivers/mmc/host/sdhci-pci-o2micro.c
@@ -17,6 +17,9 @@
  */
 
 #include <linux/pci.h>
+#include <linux/mmc/host.h>
+#include <linux/mmc/mmc.h>
+#include <linux/delay.h>
 
 #include "sdhci.h"
 #include "sdhci-pci.h"
@@ -55,6 +58,82 @@
 
 #define O2_SD_VENDOR_SETTING	0x110
 #define O2_SD_VENDOR_SETTING2	0x1C8
+#define O2_SD_HW_TUNING_DISABLE	BIT(4)
+
+static void sdhci_o2_set_tuning_mode(struct sdhci_host *host)
+{
+	u16 reg;
+
+	/* enable hardware tuning */
+	reg = sdhci_readw(host, O2_SD_VENDOR_SETTING);
+	reg &= ~O2_SD_HW_TUNING_DISABLE;
+	sdhci_writew(host, reg, O2_SD_VENDOR_SETTING);
+}
+
+static void __sdhci_o2_execute_tuning(struct sdhci_host *host, u32 opcode)
+{
+	int i;
+
+	sdhci_send_tuning(host, MMC_SEND_TUNING_BLOCK_HS200);
+
+	for (i = 0; i < 150; i++) {
+		u16 ctrl = sdhci_readw(host, SDHCI_HOST_CONTROL2);
+
+		if (!(ctrl & SDHCI_CTRL_EXEC_TUNING)) {
+			if (ctrl & SDHCI_CTRL_TUNED_CLK) {
+				host->tuning_done = true;
+				return;
+			}
+			pr_warn("%s: HW tuning failed !\n",
+				mmc_hostname(host->mmc));
+			break;
+		}
+
+		mdelay(1);
+	}
+
+	pr_info("%s: Tuning failed, falling back to fixed sampling clock\n",
+		mmc_hostname(host->mmc));
+	sdhci_reset_tuning(host);
+}
+
+static int sdhci_o2_execute_tuning(struct mmc_host *mmc, u32 opcode)
+{
+	struct sdhci_host *host = mmc_priv(mmc);
+	int current_bus_width = 0;
+
+	/*
+	 * This handler only implements the eMMC tuning that is specific to
+	 * this controller.  Fall back to the standard method for other TIMING.
+	 */
+	if (host->timing != MMC_TIMING_MMC_HS200)
+		return sdhci_execute_tuning(mmc, opcode);
+
+	if (WARN_ON(opcode != MMC_SEND_TUNING_BLOCK_HS200))
+		return -EINVAL;
+
+	/*
+	 * o2 sdhci host didn't support 8bit emmc tuning
+	 */
+	if (mmc->ios.bus_width == MMC_BUS_WIDTH_8) {
+		current_bus_width = mmc->ios.bus_width;
+		sdhci_set_bus_width(host, MMC_BUS_WIDTH_4);
+	}
+
+	sdhci_o2_set_tuning_mode(host);
+
+	sdhci_start_tuning(host);
+
+	__sdhci_o2_execute_tuning(host, opcode);
+
+	sdhci_end_tuning(host);
+
+	if (current_bus_width == MMC_BUS_WIDTH_8)
+		sdhci_set_bus_width(host, current_bus_width);
+
+	host->flags &= ~SDHCI_HS400_TUNING;
+	return 0;
+}
 
 static void o2_pci_set_baseclk(struct sdhci_pci_chip *chip, u32 value)
 {
@@ -215,6 +294,8 @@ int sdhci_pci_o2_probe_slot(struct sdhci_pci_slot *slot)
 			}
 		}
 
+		host->mmc_host_ops.execute_tuning = sdhci_o2_execute_tuning;
+
 		if (chip->pdev->device != PCI_DEVICE_ID_O2_FUJIN2)
 			break;
 		/* set dll watch dog timer */
diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
index bcea179a8d70..1b3fbd9bd5c5 100644
--- a/drivers/mmc/host/sdhci.c
+++ b/drivers/mmc/host/sdhci.c
@@ -1029,7 +1029,9 @@ static void sdhci_set_transfer_mode(struct sdhci_host *host,
 	if (data == NULL) {
 		if (host->quirks2 &
 			SDHCI_QUIRK2_CLEAR_TRANSFERMODE_REG_BEFORE_CMD) {
-			sdhci_writew(host, 0x0, SDHCI_TRANSFER_MODE);
+			/* must not clear SDHCI_TRANSFER_MODE when tuning */
+			if (cmd->opcode != MMC_SEND_TUNING_BLOCK_HS200)
+				sdhci_writew(host, 0x0, SDHCI_TRANSFER_MODE);
 		} else {
 		/* clear Auto CMD settings for no data CMDs */
 			mode = sdhci_readw(host, SDHCI_TRANSFER_MODE);
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH V7 5/5] mmc: sdhci: Add MSI interrupt support for O2 SD host
  2018-07-16  6:26 [PATCH V7 1/5] mmc: sdhci: Add support for O2 eMMC HS200 mode ernest.zhang
                   ` (2 preceding siblings ...)
  2018-07-16  6:26 ` [PATCH V7 4/5] mmc: sdhci: Add support for O2 hardware tuning ernest.zhang
@ 2018-07-16  6:26 ` ernest.zhang
  2018-07-25  7:48   ` Adrian Hunter
  2018-07-25  7:44 ` [PATCH V7 1/5] mmc: sdhci: Add support for O2 eMMC HS200 mode Adrian Hunter
  2018-07-30 15:05 ` Ulf Hansson
  5 siblings, 1 reply; 13+ messages in thread
From: ernest.zhang @ 2018-07-16  6:26 UTC (permalink / raw)
  To: Adrian Hunter, Ulf Hansson, linux-mmc, linux-kernel
  Cc: ernest.zhang, chuanjin.pang, mike.li, chevron.li, shirley.her,
	xiaoguang.yu, bobby.wu

Add MSI interrupt support if the SD host device can support MSI interrupt.

Signed-off-by: ernest.zhang <ernest.zhang@bayhubtech.com>
---
Changes in V7:
	N/A

Changes in V6:
	1. Move change log to correct place.
	2. Reduce unneeded pr_info prints.
	3. In function sdhci_pci_o2_probe_slot, remove using local
	variable 'mmc' instead of using 'host->mmc'.
	4. Make the msi enable code a sperate function.

Changes in V5:
	1. Because pci_enable_msi is marked as deprecated and should not be
	used in new code, use pci_alloc_irq_vectors instead.
	2. Remove unneeded CONFIG_PCI_MSI macro check.

Changes in V4:
	Enable MSI interrupt if the MSI capability bit is set in
	capability register.

Changes in V1~V3:
	N/A
---
 drivers/mmc/host/sdhci-pci-o2micro.c | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/drivers/mmc/host/sdhci-pci-o2micro.c b/drivers/mmc/host/sdhci-pci-o2micro.c
index 7747e8ba2e3d..56bc71763956 100644
--- a/drivers/mmc/host/sdhci-pci-o2micro.c
+++ b/drivers/mmc/host/sdhci-pci-o2micro.c
@@ -260,6 +260,29 @@ static void sdhci_pci_o2_fujin2_pci_init(struct sdhci_pci_chip *chip)
 	pci_write_config_dword(chip->pdev, O2_SD_MISC_CTRL4, scratch_32);
 }
 
+static void sdhci_pci_o2_enable_msi(struct sdhci_pci_chip *chip,
+				    struct sdhci_host *host)
+{
+	int ret;
+
+	ret = pci_find_capability(chip->pdev, PCI_CAP_ID_MSI);
+	if (!ret) {
+		pr_info("%s: unsupport msi, use INTx irq\n",
+			mmc_hostname(host->mmc));
+		return;
+	}
+
+	ret = pci_alloc_irq_vectors(chip->pdev, 1, 1,
+				    PCI_IRQ_MSI | PCI_IRQ_MSIX);
+	if (ret < 0) {
+		pr_err("%s: enable PCI MSI failed, err=%d\n",
+		       mmc_hostname(host->mmc), ret);
+		return;
+	}
+
+	host->irq = pci_irq_vector(chip->pdev, 0);
+}
+
 int sdhci_pci_o2_probe_slot(struct sdhci_pci_slot *slot)
 {
 	struct sdhci_pci_chip *chip;
@@ -279,6 +302,8 @@ int sdhci_pci_o2_probe_slot(struct sdhci_pci_slot *slot)
 		if (reg & 0x1)
 			host->quirks |= SDHCI_QUIRK_MULTIBLOCK_READ_ACMD12;
 
+		sdhci_pci_o2_enable_msi(chip, host);
+
 		if (chip->pdev->device == PCI_DEVICE_ID_O2_SEABIRD0) {
 			ret = pci_read_config_dword(chip->pdev,
 						    O2_SD_MISC_SETTING, &reg);
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* Re: [PATCH V7 1/5] mmc: sdhci: Add support for O2 eMMC HS200 mode
  2018-07-16  6:26 [PATCH V7 1/5] mmc: sdhci: Add support for O2 eMMC HS200 mode ernest.zhang
                   ` (3 preceding siblings ...)
  2018-07-16  6:26 ` [PATCH V7 5/5] mmc: sdhci: Add MSI interrupt support for O2 SD host ernest.zhang
@ 2018-07-25  7:44 ` Adrian Hunter
  2018-07-30 15:05 ` Ulf Hansson
  5 siblings, 0 replies; 13+ messages in thread
From: Adrian Hunter @ 2018-07-25  7:44 UTC (permalink / raw)
  To: ernest.zhang, Ulf Hansson, linux-mmc, linux-kernel
  Cc: chuanjin.pang, mike.li, chevron.li, shirley.her, xiaoguang.yu, bobby.wu

On 16/07/18 09:26, ernest.zhang wrote:
> When use eMMC as boot device, the eMMC signaling voltage is tied to 1.8v
> fixed output voltage, bios can set o2 sd host controller PCI configuration
> register 0x308 bit4 to 1 to let driver skip 3.3v signaling voltage and
> direct use 1.8v singling voltage in eMMC initialize process.
> 
> Signed-off-by: ernest.zhang <ernest.zhang@bayhubtech.com>

Acked-by: Adrian Hunter <adrian.hunter@intel.com>

> ---
> Changes in V7:
> 	Move V6 change item 2 to a seperate patch file
> 
> Changes in V6:
> 	1.Move change log to correct place.
> 	2.Change HS200 mode clock frequency from 208MHz to 200MHz to meet
> 	Specification.
> 
> Changes in V5:
> 	Modify code format to pass checkpatch.pl check and add a summary
> 	of what has changed in each version.
> 
> Changes in V4:
> 	Skip SDIO and SD initalization when register 0x308 bit 4 is set,
> 	and modify some typo.
> 
> Changes in V3:
> 	Rebase the patch on the mmc tree 'next' branch.
> 
> Changes in V2:
> 	Modify code format, and delete unused code path.
> 
> Changes in V1:
> 	Check PCIe register 0x308 bit 4 and skip eMMC 3.3v initialization
> 	process if it is set to 1.
> ---
>  drivers/mmc/host/sdhci-pci-o2micro.c | 18 ++++++++++++++++++
>  1 file changed, 18 insertions(+)
> 
> diff --git a/drivers/mmc/host/sdhci-pci-o2micro.c b/drivers/mmc/host/sdhci-pci-o2micro.c
> index 555970a29c94..ba59db6a126c 100644
> --- a/drivers/mmc/host/sdhci-pci-o2micro.c
> +++ b/drivers/mmc/host/sdhci-pci-o2micro.c
> @@ -3,6 +3,7 @@
>   *
>   * Authors: Peter Guo <peter.guo@bayhubtech.com>
>   *          Adam Lee <adam.lee@canonical.com>
> + *          Ernest Zhang <ernest.zhang@bayhubtech.com>
>   *
>   * This software is licensed under the terms of the GNU General Public
>   * License version 2, as published by the Free Software Foundation, and
> @@ -39,6 +40,7 @@
>  #define O2_SD_MISC_CTRL4	0xFC
>  #define O2_SD_TUNING_CTRL	0x300
>  #define O2_SD_PLL_SETTING	0x304
> +#define O2_SD_MISC_SETTING	0x308
>  #define O2_SD_CLK_SETTING	0x328
>  #define O2_SD_CAP_REG2		0x330
>  #define O2_SD_CAP_REG0		0x334
> @@ -184,6 +186,7 @@ int sdhci_pci_o2_probe_slot(struct sdhci_pci_slot *slot)
>  	struct sdhci_pci_chip *chip;
>  	struct sdhci_host *host;
>  	u32 reg;
> +	int ret;
>  
>  	chip = slot->chip;
>  	host = slot->host;
> @@ -197,6 +200,21 @@ int sdhci_pci_o2_probe_slot(struct sdhci_pci_slot *slot)
>  		if (reg & 0x1)
>  			host->quirks |= SDHCI_QUIRK_MULTIBLOCK_READ_ACMD12;
>  
> +		if (chip->pdev->device == PCI_DEVICE_ID_O2_SEABIRD0) {
> +			ret = pci_read_config_dword(chip->pdev,
> +						    O2_SD_MISC_SETTING, &reg);
> +			if (ret)
> +				return -EIO;
> +			if (reg & (1 << 4)) {
> +				pr_info("%s: emmc 1.8v flag is set, force 1.8v signaling voltage\n",
> +					mmc_hostname(host->mmc));
> +				host->flags &= ~SDHCI_SIGNALING_330;
> +				host->flags |= SDHCI_SIGNALING_180;
> +				host->mmc->caps2 |= MMC_CAP2_NO_SD;
> +				host->mmc->caps2 |= MMC_CAP2_NO_SDIO;
> +			}
> +		}
> +
>  		if (chip->pdev->device != PCI_DEVICE_ID_O2_FUJIN2)
>  			break;
>  		/* set dll watch dog timer */
> 


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH V7 2/5] mmc: sdhci: Change O2 Host HS200 mode clock frequency to 200MHz
  2018-07-16  6:26 ` [PATCH V7 2/5] mmc: sdhci: Change O2 Host HS200 mode clock frequency to 200MHz ernest.zhang
@ 2018-07-25  7:45   ` Adrian Hunter
  2018-07-27  6:49     ` Ernest Zhang(WH)
  0 siblings, 1 reply; 13+ messages in thread
From: Adrian Hunter @ 2018-07-25  7:45 UTC (permalink / raw)
  To: ernest.zhang, Ulf Hansson, linux-mmc, linux-kernel
  Cc: chuanjin.pang, mike.li, chevron.li, shirley.her, xiaoguang.yu, bobby.wu

On 16/07/18 09:26, ernest.zhang wrote:
> O2 SD Host HS200 mode clock frequency current is 208MHz, should be changed
> to 200MHz to meet specification.
> 
> Signed-off-by: ernest.zhang <ernest.zhang@bayhubtech.com>

You left in the misleading comment.  Fix that and add:

Acked-by: Adrian Hunter <adrian.hunter@intel.com>

> ---
> Change in V7:
> 	Change HS200 mode clock frequency from 208MHz to 200MHz to meet
> 	Specification.
> 
> Change in V1~V6:
> 	N/A
> ---
>  drivers/mmc/host/sdhci-pci-o2micro.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/mmc/host/sdhci-pci-o2micro.c b/drivers/mmc/host/sdhci-pci-o2micro.c
> index ba59db6a126c..94cf3cd75dd3 100644
> --- a/drivers/mmc/host/sdhci-pci-o2micro.c
> +++ b/drivers/mmc/host/sdhci-pci-o2micro.c
> @@ -311,7 +311,7 @@ int sdhci_pci_o2_probe(struct sdhci_pci_chip *chip)
>  
>  			/* Check Whether subId is 0x11 or 0x12 */
>  			if ((scratch_32 == 0x11) || (scratch_32 == 0x12)) {
> -				scratch_32 = 0x2c280000;
> +				scratch_32 = 0x25100000;
>  
>  				/* Set Base Clock to 208MZ */

That comment is misleading now.

>  				o2_pci_set_baseclk(chip, scratch_32);
> @@ -406,7 +406,7 @@ int sdhci_pci_o2_probe(struct sdhci_pci_chip *chip)
>  					       O2_SD_PLL_SETTING, scratch_32);
>  		} else {
>  			scratch_32 &= 0x0000FFFF;
> -			scratch_32 |= 0x2c280000;
> +			scratch_32 |= 0x25100000;
>  
>  			pci_write_config_dword(chip->pdev,
>  					       O2_SD_PLL_SETTING, scratch_32);
> 


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH V7 3/5] mmc: sdhci: Export sdhci tuning function symbol
  2018-07-16  6:26 ` [PATCH V7 3/5] mmc: sdhci: Export sdhci tuning function symbol ernest.zhang
@ 2018-07-25  7:46   ` Adrian Hunter
  0 siblings, 0 replies; 13+ messages in thread
From: Adrian Hunter @ 2018-07-25  7:46 UTC (permalink / raw)
  To: ernest.zhang, Ulf Hansson, linux-mmc, linux-kernel
  Cc: chuanjin.pang, mike.li, chevron.li, shirley.her, xiaoguang.yu, bobby.wu

On 16/07/18 09:26, ernest.zhang wrote:
> Export sdhci tuning function symbols which are used by other SD Host
> controller driver modules.
> 
> Signed-off-by: ernest.zhang <ernest.zhang@bayhubtech.com>

Acked-by: Adrian Hunter <adrian.hunter@intel.com>

> ---
> Changes in V7:
> 	Export sdhci tuning function symbols
> 
> Changes in V1~V6
> 	N/A
> ---
>  drivers/mmc/host/sdhci.c | 12 ++++++++----
>  drivers/mmc/host/sdhci.h |  5 +++++
>  2 files changed, 13 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
> index a7b5602ef6f7..bcea179a8d70 100644
> --- a/drivers/mmc/host/sdhci.c
> +++ b/drivers/mmc/host/sdhci.c
> @@ -2103,7 +2103,7 @@ static int sdhci_prepare_hs400_tuning(struct mmc_host *mmc, struct mmc_ios *ios)
>  	return 0;
>  }
>  
> -static void sdhci_start_tuning(struct sdhci_host *host)
> +void sdhci_start_tuning(struct sdhci_host *host)
>  {
>  	u16 ctrl;
>  
> @@ -2126,14 +2126,16 @@ static void sdhci_start_tuning(struct sdhci_host *host)
>  	sdhci_writel(host, SDHCI_INT_DATA_AVAIL, SDHCI_INT_ENABLE);
>  	sdhci_writel(host, SDHCI_INT_DATA_AVAIL, SDHCI_SIGNAL_ENABLE);
>  }
> +EXPORT_SYMBOL_GPL(sdhci_start_tuning);
>  
> -static void sdhci_end_tuning(struct sdhci_host *host)
> +void sdhci_end_tuning(struct sdhci_host *host)
>  {
>  	sdhci_writel(host, host->ier, SDHCI_INT_ENABLE);
>  	sdhci_writel(host, host->ier, SDHCI_SIGNAL_ENABLE);
>  }
> +EXPORT_SYMBOL_GPL(sdhci_end_tuning);
>  
> -static void sdhci_reset_tuning(struct sdhci_host *host)
> +void sdhci_reset_tuning(struct sdhci_host *host)
>  {
>  	u16 ctrl;
>  
> @@ -2142,6 +2144,7 @@ static void sdhci_reset_tuning(struct sdhci_host *host)
>  	ctrl &= ~SDHCI_CTRL_EXEC_TUNING;
>  	sdhci_writew(host, ctrl, SDHCI_HOST_CONTROL2);
>  }
> +EXPORT_SYMBOL_GPL(sdhci_reset_tuning);
>  
>  static void sdhci_abort_tuning(struct sdhci_host *host, u32 opcode)
>  {
> @@ -2162,7 +2165,7 @@ static void sdhci_abort_tuning(struct sdhci_host *host, u32 opcode)
>   * interrupt setup is different to other commands and there is no timeout
>   * interrupt so special handling is needed.
>   */
> -static void sdhci_send_tuning(struct sdhci_host *host, u32 opcode)
> +void sdhci_send_tuning(struct sdhci_host *host, u32 opcode)
>  {
>  	struct mmc_host *mmc = host->mmc;
>  	struct mmc_command cmd = {};
> @@ -2212,6 +2215,7 @@ static void sdhci_send_tuning(struct sdhci_host *host, u32 opcode)
>  			   msecs_to_jiffies(50));
>  
>  }
> +EXPORT_SYMBOL_GPL(sdhci_send_tuning);
>  
>  static void __sdhci_execute_tuning(struct sdhci_host *host, u32 opcode)
>  {
> diff --git a/drivers/mmc/host/sdhci.h b/drivers/mmc/host/sdhci.h
> index 23966f887da6..f0bd36ce3817 100644
> --- a/drivers/mmc/host/sdhci.h
> +++ b/drivers/mmc/host/sdhci.h
> @@ -748,4 +748,9 @@ bool sdhci_cqe_irq(struct sdhci_host *host, u32 intmask, int *cmd_error,
>  
>  void sdhci_dumpregs(struct sdhci_host *host);
>  
> +void sdhci_start_tuning(struct sdhci_host *host);
> +void sdhci_end_tuning(struct sdhci_host *host);
> +void sdhci_reset_tuning(struct sdhci_host *host);
> +void sdhci_send_tuning(struct sdhci_host *host, u32 opcode);
> +
>  #endif /* __SDHCI_HW_H */
> 


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH V7 4/5] mmc: sdhci: Add support for O2 hardware tuning
  2018-07-16  6:26 ` [PATCH V7 4/5] mmc: sdhci: Add support for O2 hardware tuning ernest.zhang
@ 2018-07-25  7:48   ` Adrian Hunter
  0 siblings, 0 replies; 13+ messages in thread
From: Adrian Hunter @ 2018-07-25  7:48 UTC (permalink / raw)
  To: ernest.zhang, Ulf Hansson, linux-mmc, linux-kernel
  Cc: chuanjin.pang, mike.li, chevron.li, shirley.her, xiaoguang.yu, bobby.wu

On 16/07/18 09:26, ernest.zhang wrote:
> Add hardware tuning function instead of software tuning because O2/Bayhub
> SD host controller support hardware tuning.
> 
> Signed-off-by: ernest.zhang <ernest.zhang@bayhubtech.com>

Acked-by: Adrian Hunter <adrian.hunter@intel.com>


> ---
> Changes in V7:
> 	Move V6 change item 1 to a seperate patch.
> 
> Changes in V6:
> 	1. From module 'sdhci' export the symbols 'sdhci_start_tuning',
> 	'sdhci_end_tuning','sdhci_send_tuning' and 'sdhci_reset_tuning'.
> 	2. Remove local tuning related functions in sdhci-pci-o2-micro.c
> 	instead of above function exported in sdhci module.
> 	3. Remove unneeded braces in function sdhci_set_transfer_mode.
> 	4. Move change log to correct place.
> 
> Changes in V5:
> 	In function sdhci_o2_send_tuning, mrq.data should set to NULL for
> 	cmd.data has been set to NULL.
> 
> Changes in V4:
> 	Patch V3 delete register SDHCI_TRANSFER_MODE write operation before
> 	send hardware tuning command in function sdhci_o2_send_tuning. This
> 	is a mistake. The write operation is essential for tuning command.
> 	Add it back.
> 
> Changes in V3:
> 	Rebase the patch on the mmc tree 'next' branch.
> 
> Changes in V2:
> 	Modify code format, and delete unused code path.
> 
> Changes in V1:
> 	Add many functions to execute hardware tuning for eMMC 1.8V HS200
> 	mode, the hardware tuning procedure is based on O2/Bayhub hardware
> 	tuning spec.
> ---
>  drivers/mmc/host/sdhci-pci-o2micro.c | 81 ++++++++++++++++++++++++++++
>  drivers/mmc/host/sdhci.c             |  4 +-
>  2 files changed, 84 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/mmc/host/sdhci-pci-o2micro.c b/drivers/mmc/host/sdhci-pci-o2micro.c
> index 94cf3cd75dd3..7747e8ba2e3d 100644
> --- a/drivers/mmc/host/sdhci-pci-o2micro.c
> +++ b/drivers/mmc/host/sdhci-pci-o2micro.c
> @@ -17,6 +17,9 @@
>   */
>  
>  #include <linux/pci.h>
> +#include <linux/mmc/host.h>
> +#include <linux/mmc/mmc.h>
> +#include <linux/delay.h>
>  
>  #include "sdhci.h"
>  #include "sdhci-pci.h"
> @@ -55,6 +58,82 @@
>  
>  #define O2_SD_VENDOR_SETTING	0x110
>  #define O2_SD_VENDOR_SETTING2	0x1C8
> +#define O2_SD_HW_TUNING_DISABLE	BIT(4)
> +
> +static void sdhci_o2_set_tuning_mode(struct sdhci_host *host)
> +{
> +	u16 reg;
> +
> +	/* enable hardware tuning */
> +	reg = sdhci_readw(host, O2_SD_VENDOR_SETTING);
> +	reg &= ~O2_SD_HW_TUNING_DISABLE;
> +	sdhci_writew(host, reg, O2_SD_VENDOR_SETTING);
> +}
> +
> +static void __sdhci_o2_execute_tuning(struct sdhci_host *host, u32 opcode)
> +{
> +	int i;
> +
> +	sdhci_send_tuning(host, MMC_SEND_TUNING_BLOCK_HS200);
> +
> +	for (i = 0; i < 150; i++) {
> +		u16 ctrl = sdhci_readw(host, SDHCI_HOST_CONTROL2);
> +
> +		if (!(ctrl & SDHCI_CTRL_EXEC_TUNING)) {
> +			if (ctrl & SDHCI_CTRL_TUNED_CLK) {
> +				host->tuning_done = true;
> +				return;
> +			}
> +			pr_warn("%s: HW tuning failed !\n",
> +				mmc_hostname(host->mmc));
> +			break;
> +		}
> +
> +		mdelay(1);
> +	}
> +
> +	pr_info("%s: Tuning failed, falling back to fixed sampling clock\n",
> +		mmc_hostname(host->mmc));
> +	sdhci_reset_tuning(host);
> +}
> +
> +static int sdhci_o2_execute_tuning(struct mmc_host *mmc, u32 opcode)
> +{
> +	struct sdhci_host *host = mmc_priv(mmc);
> +	int current_bus_width = 0;
> +
> +	/*
> +	 * This handler only implements the eMMC tuning that is specific to
> +	 * this controller.  Fall back to the standard method for other TIMING.
> +	 */
> +	if (host->timing != MMC_TIMING_MMC_HS200)
> +		return sdhci_execute_tuning(mmc, opcode);
> +
> +	if (WARN_ON(opcode != MMC_SEND_TUNING_BLOCK_HS200))
> +		return -EINVAL;
> +
> +	/*
> +	 * o2 sdhci host didn't support 8bit emmc tuning
> +	 */
> +	if (mmc->ios.bus_width == MMC_BUS_WIDTH_8) {
> +		current_bus_width = mmc->ios.bus_width;
> +		sdhci_set_bus_width(host, MMC_BUS_WIDTH_4);
> +	}
> +
> +	sdhci_o2_set_tuning_mode(host);
> +
> +	sdhci_start_tuning(host);
> +
> +	__sdhci_o2_execute_tuning(host, opcode);
> +
> +	sdhci_end_tuning(host);
> +
> +	if (current_bus_width == MMC_BUS_WIDTH_8)
> +		sdhci_set_bus_width(host, current_bus_width);
> +
> +	host->flags &= ~SDHCI_HS400_TUNING;
> +	return 0;
> +}
>  
>  static void o2_pci_set_baseclk(struct sdhci_pci_chip *chip, u32 value)
>  {
> @@ -215,6 +294,8 @@ int sdhci_pci_o2_probe_slot(struct sdhci_pci_slot *slot)
>  			}
>  		}
>  
> +		host->mmc_host_ops.execute_tuning = sdhci_o2_execute_tuning;
> +
>  		if (chip->pdev->device != PCI_DEVICE_ID_O2_FUJIN2)
>  			break;
>  		/* set dll watch dog timer */
> diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
> index bcea179a8d70..1b3fbd9bd5c5 100644
> --- a/drivers/mmc/host/sdhci.c
> +++ b/drivers/mmc/host/sdhci.c
> @@ -1029,7 +1029,9 @@ static void sdhci_set_transfer_mode(struct sdhci_host *host,
>  	if (data == NULL) {
>  		if (host->quirks2 &
>  			SDHCI_QUIRK2_CLEAR_TRANSFERMODE_REG_BEFORE_CMD) {
> -			sdhci_writew(host, 0x0, SDHCI_TRANSFER_MODE);
> +			/* must not clear SDHCI_TRANSFER_MODE when tuning */
> +			if (cmd->opcode != MMC_SEND_TUNING_BLOCK_HS200)
> +				sdhci_writew(host, 0x0, SDHCI_TRANSFER_MODE);
>  		} else {
>  		/* clear Auto CMD settings for no data CMDs */
>  			mode = sdhci_readw(host, SDHCI_TRANSFER_MODE);
> 


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH V7 5/5] mmc: sdhci: Add MSI interrupt support for O2 SD host
  2018-07-16  6:26 ` [PATCH V7 5/5] mmc: sdhci: Add MSI interrupt support for O2 SD host ernest.zhang
@ 2018-07-25  7:48   ` Adrian Hunter
  0 siblings, 0 replies; 13+ messages in thread
From: Adrian Hunter @ 2018-07-25  7:48 UTC (permalink / raw)
  To: ernest.zhang, Ulf Hansson, linux-mmc, linux-kernel
  Cc: chuanjin.pang, mike.li, chevron.li, shirley.her, xiaoguang.yu, bobby.wu

On 16/07/18 09:26, ernest.zhang wrote:
> Add MSI interrupt support if the SD host device can support MSI interrupt.
> 
> Signed-off-by: ernest.zhang <ernest.zhang@bayhubtech.com>

Acked-by: Adrian Hunter <adrian.hunter@intel.com>

> ---
> Changes in V7:
> 	N/A
> 
> Changes in V6:
> 	1. Move change log to correct place.
> 	2. Reduce unneeded pr_info prints.
> 	3. In function sdhci_pci_o2_probe_slot, remove using local
> 	variable 'mmc' instead of using 'host->mmc'.
> 	4. Make the msi enable code a sperate function.
> 
> Changes in V5:
> 	1. Because pci_enable_msi is marked as deprecated and should not be
> 	used in new code, use pci_alloc_irq_vectors instead.
> 	2. Remove unneeded CONFIG_PCI_MSI macro check.
> 
> Changes in V4:
> 	Enable MSI interrupt if the MSI capability bit is set in
> 	capability register.
> 
> Changes in V1~V3:
> 	N/A
> ---
>  drivers/mmc/host/sdhci-pci-o2micro.c | 25 +++++++++++++++++++++++++
>  1 file changed, 25 insertions(+)
> 
> diff --git a/drivers/mmc/host/sdhci-pci-o2micro.c b/drivers/mmc/host/sdhci-pci-o2micro.c
> index 7747e8ba2e3d..56bc71763956 100644
> --- a/drivers/mmc/host/sdhci-pci-o2micro.c
> +++ b/drivers/mmc/host/sdhci-pci-o2micro.c
> @@ -260,6 +260,29 @@ static void sdhci_pci_o2_fujin2_pci_init(struct sdhci_pci_chip *chip)
>  	pci_write_config_dword(chip->pdev, O2_SD_MISC_CTRL4, scratch_32);
>  }
>  
> +static void sdhci_pci_o2_enable_msi(struct sdhci_pci_chip *chip,
> +				    struct sdhci_host *host)
> +{
> +	int ret;
> +
> +	ret = pci_find_capability(chip->pdev, PCI_CAP_ID_MSI);
> +	if (!ret) {
> +		pr_info("%s: unsupport msi, use INTx irq\n",
> +			mmc_hostname(host->mmc));
> +		return;
> +	}
> +
> +	ret = pci_alloc_irq_vectors(chip->pdev, 1, 1,
> +				    PCI_IRQ_MSI | PCI_IRQ_MSIX);
> +	if (ret < 0) {
> +		pr_err("%s: enable PCI MSI failed, err=%d\n",
> +		       mmc_hostname(host->mmc), ret);
> +		return;
> +	}
> +
> +	host->irq = pci_irq_vector(chip->pdev, 0);
> +}
> +
>  int sdhci_pci_o2_probe_slot(struct sdhci_pci_slot *slot)
>  {
>  	struct sdhci_pci_chip *chip;
> @@ -279,6 +302,8 @@ int sdhci_pci_o2_probe_slot(struct sdhci_pci_slot *slot)
>  		if (reg & 0x1)
>  			host->quirks |= SDHCI_QUIRK_MULTIBLOCK_READ_ACMD12;
>  
> +		sdhci_pci_o2_enable_msi(chip, host);
> +
>  		if (chip->pdev->device == PCI_DEVICE_ID_O2_SEABIRD0) {
>  			ret = pci_read_config_dword(chip->pdev,
>  						    O2_SD_MISC_SETTING, &reg);
> 


^ permalink raw reply	[flat|nested] 13+ messages in thread

* RE: [PATCH V7 2/5] mmc: sdhci: Change O2 Host HS200 mode clock frequency to 200MHz
  2018-07-25  7:45   ` Adrian Hunter
@ 2018-07-27  6:49     ` Ernest Zhang(WH)
  2018-07-27  6:58       ` Adrian Hunter
  0 siblings, 1 reply; 13+ messages in thread
From: Ernest Zhang(WH) @ 2018-07-27  6:49 UTC (permalink / raw)
  To: Adrian Hunter, Ulf Hansson, linux-mmc, linux-kernel
  Cc: Chuanjin Pang (WH), Mike Li (WH), Chevron Li (WH),
	Shirley Her (SC), Xiaoguang Yu (WH), Bobby Wu (WH)

Hi Adrian,
	Do I need re-submit all 5 patches after fix that and change the version to v8?
BR

-----Original Message-----
From: Adrian Hunter [mailto:adrian.hunter@intel.com] 
Sent: 2018年7月25日 15:45
To: Ernest Zhang(WH); Ulf Hansson; linux-mmc@vger.kernel.org; linux-kernel@vger.kernel.org
Cc: Chuanjin Pang (WH); Mike Li (WH); Chevron Li (WH); Shirley Her (SC); Xiaoguang Yu (WH); Bobby Wu (WH)
Subject: Re: [PATCH V7 2/5] mmc: sdhci: Change O2 Host HS200 mode clock frequency to 200MHz

On 16/07/18 09:26, ernest.zhang wrote:
> O2 SD Host HS200 mode clock frequency current is 208MHz, should be 
> changed to 200MHz to meet specification.
> 
> Signed-off-by: ernest.zhang <ernest.zhang@bayhubtech.com>

You left in the misleading comment.  Fix that and add:

Acked-by: Adrian Hunter <adrian.hunter@intel.com>

> ---
> Change in V7:
> 	Change HS200 mode clock frequency from 208MHz to 200MHz to meet
> 	Specification.
> 
> Change in V1~V6:
> 	N/A
> ---
>  drivers/mmc/host/sdhci-pci-o2micro.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/mmc/host/sdhci-pci-o2micro.c 
> b/drivers/mmc/host/sdhci-pci-o2micro.c
> index ba59db6a126c..94cf3cd75dd3 100644
> --- a/drivers/mmc/host/sdhci-pci-o2micro.c
> +++ b/drivers/mmc/host/sdhci-pci-o2micro.c
> @@ -311,7 +311,7 @@ int sdhci_pci_o2_probe(struct sdhci_pci_chip 
> *chip)
>  
>  			/* Check Whether subId is 0x11 or 0x12 */
>  			if ((scratch_32 == 0x11) || (scratch_32 == 0x12)) {
> -				scratch_32 = 0x2c280000;
> +				scratch_32 = 0x25100000;
>  
>  				/* Set Base Clock to 208MZ */

That comment is misleading now.

>  				o2_pci_set_baseclk(chip, scratch_32); @@ -406,7 +406,7 @@ int 
> sdhci_pci_o2_probe(struct sdhci_pci_chip *chip)
>  					       O2_SD_PLL_SETTING, scratch_32);
>  		} else {
>  			scratch_32 &= 0x0000FFFF;
> -			scratch_32 |= 0x2c280000;
> +			scratch_32 |= 0x25100000;
>  
>  			pci_write_config_dword(chip->pdev,
>  					       O2_SD_PLL_SETTING, scratch_32);
> 


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH V7 2/5] mmc: sdhci: Change O2 Host HS200 mode clock frequency to 200MHz
  2018-07-27  6:49     ` Ernest Zhang(WH)
@ 2018-07-27  6:58       ` Adrian Hunter
  0 siblings, 0 replies; 13+ messages in thread
From: Adrian Hunter @ 2018-07-27  6:58 UTC (permalink / raw)
  To: Ernest Zhang(WH), Ulf Hansson, linux-mmc, linux-kernel
  Cc: Chuanjin Pang (WH), Mike Li (WH), Chevron Li (WH),
	Shirley Her (SC), Xiaoguang Yu (WH), Bobby Wu (WH)

On 27/07/18 09:49, Ernest Zhang(WH) wrote:
> Hi Adrian,
> 	Do I need re-submit all 5 patches after fix that and change the version to v8?

You can reply to this email with PATCH V8 2/5 that has my Ack and the
comment fixed.

> BR
> 
> -----Original Message-----
> From: Adrian Hunter [mailto:adrian.hunter@intel.com] 
> Sent: 2018年7月25日 15:45
> To: Ernest Zhang(WH); Ulf Hansson; linux-mmc@vger.kernel.org; linux-kernel@vger.kernel.org
> Cc: Chuanjin Pang (WH); Mike Li (WH); Chevron Li (WH); Shirley Her (SC); Xiaoguang Yu (WH); Bobby Wu (WH)
> Subject: Re: [PATCH V7 2/5] mmc: sdhci: Change O2 Host HS200 mode clock frequency to 200MHz
> 
> On 16/07/18 09:26, ernest.zhang wrote:
>> O2 SD Host HS200 mode clock frequency current is 208MHz, should be 
>> changed to 200MHz to meet specification.
>>
>> Signed-off-by: ernest.zhang <ernest.zhang@bayhubtech.com>
> 
> You left in the misleading comment.  Fix that and add:
> 
> Acked-by: Adrian Hunter <adrian.hunter@intel.com>
> 
>> ---
>> Change in V7:
>> 	Change HS200 mode clock frequency from 208MHz to 200MHz to meet
>> 	Specification.
>>
>> Change in V1~V6:
>> 	N/A
>> ---
>>  drivers/mmc/host/sdhci-pci-o2micro.c | 4 ++--
>>  1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/mmc/host/sdhci-pci-o2micro.c 
>> b/drivers/mmc/host/sdhci-pci-o2micro.c
>> index ba59db6a126c..94cf3cd75dd3 100644
>> --- a/drivers/mmc/host/sdhci-pci-o2micro.c
>> +++ b/drivers/mmc/host/sdhci-pci-o2micro.c
>> @@ -311,7 +311,7 @@ int sdhci_pci_o2_probe(struct sdhci_pci_chip 
>> *chip)
>>  
>>  			/* Check Whether subId is 0x11 or 0x12 */
>>  			if ((scratch_32 == 0x11) || (scratch_32 == 0x12)) {
>> -				scratch_32 = 0x2c280000;
>> +				scratch_32 = 0x25100000;
>>  
>>  				/* Set Base Clock to 208MZ */
> 
> That comment is misleading now.
> 
>>  				o2_pci_set_baseclk(chip, scratch_32); @@ -406,7 +406,7 @@ int 
>> sdhci_pci_o2_probe(struct sdhci_pci_chip *chip)
>>  					       O2_SD_PLL_SETTING, scratch_32);
>>  		} else {
>>  			scratch_32 &= 0x0000FFFF;
>> -			scratch_32 |= 0x2c280000;
>> +			scratch_32 |= 0x25100000;
>>  
>>  			pci_write_config_dword(chip->pdev,
>>  					       O2_SD_PLL_SETTING, scratch_32);
>>
> 


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH V7 1/5] mmc: sdhci: Add support for O2 eMMC HS200 mode
  2018-07-16  6:26 [PATCH V7 1/5] mmc: sdhci: Add support for O2 eMMC HS200 mode ernest.zhang
                   ` (4 preceding siblings ...)
  2018-07-25  7:44 ` [PATCH V7 1/5] mmc: sdhci: Add support for O2 eMMC HS200 mode Adrian Hunter
@ 2018-07-30 15:05 ` Ulf Hansson
  5 siblings, 0 replies; 13+ messages in thread
From: Ulf Hansson @ 2018-07-30 15:05 UTC (permalink / raw)
  To: ernest.zhang
  Cc: Adrian Hunter, linux-mmc, Linux Kernel Mailing List,
	chuanjin.pang, mike.li, chevron.li, Shirley Her (SC),
	xiaoguang.yu, bobby.wu

On 16 July 2018 at 08:26, ernest.zhang <ernest.zhang@bayhubtech.com> wrote:
> When use eMMC as boot device, the eMMC signaling voltage is tied to 1.8v
> fixed output voltage, bios can set o2 sd host controller PCI configuration
> register 0x308 bit4 to 1 to let driver skip 3.3v signaling voltage and
> direct use 1.8v singling voltage in eMMC initialize process.
>
> Signed-off-by: ernest.zhang <ernest.zhang@bayhubtech.com>

Thanks, the series applied for next!

Kind regards
Uffe

> ---
> Changes in V7:
>         Move V6 change item 2 to a seperate patch file
>
> Changes in V6:
>         1.Move change log to correct place.
>         2.Change HS200 mode clock frequency from 208MHz to 200MHz to meet
>         Specification.
>
> Changes in V5:
>         Modify code format to pass checkpatch.pl check and add a summary
>         of what has changed in each version.
>
> Changes in V4:
>         Skip SDIO and SD initalization when register 0x308 bit 4 is set,
>         and modify some typo.
>
> Changes in V3:
>         Rebase the patch on the mmc tree 'next' branch.
>
> Changes in V2:
>         Modify code format, and delete unused code path.
>
> Changes in V1:
>         Check PCIe register 0x308 bit 4 and skip eMMC 3.3v initialization
>         process if it is set to 1.
> ---
>  drivers/mmc/host/sdhci-pci-o2micro.c | 18 ++++++++++++++++++
>  1 file changed, 18 insertions(+)
>
> diff --git a/drivers/mmc/host/sdhci-pci-o2micro.c b/drivers/mmc/host/sdhci-pci-o2micro.c
> index 555970a29c94..ba59db6a126c 100644
> --- a/drivers/mmc/host/sdhci-pci-o2micro.c
> +++ b/drivers/mmc/host/sdhci-pci-o2micro.c
> @@ -3,6 +3,7 @@
>   *
>   * Authors: Peter Guo <peter.guo@bayhubtech.com>
>   *          Adam Lee <adam.lee@canonical.com>
> + *          Ernest Zhang <ernest.zhang@bayhubtech.com>
>   *
>   * This software is licensed under the terms of the GNU General Public
>   * License version 2, as published by the Free Software Foundation, and
> @@ -39,6 +40,7 @@
>  #define O2_SD_MISC_CTRL4       0xFC
>  #define O2_SD_TUNING_CTRL      0x300
>  #define O2_SD_PLL_SETTING      0x304
> +#define O2_SD_MISC_SETTING     0x308
>  #define O2_SD_CLK_SETTING      0x328
>  #define O2_SD_CAP_REG2         0x330
>  #define O2_SD_CAP_REG0         0x334
> @@ -184,6 +186,7 @@ int sdhci_pci_o2_probe_slot(struct sdhci_pci_slot *slot)
>         struct sdhci_pci_chip *chip;
>         struct sdhci_host *host;
>         u32 reg;
> +       int ret;
>
>         chip = slot->chip;
>         host = slot->host;
> @@ -197,6 +200,21 @@ int sdhci_pci_o2_probe_slot(struct sdhci_pci_slot *slot)
>                 if (reg & 0x1)
>                         host->quirks |= SDHCI_QUIRK_MULTIBLOCK_READ_ACMD12;
>
> +               if (chip->pdev->device == PCI_DEVICE_ID_O2_SEABIRD0) {
> +                       ret = pci_read_config_dword(chip->pdev,
> +                                                   O2_SD_MISC_SETTING, &reg);
> +                       if (ret)
> +                               return -EIO;
> +                       if (reg & (1 << 4)) {
> +                               pr_info("%s: emmc 1.8v flag is set, force 1.8v signaling voltage\n",
> +                                       mmc_hostname(host->mmc));
> +                               host->flags &= ~SDHCI_SIGNALING_330;
> +                               host->flags |= SDHCI_SIGNALING_180;
> +                               host->mmc->caps2 |= MMC_CAP2_NO_SD;
> +                               host->mmc->caps2 |= MMC_CAP2_NO_SDIO;
> +                       }
> +               }
> +
>                 if (chip->pdev->device != PCI_DEVICE_ID_O2_FUJIN2)
>                         break;
>                 /* set dll watch dog timer */
> --
> 2.17.1
>

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2018-07-30 15:05 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-07-16  6:26 [PATCH V7 1/5] mmc: sdhci: Add support for O2 eMMC HS200 mode ernest.zhang
2018-07-16  6:26 ` [PATCH V7 2/5] mmc: sdhci: Change O2 Host HS200 mode clock frequency to 200MHz ernest.zhang
2018-07-25  7:45   ` Adrian Hunter
2018-07-27  6:49     ` Ernest Zhang(WH)
2018-07-27  6:58       ` Adrian Hunter
2018-07-16  6:26 ` [PATCH V7 3/5] mmc: sdhci: Export sdhci tuning function symbol ernest.zhang
2018-07-25  7:46   ` Adrian Hunter
2018-07-16  6:26 ` [PATCH V7 4/5] mmc: sdhci: Add support for O2 hardware tuning ernest.zhang
2018-07-25  7:48   ` Adrian Hunter
2018-07-16  6:26 ` [PATCH V7 5/5] mmc: sdhci: Add MSI interrupt support for O2 SD host ernest.zhang
2018-07-25  7:48   ` Adrian Hunter
2018-07-25  7:44 ` [PATCH V7 1/5] mmc: sdhci: Add support for O2 eMMC HS200 mode Adrian Hunter
2018-07-30 15:05 ` Ulf Hansson

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.