Re: [Patch v9 3/3] phy: Add Qualcomm DWC3 HS/SS PHY driver

2015-01-22 Thread Jack Pham
Hi Andy,

On Fri, Sep 12, 2014 at 02:28:08PM -0500, Andy Gross wrote:
 This patch adds a new driver for the Qualcomm USB 3.0 PHY that exists on some
 Qualcomm platforms.  This driver uses the generic PHY framework and will
 interact with the DWC3 controller.
 
 Signed-off-by: Andy Gross agr...@codeaurora.org
 ---
  drivers/phy/Kconfig |   11 +
  drivers/phy/Makefile|1 +
  drivers/phy/phy-qcom-dwc3.c |  483 
 +++
  3 files changed, 495 insertions(+)
  create mode 100644 drivers/phy/phy-qcom-dwc3.c

What happened to this patch? Looks like [1/3]  [2/3] made it in during
the 3.18 merge, but did this one not get picked up by Kishon?

Thanks,
Jack
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project
--
To unsubscribe from this list: send the line unsubscribe linux-arm-msm in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [Patch v9 3/3] phy: Add Qualcomm DWC3 HS/SS PHY driver

2015-01-22 Thread Andy Gross
On Thu, Jan 22, 2015 at 10:59:14AM -0800, Jack Pham wrote:
 Hi Andy,
 
 On Fri, Sep 12, 2014 at 02:28:08PM -0500, Andy Gross wrote:
  This patch adds a new driver for the Qualcomm USB 3.0 PHY that exists on 
  some
  Qualcomm platforms.  This driver uses the generic PHY framework and will
  interact with the DWC3 controller.
  
  Signed-off-by: Andy Gross agr...@codeaurora.org
  ---
   drivers/phy/Kconfig |   11 +
   drivers/phy/Makefile|1 +
   drivers/phy/phy-qcom-dwc3.c |  483 
  +++
   3 files changed, 495 insertions(+)
   create mode 100644 drivers/phy/phy-qcom-dwc3.c
 
 What happened to this patch? Looks like [1/3]  [2/3] made it in during
 the 3.18 merge, but did this one not get picked up by Kishon?

Got sidetracked.  I'll rework and resend in.  It'll be a couple days.

-- 
Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project

--
To unsubscribe from this list: send the line unsubscribe linux-arm-msm in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [Patch v9 3/3] phy: Add Qualcomm DWC3 HS/SS PHY driver

2014-09-15 Thread Kishon Vijay Abraham I
Hi,

On Sunday 14 September 2014 07:54 AM, Felipe Balbi wrote:
 Hi,
 
 On Sat, Sep 13, 2014 at 12:16:01PM +0530, Kishon Vijay Abraham I wrote:
 On Saturday 13 September 2014 12:58 AM, Andy Gross wrote:
 This patch adds a new driver for the Qualcomm USB 3.0 PHY that exists on 
 some
 Qualcomm platforms.  This driver uses the generic PHY framework and will
 interact with the DWC3 controller.

 Do you have dt documentation for this driver?
 
 see patch 1

