[patch] ICH7 SCI_EN quirk required for Macbook

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello

((apologies to everyone receiving this for a second time -- I messed up
the original posting quite badly by mailing to the wrong place))

I've been working on getting my Macbook to sleep and wake up properly
lately.  This email directly follows my earlier posting to the
linux-acpi list on the same subject ::

http://marc.theaimsgroup.com/?l=linux-acpi&m=114957637501557&w=2

The problem is that on resume the SCI_EN bit of the hardware power
management control register is not set.  This causes an endless stream
of unacknowledged IRQ9s.  This causes the kernel to ignore IRQ9 and
prevents ACPI from working.

Fixing the problem is as simple as re-enabling the SCI_EN bit early in
the resume process (before IRQs are enabled).

To this end,  I've written a patch that enables the SCI_EN bit soon
after resume on machines that need it (I do it for all ICH7-based Intel
Apple machines since an email from Frederic Riss tells me that he has
similar problems with his Mac Mini and my hack fixed it for him too).

Cheers

-------

This patch enables the SCI_EN bit on return from sleep on Intel-based
Apple machines with the ICH7 chipset (where for some reason this bit
gets disabled by sleep).  This is required to prevent an endless stream
of unacknowledged IRQ9s.

Signed-off-by: Ryan Lortie <[email protected]>
---
 drivers/acpi/sleep/main.c |   31 +++++++++++++++++++++++++++++++
 1 file changed, 31 insertions(+)
diff -urp linux-2.6.17-rc6/drivers/acpi/sleep/main.c linux-2.6.17-rc6+/drivers/acpi/sleep/main.c
--- linux-2.6.17-rc6/drivers/acpi/sleep/main.c	2006-06-11 13:41:53.000000000 -0400
+++ linux-2.6.17-rc6+/drivers/acpi/sleep/main.c	2006-06-11 13:42:11.000000000 -0400
@@ -17,6 +17,7 @@
 #include <linux/suspend.h>
 #include <acpi/acpi_bus.h>
 #include <acpi/acpi_drivers.h>
+#include <linux/pci.h>
 #include "sleep.h"
 
 u8 sleep_states[ACPI_S_STATE_COUNT];
@@ -34,6 +35,7 @@ static u32 acpi_suspend_states[] = {
 };
 
 static int init_8259A_after_S1;
+static int ich7_sci_en_quirk_enabled;
 
 /**
  *	acpi_pm_prepare - Do preliminary suspend work.
@@ -92,6 +94,10 @@ static int acpi_pm_enter(suspend_state_t
 
 	case PM_SUSPEND_MEM:
 		do_suspend_lowlevel();
+
+		if (ich7_sci_en_quirk_enabled)
+			acpi_set_register(ACPI_BITREG_SCI_ENABLE, 1,
+					  ACPI_MTX_DO_NOT_LOCK);
 		break;
 
 	case PM_SUSPEND_DISK:
@@ -183,12 +189,37 @@ static int __init init_ints_after_s1(str
 	return 0;
 }
 
+/*
+ * Apple Macbook comes back from sleep with the SCI_EN bit disabled
+ * causing a flood of unacknowledged IRQ9s.  We need to set SCI_EN
+ * as soon as we come back.
+ */
+static int __init init_ich7_sci_en_quirk(struct dmi_system_id *d)
+{
+	/* Ensure that we have an ICH7 (this is subdevice :1f.0) */
+	if (NULL == pci_find_device(PCI_VENDOR_ID_INTEL,
+				    PCI_DEVICE_ID_INTEL_ICH7_1, NULL))
+		return 0;
+
+	/* Intel-based Apple with ICH7 chipset.  Enable the quirk. */
+	printk(KERN_WARNING "%s detected (ICH7 SCI_EN quirk enabled)\n",
+	       d->ident);
+	ich7_sci_en_quirk_enabled = 1;
+
+	return 0;
+}
+
 static struct dmi_system_id __initdata acpisleep_dmi_table[] = {
 	{
 	 .callback = init_ints_after_s1,
 	 .ident = "Toshiba Satellite 4030cdt",
 	 .matches = {DMI_MATCH(DMI_PRODUCT_NAME, "S4030CDT/4.3"),},
 	 },
+	{
+	 .callback = init_ich7_sci_en_quirk,
+	 .ident = "Intel Apple",
+	 .matches = {DMI_MATCH(DMI_SYS_VENDOR, "Apple Computer"),},
+	 },
 	{},
 };
 

Attachment: signature.asc
Description: This is a digitally signed message part


[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux