linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [GIT PULL] phy: for 4.8 merge window
@ 2016-07-05  5:23 Kishon Vijay Abraham I
  2016-07-05  5:23 ` [PATCH 01/10] phy: xgene: rename "enum phy_mode" to "enum xgene_phy_mode" Kishon Vijay Abraham I
                   ` (10 more replies)
  0 siblings, 11 replies; 14+ messages in thread
From: Kishon Vijay Abraham I @ 2016-07-05  5:23 UTC (permalink / raw)
  To: gregkh; +Cc: kishon, linux-kernel

Hi Greg,

Please find the pull request for 4.8 merge window below.

Now the controller can configure the mode in which the PHY should
work using the new phy_set_mode API. This was added by David Lechner
required for da8xx-usb phy (used by MUSB). For this I created a signed
tag 'phy-set-mode-v2' since the phy_set_mode API is called from musb
driver which is not part of this pull request. This also adds a new
phy driver for USB PHY in DA8xx SoC and includes other minor cleanups
and fixes.

Consider merging this for the next merge window. Let me know if I have
to change something.

The following changes since commit 04e59a0211ff012ba60c00baca673482570784e9:

  phy-sun4i-usb: Fix irq free conditions to match request conditions (2016-06-22 11:33:46 +0530)

are available in the git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/kishon/linux-phy.git tags/phy-for-4.8-rc1

for you to fetch changes up to c14f8a4032efa73d9c4e155add47c19252b3bdf4:

  phy: rcar-gen3-usb2: fix mutex_lock calling in interrupt (2016-07-04 18:07:39 +0530)

----------------------------------------------------------------
phy: for 4.8 -rc1

*) Add a new phy_ops for setting the phy mode
*) Add a new phy driver for DA8xx SoC USB PHY
*) Minor fixes and cleanups

Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>

----------------------------------------------------------------
David Lechner (3):
      phy: Add set_mode callback
      dt-bindings: Add bindings for phy-da8xx-usb
      phy: da8xx-usb: new driver for DA8xx SoC USB PHY

Hans de Goede (1):
      phy-sun4i-usb: Add workaround for missing Vbus det interrupts on A31

Heiko Stuebner (1):
      phy: rockchip-usb: should be a child device of the GRF

Kishon Vijay Abraham I (2):
      phy: xgene: rename "enum phy_mode" to "enum xgene_phy_mode"
      Merge tag 'phy-set-mode-v2' of git://git.kernel.org/.../kishon/linux-phy into next

Peter Griffin (2):
      phy: phy-qcom-ufs-qmp-20nm: Remove site specific OOM error message
      phy: phy-qcom-ufs-qmp-14nm: Remove site specific OOM error message

Sudip Mukherjee (1):
      phy: rockhip-usb: use devm_add_action_or_reset()

Yoshihiro Shimoda (1):
      phy: rcar-gen3-usb2: fix mutex_lock calling in interrupt

 .../devicetree/bindings/phy/phy-da8xx-usb.txt      |   40 ++++
 .../devicetree/bindings/phy/rockchip-usb-phy.txt   |   27 ++-
 drivers/phy/Kconfig                                |   10 +
 drivers/phy/Makefile                               |    1 +
 drivers/phy/phy-core.c                             |   15 ++
 drivers/phy/phy-da8xx-usb.c                        |  245 ++++++++++++++++++++
 drivers/phy/phy-qcom-ufs-qmp-14nm.c                |    1 -
 drivers/phy/phy-qcom-ufs-qmp-20nm.c                |    1 -
 drivers/phy/phy-rcar-gen3-usb2.c                   |   26 ++-
 drivers/phy/phy-rockchip-usb.c                     |   23 +-
 drivers/phy/phy-sun4i-usb.c                        |   34 ++-
 drivers/phy/phy-xgene.c                            |    4 +-
 include/linux/phy/phy.h                            |   17 ++
 13 files changed, 408 insertions(+), 36 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/phy/phy-da8xx-usb.txt
 create mode 100644 drivers/phy/phy-da8xx-usb.c

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

* [PATCH 01/10] phy: xgene: rename "enum phy_mode" to "enum xgene_phy_mode"
  2016-07-05  5:23 [GIT PULL] phy: for 4.8 merge window Kishon Vijay Abraham I
@ 2016-07-05  5:23 ` Kishon Vijay Abraham I
  2016-07-05  5:23 ` [PATCH 02/10] phy: Add set_mode callback Kishon Vijay Abraham I
                   ` (9 subsequent siblings)
  10 siblings, 0 replies; 14+ messages in thread
From: Kishon Vijay Abraham I @ 2016-07-05  5:23 UTC (permalink / raw)
  To: gregkh; +Cc: kishon, linux-kernel

No functional change. Rename "enum phy_mode" to
"enum xgene_phy_mode" in xgene phy driver in
preparation for adding set_mode callback in
phy core.

Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
Reviewed-by: Loc Ho <lho@apm.com>
---
 drivers/phy/phy-xgene.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/phy/phy-xgene.c b/drivers/phy/phy-xgene.c
index 385362e..ae266e0 100644
--- a/drivers/phy/phy-xgene.c
+++ b/drivers/phy/phy-xgene.c
@@ -518,7 +518,7 @@ enum clk_type_t {
 	CLK_INT_SING = 2,	/* Internal single ended */
 };
 
-enum phy_mode {
+enum xgene_phy_mode {
 	MODE_SATA	= 0,	/* List them for simple reference */
 	MODE_SGMII	= 1,
 	MODE_PCIE	= 2,
@@ -542,7 +542,7 @@ struct xgene_sata_override_param {
 struct xgene_phy_ctx {
 	struct device *dev;
 	struct phy *phy;
-	enum phy_mode mode;		/* Mode of operation */
+	enum xgene_phy_mode mode;		/* Mode of operation */
 	enum clk_type_t clk_type;	/* Input clock selection */
 	void __iomem *sds_base;		/* PHY CSR base addr */
 	struct clk *clk;		/* Optional clock */
-- 
1.7.9.5

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

* [PATCH 02/10] phy: Add set_mode callback
  2016-07-05  5:23 [GIT PULL] phy: for 4.8 merge window Kishon Vijay Abraham I
  2016-07-05  5:23 ` [PATCH 01/10] phy: xgene: rename "enum phy_mode" to "enum xgene_phy_mode" Kishon Vijay Abraham I
