storcenter.c 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  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/of_platform.h>
  17. #include <asm/system.h>
  18. #include <asm/time.h>
  19. #include <asm/prom.h>
  20. #include <asm/mpic.h>
  21. #include <asm/pci-bridge.h>
  22. #include "mpc10x.h"
  23. static __initdata struct of_device_id storcenter_of_bus[] = {
  24. { .name = "soc", },
  25. {},
  26. };
  27. static int __init storcenter_device_probe(void)
  28. {
  29. of_platform_bus_probe(NULL, storcenter_of_bus, NULL);
  30. return 0;
  31. }
  32. machine_device_initcall(storcenter, storcenter_device_probe);
  33. static int __init storcenter_add_bridge(struct device_node *dev)
  34. {
  35. #ifdef CONFIG_PCI
  36. int len;
  37. struct pci_controller *hose;
  38. const int *bus_range;
  39. printk("Adding PCI host bridge %s\n", dev->full_name);
  40. hose = pcibios_alloc_controller(dev);
  41. if (hose == NULL)
  42. return -ENOMEM;
  43. bus_range = of_get_property(dev, "bus-range", &len);
  44. hose->first_busno = bus_range ? bus_range[0] : 0;
  45. hose->last_busno = bus_range ? bus_range[1] : 0xff;
  46. setup_indirect_pci(hose, MPC10X_MAPB_CNFG_ADDR, MPC10X_MAPB_CNFG_DATA, 0);
  47. /* Interpret the "ranges" property */
  48. /* This also maps the I/O region and sets isa_io/mem_base */
  49. pci_process_bridge_OF_ranges(hose, dev, 1);
  50. #endif
  51. return 0;
  52. }
  53. static void __init storcenter_setup_arch(void)
  54. {
  55. struct device_node *np;
  56. /* Lookup PCI host bridges */
  57. for_each_compatible_node(np, "pci", "mpc10x-pci")
  58. storcenter_add_bridge(np);
  59. printk(KERN_INFO "IOMEGA StorCenter\n");
  60. }
  61. /*
  62. * Interrupt setup and service. Interrrupts on the turbostation come
  63. * from the four PCI slots plus onboard 8241 devices: I2C, DUART.
  64. */
  65. static void __init storcenter_init_IRQ(void)
  66. {
  67. struct mpic *mpic;
  68. struct device_node *dnp;
  69. const void *prop;
  70. int size;
  71. phys_addr_t paddr;
  72. dnp = of_find_node_by_type(NULL, "open-pic");
  73. if (dnp == NULL)
  74. return;
  75. prop = of_get_property(dnp, "reg", &size);
  76. if (prop == NULL) {
  77. of_node_put(dnp);
  78. return;
  79. }
  80. paddr = (phys_addr_t)of_translate_address(dnp, prop);
  81. mpic = mpic_alloc(dnp, paddr, MPIC_PRIMARY | MPIC_WANTS_RESET,
  82. 16, 32, " OpenPIC ");
  83. of_node_put(dnp);
  84. BUG_ON(mpic == NULL);
  85. /*
  86. * 16 Serial Interrupts followed by 16 Internal Interrupts.
  87. * I2C is the second internal, so it is at 17, 0x11020.
  88. */
  89. mpic_assign_isu(mpic, 0, paddr + 0x10200);
  90. mpic_assign_isu(mpic, 1, paddr + 0x11000);
  91. mpic_init(mpic);
  92. }
  93. static void storcenter_restart(char *cmd)
  94. {
  95. local_irq_disable();
  96. /* Set exception prefix high - to the firmware */
  97. _nmask_and_or_msr(0, MSR_IP);
  98. /* Wait for reset to happen */
  99. for (;;) ;
  100. }
  101. static int __init storcenter_probe(void)
  102. {
  103. unsigned long root = of_get_flat_dt_root();
  104. return of_flat_dt_is_compatible(root, "iomega,storcenter");
  105. }
  106. define_machine(storcenter){
  107. .name = "IOMEGA StorCenter",
  108. .probe = storcenter_probe,
  109. .setup_arch = storcenter_setup_arch,
  110. .init_IRQ = storcenter_init_IRQ,
  111. .get_irq = mpic_get_irq,
  112. .restart = storcenter_restart,
  113. .calibrate_decr = generic_calibrate_decr,
  114. };