Angel Pons | c74dae9 | 2020-04-02 23:48:16 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Yinghai Lu | 13f1c2a | 2005-07-08 02:49:49 +0000 | [diff] [blame] | 2 | |
| 3 | #include <console/console.h> |
Kyösti Mälkki | 94ce79d | 2019-12-16 17:21:13 +0200 | [diff] [blame] | 4 | #include <commonlib/helpers.h> |
Duncan Laurie | 90dcdd4 | 2011-10-25 14:15:11 -0700 | [diff] [blame] | 5 | #include <delay.h> |
Yinghai Lu | 13f1c2a | 2005-07-08 02:49:49 +0000 | [diff] [blame] | 6 | #include <device/device.h> |
| 7 | #include <device/pci.h> |
Patrick Rudolph | e56189c | 2018-04-18 10:11:59 +0200 | [diff] [blame] | 8 | #include <device/pci_ops.h> |
Yinghai Lu | 13f1c2a | 2005-07-08 02:49:49 +0000 | [diff] [blame] | 9 | #include <device/pciexp.h> |
| 10 | |
Tim Wawrzynczak | 3d121ae1 | 2021-09-16 20:18:16 -0600 | [diff] [blame] | 11 | static unsigned int pciexp_get_ext_cap_offset(const struct device *dev, unsigned int cap, |
| 12 | unsigned int offset) |
Kenji Chen | 31c6e63 | 2014-10-04 01:14:44 +0800 | [diff] [blame] | 13 | { |
Tim Wawrzynczak | 3d121ae1 | 2021-09-16 20:18:16 -0600 | [diff] [blame] | 14 | unsigned int this_cap_offset = offset; |
| 15 | unsigned int next_cap_offset, this_cap, cafe; |
Kenji Chen | 31c6e63 | 2014-10-04 01:14:44 +0800 | [diff] [blame] | 16 | do { |
Kyösti Mälkki | 91bfa8e | 2016-11-20 20:39:56 +0200 | [diff] [blame] | 17 | this_cap = pci_read_config32(dev, this_cap_offset); |
Bill XIE | 385e432 | 2022-08-04 21:52:05 +0800 | [diff] [blame^] | 18 | /* Bail out when this request is unsupported */ |
| 19 | if (this_cap == 0xffffffff) |
| 20 | break; |
Kyösti Mälkki | 91bfa8e | 2016-11-20 20:39:56 +0200 | [diff] [blame] | 21 | cafe = pci_read_config32(dev, this_cap_offset + 4); |
Tim Wawrzynczak | 3d121ae1 | 2021-09-16 20:18:16 -0600 | [diff] [blame] | 22 | if ((this_cap & 0xffff) == cap) { |
Kenji Chen | 31c6e63 | 2014-10-04 01:14:44 +0800 | [diff] [blame] | 23 | return this_cap_offset; |
Tim Wawrzynczak | 3d121ae1 | 2021-09-16 20:18:16 -0600 | [diff] [blame] | 24 | } else if ((cafe & 0xffff) == cap) { |
Kenji Chen | 31c6e63 | 2014-10-04 01:14:44 +0800 | [diff] [blame] | 25 | return this_cap_offset + 4; |
Tim Wawrzynczak | 3d121ae1 | 2021-09-16 20:18:16 -0600 | [diff] [blame] | 26 | } else { |
| 27 | next_cap_offset = this_cap >> 20; |
Kenji Chen | 31c6e63 | 2014-10-04 01:14:44 +0800 | [diff] [blame] | 28 | this_cap_offset = next_cap_offset; |
Tim Wawrzynczak | 3d121ae1 | 2021-09-16 20:18:16 -0600 | [diff] [blame] | 29 | } |
Kenji Chen | 31c6e63 | 2014-10-04 01:14:44 +0800 | [diff] [blame] | 30 | } while (next_cap_offset != 0); |
| 31 | |
| 32 | return 0; |
| 33 | } |
Kenji Chen | 31c6e63 | 2014-10-04 01:14:44 +0800 | [diff] [blame] | 34 | |
Tim Wawrzynczak | 3d121ae1 | 2021-09-16 20:18:16 -0600 | [diff] [blame] | 35 | unsigned int pciexp_find_next_extended_cap(const struct device *dev, unsigned int cap, |
| 36 | unsigned int pos) |
| 37 | { |
| 38 | const unsigned int next_cap_offset = pci_read_config32(dev, pos) >> 20; |
| 39 | return pciexp_get_ext_cap_offset(dev, cap, next_cap_offset); |
| 40 | } |
| 41 | |
| 42 | unsigned int pciexp_find_extended_cap(const struct device *dev, unsigned int cap) |
| 43 | { |
| 44 | return pciexp_get_ext_cap_offset(dev, cap, PCIE_EXT_CAP_OFFSET); |
| 45 | } |
| 46 | |
Duncan Laurie | 90dcdd4 | 2011-10-25 14:15:11 -0700 | [diff] [blame] | 47 | /* |
| 48 | * Re-train a PCIe link |
| 49 | */ |
| 50 | #define PCIE_TRAIN_RETRY 10000 |
Martin Roth | 38ddbfb | 2019-10-23 21:41:00 -0600 | [diff] [blame] | 51 | static int pciexp_retrain_link(struct device *dev, unsigned int cap) |
Duncan Laurie | 90dcdd4 | 2011-10-25 14:15:11 -0700 | [diff] [blame] | 52 | { |
Youness Alaoui | bb5fb64 | 2017-05-03 17:57:13 -0400 | [diff] [blame] | 53 | unsigned int try; |
Duncan Laurie | 90dcdd4 | 2011-10-25 14:15:11 -0700 | [diff] [blame] | 54 | u16 lnk; |
| 55 | |
Youness Alaoui | bb5fb64 | 2017-05-03 17:57:13 -0400 | [diff] [blame] | 56 | /* |
| 57 | * Implementation note (page 633) in PCIe Specification 3.0 suggests |
| 58 | * polling the Link Training bit in the Link Status register until the |
| 59 | * value returned is 0 before setting the Retrain Link bit to 1. |
| 60 | * This is meant to avoid a race condition when using the |
| 61 | * Retrain Link mechanism. |
| 62 | */ |
| 63 | for (try = PCIE_TRAIN_RETRY; try > 0; try--) { |
| 64 | lnk = pci_read_config16(dev, cap + PCI_EXP_LNKSTA); |
| 65 | if (!(lnk & PCI_EXP_LNKSTA_LT)) |
| 66 | break; |
| 67 | udelay(100); |
| 68 | } |
| 69 | if (try == 0) { |
| 70 | printk(BIOS_ERR, "%s: Link Retrain timeout\n", dev_path(dev)); |
| 71 | return -1; |
| 72 | } |
| 73 | |
Duncan Laurie | 90dcdd4 | 2011-10-25 14:15:11 -0700 | [diff] [blame] | 74 | /* Start link retraining */ |
| 75 | lnk = pci_read_config16(dev, cap + PCI_EXP_LNKCTL); |
| 76 | lnk |= PCI_EXP_LNKCTL_RL; |
| 77 | pci_write_config16(dev, cap + PCI_EXP_LNKCTL, lnk); |
| 78 | |
| 79 | /* Wait for training to complete */ |
Youness Alaoui | bb5fb64 | 2017-05-03 17:57:13 -0400 | [diff] [blame] | 80 | for (try = PCIE_TRAIN_RETRY; try > 0; try--) { |
Duncan Laurie | 90dcdd4 | 2011-10-25 14:15:11 -0700 | [diff] [blame] | 81 | lnk = pci_read_config16(dev, cap + PCI_EXP_LNKSTA); |
| 82 | if (!(lnk & PCI_EXP_LNKSTA_LT)) |
| 83 | return 0; |
| 84 | udelay(100); |
| 85 | } |
| 86 | |
| 87 | printk(BIOS_ERR, "%s: Link Retrain timeout\n", dev_path(dev)); |
| 88 | return -1; |
| 89 | } |
| 90 | |
| 91 | /* |
| 92 | * Check the Slot Clock Configuration for root port and endpoint |
| 93 | * and enable Common Clock Configuration if possible. If CCC is |
| 94 | * enabled the link must be retrained. |
| 95 | */ |
Martin Roth | 38ddbfb | 2019-10-23 21:41:00 -0600 | [diff] [blame] | 96 | static void pciexp_enable_common_clock(struct device *root, unsigned int root_cap, |
| 97 | struct device *endp, unsigned int endp_cap) |
Duncan Laurie | 90dcdd4 | 2011-10-25 14:15:11 -0700 | [diff] [blame] | 98 | { |
| 99 | u16 root_scc, endp_scc, lnkctl; |
| 100 | |
| 101 | /* Get Slot Clock Configuration for root port */ |
| 102 | root_scc = pci_read_config16(root, root_cap + PCI_EXP_LNKSTA); |
| 103 | root_scc &= PCI_EXP_LNKSTA_SLC; |
| 104 | |
| 105 | /* Get Slot Clock Configuration for endpoint */ |
| 106 | endp_scc = pci_read_config16(endp, endp_cap + PCI_EXP_LNKSTA); |
| 107 | endp_scc &= PCI_EXP_LNKSTA_SLC; |
| 108 | |
| 109 | /* Enable Common Clock Configuration and retrain */ |
| 110 | if (root_scc && endp_scc) { |
| 111 | printk(BIOS_INFO, "Enabling Common Clock Configuration\n"); |
| 112 | |
| 113 | /* Set in endpoint */ |
| 114 | lnkctl = pci_read_config16(endp, endp_cap + PCI_EXP_LNKCTL); |
| 115 | lnkctl |= PCI_EXP_LNKCTL_CCC; |
| 116 | pci_write_config16(endp, endp_cap + PCI_EXP_LNKCTL, lnkctl); |
| 117 | |
| 118 | /* Set in root port */ |
| 119 | lnkctl = pci_read_config16(root, root_cap + PCI_EXP_LNKCTL); |
| 120 | lnkctl |= PCI_EXP_LNKCTL_CCC; |
| 121 | pci_write_config16(root, root_cap + PCI_EXP_LNKCTL, lnkctl); |
| 122 | |
| 123 | /* Retrain link if CCC was enabled */ |
| 124 | pciexp_retrain_link(root, root_cap); |
| 125 | } |
| 126 | } |
Duncan Laurie | 90dcdd4 | 2011-10-25 14:15:11 -0700 | [diff] [blame] | 127 | |
Martin Roth | 38ddbfb | 2019-10-23 21:41:00 -0600 | [diff] [blame] | 128 | static void pciexp_enable_clock_power_pm(struct device *endp, unsigned int endp_cap) |
Kane Chen | 18cb134 | 2014-10-01 11:13:54 +0800 | [diff] [blame] | 129 | { |
| 130 | /* check if per port clk req is supported in device */ |
| 131 | u32 endp_ca; |
| 132 | u16 lnkctl; |
| 133 | endp_ca = pci_read_config32(endp, endp_cap + PCI_EXP_LNKCAP); |
| 134 | if ((endp_ca & PCI_EXP_CLK_PM) == 0) { |
Arthur Heymans | 330c46b | 2017-07-12 19:17:56 +0200 | [diff] [blame] | 135 | printk(BIOS_INFO, "PCIE CLK PM is not supported by endpoint\n"); |
Kane Chen | 18cb134 | 2014-10-01 11:13:54 +0800 | [diff] [blame] | 136 | return; |
| 137 | } |
| 138 | lnkctl = pci_read_config16(endp, endp_cap + PCI_EXP_LNKCTL); |
| 139 | lnkctl = lnkctl | PCI_EXP_EN_CLK_PM; |
| 140 | pci_write_config16(endp, endp_cap + PCI_EXP_LNKCTL, lnkctl); |
| 141 | } |
Kane Chen | 18cb134 | 2014-10-01 11:13:54 +0800 | [diff] [blame] | 142 | |
Nico Huber | 968ef75 | 2021-03-07 01:39:18 +0100 | [diff] [blame] | 143 | static bool _pciexp_ltr_supported(struct device *dev, unsigned int cap) |
Kenji Chen | 31c6e63 | 2014-10-04 01:14:44 +0800 | [diff] [blame] | 144 | { |
Nico Huber | 968ef75 | 2021-03-07 01:39:18 +0100 | [diff] [blame] | 145 | return pci_read_config16(dev, cap + PCI_EXP_DEVCAP2) & PCI_EXP_DEVCAP2_LTR; |
Kenji Chen | 31c6e63 | 2014-10-04 01:14:44 +0800 | [diff] [blame] | 146 | } |
| 147 | |
Nico Huber | 968ef75 | 2021-03-07 01:39:18 +0100 | [diff] [blame] | 148 | static bool _pciexp_ltr_enabled(struct device *dev, unsigned int cap) |
Aamir Bohra | 2188f57 | 2017-09-22 19:07:21 +0530 | [diff] [blame] | 149 | { |
Nico Huber | 968ef75 | 2021-03-07 01:39:18 +0100 | [diff] [blame] | 150 | return pci_read_config16(dev, cap + PCI_EXP_DEVCTL2) & PCI_EXP_DEV2_LTR; |
Aamir Bohra | 2188f57 | 2017-09-22 19:07:21 +0530 | [diff] [blame] | 151 | } |
| 152 | |
Nico Huber | 968ef75 | 2021-03-07 01:39:18 +0100 | [diff] [blame] | 153 | static bool _pciexp_enable_ltr(struct device *parent, unsigned int parent_cap, |
| 154 | struct device *dev, unsigned int cap) |
Kenji Chen | 31c6e63 | 2014-10-04 01:14:44 +0800 | [diff] [blame] | 155 | { |
Nico Huber | 968ef75 | 2021-03-07 01:39:18 +0100 | [diff] [blame] | 156 | if (!_pciexp_ltr_supported(dev, cap)) { |
| 157 | printk(BIOS_DEBUG, "%s: No LTR support\n", dev_path(dev)); |
| 158 | return false; |
Pratik Prajapati | 0cd0d28 | 2015-06-09 12:06:20 -0700 | [diff] [blame] | 159 | } |
Aamir Bohra | 2188f57 | 2017-09-22 19:07:21 +0530 | [diff] [blame] | 160 | |
Nico Huber | 968ef75 | 2021-03-07 01:39:18 +0100 | [diff] [blame] | 161 | if (_pciexp_ltr_enabled(dev, cap)) |
| 162 | return true; |
Aamir Bohra | 2188f57 | 2017-09-22 19:07:21 +0530 | [diff] [blame] | 163 | |
Nico Huber | 968ef75 | 2021-03-07 01:39:18 +0100 | [diff] [blame] | 164 | if (parent && |
| 165 | (parent->path.type != DEVICE_PATH_PCI || |
| 166 | !_pciexp_ltr_supported(parent, parent_cap) || |
| 167 | !_pciexp_ltr_enabled(parent, parent_cap))) |
| 168 | return false; |
Aamir Bohra | 2188f57 | 2017-09-22 19:07:21 +0530 | [diff] [blame] | 169 | |
Nico Huber | 968ef75 | 2021-03-07 01:39:18 +0100 | [diff] [blame] | 170 | pci_or_config16(dev, cap + PCI_EXP_DEVCTL2, PCI_EXP_DEV2_LTR); |
| 171 | printk(BIOS_INFO, "%s: Enabled LTR\n", dev_path(dev)); |
| 172 | return true; |
Aamir Bohra | 2188f57 | 2017-09-22 19:07:21 +0530 | [diff] [blame] | 173 | } |
| 174 | |
Elyes HAOUAS | b1fa287 | 2018-05-02 21:11:38 +0200 | [diff] [blame] | 175 | static void pciexp_enable_ltr(struct device *dev) |
Aamir Bohra | 2188f57 | 2017-09-22 19:07:21 +0530 | [diff] [blame] | 176 | { |
Nico Huber | 968ef75 | 2021-03-07 01:39:18 +0100 | [diff] [blame] | 177 | const unsigned int cap = pci_find_capability(dev, PCI_CAP_ID_PCIE); |
| 178 | if (!cap) |
| 179 | return; |
Aamir Bohra | 2188f57 | 2017-09-22 19:07:21 +0530 | [diff] [blame] | 180 | |
Nico Huber | 968ef75 | 2021-03-07 01:39:18 +0100 | [diff] [blame] | 181 | /* |
| 182 | * If we have get_ltr_max_latencies(), treat `dev` as the root. |
| 183 | * If not, let _pciexp_enable_ltr() query the parent's state. |
| 184 | */ |
| 185 | struct device *parent = NULL; |
| 186 | unsigned int parent_cap = 0; |
| 187 | if (!dev->ops->ops_pci || !dev->ops->ops_pci->get_ltr_max_latencies) { |
| 188 | parent = dev->bus->dev; |
Bill XIE | a43380e | 2022-08-03 00:18:14 +0800 | [diff] [blame] | 189 | parent_cap = pci_find_capability(parent, PCI_CAP_ID_PCIE); |
Nico Huber | 968ef75 | 2021-03-07 01:39:18 +0100 | [diff] [blame] | 190 | if (!parent_cap) |
| 191 | return; |
Aamir Bohra | 2188f57 | 2017-09-22 19:07:21 +0530 | [diff] [blame] | 192 | } |
Nico Huber | 968ef75 | 2021-03-07 01:39:18 +0100 | [diff] [blame] | 193 | |
| 194 | (void)_pciexp_enable_ltr(parent, parent_cap, dev, cap); |
| 195 | } |
| 196 | |
Tim Wawrzynczak | a62cb56 | 2021-12-08 21:16:43 -0700 | [diff] [blame] | 197 | bool pciexp_get_ltr_max_latencies(struct device *dev, u16 *max_snoop, u16 *max_nosnoop) |
Nico Huber | 968ef75 | 2021-03-07 01:39:18 +0100 | [diff] [blame] | 198 | { |
| 199 | /* Walk the hierarchy up to find get_ltr_max_latencies(). */ |
| 200 | do { |
| 201 | if (dev->ops->ops_pci && dev->ops->ops_pci->get_ltr_max_latencies) |
| 202 | break; |
| 203 | if (dev->bus->dev == dev || dev->bus->dev->path.type != DEVICE_PATH_PCI) |
| 204 | return false; |
| 205 | dev = dev->bus->dev; |
| 206 | } while (true); |
| 207 | |
| 208 | dev->ops->ops_pci->get_ltr_max_latencies(max_snoop, max_nosnoop); |
| 209 | return true; |
| 210 | } |
| 211 | |
| 212 | static void pciexp_configure_ltr(struct device *parent, unsigned int parent_cap, |
| 213 | struct device *dev, unsigned int cap) |
| 214 | { |
| 215 | if (!_pciexp_enable_ltr(parent, parent_cap, dev, cap)) |
| 216 | return; |
| 217 | |
| 218 | const unsigned int ltr_cap = pciexp_find_extended_cap(dev, PCIE_EXT_CAP_LTR_ID); |
| 219 | if (!ltr_cap) |
| 220 | return; |
| 221 | |
| 222 | u16 max_snoop, max_nosnoop; |
| 223 | if (!pciexp_get_ltr_max_latencies(dev, &max_snoop, &max_nosnoop)) |
| 224 | return; |
| 225 | |
| 226 | pci_write_config16(dev, ltr_cap + PCI_LTR_MAX_SNOOP, max_snoop); |
| 227 | pci_write_config16(dev, ltr_cap + PCI_LTR_MAX_NOSNOOP, max_nosnoop); |
| 228 | printk(BIOS_INFO, "%s: Programmed LTR max latencies\n", dev_path(dev)); |
Kenji Chen | 31c6e63 | 2014-10-04 01:14:44 +0800 | [diff] [blame] | 229 | } |
| 230 | |
Elyes HAOUAS | b1fa287 | 2018-05-02 21:11:38 +0200 | [diff] [blame] | 231 | static unsigned char pciexp_L1_substate_cal(struct device *dev, unsigned int endp_cap, |
Kenji Chen | 31c6e63 | 2014-10-04 01:14:44 +0800 | [diff] [blame] | 232 | unsigned int *data) |
| 233 | { |
| 234 | unsigned char mult[4] = {2, 10, 100, 0}; |
| 235 | |
| 236 | unsigned int L1SubStateSupport = *data & 0xf; |
| 237 | unsigned int comm_mode_rst_time = (*data >> 8) & 0xff; |
| 238 | unsigned int power_on_scale = (*data >> 16) & 0x3; |
| 239 | unsigned int power_on_value = (*data >> 19) & 0x1f; |
| 240 | |
Kyösti Mälkki | 91bfa8e | 2016-11-20 20:39:56 +0200 | [diff] [blame] | 241 | unsigned int endp_data = pci_read_config32(dev, endp_cap + 4); |
Kenji Chen | 31c6e63 | 2014-10-04 01:14:44 +0800 | [diff] [blame] | 242 | unsigned int endp_L1SubStateSupport = endp_data & 0xf; |
| 243 | unsigned int endp_comm_mode_restore_time = (endp_data >> 8) & 0xff; |
| 244 | unsigned int endp_power_on_scale = (endp_data >> 16) & 0x3; |
| 245 | unsigned int endp_power_on_value = (endp_data >> 19) & 0x1f; |
| 246 | |
| 247 | L1SubStateSupport &= endp_L1SubStateSupport; |
| 248 | |
| 249 | if (L1SubStateSupport == 0) |
| 250 | return 0; |
| 251 | |
| 252 | if (power_on_value * mult[power_on_scale] < |
| 253 | endp_power_on_value * mult[endp_power_on_scale]) { |
| 254 | power_on_value = endp_power_on_value; |
| 255 | power_on_scale = endp_power_on_scale; |
| 256 | } |
| 257 | if (comm_mode_rst_time < endp_comm_mode_restore_time) |
| 258 | comm_mode_rst_time = endp_comm_mode_restore_time; |
| 259 | |
| 260 | *data = (comm_mode_rst_time << 8) | (power_on_scale << 16) |
| 261 | | (power_on_value << 19) | L1SubStateSupport; |
| 262 | |
| 263 | return 1; |
| 264 | } |
| 265 | |
Elyes HAOUAS | b1fa287 | 2018-05-02 21:11:38 +0200 | [diff] [blame] | 266 | static void pciexp_L1_substate_commit(struct device *root, struct device *dev, |
Kenji Chen | 31c6e63 | 2014-10-04 01:14:44 +0800 | [diff] [blame] | 267 | unsigned int root_cap, unsigned int end_cap) |
| 268 | { |
Elyes HAOUAS | b1fa287 | 2018-05-02 21:11:38 +0200 | [diff] [blame] | 269 | struct device *dev_t; |
Kenji Chen | 31c6e63 | 2014-10-04 01:14:44 +0800 | [diff] [blame] | 270 | unsigned char L1_ss_ok; |
Kyösti Mälkki | 91bfa8e | 2016-11-20 20:39:56 +0200 | [diff] [blame] | 271 | unsigned int rp_L1_support = pci_read_config32(root, root_cap + 4); |
Kenji Chen | 31c6e63 | 2014-10-04 01:14:44 +0800 | [diff] [blame] | 272 | unsigned int L1SubStateSupport; |
| 273 | unsigned int comm_mode_rst_time; |
| 274 | unsigned int power_on_scale; |
| 275 | unsigned int endp_power_on_value; |
| 276 | |
| 277 | for (dev_t = dev; dev_t; dev_t = dev_t->sibling) { |
| 278 | /* |
| 279 | * rp_L1_support is init'd above from root port. |
| 280 | * it needs coordination with endpoints to reach in common. |
| 281 | * if certain endpoint doesn't support L1 Sub-State, abort |
| 282 | * this feature enabling. |
| 283 | */ |
| 284 | L1_ss_ok = pciexp_L1_substate_cal(dev_t, end_cap, |
| 285 | &rp_L1_support); |
| 286 | if (!L1_ss_ok) |
| 287 | return; |
| 288 | } |
| 289 | |
| 290 | L1SubStateSupport = rp_L1_support & 0xf; |
| 291 | comm_mode_rst_time = (rp_L1_support >> 8) & 0xff; |
| 292 | power_on_scale = (rp_L1_support >> 16) & 0x3; |
| 293 | endp_power_on_value = (rp_L1_support >> 19) & 0x1f; |
| 294 | |
| 295 | printk(BIOS_INFO, "L1 Sub-State supported from root port %d\n", |
| 296 | root->path.pci.devfn >> 3); |
| 297 | printk(BIOS_INFO, "L1 Sub-State Support = 0x%x\n", L1SubStateSupport); |
| 298 | printk(BIOS_INFO, "CommonModeRestoreTime = 0x%x\n", comm_mode_rst_time); |
| 299 | printk(BIOS_INFO, "Power On Value = 0x%x, Power On Scale = 0x%x\n", |
| 300 | endp_power_on_value, power_on_scale); |
| 301 | |
Kyösti Mälkki | 48c389e | 2013-07-26 08:53:59 +0300 | [diff] [blame] | 302 | pci_update_config32(root, root_cap + 0x08, ~0xff00, |
Kenji Chen | 31c6e63 | 2014-10-04 01:14:44 +0800 | [diff] [blame] | 303 | (comm_mode_rst_time << 8)); |
| 304 | |
Elyes HAOUAS | a342f39 | 2018-10-17 10:56:26 +0200 | [diff] [blame] | 305 | pci_update_config32(root, root_cap + 0x0c, 0xffffff04, |
Kenji Chen | 31c6e63 | 2014-10-04 01:14:44 +0800 | [diff] [blame] | 306 | (endp_power_on_value << 3) | (power_on_scale)); |
| 307 | |
Patrick Georgi | 9adcbfe | 2017-12-05 16:36:30 -0500 | [diff] [blame] | 308 | /* TODO: 0xa0, 2 are values that work on some chipsets but really |
| 309 | * should be determined dynamically by looking at downstream devices. |
| 310 | */ |
| 311 | pci_update_config32(root, root_cap + 0x08, |
| 312 | ~(ASPM_LTR_L12_THRESHOLD_VALUE_MASK | |
| 313 | ASPM_LTR_L12_THRESHOLD_SCALE_MASK), |
| 314 | (0xa0 << ASPM_LTR_L12_THRESHOLD_VALUE_OFFSET) | |
| 315 | (2 << ASPM_LTR_L12_THRESHOLD_SCALE_OFFSET)); |
Kenji Chen | 31c6e63 | 2014-10-04 01:14:44 +0800 | [diff] [blame] | 316 | |
Kyösti Mälkki | 48c389e | 2013-07-26 08:53:59 +0300 | [diff] [blame] | 317 | pci_update_config32(root, root_cap + 0x08, ~0x1f, |
Kenji Chen | 31c6e63 | 2014-10-04 01:14:44 +0800 | [diff] [blame] | 318 | L1SubStateSupport); |
| 319 | |
| 320 | for (dev_t = dev; dev_t; dev_t = dev_t->sibling) { |
Elyes HAOUAS | a342f39 | 2018-10-17 10:56:26 +0200 | [diff] [blame] | 321 | pci_update_config32(dev_t, end_cap + 0x0c, 0xffffff04, |
Kenji Chen | 31c6e63 | 2014-10-04 01:14:44 +0800 | [diff] [blame] | 322 | (endp_power_on_value << 3) | (power_on_scale)); |
| 323 | |
Patrick Georgi | 9adcbfe | 2017-12-05 16:36:30 -0500 | [diff] [blame] | 324 | pci_update_config32(dev_t, end_cap + 0x08, |
| 325 | ~(ASPM_LTR_L12_THRESHOLD_VALUE_MASK | |
| 326 | ASPM_LTR_L12_THRESHOLD_SCALE_MASK), |
| 327 | (0xa0 << ASPM_LTR_L12_THRESHOLD_VALUE_OFFSET) | |
| 328 | (2 << ASPM_LTR_L12_THRESHOLD_SCALE_OFFSET)); |
Kenji Chen | 31c6e63 | 2014-10-04 01:14:44 +0800 | [diff] [blame] | 329 | |
Kyösti Mälkki | 48c389e | 2013-07-26 08:53:59 +0300 | [diff] [blame] | 330 | pci_update_config32(dev_t, end_cap + 0x08, ~0x1f, |
Kenji Chen | 31c6e63 | 2014-10-04 01:14:44 +0800 | [diff] [blame] | 331 | L1SubStateSupport); |
Kenji Chen | 31c6e63 | 2014-10-04 01:14:44 +0800 | [diff] [blame] | 332 | } |
| 333 | } |
| 334 | |
Elyes HAOUAS | b1fa287 | 2018-05-02 21:11:38 +0200 | [diff] [blame] | 335 | static void pciexp_config_L1_sub_state(struct device *root, struct device *dev) |
Kenji Chen | 31c6e63 | 2014-10-04 01:14:44 +0800 | [diff] [blame] | 336 | { |
| 337 | unsigned int root_cap, end_cap; |
| 338 | |
| 339 | /* Do it for function 0 only */ |
| 340 | if (dev->path.pci.devfn & 0x7) |
| 341 | return; |
| 342 | |
| 343 | root_cap = pciexp_find_extended_cap(root, PCIE_EXT_CAP_L1SS_ID); |
| 344 | if (!root_cap) |
| 345 | return; |
| 346 | |
| 347 | end_cap = pciexp_find_extended_cap(dev, PCIE_EXT_CAP_L1SS_ID); |
| 348 | if (!end_cap) { |
| 349 | end_cap = pciexp_find_extended_cap(dev, 0xcafe); |
| 350 | if (!end_cap) |
| 351 | return; |
| 352 | } |
| 353 | |
| 354 | pciexp_L1_substate_commit(root, dev, root_cap, end_cap); |
| 355 | } |
Kenji Chen | 31c6e63 | 2014-10-04 01:14:44 +0800 | [diff] [blame] | 356 | |
Duncan Laurie | 90dcdd4 | 2011-10-25 14:15:11 -0700 | [diff] [blame] | 357 | /* |
| 358 | * Determine the ASPM L0s or L1 exit latency for a link |
| 359 | * by checking both root port and endpoint and returning |
| 360 | * the highest latency value. |
| 361 | */ |
Martin Roth | 38ddbfb | 2019-10-23 21:41:00 -0600 | [diff] [blame] | 362 | static int pciexp_aspm_latency(struct device *root, unsigned int root_cap, |
| 363 | struct device *endp, unsigned int endp_cap, |
Duncan Laurie | 90dcdd4 | 2011-10-25 14:15:11 -0700 | [diff] [blame] | 364 | enum aspm_type type) |
| 365 | { |
| 366 | int root_lat = 0, endp_lat = 0; |
| 367 | u32 root_lnkcap, endp_lnkcap; |
| 368 | |
| 369 | root_lnkcap = pci_read_config32(root, root_cap + PCI_EXP_LNKCAP); |
| 370 | endp_lnkcap = pci_read_config32(endp, endp_cap + PCI_EXP_LNKCAP); |
| 371 | |
| 372 | /* Make sure the link supports this ASPM type by checking |
| 373 | * capability bits 11:10 with aspm_type offset by 1 */ |
| 374 | if (!(root_lnkcap & (1 << (type + 9))) || |
| 375 | !(endp_lnkcap & (1 << (type + 9)))) |
| 376 | return -1; |
| 377 | |
| 378 | /* Find the one with higher latency */ |
| 379 | switch (type) { |
| 380 | case PCIE_ASPM_L0S: |
| 381 | root_lat = (root_lnkcap & PCI_EXP_LNKCAP_L0SEL) >> 12; |
| 382 | endp_lat = (endp_lnkcap & PCI_EXP_LNKCAP_L0SEL) >> 12; |
| 383 | break; |
| 384 | case PCIE_ASPM_L1: |
| 385 | root_lat = (root_lnkcap & PCI_EXP_LNKCAP_L1EL) >> 15; |
| 386 | endp_lat = (endp_lnkcap & PCI_EXP_LNKCAP_L1EL) >> 15; |
| 387 | break; |
| 388 | default: |
| 389 | return -1; |
| 390 | } |
| 391 | |
| 392 | return (endp_lat > root_lat) ? endp_lat : root_lat; |
| 393 | } |
| 394 | |
| 395 | /* |
| 396 | * Enable ASPM on PCIe root port and endpoint. |
Duncan Laurie | 90dcdd4 | 2011-10-25 14:15:11 -0700 | [diff] [blame] | 397 | */ |
Martin Roth | 38ddbfb | 2019-10-23 21:41:00 -0600 | [diff] [blame] | 398 | static void pciexp_enable_aspm(struct device *root, unsigned int root_cap, |
| 399 | struct device *endp, unsigned int endp_cap) |
Duncan Laurie | 90dcdd4 | 2011-10-25 14:15:11 -0700 | [diff] [blame] | 400 | { |
| 401 | const char *aspm_type_str[] = { "None", "L0s", "L1", "L0s and L1" }; |
| 402 | enum aspm_type apmc = PCIE_ASPM_NONE; |
| 403 | int exit_latency, ok_latency; |
| 404 | u16 lnkctl; |
| 405 | u32 devcap; |
| 406 | |
Nico Huber | 570b183 | 2017-08-30 13:38:50 +0200 | [diff] [blame] | 407 | if (endp->disable_pcie_aspm) |
| 408 | return; |
| 409 | |
Duncan Laurie | 90dcdd4 | 2011-10-25 14:15:11 -0700 | [diff] [blame] | 410 | /* Get endpoint device capabilities for acceptable limits */ |
| 411 | devcap = pci_read_config32(endp, endp_cap + PCI_EXP_DEVCAP); |
| 412 | |
| 413 | /* Enable L0s if it is within endpoint acceptable limit */ |
| 414 | ok_latency = (devcap & PCI_EXP_DEVCAP_L0S) >> 6; |
| 415 | exit_latency = pciexp_aspm_latency(root, root_cap, endp, endp_cap, |
| 416 | PCIE_ASPM_L0S); |
| 417 | if (exit_latency >= 0 && exit_latency <= ok_latency) |
| 418 | apmc |= PCIE_ASPM_L0S; |
| 419 | |
| 420 | /* Enable L1 if it is within endpoint acceptable limit */ |
| 421 | ok_latency = (devcap & PCI_EXP_DEVCAP_L1) >> 9; |
| 422 | exit_latency = pciexp_aspm_latency(root, root_cap, endp, endp_cap, |
| 423 | PCIE_ASPM_L1); |
| 424 | if (exit_latency >= 0 && exit_latency <= ok_latency) |
| 425 | apmc |= PCIE_ASPM_L1; |
| 426 | |
| 427 | if (apmc != PCIE_ASPM_NONE) { |
| 428 | /* Set APMC in root port first */ |
| 429 | lnkctl = pci_read_config16(root, root_cap + PCI_EXP_LNKCTL); |
| 430 | lnkctl |= apmc; |
| 431 | pci_write_config16(root, root_cap + PCI_EXP_LNKCTL, lnkctl); |
| 432 | |
| 433 | /* Set APMC in endpoint device next */ |
| 434 | lnkctl = pci_read_config16(endp, endp_cap + PCI_EXP_LNKCTL); |
| 435 | lnkctl |= apmc; |
| 436 | pci_write_config16(endp, endp_cap + PCI_EXP_LNKCTL, lnkctl); |
| 437 | } |
| 438 | |
| 439 | printk(BIOS_INFO, "ASPM: Enabled %s\n", aspm_type_str[apmc]); |
Duncan Laurie | 90dcdd4 | 2011-10-25 14:15:11 -0700 | [diff] [blame] | 440 | } |
Duncan Laurie | 90dcdd4 | 2011-10-25 14:15:11 -0700 | [diff] [blame] | 441 | |
Kyösti Mälkki | 94ce79d | 2019-12-16 17:21:13 +0200 | [diff] [blame] | 442 | /* |
| 443 | * Set max payload size of endpoint in accordance with max payload size of root port. |
| 444 | */ |
| 445 | static void pciexp_set_max_payload_size(struct device *root, unsigned int root_cap, |
| 446 | struct device *endp, unsigned int endp_cap) |
| 447 | { |
| 448 | unsigned int endp_max_payload, root_max_payload, max_payload; |
| 449 | u16 endp_devctl, root_devctl; |
| 450 | u32 endp_devcap, root_devcap; |
| 451 | |
| 452 | /* Get max payload size supported by endpoint */ |
| 453 | endp_devcap = pci_read_config32(endp, endp_cap + PCI_EXP_DEVCAP); |
| 454 | endp_max_payload = endp_devcap & PCI_EXP_DEVCAP_PAYLOAD; |
| 455 | |
| 456 | /* Get max payload size supported by root port */ |
| 457 | root_devcap = pci_read_config32(root, root_cap + PCI_EXP_DEVCAP); |
| 458 | root_max_payload = root_devcap & PCI_EXP_DEVCAP_PAYLOAD; |
| 459 | |
| 460 | /* Set max payload to smaller of the reported device capability. */ |
| 461 | max_payload = MIN(endp_max_payload, root_max_payload); |
| 462 | if (max_payload > 5) { |
| 463 | /* Values 6 and 7 are reserved in PCIe 3.0 specs. */ |
| 464 | printk(BIOS_ERR, "PCIe: Max_Payload_Size field restricted from %d to 5\n", |
| 465 | max_payload); |
| 466 | max_payload = 5; |
| 467 | } |
| 468 | |
| 469 | endp_devctl = pci_read_config16(endp, endp_cap + PCI_EXP_DEVCTL); |
| 470 | endp_devctl &= ~PCI_EXP_DEVCTL_PAYLOAD; |
| 471 | endp_devctl |= max_payload << 5; |
| 472 | pci_write_config16(endp, endp_cap + PCI_EXP_DEVCTL, endp_devctl); |
| 473 | |
| 474 | root_devctl = pci_read_config16(root, root_cap + PCI_EXP_DEVCTL); |
| 475 | root_devctl &= ~PCI_EXP_DEVCTL_PAYLOAD; |
| 476 | root_devctl |= max_payload << 5; |
| 477 | pci_write_config16(root, root_cap + PCI_EXP_DEVCTL, root_devctl); |
| 478 | |
| 479 | printk(BIOS_INFO, "PCIe: Max_Payload_Size adjusted to %d\n", (1 << (max_payload + 7))); |
| 480 | } |
| 481 | |
Elyes HAOUAS | b1fa287 | 2018-05-02 21:11:38 +0200 | [diff] [blame] | 482 | static void pciexp_tune_dev(struct device *dev) |
Yinghai Lu | 13f1c2a | 2005-07-08 02:49:49 +0000 | [diff] [blame] | 483 | { |
Elyes HAOUAS | b1fa287 | 2018-05-02 21:11:38 +0200 | [diff] [blame] | 484 | struct device *root = dev->bus->dev; |
Duncan Laurie | 90dcdd4 | 2011-10-25 14:15:11 -0700 | [diff] [blame] | 485 | unsigned int root_cap, cap; |
Yinghai Lu | 13f1c2a | 2005-07-08 02:49:49 +0000 | [diff] [blame] | 486 | |
| 487 | cap = pci_find_capability(dev, PCI_CAP_ID_PCIE); |
Uwe Hermann | d453dd0 | 2010-10-18 00:00:57 +0000 | [diff] [blame] | 488 | if (!cap) |
Yinghai Lu | 13f1c2a | 2005-07-08 02:49:49 +0000 | [diff] [blame] | 489 | return; |
Uwe Hermann | d453dd0 | 2010-10-18 00:00:57 +0000 | [diff] [blame] | 490 | |
Duncan Laurie | 90dcdd4 | 2011-10-25 14:15:11 -0700 | [diff] [blame] | 491 | root_cap = pci_find_capability(root, PCI_CAP_ID_PCIE); |
| 492 | if (!root_cap) |
| 493 | return; |
Stefan Reinauer | f6eb88a | 2010-01-17 13:54:08 +0000 | [diff] [blame] | 494 | |
Duncan Laurie | 90dcdd4 | 2011-10-25 14:15:11 -0700 | [diff] [blame] | 495 | /* Check for and enable Common Clock */ |
Julius Werner | cd49cce | 2019-03-05 16:53:33 -0800 | [diff] [blame] | 496 | if (CONFIG(PCIEXP_COMMON_CLOCK)) |
Kyösti Mälkki | 91bfa8e | 2016-11-20 20:39:56 +0200 | [diff] [blame] | 497 | pciexp_enable_common_clock(root, root_cap, dev, cap); |
Uwe Hermann | e487047 | 2010-11-04 23:23:47 +0000 | [diff] [blame] | 498 | |
Kane Chen | 18cb134 | 2014-10-01 11:13:54 +0800 | [diff] [blame] | 499 | /* Check if per port CLK req is supported by endpoint*/ |
Julius Werner | cd49cce | 2019-03-05 16:53:33 -0800 | [diff] [blame] | 500 | if (CONFIG(PCIEXP_CLK_PM)) |
Kyösti Mälkki | 91bfa8e | 2016-11-20 20:39:56 +0200 | [diff] [blame] | 501 | pciexp_enable_clock_power_pm(dev, cap); |
Kane Chen | 18cb134 | 2014-10-01 11:13:54 +0800 | [diff] [blame] | 502 | |
Kenji Chen | 31c6e63 | 2014-10-04 01:14:44 +0800 | [diff] [blame] | 503 | /* Enable L1 Sub-State when both root port and endpoint support */ |
Julius Werner | cd49cce | 2019-03-05 16:53:33 -0800 | [diff] [blame] | 504 | if (CONFIG(PCIEXP_L1_SUB_STATE)) |
Kyösti Mälkki | 91bfa8e | 2016-11-20 20:39:56 +0200 | [diff] [blame] | 505 | pciexp_config_L1_sub_state(root, dev); |
Kenji Chen | 31c6e63 | 2014-10-04 01:14:44 +0800 | [diff] [blame] | 506 | |
Duncan Laurie | 90dcdd4 | 2011-10-25 14:15:11 -0700 | [diff] [blame] | 507 | /* Check for and enable ASPM */ |
Julius Werner | cd49cce | 2019-03-05 16:53:33 -0800 | [diff] [blame] | 508 | if (CONFIG(PCIEXP_ASPM)) |
Kyösti Mälkki | 91bfa8e | 2016-11-20 20:39:56 +0200 | [diff] [blame] | 509 | pciexp_enable_aspm(root, root_cap, dev, cap); |
Kyösti Mälkki | 94ce79d | 2019-12-16 17:21:13 +0200 | [diff] [blame] | 510 | |
| 511 | /* Adjust Max_Payload_Size of link ends. */ |
| 512 | pciexp_set_max_payload_size(root, root_cap, dev, cap); |
Nico Huber | 968ef75 | 2021-03-07 01:39:18 +0100 | [diff] [blame] | 513 | |
| 514 | pciexp_configure_ltr(root, root_cap, dev, cap); |
Yinghai Lu | 13f1c2a | 2005-07-08 02:49:49 +0000 | [diff] [blame] | 515 | } |
| 516 | |
Kyösti Mälkki | de271a8 | 2015-03-18 13:09:47 +0200 | [diff] [blame] | 517 | void pciexp_scan_bus(struct bus *bus, unsigned int min_devfn, |
| 518 | unsigned int max_devfn) |
Yinghai Lu | 13f1c2a | 2005-07-08 02:49:49 +0000 | [diff] [blame] | 519 | { |
Elyes HAOUAS | b1fa287 | 2018-05-02 21:11:38 +0200 | [diff] [blame] | 520 | struct device *child; |
Nico Huber | 968ef75 | 2021-03-07 01:39:18 +0100 | [diff] [blame] | 521 | |
| 522 | pciexp_enable_ltr(bus->dev); |
| 523 | |
Kyösti Mälkki | de271a8 | 2015-03-18 13:09:47 +0200 | [diff] [blame] | 524 | pci_scan_bus(bus, min_devfn, max_devfn); |
Uwe Hermann | d453dd0 | 2010-10-18 00:00:57 +0000 | [diff] [blame] | 525 | |
| 526 | for (child = bus->children; child; child = child->sibling) { |
Duncan Laurie | bf69622 | 2020-10-18 15:10:00 -0700 | [diff] [blame] | 527 | if (child->path.type != DEVICE_PATH_PCI) |
| 528 | continue; |
Uwe Hermann | d453dd0 | 2010-10-18 00:00:57 +0000 | [diff] [blame] | 529 | if ((child->path.pci.devfn < min_devfn) || |
| 530 | (child->path.pci.devfn > max_devfn)) { |
Yinghai Lu | 13f1c2a | 2005-07-08 02:49:49 +0000 | [diff] [blame] | 531 | continue; |
| 532 | } |
| 533 | pciexp_tune_dev(child); |
| 534 | } |
Yinghai Lu | 13f1c2a | 2005-07-08 02:49:49 +0000 | [diff] [blame] | 535 | } |
| 536 | |
Elyes HAOUAS | b1fa287 | 2018-05-02 21:11:38 +0200 | [diff] [blame] | 537 | void pciexp_scan_bridge(struct device *dev) |
Yinghai Lu | 13f1c2a | 2005-07-08 02:49:49 +0000 | [diff] [blame] | 538 | { |
Kyösti Mälkki | 580e722 | 2015-03-19 21:04:23 +0200 | [diff] [blame] | 539 | do_pci_scan_bridge(dev, pciexp_scan_bus); |
Yinghai Lu | 13f1c2a | 2005-07-08 02:49:49 +0000 | [diff] [blame] | 540 | } |
| 541 | |
| 542 | /** Default device operations for PCI Express bridges */ |
| 543 | static struct pci_operations pciexp_bus_ops_pci = { |
| 544 | .set_subsystem = 0, |
| 545 | }; |
| 546 | |
| 547 | struct device_operations default_pciexp_ops_bus = { |
| 548 | .read_resources = pci_bus_read_resources, |
| 549 | .set_resources = pci_dev_set_resources, |
| 550 | .enable_resources = pci_bus_enable_resources, |
Uwe Hermann | d453dd0 | 2010-10-18 00:00:57 +0000 | [diff] [blame] | 551 | .scan_bus = pciexp_scan_bridge, |
Yinghai Lu | 13f1c2a | 2005-07-08 02:49:49 +0000 | [diff] [blame] | 552 | .reset_bus = pci_bus_reset, |
| 553 | .ops_pci = &pciexp_bus_ops_pci, |
| 554 | }; |
Jeremy Soller | cf2ac54 | 2019-10-09 21:40:36 -0600 | [diff] [blame] | 555 | |
Jeremy Soller | cf2ac54 | 2019-10-09 21:40:36 -0600 | [diff] [blame] | 556 | static void pciexp_hotplug_dummy_read_resources(struct device *dev) |
| 557 | { |
| 558 | struct resource *resource; |
| 559 | |
Furquan Shaikh | 32f385e | 2020-05-15 23:35:00 -0700 | [diff] [blame] | 560 | /* Add extra memory space */ |
Jeremy Soller | cf2ac54 | 2019-10-09 21:40:36 -0600 | [diff] [blame] | 561 | resource = new_resource(dev, 0x10); |
| 562 | resource->size = CONFIG_PCIEXP_HOTPLUG_MEM; |
| 563 | resource->align = 12; |
| 564 | resource->gran = 12; |
| 565 | resource->limit = 0xffffffff; |
| 566 | resource->flags |= IORESOURCE_MEM; |
| 567 | |
Furquan Shaikh | 32f385e | 2020-05-15 23:35:00 -0700 | [diff] [blame] | 568 | /* Add extra prefetchable memory space */ |
Jeremy Soller | cf2ac54 | 2019-10-09 21:40:36 -0600 | [diff] [blame] | 569 | resource = new_resource(dev, 0x14); |
| 570 | resource->size = CONFIG_PCIEXP_HOTPLUG_PREFETCH_MEM; |
| 571 | resource->align = 12; |
| 572 | resource->gran = 12; |
| 573 | resource->limit = 0xffffffffffffffff; |
| 574 | resource->flags |= IORESOURCE_MEM | IORESOURCE_PREFETCH; |
| 575 | |
Furquan Shaikh | 32f385e | 2020-05-15 23:35:00 -0700 | [diff] [blame] | 576 | /* Set resource flag requesting allocation above 4G boundary. */ |
| 577 | if (CONFIG(PCIEXP_HOTPLUG_PREFETCH_MEM_ABOVE_4G)) |
| 578 | resource->flags |= IORESOURCE_ABOVE_4G; |
| 579 | |
| 580 | /* Add extra I/O space */ |
Jeremy Soller | cf2ac54 | 2019-10-09 21:40:36 -0600 | [diff] [blame] | 581 | resource = new_resource(dev, 0x18); |
| 582 | resource->size = CONFIG_PCIEXP_HOTPLUG_IO; |
| 583 | resource->align = 12; |
| 584 | resource->gran = 12; |
| 585 | resource->limit = 0xffff; |
| 586 | resource->flags |= IORESOURCE_IO; |
| 587 | } |
| 588 | |
| 589 | static struct device_operations pciexp_hotplug_dummy_ops = { |
| 590 | .read_resources = pciexp_hotplug_dummy_read_resources, |
John Su | 3ecc777 | 2022-03-25 10:37:52 +0800 | [diff] [blame] | 591 | .set_resources = noop_set_resources, |
Jeremy Soller | cf2ac54 | 2019-10-09 21:40:36 -0600 | [diff] [blame] | 592 | }; |
| 593 | |
| 594 | void pciexp_hotplug_scan_bridge(struct device *dev) |
| 595 | { |
| 596 | dev->hotplug_buses = CONFIG_PCIEXP_HOTPLUG_BUSES; |
| 597 | |
| 598 | /* Normal PCIe Scan */ |
| 599 | pciexp_scan_bridge(dev); |
| 600 | |
| 601 | /* Add dummy slot to preserve resources, must happen after bus scan */ |
| 602 | struct device *dummy; |
| 603 | struct device_path dummy_path = { .type = DEVICE_PATH_NONE }; |
| 604 | dummy = alloc_dev(dev->link_list, &dummy_path); |
| 605 | dummy->ops = &pciexp_hotplug_dummy_ops; |
| 606 | } |
| 607 | |
| 608 | struct device_operations default_pciexp_hotplug_ops_bus = { |
| 609 | .read_resources = pci_bus_read_resources, |
| 610 | .set_resources = pci_dev_set_resources, |
| 611 | .enable_resources = pci_bus_enable_resources, |
| 612 | .scan_bus = pciexp_hotplug_scan_bridge, |
| 613 | .reset_bus = pci_bus_reset, |
| 614 | .ops_pci = &pciexp_bus_ops_pci, |
| 615 | }; |