blob: 5e90f30e08b03069de53e49779fa2e6223b08e94 [file] [log] [blame]
Simon Glass6e5b12b2014-11-12 22:42:13 -07001/*
2 * Copyright (c) 2011 The Chromium OS Authors.
3 * (C) Copyright 2008,2009
4 * Graeme Russ, <graeme.russ@gmail.com>
5 *
6 * (C) Copyright 2002
7 * Daniel Engström, Omicron Ceti AB, <daniel@omicron.se>
8 *
9 * SPDX-License-Identifier: GPL-2.0+
10 */
11
12#include <common.h>
Simon Glassaad78d22015-03-05 12:25:33 -070013#include <dm.h>
Simon Glass6e5b12b2014-11-12 22:42:13 -070014#include <pci.h>
15#include <asm/pci.h>
Simon Glassaad78d22015-03-05 12:25:33 -070016#include <asm/post.h>
Simon Glass4e7a6ac2014-11-14 18:18:32 -070017#include <asm/arch/bd82x6x.h>
18#include <asm/arch/pch.h>
Simon Glass6e5b12b2014-11-12 22:42:13 -070019
Simon Glassaad78d22015-03-05 12:25:33 -070020static int pci_ivybridge_probe(struct udevice *bus)
Simon Glass6e5b12b2014-11-12 22:42:13 -070021{
Simon Glassaad78d22015-03-05 12:25:33 -070022 struct pci_controller *hose = dev_get_uclass_priv(bus);
Simon Glass4e7a6ac2014-11-14 18:18:32 -070023 pci_dev_t dev;
24 u16 reg16;
25
Simon Glassaad78d22015-03-05 12:25:33 -070026 if (!(gd->flags & GD_FLG_RELOC))
27 return 0;
28 post_code(0x50);
Simon Glass4e7a6ac2014-11-14 18:18:32 -070029 bd82x6x_init();
Simon Glassaad78d22015-03-05 12:25:33 -070030 post_code(0x51);
Simon Glass4e7a6ac2014-11-14 18:18:32 -070031
32 reg16 = 0xff;
33 dev = PCH_DEV;
Simon Glass31f57c22015-03-05 12:25:15 -070034 reg16 = x86_pci_read_config16(dev, PCI_COMMAND);
Simon Glass4e7a6ac2014-11-14 18:18:32 -070035 reg16 |= PCI_COMMAND_SERR | PCI_COMMAND_MASTER | PCI_COMMAND_MEMORY;
Simon Glass31f57c22015-03-05 12:25:15 -070036 x86_pci_write_config16(dev, PCI_COMMAND, reg16);
Simon Glass4e7a6ac2014-11-14 18:18:32 -070037
38 /*
39 * Clear non-reserved bits in status register.
40 */
41 pci_hose_write_config_word(hose, dev, PCI_STATUS, 0xffff);
42 pci_hose_write_config_byte(hose, dev, PCI_LATENCY_TIMER, 0x80);
43 pci_hose_write_config_byte(hose, dev, PCI_CACHE_LINE_SIZE, 0x08);
44
45 pci_write_bar32(hose, dev, 0, 0xf0000000);
Simon Glassaad78d22015-03-05 12:25:33 -070046 post_code(0x52);
Simon Glass4e7a6ac2014-11-14 18:18:32 -070047
48 return 0;
49}
50
Simon Glassaad78d22015-03-05 12:25:33 -070051static const struct dm_pci_ops pci_ivybridge_ops = {
52 .read_config = pci_x86_read_config,
53 .write_config = pci_x86_write_config,
54};
Simon Glass4e7a6ac2014-11-14 18:18:32 -070055
Simon Glassaad78d22015-03-05 12:25:33 -070056static const struct udevice_id pci_ivybridge_ids[] = {
57 { .compatible = "intel,pci-ivybridge" },
58 { }
59};
Simon Glass4e7a6ac2014-11-14 18:18:32 -070060
Simon Glassaad78d22015-03-05 12:25:33 -070061U_BOOT_DRIVER(pci_ivybridge_drv) = {
62 .name = "pci_ivybridge",
63 .id = UCLASS_PCI,
64 .of_match = pci_ivybridge_ids,
65 .ops = &pci_ivybridge_ops,
66 .probe = pci_ivybridge_probe,
67};