summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRama Kandhala <rkandhala@nvidia.com>2010-03-01 21:38:06 +0530
committerGary King <gking@nvidia.com>2010-03-02 14:48:00 -0800
commit39134556d653e86a6f58c1ecac24e660a7cd1627 (patch)
treef23f5a9b4412eace47564e4118759a8a662b7c6d
parent67ef90803f261db3999f89402b29618c571d7326 (diff)
tegra usb: Clean up of host initialization
Usb host initialization code clean up for using native calls instead of Rm APIs. Change-Id: I98af3666f310cf44554f78bcdec47eb860d71f18 Reviewed-on: http://git-master/r/717 Reviewed-by: Pavan Kunapuli <pkunapuli@nvidia.com> Tested-by: Pavan Kunapuli <pkunapuli@nvidia.com> Reviewed-by: Gary King <gking@nvidia.com>
-rwxr-xr-xarch/arm/mach-tegra/init_common.c38
-rwxr-xr-xdrivers/usb/host/ehci-tegra.c53
2 files changed, 42 insertions, 49 deletions
diff --git a/arch/arm/mach-tegra/init_common.c b/arch/arm/mach-tegra/init_common.c
index cd6c2e50c175..76a106e79ee1 100755
--- a/arch/arm/mach-tegra/init_common.c
+++ b/arch/arm/mach-tegra/init_common.c
@@ -580,29 +580,16 @@ static inline int tegra_is_udc(NvU32 mod)
static void __init tegra_register_usb_host(void)
{
NvU32 port_count, i;
-
port_count = NvRmModuleGetNumInstances(s_hRmGlobal, NvRmModuleID_Usb2Otg);
for (i=0; i<port_count; i++) {
const NvOdmUsbProperty *p;
- struct platform_device *platdev = NULL;
+ struct resource *res;
struct tegra_hcd_platform_data pdata;
+ struct platform_device *platdev = NULL;
- NvU32 mod = NVRM_MODULE_ID(NvRmModuleID_Usb2Otg, i);
- NvRmPhysAddr cont_addr;
- NvU32 len;
- NvU16 irq;
-
- /* fixme: add ulpi here? */
p = NvOdmQueryGetUsbProperty(NvOdmIoModule_Usb, i);
- if (!p || !((p->UsbMode & NvOdmUsbModeType_Host) ||
- (p->UsbMode & NvOdmUsbModeType_OTG) ) ||
- (tegra_is_udc(mod) && !(p->UsbMode & NvOdmUsbModeType_OTG)))
- continue;
-
- irq = NvRmGetIrqForLogicalInterrupt(s_hRmGlobal, mod, 0);
- NvRmModuleGetBaseAddress(s_hRmGlobal, mod, &cont_addr, &len);
- if (irq==0xffff || !(~cont_addr) || !len)
+ if (!p || (p->UsbMode & NvOdmUsbModeType_Device))
continue;
platdev = platform_device_alloc("tegra-ehci", i);
@@ -611,9 +598,26 @@ static void __init tegra_register_usb_host(void)
goto fail;
}
+ res = kzalloc(sizeof(struct resource)*2, GFP_KERNEL);
+ if (!res) {
+ pr_err("unable to allocate resource for tegra-otg\n");
+ goto fail;
+ }
+
+ res[0].flags = IORESOURCE_MEM;
+ res[0].start = tegra_get_module_inst_base("usbotg", i);
+ res[0].end = res[0].start + tegra_get_module_inst_size("usbotg", i) - 1;
+ res[1].flags = IORESOURCE_IRQ;
+ res[1].start = res[1].end = tegra_get_module_inst_irq("usbotg", i, 0);
+
+ if (platform_device_add_resources(platdev, res, 2)) {
+ pr_err("unable to add resources to tegra-ehci device\n");
+ goto fail;
+ }
memset(&pdata, 0, sizeof(pdata));
pdata.instance = i;
+ pdata.pUsbProperty = p;
if (platform_device_add_data(platdev, &pdata, sizeof(pdata))) {
pr_err("unable to add data to tegra-ehci device\n");
@@ -626,7 +630,7 @@ static void __init tegra_register_usb_host(void)
}
}
fail:
- ;
+ ;
}
#endif
diff --git a/drivers/usb/host/ehci-tegra.c b/drivers/usb/host/ehci-tegra.c
index 38f595e43ce9..cc1e51581c8f 100755
--- a/drivers/usb/host/ehci-tegra.c
+++ b/drivers/usb/host/ehci-tegra.c
@@ -365,20 +365,16 @@ static const struct hc_driver tegra_ehci_hc_driver = {
.relinquish_port = ehci_relinquish_port,
.port_handed_over = ehci_port_handed_over,
};
-
static int tegra_ehci_probe(struct platform_device *pdev)
{
- int instance = pdev->id;
- NvRmPhysAddr addr;
- NvU32 size;
- struct tegra_hcd_platform_data *pdata;
- struct usb_hcd *hcd;
- int e = 0;
- int irq;
- unsigned int temp;
- void *vaddr;
- static u64 dummy_mask = DMA_32BIT_MASK;
-
+ int instance = pdev->id;
+ struct resource *res;
+ struct tegra_hcd_platform_data *pdata;
+ struct usb_hcd *hcd;
+ int e = 0;
+ int irq;
+ unsigned int temp;
+ static u64 dummy_mask = DMA_32BIT_MASK;
pdata = (struct tegra_hcd_platform_data *)pdev->dev.platform_data;
if (!pdata) {
dev_err(&pdev->dev, "Cannot run without platform data\n");
@@ -389,15 +385,11 @@ static int tegra_ehci_probe(struct platform_device *pdev)
pdev->dev.dma_mask = &dummy_mask;
hcd = usb_create_hcd(&tegra_ehci_hc_driver, &pdev->dev,
- dev_name(&pdev->dev));
+ dev_name(&pdev->dev));
if (!hcd) {
e = -ENOMEM;
goto fail;
}
- pdata->instance = instance;
-
- pdata->pUsbProperty = NvOdmQueryGetUsbProperty(NvOdmIoModule_Usb,
- instance);
if (pdata->pUsbProperty->IdPinDetectionType == NvOdmUsbIdPinType_Gpio
&& (instance == 0 || instance == 1)) {
@@ -429,32 +421,29 @@ static int tegra_ehci_probe(struct platform_device *pdev)
printk("%s: failed with error (0x%x)\n", __func__, e);
goto fail;
}
-
- NvRmModuleGetBaseAddress(s_hRmGlobal,
- NVRM_MODULE_ID(NvRmModuleID_Usb2Otg, instance), &addr, &size);
- if (addr == 0x0 || size == 0) {
- e = -ENODEV;
+ res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+ if (!res) {
+ e = -ENXIO;
goto fail;
}
- NvRmPhysicalMemMap(addr, size, NVOS_MEM_READ_WRITE,
- NvOsMemAttribute_Uncached, (void **)&vaddr);
- if (vaddr == NULL) {
+ hcd->rsrc_start = res->start;
+ hcd->rsrc_len = resource_size(res);
+ hcd->regs = ioremap(res->start, resource_size(res));
+ if (!hcd->regs) {
e = -ENOMEM;
goto fail;
}
- hcd->rsrc_start = addr;
- hcd->rsrc_len = size;
- hcd->regs = vaddr;
/* Set to Host mode by setting bit 0-1 of USB device mode register */
temp = readl(hcd->regs + TEGRA_USB_USBMODE_REG_OFFSET);
writel((temp | TEGRA_USB_USBMODE_HOST),
(hcd->regs + TEGRA_USB_USBMODE_REG_OFFSET));
-
- irq = NvRmGetIrqForLogicalInterrupt(s_hRmGlobal,
- NVRM_MODULE_ID(NvRmModuleID_Usb2Otg, instance), 0);
- if (irq == 0xffff)
+ irq = platform_get_irq(pdev, 0);
+ if (!irq) {
+ e = -ENODEV;
goto fail;
+ }
+
set_irq_flags(irq, IRQF_VALID);
e = usb_add_hcd(hcd, irq, IRQF_DISABLED | IRQF_SHARED);