aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/platform/x86
diff options
context:
space:
mode:
authorIke Panhc <ike.pan@canonical.com>2011-09-05 14:31:53 -0400
committerMatthew Garrett <mjg@redhat.com>2011-10-24 10:52:39 -0400
commit2be1dc215bd34faf4895e4396dab924a24e10944 (patch)
treec4db4dbc75a07e6c2f30755e3619d826d0d41193 /drivers/platform/x86
parent21893ab24c78ec844cbaffbb7bf11b33cfdea8b4 (diff)
ideapad: define vpc commands
Better then write hex number everywhere. Signed-off-by: Ike Panhc <ike.pan@canonical.com> Signed-off-by: Matthew Garrett <mjg@redhat.com>
Diffstat (limited to 'drivers/platform/x86')
-rw-r--r--drivers/platform/x86/ideapad-laptop.c57
1 files changed, 41 insertions, 16 deletions
diff --git a/drivers/platform/x86/ideapad-laptop.c b/drivers/platform/x86/ideapad-laptop.c
index 0d94eec00f4d..0a1ceaa9062e 100644
--- a/drivers/platform/x86/ideapad-laptop.c
+++ b/drivers/platform/x86/ideapad-laptop.c
@@ -42,6 +42,30 @@
42#define CFG_WIFI_BIT (18) 42#define CFG_WIFI_BIT (18)
43#define CFG_CAMERA_BIT (19) 43#define CFG_CAMERA_BIT (19)
44 44
45enum {
46 VPCCMD_R_VPC1 = 0x10,
47 VPCCMD_R_BL_MAX,
48 VPCCMD_R_BL,
49 VPCCMD_W_BL,
50 VPCCMD_R_WIFI,
51 VPCCMD_W_WIFI,
52 VPCCMD_R_BT,
53 VPCCMD_W_BT,
54 VPCCMD_R_BL_POWER,
55 VPCCMD_R_NOVO,
56 VPCCMD_R_VPC2,
57 VPCCMD_R_TOUCHPAD,
58 VPCCMD_W_TOUCHPAD,
59 VPCCMD_R_CAMERA,
60 VPCCMD_W_CAMERA,
61 VPCCMD_R_3G,
62 VPCCMD_W_3G,
63 VPCCMD_R_ODD, /* 0x21 */
64 VPCCMD_R_RF = 0x23,
65 VPCCMD_W_RF,
66 VPCCMD_W_BL_POWER = 0x33,
67};
68
45struct ideapad_private { 69struct ideapad_private {
46 struct rfkill *rfk[IDEAPAD_RFKILL_DEV_NUM]; 70 struct rfkill *rfk[IDEAPAD_RFKILL_DEV_NUM];
47 struct platform_device *platform_device; 71 struct platform_device *platform_device;
@@ -172,7 +196,7 @@ static ssize_t show_ideapad_cam(struct device *dev,
172{ 196{
173 unsigned long result; 197 unsigned long result;
174 198
175 if (read_ec_data(ideapad_handle, 0x1D, &result)) 199 if (read_ec_data(ideapad_handle, VPCCMD_R_CAMERA, &result))
176 return sprintf(buf, "-1\n"); 200 return sprintf(buf, "-1\n");
177 return sprintf(buf, "%lu\n", result); 201 return sprintf(buf, "%lu\n", result);
178} 202}
@@ -187,7 +211,7 @@ static ssize_t store_ideapad_cam(struct device *dev,
187 return 0; 211 return 0;
188 if (sscanf(buf, "%i", &state) != 1) 212 if (sscanf(buf, "%i", &state) != 1)
189 return -EINVAL; 213 return -EINVAL;
190 ret = write_ec_cmd(ideapad_handle, 0x1E, state); 214 ret = write_ec_cmd(ideapad_handle, VPCCMD_W_CAMERA, state);
191 if (ret < 0) 215 if (ret < 0)
192 return ret; 216 return ret;
193 return count; 217 return count;
@@ -244,9 +268,9 @@ struct ideapad_rfk_data {
244}; 268};
245 269
246const struct ideapad_rfk_data ideapad_rfk_data[] = { 270const struct ideapad_rfk_data ideapad_rfk_data[] = {
247 { "ideapad_wlan", CFG_WIFI_BIT, 0x15, RFKILL_TYPE_WLAN }, 271 { "ideapad_wlan", CFG_WIFI_BIT, VPCCMD_W_WIFI, RFKILL_TYPE_WLAN },
248 { "ideapad_bluetooth", CFG_BT_BIT, 0x17, RFKILL_TYPE_BLUETOOTH }, 272 { "ideapad_bluetooth", CFG_BT_BIT, VPCCMD_W_BT, RFKILL_TYPE_BLUETOOTH },
249 { "ideapad_3g", CFG_3G_BIT, 0x20, RFKILL_TYPE_WWAN }, 273 { "ideapad_3g", CFG_3G_BIT, VPCCMD_W_3G, RFKILL_TYPE_WWAN },
250}; 274};
251 275
252static int ideapad_rfk_set(void *data, bool blocked) 276static int ideapad_rfk_set(void *data, bool blocked)
@@ -266,7 +290,7 @@ static void ideapad_sync_rfk_state(struct acpi_device *adevice)
266 unsigned long hw_blocked; 290 unsigned long hw_blocked;
267 int i; 291 int i;
268 292
269 if (read_ec_data(ideapad_handle, 0x23, &hw_blocked)) 293 if (read_ec_data(ideapad_handle, VPCCMD_R_RF, &hw_blocked))
270 return; 294 return;
271 hw_blocked = !hw_blocked; 295 hw_blocked = !hw_blocked;
272 296
@@ -426,16 +450,17 @@ static int ideapad_backlight_get_brightness(struct backlight_device *blightdev)
426{ 450{
427 unsigned long now; 451 unsigned long now;
428 452
429 if (read_ec_data(ideapad_handle, 0x12, &now)) 453 if (read_ec_data(ideapad_handle, VPCCMD_R_BL, &now))
430 return -EIO; 454 return -EIO;
431 return now; 455 return now;
432} 456}
433 457
434static int ideapad_backlight_update_status(struct backlight_device *blightdev) 458static int ideapad_backlight_update_status(struct backlight_device *blightdev)
435{ 459{
436 if (write_ec_cmd(ideapad_handle, 0x13, blightdev->props.brightness)) 460 if (write_ec_cmd(ideapad_handle, VPCCMD_W_BL,
461 blightdev->props.brightness))
437 return -EIO; 462 return -EIO;
438 if (write_ec_cmd(ideapad_handle, 0x33, 463 if (write_ec_cmd(ideapad_handle, VPCCMD_W_BL_POWER,
439 blightdev->props.power == FB_BLANK_POWERDOWN ? 0 : 1)) 464 blightdev->props.power == FB_BLANK_POWERDOWN ? 0 : 1))
440 return -EIO; 465 return -EIO;
441 466
@@ -453,11 +478,11 @@ static int ideapad_backlight_init(struct ideapad_private *priv)
453 struct backlight_properties props; 478 struct backlight_properties props;
454 unsigned long max, now, power; 479 unsigned long max, now, power;
455 480
456 if (read_ec_data(ideapad_handle, 0x11, &max)) 481 if (read_ec_data(ideapad_handle, VPCCMD_R_BL_MAX, &max))
457 return -EIO; 482 return -EIO;
458 if (read_ec_data(ideapad_handle, 0x12, &now)) 483 if (read_ec_data(ideapad_handle, VPCCMD_R_BL, &now))
459 return -EIO; 484 return -EIO;
460 if (read_ec_data(ideapad_handle, 0x18, &power)) 485 if (read_ec_data(ideapad_handle, VPCCMD_R_BL_POWER, &power))
461 return -EIO; 486 return -EIO;
462 487
463 memset(&props, 0, sizeof(struct backlight_properties)); 488 memset(&props, 0, sizeof(struct backlight_properties));
@@ -495,7 +520,7 @@ static void ideapad_backlight_notify_power(struct ideapad_private *priv)
495 520
496 if (!blightdev) 521 if (!blightdev)
497 return; 522 return;
498 if (read_ec_data(ideapad_handle, 0x18, &power)) 523 if (read_ec_data(ideapad_handle, VPCCMD_R_BL_POWER, &power))
499 return; 524 return;
500 blightdev->props.power = power ? FB_BLANK_UNBLANK : FB_BLANK_POWERDOWN; 525 blightdev->props.power = power ? FB_BLANK_UNBLANK : FB_BLANK_POWERDOWN;
501} 526}
@@ -506,7 +531,7 @@ static void ideapad_backlight_notify_brightness(struct ideapad_private *priv)
506 531
507 /* if we control brightness via acpi video driver */ 532 /* if we control brightness via acpi video driver */
508 if (priv->blightdev == NULL) { 533 if (priv->blightdev == NULL) {
509 read_ec_data(ideapad_handle, 0x12, &now); 534 read_ec_data(ideapad_handle, VPCCMD_R_BL, &now);
510 return; 535 return;
511 } 536 }
512 537
@@ -595,9 +620,9 @@ static void ideapad_acpi_notify(struct acpi_device *adevice, u32 event)
595 acpi_handle handle = adevice->handle; 620 acpi_handle handle = adevice->handle;
596 unsigned long vpc1, vpc2, vpc_bit; 621 unsigned long vpc1, vpc2, vpc_bit;
597 622
598 if (read_ec_data(handle, 0x10, &vpc1)) 623 if (read_ec_data(handle, VPCCMD_R_VPC1, &vpc1))
599 return; 624 return;
600 if (read_ec_data(handle, 0x1A, &vpc2)) 625 if (read_ec_data(handle, VPCCMD_R_VPC2, &vpc2))
601 return; 626 return;
602 627
603 vpc1 = (vpc2 << 8) | vpc1; 628 vpc1 = (vpc2 << 8) | vpc1;