aboutsummaryrefslogtreecommitdiffstats
path: root/Documentation/phy.txt
diff options
context:
space:
mode:
authorHeikki Krogerus <heikki.krogerus@linux.intel.com>2014-11-19 10:28:18 -0500
committerKishon Vijay Abraham I <kishon@ti.com>2014-11-21 09:18:50 -0500
commitb7bc15b98e843926d01eb03b9c0e196d8ddbadeb (patch)
tree1ad10eb0f6e27ec06b17bbeed233b31d4cde66d3 /Documentation/phy.txt
parentd451057464a7ea2fe400e56c8a7e004c875f2a84 (diff)
phy: improved lookup method
Separates registration of the phy and the lookup. The method is copied from clkdev.c, Signed-off-by: Heikki Krogerus <heikki.krogerus@linux.intel.com> Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
Diffstat (limited to 'Documentation/phy.txt')
-rw-r--r--Documentation/phy.txt60
1 files changed, 16 insertions, 44 deletions
diff --git a/Documentation/phy.txt b/Documentation/phy.txt
index c6594af94d25..371361c69a4b 100644
--- a/Documentation/phy.txt
+++ b/Documentation/phy.txt
@@ -54,18 +54,14 @@ The PHY driver should create the PHY in order for other peripheral controllers
54to make use of it. The PHY framework provides 2 APIs to create the PHY. 54to make use of it. The PHY framework provides 2 APIs to create the PHY.
55 55
56struct phy *phy_create(struct device *dev, struct device_node *node, 56struct phy *phy_create(struct device *dev, struct device_node *node,
57 const struct phy_ops *ops, 57 const struct phy_ops *ops);
58 struct phy_init_data *init_data);
59struct phy *devm_phy_create(struct device *dev, struct device_node *node, 58struct phy *devm_phy_create(struct device *dev, struct device_node *node,
60 const struct phy_ops *ops, 59 const struct phy_ops *ops);
61 struct phy_init_data *init_data);
62 60
63The PHY drivers can use one of the above 2 APIs to create the PHY by passing 61The PHY drivers can use one of the above 2 APIs to create the PHY by passing
64the device pointer, phy ops and init_data. 62the device pointer and phy ops.
65phy_ops is a set of function pointers for performing PHY operations such as 63phy_ops is a set of function pointers for performing PHY operations such as
66init, exit, power_on and power_off. *init_data* is mandatory to get a reference 64init, exit, power_on and power_off.
67to the PHY in the case of non-dt boot. See section *Board File Initialization*
68on how init_data should be used.
69 65
70Inorder to dereference the private data (in phy_ops), the phy provider driver 66Inorder to dereference the private data (in phy_ops), the phy provider driver
71can use phy_set_drvdata() after creating the PHY and use phy_get_drvdata() in 67can use phy_set_drvdata() after creating the PHY and use phy_get_drvdata() in
@@ -137,42 +133,18 @@ There are exported APIs like phy_pm_runtime_get, phy_pm_runtime_get_sync,
137phy_pm_runtime_put, phy_pm_runtime_put_sync, phy_pm_runtime_allow and 133phy_pm_runtime_put, phy_pm_runtime_put_sync, phy_pm_runtime_allow and
138phy_pm_runtime_forbid for performing PM operations. 134phy_pm_runtime_forbid for performing PM operations.
139 135
1408. Board File Initialization 1368. PHY Mappings
141 137
142Certain board file initialization is necessary in order to get a reference 138In order to get reference to a PHY without help from DeviceTree, the framework
143to the PHY in the case of non-dt boot. 139offers lookups which can be compared to clkdev that allow clk structures to be
144Say we have a single device that implements 3 PHYs that of USB, SATA and PCIe, 140bound to devices. A lookup can be made be made during runtime when a handle to
145then in the board file the following initialization should be done. 141the struct phy already exists.
146 142
147struct phy_consumer consumers[] = { 143The framework offers the following API for registering and unregistering the
148 PHY_CONSUMER("dwc3.0", "usb"), 144lookups.
149 PHY_CONSUMER("pcie.0", "pcie"), 145
150 PHY_CONSUMER("sata.0", "sata"), 146int phy_create_lookup(struct phy *phy, const char *con_id, const char *dev_id);
151}; 147void phy_remove_lookup(struct phy *phy, const char *con_id, const char *dev_id);
152PHY_CONSUMER takes 2 parameters, first is the device name of the controller
153(PHY consumer) and second is the port name.
154
155struct phy_init_data init_data = {
156 .consumers = consumers,
157 .num_consumers = ARRAY_SIZE(consumers),
158};
159
160static const struct platform_device pipe3_phy_dev = {
161 .name = "pipe3-phy",
162 .id = -1,
163 .dev = {
164 .platform_data = {
165 .init_data = &init_data,
166 },
167 },
168};
169
170then, while doing phy_create, the PHY driver should pass this init_data
171 phy_create(dev, ops, pdata->init_data);
172
173and the controller driver (phy consumer) should pass the port name along with
174the device to get a reference to the PHY
175 phy_get(dev, "pcie");
176 148
1779. DeviceTree Binding 1499. DeviceTree Binding
178 150