blob: 94641c420b3fbf351823f06ecb027d306142cdd7 [file] [log] [blame]
David Howellsb920de12008-02-08 04:19:31 -08001/* MN103E010 Processor initialisation
2 *
3 * Copyright (C) 2007 Red Hat, Inc. All Rights Reserved.
4 * Written by David Howells (dhowells@redhat.com)
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public Licence
8 * as published by the Free Software Foundation; either version
9 * 2 of the Licence, or (at your option) any later version.
10 */
11#include <linux/kernel.h>
Arnd Bergmann7ee94212016-05-30 20:57:54 +020012#include <asm/cacheflush.h>
Akira Takeuchi278d91c2010-10-27 17:28:52 +010013#include <asm/fpu.h>
Arnd Bergmann7ee94212016-05-30 20:57:54 +020014#include <asm/irq.h>
David Howellsb920de12008-02-08 04:19:31 -080015#include <asm/rtc.h>
Akira Takeuchi368dd5a2010-10-27 17:28:55 +010016#include <asm/busctl-regs.h>
David Howellsb920de12008-02-08 04:19:31 -080017
18/*
19 * initialise the on-silicon processor peripherals
20 */
21asmlinkage void __init processor_init(void)
22{
23 int loop;
24
25 /* set up the exception table first */
26 for (loop = 0x000; loop < 0x400; loop += 8)
27 __set_intr_stub(loop, __common_exception);
28
29 __set_intr_stub(EXCEP_ITLBMISS, itlb_miss);
30 __set_intr_stub(EXCEP_DTLBMISS, dtlb_miss);
31 __set_intr_stub(EXCEP_IAERROR, itlb_aerror);
32 __set_intr_stub(EXCEP_DAERROR, dtlb_aerror);
33 __set_intr_stub(EXCEP_BUSERROR, raw_bus_error);
34 __set_intr_stub(EXCEP_DOUBLE_FAULT, double_fault);
Akira Takeuchi278d91c2010-10-27 17:28:52 +010035 __set_intr_stub(EXCEP_FPU_DISABLED, fpu_disabled);
David Howellsb920de12008-02-08 04:19:31 -080036 __set_intr_stub(EXCEP_SYSCALL0, system_call);
37
38 __set_intr_stub(EXCEP_NMI, nmi_handler);
39 __set_intr_stub(EXCEP_WDT, nmi_handler);
40 __set_intr_stub(EXCEP_IRQ_LEVEL0, irq_handler);
41 __set_intr_stub(EXCEP_IRQ_LEVEL1, irq_handler);
42 __set_intr_stub(EXCEP_IRQ_LEVEL2, irq_handler);
43 __set_intr_stub(EXCEP_IRQ_LEVEL3, irq_handler);
44 __set_intr_stub(EXCEP_IRQ_LEVEL4, irq_handler);
45 __set_intr_stub(EXCEP_IRQ_LEVEL5, irq_handler);
46 __set_intr_stub(EXCEP_IRQ_LEVEL6, irq_handler);
47
48 IVAR0 = EXCEP_IRQ_LEVEL0;
49 IVAR1 = EXCEP_IRQ_LEVEL1;
50 IVAR2 = EXCEP_IRQ_LEVEL2;
51 IVAR3 = EXCEP_IRQ_LEVEL3;
52 IVAR4 = EXCEP_IRQ_LEVEL4;
53 IVAR5 = EXCEP_IRQ_LEVEL5;
54 IVAR6 = EXCEP_IRQ_LEVEL6;
55
56 mn10300_dcache_flush_inv();
57 mn10300_icache_inv();
58
59 /* disable all interrupts and set to priority 6 (lowest) */
60 for (loop = 0; loop < NR_IRQS; loop++)
61 GxICR(loop) = GxICR_LEVEL_6 | GxICR_DETECT;
62
63 /* clear the timers */
64 TM0MD = 0;
65 TM1MD = 0;
66 TM2MD = 0;
67 TM3MD = 0;
68 TM4MD = 0;
69 TM5MD = 0;
70 TM6MD = 0;
71 TM6MDA = 0;
72 TM6MDB = 0;
73 TM7MD = 0;
74 TM8MD = 0;
75 TM9MD = 0;
76 TM10MD = 0;
77 TM11MD = 0;
78
79 calibrate_clock();
80}
Akira Takeuchi368dd5a2010-10-27 17:28:55 +010081
82/*
83 * determine the memory size and base from the memory controller regs
84 */
85void __init get_mem_info(unsigned long *mem_base, unsigned long *mem_size)
86{
87 unsigned long base, size;
88
89 *mem_base = 0;
90 *mem_size = 0;
91
92 base = SDBASE(0);
93 if (base & SDBASE_CE) {
94 size = (base & SDBASE_CBAM) << SDBASE_CBAM_SHIFT;
95 size = ~size + 1;
96 base &= SDBASE_CBA;
97
98 printk(KERN_INFO "SDRAM[0]: %luMb @%08lx\n", size >> 20, base);
99 *mem_size += size;
100 *mem_base = base;
101 }
102
103 base = SDBASE(1);
104 if (base & SDBASE_CE) {
105 size = (base & SDBASE_CBAM) << SDBASE_CBAM_SHIFT;
106 size = ~size + 1;
107 base &= SDBASE_CBA;
108
109 printk(KERN_INFO "SDRAM[1]: %luMb @%08lx\n", size >> 20, base);
110 *mem_size += size;
111 if (*mem_base == 0)
112 *mem_base = base;
113 }
114}