linkstation.c 4.7 KB

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