hc
2024-02-20 102a0743326a03cd1a1202ceda21e175b7d3575c
kernel/drivers/pci/controller/dwc/pcie-histb.c
....@@ -122,31 +122,36 @@
122122 histb_pcie_dbi_w_mode(&pci->pp, false);
123123 }
124124
125
-static int histb_pcie_rd_own_conf(struct pcie_port *pp, int where,
126
- int size, u32 *val)
125
+static int histb_pcie_rd_own_conf(struct pci_bus *bus, unsigned int devfn,
126
+ int where, int size, u32 *val)
127127 {
128
- struct dw_pcie *pci = to_dw_pcie_from_pp(pp);
129
- int ret;
128
+ struct dw_pcie *pci = to_dw_pcie_from_pp(bus->sysdata);
130129
131
- histb_pcie_dbi_r_mode(pp, true);
132
- ret = dw_pcie_read(pci->dbi_base + where, size, val);
133
- histb_pcie_dbi_r_mode(pp, false);
130
+ if (PCI_SLOT(devfn)) {
131
+ *val = ~0;
132
+ return PCIBIOS_DEVICE_NOT_FOUND;
133
+ }
134134
135
- return ret;
135
+ *val = dw_pcie_read_dbi(pci, where, size);
136
+ return PCIBIOS_SUCCESSFUL;
136137 }
137138
138
-static int histb_pcie_wr_own_conf(struct pcie_port *pp, int where,
139
- int size, u32 val)
139
+static int histb_pcie_wr_own_conf(struct pci_bus *bus, unsigned int devfn,
140
+ int where, int size, u32 val)
140141 {
141
- struct dw_pcie *pci = to_dw_pcie_from_pp(pp);
142
- int ret;
142
+ struct dw_pcie *pci = to_dw_pcie_from_pp(bus->sysdata);
143143
144
- histb_pcie_dbi_w_mode(pp, true);
145
- ret = dw_pcie_write(pci->dbi_base + where, size, val);
146
- histb_pcie_dbi_w_mode(pp, false);
144
+ if (PCI_SLOT(devfn))
145
+ return PCIBIOS_DEVICE_NOT_FOUND;
147146
148
- return ret;
147
+ dw_pcie_write_dbi(pci, where, size, val);
148
+ return PCIBIOS_SUCCESSFUL;
149149 }
150
+
151
+static struct pci_ops histb_pci_ops = {
152
+ .read = histb_pcie_rd_own_conf,
153
+ .write = histb_pcie_wr_own_conf,
154
+};
150155
151156 static int histb_pcie_link_up(struct dw_pcie *pci)
152157 {
....@@ -194,17 +199,15 @@
194199
195200 static int histb_pcie_host_init(struct pcie_port *pp)
196201 {
197
- histb_pcie_establish_link(pp);
202
+ pp->bridge->ops = &histb_pci_ops;
198203
199
- if (IS_ENABLED(CONFIG_PCI_MSI))
200
- dw_pcie_msi_init(pp);
204
+ histb_pcie_establish_link(pp);
205
+ dw_pcie_msi_init(pp);
201206
202207 return 0;
203208 }
204209
205
-static struct dw_pcie_host_ops histb_pcie_host_ops = {
206
- .rd_own_conf = histb_pcie_rd_own_conf,
207
- .wr_own_conf = histb_pcie_wr_own_conf,
210
+static const struct dw_pcie_host_ops histb_pcie_host_ops = {
208211 .host_init = histb_pcie_host_init,
209212 };
210213
....@@ -304,7 +307,6 @@
304307 struct histb_pcie *hipcie;
305308 struct dw_pcie *pci;
306309 struct pcie_port *pp;
307
- struct resource *res;
308310 struct device_node *np = pdev->dev.of_node;
309311 struct device *dev = &pdev->dev;
310312 enum of_gpio_flags of_flags;
....@@ -324,15 +326,13 @@
324326 pci->dev = dev;
325327 pci->ops = &dw_pcie_ops;
326328
327
- res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "control");
328
- hipcie->ctrl = devm_ioremap_resource(dev, res);
329
+ hipcie->ctrl = devm_platform_ioremap_resource_byname(pdev, "control");
329330 if (IS_ERR(hipcie->ctrl)) {
330331 dev_err(dev, "cannot get control reg base\n");
331332 return PTR_ERR(hipcie->ctrl);
332333 }
333334
334
- res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "rc-dbi");
335
- pci->dbi_base = devm_ioremap_resource(dev, res);
335
+ pci->dbi_base = devm_platform_ioremap_resource_byname(pdev, "rc-dbi");
336336 if (IS_ERR(pci->dbi_base)) {
337337 dev_err(dev, "cannot get rc-dbi base\n");
338338 return PTR_ERR(pci->dbi_base);
....@@ -402,10 +402,8 @@
402402
403403 if (IS_ENABLED(CONFIG_PCI_MSI)) {
404404 pp->msi_irq = platform_get_irq_byname(pdev, "msi");
405
- if (pp->msi_irq < 0) {
406
- dev_err(dev, "Failed to get MSI IRQ\n");
405
+ if (pp->msi_irq < 0)
407406 return pp->msi_irq;
408
- }
409407 }
410408
411409 hipcie->phy = devm_phy_get(dev, "phy");