2 * Copyright (C) 2014 Google, Inc
4 * SPDX-License-Identifier: GPL-2.0+
11 #include <asm/lapic.h>
13 #include <asm/arch/bd82x6x.h>
14 #include <asm/arch/model_206ax.h>
15 #include <asm/arch/pch.h>
16 #include <asm/arch/sandybridge.h>
18 void bd82x6x_pci_init(pci_dev_t dev)
23 debug("bd82x6x PCI init.\n");
24 /* Enable Bus Master */
25 reg16 = pci_read_config16(dev, PCI_COMMAND);
26 reg16 |= PCI_COMMAND_MASTER;
27 pci_write_config16(dev, PCI_COMMAND, reg16);
29 /* This device has no interrupt */
30 pci_write_config8(dev, INTR, 0xff);
32 /* disable parity error response and SERR */
33 reg16 = pci_read_config16(dev, BCTRL);
36 pci_write_config16(dev, BCTRL, reg16);
38 /* Master Latency Count must be set to 0x04! */
39 reg8 = pci_read_config8(dev, SMLT);
42 pci_write_config8(dev, SMLT, reg8);
44 /* Will this improve throughput of bus masters? */
45 pci_write_config8(dev, PCI_MIN_GNT, 0x06);
47 /* Clear errors in status registers */
48 reg16 = pci_read_config16(dev, PSTS);
49 /* reg16 |= 0xf900; */
50 pci_write_config16(dev, PSTS, reg16);
52 reg16 = pci_read_config16(dev, SECSTS);
53 /* reg16 |= 0xf900; */
54 pci_write_config16(dev, SECSTS, reg16);
57 #define PCI_BRIDGE_UPDATE_COMMAND
58 void bd82x6x_pci_dev_enable_resources(pci_dev_t dev)
62 command = pci_read_config16(dev, PCI_COMMAND);
63 command |= PCI_COMMAND_IO;
64 #ifdef PCI_BRIDGE_UPDATE_COMMAND
66 * If we write to PCI_COMMAND, on some systems this will cause the
67 * ROM and APICs to become invisible.
69 debug("%x cmd <- %02x\n", dev, command);
70 pci_write_config16(dev, PCI_COMMAND, command);
72 printf("%s cmd <- %02x (NOT WRITTEN!)\n", dev_path(dev), command);
76 void bd82x6x_pci_bus_enable_resources(pci_dev_t dev)
80 ctrl = pci_read_config16(dev, PCI_BRIDGE_CONTROL);
81 ctrl |= PCI_COMMAND_IO;
82 ctrl |= PCI_BRIDGE_CTL_VGA;
83 debug("%x bridge ctrl <- %04x\n", dev, ctrl);
84 pci_write_config16(dev, PCI_BRIDGE_CONTROL, ctrl);
86 bd82x6x_pci_dev_enable_resources(dev);
89 int bd82x6x_init_pci_devices(void)
91 const void *blob = gd->fdt_blob;
92 struct pci_controller *hose;
93 struct x86_cpu_priv *cpu;
94 int sata_node, gma_node;
97 hose = pci_bus_to_hose(0);
98 lpc_enable(PCH_LPC_DEV);
99 lpc_init(hose, PCH_LPC_DEV);
100 sata_node = fdtdec_next_compatible(blob, 0,
101 COMPAT_INTEL_PANTHERPOINT_AHCI);
103 debug("%s: Cannot find SATA node\n", __func__);
106 bd82x6x_sata_init(PCH_SATA_DEV, blob, sata_node);
107 bd82x6x_usb_ehci_init(PCH_EHCI1_DEV);
108 bd82x6x_usb_ehci_init(PCH_EHCI2_DEV);
110 cpu = calloc(1, sizeof(*cpu));
113 model_206ax_init(cpu);
115 gma_node = fdtdec_next_compatible(blob, 0, COMPAT_INTEL_GMA);
117 debug("%s: Cannot find GMA node\n", __func__);
120 ret = gma_func0_init(PCH_VIDEO_DEV, pci_bus_to_hose(0), blob,
128 int bd82x6x_init(void)
130 const void *blob = gd->fdt_blob;
133 sata_node = fdtdec_next_compatible(blob, 0,
134 COMPAT_INTEL_PANTHERPOINT_AHCI);
136 debug("%s: Cannot find SATA node\n", __func__);
140 bd82x6x_pci_init(PCH_DEV);
141 bd82x6x_sata_enable(PCH_SATA_DEV, blob, sata_node);
142 northbridge_enable(PCH_DEV);
143 northbridge_init(PCH_DEV);