1 /* SPDX-License-Identifier: GPL-2.0+ */
3 * Copyright 2019 Google LLC
4 * Written by Simon Glass <sjg@chromium.org>
10 /* Port Id lives in bits 23:16 and register offset lives in 15:0 of address */
11 #define PCR_PORTID_SHIFT 16
13 #if !defined(__ACPI__)
15 /* These registers contain IOAPIC and HPET devfn */
16 #define PCH_P2SB_IBDF 0x6c
17 #define PCH_P2SB_HBDF 0x70
20 * struct p2sb_child_plat - Information about each child of a p2sb device
22 * @pid: Port ID for this child
24 struct p2sb_child_plat {
29 * struct p2sb_uc_priv - information for the uclass about each device
31 * This must be set up by the driver when it is probed
33 * @mmio_base: Base address of P2SB region
40 * struct p2sb_ops - Operations for the P2SB
44 * set_hide() - Set/clear the 'hide' bit on the p2sb
46 * This device can be hidden from the PCI bus if needed. This method
47 * can be called before the p2sb is probed.
50 * @hide: true to hide the device, false to show it
51 * @return 0 if OK, -ve on error
53 int (*set_hide)(struct udevice *dev, bool hide);
56 #define p2sb_get_ops(dev) ((struct p2sb_ops *)(dev)->driver->ops)
59 * p2sb_set_hide() - Set/clear the 'hide' bit on the p2sb
61 * This device can be hidden from the PCI bus if needed. This method
62 * can be called before the p2sb is probed.
65 * @hide: true to hide the device, false to show it
66 * @return 0 if OK, -ve on error
68 int p2sb_set_hide(struct udevice *dev, bool hide);
71 * pcr_read32/16/8() - Read from a PCR device
73 * Reads data from a PCR device within the P2SB
75 * @dev: Device to read from
76 * @offset: Offset within device to read
79 uint pcr_read32(struct udevice *dev, uint offset);
80 uint pcr_read16(struct udevice *dev, uint offset);
81 uint pcr_read8(struct udevice *dev, uint offset);
84 * pcr_read32/16/8() - Write to a PCR device
86 * Writes data to a PCR device within the P2SB
88 * @dev: Device to write to
89 * @offset: Offset within device to write
90 * @data: Data to write
92 void pcr_write32(struct udevice *dev, uint offset, uint data);
93 void pcr_write16(struct udevice *dev, uint offset, uint data);
94 void pcr_write8(struct udevice *dev, uint offset, uint data);
97 * pcr_clrsetbits32/16/8() - Update a PCR device
99 * Updates dat in a PCR device within the P2SB
101 * This reads from the device, clears and set bits, then writes back.
103 * new_data = (old_data & ~clr) | set
105 * @dev: Device to update
106 * @offset: Offset within device to update
107 * @clr: Bits to clear after reading
108 * @set: Bits to set before writing
110 void pcr_clrsetbits32(struct udevice *dev, uint offset, uint clr, uint set);
111 void pcr_clrsetbits16(struct udevice *dev, uint offset, uint clr, uint set);
112 void pcr_clrsetbits8(struct udevice *dev, uint offset, uint clr, uint set);
114 static inline void pcr_setbits32(struct udevice *dev, uint offset, uint set)
116 return pcr_clrsetbits32(dev, offset, 0, set);
119 static inline void pcr_setbits16(struct udevice *dev, uint offset, uint set)
121 return pcr_clrsetbits16(dev, offset, 0, set);
124 static inline void pcr_setbits8(struct udevice *dev, uint offset, uint set)
126 return pcr_clrsetbits8(dev, offset, 0, set);
129 static inline void pcr_clrbits32(struct udevice *dev, uint offset, uint clr)
131 return pcr_clrsetbits32(dev, offset, clr, 0);
134 static inline void pcr_clrbits16(struct udevice *dev, uint offset, uint clr)
136 return pcr_clrsetbits16(dev, offset, clr, 0);
139 static inline void pcr_clrbits8(struct udevice *dev, uint offset, uint clr)
141 return pcr_clrsetbits8(dev, offset, clr, 0);
145 * p2sb_set_port_id() - Set the port ID for a p2sb child device
147 * This must be called in a device's bind() method when OF_PLATDATA is used
148 * since the uclass cannot access the device's of-platdata.
150 * @dev: Child device (whose parent is UCLASS_P2SB)
151 * @portid: Port ID of child device
152 * @return 0 if OK, -ENODEV is the p2sb device could not be found
154 int p2sb_set_port_id(struct udevice *dev, int portid);
157 * p2sb_get_port_id() - Get the port ID for a p2sb child device
159 * @dev: Child device (whose parent is UCLASS_P2SB)
160 * @return Port ID of that child
162 int p2sb_get_port_id(struct udevice *dev);
165 * pcr_reg_address() Convert an offset in p2sb space to an absolute address
167 * @dev: Child device (whose parent is UCLASS_P2SB)
168 * @offset: Offset within that child's address space
169 * @return pointer to that offset within the child's address space
171 void *pcr_reg_address(struct udevice *dev, uint offset);
173 #endif /* !__ACPI__ */