Skip to contentSkip to conversation

Generic PHY Framework

PATCH Superseded Kishon Vijay Abraham I 7 participants 27 messages Mar 20, 2013 – Apr 22, 2013

Subsystems (9)

v3 of 12 Superseded Latest is v12 →

lore
Share & tools
lore
#0 lore raw

v3 cover Generic PHY Framework

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. To obtain a reference to the PHY without using phandle, the platform specfic intialization code (say from board file) should have already called phy_bind with the binding information. The binding information consists of phy's device name, phy user device name and an index. The index is used when the same phy user binds to mulitple phys.

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.

Making omap-usb2 and twl4030 to use this framework is provided as a sample.

This patch series is developed on 3.9-rc3. Once the patch series gets finalised I'll resend omap-usb2 and twl4030 part based on Felipe's tree.

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

Did USB enumeration testing in panda and beagle. Kishon Vijay Abraham I (6):
drivers: phy: add generic PHY framework
usb: phy: omap-usb2: use the new generic PHY framework
usb: otg: twl4030: use the new generic PHY framework
ARM: OMAP: USB: Add phy binding information
ARM: dts: omap: update usb_otg_hs data
usb: musb: omap2430: use the new generic PHY framework

 Documentation/ABI/testing/sysfs-class-phy          |   15 +
 Documentation/devicetree/bindings/usb/omap-usb.txt |    5 +
 Documentation/phy.txt                              |  108 ++++
 MAINTAINERS                                        |    7 +
 arch/arm/boot/dts/omap3.dtsi                       |    2 +
 arch/arm/boot/dts/omap4.dtsi                       |    2 +
 arch/arm/mach-omap2/board-2430sdp.c                |    2 +
 arch/arm/mach-omap2/board-3430sdp.c                |    2 +
 arch/arm/mach-omap2/board-4430sdp.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-omap4panda.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/Kconfig                                    |    2 +
 drivers/Makefile                                   |    2 +
 drivers/phy/Kconfig                                |   13 +
 drivers/phy/Makefile                               |    5 +
 drivers/phy/phy-core.c                             |  574 ++++++++++++++++++++
 drivers/usb/musb/musb_core.h                       |    2 +
 drivers/usb/musb/omap2430.c                        |   22 +-
 drivers/usb/otg/twl4030-usb.c                      |   36 ++
 drivers/usb/phy/omap-usb2.c                        |   47 ++
 include/linux/phy/phy.h                            |  218 ++++++++
 34 files changed, 1090 insertions(+), 6 deletions(-)
 create mode 100644 Documentation/ABI/testing/sysfs-class-phy
 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
Signature · 1 line
1.7.10.4
#1 lore raw

PATCH v3 1/6 drivers: phy: add generic PHY framework

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. To obtain a reference to the PHY without using phandle, the platform specfic intialization code (say from board file) should have already called phy_bind with the binding information. The binding information consists of phy's device name, phy user device name and an index. The index is used when the same phy user binds to mulitple phys.

PHY drivers should create the PHY by passing phy_descriptor that has describes the PHY (label, type etc..) and ops like init, exit, suspend, resume, poweron, shutdown.

The documentation for the generic PHY framework is added in Documentation/phy.txt and the documentation for the sysfs entry is added in Documentation/ABI/testing/sysfs-class-phy.

---
 Documentation/ABI/testing/sysfs-class-phy |   15 +
 Documentation/phy.txt                     |  108 ++++++
 MAINTAINERS                               |    7 +
 drivers/Kconfig                           |    2 +
 drivers/Makefile                          |    2 +
 drivers/phy/Kconfig                       |   13 +
 drivers/phy/Makefile                      |    5 +
 drivers/phy/phy-core.c                    |  574 +++++++++++++++++++++++++++++
 include/linux/phy/phy.h                   |  218 +++++++++++
 9 files changed, 944 insertions(+)
 create mode 100644 Documentation/ABI/testing/sysfs-class-phy
 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
Documentation/ABI/testing/sysfs-class-phy new file +15 -0
new file mode 100644
index 0000000..47f17c9
@@ -0,0 +1,15 @@
+What:		/sys/class/phy/<phy>/label
+Date:		Feb 2013
+KernelVersion:	3.10
+Contact:	Kishon Vijay Abraham I <[email protected]>
+Description:
+		This is a read-only file for getting the label of the phy.
+
+What:		/sys/class/phy/<phy>/phy_bind
+Date:		Feb 2013
+KernelVersion:	3.10
+Contact:	Kishon Vijay Abraham I <[email protected]>
+Description:
+		This is a read-only file for reading the phy binding
+		information. It contains the device name of the controller,
+		the index and the device name of the PHY in that order.
Documentation/phy.txt new file +108 -0

108 lines not on this page · raw message

MAINTAINERS +7 -0
index 50b4d73..efb0498 100644
@@ -3474,6 +3474,13 @@ S:	Maintained
 F:	include/asm-generic
 F:	include/uapi/asm-generic
 
+GENERIC PHY FRAMEWORK
+M:	Kishon Vijay Abraham I <[email protected]>
+L:	linux-kernel at vger.kernel.org
+S:	Supported
+F:	drivers/phy/
+F:	include/linux/phy/
+
 GENERIC UIO DRIVER FOR PCI DEVICES
 M:	"Michael S. Tsirkin" <[email protected]>
 L:	kvm at vger.kernel.org
drivers/Kconfig +2 -0
index 202fa6d..ad2c374a 100644
@@ -162,4 +162,6 @@ source "drivers/irqchip/Kconfig"
 
 source "drivers/ipack/Kconfig"
 
+source "drivers/phy/Kconfig"
+
 endmenu
drivers/Makefile +2 -0
index dce39a9..9da8321 100644
@@ -45,6 +45,8 @@ obj-y				+= char/
 # gpu/ comes after char for AGP vs DRM startup
 obj-y				+= gpu/
 
+obj-y				+= phy/
+
 obj-$(CONFIG_CONNECTOR)		+= connector/
 
 # i810fb and intelfb depend on char/agp/
drivers/phy/Kconfig new file +13 -0
new file mode 100644
index 0000000..5f85909
@@ -0,0 +1,13 @@
+#
+# PHY
+#
+
+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.
drivers/phy/Makefile new file +5 -0
new file mode 100644
index 0000000..9e9560f
@@ -0,0 +1,5 @@
+#
+# Makefile for the phy drivers.
+#
+
+obj-$(CONFIG_GENERIC_PHY)	+= phy-core.o
drivers/phy/phy-core.c new file +574 -0

574 lines not on this page · raw message

include/linux/phy/phy.h new file +218 -0

218 lines not on this page · raw message

Signature · 1 line
1.7.10.4
#2 lore raw

Re: [PATCH v3 1/6] drivers: phy: add generic PHY framework

Hi Kishon,

Quoted 18 lines · 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. To obtain a reference to the PHY without using phandle, the platform specfic intialization code (say from board file) should have already called phy_bind with the binding information. The binding information consists of phy's device name, phy user device name and an index. The index is used when the same phy user binds to mulitple phys.

PHY drivers should create the PHY by passing phy_descriptor that has describes the PHY (label, type etc..) and ops like init, exit, suspend, resume, poweron, shutdown.

The documentation for the generic PHY framework is added in Documentation/phy.txt and the documentation for the sysfs entry is added in Documentation/ABI/testing/sysfs-class-phy.

---

[...]

include/linux/phy/phy.h line 104

Quoted 3 lines
include/linux/phy/phy.h new file +3 -0
+static inline struct phy *phy_get(struct device *dev, int index)
+{
+	return ERR_PTR(-EOPNOTSUPP);

Shouldn't these be -ENOSYS ? EOPNOTSUPP is defined by POSIX as "Operation not supported on socket". And EOPNOTSUPP appears to be mostly used in the network code in the kernel.

Quoted 18 lines
include/linux/phy/phy.h new file +18 -0
+}
+
+static inline struct phy *devm_phy_get(struct device *dev, int index)
+{
+	return ERR_PTR(-EOPNOTSUPP);
+}
+
+static inline struct phy *of_phy_get(struct device *dev, int index)
+{
+	return ERR_PTR(-EOPNOTSUPP);
+}
+
+static inline struct phy *devm_of_phy_get(struct device *dev, int index)
+{
+	return ERR_PTR(-EOPNOTSUPP);
+}
+
+static inline struct phy *of_phy_get_byname(struct device *dev,

include/linux/phy/phy.h line 132

Quoted 10 lines
include/linux/phy/phy.h new file +10 -0
+	const char *string)
+{
+	return ERR_PTR(-EOPNOTSUPP);
+}
+
+static inline struct phy *devm_of_phy_get_byname(struct device *dev,
+	const char *string)
+{
+	return ERR_PTR(-EOPNOTSUPP);
+}

Thanks,
Sylwester

author
#3 lore raw

Re: [PATCH v3 1/6] drivers: phy: add generic PHY framework

Hi,

Quoted 27 lines · Sylwester Nawrocki

Hi Kishon,

Quoted 18 lines · 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. To obtain a reference to the PHY without
using phandle, the platform specfic intialization code (say from board file)
should have already called phy_bind with the binding information. The binding
information consists of phy's device name, phy user device name and an index.
The index is used when the same phy user binds to mulitple phys.

PHY drivers should create the PHY by passing phy_descriptor that has describes the PHY (label, type etc..) and ops like init, exit, suspend, resume,
poweron, shutdown.

Quoted 6 lines

The documentation for the generic PHY framework is added in Documentation/phy.txt and the documentation for the sysfs entry is added in Documentation/ABI/testing/sysfs-class-phy.

---

Quoted 8 lines

[...]

include/linux/phy/phy.h line 104

