diff options
-rw-r--r-- | drivers/platform/x86/sony-laptop.c | 78 |
1 files changed, 78 insertions, 0 deletions
diff --git a/drivers/platform/x86/sony-laptop.c b/drivers/platform/x86/sony-laptop.c index 7b5a56d59bac..ba39a29a9f39 100644 --- a/drivers/platform/x86/sony-laptop.c +++ b/drivers/platform/x86/sony-laptop.c | |||
@@ -164,6 +164,9 @@ static int __sony_nc_gfx_switch_status_get(void); | |||
164 | static int sony_nc_highspeed_charging_setup(struct platform_device *pd); | 164 | static int sony_nc_highspeed_charging_setup(struct platform_device *pd); |
165 | static void sony_nc_highspeed_charging_cleanup(struct platform_device *pd); | 165 | static void sony_nc_highspeed_charging_cleanup(struct platform_device *pd); |
166 | 166 | ||
167 | static int sony_nc_lowbatt_setup(struct platform_device *pd); | ||
168 | static void sony_nc_lowbatt_cleanup(struct platform_device *pd); | ||
169 | |||
167 | static int sony_nc_fanspeed_setup(struct platform_device *pd); | 170 | static int sony_nc_fanspeed_setup(struct platform_device *pd); |
168 | static void sony_nc_fanspeed_cleanup(struct platform_device *pd); | 171 | static void sony_nc_fanspeed_cleanup(struct platform_device *pd); |
169 | 172 | ||
@@ -1394,6 +1397,12 @@ static void sony_nc_function_setup(struct acpi_device *device, | |||
1394 | pr_err("couldn't set up keyboard backlight function (%d)\n", | 1397 | pr_err("couldn't set up keyboard backlight function (%d)\n", |
1395 | result); | 1398 | result); |
1396 | break; | 1399 | break; |
1400 | case 0x0121: | ||
1401 | result = sony_nc_lowbatt_setup(pf_device); | ||
1402 | if (result) | ||
1403 | pr_err("couldn't set up low battery function (%d)\n", | ||
1404 | result); | ||
1405 | break; | ||
1397 | case 0x0149: | 1406 | case 0x0149: |
1398 | result = sony_nc_fanspeed_setup(pf_device); | 1407 | result = sony_nc_fanspeed_setup(pf_device); |
1399 | if (result) | 1408 | if (result) |
@@ -1476,6 +1485,9 @@ static void sony_nc_function_cleanup(struct platform_device *pd) | |||
1476 | case 0x0163: | 1485 | case 0x0163: |
1477 | sony_nc_kbd_backlight_cleanup(pd, handle); | 1486 | sony_nc_kbd_backlight_cleanup(pd, handle); |
1478 | break; | 1487 | break; |
1488 | case 0x0121: | ||
1489 | sony_nc_lowbatt_cleanup(pd); | ||
1490 | break; | ||
1479 | case 0x0149: | 1491 | case 0x0149: |
1480 | sony_nc_fanspeed_cleanup(pd); | 1492 | sony_nc_fanspeed_cleanup(pd); |
1481 | break; | 1493 | break; |
@@ -2576,6 +2588,72 @@ static void sony_nc_highspeed_charging_cleanup(struct platform_device *pd) | |||
2576 | } | 2588 | } |
2577 | } | 2589 | } |
2578 | 2590 | ||
2591 | /* low battery function */ | ||
2592 | static struct device_attribute *lowbatt_handle; | ||
2593 | |||
2594 | static ssize_t sony_nc_lowbatt_store(struct device *dev, | ||
2595 | struct device_attribute *attr, | ||
2596 | const char *buffer, size_t count) | ||
2597 | { | ||
2598 | unsigned int result; | ||
2599 | unsigned long value; | ||
2600 | |||
2601 | if (count > 31) | ||
2602 | return -EINVAL; | ||
2603 | |||
2604 | if (kstrtoul(buffer, 10, &value) || value > 1) | ||
2605 | return -EINVAL; | ||
2606 | |||
2607 | if (sony_call_snc_handle(0x0121, value << 8, &result)) | ||
2608 | return -EIO; | ||
2609 | |||
2610 | return count; | ||
2611 | } | ||
2612 | |||
2613 | static ssize_t sony_nc_lowbatt_show(struct device *dev, | ||
2614 | struct device_attribute *attr, char *buffer) | ||
2615 | { | ||
2616 | unsigned int result; | ||
2617 | |||
2618 | if (sony_call_snc_handle(0x0121, 0x0200, &result)) | ||
2619 | return -EIO; | ||
2620 | |||
2621 | return snprintf(buffer, PAGE_SIZE, "%d\n", result & 1); | ||
2622 | } | ||
2623 | |||
2624 | static int sony_nc_lowbatt_setup(struct platform_device *pd) | ||
2625 | { | ||
2626 | unsigned int result; | ||
2627 | |||
2628 | lowbatt_handle = kzalloc(sizeof(struct device_attribute), GFP_KERNEL); | ||
2629 | if (!lowbatt_handle) | ||
2630 | return -ENOMEM; | ||
2631 | |||
2632 | sysfs_attr_init(&lowbatt_handle->attr); | ||
2633 | lowbatt_handle->attr.name = "lowbatt_hibernate"; | ||
2634 | lowbatt_handle->attr.mode = S_IRUGO | S_IWUSR; | ||
2635 | lowbatt_handle->show = sony_nc_lowbatt_show; | ||
2636 | lowbatt_handle->store = sony_nc_lowbatt_store; | ||
2637 | |||
2638 | result = device_create_file(&pd->dev, lowbatt_handle); | ||
2639 | if (result) { | ||
2640 | kfree(lowbatt_handle); | ||
2641 | lowbatt_handle = NULL; | ||
2642 | return result; | ||
2643 | } | ||
2644 | |||
2645 | return 0; | ||
2646 | } | ||
2647 | |||
2648 | static void sony_nc_lowbatt_cleanup(struct platform_device *pd) | ||
2649 | { | ||
2650 | if (lowbatt_handle) { | ||
2651 | device_remove_file(&pd->dev, lowbatt_handle); | ||
2652 | kfree(lowbatt_handle); | ||
2653 | lowbatt_handle = NULL; | ||
2654 | } | ||
2655 | } | ||
2656 | |||
2579 | /* fan speed function */ | 2657 | /* fan speed function */ |
2580 | static struct device_attribute *fan_handle, *hsf_handle; | 2658 | static struct device_attribute *fan_handle, *hsf_handle; |
2581 | 2659 | ||