[coreboot-gerrit] Patch set updated for coreboot: northbridge/intel/pineview: Add remaining boilerplate code for northbridge

Damien Zammit (damien@zamaudio.com) gerrit at coreboot.org
Fri Nov 20 15:24:38 CET 2015


Damien Zammit (damien at zamaudio.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/12430

-gerrit

commit cdb5358e416830135afec37c1dc7c3e90c59b106
Author: Damien Zammit <damien at zamaudio.com>
Date:   Sat Nov 14 00:59:21 2015 +1100

    northbridge/intel/pineview: Add remaining boilerplate code for northbridge
    
    This patch does *not* include native raminit
    
    Change-Id: I3fb8146ef7fe2ad27c167ecd2fb0fd629f051cc1
    Signed-off-by: Damien Zammit <damien at zamaudio.com>
---
 src/northbridge/intel/pineview/Kconfig             |   3 +-
 src/northbridge/intel/pineview/Makefile.inc        |   3 +
 src/northbridge/intel/pineview/acpi/hostbridge.asl | 234 ++++++++++
 src/northbridge/intel/pineview/acpi/igd.asl        | 432 +++++++++++++++++
 src/northbridge/intel/pineview/acpi/peg.asl        |  41 ++
 src/northbridge/intel/pineview/acpi/pineview.asl   |  78 ++++
 src/northbridge/intel/pineview/chip.h              |   8 +
 src/northbridge/intel/pineview/early_init.c        | 179 +++++++
 src/northbridge/intel/pineview/gma.c               | 520 +++++++++++++++++++++
 src/northbridge/intel/pineview/northbridge.c       | 286 ++++++++++++
 src/northbridge/intel/pineview/pineview.h          | 177 ++++++-
 src/northbridge/intel/pineview/ram_calc.c          |  68 +--
 12 files changed, 1998 insertions(+), 31 deletions(-)

diff --git a/src/northbridge/intel/pineview/Kconfig b/src/northbridge/intel/pineview/Kconfig
index 6253b84..e37f442 100644
--- a/src/northbridge/intel/pineview/Kconfig
+++ b/src/northbridge/intel/pineview/Kconfig
@@ -26,7 +26,8 @@ config NORTHBRIDGE_SPECIFIC_OPTIONS # dummy
 	select HAVE_DEBUG_RAM_SETUP
 	select LAPIC_MONOTONIC_TIMER
 	select VGA
-	select PER_DEVICE_ACPI_TABLES
+	select INTEL_GMA_ACPI
+	select LATE_CBMEM_INIT
 
 config BOOTBLOCK_NORTHBRIDGE_INIT
 	string
diff --git a/src/northbridge/intel/pineview/Makefile.inc b/src/northbridge/intel/pineview/Makefile.inc
index 9330b17..7275d70 100644
--- a/src/northbridge/intel/pineview/Makefile.inc
+++ b/src/northbridge/intel/pineview/Makefile.inc
@@ -17,8 +17,11 @@
 ifeq ($(CONFIG_NORTHBRIDGE_INTEL_PINEVIEW),y)
 
 ramstage-y += ram_calc.c
+ramstage-y += northbridge.c
+ramstage-y += gma.c
 ramstage-y += acpi.c
 
 romstage-y += ram_calc.c
+romstage-y += early_init.c
 
 endif
diff --git a/src/northbridge/intel/pineview/acpi/hostbridge.asl b/src/northbridge/intel/pineview/acpi/hostbridge.asl
new file mode 100644
index 0000000..747d7da
--- /dev/null
+++ b/src/northbridge/intel/pineview/acpi/hostbridge.asl
@@ -0,0 +1,234 @@
+/*
+ * This file is part of the coreboot project.
+ *
+ * Copyright (C) 2007-2009 coresystems GmbH
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; version 2 of
+ * the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#include <arch/ioapic.h>
+
+Name(_HID,EISAID("PNP0A08"))	// PCIe
+Name(_CID,EISAID("PNP0A03"))	// PCI
+
+Name(_ADR, 0)
+Name(_BBN, 0)
+
+Device (MCHC)
+{
+	Name(_ADR, 0x00000000)	// 0:0.0
+
+	OperationRegion(MCHP, PCI_Config, 0x00, 0x100)
+	Field (MCHP, DWordAcc, NoLock, Preserve)
+	{
+		Offset (0x40),	// EPBAR
+		EPEN,	 1,	// Enable
+		,	11,	//
+		EPBR,	24,	// EPBAR
+
+		Offset (0x48),	// MCHBAR
+		MHEN,	 1,	// Enable
+		,	13,	//
+		MHBR,	22,	// MCHBAR
+
+		Offset (0x60),	// PCIe BAR
+		PXEN,	 1,	// Enable
+		PXSZ,	 2,	// BAR size
+		,	23,	//
+		PXBR,	10,	// PCIe BAR
+
+		Offset (0x68),	// DMIBAR
+		DMEN,	 1,	// Enable
+		,	11,	//
+		DMBR,	20,	// DMIBAR
+
+		// ...
+
+		Offset (0x90),	// PAM0
+		,	 4,
+		PM0H,	 2,
+		,	 2,
+		Offset (0x91),	// PAM1
+		PM1L,	 2,
+		,	 2,
+		PM1H,	 2,
+		,	 2,
+		Offset (0x92),	// PAM2
+		PM2L,	 2,
+		,	 2,
+		PM2H,	 2,
+		,	 2,
+		Offset (0x93),	// PAM3
+		PM3L,	 2,
+		,	 2,
+		PM3H,	 2,
+		,	 2,
+		Offset (0x94),	// PAM4
+		PM4L,	 2,
+		,	 2,
+		PM4H,	 2,
+		,	 2,
+		Offset (0x95),	// PAM5
+		PM5L,	 2,
+		,	 2,
+		PM5H,	 2,
+		,	 2,
+		Offset (0x96),	// PAM6
+		PM6L,	 2,
+		,	 2,
+		PM6H,	 2,
+		,	 2,
+
+		Offset (0xa0),	// Top of Used Memory
+		TOM,	8,
+
+		Offset (0xb0),	// Top of Low Used Memory
+		,	 4,
+		TLUD,	12,
+
+	}
+
+}
+
+
+// Current Resource Settings
+Name (MCRS, ResourceTemplate()
+{
+	// Bus Numbers
+	WordBusNumber (ResourceProducer, MinFixed, MaxFixed, PosDecode,
+			0x0000, 0x0000, 0x00ff, 0x0000, 0x0100,,, PB00)
+
+	// IO Region 0
+	DWordIO (ResourceProducer, MinFixed, MaxFixed, PosDecode, EntireRange,
+			0x0000, 0x0000, 0x0cf7, 0x0000, 0x0cf8,,, PI00)
+
+	// PCI Config Space
+	Io (Decode16, 0x0cf8, 0x0cf8, 0x0001, 0x0008)
+
+	// IO Region 1
+	DWordIO (ResourceProducer, MinFixed, MaxFixed, PosDecode, EntireRange,
+			0x0000, 0x0d00, 0xffff, 0x0000, 0xf300,,, PI01)
+
+	// VGA memory (0xa0000-0xbffff)
+	DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed,
+			Cacheable, ReadWrite,
+			0x00000000, 0x000a0000, 0x000bffff, 0x00000000,
+			0x00020000,,, ASEG)
+
+	// OPROM reserved (0xc0000-0xc3fff)
+	DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed,
+			Cacheable, ReadWrite,
+			0x00000000, 0x000c0000, 0x000c3fff, 0x00000000,
+			0x00004000,,, OPR0)
+
+	// OPROM reserved (0xc4000-0xc7fff)
+	DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed,
+			Cacheable, ReadWrite,
+			0x00000000, 0x000c4000, 0x000c7fff, 0x00000000,
+			0x00004000,,, OPR1)
+
+	// OPROM reserved (0xc8000-0xcbfff)
+	DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed,
+			Cacheable, ReadWrite,
+			0x00000000, 0x000c8000, 0x000cbfff, 0x00000000,
+			0x00004000,,, OPR2)
+
+	// OPROM reserved (0xcc000-0xcffff)
+	DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed,
+			Cacheable, ReadWrite,
+			0x00000000, 0x000cc000, 0x000cffff, 0x00000000,
+			0x00004000,,, OPR3)
+
+	// OPROM reserved (0xd0000-0xd3fff)
+	DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed,
+			Cacheable, ReadWrite,
+			0x00000000, 0x000d0000, 0x000d3fff, 0x00000000,
+			0x00004000,,, OPR4)
+
+	// OPROM reserved (0xd4000-0xd7fff)
+	DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed,
+			Cacheable, ReadWrite,
+			0x00000000, 0x000d4000, 0x000d7fff, 0x00000000,
+			0x00004000,,, OPR5)
+
+	// OPROM reserved (0xd8000-0xdbfff)
+	DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed,
+			Cacheable, ReadWrite,
+			0x00000000, 0x000d8000, 0x000dbfff, 0x00000000,
+			0x00004000,,, OPR6)
+
+	// OPROM reserved (0xdc000-0xdffff)
+	DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed,
+			Cacheable, ReadWrite,
+			0x00000000, 0x000dc000, 0x000dffff, 0x00000000,
+			0x00004000,,, OPR7)
+
+	// BIOS Extension (0xe0000-0xe3fff)
+	DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed,
+			Cacheable, ReadWrite,
+			0x00000000, 0x000e0000, 0x000e3fff, 0x00000000,
+			0x00004000,,, ESG0)
+
+	// BIOS Extension (0xe4000-0xe7fff)
+	DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed,
+			Cacheable, ReadWrite,
+			0x00000000, 0x000e4000, 0x000e7fff, 0x00000000,
+			0x00004000,,, ESG1)
+
+	// BIOS Extension (0xe8000-0xebfff)
+	DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed,
+			Cacheable, ReadWrite,
+			0x00000000, 0x000e8000, 0x000ebfff, 0x00000000,
+			0x00004000,,, ESG2)
+
+	// BIOS Extension (0xec000-0xeffff)
+	DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed,
+			Cacheable, ReadWrite,
+			0x00000000, 0x000ec000, 0x000effff, 0x00000000,
+			0x00004000,,, ESG3)
+
+	// System BIOS (0xf0000-0xfffff)
+	DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed,
+			Cacheable, ReadWrite,
+			0x00000000, 0x000f0000, 0x000fffff, 0x00000000,
+			0x00010000,,, FSEG)
+
+	// PCI Memory Region (Top of memory-0xfebfffff)
+	DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed,
+			Cacheable, ReadWrite,
+			0x00000000, 0x00000000, 0xfebfffff, 0x00000000,
+			IO_APIC_ADDR,,, PM01)
+
+	// TPM Area (0xfed40000-0xfed44fff)
+	DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed,
+			Cacheable, ReadWrite,
+			0x00000000, 0xfed40000, 0xfed44fff, 0x00000000,
+			0x00005000,,, TPMR)
+})
+
+Method (_CRS, 0, Serialized)
+{
+	// Find PCI resource area in MCRS
+	CreateDwordField(MCRS, ^PM01._MIN, PMIN)
+	CreateDwordField(MCRS, ^PM01._MAX, PMAX)
+	CreateDwordField(MCRS, ^PM01._LEN, PLEN)
+
+	// Fix up PCI memory region:
+	// Enter actual TOLUD. The TOLUD register contains bits 27-31 of
+	// the top of memory address.
+	ShiftLeft (^MCHC.TLUD, 27, PMIN)
+	Add(Subtract(PMAX, PMIN), 1, PLEN)
+
+	Return (MCRS)
+}
+
+/* IRQ assignment is mainboard specific. Get it from mainboard ACPI code */
+#include "acpi/pineview_pci_irqs.asl"
diff --git a/src/northbridge/intel/pineview/acpi/igd.asl b/src/northbridge/intel/pineview/acpi/igd.asl
new file mode 100644
index 0000000..ca14c1d
--- /dev/null
+++ b/src/northbridge/intel/pineview/acpi/igd.asl
@@ -0,0 +1,432 @@
+/*
+ * This file is part of the coreboot project.
+ *
+ * Copyright (C) 2007-2009 coresystems GmbH
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; version 2 of
+ * the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+Device (GFX0)
+{
+	Name (_ADR, 0x00020000)
+
+	OperationRegion (GFXC, PCI_Config, 0x00, 0x0100)
+	Field (GFXC, DWordAcc, NoLock, Preserve)
+	{
+		Offset (0x10),
+			BAR0, 64
+	}
+
+	OperationRegion (GFRG, SystemMemory, And (BAR0, 0xfffffffffffffff0), 0x400000)
+	Field (GFRG, DWordAcc, NoLock, Preserve)
+	{
+		Offset (0x61250),
+			CR1, 32,
+			BCLV, 16,
+			BCLM, 16,
+	}
+
+	/* Display Output Switching */
+	Method (_DOS, 1)
+	{
+		/* Windows 2000 and Windows XP call _DOS to enable/disable
+		 * Display Output Switching during init and while a switch
+		 * is already active
+		 */
+		Store (And(Arg0, 7), DSEN)
+	}
+
+	/* We try to support as many GM45 systems as possible,
+	 * so keep the number of DIDs flexible.
+	 */
+	Method (_DOD, 0)
+	{
+		If (LEqual(NDID, 1)) {
+			Name(DOD1, Package() {
+				0xffffffff
+			})
+			Store (Or(0x00010000, DID1), Index(DOD1, 0))
+			Return(DOD1)
+		}
+
+		If (LEqual(NDID, 2)) {
+			Name(DOD2, Package() {
+				0xffffffff,
+				0xffffffff
+			})
+			Store (Or(0x00010000, DID1), Index(DOD2, 0))
+			Store (Or(0x00010000, DID2), Index(DOD2, 1))
+			Return(DOD2)
+		}
+
+		If (LEqual(NDID, 3)) {
+			Name(DOD3, Package() {
+				0xffffffff,
+				0xffffffff,
+				0xffffffff
+			})
+			Store (Or(0x00010000, DID1), Index(DOD3, 0))
+			Store (Or(0x00010000, DID2), Index(DOD3, 1))
+			Store (Or(0x00010000, DID3), Index(DOD3, 2))
+			Return(DOD3)
+		}
+
+		If (LEqual(NDID, 4)) {
+			Name(DOD4, Package() {
+				0xffffffff,
+				0xffffffff,
+				0xffffffff,
+				0xffffffff
+			})
+			Store (Or(0x00010000, DID1), Index(DOD4, 0))
+			Store (Or(0x00010000, DID2), Index(DOD4, 1))
+			Store (Or(0x00010000, DID3), Index(DOD4, 2))
+			Store (Or(0x00010000, DID4), Index(DOD4, 3))
+			Return(DOD4)
+		}
+
+		If (LGreater(NDID, 4)) {
+			Name(DOD5, Package() {
+				0xffffffff,
+				0xffffffff,
+				0xffffffff,
+				0xffffffff,
+				0xffffffff
+			})
+			Store (Or(0x00010000, DID1), Index(DOD5, 0))
+			Store (Or(0x00010000, DID2), Index(DOD5, 1))
+			Store (Or(0x00010000, DID3), Index(DOD5, 2))
+			Store (Or(0x00010000, DID4), Index(DOD5, 3))
+			Store (Or(0x00010000, DID5), Index(DOD5, 4))
+			Return(DOD5)
+		}
+
+		/* Some error happened, but we have to return something */
+		Return (Package() {0x00000400})
+	}
+
+	Device(DD01)
+	{
+		/* Device Unique ID */
+		Method(_ADR, 0, Serialized)
+		{
+			If(LEqual(DID1, 0)) {
+				Return (1)
+			} Else {
+				Return (And(0xffff, DID1))
+			}
+		}
+
+		/* Device Current Status */
+		Method(_DCS, 0)
+		{
+			TRAP(1)
+			If (And(CSTE, 1)) {
+				Return (0x1f)
+			}
+			Return(0x1d)
+		}
+
+		/* Query Device Graphics State */
+		Method(_DGS, 0)
+		{
+			If (And(NSTE, 1)) {
+				Return(1)
+			}
+			Return(0)
+		}
+
+		/* Device Set State */
+		Method(_DSS, 1)
+		{
+			/* If Parameter Arg0 is (1 << 31) | (1 << 30), the
+			 * display switch was completed
+			 */
+			If (LEqual(And(Arg0, 0xc0000000), 0xc0000000)) {
+				Store (NSTE, CSTE)
+			}
+		}
+	}
+
+#ifdef DISPLAY_DEVICE_2_IS_LCD_SCREEN
+	Device (LCD0)
+	{
+		/* Device Unique ID */
+		Method(_ADR, 0, Serialized)
+		{
+			If(LEqual(DID2, 0)) {
+				Return (2)
+			} Else {
+				Return (And(0xffff, DID2))
+			}
+		}
+
+		Name (BRCT, 0)
+
+		Name (BRIG, Package (0x12)
+		{
+			0x61,
+			0x61,
+			0x2,
+			0x4,
+			0x5,
+			0x7,
+			0x9,
+			0xb,
+			0xd,
+			0x11,
+			0x14,
+			0x17,
+			0x1c,
+			0x20,
+			0x27,
+			0x31,
+			0x41,
+			0x61,
+		})
+
+		Method (_BCL, 0, NotSerialized)
+		{
+			Store (1, BRCT)
+			Return (BRIG)
+		}
+
+		Method (_BCM, 1, NotSerialized)
+		{
+			Store (ShiftLeft (Arg0, 4), ^^BCLV)
+			Store (0x80000000, ^^CR1)
+			Store (0x0610, ^^BCLM)
+		}
+		Method (_BQC, 0, NotSerialized)
+		{
+			Store (^^BCLV, Local0)
+			ShiftRight (Local0, 4, Local0)
+			Return (Local0)
+		}
+
+		Method(BRID, 1, NotSerialized)
+		{
+			Store (Match (BRIG, MEQ, Arg0, MTR, Zero, 2), Local0)
+			If (LEqual (Local0, Ones))
+			{
+				Return (0x11)
+			}
+			Return (Local0)
+		}
+
+		/* Using Notify is the right way. But Windows doesn't handle
+		   it well. So use both method in a way to avoid double action.
+		 */
+		Method (DECB, 0, NotSerialized)
+		{
+			If (BRCT)
+			{
+				Notify (LCD0, 0x87)
+			} Else {
+				Store (BRID (_BQC ()), Local0)
+				If (LNotEqual (Local0, 2))
+				{
+					Decrement (Local0)
+				}
+				_BCM (DerefOf (Index (BRIG, Local0)))
+			}
+		}
+		Method (INCB, 0, NotSerialized)
+		{
+			If (BRCT)
+			{
+				Notify (LCD0, 0x86)
+			} Else {
+				Store (BRID (_BQC ()), Local0)
+				If (LNotEqual (Local0, 0x11))
+				{
+					Increment (Local0)
+				}
+				_BCM (DerefOf (Index (BRIG, Local0)))
+			}
+		}
+	}
+#else
+	Device(DD02)
+	{
+		/* Device Unique ID */
+		Method(_ADR, 0, Serialized)
+		{
+			If(LEqual(DID2, 0)) {
+				Return (2)
+			} Else {
+				Return (And(0xffff, DID2))
+			}
+		}
+
+		/* Device Current Status */
+		Method(_DCS, 0)
+		{
+			TRAP(1)
+			If (And(CSTE, 2)) {
+				Return (0x1f)
+			}
+			Return(0x1d)
+		}
+
+		/* Query Device Graphics State */
+		Method(_DGS, 0)
+		{
+			If (And(NSTE, 2)) {
+				Return(1)
+			}
+			Return(0)
+		}
+
+		/* Device Set State */
+		Method(_DSS, 1)
+		{
+			/* If Parameter Arg0 is (1 << 31) | (1 << 30), the
+			 * display switch was completed
+			 */
+			If (LEqual(And(Arg0, 0xc0000000), 0xc0000000)) {
+				Store (NSTE, CSTE)
+			}
+		}
+	}
+#endif
+
+	Device(DD03)
+	{
+		/* Device Unique ID */
+		Method(_ADR, 0, Serialized)
+		{
+			If(LEqual(DID3, 0)) {
+				Return (3)
+			} Else {
+				Return (And(0xffff, DID3))
+			}
+		}
+
+		/* Device Current Status */
+		Method(_DCS, 0)
+		{
+			TRAP(1)
+			If (And(CSTE, 4)) {
+				Return (0x1f)
+			}
+			Return(0x1d)
+		}
+
+		/* Query Device Graphics State */
+		Method(_DGS, 0)
+		{
+			If (And(NSTE, 4)) {
+				Return(1)
+			}
+			Return(0)
+		}
+
+		/* Device Set State */
+		Method(_DSS, 1)
+		{
+			/* If Parameter Arg0 is (1 << 31) | (1 << 30), the
+			 * display switch was completed
+			 */
+			If (LEqual(And(Arg0, 0xc0000000), 0xc0000000)) {
+				Store (NSTE, CSTE)
+			}
+		}
+	}
+
+
+	Device(DD04)
+	{
+		/* Device Unique ID */
+		Method(_ADR, 0, Serialized)
+		{
+			If(LEqual(DID4, 0)) {
+				Return (4)
+			} Else {
+				Return (And(0xffff, DID4))
+			}
+		}
+
+		/* Device Current Status */
+		Method(_DCS, 0)
+		{
+			TRAP(1)
+			If (And(CSTE, 8)) {
+				Return (0x1f)
+			}
+			Return(0x1d)
+		}
+
+		/* Query Device Graphics State */
+		Method(_DGS, 0)
+		{
+			If (And(NSTE, 4)) {
+				Return(1)
+			}
+			Return(0)
+		}
+
+		/* Device Set State */
+		Method(_DSS, 1)
+		{
+			/* If Parameter Arg0 is (1 << 31) | (1 << 30), the
+			 * display switch was completed
+			 */
+			If (LEqual(And(Arg0, 0xc0000000), 0xc0000000)) {
+				Store (NSTE, CSTE)
+			}
+		}
+	}
+
+
+	Device(DD05)
+	{
+		/* Device Unique ID */
+		Method(_ADR, 0, Serialized)
+		{
+			If(LEqual(DID5, 0)) {
+				Return (5)
+			} Else {
+				Return (And(0xffff, DID5))
+			}
+		}
+
+		/* Device Current Status */
+		Method(_DCS, 0)
+		{
+			TRAP(1)
+			If (And(CSTE, 16)) {
+				Return (0x1f)
+			}
+			Return(0x1d)
+		}
+
+		/* Query Device Graphics State */
+		Method(_DGS, 0)
+		{
+			If (And(NSTE, 4)) {
+				Return(1)
+			}
+			Return(0)
+		}
+
+		/* Device Set State */
+		Method(_DSS, 1)
+		{
+			/* If Parameter Arg0 is (1 << 31) | (1 << 30), the
+			 * display switch was completed
+			 */
+			If (LEqual(And(Arg0, 0xc0000000), 0xc0000000)) {
+				Store (NSTE, CSTE)
+			}
+		}
+	}
+}
diff --git a/src/northbridge/intel/pineview/acpi/peg.asl b/src/northbridge/intel/pineview/acpi/peg.asl
new file mode 100644
index 0000000..227ca27
--- /dev/null
+++ b/src/northbridge/intel/pineview/acpi/peg.asl
@@ -0,0 +1,41 @@
+/*
+ * This file is part of the coreboot project.
+ *
+ * Copyright (C) 2007-2009 coresystems GmbH
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; version 2 of
+ * the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+Device (PEGP)
+{
+	Name (_ADR, 0x00010000)
+
+	// PCI Interrupt Routing.
+	Method (_PRT)
+	{
+		If (PICM) {
+			Return (Package() {
+				Package() { 0x0000ffff, 0, 0, 16 },
+				Package() { 0x0000ffff, 1, 0, 17 },
+				Package() { 0x0000ffff, 2, 0, 18 },
+				Package() { 0x0000ffff, 3, 0, 19 }
+			})
+		} Else {
+			Return (Package() {
+				Package() { 0x0000ffff, 0, \_SB.PCI0.LPCB.LNKA, 0 },
+				Package() { 0x0000ffff, 1, \_SB.PCI0.LPCB.LNKB, 0 },
+				Package() { 0x0000ffff, 2, \_SB.PCI0.LPCB.LNKC, 0 },
+				Package() { 0x0000ffff, 3, \_SB.PCI0.LPCB.LNKD, 0 }
+			})
+		}
+
+	}
+}
diff --git a/src/northbridge/intel/pineview/acpi/pineview.asl b/src/northbridge/intel/pineview/acpi/pineview.asl
new file mode 100644
index 0000000..b43ce07
--- /dev/null
+++ b/src/northbridge/intel/pineview/acpi/pineview.asl
@@ -0,0 +1,78 @@
+/*
+ * This file is part of the coreboot project.
+ *
+ * Copyright (C) 2007-2009 coresystems GmbH
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; version 2 of
+ * the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#include "hostbridge.asl"
+#include "../iomap.h"
+
+/* PCI Device Resource Consumption */
+Device (PDRC)
+{
+	Name (_HID, EISAID("PNP0C02"))
+	Name (_UID, 1)
+
+	// This does not seem to work correctly yet - set values statically for
+	// now.
+
+	//Name (PDRS, ResourceTemplate() {
+	//	Memory32Fixed(ReadWrite, 0x00000000, 0x00004000, RCRB) // RCBA
+	//	Memory32Fixed(ReadWrite, 0x00000000, 0x00004000, MCHB) // MCHBAR
+	//	Memory32Fixed(ReadWrite, 0x00000000, 0x00001000, DMIB) // DMIBAR
+	//	Memory32Fixed(ReadWrite, 0x00000000, 0x00001000, EGPB) // EPBAR
+	//	Memory32Fixed(ReadWrite, 0x00000000, 0x00000000, PCIE) // PCIE BAR
+	//	Memory32Fixed(ReadWrite, 0xfed20000, 0x00070000, ICHB) // Misc ICH
+	//})
+
+	Name (PDRS, ResourceTemplate() {
+		Memory32Fixed(ReadWrite, 0xfed1c000, 0x00004000) // RCBA
+		Memory32Fixed(ReadWrite, DEFAULT_MCHBAR,   0x00004000)
+		Memory32Fixed(ReadWrite, DEFAULT_DMIBAR,   0x00001000)
+		Memory32Fixed(ReadWrite, DEFAULT_EPBAR,    0x00001000)
+		Memory32Fixed(ReadWrite, DEFAULT_PCIEXBAR, 0x04000000)
+		Memory32Fixed(ReadWrite, 0xfed20000, 0x00020000) // Misc ICH
+		Memory32Fixed(ReadWrite, 0xfed40000, 0x00005000) // Misc ICH
+		Memory32Fixed(ReadWrite, 0xfed45000, 0x0004b000) // Misc ICH
+	})
+
+	// Current Resource Settings
+	Method (_CRS, 0, Serialized)
+	{
+		//CreateDwordField(PDRS, ^RCRB._BAS, RBR0)
+		//ShiftLeft(\_SB.PCI0.LPCB.RCBA, 14, RBR0)
+
+		//CreateDwordField(PDRS, ^MCHB._BAS, MBR0)
+		//ShiftLeft(\_SB.PCI0.MCHC.MHBR, 14, MBR0)
+
+		//CreateDwordField(PDRS, ^DMIB._BAS, DBR0)
+		//ShiftLeft(\_SB.PCI0.MCHC.DMBR, 12, DBR0)
+
+		//CreateDwordField(PDRS, ^EGPB._BAS, EBR0)
+		//ShiftLeft(\_SB.PCI0.MCHC.EPBR, 12, EBR0)
+
+		//CreateDwordField(PDRS, ^PCIE._BAS, PBR0)
+		//ShiftLeft(\_SB.PCI0.MCHC.PXBR, 26, PBR0)
+
+		//CreateDwordField(PDRS, ^PCIE._LEN, PSZ0)
+		//ShiftLeft(0x10000000, \_SB.PCI0.MCHC.PXSZ, PSZ0)
+
+		Return(PDRS)
+	}
+}
+
+// PCIe graphics port 0:1.0
+#include "peg.asl"
+
+// Integrated graphics 0:2.0
+//#include "igd.asl"
diff --git a/src/northbridge/intel/pineview/chip.h b/src/northbridge/intel/pineview/chip.h
new file mode 100644
index 0000000..a620857
--- /dev/null
+++ b/src/northbridge/intel/pineview/chip.h
@@ -0,0 +1,8 @@
+#include <drivers/intel/gma/i915.h>
+
+struct northbridge_intel_pineview_config {
+	u32 gpu_hotplug;
+	u32 gpu_backlight;
+	int gpu_lvds_use_spread_spectrum_clock;
+	struct i915_gpu_controller_info gfx;
+};
diff --git a/src/northbridge/intel/pineview/early_init.c b/src/northbridge/intel/pineview/early_init.c
new file mode 100644
index 0000000..c57aafc
--- /dev/null
+++ b/src/northbridge/intel/pineview/early_init.c
@@ -0,0 +1,179 @@
+/*
+ * This file is part of the coreboot project.
+ *
+ * Copyright (C) 2015 Damien Zammit <damien at zamaudio.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#include <stdint.h>
+#include <stdlib.h>
+#include <console/console.h>
+#include <arch/io.h>
+#include <device/pci_def.h>
+#include <cbmem.h>
+#include <halt.h>
+#include <string.h>
+#include <northbridge/intel/pineview/pineview.h>
+
+static void pineview_setup_bars(void)
+{
+	u8 reg8;
+	u16 reg16;
+	u32 reg32;
+
+	/* Setting up Southbridge. In the northbridge code. */
+	printk(BIOS_DEBUG, "Setting up static southbridge registers...");
+	pci_write_config32(PCI_DEV(0, 0x1f, 0), RCBA, (uintptr_t)DEFAULT_RCBA | 1);
+
+	pci_write_config32(PCI_DEV(0, 0x1f, 0), PMBASE, DEFAULT_PMBASE | 1);
+	pci_write_config8(PCI_DEV(0, 0x1f, 0), 0x44 /* ACPI_CNTL */ , 0x80); /* Enable ACPI BAR */
+
+	pci_write_config32(PCI_DEV(0, 0x1f, 0), GPIOBASE, DEFAULT_GPIOBASE | 1);
+	pci_write_config8(PCI_DEV(0, 0x1f, 0), 0x4c /* GC */ , 0x10);	/* Enable GPIOs */
+
+	pci_write_config32(PCI_DEV(0, 0x1f, 0), 0x88, 0x007c0291);
+
+	pci_write_config32(PCI_DEV(0, 0x1e, 0), 0x1b, 0x20);
+	printk(BIOS_DEBUG, " done.\n");
+
+	printk(BIOS_DEBUG, "Disabling Watchdog reboot...");
+	RCBA32(GCS) = RCBA32(GCS) | (1 << 5);	/* No reset */
+	outw((1 << 11), DEFAULT_PMBASE | 0x60 | 0x08);	/* halt timer */
+	printk(BIOS_DEBUG, " done.\n");
+
+	/* Enable upper 128bytes of CMOS */
+	RCBA32(0x3400) = (1 << 2);
+
+	/* Set up GPIO initially */
+	GPIO32(0x0) = 0x1ffde7c1;
+	GPIO32(0x30) = 0x7f;
+	GPIO32(0x4) = 0xe9e001;
+	GPIO32(0x34) = 0x7e;
+	GPIO32(0xc) = 0x4000000;
+	GPIO32(0x2c) = 0x2000;
+	GPIO32(0x18) = 0x0;
+	GPIO32(0xc) = 0xece9e802;
+
+	printk(BIOS_DEBUG, "Setting up static northbridge registers...");
+	/* Set up all hardcoded northbridge BARs */
+	pci_write_config8(PCI_DEV(0, 0x00, 0), 0x8, 0x69);
+
+	pci_write_config32(PCI_DEV(0, 0x00, 0), EPBAR, DEFAULT_EPBAR | 1);
+	pci_write_config32(PCI_DEV(0, 0x00, 0), MCHBAR, (uintptr_t)DEFAULT_MCHBAR | 1);
+	pci_write_config32(PCI_DEV(0, 0x00, 0), DMIBAR, (uintptr_t)DEFAULT_DMIBAR | 1);
+	pci_write_config32(PCI_DEV(0, 0x00, 0), PMIOBAR, (uintptr_t)0x400 | 1);
+
+
+	reg32 = MCHBAR32(0x30);
+	MCHBAR32(0x30) = 0x21800;
+	DMIBAR32(0x2c) = 0x86000040;
+	pci_write_config8(PCI_DEV(0, 0x00, 0), DEVEN, 0x09);
+	pci_write_config32(PCI_DEV(0, 0x1e, 0), 0x18, 0x00020200);
+	pci_write_config32(PCI_DEV(0, 0x1e, 0), 0x18, 0x00000000);
+	reg8 = pci_read_config8(PCI_DEV(0, 0x00, 0), 0xe5);  // 0x10
+	reg16 = pci_read_config16(PCI_DEV(0, 0x02, 0), 0x0); // 0x8086
+
+	reg16 = pci_read_config16(PCI_DEV(0, 0x00, 0), GGC);
+	pci_write_config16(PCI_DEV(0, 0x00, 0), GGC, 0x130);
+	reg16 = pci_read_config16(PCI_DEV(0, 0x00, 0), GGC);
+	pci_write_config16(PCI_DEV(0, 0x00, 0), GGC, 0x130);
+	MCHBAR8(0xb08) = 0x20;
+	reg8 = pci_read_config8(PCI_DEV(0, 0x00, 0), 0xe6); // 0x11
+	reg16 = MCHBAR16(0xc8c);
+	MCHBAR16(0xc8c) = reg16 | 0x0200;
+	reg8 = MCHBAR8(0xc8c);
+	MCHBAR8(0xc8c) = reg8;
+	MCHBAR8(0xc8c) = 0x12;
+	pci_write_config8(PCI_DEV(0, 0x02, 0), 0x62, 0x02);
+	pci_write_config16(PCI_DEV(0, 0x02, 0), 0xe8, 0x8000);
+	MCHBAR32(0x3004) = 0x48000000;
+	MCHBAR32(0x3008) = 0xfffffe00;
+	MCHBAR32(0xb08) = 0x06028220;
+	MCHBAR32(0xff4) = 0xc6db8b5f;
+	MCHBAR16(0xff8) = 0x024f;
+
+	// PLL Voltage controlled oscillator
+	//MCHBAR8(0xc38) = 0x04;
+
+	pci_write_config16(PCI_DEV(0, 0x02, 0), 0xcc, 0x014d);
+	reg32 = MCHBAR32(0x40);
+	MCHBAR32(0x40) = 0x0;
+	reg32 = MCHBAR32(0x40);
+	MCHBAR32(0x40) = 0x8;
+
+	// POST 0x13
+
+	pci_write_config8(PCI_DEV(0, 0x1f, 0), 0x8, 0x1d);
+	pci_write_config8(PCI_DEV(0, 0x1f, 0), 0x8, 0x0);
+	RCBA32(0x3410) = 0x00020465;
+	RCBA32(0x88) = 0x0011d000;
+	RCBA32(0x1fc) = 0x60f;
+	RCBA32(0x1f4) = 0x86000040;
+	RCBA32(0x214) = 0x10030509;
+	RCBA32(0x218) = 0x00020504;
+	RCBA32(0x220) = 0xc5;
+	RCBA32(0x3430) = 0x1;
+	RCBA32(0x2027) = 0x38f6a70d;
+	RCBA16(0x3e08) = 0x0080;
+	RCBA16(0x3e48) = 0x0080;
+	RCBA32(0x3e0e) = 0x00000080;
+	RCBA32(0x3e4e) = 0x00000080;
+	RCBA32(0x2034) = 0xb24577cc;
+	RCBA32(0x1c) = 0x03128010;
+	RCBA32(0x2010) = 0x400;
+	RCBA32(0x3400) = 0x4;
+	RCBA32(0x2080) = 0x18006007;
+	RCBA32(0x20a0) = 0x18006007;
+	RCBA32(0x20c0) = 0x18006007;
+	RCBA32(0x20e0) = 0x18006007;
+
+	pci_write_config32(PCI_DEV(0, 0x1d, 0), 0xca, 0x1);
+	pci_write_config32(PCI_DEV(0, 0x1d, 1), 0xca, 0x1);
+	pci_write_config32(PCI_DEV(0, 0x1d, 2), 0xca, 0x1);
+	pci_write_config32(PCI_DEV(0, 0x1d, 3), 0xca, 0x1);
+
+	RCBA32(0x3100) = 0x42210;
+	RCBA32(0x3108) = 0x10004321;
+	RCBA32(0x310c) = 0x00214321;
+	RCBA32(0x3110) = 0x1;
+	RCBA32(0x3140) = 0x01460132;
+	RCBA32(0x3142) = 0x02370146;
+	RCBA32(0x3144) = 0x32010237;
+	RCBA32(0x3146) = 0x01463201;
+	RCBA32(0x3148) = 0x146;
+
+	/* Set C0000-FFFFF to access RAM on both reads and writes */
+	pci_write_config8(PCI_DEV(0, 0x00, 0), PAM0, 0x30);
+	pci_write_config8(PCI_DEV(0, 0x00, 0), PAM1, 0x33);
+	pci_write_config8(PCI_DEV(0, 0x00, 0), PAM2, 0x33);
+	pci_write_config8(PCI_DEV(0, 0x00, 0), PAM3, 0x33);
+	pci_write_config8(PCI_DEV(0, 0x00, 0), PAM4, 0x33);
+	pci_write_config8(PCI_DEV(0, 0x00, 0), PAM5, 0x33);
+	pci_write_config8(PCI_DEV(0, 0x00, 0), PAM6, 0x33);
+
+	pci_write_config32(PCI_DEV(0, 0x00, 0), SKPAD, SKPAD_NORMAL_BOOT_MAGIC);
+	printk(BIOS_DEBUG, " done.\n");
+}
+
+void pineview_early_initialization(void)
+{
+	/* Print some chipset specific information */
+	printk(BIOS_DEBUG, "Intel Pineview northbridge\n");
+
+	/* Setup all BARs required for early PCIe and raminit */
+	pineview_setup_bars();
+
+	/* Change port80 to LPC */
+	RCBA32(GCS) &= (~0x04);
+
+	/* Just do it that way */
+	RCBA32(0x2010) |= (1 << 10);
+}
diff --git a/src/northbridge/intel/pineview/gma.c b/src/northbridge/intel/pineview/gma.c
new file mode 100644
index 0000000..4f98430
--- /dev/null
+++ b/src/northbridge/intel/pineview/gma.c
@@ -0,0 +1,520 @@
+/*
+ * This file is part of the coreboot project.
+ *
+ * Copyright (C) 2008-2009 coresystems GmbH
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#include <console/console.h>
+#include <bootmode.h>
+#include <delay.h>
+#include <device/device.h>
+#include <device/pci.h>
+#include <device/pci_ids.h>
+#include <pc80/mc146818rtc.h>
+#include <edid.h>
+#include <drivers/intel/gma/edid.h>
+#include <drivers/intel/gma/i915.h>
+#include <string.h>
+#include <pc80/vga.h>
+#include <pc80/vga_io.h>
+
+#include "chip.h"
+#include "pineview.h"
+
+#define GDRST 0xc0
+
+#define  LVDS_CLOCK_A_POWERUP_ALL	(3 << 8)
+#define  LVDS_CLOCK_B_POWERUP_ALL	(3 << 4)
+#define  LVDS_CLOCK_BOTH_POWERUP_ALL	(3 << 2)
+#define   DISPPLANE_BGRX888			(0x6<<26)
+#define   DPLLB_LVDS_P2_CLOCK_DIV_7	(1 << 24) /* i915 */
+
+#define   DPLL_INTEGRATED_CRI_CLK_VLV	(1<<14)
+
+#define PGETBL_CTL	0x2020
+#define PGETBL_ENABLED	0x00000001
+
+#define BASE_FREQUENCY 120000
+
+#if CONFIG_MAINBOARD_DO_NATIVE_VGA_INIT
+
+static int gtt_setup(void *mmiobase)
+{
+	unsigned long PGETBL_save;
+	unsigned long tom; // top of memory
+
+	/*
+	 * The Video BIOS places the GTT right below top of memory.
+	 */
+	tom = pci_read_config8(dev_find_slot(0, PCI_DEVFN(0, 0)), TOLUD) << 24;
+	PGETBL_save = tom - 256 * KiB;
+	PGETBL_save |= PGETBL_ENABLED;
+	PGETBL_save |= 2; /* set GTT to 256kb */
+
+	write32(mmiobase + GFX_FLSH_CNTL, 0);
+
+	write32(mmiobase + PGETBL_CTL, PGETBL_save);
+
+	/* verify */
+	if (read32(mmiobase + PGETBL_CTL) & PGETBL_ENABLED) {
+		printk(BIOS_DEBUG, "gtt_setup is enabled.\n");
+	} else {
+		printk(BIOS_DEBUG, "gtt_setup failed!!!\n");
+		return 1;
+	}
+	write32(mmiobase + GFX_FLSH_CNTL, 0);
+
+	return 0;
+}
+
+static int intel_gma_init(struct northbridge_intel_pineview_config *conf,
+			  unsigned int pphysbase, unsigned int piobase,
+			  void *pmmio, unsigned int pgfx)
+{
+	struct edid edid;
+	struct edid_mode *mode;
+	u8 edid_data[128];
+	unsigned long temp;
+	int hpolarity, vpolarity;
+	u32 candp1, candn;
+	u32 best_delta = 0xffffffff;
+	u32 target_frequency;
+	u32 pixel_p1 = 1;
+	u32 pixel_n = 1;
+	u32 pixel_m1 = 1;
+	u32 pixel_m2 = 1;
+	u32 hactive, vactive, right_border, bottom_border;
+	u32 vsync, hsync, vblank, hblank, hfront_porch, vfront_porch;
+	u32 i, j;
+	u32 uma_size;
+	u16 reg16;
+
+	printk(BIOS_SPEW,
+	       "i915lightup: graphics %p mmio %p addrport %04x physbase %08x\n",
+	       (void *)pgfx, pmmio, piobase, pphysbase);
+
+	intel_gmbus_read_edid(pmmio + GMBUS0, 3, 0x50, edid_data, 128);
+	decode_edid(edid_data, sizeof(edid_data), &edid);
+	mode = &edid.mode;
+
+	hpolarity = (mode->phsync == '-');
+	vpolarity = (mode->pvsync == '-');
+	hactive = edid.x_resolution;
+	vactive = edid.y_resolution;
+	right_border = mode->hborder;
+	bottom_border = mode->vborder;
+	vblank = mode->vbl;
+	hblank = mode->hbl;
+	vsync = mode->vspw;
+	hsync = mode->hspw;
+	hfront_porch = mode->hso;
+	vfront_porch = mode->vso;
+
+	for (i = 0; i < 2; i++)
+		for (j = 0; j < 0x100; j++)
+			/* R=j, G=j, B=j.  */
+			write32(pmmio + PALETTE(i) + 4 * j, 0x10101 * j);
+
+	write32(pmmio + PCH_PP_CONTROL, PANEL_UNLOCK_REGS
+		| (read32(pmmio + PCH_PP_CONTROL) & ~PANEL_UNLOCK_MASK));
+
+	write32(pmmio + MI_ARB_STATE, MI_ARB_C3_LP_WRITE_ENABLE | (1 << 27));
+	/* Clean registers.  */
+	for (i = 0; i < 0x20; i += 4)
+		write32(pmmio + RENDER_RING_BASE + i, 0);
+	for (i = 0; i < 0x20; i += 4)
+		write32(pmmio + FENCE_REG_965_0 + i, 0);
+	write32(pmmio + PP_ON_DELAYS, 0);
+	write32(pmmio + PP_OFF_DELAYS, 0);
+
+	/* Disable VGA.  */
+	write32(pmmio + VGACNTRL, VGA_DISP_DISABLE);
+
+	/* Disable pipes.  */
+	write32(pmmio + PIPECONF(0), 0);
+	write32(pmmio + PIPECONF(1), 0);
+
+	/* Init PRB0.  */
+	write32(pmmio + HWS_PGA, 0x352d2000);
+	write32(pmmio + PRB0_CTL, 0);
+	write32(pmmio + PRB0_HEAD, 0);
+	write32(pmmio + PRB0_TAIL, 0);
+	write32(pmmio + PRB0_START, 0);
+	write32(pmmio + PRB0_CTL, 0x0001f001);
+
+	write32(pmmio + D_STATE, DSTATE_PLL_D3_OFF
+		| DSTATE_GFX_CLOCK_GATING | DSTATE_DOT_CLOCK_GATING);
+	write32(pmmio + ECOSKPD, 0x00010000);
+	write32(pmmio + HWSTAM, 0xeffe);
+	write32(pmmio + PORT_HOTPLUG_EN, conf->gpu_hotplug);
+	write32(pmmio + INSTPM, 0x08000000 | INSTPM_AGPBUSY_DIS);
+
+	target_frequency = mode->lvds_dual_channel ? mode->pixel_clock
+		: (2 * mode->pixel_clock);
+
+	/* Find suitable divisors.  */
+	for (candp1 = 1; candp1 <= 8; candp1++) {
+		for (candn = 5; candn <= 10; candn++) {
+			u32 cur_frequency;
+			u32 m; /* 77 - 131.  */
+			u32 denom; /* 35 - 560.  */
+			u32 current_delta;
+
+			denom = candn * candp1 * 7;
+			/* Doesnt overflow for up to
+			   5000000 kHz = 5 GHz.  */
+			m = (target_frequency * denom
+			     + BASE_FREQUENCY / 2) / BASE_FREQUENCY;
+
+			if (m < 77 || m > 131)
+				continue;
+
+			cur_frequency = (BASE_FREQUENCY * m) / denom;
+			if (target_frequency > cur_frequency)
+				current_delta = target_frequency - cur_frequency;
+			else
+				current_delta = cur_frequency - target_frequency;
+
+			if (best_delta > current_delta) {
+				best_delta = current_delta;
+				pixel_n = candn;
+				pixel_p1 = candp1;
+				pixel_m2 = ((m + 3) % 5) + 7;
+				pixel_m1 = (m - pixel_m2) / 5;
+			}
+		}
+	}
+
+	if (best_delta == 0xffffffff) {
+		printk (BIOS_ERR, "Couldn't find GFX clock divisors\n");
+		return -1;
+	}
+
+	printk(BIOS_INFO, "bringing up panel at resolution %d x %d\n",
+	       hactive, vactive);
+	printk(BIOS_DEBUG, "Borders %d x %d\n", right_border, bottom_border);
+	printk(BIOS_DEBUG, "Blank %d x %d\n", hblank, vblank);
+	printk(BIOS_DEBUG, "Sync %d x %d\n", hsync, vsync);
+	printk(BIOS_DEBUG, "Front porch %d x %d\n", hfront_porch, vfront_porch);
+	printk(BIOS_DEBUG, (conf->gpu_lvds_use_spread_spectrum_clock
+			    ? "Spread spectrum clock\n"
+			    : "DREF clock\n"));
+	printk(BIOS_DEBUG, (mode->lvds_dual_channel
+			    ? "Dual channel\n"
+			    : "Single channel\n"));
+	printk(BIOS_DEBUG, "Polarities %d, %d\n",
+	       hpolarity, vpolarity);
+	printk(BIOS_DEBUG, "Pixel N=%d, M1=%d, M2=%d, P1=%d\n",
+	       pixel_n, pixel_m1, pixel_m2, pixel_p1);
+	printk(BIOS_DEBUG, "Pixel clock %d kHz\n",
+	       BASE_FREQUENCY * (5 * pixel_m1 + pixel_m2) / pixel_n
+	       / (pixel_p1 * 7));
+
+#if !IS_ENABLED(CONFIG_FRAMEBUFFER_KEEP_VESA_MODE)
+	write32(pmmio + PF_WIN_SZ(0), vactive | (hactive << 16));
+	write32(pmmio + PF_WIN_POS(0), 0);
+	write32(pmmio + PF_CTL(0),PF_ENABLE | PF_FILTER_MED_3x3);
+	write32(pmmio + PFIT_CONTROL, PFIT_ENABLE | (1 << PFIT_PIPE_SHIFT) | HORIZ_AUTO_SCALE | VERT_AUTO_SCALE);
+#else
+	/* Disable panel fitter (we're in native resolution).  */
+	write32(pmmio + PF_CTL(0), 0);
+	write32(pmmio + PF_WIN_SZ(0), 0);
+	write32(pmmio + PF_WIN_POS(0), 0);
+	write32(pmmio + PFIT_PGM_RATIOS, 0);
+	write32(pmmio + PFIT_CONTROL, 0);
+#endif
+
+	mdelay(1);
+
+	write32(pmmio + DSPCNTR(0), DISPPLANE_BGRX888
+		| DISPPLANE_SEL_PIPE_B | DISPPLANE_GAMMA_ENABLE);
+
+	mdelay(1);
+	write32(pmmio + PP_CONTROL, PANEL_UNLOCK_REGS
+		| (read32(pmmio + PP_CONTROL) & ~PANEL_UNLOCK_MASK));
+	write32(pmmio + FP0(1),
+		((pixel_n - 2) << 16)
+		| ((pixel_m1 - 2) << 8) | pixel_m2);
+	write32(pmmio + DPLL(1),
+		DPLL_VGA_MODE_DIS |
+		DPLL_VCO_ENABLE | DPLLB_MODE_LVDS
+		| (mode->lvds_dual_channel ? DPLLB_LVDS_P2_CLOCK_DIV_7
+		   : DPLLB_LVDS_P2_CLOCK_DIV_14)
+		| (conf->gpu_lvds_use_spread_spectrum_clock
+		   ? DPLL_INTEGRATED_CLOCK_VLV | DPLL_INTEGRATED_CRI_CLK_VLV
+		   : 0)
+		| (pixel_p1 << 16)
+		| (pixel_p1));
+	mdelay(1);
+	write32(pmmio + DPLL(1),
+		DPLL_VGA_MODE_DIS |
+		DPLL_VCO_ENABLE | DPLLB_MODE_LVDS
+		| (mode->lvds_dual_channel ? DPLLB_LVDS_P2_CLOCK_DIV_7
+		   : DPLLB_LVDS_P2_CLOCK_DIV_14)
+		| ((conf->gpu_lvds_use_spread_spectrum_clock ? 3 : 0) << 13)
+		| (pixel_p1 << 16)
+		| (pixel_p1));
+	mdelay(1);
+	write32(pmmio + HTOTAL(1),
+		((hactive + right_border + hblank - 1) << 16)
+		| (hactive - 1));
+	write32(pmmio + HBLANK(1),
+		((hactive + right_border + hblank - 1) << 16)
+		| (hactive + right_border - 1));
+	write32(pmmio + HSYNC(1),
+		((hactive + right_border + hfront_porch + hsync - 1) << 16)
+		| (hactive + right_border + hfront_porch - 1));
+
+	write32(pmmio + VTOTAL(1), ((vactive + bottom_border + vblank - 1) << 16)
+		| (vactive - 1));
+	write32(pmmio + VBLANK(1), ((vactive + bottom_border + vblank - 1) << 16)
+		| (vactive + bottom_border - 1));
+	write32(pmmio + VSYNC(1),
+		(vactive + bottom_border + vfront_porch + vsync - 1)
+		| (vactive + bottom_border + vfront_porch - 1));
+
+#if !IS_ENABLED(CONFIG_FRAMEBUFFER_KEEP_VESA_MODE)
+	write32(pmmio + PIPESRC(1), (639 << 16) | 399);
+#else
+	write32(pmmio + PIPESRC(1), ((hactive - 1) << 16) | (vactive - 1));
+#endif
+	mdelay(1);
+
+	write32(pmmio + DSPSIZE(0), (hactive - 1) | ((vactive - 1) << 16));
+	write32(pmmio + DSPPOS(0), 0);
+
+	/* Backlight init. */
+	write32(pmmio + FW_BLC_SELF, FW_BLC_SELF_EN_MASK);
+	write32(pmmio + FW_BLC, 0x011d011a);
+	write32(pmmio + FW_BLC2, 0x00000102);
+	write32(pmmio + FW_BLC_SELF, FW_BLC_SELF_EN_MASK);
+	write32(pmmio + FW_BLC_SELF, 0x0001003f);
+	write32(pmmio + FW_BLC, 0x011d0109);
+	write32(pmmio + FW_BLC2, 0x00000102);
+	write32(pmmio + FW_BLC_SELF, FW_BLC_SELF_EN_MASK);
+	write32(pmmio + BLC_PWM_CTL, conf->gpu_backlight);
+
+	edid.bytes_per_line = (edid.bytes_per_line + 63) & ~63;
+	write32(pmmio + DSPADDR(0), 0);
+	write32(pmmio + DSPSURF(0), 0);
+	write32(pmmio + DSPSTRIDE(0), edid.bytes_per_line);
+	write32(pmmio + DSPCNTR(0), DISPLAY_PLANE_ENABLE | DISPPLANE_BGRX888
+		| DISPPLANE_SEL_PIPE_B | DISPPLANE_GAMMA_ENABLE);
+	mdelay(1);
+
+	write32(pmmio + PIPECONF(1), PIPECONF_ENABLE);
+	write32(pmmio + LVDS, LVDS_ON
+		| (hpolarity << 20) | (vpolarity << 21)
+		| (mode->lvds_dual_channel ? LVDS_CLOCK_B_POWERUP_ALL
+		   | LVDS_CLOCK_BOTH_POWERUP_ALL : 0)
+		| LVDS_CLOCK_A_POWERUP_ALL
+		| LVDS_PIPE(1));
+
+	write32(pmmio + PP_CONTROL, PANEL_UNLOCK_REGS | PANEL_POWER_OFF);
+	write32(pmmio + PP_CONTROL, PANEL_UNLOCK_REGS | PANEL_POWER_RESET);
+	mdelay(1);
+	write32(pmmio + PP_CONTROL, PANEL_UNLOCK_REGS
+		| PANEL_POWER_ON | PANEL_POWER_RESET);
+
+	printk (BIOS_DEBUG, "waiting for panel powerup\n");
+	while (1) {
+		u32 reg32;
+		reg32 = read32(pmmio + PP_STATUS);
+		if ((reg32 & PP_SEQUENCE_MASK) == PP_SEQUENCE_NONE)
+			break;
+	}
+	printk (BIOS_DEBUG, "panel powered up\n");
+
+	write32(pmmio + PP_CONTROL, PANEL_POWER_ON | PANEL_POWER_RESET);
+
+	/* Clear interrupts. */
+	write32(pmmio + DEIIR, 0xffffffff);
+	write32(pmmio + SDEIIR, 0xffffffff);
+	write32(pmmio + IIR, 0xffffffff);
+	write32(pmmio + IMR, 0xffffffff);
+	write32(pmmio + EIR, 0xffffffff);
+
+	if (gtt_setup(pmmio)) {
+		printk(BIOS_ERR, "ERROR: GTT Setup Failed!!!\n");
+		return 0;
+	}
+
+	/* Setup GTT.  */
+
+	reg16 = pci_read_config16(dev_find_slot(0, PCI_DEVFN(0, 0)), GGC);
+	uma_size = 0;
+	if (!(reg16 & 2)) {
+		reg16 >>= 4;
+		reg16 &= 7;
+		switch (reg16) {
+		case 1:
+			uma_size = 1024;
+			break;
+		case 3:
+			uma_size = 8192;
+			break;
+		}
+
+		printk(BIOS_DEBUG, "%dM UMA\n", uma_size >> 10);
+	}
+
+	for (i = 0; i < (uma_size - 256) / 4; i++)
+	{
+		outl((i << 2) | 1, piobase);
+		outl(pphysbase + (i << 12) + 1, piobase + 4);
+	}
+
+	temp = read32(pmmio + PGETBL_CTL);
+	printk(BIOS_INFO, "GTT PGETBL_CTL register: 0x%lx\n", temp);
+
+	if (temp & 1)
+		printk(BIOS_INFO, "GTT Enabled\n");
+	else
+		printk(BIOS_ERR, "ERROR: GTT is still Disabled!!!\n");
+
+#if !IS_ENABLED(CONFIG_FRAMEBUFFER_KEEP_VESA_MODE)
+	vga_misc_write(0x67);
+
+	write32(pmmio + DSPCNTR(0), DISPPLANE_SEL_PIPE_B);
+
+	write32(pmmio + VGACNTRL, 0x02c4008e | VGA_PIPE_B_SELECT);
+
+	vga_textmode_init();
+#else
+	printk(BIOS_SPEW, "memset %p to 0x00 for %d bytes\n",
+	       (void *)pgfx, hactive * vactive * 4);
+	memset((void *)pgfx, 0x00, hactive * vactive * 4);
+
+	set_vbe_mode_info_valid(&edid, pgfx);
+#endif
+	return 0;
+}
+#endif
+
+static void gma_func0_init(struct device *dev)
+{
+	u32 reg32;
+
+	/* Unconditionally reset graphics */
+	pci_write_config8(dev, GDRST, 1);
+	udelay(50);
+	pci_write_config8(dev, GDRST, 0);
+	/* wait for device to finish */
+	while (pci_read_config8(dev, GDRST) & 1) { };
+
+	/* IGD needs to be Bus Master */
+	reg32 = pci_read_config32(dev, PCI_COMMAND);
+	pci_write_config32(dev, PCI_COMMAND, reg32 | PCI_COMMAND_MASTER
+		 | PCI_COMMAND_IO | PCI_COMMAND_MEMORY);
+
+#if !CONFIG_MAINBOARD_DO_NATIVE_VGA_INIT
+	/* PCI Init, will run VBIOS */
+	pci_dev_init(dev);
+#endif
+
+
+#if CONFIG_MAINBOARD_DO_NATIVE_VGA_INIT
+	/* This should probably run before post VBIOS init. */
+	printk(BIOS_SPEW, "Initializing VGA without OPROM.\n");
+	void *mmiobase;
+	u32 iobase, graphics_base;
+	struct northbridge_intel_pineview_config *conf = dev->chip_info;
+
+	iobase = dev->resource_list[1].base;
+	mmiobase = (void *)(uintptr_t)dev->resource_list[0].base;
+	graphics_base = dev->resource_list[2].base;
+
+	printk(BIOS_SPEW, "GMADR=0x%08x GTTADR=0x%08x\n",
+		pci_read_config32(dev, GMADR),
+		pci_read_config32(dev, GTTADR)
+	);
+
+	int err;
+	err = intel_gma_init(conf, pci_read_config32(dev, 0x5c) & ~0xf,
+			     iobase, mmiobase, graphics_base);
+	if (err == 0)
+		gfx_set_init_done(1);
+#endif
+}
+
+/* This doesn't reclaim stolen UMA memory, but IGD could still
+   be reenabled later. */
+static void gma_func0_disable(struct device *dev)
+{
+	struct device *dev_host = dev_find_slot(0, PCI_DEVFN(0x0, 0));
+
+	pci_write_config16(dev, GCFC, 0xa00);
+	pci_write_config16(dev_host, GGC, (1 << 1));
+
+	unsigned int reg32 = pci_read_config32(dev_host, DEVEN);
+	reg32 &= ~(DEVEN_D2F0 | DEVEN_D2F1);
+	pci_write_config32(dev_host, DEVEN, reg32);
+
+	dev->enabled = 0;
+}
+
+static void gma_set_subsystem(device_t dev, unsigned vendor, unsigned device)
+{
+	if (!vendor || !device) {
+		pci_write_config32(dev, PCI_SUBSYSTEM_VENDOR_ID,
+				pci_read_config32(dev, PCI_VENDOR_ID));
+	} else {
+		pci_write_config32(dev, PCI_SUBSYSTEM_VENDOR_ID,
+				((device & 0xffff) << 16) | (vendor & 0xffff));
+	}
+}
+
+const struct i915_gpu_controller_info *
+intel_gma_get_controller_info(void)
+{
+	device_t dev = dev_find_slot(0, PCI_DEVFN(0x2,0));
+	if (!dev) {
+		return NULL;
+	}
+	struct northbridge_intel_pineview_config *chip = dev->chip_info;
+	if (!chip) {
+		return NULL;
+	}
+	return &chip->gfx;
+}
+
+static void gma_ssdt(device_t device)
+{
+	const struct i915_gpu_controller_info *gfx = intel_gma_get_controller_info();
+	if (!gfx) {
+		return;
+	}
+
+	drivers_intel_gma_displays_ssdt_generate(gfx);
+}
+
+static struct pci_operations gma_pci_ops = {
+	.set_subsystem    = gma_set_subsystem,
+};
+
+static struct device_operations gma_func0_ops = {
+	.read_resources		= pci_dev_read_resources,
+	.set_resources		= pci_dev_set_resources,
+	.enable_resources	= pci_dev_enable_resources,
+	.init			= gma_func0_init,
+	.acpi_fill_ssdt_generator = gma_ssdt,
+	.scan_bus		= 0,
+	.enable			= 0,
+	.disable		= gma_func0_disable,
+	.ops_pci		= &gma_pci_ops,
+};
+
+static const struct pci_driver i945_gma_func0_driver __pci_driver = {
+	.ops	= &gma_func0_ops,
+	.vendor	= PCI_VENDOR_ID_INTEL,
+	.device	= 0xa001,
+};
diff --git a/src/northbridge/intel/pineview/northbridge.c b/src/northbridge/intel/pineview/northbridge.c
new file mode 100644
index 0000000..f19ce6f
--- /dev/null
+++ b/src/northbridge/intel/pineview/northbridge.c
@@ -0,0 +1,286 @@
+/*
+ * This file is part of the coreboot project.
+ *
+ * Copyright (C) 2007-2009 coresystems GmbH
+ * Copyright (C) 2015  Damien Zammit <damien at zamaudio.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#include <console/console.h>
+#include <arch/io.h>
+#include <stdint.h>
+#include <device/device.h>
+#include <device/pci.h>
+#include <device/pci_ids.h>
+#include <device/hypertransport.h>
+#include <stdlib.h>
+#include <string.h>
+#include <cpu/cpu.h>
+#include <boot/tables.h>
+#include <arch/acpi.h>
+#include <cbmem.h>
+#include "pineview.h"
+#include "arch/acpi.h"
+
+/* Reserve segments A and B:
+ *
+ * 0xa0000 - 0xbffff: legacy VGA
+ */
+static const int legacy_hole_base_k = 0xa0000 / 1024;
+static const int legacy_hole_size_k = 128;
+
+static int decode_pcie_bar(u32 *const base, u32 *const len)
+{
+	*base = 0;
+	*len = 0;
+
+	const device_t dev = dev_find_slot(0, PCI_DEVFN(0, 0));
+	if (!dev)
+		return 0;
+
+	const u32 pciexbar_reg = pci_read_config32(dev, PCIEXBAR);
+
+	if (!(pciexbar_reg & (1 << 0)))
+		return 0;
+
+	switch ((pciexbar_reg >> 1) & 3) {
+	case 0: /* 256MB */
+		*base = pciexbar_reg & (0x0f << 28);
+		*len = 256 * 1024 * 1024;
+		return 1;
+	case 1: /* 128M */
+		*base = pciexbar_reg & (0x1f << 27);
+		*len = 128 * 1024 * 1024;
+		return 1;
+	case 2: /* 64M */
+		*base = pciexbar_reg & (0x3f << 26);
+		*len = 64 * 1024 * 1024;
+		return 1;
+	}
+
+	return 0;
+}
+
+static void mch_domain_read_resources(device_t dev)
+{
+	u64 tom, touud;
+	u32 tomk, tolud, uma_sizek = 0, usable_tomk;
+	u32 pcie_config_base, pcie_config_size;
+
+	/* Total Memory 2GB example:
+	 *
+	 *  00000000  0000MB-2014MB  2014MB  RAM     (writeback)
+	 *  7de00000  2014MB-2016MB     2MB  GFX GTT (uncached)
+	 *  7e000000  2016MB-2048MB    32MB  GFX UMA (uncached)
+	 *  80000000   2048MB TOLUD
+	 *  80000000   2048MB TOM
+	 *
+	 * Total Memory 4GB example:
+	 *
+	 *  00000000  0000MB-3038MB  3038MB  RAM     (writeback)
+	 *  bde00000  3038MB-3040MB     2MB  GFX GTT (uncached)
+	 *  be000000  3040MB-3072MB    32MB  GFX UMA (uncached)
+	 *  be000000   3072MB TOLUD
+	 * 100000000   4096MB TOM
+	 * 100000000  4096MB-5120MB  1024MB  RAM     (writeback)
+	 * 140000000   5120MB TOUUD
+	 */
+
+	pci_domain_read_resources(dev);
+
+	/* Top of Upper Usable DRAM, including remap */
+	touud = pci_read_config16(dev, 0xa2);
+	touud <<= 20;
+
+	/* Top of Lower Usable DRAM */
+	tolud = pci_read_config16(dev, 0xb0) & 0xfff0;
+	tolud <<= 16;
+
+	/* Top of Memory - does not account for any UMA */
+	tom = pci_read_config16(dev, 0xa0) & 0x1ff;
+	tom <<= 27;
+
+	printk(BIOS_DEBUG, "TOUUD 0x%llx TOLUD 0x%08x TOM 0x%llx\n",
+	       touud, tolud, tom);
+
+	tomk = tolud >> 10;
+
+	/* Graphics memory comes next */
+	const u16 ggc = pci_read_config16(dev, GGC);
+
+	/* Graphics memory */
+	const u32 gms_sizek = decode_igd_memory_size((ggc >> 4) & 0xf);
+	printk(BIOS_DEBUG, "%uM UMA", gms_sizek >> 10);
+	tomk -= gms_sizek;
+
+	/* GTT Graphics Stolen Memory Size (GGMS) */
+	const u32 gsm_sizek = decode_igd_gtt_size((ggc >> 8) & 0xf);
+	printk(BIOS_DEBUG, " and %uM GTT\n", gsm_sizek >> 10);
+	tomk -= gsm_sizek;
+
+	uma_sizek = gms_sizek + gsm_sizek;
+
+	usable_tomk = ALIGN_DOWN(tomk, 64 << 10);
+	if (tomk - usable_tomk > (16 << 10))
+		usable_tomk = tomk;
+
+	printk(BIOS_INFO, "Available memory below 4GB: %uM\n", usable_tomk >> 10);
+
+	/* Report the memory regions */
+	ram_resource(dev, 3, 0, legacy_hole_base_k);
+	ram_resource(dev, 4, legacy_hole_base_k + legacy_hole_size_k,
+		     (usable_tomk - (legacy_hole_base_k + legacy_hole_size_k)));
+
+	mmio_resource(dev, 5, legacy_hole_base_k,
+				(0xc0000 >> 10) - legacy_hole_base_k);
+
+	/*
+	 * If >= 4GB installed then memory from TOLUD to 4GB
+	 * is remapped above TOM, TOUUD will account for both
+	 */
+	touud >>= 10; /* Convert to KB */
+	if (touud > 4096 * 1024) {
+		ram_resource(dev, 6, 4096 * 1024, touud - (4096 * 1024));
+		printk(BIOS_INFO, "Available memory above 4GB: %lluM\n",
+		       (touud >> 10) - 4096);
+	}
+
+	printk(BIOS_DEBUG, "Adding UMA memory area base=0x%llx "
+	       "size=0x%llx\n", ((u64)tomk) << 10, ((u64)uma_sizek) << 10);
+	/* Don't use uma_resource() as our UMA touches the PCI hole. */
+	fixed_mem_resource(dev, 7, tomk, uma_sizek, IORESOURCE_RESERVE);
+
+	if (decode_pcie_bar(&pcie_config_base, &pcie_config_size)) {
+		printk(BIOS_DEBUG, "Adding PCIe config bar base=0x%08x "
+		       "size=0x%x\n", pcie_config_base, pcie_config_size);
+		fixed_mem_resource(dev, 8, pcie_config_base >> 10,
+			pcie_config_size >> 10, IORESOURCE_RESERVE);
+	}
+
+	set_top_of_ram(tomk << 10);
+}
+
+static void mch_domain_set_resources(device_t dev)
+{
+	struct resource *resource;
+	int i;
+
+	for (i = 3; i < 9; ++i) {
+		/* Report read resources. */
+		resource = probe_resource(dev, i);
+		if (resource)
+			report_resource_stored(dev, resource, "");
+	}
+
+	assign_resources(dev->link_list);
+}
+
+static void mch_domain_init(device_t dev)
+{
+	u32 reg32;
+
+	/* Enable SERR */
+	reg32 = pci_read_config32(dev, PCI_COMMAND);
+	reg32 |= PCI_COMMAND_SERR;
+	pci_write_config32(dev, PCI_COMMAND, reg32);
+}
+
+static struct device_operations pci_domain_ops = {
+	.read_resources   = mch_domain_read_resources,
+	.set_resources    = mch_domain_set_resources,
+	.enable_resources = NULL,
+	.init             = mch_domain_init,
+	.scan_bus         = pci_domain_scan_bus,
+	.ops_pci_bus	  = pci_bus_default_ops,
+};
+
+static void cpu_bus_init(device_t dev)
+{
+	initialize_cpus(dev->link_list);
+}
+
+static struct device_operations cpu_bus_ops = {
+	.read_resources   = DEVICE_NOOP,
+	.set_resources    = DEVICE_NOOP,
+	.enable_resources = DEVICE_NOOP,
+	.init             = cpu_bus_init,
+	.scan_bus         = 0,
+};
+
+
+static void enable_dev(device_t dev)
+{
+	/* Set the operations if it is a special bus type */
+	if (dev->path.type == DEVICE_PATH_DOMAIN) {
+		dev->ops = &pci_domain_ops;
+#if CONFIG_HAVE_ACPI_RESUME
+		switch (pci_read_config32(dev_find_slot(0, PCI_DEVFN(0, 0)), /*D0F0_SKPD*/0xdc)) {
+		case SKPAD_NORMAL_BOOT_MAGIC:
+			printk(BIOS_DEBUG, "Normal boot.\n");
+			acpi_slp_type=0;
+			break;
+		case SKPAD_ACPI_S3_MAGIC:
+			printk(BIOS_DEBUG, "S3 Resume.\n");
+			acpi_slp_type=3;
+			break;
+		default:
+			printk(BIOS_DEBUG, "Unknown boot method, assuming normal.\n");
+			acpi_slp_type=0;
+			break;
+		}
+#endif
+	} else if (dev->path.type == DEVICE_PATH_CPU_CLUSTER) {
+		dev->ops = &cpu_bus_ops;
+	}
+}
+
+static void pineview_init(void *const chip_info)
+{
+	int dev, fn, bit_base;
+
+	struct device *const d0f0 = dev_find_slot(0, 0);
+
+	/* Hide internal functions based on devicetree info. */
+	for (dev = 3; dev > 0; --dev) {
+		switch (dev) {
+		case 3: /* ME */
+			fn = 3;
+			bit_base = 6;
+			break;
+		case 2: /* IGD */
+			fn = 1;
+			bit_base = 3;
+			break;
+		case 1: /* PEG */
+			fn = 0;
+			bit_base = 1;
+			break;
+		}
+		for (; fn >= 0; --fn) {
+			const struct device *const d =
+				dev_find_slot(0, PCI_DEVFN(dev, fn));
+			if (!d || d->enabled) continue;
+			const u32 deven = pci_read_config32(d0f0, DEVEN);
+			pci_write_config32(d0f0, DEVEN,
+					   deven & ~(1 << (bit_base + fn)));
+		}
+	}
+
+	const u32 deven = pci_read_config32(d0f0, DEVEN);
+	if (!(deven & (0xf << 6)))
+		pci_write_config32(d0f0, DEVEN, deven & ~(1 << 14));
+}
+
+struct chip_operations northbridge_intel_pineview_ops = {
+	CHIP_NAME("Intel Pineview Northbridge")
+	.enable_dev = enable_dev,
+	.init = pineview_init,
+};
diff --git a/src/northbridge/intel/pineview/pineview.h b/src/northbridge/intel/pineview/pineview.h
index 5441dc9..93beb95 100644
--- a/src/northbridge/intel/pineview/pineview.h
+++ b/src/northbridge/intel/pineview/pineview.h
@@ -18,6 +18,172 @@
 
 #include <northbridge/intel/pineview/iomap.h>
 
