arm: tegra: enterprise: register/unregister functions for hsic
Seshendra Gadagottu [Tue, 6 Dec 2011 04:07:15 +0000 (09:07 +0530)]
Added functions for register and unregister usb hsic device with
kernel. Updated xmm platform data with these function pointers.

BUG 787270

Reviewed-on: http://git-master/r/65092
(cherry picked from commit 7655d416cfef35bd68c9b0daf16253b4f4e013c6)

Change-Id: Ie3c5478164a4ee1a5b2e00e39827bb005d30a904
Reviewed-on: http://git-master/r/68392
Reviewed-by: Lokesh Pathak <lpathak@nvidia.com>
Tested-by: Lokesh Pathak <lpathak@nvidia.com>

Rebase-Id: R27149e6ee948469787211ffc07ac540ee0b18e40

arch/arm/mach-tegra/board-enterprise.c

index f951580..1da70dc 100644 (file)
@@ -695,6 +695,53 @@ static struct tegra_otg_platform_data tegra_otg_pdata = {
        .ehci_pdata = &tegra_ehci_pdata[0],
 };
 
+struct platform_device *tegra_usb_hsic_host_register(void)
+{
+       struct platform_device *pdev;
+       void *platform_data;
+       int val;
+
+       pdev = platform_device_alloc(tegra_ehci2_device.name,
+               tegra_ehci2_device.id);
+       if (!pdev)
+               return NULL;
+
+       val = platform_device_add_resources(pdev, tegra_ehci2_device.resource,
+               tegra_ehci2_device.num_resources);
+       if (val)
+               goto error;
+
+       pdev->dev.dma_mask =  tegra_ehci2_device.dev.dma_mask;
+       pdev->dev.coherent_dma_mask = tegra_ehci2_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_uhsic_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 contoller device\n", __func__);
+       platform_device_put(pdev);
+       return NULL;
+}
+
+void tegra_usb_hsic_host_unregister(struct platform_device *pdev)
+{
+       platform_device_unregister(pdev);
+}
+
 static int enterprise_usb_hsic_postsupend(void)
 {
        pr_debug("%s\n", __func__);
@@ -789,7 +836,6 @@ static struct baseband_power_platform_data tegra_baseband_power_data = {
                        .ipc_ap_wake = XMM_GPIO_IPC_AP_WAKE,
                        .ipc_hsic_active = XMM_GPIO_IPC_HSIC_ACTIVE,
                        .ipc_hsic_sus_req = XMM_GPIO_IPC_HSIC_SUS_REQ,
-                       .hsic_device = &tegra_ehci2_device,
                },
        },
 };
@@ -825,9 +871,6 @@ static void enterprise_baseband_init(void)
                uhsic_phy_config.preresume = enterprise_usb_hsic_preresume;
                uhsic_phy_config.usb_phy_ready = enterprise_usb_hsic_phy_ready;
                uhsic_phy_config.post_phy_off = enterprise_usb_hsic_phy_off;
-               /* baseband-power.ko will register ehci2 device */
-               tegra_ehci2_device.dev.platform_data
-                       = &tegra_ehci_uhsic_pdata;
                /* enable XMM6260 baseband gpio(s) */
                tegra_gpio_enable(tegra_baseband_power_data.modem.generic
                        .mdm_reset);
@@ -841,6 +884,10 @@ static void enterprise_baseband_init(void)
                        .ap2mdm_ack2);
                tegra_gpio_enable(tegra_baseband_power_data.modem.generic
                        .mdm2ap_ack2);
+               tegra_baseband_power_data.hsic_register =
+                                               &tegra_usb_hsic_host_register;
+               tegra_baseband_power_data.hsic_unregister =
+                                               &tegra_usb_hsic_host_unregister;
                platform_device_register(&tegra_baseband_power_device);
                platform_device_register(&tegra_baseband_power2_device);
                break;