linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3 0/9] USB Device Controller support for BCM281xx
@ 2013-11-25 18:15 Matt Porter
  2013-11-25 18:15 ` [PATCH v3 1/9] phy: add phy_get_bus_width()/phy_set_bus_width() calls Matt Porter
                   ` (8 more replies)
  0 siblings, 9 replies; 28+ messages in thread
From: Matt Porter @ 2013-11-25 18:15 UTC (permalink / raw)
  To: Felipe Balbi, Greg Kroah-Hartman, Kishon Vijay Abraham I,
	Rob Herring, Pawel Moll, Mark Rutland, Kumar Gala, Ian Campbell,
	Christian Daudt, Paul Zimmerman
  Cc: Tomasz Figa, Kamil Debski, Kyungmin Park, Linux USB List,
	Linux ARM Kernel List, Linux Kernel Mailing List,
	Devicetree List, Linaro Patches

Changes since v2:
	- Rebased on 3.13-rc1
	- Fix braces in phy_get_bus_width()/phy_set_bus_width()
	- Drop generic phy conversion to use the same support from
	  the Exynos generic phy conversion series
	- Modify dts support to match the "device" phy name required
	  in the v3 Exynos generic phy conversion
	- Add s3c-hsotg phy_init/phy_exit support
	- Fix typo on reg property in kona phy binding
	- Replace phy driver reg struct with offset defines
	- Move phy soft reset to phy driver init
	- Fix dts node names to match ePAPR conventions

Changes since v1:
	- Convert USB phy driver to generic phy subsystem
	- Add phy bus width apis
	- Drop dwc2 phy bus width DT property in favor of querying the
	  phy provider for bus width
	- Add generic phy/clock properties to dwc2 DT binding
	- Add generic phy subsystem support to s3c-hsotg with the
	  existing usb phy and pdata phy methods as a fallback
	- Split bindings out to separate patches to match the latest
	  DT binding review guidelines

This series adds USB Device Controller support for the Broadcom
BCM281xx family of parts. BCM281xx contains a DWC2 OTG block and
s3c-hsotg is used to support UDC operation.

Part 1 adds phy bus width support to the generic phy subsystem

Parts 2-6 allows s3c-hsotg to build on non-Samsung platforms, supports
the dwc2 binding, adds phy_init/phy_exit support, and supports fetching
phy bus width using the generic phy layer.

Parts 7-8 add a generic phy binding and driver for the BCM Kona USB PHY.

Part 9 adds the DT nodes to enable UDC support on both BCM281xx boards
in the kernel.

This series depends on:
	- "Update Kona drivers to use clocks" series
	  https://lkml.org/lkml/2013/11/14/450
	- "Add new Exynos USB 2.0 PHY driver" series
	  https://lkml.org/lkml/2013/11/5/271

Matt Porter (9):
  phy: add phy_get_bus_width()/phy_set_bus_width() calls
  staging: dwc2: update DT binding to add generic clock/phy properties
  usb: gadget: s3c-hsotg: enable build for other platforms
  usb: gadget: s3c-hsotg: add snps,dwc2 compatible string
  usb: gadget: s3c-hsotg: use generic phy_init()/phy_exit() support
  usb: gadget: s3c-hsotg: get phy bus width from phy subsystem
  phy: add Broadcom Kona USB2 PHY DT binding
  phy: add Broadcom Kona USB2 PHY driver
  ARM: dts: add usb udc support to bcm281xx

 .../devicetree/bindings/phy/bcm-kona-usb2-phy.txt  |  15 ++
 Documentation/devicetree/bindings/staging/dwc2.txt |  10 ++
 arch/arm/boot/dts/bcm11351-brt.dts                 |   6 +
 arch/arm/boot/dts/bcm11351.dtsi                    |  18 +++
 arch/arm/boot/dts/bcm28155-ap.dts                  |   8 ++
 drivers/phy/Kconfig                                |   6 +
 drivers/phy/Makefile                               |   1 +
 drivers/phy/phy-bcm-kona-usb2.c                    | 158 +++++++++++++++++++++
 drivers/usb/gadget/Kconfig                         |   7 +-
 drivers/usb/gadget/s3c-hsotg.c                     |  22 ++-
 drivers/usb/gadget/s3c-hsotg.h                     |   1 +
 include/linux/phy/phy.h                            |  20 +++
 12 files changed, 265 insertions(+), 7 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/phy/bcm-kona-usb2-phy.txt
 create mode 100644 drivers/phy/phy-bcm-kona-usb2.c

-- 
1.8.4


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

* [PATCH v3 1/9] phy: add phy_get_bus_width()/phy_set_bus_width() calls
  2013-11-25 18:15 [PATCH v3 0/9] USB Device Controller support for BCM281xx Matt Porter
@ 2013-11-25 18:15 ` Matt Porter
  2013-11-26 10:16   ` Kishon Vijay Abraham I
  2013-11-25 18:16 ` [PATCH v3 2/9] staging: dwc2: update DT binding to add generic clock/phy properties Matt Porter
                   ` (7 subsequent siblings)
  8 siblings, 1 reply; 28+ messages in thread
From: Matt Porter @ 2013-11-25 18:15 UTC (permalink / raw)
  To: Felipe Balbi, Greg Kroah-Hartman, Kishon Vijay Abraham I,
	Rob Herring, Pawel Moll, Mark Rutland, Kumar Gala, Ian Campbell,
	Christian Daudt, Paul Zimmerman
  Cc: Tomasz Figa, Kamil Debski, Kyungmin Park, Linux USB List,
	Linux ARM Kernel List, Linux Kernel Mailing List,
	Devicetree List, Linaro Patches

This adds a pair of APIs that allows the generic PHY subsystem to
provide information on the PHY bus width. The PHY provider driver may
use phy_set_bus_width() to set the bus width that the PHY supports.
The controller driver may then use phy_get_bus_width() to fetch the
PHY bus width in order to properly configure the controller.

Signed-off-by: Matt Porter <matt.porter@linaro.org>
---
 include/linux/phy/phy.h | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/include/linux/phy/phy.h b/include/linux/phy/phy.h
index 6d72269..6ca6c61 100644
--- a/include/linux/phy/phy.h
+++ b/include/linux/phy/phy.h
@@ -46,6 +46,7 @@ struct phy_ops {
  * @mutex: mutex to protect phy_ops
  * @init_count: used to protect when the PHY is used by multiple consumers
  * @power_count: used to protect when the PHY is used by multiple consumers
+ * @bus_width: used to specify data width of the PHY bus
  */
 struct phy {
 	struct device		dev;
@@ -55,6 +56,7 @@ struct phy {
 	struct mutex		mutex;
 	int			init_count;
 	int			power_count;
+	int			bus_width;
 };
 
 /**
@@ -127,6 +129,14 @@ 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);
+static inline int phy_get_bus_width(struct phy *phy)
+{
+	return phy->bus_width;
+}
+static inline void phy_set_bus_width(struct phy *phy, int bus_width)
+{
+	phy->bus_width = bus_width;
+}
 struct phy *phy_get(struct device *dev, const char *string);
 struct phy *devm_phy_get(struct device *dev, const char *string);
 void phy_put(struct phy *phy);
@@ -199,6 +209,16 @@ static inline int phy_power_off(struct phy *phy)
 	return -ENOSYS;
 }
 
+static inline int phy_get_bus_width(struct phy *phy)
+{
+	return -ENOSYS;
+}
+
+static inline void phy_set_bus_width(struct phy *phy, bus_width)
+{
+	return;
+}
+
 static inline struct phy *phy_get(struct device *dev, const char *string)
 {
 	return ERR_PTR(-ENOSYS);
-- 
1.8.4


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

* [PATCH v3 2/9] staging: dwc2: update DT binding to add generic clock/phy properties
  2013-11-25 18:15 [PATCH v3 0/9] USB Device Controller support for BCM281xx Matt Porter
  2013-11-25 18:15 ` [PATCH v3 1/9] phy: add phy_get_bus_width()/phy_set_bus_width() calls Matt Porter
@ 2013-11-25 18:16 ` Matt Porter
  2013-11-26 10:19   ` Kishon Vijay Abraham I
  2013-11-25 18:16 ` [PATCH v3 3/9] usb: gadget: s3c-hsotg: enable build for other platforms Matt Porter
                   ` (6 subsequent siblings)
  8 siblings, 1 reply; 28+ messages in thread
From: Matt Porter @ 2013-11-25 18:16 UTC (permalink / raw)
  To: Felipe Balbi, Greg Kroah-Hartman, Kishon Vijay Abraham I,
	Rob Herring, Pawel Moll, Mark Rutland, Kumar Gala, Ian Campbell,
	Christian Daudt, Paul Zimmerman
  Cc: Tomasz Figa, Kamil Debski, Kyungmin Park, Linux USB List,
	Linux ARM Kernel List, Linux Kernel Mailing List,
	Devicetree List, Linaro Patches

dwc2/s3c-hsotg require a single clock to be specified and optionally
a generic phy. On the s3c-hsotg driver old style USB phy support is
present as a fallback so the generic phy properties are optional.

Signed-off-by: Matt Porter <matt.porter@linaro.org>
---
 Documentation/devicetree/bindings/staging/dwc2.txt | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/Documentation/devicetree/bindings/staging/dwc2.txt b/Documentation/devicetree/bindings/staging/dwc2.txt
index 1a1b7cf..b8b42b6 100644
--- a/Documentation/devicetree/bindings/staging/dwc2.txt
+++ b/Documentation/devicetree/bindings/staging/dwc2.txt
@@ -5,6 +5,12 @@ Required properties:
 - compatible : "snps,dwc2"
 - reg : Should contain 1 register range (address and length)
 - interrupts : Should contain 1 interrupt
+- clocks: clock provider specifier
+- clock-names: shall be "otg"
+- phys: phy provider specifier
+- phy-names: shall be "device"
+Refer to clk/clock-bindings.txt for generic clock consumer properties
+Refer to phy/phy-bindings.txt for generic phy consumer properties
 
 Example:
 
@@ -12,4 +18,8 @@ Example:
                 compatible = "ralink,rt3050-usb, snps,dwc2";
                 reg = <0x101c0000 40000>;
                 interrupts = <18>;
+		clocks = <&usb_otg_ahb_clk>;
+		clock-names = "otg";
+		phys = <&usbphy>;
+		phy-names = "device";
         };
-- 
1.8.4


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

* [PATCH v3 3/9] usb: gadget: s3c-hsotg: enable build for other platforms
  2013-11-25 18:15 [PATCH v3 0/9] USB Device Controller support for BCM281xx Matt Porter
  2013-11-25 18:15 ` [PATCH v3 1/9] phy: add phy_get_bus_width()/phy_set_bus_width() calls Matt Porter
  2013-11-25 18:16 ` [PATCH v3 2/9] staging: dwc2: update DT binding to add generic clock/phy properties Matt Porter
@ 2013-11-25 18:16 ` Matt Porter
  2013-11-25 18:16 ` [PATCH v3 4/9] usb: gadget: s3c-hsotg: add snps,dwc2 compatible string Matt Porter
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 28+ messages in thread
From: Matt Porter @ 2013-11-25 18:16 UTC (permalink / raw)
  To: Felipe Balbi, Greg Kroah-Hartman, Kishon Vijay Abraham I,
	Rob Herring, Pawel Moll, Mark Rutland, Kumar Gala, Ian Campbell,
	Christian Daudt, Paul Zimmerman
  Cc: Tomasz Figa, Kamil Debski, Kyungmin Park, Linux USB List,
	Linux ARM Kernel List, Linux Kernel Mailing List,
	Devicetree List, Linaro Patches

Remove unused Samsung-specific machine include and Kconfig
dependency on S3C.

Signed-off-by: Matt Porter <matt.porter@linaro.org>
Reviewed-by: Markus Mayer <markus.mayer@linaro.org>
Reviewed-by: Tim Kryger <tim.kryger@linaro.org>
---
 drivers/usb/gadget/Kconfig     | 7 +++----
 drivers/usb/gadget/s3c-hsotg.c | 2 --
 2 files changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig
index a91e642..970bd1a 100644
--- a/drivers/usb/gadget/Kconfig
+++ b/drivers/usb/gadget/Kconfig
@@ -294,11 +294,10 @@ config USB_PXA27X
 	   gadget drivers to also be dynamically linked.
 
 config USB_S3C_HSOTG
-	tristate "S3C HS/OtG USB Device controller"
-	depends on S3C_DEV_USB_HSOTG
+	tristate "Designware/S3C HS/OtG USB Device controller"
 	help
-	  The Samsung S3C64XX USB2.0 high-speed gadget controller
-	  integrated into the S3C64XX series SoC.
+	  The Designware USB2.0 high-speed gadget controller
+	  integrated into the S3C64XX and BCM281xx series SoC.
 
 config USB_S3C2410
 	tristate "S3C2410 USB Device Controller"
diff --git a/drivers/usb/gadget/s3c-hsotg.c b/drivers/usb/gadget/s3c-hsotg.c
index 2d1f560..a8e6c3d 100644
--- a/drivers/usb/gadget/s3c-hsotg.c
+++ b/drivers/usb/gadget/s3c-hsotg.c
@@ -37,8 +37,6 @@
 #include <linux/usb/phy.h>
 #include <linux/platform_data/s3c-hsotg.h>
 
-#include <mach/map.h>
-
 #include "s3c-hsotg.h"
 
 static const char * const s3c_hsotg_supply_names[] = {
-- 
1.8.4


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

* [PATCH v3 4/9] usb: gadget: s3c-hsotg: add snps,dwc2 compatible string
  2013-11-25 18:15 [PATCH v3 0/9] USB Device Controller support for BCM281xx Matt Porter
                   ` (2 preceding siblings ...)
  2013-11-25 18:16 ` [PATCH v3 3/9] usb: gadget: s3c-hsotg: enable build for other platforms Matt Porter
@ 2013-11-25 18:16 ` Matt Porter
  2013-11-25 18:16 ` [PATCH v3 5/9] usb: gadget: s3c-hsotg: use generic phy_init()/phy_exit() support Matt Porter
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 28+ messages in thread
From: Matt Porter @ 2013-11-25 18:16 UTC (permalink / raw)
  To: Felipe Balbi, Greg Kroah-Hartman, Kishon Vijay Abraham I,
	Rob Herring, Pawel Moll, Mark Rutland, Kumar Gala, Ian Campbell,
	Christian Daudt, Paul Zimmerman
  Cc: Tomasz Figa, Kamil Debski, Kyungmin Park, Linux USB List,
	Linux ARM Kernel List, Linux Kernel Mailing List,
	Devicetree List, Linaro Patches

Enable support for the dwc2 binding.

Signed-off-by: Matt Porter <matt.porter@linaro.org>
---
 drivers/usb/gadget/s3c-hsotg.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/usb/gadget/s3c-hsotg.c b/drivers/usb/gadget/s3c-hsotg.c
index a8e6c3d..da3879b 100644
--- a/drivers/usb/gadget/s3c-hsotg.c
+++ b/drivers/usb/gadget/s3c-hsotg.c
@@ -3728,6 +3728,7 @@ static int s3c_hsotg_remove(struct platform_device *pdev)
 #ifdef CONFIG_OF
 static const struct of_device_id s3c_hsotg_of_ids[] = {
 	{ .compatible = "samsung,s3c6400-hsotg", },
+	{ .compatible = "snps,dwc2", },
 	{ /* sentinel */ }
 };
 MODULE_DEVICE_TABLE(of, s3c_hsotg_of_ids);
