Skip to content

Commit

Permalink
arm: omap: usb: usbhs core device initialization
Browse files Browse the repository at this point in the history
A new usbhs platform device is defined;
this device will be the parent device of ehci and
ohci platform devices. the usbhs_init function
is defined which does the usbhs device initialization
and I/O mux of ehci and ohci.

Signed-off-by: Keshava Munegowda <keshava_mgowda@ti.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
  • Loading branch information
Keshava Munegowda authored and Felipe Balbi committed Mar 1, 2011
1 parent 17cdd29 commit 2236396
Show file tree
Hide file tree
Showing 2 changed files with 183 additions and 14 deletions.
195 changes: 181 additions & 14 deletions arch/arm/mach-omap2/usb-host.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
*
* Copyright (C) 2007-2011 Texas Instruments
* Author: Vikram Pandita <vikram.pandita@ti.com>
* Author: Keshava Munegowda <keshava_mgowda@ti.com>
*
* Generalization by:
* Felipe Balbi <balbi@ti.com>
Expand All @@ -19,7 +20,7 @@
#include <linux/errno.h>
#include <linux/delay.h>
#include <linux/platform_device.h>
#include <linux/clk.h>
#include <linux/slab.h>
#include <linux/dma-mapping.h>

#include <asm/io.h>
Expand All @@ -30,7 +31,7 @@

#include "mux.h"

#if defined(CONFIG_USB_EHCI_HCD) || defined(CONFIG_USB_EHCI_HCD_MODULE)
#ifdef CONFIG_MFD_OMAP_USB_HOST

static struct resource ehci_resources[] = {
{
Expand Down Expand Up @@ -361,17 +362,6 @@ void __init usb_ehci_init(const struct usbhs_omap_board_data *pdata)
}
}

#else

void __init usb_ehci_init(const struct usbhs_omap_board_data *pdata)

{
}

#endif /* CONFIG_USB_EHCI_HCD */

#if defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE)

static struct resource ohci_resources[] = {
{
.name = "ohci",
Expand Down Expand Up @@ -508,6 +498,77 @@ static void setup_ohci_io_mux(const enum usbhs_omap_port_mode *port_mode)
}
}

static void setup_4430ohci_io_mux(const enum usbhs_omap_port_mode *port_mode)
{
switch (port_mode[0]) {
case OMAP_OHCI_PORT_MODE_PHY_6PIN_DATSE0:
case OMAP_OHCI_PORT_MODE_PHY_6PIN_DPDM:
case OMAP_OHCI_PORT_MODE_TLL_6PIN_DATSE0:
case OMAP_OHCI_PORT_MODE_TLL_6PIN_DPDM:
omap_mux_init_signal("usbb1_mm_rxdp",
OMAP_PIN_INPUT_PULLDOWN);
omap_mux_init_signal("usbb1_mm_rxdm",
OMAP_PIN_INPUT_PULLDOWN);

case OMAP_OHCI_PORT_MODE_PHY_4PIN_DPDM:
case OMAP_OHCI_PORT_MODE_TLL_4PIN_DPDM:
omap_mux_init_signal("usbb1_mm_rxrcv",
OMAP_PIN_INPUT_PULLDOWN);

case OMAP_OHCI_PORT_MODE_PHY_3PIN_DATSE0:
case OMAP_OHCI_PORT_MODE_TLL_3PIN_DATSE0:
omap_mux_init_signal("usbb1_mm_txen",
OMAP_PIN_INPUT_PULLDOWN);


case OMAP_OHCI_PORT_MODE_TLL_2PIN_DATSE0:
case OMAP_OHCI_PORT_MODE_TLL_2PIN_DPDM:
omap_mux_init_signal("usbb1_mm_txdat",
OMAP_PIN_INPUT_PULLDOWN);
omap_mux_init_signal("usbb1_mm_txse0",
OMAP_PIN_INPUT_PULLDOWN);
break;

case OMAP_USBHS_PORT_MODE_UNUSED:
default:
break;
}

switch (port_mode[1]) {
case OMAP_OHCI_PORT_MODE_PHY_6PIN_DATSE0:
case OMAP_OHCI_PORT_MODE_PHY_6PIN_DPDM:
case OMAP_OHCI_PORT_MODE_TLL_6PIN_DATSE0:
case OMAP_OHCI_PORT_MODE_TLL_6PIN_DPDM:
omap_mux_init_signal("usbb2_mm_rxdp",
OMAP_PIN_INPUT_PULLDOWN);
omap_mux_init_signal("usbb2_mm_rxdm",
OMAP_PIN_INPUT_PULLDOWN);

case OMAP_OHCI_PORT_MODE_PHY_4PIN_DPDM:
case OMAP_OHCI_PORT_MODE_TLL_4PIN_DPDM:
omap_mux_init_signal("usbb2_mm_rxrcv",
OMAP_PIN_INPUT_PULLDOWN);

case OMAP_OHCI_PORT_MODE_PHY_3PIN_DATSE0:
case OMAP_OHCI_PORT_MODE_TLL_3PIN_DATSE0:
omap_mux_init_signal("usbb2_mm_txen",
OMAP_PIN_INPUT_PULLDOWN);


case OMAP_OHCI_PORT_MODE_TLL_2PIN_DATSE0:
case OMAP_OHCI_PORT_MODE_TLL_2PIN_DPDM:
omap_mux_init_signal("usbb2_mm_txdat",
OMAP_PIN_INPUT_PULLDOWN);
omap_mux_init_signal("usbb2_mm_txse0",
OMAP_PIN_INPUT_PULLDOWN);
break;

case OMAP_USBHS_PORT_MODE_UNUSED:
default:
break;
}
}

