blob: 62b20a3f7b1333ad55508cef7315569e2150add5 [file] [log] [blame]
Uwe Hermannc6a10622010-10-17 19:30:58 +00001/*
2 * This file is part of the coreboot project.
3 *
4 * Copyright (C) 2005 AMD
5 * Written by Yinghai Lu <yinghai.lu@amd.com> for AMD.
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; version 2 of the License.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
Uwe Hermannc6a10622010-10-17 19:30:58 +000015 */
16
Uwe Hermann42b1c432010-12-09 18:09:14 +000017#include <stdint.h>
18#include <arch/io.h>
Uwe Hermann42b1c432010-12-09 18:09:14 +000019#include <device/pci_ids.h>
Kyösti Mälkki8a41f4b2019-02-08 18:14:34 +020020#include <device/pci_type.h>
21
22#define PCI_ID(VENDOR_ID, DEVICE_ID) \
23 ((((DEVICE_ID) & 0xFFFF) << 16) | ((VENDOR_ID) & 0xFFFF))
24
25static pci_devfn_t pci_locate_device(unsigned int pci_id, pci_devfn_t dev)
26{
27 for (; dev <= PCI_DEV(255, 31, 7); dev += PCI_DEV(0, 0, 1)) {
28 unsigned int id;
29 id = pci_read_config32(dev, 0);
30 if (id == pci_id)
31 return dev;
32 }
33 return PCI_DEV_INVALID;
34}
Uwe Hermann42b1c432010-12-09 18:09:14 +000035
36/* Enable 4MB ROM access at 0xFFC00000 - 0xFFFFFFFF. */
37static void bcm5785_enable_rom(void)
38{
39 u8 byte;
Edward O'Callaghan9a817ef2014-10-26 10:12:15 +110040 pci_devfn_t dev;
Uwe Hermann42b1c432010-12-09 18:09:14 +000041
42 dev = pci_locate_device(PCI_ID(PCI_VENDOR_ID_SERVERWORKS,
43 PCI_DEVICE_ID_SERVERWORKS_BCM5785_SB_PCI_MAIN), 0);
44
45 /* Set the 4MB enable bits. */
46 byte = pci_read_config8(dev, 0x41);
47 byte |= 0x0e;
48 pci_write_config8(dev, 0x41, byte);
49}
Patrick Georgi78c733c2010-05-22 15:07:15 +000050
Uwe Hermann39124dd2010-11-26 22:42:41 +000051static void bootblock_southbridge_init(void)
52{
53 bcm5785_enable_rom();
Patrick Georgi78c733c2010-05-22 15:07:15 +000054}