sim85e2.c 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  1. /*
  2. * arch/v850/kernel/sim85e2.c -- Machine-specific stuff for
  3. * V850E2 RTL simulator
  4. *
  5. * Copyright (C) 2002,03 NEC Electronics Corporation
  6. * Copyright (C) 2002,03 Miles Bader <miles@gnu.org>
  7. *
  8. * This file is subject to the terms and conditions of the GNU General
  9. * Public License. See the file COPYING in the main directory of this
  10. * archive for more details.
  11. *
  12. * Written by Miles Bader <miles@gnu.org>
  13. */
  14. #include <linux/kernel.h>
  15. #include <linux/module.h>
  16. #include <linux/init.h>
  17. #include <linux/mm.h>
  18. #include <linux/swap.h>
  19. #include <linux/bootmem.h>
  20. #include <linux/irq.h>
  21. #include <asm/atomic.h>
  22. #include <asm/page.h>
  23. #include <asm/machdep.h>
  24. #include "mach.h"
  25. /* There are 4 possible areas we can use:
  26. IRAM (1MB) is fast for instruction fetches, but slow for data
  27. DRAM (1020KB) is fast for data, but slow for instructions
  28. ERAM is cached, so should be fast for both insns and data
  29. SDRAM is external DRAM, similar to ERAM
  30. */
  31. #define INIT_MEMC_FOR_SDRAM
  32. #define USE_SDRAM_AREA
  33. #define KERNEL_IN_SDRAM_AREA
  34. #define DCACHE_MODE V850E2_CACHE_BTSC_DCM_WT
  35. /*#define DCACHE_MODE V850E2_CACHE_BTSC_DCM_WB_ALLOC*/
  36. #ifdef USE_SDRAM_AREA
  37. #define RAM_START SDRAM_ADDR
  38. #define RAM_END (SDRAM_ADDR + SDRAM_SIZE)
  39. #else
  40. /* When we use DRAM, we need to account for the fact that the end of it is
  41. used for R0_RAM. */
  42. #define RAM_START DRAM_ADDR
  43. #define RAM_END R0_RAM_ADDR
  44. #endif
  45. extern void memcons_setup (void);
  46. #ifdef KERNEL_IN_SDRAM_AREA
  47. #define EARLY_INIT_SECTION_ATTR __attribute__ ((section (".early.text")))
  48. #else
  49. #define EARLY_INIT_SECTION_ATTR __init
  50. #endif
  51. void EARLY_INIT_SECTION_ATTR mach_early_init (void)
  52. {
  53. /* The sim85e2 simulator tracks `undefined' values, so to make
  54. debugging easier, we begin by zeroing out all otherwise
  55. undefined registers. This is not strictly necessary.
  56. The registers we zero are:
  57. Every GPR except:
  58. stack-pointer (r3)
  59. task-pointer (r16)
  60. our return addr (r31)
  61. Every system register (SPR) that we know about except for
  62. the PSW (SPR 5), which we zero except for the
  63. disable-interrupts bit.
  64. */
  65. /* GPRs */
  66. asm volatile (" mov r0, r1 ; mov r0, r2 ");
  67. asm volatile ("mov r0, r4 ; mov r0, r5 ; mov r0, r6 ; mov r0, r7 ");
  68. asm volatile ("mov r0, r8 ; mov r0, r9 ; mov r0, r10; mov r0, r11");
  69. asm volatile ("mov r0, r12; mov r0, r13; mov r0, r14; mov r0, r15");
  70. asm volatile (" mov r0, r17; mov r0, r18; mov r0, r19");
  71. asm volatile ("mov r0, r20; mov r0, r21; mov r0, r22; mov r0, r23");
  72. asm volatile ("mov r0, r24; mov r0, r25; mov r0, r26; mov r0, r27");
  73. asm volatile ("mov r0, r28; mov r0, r29; mov r0, r30");
  74. /* SPRs */
  75. asm volatile ("ldsr r0, 0; ldsr r0, 1; ldsr r0, 2; ldsr r0, 3");
  76. asm volatile ("ldsr r0, 4");
  77. asm volatile ("addi 0x20, r0, r1; ldsr r1, 5"); /* PSW */
  78. asm volatile ("ldsr r0, 16; ldsr r0, 17; ldsr r0, 18; ldsr r0, 19");
  79. asm volatile ("ldsr r0, 20");
  80. #ifdef INIT_MEMC_FOR_SDRAM
  81. /* Settings for SDRAM controller. */
  82. V850E2_VSWC = 0x0042;
  83. V850E2_BSC = 0x9286;
  84. V850E2_BCT(0) = 0xb000; /* was: 0 */
  85. V850E2_BCT(1) = 0x000b;
  86. V850E2_ASC = 0;
  87. V850E2_LBS = 0xa9aa; /* was: 0xaaaa */
  88. V850E2_LBC(0) = 0;
  89. V850E2_LBC(1) = 0; /* was: 0x3 */
  90. V850E2_BCC = 0;
  91. V850E2_RFS(4) = 0x800a; /* was: 0xf109 */
  92. V850E2_SCR(4) = 0x2091; /* was: 0x20a1 */
  93. V850E2_RFS(3) = 0x800c;
  94. V850E2_SCR(3) = 0x20a1;
  95. V850E2_DWC(0) = 0;
  96. V850E2_DWC(1) = 0;
  97. #endif
  98. #if 0
  99. #ifdef CONFIG_V850E2_SIM85E2S
  100. /* Turn on the caches. */
  101. V850E2_CACHE_BTSC = V850E2_CACHE_BTSC_ICM | DCACHE_MODE;
  102. V850E2_BHC = 0x1010;
  103. #elif CONFIG_V850E2_SIM85E2C
  104. V850E2_CACHE_BTSC |= (V850E2_CACHE_BTSC_ICM | V850E2_CACHE_BTSC_DCM0);
  105. V850E2_BUSM_BHC = 0xFFFF;
  106. #endif
  107. #else
  108. V850E2_BHC = 0;
  109. #endif
  110. /* Don't stop the simulator at `halt' instructions. */
  111. SIM85E2_NOTHAL = 1;
  112. /* Ensure that the simulator halts on a panic, instead of going
  113. into an infinite loop inside the panic function. */
  114. panic_timeout = -1;
  115. }
  116. void __init mach_setup (char **cmdline)
  117. {
  118. memcons_setup ();
  119. }
  120. void mach_get_physical_ram (unsigned long *ram_start, unsigned long *ram_len)
  121. {
  122. *ram_start = RAM_START;
  123. *ram_len = RAM_END - RAM_START;
  124. }
  125. void __init mach_sched_init (struct irqaction *timer_action)
  126. {
  127. /* The simulator actually cycles through all interrupts
  128. periodically. We just pay attention to IRQ0, which gives us
  129. 1/64 the rate of the periodic interrupts. */
  130. setup_irq (0, timer_action);
  131. }
  132. void mach_gettimeofday (struct timespec *tv)
  133. {
  134. tv->tv_sec = 0;
  135. tv->tv_nsec = 0;
  136. }
  137. /* Interrupts */
  138. struct v850e_intc_irq_init irq_inits[] = {
  139. { "IRQ", 0, NUM_MACH_IRQS, 1, 7 },
  140. { 0 }
  141. };
  142. struct hw_interrupt_type hw_itypes[1];
  143. /* Initialize interrupts. */
  144. void __init mach_init_irqs (void)
  145. {
  146. v850e_intc_init_irq_types (irq_inits, hw_itypes);
  147. }
  148. void machine_halt (void) __attribute__ ((noreturn));
  149. void machine_halt (void)
  150. {
  151. SIM85E2_SIMFIN = 0; /* Halt immediately. */
  152. for (;;) {}
  153. }
  154. void machine_restart (char *__unused)
  155. {
  156. machine_halt ();
  157. }
  158. void machine_power_off (void)
  159. {
  160. machine_halt ();
  161. }