Hyok S. Choi | b731c31 | 2006-09-26 17:37:50 +0900 | [diff] [blame] | 1 | /* |
| 2 | * linux/arch/arm/mm/arm740.S: utility functions for ARM740 |
| 3 | * |
| 4 | * Copyright (C) 2004-2006 Hyok S. Choi (hyok.choi@samsung.com) |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or modify |
| 7 | * it under the terms of the GNU General Public License version 2 as |
| 8 | * published by the Free Software Foundation. |
| 9 | * |
| 10 | */ |
| 11 | #include <linux/linkage.h> |
| 12 | #include <linux/init.h> |
| 13 | #include <asm/assembler.h> |
| 14 | #include <asm/asm-offsets.h> |
Russell King | 5ec9407 | 2008-09-07 19:15:31 +0100 | [diff] [blame] | 15 | #include <asm/hwcap.h> |
Hyok S. Choi | b731c31 | 2006-09-26 17:37:50 +0900 | [diff] [blame] | 16 | #include <asm/pgtable-hwdef.h> |
| 17 | #include <asm/pgtable.h> |
Hyok S. Choi | b731c31 | 2006-09-26 17:37:50 +0900 | [diff] [blame] | 18 | #include <asm/ptrace.h> |
| 19 | |
Dave Martin | 4cc1f0f | 2011-06-23 17:19:11 +0100 | [diff] [blame] | 20 | #include "proc-macros.S" |
| 21 | |
Hyok S. Choi | b731c31 | 2006-09-26 17:37:50 +0900 | [diff] [blame] | 22 | .text |
| 23 | /* |
| 24 | * cpu_arm740_proc_init() |
| 25 | * cpu_arm740_do_idle() |
| 26 | * cpu_arm740_dcache_clean_area() |
| 27 | * cpu_arm740_switch_mm() |
| 28 | * |
| 29 | * These are not required. |
| 30 | */ |
| 31 | ENTRY(cpu_arm740_proc_init) |
| 32 | ENTRY(cpu_arm740_do_idle) |
| 33 | ENTRY(cpu_arm740_dcache_clean_area) |
| 34 | ENTRY(cpu_arm740_switch_mm) |
Russell King | 6ebbf2c | 2014-06-30 16:29:12 +0100 | [diff] [blame] | 35 | ret lr |
Hyok S. Choi | b731c31 | 2006-09-26 17:37:50 +0900 | [diff] [blame] | 36 | |
| 37 | /* |
| 38 | * cpu_arm740_proc_fin() |
| 39 | */ |
| 40 | ENTRY(cpu_arm740_proc_fin) |
Hyok S. Choi | b731c31 | 2006-09-26 17:37:50 +0900 | [diff] [blame] | 41 | mrc p15, 0, r0, c1, c0, 0 |
| 42 | bic r0, r0, #0x3f000000 @ bank/f/lock/s |
| 43 | bic r0, r0, #0x0000000c @ w-buffer/cache |
| 44 | mcr p15, 0, r0, c1, c0, 0 @ disable caches |
Russell King | 6ebbf2c | 2014-06-30 16:29:12 +0100 | [diff] [blame] | 45 | ret lr |
Hyok S. Choi | b731c31 | 2006-09-26 17:37:50 +0900 | [diff] [blame] | 46 | |
| 47 | /* |
| 48 | * cpu_arm740_reset(loc) |
| 49 | * Params : r0 = address to jump to |
| 50 | * Notes : This sets up everything for a reset |
| 51 | */ |
Will Deacon | 1a4baaf | 2011-11-15 13:25:04 +0000 | [diff] [blame] | 52 | .pushsection .idmap.text, "ax" |
Hyok S. Choi | b731c31 | 2006-09-26 17:37:50 +0900 | [diff] [blame] | 53 | ENTRY(cpu_arm740_reset) |
| 54 | mov ip, #0 |
| 55 | mcr p15, 0, ip, c7, c0, 0 @ invalidate cache |
| 56 | mrc p15, 0, ip, c1, c0, 0 @ get ctrl register |
| 57 | bic ip, ip, #0x0000000c @ ............wc.. |
| 58 | mcr p15, 0, ip, c1, c0, 0 @ ctrl register |
Russell King | 6ebbf2c | 2014-06-30 16:29:12 +0100 | [diff] [blame] | 59 | ret r0 |
Will Deacon | 1a4baaf | 2011-11-15 13:25:04 +0000 | [diff] [blame] | 60 | ENDPROC(cpu_arm740_reset) |
| 61 | .popsection |
Hyok S. Choi | b731c31 | 2006-09-26 17:37:50 +0900 | [diff] [blame] | 62 | |
Hyok S. Choi | b731c31 | 2006-09-26 17:37:50 +0900 | [diff] [blame] | 63 | .type __arm740_setup, #function |
| 64 | __arm740_setup: |
| 65 | mov r0, #0 |
| 66 | mcr p15, 0, r0, c7, c0, 0 @ invalidate caches |
| 67 | |
| 68 | mcr p15, 0, r0, c6, c3 @ disable area 3~7 |
| 69 | mcr p15, 0, r0, c6, c4 |
| 70 | mcr p15, 0, r0, c6, c5 |
| 71 | mcr p15, 0, r0, c6, c6 |
| 72 | mcr p15, 0, r0, c6, c7 |
| 73 | |
| 74 | mov r0, #0x0000003F @ base = 0, size = 4GB |
| 75 | mcr p15, 0, r0, c6, c0 @ set area 0, default |
| 76 | |
| 77 | ldr r0, =(CONFIG_DRAM_BASE & 0xFFFFF000) @ base[31:12] of RAM |
Will Deacon | 3ef52f2 | 2013-01-22 10:37:51 +0000 | [diff] [blame] | 78 | ldr r3, =(CONFIG_DRAM_SIZE >> 12) @ size of RAM (must be >= 4KB) |
| 79 | mov r4, #10 @ 11 is the minimum (4KB) |
| 80 | 1: add r4, r4, #1 @ area size *= 2 |
| 81 | movs r3, r3, lsr #1 |
Hyok S. Choi | b731c31 | 2006-09-26 17:37:50 +0900 | [diff] [blame] | 82 | bne 1b @ count not zero r-shift |
Will Deacon | 3ef52f2 | 2013-01-22 10:37:51 +0000 | [diff] [blame] | 83 | orr r0, r0, r4, lsl #1 @ the area register value |
Hyok S. Choi | b731c31 | 2006-09-26 17:37:50 +0900 | [diff] [blame] | 84 | orr r0, r0, #1 @ set enable bit |
| 85 | mcr p15, 0, r0, c6, c1 @ set area 1, RAM |
| 86 | |
| 87 | ldr r0, =(CONFIG_FLASH_MEM_BASE & 0xFFFFF000) @ base[31:12] of FLASH |
Will Deacon | 3ef52f2 | 2013-01-22 10:37:51 +0000 | [diff] [blame] | 88 | ldr r3, =(CONFIG_FLASH_SIZE >> 12) @ size of FLASH (must be >= 4KB) |
| 89 | cmp r3, #0 |
| 90 | moveq r0, #0 |
| 91 | beq 2f |
| 92 | mov r4, #10 @ 11 is the minimum (4KB) |
| 93 | 1: add r4, r4, #1 @ area size *= 2 |
| 94 | movs r3, r3, lsr #1 |
Hyok S. Choi | b731c31 | 2006-09-26 17:37:50 +0900 | [diff] [blame] | 95 | bne 1b @ count not zero r-shift |
Will Deacon | 3ef52f2 | 2013-01-22 10:37:51 +0000 | [diff] [blame] | 96 | orr r0, r0, r4, lsl #1 @ the area register value |
Hyok S. Choi | b731c31 | 2006-09-26 17:37:50 +0900 | [diff] [blame] | 97 | orr r0, r0, #1 @ set enable bit |
Will Deacon | 3ef52f2 | 2013-01-22 10:37:51 +0000 | [diff] [blame] | 98 | 2: mcr p15, 0, r0, c6, c2 @ set area 2, ROM/FLASH |
Hyok S. Choi | b731c31 | 2006-09-26 17:37:50 +0900 | [diff] [blame] | 99 | |
| 100 | mov r0, #0x06 |
| 101 | mcr p15, 0, r0, c2, c0 @ Region 1&2 cacheable |
| 102 | #ifdef CONFIG_CPU_DCACHE_WRITETHROUGH |
| 103 | mov r0, #0x00 @ disable whole write buffer |
| 104 | #else |
| 105 | mov r0, #0x02 @ Region 1 write bufferred |
| 106 | #endif |
| 107 | mcr p15, 0, r0, c3, c0 |
| 108 | |
| 109 | mov r0, #0x10000 |
| 110 | sub r0, r0, #1 @ r0 = 0xffff |
| 111 | mcr p15, 0, r0, c5, c0 @ all read/write access |
| 112 | |
| 113 | mrc p15, 0, r0, c1, c0 @ get control register |
| 114 | bic r0, r0, #0x3F000000 @ set to standard caching mode |
| 115 | @ need some benchmark |
| 116 | orr r0, r0, #0x0000000d @ MPU/Cache/WB |
| 117 | |
Russell King | 6ebbf2c | 2014-06-30 16:29:12 +0100 | [diff] [blame] | 118 | ret lr |
Hyok S. Choi | b731c31 | 2006-09-26 17:37:50 +0900 | [diff] [blame] | 119 | |
| 120 | .size __arm740_setup, . - __arm740_setup |
| 121 | |
| 122 | __INITDATA |
| 123 | |
Dave Martin | 4cc1f0f | 2011-06-23 17:19:11 +0100 | [diff] [blame] | 124 | @ define struct processor (see <asm/proc-fns.h> and proc-macros.S) |
| 125 | define_processor_functions arm740, dabort=v4t_late_abort, pabort=legacy_pabort, nommu=1 |
Hyok S. Choi | b731c31 | 2006-09-26 17:37:50 +0900 | [diff] [blame] | 126 | |
| 127 | .section ".rodata" |
| 128 | |
Dave Martin | 4cc1f0f | 2011-06-23 17:19:11 +0100 | [diff] [blame] | 129 | string cpu_arch_name, "armv4" |
| 130 | string cpu_elf_name, "v4" |
| 131 | string cpu_arm740_name, "ARM740T" |
Hyok S. Choi | b731c31 | 2006-09-26 17:37:50 +0900 | [diff] [blame] | 132 | |
| 133 | .align |
| 134 | |
Ard Biesheuvel | bf35706 | 2015-03-18 07:29:32 +0100 | [diff] [blame^] | 135 | .section ".proc.info.init", #alloc |
Hyok S. Choi | b731c31 | 2006-09-26 17:37:50 +0900 | [diff] [blame] | 136 | .type __arm740_proc_info,#object |
| 137 | __arm740_proc_info: |
| 138 | .long 0x41807400 |
| 139 | .long 0xfffffff0 |
| 140 | .long 0 |
Will Deacon | 3ef52f2 | 2013-01-22 10:37:51 +0000 | [diff] [blame] | 141 | .long 0 |
Ard Biesheuvel | bf35706 | 2015-03-18 07:29:32 +0100 | [diff] [blame^] | 142 | initfn __arm740_setup, __arm740_proc_info |
Hyok S. Choi | b731c31 | 2006-09-26 17:37:50 +0900 | [diff] [blame] | 143 | .long cpu_arch_name |
| 144 | .long cpu_elf_name |
Will Deacon | 3ef52f2 | 2013-01-22 10:37:51 +0000 | [diff] [blame] | 145 | .long HWCAP_SWP | HWCAP_HALF | HWCAP_THUMB | HWCAP_26BIT |
Hyok S. Choi | b731c31 | 2006-09-26 17:37:50 +0900 | [diff] [blame] | 146 | .long cpu_arm740_name |
| 147 | .long arm740_processor_functions |
| 148 | .long 0 |
| 149 | .long 0 |
Will Deacon | 82d9b0d | 2013-01-15 12:07:40 +0000 | [diff] [blame] | 150 | .long v4_cache_fns @ cache model |
Hyok S. Choi | b731c31 | 2006-09-26 17:37:50 +0900 | [diff] [blame] | 151 | .size __arm740_proc_info, . - __arm740_proc_info |