261 lines
5.0 KiB
C
Executable File
261 lines
5.0 KiB
C
Executable File
#include <linux/module.h>
|
|
#include <linux/init.h>
|
|
#include <linux/device.h>
|
|
#include <linux/platform_device.h>
|
|
|
|
|
|
#include <mach/gpio.h>
|
|
#include <asm/mach-types.h>
|
|
#include <mach/hardware.h>
|
|
#include <mach/mfp-pxa27x.h>
|
|
#include <mach/pxa2xx-regs.h>
|
|
#include <mach/udc.h>
|
|
#include <mach/g900-gpio.h>
|
|
|
|
#include <linux/usb/gpio_vbus.h>
|
|
|
|
static int g900_udc_is_connected(void)
|
|
{
|
|
printk("g900_udc_is_connected = %d\n", gpio_get_value(GPIO40_nUSB_DETECT));
|
|
return (gpio_get_value(GPIO40_nUSB_DETECT) != 0);
|
|
}
|
|
|
|
static void g900_udc_command(int command)
|
|
{
|
|
printk("g900_udc_command enter, command = %d\n", command);
|
|
switch (command)
|
|
{
|
|
case PXA2XX_UDC_CMD_DISCONNECT:
|
|
break;
|
|
case PXA2XX_UDC_CMD_CONNECT:
|
|
break;
|
|
default:
|
|
printk("%s: unknown command '%d'.", __FUNCTION__, command);
|
|
}
|
|
}
|
|
#if 0
|
|
struct gpio_vbus_mach_info gpio_vbus_data = {
|
|
.gpio_vbus = GPIO40_nUSB_DETECT,
|
|
.gpio_vbus_inverted = 1,
|
|
.gpio_pullup = -1,
|
|
};
|
|
#endif
|
|
|
|
static struct pxa2xx_udc_mach_info g900_udc_info = {
|
|
// .udc_is_connected = g900_udc_is_connected,
|
|
.gpio_vbus = GPIO40_nUSB_DETECT,
|
|
// .gpio_vbus = GPIO41_USB_P2_7,
|
|
// .gpio_pullup = GPIO93_USB_ENABLE,
|
|
.gpio_pullup = GPIO75_USB_ENABLE,
|
|
// .udc_command = g900_udc_command,
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//################################
|
|
|
|
#ifdef CONFIG_USB_ANDROID
|
|
#include <linux/usb/android_composite.h>
|
|
|
|
static char *usb_functions_ums[] = {
|
|
"usb_mass_storage",
|
|
};
|
|
|
|
static char *usb_functions_ums_adb[] = {
|
|
"usb_mass_storage",
|
|
"adb",
|
|
};
|
|
|
|
static char *usb_functions_rndis[] = {
|
|
"rndis",
|
|
};
|
|
|
|
static char *usb_functions_rndis_adb[] = {
|
|
"rndis",
|
|
"adb",
|
|
};
|
|
|
|
#ifdef CONFIG_USB_ANDROID_DIAG
|
|
static char *usb_functions_adb_diag[] = {
|
|
"usb_mass_storage",
|
|
"adb",
|
|
"diag",
|
|
};
|
|
#endif
|
|
|
|
static char *usb_functions_all[] = {
|
|
#ifdef CONFIG_USB_ANDROID_RNDIS
|
|
"rndis",
|
|
#endif
|
|
#ifdef CONFIG_USB_ANDROID_MASS_STORAGE
|
|
"usb_mass_storage",
|
|
#endif
|
|
#ifdef CONFIG_USB_ANDROID_ADB
|
|
"adb",
|
|
#endif
|
|
#ifdef CONFIG_USB_ANDROID_ACM
|
|
"acm",
|
|
#endif
|
|
#ifdef CONFIG_USB_ANDROID_DIAG
|
|
"diag",
|
|
#endif
|
|
};
|
|
|
|
static struct android_usb_product usb_products[] = {
|
|
{
|
|
.product_id = 0x4e11,
|
|
.num_functions = ARRAY_SIZE(usb_functions_ums),
|
|
.functions = usb_functions_ums,
|
|
},
|
|
{
|
|
.product_id = 0x4e12,
|
|
.num_functions = ARRAY_SIZE(usb_functions_ums_adb),
|
|
.functions = usb_functions_ums_adb,
|
|
},
|
|
{
|
|
.product_id = 0x4e13,
|
|
.num_functions = ARRAY_SIZE(usb_functions_rndis),
|
|
.functions = usb_functions_rndis,
|
|
},
|
|
{
|
|
.product_id = 0x4e14,
|
|
.num_functions = ARRAY_SIZE(usb_functions_rndis_adb),
|
|
.functions = usb_functions_rndis_adb,
|
|
},
|
|
#ifdef CONFIG_USB_ANDROID_DIAG
|
|
{
|
|
.product_id = 0x4e17,
|
|
.num_functions = ARRAY_SIZE(usb_functions_adb_diag),
|
|
.functions = usb_functions_adb_diag,
|
|
},
|
|
#endif
|
|
};
|
|
|
|
static struct usb_mass_storage_platform_data mass_storage_pdata = {
|
|
.nluns = 1,
|
|
.vendor = "Google, Inc.",
|
|
.product = "Nexus One",
|
|
.release = 0x0100,
|
|
};
|
|
|
|
static struct platform_device usb_mass_storage_device = {
|
|
.name = "usb_mass_storage",
|
|
.id = -1,
|
|
.dev = {
|
|
.platform_data = &mass_storage_pdata,
|
|
},
|
|
};
|
|
|
|
#ifdef CONFIG_USB_ANDROID_RNDIS
|
|
static struct usb_ether_platform_data rndis_pdata = {
|
|
/* ethaddr is filled by board_serialno_setup */
|
|
.vendorID = 0x18d1,
|
|
.vendorDescr = "Google, Inc.",
|
|
};
|
|
|
|
static struct platform_device rndis_device = {
|
|
.name = "rndis",
|
|
.id = -1,
|
|
.dev = {
|
|
.platform_data = &rndis_pdata,
|
|
},
|
|
};
|
|
#endif
|
|
|
|
static struct android_usb_platform_data android_usb_pdata = {
|
|
.vendor_id = 0x18d1,
|
|
.product_id = 0x4e11,
|
|
.version = 0x0100,
|
|
.product_name = "Nexus One",
|
|
.manufacturer_name = "Google, Inc.",
|
|
.num_products = ARRAY_SIZE(usb_products),
|
|
.products = usb_products,
|
|
.num_functions = ARRAY_SIZE(usb_functions_all),
|
|
.functions = usb_functions_all,
|
|
};
|
|
|
|
static struct platform_device android_usb_device = {
|
|
.name = "android_usb",
|
|
.id = -1,
|
|
.dev = {
|
|
.platform_data = &android_usb_pdata,
|
|
},
|
|
};
|
|
|
|
|
|
static struct platform_device *g900_udc_devices[] __initdata = {
|
|
#ifdef CONFIG_USB_ANDROID_MASS_STORAGE
|
|
&usb_mass_storage_device,
|
|
#endif
|
|
#ifdef CONFIG_USB_ANDROID_RNDIS
|
|
&rndis_device,
|
|
#endif
|
|
&android_usb_device,
|
|
};
|
|
|
|
void __init add_usb_devices(void)
|
|
{
|
|
|
|
platform_add_devices(g900_udc_devices,ARRAY_SIZE(g900_udc_devices));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endif
|
|
|
|
//#############################
|
|
|
|
|
|
|
|
|
|
static int g900_udc_probe(struct platform_device *pdev)
|
|
{
|
|
printk("******Probing Toshiba g900 UDC*****\n");
|
|
pxa_set_udc_info(&g900_udc_info);
|
|
return 0;
|
|
}
|
|
|
|
static int g900_udc_remove(struct platform_device *pdev)
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
static struct platform_driver g900_udc_driver = {
|
|
.driver = {
|
|
.name = "g900-udc",
|
|
},
|
|
.probe = g900_udc_probe,
|
|
.remove = g900_udc_remove,
|
|
//.suspend = g900_udc_suspend,
|
|
//.resume = g900_udc_resume,
|
|
};
|
|
|
|
static int __init g900_udc_init(void)
|
|
{
|
|
if (!machine_is_g900()) return -ENODEV;
|
|
platform_driver_register(&g900_udc_driver);
|
|
#ifdef CONFIG_USB_ANDROID
|
|
add_usb_devices();
|
|
#endif
|
|
return 0;
|
|
|
|
}
|
|
|
|
static void __exit g900_udc_exit(void)
|
|
{
|
|
return;
|
|
}
|
|
|
|
module_init(g900_udc_init);
|
|
module_exit(g900_udc_exit);
|
|
|
|
MODULE_AUTHOR("Xiao Huang <reed.huang@gmail.com");
|
|
MODULE_DESCRIPTION("Asus g900 UDC support");
|
|
MODULE_LICENSE("GPL");
|