setup.c 6.6 KB

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