void __init usb_ohci_init(const struct usbhs_omap_board_data *pdata)
{
platform_device_add_data(&ohci_device, pdata, sizeof(*pdata));
Expand All @@ -522,10 +583,116 @@ void __init usb_ohci_init(const struct usbhs_omap_board_data *pdata)
}
}

#define OMAP_USBHS_DEVICE "usbhs-omap"

static struct resource usbhs_resources[] = {
{
.name = "uhh",
.flags = IORESOURCE_MEM,
},
{
.name = "tll",
.flags = IORESOURCE_MEM,
},
{
.name = "ehci",
.flags = IORESOURCE_MEM,
},
{
.name = "ehci-irq",
.flags = IORESOURCE_IRQ,
},
{
.name = "ohci",
.flags = IORESOURCE_MEM,
},
{
.name = "ohci-irq",
.flags = IORESOURCE_IRQ,
}
};

static struct platform_device usbhs_device = {
.name = OMAP_USBHS_DEVICE,
.id = 0,
.num_resources = ARRAY_SIZE(usbhs_resources),
.resource = usbhs_resources,
};

static struct usbhs_omap_platform_data usbhs_data;
static struct ehci_hcd_omap_platform_data ehci_data;
static struct ohci_hcd_omap_platform_data ohci_data;

void __init usbhs_init(const struct usbhs_omap_board_data *pdata)
{
int i;

for (i = 0; i < OMAP3_HS_USB_PORTS; i++) {
usbhs_data.port_mode[i] = pdata->port_mode[i];
ohci_data.port_mode[i] = pdata->port_mode[i];
ehci_data.port_mode[i] = pdata->port_mode[i];
ehci_data.reset_gpio_port[i] = pdata->reset_gpio_port[i];
ehci_data.regulator[i] = pdata->regulator[i];
}
ehci_data.phy_reset = pdata->phy_reset;
ohci_data.es2_compatibility = pdata->es2_compatibility;
usbhs_data.ehci_data = &ehci_data;
usbhs_data.ohci_data = &ohci_data;

if (cpu_is_omap34xx()) {
usbhs_resources[0].start = OMAP34XX_UHH_CONFIG_BASE;
usbhs_resources[0].end = OMAP34XX_UHH_CONFIG_BASE + SZ_1K - 1;
usbhs_resources[1].start = OMAP34XX_USBTLL_BASE;
usbhs_resources[1].end = OMAP34XX_USBTLL_BASE + SZ_4K - 1;
usbhs_resources[2].start = OMAP34XX_EHCI_BASE;
usbhs_resources[2].end = OMAP34XX_EHCI_BASE + SZ_1K - 1;
usbhs_resources[3].start = INT_34XX_EHCI_IRQ;
usbhs_resources[4].start = OMAP34XX_OHCI_BASE;
usbhs_resources[4].end = OMAP34XX_OHCI_BASE + SZ_1K - 1;
usbhs_resources[5].start = INT_34XX_OHCI_IRQ;
setup_ehci_io_mux(pdata->port_mode);
setup_ohci_io_mux(pdata->port_mode);
} else if (cpu_is_omap44xx()) {
usbhs_resources[0].start = OMAP44XX_UHH_CONFIG_BASE;
usbhs_resources[0].end = OMAP44XX_UHH_CONFIG_BASE + SZ_1K - 1;
usbhs_resources[1].start = OMAP44XX_USBTLL_BASE;
usbhs_resources[1].end = OMAP44XX_USBTLL_BASE + SZ_4K - 1;
usbhs_resources[2].start = OMAP44XX_HSUSB_EHCI_BASE;
usbhs_resources[2].end = OMAP44XX_HSUSB_EHCI_BASE + SZ_1K - 1;
usbhs_resources[3].start = OMAP44XX_IRQ_EHCI;
usbhs_resources[4].start = OMAP44XX_HSUSB_OHCI_BASE;
usbhs_resources[4].end = OMAP44XX_HSUSB_OHCI_BASE + SZ_1K - 1;
usbhs_resources[5].start = OMAP44XX_IRQ_OHCI;
setup_4430ehci_io_mux(pdata->port_mode);
setup_4430ohci_io_mux(pdata->port_mode);
}

if (platform_device_add_data(&usbhs_device,
&usbhs_data, sizeof(usbhs_data)) < 0) {
printk(KERN_ERR "USBHS platform_device_add_data failed\n");
goto init_end;
}

if (platform_device_register(&usbhs_device) < 0)
printk(KERN_ERR "USBHS platform_device_register failed\n");

init_end:
return;
}

#else

void __init usbhs_init(const struct usbhs_omap_board_data *pdata)
{
}

void __init usb_ohci_init(const struct usbhs_omap_board_data *pdata)
{
}

#endif /* CONFIG_USB_OHCI_HCD */
void __init usb_ehci_init(const struct usbhs_omap_board_data *pdata)
{
}
#endif


2 changes: 2 additions & 0 deletions arch/arm/plat-omap/include/plat/usb.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ extern void usb_ehci_init(const struct usbhs_omap_board_data *pdata);

extern void usb_ohci_init(const struct usbhs_omap_board_data *pdata);

extern void usbhs_init(const struct usbhs_omap_board_data *pdata);

extern int omap_usbhs_enable(struct device *dev);
extern void omap_usbhs_disable(struct device *dev);

Expand Down

0 comments on commit 2236396

Please sign in to comment.