Jump to content

DSDT Patches for T420


Manwe150
 Share

7 posts in this topic

Recommended Posts

I've previously posted on how to turn a Lenovo T420 into a Hackintosh (http://www.insanelym...l=&fromsearch=1), including that a custom DSDT is required to get it working. Here's what I edited in my DSDT. I will try to post a few links at the bottom to sites that I found useful, but I can't possibly remember to credit everyone who has posted useful information in the creation of my DSDT. This assumes you already have a system setup like mine, including a smbios.plist from a MPB8,1 (or newer), and a new version of Chameleon/Chimera with the typical flags enabled (mine include: GraphicsEnabler YES, EthernetBuiltIn YES, UseKernelCache YES, GenerateCStates YES, GeneratePStates YES)

 

 

Several of these hacks require a method DTGP available to it. So, if you don't already have it, add the following somewhere in the top level of the DefinitionBlock (typically at the beginning or end of the file).

Method (DTGP, 5, NotSerialized)
{
	If (LEqual (Arg0, Buffer (0x10)
			{
				/* 0000 */	0xC6, 0xB7, 0xB5, 0xA0, 0x18, 0x13, 0x1C, 0x44,
				/* 0008 */	0xB0, 0xC9, 0xFE, 0x69, 0x5E, 0xAF, 0x94, 0x9B
			}))
	{
		If (LEqual (Arg1, One))
		{
			If (LEqual (Arg2, Zero))
			{
				Store (Buffer (One)
					{
						0x03
					}, Arg4)
				Return (One)
			}
			If (LEqual (Arg2, One))
			{
				Return (One)
			}
		}
	}
	Store (Buffer (One)
		{
			0x00
		}, Arg4)
	Return (Zero)
}

 

 

To enable the backlight control, we just need to tell the OS about it. All that requires is adding the following block in Scope _SB:

Scope (_SB)
{
...
	Device (PNLF)
	{
		Name (_HID, EisaId ("APP0002"))
		Name (_CID, "backlight")
		Name (_UID, 0x0A)
		Name (_STA, 0x0B)
	}

This does not fix the Fn-Home / Fn-End shortcuts, so you will want to assign those separately in the Keyboard control panel (I use PrtSc / SclLk). Sections _Q14 and _Q15 should correspond to the those events, but I haven't found a way to get Mac to recognize the keypresses.

 

To enable sleep (and fix some USB issues with being flaky), we need to add some information to the EHC1 and ECH2 devices. Put this somewhere in each of those blocks (set the value for AAPL,clock-id to 0x02 for the second one)



			Method (_DSM, 4, NotSerialized)
			{
				Store (Package (0x13)
					{
						"device-id",
						Buffer (0x04)
						{
							0x26, 0x1C, 0x00, 0x00
						},
						"built-in",
						Buffer (One)
						{
							0x00
						},
						"AAPL,clock-id",
						Buffer (One)
						{
							0x01
						},
						"device_type",
						Buffer (0x05)
						{
							"EHCI"
						},
						"AAPL,current-available",
						0x0834,
						"AAPL,current-extra",
						0x0898,
						"AAPL,current-extra-in-sleep",
						0x0640,
						"AAPL,device-internal",
						0x02,
						"AAPL,max-port-current-in-sleep",
						0x0834,
						Buffer (One)
						{
							0x00
						}
					}, Local0)
				DTGP (Arg0, Arg1, Arg2, Arg3, RefOf (Local0))
				Return (Local0)
			}

 

Next, we'll enable the thermal sensor and fan readout. Add the missing parts of the ThermalZone block (you will already have some of it).

 


 ThermalZone (THM0)
	{
		Method (_CRT, 0, NotSerialized)
		{
			Return (TCRT)
		}
		Method (_PSV, 0, NotSerialized)
		{
			Return (TPSV)
		}
		Method (_TC1, 0, NotSerialized)
		{
			Return (TTC1)
		}
		Method (_TC2, 0, NotSerialized)
		{
			Return (TTC2)
		}
		Method (_TSP, 0, NotSerialized)
		{
			Return (TTSP)
		}
		Method (_PSL, 0, NotSerialized)
		{
			If (And (PPMF, 0x01000000))
			{
				If (LEqual (PNHM, 0x000106E0))
				{
					Return (Package (0x08)
					{
						\_PR.CPU0,
						\_PR.CPU1,
						\_PR.CPU2,
						\_PR.CPU3,
						\_PR.CPU4,
						\_PR.CPU5,
						\_PR.CPU6,
						\_PR.CPU7
					})
				}
				Else
				{
					Return (Package (0x04)
					{
						\_PR.CPU0,
						\_PR.CPU1,
						\_PR.CPU2,
						\_PR.CPU3
					})
				}
			}
			Return (Package (0x01)
			{
				\_PR.CPU0
			})
		}
		Method (_TMP, 0, NotSerialized)
		{
			If (H8DR)
			{
				Store (\_SB.PCI0.LPC.EC.TMP0, Local0)
				Store (\_SB.PCI0.LPC.EC.TSL2, Local1)
				Store (\_SB.PCI0.LPC.EC.TSL3, Local2)
			}
			Else
			{
				Store (RBEC (0x78), Local0)
				Store (And (RBEC (0x8A), 0x7F), Local1)
				Store (And (RBEC (0x8B), 0x7F), Local2)
			}
			If (LEqual (Local0, 0x80))
			{
				Store (0x30, Local0)
			}
			If (Local2)
			{
				Return (C2K (0x80))
			}
			If (LNot (\_SB.PCI0.LPC.EC.HKEY.DHKC))
			{
				If (Local1)
				{
					Return (C2K (0x80))
				}
			}
			Return (C2K (Local0))
		}
	}
	Method (C2K, 1, NotSerialized)
	{
		Add (Multiply (Arg0, 0x0A), 0x0AAC, Local0)
		If (LLessEqual (Local0, 0x0AAC))
		{
			Store (0x0BB8, Local0)
		}
		If (LGreater (Local0, 0x0FAC))
		{
			Store (0x0BB8, Local0)
		}
		Return (Local0)
	}
}

 

