[U-Boot] [PATCH 1/2] USB: musb-new: omap2430: Prep driver for Peripheral support.

The omap2430 driver only currently supports host only. In preparation for supporting peripheral mode, this patch makes the driver support only the host by creating a ofdata_to_platdata function host/peripheral agnostic with a host helper version.
Signed-off-by: Adam Ford aford173@gmail.com
diff --git a/drivers/usb/musb-new/omap2430.c b/drivers/usb/musb-new/omap2430.c index 32743aa72c..b6e1320538 100644 --- a/drivers/usb/musb-new/omap2430.c +++ b/drivers/usb/musb-new/omap2430.c @@ -137,6 +137,12 @@ const struct musb_platform_ops omap2430_ops = {
#if CONFIG_IS_ENABLED(DM_USB)
+static const struct udevice_id omap2430_musb_ids[] = { + { .compatible = "ti,omap3-musb" }, + { .compatible = "ti,omap4-musb" }, + { } +}; + struct omap2430_musb_platdata { void *base; void *ctrl_mod_base; @@ -190,20 +196,6 @@ static int omap2430_musb_ofdata_to_platdata(struct udevice *dev) return -ENOENT; }
-#if 0 /* In a perfect world, mode would be set to OTG, mode 3 from DT */ - platdata->plat.mode = fdtdec_get_int(fdt, node, - "mode", -1); - if (platdata->plat.mode < 0) { - pr_err("MUSB mode DT entry missing\n"); - return -ENOENT; - } -#else /* MUSB_OTG, it doesn't work */ -#ifdef CONFIG_USB_MUSB_HOST /* Host seems to be the only option that works */ - platdata->plat.mode = MUSB_HOST; -#else /* For that matter, MUSB_PERIPHERAL doesn't either */ - platdata->plat.mode = MUSB_PERIPHERAL; -#endif -#endif platdata->otg_board_data.dev = dev; platdata->plat.config = &platdata->musb_config; platdata->plat.platform_ops = &omap2430_ops; @@ -211,11 +203,10 @@ static int omap2430_musb_ofdata_to_platdata(struct udevice *dev) return 0; }
+#ifdef CONFIG_USB_MUSB_HOST static int omap2430_musb_probe(struct udevice *dev) { -#ifdef CONFIG_USB_MUSB_HOST struct musb_host_data *host = dev_get_priv(dev); -#endif struct omap2430_musb_platdata *platdata = dev_get_platdata(dev); struct usb_bus_priv *priv = dev_get_uclass_priv(dev); struct omap_musb_board_data *otg_board_data; @@ -226,7 +217,6 @@ static int omap2430_musb_probe(struct udevice *dev)
otg_board_data = &platdata->otg_board_data;
-#ifdef CONFIG_USB_MUSB_HOST host->host = musb_init_controller(&platdata->plat, (struct device *)otg_board_data, platdata->base); @@ -235,11 +225,7 @@ static int omap2430_musb_probe(struct udevice *dev) }
ret = musb_lowlevel_init(host); -#else - ret = musb_register(&platdata->plat, - (struct device *)otg_board_data, - platdata->base); -#endif + return ret; }
@@ -252,28 +238,40 @@ static int omap2430_musb_remove(struct udevice *dev) return 0; }
-static const struct udevice_id omap2430_musb_ids[] = { - { .compatible = "ti,omap3-musb" }, - { .compatible = "ti,omap4-musb" }, - { } -}; +#if CONFIG_IS_ENABLED(OF_CONTROL) +static int omap2430_musb_host_ofdata_to_platdata(struct udevice *dev) +{ + struct ti_musb_platdata *platdata = dev_get_platdata(dev); + const void *fdt = gd->fdt_blob; + int node = dev_of_offset(dev); + int ret; + + ret = omap2430_musb_ofdata_to_platdata(dev); + if (ret) { + pr_err("platdata dt parse error\n"); + return ret; + } + + platdata->plat.mode = MUSB_HOST; + + return 0; +} +#endif
U_BOOT_DRIVER(omap2430_musb) = { .name = "omap2430-musb", -#ifdef CONFIG_USB_MUSB_HOST .id = UCLASS_USB, -#else - .id = UCLASS_USB_GADGET_GENERIC, -#endif .of_match = omap2430_musb_ids, - .ofdata_to_platdata = omap2430_musb_ofdata_to_platdata, +#if CONFIG_IS_ENABLED(OF_CONTROL) + .ofdata_to_platdata = omap2430_musb_host_ofdata_to_platdata, +#endif .probe = omap2430_musb_probe, .remove = omap2430_musb_remove, -#ifdef CONFIG_USB_MUSB_HOST .ops = &musb_usb_ops, -#endif .platdata_auto_alloc_size = sizeof(struct omap2430_musb_platdata), .priv_auto_alloc_size = sizeof(struct musb_host_data), };
+#endif + #endif /* CONFIG_IS_ENABLED(DM_USB) */

Borrowing from the updates to ti-musb.c, this glue layer checks to see if the MUSB controller is gadget or host. Going under the assumpution there is only one MUSB controller, this only builds either the host probe or the gadget probe. OTG would be preferred, but it doesn't appear to be working yet.
Signed-off-by: Adam Ford aford173@gmail.com
diff --git a/drivers/usb/musb-new/omap2430.c b/drivers/usb/musb-new/omap2430.c index b6e1320538..780d21c693 100644 --- a/drivers/usb/musb-new/omap2430.c +++ b/drivers/usb/musb-new/omap2430.c @@ -203,7 +203,7 @@ static int omap2430_musb_ofdata_to_platdata(struct udevice *dev) return 0; }
-#ifdef CONFIG_USB_MUSB_HOST +#ifndef CONFIG_USB_MUSB_GADGET static int omap2430_musb_probe(struct udevice *dev) { struct musb_host_data *host = dev_get_priv(dev); @@ -241,7 +241,7 @@ static int omap2430_musb_remove(struct udevice *dev) #if CONFIG_IS_ENABLED(OF_CONTROL) static int omap2430_musb_host_ofdata_to_platdata(struct udevice *dev) { - struct ti_musb_platdata *platdata = dev_get_platdata(dev); + struct omap2430_musb_platdata *platdata = dev_get_platdata(dev); const void *fdt = gd->fdt_blob; int node = dev_of_offset(dev); int ret; @@ -272,6 +272,83 @@ U_BOOT_DRIVER(omap2430_musb) = { .priv_auto_alloc_size = sizeof(struct musb_host_data), };
+#else + +struct omap2430_musb_peripheral { + struct musb *periph; +}; + +#if CONFIG_IS_ENABLED(OF_CONTROL) +static int omap2430_musb_peripheral_ofdata_to_platdata(struct udevice *dev) +{ + struct ti_musb_platdata *platdata = dev_get_platdata(dev); + const void *fdt = gd->fdt_blob; + int node = dev_of_offset(dev); + int ret; + + ret = omap2430_musb_ofdata_to_platdata(dev); + if (ret) { + pr_err("platdata dt parse error\n"); + return ret; + } + platdata->plat.mode = MUSB_PERIPHERAL; + + return 0; +} +#endif + +int dm_usb_gadget_handle_interrupts(struct udevice *dev) +{ + struct omap2430_musb_peripheral *priv = dev_get_priv(dev); + + priv->periph->isr(0, priv->periph); + + return 0; +} + +static int omap2430_musb_peripheral_probe(struct udevice *dev) +{ + struct omap2430_musb_peripheral *priv = dev_get_priv(dev); + struct omap2430_musb_platdata *platdata = dev_get_platdata(dev); + struct omap_musb_board_data *otg_board_data; + int ret; + + otg_board_data = &platdata->otg_board_data; + priv->periph = musb_init_controller(&platdata->plat, + (struct device *)otg_board_data, + platdata->base); + if (!priv->periph) + return -EIO; + + /* ti_musb_set_phy_power(dev, 1); */ + musb_gadget_setup(priv->periph); + return usb_add_gadget_udc((struct device *)dev, &priv->periph->g); +} + +static int omap2430_musb_peripheral_remove(struct udevice *dev) +{ + struct omap2430_musb_peripheral *priv = dev_get_priv(dev); + + usb_del_gadget_udc(&priv->periph->g); + /* ti_musb_set_phy_power(dev, 0); */ + + return 0; +} + +U_BOOT_DRIVER(omap2430_musb_peripheral) = { + .name = "ti-musb-peripheral", + .id = UCLASS_USB_GADGET_GENERIC, + .of_match = omap2430_musb_ids, +#if CONFIG_IS_ENABLED(OF_CONTROL) + .ofdata_to_platdata = omap2430_musb_peripheral_ofdata_to_platdata, +#endif + .probe = omap2430_musb_peripheral_probe, + .remove = omap2430_musb_peripheral_remove, + .ops = &musb_usb_ops, + .platdata_auto_alloc_size = sizeof(struct omap2430_musb_platdata), + .priv_auto_alloc_size = sizeof(struct omap2430_musb_peripheral), + .flags = DM_FLAG_PRE_RELOC, +}; #endif
#endif /* CONFIG_IS_ENABLED(DM_USB) */

