blob: 94a5a8ec143f6c23773919458de72dde78e7a45d [file] [log] [blame]
Aaron Durbin9a7d7bc2013-09-07 00:41:48 -05001/*
2 * This file is part of the coreboot project.
3 *
4 * Copyright (C) 2013 Google Inc.
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; version 2 of the License.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
Aaron Durbin9a7d7bc2013-09-07 00:41:48 -050014 */
15
16#include <console/console.h>
17#include <device/device.h>
18#include <device/pci.h>
19#include <arch/pci_ops.h>
20
Julius Werner18ea2d32014-10-07 16:42:17 -070021#include <soc/pci_devs.h>
22#include <soc/ramstage.h>
Aaron Durbin9a7d7bc2013-09-07 00:41:48 -050023#include "chip.h"
24
Elyes HAOUAS17a3ceb2018-05-22 10:42:28 +020025static void pci_domain_set_resources(struct device *dev)
Aaron Durbin9a7d7bc2013-09-07 00:41:48 -050026{
27 assign_resources(dev->link_list);
28}
29
30static struct device_operations pci_domain_ops = {
31 .read_resources = pci_domain_read_resources,
32 .set_resources = pci_domain_set_resources,
33 .enable_resources = NULL,
34 .init = NULL,
35 .scan_bus = pci_domain_scan_bus,
Aaron Durbin9a7d7bc2013-09-07 00:41:48 -050036};
37
Aaron Durbin9a7d7bc2013-09-07 00:41:48 -050038static struct device_operations cpu_bus_ops = {
Edward O'Callaghan0625a8b2014-10-31 08:03:16 +110039 .read_resources = DEVICE_NOOP,
40 .set_resources = DEVICE_NOOP,
41 .enable_resources = DEVICE_NOOP,
Aaron Durbin302cbd62013-10-21 12:36:17 -050042 .init = baytrail_init_cpus,
Aaron Durbinfda56a62013-09-24 12:29:57 -050043 .scan_bus = NULL,
Aaron Durbin9a7d7bc2013-09-07 00:41:48 -050044};
45
46
Elyes HAOUAS17a3ceb2018-05-22 10:42:28 +020047static void enable_dev(struct device *dev)
Aaron Durbin9a7d7bc2013-09-07 00:41:48 -050048{
Aaron Durbin9a7d7bc2013-09-07 00:41:48 -050049 /* Set the operations if it is a special bus type */
50 if (dev->path.type == DEVICE_PATH_DOMAIN) {
51 dev->ops = &pci_domain_ops;
52 } else if (dev->path.type == DEVICE_PATH_CPU_CLUSTER) {
53 dev->ops = &cpu_bus_ops;
Aaron Durbind7bc23a2013-10-29 16:37:10 -050054 } else if (dev->path.type == DEVICE_PATH_PCI) {
55 /* Handle south cluster enablement. */
56 if (PCI_SLOT(dev->path.pci.devfn) > GFX_DEV &&
57 (dev->ops == NULL || dev->ops->enable == NULL)) {
58 southcluster_enable_dev(dev);
59 }
Aaron Durbin9a7d7bc2013-09-07 00:41:48 -050060 }
61}
62
Aaron Durbin452d31a2013-09-24 16:47:49 -050063/* Called at BS_DEV_INIT_CHIPS time -- very early. Just after BS_PRE_DEVICE. */
64static void soc_init(void *chip_info)
65{
Kein Yuan35110232014-02-22 12:26:55 -080066 baytrail_init_pre_device(chip_info);
Aaron Durbin452d31a2013-09-24 16:47:49 -050067}
68
Aaron Durbin9a7d7bc2013-09-07 00:41:48 -050069struct chip_operations soc_intel_baytrail_ops = {
70 CHIP_NAME("Intel BayTrail SoC")
71 .enable_dev = enable_dev,
Aaron Durbin452d31a2013-09-24 16:47:49 -050072 .init = soc_init,
Aaron Durbin9a7d7bc2013-09-07 00:41:48 -050073};
Aaron Durbinfda56a62013-09-24 12:29:57 -050074
Elyes HAOUAS17a3ceb2018-05-22 10:42:28 +020075static void pci_set_subsystem(struct device *dev, unsigned vendor,
76 unsigned device)
Aaron Durbinfda56a62013-09-24 12:29:57 -050077{
78 if (!vendor || !device) {
79 pci_write_config32(dev, PCI_SUBSYSTEM_VENDOR_ID,
80 pci_read_config32(dev, PCI_VENDOR_ID));
81 } else {
82 pci_write_config32(dev, PCI_SUBSYSTEM_VENDOR_ID,
83 ((device & 0xffff) << 16) | (vendor & 0xffff));
84 }
85}
86
87struct pci_operations soc_pci_ops = {
88 .set_subsystem = &pci_set_subsystem,
89};