From c383a7487b875b981c23bccb29721f047dfd8a95 Mon Sep 17 00:00:00 2001 From: Jaikumar Ganesh Date: Wed, 2 Feb 2011 22:32:39 -0800 Subject: [PATCH] [ARM] tegra: stingray: Use WL_REG_ON GPIO for BT BT was using BT_REG_ON and Wlan was using WL_REG_ON. 4329 ORs both these GPIOs. However, there are problems with BT_REG_ON while coming out of LP0 suspend. So temporaraily have both wifi and BT use the same GPIO for power on. For BT, set the BT_REG_ON to output low. Change-Id: I75606ba124418fc7c606b434e4b7968fbc046228 Signed-off-by: Jaikumar Ganesh --- .../arm/mach-tegra/board-stingray-bluetooth.c | 5 +++- arch/arm/mach-tegra/board-stingray-wifi.c | 7 +---- arch/arm/mach-tegra/board-stingray.c | 28 +++++++++++++++++++ arch/arm/mach-tegra/board-stingray.h | 1 + 4 files changed, 34 insertions(+), 7 deletions(-) diff --git a/arch/arm/mach-tegra/board-stingray-bluetooth.c b/arch/arm/mach-tegra/board-stingray-bluetooth.c index 45c72bcc7a70..f4419c3874bb 100644 --- a/arch/arm/mach-tegra/board-stingray-bluetooth.c +++ b/arch/arm/mach-tegra/board-stingray-bluetooth.c @@ -38,6 +38,7 @@ #define BT_WAKE_GPIO TEGRA_GPIO_PU1 #define BT_HOST_WAKE_GPIO TEGRA_GPIO_PU6 +extern void change_power_brcm_4329(bool); static struct rfkill *bt_rfkill; struct bcm_bt_lpm { @@ -58,9 +59,11 @@ static int bcm4329_bt_rfkill_set_power(void *data, bool blocked) { // rfkill_ops callback. Turn transmitter on when blocked is false if (!blocked) { + change_power_brcm_4329(true); gpio_direction_output(BT_RESET_GPIO, 1); - gpio_direction_output(BT_SHUTDOWN_GPIO, 1); + gpio_direction_output(BT_SHUTDOWN_GPIO, 0); } else { + change_power_brcm_4329(false); gpio_direction_output(BT_SHUTDOWN_GPIO, 0); gpio_direction_output(BT_RESET_GPIO, 0); } diff --git a/arch/arm/mach-tegra/board-stingray-wifi.c b/arch/arm/mach-tegra/board-stingray-wifi.c index 5c37461b09e3..82a001803ff9 100644 --- a/arch/arm/mach-tegra/board-stingray-wifi.c +++ b/arch/arm/mach-tegra/board-stingray-wifi.c @@ -21,7 +21,6 @@ #include "gpio-names.h" #define STINGRAY_WLAN_IRQ TEGRA_GPIO_PU5 -#define STINGRAY_WLAN_PWR TEGRA_GPIO_PU4 #define STINGRAY_WLAN_RST TEGRA_GPIO_PU2 #define ATAG_STINGRAY_MAC 0x57464d41 @@ -158,7 +157,7 @@ static int stingray_wifi_power(int on) pr_debug("%s: %d\n", __func__, on); mdelay(100); - gpio_set_value(STINGRAY_WLAN_PWR, on); + change_power_brcm_4329(on); mdelay(100); gpio_set_value(STINGRAY_WLAN_RST, on); mdelay(200); @@ -238,10 +237,6 @@ static struct platform_device stingray_wifi_device = { static void __init stingray_wlan_gpio(void) { - tegra_gpio_enable(STINGRAY_WLAN_PWR); - gpio_request(STINGRAY_WLAN_PWR, "wlan_pwr"); - gpio_direction_output(STINGRAY_WLAN_PWR, 0); - tegra_gpio_enable(STINGRAY_WLAN_RST); gpio_request(STINGRAY_WLAN_RST, "wlan_rst"); gpio_direction_output(STINGRAY_WLAN_RST, 0); diff --git a/arch/arm/mach-tegra/board-stingray.c b/arch/arm/mach-tegra/board-stingray.c index 6452ae054ec2..dc46ee5f89fd 100644 --- a/arch/arm/mach-tegra/board-stingray.c +++ b/arch/arm/mach-tegra/board-stingray.c @@ -658,6 +658,9 @@ static int __init parse_tag_bdaddr(const struct tag *tag) } __tagtable(ATAG_BDADDR, parse_tag_bdaddr); +static DEFINE_SPINLOCK(brcm_4329_enable_lock); +static int brcm_4329_enable_count; + static void stingray_w1_init(void) { tegra_w1_device.dev.platform_data = &tegra_w1_pdata; @@ -888,6 +891,26 @@ static void init_dac2(bool bluetooth) } } +void change_power_brcm_4329(bool enable) { + unsigned long flags; + + spin_lock_irqsave(&brcm_4329_enable_lock, flags); + if (enable) { + gpio_set_value(TEGRA_GPIO_PU4, enable); + brcm_4329_enable_count++; + // The following shouldn't happen but protect + // if the user doesn't cleanup. + if (brcm_4329_enable_count > 2) + brcm_4329_enable_count = 2; + } else { + if (brcm_4329_enable_count > 0) + brcm_4329_enable_count--; + if (!brcm_4329_enable_count) + gpio_set_value(TEGRA_GPIO_PU4, enable); + } + spin_unlock_irqrestore(&brcm_4329_enable_lock, flags); +} + static void __init tegra_stingray_init(void) { struct clk *clk; @@ -995,6 +1018,11 @@ static void __init tegra_stingray_init(void) tegra_dvfs_rail_disable_by_name("vdd_core"); } + /* Enable 4329 Power GPIO */ + tegra_gpio_enable(TEGRA_GPIO_PU4); + gpio_request(TEGRA_GPIO_PU4, "4329_pwr"); + gpio_direction_output(TEGRA_GPIO_PU4, 0); + stingray_pinmux_init(); tegra_clk_init_from_table(stingray_clk_init_table); diff --git a/arch/arm/mach-tegra/board-stingray.h b/arch/arm/mach-tegra/board-stingray.h index 33353ddf63cd..0c1b790935dc 100644 --- a/arch/arm/mach-tegra/board-stingray.h +++ b/arch/arm/mach-tegra/board-stingray.h @@ -31,6 +31,7 @@ unsigned int stingray_powerup_reason (void); void stingray_gps_init(void); int stingray_qbp_usb_hw_bypass_enabled(void); void stingray_init_emc(void); +void change_power_brcm_4329(bool); /* as defined in the bootloader*/ #define HWREV(x) (((x)>>16) & 0xFFFF) -- 2.34.1