On 17/12/2018 21:34, Adam Ford wrote:
Borrowing from the updates to ti-musb.c, this glue layer checks to see if the MUSB controller is gadget or host. Going under the assumpution there is only one MUSB controller, this only builds either the host probe or the gadget probe. OTG would be preferred, but it doesn't appear to be working yet.
You can support both host and periph mode at the same time:
Create a new driver (a MISC UCLASS for ex) compatible with ti,omap3-musb.
Provide a bind function. In this function check the value of dr_mode and bind the appropriate child driver (host or peripheral).
This is how it is done in ti-musb.c.
JJ
Signed-off-by: Adam Ford aford173@gmail.com
diff --git a/drivers/usb/musb-new/omap2430.c b/drivers/usb/musb-new/omap2430.c index b6e1320538..780d21c693 100644 --- a/drivers/usb/musb-new/omap2430.c +++ b/drivers/usb/musb-new/omap2430.c @@ -203,7 +203,7 @@ static int omap2430_musb_ofdata_to_platdata(struct udevice *dev) return 0; }
-#ifdef CONFIG_USB_MUSB_HOST +#ifndef CONFIG_USB_MUSB_GADGET static int omap2430_musb_probe(struct udevice *dev) { struct musb_host_data *host = dev_get_priv(dev); @@ -241,7 +241,7 @@ static int omap2430_musb_remove(struct udevice *dev) #if CONFIG_IS_ENABLED(OF_CONTROL) static int omap2430_musb_host_ofdata_to_platdata(struct udevice *dev) {
- struct ti_musb_platdata *platdata = dev_get_platdata(dev);
- struct omap2430_musb_platdata *platdata = dev_get_platdata(dev); const void *fdt = gd->fdt_blob; int node = dev_of_offset(dev); int ret;
@@ -272,6 +272,83 @@ U_BOOT_DRIVER(omap2430_musb) = { .priv_auto_alloc_size = sizeof(struct musb_host_data), };
+#else
+struct omap2430_musb_peripheral {
- struct musb *periph;
+};
+#if CONFIG_IS_ENABLED(OF_CONTROL) +static int omap2430_musb_peripheral_ofdata_to_platdata(struct udevice *dev) +{
- struct ti_musb_platdata *platdata = dev_get_platdata(dev);
- const void *fdt = gd->fdt_blob;
- int node = dev_of_offset(dev);
- int ret;
- ret = omap2430_musb_ofdata_to_platdata(dev);
- if (ret) {
pr_err("platdata dt parse error\n");
return ret;
- }
- platdata->plat.mode = MUSB_PERIPHERAL;
- return 0;
+} +#endif
+int dm_usb_gadget_handle_interrupts(struct udevice *dev) +{
- struct omap2430_musb_peripheral *priv = dev_get_priv(dev);
- priv->periph->isr(0, priv->periph);
- return 0;
+}
+static int omap2430_musb_peripheral_probe(struct udevice *dev) +{
- struct omap2430_musb_peripheral *priv = dev_get_priv(dev);
- struct omap2430_musb_platdata *platdata = dev_get_platdata(dev);
- struct omap_musb_board_data *otg_board_data;
- int ret;
- otg_board_data = &platdata->otg_board_data;
- priv->periph = musb_init_controller(&platdata->plat,
(struct device *)otg_board_data,
platdata->base);
- if (!priv->periph)
return -EIO;
- /* ti_musb_set_phy_power(dev, 1); */
- musb_gadget_setup(priv->periph);
- return usb_add_gadget_udc((struct device *)dev, &priv->periph->g);
+}
+static int omap2430_musb_peripheral_remove(struct udevice *dev) +{
- struct omap2430_musb_peripheral *priv = dev_get_priv(dev);
- usb_del_gadget_udc(&priv->periph->g);
- /* ti_musb_set_phy_power(dev, 0); */
- return 0;
+}
+U_BOOT_DRIVER(omap2430_musb_peripheral) = {
- .name = "ti-musb-peripheral",
- .id = UCLASS_USB_GADGET_GENERIC,
- .of_match = omap2430_musb_ids,
+#if CONFIG_IS_ENABLED(OF_CONTROL)
- .ofdata_to_platdata = omap2430_musb_peripheral_ofdata_to_platdata,
+#endif
- .probe = omap2430_musb_peripheral_probe,
- .remove = omap2430_musb_peripheral_remove,
- .ops = &musb_usb_ops,
- .platdata_auto_alloc_size = sizeof(struct omap2430_musb_platdata),
- .priv_auto_alloc_size = sizeof(struct omap2430_musb_peripheral),
- .flags = DM_FLAG_PRE_RELOC,
+}; #endif
#endif /* CONFIG_IS_ENABLED(DM_USB) */

