blob: 6e0a90f0fd9e4b4bca7384e6cfa4795789c8839c [file] [log] [blame]
Andrey Petrov70efecd2016-03-04 21:41:13 -08001/*
2 * This file is part of the coreboot project.
3 *
4 * Copyright (C) 2015 Intel Corp.
5 * (Written by Alexandru Gagniuc <alexandrux.gagniuc@intel.com> for Intel Corp.)
6 * (Written by Andrey Petrov <andrey.petrov@intel.com> for Intel Corp.)
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
Martin Rothebabfad2016-04-10 11:09:16 -060012 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
Andrey Petrov70efecd2016-03-04 21:41:13 -080017 */
18
19#include <bootstate.h>
Lance Zhao1bd0c0c2016-04-19 18:04:21 -070020#include <cbmem.h>
Andrey Petrov70efecd2016-03-04 21:41:13 -080021#include <console/console.h>
22#include <cpu/cpu.h>
23#include <device/device.h>
24#include <device/pci.h>
25#include <fsp/api.h>
26#include <fsp/util.h>
27#include <memrange.h>
Andrey Petrove07e13d2016-03-18 14:43:00 -070028#include <soc/iomap.h>
Andrey Petrov70efecd2016-03-04 21:41:13 -080029#include <soc/cpu.h>
Lance Zhao1bd0c0c2016-04-19 18:04:21 -070030#include <soc/nvs.h>
Andrey Petrov70efecd2016-03-04 21:41:13 -080031#include <soc/pci_devs.h>
32
33#include "chip.h"
34
35static void pci_domain_set_resources(device_t dev)
36{
37 assign_resources(dev->link_list);
38}
39
40static struct device_operations pci_domain_ops = {
41 .read_resources = pci_domain_read_resources,
42 .set_resources = pci_domain_set_resources,
43 .enable_resources = NULL,
44 .init = NULL,
45 .scan_bus = pci_domain_scan_bus,
46 .ops_pci_bus = pci_bus_default_ops,
47};
48
49static struct device_operations cpu_bus_ops = {
50 .read_resources = DEVICE_NOOP,
51 .set_resources = DEVICE_NOOP,
52 .enable_resources = DEVICE_NOOP,
53 .init = apollolake_init_cpus,
54 .scan_bus = NULL,
55};
56
57static void enable_dev(device_t dev)
58{
59 /* Set the operations if it is a special bus type */
60 if (dev->path.type == DEVICE_PATH_DOMAIN) {
61 dev->ops = &pci_domain_ops;
62 } else if (dev->path.type == DEVICE_PATH_CPU_CLUSTER) {
63 dev->ops = &cpu_bus_ops;
64 }
65}
66
67static void soc_init(void *data)
68{
69 struct range_entry range;
Lance Zhao1bd0c0c2016-04-19 18:04:21 -070070 struct global_nvs_t *gnvs;
Andrey Petrov70efecd2016-03-04 21:41:13 -080071
72 /* TODO: tigten this resource range */
73 /* TODO: fix for S3 resume, as this would corrupt OS memory */
74 range_entry_init(&range, 0x200000, 4ULL*GiB, 0);
75 fsp_silicon_init(&range);
Lance Zhao1bd0c0c2016-04-19 18:04:21 -070076
77 /* Allocate ACPI NVS in CBMEM */
78 gnvs = cbmem_add(CBMEM_ID_ACPI_GNVS, sizeof(*gnvs));
Andrey Petrov70efecd2016-03-04 21:41:13 -080079}
80
81void platform_fsp_silicon_init_params_cb(struct FSPS_UPD *silupd)
82{
83 struct FSP_S_CONFIG *silconfig = &silupd->FspsConfig;
84 static struct soc_intel_apollolake_config *cfg;
85
86 /* Load VBT before devicetree-specific config. */
87 silconfig->GraphicsConfigPtr = fsp_load_vbt();
88
89 struct device *dev = NB_DEV_ROOT;
Patrick Georgi831d65d2016-04-14 11:53:48 +020090 if (!dev || !dev->chip_info) {
Andrey Petrov70efecd2016-03-04 21:41:13 -080091 printk(BIOS_ERR, "BUG! Could not find SOC devicetree config\n");
92 return;
93 }
94
95 cfg = dev->chip_info;
96
97 silconfig->PcieRpClkReqNumber[0] = cfg->pcie_rp0_clkreq_pin;
98 silconfig->PcieRpClkReqNumber[1] = cfg->pcie_rp1_clkreq_pin;
99 silconfig->PcieRpClkReqNumber[2] = cfg->pcie_rp2_clkreq_pin;
100 silconfig->PcieRpClkReqNumber[3] = cfg->pcie_rp3_clkreq_pin;
101 silconfig->PcieRpClkReqNumber[4] = cfg->pcie_rp4_clkreq_pin;
102 silconfig->PcieRpClkReqNumber[5] = cfg->pcie_rp5_clkreq_pin;
Andrey Petrove07e13d2016-03-18 14:43:00 -0700103
104 /* Our defaults may not match FSP defaults, so set them explicitly */
105 silconfig->AcpiBase = ACPI_PMIO_BASE;
106 /* First 4k in BAR0 is used for IPC, real registers start at 4k offset */
107 silconfig->PmcBase = PMC_BAR0 + 0x1000;
108 silconfig->P2sbBase = P2SB_BAR;
Andrey Petrov70efecd2016-03-04 21:41:13 -0800109}
110
111struct chip_operations soc_intel_apollolake_ops = {
112 CHIP_NAME("Intel Apollolake SOC")
113 .enable_dev = &enable_dev,
114 .init = &soc_init
115};
116
117static void fsp_notify_dummy(void *arg)
118{
119
120 enum fsp_notify_phase ph = (enum fsp_notify_phase) arg;
121
122 if (fsp_notify(ph) != FSP_SUCCESS)
123 printk(BIOS_CRIT, "FspNotify failed!\n");
124}
125
126BOOT_STATE_INIT_ENTRY(BS_DEV_RESOURCES, BS_ON_EXIT, fsp_notify_dummy,
127 (void *) AFTER_PCI_ENUM);
128BOOT_STATE_INIT_ENTRY(BS_PAYLOAD_LOAD, BS_ON_EXIT, fsp_notify_dummy,
129 (void *) READY_TO_BOOT);
130BOOT_STATE_INIT_ENTRY(BS_OS_RESUME, BS_ON_ENTRY, fsp_notify_dummy,
131 (void *) READY_TO_BOOT);