[ltp] [ACPI] Thinkpad radeon_pm.c patches (T40 2373-8CG with this setup is not affected by the power drain)

Pete Toscano linux-thinkpad@linux-thinkpad.org
Fri, 11 Feb 2005 18:39:27 -0500


This is a MIME-formatted message.  If you see this text it means that your
E-mail software does not support MIME-formatted messages.

--=_cliffie-30207-1108165197-0001-2
Content-Type: text/plain; charset=iso-8859-1; format=flowed
Content-Transfer-Encoding: 8bit

Here's the latest radeonfb-thinkpad-pm.patch I have (from Volker's 
kernel-T4x-2.6.11-12 SRPM) with the exta stanzas added in.

I just compiled it up and it works on my Thinkpad (T40 2373-94U).  I 
can't vouch for the others.

I'll contact Volker directly to see if he wants to incorporate this file 
along with some other minor tweaks I made (ipw2100 AND ipw2200, ibm-acpi 
0.10.0, removed APIC for UP systems) into his next (S)RPMS.

pete


Peter Frühberger wrote:
> Jerome Poggi wrote:
> 
>>>On Sat, 05 Feb 2005, obi wrote:
>>>
>>>
>>>>Good idea: here is mine
>>>>
>>>>	.ident = "IBM ThinkPad T41 (2378-DEU)",
>>>>	.matches = {
>>>>		DMI_MATCH(DMI_SYS_VENDOR, "IBM"),
>>>>		DMI_MATCH(DMI_PRODUCT_NAME, "2378DEU"),
>>>>	},
>>>
>>>
>>>see mine :
>>>
>>>                .ident = "IBM ThinkPad T42 (2373-FWG)",
>>>                .matches = {
>>>                        DMI_MATCH(DMI_SYS_VENDOR, "IBM"),
>>>                        DMI_MATCH(DMI_PRODUCT_NAME, "2373FWG"),
>>>                },
>>>
>>>Jerome.
> 
> 
> and my R40, as written on the bugpage:
> 
>               .ident = "IBM ThinkPad R40 (2722-B3G)",
>               .matches = {
>                       DMI_MATCH(DMI_SYS_VENDOR, "IBM"),
>                       DMI_MATCH(DMI_PRODUCT_NAME, "2722B3G"),
>               },
>  Peter

--=_cliffie-30207-1108165197-0001-2
Content-Type: text/plain; name="radeonfb-thinkpad-pm-4pt2.patch"; charset=iso-8859-1
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="radeonfb-thinkpad-pm-4pt2.patch"

Only in linux-2.6.10/drivers/video/aty: built-in.o
Only in linux-2.6.10/drivers/video/aty: .built-in.o.cmd
Only in linux-2.6.10/drivers/video/aty: radeon_accel.o
Only in linux-2.6.10/drivers/video/aty: .radeon_accel.o.cmd
diff -u linux-2.6.10-med/drivers/video/aty/radeon_base.c linux-2.6.10/drivers/video/aty/radeon_base.c
--- linux-2.6.10-med/drivers/video/aty/radeon_base.c	2005-02-03 11:52:02.000000000 -0500
+++ linux-2.6.10/drivers/video/aty/radeon_base.c	2005-02-03 13:13:42.256437916 -0500
@@ -273,6 +273,9 @@
 #ifdef CONFIG_MTRR
 static int nomtrr = 0;
 #endif
