early_init.c 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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. #include <common.h>
  10. #include <dm.h>
  11. #include <asm/io.h>
  12. #include <asm/pci.h>
  13. #include <asm/arch/pch.h>
  14. #include <asm/arch/sandybridge.h>
  15. static void sandybridge_setup_northbridge_bars(struct udevice *dev)
  16. {
  17. /* Set up all hardcoded northbridge BARs */
  18. debug("Setting up static registers\n");
  19. dm_pci_write_config32(dev, EPBAR, DEFAULT_EPBAR | 1);
  20. dm_pci_write_config32(dev, EPBAR + 4, (0LL + DEFAULT_EPBAR) >> 32);
  21. dm_pci_write_config32(dev, MCHBAR, DEFAULT_MCHBAR | 1);
  22. dm_pci_write_config32(dev, MCHBAR + 4, (0LL + DEFAULT_MCHBAR) >> 32);
  23. /* 64MB - busses 0-63 */
  24. dm_pci_write_config32(dev, PCIEXBAR, DEFAULT_PCIEXBAR | 5);
  25. dm_pci_write_config32(dev, PCIEXBAR + 4,
  26. (0LL + DEFAULT_PCIEXBAR) >> 32);
  27. dm_pci_write_config32(dev, DMIBAR, DEFAULT_DMIBAR | 1);
  28. dm_pci_write_config32(dev, DMIBAR + 4, (0LL + DEFAULT_DMIBAR) >> 32);
  29. /* Set C0000-FFFFF to access RAM on both reads and writes */
  30. dm_pci_write_config8(dev, PAM0, 0x30);
  31. dm_pci_write_config8(dev, PAM1, 0x33);
  32. dm_pci_write_config8(dev, PAM2, 0x33);
  33. dm_pci_write_config8(dev, PAM3, 0x33);
  34. dm_pci_write_config8(dev, PAM4, 0x33);
  35. dm_pci_write_config8(dev, PAM5, 0x33);
  36. dm_pci_write_config8(dev, PAM6, 0x33);
  37. }
  38. static int bd82x6x_northbridge_probe(struct udevice *dev)
  39. {
  40. const int chipset_type = SANDYBRIDGE_MOBILE;
  41. u32 capid0_a;
  42. u8 reg8;
  43. if (gd->flags & GD_FLG_RELOC)
  44. return 0;
  45. /* Device ID Override Enable should be done very early */
  46. dm_pci_read_config32(dev, 0xe4, &capid0_a);
  47. if (capid0_a & (1 << 10)) {
  48. dm_pci_read_config8(dev, 0xf3, &reg8);
  49. reg8 &= ~7; /* Clear 2:0 */
  50. if (chipset_type == SANDYBRIDGE_MOBILE)
  51. reg8 |= 1; /* Set bit 0 */
  52. dm_pci_write_config8(dev, 0xf3, reg8);
  53. }
  54. sandybridge_setup_northbridge_bars(dev);
  55. /* Device Enable */
  56. dm_pci_write_config32(dev, DEVEN, DEVEN_HOST | DEVEN_IGD);
  57. return 0;
  58. }
  59. static const struct udevice_id bd82x6x_northbridge_ids[] = {
  60. { .compatible = "intel,bd82x6x-northbridge" },
  61. { }
  62. };
  63. U_BOOT_DRIVER(bd82x6x_northbridge_drv) = {
  64. .name = "bd82x6x_northbridge",
  65. .id = UCLASS_NORTHBRIDGE,
  66. .of_match = bd82x6x_northbridge_ids,
  67. .probe = bd82x6x_northbridge_probe,
  68. };