Commit 214b606e authored by Marek Szyprowski's avatar Marek Szyprowski Committed by Greg Kroah-Hartman

usb: exynos: add support for getting PHYs from the standard dt array

Add the code for getting generic PHYs from standard device tree array
from the main controller device node. This is a first step in resolving
the conflict between Exynos EHCI/OHCI sub-nodes and generic USB device
bindings. Later the sub-nodes currently used for assigning PHYs to root
ports of the controller will be removed making a place for the generic
USB device bindings nodes.
Suggested-by: default avatarMåns Rullgård <mans@mansr.com>
Signed-off-by: default avatarMarek Szyprowski <m.szyprowski@samsung.com>
Acked-by: default avatarAlan Stern <stern@rowland.harvard.edu>
Acked-by: default avatarKrzysztof Kozlowski <krzk@kernel.org>
Link: https://lore.kernel.org/r/20190726081453.9456-3-m.szyprowski@samsung.comSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent c27989cc
...@@ -41,6 +41,7 @@ struct exynos_ehci_hcd { ...@@ -41,6 +41,7 @@ struct exynos_ehci_hcd {
struct clk *clk; struct clk *clk;
struct device_node *of_node; struct device_node *of_node;
struct phy *phy[PHY_NUMBER]; struct phy *phy[PHY_NUMBER];
bool legacy_phy;
}; };
#define to_exynos_ehci(hcd) (struct exynos_ehci_hcd *)(hcd_to_ehci(hcd)->priv) #define to_exynos_ehci(hcd) (struct exynos_ehci_hcd *)(hcd_to_ehci(hcd)->priv)
...@@ -50,10 +51,22 @@ static int exynos_ehci_get_phy(struct device *dev, ...@@ -50,10 +51,22 @@ static int exynos_ehci_get_phy(struct device *dev,
{ {
struct device_node *child; struct device_node *child;
struct phy *phy; struct phy *phy;
int phy_number; int phy_number, num_phys;
int ret; int ret;
/* Get PHYs for the controller */ /* Get PHYs for the controller */
num_phys = of_count_phandle_with_args(dev->of_node, "phys",
"#phy-cells");
for (phy_number = 0; phy_number < num_phys; phy_number++) {
phy = devm_of_phy_get_by_index(dev, dev->of_node, phy_number);
if (IS_ERR(phy))
return PTR_ERR(phy);
exynos_ehci->phy[phy_number] = phy;
}
if (num_phys > 0)
return 0;
/* Get PHYs using legacy bindings */
for_each_available_child_of_node(dev->of_node, child) { for_each_available_child_of_node(dev->of_node, child) {
ret = of_property_read_u32(child, "reg", &phy_number); ret = of_property_read_u32(child, "reg", &phy_number);
if (ret) { if (ret) {
...@@ -84,6 +97,7 @@ static int exynos_ehci_get_phy(struct device *dev, ...@@ -84,6 +97,7 @@ static int exynos_ehci_get_phy(struct device *dev,
} }
} }
exynos_ehci->legacy_phy = true;
return 0; return 0;
} }
...@@ -205,10 +219,11 @@ static int exynos_ehci_probe(struct platform_device *pdev) ...@@ -205,10 +219,11 @@ static int exynos_ehci_probe(struct platform_device *pdev)
ehci->caps = hcd->regs; ehci->caps = hcd->regs;
/* /*
* Workaround: reset of_node pointer to avoid conflict between Exynos * Workaround: reset of_node pointer to avoid conflict between legacy
* EHCI port subnodes and generic USB device bindings * Exynos EHCI port subnodes and generic USB device bindings
*/ */
exynos_ehci->of_node = pdev->dev.of_node; exynos_ehci->of_node = pdev->dev.of_node;
if (exynos_ehci->legacy_phy)
pdev->dev.of_node = NULL; pdev->dev.of_node = NULL;
/* DMA burst Enable */ /* DMA burst Enable */
......
...@@ -32,6 +32,7 @@ struct exynos_ohci_hcd { ...@@ -32,6 +32,7 @@ struct exynos_ohci_hcd {
struct clk *clk; struct clk *clk;
struct device_node *of_node; struct device_node *of_node;
struct phy *phy[PHY_NUMBER]; struct phy *phy[PHY_NUMBER];
bool legacy_phy;
}; };
static int exynos_ohci_get_phy(struct device *dev, static int exynos_ohci_get_phy(struct device *dev,
...@@ -39,10 +40,22 @@ static int exynos_ohci_get_phy(struct device *dev, ...@@ -39,10 +40,22 @@ static int exynos_ohci_get_phy(struct device *dev,
{ {
struct device_node *child; struct device_node *child;
struct phy *phy; struct phy *phy;
int phy_number; int phy_number, num_phys;
int ret; int ret;
/* Get PHYs for the controller */ /* Get PHYs for the controller */
num_phys = of_count_phandle_with_args(dev->of_node, "phys",
"#phy-cells");
for (phy_number = 0; phy_number < num_phys; phy_number++) {
phy = devm_of_phy_get_by_index(dev, dev->of_node, phy_number);
if (IS_ERR(phy))
return PTR_ERR(phy);
exynos_ohci->phy[phy_number] = phy;
}
if (num_phys > 0)
return 0;
/* Get PHYs using legacy bindings */
for_each_available_child_of_node(dev->of_node, child) { for_each_available_child_of_node(dev->of_node, child) {
ret = of_property_read_u32(child, "reg", &phy_number); ret = of_property_read_u32(child, "reg", &phy_number);
if (ret) { if (ret) {
...@@ -73,6 +86,7 @@ static int exynos_ohci_get_phy(struct device *dev, ...@@ -73,6 +86,7 @@ static int exynos_ohci_get_phy(struct device *dev,
} }
} }
exynos_ohci->legacy_phy = true;
return 0; return 0;
} }
...@@ -172,10 +186,11 @@ static int exynos_ohci_probe(struct platform_device *pdev) ...@@ -172,10 +186,11 @@ static int exynos_ohci_probe(struct platform_device *pdev)
} }
/* /*
* Workaround: reset of_node pointer to avoid conflict between Exynos * Workaround: reset of_node pointer to avoid conflict between legacy
* OHCI port subnodes and generic USB device bindings * Exynos OHCI port subnodes and generic USB device bindings
*/ */
exynos_ohci->of_node = pdev->dev.of_node; exynos_ohci->of_node = pdev->dev.of_node;
if (exynos_ohci->legacy_phy)
pdev->dev.of_node = NULL; pdev->dev.of_node = NULL;
err = usb_add_hcd(hcd, irq, IRQF_SHARED); err = usb_add_hcd(hcd, irq, IRQF_SHARED);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment