1
2
3
4
5
6
7
8
9
10
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
17#include <asm/machdep.h>
18#include <asm/cputable.h>
19#include <asm/pci-bridge.h>
20#include <asm/i8259.h>
21#include <asm/time.h>
22#include <asm/udbg.h>
23#include <asm/dma.h>
24
25extern void __flush_disable_L1(void);
26
27void amigaone_show_cpuinfo(struct seq_file *m)
28{
29 seq_printf(m, "vendor\t\t: Eyetech Ltd.\n");
30}
31
32static int __init amigaone_add_bridge(struct device_node *dev)
33{
34 const u32 *cfg_addr, *cfg_data;
35 int len;
36 const int *bus_range;
37 struct pci_controller *hose;
38
39 printk(KERN_INFO "Adding PCI host bridge %pOF\n", dev);
40
41 cfg_addr = of_get_address(dev, 0, NULL, NULL);
42 cfg_data = of_get_address(dev, 1, NULL, NULL);
43 if ((cfg_addr == NULL) || (cfg_data == NULL))
44 return -ENODEV;
45
46 bus_range = of_get_property(dev, "bus-range", &len);
47 if ((bus_range == NULL) || (len < 2 * sizeof(int)))
48 printk(KERN_WARNING "Can't get bus-range for %pOF, assume"
49 " bus 0\n", dev);
50
51 hose = pcibios_alloc_controller(dev);
52 if (hose == NULL)
53 return -ENOMEM;
54
55 hose->first_busno = bus_range ? bus_range[0] : 0;
56 hose->last_busno = bus_range ? bus_range[1] : 0xff;
57
58 setup_indirect_pci(hose, cfg_addr[0], cfg_data[0], 0);
59
60
61
62 pci_process_bridge_OF_ranges(hose, dev, 1);
63
64 return 0;
65}
66
67void __init amigaone_setup_arch(void)
68{
69 struct device_node *np;
70 int phb = -ENODEV;
71
72
73 for_each_compatible_node(np, "pci", "mai-logic,articia-s")
74 phb = amigaone_add_bridge(np);
75
76 BUG_ON(phb != 0);
77
78 if (ppc_md.progress)
79 ppc_md.progress("Linux/PPC "UTS_RELEASE"\n", 0);
80}
81
82void __init amigaone_init_IRQ(void)
83{
84 struct device_node *pic, *np = NULL;
85 const unsigned long *prop = NULL;
86 unsigned long int_ack = 0;
87
88
89 pic = of_find_compatible_node(NULL, "interrupt-controller",
90 "pnpPNP,000");
91 BUG_ON(pic == NULL);
92
93
94 np = of_find_compatible_node(NULL, "pci", "mai-logic,articia-s");
95 if (np) {
96 prop = of_get_property(np, "8259-interrupt-acknowledge", NULL);
97 if (prop)
98 int_ack = prop[0];
99 of_node_put(np);
100 }
101
102 if (int_ack == 0)
103 printk(KERN_WARNING "Cannot find PCI interrupt acknowledge"
104 " address, polling\n");
105
106 i8259_init(pic, int_ack);
107 ppc_md.get_irq = i8259_irq;
108 irq_set_default_host(i8259_get_host());
109}
110
111static int __init request_isa_regions(void)
112{
113 request_region(0x00, 0x20, "dma1");
114 request_region(0x40, 0x20, "timer");
115 request_region(0x80, 0x10, "dma page reg");
116 request_region(0xc0, 0x20, "dma2");
117
118 return 0;
119}
120machine_device_initcall(amigaone, request_isa_regions);
121
122void __noreturn amigaone_restart(char *cmd)
123{
124 local_irq_disable();
125
126
127 __flush_disable_L1();
128
129
130 mtspr(SPRN_SRR0, 0xfff00100);
131 mtspr(SPRN_SRR1, MSR_IP);
132
133
134 __asm__ __volatile__("rfi" : : : "memory");
135
136
137 while (1);
138}
139
140static int __init amigaone_probe(void)
141{
142 if (of_machine_is_compatible("eyetech,amigaone")) {
143
144
145
146
147 cur_cpu_spec->cpu_features &= ~CPU_FTR_NEED_COHERENT;
148
149 ISA_DMA_THRESHOLD = 0x00ffffff;
150 DMA_MODE_READ = 0x44;
151 DMA_MODE_WRITE = 0x48;
152
153 return 1;
154 }
155
156 return 0;
157}
158
159define_machine(amigaone) {
160 .name = "AmigaOne",
161 .probe = amigaone_probe,
162 .setup_arch = amigaone_setup_arch,
163 .show_cpuinfo = amigaone_show_cpuinfo,
164 .init_IRQ = amigaone_init_IRQ,
165 .restart = amigaone_restart,
166 .calibrate_decr = generic_calibrate_decr,
167 .progress = udbg_progress,
168};
169