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