mpc834x_sys.c 4.3 KB

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