aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2011-05-09 15:00:49 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2011-05-09 15:00:49 -0400
commit26822eebb25500fb0776c7c256a6af041e9f538b (patch)
treec8b09fbf2e16ca0e52818767cfbf82289936f970
parent047ec4b5de745fa1e0b56afcb06d431046bd36a3 (diff)
parent14fdb152416c0fab80ecddf492c129d7da1bb8ef (diff)
Merge branch 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mjg59/platform-drivers-x86
* 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mjg59/platform-drivers-x86: eeepc-laptop: Use ACPI handle to identify rfkill port [PATCH] sony-laptop: limit brightness range to DSDT provided ones sony-laptop: report failures on setting LCD brightness thinkpad-acpi: module autoloading for newer Lenovo ThinkPads.
-rw-r--r--drivers/platform/x86/eeepc-laptop.c57
-rw-r--r--drivers/platform/x86/sony-laptop.c130
-rw-r--r--drivers/platform/x86/thinkpad_acpi.c6
3 files changed, 150 insertions, 43 deletions
diff --git a/drivers/platform/x86/eeepc-laptop.c b/drivers/platform/x86/eeepc-laptop.c
index 5f2dd386152b..2c1abf63957f 100644
--- a/drivers/platform/x86/eeepc-laptop.c
+++ b/drivers/platform/x86/eeepc-laptop.c
@@ -585,8 +585,9 @@ static bool eeepc_wlan_rfkill_blocked(struct eeepc_laptop *eeepc)
585 return true; 585 return true;
586} 586}
587 587
588static void eeepc_rfkill_hotplug(struct eeepc_laptop *eeepc) 588static void eeepc_rfkill_hotplug(struct eeepc_laptop *eeepc, acpi_handle handle)
589{ 589{
590 struct pci_dev *port;
590 struct pci_dev *dev; 591 struct pci_dev *dev;
591 struct pci_bus *bus; 592 struct pci_bus *bus;
592 bool blocked = eeepc_wlan_rfkill_blocked(eeepc); 593 bool blocked = eeepc_wlan_rfkill_blocked(eeepc);
@@ -599,9 +600,16 @@ static void eeepc_rfkill_hotplug(struct eeepc_laptop *eeepc)
599 mutex_lock(&eeepc->hotplug_lock); 600 mutex_lock(&eeepc->hotplug_lock);
600 601
601 if (eeepc->hotplug_slot) { 602 if (eeepc->hotplug_slot) {
602 bus = pci_find_bus(0, 1); 603 port = acpi_get_pci_dev(handle);
604 if (!port) {
605 pr_warning("Unable to find port\n");
606 goto out_unlock;
607 }
608
609 bus = port->subordinate;
610
603 if (!bus) { 611 if (!bus) {
604 pr_warning("Unable to find PCI bus 1?\n"); 612 pr_warning("Unable to find PCI bus?\n");
605 goto out_unlock; 613 goto out_unlock;
606 } 614 }
607 615
@@ -609,6 +617,7 @@ static void eeepc_rfkill_hotplug(struct eeepc_laptop *eeepc)
609 pr_err("Unable to read PCI config space?\n"); 617 pr_err("Unable to read PCI config space?\n");
610 goto out_unlock; 618 goto out_unlock;
611 } 619 }
620
612 absent = (l == 0xffffffff); 621 absent = (l == 0xffffffff);
613 622
614 if (blocked != absent) { 623 if (blocked != absent) {
@@ -647,6 +656,17 @@ out_unlock:
647 mutex_unlock(&eeepc->hotplug_lock); 656 mutex_unlock(&eeepc->hotplug_lock);
648} 657}
649 658
659static void eeepc_rfkill_hotplug_update(struct eeepc_laptop *eeepc, char *node)
660{
661 acpi_status status = AE_OK;
662 acpi_handle handle;
663
664 status = acpi_get_handle(NULL, node, &handle);
665
666 if (ACPI_SUCCESS(status))
667 eeepc_rfkill_hotplug(eeepc, handle);
668}
669
650static void eeepc_rfkill_notify(acpi_handle handle, u32 event, void *data) 670static void eeepc_rfkill_notify(acpi_handle handle, u32 event, void *data)
651{ 671{
652 struct eeepc_laptop *eeepc = data; 672 struct eeepc_laptop *eeepc = data;
@@ -654,7 +674,7 @@ static void eeepc_rfkill_notify(acpi_handle handle, u32 event, void *data)
654 if (event != ACPI_NOTIFY_BUS_CHECK) 674 if (event != ACPI_NOTIFY_BUS_CHECK)
655 return; 675 return;
656 676
657 eeepc_rfkill_hotplug(eeepc); 677 eeepc_rfkill_hotplug(eeepc, handle);
658} 678}
659 679
660static int eeepc_register_rfkill_notifier(struct eeepc_laptop *eeepc, 680static int eeepc_register_rfkill_notifier(struct eeepc_laptop *eeepc,
@@ -672,6 +692,11 @@ static int eeepc_register_rfkill_notifier(struct eeepc_laptop *eeepc,
672 eeepc); 692 eeepc);
673 if (ACPI_FAILURE(status)) 693 if (ACPI_FAILURE(status))
674 pr_warning("Failed to register notify on %s\n", node); 694 pr_warning("Failed to register notify on %s\n", node);
695 /*
696 * Refresh pci hotplug in case the rfkill state was
697 * changed during setup.
698 */
699 eeepc_rfkill_hotplug(eeepc, handle);
675 } else 700 } else
676 return -ENODEV; 701 return -ENODEV;
677 702
@@ -693,6 +718,12 @@ static void eeepc_unregister_rfkill_notifier(struct eeepc_laptop *eeepc,
693 if (ACPI_FAILURE(status)) 718 if (ACPI_FAILURE(status))
694 pr_err("Error removing rfkill notify handler %s\n", 719 pr_err("Error removing rfkill notify handler %s\n",
695 node); 720 node);
721 /*
722 * Refresh pci hotplug in case the rfkill
723 * state was changed after
724 * eeepc_unregister_rfkill_notifier()
725 */
726 eeepc_rfkill_hotplug(eeepc, handle);
696 } 727 }
697} 728}
698 729
@@ -816,11 +847,7 @@ static void eeepc_rfkill_exit(struct eeepc_laptop *eeepc)
816 rfkill_destroy(eeepc->wlan_rfkill); 847 rfkill_destroy(eeepc->wlan_rfkill);
817 eeepc->wlan_rfkill = NULL; 848 eeepc->wlan_rfkill = NULL;
818 } 849 }
819 /* 850
820 * Refresh pci hotplug in case the rfkill state was changed after
821 * eeepc_unregister_rfkill_notifier()
822 */
823 eeepc_rfkill_hotplug(eeepc);
824 if (eeepc->hotplug_slot) 851 if (eeepc->hotplug_slot)
825 pci_hp_deregister(eeepc->hotplug_slot); 852 pci_hp_deregister(eeepc->hotplug_slot);
826 853
@@ -889,11 +916,6 @@ static int eeepc_rfkill_init(struct eeepc_laptop *eeepc)
889 eeepc_register_rfkill_notifier(eeepc, "\\_SB.PCI0.P0P5"); 916 eeepc_register_rfkill_notifier(eeepc, "\\_SB.PCI0.P0P5");
890 eeepc_register_rfkill_notifier(eeepc, "\\_SB.PCI0.P0P6"); 917 eeepc_register_rfkill_notifier(eeepc, "\\_SB.PCI0.P0P6");
891 eeepc_register_rfkill_notifier(eeepc, "\\_SB.PCI0.P0P7"); 918 eeepc_register_rfkill_notifier(eeepc, "\\_SB.PCI0.P0P7");
892 /*
893 * Refresh pci hotplug in case the rfkill state was changed during
894 * setup.
895 */
896 eeepc_rfkill_hotplug(eeepc);
897 919
898exit: 920exit:
899 if (result && result != -ENODEV) 921 if (result && result != -ENODEV)
@@ -928,8 +950,11 @@ static int eeepc_hotk_restore(struct device *device)
928 struct eeepc_laptop *eeepc = dev_get_drvdata(device); 950 struct eeepc_laptop *eeepc = dev_get_drvdata(device);
929 951
930 /* Refresh both wlan rfkill state and pci hotplug */ 952 /* Refresh both wlan rfkill state and pci hotplug */
931 if (eeepc->wlan_rfkill) 953 if (eeepc->wlan_rfkill) {
932 eeepc_rfkill_hotplug(eeepc); 954 eeepc_rfkill_hotplug_update(eeepc, "\\_SB.PCI0.P0P5");
955 eeepc_rfkill_hotplug_update(eeepc, "\\_SB.PCI0.P0P6");
956 eeepc_rfkill_hotplug_update(eeepc, "\\_SB.PCI0.P0P7");
957 }
933 958
934 if (eeepc->bluetooth_rfkill) 959 if (eeepc->bluetooth_rfkill)
935 rfkill_set_sw_state(eeepc->bluetooth_rfkill, 960 rfkill_set_sw_state(eeepc->bluetooth_rfkill,
diff --git a/drivers/platform/x86/sony-laptop.c b/drivers/platform/x86/sony-laptop.c
index 8f709aec4da0..6fe8cd6e23b5 100644
--- a/drivers/platform/x86/sony-laptop.c
+++ b/drivers/platform/x86/sony-laptop.c
@@ -934,6 +934,14 @@ static ssize_t sony_nc_sysfs_store(struct device *dev,
934/* 934/*
935 * Backlight device 935 * Backlight device
936 */ 936 */
937struct sony_backlight_props {
938 struct backlight_device *dev;
939 int handle;
940 u8 offset;
941 u8 maxlvl;
942};
943struct sony_backlight_props sony_bl_props;
944
937static int sony_backlight_update_status(struct backlight_device *bd) 945static int sony_backlight_update_status(struct backlight_device *bd)
938{ 946{
939 return acpi_callsetfunc(sony_nc_acpi_handle, "SBRT", 947 return acpi_callsetfunc(sony_nc_acpi_handle, "SBRT",
@@ -954,21 +962,26 @@ static int sony_nc_get_brightness_ng(struct backlight_device *bd)
954{ 962{
955 int result; 963 int result;
956 int *handle = (int *)bl_get_data(bd); 964 int *handle = (int *)bl_get_data(bd);
965 struct sony_backlight_props *sdev =
966 (struct sony_backlight_props *)bl_get_data(bd);
957 967
958 sony_call_snc_handle(*handle, 0x0200, &result); 968 sony_call_snc_handle(sdev->handle, 0x0200, &result);
959 969
960 return result & 0xff; 970 return (result & 0xff) - sdev->offset;
961} 971}
962 972
963static int sony_nc_update_status_ng(struct backlight_device *bd) 973static int sony_nc_update_status_ng(struct backlight_device *bd)
964{ 974{
965 int value, result; 975 int value, result;
966 int *handle = (int *)bl_get_data(bd); 976 int *handle = (int *)bl_get_data(bd);
977 struct sony_backlight_props *sdev =
978 (struct sony_backlight_props *)bl_get_data(bd);
967 979
968 value = bd->props.brightness; 980 value = bd->props.brightness + sdev->offset;
969 sony_call_snc_handle(*handle, 0x0100 | (value << 16), &result); 981 if (sony_call_snc_handle(sdev->handle, 0x0100 | (value << 16), &result))
982 return -EIO;
970 983
971 return sony_nc_get_brightness_ng(bd); 984 return value;
972} 985}
973 986
974static const struct backlight_ops sony_backlight_ops = { 987static const struct backlight_ops sony_backlight_ops = {
@@ -981,8 +994,6 @@ static const struct backlight_ops sony_backlight_ng_ops = {
981 .update_status = sony_nc_update_status_ng, 994 .update_status = sony_nc_update_status_ng,
982 .get_brightness = sony_nc_get_brightness_ng, 995 .get_brightness = sony_nc_get_brightness_ng,
983}; 996};
984static int backlight_ng_handle;
985static struct backlight_device *sony_backlight_device;
986 997
987/* 998/*
988 * New SNC-only Vaios event mapping to driver known keys 999 * New SNC-only Vaios event mapping to driver known keys
@@ -1549,6 +1560,75 @@ static void sony_nc_kbd_backlight_resume(void)
1549 &ignore); 1560 &ignore);
1550} 1561}
1551 1562
1563static void sony_nc_backlight_ng_read_limits(int handle,
1564 struct sony_backlight_props *props)
1565{
1566 int offset;
1567 acpi_status status;
1568 u8 brlvl, i;
1569 u8 min = 0xff, max = 0x00;
1570 struct acpi_object_list params;
1571 union acpi_object in_obj;
1572 union acpi_object *lvl_enum;
1573 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
1574
1575 props->handle = handle;
1576 props->offset = 0;
1577 props->maxlvl = 0xff;
1578
1579 offset = sony_find_snc_handle(handle);
1580 if (offset < 0)
1581 return;
1582
1583 /* try to read the boundaries from ACPI tables, if we fail the above
1584 * defaults should be reasonable
1585 */
1586 params.count = 1;
1587 params.pointer = &in_obj;
1588 in_obj.type = ACPI_TYPE_INTEGER;
1589 in_obj.integer.value = offset;
1590 status = acpi_evaluate_object(sony_nc_acpi_handle, "SN06", &params,
1591 &buffer);
1592 if (ACPI_FAILURE(status))
1593 return;
1594
1595 lvl_enum = (union acpi_object *) buffer.pointer;
1596 if (!lvl_enum) {
1597 pr_err("No SN06 return object.");
1598 return;
1599 }
1600 if (lvl_enum->type != ACPI_TYPE_BUFFER) {
1601 pr_err("Invalid SN06 return object 0x%.2x\n",
1602 lvl_enum->type);
1603 goto out_invalid;
1604 }
1605
1606 /* the buffer lists brightness levels available, brightness levels are
1607 * from 0 to 8 in the array, other values are used by ALS control.
1608 */
1609 for (i = 0; i < 9 && i < lvl_enum->buffer.length; i++) {
1610
1611 brlvl = *(lvl_enum->buffer.pointer + i);
1612 dprintk("Brightness level: %d\n", brlvl);
1613
1614 if (!brlvl)
1615 break;
1616
1617 if (brlvl > max)
1618 max = brlvl;
1619 if (brlvl < min)
1620 min = brlvl;
1621 }
1622 props->offset = min;
1623 props->maxlvl = max;
1624 dprintk("Brightness levels: min=%d max=%d\n", props->offset,
1625 props->maxlvl);
1626
1627out_invalid:
1628 kfree(buffer.pointer);
1629 return;
1630}
1631
1552static void sony_nc_backlight_setup(void) 1632static void sony_nc_backlight_setup(void)
1553{ 1633{
1554 acpi_handle unused; 1634 acpi_handle unused;
@@ -1557,14 +1637,14 @@ static void sony_nc_backlight_setup(void)
1557 struct backlight_properties props; 1637 struct backlight_properties props;
1558 1638
1559 if (sony_find_snc_handle(0x12f) != -1) { 1639 if (sony_find_snc_handle(0x12f) != -1) {
1560 backlight_ng_handle = 0x12f;
1561 ops = &sony_backlight_ng_ops; 1640 ops = &sony_backlight_ng_ops;
1562 max_brightness = 0xff; 1641 sony_nc_backlight_ng_read_limits(0x12f, &sony_bl_props);
1642 max_brightness = sony_bl_props.maxlvl - sony_bl_props.offset;
1563 1643
1564 } else if (sony_find_snc_handle(0x137) != -1) { 1644 } else if (sony_find_snc_handle(0x137) != -1) {
1565 backlight_ng_handle = 0x137;
1566 ops = &sony_backlight_ng_ops; 1645 ops = &sony_backlight_ng_ops;
1567 max_brightness = 0xff; 1646 sony_nc_backlight_ng_read_limits(0x137, &sony_bl_props);
1647 max_brightness = sony_bl_props.maxlvl - sony_bl_props.offset;
1568 1648
1569 } else if (ACPI_SUCCESS(acpi_get_handle(sony_nc_acpi_handle, "GBRT", 1649 } else if (ACPI_SUCCESS(acpi_get_handle(sony_nc_acpi_handle, "GBRT",
1570 &unused))) { 1650 &unused))) {
@@ -1577,22 +1657,22 @@ static void sony_nc_backlight_setup(void)
1577 memset(&props, 0, sizeof(struct backlight_properties)); 1657 memset(&props, 0, sizeof(struct backlight_properties));
1578 props.type = BACKLIGHT_PLATFORM; 1658 props.type = BACKLIGHT_PLATFORM;
1579 props.max_brightness = max_brightness; 1659 props.max_brightness = max_brightness;
1580 sony_backlight_device = backlight_device_register("sony", NULL, 1660 sony_bl_props.dev = backlight_device_register("sony", NULL,
1581 &backlight_ng_handle, 1661 &sony_bl_props,
1582 ops, &props); 1662 ops, &props);
1583 1663
1584 if (IS_ERR(sony_backlight_device)) { 1664 if (IS_ERR(sony_bl_props.dev)) {
1585 pr_warning(DRV_PFX "unable to register backlight device\n"); 1665 pr_warn(DRV_PFX "unable to register backlight device\n");
1586 sony_backlight_device = NULL; 1666 sony_bl_props.dev = NULL;
1587 } else 1667 } else
1588 sony_backlight_device->props.brightness = 1668 sony_bl_props.dev->props.brightness =
1589 ops->get_brightness(sony_backlight_device); 1669 ops->get_brightness(sony_bl_props.dev);
1590} 1670}
1591 1671
1592static void sony_nc_backlight_cleanup(void) 1672static void sony_nc_backlight_cleanup(void)
1593{ 1673{
1594 if (sony_backlight_device) 1674 if (sony_bl_props.dev)
1595 backlight_device_unregister(sony_backlight_device); 1675 backlight_device_unregister(sony_bl_props.dev);
1596} 1676}
1597 1677
1598static int sony_nc_add(struct acpi_device *device) 1678static int sony_nc_add(struct acpi_device *device)
@@ -2590,7 +2670,7 @@ static long sonypi_misc_ioctl(struct file *fp, unsigned int cmd,
2590 mutex_lock(&spic_dev.lock); 2670 mutex_lock(&spic_dev.lock);
2591 switch (cmd) { 2671 switch (cmd) {
2592 case SONYPI_IOCGBRT: 2672 case SONYPI_IOCGBRT:
2593 if (sony_backlight_device == NULL) { 2673 if (sony_bl_props.dev == NULL) {
2594 ret = -EIO; 2674 ret = -EIO;
2595 break; 2675 break;
2596 } 2676 }
@@ -2603,7 +2683,7 @@ static long sonypi_misc_ioctl(struct file *fp, unsigned int cmd,
2603 ret = -EFAULT; 2683 ret = -EFAULT;
2604 break; 2684 break;
2605 case SONYPI_IOCSBRT: 2685 case SONYPI_IOCSBRT:
2606 if (sony_backlight_device == NULL) { 2686 if (sony_bl_props.dev == NULL) {
2607 ret = -EIO; 2687 ret = -EIO;
2608 break; 2688 break;
2609 } 2689 }
@@ -2617,8 +2697,8 @@ static long sonypi_misc_ioctl(struct file *fp, unsigned int cmd,
2617 break; 2697 break;
2618 } 2698 }
2619 /* sync the backlight device status */ 2699 /* sync the backlight device status */
2620 sony_backlight_device->props.brightness = 2700 sony_bl_props.dev->props.brightness =
2621 sony_backlight_get_brightness(sony_backlight_device); 2701 sony_backlight_get_brightness(sony_bl_props.dev);
2622 break; 2702 break;
2623 case SONYPI_IOCGBAT1CAP: 2703 case SONYPI_IOCGBAT1CAP:
2624 if (ec_read16(SONYPI_BAT1_FULL, &val16)) { 2704 if (ec_read16(SONYPI_BAT1_FULL, &val16)) {
diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c
index efb3b6b9bcdb..562fcf0dd2b5 100644
--- a/drivers/platform/x86/thinkpad_acpi.c
+++ b/drivers/platform/x86/thinkpad_acpi.c
@@ -128,7 +128,8 @@ enum {
128}; 128};
129 129
130/* ACPI HIDs */ 130/* ACPI HIDs */
131#define TPACPI_ACPI_HKEY_HID "IBM0068" 131#define TPACPI_ACPI_IBM_HKEY_HID "IBM0068"
132#define TPACPI_ACPI_LENOVO_HKEY_HID "LEN0068"
132#define TPACPI_ACPI_EC_HID "PNP0C09" 133#define TPACPI_ACPI_EC_HID "PNP0C09"
133 134
134/* Input IDs */ 135/* Input IDs */
@@ -3879,7 +3880,8 @@ errexit:
3879} 3880}
3880 3881
3881static const struct acpi_device_id ibm_htk_device_ids[] = { 3882static const struct acpi_device_id ibm_htk_device_ids[] = {
3882 {TPACPI_ACPI_HKEY_HID, 0}, 3883 {TPACPI_ACPI_IBM_HKEY_HID, 0},
3884 {TPACPI_ACPI_LENOVO_HKEY_HID, 0},
3883 {"", 0}, 3885 {"", 0},
3884}; 3886};
3885 3887