blob: 010010bf205a77486573fd6d71ad553d6a4792c9 [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001// SPDX-License-Identifier: GPL-2.0
Paul Mundt9edef282010-02-17 16:28:00 +09002#include <linux/init.h>
Paul Mundt5b34d1e2010-03-10 16:46:58 +09003#include <linux/module.h>
Paul Mundt9edef282010-02-17 16:28:00 +09004#include <asm/sizes.h>
5#include <asm/page.h>
Paul Mundt40d1f002010-03-08 21:03:21 +09006#include <asm/addrspace.h>
Paul Mundt9edef282010-02-17 16:28:00 +09007
8/*
9 * This is the offset of the uncached section from its cached alias.
10 *
11 * Legacy platforms handle trivial transitions between cached and
12 * uncached segments by making use of the 1:1 mapping relationship in
13 * 512MB lowmem, others via a special uncached mapping.
14 *
15 * Default value only valid in 29 bit mode, in 32bit mode this will be
16 * updated by the early PMB initialization code.
17 */
18unsigned long cached_to_uncached = SZ_512M;
19unsigned long uncached_size = SZ_512M;
20unsigned long uncached_start, uncached_end;
Paul Mundt5b34d1e2010-03-10 16:46:58 +090021EXPORT_SYMBOL(uncached_start);
22EXPORT_SYMBOL(uncached_end);
Paul Mundt9edef282010-02-17 16:28:00 +090023
24int virt_addr_uncached(unsigned long kaddr)
25{
26 return (kaddr >= uncached_start) && (kaddr < uncached_end);
27}
Paul Mundt5b34d1e2010-03-10 16:46:58 +090028EXPORT_SYMBOL(virt_addr_uncached);
Paul Mundt9edef282010-02-17 16:28:00 +090029
30void __init uncached_init(void)
31{
Paul Mundte2fcf742010-11-04 12:32:24 +090032#if defined(CONFIG_29BIT) || !defined(CONFIG_MMU)
Paul Mundt40d1f002010-03-08 21:03:21 +090033 uncached_start = P2SEG;
34#else
Paul Mundt9edef282010-02-17 16:28:00 +090035 uncached_start = memory_end;
Paul Mundt40d1f002010-03-08 21:03:21 +090036#endif
Paul Mundt9edef282010-02-17 16:28:00 +090037 uncached_end = uncached_start + uncached_size;
38}
Paul Mundtd01447b2010-02-18 18:13:51 +090039
40void __init uncached_resize(unsigned long size)
41{
42 uncached_size = size;
43 uncached_end = uncached_start + uncached_size;
44}