@ 2016-07-05  5:23 ` Kishon Vijay Abraham I
  2016-07-05  5:23 ` [PATCH 03/10] dt-bindings: Add bindings for phy-da8xx-usb Kishon Vijay Abraham I
                   ` (8 subsequent siblings)
  10 siblings, 0 replies; 14+ messages in thread
From: Kishon Vijay Abraham I @ 2016-07-05  5:23 UTC (permalink / raw)
  To: gregkh; +Cc: kishon, linux-kernel

From: David Lechner <david@lechnology.com>

The initial use for this is for PHYs that have a mode related to USB OTG.
There are several SoCs (e.g. TI OMAP and DA8xx) that have a mode setting
in the USB PHY to override OTG VBUS and ID signals.

Of course, the enum can be expaned in the future to include modes for
other types of PHYs as well.

Suggested-by: Kishon Vijay Abraham I <kishon@ti.com>
Signed-off-by: David Lechner <david@lechnology.com>
Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
---
 drivers/phy/phy-core.c  |   15 +++++++++++++++
 include/linux/phy/phy.h |   17 +++++++++++++++++
 2 files changed, 32 insertions(+)

diff --git a/drivers/phy/phy-core.c b/drivers/phy/phy-core.c
index b72e9a3..8eca906 100644
--- a/drivers/phy/phy-core.c
+++ b/drivers/phy/phy-core.c
@@ -342,6 +342,21 @@ int phy_power_off(struct phy *phy)
 }
 EXPORT_SYMBOL_GPL(phy_power_off);
 
+int phy_set_mode(struct phy *phy, enum phy_mode mode)
+{
+	int ret;
+
+	if (!phy || !phy->ops->set_mode)
+		return 0;
+
+	mutex_lock(&phy->mutex);
+	ret = phy->ops->set_mode(phy, mode);
+	mutex_unlock(&phy->mutex);
+
+	return ret;
+}
+EXPORT_SYMBOL_GPL(phy_set_mode);
+
 /**
  * _of_phy_get() - lookup and obtain a reference to a phy by phandle
  * @np: device_node for which to get the phy
diff --git a/include/linux/phy/phy.h b/include/linux/phy/phy.h
index a810f2a..f08b672 100644
--- a/include/linux/phy/phy.h
+++ b/include/linux/phy/phy.h
@@ -22,12 +22,20 @@
 
 struct phy;
 
+enum phy_mode {
+	PHY_MODE_INVALID,
+	PHY_MODE_USB_HOST,
+	PHY_MODE_USB_DEVICE,
+	PHY_MODE_USB_OTG,
+};
+
 /**
  * struct phy_ops - set of function pointers for performing phy operations
  * @init: operation to be performed for initializing phy
  * @exit: operation to be performed while exiting
  * @power_on: powering on the phy
  * @power_off: powering off the phy
+ * @set_mode: set the mode of the phy
  * @owner: the module owner containing the ops
  */
 struct phy_ops {
@@ -35,6 +43,7 @@ struct phy_ops {
 	int	(*exit)(struct phy *phy);
 	int	(*power_on)(struct phy *phy);
 	int	(*power_off)(struct phy *phy);
+	int	(*set_mode)(struct phy *phy, enum phy_mode mode);
 	struct module *owner;
 };
 
@@ -126,6 +135,7 @@ int phy_init(struct phy *phy);
 int phy_exit(struct phy *phy);
 int phy_power_on(struct phy *phy);
 int phy_power_off(struct phy *phy);
+int phy_set_mode(struct phy *phy, enum phy_mode mode);
 static inline int phy_get_bus_width(struct phy *phy)
 {
 	return phy->attrs.bus_width;
@@ -233,6 +243,13 @@ static inline int phy_power_off(struct phy *phy)
 	return -ENOSYS;
 }
 
+static inline int phy_set_mode(struct phy *phy, enum phy_mode mode)
+{
+	if (!phy)
+		return 0;
+	return -ENOSYS;
+}
+
 static inline int phy_get_bus_width(struct phy *phy)
 {
 	return -ENOSYS;
-- 
1.7.9.5

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

* [PATCH 03/10] dt-bindings: Add bindings for phy-da8xx-usb
  2016-07-05  5:23 [GIT PULL] phy: for 4.8 merge window Kishon Vijay Abraham I
  2016-07-05  5:23 ` [PATCH 01/10] phy: xgene: rename "enum phy_mode" to "enum xgene_phy_mode" Kishon Vijay Abraham I
  2016-07-05  5:23 ` [PATCH 02/10] phy: Add set_mode callback Kishon Vijay Abraham I
@ 2016-07-05  5:23 ` Kishon Vijay Abraham I
  2016-07-05  5:23 ` [PATCH 04/10] phy: da8xx-usb: new driver for DA8xx SoC USB PHY Kishon Vijay Abraham I
                   ` (7 subsequent siblings)
  10 siblings, 0 replies; 14+ messages in thread
From: Kishon Vijay Abraham I @ 2016-07-05  5:23 UTC (permalink / raw)
  To: gregkh; +Cc: kishon, linux-kernel

From: David Lechner <david@lechnology.com>

Device tree binding for new phy-da8xx-usb driver.

Signed-off-by: David Lechner <david@lechnology.com>
Acked-by: Rob Herring <robh@kernel.org>
Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
---
 .../devicetree/bindings/phy/phy-da8xx-usb.txt      |   40 ++++++++++++++++++++
 1 file changed, 40 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/phy/phy-da8xx-usb.txt

diff --git a/Documentation/devicetree/bindings/phy/phy-da8xx-usb.txt b/Documentation/devicetree/bindings/phy/phy-da8xx-usb.txt
new file mode 100644
index 0000000..c26478b
--- /dev/null
+++ b/Documentation/devicetree/bindings/phy/phy-da8xx-usb.txt
@@ -0,0 +1,40 @@
+TI DA8xx/OMAP-L1xx/AM18xx USB PHY
+
+Required properties:
+ - compatible: must be "ti,da830-usb-phy".
+ - #phy-cells: must be 1.
+
+This device controls the PHY for both the USB 1.1 OHCI and USB 2.0 OTG
+controllers on DA8xx SoCs. Consumers of this device should use index 0 for
+the USB 2.0 phy device and index 1 for the USB 1.1 phy device.
+
+It also requires a "syscon" node with compatible = "ti,da830-cfgchip", "syscon"
+to access the CFGCHIP2 register.
+
+Example:
+
+	cfgchip: cfgchip@1417c {
+		compatible = "ti,da830-cfgchip", "syscon";
+		reg = <0x1417c 0x14>;
+	};
+
+	usb_phy: usb-phy {
+		compatible = "ti,da830-usb-phy";
+		#phy-cells = <1>;
+	};
+
+	usb20: usb@200000 {
+		compatible = "ti,da830-musb";
+		reg = <0x200000 0x1000>;
+		interrupts = <58>;
+		phys = <&usb_phy 0>;
+		phy-names = "usb-phy";
+	};
+
+	usb11: usb@225000 {
+		compatible = "ti,da830-ohci";
+		reg = <0x225000 0x1000>;
+		interrupts = <59>;
+		phys = <&usb_phy 1>;
+		phy-names = "usb-phy";
+	};
-- 
1.7.9.5

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

* [PATCH 04/10] phy: da8xx-usb: new driver for DA8xx SoC USB PHY
  2016-07-05  5:23 [GIT PULL] phy: for 4.8 merge window Kishon Vijay Abraham I
                   ` (2 preceding siblings ...)
  2016-07-05  5:23 ` [PATCH 03/10] dt-bindings: Add bindings for phy-da8xx-usb Kishon Vijay Abraham I
@ 2016-07-05  5:23 ` Kishon Vijay Abraham I
  2016-07-15 21:14   ` Arnd Bergmann
  2016-07-05  5:23 ` [PATCH 05/10] phy: rockchip-usb: should be a child device of the GRF Kishon Vijay Abraham I
                   ` (6 subsequent siblings)
  10 siblings, 1 reply; 14+ messages in thread
From: Kishon Vijay Abraham I @ 2016-07-05  5:23 UTC (permalink / raw)
  To: gregkh; +Cc: kishon, linux-kernel

From: David Lechner <david@lechnology.com>

This is a new phy driver for the SoC USB controllers on the TI DA8xx
family of microcontrollers. The USB 1.1 PHY is just a simple on/off.
The USB 2.0 PHY also allows overriding the VBUS and ID pins.

