forked from ~ljy/RK356X_SDK_RELEASE

hc
2023-12-08 01573e231f18eb2d99162747186f59511f56b64d
kernel/arch/sh/drivers/pci/pcie-sh7786.c
....@@ -1,11 +1,8 @@
1
+// SPDX-License-Identifier: GPL-2.0
12 /*
23 * Low-Level PCI Express Support for the SH7786
34 *
45 * Copyright (C) 2009 - 2011 Paul Mundt
5
- *
6
- * This file is subject to the terms and conditions of the GNU General Public
7
- * License. See the file "COPYING" in the main directory of this archive
8
- * for more details.
96 */
107 #define pr_fmt(fmt) "PCI: " fmt
118
....@@ -15,13 +12,14 @@
1512 #include <linux/io.h>
1613 #include <linux/async.h>
1714 #include <linux/delay.h>
15
+#include <linux/dma-mapping.h>
1816 #include <linux/slab.h>
1917 #include <linux/clk.h>
2018 #include <linux/sh_clk.h>
2119 #include <linux/sh_intc.h>
2220 #include <cpu/sh7786.h>
2321 #include "pcie-sh7786.h"
24
-#include <asm/sizes.h>
22
+#include <linux/sizes.h>
2523
2624 struct sh7786_pcie_port {
2725 struct pci_channel *hose;
....@@ -34,6 +32,8 @@
3432 static struct sh7786_pcie_port *sh7786_pcie_ports;
3533 static unsigned int nr_ports;
3634 static unsigned long dma_pfn_offset;
35
+size_t memsize;
36
+u64 memstart;
3737
3838 static struct sh7786_pcie_hwops {
3939 int (*core_init)(void);
....@@ -304,7 +304,6 @@
304304 struct pci_channel *chan = port->hose;
305305 unsigned int data;
306306 phys_addr_t memstart, memend;
307
- size_t memsize;
308307 int ret, i, win;
309308
310309 /* Begin initialization */
....@@ -370,8 +369,6 @@
370369 */
371370 memstart = ALIGN_DOWN(memstart, memsize);
372371 memsize = roundup_pow_of_two(memend - memstart);
373
-
374
- dma_pfn_offset = memstart >> PAGE_SHIFT;
375372
376373 /*
377374 * If there's more than 512MB of memory, we need to roll over to
....@@ -490,7 +487,8 @@
490487
491488 void pcibios_bus_add_device(struct pci_dev *pdev)
492489 {
493
- pdev->dev.dma_pfn_offset = dma_pfn_offset;
490
+ dma_direct_set_offset(&pdev->dev, __pa(memory_start),
491
+ __pa(memory_start) - memstart, memsize);
494492 }
495493
496494 static int __init sh7786_pcie_core_init(void)