summaryrefslogtreecommitdiff
path: root/arch
diff options
context:
space:
mode:
authorVarun Wadekar <vwadekar@nvidia.com>2011-06-29 18:21:40 +0530
committerManish Tuteja <mtuteja@nvidia.com>2011-06-30 04:19:58 -0700
commit583f67ecb9af974b9ddbb1f464046806460fb6d6 (patch)
treedbace20a9dc5697c30b8351c3ce276ac53c9aeb2 /arch
parent56ca96938ee143005f4e50ac6b56cbd6e2d867a5 (diff)
arm: tegra: whistler: enable usb rndis support
Bug 842809 Change-Id: Idb3fde5c3287143e4e67a2083fddd1a07f1d630f Signed-off-by: Varun Wadekar <vwadekar@nvidia.com> Reviewed-on: http://git-master/r/38960 Reviewed-by: Bharat Nihalani <bnihalani@nvidia.com>
Diffstat (limited to 'arch')
-rw-r--r--arch/arm/mach-tegra/board-whistler.c120
1 files changed, 91 insertions, 29 deletions
diff --git a/arch/arm/mach-tegra/board-whistler.c b/arch/arm/mach-tegra/board-whistler.c
index e7a2827f192b..4a12f93c9e3a 100644
--- a/arch/arm/mach-tegra/board-whistler.c
+++ b/arch/arm/mach-tegra/board-whistler.c
@@ -169,34 +169,81 @@ static __initdata struct tegra_clk_init_table whistler_clk_init_table[] = {
{ NULL, NULL, 0, 0},
};
-static char *usb_functions[] = { "mtp", "usb_mass_storage" };
-static char *usb_functions_adb[] = { "mtp", "adb", "usb_mass_storage" };
+#define USB_MANUFACTURER_NAME "NVIDIA"
+#define USB_PRODUCT_NAME "Whistler"
+#define USB_PRODUCT_ID_MTP_ADB 0x7100
+#define USB_PRODUCT_ID_MTP 0x7102
+#define USB_PRODUCT_ID_RNDIS 0x7103
+#define USB_VENDOR_ID 0x0955
+
+static char *usb_functions_mtp_ums[] = { "mtp", "usb_mass_storage" };
+static char *usb_functions_mtp_adb_ums[] = { "mtp", "adb", "usb_mass_storage" };
+#ifdef CONFIG_USB_ANDROID_RNDIS
+static char *usb_functions_rndis[] = { "rndis" };
+static char *usb_functions_rndis_adb[] = { "rndis", "adb" };
+#endif
+static char *usb_functions_all[] = {
+#ifdef CONFIG_USB_ANDROID_RNDIS
+ "rndis",
+#endif
+ "mtp",
+ "adb",
+ "usb_mass_storage"
+};
static struct android_usb_product usb_products[] = {
{
- .product_id = 0x7102,
- .num_functions = ARRAY_SIZE(usb_functions),
- .functions = usb_functions,
+ .product_id = USB_PRODUCT_ID_MTP,
+ .num_functions = ARRAY_SIZE(usb_functions_mtp_ums),
+ .functions = usb_functions_mtp_ums,
},
{
- .product_id = 0x7100,
- .num_functions = ARRAY_SIZE(usb_functions_adb),
- .functions = usb_functions_adb,
+ .product_id = USB_PRODUCT_ID_MTP_ADB,
+ .num_functions = ARRAY_SIZE(usb_functions_mtp_adb_ums),
+ .functions = usb_functions_mtp_adb_ums,
},
+#ifdef CONFIG_USB_ANDROID_RNDIS
+ {
+ .product_id = USB_PRODUCT_ID_RNDIS,
+ .num_functions = ARRAY_SIZE(usb_functions_rndis),
+ .functions = usb_functions_rndis,
+ },
+ {
+ .product_id = USB_PRODUCT_ID_RNDIS,
+ .num_functions = ARRAY_SIZE(usb_functions_rndis_adb),
+ .functions = usb_functions_rndis_adb,
+ },
+#endif
};
/* standard android USB platform data */
static struct android_usb_platform_data andusb_plat = {
- .vendor_id = 0x0955,
- .product_id = 0x7100,
- .manufacturer_name = "NVIDIA",
- .product_name = "Whistler",
+ .vendor_id = USB_VENDOR_ID,
+ .product_id = USB_PRODUCT_ID_MTP_ADB,
+ .manufacturer_name = USB_MANUFACTURER_NAME,
+ .product_name = USB_PRODUCT_NAME,
.serial_number = NULL,
.num_products = ARRAY_SIZE(usb_products),
.products = usb_products,
- .num_functions = ARRAY_SIZE(usb_functions_adb),
- .functions = usb_functions_adb,
+ .num_functions = ARRAY_SIZE(usb_functions_all),
+ .functions = usb_functions_all,
+};
+
+#ifdef CONFIG_USB_ANDROID_RNDIS
+static struct usb_ether_platform_data rndis_pdata = {
+ .ethaddr = {0, 0, 0, 0, 0, 0},
+ .vendorID = USB_VENDOR_ID,
+ .vendorDescr = USB_MANUFACTURER_NAME,
+};
+
+static struct platform_device rndis_device = {
+ .name = "rndis",
+ .id = -1,
+ .dev = {
+ .platform_data = &rndis_pdata,
+ },
};
+#endif
static struct platform_device androidusb_device = {
.name = "android_usb",
@@ -565,17 +612,6 @@ static struct tegra_otg_platform_data tegra_otg_pdata = {
.host_unregister = &tegra_usb_otg_host_unregister,
};
-static void whistler_usb_init(void)
-{
- tegra_usb_phy_init(tegra_usb_phy_pdata, ARRAY_SIZE(tegra_usb_phy_pdata));
-
- tegra_otg_device.dev.platform_data = &tegra_otg_pdata;
- platform_device_register(&tegra_otg_device);
-
- tegra_ehci3_device.dev.platform_data = &tegra_ehci_pdata[2];
- platform_device_register(&tegra_ehci3_device);
-}
-
static int __init whistler_gps_init(void)
{
tegra_gpio_enable(TEGRA_GPIO_PU4);
@@ -608,16 +644,42 @@ static void whistler_codec_init(void)
{
i2c_register_board_info(4, whistler_codec_info, 1);
}
-static void __init tegra_whistler_init(void)
+
+#define SERIAL_NUMBER_LENGTH 20
+static char usb_serial_num[SERIAL_NUMBER_LENGTH];
+static void whistler_usb_init(void)
{
- char serial[20];
+ tegra_usb_phy_init(tegra_usb_phy_pdata, ARRAY_SIZE(tegra_usb_phy_pdata));
+
+ tegra_otg_device.dev.platform_data = &tegra_otg_pdata;
+ platform_device_register(&tegra_otg_device);
+
+ tegra_ehci3_device.dev.platform_data = &tegra_ehci_pdata[2];
+ platform_device_register(&tegra_ehci3_device);
+
+#ifdef CONFIG_USB_ANDROID_RNDIS
+ src = usb_serial_num;
+ /* create a fake MAC address from our serial number.
+ * first byte is 0x02 to signify locally administered.
+ */
+ rndis_pdata.ethaddr[0] = 0x02;
+ for (i = 0; *src; i++) {
+ /* XOR the USB serial across the remaining bytes */
+ rndis_pdata.ethaddr[i % (ETH_ALEN - 1) + 1] ^= *src++;
+ }
+ platform_device_register(&rndis_device);
+#endif
+}
+
+static void __init tegra_whistler_init(void)
+{
tegra_common_init();
tegra_clk_init_from_table(whistler_clk_init_table);
whistler_pinmux_init();
whistler_i2c_init();
- snprintf(serial, sizeof(serial), "%llx", tegra_chip_uid());
- andusb_plat.serial_number = kstrdup(serial, GFP_KERNEL);
+ snprintf(usb_serial_num, sizeof(usb_serial_num), "%llx", tegra_chip_uid());
+ andusb_plat.serial_number = kstrdup(usb_serial_num, GFP_KERNEL);
tegra_i2s_device1.dev.platform_data = &tegra_audio_pdata[0];
tegra_i2s_device2.dev.platform_data = &tegra_audio_pdata[1];
tegra_spdif_device.dev.platform_data = &tegra_spdif_pdata;