linkstation.c 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. /*
  2. * Board setup routines for the Buffalo Linkstation / Kurobox Platform.
  3. *
  4. * Copyright (C) 2006 G. Liakhovetski (g.liakhovetski@gmx.de)
  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/prom.h>
  17. #include <asm/mpic.h>
  18. #include <asm/pci-bridge.h>
  19. #include "mpc10x.h"
  20. static __initdata struct of_device_id of_bus_ids[] = {
  21. { .type = "soc", },
  22. { .compatible = "simple-bus", },
  23. {},
  24. };
  25. static int __init declare_of_platform_devices(void)
  26. {
  27. of_platform_bus_probe(NULL, of_bus_ids, NULL);
  28. return 0;
  29. }
  30. machine_device_initcall(linkstation, declare_of_platform_devices);
  31. static int __init linkstation_add_bridge(struct device_node *dev)
  32. {
  33. #ifdef CONFIG_PCI
  34. int len;
  35. struct pci_controller *hose;
  36. const int *bus_range;
  37. printk("Adding PCI host bridge %s\n", dev->full_name);
  38. bus_range = of_get_property(dev, "bus-range", &len);
  39. if (bus_range == NULL || len < 2 * sizeof(int))
  40. printk(KERN_WARNING "Can't get bus-range for %s, assume"
  41. " bus 0\n", dev->full_name);
  42. hose = pcibios_alloc_controller(dev);
  43. if (hose == NULL)
  44. return -ENOMEM;
  45. hose->first_busno = bus_range ? bus_range[0] : 0;
  46. hose->last_busno = bus_range ? bus_range[1] : 0xff;
  47. setup_indirect_pci(hose, 0xfec00000, 0xfee00000, 0);
  48. /* Interpret the "ranges" property */
  49. /* This also maps the I/O region and sets isa_io/mem_base */
  50. pci_process_bridge_OF_ranges(hose, dev, 1);
  51. #endif
  52. return 0;
  53. }
  54. static void __init linkstation_setup_arch(void)
  55. {
  56. struct device_node *np;
  57. /* Lookup PCI host bridges */
  58. for_each_compatible_node(np, "pci", "mpc10x-pci")
  59. linkstation_add_bridge(np);
  60. printk(KERN_INFO "BUFFALO Network Attached Storage Series\n");
  61. printk(KERN_INFO "(C) 2002-2005 BUFFALO INC.\n");
  62. }
  63. /*
  64. * Interrupt setup and service. Interrupts on the linkstation come
  65. * from the four PCI slots plus onboard 8241 devices: I2C, DUART.
  66. */
  67. static void __init linkstation_init_IRQ(void)
  68. {
  69. struct mpic *mpic;
  70. struct device_node *dnp;
  71. const u32 *prop;
  72. int size;
  73. phys_addr_t paddr;
  74. dnp = of_find_node_by_type(NULL, "open-pic");
  75. if (dnp == NULL)
  76. return;
  77. prop = of_get_property(dnp, "reg", &size);
  78. paddr = (phys_addr_t)of_translate_address(dnp, prop);
  79. mpic = mpic_alloc(dnp, paddr, MPIC_PRIMARY | MPIC_WANTS_RESET, 4, 32, " EPIC ");
  80. BUG_ON(mpic == NULL);
  81. /* PCI IRQs */
  82. mpic_assign_isu(mpic, 0, paddr + 0x10200);
  83. /* I2C */
  84. mpic_assign_isu(mpic, 1, paddr + 0x11000);
  85. /* ttyS0, ttyS1 */
  86. mpic_assign_isu(mpic, 2, paddr + 0x11100);
  87. mpic_init(mpic);
  88. }
  89. extern void avr_uart_configure(void);
  90. extern void avr_uart_send(const char);
  91. static void linkstation_restart(char *cmd)
  92. {
  93. local_irq_disable();
  94. /* Reset system via AVR */
  95. avr_uart_configure();
  96. /* Send reboot command */
  97. avr_uart_send('C');
  98. for(;;) /* Spin until reset happens */
  99. avr_uart_send('G'); /* "kick" */
  100. }
  101. static void linkstation_power_off(void)
  102. {
  103. local_irq_disable();
  104. /* Power down system via AVR */
  105. avr_uart_configure();
  106. /* send shutdown command */
  107. avr_uart_send('E');
  108. for(;;) /* Spin until power-off happens */
  109. avr_uart_send('G'); /* "kick" */
  110. /* NOTREACHED */
  111. }
  112. static void linkstation_halt(void)
  113. {
  114. linkstation_power_off();
  115. /* NOTREACHED */
  116. }
  117. static void linkstation_show_cpuinfo(struct seq_file *m)
  118. {
  119. seq_printf(m, "vendor\t\t: Buffalo Technology\n");
  120. seq_printf(m, "machine\t\t: Linkstation I/Kurobox(HG)\n");
  121. }
  122. static int __init linkstation_probe(void)
  123. {
  124. unsigned long root;
  125. root = of_get_flat_dt_root();
  126. if (!of_flat_dt_is_compatible(root, "linkstation"))
  127. return 0;
  128. return 1;
  129. }
  130. define_machine(linkstation){
  131. .name = "Buffalo Linkstation",
  132. .probe = linkstation_probe,
  133. .setup_arch = linkstation_setup_arch,
  134. .init_IRQ = linkstation_init_IRQ,
  135. .show_cpuinfo = linkstation_show_cpuinfo,
  136. .get_irq = mpic_get_irq,
  137. .restart = linkstation_restart,
  138. .power_off = linkstation_power_off,
  139. .halt = linkstation_halt,
  140. .calibrate_decr = generic_calibrate_decr,
  141. };