Quoted 3 lines
include/linux/phy/phy.h new file +3 -0
+static inline struct phy *phy_get(struct device *dev, int index)
+{
+    return ERR_PTR(-EOPNOTSUPP);

Shouldn't these be -ENOSYS ? EOPNOTSUPP is defined by POSIX as "Operation not supported on socket". And EOPNOTSUPP appears to be mostly used in the network code in the kernel.

Fair enough. Will change to ENOSYS.

Thanks
Kishon

#4 lore raw

Re: [PATCH v3 1/6] drivers: phy: add generic PHY framework

In reply to Kishon Vijay Abraham I
Quoted 12 lines · 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. To obtain a reference to the PHY without using phandle, the platform specfic intialization code (say from board file) should have already called phy_bind with the binding information. The binding information consists of phy's device name, phy user device name and an index. The index is used when the same phy user binds to mulitple phys.

PHY drivers should create the PHY by passing phy_descriptor that has describes the PHY (label, type etc..) and ops like init, exit, suspend, resume, poweron, shutdown.

Quoted 5 lines

The documentation for the generic PHY framework is added in Documentation/phy.txt and the documentation for the sysfs entry is added in Documentation/ABI/testing/sysfs-class-phy.

Hi Kishon,

For review purposes, I'll skip most of the implementation and focus on the data structures. I think you need to take another look at the approach your using. The kernel already provides a lot of support for implementing devices and binding them to drivers that you should be able to use...

[...]

Quoted 6 lines
include/linux/phy/phy.h new file +6 -0
+/**
+ * struct phy - represent the phy device
+ * @dev: phy device
+ * @label: label given to phy
+ * @type: specifies the phy type
+ * @of_node: device node of the phy

include/linux/phy/phy.h line 61

Quoted 10 lines
include/linux/phy/phy.h new file +10 -0
+ * @ops: function pointers for performing phy operations
+ */
+struct phy {
+	struct device		dev;
+	const char		*label;
+	int			type;
+	struct bus_type		*bus;
+	struct device_node	*of_node;
+	struct phy_ops		*ops;
+};

Alright, so the core of the functionality is this 'struct phy' which tracks all the instances of PHY devices. As I understand it each physical phy will have a 'struct phy' instance tracking it. That makes sense.

struct phy embeds a struct device. Also good. The linux driver model knows all about devices and how to handle them. However, most of the rest of this structure looks to be reinventing stuff the driver model already does.

'label' seems unnecessary. struct device embeds a struct kobject, which means it has a name and shows up in sysfs. Is there a reason that the device name cannot be used directly?

'type' I just don't understand. I don't see any users of it in this patch. I only see where it is set.

'bus' absolutely should not be here. The bus type should be set in the struct device by this subsystem when the device gets registered. There is no reason to have a pointer to it here.

'of_node' is already in struct device

Finally, it really doesn't look right for a device object to have an 'ops' structure. The whole point of the driver model is that a struct device doesn't encapsulate any behaviour. A device gets registers to a bus type, and then the driver core will associate a struct device_driver to a device that it is able to drive, and the struct device_driver is supposed to contain any ops structure used to control the device.

Quoted 8 lines
include/linux/phy/phy.h new file +8 -0
+
+/**
+ * struct phy_bind - represent the binding for the phy
+ * @dev_name: the device name of the device that will bind to the phy
+ * @phy_dev_name: the device name of the phy
+ * @index: used if a single controller uses multiple phys
+ * @auto_bind: tells if the binding is done explicitly from board file or not
+ * @phy: reference to the phy

include/linux/phy/phy.h line 79

Quoted 10 lines
include/linux/phy/phy.h new file +10 -0
+ * @list: to maintain a linked list of the binding information
+ */
+struct phy_bind {
+	const char	*dev_name;
+	const char	*phy_dev_name;
+	int		index;
+	int		auto_bind:1;
+	struct phy	*phy;
+	struct list_head list;
+};

How are PHYs attached to the system. Would the PHY be a direct child of the host controller device, or would a PHY hang off another bus (like i2c) for control? (this is how Ethernet phys work; they hang off the MDIO bus, but may be attached to any Ethernet controller).

Since there is at most a 1:N relationship between host controllers and PHYs, there shouldn't be any need for a separate structure to describe binding. Put the inding data into the struct phy itself. Each host controller can have a list of phys that it is bound to.

Tring to maintain a separate global list of PHY bindings isn't a good idea. Keep it local to the host controller and the specific phys instead.

g.

#5 lore raw

Re: [PATCH v3 1/6] drivers: phy: add generic PHY framework

Hi,

Quoted 51 lines · Grant Likely
Quoted 12 lines · 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. To obtain a reference to the PHY without using phandle, the platform specfic intialization code (say from board file) should have already called phy_bind with the binding information. The binding information consists of phy's device name, phy user device name and an index. The index is used when the same phy user binds to mulitple phys.

PHY drivers should create the PHY by passing phy_descriptor that has describes the PHY (label, type etc..) and ops like init, exit, suspend, resume, poweron, shutdown.

Quoted 5 lines

The documentation for the generic PHY framework is added in Documentation/phy.txt and the documentation for the sysfs entry is added in Documentation/ABI/testing/sysfs-class-phy.

Hi Kishon,

For review purposes, I'll skip most of the implementation and focus on the data structures. I think you need to take another look at the approach your using. The kernel already provides a lot of support for implementing devices and binding them to drivers that you should be able to use...

[...]

Quoted 6 lines
include/linux/phy/phy.h new file +6 -0
+/**
+ * struct phy - represent the phy device
+ * @dev: phy device
+ * @label: label given to phy
+ * @type: specifies the phy type
+ * @of_node: device node of the phy

include/linux/phy/phy.h line 61

Quoted 10 lines
include/linux/phy/phy.h new file +10 -0
+ * @ops: function pointers for performing phy operations
+ */
+struct phy {
+	struct device		dev;
+	const char		*label;
+	int			type;
+	struct bus_type		*bus;
+	struct device_node	*of_node;
+	struct phy_ops		*ops;
+};

Alright, so the core of the functionality is this 'struct phy' which tracks all the instances of PHY devices. As I understand it each physical phy will have a 'struct phy' instance tracking it. That makes sense.

Quoted 8 lines

struct phy embeds a struct device. Also good. The linux driver model knows all about devices and how to handle them. However, most of the rest of this structure looks to be reinventing stuff the driver model already does.

'label' seems unnecessary. struct device embeds a struct kobject, which means it has a name and shows up in sysfs. Is there a reason that the device name cannot be used directly?

hmm.. the label name is supposed to be a simpler name than device name. Say for instance "omap-usb2.1.auto" device name can simply be "omap-usb2-phy". Further the device name while using dt will have register address in it. However it's used only for displaying the label in sysfs entry (/sys/class/phy/<phy>/label).

Quoted 3 lines

'type' I just don't understand. I don't see any users of it in this patch. I only see where it is set.

yeah. Was planning to remove this in my next version (btw the latest is version 5).

Quoted 4 lines

'bus' absolutely should not be here. The bus type should be set in the struct device by this subsystem when the device gets registered. There is no reason to have a pointer to it here.

right. I had removed it in version 5 of this patch series.

Quoted 2 lines

'of_node' is already in struct device

I wasn't sure if we can manually assign the of_node of one device to of_node of an another device. Here the of_node comes from _phy provider_.

Quoted 5 lines

Finally, it really doesn't look right for a device object to have an 'ops' structure. The whole point of the driver model is that a struct device doesn't encapsulate any behaviour. A device gets registers to a bus type, and then the driver core will associate a struct device_driver

We have decided not to implement the PHY layer as a separate bus layer. The PHY provider can be part of any other bus. Making the PHY layer as a bus will make the PHY provider to be part of multiple buses which will lead to bad design. All we are trying to do here is keep the pool of PHY devices under PHY class in this layer and help any controller that wants to use the PHY to get it.

Quoted 18 lines

to a device that it is able to drive, and the struct device_driver is supposed to contain any ops structure used to control the device.

Quoted 15 lines
include/linux/phy/phy.h new file +15 -0
+
+/**
+ * struct phy_bind - represent the binding for the phy
+ * @dev_name: the device name of the device that will bind to the phy
+ * @phy_dev_name: the device name of the phy
+ * @index: used if a single controller uses multiple phys
+ * @auto_bind: tells if the binding is done explicitly from board file or not
+ * @phy: reference to the phy
+ * @list: to maintain a linked list of the binding information
+ */
+struct phy_bind {
+	const char	*dev_name;
+	const char	*phy_dev_name;
+	int		index;
+	int		auto_bind:1;
Quoted 8 lines

include/linux/phy/phy.h line 79

Quoted 3 lines
include/linux/phy/phy.h new file +3 -0
+	struct phy	*phy;
+	struct list_head list;
+};

How are PHYs attached to the system. Would the PHY be a direct child of the host controller device, or would a PHY hang off another bus (like i2c) for control? (this is how Ethernet phys work; they hang off the MDIO bus, but may be attached to any Ethernet controller).

This layer does not have any restriction on how the PHY is attached to the system. For all the sample cases (USB OTG controller in OMAP platforms) that follows this patch, the PHY is attached to the platform bus and the PHY provider is a platform driver. All this framework does is maintain a list of PHY's added in the system and helps the controller to find the appropriate PHY.
We are currently not looking at having Ethernet use this layer because it itself has a comprehensive PHY layer and merging it with this will take some effort. However other subsystems like USB, SATA, video etc.. can make use of this.

Quoted 5 lines

Since there is at most a 1:N relationship between host controllers and PHYs, there shouldn't be any need for a separate structure to describe binding. Put the inding data into the struct phy itself. Each host controller can have a list of phys that it is bound to.

No. Having the host controller to have a list of phys wont be a good idea IMHO. The host controller is just an IP and the PHY to which it will be connected can vary from board to board, platform to platform. So ideally this binding should come from platform initialization code/dt data.

Thanks
Kishon

#6 lore raw

Re: [PATCH v3 1/6] drivers: phy: add generic PHY framework

Quoted 63 lines · Kishon Vijay Abraham I

Hi,

Quoted 51 lines · Grant Likely
Quoted 12 lines · 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. To obtain a reference to the PHY without using phandle, the platform specfic intialization code (say from board file) should have already called phy_bind with the binding information. The binding information consists of phy's device name, phy user device name and an index. The index is used when the same phy user binds to mulitple phys.

PHY drivers should create the PHY by passing phy_descriptor that has describes the PHY (label, type etc..) and ops like init, exit, suspend, resume, poweron, shutdown.

Quoted 5 lines

The documentation for the generic PHY framework is added in Documentation/phy.txt and the documentation for the sysfs entry is added in Documentation/ABI/testing/sysfs-class-phy.

Hi Kishon,

For review purposes, I'll skip most of the implementation and focus on the data structures. I think you need to take another look at the approach your using. The kernel already provides a lot of support for implementing devices and binding them to drivers that you should be able to use...

[...]

Quoted 6 lines
include/linux/phy/phy.h new file +6 -0
+/**
+ * struct phy - represent the phy device
+ * @dev: phy device
+ * @label: label given to phy
+ * @type: specifies the phy type
+ * @of_node: device node of the phy

include/linux/phy/phy.h line 61

Quoted 10 lines
include/linux/phy/phy.h new file +10 -0
+ * @ops: function pointers for performing phy operations
+ */
+struct phy {
+	struct device		dev;
+	const char		*label;
+	int			type;
+	struct bus_type		*bus;
+	struct device_node	*of_node;
+	struct phy_ops		*ops;
+};

Alright, so the core of the functionality is this 'struct phy' which tracks all the instances of PHY devices. As I understand it each physical phy will have a 'struct phy' instance tracking it. That makes sense.

Quoted 8 lines

struct phy embeds a struct device. Also good. The linux driver model knows all about devices and how to handle them. However, most of the rest of this structure looks to be reinventing stuff the driver model already does.

'label' seems unnecessary. struct device embeds a struct kobject, which means it has a name and shows up in sysfs. Is there a reason that the device name cannot be used directly?

Quoted 5 lines

hmm.. the label name is supposed to be a simpler name than device name. Say for instance "omap-usb2.1.auto" device name can simply be "omap-usb2-phy". Further the device name while using dt will have register address in it. However it's used only for displaying the label in sysfs entry (/sys/class/phy/<phy>/label).

I wouldn't go mucking with names in that way. Stick with one name and drop the separate label. Otherwise you introduce addtional sources of confusion.

Quoted 11 lines
Quoted 3 lines

'type' I just don't understand. I don't see any users of it in this patch. I only see where it is set.

yeah. Was planning to remove this in my next version (btw the latest is version 5).

Quoted 4 lines

'bus' absolutely should not be here. The bus type should be set in the struct device by this subsystem when the device gets registered. There is no reason to have a pointer to it here.

Quoted 6 lines

right. I had removed it in version 5 of this patch series.

Quoted 2 lines

'of_node' is already in struct device

I wasn't sure if we can manually assign the of_node of one device to of_node of an another device. Here the of_node comes from _phy provider_.

There is no problem with multiple devices referencing the same node. The only time it may cause problems is when two devices of the same bus type are referencing the same of_node. In that situation the device will get probed more than once. You're not in that situation.

Quoted 11 lines
Quoted 4 lines

Finally, it really doesn't look right for a device object to have an 'ops' structure. The whole point of the driver model is that a struct device doesn't encapsulate any behaviour. A device gets registers to a bus type, and then the driver core will associate a struct device_driver

We have decided not to implement the PHY layer as a separate bus layer. The PHY provider can be part of any other bus. Making the PHY layer as a bus will make the PHY provider to be part of multiple buses which will lead to bad design. All we are trying to do here is keep the pool of PHY devices under PHY class in this layer and help any controller that wants to use the PHY to get it.

If you're using a class, then you already have your list of registered phy devices! :-) No need to create another global list that you need to manage.

You really need to be careful here though. By lumping all the phy types into a single pot your glossing over the fact that different subsystems have phys that behave differently. It is just fine to have a framework that works in lots of places, it's actively encouraged, but by putting the struct device into struct phy, you're taping into a large amount of assumptions that the linux kernel makes about what devices are. For instance, it is generally assumed that a class contains a bunch of the same devices; but in this framework it is explicitly not true.

I would also imagine that each of the subsystems will want to wrap the struct phy with subsystem specific additions so it will be important to ensure the correct type of device is always returned.

You'd be better off providing a set of utility functions that work for all the types of phys, but have a separate instance for each one. For example, you could have a separate class for each phy type, but all of them use the same utility function.

Quoted 27 lines
Quoted 18 lines

to a device that it is able to drive, and the struct device_driver is supposed to contain any ops structure used to control the device.

Quoted 15 lines
include/linux/phy/phy.h new file +15 -0
+
+/**
+ * struct phy_bind - represent the binding for the phy
+ * @dev_name: the device name of the device that will bind to the phy
+ * @phy_dev_name: the device name of the phy
+ * @index: used if a single controller uses multiple phys
+ * @auto_bind: tells if the binding is done explicitly from board file or not
+ * @phy: reference to the phy
+ * @list: to maintain a linked list of the binding information
+ */
+struct phy_bind {
+	const char	*dev_name;
+	const char	*phy_dev_name;
+	int		index;
+	int		auto_bind:1;
Quoted 8 lines

include/linux/phy/phy.h line 79

Quoted 3 lines
include/linux/phy/phy.h new file +3 -0
+	struct phy	*phy;
+	struct list_head list;
+};

How are PHYs attached to the system. Would the PHY be a direct child of the host controller device, or would a PHY hang off another bus (like i2c) for control? (this is how Ethernet phys work; they hang off the MDIO bus, but may be attached to any Ethernet controller).

Quoted 6 lines

This layer does not have any restriction on how the PHY is attached to the system. For all the sample cases (USB OTG controller in OMAP platforms) that follows this patch, the PHY is attached to the platform bus and the PHY provider is a platform driver. All this framework does is maintain a list of PHY's added in the system and helps the controller to find the appropriate PHY.

Okay, that's what I thought. A lot of systems end up looking this way. So I would assume that for an i2c-controlled phy, and i2c driver would bind against the device, and the probe hook would create and register a phy device. That would make the sysfs tree look something like:

/sys/devices/.../i2c at 80000000/usbphy at 2/phy0

where, i2c at 80000000 is the i2c master, usbphy at 2 is what the phy's driver binds against, and phy0 is created and registered by the driver of usbphy at 2 at probe time. Correct?

Quoted 10 lines

We are currently not looking at having Ethernet use this layer because it itself has a comprehensive PHY layer and merging it with this will take some effort. However other subsystems like USB, SATA, video etc.. can make use of this.

Quoted 5 lines

Since there is at most a 1:N relationship between host controllers and PHYs, there shouldn't be any need for a separate structure to describe binding. Put the inding data into the struct phy itself. Each host controller can have a list of phys that it is bound to.

Quoted 4 lines

No. Having the host controller to have a list of phys wont be a good idea IMHO. The host controller is just an IP and the PHY to which it will be connected can vary from board to board, platform to platform. So ideally this binding should come from platform initialization code/dt data.

That is not what I mean. I mean the host controller instance should contain a list of all the PHYs that are attached to it. There should not be a global list. That has nothing to do with where the data of binding comes from.

g.

#7 lore raw

Re: [PATCH v3 1/6] drivers: phy: add generic PHY framework

Hi,

Quoted 70 lines · Grant Likely
Quoted 63 lines · Kishon Vijay Abraham I

Hi,

Quoted 51 lines · Grant Likely
Quoted 12 lines · 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. To obtain a reference to the PHY without using phandle, the platform specfic intialization code (say from board file) should have already called phy_bind with the binding information. The binding information consists of phy's device name, phy user device name and an index. The index is used when the same phy user binds to mulitple phys.

PHY drivers should create the PHY by passing phy_descriptor that has describes the PHY (label, type etc..) and ops like init, exit, suspend, resume, poweron, shutdown.

Quoted 5 lines

The documentation for the generic PHY framework is added in Documentation/phy.txt and the documentation for the sysfs entry is added in Documentation/ABI/testing/sysfs-class-phy.

Hi Kishon,

For review purposes, I'll skip most of the implementation and focus on the data structures. I think you need to take another look at the approach your using. The kernel already provides a lot of support for implementing devices and binding them to drivers that you should be able to use...

[...]

Quoted 6 lines
include/linux/phy/phy.h new file +6 -0
+/**
+ * struct phy - represent the phy device
+ * @dev: phy device
+ * @label: label given to phy
+ * @type: specifies the phy type
+ * @of_node: device node of the phy

include/linux/phy/phy.h line 61

Quoted 10 lines
include/linux/phy/phy.h new file +10 -0
+ * @ops: function pointers for performing phy operations
+ */
+struct phy {
+	struct device		dev;
+	const char		*label;
+	int			type;
+	struct bus_type		*bus;
+	struct device_node	*of_node;
+	struct phy_ops		*ops;
+};

Alright, so the core of the functionality is this 'struct phy' which tracks all the instances of PHY devices. As I understand it each physical phy will have a 'struct phy' instance tracking it. That makes sense.

Quoted 8 lines

struct phy embeds a struct device. Also good. The linux driver model knows all about devices and how to handle them. However, most of the rest of this structure looks to be reinventing stuff the driver model already does.

'label' seems unnecessary. struct device embeds a struct kobject, which means it has a name and shows up in sysfs. Is there a reason that the device name cannot be used directly?

Quoted 5 lines

hmm.. the label name is supposed to be a simpler name than device name. Say for instance "omap-usb2.1.auto" device name can simply be "omap-usb2-phy". Further the device name while using dt will have register address in it. However it's used only for displaying the label in sysfs entry (/sys/class/phy/<phy>/label).

Quoted 3 lines

I wouldn't go mucking with names in that way. Stick with one name and drop the separate label. Otherwise you introduce addtional sources of confusion.

hmm.. ok.

Quoted 16 lines
Quoted 16 lines
Quoted 4 lines

'type' I just don't understand. I don't see any users of it in this patch. I only see where it is set.

yeah. Was planning to remove this in my next version (btw the latest is version 5).

Quoted 4 lines

'bus' absolutely should not be here. The bus type should be set in the struct device by this subsystem when the device gets registered. There is no reason to have a pointer to it here.

right. I had removed it in version 5 of this patch series.

Quoted 2 lines

'of_node' is already in struct device

Quoted 7 lines
Quoted 2 lines

I wasn't sure if we can manually assign the of_node of one device to of_node of an another device. Here the of_node comes from _phy provider_.

There is no problem with multiple devices referencing the same node. The only time it may cause problems is when two devices of the same bus type are referencing the same of_node. In that situation the device will get probed more than once. You're not in that situation.

right. Will re-use of_node.

Quoted 13 lines
Quoted 6 lines
Quoted 5 lines

Finally, it really doesn't look right for a device object to have an 'ops' structure. The whole point of the driver model is that a struct device doesn't encapsulate any behaviour. A device gets registers to a bus type, and then the driver core will associate a struct device_driver

Quoted 6 lines

We have decided not to implement the PHY layer as a separate bus layer. The PHY provider can be part of any other bus. Making the PHY layer as a bus will make the PHY provider to be part of multiple buses which will lead to bad design. All we are trying to do here is keep the pool of PHY devices under PHY class in this layer and help any controller that wants to use the PHY to get it.

Quoted 3 lines

If you're using a class, then you already have your list of registered phy devices! :-) No need to create another global list that you need to manage.

right. We already use _class_dev_iter_ for finding the phy device. .
.
+static struct phy *of_phy_lookup(struct device *dev, struct device_node *node)
+{
+ struct phy *phy;
+ struct class_dev_iter iter;
+
+ class_dev_iter_init(&iter, phy_class, NULL, NULL);
+ while ((dev = class_dev_iter_next(&iter))) {
+ phy = container_of(dev, struct phy, dev);
+ if (node != phy->of_node)
+ continue;
+
+ class_dev_iter_exit(&iter);
+ return phy;
+ }
+
+ class_dev_iter_exit(&iter);
+ return ERR_PTR(-EPROBE_DEFER);
+}
.
.

however we can't get rid of the other list (phy_bind_list) where we maintain the phy binding information. It's used for the non-dt boot case.

Quoted 10 lines

You really need to be careful here though. By lumping all the phy types into a single pot your glossing over the fact that different subsystems have phys that behave differently. It is just fine to have a framework that works in lots of places, it's actively encouraged, but by putting the struct device into struct phy, you're taping into a large amount of assumptions that the linux kernel makes about what devices are. For instance, it is generally assumed that a class contains a bunch of the same devices; but in this framework it is explicitly not true.

Quoted 3 lines

I would also imagine that each of the subsystems will want to wrap the struct phy with subsystem specific additions so it will be important to ensure the correct type of device is always returned.

right. Probably this framework right now tries to implement the simplest/default case which wouldn't need subsystem specific additions. But yes, we might need to add subsystem specific additions in the future.

Quoted 45 lines

You'd be better off providing a set of utility functions that work for all the types of phys, but have a separate instance for each one. For example, you could have a separate class for each phy type, but all of them use the same utility function.

Quoted 27 lines
Quoted 18 lines

to a device that it is able to drive, and the struct device_driver is supposed to contain any ops structure used to control the device.

Quoted 15 lines
include/linux/phy/phy.h new file +15 -0
+
+/**
+ * struct phy_bind - represent the binding for the phy
+ * @dev_name: the device name of the device that will bind to the phy
+ * @phy_dev_name: the device name of the phy
+ * @index: used if a single controller uses multiple phys
+ * @auto_bind: tells if the binding is done explicitly from board file or not
+ * @phy: reference to the phy
+ * @list: to maintain a linked list of the binding information
+ */
+struct phy_bind {
+	const char	*dev_name;
+	const char	*phy_dev_name;
+	int		index;
+	int		auto_bind:1;
Quoted 8 lines

include/linux/phy/phy.h line 79

Quoted 3 lines
include/linux/phy/phy.h new file +3 -0
+	struct phy	*phy;
+	struct list_head list;
+};

How are PHYs attached to the system. Would the PHY be a direct child of the host controller device, or would a PHY hang off another bus (like i2c) for control? (this is how Ethernet phys work; they hang off the MDIO bus, but may be attached to any Ethernet controller).

Quoted 6 lines

This layer does not have any restriction on how the PHY is attached to the system. For all the sample cases (USB OTG controller in OMAP platforms) that follows this patch, the PHY is attached to the platform bus and the PHY provider is a platform driver. All this framework does is maintain a list of PHY's added in the system and helps the controller to find the appropriate PHY.

Okay, that's what I thought. A lot of systems end up looking this way. So I would assume that for an i2c-controlled phy, and i2c driver would bind against the device, and the probe hook would create and register a phy device. That would make the sysfs tree look something like:

Quoted 5 lines

/sys/devices/.../i2c at 80000000/usbphy at 2/phy0

where, i2c at 80000000 is the i2c master, usbphy at 2 is what the phy's driver binds against, and phy0 is created and registered by the driver of usbphy at 2 at probe time. Correct?

correct.

Quoted 11 lines
Quoted 11 lines

We are currently not looking at having Ethernet use this layer because it itself has a comprehensive PHY layer and merging it with this will take some effort. However other subsystems like USB, SATA, video etc.. can make use of this.

Quoted 5 lines

Since there is at most a 1:N relationship between host controllers and PHYs, there shouldn't be any need for a separate structure to describe binding. Put the inding data into the struct phy itself. Each host controller can have a list of phys that it is bound to.

Quoted 7 lines
Quoted 4 lines

No. Having the host controller to have a list of phys wont be a good idea IMHO. The host controller is just an IP and the PHY to which it will be connected can vary from board to board, platform to platform. So ideally this binding should come from platform initialization code/dt data.

That is not what I mean. I mean the host controller instance should contain a list of all the PHYs that are attached to it. There should not

Doesn't sound correct IMO. The host controller instance need not know anything about the PHY instances that is connected to it. Think of it similar to regulator, the controller wouldn't know which regulator it is connected to, all it has to know is it just has a regulator connected to it. It's up-to the regulator framework to give the controller the correct regulator. It's similar here. It makes sense for me to keep a list in the PHY framework in order for it to return the correct PHY (but note that this list is not needed for dt boot).

Thanks
Kishon

#8 lore raw

Re: [PATCH v3 1/6] drivers: phy: add generic PHY framework

Quoted 40 lines · Kishon Vijay Abraham I
Quoted 10 lines · Grant Likely
Quoted 8 lines · Kishon Vijay Abraham I
Quoted 1 line · Grant Likely

On Wed, 20 Mar 2013 14:42:00 +0530, Kishon Vijay Abraham I <[email protected]> wrote:

We have decided not to implement the PHY layer as a separate bus layer. The PHY provider can be part of any other bus. Making the PHY layer as a bus will make the PHY provider to be part of multiple buses which will lead to bad design. All we are trying to do here is keep the pool of PHY devices under PHY class in this layer and help any controller that wants to use the PHY to get it.

Quoted 3 lines

If you're using a class, then you already have your list of registered phy devices! :-) No need to create another global list that you need to manage.

right. We already use _class_dev_iter_ for finding the phy device. .
.
+static struct phy *of_phy_lookup(struct device *dev, struct device_node *node)

drivers/phy/phy-core.c new file +17 -0
+{
+	struct phy *phy;
+	struct class_dev_iter iter;
+
+	class_dev_iter_init(&iter, phy_class, NULL, NULL);
+	while ((dev = class_dev_iter_next(&iter))) {
+		phy = container_of(dev, struct phy, dev);
+		if (node != phy->of_node)
+			continue;
+
+		class_dev_iter_exit(&iter);
+		return phy;
+	}
+
+	class_dev_iter_exit(&iter);
+	return ERR_PTR(-EPROBE_DEFER);
+}

.
.

Quoted 2 lines

however we can't get rid of the other list (phy_bind_list) where we maintain the phy binding information. It's used for the non-dt boot case.

Why? If you're using a class, then it is always there. Why would non-DT and DT be different in this regard? (more below)

Quoted 13 lines
Quoted 5 lines
Quoted 5 lines
Quoted 4 lines

Since there is at most a 1:N relationship between host controllers and PHYs, there shouldn't be any need for a separate structure to describe binding. Put the inding data into the struct phy itself. Each host controller can have a list of phys that it is bound to.

Quoted 7 lines
Quoted 4 lines

No. Having the host controller to have a list of phys wont be a good idea IMHO. The host controller is just an IP and the PHY to which it will be connected can vary from board to board, platform to platform. So ideally this binding should come from platform initialization code/dt data.

That is not what I mean. I mean the host controller instance should contain a list of all the PHYs that are attached to it. There should not

Quoted 8 lines

Doesn't sound correct IMO. The host controller instance need not know anything about the PHY instances that is connected to it. Think of it similar to regulator, the controller wouldn't know which regulator it is connected to, all it has to know is it just has a regulator connected to it. It's up-to the regulator framework to give the controller the correct regulator. It's similar here. It makes sense for me to keep a list in the PHY framework in order for it to return the correct PHY (but note that this list is not needed for dt boot).

With regulators and clocks it makes sense to have a global registration place becase both implement an interconnected network independent of the device that use them. (clocks depend on other clocks; regulators depend on other regulators).

Phys are different. There is a 1:N relationship between host controllers and phys, and you don't get a interconnected network of PHYs. Its a bad idea to keep the binding data separate from the actual host controller when there is nothing else that actually needs to use the data. It creates a new set of data structures that need housekeeping to keep them in sync with the actual device structures. It really is just a bad idea and it becomes more difficult (in the non-DT case) to determine what data is associated with a given host controller. You can't tell by looking at the struct device.

Instead, for the non-DT case, do what we've always done for describing connections. Put the phy reference into the host controllers platform_data structure. That is what it is there for. That completely eliminates the need to housekeep a new set of data structures.

g.

#9 lore raw

Re: [PATCH v3 1/6] drivers: phy: add generic PHY framework

Hi,

Quoted 84 lines · Grant Likely
Quoted 40 lines · Kishon Vijay Abraham I
Quoted 10 lines · Grant Likely
Quoted 8 lines · Kishon Vijay Abraham I
Quoted 1 line · Grant Likely

On Wed, 20 Mar 2013 14:42:00 +0530, Kishon Vijay Abraham I <[email protected]> wrote:

We have decided not to implement the PHY layer as a separate bus layer. The PHY provider can be part of any other bus. Making the PHY layer as a bus will make the PHY provider to be part of multiple buses which will lead to bad design. All we are trying to do here is keep the pool of PHY devices under PHY class in this layer and help any controller that wants to use the PHY to get it.

Quoted 3 lines

If you're using a class, then you already have your list of registered phy devices! :-) No need to create another global list that you need to manage.

right. We already use _class_dev_iter_ for finding the phy device. .
.
+static struct phy *of_phy_lookup(struct device *dev, struct device_node *node)

drivers/phy/phy-core.c new file +17 -0
+{
+	struct phy *phy;
+	struct class_dev_iter iter;
+
+	class_dev_iter_init(&iter, phy_class, NULL, NULL);
+	while ((dev = class_dev_iter_next(&iter))) {
+		phy = container_of(dev, struct phy, dev);
+		if (node != phy->of_node)
+			continue;
+
+		class_dev_iter_exit(&iter);
+		return phy;
+	}
+
+	class_dev_iter_exit(&iter);
+	return ERR_PTR(-EPROBE_DEFER);
+}

.
.

Quoted 2 lines

however we can't get rid of the other list (phy_bind_list) where we maintain the phy binding information. It's used for the non-dt boot case.

Why? If you're using a class, then it is always there. Why would non-DT and DT be different in this regard? (more below)

Quoted 13 lines
Quoted 5 lines
Quoted 5 lines
Quoted 4 lines

Since there is at most a 1:N relationship between host controllers and PHYs, there shouldn't be any need for a separate structure to describe binding. Put the inding data into the struct phy itself. Each host controller can have a list of phys that it is bound to.

Quoted 7 lines
Quoted 4 lines

No. Having the host controller to have a list of phys wont be a good idea IMHO. The host controller is just an IP and the PHY to which it will be connected can vary from board to board, platform to platform. So ideally this binding should come from platform initialization code/dt data.

That is not what I mean. I mean the host controller instance should contain a list of all the PHYs that are attached to it. There should not

Quoted 8 lines

Doesn't sound correct IMO. The host controller instance need not know anything about the PHY instances that is connected to it. Think of it similar to regulator, the controller wouldn't know which regulator it is connected to, all it has to know is it just has a regulator connected to it. It's up-to the regulator framework to give the controller the correct regulator. It's similar here. It makes sense for me to keep a list in the PHY framework in order for it to return the correct PHY (but note that this list is not needed for dt boot).

With regulators and clocks it makes sense to have a global registration place becase both implement an interconnected network independent of the device that use them. (clocks depend on other clocks; regulators depend on other regulators).

Phys are different. There is a 1:N relationship between host controllers and phys, and you don't get a interconnected network of PHYs. Its a bad idea to keep the binding data separate from the actual host controller when there is nothing else that actually needs to use the data. It creates a new set of data structures that need housekeeping to keep them in sync with the actual device structures. It really is just a bad idea and it becomes more difficult (in the non-DT case) to determine what data is associated with a given host controller. You can't tell by looking at the struct device.

Quoted 3 lines

Instead, for the non-DT case, do what we've always done for describing connections. Put the phy reference into the host controllers platform_data structure.

hmm... my only concern here is there is no way we can enforce the phy reference is added in the platform_data structure.
That is what it is there for. That completely

Quoted 1 line

eliminates the need to housekeep a new set of data structures.

Ok. Makes sense.

Thanks
Kishon

#10 lore raw

PATCH v3 2/6 usb: phy: omap-usb2: use the new generic PHY framework

In reply to Kishon Vijay Abraham I

Used the generic PHY framework API to create the PHY. omap_usb2_suspend is split into omap_usb_suspend and omap_usb_resume in order to align with the new framework.

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.

---
 drivers/usb/phy/omap-usb2.c |   47 +++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 47 insertions(+)
drivers/usb/phy/omap-usb2.c +47 -0
index 844ab68..819ba71 100644
@@ -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,9 +120,48 @@ static int omap_usb2_suspend(struct usb_phy *x, int suspend)
 	return 0;
 }
 