On Wed, Dec 19, 2018 at 4:59 AM Jean-Jacques Hiblot jjhiblot@ti.com wrote:
On 17/12/2018 21:34, Adam Ford wrote:
Borrowing from the updates to ti-musb.c, this glue layer checks to see if the MUSB controller is gadget or host. Going under the assumpution there is only one MUSB controller, this only builds either the host probe or the gadget probe. OTG would be preferred, but it doesn't appear to be working yet.
You can support both host and periph mode at the same time:
Create a new driver (a MISC UCLASS for ex) compatible with ti,omap3-musb.
Provide a bind function. In this function check the value of dr_mode and bind the appropriate child driver (host or peripheral).
This is how it is done in ti-musb.c.
I tried that first. Anytime I tried to use the MISC_UCLASS, I would get the err -96 like others are reporting. If you have any other suggestions on how to fix the -96 issue, I'm willing to try them. Since we didn't have OTG working before, and it was either host or gadget, I felt this was at least one step forward by making it DM_USB compliant.
adam
JJ
Signed-off-by: Adam Ford aford173@gmail.com
diff --git a/drivers/usb/musb-new/omap2430.c b/drivers/usb/musb-new/omap2430.c index b6e1320538..780d21c693 100644 --- a/drivers/usb/musb-new/omap2430.c +++ b/drivers/usb/musb-new/omap2430.c @@ -203,7 +203,7 @@ static int omap2430_musb_ofdata_to_platdata(struct udevice *dev) return 0; }
-#ifdef CONFIG_USB_MUSB_HOST +#ifndef CONFIG_USB_MUSB_GADGET static int omap2430_musb_probe(struct udevice *dev) { struct musb_host_data *host = dev_get_priv(dev); @@ -241,7 +241,7 @@ static int omap2430_musb_remove(struct udevice *dev) #if CONFIG_IS_ENABLED(OF_CONTROL) static int omap2430_musb_host_ofdata_to_platdata(struct udevice *dev) {
struct ti_musb_platdata *platdata = dev_get_platdata(dev);
struct omap2430_musb_platdata *platdata = dev_get_platdata(dev); const void *fdt = gd->fdt_blob; int node = dev_of_offset(dev); int ret;
@@ -272,6 +272,83 @@ U_BOOT_DRIVER(omap2430_musb) = { .priv_auto_alloc_size = sizeof(struct musb_host_data), };
+#else
+struct omap2430_musb_peripheral {
struct musb *periph;
+};
+#if CONFIG_IS_ENABLED(OF_CONTROL) +static int omap2430_musb_peripheral_ofdata_to_platdata(struct udevice *dev) +{
struct ti_musb_platdata *platdata = dev_get_platdata(dev);
const void *fdt = gd->fdt_blob;
int node = dev_of_offset(dev);
int ret;
ret = omap2430_musb_ofdata_to_platdata(dev);
if (ret) {
pr_err("platdata dt parse error\n");
return ret;
}
platdata->plat.mode = MUSB_PERIPHERAL;
return 0;
+} +#endif
+int dm_usb_gadget_handle_interrupts(struct udevice *dev) +{
struct omap2430_musb_peripheral *priv = dev_get_priv(dev);
priv->periph->isr(0, priv->periph);
return 0;
+}
+static int omap2430_musb_peripheral_probe(struct udevice *dev) +{
struct omap2430_musb_peripheral *priv = dev_get_priv(dev);
struct omap2430_musb_platdata *platdata = dev_get_platdata(dev);
struct omap_musb_board_data *otg_board_data;
int ret;
otg_board_data = &platdata->otg_board_data;
priv->periph = musb_init_controller(&platdata->plat,
(struct device *)otg_board_data,
platdata->base);
if (!priv->periph)
return -EIO;
/* ti_musb_set_phy_power(dev, 1); */
musb_gadget_setup(priv->periph);
return usb_add_gadget_udc((struct device *)dev, &priv->periph->g);
+}
+static int omap2430_musb_peripheral_remove(struct udevice *dev) +{
struct omap2430_musb_peripheral *priv = dev_get_priv(dev);
usb_del_gadget_udc(&priv->periph->g);
/* ti_musb_set_phy_power(dev, 0); */
return 0;
+}
+U_BOOT_DRIVER(omap2430_musb_peripheral) = {
.name = "ti-musb-peripheral",
.id = UCLASS_USB_GADGET_GENERIC,
.of_match = omap2430_musb_ids,
+#if CONFIG_IS_ENABLED(OF_CONTROL)
.ofdata_to_platdata = omap2430_musb_peripheral_ofdata_to_platdata,
+#endif
.probe = omap2430_musb_peripheral_probe,
.remove = omap2430_musb_peripheral_remove,
.ops = &musb_usb_ops,
.platdata_auto_alloc_size = sizeof(struct omap2430_musb_platdata),
.priv_auto_alloc_size = sizeof(struct omap2430_musb_peripheral),
.flags = DM_FLAG_PRE_RELOC,
+}; #endif
#endif /* CONFIG_IS_ENABLED(DM_USB) */