+typedef enum {
+	FSB_CLOCK_667MHz	= 0,
+	FSB_CLOCK_800MHz	= 1,
+} fsb_clock_t;
+
+typedef enum {
+	MEM_CLOCK_667MHz  = 0,
+	MEM_CLOCK_800MHz  = 1,
+} mem_clock_t;
+
+typedef enum {
+	DDR2 = 2,
+	DDR3 = 3,
+} ddr_t;
+
+typedef enum { /* as in DDR3 spd */
+	CHIP_WIDTH_x4	= 0,
+	CHIP_WIDTH_x8	= 1,
+	CHIP_WIDTH_x16	= 2,
+	CHIP_WIDTH_x32	= 3,
+} chip_width_t;
+
+typedef enum { /* as in DDR3 spd */
+	CHIP_CAP_256M	= 0,
+	CHIP_CAP_512M	= 1,
+	CHIP_CAP_1G	= 2,
+	CHIP_CAP_2G	= 3,
+	CHIP_CAP_4G	= 4,
+	CHIP_CAP_8G	= 5,
+	CHIP_CAP_16G	= 6,
+} chip_capacity_t;
+
+typedef struct {
+	unsigned int	CAS;
+	fsb_clock_t	fsb_clock;
+	mem_clock_t	mem_clock;
+	unsigned int	tRAS;
+	unsigned int	tRP;
+	unsigned int	tRCD;
+	unsigned int	tWR;
+	unsigned int	tRFC;
+	unsigned int	tWTR;
+	unsigned int	tRRD;
+	unsigned int	tRTP;
+} timings_t;
+
+typedef struct {
+	unsigned int	card_type; /* 0x0: unpopulated,
+				      0xa - 0xf: raw card type A - F */
+	u8		type;
+	chip_width_t	width;
+	chip_capacity_t	chip_capacity;
+	unsigned int	page_size; /* of whole DIMM in Bytes (4096 or 8192) */
+	unsigned int	sides;
+	unsigned int	banks;
+	unsigned int	ranks;
+	unsigned int	rows;
+	unsigned int	cols;
+	unsigned int	cas_latencies;
+	unsigned int	tAAmin;
+	unsigned int	tCKmin;
+	unsigned int	tWR;
+	unsigned int	tRP;
+	unsigned int	tRCD;
+	unsigned int	tRAS;
+	unsigned int	rank_capacity_mb; /* per rank in Mega Bytes */
+	u8		spd_data[256];
+} dimminfo_t;
+
+struct pllparam {
+	u8 kcoarse[2][72];
+	u8 pi[2][72];
+	u8 dben[2][72];
+	u8 dbsel[2][72];
+	u8 clkdelay[2][72];
+} __attribute__ ((packed));
+
+typedef struct sys_info {
+	u8 maxpi;
+	u8 pioffset;
+	u8 pi[8];
+	u16 coarsectrl;
+	u16 coarsedelay;
+	u16 mediumphase;
+	u16 readptrdelay;
+
+	int		txt_enabled;
+	int		cores;
+	int		boot_path;
+	int		max_ddr2_mhz;
+	int		max_ddr3_mt;
+	int		max_fsb_mhz;
+	int		max_render_mhz;
+	int		enable_igd;
+	int		enable_peg;
+	u16		ggc;
+
+	int		dimm_config[2];
+	int		dimms_per_ch;
+	int		spd_type;
+	int		channel_capacity[2];
+	timings_t	selected_timings;
+	dimminfo_t	dimms[4];
+	u8		spd_map[4];
+
+	u8 nodll;
+	u8 async;
+	u8 dt0mode;
+	u8 mvco4x;		/* 0 (8x) or 1 (4x) */
+} sysinfo_t;
+
+#define DIMM_TCO_BASE 0x30
+#define BURSTLENGTH	 8
+
+#define BOOT_PATH_NORMAL	0
+#define BOOT_PATH_RESET		1
+#define BOOT_PATH_RESUME	2
+
+#define SYSINFO_DIMM_NOT_POPULATED	0x00
+#define SYSINFO_DIMM_X16SS		0x01
+#define SYSINFO_DIMM_X16DS		0x02
+#define SYSINFO_DIMM_X8DS		0x05
+#define SYSINFO_DIMM_X8DDS		0x06
+
+#define TOTAL_CHANNELS 1
+#define TOTAL_DIMMS 2
+
+#define DIMM_IS_POPULATED(dimms, idx) (dimms[idx].card_type != 0)
+#define IF_DIMM_POPULATED(dimms, idx) if (dimms[idx].card_type != 0)
+#define ONLY_DIMMA_IS_POPULATED(dimms, ch) ( \
+	(DIMM_IS_POPULATED(dimms, (ch == 0) ? 0 : 2) && \
+	!DIMM_IS_POPULATED(dimms, (ch == 0) ? 1 : 3)))
+#define ONLY_DIMMB_IS_POPULATED(dimms, ch) ( \
+	(DIMM_IS_POPULATED(dimms, (ch == 0) ? 1 : 3) && \
+	!DIMM_IS_POPULATED(dimms, (ch == 0) ? 0 : 2)))
+#define BOTH_DIMMS_ARE_POPULATED(dimms, ch) ( \
+	(DIMM_IS_POPULATED(dimms, (ch == 0) ? 0 : 2) && \
+	(DIMM_IS_POPULATED(dimms, (ch == 0) ? 1 : 3))))
+#define FOR_EACH_DIMM(idx) \
+	for (idx = 0; idx < TOTAL_DIMMS; ++idx)
+#define FOR_EACH_POPULATED_DIMM(dimms, idx) \
+	FOR_EACH_DIMM(idx) IF_DIMM_POPULATED(dimms, idx)
+#define CHANNEL_IS_POPULATED(dimms, idx) ((dimms[idx<<1].card_type != 0) || (dimms[(idx<<1) + 1].card_type != 0))
+#define CHANNEL_IS_CARDF(dimms, idx) ((dimms[idx<<1].card_type == 0xf) || (dimms[(idx<<1) + 1].card_type == 0xf))
+#define IF_CHANNEL_POPULATED(dimms, idx) if ((dimms[idx<<1].card_type != 0) || (dimms[(idx<<1) + 1].card_type != 0))
+#define FOR_EACH_CHANNEL(idx) \
+	for (idx = 0; idx < TOTAL_CHANNELS; ++idx)
+#define FOR_EACH_POPULATED_CHANNEL(dimms, idx) \
+	FOR_EACH_CHANNEL(idx) IF_CHANNEL_POPULATED(dimms, idx)
+
+#define RANKS_PER_CHANNEL 4
+#define RANK_IS_POPULATED(dimms, ch, r) \
+	((dimms[ch<<1].card_type && ((r) < dimms[ch<<1].ranks)) || \
+	(dimms[(ch<<1) + 1].card_type && ((r) >= 2) && ((r) < (dimms[(ch<<1) + 1].ranks + 2))))
+#define IF_RANK_POPULATED(dimms, ch, r) \
+	if ((dimms[ch<<1].card_type && ((r) < dimms[ch<<1].ranks)) || \
+	    (dimms[(ch<<1) + 1].card_type && ((r) >= 2) && ((r) < (dimms[(ch<<1) + 1].ranks + 2))))
+#define FOR_EACH_RANK_IN_CHANNEL(r) \
+	for (r = 0; r < RANKS_PER_CHANNEL; ++r)
+#define FOR_EACH_POPULATED_RANK_IN_CHANNEL(dimms, ch, r) \
+	FOR_EACH_RANK_IN_CHANNEL(r) IF_RANK_POPULATED(dimms, ch, r)
+#define FOR_EACH_RANK(ch, r) \
+	FOR_EACH_CHANNEL(ch) FOR_EACH_RANK_IN_CHANNEL(r)
+#define FOR_EACH_POPULATED_RANK(dimms, ch, r) \
+	FOR_EACH_RANK(ch, r) IF_RANK_POPULATED(dimms, ch, r)
+
 /* Device 0:0.0 PCI configuration space (Host Bridge) */
 
 #define EPBAR		0x40