Signed-off-by: David Lechner <david@lechnology.com>
Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
---
 drivers/phy/Kconfig         |   10 ++
 drivers/phy/Makefile        |    1 +
 drivers/phy/phy-da8xx-usb.c |  245 +++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 256 insertions(+)
 create mode 100644 drivers/phy/phy-da8xx-usb.c

diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig
index b869b98..02afc624 100644
--- a/drivers/phy/Kconfig
+++ b/drivers/phy/Kconfig
@@ -44,6 +44,16 @@ config ARMADA375_USBCLUSTER_PHY
 	depends on OF && HAS_IOMEM
 	select GENERIC_PHY
 
+config PHY_DA8XX_USB
+	tristate "TI DA8xx USB PHY Driver"
+	depends on ARCH_DAVINCI_DA8XX
+	select GENERIC_PHY
+	select MFD_SYSCON
+	help
+	  Enable this to support the USB PHY on DA8xx SoCs.
+
+	  This driver controls both the USB 1.1 PHY and the USB 2.0 PHY.
+
 config PHY_DM816X_USB
 	tristate "TI dm816x USB PHY driver"
 	depends on ARCH_OMAP2PLUS
diff --git a/drivers/phy/Makefile b/drivers/phy/Makefile
index 9c3e73c..fa8480e 100644
--- a/drivers/phy/Makefile
+++ b/drivers/phy/Makefile
@@ -6,6 +6,7 @@ obj-$(CONFIG_GENERIC_PHY)		+= phy-core.o
 obj-$(CONFIG_PHY_BCM_NS_USB2)		+= phy-bcm-ns-usb2.o
 obj-$(CONFIG_PHY_BERLIN_USB)		+= phy-berlin-usb.o
 obj-$(CONFIG_PHY_BERLIN_SATA)		+= phy-berlin-sata.o
+obj-$(CONFIG_PHY_DA8XX_USB)		+= phy-da8xx-usb.o
 obj-$(CONFIG_PHY_DM816X_USB)		+= phy-dm816x-usb.o
 obj-$(CONFIG_ARMADA375_USBCLUSTER_PHY)	+= phy-armada375-usb2.o
 obj-$(CONFIG_BCM_KONA_USB2_PHY)		+= phy-bcm-kona-usb2.o
diff --git a/drivers/phy/phy-da8xx-usb.c b/drivers/phy/phy-da8xx-usb.c
new file mode 100644
index 0000000..b2e59b6
--- /dev/null
+++ b/drivers/phy/phy-da8xx-usb.c
@@ -0,0 +1,245 @@
+/*
+ * phy-da8xx-usb - TI DaVinci DA8xx USB PHY driver
+ *
+ * Copyright (C) 2016 David Lechner <david@lechnology.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * 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/io.h>
+#include <linux/of.h>
+#include <linux/mfd/da8xx-cfgchip.h>
+#include <linux/mfd/syscon.h>
+#include <linux/module.h>
+#include <linux/phy/phy.h>
+#include <linux/platform_device.h>
+#include <linux/regmap.h>
+
+struct da8xx_usb_phy {
+	struct phy_provider	*phy_provider;
+	struct phy		*usb11_phy;
+	struct phy		*usb20_phy;
+	struct clk		*usb11_clk;
+	struct clk		*usb20_clk;
+	struct regmap		*regmap;
+};
+
+static int da8xx_usb11_phy_power_on(struct phy *phy)
+{
+	struct da8xx_usb_phy *d_phy = phy_get_drvdata(phy);
+	int ret;
+
+	ret = clk_prepare_enable(d_phy->usb11_clk);
+	if (ret)
+		return ret;
+
+	regmap_write_bits(d_phy->regmap, CFGCHIP(2), CFGCHIP2_USB1SUSPENDM,
+			  CFGCHIP2_USB1SUSPENDM);
+
+	return 0;
+}
+
+static int da8xx_usb11_phy_power_off(struct phy *phy)
+{
+	struct da8xx_usb_phy *d_phy = phy_get_drvdata(phy);
+
+	regmap_write_bits(d_phy->regmap, CFGCHIP(2), CFGCHIP2_USB1SUSPENDM, 0);
+
+	clk_disable_unprepare(d_phy->usb11_clk);
+
+	return 0;
+}
+
+static const struct phy_ops da8xx_usb11_phy_ops = {
+	.power_on	= da8xx_usb11_phy_power_on,
+	.power_off	= da8xx_usb11_phy_power_off,
+	.owner		= THIS_MODULE,
+};
+
+static int da8xx_usb20_phy_power_on(struct phy *phy)
+{
+	struct da8xx_usb_phy *d_phy = phy_get_drvdata(phy);
+	int ret;
+
+	ret = clk_prepare_enable(d_phy->usb20_clk);
+	if (ret)
+		return ret;
+
+	regmap_write_bits(d_phy->regmap, CFGCHIP(2), CFGCHIP2_OTGPWRDN, 0);
+
+	return 0;
+}
+
+static int da8xx_usb20_phy_power_off(struct phy *phy)
+{
+	struct da8xx_usb_phy *d_phy = phy_get_drvdata(phy);
+
+	regmap_write_bits(d_phy->regmap, CFGCHIP(2), CFGCHIP2_OTGPWRDN,
+			  CFGCHIP2_OTGPWRDN);
+
+	clk_disable_unprepare(d_phy->usb20_clk);
+
+	return 0;
+}
+
+static int da8xx_usb20_phy_set_mode(struct phy *phy, enum phy_mode mode)
+{
+	struct da8xx_usb_phy *d_phy = phy_get_drvdata(phy);
+	u32 val;
+
+	switch (mode) {
+	case PHY_MODE_USB_HOST:		/* Force VBUS valid, ID = 0 */
+		val = CFGCHIP2_OTGMODE_FORCE_HOST;
+		break;
+	case PHY_MODE_USB_DEVICE:	/* Force VBUS valid, ID = 1 */
+		val = CFGCHIP2_OTGMODE_FORCE_DEVICE;
+		break;
+	case PHY_MODE_USB_OTG:	/* Don't override the VBUS/ID comparators */
+		val = CFGCHIP2_OTGMODE_NO_OVERRIDE;
+		break;
+	default:
+		return -EINVAL;
+	}
+
+	regmap_write_bits(d_phy->regmap, CFGCHIP(2), CFGCHIP2_OTGMODE_MASK,
+			  val);
+
+	return 0;
+}
+
+static const struct phy_ops da8xx_usb20_phy_ops = {
+	.power_on	= da8xx_usb20_phy_power_on,
+	.power_off	= da8xx_usb20_phy_power_off,
+	.set_mode	= da8xx_usb20_phy_set_mode,
+	.owner		= THIS_MODULE,
+};
+
+static struct phy *da8xx_usb_phy_of_xlate(struct device *dev,
+					 struct of_phandle_args *args)
+{
+	struct da8xx_usb_phy *d_phy = dev_get_drvdata(dev);
+
+	if (!d_phy)
+		return ERR_PTR(-ENODEV);
+
+	switch (args->args[0]) {
+	case 0:
+		return d_phy->usb20_phy;
+	case 1:
+		return d_phy->usb11_phy;
+	default:
+		return ERR_PTR(-EINVAL);
+	}
+}
+
+static int da8xx_usb_phy_probe(struct platform_device *pdev)
+{
+	struct device		*dev = &pdev->dev;
+	struct device_node	*node = dev->of_node;
+	struct da8xx_usb_phy	*d_phy;
+
+	d_phy = devm_kzalloc(dev, sizeof(*d_phy), GFP_KERNEL);
+	if (!d_phy)
+		return -ENOMEM;
+
+	if (node)
+		d_phy->regmap = syscon_regmap_lookup_by_compatible(
+							"ti,da830-cfgchip");
+	else
+		d_phy->regmap = syscon_regmap_lookup_by_pdevname("syscon.0");
+	if (IS_ERR(d_phy->regmap)) {
+		dev_err(dev, "Failed to get syscon\n");
+		return PTR_ERR(d_phy->regmap);
+	}
+
+	d_phy->usb11_clk = devm_clk_get(dev, "usb11_phy");
+	if (IS_ERR(d_phy->usb11_clk)) {
+		dev_err(dev, "Failed to get usb11_phy clock\n");
+		return PTR_ERR(d_phy->usb11_clk);
+	}
+
+	d_phy->usb20_clk = devm_clk_get(dev, "usb20_phy");
+	if (IS_ERR(d_phy->usb20_clk)) {
+		dev_err(dev, "Failed to get usb20_phy clock\n");
+		return PTR_ERR(d_phy->usb20_clk);
+	}
+
+	d_phy->usb11_phy = devm_phy_create(dev, node, &da8xx_usb11_phy_ops);
+	if (IS_ERR(d_phy->usb11_phy)) {
+		dev_err(dev, "Failed to create usb11 phy\n");
+		return PTR_ERR(d_phy->usb11_phy);
+	}
+
+	d_phy->usb20_phy = devm_phy_create(dev, node, &da8xx_usb20_phy_ops);
+	if (IS_ERR(d_phy->usb20_phy)) {
+		dev_err(dev, "Failed to create usb20 phy\n");
+		return PTR_ERR(d_phy->usb20_phy);
+	}
+
+	platform_set_drvdata(pdev, d_phy);
+	phy_set_drvdata(d_phy->usb11_phy, d_phy);
+	phy_set_drvdata(d_phy->usb20_phy, d_phy);
+
+	if (node) {
+		d_phy->phy_provider = devm_of_phy_provider_register(dev,
+							da8xx_usb_phy_of_xlate);
+		if (IS_ERR(d_phy->phy_provider)) {
+			dev_err(dev, "Failed to create phy provider\n");
+			return PTR_ERR(d_phy->phy_provider);
+		}
+	} else {
+		int ret;
+
+		ret = phy_create_lookup(d_phy->usb11_phy, "usb-phy", "ohci.0");
+		if (ret)
+			dev_warn(dev, "Failed to create usb11 phy lookup\n");
+		ret = phy_create_lookup(d_phy->usb20_phy, "usb-phy",
+					"musb-da8xx");
+		if (ret)
+			dev_warn(dev, "Failed to create usb20 phy lookup\n");
+	}
+
+	return 0;
+}
+
+static int da8xx_usb_phy_remove(struct platform_device *pdev)
+{
+	struct da8xx_usb_phy *d_phy = platform_get_drvdata(pdev);
+
+	if (!pdev->dev.of_node) {
+		phy_remove_lookup(d_phy->usb20_phy, "usb-phy", "musb-da8xx");
+		phy_remove_lookup(d_phy->usb11_phy, "usb-phy", "ohci.0");
+	}
+
+	return 0;
+}
+
+static const struct of_device_id da8xx_usb_phy_ids[] = {
+	{ .compatible = "ti,da830-usb-phy" },
+	{ }
+};
+MODULE_DEVICE_TABLE(of, da8xx_usb_phy_ids);
+
+static struct platform_driver da8xx_usb_phy_driver = {
+	.probe	= da8xx_usb_phy_probe,
+	.remove	= da8xx_usb_phy_remove,
+	.driver	= {
+		.name	= "da8xx-usb-phy",
+		.of_match_table = da8xx_usb_phy_ids,
+	},
+};
+
+module_platform_driver(da8xx_usb_phy_driver);
+
+MODULE_ALIAS("platform:da8xx-usb-phy");
+MODULE_AUTHOR("David Lechner <david@lechnology.com>");
+MODULE_DESCRIPTION("TI DA8xx USB PHY driver");
+MODULE_LICENSE("GPL v2");
-- 
1.7.9.5

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

