mpc834x_sys.c 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. /*
  2. * arch/powerpc/platforms/83xx/mpc834x_sys.c
  3. *
  4. * MPC834x SYS board specific routines
  5. *
  6. * Maintainer: Kumar Gala <galak@kernel.crashing.org>
  7. *
  8. * This program is free software; you can redistribute it and/or modify it
  9. * under the terms of the GNU General Public License as published by the
  10. * Free Software Foundation; either version 2 of the License, or (at your
  11. * option) any later version.
  12. */
  13. #include <linux/stddef.h>
  14. #include <linux/kernel.h>
  15. #include <linux/init.h>
  16. #include <linux/errno.h>
  17. #include <linux/reboot.h>
  18. #include <linux/pci.h>
  19. #include <linux/kdev_t.h>
  20. #include <linux/major.h>
  21. #include <linux/console.h>
  22. #include <linux/delay.h>
  23. #include <linux/seq_file.h>
  24. #include <linux/root_dev.h>
  25. #include <asm/system.h>
  26. #include <asm/atomic.h>
  27. #include <asm/time.h>
  28. #include <asm/io.h>
  29. #include <asm/machdep.h>
  30. #include <asm/ipic.h>
  31. #include <asm/bootinfo.h>
  32. #include <asm/irq.h>
  33. #include <asm/prom.h>
  34. #include <asm/udbg.h>
  35. #include <sysdev/fsl_soc.h>
  36. #include "mpc83xx.h"
  37. #ifndef CONFIG_PCI
  38. unsigned long isa_io_base = 0;
  39. unsigned long isa_mem_base = 0;
  40. #endif
  41. #ifdef CONFIG_PCI
  42. static int
  43. mpc83xx_map_irq(struct pci_dev *dev, unsigned char idsel, unsigned char pin)
  44. {
  45. static char pci_irq_table[][4] =
  46. /*
  47. * PCI IDSEL/INTPIN->INTLINE
  48. * A B C D
  49. */
  50. {
  51. {PIRQA, PIRQB, PIRQC, PIRQD}, /* idsel 0x11 */
  52. {PIRQC, PIRQD, PIRQA, PIRQB}, /* idsel 0x12 */
  53. {PIRQD, PIRQA, PIRQB, PIRQC}, /* idsel 0x13 */
  54. {0, 0, 0, 0},
  55. {PIRQA, PIRQB, PIRQC, PIRQD}, /* idsel 0x15 */
  56. {PIRQD, PIRQA, PIRQB, PIRQC}, /* idsel 0x16 */
  57. {PIRQC, PIRQD, PIRQA, PIRQB}, /* idsel 0x17 */
  58. {PIRQB, PIRQC, PIRQD, PIRQA}, /* idsel 0x18 */
  59. {0, 0, 0, 0}, /* idsel 0x19 */
  60. {0, 0, 0, 0}, /* idsel 0x20 */
  61. };
  62. const long min_idsel = 0x11, max_idsel = 0x20, irqs_per_slot = 4;
  63. return PCI_IRQ_TABLE_LOOKUP;
  64. }
  65. #endif /* CONFIG_PCI */
  66. /* ************************************************************************
  67. *
  68. * Setup the architecture
  69. *
  70. */
  71. static void __init mpc834x_sys_setup_arch(void)
  72. {
  73. struct device_node *np;
  74. if (ppc_md.progress)
  75. ppc_md.progress("mpc834x_sys_setup_arch()", 0);
  76. np = of_find_node_by_type(NULL, "cpu");
  77. if (np != 0) {
  78. unsigned int *fp =
  79. (int *)get_property(np, "clock-frequency", NULL);
  80. if (fp != 0)
  81. loops_per_jiffy = *fp / HZ;
  82. else
  83. loops_per_jiffy = 50000000 / HZ;
  84. of_node_put(np);
  85. }
  86. #ifdef CONFIG_PCI
  87. for (np = NULL; (np = of_find_node_by_type(np, "pci")) != NULL;)
  88. add_bridge(np);
  89. ppc_md.pci_swizzle = common_swizzle;
  90. ppc_md.pci_map_irq = mpc83xx_map_irq;
  91. ppc_md.pci_exclude_device = mpc83xx_exclude_device;
  92. #endif
  93. #ifdef CONFIG_ROOT_NFS
  94. ROOT_DEV = Root_NFS;
  95. #else
  96. ROOT_DEV = Root_HDA1;
  97. #endif
  98. }
  99. void __init mpc834x_sys_init_IRQ(void)
  100. {
  101. u8 senses[8] = {
  102. 0, /* EXT 0 */
  103. IRQ_SENSE_LEVEL, /* EXT 1 */
  104. IRQ_SENSE_LEVEL, /* EXT 2 */
  105. 0, /* EXT 3 */
  106. #ifdef CONFIG_PCI
  107. IRQ_SENSE_LEVEL, /* EXT 4 */
  108. IRQ_SENSE_LEVEL, /* EXT 5 */
  109. IRQ_SENSE_LEVEL, /* EXT 6 */
  110. IRQ_SENSE_LEVEL, /* EXT 7 */
  111. #else
  112. 0, /* EXT 4 */
  113. 0, /* EXT 5 */
  114. 0, /* EXT 6 */
  115. 0, /* EXT 7 */
  116. #endif
  117. };
  118. ipic_init(get_immrbase() + 0x00700, 0, 0, senses, 8);
  119. /* Initialize the default interrupt mapping priorities,
  120. * in case the boot rom changed something on us.
  121. */
  122. ipic_set_default_priority();
  123. }
  124. #if defined(CONFIG_I2C_MPC) && defined(CONFIG_SENSORS_DS1374)
  125. extern ulong ds1374_get_rtc_time(void);
  126. extern int ds1374_set_rtc_time(ulong);
  127. static int __init mpc834x_rtc_hookup(void)
  128. {
  129. struct timespec tv;
  130. ppc_md.get_rtc_time = ds1374_get_rtc_time;
  131. ppc_md.set_rtc_time = ds1374_set_rtc_time;
  132. tv.tv_nsec = 0;
  133. tv.tv_sec = (ppc_md.get_rtc_time) ();
  134. do_settimeofday(&tv);
  135. return 0;
  136. }
  137. late_initcall(mpc834x_rtc_hookup);
  138. #endif
  139. /*
  140. * Called very early, MMU is off, device-tree isn't unflattened
  141. */
  142. static int __init mpc834x_sys_probe(void)
  143. {
  144. /* We always match for now, eventually we should look at the flat
  145. dev tree to ensure this is the board we are suppose to run on
  146. */
  147. return 1;
  148. }
  149. define_machine(mpc834x_sys) {
  150. .name = "MPC834x SYS",
  151. .probe = mpc834x_sys_probe,
  152. .setup_arch = mpc834x_sys_setup_arch,
  153. .init_IRQ = mpc834x_sys_init_IRQ,
  154. .get_irq = ipic_get_irq,
  155. .restart = mpc83xx_restart,
  156. .time_init = mpc83xx_time_init,
  157. .calibrate_decr = generic_calibrate_decr,
  158. .progress = udbg_progress,
  159. };