aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBecky Bruce <becky.bruce@freescale.com>2008-06-13 19:41:42 -0400
committerPaul Mackerras <paulus@samba.org>2008-06-30 08:31:03 -0400
commit7c5c4325d2d911fe54db3bc14149bfa558ae0acb (patch)
tree97c02e9d03bbbb1fff89e9e44eef1e53762e823e
parentbf2737f74ffd36f43c6ed11cd2c0826e1d59ad48 (diff)
powerpc: Change BAT code to use phys_addr_t
Currently, the physical address is an unsigned long, but it should be phys_addr_t in set_bat, [v/p]_mapped_by_bat. Also, create a macro that can convert a large physical address into the correct format for programming the BAT registers. Signed-off-by: Becky Bruce <becky.bruce@freescale.com> Signed-off-by: Paul Mackerras <paulus@samba.org>
-rw-r--r--arch/powerpc/mm/mmu_decl.h2
-rw-r--r--arch/powerpc/mm/pgtable_32.c6
-rw-r--r--arch/powerpc/mm/ppc_mmu_32.c10
-rw-r--r--include/asm-powerpc/mmu-hash32.h9
4 files changed, 18 insertions, 9 deletions
diff --git a/arch/powerpc/mm/mmu_decl.h b/arch/powerpc/mm/mmu_decl.h
index 04802252a64f..46585b7bb194 100644
--- a/arch/powerpc/mm/mmu_decl.h
+++ b/arch/powerpc/mm/mmu_decl.h
@@ -29,7 +29,7 @@ extern void hash_preload(struct mm_struct *mm, unsigned long ea,
29#ifdef CONFIG_PPC32 29#ifdef CONFIG_PPC32
30extern void mapin_ram(void); 30extern void mapin_ram(void);
31extern int map_page(unsigned long va, phys_addr_t pa, int flags); 31extern int map_page(unsigned long va, phys_addr_t pa, int flags);
32extern void setbat(int index, unsigned long virt, unsigned long phys, 32extern void setbat(int index, unsigned long virt, phys_addr_t phys,
33 unsigned int size, int flags); 33 unsigned int size, int flags);
34extern void settlbcam(int index, unsigned long virt, phys_addr_t phys, 34extern void settlbcam(int index, unsigned long virt, phys_addr_t phys,
35 unsigned int size, int flags, unsigned int pid); 35 unsigned int size, int flags, unsigned int pid);
diff --git a/arch/powerpc/mm/pgtable_32.c b/arch/powerpc/mm/pgtable_32.c
index e0ff59f21135..c7584072dfcc 100644
--- a/arch/powerpc/mm/pgtable_32.c
+++ b/arch/powerpc/mm/pgtable_32.c
@@ -53,9 +53,9 @@ extern void hash_page_sync(void);
53#endif 53#endif
54 54
55#ifdef HAVE_BATS 55#ifdef HAVE_BATS
56extern unsigned long v_mapped_by_bats(unsigned long va); 56extern phys_addr_t v_mapped_by_bats(unsigned long va);
57extern unsigned long p_mapped_by_bats(unsigned long pa); 57extern unsigned long p_mapped_by_bats(phys_addr_t pa);
58void setbat(int index, unsigned long virt, unsigned long phys, 58void setbat(int index, unsigned long virt, phys_addr_t phys,
59 unsigned int size, int flags); 59 unsigned int size, int flags);
60 60
61#else /* !HAVE_BATS */ 61#else /* !HAVE_BATS */
diff --git a/arch/powerpc/mm/ppc_mmu_32.c b/arch/powerpc/mm/ppc_mmu_32.c
index cef9f156874b..55ec17ed8d7c 100644
--- a/arch/powerpc/mm/ppc_mmu_32.c
+++ b/arch/powerpc/mm/ppc_mmu_32.c
@@ -46,13 +46,13 @@ union ubat { /* BAT register values to be loaded */
46struct batrange { /* stores address ranges mapped by BATs */ 46struct batrange { /* stores address ranges mapped by BATs */
47 unsigned long start; 47 unsigned long start;
48 unsigned long limit; 48 unsigned long limit;
49 unsigned long phys; 49 phys_addr_t phys;
50} bat_addrs[8]; 50} bat_addrs[8];
51 51
52/* 52/*
53 * Return PA for this VA if it is mapped by a BAT, or 0 53 * Return PA for this VA if it is mapped by a BAT, or 0
54 */ 54 */
55unsigned long v_mapped_by_bats(unsigned long va) 55phys_addr_t v_mapped_by_bats(unsigned long va)
56{ 56{
57 int b; 57 int b;
58 for (b = 0; b < 4; ++b) 58 for (b = 0; b < 4; ++b)
@@ -64,7 +64,7 @@ unsigned long v_mapped_by_bats(unsigned long va)
64/* 64/*
65 * Return VA for a given PA or 0 if not mapped 65 * Return VA for a given PA or 0 if not mapped
66 */ 66 */
67unsigned long p_mapped_by_bats(unsigned long pa) 67unsigned long p_mapped_by_bats(phys_addr_t pa)
68{ 68{
69 int b; 69 int b;
70 for (b = 0; b < 4; ++b) 70 for (b = 0; b < 4; ++b)
@@ -119,7 +119,7 @@ unsigned long __init mmu_mapin_ram(void)
119 * The parameters are not checked; in particular size must be a power 119 * The parameters are not checked; in particular size must be a power
120 * of 2 between 128k and 256M. 120 * of 2 between 128k and 256M.
121 */ 121 */
122void __init setbat(int index, unsigned long virt, unsigned long phys, 122void __init setbat(int index, unsigned long virt, phys_addr_t phys,
123 unsigned int size, int flags) 123 unsigned int size, int flags)
124{ 124{
125 unsigned int bl; 125 unsigned int bl;
@@ -138,7 +138,7 @@ void __init setbat(int index, unsigned long virt, unsigned long phys,
138 | _PAGE_COHERENT | _PAGE_GUARDED); 138 | _PAGE_COHERENT | _PAGE_GUARDED);
139 wimgxpp |= (flags & _PAGE_RW)? BPP_RW: BPP_RX; 139 wimgxpp |= (flags & _PAGE_RW)? BPP_RW: BPP_RX;
140 bat[1].word[0] = virt | (bl << 2) | 2; /* Vs=1, Vp=0 */ 140 bat[1].word[0] = virt | (bl << 2) | 2; /* Vs=1, Vp=0 */
141 bat[1].word[1] = phys | wimgxpp; 141 bat[1].word[1] = BAT_PHYS_ADDR(phys) | wimgxpp;
142#ifndef CONFIG_KGDB /* want user access for breakpoints */ 142#ifndef CONFIG_KGDB /* want user access for breakpoints */
143 if (flags & _PAGE_USER) 143 if (flags & _PAGE_USER)
144#endif 144#endif
diff --git a/include/asm-powerpc/mmu-hash32.h b/include/asm-powerpc/mmu-hash32.h
index 6e21ca618ec3..f39ff983b381 100644
--- a/include/asm-powerpc/mmu-hash32.h
+++ b/include/asm-powerpc/mmu-hash32.h
@@ -28,6 +28,15 @@
28#define BPP_RW 0x02 /* Read/write */ 28#define BPP_RW 0x02 /* Read/write */
29 29
30#ifndef __ASSEMBLY__ 30#ifndef __ASSEMBLY__
31/* Contort a phys_addr_t into the right format/bits for a BAT */
32#ifdef CONFIG_PHYS_64BIT
33#define BAT_PHYS_ADDR(x) ((u32)((x & 0x00000000fffe0000ULL) | \
34 ((x & 0x0000000e00000000ULL) >> 24) | \
35 ((x & 0x0000000100000000ULL) >> 30)))
36#else
37#define BAT_PHYS_ADDR(x) (x)
38#endif
39
31struct ppc_bat { 40struct ppc_bat {
32 struct { 41 struct {
33 unsigned long bepi:15; /* Effective page index (virtual address) */ 42 unsigned long bepi:15; /* Effective page index (virtual address) */