Thomas Gleixner | 2874c5f | 2019-05-27 08:55:01 +0200 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0-or-later |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3 | * |
Ralf Baechle | c539ef7 | 2012-01-11 15:37:16 +0100 | [diff] [blame] | 4 | * Copyright (C) 2003, 04, 11 Ralf Baechle (ralf@linux-mips.org) |
| 5 | * Copyright (C) 2011 Wind River Systems, |
| 6 | * written by Ralf Baechle (ralf@linux-mips.org) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7 | */ |
Ralf Baechle | c539ef7 | 2012-01-11 15:37:16 +0100 | [diff] [blame] | 8 | #include <linux/bug.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 9 | #include <linux/kernel.h> |
| 10 | #include <linux/mm.h> |
Mike Rapoport | 57c8a66 | 2018-10-30 15:09:49 -0700 | [diff] [blame] | 11 | #include <linux/memblock.h> |
Paul Gortmaker | cae39d1 | 2011-07-28 18:46:31 -0400 | [diff] [blame] | 12 | #include <linux/export.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 13 | #include <linux/init.h> |
| 14 | #include <linux/types.h> |
| 15 | #include <linux/pci.h> |
John Crispin | a48cf37 | 2012-05-04 10:50:13 +0200 | [diff] [blame] | 16 | #include <linux/of_address.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 17 | |
Ralf Baechle | c539ef7 | 2012-01-11 15:37:16 +0100 | [diff] [blame] | 18 | #include <asm/cpu-info.h> |
| 19 | |
Ralf Baechle | 982f6ff | 2009-09-17 02:25:07 +0200 | [diff] [blame] | 20 | unsigned long PCIBIOS_MIN_IO; |
Paul Burton | f8091a8 | 2016-10-05 18:18:11 +0100 | [diff] [blame] | 21 | EXPORT_SYMBOL(PCIBIOS_MIN_IO); |
| 22 | |
Ralf Baechle | 982f6ff | 2009-09-17 02:25:07 +0200 | [diff] [blame] | 23 | unsigned long PCIBIOS_MIN_MEM; |
Paul Burton | f8091a8 | 2016-10-05 18:18:11 +0100 | [diff] [blame] | 24 | EXPORT_SYMBOL(PCIBIOS_MIN_MEM); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 25 | |
Paul Burton | f474ba9 | 2016-10-05 18:18:09 +0100 | [diff] [blame] | 26 | static int __init pcibios_set_cache_line_size(void) |
Ralf Baechle | c539ef7 | 2012-01-11 15:37:16 +0100 | [diff] [blame] | 27 | { |
Ralf Baechle | c539ef7 | 2012-01-11 15:37:16 +0100 | [diff] [blame] | 28 | unsigned int lsize; |
| 29 | |
| 30 | /* |
| 31 | * Set PCI cacheline size to that of the highest level in the |
| 32 | * cache hierarchy. |
| 33 | */ |
Matt Redfearn | 7353026 | 2017-07-26 08:41:09 +0100 | [diff] [blame] | 34 | lsize = cpu_dcache_line_size(); |
| 35 | lsize = cpu_scache_line_size() ? : lsize; |
| 36 | lsize = cpu_tcache_line_size() ? : lsize; |
Ralf Baechle | c539ef7 | 2012-01-11 15:37:16 +0100 | [diff] [blame] | 37 | |
| 38 | BUG_ON(!lsize); |
| 39 | |
| 40 | pci_dfl_cache_line_size = lsize >> 2; |
| 41 | |
| 42 | pr_debug("PCI: pci_cache_line_size set to %d bytes\n", lsize); |
Paul Burton | f474ba9 | 2016-10-05 18:18:09 +0100 | [diff] [blame] | 43 | return 0; |
Ralf Baechle | c539ef7 | 2012-01-11 15:37:16 +0100 | [diff] [blame] | 44 | } |
Paul Burton | f474ba9 | 2016-10-05 18:18:09 +0100 | [diff] [blame] | 45 | arch_initcall(pcibios_set_cache_line_size); |
Ralf Baechle | c539ef7 | 2012-01-11 15:37:16 +0100 | [diff] [blame] | 46 | |
Bjorn Helgaas | 8221a01 | 2016-06-17 14:43:34 -0500 | [diff] [blame] | 47 | void pci_resource_to_user(const struct pci_dev *dev, int bar, |
| 48 | const struct resource *rsrc, resource_size_t *start, |
| 49 | resource_size_t *end) |
| 50 | { |
| 51 | phys_addr_t size = resource_size(rsrc); |
| 52 | |
| 53 | *start = fixup_bigphys_addr(rsrc->start, size); |
Paul Burton | 38c0a74 | 2018-07-12 09:33:04 -0700 | [diff] [blame] | 54 | *end = rsrc->start + size - 1; |
Bjorn Helgaas | 8221a01 | 2016-06-17 14:43:34 -0500 | [diff] [blame] | 55 | } |