Merge tag 'v3.3.7' into 3.3/master
[zen-stable.git] / arch / powerpc / platforms / amigaone / setup.c
blob03aabc0e16ac2f212ec6d5ae6a78909333e606c6
1 /*
2 * AmigaOne platform setup
4 * Copyright 2008 Gerhard Pircher (gerhard_pircher@gmx.net)
6 * Based on original amigaone_setup.c source code
7 * Copyright 2003 by Hans-Joerg Frieden and Thomas Frieden
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.
15 #include <linux/kernel.h>
16 #include <linux/of.h>
17 #include <linux/of_address.h>
18 #include <linux/seq_file.h>
19 #include <generated/utsrelease.h>
21 #include <asm/machdep.h>
22 #include <asm/cputable.h>
23 #include <asm/pci-bridge.h>
24 #include <asm/i8259.h>
25 #include <asm/time.h>
26 #include <asm/udbg.h>
28 extern void __flush_disable_L1(void);
30 void amigaone_show_cpuinfo(struct seq_file *m)
32 seq_printf(m, "vendor\t\t: Eyetech Ltd.\n");
35 static int __init amigaone_add_bridge(struct device_node *dev)
37 const u32 *cfg_addr, *cfg_data;
38 int len;
39 const int *bus_range;
40 struct pci_controller *hose;
42 printk(KERN_INFO "Adding PCI host bridge %s\n", dev->full_name);
44 cfg_addr = of_get_address(dev, 0, NULL, NULL);
45 cfg_data = of_get_address(dev, 1, NULL, NULL);
46 if ((cfg_addr == NULL) || (cfg_data == NULL))
47 return -ENODEV;
49 bus_range = of_get_property(dev, "bus-range", &len);
50 if ((bus_range == NULL) || (len < 2 * sizeof(int)))
51 printk(KERN_WARNING "Can't get bus-range for %s, assume"
52 " bus 0\n", dev->full_name);
54 hose = pcibios_alloc_controller(dev);
55 if (hose == NULL)
56 return -ENOMEM;
58 hose->first_busno = bus_range ? bus_range[0] : 0;
59 hose->last_busno = bus_range ? bus_range[1] : 0xff;
61 setup_indirect_pci(hose, cfg_addr[0], cfg_data[0], 0);
63 /* Interpret the "ranges" property */
64 /* This also maps the I/O region and sets isa_io/mem_base */
65 pci_process_bridge_OF_ranges(hose, dev, 1);
67 return 0;
70 void __init amigaone_setup_arch(void)
72 struct device_node *np;
73 int phb = -ENODEV;
75 /* Lookup PCI host bridges. */
76 for_each_compatible_node(np, "pci", "mai-logic,articia-s")
77 phb = amigaone_add_bridge(np);
79 BUG_ON(phb != 0);
81 if (ppc_md.progress)
82 ppc_md.progress("Linux/PPC "UTS_RELEASE"\n", 0);
85 void __init amigaone_init_IRQ(void)
87 struct device_node *pic, *np = NULL;
88 const unsigned long *prop = NULL;
89 unsigned long int_ack = 0;
91 /* Search for ISA interrupt controller. */
92 pic = of_find_compatible_node(NULL, "interrupt-controller",
93 "pnpPNP,000");
94 BUG_ON(pic == NULL);
96 /* Look for interrupt acknowledge address in the PCI root node. */
97 np = of_find_compatible_node(NULL, "pci", "mai-logic,articia-s");
98 if (np) {
99 prop = of_get_property(np, "8259-interrupt-acknowledge", NULL);
100 if (prop)
101 int_ack = prop[0];
102 of_node_put(np);
105 if (int_ack == 0)
106 printk(KERN_WARNING "Cannot find PCI interrupt acknowledge"
107 " address, polling\n");
109 i8259_init(pic, int_ack);
110 ppc_md.get_irq = i8259_irq;
111 irq_set_default_host(i8259_get_host());
114 static int __init request_isa_regions(void)
116 request_region(0x00, 0x20, "dma1");
117 request_region(0x40, 0x20, "timer");
118 request_region(0x80, 0x10, "dma page reg");
119 request_region(0xc0, 0x20, "dma2");
121 return 0;
123 machine_device_initcall(amigaone, request_isa_regions);
125 void amigaone_restart(char *cmd)
127 local_irq_disable();
129 /* Flush and disable caches. */
130 __flush_disable_L1();
132 /* Set SRR0 to the reset vector and turn on MSR_IP. */
133 mtspr(SPRN_SRR0, 0xfff00100);
134 mtspr(SPRN_SRR1, MSR_IP);
136 /* Do an rfi to jump back to firmware. */
137 __asm__ __volatile__("rfi" : : : "memory");
139 /* Not reached. */
140 while (1);
143 static int __init amigaone_probe(void)
145 unsigned long root = of_get_flat_dt_root();
147 if (of_flat_dt_is_compatible(root, "eyetech,amigaone")) {
149 * Coherent memory access cause complete system lockup! Thus
150 * disable this CPU feature, even if the CPU needs it.
152 cur_cpu_spec->cpu_features &= ~CPU_FTR_NEED_COHERENT;
154 ISA_DMA_THRESHOLD = 0x00ffffff;
155 DMA_MODE_READ = 0x44;
156 DMA_MODE_WRITE = 0x48;
158 return 1;
161 return 0;
164 define_machine(amigaone) {
165 .name = "AmigaOne",
166 .probe = amigaone_probe,
167 .setup_arch = amigaone_setup_arch,
168 .show_cpuinfo = amigaone_show_cpuinfo,
169 .init_IRQ = amigaone_init_IRQ,
170 .restart = amigaone_restart,
171 .calibrate_decr = generic_calibrate_decr,
172 .progress = udbg_progress,