aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIke Panhc <ike.pan@canonical.com>2011-06-30 07:50:40 -0400
committerMatthew Garrett <mjg@redhat.com>2011-08-05 14:45:42 -0400
commit3371f48167e04017125dd08cc1f70fa93d2f2e17 (patch)
treea45b029f0a64e44f2b731a6fba0954c0f9ce8ba5
parent33009557bd9397c446a59e4cc91059a8e84c046b (diff)
ideapad: define cfg bits and create sysfs node for cfg
Create /sys/devices/platform/ideapad/cfg for showing cfg value. Signed-off-by: Ike Panhc <ike.pan@canonical.com> Signed-off-by: Matthew Garrett <mjg@redhat.com>
-rw-r--r--Documentation/ABI/testing/sysfs-platform-ideapad-laptop17
-rw-r--r--drivers/platform/x86/ideapad-laptop.c51
2 files changed, 52 insertions, 16 deletions
diff --git a/Documentation/ABI/testing/sysfs-platform-ideapad-laptop b/Documentation/ABI/testing/sysfs-platform-ideapad-laptop
index 807fca2ae2a4..ff53183c3848 100644
--- a/Documentation/ABI/testing/sysfs-platform-ideapad-laptop
+++ b/Documentation/ABI/testing/sysfs-platform-ideapad-laptop
@@ -4,3 +4,20 @@ KernelVersion: 2.6.37
4Contact: "Ike Panhc <ike.pan@canonical.com>" 4Contact: "Ike Panhc <ike.pan@canonical.com>"
5Description: 5Description:
6 Control the power of camera module. 1 means on, 0 means off. 6 Control the power of camera module. 1 means on, 0 means off.
7
8What: /sys/devices/platform/ideapad/cfg
9Date: Jun 2011
10KernelVersion: 3.1
11Contact: "Ike Panhc <ike.pan@canonical.com>"
12Description:
13 Ideapad capability bits.
14 Bit 8-10: 1 - Intel graphic only
15 2 - ATI graphic only
16 3 - Nvidia graphic only
17 4 - Intel and ATI graphic
18 5 - Intel and Nvidia graphic
19 Bit 16: Bluetooth exist (1 for exist)
20 Bit 17: 3G exist (1 for exist)
21 Bit 18: Wifi exist (1 for exist)
22 Bit 19: Camera exist (1 for exist)
23
diff --git a/drivers/platform/x86/ideapad-laptop.c b/drivers/platform/x86/ideapad-laptop.c
index bfdda33feb26..42b9ba7e903c 100644
--- a/drivers/platform/x86/ideapad-laptop.c
+++ b/drivers/platform/x86/ideapad-laptop.c
@@ -35,10 +35,15 @@
35 35
36#define IDEAPAD_RFKILL_DEV_NUM (3) 36#define IDEAPAD_RFKILL_DEV_NUM (3)
37 37
38#define CFG_BT_BIT (16)
39#define CFG_3G_BIT (17)
40#define CFG_WIFI_BIT (18)
41
38struct ideapad_private { 42struct ideapad_private {
39 struct rfkill *rfk[IDEAPAD_RFKILL_DEV_NUM]; 43 struct rfkill *rfk[IDEAPAD_RFKILL_DEV_NUM];
40 struct platform_device *platform_device; 44 struct platform_device *platform_device;
41 struct input_dev *inputdev; 45 struct input_dev *inputdev;
46 unsigned long cfg;
42}; 47};
43 48
44static acpi_handle ideapad_handle; 49static acpi_handle ideapad_handle;
@@ -155,7 +160,7 @@ static int write_ec_cmd(acpi_handle handle, int cmd, unsigned long data)
155} 160}
156 161
157/* 162/*
158 * camera power 163 * sysfs
159 */ 164 */
160static ssize_t show_ideapad_cam(struct device *dev, 165static ssize_t show_ideapad_cam(struct device *dev,
161 struct device_attribute *attr, 166 struct device_attribute *attr,
@@ -186,6 +191,27 @@ static ssize_t store_ideapad_cam(struct device *dev,
186 191
187static DEVICE_ATTR(camera_power, 0644, show_ideapad_cam, store_ideapad_cam); 192static DEVICE_ATTR(camera_power, 0644, show_ideapad_cam, store_ideapad_cam);
188 193
194static ssize_t show_ideapad_cfg(struct device *dev,
195 struct device_attribute *attr,
196 char *buf)
197{
198 struct ideapad_private *priv = dev_get_drvdata(dev);
199
200 return sprintf(buf, "0x%.8lX\n", priv->cfg);
201}
202
203static DEVICE_ATTR(cfg, 0444, show_ideapad_cfg, NULL);
204
205static struct attribute *ideapad_attributes[] = {
206 &dev_attr_camera_power.attr,
207 &dev_attr_cfg.attr,
208 NULL
209};
210
211static struct attribute_group ideapad_attribute_group = {
212 .attrs = ideapad_attributes
213};
214
189/* 215/*
190 * Rfkill 216 * Rfkill
191 */ 217 */
@@ -197,9 +223,9 @@ struct ideapad_rfk_data {
197}; 223};
198 224
199const struct ideapad_rfk_data ideapad_rfk_data[] = { 225const struct ideapad_rfk_data ideapad_rfk_data[] = {
200 { "ideapad_wlan", 18, 0x15, RFKILL_TYPE_WLAN }, 226 { "ideapad_wlan", CFG_WIFI_BIT, 0x15, RFKILL_TYPE_WLAN },
201 { "ideapad_bluetooth", 16, 0x17, RFKILL_TYPE_BLUETOOTH }, 227 { "ideapad_bluetooth", CFG_BT_BIT, 0x17, RFKILL_TYPE_BLUETOOTH },
202 { "ideapad_3g", 17, 0x20, RFKILL_TYPE_WWAN }, 228 { "ideapad_3g", CFG_3G_BIT, 0x20, RFKILL_TYPE_WWAN },
203}; 229};
204 230
205static int ideapad_rfk_set(void *data, bool blocked) 231static int ideapad_rfk_set(void *data, bool blocked)
@@ -280,15 +306,6 @@ static void __devexit ideapad_unregister_rfkill(struct acpi_device *adevice,
280/* 306/*
281 * Platform device 307 * Platform device
282 */ 308 */
283static struct attribute *ideapad_attributes[] = {
284 &dev_attr_camera_power.attr,
285 NULL
286};
287
288static struct attribute_group ideapad_attribute_group = {
289 .attrs = ideapad_attributes
290};
291
292static int __devinit ideapad_platform_init(struct ideapad_private *priv) 309static int __devinit ideapad_platform_init(struct ideapad_private *priv)
293{ 310{
294 int result; 311 int result;
@@ -393,10 +410,11 @@ MODULE_DEVICE_TABLE(acpi, ideapad_device_ids);
393 410
394static int __devinit ideapad_acpi_add(struct acpi_device *adevice) 411static int __devinit ideapad_acpi_add(struct acpi_device *adevice)
395{ 412{
396 int ret, i, cfg; 413 int ret, i;
414 unsigned long cfg;
397 struct ideapad_private *priv; 415 struct ideapad_private *priv;
398 416
399 if (read_method_int(adevice->handle, "_CFG", &cfg)) 417 if (read_method_int(adevice->handle, "_CFG", (int *)&cfg))
400 return -ENODEV; 418 return -ENODEV;
401 419
402 priv = kzalloc(sizeof(*priv), GFP_KERNEL); 420 priv = kzalloc(sizeof(*priv), GFP_KERNEL);
@@ -404,6 +422,7 @@ static int __devinit ideapad_acpi_add(struct acpi_device *adevice)
404 return -ENOMEM; 422 return -ENOMEM;
405 dev_set_drvdata(&adevice->dev, priv); 423 dev_set_drvdata(&adevice->dev, priv);
406 ideapad_handle = adevice->handle; 424 ideapad_handle = adevice->handle;
425 priv->cfg = cfg;
407 426
408 ret = ideapad_platform_init(priv); 427 ret = ideapad_platform_init(priv);
409 if (ret) 428 if (ret)
@@ -414,7 +433,7 @@ static int __devinit ideapad_acpi_add(struct acpi_device *adevice)
414 goto input_failed; 433 goto input_failed;
415 434
416 for (i = 0; i < IDEAPAD_RFKILL_DEV_NUM; i++) { 435 for (i = 0; i < IDEAPAD_RFKILL_DEV_NUM; i++) {
417 if (test_bit(ideapad_rfk_data[i].cfgbit, (unsigned long *)&cfg)) 436 if (test_bit(ideapad_rfk_data[i].cfgbit, &cfg))
418 ideapad_register_rfkill(adevice, i); 437 ideapad_register_rfkill(adevice, i);
419 else 438 else
420 priv->rfk[i] = NULL; 439 priv->rfk[i] = NULL;