blob: 83ef7b766516f500ea12155e40142af34f92f19b [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_lpc_bars(pci_dev_t lpc_dev)
Simon Glass30580fc2014-11-12 22:42:23 -070018{
19 /* Setting up Southbridge. In the northbridge code. */
20 debug("Setting up static southbridge registers\n");
Simon Glass240d06d2015-03-05 12:25:15 -070021 x86_pci_write_config32(lpc_dev, PCH_RCBA_BASE, DEFAULT_RCBA | 1);
Simon Glass30580fc2014-11-12 22:42:23 -070022
Simon Glass240d06d2015-03-05 12:25:15 -070023 x86_pci_write_config32(lpc_dev, PMBASE, DEFAULT_PMBASE | 1);
24 x86_pci_write_config8(lpc_dev, ACPI_CNTL, 0x80); /* Enable ACPI BAR */
Simon Glass30580fc2014-11-12 22:42:23 -070025
26 debug("Disabling watchdog reboot\n");
27 setbits_le32(RCB_REG(GCS), 1 >> 5); /* No reset */
28 outw(1 << 11, DEFAULT_PMBASE | 0x60 | 0x08); /* halt timer */
Simon Glass99eecaa2016-01-17 16:11:17 -070029}
Simon Glass30580fc2014-11-12 22:42:23 -070030
Simon Glass99eecaa2016-01-17 16:11:17 -070031static void sandybridge_setup_northbridge_bars(struct udevice *dev)
32{
Simon Glass30580fc2014-11-12 22:42:23 -070033 /* Set up all hardcoded northbridge BARs */
34 debug("Setting up static registers\n");
Simon Glass99eecaa2016-01-17 16:11:17 -070035 dm_pci_write_config32(dev, EPBAR, DEFAULT_EPBAR | 1);
36 dm_pci_write_config32(dev, EPBAR + 4, (0LL + DEFAULT_EPBAR) >> 32);
37 dm_pci_write_config32(dev, MCHBAR, DEFAULT_MCHBAR | 1);
38 dm_pci_write_config32(dev, MCHBAR + 4, (0LL + DEFAULT_MCHBAR) >> 32);
Simon Glass30580fc2014-11-12 22:42:23 -070039 /* 64MB - busses 0-63 */
Simon Glass99eecaa2016-01-17 16:11:17 -070040 dm_pci_write_config32(dev, PCIEXBAR, DEFAULT_PCIEXBAR | 5);
41 dm_pci_write_config32(dev, PCIEXBAR + 4,
42 (0LL + DEFAULT_PCIEXBAR) >> 32);
43 dm_pci_write_config32(dev, DMIBAR, DEFAULT_DMIBAR | 1);
44 dm_pci_write_config32(dev, DMIBAR + 4, (0LL + DEFAULT_DMIBAR) >> 32);
Simon Glass30580fc2014-11-12 22:42:23 -070045
46 /* Set C0000-FFFFF to access RAM on both reads and writes */
Simon Glass99eecaa2016-01-17 16:11:17 -070047 dm_pci_write_config8(dev, PAM0, 0x30);
48 dm_pci_write_config8(dev, PAM1, 0x33);
49 dm_pci_write_config8(dev, PAM2, 0x33);
50 dm_pci_write_config8(dev, PAM3, 0x33);
51 dm_pci_write_config8(dev, PAM4, 0x33);
52 dm_pci_write_config8(dev, PAM5, 0x33);
53 dm_pci_write_config8(dev, PAM6, 0x33);
Simon Glass30580fc2014-11-12 22:42:23 -070054}
55
Simon Glass061e9ea2016-01-17 16:11:15 -070056static int bd82x6x_northbridge_probe(struct udevice *dev)
57{
Simon Glassaa0f23e2016-01-17 16:11:16 -070058 const int chipset_type = SANDYBRIDGE_MOBILE;
59 u32 capid0_a;
60 u8 reg8;
61
62 if (gd->flags & GD_FLG_RELOC)
63 return 0;
64
65 /* Device ID Override Enable should be done very early */
66 dm_pci_read_config32(dev, 0xe4, &capid0_a);
67 if (capid0_a & (1 << 10)) {
68 dm_pci_read_config8(dev, 0xf3, &reg8);
69 reg8 &= ~7; /* Clear 2:0 */
70
71 if (chipset_type == SANDYBRIDGE_MOBILE)
72 reg8 |= 1; /* Set bit 0 */
73
74 dm_pci_write_config8(dev, 0xf3, reg8);
75 }
76
Simon Glass99eecaa2016-01-17 16:11:17 -070077 sandybridge_setup_lpc_bars(PCH_LPC_DEV);
78
79 sandybridge_setup_northbridge_bars(dev);
80
Simon Glassd4d1e912016-01-17 16:11:20 -070081 /* Device Enable */
82 dm_pci_write_config32(dev, DEVEN, DEVEN_HOST | DEVEN_IGD);
83
Simon Glass061e9ea2016-01-17 16:11:15 -070084 return 0;
85}
86
87static const struct udevice_id bd82x6x_northbridge_ids[] = {
88 { .compatible = "intel,bd82x6x-northbridge" },
89 { }
90};
91
92U_BOOT_DRIVER(bd82x6x_northbridge_drv) = {
93 .name = "bd82x6x_northbridge",
94 .id = UCLASS_NORTHBRIDGE,
95 .of_match = bd82x6x_northbridge_ids,
96 .probe = bd82x6x_northbridge_probe,
97};