* [RFC PATCH 0/2] phy: core: better support for multi-phy in phy-core
@ 2014-07-04 15:07 Kishon Vijay Abraham I
2014-07-04 15:07 ` [RFC PATCH 1/2] phy: core: Fix of_phy_provider_lookup to return PHY provider for sub node Kishon Vijay Abraham I
2014-07-04 15:07 ` [RFC PATCH 2/2] phy: core: the node pointer of PHY need not be the same as that of PHY provider Kishon Vijay Abraham I
0 siblings, 2 replies; 7+ messages in thread
From: Kishon Vijay Abraham I @ 2014-07-04 15:07 UTC (permalink / raw)
To: linux-arm-kernel
In multi-phy PHY providers, each PHY should be modeled as sub-node of PHY
provider. So it makes sense for the controller node to have the phandle for
the sub-node instead of the PHY-provider node in the 'phy' property.
This patch series added support so that the controller node can have the
phandle to the sub-node. So if the phy specifier does not have any other
fields other than the phandle (and the PHY driver uses the default xlate),
phy_get will return the correct PHY.
However if the phy_sepcifier has other fields and the PHY driver provides
its own xlate, the PHY driver can use the *phy->dev.of_node*. (note that
now phy->dev.of_node will have the node pointer of the sub-node).
Kishon Vijay Abraham I (2):
phy: core: Fix of_phy_provider_lookup to return PHY provider for sub
node
phy: core: the node pointer of PHY need not be the same as that of
PHY provider
Documentation/phy.txt | 10 ++++++----
drivers/phy/phy-bcm-kona-usb2.c | 2 +-
drivers/phy/phy-core.c | 35 +++++++++++++++++++++++++++--------
drivers/phy/phy-exynos-dp-video.c | 2 +-
drivers/phy/phy-exynos-mipi-video.c | 2 +-
drivers/phy/phy-exynos5-usbdrd.c | 3 ++-
drivers/phy/phy-exynos5250-sata.c | 2 +-
drivers/phy/phy-mvebu-sata.c | 2 +-
drivers/phy/phy-omap-usb2.c | 2 +-
drivers/phy/phy-samsung-usb2.c | 3 ++-
drivers/phy/phy-sun4i-usb.c | 2 +-
drivers/phy/phy-ti-pipe3.c | 2 +-
drivers/phy/phy-twl4030-usb.c | 2 +-
drivers/phy/phy-xgene.c | 2 +-
include/linux/phy/phy.h | 15 ++++++++++-----
15 files changed, 57 insertions(+), 29 deletions(-)
--
1.7.9.5
^ permalink raw reply [flat|nested] 7+ messages in thread
* [RFC PATCH 1/2] phy: core: Fix of_phy_provider_lookup to return PHY provider for sub node
2014-07-04 15:07 [RFC PATCH 0/2] phy: core: better support for multi-phy in phy-core Kishon Vijay Abraham I
@ 2014-07-04 15:07 ` Kishon Vijay Abraham I
2014-07-07 13:43 ` Lee Jones
2014-07-04 15:07 ` [RFC PATCH 2/2] phy: core: the node pointer of PHY need not be the same as that of PHY provider Kishon Vijay Abraham I
1 sibling, 1 reply; 7+ messages in thread
From: Kishon Vijay Abraham I @ 2014-07-04 15:07 UTC (permalink / raw)
To: linux-arm-kernel
Fixed of_phy_provider_lookup to return 'phy_provider' if _of_phy_get
passes the node pointer of the sub-node of phy provider node. This is
needed when phy provider implements multiple PHYs and each PHY is
modelled as the sub-node of PHY provider device node.
Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
---
drivers/phy/phy-core.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/drivers/phy/phy-core.c b/drivers/phy/phy-core.c
index c64a2f3..a4a1f783 100644
--- a/drivers/phy/phy-core.c
+++ b/drivers/phy/phy-core.c
@@ -86,10 +86,18 @@ static struct phy *phy_lookup(struct device *device, const char *port)
static struct phy_provider *of_phy_provider_lookup(struct device_node *node)
{
struct phy_provider *phy_provider;
+ struct device_node *child;
list_for_each_entry(phy_provider, &phy_provider_list, list) {
- if (phy_provider->dev->of_node == node)
+ if (phy_provider->dev->of_node != node) {
+ for_each_child_of_node(phy_provider->dev->of_node,
+ child) {
+ if (child == node)
+ return phy_provider;
+ }
+ } else {
return phy_provider;
+ }
}
return ERR_PTR(-EPROBE_DEFER);
--
1.7.9.5
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [RFC PATCH 2/2] phy: core: the node pointer of PHY need not be the same as that of PHY provider
2014-07-04 15:07 [RFC PATCH 0/2] phy: core: better support for multi-phy in phy-core Kishon Vijay Abraham I
2014-07-04 15:07 ` [RFC PATCH 1/2] phy: core: Fix of_phy_provider_lookup to return PHY provider for sub node Kishon Vijay Abraham I
@ 2014-07-04 15:07 ` Kishon Vijay Abraham I
2014-07-07 13:12 ` Lee Jones
1 sibling, 1 reply; 7+ messages in thread
From: Kishon Vijay Abraham I @ 2014-07-04 15:07 UTC (permalink / raw)
To: linux-arm-kernel
In case of multi-phy PHY providers, each PHY should be modeled as a sub
node of the PHY provider. Then each PHY will have a different node pointer
(node pointer of sub node) than that of PHY provider. Added this provision
in the PHY core.
Also fixed all drivers to use the updated API.
Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
---
Documentation/phy.txt | 10 ++++++----
drivers/phy/phy-bcm-kona-usb2.c | 2 +-
drivers/phy/phy-core.c | 25 ++++++++++++++++++-------
drivers/phy/phy-exynos-dp-video.c | 2 +-
drivers/phy/phy-exynos-mipi-video.c | 2 +-
drivers/phy/phy-exynos5-usbdrd.c | 3 ++-
drivers/phy/phy-exynos5250-sata.c | 2 +-
drivers/phy/phy-mvebu-sata.c | 2 +-
drivers/phy/phy-omap-usb2.c | 2 +-
drivers/phy/phy-samsung-usb2.c | 3 ++-
drivers/phy/phy-sun4i-usb.c | 2 +-
drivers/phy/phy-ti-pipe3.c | 2 +-
drivers/phy/phy-twl4030-usb.c | 2 +-
drivers/phy/phy-xgene.c | 2 +-
include/linux/phy/phy.h | 15 ++++++++++-----
15 files changed, 48 insertions(+), 28 deletions(-)
diff --git a/Documentation/phy.txt b/Documentation/phy.txt
index ebff6ee..c6594af 100644
--- a/Documentation/phy.txt
+++ b/Documentation/phy.txt
@@ -53,10 +53,12 @@ unregister the PHY.
The PHY driver should create the PHY in order for other peripheral controllers
to make use of it. The PHY framework provides 2 APIs to create the PHY.
-struct phy *phy_create(struct device *dev, const struct phy_ops *ops,
- struct phy_init_data *init_data);
-struct phy *devm_phy_create(struct device *dev, const struct phy_ops *ops,
- struct phy_init_data *init_data);
+struct phy *phy_create(struct device *dev, struct device_node *node,
+ const struct phy_ops *ops,
+ struct phy_init_data *init_data);
+struct phy *devm_phy_create(struct device *dev, struct device_node *node,
+ const struct phy_ops *ops,
+ struct phy_init_data *init_data);
The PHY drivers can use one of the above 2 APIs to create the PHY by passing
the device pointer, phy ops and init_data.
diff --git a/drivers/phy/phy-bcm-kona-usb2.c b/drivers/phy/phy-bcm-kona-usb2.c
index e94f5a6..894fe74 100644
--- a/drivers/phy/phy-bcm-kona-usb2.c
+++ b/drivers/phy/phy-bcm-kona-usb2.c
@@ -117,7 +117,7 @@ static int bcm_kona_usb2_probe(struct platform_device *pdev)
platform_set_drvdata(pdev, phy);
- gphy = devm_phy_create(dev, &ops, NULL);
+ gphy = devm_phy_create(dev, NULL, &ops, NULL);
if (IS_ERR(gphy))
return PTR_ERR(gphy);
diff --git a/drivers/phy/phy-core.c b/drivers/phy/phy-core.c
index a4a1f783..9ad6691 100644
--- a/drivers/phy/phy-core.c
+++ b/drivers/phy/phy-core.c
@@ -406,13 +406,20 @@ struct phy *of_phy_simple_xlate(struct device *dev, struct of_phandle_args
struct phy *phy;
struct class_dev_iter iter;
struct device_node *node = dev->of_node;
+ struct device_node *child;
class_dev_iter_init(&iter, phy_class, NULL, NULL);
while ((dev = class_dev_iter_next(&iter))) {
phy = to_phy(dev);
- if (node != phy->dev.of_node)
+ if (node != phy->dev.of_node) {
+ for_each_child_of_node(node, child) {
+ if (child == phy->dev.of_node)
+ goto phy_found;
+ }
continue;
+ }
+phy_found:
class_dev_iter_exit(&iter);
return phy;
}
@@ -570,13 +577,15 @@ EXPORT_SYMBOL_GPL(devm_of_phy_get);
/**
* phy_create() - create a new phy
* @dev: device that is creating the new phy
+ * @node: device node of the phy
* @ops: function pointers for performing phy operations
* @init_data: contains the list of PHY consumers or NULL
*
* Called to create a phy using phy framework.
*/
-struct phy *phy_create(struct device *dev, const struct phy_ops *ops,
- struct phy_init_data *init_data)
+struct phy *phy_create(struct device *dev, struct device_node *node,
+ const struct phy_ops *ops,
+ struct phy_init_data *init_data)
{
int ret;
int id;
@@ -601,7 +610,7 @@ struct phy *phy_create(struct device *dev, const struct phy_ops *ops,
phy->dev.class = phy_class;
phy->dev.parent = dev;
- phy->dev.of_node = dev->of_node;
+ phy->dev.of_node = node?node:dev->of_node;
phy->id = id;
phy->ops = ops;
phy->init_data = init_data;
@@ -633,6 +642,7 @@ EXPORT_SYMBOL_GPL(phy_create);
/**
* devm_phy_create() - create a new phy
* @dev: device that is creating the new phy
+ * @node: device node of the phy
* @ops: function pointers for performing phy operations
* @init_data: contains the list of PHY consumers or NULL
*
@@ -641,8 +651,9 @@ EXPORT_SYMBOL_GPL(phy_create);
* On driver detach, release function is invoked on the devres data,
* then, devres data is freed.
*/
-struct phy *devm_phy_create(struct device *dev, const struct phy_ops *ops,
- struct phy_init_data *init_data)
+struct phy *devm_phy_create(struct device *dev, struct device_node *node,
+ const struct phy_ops *ops,
+ struct phy_init_data *init_data)
{
struct phy **ptr, *phy;
@@ -650,7 +661,7 @@ struct phy *devm_phy_create(struct device *dev, const struct phy_ops *ops,
if (!ptr)
return ERR_PTR(-ENOMEM);
- phy = phy_create(dev, ops, init_data);
+ phy = phy_create(dev, node, ops, init_data);
if (!IS_ERR(phy)) {
*ptr = phy;
devres_add(dev, ptr);
diff --git a/drivers/phy/phy-exynos-dp-video.c b/drivers/phy/phy-exynos-dp-video.c
index 0786fef..94fc0d1 100644
--- a/drivers/phy/phy-exynos-dp-video.c
+++ b/drivers/phy/phy-exynos-dp-video.c
@@ -76,7 +76,7 @@ static int exynos_dp_video_phy_probe(struct platform_device *pdev)
if (IS_ERR(state->regs))
return PTR_ERR(state->regs);
- phy = devm_phy_create(dev, &exynos_dp_video_phy_ops, NULL);
+ phy = devm_phy_create(dev, NULL, &exynos_dp_video_phy_ops, NULL);
if (IS_ERR(phy)) {
dev_err(dev, "failed to create Display Port PHY\n");
return PTR_ERR(phy);
diff --git a/drivers/phy/phy-exynos-mipi-video.c b/drivers/phy/phy-exynos-mipi-video.c
index ff02668..e29a100 100644
--- a/drivers/phy/phy-exynos-mipi-video.c
+++ b/drivers/phy/phy-exynos-mipi-video.c
@@ -135,7 +135,7 @@ static int exynos_mipi_video_phy_probe(struct platform_device *pdev)
spin_lock_init(&state->slock);
for (i = 0; i < EXYNOS_MIPI_PHYS_NUM; i++) {
- struct phy *phy = devm_phy_create(dev,
+ struct phy *phy = devm_phy_create(dev, NULL,
&exynos_mipi_video_phy_ops, NULL);
if (IS_ERR(phy)) {
dev_err(dev, "failed to create PHY %d\n", i);
diff --git a/drivers/phy/phy-exynos5-usbdrd.c b/drivers/phy/phy-exynos5-usbdrd.c
index 76d862b..950532f 100644
--- a/drivers/phy/phy-exynos5-usbdrd.c
+++ b/drivers/phy/phy-exynos5-usbdrd.c
@@ -635,7 +635,8 @@ static int exynos5_usbdrd_phy_probe(struct platform_device *pdev)
dev_vdbg(dev, "Creating usbdrd_phy phy\n");
for (i = 0; i < EXYNOS5_DRDPHYS_NUM; i++) {
- struct phy *phy = devm_phy_create(dev, &exynos5_usbdrd_phy_ops,
+ struct phy *phy = devm_phy_create(dev, NULL,
+ &exynos5_usbdrd_phy_ops,
NULL);
if (IS_ERR(phy)) {
dev_err(dev, "Failed to create usbdrd_phy phy\n");
diff --git a/drivers/phy/phy-exynos5250-sata.c b/drivers/phy/phy-exynos5250-sata.c
index 0568945..19a679a 100644
--- a/drivers/phy/phy-exynos5250-sata.c
+++ b/drivers/phy/phy-exynos5250-sata.c
@@ -210,7 +210,7 @@ static int exynos_sata_phy_probe(struct platform_device *pdev)
return ret;
}
- sata_phy->phy = devm_phy_create(dev, &exynos_sata_phy_ops, NULL);
+ sata_phy->phy = devm_phy_create(dev, NULL, &exynos_sata_phy_ops, NULL);
if (IS_ERR(sata_phy->phy)) {
clk_disable_unprepare(sata_phy->phyclk);
dev_err(dev, "failed to create PHY\n");
diff --git a/drivers/phy/phy-mvebu-sata.c b/drivers/phy/phy-mvebu-sata.c
index d70ecd6..cc3c0e1 100644
--- a/drivers/phy/phy-mvebu-sata.c
+++ b/drivers/phy/phy-mvebu-sata.c
@@ -99,7 +99,7 @@ static int phy_mvebu_sata_probe(struct platform_device *pdev)
if (IS_ERR(priv->clk))
return PTR_ERR(priv->clk);
- phy = devm_phy_create(&pdev->dev, &phy_mvebu_sata_ops, NULL);
+ phy = devm_phy_create(&pdev->dev, NULL, &phy_mvebu_sata_ops, NULL);
if (IS_ERR(phy))
return PTR_ERR(phy);
diff --git a/drivers/phy/phy-omap-usb2.c b/drivers/phy/phy-omap-usb2.c
index 7007c11..fb17533 100644
--- a/drivers/phy/phy-omap-usb2.c
+++ b/drivers/phy/phy-omap-usb2.c
@@ -264,7 +264,7 @@ static int omap_usb2_probe(struct platform_device *pdev)
platform_set_drvdata(pdev, phy);
pm_runtime_enable(phy->dev);
- generic_phy = devm_phy_create(phy->dev, &ops, NULL);
+ generic_phy = devm_phy_create(phy->dev, NULL, &ops, NULL);
if (IS_ERR(generic_phy))
return PTR_ERR(generic_phy);
diff --git a/drivers/phy/phy-samsung-usb2.c b/drivers/phy/phy-samsung-usb2.c
index 8a8c6bc..8c75add 100644
--- a/drivers/phy/phy-samsung-usb2.c
+++ b/drivers/phy/phy-samsung-usb2.c
@@ -189,7 +189,8 @@ static int samsung_usb2_phy_probe(struct platform_device *pdev)
struct samsung_usb2_phy_instance *p = &drv->instances[i];
dev_dbg(dev, "Creating phy \"%s\"\n", label);
- p->phy = devm_phy_create(dev, &samsung_usb2_phy_ops, NULL);
+ p->phy = devm_phy_create(dev, NULL, &samsung_usb2_phy_ops,
+ NULL);
if (IS_ERR(p->phy)) {
dev_err(drv->dev, "Failed to create usb2_phy \"%s\"\n",
label);
diff --git a/drivers/phy/phy-sun4i-usb.c b/drivers/phy/phy-sun4i-usb.c
index 115d8d5..60e11ff 100644
--- a/drivers/phy/phy-sun4i-usb.c
+++ b/drivers/phy/phy-sun4i-usb.c
@@ -294,7 +294,7 @@ static int sun4i_usb_phy_probe(struct platform_device *pdev)
return PTR_ERR(phy->pmu);
}
- phy->phy = devm_phy_create(dev, &sun4i_usb_phy_ops, NULL);
+ phy->phy = devm_phy_create(dev, NULL, &sun4i_usb_phy_ops, NULL);
if (IS_ERR(phy->phy)) {
dev_err(dev, "failed to create PHY %d\n", i);
return PTR_ERR(phy->phy);
diff --git a/drivers/phy/phy-ti-pipe3.c b/drivers/phy/phy-ti-pipe3.c
index 93bcd67..b964aa9 100644
--- a/drivers/phy/phy-ti-pipe3.c
+++ b/drivers/phy/phy-ti-pipe3.c
@@ -400,7 +400,7 @@ static int ti_pipe3_probe(struct platform_device *pdev)
platform_set_drvdata(pdev, phy);
pm_runtime_enable(phy->dev);
- generic_phy = devm_phy_create(phy->dev, &ops, NULL);
+ generic_phy = devm_phy_create(phy->dev, NULL, &ops, NULL);
if (IS_ERR(generic_phy))
return PTR_ERR(generic_phy);
diff --git a/drivers/phy/phy-twl4030-usb.c b/drivers/phy/phy-twl4030-usb.c
index 2e0e9b3..e1a6623 100644
--- a/drivers/phy/phy-twl4030-usb.c
+++ b/drivers/phy/phy-twl4030-usb.c
@@ -695,7 +695,7 @@ 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, &ops, init_data);
+ phy = devm_phy_create(twl->dev, NULL, &ops, init_data);
if (IS_ERR(phy)) {
dev_dbg(&pdev->dev, "Failed to create PHY\n");
return PTR_ERR(phy);
diff --git a/drivers/phy/phy-xgene.c b/drivers/phy/phy-xgene.c
index 4aa1ccd..db809b9 100644
--- a/drivers/phy/phy-xgene.c
+++ b/drivers/phy/phy-xgene.c
@@ -1707,7 +1707,7 @@ static int xgene_phy_probe(struct platform_device *pdev)
ctx->dev = &pdev->dev;
platform_set_drvdata(pdev, ctx);
- ctx->phy = devm_phy_create(ctx->dev, &xgene_phy_ops, NULL);
+ ctx->phy = devm_phy_create(ctx->dev, NULL, &xgene_phy_ops, NULL);
if (IS_ERR(ctx->phy)) {
dev_dbg(&pdev->dev, "Failed to create PHY\n");
rc = PTR_ERR(ctx->phy);
diff --git a/include/linux/phy/phy.h b/include/linux/phy/phy.h
index 2760744..cfb878f 100644
--- a/include/linux/phy/phy.h
+++ b/include/linux/phy/phy.h
@@ -156,9 +156,10 @@ void devm_phy_put(struct device *dev, struct phy *phy);
struct phy *of_phy_get(struct device_node *np, const char *con_id);
struct phy *of_phy_simple_xlate(struct device *dev,
struct of_phandle_args *args);
-struct phy *phy_create(struct device *dev, const struct phy_ops *ops,
- struct phy_init_data *init_data);
-struct phy *devm_phy_create(struct device *dev,
+struct phy *phy_create(struct device *dev, struct device_node *node,
+ const struct phy_ops *ops,
+ struct phy_init_data *init_data);
+struct phy *devm_phy_create(struct device *dev, struct device_node *node,
const struct phy_ops *ops, struct phy_init_data *init_data);
void phy_destroy(struct phy *phy);
void devm_phy_destroy(struct device *dev, struct phy *phy);
@@ -297,13 +298,17 @@ static inline struct phy *of_phy_simple_xlate(struct device *dev,
}
static inline struct phy *phy_create(struct device *dev,
- const struct phy_ops *ops, struct phy_init_data *init_data)
+ struct device_node *node,
+ const struct phy_ops *ops,
+ struct phy_init_data *init_data)
{
return ERR_PTR(-ENOSYS);
}
static inline struct phy *devm_phy_create(struct device *dev,
- const struct phy_ops *ops, struct phy_init_data *init_data)
+ struct device_node *node,
+ const struct phy_ops *ops,
+ struct phy_init_data *init_data)
{
return ERR_PTR(-ENOSYS);
}
--
1.7.9.5
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [RFC PATCH 2/2] phy: core: the node pointer of PHY need not be the same as that of PHY provider
2014-07-04 15:07 ` [RFC PATCH 2/2] phy: core: the node pointer of PHY need not be the same as that of PHY provider Kishon Vijay Abraham I
@ 2014-07-07 13:12 ` Lee Jones
2014-07-07 14:09 ` Kishon Vijay Abraham I
0 siblings, 1 reply; 7+ messages in thread
From: Lee Jones @ 2014-07-07 13:12 UTC (permalink / raw)
To: linux-arm-kernel
On Fri, 04 Jul 2014, Kishon Vijay Abraham I wrote:
> In case of multi-phy PHY providers, each PHY should be modeled as a sub
> node of the PHY provider. Then each PHY will have a different node pointer
> (node pointer of sub node) than that of PHY provider. Added this provision
> in the PHY core.
> Also fixed all drivers to use the updated API.
>
> Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
> ---
> Documentation/phy.txt | 10 ++++++----
> drivers/phy/phy-bcm-kona-usb2.c | 2 +-
> drivers/phy/phy-core.c | 25 ++++++++++++++++++-------
> drivers/phy/phy-exynos-dp-video.c | 2 +-
> drivers/phy/phy-exynos-mipi-video.c | 2 +-
> drivers/phy/phy-exynos5-usbdrd.c | 3 ++-
> drivers/phy/phy-exynos5250-sata.c | 2 +-
> drivers/phy/phy-mvebu-sata.c | 2 +-
> drivers/phy/phy-omap-usb2.c | 2 +-
> drivers/phy/phy-samsung-usb2.c | 3 ++-
> drivers/phy/phy-sun4i-usb.c | 2 +-
> drivers/phy/phy-ti-pipe3.c | 2 +-
> drivers/phy/phy-twl4030-usb.c | 2 +-
> drivers/phy/phy-xgene.c | 2 +-
> include/linux/phy/phy.h | 15 ++++++++++-----
> 15 files changed, 48 insertions(+), 28 deletions(-)
I wrote a very similar patch already. I knew I should have sent it on
Friday. :(
Patch looks good, just a real minor point.
> phy->dev.class = phy_class;
> phy->dev.parent = dev;
> - phy->dev.of_node = dev->of_node;
> + phy->dev.of_node = node?node:dev->of_node;
There should be spaces either side of the '?' and ':', or you can do
this more succinctly by:
phy->dev.of_node = node ?: dev->of_node;
Once fixed, feel free to add my:
Acked-by: Lee Jones <lee.jones@linaro.org>
--
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org ? Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
^ permalink raw reply [flat|nested] 7+ messages in thread
* [RFC PATCH 1/2] phy: core: Fix of_phy_provider_lookup to return PHY provider for sub node
2014-07-04 15:07 ` [RFC PATCH 1/2] phy: core: Fix of_phy_provider_lookup to return PHY provider for sub node Kishon Vijay Abraham I
@ 2014-07-07 13:43 ` Lee Jones
0 siblings, 0 replies; 7+ messages in thread
From: Lee Jones @ 2014-07-07 13:43 UTC (permalink / raw)
To: linux-arm-kernel
On Fri, 04 Jul 2014, Kishon Vijay Abraham I wrote:
> Fixed of_phy_provider_lookup to return 'phy_provider' if _of_phy_get
> passes the node pointer of the sub-node of phy provider node. This is
> needed when phy provider implements multiple PHYs and each PHY is
> modelled as the sub-node of PHY provider device node.
>
> Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
> ---
> drivers/phy/phy-core.c | 10 +++++++++-
> 1 file changed, 9 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/phy/phy-core.c b/drivers/phy/phy-core.c
> index c64a2f3..a4a1f783 100644
> --- a/drivers/phy/phy-core.c
> +++ b/drivers/phy/phy-core.c
> @@ -86,10 +86,18 @@ static struct phy *phy_lookup(struct device *device, const char *port)
> static struct phy_provider *of_phy_provider_lookup(struct device_node *node)
> {
> struct phy_provider *phy_provider;
> + struct device_node *child;
>
> list_for_each_entry(phy_provider, &phy_provider_list, list) {
> - if (phy_provider->dev->of_node == node)
> + if (phy_provider->dev->of_node != node) {
> + for_each_child_of_node(phy_provider->dev->of_node,
> + child) {
> + if (child == node)
> + return phy_provider;
> + }
> + } else {
> return phy_provider;
> + }
> }
>
> return ERR_PTR(-EPROBE_DEFER);
How about this instead:
> list_for_each_entry(phy_provider, &phy_provider_list, list) {
> if (phy_provider->dev->of_node == node)
> return phy_provider;
> +
> + for_each_child_of_node(phy_provider->dev->of_node, child)
> + if (child == node)
> + return phy_provider;
> }
--
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org ? Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
^ permalink raw reply [flat|nested] 7+ messages in thread
* [RFC PATCH 2/2] phy: core: the node pointer of PHY need not be the same as that of PHY provider
2014-07-07 13:12 ` Lee Jones
@ 2014-07-07 14:09 ` Kishon Vijay Abraham I
2014-07-07 14:59 ` Lee Jones
0 siblings, 1 reply; 7+ messages in thread
From: Kishon Vijay Abraham I @ 2014-07-07 14:09 UTC (permalink / raw)
To: linux-arm-kernel
Hi,
On Monday 07 July 2014 06:42 PM, Lee Jones wrote:
> On Fri, 04 Jul 2014, Kishon Vijay Abraham I wrote:
>
>> In case of multi-phy PHY providers, each PHY should be modeled as a sub
>> node of the PHY provider. Then each PHY will have a different node pointer
>> (node pointer of sub node) than that of PHY provider. Added this provision
>> in the PHY core.
>> Also fixed all drivers to use the updated API.
>>
>> Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
>> ---
>> Documentation/phy.txt | 10 ++++++----
>> drivers/phy/phy-bcm-kona-usb2.c | 2 +-
>> drivers/phy/phy-core.c | 25 ++++++++++++++++++-------
>> drivers/phy/phy-exynos-dp-video.c | 2 +-
>> drivers/phy/phy-exynos-mipi-video.c | 2 +-
>> drivers/phy/phy-exynos5-usbdrd.c | 3 ++-
>> drivers/phy/phy-exynos5250-sata.c | 2 +-
>> drivers/phy/phy-mvebu-sata.c | 2 +-
>> drivers/phy/phy-omap-usb2.c | 2 +-
>> drivers/phy/phy-samsung-usb2.c | 3 ++-
>> drivers/phy/phy-sun4i-usb.c | 2 +-
>> drivers/phy/phy-ti-pipe3.c | 2 +-
>> drivers/phy/phy-twl4030-usb.c | 2 +-
>> drivers/phy/phy-xgene.c | 2 +-
>> include/linux/phy/phy.h | 15 ++++++++++-----
>> 15 files changed, 48 insertions(+), 28 deletions(-)
>
> I wrote a very similar patch already. I knew I should have sent it on
> Friday. :(
No problem! you can send your patch along with the MiPHY series.
Cheers
Kishon
>
> Patch looks good, just a real minor point.
>
>> phy->dev.class = phy_class;
>> phy->dev.parent = dev;
>> - phy->dev.of_node = dev->of_node;
>> + phy->dev.of_node = node?node:dev->of_node;
>
> There should be spaces either side of the '?' and ':', or you can do
> this more succinctly by:
>
> phy->dev.of_node = node ?: dev->of_node;
>
> Once fixed, feel free to add my:
>
> Acked-by: Lee Jones <lee.jones@linaro.org>
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* [RFC PATCH 2/2] phy: core: the node pointer of PHY need not be the same as that of PHY provider
2014-07-07 14:09 ` Kishon Vijay Abraham I
@ 2014-07-07 14:59 ` Lee Jones
0 siblings, 0 replies; 7+ messages in thread
From: Lee Jones @ 2014-07-07 14:59 UTC (permalink / raw)
To: linux-arm-kernel
On Mon, 07 Jul 2014, Kishon Vijay Abraham I wrote:
> Hi,
>
> On Monday 07 July 2014 06:42 PM, Lee Jones wrote:
> > On Fri, 04 Jul 2014, Kishon Vijay Abraham I wrote:
> >
> >> In case of multi-phy PHY providers, each PHY should be modeled as a sub
> >> node of the PHY provider. Then each PHY will have a different node pointer
> >> (node pointer of sub node) than that of PHY provider. Added this provision
> >> in the PHY core.
> >> Also fixed all drivers to use the updated API.
> >>
> >> Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
> >> ---
> >> Documentation/phy.txt | 10 ++++++----
> >> drivers/phy/phy-bcm-kona-usb2.c | 2 +-
> >> drivers/phy/phy-core.c | 25 ++++++++++++++++++-------
> >> drivers/phy/phy-exynos-dp-video.c | 2 +-
> >> drivers/phy/phy-exynos-mipi-video.c | 2 +-
> >> drivers/phy/phy-exynos5-usbdrd.c | 3 ++-
> >> drivers/phy/phy-exynos5250-sata.c | 2 +-
> >> drivers/phy/phy-mvebu-sata.c | 2 +-
> >> drivers/phy/phy-omap-usb2.c | 2 +-
> >> drivers/phy/phy-samsung-usb2.c | 3 ++-
> >> drivers/phy/phy-sun4i-usb.c | 2 +-
> >> drivers/phy/phy-ti-pipe3.c | 2 +-
> >> drivers/phy/phy-twl4030-usb.c | 2 +-
> >> drivers/phy/phy-xgene.c | 2 +-
> >> include/linux/phy/phy.h | 15 ++++++++++-----
> >> 15 files changed, 48 insertions(+), 28 deletions(-)
> >
> > I wrote a very similar patch already. I knew I should have sent it on
> > Friday. :(
>
> No problem! you can send your patch along with the MiPHY series.
That's okay. It's silly for us both to submit the same patch and
yours hit the MLs first & looks good so, the honour is yours.
> > Patch looks good, just a real minor point.
> >
> >> phy->dev.class = phy_class;
> >> phy->dev.parent = dev;
> >> - phy->dev.of_node = dev->of_node;
> >> + phy->dev.of_node = node?node:dev->of_node;
> >
> > There should be spaces either side of the '?' and ':', or you can do
> > this more succinctly by:
> >
> > phy->dev.of_node = node ?: dev->of_node;
> >
> > Once fixed, feel free to add my:
> >
> > Acked-by: Lee Jones <lee.jones@linaro.org>
> >
--
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org ? Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2014-07-07 14:59 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-07-04 15:07 [RFC PATCH 0/2] phy: core: better support for multi-phy in phy-core Kishon Vijay Abraham I
2014-07-04 15:07 ` [RFC PATCH 1/2] phy: core: Fix of_phy_provider_lookup to return PHY provider for sub node Kishon Vijay Abraham I
2014-07-07 13:43 ` Lee Jones
2014-07-04 15:07 ` [RFC PATCH 2/2] phy: core: the node pointer of PHY need not be the same as that of PHY provider Kishon Vijay Abraham I
2014-07-07 13:12 ` Lee Jones
2014-07-07 14:09 ` Kishon Vijay Abraham I
2014-07-07 14:59 ` Lee Jones
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).