1 /* SPDX-License-Identifier: GPL-2.0 */ << 2 /* 1 /* 3 * head.S - Common startup code for 68000 core 2 * head.S - Common startup code for 68000 core based CPU's 4 * 3 * 5 * 2012.10.21, Luis Alves <ljalvs@gmail.com>, S 4 * 2012.10.21, Luis Alves <ljalvs@gmail.com>, Single head.S file for all 6 * 68000 core based CPU's. Based o 5 * 68000 core based CPU's. Based on the sources from: 7 * Coldfire by Greg Ungerer <gerg@s 6 * Coldfire by Greg Ungerer <gerg@snapgear.com> 8 * 68328 by D. Jeff Dionne <jeff@ry 7 * 68328 by D. Jeff Dionne <jeff@ryeham.ee.ryerson.ca>, 9 * Kenneth Albanowski <kja 8 * Kenneth Albanowski <kjahds@kjahds.com>, 10 * The Silver Hammer Grou 9 * The Silver Hammer Group, Ltd. 11 * 10 * 12 */ 11 */ 13 12 14 #include <linux/linkage.h> 13 #include <linux/linkage.h> 15 #include <linux/init.h> 14 #include <linux/init.h> 16 #include <asm/asm-offsets.h> 15 #include <asm/asm-offsets.h> 17 #include <asm/thread_info.h> 16 #include <asm/thread_info.h> 18 17 19 18 20 /********************************************* 19 /***************************************************************************** 21 * UCSIMM and UCDIMM use CONFIG_MEMORY_RESERVE 20 * UCSIMM and UCDIMM use CONFIG_MEMORY_RESERVE to reserve some RAM 22 ********************************************* 21 *****************************************************************************/ 23 #ifdef CONFIG_MEMORY_RESERVE 22 #ifdef CONFIG_MEMORY_RESERVE 24 #define RAMEND (CONFIG_RAMBASE+CONFIG_RAMSIZE) 23 #define RAMEND (CONFIG_RAMBASE+CONFIG_RAMSIZE)-(CONFIG_MEMORY_RESERVE*0x100000) 25 #else 24 #else 26 #define RAMEND (CONFIG_RAMBASE+CONFIG_RAMSIZE) 25 #define RAMEND (CONFIG_RAMBASE+CONFIG_RAMSIZE) 27 #endif 26 #endif 28 /********************************************* 27 /*****************************************************************************/ 29 28 30 .global _start 29 .global _start 31 .global _rambase 30 .global _rambase 32 .global _ramvec 31 .global _ramvec 33 .global _ramstart 32 .global _ramstart 34 .global _ramend 33 .global _ramend 35 34 36 #if defined(CONFIG_PILOT) || defined(CONFIG_IN 35 #if defined(CONFIG_PILOT) || defined(CONFIG_INIT_LCD) 37 .global bootlogo_bits 36 .global bootlogo_bits 38 #endif 37 #endif 39 38 40 /* Defining DEBUG_HEAD_CODE, serial port in 68 39 /* Defining DEBUG_HEAD_CODE, serial port in 68x328 is inited */ 41 /* #define DEBUG_HEAD_CODE */ 40 /* #define DEBUG_HEAD_CODE */ 42 #undef DEBUG_HEAD_CODE 41 #undef DEBUG_HEAD_CODE 43 42 44 .data 43 .data 45 44 46 /********************************************* 45 /***************************************************************************** 47 * RAM setup pointers. Used by the kernel to d 46 * RAM setup pointers. Used by the kernel to determine RAM location and size. 48 ********************************************* 47 *****************************************************************************/ 49 48 50 _rambase: 49 _rambase: 51 .long 0 50 .long 0 52 _ramvec: 51 _ramvec: 53 .long 0 52 .long 0 54 _ramstart: 53 _ramstart: 55 .long 0 54 .long 0 56 _ramend: 55 _ramend: 57 .long 0 56 .long 0 58 57 59 __HEAD 58 __HEAD 60 59 61 /********************************************* 60 /***************************************************************************** 62 * Entry point, where all begins! 61 * Entry point, where all begins! 63 ********************************************* 62 *****************************************************************************/ 64 63 65 _start: 64 _start: 66 65 67 /* Pilot need this specific signature at the s 66 /* Pilot need this specific signature at the start of ROM */ 68 #ifdef CONFIG_PILOT 67 #ifdef CONFIG_PILOT 69 .byte 0x4e, 0xfa, 0x00, 0x0a 68 .byte 0x4e, 0xfa, 0x00, 0x0a /* bra opcode (jmp 10 bytes) */ 70 .byte 'b', 'o', 'o', 't' 69 .byte 'b', 'o', 'o', 't' 71 .word 10000 70 .word 10000 72 nop 71 nop 73 moveq #0, %d0 72 moveq #0, %d0 74 movew %d0, 0xfffff618 73 movew %d0, 0xfffff618 /* Watchdog off */ 75 movel #0x00011f07, 0xfffff114 74 movel #0x00011f07, 0xfffff114 /* CS A1 Mask */ 76 #endif /* CONFIG_PILOT */ 75 #endif /* CONFIG_PILOT */ 77 76 78 movew #0x2700, %sr 77 movew #0x2700, %sr /* disable all interrupts */ 79 78 80 /********************************************* 79 /***************************************************************************** 81 * Setup PLL and wait for it to settle (in 68x 80 * Setup PLL and wait for it to settle (in 68x328 cpu's). 82 * Also, if enabled, init serial port. 81 * Also, if enabled, init serial port. 83 ********************************************* 82 *****************************************************************************/ 84 #if defined(CONFIG_M68328) || \ 83 #if defined(CONFIG_M68328) || \ 85 defined(CONFIG_M68EZ328) || \ 84 defined(CONFIG_M68EZ328) || \ 86 defined(CONFIG_M68VZ328) 85 defined(CONFIG_M68VZ328) 87 86 88 /* Serial port setup. Should only be needed if 87 /* Serial port setup. Should only be needed if debugging this startup code. */ 89 #ifdef DEBUG_HEAD_CODE 88 #ifdef DEBUG_HEAD_CODE 90 movew #0x0800, 0xfffff906 89 movew #0x0800, 0xfffff906 /* Ignore CTS */ 91 movew #0x010b, 0xfffff902 90 movew #0x010b, 0xfffff902 /* BAUD to 9600 */ 92 movew #0xe100, 0xfffff900 91 movew #0xe100, 0xfffff900 /* enable */ 93 #endif /* DEBUG_HEAD */ 92 #endif /* DEBUG_HEAD */ 94 93 95 #ifdef CONFIG_PILOT 94 #ifdef CONFIG_PILOT 96 movew #0x2410, 0xfffff200 95 movew #0x2410, 0xfffff200 /* PLLCR */ 97 #else 96 #else 98 movew #0x2400, 0xfffff200 97 movew #0x2400, 0xfffff200 /* PLLCR */ 99 #endif 98 #endif 100 movew #0x0123, 0xfffff202 99 movew #0x0123, 0xfffff202 /* PLLFSR */ 101 moveq #0, %d0 100 moveq #0, %d0 102 movew #16384, %d0 101 movew #16384, %d0 /* PLL settle wait loop */ 103 _pll_settle: 102 _pll_settle: 104 subw #1, %d0 103 subw #1, %d0 105 bne _pll_settle 104 bne _pll_settle 106 #endif /* CONFIG_M68x328 */ 105 #endif /* CONFIG_M68x328 */ 107 106 108 107 109 /********************************************* 108 /***************************************************************************** 110 * If running kernel from ROM some specific in 109 * If running kernel from ROM some specific initialization has to be done. 111 * (Assuming that everything is already init'e 110 * (Assuming that everything is already init'ed when running from RAM) 112 ********************************************* 111 *****************************************************************************/ 113 #ifdef CONFIG_ROMKERNEL 112 #ifdef CONFIG_ROMKERNEL 114 113 115 /********************************************* 114 /***************************************************************************** 116 * Init chip registers (uCsimm specific) 115 * Init chip registers (uCsimm specific) 117 ********************************************* 116 *****************************************************************************/ 118 #ifdef CONFIG_UCSIMM 117 #ifdef CONFIG_UCSIMM 119 moveb #0x00, 0xfffffb0b /* Wat 118 moveb #0x00, 0xfffffb0b /* Watchdog off */ 120 moveb #0x10, 0xfffff000 /* SCR 119 moveb #0x10, 0xfffff000 /* SCR */ 121 moveb #0x00, 0xfffff40b /* ena 120 moveb #0x00, 0xfffff40b /* enable chip select */ 122 moveb #0x00, 0xfffff423 /* ena 121 moveb #0x00, 0xfffff423 /* enable /DWE */ 123 moveb #0x08, 0xfffffd0d /* dis 122 moveb #0x08, 0xfffffd0d /* disable hardmap */ 124 moveb #0x07, 0xfffffd0e /* lev 123 moveb #0x07, 0xfffffd0e /* level 7 interrupt clear */ 125 movew #0x8600, 0xfffff100 /* FLA 124 movew #0x8600, 0xfffff100 /* FLASH at 0x10c00000 */ 126 movew #0x018b, 0xfffff110 /* 2Me 125 movew #0x018b, 0xfffff110 /* 2Meg, enable, 0ws */ 127 movew #0x8f00, 0xfffffc00 /* DRA 126 movew #0x8f00, 0xfffffc00 /* DRAM configuration */ 128 movew #0x9667, 0xfffffc02 /* DRA 127 movew #0x9667, 0xfffffc02 /* DRAM control */ 129 movew #0x0000, 0xfffff106 /* DRA 128 movew #0x0000, 0xfffff106 /* DRAM at 0x00000000 */ 130 movew #0x068f, 0xfffff116 /* 8Me 129 movew #0x068f, 0xfffff116 /* 8Meg, enable, 0ws */ 131 moveb #0x40, 0xfffff300 /* IVR 130 moveb #0x40, 0xfffff300 /* IVR */ 132 movel #0x007FFFFF, %d0 /* IMR 131 movel #0x007FFFFF, %d0 /* IMR */ 133 movel %d0, 0xfffff304 132 movel %d0, 0xfffff304 134 moveb 0xfffff42b, %d0 133 moveb 0xfffff42b, %d0 135 andb #0xe0, %d0 134 andb #0xe0, %d0 136 moveb %d0, 0xfffff42b 135 moveb %d0, 0xfffff42b 137 #endif 136 #endif 138 137 139 /********************************************* 138 /***************************************************************************** 140 * Init LCD controller. 139 * Init LCD controller. 141 * (Assuming that LCD controller is already in 140 * (Assuming that LCD controller is already init'ed when running from RAM) 142 ********************************************* 141 *****************************************************************************/ 143 #ifdef CONFIG_INIT_LCD 142 #ifdef CONFIG_INIT_LCD 144 #ifdef CONFIG_PILOT 143 #ifdef CONFIG_PILOT 145 moveb #0, 0xfffffA27 144 moveb #0, 0xfffffA27 /* LCKCON */ 146 movel #_start, 0xfffffA00 145 movel #_start, 0xfffffA00 /* LSSA */ 147 moveb #0xa, 0xfffffA05 146 moveb #0xa, 0xfffffA05 /* LVPW */ 148 movew #0x9f, 0xFFFFFa08 147 movew #0x9f, 0xFFFFFa08 /* LXMAX */ 149 movew #0x9f, 0xFFFFFa0a 148 movew #0x9f, 0xFFFFFa0a /* LYMAX */ 150 moveb #9, 0xfffffa29 149 moveb #9, 0xfffffa29 /* LBAR */ 151 moveb #0, 0xfffffa25 150 moveb #0, 0xfffffa25 /* LPXCD */ 152 moveb #0x04, 0xFFFFFa20 151 moveb #0x04, 0xFFFFFa20 /* LPICF */ 153 moveb #0x58, 0xfffffA27 152 moveb #0x58, 0xfffffA27 /* LCKCON */ 154 moveb #0x85, 0xfffff429 153 moveb #0x85, 0xfffff429 /* PFDATA */ 155 moveb #0xd8, 0xfffffA27 154 moveb #0xd8, 0xfffffA27 /* LCKCON */ 156 moveb #0xc5, 0xfffff429 155 moveb #0xc5, 0xfffff429 /* PFDATA */ 157 moveb #0xd5, 0xfffff429 156 moveb #0xd5, 0xfffff429 /* PFDATA */ 158 movel #bootlogo_bits, 0xFFFFFA00 157 movel #bootlogo_bits, 0xFFFFFA00 /* LSSA */ 159 moveb #10, 0xFFFFFA05 158 moveb #10, 0xFFFFFA05 /* LVPW */ 160 movew #160, 0xFFFFFA08 159 movew #160, 0xFFFFFA08 /* LXMAX */ 161 movew #160, 0xFFFFFA0A 160 movew #160, 0xFFFFFA0A /* LYMAX */ 162 #else /* CONFIG_PILOT */ 161 #else /* CONFIG_PILOT */ 163 movel #bootlogo_bits, 0xfffffA00 162 movel #bootlogo_bits, 0xfffffA00 /* LSSA */ 164 moveb #0x28, 0xfffffA05 163 moveb #0x28, 0xfffffA05 /* LVPW */ 165 movew #0x280, 0xFFFFFa08 164 movew #0x280, 0xFFFFFa08 /* LXMAX */ 166 movew #0x1df, 0xFFFFFa0a 165 movew #0x1df, 0xFFFFFa0a /* LYMAX */ 167 moveb #0, 0xfffffa29 166 moveb #0, 0xfffffa29 /* LBAR */ 168 moveb #0, 0xfffffa25 167 moveb #0, 0xfffffa25 /* LPXCD */ 169 moveb #0x08, 0xFFFFFa20 168 moveb #0x08, 0xFFFFFa20 /* LPICF */ 170 moveb #0x01, 0xFFFFFA21 169 moveb #0x01, 0xFFFFFA21 /* -ve pol */ 171 moveb #0x81, 0xfffffA27 170 moveb #0x81, 0xfffffA27 /* LCKCON */ 172 movew #0xff00, 0xfffff412 171 movew #0xff00, 0xfffff412 /* LCD pins */ 173 #endif /* CONFIG_PILOT */ 172 #endif /* CONFIG_PILOT */ 174 #endif /* CONFIG_INIT_LCD */ 173 #endif /* CONFIG_INIT_LCD */ 175 174 176 /********************************************* 175 /***************************************************************************** 177 * Kernel is running from FLASH/ROM (XIP) 176 * Kernel is running from FLASH/ROM (XIP) 178 * Copy init text & data to RAM 177 * Copy init text & data to RAM 179 ********************************************* 178 *****************************************************************************/ 180 moveal #_etext, %a0 179 moveal #_etext, %a0 181 moveal #_sdata, %a1 180 moveal #_sdata, %a1 182 moveal #__bss_start, %a2 181 moveal #__bss_start, %a2 183 _copy_initmem: 182 _copy_initmem: 184 movel %a0@+, %a1@+ 183 movel %a0@+, %a1@+ 185 cmpal %a1, %a2 184 cmpal %a1, %a2 186 bhi _copy_initmem 185 bhi _copy_initmem 187 #endif /* CONFIG_ROMKERNEL */ 186 #endif /* CONFIG_ROMKERNEL */ 188 187 189 /********************************************* 188 /***************************************************************************** 190 * Setup basic memory information for kernel 189 * Setup basic memory information for kernel 191 ********************************************* 190 *****************************************************************************/ 192 movel #CONFIG_VECTORBASE,_ramvec 191 movel #CONFIG_VECTORBASE,_ramvec /* set vector base location */ 193 movel #CONFIG_RAMBASE,_rambase 192 movel #CONFIG_RAMBASE,_rambase /* set the base of RAM */ 194 movel #RAMEND, _ramend 193 movel #RAMEND, _ramend /* set end ram addr */ 195 lea __bss_stop,%a1 194 lea __bss_stop,%a1 196 movel %a1,_ramstart 195 movel %a1,_ramstart 197 196 198 /********************************************* 197 /***************************************************************************** 199 * If the kernel is in RAM, move romfs to righ 198 * If the kernel is in RAM, move romfs to right above bss and 200 * adjust _ramstart to where romfs ends. 199 * adjust _ramstart to where romfs ends. 201 * 200 * 202 * (Do this only if CONFIG_MTD_UCLINUX is true 201 * (Do this only if CONFIG_MTD_UCLINUX is true) 203 ********************************************* 202 *****************************************************************************/ 204 203 205 #if defined(CONFIG_ROMFS_FS) && defined(CONFIG 204 #if defined(CONFIG_ROMFS_FS) && defined(CONFIG_RAMKERNEL) && \ 206 defined(CONFIG_MTD_UCLINUX) 205 defined(CONFIG_MTD_UCLINUX) 207 lea __bss_start, %a0 206 lea __bss_start, %a0 /* get start of bss */ 208 lea __bss_stop, %a1 207 lea __bss_stop, %a1 /* set up destination */ 209 movel %a0, %a2 208 movel %a0, %a2 /* copy of bss start */ 210 209 211 movel 8(%a0), %d0 210 movel 8(%a0), %d0 /* get size of ROMFS */ 212 addql #8, %d0 211 addql #8, %d0 /* allow for rounding */ 213 andl #0xfffffffc, %d0 212 andl #0xfffffffc, %d0 /* whole words */ 214 213 215 addl %d0, %a0 214 addl %d0, %a0 /* copy from end */ 216 addl %d0, %a1 215 addl %d0, %a1 /* copy from end */ 217 movel %a1, _ramstart 216 movel %a1, _ramstart /* set start of ram */ 218 _copy_romfs: 217 _copy_romfs: 219 movel -(%a0), -(%a1) 218 movel -(%a0), -(%a1) /* copy dword */ 220 cmpl %a0, %a2 219 cmpl %a0, %a2 /* check if at end */ 221 bne _copy_romfs 220 bne _copy_romfs 222 #endif /* CONFIG_ROMFS_FS && CONFIG_RAMKERNEL 221 #endif /* CONFIG_ROMFS_FS && CONFIG_RAMKERNEL && CONFIG_MTD_UCLINUX */ 223 222 224 /********************************************* 223 /***************************************************************************** 225 * Clear bss region 224 * Clear bss region 226 ********************************************* 225 *****************************************************************************/ 227 lea __bss_start, %a0 226 lea __bss_start, %a0 /* get start of bss */ 228 lea __bss_stop, %a1 227 lea __bss_stop, %a1 /* get end of bss */ 229 _clear_bss: 228 _clear_bss: 230 movel #0, (%a0)+ 229 movel #0, (%a0)+ /* clear each word */ 231 cmpl %a0, %a1 230 cmpl %a0, %a1 /* check if at end */ 232 bne _clear_bss 231 bne _clear_bss 233 232 234 /********************************************* 233 /***************************************************************************** 235 * Load the current task pointer and stack. 234 * Load the current task pointer and stack. 236 ********************************************* 235 *****************************************************************************/ 237 lea init_thread_union,%a0 236 lea init_thread_union,%a0 238 lea THREAD_SIZE(%a0),%sp 237 lea THREAD_SIZE(%a0),%sp 239 jsr start_kernel 238 jsr start_kernel /* start Linux kernel */ 240 _exit: 239 _exit: 241 jmp _exit 240 jmp _exit /* should never get here */
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.