setup.c 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. // SPDX-License-Identifier: GPL-2.0-or-later
  2. /*
  3. * AmigaOne platform setup
  4. *
  5. * Copyright 2008 Gerhard Pircher ([email protected])
  6. *
  7. * Based on original amigaone_setup.c source code
  8. * Copyright 2003 by Hans-Joerg Frieden and Thomas Frieden
  9. */
  10. #include <linux/irqdomain.h>
  11. #include <linux/kernel.h>
  12. #include <linux/of.h>
  13. #include <linux/of_address.h>
  14. #include <linux/seq_file.h>
  15. #include <generated/utsrelease.h>
  16. #include <asm/machdep.h>
  17. #include <asm/cputable.h>
  18. #include <asm/pci-bridge.h>
  19. #include <asm/i8259.h>
  20. #include <asm/time.h>
  21. #include <asm/udbg.h>
  22. #include <asm/dma.h>
  23. extern void __flush_disable_L1(void);
  24. void amigaone_show_cpuinfo(struct seq_file *m)
  25. {
  26. seq_printf(m, "vendor\t\t: Eyetech Ltd.\n");
  27. }
  28. static int __init amigaone_add_bridge(struct device_node *dev)
  29. {
  30. const u32 *cfg_addr, *cfg_data;
  31. int len;
  32. const int *bus_range;
  33. struct pci_controller *hose;
  34. printk(KERN_INFO "Adding PCI host bridge %pOF\n", dev);
  35. cfg_addr = of_get_address(dev, 0, NULL, NULL);
  36. cfg_data = of_get_address(dev, 1, NULL, NULL);
  37. if ((cfg_addr == NULL) || (cfg_data == NULL))
  38. return -ENODEV;
  39. bus_range = of_get_property(dev, "bus-range", &len);
  40. if ((bus_range == NULL) || (len < 2 * sizeof(int)))
  41. printk(KERN_WARNING "Can't get bus-range for %pOF, assume"
  42. " bus 0\n", dev);
  43. hose = pcibios_alloc_controller(dev);
  44. if (hose == NULL)
  45. return -ENOMEM;
  46. hose->first_busno = bus_range ? bus_range[0] : 0;
  47. hose->last_busno = bus_range ? bus_range[1] : 0xff;
  48. setup_indirect_pci(hose, cfg_addr[0], cfg_data[0], 0);
  49. /* Interpret the "ranges" property */
  50. /* This also maps the I/O region and sets isa_io/mem_base */
  51. pci_process_bridge_OF_ranges(hose, dev, 1);
  52. return 0;
  53. }
  54. void __init amigaone_setup_arch(void)
  55. {
  56. if (ppc_md.progress)
  57. ppc_md.progress("Linux/PPC "UTS_RELEASE"\n", 0);
  58. }
  59. static void __init amigaone_discover_phbs(void)
  60. {
  61. struct device_node *np;
  62. int phb = -ENODEV;
  63. /* Lookup PCI host bridges. */
  64. for_each_compatible_node(np, "pci", "mai-logic,articia-s")
  65. phb = amigaone_add_bridge(np);
  66. BUG_ON(phb != 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. DMA_MODE_READ = 0x44;
  123. DMA_MODE_WRITE = 0x48;
  124. return 1;
  125. }
  126. return 0;
  127. }
  128. define_machine(amigaone) {
  129. .name = "AmigaOne",
  130. .probe = amigaone_probe,
  131. .setup_arch = amigaone_setup_arch,
  132. .discover_phbs = amigaone_discover_phbs,
  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. };