Commit af9f51c5 authored by Felipe Balbi's avatar Felipe Balbi

usb: phy: generic: fix how we find out about our resources

instead of having each user of generic phy find
out about its own resources and pass it to the
core layer, have th core layer itself figure that
out. It's as simple as moving a piece of code
around. This fixes a big regression caused during
the merge window where am335x-based platforms
wouldn't be able to probe their PHY driver.
Signed-off-by: default avatarFelipe Balbi <balbi@ti.com>
parent 39189c98
...@@ -52,8 +52,7 @@ static int am335x_phy_probe(struct platform_device *pdev) ...@@ -52,8 +52,7 @@ static int am335x_phy_probe(struct platform_device *pdev)
return am_phy->id; return am_phy->id;
} }
ret = usb_phy_gen_create_phy(dev, &am_phy->usb_phy_gen, ret = usb_phy_gen_create_phy(dev, &am_phy->usb_phy_gen, NULL);
USB_PHY_TYPE_USB2, 0, false);
if (ret) if (ret)
return ret; return ret;
......
...@@ -150,10 +150,38 @@ static int nop_set_host(struct usb_otg *otg, struct usb_bus *host) ...@@ -150,10 +150,38 @@ static int nop_set_host(struct usb_otg *otg, struct usb_bus *host)
} }
int usb_phy_gen_create_phy(struct device *dev, struct usb_phy_gen_xceiv *nop, int usb_phy_gen_create_phy(struct device *dev, struct usb_phy_gen_xceiv *nop,
enum usb_phy_type type, u32 clk_rate, bool needs_vcc) struct usb_phy_gen_xceiv_platform_data *pdata)
{ {
enum usb_phy_type type = USB_PHY_TYPE_USB2;
int err; int err;
u32 clk_rate = 0;
bool needs_vcc = false;
nop->reset_active_low = true; /* default behaviour */
if (dev->of_node) {
struct device_node *node = dev->of_node;
enum of_gpio_flags flags;
if (of_property_read_u32(node, "clock-frequency", &clk_rate))
clk_rate = 0;
needs_vcc = of_property_read_bool(node, "vcc-supply");
nop->gpio_reset = of_get_named_gpio_flags(node, "reset-gpios",
0, &flags);
if (nop->gpio_reset == -EPROBE_DEFER)
return -EPROBE_DEFER;
nop->reset_active_low = flags & OF_GPIO_ACTIVE_LOW;
} else if (pdata) {
type = pdata->type;
clk_rate = pdata->clk_rate;
needs_vcc = pdata->needs_vcc;
nop->gpio_reset = pdata->gpio_reset;
}
nop->phy.otg = devm_kzalloc(dev, sizeof(*nop->phy.otg), nop->phy.otg = devm_kzalloc(dev, sizeof(*nop->phy.otg),
GFP_KERNEL); GFP_KERNEL);
if (!nop->phy.otg) if (!nop->phy.otg)
...@@ -218,43 +246,14 @@ EXPORT_SYMBOL_GPL(usb_phy_gen_create_phy); ...@@ -218,43 +246,14 @@ EXPORT_SYMBOL_GPL(usb_phy_gen_create_phy);
static int usb_phy_gen_xceiv_probe(struct platform_device *pdev) static int usb_phy_gen_xceiv_probe(struct platform_device *pdev)
{ {
struct device *dev = &pdev->dev; struct device *dev = &pdev->dev;
struct usb_phy_gen_xceiv_platform_data *pdata =
dev_get_platdata(&pdev->dev);
struct usb_phy_gen_xceiv *nop; struct usb_phy_gen_xceiv *nop;
enum usb_phy_type type = USB_PHY_TYPE_USB2;
int err; int err;
u32 clk_rate = 0;
bool needs_vcc = false;
nop = devm_kzalloc(dev, sizeof(*nop), GFP_KERNEL); nop = devm_kzalloc(dev, sizeof(*nop), GFP_KERNEL);
if (!nop) if (!nop)
return -ENOMEM; return -ENOMEM;
nop->reset_active_low = true; /* default behaviour */ err = usb_phy_gen_create_phy(dev, nop, dev_get_platdata(&pdev->dev));
if (dev->of_node) {
struct device_node *node = dev->of_node;
enum of_gpio_flags flags;
if (of_property_read_u32(node, "clock-frequency", &clk_rate))
clk_rate = 0;
needs_vcc = of_property_read_bool(node, "vcc-supply");
nop->gpio_reset = of_get_named_gpio_flags(node, "reset-gpios",
0, &flags);
if (nop->gpio_reset == -EPROBE_DEFER)
return -EPROBE_DEFER;
nop->reset_active_low = flags & OF_GPIO_ACTIVE_LOW;
} else if (pdata) {
type = pdata->type;
clk_rate = pdata->clk_rate;
needs_vcc = pdata->needs_vcc;
nop->gpio_reset = pdata->gpio_reset;
}
err = usb_phy_gen_create_phy(dev, nop, type, clk_rate, needs_vcc);
if (err) if (err)
return err; return err;
......
#ifndef _PHY_GENERIC_H_ #ifndef _PHY_GENERIC_H_
#define _PHY_GENERIC_H_ #define _PHY_GENERIC_H_
#include <linux/usb/usb_phy_gen_xceiv.h>
struct usb_phy_gen_xceiv { struct usb_phy_gen_xceiv {
struct usb_phy phy; struct usb_phy phy;
struct device *dev; struct device *dev;
...@@ -14,6 +16,6 @@ int usb_gen_phy_init(struct usb_phy *phy); ...@@ -14,6 +16,6 @@ int usb_gen_phy_init(struct usb_phy *phy);
void usb_gen_phy_shutdown(struct usb_phy *phy); void usb_gen_phy_shutdown(struct usb_phy *phy);
int usb_phy_gen_create_phy(struct device *dev, struct usb_phy_gen_xceiv *nop, int usb_phy_gen_create_phy(struct device *dev, struct usb_phy_gen_xceiv *nop,
enum usb_phy_type type, u32 clk_rate, bool needs_vcc); struct usb_phy_gen_xceiv_platform_data *pdata);
#endif #endif
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