[PATCH 2/3] deglitch-wlan-power-control.patch

Werner Almesberger werner at openmoko.org
Sat Nov 22 04:16:26 CET 2008


gta02_wlan_power(1) causes a reset each time it's invoked, even if the
device was not turned off.

This causes problems if we use the set_power callback from s3cmci,
because it will try to turn on power even when the device is already
operational.

This patch makes sure we only reset the WLAN if the device was off or
if we don't know the current state.

Doing the "deglitching" in gta02_wlan_power instead of the set_power
handler has the advantage that we're synchronized with any other
agents that may change WLAN power.

Signed-off-by: Werner Almesberger <werner at openmoko.org>

---

Index: ktrack/arch/arm/plat-s3c24xx/gta02_pm_wlan.c
===================================================================
--- ktrack.orig/arch/arm/plat-s3c24xx/gta02_pm_wlan.c	2008-11-21 23:23:23.000000000 -0200
+++ ktrack/arch/arm/plat-s3c24xx/gta02_pm_wlan.c	2008-11-22 00:33:13.000000000 -0200
@@ -14,6 +14,7 @@
 #include <linux/module.h>
 #include <linux/init.h>
 #include <linux/kernel.h>
+#include <linux/mutex.h>
 #include <linux/platform_device.h>
 
 #include <mach/hardware.h>
@@ -27,7 +28,7 @@
 #include <linux/delay.h>
 
 
-static void gta02_wlan_power(int on)
+static void __gta02_wlan_power(int on)
 {
 	if (!on) {
 		s3c2410_gpio_setpin(GTA02_CHIP_PWD, 1);
@@ -43,7 +44,19 @@
 	s3c2410_gpio_setpin(GTA02_CHIP_PWD, 0);
 	msleep(100);
 	s3c2410_gpio_setpin(GTA02_GPIO_nWLAN_RESET, 1);
+}
+
+static void gta02_wlan_power(int on)
+{
+	static DEFINE_MUTEX(lock);
+	static int is_on = -1; /* initial state is unknown */
 
+	on = !!on; /* normalize */
+	mutex_lock(&lock);
+	if (on != is_on)
+		__gta02_wlan_power(on);
+	is_on = on;
+	mutex_unlock(&lock);
 }
 
 static ssize_t gta02_wlan_read(struct device *dev,



More information about the openmoko-kernel mailing list