[PATCH] mx27: mxt_td60: Add USB Support
Daniel Mack
daniel at caiaq.de
Fri Dec 4 13:05:54 EST 2009
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 at 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
More information about the linux-arm-kernel
mailing list