setup.c 6.6 KB

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