From 400d3a1746534ceaf3c32565fadee4e51816df1b Mon Sep 17 00:00:00 2001 From: John Michelau Date: Sun, 21 Nov 2010 18:23:28 -0600 Subject: [PATCH] ARM: tegra: stingray: Disable USB detect when BP USB HW Bypass The bootloader sets up a switch in this mode to reroute the QCOM BP USB out of stingray's external USB connector. We must disable the AP-side drivers in this mode, otherwise they interfere with the BP's usage of the external USB. Change-Id: Ib6cdd47be930781034f27095baff8c7a229469a6 Signed-off-by: Benoit Goby --- arch/arm/mach-tegra/board-stingray-power.c | 4 +++- arch/arm/mach-tegra/board-stingray.c | 23 ++++++++++++++++++---- arch/arm/mach-tegra/board-stingray.h | 1 + 3 files changed, 23 insertions(+), 5 deletions(-) diff --git a/arch/arm/mach-tegra/board-stingray-power.c b/arch/arm/mach-tegra/board-stingray-power.c index 6fc003efebeb..0ad1beea4eab 100644 --- a/arch/arm/mach-tegra/board-stingray-power.c +++ b/arch/arm/mach-tegra/board-stingray-power.c @@ -270,7 +270,6 @@ static struct platform_device cpcap_notification_led = { static struct platform_device *cpcap_devices[] = { &cpcap_validity_device, - &cpcap_whisper_device, &cpcap_notification_led, &cpcap_privacy_led, &cpcap_3mm5_device, @@ -720,6 +719,9 @@ int __init stingray_power_init(void) for (i = 0; i < ARRAY_SIZE(cpcap_devices); i++) cpcap_device_register(cpcap_devices[i]); + if (!stingray_qbp_usb_hw_bypass_enabled()) + cpcap_device_register(&cpcap_whisper_device); + (void) cpcap_driver_register(&cpcap_validity_driver); i2c_register_board_info(3, stingray_i2c_bus4_power_info, diff --git a/arch/arm/mach-tegra/board-stingray.c b/arch/arm/mach-tegra/board-stingray.c index 77ef3c92251b..aa2f03453b1b 100644 --- a/arch/arm/mach-tegra/board-stingray.c +++ b/arch/arm/mach-tegra/board-stingray.c @@ -893,6 +893,19 @@ static int __init stingray_revision_parse(char *options) } __setup("hw_rev=", stingray_revision_parse); +int stingray_qbp_usb_hw_bypass_enabled(void) +{ + /* We could use the boot_mode string instead of probing the HW, but + * that would not work if we enable run-time switching to this mode + * in the future. + */ + if (gpio_get_value(TEGRA_GPIO_PT3) && !gpio_get_value(TEGRA_GPIO_PV4)) { + pr_info("stingray_qbp_usb_hw_bypass enabled\n"); + return 1; + } + return 0; +} + static struct tegra_suspend_platform_data stingray_suspend = { .cpu_timer = 1500, .cpu_off_timer = 1, @@ -950,13 +963,15 @@ static void __init tegra_stingray_init(void) tegra_common_init(); tegra_init_suspend(&stingray_suspend); - /* Stingray has a USB switch that disconnects the usb port from the AP20 + /* Stingray has a USB switch that disconnects the usb port from the T20 unless a factory cable is used, the factory jumper is set, or the usb_data_en gpio is set. */ - tegra_gpio_enable(TEGRA_GPIO_PV4); - gpio_request(TEGRA_GPIO_PV4, "usb_data_en"); - gpio_direction_output(TEGRA_GPIO_PV4, 1); + if (!stingray_qbp_usb_hw_bypass_enabled()) { + tegra_gpio_enable(TEGRA_GPIO_PV4); + gpio_request(TEGRA_GPIO_PV4, "usb_data_en"); + gpio_direction_output(TEGRA_GPIO_PV4, 1); + } /* USB_FORCEON_N (TEGRA_GPIO_PC5) should be forced high at boot and will be pulled low by the hardware on attach */ diff --git a/arch/arm/mach-tegra/board-stingray.h b/arch/arm/mach-tegra/board-stingray.h index be6d9696819c..9a107ae5ee2f 100644 --- a/arch/arm/mach-tegra/board-stingray.h +++ b/arch/arm/mach-tegra/board-stingray.h @@ -29,6 +29,7 @@ int stingray_power_init(void); unsigned int stingray_revision(void); unsigned int stingray_powerup_reason (void); void stingray_gps_init(void); +int stingray_qbp_usb_hw_bypass_enabled(void); /* as defined in the bootloader*/ #define HWREV(x) (((x)>>16) & 0xFFFF) -- 2.34.1