aboutsummaryrefslogtreecommitdiff
path: root/arch/arm
diff options
context:
space:
mode:
Diffstat (limited to 'arch/arm')
-rw-r--r--arch/arm/mach-s3c2440/mach-gta02.c30
-rw-r--r--arch/arm/plat-s3c24xx/Makefile1
-rw-r--r--arch/arm/plat-s3c24xx/gta02_pm_wlan.c142
3 files changed, 149 insertions, 24 deletions
diff --git a/arch/arm/mach-s3c2440/mach-gta02.c b/arch/arm/mach-s3c2440/mach-gta02.c
index 302cdd95cef..0ccb7fba850 100644
--- a/arch/arm/mach-s3c2440/mach-gta02.c
+++ b/arch/arm/mach-s3c2440/mach-gta02.c
@@ -554,6 +554,10 @@ static void gta02_pcf50633_attach_child_devices(struct device *parent_device)
platform_device_register(&gta01_pm_gps_dev);
}
+static struct platform_device gta02_pm_wlan_dev = {
+ .name = "gta02-pm-wlan",
+};
+
static struct pcf50633_platform_data gta02_pcf_pdata = {
.used_features = PCF50633_FEAT_MBC |
PCF50633_FEAT_BBC |
@@ -869,6 +873,7 @@ static struct platform_device *gta02_devices[] __initdata = {
&gta02_memconfig_device,
&gta02_resume_reason_device,
&s3c24xx_pwm_device,
+ &gta02_pm_wlan_dev, /* not dependent on PMU */
};
@@ -1605,30 +1610,7 @@ static void __init gta02_machine_init(void)
s3c24xx_udc_set_platdata(&gta02_udc_cfg);
set_s3c2410ts_info(&gta02_ts_cfg);
-
- /* FIXME: hardcoded WLAN module power-up */
- s3c2410_gpio_cfgpin(GTA02_CHIP_PWD, S3C2410_GPIO_OUTPUT);
-
- /* Power is down */
- s3c2410_gpio_setpin(GTA02_CHIP_PWD, 1);
- mdelay(100);
-
- switch (system_rev) {
- case GTA02v1_SYSTEM_REV:
- s3c2410_gpio_setpin(GTA02_CHIP_PWD, 0);
- break;
- default:
- /* Chip is in reset state */
- s3c2410_gpio_setpin(GTA02_GPIO_nWLAN_RESET, 0);
- s3c2410_gpio_cfgpin(GTA02_GPIO_nWLAN_RESET, S3C2410_GPIO_OUTPUT);
- mdelay(100);
- /* Power is up */
- s3c2410_gpio_setpin(GTA02_CHIP_PWD, 0);
- mdelay(100);
- /* Chip is out of reset */
- s3c2410_gpio_setpin(GTA02_GPIO_nWLAN_RESET, 1);
- break;
- }
+
mangle_glamo_res_by_system_rev();
platform_device_register(&gta02_glamo_dev);
diff --git a/arch/arm/plat-s3c24xx/Makefile b/arch/arm/plat-s3c24xx/Makefile
index fafd153374f..065b951aa3b 100644
--- a/arch/arm/plat-s3c24xx/Makefile
+++ b/arch/arm/plat-s3c24xx/Makefile
@@ -48,6 +48,7 @@ obj-$(CONFIG_MACH_NEO1973) += neo1973_version.o \
neo1973_pm_gsm.o \
neo1973_pm_gps.o \
neo1973_pm_bt.o \
+ gta02_pm_wlan.o \
neo1973_shadow.o \
neo1973_pm_resume_reason.o \
neo1973_memconfig.o
diff --git a/arch/arm/plat-s3c24xx/gta02_pm_wlan.c b/arch/arm/plat-s3c24xx/gta02_pm_wlan.c
new file mode 100644
index 00000000000..954015e4c71
--- /dev/null
+++ b/arch/arm/plat-s3c24xx/gta02_pm_wlan.c
@@ -0,0 +1,142 @@
+/*
+ * GTA02 WLAN power management
+ *
+ * (C) 2008 by Openmoko Inc.
+ * Author: Andy Green <andy@openmoko.com>
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation
+ *
+ */
+
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/kernel.h>
+#include <linux/platform_device.h>
+
+#include <mach/hardware.h>
+#include <asm/mach-types.h>
+#include <asm/plat-s3c24xx/neo1973.h>
+
+#include <mach/gta02.h>
+#include <mach/regs-gpio.h>
+#include <mach/regs-gpioj.h>
+
+#include <linux/delay.h>
+
+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;
+
+ if (!on) {
+ s3c2410_gpio_setpin(GTA02_CHIP_PWD, 1);
+ s3c2410_gpio_setpin(GTA02_GPIO_nWLAN_RESET, 0);
+
+ return count;
+ }
+
+ /* 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);
+
+ 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)
+{
+ dev_dbg(&pdev->dev, "suspending\n");
+
+ return 0;
+}
+
+static int gta02_wlan_resume(struct platform_device *pdev)
+{
+ dev_dbg(&pdev->dev, "resuming\n");
+
+ return 0;
+}
+#else
+#define gta02_wlan_suspend NULL
+#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,
+};
+
+static int __init gta02_wlan_probe(struct platform_device *pdev)
+{
+ if (!machine_is_neo1973_gta02())
+ return -EINVAL;
+
+ dev_info(&pdev->dev, "starting\n");
+
+ /* Power is down */
+ s3c2410_gpio_setpin(GTA02_CHIP_PWD, 1);
+ s3c2410_gpio_cfgpin(GTA02_CHIP_PWD, S3C2410_GPIO_OUTPUT);
+ /* reset is asserted */
+ s3c2410_gpio_setpin(GTA02_GPIO_nWLAN_RESET, 0);
+ s3c2410_gpio_cfgpin(GTA02_GPIO_nWLAN_RESET, S3C2410_GPIO_OUTPUT);
+
+ return sysfs_create_group(&pdev->dev.kobj, &gta02_wlan_attr_group);
+}
+
+static int gta02_wlan_remove(struct platform_device *pdev)
+{
+ sysfs_remove_group(&pdev->dev.kobj, &gta02_wlan_attr_group);
+
+ return 0;
+}
+
+static struct platform_driver gta02_wlan_driver = {
+ .probe = gta02_wlan_probe,
+ .remove = gta02_wlan_remove,
+ .suspend = gta02_wlan_suspend,
+ .resume = gta02_wlan_resume,
+ .driver = {
+ .name = "gta02-pm-wlan",
+ },
+};
+
+static int __devinit gta02_wlan_init(void)
+{
+ return platform_driver_register(&gta02_wlan_driver);
+}
+
+static void gta02_wlan_exit(void)
+{
+ platform_driver_unregister(&gta02_wlan_driver);
+}
+
+module_init(gta02_wlan_init);
+module_exit(gta02_wlan_exit);
+
+MODULE_LICENSE("GPL");
+MODULE_AUTHOR("Andy Green <andy@openmoko.com>");
+MODULE_DESCRIPTION("Openmoko GTA02 WLAN power management");