2 * Architecture specific OF callbacks.
4 #include <linux/bootmem.h>
6 #include <linux/interrupt.h>
7 #include <linux/list.h>
9 #include <linux/of_fdt.h>
10 #include <linux/of_address.h>
11 #include <linux/of_platform.h>
12 #include <linux/slab.h>
14 #include <asm/irq_controller.h>
17 __initdata u64 initial_dtb;
18 char __initdata cmd_line[COMMAND_LINE_SIZE];
19 static LIST_HEAD(irq_domains);
20 static DEFINE_RAW_SPINLOCK(big_irq_lock);
22 int __initdata of_ioapic;
24 void add_interrupt_host(struct irq_domain *ih)
28 raw_spin_lock_irqsave(&big_irq_lock, flags);
29 list_add(&ih->l, &irq_domains);
30 raw_spin_unlock_irqrestore(&big_irq_lock, flags);
33 static struct irq_domain *get_ih_from_node(struct device_node *controller)
35 struct irq_domain *ih, *found = NULL;
38 raw_spin_lock_irqsave(&big_irq_lock, flags);
39 list_for_each_entry(ih, &irq_domains, l) {
40 if (ih->controller == controller) {
45 raw_spin_unlock_irqrestore(&big_irq_lock, flags);
49 unsigned int irq_create_of_mapping(struct device_node *controller,
50 const u32 *intspec, unsigned int intsize)
52 struct irq_domain *ih;
56 ih = get_ih_from_node(controller);
59 ret = ih->xlate(ih, intspec, intsize, &virq, &type);
62 if (type == IRQ_TYPE_NONE)
64 /* set the mask if it is different from current */
65 if (type == (irq_to_desc(virq)->status & IRQF_TRIGGER_MASK))
66 set_irq_type(virq, type);
69 EXPORT_SYMBOL_GPL(irq_create_of_mapping);
71 unsigned long pci_address_to_pio(phys_addr_t address)
74 * The ioport address can be directly used by inX / outX
76 BUG_ON(address >= (1 << 16));
77 return (unsigned long)address;
79 EXPORT_SYMBOL_GPL(pci_address_to_pio);
81 void __init early_init_dt_scan_chosen_arch(unsigned long node)
86 void __init early_init_dt_add_memory_arch(u64 base, u64 size)
91 void * __init early_init_dt_alloc_memory_arch(u64 size, u64 align)
93 return __alloc_bootmem(size, align, __pa(MAX_DMA_ADDRESS));
96 void __init add_dtb(u64 data)
98 initial_dtb = data + offsetof(struct setup_data, data);
101 static void __init dtb_lapic_setup(void)
103 #ifdef CONFIG_X86_LOCAL_APIC
104 if (apic_force_enable())
107 smp_found_config = 1;
109 /* Required for ioapic registration */
110 set_fixmap_nocache(FIX_APIC_BASE, mp_lapic_addr);
111 if (boot_cpu_physical_apicid == -1U)
112 boot_cpu_physical_apicid = read_apic_id();
114 generic_processor_info(boot_cpu_physical_apicid,
115 GET_APIC_VERSION(apic_read(APIC_LVR)));
119 #ifdef CONFIG_X86_IO_APIC
120 static unsigned int ioapic_id;
122 static void __init dtb_add_ioapic(struct device_node *dn)
127 ret = of_address_to_resource(dn, 0, &r);
129 printk(KERN_ERR "Can't obtain address from node %s.\n",
133 mp_register_ioapic(++ioapic_id, r.start, gsi_top);
136 static void __init dtb_ioapic_setup(void)
138 struct device_node *dn;
140 if (!smp_found_config)
143 for_each_compatible_node(dn, NULL, "intel,ce4100-ioapic")
150 printk(KERN_ERR "Error: No information about IO-APIC in OF.\n");
151 smp_found_config = 0;
154 static void __init dtb_ioapic_setup(void) {}
157 static void __init dtb_apic_setup(void)
163 void __init x86_dtb_find_config(void)
166 smp_found_config = 1;
168 printk(KERN_ERR "Missing device tree!.\n");
171 void __init x86_dtb_get_config(unsigned int unused)
179 map_len = max(PAGE_SIZE - (initial_dtb & ~PAGE_MASK),
180 (u64)sizeof(struct boot_param_header));
182 initial_boot_params = early_memremap(initial_dtb, map_len);
183 size = be32_to_cpu(initial_boot_params->totalsize);
184 if (map_len < size) {
185 early_iounmap(initial_boot_params, map_len);
186 initial_boot_params = early_memremap(initial_dtb, size);
190 new_dtb = alloc_bootmem(size);
191 memcpy(new_dtb, initial_boot_params, size);
192 early_iounmap(initial_boot_params, map_len);
194 initial_boot_params = new_dtb;
196 /* root level address cells */
197 of_scan_flat_dt(early_init_dt_scan_root, NULL);
199 unflatten_device_tree();