On Tue, Mar 11, 2014 at 02:08:55PM +0100, Andreas Noever wrote:

> That seems to do it. I was afraid that setting OSDW globally would
> affect other parts (USB?) But that does not seem to be the case.

I think it results in the USB ports coming up in XHCI mode by default, 
but we can handle that. There's one other thing - the battery switches 
from being a control method battery to being an SBS one, and Apple's 
implementation seems to break our driver. I've got a trivial patch that 
makes it work (attached).

> What is the reason for clearing the PME flag?

It looks like the PME flag gets cleared on the _OSC route in non-Darwin 
mode? I'll go back and check that to make sure.

-- 
Matthew Garrett | mj...@srcf.ucam.org
>From 2a8ffff11f91aad146916ca14c768ebc407865aa Mon Sep 17 00:00:00 2001
From: Matthew Garrett <matthew.garr...@nebula.com>
Date: Mon, 10 Mar 2014 14:44:55 -0400
Subject: [PATCH 21/28] ACPI: Don't re-select SBS battery if it's already
 selected

The existing SBS code explicitly sets the selected battery in the SBS
manager regardless of whether the battery in question is already selected.
This causes bus timeouts on Apple hardware. Check for this case and avoid
it.

Signed-off-by: Matthew Garrett <matthew.garr...@nebula.com>
---
 drivers/acpi/sbs.c | 18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)

diff --git a/drivers/acpi/sbs.c b/drivers/acpi/sbs.c
index dbd4849..c386505 100644
--- a/drivers/acpi/sbs.c
+++ b/drivers/acpi/sbs.c
@@ -470,17 +470,25 @@ static struct device_attribute alarm_attr = {
 static int acpi_battery_read(struct acpi_battery *battery)
 {
        int result = 0, saved_present = battery->present;
-       u16 state;
+       u16 state, selected, desired;
 
        if (battery->sbs->manager_present) {
                result = acpi_smbus_read(battery->sbs->hc, SMBUS_READ_WORD,
                                ACPI_SBS_MANAGER, 0x01, (u8 *)&state);
                if (!result)
                        battery->present = state & (1 << battery->id);
-               state &= 0x0fff;
-               state |= 1 << (battery->id + 12);
-               acpi_smbus_write(battery->sbs->hc, SMBUS_WRITE_WORD,
-                                 ACPI_SBS_MANAGER, 0x01, (u8 *)&state, 2);
+               /*
+                * Don't switch battery if the correct one is already selected
+                */
+               selected = state & 0xf000;
+               desired = 1 << (battery->id + 12);
+               if (selected != desired) {
+                       state &= 0x0fff;
+                       state |= desired;
+                       acpi_smbus_write(battery->sbs->hc, SMBUS_WRITE_WORD,
+                                        ACPI_SBS_MANAGER, 0x01,
+                                        (u8 *)&state, 2);
+               }
        } else if (battery->id == 0)
                battery->present = 1;
        if (result || !battery->present)
-- 
1.8.5.3

Reply via email to