mpc834x_sys.c 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307
  1. /*
  2. * arch/ppc/platforms/83xx/mpc834x_sys.c
  3. *
  4. * MPC834x SYS board specific routines
  5. *
  6. * Maintainer: Kumar Gala <kumar.gala@freescale.com>
  7. *
  8. * Copyright 2005 Freescale Semiconductor Inc.
  9. *
  10. * This program is free software; you can redistribute it and/or modify it
  11. * under the terms of the GNU General Public License as published by the
  12. * Free Software Foundation; either version 2 of the License, or (at your
  13. * option) any later version.
  14. */
  15. #include <linux/config.h>
  16. #include <linux/stddef.h>
  17. #include <linux/kernel.h>
  18. #include <linux/init.h>
  19. #include <linux/errno.h>
  20. #include <linux/reboot.h>
  21. #include <linux/pci.h>
  22. #include <linux/kdev_t.h>
  23. #include <linux/major.h>
  24. #include <linux/console.h>
  25. #include <linux/delay.h>
  26. #include <linux/irq.h>
  27. #include <linux/seq_file.h>
  28. #include <linux/root_dev.h>
  29. #include <linux/serial.h>
  30. #include <linux/tty.h> /* for linux/serial_core.h */
  31. #include <linux/serial_core.h>
  32. #include <linux/initrd.h>
  33. #include <linux/module.h>
  34. #include <linux/fsl_devices.h>
  35. #include <asm/system.h>
  36. #include <asm/pgtable.h>
  37. #include <asm/page.h>
  38. #include <asm/atomic.h>
  39. #include <asm/time.h>
  40. #include <asm/io.h>
  41. #include <asm/machdep.h>
  42. #include <asm/ipic.h>
  43. #include <asm/bootinfo.h>
  44. #include <asm/pci-bridge.h>
  45. #include <asm/mpc83xx.h>
  46. #include <asm/irq.h>
  47. #include <asm/kgdb.h>
  48. #include <asm/ppc_sys.h>
  49. #include <mm/mmu_decl.h>
  50. #include <syslib/ppc83xx_setup.h>
  51. #ifndef CONFIG_PCI
  52. unsigned long isa_io_base = 0;
  53. unsigned long isa_mem_base = 0;
  54. #endif
  55. extern unsigned long total_memory; /* in mm/init */
  56. unsigned char __res[sizeof (bd_t)];
  57. #ifdef CONFIG_PCI
  58. #error "PCI is not supported"
  59. /* NEED mpc83xx_map_irq & mpc83xx_exclude_device
  60. see platforms/85xx/mpc85xx_ads_common.c */
  61. #endif /* CONFIG_PCI */
  62. /* ************************************************************************
  63. *
  64. * Setup the architecture
  65. *
  66. */
  67. static void __init
  68. mpc834x_sys_setup_arch(void)
  69. {
  70. bd_t *binfo = (bd_t *) __res;
  71. unsigned int freq;
  72. struct gianfar_platform_data *pdata;
  73. /* get the core frequency */
  74. freq = binfo->bi_intfreq;
  75. /* Set loops_per_jiffy to a half-way reasonable value,
  76. for use until calibrate_delay gets called. */
  77. loops_per_jiffy = freq / HZ;
  78. #ifdef CONFIG_PCI
  79. /* setup PCI host bridges */
  80. mpc83xx_sys_setup_hose();
  81. #endif
  82. mpc83xx_early_serial_map();
  83. /* setup the board related information for the enet controllers */
  84. pdata = (struct gianfar_platform_data *) ppc_sys_get_pdata(MPC83xx_TSEC1);
  85. pdata->board_flags = FSL_GIANFAR_BRD_HAS_PHY_INTR;
  86. pdata->interruptPHY = MPC83xx_IRQ_EXT1;
  87. pdata->phyid = 0;
  88. /* fixup phy address */
  89. pdata->phy_reg_addr += binfo->bi_immr_base;
  90. memcpy(pdata->mac_addr, binfo->bi_enetaddr, 6);
  91. pdata = (struct gianfar_platform_data *) ppc_sys_get_pdata(MPC83xx_TSEC2);
  92. pdata->board_flags = FSL_GIANFAR_BRD_HAS_PHY_INTR;
  93. pdata->interruptPHY = MPC83xx_IRQ_EXT2;
  94. pdata->phyid = 1;
  95. /* fixup phy address */
  96. pdata->phy_reg_addr += binfo->bi_immr_base;
  97. memcpy(pdata->mac_addr, binfo->bi_enet1addr, 6);
  98. #ifdef CONFIG_BLK_DEV_INITRD
  99. if (initrd_start)
  100. ROOT_DEV = Root_RAM0;
  101. else
  102. #endif
  103. #ifdef CONFIG_ROOT_NFS
  104. ROOT_DEV = Root_NFS;
  105. #else
  106. ROOT_DEV = Root_HDA1;
  107. #endif
  108. }
  109. static void __init
  110. mpc834x_sys_map_io(void)
  111. {
  112. /* we steal the lowest ioremap addr for virt space */
  113. io_block_mapping(VIRT_IMMRBAR, immrbar, 1024*1024, _PAGE_IO);
  114. }
  115. int
  116. mpc834x_sys_show_cpuinfo(struct seq_file *m)
  117. {
  118. uint pvid, svid, phid1;
  119. bd_t *binfo = (bd_t *) __res;
  120. unsigned int freq;
  121. /* get the core frequency */
  122. freq = binfo->bi_intfreq;
  123. pvid = mfspr(SPRN_PVR);
  124. svid = mfspr(SPRN_SVR);
  125. seq_printf(m, "Vendor\t\t: Freescale Inc.\n");
  126. seq_printf(m, "Machine\t\t: mpc%s sys\n", cur_ppc_sys_spec->ppc_sys_name);
  127. seq_printf(m, "core clock\t: %d MHz\n"
  128. "bus clock\t: %d MHz\n",
  129. (int)(binfo->bi_intfreq / 1000000),
  130. (int)(binfo->bi_busfreq / 1000000));
  131. seq_printf(m, "PVR\t\t: 0x%x\n", pvid);
  132. seq_printf(m, "SVR\t\t: 0x%x\n", svid);
  133. /* Display cpu Pll setting */
  134. phid1 = mfspr(SPRN_HID1);
  135. seq_printf(m, "PLL setting\t: 0x%x\n", ((phid1 >> 24) & 0x3f));
  136. /* Display the amount of memory */
  137. seq_printf(m, "Memory\t\t: %d MB\n", (int)(binfo->bi_memsize / (1024 * 1024)));
  138. return 0;
  139. }
  140. void __init
  141. mpc834x_sys_init_IRQ(void)
  142. {
  143. bd_t *binfo = (bd_t *) __res;
  144. u8 senses[8] = {
  145. 0, /* EXT 0 */
  146. IRQ_SENSE_LEVEL, /* EXT 1 */
  147. IRQ_SENSE_LEVEL, /* EXT 2 */
  148. 0, /* EXT 3 */
  149. 0, /* EXT 4 */
  150. 0, /* EXT 5 */
  151. 0, /* EXT 6 */
  152. 0, /* EXT 7 */
  153. };
  154. ipic_init(binfo->bi_immr_base + 0x00700, 0, MPC83xx_IPIC_IRQ_OFFSET, senses, 8);
  155. /* Initialize the default interrupt mapping priorities,
  156. * in case the boot rom changed something on us.
  157. */
  158. ipic_set_default_priority();
  159. }
  160. #if defined(CONFIG_I2C_MPC) && defined(CONFIG_SENSORS_DS1374)
  161. extern ulong ds1374_get_rtc_time(void);
  162. extern int ds1374_set_rtc_time(ulong);
  163. static int __init
  164. mpc834x_rtc_hookup(void)
  165. {
  166. struct timespec tv;
  167. ppc_md.get_rtc_time = ds1374_get_rtc_time;
  168. ppc_md.set_rtc_time = ds1374_set_rtc_time;
  169. tv.tv_nsec = 0;
  170. tv.tv_sec = (ppc_md.get_rtc_time)();
  171. do_settimeofday(&tv);
  172. return 0;
  173. }
  174. late_initcall(mpc834x_rtc_hookup);
  175. #endif
  176. static __inline__ void
  177. mpc834x_sys_set_bat(void)
  178. {
  179. /* we steal the lowest ioremap addr for virt space */
  180. mb();
  181. mtspr(SPRN_DBAT1U, VIRT_IMMRBAR | 0x1e);
  182. mtspr(SPRN_DBAT1L, immrbar | 0x2a);
  183. mb();
  184. }
  185. void __init
  186. platform_init(unsigned long r3, unsigned long r4, unsigned long r5,
  187. unsigned long r6, unsigned long r7)
  188. {
  189. bd_t *binfo = (bd_t *) __res;
  190. /* parse_bootinfo must always be called first */
  191. parse_bootinfo(find_bootinfo());
  192. /*
  193. * If we were passed in a board information, copy it into the
  194. * residual data area.
  195. */
  196. if (r3) {
  197. memcpy((void *) __res, (void *) (r3 + KERNELBASE),
  198. sizeof (bd_t));
  199. }
  200. #if defined(CONFIG_BLK_DEV_INITRD)
  201. /*
  202. * If the init RAM disk has been configured in, and there's a valid
  203. * starting address for it, set it up.
  204. */
  205. if (r4) {
  206. initrd_start = r4 + KERNELBASE;
  207. initrd_end = r5 + KERNELBASE;
  208. }
  209. #endif /* CONFIG_BLK_DEV_INITRD */
  210. /* Copy the kernel command line arguments to a safe place. */
  211. if (r6) {
  212. *(char *) (r7 + KERNELBASE) = 0;
  213. strcpy(cmd_line, (char *) (r6 + KERNELBASE));
  214. }
  215. immrbar = binfo->bi_immr_base;
  216. mpc834x_sys_set_bat();
  217. #if defined(CONFIG_SERIAL_8250) && defined(CONFIG_SERIAL_TEXT_DEBUG)
  218. {
  219. struct uart_port p;
  220. memset(&p, 0, sizeof (p));
  221. p.iotype = SERIAL_IO_MEM;
  222. p.membase = (unsigned char __iomem *)(VIRT_IMMRBAR + 0x4500);
  223. p.uartclk = binfo->bi_busfreq;
  224. gen550_init(0, &p);
  225. memset(&p, 0, sizeof (p));
  226. p.iotype = SERIAL_IO_MEM;
  227. p.membase = (unsigned char __iomem *)(VIRT_IMMRBAR + 0x4600);
  228. p.uartclk = binfo->bi_busfreq;
  229. gen550_init(1, &p);
  230. }
  231. #endif
  232. identify_ppc_sys_by_id(mfspr(SPRN_SVR));
  233. /* setup the PowerPC module struct */
  234. ppc_md.setup_arch = mpc834x_sys_setup_arch;
  235. ppc_md.show_cpuinfo = mpc834x_sys_show_cpuinfo;
  236. ppc_md.init_IRQ = mpc834x_sys_init_IRQ;
  237. ppc_md.get_irq = ipic_get_irq;
  238. ppc_md.restart = mpc83xx_restart;
  239. ppc_md.power_off = mpc83xx_power_off;
  240. ppc_md.halt = mpc83xx_halt;
  241. ppc_md.find_end_of_memory = mpc83xx_find_end_of_memory;
  242. ppc_md.setup_io_mappings = mpc834x_sys_map_io;
  243. ppc_md.time_init = mpc83xx_time_init;
  244. ppc_md.set_rtc_time = NULL;
  245. ppc_md.get_rtc_time = NULL;
  246. ppc_md.calibrate_decr = mpc83xx_calibrate_decr;
  247. ppc_md.early_serial_map = mpc83xx_early_serial_map;
  248. #if defined(CONFIG_SERIAL_8250) && defined(CONFIG_SERIAL_TEXT_DEBUG)
  249. ppc_md.progress = gen550_progress;
  250. #endif /* CONFIG_SERIAL_8250 && CONFIG_SERIAL_TEXT_DEBUG */
  251. if (ppc_md.progress)
  252. ppc_md.progress("mpc834x_sys_init(): exit", 0);
  253. return;
  254. }