storcenter.c 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. /*
  2. * Board setup routines for the storcenter
  3. *
  4. * Copyright 2007 (C) Oyvind Repvik (nail@nslu2-linux.org)
  5. * Copyright 2007 Andy Wilcox, Jon Loeliger
  6. *
  7. * Based on linkstation.c by G. Liakhovetski
  8. *
  9. * This file is licensed under the terms of the GNU General Public License
  10. * version 2. This program is licensed "as is" without any warranty of
  11. * any kind, whether express or implied.
  12. */
  13. #include <linux/kernel.h>
  14. #include <linux/pci.h>
  15. #include <linux/initrd.h>
  16. #include <linux/mtd/physmap.h>
  17. #include <linux/of_platform.h>
  18. #include <asm/system.h>
  19. #include <asm/time.h>
  20. #include <asm/prom.h>
  21. #include <asm/mpic.h>
  22. #include <asm/pci-bridge.h>
  23. #include "mpc10x.h"
  24. #ifdef CONFIG_MTD_PHYSMAP
  25. static struct mtd_partition storcenter_physmap_partitions[] = {
  26. {
  27. .name = "kernel",
  28. .offset = 0x000000,
  29. .size = 0x170000,
  30. },
  31. {
  32. .name = "rootfs",
  33. .offset = 0x170000,
  34. .size = 0x590000,
  35. },
  36. {
  37. .name = "uboot",
  38. .offset = 0x700000,
  39. .size = 0x040000,
  40. },
  41. {
  42. .name = "config",
  43. .offset = 0x740000,
  44. .size = 0x0c0000,
  45. },
  46. };
  47. #endif
  48. static __initdata struct of_device_id storcenter_of_bus[] = {
  49. { .name = "soc", },
  50. {},
  51. };
  52. static int __init storcenter_device_probe(void)
  53. {
  54. of_platform_bus_probe(NULL, storcenter_of_bus, NULL);
  55. return 0;
  56. }
  57. machine_device_initcall(storcenter, storcenter_device_probe);
  58. static int __init storcenter_add_bridge(struct device_node *dev)
  59. {
  60. #ifdef CONFIG_PCI
  61. int len;
  62. struct pci_controller *hose;
  63. const int *bus_range;
  64. printk("Adding PCI host bridge %s\n", dev->full_name);
  65. hose = pcibios_alloc_controller(dev);
  66. if (hose == NULL)
  67. return -ENOMEM;
  68. bus_range = of_get_property(dev, "bus-range", &len);
  69. hose->first_busno = bus_range ? bus_range[0] : 0;
  70. hose->last_busno = bus_range ? bus_range[1] : 0xff;
  71. setup_indirect_pci(hose, MPC10X_MAPB_CNFG_ADDR, MPC10X_MAPB_CNFG_DATA, 0);
  72. /* Interpret the "ranges" property */
  73. /* This also maps the I/O region and sets isa_io/mem_base */
  74. pci_process_bridge_OF_ranges(hose, dev, 1);
  75. #endif
  76. return 0;
  77. }
  78. static void __init storcenter_setup_arch(void)
  79. {
  80. struct device_node *np;
  81. #ifdef CONFIG_MTD_PHYSMAP
  82. physmap_set_partitions(storcenter_physmap_partitions,
  83. ARRAY_SIZE(storcenter_physmap_partitions));
  84. #endif
  85. /* Lookup PCI host bridges */
  86. for_each_compatible_node(np, "pci", "mpc10x-pci")
  87. storcenter_add_bridge(np);
  88. printk(KERN_INFO "IOMEGA StorCenter\n");
  89. }
  90. /*
  91. * Interrupt setup and service. Interrrupts on the turbostation come
  92. * from the four PCI slots plus onboard 8241 devices: I2C, DUART.
  93. */
  94. static void __init storcenter_init_IRQ(void)
  95. {
  96. struct mpic *mpic;
  97. struct device_node *dnp;
  98. const void *prop;
  99. int size;
  100. phys_addr_t paddr;
  101. dnp = of_find_node_by_type(NULL, "open-pic");
  102. if (dnp == NULL)
  103. return;
  104. prop = of_get_property(dnp, "reg", &size);
  105. if (prop == NULL) {
  106. of_node_put(dnp);
  107. return;
  108. }
  109. paddr = (phys_addr_t)of_translate_address(dnp, prop);
  110. mpic = mpic_alloc(dnp, paddr, MPIC_PRIMARY | MPIC_WANTS_RESET,
  111. 16, 32, " OpenPIC ");
  112. of_node_put(dnp);
  113. BUG_ON(mpic == NULL);
  114. /*
  115. * 16 Serial Interrupts followed by 16 Internal Interrupts.
  116. * I2C is the second internal, so it is at 17, 0x11020.
  117. */
  118. mpic_assign_isu(mpic, 0, paddr + 0x10200);
  119. mpic_assign_isu(mpic, 1, paddr + 0x11000);
  120. mpic_init(mpic);
  121. }
  122. static void storcenter_restart(char *cmd)
  123. {
  124. local_irq_disable();
  125. /* Set exception prefix high - to the firmware */
  126. _nmask_and_or_msr(0, MSR_IP);
  127. /* Wait for reset to happen */
  128. for (;;) ;
  129. }
  130. static int __init storcenter_probe(void)
  131. {
  132. unsigned long root = of_get_flat_dt_root();
  133. return of_flat_dt_is_compatible(root, "iomega,storcenter");
  134. }
  135. define_machine(storcenter){
  136. .name = "IOMEGA StorCenter",
  137. .probe = storcenter_probe,
  138. .setup_arch = storcenter_setup_arch,
  139. .init_IRQ = storcenter_init_IRQ,
  140. .get_irq = mpic_get_irq,
  141. .restart = storcenter_restart,
  142. .calibrate_decr = generic_calibrate_decr,
  143. };