From: Marek Vasut <marex@denx.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v2 07/11] drivers: usb: musb: add ti musb peripheral driver with driver model support
Date: Tue, 10 May 2016 14:39:35 +0200 [thread overview]
Message-ID: <5731D687.40709@denx.de> (raw)
In-Reply-To: <20160510114816.2899-8-mugunthanvnm@ti.com>
On 05/10/2016 01:48 PM, Mugunthan V N wrote:
> Add a TI MUSB peripheral driver with driver model support and the
> driver will be bound by the MUSB wrapper driver based on the
> dr_mode device tree entry.
>
> Signed-off-by: Mugunthan V N <mugunthanvnm@ti.com>
> ---
> drivers/usb/musb-new/musb_uboot.c | 2 +
> drivers/usb/musb-new/ti-musb.c | 113 ++++++++++++++++++++++++++++++++++++++
> 2 files changed, 115 insertions(+)
>
> diff --git a/drivers/usb/musb-new/musb_uboot.c b/drivers/usb/musb-new/musb_uboot.c
> index 6ce528c..b03b556 100644
> --- a/drivers/usb/musb-new/musb_uboot.c
> +++ b/drivers/usb/musb-new/musb_uboot.c
> @@ -373,6 +373,7 @@ struct dm_usb_ops musb_usb_ops = {
> #endif /* CONFIG_DM_USB */
> #endif /* CONFIG_USB_MUSB_HOST */
>
> +#ifndef CONFIG_DM_USB
> #ifdef CONFIG_USB_MUSB_GADGET
> static struct musb *gadget;
>
> @@ -453,3 +454,4 @@ int musb_register(struct musb_hdrc_platform_data *plat, void *bdata,
>
> return 0;
> }
> +#endif /* CONFIG_DM_USB */
> diff --git a/drivers/usb/musb-new/ti-musb.c b/drivers/usb/musb-new/ti-musb.c
> index 1c15aa2..11d10aa 100644
> --- a/drivers/usb/musb-new/ti-musb.c
> +++ b/drivers/usb/musb-new/ti-musb.c
> @@ -14,6 +14,7 @@
> #include <dm/device-internal.h>
> #include <dm/lists.h>
>
> +#include <watchdog.h>
> #include <asm/io.h>
> #include <asm/omap_musb.h>
> #include "musb_uboot.h"
> @@ -142,6 +143,110 @@ static int ti_musb_ofdata_to_platdata(struct udevice *dev)
> return 0;
> }
>
> +static struct musb *gadget;
> +
> +int usb_gadget_handle_interrupts(int index)
> +{
> + WATCHDOG_RESET();
> + if (!gadget || !gadget->isr)
> + return -EINVAL;
> +
> + return gadget->isr(0, gadget);
> +}
> +
> +int usb_gadget_register_driver(struct usb_gadget_driver *driver)
> +{
> + int ret;
> +
> + if (!driver || driver->speed < USB_SPEED_FULL || !driver->bind ||
> + !driver->setup) {
> + printf("bad parameter.\n");
Sentence usually starts with capital letter and ends with fullstop (not
the case below).
> + return -EINVAL;
> + }
> +
> + if (!gadget) {
> + printf("Controller uninitialized\n");
> + return -ENXIO;
> + }
> +
> + ret = musb_gadget_start(&gadget->g, driver);
> + if (ret < 0) {
> + printf("gadget_start failed with %d\n", ret);
> + return ret;
> + }
> +
> + ret = driver->bind(&gadget->g);
> + if (ret < 0) {
> + printf("bind failed with %d\n", ret);
Are all these prints really useful ?
> + return ret;
> + }
> +
> + return 0;
> +}
> +
> +int usb_gadget_unregister_driver(struct usb_gadget_driver *driver)
> +{
> + if (driver->disconnect)
> + driver->disconnect(&gadget->g);
> + if (driver->unbind)
> + driver->unbind(&gadget->g);
> + return 0;
> +}
> +
> +static int ti_musb_peripheral_usb_probe(struct udevice *dev)
> +{
> + struct ti_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;
> +
> + otg_board_data = &platdata->otg_board_data;
> +
> + gadget = musb_init_controller(&platdata->plat,
> + (struct device *)otg_board_data,
> + platdata->base);
> + if (!gadget) {
> + error("gadget init failed\n");
> + return -EIO;
> + }
> +
> + return 0;
> +}
> +
> +static int ti_musb_peripheral_remove(struct udevice *dev)
> +{
> + musb_stop(gadget);
> +
> + return 0;
> +}
> +
> +static int ti_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;
> + int ret;
> +
> + ret = ti_musb_ofdata_to_platdata(dev);
> + if (ret) {
> + error("platdata dt parse error\n");
> + return ret;
> + }
> +
> + platdata->plat.mode = MUSB_PERIPHERAL;
> +
> + return 0;
> +}
> +
> +U_BOOT_DRIVER(ti_musb_peripheral) = {
> + .name = "ti-musb-peripheral",
> + .id = UCLASS_USB_DEV_GENERIC,
> + .ofdata_to_platdata = ti_musb_peripheral_ofdata_to_platdata,
> + .probe = ti_musb_peripheral_usb_probe,
> + .remove = ti_musb_peripheral_remove,
> + .platdata_auto_alloc_size = sizeof(struct ti_musb_platdata),
> + .priv_auto_alloc_size = sizeof(struct musb),
> +};
> +
> static int ti_musb_host_probe(struct udevice *dev)
> {
> struct musb_host_data *host = dev_get_priv(dev);
> @@ -222,7 +327,15 @@ static int ti_musb_wrapper_bind(struct udevice *parent)
> dr_mode = usb_get_dr_mode(node);
> switch (dr_mode) {
> case USB_DR_MODE_PERIPHERAL:
> + case USB_DR_MODE_OTG:
> /* Bind MUSB device */
> + ret = device_bind_driver_to_node(parent,
> + "ti-musb-peripheral",
> + name, node, &dev);
> + if (ret) {
> + error("musb - not able to bind usb device node\n");
> + return ret;
> + }
> break;
> case USB_DR_MODE_HOST:
> /* Bind MUSB host */
>
--
Best regards,
Marek Vasut
next prev parent reply other threads:[~2016-05-10 12:39 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-05-10 11:48 [U-Boot] [PATCH v2 00/11] driver model bring-up of musb on AM335x GP and BBB Mugunthan V N
2016-05-10 11:48 ` [U-Boot] [PATCH v2 01/11] configs: am335x: usb: do not define CONFIG_DM_USB for spl Mugunthan V N
2016-05-10 11:48 ` [U-Boot] [PATCH v2 02/11] am33xx: board: do not register usb devices when CONFIG_DM_USB is defined Mugunthan V N
2016-05-10 11:48 ` [U-Boot] [PATCH v2 03/11] drivers: usb: musb: add ti musb misc driver for wrapper Mugunthan V N
2016-05-13 20:46 ` Tom Rini
2016-05-10 11:48 ` [U-Boot] [PATCH v2 04/11] am33xx: board: probe misc drivers to register musb devices Mugunthan V N
2016-05-10 11:48 ` [U-Boot] [PATCH v2 05/11] drivers: usb: musb: adopt musb backend driver to driver model Mugunthan V N
2016-05-13 20:46 ` Tom Rini
2016-05-10 11:48 ` [U-Boot] [PATCH v2 06/11] drivers: usb: musb: add ti musb host driver with driver model support Mugunthan V N
2016-05-13 20:46 ` Tom Rini
2016-05-10 11:48 ` [U-Boot] [PATCH v2 07/11] drivers: usb: musb: add ti musb peripheral " Mugunthan V N
2016-05-10 12:39 ` Marek Vasut [this message]
2016-05-12 5:49 ` Mugunthan V N
2016-05-19 4:00 ` Simon Glass
2016-05-10 11:48 ` [U-Boot] [PATCH v2 08/11] am33xx: board: init usb ether gadget for rndis support Mugunthan V N
2016-05-10 11:48 ` [U-Boot] [PATCH v2 09/11] am335x_evm: enable usb ether gadget as it supports DM_ETH Mugunthan V N
2016-05-10 11:48 ` [U-Boot] [PATCH v2 10/11] defconfig: am335x_boneblack: enable usb driver model Mugunthan V N
2016-05-10 11:48 ` [U-Boot] [PATCH v2 11/11] defconfig: am335x_gp_evm: " Mugunthan V N
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=5731D687.40709@denx.de \
--to=marex@denx.de \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox