setup.c 4.2 KB

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