aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2014-10-09 16:07:43 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2014-10-09 16:07:43 -0400
commitb528392669415dc1e53a047215e5ad6c2de879fc (patch)
treed19aa6e1464ef7c7d9f399ac8ec9a7707e5ba6b4 /drivers/acpi
parent80213c03c4151d900cf293ef0fc51f8d88495e14 (diff)
parent9f1a053296953c69d7f23511db9441290cb89e2c (diff)
Merge tag 'pm+acpi-3.18-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm
Pull ACPI and power management updates from Rafael Wysocki: "Features-wise, to me the most important this time is a rework of wakeup interrupts handling in the core that makes them work consistently across all of the available sleep states, including suspend-to-idle. Many thanks to Thomas Gleixner for his help with this work. Second is an update of the generic PM domains code that has been in need of some care for quite a while. Unused code is being removed, DT support is being added and domains are now going to be attached to devices in bus type code in analogy with the ACPI PM domain. The majority of work here was done by Ulf Hansson who also has been the most active developer this time. Apart from this we have a traditional ACPICA update, this time to upstream version 20140828 and a few ACPI wakeup interrupts handling patches on top of the general rework mentioned above. There also are several cpufreq commits including renaming the cpufreq-cpu0 driver to cpufreq-dt, as this is what implements generic DT-based cpufreq support, and a new DT-based idle states infrastructure for cpuidle. In addition to that, the ACPI LPSS driver is updated, ACPI support for Apple machines is improved, a few bugs are fixed and a few cleanups are made all over. Finally, the Adaptive Voltage Scaling (AVS) subsystem now has a tree maintained by Kevin Hilman that will be merged through the PM tree. Numbers-wise, the generic PM domains update takes the lead this time with 32 non-merge commits, second is cpufreq (15 commits) and the 3rd place goes to the wakeup interrupts handling rework (13 commits). Specifics: - Rework the handling of wakeup IRQs by the IRQ core such that all of them will be switched over to "wakeup" mode in suspend_device_irqs() and in that mode the first interrupt will abort system suspend in progress or wake up the system if already in suspend-to-idle (or equivalent) without executing any interrupt handlers. Among other things that eliminates the wakeup-related motivation to use the IRQF_NO_SUSPEND interrupt flag with interrupts which don't really need it and should not use it (Thomas Gleixner and Rafael Wysocki) - Switch over ACPI to handling wakeup interrupts with the help of the new mechanism introduced by the above IRQ core rework (Rafael Wysocki) - Rework the core generic PM domains code to eliminate code that's not used, add DT support and add a generic mechanism by which devices can be added to PM domains automatically during enumeration (Ulf Hansson, Geert Uytterhoeven and Tomasz Figa). - Add debugfs-based mechanics for debugging generic PM domains (Maciej Matraszek). - ACPICA update to upstream version 20140828. Included are updates related to the SRAT and GTDT tables and the _PSx methods are in the METHOD_NAME list now (Bob Moore and Hanjun Guo). - Add _OSI("Darwin") support to the ACPI core (unfortunately, that can't really be done in a straightforward way) to prevent Thunderbolt from being turned off on Apple systems after boot (or after resume from system suspend) and rework the ACPI Smart Battery Subsystem (SBS) driver to work correctly with Apple platforms (Matthew Garrett and Andreas Noever). - ACPI LPSS (Low-Power Subsystem) driver update cleaning up the code, adding support for 133MHz I2C source clock on Intel Baytrail to it and making it avoid using UART RTS override with Auto Flow Control (Heikki Krogerus). - ACPI backlight updates removing the video_set_use_native_backlight quirk which is not necessary any more, making the code check the list of output devices returned by the _DOD method to avoid creating acpi_video interfaces that won't work and adding a quirk for Lenovo Ideapad Z570 (Hans de Goede, Aaron Lu and Stepan Bujnak) - New Win8 ACPI OSI quirks for some Dell laptops (Edward Lin) - Assorted ACPI code cleanups (Fabian Frederick, Rasmus Villemoes, Sudip Mukherjee, Yijing Wang, and Zhang Rui) - cpufreq core updates and cleanups (Viresh Kumar, Preeti U Murthy, Rasmus Villemoes) - cpufreq driver updates: cpufreq-cpu0/cpufreq-dt (driver name change among other things), ppc-corenet, powernv (Viresh Kumar, Preeti U Murthy, Shilpasri G Bhat, Lucas Stach) - cpuidle support for DT-based idle states infrastructure, new ARM64 cpuidle driver, cpuidle core cleanups (Lorenzo Pieralisi, Rasmus Villemoes) - ARM big.LITTLE cpuidle driver updates: support for DT-based initialization and Exynos5800 compatible string (Lorenzo Pieralisi, Kevin Hilman) - Rework of the test_suspend kernel command line argument and a new trace event for console resume (Srinivas Pandruvada, Todd E Brandt) - Second attempt to optimize swsusp_free() (hibernation core) to make it avoid going through all PFNs which may be way too slow on some systems (Joerg Roedel) - devfreq updates (Paul Bolle, Punit Agrawal, Ãrjan Eide). - rockchip-io Adaptive Voltage Scaling (AVS) driver and AVS entry update in MAINTAINERS (Heiko Stübner, Kevin Hilman) - PM core fix related to clock management (Geert Uytterhoeven) - PM core's sysfs code cleanup (Johannes Berg)" * tag 'pm+acpi-3.18-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm: (105 commits) ACPI / fan: printk replacement PM / clk: Fix crash in clocks management code if !CONFIG_PM_RUNTIME PM / Domains: Rename cpu_data to cpuidle_data cpufreq: cpufreq-dt: fix potential double put of cpu OF node cpufreq: cpu0: rename driver and internals to 'cpufreq_dt' PM / hibernate: Iterate over set bits instead of PFNs in swsusp_free() cpufreq: ppc-corenet: remove duplicate update of cpu_data ACPI / sleep: Rework the handling of ACPI GPE wakeup from suspend-to-idle PM / sleep: Rename platform suspend/resume functions in suspend.c PM / sleep: Export dpm_suspend_late/noirq() and dpm_resume_early/noirq() ACPICA: Introduce acpi_enable_all_wakeup_gpes() ACPICA: Clear all non-wakeup GPEs in acpi_hw_enable_wakeup_gpe_block() ACPI / video: check _DOD list when creating backlight devices PM / Domains: Move dev_pm_domain_attach|detach() to pm_domain.h cpufreq: Replace strnicmp with strncasecmp cpufreq: powernv: Set the cpus to nominal frequency during reboot/kexec cpufreq: powernv: Set the pstate of the last hotplugged out cpu in policy->cpus to minimum cpufreq: Allow stop CPU callback to be used by all cpufreq drivers PM / devfreq: exynos: Enable building exynos PPMU as module PM / devfreq: Export helper functions for drivers ...
Diffstat (limited to 'drivers/acpi')
-rw-r--r--drivers/acpi/acpi_lpss.c167
-rw-r--r--drivers/acpi/acpi_pnp.c4
-rw-r--r--drivers/acpi/acpica/evxfgpe.c32
-rw-r--r--drivers/acpi/acpica/hwgpe.c8
-rw-r--r--drivers/acpi/acpica/utresrc.c4
-rw-r--r--drivers/acpi/battery.c2
-rw-r--r--drivers/acpi/blacklist.c36
-rw-r--r--drivers/acpi/device_pm.c71
-rw-r--r--drivers/acpi/fan.c18
-rw-r--r--drivers/acpi/osl.c12
-rw-r--r--drivers/acpi/pci_root.c14
-rw-r--r--drivers/acpi/processor_core.c6
-rw-r--r--drivers/acpi/sbs.c80
-rw-r--r--drivers/acpi/sleep.c16
-rw-r--r--drivers/acpi/utils.c1
-rw-r--r--drivers/acpi/video.c291
-rw-r--r--drivers/acpi/video_detect.c8
17 files changed, 319 insertions, 451 deletions
diff --git a/drivers/acpi/acpi_lpss.c b/drivers/acpi/acpi_lpss.c
index b0ea767c8696..93d160661f4c 100644
--- a/drivers/acpi/acpi_lpss.c
+++ b/drivers/acpi/acpi_lpss.c
@@ -54,55 +54,58 @@ ACPI_MODULE_NAME("acpi_lpss");
54 54
55#define LPSS_PRV_REG_COUNT 9 55#define LPSS_PRV_REG_COUNT 9
56 56
57struct lpss_shared_clock { 57/* LPSS Flags */
58 const char *name; 58#define LPSS_CLK BIT(0)
59 unsigned long rate; 59#define LPSS_CLK_GATE BIT(1)
60 struct clk *clk; 60#define LPSS_CLK_DIVIDER BIT(2)
61}; 61#define LPSS_LTR BIT(3)
62#define LPSS_SAVE_CTX BIT(4)
62 63
63struct lpss_private_data; 64struct lpss_private_data;
64 65
65struct lpss_device_desc { 66struct lpss_device_desc {
66 bool clk_required; 67 unsigned int flags;
67 const char *clkdev_name;
68 bool ltr_required;
69 unsigned int prv_offset; 68 unsigned int prv_offset;
70 size_t prv_size_override; 69 size_t prv_size_override;
71 bool clk_divider;
72 bool clk_gate;
73 bool save_ctx;
74 struct lpss_shared_clock *shared_clock;
75 void (*setup)(struct lpss_private_data *pdata); 70 void (*setup)(struct lpss_private_data *pdata);
76}; 71};
77 72
78static struct lpss_device_desc lpss_dma_desc = { 73static struct lpss_device_desc lpss_dma_desc = {
79 .clk_required = true, 74 .flags = LPSS_CLK,
80 .clkdev_name = "hclk",
81}; 75};
82 76
83struct lpss_private_data { 77struct lpss_private_data {
84 void __iomem *mmio_base; 78 void __iomem *mmio_base;
85 resource_size_t mmio_size; 79 resource_size_t mmio_size;
80 unsigned int fixed_clk_rate;
86 struct clk *clk; 81 struct clk *clk;
87 const struct lpss_device_desc *dev_desc; 82 const struct lpss_device_desc *dev_desc;
88 u32 prv_reg_ctx[LPSS_PRV_REG_COUNT]; 83 u32 prv_reg_ctx[LPSS_PRV_REG_COUNT];
89}; 84};
90 85
86/* UART Component Parameter Register */
87#define LPSS_UART_CPR 0xF4
88#define LPSS_UART_CPR_AFCE BIT(4)
89
91static void lpss_uart_setup(struct lpss_private_data *pdata) 90static void lpss_uart_setup(struct lpss_private_data *pdata)
92{ 91{
93 unsigned int offset; 92 unsigned int offset;
94 u32 reg; 93 u32 val;
95 94
96 offset = pdata->dev_desc->prv_offset + LPSS_TX_INT; 95 offset = pdata->dev_desc->prv_offset + LPSS_TX_INT;
97 reg = readl(pdata->mmio_base + offset); 96 val = readl(pdata->mmio_base + offset);
98 writel(reg | LPSS_TX_INT_MASK, pdata->mmio_base + offset); 97 writel(val | LPSS_TX_INT_MASK, pdata->mmio_base + offset);
99 98
100 offset = pdata->dev_desc->prv_offset + LPSS_GENERAL; 99 val = readl(pdata->mmio_base + LPSS_UART_CPR);
101 reg = readl(pdata->mmio_base + offset); 100 if (!(val & LPSS_UART_CPR_AFCE)) {
102 writel(reg | LPSS_GENERAL_UART_RTS_OVRD, pdata->mmio_base + offset); 101 offset = pdata->dev_desc->prv_offset + LPSS_GENERAL;
102 val = readl(pdata->mmio_base + offset);
103 val |= LPSS_GENERAL_UART_RTS_OVRD;
104 writel(val, pdata->mmio_base + offset);
105 }
103} 106}
104 107
105static void lpss_i2c_setup(struct lpss_private_data *pdata) 108static void byt_i2c_setup(struct lpss_private_data *pdata)
106{ 109{
107 unsigned int offset; 110 unsigned int offset;
108 u32 val; 111 u32 val;
@@ -111,100 +114,56 @@ static void lpss_i2c_setup(struct lpss_private_data *pdata)
111 val = readl(pdata->mmio_base + offset); 114 val = readl(pdata->mmio_base + offset);
112 val |= LPSS_RESETS_RESET_APB | LPSS_RESETS_RESET_FUNC; 115 val |= LPSS_RESETS_RESET_APB | LPSS_RESETS_RESET_FUNC;
113 writel(val, pdata->mmio_base + offset); 116 writel(val, pdata->mmio_base + offset);
114}
115 117
116static struct lpss_device_desc wpt_dev_desc = { 118 if (readl(pdata->mmio_base + pdata->dev_desc->prv_offset))
117 .clk_required = true, 119 pdata->fixed_clk_rate = 133000000;
118 .prv_offset = 0x800, 120}
119 .ltr_required = true,
120 .clk_divider = true,
121 .clk_gate = true,
122};
123 121
124static struct lpss_device_desc lpt_dev_desc = { 122static struct lpss_device_desc lpt_dev_desc = {
125 .clk_required = true, 123 .flags = LPSS_CLK | LPSS_CLK_GATE | LPSS_CLK_DIVIDER | LPSS_LTR,
126 .prv_offset = 0x800, 124 .prv_offset = 0x800,
127 .ltr_required = true,
128 .clk_divider = true,
129 .clk_gate = true,
130}; 125};
131 126
132static struct lpss_device_desc lpt_i2c_dev_desc = { 127static struct lpss_device_desc lpt_i2c_dev_desc = {
133 .clk_required = true, 128 .flags = LPSS_CLK | LPSS_CLK_GATE | LPSS_LTR,
134 .prv_offset = 0x800, 129 .prv_offset = 0x800,
135 .ltr_required = true,
136 .clk_gate = true,
137}; 130};
138 131
139static struct lpss_device_desc lpt_uart_dev_desc = { 132static struct lpss_device_desc lpt_uart_dev_desc = {
140 .clk_required = true, 133 .flags = LPSS_CLK | LPSS_CLK_GATE | LPSS_CLK_DIVIDER | LPSS_LTR,
141 .prv_offset = 0x800, 134 .prv_offset = 0x800,
142 .ltr_required = true,
143 .clk_divider = true,
144 .clk_gate = true,
145 .setup = lpss_uart_setup, 135 .setup = lpss_uart_setup,
146}; 136};
147 137
148static struct lpss_device_desc lpt_sdio_dev_desc = { 138static struct lpss_device_desc lpt_sdio_dev_desc = {
139 .flags = LPSS_LTR,
149 .prv_offset = 0x1000, 140 .prv_offset = 0x1000,
150 .prv_size_override = 0x1018, 141 .prv_size_override = 0x1018,
151 .ltr_required = true,
152};
153
154static struct lpss_shared_clock pwm_clock = {
155 .name = "pwm_clk",
156 .rate = 25000000,
157}; 142};
158 143
159static struct lpss_device_desc byt_pwm_dev_desc = { 144static struct lpss_device_desc byt_pwm_dev_desc = {
160 .clk_required = true, 145 .flags = LPSS_SAVE_CTX,
161 .save_ctx = true,
162 .shared_clock = &pwm_clock,
163}; 146};
164 147
165static struct lpss_device_desc byt_uart_dev_desc = { 148static struct lpss_device_desc byt_uart_dev_desc = {
166 .clk_required = true, 149 .flags = LPSS_CLK | LPSS_CLK_GATE | LPSS_CLK_DIVIDER | LPSS_SAVE_CTX,
167 .prv_offset = 0x800, 150 .prv_offset = 0x800,
168 .clk_divider = true,
169 .clk_gate = true,
170 .save_ctx = true,
171 .setup = lpss_uart_setup, 151 .setup = lpss_uart_setup,
172}; 152};
173 153
174static struct lpss_device_desc byt_spi_dev_desc = { 154static struct lpss_device_desc byt_spi_dev_desc = {
175 .clk_required = true, 155 .flags = LPSS_CLK | LPSS_CLK_GATE | LPSS_CLK_DIVIDER | LPSS_SAVE_CTX,
176 .prv_offset = 0x400, 156 .prv_offset = 0x400,
177 .clk_divider = true,
178 .clk_gate = true,
179 .save_ctx = true,
180}; 157};
181 158
182static struct lpss_device_desc byt_sdio_dev_desc = { 159static struct lpss_device_desc byt_sdio_dev_desc = {
183 .clk_required = true, 160 .flags = LPSS_CLK,
184};
185
186static struct lpss_shared_clock i2c_clock = {
187 .name = "i2c_clk",
188 .rate = 100000000,
189}; 161};
190 162
191static struct lpss_device_desc byt_i2c_dev_desc = { 163static struct lpss_device_desc byt_i2c_dev_desc = {
192 .clk_required = true, 164 .flags = LPSS_CLK | LPSS_SAVE_CTX,
193 .prv_offset = 0x800, 165 .prv_offset = 0x800,
194 .save_ctx = true, 166 .setup = byt_i2c_setup,
195 .shared_clock = &i2c_clock,
196 .setup = lpss_i2c_setup,
197};
198
199static struct lpss_shared_clock bsw_pwm_clock = {
200 .name = "pwm_clk",
201 .rate = 19200000,
202};
203
204static struct lpss_device_desc bsw_pwm_dev_desc = {
205 .clk_required = true,
206 .save_ctx = true,
207 .shared_clock = &bsw_pwm_clock,
208}; 167};
209 168
210#else 169#else
@@ -237,7 +196,7 @@ static const struct acpi_device_id acpi_lpss_device_ids[] = {
237 { "INT33FC", }, 196 { "INT33FC", },
238 197
239 /* Braswell LPSS devices */ 198 /* Braswell LPSS devices */
240 { "80862288", LPSS_ADDR(bsw_pwm_dev_desc) }, 199 { "80862288", LPSS_ADDR(byt_pwm_dev_desc) },
241 { "8086228A", LPSS_ADDR(byt_uart_dev_desc) }, 200 { "8086228A", LPSS_ADDR(byt_uart_dev_desc) },
242 { "8086228E", LPSS_ADDR(byt_spi_dev_desc) }, 201 { "8086228E", LPSS_ADDR(byt_spi_dev_desc) },
243 { "808622C1", LPSS_ADDR(byt_i2c_dev_desc) }, 202 { "808622C1", LPSS_ADDR(byt_i2c_dev_desc) },
@@ -251,7 +210,8 @@ static const struct acpi_device_id acpi_lpss_device_ids[] = {
251 { "INT3436", LPSS_ADDR(lpt_sdio_dev_desc) }, 210 { "INT3436", LPSS_ADDR(lpt_sdio_dev_desc) },
252 { "INT3437", }, 211 { "INT3437", },
253 212
254 { "INT3438", LPSS_ADDR(wpt_dev_desc) }, 213 /* Wildcat Point LPSS devices */
214 { "INT3438", LPSS_ADDR(lpt_dev_desc) },
255 215
256 { } 216 { }
257}; 217};
@@ -276,7 +236,6 @@ static int register_device_clock(struct acpi_device *adev,
276 struct lpss_private_data *pdata) 236 struct lpss_private_data *pdata)
277{ 237{
278 const struct lpss_device_desc *dev_desc = pdata->dev_desc; 238 const struct lpss_device_desc *dev_desc = pdata->dev_desc;
279 struct lpss_shared_clock *shared_clock = dev_desc->shared_clock;
280 const char *devname = dev_name(&adev->dev); 239 const char *devname = dev_name(&adev->dev);
281 struct clk *clk = ERR_PTR(-ENODEV); 240 struct clk *clk = ERR_PTR(-ENODEV);
282 struct lpss_clk_data *clk_data; 241 struct lpss_clk_data *clk_data;
@@ -289,12 +248,7 @@ static int register_device_clock(struct acpi_device *adev,
289 clk_data = platform_get_drvdata(lpss_clk_dev); 248 clk_data = platform_get_drvdata(lpss_clk_dev);
290 if (!clk_data) 249 if (!clk_data)
291 return -ENODEV; 250 return -ENODEV;
292 251 clk = clk_data->clk;
293 if (dev_desc->clkdev_name) {
294 clk_register_clkdev(clk_data->clk, dev_desc->clkdev_name,
295 devname);
296 return 0;
297 }
298 252
299 if (!pdata->mmio_base 253 if (!pdata->mmio_base
300 || pdata->mmio_size < dev_desc->prv_offset + LPSS_CLK_SIZE) 254 || pdata->mmio_size < dev_desc->prv_offset + LPSS_CLK_SIZE)
@@ -303,24 +257,19 @@ static int register_device_clock(struct acpi_device *adev,
303 parent = clk_data->name; 257 parent = clk_data->name;
304 prv_base = pdata->mmio_base + dev_desc->prv_offset; 258 prv_base = pdata->mmio_base + dev_desc->prv_offset;
305 259
306 if (shared_clock) { 260 if (pdata->fixed_clk_rate) {
307 clk = shared_clock->clk; 261 clk = clk_register_fixed_rate(NULL, devname, parent, 0,
308 if (!clk) { 262 pdata->fixed_clk_rate);
309 clk = clk_register_fixed_rate(NULL, shared_clock->name, 263 goto out;
310 "lpss_clk", 0,
311 shared_clock->rate);
312 shared_clock->clk = clk;
313 }
314 parent = shared_clock->name;
315 } 264 }
316 265
317 if (dev_desc->clk_gate) { 266 if (dev_desc->flags & LPSS_CLK_GATE) {
318 clk = clk_register_gate(NULL, devname, parent, 0, 267 clk = clk_register_gate(NULL, devname, parent, 0,
319 prv_base, 0, 0, NULL); 268 prv_base, 0, 0, NULL);
320 parent = devname; 269 parent = devname;
321 } 270 }
322 271
323 if (dev_desc->clk_divider) { 272 if (dev_desc->flags & LPSS_CLK_DIVIDER) {
324 /* Prevent division by zero */ 273 /* Prevent division by zero */
325 if (!readl(prv_base)) 274 if (!readl(prv_base))
326 writel(LPSS_CLK_DIVIDER_DEF_MASK, prv_base); 275 writel(LPSS_CLK_DIVIDER_DEF_MASK, prv_base);
@@ -344,7 +293,7 @@ static int register_device_clock(struct acpi_device *adev,
344 kfree(parent); 293 kfree(parent);
345 kfree(clk_name); 294 kfree(clk_name);
346 } 295 }
347 296out:
348 if (IS_ERR(clk)) 297 if (IS_ERR(clk))
349 return PTR_ERR(clk); 298 return PTR_ERR(clk);
350 299
@@ -392,7 +341,10 @@ static int acpi_lpss_create_device(struct acpi_device *adev,
392 341
393 pdata->dev_desc = dev_desc; 342 pdata->dev_desc = dev_desc;
394 343
395 if (dev_desc->clk_required) { 344 if (dev_desc->setup)
345 dev_desc->setup(pdata);
346
347 if (dev_desc->flags & LPSS_CLK) {
396 ret = register_device_clock(adev, pdata); 348 ret = register_device_clock(adev, pdata);
397 if (ret) { 349 if (ret) {
398 /* Skip the device, but continue the namespace scan. */ 350 /* Skip the device, but continue the namespace scan. */
@@ -413,9 +365,6 @@ static int acpi_lpss_create_device(struct acpi_device *adev,
413 goto err_out; 365 goto err_out;
414 } 366 }
415 367
416 if (dev_desc->setup)
417 dev_desc->setup(pdata);
418
419 adev->driver_data = pdata; 368 adev->driver_data = pdata;
420 pdev = acpi_create_platform_device(adev); 369 pdev = acpi_create_platform_device(adev);
421 if (!IS_ERR_OR_NULL(pdev)) { 370 if (!IS_ERR_OR_NULL(pdev)) {
@@ -692,19 +641,19 @@ static int acpi_lpss_platform_notify(struct notifier_block *nb,
692 641
693 switch (action) { 642 switch (action) {
694 case BUS_NOTIFY_BOUND_DRIVER: 643 case BUS_NOTIFY_BOUND_DRIVER:
695 if (pdata->dev_desc->save_ctx) 644 if (pdata->dev_desc->flags & LPSS_SAVE_CTX)
696 pdev->dev.pm_domain = &acpi_lpss_pm_domain; 645 pdev->dev.pm_domain = &acpi_lpss_pm_domain;
697 break; 646 break;
698 case BUS_NOTIFY_UNBOUND_DRIVER: 647 case BUS_NOTIFY_UNBOUND_DRIVER:
699 if (pdata->dev_desc->save_ctx) 648 if (pdata->dev_desc->flags & LPSS_SAVE_CTX)
700 pdev->dev.pm_domain = NULL; 649 pdev->dev.pm_domain = NULL;
701 break; 650 break;
702 case BUS_NOTIFY_ADD_DEVICE: 651 case BUS_NOTIFY_ADD_DEVICE:
703 if (pdata->dev_desc->ltr_required) 652 if (pdata->dev_desc->flags & LPSS_LTR)
704 return sysfs_create_group(&pdev->dev.kobj, 653 return sysfs_create_group(&pdev->dev.kobj,
705 &lpss_attr_group); 654 &lpss_attr_group);
706 case BUS_NOTIFY_DEL_DEVICE: 655 case BUS_NOTIFY_DEL_DEVICE:
707 if (pdata->dev_desc->ltr_required) 656 if (pdata->dev_desc->flags & LPSS_LTR)
708 sysfs_remove_group(&pdev->dev.kobj, &lpss_attr_group); 657 sysfs_remove_group(&pdev->dev.kobj, &lpss_attr_group);
709 default: 658 default:
710 break; 659 break;
@@ -721,7 +670,7 @@ static void acpi_lpss_bind(struct device *dev)
721{ 670{
722 struct lpss_private_data *pdata = acpi_driver_data(ACPI_COMPANION(dev)); 671 struct lpss_private_data *pdata = acpi_driver_data(ACPI_COMPANION(dev));
723 672
724 if (!pdata || !pdata->mmio_base || !pdata->dev_desc->ltr_required) 673 if (!pdata || !pdata->mmio_base || !(pdata->dev_desc->flags & LPSS_LTR))
725 return; 674 return;
726 675
727 if (pdata->mmio_size >= pdata->dev_desc->prv_offset + LPSS_LTR_SIZE) 676 if (pdata->mmio_size >= pdata->dev_desc->prv_offset + LPSS_LTR_SIZE)
diff --git a/drivers/acpi/acpi_pnp.c b/drivers/acpi/acpi_pnp.c
index 1f8b20496f32..b193f8425999 100644
--- a/drivers/acpi/acpi_pnp.c
+++ b/drivers/acpi/acpi_pnp.c
@@ -130,10 +130,6 @@ static const struct acpi_device_id acpi_pnp_device_ids[] = {
130 {"PNP0401"}, /* ECP Printer Port */ 130 {"PNP0401"}, /* ECP Printer Port */
131 /* apple-gmux */ 131 /* apple-gmux */
132 {"APP000B"}, 132 {"APP000B"},
133 /* fujitsu-laptop.c */
134 {"FUJ02bf"},
135 {"FUJ02B1"},
136 {"FUJ02E3"},
137 /* system */ 133 /* system */
138 {"PNP0c02"}, /* General ID for reserving resources */ 134 {"PNP0c02"}, /* General ID for reserving resources */
139 {"PNP0c01"}, /* memory controller */ 135 {"PNP0c01"}, /* memory controller */
diff --git a/drivers/acpi/acpica/evxfgpe.c b/drivers/acpi/acpica/evxfgpe.c
index 0cf159cc6e6d..56710a03c9b0 100644
--- a/drivers/acpi/acpica/evxfgpe.c
+++ b/drivers/acpi/acpica/evxfgpe.c
@@ -596,6 +596,38 @@ acpi_status acpi_enable_all_runtime_gpes(void)
596 596
597ACPI_EXPORT_SYMBOL(acpi_enable_all_runtime_gpes) 597ACPI_EXPORT_SYMBOL(acpi_enable_all_runtime_gpes)
598 598
599/******************************************************************************
600 *
601 * FUNCTION: acpi_enable_all_wakeup_gpes
602 *
603 * PARAMETERS: None
604 *
605 * RETURN: Status
606 *
607 * DESCRIPTION: Enable all "wakeup" GPEs and disable all of the other GPEs, in
608 * all GPE blocks.
609 *
610 ******************************************************************************/
611
612acpi_status acpi_enable_all_wakeup_gpes(void)
613{
614 acpi_status status;
615
616 ACPI_FUNCTION_TRACE(acpi_enable_all_wakeup_gpes);
617
618 status = acpi_ut_acquire_mutex(ACPI_MTX_EVENTS);
619 if (ACPI_FAILURE(status)) {
620 return_ACPI_STATUS(status);
621 }
622
623 status = acpi_hw_enable_all_wakeup_gpes();
624 (void)acpi_ut_release_mutex(ACPI_MTX_EVENTS);
625
626 return_ACPI_STATUS(status);
627}
628
629ACPI_EXPORT_SYMBOL(acpi_enable_all_wakeup_gpes)
630
599/******************************************************************************* 631/*******************************************************************************
600 * 632 *
601 * FUNCTION: acpi_install_gpe_block 633 * FUNCTION: acpi_install_gpe_block
diff --git a/drivers/acpi/acpica/hwgpe.c b/drivers/acpi/acpica/hwgpe.c
index 2e6caabba07a..ea62d40fd161 100644
--- a/drivers/acpi/acpica/hwgpe.c
+++ b/drivers/acpi/acpica/hwgpe.c
@@ -396,11 +396,11 @@ acpi_hw_enable_wakeup_gpe_block(struct acpi_gpe_xrupt_info *gpe_xrupt_info,
396 /* Examine each GPE Register within the block */ 396 /* Examine each GPE Register within the block */
397 397
398 for (i = 0; i < gpe_block->register_count; i++) { 398 for (i = 0; i < gpe_block->register_count; i++) {
399 if (!gpe_block->register_info[i].enable_for_wake) {
400 continue;
401 }
402 399
403 /* Enable all "wake" GPEs in this register */ 400 /*
401 * Enable all "wake" GPEs in this register and disable the
402 * remaining ones.
403 */
404 404
405 status = 405 status =
406 acpi_hw_write(gpe_block->register_info[i].enable_for_wake, 406 acpi_hw_write(gpe_block->register_info[i].enable_for_wake,
diff --git a/drivers/acpi/acpica/utresrc.c b/drivers/acpi/acpica/utresrc.c
index 14cb6c0c8be2..5cd017c7ac0e 100644
--- a/drivers/acpi/acpica/utresrc.c
+++ b/drivers/acpi/acpica/utresrc.c
@@ -87,7 +87,9 @@ const char *acpi_gbl_io_decode[] = {
87 87
88const char *acpi_gbl_ll_decode[] = { 88const char *acpi_gbl_ll_decode[] = {
89 "ActiveHigh", 89 "ActiveHigh",
90 "ActiveLow" 90 "ActiveLow",
91 "ActiveBoth",
92 "Reserved"
91}; 93};
92 94
93const char *acpi_gbl_max_decode[] = { 95const char *acpi_gbl_max_decode[] = {
diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c
index 5fdfe65fe165..8ec8a89a20ab 100644
--- a/drivers/acpi/battery.c
+++ b/drivers/acpi/battery.c
@@ -695,7 +695,7 @@ static void acpi_battery_quirks(struct acpi_battery *battery)
695 if (battery->power_unit && dmi_name_in_vendors("LENOVO")) { 695 if (battery->power_unit && dmi_name_in_vendors("LENOVO")) {
696 const char *s; 696 const char *s;
697 s = dmi_get_system_info(DMI_PRODUCT_VERSION); 697 s = dmi_get_system_info(DMI_PRODUCT_VERSION);
698 if (s && !strnicmp(s, "ThinkPad", 8)) { 698 if (s && !strncasecmp(s, "ThinkPad", 8)) {
699 dmi_walk(find_battery, battery); 699 dmi_walk(find_battery, battery);
700 if (test_bit(ACPI_BATTERY_QUIRK_THINKPAD_MAH, 700 if (test_bit(ACPI_BATTERY_QUIRK_THINKPAD_MAH,
701 &battery->flags) && 701 &battery->flags) &&
diff --git a/drivers/acpi/blacklist.c b/drivers/acpi/blacklist.c
index 36eb42e3b0bb..ed122e17636e 100644
--- a/drivers/acpi/blacklist.c
+++ b/drivers/acpi/blacklist.c
@@ -247,8 +247,8 @@ static struct dmi_system_id acpi_osi_dmi_table[] __initdata = {
247 }, 247 },
248 248
249 /* 249 /*
250 * These machines will power on immediately after shutdown when 250 * The wireless hotkey does not work on those machines when
251 * reporting the Windows 2012 OSI. 251 * returning true for _OSI("Windows 2012")
252 */ 252 */
253 { 253 {
254 .callback = dmi_disable_osi_win8, 254 .callback = dmi_disable_osi_win8,
@@ -258,6 +258,38 @@ static struct dmi_system_id acpi_osi_dmi_table[] __initdata = {
258 DMI_MATCH(DMI_PRODUCT_NAME, "Inspiron 7737"), 258 DMI_MATCH(DMI_PRODUCT_NAME, "Inspiron 7737"),
259 }, 259 },
260 }, 260 },
261 {
262 .callback = dmi_disable_osi_win8,
263 .ident = "Dell Inspiron 7537",
264 .matches = {
265 DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
266 DMI_MATCH(DMI_PRODUCT_NAME, "Inspiron 7537"),
267 },
268 },
269 {
270 .callback = dmi_disable_osi_win8,
271 .ident = "Dell Inspiron 5437",
272 .matches = {
273 DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
274 DMI_MATCH(DMI_PRODUCT_NAME, "Inspiron 5437"),
275 },
276 },
277 {
278 .callback = dmi_disable_osi_win8,
279 .ident = "Dell Inspiron 3437",
280 .matches = {
281 DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
282 DMI_MATCH(DMI_PRODUCT_NAME, "Inspiron 3437"),
283 },
284 },
285 {
286 .callback = dmi_disable_osi_win8,
287 .ident = "Dell Vostro 3446",
288 .matches = {
289 DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
290 DMI_MATCH(DMI_PRODUCT_NAME, "Vostro 3446"),
291 },
292 },
261 293
262 /* 294 /*
263 * BIOS invocation of _OSI(Linux) is almost always a BIOS bug. 295 * BIOS invocation of _OSI(Linux) is almost always a BIOS bug.
diff --git a/drivers/acpi/device_pm.c b/drivers/acpi/device_pm.c
index 67075f800e34..bea6896be122 100644
--- a/drivers/acpi/device_pm.c
+++ b/drivers/acpi/device_pm.c
@@ -1041,6 +1041,40 @@ static struct dev_pm_domain acpi_general_pm_domain = {
1041}; 1041};
1042 1042
1043/** 1043/**
1044 * acpi_dev_pm_detach - Remove ACPI power management from the device.
1045 * @dev: Device to take care of.
1046 * @power_off: Whether or not to try to remove power from the device.
1047 *
1048 * Remove the device from the general ACPI PM domain and remove its wakeup
1049 * notifier. If @power_off is set, additionally remove power from the device if
1050 * possible.
1051 *
1052 * Callers must ensure proper synchronization of this function with power
1053 * management callbacks.
1054 */
1055static void acpi_dev_pm_detach(struct device *dev, bool power_off)
1056{
1057 struct acpi_device *adev = ACPI_COMPANION(dev);
1058
1059 if (adev && dev->pm_domain == &acpi_general_pm_domain) {
1060 dev->pm_domain = NULL;
1061 acpi_remove_pm_notifier(adev);
1062 if (power_off) {
1063 /*
1064 * If the device's PM QoS resume latency limit or flags
1065 * have been exposed to user space, they have to be
1066 * hidden at this point, so that they don't affect the
1067 * choice of the low-power state to put the device into.
1068 */
1069 dev_pm_qos_hide_latency_limit(dev);
1070 dev_pm_qos_hide_flags(dev);
1071 acpi_device_wakeup(adev, ACPI_STATE_S0, false);
1072 acpi_dev_pm_low_power(dev, adev, ACPI_STATE_S0);
1073 }
1074 }
1075}
1076
1077/**
1044 * acpi_dev_pm_attach - Prepare device for ACPI power management. 1078 * acpi_dev_pm_attach - Prepare device for ACPI power management.
1045 * @dev: Device to prepare. 1079 * @dev: Device to prepare.
1046 * @power_on: Whether or not to power on the device. 1080 * @power_on: Whether or not to power on the device.
@@ -1072,42 +1106,9 @@ int acpi_dev_pm_attach(struct device *dev, bool power_on)
1072 acpi_dev_pm_full_power(adev); 1106 acpi_dev_pm_full_power(adev);
1073 acpi_device_wakeup(adev, ACPI_STATE_S0, false); 1107 acpi_device_wakeup(adev, ACPI_STATE_S0, false);
1074 } 1108 }
1109
1110 dev->pm_domain->detach = acpi_dev_pm_detach;
1075 return 0; 1111 return 0;
1076} 1112}
1077EXPORT_SYMBOL_GPL(acpi_dev_pm_attach); 1113EXPORT_SYMBOL_GPL(acpi_dev_pm_attach);
1078
1079/**
1080 * acpi_dev_pm_detach - Remove ACPI power management from the device.
1081 * @dev: Device to take care of.
1082 * @power_off: Whether or not to try to remove power from the device.
1083 *
1084 * Remove the device from the general ACPI PM domain and remove its wakeup
1085 * notifier. If @power_off is set, additionally remove power from the device if
1086 * possible.
1087 *
1088 * Callers must ensure proper synchronization of this function with power
1089 * management callbacks.
1090 */
1091void acpi_dev_pm_detach(struct device *dev, bool power_off)
1092{
1093 struct acpi_device *adev = ACPI_COMPANION(dev);
1094
1095 if (adev && dev->pm_domain == &acpi_general_pm_domain) {
1096 dev->pm_domain = NULL;
1097 acpi_remove_pm_notifier(adev);
1098 if (power_off) {
1099 /*
1100 * If the device's PM QoS resume latency limit or flags
1101 * have been exposed to user space, they have to be
1102 * hidden at this point, so that they don't affect the
1103 * choice of the low-power state to put the device into.
1104 */
1105 dev_pm_qos_hide_latency_limit(dev);
1106 dev_pm_qos_hide_flags(dev);
1107 acpi_device_wakeup(adev, ACPI_STATE_S0, false);
1108 acpi_dev_pm_low_power(dev, adev, ACPI_STATE_S0);
1109 }
1110 }
1111}
1112EXPORT_SYMBOL_GPL(acpi_dev_pm_detach);
1113#endif /* CONFIG_PM */ 1114#endif /* CONFIG_PM */
diff --git a/drivers/acpi/fan.c b/drivers/acpi/fan.c
index 8acf53e62966..5328b1090e08 100644
--- a/drivers/acpi/fan.c
+++ b/drivers/acpi/fan.c
@@ -27,12 +27,10 @@
27#include <linux/module.h> 27#include <linux/module.h>
28#include <linux/init.h> 28#include <linux/init.h>
29#include <linux/types.h> 29#include <linux/types.h>
30#include <asm/uaccess.h> 30#include <linux/uaccess.h>
31#include <linux/thermal.h> 31#include <linux/thermal.h>
32#include <linux/acpi.h> 32#include <linux/acpi.h>
33 33
34#define PREFIX "ACPI: "
35
36#define ACPI_FAN_CLASS "fan" 34#define ACPI_FAN_CLASS "fan"
37#define ACPI_FAN_FILE_STATE "state" 35#define ACPI_FAN_FILE_STATE "state"
38 36
@@ -127,8 +125,9 @@ static const struct thermal_cooling_device_ops fan_cooling_ops = {
127}; 125};
128 126
129/* -------------------------------------------------------------------------- 127/* --------------------------------------------------------------------------
130 Driver Interface 128 * Driver Interface
131 -------------------------------------------------------------------------- */ 129 * --------------------------------------------------------------------------
130*/
132 131
133static int acpi_fan_add(struct acpi_device *device) 132static int acpi_fan_add(struct acpi_device *device)
134{ 133{
@@ -143,7 +142,7 @@ static int acpi_fan_add(struct acpi_device *device)
143 142
144 result = acpi_bus_update_power(device->handle, NULL); 143 result = acpi_bus_update_power(device->handle, NULL);
145 if (result) { 144 if (result) {
146 printk(KERN_ERR PREFIX "Setting initial power state\n"); 145 dev_err(&device->dev, "Setting initial power state\n");
147 goto end; 146 goto end;
148 } 147 }
149 148
@@ -168,10 +167,9 @@ static int acpi_fan_add(struct acpi_device *device)
168 &device->dev.kobj, 167 &device->dev.kobj,
169 "device"); 168 "device");
170 if (result) 169 if (result)
171 dev_err(&device->dev, "Failed to create sysfs link " 170 dev_err(&device->dev, "Failed to create sysfs link 'device'\n");
172 "'device'\n");
173 171
174 printk(KERN_INFO PREFIX "%s [%s] (%s)\n", 172 dev_info(&device->dev, "ACPI: %s [%s] (%s)\n",
175 acpi_device_name(device), acpi_device_bid(device), 173 acpi_device_name(device), acpi_device_bid(device),
176 !device->power.state ? "on" : "off"); 174 !device->power.state ? "on" : "off");
177 175
@@ -217,7 +215,7 @@ static int acpi_fan_resume(struct device *dev)
217 215
218 result = acpi_bus_update_power(to_acpi_device(dev)->handle, NULL); 216 result = acpi_bus_update_power(to_acpi_device(dev)->handle, NULL);
219 if (result) 217 if (result)
220 printk(KERN_ERR PREFIX "Error updating fan power state\n"); 218 dev_err(dev, "Error updating fan power state\n");
221 219
222 return result; 220 return result;
223} 221}
diff --git a/drivers/acpi/osl.c b/drivers/acpi/osl.c
index 3abe9b223ba7..9964f70be98d 100644
--- a/drivers/acpi/osl.c
+++ b/drivers/acpi/osl.c
@@ -152,6 +152,16 @@ static u32 acpi_osi_handler(acpi_string interface, u32 supported)
152 osi_linux.dmi ? " via DMI" : ""); 152 osi_linux.dmi ? " via DMI" : "");
153 } 153 }
154 154
155 if (!strcmp("Darwin", interface)) {
156 /*
157 * Apple firmware will behave poorly if it receives positive
158 * answers to "Darwin" and any other OS. Respond positively
159 * to Darwin and then disable all other vendor strings.
160 */
161 acpi_update_interfaces(ACPI_DISABLE_ALL_VENDOR_STRINGS);
162 supported = ACPI_UINT32_MAX;
163 }
164
155 return supported; 165 return supported;
156} 166}
157 167
@@ -825,7 +835,7 @@ acpi_os_install_interrupt_handler(u32 gsi, acpi_osd_handler handler,
825 835
826 acpi_irq_handler = handler; 836 acpi_irq_handler = handler;
827 acpi_irq_context = context; 837 acpi_irq_context = context;
828 if (request_irq(irq, acpi_irq, IRQF_SHARED | IRQF_NO_SUSPEND, "acpi", acpi_irq)) { 838 if (request_irq(irq, acpi_irq, IRQF_SHARED, "acpi", acpi_irq)) {
829 printk(KERN_ERR PREFIX "SCI (IRQ%d) allocation failed\n", irq); 839 printk(KERN_ERR PREFIX "SCI (IRQ%d) allocation failed\n", irq);
830 acpi_irq_handler = NULL; 840 acpi_irq_handler = NULL;
831 return AE_NOT_ACQUIRED; 841 return AE_NOT_ACQUIRED;
diff --git a/drivers/acpi/pci_root.c b/drivers/acpi/pci_root.c
index e6ae603ed1a1..cd4de7e038ea 100644
--- a/drivers/acpi/pci_root.c
+++ b/drivers/acpi/pci_root.c
@@ -35,6 +35,7 @@
35#include <linux/pci-aspm.h> 35#include <linux/pci-aspm.h>
36#include <linux/acpi.h> 36#include <linux/acpi.h>
37#include <linux/slab.h> 37#include <linux/slab.h>
38#include <linux/dmi.h>
38#include <acpi/apei.h> /* for acpi_hest_init() */ 39#include <acpi/apei.h> /* for acpi_hest_init() */
39 40
40#include "internal.h" 41#include "internal.h"
@@ -430,6 +431,19 @@ static void negotiate_os_control(struct acpi_pci_root *root, int *no_aspm,
430 acpi_handle handle = device->handle; 431 acpi_handle handle = device->handle;
431 432
432 /* 433 /*
434 * Apple always return failure on _OSC calls when _OSI("Darwin") has
435 * been called successfully. We know the feature set supported by the
436 * platform, so avoid calling _OSC at all
437 */
438
439 if (dmi_match(DMI_SYS_VENDOR, "Apple Inc.")) {
440 root->osc_control_set = ~OSC_PCI_EXPRESS_PME_CONTROL;
441 decode_osc_control(root, "OS assumes control of",
442 root->osc_control_set);
443 return;
444 }
445
446 /*
433 * All supported architectures that use ACPI have support for 447 * All supported architectures that use ACPI have support for
434 * PCI domains, so we indicate this in _OSC support capabilities. 448 * PCI domains, so we indicate this in _OSC support capabilities.
435 */ 449 */
diff --git a/drivers/acpi/processor_core.c b/drivers/acpi/processor_core.c
index e32321ce9a5c..ef58f46c8442 100644
--- a/drivers/acpi/processor_core.c
+++ b/drivers/acpi/processor_core.c
@@ -16,7 +16,7 @@ static int map_lapic_id(struct acpi_subtable_header *entry,
16 u32 acpi_id, int *apic_id) 16 u32 acpi_id, int *apic_id)
17{ 17{
18 struct acpi_madt_local_apic *lapic = 18 struct acpi_madt_local_apic *lapic =
19 (struct acpi_madt_local_apic *)entry; 19 container_of(entry, struct acpi_madt_local_apic, header);
20 20
21 if (!(lapic->lapic_flags & ACPI_MADT_ENABLED)) 21 if (!(lapic->lapic_flags & ACPI_MADT_ENABLED))
22 return -ENODEV; 22 return -ENODEV;
@@ -32,7 +32,7 @@ static int map_x2apic_id(struct acpi_subtable_header *entry,
32 int device_declaration, u32 acpi_id, int *apic_id) 32 int device_declaration, u32 acpi_id, int *apic_id)
33{ 33{
34 struct acpi_madt_local_x2apic *apic = 34 struct acpi_madt_local_x2apic *apic =
35 (struct acpi_madt_local_x2apic *)entry; 35 container_of(entry, struct acpi_madt_local_x2apic, header);
36 36
37 if (!(apic->lapic_flags & ACPI_MADT_ENABLED)) 37 if (!(apic->lapic_flags & ACPI_MADT_ENABLED))
38 return -ENODEV; 38 return -ENODEV;
@@ -49,7 +49,7 @@ static int map_lsapic_id(struct acpi_subtable_header *entry,
49 int device_declaration, u32 acpi_id, int *apic_id) 49 int device_declaration, u32 acpi_id, int *apic_id)
50{ 50{
51 struct acpi_madt_local_sapic *lsapic = 51 struct acpi_madt_local_sapic *lsapic =
52 (struct acpi_madt_local_sapic *)entry; 52 container_of(entry, struct acpi_madt_local_sapic, header);
53 53
54 if (!(lsapic->lapic_flags & ACPI_MADT_ENABLED)) 54 if (!(lsapic->lapic_flags & ACPI_MADT_ENABLED))
55 return -ENODEV; 55 return -ENODEV;
diff --git a/drivers/acpi/sbs.c b/drivers/acpi/sbs.c
index 366ca40a6f70..a7a3edd28beb 100644
--- a/drivers/acpi/sbs.c
+++ b/drivers/acpi/sbs.c
@@ -35,6 +35,7 @@
35#include <linux/jiffies.h> 35#include <linux/jiffies.h>
36#include <linux/delay.h> 36#include <linux/delay.h>
37#include <linux/power_supply.h> 37#include <linux/power_supply.h>
38#include <linux/dmi.h>
38 39
39#include "sbshc.h" 40#include "sbshc.h"
40#include "battery.h" 41#include "battery.h"
@@ -61,6 +62,8 @@ static unsigned int cache_time = 1000;
61module_param(cache_time, uint, 0644); 62module_param(cache_time, uint, 0644);
62MODULE_PARM_DESC(cache_time, "cache time in milliseconds"); 63MODULE_PARM_DESC(cache_time, "cache time in milliseconds");
63 64
65static bool sbs_manager_broken;
66
64#define MAX_SBS_BAT 4 67#define MAX_SBS_BAT 4
65#define ACPI_SBS_BLOCK_MAX 32 68#define ACPI_SBS_BLOCK_MAX 32
66 69
@@ -109,6 +112,7 @@ struct acpi_sbs {
109 u8 batteries_supported:4; 112 u8 batteries_supported:4;
110 u8 manager_present:1; 113 u8 manager_present:1;
111 u8 charger_present:1; 114 u8 charger_present:1;
115 u8 charger_exists:1;
112}; 116};
113 117
114#define to_acpi_sbs(x) container_of(x, struct acpi_sbs, charger) 118#define to_acpi_sbs(x) container_of(x, struct acpi_sbs, charger)
@@ -429,9 +433,19 @@ static int acpi_ac_get_present(struct acpi_sbs *sbs)
429 433
430 result = acpi_smbus_read(sbs->hc, SMBUS_READ_WORD, ACPI_SBS_CHARGER, 434 result = acpi_smbus_read(sbs->hc, SMBUS_READ_WORD, ACPI_SBS_CHARGER,
431 0x13, (u8 *) & status); 435 0x13, (u8 *) & status);
432 if (!result) 436
433 sbs->charger_present = (status >> 15) & 0x1; 437 if (result)
434 return result; 438 return result;
439
440 /*
441 * The spec requires that bit 4 always be 1. If it's not set, assume
442 * that the implementation doesn't support an SBS charger
443 */
444 if (!((status >> 4) & 0x1))
445 return -ENODEV;
446
447 sbs->charger_present = (status >> 15) & 0x1;
448 return 0;
435} 449}
436 450
437static ssize_t acpi_battery_alarm_show(struct device *dev, 451static ssize_t acpi_battery_alarm_show(struct device *dev,
@@ -483,16 +497,21 @@ static int acpi_battery_read(struct acpi_battery *battery)
483 ACPI_SBS_MANAGER, 0x01, (u8 *)&state, 2); 497 ACPI_SBS_MANAGER, 0x01, (u8 *)&state, 2);
484 } else if (battery->id == 0) 498 } else if (battery->id == 0)
485 battery->present = 1; 499 battery->present = 1;
500
486 if (result || !battery->present) 501 if (result || !battery->present)
487 return result; 502 return result;
488 503
489 if (saved_present != battery->present) { 504 if (saved_present != battery->present) {
490 battery->update_time = 0; 505 battery->update_time = 0;
491 result = acpi_battery_get_info(battery); 506 result = acpi_battery_get_info(battery);
492 if (result) 507 if (result) {
508 battery->present = 0;
493 return result; 509 return result;
510 }
494 } 511 }
495 result = acpi_battery_get_state(battery); 512 result = acpi_battery_get_state(battery);
513 if (result)
514 battery->present = 0;
496 return result; 515 return result;
497} 516}
498 517
@@ -524,6 +543,7 @@ static int acpi_battery_add(struct acpi_sbs *sbs, int id)
524 result = power_supply_register(&sbs->device->dev, &battery->bat); 543 result = power_supply_register(&sbs->device->dev, &battery->bat);
525 if (result) 544 if (result)
526 goto end; 545 goto end;
546
527 result = device_create_file(battery->bat.dev, &alarm_attr); 547 result = device_create_file(battery->bat.dev, &alarm_attr);
528 if (result) 548 if (result)
529 goto end; 549 goto end;
@@ -554,6 +574,7 @@ static int acpi_charger_add(struct acpi_sbs *sbs)
554 if (result) 574 if (result)
555 goto end; 575 goto end;
556 576
577 sbs->charger_exists = 1;
557 sbs->charger.name = "sbs-charger"; 578 sbs->charger.name = "sbs-charger";
558 sbs->charger.type = POWER_SUPPLY_TYPE_MAINS; 579 sbs->charger.type = POWER_SUPPLY_TYPE_MAINS;
559 sbs->charger.properties = sbs_ac_props; 580 sbs->charger.properties = sbs_ac_props;
@@ -580,9 +601,12 @@ static void acpi_sbs_callback(void *context)
580 struct acpi_battery *bat; 601 struct acpi_battery *bat;
581 u8 saved_charger_state = sbs->charger_present; 602 u8 saved_charger_state = sbs->charger_present;
582 u8 saved_battery_state; 603 u8 saved_battery_state;
583 acpi_ac_get_present(sbs); 604
584 if (sbs->charger_present != saved_charger_state) 605 if (sbs->charger_exists) {
585 kobject_uevent(&sbs->charger.dev->kobj, KOBJ_CHANGE); 606 acpi_ac_get_present(sbs);
607 if (sbs->charger_present != saved_charger_state)
608 kobject_uevent(&sbs->charger.dev->kobj, KOBJ_CHANGE);
609 }
586 610
587 if (sbs->manager_present) { 611 if (sbs->manager_present) {
588 for (id = 0; id < MAX_SBS_BAT; ++id) { 612 for (id = 0; id < MAX_SBS_BAT; ++id) {
@@ -598,12 +622,31 @@ static void acpi_sbs_callback(void *context)
598 } 622 }
599} 623}
600 624
625static int disable_sbs_manager(const struct dmi_system_id *d)
626{
627 sbs_manager_broken = true;
628 return 0;
629}
630
631static struct dmi_system_id acpi_sbs_dmi_table[] = {
632 {
633 .callback = disable_sbs_manager,
634 .ident = "Apple",
635 .matches = {
636 DMI_MATCH(DMI_SYS_VENDOR, "Apple Inc.")
637 },
638 },
639 { },
640};
641
601static int acpi_sbs_add(struct acpi_device *device) 642static int acpi_sbs_add(struct acpi_device *device)
602{ 643{
603 struct acpi_sbs *sbs; 644 struct acpi_sbs *sbs;
604 int result = 0; 645 int result = 0;
605 int id; 646 int id;
606 647
648 dmi_check_system(acpi_sbs_dmi_table);
649
607 sbs = kzalloc(sizeof(struct acpi_sbs), GFP_KERNEL); 650 sbs = kzalloc(sizeof(struct acpi_sbs), GFP_KERNEL);
608 if (!sbs) { 651 if (!sbs) {
609 result = -ENOMEM; 652 result = -ENOMEM;
@@ -619,17 +662,24 @@ static int acpi_sbs_add(struct acpi_device *device)
619 device->driver_data = sbs; 662 device->driver_data = sbs;
620 663
621 result = acpi_charger_add(sbs); 664 result = acpi_charger_add(sbs);
622 if (result) 665 if (result && result != -ENODEV)
623 goto end; 666 goto end;
624 667
625 result = acpi_manager_get_info(sbs); 668 result = 0;
626 if (!result) { 669
627 sbs->manager_present = 1; 670 if (!sbs_manager_broken) {
628 for (id = 0; id < MAX_SBS_BAT; ++id) 671 result = acpi_manager_get_info(sbs);
629 if ((sbs->batteries_supported & (1 << id))) 672 if (!result) {
630 acpi_battery_add(sbs, id); 673 sbs->manager_present = 0;
631 } else 674 for (id = 0; id < MAX_SBS_BAT; ++id)
675 if ((sbs->batteries_supported & (1 << id)))
676 acpi_battery_add(sbs, id);
677 }
678 }
679
680 if (!sbs->manager_present)
632 acpi_battery_add(sbs, 0); 681 acpi_battery_add(sbs, 0);
682
633 acpi_smbus_register_callback(sbs->hc, acpi_sbs_callback, sbs); 683 acpi_smbus_register_callback(sbs->hc, acpi_sbs_callback, sbs);
634 end: 684 end:
635 if (result) 685 if (result)
diff --git a/drivers/acpi/sleep.c b/drivers/acpi/sleep.c
index 54da4a3fe65e..05a31b573fc3 100644
--- a/drivers/acpi/sleep.c
+++ b/drivers/acpi/sleep.c
@@ -14,6 +14,7 @@
14#include <linux/irq.h> 14#include <linux/irq.h>
15#include <linux/dmi.h> 15#include <linux/dmi.h>
16#include <linux/device.h> 16#include <linux/device.h>
17#include <linux/interrupt.h>
17#include <linux/suspend.h> 18#include <linux/suspend.h>
18#include <linux/reboot.h> 19#include <linux/reboot.h>
19#include <linux/acpi.h> 20#include <linux/acpi.h>
@@ -626,6 +627,19 @@ static int acpi_freeze_begin(void)
626 return 0; 627 return 0;
627} 628}
628 629
630static int acpi_freeze_prepare(void)
631{
632 acpi_enable_all_wakeup_gpes();
633 enable_irq_wake(acpi_gbl_FADT.sci_interrupt);
634 return 0;
635}
636
637static void acpi_freeze_restore(void)
638{
639 disable_irq_wake(acpi_gbl_FADT.sci_interrupt);
640 acpi_enable_all_runtime_gpes();
641}
642
629static void acpi_freeze_end(void) 643static void acpi_freeze_end(void)
630{ 644{
631 acpi_scan_lock_release(); 645 acpi_scan_lock_release();
@@ -633,6 +647,8 @@ static void acpi_freeze_end(void)
633 647
634static const struct platform_freeze_ops acpi_freeze_ops = { 648static const struct platform_freeze_ops acpi_freeze_ops = {
635 .begin = acpi_freeze_begin, 649 .begin = acpi_freeze_begin,
650 .prepare = acpi_freeze_prepare,
651 .restore = acpi_freeze_restore,
636 .end = acpi_freeze_end, 652 .end = acpi_freeze_end,
637}; 653};
638 654
diff --git a/drivers/acpi/utils.c b/drivers/acpi/utils.c
index 07c8c5a5ee95..834f35c4bf8d 100644
--- a/drivers/acpi/utils.c
+++ b/drivers/acpi/utils.c
@@ -661,7 +661,6 @@ EXPORT_SYMBOL(acpi_evaluate_dsm);
661 * @uuid: UUID of requested functions, should be 16 bytes at least 661 * @uuid: UUID of requested functions, should be 16 bytes at least
662 * @rev: revision number of requested functions 662 * @rev: revision number of requested functions
663 * @funcs: bitmap of requested functions 663 * @funcs: bitmap of requested functions
664 * @exclude: excluding special value, used to support i915 and nouveau
665 * 664 *
666 * Evaluate device's _DSM method to check whether it supports requested 665 * Evaluate device's _DSM method to check whether it supports requested
667 * functions. Currently only support 64 functions at maximum, should be 666 * functions. Currently only support 64 functions at maximum, should be
diff --git a/drivers/acpi/video.c b/drivers/acpi/video.c
index 8e7e18567ae6..807a88a0f394 100644
--- a/drivers/acpi/video.c
+++ b/drivers/acpi/video.c
@@ -411,12 +411,6 @@ static int __init video_set_bqc_offset(const struct dmi_system_id *d)
411 return 0; 411 return 0;
412} 412}
413 413
414static int __init video_set_use_native_backlight(const struct dmi_system_id *d)
415{
416 use_native_backlight_dmi = true;
417 return 0;
418}
419
420static int __init video_disable_native_backlight(const struct dmi_system_id *d) 414static int __init video_disable_native_backlight(const struct dmi_system_id *d)
421{ 415{
422 use_native_backlight_dmi = false; 416 use_native_backlight_dmi = false;
@@ -467,265 +461,6 @@ static struct dmi_system_id video_dmi_table[] __initdata = {
467 DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 7720"), 461 DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 7720"),
468 }, 462 },
469 }, 463 },
470 {
471 .callback = video_set_use_native_backlight,
472 .ident = "ThinkPad X230",
473 .matches = {
474 DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
475 DMI_MATCH(DMI_PRODUCT_VERSION, "ThinkPad X230"),
476 },
477 },
478 {
479 .callback = video_set_use_native_backlight,
480 .ident = "ThinkPad T430 and T430s",
481 .matches = {
482 DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
483 DMI_MATCH(DMI_PRODUCT_VERSION, "ThinkPad T430"),
484 },
485 },
486 {
487 .callback = video_set_use_native_backlight,
488 .ident = "ThinkPad T430",
489 .matches = {
490 DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
491 DMI_MATCH(DMI_PRODUCT_VERSION, "2349D15"),
492 },
493 },
494 {
495 .callback = video_set_use_native_backlight,
496 .ident = "ThinkPad T431s",
497 .matches = {
498 DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
499 DMI_MATCH(DMI_PRODUCT_VERSION, "20AACTO1WW"),
500 },
501 },
502 {
503 .callback = video_set_use_native_backlight,
504 .ident = "ThinkPad Edge E530",
505 .matches = {
506 DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
507 DMI_MATCH(DMI_PRODUCT_VERSION, "3259A2G"),
508 },
509 },
510 {
511 .callback = video_set_use_native_backlight,
512 .ident = "ThinkPad Edge E530",
513 .matches = {
514 DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
515 DMI_MATCH(DMI_PRODUCT_VERSION, "3259CTO"),
516 },
517 },
518 {
519 .callback = video_set_use_native_backlight,
520 .ident = "ThinkPad Edge E530",
521 .matches = {
522 DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
523 DMI_MATCH(DMI_PRODUCT_VERSION, "3259HJG"),
524 },
525 },
526 {
527 .callback = video_set_use_native_backlight,
528 .ident = "ThinkPad W530",
529 .matches = {
530 DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
531 DMI_MATCH(DMI_PRODUCT_VERSION, "ThinkPad W530"),
532 },
533 },
534 {
535 .callback = video_set_use_native_backlight,
536 .ident = "ThinkPad X1 Carbon",
537 .matches = {
538 DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
539 DMI_MATCH(DMI_PRODUCT_VERSION, "ThinkPad X1 Carbon"),
540 },
541 },
542 {
543 .callback = video_set_use_native_backlight,
544 .ident = "Lenovo Yoga 13",
545 .matches = {
546 DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
547 DMI_MATCH(DMI_PRODUCT_VERSION, "Lenovo IdeaPad Yoga 13"),
548 },
549 },
550 {
551 .callback = video_set_use_native_backlight,
552 .ident = "Lenovo Yoga 2 11",
553 .matches = {
554 DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
555 DMI_MATCH(DMI_PRODUCT_VERSION, "Lenovo Yoga 2 11"),
556 },
557 },
558 {
559 .callback = video_set_use_native_backlight,
560 .ident = "Thinkpad Helix",
561 .matches = {
562 DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
563 DMI_MATCH(DMI_PRODUCT_VERSION, "ThinkPad Helix"),
564 },
565 },
566 {
567 .callback = video_set_use_native_backlight,
568 .ident = "Dell Inspiron 7520",
569 .matches = {
570 DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
571 DMI_MATCH(DMI_PRODUCT_NAME, "Inspiron 7520"),
572 },
573 },
574 {
575 .callback = video_set_use_native_backlight,
576 .ident = "Acer Aspire 5733Z",
577 .matches = {
578 DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
579 DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 5733Z"),
580 },
581 },
582 {
583 .callback = video_set_use_native_backlight,
584 .ident = "Acer Aspire 5742G",
585 .matches = {
586 DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
587 DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 5742G"),
588 },
589 },
590 {
591 .callback = video_set_use_native_backlight,
592 .ident = "Acer Aspire V5-171",
593 .matches = {
594 DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
595 DMI_MATCH(DMI_PRODUCT_NAME, "V5-171"),
596 },
597 },
598 {
599 .callback = video_set_use_native_backlight,
600 .ident = "Acer Aspire V5-431",
601 .matches = {
602 DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
603 DMI_MATCH(DMI_PRODUCT_NAME, "Aspire V5-431"),
604 },
605 },
606 {
607 .callback = video_set_use_native_backlight,
608 .ident = "Acer Aspire V5-471G",
609 .matches = {
610 DMI_MATCH(DMI_BOARD_VENDOR, "Acer"),
611 DMI_MATCH(DMI_PRODUCT_NAME, "Aspire V5-471G"),
612 },
613 },
614 {
615 .callback = video_set_use_native_backlight,
616 .ident = "Acer TravelMate B113",
617 .matches = {
618 DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
619 DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate B113"),
620 },
621 },
622 {
623 .callback = video_set_use_native_backlight,
624 .ident = "Acer Aspire V5-572G",
625 .matches = {
626 DMI_MATCH(DMI_SYS_VENDOR, "Acer Aspire"),
627 DMI_MATCH(DMI_PRODUCT_VERSION, "V5-572G/Dazzle_CX"),
628 },
629 },
630 {
631 .callback = video_set_use_native_backlight,
632 .ident = "Acer Aspire V5-573G",
633 .matches = {
634 DMI_MATCH(DMI_SYS_VENDOR, "Acer Aspire"),
635 DMI_MATCH(DMI_PRODUCT_VERSION, "V5-573G/Dazzle_HW"),
636 },
637 },
638 {
639 .callback = video_set_use_native_backlight,
640 .ident = "ASUS Zenbook Prime UX31A",
641 .matches = {
642 DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
643 DMI_MATCH(DMI_PRODUCT_NAME, "UX31A"),
644 },
645 },
646 {
647 .callback = video_set_use_native_backlight,
648 .ident = "HP ProBook 4340s",
649 .matches = {
650 DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
651 DMI_MATCH(DMI_PRODUCT_VERSION, "HP ProBook 4340s"),
652 },
653 },
654 {
655 .callback = video_set_use_native_backlight,
656 .ident = "HP ProBook 4540s",
657 .matches = {
658 DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
659 DMI_MATCH(DMI_PRODUCT_VERSION, "HP ProBook 4540s"),
660 },
661 },
662 {
663 .callback = video_set_use_native_backlight,
664 .ident = "HP ProBook 2013 models",
665 .matches = {
666 DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
667 DMI_MATCH(DMI_PRODUCT_NAME, "HP ProBook "),
668 DMI_MATCH(DMI_PRODUCT_NAME, " G1"),
669 },
670 },
671 {
672 .callback = video_set_use_native_backlight,
673 .ident = "HP EliteBook 2013 models",
674 .matches = {
675 DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
676 DMI_MATCH(DMI_PRODUCT_NAME, "HP EliteBook "),
677 DMI_MATCH(DMI_PRODUCT_NAME, " G1"),
678 },
679 },
680 {
681 .callback = video_set_use_native_backlight,
682 .ident = "HP EliteBook 2014 models",
683 .matches = {
684 DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
685 DMI_MATCH(DMI_PRODUCT_NAME, "HP EliteBook "),
686 DMI_MATCH(DMI_PRODUCT_NAME, " G2"),
687 },
688 },
689 {
690 .callback = video_set_use_native_backlight,
691 .ident = "HP ZBook 14",
692 .matches = {
693 DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
694 DMI_MATCH(DMI_PRODUCT_NAME, "HP ZBook 14"),
695 },
696 },
697 {
698 .callback = video_set_use_native_backlight,
699 .ident = "HP ZBook 15",
700 .matches = {
701 DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
702 DMI_MATCH(DMI_PRODUCT_NAME, "HP ZBook 15"),
703 },
704 },
705 {
706 .callback = video_set_use_native_backlight,
707 .ident = "HP ZBook 17",
708 .matches = {
709 DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
710 DMI_MATCH(DMI_PRODUCT_NAME, "HP ZBook 17"),
711 },
712 },
713 {
714 .callback = video_set_use_native_backlight,
715 .ident = "HP EliteBook 8470p",
716 .matches = {
717 DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
718 DMI_MATCH(DMI_PRODUCT_NAME, "HP EliteBook 8470p"),
719 },
720 },
721 {
722 .callback = video_set_use_native_backlight,
723 .ident = "HP EliteBook 8780w",
724 .matches = {
725 DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
726 DMI_MATCH(DMI_PRODUCT_NAME, "HP EliteBook 8780w"),
727 },
728 },
729 464
730 /* 465 /*
731 * These models have a working acpi_video backlight control, and using 466 * These models have a working acpi_video backlight control, and using
@@ -1419,6 +1154,23 @@ acpi_video_device_bind(struct acpi_video_bus *video,
1419 } 1154 }
1420} 1155}
1421 1156
1157static bool acpi_video_device_in_dod(struct acpi_video_device *device)
1158{
1159 struct acpi_video_bus *video = device->video;
1160 int i;
1161
1162 /* If we have a broken _DOD, no need to test */
1163 if (!video->attached_count)
1164 return true;
1165
1166 for (i = 0; i < video->attached_count; i++) {
1167 if (video->attached_array[i].bind_info == device)
1168 return true;
1169 }
1170
1171 return false;
1172}
1173
1422/* 1174/*
1423 * Arg: 1175 * Arg:
1424 * video : video bus device 1176 * video : video bus device
@@ -1858,6 +1610,15 @@ static void acpi_video_dev_register_backlight(struct acpi_video_device *device)
1858 static int count; 1610 static int count;
1859 char *name; 1611 char *name;
1860 1612
1613 /*
1614 * Do not create backlight device for video output
1615 * device that is not in the enumerated list.
1616 */
1617 if (!acpi_video_device_in_dod(device)) {
1618 dev_dbg(&device->dev->dev, "not in _DOD list, ignore\n");
1619 return;
1620 }
1621
1861 result = acpi_video_init_brightness(device); 1622 result = acpi_video_init_brightness(device);
1862 if (result) 1623 if (result)
1863 return; 1624 return;
diff --git a/drivers/acpi/video_detect.c b/drivers/acpi/video_detect.c
index c42feb2bacd0..27c43499977a 100644
--- a/drivers/acpi/video_detect.c
+++ b/drivers/acpi/video_detect.c
@@ -174,6 +174,14 @@ static struct dmi_system_id video_detect_dmi_table[] = {
174 DMI_MATCH(DMI_PRODUCT_NAME, "Inspiron 5737"), 174 DMI_MATCH(DMI_PRODUCT_NAME, "Inspiron 5737"),
175 }, 175 },
176 }, 176 },
177 {
178 .callback = video_detect_force_vendor,
179 .ident = "Lenovo IdeaPad Z570",
180 .matches = {
181 DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
182 DMI_MATCH(DMI_PRODUCT_VERSION, "Ideapad Z570"),
183 },
184 },
177 { }, 185 { },
178}; 186};
179 187