* [PATCH 05/10] phy: rockchip-usb: should be a child device of the GRF
  2016-07-05  5:23 [GIT PULL] phy: for 4.8 merge window Kishon Vijay Abraham I
                   ` (3 preceding siblings ...)
  2016-07-05  5:23 ` [PATCH 04/10] phy: da8xx-usb: new driver for DA8xx SoC USB PHY Kishon Vijay Abraham I
@ 2016-07-05  5:23 ` Kishon Vijay Abraham I
  2016-07-05  5:23 ` [PATCH 06/10] phy: phy-qcom-ufs-qmp-20nm: Remove site specific OOM error message Kishon Vijay Abraham I
                   ` (5 subsequent siblings)
  10 siblings, 0 replies; 14+ messages in thread
From: Kishon Vijay Abraham I @ 2016-07-05  5:23 UTC (permalink / raw)
  To: gregkh; +Cc: kishon, linux-kernel

From: Heiko Stuebner <heiko@sntech.de>

The usb-phy is fully enclosed in the general register files (GRF).
Therefore as seen from the device-tree it shouldn't be a separate
platform-device but instead a sub-device of the GRF - using the
simply-mfd mechanism.

As the usb-phy is part of the kernel for some releases now, we keep
the old (and now deprecated) binding for compatibility purposes.

Signed-off-by: Heiko Stuebner <heiko@sntech.de>
Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
---
 .../devicetree/bindings/phy/rockchip-usb-phy.txt   |   27 ++++++++++++--------
 drivers/phy/phy-rockchip-usb.c                     |   15 ++++++++---
 2 files changed, 29 insertions(+), 13 deletions(-)

diff --git a/Documentation/devicetree/bindings/phy/rockchip-usb-phy.txt b/Documentation/devicetree/bindings/phy/rockchip-usb-phy.txt
index 68498d5..cc6be96 100644
--- a/Documentation/devicetree/bindings/phy/rockchip-usb-phy.txt
+++ b/Documentation/devicetree/bindings/phy/rockchip-usb-phy.txt
@@ -5,11 +5,13 @@ Required properties:
      "rockchip,rk3066a-usb-phy"
      "rockchip,rk3188-usb-phy"
      "rockchip,rk3288-usb-phy"
- - rockchip,grf : phandle to the syscon managing the "general
-   register files"
  - #address-cells: should be 1
  - #size-cells: should be 0
 
+Deprecated properties:
+ - rockchip,grf : phandle to the syscon managing the "general
+   register files" - phy should be a child of the GRF instead
+
 Sub-nodes:
 Each PHY should be represented as a sub-node.
 
@@ -28,14 +30,19 @@ Optional Properties:
 
 Example:
 
-usbphy: phy {
-	compatible = "rockchip,rk3288-usb-phy";
-	rockchip,grf = <&grf>;
-	#address-cells = <1>;
-	#size-cells = <0>;
+grf: syscon@ff770000 {
+	compatible = "rockchip,rk3288-grf", "syscon", "simple-mfd";
+
+...
+
+	usbphy: phy {
+		compatible = "rockchip,rk3288-usb-phy";
+		#address-cells = <1>;
+		#size-cells = <0>;
 
-	usbphy0: usb-phy0 {
-		#phy-cells = <0>;
-		reg = <0x320>;
+		usbphy0: usb-phy0 {
+			#phy-cells = <0>;
+			reg = <0x320>;
+		};
 	};
 };
diff --git a/drivers/phy/phy-rockchip-usb.c b/drivers/phy/phy-rockchip-usb.c
index d60b149..e66b5bf 100644
--- a/drivers/phy/phy-rockchip-usb.c
+++ b/drivers/phy/phy-rockchip-usb.c
@@ -397,8 +397,13 @@ static int rockchip_usb_phy_probe(struct platform_device *pdev)
 	phy_base->pdata = match->data;
 
 	phy_base->dev = dev;
-	phy_base->reg_base = syscon_regmap_lookup_by_phandle(dev->of_node,
-							     "rockchip,grf");
+	phy_base->reg_base = ERR_PTR(-ENODEV);
+	if (dev->parent && dev->parent->of_node)
+		phy_base->reg_base = syscon_node_to_regmap(
+						dev->parent->of_node);
+	if (IS_ERR(phy_base->reg_base))
+		phy_base->reg_base = syscon_regmap_lookup_by_phandle(
+						dev->of_node, "rockchip,grf");
 	if (IS_ERR(phy_base->reg_base)) {
 		dev_err(&pdev->dev, "Missing rockchip,grf property\n");
 		return PTR_ERR(phy_base->reg_base);
@@ -463,7 +468,11 @@ static int __init rockchip_init_usb_uart(void)
 		return -ENOTSUPP;
 	}
 
-	grf = syscon_regmap_lookup_by_phandle(np, "rockchip,grf");
+	grf = ERR_PTR(-ENODEV);
+	if (np->parent)
+		grf = syscon_node_to_regmap(np->parent);
+	if (IS_ERR(grf))
+		grf = syscon_regmap_lookup_by_phandle(np, "rockchip,grf");
 	if (IS_ERR(grf)) {
 		pr_err("%s: Missing rockchip,grf property, %lu\n",
 		       __func__, PTR_ERR(grf));
-- 
1.7.9.5

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

* [PATCH 06/10] phy: phy-qcom-ufs-qmp-20nm: Remove site specific OOM error message
  2016-07-05  5:23 [GIT PULL] phy: for 4.8 merge window Kishon Vijay Abraham I
                   ` (4 preceding siblings ...)
  2016-07-05  5:23 ` [PATCH 05/10] phy: rockchip-usb: should be a child device of the GRF Kishon Vijay Abraham I
@ 2016-07-05  5:23 ` Kishon Vijay Abraham I
  2016-07-05  5:23 ` [PATCH 07/10] phy: phy-qcom-ufs-qmp-14nm: " Kishon Vijay Abraham I
                   ` (4 subsequent siblings)
  10 siblings, 0 replies; 14+ messages in thread
