setup.c 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242
  1. /*
  2. * linux/arch/h8300/kernel/setup.c
  3. *
  4. * Copyleft ()) 2000 James D. Schettine {james@telos-systems.com}
  5. * Copyright (C) 1999,2000 Greg Ungerer (gerg@snapgear.com)
  6. * Copyright (C) 1998,1999 D. Jeff Dionne <jeff@lineo.ca>
  7. * Copyright (C) 1998 Kenneth Albanowski <kjahds@kjahds.com>
  8. * Copyright (C) 1995 Hamish Macdonald
  9. * Copyright (C) 2000 Lineo Inc. (www.lineo.com)
  10. * Copyright (C) 2001 Lineo, Inc. <www.lineo.com>
  11. *
  12. * H8/300 porting Yoshinori Sato <ysato@users.sourceforge.jp>
  13. */
  14. /*
  15. * This file handles the architecture-dependent parts of system setup
  16. */
  17. #include <linux/kernel.h>
  18. #include <linux/sched.h>
  19. #include <linux/delay.h>
  20. #include <linux/interrupt.h>
  21. #include <linux/mm.h>
  22. #include <linux/fs.h>
  23. #include <linux/fb.h>
  24. #include <linux/console.h>
  25. #include <linux/genhd.h>
  26. #include <linux/errno.h>
  27. #include <linux/string.h>
  28. #include <linux/major.h>
  29. #include <linux/bootmem.h>
  30. #include <linux/seq_file.h>
  31. #include <linux/init.h>
  32. #include <asm/setup.h>
  33. #include <asm/irq.h>
  34. #include <asm/pgtable.h>
  35. #include <asm/sections.h>
  36. #if defined(__H8300H__)
  37. #define CPU "H8/300H"
  38. #include <asm/regs306x.h>
  39. #endif
  40. #if defined(__H8300S__)
  41. #define CPU "H8S"
  42. #include <asm/regs267x.h>
  43. #endif
  44. #define STUBSIZE 0xc000
  45. unsigned long rom_length;
  46. unsigned long memory_start;
  47. unsigned long memory_end;
  48. char __initdata command_line[COMMAND_LINE_SIZE];
  49. extern int _ramstart, _ramend;
  50. extern char _target_name[];
  51. extern void h8300_gpio_init(void);
  52. #if (defined(CONFIG_H8300H_SIM) || defined(CONFIG_H8S_SIM)) \
  53. && defined(CONFIG_GDB_MAGICPRINT)
  54. /* printk with gdb service */
  55. static void gdb_console_output(struct console *c, const char *msg, unsigned len)
  56. {
  57. for (; len > 0; len--) {
  58. asm("mov.w %0,r2\n\t"
  59. "jsr @0xc4"::"r"(*msg++):"er2");
  60. }
  61. }
  62. /*
  63. * Setup initial baud/bits/parity. We do two things here:
  64. * - construct a cflag setting for the first rs_open()
  65. * - initialize the serial port
  66. * Return non-zero if we didn't find a serial port.
  67. */
  68. static int __init gdb_console_setup(struct console *co, char *options)
  69. {
  70. return 0;
  71. }
  72. static const struct console gdb_console = {
  73. .name = "gdb_con",
  74. .write = gdb_console_output,
  75. .device = NULL,
  76. .setup = gdb_console_setup,
  77. .flags = CON_PRINTBUFFER,
  78. .index = -1,
  79. };
  80. #endif
  81. void __init setup_arch(char **cmdline_p)
  82. {
  83. int bootmap_size;
  84. memory_start = (unsigned long) &_ramstart;
  85. /* allow for ROMFS on the end of the kernel */
  86. if (memcmp((void *)memory_start, "-rom1fs-", 8) == 0) {
  87. #if defined(CONFIG_BLK_DEV_INITRD)
  88. initrd_start = memory_start;
  89. initrd_end = memory_start += be32_to_cpu(((unsigned long *) (memory_start))[2]);
  90. #else
  91. memory_start += be32_to_cpu(((unsigned long *) memory_start)[2]);
  92. #endif
  93. }
  94. memory_start = PAGE_ALIGN(memory_start);
  95. #if !defined(CONFIG_BLKDEV_RESERVE)
  96. memory_end = (unsigned long) &_ramend; /* by now the stack is part of the init task */
  97. #if defined(CONFIG_GDB_DEBUG)
  98. memory_end -= STUBSIZE;
  99. #endif
  100. #else
  101. if ((memory_end < CONFIG_BLKDEV_RESERVE_ADDRESS) &&
  102. (memory_end > CONFIG_BLKDEV_RESERVE_ADDRESS))
  103. /* overlap userarea */
  104. memory_end = CONFIG_BLKDEV_RESERVE_ADDRESS;
  105. #endif
  106. init_mm.start_code = (unsigned long) _stext;
  107. init_mm.end_code = (unsigned long) _etext;
  108. init_mm.end_data = (unsigned long) _edata;
  109. init_mm.brk = (unsigned long) 0;
  110. #if (defined(CONFIG_H8300H_SIM) || defined(CONFIG_H8S_SIM)) && defined(CONFIG_GDB_MAGICPRINT)
  111. register_console((struct console *)&gdb_console);
  112. #endif
  113. printk(KERN_INFO "\r\n\nuClinux " CPU "\n");
  114. printk(KERN_INFO "Target Hardware: %s\n",_target_name);
  115. printk(KERN_INFO "Flat model support (C) 1998,1999 Kenneth Albanowski, D. Jeff Dionne\n");
  116. printk(KERN_INFO "H8/300 series support by Yoshinori Sato <ysato@users.sourceforge.jp>\n");
  117. #ifdef DEBUG
  118. printk(KERN_DEBUG "KERNEL -> TEXT=0x%p-0x%p DATA=0x%p-0x%p "
  119. "BSS=0x%p-0x%p\n", _stext, _etext, _sdata, _edata, __bss_start,
  120. __bss_stop);
  121. printk(KERN_DEBUG "KERNEL -> ROMFS=0x%p-0x%06lx MEM=0x%06lx-0x%06lx "
  122. "STACK=0x%06lx-0x%p\n", __bss_stop, memory_start, memory_start,
  123. memory_end, memory_end, &_ramend);
  124. #endif
  125. #ifdef CONFIG_DEFAULT_CMDLINE
  126. /* set from default command line */
  127. if (*command_line == '\0')
  128. strcpy(command_line,CONFIG_KERNEL_COMMAND);
  129. #endif
  130. /* Keep a copy of command line */
  131. *cmdline_p = &command_line[0];
  132. memcpy(boot_command_line, command_line, COMMAND_LINE_SIZE);
  133. boot_command_line[COMMAND_LINE_SIZE-1] = 0;
  134. #ifdef DEBUG
  135. if (strlen(*cmdline_p))
  136. printk(KERN_DEBUG "Command line: '%s'\n", *cmdline_p);
  137. #endif
  138. /*
  139. * give all the memory to the bootmap allocator, tell it to put the
  140. * boot mem_map at the start of memory
  141. */
  142. bootmap_size = init_bootmem_node(
  143. NODE_DATA(0),
  144. memory_start >> PAGE_SHIFT, /* map goes here */
  145. PAGE_OFFSET >> PAGE_SHIFT, /* 0 on coldfire */
  146. memory_end >> PAGE_SHIFT);
  147. /*
  148. * free the usable memory, we have to make sure we do not free
  149. * the bootmem bitmap so we then reserve it after freeing it :-)
  150. */
  151. free_bootmem(memory_start, memory_end - memory_start);
  152. reserve_bootmem(memory_start, bootmap_size, BOOTMEM_DEFAULT);
  153. /*
  154. * get kmalloc into gear
  155. */
  156. paging_init();
  157. h8300_gpio_init();
  158. #if defined(CONFIG_H8300_AKI3068NET) && defined(CONFIG_IDE)
  159. {
  160. #define AREABIT(addr) (1 << (((addr) >> 21) & 7))
  161. /* setup BSC */
  162. volatile unsigned char *abwcr = (volatile unsigned char *)ABWCR;
  163. volatile unsigned char *cscr = (volatile unsigned char *)CSCR;
  164. *abwcr &= ~(AREABIT(CONFIG_H8300_IDE_BASE) | AREABIT(CONFIG_H8300_IDE_ALT));
  165. *cscr |= (AREABIT(CONFIG_H8300_IDE_BASE) | AREABIT(CONFIG_H8300_IDE_ALT)) | 0x0f;
  166. }
  167. #endif
  168. #ifdef DEBUG
  169. printk(KERN_DEBUG "Done setup_arch\n");
  170. #endif
  171. }
  172. /*
  173. * Get CPU information for use by the procfs.
  174. */
  175. static int show_cpuinfo(struct seq_file *m, void *v)
  176. {
  177. char *cpu;
  178. int mode;
  179. u_long clockfreq;
  180. cpu = CPU;
  181. mode = *(volatile unsigned char *)MDCR & 0x07;
  182. clockfreq = CONFIG_CPU_CLOCK;
  183. seq_printf(m, "CPU:\t\t%s (mode:%d)\n"
  184. "Clock:\t\t%lu.%1luMHz\n"
  185. "BogoMips:\t%lu.%02lu\n"
  186. "Calibration:\t%lu loops\n",
  187. cpu,mode,
  188. clockfreq/1000,clockfreq%1000,
  189. (loops_per_jiffy*HZ)/500000,((loops_per_jiffy*HZ)/5000)%100,
  190. (loops_per_jiffy*HZ));
  191. return 0;
  192. }
  193. static void *c_start(struct seq_file *m, loff_t *pos)
  194. {
  195. return *pos < NR_CPUS ? ((void *) 0x12345678) : NULL;
  196. }
  197. static void *c_next(struct seq_file *m, void *v, loff_t *pos)
  198. {
  199. ++*pos;
  200. return c_start(m, pos);
  201. }
  202. static void c_stop(struct seq_file *m, void *v)
  203. {
  204. }
  205. const struct seq_operations cpuinfo_op = {
  206. .start = c_start,
  207. .next = c_next,
  208. .stop = c_stop,
  209. .show = show_cpuinfo,
  210. };