coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
p2sb.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 
3 #define __SIMPLE_DEVICE__
4 
5 #include <device/pci_ops.h>
6 #include <console/console.h>
7 #include <device/device.h>
8 #include <device/pci.h>
9 #include <device/pci_ids.h>
10 #include <intelblocks/p2sb.h>
11 #include <intelblocks/p2sblib.h>
12 #include <soc/iomap.h>
13 #include <soc/p2sb.h>
14 #include <soc/pci_devs.h>
15 #include <string.h>
16 
17 #define PCH_P2SB_EPMASK(mask_number) (PCH_P2SB_EPMASK0 + ((mask_number) * 4))
18 
19 void p2sb_enable_bar(void)
20 {
22 }
23 
24 /*
25  * Enable decoding for HPET range.
26  * This is needed for FspMemoryInit to store and retrieve a global data
27  * pointer.
28  */
30 {
31  /*
32  * Enable decoding for HPET memory address range.
33  * HPTC_OFFSET(0x60) bit 7, when set the P2SB will decode
34  * the High Performance Timer memory address range
35  * selected by bits 1:0
36  */
38 }
39 
41 {
42  const bool was_hidden = p2sb_dev_is_hidden(PCH_DEV_P2SB);
43  if (was_hidden)
44  p2sb_unhide();
45 
47 
48  if (was_hidden)
49  p2sb_hide();
50 
51  return bdf;
52 }
53 
54 void p2sb_set_hpet_bdf(union p2sb_bdf bdf)
55 {
57 }
58 
60 {
61  const bool was_hidden = p2sb_dev_is_hidden(PCH_DEV_P2SB);
62  if (was_hidden)
63  p2sb_unhide();
64 
66 
67  if (was_hidden)
68  p2sb_hide();
69 
70  return bdf;
71 }
72 
74 {
76 }
77 
78 void p2sb_unhide(void)
79 {
81 }
82 
83 void p2sb_hide(void)
84 {
86 }
87 
88 static void p2sb_configure_endpoints(int epmask_id, uint32_t mask)
89 {
90  uint32_t reg32;
91 
92  reg32 = pci_read_config32(PCH_DEV_P2SB, PCH_P2SB_EPMASK(epmask_id));
94  reg32 | mask);
95 }
96 
97 static void p2sb_lock_endpoints(void)
98 {
99  uint8_t reg8;
100 
101  /* Set the "Endpoint Mask Lock!", P2SB PCI offset E2h bit[1] to 1. */
104  reg8 | P2SB_E0_MASKLOCK);
105 }
106 
108 {
110  int i;
111 
112  memset(ep_mask, 0, sizeof(ep_mask));
113 
114  p2sb_soc_get_sb_mask(ep_mask, ARRAY_SIZE(ep_mask));
115 
116  /* Remove the host accessing right to PSF register range. */
117  for (i = 0; i < P2SB_EP_MASK_MAX_REG; i++)
118  p2sb_configure_endpoints(i, ep_mask[i]);
119 
121 }
122 
123 static void read_resources(struct device *dev)
124 {
125  /*
126  * There's only one resource on the P2SB device. It's also already
127  * manually set to a fixed address in earlier boot stages.
128  * The following code makes sure that it doesn't change if the device
129  * is visible and the resource allocator is being run.
130  */
132 }
133 
134 static const struct device_operations device_ops = {
136  .set_resources = noop_set_resources,
137  .ops_pci = &pci_dev_ops_pci,
138 };
139 
140 static const unsigned short pci_device_ids[] = {
161  0,
162 };
163 
164 static const struct pci_driver pmc __pci_driver = {
165  .ops = &device_ops,
166  .vendor = PCI_VID_INTEL,
167  .devices = pci_device_ids,
168 };
#define HPTC_ADDR_ENABLE_BIT
Definition: p2sb.h:13
#define HPTC_OFFSET
Definition: p2sb.h:12
void p2sb_soc_get_sb_mask(uint32_t *ep_mask, size_t count)
Definition: p2sb.c:12
void * memset(void *dstpp, int c, size_t len)
Definition: memset.c:12
#define ARRAY_SIZE(a)
Definition: helpers.h:12
#define KiB
Definition: helpers.h:75
#define PCH_P2SB_IBDF
Definition: p2sb.h:11
#define P2SB_E0_MASKLOCK
Definition: p2sb.h:10
@ P2SB_EP_MASK_MAX_REG
Definition: p2sb.h:23
#define PCH_P2SB_E0
Definition: p2sb.h:9
#define PCH_P2SB_HBDF
Definition: p2sb.h:12
#define PCH_P2SB_EPMASK(mask_number)
Definition: p2sb.c:17
union p2sb_bdf p2sb_get_ioapic_bdf(void)
Definition: p2sb.c:59
static const struct pci_driver pmc __pci_driver
Definition: p2sb.c:164
void p2sb_set_ioapic_bdf(union p2sb_bdf bdf)
Definition: p2sb.c:73
static const struct device_operations device_ops
Definition: p2sb.c:134
void p2sb_hide(void)
Definition: p2sb.c:83
void p2sb_disable_sideband_access(void)
Definition: p2sb.c:107
union p2sb_bdf p2sb_get_hpet_bdf(void)
Definition: p2sb.c:40
void p2sb_set_hpet_bdf(union p2sb_bdf bdf)
Definition: p2sb.c:54
static const unsigned short pci_device_ids[]
Definition: p2sb.c:140
void p2sb_enable_bar(void)
Definition: p2sb.c:19
void p2sb_configure_hpet(void)
Definition: p2sb.c:29
static void p2sb_lock_endpoints(void)
Definition: p2sb.c:97
void p2sb_unhide(void)
Definition: p2sb.c:78
static void read_resources(struct device *dev)
Definition: p2sb.c:123
static void p2sb_configure_endpoints(int epmask_id, uint32_t mask)
Definition: p2sb.c:88
static void noop_set_resources(struct device *dev)
Definition: device.h:74
#define mmio_resource(dev, idx, basek, sizek)
Definition: device.h:334
static __always_inline void pci_write_config32(const struct device *dev, u16 reg, u32 val)
Definition: pci_ops.h:76
static __always_inline u16 pci_read_config16(const struct device *dev, u16 reg)
Definition: pci_ops.h:52
static __always_inline u32 pci_read_config32(const struct device *dev, u16 reg)
Definition: pci_ops.h:58
static __always_inline u8 pci_read_config8(const struct device *dev, u16 reg)
Definition: pci_ops.h:46
static __always_inline void pci_write_config16(const struct device *dev, u16 reg, u16 val)
Definition: pci_ops.h:70
static __always_inline void pci_write_config8(const struct device *dev, u16 reg, u8 val)
Definition: pci_ops.h:64
#define P2SB_SIZE
Definition: iomap.h:106
#define P2SB_BAR
Definition: iomap.h:105
bool p2sb_dev_is_hidden(pci_devfn_t dev)
Definition: p2sblib.c:23
void p2sb_dev_unhide(pci_devfn_t dev)
Definition: p2sblib.c:48
void p2sb_dev_enable_bar(pci_devfn_t dev, uint64_t bar)
Definition: p2sblib.c:13
void p2sb_dev_hide(pci_devfn_t dev)
Definition: p2sblib.c:57
#define PCI_BASE_ADDRESS_0
Definition: pci_def.h:63
struct pci_operations pci_dev_ops_pci
Default device operation for PCI devices.
Definition: pci_device.c:911
#define PCI_DID_INTEL_EHL_P2SB
Definition: pci_ids.h:4156
#define PCI_DID_INTEL_SKL_LP_P2SB
Definition: pci_ids.h:4146
#define PCI_DID_INTEL_GLK_P2SB
Definition: pci_ids.h:4143
#define PCI_DID_INTEL_CNL_P2SB
Definition: pci_ids.h:4149
#define PCI_DID_INTEL_ADP_M_P2SB
Definition: pci_ids.h:4160
#define PCI_DID_INTEL_CMP_P2SB
Definition: pci_ids.h:4152
#define PCI_DID_INTEL_APL_P2SB
Definition: pci_ids.h:4142
#define PCI_DID_INTEL_LWB_P2SB_SUPER
Definition: pci_ids.h:4145
#define PCI_DID_INTEL_KBL_P2SB
Definition: pci_ids.h:4148
#define PCI_DID_INTEL_TGL_P2SB
Definition: pci_ids.h:4154
#define PCI_DID_INTEL_LWB_P2SB
Definition: pci_ids.h:4144
#define PCI_DID_INTEL_ADP_P_P2SB
Definition: pci_ids.h:4158
#define PCI_DID_INTEL_ADP_S_P2SB
Definition: pci_ids.h:4159
#define PCI_DID_INTEL_SKL_P2SB
Definition: pci_ids.h:4147
#define PCI_DID_INTEL_CNP_H_P2SB
Definition: pci_ids.h:4150
#define PCI_DID_INTEL_MTL_SOC_P2SB
Definition: pci_ids.h:4161
#define PCI_DID_INTEL_TGL_H_P2SB
Definition: pci_ids.h:4155
#define PCI_VID_INTEL
Definition: pci_ids.h:2157
#define PCI_DID_INTEL_JSP_P2SB
Definition: pci_ids.h:4157
#define PCI_DID_INTEL_ICL_P2SB
Definition: pci_ids.h:4151
#define PCI_DID_INTEL_CMP_H_P2SB
Definition: pci_ids.h:4153
#define PCH_DEV_P2SB
Definition: pci_devs.h:225
static const int mask[4]
Definition: gpio.c:308
static struct tegra_pmc_regs * pmc
Definition: clock.c:19
unsigned int uint32_t
Definition: stdint.h:14
unsigned char uint8_t
Definition: stdint.h:8
void(* read_resources)(struct device *dev)
Definition: device.h:39
Definition: device.h:107
Definition: p2sb.h:40
uint16_t dev
Definition: p2sb.h:43
uint16_t raw
Definition: p2sb.h:46
typedef void(X86APIP X86EMU_intrFuncs)(int num)