On 19/12/2018 13:59, Adam Ford wrote:
On Wed, Dec 19, 2018 at 4:59 AM Jean-Jacques Hiblot jjhiblot@ti.com wrote:
On 17/12/2018 21:34, Adam Ford wrote:
Borrowing from the updates to ti-musb.c, this glue layer checks to see if the MUSB controller is gadget or host. Going under the assumpution there is only one MUSB controller, this only builds either the host probe or the gadget probe. OTG would be preferred, but it doesn't appear to be working yet.
You can support both host and periph mode at the same time:
Create a new driver (a MISC UCLASS for ex) compatible with ti,omap3-musb.
Provide a bind function. In this function check the value of dr_mode and bind the appropriate child driver (host or peripheral).
This is how it is done in ti-musb.c.
I tried that first. Anytime I tried to use the MISC_UCLASS, I would
You need to enable CONFIG_MISC in that case. That is probably the error
get the err -96 like others are reporting. If you have any other suggestions on how to fix the -96 issue, I'm willing to try them. Since we didn't have OTG working before, and it was either host or gadget, I felt this was at least one step forward by making it DM_USB compliant.
adam
JJ
Signed-off-by: Adam Ford aford173@gmail.com
diff --git a/drivers/usb/musb-new/omap2430.c b/drivers/usb/musb-new/omap2430.c index b6e1320538..780d21c693 100644 --- a/drivers/usb/musb-new/omap2430.c +++ b/drivers/usb/musb-new/omap2430.c @@ -203,7 +203,7 @@ static int omap2430_musb_ofdata_to_platdata(struct udevice *dev) return 0; }
-#ifdef CONFIG_USB_MUSB_HOST +#ifndef CONFIG_USB_MUSB_GADGET static int omap2430_musb_probe(struct udevice *dev) { struct musb_host_data *host = dev_get_priv(dev); @@ -241,7 +241,7 @@ static int omap2430_musb_remove(struct udevice *dev) #if CONFIG_IS_ENABLED(OF_CONTROL) static int omap2430_musb_host_ofdata_to_platdata(struct udevice *dev) {
struct ti_musb_platdata *platdata = dev_get_platdata(dev);
struct omap2430_musb_platdata *platdata = dev_get_platdata(dev); const void *fdt = gd->fdt_blob; int node = dev_of_offset(dev); int ret;
@@ -272,6 +272,83 @@ U_BOOT_DRIVER(omap2430_musb) = { .priv_auto_alloc_size = sizeof(struct musb_host_data), };
+#else
+struct omap2430_musb_peripheral {
struct musb *periph;
+};
+#if CONFIG_IS_ENABLED(OF_CONTROL) +static int omap2430_musb_peripheral_ofdata_to_platdata(struct udevice *dev) +{
struct ti_musb_platdata *platdata = dev_get_platdata(dev);
const void *fdt = gd->fdt_blob;
int node = dev_of_offset(dev);
int ret;
ret = omap2430_musb_ofdata_to_platdata(dev);
if (ret) {
pr_err("platdata dt parse error\n");
return ret;
}
platdata->plat.mode = MUSB_PERIPHERAL;
return 0;
+} +#endif
+int dm_usb_gadget_handle_interrupts(struct udevice *dev) +{
struct omap2430_musb_peripheral *priv = dev_get_priv(dev);
priv->periph->isr(0, priv->periph);
return 0;
+}
+static int omap2430_musb_peripheral_probe(struct udevice *dev) +{
struct omap2430_musb_peripheral *priv = dev_get_priv(dev);
struct omap2430_musb_platdata *platdata = dev_get_platdata(dev);
struct omap_musb_board_data *otg_board_data;
int ret;
otg_board_data = &platdata->otg_board_data;
priv->periph = musb_init_controller(&platdata->plat,
(struct device *)otg_board_data,
platdata->base);
if (!priv->periph)
return -EIO;
/* ti_musb_set_phy_power(dev, 1); */
musb_gadget_setup(priv->periph);
return usb_add_gadget_udc((struct device *)dev, &priv->periph->g);
+}
+static int omap2430_musb_peripheral_remove(struct udevice *dev) +{
struct omap2430_musb_peripheral *priv = dev_get_priv(dev);
usb_del_gadget_udc(&priv->periph->g);
/* ti_musb_set_phy_power(dev, 0); */
return 0;
+}
+U_BOOT_DRIVER(omap2430_musb_peripheral) = {
.name = "ti-musb-peripheral",
.id = UCLASS_USB_GADGET_GENERIC,
.of_match = omap2430_musb_ids,
+#if CONFIG_IS_ENABLED(OF_CONTROL)
.ofdata_to_platdata = omap2430_musb_peripheral_ofdata_to_platdata,
+#endif
.probe = omap2430_musb_peripheral_probe,
.remove = omap2430_musb_peripheral_remove,
.ops = &musb_usb_ops,
.platdata_auto_alloc_size = sizeof(struct omap2430_musb_platdata),
.priv_auto_alloc_size = sizeof(struct omap2430_musb_peripheral),
.flags = DM_FLAG_PRE_RELOC,
+}; #endif
#endif /* CONFIG_IS_ENABLED(DM_USB) */

