All of lore.kernel.org
 help / color / mirror / Atom feed
From: daniel@caiaq.de (Daniel Mack)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH] mx27: mxt_td60: Add USB Support
Date: Fri, 4 Dec 2009 19:05:54 +0100	[thread overview]
Message-ID: <20091204180554.GX14091@buzzloop.caiaq.de> (raw)
In-Reply-To: <1259948719-10008-1-git-send-email-acassis@gmail.com>

On Fri, Dec 04, 2009 at 03:45:19PM -0200, Alan Carvalho de Assis wrote:
> This patch add USB support on i-MXT TD60 to Host1 and Host2 ports.
> 
> Signed-off-by: Alan Carvalho de Assis <acassis@gmail.com>
> ---
>  arch/arm/mach-mx2/Kconfig                   |    1 +
>  arch/arm/mach-mx2/mxt_td60.c                |  106 +++++++++++++++++++++++++++
>  arch/arm/plat-mxc/include/mach/iomux-mx27.h |   14 ++++

Changes to iomux-mx27.h should go in an extra patch, I think.

[...]

> +static int isp1105_init(struct otg_transceiver *otg)
> +{
> +	mxc_gpio_mode(GPIO_PORTB | 23 | GPIO_GPIO | GPIO_OUT);
> +	gpio_set_value(GPIO_PORTB + 23, 1);
> +	mxc_gpio_mode(GPIO_PORTC | 31 | GPIO_GPIO | GPIO_OUT);
> +	gpio_set_value(GPIO_PORTC + 31, 1);
> +	return 0;
> +}

gpio_request() is needed here.

> +static int isp1105_set_vbus(struct otg_transceiver *otg, bool on)
> +{
> +	if (on)
> +		gpio_set_value(GPIO_PORTB + 27, 0);
> +	else
> +		gpio_set_value(GPIO_PORTB + 27, 1);
> +
> +	return 0;
> +}
> +
> +static struct mxc_usbh_platform_data usbh1_pdata = {
> +	.portsc	= MXC_EHCI_MODE_UTMI | MXC_EHCI_SERIAL,
> +	.flags	= MXC_EHCI_POWER_PINS_ENABLED | MXC_EHCI_INTERFACE_SINGLE_UNI,
> +};
> +
> +static int __init usbh1_init(void)
> +{
> +	struct otg_transceiver *otg;
> +
> +	otg = kzalloc(sizeof(*otg), GFP_KERNEL);
> +	if (!otg)
> +		return -ENOMEM;
> +
> +	otg->label	= "ISP1105";
> +	otg->init	= isp1105_init;
> +	otg->set_vbus	= isp1105_set_vbus;
> +
> +	usbh1_pdata.otg = otg;
> +
> +	return mxc_register_device(&mxc_usbh1, &usbh1_pdata);
> +}

Ideally, you would make that a more generic driver of its own, which lives in
drivers/usb/otg/ and is named something like 'transceiver-gpio'. You would
instanciate it by passing a platform data struct to set the gpios you want it
to use. This might sound overdone, but it would make your code reusable.

The calls to mxc_gpio_mode() would remain in your platform code, of course.

Daniel

  reply	other threads:[~2009-12-04 18:05 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-12-04 17:45 [PATCH] mx27: mxt_td60: Add USB Support Alan Carvalho de Assis
2009-12-04 18:05 ` Daniel Mack [this message]
2009-12-07 11:39   ` Alan Carvalho de Assis
2009-12-09  3:00     ` Daniel Mack

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=20091204180554.GX14091@buzzloop.caiaq.de \
    --to=daniel@caiaq.de \
    --cc=linux-arm-kernel@lists.infradead.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.