public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Mugunthan V N <mugunthanvnm@ti.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 03/17] drivers: usb: musb: add ti musb misc driver for wrapper
Date: Mon, 29 Feb 2016 14:16:18 +0530	[thread overview]
Message-ID: <56D4055A.60405@ti.com> (raw)
In-Reply-To: <1456717460-3132-4-git-send-email-mugunthanvnm@ti.com>

On Monday 29 February 2016 09:14 AM, Mugunthan V N wrote:
> Add a misc driver for MUSB wrapper, so that based on dr_mode the
> USB devices can bind to USB host or USB device drivers.
> 
> Signed-off-by: Mugunthan V N <mugunthanvnm@ti.com>
> ---
>  drivers/usb/musb-new/Kconfig   |  9 +++++
>  drivers/usb/musb-new/Makefile  |  1 +
>  drivers/usb/musb-new/ti-musb.c | 89 ++++++++++++++++++++++++++++++++++++++++++
>  3 files changed, 99 insertions(+)
>  create mode 100644 drivers/usb/musb-new/ti-musb.c
> 
> diff --git a/drivers/usb/musb-new/Kconfig b/drivers/usb/musb-new/Kconfig
> index 6a6cb93..2bcc646 100644
> --- a/drivers/usb/musb-new/Kconfig
> +++ b/drivers/usb/musb-new/Kconfig
> @@ -13,6 +13,15 @@ config USB_MUSB_GADGET
>  	help
>  	  Enables the MUSB USB dual-role controller in gadget mode.
>  
> +config USB_MUSB_TI
> +	bool "Enable TI OTG USB controller"
> +	depends on DM_USB
> +	default y
> +	help
> +	  Say y here to enable support for the TI OTG USB controller
> +	  used on TI SoCs. fadsf fa fad af adf adf asf adfa fad fd af
> +	   asdf asdf fadsf asf s

Oops!, This was done to fix checkpatch warning temporarily but forgot to
fix it properly before submitting. Will fix in v2.

Regards
Mugunthan V N

