All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] usb: dwc2: Update Core Reset programming flow.
@ 2020-05-20 13:31 Minas Harutyunyan
  2020-05-20 23:07   ` kbuild test robot
  2020-05-21  1:29 ` kbuild test robot
  0 siblings, 2 replies; 4+ messages in thread
From: Minas Harutyunyan @ 2020-05-20 13:31 UTC (permalink / raw)
  To: Felipe Balbi, Greg Kroah-Hartman, Minas Harutyunyan, linux-usb; +Cc: John Youn

Starting from core version 4.20a Core Reset flow is changed.
Introduced new bit in GRSTCTL register - GRSTCTL_CSFTRST_DONE.
Core Reset new programming flow steps are follow:
1. Set GRSTCTL_CSFTRST bit.
2. Wait for bit GRSTCTL_CSFTRST_DONE is set.
3. Clear GRSTCTL_CSFTRST and GRSTCTL_CSFTRST_DONE bits.

Check core version functionality separated from dwc2_get_hwparams() to
new dwc2_check_core_version() function because Core Reset flow depend
on SNPSID.

Signed-off-by: Minas Harutyunyan <hminas@synopsys.com>
---
 drivers/usb/dwc2/core.c     | 23 +++++++++++++++++++----
 drivers/usb/dwc2/core.h     |  2 ++
 drivers/usb/dwc2/hw.h       |  1 +
 drivers/usb/dwc2/params.c   | 19 -------------------
 drivers/usb/dwc2/platform.c | 39 +++++++++++++++++++++++++++++++++++++++
 5 files changed, 61 insertions(+), 23 deletions(-)

diff --git a/drivers/usb/dwc2/core.c b/drivers/usb/dwc2/core.c
index 78a4925aa118..fec17a2d2447 100644
--- a/drivers/usb/dwc2/core.c
+++ b/drivers/usb/dwc2/core.c
@@ -524,10 +524,25 @@ int dwc2_core_reset(struct dwc2_hsotg *hsotg, bool skip_wait)
 	greset |= GRSTCTL_CSFTRST;
 	dwc2_writel(hsotg, greset, GRSTCTL);
 
-	if (dwc2_hsotg_wait_bit_clear(hsotg, GRSTCTL, GRSTCTL_CSFTRST, 10000)) {
-		dev_warn(hsotg->dev, "%s: HANG! Soft Reset timeout GRSTCTL GRSTCTL_CSFTRST\n",
-			 __func__);
-		return -EBUSY;
+	if ((hsotg->hw_params.snpsid & DWC2_CORE_REV_MASK) <
+		(DWC2_CORE_REV_4_20a & DWC2_CORE_REV_MASK)) {
+		if (dwc2_hsotg_wait_bit_clear(hsotg, GRSTCTL,
+					      GRSTCTL_CSFTRST, 10000)) {
+			dev_warn(hsotg->dev, "%s: HANG! Soft Reset timeout GRSTCTL_CSFTRST\n",
+				 __func__);
+			return -EBUSY;
+		}
+	} else {
+		if (dwc2_hsotg_wait_bit_set(hsotg, GRSTCTL,
+					    GRSTCTL_CSFTRST_DONE, 10000)) {
+			dev_warn(hsotg->dev, "%s: HANG! Soft Reset timeout GRSTCTL_CSFTRST_DONE\n",
+				 __func__);
+			return -EBUSY;
+		}
+		greset = dwc2_readl(hsotg, GRSTCTL);
+		greset &= ~GRSTCTL_CSFTRST;
+		greset |= GRSTCTL_CSFTRST_DONE;
+		dwc2_writel(hsotg, greset, GRSTCTL);
 	}
 
 	/* Wait for AHB master IDLE state */
diff --git a/drivers/usb/dwc2/core.h b/drivers/usb/dwc2/core.h
index 668d1ad646a4..f55f664c0718 100644
--- a/drivers/usb/dwc2/core.h
+++ b/drivers/usb/dwc2/core.h
@@ -1103,8 +1103,10 @@ struct dwc2_hsotg {
 #define DWC2_CORE_REV_3_00a	0x4f54300a
 #define DWC2_CORE_REV_3_10a	0x4f54310a
 #define DWC2_CORE_REV_4_00a	0x4f54400a
+#define DWC2_CORE_REV_4_20a	0x4f54420a
 #define DWC2_FS_IOT_REV_1_00a	0x5531100a
 #define DWC2_HS_IOT_REV_1_00a	0x5532100a
+#define DWC2_CORE_REV_MASK	0x0000ffff
 
 	/* DWC OTG HW Core ID */
 #define DWC2_OTG_ID		0x4f540000
diff --git a/drivers/usb/dwc2/hw.h b/drivers/usb/dwc2/hw.h
index 864b76a0b954..c3d6dde2aca4 100644
--- a/drivers/usb/dwc2/hw.h
+++ b/drivers/usb/dwc2/hw.h
@@ -126,6 +126,7 @@
 #define GRSTCTL				HSOTG_REG(0x010)
 #define GRSTCTL_AHBIDLE			BIT(31)
 #define GRSTCTL_DMAREQ			BIT(30)
+#define GRSTCTL_CSFTRST_DONE		BIT(29)
 #define GRSTCTL_TXFNUM_MASK		(0x1f << 6)
 #define GRSTCTL_TXFNUM_SHIFT		6
 #define GRSTCTL_TXFNUM_LIMIT		0x1f
diff --git a/drivers/usb/dwc2/params.c b/drivers/usb/dwc2/params.c
index 8ccc83f7eb3f..ce736d67c7c3 100644
--- a/drivers/usb/dwc2/params.c
+++ b/drivers/usb/dwc2/params.c
@@ -782,25 +782,6 @@ int dwc2_get_hwparams(struct dwc2_hsotg *hsotg)
 	u32 hwcfg1, hwcfg2, hwcfg3, hwcfg4;
 	u32 grxfsiz;
 
-	/*
-	 * Attempt to ensure this device is really a DWC_otg Controller.
-	 * Read and verify the GSNPSID register contents. The value should be
-	 * 0x45f4xxxx, 0x5531xxxx or 0x5532xxxx
-	 */
-
-	hw->snpsid = dwc2_readl(hsotg, GSNPSID);
-	if ((hw->snpsid & GSNPSID_ID_MASK) != DWC2_OTG_ID &&
-	    (hw->snpsid & GSNPSID_ID_MASK) != DWC2_FS_IOT_ID &&
-	    (hw->snpsid & GSNPSID_ID_MASK) != DWC2_HS_IOT_ID) {
-		dev_err(hsotg->dev, "Bad value for GSNPSID: 0x%08x\n",
-			hw->snpsid);
-		return -ENODEV;
-	}
-
-	dev_dbg(hsotg->dev, "Core Release: %1x.%1x%1x%1x (snpsid=%x)\n",
-		hw->snpsid >> 12 & 0xf, hw->snpsid >> 8 & 0xf,
-		hw->snpsid >> 4 & 0xf, hw->snpsid & 0xf, hw->snpsid);
-
 	hwcfg1 = dwc2_readl(hsotg, GHWCFG1);
 	hwcfg2 = dwc2_readl(hsotg, GHWCFG2);
 	hwcfg3 = dwc2_readl(hsotg, GHWCFG3);
diff --git a/drivers/usb/dwc2/platform.c b/drivers/usb/dwc2/platform.c
index 69972750e161..e571c8ae65ec 100644
--- a/drivers/usb/dwc2/platform.c
+++ b/drivers/usb/dwc2/platform.c
@@ -362,6 +362,37 @@ static bool dwc2_check_core_endianness(struct dwc2_hsotg *hsotg)
 	return true;
 }
 
+/**
+ * Check core version
+ *
+ * @hsotg: Programming view of the DWC_otg controller
+ *
+ */
+int dwc2_check_core_version(struct dwc2_hsotg *hsotg)
+{
+	struct dwc2_hw_params *hw = &hsotg->hw_params;
+
+	/*
+	 * Attempt to ensure this device is really a DWC_otg Controller.
+	 * Read and verify the GSNPSID register contents. The value should be
+	 * 0x45f4xxxx, 0x5531xxxx or 0x5532xxxx
+	 */
+
+	hw->snpsid = dwc2_readl(hsotg, GSNPSID);
+	if ((hw->snpsid & GSNPSID_ID_MASK) != DWC2_OTG_ID &&
+	    (hw->snpsid & GSNPSID_ID_MASK) != DWC2_FS_IOT_ID &&
+	    (hw->snpsid & GSNPSID_ID_MASK) != DWC2_HS_IOT_ID) {
+		dev_err(hsotg->dev, "Bad value for GSNPSID: 0x%08x\n",
+			hw->snpsid);
+		return -ENODEV;
+	}
+
+	dev_dbg(hsotg->dev, "Core Release: %1x.%1x%1x%1x (snpsid=%x)\n",
+		hw->snpsid >> 12 & 0xf, hw->snpsid >> 8 & 0xf,
+		hw->snpsid >> 4 & 0xf, hw->snpsid & 0xf, hw->snpsid);
+	return 0;
+}
+
 /**
  * dwc2_driver_probe() - Called when the DWC_otg core is bound to the DWC_otg
  * driver
@@ -444,6 +475,14 @@ static int dwc2_driver_probe(struct platform_device *dev)
 		of_property_read_bool(dev->dev.of_node,
 				      "snps,need-phy-for-wake");
 
+	/*
+	 * Before performing any core related operations
+	 * check core version.
+	 */
+	retval = dwc2_check_core_version(hsotg);
+	if (retval)
+		goto error;
+
 	/*
 	 * Reset before dwc2_get_hwparams() then it could get power-on real
 	 * reset value form registers.
-- 
2.11.0


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

* Re: [PATCH] usb: dwc2: Update Core Reset programming flow.
  2020-05-20 13:31 [PATCH] usb: dwc2: Update Core Reset programming flow Minas Harutyunyan
@ 2020-05-20 23:07   ` kbuild test robot
  2020-05-21  1:29 ` kbuild test robot
  1 sibling, 0 replies; 4+ messages in thread
From: kbuild test robot @ 2020-05-20 23:07 UTC (permalink / raw)
  To: Minas Harutyunyan, Felipe Balbi, Greg Kroah-Hartman, linux-usb
  Cc: kbuild-all, John Youn

[-- Attachment #1: Type: text/plain, Size: 2701 bytes --]

Hi Minas,

I love your patch! Perhaps something to improve:

[auto build test WARNING on balbi-usb/testing/next]
[also build test WARNING on usb/usb-testing peter.chen-usb/ci-for-usb-next v5.7-rc6 next-20200519]
[if your patch is applied to the wrong git tree, please drop us a note to help
improve the system. BTW, we also suggest to use '--base' option to specify the
base tree in git format-patch, please see https://stackoverflow.com/a/37406982]

url:    https://github.com/0day-ci/linux/commits/Minas-Harutyunyan/usb-dwc2-Update-Core-Reset-programming-flow/20200521-032421
base:   https://git.kernel.org/pub/scm/linux/kernel/git/balbi/usb.git testing/next
config: ia64-allmodconfig (attached as .config)
compiler: ia64-linux-gcc (GCC) 9.3.0
reproduce:
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=ia64 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kbuild test robot <lkp@intel.com>

All warnings (new ones prefixed by >>, old ones prefixed by <<):

>> drivers/usb/dwc2/platform.c:371:5: warning: no previous prototype for 'dwc2_check_core_version' [-Wmissing-prototypes]
371 | int dwc2_check_core_version(struct dwc2_hsotg *hsotg)
|     ^~~~~~~~~~~~~~~~~~~~~~~

vim +/dwc2_check_core_version +371 drivers/usb/dwc2/platform.c

   364	
   365	/**
   366	 * Check core version
   367	 *
   368	 * @hsotg: Programming view of the DWC_otg controller
   369	 *
   370	 */
 > 371	int dwc2_check_core_version(struct dwc2_hsotg *hsotg)
   372	{
   373		struct dwc2_hw_params *hw = &hsotg->hw_params;
   374	
   375		/*
   376		 * Attempt to ensure this device is really a DWC_otg Controller.
   377		 * Read and verify the GSNPSID register contents. The value should be
   378		 * 0x45f4xxxx, 0x5531xxxx or 0x5532xxxx
   379		 */
   380	
   381		hw->snpsid = dwc2_readl(hsotg, GSNPSID);
   382		if ((hw->snpsid & GSNPSID_ID_MASK) != DWC2_OTG_ID &&
   383		    (hw->snpsid & GSNPSID_ID_MASK) != DWC2_FS_IOT_ID &&
   384		    (hw->snpsid & GSNPSID_ID_MASK) != DWC2_HS_IOT_ID) {
   385			dev_err(hsotg->dev, "Bad value for GSNPSID: 0x%08x\n",
   386				hw->snpsid);
   387			return -ENODEV;
   388		}
   389	
   390		dev_dbg(hsotg->dev, "Core Release: %1x.%1x%1x%1x (snpsid=%x)\n",
   391			hw->snpsid >> 12 & 0xf, hw->snpsid >> 8 & 0xf,
   392			hw->snpsid >> 4 & 0xf, hw->snpsid & 0xf, hw->snpsid);
   393		return 0;
   394	}
   395	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 57812 bytes --]

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

