blob: ae9b9a403c539d0add9590b2493a7a1287b13d78 [file] [log] [blame]
Ravi Sarawadi8069b5d2022-04-10 23:36:52 -07001/* SPDX-License-Identifier: GPL-2.0-only */
2
3#include <console/console.h>
Ravi Sarawadi91ffac82022-05-07 16:37:09 -07004#include <device/device.h>
Subrata Banik4ed30ca2022-10-27 15:44:54 +05305#include <device/pci_def.h>
Ravi Sarawadi8069b5d2022-04-10 23:36:52 -07006#include <intelblocks/p2sb.h>
Ravi Sarawadi91ffac82022-05-07 16:37:09 -07007#include <soc/iomap.h>
Ravi Sarawadi8069b5d2022-04-10 23:36:52 -07008
9void p2sb_soc_get_sb_mask(uint32_t *ep_mask, size_t count)
10{
11 uint32_t mask;
12
13 if (count != P2SB_EP_MASK_MAX_REG) {
14 printk(BIOS_ERR, "Unable to program EPMASK registers\n");
15 return;
16 }
17
18 /* Remove the host accessing right to PSF register range.
19 * Set p2sb PCI offset EPMASK5 [29, 28, 27, 26] to disable Sideband
20 * access for PCI Root Bridge.
21 */
22 mask = (1 << 29) | (1 << 28) | (1 << 27) | (1 << 26);
23
24 ep_mask[P2SB_EP_MASK_5_REG] = mask;
25
26 /*
27 * Set p2sb PCI offset EPMASK7 [31, 30] to disable Sideband
28 * access for Broadcast and Multicast.
29 */
30 mask = (1 << 31) | (1 << 30);
31
32 ep_mask[P2SB_EP_MASK_7_REG] = mask;
33}
Ravi Sarawadi91ffac82022-05-07 16:37:09 -070034
35static void ioe_p2sb_read_resources(struct device *dev)
36{
37 /* Add the fixed MMIO resource for IOM */
Subrata Banikf9c075d2022-10-31 17:35:50 +053038 mmio_range(dev, PCI_BASE_ADDRESS_0, IOM_BASE_ADDR, IOM_BASE_SIZE);
Ravi Sarawadi91ffac82022-05-07 16:37:09 -070039}
40
Subrata Banik4ed30ca2022-10-27 15:44:54 +053041static void p2sb_read_resources(struct device *dev)
42{
43 /*
44 * There's only one resource on the P2SB device. It's also already
45 * manually set to a fixed address in earlier boot stages.
46 * The following code makes sure that it doesn't change even the
47 * resource allocator is being run.
48 */
49 mmio_range(dev, PCI_BASE_ADDRESS_0, P2SB_BAR, P2SB_SIZE);
50}
51
Ravi Sarawadi91ffac82022-05-07 16:37:09 -070052struct device_operations ioe_p2sb_ops = {
53 .read_resources = ioe_p2sb_read_resources,
54 .set_resources = noop_set_resources,
55 .scan_bus = scan_static_bus,
56};
Subrata Banik4ed30ca2022-10-27 15:44:54 +053057
58struct device_operations soc_p2sb_ops = {
59 .read_resources = p2sb_read_resources,
60 .set_resources = noop_set_resources,
61 .scan_bus = scan_static_bus,
62};