+static int omap_usb_suspend(struct phy *x)
+{
+	struct omap_usb *phy = dev_get_drvdata(&x->dev);
+
+	if (!phy->is_suspended) {
+		omap_control_usb_phy_power(phy->control_dev, 0);
+		pm_runtime_put_sync(phy->dev);
+		phy->is_suspended = 1;
+	}
+
+	return 0;
+}
+
+static int omap_usb_resume(struct phy *x)
+{
+	u32 ret;
+	struct omap_usb *phy = dev_get_drvdata(&x->dev);
+
+	if (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 struct phy_ops ops = {
+	.suspend	= omap_usb_suspend,
+	.resume		= omap_usb_resume,
+	.owner		= THIS_MODULE,
+};
+
 static int omap_usb2_probe(struct platform_device *pdev)
 {
 	struct omap_usb			*phy;
+	struct phy			*generic_phy;
 	struct usb_otg			*otg;
 
 	phy = devm_kzalloc(&pdev->dev, sizeof(*phy), GFP_KERNEL);
@@ -144,6 +184,13 @@ static int omap_usb2_probe(struct platform_device *pdev)
 	phy->phy.otg		= otg;
 	phy->phy.type		= USB_PHY_TYPE_USB2;
 
+	generic_phy = devm_phy_create(phy->dev, "omap-usb2", pdev->dev.of_node,
+		USB_PHY_TYPE_USB2, &ops, phy);
+	if (IS_ERR(generic_phy)) {
+		dev_dbg(&pdev->dev, "Failed to create PHY\n");
+		return PTR_ERR(generic_phy);
+	}
+
 	phy->control_dev = omap_get_control_dev();
 	if (IS_ERR(phy->control_dev)) {
 		dev_dbg(&pdev->dev, "Failed to get control device\n");
Signature · 1 line
1.7.10.4
#11 lore raw

PATCH v3 3/6 usb: otg: twl4030: use the new generic PHY framework

In reply to Kishon Vijay Abraham I

Used the generic PHY framework API to create the PHY. twl4030_usb_suspend and twl4030_usb_resume is added to phy_ops in order to align with the new framework.

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.

---
 drivers/usb/otg/twl4030-usb.c |   36 ++++++++++++++++++++++++++++++++++++
 1 file changed, 36 insertions(+)
drivers/usb/otg/twl4030-usb.c +36 -0
index a994715..aebcd6a 100644
@@ -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>
@@ -575,10 +576,38 @@ static int twl4030_set_host(struct usb_otg *otg, struct usb_bus *host)
 	return 0;
 }
 
+static int twl4030_usb_suspend(struct phy *phy)
+{
+	struct twl4030_usb *twl = dev_get_drvdata(&phy->dev);
+
+	twl4030_phy_suspend(twl, 1);
+
+	return 0;
+}
+
+static int twl4030_usb_resume(struct phy *phy)
+{
+	struct twl4030_usb *twl = dev_get_drvdata(&phy->dev);
+
+	if (!twl->asleep)
+		return -EBUSY;
+	__twl4030_phy_resume(twl);
+	twl->asleep = 0;
+
+	return 0;
+}
+
+static struct phy_ops ops = {
+	.suspend	= twl4030_usb_suspend,
+	.resume		= twl4030_usb_resume,
+	.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;
@@ -617,6 +646,13 @@ static int twl4030_usb_probe(struct platform_device *pdev)
 	otg->set_host		= twl4030_set_host;
 	otg->set_peripheral	= twl4030_set_peripheral;
 
+	phy = devm_phy_create(twl->dev, "twl4030", pdev->dev.of_node,
+		USB_PHY_TYPE_USB2, &ops, twl);
+	if (IS_ERR(phy)) {
+		dev_dbg(&pdev->dev, "Failed to create PHY\n");
+		return PTR_ERR(phy);
+	}
+
 	/* init spinlock for workqueue */
 	spin_lock_init(&twl->lock);
 
Signature · 1 line
1.7.10.4
#12 lore raw

PATCH v3 4/6 ARM: OMAP: USB: Add phy binding information

In reply to Kishon Vijay Abraham I

In order for controllers to get PHY in case of non dt boot, the phy binding information should be added in the platform specific initialization code using phy_bind. The previously added usb_bind_phy can't be removed yet because the musb controller continues to use the old PHY library which has OTG in it (struct usb_phy has struct usb_otg as member). Until we have a separate OTG state machine to handle all of that, the new generic PHY framework and the old phy library will co-exist.

---
 arch/arm/mach-omap2/board-2430sdp.c          |    2 ++
 arch/arm/mach-omap2/board-3430sdp.c          |    2 ++
 arch/arm/mach-omap2/board-4430sdp.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-omap4panda.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 ++
 18 files changed, 36 insertions(+)
arch/arm/mach-omap2/board-2430sdp.c +2 -0
index a3e0aaa..271458b 100644
@@ -28,6 +28,7 @@
 #include <linux/io.h>
 #include <linux/gpio.h>
 #include <linux/usb/phy.h>
+#include <linux/phy/phy.h>
 
 #include <asm/mach-types.h>
 #include <asm/mach/arch.h>
@@ -265,6 +266,7 @@ static void __init omap_2430sdp_init(void)
 
 	omap_mux_init_signal("usb0hs_stp", OMAP_PULL_ENA | OMAP_PULL_UP);
 	usb_bind_phy("musb-hdrc.0.auto", 0, "twl4030_usb");
+	phy_bind("musb-hdrc.0.auto", 0, "twl4030_usb");
 	usb_musb_init(NULL);
 
 	board_smc91x_init();
arch/arm/mach-omap2/board-3430sdp.c +2 -0
index ce812de..bf6ce1d 100644
@@ -27,6 +27,7 @@
 #include <linux/platform_data/spi-omap2-mcspi.h>
 #include <linux/platform_data/omap-twl4030.h>
 #include <linux/usb/phy.h>
+#include <linux/phy/phy.h>
 
 #include <asm/mach-types.h>
 #include <asm/mach/arch.h>
@@ -601,6 +602,7 @@ static void __init omap_3430sdp_init(void)
 	omap_serial_init();
 	omap_sdrc_init(hyb18m512160af6_sdrc_params, NULL);
 	usb_bind_phy("musb-hdrc.0.auto", 0, "twl4030_usb");
+	phy_bind("musb-hdrc.0.auto", 0, "twl4030_usb");
 	usb_musb_init(NULL);
 	board_smc91x_init();
 	board_flash_init(sdp_flash_partitions, chip_sel_3430, 0);
arch/arm/mach-omap2/board-4430sdp.c +2 -0
index 35f3ad0..1a236cb 100644
@@ -32,6 +32,7 @@
 #include <linux/platform_data/omap4-keypad.h>
 #include <linux/usb/musb.h>
 #include <linux/usb/phy.h>
+#include <linux/phy/phy.h>
 
 #include <asm/mach-types.h>
 #include <asm/mach/arch.h>
@@ -725,6 +726,7 @@ static void __init omap_4430sdp_init(void)
 	omap4_twl6030_hsmmc_init(mmc);
 
 	usb_bind_phy("musb-hdrc.0.auto", 0, "omap-usb2.1.auto");
+	phy_bind("musb-hdrc.0.auto", 0, "omap-usb2.1.auto");
 	usb_musb_init(&musb_board_data);
 
 	status = omap_ethernet_init();
arch/arm/mach-omap2/board-cm-t35.c +2 -0
index af2bb21..6a2615a 100644
@@ -31,6 +31,7 @@
 #include <linux/regulator/machine.h>
 #include <linux/mmc/host.h>
 #include <linux/usb/phy.h>
+#include <linux/phy/phy.h>
 
 #include <linux/spi/spi.h>
 #include <linux/spi/tdo24m.h>
@@ -726,6 +727,7 @@ static void __init cm_t3x_common_init(void)
 	omap_twl4030_audio_init("cm-t3x", NULL);
 
 	usb_bind_phy("musb-hdrc.0.auto", 0, "twl4030_usb");
+	phy_bind("musb-hdrc.0.auto", 0, "twl4030_usb");
 	usb_musb_init(NULL);
 	cm_t35_init_usbh();
 	cm_t35_init_camera();
arch/arm/mach-omap2/board-devkit8000.c +2 -0
index 53056c3..4ca7d23 100644
@@ -30,6 +30,7 @@
 #include <linux/mtd/nand.h>
 #include <linux/mmc/host.h>
 #include <linux/usb/phy.h>
+#include <linux/phy/phy.h>
 
 #include <linux/regulator/machine.h>
 #include <linux/i2c/twl.h>
@@ -624,6 +625,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");
+	phy_bind("musb-hdrc.0.auto", 0, "twl4030_usb");
 	usb_musb_init(NULL);
 	usbhs_init(&usbhs_bdata);
 	board_nand_init(devkit8000_nand_partitions,
arch/arm/mach-omap2/board-igep0020.c +2 -0
index bf92678..f0c28bc 100644
@@ -19,6 +19,7 @@
 #include <linux/interrupt.h>
 #include <linux/input.h>
 #include <linux/usb/phy.h>
+#include <linux/phy/phy.h>
 
 #include <linux/regulator/machine.h>
 #include <linux/regulator/fixed.h>
@@ -627,6 +628,7 @@ static void __init igep_init(void)
 	omap_sdrc_init(m65kxxxxam_sdrc_params,
 				  m65kxxxxam_sdrc_params);
 	usb_bind_phy("musb-hdrc.0.auto", 0, "twl4030_usb");
+	phy_bind("musb-hdrc.0.auto", 0, "twl4030_usb");
 	usb_musb_init(NULL);
 
 	igep_flash_init();
arch/arm/mach-omap2/board-ldp.c +2 -0
index b12fe96..3f43626 100644
@@ -29,6 +29,7 @@
 #include <linux/smsc911x.h>
 #include <linux/mmc/host.h>
 #include <linux/usb/phy.h>
+#include <linux/phy/phy.h>
 #include <linux/platform_data/spi-omap2-mcspi.h>
 
 #include <asm/mach-types.h>
@@ -420,6 +421,7 @@ static void __init omap_ldp_init(void)
 	omap_serial_init();
 	omap_sdrc_init(NULL, NULL);
 	usb_bind_phy("musb-hdrc.0.auto", 0, "twl4030_usb");
+	phy_bind("musb-hdrc.0.auto", 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);
arch/arm/mach-omap2/board-omap3beagle.c +2 -0
index c3558f9..5dc0f81 100644
@@ -33,6 +33,7 @@
 #include <linux/mtd/nand.h>
 #include <linux/mmc/host.h>
 #include <linux/usb/phy.h>
+#include <linux/phy/phy.h>
 
 #include <linux/regulator/machine.h>
 #include <linux/i2c/twl.h>
@@ -542,6 +543,7 @@ static void __init omap3_beagle_init(void)
 				  mt46h32m32lf6_sdrc_params);
 
 	usb_bind_phy("musb-hdrc.0.auto", 0, "twl4030_usb");
+	phy_bind("musb-hdrc.0.auto", 0, "twl4030_usb");
 	usb_musb_init(NULL);
 	usbhs_init(&usbhs_bdata);
 	board_nand_init(omap3beagle_nand_partitions,
arch/arm/mach-omap2/board-omap3evm.c +2 -0
index 48789e0..47e68cd 100644
@@ -42,6 +42,7 @@
 #include <linux/mmc/host.h>
 #include <linux/export.h>
 #include <linux/usb/phy.h>
+#include <linux/phy/phy.h>
 
 #include <asm/mach-types.h>
 #include <asm/mach/arch.h>
@@ -736,6 +737,7 @@ static void __init omap3_evm_init(void)
 		usbhs_bdata.reset_gpio_port[1] = 135;
 	}
 	usb_bind_phy("musb-hdrc.0.auto", 0, "twl4030_usb");
+	phy_bind("musb-hdrc.0.auto", 0, "twl4030_usb");
 	usb_musb_init(&musb_board_data);
 	usbhs_init(&usbhs_bdata);
 	board_nand_init(omap3evm_nand_partitions,
arch/arm/mach-omap2/board-omap3logic.c +2 -0
index bab51e6..2c35ae2 100644
@@ -30,6 +30,7 @@
 #include <linux/i2c/twl.h>
 #include <linux/mmc/host.h>
 #include <linux/usb/phy.h>
+#include <linux/phy/phy.h>
 
 #include <asm/mach-types.h>
 #include <asm/mach/arch.h>
@@ -217,6 +218,7 @@ static void __init omap3logic_init(void)
 	board_smsc911x_init();
 
 	usb_bind_phy("musb-hdrc.0.auto", 0, "twl4030_usb");
+	phy_bind("musb-hdrc.0.auto", 0, "twl4030_usb");
 	usb_musb_init(NULL);
 
 	/* Ensure SDRC pins are mux'd for self-refresh */
arch/arm/mach-omap2/board-omap3pandora.c +2 -0
index 2bba362..07cede4 100644
@@ -36,6 +36,7 @@
 #include <linux/mmc/card.h>
 #include <linux/regulator/fixed.h>
 #include <linux/usb/phy.h>
+#include <linux/phy/phy.h>
 #include <linux/platform_data/spi-omap2-mcspi.h>
 
 #include <asm/mach-types.h>
@@ -603,6 +604,7 @@ static void __init omap3pandora_init(void)
 	omap_ads7846_init(1, OMAP3_PANDORA_TS_GPIO, 0, NULL);
 	usbhs_init(&usbhs_bdata);
 	usb_bind_phy("musb-hdrc.0.auto", 0, "twl4030_usb");
+	phy_bind("musb-hdrc.0.auto", 0, "twl4030_usb");
 	usb_musb_init(NULL);
 	gpmc_nand_init(&pandora_nand_data, NULL);
 
arch/arm/mach-omap2/board-omap3stalker.c +2 -0
index 95c10b3..bf2575b 100644
@@ -34,6 +34,7 @@
 #include <linux/smsc911x.h>
 #include <linux/i2c/at24.h>
 #include <linux/usb/phy.h>
+#include <linux/phy/phy.h>
 
 #include <asm/mach-types.h>
 #include <asm/mach/arch.h>
@@ -406,6 +407,7 @@ static void __init omap3_stalker_init(void)
 	omap_serial_init();
 	omap_sdrc_init(mt46h32m32lf6_sdrc_params, NULL);
 	usb_bind_phy("musb-hdrc.0.auto", 0, "twl4030_usb");
+	phy_bind("musb-hdrc.0.auto", 0, "twl4030_usb");
 	usb_musb_init(NULL);
 	usbhs_init(&usbhs_bdata);
 	omap_ads7846_init(1, OMAP3_STALKER_TS_GPIO, 310, NULL);
arch/arm/mach-omap2/board-omap3touchbook.c +2 -0
index bcd44fb..2665d47 100644
@@ -29,6 +29,7 @@
 #include <linux/mtd/nand.h>
 #include <linux/mmc/host.h>
 #include <linux/usb/phy.h>
+#include <linux/phy/phy.h>
 
 #include <linux/platform_data/spi-omap2-mcspi.h>
 #include <linux/spi/spi.h>
@@ -367,6 +368,7 @@ static void __init omap3_touchbook_init(void)
 	/* Touchscreen and accelerometer */
 	omap_ads7846_init(4, OMAP3_TS_GPIO, 310, &ads7846_pdata);
 	usb_bind_phy("musb-hdrc.0.auto", 0, "twl4030_usb");
+	phy_bind("musb-hdrc.0.auto", 0, "twl4030_usb");
 	usb_musb_init(NULL);
 	usbhs_init(&usbhs_bdata);
 	board_nand_init(omap3touchbook_nand_partitions,
arch/arm/mach-omap2/board-omap4panda.c +2 -0
index b02c2f0..d977c11 100644
@@ -31,6 +31,7 @@
 #include <linux/ti_wilink_st.h>
 #include <linux/usb/musb.h>
 #include <linux/usb/phy.h>
+#include <linux/phy/phy.h>
 #include <linux/wl12xx.h>
 #include <linux/irqchip/arm-gic.h>
 #include <linux/platform_data/omap-abe-twl6040.h>
@@ -449,6 +450,7 @@ static void __init omap4_panda_init(void)
 	omap4_twl6030_hsmmc_init(mmc);
 	omap4_ehci_init();
 	usb_bind_phy("musb-hdrc.0.auto", 0, "omap-usb2.1.auto");
+	phy_bind("musb-hdrc.0.auto", 0, "omap-usb2.1.auto");
 	usb_musb_init(&musb_board_data);
 	omap4_panda_display_init();
 }
arch/arm/mach-omap2/board-overo.c +2 -0
index 86bab51..f75cb33 100644
@@ -37,6 +37,7 @@
 #include <linux/mtd/partitions.h>
 #include <linux/mmc/host.h>
 #include <linux/usb/phy.h>
+#include <linux/phy/phy.h>
 
 #include <linux/platform_data/mtd-nand-omap2.h>
 #include <linux/platform_data/spi-omap2-mcspi.h>
@@ -501,6 +502,7 @@ static void __init overo_init(void)
 	board_nand_init(overo_nand_partitions,
 			ARRAY_SIZE(overo_nand_partitions), NAND_CS, 0, NULL);
 	usb_bind_phy("musb-hdrc.0.auto", 0, "twl4030_usb");
+	phy_bind("musb-hdrc.0.auto", 0, "twl4030_usb");
 	usb_musb_init(NULL);
 	usbhs_init(&usbhs_bdata);
 	overo_spi_init();
arch/arm/mach-omap2/board-rm680.c +2 -0
index 345e8c4..2895fe8 100644
@@ -19,6 +19,7 @@
 #include <linux/regulator/consumer.h>
 #include <linux/platform_data/mtd-onenand-omap2.h>
 #include <linux/usb/phy.h>
+#include <linux/phy/phy.h>
 
 #include <asm/mach/arch.h>
 #include <asm/mach-types.h>
@@ -136,6 +137,7 @@ static void __init rm680_init(void)
 	omap_sdrc_init(sdrc_params, sdrc_params);
 
 	usb_bind_phy("musb-hdrc.0.auto", 0, "twl4030_usb");
+	phy_bind("musb-hdrc.0.auto", 0, "twl4030_usb");
 	usb_musb_init(NULL);
 	rm680_peripherals_init();
 }
arch/arm/mach-omap2/board-rx51.c +2 -0
index d2ea68e..508f8d9 100644
@@ -18,6 +18,7 @@
 #include <linux/gpio.h>
 #include <linux/leds.h>
 #include <linux/usb/phy.h>
+#include <linux/phy/phy.h>
 #include <linux/usb/musb.h>
 #include <linux/platform_data/spi-omap2-mcspi.h>
 
@@ -100,6 +101,7 @@ static void __init rx51_init(void)
 	omap_sdrc_init(sdrc_params, sdrc_params);
 
 	usb_bind_phy("musb-hdrc.0.auto", 0, "twl4030_usb");
+	phy_bind("musb-hdrc.0.auto", 0, "twl4030_usb");
 	usb_musb_init(&musb_board_data);
 	rx51_peripherals_init();
 
arch/arm/mach-omap2/board-zoom-peripherals.c +2 -0
index cdc0c10..b58d7cd 100644
@@ -22,6 +22,7 @@
 #include <linux/platform_data/gpio-omap.h>
 #include <linux/platform_data/omap-twl4030.h>
 #include <linux/usb/phy.h>
+#include <linux/phy/phy.h>
 
 #include <asm/mach-types.h>
 #include <asm/mach/arch.h>
@@ -303,6 +304,7 @@ void __init zoom_peripherals_init(void)
 	omap_i2c_init();
 	platform_device_register(&omap_vwlan_device);
 	usb_bind_phy("musb-hdrc.0.auto", 0, "twl4030_usb");
+	phy_bind("musb-hdrc.0.auto", 0, "twl4030_usb");
 	usb_musb_init(NULL);
 	enable_board_wakeup_source();
 	omap_serial_init();
Signature · 1 line
1.7.10.4
maintainer
#13 lore raw

Re: [PATCH v3 4/6] ARM: OMAP: USB: Add phy binding information

Quoted 14 lines · Kishon Vijay Abraham I
arch/arm/mach-omap2/board-2430sdp.c +1 -0
@@ -265,6 +266,7 @@ static void __init omap_2430sdp_init(void)
 
 	omap_mux_init_signal("usb0hs_stp", OMAP_PULL_ENA | OMAP_PULL_UP);
 	usb_bind_phy("musb-hdrc.0.auto", 0, "twl4030_usb");
+	phy_bind("musb-hdrc.0.auto", 0, "twl4030_usb");
 	usb_musb_init(NULL);
 
 	board_smc91x_init();

arch/arm/mach-omap2/board-3430sdp.c static void __init omap_3430sdp_init(void) · line 608

Quoted 7 lines
arch/arm/mach-omap2/board-3430sdp.c +1 -0
@@ -601,6 +602,7 @@ static void __init omap_3430sdp_init(void)
 	omap_serial_init();
 	omap_sdrc_init(hyb18m512160af6_sdrc_params, NULL);
 	usb_bind_phy("musb-hdrc.0.auto", 0, "twl4030_usb");
+	phy_bind("musb-hdrc.0.auto", 0, "twl4030_usb");
 	usb_musb_init(NULL);
 	board_smc91x_init();
 	board_flash_init(sdp_flash_partitions, chip_sel_3430, 0);

Can't you call phy_bind() from usb_musb_init() with the default values automatically when usb_musb_init() is passed NULL?

That way you don't have to patch every board-*.c file with the same lines, and don't need to include <linux/phy/phy.h> in each board-*.c file.

Quoted 11 lines
arch/arm/mach-omap2/board-4430sdp.c +1 -0
@@ -32,6 +32,7 @@
 #include <linux/platform_data/omap4-keypad.h>
 #include <linux/usb/musb.h>
 #include <linux/usb/phy.h>
+#include <linux/phy/phy.h>
 
 #include <asm/mach-types.h>
 #include <asm/mach/arch.h>

arch/arm/mach-omap2/board-4430sdp.c static void __init omap_4430sdp_init(void) · line 732

Quoted 7 lines
arch/arm/mach-omap2/board-4430sdp.c +1 -0
@@ -725,6 +726,7 @@ static void __init omap_4430sdp_init(void)
 	omap4_twl6030_hsmmc_init(mmc);
 
 	usb_bind_phy("musb-hdrc.0.auto", 0, "omap-usb2.1.auto");
+	phy_bind("musb-hdrc.0.auto", 0, "omap-usb2.1.auto");
 	usb_musb_init(&musb_board_data);
 
 	status = omap_ethernet_init();

Here usb_musb_init() gets called with musb_board_data, so keeping the phy_bind() in the board-4430sdp.c can then override the default in usb_musb_init().

Regards,

Tony

author
#14 lore raw

Re: [PATCH v3 4/6] ARM: OMAP: USB: Add phy binding information

Hi,

Quoted 47 lines · Tony Lindgren
Quoted 14 lines · Kishon Vijay Abraham I
arch/arm/mach-omap2/board-2430sdp.c +1 -0
@@ -265,6 +266,7 @@ static void __init omap_2430sdp_init(void)
 
  	omap_mux_init_signal("usb0hs_stp", OMAP_PULL_ENA | OMAP_PULL_UP);
  	usb_bind_phy("musb-hdrc.0.auto", 0, "twl4030_usb");
+	phy_bind("musb-hdrc.0.auto", 0, "twl4030_usb");
  	usb_musb_init(NULL);
 
  	board_smc91x_init();

arch/arm/mach-omap2/board-3430sdp.c static void __init omap_3430sdp_init(void) · line 608

Quoted 7 lines
arch/arm/mach-omap2/board-3430sdp.c +1 -0
@@ -601,6 +602,7 @@ static void __init omap_3430sdp_init(void)
  	omap_serial_init();
  	omap_sdrc_init(hyb18m512160af6_sdrc_params, NULL);
  	usb_bind_phy("musb-hdrc.0.auto", 0, "twl4030_usb");
+	phy_bind("musb-hdrc.0.auto", 0, "twl4030_usb");
  	usb_musb_init(NULL);
  	board_smc91x_init();
  	board_flash_init(sdp_flash_partitions, chip_sel_3430, 0);

Can't you call phy_bind() from usb_musb_init() with the default values automatically when usb_musb_init() is passed NULL?

That way you don't have to patch every board-*.c file with the same lines, and don't need to include <linux/phy/phy.h> in each board-*.c file.

Quoted 17 lines
arch/arm/mach-omap2/board-4430sdp.c +2 -0
@@ -32,6 +32,7 @@
  #include <linux/platform_data/omap4-keypad.h>
  #include <linux/usb/musb.h>
  #include <linux/usb/phy.h>
+#include <linux/phy/phy.h>
 
  #include <asm/mach-types.h>
  #include <asm/mach/arch.h>
@@ -725,6 +726,7 @@ static void __init omap_4430sdp_init(void)
  	omap4_twl6030_hsmmc_init(mmc);
 
  	usb_bind_phy("musb-hdrc.0.auto", 0, "omap-usb2.1.auto");
+	phy_bind("musb-hdrc.0.auto", 0, "omap-usb2.1.auto");
  	usb_musb_init(&musb_board_data);
 
Quoted 5 lines

arch/arm/mach-omap2/board-4430sdp.c static void __init omap_4430sdp_init(void) · line 732

Quoted 1 line
arch/arm/mach-omap2/board-4430sdp.c +0 -0
  	status = omap_ethernet_init();

Here usb_musb_init() gets called with musb_board_data, so keeping the phy_bind() in the board-4430sdp.c can then override the default in usb_musb_init().

Currently phy_bind has a limitation to do that. Will change phy_bind() and have your comment incorporated.

Thanks
Kishon

#15 lore raw

PATCH v3 5/6 ARM: dts: omap: update usb_otg_hs data

In reply to 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.

---
 Documentation/devicetree/bindings/usb/omap-usb.txt |    5 +++++
 arch/arm/boot/dts/omap3.dtsi                       |    2 ++
 arch/arm/boot/dts/omap4.dtsi                       |    2 ++
 3 files changed, 9 insertions(+)
Documentation/devicetree/bindings/usb/omap-usb.txt +5 -0
index abce256..3d6f9f6 100644
@@ -19,6 +19,9 @@ OMAP MUSB GLUE
  - power : Should be "50". This signifies the controller can supply upto
    100mA when operating in host mode.
  - usb-phy : the phandle for the PHY device
+ - phy : 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 at 4a0ab000 {
 	num_eps = <16>;
 	ram_bits = <12>;
 	ctrl-module = <&omap_control_usb>;
+	phy = <&usb2_phy>;
+	phy-names = "usb2-phy";
 };
 
 Board specific device node entry
arch/arm/boot/dts/omap3.dtsi +2 -0
index 1e21565..cf50c18 100644
@@ -405,6 +405,8 @@
 			interrupt-names = "mc", "dma";
 			ti,hwmods = "usb_otg_hs";
 			usb-phy = <&usb2_phy>;
+			phy = <&usb2_phy>;
+			phy-names = "usb2-phy";
 			multipoint = <1>;
 			num-eps = <16>;
 			ram-bits = <12>;
arch/arm/boot/dts/omap4.dtsi +2 -0
index 06d044e..188d5b8 100644
@@ -550,6 +550,8 @@
 			interrupt-names = "mc", "dma";
 			ti,hwmods = "usb_otg_hs";
 			usb-phy = <&usb2_phy>;
+			phy = <&usb2_phy>;
+			phy-names = "usb2-phy";
 			multipoint = <1>;
 			num-eps = <16>;
 			ram-bits = <12>;
Signature · 1 line
1.7.10.4
#16 lore raw

Re: [PATCH v3 5/6] ARM: dts: omap: update usb_otg_hs data

Quoted 9 lines · 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.

Documentation/devicetree/bindings/usb/omap-usb.txt +0 -0
index abce256..3d6f9f6 100644

Documentation/devicetree/bindings/usb/omap-usb.txt OMAP MUSB GLUE · line 24

Quoted 6 lines
Documentation/devicetree/bindings/usb/omap-usb.txt +3 -0
@@ -19,6 +19,9 @@ OMAP MUSB GLUE
  - power : Should be "50". This signifies the controller can supply upto
    100mA when operating in host mode.
  - usb-phy : the phandle for the PHY device
+ - phy : 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.

If the intent is for those properties to be generic and used by any DT binding that refers to a PHY node, I think you'd want to define those properties in e.g. Documentation/devicetree/bindings/phy/phy.txt, just like common clock/GPIO/... properties are defined in standalone common files.

I think you want to require that DT nodes that represent PHYs have a #phy-cells property, and that the format of the phy property be <&phy_phandle phy_specifier*>, where #phy-cells in the referenced node defines how many cells are part of phy_specifier*, just like (almost) any other DT property that references another node by phandle. That way, if a single DT node represents a HW block that implements e.g. 3 PHYs, it can use #phy-cells = <1>, and the referencing phy property can include a cell that indicates which of those 3 PHYs is being referenced.

author
#17 lore raw

Re: [PATCH v3 5/6] ARM: dts: omap: update usb_otg_hs data

Hi,

Quoted 14 lines · Stephen Warren
Quoted 13 lines · 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.

Documentation/devicetree/bindings/usb/omap-usb.txt +1 -0
index abce256..3d6f9f6 100644
@@ -19,6 +19,9 @@ OMAP MUSB GLUE
   - power : Should be "50". This signifies the controller can supply upto
     100mA when operating in host mode.
   - usb-phy : the phandle for the PHY device
+ - phy : the phandle for the PHY device (used by generic PHY framework)
Quoted 8 lines

Documentation/devicetree/bindings/usb/omap-usb.txt OMAP MUSB GLUE · line 24

Quoted 2 lines
Documentation/devicetree/bindings/usb/omap-usb.txt +2 -0
+ - phy-names : the names of the PHY corresponding to the PHYs present in the
+   *phy* phandle.

If the intent is for those properties to be generic and used by any DT binding that refers to a PHY node, I think you'd want to define those properties in e.g. Documentation/devicetree/bindings/phy/phy.txt, just like common clock/GPIO/... properties are defined in standalone common files.

Ok. Will add it.

Quoted 9 lines

I think you want to require that DT nodes that represent PHYs have a #phy-cells property, and that the format of the phy property be <&phy_phandle phy_specifier*>, where #phy-cells in the referenced node defines how many cells are part of phy_specifier*, just like (almost) any other DT property that references another node by phandle. That way, if a single DT node represents a HW block that implements e.g. 3 PHYs, it can use #phy-cells = <1>, and the referencing phy property can include a cell that indicates which of those 3 PHYs is being referenced.

Currently, if a single phandle have reference to multiple PHYs, we can get PHY by passing index or by name as give in phy-names. I'm not sure if we have <&phy_phandle phy_specifier*>, what could that phy_specifier be? Maybe phy_type?

Thanks
Kishon

#18 lore raw

Re: [PATCH v3 5/6] ARM: dts: omap: update usb_otg_hs data

Quoted 40 lines · kishon

Hi,

Quoted 17 lines · Stephen Warren
Quoted 16 lines · 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.

Documentation/devicetree/bindings/usb/omap-usb.txt +0 -0
index abce256..3d6f9f6 100644
@@ -19,6 +19,9 @@ OMAP MUSB GLUE
   - power : Should be "50". This signifies the controller can supply

upto
100mA when operating in host mode.
- usb-phy : the phandle for the PHY device
+ - phy : the phandle for the PHY device (used by generic PHY framework)
+ - phy-names : the names of the PHY corresponding to the PHYs

Quoted 8 lines
Quoted 2 lines

present in the
+ *phy* phandle.

If the intent is for those properties to be generic and used by any DT binding that refers to a PHY node, I think you'd want to define those properties in e.g. Documentation/devicetree/bindings/phy/phy.txt, just like common clock/GPIO/... properties are defined in standalone common files.

Ok. Will add it.

Quoted 9 lines

I think you want to require that DT nodes that represent PHYs have a #phy-cells property, and that the format of the phy property be <&phy_phandle phy_specifier*>, where #phy-cells in the referenced node defines how many cells are part of phy_specifier*, just like (almost) any other DT property that references another node by phandle. That way, if a single DT node represents a HW block that implements e.g. 3 PHYs, it can use #phy-cells = <1>, and the referencing phy property can include a cell that indicates which of those 3 PHYs is being referenced.

Quoted 4 lines

Currently, if a single phandle have reference to multiple PHYs, we can get PHY by passing index or by name as give in phy-names. I'm not sure if we have <&phy_phandle phy_specifier*>, what could that phy_specifier be? Maybe phy_type?

I'm not talking about the case where a consumer node references multiple PHYs. As you say, that is indeed handled by the driver looking at a particular index in the phys property, or using phy-names.

I'm talking about the case where a single provider provides multiple PHYs. For example, consider:

phys: phy {
    compatible = "xxx";
    reg = <...>;
    #phy-cells = <1>;
};

That node describes an IP block that implements 3 different PHYs. The registers are inter-mixed in such a way that you can't split it into 3 separate nodes each with a separate device instance. If the consumers simply say:

phys = <&phys>;

then which of the 3 PHYs are you referring to?

Instead, the consumer needs to say one of:

phys = <&phys 0>;
phys = <&phys 1>;
phys = <&phys 2>;

in order to specify which of the PHYs it refers to.

The number of cells in the phy property after the phandle is specified by the #phy-cells property in the node referred to by the phandle. The meaning of all those cells is defined by the binding for the phy node. This could include both the PHY ID (as in my example here), or whatever configuration information or flags the provider needs. For example, both GPIOs and interrupts have specifiers than describe both of these things.

For more background, take a look at almost any other binding that uses phandles.

By the way, the property in the consumer should probably be "phys" not "phy" to be consistent with other similar properties (e.g. gpios, interrupts, ... which are all plural).

#19 lore raw

Re: [PATCH v3 5/6] ARM: dts: omap: update usb_otg_hs data

Hi,

Quoted 74 lines · Stephen Warren
Quoted 40 lines · kishon

Hi,

Quoted 17 lines · Stephen Warren
Quoted 16 lines · 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.

Documentation/devicetree/bindings/usb/omap-usb.txt +0 -0
index abce256..3d6f9f6 100644
@@ -19,6 +19,9 @@ OMAP MUSB GLUE
    - power : Should be "50". This signifies the controller can supply

upto
100mA when operating in host mode.
- usb-phy : the phandle for the PHY device
+ - phy : the phandle for the PHY device (used by generic PHY framework)
+ - phy-names : the names of the PHY corresponding to the PHYs

Quoted 8 lines
Quoted 2 lines

present in the
+ *phy* phandle.

If the intent is for those properties to be generic and used by any DT binding that refers to a PHY node, I think you'd want to define those properties in e.g. Documentation/devicetree/bindings/phy/phy.txt, just like common clock/GPIO/... properties are defined in standalone common files.

Ok. Will add it.

Quoted 9 lines

I think you want to require that DT nodes that represent PHYs have a #phy-cells property, and that the format of the phy property be <&phy_phandle phy_specifier*>, where #phy-cells in the referenced node defines how many cells are part of phy_specifier*, just like (almost) any other DT property that references another node by phandle. That way, if a single DT node represents a HW block that implements e.g. 3 PHYs, it can use #phy-cells = <1>, and the referencing phy property can include a cell that indicates which of those 3 PHYs is being referenced.

Quoted 4 lines

Currently, if a single phandle have reference to multiple PHYs, we can get PHY by passing index or by name as give in phy-names. I'm not sure if we have <&phy_phandle phy_specifier*>, what could that phy_specifier be? Maybe phy_type?

I'm not talking about the case where a consumer node references multiple PHYs. As you say, that is indeed handled by the driver looking at a particular index in the phys property, or using phy-names.

I'm talking about the case where a single provider provides multiple PHYs. For example, consider:

phys: phy {
     compatible = "xxx";
     reg = <...>;
     #phy-cells = <1>;
};

That node describes an IP block that implements 3 different PHYs. The registers are inter-mixed in such a way that you can't split it into 3 separate nodes each with a separate device instance. If the consumers simply say:

phys = <&phys>;

then which of the 3 PHYs are you referring to?

Instead, the consumer needs to say one of:

phys = <&phys 0>;
phys = <&phys 1>;
phys = <&phys 2>;

Quoted 8 lines

in order to specify which of the PHYs it refers to.

The number of cells in the phy property after the phandle is specified by the #phy-cells property in the node referred to by the phandle. The meaning of all those cells is defined by the binding for the phy node. This could include both the PHY ID (as in my example here), or whatever configuration information or flags the provider needs. For example, both GPIOs and interrupts have specifiers than describe both of these things.

Thanks for the explanation. I'll add it in my next version.

Quoted 8 lines

For more background, take a look at almost any other binding that uses phandles.

By the way, the property in the consumer should probably be "phys" not "phy" to be consistent with other similar properties (e.g. gpios, interrupts, ... which are all plural).

Ok.

Thanks
Kishon

#20 lore raw

PATCH v3 6/6 usb: musb: omap2430: use the new generic PHY framework

In reply to Kishon Vijay Abraham I

Use the generic PHY framework API to get the PHY. The usb_phy_set_suspend and usb_phy_set_resume is replaced with phy_suspend and phy_resume 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.

---
 drivers/usb/musb/musb_core.h |    2 ++
 drivers/usb/musb/omap2430.c  |   22 ++++++++++++++++------
 2 files changed, 18 insertions(+), 6 deletions(-)
drivers/usb/musb/musb_core.h +2 -0
index 7fb4819..78251fd 100644
@@ -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;
@@ -357,6 +358,7 @@ struct musb {
 	u16			int_tx;
 
 	struct usb_phy		*xceiv;
+	struct phy		*phy;
 
 	int nIrq;
 	unsigned		irq_wake:1;
drivers/usb/musb/omap2430.c +16 -6
index 1a42a45..55f071d 100644
@@ -349,14 +349,24 @@ 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_of_phy_get_byname(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, 0);
+	}
 
-	if (IS_ERR_OR_NULL(musb->xceiv)) {
-		pr_err("HS USB OTG: no transceiver configured\n");
+	if (IS_ERR_OR_NULL(musb->xceiv) || IS_ERR_OR_NULL(musb->phy)) {
+		dev_err(dev, "no transceiver configured\n");
 		return -EPROBE_DEFER;
 	}
 
@@ -612,7 +622,7 @@ static int omap2430_runtime_suspend(struct device *dev)
 				OTG_INTERFSEL);
 
 		omap2430_low_level_exit(musb);
-		usb_phy_set_suspend(musb->xceiv, 1);
+		phy_suspend(musb->phy);
 	}
 
 	return 0;
@@ -628,7 +638,7 @@ static int omap2430_runtime_resume(struct device *dev)
 		musb_writel(musb->mregs, OTG_INTERFSEL,
 				musb->context.otg_interfsel);
 
-		usb_phy_set_suspend(musb->xceiv, 0);
+		phy_resume(musb->phy);
 	}
 
 	return 0;
Signature · 1 line
1.7.10.4
#21 lore raw
In reply to Kishon Vijay Abraham I
Quoted 24 lines · 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. To obtain a reference to the PHY without using phandle, the platform specfic intialization code (say from board file) should have already called phy_bind with the binding information. The binding information consists of phy's device name, phy user device name and an index. The index is used when the same phy user binds to mulitple phys.

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.

Making omap-usb2 and twl4030 to use this framework is provided as a sample.

This patch series is developed on 3.9-rc3. Once the patch series gets finalised I'll resend omap-usb2 and twl4030 part based on Felipe's tree.

[...]

Quoted 5 lines
 drivers/Kconfig                                    |    2 +
 drivers/Makefile                                   |    2 +
 drivers/phy/Kconfig                                |   13 +
 drivers/phy/Makefile                               |    5 +
 drivers/phy/phy-core.c                             |  574 ++++++++++++++++++++

This looks to be very specific for USB PHYs. Are you intending it to be used for other types of PHYs, like Ethernet PHYs? If not, then this infrastruction should be named something like usb-phy so that it isn't confused with other layers, and it really should live under drivers/usb.

g.

#22 lore raw

Hi,

Quoted 28 lines · Grant Likely
Quoted 24 lines · 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. To obtain a reference to the PHY without using phandle, the platform specfic intialization code (say from board file) should have already called phy_bind with the binding information. The binding information consists of phy's device name, phy user device name and an index. The index is used when the same phy user binds to mulitple phys.

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.

Making omap-usb2 and twl4030 to use this framework is provided as a sample.

This patch series is developed on 3.9-rc3. Once the patch series gets finalised I'll resend omap-usb2 and twl4030 part based on Felipe's tree.

[...]

Quoted 8 lines
Quoted 5 lines
  drivers/Kconfig                                    |    2 +
  drivers/Makefile                                   |    2 +
  drivers/phy/Kconfig                                |   13 +
  drivers/phy/Makefile                               |    5 +
  drivers/phy/phy-core.c                             |  574 ++++++++++++++++++++

This looks to be very specific for USB PHYs. Are you intending it to be used for other types of PHYs, like Ethernet PHYs? If not, then this

Not really. This can be used by USB, SATA and Sylwester was planning to use it for video PHY's.

Thanks
Kishon

#23 lore raw
Quoted 37 lines · Kishon Vijay Abraham I
Quoted 36 lines · Grant Likely
Quoted 24 lines · 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. To obtain a reference to the PHY without using phandle, the platform specfic intialization code (say from board file) should have already called phy_bind with the binding information. The binding information consists of phy's device name, phy user device name and an index. The index is used when the same phy user binds to mulitple phys.

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.

Making omap-usb2 and twl4030 to use this framework is provided as a sample.

This patch series is developed on 3.9-rc3. Once the patch series gets finalised I'll resend omap-usb2 and twl4030 part based on Felipe's tree.

[...]

Quoted 6 lines
  drivers/Kconfig                                    |    2 +
  drivers/Makefile                                   |    2 +
  drivers/phy/Kconfig                                |   13 +
  drivers/phy/Makefile                               |    5 +
  drivers/phy/phy-core.c                             |  574

++++++++++++++++++++

Quoted 5 lines
Quoted 2 lines

This looks to be very specific for USB PHYs. Are you intending it to be used for other types of PHYs, like Ethernet PHYs? If not, then this

Not really. This can be used by USB, SATA and Sylwester was planning to use it for video PHY's.

Yes, I have already some RFC patches to handle the display and the camera interface DPHYs (MIPI DSI, MIPI CSI-2) with this API. I didn't post it, since this framework is not settled yet. Those DPHYs need very few operations, like disable/enable only and there was really not suitable API in the kernel until now to handle them. We had plans in the past to write something like this generic PHY framework for the Samsung SoCs.

Some SoCs have plenty different PHYs: USB, SATA, MIPI CSI-2, MIPI DSI, HDMI... And some of them are simple enough to be covered by this generic PHY API.

Thanks,
Sylwester

#24 lore raw
In reply to Kishon Vijay Abraham I
Quoted 37 lines · Kishon Vijay Abraham I

Hi,

Quoted 34 lines · Grant Likely
Quoted 24 lines · 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. To obtain a reference to the PHY without using phandle, the platform specfic intialization code (say from board file) should have already called phy_bind with the binding information. The binding information consists of phy's device name, phy user device name and an index. The index is used when the same phy user binds to mulitple phys.

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.

Making omap-usb2 and twl4030 to use this framework is provided as a sample.

This patch series is developed on 3.9-rc3. Once the patch series gets finalised I'll resend omap-usb2 and twl4030 part based on Felipe's tree.

[...]

Quoted 5 lines
  drivers/Kconfig                                    |    2 +
  drivers/Makefile                                   |    2 +
  drivers/phy/Kconfig                                |   13 +
  drivers/phy/Makefile                               |    5 +
  drivers/phy/phy-core.c                             |  574 ++++++++++++++++++++
Quoted 5 lines
Quoted 2 lines

This looks to be very specific for USB PHYs. Are you intending it to be used for other types of PHYs, like Ethernet PHYs? If not, then this

Not really. This can be used by USB, SATA and Sylwester was planning to use it for video PHY's.

So what are the common bits that are shared between those phys? Merely matching phys to controllers? Besides that, each of those devices have very different behaviour. You wouldn't be able to attach any interface logic to the generic struct phy. I don't think it makes a whole lot of sense to lump them all into the same type of registration.

g.

#25 lore raw

Hi,

Quoted 38 lines · Grant Likely
Quoted 37 lines · Kishon Vijay Abraham I

Hi,

Quoted 34 lines · Grant Likely
Quoted 24 lines · 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. To obtain a reference to the PHY without using phandle, the platform specfic intialization code (say from board file) should have already called phy_bind with the binding information. The binding information consists of phy's device name, phy user device name and an index. The index is used when the same phy user binds to mulitple phys.

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.

Making omap-usb2 and twl4030 to use this framework is provided as a sample.

This patch series is developed on 3.9-rc3. Once the patch series gets finalised I'll resend omap-usb2 and twl4030 part based on Felipe's tree.

[...]

Quoted 5 lines
   drivers/Kconfig                                    |    2 +
   drivers/Makefile                                   |    2 +
   drivers/phy/Kconfig                                |   13 +
   drivers/phy/Makefile                               |    5 +
   drivers/phy/phy-core.c                             |  574 ++++++++++++++++++++
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

This looks to be very specific for USB PHYs. Are you intending it to be used for other types of PHYs, like Ethernet PHYs? If not, then this

Not really. This can be used by USB, SATA and Sylwester was planning to use it for video PHY's.

So what are the common bits that are shared between those phys? Merely matching phys to controllers? Besides that, each of those devices have

The same PIPE3 PHY IP is used for USB (usb3) and SATA in OMAP5. Even for just matching PHYs to controllers you need a simple framework (like this) or else we'll end up in creating such frameworks for lot of these subsystems.

Thanks
Kishon

#26 lore raw
In reply to Kishon Vijay Abraham I

Hi Kishon,

Quoted 8 lines · 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. To obtain a reference to the PHY without using phandle, the platform specfic intialization code (say from board file) should have already called phy_bind with the binding information. The binding information consists of phy's device name, phy user device name and an index. The index is used when the same phy user binds to mulitple phys.

Quoted 4 lines

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

From a top level what you are doing looks closely related to External

connector (extcon).

I understand a connector is not the same as a phy, but it will still be useful to know why extcon framework (or some extension of it) will not suffice your needs.

You can probably note it in the cover-letter so folks like me get their answer.

Thanks,
Sekhar