* Re: [PATCH] usb: dwc2: Update Core Reset programming flow.
@ 2020-05-20 23:07   ` kbuild test robot
  0 siblings, 0 replies; 4+ messages in thread
From: kbuild test robot @ 2020-05-20 23:07 UTC (permalink / raw)
  To: kbuild-all

[-- Attachment #1: Type: text/plain, Size: 2770 bytes --]

Hi Minas,

I love your patch! Perhaps something to improve:

[auto build test WARNING on balbi-usb/testing/next]
[also build test WARNING on usb/usb-testing peter.chen-usb/ci-for-usb-next v5.7-rc6 next-20200519]
[if your patch is applied to the wrong git tree, please drop us a note to help
improve the system. BTW, we also suggest to use '--base' option to specify the
base tree in git format-patch, please see https://stackoverflow.com/a/37406982]

url:    https://github.com/0day-ci/linux/commits/Minas-Harutyunyan/usb-dwc2-Update-Core-Reset-programming-flow/20200521-032421
base:   https://git.kernel.org/pub/scm/linux/kernel/git/balbi/usb.git testing/next
config: ia64-allmodconfig (attached as .config)
compiler: ia64-linux-gcc (GCC) 9.3.0
reproduce:
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=ia64 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kbuild test robot <lkp@intel.com>

All warnings (new ones prefixed by >>, old ones prefixed by <<):

>> drivers/usb/dwc2/platform.c:371:5: warning: no previous prototype for 'dwc2_check_core_version' [-Wmissing-prototypes]
371 | int dwc2_check_core_version(struct dwc2_hsotg *hsotg)
|     ^~~~~~~~~~~~~~~~~~~~~~~

vim +/dwc2_check_core_version +371 drivers/usb/dwc2/platform.c

   364	
   365	/**
   366	 * Check core version
   367	 *
   368	 * @hsotg: Programming view of the DWC_otg controller
   369	 *
   370	 */
 > 371	int dwc2_check_core_version(struct dwc2_hsotg *hsotg)
   372	{
   373		struct dwc2_hw_params *hw = &hsotg->hw_params;
   374	
   375		/*
   376		 * Attempt to ensure this device is really a DWC_otg Controller.
   377		 * Read and verify the GSNPSID register contents. The value should be
   378		 * 0x45f4xxxx, 0x5531xxxx or 0x5532xxxx
   379		 */
   380	
   381		hw->snpsid = dwc2_readl(hsotg, GSNPSID);
   382		if ((hw->snpsid & GSNPSID_ID_MASK) != DWC2_OTG_ID &&
   383		    (hw->snpsid & GSNPSID_ID_MASK) != DWC2_FS_IOT_ID &&
   384		    (hw->snpsid & GSNPSID_ID_MASK) != DWC2_HS_IOT_ID) {
   385			dev_err(hsotg->dev, "Bad value for GSNPSID: 0x%08x\n",
   386				hw->snpsid);
   387			return -ENODEV;
   388		}
   389	
   390		dev_dbg(hsotg->dev, "Core Release: %1x.%1x%1x%1x (snpsid=%x)\n",
   391			hw->snpsid >> 12 & 0xf, hw->snpsid >> 8 & 0xf,
   392			hw->snpsid >> 4 & 0xf, hw->snpsid & 0xf, hw->snpsid);
   393		return 0;
   394	}
   395	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 57812 bytes --]

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

* Re: [PATCH] usb: dwc2: Update Core Reset programming flow.
  2020-05-20 13:31 [PATCH] usb: dwc2: Update Core Reset programming flow Minas Harutyunyan
  2020-05-20 23:07   ` kbuild test robot
