Re: [PATCH v11 0/8] PHY framework

2013-08-28 Thread Kishon Vijay Abraham I
Hi,

On Wednesday 28 August 2013 12:50 AM, Felipe Balbi wrote:
 Hi,
 
 On Mon, Aug 26, 2013 at 01:44:49PM +0530, Kishon Vijay Abraham I wrote:
 On Wednesday 21 August 2013 11:16 AM, Kishon Vijay Abraham I wrote:
 Added a generic PHY framework that provides a set of APIs for the PHY 
 drivers
 to create/destroy a PHY and APIs for the PHY users to obtain a reference to
 the PHY with or without using phandle.

 This framework will be of use only to devices that uses external PHY (PHY
 functionality is not embedded within the controller).

 The intention of creating this framework is to bring the phy drivers spread
 all over the Linux kernel to drivers/phy to increase code re-use and to
 increase code maintainability.

 Comments to make PHY as bus wasn't done because PHY devices can be part of
 other bus and making a same device attached to multiple bus leads to bad
 design.

 If the PHY driver has to send notification on connect/disconnect, the PHY
 driver should make use of the extcon framework. Using this susbsystem
 to use extcon framwork will have to be analysed.

 You can find this patch series @
 git://git.kernel.org/pub/scm/linux/kernel/git/kishon/linux-phy.git testing

 Looks like there are not further comments on this series. Can you take this 
 in
 your misc tree?
 
 Do you want me to queue these for you ? There are quite a few users for
 this framework already and I know of at least 2 others which will show
 up for v3.13.

yeah sure. That would be better I think.

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


Re: [PATCH v11 0/8] PHY framework

2013-08-26 Thread Kishon Vijay Abraham I
Hi Greg,

On Wednesday 21 August 2013 11:16 AM, Kishon Vijay Abraham I wrote:
 Added a generic PHY framework that provides a set of APIs for the PHY drivers
 to create/destroy a PHY and APIs for the PHY users to obtain a reference to
 the PHY with or without using phandle.
 
 This framework will be of use only to devices that uses external PHY (PHY
 functionality is not embedded within the controller).
 
 The intention of creating this framework is to bring the phy drivers spread
 all over the Linux kernel to drivers/phy to increase code re-use and to
 increase code maintainability.
 
 Comments to make PHY as bus wasn't done because PHY devices can be part of
 other bus and making a same device attached to multiple bus leads to bad
 design.
 
 If the PHY driver has to send notification on connect/disconnect, the PHY
 driver should make use of the extcon framework. Using this susbsystem
 to use extcon framwork will have to be analysed.
 
 You can find this patch series @
 git://git.kernel.org/pub/scm/linux/kernel/git/kishon/linux-phy.git testing

Looks like there are not further comments on this series. Can you take this in
your misc tree?

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


Re: [PATCH v4] extcon: palmas: Added a new compatible type *ti,palmas-usb-vid*

2013-08-26 Thread Kishon Vijay Abraham I
On Saturday 24 August 2013 12:47 AM, Stephen Warren wrote:
 On 08/23/2013 05:28 AM, Kishon Vijay Abraham I wrote:
 Hi,

 On Friday 23 August 2013 02:20 AM, Stephen Warren wrote:
 On 08/22/2013 02:31 AM, Kishon Vijay Abraham I wrote:
 The Palmas device contains only a USB VBUS-ID detector, so added a
 compatible type *ti,palmas-usb-vid*. Didn't remove the existing compatible
 types for backward compatibility.

 diff --git a/Documentation/devicetree/bindings/extcon/extcon-palmas.txt 
 b/Documentation/devicetree/bindings/extcon/extcon-palmas.txt

  PALMAS USB COMPARATOR
  Required Properties:
 - - compatible : Should be ti,palmas-usb or ti,twl6035-usb
 + - compatible : Should be ti,palmas-usb-vid. ti,twl6035-usb and
 +   ti,palmas-usb is deprecated and is kept for backward compatibility.

 So this defines one new value and deprecates the two old values.

 yeah.

 Why isn't a new ti,twl6035-usb-vid entry useful? Don't you still need

 yeah, it should be added too.
 SoC-specific compatible values so the driver can enable any SoC-specific
 bug-fixes/workarounds later if needed?

 hmm.. Palmas is external to SoC. So not sure if adding SoC specific 
 compatible
 values is such a good idea.
 
 In this case, but SoC, I meant the Palmas chip rather than the
 application processor. Is twl6035 a name for Palmas or something else?

yeah, tw6035 is a name for palmas.

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


Re: [PATCH v4] extcon: palmas: Added a new compatible type *ti,palmas-usb-vid*

2013-08-23 Thread Kishon Vijay Abraham I
Hi,

On Friday 23 August 2013 02:20 AM, Stephen Warren wrote:
 On 08/22/2013 02:31 AM, Kishon Vijay Abraham I wrote:
 The Palmas device contains only a USB VBUS-ID detector, so added a
 compatible type *ti,palmas-usb-vid*. Didn't remove the existing compatible
 types for backward compatibility.
 
 diff --git a/Documentation/devicetree/bindings/extcon/extcon-palmas.txt 
 b/Documentation/devicetree/bindings/extcon/extcon-palmas.txt
 
  PALMAS USB COMPARATOR
  Required Properties:
 - - compatible : Should be ti,palmas-usb or ti,twl6035-usb
 + - compatible : Should be ti,palmas-usb-vid. ti,twl6035-usb and
 +   ti,palmas-usb is deprecated and is kept for backward compatibility.
 
 So this defines one new value and deprecates the two old values.

yeah.
 
 Why isn't a new ti,twl6035-usb-vid entry useful? Don't you still need

yeah, it should be added too.
 SoC-specific compatible values so the driver can enable any SoC-specific
 bug-fixes/workarounds later if needed?

hmm.. Palmas is external to SoC. So not sure if adding SoC specific compatible
values is such a good idea.

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


[PATCH v4] extcon: palmas: Added a new compatible type *ti,palmas-usb-vid*

2013-08-22 Thread Kishon Vijay Abraham I
The Palmas device contains only a USB VBUS-ID detector, so added a
compatible type *ti,palmas-usb-vid*. Didn't remove the existing compatible
types for backward compatibility.

Signed-off-by: Kishon Vijay Abraham I kis...@ti.com
---
Changes from v3:
* Fixed commit log message (VID to VBUS-ID).
* Fixed the Documentation to tell ti,twl6035-usb and ti,palmas-usb is
deprecated

Changes from [1]:
* Since the old compatible values will be in 3.11 kernel, we shouldn't remove
the old compatible values. So retain the old compatible values.

[1] - http://www.spinics.net/lists/linux-omap/msg95843.html

 Documentation/devicetree/bindings/extcon/extcon-palmas.txt |3 ++-
 drivers/extcon/extcon-palmas.c |1 +
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/Documentation/devicetree/bindings/extcon/extcon-palmas.txt 
b/Documentation/devicetree/bindings/extcon/extcon-palmas.txt
index 7dab6a8..dc5fab3 100644
--- a/Documentation/devicetree/bindings/extcon/extcon-palmas.txt
+++ b/Documentation/devicetree/bindings/extcon/extcon-palmas.txt
@@ -2,7 +2,8 @@ EXTCON FOR PALMAS/TWL CHIPS
 
 PALMAS USB COMPARATOR
 Required Properties:
- - compatible : Should be ti,palmas-usb or ti,twl6035-usb
+ - compatible : Should be ti,palmas-usb-vid. ti,twl6035-usb and
+   ti,palmas-usb is deprecated and is kept for backward compatibility.
 
 Optional Properties:
  - ti,wakeup : To enable the wakeup comparator in probe
diff --git a/drivers/extcon/extcon-palmas.c b/drivers/extcon/extcon-palmas.c
index 89fdd05..9672f31 100644
--- a/drivers/extcon/extcon-palmas.c
+++ b/drivers/extcon/extcon-palmas.c
@@ -268,6 +268,7 @@ static const struct dev_pm_ops palmas_pm_ops = {
 
 static struct of_device_id of_palmas_match_tbl[] = {
{ .compatible = ti,palmas-usb, },
+   { .compatible = ti,palmas-usb-vid, },
{ .compatible = ti,twl6035-usb, },
{ /* end */ }
 };
-- 
1.7.10.4

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


[PATCH v3 1/5] arm: omap5: dts: fix reg property size

2013-08-21 Thread Kishon Vijay Abraham I
From: Felipe Balbi ba...@ti.com

USB3 block has a 64KiB space, another 64KiB is
used for the wrapper.

Without this change, resource_size() will get
confused and driver won't probe because size
will be negative.

Signed-off-by: Felipe Balbi ba...@ti.com
Signed-off-by: Kishon Vijay Abraham I kis...@ti.com
---
 arch/arm/boot/dts/omap5.dtsi |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/arm/boot/dts/omap5.dtsi b/arch/arm/boot/dts/omap5.dtsi
index e643620..5c99f19 100644
--- a/arch/arm/boot/dts/omap5.dtsi
+++ b/arch/arm/boot/dts/omap5.dtsi
@@ -637,7 +637,7 @@
omap_dwc3@4a02 {
compatible = ti,dwc3;
ti,hwmods = usb_otg_ss;
-   reg = 0x4a02 0x1000;
+   reg = 0x4a02 0x1;
interrupts = GIC_SPI 93 IRQ_TYPE_LEVEL_HIGH;
#address-cells = 1;
#size-cells = 1;
@@ -645,7 +645,7 @@
ranges;
dwc3@4a03 {
compatible = synopsys,dwc3;
-   reg = 0x4a03 0x1000;
+   reg = 0x4a03 0x1;
interrupts = GIC_SPI 92 IRQ_TYPE_LEVEL_HIGH;
usb-phy = usb2_phy, usb3_phy;
tx-fifo-resize;
-- 
1.7.10.4

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


[PATCH v3 4/5] arm: omap5: hwmod: add missing ocp2scp hwmod data

2013-08-21 Thread Kishon Vijay Abraham I
From: Benoit Cousson bcous...@baylibre.com

without that hwmod data, USB3 will not in OMAP5 boards.

Signed-off-by: Benoit Cousson bcous...@baylibre.com
Signed-off-by: Felipe Balbi ba...@ti.com
Signed-off-by: Kishon Vijay Abraham I kis...@ti.com
---
 arch/arm/mach-omap2/omap_hwmod_54xx_data.c |   45 
 1 file changed, 45 insertions(+)

diff --git a/arch/arm/mach-omap2/omap_hwmod_54xx_data.c 
b/arch/arm/mach-omap2/omap_hwmod_54xx_data.c
index 3c70f5c..33ae523 100644
--- a/arch/arm/mach-omap2/omap_hwmod_54xx_data.c
+++ b/arch/arm/mach-omap2/omap_hwmod_54xx_data.c
@@ -1114,6 +1114,42 @@ static struct omap_hwmod omap54xx_mpu_hwmod = {
 };
 
 /*
+ * 'ocp2scp' class
+ * bridge to transform ocp interface protocol to scp (serial control port)
+ * protocol
+ */
+
+static struct omap_hwmod_class_sysconfig omap54xx_ocp2scp_sysc = {
+   .rev_offs   = 0x,
+   .sysc_offs  = 0x0010,
+   .syss_offs  = 0x0014,
+   .sysc_flags = (SYSC_HAS_AUTOIDLE | SYSC_HAS_SIDLEMODE |
+   SYSC_HAS_SOFTRESET | SYSS_HAS_RESET_STATUS),
+   .idlemodes  = (SIDLE_FORCE | SIDLE_NO | SIDLE_SMART),
+   .sysc_fields= omap_hwmod_sysc_type1,
+};
+
+static struct omap_hwmod_class omap54xx_ocp2scp_hwmod_class = {
+   .name   = ocp2scp,
+   .sysc   = omap54xx_ocp2scp_sysc,
+};
+
+/* ocp2scp1 */
+static struct omap_hwmod omap54xx_ocp2scp1_hwmod = {
+   .name   = ocp2scp1,
+   .class  = omap54xx_ocp2scp_hwmod_class,
+   .clkdm_name = l3init_clkdm,
+   .main_clk   = l4_root_clk_div,
+   .prcm = {
+   .omap4 = {
+   .clkctrl_offs = 
OMAP54XX_CM_L3INIT_OCP2SCP1_CLKCTRL_OFFSET,
+   .context_offs = 
OMAP54XX_RM_L3INIT_OCP2SCP1_CONTEXT_OFFSET,
+   .modulemode   = MODULEMODE_HWCTRL,
+   },
+   },
+};
+
+/*
  * 'timer' class
  * general purpose timer module with accurate 1ms tick
  * This class contains several variants: ['timer_1ms', 'timer']
@@ -1920,6 +1956,14 @@ static struct omap_hwmod_ocp_if omap54xx_l4_cfg__mpu = {
.user   = OCP_USER_MPU | OCP_USER_SDMA,
 };
 
+/* l4_cfg - ocp2scp1 */
+static struct omap_hwmod_ocp_if omap54xx_l4_cfg__ocp2scp1 = {
+   .master = omap54xx_l4_cfg_hwmod,
+   .slave  = omap54xx_ocp2scp1_hwmod,
+   .clk= l4_root_clk_div,
+   .user   = OCP_USER_MPU | OCP_USER_SDMA,
+};
+
 /* l4_wkup - timer1 */
 static struct omap_hwmod_ocp_if omap54xx_l4_wkup__timer1 = {
.master = omap54xx_l4_wkup_hwmod,
@@ -2122,6 +2166,7 @@ static struct omap_hwmod_ocp_if *omap54xx_hwmod_ocp_ifs[] 
__initdata = {
omap54xx_l4_per__mmc4,
omap54xx_l4_per__mmc5,
omap54xx_l4_cfg__mpu,
+   omap54xx_l4_cfg__ocp2scp1,
omap54xx_l4_wkup__timer1,
omap54xx_l4_per__timer2,
omap54xx_l4_per__timer3,
-- 
1.7.10.4

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


[PATCH v3 3/5] arm: omap5: dts: add palmas-usb node

2013-08-21 Thread Kishon Vijay Abraham I
From: Felipe Balbi ba...@ti.com

Without this node, there will be no palmas
driver to notify dwc3 that a cable has
been connected and, without that, dwc3
will never initialize.

[ kis...@ti.com: added dt properties for enabling vbus/id interrupts and fixed
vbus-supply value after SMPS10 is modeled as 2 regulators ]

Signed-off-by: Felipe Balbi ba...@ti.com
Signed-off-by: Kishon Vijay Abraham I kis...@ti.com
---
 arch/arm/boot/dts/omap5-uevm.dts |   12 
 arch/arm/boot/dts/omap5.dtsi |2 +-
 2 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/arch/arm/boot/dts/omap5-uevm.dts b/arch/arm/boot/dts/omap5-uevm.dts
index 65d7b60..2a3f363 100644
--- a/arch/arm/boot/dts/omap5-uevm.dts
+++ b/arch/arm/boot/dts/omap5-uevm.dts
@@ -272,6 +272,13 @@
interrupt-controller;
#interrupt-cells = 2;
 
+   extcon_usb3: palmas_usb {
+   compatible = ti,palmas-usb-vid;
+   ti,enable-vbus-detection;
+   ti,enable-id-detection;
+   ti,wakeup;
+   };
+
palmas_pmic {
compatible = ti,palmas-pmic;
interrupt-parent = palmas;
@@ -470,6 +477,11 @@
phys = 0 hsusb2_phy hsusb3_phy;
 };
 
+usb3 {
+   extcon = extcon_usb3;
+   vbus-supply = smps10_out1_reg;
+};
+
 mcspi1 {
 
 };
diff --git a/arch/arm/boot/dts/omap5.dtsi b/arch/arm/boot/dts/omap5.dtsi
index 4e41409..1659246 100644
--- a/arch/arm/boot/dts/omap5.dtsi
+++ b/arch/arm/boot/dts/omap5.dtsi
@@ -634,7 +634,7 @@
ti,type = 2;
};
 
-   omap_dwc3@4a02 {
+   usb3: omap_dwc3@4a02 {
compatible = ti,dwc3;
ti,hwmods = usb_otg_ss;
reg = 0x4a02 0x1;
-- 
1.7.10.4

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


[PATCH v3 5/5] arm: omap2plus_defconfig: enable dwc3 and dependencies

2013-08-21 Thread Kishon Vijay Abraham I
From: Felipe Balbi ba...@ti.com

DWC3 enables USB3 functionality for OMAP5 boards,
it's safe to enable those drivers in omap2plus_defconfig.

Signed-off-by: Felipe Balbi ba...@ti.com
Acked-by: Tony Lindgren t...@atomide.com
Signed-off-by: Kishon Vijay Abraham I kis...@ti.com
---
 arch/arm/configs/omap2plus_defconfig |9 +
 1 file changed, 9 insertions(+)

diff --git a/arch/arm/configs/omap2plus_defconfig 
b/arch/arm/configs/omap2plus_defconfig
index 5339e6a..aed3cce 100644
--- a/arch/arm/configs/omap2plus_defconfig
+++ b/arch/arm/configs/omap2plus_defconfig
@@ -81,6 +81,7 @@ CONFIG_CMA=y
 CONFIG_CONNECTOR=y
 CONFIG_DEVTMPFS=y
 CONFIG_DEVTMPFS_MOUNT=y
+CONFIG_OMAP_OCP2SCP=y
 CONFIG_MTD=y
 CONFIG_MTD_CMDLINE_PARTS=y
 CONFIG_MTD_CHAR=y
@@ -167,9 +168,11 @@ CONFIG_THERMAL_GOV_USER_SPACE=y
 CONFIG_CPU_THERMAL=y
 CONFIG_OMAP_WATCHDOG=y
 CONFIG_TWL4030_WATCHDOG=y
+CONFIG_MFD_PALMAS=y
 CONFIG_MFD_TPS65217=y
 CONFIG_MFD_TPS65910=y
 CONFIG_TWL6040_CORE=y
+CONFIG_REGULATOR_PALMAS=y
 CONFIG_REGULATOR_TWL4030=y
 CONFIG_REGULATOR_TPS65023=y
 CONFIG_REGULATOR_TPS6507X=y
@@ -222,10 +225,14 @@ CONFIG_USB_MON=y
 CONFIG_USB_WDM=y
 CONFIG_USB_STORAGE=y
 CONFIG_USB_LIBUSUAL=y
+CONFIG_USB_DWC3=m
+CONFIG_USB_DWC3_OMAP=m
 CONFIG_USB_TEST=y
 CONFIG_USB_PHY=y
 CONFIG_NOP_USB_XCEIV=y
 CONFIG_USB_GADGET=y
+CONFIG_OMAP_USB2=y
+CONFIG_OMAP_USB3=y
 CONFIG_USB_GADGET_DEBUG=y
 CONFIG_USB_GADGET_DEBUG_FILES=y
 CONFIG_USB_GADGET_DEBUG_FS=y
@@ -258,6 +265,8 @@ CONFIG_TI_THERMAL=y
 CONFIG_OMAP4_THERMAL=y
 CONFIG_OMAP5_THERMAL=y
 CONFIG_DRA752_THERMAL=y
+CONFIG_EXTCON=y
+CONFIG_EXTCON_PALMAS=y
 CONFIG_EXT2_FS=y
 CONFIG_EXT3_FS=y
 # CONFIG_EXT3_FS_XATTR is not set
-- 
1.7.10.4

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


[PATCH v3 0/5] ARM: OMAP: DTS/HWMOD/defconfig changes for USB3

2013-08-21 Thread Kishon Vijay Abraham I
From: Felipe Balbi ba...@ti.com

With these patches (plus a few others on the driver side which
will be going upstream soon) I could get functional USB3 with my
omap5-uevm platform.

Changes since v2:
- added dt properties for enabling vbus/id interrupts and fixed
vbus-supply value after SMPS10 is modeled as 2 regulators

Changes since v1:
- split ocp2scp dts and hwmod data into separate patches
- reorganize the series in order to group DTS, hwmod and defconfig
  changes

Benoit Cousson (1):
  arm: omap5: hwmod: add missing ocp2scp hwmod data

Felipe Balbi (4):
  arm: omap5: dts: fix reg property size
  arm: omap5: dts: fix ocp2scp DTS data
  arm: omap5: dts: add palmas-usb node
  arm: omap2plus_defconfig: enable dwc3 and dependencies

 arch/arm/boot/dts/omap5-uevm.dts   |   12 
 arch/arm/boot/dts/omap5.dtsi   |9 +++---
 arch/arm/configs/omap2plus_defconfig   |9 ++
 arch/arm/mach-omap2/omap_hwmod_54xx_data.c |   45 
 4 files changed, 71 insertions(+), 4 deletions(-)

-- 
1.7.10.4

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


[PATCH v3 2/5] arm: omap5: dts: fix ocp2scp DTS data

2013-08-21 Thread Kishon Vijay Abraham I
From: Felipe Balbi ba...@ti.com

this patch fixes the DTS data for ocp2scp
node by adding the missing reg property.

Signed-off-by: Felipe Balbi ba...@ti.com
Signed-off-by: Kishon Vijay Abraham I kis...@ti.com
---
 arch/arm/boot/dts/omap5.dtsi |3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/arch/arm/boot/dts/omap5.dtsi b/arch/arm/boot/dts/omap5.dtsi
index 5c99f19..4e41409 100644
--- a/arch/arm/boot/dts/omap5.dtsi
+++ b/arch/arm/boot/dts/omap5.dtsi
@@ -652,10 +652,11 @@
};
};
 
-   ocp2scp {
+   ocp2scp@4a08 {
compatible = ti,omap-ocp2scp;
#address-cells = 1;
#size-cells = 1;
+   reg = 0x4a08 0x20;
ranges;
ti,hwmods = ocp2scp1;
usb2_phy: usb2phy@4a084000 {
-- 
1.7.10.4

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


[PATCH v3] extcon: palmas: Added a new compatible type *ti,palmas-usb-vid*

2013-08-21 Thread Kishon Vijay Abraham I
The Palmas device contains only a USB VID detector, so added a
compatible type *ti,palmas-usb-vid*. Didn't remove the existing compatible
types for backward compatibility.

Signed-off-by: Kishon Vijay Abraham I kis...@ti.com
---
Changes from [1]:
* Since the old compatible values will be in 3.11 kernel, we shouldn't remove
the old compatible values. So retain the old compatible values.

[1] - http://www.spinics.net/lists/linux-omap/msg95843.html

 Documentation/devicetree/bindings/extcon/extcon-palmas.txt |3 ++-
 drivers/extcon/extcon-palmas.c |1 +
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/Documentation/devicetree/bindings/extcon/extcon-palmas.txt 
b/Documentation/devicetree/bindings/extcon/extcon-palmas.txt
index 7dab6a8..dc5fab3 100644
--- a/Documentation/devicetree/bindings/extcon/extcon-palmas.txt
+++ b/Documentation/devicetree/bindings/extcon/extcon-palmas.txt
@@ -2,7 +2,8 @@ EXTCON FOR PALMAS/TWL CHIPS
 
 PALMAS USB COMPARATOR
 Required Properties:
- - compatible : Should be ti,palmas-usb or ti,twl6035-usb
+ - compatible : Should be ti,palmas-usb or ti,twl6035-usb or
+   ti,palmas-usb-vid.
 
 Optional Properties:
  - ti,wakeup : To enable the wakeup comparator in probe
diff --git a/drivers/extcon/extcon-palmas.c b/drivers/extcon/extcon-palmas.c
index 89fdd05..9672f31 100644
--- a/drivers/extcon/extcon-palmas.c
+++ b/drivers/extcon/extcon-palmas.c
@@ -268,6 +268,7 @@ static const struct dev_pm_ops palmas_pm_ops = {
 
 static struct of_device_id of_palmas_match_tbl[] = {
{ .compatible = ti,palmas-usb, },
+   { .compatible = ti,palmas-usb-vid, },
{ .compatible = ti,twl6035-usb, },
{ /* end */ }
 };
-- 
1.7.10.4

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


[PATCH v11 8/8] usb: phy: twl4030-usb: remove *set_suspend* and *phy_init* ops

2013-08-20 Thread Kishon Vijay Abraham I
Now that twl4030-usb is adapted to the new generic PHY framework,
*set_suspend* and *phy_init* ops can be removed from twl4030-usb driver.

Signed-off-by: Kishon Vijay Abraham I kis...@ti.com
Acked-by: Felipe Balbi ba...@ti.com
Reviewed-by: Sylwester Nawrocki s.nawro...@samsung.com
---
 drivers/phy/phy-twl4030-usb.c |   57 ++---
 1 file changed, 13 insertions(+), 44 deletions(-)

diff --git a/drivers/phy/phy-twl4030-usb.c b/drivers/phy/phy-twl4030-usb.c
index 494f107..c437211 100644
--- a/drivers/phy/phy-twl4030-usb.c
+++ b/drivers/phy/phy-twl4030-usb.c
@@ -422,25 +422,20 @@ static void twl4030_phy_power(struct twl4030_usb *twl, 
int on)
}
 }
 
-static void twl4030_phy_suspend(struct twl4030_usb *twl, int controller_off)
+static int twl4030_phy_power_off(struct phy *phy)
 {
+   struct twl4030_usb *twl = phy_get_drvdata(phy);
+
if (twl-asleep)
-   return;
+   return 0;
 
twl4030_phy_power(twl, 0);
twl-asleep = 1;
dev_dbg(twl-dev, %s\n, __func__);
-}
-
-static int twl4030_phy_power_off(struct phy *phy)
-{
-   struct twl4030_usb *twl = phy_get_drvdata(phy);
-
-   twl4030_phy_suspend(twl, 0);
return 0;
 }
 
-static void __twl4030_phy_resume(struct twl4030_usb *twl)
+static void __twl4030_phy_power_on(struct twl4030_usb *twl)
 {
twl4030_phy_power(twl, 1);
twl4030_i2c_access(twl, 1);
@@ -449,11 +444,13 @@ static void __twl4030_phy_resume(struct twl4030_usb *twl)
twl4030_i2c_access(twl, 0);
 }
 
-static void twl4030_phy_resume(struct twl4030_usb *twl)
+static int twl4030_phy_power_on(struct phy *phy)
 {
+   struct twl4030_usb *twl = phy_get_drvdata(phy);
+
if (!twl-asleep)
-   return;
-   __twl4030_phy_resume(twl);
+   return 0;
+   __twl4030_phy_power_on(twl);
twl-asleep = 0;
dev_dbg(twl-dev, %s\n, __func__);
 
@@ -466,13 +463,6 @@ static void twl4030_phy_resume(struct twl4030_usb *twl)
cancel_delayed_work(twl-id_workaround_work);
schedule_delayed_work(twl-id_workaround_work, HZ);
}
-}
-
-static int twl4030_phy_power_on(struct phy *phy)
-{
-   struct twl4030_usb *twl = phy_get_drvdata(phy);
-
-   twl4030_phy_resume(twl);
return 0;
 }
 
@@ -604,9 +594,9 @@ static void twl4030_id_workaround_work(struct work_struct 
*work)
}
 }
 
-static int twl4030_usb_phy_init(struct usb_phy *phy)
+static int twl4030_phy_init(struct phy *phy)
 {
-   struct twl4030_usb *twl = phy_to_twl(phy);
+   struct twl4030_usb *twl = phy_get_drvdata(phy);
enum omap_musb_vbus_id_status status;
 
/*
@@ -621,32 +611,13 @@ static int twl4030_usb_phy_init(struct usb_phy *phy)
 
if (status == OMAP_MUSB_ID_GROUND || status == OMAP_MUSB_VBUS_VALID) {
omap_musb_mailbox(twl-linkstat);
-   twl4030_phy_resume(twl);
+   twl4030_phy_power_on(phy);
}
 
sysfs_notify(twl-dev-kobj, NULL, vbus);
return 0;
 }
 
-static int twl4030_phy_init(struct phy *phy)
-{
-   struct twl4030_usb *twl = phy_get_drvdata(phy);
-
-   return twl4030_usb_phy_init(twl-phy);
-}
-
-static int twl4030_set_suspend(struct usb_phy *x, int suspend)
-{
-   struct twl4030_usb *twl = phy_to_twl(x);
-
-   if (suspend)
-   twl4030_phy_suspend(twl, 1);
-   else
-   twl4030_phy_resume(twl);
-
-   return 0;
-}
-
 static int twl4030_set_peripheral(struct usb_otg *otg,
struct usb_gadget *gadget)
 {
@@ -719,8 +690,6 @@ static int twl4030_usb_probe(struct platform_device *pdev)
twl-phy.label  = twl4030;
twl-phy.otg= otg;
twl-phy.type   = USB_PHY_TYPE_USB2;
-   twl-phy.set_suspend= twl4030_set_suspend;
-   twl-phy.init   = twl4030_usb_phy_init;
 
otg-phy= twl-phy;
otg-set_host   = twl4030_set_host;
-- 
1.7.10.4

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


[PATCH v11 7/8] usb: phy: omap-usb2: remove *set_suspend* callback from omap-usb2

2013-08-20 Thread Kishon Vijay Abraham I
Now that omap-usb2 is adapted to the new generic PHY framework,
*set_suspend* ops can be removed from omap-usb2 driver.

Signed-off-by: Kishon Vijay Abraham I kis...@ti.com
Acked-by: Felipe Balbi ba...@ti.com
Reviewed-by: Sylwester Nawrocki s.nawro...@samsung.com
---
 drivers/phy/phy-omap-usb2.c |   25 -
 1 file changed, 25 deletions(-)

diff --git a/drivers/phy/phy-omap-usb2.c b/drivers/phy/phy-omap-usb2.c
index 25e0f3c..dec3fab 100644
--- a/drivers/phy/phy-omap-usb2.c
+++ b/drivers/phy/phy-omap-usb2.c
@@ -97,29 +97,6 @@ static int omap_usb_set_peripheral(struct usb_otg *otg,
return 0;
 }
 
-static int omap_usb2_suspend(struct usb_phy *x, int suspend)
-{
-   u32 ret;
-   struct omap_usb *phy = phy_to_omapusb(x);
-
-   if (suspend  !phy-is_suspended) {
-   omap_control_usb_phy_power(phy-control_dev, 0);
-   pm_runtime_put_sync(phy-dev);
-   phy-is_suspended = 1;
-   } else if (!suspend  phy-is_suspended) {
-   ret = pm_runtime_get_sync(phy-dev);
-   if (ret  0) {
-   dev_err(phy-dev, get_sync failed with err %d\n,
-   ret);
-   return ret;
-   }
-   omap_control_usb_phy_power(phy-control_dev, 1);
-   phy-is_suspended = 0;
-   }
-
-   return 0;
-}
-
 static int omap_usb_power_off(struct phy *x)
 {
struct omap_usb *phy = phy_get_drvdata(x);
@@ -167,7 +144,6 @@ static int omap_usb2_probe(struct platform_device *pdev)
 
phy-phy.dev= phy-dev;
phy-phy.label  = omap-usb2;
-   phy-phy.set_suspend= omap_usb2_suspend;
phy-phy.otg= otg;
phy-phy.type   = USB_PHY_TYPE_USB2;
 
@@ -182,7 +158,6 @@ static int omap_usb2_probe(struct platform_device *pdev)
return -ENODEV;
}
 
-   phy-is_suspended   = 1;
omap_control_usb_phy_power(phy-control_dev, 0);
 
otg-set_host   = omap_usb_set_host;
-- 
1.7.10.4

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


[PATCH v11 5/8] ARM: dts: omap: update usb_otg_hs data

2013-08-20 Thread Kishon Vijay Abraham I
Updated the usb_otg_hs dt data to include the *phy* and *phy-names*
binding in order for the driver to use the new generic PHY framework.
Also updated the Documentation to include the binding information.
The PHY binding information can be found at
Documentation/devicetree/bindings/phy/phy-bindings.txt

Signed-off-by: Kishon Vijay Abraham I kis...@ti.com
Acked-by: Felipe Balbi ba...@ti.com
Acked-by: Tony Lindgren t...@atomide.com
Reviewed-by: Sylwester Nawrocki s.nawro...@samsung.com
---
 Documentation/devicetree/bindings/usb/omap-usb.txt |5 +
 Documentation/devicetree/bindings/usb/usb-phy.txt  |6 ++
 arch/arm/boot/dts/omap3-beagle-xm.dts  |2 ++
 arch/arm/boot/dts/omap3-evm.dts|2 ++
 arch/arm/boot/dts/omap3-overo.dtsi |2 ++
 arch/arm/boot/dts/omap4.dtsi   |3 +++
 arch/arm/boot/dts/twl4030.dtsi |1 +
 7 files changed, 21 insertions(+)

diff --git a/Documentation/devicetree/bindings/usb/omap-usb.txt 
b/Documentation/devicetree/bindings/usb/omap-usb.txt
index 57e71f6..825790d 100644
--- a/Documentation/devicetree/bindings/usb/omap-usb.txt
+++ b/Documentation/devicetree/bindings/usb/omap-usb.txt
@@ -19,6 +19,9 @@ OMAP MUSB GLUE
  - power : Should be 50. This signifies the controller can supply up to
100mA when operating in host mode.
  - usb-phy : the phandle for the PHY device
+ - phys : the phandle for the PHY device (used by generic PHY framework)
+ - phy-names : the names of the PHY corresponding to the PHYs present in the
+   *phy* phandle.
 
 Optional properties:
  - ctrl-module : phandle of the control module this glue uses to write to
@@ -33,6 +36,8 @@ usb_otg_hs: usb_otg_hs@4a0ab000 {
num-eps = 16;
ram-bits = 12;
ctrl-module = omap_control_usb;
+   phys = usb2_phy;
+   phy-names = usb2-phy;
 };
 
 Board specific device node entry
diff --git a/Documentation/devicetree/bindings/usb/usb-phy.txt 
b/Documentation/devicetree/bindings/usb/usb-phy.txt
index 61496f5..c0245c8 100644
--- a/Documentation/devicetree/bindings/usb/usb-phy.txt
+++ b/Documentation/devicetree/bindings/usb/usb-phy.txt
@@ -5,6 +5,8 @@ OMAP USB2 PHY
 Required properties:
  - compatible: Should be ti,omap-usb2
  - reg : Address and length of the register set for the device.
+ - #phy-cells: determine the number of cells that should be given in the
+   phandle while referencing this phy.
 
 Optional properties:
  - ctrl-module : phandle of the control module used by PHY driver to power on
@@ -16,6 +18,7 @@ usb2phy@4a0ad080 {
compatible = ti,omap-usb2;
reg = 0x4a0ad080 0x58;
ctrl-module = omap_control_usb;
+   #phy-cells = 0;
 };
 
 OMAP USB3 PHY
@@ -25,6 +28,8 @@ Required properties:
  - reg : Address and length of the register set for the device.
  - reg-names: The names of the register addresses corresponding to the 
registers
filled in reg.
+ - #phy-cells: determine the number of cells that should be given in the
+   phandle while referencing this phy.
 
 Optional properties:
  - ctrl-module : phandle of the control module used by PHY driver to power on
@@ -39,4 +44,5 @@ usb3phy@4a084400 {
  0x4a084c00 0x40;
reg-names = phy_rx, phy_tx, pll_ctrl;
ctrl-module = omap_control_usb;
+   #phy-cells = 0;
 };
diff --git a/arch/arm/boot/dts/omap3-beagle-xm.dts 
b/arch/arm/boot/dts/omap3-beagle-xm.dts
index afdb164..533b2da 100644
--- a/arch/arm/boot/dts/omap3-beagle-xm.dts
+++ b/arch/arm/boot/dts/omap3-beagle-xm.dts
@@ -144,6 +144,8 @@
 usb_otg_hs {
interface-type = 0;
usb-phy = usb2_phy;
+   phys = usb2_phy;
+   phy-names = usb2-phy;
mode = 3;
power = 50;
 };
diff --git a/arch/arm/boot/dts/omap3-evm.dts b/arch/arm/boot/dts/omap3-evm.dts
index 7d4329d..4134dd0 100644
--- a/arch/arm/boot/dts/omap3-evm.dts
+++ b/arch/arm/boot/dts/omap3-evm.dts
@@ -70,6 +70,8 @@
 usb_otg_hs {
interface-type = 0;
usb-phy = usb2_phy;
+   phys = usb2_phy;
+   phy-names = usb2-phy;
mode = 3;
power = 50;
 };
diff --git a/arch/arm/boot/dts/omap3-overo.dtsi 
b/arch/arm/boot/dts/omap3-overo.dtsi
index 8f1abec..a461d2f 100644
--- a/arch/arm/boot/dts/omap3-overo.dtsi
+++ b/arch/arm/boot/dts/omap3-overo.dtsi
@@ -76,6 +76,8 @@
 usb_otg_hs {
interface-type = 0;
usb-phy = usb2_phy;
+   phys = usb2_phy;
+   phy-names = usb2-phy;
mode = 3;
power = 50;
 };
diff --git a/arch/arm/boot/dts/omap4.dtsi b/arch/arm/boot/dts/omap4.dtsi
index 22d9f2b..1e8e2fe 100644
--- a/arch/arm/boot/dts/omap4.dtsi
+++ b/arch/arm/boot/dts/omap4.dtsi
@@ -520,6 +520,7 @@
compatible = ti,omap-usb2;
reg = 0x4a0ad080 0x58;
ctrl-module = omap_control_usb;
+   #phy-cells = 0;
};
};
 
@@ -658,6 +659,8

[PATCH v11 6/8] usb: musb: omap2430: use the new generic PHY framework

2013-08-20 Thread Kishon Vijay Abraham I
Use the generic PHY framework API to get the PHY. The usb_phy_set_resume
and usb_phy_set_suspend is replaced with power_on and
power_off to align with the new PHY framework.

musb-xceiv can't be removed as of now because musb core uses xceiv.state and
xceiv.otg. Once there is a separate state machine to handle otg, these can be
moved out of xceiv and then we can start using the generic PHY framework.

Signed-off-by: Kishon Vijay Abraham I kis...@ti.com
Reviewed-by: Sylwester Nawrocki s.nawro...@samsung.com
Acked-by: Felipe Balbi ba...@ti.com
---
 drivers/usb/musb/Kconfig |1 +
 drivers/usb/musb/musb_core.h |2 ++
 drivers/usb/musb/omap2430.c  |   26 --
 3 files changed, 23 insertions(+), 6 deletions(-)

diff --git a/drivers/usb/musb/Kconfig b/drivers/usb/musb/Kconfig
index 797e3fd..25e2e57 100644
--- a/drivers/usb/musb/Kconfig
+++ b/drivers/usb/musb/Kconfig
@@ -76,6 +76,7 @@ config USB_MUSB_TUSB6010
 config USB_MUSB_OMAP2PLUS
tristate OMAP2430 and onwards
depends on ARCH_OMAP2PLUS
+   select GENERIC_PHY
 
 config USB_MUSB_AM35X
tristate AM35x
diff --git a/drivers/usb/musb/musb_core.h b/drivers/usb/musb/musb_core.h
index 7d341c3..6e567bd 100644
--- a/drivers/usb/musb/musb_core.h
+++ b/drivers/usb/musb/musb_core.h
@@ -46,6 +46,7 @@
 #include linux/usb.h
 #include linux/usb/otg.h
 #include linux/usb/musb.h
+#include linux/phy/phy.h
 
 struct musb;
 struct musb_hw_ep;
@@ -346,6 +347,7 @@ struct musb {
u16 int_tx;
 
struct usb_phy  *xceiv;
+   struct phy  *phy;
 
int nIrq;
unsignedirq_wake:1;
diff --git a/drivers/usb/musb/omap2430.c b/drivers/usb/musb/omap2430.c
index f44e8b5..063773a 100644
--- a/drivers/usb/musb/omap2430.c
+++ b/drivers/usb/musb/omap2430.c
@@ -348,11 +348,21 @@ static int omap2430_musb_init(struct musb *musb)
 * up through ULPI.  TWL4030-family PMICs include one,
 * which needs a driver, drivers aren't always needed.
 */
-   if (dev-parent-of_node)
+   if (dev-parent-of_node) {
+   musb-phy = devm_phy_get(dev-parent, usb2-phy);
+
+   /* We can't totally remove musb-xceiv as of now because
+* musb core uses xceiv.state and xceiv.otg. Once we have
+* a separate state machine to handle otg, these can be moved
+* out of xceiv and then we can start using the generic PHY
+* framework
+*/
musb-xceiv = devm_usb_get_phy_by_phandle(dev-parent,
usb-phy, 0);
-   else
+   } else {
musb-xceiv = devm_usb_get_phy_dev(dev, 0);
+   musb-phy = devm_phy_get(dev, usb);
+   }
 
if (IS_ERR(musb-xceiv)) {
status = PTR_ERR(musb-xceiv);
@@ -364,6 +374,10 @@ static int omap2430_musb_init(struct musb *musb)
return -EPROBE_DEFER;
}
 
+   if (IS_ERR(musb-phy)) {
+   pr_err(HS USB OTG: no PHY configured\n);
+   return PTR_ERR(musb-phy);
+   }
musb-isr = omap2430_musb_interrupt;
 
status = pm_runtime_get_sync(dev);
@@ -397,7 +411,7 @@ static int omap2430_musb_init(struct musb *musb)
if (glue-status != OMAP_MUSB_UNKNOWN)
omap_musb_set_mailbox(glue);
 
-   usb_phy_init(musb-xceiv);
+   phy_init(musb-phy);
 
pm_runtime_put_noidle(musb-controller);
return 0;
@@ -460,6 +474,7 @@ static int omap2430_musb_exit(struct musb *musb)
del_timer_sync(musb_idle_timer);
 
omap2430_low_level_exit(musb);
+   phy_exit(musb-phy);
 
return 0;
 }
@@ -638,7 +653,7 @@ static int omap2430_runtime_suspend(struct device *dev)
OTG_INTERFSEL);
 
omap2430_low_level_exit(musb);
-   usb_phy_set_suspend(musb-xceiv, 1);
+   phy_power_off(musb-phy);
}
 
return 0;
@@ -653,8 +668,7 @@ static int omap2430_runtime_resume(struct device *dev)
omap2430_low_level_init(musb);
musb_writel(musb-mregs, OTG_INTERFSEL,
musb-context.otg_interfsel);
-
-   usb_phy_set_suspend(musb-xceiv, 0);
+   phy_power_on(musb-phy);
}
 
return 0;
-- 
1.7.10.4

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


[PATCH v11 4/8] arm: omap3: twl: add phy consumer data in twl4030_usb_data

2013-08-20 Thread Kishon Vijay Abraham I
The PHY framework uses the phy consumer data populated in platform data in the
case of non-dt boot to return the reference to the PHY when the controller
(PHY consumer) requests for it. So populated the phy consumer data in the 
platform
data of twl usb.

Signed-off-by: Kishon Vijay Abraham I kis...@ti.com
---
 arch/arm/mach-omap2/twl-common.c |   11 +++
 1 file changed, 11 insertions(+)

diff --git a/arch/arm/mach-omap2/twl-common.c b/arch/arm/mach-omap2/twl-common.c
index c05898f..b0d54da 100644
--- a/arch/arm/mach-omap2/twl-common.c
+++ b/arch/arm/mach-omap2/twl-common.c
@@ -24,6 +24,7 @@
 #include linux/i2c/twl.h
 #include linux/gpio.h
 #include linux/string.h
+#include linux/phy/phy.h
 #include linux/regulator/machine.h
 #include linux/regulator/fixed.h
 
@@ -90,8 +91,18 @@ void __init omap_pmic_late_init(void)
 }
 
 #if defined(CONFIG_ARCH_OMAP3)
+struct phy_consumer consumers[] = {
+   PHY_CONSUMER(musb-hdrc.0, usb),
+};
+
+struct phy_init_data init_data = {
+   .consumers = consumers,
+   .num_consumers = ARRAY_SIZE(consumers),
+};
+
 static struct twl4030_usb_data omap3_usb_pdata = {
.usb_mode   = T2_USB_MODE_ULPI,
+   .init_data  = init_data,
 };
 
 static int omap3_batt_table[] = {
-- 
1.7.10.4

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


[PATCH v11 1/8] drivers: phy: add generic PHY framework

2013-08-20 Thread Kishon Vijay Abraham I
The PHY framework provides a set of APIs for the PHY drivers to
create/destroy a PHY and APIs for the PHY users to obtain a reference to the
PHY with or without using phandle. For dt-boot, the PHY drivers should
also register *PHY provider* with the framework.

PHY drivers should create the PHY by passing id and ops like init, exit,
power_on and power_off. This framework is also pm runtime enabled.

The documentation for the generic PHY framework is added in
Documentation/phy.txt and the documentation for dt binding can be found at
Documentation/devicetree/bindings/phy/phy-bindings.txt

Cc: Tomasz Figa t.f...@samsung.com
Cc: Greg Kroah-Hartman gre...@linuxfoundation.org
Signed-off-by: Kishon Vijay Abraham I kis...@ti.com
Acked-by: Felipe Balbi ba...@ti.com
Tested-by: Sylwester Nawrocki s.nawro...@samsung.com
---
 .../devicetree/bindings/phy/phy-bindings.txt   |   66 ++
 Documentation/phy.txt  |  166 +
 MAINTAINERS|8 +
 drivers/Kconfig|2 +
 drivers/Makefile   |2 +
 drivers/phy/Kconfig|   18 +
 drivers/phy/Makefile   |5 +
 drivers/phy/phy-core.c |  698 
 include/linux/phy/phy.h|  270 
 9 files changed, 1235 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/phy/phy-bindings.txt
 create mode 100644 Documentation/phy.txt
 create mode 100644 drivers/phy/Kconfig
 create mode 100644 drivers/phy/Makefile
 create mode 100644 drivers/phy/phy-core.c
 create mode 100644 include/linux/phy/phy.h

diff --git a/Documentation/devicetree/bindings/phy/phy-bindings.txt 
b/Documentation/devicetree/bindings/phy/phy-bindings.txt
new file mode 100644
index 000..8ae844f
--- /dev/null
+++ b/Documentation/devicetree/bindings/phy/phy-bindings.txt
@@ -0,0 +1,66 @@
+This document explains only the device tree data binding. For general
+information about PHY subsystem refer to Documentation/phy.txt
+
+PHY device node
+===
+
+Required Properties:
+#phy-cells:Number of cells in a PHY specifier;  The meaning of all those
+   cells is defined by the binding for the phy node. The PHY
+   provider can use the values in cells to find the appropriate
+   PHY.
+
+For example:
+
+phys: phy {
+compatible = xxx;
+reg = ...;
+.
+.
+#phy-cells = 1;
+.
+.
+};
+
+That node describes an IP block (PHY provider) that implements 2 different 
PHYs.
+In order to differentiate between these 2 PHYs, an additonal specifier should 
be
+given while trying to get a reference to it.
+
+PHY user node
+=
+
+Required Properties:
+phys : the phandle for the PHY device (used by the PHY subsystem)
+phy-names : the names of the PHY corresponding to the PHYs present in the
+   *phys* phandle
+
+Example 1:
+usb1: usb_otg_ss@xxx {
+compatible = xxx;
+reg = xxx;
+.
+.
+phys = usb2_phy, usb3_phy;
+phy-names = usb2phy, usb3phy;
+.
+.
+};
+
+This node represents a controller that uses two PHYs, one for usb2 and one for
+usb3.
+
+Example 2:
+usb2: usb_otg_ss@xxx {
+compatible = xxx;
+reg = xxx;
+.
+.
+phys = phys 1;
+phy-names = usbphy;
+.
+.
+};
+
+This node represents a controller that uses one of the PHYs of the PHY provider
+device defined previously. Note that the phy handle has an additional specifier
+1 to differentiate between the two PHYs.
diff --git a/Documentation/phy.txt b/Documentation/phy.txt
new file mode 100644
index 000..0103e4b
--- /dev/null
+++ b/Documentation/phy.txt
@@ -0,0 +1,166 @@
+   PHY SUBSYSTEM
+ Kishon Vijay Abraham I kis...@ti.com
+
+This document explains the Generic PHY Framework along with the APIs provided,
+and how-to-use.
+
+1. Introduction
+
+*PHY* is the abbreviation for physical layer. It is used to connect a device
+to the physical medium e.g., the USB controller has a PHY to provide functions
+such as serialization, de-serialization, encoding, decoding and is responsible
+for obtaining the required data transmission rate. Note that some USB
+controllers have PHY functionality embedded into it and others use an external
+PHY. Other peripherals that use PHY include Wireless LAN, Ethernet,
+SATA etc.
+
+The intention of creating this framework is to bring the PHY drivers spread
+all over the Linux kernel to drivers/phy to increase code re-use and for
+better code maintainability.
+
+This framework will be of use only to devices that use external PHY (PHY
+functionality is not embedded within the controller).
+
+2. Registering/Unregistering the PHY provider
+
+PHY provider refers to an entity that implements one or more PHY instances.
+For the simple case where the PHY provider implements only a single instance

[PATCH v11 2/8] usb: phy: omap-usb2: use the new generic PHY framework

2013-08-20 Thread Kishon Vijay Abraham I
Used the generic PHY framework API to create the PHY. Now the power off and
power on are done in omap_usb_power_off and omap_usb_power_on respectively.
The omap-usb2 driver is also moved to driver/phy.

However using the old USB PHY library cannot be completely removed
because OTG is intertwined with PHY and moving to the new framework
will break OTG. Once we have a separate OTG state machine, we
can get rid of the USB PHY library.

Signed-off-by: Kishon Vijay Abraham I kis...@ti.com
Reviewed-by: Sylwester Nawrocki s.nawro...@samsung.com
Acked-by: Felipe Balbi ba...@ti.com
---
 drivers/phy/Kconfig   |   12 +
 drivers/phy/Makefile  |1 +
 drivers/{usb = }/phy/phy-omap-usb2.c |   45 ++---
 drivers/usb/phy/Kconfig   |   10 
 drivers/usb/phy/Makefile  |1 -
 5 files changed, 54 insertions(+), 15 deletions(-)
 rename drivers/{usb = }/phy/phy-omap-usb2.c (88%)

diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig
index 349bef2..38c3477 100644
--- a/drivers/phy/Kconfig
+++ b/drivers/phy/Kconfig
@@ -15,4 +15,16 @@ config GENERIC_PHY
  phy users can obtain reference to the PHY. All the users of this
  framework should select this config.
 
+config OMAP_USB2
+   tristate OMAP USB2 PHY Driver
+   depends on ARCH_OMAP2PLUS
+   select GENERIC_PHY
+   select USB_PHY
+   select OMAP_CONTROL_USB
+   help
+ Enable this to support the transceiver that is part of SOC. This
+ driver takes care of all the PHY functionality apart from comparator.
+ The USB OTG controller communicates with the comparator using this
+ driver.
+
 endmenu
diff --git a/drivers/phy/Makefile b/drivers/phy/Makefile
index 9e9560f..ed5b088 100644
--- a/drivers/phy/Makefile
+++ b/drivers/phy/Makefile
@@ -3,3 +3,4 @@
 #
 
 obj-$(CONFIG_GENERIC_PHY)  += phy-core.o
+obj-$(CONFIG_OMAP_USB2)+= phy-omap-usb2.o
diff --git a/drivers/usb/phy/phy-omap-usb2.c b/drivers/phy/phy-omap-usb2.c
similarity index 88%
rename from drivers/usb/phy/phy-omap-usb2.c
rename to drivers/phy/phy-omap-usb2.c
index 844ab68..25e0f3c 100644
--- a/drivers/usb/phy/phy-omap-usb2.c
+++ b/drivers/phy/phy-omap-usb2.c
@@ -28,6 +28,7 @@
 #include linux/pm_runtime.h
 #include linux/delay.h
 #include linux/usb/omap_control_usb.h
+#include linux/phy/phy.h
 
 /**
  * omap_usb2_set_comparator - links the comparator present in the sytem with
@@ -119,10 +120,36 @@ static int omap_usb2_suspend(struct usb_phy *x, int 
suspend)
return 0;
 }
 
+static int omap_usb_power_off(struct phy *x)
+{
+   struct omap_usb *phy = phy_get_drvdata(x);
+
+   omap_control_usb_phy_power(phy-control_dev, 0);
+
+   return 0;
+}
+
+static int omap_usb_power_on(struct phy *x)
+{
+   struct omap_usb *phy = phy_get_drvdata(x);
+
+   omap_control_usb_phy_power(phy-control_dev, 1);
+
+   return 0;
+}
+
+static struct phy_ops ops = {
+   .power_on   = omap_usb_power_on,
+   .power_off  = omap_usb_power_off,
+   .owner  = THIS_MODULE,
+};
+
 static int omap_usb2_probe(struct platform_device *pdev)
 {
struct omap_usb *phy;
+   struct phy  *generic_phy;
struct usb_otg  *otg;
+   struct phy_provider *phy_provider;
 
phy = devm_kzalloc(pdev-dev, sizeof(*phy), GFP_KERNEL);
if (!phy) {
@@ -144,6 +171,11 @@ static int omap_usb2_probe(struct platform_device *pdev)
phy-phy.otg= otg;
phy-phy.type   = USB_PHY_TYPE_USB2;
 
+   phy_provider = devm_of_phy_provider_register(phy-dev,
+   of_phy_simple_xlate);
+   if (IS_ERR(phy_provider))
+   return PTR_ERR(phy_provider);
+
phy-control_dev = omap_get_control_dev();
if (IS_ERR(phy-control_dev)) {
dev_dbg(pdev-dev, Failed to get control device\n);
@@ -159,6 +191,15 @@ static int omap_usb2_probe(struct platform_device *pdev)
otg-start_srp  = omap_usb_start_srp;
otg-phy= phy-phy;
 
+   platform_set_drvdata(pdev, phy);
+   pm_runtime_enable(phy-dev);
+
+   generic_phy = devm_phy_create(phy-dev, ops, NULL);
+   if (IS_ERR(generic_phy))
+   return PTR_ERR(generic_phy);
+
+   phy_set_drvdata(generic_phy, phy);
+
phy-wkupclk = devm_clk_get(phy-dev, usb_phy_cm_clk32k);
if (IS_ERR(phy-wkupclk)) {
dev_err(pdev-dev, unable to get usb_phy_cm_clk32k\n);
@@ -174,10 +215,6 @@ static int omap_usb2_probe(struct platform_device *pdev)
 
usb_add_phy_dev(phy-phy);
 
-   platform_set_drvdata(pdev, phy);
-
-   pm_runtime_enable(phy-dev);
-
return 0;
 }
 
diff --git a/drivers/usb/phy/Kconfig b/drivers/usb/phy/Kconfig
index 3622fff..7813238 100644
--- a/drivers/usb/phy/Kconfig
+++ b/drivers/usb/phy/Kconfig
@@ -72,16 +72,6 @@ config

[PATCH v11 0/8] PHY framework

2013-08-20 Thread Kishon Vijay Abraham I
 Documentation for the PHY framework
* Added few more APIs mostly w.r.t devres
* Modified omap-usb2 and twl4030 to make use of the new framework

Kishon Vijay Abraham I (8):
  drivers: phy: add generic PHY framework
  usb: phy: omap-usb2: use the new generic PHY framework
  usb: phy: twl4030: use the new generic PHY framework
  arm: omap3: twl: add phy consumer data in twl4030_usb_data
  ARM: dts: omap: update usb_otg_hs data
  usb: musb: omap2430: use the new generic PHY framework
  usb: phy: omap-usb2: remove *set_suspend* callback from omap-usb2
  usb: phy: twl4030-usb: remove *set_suspend* and *phy_init* ops

 .../devicetree/bindings/phy/phy-bindings.txt   |   66 ++
 Documentation/devicetree/bindings/usb/omap-usb.txt |5 +
 Documentation/devicetree/bindings/usb/usb-phy.txt  |6 +
 Documentation/phy.txt  |  166 +
 MAINTAINERS|8 +
 arch/arm/boot/dts/omap3-beagle-xm.dts  |2 +
 arch/arm/boot/dts/omap3-evm.dts|2 +
 arch/arm/boot/dts/omap3-overo.dtsi |2 +
 arch/arm/boot/dts/omap4.dtsi   |3 +
 arch/arm/boot/dts/twl4030.dtsi |1 +
 arch/arm/mach-omap2/twl-common.c   |   11 +
 drivers/Kconfig|2 +
 drivers/Makefile   |2 +
 drivers/phy/Kconfig|   41 ++
 drivers/phy/Makefile   |7 +
 drivers/phy/phy-core.c |  698 
 drivers/{usb = }/phy/phy-omap-usb2.c  |   60 +-
 drivers/{usb = }/phy/phy-twl4030-usb.c|   69 +-
 drivers/usb/musb/Kconfig   |1 +
 drivers/usb/musb/musb_core.h   |2 +
 drivers/usb/musb/omap2430.c|   26 +-
 drivers/usb/phy/Kconfig|   19 -
 drivers/usb/phy/Makefile   |2 -
 include/linux/i2c/twl.h|2 +
 include/linux/phy/phy.h|  270 
 25 files changed, 1397 insertions(+), 76 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/phy/phy-bindings.txt
 create mode 100644 Documentation/phy.txt
 create mode 100644 drivers/phy/Kconfig
 create mode 100644 drivers/phy/Makefile
 create mode 100644 drivers/phy/phy-core.c
 rename drivers/{usb = }/phy/phy-omap-usb2.c (88%)
 rename drivers/{usb = }/phy/phy-twl4030-usb.c (94%)
 create mode 100644 include/linux/phy/phy.h

-- 
1.7.10.4

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


[PATCH v11 3/8] usb: phy: twl4030: use the new generic PHY framework

2013-08-20 Thread Kishon Vijay Abraham I
Used the generic PHY framework API to create the PHY. For powering on
and powering off the PHY, power_on and power_off ops are used. Once the
MUSB OMAP glue is adapted to the new framework, the suspend and resume
ops of usb phy library will be removed. Also twl4030-usb driver is moved
to drivers/phy/.

However using the old usb phy library cannot be completely removed
because otg is intertwined with phy and moving to the new
framework completely will break otg. Once we have a separate otg state machine,
we can get rid of the usb phy library.

Signed-off-by: Kishon Vijay Abraham I kis...@ti.com
Acked-by: Felipe Balbi ba...@ti.com
Reviewed-by: Sylwester Nawrocki s.nawro...@samsung.com
---
 drivers/phy/Kconfig |   11 ++
 drivers/phy/Makefile|1 +
 drivers/{usb = }/phy/phy-twl4030-usb.c |   56 +--
 drivers/usb/phy/Kconfig |9 -
 drivers/usb/phy/Makefile|1 -
 include/linux/i2c/twl.h |2 ++
 6 files changed, 67 insertions(+), 13 deletions(-)
 rename drivers/{usb = }/phy/phy-twl4030-usb.c (95%)

diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig
index 38c3477..ac239ac 100644
--- a/drivers/phy/Kconfig
+++ b/drivers/phy/Kconfig
@@ -27,4 +27,15 @@ config OMAP_USB2
  The USB OTG controller communicates with the comparator using this
  driver.
 
+config TWL4030_USB
+   tristate TWL4030 USB Transceiver Driver
+   depends on TWL4030_CORE  REGULATOR_TWL4030  USB_MUSB_OMAP2PLUS
+   select GENERIC_PHY
+   select USB_PHY
+   help
+ Enable this to support the USB OTG transceiver on TWL4030
+ family chips (including the TWL5030 and TPS659x0 devices).
+ This transceiver supports high and full speed devices plus,
+ in host mode, low speed.
+
 endmenu
diff --git a/drivers/phy/Makefile b/drivers/phy/Makefile
index ed5b088..0dd8a98 100644
--- a/drivers/phy/Makefile
+++ b/drivers/phy/Makefile
@@ -4,3 +4,4 @@
 
 obj-$(CONFIG_GENERIC_PHY)  += phy-core.o
 obj-$(CONFIG_OMAP_USB2)+= phy-omap-usb2.o
+obj-$(CONFIG_TWL4030_USB)  += phy-twl4030-usb.o
diff --git a/drivers/usb/phy/phy-twl4030-usb.c b/drivers/phy/phy-twl4030-usb.c
similarity index 95%
rename from drivers/usb/phy/phy-twl4030-usb.c
rename to drivers/phy/phy-twl4030-usb.c
index 8f78d2d..494f107 100644
--- a/drivers/usb/phy/phy-twl4030-usb.c
+++ b/drivers/phy/phy-twl4030-usb.c
@@ -33,6 +33,7 @@
 #include linux/io.h
 #include linux/delay.h
 #include linux/usb/otg.h
+#include linux/phy/phy.h
 #include linux/usb/musb-omap.h
 #include linux/usb/ulpi.h
 #include linux/i2c/twl.h
@@ -431,6 +432,14 @@ static void twl4030_phy_suspend(struct twl4030_usb *twl, 
int controller_off)
dev_dbg(twl-dev, %s\n, __func__);
 }
 
+static int twl4030_phy_power_off(struct phy *phy)
+{
+   struct twl4030_usb *twl = phy_get_drvdata(phy);
+
+   twl4030_phy_suspend(twl, 0);
+   return 0;
+}
+
 static void __twl4030_phy_resume(struct twl4030_usb *twl)
 {
twl4030_phy_power(twl, 1);
@@ -459,6 +468,14 @@ static void twl4030_phy_resume(struct twl4030_usb *twl)
}
 }
 
+static int twl4030_phy_power_on(struct phy *phy)
+{
+   struct twl4030_usb *twl = phy_get_drvdata(phy);
+
+   twl4030_phy_resume(twl);
+   return 0;
+}
+
 static int twl4030_usb_ldo_init(struct twl4030_usb *twl)
 {
/* Enable writing to power configuration registers */
@@ -602,13 +619,22 @@ static int twl4030_usb_phy_init(struct usb_phy *phy)
status = twl4030_usb_linkstat(twl);
twl-linkstat = status;
 
-   if (status == OMAP_MUSB_ID_GROUND || status == OMAP_MUSB_VBUS_VALID)
+   if (status == OMAP_MUSB_ID_GROUND || status == OMAP_MUSB_VBUS_VALID) {
omap_musb_mailbox(twl-linkstat);
+   twl4030_phy_resume(twl);
+   }
 
sysfs_notify(twl-dev-kobj, NULL, vbus);
return 0;
 }
 
+static int twl4030_phy_init(struct phy *phy)
+{
+   struct twl4030_usb *twl = phy_get_drvdata(phy);
+
+   return twl4030_usb_phy_init(twl-phy);
+}
+
 static int twl4030_set_suspend(struct usb_phy *x, int suspend)
 {
struct twl4030_usb *twl = phy_to_twl(x);
@@ -646,13 +672,23 @@ static int twl4030_set_host(struct usb_otg *otg, struct 
usb_bus *host)
return 0;
 }
 
+static const struct phy_ops ops = {
+   .init   = twl4030_phy_init,
+   .power_on   = twl4030_phy_power_on,
+   .power_off  = twl4030_phy_power_off,
+   .owner  = THIS_MODULE,
+};
+
 static int twl4030_usb_probe(struct platform_device *pdev)
 {
struct twl4030_usb_data *pdata = pdev-dev.platform_data;
struct twl4030_usb  *twl;
+   struct phy  *phy;
int status, err;
struct usb_otg  *otg;
struct device_node  *np = pdev-dev.of_node;
+   struct phy_provider *phy_provider;
+   struct phy_init_data

Re: [PATCH v2] extcon: palmas: Modified the compatible type to *ti,palmas-usb-vid*

2013-08-19 Thread Kishon Vijay Abraham I
On Monday 19 August 2013 10:35 AM, Kishon Vijay Abraham I wrote:
 Hi,
 
 On Saturday 17 August 2013 03:51 AM, Stephen Warren wrote:
 On 08/16/2013 04:20 AM, Kishon Vijay Abraham I wrote:
 The Palmas device contains only a USB VID detector, so modified the
 compatible type to *ti,palmas-usb-vid*.

 diff --git a/Documentation/devicetree/bindings/extcon/extcon-palmas.txt 
 b/Documentation/devicetree/bindings/extcon/extcon-palmas.txt

  PALMAS USB COMPARATOR
  Required Properties:
 - - compatible : Should be ti,palmas-usb or ti,twl6035-usb
 + - compatible : Should be ti,palmas-usb-vid.

 Has the old value been published in a release kernel? If so, it makes
 
 No. This was merged only in 3.11-rc1. So I think we should take this version?
 Chanwoo can you take this patch?

Ah.. the old values will be part of 3.11 kernel. So should we retain the old
values?

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


Re: [PATCH v2] extcon: palmas: Modified the compatible type to *ti,palmas-usb-vid*

2013-08-19 Thread Kishon Vijay Abraham I
On Monday 19 August 2013 02:54 PM, Chanwoo Choi wrote:
 On 08/19/2013 05:47 PM, Kishon Vijay Abraham I wrote:
 On Monday 19 August 2013 10:35 AM, Kishon Vijay Abraham I wrote:
 Hi,

 On Saturday 17 August 2013 03:51 AM, Stephen Warren wrote:
 On 08/16/2013 04:20 AM, Kishon Vijay Abraham I wrote:
 The Palmas device contains only a USB VID detector, so modified the
 compatible type to *ti,palmas-usb-vid*.

 diff --git a/Documentation/devicetree/bindings/extcon/extcon-palmas.txt 
 b/Documentation/devicetree/bindings/extcon/extcon-palmas.txt

  PALMAS USB COMPARATOR
  Required Properties:
 - - compatible : Should be ti,palmas-usb or ti,twl6035-usb
 + - compatible : Should be ti,palmas-usb-vid.

 Has the old value been published in a release kernel? If so, it makes

 No. This was merged only in 3.11-rc1. So I think we should take this 
 version?
 Chanwoo can you take this patch?

 Ah.. the old values will be part of 3.11 kernel. So should we retain the old
 values?
 
 What is the meaning of old value? previous value related to extcon-twl.txt?

We were discussing on whether to have ti,palmas-usb or ti,twl6035-usb in
compatible value in addition to ti,palmas-usb-vid. Stephen wanted the old
values (ti,palmas-usb or ti,twl6035-usb) if it has been published in a
release kernel.
 
 The extcon-twl.txt was included in 3.11 kernel

Right. Since it's part of 3.11 kernel, I think we should retain the old
compatible values.

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


Re: [PATCH v2] extcon: palmas: Modified the compatible type to *ti,palmas-usb-vid*

2013-08-19 Thread Kishon Vijay Abraham I
On Monday 19 August 2013 03:51 PM, Benoit Cousson wrote:
 Hi Kishon,
 
 On 19/08/2013 11:29, Kishon Vijay Abraham I wrote:
 On Monday 19 August 2013 02:54 PM, Chanwoo Choi wrote:
 On 08/19/2013 05:47 PM, Kishon Vijay Abraham I wrote:
 On Monday 19 August 2013 10:35 AM, Kishon Vijay Abraham I wrote:
 Hi,

 On Saturday 17 August 2013 03:51 AM, Stephen Warren wrote:
 On 08/16/2013 04:20 AM, Kishon Vijay Abraham I wrote:
 The Palmas device contains only a USB VID detector, so modified the
 compatible type to *ti,palmas-usb-vid*.

 diff --git a/Documentation/devicetree/bindings/extcon/extcon-palmas.txt
 b/Documentation/devicetree/bindings/extcon/extcon-palmas.txt
 
 That file is not yet in 3.11. Only the twl is there.
 Is this one a rename of the twl one?

yes Benoit. This is the commit
http://git.kernel.org/cgit/linux/kernel/git/chanwoo/extcon.git/commit/?h=extcon-nextid=80d644b297dc26c5126858555044edef76f4ffe8

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


Re: [PATCH v2] extcon: palmas: Modified the compatible type to *ti,palmas-usb-vid*

2013-08-18 Thread Kishon Vijay Abraham I
Hi,

On Saturday 17 August 2013 03:51 AM, Stephen Warren wrote:
 On 08/16/2013 04:20 AM, Kishon Vijay Abraham I wrote:
 The Palmas device contains only a USB VID detector, so modified the
 compatible type to *ti,palmas-usb-vid*.
 
 diff --git a/Documentation/devicetree/bindings/extcon/extcon-palmas.txt 
 b/Documentation/devicetree/bindings/extcon/extcon-palmas.txt
 
  PALMAS USB COMPARATOR
  Required Properties:
 - - compatible : Should be ti,palmas-usb or ti,twl6035-usb
 + - compatible : Should be ti,palmas-usb-vid.
 
 Has the old value been published in a release kernel? If so, it makes

No. This was merged only in 3.11-rc1. So I think we should take this version?
Chanwoo can you take this patch?

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


Re: [PATCH 01/15] drivers: phy: add generic PHY framework

2013-08-18 Thread Kishon Vijay Abraham I
Felipe,

ping..

On Wednesday 14 August 2013 08:35 PM, Kishon Vijay Abraham I wrote:
 Hi,
 
 On Wednesday 14 August 2013 04:34 AM, Tomasz Figa wrote:
 On Wednesday 14 of August 2013 00:19:28 Sylwester Nawrocki wrote:
 W dniu 2013-08-13 14:05, Kishon Vijay Abraham I pisze:
 On Tuesday 13 August 2013 05:07 PM, Tomasz Figa wrote:
 On Tuesday 13 of August 2013 16:14:44 Kishon Vijay Abraham I wrote:
 On Wednesday 31 July 2013 11:45 AM, Felipe Balbi wrote:
 On Wed, Jul 31, 2013 at 11:14:32AM +0530, Kishon Vijay Abraham I 
 wrote:
 IMHO we need a lookup method for PHYs, just like for clocks,
 regulators, PWMs or even i2c busses because there are complex
 cases
 when passing just a name using platform data will not work. I
 would
 second what Stephen said [1] and define a structure doing
 things
 in a
 DT-like way.

 Example;

 [platform code]

 static const struct phy_lookup my_phy_lookup[] = {

   PHY_LOOKUP(s3c-hsotg.0, otg, samsung-usbphy.1,
   phy.2),

 The only problem here is that if *PLATFORM_DEVID_AUTO* is used
 while
 creating the device, the ids in the device name would change
 and
 PHY_LOOKUP wont be useful.

 I don't think this is a problem. All the existing lookup
 methods
 already
 use ID to identify devices (see regulators, clkdev, PWMs, i2c,
 ...). You
 can simply add a requirement that the ID must be assigned
 manually,
 without using PLATFORM_DEVID_AUTO to use PHY lookup.

 And I'm saying that this idea, of using a specific name and id,
 is
 frought with fragility and will break in the future in various
 ways
 when
 devices get added to systems, making these strings constantly
 have
 to be
 kept up to date with different board configurations.

 People, NEVER, hardcode something like an id.  The fact that
 this
 happens today with the clock code, doesn't make it right, it
 makes
 the
 clock code wrong.  Others have already said that this is wrong
 there
 as
 well, as systems change and dynamic ids get used more and more.

 Let's not repeat the same mistakes of the past just because we
 refuse to
 learn from them...

 So again, the find a phy by a string functions should be
 removed,
 the
 device id should be automatically created by the phy core just
 to
 make
 things unique in sysfs, and no driver code should _ever_ be
 reliant
 on
 the number that is being created, and the pointer to the phy
 structure
 should be used everywhere instead.

 With those types of changes, I will consider merging this
 subsystem,
 but
 without them, sorry, I will not.

 I'll agree with Greg here, the very fact that we see people
 trying to
 add a requirement of *NOT* using PLATFORM_DEVID_AUTO already
 points
 to a big problem in the framework.

 The fact is that if we don't allow PLATFORM_DEVID_AUTO we will
 end up
 adding similar infrastructure to the driver themselves to make
 sure
 we
 don't end up with duplicate names in sysfs in case we have
 multiple
 instances of the same IP in the SoC (or several of the same PCIe
 card).
 I really don't want to go back to that.

 If we are using PLATFORM_DEVID_AUTO, then I dont see any way we
 can
 give the correct binding information to the PHY framework. I think
 we
 can drop having this non-dt support in PHY framework? I see only
 one
 platform (OMAP3) going to be needing this non-dt support and we
 can
 use the USB PHY library for it.

 you shouldn't drop support for non-DT platform, in any case we
 lived
 without DT (and still do) for years. Gotta find a better way ;-)

 hmm..

 how about passing the device names of PHY in platform data of the
 controller? It should be deterministic as the PHY framework assigns
 its
 own id and we *don't* want to add any requirement that the ID must
 be
 assigned manually without using PLATFORM_DEVID_AUTO. We can get rid
 of
 *phy_init_data* in the v10 patch series.

 OK, so the PHY device name would have a fixed part, passed as
 platform data of the controller and a variable part appended
 by the PHY core, depending on the number of registered PHYs ?

 Then same PHY names would be passed as the PHY provider driver's
 platform data ?

 Then if there are 2 instances of the above (same names in platform
 data) how would be determined which PHY controller is linked to
 which PHY supplier ?

 I guess you want each device instance to have different PHY device
 names already in platform data ? That might work. We probably will
 be focused mostly on DT anyway. It seem without DT we are trying
 to find some layer that would allow us to couple relevant devices
 and overcome driver core inconvenience that it provides to means
 to identify specific devices in advance. :) Your proposal sounds
 reasonable, however I might be missing some details or corner cases.

 What about slightly altering the concept of v9 to pass a pointer to
 struct device instead of device name inside phy_init_data?

 As Felipe said, we don't want to pass pointers in platform_data
 to/from random subsystems. We pass data, passing pointers would
 be a total mess IMHO.

 Well

Re: [PATCH] arm: omap5: dts: split SMPS10 dt node

2013-08-16 Thread Kishon Vijay Abraham I
On Friday 16 August 2013 02:24 PM, Benoit Cousson wrote:
 On 16/08/2013 07:15, Kishon Vijay Abraham I wrote:
 Hi Benoit,

 On Tuesday 13 August 2013 08:18 PM, Benoit Cousson wrote:
 On 13/08/2013 16:45, Kishon Vijay Abraham I wrote:
 Hi,

 On Tuesday 13 August 2013 06:51 PM, Benoit Cousson wrote:
 Hi Kishon,

 On 12/08/2013 11:37, Kishon Vijay Abraham I wrote:
 SMPS10 has two outputs OUT1 and OUT2. Hence SMPS10 is modeled as
 two regulators. The dt node is split to reflect it.

 Mmm, I'm curious. How is it supposed to work?

 Do you have dedicated control on each output?

 Yes. It can be controlled by setting different values to the same bit 
 fields.
 You can refer [1] where we actually implement SMPS10 as two different
 regulators.

 [1] - http://permalink.gmane.org/gmane.linux.kernel/1542521

 Great, thanks.

 Can we merge that one safely if the driver changed are not done yet?

 I think it shouldn't cause any issues. However Mark has already merged the
 driver changes.
 
 Cool. I've just applied your patch in for_3.12/dts

Thanks :-)

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


[PATCH v2] extcon: palmas: Modified the compatible type to *ti,palmas-usb-vid*

2013-08-16 Thread Kishon Vijay Abraham I
The Palmas device contains only a USB VID detector, so modified the
compatible type to *ti,palmas-usb-vid*.

Signed-off-by: Kishon Vijay Abraham I kis...@ti.com
---
Changes from v1:
* removed the existing compatible types and changed it to *ti,palmas-usb-vid*

 Documentation/devicetree/bindings/extcon/extcon-palmas.txt |4 ++--
 drivers/extcon/extcon-palmas.c |3 +--
 2 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/Documentation/devicetree/bindings/extcon/extcon-palmas.txt 
b/Documentation/devicetree/bindings/extcon/extcon-palmas.txt
index 7dab6a8..00859f6 100644
--- a/Documentation/devicetree/bindings/extcon/extcon-palmas.txt
+++ b/Documentation/devicetree/bindings/extcon/extcon-palmas.txt
@@ -2,7 +2,7 @@ EXTCON FOR PALMAS/TWL CHIPS
 
 PALMAS USB COMPARATOR
 Required Properties:
- - compatible : Should be ti,palmas-usb or ti,twl6035-usb
+ - compatible : Should be ti,palmas-usb-vid.
 
 Optional Properties:
  - ti,wakeup : To enable the wakeup comparator in probe
@@ -10,6 +10,6 @@ Optional Properties:
  - ti,enable-vbus-detection: Perform VBUS detection.
 
 palmas-usb {
-   compatible = ti,twl6035-usb, ti,palmas-usb;
+   compatible = ti,palmas-usb-vid;
ti,wakeup;
 };
diff --git a/drivers/extcon/extcon-palmas.c b/drivers/extcon/extcon-palmas.c
index 89fdd05..f3ed2d7 100644
--- a/drivers/extcon/extcon-palmas.c
+++ b/drivers/extcon/extcon-palmas.c
@@ -267,8 +267,7 @@ static const struct dev_pm_ops palmas_pm_ops = {
 };
 
 static struct of_device_id of_palmas_match_tbl[] = {
-   { .compatible = ti,palmas-usb, },
-   { .compatible = ti,twl6035-usb, },
+   { .compatible = ti,palmas-usb-vid, },
{ /* end */ }
 };
 
-- 
1.7.10.4

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


Re: [PATCH] arm: omap5: dts: split SMPS10 dt node

2013-08-15 Thread Kishon Vijay Abraham I
Hi Benoit,

On Tuesday 13 August 2013 08:18 PM, Benoit Cousson wrote:
 On 13/08/2013 16:45, Kishon Vijay Abraham I wrote:
 Hi,

 On Tuesday 13 August 2013 06:51 PM, Benoit Cousson wrote:
 Hi Kishon,

 On 12/08/2013 11:37, Kishon Vijay Abraham I wrote:
 SMPS10 has two outputs OUT1 and OUT2. Hence SMPS10 is modeled as
 two regulators. The dt node is split to reflect it.

 Mmm, I'm curious. How is it supposed to work?

 Do you have dedicated control on each output?

 Yes. It can be controlled by setting different values to the same bit fields.
 You can refer [1] where we actually implement SMPS10 as two different
 regulators.

 [1] - http://permalink.gmane.org/gmane.linux.kernel/1542521
 
 Great, thanks.
 
 Can we merge that one safely if the driver changed are not done yet?

I think it shouldn't cause any issues. However Mark has already merged the
driver changes.

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


Re: [PATCH 01/15] drivers: phy: add generic PHY framework

2013-08-14 Thread Kishon Vijay Abraham I
Hi,

On Wednesday 14 August 2013 04:34 AM, Tomasz Figa wrote:
 On Wednesday 14 of August 2013 00:19:28 Sylwester Nawrocki wrote:
 W dniu 2013-08-13 14:05, Kishon Vijay Abraham I pisze:
 On Tuesday 13 August 2013 05:07 PM, Tomasz Figa wrote:
 On Tuesday 13 of August 2013 16:14:44 Kishon Vijay Abraham I wrote:
 On Wednesday 31 July 2013 11:45 AM, Felipe Balbi wrote:
 On Wed, Jul 31, 2013 at 11:14:32AM +0530, Kishon Vijay Abraham I 
 wrote:
 IMHO we need a lookup method for PHYs, just like for clocks,
 regulators, PWMs or even i2c busses because there are complex
 cases
 when passing just a name using platform data will not work. I
 would
 second what Stephen said [1] and define a structure doing
 things
 in a
 DT-like way.

 Example;

 [platform code]

 static const struct phy_lookup my_phy_lookup[] = {

PHY_LOOKUP(s3c-hsotg.0, otg, samsung-usbphy.1,
phy.2),

 The only problem here is that if *PLATFORM_DEVID_AUTO* is used
 while
 creating the device, the ids in the device name would change
 and
 PHY_LOOKUP wont be useful.

 I don't think this is a problem. All the existing lookup
 methods
 already
 use ID to identify devices (see regulators, clkdev, PWMs, i2c,
 ...). You
 can simply add a requirement that the ID must be assigned
 manually,
 without using PLATFORM_DEVID_AUTO to use PHY lookup.

 And I'm saying that this idea, of using a specific name and id,
 is
 frought with fragility and will break in the future in various
 ways
 when
 devices get added to systems, making these strings constantly
 have
 to be
 kept up to date with different board configurations.

 People, NEVER, hardcode something like an id.  The fact that
 this
 happens today with the clock code, doesn't make it right, it
 makes
 the
 clock code wrong.  Others have already said that this is wrong
 there
 as
 well, as systems change and dynamic ids get used more and more.

 Let's not repeat the same mistakes of the past just because we
 refuse to
 learn from them...

 So again, the find a phy by a string functions should be
 removed,
 the
 device id should be automatically created by the phy core just
 to
 make
 things unique in sysfs, and no driver code should _ever_ be
 reliant
 on
 the number that is being created, and the pointer to the phy
 structure
 should be used everywhere instead.

 With those types of changes, I will consider merging this
 subsystem,
 but
 without them, sorry, I will not.

 I'll agree with Greg here, the very fact that we see people
 trying to
 add a requirement of *NOT* using PLATFORM_DEVID_AUTO already
 points
 to a big problem in the framework.

 The fact is that if we don't allow PLATFORM_DEVID_AUTO we will
 end up
 adding similar infrastructure to the driver themselves to make
 sure
 we
 don't end up with duplicate names in sysfs in case we have
 multiple
 instances of the same IP in the SoC (or several of the same PCIe
 card).
 I really don't want to go back to that.

 If we are using PLATFORM_DEVID_AUTO, then I dont see any way we
 can
 give the correct binding information to the PHY framework. I think
 we
 can drop having this non-dt support in PHY framework? I see only
 one
 platform (OMAP3) going to be needing this non-dt support and we
 can
 use the USB PHY library for it.

 you shouldn't drop support for non-DT platform, in any case we
 lived
 without DT (and still do) for years. Gotta find a better way ;-)

 hmm..

 how about passing the device names of PHY in platform data of the
 controller? It should be deterministic as the PHY framework assigns
 its
 own id and we *don't* want to add any requirement that the ID must
 be
 assigned manually without using PLATFORM_DEVID_AUTO. We can get rid
 of
 *phy_init_data* in the v10 patch series.

 OK, so the PHY device name would have a fixed part, passed as
 platform data of the controller and a variable part appended
 by the PHY core, depending on the number of registered PHYs ?

 Then same PHY names would be passed as the PHY provider driver's
 platform data ?

 Then if there are 2 instances of the above (same names in platform
 data) how would be determined which PHY controller is linked to
 which PHY supplier ?

 I guess you want each device instance to have different PHY device
 names already in platform data ? That might work. We probably will
 be focused mostly on DT anyway. It seem without DT we are trying
 to find some layer that would allow us to couple relevant devices
 and overcome driver core inconvenience that it provides to means
 to identify specific devices in advance. :) Your proposal sounds
 reasonable, however I might be missing some details or corner cases.

 What about slightly altering the concept of v9 to pass a pointer to
 struct device instead of device name inside phy_init_data?

 As Felipe said, we don't want to pass pointers in platform_data
 to/from random subsystems. We pass data, passing pointers would
 be a total mess IMHO.
 
 Well, this is a total mess anyway... I don't really get the point of using

[PATCH 1/2] usb: musb: convert to devm_* to allocate resources

2013-08-13 Thread Kishon Vijay Abraham I
No functional change. Used devm_kzalloc and devm_clk_get instead of
kzalloc and clk_get.

Signed-off-by: Kishon Vijay Abraham I kis...@ti.com
---
only *compile* tested.

 drivers/usb/musb/am35x.c |   40 ++--
 drivers/usb/musb/blackfin.c  |8 ++--
 drivers/usb/musb/da8xx.c |   28 ++--
 drivers/usb/musb/davinci.c   |   28 ++--
 drivers/usb/musb/musb_dsps.c |4 +---
 drivers/usb/musb/tusb6010.c  |   16 ++--
 drivers/usb/musb/ux500.c |   28 ++--
 7 files changed, 53 insertions(+), 99 deletions(-)

diff --git a/drivers/usb/musb/am35x.c b/drivers/usb/musb/am35x.c
index 5c310c6..50ba013 100644
--- a/drivers/usb/musb/am35x.c
+++ b/drivers/usb/musb/am35x.c
@@ -465,7 +465,7 @@ static int am35x_probe(struct platform_device *pdev)
 
int ret = -ENOMEM;
 
-   glue = kzalloc(sizeof(*glue), GFP_KERNEL);
+   glue = devm_kzalloc(pdev-dev, sizeof(*glue), GFP_KERNEL);
if (!glue) {
dev_err(pdev-dev, failed to allocate glue context\n);
goto err0;
@@ -474,33 +474,33 @@ static int am35x_probe(struct platform_device *pdev)
musb = platform_device_alloc(musb-hdrc, PLATFORM_DEVID_AUTO);
if (!musb) {
dev_err(pdev-dev, failed to allocate musb device\n);
-   goto err1;
+   goto err0;
}
 
-   phy_clk = clk_get(pdev-dev, fck);
+   phy_clk = devm_clk_get(pdev-dev, fck);
if (IS_ERR(phy_clk)) {
dev_err(pdev-dev, failed to get PHY clock\n);
ret = PTR_ERR(phy_clk);
-   goto err3;
+   goto err1;
}
 
-   clk = clk_get(pdev-dev, ick);
+   clk = devm_clk_get(pdev-dev, ick);
if (IS_ERR(clk)) {
dev_err(pdev-dev, failed to get clock\n);
ret = PTR_ERR(clk);
-   goto err4;
+   goto err1;
}
 
ret = clk_enable(phy_clk);
if (ret) {
dev_err(pdev-dev, failed to enable PHY clock\n);
-   goto err5;
+   goto err1;
}
 
ret = clk_enable(clk);
if (ret) {
dev_err(pdev-dev, failed to enable clock\n);
-   goto err6;
+   goto err2;
}
 
musb-dev.parent= pdev-dev;
@@ -520,40 +520,31 @@ static int am35x_probe(struct platform_device *pdev)
pdev-num_resources);
if (ret) {
dev_err(pdev-dev, failed to add resources\n);
-   goto err7;
+   goto err3;
}
 
ret = platform_device_add_data(musb, pdata, sizeof(*pdata));
if (ret) {
dev_err(pdev-dev, failed to add platform_data\n);
-   goto err7;
+   goto err3;
}
 
ret = platform_device_add(musb);
if (ret) {
dev_err(pdev-dev, failed to register musb device\n);
-   goto err7;
+   goto err3;
}
 
return 0;
 
-err7:
+err3:
clk_disable(clk);
 
-err6:
+err2:
clk_disable(phy_clk);
 
-err5:
-   clk_put(clk);
-
-err4:
-   clk_put(phy_clk);
-
-err3:
-   platform_device_put(musb);
-
 err1:
-   kfree(glue);
+   platform_device_put(musb);
 
 err0:
return ret;
@@ -566,9 +557,6 @@ static int am35x_remove(struct platform_device *pdev)
platform_device_unregister(glue-musb);
clk_disable(glue-clk);
clk_disable(glue-phy_clk);
-   clk_put(glue-clk);
-   clk_put(glue-phy_clk);
-   kfree(glue);
 
return 0;
 }
diff --git a/drivers/usb/musb/blackfin.c b/drivers/usb/musb/blackfin.c
index 72e2056..70f4c5d 100644
--- a/drivers/usb/musb/blackfin.c
+++ b/drivers/usb/musb/blackfin.c
@@ -457,7 +457,7 @@ static int bfin_probe(struct platform_device *pdev)
 
int ret = -ENOMEM;
 
-   glue = kzalloc(sizeof(*glue), GFP_KERNEL);
+   glue = devm_kzalloc(pdev-dev, sizeof(*glue), GFP_KERNEL);
if (!glue) {
dev_err(pdev-dev, failed to allocate glue context\n);
goto err0;
@@ -466,7 +466,7 @@ static int bfin_probe(struct platform_device *pdev)
musb = platform_device_alloc(musb-hdrc, PLATFORM_DEVID_AUTO);
if (!musb) {
dev_err(pdev-dev, failed to allocate musb device\n);
-   goto err1;
+   goto err0;
}
 
musb-dev.parent= pdev-dev;
@@ -517,9 +517,6 @@ static int bfin_probe(struct platform_device *pdev)
 err3:
platform_device_put(musb);
 
-err1:
-   kfree(glue);
-
 err0:
return ret;
 }
@@ -529,7 +526,6 @@ static int bfin_remove(struct platform_device *pdev)
struct bfin_glue*glue = platform_get_drvdata(pdev);
 
platform_device_unregister(glue-musb);
-   kfree(glue

[PATCH 2/2] usb: musb: pass on all the required resources from glue to musb core

2013-08-13 Thread Kishon Vijay Abraham I
musb glue have to pass either 2 resources or 3 resources to the musb
core (musb core irq number, dma irq number and a memory
resource). So allocated *resource* for musb core in glue (based on the number
of resources in glue), copy all the resources from glue to core before creating
the musb core device. This prevents the need to know the number of resources
beforehand.

Signed-off-by: Kishon Vijay Abraham I kis...@ti.com
---
Tested omap4 panda and omap3 beagle for enumeration .
All other platforms compile tested only.

 drivers/usb/musb/am35x.c|   16 +++-
 drivers/usb/musb/blackfin.c |   28 ++--
 drivers/usb/musb/da8xx.c|   28 ++--
 drivers/usb/musb/davinci.c  |   28 ++--
 drivers/usb/musb/omap2430.c |   33 ++---
 drivers/usb/musb/tusb6010.c |   33 ++---
 drivers/usb/musb/ux500.c|   28 ++--
 7 files changed, 99 insertions(+), 95 deletions(-)

diff --git a/drivers/usb/musb/am35x.c b/drivers/usb/musb/am35x.c
index 50ba013..6ea907d 100644
--- a/drivers/usb/musb/am35x.c
+++ b/drivers/usb/musb/am35x.c
@@ -457,8 +457,10 @@ static u64 am35x_dmamask = DMA_BIT_MASK(32);
 static int am35x_probe(struct platform_device *pdev)
 {
struct musb_hdrc_platform_data  *pdata = dev_get_platdata(pdev-dev);
+   struct resource *musb_resources;
struct platform_device  *musb;
struct am35x_glue   *glue;
+   int i;
 
struct clk  *phy_clk;
struct clk  *clk;
@@ -477,6 +479,11 @@ static int am35x_probe(struct platform_device *pdev)
goto err0;
}
 
+   musb_resources = devm_kzalloc(pdev-dev, pdev-num_resources *
+   sizeof(*musb_resources), GFP_KERNEL);
+   if (!musb_resources)
+   goto err1;
+
phy_clk = devm_clk_get(pdev-dev, fck);
if (IS_ERR(phy_clk)) {
dev_err(pdev-dev, failed to get PHY clock\n);
@@ -516,7 +523,14 @@ static int am35x_probe(struct platform_device *pdev)
 
platform_set_drvdata(pdev, glue);
 
-   ret = platform_device_add_resources(musb, pdev-resource,
+   for (i = 0; i  pdev-num_resources; i++) {
+   musb_resources[i].name = pdev-resource[i].name;
+   musb_resources[i].start = pdev-resource[i].start;
+   musb_resources[i].end = pdev-resource[i].end;
+   musb_resources[i].flags = pdev-resource[i].flags;
+   }
+
+   ret = platform_device_add_resources(musb, musb_resources,
pdev-num_resources);
if (ret) {
dev_err(pdev-dev, failed to add resources\n);
diff --git a/drivers/usb/musb/blackfin.c b/drivers/usb/musb/blackfin.c
index 70f4c5d..9331ca9 100644
--- a/drivers/usb/musb/blackfin.c
+++ b/drivers/usb/musb/blackfin.c
@@ -450,10 +450,11 @@ static u64 bfin_dmamask = DMA_BIT_MASK(32);
 
 static int bfin_probe(struct platform_device *pdev)
 {
-   struct resource musb_resources[2];
+   struct resource *musb_resources;
struct musb_hdrc_platform_data  *pdata = dev_get_platdata(pdev-dev);
struct platform_device  *musb;
struct bfin_glue*glue;
+   int i;
 
int ret = -ENOMEM;
 
@@ -469,6 +470,11 @@ static int bfin_probe(struct platform_device *pdev)
goto err0;
}
 
+   musb_resources = devm_kzalloc(pdev-dev, pdev-num_resources *
+   sizeof(*musb_resources), GFP_KERNEL);
+   if (!musb_resources)
+   goto err3;
+
musb-dev.parent= pdev-dev;
musb-dev.dma_mask  = bfin_dmamask;
musb-dev.coherent_dma_mask = bfin_dmamask;
@@ -480,21 +486,15 @@ static int bfin_probe(struct platform_device *pdev)
 
platform_set_drvdata(pdev, glue);
 
-   memset(musb_resources, 0x00, sizeof(*musb_resources) *
-   ARRAY_SIZE(musb_resources));
-
-   musb_resources[0].name = pdev-resource[0].name;
-   musb_resources[0].start = pdev-resource[0].start;
-   musb_resources[0].end = pdev-resource[0].end;
-   musb_resources[0].flags = pdev-resource[0].flags;
-
-   musb_resources[1].name = pdev-resource[1].name;
-   musb_resources[1].start = pdev-resource[1].start;
-   musb_resources[1].end = pdev-resource[1].end;
-   musb_resources[1].flags = pdev-resource[1].flags;
+   for (i = 0; i  pdev-num_resources; i++) {
+   musb_resources[i].name = pdev-resource[i].name;
+   musb_resources[i].start = pdev-resource[i].start;
+   musb_resources[i].end = pdev-resource[i].end;
+   musb_resources[i].flags = pdev-resource[i].flags;
+   }
 
ret = platform_device_add_resources(musb, musb_resources

Re: [PATCH 1/2] extcon: palmas: Added a new compatible type *ti,palmas-usb-vid*

2013-08-13 Thread Kishon Vijay Abraham I
On Tuesday 13 August 2013 03:24 PM, Chanwoo Choi wrote:
 Hi Kishon,
 
 On 08/13/2013 02:37 PM, Kishon Vijay Abraham I wrote:
 The Palmas device contains only a USB VID detector, so added a
 compatible type *ti,palmas-usb-vid*. Dint remove the existing compatible
 types for backward compatibility.

 Signed-off-by: Kishon Vijay Abraham I kis...@ti.com
 ---
  Documentation/devicetree/bindings/extcon/extcon-twl.txt |3 ++-
  drivers/extcon/extcon-palmas.c  |1 +
  2 files changed, 3 insertions(+), 1 deletion(-)

 diff --git a/Documentation/devicetree/bindings/extcon/extcon-twl.txt 
 b/Documentation/devicetree/bindings/extcon/extcon-twl.txt
 index 58f531a..5be4afc 100644
 --- a/Documentation/devicetree/bindings/extcon/extcon-twl.txt
 +++ b/Documentation/devicetree/bindings/extcon/extcon-twl.txt
 @@ -2,7 +2,8 @@ EXTCON FOR TWL CHIPS
  
  PALMAS USB COMPARATOR
  Required Properties:
 - - compatible : Should be ti,palmas-usb or ti,twl6035-usb
 + - compatible : Should be ti,palmas-usb or ti,twl6035-usb or
 +   ti,palmas-usb-vid.
   - vbus-supply : phandle to the regulator device tree node.
  
  Optional Properties:
 diff --git a/drivers/extcon/extcon-palmas.c b/drivers/extcon/extcon-palmas.c
 index b752a0a..4f83fae 100644
 --- a/drivers/extcon/extcon-palmas.c
 +++ b/drivers/extcon/extcon-palmas.c
 @@ -223,6 +223,7 @@ static int palmas_usb_remove(struct platform_device 
 *pdev)
  
  static struct of_device_id of_palmas_match_tbl[] = {
  { .compatible = ti,palmas-usb, },
 +{ .compatible = ti,palmas-usb-vid, },
  { .compatible = ti,twl6035-usb, },
  { /* end */ }
  };

 
 This patch has a conflict. You have to always implement patch on extcon branch
 including latest patch. You need to resend v2 patch based on extcon-next 
 branch.
 
 'extcon-twl.txt' is renamed as 'extcon-palmas.txt' on following patch:
 http://git.kernel.org/cgit/linux/kernel/git/chanwoo/extcon.git/commit/?h=extcon-nextid=80d644b297dc26c5126858555044edef76f4ffe8
 
 And, 'vbus-supply' phandle was removed on following patch:
 http://git.kernel.org/cgit/linux/kernel/git/chanwoo/extcon.git/commit/?h=extcon-nextid=26ece4f0b7d2264282d9077d1843ff1e98189b6c

Alright. I'll send the patch shortly.

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


Re: [PATCH 01/15] drivers: phy: add generic PHY framework

2013-08-13 Thread Kishon Vijay Abraham I
Hi,

On Wednesday 31 July 2013 11:45 AM, Felipe Balbi wrote:
 Hi,
 
 On Wed, Jul 31, 2013 at 11:14:32AM +0530, Kishon Vijay Abraham I wrote:
 IMHO we need a lookup method for PHYs, just like for clocks,
 regulators, PWMs or even i2c busses because there are complex cases
 when passing just a name using platform data will not work. I would
 second what Stephen said [1] and define a structure doing things in a
 DT-like way.

 Example;

 [platform code]

 static const struct phy_lookup my_phy_lookup[] = {

 PHY_LOOKUP(s3c-hsotg.0, otg, samsung-usbphy.1, phy.2),

 The only problem here is that if *PLATFORM_DEVID_AUTO* is used while
 creating the device, the ids in the device name would change and
 PHY_LOOKUP wont be useful.

 I don't think this is a problem. All the existing lookup methods already 
 use ID to identify devices (see regulators, clkdev, PWMs, i2c, ...). You 
 can simply add a requirement that the ID must be assigned manually, 
 without using PLATFORM_DEVID_AUTO to use PHY lookup.

 And I'm saying that this idea, of using a specific name and id, is
 frought with fragility and will break in the future in various ways when
 devices get added to systems, making these strings constantly have to be
 kept up to date with different board configurations.

 People, NEVER, hardcode something like an id.  The fact that this
 happens today with the clock code, doesn't make it right, it makes the
 clock code wrong.  Others have already said that this is wrong there as
 well, as systems change and dynamic ids get used more and more.

 Let's not repeat the same mistakes of the past just because we refuse to
 learn from them...

 So again, the find a phy by a string functions should be removed, the
 device id should be automatically created by the phy core just to make
 things unique in sysfs, and no driver code should _ever_ be reliant on
 the number that is being created, and the pointer to the phy structure
 should be used everywhere instead.

 With those types of changes, I will consider merging this subsystem, but
 without them, sorry, I will not.

 I'll agree with Greg here, the very fact that we see people trying to
 add a requirement of *NOT* using PLATFORM_DEVID_AUTO already points to a
 big problem in the framework.

 The fact is that if we don't allow PLATFORM_DEVID_AUTO we will end up
 adding similar infrastructure to the driver themselves to make sure we
 don't end up with duplicate names in sysfs in case we have multiple
 instances of the same IP in the SoC (or several of the same PCIe card).
 I really don't want to go back to that.

 If we are using PLATFORM_DEVID_AUTO, then I dont see any way we can give the
 correct binding information to the PHY framework. I think we can drop having
 this non-dt support in PHY framework? I see only one platform (OMAP3) going 
 to
 be needing this non-dt support and we can use the USB PHY library for it.
 
 you shouldn't drop support for non-DT platform, in any case we lived
 without DT (and still do) for years. Gotta find a better way ;-)

hmm..

how about passing the device names of PHY in platform data of the controller?
It should be deterministic as the PHY framework assigns its own id and we
*don't* want to add any requirement that the ID must be assigned manually
without using PLATFORM_DEVID_AUTO. We can get rid of *phy_init_data* in the v10
patch series.

Thanks
Kishon
 

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


[PATCH v2] extcon: palmas: Added a new compatible type *ti,palmas-usb-vid*

2013-08-13 Thread Kishon Vijay Abraham I
The Palmas device contains only a USB VID detector, so added a
compatible type *ti,palmas-usb-vid*. Dint remove the existing compatible
types for backward compatibility.

Signed-off-by: Kishon Vijay Abraham I kis...@ti.com
---
Changes from v1:
rebased on extcon-next

 Documentation/devicetree/bindings/extcon/extcon-palmas.txt |3 ++-
 drivers/extcon/extcon-palmas.c |1 +
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/Documentation/devicetree/bindings/extcon/extcon-palmas.txt 
b/Documentation/devicetree/bindings/extcon/extcon-palmas.txt
index 7dab6a8..dc5fab3 100644
--- a/Documentation/devicetree/bindings/extcon/extcon-palmas.txt
+++ b/Documentation/devicetree/bindings/extcon/extcon-palmas.txt
@@ -2,7 +2,8 @@ EXTCON FOR PALMAS/TWL CHIPS
 
 PALMAS USB COMPARATOR
 Required Properties:
- - compatible : Should be ti,palmas-usb or ti,twl6035-usb
+ - compatible : Should be ti,palmas-usb or ti,twl6035-usb or
+   ti,palmas-usb-vid.
 
 Optional Properties:
  - ti,wakeup : To enable the wakeup comparator in probe
diff --git a/drivers/extcon/extcon-palmas.c b/drivers/extcon/extcon-palmas.c
index 89fdd05..9672f31 100644
--- a/drivers/extcon/extcon-palmas.c
+++ b/drivers/extcon/extcon-palmas.c
@@ -268,6 +268,7 @@ static const struct dev_pm_ops palmas_pm_ops = {
 
 static struct of_device_id of_palmas_match_tbl[] = {
{ .compatible = ti,palmas-usb, },
+   { .compatible = ti,palmas-usb-vid, },
{ .compatible = ti,twl6035-usb, },
{ /* end */ }
 };
-- 
1.7.10.4

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


Re: [PATCH 01/15] drivers: phy: add generic PHY framework

2013-08-13 Thread Kishon Vijay Abraham I
On Tuesday 13 August 2013 05:07 PM, Tomasz Figa wrote:
 On Tuesday 13 of August 2013 16:14:44 Kishon Vijay Abraham I wrote:
 Hi,

 On Wednesday 31 July 2013 11:45 AM, Felipe Balbi wrote:
 Hi,

 On Wed, Jul 31, 2013 at 11:14:32AM +0530, Kishon Vijay Abraham I wrote:
 IMHO we need a lookup method for PHYs, just like for clocks,
 regulators, PWMs or even i2c busses because there are complex
 cases
 when passing just a name using platform data will not work. I
 would
 second what Stephen said [1] and define a structure doing things
 in a
 DT-like way.

 Example;

 [platform code]

 static const struct phy_lookup my_phy_lookup[] = {

   PHY_LOOKUP(s3c-hsotg.0, otg, samsung-usbphy.1, phy.2),

 The only problem here is that if *PLATFORM_DEVID_AUTO* is used
 while
 creating the device, the ids in the device name would change and
 PHY_LOOKUP wont be useful.

 I don't think this is a problem. All the existing lookup methods
 already
 use ID to identify devices (see regulators, clkdev, PWMs, i2c,
 ...). You
 can simply add a requirement that the ID must be assigned manually,
 without using PLATFORM_DEVID_AUTO to use PHY lookup.

 And I'm saying that this idea, of using a specific name and id, is
 frought with fragility and will break in the future in various ways
 when
 devices get added to systems, making these strings constantly have
 to be
 kept up to date with different board configurations.

 People, NEVER, hardcode something like an id.  The fact that this
 happens today with the clock code, doesn't make it right, it makes
 the
 clock code wrong.  Others have already said that this is wrong there
 as
 well, as systems change and dynamic ids get used more and more.

 Let's not repeat the same mistakes of the past just because we
 refuse to
 learn from them...

 So again, the find a phy by a string functions should be removed,
 the
 device id should be automatically created by the phy core just to
 make
 things unique in sysfs, and no driver code should _ever_ be reliant
 on
 the number that is being created, and the pointer to the phy
 structure
 should be used everywhere instead.

 With those types of changes, I will consider merging this subsystem,
 but
 without them, sorry, I will not.

 I'll agree with Greg here, the very fact that we see people trying to
 add a requirement of *NOT* using PLATFORM_DEVID_AUTO already points
 to a
 big problem in the framework.

 The fact is that if we don't allow PLATFORM_DEVID_AUTO we will end up
 adding similar infrastructure to the driver themselves to make sure
 we
 don't end up with duplicate names in sysfs in case we have multiple
 instances of the same IP in the SoC (or several of the same PCIe
 card).
 I really don't want to go back to that.

 If we are using PLATFORM_DEVID_AUTO, then I dont see any way we can
 give the correct binding information to the PHY framework. I think we
 can drop having this non-dt support in PHY framework? I see only one
 platform (OMAP3) going to be needing this non-dt support and we can
 use the USB PHY library for it. 
 you shouldn't drop support for non-DT platform, in any case we lived
 without DT (and still do) for years. Gotta find a better way ;-)

 hmm..

 how about passing the device names of PHY in platform data of the
 controller? It should be deterministic as the PHY framework assigns its
 own id and we *don't* want to add any requirement that the ID must be
 assigned manually without using PLATFORM_DEVID_AUTO. We can get rid of
 *phy_init_data* in the v10 patch series.
 
 What about slightly altering the concept of v9 to pass a pointer to struct 
 device instead of device name inside phy_init_data?

The problem is device might be created very late. (For example in omap4, usb2
phy device gets created when ocp2scp bus is probed). And we have to pass the
init data in board file.

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


Re: [PATCH] arm: omap5: dts: split SMPS10 dt node

2013-08-13 Thread Kishon Vijay Abraham I
Hi,

On Tuesday 13 August 2013 06:51 PM, Benoit Cousson wrote:
 Hi Kishon,
 
 On 12/08/2013 11:37, Kishon Vijay Abraham I wrote:
 SMPS10 has two outputs OUT1 and OUT2. Hence SMPS10 is modeled as
 two regulators. The dt node is split to reflect it.
 
 Mmm, I'm curious. How is it supposed to work?
 
 Do you have dedicated control on each output?

Yes. It can be controlled by setting different values to the same bit fields.
You can refer [1] where we actually implement SMPS10 as two different 
regulators.

[1] - http://permalink.gmane.org/gmane.linux.kernel/1542521

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


Re: [PATCH 1/2] extcon: palmas: Added a new compatible type *ti,palmas-usb-vid*

2013-08-13 Thread Kishon Vijay Abraham I
Hi,

On Wednesday 14 August 2013 12:43 AM, Stephen Warren wrote:
 On 08/12/2013 11:37 PM, Kishon Vijay Abraham I wrote:
 The Palmas device contains only a USB VID detector, so added a
 compatible type *ti,palmas-usb-vid*. Dint remove the existing compatible
 
 s/Dint/Didn't/
 
 diff --git a/Documentation/devicetree/bindings/extcon/extcon-twl.txt 
 b/Documentation/devicetree/bindings/extcon/extcon-twl.txt
 
  PALMAS USB COMPARATOR
  Required Properties:
 - - compatible : Should be ti,palmas-usb or ti,twl6035-usb
 + - compatible : Should be ti,palmas-usb or ti,twl6035-usb or
 +   ti,palmas-usb-vid.
 
 So are ti,palmas-usb and ti,twl6035-usb full EHCI controllers then?

No. I thought I shouldn't remove those if someone is already using those
compatible value.

Thanks
Kishon

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


[PATCH] arm: omap5: dts: split SMPS10 dt node

2013-08-12 Thread Kishon Vijay Abraham I
SMPS10 has two outputs OUT1 and OUT2. Hence SMPS10 is modeled as
two regulators. The dt node is split to reflect it.

Signed-off-by: Kishon Vijay Abraham I kis...@ti.com
---
 arch/arm/boot/dts/omap5-uevm.dts |   13 +++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/arch/arm/boot/dts/omap5-uevm.dts b/arch/arm/boot/dts/omap5-uevm.dts
index 65d7b60..05b9b12 100644
--- a/arch/arm/boot/dts/omap5-uevm.dts
+++ b/arch/arm/boot/dts/omap5-uevm.dts
@@ -334,9 +334,18 @@
ti,smps-range = 0x80;
};
 
-   smps10_reg: smps10 {
+   smps10_out2_reg: smps10_out2 {
/* VBUS_5V_OTG */
-   regulator-name = smps10;
+   regulator-name = smps10_out2;
+   regulator-min-microvolt = 500;
+   regulator-max-microvolt = 500;
+   regulator-always-on;
+   regulator-boot-on;
+   };
+
+   smps10_out1_reg: smps10_out1 {
+   /* VBUS_5V_OTG */
+   regulator-name = smps10_out1;
regulator-min-microvolt = 500;
regulator-max-microvolt = 500;
regulator-always-on;
-- 
1.7.10.4

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


[PATCH v3] arm: omap5: dts: add palmas-usb node

2013-08-12 Thread Kishon Vijay Abraham I
From: Felipe Balbi ba...@ti.com

Without this node, there will be no palmas
driver to notify dwc3 that a cable has
been connected and, without that, dwc3
will never initialize.

[ kis...@ti.com : fix vbus-supply value after SMPS10 is modeled as 2 regulators]

Signed-off-by: Felipe Balbi ba...@ti.com
Signed-off-by: Kishon Vijay Abraham I kis...@ti.com
---
Change from v2:
fix vbus-supply value after SMPS10 is modeled as 2 regulators. This is needed
after SMPS10 is modeled as 2 regulators.
[1] models SMPS10 as 2 regulators.
[2] splits the SMPS10 node into two to represent the 2 regulators.

[1] - http://comments.gmane.org/gmane.linux.kernel/1542521
[2] - http://www.mail-archive.com/linux-omap@vger.kernel.org/msg93779.html

 arch/arm/boot/dts/omap5-uevm.dts |   10 ++
 arch/arm/boot/dts/omap5.dtsi |2 +-
 2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/arch/arm/boot/dts/omap5-uevm.dts b/arch/arm/boot/dts/omap5-uevm.dts
index 08b7267..51a4acc 100644
--- a/arch/arm/boot/dts/omap5-uevm.dts
+++ b/arch/arm/boot/dts/omap5-uevm.dts
@@ -272,6 +272,11 @@
interrupt-controller;
#interrupt-cells = 2;
 
+   extcon_usb3: palmas_usb {
+   compatible = ti,palmas-usb;
+   ti,wakeup;
+   };
+
palmas_pmic {
compatible = ti,palmas-pmic;
interrupt-parent = palmas;
@@ -450,6 +455,11 @@
phys = 0 hsusb2_phy hsusb3_phy;
 };
 
+usb3 {
+   extcon = extcon_usb3;
+   vbus-supply = smps10_out1_reg;
+};
+
 mcspi1 {
 
 };
diff --git a/arch/arm/boot/dts/omap5.dtsi b/arch/arm/boot/dts/omap5.dtsi
index 4e41409..1659246 100644
--- a/arch/arm/boot/dts/omap5.dtsi
+++ b/arch/arm/boot/dts/omap5.dtsi
@@ -634,7 +634,7 @@
ti,type = 2;
};
 
-   omap_dwc3@4a02 {
+   usb3: omap_dwc3@4a02 {
compatible = ti,dwc3;
ti,hwmods = usb_otg_ss;
reg = 0x4a02 0x1;
-- 
1.7.10.4

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


[PATCH 1/2] extcon: palmas: Added a new compatible type *ti,palmas-usb-vid*

2013-08-12 Thread Kishon Vijay Abraham I
The Palmas device contains only a USB VID detector, so added a
compatible type *ti,palmas-usb-vid*. Dint remove the existing compatible
types for backward compatibility.

Signed-off-by: Kishon Vijay Abraham I kis...@ti.com
---
 Documentation/devicetree/bindings/extcon/extcon-twl.txt |3 ++-
 drivers/extcon/extcon-palmas.c  |1 +
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/Documentation/devicetree/bindings/extcon/extcon-twl.txt 
b/Documentation/devicetree/bindings/extcon/extcon-twl.txt
index 58f531a..5be4afc 100644
--- a/Documentation/devicetree/bindings/extcon/extcon-twl.txt
+++ b/Documentation/devicetree/bindings/extcon/extcon-twl.txt
@@ -2,7 +2,8 @@ EXTCON FOR TWL CHIPS
 
 PALMAS USB COMPARATOR
 Required Properties:
- - compatible : Should be ti,palmas-usb or ti,twl6035-usb
+ - compatible : Should be ti,palmas-usb or ti,twl6035-usb or
+   ti,palmas-usb-vid.
  - vbus-supply : phandle to the regulator device tree node.
 
 Optional Properties:
diff --git a/drivers/extcon/extcon-palmas.c b/drivers/extcon/extcon-palmas.c
index b752a0a..4f83fae 100644
--- a/drivers/extcon/extcon-palmas.c
+++ b/drivers/extcon/extcon-palmas.c
@@ -223,6 +223,7 @@ static int palmas_usb_remove(struct platform_device *pdev)
 
 static struct of_device_id of_palmas_match_tbl[] = {
{ .compatible = ti,palmas-usb, },
+   { .compatible = ti,palmas-usb-vid, },
{ .compatible = ti,twl6035-usb, },
{ /* end */ }
 };
-- 
1.7.10.4

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


[PATCH v4 2/2] arm: omap5: dts: add palmas-usb node

2013-08-12 Thread Kishon Vijay Abraham I
From: Felipe Balbi ba...@ti.com

Without this node, there will be no palmas
driver to notify dwc3 that a cable has
been connected and, without that, dwc3
will never initialize.

[ kis...@ti.com : fix vbus-supply value after SMPS10 is modeled as 2 regulators]

Signed-off-by: Felipe Balbi ba...@ti.com
Signed-off-by: Kishon Vijay Abraham I kis...@ti.com
---
Changes from v3:
* Changed the compatible type to ti,palmas-usb-vid

Changes from v2:
fix vbus-supply value after SMPS10 is modeled as 2 regulators. This is needed
after SMPS10 is modeled as 2 regulators.
[1] models SMPS10 as 2 regulators.
[2] splits the SMPS10 node into two to represent the 2 regulators.

[1] - http://comments.gmane.org/gmane.linux.kernel/1542521
[2] - http://www.mail-archive.com/linux-omap@vger.kernel.org/msg93779.html

 arch/arm/boot/dts/omap5-uevm.dts |   10 ++
 arch/arm/boot/dts/omap5.dtsi |2 +-
 2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/arch/arm/boot/dts/omap5-uevm.dts b/arch/arm/boot/dts/omap5-uevm.dts
index e8704bc..c18ea50 100644
--- a/arch/arm/boot/dts/omap5-uevm.dts
+++ b/arch/arm/boot/dts/omap5-uevm.dts
@@ -272,6 +272,11 @@
interrupt-controller;
#interrupt-cells = 2;
 
+   extcon_usb3: palmas_usb {
+   compatible = ti,palmas-usb-vid;
+   ti,wakeup;
+   };
+
palmas_pmic {
compatible = ti,palmas-pmic;
interrupt-parent = palmas;
@@ -460,6 +465,11 @@
phys = 0 hsusb2_phy hsusb3_phy;
 };
 
+usb3 {
+   extcon = extcon_usb3;
+   vbus-supply = smps10_out1_reg;
+};
+
 mcspi1 {
 
 };
diff --git a/arch/arm/boot/dts/omap5.dtsi b/arch/arm/boot/dts/omap5.dtsi
index 4e41409..1659246 100644
--- a/arch/arm/boot/dts/omap5.dtsi
+++ b/arch/arm/boot/dts/omap5.dtsi
@@ -634,7 +634,7 @@
ti,type = 2;
};
 
-   omap_dwc3@4a02 {
+   usb3: omap_dwc3@4a02 {
compatible = ti,dwc3;
ti,hwmods = usb_otg_ss;
reg = 0x4a02 0x1;
-- 
1.7.10.4

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


Re: [PATCH 1/7] usb: phy: omap: Add new PHY types and remove omap_control_usb3_phy_power()

2013-08-06 Thread Kishon Vijay Abraham I

Hi,

On Thursday 01 August 2013 07:35 PM, Roger Quadros wrote:

TYPE2 meaning has changed. It is now a USB2 phy with Power down bit in
control_dev_conf register.

Introduce TYPE3 and TYPE4 PHY. TYPE3 is USB3 phy with DPLL and individual
TX/RX power control. TYPE4 is USB2 phy with power aux register.

Update DT binding information to reflect these changes.

Also get rid of omap_control_usb3_phy_power(). Just one function
i.e. omap_control_usb_phy_power() will now take care of all PHY types.

Signed-off-by: Roger Quadros rog...@ti.com


Tested-by: Kishon Vijay Abraham I kis...@ti.com
but one minor comment below.

---
  Documentation/devicetree/bindings/usb/omap-usb.txt |   23 ++--
  drivers/usb/phy/phy-omap-control.c |  129 +++-
  drivers/usb/phy/phy-omap-usb2.c|4 +
  drivers/usb/phy/phy-omap-usb3.c|6 +-
  include/linux/usb/omap_control_usb.h   |   18 ++--
  5 files changed, 100 insertions(+), 80 deletions(-)


.
.
snip
.
.


+   omap_control_usb_phy_power(phy-control_dev, 0);
usb_add_phy_dev(phy-phy);

platform_set_drvdata(pdev, phy);
diff --git a/include/linux/usb/omap_control_usb.h 
b/include/linux/usb/omap_control_usb.h
index 27b5b8c..7f027d3 100644
--- a/include/linux/usb/omap_control_usb.h
+++ b/include/linux/usb/omap_control_usb.h
@@ -22,9 +22,9 @@



  struct omap_control_usb {
struct device *dev;

-   u32 __iomem *dev_conf;
u32 __iomem *otghs_control;
-   u32 __iomem *phy_power;
+   u32 __iomem *power;
+   u32 __iomem *power_aux;

struct clk *sys_clk;


you can remove omap_control_usb_platform_data from here.

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


Re: [PATCH 3/7] usb: phy: omap-usb3: Don't use omap_get_control_dev()

2013-08-06 Thread Kishon Vijay Abraham I

On Thursday 01 August 2013 07:35 PM, Roger Quadros wrote:

omap_get_control_dev() is being deprecated as it doesn't support
multiple instances. As control device is present only from OMAP4
onwards which supports DT only, we use phandles to get the
reference to the control device.

As we don't support non-DT boot, we just bail out on probe
if device node is not present.

Signed-off-by: Roger Quadros rog...@ti.com


Tested-by: Kishon Vijay Abraham I kis...@ti.com



---
  drivers/usb/phy/phy-omap-usb3.c |   20 +---
  1 files changed, 17 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/phy/phy-omap-usb3.c b/drivers/usb/phy/phy-omap-usb3.c
index 4a7f27c..bad032e 100644
--- a/drivers/usb/phy/phy-omap-usb3.c
+++ b/drivers/usb/phy/phy-omap-usb3.c
@@ -26,6 +26,7 @@
  #include linux/pm_runtime.h
  #include linux/delay.h
  #include linux/usb/omap_control_usb.h
+#include linux/of_platform.h

  #define   PLL_STATUS  0x0004
  #define   PLL_GO  0x0008
@@ -198,6 +199,12 @@ static int omap_usb3_probe(struct platform_device *pdev)
  {
struct omap_usb *phy;
struct resource *res;
+   struct device_node *node = pdev-dev.of_node;
+   struct device_node *control_node;
+   struct platform_device *control_pdev;
+
+   if (!node)
+   return -ENODEV;

phy = devm_kzalloc(pdev-dev, sizeof(*phy), GFP_KERNEL);
if (!phy) {
@@ -239,11 +246,18 @@ static int omap_usb3_probe(struct platform_device *pdev)
return -EINVAL;
}

-   phy-control_dev = omap_get_control_dev();
-   if (IS_ERR(phy-control_dev)) {
-   dev_dbg(pdev-dev, Failed to get control device\n);
+   control_node = of_parse_phandle(node, ctrl-module, 0);
+   if (!control_node) {
+   dev_err(pdev-dev, Failed to get control device phandle\n);
return -ENODEV;
}
+   control_pdev = of_find_device_by_node(control_node);
+   if (!control_pdev) {
+   dev_err(pdev-dev, Failed to get control device\n);
+   return -ENODEV;
+   }
+
+   phy-control_dev = control_pdev-dev;

omap_control_usb_phy_power(phy-control_dev, 0);
usb_add_phy_dev(phy-phy);



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


Re: [PATCH 4/7] usb: musb: omap2430: Don't use omap_get_control_dev()

2013-08-06 Thread Kishon Vijay Abraham I

Hi,

On Thursday 01 August 2013 07:35 PM, Roger Quadros wrote:

omap_get_control_dev() is being deprecated as it doesn't support
multiple instances. As control device is present only from OMAP4
onwards which supports DT only, we use phandles to get the
reference to the control device.

Signed-off-by: Roger Quadros rog...@ti.com
---
  drivers/usb/musb/omap2430.c |   22 ++
  1 files changed, 18 insertions(+), 4 deletions(-)

diff --git a/drivers/usb/musb/omap2430.c b/drivers/usb/musb/omap2430.c
index ebb46ec..1db9588 100644
--- a/drivers/usb/musb/omap2430.c
+++ b/drivers/usb/musb/omap2430.c
@@ -38,6 +38,7 @@
  #include linux/delay.h
  #include linux/usb/musb-omap.h
  #include linux/usb/omap_control_usb.h
+#include linux/of_platform.h

  #include musb_core.h
  #include omap2430.h
@@ -547,12 +548,25 @@ static int omap2430_probe(struct platform_device *pdev)
}

if (pdata-has_mailbox) {


I think you can remove this this check all together. Mailbox is present 
only from OMAP4 so it can be dt only.


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


Re: [PATCH 2/7] usb: phy: omap-usb2: Don't use omap_get_control_dev()

2013-08-06 Thread Kishon Vijay Abraham I

On Thursday 01 August 2013 07:35 PM, Roger Quadros wrote:

omap_get_control_dev() is being deprecated as it doesn't support
multiple instances. As control device is present only from OMAP4
onwards which supports DT only, we use phandles to get the
reference to the control device.

As we don't support non-DT boot, we just bail out on probe
if device node is not present.

Signed-off-by: Roger Quadros rog...@ti.com

Tested-by: Kishon Vijay Abraham I kis...@ti.com

---
  drivers/usb/phy/phy-omap-usb2.c |   16 +---
  1 files changed, 13 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/phy/phy-omap-usb2.c b/drivers/usb/phy/phy-omap-usb2.c
index 376b367..77e0cf4 100644
--- a/drivers/usb/phy/phy-omap-usb2.c
+++ b/drivers/usb/phy/phy-omap-usb2.c
@@ -28,6 +28,7 @@
  #include linux/pm_runtime.h
  #include linux/delay.h
  #include linux/usb/omap_control_usb.h
+#include linux/of_platform.h

  /**
   * omap_usb2_set_comparator - links the comparator present in the sytem with
@@ -124,6 +125,8 @@ static int omap_usb2_probe(struct platform_device *pdev)
struct omap_usb *phy;
struct usb_otg  *otg;
struct device_node *node = pdev-dev.of_node;
+   struct device_node *control_node;
+   struct platform_device *control_pdev;

if (!node)
return -ENODEV;
@@ -148,11 +151,18 @@ static int omap_usb2_probe(struct platform_device *pdev)
phy-phy.otg = otg;
phy-phy.type= USB_PHY_TYPE_USB2;

-   phy-control_dev = omap_get_control_dev();
-   if (IS_ERR(phy-control_dev)) {
-   dev_dbg(pdev-dev, Failed to get control device\n);
+   control_node = of_parse_phandle(node, ctrl-module, 0);
+   if (!control_node) {
+   dev_err(pdev-dev, Failed to get control device phandle\n);
return -ENODEV;
}
+   control_pdev = of_find_device_by_node(control_node);
+   if (!control_pdev) {
+   dev_err(pdev-dev, Failed to get control device\n);
+   return -ENODEV;
+   }
+
+   phy-control_dev = control_pdev-dev;

phy-is_suspended= 1;
omap_control_usb_phy_power(phy-control_dev, 0);



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


Re: [PATCH 5/7] usb: phy: omap: get rid of omap_get_control_dev()

2013-08-06 Thread Kishon Vijay Abraham I

On Thursday 01 August 2013 07:35 PM, Roger Quadros wrote:

This function was preventing us from supporting multiple
instances. Get rid of it. Since we support DT boots only,
users can get the control device phandle from the DT node.

Signed-off-by: Roger Quadros rog...@ti.com


Tested-by: Kishon Vijay Abraham I kis...@ti.com

---
  drivers/usb/phy/phy-omap-control.c   |   31 ++-
  include/linux/usb/omap_control_usb.h |5 -
  2 files changed, 10 insertions(+), 26 deletions(-)

diff --git a/drivers/usb/phy/phy-omap-control.c 
b/drivers/usb/phy/phy-omap-control.c
index cf93c5a..015eeef 100644
--- a/drivers/usb/phy/phy-omap-control.c
+++ b/drivers/usb/phy/phy-omap-control.c
@@ -25,26 +25,6 @@
  #include linux/clk.h
  #include linux/usb/omap_control_usb.h

-static struct omap_control_usb *control_usb;
-
-/**
- * omap_get_control_dev - returns the device pointer for this control device
- *
- * This API should be called to get the device pointer for this control
- * module device. This device pointer should be used for called other
- * exported API's in this driver.
- *
- * To be used by PHY driver and glue driver.
- */
-struct device *omap_get_control_dev(void)
-{
-   if (!control_usb)
-   return ERR_PTR(-ENODEV);
-
-   return control_usb-dev;
-}
-EXPORT_SYMBOL_GPL(omap_get_control_dev);
-
  /**
   * omap_control_usb_phy_power - power on/off the phy using control module reg
   * @dev: the control module device
@@ -187,11 +167,19 @@ void omap_control_usb_set_mode(struct device *dev,
  {
struct omap_control_usb *ctrl_usb;

-   if (IS_ERR(dev) || control_usb-type != OMAP_CTRL_DEV_TYPE1)
+   if (IS_ERR(dev) || !dev)
return;

ctrl_usb = dev_get_drvdata(dev);

+   if (!ctrl_usb) {
+   dev_err(dev, Invalid control usb device\n);
+   return;
+   }
+
+   if (ctrl_usb-type != OMAP_CTRL_DEV_TYPE1)
+   return;
+
switch (mode) {
case USB_MODE_HOST:
omap_control_usb_host_mode(ctrl_usb);
@@ -214,6 +202,7 @@ static int omap_control_usb_probe(struct platform_device 
*pdev)
struct device_node *np = pdev-dev.of_node;
struct omap_control_usb_platform_data *pdata =
dev_get_platdata(pdev-dev);
+   struct omap_control_usb *control_usb;

control_usb = devm_kzalloc(pdev-dev, sizeof(*control_usb),
GFP_KERNEL);
diff --git a/include/linux/usb/omap_control_usb.h 
b/include/linux/usb/omap_control_usb.h
index 7f027d3..8b48584 100644
--- a/include/linux/usb/omap_control_usb.h
+++ b/include/linux/usb/omap_control_usb.h
@@ -67,15 +67,10 @@ enum omap_control_usb_mode {
  #define OMAP_CTRL_USB2_PHY_PD BIT(28)

  #if IS_ENABLED(CONFIG_OMAP_CONTROL_USB)
-extern struct device *omap_get_control_dev(void);
  extern void omap_control_usb_phy_power(struct device *dev, int on);
  extern void omap_control_usb_set_mode(struct device *dev,
enum omap_control_usb_mode mode);
  #else
-static inline struct device *omap_get_control_dev(void)
-{
-   return ERR_PTR(-ENODEV);
-}

  static inline void omap_control_usb_phy_power(struct device *dev, int on)
  {



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


Re: [PATCH 2/2] arm: omap: remove *.auto* from device names given in usb_bind_phy

2013-07-30 Thread Kishon Vijay Abraham I
Hi,

On Tuesday 30 July 2013 11:31 AM, Felipe Balbi wrote:
 Hi,
 
 On Tue, Jul 30, 2013 at 10:44:48AM +0530, Kishon Vijay Abraham I wrote:
 On Mon, Jul 29, 2013 at 08:59:26PM +0530, Kishon Vijay Abraham I wrote:
 Previously MUSB wrapper (OMAP) device used PLATFORM_DEVID_AUTO while 
 creating
 MUSB core device. So in usb_bind_phy (binds the controller with the 
 PHY), the
 device name of the controller had *.auto* in it. Since with using
 PLATFORM_DEVID_AUTO, there is no way to know the exact device name in 
 advance,
 the data given in usb_bind_phy became obsolete and usb_get_phy was 
 failing.
 So MUSB wrapper was modified not to use PLATFORM_DEVID_AUTO. 
 Corresponding
 change is done in board file here.

 Signed-off-by: Kishon Vijay Abraham I kis...@ti.com
 ---
  arch/arm/mach-omap2/board-2430sdp.c  |2 +-
  arch/arm/mach-omap2/board-3430sdp.c  |2 +-
  arch/arm/mach-omap2/board-cm-t35.c   |2 +-
  arch/arm/mach-omap2/board-devkit8000.c   |2 +-
  arch/arm/mach-omap2/board-igep0020.c |2 +-
  arch/arm/mach-omap2/board-ldp.c  |2 +-
  arch/arm/mach-omap2/board-omap3beagle.c  |2 +-
  arch/arm/mach-omap2/board-omap3evm.c |2 +-
  arch/arm/mach-omap2/board-omap3logic.c   |2 +-
  arch/arm/mach-omap2/board-omap3pandora.c |2 +-
  arch/arm/mach-omap2/board-omap3stalker.c |2 +-
  arch/arm/mach-omap2/board-omap3touchbook.c   |2 +-
  arch/arm/mach-omap2/board-overo.c|2 +-
  arch/arm/mach-omap2/board-rm680.c|2 +-
  arch/arm/mach-omap2/board-rx51.c |2 +-
  arch/arm/mach-omap2/board-zoom-peripherals.c |2 +-
  16 files changed, 16 insertions(+), 16 deletions(-)

 diff --git a/arch/arm/mach-omap2/board-2430sdp.c 
 b/arch/arm/mach-omap2/board-2430sdp.c
 index 244d8a5..17bb076 100644
 --- a/arch/arm/mach-omap2/board-2430sdp.c
 +++ b/arch/arm/mach-omap2/board-2430sdp.c
 @@ -233,7 +233,7 @@ static void __init omap_2430sdp_init(void)
  omap_hsmmc_init(mmc);
  
  omap_mux_init_signal(usb0hs_stp, OMAP_PULL_ENA | 
 OMAP_PULL_UP);
 -usb_bind_phy(musb-hdrc.0.auto, 0, twl4030_usb);
 +usb_bind_phy(musb-hdrc.0, 0, twl4030_usb);

 how about moving usb_bind_phy() calls to omap2430.c ?

 diff --git a/drivers/usb/musb/omap2430.c b/drivers/usb/musb/omap2430.c
 index f44e8b5..b6abc1a 100644
 --- a/drivers/usb/musb/omap2430.c
 +++ b/drivers/usb/musb/omap2430.c
 @@ -544,6 +544,9 @@ static int omap2430_probe(struct platform_device 
 *pdev)
  
   pdata-board_data   = data;
   pdata-config   = config;
 + } else {
 + /* bind the PHY */
 + usb_bind_phy(dev_name(musb-dev), 0, twl4030_usb);

 This looks like a hack IMHO to workaround the usb phy library. otherwise 
 it is
 similar to get_phy_by_name.

 actually, this is a workaround to the fact that we're not creating all
 platform_devices in arch/arm/mach-omap2/ :-)

 If we had the musb allocation there, we could easily handle
 usb_bind_phy()

 so that's temporary. It might be better than to reintroduce the IDR in
 musb_core.c.

 that’s needed for generic phy framework anyway :-s

 right, but generic phy framework can handle everything just fine, the
 only problem is that names are changing.

 right. But if the names change, PHY framework wouldn't be able to return the
 reference to the PHY.
 
 with my suggestion they can change whenever they want since we're using
 dev_name() of the just-created musb platform_device. Right ?

right. But the PHY device can be created in a different place from where the
musb devices are created. And in the PHY framework, the PHY device should have
the list of controller device (names) it can support (PHY framework does not
maintain a separate list for binding like how we had in USB PHY library). e.g.
http://www.mail-archive.com/linux-omap@vger.kernel.org/msg92817.html. In such
cases how do we pass the device names. Also will the MUSB core device be
created before twl4030-usb PHY device?

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


Re: [PATCH 2/2] arm: omap: remove *.auto* from device names given in usb_bind_phy

2013-07-30 Thread Kishon Vijay Abraham I
Hi,

On Tuesday 30 July 2013 11:48 AM, Felipe Balbi wrote:
 Hi,
 
 On Tue, Jul 30, 2013 at 11:41:23AM +0530, Kishon Vijay Abraham I wrote:
 diff --git a/arch/arm/mach-omap2/board-2430sdp.c 
 b/arch/arm/mach-omap2/board-2430sdp.c
 index 244d8a5..17bb076 100644
 --- a/arch/arm/mach-omap2/board-2430sdp.c
 +++ b/arch/arm/mach-omap2/board-2430sdp.c
 @@ -233,7 +233,7 @@ static void __init omap_2430sdp_init(void)
omap_hsmmc_init(mmc);
  
omap_mux_init_signal(usb0hs_stp, OMAP_PULL_ENA | 
 OMAP_PULL_UP);
 -  usb_bind_phy(musb-hdrc.0.auto, 0, twl4030_usb);
 +  usb_bind_phy(musb-hdrc.0, 0, twl4030_usb);

 how about moving usb_bind_phy() calls to omap2430.c ?

 diff --git a/drivers/usb/musb/omap2430.c b/drivers/usb/musb/omap2430.c
 index f44e8b5..b6abc1a 100644
 --- a/drivers/usb/musb/omap2430.c
 +++ b/drivers/usb/musb/omap2430.c
 @@ -544,6 +544,9 @@ static int omap2430_probe(struct platform_device 
 *pdev)
  
 pdata-board_data   = data;
 pdata-config   = config;
 +   } else {
 +   /* bind the PHY */
 +   usb_bind_phy(dev_name(musb-dev), 0, twl4030_usb);

 This looks like a hack IMHO to workaround the usb phy library. otherwise 
 it is
 similar to get_phy_by_name.

 actually, this is a workaround to the fact that we're not creating all
 platform_devices in arch/arm/mach-omap2/ :-)

 If we had the musb allocation there, we could easily handle
 usb_bind_phy()

 so that's temporary. It might be better than to reintroduce the IDR in
 musb_core.c.

 that’s needed for generic phy framework anyway :-s

 right, but generic phy framework can handle everything just fine, the
 only problem is that names are changing.

 right. But if the names change, PHY framework wouldn't be able to return 
 the
 reference to the PHY.

 with my suggestion they can change whenever they want since we're using
 dev_name() of the just-created musb platform_device. Right ?

 right. But the PHY device can be created in a different place from where the
 musb devices are created. And in the PHY framework, the PHY device should 
 have
 
 this shouldn't be a problem. As long as the phy is created, all should
 be good.
 
 the list of controller device (names) it can support (PHY framework does not
 maintain a separate list for binding like how we had in USB PHY library). 
 e.g.
 http://www.mail-archive.com/linux-omap@vger.kernel.org/msg92817.html. In such
 
 this has nothing to do with $subject though. We talk about generic PHY
 framework once all these PHY drivers are moved there :-)
 
 cases how do we pass the device names. Also will the MUSB core device be
 created before twl4030-usb PHY device?
 
 and why would that be a problem ? We're telling the framework that the
 musb device will use a phy with a name of 'twl4030'. If musb calls
 usb_get_phy_dev() and doesn't find a phy, it'll return -EPROBE_DEFER and
 try again later.

I think we are talking about different problems here ;-) I'm trying to tell
using idr in MUSB core is needed for Generic PHY Framework. So in a way, the
Generic PHY Framework series depends on this patch series or else MUSB in OMAP3
platforms wont work after Generic PHY framework gets merged.

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


Re: [PATCH 2/2] arm: omap: remove *.auto* from device names given in usb_bind_phy

2013-07-30 Thread Kishon Vijay Abraham I
Hi,

On Tuesday 30 July 2013 11:58 AM, Felipe Balbi wrote:
 Hi,
 
 On Tue, Jul 30, 2013 at 11:55:04AM +0530, Kishon Vijay Abraham I wrote:
 On Tue, Jul 30, 2013 at 11:41:23AM +0530, Kishon Vijay Abraham I wrote:
 diff --git a/arch/arm/mach-omap2/board-2430sdp.c 
 b/arch/arm/mach-omap2/board-2430sdp.c
 index 244d8a5..17bb076 100644
 --- a/arch/arm/mach-omap2/board-2430sdp.c
 +++ b/arch/arm/mach-omap2/board-2430sdp.c
 @@ -233,7 +233,7 @@ static void __init omap_2430sdp_init(void)
  omap_hsmmc_init(mmc);
  
  omap_mux_init_signal(usb0hs_stp, OMAP_PULL_ENA | 
 OMAP_PULL_UP);
 -usb_bind_phy(musb-hdrc.0.auto, 0, twl4030_usb);
 +usb_bind_phy(musb-hdrc.0, 0, twl4030_usb);

 how about moving usb_bind_phy() calls to omap2430.c ?

 diff --git a/drivers/usb/musb/omap2430.c b/drivers/usb/musb/omap2430.c
 index f44e8b5..b6abc1a 100644
 --- a/drivers/usb/musb/omap2430.c
 +++ b/drivers/usb/musb/omap2430.c
 @@ -544,6 +544,9 @@ static int omap2430_probe(struct platform_device 
 *pdev)
  
   pdata-board_data   = data;
   pdata-config   = config;
 + } else {
 + /* bind the PHY */
 + usb_bind_phy(dev_name(musb-dev), 0, twl4030_usb);

 This looks like a hack IMHO to workaround the usb phy library. 
 otherwise it is
 similar to get_phy_by_name.

 actually, this is a workaround to the fact that we're not creating all
 platform_devices in arch/arm/mach-omap2/ :-)

 If we had the musb allocation there, we could easily handle
 usb_bind_phy()

 so that's temporary. It might be better than to reintroduce the IDR in
 musb_core.c.

 that’s needed for generic phy framework anyway :-s

 right, but generic phy framework can handle everything just fine, the
 only problem is that names are changing.

 right. But if the names change, PHY framework wouldn't be able to return 
 the
 reference to the PHY.

 with my suggestion they can change whenever they want since we're using
 dev_name() of the just-created musb platform_device. Right ?

 right. But the PHY device can be created in a different place from where 
 the
 musb devices are created. And in the PHY framework, the PHY device should 
 have

 this shouldn't be a problem. As long as the phy is created, all should
 be good.

 the list of controller device (names) it can support (PHY framework does 
 not
 maintain a separate list for binding like how we had in USB PHY library). 
 e.g.
 http://www.mail-archive.com/linux-omap@vger.kernel.org/msg92817.html. In 
 such

 this has nothing to do with $subject though. We talk about generic PHY
 framework once all these PHY drivers are moved there :-)

 cases how do we pass the device names. Also will the MUSB core device be
 created before twl4030-usb PHY device?

 and why would that be a problem ? We're telling the framework that the
 musb device will use a phy with a name of 'twl4030'. If musb calls
 usb_get_phy_dev() and doesn't find a phy, it'll return -EPROBE_DEFER and
 try again later.

 I think we are talking about different problems here ;-) I'm trying to tell
 using idr in MUSB core is needed for Generic PHY Framework. So in a way, the
 Generic PHY Framework series depends on this patch series or else MUSB in 
 OMAP3
 platforms wont work after Generic PHY framework gets merged.
 
 then you just found a limitation in your framework, right ? :-) I mean,
 imagine if now we have to add an IDR to every single user of your
 framework because they could end up in systems with multiple instances
 of the same IP ?

I raised a similar concern in the PHY framework discussion [1] :-) And since
it's used everywhere else regulators, clkdev, etc.. it's agreed to be used in
PHY as well. Btw if PLATFORM_DEVID_AUTO is used even regulator, clk_get should
fail IMO.

[1] - http://lkml.indiana.edu/hypermail/linux/kernel/1307.2/03573.html

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


Re: [PATCH 2/2] arm: omap: remove *.auto* from device names given in usb_bind_phy

2013-07-30 Thread Kishon Vijay Abraham I
On Tuesday 30 July 2013 12:46 PM, Felipe Balbi wrote:
 Hi,
 
 On Tue, Jul 30, 2013 at 12:16:20PM +0530, Kishon Vijay Abraham I wrote:
 the list of controller device (names) it can support (PHY framework does 
 not
 maintain a separate list for binding like how we had in USB PHY 
 library). e.g.
 http://www.mail-archive.com/linux-omap@vger.kernel.org/msg92817.html. In 
 such

 this has nothing to do with $subject though. We talk about generic PHY
 framework once all these PHY drivers are moved there :-)

 cases how do we pass the device names. Also will the MUSB core device be
 created before twl4030-usb PHY device?

 and why would that be a problem ? We're telling the framework that the
 musb device will use a phy with a name of 'twl4030'. If musb calls
 usb_get_phy_dev() and doesn't find a phy, it'll return -EPROBE_DEFER and
 try again later.

 I think we are talking about different problems here ;-) I'm trying to tell
 using idr in MUSB core is needed for Generic PHY Framework. So in a way, 
 the
 Generic PHY Framework series depends on this patch series or else MUSB in 
 OMAP3
 platforms wont work after Generic PHY framework gets merged.

 then you just found a limitation in your framework, right ? :-) I mean,
 imagine if now we have to add an IDR to every single user of your
 framework because they could end up in systems with multiple instances
 of the same IP ?

 I raised a similar concern in the PHY framework discussion [1] :-) And since
 it's used everywhere else regulators, clkdev, etc.. it's agreed to be used in
 PHY as well. Btw if PLATFORM_DEVID_AUTO is used even regulator, clk_get 
 should
 fail IMO.

 [1] - http://lkml.indiana.edu/hypermail/linux/kernel/1307.2/03573.html
 
 look at Greg's and my reply to that email.

but finally Greg agreed to what Tomasz proposed no?

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


Re: [PATCH 01/15] drivers: phy: add generic PHY framework

2013-07-30 Thread Kishon Vijay Abraham I
Hi,

On Tuesday 30 July 2013 12:41 PM, Felipe Balbi wrote:
 On Sun, Jul 21, 2013 at 08:46:53AM -0700, Greg KH wrote:
 On Sun, Jul 21, 2013 at 01:12:07PM +0200, Tomasz Figa wrote:
 On Sunday 21 of July 2013 16:37:33 Kishon Vijay Abraham I wrote:
 Hi,

 On Sunday 21 July 2013 04:01 PM, Tomasz Figa wrote:
 Hi,

 On Saturday 20 of July 2013 19:59:10 Greg KH wrote:
 On Sat, Jul 20, 2013 at 10:32:26PM -0400, Alan Stern wrote:
 On Sat, 20 Jul 2013, Greg KH wrote:
 That should be passed using platform data.

 Ick, don't pass strings around, pass pointers.  If you have
 platform
 data you can get to, then put the pointer there, don't use a
 name.

 I don't think I understood you here :-s We wont have phy pointer
 when we create the device for the controller no?(it'll be done in
 board file). Probably I'm missing something.

 Why will you not have that pointer?  You can't rely on the name
 as
 the device id will not match up, so you should be able to rely on
 the pointer being in the structure that the board sets up, right?

 Don't use names, especially as ids can, and will, change, that is
 going
 to cause big problems.  Use pointers, this is C, we are supposed to
 be
 doing that :)

 Kishon, I think what Greg means is this:  The name you are using
 must
 be stored somewhere in a data structure constructed by the board
 file,
 right?  Or at least, associated with some data structure somehow.
 Otherwise the platform code wouldn't know which PHY hardware
 corresponded to a particular name.

 Greg's suggestion is that you store the address of that data
 structure
 in the platform data instead of storing the name string.  Have the
 consumer pass the data structure's address when it calls phy_create,
 instead of passing the name.  Then you don't have to worry about two
 PHYs accidentally ending up with the same name or any other similar
 problems.

 Close, but the issue is that whatever returns from phy_create()
 should
 then be used, no need to call any find functions, as you can just
 use
 the pointer that phy_create() returns.  Much like all other class api
 functions in the kernel work.

 I think there is a confusion here about who registers the PHYs.

 All platform code does is registering a platform/i2c/whatever device,
 which causes a driver (located in drivers/phy/) to be instantiated.
 Such drivers call phy_create(), usually in their probe() callbacks,
 so platform_code has no way (and should have no way, for the sake of
 layering) to get what phy_create() returns.

 Why not put pointers in the platform data structure that can hold these
 pointers?  I thought that is why we created those structures in the
 first place.  If not, what are they there for?
 
 heh, IMO we shouldn't pass pointers of any kind through platform_data,
 we want to pass data :-)
 
 Allowing to pass pointers through that, is one of the reasons which got
 us in such a big mess in ARM land, well it was much easier for a
 board-file/driver writer to pass a function pointer then to create a
 generic framework :-)
 
 IMHO we need a lookup method for PHYs, just like for clocks,
 regulators, PWMs or even i2c busses because there are complex cases
 when passing just a name using platform data will not work. I would
 second what Stephen said [1] and define a structure doing things in a
 DT-like way.

 Example;

 [platform code]

 static const struct phy_lookup my_phy_lookup[] = {

   PHY_LOOKUP(s3c-hsotg.0, otg, samsung-usbphy.1, phy.2),

 The only problem here is that if *PLATFORM_DEVID_AUTO* is used while
 creating the device, the ids in the device name would change and
 PHY_LOOKUP wont be useful.

 I don't think this is a problem. All the existing lookup methods already 
 use ID to identify devices (see regulators, clkdev, PWMs, i2c, ...). You 
 can simply add a requirement that the ID must be assigned manually, 
 without using PLATFORM_DEVID_AUTO to use PHY lookup.

 And I'm saying that this idea, of using a specific name and id, is
 frought with fragility and will break in the future in various ways when
 devices get added to systems, making these strings constantly have to be
 kept up to date with different board configurations.

 People, NEVER, hardcode something like an id.  The fact that this
 happens today with the clock code, doesn't make it right, it makes the
 clock code wrong.  Others have already said that this is wrong there as
 well, as systems change and dynamic ids get used more and more.

 Let's not repeat the same mistakes of the past just because we refuse to
 learn from them...

 So again, the find a phy by a string functions should be removed, the
 device id should be automatically created by the phy core just to make
 things unique in sysfs, and no driver code should _ever_ be reliant on
 the number that is being created, and the pointer to the phy structure
 should be used everywhere instead.

 With those types of changes, I will consider merging this subsystem, but
 without them, sorry, I will not.
 
 I'll agree with Greg

Re: [PATCH 2/2] arm: omap: remove *.auto* from device names given in usb_bind_phy

2013-07-29 Thread Kishon Vijay Abraham I
Hi,

On Monday 29 July 2013 08:36 PM, Felipe Balbi wrote:
 Hi,
 
 On Fri, Jul 26, 2013 at 02:33:38PM +0530, Kishon Vijay Abraham I wrote:
 Previously MUSB wrapper (OMAP) device used PLATFORM_DEVID_AUTO while creating
 MUSB core device. So in usb_bind_phy (binds the controller with the PHY), the
 device name of the controller had *.auto* in it. Since with using
 PLATFORM_DEVID_AUTO, there is no way to know the exact device name in 
 advance,
 the data given in usb_bind_phy became obsolete and usb_get_phy was failing.
 So MUSB wrapper was modified not to use PLATFORM_DEVID_AUTO. Corresponding
 change is done in board file here.

 Signed-off-by: Kishon Vijay Abraham I kis...@ti.com
 ---
  arch/arm/mach-omap2/board-2430sdp.c  |2 +-
  arch/arm/mach-omap2/board-3430sdp.c  |2 +-
  arch/arm/mach-omap2/board-cm-t35.c   |2 +-
  arch/arm/mach-omap2/board-devkit8000.c   |2 +-
  arch/arm/mach-omap2/board-igep0020.c |2 +-
  arch/arm/mach-omap2/board-ldp.c  |2 +-
  arch/arm/mach-omap2/board-omap3beagle.c  |2 +-
  arch/arm/mach-omap2/board-omap3evm.c |2 +-
  arch/arm/mach-omap2/board-omap3logic.c   |2 +-
  arch/arm/mach-omap2/board-omap3pandora.c |2 +-
  arch/arm/mach-omap2/board-omap3stalker.c |2 +-
  arch/arm/mach-omap2/board-omap3touchbook.c   |2 +-
  arch/arm/mach-omap2/board-overo.c|2 +-
  arch/arm/mach-omap2/board-rm680.c|2 +-
  arch/arm/mach-omap2/board-rx51.c |2 +-
  arch/arm/mach-omap2/board-zoom-peripherals.c |2 +-
  16 files changed, 16 insertions(+), 16 deletions(-)

 diff --git a/arch/arm/mach-omap2/board-2430sdp.c 
 b/arch/arm/mach-omap2/board-2430sdp.c
 index 244d8a5..17bb076 100644
 --- a/arch/arm/mach-omap2/board-2430sdp.c
 +++ b/arch/arm/mach-omap2/board-2430sdp.c
 @@ -233,7 +233,7 @@ static void __init omap_2430sdp_init(void)
  omap_hsmmc_init(mmc);
  
  omap_mux_init_signal(usb0hs_stp, OMAP_PULL_ENA | OMAP_PULL_UP);
 -usb_bind_phy(musb-hdrc.0.auto, 0, twl4030_usb);
 +usb_bind_phy(musb-hdrc.0, 0, twl4030_usb);
 
 how about moving usb_bind_phy() calls to omap2430.c ?
 
 diff --git a/drivers/usb/musb/omap2430.c b/drivers/usb/musb/omap2430.c
 index f44e8b5..b6abc1a 100644
 --- a/drivers/usb/musb/omap2430.c
 +++ b/drivers/usb/musb/omap2430.c
 @@ -544,6 +544,9 @@ static int omap2430_probe(struct platform_device *pdev)
  
   pdata-board_data   = data;
   pdata-config   = config;
 + } else {
 + /* bind the PHY */
 + usb_bind_phy(dev_name(musb-dev), 0, twl4030_usb);

This looks like a hack IMHO to workaround the usb phy library. otherwise it is
similar to get_phy_by_name.
   }
  
   if (pdata-has_mailbox) {
 
 The only problem is if some board comes with a PHY other than
 twl4030_usb, but in that case we can add a separate compatible flag and
 treat it properly. We only need to bind the phy in non-DT case anyway,

right.
 so that's temporary. It might be better than to reintroduce the IDR in
 musb_core.c.

that’s needed for generic phy framework anyway :-s

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


Re: [RESEND PATCH v10 1/8] drivers: phy: add generic PHY framework

2013-07-29 Thread Kishon Vijay Abraham I
On Monday 29 July 2013 08:58 PM, Kamil Debski wrote:
 Hi Kishon,
 
 A small fix follows inline.
 
 From: linux-media-ow...@vger.kernel.org [mailto:linux-media-
 ow...@vger.kernel.org] On Behalf Of Kishon Vijay Abraham I
 Sent: Friday, July 26, 2013 2:49 PM

 The PHY framework provides a set of APIs for the PHY drivers to
 create/destroy a PHY and APIs for the PHY users to obtain a reference
 to the PHY with or without using phandle. For dt-boot, the PHY drivers
 should also register *PHY provider* with the framework.

 PHY drivers should create the PHY by passing id and ops like init, exit,
 power_on and power_off. This framework is also pm runtime enabled.

 The documentation for the generic PHY framework is added in
 Documentation/phy.txt and the documentation for dt binding can be found
 at Documentation/devicetree/bindings/phy/phy-bindings.txt

 Cc: Tomasz Figa t.f...@samsung.com
 Cc: Greg Kroah-Hartman gre...@linuxfoundation.org
 Signed-off-by: Kishon Vijay Abraham I kis...@ti.com
 Acked-by: Felipe Balbi ba...@ti.com
 Tested-by: Sylwester Nawrocki s.nawro...@samsung.com
 ---
  .../devicetree/bindings/phy/phy-bindings.txt   |   66 ++
  Documentation/phy.txt  |  166 +
  MAINTAINERS|8 +
  drivers/Kconfig|2 +
  drivers/Makefile   |2 +
  drivers/phy/Kconfig|   18 +
  drivers/phy/Makefile   |5 +
  drivers/phy/phy-core.c |  714
 
  include/linux/phy/phy.h|  270 
  9 files changed, 1251 insertions(+)
  create mode 100644 Documentation/devicetree/bindings/phy/phy-
 bindings.txt
  create mode 100644 Documentation/phy.txt  create mode 100644
 drivers/phy/Kconfig  create mode 100644 drivers/phy/Makefile  create
 mode 100644 drivers/phy/phy-core.c  create mode 100644
 include/linux/phy/phy.h

 
 [snip]
 
 diff --git a/include/linux/phy/phy.h b/include/linux/phy/phy.h new file
 mode 100644 index 000..e444b23
 --- /dev/null
 +++ b/include/linux/phy/phy.h
 @@ -0,0 +1,270 @@
 
 [snip]
 
 +struct phy_init_data {
 +unsigned int num_consumers;
 +struct phy_consumer *consumers;
 +};
 +
 +#define PHY_CONSUMER(_dev_name, _port)  \
 +{   \
 +.dev_name   = _dev_name,\
 +.port   = _port,\
 +}
 +
 +#define to_phy(dev) (container_of((dev), struct phy, dev))
 +
 +#define of_phy_provider_register(dev, xlate)\
 +__of_phy_provider_register((dev), THIS_MODULE, (xlate))
 +
 +#define devm_of_phy_provider_register(dev, xlate)   \
 +__of_phy_provider_register((dev), THIS_MODULE, (xlate))
 
 I think this should be:
 + __devm_of_phy_provider_register((dev), THIS_MODULE, (xlate))
 Right?

right.. thanks for spotting this.

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


Re: [RESEND PATCH v10 1/8] drivers: phy: add generic PHY framework

2013-07-29 Thread Kishon Vijay Abraham I
Hi,

On Monday 29 July 2013 09:21 PM, Sylwester Nawrocki wrote:
 On 07/26/2013 02:49 PM, Kishon Vijay Abraham I wrote:
 The PHY framework provides a set of APIs for the PHY drivers to
 create/destroy a PHY and APIs for the PHY users to obtain a reference to the
 PHY with or without using phandle. For dt-boot, the PHY drivers should
 also register *PHY provider* with the framework.

 PHY drivers should create the PHY by passing id and ops like init, exit,
 power_on and power_off. This framework is also pm runtime enabled.

 The documentation for the generic PHY framework is added in
 Documentation/phy.txt and the documentation for dt binding can be found at
 Documentation/devicetree/bindings/phy/phy-bindings.txt

 Cc: Tomasz Figa t.f...@samsung.com
 Cc: Greg Kroah-Hartman gre...@linuxfoundation.org
 Signed-off-by: Kishon Vijay Abraham I kis...@ti.com
 Acked-by: Felipe Balbi ba...@ti.com
 Tested-by: Sylwester Nawrocki s.nawro...@samsung.com
 ---
  .../devicetree/bindings/phy/phy-bindings.txt   |   66 ++
  Documentation/phy.txt  |  166 +
  MAINTAINERS|8 +
  drivers/Kconfig|2 +
  drivers/Makefile   |2 +
  drivers/phy/Kconfig|   18 +
  drivers/phy/Makefile   |5 +
  drivers/phy/phy-core.c |  714 
 
  include/linux/phy/phy.h|  270 
  9 files changed, 1251 insertions(+)
  create mode 100644 Documentation/devicetree/bindings/phy/phy-bindings.txt
  create mode 100644 Documentation/phy.txt
  create mode 100644 drivers/phy/Kconfig
  create mode 100644 drivers/phy/Makefile
  create mode 100644 drivers/phy/phy-core.c
  create mode 100644 include/linux/phy/phy.h

 diff --git a/Documentation/devicetree/bindings/phy/phy-bindings.txt 
 b/Documentation/devicetree/bindings/phy/phy-bindings.txt
 new file mode 100644
 index 000..8ae844f
 --- /dev/null
 +++ b/Documentation/devicetree/bindings/phy/phy-bindings.txt
 @@ -0,0 +1,66 @@
 +This document explains only the device tree data binding. For general
 +information about PHY subsystem refer to Documentation/phy.txt
 [...]
 @@ -0,0 +1,166 @@
 +PHY SUBSYSTEM
 +  Kishon Vijay Abraham I kis...@ti.com
 +
 +This document explains the Generic PHY Framework along with the APIs 
 provided,
 +and how-to-use.
 +
 +1. Introduction
 +
 +*PHY* is the abbreviation for physical layer. It is used to connect a device
 +to the physical medium e.g., the USB controller has a PHY to provide 
 functions
 +such as serialization, de-serialization, encoding, decoding and is 
 responsible
 +for obtaining the required data transmission rate. Note that some USB
 +controllers have PHY functionality embedded into it and others use an 
 external
 +PHY. Other peripherals that use PHY include Wireless LAN, Ethernet,
 +SATA etc.
 +
 +The intention of creating this framework is to bring the PHY drivers spread
 +all over the Linux kernel to drivers/phy to increase code re-use and for
 +better code maintainability.
 +
 +This framework will be of use only to devices that use external PHY (PHY
 +functionality is not embedded within the controller).
 +
 +2. Registering/Unregistering the PHY provider
 +
 +PHY provider refers to an entity that implements one or more PHY instances.
 +For the simple case where the PHY provider implements only a single 
 instance of
 +the PHY, the framework provides its own implementation of of_xlate in
 +of_phy_simple_xlate. If the PHY provider implements multiple instances, it
 +should provide its own implementation of of_xlate. of_xlate is used only for
 +dt boot case.
 +
 +#define of_phy_provider_register(dev, xlate)\
 +__of_phy_provider_register((dev), THIS_MODULE, (xlate))
 +
 +#define devm_of_phy_provider_register(dev, xlate)   \
 +__of_phy_provider_register((dev), THIS_MODULE, (xlate))
 
 This needs to be:
 
   __devm_of_phy_provider_register((dev), THIS_MODULE, (xlate))
 
 as Kamil pointed out. We've tested it here with v9 and it makes
 Bad Things happen. ;)
 
 +of_phy_provider_register and devm_of_phy_provider_register macros can be 
 used to
 +register the phy_provider and it takes device and of_xlate as
 +arguments. For the dt boot case, all PHY providers should use one of the 
 above
 +2 macros to register the PHY provider.
 +
 +void devm_of_phy_provider_unregister(struct device *dev,
 +struct phy_provider *phy_provider);
 +void of_phy_provider_unregister(struct phy_provider *phy_provider);
 +
 +devm_of_phy_provider_unregister and of_phy_provider_unregister can be used 
 to
 +unregister the PHY.
 +
 [...]
 diff --git a/drivers/phy/phy-core.c b/drivers/phy/phy-core.c
 new file mode 100644
 index 000..f1d15e5
 --- /dev/null
 +++ b/drivers/phy/phy-core.c
 @@ -0,0 +1,714 @@
 [...]
 +static struct phy

Re: [PATCH 2/2] arm: omap: remove *.auto* from device names given in usb_bind_phy

2013-07-29 Thread Kishon Vijay Abraham I
Hi,

On Monday 29 July 2013 11:24 PM, Felipe Balbi wrote:
 Hi,
 
 On Mon, Jul 29, 2013 at 08:59:26PM +0530, Kishon Vijay Abraham I wrote:
 Previously MUSB wrapper (OMAP) device used PLATFORM_DEVID_AUTO while 
 creating
 MUSB core device. So in usb_bind_phy (binds the controller with the PHY), 
 the
 device name of the controller had *.auto* in it. Since with using
 PLATFORM_DEVID_AUTO, there is no way to know the exact device name in 
 advance,
 the data given in usb_bind_phy became obsolete and usb_get_phy was failing.
 So MUSB wrapper was modified not to use PLATFORM_DEVID_AUTO. Corresponding
 change is done in board file here.

 Signed-off-by: Kishon Vijay Abraham I kis...@ti.com
 ---
  arch/arm/mach-omap2/board-2430sdp.c  |2 +-
  arch/arm/mach-omap2/board-3430sdp.c  |2 +-
  arch/arm/mach-omap2/board-cm-t35.c   |2 +-
  arch/arm/mach-omap2/board-devkit8000.c   |2 +-
  arch/arm/mach-omap2/board-igep0020.c |2 +-
  arch/arm/mach-omap2/board-ldp.c  |2 +-
  arch/arm/mach-omap2/board-omap3beagle.c  |2 +-
  arch/arm/mach-omap2/board-omap3evm.c |2 +-
  arch/arm/mach-omap2/board-omap3logic.c   |2 +-
  arch/arm/mach-omap2/board-omap3pandora.c |2 +-
  arch/arm/mach-omap2/board-omap3stalker.c |2 +-
  arch/arm/mach-omap2/board-omap3touchbook.c   |2 +-
  arch/arm/mach-omap2/board-overo.c|2 +-
  arch/arm/mach-omap2/board-rm680.c|2 +-
  arch/arm/mach-omap2/board-rx51.c |2 +-
  arch/arm/mach-omap2/board-zoom-peripherals.c |2 +-
  16 files changed, 16 insertions(+), 16 deletions(-)

 diff --git a/arch/arm/mach-omap2/board-2430sdp.c 
 b/arch/arm/mach-omap2/board-2430sdp.c
 index 244d8a5..17bb076 100644
 --- a/arch/arm/mach-omap2/board-2430sdp.c
 +++ b/arch/arm/mach-omap2/board-2430sdp.c
 @@ -233,7 +233,7 @@ static void __init omap_2430sdp_init(void)
omap_hsmmc_init(mmc);
  
omap_mux_init_signal(usb0hs_stp, OMAP_PULL_ENA | OMAP_PULL_UP);
 -  usb_bind_phy(musb-hdrc.0.auto, 0, twl4030_usb);
 +  usb_bind_phy(musb-hdrc.0, 0, twl4030_usb);

 how about moving usb_bind_phy() calls to omap2430.c ?

 diff --git a/drivers/usb/musb/omap2430.c b/drivers/usb/musb/omap2430.c
 index f44e8b5..b6abc1a 100644
 --- a/drivers/usb/musb/omap2430.c
 +++ b/drivers/usb/musb/omap2430.c
 @@ -544,6 +544,9 @@ static int omap2430_probe(struct platform_device *pdev)
  
 pdata-board_data   = data;
 pdata-config   = config;
 +   } else {
 +   /* bind the PHY */
 +   usb_bind_phy(dev_name(musb-dev), 0, twl4030_usb);

 This looks like a hack IMHO to workaround the usb phy library. otherwise it 
 is
 similar to get_phy_by_name.
 
 actually, this is a workaround to the fact that we're not creating all
 platform_devices in arch/arm/mach-omap2/ :-)
 
 If we had the musb allocation there, we could easily handle
 usb_bind_phy()
 
 so that's temporary. It might be better than to reintroduce the IDR in
 musb_core.c.

 that’s needed for generic phy framework anyway :-s
 
 right, but generic phy framework can handle everything just fine, the
 only problem is that names are changing.

right. But if the names change, PHY framework wouldn't be able to return the
reference to the PHY.

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


[PATCH 0/2] usb: fix controller-PHY binding for OMAP3 platform

2013-07-26 Thread Kishon Vijay Abraham I
After the platform devices are created using PLATFORM_DEVID_AUTO, the
device names given in usb_bind_phy (in board file) does not match with
the actual device name causing the USB PHY library not to return the
PHY reference when the MUSB controller request for the PHY in the non-dt boot
case.
So removed creating platform devices using PLATFORM_DEVID_AUTO in omap2430.c.
This is also needed for the Generic PHY Framework [1] after it's redesigned
to address Greg's concerns [2]

*usb: musb: fix USB enumeration issue in OMAP3 platform* can be dropped since
this patch series should fix the same issue.

I've tested in beagle, but if any of you have any other OMAP3 boards, would be
great if you can test it too.

[1] - https://git.kernel.org/cgit/linux/kernel/git/kishon/linux-phy.git/
[2] - http://thread.gmane.org/gmane.linux.ports.arm.kernel/252813/focus=101661

Kishon Vijay Abraham I (2):
  usb: musb: omap: remove using PLATFORM_DEVID_AUTO in omap2430.c
  arm: omap: remove *.auto* from device names given in usb_bind_phy

 arch/arm/mach-omap2/board-2430sdp.c  |2 +-
 arch/arm/mach-omap2/board-3430sdp.c  |2 +-
 arch/arm/mach-omap2/board-cm-t35.c   |2 +-
 arch/arm/mach-omap2/board-devkit8000.c   |2 +-
 arch/arm/mach-omap2/board-igep0020.c |2 +-
 arch/arm/mach-omap2/board-ldp.c  |2 +-
 arch/arm/mach-omap2/board-omap3beagle.c  |2 +-
 arch/arm/mach-omap2/board-omap3evm.c |2 +-
 arch/arm/mach-omap2/board-omap3logic.c   |2 +-
 arch/arm/mach-omap2/board-omap3pandora.c |2 +-
 arch/arm/mach-omap2/board-omap3stalker.c |2 +-
 arch/arm/mach-omap2/board-omap3touchbook.c   |2 +-
 arch/arm/mach-omap2/board-overo.c|2 +-
 arch/arm/mach-omap2/board-rm680.c|2 +-
 arch/arm/mach-omap2/board-rx51.c |2 +-
 arch/arm/mach-omap2/board-zoom-peripherals.c |2 +-
 drivers/usb/musb/musb_core.c |   31 +-
 drivers/usb/musb/musb_core.h |2 ++
 drivers/usb/musb/omap2430.c  |   16 +++--
 19 files changed, 62 insertions(+), 19 deletions(-)

-- 
1.7.10.4

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


[PATCH 1/2] usb: musb: omap: remove using PLATFORM_DEVID_AUTO in omap2430.c

2013-07-26 Thread Kishon Vijay Abraham I
After the platform devices are created using PLATFORM_DEVID_AUTO, the
device names given in usb_bind_phy (in board file) does not match with
the actual device name causing the USB PHY library not to return the
PHY reference when the MUSB controller request for the PHY in the non-dt boot
case.
So removed creating platform devices using PLATFORM_DEVID_AUTO in omap2430.c.
This is also needed for the Generic PHY Framework.

Signed-off-by: Kishon Vijay Abraham I kis...@ti.com
---
 drivers/usb/musb/musb_core.c |   31 ++-
 drivers/usb/musb/musb_core.h |2 ++
 drivers/usb/musb/omap2430.c  |   16 ++--
 3 files changed, 46 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c
index 29a24ce..eb5d876 100644
--- a/drivers/usb/musb/musb_core.c
+++ b/drivers/usb/musb/musb_core.c
@@ -121,7 +121,7 @@ MODULE_DESCRIPTION(DRIVER_INFO);
 MODULE_AUTHOR(DRIVER_AUTHOR);
 MODULE_LICENSE(GPL);
 MODULE_ALIAS(platform: MUSB_DRIVER_NAME);
-
+static DEFINE_IDA(musb_ida);
 
 /*-*/
 
@@ -132,6 +132,35 @@ static inline struct musb *dev_to_musb(struct device *dev)
 
 /*-*/
 
+int musb_get_id(struct device *dev, gfp_t gfp_mask)
+{
+   int ret;
+   int id;
+
+   ret = ida_pre_get(musb_ida, gfp_mask);
+   if (!ret) {
+   dev_err(dev, failed to reserve resource for id\n);
+   return -ENOMEM;
+   }
+
+   ret = ida_get_new(musb_ida, id);
+   if (ret  0) {
+   dev_err(dev, failed to allocate a new id\n);
+   return ret;
+   }
+
+   return id;
+}
+EXPORT_SYMBOL_GPL(musb_get_id);
+
+void musb_put_id(struct device *dev, int id)
+{
+
+   dev_dbg(dev, removing id %d\n, id);
+   ida_remove(musb_ida, id);
+}
+EXPORT_SYMBOL_GPL(musb_put_id);
+
 #ifndef CONFIG_BLACKFIN
 static int musb_ulpi_read(struct usb_phy *phy, u32 offset)
 {
diff --git a/drivers/usb/musb/musb_core.h b/drivers/usb/musb/musb_core.h
index 7d341c3..79545a4 100644
--- a/drivers/usb/musb/musb_core.h
+++ b/drivers/usb/musb/musb_core.h
@@ -511,6 +511,8 @@ static inline void musb_configure_ep0(struct musb *musb)
 extern const char musb_driver_name[];
 
 extern void musb_stop(struct musb *musb);
+extern int musb_get_id(struct device *dev, gfp_t gfp_mask);
+extern void musb_put_id(struct device *dev, int id);
 
 extern void musb_write_fifo(struct musb_hw_ep *ep, u16 len, const u8 *src);
 extern void musb_read_fifo(struct musb_hw_ep *ep, u16 len, u8 *dst);
diff --git a/drivers/usb/musb/omap2430.c b/drivers/usb/musb/omap2430.c
index 6708a3b..812a7fc 100644
--- a/drivers/usb/musb/omap2430.c
+++ b/drivers/usb/musb/omap2430.c
@@ -489,6 +489,7 @@ static int omap2430_probe(struct platform_device *pdev)
struct device_node  *np = pdev-dev.of_node;
struct musb_hdrc_config *config;
int ret = -ENOMEM;
+   int musbid;
 
glue = devm_kzalloc(pdev-dev, sizeof(*glue), GFP_KERNEL);
if (!glue) {
@@ -496,10 +497,18 @@ static int omap2430_probe(struct platform_device *pdev)
goto err0;
}
 
-   musb = platform_device_alloc(musb-hdrc, PLATFORM_DEVID_AUTO);
+   /* get the musb id */
+   musbid = musb_get_id(pdev-dev, GFP_KERNEL);
+   if (musbid  0) {
+   dev_err(pdev-dev, failed to allocate musb id\n);
+   ret = -ENOMEM;
+   goto err0;
+   }
+
+   musb = platform_device_alloc(musb-hdrc, musbid);
if (!musb) {
dev_err(pdev-dev, failed to allocate musb device\n);
-   goto err0;
+   goto err1;
}
 
musb-dev.parent= pdev-dev;
@@ -607,6 +616,9 @@ static int omap2430_probe(struct platform_device *pdev)
 err2:
platform_device_put(musb);
 
+err1:
+   musb_put_id(pdev-dev, musbid);
+
 err0:
return ret;
 }
-- 
1.7.10.4

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


[PATCH 2/2] arm: omap: remove *.auto* from device names given in usb_bind_phy

2013-07-26 Thread Kishon Vijay Abraham I
Previously MUSB wrapper (OMAP) device used PLATFORM_DEVID_AUTO while creating
MUSB core device. So in usb_bind_phy (binds the controller with the PHY), the
device name of the controller had *.auto* in it. Since with using
PLATFORM_DEVID_AUTO, there is no way to know the exact device name in advance,
the data given in usb_bind_phy became obsolete and usb_get_phy was failing.
So MUSB wrapper was modified not to use PLATFORM_DEVID_AUTO. Corresponding
change is done in board file here.

Signed-off-by: Kishon Vijay Abraham I kis...@ti.com
---
 arch/arm/mach-omap2/board-2430sdp.c  |2 +-
 arch/arm/mach-omap2/board-3430sdp.c  |2 +-
 arch/arm/mach-omap2/board-cm-t35.c   |2 +-
 arch/arm/mach-omap2/board-devkit8000.c   |2 +-
 arch/arm/mach-omap2/board-igep0020.c |2 +-
 arch/arm/mach-omap2/board-ldp.c  |2 +-
 arch/arm/mach-omap2/board-omap3beagle.c  |2 +-
 arch/arm/mach-omap2/board-omap3evm.c |2 +-
 arch/arm/mach-omap2/board-omap3logic.c   |2 +-
 arch/arm/mach-omap2/board-omap3pandora.c |2 +-
 arch/arm/mach-omap2/board-omap3stalker.c |2 +-
 arch/arm/mach-omap2/board-omap3touchbook.c   |2 +-
 arch/arm/mach-omap2/board-overo.c|2 +-
 arch/arm/mach-omap2/board-rm680.c|2 +-
 arch/arm/mach-omap2/board-rx51.c |2 +-
 arch/arm/mach-omap2/board-zoom-peripherals.c |2 +-
 16 files changed, 16 insertions(+), 16 deletions(-)

diff --git a/arch/arm/mach-omap2/board-2430sdp.c 
b/arch/arm/mach-omap2/board-2430sdp.c
index 244d8a5..17bb076 100644
--- a/arch/arm/mach-omap2/board-2430sdp.c
+++ b/arch/arm/mach-omap2/board-2430sdp.c
@@ -233,7 +233,7 @@ static void __init omap_2430sdp_init(void)
omap_hsmmc_init(mmc);
 
omap_mux_init_signal(usb0hs_stp, OMAP_PULL_ENA | OMAP_PULL_UP);
-   usb_bind_phy(musb-hdrc.0.auto, 0, twl4030_usb);
+   usb_bind_phy(musb-hdrc.0, 0, twl4030_usb);
usb_musb_init(NULL);
 
board_smc91x_init();
diff --git a/arch/arm/mach-omap2/board-3430sdp.c 
b/arch/arm/mach-omap2/board-3430sdp.c
index 23b004a..5f43fc4 100644
--- a/arch/arm/mach-omap2/board-3430sdp.c
+++ b/arch/arm/mach-omap2/board-3430sdp.c
@@ -590,7 +590,7 @@ static void __init omap_3430sdp_init(void)
omap_ads7846_init(1, gpio_pendown, 310, NULL);
omap_serial_init();
omap_sdrc_init(hyb18m512160af6_sdrc_params, NULL);
-   usb_bind_phy(musb-hdrc.0.auto, 0, twl4030_usb);
+   usb_bind_phy(musb-hdrc.0, 0, twl4030_usb);
usb_musb_init(NULL);
board_smc91x_init();
board_flash_init(sdp_flash_partitions, chip_sel_3430, 0);
diff --git a/arch/arm/mach-omap2/board-cm-t35.c 
b/arch/arm/mach-omap2/board-cm-t35.c
index d4622ed..1c3345d 100644
--- a/arch/arm/mach-omap2/board-cm-t35.c
+++ b/arch/arm/mach-omap2/board-cm-t35.c
@@ -691,7 +691,7 @@ static void __init cm_t3x_common_init(void)
cm_t35_init_display();
omap_twl4030_audio_init(cm-t3x, NULL);
 
-   usb_bind_phy(musb-hdrc.0.auto, 0, twl4030_usb);
+   usb_bind_phy(musb-hdrc.0, 0, twl4030_usb);
usb_musb_init(NULL);
cm_t35_init_usbh();
cm_t35_init_camera();
diff --git a/arch/arm/mach-omap2/board-devkit8000.c 
b/arch/arm/mach-omap2/board-devkit8000.c
index f1d91ba..b4d57ec 100644
--- a/arch/arm/mach-omap2/board-devkit8000.c
+++ b/arch/arm/mach-omap2/board-devkit8000.c
@@ -594,7 +594,7 @@ static void __init devkit8000_init(void)
 
omap_ads7846_init(2, OMAP3_DEVKIT_TS_GPIO, 0, NULL);
 
-   usb_bind_phy(musb-hdrc.0.auto, 0, twl4030_usb);
+   usb_bind_phy(musb-hdrc.0, 0, twl4030_usb);
usb_musb_init(NULL);
usbhs_init(usbhs_bdata);
board_nand_init(devkit8000_nand_partitions,
diff --git a/arch/arm/mach-omap2/board-igep0020.c 
b/arch/arm/mach-omap2/board-igep0020.c
index 87e65dd..b1cbbba 100644
--- a/arch/arm/mach-omap2/board-igep0020.c
+++ b/arch/arm/mach-omap2/board-igep0020.c
@@ -659,7 +659,7 @@ static void __init igep_init(void)
omap_serial_init();
omap_sdrc_init(m65kam_sdrc_params,
  m65kam_sdrc_params);
-   usb_bind_phy(musb-hdrc.0.auto, 0, twl4030_usb);
+   usb_bind_phy(musb-hdrc.0, 0, twl4030_usb);
usb_musb_init(NULL);
 
igep_flash_init();
diff --git a/arch/arm/mach-omap2/board-ldp.c b/arch/arm/mach-omap2/board-ldp.c
index 62e4f70..02d7505 100644
--- a/arch/arm/mach-omap2/board-ldp.c
+++ b/arch/arm/mach-omap2/board-ldp.c
@@ -377,7 +377,7 @@ static void __init omap_ldp_init(void)
omap_ads7846_init(1, 54, 310, NULL);
omap_serial_init();
omap_sdrc_init(NULL, NULL);
-   usb_bind_phy(musb-hdrc.0.auto, 0, twl4030_usb);
+   usb_bind_phy(musb-hdrc.0, 0, twl4030_usb);
usb_musb_init(NULL);
board_nand_init(ldp_nand_partitions, ARRAY_SIZE(ldp_nand_partitions),
ZOOM_NAND_CS, 0, nand_default_timings);
diff --git a/arch/arm/mach-omap2/board

[PATCH v10 5/8] ARM: dts: omap: update usb_otg_hs data

2013-07-26 Thread Kishon Vijay Abraham I
Updated the usb_otg_hs dt data to include the *phy* and *phy-names*
binding in order for the driver to use the new generic PHY framework.
Also updated the Documentation to include the binding information.
The PHY binding information can be found at
Documentation/devicetree/bindings/phy/phy-bindings.txt

Signed-off-by: Kishon Vijay Abraham I kis...@ti.com
Acked-by: Felipe Balbi ba...@ti.com
Reviewed-by: Sylwester Nawrocki s.nawro...@samsung.com
---
 Documentation/devicetree/bindings/usb/omap-usb.txt |5 +
 Documentation/devicetree/bindings/usb/usb-phy.txt  |6 ++
 arch/arm/boot/dts/omap3-beagle-xm.dts  |2 ++
 arch/arm/boot/dts/omap3-evm.dts|2 ++
 arch/arm/boot/dts/omap3-overo.dtsi |2 ++
 arch/arm/boot/dts/omap4.dtsi   |3 +++
 arch/arm/boot/dts/twl4030.dtsi |1 +
 7 files changed, 21 insertions(+)

diff --git a/Documentation/devicetree/bindings/usb/omap-usb.txt 
b/Documentation/devicetree/bindings/usb/omap-usb.txt
index 57e71f6..825790d 100644
--- a/Documentation/devicetree/bindings/usb/omap-usb.txt
+++ b/Documentation/devicetree/bindings/usb/omap-usb.txt
@@ -19,6 +19,9 @@ OMAP MUSB GLUE
  - power : Should be 50. This signifies the controller can supply up to
100mA when operating in host mode.
  - usb-phy : the phandle for the PHY device
+ - phys : the phandle for the PHY device (used by generic PHY framework)
+ - phy-names : the names of the PHY corresponding to the PHYs present in the
+   *phy* phandle.
 
 Optional properties:
  - ctrl-module : phandle of the control module this glue uses to write to
@@ -33,6 +36,8 @@ usb_otg_hs: usb_otg_hs@4a0ab000 {
num-eps = 16;
ram-bits = 12;
ctrl-module = omap_control_usb;
+   phys = usb2_phy;
+   phy-names = usb2-phy;
 };
 
 Board specific device node entry
diff --git a/Documentation/devicetree/bindings/usb/usb-phy.txt 
b/Documentation/devicetree/bindings/usb/usb-phy.txt
index 61496f5..c0245c8 100644
--- a/Documentation/devicetree/bindings/usb/usb-phy.txt
+++ b/Documentation/devicetree/bindings/usb/usb-phy.txt
@@ -5,6 +5,8 @@ OMAP USB2 PHY
 Required properties:
  - compatible: Should be ti,omap-usb2
  - reg : Address and length of the register set for the device.
+ - #phy-cells: determine the number of cells that should be given in the
+   phandle while referencing this phy.
 
 Optional properties:
  - ctrl-module : phandle of the control module used by PHY driver to power on
@@ -16,6 +18,7 @@ usb2phy@4a0ad080 {
compatible = ti,omap-usb2;
reg = 0x4a0ad080 0x58;
ctrl-module = omap_control_usb;
+   #phy-cells = 0;
 };
 
 OMAP USB3 PHY
@@ -25,6 +28,8 @@ Required properties:
  - reg : Address and length of the register set for the device.
  - reg-names: The names of the register addresses corresponding to the 
registers
filled in reg.
+ - #phy-cells: determine the number of cells that should be given in the
+   phandle while referencing this phy.
 
 Optional properties:
  - ctrl-module : phandle of the control module used by PHY driver to power on
@@ -39,4 +44,5 @@ usb3phy@4a084400 {
  0x4a084c00 0x40;
reg-names = phy_rx, phy_tx, pll_ctrl;
ctrl-module = omap_control_usb;
+   #phy-cells = 0;
 };
diff --git a/arch/arm/boot/dts/omap3-beagle-xm.dts 
b/arch/arm/boot/dts/omap3-beagle-xm.dts
index afdb164..533b2da 100644
--- a/arch/arm/boot/dts/omap3-beagle-xm.dts
+++ b/arch/arm/boot/dts/omap3-beagle-xm.dts
@@ -144,6 +144,8 @@
 usb_otg_hs {
interface-type = 0;
usb-phy = usb2_phy;
+   phys = usb2_phy;
+   phy-names = usb2-phy;
mode = 3;
power = 50;
 };
diff --git a/arch/arm/boot/dts/omap3-evm.dts b/arch/arm/boot/dts/omap3-evm.dts
index 7d4329d..4134dd0 100644
--- a/arch/arm/boot/dts/omap3-evm.dts
+++ b/arch/arm/boot/dts/omap3-evm.dts
@@ -70,6 +70,8 @@
 usb_otg_hs {
interface-type = 0;
usb-phy = usb2_phy;
+   phys = usb2_phy;
+   phy-names = usb2-phy;
mode = 3;
power = 50;
 };
diff --git a/arch/arm/boot/dts/omap3-overo.dtsi 
b/arch/arm/boot/dts/omap3-overo.dtsi
index 8f1abec..a461d2f 100644
--- a/arch/arm/boot/dts/omap3-overo.dtsi
+++ b/arch/arm/boot/dts/omap3-overo.dtsi
@@ -76,6 +76,8 @@
 usb_otg_hs {
interface-type = 0;
usb-phy = usb2_phy;
+   phys = usb2_phy;
+   phy-names = usb2-phy;
mode = 3;
power = 50;
 };
diff --git a/arch/arm/boot/dts/omap4.dtsi b/arch/arm/boot/dts/omap4.dtsi
index 22d9f2b..1e8e2fe 100644
--- a/arch/arm/boot/dts/omap4.dtsi
+++ b/arch/arm/boot/dts/omap4.dtsi
@@ -520,6 +520,7 @@
compatible = ti,omap-usb2;
reg = 0x4a0ad080 0x58;
ctrl-module = omap_control_usb;
+   #phy-cells = 0;
};
};
 
@@ -658,6 +659,8 @@
interrupt-names = mc, dma

[PATCH v10 0/8] PHY framework

2013-07-26 Thread Kishon Vijay Abraham I
Added a generic PHY framework that provides a set of APIs for the PHY drivers
to create/destroy a PHY and APIs for the PHY users to obtain a reference to
the PHY with or without using phandle.

This framework will be of use only to devices that uses external PHY (PHY
functionality is not embedded within the controller).

The intention of creating this framework is to bring the phy drivers spread
all over the Linux kernel to drivers/phy to increase code re-use and to
increase code maintainability.

Comments to make PHY as bus wasn't done because PHY devices can be part of
other bus and making a same device attached to multiple bus leads to bad
design.

If the PHY driver has to send notification on connect/disconnect, the PHY
driver should make use of the extcon framework. Using this susbsystem
to use extcon framwork will have to be analysed.

You can find this patch series @
git://git.kernel.org/pub/scm/linux/kernel/git/kishon/linux-phy.git testing

I'll create a new branch *next* once this patch series is finalized. All the
PHY driver development that depends on PHY framework can be based on this
branch.

Did USB enumeration testing in panda and beagle after applying [1]

[1] - https://lkml.org/lkml/2013/7/26/88

Changes from v9:
* Fixed Greg's concern on having *find PHY by string* and changed it to Tomasz
  pseudo code.
* move omap-usb2 phy and twl4030-usb phy to drivers/phy
* made all the dependent drivers select GENERIC_PHY instead of having depends
  on
* Made PHY core to assign the id's (so changed the phy_create API).
* Adapted twl4030-usb to the new design.

Changes from v8:
* Added phy_set_drvdata and phy_get_drvdata in phy.h.
* Changed phy_create API not to take void *priv. private data should now be set
  using phy_set_drvdata now.
Changes from v7:
* Fixed Documentation
* Added to_phy, of_phy_provider_register and devm_of_phy_provider_register
* modified runtime_pm usage in phy_init, phy_exit, phy_power_on and
  phy_power_off. Now phy_power_on will enable the clocks and phy_power_off will
  disable the clocks.
* pm_runtime_no_callbacks() is added so that pm_runtime_get_sync doesn't fail
* modified other patches to adhere to the changes in the PHY framework
* removed usb: phy: twl4030: twl4030 shouldn't be subsys_initcall as it will
  be merged separately.
* reference counting has been added to protect phy ops when the PHY is shared
  by multiple consumers.

Changes from v6
* corrected few typos in Documentation
* Changed PHY Subsystem to *bool* in Kconfig (to avoid compilation errors when
  PHY Subsystem is kept as module and the dependent modules are built-in)
* Added if pm_runtime_enabled check before runtime pm calls.

Changes from v5:
* removed the new sysfs entries as it dint have any new information other than
  what is already there in /sys/devices/...
* removed a bunch of APIs added to get the PHY and now only phy_get and
  devm_phy_get are used.
* Added new APIs to register/unregister the PHY provider. This is needed for
  dt boot case.
* Enabled pm runtime and incorporated the comments given by Alan Stern in a
  different patch series by Gautam.
* Removed the *phy_bind* API. Now the phy binding information should be passed
  using the platform data to the controller devices.
* Fixed a few typos.

Changes from v4:
* removed of_phy_get_with_args/devm_of_phy_get_with_args. Now the *phy 
providers*
  should use their custom implementation of of_xlate or use of_phy_xlate to get
  *phy instance* from *phy providers*.
* Added of_phy_xlate to be used by *phy providers* if it provides only one PHY.
* changed phy_core from having subsys_initcall to module_init.
* other minor fixes.

Changes from v3:
* Changed the return value of PHY APIs to ENOSYS
* Added APIs of_phy_get_with_args/devm_of_phy_get_with_args to support getting
  PHYs if the same IP implements multiple PHYs.
* modified phy_bind API so that the binding information can now be _updated_.
  In effect of this removed the binding information added in board files and
  added only in usb-musb.c. If a particular board uses a different phy binding,
  it can update it in board file after usb_musb_init().
* Added Documentation/devicetree/bindings/phy/phy-bindings.txt for dt binding
  information.

Changes from v2:
* removed phy_descriptor structure completely so changed the APIs which were
  taking phy_descriptor as parameters
* Added 2 more APIs *of_phy_get_byname* and *devm_of_phy_get_byname* to be used
  by PHY user drivers which has *phy* and *phy-names* binding in the dt data
* Fixed a few typos
* Removed phy_list and we now use class_dev_iter_init, class_dev_iter_next and
  class_dev_iter_exit for traversing through the phy list. (Note we still need
  phy_bind list and phy_bind_mutex).
* Changed the sysfs entry name from *bind* to *phy_bind*.

Changes from v1:
* Added Documentation for the PHY framework
* Added few more APIs mostly w.r.t devres
* Modified omap-usb2 and twl4030 to make use of the new framework

Kishon Vijay Abraham I (8

[PATCH v10 7/8] usb: phy: omap-usb2: remove *set_suspend* callback from omap-usb2

2013-07-26 Thread Kishon Vijay Abraham I
Now that omap-usb2 is adapted to the new generic PHY framework,
*set_suspend* ops can be removed from omap-usb2 driver.

Signed-off-by: Kishon Vijay Abraham I kis...@ti.com
Acked-by: Felipe Balbi ba...@ti.com
Reviewed-by: Sylwester Nawrocki s.nawro...@samsung.com
---
 drivers/phy/phy-omap-usb2.c |   25 -
 1 file changed, 25 deletions(-)

diff --git a/drivers/phy/phy-omap-usb2.c b/drivers/phy/phy-omap-usb2.c
index 25e0f3c..dec3fab 100644
--- a/drivers/phy/phy-omap-usb2.c
+++ b/drivers/phy/phy-omap-usb2.c
@@ -97,29 +97,6 @@ static int omap_usb_set_peripheral(struct usb_otg *otg,
return 0;
 }
 
-static int omap_usb2_suspend(struct usb_phy *x, int suspend)
-{
-   u32 ret;
-   struct omap_usb *phy = phy_to_omapusb(x);
-
-   if (suspend  !phy-is_suspended) {
-   omap_control_usb_phy_power(phy-control_dev, 0);
-   pm_runtime_put_sync(phy-dev);
-   phy-is_suspended = 1;
-   } else if (!suspend  phy-is_suspended) {
-   ret = pm_runtime_get_sync(phy-dev);
-   if (ret  0) {
-   dev_err(phy-dev, get_sync failed with err %d\n,
-   ret);
-   return ret;
-   }
-   omap_control_usb_phy_power(phy-control_dev, 1);
-   phy-is_suspended = 0;
-   }
-
-   return 0;
-}
-
 static int omap_usb_power_off(struct phy *x)
 {
struct omap_usb *phy = phy_get_drvdata(x);
@@ -167,7 +144,6 @@ static int omap_usb2_probe(struct platform_device *pdev)
 
phy-phy.dev= phy-dev;
phy-phy.label  = omap-usb2;
-   phy-phy.set_suspend= omap_usb2_suspend;
phy-phy.otg= otg;
phy-phy.type   = USB_PHY_TYPE_USB2;
 
@@ -182,7 +158,6 @@ static int omap_usb2_probe(struct platform_device *pdev)
return -ENODEV;
}
 
-   phy-is_suspended   = 1;
omap_control_usb_phy_power(phy-control_dev, 0);
 
otg-set_host   = omap_usb_set_host;
-- 
1.7.10.4

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


[PATCH v10 8/8] usb: phy: twl4030-usb: remove *set_suspend* and *phy_init* ops

2013-07-26 Thread Kishon Vijay Abraham I
Now that twl4030-usb is adapted to the new generic PHY framework,
*set_suspend* and *phy_init* ops can be removed from twl4030-usb driver.

Signed-off-by: Kishon Vijay Abraham I kis...@ti.com
Acked-by: Felipe Balbi ba...@ti.com
Reviewed-by: Sylwester Nawrocki s.nawro...@samsung.com
---
 drivers/phy/phy-twl4030-usb.c |   57 ++---
 1 file changed, 13 insertions(+), 44 deletions(-)

diff --git a/drivers/phy/phy-twl4030-usb.c b/drivers/phy/phy-twl4030-usb.c
index 494f107..c437211 100644
--- a/drivers/phy/phy-twl4030-usb.c
+++ b/drivers/phy/phy-twl4030-usb.c
@@ -422,25 +422,20 @@ static void twl4030_phy_power(struct twl4030_usb *twl, 
int on)
}
 }
 
-static void twl4030_phy_suspend(struct twl4030_usb *twl, int controller_off)
+static int twl4030_phy_power_off(struct phy *phy)
 {
+   struct twl4030_usb *twl = phy_get_drvdata(phy);
+
if (twl-asleep)
-   return;
+   return 0;
 
twl4030_phy_power(twl, 0);
twl-asleep = 1;
dev_dbg(twl-dev, %s\n, __func__);
-}
-
-static int twl4030_phy_power_off(struct phy *phy)
-{
-   struct twl4030_usb *twl = phy_get_drvdata(phy);
-
-   twl4030_phy_suspend(twl, 0);
return 0;
 }
 
-static void __twl4030_phy_resume(struct twl4030_usb *twl)
+static void __twl4030_phy_power_on(struct twl4030_usb *twl)
 {
twl4030_phy_power(twl, 1);
twl4030_i2c_access(twl, 1);
@@ -449,11 +444,13 @@ static void __twl4030_phy_resume(struct twl4030_usb *twl)
twl4030_i2c_access(twl, 0);
 }
 
-static void twl4030_phy_resume(struct twl4030_usb *twl)
+static int twl4030_phy_power_on(struct phy *phy)
 {
+   struct twl4030_usb *twl = phy_get_drvdata(phy);
+
if (!twl-asleep)
-   return;
-   __twl4030_phy_resume(twl);
+   return 0;
+   __twl4030_phy_power_on(twl);
twl-asleep = 0;
dev_dbg(twl-dev, %s\n, __func__);
 
@@ -466,13 +463,6 @@ static void twl4030_phy_resume(struct twl4030_usb *twl)
cancel_delayed_work(twl-id_workaround_work);
schedule_delayed_work(twl-id_workaround_work, HZ);
}
-}
-
-static int twl4030_phy_power_on(struct phy *phy)
-{
-   struct twl4030_usb *twl = phy_get_drvdata(phy);
-
-   twl4030_phy_resume(twl);
return 0;
 }
 
@@ -604,9 +594,9 @@ static void twl4030_id_workaround_work(struct work_struct 
*work)
}
 }
 
-static int twl4030_usb_phy_init(struct usb_phy *phy)
+static int twl4030_phy_init(struct phy *phy)
 {
-   struct twl4030_usb *twl = phy_to_twl(phy);
+   struct twl4030_usb *twl = phy_get_drvdata(phy);
enum omap_musb_vbus_id_status status;
 
/*
@@ -621,32 +611,13 @@ static int twl4030_usb_phy_init(struct usb_phy *phy)
 
if (status == OMAP_MUSB_ID_GROUND || status == OMAP_MUSB_VBUS_VALID) {
omap_musb_mailbox(twl-linkstat);
-   twl4030_phy_resume(twl);
+   twl4030_phy_power_on(phy);
}
 
sysfs_notify(twl-dev-kobj, NULL, vbus);
return 0;
 }
 
-static int twl4030_phy_init(struct phy *phy)
-{
-   struct twl4030_usb *twl = phy_get_drvdata(phy);
-
-   return twl4030_usb_phy_init(twl-phy);
-}
-
-static int twl4030_set_suspend(struct usb_phy *x, int suspend)
-{
-   struct twl4030_usb *twl = phy_to_twl(x);
-
-   if (suspend)
-   twl4030_phy_suspend(twl, 1);
-   else
-   twl4030_phy_resume(twl);
-
-   return 0;
-}
-
 static int twl4030_set_peripheral(struct usb_otg *otg,
struct usb_gadget *gadget)
 {
@@ -719,8 +690,6 @@ static int twl4030_usb_probe(struct platform_device *pdev)
twl-phy.label  = twl4030;
twl-phy.otg= otg;
twl-phy.type   = USB_PHY_TYPE_USB2;
-   twl-phy.set_suspend= twl4030_set_suspend;
-   twl-phy.init   = twl4030_usb_phy_init;
 
otg-phy= twl-phy;
otg-set_host   = twl4030_set_host;
-- 
1.7.10.4

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


[PATCH v10 6/8] usb: musb: omap2430: use the new generic PHY framework

2013-07-26 Thread Kishon Vijay Abraham I
Use the generic PHY framework API to get the PHY. The usb_phy_set_resume
and usb_phy_set_suspend is replaced with power_on and
power_off to align with the new PHY framework.

musb-xceiv can't be removed as of now because musb core uses xceiv.state and
xceiv.otg. Once there is a separate state machine to handle otg, these can be
moved out of xceiv and then we can start using the generic PHY framework.

Signed-off-by: Kishon Vijay Abraham I kis...@ti.com
Reviewed-by: Sylwester Nawrocki s.nawro...@samsung.com
Acked-by: Felipe Balbi ba...@ti.com
---
 drivers/usb/musb/Kconfig |1 +
 drivers/usb/musb/musb_core.h |2 ++
 drivers/usb/musb/omap2430.c  |   26 --
 3 files changed, 23 insertions(+), 6 deletions(-)

diff --git a/drivers/usb/musb/Kconfig b/drivers/usb/musb/Kconfig
index 797e3fd..25e2e57 100644
--- a/drivers/usb/musb/Kconfig
+++ b/drivers/usb/musb/Kconfig
@@ -76,6 +76,7 @@ config USB_MUSB_TUSB6010
 config USB_MUSB_OMAP2PLUS
tristate OMAP2430 and onwards
depends on ARCH_OMAP2PLUS
+   select GENERIC_PHY
 
 config USB_MUSB_AM35X
tristate AM35x
diff --git a/drivers/usb/musb/musb_core.h b/drivers/usb/musb/musb_core.h
index 7d341c3..6e567bd 100644
--- a/drivers/usb/musb/musb_core.h
+++ b/drivers/usb/musb/musb_core.h
@@ -46,6 +46,7 @@
 #include linux/usb.h
 #include linux/usb/otg.h
 #include linux/usb/musb.h
+#include linux/phy/phy.h
 
 struct musb;
 struct musb_hw_ep;
@@ -346,6 +347,7 @@ struct musb {
u16 int_tx;
 
struct usb_phy  *xceiv;
+   struct phy  *phy;
 
int nIrq;
unsignedirq_wake:1;
diff --git a/drivers/usb/musb/omap2430.c b/drivers/usb/musb/omap2430.c
index 6708a3b..f7b33f4 100644
--- a/drivers/usb/musb/omap2430.c
+++ b/drivers/usb/musb/omap2430.c
@@ -348,11 +348,21 @@ static int omap2430_musb_init(struct musb *musb)
 * up through ULPI.  TWL4030-family PMICs include one,
 * which needs a driver, drivers aren't always needed.
 */
-   if (dev-parent-of_node)
+   if (dev-parent-of_node) {
+   musb-phy = devm_phy_get(dev-parent, usb2-phy);
+
+   /* We can't totally remove musb-xceiv as of now because
+* musb core uses xceiv.state and xceiv.otg. Once we have
+* a separate state machine to handle otg, these can be moved
+* out of xceiv and then we can start using the generic PHY
+* framework
+*/
musb-xceiv = devm_usb_get_phy_by_phandle(dev-parent,
usb-phy, 0);
-   else
+   } else {
musb-xceiv = devm_usb_get_phy_dev(dev, 0);
+   musb-phy = devm_phy_get(dev, usb);
+   }
 
if (IS_ERR(musb-xceiv)) {
status = PTR_ERR(musb-xceiv);
@@ -364,6 +374,10 @@ static int omap2430_musb_init(struct musb *musb)
return -EPROBE_DEFER;
}
 
+   if (IS_ERR(musb-phy)) {
+   pr_err(HS USB OTG: no PHY configured\n);
+   return PTR_ERR(musb-phy);
+   }
musb-isr = omap2430_musb_interrupt;
 
status = pm_runtime_get_sync(dev);
@@ -397,7 +411,7 @@ static int omap2430_musb_init(struct musb *musb)
if (glue-status != OMAP_MUSB_UNKNOWN)
omap_musb_set_mailbox(glue);
 
-   usb_phy_init(musb-xceiv);
+   phy_init(musb-phy);
 
pm_runtime_put_noidle(musb-controller);
return 0;
@@ -460,6 +474,7 @@ static int omap2430_musb_exit(struct musb *musb)
del_timer_sync(musb_idle_timer);
 
omap2430_low_level_exit(musb);
+   phy_exit(musb-phy);
 
return 0;
 }
@@ -633,7 +648,7 @@ static int omap2430_runtime_suspend(struct device *dev)
OTG_INTERFSEL);
 
omap2430_low_level_exit(musb);
-   usb_phy_set_suspend(musb-xceiv, 1);
+   phy_power_off(musb-phy);
}
 
return 0;
@@ -648,8 +663,7 @@ static int omap2430_runtime_resume(struct device *dev)
omap2430_low_level_init(musb);
musb_writel(musb-mregs, OTG_INTERFSEL,
musb-context.otg_interfsel);
-
-   usb_phy_set_suspend(musb-xceiv, 0);
+   phy_power_on(musb-phy);
}
 
return 0;
-- 
1.7.10.4

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


[PATCH v10 4/8] arm: omap3: twl: add phy consumer data in twl4030_usb_data

2013-07-26 Thread Kishon Vijay Abraham I
The PHY framework uses the phy consumer data populated in platform data in the
case of non-dt boot to return the reference to the PHY when the controller
(PHY consumer) requests for it. So populated the phy consumer data in the 
platform
data of twl usb.

Signed-off-by: Kishon Vijay Abraham I kis...@ti.com
---
 arch/arm/mach-omap2/twl-common.c |   11 +++
 1 file changed, 11 insertions(+)

diff --git a/arch/arm/mach-omap2/twl-common.c b/arch/arm/mach-omap2/twl-common.c
index c05898f..b0d54da 100644
--- a/arch/arm/mach-omap2/twl-common.c
+++ b/arch/arm/mach-omap2/twl-common.c
@@ -24,6 +24,7 @@
 #include linux/i2c/twl.h
 #include linux/gpio.h
 #include linux/string.h
+#include linux/phy/phy.h
 #include linux/regulator/machine.h
 #include linux/regulator/fixed.h
 
@@ -90,8 +91,18 @@ void __init omap_pmic_late_init(void)
 }
 
 #if defined(CONFIG_ARCH_OMAP3)
+struct phy_consumer consumers[] = {
+   PHY_CONSUMER(musb-hdrc.0, usb),
+};
+
+struct phy_init_data init_data = {
+   .consumers = consumers,
+   .num_consumers = ARRAY_SIZE(consumers),
+};
+
 static struct twl4030_usb_data omap3_usb_pdata = {
.usb_mode   = T2_USB_MODE_ULPI,
+   .init_data  = init_data,
 };
 
 static int omap3_batt_table[] = {
-- 
1.7.10.4

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


[PATCH v10 1/8] drivers: phy: add generic PHY framework

2013-07-26 Thread Kishon Vijay Abraham I
The PHY framework provides a set of APIs for the PHY drivers to
create/destroy a PHY and APIs for the PHY users to obtain a reference to the
PHY with or without using phandle. For dt-boot, the PHY drivers should
also register *PHY provider* with the framework.

PHY drivers should create the PHY by passing id and ops like init, exit,
power_on and power_off. This framework is also pm runtime enabled.

The documentation for the generic PHY framework is added in
Documentation/phy.txt and the documentation for dt binding can be found at
Documentation/devicetree/bindings/phy/phy-bindings.txt

Cc: Tomasz Figa t.f...@samsung.com
Cc: Greg Kroah-Hartman gre...@linuxfoundation.org
Signed-off-by: Kishon Vijay Abraham I kis...@ti.com
Acked-by: Felipe Balbi ba...@ti.com
Tested-by: Sylwester Nawrocki s.nawro...@samsung.com
---
 .../devicetree/bindings/phy/phy-bindings.txt   |   66 ++
 Documentation/phy.txt  |  166 +
 MAINTAINERS|8 +
 drivers/Kconfig|2 +
 drivers/Makefile   |2 +
 drivers/phy/Kconfig|   18 +
 drivers/phy/Makefile   |5 +
 drivers/phy/phy-core.c |  714 
 include/linux/phy/phy.h|  270 
 9 files changed, 1251 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/phy/phy-bindings.txt
 create mode 100644 Documentation/phy.txt
 create mode 100644 drivers/phy/Kconfig
 create mode 100644 drivers/phy/Makefile
 create mode 100644 drivers/phy/phy-core.c
 create mode 100644 include/linux/phy/phy.h

diff --git a/Documentation/devicetree/bindings/phy/phy-bindings.txt 
b/Documentation/devicetree/bindings/phy/phy-bindings.txt
new file mode 100644
index 000..8ae844f
--- /dev/null
+++ b/Documentation/devicetree/bindings/phy/phy-bindings.txt
@@ -0,0 +1,66 @@
+This document explains only the device tree data binding. For general
+information about PHY subsystem refer to Documentation/phy.txt
+
+PHY device node
+===
+
+Required Properties:
+#phy-cells:Number of cells in a PHY specifier;  The meaning of all those
+   cells is defined by the binding for the phy node. The PHY
+   provider can use the values in cells to find the appropriate
+   PHY.
+
+For example:
+
+phys: phy {
+compatible = xxx;
+reg = ...;
+.
+.
+#phy-cells = 1;
+.
+.
+};
+
+That node describes an IP block (PHY provider) that implements 2 different 
PHYs.
+In order to differentiate between these 2 PHYs, an additonal specifier should 
be
+given while trying to get a reference to it.
+
+PHY user node
+=
+
+Required Properties:
+phys : the phandle for the PHY device (used by the PHY subsystem)
+phy-names : the names of the PHY corresponding to the PHYs present in the
+   *phys* phandle
+
+Example 1:
+usb1: usb_otg_ss@xxx {
+compatible = xxx;
+reg = xxx;
+.
+.
+phys = usb2_phy, usb3_phy;
+phy-names = usb2phy, usb3phy;
+.
+.
+};
+
+This node represents a controller that uses two PHYs, one for usb2 and one for
+usb3.
+
+Example 2:
+usb2: usb_otg_ss@xxx {
+compatible = xxx;
+reg = xxx;
+.
+.
+phys = phys 1;
+phy-names = usbphy;
+.
+.
+};
+
+This node represents a controller that uses one of the PHYs of the PHY provider
+device defined previously. Note that the phy handle has an additional specifier
+1 to differentiate between the two PHYs.
diff --git a/Documentation/phy.txt b/Documentation/phy.txt
new file mode 100644
index 000..4e056c4
--- /dev/null
+++ b/Documentation/phy.txt
@@ -0,0 +1,166 @@
+   PHY SUBSYSTEM
+ Kishon Vijay Abraham I kis...@ti.com
+
+This document explains the Generic PHY Framework along with the APIs provided,
+and how-to-use.
+
+1. Introduction
+
+*PHY* is the abbreviation for physical layer. It is used to connect a device
+to the physical medium e.g., the USB controller has a PHY to provide functions
+such as serialization, de-serialization, encoding, decoding and is responsible
+for obtaining the required data transmission rate. Note that some USB
+controllers have PHY functionality embedded into it and others use an external
+PHY. Other peripherals that use PHY include Wireless LAN, Ethernet,
+SATA etc.
+
+The intention of creating this framework is to bring the PHY drivers spread
+all over the Linux kernel to drivers/phy to increase code re-use and for
+better code maintainability.
+
+This framework will be of use only to devices that use external PHY (PHY
+functionality is not embedded within the controller).
+
+2. Registering/Unregistering the PHY provider
+
+PHY provider refers to an entity that implements one or more PHY instances.
+For the simple case where the PHY provider implements only a single instance

[PATCH v10 3/8] usb: phy: twl4030: use the new generic PHY framework

2013-07-26 Thread Kishon Vijay Abraham I
Used the generic PHY framework API to create the PHY. For powering on
and powering off the PHY, power_on and power_off ops are used. Once the
MUSB OMAP glue is adapted to the new framework, the suspend and resume
ops of usb phy library will be removed. Also twl4030-usb driver is moved
to drivers/phy/.

However using the old usb phy library cannot be completely removed
because otg is intertwined with phy and moving to the new
framework completely will break otg. Once we have a separate otg state machine,
we can get rid of the usb phy library.

Signed-off-by: Kishon Vijay Abraham I kis...@ti.com
Acked-by: Felipe Balbi ba...@ti.com
Reviewed-by: Sylwester Nawrocki s.nawro...@samsung.com
---
 drivers/phy/Kconfig |   11 ++
 drivers/phy/Makefile|1 +
 drivers/{usb = }/phy/phy-twl4030-usb.c |   56 +--
 drivers/usb/phy/Kconfig |9 -
 drivers/usb/phy/Makefile|1 -
 include/linux/i2c/twl.h |2 ++
 6 files changed, 67 insertions(+), 13 deletions(-)
 rename drivers/{usb = }/phy/phy-twl4030-usb.c (95%)

diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig
index 38c3477..ac239ac 100644
--- a/drivers/phy/Kconfig
+++ b/drivers/phy/Kconfig
@@ -27,4 +27,15 @@ config OMAP_USB2
  The USB OTG controller communicates with the comparator using this
  driver.
 
+config TWL4030_USB
+   tristate TWL4030 USB Transceiver Driver
+   depends on TWL4030_CORE  REGULATOR_TWL4030  USB_MUSB_OMAP2PLUS
+   select GENERIC_PHY
+   select USB_PHY
+   help
+ Enable this to support the USB OTG transceiver on TWL4030
+ family chips (including the TWL5030 and TPS659x0 devices).
+ This transceiver supports high and full speed devices plus,
+ in host mode, low speed.
+
 endmenu
diff --git a/drivers/phy/Makefile b/drivers/phy/Makefile
index ed5b088..0dd8a98 100644
--- a/drivers/phy/Makefile
+++ b/drivers/phy/Makefile
@@ -4,3 +4,4 @@
 
 obj-$(CONFIG_GENERIC_PHY)  += phy-core.o
 obj-$(CONFIG_OMAP_USB2)+= phy-omap-usb2.o
+obj-$(CONFIG_TWL4030_USB)  += phy-twl4030-usb.o
diff --git a/drivers/usb/phy/phy-twl4030-usb.c b/drivers/phy/phy-twl4030-usb.c
similarity index 95%
rename from drivers/usb/phy/phy-twl4030-usb.c
rename to drivers/phy/phy-twl4030-usb.c
index 8f78d2d..494f107 100644
--- a/drivers/usb/phy/phy-twl4030-usb.c
+++ b/drivers/phy/phy-twl4030-usb.c
@@ -33,6 +33,7 @@
 #include linux/io.h
 #include linux/delay.h
 #include linux/usb/otg.h
+#include linux/phy/phy.h
 #include linux/usb/musb-omap.h
 #include linux/usb/ulpi.h
 #include linux/i2c/twl.h
@@ -431,6 +432,14 @@ static void twl4030_phy_suspend(struct twl4030_usb *twl, 
int controller_off)
dev_dbg(twl-dev, %s\n, __func__);
 }
 
+static int twl4030_phy_power_off(struct phy *phy)
+{
+   struct twl4030_usb *twl = phy_get_drvdata(phy);
+
+   twl4030_phy_suspend(twl, 0);
+   return 0;
+}
+
 static void __twl4030_phy_resume(struct twl4030_usb *twl)
 {
twl4030_phy_power(twl, 1);
@@ -459,6 +468,14 @@ static void twl4030_phy_resume(struct twl4030_usb *twl)
}
 }
 
+static int twl4030_phy_power_on(struct phy *phy)
+{
+   struct twl4030_usb *twl = phy_get_drvdata(phy);
+
+   twl4030_phy_resume(twl);
+   return 0;
+}
+
 static int twl4030_usb_ldo_init(struct twl4030_usb *twl)
 {
/* Enable writing to power configuration registers */
@@ -602,13 +619,22 @@ static int twl4030_usb_phy_init(struct usb_phy *phy)
status = twl4030_usb_linkstat(twl);
twl-linkstat = status;
 
-   if (status == OMAP_MUSB_ID_GROUND || status == OMAP_MUSB_VBUS_VALID)
+   if (status == OMAP_MUSB_ID_GROUND || status == OMAP_MUSB_VBUS_VALID) {
omap_musb_mailbox(twl-linkstat);
+   twl4030_phy_resume(twl);
+   }
 
sysfs_notify(twl-dev-kobj, NULL, vbus);
return 0;
 }
 
+static int twl4030_phy_init(struct phy *phy)
+{
+   struct twl4030_usb *twl = phy_get_drvdata(phy);
+
+   return twl4030_usb_phy_init(twl-phy);
+}
+
 static int twl4030_set_suspend(struct usb_phy *x, int suspend)
 {
struct twl4030_usb *twl = phy_to_twl(x);
@@ -646,13 +672,23 @@ static int twl4030_set_host(struct usb_otg *otg, struct 
usb_bus *host)
return 0;
 }
 
+static const struct phy_ops ops = {
+   .init   = twl4030_phy_init,
+   .power_on   = twl4030_phy_power_on,
+   .power_off  = twl4030_phy_power_off,
+   .owner  = THIS_MODULE,
+};
+
 static int twl4030_usb_probe(struct platform_device *pdev)
 {
struct twl4030_usb_data *pdata = pdev-dev.platform_data;
struct twl4030_usb  *twl;
+   struct phy  *phy;
int status, err;
struct usb_otg  *otg;
struct device_node  *np = pdev-dev.of_node;
+   struct phy_provider *phy_provider;
+   struct phy_init_data

[PATCH v10 2/8] usb: phy: omap-usb2: use the new generic PHY framework

2013-07-26 Thread Kishon Vijay Abraham I
Used the generic PHY framework API to create the PHY. Now the power off and
power on are done in omap_usb_power_off and omap_usb_power_on respectively.
The omap-usb2 driver is also moved to driver/phy.

However using the old USB PHY library cannot be completely removed
because OTG is intertwined with PHY and moving to the new framework
will break OTG. Once we have a separate OTG state machine, we
can get rid of the USB PHY library.

Signed-off-by: Kishon Vijay Abraham I kis...@ti.com
Reviewed-by: Sylwester Nawrocki s.nawro...@samsung.com
Acked-by: Felipe Balbi ba...@ti.com
---
 drivers/phy/Kconfig   |   12 +
 drivers/phy/Makefile  |1 +
 drivers/{usb = }/phy/phy-omap-usb2.c |   45 ++---
 drivers/usb/phy/Kconfig   |   10 
 drivers/usb/phy/Makefile  |1 -
 5 files changed, 54 insertions(+), 15 deletions(-)
 rename drivers/{usb = }/phy/phy-omap-usb2.c (88%)

diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig
index 349bef2..38c3477 100644
--- a/drivers/phy/Kconfig
+++ b/drivers/phy/Kconfig
@@ -15,4 +15,16 @@ config GENERIC_PHY
  phy users can obtain reference to the PHY. All the users of this
  framework should select this config.
 
+config OMAP_USB2
+   tristate OMAP USB2 PHY Driver
+   depends on ARCH_OMAP2PLUS
+   select GENERIC_PHY
+   select USB_PHY
+   select OMAP_CONTROL_USB
+   help
+ Enable this to support the transceiver that is part of SOC. This
+ driver takes care of all the PHY functionality apart from comparator.
+ The USB OTG controller communicates with the comparator using this
+ driver.
+
 endmenu
diff --git a/drivers/phy/Makefile b/drivers/phy/Makefile
index 9e9560f..ed5b088 100644
--- a/drivers/phy/Makefile
+++ b/drivers/phy/Makefile
@@ -3,3 +3,4 @@
 #
 
 obj-$(CONFIG_GENERIC_PHY)  += phy-core.o
+obj-$(CONFIG_OMAP_USB2)+= phy-omap-usb2.o
diff --git a/drivers/usb/phy/phy-omap-usb2.c b/drivers/phy/phy-omap-usb2.c
similarity index 88%
rename from drivers/usb/phy/phy-omap-usb2.c
rename to drivers/phy/phy-omap-usb2.c
index 844ab68..25e0f3c 100644
--- a/drivers/usb/phy/phy-omap-usb2.c
+++ b/drivers/phy/phy-omap-usb2.c
@@ -28,6 +28,7 @@
 #include linux/pm_runtime.h
 #include linux/delay.h
 #include linux/usb/omap_control_usb.h
+#include linux/phy/phy.h
 
 /**
  * omap_usb2_set_comparator - links the comparator present in the sytem with
@@ -119,10 +120,36 @@ static int omap_usb2_suspend(struct usb_phy *x, int 
suspend)
return 0;
 }
 
+static int omap_usb_power_off(struct phy *x)
+{
+   struct omap_usb *phy = phy_get_drvdata(x);
+
+   omap_control_usb_phy_power(phy-control_dev, 0);
+
+   return 0;
+}
+
+static int omap_usb_power_on(struct phy *x)
+{
+   struct omap_usb *phy = phy_get_drvdata(x);
+
+   omap_control_usb_phy_power(phy-control_dev, 1);
+
+   return 0;
+}
+
+static struct phy_ops ops = {
+   .power_on   = omap_usb_power_on,
+   .power_off  = omap_usb_power_off,
+   .owner  = THIS_MODULE,
+};
+
 static int omap_usb2_probe(struct platform_device *pdev)
 {
struct omap_usb *phy;
+   struct phy  *generic_phy;
struct usb_otg  *otg;
+   struct phy_provider *phy_provider;
 
phy = devm_kzalloc(pdev-dev, sizeof(*phy), GFP_KERNEL);
if (!phy) {
@@ -144,6 +171,11 @@ static int omap_usb2_probe(struct platform_device *pdev)
phy-phy.otg= otg;
phy-phy.type   = USB_PHY_TYPE_USB2;
 
+   phy_provider = devm_of_phy_provider_register(phy-dev,
+   of_phy_simple_xlate);
+   if (IS_ERR(phy_provider))
+   return PTR_ERR(phy_provider);
+
phy-control_dev = omap_get_control_dev();
if (IS_ERR(phy-control_dev)) {
dev_dbg(pdev-dev, Failed to get control device\n);
@@ -159,6 +191,15 @@ static int omap_usb2_probe(struct platform_device *pdev)
otg-start_srp  = omap_usb_start_srp;
otg-phy= phy-phy;
 
+   platform_set_drvdata(pdev, phy);
+   pm_runtime_enable(phy-dev);
+
+   generic_phy = devm_phy_create(phy-dev, ops, NULL);
+   if (IS_ERR(generic_phy))
+   return PTR_ERR(generic_phy);
+
+   phy_set_drvdata(generic_phy, phy);
+
phy-wkupclk = devm_clk_get(phy-dev, usb_phy_cm_clk32k);
if (IS_ERR(phy-wkupclk)) {
dev_err(pdev-dev, unable to get usb_phy_cm_clk32k\n);
@@ -174,10 +215,6 @@ static int omap_usb2_probe(struct platform_device *pdev)
 
usb_add_phy_dev(phy-phy);
 
-   platform_set_drvdata(pdev, phy);
-
-   pm_runtime_enable(phy-dev);
-
return 0;
 }
 
diff --git a/drivers/usb/phy/Kconfig b/drivers/usb/phy/Kconfig
index 3622fff..7813238 100644
--- a/drivers/usb/phy/Kconfig
+++ b/drivers/usb/phy/Kconfig
@@ -72,16 +72,6 @@ config

[RESEND PATCH v10 2/8] usb: phy: omap-usb2: use the new generic PHY framework

2013-07-26 Thread Kishon Vijay Abraham I
Used the generic PHY framework API to create the PHY. Now the power off and
power on are done in omap_usb_power_off and omap_usb_power_on respectively.
The omap-usb2 driver is also moved to driver/phy.

However using the old USB PHY library cannot be completely removed
because OTG is intertwined with PHY and moving to the new framework
will break OTG. Once we have a separate OTG state machine, we
can get rid of the USB PHY library.

Signed-off-by: Kishon Vijay Abraham I kis...@ti.com
Reviewed-by: Sylwester Nawrocki s.nawro...@samsung.com
Acked-by: Felipe Balbi ba...@ti.com
---
 drivers/phy/Kconfig   |   12 +
 drivers/phy/Makefile  |1 +
 drivers/{usb = }/phy/phy-omap-usb2.c |   45 ++---
 drivers/usb/phy/Kconfig   |   10 
 drivers/usb/phy/Makefile  |1 -
 5 files changed, 54 insertions(+), 15 deletions(-)
 rename drivers/{usb = }/phy/phy-omap-usb2.c (88%)

diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig
index 349bef2..38c3477 100644
--- a/drivers/phy/Kconfig
+++ b/drivers/phy/Kconfig
@@ -15,4 +15,16 @@ config GENERIC_PHY
  phy users can obtain reference to the PHY. All the users of this
  framework should select this config.
 
+config OMAP_USB2
+   tristate OMAP USB2 PHY Driver
+   depends on ARCH_OMAP2PLUS
+   select GENERIC_PHY
+   select USB_PHY
+   select OMAP_CONTROL_USB
+   help
+ Enable this to support the transceiver that is part of SOC. This
+ driver takes care of all the PHY functionality apart from comparator.
+ The USB OTG controller communicates with the comparator using this
+ driver.
+
 endmenu
diff --git a/drivers/phy/Makefile b/drivers/phy/Makefile
index 9e9560f..ed5b088 100644
--- a/drivers/phy/Makefile
+++ b/drivers/phy/Makefile
@@ -3,3 +3,4 @@
 #
 
 obj-$(CONFIG_GENERIC_PHY)  += phy-core.o
+obj-$(CONFIG_OMAP_USB2)+= phy-omap-usb2.o
diff --git a/drivers/usb/phy/phy-omap-usb2.c b/drivers/phy/phy-omap-usb2.c
similarity index 88%
rename from drivers/usb/phy/phy-omap-usb2.c
rename to drivers/phy/phy-omap-usb2.c
index 844ab68..25e0f3c 100644
--- a/drivers/usb/phy/phy-omap-usb2.c
+++ b/drivers/phy/phy-omap-usb2.c
@@ -28,6 +28,7 @@
 #include linux/pm_runtime.h
 #include linux/delay.h
 #include linux/usb/omap_control_usb.h
+#include linux/phy/phy.h
 
 /**
  * omap_usb2_set_comparator - links the comparator present in the sytem with
@@ -119,10 +120,36 @@ static int omap_usb2_suspend(struct usb_phy *x, int 
suspend)
return 0;
 }
 
+static int omap_usb_power_off(struct phy *x)
+{
+   struct omap_usb *phy = phy_get_drvdata(x);
+
+   omap_control_usb_phy_power(phy-control_dev, 0);
+
+   return 0;
+}
+
+static int omap_usb_power_on(struct phy *x)
+{
+   struct omap_usb *phy = phy_get_drvdata(x);
+
+   omap_control_usb_phy_power(phy-control_dev, 1);
+
+   return 0;
+}
+
+static struct phy_ops ops = {
+   .power_on   = omap_usb_power_on,
+   .power_off  = omap_usb_power_off,
+   .owner  = THIS_MODULE,
+};
+
 static int omap_usb2_probe(struct platform_device *pdev)
 {
struct omap_usb *phy;
+   struct phy  *generic_phy;
struct usb_otg  *otg;
+   struct phy_provider *phy_provider;
 
phy = devm_kzalloc(pdev-dev, sizeof(*phy), GFP_KERNEL);
if (!phy) {
@@ -144,6 +171,11 @@ static int omap_usb2_probe(struct platform_device *pdev)
phy-phy.otg= otg;
phy-phy.type   = USB_PHY_TYPE_USB2;
 
+   phy_provider = devm_of_phy_provider_register(phy-dev,
+   of_phy_simple_xlate);
+   if (IS_ERR(phy_provider))
+   return PTR_ERR(phy_provider);
+
phy-control_dev = omap_get_control_dev();
if (IS_ERR(phy-control_dev)) {
dev_dbg(pdev-dev, Failed to get control device\n);
@@ -159,6 +191,15 @@ static int omap_usb2_probe(struct platform_device *pdev)
otg-start_srp  = omap_usb_start_srp;
otg-phy= phy-phy;
 
+   platform_set_drvdata(pdev, phy);
+   pm_runtime_enable(phy-dev);
+
+   generic_phy = devm_phy_create(phy-dev, ops, NULL);
+   if (IS_ERR(generic_phy))
+   return PTR_ERR(generic_phy);
+
+   phy_set_drvdata(generic_phy, phy);
+
phy-wkupclk = devm_clk_get(phy-dev, usb_phy_cm_clk32k);
if (IS_ERR(phy-wkupclk)) {
dev_err(pdev-dev, unable to get usb_phy_cm_clk32k\n);
@@ -174,10 +215,6 @@ static int omap_usb2_probe(struct platform_device *pdev)
 
usb_add_phy_dev(phy-phy);
 
-   platform_set_drvdata(pdev, phy);
-
-   pm_runtime_enable(phy-dev);
-
return 0;
 }
 
diff --git a/drivers/usb/phy/Kconfig b/drivers/usb/phy/Kconfig
index 3622fff..7813238 100644
--- a/drivers/usb/phy/Kconfig
+++ b/drivers/usb/phy/Kconfig
@@ -72,16 +72,6 @@ config

[RESEND PATCH v10 6/8] usb: musb: omap2430: use the new generic PHY framework

2013-07-26 Thread Kishon Vijay Abraham I
Use the generic PHY framework API to get the PHY. The usb_phy_set_resume
and usb_phy_set_suspend is replaced with power_on and
power_off to align with the new PHY framework.

musb-xceiv can't be removed as of now because musb core uses xceiv.state and
xceiv.otg. Once there is a separate state machine to handle otg, these can be
moved out of xceiv and then we can start using the generic PHY framework.

Signed-off-by: Kishon Vijay Abraham I kis...@ti.com
Reviewed-by: Sylwester Nawrocki s.nawro...@samsung.com
Acked-by: Felipe Balbi ba...@ti.com
---
 drivers/usb/musb/Kconfig |1 +
 drivers/usb/musb/musb_core.h |2 ++
 drivers/usb/musb/omap2430.c  |   26 --
 3 files changed, 23 insertions(+), 6 deletions(-)

diff --git a/drivers/usb/musb/Kconfig b/drivers/usb/musb/Kconfig
index 797e3fd..25e2e57 100644
--- a/drivers/usb/musb/Kconfig
+++ b/drivers/usb/musb/Kconfig
@@ -76,6 +76,7 @@ config USB_MUSB_TUSB6010
 config USB_MUSB_OMAP2PLUS
tristate OMAP2430 and onwards
depends on ARCH_OMAP2PLUS
+   select GENERIC_PHY
 
 config USB_MUSB_AM35X
tristate AM35x
diff --git a/drivers/usb/musb/musb_core.h b/drivers/usb/musb/musb_core.h
index 7d341c3..6e567bd 100644
--- a/drivers/usb/musb/musb_core.h
+++ b/drivers/usb/musb/musb_core.h
@@ -46,6 +46,7 @@
 #include linux/usb.h
 #include linux/usb/otg.h
 #include linux/usb/musb.h
+#include linux/phy/phy.h
 
 struct musb;
 struct musb_hw_ep;
@@ -346,6 +347,7 @@ struct musb {
u16 int_tx;
 
struct usb_phy  *xceiv;
+   struct phy  *phy;
 
int nIrq;
unsignedirq_wake:1;
diff --git a/drivers/usb/musb/omap2430.c b/drivers/usb/musb/omap2430.c
index 6708a3b..f7b33f4 100644
--- a/drivers/usb/musb/omap2430.c
+++ b/drivers/usb/musb/omap2430.c
@@ -348,11 +348,21 @@ static int omap2430_musb_init(struct musb *musb)
 * up through ULPI.  TWL4030-family PMICs include one,
 * which needs a driver, drivers aren't always needed.
 */
-   if (dev-parent-of_node)
+   if (dev-parent-of_node) {
+   musb-phy = devm_phy_get(dev-parent, usb2-phy);
+
+   /* We can't totally remove musb-xceiv as of now because
+* musb core uses xceiv.state and xceiv.otg. Once we have
+* a separate state machine to handle otg, these can be moved
+* out of xceiv and then we can start using the generic PHY
+* framework
+*/
musb-xceiv = devm_usb_get_phy_by_phandle(dev-parent,
usb-phy, 0);
-   else
+   } else {
musb-xceiv = devm_usb_get_phy_dev(dev, 0);
+   musb-phy = devm_phy_get(dev, usb);
+   }
 
if (IS_ERR(musb-xceiv)) {
status = PTR_ERR(musb-xceiv);
@@ -364,6 +374,10 @@ static int omap2430_musb_init(struct musb *musb)
return -EPROBE_DEFER;
}
 
+   if (IS_ERR(musb-phy)) {
+   pr_err(HS USB OTG: no PHY configured\n);
+   return PTR_ERR(musb-phy);
+   }
musb-isr = omap2430_musb_interrupt;
 
status = pm_runtime_get_sync(dev);
@@ -397,7 +411,7 @@ static int omap2430_musb_init(struct musb *musb)
if (glue-status != OMAP_MUSB_UNKNOWN)
omap_musb_set_mailbox(glue);
 
-   usb_phy_init(musb-xceiv);
+   phy_init(musb-phy);
 
pm_runtime_put_noidle(musb-controller);
return 0;
@@ -460,6 +474,7 @@ static int omap2430_musb_exit(struct musb *musb)
del_timer_sync(musb_idle_timer);
 
omap2430_low_level_exit(musb);
+   phy_exit(musb-phy);
 
return 0;
 }
@@ -633,7 +648,7 @@ static int omap2430_runtime_suspend(struct device *dev)
OTG_INTERFSEL);
 
omap2430_low_level_exit(musb);
-   usb_phy_set_suspend(musb-xceiv, 1);
+   phy_power_off(musb-phy);
}
 
return 0;
@@ -648,8 +663,7 @@ static int omap2430_runtime_resume(struct device *dev)
omap2430_low_level_init(musb);
musb_writel(musb-mregs, OTG_INTERFSEL,
musb-context.otg_interfsel);
-
-   usb_phy_set_suspend(musb-xceiv, 0);
+   phy_power_on(musb-phy);
}
 
return 0;
-- 
1.7.10.4

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


[RESEND PATCH v10 5/8] ARM: dts: omap: update usb_otg_hs data

2013-07-26 Thread Kishon Vijay Abraham I
Updated the usb_otg_hs dt data to include the *phy* and *phy-names*
binding in order for the driver to use the new generic PHY framework.
Also updated the Documentation to include the binding information.
The PHY binding information can be found at
Documentation/devicetree/bindings/phy/phy-bindings.txt

Signed-off-by: Kishon Vijay Abraham I kis...@ti.com
Acked-by: Felipe Balbi ba...@ti.com
Reviewed-by: Sylwester Nawrocki s.nawro...@samsung.com
---
 Documentation/devicetree/bindings/usb/omap-usb.txt |5 +
 Documentation/devicetree/bindings/usb/usb-phy.txt  |6 ++
 arch/arm/boot/dts/omap3-beagle-xm.dts  |2 ++
 arch/arm/boot/dts/omap3-evm.dts|2 ++
 arch/arm/boot/dts/omap3-overo.dtsi |2 ++
 arch/arm/boot/dts/omap4.dtsi   |3 +++
 arch/arm/boot/dts/twl4030.dtsi |1 +
 7 files changed, 21 insertions(+)

diff --git a/Documentation/devicetree/bindings/usb/omap-usb.txt 
b/Documentation/devicetree/bindings/usb/omap-usb.txt
index 57e71f6..825790d 100644
--- a/Documentation/devicetree/bindings/usb/omap-usb.txt
+++ b/Documentation/devicetree/bindings/usb/omap-usb.txt
@@ -19,6 +19,9 @@ OMAP MUSB GLUE
  - power : Should be 50. This signifies the controller can supply up to
100mA when operating in host mode.
  - usb-phy : the phandle for the PHY device
+ - phys : the phandle for the PHY device (used by generic PHY framework)
+ - phy-names : the names of the PHY corresponding to the PHYs present in the
+   *phy* phandle.
 
 Optional properties:
  - ctrl-module : phandle of the control module this glue uses to write to
@@ -33,6 +36,8 @@ usb_otg_hs: usb_otg_hs@4a0ab000 {
num-eps = 16;
ram-bits = 12;
ctrl-module = omap_control_usb;
+   phys = usb2_phy;
+   phy-names = usb2-phy;
 };
 
 Board specific device node entry
diff --git a/Documentation/devicetree/bindings/usb/usb-phy.txt 
b/Documentation/devicetree/bindings/usb/usb-phy.txt
index 61496f5..c0245c8 100644
--- a/Documentation/devicetree/bindings/usb/usb-phy.txt
+++ b/Documentation/devicetree/bindings/usb/usb-phy.txt
@@ -5,6 +5,8 @@ OMAP USB2 PHY
 Required properties:
  - compatible: Should be ti,omap-usb2
  - reg : Address and length of the register set for the device.
+ - #phy-cells: determine the number of cells that should be given in the
+   phandle while referencing this phy.
 
 Optional properties:
  - ctrl-module : phandle of the control module used by PHY driver to power on
@@ -16,6 +18,7 @@ usb2phy@4a0ad080 {
compatible = ti,omap-usb2;
reg = 0x4a0ad080 0x58;
ctrl-module = omap_control_usb;
+   #phy-cells = 0;
 };
 
 OMAP USB3 PHY
@@ -25,6 +28,8 @@ Required properties:
  - reg : Address and length of the register set for the device.
  - reg-names: The names of the register addresses corresponding to the 
registers
filled in reg.
+ - #phy-cells: determine the number of cells that should be given in the
+   phandle while referencing this phy.
 
 Optional properties:
  - ctrl-module : phandle of the control module used by PHY driver to power on
@@ -39,4 +44,5 @@ usb3phy@4a084400 {
  0x4a084c00 0x40;
reg-names = phy_rx, phy_tx, pll_ctrl;
ctrl-module = omap_control_usb;
+   #phy-cells = 0;
 };
diff --git a/arch/arm/boot/dts/omap3-beagle-xm.dts 
b/arch/arm/boot/dts/omap3-beagle-xm.dts
index afdb164..533b2da 100644
--- a/arch/arm/boot/dts/omap3-beagle-xm.dts
+++ b/arch/arm/boot/dts/omap3-beagle-xm.dts
@@ -144,6 +144,8 @@
 usb_otg_hs {
interface-type = 0;
usb-phy = usb2_phy;
+   phys = usb2_phy;
+   phy-names = usb2-phy;
mode = 3;
power = 50;
 };
diff --git a/arch/arm/boot/dts/omap3-evm.dts b/arch/arm/boot/dts/omap3-evm.dts
index 7d4329d..4134dd0 100644
--- a/arch/arm/boot/dts/omap3-evm.dts
+++ b/arch/arm/boot/dts/omap3-evm.dts
@@ -70,6 +70,8 @@
 usb_otg_hs {
interface-type = 0;
usb-phy = usb2_phy;
+   phys = usb2_phy;
+   phy-names = usb2-phy;
mode = 3;
power = 50;
 };
diff --git a/arch/arm/boot/dts/omap3-overo.dtsi 
b/arch/arm/boot/dts/omap3-overo.dtsi
index 8f1abec..a461d2f 100644
--- a/arch/arm/boot/dts/omap3-overo.dtsi
+++ b/arch/arm/boot/dts/omap3-overo.dtsi
@@ -76,6 +76,8 @@
 usb_otg_hs {
interface-type = 0;
usb-phy = usb2_phy;
+   phys = usb2_phy;
+   phy-names = usb2-phy;
mode = 3;
power = 50;
 };
diff --git a/arch/arm/boot/dts/omap4.dtsi b/arch/arm/boot/dts/omap4.dtsi
index 22d9f2b..1e8e2fe 100644
--- a/arch/arm/boot/dts/omap4.dtsi
+++ b/arch/arm/boot/dts/omap4.dtsi
@@ -520,6 +520,7 @@
compatible = ti,omap-usb2;
reg = 0x4a0ad080 0x58;
ctrl-module = omap_control_usb;
+   #phy-cells = 0;
};
};
 
@@ -658,6 +659,8 @@
interrupt-names = mc, dma

[RESEND PATCH v10 3/8] usb: phy: twl4030: use the new generic PHY framework

2013-07-26 Thread Kishon Vijay Abraham I
Used the generic PHY framework API to create the PHY. For powering on
and powering off the PHY, power_on and power_off ops are used. Once the
MUSB OMAP glue is adapted to the new framework, the suspend and resume
ops of usb phy library will be removed. Also twl4030-usb driver is moved
to drivers/phy/.

However using the old usb phy library cannot be completely removed
because otg is intertwined with phy and moving to the new
framework completely will break otg. Once we have a separate otg state machine,
we can get rid of the usb phy library.

Signed-off-by: Kishon Vijay Abraham I kis...@ti.com
Acked-by: Felipe Balbi ba...@ti.com
Reviewed-by: Sylwester Nawrocki s.nawro...@samsung.com
---
 drivers/phy/Kconfig |   11 ++
 drivers/phy/Makefile|1 +
 drivers/{usb = }/phy/phy-twl4030-usb.c |   56 +--
 drivers/usb/phy/Kconfig |9 -
 drivers/usb/phy/Makefile|1 -
 include/linux/i2c/twl.h |2 ++
 6 files changed, 67 insertions(+), 13 deletions(-)
 rename drivers/{usb = }/phy/phy-twl4030-usb.c (95%)

diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig
index 38c3477..ac239ac 100644
--- a/drivers/phy/Kconfig
+++ b/drivers/phy/Kconfig
@@ -27,4 +27,15 @@ config OMAP_USB2
  The USB OTG controller communicates with the comparator using this
  driver.
 
+config TWL4030_USB
+   tristate TWL4030 USB Transceiver Driver
+   depends on TWL4030_CORE  REGULATOR_TWL4030  USB_MUSB_OMAP2PLUS
+   select GENERIC_PHY
+   select USB_PHY
+   help
+ Enable this to support the USB OTG transceiver on TWL4030
+ family chips (including the TWL5030 and TPS659x0 devices).
+ This transceiver supports high and full speed devices plus,
+ in host mode, low speed.
+
 endmenu
diff --git a/drivers/phy/Makefile b/drivers/phy/Makefile
index ed5b088..0dd8a98 100644
--- a/drivers/phy/Makefile
+++ b/drivers/phy/Makefile
@@ -4,3 +4,4 @@
 
 obj-$(CONFIG_GENERIC_PHY)  += phy-core.o
 obj-$(CONFIG_OMAP_USB2)+= phy-omap-usb2.o
+obj-$(CONFIG_TWL4030_USB)  += phy-twl4030-usb.o
diff --git a/drivers/usb/phy/phy-twl4030-usb.c b/drivers/phy/phy-twl4030-usb.c
similarity index 95%
rename from drivers/usb/phy/phy-twl4030-usb.c
rename to drivers/phy/phy-twl4030-usb.c
index 8f78d2d..494f107 100644
--- a/drivers/usb/phy/phy-twl4030-usb.c
+++ b/drivers/phy/phy-twl4030-usb.c
@@ -33,6 +33,7 @@
 #include linux/io.h
 #include linux/delay.h
 #include linux/usb/otg.h
+#include linux/phy/phy.h
 #include linux/usb/musb-omap.h
 #include linux/usb/ulpi.h
 #include linux/i2c/twl.h
@@ -431,6 +432,14 @@ static void twl4030_phy_suspend(struct twl4030_usb *twl, 
int controller_off)
dev_dbg(twl-dev, %s\n, __func__);
 }
 
+static int twl4030_phy_power_off(struct phy *phy)
+{
+   struct twl4030_usb *twl = phy_get_drvdata(phy);
+
+   twl4030_phy_suspend(twl, 0);
+   return 0;
+}
+
 static void __twl4030_phy_resume(struct twl4030_usb *twl)
 {
twl4030_phy_power(twl, 1);
@@ -459,6 +468,14 @@ static void twl4030_phy_resume(struct twl4030_usb *twl)
}
 }
 
+static int twl4030_phy_power_on(struct phy *phy)
+{
+   struct twl4030_usb *twl = phy_get_drvdata(phy);
+
+   twl4030_phy_resume(twl);
+   return 0;
+}
+
 static int twl4030_usb_ldo_init(struct twl4030_usb *twl)
 {
/* Enable writing to power configuration registers */
@@ -602,13 +619,22 @@ static int twl4030_usb_phy_init(struct usb_phy *phy)
status = twl4030_usb_linkstat(twl);
twl-linkstat = status;
 
-   if (status == OMAP_MUSB_ID_GROUND || status == OMAP_MUSB_VBUS_VALID)
+   if (status == OMAP_MUSB_ID_GROUND || status == OMAP_MUSB_VBUS_VALID) {
omap_musb_mailbox(twl-linkstat);
+   twl4030_phy_resume(twl);
+   }
 
sysfs_notify(twl-dev-kobj, NULL, vbus);
return 0;
 }
 
+static int twl4030_phy_init(struct phy *phy)
+{
+   struct twl4030_usb *twl = phy_get_drvdata(phy);
+
+   return twl4030_usb_phy_init(twl-phy);
+}
+
 static int twl4030_set_suspend(struct usb_phy *x, int suspend)
 {
struct twl4030_usb *twl = phy_to_twl(x);
@@ -646,13 +672,23 @@ static int twl4030_set_host(struct usb_otg *otg, struct 
usb_bus *host)
return 0;
 }
 
+static const struct phy_ops ops = {
+   .init   = twl4030_phy_init,
+   .power_on   = twl4030_phy_power_on,
+   .power_off  = twl4030_phy_power_off,
+   .owner  = THIS_MODULE,
+};
+
 static int twl4030_usb_probe(struct platform_device *pdev)
 {
struct twl4030_usb_data *pdata = pdev-dev.platform_data;
struct twl4030_usb  *twl;
+   struct phy  *phy;
int status, err;
struct usb_otg  *otg;
struct device_node  *np = pdev-dev.of_node;
+   struct phy_provider *phy_provider;
+   struct phy_init_data

[RESEND PATCH v10 7/8] usb: phy: omap-usb2: remove *set_suspend* callback from omap-usb2

2013-07-26 Thread Kishon Vijay Abraham I
Now that omap-usb2 is adapted to the new generic PHY framework,
*set_suspend* ops can be removed from omap-usb2 driver.

Signed-off-by: Kishon Vijay Abraham I kis...@ti.com
Acked-by: Felipe Balbi ba...@ti.com
Reviewed-by: Sylwester Nawrocki s.nawro...@samsung.com
---
 drivers/phy/phy-omap-usb2.c |   25 -
 1 file changed, 25 deletions(-)

diff --git a/drivers/phy/phy-omap-usb2.c b/drivers/phy/phy-omap-usb2.c
index 25e0f3c..dec3fab 100644
--- a/drivers/phy/phy-omap-usb2.c
+++ b/drivers/phy/phy-omap-usb2.c
@@ -97,29 +97,6 @@ static int omap_usb_set_peripheral(struct usb_otg *otg,
return 0;
 }
 
-static int omap_usb2_suspend(struct usb_phy *x, int suspend)
-{
-   u32 ret;
-   struct omap_usb *phy = phy_to_omapusb(x);
-
-   if (suspend  !phy-is_suspended) {
-   omap_control_usb_phy_power(phy-control_dev, 0);
-   pm_runtime_put_sync(phy-dev);
-   phy-is_suspended = 1;
-   } else if (!suspend  phy-is_suspended) {
-   ret = pm_runtime_get_sync(phy-dev);
-   if (ret  0) {
-   dev_err(phy-dev, get_sync failed with err %d\n,
-   ret);
-   return ret;
-   }
-   omap_control_usb_phy_power(phy-control_dev, 1);
-   phy-is_suspended = 0;
-   }
-
-   return 0;
-}
-
 static int omap_usb_power_off(struct phy *x)
 {
struct omap_usb *phy = phy_get_drvdata(x);
@@ -167,7 +144,6 @@ static int omap_usb2_probe(struct platform_device *pdev)
 
phy-phy.dev= phy-dev;
phy-phy.label  = omap-usb2;
-   phy-phy.set_suspend= omap_usb2_suspend;
phy-phy.otg= otg;
phy-phy.type   = USB_PHY_TYPE_USB2;
 
@@ -182,7 +158,6 @@ static int omap_usb2_probe(struct platform_device *pdev)
return -ENODEV;
}
 
-   phy-is_suspended   = 1;
omap_control_usb_phy_power(phy-control_dev, 0);
 
otg-set_host   = omap_usb_set_host;
-- 
1.7.10.4

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


[RESEND PATCH v10 8/8] usb: phy: twl4030-usb: remove *set_suspend* and *phy_init* ops

2013-07-26 Thread Kishon Vijay Abraham I
Now that twl4030-usb is adapted to the new generic PHY framework,
*set_suspend* and *phy_init* ops can be removed from twl4030-usb driver.

Signed-off-by: Kishon Vijay Abraham I kis...@ti.com
Acked-by: Felipe Balbi ba...@ti.com
Reviewed-by: Sylwester Nawrocki s.nawro...@samsung.com
---
 drivers/phy/phy-twl4030-usb.c |   57 ++---
 1 file changed, 13 insertions(+), 44 deletions(-)

diff --git a/drivers/phy/phy-twl4030-usb.c b/drivers/phy/phy-twl4030-usb.c
index 494f107..c437211 100644
--- a/drivers/phy/phy-twl4030-usb.c
+++ b/drivers/phy/phy-twl4030-usb.c
@@ -422,25 +422,20 @@ static void twl4030_phy_power(struct twl4030_usb *twl, 
int on)
}
 }
 
-static void twl4030_phy_suspend(struct twl4030_usb *twl, int controller_off)
+static int twl4030_phy_power_off(struct phy *phy)
 {
+   struct twl4030_usb *twl = phy_get_drvdata(phy);
+
if (twl-asleep)
-   return;
+   return 0;
 
twl4030_phy_power(twl, 0);
twl-asleep = 1;
dev_dbg(twl-dev, %s\n, __func__);
-}
-
-static int twl4030_phy_power_off(struct phy *phy)
-{
-   struct twl4030_usb *twl = phy_get_drvdata(phy);
-
-   twl4030_phy_suspend(twl, 0);
return 0;
 }
 
-static void __twl4030_phy_resume(struct twl4030_usb *twl)
+static void __twl4030_phy_power_on(struct twl4030_usb *twl)
 {
twl4030_phy_power(twl, 1);
twl4030_i2c_access(twl, 1);
@@ -449,11 +444,13 @@ static void __twl4030_phy_resume(struct twl4030_usb *twl)
twl4030_i2c_access(twl, 0);
 }
 
-static void twl4030_phy_resume(struct twl4030_usb *twl)
+static int twl4030_phy_power_on(struct phy *phy)
 {
+   struct twl4030_usb *twl = phy_get_drvdata(phy);
+
if (!twl-asleep)
-   return;
-   __twl4030_phy_resume(twl);
+   return 0;
+   __twl4030_phy_power_on(twl);
twl-asleep = 0;
dev_dbg(twl-dev, %s\n, __func__);
 
@@ -466,13 +463,6 @@ static void twl4030_phy_resume(struct twl4030_usb *twl)
cancel_delayed_work(twl-id_workaround_work);
schedule_delayed_work(twl-id_workaround_work, HZ);
}
-}
-
-static int twl4030_phy_power_on(struct phy *phy)
-{
-   struct twl4030_usb *twl = phy_get_drvdata(phy);
-
-   twl4030_phy_resume(twl);
return 0;
 }
 
@@ -604,9 +594,9 @@ static void twl4030_id_workaround_work(struct work_struct 
*work)
}
 }
 
-static int twl4030_usb_phy_init(struct usb_phy *phy)
+static int twl4030_phy_init(struct phy *phy)
 {
-   struct twl4030_usb *twl = phy_to_twl(phy);
+   struct twl4030_usb *twl = phy_get_drvdata(phy);
enum omap_musb_vbus_id_status status;
 
/*
@@ -621,32 +611,13 @@ static int twl4030_usb_phy_init(struct usb_phy *phy)
 
if (status == OMAP_MUSB_ID_GROUND || status == OMAP_MUSB_VBUS_VALID) {
omap_musb_mailbox(twl-linkstat);
-   twl4030_phy_resume(twl);
+   twl4030_phy_power_on(phy);
}
 
sysfs_notify(twl-dev-kobj, NULL, vbus);
return 0;
 }
 
-static int twl4030_phy_init(struct phy *phy)
-{
-   struct twl4030_usb *twl = phy_get_drvdata(phy);
-
-   return twl4030_usb_phy_init(twl-phy);
-}
-
-static int twl4030_set_suspend(struct usb_phy *x, int suspend)
-{
-   struct twl4030_usb *twl = phy_to_twl(x);
-
-   if (suspend)
-   twl4030_phy_suspend(twl, 1);
-   else
-   twl4030_phy_resume(twl);
-
-   return 0;
-}
-
 static int twl4030_set_peripheral(struct usb_otg *otg,
struct usb_gadget *gadget)
 {
@@ -719,8 +690,6 @@ static int twl4030_usb_probe(struct platform_device *pdev)
twl-phy.label  = twl4030;
twl-phy.otg= otg;
twl-phy.type   = USB_PHY_TYPE_USB2;
-   twl-phy.set_suspend= twl4030_set_suspend;
-   twl-phy.init   = twl4030_usb_phy_init;
 
otg-phy= twl-phy;
otg-set_host   = twl4030_set_host;
-- 
1.7.10.4

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


[RESEND PATCH v10 4/8] arm: omap3: twl: add phy consumer data in twl4030_usb_data

2013-07-26 Thread Kishon Vijay Abraham I
The PHY framework uses the phy consumer data populated in platform data in the
case of non-dt boot to return the reference to the PHY when the controller
(PHY consumer) requests for it. So populated the phy consumer data in the 
platform
data of twl usb.

Signed-off-by: Kishon Vijay Abraham I kis...@ti.com
---
 arch/arm/mach-omap2/twl-common.c |   11 +++
 1 file changed, 11 insertions(+)

diff --git a/arch/arm/mach-omap2/twl-common.c b/arch/arm/mach-omap2/twl-common.c
index c05898f..b0d54da 100644
--- a/arch/arm/mach-omap2/twl-common.c
+++ b/arch/arm/mach-omap2/twl-common.c
@@ -24,6 +24,7 @@
 #include linux/i2c/twl.h
 #include linux/gpio.h
 #include linux/string.h
+#include linux/phy/phy.h
 #include linux/regulator/machine.h
 #include linux/regulator/fixed.h
 
@@ -90,8 +91,18 @@ void __init omap_pmic_late_init(void)
 }
 
 #if defined(CONFIG_ARCH_OMAP3)
+struct phy_consumer consumers[] = {
+   PHY_CONSUMER(musb-hdrc.0, usb),
+};
+
+struct phy_init_data init_data = {
+   .consumers = consumers,
+   .num_consumers = ARRAY_SIZE(consumers),
+};
+
 static struct twl4030_usb_data omap3_usb_pdata = {
.usb_mode   = T2_USB_MODE_ULPI,
+   .init_data  = init_data,
 };
 
 static int omap3_batt_table[] = {
-- 
1.7.10.4

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


[RESEND PATCH v10 1/8] drivers: phy: add generic PHY framework

2013-07-26 Thread Kishon Vijay Abraham I
The PHY framework provides a set of APIs for the PHY drivers to
create/destroy a PHY and APIs for the PHY users to obtain a reference to the
PHY with or without using phandle. For dt-boot, the PHY drivers should
also register *PHY provider* with the framework.

PHY drivers should create the PHY by passing id and ops like init, exit,
power_on and power_off. This framework is also pm runtime enabled.

The documentation for the generic PHY framework is added in
Documentation/phy.txt and the documentation for dt binding can be found at
Documentation/devicetree/bindings/phy/phy-bindings.txt

Cc: Tomasz Figa t.f...@samsung.com
Cc: Greg Kroah-Hartman gre...@linuxfoundation.org
Signed-off-by: Kishon Vijay Abraham I kis...@ti.com
Acked-by: Felipe Balbi ba...@ti.com
Tested-by: Sylwester Nawrocki s.nawro...@samsung.com
---
 .../devicetree/bindings/phy/phy-bindings.txt   |   66 ++
 Documentation/phy.txt  |  166 +
 MAINTAINERS|8 +
 drivers/Kconfig|2 +
 drivers/Makefile   |2 +
 drivers/phy/Kconfig|   18 +
 drivers/phy/Makefile   |5 +
 drivers/phy/phy-core.c |  714 
 include/linux/phy/phy.h|  270 
 9 files changed, 1251 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/phy/phy-bindings.txt
 create mode 100644 Documentation/phy.txt
 create mode 100644 drivers/phy/Kconfig
 create mode 100644 drivers/phy/Makefile
 create mode 100644 drivers/phy/phy-core.c
 create mode 100644 include/linux/phy/phy.h

diff --git a/Documentation/devicetree/bindings/phy/phy-bindings.txt 
b/Documentation/devicetree/bindings/phy/phy-bindings.txt
new file mode 100644
index 000..8ae844f
--- /dev/null
+++ b/Documentation/devicetree/bindings/phy/phy-bindings.txt
@@ -0,0 +1,66 @@
+This document explains only the device tree data binding. For general
+information about PHY subsystem refer to Documentation/phy.txt
+
+PHY device node
+===
+
+Required Properties:
+#phy-cells:Number of cells in a PHY specifier;  The meaning of all those
+   cells is defined by the binding for the phy node. The PHY
+   provider can use the values in cells to find the appropriate
+   PHY.
+
+For example:
+
+phys: phy {
+compatible = xxx;
+reg = ...;
+.
+.
+#phy-cells = 1;
+.
+.
+};
+
+That node describes an IP block (PHY provider) that implements 2 different 
PHYs.
+In order to differentiate between these 2 PHYs, an additonal specifier should 
be
+given while trying to get a reference to it.
+
+PHY user node
+=
+
+Required Properties:
+phys : the phandle for the PHY device (used by the PHY subsystem)
+phy-names : the names of the PHY corresponding to the PHYs present in the
+   *phys* phandle
+
+Example 1:
+usb1: usb_otg_ss@xxx {
+compatible = xxx;
+reg = xxx;
+.
+.
+phys = usb2_phy, usb3_phy;
+phy-names = usb2phy, usb3phy;
+.
+.
+};
+
+This node represents a controller that uses two PHYs, one for usb2 and one for
+usb3.
+
+Example 2:
+usb2: usb_otg_ss@xxx {
+compatible = xxx;
+reg = xxx;
+.
+.
+phys = phys 1;
+phy-names = usbphy;
+.
+.
+};
+
+This node represents a controller that uses one of the PHYs of the PHY provider
+device defined previously. Note that the phy handle has an additional specifier
+1 to differentiate between the two PHYs.
diff --git a/Documentation/phy.txt b/Documentation/phy.txt
new file mode 100644
index 000..4e056c4
--- /dev/null
+++ b/Documentation/phy.txt
@@ -0,0 +1,166 @@
+   PHY SUBSYSTEM
+ Kishon Vijay Abraham I kis...@ti.com
+
+This document explains the Generic PHY Framework along with the APIs provided,
+and how-to-use.
+
+1. Introduction
+
+*PHY* is the abbreviation for physical layer. It is used to connect a device
+to the physical medium e.g., the USB controller has a PHY to provide functions
+such as serialization, de-serialization, encoding, decoding and is responsible
+for obtaining the required data transmission rate. Note that some USB
+controllers have PHY functionality embedded into it and others use an external
+PHY. Other peripherals that use PHY include Wireless LAN, Ethernet,
+SATA etc.
+
+The intention of creating this framework is to bring the PHY drivers spread
+all over the Linux kernel to drivers/phy to increase code re-use and for
+better code maintainability.
+
+This framework will be of use only to devices that use external PHY (PHY
+functionality is not embedded within the controller).
+
+2. Registering/Unregistering the PHY provider
+
+PHY provider refers to an entity that implements one or more PHY instances.
+For the simple case where the PHY provider implements only a single instance

[RESEND PATCH v10 0/8] PHY framework

2013-07-26 Thread Kishon Vijay Abraham I
 use of the new framework

Kishon Vijay Abraham I (8):
  drivers: phy: add generic PHY framework
  usb: phy: omap-usb2: use the new generic PHY framework
  usb: phy: twl4030: use the new generic PHY framework
  arm: omap3: twl: add phy consumer data in twl4030_usb_data
  ARM: dts: omap: update usb_otg_hs data
  usb: musb: omap2430: use the new generic PHY framework
  usb: phy: omap-usb2: remove *set_suspend* callback from omap-usb2
  usb: phy: twl4030-usb: remove *set_suspend* and *phy_init* ops

 .../devicetree/bindings/phy/phy-bindings.txt   |   66 ++
 Documentation/devicetree/bindings/usb/omap-usb.txt |5 +
 Documentation/devicetree/bindings/usb/usb-phy.txt  |6 +
 Documentation/phy.txt  |  166 +
 MAINTAINERS|8 +
 arch/arm/boot/dts/omap3-beagle-xm.dts  |2 +
 arch/arm/boot/dts/omap3-evm.dts|2 +
 arch/arm/boot/dts/omap3-overo.dtsi |2 +
 arch/arm/boot/dts/omap4.dtsi   |3 +
 arch/arm/boot/dts/twl4030.dtsi |1 +
 arch/arm/mach-omap2/twl-common.c   |   11 +
 drivers/Kconfig|2 +
 drivers/Makefile   |2 +
 drivers/phy/Kconfig|   41 ++
 drivers/phy/Makefile   |7 +
 drivers/phy/phy-core.c |  714 
 drivers/{usb = }/phy/phy-omap-usb2.c  |   60 +-
 drivers/{usb = }/phy/phy-twl4030-usb.c|   69 +-
 drivers/usb/musb/Kconfig   |1 +
 drivers/usb/musb/musb_core.h   |2 +
 drivers/usb/musb/omap2430.c|   26 +-
 drivers/usb/phy/Kconfig|   19 -
 drivers/usb/phy/Makefile   |2 -
 include/linux/i2c/twl.h|2 +
 include/linux/phy/phy.h|  270 
 25 files changed, 1413 insertions(+), 76 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/phy/phy-bindings.txt
 create mode 100644 Documentation/phy.txt
 create mode 100644 drivers/phy/Kconfig
 create mode 100644 drivers/phy/Makefile
 create mode 100644 drivers/phy/phy-core.c
 rename drivers/{usb = }/phy/phy-omap-usb2.c (88%)
 rename drivers/{usb = }/phy/phy-twl4030-usb.c (94%)
 create mode 100644 include/linux/phy/phy.h

-- 
1.7.10.4

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


Re: [PATCH 01/15] drivers: phy: add generic PHY framework

2013-07-23 Thread Kishon Vijay Abraham I
Hi,

On Tuesday 23 July 2013 08:07 PM, Alan Stern wrote:
 On Tue, 23 Jul 2013, Tomasz Figa wrote:
 
 On Tuesday 23 of July 2013 09:29:32 Tomasz Figa wrote:
 Hi Alan,
 
 Thanks for helping to clarify the issues here.
 
 Okay.  Are PHYs _always_ platform devices?

 They can be i2c, spi or any other device types as well.
 
 In those other cases, presumably there is no platform data associated
 with the PHY since it isn't a platform device.  Then how does the
 kernel know which controller is attached to the PHY?  Is this spelled
 out in platform data associated with the PHY's i2c/spi/whatever parent?

Yes. I think we could use i2c_board_info for passing platform data.
 
  PHY.  Currently this information is represented by name or 
 ID
  strings embedded in platform data.

 right. It's embedded in the platform data of the controller.

 It must also be embedded in the PHY's platform data somehow.
 Otherwise, how would the kernel know which PHY to use?

 By using a PHY lookup as Stephen and I suggested in our previous
 replies. Without any extra data in platform data. (I have even posted a
 code example.)
 
 I don't understand, because I don't know what a PHY lookup does.

It is how the PHY framework finds a PHY, when the controller (say USB)requests
a PHY from the PHY framework.
 
 In this case, it doesn't matter where the platform_device structures
 are created or where the driver source code is.  Let's take a simple
 example.  Suppose the system design includes a PHY named foo.  Then
 the board file could contain:

 struct phy_info { ... } phy_foo;
 EXPORT_SYMBOL_GPL(phy_foo);

 and a header file would contain:

 extern struct phy_info phy_foo;

 The PHY supplier could then call phy_create(phy_foo), and the PHY
 client could call phy_find(phy_foo).  Or something like that; make up
 your own structure tags and function names.

 It's still possible to have conflicts, but now two PHYs with the same
 name (or a misspelled name somewhere) will cause an error at link
 time.

 This is incorrect, sorry. First of all it's a layering violation - you
 export random driver-specific symbols from one driver to another. Then
 
 No, that's not what I said.  Neither the PHY driver nor the controller
 driver exports anything to the other.  Instead, both drivers use data
 exported by the board file.

I think instead we can use the same data while creating the platform data of
the controller and the PHY.
The PHY driver while creating the PHY (using PHY framework) will also pass the
*data* it actually got from the platform data to the framework.
The PHY user driver (USB), while requesting for the PHY (from the PHY
framework) will pass the *data* it got from its platform data.
The PHY framework can do a comparison of the *data* pointers it has and return
the appropriate PHY to the controller.
 
 imagine 4 SoCs - A, B, C, D. There are two PHY types PHY1 and PHY2 and
 there are two types of consumer drivers (e.g. USB host controllers). Now
 consider following mapping:

 SoC PHY consumer
 A   PHY1HOST1
 B   PHY1HOST2
 C   PHY2HOST1
 D   PHY2HOST2

 So we have to be able to use any of the PHYs with any of the host
 drivers. This means you would have to export symbol with the same name
 from both PHY drivers, which obviously would not work in this case,
 because having both drivers enabled (in a multiplatform aware
 configuration) would lead to linking conflict.
 
 You're right; the scheme was too simple.  Instead, the board file must
 export two types of data structures, one for PHYs and one for
 controllers.  Like this:
 
 struct phy_info {
   /* Info for the controller attached to this PHY */
   struct controller_info  *hinfo;
 };
 
 struct controller_info {
   /* Info for the PHY which this controller is attached to */
   struct phy_info *pinfo;
 };
 
 The board file for SoC A would contain:
 
 struct phy_info phy1 = {host1);
 EXPORT_SYMBOL(phy1);
 struct controller_info host1 = {phy1};
 EXPORT_SYMBOL(host1);
 
 The board file for SoC B would contain:
 
 struct phy_info phy1 = {host2);
 EXPORT_SYMBOL(phy1);
 struct controller_info host2 = {phy1};
 EXPORT_SYMBOL(host2);

I meant something like this
struct phy_info {
const char *name;
};

struct phy_platform_data {
.
.
struct phy_info *info;
};

struct usb_controller_platform_data {
.
.
struct phy_info *info;
};

struct phy_info phy_info;

While creating the phy device
struct phy_platform_data phy_data;
phy_data.info = info;
platform_device_add_data(pdev, phy_data, sizeof(*phy_data))
platform_device_add();

While creating the controller device
struct usb_controller_platform_data controller_data;
controller_data.info = info;
platform_device_add_data(pdev, controller_data, 
sizeof(*controller_data))
platform_device_add();

Then modify PHY framework API phy create
phy_create((struct device *dev, const struct phy_ops 

Re: [PATCH 01/15] drivers: phy: add generic PHY framework

2013-07-23 Thread Kishon Vijay Abraham I
Hi Greg,

On Tuesday 23 July 2013 09:48 PM, Greg KH wrote:
 On Tue, Jul 23, 2013 at 08:48:24PM +0530, Kishon Vijay Abraham I wrote:
 Hi,

 On Tuesday 23 July 2013 08:07 PM, Alan Stern wrote:
 On Tue, 23 Jul 2013, Tomasz Figa wrote:

 On Tuesday 23 of July 2013 09:29:32 Tomasz Figa wrote:
 Hi Alan,

 Thanks for helping to clarify the issues here.

 Okay.  Are PHYs _always_ platform devices?

 They can be i2c, spi or any other device types as well.

 In those other cases, presumably there is no platform data associated
 with the PHY since it isn't a platform device.  Then how does the
 kernel know which controller is attached to the PHY?  Is this spelled
 out in platform data associated with the PHY's i2c/spi/whatever parent?
.
.
snip
.
.

  static struct phy *phy_lookup(void *priv) {
  .
  .
  if (phy-priv==priv) //instead of string comparison, we'll use 
 pointer
  return phy;
  }

 PHY driver should be like
  phy_create((dev, ops, pdata-info);

 The controller driver would do
  phy_get(dev, NULL, pdata-info);

 Now the PHY framework will check for a match of *priv* pointer and return 
 the PHY.

 I think this should be possible?
 
 Ick, no.  Why can't you just pass the pointer to the phy itself?  If you
 had a priv pointer to search from, then you could have just passed the
 original phy pointer in the first place, right?
 
 The issue is that a string name is not going to scale at all, as it
 requires hard-coded information that will change over time (as the
 existing clock interface is already showing.)
 
 Please just pass the real phy pointer around, that's what it is there
 for.  Your board binding logic/code should be able to handle this, as
 it somehow was going to do the same thing with a name.

The problem is the board file won't have the *phy* pointer. *phy* pointer is
created at a much later time when the phy driver is probed.

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


Re: [PATCH 01/15] drivers: phy: add generic PHY framework

2013-07-22 Thread Kishon Vijay Abraham I
Hi,

On Monday 22 July 2013 12:52 AM, Alan Stern wrote:
 On Sun, 21 Jul 2013, Sylwester Nawrocki wrote:
 
 What's wrong with the platform_data structure, why can't that be used
 for this?

 At the point the platform data of some driver is initialized, e.g. in
 board setup code the PHY pointer is not known, since the PHY supplier
 driver has not initialized yet.  Even though we wanted to pass pointer
 to a PHY through some notifier call, it would have been not clear
 which PHY user driver should match on such notifier.  A single PHY
 supplier driver can create M PHY objects and this needs to be mapped
 to N PHY user drivers.  This mapping needs to be defined somewhere by
 the system integrator.  It works well with device tree, but except that
 there seems to be no other reliable infrastructure in the kernel to
 define links/dependencies between devices, since device identifiers are
 not known in advance in all cases.

 What Tomasz proposed seems currently most reasonable to me for non-dt.

 Or, if not, we can always add pointers to the platform device structure,
 or even the main 'struct device' as well, that's what it is there for.

 Still we would need to solve a problem which platform device structure
 gets which PHY pointer.
 
 Can you explain the issues in more detail?  I don't fully understand 
 the situation.
 
 Here's what I think I know:
 
   The PHY and the controller it is attached to are both physical
   devices.
 
   The connection between them is hardwired by the system
   manufacturer and cannot be changed by software.
 
   PHYs are generally described by fixed system-specific board
   files or by Device Tree information.  Are they ever discovered
   dynamically?

No. They are created just like any other platform devices are created.
 
   Is the same true for the controllers attached to the PHYs?
   If not -- if both a PHY and a controller are discovered 
   dynamically -- how does the kernel know whether they are 
   connected to each other?

No differences here. Both PHY and controller will have dt information or hwmod
data using which platform devices will be created.
 
   The kernel needs to know which controller is attached to which
   PHY.  Currently this information is represented by name or ID
   strings embedded in platform data.

right. It's embedded in the platform data of the controller.
 
   The PHY's driver (the supplier) uses the platform data to 
   construct a platform_device structure that represents the PHY.  

Currently the driver assigns static labels (corresponding to the label used in
the platform data of the controller).
   Until this is done, the controller's driver (the client) cannot 
   use the PHY.

right.
 
   Since there is no parent-child relation between the PHY and the 
   controller, there is no guarantee that the PHY's driver will be
   ready when the controller's driver wants to use it.  A deferred
   probe may be needed.

right.
 
   The issue (or one of the issues) in this discussion is that 
   Greg does not like the idea of using names or IDs to associate
   PHYs with controllers, because they are too prone to
   duplications or other errors.  Pointers are more reliable.
 
   But pointers to what?  Since the only data known to be 
   available to both the PHY driver and controller driver is the
   platform data, the obvious answer is a pointer to platform data
   (either for the PHY or for the controller, or maybe both).

hmm.. it's not going to be simple though as the platform device for the PHY and
controller can be created in entirely different places. e.g., in some cases the
PHY device is a child of some mfd core device (the device will be created in
drivers/mfd) and the controller driver (usually) is created in board file. I
guess then we have to come up with something to share a pointer in two
different files.
 
 Probably some of the details above are wrong; please indicate where I
 have gone astray.  Also, I'm not clear about the role played by various 
 APIs.  For example, where does phy_create() fit into this picture?

phy_create is the API by which the PHY's driver (the supplier) hook into the
PHY framework. It's like the controller driver will always interact with the
PHY driver through the PHY framework.

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


Re: [PATCH 01/15] drivers: phy: add generic PHY framework

2013-07-22 Thread Kishon Vijay Abraham I
Hi,

On Monday 22 July 2013 08:34 PM, Greg KH wrote:
 On Mon, Jul 22, 2013 at 12:55:18PM +0530, Kishon Vijay Abraham I wrote:
 The issue (or one of the issues) in this discussion is that 
 Greg does not like the idea of using names or IDs to associate
 PHYs with controllers, because they are too prone to
 duplications or other errors.  Pointers are more reliable.

 But pointers to what?  Since the only data known to be 
 available to both the PHY driver and controller driver is the
 platform data, the obvious answer is a pointer to platform data
 (either for the PHY or for the controller, or maybe both).

 hmm.. it's not going to be simple though as the platform device for the PHY 
 and
 controller can be created in entirely different places. e.g., in some cases 
 the
 PHY device is a child of some mfd core device (the device will be created in
 drivers/mfd) and the controller driver (usually) is created in board file. I
 guess then we have to come up with something to share a pointer in two
 different files.
 
 What's wrong with using the platform_data structure that is unique to
 all boards (see include/platform_data/ for examples)?  Isn't that what
 this structure is there for?

Alright. I got some ideas from Alan Stern. I'll use it with platform_data and
repost the series.

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


Re: [PATCH 01/15] drivers: phy: add generic PHY framework

2013-07-22 Thread Kishon Vijay Abraham I
Hi,

On Monday 22 July 2013 08:14 PM, Alan Stern wrote:
 On Mon, 22 Jul 2013, Kishon Vijay Abraham I wrote:
 
 The PHY and the controller it is attached to are both physical
 devices.

 The connection between them is hardwired by the system
 manufacturer and cannot be changed by software.

 PHYs are generally described by fixed system-specific board
 files or by Device Tree information.  Are they ever discovered
 dynamically?

 No. They are created just like any other platform devices are created.
 
 Okay.  Are PHYs _always_ platform devices?

Not always. It can be any other device also.
 
 Is the same true for the controllers attached to the PHYs?
 If not -- if both a PHY and a controller are discovered 
 dynamically -- how does the kernel know whether they are 
 connected to each other?

 No differences here. Both PHY and controller will have dt information or 
 hwmod
 data using which platform devices will be created.

 The kernel needs to know which controller is attached to which
 PHY.  Currently this information is represented by name or ID
 strings embedded in platform data.

 right. It's embedded in the platform data of the controller.
 
 It must also be embedded in the PHY's platform data somehow.  
 Otherwise, how would the kernel know which PHY to use?
 
 The PHY's driver (the supplier) uses the platform data to 
 construct a platform_device structure that represents the PHY.  

 Currently the driver assigns static labels (corresponding to the label used 
 in
 the platform data of the controller).
 Until this is done, the controller's driver (the client) cannot 
 use the PHY.

 right.

 Since there is no parent-child relation between the PHY and the 
 controller, there is no guarantee that the PHY's driver will be
 ready when the controller's driver wants to use it.  A deferred
 probe may be needed.

 right.

 The issue (or one of the issues) in this discussion is that 
 Greg does not like the idea of using names or IDs to associate
 PHYs with controllers, because they are too prone to
 duplications or other errors.  Pointers are more reliable.

 But pointers to what?  Since the only data known to be 
 available to both the PHY driver and controller driver is the
 platform data, the obvious answer is a pointer to platform data
 (either for the PHY or for the controller, or maybe both).

 hmm.. it's not going to be simple though as the platform device for the PHY 
 and
 controller can be created in entirely different places. e.g., in some cases 
 the
 PHY device is a child of some mfd core device (the device will be created in
 drivers/mfd) and the controller driver (usually) is created in board file. I
 guess then we have to come up with something to share a pointer in two
 different files.
 
 The ability for two different source files to share a pointer to a data 
 item defined in a third source file has been around since long before 
 the C language was invented.  :-)
 
 In this case, it doesn't matter where the platform_device structures 
 are created or where the driver source code is.  Let's take a simple 
 example.  Suppose the system design includes a PHY named foo.  Then 
 the board file could contain:
 
 struct phy_info { ... } phy_foo;
 EXPORT_SYMBOL_GPL(phy_foo);
 
 and a header file would contain:
 
 extern struct phy_info phy_foo;
 
 The PHY supplier could then call phy_create(phy_foo), and the PHY 
 client could call phy_find(phy_foo).  Or something like that; make up 
 your own structure tags and function names.

Alright. Thanks for the hint :-)

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


Re: [PATCH 01/15] drivers: phy: add generic PHY framework

2013-07-21 Thread Kishon Vijay Abraham I

Hi,

On Sunday 21 July 2013 04:01 PM, Tomasz Figa wrote:

Hi,

On Saturday 20 of July 2013 19:59:10 Greg KH wrote:

On Sat, Jul 20, 2013 at 10:32:26PM -0400, Alan Stern wrote:

On Sat, 20 Jul 2013, Greg KH wrote:

That should be passed using platform data.


Ick, don't pass strings around, pass pointers.  If you have
platform
data you can get to, then put the pointer there, don't use a
name.


I don't think I understood you here :-s We wont have phy pointer
when we create the device for the controller no?(it'll be done in
board file). Probably I'm missing something.


Why will you not have that pointer?  You can't rely on the name as
the device id will not match up, so you should be able to rely on
the pointer being in the structure that the board sets up, right?

Don't use names, especially as ids can, and will, change, that is
going
to cause big problems.  Use pointers, this is C, we are supposed to
be
doing that :)


Kishon, I think what Greg means is this:  The name you are using must
be stored somewhere in a data structure constructed by the board file,
right?  Or at least, associated with some data structure somehow.
Otherwise the platform code wouldn't know which PHY hardware
corresponded to a particular name.

Greg's suggestion is that you store the address of that data structure
in the platform data instead of storing the name string.  Have the
consumer pass the data structure's address when it calls phy_create,
instead of passing the name.  Then you don't have to worry about two
PHYs accidentally ending up with the same name or any other similar
problems.


Close, but the issue is that whatever returns from phy_create() should
then be used, no need to call any find functions, as you can just use
the pointer that phy_create() returns.  Much like all other class api
functions in the kernel work.


I think there is a confusion here about who registers the PHYs.

All platform code does is registering a platform/i2c/whatever device,
which causes a driver (located in drivers/phy/) to be instantiated. Such
drivers call phy_create(), usually in their probe() callbacks, so
platform_code has no way (and should have no way, for the sake of
layering) to get what phy_create() returns.


right.


IMHO we need a lookup method for PHYs, just like for clocks, regulators,
PWMs or even i2c busses because there are complex cases when passing just
a name using platform data will not work. I would second what Stephen said
[1] and define a structure doing things in a DT-like way.

Example;

[platform code]

static const struct phy_lookup my_phy_lookup[] = {
PHY_LOOKUP(s3c-hsotg.0, otg, samsung-usbphy.1, phy.2),


The only problem here is that if *PLATFORM_DEVID_AUTO* is used while 
creating the device, the ids in the device name would change and 
PHY_LOOKUP wont be useful.


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


Re: [PATCH 01/15] drivers: phy: add generic PHY framework

2013-07-19 Thread Kishon Vijay Abraham I
Hi,

On Friday 19 July 2013 11:59 AM, Greg KH wrote:
 On Fri, Jul 19, 2013 at 11:25:44AM +0530, Kishon Vijay Abraham I wrote:
 Hi,

 On Friday 19 July 2013 11:13 AM, Greg KH wrote:
 On Fri, Jul 19, 2013 at 11:07:10AM +0530, Kishon Vijay Abraham I wrote:
 +  ret = dev_set_name(phy-dev, %s.%d, dev_name(dev), id);

 Your naming is odd, no phy anywhere in it?  You rely on the sender to
 never send a duplicate name.id pair?  Why not create your own ids based
 on the number of phys in the system, like almost all other classes and
 subsystems do?

 hmm.. some PHY drivers use the id they provide to perform some of their
 internal operation as in [1] (This is used only if a single PHY provider
 implements multiple PHYS). Probably I'll add an option like 
 PLATFORM_DEVID_AUTO
 to give the PHY drivers an option to use auto id.

 [1] -
 http://archive.arm.linux.org.uk/lurker/message/20130628.134308.4a8f7668.ca.html

 No, who cares about the id?  No one outside of the phy core ever should,
 because you pass back the only pointer that they really do care about,
 if they need to do anything with the device.  Use that, and then you can

 hmm.. ok.

 rip out all of the search for a phy by a string logic, as that's not

 Actually this is needed for non-dt boot case. In the case of dt boot, we 
 use a
 phandle by which the controller can get a reference to the phy. But in the 
 case
 of non-dt boot, the controller can get a reference to the phy only by 
 label.

 I don't understand.  They registered the phy, and got back a pointer to
 it.  Why can't they save it in their local structure to use it again
 later if needed?  They should never have to ask for the device, as the

 One is a *PHY provider* driver which is a driver for some PHY device. This 
 will
 use phy_create to create the phy.
 The other is a *PHY consumer* driver which might be any controller driver 
 (can
 be USB/SATA/PCIE). The PHY consumer will use phy_get to get a reference to 
 the
 phy (by *phandle* in the case of dt boot and *label* in the case of non-dt 
 boot).
 device id might be unknown if there are multiple devices in the system.

 I agree with you on the device id part. That need not be known to the PHY 
 driver.
 
 How does a consumer know which label to use in a non-dt system if
 there are multiple PHYs in the system?

That should be passed using platform data.
 
 Do you have any drivers that are non-dt using this yet?

yes. tw4030 (used in OMAP3) supports non-dt.
[PATCH 04/15] ARM: OMAP: USB: Add phy binding information
[PATCH 06/15] usb: musb: omap2430: use the new generic PHY framework
of this patch series shows how it's used.

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


Re: [PATCH v2 0/4] usb: musb: fix USB enumeration issue in OMAP3 platform

2013-07-19 Thread Kishon Vijay Abraham I
Felipe,

On Tuesday 16 July 2013 06:12 PM, Felipe Balbi wrote:
 Hi,
 
 On Tue, Jul 16, 2013 at 11:22:38AM +0530, Kishon Vijay Abraham I wrote:
 Tony,

 On Monday 08 July 2013 04:44 PM, Kishon Vijay Abraham I wrote:
 This series fixes the USB enumeration issue caused because of the controller
 not able to get a reference to the PHY because of incorrect binding in the
 board file.

 In the case of non-dt boot, the platform specific initialization file
 (board file) will do usb_bind_phy that binds the usb controller with the
 PHY using device names. After the device names are created using 
 PLATFORM_DEVID_AUTO, our original method of binding by device names doesn't
 work reliably (since the device name changes). Hence the usb controller
 is made to use labels for getting the PHY.

 Here the PHY name is added in the plat data of USB controller device which
 should be used by the controller driver to get the PHY.
 Two new APIs usb_get_phy_by_name and devm_usb_get_phy_by_name are added to
 be used by the controller to get the PHY by name.

 You haven't picked this patch series?
 
 yeah and now it's too much to send during the -rc series. Here's what we
 can do, we can to minimum fix for -rc series (patching the names again)

There are a lot of different boards available using OMAP3 and the device names
(PHY and MUSB) vary across each board (apparently). It will be difficult to
find the device names (for PHY and MUSB) for all the different boards available
(partly because of non-availability of all the boards) and test it.

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


Re: [PATCH v2 0/4] Add phy support for AM335X platform using Generic PHy framework

2013-07-19 Thread Kishon Vijay Abraham I
Hi,

On Friday 19 July 2013 06:04 PM, George Cherian wrote:
 This patch series adds phy support for AM335X platform.
 This patch series is based on Generic PHY framework [1].

There are some comments on the generic PHY framework. So you might have to
adapt it once those comments are fixed.

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


Re: [PATCH v2 1/4] usb: phy: phy-omap-control: Add API to power and wakeup

2013-07-19 Thread Kishon Vijay Abraham I
Hi,

On Friday 19 July 2013 06:04 PM, George Cherian wrote:
 on/off USB PHY for AM335X
 
 Add APIs to
   -power on/off USB PHY for AM335X
   -enable/disable PHY wakeup.
 
 This API will be called from phy-am-usb driver.
 
 Signed-off-by: George Cherian george.cher...@ti.com
 ---
  drivers/usb/phy/phy-omap-control.c   | 67 
 
  include/linux/usb/omap_control_usb.h | 24 +
  2 files changed, 91 insertions(+)
 
 diff --git a/drivers/usb/phy/phy-omap-control.c 
 b/drivers/usb/phy/phy-omap-control.c
 index 1419ced..4f2502c 100644
 --- a/drivers/usb/phy/phy-omap-control.c
 +++ b/drivers/usb/phy/phy-omap-control.c
 @@ -46,6 +46,73 @@ struct device *omap_get_control_dev(void)
  EXPORT_SYMBOL_GPL(omap_get_control_dev);
  
  /**
 + * omap_control_am335x_phy_wkup - PHY wakeup on/off  using control
 + *   module
 + * @dev: the control module device
 + * @on: 0 to off and 1 to on PHY wakeup feature

%s/off/disable %s/on/enable
 + * @id: phy id 0 or 1 for phy instance 0 and 1 repectively
 + *
 + * AM PHY driver should call this API to enable or disable PHY wakeup.
 + */
 +void omap_control_am335x_phy_wkup(struct device *dev, bool on, u8 id)
 +{
 + u32 val;
 + u32 *phy_wkup_reg;
 + struct omap_control_usb *control_usb = dev_get_drvdata(dev);
 +
 + if (control_usb-type != OMAP_CTRL_DEV_TYPE3 || id  0 || id  1)
 + return;
 +
 + phy_wkup_reg = control_usb-dev_conf + AM335X_USB_WKUP_OFFSET;
 + val = readl(phy_wkup_reg);
 +
 + if (on)
 + val |= id ? AM335X_USB1_WKUP_CTRL_ENABLE :
 + AM335X_USB0_WKUP_CTRL_ENABLE;
 +  else
 + val = id ? ~AM335X_USB1_WKUP_CTRL_ENABLE :
 + ~AM335X_USB0_WKUP_CTRL_ENABLE;
 +
 +

You really need two blank spaces here?
 + writel(val, phy_wkup_reg);
 +}
 +EXPORT_SYMBOL_GPL(omap_control_am335x_phy_wkup);
 +
 +/**
 + * omap_control_am335x_phy_power - power on/off the serializer using control
 + *   module
 + * @dev: the control module device
 + * @on: 0 to off and 1 to on based on powering on or off the PHY
 + * @id: phy id 0 or 1 for phy instance 0 and 1 repectively
 + *
 + * AM PHY driver should call this API to power on or off the PHY.
 + */
 +void omap_control_am335x_phy_power(struct device *dev, bool on, u8 id)
 +{
 + u32 val;
 + u32 *phy_pwr_reg;
 + struct omap_control_usb *control_usb = dev_get_drvdata(dev);
 +
 + if (control_usb-type != OMAP_CTRL_DEV_TYPE3 || id  0 || id  1)
 + return;
 +
 + phy_pwr_reg = GET_PHY_POWER_REG(control_usb-dev_conf, id);
 + val = readl(phy_pwr_reg);
 +
 + if (on) {
 + val = ~(AM335X_USBPHY_CM_PWRDN | AM335X_USBPHY_OTG_PWRDN);
 + val |= AM335X_USBPHY_OTGVDET_EN |
 + AM335X_USBPHY_OTGSESSEND_EN;
 + } else
 + val |= AM335X_USBPHY_CM_PWRDN | AM335X_USBPHY_OTG_PWRDN;
 +
 +
ditto.
 + writel(val, phy_pwr_reg);
 +}
 +EXPORT_SYMBOL_GPL(omap_control_am335x_phy_power);
 +
 +
ditto.
 +/**
   * omap_control_usb3_phy_power - power on/off the serializer using control
   *   module
   * @dev: the control module device
 diff --git a/include/linux/usb/omap_control_usb.h 
 b/include/linux/usb/omap_control_usb.h
 index 27b5b8c..a92b417 100644
 --- a/include/linux/usb/omap_control_usb.h
 +++ b/include/linux/usb/omap_control_usb.h
 @@ -45,6 +45,7 @@ enum omap_control_usb_mode {
  /* To differentiate ctrl module IP having either mailbox or USB3 PHY power */
  #define  OMAP_CTRL_DEV_TYPE1 0x1
  #define  OMAP_CTRL_DEV_TYPE2 0x2
 +#define  OMAP_CTRL_DEV_TYPE3 0x3
  
  #define  OMAP_CTRL_DEV_PHY_PDBIT(0)
  
 @@ -63,10 +64,23 @@ enum omap_control_usb_mode {
  #define  OMAP_CTRL_USB3_PHY_TX_RX_POWERON0x3
  #define  OMAP_CTRL_USB3_PHY_TX_RX_POWEROFF   0x0
  
 +#define GET_PHY_POWER_REG(base, id)  ((u32 *)base + (id * 2))

how about
#define GET_PHY_POWER_REG(base, id) ((u32 *)(base) + ((id) * 2))
 +#define AM335X_USBPHY_CM_PWRDN   (1  0)
 +#define AM335X_USBPHY_OTG_PWRDN  (1  1)
 +#define AM335X_USBPHY_OTGVDET_EN (1  19)
 +#define AM335X_USBPHY_OTGSESSEND_EN  (1  20)
 +#define AM335X_USB_WKUP_OFFSET   0xA
 +#define AM335X_USB0_WKUP_CTRL_ENABLE (1  0)
 +#define AM335X_USB1_WKUP_CTRL_ENABLE (1  8)
 +
 +
 +

too many blank lines...

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


Re: [PATCH v2 2/4] phy: phy-amxxxx-usb: Add PHY driver for amxxxx platform

2013-07-19 Thread Kishon Vijay Abraham I
Hi,

On Friday 19 July 2013 06:04 PM, George Cherian wrote:
 Adds phy driver support for am33xx platform, the host/device
 peripheral controller shall get this phy object to control the phy
 operations.
 
 Signed-off-by: George Cherian george.cher...@ti.com
 ---
  drivers/phy/Kconfig  |  12 +++
  drivers/phy/Makefile |   1 +
  drivers/phy/phy-am-usb.c | 222 
 +++
  3 files changed, 235 insertions(+)
  create mode 100644 drivers/phy/phy-am-usb.c
 
 diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig
 index 5f85909..55087ab 100644
 --- a/drivers/phy/Kconfig
 +++ b/drivers/phy/Kconfig
 @@ -11,3 +11,15 @@ menuconfig GENERIC_PHY
 devices present in the kernel. This layer will have the generic
 API by which phy drivers can create PHY using the phy framework and
 phy users can obtain reference to the PHY.
 +if GENERIC_PHY

Greg has some comments about the generic PHY framework. So instead of having
like this, you might have to select GENERIC_PHY in the Kconfig of your phy 
driver.
 +
 +config PHY_AM_USB
 + tristate AM USB2 PHY Driver
 + depends on SOC_AM33XX
 + help
 +   Enable this to support the transceiver that is part of SOC. This
 +   phy supports all LS/FS/HS speed and also supports OTG functionality.
 +   The USB OTG controller communicates with this phy through stand UTMI
 +   interface.
 +
 +endif
 diff --git a/drivers/phy/Makefile b/drivers/phy/Makefile
 index 9e9560f..471c525 100644
 --- a/drivers/phy/Makefile
 +++ b/drivers/phy/Makefile
 @@ -3,3 +3,4 @@
  #
  
  obj-$(CONFIG_GENERIC_PHY)+= phy-core.o
 +obj-$(CONFIG_PHY_AM_USB) += phy-am-usb.o
 diff --git a/drivers/phy/phy-am-usb.c b/drivers/phy/phy-am-usb.c
 new file mode 100644
 index 000..d0b0749
 --- /dev/null
 +++ b/drivers/phy/phy-am-usb.c
 @@ -0,0 +1,222 @@
 +/*
 + * phy-am-usb.c - USB PHY, talking to usb controller in AMXXX.
 + *
 + * Copyright (C) 2013 Texas Instruments Incorporated - http://www.ti.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; either version 2 of the License, or
 + * (at your option) any later version.
 + *
 + * Author: George Cherian george.cher...@ti.com
 + *
 + * 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/platform_device.h
 +#include linux/of.h
 +#include linux/usb/otg.h
 +#include linux/clk.h
 +#include linux/pm_runtime.h
 +#include linux/usb/omap_control_usb.h
 +#include linux/phy/phy.h
 +
 +struct am_usb {
 + struct usb_phy  phy;
 + struct device   *dev;
 + struct device   *control_dev;
 + struct clk  *optclk;
 + u32 id;
 +};
 +
 +#define phy_to_amphy(x)  container_of((x), struct am_phy, phy)
 +
 +

additional blank line..
 +static int am_usb_set_host(struct usb_otg *otg, struct usb_bus *host)
 +{
 + struct usb_phy  *phy = otg-phy;
 +
 + otg-host = host;
 + if (!host)
 + phy-state = OTG_STATE_UNDEFINED;
 +
 + return 0;
 +}
 +
 +static int am_usb_set_peripheral(struct usb_otg *otg,
 + struct usb_gadget *gadget)
 +{
 + struct usb_phy  *phy = otg-phy;
 +
 + otg-gadget = gadget;
 + if (!gadget)
 + phy-state = OTG_STATE_UNDEFINED;
 +
 + return 0;
 +}
 +
 +
 +
ditto..
 +static int am_usb_power_off(struct phy *x)
 +{
 + struct am_usb *phy = phy_get_drvdata(x);
 +
 + omap_control_am335x_phy_power(phy-control_dev, 0, phy-id);
 +
 + return 0;
 +}
 +
 +static int am_usb_power_on(struct phy *x)
 +{
 + struct am_usb *phy = phy_get_drvdata(x);
 +
 + omap_control_am335x_phy_power(phy-control_dev, 1, phy-id);
 +
 + return 0;
 +}
 +
 +static struct phy_ops ops = {
 + .power_on   = am_usb_power_on,
 + .power_off  = am_usb_power_off,
 + .owner  = THIS_MODULE,
 +};
 +
 +static int am_usb2_probe(struct platform_device *pdev)
 +{
 + struct device_node *np = pdev-dev.of_node;
 + struct am_usb   *phy;
 + struct phy  *generic_phy;
 + struct usb_otg  *otg;
 + struct phy_provider *phy_provider;
 +
 + phy = devm_kzalloc(pdev-dev, sizeof(*phy), GFP_KERNEL);

You might have to bail out of memory allocation fails.
 +
 + otg = devm_kzalloc(pdev-dev, sizeof(*otg), GFP_KERNEL);

ditto.
 +
 + phy-dev= pdev-dev;
 +
 + if (np)
 + of_property_read_u32(np, id, phy-id);
 +
 + phy-phy.dev= phy-dev;
 + phy-phy.label  = am-usb2;
 + 

Re: [PATCH v2 3/4] arm: dts: Add USB phy nodes for AM33XX

2013-07-19 Thread Kishon Vijay Abraham I
Hi,

On Friday 19 July 2013 06:04 PM, George Cherian wrote:
 Add phy nodes for AM33XX platform and split the musb nodes
 per instance.
 
 Signed-off-by: Sebastian Andrzej Siewior bige...@linutronix.de
 Signed-off-by: George Cherian george.cher...@ti.com
 ---
  arch/arm/boot/dts/am33xx.dtsi | 68 
 +--
  1 file changed, 53 insertions(+), 15 deletions(-)
 
 diff --git a/arch/arm/boot/dts/am33xx.dtsi b/arch/arm/boot/dts/am33xx.dtsi
 index 8e1248f..e3890c4 100644
 --- a/arch/arm/boot/dts/am33xx.dtsi
 +++ b/arch/arm/boot/dts/am33xx.dtsi
 @@ -326,21 +326,59 @@
   status = disabled;
   };
  
 - usb@4740 {
 - compatible = ti,musb-am33xx;
 - reg = 0x4740 0x1000/* usbss */
 -0x47401000 0x800 /* musb instance 0 */
 -0x47401800 0x800;   /* musb instance 1 */
 - interrupts = 17/* usbss */
 -   18/* musb instance 0 */
 -   19;  /* musb instance 1 */
 - multipoint = 1;
 - num-eps = 16;
 - ram-bits = 12;
 - port0-mode = 3;
 - port1-mode = 3;
 - power = 250;
 - ti,hwmods = usb_otg_hs;
 + phy1: am335x-usb0@44e10620 {

*44e10620* is not needed if you are not having the reg property.
 + compatible = ti,am335x-usb2;
 + #phy-cells = 0;
 + id= 0;
 + };
 +
 + phy2: am335x-usb1@44e10628 {
 + compatible = ti,am335x-usb2;

ditto..
 + #phy-cells = 0;
 + id= 1;
 + };
 +
 + omap_control_usb: omap-control-usb@44e10620 {
 + compatible = ti,omap-control-usb;
 + reg = 0x44e10620 0x10;
 + reg-names = control_dev_conf;
 + ti,type = 3;
 + };
 +
 +musb: usb@4740 {
 +compatible = ti,musb-am33xx;
 +reg = 0x4740 0x1000;
 +ranges;
 +#address-cells = 1;
 +#size-cells = 1;
 +interrupts = 17;
 +ti,hwmods = usb_otg_hs;
 +
 +usb0@47401000 {
 +reg = 0x47401000 0x800;
 +interrupts = 18;
 +interrupt-names = mc;
 +multipoint = 1;
 +num-eps = 16;
 +ram-bits = 12;
 +port-mode = 3;
 +power = 250;
 +phys = phy1;
 + phy-names = am335x-usb0;

Looks like alignment has gone wrong here.
 +};
 +
 +usb1@47401800 {
 +reg = 0x47401800 0x800;
 +interrupts = 19;
 +interrupt-names = mc;
 +multipoint = 1;
 +num-eps = 16;
 +ram-bits = 12;
 +port-mode = 3;
 +power = 250;
 +phys = phy2;
 + phy-names = am335x-usb1;
ditto.

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


Re: [PATCH v2 4/4] usb: musb: dsps: Remove the phy control from glue and add phy driver APIs

2013-07-19 Thread Kishon Vijay Abraham I
On Friday 19 July 2013 06:04 PM, George Cherian wrote:
 Remove usb phy control module access from platform glue.
 The same is now done using am phy driver and phy-omap-control.
 Adapt the driver to the split dt nodes.

This patch should be split.
 
 Signed-off-by: Sebastian Andrzej Siewior bige...@linutronix.de
 Signed-off-by: George Cherian george.cher...@ti.com
 ---
  drivers/usb/musb/musb_dsps.c | 150 
 ---
  1 file changed, 55 insertions(+), 95 deletions(-)
 
 diff --git a/drivers/usb/musb/musb_dsps.c b/drivers/usb/musb/musb_dsps.c
 index 41f135a..6bec458 100644
 --- a/drivers/usb/musb/musb_dsps.c
 +++ b/drivers/usb/musb/musb_dsps.c
 @@ -43,6 +43,7 @@
  #include linux/of.h
  #include linux/of_device.h
  #include linux/of_address.h
 +#include linux/of_irq.h
  
  #include musb_core.h
  
 @@ -110,8 +111,6 @@ struct dsps_musb_wrapper {
   /* miscellaneous stuff */
   u32 musb_core_offset;
   u8  poll_seconds;
 - /* number of musb instances */
 - u8  instances;
  };
  
  /**
 @@ -123,49 +122,11 @@ struct dsps_glue {
   const struct dsps_musb_wrapper *wrp; /* wrapper register offsets */
   struct timer_list timer[2]; /* otg_workaround timer */
   unsigned long last_timer[2];/* last timer data for each instance */
 - u32 __iomem *usb_ctrl[2];
  };
  
 -#define  DSPS_AM33XX_CONTROL_MODULE_PHYS_0   0x44e10620
 -#define  DSPS_AM33XX_CONTROL_MODULE_PHYS_1   0x44e10628
 +#define glue_to_musb(g, i)   platform_get_drvdata(g-musb[i])
  
 -static const resource_size_t dsps_control_module_phys[] = {
 - DSPS_AM33XX_CONTROL_MODULE_PHYS_0,
 - DSPS_AM33XX_CONTROL_MODULE_PHYS_1,
 -};
 -
 -#define USBPHY_CM_PWRDN  (1  0)
 -#define USBPHY_OTG_PWRDN (1  1)
 -#define USBPHY_OTGVDET_EN(1  19)
 -#define USBPHY_OTGSESSEND_EN (1  20)
 -
 -/**
 - * musb_dsps_phy_control - phy on/off
 - * @glue: struct dsps_glue *
 - * @id: musb instance
 - * @on: flag for phy to be switched on or off
 - *
 - * This is to enable the PHY using usb_ctrl register in system control
 - * module space.
 - *
 - * XXX: This function will be removed once we have a seperate driver for
 - * control module
 - */
 -static void musb_dsps_phy_control(struct dsps_glue *glue, u8 id, u8 on)
 -{
 - u32 usbphycfg;
 -
 - usbphycfg = readl(glue-usb_ctrl[id]);
 -
 - if (on) {
 - usbphycfg = ~(USBPHY_CM_PWRDN | USBPHY_OTG_PWRDN);
 - usbphycfg |= USBPHY_OTGVDET_EN | USBPHY_OTGSESSEND_EN;
 - } else {
 - usbphycfg |= USBPHY_CM_PWRDN | USBPHY_OTG_PWRDN;
 - }
  
 - writel(usbphycfg, glue-usb_ctrl[id]);
 -}
  /**
   * dsps_musb_enable - enable interrupts
   */
 @@ -411,16 +372,28 @@ static int dsps_musb_init(struct musb *musb)
   void __iomem *reg_base = musb-ctrl_base;
   u32 rev, val;
   int status;
 + char phyname[12];
  
   /* mentor core register starts at offset of 0x400 from musb base */
   musb-mregs += wrp-musb_core_offset;
  
 - /* NOP driver needs change if supporting dual instance */
 - usb_nop_xceiv_register();
 - musb-xceiv = usb_get_phy(USB_PHY_TYPE_USB2);
 + snprintf(phyname , 12, am335x-usb%d, pdev-id);
 +
 + if (dev-of_node) {
 + musb-phy = devm_phy_get(dev, phyname);
 + musb-xceiv = devm_usb_get_phy_by_phandle(dev,
 + phys, 0);
 + } else {
 + musb-phy = devm_phy_get(dev, musb-phy_label);
 + musb-xceiv = devm_usb_get_phy_dev(dev, pdev-id);
 + }
 +
   if (IS_ERR_OR_NULL(musb-xceiv))
   return -EPROBE_DEFER;
  
 + if (IS_ERR_OR_NULL(musb-phy))
 + return -EPROBE_DEFER;
 +
   /* Returns zero if e.g. not clocked */
   rev = dsps_readl(reg_base, wrp-revision);
   if (!rev) {
 @@ -434,7 +407,8 @@ static int dsps_musb_init(struct musb *musb)
   dsps_writel(reg_base, wrp-control, (1  wrp-reset));
  
   /* Start the on-chip PHY and its PLL. */
 - musb_dsps_phy_control(glue, pdev-id, 1);
 + phy_init(musb-phy);
 + phy_power_on(musb-phy);
  
   musb-isr = dsps_interrupt;
  
 @@ -448,8 +422,7 @@ static int dsps_musb_init(struct musb *musb)
  
   return 0;
  err0:
 - usb_put_phy(musb-xceiv);
 - usb_nop_xceiv_unregister();
 + devm_phy_put(dev-parent, musb-phy);
   return status;
  }
  
 @@ -462,11 +435,8 @@ static int dsps_musb_exit(struct musb *musb)
   del_timer_sync(glue-timer[pdev-id]);
  
   /* Shutdown the on-chip PHY and its PLL. */
 - musb_dsps_phy_control(glue, pdev-id, 0);
 -
 - /* NOP driver needs change if supporting dual instance */
 - usb_put_phy(musb-xceiv);
 - usb_nop_xceiv_unregister();
 + phy_power_off(musb-phy);
 + phy_exit(musb-phy);
  
   return 0;
  }
 @@ -483,49 +453,34 @@ static struct musb_platform_ops dsps_ops = {
  
  static u64 musb_dmamask = 

Re: [PATCH 01/15] drivers: phy: add generic PHY framework

2013-07-19 Thread Kishon Vijay Abraham I

Hi,

On Friday 19 July 2013 09:24 PM, Stephen Warren wrote:

On 07/19/2013 12:36 AM, Kishon Vijay Abraham I wrote:

Hi,

On Friday 19 July 2013 11:59 AM, Greg KH wrote:

On Fri, Jul 19, 2013 at 11:25:44AM +0530, Kishon Vijay Abraham I wrote:

Hi,

On Friday 19 July 2013 11:13 AM, Greg KH wrote:

On Fri, Jul 19, 2013 at 11:07:10AM +0530, Kishon Vijay Abraham I wrote:

+   ret = dev_set_name(phy-dev, %s.%d, dev_name(dev), id);


Your naming is odd, no phy anywhere in it?  You rely on the sender to
never send a duplicate name.id pair?  Why not create your own ids based
on the number of phys in the system, like almost all other classes and
subsystems do?


hmm.. some PHY drivers use the id they provide to perform some of their
internal operation as in [1] (This is used only if a single PHY provider
implements multiple PHYS). Probably I'll add an option like PLATFORM_DEVID_AUTO
to give the PHY drivers an option to use auto id.

[1] -
http://archive.arm.linux.org.uk/lurker/message/20130628.134308.4a8f7668.ca.html


No, who cares about the id?  No one outside of the phy core ever should,
because you pass back the only pointer that they really do care about,
if they need to do anything with the device.  Use that, and then you can


hmm.. ok.


rip out all of the search for a phy by a string logic, as that's not


Actually this is needed for non-dt boot case. In the case of dt boot, we use a
phandle by which the controller can get a reference to the phy. But in the case
of non-dt boot, the controller can get a reference to the phy only by label.


I don't understand.  They registered the phy, and got back a pointer to
it.  Why can't they save it in their local structure to use it again
later if needed?  They should never have to ask for the device, as the


One is a *PHY provider* driver which is a driver for some PHY device. This will
use phy_create to create the phy.
The other is a *PHY consumer* driver which might be any controller driver (can
be USB/SATA/PCIE). The PHY consumer will use phy_get to get a reference to the
phy (by *phandle* in the case of dt boot and *label* in the case of non-dt 
boot).

device id might be unknown if there are multiple devices in the system.


I agree with you on the device id part. That need not be known to the PHY 
driver.


How does a consumer know which label to use in a non-dt system if
there are multiple PHYs in the system?


That should be passed using platform data.


I don't think that's right. That's just like passing clock names in
platform data, which I believe is frowned upon.

Instead, why not take the approach that e.g. regulators have taken? Each
driver defines the names of the objects that it requires. There is a
table (registered by a board file) that has lookup key (device name,


We were using a similar approach with USB PHY layer but things started 
breaking after the device names are created using PLATFORM_DEVID_AUTO. 
Now theres no way to reliably know the device names in advance.
Btw I had such device name binding in my v3 of this patch series [1] and 
had some discussion with Grant during that time [2].


[1] - 
http://archive.arm.linux.org.uk/lurker/message/20130320.091200.721a6fb5.hu.html

[2] - https://lkml.org/lkml/2013/4/22/26

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


Re: [PATCH 01/15] drivers: phy: add generic PHY framework

2013-07-19 Thread Kishon Vijay Abraham I

Hi,

On Saturday 20 July 2013 05:20 AM, Greg KH wrote:

On Fri, Jul 19, 2013 at 12:06:01PM +0530, Kishon Vijay Abraham I wrote:

Hi,

On Friday 19 July 2013 11:59 AM, Greg KH wrote:

On Fri, Jul 19, 2013 at 11:25:44AM +0530, Kishon Vijay Abraham I wrote:

Hi,

On Friday 19 July 2013 11:13 AM, Greg KH wrote:

On Fri, Jul 19, 2013 at 11:07:10AM +0530, Kishon Vijay Abraham I wrote:

+   ret = dev_set_name(phy-dev, %s.%d, dev_name(dev), id);


Your naming is odd, no phy anywhere in it?  You rely on the sender to
never send a duplicate name.id pair?  Why not create your own ids based
on the number of phys in the system, like almost all other classes and
subsystems do?


hmm.. some PHY drivers use the id they provide to perform some of their
internal operation as in [1] (This is used only if a single PHY provider
implements multiple PHYS). Probably I'll add an option like PLATFORM_DEVID_AUTO
to give the PHY drivers an option to use auto id.

[1] -
http://archive.arm.linux.org.uk/lurker/message/20130628.134308.4a8f7668.ca.html


No, who cares about the id?  No one outside of the phy core ever should,
because you pass back the only pointer that they really do care about,
if they need to do anything with the device.  Use that, and then you can


hmm.. ok.


rip out all of the search for a phy by a string logic, as that's not


Actually this is needed for non-dt boot case. In the case of dt boot, we use a
phandle by which the controller can get a reference to the phy. But in the case
of non-dt boot, the controller can get a reference to the phy only by label.


I don't understand.  They registered the phy, and got back a pointer to
it.  Why can't they save it in their local structure to use it again
later if needed?  They should never have to ask for the device, as the


One is a *PHY provider* driver which is a driver for some PHY device. This will
use phy_create to create the phy.
The other is a *PHY consumer* driver which might be any controller driver (can
be USB/SATA/PCIE). The PHY consumer will use phy_get to get a reference to the
phy (by *phandle* in the case of dt boot and *label* in the case of non-dt 
boot).

device id might be unknown if there are multiple devices in the system.


I agree with you on the device id part. That need not be known to the PHY 
driver.


How does a consumer know which label to use in a non-dt system if
there are multiple PHYs in the system?


That should be passed using platform data.


Ick, don't pass strings around, pass pointers.  If you have platform
data you can get to, then put the pointer there, don't use a name.


I don't think I understood you here :-s We wont have phy pointer when we 
create the device for the controller no?(it'll be done in board file). 
Probably I'm missing something.


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


Re: [PATCH v9 1/8] drivers: phy: add generic PHY framework

2013-07-18 Thread Kishon Vijay Abraham I
Hi,

On Wednesday 17 July 2013 10:55 PM, Greg KH wrote:
 On Wed, Jul 17, 2013 at 03:02:59PM +0530, Kishon Vijay Abraham I wrote:
 Hi,

 On Wednesday 17 July 2013 11:59 AM, Greg KH wrote:
 On Wed, Jun 26, 2013 at 05:17:29PM +0530, Kishon Vijay Abraham I wrote:
 +menuconfig GENERIC_PHY
 +  tristate PHY Subsystem
 +  help
 +Generic PHY support.
 +
 +This framework is designed to provide a generic interface for PHY
 +devices present in the kernel. This layer will have the generic
 +API by which phy drivers can create PHY using the phy framework and
 +phy users can obtain reference to the PHY.

 Shouldn't this be something that other drivers select?  How will anyone
 know if they need this or not?

 All the PHY drivers should go here. So only if *GENERIC_PHY* is enabled those
 PHY drivers can be selected like in [1].
 The PHY consumer driver should ideally use *depends on* in their Kconfig.

 [1] -
 http://archive.arm.linux.org.uk/lurker/message/20130628.134308.4a8f7668.ca.html
 
 No, switch it around the other way.  How would I even _know_ that I need
 to enable the generic PHY subsystem in the first place?  How can I
 determine that I need this for my hardware?  You need to give hints to
 someone who doesn't even know what a PHY is, otherwise they will always
 disable it and move on.
 
 --- /dev/null
 +++ b/drivers/phy/phy-core.c
 @@ -0,0 +1,544 @@
 +/*
 + * phy-core.c  --  Generic Phy framework.
 + *
 + * Copyright (C) 2013 Texas Instruments
 + *
 + * Author: Kishon Vijay Abraham I kis...@ti.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;  either version 2 of the  License, or (at 
 your
 + * option) any later version.

 You really mean any later version (I have to ask)?

 That was copied from somewhere :-s
 
 So, is that what you really mean to have for this code?

indeed.
 
 + * 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.
 + *
 + * You should have received a copy of the GNU General Public License
 + * along with this program.  If not, see http://www.gnu.org/licenses/.

 Are these two paragraphs needed?  This isn't a program, and they got a
 copy of the GPL already with the kernel.

 hmm.. I can remove that.

 +static struct class *phy_class;

 Why do you need a class?

 Wanted to group all the PHY drivers to be used by different subsystems
 (SATA/USB/PCIE/HDMI/VIDEO) into a single entity. There were some comments in 
 my
 initial version [3] on using a bus_type instead of class but then it was
 decided to go with class itself.

 [3] - http://lkml.indiana.edu/hypermail/linux/kernel/1302.2/01389.html
 
 Ok, but what does the class usage get you?

hmm.. actually I use class only to iterate through the list of devices in *phy*
class which could very well be implemented using list. Just that I wont have a
/sys/class/phy/ entry to find the list of phys added in the system. I dont
think I want to add any other stuff to expose to the user space at this point
of time.
 
 When modifying/adding new sysfs stuff, you need a Documentation/ABI/
 entry as well.

 I'm not actually adding any new sysfs entry other than what a *class_create*
 must have created. Do I need to add one for that?
 
 If you are not creating anything in sysfs at all, why use the driver
 model?  (hint, I think you need to do something here to justify it...)

Well.. it helps me to use pm_runtime to enable clocks utilizing the
parent-child relationship.

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


Re: [PATCH v9 1/8] drivers: phy: add generic PHY framework

2013-07-18 Thread Kishon Vijay Abraham I
On Thursday 18 July 2013 11:54 AM, Greg KH wrote:
 On Thu, Jul 18, 2013 at 11:33:17AM +0530, Kishon Vijay Abraham I wrote:
 Wanted to group all the PHY drivers to be used by different subsystems
 (SATA/USB/PCIE/HDMI/VIDEO) into a single entity. There were some comments 
 in my
 initial version [3] on using a bus_type instead of class but then it was
 decided to go with class itself.

 [3] - http://lkml.indiana.edu/hypermail/linux/kernel/1302.2/01389.html

 Ok, but what does the class usage get you?

 hmm.. actually I use class only to iterate through the list of devices in 
 *phy*
 class which could very well be implemented using list. Just that I wont have 
 a
 /sys/class/phy/ entry to find the list of phys added in the system. I dont
 think I want to add any other stuff to expose to the user space at this point
 of time.

 When modifying/adding new sysfs stuff, you need a Documentation/ABI/
 entry as well.

 I'm not actually adding any new sysfs entry other than what a 
 *class_create*
 must have created. Do I need to add one for that?

 If you are not creating anything in sysfs at all, why use the driver
 model?  (hint, I think you need to do something here to justify it...)

 Well.. it helps me to use pm_runtime to enable clocks utilizing the
 parent-child relationship.
 
 Ok, that's a good reason for this, nevermind then.  Care to send the
 latest patches you have in emails so I can review them?

Sure.

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


[PATCH 15/15] video: exynos_dp: Use the generic PHY driver

2013-07-18 Thread Kishon Vijay Abraham I
From: Jingoo Han jg1@samsung.com

Use the generic PHY API to control the DP PHY.

Signed-off-by: Jingoo Han jg1@samsung.com
Reviewed-by: Tomasz Figa t.f...@samsung.com
Signed-off-by: Kishon Vijay Abraham I kis...@ti.com
---
 .../devicetree/bindings/video/exynos_dp.txt  |   18 +-
 drivers/video/exynos/exynos_dp_core.c|   16 
 drivers/video/exynos/exynos_dp_core.h|1 +
 3 files changed, 22 insertions(+), 13 deletions(-)

diff --git a/Documentation/devicetree/bindings/video/exynos_dp.txt 
b/Documentation/devicetree/bindings/video/exynos_dp.txt
index 84f10c1..2f56376 100644
--- a/Documentation/devicetree/bindings/video/exynos_dp.txt
+++ b/Documentation/devicetree/bindings/video/exynos_dp.txt
@@ -6,10 +6,10 @@ We use two nodes:
-dptx-phy node(defined inside dp-controller node)
 
 For the DP-PHY initialization, we use the dptx-phy node.
-Required properties for dptx-phy:
-   -reg:
+Required properties for dptx-phy: deprecated, use phys and phy-names
+   -reg: deprecated
Base address of DP PHY register.
-   -samsung,enable-mask:
+   -samsung,enable-mask: deprecated
The bit-mask used to enable/disable DP PHY.
 
 For the Panel initialization, we read data from dp-controller node.
@@ -25,6 +25,10 @@ Required properties for dp-controller:
from common clock binding: handle to dp clock.
-clock-names:
from common clock binding: Shall be dp.
+   -phys:
+   from general PHY binding: the phandle for the PHY device.
+   -phy-names:
+   from general PHY binding: Should be dp.
-interrupt-parent:
phandle to Interrupt combiner node.
-samsung,color-space:
@@ -67,12 +71,8 @@ SOC specific portion:
interrupt-parent = combiner;
clocks = clock 342;
clock-names = dp;
-
-   dptx-phy {
-   reg = 0x10040720;
-   samsung,enable-mask = 1;
-   };
-
+   phys = dp_phy;
+   phy-names = dp;
};
 
 Board Specific portion:
diff --git a/drivers/video/exynos/exynos_dp_core.c 
b/drivers/video/exynos/exynos_dp_core.c
index 05fed7d..5e1a715 100644
--- a/drivers/video/exynos/exynos_dp_core.c
+++ b/drivers/video/exynos/exynos_dp_core.c
@@ -19,6 +19,7 @@
 #include linux/interrupt.h
 #include linux/delay.h
 #include linux/of.h
+#include linux/phy/phy.h
 
 #include exynos_dp_core.h
 
@@ -960,8 +961,11 @@ static int exynos_dp_dt_parse_phydata(struct 
exynos_dp_device *dp)
 
dp_phy_node = of_find_node_by_name(dp_phy_node, dptx-phy);
if (!dp_phy_node) {
-   dev_err(dp-dev, could not find dptx-phy node\n);
-   return -ENODEV;
+   dp-phy = devm_phy_get(dp-dev, dp);
+   if (IS_ERR(dp-phy))
+   return PTR_ERR(dp-phy);
+   else
+   return 0;
}
 
if (of_property_read_u32(dp_phy_node, reg, phy_base)) {
@@ -992,7 +996,9 @@ err:
 
 static void exynos_dp_phy_init(struct exynos_dp_device *dp)
 {
-   if (dp-phy_addr) {
+   if (dp-phy) {
+   phy_power_on(dp-phy);
+   } else if (dp-phy_addr) {
u32 reg;
 
reg = __raw_readl(dp-phy_addr);
@@ -1003,7 +1009,9 @@ static void exynos_dp_phy_init(struct exynos_dp_device 
*dp)
 
 static void exynos_dp_phy_exit(struct exynos_dp_device *dp)
 {
-   if (dp-phy_addr) {
+   if (dp-phy) {
+   phy_power_off(dp-phy);
+   } else if (dp-phy_addr) {
u32 reg;
 
reg = __raw_readl(dp-phy_addr);
diff --git a/drivers/video/exynos/exynos_dp_core.h 
b/drivers/video/exynos/exynos_dp_core.h
index 56cfec8..607e36d 100644
--- a/drivers/video/exynos/exynos_dp_core.h
+++ b/drivers/video/exynos/exynos_dp_core.h
@@ -151,6 +151,7 @@ struct exynos_dp_device {
struct video_info   *video_info;
struct link_train   link_train;
struct work_struct  hotplug_work;
+   struct phy  *phy;
 };
 
 /* exynos_dp_reg.c */
-- 
1.7.10.4

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


[PATCH 14/15] video: exynos_dp: remove non-DT support for Exynos Display Port

2013-07-18 Thread Kishon Vijay Abraham I
From: Jingoo Han jg1@samsung.com

Exynos Display Port can be used only for Exynos SoCs. In addition,
non-DT for EXYNOS SoCs is not supported from v3.11; thus, there is
no need to support non-DT for Exynos Display Port.

The 'include/video/exynos_dp.h' file has been used for non-DT
support and the content of file include/video/exynos_dp.h is moved
to drivers/video/exynos/exynos_dp_core.h. Thus, the 'exynos_dp.h'
file is removed. Also, 'struct exynos_dp_platdata' is removed,
because it is not used any more.

Signed-off-by: Jingoo Han jg1@samsung.com
Reviewed-by: Tomasz Figa t.f...@samsung.com
Signed-off-by: Kishon Vijay Abraham I kis...@ti.com
---
 drivers/video/exynos/Kconfig  |2 +-
 drivers/video/exynos/exynos_dp_core.c |  116 +++--
 drivers/video/exynos/exynos_dp_core.h |  109 +++
 drivers/video/exynos/exynos_dp_reg.c  |2 -
 include/video/exynos_dp.h |  131 -
 5 files changed, 135 insertions(+), 225 deletions(-)
 delete mode 100644 include/video/exynos_dp.h

diff --git a/drivers/video/exynos/Kconfig b/drivers/video/exynos/Kconfig
index 1b035b2..fab9019 100644
--- a/drivers/video/exynos/Kconfig
+++ b/drivers/video/exynos/Kconfig
@@ -29,7 +29,7 @@ config EXYNOS_LCD_S6E8AX0
 
 config EXYNOS_DP
bool EXYNOS DP driver support
-   depends on ARCH_EXYNOS
+   depends on OF  ARCH_EXYNOS
default n
help
  This enables support for DP device.
diff --git a/drivers/video/exynos/exynos_dp_core.c 
b/drivers/video/exynos/exynos_dp_core.c
index 12bbede..05fed7d 100644
--- a/drivers/video/exynos/exynos_dp_core.c
+++ b/drivers/video/exynos/exynos_dp_core.c
@@ -20,8 +20,6 @@
 #include linux/delay.h
 #include linux/of.h
 
-#include video/exynos_dp.h
-
 #include exynos_dp_core.h
 
 static int exynos_dp_init_dp(struct exynos_dp_device *dp)
@@ -894,26 +892,17 @@ static void exynos_dp_hotplug(struct work_struct *work)
dev_err(dp-dev, unable to config video\n);
 }
 
-#ifdef CONFIG_OF
-static struct exynos_dp_platdata *exynos_dp_dt_parse_pdata(struct device *dev)
+static struct video_info *exynos_dp_dt_parse_pdata(struct device *dev)
 {
struct device_node *dp_node = dev-of_node;
-   struct exynos_dp_platdata *pd;
struct video_info *dp_video_config;
 
-   pd = devm_kzalloc(dev, sizeof(*pd), GFP_KERNEL);
-   if (!pd) {
-   dev_err(dev, memory allocation for pdata failed\n);
-   return ERR_PTR(-ENOMEM);
-   }
dp_video_config = devm_kzalloc(dev,
sizeof(*dp_video_config), GFP_KERNEL);
-
if (!dp_video_config) {
dev_err(dev, memory allocation for video config failed\n);
return ERR_PTR(-ENOMEM);
}
-   pd-video_info = dp_video_config;
 
dp_video_config-h_sync_polarity =
of_property_read_bool(dp_node, hsync-active-high);
@@ -960,7 +949,7 @@ static struct exynos_dp_platdata 
*exynos_dp_dt_parse_pdata(struct device *dev)
return ERR_PTR(-EINVAL);
}
 
-   return pd;
+   return dp_video_config;
 }
 
 static int exynos_dp_dt_parse_phydata(struct exynos_dp_device *dp)
@@ -1003,48 +992,30 @@ err:
 
 static void exynos_dp_phy_init(struct exynos_dp_device *dp)
 {
-   u32 reg;
+   if (dp-phy_addr) {
+   u32 reg;
 
-   reg = __raw_readl(dp-phy_addr);
-   reg |= dp-enable_mask;
-   __raw_writel(reg, dp-phy_addr);
+   reg = __raw_readl(dp-phy_addr);
+   reg |= dp-enable_mask;
+   __raw_writel(reg, dp-phy_addr);
+   }
 }
 
 static void exynos_dp_phy_exit(struct exynos_dp_device *dp)
 {
-   u32 reg;
-
-   reg = __raw_readl(dp-phy_addr);
-   reg = ~(dp-enable_mask);
-   __raw_writel(reg, dp-phy_addr);
-}
-#else
-static struct exynos_dp_platdata *exynos_dp_dt_parse_pdata(struct device *dev)
-{
-   return NULL;
-}
-
-static int exynos_dp_dt_parse_phydata(struct exynos_dp_device *dp)
-{
-   return -EINVAL;
-}
-
-static void exynos_dp_phy_init(struct exynos_dp_device *dp)
-{
-   return;
-}
+   if (dp-phy_addr) {
+   u32 reg;
 
-static void exynos_dp_phy_exit(struct exynos_dp_device *dp)
-{
-   return;
+   reg = __raw_readl(dp-phy_addr);
+   reg = ~(dp-enable_mask);
+   __raw_writel(reg, dp-phy_addr);
+   }
 }
-#endif /* CONFIG_OF */
 
 static int exynos_dp_probe(struct platform_device *pdev)
 {
struct resource *res;
struct exynos_dp_device *dp;
-   struct exynos_dp_platdata *pdata;
 
int ret = 0;
 
@@ -1057,21 +1028,13 @@ static int exynos_dp_probe(struct platform_device *pdev)
 
dp-dev = pdev-dev;
 
-   if (pdev-dev.of_node) {
-   pdata = exynos_dp_dt_parse_pdata(pdev-dev);
-   if (IS_ERR(pdata))
-   return PTR_ERR(pdata);
+   dp-video_info

[PATCH 12/15] ARM: Samsung: Remove the MIPI PHY setup code

2013-07-18 Thread Kishon Vijay Abraham I
From: Sylwester Nawrocki s.nawro...@samsung.com

Generic PHY drivers are used to handle the MIPI CSIS and MIPI DSIM
DPHYs so we can remove now unused code at arch/arm/plat-samsung.
In case there is any board file for S5PV210 platforms using MIPI
CSIS/DSIM (not any upstream currently) it should use the generic
PHY API to bind the PHYs to respective PHY consumer drivers and
a platform device for the PHY provider should be defined.

Signed-off-by: Sylwester Nawrocki s.nawro...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
Acked-by: Felipe Balbi ba...@ti.com
Acked-by: Kukjin Kim kgene@samsung.com
Signed-off-by: Kishon Vijay Abraham I kis...@ti.com
---
 arch/arm/mach-exynos/include/mach/regs-pmu.h|5 --
 arch/arm/mach-s5pv210/include/mach/regs-clock.h |4 --
 arch/arm/plat-samsung/Kconfig   |5 --
 arch/arm/plat-samsung/Makefile  |1 -
 arch/arm/plat-samsung/setup-mipiphy.c   |   60 ---
 5 files changed, 75 deletions(-)
 delete mode 100644 arch/arm/plat-samsung/setup-mipiphy.c

diff --git a/arch/arm/mach-exynos/include/mach/regs-pmu.h 
b/arch/arm/mach-exynos/include/mach/regs-pmu.h
index 57344b7..2cdb63e 100644
--- a/arch/arm/mach-exynos/include/mach/regs-pmu.h
+++ b/arch/arm/mach-exynos/include/mach/regs-pmu.h
@@ -44,11 +44,6 @@
 #define S5P_DAC_PHY_CONTROLS5P_PMUREG(0x070C)
 #define S5P_DAC_PHY_ENABLE (1  0)
 
-#define S5P_MIPI_DPHY_CONTROL(n)   S5P_PMUREG(0x0710 + (n) * 4)
-#define S5P_MIPI_DPHY_ENABLE   (1  0)
-#define S5P_MIPI_DPHY_SRESETN  (1  1)
-#define S5P_MIPI_DPHY_MRESETN  (1  2)
-
 #define S5P_INFORM0S5P_PMUREG(0x0800)
 #define S5P_INFORM1S5P_PMUREG(0x0804)
 #define S5P_INFORM2S5P_PMUREG(0x0808)
diff --git a/arch/arm/mach-s5pv210/include/mach/regs-clock.h 
b/arch/arm/mach-s5pv210/include/mach/regs-clock.h
index 032de66..e345584 100644
--- a/arch/arm/mach-s5pv210/include/mach/regs-clock.h
+++ b/arch/arm/mach-s5pv210/include/mach/regs-clock.h
@@ -147,10 +147,6 @@
 #define S5P_HDMI_PHY_CONTROL   S5P_CLKREG(0xE804)
 #define S5P_USB_PHY_CONTROLS5P_CLKREG(0xE80C)
 #define S5P_DAC_PHY_CONTROLS5P_CLKREG(0xE810)
-#define S5P_MIPI_DPHY_CONTROL(x) S5P_CLKREG(0xE814)
-#define S5P_MIPI_DPHY_ENABLE   (1  0)
-#define S5P_MIPI_DPHY_SRESETN  (1  1)
-#define S5P_MIPI_DPHY_MRESETN  (1  2)
 
 #define S5P_INFORM0S5P_CLKREG(0xF000)
 #define S5P_INFORM1S5P_CLKREG(0xF004)
diff --git a/arch/arm/plat-samsung/Kconfig b/arch/arm/plat-samsung/Kconfig
index 3dc5cbe..db2d814 100644
--- a/arch/arm/plat-samsung/Kconfig
+++ b/arch/arm/plat-samsung/Kconfig
@@ -402,11 +402,6 @@ config S3C24XX_PWM
  Support for exporting the PWM timer blocks via the pwm device
  system
 
-config S5P_SETUP_MIPIPHY
-   bool
-   help
- Compile in common setup code for MIPI-CSIS and MIPI-DSIM devices
-
 config S3C_SETUP_CAMIF
bool
help
diff --git a/arch/arm/plat-samsung/Makefile b/arch/arm/plat-samsung/Makefile
index 98d07d8..98f1e31 100644
--- a/arch/arm/plat-samsung/Makefile
+++ b/arch/arm/plat-samsung/Makefile
@@ -41,7 +41,6 @@ obj-$(CONFIG_S5P_DEV_UART)+= s5p-dev-uart.o
 obj-$(CONFIG_SAMSUNG_DEV_BACKLIGHT)+= dev-backlight.o
 
 obj-$(CONFIG_S3C_SETUP_CAMIF)  += setup-camif.o
-obj-$(CONFIG_S5P_SETUP_MIPIPHY)+= setup-mipiphy.o
 
 # DMA support
 
diff --git a/arch/arm/plat-samsung/setup-mipiphy.c 
b/arch/arm/plat-samsung/setup-mipiphy.c
deleted file mode 100644
index 66df315..000
--- a/arch/arm/plat-samsung/setup-mipiphy.c
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Copyright (C) 2011 Samsung Electronics Co., Ltd.
- *
- * S5P - Helper functions for MIPI-CSIS and MIPI-DSIM D-PHY control
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- */
-
-#include linux/export.h
-#include linux/kernel.h
-#include linux/platform_device.h
-#include linux/io.h
-#include linux/spinlock.h
-#include mach/regs-clock.h
-
-static int __s5p_mipi_phy_control(int id, bool on, u32 reset)
-{
-   static DEFINE_SPINLOCK(lock);
-   void __iomem *addr;
-   unsigned long flags;
-   u32 cfg;
-
-   id = max(0, id);
-   if (id  1)
-   return -EINVAL;
-
-   addr = S5P_MIPI_DPHY_CONTROL(id);
-
-   spin_lock_irqsave(lock, flags);
-
-   cfg = __raw_readl(addr);
-   cfg = on ? (cfg | reset) : (cfg  ~reset);
-   __raw_writel(cfg, addr);
-
-   if (on) {
-   cfg |= S5P_MIPI_DPHY_ENABLE;
-   } else if (!(cfg  (S5P_MIPI_DPHY_SRESETN |
-   S5P_MIPI_DPHY_MRESETN)  ~reset)) {
-   cfg = ~S5P_MIPI_DPHY_ENABLE;
-   }
-
-   __raw_writel(cfg, addr

[PATCH 13/15] phy: Add driver for Exynos DP PHY

2013-07-18 Thread Kishon Vijay Abraham I
From: Jingoo Han jg1@samsung.com

Add a PHY provider driver for the Samsung Exynos SoC Display Port PHY.

Signed-off-by: Jingoo Han jg1@samsung.com
Reviewed-by: Tomasz Figa t.f...@samsung.com
Cc: Sylwester Nawrocki s.nawro...@samsung.com
Acked-by: Felipe Balbi ba...@ti.com
Signed-off-by: Kishon Vijay Abraham I kis...@ti.com
---
 .../devicetree/bindings/phy/samsung-phy.txt|8 ++
 drivers/phy/Kconfig|6 ++
 drivers/phy/Makefile   |1 +
 drivers/phy/phy-exynos-dp-video.c  |  111 
 4 files changed, 126 insertions(+)
 create mode 100644 drivers/phy/phy-exynos-dp-video.c

diff --git a/Documentation/devicetree/bindings/phy/samsung-phy.txt 
b/Documentation/devicetree/bindings/phy/samsung-phy.txt
index 5ff208c..c0fccaa 100644
--- a/Documentation/devicetree/bindings/phy/samsung-phy.txt
+++ b/Documentation/devicetree/bindings/phy/samsung-phy.txt
@@ -12,3 +12,11 @@ the PHY specifier identifies the PHY and its meaning is as 
follows:
   1 - MIPI DSIM 0,
   2 - MIPI CSIS 1,
   3 - MIPI DSIM 1.
+
+Samsung EXYNOS SoC series Display Port PHY
+-
+
+Required properties:
+- compatible : should be samsung,exynos5250-dp-video-phy;
+- reg : offset and length of the Display Port PHY register set;
+- #phy-cells : from the generic PHY bindings, must be 0;
diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig
index 6f446d0..ed0b1b8 100644
--- a/drivers/phy/Kconfig
+++ b/drivers/phy/Kconfig
@@ -19,4 +19,10 @@ config PHY_EXYNOS_MIPI_VIDEO
help
  Support for MIPI CSI-2 and MIPI DSI DPHY found on Samsung
  S5P and EXYNOS SoCs.
+
+config PHY_EXYNOS_DP_VIDEO
+   tristate EXYNOS SoC series Display Port PHY driver
+   depends on OF
+   help
+ Support for Display Port PHY found on Samsung EXYNOS SoCs.
 endif
diff --git a/drivers/phy/Makefile b/drivers/phy/Makefile
index 71d8841..0fd1340 100644
--- a/drivers/phy/Makefile
+++ b/drivers/phy/Makefile
@@ -4,3 +4,4 @@
 
 obj-$(CONFIG_GENERIC_PHY)  += phy-core.o
 obj-$(CONFIG_PHY_EXYNOS_MIPI_VIDEO)+= phy-exynos-mipi-video.o
+obj-$(CONFIG_PHY_EXYNOS_DP_VIDEO)  += phy-exynos-dp-video.o
diff --git a/drivers/phy/phy-exynos-dp-video.c 
b/drivers/phy/phy-exynos-dp-video.c
new file mode 100644
index 000..3c8e247
--- /dev/null
+++ b/drivers/phy/phy-exynos-dp-video.c
@@ -0,0 +1,111 @@
+/*
+ * Samsung EXYNOS SoC series Display Port PHY driver
+ *
+ * Copyright (C) 2013 Samsung Electronics Co., Ltd.
+ * Author: Jingoo Han jg1@samsung.com
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include linux/io.h
+#include linux/kernel.h
+#include linux/module.h
+#include linux/of.h
+#include linux/of_address.h
+#include linux/phy/phy.h
+#include linux/platform_device.h
+
+/* DPTX_PHY_CONTROL register */
+#define EXYNOS_DPTX_PHY_ENABLE (1  0)
+
+struct exynos_dp_video_phy {
+   void __iomem *regs;
+};
+
+static int __set_phy_state(struct exynos_dp_video_phy *state, unsigned int on)
+{
+   u32 reg;
+
+   reg = readl(state-regs);
+   if (on)
+   reg |= EXYNOS_DPTX_PHY_ENABLE;
+   else
+   reg = ~EXYNOS_DPTX_PHY_ENABLE;
+   writel(reg, state-regs);
+
+   return 0;
+}
+
+static int exynos_dp_video_phy_power_on(struct phy *phy)
+{
+   struct exynos_dp_video_phy *state = phy_get_drvdata(phy);
+
+   return __set_phy_state(state, 1);
+}
+
+static int exynos_dp_video_phy_power_off(struct phy *phy)
+{
+   struct exynos_dp_video_phy *state = phy_get_drvdata(phy);
+
+   return __set_phy_state(state, 0);
+}
+
+static struct phy_ops exynos_dp_video_phy_ops = {
+   .power_on   = exynos_dp_video_phy_power_on,
+   .power_off  = exynos_dp_video_phy_power_off,
+   .owner  = THIS_MODULE,
+};
+
+static int exynos_dp_video_phy_probe(struct platform_device *pdev)
+{
+   struct exynos_dp_video_phy *state;
+   struct device *dev = pdev-dev;
+   struct resource *res;
+   struct phy_provider *phy_provider;
+   struct phy *phy;
+
+   state = devm_kzalloc(dev, sizeof(*state), GFP_KERNEL);
+   if (!state)
+   return -ENOMEM;
+
+   res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+
+   state-regs = devm_ioremap_resource(dev, res);
+   if (IS_ERR(state-regs))
+   return PTR_ERR(state-regs);
+
+   phy_provider = devm_of_phy_provider_register(dev, of_phy_simple_xlate);
+   if (IS_ERR(phy_provider))
+   return PTR_ERR(phy_provider);
+
+   phy = devm_phy_create(dev, 0, exynos_dp_video_phy_ops, NULL);
+   if (IS_ERR(phy)) {
+   dev_err(dev, failed to create Display Port PHY\n);
+   return PTR_ERR(phy);
+   }
+   phy_set_drvdata(phy

[PATCH 05/15] ARM: dts: omap: update usb_otg_hs data

2013-07-18 Thread Kishon Vijay Abraham I
Updated the usb_otg_hs dt data to include the *phy* and *phy-names*
binding in order for the driver to use the new generic PHY framework.
Also updated the Documentation to include the binding information.
The PHY binding information can be found at
Documentation/devicetree/bindings/phy/phy-bindings.txt

Signed-off-by: Kishon Vijay Abraham I kis...@ti.com
Acked-by: Felipe Balbi ba...@ti.com
Reviewed-by: Sylwester Nawrocki s.nawro...@samsung.com
---
 Documentation/devicetree/bindings/usb/omap-usb.txt |5 +
 Documentation/devicetree/bindings/usb/usb-phy.txt  |6 ++
 arch/arm/boot/dts/omap3-beagle-xm.dts  |2 ++
 arch/arm/boot/dts/omap3-evm.dts|2 ++
 arch/arm/boot/dts/omap3-overo.dtsi |2 ++
 arch/arm/boot/dts/omap4.dtsi   |3 +++
 arch/arm/boot/dts/twl4030.dtsi |1 +
 7 files changed, 21 insertions(+)

diff --git a/Documentation/devicetree/bindings/usb/omap-usb.txt 
b/Documentation/devicetree/bindings/usb/omap-usb.txt
index 57e71f6..825790d 100644
--- a/Documentation/devicetree/bindings/usb/omap-usb.txt
+++ b/Documentation/devicetree/bindings/usb/omap-usb.txt
@@ -19,6 +19,9 @@ OMAP MUSB GLUE
  - power : Should be 50. This signifies the controller can supply up to
100mA when operating in host mode.
  - usb-phy : the phandle for the PHY device
+ - phys : the phandle for the PHY device (used by generic PHY framework)
+ - phy-names : the names of the PHY corresponding to the PHYs present in the
+   *phy* phandle.
 
 Optional properties:
  - ctrl-module : phandle of the control module this glue uses to write to
@@ -33,6 +36,8 @@ usb_otg_hs: usb_otg_hs@4a0ab000 {
num-eps = 16;
ram-bits = 12;
ctrl-module = omap_control_usb;
+   phys = usb2_phy;
+   phy-names = usb2-phy;
 };
 
 Board specific device node entry
diff --git a/Documentation/devicetree/bindings/usb/usb-phy.txt 
b/Documentation/devicetree/bindings/usb/usb-phy.txt
index 61496f5..c0245c8 100644
--- a/Documentation/devicetree/bindings/usb/usb-phy.txt
+++ b/Documentation/devicetree/bindings/usb/usb-phy.txt
@@ -5,6 +5,8 @@ OMAP USB2 PHY
 Required properties:
  - compatible: Should be ti,omap-usb2
  - reg : Address and length of the register set for the device.
+ - #phy-cells: determine the number of cells that should be given in the
+   phandle while referencing this phy.
 
 Optional properties:
  - ctrl-module : phandle of the control module used by PHY driver to power on
@@ -16,6 +18,7 @@ usb2phy@4a0ad080 {
compatible = ti,omap-usb2;
reg = 0x4a0ad080 0x58;
ctrl-module = omap_control_usb;
+   #phy-cells = 0;
 };
 
 OMAP USB3 PHY
@@ -25,6 +28,8 @@ Required properties:
  - reg : Address and length of the register set for the device.
  - reg-names: The names of the register addresses corresponding to the 
registers
filled in reg.
+ - #phy-cells: determine the number of cells that should be given in the
+   phandle while referencing this phy.
 
 Optional properties:
  - ctrl-module : phandle of the control module used by PHY driver to power on
@@ -39,4 +44,5 @@ usb3phy@4a084400 {
  0x4a084c00 0x40;
reg-names = phy_rx, phy_tx, pll_ctrl;
ctrl-module = omap_control_usb;
+   #phy-cells = 0;
 };
diff --git a/arch/arm/boot/dts/omap3-beagle-xm.dts 
b/arch/arm/boot/dts/omap3-beagle-xm.dts
index afdb164..533b2da 100644
--- a/arch/arm/boot/dts/omap3-beagle-xm.dts
+++ b/arch/arm/boot/dts/omap3-beagle-xm.dts
@@ -144,6 +144,8 @@
 usb_otg_hs {
interface-type = 0;
usb-phy = usb2_phy;
+   phys = usb2_phy;
+   phy-names = usb2-phy;
mode = 3;
power = 50;
 };
diff --git a/arch/arm/boot/dts/omap3-evm.dts b/arch/arm/boot/dts/omap3-evm.dts
index 7d4329d..4134dd0 100644
--- a/arch/arm/boot/dts/omap3-evm.dts
+++ b/arch/arm/boot/dts/omap3-evm.dts
@@ -70,6 +70,8 @@
 usb_otg_hs {
interface-type = 0;
usb-phy = usb2_phy;
+   phys = usb2_phy;
+   phy-names = usb2-phy;
mode = 3;
power = 50;
 };
diff --git a/arch/arm/boot/dts/omap3-overo.dtsi 
b/arch/arm/boot/dts/omap3-overo.dtsi
index 8f1abec..a461d2f 100644
--- a/arch/arm/boot/dts/omap3-overo.dtsi
+++ b/arch/arm/boot/dts/omap3-overo.dtsi
@@ -76,6 +76,8 @@
 usb_otg_hs {
interface-type = 0;
usb-phy = usb2_phy;
+   phys = usb2_phy;
+   phy-names = usb2-phy;
mode = 3;
power = 50;
 };
diff --git a/arch/arm/boot/dts/omap4.dtsi b/arch/arm/boot/dts/omap4.dtsi
index 22d9f2b..1e8e2fe 100644
--- a/arch/arm/boot/dts/omap4.dtsi
+++ b/arch/arm/boot/dts/omap4.dtsi
@@ -520,6 +520,7 @@
compatible = ti,omap-usb2;
reg = 0x4a0ad080 0x58;
ctrl-module = omap_control_usb;
+   #phy-cells = 0;
};
};
 
@@ -658,6 +659,8 @@
interrupt-names = mc, dma

[PATCH 09/15] phy: Add driver for Exynos MIPI CSIS/DSIM DPHYs

2013-07-18 Thread Kishon Vijay Abraham I
From: Sylwester Nawrocki s.nawro...@samsung.com

Add a PHY provider driver for the Samsung S5P/Exynos SoC MIPI CSI-2
receiver and MIPI DSI transmitter DPHYs.

Signed-off-by: Sylwester Nawrocki s.nawro...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
Acked-by: Felipe Balbi ba...@ti.com
Signed-off-by: Kishon Vijay Abraham I kis...@ti.com
---
 .../devicetree/bindings/phy/samsung-phy.txt|   14 ++
 drivers/phy/Kconfig|9 ++
 drivers/phy/Makefile   |3 +-
 drivers/phy/phy-exynos-mipi-video.c|  169 
 4 files changed, 194 insertions(+), 1 deletion(-)
 create mode 100644 Documentation/devicetree/bindings/phy/samsung-phy.txt
 create mode 100644 drivers/phy/phy-exynos-mipi-video.c

diff --git a/Documentation/devicetree/bindings/phy/samsung-phy.txt 
b/Documentation/devicetree/bindings/phy/samsung-phy.txt
new file mode 100644
index 000..5ff208c
--- /dev/null
+++ b/Documentation/devicetree/bindings/phy/samsung-phy.txt
@@ -0,0 +1,14 @@
+Samsung S5P/EXYNOS SoC series MIPI CSIS/DSIM DPHY
+-
+
+Required properties:
+- compatible : should be samsung,s5pv210-mipi-video-phy;
+- reg : offset and length of the MIPI DPHY register set;
+- #phy-cells : from the generic phy bindings, must be 1;
+
+For samsung,s5pv210-mipi-video-phy compatible PHYs the second cell in
+the PHY specifier identifies the PHY and its meaning is as follows:
+  0 - MIPI CSIS 0,
+  1 - MIPI DSIM 0,
+  2 - MIPI CSIS 1,
+  3 - MIPI DSIM 1.
diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig
index 5f85909..6f446d0 100644
--- a/drivers/phy/Kconfig
+++ b/drivers/phy/Kconfig
@@ -11,3 +11,12 @@ menuconfig GENERIC_PHY
  devices present in the kernel. This layer will have the generic
  API by which phy drivers can create PHY using the phy framework and
  phy users can obtain reference to the PHY.
+
+if GENERIC_PHY
+
+config PHY_EXYNOS_MIPI_VIDEO
+   tristate S5P/EXYNOS SoC series MIPI CSI-2/DSI PHY driver
+   help
+ Support for MIPI CSI-2 and MIPI DSI DPHY found on Samsung
+ S5P and EXYNOS SoCs.
+endif
diff --git a/drivers/phy/Makefile b/drivers/phy/Makefile
index 9e9560f..71d8841 100644
--- a/drivers/phy/Makefile
+++ b/drivers/phy/Makefile
@@ -2,4 +2,5 @@
 # Makefile for the phy drivers.
 #
 
-obj-$(CONFIG_GENERIC_PHY)  += phy-core.o
+obj-$(CONFIG_GENERIC_PHY)  += phy-core.o
+obj-$(CONFIG_PHY_EXYNOS_MIPI_VIDEO)+= phy-exynos-mipi-video.o
diff --git a/drivers/phy/phy-exynos-mipi-video.c 
b/drivers/phy/phy-exynos-mipi-video.c
new file mode 100644
index 000..7e7fcd7
--- /dev/null
+++ b/drivers/phy/phy-exynos-mipi-video.c
@@ -0,0 +1,169 @@
+/*
+ * Samsung S5P/EXYNOS SoC series MIPI CSIS/DSIM DPHY driver
+ *
+ * Copyright (C) 2013 Samsung Electronics Co., Ltd.
+ * Author: Sylwester Nawrocki s.nawro...@samsung.com
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include linux/io.h
+#include linux/kernel.h
+#include linux/module.h
+#include linux/of.h
+#include linux/of_address.h
+#include linux/phy/phy.h
+#include linux/platform_device.h
+#include linux/spinlock.h
+
+/* MIPI_PHYn_CONTROL register offset: n = 0..1 */
+#define EXYNOS_MIPI_PHY_CONTROL(n) ((n) * 4)
+#define EXYNOS_MIPI_PHY_ENABLE (1  0)
+#define EXYNOS_MIPI_PHY_SRESETN(1  1)
+#define EXYNOS_MIPI_PHY_MRESETN(1  2)
+#define EXYNOS_MIPI_PHY_RESET_MASK (3  1)
+
+enum exynos_mipi_phy_id {
+   EXYNOS_MIPI_PHY_ID_CSIS0,
+   EXYNOS_MIPI_PHY_ID_DSIM0,
+   EXYNOS_MIPI_PHY_ID_CSIS1,
+   EXYNOS_MIPI_PHY_ID_DSIM1,
+   EXYNOS_MIPI_PHYS_NUM
+};
+
+#define IS_EXYNOS_MIPI_DSIM_PHY_ID(id) \
+   ((id) == EXYNOS_MIPI_PHY_ID_DSIM0 || (id) == EXYNOS_MIPI_PHY_ID_DSIM0)
+
+struct exynos_mipi_video_phy {
+   spinlock_t slock;
+   struct phy *phys[EXYNOS_MIPI_PHYS_NUM];
+   void __iomem *regs;
+};
+
+static int __set_phy_state(struct exynos_mipi_video_phy *state,
+   enum exynos_mipi_phy_id id, unsigned int on)
+{
+   void __iomem *addr;
+   u32 reg, reset;
+
+   addr = state-regs + EXYNOS_MIPI_PHY_CONTROL(id / 2);
+
+   if (IS_EXYNOS_MIPI_DSIM_PHY_ID(id))
+   reset = EXYNOS_MIPI_PHY_MRESETN;
+   else
+   reset = EXYNOS_MIPI_PHY_SRESETN;
+
+   spin_lock(state-slock);
+   reg = readl(addr);
+   if (on)
+   reg |= reset;
+   else
+   reg = ~reset;
+   writel(reg, addr);
+
+   /* Clear ENABLE bit only if MRESETN, SRESETN bits are not set. */
+   if (on)
+   reg |= EXYNOS_MIPI_PHY_ENABLE;
+   else if (!(reg  EXYNOS_MIPI_PHY_RESET_MASK))
+   reg = ~EXYNOS_MIPI_PHY_ENABLE;
+
+   writel(reg, addr

<    2   3   4   5   6   7   8   9   10   11   >