storcenter.c 2.9 KB

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