linkstation.c 4.8 KB

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