diff options
-rw-r--r-- | arch/arm/mach-tegra/board-aruba.c | 45 | ||||
-rw-r--r-- | arch/arm/mach-tegra/board-cardhu.c | 55 | ||||
-rw-r--r-- | arch/arm/mach-tegra/board-enterprise.c | 51 | ||||
-rw-r--r-- | arch/arm/mach-tegra/board-ventana.c | 51 | ||||
-rw-r--r-- | arch/arm/mach-tegra/board-whistler.c | 52 | ||||
-rw-r--r-- | drivers/usb/otg/tegra-otg.c | 57 | ||||
-rw-r--r-- | include/linux/platform_data/tegra_usb.h | 4 |
7 files changed, 64 insertions, 251 deletions
diff --git a/arch/arm/mach-tegra/board-aruba.c b/arch/arm/mach-tegra/board-aruba.c index 172e6b1b1092..90d022b1535b 100644 --- a/arch/arm/mach-tegra/board-aruba.c +++ b/arch/arm/mach-tegra/board-aruba.c @@ -495,51 +495,6 @@ static void aruba_usb_init(void) platform_device_register(&tegra_ehci2_device); } -struct platform_device *tegra_usb_otg_host_register(void) -{ - struct platform_device *pdev; - void *platform_data; - int val; - - pdev = platform_device_alloc(tegra_ehci1_device.name, tegra_ehci1_device.id); - if (!pdev) - return NULL; - - val = platform_device_add_resources(pdev, tegra_ehci1_device.resource, - tegra_ehci1_device.num_resources); - if (val) - goto error; - - pdev->dev.dma_mask = tegra_ehci1_device.dev.dma_mask; - pdev->dev.coherent_dma_mask = tegra_ehci1_device.dev.coherent_dma_mask; - - platform_data = kmalloc(sizeof(struct tegra_ehci_platform_data), GFP_KERNEL); - if (!platform_data) - goto error; - - memcpy(platform_data, &tegra_ehci_pdata[0], - sizeof(struct tegra_ehci_platform_data)); - pdev->dev.platform_data = platform_data; - - val = platform_device_add(pdev); - if (val) - goto error_add; - - return pdev; - -error_add: - kfree(platform_data); -error: - pr_err("%s: failed to add the host contoller device\n", __func__); - platform_device_put(pdev); - return NULL; -} - -void tegra_usb_otg_host_unregister(struct platform_device *pdev) -{ - platform_device_unregister(pdev); -} - #ifdef CONFIG_SATA_AHCI_TEGRA static void aruba_sata_init(void) { diff --git a/arch/arm/mach-tegra/board-cardhu.c b/arch/arm/mach-tegra/board-cardhu.c index cec58352ded1..1b8db209fd89 100644 --- a/arch/arm/mach-tegra/board-cardhu.c +++ b/arch/arm/mach-tegra/board-cardhu.c @@ -699,52 +699,10 @@ static struct tegra_ehci_platform_data tegra_ehci_pdata[] = { }, }; -static struct platform_device *tegra_usb_otg_host_register(void) -{ - struct platform_device *pdev; - void *platform_data; - int val; - - pdev = platform_device_alloc(tegra_ehci1_device.name, - tegra_ehci1_device.id); - if (!pdev) - return NULL; - - val = platform_device_add_resources(pdev, tegra_ehci1_device.resource, - tegra_ehci1_device.num_resources); - if (val) - goto error; - - pdev->dev.dma_mask = tegra_ehci1_device.dev.dma_mask; - pdev->dev.coherent_dma_mask = tegra_ehci1_device.dev.coherent_dma_mask; - - platform_data = kmalloc(sizeof(struct tegra_ehci_platform_data), - GFP_KERNEL); - if (!platform_data) - goto error; - - memcpy(platform_data, &tegra_ehci_pdata[0], - sizeof(struct tegra_ehci_platform_data)); - pdev->dev.platform_data = platform_data; - - val = platform_device_add(pdev); - if (val) - goto error_add; - - return pdev; - -error_add: - kfree(platform_data); -error: - pr_err("%s: failed to add the host contoller device\n", __func__); - platform_device_put(pdev); - return NULL; -} - -static void tegra_usb_otg_host_unregister(struct platform_device *pdev) -{ - platform_device_unregister(pdev); -} +static struct tegra_otg_platform_data tegra_otg_pdata = { + .ehci_device = &tegra_ehci1_device, + .ehci_pdata = &tegra_ehci_pdata[0], +}; #ifdef CONFIG_USB_SUPPORT static struct usb_phy_plat_data tegra_usb_phy_pdata[] = { @@ -764,11 +722,6 @@ static struct usb_phy_plat_data tegra_usb_phy_pdata[] = { }, }; -static struct tegra_otg_platform_data tegra_otg_pdata = { - .host_register = &tegra_usb_otg_host_register, - .host_unregister = &tegra_usb_otg_host_unregister, -}; - static void cardhu_usb_init(void) { struct board_info bi; diff --git a/arch/arm/mach-tegra/board-enterprise.c b/arch/arm/mach-tegra/board-enterprise.c index c09b1b324e16..82d9ee0962ce 100644 --- a/arch/arm/mach-tegra/board-enterprise.c +++ b/arch/arm/mach-tegra/board-enterprise.c @@ -636,56 +636,9 @@ static struct tegra_ehci_platform_data tegra_ehci_pdata[] = { }, }; -static struct platform_device *tegra_usb_otg_host_register(void) -{ - struct platform_device *pdev; - void *platform_data; - int val; - - pdev = platform_device_alloc(tegra_ehci1_device.name, - tegra_ehci1_device.id); - if (!pdev) - return NULL; - - val = platform_device_add_resources(pdev, tegra_ehci1_device.resource, - tegra_ehci1_device.num_resources); - if (val) - goto error; - - pdev->dev.dma_mask = tegra_ehci1_device.dev.dma_mask; - pdev->dev.coherent_dma_mask = tegra_ehci1_device.dev.coherent_dma_mask; - - platform_data = kmalloc(sizeof(struct tegra_ehci_platform_data), - GFP_KERNEL); - if (!platform_data) - goto error; - - memcpy(platform_data, &tegra_ehci_pdata[0], - sizeof(struct tegra_ehci_platform_data)); - pdev->dev.platform_data = platform_data; - - val = platform_device_add(pdev); - if (val) - goto error_add; - - return pdev; - -error_add: - kfree(platform_data); -error: - pr_err("%s: failed to add the host contoller device\n", __func__); - platform_device_put(pdev); - return NULL; -} - -static void tegra_usb_otg_host_unregister(struct platform_device *pdev) -{ - platform_device_unregister(pdev); -} - static struct tegra_otg_platform_data tegra_otg_pdata = { - .host_register = &tegra_usb_otg_host_register, - .host_unregister = &tegra_usb_otg_host_unregister, + .ehci_device = &tegra_ehci1_device, + .ehci_pdata = &tegra_ehci_pdata[0], }; static void enterprise_usb_init(void) diff --git a/arch/arm/mach-tegra/board-ventana.c b/arch/arm/mach-tegra/board-ventana.c index a7265bd6c0da..845494baf9e5 100644 --- a/arch/arm/mach-tegra/board-ventana.c +++ b/arch/arm/mach-tegra/board-ventana.c @@ -491,56 +491,9 @@ static struct tegra_ehci_platform_data tegra_ehci_pdata[] = { }, }; -static struct platform_device *tegra_usb_otg_host_register(void) -{ - struct platform_device *pdev; - void *platform_data; - int val; - - pdev = platform_device_alloc(tegra_ehci1_device.name, tegra_ehci1_device.id); - if (!pdev) - return NULL; - - val = platform_device_add_resources(pdev, tegra_ehci1_device.resource, - tegra_ehci1_device.num_resources); - if (val) - goto error; - - pdev->dev.dma_mask = tegra_ehci1_device.dev.dma_mask; - pdev->dev.coherent_dma_mask = tegra_ehci1_device.dev.coherent_dma_mask; - - platform_data = kmalloc(sizeof(struct tegra_ehci_platform_data), GFP_KERNEL); - if (!platform_data) - goto error; - - memcpy(platform_data, &tegra_ehci_pdata[0], - sizeof(struct tegra_ehci_platform_data)); - pdev->dev.platform_data = platform_data; - - val = platform_device_add(pdev); - if (val) - goto error_add; - - return pdev; - -error_add: - kfree(platform_data); -error: - pr_err("%s: failed to add the host contoller device\n", __func__); - platform_device_put(pdev); - return NULL; -} - -static void tegra_usb_otg_host_unregister(struct platform_device *pdev) -{ - kfree(pdev->dev.platform_data); - pdev->dev.platform_data = NULL; - platform_device_unregister(pdev); -} - static struct tegra_otg_platform_data tegra_otg_pdata = { - .host_register = &tegra_usb_otg_host_register, - .host_unregister = &tegra_usb_otg_host_unregister, + .ehci_device = &tegra_ehci1_device, + .ehci_pdata = &tegra_ehci_pdata[0], }; static int __init ventana_gps_init(void) diff --git a/arch/arm/mach-tegra/board-whistler.c b/arch/arm/mach-tegra/board-whistler.c index 51e94a8a8607..f0714b72f03c 100644 --- a/arch/arm/mach-tegra/board-whistler.c +++ b/arch/arm/mach-tegra/board-whistler.c @@ -391,57 +391,9 @@ static struct tegra_ehci_platform_data tegra_ehci_pdata[] = { }, }; -static struct platform_device *tegra_usb_otg_host_register(void) -{ - struct platform_device *pdev; - void *platform_data; - int val; - - pdev = platform_device_alloc(tegra_ehci1_device.name, - tegra_ehci1_device.id); - if (!pdev) - return NULL; - - val = platform_device_add_resources(pdev, tegra_ehci1_device.resource, - tegra_ehci1_device.num_resources); - if (val) - goto error; - - pdev->dev.dma_mask = tegra_ehci1_device.dev.dma_mask; - pdev->dev.coherent_dma_mask = tegra_ehci1_device.dev.coherent_dma_mask; - - platform_data = kmalloc(sizeof(struct tegra_ehci_platform_data), - GFP_KERNEL); - if (!platform_data) - goto error; - - memcpy(platform_data, &tegra_ehci_pdata[0], - sizeof(struct tegra_ehci_platform_data)); - pdev->dev.platform_data = platform_data; - - val = platform_device_add(pdev); - if (val) - goto error_add; - - return pdev; - -error_add: - kfree(platform_data); -error: - pr_err("%s: failed to add the host contoller device\n", __func__); - platform_device_put(pdev); - return NULL; -} - -static void tegra_usb_otg_host_unregister(struct platform_device *pdev) -{ - kfree(pdev->dev.platform_data); - platform_device_unregister(pdev); -} - static struct tegra_otg_platform_data tegra_otg_pdata = { - .host_register = &tegra_usb_otg_host_register, - .host_unregister = &tegra_usb_otg_host_unregister, + .ehci_device = &tegra_ehci1_device, + .ehci_pdata = &tegra_ehci_pdata[0], }; static int __init whistler_gps_init(void) diff --git a/drivers/usb/otg/tegra-otg.c b/drivers/usb/otg/tegra-otg.c index 2545aa772df5..a063630e529d 100644 --- a/drivers/usb/otg/tegra-otg.c +++ b/drivers/usb/otg/tegra-otg.c @@ -50,14 +50,12 @@ struct tegra_otg_data { void __iomem *regs; struct clk *clk; int irq; - struct platform_device *host; struct platform_device *pdev; struct work_struct work; unsigned int intr_reg_data; bool detect_vbus; bool clk_enabled; }; - static struct tegra_otg_data *tegra_clone; static inline unsigned long otg_readl(struct tegra_otg_data *tegra, @@ -97,19 +95,68 @@ static const char *tegra_state_name(enum usb_otg_state state) return "INVALID"; } +static struct platform_device * +tegra_usb_otg_host_register(struct platform_device *ehci_device, + struct tegra_ehci_platform_data *pdata) +{ + struct platform_device *pdev; + void *platform_data; + int val; + + pdev = platform_device_alloc(ehci_device->name, ehci_device->id); + if (!pdev) + return NULL; + + val = platform_device_add_resources(pdev, ehci_device->resource, + ehci_device->num_resources); + if (val) + goto error; + + pdev->dev.dma_mask = ehci_device->dev.dma_mask; + pdev->dev.coherent_dma_mask = ehci_device->dev.coherent_dma_mask; + + platform_data = kmalloc(sizeof(struct tegra_ehci_platform_data), + GFP_KERNEL); + if (!platform_data) + goto error; + + memcpy(platform_data, pdata, sizeof(struct tegra_ehci_platform_data)); + pdev->dev.platform_data = platform_data; + + val = platform_device_add(pdev); + if (val) + goto error_add; + + return pdev; + +error_add: + kfree(platform_data); +error: + pr_err("%s: failed to add the host controller device\n", __func__); + platform_device_put(pdev); + return NULL; +} + +static void tegra_usb_otg_host_unregister(struct platform_device *pdev) +{ + kfree(pdev->dev.platform_data); + pdev->dev.platform_data = NULL; + platform_device_unregister(pdev); +} + void tegra_start_host(struct tegra_otg_data *tegra) { struct tegra_otg_platform_data *pdata = tegra->otg.dev->platform_data; if (!tegra->pdev) { - tegra->pdev = pdata->host_register(); + tegra->pdev = tegra_usb_otg_host_register(pdata->ehci_device, + pdata->ehci_pdata); } } void tegra_stop_host(struct tegra_otg_data *tegra) { - struct tegra_otg_platform_data *pdata = tegra->otg.dev->platform_data; if (tegra->pdev) { - pdata->host_unregister(tegra->pdev); + tegra_usb_otg_host_unregister(tegra->pdev); tegra->pdev = NULL; } } diff --git a/include/linux/platform_data/tegra_usb.h b/include/linux/platform_data/tegra_usb.h index cf75a98f5c37..09f32de5c671 100644 --- a/include/linux/platform_data/tegra_usb.h +++ b/include/linux/platform_data/tegra_usb.h @@ -40,8 +40,8 @@ struct tegra_ehci_platform_data { }; struct tegra_otg_platform_data { - struct platform_device* (*host_register)(void); - void (*host_unregister)(struct platform_device*); + struct platform_device *ehci_device; + struct tegra_ehci_platform_data *ehci_pdata; }; #endif /* _TEGRA_USB_H_ */ |