Simon Glass | 3274ae0 | 2014-11-12 22:42:13 -0700 | [diff] [blame] | 1 | /* |
| 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 Glass | e0e7b36 | 2015-03-05 12:25:33 -0700 | [diff] [blame] | 13 | #include <dm.h> |
Simon Glass | 3274ae0 | 2014-11-12 22:42:13 -0700 | [diff] [blame] | 14 | #include <pci.h> |
| 15 | #include <asm/pci.h> |
Simon Glass | e0e7b36 | 2015-03-05 12:25:33 -0700 | [diff] [blame] | 16 | #include <asm/post.h> |
Simon Glass | 17f1c40 | 2014-11-14 18:18:32 -0700 | [diff] [blame] | 17 | #include <asm/arch/bd82x6x.h> |
| 18 | #include <asm/arch/pch.h> |
Simon Glass | 3274ae0 | 2014-11-12 22:42:13 -0700 | [diff] [blame] | 19 | |
Simon Glass | e0e7b36 | 2015-03-05 12:25:33 -0700 | [diff] [blame] | 20 | static int pci_ivybridge_probe(struct udevice *bus) |
Simon Glass | 3274ae0 | 2014-11-12 22:42:13 -0700 | [diff] [blame] | 21 | { |
Simon Glass | e0e7b36 | 2015-03-05 12:25:33 -0700 | [diff] [blame] | 22 | struct pci_controller *hose = dev_get_uclass_priv(bus); |
Simon Glass | 17f1c40 | 2014-11-14 18:18:32 -0700 | [diff] [blame] | 23 | pci_dev_t dev; |
| 24 | u16 reg16; |
| 25 | |
Simon Glass | e0e7b36 | 2015-03-05 12:25:33 -0700 | [diff] [blame] | 26 | if (!(gd->flags & GD_FLG_RELOC)) |
| 27 | return 0; |
| 28 | post_code(0x50); |
Simon Glass | 17f1c40 | 2014-11-14 18:18:32 -0700 | [diff] [blame] | 29 | bd82x6x_init(); |
Simon Glass | e0e7b36 | 2015-03-05 12:25:33 -0700 | [diff] [blame] | 30 | post_code(0x51); |
Simon Glass | 17f1c40 | 2014-11-14 18:18:32 -0700 | [diff] [blame] | 31 | |
| 32 | reg16 = 0xff; |
| 33 | dev = PCH_DEV; |
Simon Glass | 240d06d | 2015-03-05 12:25:15 -0700 | [diff] [blame] | 34 | reg16 = x86_pci_read_config16(dev, PCI_COMMAND); |
Simon Glass | 17f1c40 | 2014-11-14 18:18:32 -0700 | [diff] [blame] | 35 | reg16 |= PCI_COMMAND_SERR | PCI_COMMAND_MASTER | PCI_COMMAND_MEMORY; |
Simon Glass | 240d06d | 2015-03-05 12:25:15 -0700 | [diff] [blame] | 36 | x86_pci_write_config16(dev, PCI_COMMAND, reg16); |
Simon Glass | 17f1c40 | 2014-11-14 18:18:32 -0700 | [diff] [blame] | 37 | |
| 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 Glass | e0e7b36 | 2015-03-05 12:25:33 -0700 | [diff] [blame] | 46 | post_code(0x52); |
Simon Glass | 17f1c40 | 2014-11-14 18:18:32 -0700 | [diff] [blame] | 47 | |
| 48 | return 0; |
| 49 | } |
| 50 | |
Simon Glass | e0e7b36 | 2015-03-05 12:25:33 -0700 | [diff] [blame] | 51 | static const struct dm_pci_ops pci_ivybridge_ops = { |
| 52 | .read_config = pci_x86_read_config, |
| 53 | .write_config = pci_x86_write_config, |
| 54 | }; |
Simon Glass | 17f1c40 | 2014-11-14 18:18:32 -0700 | [diff] [blame] | 55 | |
Simon Glass | e0e7b36 | 2015-03-05 12:25:33 -0700 | [diff] [blame] | 56 | static const struct udevice_id pci_ivybridge_ids[] = { |
| 57 | { .compatible = "intel,pci-ivybridge" }, |
| 58 | { } |
| 59 | }; |
Simon Glass | 17f1c40 | 2014-11-14 18:18:32 -0700 | [diff] [blame] | 60 | |
Simon Glass | e0e7b36 | 2015-03-05 12:25:33 -0700 | [diff] [blame] | 61 | U_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 | }; |