diff options
author | Werner Almesberger <werner@openmoko.org> | 2009-01-19 01:18:06 +0000 |
---|---|---|
committer | Andy Green <agreen@octopus.localdomain> | 2009-01-19 01:18:06 +0000 |
commit | d1184dc21448404d2e274ce5a5a95b98878a624f (patch) | |
tree | 0b3ec65f9a6de67d0ae0f295a29c86ade03bbe7f /arch | |
parent | cde71aa787eb9f986c04da58e9f9130be2ac52eb (diff) |
clean up GTA02 WLAN power control
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 <werner@openmoko.org>
Diffstat (limited to 'arch')
-rw-r--r-- | arch/arm/mach-s3c2410/include/mach/gta02-pm-wlan.h | 2 | ||||
-rw-r--r-- | arch/arm/mach-s3c2440/mach-gta02.c | 10 | ||||
-rw-r--r-- | arch/arm/plat-s3c24xx/gta02_pm_wlan.c | 73 |
3 files changed, 15 insertions, 70 deletions
diff --git a/arch/arm/mach-s3c2410/include/mach/gta02-pm-wlan.h b/arch/arm/mach-s3c2410/include/mach/gta02-pm-wlan.h index 5a224fe036b..48369789709 100644 --- a/arch/arm/mach-s3c2410/include/mach/gta02-pm-wlan.h +++ b/arch/arm/mach-s3c2410/include/mach/gta02-pm-wlan.h @@ -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); diff --git a/arch/arm/mach-s3c2440/mach-gta02.c b/arch/arm/mach-s3c2440/mach-gta02.c index cff7affa0d7..a32a11e3135 100644 --- a/arch/arm/mach-s3c2440/mach-gta02.c +++ b/arch/arm/mach-s3c2440/mach-gta02.c @@ -955,9 +955,13 @@ static struct s3c2410_platform_nand gta02_nand_info = { 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; } diff --git a/arch/arm/plat-s3c24xx/gta02_pm_wlan.c b/arch/arm/plat-s3c24xx/gta02_pm_wlan.c index 419b3f77403..00f27d8bb47 100644 --- a/arch/arm/plat-s3c24xx/gta02_pm_wlan.c +++ b/arch/arm/plat-s3c24xx/gta02_pm_wlan.c @@ -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 @@ static int gta02_wlan_resume(struct platform_device *pdev) #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 @@ static int __init gta02_wlan_probe(struct platform_device *pdev) 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 @@ static int __init gta02_wlan_probe(struct platform_device *pdev) return error; } - error = sysfs_create_group(&pdev->dev.kobj, >a02_wlan_attr_group); - if (error) { - rfkill_free(rfkill); - return error; - } - dev_set_drvdata(&pdev->dev, rfkill); return 0; @@ -248,8 +191,6 @@ static int gta02_wlan_remove(struct platform_device *pdev) rfkill_unregister(rfkill); rfkill_free(rfkill); - sysfs_remove_group(&pdev->dev.kobj, >a02_wlan_attr_group); - return 0; } |