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/pci.h>
  14. #include <linux/initrd.h>
  15. #include <linux/mtd/physmap.h>
  16. #include <asm/time.h>
  17. #include <asm/prom.h>
  18. #include <asm/mpic.h>
  19. #include <asm/mpc10x.h>
  20. #include <asm/pci-bridge.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 int __init linkstation_add_bridge(struct device_node *dev)
  54. {
  55. #ifdef CONFIG_PCI
  56. int len;
  57. struct pci_controller *hose;
  58. const int *bus_range;
  59. printk("Adding PCI host bridge %s\n", dev->full_name);
  60. bus_range = of_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(dev);
  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. setup_indirect_pci(hose, 0xfec00000, 0xfee00000);
  70. /* Interpret the "ranges" property */
  71. /* This also maps the I/O region and sets isa_io/mem_base */
  72. pci_process_bridge_OF_ranges(hose, dev, 1);
  73. #endif
  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. /* Lookup PCI host bridges */
  84. for (np = NULL; (np = of_find_node_by_type(np, "pci")) != NULL;)
  85. linkstation_add_bridge(np);
  86. printk(KERN_INFO "BUFFALO Network Attached Storage Series\n");
  87. printk(KERN_INFO "(C) 2002-2005 BUFFALO INC.\n");
  88. }
  89. /*
  90. * Interrupt setup and service. Interrrupts on the linkstation come
  91. * from the four PCI slots plus onboard 8241 devices: I2C, DUART.
  92. */
  93. static void __init linkstation_init_IRQ(void)
  94. {
  95. struct mpic *mpic;
  96. struct device_node *dnp;
  97. const u32 *prop;
  98. int size;
  99. phys_addr_t paddr;
  100. dnp = of_find_node_by_type(NULL, "open-pic");
  101. if (dnp == NULL)
  102. return;
  103. prop = of_get_property(dnp, "reg", &size);
  104. paddr = (phys_addr_t)of_translate_address(dnp, prop);
  105. mpic = mpic_alloc(dnp, paddr, MPIC_PRIMARY | MPIC_WANTS_RESET, 4, 32, " EPIC ");
  106. BUG_ON(mpic == NULL);
  107. /* PCI IRQs */
  108. mpic_assign_isu(mpic, 0, paddr + 0x10200);
  109. /* I2C */
  110. mpic_assign_isu(mpic, 1, paddr + 0x11000);
  111. /* ttyS0, ttyS1 */
  112. mpic_assign_isu(mpic, 2, paddr + 0x11100);
  113. mpic_init(mpic);
  114. }
  115. extern void avr_uart_configure(void);
  116. extern void avr_uart_send(const char);
  117. static void linkstation_restart(char *cmd)
  118. {
  119. local_irq_disable();
  120. /* Reset system via AVR */
  121. avr_uart_configure();
  122. /* Send reboot command */
  123. avr_uart_send('C');
  124. for(;;) /* Spin until reset happens */
  125. avr_uart_send('G'); /* "kick" */
  126. }
  127. static void linkstation_power_off(void)
  128. {
  129. local_irq_disable();
  130. /* Power down system via AVR */
  131. avr_uart_configure();
  132. /* send shutdown command */
  133. avr_uart_send('E');
  134. for(;;) /* Spin until power-off happens */
  135. avr_uart_send('G'); /* "kick" */
  136. /* NOTREACHED */
  137. }
  138. static void linkstation_halt(void)
  139. {
  140. linkstation_power_off();
  141. /* NOTREACHED */
  142. }
  143. static void linkstation_show_cpuinfo(struct seq_file *m)
  144. {
  145. seq_printf(m, "vendor\t\t: Buffalo Technology\n");
  146. seq_printf(m, "machine\t\t: Linkstation I/Kurobox(HG)\n");
  147. }
  148. static int __init linkstation_probe(void)
  149. {
  150. unsigned long root;
  151. root = of_get_flat_dt_root();
  152. if (!of_flat_dt_is_compatible(root, "linkstation"))
  153. return 0;
  154. return 1;
  155. }
  156. define_machine(linkstation){
  157. .name = "Buffalo Linkstation",
  158. .probe = linkstation_probe,
  159. .setup_arch = linkstation_setup_arch,
  160. .init_IRQ = linkstation_init_IRQ,
  161. .show_cpuinfo = linkstation_show_cpuinfo,
  162. .get_irq = mpic_get_irq,
  163. .restart = linkstation_restart,
  164. .power_off = linkstation_power_off,
  165. .halt = linkstation_halt,
  166. .calibrate_decr = generic_calibrate_decr,
  167. };