Ravi Sarawadi | 8069b5d | 2022-04-10 23:36:52 -0700 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
| 2 | |
| 3 | #include <console/console.h> |
Ravi Sarawadi | 91ffac8 | 2022-05-07 16:37:09 -0700 | [diff] [blame] | 4 | #include <device/device.h> |
Subrata Banik | 4ed30ca | 2022-10-27 15:44:54 +0530 | [diff] [blame] | 5 | #include <device/pci_def.h> |
Ravi Sarawadi | 8069b5d | 2022-04-10 23:36:52 -0700 | [diff] [blame] | 6 | #include <intelblocks/p2sb.h> |
Ravi Sarawadi | 91ffac8 | 2022-05-07 16:37:09 -0700 | [diff] [blame] | 7 | #include <soc/iomap.h> |
Ravi Sarawadi | 8069b5d | 2022-04-10 23:36:52 -0700 | [diff] [blame] | 8 | |
| 9 | void 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 Sarawadi | 91ffac8 | 2022-05-07 16:37:09 -0700 | [diff] [blame] | 34 | |
| 35 | static void ioe_p2sb_read_resources(struct device *dev) |
| 36 | { |
| 37 | /* Add the fixed MMIO resource for IOM */ |
Subrata Banik | f9c075d | 2022-10-31 17:35:50 +0530 | [diff] [blame] | 38 | mmio_range(dev, PCI_BASE_ADDRESS_0, IOM_BASE_ADDR, IOM_BASE_SIZE); |
Ravi Sarawadi | 91ffac8 | 2022-05-07 16:37:09 -0700 | [diff] [blame] | 39 | } |
| 40 | |
Subrata Banik | 4ed30ca | 2022-10-27 15:44:54 +0530 | [diff] [blame] | 41 | static 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 Sarawadi | 91ffac8 | 2022-05-07 16:37:09 -0700 | [diff] [blame] | 52 | struct 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 Banik | 4ed30ca | 2022-10-27 15:44:54 +0530 | [diff] [blame] | 57 | |
| 58 | struct device_operations soc_p2sb_ops = { |
| 59 | .read_resources = p2sb_read_resources, |
| 60 | .set_resources = noop_set_resources, |
| 61 | .scan_bus = scan_static_bus, |
| 62 | }; |