@ 2020-05-21  1:29 ` kbuild test robot
  1 sibling, 0 replies; 4+ messages in thread
From: kbuild test robot @ 2020-05-21  1:29 UTC (permalink / raw)
  To: kbuild-all

[-- Attachment #1: Type: text/plain, Size: 3127 bytes --]

Hi Minas,

I love your patch! Perhaps something to improve:

[auto build test WARNING on balbi-usb/testing/next]
[also build test WARNING on usb/usb-testing v5.7-rc6 next-20200519]
[if your patch is applied to the wrong git tree, please drop us a note to help
improve the system. BTW, we also suggest to use '--base' option to specify the
base tree in git format-patch, please see https://stackoverflow.com/a/37406982]

url:    https://github.com/0day-ci/linux/commits/Minas-Harutyunyan/usb-dwc2-Update-Core-Reset-programming-flow/20200521-032421
base:   https://git.kernel.org/pub/scm/linux/kernel/git/balbi/usb.git testing/next
config: x86_64-allyesconfig (attached as .config)
compiler: clang version 11.0.0 (https://github.com/llvm/llvm-project e6658079aca6d971b4e9d7137a3a2ecbc9c34aec)
reproduce:
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # install x86_64 cross compiling tool for clang build
        # apt-get install binutils-x86-64-linux-gnu
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=x86_64 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kbuild test robot <lkp@intel.com>

All warnings (new ones prefixed by >>, old ones prefixed by <<):

>> drivers/usb/dwc2/platform.c:371:5: warning: no previous prototype for function 'dwc2_check_core_version' [-Wmissing-prototypes]
int dwc2_check_core_version(struct dwc2_hsotg *hsotg)
^
drivers/usb/dwc2/platform.c:371:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
int dwc2_check_core_version(struct dwc2_hsotg *hsotg)
^
static
1 warning generated.

vim +/dwc2_check_core_version +371 drivers/usb/dwc2/platform.c

   364	
   365	/**
   366	 * Check core version
   367	 *
   368	 * @hsotg: Programming view of the DWC_otg controller
   369	 *
   370	 */
 > 371	int dwc2_check_core_version(struct dwc2_hsotg *hsotg)
   372	{
   373		struct dwc2_hw_params *hw = &hsotg->hw_params;
   374	
   375		/*
   376		 * Attempt to ensure this device is really a DWC_otg Controller.
   377		 * Read and verify the GSNPSID register contents. The value should be
   378		 * 0x45f4xxxx, 0x5531xxxx or 0x5532xxxx
   379		 */
   380	
   381		hw->snpsid = dwc2_readl(hsotg, GSNPSID);
   382		if ((hw->snpsid & GSNPSID_ID_MASK) != DWC2_OTG_ID &&
   383		    (hw->snpsid & GSNPSID_ID_MASK) != DWC2_FS_IOT_ID &&
   384		    (hw->snpsid & GSNPSID_ID_MASK) != DWC2_HS_IOT_ID) {
   385			dev_err(hsotg->dev, "Bad value for GSNPSID: 0x%08x\n",
   386				hw->snpsid);
   387			return -ENODEV;
   388		}
   389	
   390		dev_dbg(hsotg->dev, "Core Release: %1x.%1x%1x%1x (snpsid=%x)\n",
   391			hw->snpsid >> 12 & 0xf, hw->snpsid >> 8 & 0xf,
   392			hw->snpsid >> 4 & 0xf, hw->snpsid & 0xf, hw->snpsid);
   393		return 0;
   394	}
   395	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 73528 bytes --]

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

end of thread, other threads:[~2020-05-21  1:29 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-20 13:31 [PATCH] usb: dwc2: Update Core Reset programming flow Minas Harutyunyan
2020-05-20 23:07 ` kbuild test robot
2020-05-20 23:07   ` kbuild test robot
2020-05-21  1:29 ` kbuild test robot

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.