aboutsummaryrefslogtreecommitdiffstats
path: root/arch/sh/mm
diff options
context:
space:
mode:
Diffstat (limited to 'arch/sh/mm')
-rw-r--r--arch/sh/mm/Kconfig29
-rw-r--r--arch/sh/mm/Makefile_327
-rw-r--r--arch/sh/mm/asids-debugfs.c4
-rw-r--r--arch/sh/mm/ioremap_32.c8
-rw-r--r--arch/sh/mm/pmb-fixed.c45
-rw-r--r--arch/sh/mm/pmb.c38
-rw-r--r--arch/sh/mm/tlb-pteaex.c96
7 files changed, 218 insertions, 9 deletions
diff --git a/arch/sh/mm/Kconfig b/arch/sh/mm/Kconfig
index 555ec9714b9e..10c24356d2d5 100644
--- a/arch/sh/mm/Kconfig
+++ b/arch/sh/mm/Kconfig
@@ -57,7 +57,7 @@ config 32BIT
57 bool 57 bool
58 default y if CPU_SH5 58 default y if CPU_SH5
59 59
60config PMB 60config PMB_ENABLE
61 bool "Support 32-bit physical addressing through PMB" 61 bool "Support 32-bit physical addressing through PMB"
62 depends on MMU && EXPERIMENTAL && (CPU_SUBTYPE_SH7780 || CPU_SUBTYPE_SH7785) 62 depends on MMU && EXPERIMENTAL && (CPU_SUBTYPE_SH7780 || CPU_SUBTYPE_SH7785)
63 select 32BIT 63 select 32BIT
@@ -67,6 +67,33 @@ config PMB
67 32-bits through the SH-4A PMB. If this is not set, legacy 67 32-bits through the SH-4A PMB. If this is not set, legacy
68 29-bit physical addressing will be used. 68 29-bit physical addressing will be used.
69 69
70choice
71 prompt "PMB handling type"
72 depends on PMB_ENABLE
73 default PMB_FIXED
74
75config PMB
76 bool "PMB"
77 depends on MMU && EXPERIMENTAL && (CPU_SUBTYPE_SH7780 || CPU_SUBTYPE_SH7785)
78 select 32BIT
79 help
80 If you say Y here, physical addressing will be extended to
81 32-bits through the SH-4A PMB. If this is not set, legacy
82 29-bit physical addressing will be used.
83
84config PMB_FIXED
85 bool "fixed PMB"
86 depends on MMU && EXPERIMENTAL && (CPU_SUBTYPE_SH7780 || \
87 CPU_SUBTYPE_SH7785)
88 select 32BIT
89 help
90 If this option is enabled, fixed PMB mappings are inherited
91 from the boot loader, and the kernel does not attempt dynamic
92 management. This is the closest to legacy 29-bit physical mode,
93 and allows systems to support up to 512MiB of system memory.
94
95endchoice
96
70config X2TLB 97config X2TLB
71 bool "Enable extended TLB mode" 98 bool "Enable extended TLB mode"
72 depends on (CPU_SHX2 || CPU_SHX3) && MMU && EXPERIMENTAL 99 depends on (CPU_SHX2 || CPU_SHX3) && MMU && EXPERIMENTAL
diff --git a/arch/sh/mm/Makefile_32 b/arch/sh/mm/Makefile_32
index cb2f3f299591..986a1e055834 100644
--- a/arch/sh/mm/Makefile_32
+++ b/arch/sh/mm/Makefile_32
@@ -25,8 +25,10 @@ obj-$(CONFIG_CPU_SH4) += cache-debugfs.o
25endif 25endif
26 26
27ifdef CONFIG_MMU 27ifdef CONFIG_MMU
28obj-$(CONFIG_CPU_SH3) += tlb-sh3.o 28tlb-$(CONFIG_CPU_SH3) := tlb-sh3.o
29obj-$(CONFIG_CPU_SH4) += tlb-sh4.o 29tlb-$(CONFIG_CPU_SH4) := tlb-sh4.o
30tlb-$(CONFIG_CPU_HAS_PTEAEX) := tlb-pteaex.o
31obj-y += $(tlb-y)
30ifndef CONFIG_CACHE_OFF 32ifndef CONFIG_CACHE_OFF
31obj-$(CONFIG_CPU_SH4) += pg-sh4.o 33obj-$(CONFIG_CPU_SH4) += pg-sh4.o
32obj-$(CONFIG_SH7705_CACHE_32KB) += pg-sh7705.o 34obj-$(CONFIG_SH7705_CACHE_32KB) += pg-sh7705.o
@@ -35,6 +37,7 @@ endif
35 37
36obj-$(CONFIG_HUGETLB_PAGE) += hugetlbpage.o 38obj-$(CONFIG_HUGETLB_PAGE) += hugetlbpage.o
37obj-$(CONFIG_PMB) += pmb.o 39obj-$(CONFIG_PMB) += pmb.o
40obj-$(CONFIG_PMB_FIXED) += pmb-fixed.o
38obj-$(CONFIG_NUMA) += numa.o 41obj-$(CONFIG_NUMA) += numa.o
39 42
40EXTRA_CFLAGS += -Werror 43EXTRA_CFLAGS += -Werror
diff --git a/arch/sh/mm/asids-debugfs.c b/arch/sh/mm/asids-debugfs.c
index 8e912a15e94f..cd8c3bf39b5a 100644
--- a/arch/sh/mm/asids-debugfs.c
+++ b/arch/sh/mm/asids-debugfs.c
@@ -37,10 +37,8 @@ static int asids_seq_show(struct seq_file *file, void *iter)
37 continue; 37 continue;
38 38
39 if (p->mm) 39 if (p->mm)
40 seq_printf(file, "%5d : %02lx\n", pid, 40 seq_printf(file, "%5d : %04lx\n", pid,
41 cpu_asid(smp_processor_id(), p->mm)); 41 cpu_asid(smp_processor_id(), p->mm));
42 else
43 seq_printf(file, "%5d : (none)\n", pid);
44 } 42 }
45 43
46 read_unlock(&tasklist_lock); 44 read_unlock(&tasklist_lock);
diff --git a/arch/sh/mm/ioremap_32.c b/arch/sh/mm/ioremap_32.c
index 32946fba123e..60cc486d2c2c 100644
--- a/arch/sh/mm/ioremap_32.c
+++ b/arch/sh/mm/ioremap_32.c
@@ -59,11 +59,13 @@ void __iomem *__ioremap(unsigned long phys_addr, unsigned long size,
59 if (is_pci_memaddr(phys_addr) && is_pci_memaddr(last_addr)) 59 if (is_pci_memaddr(phys_addr) && is_pci_memaddr(last_addr))
60 return (void __iomem *)phys_addr; 60 return (void __iomem *)phys_addr;
61 61
62#if !defined(CONFIG_PMB_FIXED)
62 /* 63 /*
63 * Don't allow anybody to remap normal RAM that we're using.. 64 * Don't allow anybody to remap normal RAM that we're using..
64 */ 65 */
65 if (phys_addr < virt_to_phys(high_memory)) 66 if (phys_addr < virt_to_phys(high_memory))
66 return NULL; 67 return NULL;
68#endif
67 69
68 /* 70 /*
69 * Mappings have to be page-aligned 71 * Mappings have to be page-aligned
@@ -81,7 +83,7 @@ void __iomem *__ioremap(unsigned long phys_addr, unsigned long size,
81 area->phys_addr = phys_addr; 83 area->phys_addr = phys_addr;
82 orig_addr = addr = (unsigned long)area->addr; 84 orig_addr = addr = (unsigned long)area->addr;
83 85
84#ifdef CONFIG_32BIT 86#ifdef CONFIG_PMB
85 /* 87 /*
86 * First try to remap through the PMB once a valid VMA has been 88 * First try to remap through the PMB once a valid VMA has been
87 * established. Smaller allocations (or the rest of the size 89 * established. Smaller allocations (or the rest of the size
@@ -119,10 +121,10 @@ void __iounmap(void __iomem *addr)
119 unsigned long seg = PXSEG(vaddr); 121 unsigned long seg = PXSEG(vaddr);
120 struct vm_struct *p; 122 struct vm_struct *p;
121 123
122 if (seg < P3SEG || seg >= P3_ADDR_MAX || is_pci_memaddr(vaddr)) 124 if (seg < P3SEG || vaddr >= P3_ADDR_MAX || is_pci_memaddr(vaddr))
123 return; 125 return;
124 126
125#ifdef CONFIG_32BIT 127#ifdef CONFIG_PMB
126 /* 128 /*
127 * Purge any PMB entries that may have been established for this 129 * Purge any PMB entries that may have been established for this
128 * mapping, then proceed with conventional VMA teardown. 130 * mapping, then proceed with conventional VMA teardown.
diff --git a/arch/sh/mm/pmb-fixed.c b/arch/sh/mm/pmb-fixed.c
new file mode 100644
index 000000000000..43c8eac4d8a1
--- /dev/null
+++ b/arch/sh/mm/pmb-fixed.c
@@ -0,0 +1,45 @@
1/*
2 * arch/sh/mm/fixed_pmb.c
3 *
4 * Copyright (C) 2009 Renesas Solutions Corp.
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.
9 */
10#include <linux/init.h>
11#include <linux/mm.h>
12#include <linux/io.h>
13#include <asm/mmu.h>
14#include <asm/mmu_context.h>
15
16static int __uses_jump_to_uncached fixed_pmb_init(void)
17{
18 int i;
19 unsigned long addr, data;
20
21 jump_to_uncached();
22
23 for (i = 0; i < PMB_ENTRY_MAX; i++) {
24 addr = PMB_DATA + (i << PMB_E_SHIFT);
25 data = ctrl_inl(addr);
26 if (!(data & PMB_V))
27 continue;
28
29 if (data & PMB_C) {
30#if defined(CONFIG_CACHE_WRITETHROUGH)
31 data |= PMB_WT;
32#elif defined(CONFIG_CACHE_WRITEBACK)
33 data &= ~PMB_WT;
34#else
35 data &= ~(PMB_C | PMB_WT);
36#endif
37 }
38 ctrl_outl(data, addr);
39 }
40
41 back_to_cached();
42
43 return 0;
44}
45arch_initcall(fixed_pmb_init);
diff --git a/arch/sh/mm/pmb.c b/arch/sh/mm/pmb.c
index 84241676265e..b1a714a92b14 100644
--- a/arch/sh/mm/pmb.c
+++ b/arch/sh/mm/pmb.c
@@ -15,6 +15,8 @@
15 */ 15 */
16#include <linux/init.h> 16#include <linux/init.h>
17#include <linux/kernel.h> 17#include <linux/kernel.h>
18#include <linux/sysdev.h>
19#include <linux/cpu.h>
18#include <linux/module.h> 20#include <linux/module.h>
19#include <linux/slab.h> 21#include <linux/slab.h>
20#include <linux/bitops.h> 22#include <linux/bitops.h>
@@ -402,3 +404,39 @@ static int __init pmb_debugfs_init(void)
402 return 0; 404 return 0;
403} 405}
404postcore_initcall(pmb_debugfs_init); 406postcore_initcall(pmb_debugfs_init);
407
408#ifdef CONFIG_PM
409static int pmb_sysdev_suspend(struct sys_device *dev, pm_message_t state)
410{
411 static pm_message_t prev_state;
412
413 /* Restore the PMB after a resume from hibernation */
414 if (state.event == PM_EVENT_ON &&
415 prev_state.event == PM_EVENT_FREEZE) {
416 struct pmb_entry *pmbe;
417 spin_lock_irq(&pmb_list_lock);
418 for (pmbe = pmb_list; pmbe; pmbe = pmbe->next)
419 set_pmb_entry(pmbe);
420 spin_unlock_irq(&pmb_list_lock);
421 }
422 prev_state = state;
423 return 0;
424}
425
426static int pmb_sysdev_resume(struct sys_device *dev)
427{
428 return pmb_sysdev_suspend(dev, PMSG_ON);
429}
430
431static struct sysdev_driver pmb_sysdev_driver = {
432 .suspend = pmb_sysdev_suspend,
433 .resume = pmb_sysdev_resume,
434};
435
436static int __init pmb_sysdev_init(void)
437{
438 return sysdev_driver_register(&cpu_sysdev_class, &pmb_sysdev_driver);
439}
440
441subsys_initcall(pmb_sysdev_init);
442#endif
diff --git a/arch/sh/mm/tlb-pteaex.c b/arch/sh/mm/tlb-pteaex.c
new file mode 100644
index 000000000000..2aab3ea934d7
--- /dev/null
+++ b/arch/sh/mm/tlb-pteaex.c
@@ -0,0 +1,96 @@
1/*
2 * arch/sh/mm/tlb-pteaex.c
3 *
4 * TLB operations for SH-X3 CPUs featuring PTE ASID Extensions.
5 *
6 * Copyright (C) 2009 Paul Mundt
7 *
8 * This file is subject to the terms and conditions of the GNU General Public
9 * License. See the file "COPYING" in the main directory of this archive
10 * for more details.
11 */
12#include <linux/kernel.h>
13#include <linux/mm.h>
14#include <linux/io.h>
15#include <asm/system.h>
16#include <asm/mmu_context.h>
17#include <asm/cacheflush.h>
18
19void update_mmu_cache(struct vm_area_struct * vma,
20 unsigned long address, pte_t pte)
21{
22 unsigned long flags;
23 unsigned long pteval;
24 unsigned long vpn;
25
26 /* Ptrace may call this routine. */
27 if (vma && current->active_mm != vma->vm_mm)
28 return;
29
30#ifndef CONFIG_CACHE_OFF
31 {
32 unsigned long pfn = pte_pfn(pte);
33
34 if (pfn_valid(pfn)) {
35 struct page *page = pfn_to_page(pfn);
36
37 if (!test_bit(PG_mapped, &page->flags)) {
38 unsigned long phys = pte_val(pte) & PTE_PHYS_MASK;
39 __flush_wback_region((void *)P1SEGADDR(phys),
40 PAGE_SIZE);
41 __set_bit(PG_mapped, &page->flags);
42 }
43 }
44 }
45#endif
46
47 local_irq_save(flags);
48
49 /* Set PTEH register */
50 vpn = address & MMU_VPN_MASK;
51 __raw_writel(vpn, MMU_PTEH);
52
53 /* Set PTEAEX */
54 __raw_writel(get_asid(), MMU_PTEAEX);
55
56 pteval = pte.pte_low;
57
58 /* Set PTEA register */
59#ifdef CONFIG_X2TLB
60 /*
61 * For the extended mode TLB this is trivial, only the ESZ and
62 * EPR bits need to be written out to PTEA, with the remainder of
63 * the protection bits (with the exception of the compat-mode SZ
64 * and PR bits, which are cleared) being written out in PTEL.
65 */
66 __raw_writel(pte.pte_high, MMU_PTEA);
67#endif
68
69 /* Set PTEL register */
70 pteval &= _PAGE_FLAGS_HARDWARE_MASK; /* drop software flags */
71#ifdef CONFIG_CACHE_WRITETHROUGH
72 pteval |= _PAGE_WT;
73#endif
74 /* conveniently, we want all the software flags to be 0 anyway */
75 __raw_writel(pteval, MMU_PTEL);
76
77 /* Load the TLB */
78 asm volatile("ldtlb": /* no output */ : /* no input */ : "memory");
79 local_irq_restore(flags);
80}
81
82/*
83 * While SH-X2 extended TLB mode splits out the memory-mapped I/UTLB
84 * data arrays, SH-X3 cores with PTEAEX split out the memory-mapped
85 * address arrays. In compat mode the second array is inaccessible, while
86 * in extended mode, the legacy 8-bit ASID field in address array 1 has
87 * undefined behaviour.
88 */
89void __uses_jump_to_uncached local_flush_tlb_one(unsigned long asid,
90 unsigned long page)
91{
92 jump_to_uncached();
93 __raw_writel(page, MMU_UTLB_ADDRESS_ARRAY | MMU_PAGE_ASSOC_BIT);
94 __raw_writel(asid, MMU_UTLB_ADDRESS_ARRAY2 | MMU_PAGE_ASSOC_BIT);
95 back_to_cached();
96}