setup.c 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  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. extern void __flush_disable_L1(void);
  26. void amigaone_show_cpuinfo(struct seq_file *m)
  27. {
  28. seq_printf(m, "vendor\t\t: Eyetech Ltd.\n");
  29. }
  30. static int __init amigaone_add_bridge(struct device_node *dev)
  31. {
  32. const u32 *cfg_addr, *cfg_data;
  33. int len;
  34. const int *bus_range;
  35. struct pci_controller *hose;
  36. printk(KERN_INFO "Adding PCI host bridge %s\n", dev->full_name);
  37. cfg_addr = of_get_address(dev, 0, NULL, NULL);
  38. cfg_data = of_get_address(dev, 1, NULL, NULL);
  39. if ((cfg_addr == NULL) || (cfg_data == NULL))
  40. return -ENODEV;
  41. bus_range = of_get_property(dev, "bus-range", &len);
  42. if ((bus_range == NULL) || (len < 2 * sizeof(int)))
  43. printk(KERN_WARNING "Can't get bus-range for %s, assume"
  44. " bus 0\n", dev->full_name);
  45. hose = pcibios_alloc_controller(dev);
  46. if (hose == NULL)
  47. return -ENOMEM;
  48. hose->first_busno = bus_range ? bus_range[0] : 0;
  49. hose->last_busno = bus_range ? bus_range[1] : 0xff;
  50. setup_indirect_pci(hose, cfg_addr[0], cfg_data[0], 0);
  51. /* Interpret the "ranges" property */
  52. /* This also maps the I/O region and sets isa_io/mem_base */
  53. pci_process_bridge_OF_ranges(hose, dev, 1);
  54. return 0;
  55. }
  56. void __init amigaone_setup_arch(void)
  57. {
  58. struct device_node *np;
  59. int phb = -ENODEV;
  60. /* Lookup PCI host bridges. */
  61. for_each_compatible_node(np, "pci", "mai-logic,articia-s")
  62. phb = amigaone_add_bridge(np);
  63. BUG_ON(phb != 0);
  64. if (ppc_md.progress)
  65. ppc_md.progress("Linux/PPC "UTS_RELEASE"\n", 0);
  66. }
  67. void __init amigaone_init_IRQ(void)
  68. {
  69. struct device_node *pic, *np = NULL;
  70. const unsigned long *prop = NULL;
  71. unsigned long int_ack = 0;
  72. /* Search for ISA interrupt controller. */
  73. pic = of_find_compatible_node(NULL, "interrupt-controller",
  74. "pnpPNP,000");
  75. BUG_ON(pic == NULL);
  76. /* Look for interrupt acknowledge address in the PCI root node. */
  77. np = of_find_compatible_node(NULL, "pci", "mai-logic,articia-s");
  78. if (np) {
  79. prop = of_get_property(np, "8259-interrupt-acknowledge", NULL);
  80. if (prop)
  81. int_ack = prop[0];
  82. of_node_put(np);
  83. }
  84. if (int_ack == 0)
  85. printk(KERN_WARNING "Cannot find PCI interrupt acknowledge"
  86. " address, polling\n");
  87. i8259_init(pic, int_ack);
  88. ppc_md.get_irq = i8259_irq;
  89. irq_set_default_host(i8259_get_host());
  90. }
  91. static int __init request_isa_regions(void)
  92. {
  93. request_region(0x00, 0x20, "dma1");
  94. request_region(0x40, 0x20, "timer");
  95. request_region(0x80, 0x10, "dma page reg");
  96. request_region(0xc0, 0x20, "dma2");
  97. return 0;
  98. }
  99. machine_device_initcall(amigaone, request_isa_regions);
  100. void amigaone_restart(char *cmd)
  101. {
  102. local_irq_disable();
  103. /* Flush and disable caches. */
  104. __flush_disable_L1();
  105. /* Set SRR0 to the reset vector and turn on MSR_IP. */
  106. mtspr(SPRN_SRR0, 0xfff00100);
  107. mtspr(SPRN_SRR1, MSR_IP);
  108. /* Do an rfi to jump back to firmware. */
  109. __asm__ __volatile__("rfi" : : : "memory");
  110. /* Not reached. */
  111. while (1);
  112. }
  113. static int __init amigaone_probe(void)
  114. {
  115. unsigned long root = of_get_flat_dt_root();
  116. if (of_flat_dt_is_compatible(root, "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. };