13 #include <generated/utsrelease.h>
14 #include <linux/kernel.h>
15 #include <linux/sched.h>
23 #include <linux/errno.h>
24 #include <linux/string.h>
29 #include <linux/serial.h>
30 #include <linux/serial_core.h>
34 #include <asm/setup.h>
36 #include <asm/sections.h>
37 #include <asm/pgalloc.h>
38 #include <asm/busctl-regs.h>
39 #include <asm/serial-regs.h>
40 #include <asm/timer-regs.h>
45 #include <asm/gdb-stub.h>
48 #ifdef CONFIG_BLK_DEV_INITRD
49 #include <asm/pgtable.h>
54 #ifdef CONFIG_MB93090_MB00
55 static void __init mb93090_display(
void);
58 static void __init setup_linux_memory(
void);
60 static void __init setup_uclinux_memory(
void);
63 #ifdef CONFIG_MB93090_MB00
64 static char __initdata mb93090_banner[] =
"FJ/RH FR-V Linux";
65 static char __initdata mb93090_version[] = UTS_RELEASE;
67 int __nongprelbss mb93090_mb00_detected;
84 static const char *__nongprelbss cpu_series;
85 static const char *__nongprelbss cpu_core;
86 static const char *__nongprelbss cpu_silicon;
87 static const char *__nongprelbss cpu_mmu;
88 static const char *__nongprelbss cpu_system;
89 static const char *__nongprelbss cpu_board1;
90 static const char *__nongprelbss cpu_board2;
92 static unsigned long __nongprelbss cpu_psr_all;
93 static unsigned long __nongprelbss cpu_hsr0_all;
115 #define __pminitconst
117 #define __pminit __init
118 #define __pminitdata __initdata
119 #define __pminitconst __initconst
126 #define _frac(N,D) ((N)<<4 | (D))
127 #define _x0_16 _frac(1,6)
128 #define _x0_25 _frac(1,4)
129 #define _x0_33 _frac(1,3)
130 #define _x0_375 _frac(3,8)
131 #define _x0_5 _frac(1,2)
132 #define _x0_66 _frac(2,3)
133 #define _x0_75 _frac(3,4)
134 #define _x1 _frac(1,1)
135 #define _x1_5 _frac(3,2)
136 #define _x2 _frac(2,1)
137 #define _x3 _frac(3,1)
138 #define _x4 _frac(4,1)
139 #define _x4_5 _frac(9,2)
140 #define _x6 _frac(6,1)
141 #define _x8 _frac(8,1)
142 #define _x9 _frac(9,1)
148 int __nongprelbss clock_cmodes_permitted;
149 unsigned long __nongprelbss clock_bits_settable;
176 #define CLOCK_CMODES_PERMITTED_FR405 0xd31f
211 static void __init printk_xampr(
unsigned long ampr,
unsigned long amlr,
char i_d,
int n)
213 unsigned long phys, virt, cxn,
size;
216 virt = amlr & 0xffffc000;
219 virt = ampr & 0xffffc000;
223 size = 1 << (((ampr &
xAMPRx_SS) >> 4) + 17);
225 printk(
"%cAMPR%d: va %08lx-%08lx [pa %08lx] %c%c%c%c [cxn:%04lx]\n",
227 virt, virt + size - 1,
242 static void __init dump_memory_map(
void)
285 printk(
"Master: %08lx-%08lx CR=%08lx\n",
290 for (loop = 1; loop <= 7; loop++) {
292 printk(
"CS#%d: %08lx-%08lx %c%c%c%c%c%c%c%c%c\n",
295 lcr & 0x80000000 ?
'r' :
'-',
296 lcr & 0x40000000 ?
'w' :
'-',
297 lcr & 0x08000000 ?
'b' :
'-',
298 lcr & 0x04000000 ?
'B' :
'-',
299 lcr & 0x02000000 ?
'C' :
'-',
300 lcr & 0x01000000 ?
'D' :
'-',
301 lcr & 0x00800000 ?
'W' :
'-',
302 lcr & 0x00400000 ?
'R' :
'-',
303 (lcr & 0x00030000) == 0x00000000 ?
'4' :
304 (lcr & 0x00030000) == 0x00010000 ?
'2' :
305 (lcr & 0x00030000) == 0x00020000 ?
'1' :
320 #ifdef CONFIG_MB93091_VDK
321 static void __init detect_mb93091(
void)
323 #ifdef CONFIG_MB93090_MB00
325 if (!(cpu_system ==
__frv_mb93091_cb70 && ((*(
unsigned short *)0xffc00030) & 0x100))) {
327 mb93090_mb00_detected = 1;
331 #ifdef CONFIG_FUJITSU_MB93493
368 static void __init determine_cpu(
void)
383 cpu_series =
"unknown";
384 cpu_core =
"unknown";
385 cpu_silicon =
"unknown";
391 clock_bits_settable = CLOCK_BIT_CM_H | CLOCK_BIT_CM_M | CLOCK_BIT_P0;
396 cpu_series =
"fr400";
402 cpu_silicon =
"mb93401";
404 clock_cmodes = clock_cmodes_fr401_fr403;
408 cpu_silicon =
"mb93401/A";
410 clock_cmodes = clock_cmodes_fr401_fr403;
413 cpu_silicon =
"mb93403";
414 #ifndef CONFIG_MB93093_PDK
419 clock_cmodes = clock_cmodes_fr401_fr403;
427 cpu_series =
"fr400";
433 cpu_silicon =
"mb93405";
435 clock_cmodes = clock_cmodes_fr405;
437 clock_bits_settable |= CLOCK_BIT_CMODE;
445 if (*(
volatile unsigned short *) 0xffc001a0 == 0x0046)
454 cpu_series =
"fr450";
458 clock_bits_settable |= CLOCK_BIT_CMODE;
463 cpu_silicon =
"mb93451";
464 cpu_mmu =
"Prot, SAT, xSAT, DAT";
466 clock_cmodes = clock_cmodes_fr405;
474 cpu_series =
"fr500";
487 cpu_series =
"fr550";
493 cpu_silicon =
"mb93555";
494 cpu_mmu =
"Prot, SAT";
496 clock_cmodes = clock_cmodes_fr555;
508 printk(
"- Series:%s CPU:%s Silicon:%s\n",
509 cpu_series, cpu_core, cpu_silicon);
511 #ifdef CONFIG_MB93091_VDK
515 #if defined(CONFIG_MB93093_PDK) && defined(CONFIG_FUJITSU_MB93493)
528 unsigned long clkc,
psr, quot;
543 unsigned short clkswr = *(
volatile unsigned short *) 0xffc00104UL & 0x1fffUL;
549 ((clkswr >> 8) & 0xf) * 10000000 +
550 ((clkswr >> 4) & 0xf) * 1000000 +
551 ((clkswr ) & 0xf) * 100000;
556 unsigned short clkswr = *(
volatile unsigned short *) 0xffc00104UL & 0x1fffUL;
562 ((clkswr >> 8) & 0xf) * 10000000 +
563 ((clkswr >> 4) & 0xf) * 1000000 +
564 ((clkswr ) & 0xf) * 100000;
572 mode = &undef_clock_cmode;
579 #define CLOCK(SRC,RATIO) ((SRC) * (((RATIO) >> 4) & 0x0f) / ((RATIO) & 0x0f))
588 switch (clkc & CLKC_CM) {
599 printk(
"Unsupported CLKC CM %ld\n", clkc & CLKC_CM);
608 printk(
"CLKIN: %lu.%3.3luMHz\n",
613 " ext=%luMHz res=%luMHz sdram=%luMHz cbus=%luMHz core=%luMHz dsu=%luMHz\n",
659 #ifdef CONFIG_RESERVE_DMA_COHERENT
660 static void __init reserve_dma_coherent(
void)
665 #define __steal_AMPR(r) \
666 if (__get_DAMPR(r) & xAMPRx_V) { \
667 ampr = __get_DAMPR(r); \
668 __set_DAMPR(r, ampr | xAMPRx_S | xAMPRx_C); \
692 printk(
"No DMA consistent memory reserved\n");
699 ampr = 1 << (ampr - 3 + 20);
702 printk(
"DMA consistent memory reserved %lx-%lx\n",
716 printk(
"Calibrating delay loop... %lu.%02lu BogoMIPS\n",
738 if (!
memcmp(cmdline,
"mem=", 4)) {
741 mem_size =
memparse(cmdline + 4, &cmdline);
745 while (*cmdline && *cmdline !=
' ')
770 #ifdef CONFIG_GDBSTUB
774 #ifdef CONFIG_RESERVE_DMA_COHERENT
775 reserve_dma_coherent();
779 #ifdef CONFIG_MB93090_MB00
780 if (mb93090_mb00_detected)
785 #ifdef CONFIG_FRV_ONCPU_SERIAL
786 #ifndef CONFIG_GDBSTUB_UART0
790 #ifndef CONFIG_GDBSTUB_UART1
817 printk(
"KERNEL -> TEXT=0x%06x-0x%06x DATA=0x%06x-0x%06x BSS=0x%06x-0x%06x\n",
820 (
int) &_sbss, (
int) &
_ebss);
824 #if defined(CONFIG_VGA_CONSOLE)
826 #elif defined(CONFIG_DUMMY_CONSOLE)
832 setup_linux_memory();
834 setup_uclinux_memory();
843 printk(
"Done setup_arch\n");
857 static int __devinit setup_arch_serial(
void)
860 #ifndef CONFIG_GDBSTUB_UART0
863 #ifndef CONFIG_GDBSTUB_UART1
878 static void __init setup_linux_memory(
void)
880 unsigned long bootmap_size, low_top_pfn, kstart, kend, high_mem;
886 kend = (kend +
PAGE_SIZE - 1) & PAGE_MASK;
899 low_top_pfn = (KERNEL_LOWMEM_END - KERNEL_LOWMEM_START) >>
PAGE_SHIFT;
903 #ifdef CONFIG_HIGHMEM
919 printk(
KERN_NOTICE "%ldMB LOWMEM available.\n", low_top_pfn >> (20 - PAGE_SHIFT));
923 #ifdef CONFIG_HIGHMEM
933 #ifdef CONFIG_BLK_DEV_INITRD
943 "initrd extends beyond end of memory (0x%08lx > 0x%08lx)\n"
944 "disabling initrd\n",
946 low_top_pfn << PAGE_SHIFT);
960 static void __init setup_uclinux_memory(
void)
962 #ifdef CONFIG_PROTECT_KERNEL
968 kend = (
unsigned long) &__kernel_image_end;
969 kend = (kend +
PAGE_SIZE - 1) & PAGE_MASK;
991 #ifndef CONFIG_PROTECT_KERNEL
994 kend - (
unsigned long) &__kernel_image_start,
1000 dampr = (dampr >> 4) + 17;
1007 #ifdef CONFIG_RESERVE_DMA_COHERENT
1023 const char *
gr, *fr, *
fm, *
fp, *cm, *nem, *ble;
1028 gr = cpu_hsr0_all &
HSR0_GRHE ?
"gr0-63" :
"gr0-31";
1029 fr = cpu_hsr0_all &
HSR0_FRHE ?
"fr0-63" :
"fr0-31";
1030 fm = cpu_psr_all &
PSR_EM ?
", Media" :
"";
1031 fp = cpu_psr_all &
PSR_EF ?
", FPU" :
"";
1032 cm = cpu_psr_all &
PSR_CM ?
", CCCR" :
"";
1033 nem = cpu_psr_all &
PSR_NEM ?
", NE" :
"";
1034 ble = cpu_psr_all &
PSR_BE ?
"BE" :
"LE";
1038 "CPU-Core:\t%s, %s, %s%s%s\n"
1041 "FP-Media:\t%s%s%s\n"
1044 cpu_core, gr, ble, cm, nem,
1062 if (clock_bits_settable & CLOCK_BIT_CMODE) {
1063 seq_printf(m,
"%scmode=0x%04hx", sep, clock_cmodes_permitted);
1067 if (clock_bits_settable & CLOCK_BIT_CM) {
1068 seq_printf(m,
"%scm=0x%lx", sep, clock_bits_settable & CLOCK_BIT_CM);
1072 if (clock_bits_settable & CLOCK_BIT_P0) {
1081 "PM-Status:\tcmode=%d, cm=%d, p0=%d\n",
1084 #define print_clk(TAG, VAR) \
1085 seq_printf(m, "Clock-" TAG ":\t%lu.%2.2lu MHz\n", VAR / 1000000, (VAR / 10000) % 100)
1096 "BogoMips:\t%lu.%02lu\n",
1104 return *pos <
NR_CPUS ? (
void *) 0x12345678 :
NULL;
1107 static void *c_next(
struct seq_file *m,
void *v, loff_t *
pos)
1113 static void c_stop(
struct seq_file *m,
void *v)
1127 *year = *mon = *day = *hour = *min = *sec = 0;
1134 #ifdef CONFIG_MB93090_MB00
1137 unsigned long base = __addr_LCD();
1141 __set_LCD(base, LCD_CMD_READ_BUSY);
1142 __set_LCD(base, LCD_CMD_READ_BUSY & ~LCD_E);
1145 for (loop = 10000; loop > 0; loop--)
1146 if (!(__get_LCD(base) & 0x80))
1150 __set_LCD(base, cmd);
1151 __set_LCD(base, cmd & ~LCD_E);
1159 static void __init mb93090_display(
void)
1166 mb93090_sendlcdcmd(LCD_CMD_CLEAR);
1167 mb93090_sendlcdcmd(LCD_CMD_FUNCSET(1,1,0));
1168 mb93090_sendlcdcmd(LCD_CMD_ON(0,0));
1169 mb93090_sendlcdcmd(LCD_CMD_HOME);
1171 mb93090_sendlcdcmd(LCD_CMD_SET_DD_ADDR(0));
1172 for (p = mb93090_banner; *
p; p++)
1173 mb93090_sendlcdcmd(LCD_DATA_WRITE(*p));
1175 mb93090_sendlcdcmd(LCD_CMD_SET_DD_ADDR(64));
1176 for (p = mb93090_version; *
p; p++)
1177 mb93090_sendlcdcmd(LCD_DATA_WRITE(*p));
1181 #endif // CONFIG_MB93090_MB00