-- 
1.8.4


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

* [PATCH v3 5/9] usb: gadget: s3c-hsotg: use generic phy_init()/phy_exit() support
  2013-11-25 18:15 [PATCH v3 0/9] USB Device Controller support for BCM281xx Matt Porter
                   ` (3 preceding siblings ...)
  2013-11-25 18:16 ` [PATCH v3 4/9] usb: gadget: s3c-hsotg: add snps,dwc2 compatible string Matt Porter
@ 2013-11-25 18:16 ` Matt Porter
  2013-11-26 10:23   ` Kishon Vijay Abraham I
  2013-11-25 18:16 ` [PATCH v3 6/9] usb: gadget: s3c-hsotg: get phy bus width from phy subsystem Matt Porter
                   ` (3 subsequent siblings)
  8 siblings, 1 reply; 28+ messages in thread
From: Matt Porter @ 2013-11-25 18:16 UTC (permalink / raw)
  To: Felipe Balbi, Greg Kroah-Hartman, Kishon Vijay Abraham I,
	Rob Herring, Pawel Moll, Mark Rutland, Kumar Gala, Ian Campbell,
	Christian Daudt, Paul Zimmerman
  Cc: Tomasz Figa, Kamil Debski, Kyungmin Park, Linux USB List,
	Linux ARM Kernel List, Linux Kernel Mailing List,
	Devicetree List, Linaro Patches

If a generic phy is present, call phy_init()/phy_exit(). This supports
generic phys that must be soft reset before power on.

Signed-off-by: Matt Porter <matt.porter@linaro.org>
---
 drivers/usb/gadget/s3c-hsotg.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/drivers/usb/gadget/s3c-hsotg.c b/drivers/usb/gadget/s3c-hsotg.c
index da3879b..8dfe33f 100644
--- a/drivers/usb/gadget/s3c-hsotg.c
+++ b/drivers/usb/gadget/s3c-hsotg.c
@@ -3622,6 +3622,9 @@ static int s3c_hsotg_probe(struct platform_device *pdev)
 		goto err_supplies;
 	}
 
+	if (hsotg->phy)
+		phy_init(hsotg->phy);
+
 	/* usb phy enable */
 	s3c_hsotg_phy_enable(hsotg);
 
@@ -3715,6 +3718,8 @@ static int s3c_hsotg_remove(struct platform_device *pdev)
 	}
 
 	s3c_hsotg_phy_disable(hsotg);
+	if (hsotg->phy)
+		phy_exit(hsotg->phy);
 	clk_disable_unprepare(hsotg->clk);
 
 	return 0;
-- 
1.8.4


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

* [PATCH v3 6/9] usb: gadget: s3c-hsotg: get phy bus width from phy subsystem
  2013-11-25 18:15 [PATCH v3 0/9] USB Device Controller support for BCM281xx Matt Porter
                   ` (4 preceding siblings ...)
  2013-11-25 18:16 ` [PATCH v3 5/9] usb: gadget: s3c-hsotg: use generic phy_init()/phy_exit() support Matt Porter
@ 2013-11-25 18:16 ` Matt Porter
  2013-11-26 10:28   ` Kishon Vijay Abraham I
  2013-11-25 18:16 ` [PATCH v3 7/9] phy: add Broadcom Kona USB2 PHY DT binding Matt Porter
                   ` (2 subsequent siblings)
  8 siblings, 1 reply; 28+ messages in thread
From: Matt Porter @ 2013-11-25 18:16 UTC (permalink / raw)
  To: Felipe Balbi, Greg Kroah-Hartman, Kishon Vijay Abraham I,
	Rob Herring, Pawel Moll, Mark Rutland, Kumar Gala, Ian Campbell,
	Christian Daudt, Paul Zimmerman
  Cc: Tomasz Figa, Kamil Debski, Kyungmin Park, Linux USB List,
	Linux ARM Kernel List, Linux Kernel Mailing List,
	Devicetree List, Linaro Patches

Adds support for querying the phy bus width from the generic phy
subsystem. Configure UTMI bus width in GUSBCFG based on this value.

Signed-off-by: Matt Porter <matt.porter@linaro.org>
---
 drivers/usb/gadget/s3c-hsotg.c | 14 +++++++++++++-
 drivers/usb/gadget/s3c-hsotg.h |  1 +
 2 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/gadget/s3c-hsotg.c b/drivers/usb/gadget/s3c-hsotg.c
