From: Sergey Kudakov Date: Fri, 23 Jul 2010 17:07:26 +0000 (-0500) Subject: Corrections for usb platform data X-Git-Tag: firefly_0821_release~9834^2~767 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=e0782d535446eb8059eabbaeba4e3c57d1a7f400;p=firefly-linux-kernel-4.4.55.git Corrections for usb platform data Signed-off-by: Sergey Kudakov --- diff --git a/arch/arm/mach-tegra/board-stingray.c b/arch/arm/mach-tegra/board-stingray.c index c6e13475e8e8..c3846c1012be 100644 --- a/arch/arm/mach-tegra/board-stingray.c +++ b/arch/arm/mach-tegra/board-stingray.c @@ -374,7 +374,7 @@ static struct android_usb_platform_data andusb_plat_factory = { }; static struct platform_device usbnet_device = { - .name = "usbnet", + .name = "usbnet", }; /* bq24617 charger */ @@ -584,7 +584,6 @@ static int __init parse_tag_bdaddr(const struct tag *tag) return 0; } - __tagtable(ATAG_BDADDR, parse_tag_bdaddr); static void stingray_w1_init(void) @@ -593,30 +592,50 @@ static void stingray_w1_init(void) platform_device_register(&tegra_w1_device); } -#define BOOT_MODE_MAX_LEN 30 -static char boot_mode[BOOT_MODE_MAX_LEN+1]; -int __init board_boot_mode_init(char *s) +/* powerup reason */ +#define ATAG_POWERUP_REASON 0xf1000401 +#define ATAG_POWERUP_REASON_SIZE 3 /* size + tag id + tag data */ -{ - strncpy(boot_mode, s, BOOT_MODE_MAX_LEN); +static unsigned int powerup_reason = PU_REASON_PWR_KEY_PRESS; - printk(KERN_INFO "boot_mode=%s\n", boot_mode); +static int __init parse_tag_powerup_reason(const struct tag *tag) +{ + if (tag->hdr.size != ATAG_POWERUP_REASON_SIZE) + return -EINVAL; + memcpy(&powerup_reason, &tag->u, sizeof(powerup_reason)); + printk(KERN_INFO "powerup reason=0x%08x\n", powerup_reason); + return 0; +} +__tagtable(ATAG_POWERUP_REASON, parse_tag_powerup_reason); +#define SERIAL_NUMBER_LENGTH 16 +static char usb_serial_num[SERIAL_NUMBER_LENGTH + 1]; +static int __init mot_usb_serial_num_setup(char *options) +{ + strncpy(usb_serial_num, options, SERIAL_NUMBER_LENGTH); + usb_serial_num[SERIAL_NUMBER_LENGTH] = '\0'; + printk(KERN_INFO "usb_serial_num=%s\n", usb_serial_num); return 1; } -__setup("androidboot.mode=", board_boot_mode_init); +__setup("androidboot.serialno=", mot_usb_serial_num_setup); static void stingray_gadget_init(void) { - int factory_test = !strcmp(boot_mode, "factorycable"); + struct android_usb_platform_data *platform_data; - /* use different USB configuration when in factory test mode */ - if (factory_test) { - androidusb_device.dev.platform_data = &andusb_plat_factory; + if (powerup_reason & PU_REASON_FACTORY_CABLE) + { + platform_data = &andusb_plat_factory; platform_device_register(&usbnet_device); } + else + platform_data = &andusb_plat; + + platform_data->serial_number = usb_serial_num; + androidusb_device.dev.platform_data = platform_data; platform_device_register(&androidusb_device); } + static void __init tegra_stingray_fixup(struct machine_desc *desc, struct tag *tags, char **cmdline, struct meminfo *mi) { @@ -651,9 +670,9 @@ static void __init stingray_power_off_init(void) pm_power_off = stingray_power_off; } -static int stingray_board_revision = STINGRAY_REVISION_UNKNOWN; +static unsigned int stingray_board_revision = STINGRAY_REVISION_UNKNOWN; -int stingray_revision(void) +unsigned int stingray_revision(void) { return stingray_board_revision; } @@ -668,10 +687,13 @@ static int __init stingray_revision_parse(char *options) stingray_board_revision = STINGRAY_REVISION_P1; else if (!strcmp(options, "p2")) stingray_board_revision = STINGRAY_REVISION_P2; + else + stingray_board_revision = system_rev; + + printk(KERN_INFO "hw_rev=0x%x\n", stingray_board_revision); return 1; } - __setup("hw_rev=", stingray_revision_parse); static void __init tegra_stingray_init(void) diff --git a/arch/arm/mach-tegra/board-stingray.h b/arch/arm/mach-tegra/board-stingray.h index a9d41e654483..f1e24bb2a6c2 100644 --- a/arch/arm/mach-tegra/board-stingray.h +++ b/arch/arm/mach-tegra/board-stingray.h @@ -24,15 +24,40 @@ int stingray_wlan_init(void); int stingray_sensors_init(void); int stingray_touch_init(void); int stingray_power_init(void); -int stingray_revision(void); +unsigned int stingray_revision(void); void stingray_gps_init(void); -enum { - STINGRAY_REVISION_UNKNOWN, - STINGRAY_REVISION_M1, - STINGRAY_REVISION_P0, - STINGRAY_REVISION_P1, - STINGRAY_REVISION_P2, -}; +/* as defined in the bootloader*/ +#define HWREV(x) (((x)>>16) & 0xFFFF) +#define INSTANCE(x) ((x) & 0xFFFF) +#define _HWREV(x) ((x)<<16) +#define STINGRAY_REVISION_UNKNOWN _HWREV(0x0000) +#define SSTINGRAY_REVISION_DEF _HWREV(0xFF00) +#define STINGRAY_REVISION_S1 _HWREV(0x1100) +#define STINGRAY_REVISION_S2 _HWREV(0x1200) +#define STINGRAY_REVISION_S3 _HWREV(0x1300) +#define STINGRAY_REVISION_M1 _HWREV(0x2100) +#define STINGRAY_REVISION_M2 _HWREV(0x2200) +#define STINGRAY_REVISION_M3 _HWREV(0x2300) +#define STINGRAY_REVISION_P0 _HWREV(0x8000) +#define STINGRAY_REVISION_P1 _HWREV(0x8100) +#define STINGRAY_REVISION_P2 _HWREV(0x8200) +#define STINGRAY_REVISION_P3 _HWREV(0x8300) +#define STINGRAY_REVISION_P4 _HWREV(0x8400) +#define STINGRAY_REVISION_P5 _HWREV(0x8500) +#define STINGRAY_REVISION_P6 _HWREV(0x8600) + +/* + * These #defines are used for the bits in powerup_reason. + */ +#define PU_REASON_USB_CABLE 0x00000010 /* Bit 4 */ +#define PU_REASON_FACTORY_CABLE 0x00000020 /* Bit 5 */ +#define PU_REASON_PWR_KEY_PRESS 0x00000080 /* Bit 7 */ +#define PU_REASON_CHARGER 0x00000100 /* Bit 8 */ +#define PU_REASON_POWER_CUT 0x00000200 /* bit 9 */ +#define PU_REASON_SW_AP_RESET 0x00004000 /* Bit 14 */ +#define PU_REASON_WDOG_AP_RESET 0x00008000 /* Bit 15 */ +#define PU_REASON_AP_KERNEL_PANIC 0x00020000 /* Bit 17 */ + #endif