+#if defined(CONFIG_PM) && defined(CONFIG_X86)
+int radeon_force_sleep = 0;
+#endif
 
 /*
  * prototypes
@@ -2531,6 +2534,10 @@
 			force_measure_pll = 1;
 		} else if (!strncmp(this_opt, "ignore_edid", 11)) {
 			ignore_edid = 1;
+#if defined(CONFIG_PM) && defined(CONFIG_X86)
+		} else if (!strncmp(this_opt, "force_sleep", 11)) {
+			radeon_force_sleep = 1;
+#endif
 		} else
 			mode_option = this_opt;
 	}
@@ -2570,3 +2577,5 @@
 MODULE_PARM_DESC(panel_yres, "int: set panel yres");
 module_param(mode_option, charp, 0);
 MODULE_PARM_DESC(mode_option, "Specify resolution as \"<xres>x<yres>[-<bpp>][@<refresh>]\" ");
+module_param(radeon_force_sleep, int, 0);
+MODULE_PARM_DESC(radeon_force_sleep, "bool: force ACPI sleep mode on untested machines");
Only in linux-2.6.10/drivers/video/aty: radeon_base.o
Only in linux-2.6.10/drivers/video/aty: .radeon_base.o.cmd
Only in linux-2.6.10/drivers/video/aty: radeonfb.o
Only in linux-2.6.10/drivers/video/aty: .radeonfb.o.cmd
Only in linux-2.6.10/drivers/video/aty: radeon_i2c.o
Only in linux-2.6.10/drivers/video/aty: .radeon_i2c.o.cmd
Only in linux-2.6.10/drivers/video/aty: radeon_monitor.o
Only in linux-2.6.10/drivers/video/aty: .radeon_monitor.o.cmd
diff -u linux-2.6.10-med/drivers/video/aty/radeon_pm.c linux-2.6.10/drivers/video/aty/radeon_pm.c
--- linux-2.6.10-med/drivers/video/aty/radeon_pm.c	2005-02-03 11:52:02.000000000 -0500
+++ linux-2.6.10/drivers/video/aty/radeon_pm.c	2005-02-03 13:05:40.000000000 -0500
@@ -25,8 +25,83 @@
 #include <asm/pmac_feature.h>
 #endif
 
+/* For detecting supported PC laptops */
+#ifdef CONFIG_X86
+#include <linux/dmi.h>
+#endif
+
 #include "ati_ids.h"
 