index 8dfe33f..be41585 100644
--- a/drivers/usb/gadget/s3c-hsotg.c
+++ b/drivers/usb/gadget/s3c-hsotg.c
@@ -144,6 +144,7 @@ struct s3c_hsotg_ep {
  * @regs: The memory area mapped for accessing registers.
  * @irq: The IRQ number we are using
  * @supplies: Definition of USB power supplies
+ * @phyif: PHY interface width
  * @dedicated_fifos: Set if the hardware has dedicated IN-EP fifos.
  * @num_of_eps: Number of available EPs (excluding EP0)
  * @debug_root: root directrory for debugfs.
@@ -171,6 +172,7 @@ struct s3c_hsotg {
 
 	struct regulator_bulk_data supplies[ARRAY_SIZE(s3c_hsotg_supply_names)];
 
+	u32			phyif;
 	unsigned int		dedicated_fifos:1;
 	unsigned char           num_of_eps;
 
@@ -2276,7 +2278,7 @@ static void s3c_hsotg_core_init(struct s3c_hsotg *hsotg)
 	 */
 
 	/* set the PLL on, remove the HNP/SRP and set the PHY */
-	writel(GUSBCFG_PHYIf16 | GUSBCFG_TOutCal(7) |
+	writel(hsotg->phyif | GUSBCFG_TOutCal(7) |
 	       (0x5 << 10), hsotg->regs + GUSBCFG);
 
 	s3c_hsotg_init_fifo(hsotg);
@@ -3622,6 +3624,16 @@ static int s3c_hsotg_probe(struct platform_device *pdev)
 		goto err_supplies;
 	}
 
+	/* Set default UTMI width */
+	hsotg->phyif = GUSBCFG_PHYIf16;
+
+	/*
+	 * If using the generic PHY framework, check if the PHY bus
+	 * width is 8-bit and set the phyif appropriately.
+	 */
+	if (hsotg->phy && (phy_get_bus_width(phy) == 8))
+		hsotg->phyif = GUSBCFG_PHYIf8;
+
 	if (hsotg->phy)
 		phy_init(hsotg->phy);
 
diff --git a/drivers/usb/gadget/s3c-hsotg.h b/drivers/usb/gadget/s3c-hsotg.h
index d650b12..85f549f 100644
--- a/drivers/usb/gadget/s3c-hsotg.h
+++ b/drivers/usb/gadget/s3c-hsotg.h
@@ -55,6 +55,7 @@
 #define GUSBCFG_HNPCap				(1 << 9)
 #define GUSBCFG_SRPCap				(1 << 8)
 #define GUSBCFG_PHYIf16			(1 << 3)
+#define GUSBCFG_PHYIf8				(0 << 3)
 #define GUSBCFG_TOutCal_MASK			(0x7 << 0)
 #define GUSBCFG_TOutCal_SHIFT			(0)
 #define GUSBCFG_TOutCal_LIMIT			(0x7)
-- 
1.8.4


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

* [PATCH v3 7/9] phy: add Broadcom Kona USB2 PHY DT binding
  2013-11-25 18:15 [PATCH v3 0/9] USB Device Controller support for BCM281xx Matt Porter
                   ` (5 preceding siblings ...)
  2013-11-25 18:16 ` [PATCH v3 6/9] usb: gadget: s3c-hsotg: get phy bus width from phy subsystem Matt Porter
@ 2013-11-25 18:16 ` Matt Porter
  2013-11-26 10:31   ` Kishon Vijay Abraham I
  2013-11-25 18:16 ` [PATCH v3 8/9] phy: add Broadcom Kona USB2 PHY driver Matt Porter
  2013-11-25 18:16 ` [PATCH v3 9/9] ARM: dts: add usb udc support to bcm281xx Matt Porter
  8 siblings, 1 reply; 28+ messages in thread
From: Matt Porter @ 2013-11-25 18:16 UTC (permalink / raw)
  To: Felipe Balbi, Greg Kroah-Hartman, Kishon Vijay Abraham I,
	Rob Herring, Pawel Moll, Mark Rutland, Kumar Gala, Ian Campbell,
	Christian Daudt, Paul Zimmerman
  Cc: Tomasz Figa, Kamil Debski, Kyungmin Park, Linux USB List,
	Linux ARM Kernel List, Linux Kernel Mailing List,
	Devicetree List, Linaro Patches

Add a binding that describes the Broadcom Kona USB2 PHY found
on the BCM281xx family of SoCs.

Signed-off-by: Matt Porter <matt.porter@linaro.org>
---
 .../devicetree/bindings/phy/bcm-kona-usb2-phy.txt         | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/phy/bcm-kona-usb2-phy.txt

diff --git a/Documentation/devicetree/bindings/phy/bcm-kona-usb2-phy.txt b/Documentation/devicetree/bindings/phy/bcm-kona-usb2-phy.txt
new file mode 100644
index 0000000..3dc8b3d
--- /dev/null
+++ b/Documentation/devicetree/bindings/phy/bcm-kona-usb2-phy.txt
@@ -0,0 +1,15 @@
+BROADCOM KONA USB2 PHY
+
+Required properties:
+ - compatible: brcm,kona-usb2-phy
+ - reg: offset and length of the PHY registers
+ - #phy-cells: must be 0
+Refer to phy/phy-bindings.txt for the generic PHY binding properties
+
+Example:
+
+	usbphy: usb-phy@3f130000 {
+		compatible = "brcm,kona-usb2-phy";
+		reg = <0x3f130000 0x28>;
+		#phy-cells = <0>;
+	};
-- 
1.8.4


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

* [PATCH v3 8/9] phy: add Broadcom Kona USB2 PHY driver
  2013-11-25 18:15 [PATCH v3 0/9] USB Device Controller support for BCM281xx Matt Porter
                   ` (6 preceding siblings ...)
  2013-11-25 18:16 ` [PATCH v3 7/9] phy: add Broadcom Kona USB2 PHY DT binding Matt Porter
@ 2013-11-25 18:16 ` Matt Porter
  2013-11-27  8:51   ` Kishon Vijay Abraham I
  2013-11-25 18:16 ` [PATCH v3 9/9] ARM: dts: add usb udc support to bcm281xx Matt Porter
  8 siblings, 1 reply; 28+ messages in thread
From: Matt Porter @ 2013-11-25 18:16 UTC (permalink / raw)
  To: Felipe Balbi, Greg Kroah-Hartman, Kishon Vijay Abraham I,
	Rob Herring, Pawel Moll, Mark Rutland, Kumar Gala, Ian Campbell,
	Christian Daudt, Paul Zimmerman
  Cc: Tomasz Figa, Kamil Debski, Kyungmin Park, Linux USB List,
	Linux ARM Kernel List, Linux Kernel Mailing List,
	Devicetree List, Linaro Patches

Add a driver for the internal Broadcom Kona USB 2.0 PHY found
on the BCM281xx family of SoCs.

Signed-off-by: Matt Porter <matt.porter@linaro.org>
---
 drivers/phy/Kconfig             |   6 ++
 drivers/phy/Makefile            |   1 +
 drivers/phy/phy-bcm-kona-usb2.c | 158 ++++++++++++++++++++++++++++++++++++++++
 3 files changed, 165 insertions(+)
 create mode 100644 drivers/phy/phy-bcm-kona-usb2.c

diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig
index a344f3d..2e87fa8 100644
--- a/drivers/phy/Kconfig
+++ b/drivers/phy/Kconfig
@@ -51,4 +51,10 @@ config PHY_EXYNOS_DP_VIDEO
 	help
 	  Support for Display Port PHY found on Samsung EXYNOS SoCs.
 
+config BCM_KONA_USB2_PHY
+	tristate "Broadcom Kona USB2 PHY Driver"
+	depends on GENERIC_PHY
+	help
+	  Enable this to support the Broadcom Kona USB 2.0 PHY.
+
 endmenu
diff --git a/drivers/phy/Makefile b/drivers/phy/Makefile
index d0caae9..c447f1a 100644
--- a/drivers/phy/Makefile
+++ b/drivers/phy/Makefile
@@ -3,6 +3,7 @@
 #
 
 obj-$(CONFIG_GENERIC_PHY)		+= phy-core.o
+obj-$(CONFIG_BCM_KONA_USB2_PHY)		+= phy-bcm-kona-usb2.o
 obj-$(CONFIG_PHY_EXYNOS_DP_VIDEO)	+= phy-exynos-dp-video.o
 obj-$(CONFIG_PHY_EXYNOS_MIPI_VIDEO)	+= phy-exynos-mipi-video.o
 obj-$(CONFIG_OMAP_USB2)			+= phy-omap-usb2.o
diff --git a/drivers/phy/phy-bcm-kona-usb2.c b/drivers/phy/phy-bcm-kona-usb2.c
new file mode 100644
index 0000000..2c54fb8
--- /dev/null
+++ b/drivers/phy/phy-bcm-kona-usb2.c
@@ -0,0 +1,158 @@
+/*
+ * phy-bcm-kona-usb2.c - Broadcom Kona USB2 Phy Driver
+ *
+ * Copyright (C) 2013 Linaro Limited
+ * Matt Porter <matt.porter@linaro.org>
+ *
+ * This software is licensed under the terms of the GNU General Public
+ * License version 2, as published by the Free Software Foundation, and
+ * may be copied, distributed, and modified under those terms.
+ *
+ * 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/module.h>
+#include <linux/of.h>
+#include <linux/delay.h>
+#include <linux/platform_device.h>
+#include <linux/err.h>
+#include <linux/io.h>
+#include <linux/clk.h>
+#include <linux/phy/phy.h>
+
+#define OTGCTL			(0)
+#define OTGCTL_OTGSTAT2		(1 << 31)
+#define OTGCTL_OTGSTAT1		(1 << 30)
+#define OTGCTL_PRST_N_SW	(1 << 11)
+#define OTGCTL_HRESET_N		(1 << 10)
+#define OTGCTL_UTMI_LINE_STATE1	(1 << 9)
+#define OTGCTL_UTMI_LINE_STATE0	(1 << 8)
+
+#define P1CTL			(8)
+#define P1CTL_SOFT_RESET	(1 << 1)
+#define P1CTL_NON_DRIVING	(1 << 0)
+
+struct bcm_kona_usb {
+	void __iomem *regs;
+};
+
+static void bcm_kona_usb_phy_power(struct bcm_kona_usb *phy, int on)
+{
+	u32 val;
+
+	val = readl(phy->regs + OTGCTL);
+	if (on) {
+		/* Configure and power PHY */
+		val &= ~(OTGCTL_OTGSTAT2 | OTGCTL_OTGSTAT1 |
+			 OTGCTL_UTMI_LINE_STATE1 | OTGCTL_UTMI_LINE_STATE0);
+		val |= OTGCTL_PRST_N_SW | OTGCTL_HRESET_N;
+	} else {
+		val &= ~(OTGCTL_PRST_N_SW | OTGCTL_HRESET_N);
+	}
+	writel(val, phy->regs + OTGCTL);
+}
+
+static int bcm_kona_usb_phy_init(struct phy *gphy)
+{
+	struct bcm_kona_usb *phy = phy_get_drvdata(gphy);
+	u32 val;
+
+	/* Soft reset PHY */
+	val = readl(phy->regs + P1CTL);
+	val &= ~P1CTL_NON_DRIVING;
+	val |= P1CTL_SOFT_RESET;
+	writel(val, phy->regs + P1CTL);
+	writel(val & ~P1CTL_SOFT_RESET, phy->regs + P1CTL);
+	/* Reset needs to be asserted for 2ms */
+	mdelay(2);
+	writel(val | P1CTL_SOFT_RESET, phy->regs + P1CTL);
+
+	return 0;
+}
+
+static int bcm_kona_usb_phy_power_on(struct phy *gphy)
+{
+	struct bcm_kona_usb *phy = phy_get_drvdata(gphy);
+
+	bcm_kona_usb_phy_power(phy, 1);
+
+	return 0;
+}
+
+static int bcm_kona_usb_phy_power_off(struct phy *gphy)
+{
+	struct bcm_kona_usb *phy = phy_get_drvdata(gphy);
+
+	bcm_kona_usb_phy_power(phy, 0);
+
+	return 0;
+}
+
+static struct phy_ops ops = {
+	.init		= bcm_kona_usb_phy_init,
+	.power_on	= bcm_kona_usb_phy_power_on,
+	.power_off	= bcm_kona_usb_phy_power_off,
+	.owner = THIS_MODULE,
+};
+
+static int bcm_kona_usb2_probe(struct platform_device *pdev)
+{
+	struct device *dev = &pdev->dev;
+	struct bcm_kona_usb *phy;
+	struct resource *res;
+	struct phy *gphy;
+	struct phy_provider *phy_provider;
+
+	phy = devm_kzalloc(dev, sizeof(*phy), GFP_KERNEL);
+	if (!phy)
+		return -ENOMEM;
+
+	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+	phy->regs = devm_ioremap_resource(&pdev->dev, res);
+	if (IS_ERR(phy->regs))
+		return PTR_ERR(phy->regs);
+
+	platform_set_drvdata(pdev, phy);
+
+	phy_provider = devm_of_phy_provider_register(dev,
+			of_phy_simple_xlate);
+	if (IS_ERR(phy_provider))
+		return PTR_ERR(phy_provider);
+
+	gphy = devm_phy_create(dev, &ops, NULL);
+	if (IS_ERR(gphy))
+		return PTR_ERR(gphy);
+
+	/* The Kona PHY supports an 8-bit wide UTMI interface */
+	phy_set_bus_width(gphy, 8);
+
+	phy_set_drvdata(gphy, phy);
+
+	return 0;
+}
+
+static const struct of_device_id bcm_kona_usb2_dt_ids[] = {
+	{ .compatible = "brcm,kona-usb2-phy" },
+	{ /* sentinel */ }
+};
+
+MODULE_DEVICE_TABLE(of, bcm_kona_usb2_dt_ids);
+
+static struct platform_driver bcm_kona_usb2_driver = {
+	.probe		= bcm_kona_usb2_probe,
+	.driver		= {
+		.name	= "bcm-kona-usb2",
+		.owner	= THIS_MODULE,
+		.of_match_table = bcm_kona_usb2_dt_ids,
+	},
+};
+
+module_platform_driver(bcm_kona_usb2_driver);
+
+MODULE_ALIAS("platform:bcm-kona-usb2");
+MODULE_AUTHOR("Matt Porter <matt.porter@linaro.org>");
+MODULE_DESCRIPTION("BCM Kona USB 2.0 PHY driver");
+MODULE_LICENSE("GPL v2");
-- 
1.8.4


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

* [PATCH v3 9/9] ARM: dts: add usb udc support to bcm281xx
  2013-11-25 18:15 [PATCH v3 0/9] USB Device Controller support for BCM281xx Matt Porter
                   ` (7 preceding siblings ...)
  2013-11-25 18:16 ` [PATCH v3 8/9] phy: add Broadcom Kona USB2 PHY driver Matt Porter
@ 2013-11-25 18:16 ` Matt Porter
  2013-11-27  8:57   ` Kishon Vijay Abraham I
  8 siblings, 1 reply; 28+ messages in thread
From: Matt Porter @ 2013-11-25 18:16 UTC (permalink / raw)
  To: Felipe Balbi, Greg Kroah-Hartman, Kishon Vijay Abraham I,
	Rob Herring, Pawel Moll, Mark Rutland, Kumar Gala, Ian Campbell,
	Christian Daudt, Paul Zimmerman
  Cc: Tomasz Figa, Kamil Debski, Kyungmin Park, Linux USB List,
	Linux ARM Kernel List, Linux Kernel Mailing List,
	Devicetree List, Linaro Patches

Adds USB OTG/PHY and clock support to BCM281xx and enables
UDC support on the bcm11351-brt and bcm28155-ap boards.

Signed-off-by: Matt Porter <matt.porter@linaro.org>
Reviewed-by: Markus Mayer <markus.mayer@linaro.org>
Reviewed-by: Tim Kryger <tim.kryger@linaro.org>
---
 arch/arm/boot/dts/bcm11351-brt.dts |  6 ++++++
 arch/arm/boot/dts/bcm11351.dtsi    | 18 ++++++++++++++++++
 arch/arm/boot/dts/bcm28155-ap.dts  |  8 ++++++++
 3 files changed, 32 insertions(+)

diff --git a/arch/arm/boot/dts/bcm11351-brt.dts b/arch/arm/boot/dts/bcm11351-brt.dts
index 23cd16d..396b704 100644
--- a/arch/arm/boot/dts/bcm11351-brt.dts
+++ b/arch/arm/boot/dts/bcm11351-brt.dts
@@ -44,5 +44,11 @@
 		status = "okay";
 	};
 
+	usbotg: usb@3f120000 {
+		status = "okay";
+	};
 
+	usbphy: usb-phy@3f130000 {
+		status = "okay";
+	};
 };
diff --git a/arch/arm/boot/dts/bcm11351.dtsi b/arch/arm/boot/dts/bcm11351.dtsi
index 1246885..868879a 100644
--- a/arch/arm/boot/dts/bcm11351.dtsi
+++ b/arch/arm/boot/dts/bcm11351.dtsi
@@ -243,4 +243,22 @@
 			#clock-cells = <0>;
 		};
 	};
+
+	usbotg: usb@3f120000 {
+		compatible = "snps,dwc2";
+		reg = <0x3f120000 0x10000>;
+		interrupts = <GIC_SPI 47 IRQ_TYPE_LEVEL_HIGH>;
+		clocks = <&usb_otg_ahb_clk>;
+		clock-names = "otg";
+		phys = <&usbphy>;
+		phy-names = "device";
+		status = "disabled";
+	};
+
+	usbphy: usb-phy@3f130000 {
+		compatible = "brcm,kona-usb2-phy";
+		reg = <0x3f130000 0x28>;
+		#phy-cells = <0>;
+		status = "disabled";
+	};
 };
diff --git a/arch/arm/boot/dts/bcm28155-ap.dts b/arch/arm/boot/dts/bcm28155-ap.dts
index 08e47c2..a3bc436 100644
--- a/arch/arm/boot/dts/bcm28155-ap.dts
+++ b/arch/arm/boot/dts/bcm28155-ap.dts
@@ -43,4 +43,12 @@
 		cd-gpios = <&gpio 14 0>;
 		status = "okay";
 	};
+
+	usbotg: usb@3f120000 {
+		status = "okay";
+	};
+
+	usbphy: usb-phy@3f130000 {
+		status = "okay";
+	};
 };
-- 
1.8.4


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

* Re: [PATCH v3 1/9] phy: add phy_get_bus_width()/phy_set_bus_width() calls
  2013-11-25 18:15 ` [PATCH v3 1/9] phy: add phy_get_bus_width()/phy_set_bus_width() calls Matt Porter
@ 2013-11-26 10:16   ` Kishon Vijay Abraham I
  2013-11-27 16:55     ` Matt Porter
  0 siblings, 1 reply; 28+ messages in thread
From: Kishon Vijay Abraham I @ 2013-11-26 10:16 UTC (permalink / raw)
  To: Matt Porter, Felipe Balbi, Greg Kroah-Hartman, Rob Herring,
	Pawel Moll, Mark Rutland, Kumar Gala, Ian Campbell,
	Christian Daudt, Paul Zimmerman
  Cc: Tomasz Figa, Kamil Debski, Kyungmin Park, Linux USB List,
	Linux ARM Kernel List, Linux Kernel Mailing List,
	Devicetree List, Linaro Patches

Hi,

On Monday 25 November 2013 11:45 PM, Matt Porter wrote:
> This adds a pair of APIs that allows the generic PHY subsystem to
> provide information on the PHY bus width. The PHY provider driver may
> use phy_set_bus_width() to set the bus width that the PHY supports.
> The controller driver may then use phy_get_bus_width() to fetch the
> PHY bus width in order to properly configure the controller.
> 
> Signed-off-by: Matt Porter <matt.porter@linaro.org>
> ---
>  include/linux/phy/phy.h | 20 ++++++++++++++++++++
>  1 file changed, 20 insertions(+)
> 
> diff --git a/include/linux/phy/phy.h b/include/linux/phy/phy.h
> index 6d72269..6ca6c61 100644
> --- a/include/linux/phy/phy.h
> +++ b/include/linux/phy/phy.h
> @@ -46,6 +46,7 @@ struct phy_ops {
>   * @mutex: mutex to protect phy_ops
>   * @init_count: used to protect when the PHY is used by multiple consumers
>   * @power_count: used to protect when the PHY is used by multiple consumers
> + * @bus_width: used to specify data width of the PHY bus
>   */
>  struct phy {
>  	struct device		dev;
> @@ -55,6 +56,7 @@ struct phy {
>  	struct mutex		mutex;
>  	int			init_count;
>  	int			power_count;
> +	int			bus_width;

the bus_width can be part of the attrs struct which you initially proposed.
Soon there will be requests for other attributes being added (e.g., speed).
>  };
>  
>  /**
> @@ -127,6 +129,14 @@ 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);
> +static inline int phy_get_bus_width(struct phy *phy)
> +{
> +	return phy->bus_width;
> +}
> +static inline void phy_set_bus_width(struct phy *phy, int bus_width)

u32 bus_width?
> +{
> +	phy->bus_width = bus_width;
> +}
>  struct phy *phy_get(struct device *dev, const char *string);
>  struct phy *devm_phy_get(struct device *dev, const char *string);
>  void phy_put(struct phy *phy);
> @@ -199,6 +209,16 @@ static inline int phy_power_off(struct phy *phy)
>  	return -ENOSYS;
>  }
>  
> +static inline int phy_get_bus_width(struct phy *phy)
> +{
> +	return -ENOSYS;
> +}
> +
> +static inline void phy_set_bus_width(struct phy *phy, bus_width)

er.. has this been compile tested?

Thanks
Kishon

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

* Re: [PATCH v3 2/9] staging: dwc2: update DT binding to add generic clock/phy properties
  2013-11-25 18:16 ` [PATCH v3 2/9] staging: dwc2: update DT binding to add generic clock/phy properties Matt Porter
@ 2013-11-26 10:19   ` Kishon Vijay Abraham I
  2013-11-27 16:56     ` Matt Porter
  0 siblings, 1 reply; 28+ messages in thread
From: Kishon Vijay Abraham I @ 2013-11-26 10:19 UTC (permalink / raw)
  To: Matt Porter, Felipe Balbi, Greg Kroah-Hartman, Rob Herring,
	Pawel Moll, Mark Rutland, Kumar Gala, Ian Campbell,
	Christian Daudt, Paul Zimmerman
  Cc: Tomasz Figa, Kamil Debski, Kyungmin Park, Linux USB List,
	Linux ARM Kernel List, Linux Kernel Mailing List,
	Devicetree List, Linaro Patches

On Monday 25 November 2013 11:46 PM, Matt Porter wrote:
> dwc2/s3c-hsotg require a single clock to be specified and optionally
> a generic phy. On the s3c-hsotg driver old style USB phy support is
> present as a fallback so the generic phy properties are optional.
> 
> Signed-off-by: Matt Porter <matt.porter@linaro.org>
> ---
>  Documentation/devicetree/bindings/staging/dwc2.txt | 10 ++++++++++
>  1 file changed, 10 insertions(+)
> 
> diff --git a/Documentation/devicetree/bindings/staging/dwc2.txt b/Documentation/devicetree/bindings/staging/dwc2.txt
> index 1a1b7cf..b8b42b6 100644
> --- a/Documentation/devicetree/bindings/staging/dwc2.txt
> +++ b/Documentation/devicetree/bindings/staging/dwc2.txt
> @@ -5,6 +5,12 @@ Required properties:
>  - compatible : "snps,dwc2"
>  - reg : Should contain 1 register range (address and length)
>  - interrupts : Should contain 1 interrupt
> +- clocks: clock provider specifier
> +- clock-names: shall be "otg"
> +- phys: phy provider specifier
> +- phy-names: shall be "device"

lets mention in the Documentation too that the phy properties are optional.
apart from that..
Acked-by: Kishon Vijay Abraham I <kishon@ti.com>
> +Refer to clk/clock-bindings.txt for generic clock consumer properties
> +Refer to phy/phy-bindings.txt for generic phy consumer properties
>  
>  Example:
>  
> @@ -12,4 +18,8 @@ Example:
>                  compatible = "ralink,rt3050-usb, snps,dwc2";
>                  reg = <0x101c0000 40000>;
>                  interrupts = <18>;
> +		clocks = <&usb_otg_ahb_clk>;
> +		clock-names = "otg";
> +		phys = <&usbphy>;
> +		phy-names = "device";
>          };
> 


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

* Re: [PATCH v3 5/9] usb: gadget: s3c-hsotg: use generic phy_init()/phy_exit() support
  2013-11-25 18:16 ` [PATCH v3 5/9] usb: gadget: s3c-hsotg: use generic phy_init()/phy_exit() support Matt Porter
@ 2013-11-26 10:23   ` Kishon Vijay Abraham I
  2013-11-27 17:13     ` Matt Porter
  0 siblings, 1 reply; 28+ messages in thread
From: Kishon Vijay Abraham I @ 2013-11-26 10:23 UTC (permalink / raw)
  To: Matt Porter, Felipe Balbi, Greg Kroah-Hartman, Rob Herring,
	Pawel Moll, Mark Rutland, Kumar Gala, Ian Campbell,
	Christian Daudt, Paul Zimmerman
  Cc: Tomasz Figa, Kamil Debski, Kyungmin Park, Linux USB List,
	Linux ARM Kernel List, Linux Kernel Mailing List,
	Devicetree List, Linaro Patches

Hi,

On Monday 25 November 2013 11:46 PM, Matt Porter wrote:
> If a generic phy is present, call phy_init()/phy_exit(). This supports
> generic phys that must be soft reset before power on.
> 
> Signed-off-by: Matt Porter <matt.porter@linaro.org>
> ---
>  drivers/usb/gadget/s3c-hsotg.c | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/drivers/usb/gadget/s3c-hsotg.c b/drivers/usb/gadget/s3c-hsotg.c
> index da3879b..8dfe33f 100644
> --- a/drivers/usb/gadget/s3c-hsotg.c
> +++ b/drivers/usb/gadget/s3c-hsotg.c
> @@ -3622,6 +3622,9 @@ static int s3c_hsotg_probe(struct platform_device *pdev)
>  		goto err_supplies;
>  	}
>  
> +	if (hsotg->phy)

IS_ERR? If your phy_get fails *phy* will have a error value..

> +		phy_init(hsotg->phy);
> +
>  	/* usb phy enable */
>  	s3c_hsotg_phy_enable(hsotg);
>  
> @@ -3715,6 +3718,8 @@ static int s3c_hsotg_remove(struct platform_device *pdev)
>  	}
>  
>  	s3c_hsotg_phy_disable(hsotg);
> +	if (hsotg->phy)

same here.

Thanks
Kishon

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

* Re: [PATCH v3 6/9] usb: gadget: s3c-hsotg: get phy bus width from phy subsystem
  2013-11-25 18:16 ` [PATCH v3 6/9] usb: gadget: s3c-hsotg: get phy bus width from phy subsystem Matt Porter
@ 2013-11-26 10:28   ` Kishon Vijay Abraham I
  2013-11-27 17:16     ` Matt Porter
  0 siblings, 1 reply; 28+ messages in thread
From: Kishon Vijay Abraham I @ 2013-11-26 10:28 UTC (permalink / raw)
  To: Matt Porter, Felipe Balbi, Greg Kroah-Hartman, Rob Herring,
	Pawel Moll, Mark Rutland, Kumar Gala, Ian Campbell,
	Christian Daudt, Paul Zimmerman
  Cc: Tomasz Figa, Kamil Debski, Kyungmin Park, Linux USB List,
	Linux ARM Kernel List, Linux Kernel Mailing List,
	Devicetree List, Linaro Patches

Hi,

On Monday 25 November 2013 11:46 PM, Matt Porter wrote:
> Adds support for querying the phy bus width from the generic phy
> subsystem. Configure UTMI bus width in GUSBCFG based on this value.
> 
> Signed-off-by: Matt Porter <matt.porter@linaro.org>
> ---
>  drivers/usb/gadget/s3c-hsotg.c | 14 +++++++++++++-
>  drivers/usb/gadget/s3c-hsotg.h |  1 +
>  2 files changed, 14 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/usb/gadget/s3c-hsotg.c b/drivers/usb/gadget/s3c-hsotg.c
> index 8dfe33f..be41585 100644
> --- a/drivers/usb/gadget/s3c-hsotg.c
> +++ b/drivers/usb/gadget/s3c-hsotg.c
> @@ -144,6 +144,7 @@ struct s3c_hsotg_ep {
>   * @regs: The memory area mapped for accessing registers.
>   * @irq: The IRQ number we are using
>   * @supplies: Definition of USB power supplies
> + * @phyif: PHY interface width
>   * @dedicated_fifos: Set if the hardware has dedicated IN-EP fifos.
>   * @num_of_eps: Number of available EPs (excluding EP0)
>   * @debug_root: root directrory for debugfs.
> @@ -171,6 +172,7 @@ struct s3c_hsotg {
>  
>  	struct regulator_bulk_data supplies[ARRAY_SIZE(s3c_hsotg_supply_names)];
>  
> +	u32			phyif;
>  	unsigned int		dedicated_fifos:1;
>  	unsigned char           num_of_eps;
>  
> @@ -2276,7 +2278,7 @@ static void s3c_hsotg_core_init(struct s3c_hsotg *hsotg)
>  	 */
>  
>  	/* set the PLL on, remove the HNP/SRP and set the PHY */
> -	writel(GUSBCFG_PHYIf16 | GUSBCFG_TOutCal(7) |
> +	writel(hsotg->phyif | GUSBCFG_TOutCal(7) |
>  	       (0x5 << 10), hsotg->regs + GUSBCFG);
>  
>  	s3c_hsotg_init_fifo(hsotg);
> @@ -3622,6 +3624,16 @@ static int s3c_hsotg_probe(struct platform_device *pdev)
>  		goto err_supplies;
>  	}
>  
> +	/* Set default UTMI width */
> +	hsotg->phyif = GUSBCFG_PHYIf16;
> +
> +	/*
> +	 * If using the generic PHY framework, check if the PHY bus
> +	 * width is 8-bit and set the phyif appropriately.
> +	 */
> +	if (hsotg->phy && (phy_get_bus_width(phy) == 8))

what if the phy has error value here?

Thanks
Kishon

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

* Re: [PATCH v3 7/9] phy: add Broadcom Kona USB2 PHY DT binding
  2013-11-25 18:16 ` [PATCH v3 7/9] phy: add Broadcom Kona USB2 PHY DT binding Matt Porter
@ 2013-11-26 10:31   ` Kishon Vijay Abraham I
  2013-11-27 17:19     ` Matt Porter
  0 siblings, 1 reply; 28+ messages in thread
From: Kishon Vijay Abraham I @ 2013-11-26 10:31 UTC (permalink / raw)
  To: Matt Porter, Felipe Balbi, Greg Kroah-Hartman, Rob Herring,
	Pawel Moll, Mark Rutland, Kumar Gala, Ian Campbell,
	Christian Daudt, Paul Zimmerman
  Cc: Tomasz Figa, Kamil Debski, Kyungmin Park, Linux USB List,
	Linux ARM Kernel List, Linux Kernel Mailing List,
	Devicetree List, Linaro Patches

Hi,

On Monday 25 November 2013 11:46 PM, Matt Porter wrote:
> Add a binding that describes the Broadcom Kona USB2 PHY found
> on the BCM281xx family of SoCs.
> 
> Signed-off-by: Matt Porter <matt.porter@linaro.org>
> ---
>  .../devicetree/bindings/phy/bcm-kona-usb2-phy.txt         | 15 +++++++++++++++
>  1 file changed, 15 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/phy/bcm-kona-usb2-phy.txt
> 
> diff --git a/Documentation/devicetree/bindings/phy/bcm-kona-usb2-phy.txt b/Documentation/devicetree/bindings/phy/bcm-kona-usb2-phy.txt
> new file mode 100644
> index 0000000..3dc8b3d
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/phy/bcm-kona-usb2-phy.txt

you should name this bcm-phy. Then you can add binding info of all (future) PHY
IP from broadcom here.

other than that this looks fine..
Acked-by: Kishon Vijay Abraham I <kishon@ti.com>

Thanks
Kishon

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

* Re: [PATCH v3 8/9] phy: add Broadcom Kona USB2 PHY driver
  2013-11-25 18:16 ` [PATCH v3 8/9] phy: add Broadcom Kona USB2 PHY driver Matt Porter
@ 2013-11-27  8:51   ` Kishon Vijay Abraham I
  2013-11-27 17:21     ` Matt Porter
  0 siblings, 1 reply; 28+ messages in thread
From: Kishon Vijay Abraham I @ 2013-11-27  8:51 UTC (permalink / raw)
  To: Matt Porter, Felipe Balbi, Greg Kroah-Hartman, Rob Herring,
	Pawel Moll, Mark Rutland, Kumar Gala, Ian Campbell,
	Christian Daudt, Paul Zimmerman
  Cc: Tomasz Figa, Kamil Debski, Kyungmin Park, Linux USB List,
	Linux ARM Kernel List, Linux Kernel Mailing List,
	Devicetree List, Linaro Patches

Hi,

On Monday 25 November 2013 11:46 PM, Matt Porter wrote:
> Add a driver for the internal Broadcom Kona USB 2.0 PHY found
> on the BCM281xx family of SoCs.
> 
> Signed-off-by: Matt Porter <matt.porter@linaro.org>
> ---
>  drivers/phy/Kconfig             |   6 ++
>  drivers/phy/Makefile            |   1 +
>  drivers/phy/phy-bcm-kona-usb2.c | 158 ++++++++++++++++++++++++++++++++++++++++
>  3 files changed, 165 insertions(+)
>  create mode 100644 drivers/phy/phy-bcm-kona-usb2.c
> 
> diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig
> index a344f3d..2e87fa8 100644
> --- a/drivers/phy/Kconfig
> +++ b/drivers/phy/Kconfig
> @@ -51,4 +51,10 @@ config PHY_EXYNOS_DP_VIDEO
>  	help
>  	  Support for Display Port PHY found on Samsung EXYNOS SoCs.
>  
> +config BCM_KONA_USB2_PHY
> +	tristate "Broadcom Kona USB2 PHY Driver"
> +	depends on GENERIC_PHY
> +	help
> +	  Enable this to support the Broadcom Kona USB 2.0 PHY.
> +
>  endmenu
> diff --git a/drivers/phy/Makefile b/drivers/phy/Makefile
> index d0caae9..c447f1a 100644
> --- a/drivers/phy/Makefile
> +++ b/drivers/phy/Makefile
> @@ -3,6 +3,7 @@
>  #
>  
>  obj-$(CONFIG_GENERIC_PHY)		+= phy-core.o
> +obj-$(CONFIG_BCM_KONA_USB2_PHY)		+= phy-bcm-kona-usb2.o
>  obj-$(CONFIG_PHY_EXYNOS_DP_VIDEO)	+= phy-exynos-dp-video.o
>  obj-$(CONFIG_PHY_EXYNOS_MIPI_VIDEO)	+= phy-exynos-mipi-video.o
>  obj-$(CONFIG_OMAP_USB2)			+= phy-omap-usb2.o
> diff --git a/drivers/phy/phy-bcm-kona-usb2.c b/drivers/phy/phy-bcm-kona-usb2.c
> new file mode 100644
> index 0000000..2c54fb8
> --- /dev/null
> +++ b/drivers/phy/phy-bcm-kona-usb2.c
> @@ -0,0 +1,158 @@
> +/*
> + * phy-bcm-kona-usb2.c - Broadcom Kona USB2 Phy Driver
> + *
> + * Copyright (C) 2013 Linaro Limited
> + * Matt Porter <matt.porter@linaro.org>
> + *
> + * This software is licensed under the terms of the GNU General Public
> + * License version 2, as published by the Free Software Foundation, and
> + * may be copied, distributed, and modified under those terms.
> + *
> + * 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/module.h>
> +#include <linux/of.h>
> +#include <linux/delay.h>
> +#include <linux/platform_device.h>
> +#include <linux/err.h>
> +#include <linux/io.h>
> +#include <linux/clk.h>
> +#include <linux/phy/phy.h>

arrange the headers in alphabetical order so that it's easy while adding new
headers. Just my preference.
> +
> +#define OTGCTL			(0)
> +#define OTGCTL_OTGSTAT2		(1 << 31)
> +#define OTGCTL_OTGSTAT1		(1 << 30)
> +#define OTGCTL_PRST_N_SW	(1 << 11)
> +#define OTGCTL_HRESET_N		(1 << 10)
> +#define OTGCTL_UTMI_LINE_STATE1	(1 << 9)
> +#define OTGCTL_UTMI_LINE_STATE0	(1 << 8)
> +
> +#define P1CTL			(8)
> +#define P1CTL_SOFT_RESET	(1 << 1)
> +#define P1CTL_NON_DRIVING	(1 << 0)

you can use BIT() instead.
> +
> +struct bcm_kona_usb {
> +	void __iomem *regs;
> +};
> +
> +static void bcm_kona_usb_phy_power(struct bcm_kona_usb *phy, int on)
> +{
> +	u32 val;
> +
> +	val = readl(phy->regs + OTGCTL);
> +	if (on) {
> +		/* Configure and power PHY */
> +		val &= ~(OTGCTL_OTGSTAT2 | OTGCTL_OTGSTAT1 |
> +			 OTGCTL_UTMI_LINE_STATE1 | OTGCTL_UTMI_LINE_STATE0);
> +		val |= OTGCTL_PRST_N_SW | OTGCTL_HRESET_N;
> +	} else {
> +		val &= ~(OTGCTL_PRST_N_SW | OTGCTL_HRESET_N);
> +	}
> +	writel(val, phy->regs + OTGCTL);
> +}
> +
> +static int bcm_kona_usb_phy_init(struct phy *gphy)
> +{
> +	struct bcm_kona_usb *phy = phy_get_drvdata(gphy);
> +	u32 val;
> +
> +	/* Soft reset PHY */
> +	val = readl(phy->regs + P1CTL);
> +	val &= ~P1CTL_NON_DRIVING;
> +	val |= P1CTL_SOFT_RESET;
> +	writel(val, phy->regs + P1CTL);
> +	writel(val & ~P1CTL_SOFT_RESET, phy->regs + P1CTL);
> +	/* Reset needs to be asserted for 2ms */
> +	mdelay(2);
> +	writel(val | P1CTL_SOFT_RESET, phy->regs + P1CTL);
> +
> +	return 0;
> +}
> +
> +static int bcm_kona_usb_phy_power_on(struct phy *gphy)
> +{
> +	struct bcm_kona_usb *phy = phy_get_drvdata(gphy);
> +
> +	bcm_kona_usb_phy_power(phy, 1);
> +
> +	return 0;
> +}
> +
> +static int bcm_kona_usb_phy_power_off(struct phy *gphy)
> +{
> +	struct bcm_kona_usb *phy = phy_get_drvdata(gphy);
> +
> +	bcm_kona_usb_phy_power(phy, 0);
> +
> +	return 0;
> +}
> +
> +static struct phy_ops ops = {
> +	.init		= bcm_kona_usb_phy_init,
> +	.power_on	= bcm_kona_usb_phy_power_on,
> +	.power_off	= bcm_kona_usb_phy_power_off,
> +	.owner = THIS_MODULE,

owner is aligned differently..
> +};
> +
> +static int bcm_kona_usb2_probe(struct platform_device *pdev)
> +{
> +	struct device *dev = &pdev->dev;
> +	struct bcm_kona_usb *phy;
> +	struct resource *res;
> +	struct phy *gphy;
> +	struct phy_provider *phy_provider;
> +
> +	phy = devm_kzalloc(dev, sizeof(*phy), GFP_KERNEL);
> +	if (!phy)
> +		return -ENOMEM;
> +
> +	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> +	phy->regs = devm_ioremap_resource(&pdev->dev, res);
> +	if (IS_ERR(phy->regs))
> +		return PTR_ERR(phy->regs);
> +
> +	platform_set_drvdata(pdev, phy);
> +
> +	phy_provider = devm_of_phy_provider_register(dev,
> +			of_phy_simple_xlate);
> +	if (IS_ERR(phy_provider))
> +		return PTR_ERR(phy_provider);
> +
> +	gphy = devm_phy_create(dev, &ops, NULL);
> +	if (IS_ERR(gphy))
> +		return PTR_ERR(gphy);
> +
> +	/* The Kona PHY supports an 8-bit wide UTMI interface */
> +	phy_set_bus_width(gphy, 8);
> +
> +	phy_set_drvdata(gphy, phy);
> +
> +	return 0;
> +}
> +
> +static const struct of_device_id bcm_kona_usb2_dt_ids[] = {
> +	{ .compatible = "brcm,kona-usb2-phy" },
> +	{ /* sentinel */ }
> +};
> +
> +MODULE_DEVICE_TABLE(of, bcm_kona_usb2_dt_ids);
> +
> +static struct platform_driver bcm_kona_usb2_driver = {
> +	.probe		= bcm_kona_usb2_probe,
> +	.driver		= {
> +		.name	= "bcm-kona-usb2",
> +		.owner	= THIS_MODULE,
> +		.of_match_table = bcm_kona_usb2_dt_ids,
> +	},
> +};
> +
> +module_platform_driver(bcm_kona_usb2_driver);
> +
> +MODULE_ALIAS("platform:bcm-kona-usb2");
> +MODULE_AUTHOR("Matt Porter <matt.porter@linaro.org>");
> +MODULE_DESCRIPTION("BCM Kona USB 2.0 PHY driver");
> +MODULE_LICENSE("GPL v2");
> 
Apart from those comments, this patch looks good.

Thanks
Kishon


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

* Re: [PATCH v3 9/9] ARM: dts: add usb udc support to bcm281xx
  2013-11-25 18:16 ` [PATCH v3 9/9] ARM: dts: add usb udc support to bcm281xx Matt Porter
@ 2013-11-27  8:57   ` Kishon Vijay Abraham I
  2013-11-27 17:24     ` Matt Porter
  0 siblings, 1 reply; 28+ messages in thread
From: Kishon Vijay Abraham I @ 2013-11-27  8:57 UTC (permalink / raw)
  To: Matt Porter, Felipe Balbi, Greg Kroah-Hartman, Rob Herring,
	Pawel Moll, Mark Rutland, Kumar Gala, Ian Campbell,
	Christian Daudt, Paul Zimmerman
  Cc: Tomasz Figa, Kamil Debski, Kyungmin Park, Linux USB List,
	Linux ARM Kernel List, Linux Kernel Mailing List,
	Devicetree List, Linaro Patches

Hi,

On Monday 25 November 2013 11:46 PM, Matt Porter wrote:
> Adds USB OTG/PHY and clock support to BCM281xx and enables
> UDC support on the bcm11351-brt and bcm28155-ap boards.
> 
> Signed-off-by: Matt Porter <matt.porter@linaro.org>
> Reviewed-by: Markus Mayer <markus.mayer@linaro.org>
> Reviewed-by: Tim Kryger <tim.kryger@linaro.org>
> ---
>  arch/arm/boot/dts/bcm11351-brt.dts |  6 ++++++
>  arch/arm/boot/dts/bcm11351.dtsi    | 18 ++++++++++++++++++
>  arch/arm/boot/dts/bcm28155-ap.dts  |  8 ++++++++
>  3 files changed, 32 insertions(+)
> 
> diff --git a/arch/arm/boot/dts/bcm11351-brt.dts b/arch/arm/boot/dts/bcm11351-brt.dts
> index 23cd16d..396b704 100644
> --- a/arch/arm/boot/dts/bcm11351-brt.dts
> +++ b/arch/arm/boot/dts/bcm11351-brt.dts
> @@ -44,5 +44,11 @@
>  		status = "okay";
>  	};
>  
> +	usbotg: usb@3f120000 {
> +		status = "okay";
> +	};

using &usbotg could have been better. I mean if you have something like
&usbotg, you realise that the node has been created somewhere and we are just
referencing it here to add more properties.

Thanks
Kishon

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

* Re: [PATCH v3 1/9] phy: add phy_get_bus_width()/phy_set_bus_width() calls
  2013-11-26 10:16   ` Kishon Vijay Abraham I
@ 2013-11-27 16:55     ` Matt Porter
  0 siblings, 0 replies; 28+ messages in thread
From: Matt Porter @ 2013-11-27 16:55 UTC (permalink / raw)
  To: Kishon Vijay Abraham I
  Cc: Felipe Balbi, Greg Kroah-Hartman, Rob Herring, Pawel Moll,
	Mark Rutland, Kumar Gala, Ian Campbell, Christian Daudt,
	Paul Zimmerman, Tomasz Figa, Kamil Debski, Kyungmin Park,
	Linux USB List, Linux ARM Kernel List, Linux Kernel Mailing List,
	Devicetree List, Linaro Patches

On Tue, Nov 26, 2013 at 03:46:26PM +0530, Kishon Vijay Abraham I wrote:
> Hi,
> 
> On Monday 25 November 2013 11:45 PM, Matt Porter wrote:
> > This adds a pair of APIs that allows the generic PHY subsystem to
> > provide information on the PHY bus width. The PHY provider driver may
> > use phy_set_bus_width() to set the bus width that the PHY supports.
> > The controller driver may then use phy_get_bus_width() to fetch the
> > PHY bus width in order to properly configure the controller.
> > 
> > Signed-off-by: Matt Porter <matt.porter@linaro.org>
> > ---
> >  include/linux/phy/phy.h | 20 ++++++++++++++++++++
> >  1 file changed, 20 insertions(+)
> > 
> > diff --git a/include/linux/phy/phy.h b/include/linux/phy/phy.h
> > index 6d72269..6ca6c61 100644
> > --- a/include/linux/phy/phy.h
> > +++ b/include/linux/phy/phy.h
> > @@ -46,6 +46,7 @@ struct phy_ops {
> >   * @mutex: mutex to protect phy_ops
> >   * @init_count: used to protect when the PHY is used by multiple consumers
> >   * @power_count: used to protect when the PHY is used by multiple consumers
> > + * @bus_width: used to specify data width of the PHY bus
> >   */
> >  struct phy {
> >  	struct device		dev;
> > @@ -55,6 +56,7 @@ struct phy {
> >  	struct mutex		mutex;
> >  	int			init_count;
> >  	int			power_count;
> > +	int			bus_width;
> 
> the bus_width can be part of the attrs struct which you initially proposed.
> Soon there will be requests for other attributes being added (e.g., speed).

Agreed, I'll merge the accessors with the original attrs struct.

> >  };
> >  
> >  /**
> > @@ -127,6 +129,14 @@ 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);
> > +static inline int phy_get_bus_width(struct phy *phy)
> > +{
> > +	return phy->bus_width;
> > +}
> > +static inline void phy_set_bus_width(struct phy *phy, int bus_width)
> 
> u32 bus_width?

will update

> > +{
> > +	phy->bus_width = bus_width;
> > +}
> >  struct phy *phy_get(struct device *dev, const char *string);
> >  struct phy *devm_phy_get(struct device *dev, const char *string);
> >  void phy_put(struct phy *phy);
> > @@ -199,6 +209,16 @@ static inline int phy_power_off(struct phy *phy)
> >  	return -ENOSYS;
> >  }
> >  
> > +static inline int phy_get_bus_width(struct phy *phy)
> > +{
> > +	return -ENOSYS;
> > +}
> > +
> > +static inline void phy_set_bus_width(struct phy *phy, bus_width)
> 
> er.. has this been compile tested?

*sigh* obviously not, will address this.

-Matt

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

* Re: [PATCH v3 2/9] staging: dwc2: update DT binding to add generic clock/phy properties
  2013-11-26 10:19   ` Kishon Vijay Abraham I
@ 2013-11-27 16:56     ` Matt Porter
  0 siblings, 0 replies; 28+ messages in thread
From: Matt Porter @ 2013-11-27 16:56 UTC (permalink / raw)
  To: Kishon Vijay Abraham I
  Cc: Felipe Balbi, Greg Kroah-Hartman, Rob Herring, Pawel Moll,
	Mark Rutland, Kumar Gala, Ian Campbell, Christian Daudt,
	Paul Zimmerman, Tomasz Figa, Kamil Debski, Kyungmin Park,
	Linux USB List, Linux ARM Kernel List, Linux Kernel Mailing List,
	Devicetree List, Linaro Patches

On Tue, Nov 26, 2013 at 03:49:30PM +0530, Kishon Vijay Abraham I wrote:
> On Monday 25 November 2013 11:46 PM, Matt Porter wrote:
> > dwc2/s3c-hsotg require a single clock to be specified and optionally
> > a generic phy. On the s3c-hsotg driver old style USB phy support is
> > present as a fallback so the generic phy properties are optional.
> > 
> > Signed-off-by: Matt Porter <matt.porter@linaro.org>
> > ---
> >  Documentation/devicetree/bindings/staging/dwc2.txt | 10 ++++++++++
> >  1 file changed, 10 insertions(+)
> > 
> > diff --git a/Documentation/devicetree/bindings/staging/dwc2.txt b/Documentation/devicetree/bindings/staging/dwc2.txt
> > index 1a1b7cf..b8b42b6 100644
> > --- a/Documentation/devicetree/bindings/staging/dwc2.txt
> > +++ b/Documentation/devicetree/bindings/staging/dwc2.txt
> > @@ -5,6 +5,12 @@ Required properties:
> >  - compatible : "snps,dwc2"
> >  - reg : Should contain 1 register range (address and length)
> >  - interrupts : Should contain 1 interrupt
> > +- clocks: clock provider specifier
> > +- clock-names: shall be "otg"
> > +- phys: phy provider specifier
> > +- phy-names: shall be "device"
> 
> lets mention in the Documentation too that the phy properties are optional.
> apart from that..

Good point, will do so.

> Acked-by: Kishon Vijay Abraham I <kishon@ti.com>
> > +Refer to clk/clock-bindings.txt for generic clock consumer properties
> > +Refer to phy/phy-bindings.txt for generic phy consumer properties
> >  
> >  Example:
> >  
> > @@ -12,4 +18,8 @@ Example:
> >                  compatible = "ralink,rt3050-usb, snps,dwc2";
> >                  reg = <0x101c0000 40000>;
> >                  interrupts = <18>;
> > +		clocks = <&usb_otg_ahb_clk>;
> > +		clock-names = "otg";
> > +		phys = <&usbphy>;
> > +		phy-names = "device";
> >          };
> > 
> 

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

* Re: [PATCH v3 5/9] usb: gadget: s3c-hsotg: use generic phy_init()/phy_exit() support
  2013-11-26 10:23   ` Kishon Vijay Abraham I
@ 2013-11-27 17:13     ` Matt Porter
  2013-11-27 22:36       ` Matt Porter
  0 siblings, 1 reply; 28+ messages in thread
From: Matt Porter @ 2013-11-27 17:13 UTC (permalink / raw)
  To: Kishon Vijay Abraham I
  Cc: Felipe Balbi, Greg Kroah-Hartman, Rob Herring, Pawel Moll,
	Mark Rutland, Kumar Gala, Ian Campbell, Christian Daudt,
	Paul Zimmerman, Tomasz Figa, Kamil Debski, Kyungmin Park,
	Linux USB List, Linux ARM Kernel List, Linux Kernel Mailing List,
	Devicetree List, Linaro Patches

On Tue, Nov 26, 2013 at 03:53:32PM +0530, Kishon Vijay Abraham I wrote:
> Hi,
> 
> On Monday 25 November 2013 11:46 PM, Matt Porter wrote:
> > If a generic phy is present, call phy_init()/phy_exit(). This supports
> > generic phys that must be soft reset before power on.
> > 
> > Signed-off-by: Matt Porter <matt.porter@linaro.org>
> > ---
> >  drivers/usb/gadget/s3c-hsotg.c | 5 +++++
> >  1 file changed, 5 insertions(+)
> > 
> > diff --git a/drivers/usb/gadget/s3c-hsotg.c b/drivers/usb/gadget/s3c-hsotg.c
> > index da3879b..8dfe33f 100644
> > --- a/drivers/usb/gadget/s3c-hsotg.c
> > +++ b/drivers/usb/gadget/s3c-hsotg.c
> > @@ -3622,6 +3622,9 @@ static int s3c_hsotg_probe(struct platform_device *pdev)
> >  		goto err_supplies;
> >  	}
> >  
> > +	if (hsotg->phy)
> 
> IS_ERR? If your phy_get fails *phy* will have a error value..

Yes, thanks. I'll fix these and also note that the same issue exists in
Kamil's patch for these same hsotg->phy conditional uses. I'll work with
Kamil to either get those addressed there or in a follow on fix.

> 
> > +		phy_init(hsotg->phy);
> > +
> >  	/* usb phy enable */
> >  	s3c_hsotg_phy_enable(hsotg);
> >  
> > @@ -3715,6 +3718,8 @@ static int s3c_hsotg_remove(struct platform_device *pdev)
> >  	}
> >  
> >  	s3c_hsotg_phy_disable(hsotg);
> > +	if (hsotg->phy)
> 
> same here.

Ok.

> 
> Thanks
> Kishon

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

* Re: [PATCH v3 6/9] usb: gadget: s3c-hsotg: get phy bus width from phy subsystem
  2013-11-26 10:28   ` Kishon Vijay Abraham I
@ 2013-11-27 17:16     ` Matt Porter
  0 siblings, 0 replies; 28+ messages in thread
From: Matt Porter @ 2013-11-27 17:16 UTC (permalink / raw)
  To: Kishon Vijay Abraham I
  Cc: Felipe Balbi, Greg Kroah-Hartman, Rob Herring, Pawel Moll,
	Mark Rutland, Kumar Gala, Ian Campbell, Christian Daudt,
	Paul Zimmerman, Tomasz Figa, Kamil Debski, Kyungmin Park,
	Linux USB List, Linux ARM Kernel List, Linux Kernel Mailing List,
	Devicetree List, Linaro Patches

On Tue, Nov 26, 2013 at 03:58:45PM +0530, Kishon Vijay Abraham I wrote:
> Hi,
> 
> On Monday 25 November 2013 11:46 PM, Matt Porter wrote:
> > Adds support for querying the phy bus width from the generic phy
> > subsystem. Configure UTMI bus width in GUSBCFG based on this value.
> > 
> > Signed-off-by: Matt Porter <matt.porter@linaro.org>
> > ---
> >  drivers/usb/gadget/s3c-hsotg.c | 14 +++++++++++++-
> >  drivers/usb/gadget/s3c-hsotg.h |  1 +
> >  2 files changed, 14 insertions(+), 1 deletion(-)
> > 
> > diff --git a/drivers/usb/gadget/s3c-hsotg.c b/drivers/usb/gadget/s3c-hsotg.c
> > index 8dfe33f..be41585 100644
> > --- a/drivers/usb/gadget/s3c-hsotg.c
> > +++ b/drivers/usb/gadget/s3c-hsotg.c
> > @@ -144,6 +144,7 @@ struct s3c_hsotg_ep {
> >   * @regs: The memory area mapped for accessing registers.
> >   * @irq: The IRQ number we are using
> >   * @supplies: Definition of USB power supplies
> > + * @phyif: PHY interface width
> >   * @dedicated_fifos: Set if the hardware has dedicated IN-EP fifos.
> >   * @num_of_eps: Number of available EPs (excluding EP0)
> >   * @debug_root: root directrory for debugfs.
> > @@ -171,6 +172,7 @@ struct s3c_hsotg {
> >  
> >  	struct regulator_bulk_data supplies[ARRAY_SIZE(s3c_hsotg_supply_names)];
> >  
> > +	u32			phyif;
> >  	unsigned int		dedicated_fifos:1;
> >  	unsigned char           num_of_eps;
> >  
> > @@ -2276,7 +2278,7 @@ static void s3c_hsotg_core_init(struct s3c_hsotg *hsotg)
> >  	 */
> >  
> >  	/* set the PLL on, remove the HNP/SRP and set the PHY */
> > -	writel(GUSBCFG_PHYIf16 | GUSBCFG_TOutCal(7) |
> > +	writel(hsotg->phyif | GUSBCFG_TOutCal(7) |
> >  	       (0x5 << 10), hsotg->regs + GUSBCFG);
> >  
> >  	s3c_hsotg_init_fifo(hsotg);
> > @@ -3622,6 +3624,16 @@ static int s3c_hsotg_probe(struct platform_device *pdev)
> >  		goto err_supplies;
> >  	}
> >  
> > +	/* Set default UTMI width */
> > +	hsotg->phyif = GUSBCFG_PHYIf16;
> > +
> > +	/*
> > +	 * If using the generic PHY framework, check if the PHY bus
> > +	 * width is 8-bit and set the phyif appropriately.
> > +	 */
> > +	if (hsotg->phy && (phy_get_bus_width(phy) == 8))
> 
> what if the phy has error value here?

I'm addressing this like the other !IS_ERR checks. In the platform data
case, we'll have an error value here, and need to use the default. Until
the platform data case is removed (those platform board files removed),
we assume (correctly) that they use a phy interface width of 16.

-Matt

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

* Re: [PATCH v3 7/9] phy: add Broadcom Kona USB2 PHY DT binding
  2013-11-26 10:31   ` Kishon Vijay Abraham I
@ 2013-11-27 17:19     ` Matt Porter
  0 siblings, 0 replies; 28+ messages in thread
From: Matt Porter @ 2013-11-27 17:19 UTC (permalink / raw)
  To: Kishon Vijay Abraham I
  Cc: Felipe Balbi, Greg Kroah-Hartman, Rob Herring, Pawel Moll,
	Mark Rutland, Kumar Gala, Ian Campbell, Christian Daudt,
	Paul Zimmerman, Tomasz Figa, Kamil Debski, Kyungmin Park,
	Linux USB List, Linux ARM Kernel List, Linux Kernel Mailing List,
	Devicetree List, Linaro Patches

On Tue, Nov 26, 2013 at 04:01:05PM +0530, Kishon Vijay Abraham I wrote:
> Hi,
> 
> On Monday 25 November 2013 11:46 PM, Matt Porter wrote:
> > Add a binding that describes the Broadcom Kona USB2 PHY found
> > on the BCM281xx family of SoCs.
> > 
> > Signed-off-by: Matt Porter <matt.porter@linaro.org>
> > ---
> >  .../devicetree/bindings/phy/bcm-kona-usb2-phy.txt         | 15 +++++++++++++++
> >  1 file changed, 15 insertions(+)
> >  create mode 100644 Documentation/devicetree/bindings/phy/bcm-kona-usb2-phy.txt
> > 
> > diff --git a/Documentation/devicetree/bindings/phy/bcm-kona-usb2-phy.txt b/Documentation/devicetree/bindings/phy/bcm-kona-usb2-phy.txt
> > new file mode 100644
> > index 0000000..3dc8b3d
> > --- /dev/null
> > +++ b/Documentation/devicetree/bindings/phy/bcm-kona-usb2-phy.txt
> 
> you should name this bcm-phy. Then you can add binding info of all (future) PHY
> IP from broadcom here.
> 
> other than that this looks fine..

Ok, sounds reasonable. I've noticed that convention with the TI USB
bindings...I'll do the same.

> Acked-by: Kishon Vijay Abraham I <kishon@ti.com>
> 
> Thanks
> Kishon

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

* Re: [PATCH v3 8/9] phy: add Broadcom Kona USB2 PHY driver
  2013-11-27  8:51   ` Kishon Vijay Abraham I
@ 2013-11-27 17:21     ` Matt Porter
  0 siblings, 0 replies; 28+ messages in thread
From: Matt Porter @ 2013-11-27 17:21 UTC (permalink / raw)
  To: Kishon Vijay Abraham I
  Cc: Felipe Balbi, Greg Kroah-Hartman, Rob Herring, Pawel Moll,
	Mark Rutland, Kumar Gala, Ian Campbell, Christian Daudt,
	Paul Zimmerman, Tomasz Figa, Kamil Debski, Kyungmin Park,
	Linux USB List, Linux ARM Kernel List, Linux Kernel Mailing List,
	Devicetree List, Linaro Patches

On Wed, Nov 27, 2013 at 02:21:52PM +0530, Kishon Vijay Abraham I wrote:
> Hi,
> 
> On Monday 25 November 2013 11:46 PM, Matt Porter wrote:
> > Add a driver for the internal Broadcom Kona USB 2.0 PHY found
> > on the BCM281xx family of SoCs.
> > 
> > Signed-off-by: Matt Porter <matt.porter@linaro.org>
> > ---
> >  drivers/phy/Kconfig             |   6 ++
> >  drivers/phy/Makefile            |   1 +
> >  drivers/phy/phy-bcm-kona-usb2.c | 158 ++++++++++++++++++++++++++++++++++++++++
> >  3 files changed, 165 insertions(+)
> >  create mode 100644 drivers/phy/phy-bcm-kona-usb2.c
> > 
> > diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig
> > index a344f3d..2e87fa8 100644
> > --- a/drivers/phy/Kconfig
> > +++ b/drivers/phy/Kconfig
> > @@ -51,4 +51,10 @@ config PHY_EXYNOS_DP_VIDEO
> >  	help
> >  	  Support for Display Port PHY found on Samsung EXYNOS SoCs.
> >  
> > +config BCM_KONA_USB2_PHY
> > +	tristate "Broadcom Kona USB2 PHY Driver"
> > +	depends on GENERIC_PHY
> > +	help
> > +	  Enable this to support the Broadcom Kona USB 2.0 PHY.
> > +
> >  endmenu
> > diff --git a/drivers/phy/Makefile b/drivers/phy/Makefile
> > index d0caae9..c447f1a 100644
> > --- a/drivers/phy/Makefile
> > +++ b/drivers/phy/Makefile
> > @@ -3,6 +3,7 @@
> >  #
> >  
> >  obj-$(CONFIG_GENERIC_PHY)		+= phy-core.o
> > +obj-$(CONFIG_BCM_KONA_USB2_PHY)		+= phy-bcm-kona-usb2.o
> >  obj-$(CONFIG_PHY_EXYNOS_DP_VIDEO)	+= phy-exynos-dp-video.o
> >  obj-$(CONFIG_PHY_EXYNOS_MIPI_VIDEO)	+= phy-exynos-mipi-video.o
> >  obj-$(CONFIG_OMAP_USB2)			+= phy-omap-usb2.o
> > diff --git a/drivers/phy/phy-bcm-kona-usb2.c b/drivers/phy/phy-bcm-kona-usb2.c
> > new file mode 100644
> > index 0000000..2c54fb8
> > --- /dev/null
> > +++ b/drivers/phy/phy-bcm-kona-usb2.c
> > @@ -0,0 +1,158 @@
> > +/*
> > + * phy-bcm-kona-usb2.c - Broadcom Kona USB2 Phy Driver
> > + *
> > + * Copyright (C) 2013 Linaro Limited
> > + * Matt Porter <matt.porter@linaro.org>
> > + *
> > + * This software is licensed under the terms of the GNU General Public
> > + * License version 2, as published by the Free Software Foundation, and
> > + * may be copied, distributed, and modified under those terms.
> > + *
> > + * 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/module.h>
> > +#include <linux/of.h>
> > +#include <linux/delay.h>
> > +#include <linux/platform_device.h>
> > +#include <linux/err.h>
> > +#include <linux/io.h>
> > +#include <linux/clk.h>
> > +#include <linux/phy/phy.h>
> 
> arrange the headers in alphabetical order so that it's easy while adding new
> headers. Just my preference.

yeah, same here. just development creep that I will address.

> > +
> > +#define OTGCTL			(0)
> > +#define OTGCTL_OTGSTAT2		(1 << 31)
> > +#define OTGCTL_OTGSTAT1		(1 << 30)
> > +#define OTGCTL_PRST_N_SW	(1 << 11)
> > +#define OTGCTL_HRESET_N		(1 << 10)
> > +#define OTGCTL_UTMI_LINE_STATE1	(1 << 9)
> > +#define OTGCTL_UTMI_LINE_STATE0	(1 << 8)
> > +
> > +#define P1CTL			(8)
> > +#define P1CTL_SOFT_RESET	(1 << 1)
> > +#define P1CTL_NON_DRIVING	(1 << 0)
> 
> you can use BIT() instead.

will do

> > +
> > +struct bcm_kona_usb {
> > +	void __iomem *regs;
> > +};
> > +
> > +static void bcm_kona_usb_phy_power(struct bcm_kona_usb *phy, int on)
> > +{
> > +	u32 val;
> > +
> > +	val = readl(phy->regs + OTGCTL);
> > +	if (on) {
> > +		/* Configure and power PHY */
> > +		val &= ~(OTGCTL_OTGSTAT2 | OTGCTL_OTGSTAT1 |
> > +			 OTGCTL_UTMI_LINE_STATE1 | OTGCTL_UTMI_LINE_STATE0);
> > +		val |= OTGCTL_PRST_N_SW | OTGCTL_HRESET_N;
> > +	} else {
> > +		val &= ~(OTGCTL_PRST_N_SW | OTGCTL_HRESET_N);
> > +	}
> > +	writel(val, phy->regs + OTGCTL);
> > +}
> > +
> > +static int bcm_kona_usb_phy_init(struct phy *gphy)
> > +{
> > +	struct bcm_kona_usb *phy = phy_get_drvdata(gphy);
> > +	u32 val;
> > +
> > +	/* Soft reset PHY */
> > +	val = readl(phy->regs + P1CTL);
> > +	val &= ~P1CTL_NON_DRIVING;
> > +	val |= P1CTL_SOFT_RESET;
> > +	writel(val, phy->regs + P1CTL);
> > +	writel(val & ~P1CTL_SOFT_RESET, phy->regs + P1CTL);
> > +	/* Reset needs to be asserted for 2ms */
> > +	mdelay(2);
> > +	writel(val | P1CTL_SOFT_RESET, phy->regs + P1CTL);
> > +
> > +	return 0;
> > +}
> > +
> > +static int bcm_kona_usb_phy_power_on(struct phy *gphy)
> > +{
> > +	struct bcm_kona_usb *phy = phy_get_drvdata(gphy);
> > +
> > +	bcm_kona_usb_phy_power(phy, 1);
> > +
> > +	return 0;
> > +}
> > +
> > +static int bcm_kona_usb_phy_power_off(struct phy *gphy)
> > +{
> > +	struct bcm_kona_usb *phy = phy_get_drvdata(gphy);
> > +
> > +	bcm_kona_usb_phy_power(phy, 0);
> > +
> > +	return 0;
> > +}
> > +
> > +static struct phy_ops ops = {
> > +	.init		= bcm_kona_usb_phy_init,
> > +	.power_on	= bcm_kona_usb_phy_power_on,
> > +	.power_off	= bcm_kona_usb_phy_power_off,
> > +	.owner = THIS_MODULE,
> 
> owner is aligned differently..

ok

> > +};
> > +
> > +static int bcm_kona_usb2_probe(struct platform_device *pdev)
> > +{
> > +	struct device *dev = &pdev->dev;
> > +	struct bcm_kona_usb *phy;
> > +	struct resource *res;
> > +	struct phy *gphy;
> > +	struct phy_provider *phy_provider;
> > +
> > +	phy = devm_kzalloc(dev, sizeof(*phy), GFP_KERNEL);
> > +	if (!phy)
> > +		return -ENOMEM;
> > +
> > +	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> > +	phy->regs = devm_ioremap_resource(&pdev->dev, res);
> > +	if (IS_ERR(phy->regs))
> > +		return PTR_ERR(phy->regs);
> > +
> > +	platform_set_drvdata(pdev, phy);
> > +
> > +	phy_provider = devm_of_phy_provider_register(dev,
> > +			of_phy_simple_xlate);
> > +	if (IS_ERR(phy_provider))
> > +		return PTR_ERR(phy_provider);
> > +
> > +	gphy = devm_phy_create(dev, &ops, NULL);
> > +	if (IS_ERR(gphy))
> > +		return PTR_ERR(gphy);
> > +
> > +	/* The Kona PHY supports an 8-bit wide UTMI interface */
> > +	phy_set_bus_width(gphy, 8);
> > +
> > +	phy_set_drvdata(gphy, phy);
> > +
> > +	return 0;
> > +}
> > +
> > +static const struct of_device_id bcm_kona_usb2_dt_ids[] = {
> > +	{ .compatible = "brcm,kona-usb2-phy" },
> > +	{ /* sentinel */ }
> > +};
> > +
> > +MODULE_DEVICE_TABLE(of, bcm_kona_usb2_dt_ids);
> > +
> > +static struct platform_driver bcm_kona_usb2_driver = {
> > +	.probe		= bcm_kona_usb2_probe,
> > +	.driver		= {
> > +		.name	= "bcm-kona-usb2",
> > +		.owner	= THIS_MODULE,
> > +		.of_match_table = bcm_kona_usb2_dt_ids,
> > +	},
> > +};
> > +
> > +module_platform_driver(bcm_kona_usb2_driver);
> > +
> > +MODULE_ALIAS("platform:bcm-kona-usb2");
> > +MODULE_AUTHOR("Matt Porter <matt.porter@linaro.org>");
> > +MODULE_DESCRIPTION("BCM Kona USB 2.0 PHY driver");
> > +MODULE_LICENSE("GPL v2");
> > 
> Apart from those comments, this patch looks good.

Ok, thanks much for all the reviews.

-Matt

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

* Re: [PATCH v3 9/9] ARM: dts: add usb udc support to bcm281xx
  2013-11-27  8:57   ` Kishon Vijay Abraham I
@ 2013-11-27 17:24     ` Matt Porter
  0 siblings, 0 replies; 28+ messages in thread
From: Matt Porter @ 2013-11-27 17:24 UTC (permalink / raw)
  To: Kishon Vijay Abraham I
  Cc: Felipe Balbi, Greg Kroah-Hartman, Rob Herring, Pawel Moll,
	Mark Rutland, Kumar Gala, Ian Campbell, Christian Daudt,
	Paul Zimmerman, Tomasz Figa, Kamil Debski, Kyungmin Park,
	Linux USB List, Linux ARM Kernel List, Linux Kernel Mailing List,
	Devicetree List, Linaro Patches

On Wed, Nov 27, 2013 at 02:27:19PM +0530, Kishon Vijay Abraham I wrote:
> Hi,
> 
> On Monday 25 November 2013 11:46 PM, Matt Porter wrote:
> > Adds USB OTG/PHY and clock support to BCM281xx and enables
> > UDC support on the bcm11351-brt and bcm28155-ap boards.
> > 
> > Signed-off-by: Matt Porter <matt.porter@linaro.org>
> > Reviewed-by: Markus Mayer <markus.mayer@linaro.org>
> > Reviewed-by: Tim Kryger <tim.kryger@linaro.org>
> > ---
> >  arch/arm/boot/dts/bcm11351-brt.dts |  6 ++++++
> >  arch/arm/boot/dts/bcm11351.dtsi    | 18 ++++++++++++++++++
> >  arch/arm/boot/dts/bcm28155-ap.dts  |  8 ++++++++
> >  3 files changed, 32 insertions(+)
> > 
> > diff --git a/arch/arm/boot/dts/bcm11351-brt.dts b/arch/arm/boot/dts/bcm11351-brt.dts
> > index 23cd16d..396b704 100644
> > --- a/arch/arm/boot/dts/bcm11351-brt.dts
> > +++ b/arch/arm/boot/dts/bcm11351-brt.dts
> > @@ -44,5 +44,11 @@
> >  		status = "okay";
> >  	};
> >  
> > +	usbotg: usb@3f120000 {
> > +		status = "okay";
> > +	};
> 
> using &usbotg could have been better. I mean if you have something like
> &usbotg, you realise that the node has been created somewhere and we are just
> referencing it here to add more properties.

That's normally my preference, but Christian owns this file and doesn't
like that syntax. Instead, I'm conforming with the rest of the .dts
entries. He and I discussed moving to &label references a while back and
that's a no go.

Thanks,
Matt

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

* Re: [PATCH v3 5/9] usb: gadget: s3c-hsotg: use generic phy_init()/phy_exit() support
  2013-11-27 17:13     ` Matt Porter
@ 2013-11-27 22:36       ` Matt Porter
  2013-11-28  5:53         ` Kishon Vijay Abraham I
  0 siblings, 1 reply; 28+ messages in thread
From: Matt Porter @ 2013-11-27 22:36 UTC (permalink / raw)
  To: Kishon Vijay Abraham I
  Cc: Felipe Balbi, Greg Kroah-Hartman, Rob Herring, Pawel Moll,
	Mark Rutland, Kumar Gala, Ian Campbell, Christian Daudt,
	Paul Zimmerman, Tomasz Figa, Kamil Debski, Kyungmin Park,
	Linux USB List, Linux ARM Kernel List, Linux Kernel Mailing List,
	Devicetree List, Linaro Patches

On Wed, Nov 27, 2013 at 12:13:25PM -0500, Matt Porter wrote:
> On Tue, Nov 26, 2013 at 03:53:32PM +0530, Kishon Vijay Abraham I wrote:
> > Hi,
> > 
> > On Monday 25 November 2013 11:46 PM, Matt Porter wrote:
> > > If a generic phy is present, call phy_init()/phy_exit(). This supports
> > > generic phys that must be soft reset before power on.
> > > 
> > > Signed-off-by: Matt Porter <matt.porter@linaro.org>
> > > ---
> > >  drivers/usb/gadget/s3c-hsotg.c | 5 +++++
> > >  1 file changed, 5 insertions(+)
> > > 
> > > diff --git a/drivers/usb/gadget/s3c-hsotg.c b/drivers/usb/gadget/s3c-hsotg.c
> > > index da3879b..8dfe33f 100644
> > > --- a/drivers/usb/gadget/s3c-hsotg.c
> > > +++ b/drivers/usb/gadget/s3c-hsotg.c
> > > @@ -3622,6 +3622,9 @@ static int s3c_hsotg_probe(struct platform_device *pdev)
> > >  		goto err_supplies;
> > >  	}
> > >  
> > > +	if (hsotg->phy)
> > 
> > IS_ERR? If your phy_get fails *phy* will have a error value..
> 
> Yes, thanks. I'll fix these and also note that the same issue exists in
> Kamil's patch for these same hsotg->phy conditional uses. I'll work with
> Kamil to either get those addressed there or in a follow on fix.

I spoke too soon. If devm_phy_get fails, we don't set hsotg->phy and probe
defer thus not reaching this point. Since hsotg->phy is either NULL or a
valid struct phy *, this is correct as is throughout the driver.

> > 
> > > +		phy_init(hsotg->phy);
> > > +
> > >  	/* usb phy enable */
> > >  	s3c_hsotg_phy_enable(hsotg);
> > >  
> > > @@ -3715,6 +3718,8 @@ static int s3c_hsotg_remove(struct platform_device *pdev)
> > >  	}
> > >  
> > >  	s3c_hsotg_phy_disable(hsotg);
> > > +	if (hsotg->phy)
> > 
> > same here.
> 
> Ok.

Same above, this will be NULL on failure (but is only applicable at this
point on the platform data path.

-Matt

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

* Re: [PATCH v3 5/9] usb: gadget: s3c-hsotg: use generic phy_init()/phy_exit() support
  2013-11-27 22:36       ` Matt Porter
@ 2013-11-28  5:53         ` Kishon Vijay Abraham I
  2013-11-28 16:41           ` Matt Porter
  0 siblings, 1 reply; 28+ messages in thread
From: Kishon Vijay Abraham I @ 2013-11-28  5:53 UTC (permalink / raw)
  To: Matt Porter
  Cc: Felipe Balbi, Greg Kroah-Hartman, Rob Herring, Pawel Moll,
	Mark Rutland, Kumar Gala, Ian Campbell, Christian Daudt,
	Paul Zimmerman, Tomasz Figa, Kamil Debski, Kyungmin Park,
	Linux USB List, Linux ARM Kernel List, Linux Kernel Mailing List,
	Devicetree List, Linaro Patches

On Thursday 28 November 2013 04:06 AM, Matt Porter wrote:
> On Wed, Nov 27, 2013 at 12:13:25PM -0500, Matt Porter wrote:
>> On Tue, Nov 26, 2013 at 03:53:32PM +0530, Kishon Vijay Abraham I wrote:
>>> Hi,
>>>
>>> On Monday 25 November 2013 11:46 PM, Matt Porter wrote:
>>>> If a generic phy is present, call phy_init()/phy_exit(). This supports
>>>> generic phys that must be soft reset before power on.
>>>>
>>>> Signed-off-by: Matt Porter <matt.porter@linaro.org>
>>>> ---
>>>>  drivers/usb/gadget/s3c-hsotg.c | 5 +++++
>>>>  1 file changed, 5 insertions(+)
>>>>
>>>> diff --git a/drivers/usb/gadget/s3c-hsotg.c b/drivers/usb/gadget/s3c-hsotg.c
>>>> index da3879b..8dfe33f 100644
>>>> --- a/drivers/usb/gadget/s3c-hsotg.c
>>>> +++ b/drivers/usb/gadget/s3c-hsotg.c
>>>> @@ -3622,6 +3622,9 @@ static int s3c_hsotg_probe(struct platform_device *pdev)
>>>>  		goto err_supplies;
>>>>  	}
>>>>  
>>>> +	if (hsotg->phy)
>>>
>>> IS_ERR? If your phy_get fails *phy* will have a error value..
>>
>> Yes, thanks. I'll fix these and also note that the same issue exists in
>> Kamil's patch for these same hsotg->phy conditional uses. I'll work with
>> Kamil to either get those addressed there or in a follow on fix.
> 
> I spoke too soon. If devm_phy_get fails, we don't set hsotg->phy and probe
> defer thus not reaching this point. Since hsotg->phy is either NULL or a
> valid struct phy *, this is correct as is throughout the driver.
> 
>>>
>>>> +		phy_init(hsotg->phy);
>>>> +
>>>>  	/* usb phy enable */
>>>>  	s3c_hsotg_phy_enable(hsotg);
>>>>  
>>>> @@ -3715,6 +3718,8 @@ static int s3c_hsotg_remove(struct platform_device *pdev)
>>>>  	}
>>>>  
>>>>  	s3c_hsotg_phy_disable(hsotg);
>>>> +	if (hsotg->phy)
>>>
>>> same here.
>>
>> Ok.
> 
> Same above, this will be NULL on failure (but is only applicable at this
> point on the platform data path.

Ah ok.. Btw where is phy_get being called? Is it not part of this series?

Thanks
Kishon

> 
> -Matt
> 


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

* Re: [PATCH v3 5/9] usb: gadget: s3c-hsotg: use generic phy_init()/phy_exit() support
  2013-11-28  5:53         ` Kishon Vijay Abraham I
@ 2013-11-28 16:41           ` Matt Porter
  2013-11-28 17:02             ` Kamil Debski
  0 siblings, 1 reply; 28+ messages in thread
From: Matt Porter @ 2013-11-28 16:41 UTC (permalink / raw)
  To: Kishon Vijay Abraham I
  Cc: Felipe Balbi, Greg Kroah-Hartman, Rob Herring, Pawel Moll,
	Mark Rutland, Kumar Gala, Ian Campbell, Christian Daudt,
	Paul Zimmerman, Tomasz Figa, Kamil Debski, Kyungmin Park,
	Linux USB List, Linux ARM Kernel List, Linux Kernel Mailing List,
	Devicetree List, Linaro Patches

On Thu, Nov 28, 2013 at 11:23:52AM +0530, Kishon Vijay Abraham I wrote:
> On Thursday 28 November 2013 04:06 AM, Matt Porter wrote:
> > On Wed, Nov 27, 2013 at 12:13:25PM -0500, Matt Porter wrote:
> >> On Tue, Nov 26, 2013 at 03:53:32PM +0530, Kishon Vijay Abraham I wrote:
> >>> Hi,
> >>>
> >>> On Monday 25 November 2013 11:46 PM, Matt Porter wrote:
> >>>> If a generic phy is present, call phy_init()/phy_exit(). This supports
> >>>> generic phys that must be soft reset before power on.
> >>>>
> >>>> Signed-off-by: Matt Porter <matt.porter@linaro.org>
> >>>> ---
> >>>>  drivers/usb/gadget/s3c-hsotg.c | 5 +++++
> >>>>  1 file changed, 5 insertions(+)
> >>>>
> >>>> diff --git a/drivers/usb/gadget/s3c-hsotg.c b/drivers/usb/gadget/s3c-hsotg.c
> >>>> index da3879b..8dfe33f 100644
> >>>> --- a/drivers/usb/gadget/s3c-hsotg.c
> >>>> +++ b/drivers/usb/gadget/s3c-hsotg.c
> >>>> @@ -3622,6 +3622,9 @@ static int s3c_hsotg_probe(struct platform_device *pdev)
> >>>>  		goto err_supplies;
> >>>>  	}
> >>>>  
> >>>> +	if (hsotg->phy)
> >>>
> >>> IS_ERR? If your phy_get fails *phy* will have a error value..
> >>
> >> Yes, thanks. I'll fix these and also note that the same issue exists in
> >> Kamil's patch for these same hsotg->phy conditional uses. I'll work with
> >> Kamil to either get those addressed there or in a follow on fix.
> > 
> > I spoke too soon. If devm_phy_get fails, we don't set hsotg->phy and probe
> > defer thus not reaching this point. Since hsotg->phy is either NULL or a
> > valid struct phy *, this is correct as is throughout the driver.
> > 
> >>>
> >>>> +		phy_init(hsotg->phy);
> >>>> +
> >>>>  	/* usb phy enable */
> >>>>  	s3c_hsotg_phy_enable(hsotg);
> >>>>  
> >>>> @@ -3715,6 +3718,8 @@ static int s3c_hsotg_remove(struct platform_device *pdev)
> >>>>  	}
> >>>>  
> >>>>  	s3c_hsotg_phy_disable(hsotg);
> >>>> +	if (hsotg->phy)
> >>>
> >>> same here.
> >>
> >> Ok.
> > 
> > Same above, this will be NULL on failure (but is only applicable at this
> > point on the platform data path.
> 
> Ah ok.. Btw where is phy_get being called? Is it not part of this series?

It's in the Kamil's Exynos USB Phy -> generic phy series [1] which I depend
on here. I mentioned it in the cover letter toward the end so it's a bit
buried.

I have some outstanding, but trivial, comments on that series but I hear
Kamil will be posting an update in the coming days. I'll wait a few days
to post v4 addressing your comments so I can hopefully rebase against
his updated s3c-hsotg patch.

-Matt

[1] https://lkml.org/lkml/2013/11/5/275

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

* RE: [PATCH v3 5/9] usb: gadget: s3c-hsotg: use generic phy_init()/phy_exit() support
  2013-11-28 16:41           ` Matt Porter
@ 2013-11-28 17:02             ` Kamil Debski
  0 siblings, 0 replies; 28+ messages in thread
From: Kamil Debski @ 2013-11-28 17:02 UTC (permalink / raw)
  To: 'Matt Porter', 'Kishon Vijay Abraham I'
  Cc: 'Felipe Balbi', 'Greg Kroah-Hartman',
	'Rob Herring', 'Pawel Moll',
	'Mark Rutland', 'Kumar Gala',
	'Ian Campbell', 'Christian Daudt',
	'Paul Zimmerman', Tomasz Figa, 'Kyungmin Park',
	'Linux USB List', 'Linux ARM Kernel List',
	'Linux Kernel Mailing List', 'Devicetree List',
	'Linaro Patches'

Hi Matt,

> From: Matt Porter [mailto:matt.porter@linaro.org]
> Sent: Thursday, November 28, 2013 5:42 PM
> 
> On Thu, Nov 28, 2013 at 11:23:52AM +0530, Kishon Vijay Abraham I wrote:
> > On Thursday 28 November 2013 04:06 AM, Matt Porter wrote:
> > > On Wed, Nov 27, 2013 at 12:13:25PM -0500, Matt Porter wrote:
> > >> On Tue, Nov 26, 2013 at 03:53:32PM +0530, Kishon Vijay Abraham I
> wrote:
> > >>> Hi,
> > >>>
> > >>> On Monday 25 November 2013 11:46 PM, Matt Porter wrote:
> > >>>> If a generic phy is present, call phy_init()/phy_exit(). This
> > >>>> supports generic phys that must be soft reset before power on.
> > >>>>
> > >>>> Signed-off-by: Matt Porter <matt.porter@linaro.org>
> > >>>> ---
> > >>>>  drivers/usb/gadget/s3c-hsotg.c | 5 +++++
> > >>>>  1 file changed, 5 insertions(+)
> > >>>>
> > >>>> diff --git a/drivers/usb/gadget/s3c-hsotg.c
> > >>>> b/drivers/usb/gadget/s3c-hsotg.c index da3879b..8dfe33f 100644
> > >>>> --- a/drivers/usb/gadget/s3c-hsotg.c
> > >>>> +++ b/drivers/usb/gadget/s3c-hsotg.c
> > >>>> @@ -3622,6 +3622,9 @@ static int s3c_hsotg_probe(struct
> platform_device *pdev)
> > >>>>  		goto err_supplies;
> > >>>>  	}
> > >>>>
> > >>>> +	if (hsotg->phy)
> > >>>
> > >>> IS_ERR? If your phy_get fails *phy* will have a error value..
> > >>
> > >> Yes, thanks. I'll fix these and also note that the same issue
> > >> exists in Kamil's patch for these same hsotg->phy conditional uses.
> > >> I'll work with Kamil to either get those addressed there or in a
> follow on fix.
> > >
> > > I spoke too soon. If devm_phy_get fails, we don't set hsotg->phy
> and
> > > probe defer thus not reaching this point. Since hsotg->phy is
> either
> > > NULL or a valid struct phy *, this is correct as is throughout the
> driver.
> > >
> > >>>
> > >>>> +		phy_init(hsotg->phy);
> > >>>> +
> > >>>>  	/* usb phy enable */
> > >>>>  	s3c_hsotg_phy_enable(hsotg);
> > >>>>
> > >>>> @@ -3715,6 +3718,8 @@ static int s3c_hsotg_remove(struct
> platform_device *pdev)
> > >>>>  	}
> > >>>>
> > >>>>  	s3c_hsotg_phy_disable(hsotg);
> > >>>> +	if (hsotg->phy)
> > >>>
> > >>> same here.
> > >>
> > >> Ok.
> > >
> > > Same above, this will be NULL on failure (but is only applicable at
> > > this point on the platform data path.
> >
> > Ah ok.. Btw where is phy_get being called? Is it not part of this
> series?
> 
> It's in the Kamil's Exynos USB Phy -> generic phy series [1] which I
> depend on here. I mentioned it in the cover letter toward the end so
> it's a bit buried.
> 
> I have some outstanding, but trivial, comments on that series but I
> hear Kamil will be posting an update in the coming days. I'll wait a
> few days to post v4 addressing your comments so I can hopefully rebase
> against his updated s3c-hsotg patch.
> 

I am sorry to keep you waiting. I was doing some urgent non USB work 
lately and that is the reason for the delay. Thank you for the review of
the last version, by the way. I should post the new version on Wednesday
(or Tuesday afternoon, time permitting). Also, I will have no access to
my Samsung email until Tuesday.

Best wishes,
Kamil Debski



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

end of thread, other threads:[~2013-11-28 17:02 UTC | newest]

Thread overview: 28+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-11-25 18:15 [PATCH v3 0/9] USB Device Controller support for BCM281xx Matt Porter
2013-11-25 18:15 ` [PATCH v3 1/9] phy: add phy_get_bus_width()/phy_set_bus_width() calls Matt Porter
2013-11-26 10:16   ` Kishon Vijay Abraham I
2013-11-27 16:55     ` Matt Porter
2013-11-25 18:16 ` [PATCH v3 2/9] staging: dwc2: update DT binding to add generic clock/phy properties Matt Porter
2013-11-26 10:19   ` Kishon Vijay Abraham I
2013-11-27 16:56     ` Matt Porter
2013-11-25 18:16 ` [PATCH v3 3/9] usb: gadget: s3c-hsotg: enable build for other platforms Matt Porter
2013-11-25 18:16 ` [PATCH v3 4/9] usb: gadget: s3c-hsotg: add snps,dwc2 compatible string Matt Porter
2013-11-25 18:16 ` [PATCH v3 5/9] usb: gadget: s3c-hsotg: use generic phy_init()/phy_exit() support Matt Porter
2013-11-26 10:23   ` Kishon Vijay Abraham I
2013-11-27 17:13     ` Matt Porter
2013-11-27 22:36       ` Matt Porter
2013-11-28  5:53         ` Kishon Vijay Abraham I
2013-11-28 16:41           ` Matt Porter
2013-11-28 17:02             ` Kamil Debski
2013-11-25 18:16 ` [PATCH v3 6/9] usb: gadget: s3c-hsotg: get phy bus width from phy subsystem Matt Porter
2013-11-26 10:28   ` Kishon Vijay Abraham I
2013-11-27 17:16     ` Matt Porter
2013-11-25 18:16 ` [PATCH v3 7/9] phy: add Broadcom Kona USB2 PHY DT binding Matt Porter
2013-11-26 10:31   ` Kishon Vijay Abraham I
2013-11-27 17:19     ` Matt Porter
2013-11-25 18:16 ` [PATCH v3 8/9] phy: add Broadcom Kona USB2 PHY driver Matt Porter
2013-11-27  8:51   ` Kishon Vijay Abraham I
2013-11-27 17:21     ` Matt Porter
2013-11-25 18:16 ` [PATCH v3 9/9] ARM: dts: add usb udc support to bcm281xx Matt Porter
2013-11-27  8:57   ` Kishon Vijay Abraham I
2013-11-27 17:24     ` Matt Porter

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).