hmm.. missed that.
 
 +static inline void qcom_dwc3_phy_write_readback(
 +   struct qcom_dwc3_usb_phy *phy_dwc3, u32 offset,
 +   const u32 mask, u32 val)
 +{
 +   u32 write_val, tmp = readl(phy_dwc3-base + offset);
 +
 +   tmp = ~mask;   /* retain other bits */
 +   write_val = tmp | val;
 +
 +   writel(write_val, phy_dwc3-base + offset);
 +
 +   /* Read back to see if val was written */

 Does it fail sometime? I'm not sure if this should be present in the
 driver since this looks more of a debug code.
 
 this was mentioned before. Silicon bug.

okay.
 
 +   writel_relaxed(data | SSUSB_CTRL_SS_PHY_RESET,
 +   phy_dwc3-base + SSUSB_PHY_CTRL_REG);
 +   usleep_range(2000, 2200);

 use msleep here..
 
 why ? usleep_range() gives the scheduler oportunity to group timers.

Was of the opinion that for larger delays msleep should be used. But looks like
it is only for 10+ ms (Documentation/timers/timers-howto.txt).

Thanks
Kishon
--
To unsubscribe from this list: send the line unsubscribe linux-arm-msm in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [Patch v9 3/3] phy: Add Qualcomm DWC3 HS/SS PHY driver

2014-09-13 Thread Kishon Vijay Abraham I
Hi,

On Saturday 13 September 2014 12:58 AM, Andy Gross wrote:
 This patch adds a new driver for the Qualcomm USB 3.0 PHY that exists on some
 Qualcomm platforms.  This driver uses the generic PHY framework and will
 interact with the DWC3 controller.

Do you have dt documentation for this driver?
 
 Signed-off-by: Andy Gross agr...@codeaurora.org
 ---
  drivers/phy/Kconfig |   11 +
  drivers/phy/Makefile|1 +
  drivers/phy/phy-qcom-dwc3.c |  483 
 +++
  3 files changed, 495 insertions(+)
  create mode 100644 drivers/phy/phy-qcom-dwc3.c
 
 diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig
 index 0dd7427..5d56161 100644
 --- a/drivers/phy/Kconfig
 +++ b/drivers/phy/Kconfig
 @@ -230,4 +230,15 @@ config PHY_XGENE
   help
 This option enables support for APM X-Gene SoC multi-purpose PHY.
  
 +config PHY_QCOM_DWC3
 + tristate QCOM DWC3 USB PHY support
 + depends on ARCH_QCOM
 + depends on HAS_IOMEM
 + depends on OF
 + select GENERIC_PHY
 + help
 +   This option enables support for the Synopsis PHYs present inside the
 +   Qualcomm USB3.0 DWC3 controller.  This driver supports both HS and SS
 +   PHY controllers.
 +
  endmenu
 diff --git a/drivers/phy/Makefile b/drivers/phy/Makefile
 index 95c69ed..aa16f30 100644
 --- a/drivers/phy/Makefile
 +++ b/drivers/phy/Makefile
 @@ -28,3 +28,4 @@ obj-$(CONFIG_PHY_QCOM_IPQ806X_SATA) += 
 phy-qcom-ipq806x-sata.o
  obj-$(CONFIG_PHY_ST_SPEAR1310_MIPHY) += phy-spear1310-miphy.o
  obj-$(CONFIG_PHY_ST_SPEAR1340_MIPHY) += phy-spear1340-miphy.o
  obj-$(CONFIG_PHY_XGENE)  += phy-xgene.o
 +obj-$(CONFIG_PHY_QCOM_DWC3)  += phy-qcom-dwc3.o
 diff --git a/drivers/phy/phy-qcom-dwc3.c b/drivers/phy/phy-qcom-dwc3.c
 new file mode 100644
 index 000..2c7b316
 --- /dev/null
 +++ b/drivers/phy/phy-qcom-dwc3.c
 @@ -0,0 +1,483 @@
 +/* Copyright (c) 2013-2014, Code Aurora Forum. All rights reserved.
 + *
 + * This program is free software; you can redistribute it and/or modify
 + * it under the terms of the GNU General Public License version 2 and
 + * only version 2 as published by the Free Software Foundation.
 + *
 + * This program is distributed in the hope that it will be useful,
 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 + * GNU General Public License for more details.
 + */
 +
 +#include linux/clk.h
 +#include linux/err.h
 +#include linux/io.h
 +#include linux/module.h
 +#include linux/of.h
 +#include linux/phy/phy.h
 +#include linux/platform_device.h
 +#include linux/delay.h
 +
 +/**
 + *  USB QSCRATCH Hardware registers
 + */
 +#define QSCRATCH_GENERAL_CFG (0x08)
 +#define HSUSB_PHY_CTRL_REG   (0x10)
 +
 +/* PHY_CTRL_REG */
 +#define HSUSB_CTRL_DMSEHV_CLAMP  BIT(24)
 +#define HSUSB_CTRL_USB2_SUSPEND  BIT(23)
 +#define HSUSB_CTRL_UTMI_CLK_EN   BIT(21)
 +#define  HSUSB_CTRL_UTMI_OTG_VBUS_VALID  BIT(20)
  
alignment went wrong here..

 +#define HSUSB_CTRL_USE_CLKCORE   BIT(18)
 +#define HSUSB_CTRL_DPSEHV_CLAMP  BIT(17)
 +#define HSUSB_CTRL_COMMONONN BIT(11)
 +#define HSUSB_CTRL_ID_HV_CLAMP   BIT(9)
 +#define HSUSB_CTRL_OTGSESSVLD_CLAMP  BIT(8)
 +#define HSUSB_CTRL_CLAMP_EN  BIT(7)
 +#define HSUSB_CTRL_RETENABLENBIT(1)
 +#define HSUSB_CTRL_POR   BIT(0)
 +
 +/* QSCRATCH_GENERAL_CFG */
 +#define HSUSB_GCFG_XHCI_REV  BIT(2)
 +
 +/**
 + *  USB QSCRATCH Hardware registers
 + */
 +#define SSUSB_PHY_CTRL_REG   (0x00)
 +#define SSUSB_PHY_PARAM_CTRL_1   (0x04)
 +#define SSUSB_PHY_PARAM_CTRL_2   (0x08)
 +#define CR_PROTOCOL_DATA_IN_REG  (0x0c)
 +#define CR_PROTOCOL_DATA_OUT_REG (0x10)
 +#define CR_PROTOCOL_CAP_ADDR_REG (0x14)
 +#define CR_PROTOCOL_CAP_DATA_REG (0x18)
 +#define CR_PROTOCOL_READ_REG (0x1c)
 +#define CR_PROTOCOL_WRITE_REG(0x20)
 +
 +/* PHY_CTRL_REG */
 +#define SSUSB_CTRL_REF_USE_PAD   BIT(28)
 +#define SSUSB_CTRL_TEST_POWERDOWNBIT(27)
 +#define SSUSB_CTRL_LANE0_PWR_PRESENT BIT(24)
 +#define SSUSB_CTRL_SS_PHY_EN BIT(8)
 +#define SSUSB_CTRL_SS_PHY_RESET  BIT(7)
 +
 +/* SSPHY control registers */
 +#define SSPHY_CTRL_RX_OVRD_IN_HI(lane)   (0x1006 + 0x100 * lane)
 +#define SSPHY_CTRL_TX_OVRD_DRV_LO(lane)  (0x1002 + 0x100 * lane)
 +
 +/* RX OVRD IN HI bits */
 +#define RX_OVRD_IN_HI_RX_RESET_OVRD  BIT(13)
 +#define RX_OVRD_IN_HI_RX_RX_RESETBIT(12)
 +#define RX_OVRD_IN_HI_RX_EQ_OVRD BIT(11)
 +#define RX_OVRD_IN_HI_RX_EQ_MASK 0x0700
 +#define RX_OVRD_IN_HI_RX_EQ_SHIFT8
 +#define RX_OVRD_IN_HI_RX_EQ_EN_OVRD  BIT(7)
 

Re: [Patch v9 3/3] phy: Add Qualcomm DWC3 HS/SS PHY driver

2014-09-13 Thread Felipe Balbi
Hi,

On Sat, Sep 13, 2014 at 12:16:01PM +0530, Kishon Vijay Abraham I wrote:
 On Saturday 13 September 2014 12:58 AM, Andy Gross wrote:
  This patch adds a new driver for the Qualcomm USB 3.0 PHY that exists on 
  some
  Qualcomm platforms.  This driver uses the generic PHY framework and will
  interact with the DWC3 controller.
 
 Do you have dt documentation for this driver?

see patch 1

  +static inline void qcom_dwc3_phy_write_readback(
  +   struct qcom_dwc3_usb_phy *phy_dwc3, u32 offset,
  +   const u32 mask, u32 val)
  +{
  +   u32 write_val, tmp = readl(phy_dwc3-base + offset);
  +
  +   tmp = ~mask;   /* retain other bits */
  +   write_val = tmp | val;
  +
  +   writel(write_val, phy_dwc3-base + offset);
  +
  +   /* Read back to see if val was written */
 
 Does it fail sometime? I'm not sure if this should be present in the
 driver since this looks more of a debug code.

this was mentioned before. Silicon bug.

  +   writel_relaxed(data | SSUSB_CTRL_SS_PHY_RESET,
  +   phy_dwc3-base + SSUSB_PHY_CTRL_REG);
  +   usleep_range(2000, 2200);
 
 use msleep here..

why ? usleep_range() gives the scheduler oportunity to group timers.

-- 
balbi


signature.asc
Description: Digital signature


[Patch v9 3/3] phy: Add Qualcomm DWC3 HS/SS PHY driver

2014-09-12 Thread Andy Gross
This patch adds a new driver for the Qualcomm USB 3.0 PHY that exists on some
Qualcomm platforms.  This driver uses the generic PHY framework and will
interact with the DWC3 controller.

Signed-off-by: Andy Gross agr...@codeaurora.org
---
 drivers/phy/Kconfig |   11 +
 drivers/phy/Makefile|1 +
 drivers/phy/phy-qcom-dwc3.c |  483 +++
 3 files changed, 495 insertions(+)
 create mode 100644 drivers/phy/phy-qcom-dwc3.c

diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig
index 0dd7427..5d56161 100644
--- a/drivers/phy/Kconfig
+++ b/drivers/phy/Kconfig
@@ -230,4 +230,15 @@ config PHY_XGENE
help
  This option enables support for APM X-Gene SoC multi-purpose PHY.
 
+config PHY_QCOM_DWC3
+   tristate QCOM DWC3 USB PHY support
+   depends on ARCH_QCOM
+   depends on HAS_IOMEM
+   depends on OF
+   select GENERIC_PHY
+   help
+ This option enables support for the Synopsis PHYs present inside the
+ Qualcomm USB3.0 DWC3 controller.  This driver supports both HS and SS
+ PHY controllers.
+
 endmenu
diff --git a/drivers/phy/Makefile b/drivers/phy/Makefile
index 95c69ed..aa16f30 100644
--- a/drivers/phy/Makefile
+++ b/drivers/phy/Makefile
@@ -28,3 +28,4 @@ obj-$(CONFIG_PHY_QCOM_IPQ806X_SATA)   += 
phy-qcom-ipq806x-sata.o
 obj-$(CONFIG_PHY_ST_SPEAR1310_MIPHY)   += phy-spear1310-miphy.o
 obj-$(CONFIG_PHY_ST_SPEAR1340_MIPHY)   += phy-spear1340-miphy.o
 obj-$(CONFIG_PHY_XGENE)+= phy-xgene.o
+obj-$(CONFIG_PHY_QCOM_DWC3)+= phy-qcom-dwc3.o
diff --git a/drivers/phy/phy-qcom-dwc3.c b/drivers/phy/phy-qcom-dwc3.c
new file mode 100644
index 000..2c7b316
--- /dev/null
+++ b/drivers/phy/phy-qcom-dwc3.c
@@ -0,0 +1,483 @@
+/* Copyright (c) 2013-2014, Code Aurora Forum. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#include linux/clk.h
+#include linux/err.h
+#include linux/io.h
+#include linux/module.h
+#include linux/of.h
+#include linux/phy/phy.h
+#include linux/platform_device.h
+#include linux/delay.h
+
+/**
+ *  USB QSCRATCH Hardware registers
+ */
+#define QSCRATCH_GENERAL_CFG   (0x08)
+#define HSUSB_PHY_CTRL_REG (0x10)
+
+/* PHY_CTRL_REG */
+#define HSUSB_CTRL_DMSEHV_CLAMPBIT(24)
+#define HSUSB_CTRL_USB2_SUSPENDBIT(23)
+#define HSUSB_CTRL_UTMI_CLK_EN BIT(21)
+#defineHSUSB_CTRL_UTMI_OTG_VBUS_VALID  BIT(20)
+#define HSUSB_CTRL_USE_CLKCORE BIT(18)
+#define HSUSB_CTRL_DPSEHV_CLAMPBIT(17)
+#define HSUSB_CTRL_COMMONONN   BIT(11)
+#define HSUSB_CTRL_ID_HV_CLAMP BIT(9)
+#define HSUSB_CTRL_OTGSESSVLD_CLAMPBIT(8)
+#define HSUSB_CTRL_CLAMP_ENBIT(7)
+#define HSUSB_CTRL_RETENABLEN  BIT(1)
+#define HSUSB_CTRL_POR BIT(0)
+
+/* QSCRATCH_GENERAL_CFG */
+#define HSUSB_GCFG_XHCI_REVBIT(2)
+
+/**
+ *  USB QSCRATCH Hardware registers
+ */
+#define SSUSB_PHY_CTRL_REG (0x00)
+#define SSUSB_PHY_PARAM_CTRL_1 (0x04)
+#define SSUSB_PHY_PARAM_CTRL_2 (0x08)
+#define CR_PROTOCOL_DATA_IN_REG(0x0c)
+#define CR_PROTOCOL_DATA_OUT_REG   (0x10)
+#define CR_PROTOCOL_CAP_ADDR_REG   (0x14)
+#define CR_PROTOCOL_CAP_DATA_REG   (0x18)
+#define CR_PROTOCOL_READ_REG   (0x1c)
+#define CR_PROTOCOL_WRITE_REG  (0x20)
+
+/* PHY_CTRL_REG */
+#define SSUSB_CTRL_REF_USE_PAD BIT(28)
+#define SSUSB_CTRL_TEST_POWERDOWN  BIT(27)
+#define SSUSB_CTRL_LANE0_PWR_PRESENT   BIT(24)
+#define SSUSB_CTRL_SS_PHY_EN   BIT(8)
+#define SSUSB_CTRL_SS_PHY_RESETBIT(7)
+
+/* SSPHY control registers */
+#define SSPHY_CTRL_RX_OVRD_IN_HI(lane) (0x1006 + 0x100 * lane)
+#define SSPHY_CTRL_TX_OVRD_DRV_LO(lane)(0x1002 + 0x100 * lane)
+
+/* RX OVRD IN HI bits */
+#define RX_OVRD_IN_HI_RX_RESET_OVRDBIT(13)
+#define RX_OVRD_IN_HI_RX_RX_RESET  BIT(12)
+#define RX_OVRD_IN_HI_RX_EQ_OVRD   BIT(11)
+#define RX_OVRD_IN_HI_RX_EQ_MASK   0x0700
+#define RX_OVRD_IN_HI_RX_EQ_SHIFT  8
+#define RX_OVRD_IN_HI_RX_EQ_EN_OVRDBIT(7)
+#define RX_OVRD_IN_HI_RX_EQ_EN BIT(6)
+#define RX_OVRD_IN_HI_RX_LOS_FILTER_OVRD   BIT(5)
+#define RX_OVRD_IN_HI_RX_LOS_FILTER_MASK   0x0018
+#define RX_OVRD_IN_HI_RX_RATE_OVRD BIT(2)
+#define RX_OVRD_IN_HI_RX_RATE_MASK