@@ -56,7 +222,7 @@
 #define TOUUD		0xa2
 #define GBSM		0xa4
 #define BGSM		0xa8
-#define TSEGMB		0xac
+#define TSEG		0xac
 #define TOLUD		0xb0	/* Top of Low Used Memory */
 #define ERRSTS		0xc8
 #define ERRCMD		0xca
@@ -84,6 +250,8 @@
 #define GCFC		0xf0	/* Graphics Clock Frequency & Gating Control */
 
 
+#define GPIO32(x) *((volatile u32 *)(DEFAULT_GPIOBASE + x))
+
 /*
  * MCHBAR
  */
@@ -108,7 +276,14 @@
 #define DMIBAR16(x) *((volatile u16 *)(DEFAULT_DMIBAR + x))
 #define DMIBAR32(x) *((volatile u32 *)(DEFAULT_DMIBAR + x))
 
+void pineview_early_initialization(void);
+u32 decode_igd_memory_size(const u32 gms);
+u32 decode_igd_gtt_size(const u32 gsm);
+
 /* provided by mainboard code */
 void setup_ich7_gpios(void);
 
+struct acpi_rsdp;
+unsigned long northbridge_write_acpi_tables(unsigned long start, struct acpi_rsdp *rsdp);
+
 #endif /* NORTHBRIDGE_INTEL_PINEVIEW_H */