And the following in Device LPC in Device PCI0 (e.g. right below Device TPM):


			Device (SMCD)
			{
				Name (_HID, "MONITOR")
				Method (FAN0, 0, NotSerialized)
				{
					Store (\_SB.PCI0.LPC.EC.HFN1, Local0)
					Return (Local0)
				}
				Method (TCPU, 0, NotSerialized)
				{
					Store (\_SB.PCI0.LPC.EC.TMP0, Local0)
					Return (Local0)
				}
			}

We still have to tell the DSDT about how to read the fan speed, so add the following to Device EC after the large ECOR field:


				Field (ECOR, ByteAcc, NoLock, Preserve)
				{
							Offset (0x84),
					HFN1, 16
				}

Once booted, install ACPISensors.kext (change the IONameMatch to MONITOR) and IntelCPUMonitor.kext (and the corresponding version of FakeSMC.kext). The download link for this package is below. Then use iStat or HWMonitor.app to view the information.

 

 

If you have a high resolution monitor, you will need the following DualLink information in your VID section. (It has no negative effect if you happen not to need it).


		Device (VID)
		{
			Name (_ADR, 0x00020000)


			Method (_DSM, 4, NotSerialized)
			{
				Store (Package (0x06)
					{
						"AAPL00,DualLink",
						Buffer (0x04)
						{
							0x01, 0x00, 0x00, 0x00
						},
						"hda-gfx",
						Buffer (0x0A)
						{
							"onboard-2"
						},
						"model",
						Buffer (0x18)
						{
							"Intel HD Graphics 3000"
						},
					}, Local0)
				DTGP (Arg0, Arg1, Arg2, Arg3, RefOf (Local0))
				Return (Local0)
			}

 

Next, it's easiest just to delete the HDEF device section entirely. That way we can leave AppleHDA in place and just install VoodooHDA, without getting a KP.


//			 Device (HDEF)
//			 {
//			 }

EDIT: there is now a patched AppleHDA that works. Replace HDEF section with below, and install replacement AppleHDA.kext from http://www.mediafire...ey7744p264ord1q



		Device (HDEF)
		{
			Name (_ADR, 0x001B0000)
			Name (_S3D, 0x03)
			Name (RID, Zero)
			Name (_PRW, Package (0x02)
			{
				0x0D,
				0x04
			})
			Method (_PSW, 1, NotSerialized)
			{
				Noop
			}
			Method (_DSM, 4, NotSerialized)
			{
				Store (Package (0x0A)
					{
						"codec-id",
						Buffer (0x04)
						{
							0x6E, 0x50, 0xF1, 0x14
						},
						"layout-id",
						Buffer (0x04)
						{
							0x6E, 0x50, 0x00, 0x00
						},
						"PinConfigurations",
						Buffer (Zero) {},
						"hda-gfx",
						Buffer (0x0A)
						{
							"onboard-2"
						},
						"device-type",
						Buffer (0x11)
						{
							"Conexant CX20590"
						}
					}, Local0)
				DTGP (Arg0, Arg1, Arg2, Arg3, RefOf (Local0))
				Return (Local0)
			}
		}

 

I wanted to make sure my laptop would always be cool enough, so I added an option fan override section tied to the ThinkVantage button. This causes the ThinkVantage button to toggle the fan speed between high speed and auto with each click (not that there is a bit of a delay in fan response).


	Scope (PCI0.LPC.EC)
	{
		Method (_Q19, 0, NotSerialized)
		{
//				 If (^HKEY.MHKK (0x00800000))
//				 {
//					 ^HKEY.MHKQ (0x1018)
//				 }
//				 UCMS (0x03)				
			Name (FANS, One)
			Store (HFSP, FANS)
			XOr (FANS, 0x80, Local0)
			If (Local0)
			{
				Store (0x80, HFSP) //Fan speed auto
			}
			Else
			{
				Store (0x07, HFSP) //Fan speed 7
			}
		}
	}

 

We can also turn on some "advanced" features. I don't know what they do, but in Scope _SB, Method _INI, add the following lines to hardcode these values, since the DSDT doesn't know about darwin:

		Store (One, WNTF)
		Store (One, WXPF)
		Store (0x02, WSPV)
		Store (One, WVIS)

 

I have not been able to get the Fn key to work, I tried adding the following code in the KBD device section, but it seemed to have no effect.

				Name (_CID, EisaId ("PNP030B"))
				Method (_DSM, 4, NotSerialized)
				{
					Store (Package (0x02)
						{
							"AAPL,has-embedded-fn-keys",
							Buffer (0x04)
							{
								0x01, 0x00, 0x00, 0x00
							}
						}, Local0)
					DTGP (Arg0, Arg1, Arg2, Arg3, RefOf (Local0))
					Return (Local0)
				}

 

 

Recognize AC adapter (not technically necessary when using VoodooBattery.kext, but a good idea anyway)

Device (AC)
{
Name (_HID, "ACPI0003")
Name (_UID, 0x00)
/* Fix - Enable AppleACAdapter driver */
Name (_PRW, Package (0x02)
{
	 0x18,
	 0x03
})
/* Fix End */
Name (_PCL, Package (0x01)

 

http://www.insanelym...howtopic=273621 (similar system configuration)

http://www.projectos...?showtopic=1643 ( FakeSMC_plugins_Apps)

http://www.thinkwiki...p_configuration (Fn key HKEY.MHKQ map, can help with identifying buttons)

http://olarila.com/f...c.php?f=19&t=62 (DSDT Editor and Patcher, alternatively DSDTSE does the same thing)

http://www.insanelym...howtopic=274164 (several additional fixes)

 

 

----- EDIT 5/21/2012 ------

(see corresponding changes in system installation description thread

http://www.insanelym...l=&fromsearch=1)

- VGA output fixed

- Audio output fixed

 

 

----- EDIT 3/20/2012 ------

In Mountain Lion, we need GraphicsEnabler NO, or the system fails to load the display kexts

dsdt.manwe150.zip

Edited by Manwe150
  • Like 2
Link to comment
Share on other sites

  • 2 weeks later...
  • 2 months later...
  • 5 months later...

Thank you very much and I am able to use your file to make my T520 working...

 

 

The only thing I still haven't figure it out is how do you "

Brightness control enabled in Display Settings (PNLF). I then bound up/down to PrtSc/ScrLk to give me back keyboard control.."

 

More details?

Link to comment
Share on other sites

  • 2 months later...
 Share

×
×
  • Create New...