Simon Glass | 30580fc | 2014-11-12 22:42:23 -0700 | [diff] [blame] | 1 | /* |
| 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 Glass | 061e9ea | 2016-01-17 16:11:15 -0700 | [diff] [blame] | 11 | #include <dm.h> |
Simon Glass | 30580fc | 2014-11-12 22:42:23 -0700 | [diff] [blame] | 12 | #include <asm/io.h> |
| 13 | #include <asm/pci.h> |
| 14 | #include <asm/arch/pch.h> |
| 15 | #include <asm/arch/sandybridge.h> |
| 16 | |
Simon Glass | 99eecaa | 2016-01-17 16:11:17 -0700 | [diff] [blame] | 17 | static void sandybridge_setup_northbridge_bars(struct udevice *dev) |
| 18 | { |
Simon Glass | 30580fc | 2014-11-12 22:42:23 -0700 | [diff] [blame] | 19 | /* Set up all hardcoded northbridge BARs */ |
| 20 | debug("Setting up static registers\n"); |
Simon Glass | 99eecaa | 2016-01-17 16:11:17 -0700 | [diff] [blame] | 21 | 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 Glass | 30580fc | 2014-11-12 22:42:23 -0700 | [diff] [blame] | 25 | /* 64MB - busses 0-63 */ |
Simon Glass | 99eecaa | 2016-01-17 16:11:17 -0700 | [diff] [blame] | 26 | 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 Glass | 30580fc | 2014-11-12 22:42:23 -0700 | [diff] [blame] | 31 | |
| 32 | /* Set C0000-FFFFF to access RAM on both reads and writes */ |
Simon Glass | 99eecaa | 2016-01-17 16:11:17 -0700 | [diff] [blame] | 33 | 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 Glass | 30580fc | 2014-11-12 22:42:23 -0700 | [diff] [blame] | 40 | } |
| 41 | |
Simon Glass | 061e9ea | 2016-01-17 16:11:15 -0700 | [diff] [blame] | 42 | static int bd82x6x_northbridge_probe(struct udevice *dev) |
| 43 | { |
Simon Glass | aa0f23e | 2016-01-17 16:11:16 -0700 | [diff] [blame] | 44 | 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, ®8); |
| 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 Glass | 99eecaa | 2016-01-17 16:11:17 -0700 | [diff] [blame] | 63 | sandybridge_setup_northbridge_bars(dev); |
| 64 | |
Simon Glass | d4d1e91 | 2016-01-17 16:11:20 -0700 | [diff] [blame] | 65 | /* Device Enable */ |
| 66 | dm_pci_write_config32(dev, DEVEN, DEVEN_HOST | DEVEN_IGD); |
| 67 | |
Simon Glass | 061e9ea | 2016-01-17 16:11:15 -0700 | [diff] [blame] | 68 | return 0; |
| 69 | } |
| 70 | |
| 71 | static const struct udevice_id bd82x6x_northbridge_ids[] = { |
| 72 | { .compatible = "intel,bd82x6x-northbridge" }, |
| 73 | { } |
| 74 | }; |
| 75 | |
| 76 | U_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 | }; |