+#ifdef CONFIG_X86
+/* This array holds a list of supported PC laptops.
+ * Currently only few IBM models are tested.
+ * If you want to experiment, use dmidecode to find out
+ * vendor and product codes for Your laptop.
+ */
+static struct dmi_system_id __devinitdata radeonfb_dmi_table[] = {
+	{
+		.ident = "IBM ThinkPad R40 (2722-B3G)",
+		.matches = {
+			DMI_MATCH(DMI_SYS_VENDOR, "IBM"),
+			DMI_MATCH(DMI_PRODUCT_NAME, "2722B3G"),
+		},
+	},
+	{
+		.ident = "IBM ThinkPad T40 (2373-92G)",
+		.matches = {
+			DMI_MATCH(DMI_SYS_VENDOR, "IBM"),
+			DMI_MATCH(DMI_PRODUCT_NAME, "237392G"),
+  	      },
+	},
+	{
+		.ident = "IBM ThinkPad T40 (2373-8CG)",
+		.matches = {
+			DMI_MATCH(DMI_SYS_VENDOR, "IBM"),
+			DMI_MATCH(DMI_PRODUCT_NAME, "23738CG"),
+		},
+	},
+	{
+		.ident = "IBM ThinkPad T40 (2373-94U)",
+		.matches = {
+			DMI_MATCH(DMI_SYS_VENDOR, "IBM"),
+			DMI_MATCH(DMI_PRODUCT_NAME, "237394U"),
+		},
+	},
+	{
+		.ident = "IBM ThinkPad T41 (2373-2FG)",
+		.matches = {
+			DMI_MATCH(DMI_SYS_VENDOR, "IBM"),
+			DMI_MATCH(DMI_PRODUCT_NAME, "23732FG"),
+		},
+	},
+	{
+		.ident = "IBM ThinkPad T41 (2378-DEU)",
+		.matches = {
+			DMI_MATCH(DMI_SYS_VENDOR, "IBM"),
+			DMI_MATCH(DMI_PRODUCT_NAME, "2378DEU"),
+		},
+	},
+	{
+		/* Reported by Volker Braun <vbraun@physics.upenn.edu> */
+		.ident = "IBM ThinkPad T41 (2379-DJU)",
+		.matches = {
+			DMI_MATCH(DMI_SYS_VENDOR, "IBM"),
+			DMI_MATCH(DMI_PRODUCT_NAME, "2379DJU"),
+		},
+	},
+	{
+		.ident = "IBM ThinkPad T42 (2373-FWG)",
+		.matches = {
+			DMI_MATCH(DMI_SYS_VENDOR, "IBM"),
+			DMI_MATCH(DMI_PRODUCT_NAME, "2373FWG"),
+		},
+	},
+	{ },
+};
+
+extern int radeon_force_sleep;
+#endif
+
 void radeon_pm_disable_dynamic_mode(struct radeonfb_info *rinfo)
 {
 	u32 tmp;
@@ -853,6 +928,13 @@
 	tmp = INPLL( pllMCLK_MISC) | MCLK_MISC__EN_MCLK_TRISTATE_IN_SUSPEND;
 	OUTPLL( pllMCLK_MISC, tmp);
 	
+ 	/* BUS_CNTL1__MOBILE_PLATORM_SEL setting is northbridge chipset
+ 	 * and radeon chip dependent. Thus we only enable it on Mac for
+ 	 * now (until we get more info on how to compute the correct 
+ 	 * value for various X86 bridges).
+ 	 */
+ 
+#ifdef CONFIG_PPC_PMAC
 	/* AGP PLL control */
 	if (rinfo->family <= CHIP_FAMILY_RV280) {
 		OUTREG(BUS_CNTL1, INREG(BUS_CNTL1) |  BUS_CNTL1__AGPCLK_VALID);
@@ -864,6 +946,7 @@
 		OUTREG(BUS_CNTL1, INREG(BUS_CNTL1));
 		OUTREG(BUS_CNTL1, (INREG(BUS_CNTL1) & ~0x4000) | 0x8000);
 	}
+#endif
 
 	OUTREG(CRTC_OFFSET_CNTL, (INREG(CRTC_OFFSET_CNTL)
 				  & ~CRTC_OFFSET_CNTL__CRTC_STEREO_SYNC_OUT_EN));
@@ -2748,6 +2831,29 @@
 		OUTREG(TV_DAC_CNTL, INREG(TV_DAC_CNTL) | 0x07000000);
 	}
 #endif /* defined(CONFIG_PM) && defined(CONFIG_PPC_OF) */
+
+/* The PM code also works on some PC laptops.
+ * Only a few models are actually tested so Your mileage may vary.
+ * We can do D2 on at least M7 and M9 on some IBM ThinkPad T41 models.
+ */
+#if defined(CONFIG_PM) && defined(CONFIG_X86)
+	if (radeon_force_sleep || dmi_check_system(radeonfb_dmi_table)) {
+		if (radeon_force_sleep)
+			printk("radeonfb: forcefully enabling sleep mode\n");
+		else
+			printk("radeonfb: enabling sleep mode\n");
+
+		if (rinfo->is_mobility && rinfo->pm_reg &&
+		    rinfo->family <= CHIP_FAMILY_RV250)
+			rinfo->pm_mode |= radeon_pm_d2;
+
+		/* Power down TV DAC, that saves a significant amount of power,
+		 * we'll have something better once we actually have some TVOut
+		 * support
+		 */
+		OUTREG(TV_DAC_CNTL, INREG(TV_DAC_CNTL) | 0x07000000);
+	}
+#endif /* defined(CONFIG_PM) && defined(CONFIG_X86) */
 }
 
 void radeonfb_pm_exit(struct radeonfb_info *rinfo)
Only in linux-2.6.10/drivers/video/aty: radeon_pm.c.rej
Only in linux-2.6.10/drivers/video/aty: radeon_pm.o
Only in linux-2.6.10/drivers/video/aty: .radeon_pm.o.cmd

--=_cliffie-30207-1108165197-0001-2--