From: Kishon Vijay Abraham I @ 2016-07-05  5:23 UTC (permalink / raw)
  To: gregkh; +Cc: kishon, linux-kernel

From: Peter Griffin <peter.griffin@linaro.org>

kzalloc will issue its own error message including a dump_stack()
so remote the site specific message.

Signed-off-by: Peter Griffin <peter.griffin@linaro.org>
Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
---
 drivers/phy/phy-qcom-ufs-qmp-20nm.c |    1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/phy/phy-qcom-ufs-qmp-20nm.c b/drivers/phy/phy-qcom-ufs-qmp-20nm.c
index b16ea77..770087a 100644
--- a/drivers/phy/phy-qcom-ufs-qmp-20nm.c
+++ b/drivers/phy/phy-qcom-ufs-qmp-20nm.c
@@ -196,7 +196,6 @@ static int ufs_qcom_phy_qmp_20nm_probe(struct platform_device *pdev)
 
 	phy = devm_kzalloc(dev, sizeof(*phy), GFP_KERNEL);
 	if (!phy) {
-		dev_err(dev, "%s: failed to allocate phy\n", __func__);
 		err = -ENOMEM;
 		goto out;
 	}
-- 
1.7.9.5

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

* [PATCH 07/10] phy: phy-qcom-ufs-qmp-14nm: Remove site specific OOM error message
  2016-07-05  5:23 [GIT PULL] phy: for 4.8 merge window Kishon Vijay Abraham I
                   ` (5 preceding siblings ...)
  2016-07-05  5:23 ` [PATCH 06/10] phy: phy-qcom-ufs-qmp-20nm: Remove site specific OOM error message Kishon Vijay Abraham I
@ 2016-07-05  5:23 ` Kishon Vijay Abraham I
  2016-07-05  5:23 ` [PATCH 08/10] phy-sun4i-usb: Add workaround for missing Vbus det interrupts on A31 Kishon Vijay Abraham I
                   ` (3 subsequent siblings)
  10 siblings, 0 replies; 14+ messages in thread
From: Kishon Vijay Abraham I @ 2016-07-05  5:23 UTC (permalink / raw)
  To: gregkh; +Cc: kishon, linux-kernel

From: Peter Griffin <peter.griffin@linaro.org>

kzalloc will issue its own error message including a dump_stack()
so remote the site specific message.

Signed-off-by: Peter Griffin <peter.griffin@linaro.org>
Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
---
 drivers/phy/phy-qcom-ufs-qmp-14nm.c |    1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/phy/phy-qcom-ufs-qmp-14nm.c b/drivers/phy/phy-qcom-ufs-qmp-14nm.c
index 56631e7..6ee5149 100644
--- a/drivers/phy/phy-qcom-ufs-qmp-14nm.c
+++ b/drivers/phy/phy-qcom-ufs-qmp-14nm.c
@@ -140,7 +140,6 @@ static int ufs_qcom_phy_qmp_14nm_probe(struct platform_device *pdev)
 
 	phy = devm_kzalloc(dev, sizeof(*phy), GFP_KERNEL);
 	if (!phy) {
-		dev_err(dev, "%s: failed to allocate phy\n", __func__);
 		err = -ENOMEM;
 		goto out;
 	}
-- 
1.7.9.5

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

* [PATCH 08/10] phy-sun4i-usb: Add workaround for missing Vbus det interrupts on A31
  2016-07-05  5:23 [GIT PULL] phy: for 4.8 merge window Kishon Vijay Abraham I
                   ` (6 preceding siblings ...)
  2016-07-05  5:23 ` [PATCH 07/10] phy: phy-qcom-ufs-qmp-14nm: " Kishon Vijay Abraham I
@ 2016-07-05  5:23 ` Kishon Vijay Abraham I
  2016-07-05  5:23 ` [PATCH 09/10] phy: rockhip-usb: use devm_add_action_or_reset() Kishon Vijay Abraham I
                   ` (2 subsequent siblings)
  10 siblings, 0 replies; 14+ messages in thread
From: Kishon Vijay Abraham I @ 2016-07-05  5:23 UTC (permalink / raw)
  To: gregkh; +Cc: kishon, linux-kernel

From: Hans de Goede <hdegoede@redhat.com>

The A31 companion pmic (axp221) does not generate vbus change interrupts
when the board is driving vbus, so we must poll when using the pmic for
vbus-det _and_ we're driving vbus.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Acked-by: Kishon Vijay Abraham I <kishon@ti.com>
Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
---
 drivers/phy/phy-sun4i-usb.c |   34 ++++++++++++++++++++++++----------
 1 file changed, 24 insertions(+), 10 deletions(-)

diff --git a/drivers/phy/phy-sun4i-usb.c b/drivers/phy/phy-sun4i-usb.c
index de3101f..0a45bc6 100644
--- a/drivers/phy/phy-sun4i-usb.c
+++ b/drivers/phy/phy-sun4i-usb.c
@@ -94,6 +94,7 @@
 
 enum sun4i_usb_phy_type {
 	sun4i_a10_phy,
+	sun6i_a31_phy,
 	sun8i_a33_phy,
 	sun8i_h3_phy,
 };
@@ -122,7 +123,6 @@ struct sun4i_usb_phy_data {
 	/* phy0 / otg related variables */
 	struct extcon_dev *extcon;
 	bool phy0_init;
-	bool phy0_poll;
 	struct gpio_desc *id_det_gpio;
 	struct gpio_desc *vbus_det_gpio;
 	struct power_supply *vbus_power_supply;
@@ -343,6 +343,24 @@ static bool sun4i_usb_phy0_have_vbus_det(struct sun4i_usb_phy_data *data)
 	return data->vbus_det_gpio || data->vbus_power_supply;
 }
 
+static bool sun4i_usb_phy0_poll(struct sun4i_usb_phy_data *data)
+{
+	if ((data->id_det_gpio && data->id_det_irq <= 0) ||
+	    (data->vbus_det_gpio && data->vbus_det_irq <= 0))
+		return true;
+
+	/*
+	 * The A31 companion pmic (axp221) does not generate vbus change
+	 * interrupts when the board is driving vbus, so we must poll
+	 * when using the pmic for vbus-det _and_ we're driving vbus.
+	 */
+	if (data->cfg->type == sun6i_a31_phy &&
+	    data->vbus_power_supply && data->phys[0].regulator_on)
+		return true;
+
+	return false;
+}
+
 static int sun4i_usb_phy_power_on(struct phy *_phy)
 {
 	struct sun4i_usb_phy *phy = phy_get_drvdata(_phy);
@@ -364,7 +382,7 @@ static int sun4i_usb_phy_power_on(struct phy *_phy)
 	phy->regulator_on = true;
 
 	/* We must report Vbus high within OTG_TIME_A_WAIT_VRISE msec. */
-	if (phy->index == 0 && data->vbus_det_gpio && data->phy0_poll)
+	if (phy->index == 0 && sun4i_usb_phy0_poll(data))
 		mod_delayed_work(system_wq, &data->detect, DEBOUNCE_TIME);
 
 	return 0;
@@ -385,7 +403,7 @@ static int sun4i_usb_phy_power_off(struct phy *_phy)
 	 * phy0 vbus typically slowly discharges, sometimes this causes the
 	 * Vbus gpio to not trigger an edge irq on Vbus off, so force a rescan.
 	 */
-	if (phy->index == 0 && data->vbus_det_gpio && !data->phy0_poll)
+	if (phy->index == 0 && !sun4i_usb_phy0_poll(data))
 		mod_delayed_work(system_wq, &data->detect, POLL_TIME);
 
 	return 0;
@@ -468,7 +486,7 @@ static void sun4i_usb_phy0_id_vbus_det_scan(struct work_struct *work)
 	if (vbus_notify)
 		extcon_set_cable_state_(data->extcon, EXTCON_USB, vbus_det);
 
-	if (data->phy0_poll)
+	if (sun4i_usb_phy0_poll(data))
 		queue_delayed_work(system_wq, &data->detect, POLL_TIME);
 }
 
@@ -644,11 +662,6 @@ static int sun4i_usb_phy_probe(struct platform_device *pdev)
 	}
 
 	data->id_det_irq = gpiod_to_irq(data->id_det_gpio);
-	data->vbus_det_irq = gpiod_to_irq(data->vbus_det_gpio);
-	if ((data->id_det_gpio && data->id_det_irq <= 0) ||
-	    (data->vbus_det_gpio && data->vbus_det_irq <= 0))
-		data->phy0_poll = true;
-
 	if (data->id_det_irq > 0) {
 		ret = devm_request_irq(dev, data->id_det_irq,
 				sun4i_usb_phy0_id_vbus_det_irq,
@@ -660,6 +673,7 @@ static int sun4i_usb_phy_probe(struct platform_device *pdev)
 		}
 	}
 