diff --git a/src/northbridge/intel/pineview/ram_calc.c b/src/northbridge/intel/pineview/ram_calc.c
index e9f8eed..ae743eb 100644
--- a/src/northbridge/intel/pineview/ram_calc.c
+++ b/src/northbridge/intel/pineview/ram_calc.c
@@ -14,45 +14,55 @@
  * GNU General Public License for more details.
  */
 
-/* Use simple device model for this file even in ramstage */
 #define __SIMPLE_DEVICE__
 
 #include <arch/io.h>
+#include <console/console.h>
 #include <cbmem.h>
 #include <northbridge/intel/pineview/pineview.h>
 
-static void *find_ramtop(void)
+/** Decodes used Graphics Mode Select (GMS) to kilobytes. */
+u32 decode_igd_memory_size(const u32 gms)
 {
-	uint32_t tom;
-
-	if (pci_read_config8(PCI_DEV(0, 0x0, 0), DEVEN) & (DEVEN_D2F0 | DEVEN_D2F1)) {
-		/* IGD enabled, get top of Memory from BSM register */
-		tom = pci_read_config32(PCI_DEV(0,2,0), BSM);
-	} else
-		tom = (pci_read_config8(PCI_DEV(0,0,0), TOLUD) & 0xf7) << 24;
-
-	/* if TSEG enabled subtract size */
-	switch(pci_read_config8(PCI_DEV(0, 0, 0), ESMRAM) & 0x07) {
-	case 0x01:
-		/* 1MB TSEG */
-		tom -= 0x100000;
-		break;
-	case 0x03:
-		/* 2MB TSEG */
-		tom -= 0x200000;
-		break;
-	case 0x05:
-		/* 8MB TSEG */
-		tom -= 0x800000;
-		break;
+	switch (gms) {
+	case 0:
+		return   0;
+	case 1:
+		return   1 << 10;
+	case 2:
+		return   4 << 10;
+	case 3:
+		return   8 << 10;
+	case 4:
+		return  16 << 10;
+	case 5:
+		return  32 << 10;
+	case 6:
+		return  48 << 10;
+	case 7:
+		return  64 << 10;
+	case 8:
+		return 128 << 10;
+	case 9:
+		return 256 << 10;
 	default:
-		/* TSEG either disabled or invalid */
-		break;
+		printk(BIOS_DEBUG, "Bad Graphics Mode Select (GMS) setting.\n");
+		return 0;
 	}
-	return (void *)tom;
 }
 
-void *cbmem_top(void)
+/** Decodes used Graphics Stolen Memory (GSM) to kilobytes. */
+u32 decode_igd_gtt_size(const u32 gsm)
 {
-	return find_ramtop();
+	switch (gsm) {
+	case 2:
+	case 3:
+	case 0:
+		return 0;
+	case 1:
+		return 1 << 10;
+	default:
+		printk(BIOS_DEBUG, "Bad Graphics Stolen Memory (GSM) setting.\n");
+		return 0;
+	}
 }



More information about the coreboot-gerrit mailing list