blob: 5b16abce046d5ee70d10ce86022d2cfa94042e35 [file] [log] [blame]
Simon Glass30580fc2014-11-12 22:42:23 -07001/*
2 * From Coreboot
3 *
4 * Copyright (C) 2007-2010 coresystems GmbH
5 * Copyright (C) 2011 Google Inc
6 *
7 * SPDX-License-Identifier: GPL-2.0+
8 */
9
10#include <common.h>
Simon Glass061e9ea2016-01-17 16:11:15 -070011#include <dm.h>
Simon Glass30580fc2014-11-12 22:42:23 -070012#include <asm/io.h>
13#include <asm/pci.h>
14#include <asm/arch/pch.h>
15#include <asm/arch/sandybridge.h>
16
Simon Glass99eecaa2016-01-17 16:11:17 -070017static void sandybridge_setup_northbridge_bars(struct udevice *dev)
18{
Simon Glass30580fc2014-11-12 22:42:23 -070019 /* Set up all hardcoded northbridge BARs */
20 debug("Setting up static registers\n");
Simon Glass99eecaa2016-01-17 16:11:17 -070021 dm_pci_write_config32(dev, EPBAR, DEFAULT_EPBAR | 1);
22 dm_pci_write_config32(dev, EPBAR + 4, (0LL + DEFAULT_EPBAR) >> 32);
23 dm_pci_write_config32(dev, MCHBAR, DEFAULT_MCHBAR | 1);
24 dm_pci_write_config32(dev, MCHBAR + 4, (0LL + DEFAULT_MCHBAR) >> 32);
Simon Glass30580fc2014-11-12 22:42:23 -070025 /* 64MB - busses 0-63 */
Simon Glass99eecaa2016-01-17 16:11:17 -070026 dm_pci_write_config32(dev, PCIEXBAR, DEFAULT_PCIEXBAR | 5);
27 dm_pci_write_config32(dev, PCIEXBAR + 4,
28 (0LL + DEFAULT_PCIEXBAR) >> 32);
29 dm_pci_write_config32(dev, DMIBAR, DEFAULT_DMIBAR | 1);
30 dm_pci_write_config32(dev, DMIBAR + 4, (0LL + DEFAULT_DMIBAR) >> 32);
Simon Glass30580fc2014-11-12 22:42:23 -070031
32 /* Set C0000-FFFFF to access RAM on both reads and writes */
Simon Glass99eecaa2016-01-17 16:11:17 -070033 dm_pci_write_config8(dev, PAM0, 0x30);
34 dm_pci_write_config8(dev, PAM1, 0x33);
35 dm_pci_write_config8(dev, PAM2, 0x33);
36 dm_pci_write_config8(dev, PAM3, 0x33);
37 dm_pci_write_config8(dev, PAM4, 0x33);
38 dm_pci_write_config8(dev, PAM5, 0x33);
39 dm_pci_write_config8(dev, PAM6, 0x33);
Simon Glass30580fc2014-11-12 22:42:23 -070040}
41
Simon Glass061e9ea2016-01-17 16:11:15 -070042static int bd82x6x_northbridge_probe(struct udevice *dev)
43{
Simon Glassaa0f23e2016-01-17 16:11:16 -070044 const int chipset_type = SANDYBRIDGE_MOBILE;
45 u32 capid0_a;
46 u8 reg8;
47
48 if (gd->flags & GD_FLG_RELOC)
49 return 0;
50
51 /* Device ID Override Enable should be done very early */
52 dm_pci_read_config32(dev, 0xe4, &capid0_a);
53 if (capid0_a & (1 << 10)) {
54 dm_pci_read_config8(dev, 0xf3, &reg8);
55 reg8 &= ~7; /* Clear 2:0 */
56
57 if (chipset_type == SANDYBRIDGE_MOBILE)
58 reg8 |= 1; /* Set bit 0 */
59
60 dm_pci_write_config8(dev, 0xf3, reg8);
61 }
62
Simon Glass99eecaa2016-01-17 16:11:17 -070063 sandybridge_setup_northbridge_bars(dev);
64
Simon Glassd4d1e912016-01-17 16:11:20 -070065 /* Device Enable */
66 dm_pci_write_config32(dev, DEVEN, DEVEN_HOST | DEVEN_IGD);
67
Simon Glass061e9ea2016-01-17 16:11:15 -070068 return 0;
69}
70
71static const struct udevice_id bd82x6x_northbridge_ids[] = {
72 { .compatible = "intel,bd82x6x-northbridge" },
73 { }
74};
75
76U_BOOT_DRIVER(bd82x6x_northbridge_drv) = {
77 .name = "bd82x6x_northbridge",
78 .id = UCLASS_NORTHBRIDGE,
79 .of_match = bd82x6x_northbridge_ids,
80 .probe = bd82x6x_northbridge_probe,
81};