On Mon, Dec 17, 2018 at 2:35 PM Adam Ford aford173@gmail.com wrote:
The omap2430 driver only currently supports host only. In preparation for supporting peripheral mode, this patch makes the driver support only the host by creating a ofdata_to_platdata function host/peripheral agnostic with a host helper version.
Signed-off-by: Adam Ford aford173@gmail.com
With the merge window and the pending DM_USB requirements, is there anything I need to do differently to this series, or it is ok as-is?
adam
diff --git a/drivers/usb/musb-new/omap2430.c b/drivers/usb/musb-new/omap2430.c index 32743aa72c..b6e1320538 100644 --- a/drivers/usb/musb-new/omap2430.c +++ b/drivers/usb/musb-new/omap2430.c @@ -137,6 +137,12 @@ const struct musb_platform_ops omap2430_ops = {
#if CONFIG_IS_ENABLED(DM_USB)
+static const struct udevice_id omap2430_musb_ids[] = {
{ .compatible = "ti,omap3-musb" },
{ .compatible = "ti,omap4-musb" },
{ }
+};
struct omap2430_musb_platdata { void *base; void *ctrl_mod_base; @@ -190,20 +196,6 @@ static int omap2430_musb_ofdata_to_platdata(struct udevice *dev) return -ENOENT; }
-#if 0 /* In a perfect world, mode would be set to OTG, mode 3 from DT */
platdata->plat.mode = fdtdec_get_int(fdt, node,
"mode", -1);
if (platdata->plat.mode < 0) {
pr_err("MUSB mode DT entry missing\n");
return -ENOENT;
}
-#else /* MUSB_OTG, it doesn't work */ -#ifdef CONFIG_USB_MUSB_HOST /* Host seems to be the only option that works */
platdata->plat.mode = MUSB_HOST;
-#else /* For that matter, MUSB_PERIPHERAL doesn't either */
platdata->plat.mode = MUSB_PERIPHERAL;
-#endif -#endif platdata->otg_board_data.dev = dev; platdata->plat.config = &platdata->musb_config; platdata->plat.platform_ops = &omap2430_ops; @@ -211,11 +203,10 @@ static int omap2430_musb_ofdata_to_platdata(struct udevice *dev) return 0; }
+#ifdef CONFIG_USB_MUSB_HOST static int omap2430_musb_probe(struct udevice *dev) { -#ifdef CONFIG_USB_MUSB_HOST struct musb_host_data *host = dev_get_priv(dev); -#endif struct omap2430_musb_platdata *platdata = dev_get_platdata(dev); struct usb_bus_priv *priv = dev_get_uclass_priv(dev); struct omap_musb_board_data *otg_board_data; @@ -226,7 +217,6 @@ static int omap2430_musb_probe(struct udevice *dev)
otg_board_data = &platdata->otg_board_data;
-#ifdef CONFIG_USB_MUSB_HOST host->host = musb_init_controller(&platdata->plat, (struct device *)otg_board_data, platdata->base); @@ -235,11 +225,7 @@ static int omap2430_musb_probe(struct udevice *dev) }
ret = musb_lowlevel_init(host);
-#else
ret = musb_register(&platdata->plat,
(struct device *)otg_board_data,
platdata->base);
-#endif
return ret;
}
@@ -252,28 +238,40 @@ static int omap2430_musb_remove(struct udevice *dev) return 0; }
-static const struct udevice_id omap2430_musb_ids[] = {
{ .compatible = "ti,omap3-musb" },
{ .compatible = "ti,omap4-musb" },
{ }
-}; +#if CONFIG_IS_ENABLED(OF_CONTROL) +static int omap2430_musb_host_ofdata_to_platdata(struct udevice *dev) +{
struct ti_musb_platdata *platdata = dev_get_platdata(dev);
const void *fdt = gd->fdt_blob;
int node = dev_of_offset(dev);
int ret;
ret = omap2430_musb_ofdata_to_platdata(dev);
if (ret) {
pr_err("platdata dt parse error\n");
return ret;
}
platdata->plat.mode = MUSB_HOST;
return 0;
+} +#endif
U_BOOT_DRIVER(omap2430_musb) = { .name = "omap2430-musb", -#ifdef CONFIG_USB_MUSB_HOST .id = UCLASS_USB, -#else
.id = UCLASS_USB_GADGET_GENERIC,
-#endif .of_match = omap2430_musb_ids,
.ofdata_to_platdata = omap2430_musb_ofdata_to_platdata,
+#if CONFIG_IS_ENABLED(OF_CONTROL)
.ofdata_to_platdata = omap2430_musb_host_ofdata_to_platdata,
+#endif .probe = omap2430_musb_probe, .remove = omap2430_musb_remove, -#ifdef CONFIG_USB_MUSB_HOST .ops = &musb_usb_ops, -#endif .platdata_auto_alloc_size = sizeof(struct omap2430_musb_platdata), .priv_auto_alloc_size = sizeof(struct musb_host_data), };
+#endif
#endif /* CONFIG_IS_ENABLED(DM_USB) */
2.17.1
participants (2)
-
Adam Ford
-
Jean-Jacques Hiblot