summaryrefslogtreecommitdiff
path: root/arch
diff options
context:
space:
mode:
authorChris Ball <cjb@laptop.org>2008-06-13 20:05:47 -0400
committerDeepak Saxena <dsaxena@laptop.org>2008-06-18 11:40:12 -0700
commitbc6e17b62bdb171efdaa6660584e852e181b928d (patch)
tree6ea51f4286323fcbee749dc0e866af9cc33aedad /arch
parentbf7f6899971bebfe884a4e70efc78b02e6bd508f (diff)
downloadlwn-bc6e17b62bdb171efdaa6660584e852e181b928d.tar.gz
lwn-bc6e17b62bdb171efdaa6660584e852e181b928d.zip
[PATCH #3355] Add sysfs support for powering down the OLPC 88W8838 wireless chip
This uses the OLPC EC 0x35/0x25 interface. Signed-off-by: Chris Ball <cjb@laptop.org> Signed-off-by: Deepak Saxena <dsaxena@laptop.org>
Diffstat (limited to 'arch')
-rw-r--r--arch/x86/kernel/olpc-pm.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/arch/x86/kernel/olpc-pm.c b/arch/x86/kernel/olpc-pm.c
index 19d34aa42d26..5a15dfd7e4e3 100644
--- a/arch/x86/kernel/olpc-pm.c
+++ b/arch/x86/kernel/olpc-pm.c
@@ -43,6 +43,8 @@
/* These, and the battery EC commands, should be in an olpc.h. */
#define EC_WRITE_SCI_MASK 0x1b
#define EC_READ_SCI_MASK 0x1c
+#define EC_WLAN_ENTER_RESET 0x35
+#define EC_WLAN_LEAVE_RESET 0x25
extern void do_olpc_suspend_lowlevel(void);
@@ -69,6 +71,8 @@ static u16 olpc_wakeup_mask = 0;
static unsigned int test_timeout = 0;
static char *wackup_source = "none";
+static unsigned int wlan_enabled = 1;
+
struct platform_device olpc_powerbutton_dev = {
.name = "powerbutton",
.id = -1,
@@ -661,6 +665,30 @@ static ssize_t wackup_show(struct kobject *s, struct kobj_attribute *attr,
return sprintf(buf, "%s\n", wackup_source ? wackup_source : "none");
}
+static ssize_t wlan_enabled_show(struct kobject *s, struct kobj_attribute *attr,
+ char *buf)
+{
+ return sprintf(buf, "%u\n", wlan_enabled);
+}
+
+static ssize_t wlan_enabled_store(struct kobject *s, struct kobj_attribute *attr,
+ const char *buf, size_t n)
+{
+ unsigned int val;
+ if (!sscanf(buf, "%u", &val) == 1) {
+ return -EINVAL;
+ }
+ if (val == 1) {
+ olpc_ec_cmd(EC_WLAN_LEAVE_RESET, NULL, 0, NULL, 0);
+ wlan_enabled = 1;
+ }
+ else if (val == 0) {
+ olpc_ec_cmd(EC_WLAN_ENTER_RESET, NULL, 0, NULL, 0);
+ wlan_enabled = 0;
+ }
+ return n;
+}
+
static struct kobj_attribute control_attr =
__ATTR(olpc-pm, 0644, control_show, control_store);
@@ -670,10 +698,14 @@ static struct kobj_attribute test_attr =
static struct kobj_attribute wackup_attr =
__ATTR(wakeup-source, 0400, wackup_show, NULL);
+static struct kobj_attribute wlanenabled_attr =
+ __ATTR(wlan-enabled, 0644, wlan_enabled_show, wlan_enabled_store);
+
static struct attribute * olpc_attributes[] = {
&control_attr.attr,
&test_attr.attr,
&wackup_attr.attr,
+ &wlanenabled_attr.attr,
NULL
};