hc
2024-02-20 102a0743326a03cd1a1202ceda21e175b7d3575c
kernel/drivers/pci/controller/dwc/pci-exynos.c
....@@ -1,9 +1,9 @@
11 // SPDX-License-Identifier: GPL-2.0
22 /*
3
- * PCIe host controller driver for Samsung EXYNOS SoCs
3
+ * PCIe host controller driver for Samsung Exynos SoCs
44 *
55 * Copyright (C) 2013 Samsung Electronics Co., Ltd.
6
- * http://www.samsung.com
6
+ * https://www.samsung.com
77 *
88 * Author: Jingoo Han <jg1.han@samsung.com>
99 */
....@@ -84,14 +84,12 @@
8484 {
8585 struct dw_pcie *pci = ep->pci;
8686 struct device *dev = pci->dev;
87
- struct resource *res;
8887
8988 ep->mem_res = devm_kzalloc(dev, sizeof(*ep->mem_res), GFP_KERNEL);
9089 if (!ep->mem_res)
9190 return -ENOMEM;
9291
93
- res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
94
- ep->mem_res->elbi_base = devm_ioremap_resource(dev, res);
92
+ ep->mem_res->elbi_base = devm_platform_ioremap_resource(pdev, 0);
9593 if (IS_ERR(ep->mem_res->elbi_base))
9694 return PTR_ERR(ep->mem_res->elbi_base);
9795
....@@ -338,31 +336,36 @@
338336 exynos_pcie_sideband_dbi_w_mode(ep, false);
339337 }
340338
341
-static int exynos_pcie_rd_own_conf(struct pcie_port *pp, int where, int size,
342
- u32 *val)
339
+static int exynos_pcie_rd_own_conf(struct pci_bus *bus, unsigned int devfn,
340
+ int where, int size, u32 *val)
343341 {
344
- struct dw_pcie *pci = to_dw_pcie_from_pp(pp);
345
- struct exynos_pcie *ep = to_exynos_pcie(pci);
346
- int ret;
342
+ struct dw_pcie *pci = to_dw_pcie_from_pp(bus->sysdata);
347343
348
- exynos_pcie_sideband_dbi_r_mode(ep, true);
349
- ret = dw_pcie_read(pci->dbi_base + where, size, val);
350
- exynos_pcie_sideband_dbi_r_mode(ep, false);
351
- return ret;
344
+ if (PCI_SLOT(devfn)) {
345
+ *val = ~0;
346
+ return PCIBIOS_DEVICE_NOT_FOUND;
347
+ }
348
+
349
+ *val = dw_pcie_read_dbi(pci, where, size);
350
+ return PCIBIOS_SUCCESSFUL;
352351 }
353352
354
-static int exynos_pcie_wr_own_conf(struct pcie_port *pp, int where, int size,
355
- u32 val)
353
+static int exynos_pcie_wr_own_conf(struct pci_bus *bus, unsigned int devfn,
354
+ int where, int size, u32 val)
356355 {
357
- struct dw_pcie *pci = to_dw_pcie_from_pp(pp);
358
- struct exynos_pcie *ep = to_exynos_pcie(pci);
359
- int ret;
356
+ struct dw_pcie *pci = to_dw_pcie_from_pp(bus->sysdata);
360357
361
- exynos_pcie_sideband_dbi_w_mode(ep, true);
362
- ret = dw_pcie_write(pci->dbi_base + where, size, val);
363
- exynos_pcie_sideband_dbi_w_mode(ep, false);
364
- return ret;
358
+ if (PCI_SLOT(devfn))
359
+ return PCIBIOS_DEVICE_NOT_FOUND;
360
+
361
+ dw_pcie_write_dbi(pci, where, size, val);
362
+ return PCIBIOS_SUCCESSFUL;
365363 }
364
+
365
+static struct pci_ops exynos_pci_ops = {
366
+ .read = exynos_pcie_rd_own_conf,
367
+ .write = exynos_pcie_wr_own_conf,
368
+};
366369
367370 static int exynos_pcie_link_up(struct dw_pcie *pci)
368371 {
....@@ -381,6 +384,8 @@
381384 struct dw_pcie *pci = to_dw_pcie_from_pp(pp);
382385 struct exynos_pcie *ep = to_exynos_pcie(pci);
383386
387
+ pp->bridge->ops = &exynos_pci_ops;
388
+
384389 exynos_pcie_establish_link(ep);
385390 exynos_pcie_enable_interrupts(ep);
386391
....@@ -388,8 +393,6 @@
388393 }
389394
390395 static const struct dw_pcie_host_ops exynos_pcie_host_ops = {
391
- .rd_own_conf = exynos_pcie_rd_own_conf,
392
- .wr_own_conf = exynos_pcie_wr_own_conf,
393396 .host_init = exynos_pcie_host_init,
394397 };
395398
....@@ -402,10 +405,9 @@
402405 int ret;
403406
404407 pp->irq = platform_get_irq(pdev, 1);
405
- if (pp->irq < 0) {
406
- dev_err(dev, "failed to get irq\n");
408
+ if (pp->irq < 0)
407409 return pp->irq;
408
- }
410
+
409411 ret = devm_request_irq(dev, pp->irq, exynos_pcie_irq_handler,
410412 IRQF_SHARED, "exynos-pcie", ep);
411413 if (ret) {
....@@ -415,10 +417,8 @@
415417
416418 if (IS_ENABLED(CONFIG_PCI_MSI)) {
417419 pp->msi_irq = platform_get_irq(pdev, 0);
418
- if (pp->msi_irq < 0) {
419
- dev_err(dev, "failed to get msi irq\n");
420
+ if (pp->msi_irq < 0)
420421 return pp->msi_irq;
421
- }
422422 }
423423
424424 pp->ops = &exynos_pcie_host_ops;