/* SPDX-License-Identifier: GPL-2.0 */1/*2* head.S - Common startup code for 68000 core based CPU's3*4* 2012.10.21, Luis Alves <[email protected]>, Single head.S file for all5* 68000 core based CPU's. Based on the sources from:6* Coldfire by Greg Ungerer <[email protected]>7* 68328 by D. Jeff Dionne <[email protected]>,8* Kenneth Albanowski <[email protected]>,9* The Silver Hammer Group, Ltd.10*11*/1213#include <linux/linkage.h>14#include <linux/init.h>15#include <asm/asm-offsets.h>16#include <asm/thread_info.h>171819/*****************************************************************************20* UCSIMM and UCDIMM use CONFIG_MEMORY_RESERVE to reserve some RAM21*****************************************************************************/22#ifdef CONFIG_MEMORY_RESERVE23#define RAMEND (CONFIG_RAMBASE+CONFIG_RAMSIZE)-(CONFIG_MEMORY_RESERVE*0x100000)24#else25#define RAMEND (CONFIG_RAMBASE+CONFIG_RAMSIZE)26#endif27/*****************************************************************************/2829.global _start30.global _rambase31.global _ramvec32.global _ramstart33.global _ramend3435#if defined(CONFIG_PILOT) || defined(CONFIG_INIT_LCD)36.global bootlogo_bits37#endif3839/* Defining DEBUG_HEAD_CODE, serial port in 68x328 is inited */40/* #define DEBUG_HEAD_CODE */41#undef DEBUG_HEAD_CODE4243.data4445/*****************************************************************************46* RAM setup pointers. Used by the kernel to determine RAM location and size.47*****************************************************************************/4849_rambase:50.long 051_ramvec:52.long 053_ramstart:54.long 055_ramend:56.long 05758__HEAD5960/*****************************************************************************61* Entry point, where all begins!62*****************************************************************************/6364_start:6566/* Pilot need this specific signature at the start of ROM */67#ifdef CONFIG_PILOT68.byte 0x4e, 0xfa, 0x00, 0x0a /* bra opcode (jmp 10 bytes) */69.byte 'b', 'o', 'o', 't'70.word 1000071nop72moveq #0, %d073movew %d0, 0xfffff618 /* Watchdog off */74movel #0x00011f07, 0xfffff114 /* CS A1 Mask */75#endif /* CONFIG_PILOT */7677movew #0x2700, %sr /* disable all interrupts */7879/*****************************************************************************80* Setup PLL and wait for it to settle (in 68x328 cpu's).81* Also, if enabled, init serial port.82*****************************************************************************/83#if defined(CONFIG_M68328) || \84defined(CONFIG_M68EZ328) || \85defined(CONFIG_M68VZ328)8687/* Serial port setup. Should only be needed if debugging this startup code. */88#ifdef DEBUG_HEAD_CODE89movew #0x0800, 0xfffff906 /* Ignore CTS */90movew #0x010b, 0xfffff902 /* BAUD to 9600 */91movew #0xe100, 0xfffff900 /* enable */92#endif /* DEBUG_HEAD */9394#ifdef CONFIG_PILOT95movew #0x2410, 0xfffff200 /* PLLCR */96#else97movew #0x2400, 0xfffff200 /* PLLCR */98#endif99movew #0x0123, 0xfffff202 /* PLLFSR */100moveq #0, %d0101movew #16384, %d0 /* PLL settle wait loop */102_pll_settle:103subw #1, %d0104bne _pll_settle105#endif /* CONFIG_M68x328 */106107108/*****************************************************************************109* If running kernel from ROM some specific initialization has to be done.110* (Assuming that everything is already init'ed when running from RAM)111*****************************************************************************/112#ifdef CONFIG_ROMKERNEL113114/*****************************************************************************115* Init chip registers (uCsimm specific)116*****************************************************************************/117#ifdef CONFIG_UCSIMM118moveb #0x00, 0xfffffb0b /* Watchdog off */119moveb #0x10, 0xfffff000 /* SCR */120moveb #0x00, 0xfffff40b /* enable chip select */121moveb #0x00, 0xfffff423 /* enable /DWE */122moveb #0x08, 0xfffffd0d /* disable hardmap */123moveb #0x07, 0xfffffd0e /* level 7 interrupt clear */124movew #0x8600, 0xfffff100 /* FLASH at 0x10c00000 */125movew #0x018b, 0xfffff110 /* 2Meg, enable, 0ws */126movew #0x8f00, 0xfffffc00 /* DRAM configuration */127movew #0x9667, 0xfffffc02 /* DRAM control */128movew #0x0000, 0xfffff106 /* DRAM at 0x00000000 */129movew #0x068f, 0xfffff116 /* 8Meg, enable, 0ws */130moveb #0x40, 0xfffff300 /* IVR */131movel #0x007FFFFF, %d0 /* IMR */132movel %d0, 0xfffff304133moveb 0xfffff42b, %d0134andb #0xe0, %d0135moveb %d0, 0xfffff42b136#endif137138/*****************************************************************************139* Init LCD controller.140* (Assuming that LCD controller is already init'ed when running from RAM)141*****************************************************************************/142#ifdef CONFIG_INIT_LCD143#ifdef CONFIG_PILOT144moveb #0, 0xfffffA27 /* LCKCON */145movel #_start, 0xfffffA00 /* LSSA */146moveb #0xa, 0xfffffA05 /* LVPW */147movew #0x9f, 0xFFFFFa08 /* LXMAX */148movew #0x9f, 0xFFFFFa0a /* LYMAX */149moveb #9, 0xfffffa29 /* LBAR */150moveb #0, 0xfffffa25 /* LPXCD */151moveb #0x04, 0xFFFFFa20 /* LPICF */152moveb #0x58, 0xfffffA27 /* LCKCON */153moveb #0x85, 0xfffff429 /* PFDATA */154moveb #0xd8, 0xfffffA27 /* LCKCON */155moveb #0xc5, 0xfffff429 /* PFDATA */156moveb #0xd5, 0xfffff429 /* PFDATA */157movel #bootlogo_bits, 0xFFFFFA00 /* LSSA */158moveb #10, 0xFFFFFA05 /* LVPW */159movew #160, 0xFFFFFA08 /* LXMAX */160movew #160, 0xFFFFFA0A /* LYMAX */161#else /* CONFIG_PILOT */162movel #bootlogo_bits, 0xfffffA00 /* LSSA */163moveb #0x28, 0xfffffA05 /* LVPW */164movew #0x280, 0xFFFFFa08 /* LXMAX */165movew #0x1df, 0xFFFFFa0a /* LYMAX */166moveb #0, 0xfffffa29 /* LBAR */167moveb #0, 0xfffffa25 /* LPXCD */168moveb #0x08, 0xFFFFFa20 /* LPICF */169moveb #0x01, 0xFFFFFA21 /* -ve pol */170moveb #0x81, 0xfffffA27 /* LCKCON */171movew #0xff00, 0xfffff412 /* LCD pins */172#endif /* CONFIG_PILOT */173#endif /* CONFIG_INIT_LCD */174175/*****************************************************************************176* Kernel is running from FLASH/ROM (XIP)177* Copy init text & data to RAM178*****************************************************************************/179moveal #_etext, %a0180moveal #_sdata, %a1181moveal #__bss_start, %a2182_copy_initmem:183movel %a0@+, %a1@+184cmpal %a1, %a2185bhi _copy_initmem186#endif /* CONFIG_ROMKERNEL */187188/*****************************************************************************189* Setup basic memory information for kernel190*****************************************************************************/191movel #CONFIG_VECTORBASE,_ramvec /* set vector base location */192movel #CONFIG_RAMBASE,_rambase /* set the base of RAM */193movel #RAMEND, _ramend /* set end ram addr */194lea __bss_stop,%a1195movel %a1,_ramstart196197/*****************************************************************************198* If the kernel is in RAM, move romfs to right above bss and199* adjust _ramstart to where romfs ends.200*201* (Do this only if CONFIG_MTD_UCLINUX is true)202*****************************************************************************/203204#if defined(CONFIG_ROMFS_FS) && defined(CONFIG_RAMKERNEL) && \205defined(CONFIG_MTD_UCLINUX)206lea __bss_start, %a0 /* get start of bss */207lea __bss_stop, %a1 /* set up destination */208movel %a0, %a2 /* copy of bss start */209210movel 8(%a0), %d0 /* get size of ROMFS */211addql #8, %d0 /* allow for rounding */212andl #0xfffffffc, %d0 /* whole words */213214addl %d0, %a0 /* copy from end */215addl %d0, %a1 /* copy from end */216movel %a1, _ramstart /* set start of ram */217_copy_romfs:218movel -(%a0), -(%a1) /* copy dword */219cmpl %a0, %a2 /* check if at end */220bne _copy_romfs221#endif /* CONFIG_ROMFS_FS && CONFIG_RAMKERNEL && CONFIG_MTD_UCLINUX */222223/*****************************************************************************224* Clear bss region225*****************************************************************************/226lea __bss_start, %a0 /* get start of bss */227lea __bss_stop, %a1 /* get end of bss */228_clear_bss:229movel #0, (%a0)+ /* clear each word */230cmpl %a0, %a1 /* check if at end */231bne _clear_bss232233/*****************************************************************************234* Load the current task pointer and stack.235*****************************************************************************/236lea init_thread_union,%a0237lea THREAD_SIZE(%a0),%sp238jsr start_kernel /* start Linux kernel */239_exit:240jmp _exit /* should never get here */241242243