setup.c 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. /*
  2. * AmigaOne platform setup
  3. *
  4. * Copyright 2008 Gerhard Pircher (gerhard_pircher@gmx.net)
  5. *
  6. * Based on original amigaone_setup.c source code
  7. * Copyright 2003 by Hans-Joerg Frieden and Thomas Frieden
  8. *
  9. * This program is free software; you can redistribute it and/or modify it
  10. * under the terms of the GNU General Public License as published by the
  11. * Free Software Foundation; either version 2 of the License, or (at your
  12. * option) any later version.
  13. */
  14. #include <linux/kernel.h>
  15. #include <linux/of.h>
  16. #include <linux/of_address.h>
  17. #include <linux/seq_file.h>
  18. #include <generated/utsrelease.h>
  19. #include <asm/machdep.h>
  20. #include <asm/cputable.h>
  21. #include <asm/pci-bridge.h>
  22. #include <asm/i8259.h>
  23. #include <asm/time.h>
  24. #include <asm/udbg.h>
  25. #include <asm/dma.h>
  26. extern void __flush_disable_L1(void);
  27. void amigaone_show_cpuinfo(struct seq_file *m)
  28. {
  29. seq_printf(m, "vendor\t\t: Eyetech Ltd.\n");
  30. }
  31. static int __init amigaone_add_bridge(struct device_node *dev)
  32. {
  33. const u32 *cfg_addr, *cfg_data;
  34. int len;
  35. const int *bus_range;
  36. struct pci_controller *hose;
  37. printk(KERN_INFO "Adding PCI host bridge %s\n", dev->full_name);
  38. cfg_addr = of_get_address(dev, 0, NULL, NULL);
  39. cfg_data = of_get_address(dev, 1, NULL, NULL);
  40. if ((cfg_addr == NULL) || (cfg_data == NULL))
  41. return -ENODEV;
  42. bus_range = of_get_property(dev, "bus-range", &len);
  43. if ((bus_range == NULL) || (len < 2 * sizeof(int)))
  44. printk(KERN_WARNING "Can't get bus-range for %s, assume"
  45. " bus 0\n", dev->full_name);
  46. hose = pcibios_alloc_controller(dev);
  47. if (hose == NULL)
  48. return -ENOMEM;
  49. hose->first_busno = bus_range ? bus_range[0] : 0;
  50. hose->last_busno = bus_range ? bus_range[1] : 0xff;
  51. setup_indirect_pci(hose, cfg_addr[0], cfg_data[0], 0);
  52. /* Interpret the "ranges" property */
  53. /* This also maps the I/O region and sets isa_io/mem_base */
  54. pci_process_bridge_OF_ranges(hose, dev, 1);
  55. return 0;
  56. }
  57. void __init amigaone_setup_arch(void)
  58. {
  59. struct device_node *np;
  60. int phb = -ENODEV;
  61. /* Lookup PCI host bridges. */
  62. for_each_compatible_node(np, "pci", "mai-logic,articia-s")
  63. phb = amigaone_add_bridge(np);
  64. BUG_ON(phb != 0);
  65. if (ppc_md.progress)
  66. ppc_md.progress("Linux/PPC "UTS_RELEASE"\n", 0);
  67. }
  68. void __init amigaone_init_IRQ(void)
  69. {
  70. struct device_node *pic, *np = NULL;
  71. const unsigned long *prop = NULL;
  72. unsigned long int_ack = 0;
  73. /* Search for ISA interrupt controller. */
  74. pic = of_find_compatible_node(NULL, "interrupt-controller",
  75. "pnpPNP,000");
  76. BUG_ON(pic == NULL);
  77. /* Look for interrupt acknowledge address in the PCI root node. */
  78. np = of_find_compatible_node(NULL, "pci", "mai-logic,articia-s");
  79. if (np) {
  80. prop = of_get_property(np, "8259-interrupt-acknowledge", NULL);
  81. if (prop)
  82. int_ack = prop[0];
  83. of_node_put(np);
  84. }
  85. if (int_ack == 0)
  86. printk(KERN_WARNING "Cannot find PCI interrupt acknowledge"
  87. " address, polling\n");
  88. i8259_init(pic, int_ack);
  89. ppc_md.get_irq = i8259_irq;
  90. irq_set_default_host(i8259_get_host());
  91. }
  92. static int __init request_isa_regions(void)
  93. {
  94. request_region(0x00, 0x20, "dma1");
  95. request_region(0x40, 0x20, "timer");
  96. request_region(0x80, 0x10, "dma page reg");
  97. request_region(0xc0, 0x20, "dma2");
  98. return 0;
  99. }
  100. machine_device_initcall(amigaone, request_isa_regions);
  101. void __noreturn amigaone_restart(char *cmd)
  102. {
  103. local_irq_disable();
  104. /* Flush and disable caches. */
  105. __flush_disable_L1();
  106. /* Set SRR0 to the reset vector and turn on MSR_IP. */
  107. mtspr(SPRN_SRR0, 0xfff00100);
  108. mtspr(SPRN_SRR1, MSR_IP);
  109. /* Do an rfi to jump back to firmware. */
  110. __asm__ __volatile__("rfi" : : : "memory");
  111. /* Not reached. */
  112. while (1);
  113. }
  114. static int __init amigaone_probe(void)
  115. {
  116. if (of_machine_is_compatible("eyetech,amigaone")) {
  117. /*
  118. * Coherent memory access cause complete system lockup! Thus
  119. * disable this CPU feature, even if the CPU needs it.
  120. */
  121. cur_cpu_spec->cpu_features &= ~CPU_FTR_NEED_COHERENT;
  122. ISA_DMA_THRESHOLD = 0x00ffffff;
  123. DMA_MODE_READ = 0x44;
  124. DMA_MODE_WRITE = 0x48;
  125. return 1;
  126. }
  127. return 0;
  128. }
  129. define_machine(amigaone) {
  130. .name = "AmigaOne",
  131. .probe = amigaone_probe,
  132. .setup_arch = amigaone_setup_arch,
  133. .show_cpuinfo = amigaone_show_cpuinfo,
  134. .init_IRQ = amigaone_init_IRQ,
  135. .restart = amigaone_restart,
  136. .calibrate_decr = generic_calibrate_decr,
  137. .progress = udbg_progress,
  138. };