blob: feebc6eeee5b7d7b7ad2df4ffaffe1bc0678b137 [file] [log] [blame]
Thomas Gleixner2874c5f2019-05-27 08:55:01 +02001// SPDX-License-Identifier: GPL-2.0-or-later
Linus Torvalds1da177e2005-04-16 15:20:36 -07002/*
Linus Torvalds1da177e2005-04-16 15:20:36 -07003 *
Ralf Baechlec539ef72012-01-11 15:37:16 +01004 * 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 Torvalds1da177e2005-04-16 15:20:36 -07007 */
Ralf Baechlec539ef72012-01-11 15:37:16 +01008#include <linux/bug.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -07009#include <linux/kernel.h>
10#include <linux/mm.h>
Mike Rapoport57c8a662018-10-30 15:09:49 -070011#include <linux/memblock.h>
Paul Gortmakercae39d12011-07-28 18:46:31 -040012#include <linux/export.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070013#include <linux/init.h>
14#include <linux/types.h>
15#include <linux/pci.h>
John Crispina48cf372012-05-04 10:50:13 +020016#include <linux/of_address.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070017
Ralf Baechlec539ef72012-01-11 15:37:16 +010018#include <asm/cpu-info.h>
19
Ralf Baechle982f6ff2009-09-17 02:25:07 +020020unsigned long PCIBIOS_MIN_IO;
Paul Burtonf8091a82016-10-05 18:18:11 +010021EXPORT_SYMBOL(PCIBIOS_MIN_IO);
22
Ralf Baechle982f6ff2009-09-17 02:25:07 +020023unsigned long PCIBIOS_MIN_MEM;
Paul Burtonf8091a82016-10-05 18:18:11 +010024EXPORT_SYMBOL(PCIBIOS_MIN_MEM);
Linus Torvalds1da177e2005-04-16 15:20:36 -070025
Paul Burtonf474ba92016-10-05 18:18:09 +010026static int __init pcibios_set_cache_line_size(void)
Ralf Baechlec539ef72012-01-11 15:37:16 +010027{
Ralf Baechlec539ef72012-01-11 15:37:16 +010028 unsigned int lsize;
29
30 /*
31 * Set PCI cacheline size to that of the highest level in the
32 * cache hierarchy.
33 */
Matt Redfearn73530262017-07-26 08:41:09 +010034 lsize = cpu_dcache_line_size();
35 lsize = cpu_scache_line_size() ? : lsize;
36 lsize = cpu_tcache_line_size() ? : lsize;
Ralf Baechlec539ef72012-01-11 15:37:16 +010037
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 Burtonf474ba92016-10-05 18:18:09 +010043 return 0;
Ralf Baechlec539ef72012-01-11 15:37:16 +010044}
Paul Burtonf474ba92016-10-05 18:18:09 +010045arch_initcall(pcibios_set_cache_line_size);
Ralf Baechlec539ef72012-01-11 15:37:16 +010046
Bjorn Helgaas8221a012016-06-17 14:43:34 -050047void 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 Burton38c0a742018-07-12 09:33:04 -070054 *end = rsrc->start + size - 1;
Bjorn Helgaas8221a012016-06-17 14:43:34 -050055}