diff options
32 files changed, 2876 insertions, 1121 deletions
diff --git a/Documentation/feature-removal-schedule.txt b/Documentation/feature-removal-schedule.txt index 0ba6af02cdaf..b3d1ce7e3ba0 100644 --- a/Documentation/feature-removal-schedule.txt +++ b/Documentation/feature-removal-schedule.txt | |||
| @@ -274,6 +274,7 @@ Who: Venkatesh Pallipadi <venkatesh.pallipadi@intel.com> | |||
| 274 | 274 | ||
| 275 | --------------------------- | 275 | --------------------------- |
| 276 | 276 | ||
| 277 | <<<<<<< test:Documentation/feature-removal-schedule.txt | ||
| 277 | What: ACPI hotkey driver (CONFIG_ACPI_HOTKEY) | 278 | What: ACPI hotkey driver (CONFIG_ACPI_HOTKEY) |
| 278 | When: 2.6.21 | 279 | When: 2.6.21 |
| 279 | Why: hotkey.c was an attempt to consolidate multiple drivers that use | 280 | Why: hotkey.c was an attempt to consolidate multiple drivers that use |
| @@ -306,11 +307,18 @@ Why: The ACPI namespace is effectively the symbol list for | |||
| 306 | the BIOS can be extracted and disassembled with acpidump | 307 | the BIOS can be extracted and disassembled with acpidump |
| 307 | and iasl as documented in the pmtools package here: | 308 | and iasl as documented in the pmtools package here: |
| 308 | http://ftp.kernel.org/pub/linux/kernel/people/lenb/acpi/utils | 309 | http://ftp.kernel.org/pub/linux/kernel/people/lenb/acpi/utils |
| 309 | |||
| 310 | Who: Len Brown <len.brown@intel.com> | 310 | Who: Len Brown <len.brown@intel.com> |
| 311 | 311 | ||
| 312 | --------------------------- | 312 | --------------------------- |
| 313 | 313 | ||
| 314 | What: ACPI procfs interface | ||
| 315 | When: July 2007 | ||
| 316 | Why: After ACPI sysfs conversion, ACPI attributes will be duplicated | ||
| 317 | in sysfs and the ACPI procfs interface should be removed. | ||
| 318 | Who: Zhang Rui <rui.zhang@intel.com> | ||
| 319 | |||
| 320 | --------------------------- | ||
| 321 | |||
| 314 | What: /proc/acpi/button | 322 | What: /proc/acpi/button |
| 315 | When: August 2007 | 323 | When: August 2007 |
| 316 | Why: /proc/acpi/button has been replaced by events to the input layer | 324 | Why: /proc/acpi/button has been replaced by events to the input layer |
diff --git a/Documentation/video-output.txt b/Documentation/video-output.txt new file mode 100644 index 000000000000..e517011be4f9 --- /dev/null +++ b/Documentation/video-output.txt | |||
| @@ -0,0 +1,34 @@ | |||
| 1 | |||
| 2 | Video Output Switcher Control | ||
| 3 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
| 4 | 2006 luming.yu@intel.com | ||
| 5 | |||
| 6 | The output sysfs class driver provides an abstract video output layer that | ||
| 7 | can be used to hook platform specific methods to enable/disable video output | ||
| 8 | device through common sysfs interface. For example, on my IBM ThinkPad T42 | ||
| 9 | laptop, The ACPI video driver registered its output devices and read/write | ||
| 10 | method for 'state' with output sysfs class. The user interface under sysfs is: | ||
| 11 | |||
| 12 | linux:/sys/class/video_output # tree . | ||
| 13 | . | ||
| 14 | |-- CRT0 | ||
| 15 | | |-- device -> ../../../devices/pci0000:00/0000:00:01.0 | ||
| 16 | | |-- state | ||
| 17 | | |-- subsystem -> ../../../class/video_output | ||
| 18 | | `-- uevent | ||
| 19 | |-- DVI0 | ||
| 20 | | |-- device -> ../../../devices/pci0000:00/0000:00:01.0 | ||
| 21 | | |-- state | ||
| 22 | | |-- subsystem -> ../../../class/video_output | ||
| 23 | | `-- uevent | ||
| 24 | |-- LCD0 | ||
| 25 | | |-- device -> ../../../devices/pci0000:00/0000:00:01.0 | ||
| 26 | | |-- state | ||
| 27 | | |-- subsystem -> ../../../class/video_output | ||
| 28 | | `-- uevent | ||
| 29 | `-- TV0 | ||
| 30 | |-- device -> ../../../devices/pci0000:00/0000:00:01.0 | ||
| 31 | |-- state | ||
| 32 | |-- subsystem -> ../../../class/video_output | ||
| 33 | `-- uevent | ||
| 34 | |||
diff --git a/MAINTAINERS b/MAINTAINERS index 0ad8803a0c75..efca26a9242c 100644 --- a/MAINTAINERS +++ b/MAINTAINERS | |||
| @@ -584,6 +584,14 @@ W: http://sourceforge.net/projects/acpi4asus | |||
| 584 | W: http://xf.iksaif.net/acpi4asus | 584 | W: http://xf.iksaif.net/acpi4asus |
| 585 | S: Maintained | 585 | S: Maintained |
| 586 | 586 | ||
| 587 | ASUS LAPTOP EXTRAS DRIVER | ||
| 588 | P: Corentin Chary | ||
| 589 | M: corentincj@iksaif.net | ||
| 590 | L: acpi4asus-user@lists.sourceforge.net | ||
| 591 | W: http://sourceforge.net/projects/acpi4asus | ||
| 592 | W: http://xf.iksaif.net/acpi4asus | ||
| 593 | S: Maintained | ||
| 594 | |||
| 587 | ATA OVER ETHERNET DRIVER | 595 | ATA OVER ETHERNET DRIVER |
| 588 | P: Ed L. Cashin | 596 | P: Ed L. Cashin |
| 589 | M: ecashin@coraid.com | 597 | M: ecashin@coraid.com |
diff --git a/arch/i386/defconfig b/arch/i386/defconfig index 5d80edfc61b7..bb0c376b62b3 100644 --- a/arch/i386/defconfig +++ b/arch/i386/defconfig | |||
| @@ -466,7 +466,8 @@ CONFIG_FW_LOADER=y | |||
| 466 | # | 466 | # |
| 467 | # Plug and Play support | 467 | # Plug and Play support |
| 468 | # | 468 | # |
| 469 | # CONFIG_PNP is not set | 469 | CONFIG_PNP=y |
| 470 | CONFIG_PNPACPI=y | ||
| 470 | 471 | ||
| 471 | # | 472 | # |
| 472 | # Block devices | 473 | # Block devices |
diff --git a/drivers/acpi/Kconfig b/drivers/acpi/Kconfig index f4f000abc4e9..20eacc2c9e0e 100644 --- a/drivers/acpi/Kconfig +++ b/drivers/acpi/Kconfig | |||
| @@ -3,6 +3,7 @@ | |||
| 3 | # | 3 | # |
| 4 | 4 | ||
| 5 | menu "ACPI (Advanced Configuration and Power Interface) Support" | 5 | menu "ACPI (Advanced Configuration and Power Interface) Support" |
| 6 | depends on !X86_NUMAQ | ||
| 6 | depends on !X86_VISWS | 7 | depends on !X86_VISWS |
| 7 | depends on !IA64_HP_SIM | 8 | depends on !IA64_HP_SIM |
| 8 | depends on IA64 || X86 | 9 | depends on IA64 || X86 |
| @@ -77,6 +78,20 @@ config ACPI_SLEEP_PROC_SLEEP | |||
| 77 | Create /proc/acpi/sleep | 78 | Create /proc/acpi/sleep |
| 78 | Deprecated by /sys/power/state | 79 | Deprecated by /sys/power/state |
| 79 | 80 | ||
| 81 | config ACPI_PROCFS | ||
| 82 | bool "Procfs interface (deprecated)" | ||
| 83 | depends on ACPI | ||
| 84 | default y | ||
| 85 | ---help--- | ||
| 86 | Procfs interface for ACPI is made optional for back-compatible. | ||
| 87 | As the same functions are duplicated in sysfs interface | ||
| 88 | and this proc interface will be removed some time later, | ||
| 89 | it's marked as deprecated. | ||
| 90 | ( /proc/acpi/debug_layer && debug_level are deprecated by | ||
| 91 | /sys/module/acpi/parameters/debug_layer && debug_level. | ||
| 92 | /proc/acpi/info is deprecated by | ||
| 93 | /sys/module/acpi/parameters/acpica_version ) | ||
| 94 | |||
| 80 | config ACPI_AC | 95 | config ACPI_AC |
| 81 | tristate "AC Adapter" | 96 | tristate "AC Adapter" |
| 82 | depends on X86 | 97 | depends on X86 |
| @@ -107,7 +122,7 @@ config ACPI_BUTTON | |||
| 107 | 122 | ||
| 108 | config ACPI_VIDEO | 123 | config ACPI_VIDEO |
| 109 | tristate "Video" | 124 | tristate "Video" |
| 110 | depends on X86 | 125 | depends on X86 && BACKLIGHT_CLASS_DEVICE |
| 111 | help | 126 | help |
| 112 | This driver implement the ACPI Extensions For Display Adapters | 127 | This driver implement the ACPI Extensions For Display Adapters |
| 113 | for integrated graphics devices on motherboard, as specified in | 128 | for integrated graphics devices on motherboard, as specified in |
| @@ -139,6 +154,13 @@ config ACPI_DOCK | |||
| 139 | help | 154 | help |
| 140 | This driver adds support for ACPI controlled docking stations | 155 | This driver adds support for ACPI controlled docking stations |
| 141 | 156 | ||
| 157 | config ACPI_BAY | ||
| 158 | tristate "Removable Drive Bay (EXPERIMENTAL)" | ||
| 159 | depends on EXPERIMENTAL | ||
| 160 | help | ||
| 161 | This driver adds support for ACPI controlled removable drive | ||
| 162 | bays such as the IBM ultrabay or the Dell Module Bay. | ||
| 163 | |||
| 142 | config ACPI_PROCESSOR | 164 | config ACPI_PROCESSOR |
| 143 | tristate "Processor" | 165 | tristate "Processor" |
| 144 | default y | 166 | default y |
| @@ -186,19 +208,22 @@ config ACPI_ASUS | |||
| 186 | 208 | ||
| 187 | Note: display switching code is currently considered EXPERIMENTAL, | 209 | Note: display switching code is currently considered EXPERIMENTAL, |
| 188 | toying with these values may even lock your machine. | 210 | toying with these values may even lock your machine. |
| 189 | 211 | ||
| 190 | All settings are changed via /proc/acpi/asus directory entries. Owner | 212 | All settings are changed via /proc/acpi/asus directory entries. Owner |
| 191 | and group for these entries can be set with asus_uid and asus_gid | 213 | and group for these entries can be set with asus_uid and asus_gid |
| 192 | parameters. | 214 | parameters. |
| 193 | 215 | ||
| 194 | More information and a userspace daemon for handling the extra buttons | 216 | More information and a userspace daemon for handling the extra buttons |
| 195 | at <http://sourceforge.net/projects/acpi4asus/>. | 217 | at <http://sourceforge.net/projects/acpi4asus/>. |
| 196 | 218 | ||
| 197 | If you have an ACPI-compatible ASUS laptop, say Y or M here. This | 219 | If you have an ACPI-compatible ASUS laptop, say Y or M here. This |
| 198 | driver is still under development, so if your laptop is unsupported or | 220 | driver is still under development, so if your laptop is unsupported or |
| 199 | something works not quite as expected, please use the mailing list | 221 | something works not quite as expected, please use the mailing list |
| 200 | available on the above page (acpi4asus-user@lists.sourceforge.net) | 222 | available on the above page (acpi4asus-user@lists.sourceforge.net). |
| 201 | 223 | ||
| 224 | NOTE: This driver is deprecated and will probably be removed soon, | ||
| 225 | use asus-laptop instead. | ||
| 226 | |||
| 202 | config ACPI_IBM | 227 | config ACPI_IBM |
| 203 | tristate "IBM ThinkPad Laptop Extras" | 228 | tristate "IBM ThinkPad Laptop Extras" |
| 204 | depends on X86 | 229 | depends on X86 |
diff --git a/drivers/acpi/Makefile b/drivers/acpi/Makefile index bce7ca27b429..856c32bccacb 100644 --- a/drivers/acpi/Makefile +++ b/drivers/acpi/Makefile | |||
| @@ -37,13 +37,15 @@ endif | |||
| 37 | 37 | ||
| 38 | obj-y += sleep/ | 38 | obj-y += sleep/ |
| 39 | obj-y += bus.o glue.o | 39 | obj-y += bus.o glue.o |
| 40 | obj-y += scan.o | ||
| 40 | obj-$(CONFIG_ACPI_AC) += ac.o | 41 | obj-$(CONFIG_ACPI_AC) += ac.o |
| 41 | obj-$(CONFIG_ACPI_BATTERY) += battery.o | 42 | obj-$(CONFIG_ACPI_BATTERY) += battery.o |
| 42 | obj-$(CONFIG_ACPI_BUTTON) += button.o | 43 | obj-$(CONFIG_ACPI_BUTTON) += button.o |
| 43 | obj-$(CONFIG_ACPI_EC) += ec.o | 44 | obj-$(CONFIG_ACPI_EC) += ec.o |
| 44 | obj-$(CONFIG_ACPI_FAN) += fan.o | 45 | obj-$(CONFIG_ACPI_FAN) += fan.o |
| 45 | obj-$(CONFIG_ACPI_DOCK) += dock.o | 46 | obj-$(CONFIG_ACPI_DOCK) += dock.o |
| 46 | obj-$(CONFIG_ACPI_VIDEO) += video.o | 47 | obj-$(CONFIG_ACPI_BAY) += bay.o |
| 48 | obj-$(CONFIG_ACPI_VIDEO) += video.o | ||
| 47 | obj-$(CONFIG_ACPI_HOTKEY) += hotkey.o | 49 | obj-$(CONFIG_ACPI_HOTKEY) += hotkey.o |
| 48 | obj-y += pci_root.o pci_link.o pci_irq.o pci_bind.o | 50 | obj-y += pci_root.o pci_link.o pci_irq.o pci_bind.o |
| 49 | obj-$(CONFIG_ACPI_POWER) += power.o | 51 | obj-$(CONFIG_ACPI_POWER) += power.o |
| @@ -56,7 +58,6 @@ obj-$(CONFIG_ACPI_NUMA) += numa.o | |||
| 56 | obj-$(CONFIG_ACPI_ASUS) += asus_acpi.o | 58 | obj-$(CONFIG_ACPI_ASUS) += asus_acpi.o |
| 57 | obj-$(CONFIG_ACPI_IBM) += ibm_acpi.o | 59 | obj-$(CONFIG_ACPI_IBM) += ibm_acpi.o |
| 58 | obj-$(CONFIG_ACPI_TOSHIBA) += toshiba_acpi.o | 60 | obj-$(CONFIG_ACPI_TOSHIBA) += toshiba_acpi.o |
| 59 | obj-y += scan.o motherboard.o | ||
| 60 | obj-$(CONFIG_ACPI_HOTPLUG_MEMORY) += acpi_memhotplug.o | 61 | obj-$(CONFIG_ACPI_HOTPLUG_MEMORY) += acpi_memhotplug.o |
| 61 | obj-y += cm_sbs.o | 62 | obj-y += cm_sbs.o |
| 62 | obj-$(CONFIG_ACPI_SBS) += i2c_ec.o sbs.o | 63 | obj-$(CONFIG_ACPI_SBS) += i2c_ec.o sbs.o |
diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c index 5f43e0d14899..2f4521a48fe7 100644 --- a/drivers/acpi/battery.c +++ b/drivers/acpi/battery.c | |||
| @@ -64,7 +64,7 @@ extern void *acpi_unlock_battery_dir(struct proc_dir_entry *acpi_battery_dir); | |||
| 64 | 64 | ||
| 65 | static int acpi_battery_add(struct acpi_device *device); | 65 | static int acpi_battery_add(struct acpi_device *device); |
| 66 | static int acpi_battery_remove(struct acpi_device *device, int type); | 66 | static int acpi_battery_remove(struct acpi_device *device, int type); |
| 67 | static int acpi_battery_resume(struct acpi_device *device, int status); | 67 | static int acpi_battery_resume(struct acpi_device *device); |
| 68 | 68 | ||
| 69 | static struct acpi_driver acpi_battery_driver = { | 69 | static struct acpi_driver acpi_battery_driver = { |
| 70 | .name = ACPI_BATTERY_DRIVER_NAME, | 70 | .name = ACPI_BATTERY_DRIVER_NAME, |
| @@ -753,7 +753,7 @@ static int acpi_battery_remove(struct acpi_device *device, int type) | |||
| 753 | } | 753 | } |
| 754 | 754 | ||
| 755 | /* this is needed to learn about changes made in suspended state */ | 755 | /* this is needed to learn about changes made in suspended state */ |
| 756 | static int acpi_battery_resume(struct acpi_device *device, int state) | 756 | static int acpi_battery_resume(struct acpi_device *device) |
| 757 | { | 757 | { |
| 758 | struct acpi_battery *battery; | 758 | struct acpi_battery *battery; |
| 759 | 759 | ||
diff --git a/drivers/acpi/bay.c b/drivers/acpi/bay.c new file mode 100644 index 000000000000..667fa1dfa1a3 --- /dev/null +++ b/drivers/acpi/bay.c | |||
| @@ -0,0 +1,490 @@ | |||
| 1 | /* | ||
| 2 | * bay.c - ACPI removable drive bay driver | ||
| 3 | * | ||
| 4 | * Copyright (C) 2006 Kristen Carlson Accardi <kristen.c.accardi@intel.com> | ||
| 5 | * | ||
| 6 | * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
| 7 | * | ||
| 8 | * This program is free software; you can redistribute it and/or modify | ||
| 9 | * it under the terms of the GNU General Public License as published by | ||
| 10 | * the Free Software Foundation; either version 2 of the License, or (at | ||
| 11 | * your option) any later version. | ||
| 12 | * | ||
| 13 | * This program is distributed in the hope that it will be useful, but | ||
| 14 | * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
| 16 | * General Public License for more details. | ||
| 17 | * | ||
| 18 | * You should have received a copy of the GNU General Public License along | ||
| 19 | * with this program; if not, write to the Free Software Foundation, Inc., | ||
| 20 | * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. | ||
| 21 | * | ||
| 22 | * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
| 23 | */ | ||
| 24 | #include <linux/kernel.h> | ||
| 25 | #include <linux/module.h> | ||
| 26 | #include <linux/init.h> | ||
| 27 | #include <linux/types.h> | ||
| 28 | #include <linux/notifier.h> | ||
| 29 | #include <acpi/acpi_bus.h> | ||
| 30 | #include <acpi/acpi_drivers.h> | ||
| 31 | #include <linux/seq_file.h> | ||
| 32 | #include <asm/uaccess.h> | ||
| 33 | #include <linux/platform_device.h> | ||
| 34 | |||
| 35 | #define ACPI_BAY_DRIVER_NAME "ACPI Removable Drive Bay Driver" | ||
| 36 | |||
| 37 | ACPI_MODULE_NAME("bay") | ||
| 38 | MODULE_AUTHOR("Kristen Carlson Accardi"); | ||
| 39 | MODULE_DESCRIPTION(ACPI_BAY_DRIVER_NAME); | ||
| 40 | MODULE_LICENSE("GPL"); | ||
| 41 | #define ACPI_BAY_CLASS "bay" | ||
| 42 | #define ACPI_BAY_COMPONENT 0x10000000 | ||
| 43 | #define _COMPONENT ACPI_BAY_COMPONENT | ||
| 44 | #define bay_dprintk(h,s) {\ | ||
| 45 | char prefix[80] = {'\0'};\ | ||
| 46 | struct acpi_buffer buffer = {sizeof(prefix), prefix};\ | ||
| 47 | acpi_get_name(h, ACPI_FULL_PATHNAME, &buffer);\ | ||
| 48 | printk(KERN_DEBUG PREFIX "%s: %s\n", prefix, s); } | ||
| 49 | static void bay_notify(acpi_handle handle, u32 event, void *data); | ||
| 50 | static int acpi_bay_add(struct acpi_device *device); | ||
| 51 | static int acpi_bay_remove(struct acpi_device *device, int type); | ||
| 52 | |||
| 53 | static struct acpi_driver acpi_bay_driver = { | ||
| 54 | .name = ACPI_BAY_DRIVER_NAME, | ||
| 55 | .class = ACPI_BAY_CLASS, | ||
| 56 | .ids = ACPI_BAY_HID, | ||
| 57 | .ops = { | ||
| 58 | .add = acpi_bay_add, | ||
| 59 | .remove = acpi_bay_remove, | ||
| 60 | }, | ||
| 61 | }; | ||
| 62 | |||
| 63 | struct bay { | ||
| 64 | acpi_handle handle; | ||
| 65 | char *name; | ||
| 66 | struct list_head list; | ||
| 67 | struct platform_device *pdev; | ||
| 68 | }; | ||
| 69 | |||
| 70 | static LIST_HEAD(drive_bays); | ||
| 71 | |||
| 72 | |||
| 73 | /***************************************************************************** | ||
| 74 | * Drive Bay functions * | ||
| 75 | *****************************************************************************/ | ||
| 76 | /** | ||
| 77 | * is_ejectable - see if a device is ejectable | ||
| 78 | * @handle: acpi handle of the device | ||
| 79 | * | ||
| 80 | * If an acpi object has a _EJ0 method, then it is ejectable | ||
| 81 | */ | ||
| 82 | static int is_ejectable(acpi_handle handle) | ||
| 83 | { | ||
| 84 | acpi_status status; | ||
| 85 | acpi_handle tmp; | ||
| 86 | |||
| 87 | status = acpi_get_handle(handle, "_EJ0", &tmp); | ||
| 88 | if (ACPI_FAILURE(status)) | ||
| 89 | return 0; | ||
| 90 | return 1; | ||
| 91 | } | ||
| 92 | |||
| 93 | /** | ||
| 94 | * bay_present - see if the bay device is present | ||
| 95 | * @bay: the drive bay | ||
| 96 | * | ||
| 97 | * execute the _STA method. | ||
| 98 | */ | ||
| 99 | static int bay_present(struct bay *bay) | ||
| 100 | { | ||
| 101 | unsigned long sta; | ||
| 102 | acpi_status status; | ||
| 103 | |||
| 104 | if (bay) { | ||
| 105 | status = acpi_evaluate_integer(bay->handle, "_STA", NULL, &sta); | ||
| 106 | if (ACPI_SUCCESS(status) && sta) | ||
| 107 | return 1; | ||
| 108 | } | ||
| 109 | return 0; | ||
| 110 | } | ||
| 111 | |||
| 112 | /** | ||
| 113 | * eject_device - respond to an eject request | ||
| 114 | * @handle - the device to eject | ||
| 115 | * | ||
| 116 | * Call this devices _EJ0 method. | ||
| 117 | */ | ||
| 118 | static void eject_device(acpi_handle handle) | ||
| 119 | { | ||
| 120 | struct acpi_object_list arg_list; | ||
| 121 | union acpi_object arg; | ||
| 122 | |||
| 123 | bay_dprintk(handle, "Ejecting device"); | ||
| 124 | |||
| 125 | arg_list.count = 1; | ||
| 126 | arg_list.pointer = &arg; | ||
| 127 | arg.type = ACPI_TYPE_INTEGER; | ||
| 128 | arg.integer.value = 1; | ||
| 129 | |||
| 130 | if (ACPI_FAILURE(acpi_evaluate_object(handle, "_EJ0", | ||
| 131 | &arg_list, NULL))) | ||
| 132 | pr_debug("Failed to evaluate _EJ0!\n"); | ||
| 133 | } | ||
| 134 | |||
| 135 | /* | ||
| 136 | * show_present - read method for "present" file in sysfs | ||
| 137 | */ | ||
| 138 | static ssize_t show_present(struct device *dev, | ||
| 139 | struct device_attribute *attr, char *buf) | ||
| 140 | { | ||
| 141 | struct bay *bay = dev_get_drvdata(dev); | ||
| 142 | return snprintf(buf, PAGE_SIZE, "%d\n", bay_present(bay)); | ||
| 143 | |||
| 144 | } | ||
| 145 | DEVICE_ATTR(present, S_IRUGO, show_present, NULL); | ||
| 146 | |||
| 147 | /* | ||
| 148 | * write_eject - write method for "eject" file in sysfs | ||
| 149 | */ | ||
| 150 | static ssize_t write_eject(struct device *dev, struct device_attribute *attr, | ||
| 151 | const char *buf, size_t count) | ||
| 152 | { | ||
| 153 | struct bay *bay = dev_get_drvdata(dev); | ||
| 154 | |||
| 155 | if (!count) | ||
| 156 | return -EINVAL; | ||
| 157 | |||
| 158 | eject_device(bay->handle); | ||
| 159 | return count; | ||
| 160 | } | ||
| 161 | DEVICE_ATTR(eject, S_IWUSR, NULL, write_eject); | ||
| 162 | |||
| 163 | /** | ||
| 164 | * is_ata - see if a device is an ata device | ||
| 165 | * @handle: acpi handle of the device | ||
| 166 | * | ||
| 167 | * If an acpi object has one of 4 ATA ACPI methods defined, | ||
| 168 | * then it is an ATA device | ||
| 169 | */ | ||
| 170 | static int is_ata(acpi_handle handle) | ||
| 171 | { | ||
| 172 | acpi_handle tmp; | ||
| 173 | |||
| 174 | if ((ACPI_SUCCESS(acpi_get_handle(handle, "_GTF", &tmp))) || | ||
| 175 | (ACPI_SUCCESS(acpi_get_handle(handle, "_GTM", &tmp))) || | ||
| 176 | (ACPI_SUCCESS(acpi_get_handle(handle, "_STM", &tmp))) || | ||
| 177 | (ACPI_SUCCESS(acpi_get_handle(handle, "_SDD", &tmp)))) | ||
| 178 | return 1; | ||
| 179 | |||
| 180 | return 0; | ||
| 181 | } | ||
| 182 | |||
| 183 | /** | ||
| 184 | * parent_is_ata(acpi_handle handle) | ||
| 185 | * | ||
| 186 | */ | ||
| 187 | static int parent_is_ata(acpi_handle handle) | ||
| 188 | { | ||
| 189 | acpi_handle phandle; | ||
| 190 | |||
| 191 | if (acpi_get_parent(handle, &phandle)) | ||
| 192 | return 0; | ||
| 193 | |||
| 194 | return is_ata(phandle); | ||
| 195 | } | ||
| 196 | |||
| 197 | /** | ||
| 198 | * is_ejectable_bay - see if a device is an ejectable drive bay | ||
| 199 | * @handle: acpi handle of the device | ||
| 200 | * | ||
| 201 | * If an acpi object is ejectable and has one of the ACPI ATA | ||
| 202 | * methods defined, then we can safely call it an ejectable | ||
| 203 | * drive bay | ||
| 204 | */ | ||
| 205 | static int is_ejectable_bay(acpi_handle handle) | ||
| 206 | { | ||
| 207 | if ((is_ata(handle) || parent_is_ata(handle)) && is_ejectable(handle)) | ||
| 208 | return 1; | ||
| 209 | return 0; | ||
| 210 | } | ||
| 211 | |||
| 212 | /** | ||
| 213 | * eject_removable_drive - try to eject this drive | ||
| 214 | * @dev : the device structure of the drive | ||
| 215 | * | ||
| 216 | * If a device is a removable drive that requires an _EJ0 method | ||
| 217 | * to be executed in order to safely remove from the system, do | ||
| 218 | * it. ATM - always returns success | ||
| 219 | */ | ||
| 220 | int eject_removable_drive(struct device *dev) | ||
| 221 | { | ||
| 222 | acpi_handle handle = DEVICE_ACPI_HANDLE(dev); | ||
| 223 | |||
| 224 | if (handle) { | ||
| 225 | bay_dprintk(handle, "Got device handle"); | ||
| 226 | if (is_ejectable_bay(handle)) | ||
| 227 | eject_device(handle); | ||
| 228 | } else { | ||
| 229 | printk("No acpi handle for device\n"); | ||
| 230 | } | ||
| 231 | |||
| 232 | /* should I return an error code? */ | ||
| 233 | return 0; | ||
| 234 | } | ||
| 235 | EXPORT_SYMBOL_GPL(eject_removable_drive); | ||
| 236 | |||
| 237 | static int acpi_bay_add(struct acpi_device *device) | ||
| 238 | { | ||
| 239 | bay_dprintk(device->handle, "adding bay device"); | ||
| 240 | strcpy(acpi_device_name(device), "Dockable Bay"); | ||
| 241 | strcpy(acpi_device_class(device), "bay"); | ||
| 242 | return 0; | ||
| 243 | } | ||
| 244 | |||
| 245 | static int acpi_bay_add_fs(struct bay *bay) | ||
| 246 | { | ||
| 247 | int ret; | ||
| 248 | struct device *dev = &bay->pdev->dev; | ||
| 249 | |||
| 250 | ret = device_create_file(dev, &dev_attr_present); | ||
| 251 | if (ret) | ||
| 252 | goto add_fs_err; | ||
| 253 | ret = device_create_file(dev, &dev_attr_eject); | ||
| 254 | if (ret) { | ||
| 255 | device_remove_file(dev, &dev_attr_present); | ||
| 256 | goto add_fs_err; | ||
| 257 | } | ||
| 258 | return 0; | ||
| 259 | |||
| 260 | add_fs_err: | ||
| 261 | bay_dprintk(bay->handle, "Error adding sysfs files\n"); | ||
| 262 | return ret; | ||
| 263 | } | ||
| 264 | |||
| 265 | static void acpi_bay_remove_fs(struct bay *bay) | ||
| 266 | { | ||
| 267 | struct device *dev = &bay->pdev->dev; | ||
| 268 | |||
| 269 | /* cleanup sysfs */ | ||
| 270 | device_remove_file(dev, &dev_attr_present); | ||
| 271 | device_remove_file(dev, &dev_attr_eject); | ||
| 272 | } | ||
| 273 | |||
| 274 | static int bay_is_dock_device(acpi_handle handle) | ||
| 275 | { | ||
| 276 | acpi_handle parent; | ||
| 277 | |||
| 278 | acpi_get_parent(handle, &parent); | ||
| 279 | |||
| 280 | /* if the device or it's parent is dependent on the | ||
| 281 | * dock, then we are a dock device | ||
| 282 | */ | ||
| 283 | return (is_dock_device(handle) || is_dock_device(parent)); | ||
| 284 | } | ||
| 285 | |||
| 286 | static int bay_add(acpi_handle handle, int id) | ||
| 287 | { | ||
| 288 | acpi_status status; | ||
| 289 | struct bay *new_bay; | ||
| 290 | struct platform_device *pdev; | ||
| 291 | struct acpi_buffer nbuffer = {ACPI_ALLOCATE_BUFFER, NULL}; | ||
| 292 | acpi_get_name(handle, ACPI_FULL_PATHNAME, &nbuffer); | ||
| 293 | |||
| 294 | bay_dprintk(handle, "Adding notify handler"); | ||
| 295 | |||
| 296 | /* | ||
| 297 | * Initialize bay device structure | ||
| 298 | */ | ||
| 299 | new_bay = kzalloc(GFP_ATOMIC, sizeof(*new_bay)); | ||
| 300 | INIT_LIST_HEAD(&new_bay->list); | ||
| 301 | new_bay->handle = handle; | ||
| 302 | new_bay->name = (char *)nbuffer.pointer; | ||
| 303 | |||
| 304 | /* initialize platform device stuff */ | ||
| 305 | pdev = platform_device_register_simple(ACPI_BAY_CLASS, id, NULL, 0); | ||
| 306 | if (pdev == NULL) { | ||
| 307 | printk(KERN_ERR PREFIX "Error registering bay device\n"); | ||
| 308 | goto bay_add_err; | ||
| 309 | } | ||
| 310 | new_bay->pdev = pdev; | ||
| 311 | platform_set_drvdata(pdev, new_bay); | ||
| 312 | |||
| 313 | if (acpi_bay_add_fs(new_bay)) { | ||
| 314 | platform_device_unregister(new_bay->pdev); | ||
| 315 | goto bay_add_err; | ||
| 316 | } | ||
| 317 | |||
| 318 | /* register for events on this device */ | ||
| 319 | status = acpi_install_notify_handler(handle, ACPI_SYSTEM_NOTIFY, | ||
| 320 | bay_notify, new_bay); | ||
| 321 | if (ACPI_FAILURE(status)) { | ||
| 322 | printk(KERN_ERR PREFIX "Error installing bay notify handler\n"); | ||
| 323 | } | ||
| 324 | |||
| 325 | /* if we are on a dock station, we should register for dock | ||
| 326 | * notifications. | ||
| 327 | */ | ||
| 328 | if (bay_is_dock_device(handle)) { | ||
| 329 | bay_dprintk(handle, "Is dependent on dock\n"); | ||
| 330 | register_hotplug_dock_device(handle, bay_notify, new_bay); | ||
| 331 | } | ||
| 332 | list_add(&new_bay->list, &drive_bays); | ||
| 333 | printk(KERN_INFO PREFIX "Bay [%s] Added\n", new_bay->name); | ||
| 334 | return 0; | ||
| 335 | |||
| 336 | bay_add_err: | ||
| 337 | kfree(new_bay->name); | ||
| 338 | kfree(new_bay); | ||
| 339 | return -ENODEV; | ||
| 340 | } | ||
| 341 | |||
| 342 | static int acpi_bay_remove(struct acpi_device *device, int type) | ||
| 343 | { | ||
| 344 | /*** FIXME: do something here */ | ||
| 345 | return 0; | ||
| 346 | } | ||
| 347 | |||
| 348 | /** | ||
| 349 | * bay_create_acpi_device - add new devices to acpi | ||
| 350 | * @handle - handle of the device to add | ||
| 351 | * | ||
| 352 | * This function will create a new acpi_device for the given | ||
| 353 | * handle if one does not exist already. This should cause | ||
| 354 | * acpi to scan for drivers for the given devices, and call | ||
| 355 | * matching driver's add routine. | ||
| 356 | * | ||
| 357 | * Returns a pointer to the acpi_device corresponding to the handle. | ||
| 358 | */ | ||
| 359 | static struct acpi_device * bay_create_acpi_device(acpi_handle handle) | ||
| 360 | { | ||
| 361 | struct acpi_device *device = NULL; | ||
| 362 | struct acpi_device *parent_device; | ||
| 363 | acpi_handle parent; | ||
| 364 | int ret; | ||
| 365 | |||
| 366 | bay_dprintk(handle, "Trying to get device"); | ||
| 367 | if (acpi_bus_get_device(handle, &device)) { | ||
| 368 | /* | ||
| 369 | * no device created for this object, | ||
| 370 | * so we should create one. | ||
| 371 | */ | ||
| 372 | bay_dprintk(handle, "No device for handle"); | ||
| 373 | acpi_get_parent(handle, &parent); | ||
| 374 | if (acpi_bus_get_device(parent, &parent_device)) | ||
| 375 | parent_device = NULL; | ||
| 376 | |||
| 377 | ret = acpi_bus_add(&device, parent_device, handle, | ||
| 378 | ACPI_BUS_TYPE_DEVICE); | ||
| 379 | if (ret) { | ||
| 380 | pr_debug("error adding bus, %x\n", | ||
| 381 | -ret); | ||
| 382 | return NULL; | ||
| 383 | } | ||
| 384 | } | ||
| 385 | return device; | ||
| 386 | } | ||
| 387 | |||
| 388 | /** | ||
| 389 | * bay_notify - act upon an acpi bay notification | ||
| 390 | * @handle: the bay handle | ||
| 391 | * @event: the acpi event | ||
| 392 | * @data: our driver data struct | ||
| 393 | * | ||
| 394 | */ | ||
| 395 | static void bay_notify(acpi_handle handle, u32 event, void *data) | ||
| 396 | { | ||
| 397 | struct acpi_device *dev; | ||
| 398 | |||
| 399 | bay_dprintk(handle, "Bay event"); | ||
| 400 | |||
| 401 | switch(event) { | ||
| 402 | case ACPI_NOTIFY_BUS_CHECK: | ||
| 403 | printk("Bus Check\n"); | ||
| 404 | case ACPI_NOTIFY_DEVICE_CHECK: | ||
| 405 | printk("Device Check\n"); | ||
| 406 | dev = bay_create_acpi_device(handle); | ||
| 407 | if (dev) | ||
| 408 | acpi_bus_generate_event(dev, event, 0); | ||
| 409 | else | ||
| 410 | printk("No device for generating event\n"); | ||
| 411 | /* wouldn't it be a good idea to just rescan SATA | ||
| 412 | * right here? | ||
| 413 | */ | ||
| 414 | break; | ||
| 415 | case ACPI_NOTIFY_EJECT_REQUEST: | ||
| 416 | printk("Eject request\n"); | ||
| 417 | dev = bay_create_acpi_device(handle); | ||
| 418 | if (dev) | ||
| 419 | acpi_bus_generate_event(dev, event, 0); | ||
| 420 | else | ||
| 421 | printk("No device for generating eventn"); | ||
| 422 | |||
| 423 | /* wouldn't it be a good idea to just call the | ||
| 424 | * eject_device here if we were a SATA device? | ||
| 425 | */ | ||
| 426 | break; | ||
| 427 | default: | ||
| 428 | printk("unknown event %d\n", event); | ||
| 429 | } | ||
| 430 | } | ||
| 431 | |||
| 432 | static acpi_status | ||
| 433 | find_bay(acpi_handle handle, u32 lvl, void *context, void **rv) | ||
| 434 | { | ||
| 435 | int *count = (int *)context; | ||
| 436 | |||
| 437 | /* | ||
| 438 | * there could be more than one ejectable bay. | ||
| 439 | * so, just return AE_OK always so that every object | ||
| 440 | * will be checked. | ||
| 441 | */ | ||
| 442 | if (is_ejectable_bay(handle)) { | ||
| 443 | bay_dprintk(handle, "found ejectable bay"); | ||
| 444 | if (!bay_add(handle, *count)) | ||
| 445 | (*count)++; | ||
| 446 | } | ||
| 447 | return AE_OK; | ||
| 448 | } | ||
| 449 | |||
| 450 | static int __init bay_init(void) | ||
| 451 | { | ||
| 452 | int bays = 0; | ||
| 453 | |||
| 454 | INIT_LIST_HEAD(&drive_bays); | ||
| 455 | |||
| 456 | /* look for dockable drive bays */ | ||
| 457 | acpi_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT, | ||
| 458 | ACPI_UINT32_MAX, find_bay, &bays, NULL); | ||
| 459 | |||
| 460 | if (bays) | ||
| 461 | if ((acpi_bus_register_driver(&acpi_bay_driver) < 0)) | ||
| 462 | printk(KERN_ERR "Unable to register bay driver\n"); | ||
| 463 | |||
| 464 | if (!bays) | ||
| 465 | return -ENODEV; | ||
| 466 | |||
| 467 | return 0; | ||
| 468 | } | ||
| 469 | |||
| 470 | static void __exit bay_exit(void) | ||
| 471 | { | ||
| 472 | struct bay *bay, *tmp; | ||
| 473 | |||
| 474 | list_for_each_entry_safe(bay, tmp, &drive_bays, list) { | ||
| 475 | if (is_dock_device(bay->handle)) | ||
| 476 | unregister_hotplug_dock_device(bay->handle); | ||
| 477 | acpi_bay_remove_fs(bay); | ||
| 478 | acpi_remove_notify_handler(bay->handle, ACPI_SYSTEM_NOTIFY, | ||
| 479 | bay_notify); | ||
| 480 | platform_device_unregister(bay->pdev); | ||
| 481 | kfree(bay->name); | ||
| 482 | kfree(bay); | ||
| 483 | } | ||
| 484 | |||
| 485 | acpi_bus_unregister_driver(&acpi_bay_driver); | ||
| 486 | } | ||
| 487 | |||
| 488 | postcore_initcall(bay_init); | ||
| 489 | module_exit(bay_exit); | ||
| 490 | |||
diff --git a/drivers/acpi/bus.c b/drivers/acpi/bus.c index 15d677e6cee9..c26468da4295 100644 --- a/drivers/acpi/bus.c +++ b/drivers/acpi/bus.c | |||
| @@ -192,7 +192,7 @@ int acpi_bus_set_power(acpi_handle handle, int state) | |||
| 192 | 192 | ||
| 193 | if (!device->flags.power_manageable) { | 193 | if (!device->flags.power_manageable) { |
| 194 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Device `[%s]' is not power manageable\n", | 194 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Device `[%s]' is not power manageable\n", |
| 195 | device->kobj.name)); | 195 | device->dev.kobj.name)); |
| 196 | return -ENODEV; | 196 | return -ENODEV; |
| 197 | } | 197 | } |
| 198 | /* | 198 | /* |
diff --git a/drivers/acpi/button.c b/drivers/acpi/button.c index ac860583c203..c726612fafb6 100644 --- a/drivers/acpi/button.c +++ b/drivers/acpi/button.c | |||
| @@ -75,7 +75,7 @@ static int acpi_button_state_open_fs(struct inode *inode, struct file *file); | |||
| 75 | static struct acpi_driver acpi_button_driver = { | 75 | static struct acpi_driver acpi_button_driver = { |
| 76 | .name = ACPI_BUTTON_DRIVER_NAME, | 76 | .name = ACPI_BUTTON_DRIVER_NAME, |
| 77 | .class = ACPI_BUTTON_CLASS, | 77 | .class = ACPI_BUTTON_CLASS, |
| 78 | .ids = "ACPI_FPB,ACPI_FSB,PNP0C0D,PNP0C0C,PNP0C0E", | 78 | .ids = "button_power,button_sleep,PNP0C0D,PNP0C0C,PNP0C0E", |
| 79 | .ops = { | 79 | .ops = { |
| 80 | .add = acpi_button_add, | 80 | .add = acpi_button_add, |
| 81 | .remove = acpi_button_remove, | 81 | .remove = acpi_button_remove, |
diff --git a/drivers/acpi/container.c b/drivers/acpi/container.c index 0a1863ec91f3..69a68fd394cf 100644 --- a/drivers/acpi/container.c +++ b/drivers/acpi/container.c | |||
| @@ -167,7 +167,7 @@ static void container_notify_cb(acpi_handle handle, u32 type, void *context) | |||
| 167 | if (ACPI_FAILURE(status) || !device) { | 167 | if (ACPI_FAILURE(status) || !device) { |
| 168 | result = container_device_add(&device, handle); | 168 | result = container_device_add(&device, handle); |
| 169 | if (!result) | 169 | if (!result) |
| 170 | kobject_uevent(&device->kobj, | 170 | kobject_uevent(&device->dev.kobj, |
| 171 | KOBJ_ONLINE); | 171 | KOBJ_ONLINE); |
| 172 | else | 172 | else |
| 173 | printk("Failed to add container\n"); | 173 | printk("Failed to add container\n"); |
| @@ -175,13 +175,13 @@ static void container_notify_cb(acpi_handle handle, u32 type, void *context) | |||
| 175 | } else { | 175 | } else { |
| 176 | if (ACPI_SUCCESS(status)) { | 176 | if (ACPI_SUCCESS(status)) { |
| 177 | /* device exist and this is a remove request */ | 177 | /* device exist and this is a remove request */ |
| 178 | kobject_uevent(&device->kobj, KOBJ_OFFLINE); | 178 | kobject_uevent(&device->dev.kobj, KOBJ_OFFLINE); |
| 179 | } | 179 | } |
| 180 | } | 180 | } |
| 181 | break; | 181 | break; |
| 182 | case ACPI_NOTIFY_EJECT_REQUEST: | 182 | case ACPI_NOTIFY_EJECT_REQUEST: |
| 183 | if (!acpi_bus_get_device(handle, &device) && device) { | 183 | if (!acpi_bus_get_device(handle, &device) && device) { |
| 184 | kobject_uevent(&device->kobj, KOBJ_OFFLINE); | 184 | kobject_uevent(&device->dev.kobj, KOBJ_OFFLINE); |
| 185 | } | 185 | } |
| 186 | break; | 186 | break; |
| 187 | default: | 187 | default: |
diff --git a/drivers/acpi/debug.c b/drivers/acpi/debug.c index 35c6af8a83cd..d48f65a8f658 100644 --- a/drivers/acpi/debug.c +++ b/drivers/acpi/debug.c | |||
| @@ -13,14 +13,11 @@ | |||
| 13 | 13 | ||
| 14 | #define _COMPONENT ACPI_SYSTEM_COMPONENT | 14 | #define _COMPONENT ACPI_SYSTEM_COMPONENT |
| 15 | ACPI_MODULE_NAME("debug") | 15 | ACPI_MODULE_NAME("debug") |
| 16 | #define ACPI_SYSTEM_FILE_DEBUG_LAYER "debug_layer" | 16 | |
| 17 | #define ACPI_SYSTEM_FILE_DEBUG_LEVEL "debug_level" | ||
| 18 | #ifdef MODULE_PARAM_PREFIX | 17 | #ifdef MODULE_PARAM_PREFIX |
| 19 | #undef MODULE_PARAM_PREFIX | 18 | #undef MODULE_PARAM_PREFIX |
| 20 | #endif | 19 | #endif |
| 21 | #define MODULE_PARAM_PREFIX | 20 | #define MODULE_PARAM_PREFIX "acpi." |
| 22 | module_param(acpi_dbg_layer, uint, 0400); | ||
| 23 | module_param(acpi_dbg_level, uint, 0400); | ||
| 24 | 21 | ||
| 25 | struct acpi_dlayer { | 22 | struct acpi_dlayer { |
| 26 | const char *name; | 23 | const char *name; |
| @@ -86,6 +83,60 @@ static const struct acpi_dlevel acpi_debug_levels[] = { | |||
| 86 | ACPI_DEBUG_INIT(ACPI_LV_EVENTS), | 83 | ACPI_DEBUG_INIT(ACPI_LV_EVENTS), |
| 87 | }; | 84 | }; |
| 88 | 85 | ||
| 86 | /* -------------------------------------------------------------------------- | ||
| 87 | FS Interface (/sys) | ||
| 88 | -------------------------------------------------------------------------- */ | ||
| 89 | static int param_get_debug_layer(char *buffer, struct kernel_param *kp) { | ||
| 90 | int result = 0; | ||
| 91 | int i; | ||
| 92 | |||
| 93 | result = sprintf(buffer, "%-25s\tHex SET\n", "Description"); | ||
| 94 | |||
| 95 | for(i = 0; i <ARRAY_SIZE(acpi_debug_layers); i++) { | ||
| 96 | result += sprintf(buffer+result, "%-25s\t0x%08lX [%c]\n", | ||
| 97 | acpi_debug_layers[i].name, | ||
| 98 | acpi_debug_layers[i].value, | ||
| 99 | (acpi_dbg_layer & acpi_debug_layers[i].value) ? '*' : ' '); | ||
| 100 | } | ||
| 101 | result += sprintf(buffer+result, "%-25s\t0x%08X [%c]\n", "ACPI_ALL_DRIVERS", | ||
| 102 | ACPI_ALL_DRIVERS, | ||
| 103 | (acpi_dbg_layer & ACPI_ALL_DRIVERS) == | ||
| 104 | ACPI_ALL_DRIVERS ? '*' : (acpi_dbg_layer & | ||
| 105 | ACPI_ALL_DRIVERS) == 0 ? ' ' : '-'); | ||
| 106 | result += sprintf(buffer+result, "--\ndebug_layer = 0x%08X ( * = enabled)\n", acpi_dbg_layer); | ||
| 107 | |||
| 108 | return result; | ||
| 109 | } | ||
| 110 | |||
| 111 | static int param_get_debug_level(char *buffer, struct kernel_param *kp) { | ||
| 112 | int result = 0; | ||
| 113 | int i; | ||
| 114 | |||
| 115 | result = sprintf(buffer, "%-25s\tHex SET\n", "Description"); | ||
| 116 | |||
| 117 | for (i = 0; i < ARRAY_SIZE(acpi_debug_levels); i++) { | ||
| 118 | result += sprintf(buffer+result, "%-25s\t0x%08lX [%c]\n", | ||
| 119 | acpi_debug_levels[i].name, | ||
| 120 | acpi_debug_levels[i].value, | ||
| 121 | (acpi_dbg_level & acpi_debug_levels[i]. | ||
| 122 | value) ? '*' : ' '); | ||
| 123 | } | ||
| 124 | result += sprintf(buffer+result, "--\ndebug_level = 0x%08X (* = enabled)\n", | ||
| 125 | acpi_dbg_level); | ||
| 126 | |||
| 127 | return result; | ||
| 128 | } | ||
| 129 | |||
| 130 | module_param_call(debug_layer, param_set_uint, param_get_debug_layer, &acpi_dbg_layer, 0644); | ||
| 131 | module_param_call(debug_level, param_set_uint, param_get_debug_level, &acpi_dbg_level, 0644); | ||
| 132 | |||
| 133 | /* -------------------------------------------------------------------------- | ||
| 134 | FS Interface (/proc) | ||
| 135 | -------------------------------------------------------------------------- */ | ||
| 136 | #ifdef CONFIG_ACPI_PROCFS | ||
| 137 | #define ACPI_SYSTEM_FILE_DEBUG_LAYER "debug_layer" | ||
| 138 | #define ACPI_SYSTEM_FILE_DEBUG_LEVEL "debug_level" | ||
| 139 | |||
| 89 | static int | 140 | static int |
| 90 | acpi_system_read_debug(char *page, | 141 | acpi_system_read_debug(char *page, |
| 91 | char **start, off_t off, int count, int *eof, void *data) | 142 | char **start, off_t off, int count, int *eof, void *data) |
| @@ -221,3 +272,4 @@ static int __init acpi_debug_init(void) | |||
| 221 | } | 272 | } |
| 222 | 273 | ||
| 223 | subsys_initcall(acpi_debug_init); | 274 | subsys_initcall(acpi_debug_init); |
| 275 | #endif | ||
diff --git a/drivers/acpi/dock.c b/drivers/acpi/dock.c index 90990a4b6526..688e83a16906 100644 --- a/drivers/acpi/dock.c +++ b/drivers/acpi/dock.c | |||
| @@ -615,20 +615,28 @@ static acpi_status | |||
| 615 | find_dock_devices(acpi_handle handle, u32 lvl, void *context, void **rv) | 615 | find_dock_devices(acpi_handle handle, u32 lvl, void *context, void **rv) |
| 616 | { | 616 | { |
| 617 | acpi_status status; | 617 | acpi_status status; |
| 618 | acpi_handle tmp; | 618 | acpi_handle tmp, parent; |
| 619 | struct dock_station *ds = context; | 619 | struct dock_station *ds = context; |
| 620 | struct dock_dependent_device *dd; | 620 | struct dock_dependent_device *dd; |
| 621 | 621 | ||
| 622 | status = acpi_bus_get_ejd(handle, &tmp); | 622 | status = acpi_bus_get_ejd(handle, &tmp); |
| 623 | if (ACPI_FAILURE(status)) | 623 | if (ACPI_FAILURE(status)) { |
| 624 | return AE_OK; | 624 | /* try the parent device as well */ |
| 625 | status = acpi_get_parent(handle, &parent); | ||
| 626 | if (ACPI_FAILURE(status)) | ||
| 627 | goto fdd_out; | ||
| 628 | /* see if parent is dependent on dock */ | ||
| 629 | status = acpi_bus_get_ejd(parent, &tmp); | ||
| 630 | if (ACPI_FAILURE(status)) | ||
| 631 | goto fdd_out; | ||
| 632 | } | ||
| 625 | 633 | ||
| 626 | if (tmp == ds->handle) { | 634 | if (tmp == ds->handle) { |
| 627 | dd = alloc_dock_dependent_device(handle); | 635 | dd = alloc_dock_dependent_device(handle); |
| 628 | if (dd) | 636 | if (dd) |
| 629 | add_dock_dependent_device(ds, dd); | 637 | add_dock_dependent_device(ds, dd); |
| 630 | } | 638 | } |
| 631 | 639 | fdd_out: | |
| 632 | return AE_OK; | 640 | return AE_OK; |
| 633 | } | 641 | } |
| 634 | 642 | ||
diff --git a/drivers/acpi/fan.c b/drivers/acpi/fan.c index f305a826ca2d..af22fdf73413 100644 --- a/drivers/acpi/fan.c +++ b/drivers/acpi/fan.c | |||
| @@ -48,8 +48,8 @@ MODULE_LICENSE("GPL"); | |||
| 48 | 48 | ||
| 49 | static int acpi_fan_add(struct acpi_device *device); | 49 | static int acpi_fan_add(struct acpi_device *device); |
| 50 | static int acpi_fan_remove(struct acpi_device *device, int type); | 50 | static int acpi_fan_remove(struct acpi_device *device, int type); |
| 51 | static int acpi_fan_suspend(struct acpi_device *device, int state); | 51 | static int acpi_fan_suspend(struct acpi_device *device, pm_message_t state); |
| 52 | static int acpi_fan_resume(struct acpi_device *device, int state); | 52 | static int acpi_fan_resume(struct acpi_device *device); |
| 53 | 53 | ||
| 54 | static struct acpi_driver acpi_fan_driver = { | 54 | static struct acpi_driver acpi_fan_driver = { |
| 55 | .name = ACPI_FAN_DRIVER_NAME, | 55 | .name = ACPI_FAN_DRIVER_NAME, |
| @@ -237,7 +237,7 @@ static int acpi_fan_remove(struct acpi_device *device, int type) | |||
| 237 | return 0; | 237 | return 0; |
| 238 | } | 238 | } |
| 239 | 239 | ||
| 240 | static int acpi_fan_suspend(struct acpi_device *device, int state) | 240 | static int acpi_fan_suspend(struct acpi_device *device, pm_message_t state) |
| 241 | { | 241 | { |
| 242 | if (!device) | 242 | if (!device) |
| 243 | return -EINVAL; | 243 | return -EINVAL; |
| @@ -247,7 +247,7 @@ static int acpi_fan_suspend(struct acpi_device *device, int state) | |||
| 247 | return AE_OK; | 247 | return AE_OK; |
| 248 | } | 248 | } |
| 249 | 249 | ||
| 250 | static int acpi_fan_resume(struct acpi_device *device, int state) | 250 | static int acpi_fan_resume(struct acpi_device *device) |
| 251 | { | 251 | { |
| 252 | int result = 0; | 252 | int result = 0; |
| 253 | int power_state = 0; | 253 | int power_state = 0; |
diff --git a/drivers/acpi/glue.c b/drivers/acpi/glue.c index 8a0324b43e53..7b6c9ff9bebe 100644 --- a/drivers/acpi/glue.c +++ b/drivers/acpi/glue.c | |||
| @@ -86,129 +86,6 @@ static int acpi_find_bridge_device(struct device *dev, acpi_handle * handle) | |||
| 86 | return ret; | 86 | return ret; |
| 87 | } | 87 | } |
| 88 | 88 | ||
| 89 | /* Get PCI root bridge's handle from its segment and bus number */ | ||
| 90 | struct acpi_find_pci_root { | ||
| 91 | unsigned int seg; | ||
| 92 | unsigned int bus; | ||
| 93 | acpi_handle handle; | ||
| 94 | }; | ||
| 95 | |||
| 96 | static acpi_status | ||
| 97 | do_root_bridge_busnr_callback(struct acpi_resource *resource, void *data) | ||
| 98 | { | ||
| 99 | unsigned long *busnr = data; | ||
| 100 | struct acpi_resource_address64 address; | ||
| 101 | |||
| 102 | if (resource->type != ACPI_RESOURCE_TYPE_ADDRESS16 && | ||
| 103 | resource->type != ACPI_RESOURCE_TYPE_ADDRESS32 && | ||
| 104 | resource->type != ACPI_RESOURCE_TYPE_ADDRESS64) | ||
| 105 | return AE_OK; | ||
| 106 | |||
| 107 | acpi_resource_to_address64(resource, &address); | ||
| 108 | if ((address.address_length > 0) && | ||
| 109 | (address.resource_type == ACPI_BUS_NUMBER_RANGE)) | ||
| 110 | *busnr = address.minimum; | ||
| 111 | |||
| 112 | return AE_OK; | ||
| 113 | } | ||
| 114 | |||
| 115 | static int get_root_bridge_busnr(acpi_handle handle) | ||
| 116 | { | ||
| 117 | acpi_status status; | ||
| 118 | unsigned long bus, bbn; | ||
| 119 | struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; | ||
| 120 | |||
| 121 | acpi_get_name(handle, ACPI_FULL_PATHNAME, &buffer); | ||
| 122 | |||
| 123 | status = acpi_evaluate_integer(handle, METHOD_NAME__BBN, NULL, | ||
| 124 | &bbn); | ||
| 125 | if (status == AE_NOT_FOUND) { | ||
| 126 | /* Assume bus = 0 */ | ||
| 127 | printk(KERN_INFO PREFIX | ||
| 128 | "Assume root bridge [%s] bus is 0\n", | ||
| 129 | (char *)buffer.pointer); | ||
| 130 | status = AE_OK; | ||
| 131 | bbn = 0; | ||
| 132 | } | ||
| 133 | if (ACPI_FAILURE(status)) { | ||
| 134 | bbn = -ENODEV; | ||
| 135 | goto exit; | ||
| 136 | } | ||
| 137 | if (bbn > 0) | ||
| 138 | goto exit; | ||
| 139 | |||
| 140 | /* _BBN in some systems return 0 for all root bridges */ | ||
| 141 | bus = -1; | ||
| 142 | status = acpi_walk_resources(handle, METHOD_NAME__CRS, | ||
| 143 | do_root_bridge_busnr_callback, &bus); | ||
| 144 | /* If _CRS failed, we just use _BBN */ | ||
| 145 | if (ACPI_FAILURE(status) || (bus == -1)) | ||
| 146 | goto exit; | ||
| 147 | /* We select _CRS */ | ||
| 148 | if (bbn != bus) { | ||
| 149 | printk(KERN_INFO PREFIX | ||
| 150 | "_BBN and _CRS returns different value for %s. Select _CRS\n", | ||
| 151 | (char *)buffer.pointer); | ||
| 152 | bbn = bus; | ||
| 153 | } | ||
| 154 | exit: | ||
| 155 | kfree(buffer.pointer); | ||
| 156 | return (int)bbn; | ||
| 157 | } | ||
| 158 | |||
| 159 | static acpi_status | ||
| 160 | find_pci_rootbridge(acpi_handle handle, u32 lvl, void *context, void **rv) | ||
| 161 | { | ||
| 162 | struct acpi_find_pci_root *find = (struct acpi_find_pci_root *)context; | ||
| 163 | unsigned long seg, bus; | ||
| 164 | acpi_status status; | ||
| 165 | int tmp; | ||
| 166 | struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; | ||
| 167 | |||
| 168 | acpi_get_name(handle, ACPI_FULL_PATHNAME, &buffer); | ||
| 169 | |||
| 170 | status = acpi_evaluate_integer(handle, METHOD_NAME__SEG, NULL, &seg); | ||
| 171 | if (status == AE_NOT_FOUND) { | ||
| 172 | /* Assume seg = 0 */ | ||
| 173 | status = AE_OK; | ||
| 174 | seg = 0; | ||
| 175 | } | ||
| 176 | if (ACPI_FAILURE(status)) { | ||
| 177 | status = AE_CTRL_DEPTH; | ||
| 178 | goto exit; | ||
| 179 | } | ||
| 180 | |||
| 181 | tmp = get_root_bridge_busnr(handle); | ||
| 182 | if (tmp < 0) { | ||
| 183 | printk(KERN_ERR PREFIX | ||
| 184 | "Find root bridge failed for %s\n", | ||
| 185 | (char *)buffer.pointer); | ||
| 186 | status = AE_CTRL_DEPTH; | ||
| 187 | goto exit; | ||
| 188 | } | ||
| 189 | bus = tmp; | ||
| 190 | |||
| 191 | if (seg == find->seg && bus == find->bus) | ||
| 192 | { | ||
| 193 | find->handle = handle; | ||
| 194 | status = AE_CTRL_TERMINATE; | ||
| 195 | } | ||
| 196 | else | ||
| 197 | status = AE_OK; | ||
| 198 | exit: | ||
| 199 | kfree(buffer.pointer); | ||
| 200 | return status; | ||
| 201 | } | ||
| 202 | |||
| 203 | acpi_handle acpi_get_pci_rootbridge_handle(unsigned int seg, unsigned int bus) | ||
| 204 | { | ||
| 205 | struct acpi_find_pci_root find = { seg, bus, NULL }; | ||
| 206 | |||
| 207 | acpi_get_devices(PCI_ROOT_HID_STRING, find_pci_rootbridge, &find, NULL); | ||
| 208 | return find.handle; | ||
| 209 | } | ||
| 210 | EXPORT_SYMBOL_GPL(acpi_get_pci_rootbridge_handle); | ||
| 211 | |||
| 212 | /* Get device's handler per its address under its parent */ | 89 | /* Get device's handler per its address under its parent */ |
| 213 | struct acpi_find_child { | 90 | struct acpi_find_child { |
| 214 | acpi_handle handle; | 91 | acpi_handle handle; |
diff --git a/drivers/acpi/motherboard.c b/drivers/acpi/motherboard.c deleted file mode 100644 index b61107b05262..000000000000 --- a/drivers/acpi/motherboard.c +++ /dev/null | |||
| @@ -1,191 +0,0 @@ | |||
| 1 | /* | ||
| 2 | * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
| 3 | * This program is free software; you can redistribute it and/or modify | ||
| 4 | * it under the terms of the GNU General Public License as published by | ||
| 5 | * the Free Software Foundation; either version 2 of the License, or (at | ||
| 6 | * your option) any later version. | ||
| 7 | * | ||
| 8 | * This program is distributed in the hope that it will be useful, but | ||
| 9 | * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
| 11 | * General Public License for more details. | ||
| 12 | * | ||
| 13 | * You should have received a copy of the GNU General Public License along | ||
| 14 | * with this program; if not, write to the Free Software Foundation, Inc., | ||
| 15 | * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. | ||
| 16 | * | ||
| 17 | * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
| 18 | */ | ||
| 19 | |||
| 20 | /* Purpose: Prevent PCMCIA cards from using motherboard resources. */ | ||
| 21 | |||
| 22 | #include <linux/kernel.h> | ||
| 23 | #include <linux/init.h> | ||
| 24 | #include <linux/types.h> | ||
| 25 | #include <linux/pci.h> | ||
| 26 | #include <linux/ioport.h> | ||
| 27 | #include <asm/io.h> | ||
| 28 | |||
| 29 | #include <acpi/acpi_bus.h> | ||
| 30 | #include <acpi/acpi_drivers.h> | ||
| 31 | |||
| 32 | #define _COMPONENT ACPI_SYSTEM_COMPONENT | ||
| 33 | ACPI_MODULE_NAME("acpi_motherboard") | ||
| 34 | |||
| 35 | /* Dell use PNP0C01 instead of PNP0C02 */ | ||
| 36 | #define ACPI_MB_HID1 "PNP0C01" | ||
| 37 | #define ACPI_MB_HID2 "PNP0C02" | ||
| 38 | /** | ||
| 39 | * Doesn't care about legacy IO ports, only IO ports beyond 0x1000 are reserved | ||
| 40 | * Doesn't care about the failure of 'request_region', since other may reserve | ||
| 41 | * the io ports as well | ||
| 42 | */ | ||
| 43 | #define IS_RESERVED_ADDR(base, len) \ | ||
| 44 | (((len) > 0) && ((base) > 0) && ((base) + (len) < IO_SPACE_LIMIT) \ | ||
| 45 | && ((base) + (len) > PCIBIOS_MIN_IO)) | ||
| 46 | /* | ||
| 47 | * Clearing the flag (IORESOURCE_BUSY) allows drivers to use | ||
| 48 | * the io ports if they really know they can use it, while | ||
| 49 | * still preventing hotplug PCI devices from using it. | ||
| 50 | */ | ||
| 51 | |||
| 52 | /* | ||
| 53 | * When CONFIG_PNP is enabled, pnp/system.c binds to PNP0C01 | ||
| 54 | * and PNP0C02, redundant with acpi_reserve_io_ranges(). | ||
| 55 | * But acpi_reserve_io_ranges() is necessary for !CONFIG_PNP. | ||
| 56 | */ | ||
| 57 | static acpi_status acpi_reserve_io_ranges(struct acpi_resource *res, void *data) | ||
| 58 | { | ||
| 59 | struct resource *requested_res = NULL; | ||
| 60 | |||
| 61 | |||
| 62 | if (res->type == ACPI_RESOURCE_TYPE_IO) { | ||
| 63 | struct acpi_resource_io *io_res = &res->data.io; | ||
| 64 | |||
| 65 | if (io_res->minimum != io_res->maximum) | ||
| 66 | return AE_OK; | ||
| 67 | if (IS_RESERVED_ADDR | ||
| 68 | (io_res->minimum, io_res->address_length)) { | ||
| 69 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, | ||
| 70 | "Motherboard resources 0x%08x - 0x%08x\n", | ||
| 71 | io_res->minimum, | ||
| 72 | io_res->minimum + | ||
| 73 | io_res->address_length)); | ||
| 74 | requested_res = | ||
| 75 | request_region(io_res->minimum, | ||
| 76 | io_res->address_length, "motherboard"); | ||
| 77 | } | ||
| 78 | } else if (res->type == ACPI_RESOURCE_TYPE_FIXED_IO) { | ||
| 79 | struct acpi_resource_fixed_io *fixed_io_res = | ||
| 80 | &res->data.fixed_io; | ||
| 81 | |||
| 82 | if (IS_RESERVED_ADDR | ||
| 83 | (fixed_io_res->address, fixed_io_res->address_length)) { | ||
| 84 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, | ||
| 85 | "Motherboard resources 0x%08x - 0x%08x\n", | ||
| 86 | fixed_io_res->address, | ||
| 87 | fixed_io_res->address + | ||
| 88 | fixed_io_res->address_length)); | ||
| 89 | requested_res = | ||
| 90 | request_region(fixed_io_res->address, | ||
| 91 | fixed_io_res->address_length, | ||
| 92 | "motherboard"); | ||
| 93 | } | ||
| 94 | } else { | ||
| 95 | /* Memory mapped IO? */ | ||
| 96 | } | ||
| 97 | |||
| 98 | if (requested_res) | ||
| 99 | requested_res->flags &= ~IORESOURCE_BUSY; | ||
| 100 | return AE_OK; | ||
| 101 | } | ||
| 102 | |||
| 103 | static int acpi_motherboard_add(struct acpi_device *device) | ||
| 104 | { | ||
| 105 | if (!device) | ||
| 106 | return -EINVAL; | ||
| 107 | acpi_walk_resources(device->handle, METHOD_NAME__CRS, | ||
| 108 | acpi_reserve_io_ranges, NULL); | ||
| 109 | |||
| 110 | return 0; | ||
| 111 | } | ||
| 112 | |||
| 113 | static struct acpi_driver acpi_motherboard_driver1 = { | ||
| 114 | .name = "motherboard", | ||
| 115 | .class = "", | ||
| 116 | .ids = ACPI_MB_HID1, | ||
| 117 | .ops = { | ||
| 118 | .add = acpi_motherboard_add, | ||
| 119 | }, | ||
| 120 | }; | ||
| 121 | |||
| 122 | static struct acpi_driver acpi_motherboard_driver2 = { | ||
| 123 | .name = "motherboard", | ||
| 124 | .class = "", | ||
| 125 | .ids = ACPI_MB_HID2, | ||
| 126 | .ops = { | ||
| 127 | .add = acpi_motherboard_add, | ||
| 128 | }, | ||
| 129 | }; | ||
| 130 | |||
| 131 | static void __init acpi_request_region (struct acpi_generic_address *addr, | ||
| 132 | unsigned int length, char *desc) | ||
| 133 | { | ||
| 134 | if (!addr->address || !length) | ||
| 135 | return; | ||
| 136 | |||
| 137 | if (addr->space_id == ACPI_ADR_SPACE_SYSTEM_IO) | ||
| 138 | request_region(addr->address, length, desc); | ||
| 139 | else if (addr->space_id == ACPI_ADR_SPACE_SYSTEM_MEMORY) | ||
| 140 | request_mem_region(addr->address, length, desc); | ||
| 141 | } | ||
| 142 | |||
| 143 | static void __init acpi_reserve_resources(void) | ||
| 144 | { | ||
| 145 | acpi_request_region(&acpi_gbl_FADT.xpm1a_event_block, | ||
| 146 | acpi_gbl_FADT.pm1_event_length, "ACPI PM1a_EVT_BLK"); | ||
| 147 | |||
| 148 | acpi_request_region(&acpi_gbl_FADT.xpm1b_event_block, | ||
| 149 | acpi_gbl_FADT.pm1_event_length, "ACPI PM1b_EVT_BLK"); | ||
| 150 | |||
| 151 | acpi_request_region(&acpi_gbl_FADT.xpm1a_control_block, | ||
| 152 | acpi_gbl_FADT.pm1_control_length, "ACPI PM1a_CNT_BLK"); | ||
| 153 | |||
| 154 | acpi_request_region(&acpi_gbl_FADT.xpm1b_control_block, | ||
| 155 | acpi_gbl_FADT.pm1_control_length, "ACPI PM1b_CNT_BLK"); | ||
| 156 | |||
| 157 | if (acpi_gbl_FADT.pm_timer_length == 4) | ||
| 158 | acpi_request_region(&acpi_gbl_FADT.xpm_timer_block, 4, "ACPI PM_TMR"); | ||
| 159 | |||
| 160 | acpi_request_region(&acpi_gbl_FADT.xpm2_control_block, | ||
| 161 | acpi_gbl_FADT.pm2_control_length, "ACPI PM2_CNT_BLK"); | ||
| 162 | |||
| 163 | /* Length of GPE blocks must be a non-negative multiple of 2 */ | ||
| 164 | |||
| 165 | if (!(acpi_gbl_FADT.gpe0_block_length & 0x1)) | ||
| 166 | acpi_request_region(&acpi_gbl_FADT.xgpe0_block, | ||
| 167 | acpi_gbl_FADT.gpe0_block_length, "ACPI GPE0_BLK"); | ||
| 168 | |||
| 169 | if (!(acpi_gbl_FADT.gpe1_block_length & 0x1)) | ||
| 170 | acpi_request_region(&acpi_gbl_FADT.xgpe1_block, | ||
| 171 | acpi_gbl_FADT.gpe1_block_length, "ACPI GPE1_BLK"); | ||
| 172 | } | ||
| 173 | |||
| 174 | static int __init acpi_motherboard_init(void) | ||
| 175 | { | ||
| 176 | acpi_bus_register_driver(&acpi_motherboard_driver1); | ||
| 177 | acpi_bus_register_driver(&acpi_motherboard_driver2); | ||
| 178 | /* | ||
| 179 | * Guarantee motherboard IO reservation first | ||
| 180 | * This module must run after scan.c | ||
| 181 | */ | ||
| 182 | if (!acpi_disabled) | ||
| 183 | acpi_reserve_resources(); | ||
| 184 | return 0; | ||
| 185 | } | ||
| 186 | |||
| 187 | /** | ||
| 188 | * Reserve motherboard resources after PCI claim BARs, | ||
| 189 | * but before PCI assign resources for uninitialized PCI devices | ||
| 190 | */ | ||
| 191 | fs_initcall(acpi_motherboard_init); | ||
diff --git a/drivers/acpi/osl.c b/drivers/acpi/osl.c index a28f5b8972b4..0f6f3bcbc8eb 100644 --- a/drivers/acpi/osl.c +++ b/drivers/acpi/osl.c | |||
| @@ -76,6 +76,54 @@ static acpi_osd_handler acpi_irq_handler; | |||
| 76 | static void *acpi_irq_context; | 76 | static void *acpi_irq_context; |
| 77 | static struct workqueue_struct *kacpid_wq; | 77 | static struct workqueue_struct *kacpid_wq; |
| 78 | 78 | ||
| 79 | static void __init acpi_request_region (struct acpi_generic_address *addr, | ||
| 80 | unsigned int length, char *desc) | ||
| 81 | { | ||
| 82 | struct resource *res; | ||
| 83 | |||
| 84 | if (!addr->address || !length) | ||
| 85 | return; | ||
| 86 | |||
| 87 | if (addr->space_id == ACPI_ADR_SPACE_SYSTEM_IO) | ||
| 88 | res = request_region(addr->address, length, desc); | ||
| 89 | else if (addr->space_id == ACPI_ADR_SPACE_SYSTEM_MEMORY) | ||
| 90 | res = request_mem_region(addr->address, length, desc); | ||
| 91 | } | ||
| 92 | |||
| 93 | static int __init acpi_reserve_resources(void) | ||
| 94 | { | ||
| 95 | acpi_request_region(&acpi_gbl_FADT.xpm1a_event_block, acpi_gbl_FADT.pm1_event_length, | ||
| 96 | "ACPI PM1a_EVT_BLK"); | ||
| 97 | |||
| 98 | acpi_request_region(&acpi_gbl_FADT.xpm1b_event_block, acpi_gbl_FADT.pm1_event_length, | ||
| 99 | "ACPI PM1b_EVT_BLK"); | ||
| 100 | |||
| 101 | acpi_request_region(&acpi_gbl_FADT.xpm1a_control_block, acpi_gbl_FADT.pm1_control_length, | ||
| 102 | "ACPI PM1a_CNT_BLK"); | ||
| 103 | |||
| 104 | acpi_request_region(&acpi_gbl_FADT.xpm1b_control_block, acpi_gbl_FADT.pm1_control_length, | ||
| 105 | "ACPI PM1b_CNT_BLK"); | ||
| 106 | |||
| 107 | if (acpi_gbl_FADT.pm_timer_length == 4) | ||
| 108 | acpi_request_region(&acpi_gbl_FADT.xpm_timer_block, 4, "ACPI PM_TMR"); | ||
| 109 | |||
| 110 | acpi_request_region(&acpi_gbl_FADT.xpm2_control_block, acpi_gbl_FADT.pm2_control_length, | ||
| 111 | "ACPI PM2_CNT_BLK"); | ||
| 112 | |||
| 113 | /* Length of GPE blocks must be a non-negative multiple of 2 */ | ||
| 114 | |||
| 115 | if (!(acpi_gbl_FADT.gpe0_block_length & 0x1)) | ||
| 116 | acpi_request_region(&acpi_gbl_FADT.xgpe0_block, | ||
| 117 | acpi_gbl_FADT.gpe0_block_length, "ACPI GPE0_BLK"); | ||
| 118 | |||
| 119 | if (!(acpi_gbl_FADT.gpe1_block_length & 0x1)) | ||
| 120 | acpi_request_region(&acpi_gbl_FADT.xgpe1_block, | ||
| 121 | acpi_gbl_FADT.gpe1_block_length, "ACPI GPE1_BLK"); | ||
| 122 | |||
| 123 | return 0; | ||
| 124 | } | ||
| 125 | device_initcall(acpi_reserve_resources); | ||
| 126 | |||
| 79 | acpi_status acpi_os_initialize(void) | 127 | acpi_status acpi_os_initialize(void) |
| 80 | { | 128 | { |
| 81 | return AE_OK; | 129 | return AE_OK; |
diff --git a/drivers/acpi/pci_root.c b/drivers/acpi/pci_root.c index a860efa2c562..4ecf701687e8 100644 --- a/drivers/acpi/pci_root.c +++ b/drivers/acpi/pci_root.c | |||
| @@ -117,6 +117,19 @@ void acpi_pci_unregister_driver(struct acpi_pci_driver *driver) | |||
| 117 | 117 | ||
| 118 | EXPORT_SYMBOL(acpi_pci_unregister_driver); | 118 | EXPORT_SYMBOL(acpi_pci_unregister_driver); |
| 119 | 119 | ||
| 120 | acpi_handle acpi_get_pci_rootbridge_handle(unsigned int seg, unsigned int bus) | ||
| 121 | { | ||
| 122 | struct acpi_pci_root *tmp; | ||
| 123 | |||
| 124 | list_for_each_entry(tmp, &acpi_pci_roots, node) { | ||
| 125 | if ((tmp->id.segment == (u16) seg) && (tmp->id.bus == (u16) bus)) | ||
| 126 | return tmp->device->handle; | ||
| 127 | } | ||
| 128 | return NULL; | ||
| 129 | } | ||
| 130 | |||
| 131 | EXPORT_SYMBOL_GPL(acpi_get_pci_rootbridge_handle); | ||
| 132 | |||
| 120 | static acpi_status | 133 | static acpi_status |
| 121 | get_root_bridge_busnr_callback(struct acpi_resource *resource, void *data) | 134 | get_root_bridge_busnr_callback(struct acpi_resource *resource, void *data) |
| 122 | { | 135 | { |
| @@ -152,6 +165,21 @@ static acpi_status try_get_root_bridge_busnr(acpi_handle handle, int *busnum) | |||
| 152 | return AE_OK; | 165 | return AE_OK; |
| 153 | } | 166 | } |
| 154 | 167 | ||
| 168 | static void acpi_pci_bridge_scan(struct acpi_device *device) | ||
| 169 | { | ||
| 170 | int status; | ||
| 171 | struct acpi_device *child = NULL; | ||
| 172 | |||
| 173 | if (device->flags.bus_address) | ||
| 174 | if (device->parent && device->parent->ops.bind) { | ||
| 175 | status = device->parent->ops.bind(device); | ||
| 176 | if (!status) { | ||
| 177 | list_for_each_entry(child, &device->children, node) | ||
| 178 | acpi_pci_bridge_scan(child); | ||
| 179 | } | ||
| 180 | } | ||
| 181 | } | ||
| 182 | |||
| 155 | static int acpi_pci_root_add(struct acpi_device *device) | 183 | static int acpi_pci_root_add(struct acpi_device *device) |
| 156 | { | 184 | { |
| 157 | int result = 0; | 185 | int result = 0; |
| @@ -160,6 +188,7 @@ static int acpi_pci_root_add(struct acpi_device *device) | |||
| 160 | acpi_status status = AE_OK; | 188 | acpi_status status = AE_OK; |
| 161 | unsigned long value = 0; | 189 | unsigned long value = 0; |
| 162 | acpi_handle handle = NULL; | 190 | acpi_handle handle = NULL; |
| 191 | struct acpi_device *child; | ||
| 163 | 192 | ||
| 164 | 193 | ||
| 165 | if (!device) | 194 | if (!device) |
| @@ -175,9 +204,6 @@ static int acpi_pci_root_add(struct acpi_device *device) | |||
| 175 | strcpy(acpi_device_class(device), ACPI_PCI_ROOT_CLASS); | 204 | strcpy(acpi_device_class(device), ACPI_PCI_ROOT_CLASS); |
| 176 | acpi_driver_data(device) = root; | 205 | acpi_driver_data(device) = root; |
| 177 | 206 | ||
| 178 | /* | ||
| 179 | * TBD: Doesn't the bus driver automatically set this? | ||
| 180 | */ | ||
| 181 | device->ops.bind = acpi_pci_bind; | 207 | device->ops.bind = acpi_pci_bind; |
| 182 | 208 | ||
| 183 | /* | 209 | /* |
| @@ -299,6 +325,12 @@ static int acpi_pci_root_add(struct acpi_device *device) | |||
| 299 | result = acpi_pci_irq_add_prt(device->handle, root->id.segment, | 325 | result = acpi_pci_irq_add_prt(device->handle, root->id.segment, |
| 300 | root->id.bus); | 326 | root->id.bus); |
| 301 | 327 | ||
| 328 | /* | ||
| 329 | * Scan and bind all _ADR-Based Devices | ||
| 330 | */ | ||
| 331 | list_for_each_entry(child, &device->children, node) | ||
| 332 | acpi_pci_bridge_scan(child); | ||
| 333 | |||
| 302 | end: | 334 | end: |
| 303 | if (result) { | 335 | if (result) { |
| 304 | if (!list_empty(&root->node)) | 336 | if (!list_empty(&root->node)) |
diff --git a/drivers/acpi/processor_core.c b/drivers/acpi/processor_core.c index eacf9a252019..0079bc51082c 100644 --- a/drivers/acpi/processor_core.c +++ b/drivers/acpi/processor_core.c | |||
| @@ -814,7 +814,7 @@ int acpi_processor_device_add(acpi_handle handle, struct acpi_device **device) | |||
| 814 | return -ENODEV; | 814 | return -ENODEV; |
| 815 | 815 | ||
| 816 | if ((pr->id >= 0) && (pr->id < NR_CPUS)) { | 816 | if ((pr->id >= 0) && (pr->id < NR_CPUS)) { |
| 817 | kobject_uevent(&(*device)->kobj, KOBJ_ONLINE); | 817 | kobject_uevent(&(*device)->dev.kobj, KOBJ_ONLINE); |
| 818 | } | 818 | } |
| 819 | return 0; | 819 | return 0; |
| 820 | } | 820 | } |
| @@ -852,13 +852,13 @@ acpi_processor_hotplug_notify(acpi_handle handle, u32 event, void *data) | |||
| 852 | } | 852 | } |
| 853 | 853 | ||
| 854 | if (pr->id >= 0 && (pr->id < NR_CPUS)) { | 854 | if (pr->id >= 0 && (pr->id < NR_CPUS)) { |
| 855 | kobject_uevent(&device->kobj, KOBJ_OFFLINE); | 855 | kobject_uevent(&device->dev.kobj, KOBJ_OFFLINE); |
| 856 | break; | 856 | break; |
| 857 | } | 857 | } |
| 858 | 858 | ||
| 859 | result = acpi_processor_start(device); | 859 | result = acpi_processor_start(device); |
| 860 | if ((!result) && ((pr->id >= 0) && (pr->id < NR_CPUS))) { | 860 | if ((!result) && ((pr->id >= 0) && (pr->id < NR_CPUS))) { |
| 861 | kobject_uevent(&device->kobj, KOBJ_ONLINE); | 861 | kobject_uevent(&device->dev.kobj, KOBJ_ONLINE); |
| 862 | } else { | 862 | } else { |
| 863 | printk(KERN_ERR PREFIX "Device [%s] failed to start\n", | 863 | printk(KERN_ERR PREFIX "Device [%s] failed to start\n", |
| 864 | acpi_device_bid(device)); | 864 | acpi_device_bid(device)); |
| @@ -881,7 +881,7 @@ acpi_processor_hotplug_notify(acpi_handle handle, u32 event, void *data) | |||
| 881 | } | 881 | } |
| 882 | 882 | ||
| 883 | if ((pr->id < NR_CPUS) && (cpu_present(pr->id))) | 883 | if ((pr->id < NR_CPUS) && (cpu_present(pr->id))) |
| 884 | kobject_uevent(&device->kobj, KOBJ_OFFLINE); | 884 | kobject_uevent(&device->dev.kobj, KOBJ_OFFLINE); |
| 885 | break; | 885 | break; |
| 886 | default: | 886 | default: |
| 887 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, | 887 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, |
diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c index 0de458664642..64f26db10c8e 100644 --- a/drivers/acpi/scan.c +++ b/drivers/acpi/scan.c | |||
| @@ -21,101 +21,305 @@ extern struct acpi_device *acpi_root; | |||
| 21 | #define ACPI_BUS_DEVICE_NAME "System Bus" | 21 | #define ACPI_BUS_DEVICE_NAME "System Bus" |
| 22 | 22 | ||
| 23 | static LIST_HEAD(acpi_device_list); | 23 | static LIST_HEAD(acpi_device_list); |
| 24 | static LIST_HEAD(acpi_bus_id_list); | ||
| 24 | DEFINE_SPINLOCK(acpi_device_lock); | 25 | DEFINE_SPINLOCK(acpi_device_lock); |
| 25 | LIST_HEAD(acpi_wakeup_device_list); | 26 | LIST_HEAD(acpi_wakeup_device_list); |
| 26 | 27 | ||
| 28 | struct acpi_device_bus_id{ | ||
| 29 | char bus_id[15]; | ||
| 30 | unsigned int instance_no; | ||
| 31 | struct list_head node; | ||
| 32 | }; | ||
| 33 | static int acpi_eject_operation(acpi_handle handle, int lockable) | ||
| 34 | { | ||
| 35 | struct acpi_object_list arg_list; | ||
| 36 | union acpi_object arg; | ||
| 37 | acpi_status status = AE_OK; | ||
| 38 | |||
| 39 | /* | ||
| 40 | * TBD: evaluate _PS3? | ||
| 41 | */ | ||
| 42 | |||
| 43 | if (lockable) { | ||
| 44 | arg_list.count = 1; | ||
| 45 | arg_list.pointer = &arg; | ||
| 46 | arg.type = ACPI_TYPE_INTEGER; | ||
| 47 | arg.integer.value = 0; | ||
| 48 | acpi_evaluate_object(handle, "_LCK", &arg_list, NULL); | ||
| 49 | } | ||
| 50 | |||
| 51 | arg_list.count = 1; | ||
| 52 | arg_list.pointer = &arg; | ||
| 53 | arg.type = ACPI_TYPE_INTEGER; | ||
| 54 | arg.integer.value = 1; | ||
| 55 | |||
| 56 | /* | ||
| 57 | * TBD: _EJD support. | ||
| 58 | */ | ||
| 59 | |||
| 60 | status = acpi_evaluate_object(handle, "_EJ0", &arg_list, NULL); | ||
| 61 | if (ACPI_FAILURE(status)) { | ||
| 62 | return (-ENODEV); | ||
| 63 | } | ||
| 64 | |||
| 65 | return (0); | ||
| 66 | } | ||
| 27 | 67 | ||
| 28 | static void acpi_device_release(struct kobject *kobj) | 68 | static ssize_t |
| 69 | acpi_eject_store(struct device *d, struct device_attribute *attr, | ||
| 70 | const char *buf, size_t count) | ||
| 29 | { | 71 | { |
| 30 | struct acpi_device *dev = container_of(kobj, struct acpi_device, kobj); | 72 | int result; |
| 31 | kfree(dev->pnp.cid_list); | 73 | int ret = count; |
| 32 | kfree(dev); | 74 | int islockable; |
| 75 | acpi_status status; | ||
| 76 | acpi_handle handle; | ||
| 77 | acpi_object_type type = 0; | ||
| 78 | struct acpi_device *acpi_device = to_acpi_device(d); | ||
| 79 | |||
| 80 | if ((!count) || (buf[0] != '1')) { | ||
| 81 | return -EINVAL; | ||
| 82 | } | ||
| 83 | #ifndef FORCE_EJECT | ||
| 84 | if (acpi_device->driver == NULL) { | ||
| 85 | ret = -ENODEV; | ||
| 86 | goto err; | ||
| 87 | } | ||
| 88 | #endif | ||
| 89 | status = acpi_get_type(acpi_device->handle, &type); | ||
| 90 | if (ACPI_FAILURE(status) || (!acpi_device->flags.ejectable)) { | ||
| 91 | ret = -ENODEV; | ||
| 92 | goto err; | ||
| 93 | } | ||
| 94 | |||
| 95 | islockable = acpi_device->flags.lockable; | ||
| 96 | handle = acpi_device->handle; | ||
| 97 | |||
| 98 | result = acpi_bus_trim(acpi_device, 1); | ||
| 99 | |||
| 100 | if (!result) | ||
| 101 | result = acpi_eject_operation(handle, islockable); | ||
| 102 | |||
| 103 | if (result) { | ||
| 104 | ret = -EBUSY; | ||
| 105 | } | ||
| 106 | err: | ||
| 107 | return ret; | ||
| 33 | } | 108 | } |
| 34 | 109 | ||
| 35 | struct acpi_device_attribute { | 110 | static DEVICE_ATTR(eject, 0200, NULL, acpi_eject_store); |
| 36 | struct attribute attr; | 111 | |
| 37 | ssize_t(*show) (struct acpi_device *, char *); | 112 | static ssize_t |
| 38 | ssize_t(*store) (struct acpi_device *, const char *, size_t); | 113 | acpi_device_hid_show(struct device *dev, struct device_attribute *attr, char *buf) { |
| 39 | }; | 114 | struct acpi_device *acpi_dev = to_acpi_device(dev); |
| 115 | |||
| 116 | return sprintf(buf, "%s\n", acpi_dev->pnp.hardware_id); | ||
| 117 | } | ||
| 118 | static DEVICE_ATTR(hid, 0444, acpi_device_hid_show, NULL); | ||
| 119 | |||
| 120 | static ssize_t | ||
| 121 | acpi_device_path_show(struct device *dev, struct device_attribute *attr, char *buf) { | ||
| 122 | struct acpi_device *acpi_dev = to_acpi_device(dev); | ||
| 123 | struct acpi_buffer path = {ACPI_ALLOCATE_BUFFER, NULL}; | ||
| 124 | int result; | ||
| 125 | |||
| 126 | result = acpi_get_name(acpi_dev->handle, ACPI_FULL_PATHNAME, &path); | ||
| 127 | if(result) | ||
| 128 | goto end; | ||
| 129 | |||
| 130 | result = sprintf(buf, "%s\n", (char*)path.pointer); | ||
| 131 | kfree(path.pointer); | ||
| 132 | end: | ||
| 133 | return result; | ||
| 134 | } | ||
| 135 | static DEVICE_ATTR(path, 0444, acpi_device_path_show, NULL); | ||
| 136 | |||
| 137 | static int acpi_device_setup_files(struct acpi_device *dev) | ||
| 138 | { | ||
| 139 | acpi_status status; | ||
| 140 | acpi_handle temp; | ||
| 141 | int result = 0; | ||
| 142 | |||
| 143 | /* | ||
| 144 | * Devices gotten from FADT don't have a "path" attribute | ||
| 145 | */ | ||
| 146 | if(dev->handle) { | ||
| 147 | result = device_create_file(&dev->dev, &dev_attr_path); | ||
| 148 | if(result) | ||
| 149 | goto end; | ||
| 150 | } | ||
| 40 | 151 | ||
| 41 | typedef void acpi_device_sysfs_files(struct kobject *, | 152 | if(dev->flags.hardware_id) { |
| 42 | const struct attribute *); | 153 | result = device_create_file(&dev->dev, &dev_attr_hid); |
| 154 | if(result) | ||
| 155 | goto end; | ||
| 156 | } | ||
| 43 | 157 | ||
| 44 | static void setup_sys_fs_device_files(struct acpi_device *dev, | 158 | /* |
| 45 | acpi_device_sysfs_files * func); | 159 | * If device has _EJ0, 'eject' file is created that is used to trigger |
| 160 | * hot-removal function from userland. | ||
| 161 | */ | ||
| 162 | status = acpi_get_handle(dev->handle, "_EJ0", &temp); | ||
| 163 | if (ACPI_SUCCESS(status)) | ||
| 164 | result = device_create_file(&dev->dev, &dev_attr_eject); | ||
| 165 | end: | ||
| 166 | return result; | ||
| 167 | } | ||
| 46 | 168 | ||
| 47 | #define create_sysfs_device_files(dev) \ | 169 | static void acpi_device_remove_files(struct acpi_device *dev) |
| 48 | setup_sys_fs_device_files(dev, (acpi_device_sysfs_files *)&sysfs_create_file) | 170 | { |
| 49 | #define remove_sysfs_device_files(dev) \ | 171 | acpi_status status; |
| 50 | setup_sys_fs_device_files(dev, (acpi_device_sysfs_files *)&sysfs_remove_file) | 172 | acpi_handle temp; |
| 51 | 173 | ||
| 52 | #define to_acpi_device(n) container_of(n, struct acpi_device, kobj) | 174 | /* |
| 53 | #define to_handle_attr(n) container_of(n, struct acpi_device_attribute, attr); | 175 | * If device has _EJ0, 'eject' file is created that is used to trigger |
| 176 | * hot-removal function from userland. | ||
| 177 | */ | ||
| 178 | status = acpi_get_handle(dev->handle, "_EJ0", &temp); | ||
| 179 | if (ACPI_SUCCESS(status)) | ||
| 180 | device_remove_file(&dev->dev, &dev_attr_eject); | ||
| 54 | 181 | ||
| 55 | static ssize_t acpi_device_attr_show(struct kobject *kobj, | 182 | if(dev->flags.hardware_id) |
| 56 | struct attribute *attr, char *buf) | 183 | device_remove_file(&dev->dev, &dev_attr_hid); |
| 184 | if(dev->handle) | ||
| 185 | device_remove_file(&dev->dev, &dev_attr_path); | ||
| 186 | } | ||
| 187 | /* -------------------------------------------------------------------------- | ||
| 188 | ACPI Bus operations | ||
| 189 | -------------------------------------------------------------------------- */ | ||
| 190 | static void acpi_device_release(struct device *dev) | ||
| 57 | { | 191 | { |
| 58 | struct acpi_device *device = to_acpi_device(kobj); | 192 | struct acpi_device *acpi_dev = to_acpi_device(dev); |
| 59 | struct acpi_device_attribute *attribute = to_handle_attr(attr); | 193 | |
| 60 | return attribute->show ? attribute->show(device, buf) : -EIO; | 194 | kfree(acpi_dev->pnp.cid_list); |
| 195 | kfree(acpi_dev); | ||
| 61 | } | 196 | } |
| 62 | static ssize_t acpi_device_attr_store(struct kobject *kobj, | 197 | |
| 63 | struct attribute *attr, const char *buf, | 198 | static int acpi_device_suspend(struct device *dev, pm_message_t state) |
| 64 | size_t len) | ||
| 65 | { | 199 | { |
| 66 | struct acpi_device *device = to_acpi_device(kobj); | 200 | struct acpi_device *acpi_dev = to_acpi_device(dev); |
| 67 | struct acpi_device_attribute *attribute = to_handle_attr(attr); | 201 | struct acpi_driver *acpi_drv = acpi_dev->driver; |
| 68 | return attribute->store ? attribute->store(device, buf, len) : -EIO; | 202 | |
| 203 | if (acpi_drv && acpi_drv->ops.suspend) | ||
| 204 | return acpi_drv->ops.suspend(acpi_dev, state); | ||
| 205 | return 0; | ||
| 69 | } | 206 | } |
| 70 | 207 | ||
| 71 | static struct sysfs_ops acpi_device_sysfs_ops = { | 208 | static int acpi_device_resume(struct device *dev) |
| 72 | .show = acpi_device_attr_show, | 209 | { |
| 73 | .store = acpi_device_attr_store, | 210 | struct acpi_device *acpi_dev = to_acpi_device(dev); |
| 74 | }; | 211 | struct acpi_driver *acpi_drv = acpi_dev->driver; |
| 75 | 212 | ||
| 76 | static struct kobj_type ktype_acpi_ns = { | 213 | if (acpi_drv && acpi_drv->ops.resume) |
| 77 | .sysfs_ops = &acpi_device_sysfs_ops, | 214 | return acpi_drv->ops.resume(acpi_dev); |
| 78 | .release = acpi_device_release, | 215 | return 0; |
| 79 | }; | 216 | } |
| 80 | 217 | ||
| 81 | static int namespace_uevent(struct kset *kset, struct kobject *kobj, | 218 | static int acpi_bus_match(struct device *dev, struct device_driver *drv) |
| 82 | char **envp, int num_envp, char *buffer, | ||
| 83 | int buffer_size) | ||
| 84 | { | 219 | { |
| 85 | struct acpi_device *dev = to_acpi_device(kobj); | 220 | struct acpi_device *acpi_dev = to_acpi_device(dev); |
| 86 | int i = 0; | 221 | struct acpi_driver *acpi_drv = to_acpi_driver(drv); |
| 87 | int len = 0; | ||
| 88 | 222 | ||
| 89 | if (!dev->driver) | 223 | return !acpi_match_ids(acpi_dev, acpi_drv->ids); |
| 90 | return 0; | 224 | } |
| 91 | 225 | ||
| 92 | if (add_uevent_var(envp, num_envp, &i, buffer, buffer_size, &len, | 226 | static int acpi_device_uevent(struct device *dev, char **envp, int num_envp, |
| 93 | "PHYSDEVDRIVER=%s", dev->driver->name)) | 227 | char *buffer, int buffer_size) |
| 228 | { | ||
| 229 | struct acpi_device *acpi_dev = to_acpi_device(dev); | ||
| 230 | int i = 0, length = 0, ret = 0; | ||
| 231 | |||
| 232 | if (acpi_dev->flags.hardware_id) | ||
| 233 | ret = add_uevent_var(envp, num_envp, &i, | ||
| 234 | buffer, buffer_size, &length, | ||
| 235 | "HWID=%s", acpi_dev->pnp.hardware_id); | ||
| 236 | if (ret) | ||
| 94 | return -ENOMEM; | 237 | return -ENOMEM; |
| 238 | if (acpi_dev->flags.compatible_ids) { | ||
| 239 | int j; | ||
| 240 | struct acpi_compatible_id_list *cid_list; | ||
| 241 | |||
| 242 | cid_list = acpi_dev->pnp.cid_list; | ||
| 243 | |||
| 244 | for (j = 0; j < cid_list->count; j++) { | ||
| 245 | ret = add_uevent_var(envp, num_envp, &i, buffer, | ||
| 246 | buffer_size, &length, "COMPTID=%s", | ||
| 247 | cid_list->id[j].value); | ||
| 248 | if (ret) | ||
| 249 | return -ENOMEM; | ||
| 250 | } | ||
| 251 | } | ||
| 95 | 252 | ||
| 96 | envp[i] = NULL; | 253 | envp[i] = NULL; |
| 254 | return 0; | ||
| 255 | } | ||
| 256 | |||
| 257 | static int acpi_bus_driver_init(struct acpi_device *, struct acpi_driver *); | ||
| 258 | static int acpi_start_single_object(struct acpi_device *); | ||
| 259 | static int acpi_device_probe(struct device * dev) | ||
| 260 | { | ||
| 261 | struct acpi_device *acpi_dev = to_acpi_device(dev); | ||
| 262 | struct acpi_driver *acpi_drv = to_acpi_driver(dev->driver); | ||
| 263 | int ret; | ||
| 264 | |||
| 265 | ret = acpi_bus_driver_init(acpi_dev, acpi_drv); | ||
| 266 | if (!ret) { | ||
| 267 | if (acpi_dev->bus_ops.acpi_op_start) | ||
| 268 | acpi_start_single_object(acpi_dev); | ||
| 269 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, | ||
| 270 | "Found driver [%s] for device [%s]\n", | ||
| 271 | acpi_drv->name, acpi_dev->pnp.bus_id)); | ||
| 272 | get_device(dev); | ||
| 273 | } | ||
| 274 | return ret; | ||
| 275 | } | ||
| 97 | 276 | ||
| 277 | static int acpi_device_remove(struct device * dev) | ||
| 278 | { | ||
| 279 | struct acpi_device *acpi_dev = to_acpi_device(dev); | ||
| 280 | struct acpi_driver *acpi_drv = acpi_dev->driver; | ||
| 281 | |||
| 282 | if (acpi_drv) { | ||
| 283 | if (acpi_drv->ops.stop) | ||
| 284 | acpi_drv->ops.stop(acpi_dev, acpi_dev->removal_type); | ||
| 285 | if (acpi_drv->ops.remove) | ||
| 286 | acpi_drv->ops.remove(acpi_dev, acpi_dev->removal_type); | ||
| 287 | } | ||
| 288 | acpi_dev->driver = NULL; | ||
| 289 | acpi_driver_data(dev) = NULL; | ||
| 290 | |||
| 291 | put_device(dev); | ||
| 98 | return 0; | 292 | return 0; |
| 99 | } | 293 | } |
| 100 | 294 | ||
| 101 | static struct kset_uevent_ops namespace_uevent_ops = { | 295 | static void acpi_device_shutdown(struct device *dev) |
| 102 | .uevent = &namespace_uevent, | 296 | { |
| 103 | }; | 297 | struct acpi_device *acpi_dev = to_acpi_device(dev); |
| 298 | struct acpi_driver *acpi_drv = acpi_dev->driver; | ||
| 299 | |||
| 300 | if (acpi_drv && acpi_drv->ops.shutdown) | ||
| 301 | acpi_drv->ops.shutdown(acpi_dev); | ||
| 104 | 302 | ||
| 105 | static struct kset acpi_namespace_kset = { | 303 | return ; |
| 106 | .kobj = { | 304 | } |
| 107 | .name = "namespace", | 305 | |
| 108 | }, | 306 | static struct bus_type acpi_bus_type = { |
| 109 | .subsys = &acpi_subsys, | 307 | .name = "acpi", |
| 110 | .ktype = &ktype_acpi_ns, | 308 | .suspend = acpi_device_suspend, |
| 111 | .uevent_ops = &namespace_uevent_ops, | 309 | .resume = acpi_device_resume, |
| 310 | .shutdown = acpi_device_shutdown, | ||
| 311 | .match = acpi_bus_match, | ||
| 312 | .probe = acpi_device_probe, | ||
| 313 | .remove = acpi_device_remove, | ||
| 314 | .uevent = acpi_device_uevent, | ||
| 112 | }; | 315 | }; |
| 113 | 316 | ||
| 114 | static void acpi_device_register(struct acpi_device *device, | 317 | static int acpi_device_register(struct acpi_device *device, |
| 115 | struct acpi_device *parent) | 318 | struct acpi_device *parent) |
| 116 | { | 319 | { |
| 117 | int err; | 320 | int result; |
| 118 | 321 | struct acpi_device_bus_id *acpi_device_bus_id, *new_bus_id; | |
| 322 | int found = 0; | ||
| 119 | /* | 323 | /* |
| 120 | * Linkage | 324 | * Linkage |
| 121 | * ------- | 325 | * ------- |
| @@ -126,7 +330,33 @@ static void acpi_device_register(struct acpi_device *device, | |||
| 126 | INIT_LIST_HEAD(&device->g_list); | 330 | INIT_LIST_HEAD(&device->g_list); |
| 127 | INIT_LIST_HEAD(&device->wakeup_list); | 331 | INIT_LIST_HEAD(&device->wakeup_list); |
| 128 | 332 | ||
| 333 | new_bus_id = kzalloc(sizeof(struct acpi_device_bus_id), GFP_KERNEL); | ||
| 334 | if (!new_bus_id) { | ||
| 335 | printk(KERN_ERR PREFIX "Memory allocation error\n"); | ||
| 336 | return -ENOMEM; | ||
| 337 | } | ||
| 338 | |||
| 129 | spin_lock(&acpi_device_lock); | 339 | spin_lock(&acpi_device_lock); |
| 340 | /* | ||
| 341 | * Find suitable bus_id and instance number in acpi_bus_id_list | ||
| 342 | * If failed, create one and link it into acpi_bus_id_list | ||
| 343 | */ | ||
| 344 | list_for_each_entry(acpi_device_bus_id, &acpi_bus_id_list, node) { | ||
| 345 | if(!strcmp(acpi_device_bus_id->bus_id, device->flags.hardware_id? device->pnp.hardware_id : "device")) { | ||
| 346 | acpi_device_bus_id->instance_no ++; | ||
| 347 | found = 1; | ||
| 348 | kfree(new_bus_id); | ||
| 349 | break; | ||
| 350 | } | ||
| 351 | } | ||
| 352 | if(!found) { | ||
| 353 | acpi_device_bus_id = new_bus_id; | ||
| 354 | strcpy(acpi_device_bus_id->bus_id, device->flags.hardware_id ? device->pnp.hardware_id : "device"); | ||
| 355 | acpi_device_bus_id->instance_no = 0; | ||
| 356 | list_add_tail(&acpi_device_bus_id->node, &acpi_bus_id_list); | ||
| 357 | } | ||
| 358 | sprintf(device->dev.bus_id, "%s:%02x", acpi_device_bus_id->bus_id, acpi_device_bus_id->instance_no); | ||
| 359 | |||
| 130 | if (device->parent) { | 360 | if (device->parent) { |
| 131 | list_add_tail(&device->node, &device->parent->children); | 361 | list_add_tail(&device->node, &device->parent->children); |
| 132 | list_add_tail(&device->g_list, &device->parent->g_list); | 362 | list_add_tail(&device->g_list, &device->parent->g_list); |
| @@ -136,16 +366,33 @@ static void acpi_device_register(struct acpi_device *device, | |||
| 136 | list_add_tail(&device->wakeup_list, &acpi_wakeup_device_list); | 366 | list_add_tail(&device->wakeup_list, &acpi_wakeup_device_list); |
| 137 | spin_unlock(&acpi_device_lock); | 367 | spin_unlock(&acpi_device_lock); |
| 138 | 368 | ||
| 139 | strlcpy(device->kobj.name, device->pnp.bus_id, KOBJ_NAME_LEN); | 369 | if (device->parent) |
| 140 | if (parent) | 370 | device->dev.parent = &parent->dev; |
| 141 | device->kobj.parent = &parent->kobj; | 371 | device->dev.bus = &acpi_bus_type; |
| 142 | device->kobj.ktype = &ktype_acpi_ns; | 372 | device_initialize(&device->dev); |
| 143 | device->kobj.kset = &acpi_namespace_kset; | 373 | device->dev.release = &acpi_device_release; |
| 144 | err = kobject_register(&device->kobj); | 374 | result = device_add(&device->dev); |
| 145 | if (err < 0) | 375 | if(result) { |
| 146 | printk(KERN_WARNING "%s: kobject_register error: %d\n", | 376 | printk("Error adding device %s", device->dev.bus_id); |
| 147 | __FUNCTION__, err); | 377 | goto end; |
| 148 | create_sysfs_device_files(device); | 378 | } |
| 379 | |||
| 380 | result = acpi_device_setup_files(device); | ||
| 381 | if(result) | ||
| 382 | ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error creating sysfs interface for device %s\n", device->dev.bus_id)); | ||
| 383 | |||
| 384 | device->removal_type = ACPI_BUS_REMOVAL_NORMAL; | ||
| 385 | return 0; | ||
| 386 | end: | ||
| 387 | spin_lock(&acpi_device_lock); | ||
| 388 | if (device->parent) { | ||
| 389 | list_del(&device->node); | ||
| 390 | list_del(&device->g_list); | ||
| 391 | } else | ||
| 392 | list_del(&device->g_list); | ||
| 393 | list_del(&device->wakeup_list); | ||
| 394 | spin_unlock(&acpi_device_lock); | ||
| 395 | return result; | ||
| 149 | } | 396 | } |
| 150 | 397 | ||
| 151 | static void acpi_device_unregister(struct acpi_device *device, int type) | 398 | static void acpi_device_unregister(struct acpi_device *device, int type) |
| @@ -158,81 +405,143 @@ static void acpi_device_unregister(struct acpi_device *device, int type) | |||
| 158 | list_del(&device->g_list); | 405 | list_del(&device->g_list); |
| 159 | 406 | ||
| 160 | list_del(&device->wakeup_list); | 407 | list_del(&device->wakeup_list); |
| 161 | |||
| 162 | spin_unlock(&acpi_device_lock); | 408 | spin_unlock(&acpi_device_lock); |
| 163 | 409 | ||
| 164 | acpi_detach_data(device->handle, acpi_bus_data_handler); | 410 | acpi_detach_data(device->handle, acpi_bus_data_handler); |
| 165 | remove_sysfs_device_files(device); | 411 | |
| 166 | kobject_unregister(&device->kobj); | 412 | acpi_device_remove_files(device); |
| 413 | device_unregister(&device->dev); | ||
| 167 | } | 414 | } |
| 168 | 415 | ||
| 169 | void acpi_bus_data_handler(acpi_handle handle, u32 function, void *context) | 416 | /* -------------------------------------------------------------------------- |
| 417 | Driver Management | ||
| 418 | -------------------------------------------------------------------------- */ | ||
| 419 | /** | ||
| 420 | * acpi_bus_driver_init - add a device to a driver | ||
| 421 | * @device: the device to add and initialize | ||
| 422 | * @driver: driver for the device | ||
| 423 | * | ||
| 424 | * Used to initialize a device via its device driver. Called whenever a | ||
| 425 | * driver is bound to a device. Invokes the driver's add() ops. | ||
| 426 | */ | ||
| 427 | static int | ||
| 428 | acpi_bus_driver_init(struct acpi_device *device, struct acpi_driver *driver) | ||
| 170 | { | 429 | { |
| 430 | int result = 0; | ||
| 171 | 431 | ||
| 172 | /* TBD */ | ||
| 173 | 432 | ||
| 174 | return; | 433 | if (!device || !driver) |
| 175 | } | 434 | return -EINVAL; |
| 176 | 435 | ||
| 177 | static int acpi_bus_get_power_flags(struct acpi_device *device) | 436 | if (!driver->ops.add) |
| 178 | { | 437 | return -ENOSYS; |
| 179 | acpi_status status = 0; | ||
| 180 | acpi_handle handle = NULL; | ||
| 181 | u32 i = 0; | ||
| 182 | 438 | ||
| 439 | result = driver->ops.add(device); | ||
| 440 | if (result) { | ||
| 441 | device->driver = NULL; | ||
| 442 | acpi_driver_data(device) = NULL; | ||
| 443 | return result; | ||
| 444 | } | ||
| 183 | 445 | ||
| 184 | /* | 446 | device->driver = driver; |
| 185 | * Power Management Flags | ||
| 186 | */ | ||
| 187 | status = acpi_get_handle(device->handle, "_PSC", &handle); | ||
| 188 | if (ACPI_SUCCESS(status)) | ||
| 189 | device->power.flags.explicit_get = 1; | ||
| 190 | status = acpi_get_handle(device->handle, "_IRC", &handle); | ||
| 191 | if (ACPI_SUCCESS(status)) | ||
| 192 | device->power.flags.inrush_current = 1; | ||
| 193 | 447 | ||
| 194 | /* | 448 | /* |
| 195 | * Enumerate supported power management states | 449 | * TBD - Configuration Management: Assign resources to device based |
| 450 | * upon possible configuration and currently allocated resources. | ||
| 196 | */ | 451 | */ |
| 197 | for (i = ACPI_STATE_D0; i <= ACPI_STATE_D3; i++) { | ||
| 198 | struct acpi_device_power_state *ps = &device->power.states[i]; | ||
| 199 | char object_name[5] = { '_', 'P', 'R', '0' + i, '\0' }; | ||
| 200 | 452 | ||
| 201 | /* Evaluate "_PRx" to se if power resources are referenced */ | 453 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, |
| 202 | acpi_evaluate_reference(device->handle, object_name, NULL, | 454 | "Driver successfully bound to device\n")); |
| 203 | &ps->resources); | 455 | return 0; |
| 204 | if (ps->resources.count) { | 456 | } |
| 205 | device->power.flags.power_resources = 1; | ||
| 206 | ps->flags.valid = 1; | ||
| 207 | } | ||
| 208 | 457 | ||
| 209 | /* Evaluate "_PSx" to see if we can do explicit sets */ | 458 | static int acpi_start_single_object(struct acpi_device *device) |
| 210 | object_name[2] = 'S'; | 459 | { |
| 211 | status = acpi_get_handle(device->handle, object_name, &handle); | 460 | int result = 0; |
| 212 | if (ACPI_SUCCESS(status)) { | 461 | struct acpi_driver *driver; |
| 213 | ps->flags.explicit_set = 1; | ||
| 214 | ps->flags.valid = 1; | ||
| 215 | } | ||
| 216 | 462 | ||
| 217 | /* State is valid if we have some power control */ | ||
| 218 | if (ps->resources.count || ps->flags.explicit_set) | ||
| 219 | ps->flags.valid = 1; | ||
| 220 | 463 | ||
| 221 | ps->power = -1; /* Unknown - driver assigned */ | 464 | if (!(driver = device->driver)) |
| 222 | ps->latency = -1; /* Unknown - driver assigned */ | 465 | return 0; |
| 466 | |||
| 467 | if (driver->ops.start) { | ||
| 468 | result = driver->ops.start(device); | ||
| 469 | if (result && driver->ops.remove) | ||
| 470 | driver->ops.remove(device, ACPI_BUS_REMOVAL_NORMAL); | ||
| 223 | } | 471 | } |
| 224 | 472 | ||
| 225 | /* Set defaults for D0 and D3 states (always valid) */ | 473 | return result; |
| 226 | device->power.states[ACPI_STATE_D0].flags.valid = 1; | 474 | } |
| 227 | device->power.states[ACPI_STATE_D0].power = 100; | ||
| 228 | device->power.states[ACPI_STATE_D3].flags.valid = 1; | ||
| 229 | device->power.states[ACPI_STATE_D3].power = 0; | ||
| 230 | 475 | ||
| 231 | /* TBD: System wake support and resource requirements. */ | 476 | /** |
| 477 | * acpi_bus_register_driver - register a driver with the ACPI bus | ||
| 478 | * @driver: driver being registered | ||
| 479 | * | ||
| 480 | * Registers a driver with the ACPI bus. Searches the namespace for all | ||
| 481 | * devices that match the driver's criteria and binds. Returns zero for | ||
| 482 | * success or a negative error status for failure. | ||
| 483 | */ | ||
| 484 | int acpi_bus_register_driver(struct acpi_driver *driver) | ||
| 485 | { | ||
| 486 | int ret; | ||
| 232 | 487 | ||
| 233 | device->power.state = ACPI_STATE_UNKNOWN; | 488 | if (acpi_disabled) |
| 489 | return -ENODEV; | ||
| 490 | driver->drv.name = driver->name; | ||
| 491 | driver->drv.bus = &acpi_bus_type; | ||
| 492 | driver->drv.owner = driver->owner; | ||
| 234 | 493 | ||
| 235 | return 0; | 494 | ret = driver_register(&driver->drv); |
| 495 | return ret; | ||
| 496 | } | ||
| 497 | |||
| 498 | EXPORT_SYMBOL(acpi_bus_register_driver); | ||
| 499 | |||
| 500 | /** | ||
| 501 | * acpi_bus_unregister_driver - unregisters a driver with the APIC bus | ||
| 502 | * @driver: driver to unregister | ||
| 503 | * | ||
| 504 | * Unregisters a driver with the ACPI bus. Searches the namespace for all | ||
| 505 | * devices that match the driver's criteria and unbinds. | ||
| 506 | */ | ||
| 507 | void acpi_bus_unregister_driver(struct acpi_driver *driver) | ||
| 508 | { | ||
| 509 | driver_unregister(&driver->drv); | ||
| 510 | } | ||
| 511 | |||
| 512 | EXPORT_SYMBOL(acpi_bus_unregister_driver); | ||
| 513 | |||
| 514 | /* -------------------------------------------------------------------------- | ||
| 515 | Device Enumeration | ||
| 516 | -------------------------------------------------------------------------- */ | ||
| 517 | acpi_status | ||
| 518 | acpi_bus_get_ejd(acpi_handle handle, acpi_handle *ejd) | ||
| 519 | { | ||
| 520 | acpi_status status; | ||
| 521 | acpi_handle tmp; | ||
| 522 | struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER, NULL}; | ||
| 523 | union acpi_object *obj; | ||
| 524 | |||
| 525 | status = acpi_get_handle(handle, "_EJD", &tmp); | ||
| 526 | if (ACPI_FAILURE(status)) | ||
| 527 | return status; | ||
| 528 | |||
| 529 | status = acpi_evaluate_object(handle, "_EJD", NULL, &buffer); | ||
| 530 | if (ACPI_SUCCESS(status)) { | ||
| 531 | obj = buffer.pointer; | ||
| 532 | status = acpi_get_handle(NULL, obj->string.pointer, ejd); | ||
| 533 | kfree(buffer.pointer); | ||
| 534 | } | ||
| 535 | return status; | ||
| 536 | } | ||
| 537 | EXPORT_SYMBOL_GPL(acpi_bus_get_ejd); | ||
| 538 | |||
| 539 | void acpi_bus_data_handler(acpi_handle handle, u32 function, void *context) | ||
| 540 | { | ||
| 541 | |||
| 542 | /* TBD */ | ||
| 543 | |||
| 544 | return; | ||
| 236 | } | 545 | } |
| 237 | 546 | ||
| 238 | int acpi_match_ids(struct acpi_device *device, char *ids) | 547 | int acpi_match_ids(struct acpi_device *device, char *ids) |
| @@ -254,6 +563,12 @@ int acpi_match_ids(struct acpi_device *device, char *ids) | |||
| 254 | return -ENOENT; | 563 | return -ENOENT; |
| 255 | } | 564 | } |
| 256 | 565 | ||
| 566 | static int acpi_bus_get_perf_flags(struct acpi_device *device) | ||
| 567 | { | ||
| 568 | device->performance.state = ACPI_STATE_UNKNOWN; | ||
| 569 | return 0; | ||
| 570 | } | ||
| 571 | |||
| 257 | static acpi_status | 572 | static acpi_status |
| 258 | acpi_bus_extract_wakeup_device_power_package(struct acpi_device *device, | 573 | acpi_bus_extract_wakeup_device_power_package(struct acpi_device *device, |
| 259 | union acpi_object *package) | 574 | union acpi_object *package) |
| @@ -338,359 +653,66 @@ static int acpi_bus_get_wakeup_device_flags(struct acpi_device *device) | |||
| 338 | return 0; | 653 | return 0; |
| 339 | } | 654 | } |
| 340 | 655 | ||
| 341 | /* -------------------------------------------------------------------------- | 656 | static int acpi_bus_get_power_flags(struct acpi_device *device) |
| 342 | ACPI sysfs device file support | ||
| 343 | -------------------------------------------------------------------------- */ | ||
| 344 | static ssize_t acpi_eject_store(struct acpi_device *device, | ||
| 345 | const char *buf, size_t count); | ||
| 346 | |||
| 347 | #define ACPI_DEVICE_ATTR(_name,_mode,_show,_store) \ | ||
| 348 | static struct acpi_device_attribute acpi_device_attr_##_name = \ | ||
| 349 | __ATTR(_name, _mode, _show, _store) | ||
| 350 | |||
| 351 | ACPI_DEVICE_ATTR(eject, 0200, NULL, acpi_eject_store); | ||
| 352 | |||
| 353 | /** | ||
| 354 | * setup_sys_fs_device_files - sets up the device files under device namespace | ||
| 355 | * @dev: acpi_device object | ||
| 356 | * @func: function pointer to create or destroy the device file | ||
| 357 | */ | ||
| 358 | static void | ||
| 359 | setup_sys_fs_device_files(struct acpi_device *dev, | ||
| 360 | acpi_device_sysfs_files * func) | ||
| 361 | { | ||
| 362 | acpi_status status; | ||
| 363 | acpi_handle temp = NULL; | ||
| 364 | |||
| 365 | /* | ||
| 366 | * If device has _EJ0, 'eject' file is created that is used to trigger | ||
| 367 | * hot-removal function from userland. | ||
| 368 | */ | ||
| 369 | status = acpi_get_handle(dev->handle, "_EJ0", &temp); | ||
| 370 | if (ACPI_SUCCESS(status)) | ||
| 371 | (*(func)) (&dev->kobj, &acpi_device_attr_eject.attr); | ||
| 372 | } | ||
| 373 | |||
| 374 | static int acpi_eject_operation(acpi_handle handle, int lockable) | ||
| 375 | { | 657 | { |
| 376 | struct acpi_object_list arg_list; | 658 | acpi_status status = 0; |
| 377 | union acpi_object arg; | 659 | acpi_handle handle = NULL; |
| 378 | acpi_status status = AE_OK; | 660 | u32 i = 0; |
| 379 | |||
| 380 | /* | ||
| 381 | * TBD: evaluate _PS3? | ||
| 382 | */ | ||
| 383 | |||
| 384 | if (lockable) { | ||
| 385 | arg_list.count = 1; | ||
| 386 | arg_list.pointer = &arg; | ||
| 387 | arg.type = ACPI_TYPE_INTEGER; | ||
| 388 | arg.integer.value = 0; | ||
| 389 | acpi_evaluate_object(handle, "_LCK", &arg_list, NULL); | ||
| 390 | } | ||
| 391 | 661 | ||
| 392 | arg_list.count = 1; | ||
| 393 | arg_list.pointer = &arg; | ||
| 394 | arg.type = ACPI_TYPE_INTEGER; | ||
| 395 | arg.integer.value = 1; | ||
| 396 | 662 | ||
| 397 | /* | 663 | /* |
| 398 | * TBD: _EJD support. | 664 | * Power Management Flags |
| 399 | */ | 665 | */ |
| 400 | 666 | status = acpi_get_handle(device->handle, "_PSC", &handle); | |
| 401 | status = acpi_evaluate_object(handle, "_EJ0", &arg_list, NULL); | 667 | if (ACPI_SUCCESS(status)) |
| 402 | if (ACPI_FAILURE(status)) { | 668 | device->power.flags.explicit_get = 1; |
| 403 | return (-ENODEV); | 669 | status = acpi_get_handle(device->handle, "_IRC", &handle); |
| 404 | } | 670 | if (ACPI_SUCCESS(status)) |
| 405 | 671 | device->power.flags.inrush_current = 1; | |
| 406 | return (0); | ||
| 407 | } | ||
| 408 | |||
| 409 | static ssize_t | ||
| 410 | acpi_eject_store(struct acpi_device *device, const char *buf, size_t count) | ||
| 411 | { | ||
| 412 | int result; | ||
| 413 | int ret = count; | ||
| 414 | int islockable; | ||
| 415 | acpi_status status; | ||
| 416 | acpi_handle handle; | ||
| 417 | acpi_object_type type = 0; | ||
| 418 | |||
| 419 | if ((!count) || (buf[0] != '1')) { | ||
| 420 | return -EINVAL; | ||
| 421 | } | ||
| 422 | #ifndef FORCE_EJECT | ||
| 423 | if (device->driver == NULL) { | ||
| 424 | ret = -ENODEV; | ||
| 425 | goto err; | ||
| 426 | } | ||
| 427 | #endif | ||
| 428 | status = acpi_get_type(device->handle, &type); | ||
| 429 | if (ACPI_FAILURE(status) || (!device->flags.ejectable)) { | ||
| 430 | ret = -ENODEV; | ||
| 431 | goto err; | ||
| 432 | } | ||
| 433 | |||
| 434 | islockable = device->flags.lockable; | ||
| 435 | handle = device->handle; | ||
| 436 | |||
| 437 | result = acpi_bus_trim(device, 1); | ||
| 438 | |||
| 439 | if (!result) | ||
| 440 | result = acpi_eject_operation(handle, islockable); | ||
| 441 | |||
| 442 | if (result) { | ||
| 443 | ret = -EBUSY; | ||
| 444 | } | ||
| 445 | err: | ||
| 446 | return ret; | ||
| 447 | } | ||
| 448 | |||
| 449 | /* -------------------------------------------------------------------------- | ||
| 450 | Performance Management | ||
| 451 | -------------------------------------------------------------------------- */ | ||
| 452 | |||
| 453 | static int acpi_bus_get_perf_flags(struct acpi_device *device) | ||
| 454 | { | ||
| 455 | device->performance.state = ACPI_STATE_UNKNOWN; | ||
| 456 | return 0; | ||
| 457 | } | ||
| 458 | |||
| 459 | /* -------------------------------------------------------------------------- | ||
| 460 | Driver Management | ||
| 461 | -------------------------------------------------------------------------- */ | ||
| 462 | |||
| 463 | static LIST_HEAD(acpi_bus_drivers); | ||
| 464 | |||
| 465 | /** | ||
| 466 | * acpi_bus_match - match device IDs to driver's supported IDs | ||
| 467 | * @device: the device that we are trying to match to a driver | ||
| 468 | * @driver: driver whose device id table is being checked | ||
| 469 | * | ||
| 470 | * Checks the device's hardware (_HID) or compatible (_CID) ids to see if it | ||
| 471 | * matches the specified driver's criteria. | ||
| 472 | */ | ||
| 473 | static int | ||
| 474 | acpi_bus_match(struct acpi_device *device, struct acpi_driver *driver) | ||
| 475 | { | ||
| 476 | if (driver && driver->ops.match) | ||
| 477 | return driver->ops.match(device, driver); | ||
| 478 | return acpi_match_ids(device, driver->ids); | ||
| 479 | } | ||
| 480 | |||
| 481 | /** | ||
| 482 | * acpi_bus_driver_init - add a device to a driver | ||
| 483 | * @device: the device to add and initialize | ||
| 484 | * @driver: driver for the device | ||
| 485 | * | ||
| 486 | * Used to initialize a device via its device driver. Called whenever a | ||
| 487 | * driver is bound to a device. Invokes the driver's add() and start() ops. | ||
| 488 | */ | ||
| 489 | static int | ||
| 490 | acpi_bus_driver_init(struct acpi_device *device, struct acpi_driver *driver) | ||
| 491 | { | ||
| 492 | int result = 0; | ||
| 493 | |||
| 494 | |||
| 495 | if (!device || !driver) | ||
| 496 | return -EINVAL; | ||
| 497 | |||
| 498 | if (!driver->ops.add) | ||
| 499 | return -ENOSYS; | ||
| 500 | |||
| 501 | result = driver->ops.add(device); | ||
| 502 | if (result) { | ||
| 503 | device->driver = NULL; | ||
| 504 | acpi_driver_data(device) = NULL; | ||
| 505 | return result; | ||
| 506 | } | ||
| 507 | |||
| 508 | device->driver = driver; | ||
| 509 | 672 | ||
| 510 | /* | 673 | /* |
| 511 | * TBD - Configuration Management: Assign resources to device based | 674 | * Enumerate supported power management states |
| 512 | * upon possible configuration and currently allocated resources. | ||
| 513 | */ | 675 | */ |
| 676 | for (i = ACPI_STATE_D0; i <= ACPI_STATE_D3; i++) { | ||
| 677 | struct acpi_device_power_state *ps = &device->power.states[i]; | ||
| 678 | char object_name[5] = { '_', 'P', 'R', '0' + i, '\0' }; | ||
| 514 | 679 | ||
| 515 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, | 680 | /* Evaluate "_PRx" to se if power resources are referenced */ |
| 516 | "Driver successfully bound to device\n")); | 681 | acpi_evaluate_reference(device->handle, object_name, NULL, |
| 517 | return 0; | 682 | &ps->resources); |
| 518 | } | 683 | if (ps->resources.count) { |
| 519 | 684 | device->power.flags.power_resources = 1; | |
| 520 | static int acpi_start_single_object(struct acpi_device *device) | 685 | ps->flags.valid = 1; |
| 521 | { | ||
| 522 | int result = 0; | ||
| 523 | struct acpi_driver *driver; | ||
| 524 | |||
| 525 | |||
| 526 | if (!(driver = device->driver)) | ||
| 527 | return 0; | ||
| 528 | |||
| 529 | if (driver->ops.start) { | ||
| 530 | result = driver->ops.start(device); | ||
| 531 | if (result && driver->ops.remove) | ||
| 532 | driver->ops.remove(device, ACPI_BUS_REMOVAL_NORMAL); | ||
| 533 | } | ||
| 534 | |||
| 535 | return result; | ||
| 536 | } | ||
| 537 | |||
| 538 | static void acpi_driver_attach(struct acpi_driver *drv) | ||
| 539 | { | ||
| 540 | struct list_head *node, *next; | ||
| 541 | |||
| 542 | |||
| 543 | spin_lock(&acpi_device_lock); | ||
| 544 | list_for_each_safe(node, next, &acpi_device_list) { | ||
| 545 | struct acpi_device *dev = | ||
| 546 | container_of(node, struct acpi_device, g_list); | ||
| 547 | |||
| 548 | if (dev->driver || !dev->status.present) | ||
| 549 | continue; | ||
| 550 | spin_unlock(&acpi_device_lock); | ||
| 551 | |||
| 552 | if (!acpi_bus_match(dev, drv)) { | ||
| 553 | if (!acpi_bus_driver_init(dev, drv)) { | ||
| 554 | acpi_start_single_object(dev); | ||
| 555 | atomic_inc(&drv->references); | ||
| 556 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, | ||
| 557 | "Found driver [%s] for device [%s]\n", | ||
| 558 | drv->name, dev->pnp.bus_id)); | ||
| 559 | } | ||
| 560 | } | 686 | } |
| 561 | spin_lock(&acpi_device_lock); | ||
| 562 | } | ||
| 563 | spin_unlock(&acpi_device_lock); | ||
| 564 | } | ||
| 565 | |||
| 566 | static void acpi_driver_detach(struct acpi_driver *drv) | ||
| 567 | { | ||
| 568 | struct list_head *node, *next; | ||
| 569 | 687 | ||
| 570 | 688 | /* Evaluate "_PSx" to see if we can do explicit sets */ | |
| 571 | spin_lock(&acpi_device_lock); | 689 | object_name[2] = 'S'; |
| 572 | list_for_each_safe(node, next, &acpi_device_list) { | 690 | status = acpi_get_handle(device->handle, object_name, &handle); |
| 573 | struct acpi_device *dev = | 691 | if (ACPI_SUCCESS(status)) { |
| 574 | container_of(node, struct acpi_device, g_list); | 692 | ps->flags.explicit_set = 1; |
| 575 | 693 | ps->flags.valid = 1; | |
| 576 | if (dev->driver == drv) { | ||
| 577 | spin_unlock(&acpi_device_lock); | ||
| 578 | if (drv->ops.remove) | ||
| 579 | drv->ops.remove(dev, ACPI_BUS_REMOVAL_NORMAL); | ||
| 580 | spin_lock(&acpi_device_lock); | ||
| 581 | dev->driver = NULL; | ||
| 582 | dev->driver_data = NULL; | ||
| 583 | atomic_dec(&drv->references); | ||
| 584 | } | 694 | } |
| 585 | } | ||
| 586 | spin_unlock(&acpi_device_lock); | ||
| 587 | } | ||
| 588 | |||
| 589 | /** | ||
| 590 | * acpi_bus_register_driver - register a driver with the ACPI bus | ||
| 591 | * @driver: driver being registered | ||
| 592 | * | ||
| 593 | * Registers a driver with the ACPI bus. Searches the namespace for all | ||
| 594 | * devices that match the driver's criteria and binds. Returns zero for | ||
| 595 | * success or a negative error status for failure. | ||
| 596 | */ | ||
| 597 | int acpi_bus_register_driver(struct acpi_driver *driver) | ||
| 598 | { | ||
| 599 | |||
| 600 | if (acpi_disabled) | ||
| 601 | return -ENODEV; | ||
| 602 | |||
| 603 | spin_lock(&acpi_device_lock); | ||
| 604 | list_add_tail(&driver->node, &acpi_bus_drivers); | ||
| 605 | spin_unlock(&acpi_device_lock); | ||
| 606 | acpi_driver_attach(driver); | ||
| 607 | |||
| 608 | return 0; | ||
| 609 | } | ||
| 610 | |||
| 611 | EXPORT_SYMBOL(acpi_bus_register_driver); | ||
| 612 | |||
| 613 | /** | ||
| 614 | * acpi_bus_unregister_driver - unregisters a driver with the APIC bus | ||
| 615 | * @driver: driver to unregister | ||
| 616 | * | ||
| 617 | * Unregisters a driver with the ACPI bus. Searches the namespace for all | ||
| 618 | * devices that match the driver's criteria and unbinds. | ||
| 619 | */ | ||
| 620 | void acpi_bus_unregister_driver(struct acpi_driver *driver) | ||
| 621 | { | ||
| 622 | acpi_driver_detach(driver); | ||
| 623 | |||
| 624 | if (!atomic_read(&driver->references)) { | ||
| 625 | spin_lock(&acpi_device_lock); | ||
| 626 | list_del_init(&driver->node); | ||
| 627 | spin_unlock(&acpi_device_lock); | ||
| 628 | } | ||
| 629 | return; | ||
| 630 | } | ||
| 631 | |||
| 632 | EXPORT_SYMBOL(acpi_bus_unregister_driver); | ||
| 633 | |||
| 634 | /** | ||
| 635 | * acpi_bus_find_driver - check if there is a driver installed for the device | ||
| 636 | * @device: device that we are trying to find a supporting driver for | ||
| 637 | * | ||
| 638 | * Parses the list of registered drivers looking for a driver applicable for | ||
| 639 | * the specified device. | ||
| 640 | */ | ||
| 641 | static int acpi_bus_find_driver(struct acpi_device *device) | ||
| 642 | { | ||
| 643 | int result = 0; | ||
| 644 | struct list_head *node, *next; | ||
| 645 | 695 | ||
| 696 | /* State is valid if we have some power control */ | ||
| 697 | if (ps->resources.count || ps->flags.explicit_set) | ||
| 698 | ps->flags.valid = 1; | ||
| 646 | 699 | ||
| 647 | spin_lock(&acpi_device_lock); | 700 | ps->power = -1; /* Unknown - driver assigned */ |
| 648 | list_for_each_safe(node, next, &acpi_bus_drivers) { | 701 | ps->latency = -1; /* Unknown - driver assigned */ |
| 649 | struct acpi_driver *driver = | ||
| 650 | container_of(node, struct acpi_driver, node); | ||
| 651 | |||
| 652 | atomic_inc(&driver->references); | ||
| 653 | spin_unlock(&acpi_device_lock); | ||
| 654 | if (!acpi_bus_match(device, driver)) { | ||
| 655 | result = acpi_bus_driver_init(device, driver); | ||
| 656 | if (!result) | ||
| 657 | goto Done; | ||
| 658 | } | ||
| 659 | atomic_dec(&driver->references); | ||
| 660 | spin_lock(&acpi_device_lock); | ||
| 661 | } | 702 | } |
| 662 | spin_unlock(&acpi_device_lock); | ||
| 663 | |||
| 664 | Done: | ||
| 665 | return result; | ||
| 666 | } | ||
| 667 | 703 | ||
| 668 | /* -------------------------------------------------------------------------- | 704 | /* Set defaults for D0 and D3 states (always valid) */ |
| 669 | Device Enumeration | 705 | device->power.states[ACPI_STATE_D0].flags.valid = 1; |
| 670 | -------------------------------------------------------------------------- */ | 706 | device->power.states[ACPI_STATE_D0].power = 100; |
| 707 | device->power.states[ACPI_STATE_D3].flags.valid = 1; | ||
| 708 | device->power.states[ACPI_STATE_D3].power = 0; | ||
| 671 | 709 | ||
| 672 | acpi_status | 710 | /* TBD: System wake support and resource requirements. */ |
| 673 | acpi_bus_get_ejd(acpi_handle handle, acpi_handle *ejd) | ||
| 674 | { | ||
| 675 | acpi_status status; | ||
| 676 | acpi_handle tmp; | ||
| 677 | struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER, NULL}; | ||
| 678 | union acpi_object *obj; | ||
| 679 | 711 | ||
| 680 | status = acpi_get_handle(handle, "_EJD", &tmp); | 712 | device->power.state = ACPI_STATE_UNKNOWN; |
| 681 | if (ACPI_FAILURE(status)) | ||
| 682 | return status; | ||
| 683 | 713 | ||
| 684 | status = acpi_evaluate_object(handle, "_EJD", NULL, &buffer); | 714 | return 0; |
| 685 | if (ACPI_SUCCESS(status)) { | ||
| 686 | obj = buffer.pointer; | ||
| 687 | status = acpi_get_handle(NULL, obj->string.pointer, ejd); | ||
| 688 | kfree(buffer.pointer); | ||
| 689 | } | ||
| 690 | return status; | ||
| 691 | } | 715 | } |
| 692 | EXPORT_SYMBOL_GPL(acpi_bus_get_ejd); | ||
| 693 | |||
| 694 | 716 | ||
| 695 | static int acpi_bus_get_flags(struct acpi_device *device) | 717 | static int acpi_bus_get_flags(struct acpi_device *device) |
| 696 | { | 718 | { |
| @@ -782,6 +804,75 @@ static void acpi_device_get_busid(struct acpi_device *device, | |||
| 782 | } | 804 | } |
| 783 | } | 805 | } |
| 784 | 806 | ||
| 807 | static int | ||
| 808 | acpi_video_bus_match(struct acpi_device *device) | ||
| 809 | { | ||
| 810 | acpi_handle h_dummy1; | ||
| 811 | acpi_handle h_dummy2; | ||
| 812 | acpi_handle h_dummy3; | ||
| 813 | |||
| 814 | |||
| 815 | if (!device) | ||
| 816 | return -EINVAL; | ||
| 817 | |||
| 818 | /* Since there is no HID, CID for ACPI Video drivers, we have | ||
| 819 | * to check well known required nodes for each feature we support. | ||
| 820 | */ | ||
| 821 | |||
| 822 | /* Does this device able to support video switching ? */ | ||
| 823 | if (ACPI_SUCCESS(acpi_get_handle(device->handle, "_DOD", &h_dummy1)) && | ||
| 824 | ACPI_SUCCESS(acpi_get_handle(device->handle, "_DOS", &h_dummy2))) | ||
| 825 | return 0; | ||
| 826 | |||
| 827 | /* Does this device able to retrieve a video ROM ? */ | ||
| 828 | if (ACPI_SUCCESS(acpi_get_handle(device->handle, "_ROM", &h_dummy1))) | ||
| 829 | return 0; | ||
| 830 | |||
| 831 | /* Does this device able to configure which video head to be POSTed ? */ | ||
| 832 | if (ACPI_SUCCESS(acpi_get_handle(device->handle, "_VPO", &h_dummy1)) && | ||
| 833 | ACPI_SUCCESS(acpi_get_handle(device->handle, "_GPD", &h_dummy2)) && | ||
| 834 | ACPI_SUCCESS(acpi_get_handle(device->handle, "_SPD", &h_dummy3))) | ||
| 835 | return 0; | ||
| 836 | |||
| 837 | return -ENODEV; | ||
| 838 | } | ||
| 839 | |||
| 840 | /* | ||
| 841 | * acpi_bay_match - see if a device is an ejectable driver bay | ||
| 842 | * | ||
| 843 | * If an acpi object is ejectable and has one of the ACPI ATA methods defined, | ||
| 844 | * then we can safely call it an ejectable drive bay | ||
| 845 | */ | ||
| 846 | static int acpi_bay_match(struct acpi_device *device){ | ||
| 847 | acpi_status status; | ||
| 848 | acpi_handle handle; | ||
| 849 | acpi_handle tmp; | ||
| 850 | acpi_handle phandle; | ||
| 851 | |||
| 852 | handle = device->handle; | ||
| 853 | |||
| 854 | status = acpi_get_handle(handle, "_EJ0", &tmp); | ||
| 855 | if (ACPI_FAILURE(status)) | ||
| 856 | return -ENODEV; | ||
| 857 | |||
| 858 | if ((ACPI_SUCCESS(acpi_get_handle(handle, "_GTF", &tmp))) || | ||
| 859 | (ACPI_SUCCESS(acpi_get_handle(handle, "_GTM", &tmp))) || | ||
| 860 | (ACPI_SUCCESS(acpi_get_handle(handle, "_STM", &tmp))) || | ||
| 861 | (ACPI_SUCCESS(acpi_get_handle(handle, "_SDD", &tmp)))) | ||
| 862 | return 0; | ||
| 863 | |||
| 864 | if (acpi_get_parent(handle, &phandle)) | ||
| 865 | return -ENODEV; | ||
| 866 | |||
| 867 | if ((ACPI_SUCCESS(acpi_get_handle(phandle, "_GTF", &tmp))) || | ||
| 868 | (ACPI_SUCCESS(acpi_get_handle(phandle, "_GTM", &tmp))) || | ||
| 869 | (ACPI_SUCCESS(acpi_get_handle(phandle, "_STM", &tmp))) || | ||
| 870 | (ACPI_SUCCESS(acpi_get_handle(phandle, "_SDD", &tmp)))) | ||
| 871 | return 0; | ||
| 872 | |||
| 873 | return -ENODEV; | ||
| 874 | } | ||
| 875 | |||
| 785 | static void acpi_device_set_id(struct acpi_device *device, | 876 | static void acpi_device_set_id(struct acpi_device *device, |
| 786 | struct acpi_device *parent, acpi_handle handle, | 877 | struct acpi_device *parent, acpi_handle handle, |
| 787 | int type) | 878 | int type) |
| @@ -812,6 +903,16 @@ static void acpi_device_set_id(struct acpi_device *device, | |||
| 812 | device->pnp.bus_address = info->address; | 903 | device->pnp.bus_address = info->address; |
| 813 | device->flags.bus_address = 1; | 904 | device->flags.bus_address = 1; |
| 814 | } | 905 | } |
| 906 | |||
| 907 | if(!(info->valid & (ACPI_VALID_HID | ACPI_VALID_CID))){ | ||
| 908 | status = acpi_video_bus_match(device); | ||
| 909 | if(ACPI_SUCCESS(status)) | ||
| 910 | hid = ACPI_VIDEO_HID; | ||
| 911 | |||
| 912 | status = acpi_bay_match(device); | ||
| 913 | if (ACPI_SUCCESS(status)) | ||
| 914 | hid = ACPI_BAY_HID; | ||
| 915 | } | ||
| 815 | break; | 916 | break; |
| 816 | case ACPI_BUS_TYPE_POWER: | 917 | case ACPI_BUS_TYPE_POWER: |
| 817 | hid = ACPI_POWER_HID; | 918 | hid = ACPI_POWER_HID; |
| @@ -888,86 +989,24 @@ static int acpi_device_set_context(struct acpi_device *device, int type) | |||
| 888 | return result; | 989 | return result; |
| 889 | } | 990 | } |
| 890 | 991 | ||
| 891 | static void acpi_device_get_debug_info(struct acpi_device *device, | ||
| 892 | acpi_handle handle, int type) | ||
| 893 | { | ||
| 894 | #ifdef CONFIG_ACPI_DEBUG_OUTPUT | ||
| 895 | char *type_string = NULL; | ||
| 896 | char name[80] = { '?', '\0' }; | ||
| 897 | struct acpi_buffer buffer = { sizeof(name), name }; | ||
| 898 | |||
| 899 | switch (type) { | ||
| 900 | case ACPI_BUS_TYPE_DEVICE: | ||
| 901 | type_string = "Device"; | ||
| 902 | acpi_get_name(handle, ACPI_FULL_PATHNAME, &buffer); | ||
| 903 | break; | ||
| 904 | case ACPI_BUS_TYPE_POWER: | ||
| 905 | type_string = "Power Resource"; | ||
| 906 | acpi_get_name(handle, ACPI_FULL_PATHNAME, &buffer); | ||
| 907 | break; | ||
| 908 | case ACPI_BUS_TYPE_PROCESSOR: | ||
| 909 | type_string = "Processor"; | ||
| 910 | acpi_get_name(handle, ACPI_FULL_PATHNAME, &buffer); | ||
| 911 | break; | ||
| 912 | case ACPI_BUS_TYPE_SYSTEM: | ||
| 913 | type_string = "System"; | ||
| 914 | acpi_get_name(handle, ACPI_FULL_PATHNAME, &buffer); | ||
| 915 | break; | ||
| 916 | case ACPI_BUS_TYPE_THERMAL: | ||
| 917 | type_string = "Thermal Zone"; | ||
| 918 | acpi_get_name(handle, ACPI_FULL_PATHNAME, &buffer); | ||
| 919 | break; | ||
| 920 | case ACPI_BUS_TYPE_POWER_BUTTON: | ||
| 921 | type_string = "Power Button"; | ||
| 922 | sprintf(name, "PWRB"); | ||
| 923 | break; | ||
| 924 | case ACPI_BUS_TYPE_SLEEP_BUTTON: | ||
| 925 | type_string = "Sleep Button"; | ||
| 926 | sprintf(name, "SLPB"); | ||
| 927 | break; | ||
| 928 | } | ||
| 929 | |||
| 930 | printk(KERN_DEBUG "Found %s %s [%p]\n", type_string, name, handle); | ||
| 931 | #endif /*CONFIG_ACPI_DEBUG_OUTPUT */ | ||
| 932 | } | ||
| 933 | |||
| 934 | static int acpi_bus_remove(struct acpi_device *dev, int rmdevice) | 992 | static int acpi_bus_remove(struct acpi_device *dev, int rmdevice) |
| 935 | { | 993 | { |
| 936 | int result = 0; | ||
| 937 | struct acpi_driver *driver; | ||
| 938 | |||
| 939 | |||
| 940 | if (!dev) | 994 | if (!dev) |
| 941 | return -EINVAL; | 995 | return -EINVAL; |
| 942 | 996 | ||
| 943 | driver = dev->driver; | 997 | dev->removal_type = ACPI_BUS_REMOVAL_EJECT; |
| 944 | 998 | device_release_driver(&dev->dev); | |
| 945 | if ((driver) && (driver->ops.remove)) { | ||
| 946 | |||
| 947 | if (driver->ops.stop) { | ||
| 948 | result = driver->ops.stop(dev, ACPI_BUS_REMOVAL_EJECT); | ||
| 949 | if (result) | ||
| 950 | return result; | ||
| 951 | } | ||
| 952 | |||
| 953 | result = dev->driver->ops.remove(dev, ACPI_BUS_REMOVAL_EJECT); | ||
| 954 | if (result) { | ||
| 955 | return result; | ||
| 956 | } | ||
| 957 | |||
| 958 | atomic_dec(&dev->driver->references); | ||
| 959 | dev->driver = NULL; | ||
| 960 | acpi_driver_data(dev) = NULL; | ||
| 961 | } | ||
| 962 | 999 | ||
| 963 | if (!rmdevice) | 1000 | if (!rmdevice) |
| 964 | return 0; | 1001 | return 0; |
| 965 | 1002 | ||
| 1003 | /* | ||
| 1004 | * unbind _ADR-Based Devices when hot removal | ||
| 1005 | */ | ||
| 966 | if (dev->flags.bus_address) { | 1006 | if (dev->flags.bus_address) { |
| 967 | if ((dev->parent) && (dev->parent->ops.unbind)) | 1007 | if ((dev->parent) && (dev->parent->ops.unbind)) |
| 968 | dev->parent->ops.unbind(dev); | 1008 | dev->parent->ops.unbind(dev); |
| 969 | } | 1009 | } |
| 970 | |||
| 971 | acpi_device_unregister(dev, ACPI_BUS_REMOVAL_EJECT); | 1010 | acpi_device_unregister(dev, ACPI_BUS_REMOVAL_EJECT); |
| 972 | 1011 | ||
| 973 | return 0; | 1012 | return 0; |
| @@ -975,7 +1014,8 @@ static int acpi_bus_remove(struct acpi_device *dev, int rmdevice) | |||
| 975 | 1014 | ||
| 976 | static int | 1015 | static int |
| 977 | acpi_add_single_object(struct acpi_device **child, | 1016 | acpi_add_single_object(struct acpi_device **child, |
| 978 | struct acpi_device *parent, acpi_handle handle, int type) | 1017 | struct acpi_device *parent, acpi_handle handle, int type, |
| 1018 | struct acpi_bus_ops *ops) | ||
| 979 | { | 1019 | { |
| 980 | int result = 0; | 1020 | int result = 0; |
| 981 | struct acpi_device *device = NULL; | 1021 | struct acpi_device *device = NULL; |
| @@ -992,6 +1032,8 @@ acpi_add_single_object(struct acpi_device **child, | |||
| 992 | 1032 | ||
| 993 | device->handle = handle; | 1033 | device->handle = handle; |
| 994 | device->parent = parent; | 1034 | device->parent = parent; |
| 1035 | device->bus_ops = *ops; /* workround for not call .start */ | ||
| 1036 | |||
| 995 | 1037 | ||
| 996 | acpi_device_get_busid(device, handle, type); | 1038 | acpi_device_get_busid(device, handle, type); |
| 997 | 1039 | ||
| @@ -1076,33 +1118,16 @@ acpi_add_single_object(struct acpi_device **child, | |||
| 1076 | if ((result = acpi_device_set_context(device, type))) | 1118 | if ((result = acpi_device_set_context(device, type))) |
| 1077 | goto end; | 1119 | goto end; |
| 1078 | 1120 | ||
| 1079 | acpi_device_get_debug_info(device, handle, type); | 1121 | result = acpi_device_register(device, parent); |
| 1080 | |||
| 1081 | acpi_device_register(device, parent); | ||
| 1082 | 1122 | ||
| 1083 | /* | 1123 | /* |
| 1084 | * Bind _ADR-Based Devices | 1124 | * Bind _ADR-Based Devices when hot add |
| 1085 | * ----------------------- | ||
| 1086 | * If there's a a bus address (_ADR) then we utilize the parent's | ||
| 1087 | * 'bind' function (if exists) to bind the ACPI- and natively- | ||
| 1088 | * enumerated device representations. | ||
| 1089 | */ | 1125 | */ |
| 1090 | if (device->flags.bus_address) { | 1126 | if (device->flags.bus_address) { |
| 1091 | if (device->parent && device->parent->ops.bind) | 1127 | if (device->parent && device->parent->ops.bind) |
| 1092 | device->parent->ops.bind(device); | 1128 | device->parent->ops.bind(device); |
| 1093 | } | 1129 | } |
| 1094 | 1130 | ||
| 1095 | /* | ||
| 1096 | * Locate & Attach Driver | ||
| 1097 | * ---------------------- | ||
| 1098 | * If there's a hardware id (_HID) or compatible ids (_CID) we check | ||
| 1099 | * to see if there's a driver installed for this kind of device. Note | ||
| 1100 | * that drivers can install before or after a device is enumerated. | ||
| 1101 | * | ||
| 1102 | * TBD: Assumes LDM provides driver hot-plug capability. | ||
| 1103 | */ | ||
| 1104 | acpi_bus_find_driver(device); | ||
| 1105 | |||
| 1106 | end: | 1131 | end: |
| 1107 | if (!result) | 1132 | if (!result) |
| 1108 | *child = device; | 1133 | *child = device; |
| @@ -1188,14 +1213,14 @@ static int acpi_bus_scan(struct acpi_device *start, struct acpi_bus_ops *ops) | |||
| 1188 | 1213 | ||
| 1189 | if (ops->acpi_op_add) | 1214 | if (ops->acpi_op_add) |
| 1190 | status = acpi_add_single_object(&child, parent, | 1215 | status = acpi_add_single_object(&child, parent, |
| 1191 | chandle, type); | 1216 | chandle, type, ops); |
| 1192 | else | 1217 | else |
| 1193 | status = acpi_bus_get_device(chandle, &child); | 1218 | status = acpi_bus_get_device(chandle, &child); |
| 1194 | 1219 | ||
| 1195 | if (ACPI_FAILURE(status)) | 1220 | if (ACPI_FAILURE(status)) |
| 1196 | continue; | 1221 | continue; |
| 1197 | 1222 | ||
| 1198 | if (ops->acpi_op_start) { | 1223 | if (ops->acpi_op_start && !(ops->acpi_op_add)) { |
| 1199 | status = acpi_start_single_object(child); | 1224 | status = acpi_start_single_object(child); |
| 1200 | if (ACPI_FAILURE(status)) | 1225 | if (ACPI_FAILURE(status)) |
| 1201 | continue; | 1226 | continue; |
| @@ -1233,13 +1258,13 @@ acpi_bus_add(struct acpi_device **child, | |||
| 1233 | int result; | 1258 | int result; |
| 1234 | struct acpi_bus_ops ops; | 1259 | struct acpi_bus_ops ops; |
| 1235 | 1260 | ||
| 1261 | memset(&ops, 0, sizeof(ops)); | ||
| 1262 | ops.acpi_op_add = 1; | ||
| 1236 | 1263 | ||
| 1237 | result = acpi_add_single_object(child, parent, handle, type); | 1264 | result = acpi_add_single_object(child, parent, handle, type, &ops); |
| 1238 | if (!result) { | 1265 | if (!result) |
| 1239 | memset(&ops, 0, sizeof(ops)); | ||
| 1240 | ops.acpi_op_add = 1; | ||
| 1241 | result = acpi_bus_scan(*child, &ops); | 1266 | result = acpi_bus_scan(*child, &ops); |
| 1242 | } | 1267 | |
| 1243 | return result; | 1268 | return result; |
| 1244 | } | 1269 | } |
| 1245 | 1270 | ||
| @@ -1325,127 +1350,35 @@ static int acpi_bus_scan_fixed(struct acpi_device *root) | |||
| 1325 | { | 1350 | { |
| 1326 | int result = 0; | 1351 | int result = 0; |
| 1327 | struct acpi_device *device = NULL; | 1352 | struct acpi_device *device = NULL; |
| 1328 | 1353 | struct acpi_bus_ops ops; | |
| 1329 | 1354 | ||
| 1330 | if (!root) | 1355 | if (!root) |
| 1331 | return -ENODEV; | 1356 | return -ENODEV; |
| 1332 | 1357 | ||
| 1358 | memset(&ops, 0, sizeof(ops)); | ||
| 1359 | ops.acpi_op_add = 1; | ||
| 1360 | ops.acpi_op_start = 1; | ||
| 1361 | |||
| 1333 | /* | 1362 | /* |
| 1334 | * Enumerate all fixed-feature devices. | 1363 | * Enumerate all fixed-feature devices. |
| 1335 | */ | 1364 | */ |
| 1336 | if ((acpi_gbl_FADT.flags & ACPI_FADT_POWER_BUTTON) == 0) { | 1365 | if ((acpi_gbl_FADT.flags & ACPI_FADT_POWER_BUTTON) == 0) { |
| 1337 | result = acpi_add_single_object(&device, acpi_root, | 1366 | result = acpi_add_single_object(&device, acpi_root, |
| 1338 | NULL, | 1367 | NULL, |
| 1339 | ACPI_BUS_TYPE_POWER_BUTTON); | 1368 | ACPI_BUS_TYPE_POWER_BUTTON, |
| 1340 | if (!result) | 1369 | &ops); |
| 1341 | result = acpi_start_single_object(device); | ||
| 1342 | } | 1370 | } |
| 1343 | 1371 | ||
| 1344 | if ((acpi_gbl_FADT.flags & ACPI_FADT_SLEEP_BUTTON) == 0) { | 1372 | if ((acpi_gbl_FADT.flags & ACPI_FADT_SLEEP_BUTTON) == 0) { |
| 1345 | result = acpi_add_single_object(&device, acpi_root, | 1373 | result = acpi_add_single_object(&device, acpi_root, |
| 1346 | NULL, | 1374 | NULL, |
| 1347 | ACPI_BUS_TYPE_SLEEP_BUTTON); | 1375 | ACPI_BUS_TYPE_SLEEP_BUTTON, |
| 1348 | if (!result) | 1376 | &ops); |
| 1349 | result = acpi_start_single_object(device); | ||
| 1350 | } | 1377 | } |
| 1351 | 1378 | ||
| 1352 | return result; | 1379 | return result; |
| 1353 | } | 1380 | } |
| 1354 | 1381 | ||
| 1355 | |||
| 1356 | static inline struct acpi_device * to_acpi_dev(struct device * dev) | ||
| 1357 | { | ||
| 1358 | return container_of(dev, struct acpi_device, dev); | ||
| 1359 | } | ||
| 1360 | |||
| 1361 | |||
| 1362 | static int root_suspend(struct acpi_device * acpi_dev, pm_message_t state) | ||
| 1363 | { | ||
| 1364 | struct acpi_device * dev, * next; | ||
| 1365 | int result; | ||
| 1366 | |||
| 1367 | spin_lock(&acpi_device_lock); | ||
| 1368 | list_for_each_entry_safe_reverse(dev, next, &acpi_device_list, g_list) { | ||
| 1369 | if (dev->driver && dev->driver->ops.suspend) { | ||
| 1370 | spin_unlock(&acpi_device_lock); | ||
| 1371 | result = dev->driver->ops.suspend(dev, 0); | ||
| 1372 | if (result) { | ||
| 1373 | printk(KERN_ERR PREFIX "[%s - %s] Suspend failed: %d\n", | ||
| 1374 | acpi_device_name(dev), | ||
| 1375 | acpi_device_bid(dev), result); | ||
| 1376 | } | ||
| 1377 | spin_lock(&acpi_device_lock); | ||
| 1378 | } | ||
| 1379 | } | ||
| 1380 | spin_unlock(&acpi_device_lock); | ||
| 1381 | return 0; | ||
| 1382 | } | ||
| 1383 | |||
| 1384 | |||
| 1385 | static int acpi_device_suspend(struct device * dev, pm_message_t state) | ||
| 1386 | { | ||
| 1387 | struct acpi_device * acpi_dev = to_acpi_dev(dev); | ||
| 1388 | |||
| 1389 | /* | ||
| 1390 | * For now, we should only register 1 generic device - | ||
| 1391 | * the ACPI root device - and from there, we walk the | ||
| 1392 | * tree of ACPI devices to suspend each one using the | ||
| 1393 | * ACPI driver methods. | ||
| 1394 | */ | ||
| 1395 | if (acpi_dev->handle == ACPI_ROOT_OBJECT) | ||
| 1396 | root_suspend(acpi_dev, state); | ||
| 1397 | return 0; | ||
| 1398 | } | ||
| 1399 | |||
| 1400 | |||
| 1401 | |||
| 1402 | static int root_resume(struct acpi_device * acpi_dev) | ||
| 1403 | { | ||
| 1404 | struct acpi_device * dev, * next; | ||
| 1405 | int result; | ||
| 1406 | |||
| 1407 | spin_lock(&acpi_device_lock); | ||
| 1408 | list_for_each_entry_safe(dev, next, &acpi_device_list, g_list) { | ||
| 1409 | if (dev->driver && dev->driver->ops.resume) { | ||
| 1410 | spin_unlock(&acpi_device_lock); | ||
| 1411 | result = dev->driver->ops.resume(dev, 0); | ||
| 1412 | if (result) { | ||
| 1413 | printk(KERN_ERR PREFIX "[%s - %s] resume failed: %d\n", | ||
| 1414 | acpi_device_name(dev), | ||
| 1415 | acpi_device_bid(dev), result); | ||
| 1416 | } | ||
| 1417 | spin_lock(&acpi_device_lock); | ||
| 1418 | } | ||
| 1419 | } | ||
| 1420 | spin_unlock(&acpi_device_lock); | ||
| 1421 | return 0; | ||
| 1422 | } | ||
| 1423 | |||
| 1424 | |||
| 1425 | static int acpi_device_resume(struct device * dev) | ||
| 1426 | { | ||
| 1427 | struct acpi_device * acpi_dev = to_acpi_dev(dev); | ||
| 1428 | |||
| 1429 | /* | ||
| 1430 | * For now, we should only register 1 generic device - | ||
| 1431 | * the ACPI root device - and from there, we walk the | ||
| 1432 | * tree of ACPI devices to resume each one using the | ||
| 1433 | * ACPI driver methods. | ||
| 1434 | */ | ||
| 1435 | if (acpi_dev->handle == ACPI_ROOT_OBJECT) | ||
| 1436 | root_resume(acpi_dev); | ||
| 1437 | return 0; | ||
| 1438 | } | ||
| 1439 | |||
| 1440 | |||
| 1441 | static struct bus_type acpi_bus_type = { | ||
| 1442 | .name = "acpi", | ||
| 1443 | .suspend = acpi_device_suspend, | ||
| 1444 | .resume = acpi_device_resume, | ||
| 1445 | }; | ||
| 1446 | |||
| 1447 | |||
| 1448 | |||
| 1449 | static int __init acpi_scan_init(void) | 1382 | static int __init acpi_scan_init(void) |
| 1450 | { | 1383 | { |
| 1451 | int result; | 1384 | int result; |
| @@ -1455,9 +1388,9 @@ static int __init acpi_scan_init(void) | |||
| 1455 | if (acpi_disabled) | 1388 | if (acpi_disabled) |
| 1456 | return 0; | 1389 | return 0; |
| 1457 | 1390 | ||
| 1458 | result = kset_register(&acpi_namespace_kset); | 1391 | memset(&ops, 0, sizeof(ops)); |
| 1459 | if (result < 0) | 1392 | ops.acpi_op_add = 1; |
| 1460 | printk(KERN_ERR PREFIX "kset_register error: %d\n", result); | 1393 | ops.acpi_op_start = 1; |
| 1461 | 1394 | ||
| 1462 | result = bus_register(&acpi_bus_type); | 1395 | result = bus_register(&acpi_bus_type); |
| 1463 | if (result) { | 1396 | if (result) { |
| @@ -1469,32 +1402,16 @@ static int __init acpi_scan_init(void) | |||
| 1469 | * Create the root device in the bus's device tree | 1402 | * Create the root device in the bus's device tree |
| 1470 | */ | 1403 | */ |
| 1471 | result = acpi_add_single_object(&acpi_root, NULL, ACPI_ROOT_OBJECT, | 1404 | result = acpi_add_single_object(&acpi_root, NULL, ACPI_ROOT_OBJECT, |
| 1472 | ACPI_BUS_TYPE_SYSTEM); | 1405 | ACPI_BUS_TYPE_SYSTEM, &ops); |
| 1473 | if (result) | 1406 | if (result) |
| 1474 | goto Done; | 1407 | goto Done; |
| 1475 | 1408 | ||
| 1476 | result = acpi_start_single_object(acpi_root); | ||
| 1477 | if (result) | ||
| 1478 | goto Done; | ||
| 1479 | |||
| 1480 | acpi_root->dev.bus = &acpi_bus_type; | ||
| 1481 | snprintf(acpi_root->dev.bus_id, BUS_ID_SIZE, "%s", acpi_bus_type.name); | ||
| 1482 | result = device_register(&acpi_root->dev); | ||
| 1483 | if (result) { | ||
| 1484 | /* We don't want to quit even if we failed to add suspend/resume */ | ||
| 1485 | printk(KERN_ERR PREFIX "Could not register device\n"); | ||
| 1486 | } | ||
| 1487 | |||
| 1488 | /* | 1409 | /* |
| 1489 | * Enumerate devices in the ACPI namespace. | 1410 | * Enumerate devices in the ACPI namespace. |
| 1490 | */ | 1411 | */ |
| 1491 | result = acpi_bus_scan_fixed(acpi_root); | 1412 | result = acpi_bus_scan_fixed(acpi_root); |
| 1492 | if (!result) { | 1413 | if (!result) |
| 1493 | memset(&ops, 0, sizeof(ops)); | ||
| 1494 | ops.acpi_op_add = 1; | ||
| 1495 | ops.acpi_op_start = 1; | ||
| 1496 | result = acpi_bus_scan(acpi_root, &ops); | 1414 | result = acpi_bus_scan(acpi_root, &ops); |
| 1497 | } | ||
| 1498 | 1415 | ||
| 1499 | if (result) | 1416 | if (result) |
| 1500 | acpi_device_unregister(acpi_root, ACPI_BUS_REMOVAL_NORMAL); | 1417 | acpi_device_unregister(acpi_root, ACPI_BUS_REMOVAL_NORMAL); |
diff --git a/drivers/acpi/system.c b/drivers/acpi/system.c index 2d425d845821..7147b0bdab0a 100644 --- a/drivers/acpi/system.c +++ b/drivers/acpi/system.c | |||
| @@ -32,6 +32,11 @@ | |||
| 32 | 32 | ||
| 33 | #define _COMPONENT ACPI_SYSTEM_COMPONENT | 33 | #define _COMPONENT ACPI_SYSTEM_COMPONENT |
| 34 | ACPI_MODULE_NAME("acpi_system") | 34 | ACPI_MODULE_NAME("acpi_system") |
| 35 | #ifdef MODULE_PARAM_PREFIX | ||
| 36 | #undef MODULE_PARAM_PREFIX | ||
| 37 | #endif | ||
| 38 | #define MODULE_PARAM_PREFIX "acpi." | ||
| 39 | |||
| 35 | #define ACPI_SYSTEM_CLASS "system" | 40 | #define ACPI_SYSTEM_CLASS "system" |
| 36 | #define ACPI_SYSTEM_DRIVER_NAME "ACPI System Driver" | 41 | #define ACPI_SYSTEM_DRIVER_NAME "ACPI System Driver" |
| 37 | #define ACPI_SYSTEM_DEVICE_NAME "System" | 42 | #define ACPI_SYSTEM_DEVICE_NAME "System" |
| @@ -40,9 +45,23 @@ ACPI_MODULE_NAME("acpi_system") | |||
| 40 | #define ACPI_SYSTEM_FILE_DSDT "dsdt" | 45 | #define ACPI_SYSTEM_FILE_DSDT "dsdt" |
| 41 | #define ACPI_SYSTEM_FILE_FADT "fadt" | 46 | #define ACPI_SYSTEM_FILE_FADT "fadt" |
| 42 | 47 | ||
| 48 | /* | ||
| 49 | * Make ACPICA version work as module param | ||
| 50 | */ | ||
| 51 | static int param_get_acpica_version(char *buffer, struct kernel_param *kp) { | ||
| 52 | int result; | ||
| 53 | |||
| 54 | result = sprintf(buffer, "%x", ACPI_CA_VERSION); | ||
| 55 | |||
| 56 | return result; | ||
| 57 | } | ||
| 58 | |||
| 59 | module_param_call(acpica_version, NULL, param_get_acpica_version, NULL, 0444); | ||
| 60 | |||
| 43 | /* -------------------------------------------------------------------------- | 61 | /* -------------------------------------------------------------------------- |
| 44 | FS Interface (/proc) | 62 | FS Interface (/proc) |
| 45 | -------------------------------------------------------------------------- */ | 63 | -------------------------------------------------------------------------- */ |
| 64 | #ifdef CONFIG_ACPI_PROCFS | ||
| 46 | 65 | ||
| 47 | static int acpi_system_read_info(struct seq_file *seq, void *offset) | 66 | static int acpi_system_read_info(struct seq_file *seq, void *offset) |
| 48 | { | 67 | { |
| @@ -62,6 +81,7 @@ static const struct file_operations acpi_system_info_ops = { | |||
| 62 | .llseek = seq_lseek, | 81 | .llseek = seq_lseek, |
| 63 | .release = single_release, | 82 | .release = single_release, |
| 64 | }; | 83 | }; |
| 84 | #endif | ||
| 65 | 85 | ||
| 66 | static ssize_t acpi_system_read_dsdt(struct file *, char __user *, size_t, | 86 | static ssize_t acpi_system_read_dsdt(struct file *, char __user *, size_t, |
| 67 | loff_t *); | 87 | loff_t *); |
| @@ -125,6 +145,7 @@ static int __init acpi_system_init(void) | |||
| 125 | if (acpi_disabled) | 145 | if (acpi_disabled) |
| 126 | return 0; | 146 | return 0; |
| 127 | 147 | ||
| 148 | #ifdef CONFIG_ACPI_PROCFS | ||
| 128 | /* 'info' [R] */ | 149 | /* 'info' [R] */ |
| 129 | name = ACPI_SYSTEM_FILE_INFO; | 150 | name = ACPI_SYSTEM_FILE_INFO; |
| 130 | entry = create_proc_entry(name, S_IRUGO, acpi_root_dir); | 151 | entry = create_proc_entry(name, S_IRUGO, acpi_root_dir); |
| @@ -133,6 +154,7 @@ static int __init acpi_system_init(void) | |||
| 133 | else { | 154 | else { |
| 134 | entry->proc_fops = &acpi_system_info_ops; | 155 | entry->proc_fops = &acpi_system_info_ops; |
| 135 | } | 156 | } |
| 157 | #endif | ||
| 136 | 158 | ||
| 137 | /* 'dsdt' [R] */ | 159 | /* 'dsdt' [R] */ |
| 138 | name = ACPI_SYSTEM_FILE_DSDT; | 160 | name = ACPI_SYSTEM_FILE_DSDT; |
| @@ -156,7 +178,9 @@ static int __init acpi_system_init(void) | |||
| 156 | Error: | 178 | Error: |
| 157 | remove_proc_entry(ACPI_SYSTEM_FILE_FADT, acpi_root_dir); | 179 | remove_proc_entry(ACPI_SYSTEM_FILE_FADT, acpi_root_dir); |
| 158 | remove_proc_entry(ACPI_SYSTEM_FILE_DSDT, acpi_root_dir); | 180 | remove_proc_entry(ACPI_SYSTEM_FILE_DSDT, acpi_root_dir); |
| 181 | #ifdef CONFIG_ACPI_PROCFS | ||
| 159 | remove_proc_entry(ACPI_SYSTEM_FILE_INFO, acpi_root_dir); | 182 | remove_proc_entry(ACPI_SYSTEM_FILE_INFO, acpi_root_dir); |
| 183 | #endif | ||
| 160 | 184 | ||
| 161 | error = -EFAULT; | 185 | error = -EFAULT; |
| 162 | goto Done; | 186 | goto Done; |
diff --git a/drivers/acpi/thermal.c b/drivers/acpi/thermal.c index 40ddb4dd9631..f76d3168c2b2 100644 --- a/drivers/acpi/thermal.c +++ b/drivers/acpi/thermal.c | |||
| @@ -82,7 +82,7 @@ MODULE_PARM_DESC(tzp, "Thermal zone polling frequency, in 1/10 seconds.\n"); | |||
| 82 | 82 | ||
| 83 | static int acpi_thermal_add(struct acpi_device *device); | 83 | static int acpi_thermal_add(struct acpi_device *device); |
| 84 | static int acpi_thermal_remove(struct acpi_device *device, int type); | 84 | static int acpi_thermal_remove(struct acpi_device *device, int type); |
| 85 | static int acpi_thermal_resume(struct acpi_device *device, int state); | 85 | static int acpi_thermal_resume(struct acpi_device *device); |
| 86 | static int acpi_thermal_state_open_fs(struct inode *inode, struct file *file); | 86 | static int acpi_thermal_state_open_fs(struct inode *inode, struct file *file); |
| 87 | static int acpi_thermal_temp_open_fs(struct inode *inode, struct file *file); | 87 | static int acpi_thermal_temp_open_fs(struct inode *inode, struct file *file); |
| 88 | static int acpi_thermal_trip_open_fs(struct inode *inode, struct file *file); | 88 | static int acpi_thermal_trip_open_fs(struct inode *inode, struct file *file); |
| @@ -1353,7 +1353,7 @@ static int acpi_thermal_remove(struct acpi_device *device, int type) | |||
| 1353 | return 0; | 1353 | return 0; |
| 1354 | } | 1354 | } |
| 1355 | 1355 | ||
| 1356 | static int acpi_thermal_resume(struct acpi_device *device, int state) | 1356 | static int acpi_thermal_resume(struct acpi_device *device) |
| 1357 | { | 1357 | { |
| 1358 | struct acpi_thermal *tz = NULL; | 1358 | struct acpi_thermal *tz = NULL; |
| 1359 | int i; | 1359 | int i; |
diff --git a/drivers/acpi/video.c b/drivers/acpi/video.c index 3d54680d0333..e0b97add8c63 100644 --- a/drivers/acpi/video.c +++ b/drivers/acpi/video.c | |||
| @@ -32,6 +32,7 @@ | |||
| 32 | #include <linux/proc_fs.h> | 32 | #include <linux/proc_fs.h> |
| 33 | #include <linux/seq_file.h> | 33 | #include <linux/seq_file.h> |
| 34 | 34 | ||
| 35 | #include <linux/backlight.h> | ||
| 35 | #include <asm/uaccess.h> | 36 | #include <asm/uaccess.h> |
| 36 | 37 | ||
| 37 | #include <acpi/acpi_bus.h> | 38 | #include <acpi/acpi_bus.h> |
| @@ -56,6 +57,12 @@ | |||
| 56 | 57 | ||
| 57 | #define ACPI_VIDEO_HEAD_INVALID (~0u - 1) | 58 | #define ACPI_VIDEO_HEAD_INVALID (~0u - 1) |
| 58 | #define ACPI_VIDEO_HEAD_END (~0u) | 59 | #define ACPI_VIDEO_HEAD_END (~0u) |
| 60 | #define MAX_NAME_LEN 20 | ||
| 61 | |||
| 62 | #define ACPI_VIDEO_DISPLAY_CRT 1 | ||
| 63 | #define ACPI_VIDEO_DISPLAY_TV 2 | ||
| 64 | #define ACPI_VIDEO_DISPLAY_DVI 3 | ||
| 65 | #define ACPI_VIDEO_DISPLAY_LCD 4 | ||
| 59 | 66 | ||
| 60 | #define _COMPONENT ACPI_VIDEO_COMPONENT | 67 | #define _COMPONENT ACPI_VIDEO_COMPONENT |
| 61 | ACPI_MODULE_NAME("acpi_video") | 68 | ACPI_MODULE_NAME("acpi_video") |
| @@ -66,16 +73,14 @@ MODULE_LICENSE("GPL"); | |||
| 66 | 73 | ||
| 67 | static int acpi_video_bus_add(struct acpi_device *device); | 74 | static int acpi_video_bus_add(struct acpi_device *device); |
| 68 | static int acpi_video_bus_remove(struct acpi_device *device, int type); | 75 | static int acpi_video_bus_remove(struct acpi_device *device, int type); |
| 69 | static int acpi_video_bus_match(struct acpi_device *device, | ||
| 70 | struct acpi_driver *driver); | ||
| 71 | 76 | ||
| 72 | static struct acpi_driver acpi_video_bus = { | 77 | static struct acpi_driver acpi_video_bus = { |
| 73 | .name = ACPI_VIDEO_DRIVER_NAME, | 78 | .name = ACPI_VIDEO_DRIVER_NAME, |
| 74 | .class = ACPI_VIDEO_CLASS, | 79 | .class = ACPI_VIDEO_CLASS, |
| 80 | .ids = ACPI_VIDEO_HID, | ||
| 75 | .ops = { | 81 | .ops = { |
| 76 | .add = acpi_video_bus_add, | 82 | .add = acpi_video_bus_add, |
| 77 | .remove = acpi_video_bus_remove, | 83 | .remove = acpi_video_bus_remove, |
| 78 | .match = acpi_video_bus_match, | ||
| 79 | }, | 84 | }, |
| 80 | }; | 85 | }; |
| 81 | 86 | ||
| @@ -133,20 +138,21 @@ struct acpi_video_device_flags { | |||
| 133 | u8 crt:1; | 138 | u8 crt:1; |
| 134 | u8 lcd:1; | 139 | u8 lcd:1; |
| 135 | u8 tvout:1; | 140 | u8 tvout:1; |
| 141 | u8 dvi:1; | ||
| 136 | u8 bios:1; | 142 | u8 bios:1; |
| 137 | u8 unknown:1; | 143 | u8 unknown:1; |
| 138 | u8 reserved:3; | 144 | u8 reserved:2; |
| 139 | }; | 145 | }; |
| 140 | 146 | ||
| 141 | struct acpi_video_device_cap { | 147 | struct acpi_video_device_cap { |
| 142 | u8 _ADR:1; /*Return the unique ID */ | 148 | u8 _ADR:1; /*Return the unique ID */ |
| 143 | u8 _BCL:1; /*Query list of brightness control levels supported */ | 149 | u8 _BCL:1; /*Query list of brightness control levels supported */ |
| 144 | u8 _BCM:1; /*Set the brightness level */ | 150 | u8 _BCM:1; /*Set the brightness level */ |
| 151 | u8 _BQC:1; /* Get current brightness level */ | ||
| 145 | u8 _DDC:1; /*Return the EDID for this device */ | 152 | u8 _DDC:1; /*Return the EDID for this device */ |
| 146 | u8 _DCS:1; /*Return status of output device */ | 153 | u8 _DCS:1; /*Return status of output device */ |
| 147 | u8 _DGS:1; /*Query graphics state */ | 154 | u8 _DGS:1; /*Query graphics state */ |
| 148 | u8 _DSS:1; /*Device state set */ | 155 | u8 _DSS:1; /*Device state set */ |
| 149 | u8 _reserved:1; | ||
| 150 | }; | 156 | }; |
| 151 | 157 | ||
| 152 | struct acpi_video_device_brightness { | 158 | struct acpi_video_device_brightness { |
| @@ -163,6 +169,8 @@ struct acpi_video_device { | |||
| 163 | struct acpi_video_bus *video; | 169 | struct acpi_video_bus *video; |
| 164 | struct acpi_device *dev; | 170 | struct acpi_device *dev; |
| 165 | struct acpi_video_device_brightness *brightness; | 171 | struct acpi_video_device_brightness *brightness; |
| 172 | struct backlight_device *backlight; | ||
| 173 | struct backlight_properties *data; | ||
| 166 | }; | 174 | }; |
| 167 | 175 | ||
| 168 | /* bus */ | 176 | /* bus */ |
| @@ -257,11 +265,35 @@ static void acpi_video_device_bind(struct acpi_video_bus *video, | |||
| 257 | struct acpi_video_device *device); | 265 | struct acpi_video_device *device); |
| 258 | static int acpi_video_device_enumerate(struct acpi_video_bus *video); | 266 | static int acpi_video_device_enumerate(struct acpi_video_bus *video); |
| 259 | static int acpi_video_switch_output(struct acpi_video_bus *video, int event); | 267 | static int acpi_video_switch_output(struct acpi_video_bus *video, int event); |
| 268 | static int acpi_video_device_lcd_set_level(struct acpi_video_device *device, | ||
| 269 | int level); | ||
| 270 | static int acpi_video_device_lcd_get_level_current( | ||
| 271 | struct acpi_video_device *device, | ||
| 272 | unsigned long *level); | ||
| 260 | static int acpi_video_get_next_level(struct acpi_video_device *device, | 273 | static int acpi_video_get_next_level(struct acpi_video_device *device, |
| 261 | u32 level_current, u32 event); | 274 | u32 level_current, u32 event); |
| 262 | static void acpi_video_switch_brightness(struct acpi_video_device *device, | 275 | static void acpi_video_switch_brightness(struct acpi_video_device *device, |
| 263 | int event); | 276 | int event); |
| 264 | 277 | ||
| 278 | /*backlight device sysfs support*/ | ||
| 279 | static int acpi_video_get_brightness(struct backlight_device *bd) | ||
| 280 | { | ||
| 281 | unsigned long cur_level; | ||
| 282 | struct acpi_video_device *vd = | ||
| 283 | (struct acpi_video_device *)class_get_devdata(&bd->class_dev); | ||
| 284 | acpi_video_device_lcd_get_level_current(vd, &cur_level); | ||
| 285 | return (int) cur_level; | ||
| 286 | } | ||
| 287 | |||
| 288 | static int acpi_video_set_brightness(struct backlight_device *bd) | ||
| 289 | { | ||
| 290 | int request_level = bd->props->brightness; | ||
| 291 | struct acpi_video_device *vd = | ||
| 292 | (struct acpi_video_device *)class_get_devdata(&bd->class_dev); | ||
| 293 | acpi_video_device_lcd_set_level(vd, request_level); | ||
| 294 | return 0; | ||
| 295 | } | ||
| 296 | |||
| 265 | /* -------------------------------------------------------------------------- | 297 | /* -------------------------------------------------------------------------- |
| 266 | Video Management | 298 | Video Management |
| 267 | -------------------------------------------------------------------------- */ | 299 | -------------------------------------------------------------------------- */ |
| @@ -499,6 +531,7 @@ static void acpi_video_device_find_cap(struct acpi_video_device *device) | |||
| 499 | acpi_integer status; | 531 | acpi_integer status; |
| 500 | acpi_handle h_dummy1; | 532 | acpi_handle h_dummy1; |
| 501 | int i; | 533 | int i; |
| 534 | u32 max_level = 0; | ||
| 502 | union acpi_object *obj = NULL; | 535 | union acpi_object *obj = NULL; |
| 503 | struct acpi_video_device_brightness *br = NULL; | 536 | struct acpi_video_device_brightness *br = NULL; |
| 504 | 537 | ||
| @@ -514,6 +547,8 @@ static void acpi_video_device_find_cap(struct acpi_video_device *device) | |||
| 514 | if (ACPI_SUCCESS(acpi_get_handle(device->dev->handle, "_BCM", &h_dummy1))) { | 547 | if (ACPI_SUCCESS(acpi_get_handle(device->dev->handle, "_BCM", &h_dummy1))) { |
| 515 | device->cap._BCM = 1; | 548 | device->cap._BCM = 1; |
| 516 | } | 549 | } |
| 550 | if (ACPI_SUCCESS(acpi_get_handle(device->dev->handle,"_BQC",&h_dummy1))) | ||
| 551 | device->cap._BQC = 1; | ||
| 517 | if (ACPI_SUCCESS(acpi_get_handle(device->dev->handle, "_DDC", &h_dummy1))) { | 552 | if (ACPI_SUCCESS(acpi_get_handle(device->dev->handle, "_DDC", &h_dummy1))) { |
| 518 | device->cap._DDC = 1; | 553 | device->cap._DDC = 1; |
| 519 | } | 554 | } |
| @@ -550,6 +585,8 @@ static void acpi_video_device_find_cap(struct acpi_video_device *device) | |||
| 550 | continue; | 585 | continue; |
| 551 | } | 586 | } |
| 552 | br->levels[count] = (u32) o->integer.value; | 587 | br->levels[count] = (u32) o->integer.value; |
| 588 | if (br->levels[count] > max_level) | ||
| 589 | max_level = br->levels[count]; | ||
| 553 | count++; | 590 | count++; |
| 554 | } | 591 | } |
| 555 | out: | 592 | out: |
| @@ -568,6 +605,37 @@ static void acpi_video_device_find_cap(struct acpi_video_device *device) | |||
| 568 | 605 | ||
| 569 | kfree(obj); | 606 | kfree(obj); |
| 570 | 607 | ||
| 608 | if (device->cap._BCL && device->cap._BCM && device->cap._BQC){ | ||
| 609 | unsigned long tmp; | ||
| 610 | static int count = 0; | ||
| 611 | char *name; | ||
| 612 | struct backlight_properties *acpi_video_data; | ||
| 613 | |||
| 614 | name = kzalloc(MAX_NAME_LEN, GFP_KERNEL); | ||
| 615 | if (!name) | ||
| 616 | return; | ||
| 617 | |||
| 618 | acpi_video_data = kzalloc( | ||
| 619 | sizeof(struct backlight_properties), | ||
| 620 | GFP_KERNEL); | ||
| 621 | if (!acpi_video_data){ | ||
| 622 | kfree(name); | ||
| 623 | return; | ||
| 624 | } | ||
| 625 | acpi_video_data->owner = THIS_MODULE; | ||
| 626 | acpi_video_data->get_brightness = | ||
| 627 | acpi_video_get_brightness; | ||
| 628 | acpi_video_data->update_status = | ||
| 629 | acpi_video_set_brightness; | ||
| 630 | sprintf(name, "acpi_video%d", count++); | ||
| 631 | device->data = acpi_video_data; | ||
| 632 | acpi_video_data->max_brightness = max_level; | ||
| 633 | acpi_video_device_lcd_get_level_current(device, &tmp); | ||
| 634 | acpi_video_data->brightness = (int)tmp; | ||
| 635 | device->backlight = backlight_device_register(name, | ||
| 636 | NULL, device, acpi_video_data); | ||
| 637 | kfree(name); | ||
| 638 | } | ||
| 571 | return; | 639 | return; |
| 572 | } | 640 | } |
| 573 | 641 | ||
| @@ -668,6 +736,8 @@ static int acpi_video_device_info_seq_show(struct seq_file *seq, void *offset) | |||
| 668 | seq_printf(seq, "LCD\n"); | 736 | seq_printf(seq, "LCD\n"); |
| 669 | else if (dev->flags.tvout) | 737 | else if (dev->flags.tvout) |
| 670 | seq_printf(seq, "TVOUT\n"); | 738 | seq_printf(seq, "TVOUT\n"); |
| 739 | else if (dev->flags.dvi) | ||
| 740 | seq_printf(seq, "DVI\n"); | ||
| 671 | else | 741 | else |
| 672 | seq_printf(seq, "UNKNOWN\n"); | 742 | seq_printf(seq, "UNKNOWN\n"); |
| 673 | 743 | ||
| @@ -1242,6 +1312,16 @@ static int acpi_video_bus_remove_fs(struct acpi_device *device) | |||
| 1242 | -------------------------------------------------------------------------- */ | 1312 | -------------------------------------------------------------------------- */ |
| 1243 | 1313 | ||
| 1244 | /* device interface */ | 1314 | /* device interface */ |
| 1315 | static struct acpi_video_device_attrib* | ||
| 1316 | acpi_video_get_device_attr(struct acpi_video_bus *video, unsigned long device_id) | ||
| 1317 | { | ||
| 1318 | int count; | ||
| 1319 | |||
| 1320 | for(count = 0; count < video->attached_count; count++) | ||
| 1321 | if((video->attached_array[count].value.int_val & 0xffff) == device_id) | ||
| 1322 | return &(video->attached_array[count].value.attrib); | ||
| 1323 | return NULL; | ||
| 1324 | } | ||
| 1245 | 1325 | ||
| 1246 | static int | 1326 | static int |
| 1247 | acpi_video_bus_get_one_device(struct acpi_device *device, | 1327 | acpi_video_bus_get_one_device(struct acpi_device *device, |
| @@ -1250,7 +1330,7 @@ acpi_video_bus_get_one_device(struct acpi_device *device, | |||
| 1250 | unsigned long device_id; | 1330 | unsigned long device_id; |
| 1251 | int status; | 1331 | int status; |
| 1252 | struct acpi_video_device *data; | 1332 | struct acpi_video_device *data; |
| 1253 | 1333 | struct acpi_video_device_attrib* attribute; | |
| 1254 | 1334 | ||
| 1255 | if (!device || !video) | 1335 | if (!device || !video) |
| 1256 | return -EINVAL; | 1336 | return -EINVAL; |
| @@ -1271,20 +1351,30 @@ acpi_video_bus_get_one_device(struct acpi_device *device, | |||
| 1271 | data->video = video; | 1351 | data->video = video; |
| 1272 | data->dev = device; | 1352 | data->dev = device; |
| 1273 | 1353 | ||
| 1274 | switch (device_id & 0xffff) { | 1354 | attribute = acpi_video_get_device_attr(video, device_id); |
| 1275 | case 0x0100: | 1355 | |
| 1276 | data->flags.crt = 1; | 1356 | if((attribute != NULL) && attribute->device_id_scheme) { |
| 1277 | break; | 1357 | switch (attribute->display_type) { |
| 1278 | case 0x0400: | 1358 | case ACPI_VIDEO_DISPLAY_CRT: |
| 1279 | data->flags.lcd = 1; | 1359 | data->flags.crt = 1; |
| 1280 | break; | 1360 | break; |
| 1281 | case 0x0200: | 1361 | case ACPI_VIDEO_DISPLAY_TV: |
| 1282 | data->flags.tvout = 1; | 1362 | data->flags.tvout = 1; |
| 1283 | break; | 1363 | break; |
| 1284 | default: | 1364 | case ACPI_VIDEO_DISPLAY_DVI: |
| 1365 | data->flags.dvi = 1; | ||
| 1366 | break; | ||
| 1367 | case ACPI_VIDEO_DISPLAY_LCD: | ||
| 1368 | data->flags.lcd = 1; | ||
| 1369 | break; | ||
| 1370 | default: | ||
| 1371 | data->flags.unknown = 1; | ||
| 1372 | break; | ||
| 1373 | } | ||
| 1374 | if(attribute->bios_can_detect) | ||
| 1375 | data->flags.bios = 1; | ||
| 1376 | } else | ||
| 1285 | data->flags.unknown = 1; | 1377 | data->flags.unknown = 1; |
| 1286 | break; | ||
| 1287 | } | ||
| 1288 | 1378 | ||
| 1289 | acpi_video_device_bind(video, data); | 1379 | acpi_video_device_bind(video, data); |
| 1290 | acpi_video_device_find_cap(data); | 1380 | acpi_video_device_find_cap(data); |
| @@ -1588,7 +1678,10 @@ static int acpi_video_bus_put_one_device(struct acpi_video_device *device) | |||
| 1588 | status = acpi_remove_notify_handler(device->dev->handle, | 1678 | status = acpi_remove_notify_handler(device->dev->handle, |
| 1589 | ACPI_DEVICE_NOTIFY, | 1679 | ACPI_DEVICE_NOTIFY, |
| 1590 | acpi_video_device_notify); | 1680 | acpi_video_device_notify); |
| 1591 | 1681 | if (device->backlight){ | |
| 1682 | backlight_device_unregister(device->backlight); | ||
| 1683 | kfree(device->data); | ||
| 1684 | } | ||
| 1592 | return 0; | 1685 | return 0; |
| 1593 | } | 1686 | } |
| 1594 | 1687 | ||
| @@ -1790,39 +1883,6 @@ static int acpi_video_bus_remove(struct acpi_device *device, int type) | |||
| 1790 | return 0; | 1883 | return 0; |
| 1791 | } | 1884 | } |
| 1792 | 1885 | ||
| 1793 | static int | ||
| 1794 | acpi_video_bus_match(struct acpi_device *device, struct acpi_driver *driver) | ||
| 1795 | { | ||
| 1796 | acpi_handle h_dummy1; | ||
| 1797 | acpi_handle h_dummy2; | ||
| 1798 | acpi_handle h_dummy3; | ||
| 1799 | |||
| 1800 | |||
| 1801 | if (!device || !driver) | ||
| 1802 | return -EINVAL; | ||
| 1803 | |||
| 1804 | /* Since there is no HID, CID for ACPI Video drivers, we have | ||
| 1805 | * to check well known required nodes for each feature we support. | ||
| 1806 | */ | ||
| 1807 | |||
| 1808 | /* Does this device able to support video switching ? */ | ||
| 1809 | if (ACPI_SUCCESS(acpi_get_handle(device->handle, "_DOD", &h_dummy1)) && | ||
| 1810 | ACPI_SUCCESS(acpi_get_handle(device->handle, "_DOS", &h_dummy2))) | ||
| 1811 | return 0; | ||
| 1812 | |||
| 1813 | /* Does this device able to retrieve a video ROM ? */ | ||
| 1814 | if (ACPI_SUCCESS(acpi_get_handle(device->handle, "_ROM", &h_dummy1))) | ||
| 1815 | return 0; | ||
| 1816 | |||
| 1817 | /* Does this device able to configure which video head to be POSTed ? */ | ||
| 1818 | if (ACPI_SUCCESS(acpi_get_handle(device->handle, "_VPO", &h_dummy1)) && | ||
| 1819 | ACPI_SUCCESS(acpi_get_handle(device->handle, "_GPD", &h_dummy2)) && | ||
| 1820 | ACPI_SUCCESS(acpi_get_handle(device->handle, "_SPD", &h_dummy3))) | ||
| 1821 | return 0; | ||
| 1822 | |||
| 1823 | return -ENODEV; | ||
| 1824 | } | ||
| 1825 | |||
| 1826 | static int __init acpi_video_init(void) | 1886 | static int __init acpi_video_init(void) |
| 1827 | { | 1887 | { |
| 1828 | int result = 0; | 1888 | int result = 0; |
diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig index 00db31c314e0..89bba277da5f 100644 --- a/drivers/misc/Kconfig +++ b/drivers/misc/Kconfig | |||
| @@ -69,6 +69,25 @@ config TIFM_7XX1 | |||
| 69 | To compile this driver as a module, choose M here: the module will | 69 | To compile this driver as a module, choose M here: the module will |
| 70 | be called tifm_7xx1. | 70 | be called tifm_7xx1. |
| 71 | 71 | ||
| 72 | config ASUS_LAPTOP | ||
| 73 | tristate "Asus Laptop Extras (EXPERIMENTAL)" | ||
| 74 | depends on X86 | ||
| 75 | depends on ACPI | ||
| 76 | depends on EXPERIMENTAL && !ACPI_ASUS | ||
| 77 | depends on LEDS_CLASS | ||
| 78 | depends on BACKLIGHT_CLASS_DEVICE | ||
| 79 | ---help--- | ||
| 80 | This is the new Linux driver for Asus laptops. It may also support some | ||
| 81 | MEDION, JVC or VICTOR laptops. It makes all the extra buttons generate | ||
| 82 | standard ACPI events that go through /proc/acpi/events. It also adds | ||
| 83 | support for video output switching, LCD backlight control, Bluetooth and | ||
| 84 | Wlan control, and most importantly, allows you to blink those fancy LEDs. | ||
| 85 | |||
| 86 | For more information and a userspace daemon for handling the extra | ||
| 87 | buttons see <http://acpi4asus.sf.net/>. | ||
| 88 | |||
| 89 | If you have an ACPI-compatible ASUS laptop, say Y or M here. | ||
| 90 | |||
| 72 | config MSI_LAPTOP | 91 | config MSI_LAPTOP |
| 73 | tristate "MSI Laptop Extras" | 92 | tristate "MSI Laptop Extras" |
| 74 | depends on X86 | 93 | depends on X86 |
diff --git a/drivers/misc/Makefile b/drivers/misc/Makefile index c9e98ab021c5..35da53c409c0 100644 --- a/drivers/misc/Makefile +++ b/drivers/misc/Makefile | |||
| @@ -6,6 +6,7 @@ obj- := misc.o # Dummy rule to force built-in.o to be made | |||
| 6 | obj-$(CONFIG_IBM_ASM) += ibmasm/ | 6 | obj-$(CONFIG_IBM_ASM) += ibmasm/ |
| 7 | obj-$(CONFIG_HDPU_FEATURES) += hdpuftrs/ | 7 | obj-$(CONFIG_HDPU_FEATURES) += hdpuftrs/ |
| 8 | obj-$(CONFIG_MSI_LAPTOP) += msi-laptop.o | 8 | obj-$(CONFIG_MSI_LAPTOP) += msi-laptop.o |
| 9 | obj-$(CONFIG_ASUS_LAPTOP) += asus-laptop.o | ||
| 9 | obj-$(CONFIG_LKDTM) += lkdtm.o | 10 | obj-$(CONFIG_LKDTM) += lkdtm.o |
| 10 | obj-$(CONFIG_TIFM_CORE) += tifm_core.o | 11 | obj-$(CONFIG_TIFM_CORE) += tifm_core.o |
| 11 | obj-$(CONFIG_TIFM_7XX1) += tifm_7xx1.o | 12 | obj-$(CONFIG_TIFM_7XX1) += tifm_7xx1.o |
diff --git a/drivers/misc/asus-laptop.c b/drivers/misc/asus-laptop.c new file mode 100644 index 000000000000..861c39935f99 --- /dev/null +++ b/drivers/misc/asus-laptop.c | |||
| @@ -0,0 +1,1165 @@ | |||
| 1 | /* | ||
| 2 | * asus-laptop.c - Asus Laptop Support | ||
| 3 | * | ||
| 4 | * | ||
| 5 | * Copyright (C) 2002-2005 Julien Lerouge, 2003-2006 Karol Kozimor | ||
| 6 | * Copyright (C) 2006 Corentin Chary | ||
| 7 | * | ||
| 8 | * This program is free software; you can redistribute it and/or modify | ||
| 9 | * it under the terms of the GNU General Public License as published by | ||
| 10 | * the Free Software Foundation; either version 2 of the License, or | ||
| 11 | * (at your option) any later version. | ||
| 12 | * | ||
| 13 | * This program is distributed in the hope that it will be useful, | ||
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 16 | * GNU General Public License for more details. | ||
| 17 | * | ||
| 18 | * You should have received a copy of the GNU General Public License | ||
| 19 | * along with this program; if not, write to the Free Software | ||
| 20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
| 21 | * | ||
| 22 | * | ||
| 23 | * The development page for this driver is located at | ||
| 24 | * http://sourceforge.net/projects/acpi4asus/ | ||
| 25 | * | ||
| 26 | * Credits: | ||
| 27 | * Pontus Fuchs - Helper functions, cleanup | ||
| 28 | * Johann Wiesner - Small compile fixes | ||
| 29 | * John Belmonte - ACPI code for Toshiba laptop was a good starting point. | ||
| 30 | * Eric Burghard - LED display support for W1N | ||
| 31 | * Josh Green - Light Sens support | ||
| 32 | * Thomas Tuttle - His first patch for led support was very helpfull | ||
| 33 | * | ||
| 34 | */ | ||
| 35 | |||
| 36 | #include <linux/autoconf.h> | ||
| 37 | #include <linux/kernel.h> | ||
| 38 | #include <linux/module.h> | ||
| 39 | #include <linux/init.h> | ||
| 40 | #include <linux/types.h> | ||
| 41 | #include <linux/err.h> | ||
| 42 | #include <linux/proc_fs.h> | ||
| 43 | #include <linux/backlight.h> | ||
| 44 | #include <linux/fb.h> | ||
| 45 | #include <linux/leds.h> | ||
| 46 | #include <linux/platform_device.h> | ||
| 47 | #include <acpi/acpi_drivers.h> | ||
| 48 | #include <acpi/acpi_bus.h> | ||
| 49 | #include <asm/uaccess.h> | ||
| 50 | |||
| 51 | #define ASUS_LAPTOP_VERSION "0.40" | ||
| 52 | |||
| 53 | #define ASUS_HOTK_NAME "Asus Laptop Support" | ||
| 54 | #define ASUS_HOTK_CLASS "hotkey" | ||
| 55 | #define ASUS_HOTK_DEVICE_NAME "Hotkey" | ||
| 56 | #define ASUS_HOTK_HID "ATK0100" | ||
| 57 | #define ASUS_HOTK_FILE "asus-laptop" | ||
| 58 | #define ASUS_HOTK_PREFIX "\\_SB.ATKD." | ||
| 59 | |||
| 60 | /* | ||
| 61 | * Some events we use, same for all Asus | ||
| 62 | */ | ||
| 63 | #define ATKD_BR_UP 0x10 | ||
| 64 | #define ATKD_BR_DOWN 0x20 | ||
| 65 | #define ATKD_LCD_ON 0x33 | ||
| 66 | #define ATKD_LCD_OFF 0x34 | ||
| 67 | |||
| 68 | /* | ||
| 69 | * Known bits returned by \_SB.ATKD.HWRS | ||
| 70 | */ | ||
| 71 | #define WL_HWRS 0x80 | ||
| 72 | #define BT_HWRS 0x100 | ||
| 73 | |||
| 74 | /* | ||
| 75 | * Flags for hotk status | ||
| 76 | * WL_ON and BT_ON are also used for wireless_status() | ||
| 77 | */ | ||
| 78 | #define WL_ON 0x01 //internal Wifi | ||
| 79 | #define BT_ON 0x02 //internal Bluetooth | ||
| 80 | #define MLED_ON 0x04 //mail LED | ||
| 81 | #define TLED_ON 0x08 //touchpad LED | ||
| 82 | #define RLED_ON 0x10 //Record LED | ||
| 83 | #define PLED_ON 0x20 //Phone LED | ||
| 84 | #define LCD_ON 0x40 //LCD backlight | ||
| 85 | |||
| 86 | #define ASUS_LOG ASUS_HOTK_FILE ": " | ||
| 87 | #define ASUS_ERR KERN_ERR ASUS_LOG | ||
| 88 | #define ASUS_WARNING KERN_WARNING ASUS_LOG | ||
| 89 | #define ASUS_NOTICE KERN_NOTICE ASUS_LOG | ||
| 90 | #define ASUS_INFO KERN_INFO ASUS_LOG | ||
| 91 | #define ASUS_DEBUG KERN_DEBUG ASUS_LOG | ||
| 92 | |||
| 93 | MODULE_AUTHOR("Julien Lerouge, Karol Kozimor, Corentin Chary"); | ||
| 94 | MODULE_DESCRIPTION(ASUS_HOTK_NAME); | ||
| 95 | MODULE_LICENSE("GPL"); | ||
| 96 | |||
| 97 | #define ASUS_HANDLE(object, paths...) \ | ||
| 98 | static acpi_handle object##_handle = NULL; \ | ||
| 99 | static char *object##_paths[] = { paths } | ||
| 100 | |||
| 101 | /* LED */ | ||
| 102 | ASUS_HANDLE(mled_set, ASUS_HOTK_PREFIX "MLED"); | ||
| 103 | ASUS_HANDLE(tled_set, ASUS_HOTK_PREFIX "TLED"); | ||
| 104 | ASUS_HANDLE(rled_set, ASUS_HOTK_PREFIX "RLED"); /* W1JC */ | ||
| 105 | ASUS_HANDLE(pled_set, ASUS_HOTK_PREFIX "PLED"); /* A7J */ | ||
| 106 | |||
| 107 | /* LEDD */ | ||
| 108 | ASUS_HANDLE(ledd_set, ASUS_HOTK_PREFIX "SLCM"); | ||
| 109 | |||
| 110 | /* Bluetooth and WLAN | ||
| 111 | * WLED and BLED are not handled like other XLED, because in some dsdt | ||
| 112 | * they also control the WLAN/Bluetooth device. | ||
| 113 | */ | ||
| 114 | ASUS_HANDLE(wl_switch, ASUS_HOTK_PREFIX "WLED"); | ||
| 115 | ASUS_HANDLE(bt_switch, ASUS_HOTK_PREFIX "BLED"); | ||
| 116 | ASUS_HANDLE(wireless_status, ASUS_HOTK_PREFIX "RSTS"); /* All new models */ | ||
| 117 | |||
| 118 | /* Brightness */ | ||
| 119 | ASUS_HANDLE(brightness_set, ASUS_HOTK_PREFIX "SPLV"); | ||
| 120 | ASUS_HANDLE(brightness_get, ASUS_HOTK_PREFIX "GPLV"); | ||
| 121 | |||
| 122 | /* Backlight */ | ||
| 123 | ASUS_HANDLE(lcd_switch, "\\_SB.PCI0.SBRG.EC0._Q10", /* All new models */ | ||
| 124 | "\\_SB.PCI0.ISA.EC0._Q10", /* A1x */ | ||
| 125 | "\\_SB.PCI0.PX40.ECD0._Q10", /* L3C */ | ||
| 126 | "\\_SB.PCI0.PX40.EC0.Q10", /* M1A */ | ||
| 127 | "\\_SB.PCI0.LPCB.EC0._Q10", /* P30 */ | ||
| 128 | "\\_SB.PCI0.PX40.Q10", /* S1x */ | ||
| 129 | "\\Q10"); /* A2x, L2D, L3D, M2E */ | ||
| 130 | |||
| 131 | /* Display */ | ||
| 132 | ASUS_HANDLE(display_set, ASUS_HOTK_PREFIX "SDSP"); | ||
| 133 | ASUS_HANDLE(display_get, "\\_SB.PCI0.P0P1.VGA.GETD", /* A6B, A6K A6R A7D F3JM L4R M6R A3G | ||
| 134 | M6A M6V VX-1 V6J V6V W3Z */ | ||
| 135 | "\\_SB.PCI0.P0P2.VGA.GETD", /* A3E A4K, A4D A4L A6J A7J A8J Z71V M9V | ||
| 136 | S5A M5A z33A W1Jc W2V */ | ||
| 137 | "\\_SB.PCI0.P0P3.VGA.GETD", /* A6V A6Q */ | ||
| 138 | "\\_SB.PCI0.P0PA.VGA.GETD", /* A6T, A6M */ | ||
| 139 | "\\_SB.PCI0.PCI1.VGAC.NMAP", /* L3C */ | ||
| 140 | "\\_SB.PCI0.VGA.GETD", /* Z96F */ | ||
| 141 | "\\ACTD", /* A2D */ | ||
| 142 | "\\ADVG", /* A4G Z71A W1N W5A W5F M2N M3N M5N M6N S1N S5N */ | ||
| 143 | "\\DNXT", /* P30 */ | ||
| 144 | "\\INFB", /* A2H D1 L2D L3D L3H L2E L5D L5C M1A M2E L4L W3V */ | ||
| 145 | "\\SSTE"); /* A3F A6F A3N A3L M6N W3N W6A */ | ||
| 146 | |||
| 147 | ASUS_HANDLE(ls_switch, ASUS_HOTK_PREFIX "ALSC"); /* Z71A Z71V */ | ||
| 148 | ASUS_HANDLE(ls_level, ASUS_HOTK_PREFIX "ALSL"); /* Z71A Z71V */ | ||
| 149 | |||
| 150 | /* | ||
| 151 | * This is the main structure, we can use it to store anything interesting | ||
| 152 | * about the hotk device | ||
| 153 | */ | ||
| 154 | struct asus_hotk { | ||
| 155 | char *name; //laptop name | ||
| 156 | struct acpi_device *device; //the device we are in | ||
| 157 | acpi_handle handle; //the handle of the hotk device | ||
| 158 | char status; //status of the hotk, for LEDs, ... | ||
| 159 | u32 ledd_status; //status of the LED display | ||
| 160 | u8 light_level; //light sensor level | ||
| 161 | u8 light_switch; //light sensor switch value | ||
| 162 | u16 event_count[128]; //count for each event TODO make this better | ||
| 163 | }; | ||
| 164 | |||
| 165 | /* | ||
| 166 | * This header is made available to allow proper configuration given model, | ||
| 167 | * revision number , ... this info cannot go in struct asus_hotk because it is | ||
| 168 | * available before the hotk | ||
| 169 | */ | ||
| 170 | static struct acpi_table_header *asus_info; | ||
| 171 | |||
| 172 | /* The actual device the driver binds to */ | ||
| 173 | static struct asus_hotk *hotk; | ||
| 174 | |||
| 175 | /* | ||
| 176 | * The hotkey driver declaration | ||
| 177 | */ | ||
| 178 | static int asus_hotk_add(struct acpi_device *device); | ||
| 179 | static int asus_hotk_remove(struct acpi_device *device, int type); | ||
| 180 | static struct acpi_driver asus_hotk_driver = { | ||
| 181 | .name = ASUS_HOTK_NAME, | ||
| 182 | .class = ASUS_HOTK_CLASS, | ||
| 183 | .ids = ASUS_HOTK_HID, | ||
| 184 | .ops = { | ||
| 185 | .add = asus_hotk_add, | ||
| 186 | .remove = asus_hotk_remove, | ||
| 187 | }, | ||
| 188 | }; | ||
| 189 | |||
| 190 | /* The backlight device /sys/class/backlight */ | ||
| 191 | static struct backlight_device *asus_backlight_device; | ||
| 192 | |||
| 193 | /* | ||
| 194 | * The backlight class declaration | ||
| 195 | */ | ||
| 196 | static int read_brightness(struct backlight_device *bd); | ||
| 197 | static int update_bl_status(struct backlight_device *bd); | ||
| 198 | static struct backlight_properties asusbl_data = { | ||
| 199 | .owner = THIS_MODULE, | ||
| 200 | .get_brightness = read_brightness, | ||
| 201 | .update_status = update_bl_status, | ||
| 202 | .max_brightness = 15, | ||
| 203 | }; | ||
| 204 | |||
| 205 | /* These functions actually update the LED's, and are called from a | ||
| 206 | * workqueue. By doing this as separate work rather than when the LED | ||
| 207 | * subsystem asks, we avoid messing with the Asus ACPI stuff during a | ||
| 208 | * potentially bad time, such as a timer interrupt. */ | ||
| 209 | static struct workqueue_struct *led_workqueue; | ||
| 210 | |||
| 211 | #define ASUS_LED(object, ledname) \ | ||
| 212 | static void object##_led_set(struct led_classdev *led_cdev, \ | ||
| 213 | enum led_brightness value); \ | ||
| 214 | static void object##_led_update(struct work_struct *ignored); \ | ||
| 215 | static int object##_led_wk; \ | ||
| 216 | DECLARE_WORK(object##_led_work, object##_led_update); \ | ||
| 217 | static struct led_classdev object##_led = { \ | ||
| 218 | .name = "asus:" ledname, \ | ||
| 219 | .brightness_set = object##_led_set, \ | ||
| 220 | } | ||
| 221 | |||
| 222 | ASUS_LED(mled, "mail"); | ||
| 223 | ASUS_LED(tled, "touchpad"); | ||
| 224 | ASUS_LED(rled, "record"); | ||
| 225 | ASUS_LED(pled, "phone"); | ||
| 226 | |||
| 227 | /* | ||
| 228 | * This function evaluates an ACPI method, given an int as parameter, the | ||
| 229 | * method is searched within the scope of the handle, can be NULL. The output | ||
| 230 | * of the method is written is output, which can also be NULL | ||
| 231 | * | ||
| 232 | * returns 1 if write is successful, 0 else. | ||
| 233 | */ | ||
| 234 | static int write_acpi_int(acpi_handle handle, const char *method, int val, | ||
| 235 | struct acpi_buffer *output) | ||
| 236 | { | ||
| 237 | struct acpi_object_list params; //list of input parameters (an int here) | ||
| 238 | union acpi_object in_obj; //the only param we use | ||
| 239 | acpi_status status; | ||
| 240 | |||
| 241 | params.count = 1; | ||
| 242 | params.pointer = &in_obj; | ||
| 243 | in_obj.type = ACPI_TYPE_INTEGER; | ||
| 244 | in_obj.integer.value = val; | ||
| 245 | |||
| 246 | status = acpi_evaluate_object(handle, (char *)method, ¶ms, output); | ||
| 247 | return (status == AE_OK); | ||
| 248 | } | ||
| 249 | |||
| 250 | static int read_acpi_int(acpi_handle handle, const char *method, int *val, | ||
| 251 | struct acpi_object_list *params) | ||
| 252 | { | ||
| 253 | struct acpi_buffer output; | ||
| 254 | union acpi_object out_obj; | ||
| 255 | acpi_status status; | ||
| 256 | |||
| 257 | output.length = sizeof(out_obj); | ||
| 258 | output.pointer = &out_obj; | ||
| 259 | |||
| 260 | status = acpi_evaluate_object(handle, (char *)method, params, &output); | ||
| 261 | *val = out_obj.integer.value; | ||
| 262 | return (status == AE_OK) && (out_obj.type == ACPI_TYPE_INTEGER); | ||
| 263 | } | ||
| 264 | |||
| 265 | static int read_wireless_status(int mask) | ||
| 266 | { | ||
| 267 | int status; | ||
| 268 | |||
| 269 | if (!wireless_status_handle) | ||
| 270 | return (hotk->status & mask) ? 1 : 0; | ||
| 271 | |||
| 272 | if (read_acpi_int(wireless_status_handle, NULL, &status, NULL)) { | ||
| 273 | return (status & mask) ? 1 : 0; | ||
| 274 | } else | ||
| 275 | printk(ASUS_WARNING "Error reading Wireless status\n"); | ||
| 276 | |||
| 277 | return (hotk->status & mask) ? 1 : 0; | ||
| 278 | } | ||
| 279 | |||
| 280 | /* Generic LED functions */ | ||
| 281 | static int read_status(int mask) | ||
| 282 | { | ||
| 283 | /* There is a special method for both wireless devices */ | ||
| 284 | if (mask == BT_ON || mask == WL_ON) | ||
| 285 | return read_wireless_status(mask); | ||
| 286 | |||
| 287 | return (hotk->status & mask) ? 1 : 0; | ||
| 288 | } | ||
| 289 | |||
| 290 | static void write_status(acpi_handle handle, int out, int mask, int invert) | ||
| 291 | { | ||
| 292 | hotk->status = (out) ? (hotk->status | mask) : (hotk->status & ~mask); | ||
| 293 | |||
| 294 | if (invert) /* invert target value */ | ||
| 295 | out = !out & 0x1; | ||
| 296 | |||
| 297 | if (handle && !write_acpi_int(handle, NULL, out, NULL)) | ||
| 298 | printk(ASUS_WARNING " write failed\n"); | ||
| 299 | } | ||
| 300 | |||
| 301 | /* /sys/class/led handlers */ | ||
| 302 | #define ASUS_LED_HANDLER(object, mask, invert) \ | ||
| 303 | static void object##_led_set(struct led_classdev *led_cdev, \ | ||
| 304 | enum led_brightness value) \ | ||
| 305 | { \ | ||
| 306 | object##_led_wk = value; \ | ||
| 307 | queue_work(led_workqueue, &object##_led_work); \ | ||
| 308 | } \ | ||
| 309 | static void object##_led_update(struct work_struct *ignored) \ | ||
| 310 | { \ | ||
| 311 | int value = object##_led_wk; \ | ||
| 312 | write_status(object##_set_handle, value, (mask), (invert)); \ | ||
| 313 | } | ||
| 314 | |||
| 315 | ASUS_LED_HANDLER(mled, MLED_ON, 1); | ||
| 316 | ASUS_LED_HANDLER(pled, PLED_ON, 0); | ||
| 317 | ASUS_LED_HANDLER(rled, RLED_ON, 0); | ||
| 318 | ASUS_LED_HANDLER(tled, TLED_ON, 0); | ||
| 319 | |||
| 320 | static int get_lcd_state(void) | ||
| 321 | { | ||
| 322 | return read_status(LCD_ON); | ||
| 323 | } | ||
| 324 | |||
| 325 | static int set_lcd_state(int value) | ||
| 326 | { | ||
| 327 | int lcd = 0; | ||
| 328 | acpi_status status = 0; | ||
| 329 | |||
| 330 | lcd = value ? 1 : 0; | ||
| 331 | |||
| 332 | if (lcd == get_lcd_state()) | ||
| 333 | return 0; | ||
| 334 | |||
| 335 | if (lcd_switch_handle) { | ||
| 336 | status = acpi_evaluate_object(lcd_switch_handle, | ||
| 337 | NULL, NULL, NULL); | ||
| 338 | |||
| 339 | if (ACPI_FAILURE(status)) | ||
| 340 | printk(ASUS_WARNING "Error switching LCD\n"); | ||
| 341 | } | ||
| 342 | |||
| 343 | write_status(NULL, lcd, LCD_ON, 0); | ||
| 344 | return 0; | ||
| 345 | } | ||
| 346 | |||
| 347 | static void lcd_blank(int blank) | ||
| 348 | { | ||
| 349 | struct backlight_device *bd = asus_backlight_device; | ||
| 350 | |||
| 351 | if (bd) { | ||
| 352 | down(&bd->sem); | ||
| 353 | if (likely(bd->props)) { | ||
| 354 | bd->props->power = blank; | ||
| 355 | if (likely(bd->props->update_status)) | ||
| 356 | bd->props->update_status(bd); | ||
| 357 | } | ||
| 358 | up(&bd->sem); | ||
| 359 | } | ||
| 360 | } | ||
| 361 | |||
| 362 | static int read_brightness(struct backlight_device *bd) | ||
| 363 | { | ||
| 364 | int value; | ||
| 365 | |||
| 366 | if (!read_acpi_int(brightness_get_handle, NULL, &value, NULL)) | ||
| 367 | printk(ASUS_WARNING "Error reading brightness\n"); | ||
| 368 | |||
| 369 | return value; | ||
| 370 | } | ||
| 371 | |||
| 372 | static int set_brightness(struct backlight_device *bd, int value) | ||
| 373 | { | ||
| 374 | int ret = 0; | ||
| 375 | |||
| 376 | value = (0 < value) ? ((15 < value) ? 15 : value) : 0; | ||
| 377 | /* 0 <= value <= 15 */ | ||
| 378 | |||
| 379 | if (!write_acpi_int(brightness_set_handle, NULL, value, NULL)) { | ||
| 380 | printk(ASUS_WARNING "Error changing brightness\n"); | ||
| 381 | ret = -EIO; | ||
| 382 | } | ||
| 383 | |||
| 384 | return ret; | ||
| 385 | } | ||
| 386 | |||
| 387 | static int update_bl_status(struct backlight_device *bd) | ||
| 388 | { | ||
| 389 | int rv; | ||
| 390 | int value = bd->props->brightness; | ||
| 391 | |||
| 392 | rv = set_brightness(bd, value); | ||
| 393 | if (rv) | ||
| 394 | return rv; | ||
| 395 | |||
| 396 | value = (bd->props->power == FB_BLANK_UNBLANK) ? 1 : 0; | ||
| 397 | return set_lcd_state(value); | ||
| 398 | } | ||
| 399 | |||
| 400 | /* | ||
| 401 | * Platform device handlers | ||
| 402 | */ | ||
| 403 | |||
| 404 | /* | ||
| 405 | * We write our info in page, we begin at offset off and cannot write more | ||
| 406 | * than count bytes. We set eof to 1 if we handle those 2 values. We return the | ||
| 407 | * number of bytes written in page | ||
| 408 | */ | ||
| 409 | static ssize_t show_infos(struct device *dev, | ||
| 410 | struct device_attribute *attr, char *page) | ||
| 411 | { | ||
| 412 | int len = 0; | ||
| 413 | int temp; | ||
| 414 | char buf[16]; //enough for all info | ||
| 415 | /* | ||
| 416 | * We use the easy way, we don't care of off and count, so we don't set eof | ||
| 417 | * to 1 | ||
| 418 | */ | ||
| 419 | |||
| 420 | len += sprintf(page, ASUS_HOTK_NAME " " ASUS_LAPTOP_VERSION "\n"); | ||
| 421 | len += sprintf(page + len, "Model reference : %s\n", hotk->name); | ||
| 422 | /* | ||
| 423 | * The SFUN method probably allows the original driver to get the list | ||
| 424 | * of features supported by a given model. For now, 0x0100 or 0x0800 | ||
| 425 | * bit signifies that the laptop is equipped with a Wi-Fi MiniPCI card. | ||
| 426 | * The significance of others is yet to be found. | ||
| 427 | */ | ||
| 428 | if (read_acpi_int(hotk->handle, "SFUN", &temp, NULL)) | ||
| 429 | len += | ||
| 430 | sprintf(page + len, "SFUN value : 0x%04x\n", temp); | ||
| 431 | /* | ||
| 432 | * Another value for userspace: the ASYM method returns 0x02 for | ||
| 433 | * battery low and 0x04 for battery critical, its readings tend to be | ||
| 434 | * more accurate than those provided by _BST. | ||
| 435 | * Note: since not all the laptops provide this method, errors are | ||
| 436 | * silently ignored. | ||
| 437 | */ | ||
| 438 | if (read_acpi_int(hotk->handle, "ASYM", &temp, NULL)) | ||
| 439 | len += | ||
| 440 | sprintf(page + len, "ASYM value : 0x%04x\n", temp); | ||
| 441 | if (asus_info) { | ||
| 442 | snprintf(buf, 16, "%d", asus_info->length); | ||
| 443 | len += sprintf(page + len, "DSDT length : %s\n", buf); | ||
| 444 | snprintf(buf, 16, "%d", asus_info->checksum); | ||
| 445 | len += sprintf(page + len, "DSDT checksum : %s\n", buf); | ||
| 446 | snprintf(buf, 16, "%d", asus_info->revision); | ||
| 447 | len += sprintf(page + len, "DSDT revision : %s\n", buf); | ||
| 448 | snprintf(buf, 7, "%s", asus_info->oem_id); | ||
| 449 | len += sprintf(page + len, "OEM id : %s\n", buf); | ||
| 450 | snprintf(buf, 9, "%s", asus_info->oem_table_id); | ||
| 451 | len += sprintf(page + len, "OEM table id : %s\n", buf); | ||
| 452 | snprintf(buf, 16, "%x", asus_info->oem_revision); | ||
| 453 | len += sprintf(page + len, "OEM revision : 0x%s\n", buf); | ||
| 454 | snprintf(buf, 5, "%s", asus_info->asl_compiler_id); | ||
| 455 | len += sprintf(page + len, "ASL comp vendor id : %s\n", buf); | ||
| 456 | snprintf(buf, 16, "%x", asus_info->asl_compiler_revision); | ||
| 457 | len += sprintf(page + len, "ASL comp revision : 0x%s\n", buf); | ||
| 458 | } | ||
| 459 | |||
| 460 | return len; | ||
| 461 | } | ||
| 462 | |||
| 463 | static int parse_arg(const char *buf, unsigned long count, int *val) | ||
| 464 | { | ||
| 465 | if (!count) | ||
| 466 | return 0; | ||
| 467 | if (count > 31) | ||
| 468 | return -EINVAL; | ||
| 469 | if (sscanf(buf, "%i", val) != 1) | ||
| 470 | return -EINVAL; | ||
| 471 | return count; | ||
| 472 | } | ||
| 473 | |||
| 474 | static ssize_t store_status(const char *buf, size_t count, | ||
| 475 | acpi_handle handle, int mask, int invert) | ||
| 476 | { | ||
| 477 | int rv, value; | ||
| 478 | int out = 0; | ||
| 479 | |||
| 480 | rv = parse_arg(buf, count, &value); | ||
| 481 | if (rv > 0) | ||
| 482 | out = value ? 1 : 0; | ||
| 483 | |||
| 484 | write_status(handle, out, mask, invert); | ||
| 485 | |||
| 486 | return rv; | ||
| 487 | } | ||
| 488 | |||
| 489 | /* | ||
| 490 | * LEDD display | ||
| 491 | */ | ||
| 492 | static ssize_t show_ledd(struct device *dev, | ||
| 493 | struct device_attribute *attr, char *buf) | ||
| 494 | { | ||
| 495 | return sprintf(buf, "0x%08x\n", hotk->ledd_status); | ||
| 496 | } | ||
| 497 | |||
| 498 | static ssize_t store_ledd(struct device *dev, struct device_attribute *attr, | ||
| 499 | const char *buf, size_t count) | ||
| 500 | { | ||
| 501 | int rv, value; | ||
| 502 | |||
| 503 | rv = parse_arg(buf, count, &value); | ||
| 504 | if (rv > 0) { | ||
| 505 | if (!write_acpi_int(ledd_set_handle, NULL, value, NULL)) | ||
| 506 | printk(ASUS_WARNING "LED display write failed\n"); | ||
| 507 | else | ||
| 508 | hotk->ledd_status = (u32) value; | ||
| 509 | } | ||
| 510 | return rv; | ||
| 511 | } | ||
| 512 | |||
| 513 | /* | ||
| 514 | * WLAN | ||
| 515 | */ | ||
| 516 | static ssize_t show_wlan(struct device *dev, | ||
| 517 | struct device_attribute *attr, char *buf) | ||
| 518 | { | ||
| 519 | return sprintf(buf, "%d\n", read_status(WL_ON)); | ||
| 520 | } | ||
| 521 | |||
| 522 | static ssize_t store_wlan(struct device *dev, struct device_attribute *attr, | ||
| 523 | const char *buf, size_t count) | ||
| 524 | { | ||
| 525 | return store_status(buf, count, wl_switch_handle, WL_ON, 0); | ||
| 526 | } | ||
| 527 | |||
| 528 | /* | ||
| 529 | * Bluetooth | ||
| 530 | */ | ||
| 531 | static ssize_t show_bluetooth(struct device *dev, | ||
| 532 | struct device_attribute *attr, char *buf) | ||
| 533 | { | ||
| 534 | return sprintf(buf, "%d\n", read_status(BT_ON)); | ||
| 535 | } | ||
| 536 | |||
| 537 | static ssize_t store_bluetooth(struct device *dev, | ||
| 538 | struct device_attribute *attr, const char *buf, | ||
| 539 | size_t count) | ||
| 540 | { | ||
| 541 | return store_status(buf, count, bt_switch_handle, BT_ON, 0); | ||
| 542 | } | ||
| 543 | |||
| 544 | /* | ||
| 545 | * Display | ||
| 546 | */ | ||
| 547 | static void set_display(int value) | ||
| 548 | { | ||
| 549 | /* no sanity check needed for now */ | ||
| 550 | if (!write_acpi_int(display_set_handle, NULL, value, NULL)) | ||
| 551 | printk(ASUS_WARNING "Error setting display\n"); | ||
| 552 | return; | ||
| 553 | } | ||
| 554 | |||
| 555 | static int read_display(void) | ||
| 556 | { | ||
| 557 | int value = 0; | ||
| 558 | |||
| 559 | /* In most of the case, we know how to set the display, but sometime | ||
| 560 | we can't read it */ | ||
| 561 | if (display_get_handle) { | ||
| 562 | if (!read_acpi_int(display_get_handle, NULL, &value, NULL)) | ||
| 563 | printk(ASUS_WARNING "Error reading display status\n"); | ||
| 564 | } | ||
| 565 | |||
| 566 | value &= 0x0F; /* needed for some models, shouldn't hurt others */ | ||
| 567 | |||
| 568 | return value; | ||
| 569 | } | ||
| 570 | |||
| 571 | /* | ||
| 572 | * Now, *this* one could be more user-friendly, but so far, no-one has | ||
| 573 | * complained. The significance of bits is the same as in store_disp() | ||
| 574 | */ | ||
| 575 | static ssize_t show_disp(struct device *dev, | ||
| 576 | struct device_attribute *attr, char *buf) | ||
| 577 | { | ||
| 578 | return sprintf(buf, "%d\n", read_display()); | ||
| 579 | } | ||
| 580 | |||
| 581 | /* | ||
| 582 | * Experimental support for display switching. As of now: 1 should activate | ||
| 583 | * the LCD output, 2 should do for CRT, 4 for TV-Out and 8 for DVI. | ||
| 584 | * Any combination (bitwise) of these will suffice. I never actually tested 4 | ||
| 585 | * displays hooked up simultaneously, so be warned. See the acpi4asus README | ||
| 586 | * for more info. | ||
| 587 | */ | ||
| 588 | static ssize_t store_disp(struct device *dev, struct device_attribute *attr, | ||
| 589 | const char *buf, size_t count) | ||
| 590 | { | ||
| 591 | int rv, value; | ||
| 592 | |||
| 593 | rv = parse_arg(buf, count, &value); | ||
| 594 | if (rv > 0) | ||
| 595 | set_display(value); | ||
| 596 | return rv; | ||
| 597 | } | ||
| 598 | |||
| 599 | /* | ||
| 600 | * Light Sens | ||
| 601 | */ | ||
| 602 | static void set_light_sens_switch(int value) | ||
| 603 | { | ||
| 604 | if (!write_acpi_int(ls_switch_handle, NULL, value, NULL)) | ||
| 605 | printk(ASUS_WARNING "Error setting light sensor switch\n"); | ||
| 606 | hotk->light_switch = value; | ||
| 607 | } | ||
| 608 | |||
| 609 | static ssize_t show_lssw(struct device *dev, | ||
| 610 | struct device_attribute *attr, char *buf) | ||
| 611 | { | ||
| 612 | return sprintf(buf, "%d\n", hotk->light_switch); | ||
| 613 | } | ||
| 614 | |||
| 615 | static ssize_t store_lssw(struct device *dev, struct device_attribute *attr, | ||
| 616 | const char *buf, size_t count) | ||
| 617 | { | ||
| 618 | int rv, value; | ||
| 619 | |||
| 620 | rv = parse_arg(buf, count, &value); | ||
| 621 | if (rv > 0) | ||
| 622 | set_light_sens_switch(value ? 1 : 0); | ||
| 623 | |||
| 624 | return rv; | ||
| 625 | } | ||
| 626 | |||
| 627 | static void set_light_sens_level(int value) | ||
| 628 | { | ||
| 629 | if (!write_acpi_int(ls_level_handle, NULL, value, NULL)) | ||
| 630 | printk(ASUS_WARNING "Error setting light sensor level\n"); | ||
| 631 | hotk->light_level = value; | ||
| 632 | } | ||
| 633 | |||
| 634 | static ssize_t show_lslvl(struct device *dev, | ||
| 635 | struct device_attribute *attr, char *buf) | ||
| 636 | { | ||
| 637 | return sprintf(buf, "%d\n", hotk->light_level); | ||
| 638 | } | ||
| 639 | |||
| 640 | static ssize_t store_lslvl(struct device *dev, struct device_attribute *attr, | ||
| 641 | const char *buf, size_t count) | ||
| 642 | { | ||
| 643 | int rv, value; | ||
| 644 | |||
| 645 | rv = parse_arg(buf, count, &value); | ||
| 646 | if (rv > 0) { | ||
| 647 | value = (0 < value) ? ((15 < value) ? 15 : value) : 0; | ||
| 648 | /* 0 <= value <= 15 */ | ||
| 649 | set_light_sens_level(value); | ||
| 650 | } | ||
| 651 | |||
| 652 | return rv; | ||
| 653 | } | ||
| 654 | |||
| 655 | static void asus_hotk_notify(acpi_handle handle, u32 event, void *data) | ||
| 656 | { | ||
| 657 | /* TODO Find a better way to handle events count. */ | ||
| 658 | if (!hotk) | ||
| 659 | return; | ||
| 660 | |||
| 661 | /* | ||
| 662 | * We need to tell the backlight device when the backlight power is | ||
| 663 | * switched | ||
| 664 | */ | ||
| 665 | if (event == ATKD_LCD_ON) { | ||
| 666 | write_status(NULL, 1, LCD_ON, 0); | ||
| 667 | lcd_blank(FB_BLANK_UNBLANK); | ||
| 668 | } else if (event == ATKD_LCD_OFF) { | ||
| 669 | write_status(NULL, 0, LCD_ON, 0); | ||
| 670 | lcd_blank(FB_BLANK_POWERDOWN); | ||
| 671 | } | ||
| 672 | |||
| 673 | acpi_bus_generate_event(hotk->device, event, | ||
| 674 | hotk->event_count[event % 128]++); | ||
| 675 | |||
| 676 | return; | ||
| 677 | } | ||
| 678 | |||
| 679 | #define ASUS_CREATE_DEVICE_ATTR(_name) \ | ||
| 680 | struct device_attribute dev_attr_##_name = { \ | ||
| 681 | .attr = { \ | ||
| 682 | .name = __stringify(_name), \ | ||
| 683 | .mode = 0, \ | ||
| 684 | .owner = THIS_MODULE }, \ | ||
| 685 | .show = NULL, \ | ||
| 686 | .store = NULL, \ | ||
| 687 | } | ||
| 688 | |||
| 689 | #define ASUS_SET_DEVICE_ATTR(_name, _mode, _show, _store) \ | ||
| 690 | do { \ | ||
| 691 | dev_attr_##_name.attr.mode = _mode; \ | ||
| 692 | dev_attr_##_name.show = _show; \ | ||
| 693 | dev_attr_##_name.store = _store; \ | ||
| 694 | } while(0) | ||
| 695 | |||
| 696 | static ASUS_CREATE_DEVICE_ATTR(infos); | ||
| 697 | static ASUS_CREATE_DEVICE_ATTR(wlan); | ||
| 698 | static ASUS_CREATE_DEVICE_ATTR(bluetooth); | ||
| 699 | static ASUS_CREATE_DEVICE_ATTR(display); | ||
| 700 | static ASUS_CREATE_DEVICE_ATTR(ledd); | ||
| 701 | static ASUS_CREATE_DEVICE_ATTR(ls_switch); | ||
| 702 | static ASUS_CREATE_DEVICE_ATTR(ls_level); | ||
| 703 | |||
| 704 | static struct attribute *asuspf_attributes[] = { | ||
| 705 | &dev_attr_infos.attr, | ||
| 706 | &dev_attr_wlan.attr, | ||
| 707 | &dev_attr_bluetooth.attr, | ||
| 708 | &dev_attr_display.attr, | ||
| 709 | &dev_attr_ledd.attr, | ||
| 710 | &dev_attr_ls_switch.attr, | ||
| 711 | &dev_attr_ls_level.attr, | ||
| 712 | NULL | ||
| 713 | }; | ||
| 714 | |||
| 715 | static struct attribute_group asuspf_attribute_group = { | ||
| 716 | .attrs = asuspf_attributes | ||
| 717 | }; | ||
| 718 | |||
| 719 | static struct platform_driver asuspf_driver = { | ||
| 720 | .driver = { | ||
| 721 | .name = ASUS_HOTK_FILE, | ||
| 722 | .owner = THIS_MODULE, | ||
| 723 | } | ||
| 724 | }; | ||
| 725 | |||
| 726 | static struct platform_device *asuspf_device; | ||
| 727 | |||
| 728 | static void asus_hotk_add_fs(void) | ||
| 729 | { | ||
| 730 | ASUS_SET_DEVICE_ATTR(infos, 0444, show_infos, NULL); | ||
| 731 | |||
| 732 | if (wl_switch_handle) | ||
| 733 | ASUS_SET_DEVICE_ATTR(wlan, 0644, show_wlan, store_wlan); | ||
| 734 | |||
| 735 | if (bt_switch_handle) | ||
| 736 | ASUS_SET_DEVICE_ATTR(bluetooth, 0644, | ||
| 737 | show_bluetooth, store_bluetooth); | ||
| 738 | |||
| 739 | if (display_set_handle && display_get_handle) | ||
| 740 | ASUS_SET_DEVICE_ATTR(display, 0644, show_disp, store_disp); | ||
| 741 | else if (display_set_handle) | ||
| 742 | ASUS_SET_DEVICE_ATTR(display, 0200, NULL, store_disp); | ||
| 743 | |||
| 744 | if (ledd_set_handle) | ||
| 745 | ASUS_SET_DEVICE_ATTR(ledd, 0644, show_ledd, store_ledd); | ||
| 746 | |||
| 747 | if (ls_switch_handle && ls_level_handle) { | ||
| 748 | ASUS_SET_DEVICE_ATTR(ls_level, 0644, show_lslvl, store_lslvl); | ||
| 749 | ASUS_SET_DEVICE_ATTR(ls_switch, 0644, show_lssw, store_lssw); | ||
| 750 | } | ||
| 751 | } | ||
| 752 | |||
| 753 | static int asus_handle_init(char *name, acpi_handle * handle, | ||
| 754 | char **paths, int num_paths) | ||
| 755 | { | ||
| 756 | int i; | ||
| 757 | acpi_status status; | ||
| 758 | |||
| 759 | for (i = 0; i < num_paths; i++) { | ||
| 760 | status = acpi_get_handle(NULL, paths[i], handle); | ||
| 761 | if (ACPI_SUCCESS(status)) | ||
| 762 | return 0; | ||
| 763 | } | ||
| 764 | |||
| 765 | *handle = NULL; | ||
| 766 | return -ENODEV; | ||
| 767 | } | ||
| 768 | |||
| 769 | #define ASUS_HANDLE_INIT(object) \ | ||
| 770 | asus_handle_init(#object, &object##_handle, object##_paths, \ | ||
| 771 | ARRAY_SIZE(object##_paths)) | ||
| 772 | |||
| 773 | /* | ||
| 774 | * This function is used to initialize the hotk with right values. In this | ||
| 775 | * method, we can make all the detection we want, and modify the hotk struct | ||
| 776 | */ | ||
| 777 | static int asus_hotk_get_info(void) | ||
| 778 | { | ||
| 779 | struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; | ||
| 780 | union acpi_object *model = NULL; | ||
| 781 | int bsts_result, hwrs_result; | ||
| 782 | char *string = NULL; | ||
| 783 | acpi_status status; | ||
| 784 | |||
| 785 | /* | ||
| 786 | * Get DSDT headers early enough to allow for differentiating between | ||
| 787 | * models, but late enough to allow acpi_bus_register_driver() to fail | ||
| 788 | * before doing anything ACPI-specific. Should we encounter a machine, | ||
| 789 | * which needs special handling (i.e. its hotkey device has a different | ||
| 790 | * HID), this bit will be moved. A global variable asus_info contains | ||
| 791 | * the DSDT header. | ||
| 792 | */ | ||
| 793 | status = acpi_get_table(ACPI_SIG_DSDT, 1, &asus_info); | ||
| 794 | if (ACPI_FAILURE(status)) | ||
| 795 | printk(ASUS_WARNING "Couldn't get the DSDT table header\n"); | ||
| 796 | |||
| 797 | /* We have to write 0 on init this far for all ASUS models */ | ||
| 798 | if (!write_acpi_int(hotk->handle, "INIT", 0, &buffer)) { | ||
| 799 | printk(ASUS_ERR "Hotkey initialization failed\n"); | ||
| 800 | return -ENODEV; | ||
| 801 | } | ||
| 802 | |||
| 803 | /* This needs to be called for some laptops to init properly */ | ||
| 804 | if (!read_acpi_int(hotk->handle, "BSTS", &bsts_result, NULL)) | ||
| 805 | printk(ASUS_WARNING "Error calling BSTS\n"); | ||
| 806 | else if (bsts_result) | ||
| 807 | printk(ASUS_NOTICE "BSTS called, 0x%02x returned\n", | ||
| 808 | bsts_result); | ||
| 809 | |||
| 810 | /* | ||
| 811 | * Try to match the object returned by INIT to the specific model. | ||
| 812 | * Handle every possible object (or the lack of thereof) the DSDT | ||
| 813 | * writers might throw at us. When in trouble, we pass NULL to | ||
| 814 | * asus_model_match() and try something completely different. | ||
| 815 | */ | ||
| 816 | if (buffer.pointer) { | ||
| 817 | model = buffer.pointer; | ||
| 818 | switch (model->type) { | ||
| 819 | case ACPI_TYPE_STRING: | ||
| 820 | string = model->string.pointer; | ||
| 821 | break; | ||
| 822 | case ACPI_TYPE_BUFFER: | ||
| 823 | string = model->buffer.pointer; | ||
| 824 | break; | ||
| 825 | default: | ||
| 826 | string = ""; | ||
| 827 | break; | ||
| 828 | } | ||
| 829 | } | ||
| 830 | hotk->name = kstrdup(string, GFP_KERNEL); | ||
| 831 | if (!hotk->name) | ||
| 832 | return -ENOMEM; | ||
| 833 | |||
| 834 | if (*string) | ||
| 835 | printk(ASUS_NOTICE " %s model detected\n", string); | ||
| 836 | |||
| 837 | ASUS_HANDLE_INIT(mled_set); | ||
| 838 | ASUS_HANDLE_INIT(tled_set); | ||
| 839 | ASUS_HANDLE_INIT(rled_set); | ||
| 840 | ASUS_HANDLE_INIT(pled_set); | ||
| 841 | |||
| 842 | ASUS_HANDLE_INIT(ledd_set); | ||
| 843 | |||
| 844 | /* | ||
| 845 | * The HWRS method return informations about the hardware. | ||
| 846 | * 0x80 bit is for WLAN, 0x100 for Bluetooth. | ||
| 847 | * The significance of others is yet to be found. | ||
| 848 | * If we don't find the method, we assume the device are present. | ||
| 849 | */ | ||
| 850 | if (!read_acpi_int(hotk->handle, "HRWS", &hwrs_result, NULL)) | ||
| 851 | hwrs_result = WL_HWRS | BT_HWRS; | ||
| 852 | |||
| 853 | if (hwrs_result & WL_HWRS) | ||
| 854 | ASUS_HANDLE_INIT(wl_switch); | ||
| 855 | if (hwrs_result & BT_HWRS) | ||
| 856 | ASUS_HANDLE_INIT(bt_switch); | ||
| 857 | |||
| 858 | ASUS_HANDLE_INIT(wireless_status); | ||
| 859 | |||
| 860 | ASUS_HANDLE_INIT(brightness_set); | ||
| 861 | ASUS_HANDLE_INIT(brightness_get); | ||
| 862 | |||
| 863 | ASUS_HANDLE_INIT(lcd_switch); | ||
| 864 | |||
| 865 | ASUS_HANDLE_INIT(display_set); | ||
| 866 | ASUS_HANDLE_INIT(display_get); | ||
| 867 | |||
| 868 | /* There is a lot of models with "ALSL", but a few get | ||
| 869 | a real light sens, so we need to check it. */ | ||
| 870 | if (ASUS_HANDLE_INIT(ls_switch)) | ||
| 871 | ASUS_HANDLE_INIT(ls_level); | ||
| 872 | |||
| 873 | kfree(model); | ||
| 874 | |||
| 875 | return AE_OK; | ||
| 876 | } | ||
| 877 | |||
| 878 | static int asus_hotk_check(void) | ||
| 879 | { | ||
| 880 | int result = 0; | ||
| 881 | |||
| 882 | result = acpi_bus_get_status(hotk->device); | ||
| 883 | if (result) | ||
| 884 | return result; | ||
| 885 | |||
| 886 | if (hotk->device->status.present) { | ||
| 887 | result = asus_hotk_get_info(); | ||
| 888 | } else { | ||
| 889 | printk(ASUS_ERR "Hotkey device not present, aborting\n"); | ||
| 890 | return -EINVAL; | ||
| 891 | } | ||
| 892 | |||
| 893 | return result; | ||
| 894 | } | ||
| 895 | |||
| 896 | static int asus_hotk_found; | ||
| 897 | |||
| 898 | static int asus_hotk_add(struct acpi_device *device) | ||
| 899 | { | ||
| 900 | acpi_status status = AE_OK; | ||
| 901 | int result; | ||
| 902 | |||
| 903 | if (!device) | ||
| 904 | return -EINVAL; | ||
| 905 | |||
| 906 | printk(ASUS_NOTICE "Asus Laptop Support version %s\n", | ||
| 907 | ASUS_LAPTOP_VERSION); | ||
| 908 | |||
| 909 | hotk = kmalloc(sizeof(struct asus_hotk), GFP_KERNEL); | ||
| 910 | if (!hotk) | ||
| 911 | return -ENOMEM; | ||
| 912 | memset(hotk, 0, sizeof(struct asus_hotk)); | ||
| 913 | |||
| 914 | hotk->handle = device->handle; | ||
| 915 | strcpy(acpi_device_name(device), ASUS_HOTK_DEVICE_NAME); | ||
| 916 | strcpy(acpi_device_class(device), ASUS_HOTK_CLASS); | ||
| 917 | acpi_driver_data(device) = hotk; | ||
| 918 | hotk->device = device; | ||
| 919 | |||
| 920 | result = asus_hotk_check(); | ||
| 921 | if (result) | ||
| 922 | goto end; | ||
| 923 | |||
| 924 | asus_hotk_add_fs(); | ||
| 925 | |||
| 926 | /* | ||
| 927 | * We install the handler, it will receive the hotk in parameter, so, we | ||
| 928 | * could add other data to the hotk struct | ||
| 929 | */ | ||
| 930 | status = acpi_install_notify_handler(hotk->handle, ACPI_SYSTEM_NOTIFY, | ||
| 931 | asus_hotk_notify, hotk); | ||
| 932 | if (ACPI_FAILURE(status)) | ||
| 933 | printk(ASUS_ERR "Error installing notify handler\n"); | ||
| 934 | |||
| 935 | asus_hotk_found = 1; | ||
| 936 | |||
| 937 | /* WLED and BLED are on by default */ | ||
| 938 | write_status(bt_switch_handle, 1, BT_ON, 0); | ||
| 939 | write_status(wl_switch_handle, 1, WL_ON, 0); | ||
| 940 | |||
| 941 | /* LCD Backlight is on by default */ | ||
| 942 | write_status(NULL, 1, LCD_ON, 0); | ||
| 943 | |||
| 944 | /* LED display is off by default */ | ||
| 945 | hotk->ledd_status = 0xFFF; | ||
| 946 | |||
| 947 | /* Set initial values of light sensor and level */ | ||
| 948 | hotk->light_switch = 1; /* Default to light sensor disabled */ | ||
| 949 | hotk->light_level = 0; /* level 5 for sensor sensitivity */ | ||
| 950 | |||
| 951 | if (ls_switch_handle) | ||
| 952 | set_light_sens_switch(hotk->light_switch); | ||
| 953 | |||
| 954 | if (ls_level_handle) | ||
| 955 | set_light_sens_level(hotk->light_level); | ||
| 956 | |||
| 957 | end: | ||
| 958 | if (result) { | ||
| 959 | kfree(hotk->name); | ||
| 960 | kfree(hotk); | ||
| 961 | } | ||
| 962 | |||
| 963 | return result; | ||
| 964 | } | ||
| 965 | |||
| 966 | static int asus_hotk_remove(struct acpi_device *device, int type) | ||
| 967 | { | ||
| 968 | acpi_status status = 0; | ||
| 969 | |||
| 970 | if (!device || !acpi_driver_data(device)) | ||
| 971 | return -EINVAL; | ||
| 972 | |||
| 973 | status = acpi_remove_notify_handler(hotk->handle, ACPI_SYSTEM_NOTIFY, | ||
| 974 | asus_hotk_notify); | ||
| 975 | if (ACPI_FAILURE(status)) | ||
| 976 | printk(ASUS_ERR "Error removing notify handler\n"); | ||
| 977 | |||
| 978 | kfree(hotk->name); | ||
| 979 | kfree(hotk); | ||
| 980 | |||
| 981 | return 0; | ||
| 982 | } | ||
| 983 | |||
| 984 | static void asus_backlight_exit(void) | ||
| 985 | { | ||
| 986 | if (asus_backlight_device) | ||
| 987 | backlight_device_unregister(asus_backlight_device); | ||
| 988 | } | ||
| 989 | |||
| 990 | #define ASUS_LED_UNREGISTER(object) \ | ||
| 991 | if(object##_led.class_dev \ | ||
| 992 | && !IS_ERR(object##_led.class_dev)) \ | ||
| 993 | led_classdev_unregister(&object##_led) | ||
| 994 | |||
| 995 | static void asus_led_exit(void) | ||
| 996 | { | ||
| 997 | ASUS_LED_UNREGISTER(mled); | ||
| 998 | ASUS_LED_UNREGISTER(tled); | ||
| 999 | ASUS_LED_UNREGISTER(pled); | ||
| 1000 | ASUS_LED_UNREGISTER(rled); | ||
| 1001 | |||
| 1002 | destroy_workqueue(led_workqueue); | ||
| 1003 | } | ||
| 1004 | |||
| 1005 | static void __exit asus_laptop_exit(void) | ||
| 1006 | { | ||
| 1007 | asus_backlight_exit(); | ||
| 1008 | asus_led_exit(); | ||
| 1009 | |||
| 1010 | acpi_bus_unregister_driver(&asus_hotk_driver); | ||
| 1011 | sysfs_remove_group(&asuspf_device->dev.kobj, &asuspf_attribute_group); | ||
| 1012 | platform_device_unregister(asuspf_device); | ||
| 1013 | platform_driver_unregister(&asuspf_driver); | ||
| 1014 | } | ||
| 1015 | |||
| 1016 | static int asus_backlight_init(struct device *dev) | ||
| 1017 | { | ||
| 1018 | struct backlight_device *bd; | ||
| 1019 | |||
| 1020 | if (brightness_set_handle && lcd_switch_handle) { | ||
| 1021 | bd = backlight_device_register(ASUS_HOTK_FILE, dev, | ||
| 1022 | NULL, &asusbl_data); | ||
| 1023 | if (IS_ERR(bd)) { | ||
| 1024 | printk(ASUS_ERR | ||
| 1025 | "Could not register asus backlight device\n"); | ||
| 1026 | asus_backlight_device = NULL; | ||
| 1027 | return PTR_ERR(bd); | ||
| 1028 | } | ||
| 1029 | |||
| 1030 | asus_backlight_device = bd; | ||
| 1031 | |||
| 1032 | down(&bd->sem); | ||
| 1033 | if (likely(bd->props)) { | ||
| 1034 | bd->props->brightness = read_brightness(NULL); | ||
| 1035 | bd->props->power = FB_BLANK_UNBLANK; | ||
| 1036 | if (likely(bd->props->update_status)) | ||
| 1037 | bd->props->update_status(bd); | ||
| 1038 | } | ||
| 1039 | up(&bd->sem); | ||
| 1040 | } | ||
| 1041 | return 0; | ||
| 1042 | } | ||
| 1043 | |||
| 1044 | static int asus_led_register(acpi_handle handle, | ||
| 1045 | struct led_classdev *ldev, struct device *dev) | ||
| 1046 | { | ||
| 1047 | if (!handle) | ||
| 1048 | return 0; | ||
| 1049 | |||
| 1050 | return led_classdev_register(dev, ldev); | ||
| 1051 | } | ||
| 1052 | |||
| 1053 | #define ASUS_LED_REGISTER(object, device) \ | ||
| 1054 | asus_led_register(object##_set_handle, &object##_led, device) | ||
| 1055 | |||
| 1056 | static int asus_led_init(struct device *dev) | ||
| 1057 | { | ||
| 1058 | int rv; | ||
| 1059 | |||
| 1060 | rv = ASUS_LED_REGISTER(mled, dev); | ||
| 1061 | if (rv) | ||
| 1062 | return rv; | ||
| 1063 | |||
| 1064 | rv = ASUS_LED_REGISTER(tled, dev); | ||
| 1065 | if (rv) | ||
| 1066 | return rv; | ||
| 1067 | |||
| 1068 | rv = ASUS_LED_REGISTER(rled, dev); | ||
| 1069 | if (rv) | ||
| 1070 | return rv; | ||
| 1071 | |||
| 1072 | rv = ASUS_LED_REGISTER(pled, dev); | ||
| 1073 | if (rv) | ||
| 1074 | return rv; | ||
| 1075 | |||
| 1076 | led_workqueue = create_singlethread_workqueue("led_workqueue"); | ||
| 1077 | if (!led_workqueue) | ||
| 1078 | return -ENOMEM; | ||
| 1079 | |||
| 1080 | return 0; | ||
| 1081 | } | ||
| 1082 | |||
| 1083 | static int __init asus_laptop_init(void) | ||
| 1084 | { | ||
| 1085 | struct device *dev; | ||
| 1086 | int result; | ||
| 1087 | |||
| 1088 | if (acpi_disabled) | ||
| 1089 | return -ENODEV; | ||
| 1090 | |||
| 1091 | if (!acpi_specific_hotkey_enabled) { | ||
| 1092 | printk(ASUS_ERR "Using generic hotkey driver\n"); | ||
| 1093 | return -ENODEV; | ||
| 1094 | } | ||
| 1095 | |||
| 1096 | result = acpi_bus_register_driver(&asus_hotk_driver); | ||
| 1097 | if (result < 0) | ||
| 1098 | return result; | ||
| 1099 | |||
| 1100 | /* | ||
| 1101 | * This is a bit of a kludge. We only want this module loaded | ||
| 1102 | * for ASUS systems, but there's currently no way to probe the | ||
| 1103 | * ACPI namespace for ASUS HIDs. So we just return failure if | ||
| 1104 | * we didn't find one, which will cause the module to be | ||
| 1105 | * unloaded. | ||
| 1106 | */ | ||
| 1107 | if (!asus_hotk_found) { | ||
| 1108 | acpi_bus_unregister_driver(&asus_hotk_driver); | ||
| 1109 | return -ENODEV; | ||
| 1110 | } | ||
| 1111 | |||
| 1112 | dev = acpi_get_physical_device(hotk->device->handle); | ||
| 1113 | |||
| 1114 | result = asus_backlight_init(dev); | ||
| 1115 | if (result) | ||
| 1116 | goto fail_backlight; | ||
| 1117 | |||
| 1118 | result = asus_led_init(dev); | ||
| 1119 | if (result) | ||
| 1120 | goto fail_led; | ||
| 1121 | |||
| 1122 | /* Register platform stuff */ | ||
| 1123 | result = platform_driver_register(&asuspf_driver); | ||
| 1124 | if (result) | ||
| 1125 | goto fail_platform_driver; | ||
| 1126 | |||
| 1127 | asuspf_device = platform_device_alloc(ASUS_HOTK_FILE, -1); | ||
| 1128 | if (!asuspf_device) { | ||
| 1129 | result = -ENOMEM; | ||
| 1130 | goto fail_platform_device1; | ||
| 1131 | } | ||
| 1132 | |||
| 1133 | result = platform_device_add(asuspf_device); | ||
| 1134 | if (result) | ||
| 1135 | goto fail_platform_device2; | ||
| 1136 | |||
| 1137 | result = sysfs_create_group(&asuspf_device->dev.kobj, | ||
| 1138 | &asuspf_attribute_group); | ||
| 1139 | if (result) | ||
| 1140 | goto fail_sysfs; | ||
| 1141 | |||
| 1142 | return 0; | ||
| 1143 | |||
| 1144 | fail_sysfs: | ||
| 1145 | platform_device_del(asuspf_device); | ||
| 1146 | |||
| 1147 | fail_platform_device2: | ||
| 1148 | platform_device_put(asuspf_device); | ||
| 1149 | |||
| 1150 | fail_platform_device1: | ||
| 1151 | platform_driver_unregister(&asuspf_driver); | ||
| 1152 | |||
| 1153 | fail_platform_driver: | ||
| 1154 | asus_led_exit(); | ||
| 1155 | |||
| 1156 | fail_led: | ||
| 1157 | asus_backlight_exit(); | ||
| 1158 | |||
| 1159 | fail_backlight: | ||
| 1160 | |||
| 1161 | return result; | ||
| 1162 | } | ||
| 1163 | |||
| 1164 | module_init(asus_laptop_init); | ||
| 1165 | module_exit(asus_laptop_exit); | ||
diff --git a/drivers/pnp/pnpacpi/Kconfig b/drivers/pnp/pnpacpi/Kconfig index b1854171b963..ad27e5e0101f 100644 --- a/drivers/pnp/pnpacpi/Kconfig +++ b/drivers/pnp/pnpacpi/Kconfig | |||
| @@ -2,8 +2,8 @@ | |||
| 2 | # Plug and Play ACPI configuration | 2 | # Plug and Play ACPI configuration |
| 3 | # | 3 | # |
| 4 | config PNPACPI | 4 | config PNPACPI |
| 5 | bool "Plug and Play ACPI support (EXPERIMENTAL)" | 5 | bool "Plug and Play ACPI support" |
| 6 | depends on PNP && ACPI && EXPERIMENTAL | 6 | depends on PNP && ACPI |
| 7 | default y | 7 | default y |
| 8 | ---help--- | 8 | ---help--- |
| 9 | Linux uses the PNPACPI to autodetect built-in | 9 | Linux uses the PNPACPI to autodetect built-in |
diff --git a/drivers/pnp/system.c b/drivers/pnp/system.c index d42015c382af..2065e74bb63f 100644 --- a/drivers/pnp/system.c +++ b/drivers/pnp/system.c | |||
| @@ -3,7 +3,8 @@ | |||
| 3 | * | 3 | * |
| 4 | * Some code is based on pnpbios_core.c | 4 | * Some code is based on pnpbios_core.c |
| 5 | * Copyright 2002 Adam Belay <ambx1@neo.rr.com> | 5 | * Copyright 2002 Adam Belay <ambx1@neo.rr.com> |
| 6 | * | 6 | * (c) Copyright 2007 Hewlett-Packard Development Company, L.P. |
| 7 | * Bjorn Helgaas <bjorn.helgaas@hp.com> | ||
| 7 | */ | 8 | */ |
| 8 | 9 | ||
| 9 | #include <linux/pnp.h> | 10 | #include <linux/pnp.h> |
| @@ -21,18 +22,21 @@ static const struct pnp_device_id pnp_dev_table[] = { | |||
| 21 | { "", 0 } | 22 | { "", 0 } |
| 22 | }; | 23 | }; |
| 23 | 24 | ||
| 24 | static void reserve_ioport_range(char *pnpid, int start, int end) | 25 | static void reserve_range(char *pnpid, int start, int end, int port) |
| 25 | { | 26 | { |
| 26 | struct resource *res; | 27 | struct resource *res; |
| 27 | char *regionid; | 28 | char *regionid; |
| 28 | 29 | ||
| 29 | regionid = kmalloc(16, GFP_KERNEL); | 30 | regionid = kmalloc(16, GFP_KERNEL); |
| 30 | if ( regionid == NULL ) | 31 | if (regionid == NULL) |
| 31 | return; | 32 | return; |
| 32 | snprintf(regionid, 16, "pnp %s", pnpid); | 33 | snprintf(regionid, 16, "pnp %s", pnpid); |
| 33 | res = request_region(start,end-start+1,regionid); | 34 | if (port) |
| 34 | if ( res == NULL ) | 35 | res = request_region(start,end-start+1,regionid); |
| 35 | kfree( regionid ); | 36 | else |
| 37 | res = request_mem_region(start,end-start+1,regionid); | ||
| 38 | if (res == NULL) | ||
| 39 | kfree(regionid); | ||
| 36 | else | 40 | else |
| 37 | res->flags &= ~IORESOURCE_BUSY; | 41 | res->flags &= ~IORESOURCE_BUSY; |
| 38 | /* | 42 | /* |
| @@ -41,26 +45,20 @@ static void reserve_ioport_range(char *pnpid, int start, int end) | |||
| 41 | * have double reservations. | 45 | * have double reservations. |
| 42 | */ | 46 | */ |
| 43 | printk(KERN_INFO | 47 | printk(KERN_INFO |
| 44 | "pnp: %s: ioport range 0x%x-0x%x %s reserved\n", | 48 | "pnp: %s: %s range 0x%x-0x%x %s reserved\n", |
| 45 | pnpid, start, end, | 49 | pnpid, port ? "ioport" : "iomem", start, end, |
| 46 | NULL != res ? "has been" : "could not be" | 50 | NULL != res ? "has been" : "could not be"); |
| 47 | ); | ||
| 48 | |||
| 49 | return; | ||
| 50 | } | 51 | } |
| 51 | 52 | ||
| 52 | static void reserve_resources_of_dev( struct pnp_dev *dev ) | 53 | static void reserve_resources_of_dev(struct pnp_dev *dev) |
| 53 | { | 54 | { |
| 54 | int i; | 55 | int i; |
| 55 | 56 | ||
| 56 | for (i=0;i<PNP_MAX_PORT;i++) { | 57 | for (i = 0; i < PNP_MAX_PORT; i++) { |
| 57 | if (!pnp_port_valid(dev, i)) | 58 | if (!pnp_port_valid(dev, i)) |
| 58 | /* end of resources */ | ||
| 59 | continue; | 59 | continue; |
| 60 | if (pnp_port_start(dev, i) == 0) | 60 | if (pnp_port_start(dev, i) == 0) |
| 61 | /* disabled */ | 61 | continue; /* disabled */ |
| 62 | /* Do nothing */ | ||
| 63 | continue; | ||
| 64 | if (pnp_port_start(dev, i) < 0x100) | 62 | if (pnp_port_start(dev, i) < 0x100) |
| 65 | /* | 63 | /* |
| 66 | * Below 0x100 is only standard PC hardware | 64 | * Below 0x100 is only standard PC hardware |
| @@ -72,14 +70,18 @@ static void reserve_resources_of_dev( struct pnp_dev *dev ) | |||
| 72 | */ | 70 | */ |
| 73 | continue; | 71 | continue; |
| 74 | if (pnp_port_end(dev, i) < pnp_port_start(dev, i)) | 72 | if (pnp_port_end(dev, i) < pnp_port_start(dev, i)) |
| 75 | /* invalid endpoint */ | 73 | continue; /* invalid */ |
| 76 | /* Do nothing */ | 74 | |
| 75 | reserve_range(dev->dev.bus_id, pnp_port_start(dev, i), | ||
| 76 | pnp_port_end(dev, i), 1); | ||
| 77 | } | ||
| 78 | |||
| 79 | for (i = 0; i < PNP_MAX_MEM; i++) { | ||
| 80 | if (!pnp_mem_valid(dev, i)) | ||
| 77 | continue; | 81 | continue; |
| 78 | reserve_ioport_range( | 82 | |
| 79 | dev->dev.bus_id, | 83 | reserve_range(dev->dev.bus_id, pnp_mem_start(dev, i), |
| 80 | pnp_port_start(dev, i), | 84 | pnp_mem_end(dev, i), 0); |
| 81 | pnp_port_end(dev, i) | ||
| 82 | ); | ||
| 83 | } | 85 | } |
| 84 | 86 | ||
| 85 | return; | 87 | return; |
diff --git a/drivers/video/output.c b/drivers/video/output.c new file mode 100644 index 000000000000..1473f2c892d2 --- /dev/null +++ b/drivers/video/output.c | |||
| @@ -0,0 +1,129 @@ | |||
| 1 | /* | ||
| 2 | * output.c - Display Output Switch driver | ||
| 3 | * | ||
| 4 | * Copyright (C) 2006 Luming Yu <luming.yu@intel.com> | ||
| 5 | * | ||
| 6 | * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
| 7 | * | ||
| 8 | * This program is free software; you can redistribute it and/or modify | ||
| 9 | * it under the terms of the GNU General Public License as published by | ||
| 10 | * the Free Software Foundation; either version 2 of the License, or (at | ||
| 11 | * your option) any later version. | ||
| 12 | * | ||
| 13 | * This program is distributed in the hope that it will be useful, but | ||
| 14 | * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
| 16 | * General Public License for more details. | ||
| 17 | * | ||
| 18 | * You should have received a copy of the GNU General Public License along | ||
| 19 | * with this program; if not, write to the Free Software Foundation, Inc., | ||
| 20 | * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. | ||
| 21 | * | ||
| 22 | * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
| 23 | */ | ||
| 24 | #include <linux/module.h> | ||
| 25 | #include <linux/video_output.h> | ||
| 26 | #include <linux/err.h> | ||
| 27 | #include <linux/ctype.h> | ||
| 28 | |||
| 29 | |||
| 30 | MODULE_DESCRIPTION("Display Output Switcher Lowlevel Control Abstraction"); | ||
| 31 | MODULE_LICENSE("GPL"); | ||
| 32 | MODULE_AUTHOR("Luming Yu <luming.yu@intel.com>"); | ||
| 33 | |||
| 34 | static ssize_t video_output_show_state(struct class_device *dev,char *buf) | ||
| 35 | { | ||
| 36 | ssize_t ret_size = 0; | ||
| 37 | struct output_device *od = to_output_device(dev); | ||
| 38 | if (od->props) | ||
| 39 | ret_size = sprintf(buf,"%.8x\n",od->props->get_status(od)); | ||
| 40 | return ret_size; | ||
| 41 | } | ||
| 42 | |||
| 43 | static ssize_t video_output_store_state(struct class_device *dev, | ||
| 44 | const char *buf,size_t count) | ||
| 45 | { | ||
| 46 | char *endp; | ||
| 47 | struct output_device *od = to_output_device(dev); | ||
| 48 | int request_state = simple_strtoul(buf,&endp,0); | ||
| 49 | size_t size = endp - buf; | ||
| 50 | |||
| 51 | if (*endp && isspace(*endp)) | ||
| 52 | size++; | ||
| 53 | if (size != count) | ||
| 54 | return -EINVAL; | ||
| 55 | |||
| 56 | if (od->props) { | ||
| 57 | od->request_state = request_state; | ||
| 58 | od->props->set_state(od); | ||
| 59 | } | ||
| 60 | return count; | ||
| 61 | } | ||
| 62 | |||
| 63 | static void video_output_class_release(struct class_device *dev) | ||
| 64 | { | ||
| 65 | struct output_device *od = to_output_device(dev); | ||
| 66 | kfree(od); | ||
| 67 | } | ||
| 68 | |||
| 69 | static struct class_device_attribute video_output_attributes[] = { | ||
| 70 | __ATTR(state, 0644, video_output_show_state, video_output_store_state), | ||
| 71 | __ATTR_NULL, | ||
| 72 | }; | ||
| 73 | |||
| 74 | static struct class video_output_class = { | ||
| 75 | .name = "video_output", | ||
| 76 | .release = video_output_class_release, | ||
| 77 | .class_dev_attrs = video_output_attributes, | ||
| 78 | }; | ||
| 79 | |||
| 80 | struct output_device *video_output_register(const char *name, | ||
| 81 | struct device *dev, | ||
| 82 | void *devdata, | ||
| 83 | struct output_properties *op) | ||
| 84 | { | ||
| 85 | struct output_device *new_dev; | ||
| 86 | int ret_code = 0; | ||
| 87 | |||
| 88 | new_dev = kzalloc(sizeof(struct output_device),GFP_KERNEL); | ||
| 89 | if (!new_dev) { | ||
| 90 | ret_code = -ENOMEM; | ||
| 91 | goto error_return; | ||
| 92 | } | ||
| 93 | new_dev->props = op; | ||
| 94 | new_dev->class_dev.class = &video_output_class; | ||
| 95 | new_dev->class_dev.dev = dev; | ||
| 96 | strlcpy(new_dev->class_dev.class_id,name,KOBJ_NAME_LEN); | ||
| 97 | class_set_devdata(&new_dev->class_dev,devdata); | ||
| 98 | ret_code = class_device_register(&new_dev->class_dev); | ||
| 99 | if (ret_code) { | ||
| 100 | kfree(new_dev); | ||
| 101 | goto error_return; | ||
| 102 | } | ||
| 103 | return new_dev; | ||
| 104 | |||
| 105 | error_return: | ||
| 106 | return ERR_PTR(ret_code); | ||
| 107 | } | ||
| 108 | EXPORT_SYMBOL(video_output_register); | ||
| 109 | |||
| 110 | void video_output_unregister(struct output_device *dev) | ||
| 111 | { | ||
| 112 | if (!dev) | ||
| 113 | return; | ||
| 114 | class_device_unregister(&dev->class_dev); | ||
| 115 | } | ||
| 116 | EXPORT_SYMBOL(video_output_unregister); | ||
| 117 | |||
| 118 | static void __exit video_output_class_exit(void) | ||
| 119 | { | ||
| 120 | class_unregister(&video_output_class); | ||
| 121 | } | ||
| 122 | |||
| 123 | static int __init video_output_class_init(void) | ||
| 124 | { | ||
| 125 | return class_register(&video_output_class); | ||
| 126 | } | ||
| 127 | |||
| 128 | postcore_initcall(video_output_class_init); | ||
| 129 | module_exit(video_output_class_exit); | ||
diff --git a/include/acpi/acpi_bus.h b/include/acpi/acpi_bus.h index aef0e55253a9..0d9f984a60a1 100644 --- a/include/acpi/acpi_bus.h +++ b/include/acpi/acpi_bus.h | |||
| @@ -91,13 +91,12 @@ typedef int (*acpi_op_remove) (struct acpi_device * device, int type); | |||
| 91 | typedef int (*acpi_op_lock) (struct acpi_device * device, int type); | 91 | typedef int (*acpi_op_lock) (struct acpi_device * device, int type); |
| 92 | typedef int (*acpi_op_start) (struct acpi_device * device); | 92 | typedef int (*acpi_op_start) (struct acpi_device * device); |
| 93 | typedef int (*acpi_op_stop) (struct acpi_device * device, int type); | 93 | typedef int (*acpi_op_stop) (struct acpi_device * device, int type); |
| 94 | typedef int (*acpi_op_suspend) (struct acpi_device * device, int state); | 94 | typedef int (*acpi_op_suspend) (struct acpi_device * device, pm_message_t state); |
| 95 | typedef int (*acpi_op_resume) (struct acpi_device * device, int state); | 95 | typedef int (*acpi_op_resume) (struct acpi_device * device); |
| 96 | typedef int (*acpi_op_scan) (struct acpi_device * device); | 96 | typedef int (*acpi_op_scan) (struct acpi_device * device); |
| 97 | typedef int (*acpi_op_bind) (struct acpi_device * device); | 97 | typedef int (*acpi_op_bind) (struct acpi_device * device); |
| 98 | typedef int (*acpi_op_unbind) (struct acpi_device * device); | 98 | typedef int (*acpi_op_unbind) (struct acpi_device * device); |
| 99 | typedef int (*acpi_op_match) (struct acpi_device * device, | 99 | typedef int (*acpi_op_shutdown) (struct acpi_device * device); |
| 100 | struct acpi_driver * driver); | ||
| 101 | 100 | ||
| 102 | struct acpi_bus_ops { | 101 | struct acpi_bus_ops { |
| 103 | u32 acpi_op_add:1; | 102 | u32 acpi_op_add:1; |
| @@ -110,7 +109,7 @@ struct acpi_bus_ops { | |||
| 110 | u32 acpi_op_scan:1; | 109 | u32 acpi_op_scan:1; |
| 111 | u32 acpi_op_bind:1; | 110 | u32 acpi_op_bind:1; |
| 112 | u32 acpi_op_unbind:1; | 111 | u32 acpi_op_unbind:1; |
| 113 | u32 acpi_op_match:1; | 112 | u32 acpi_op_shutdown:1; |
| 114 | u32 reserved:21; | 113 | u32 reserved:21; |
| 115 | }; | 114 | }; |
| 116 | 115 | ||
| @@ -125,16 +124,16 @@ struct acpi_device_ops { | |||
| 125 | acpi_op_scan scan; | 124 | acpi_op_scan scan; |
| 126 | acpi_op_bind bind; | 125 | acpi_op_bind bind; |
| 127 | acpi_op_unbind unbind; | 126 | acpi_op_unbind unbind; |
| 128 | acpi_op_match match; | 127 | acpi_op_shutdown shutdown; |
| 129 | }; | 128 | }; |
| 130 | 129 | ||
| 131 | struct acpi_driver { | 130 | struct acpi_driver { |
| 132 | struct list_head node; | ||
| 133 | char name[80]; | 131 | char name[80]; |
| 134 | char class[80]; | 132 | char class[80]; |
| 135 | atomic_t references; | ||
| 136 | char *ids; /* Supported Hardware IDs */ | 133 | char *ids; /* Supported Hardware IDs */ |
| 137 | struct acpi_device_ops ops; | 134 | struct acpi_device_ops ops; |
| 135 | struct device_driver drv; | ||
| 136 | struct module *owner; | ||
| 138 | }; | 137 | }; |
| 139 | 138 | ||
| 140 | /* | 139 | /* |
| @@ -184,7 +183,7 @@ struct acpi_device_dir { | |||
| 184 | 183 | ||
| 185 | typedef char acpi_bus_id[5]; | 184 | typedef char acpi_bus_id[5]; |
| 186 | typedef unsigned long acpi_bus_address; | 185 | typedef unsigned long acpi_bus_address; |
| 187 | typedef char acpi_hardware_id[9]; | 186 | typedef char acpi_hardware_id[15]; |
| 188 | typedef char acpi_unique_id[9]; | 187 | typedef char acpi_unique_id[9]; |
| 189 | typedef char acpi_device_name[40]; | 188 | typedef char acpi_device_name[40]; |
| 190 | typedef char acpi_device_class[20]; | 189 | typedef char acpi_device_class[20]; |
| @@ -295,11 +294,14 @@ struct acpi_device { | |||
| 295 | struct acpi_device_ops ops; | 294 | struct acpi_device_ops ops; |
| 296 | struct acpi_driver *driver; | 295 | struct acpi_driver *driver; |
| 297 | void *driver_data; | 296 | void *driver_data; |
| 298 | struct kobject kobj; | ||
| 299 | struct device dev; | 297 | struct device dev; |
| 298 | struct acpi_bus_ops bus_ops; /* workaround for different code path for hotplug */ | ||
| 299 | enum acpi_bus_removal_type removal_type; /* indicate for different removal type */ | ||
| 300 | }; | 300 | }; |
| 301 | 301 | ||
| 302 | #define acpi_driver_data(d) ((d)->driver_data) | 302 | #define acpi_driver_data(d) ((d)->driver_data) |
| 303 | #define to_acpi_device(d) container_of(d, struct acpi_device, dev) | ||
| 304 | #define to_acpi_driver(d) container_of(d, struct acpi_driver, drv) | ||
| 303 | 305 | ||
| 304 | /* | 306 | /* |
| 305 | * Events | 307 | * Events |
diff --git a/include/acpi/acpi_drivers.h b/include/acpi/acpi_drivers.h index baaa734b1098..4dc8a5043ef0 100644 --- a/include/acpi/acpi_drivers.h +++ b/include/acpi/acpi_drivers.h | |||
| @@ -36,13 +36,14 @@ | |||
| 36 | 36 | ||
| 37 | /* _HID definitions */ | 37 | /* _HID definitions */ |
| 38 | 38 | ||
| 39 | #define ACPI_POWER_HID "ACPI_PWR" | 39 | #define ACPI_POWER_HID "power_resource" |
| 40 | #define ACPI_PROCESSOR_HID "ACPI0007" | 40 | #define ACPI_PROCESSOR_HID "ACPI0007" |
| 41 | #define ACPI_SYSTEM_HID "ACPI_SYS" | 41 | #define ACPI_SYSTEM_HID "acpi_system" |
| 42 | #define ACPI_THERMAL_HID "ACPI_THM" | 42 | #define ACPI_THERMAL_HID "thermal" |
| 43 | #define ACPI_BUTTON_HID_POWERF "ACPI_FPB" | 43 | #define ACPI_BUTTON_HID_POWERF "button_power" |
| 44 | #define ACPI_BUTTON_HID_SLEEPF "ACPI_FSB" | 44 | #define ACPI_BUTTON_HID_SLEEPF "button_sleep" |
| 45 | 45 | #define ACPI_VIDEO_HID "video" | |
| 46 | #define ACPI_BAY_HID "bay" | ||
| 46 | /* -------------------------------------------------------------------------- | 47 | /* -------------------------------------------------------------------------- |
| 47 | PCI | 48 | PCI |
| 48 | -------------------------------------------------------------------------- */ | 49 | -------------------------------------------------------------------------- */ |
diff --git a/include/linux/video_output.h b/include/linux/video_output.h new file mode 100644 index 000000000000..e63e0c03ee0d --- /dev/null +++ b/include/linux/video_output.h | |||
| @@ -0,0 +1,42 @@ | |||
| 1 | /* | ||
| 2 | * | ||
| 3 | * Copyright (C) 2006 Luming Yu <luming.yu@intel.com> | ||
| 4 | * | ||
| 5 | * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
| 6 | * | ||
| 7 | * This program is free software; you can redistribute it and/or modify | ||
| 8 | * it under the terms of the GNU General Public License as published by | ||
| 9 | * the Free Software Foundation; either version 2 of the License, or (at | ||
| 10 | * your option) any later version. | ||
| 11 | * | ||
| 12 | * This program is distributed in the hope that it will be useful, but | ||
| 13 | * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
| 15 | * General Public License for more details. | ||
| 16 | * | ||
| 17 | * You should have received a copy of the GNU General Public License along | ||
| 18 | * with this program; if not, write to the Free Software Foundation, Inc., | ||
| 19 | * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. | ||
| 20 | * | ||
| 21 | * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
| 22 | */ | ||
| 23 | #ifndef _LINUX_VIDEO_OUTPUT_H | ||
| 24 | #define _LINUX_VIDEO_OUTPUT_H | ||
| 25 | #include <linux/device.h> | ||
| 26 | struct output_device; | ||
| 27 | struct output_properties { | ||
| 28 | int (*set_state)(struct output_device *); | ||
| 29 | int (*get_status)(struct output_device *); | ||
| 30 | }; | ||
| 31 | struct output_device { | ||
| 32 | int request_state; | ||
| 33 | struct output_properties *props; | ||
| 34 | struct class_device class_dev; | ||
| 35 | }; | ||
| 36 | #define to_output_device(obj) container_of(obj, struct output_device, class_dev) | ||
| 37 | struct output_device *video_output_register(const char *name, | ||
| 38 | struct device *dev, | ||
| 39 | void *devdata, | ||
| 40 | struct output_properties *op); | ||
| 41 | void video_output_unregister(struct output_device *dev); | ||
| 42 | #endif | ||
