blob: 3172b7324701c934f7bad8864a6eaeb15f8b7de4 [file] [log] [blame]
Lee Leahy77ff0b12015-05-05 15:07:29 -07001/*
2 * This file is part of the coreboot project.
3 *
4 * Copyright (C) 2013 Google Inc.
Lee Leahy32471722015-04-20 15:20:28 -07005 * Copyright (C) 2015 Intel Corp.
Lee Leahy77ff0b12015-05-05 15:07:29 -07006 *
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.
Lee Leahy77ff0b12015-05-05 15:07:29 -070015 */
16
17
18#include <cbmem.h>
19#include <console/console.h>
20#include <device/device.h>
21#include <device/pci.h>
22#include <device/pci_ids.h>
Lee Leahy77ff0b12015-05-05 15:07:29 -070023#include <soc/iosf.h>
24#include <soc/nvs.h>
25#include <soc/ramstage.h>
26
Lee Leahy77ff0b12015-05-05 15:07:29 -070027void scc_enable_acpi_mode(device_t dev, int iosf_reg, int nvs_index)
28{
Lee Leahy77ff0b12015-05-05 15:07:29 -070029 struct resource *bar;
30 global_nvs_t *gnvs;
31
Lee Leahy32471722015-04-20 15:20:28 -070032 printk(BIOS_SPEW, "%s/%s ( %s, 0x%08x, 0x%08x )\n",
33 __FILE__, __func__, dev_name(dev), iosf_reg, nvs_index);
34
Lee Leahy77ff0b12015-05-05 15:07:29 -070035 /* Find ACPI NVS to update BARs */
Lee Leahy32471722015-04-20 15:20:28 -070036 gnvs = cbmem_find(CBMEM_ID_ACPI_GNVS);
Lee Leahy77ff0b12015-05-05 15:07:29 -070037 if (!gnvs) {
38 printk(BIOS_ERR, "Unable to locate Global NVS\n");
39 return;
40 }
41
42 /* Save BAR0 and BAR1 to ACPI NVS */
43 bar = find_resource(dev, PCI_BASE_ADDRESS_0);
44 if (bar)
45 gnvs->dev.scc_bar0[nvs_index] = (u32)bar->base;
46
Lee Leahy77ff0b12015-05-05 15:07:29 -070047 /* Device is enabled in ACPI mode */
48 gnvs->dev.scc_en[nvs_index] = 1;
Lee Leahy77ff0b12015-05-05 15:07:29 -070049}