linkstation.c 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. /*
  2. * Board setup routines for the Buffalo Linkstation / Kurobox Platform.
  3. *
  4. * Copyright (C) 2006 G. Liakhovetski ([email protected])
  5. *
  6. * Based on sandpoint.c by Mark A. Greer
  7. *
  8. * This file is licensed under the terms of the GNU General Public License
  9. * version 2. This program is licensed "as is" without any warranty of
  10. * any kind, whether express or implied.
  11. */
  12. #include <linux/kernel.h>
  13. #include <linux/initrd.h>
  14. #include <linux/of_platform.h>
  15. #include <asm/time.h>
  16. #include <asm/mpic.h>
  17. #include <asm/pci-bridge.h>
  18. #include "mpc10x.h"
  19. static const struct of_device_id of_bus_ids[] __initconst = {
  20. { .type = "soc", },
  21. { .compatible = "simple-bus", },
  22. {},
  23. };
  24. static int __init declare_of_platform_devices(void)
  25. {
  26. of_platform_bus_probe(NULL, of_bus_ids, NULL);
  27. return 0;
  28. }
  29. machine_device_initcall(linkstation, declare_of_platform_devices);
  30. static int __init linkstation_add_bridge(struct device_node *dev)
  31. {
  32. #ifdef CONFIG_PCI
  33. int len;
  34. struct pci_controller *hose;
  35. const int *bus_range;
  36. printk("Adding PCI host bridge %pOF\n", dev);
  37. bus_range = of_get_property(dev, "bus-range", &len);
  38. if (bus_range == NULL || len < 2 * sizeof(int))
  39. printk(KERN_WARNING "Can't get bus-range for %pOF, assume"
  40. " bus 0\n", dev);
  41. hose = pcibios_alloc_controller(dev);
  42. if (hose == NULL)
  43. return -ENOMEM;
  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, 0xfec00000, 0xfee00000, 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 linkstation_setup_arch(void)
  54. {
  55. printk(KERN_INFO "BUFFALO Network Attached Storage Series\n");
  56. printk(KERN_INFO "(C) 2002-2005 BUFFALO INC.\n");
  57. }
  58. static void __init linkstation_setup_pci(void)
  59. {
  60. struct device_node *np;
  61. /* Lookup PCI host bridges */
  62. for_each_compatible_node(np, "pci", "mpc10x-pci")
  63. linkstation_add_bridge(np);
  64. }
  65. /*
  66. * Interrupt setup and service. Interrupts on the linkstation come
  67. * from the four PCI slots plus onboard 8241 devices: I2C, DUART.
  68. */
  69. static void __init linkstation_init_IRQ(void)
  70. {
  71. struct mpic *mpic;
  72. mpic = mpic_alloc(NULL, 0, 0, 4, 0, " EPIC ");
  73. BUG_ON(mpic == NULL);
  74. /* PCI IRQs */
  75. mpic_assign_isu(mpic, 0, mpic->paddr + 0x10200);
  76. /* I2C */
  77. mpic_assign_isu(mpic, 1, mpic->paddr + 0x11000);
  78. /* ttyS0, ttyS1 */
  79. mpic_assign_isu(mpic, 2, mpic->paddr + 0x11100);
  80. mpic_init(mpic);
  81. }
  82. extern void avr_uart_configure(void);
  83. extern void avr_uart_send(const char);
  84. static void __noreturn linkstation_restart(char *cmd)
  85. {
  86. local_irq_disable();
  87. /* Reset system via AVR */
  88. avr_uart_configure();
  89. /* Send reboot command */
  90. avr_uart_send('C');
  91. for(;;) /* Spin until reset happens */
  92. avr_uart_send('G'); /* "kick" */
  93. }
  94. static void __noreturn linkstation_power_off(void)
  95. {
  96. local_irq_disable();
  97. /* Power down system via AVR */
  98. avr_uart_configure();
  99. /* send shutdown command */
  100. avr_uart_send('E');
  101. for(;;) /* Spin until power-off happens */
  102. avr_uart_send('G'); /* "kick" */
  103. /* NOTREACHED */
  104. }
  105. static void __noreturn linkstation_halt(void)
  106. {
  107. linkstation_power_off();
  108. /* NOTREACHED */
  109. }
  110. static void linkstation_show_cpuinfo(struct seq_file *m)
  111. {
  112. seq_printf(m, "vendor\t\t: Buffalo Technology\n");
  113. seq_printf(m, "machine\t\t: Linkstation I/Kurobox(HG)\n");
  114. }
  115. static int __init linkstation_probe(void)
  116. {
  117. if (!of_machine_is_compatible("linkstation"))
  118. return 0;
  119. pm_power_off = linkstation_power_off;
  120. return 1;
  121. }
  122. define_machine(linkstation){
  123. .name = "Buffalo Linkstation",
  124. .probe = linkstation_probe,
  125. .setup_arch = linkstation_setup_arch,
  126. .discover_phbs = linkstation_setup_pci,
  127. .init_IRQ = linkstation_init_IRQ,
  128. .show_cpuinfo = linkstation_show_cpuinfo,
  129. .get_irq = mpic_get_irq,
  130. .restart = linkstation_restart,
  131. .halt = linkstation_halt,
  132. .calibrate_decr = generic_calibrate_decr,
  133. };