+	data->vbus_det_irq = gpiod_to_irq(data->vbus_det_gpio);
 	if (data->vbus_det_irq > 0) {
 		ret = devm_request_irq(dev, data->vbus_det_irq,
 				sun4i_usb_phy0_id_vbus_det_irq,
@@ -711,7 +725,7 @@ static const struct sun4i_usb_phy_cfg sun5i_a13_cfg = {
 
 static const struct sun4i_usb_phy_cfg sun6i_a31_cfg = {
 	.num_phys = 3,
-	.type = sun4i_a10_phy,
+	.type = sun6i_a31_phy,
 	.disc_thresh = 3,
 	.phyctl_offset = REG_PHYCTL_A10,
 	.dedicated_clocks = true,
-- 
1.7.9.5

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

* [PATCH 09/10] phy: rockhip-usb: use devm_add_action_or_reset()
  2016-07-05  5:23 [GIT PULL] phy: for 4.8 merge window Kishon Vijay Abraham I
                   ` (7 preceding siblings ...)
  2016-07-05  5:23 ` [PATCH 08/10] phy-sun4i-usb: Add workaround for missing Vbus det interrupts on A31 Kishon Vijay Abraham I
@ 2016-07-05  5:23 ` Kishon Vijay Abraham I
  2016-07-05  5:23 ` [PATCH 10/10] phy: rcar-gen3-usb2: fix mutex_lock calling in interrupt Kishon Vijay Abraham I
  2016-07-14  3:04 ` [GIT PULL] phy: for 4.8 merge window Greg KH
  10 siblings, 0 replies; 14+ messages in thread
From: Kishon Vijay Abraham I @ 2016-07-05  5:23 UTC (permalink / raw)
  To: gregkh; +Cc: kishon, linux-kernel

From: Sudip Mukherjee <sudipm.mukherjee@gmail.com>

If devm_add_action() fails we are explicitly calling the cleanup to free
the resources allocated.  Lets use the helper devm_add_action_or_reset()
and return directly in case of error, as we know that the cleanup function
has been already called by the helper if there was any error.

Signed-off-by: Sudip Mukherjee <sudip.mukherjee@codethink.co.uk>
Reviewed-by: Heiko Stuebner <heiko@sntech.de>
Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
---
 drivers/phy/phy-rockchip-usb.c |    8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/drivers/phy/phy-rockchip-usb.c b/drivers/phy/phy-rockchip-usb.c
index e66b5bf..2a7381f 100644
--- a/drivers/phy/phy-rockchip-usb.c
+++ b/drivers/phy/phy-rockchip-usb.c
@@ -236,9 +236,10 @@ static int rockchip_usb_phy_init(struct rockchip_usb_phy_base *base,
 			goto err_clk_prov;
 	}
 
-	err = devm_add_action(base->dev, rockchip_usb_phy_action, rk_phy);
+	err = devm_add_action_or_reset(base->dev, rockchip_usb_phy_action,
+				       rk_phy);
 	if (err)
-		goto err_devm_action;
+		return err;
 
 	rk_phy->phy = devm_phy_create(base->dev, child, &ops);
 	if (IS_ERR(rk_phy->phy)) {
@@ -256,9 +257,6 @@ static int rockchip_usb_phy_init(struct rockchip_usb_phy_base *base,
 	else
 		return rockchip_usb_phy_power(rk_phy, 1);
 
-err_devm_action:
-	if (!rk_phy->uart_enabled)
-		of_clk_del_provider(child);
 err_clk_prov:
 	if (!rk_phy->uart_enabled)
 		clk_unregister(rk_phy->clk480m);
-- 
1.7.9.5

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

* [PATCH 10/10] phy: rcar-gen3-usb2: fix mutex_lock calling in interrupt
  2016-07-05  5:23 [GIT PULL] phy: for 4.8 merge window Kishon Vijay Abraham I
                   ` (8 preceding siblings ...)
  2016-07-05  5:23 ` [PATCH 09/10] phy: rockhip-usb: use devm_add_action_or_reset() Kishon Vijay Abraham I
@ 2016-07-05  5:23 ` Kishon Vijay Abraham I
  2016-07-14  3:04 ` [GIT PULL] phy: for 4.8 merge window Greg KH
  10 siblings, 0 replies; 14+ messages in thread
From: Kishon Vijay Abraham I @ 2016-07-05  5:23 UTC (permalink / raw)
  To: gregkh; +Cc: kishon, linux-kernel

From: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>

This patch fixes an issue that the extcon_set_cable_state_() is possible
to cause "BUG: scheduling while atomic" because this driver calls
extcon_set_cable_state_() in the interrupt handler and mutex_lock()
is possible to be called by like the following call trace.
So, this patch adds a workqueue function to resolve this issue.

[    9.706504] BUG: scheduling while atomic: systemd-journal/25893/0x00010303
[    9.714569] Modules linked in:
[    9.717629] CPU: 0 PID: 25893 Comm: systemd-journal Not tainted 4.7.0-rc4+ #86
[    9.724844] Hardware name: Renesas Salvator-X board based on r8a7795 (DT)
[    9.731624] Call trace:
[    9.734077] [<ffff0000080889f0>] dump_backtrace+0x0/0x1a8
[    9.739470] [<ffff000008088bac>] show_stack+0x14/0x20
[    9.744520] [<ffff000008348ab4>] dump_stack+0x94/0xb8
[    9.749568] [<ffff0000080da18c>] __schedule_bug+0x44/0x58
[    9.754966] [<ffff0000087c6394>] __schedule+0x4e4/0x598
[    9.760185] [<ffff0000087c6484>] schedule+0x3c/0xa8
[    9.765057] [<ffff0000087c6928>] schedule_preempt_disabled+0x20/0x38
[    9.771408] [<ffff0000080f20dc>] mutex_optimistic_spin+0x18c/0x1d0
[    9.777583] [<ffff0000087c7ef0>] __mutex_lock_slowpath+0x38/0x140
[    9.783669] [<ffff0000087c803c>] mutex_lock+0x44/0x60
[    9.788717] [<ffff00000834ca48>] kobject_uevent_env+0x250/0x500
[    9.794634] [<ffff0000086ae8c0>] extcon_update_state+0x220/0x298
[    9.800634] [<ffff0000086ae9d8>] extcon_set_cable_state_+0x78/0x88
[    9.806812] [<ffff000008376004>] rcar_gen3_device_recognition+0x5c/0xe0
[    9.813420] [<ffff0000083761bc>] rcar_gen3_phy_usb2_irq+0x3c/0x48
[    9.819509] [<ffff0000080fae94>] handle_irq_event_percpu+0x94/0x140
[    9.825769] [<ffff0000080faf88>] handle_irq_event+0x48/0x78
[    9.831334] [<ffff0000080fe620>] handle_fasteoi_irq+0xb8/0x1b0
[    9.837162] [<ffff0000080fa3c4>] generic_handle_irq+0x24/0x38
[    9.842900] [<ffff0000080fa6fc>] __handle_domain_irq+0x5c/0xb8
[    9.848727] [<ffff000008081520>] gic_handle_irq+0x58/0xb0

Reported-by: Simon Horman <horms@verge.net.au>
Fixes: 2b38543c8db1 ("phy: rcar-gen3-usb2: add extcon support")
Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
---
 drivers/phy/phy-rcar-gen3-usb2.c |   26 ++++++++++++++++++++++----
 1 file changed, 22 insertions(+), 4 deletions(-)

diff --git a/drivers/phy/phy-rcar-gen3-usb2.c b/drivers/phy/phy-rcar-gen3-usb2.c
index 4be3f5d..31156c9 100644
--- a/drivers/phy/phy-rcar-gen3-usb2.c
+++ b/drivers/phy/phy-rcar-gen3-usb2.c
@@ -21,6 +21,7 @@
 #include <linux/phy/phy.h>
 #include <linux/platform_device.h>
 #include <linux/regulator/consumer.h>
+#include <linux/workqueue.h>
 
 /******* USB2.0 Host registers (original offset is +0x200) *******/
 #define USB2_INT_ENABLE		0x000
@@ -81,9 +82,25 @@ struct rcar_gen3_chan {
 	struct extcon_dev *extcon;
 	struct phy *phy;
 	struct regulator *vbus;
+	struct work_struct work;
+	bool extcon_host;
 	bool has_otg;
 };
 
+static void rcar_gen3_phy_usb2_work(struct work_struct *work)
+{
+	struct rcar_gen3_chan *ch = container_of(work, struct rcar_gen3_chan,
+						 work);
+
+	if (ch->extcon_host) {
+		extcon_set_cable_state_(ch->extcon, EXTCON_USB_HOST, true);
+		extcon_set_cable_state_(ch->extcon, EXTCON_USB, false);
+	} else {
+		extcon_set_cable_state_(ch->extcon, EXTCON_USB_HOST, false);
+		extcon_set_cable_state_(ch->extcon, EXTCON_USB, true);
+	}
+}
+
 static void rcar_gen3_set_host_mode(struct rcar_gen3_chan *ch, int host)
 {
 	void __iomem *usb2_base = ch->base;
@@ -130,8 +147,8 @@ static void rcar_gen3_init_for_host(struct rcar_gen3_chan *ch)
 	rcar_gen3_set_host_mode(ch, 1);
 	rcar_gen3_enable_vbus_ctrl(ch, 1);
 
-	extcon_set_cable_state_(ch->extcon, EXTCON_USB_HOST, true);
-	extcon_set_cable_state_(ch->extcon, EXTCON_USB, false);
+	ch->extcon_host = true;
+	schedule_work(&ch->work);
 }
 
 static void rcar_gen3_init_for_peri(struct rcar_gen3_chan *ch)
@@ -140,8 +157,8 @@ static void rcar_gen3_init_for_peri(struct rcar_gen3_chan *ch)
 	rcar_gen3_set_host_mode(ch, 0);
 	rcar_gen3_enable_vbus_ctrl(ch, 0);
 
-	extcon_set_cable_state_(ch->extcon, EXTCON_USB_HOST, false);
-	extcon_set_cable_state_(ch->extcon, EXTCON_USB, true);
+	ch->extcon_host = false;
+	schedule_work(&ch->work);
 }
 
 static bool rcar_gen3_check_id(struct rcar_gen3_chan *ch)
@@ -301,6 +318,7 @@ static int rcar_gen3_phy_usb2_probe(struct platform_device *pdev)
 	if (irq >= 0) {
 		int ret;
 
+		INIT_WORK(&channel->work, rcar_gen3_phy_usb2_work);
 		irq = devm_request_irq(dev, irq, rcar_gen3_phy_usb2_irq,
 				       IRQF_SHARED, dev_name(dev), channel);
 		if (irq < 0)
-- 
1.7.9.5

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

* Re: [GIT PULL] phy: for 4.8 merge window
  2016-07-05  5:23 [GIT PULL] phy: for 4.8 merge window Kishon Vijay Abraham I
                   ` (9 preceding siblings ...)
  2016-07-05  5:23 ` [PATCH 10/10] phy: rcar-gen3-usb2: fix mutex_lock calling in interrupt Kishon Vijay Abraham I
@ 2016-07-14  3:04 ` Greg KH
  10 siblings, 0 replies; 14+ messages in thread
From: Greg KH @ 2016-07-14  3:04 UTC (permalink / raw)
  To: Kishon Vijay Abraham I; +Cc: linux-kernel

On Tue, Jul 05, 2016 at 10:53:47AM +0530, Kishon Vijay Abraham I wrote:
> Hi Greg,
> 
> Please find the pull request for 4.8 merge window below.
> 
> Now the controller can configure the mode in which the PHY should
> work using the new phy_set_mode API. This was added by David Lechner
> required for da8xx-usb phy (used by MUSB). For this I created a signed
> tag 'phy-set-mode-v2' since the phy_set_mode API is called from musb
> driver which is not part of this pull request. This also adds a new
> phy driver for USB PHY in DA8xx SoC and includes other minor cleanups
> and fixes.
> 
> Consider merging this for the next merge window. Let me know if I have
> to change something.
> 
> The following changes since commit 04e59a0211ff012ba60c00baca673482570784e9:
> 
>   phy-sun4i-usb: Fix irq free conditions to match request conditions (2016-06-22 11:33:46 +0530)
> 
> are available in the git repository at:
> 
>   git://git.kernel.org/pub/scm/linux/kernel/git/kishon/linux-phy.git tags/phy-for-4.8-rc1

Now pulled, thanks.

greg k-h

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

* Re: [PATCH 04/10] phy: da8xx-usb: new driver for DA8xx SoC USB PHY
  2016-07-05  5:23 ` [PATCH 04/10] phy: da8xx-usb: new driver for DA8xx SoC USB PHY Kishon Vijay Abraham I
@ 2016-07-15 21:14   ` Arnd Bergmann
  2016-07-18  5:51     ` Kishon Vijay Abraham I
  0 siblings, 1 reply; 14+ messages in thread
From: Arnd Bergmann @ 2016-07-15 21:14 UTC (permalink / raw)
  To: Kishon Vijay Abraham I; +Cc: gregkh, linux-kernel

On Tuesday, July 5, 2016 10:53:51 AM CEST Kishon Vijay Abraham I wrote:
> From: David Lechner <david@lechnology.com>
> 
> This is a new phy driver for the SoC USB controllers on the TI DA8xx
> family of microcontrollers. The USB 1.1 PHY is just a simple on/off.
> The USB 2.0 PHY also allows overriding the VBUS and ID pins.
> 
> Signed-off-by: David Lechner <david@lechnology.com>
> Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>

This is now in linux-next, but fails to build:

> +#include <linux/clk.h>
> +#include <linux/io.h>
> +#include <linux/of.h>
> +#include <linux/mfd/da8xx-cfgchip.h>

drivers/phy/phy-da8xx-usb.c:19:37: fatal error: linux/mfd/da8xx-cfgchip.h: No such file or directory

	Arnd

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

* Re: [PATCH 04/10] phy: da8xx-usb: new driver for DA8xx SoC USB PHY
  2016-07-15 21:14   ` Arnd Bergmann
@ 2016-07-18  5:51     ` Kishon Vijay Abraham I
  0 siblings, 0 replies; 14+ messages in thread
From: Kishon Vijay Abraham I @ 2016-07-18  5:51 UTC (permalink / raw)
  To: Arnd Bergmann; +Cc: gregkh, linux-kernel

Hi Arnd,

On Saturday 16 July 2016 02:44 AM, Arnd Bergmann wrote:
> On Tuesday, July 5, 2016 10:53:51 AM CEST Kishon Vijay Abraham I wrote:
>> From: David Lechner <david@lechnology.com>
>>
>> This is a new phy driver for the SoC USB controllers on the TI DA8xx
>> family of microcontrollers. The USB 1.1 PHY is just a simple on/off.
>> The USB 2.0 PHY also allows overriding the VBUS and ID pins.
>>
>> Signed-off-by: David Lechner <david@lechnology.com>
>> Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
> 
> This is now in linux-next, but fails to build:
> 
>> +#include <linux/clk.h>
>> +#include <linux/io.h>
>> +#include <linux/of.h>
>> +#include <linux/mfd/da8xx-cfgchip.h>
> 
> drivers/phy/phy-da8xx-usb.c:19:37: fatal error: linux/mfd/da8xx-cfgchip.h: No such file or directory

I'll look at this.

Thanks
Kishon

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

end of thread, other threads:[~2016-07-18  5:51 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-07-05  5:23 [GIT PULL] phy: for 4.8 merge window Kishon Vijay Abraham I
2016-07-05  5:23 ` [PATCH 01/10] phy: xgene: rename "enum phy_mode" to "enum xgene_phy_mode" Kishon Vijay Abraham I
2016-07-05  5:23 ` [PATCH 02/10] phy: Add set_mode callback Kishon Vijay Abraham I
2016-07-05  5:23 ` [PATCH 03/10] dt-bindings: Add bindings for phy-da8xx-usb Kishon Vijay Abraham I
2016-07-05  5:23 ` [PATCH 04/10] phy: da8xx-usb: new driver for DA8xx SoC USB PHY Kishon Vijay Abraham I
2016-07-15 21:14   ` Arnd Bergmann
2016-07-18  5:51     ` Kishon Vijay Abraham I
2016-07-05  5:23 ` [PATCH 05/10] phy: rockchip-usb: should be a child device of the GRF Kishon Vijay Abraham I
2016-07-05  5:23 ` [PATCH 06/10] phy: phy-qcom-ufs-qmp-20nm: Remove site specific OOM error message Kishon Vijay Abraham I
2016-07-05  5:23 ` [PATCH 07/10] phy: phy-qcom-ufs-qmp-14nm: " Kishon Vijay Abraham I
2016-07-05  5:23 ` [PATCH 08/10] phy-sun4i-usb: Add workaround for missing Vbus det interrupts on A31 Kishon Vijay Abraham I
2016-07-05  5:23 ` [PATCH 09/10] phy: rockhip-usb: use devm_add_action_or_reset() Kishon Vijay Abraham I
2016-07-05  5:23 ` [PATCH 10/10] phy: rcar-gen3-usb2: fix mutex_lock calling in interrupt Kishon Vijay Abraham I
2016-07-14  3:04 ` [GIT PULL] phy: for 4.8 merge window Greg KH

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).