This patch cleans up the GTA02 WLAN power control platform device:

- remove misleading /sys/devices/platform/gta02-pm-wlan.0/power_on
  Users really wishing to play with reset can just  gpio j12=0

- rename gta02_wlan_power to gta02_wlan_reset, because that's what it
  truly is

- remove handling of GTA02_CHIP_PWD because
  - it's not used, say our schematics
  - even if it is, it's sampled long before we could affect it

- move SDIO-specific conversion from "power switch" to "reset
  button" logic from gta02_wlan_reset to gta02_s3c_mmc_set_power

- removed mutex protection because we now only have a single user

A note in passing: we can probably do away with gta02_pm_wlan
completely once upstream rfkill adds better support for type-based
control.

Signed-off-by: Werner Almesberger <[email protected]>

---

Index: ktrack/arch/arm/plat-s3c24xx/gta02_pm_wlan.c
===================================================================
--- ktrack.orig/arch/arm/plat-s3c24xx/gta02_pm_wlan.c   2009-01-16 
19:13:10.000000000 -0200
+++ ktrack/arch/arm/plat-s3c24xx/gta02_pm_wlan.c        2009-01-16 
20:28:04.000000000 -0200
@@ -33,57 +33,16 @@
 /* ----- Module hardware reset ("power") ----------------------------------- */
 
 
-static void __gta02_wlan_power(int on)
+void gta02_wlan_reset(int assert_reset)
 {
-       if (!on) {
-               s3c2410_gpio_setpin(GTA02_CHIP_PWD, 1);
+       if (assert_reset) {
                s3c2410_gpio_setpin(GTA02_GPIO_nWLAN_RESET, 0);
-               return;
+               msleep(200); /* probably excessive but we don't have specs */
+       } else {
+               s3c2410_gpio_setpin(GTA02_GPIO_nWLAN_RESET, 1);
        }
-
-       /* power up sequencing */
-
-       s3c2410_gpio_setpin(GTA02_CHIP_PWD, 1);
-       s3c2410_gpio_setpin(GTA02_GPIO_nWLAN_RESET, 0);
-       msleep(100);
-       s3c2410_gpio_setpin(GTA02_CHIP_PWD, 0);
-       msleep(100);
-       s3c2410_gpio_setpin(GTA02_GPIO_nWLAN_RESET, 1);
 }
 
-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,
-                                      struct device_attribute *attr, char *buf)
-{
-       if (s3c2410_gpio_getpin(GTA02_CHIP_PWD))
-               return strlcpy(buf, "0\n", 3);
-
-       return strlcpy(buf, "1\n", 3);
-}
-
-static ssize_t gta02_wlan_write(struct device *dev,
-                  struct device_attribute *attr, const char *buf, size_t count)
-{
-       unsigned long on = simple_strtoul(buf, NULL, 10) & 1;
-
-       gta02_wlan_power(on);
-       return count;
-}
-
-static DEVICE_ATTR(power_on, 0644, gta02_wlan_read, gta02_wlan_write);
-
 #ifdef CONFIG_PM
 static int gta02_wlan_suspend(struct platform_device *pdev, pm_message_t state)
 {
@@ -103,16 +62,6 @@
 #define gta02_wlan_resume              NULL
 #endif
 
-static struct attribute *gta02_wlan_sysfs_entries[] = {
-       &dev_attr_power_on.attr,
-       NULL
-};
-
-static struct attribute_group gta02_wlan_attr_group = {
-       .name   = NULL,
-       .attrs  = gta02_wlan_sysfs_entries,
-};
-
 
 /* ----- rfkill ------------------------------------------------------------ */
 
@@ -207,9 +156,9 @@
 
        dev_info(&pdev->dev, "starting\n");
 
-       s3c2410_gpio_cfgpin(GTA02_CHIP_PWD, S3C2410_GPIO_OUTPUT);
        s3c2410_gpio_cfgpin(GTA02_GPIO_nWLAN_RESET, S3C2410_GPIO_OUTPUT);
-       gta02_wlan_power(1);
+       gta02_wlan_reset(1);
+       gta02_wlan_reset(0);
 
        rfkill = rfkill_allocate(&pdev->dev, RFKILL_TYPE_WLAN);
        rfkill->name = "ar6000";
@@ -230,12 +179,6 @@
                return error;
        }
 
-       error = sysfs_create_group(&pdev->dev.kobj, &gta02_wlan_attr_group);
-       if (error) {
-               rfkill_free(rfkill);
-               return error;
-       }
-
        dev_set_drvdata(&pdev->dev, rfkill);
 
        return 0;
@@ -248,8 +191,6 @@
        rfkill_unregister(rfkill);
        rfkill_free(rfkill);
 
-       sysfs_remove_group(&pdev->dev.kobj, &gta02_wlan_attr_group);
-
        return 0;
 }
 
Index: ktrack/arch/arm/mach-s3c2410/include/mach/gta02-pm-wlan.h
===================================================================
--- ktrack.orig/arch/arm/mach-s3c2410/include/mach/gta02-pm-wlan.h      
2009-01-16 19:13:10.000000000 -0200
+++ ktrack/arch/arm/mach-s3c2410/include/mach/gta02-pm-wlan.h   2009-01-16 
20:18:44.000000000 -0200
@@ -1,7 +1,7 @@
 #ifndef __MACH_GTA02_PM_WLAN_H
 #define __MACH_GTA02_PM_WLAN_H
 
-void gta02_wlan_power(int on);
+void gta02_wlan_reset(int assert_reset);
 int gta02_wlan_query_rfkill_lock(void);
 void gta02_wlan_query_rfkill_unlock(void);
 void gta02_wlan_set_rfkill_cb(int (*cb)(void *user, int on), void *user);
Index: ktrack/arch/arm/mach-s3c2440/mach-gta02.c
===================================================================
--- ktrack.orig/arch/arm/mach-s3c2440/mach-gta02.c      2009-01-16 
19:13:10.000000000 -0200
+++ ktrack/arch/arm/mach-s3c2440/mach-gta02.c   2009-01-16 20:28:58.000000000 
-0200
@@ -955,9 +955,13 @@
 static void gta02_s3c_mmc_set_power(unsigned char power_mode,
     unsigned short vdd)
 {
-       gta02_wlan_power(
-           power_mode == MMC_POWER_ON ||
-           power_mode == MMC_POWER_UP);
+       static int is_on = -1;
+       int on;
+
+       on = power_mode == MMC_POWER_ON || power_mode == MMC_POWER_UP;
+       if (is_on != on)
+               gta02_wlan_reset(!on);
+       is_on = on;
 }
 
 

Reply via email to