linkstation.c 4.5 KB

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