> +
>  if USB_MUSB_HOST || USB_MUSB_GADGET
>  
>  config USB_MUSB_SUNXI
> diff --git a/drivers/usb/musb-new/Makefile b/drivers/usb/musb-new/Makefile
> index 072d516..d137044 100644
> --- a/drivers/usb/musb-new/Makefile
> +++ b/drivers/usb/musb-new/Makefile
> @@ -11,6 +11,7 @@ obj-$(CONFIG_USB_MUSB_DSPS) += musb_dsps.o
>  obj-$(CONFIG_USB_MUSB_AM35X) += am35x.o
>  obj-$(CONFIG_USB_MUSB_OMAP2PLUS) += omap2430.o
>  obj-$(CONFIG_USB_MUSB_SUNXI) += sunxi.o
> +obj-$(CONFIG_USB_MUSB_TI) += ti-musb.o
>  
>  ccflags-y := $(call cc-option,-Wno-unused-variable) \
>  		$(call cc-option,-Wno-unused-but-set-variable) \
> diff --git a/drivers/usb/musb-new/ti-musb.c b/drivers/usb/musb-new/ti-musb.c
> new file mode 100644
> index 0000000..c1a4952
> --- /dev/null
> +++ b/drivers/usb/musb-new/ti-musb.c
> @@ -0,0 +1,89 @@
> +/*
> + * MISC driver for TI MUSB Glue.
> + *
> + * (C) Copyright 2012-2016
> + *     Texas Instruments Incorporated, <www.ti.com>
> + *
> + * SPDX-License-Identifier:     GPL-2.0+
> + */
> +#include <common.h>
> +#include <command.h>
> +#include <console.h>
> +#include <dm.h>
> +#include <linux/usb/otg.h>
> +#include <dm/device-internal.h>
> +#include <dm/lists.h>
> +
> +DECLARE_GLOBAL_DATA_PTR;
> +
> +#ifdef CONFIG_DM_USB
> +
> +static const char *const usb_dr_modes[] = {
> +	[USB_DR_MODE_UNKNOWN]		= "",
> +	[USB_DR_MODE_HOST]		= "host",
> +	[USB_DR_MODE_PERIPHERAL]	= "peripheral",
> +	[USB_DR_MODE_OTG]		= "otg",
> +};
> +
> +enum usb_dr_mode usb_get_dr_mode(const char *dr_mode)
> +{
> +	int i;
> +
> +	for (i = 0; i < ARRAY_SIZE(usb_dr_modes); i++)
> +		if (!strcmp(dr_mode, usb_dr_modes[i]))
> +			return i;
> +
> +	return USB_DR_MODE_UNKNOWN;
> +}
> +
> +static int ti_musb_wrapper_bind(struct udevice *parent)
> +{
> +	const void *fdt = gd->fdt_blob;
> +	int node;
> +	int ret;
> +
> +	for (node = fdt_first_subnode(fdt, parent->of_offset); node > 0;
> +	     node = fdt_next_subnode(fdt, node)) {
> +		struct udevice *dev;
> +		const char *name = fdt_get_name(fdt, node, NULL);
> +		const char *dr_mode_str;
> +		enum usb_dr_mode dr_mode;
> +		struct driver *drv;
> +
> +		if (strncmp(name, "usb@", 4))
> +			continue;
> +
> +		dr_mode_str = fdt_getprop(fdt, node, "dr_mode", NULL);
> +		if (!dr_mode_str) {
> +			error("usb dr_mode not found\n");
> +			return -ENOENT;
> +		}
> +
> +		dr_mode = usb_get_dr_mode(dr_mode_str);
> +		switch (dr_mode) {
> +		case USB_DR_MODE_PERIPHERAL:
> +			/* Bind MUSB device */
> +			break;
> +		case USB_DR_MODE_HOST:
> +			/* Bind MUSB host */
> +			break;
> +		default:
> +			break;
> +		};
> +	}
> +	return 0;
> +}
> +
> +static const struct udevice_id ti_musb_ids[] = {
> +	{ .compatible = "ti,am33xx-usb" },
> +	{ }
> +};
> +
> +U_BOOT_DRIVER(ti_musb_wrapper) = {
> +	.name	= "ti-musb-wrapper",
> +	.id	= UCLASS_MISC,
> +	.of_match = ti_musb_ids,
> +	.bind = ti_musb_wrapper_bind,
> +};
> +
> +#endif /* CONFIG_DM_USB */
> 

  reply	other threads:[~2016-02-29  8:46 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-29  3:44 [U-Boot] [PATCH 00/17] driver model bring-up of musb on AM335x GP and BBB and usb_ether DM conversion Mugunthan V N
2016-02-29  3:44 ` [U-Boot] [PATCH 01/17] configs: am335x: usb: do not define CONFIG_DM_USB for spl Mugunthan V N
2016-03-01  1:57   ` Tom Rini
2016-02-29  3:44 ` [U-Boot] [PATCH 02/17] am33xx: board: do not register usb devices when CONFIG_DM_USB is defined Mugunthan V N
2016-03-01  1:57   ` Tom Rini
2016-02-29  3:44 ` [U-Boot] [PATCH 03/17] drivers: usb: musb: add ti musb misc driver for wrapper Mugunthan V N
2016-02-29  8:46   ` Mugunthan V N [this message]
2016-02-29 12:02   ` Marek Vasut
2016-02-29 13:21     ` Mugunthan V N
2016-02-29 14:42       ` Tom Rini
2016-02-29 14:42         ` Marek Vasut
2016-02-29  3:44 ` [U-Boot] [PATCH 04/17] am33xx: board: probe misc drivers to register musb devices Mugunthan V N
2016-03-01  1:58   ` Tom Rini
2016-02-29  3:44 ` [U-Boot] [PATCH 05/17] drivers: usb: musb: adopt musb backend driver to driver model Mugunthan V N
2016-02-29 12:04   ` Marek Vasut
2016-02-29 13:26     ` Mugunthan V N
2016-02-29 13:34       ` Marek Vasut
2016-02-29 14:43         ` Tom Rini
2016-02-29  3:44 ` [U-Boot] [PATCH 06/17] drivers: usb: musb: add ti musb host driver with driver model support Mugunthan V N
2016-02-29  3:44 ` [U-Boot] [PATCH 07/17] drivers: usb: musb: add ti musb peripheral " Mugunthan V N
2016-02-29  3:44 ` [U-Boot] [PATCH 08/17] drivers: usb: gadget: ether: adopt to usb driver model Mugunthan V N
2016-02-29  3:44 ` [U-Boot] [PATCH 09/17] drivers: usb: gadget: ether: access network_started using local variable Mugunthan V N
2016-02-29  3:44 ` [U-Boot] [PATCH 10/17] drivers: usb: gadget: ether: consolidate global devices to single struct Mugunthan V N
2016-02-29  3:44 ` [U-Boot] [PATCH 11/17] drivers: usb: gadget: ether: use net device priv to pass usb ether priv Mugunthan V N
2016-02-29  3:44 ` [U-Boot] [PATCH 12/17] drivers: usb: gadget: ether: prepare driver for driver model migration Mugunthan V N
2016-02-29  3:44 ` [U-Boot] [PATCH 13/17] drivers: usb: gadget: ether/rndis: convert driver to adopt device driver model Mugunthan V N
2016-02-29  3:44 ` [U-Boot] [PATCH 14/17] am33xx: board: init usb ether gadget for rndis support Mugunthan V N
2016-03-01  1:58   ` Tom Rini
2016-02-29  3:44 ` [U-Boot] [PATCH 15/17] am335x_evm: enable usb ether gadget as it supports DM_ETH Mugunthan V N
2016-03-01  1:58   ` Tom Rini
2016-02-29  3:44 ` [U-Boot] [PATCH 16/17] defconfig: am335x_boneblack: enable usb driver model Mugunthan V N
2016-03-01  1:58   ` Tom Rini
2016-02-29  3:44 ` [U-Boot] [PATCH 17/17] defconfig: am335x_gp_evm: " Mugunthan V N
2016-03-01  1:58   ` Tom Rini

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=56D4055A.60405@ti.com \
    --to=mugunthanvnm@ti.com \
    --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