|
@@ -11,6 +11,7 @@
|
|
|
#include <linux/of_address.h>
|
|
|
#include <linux/of_platform.h>
|
|
|
#include <linux/of_irq.h>
|
|
|
+#include <linux/libfdt.h>
|
|
|
#include <linux/slab.h>
|
|
|
#include <linux/pci.h>
|
|
|
#include <linux/of_pci.h>
|
|
@@ -130,34 +131,52 @@ static void __init dtb_setup_hpet(void)
|
|
|
#endif
|
|
|
}
|
|
|
|
|
|
+#ifdef CONFIG_X86_LOCAL_APIC
|
|
|
+
|
|
|
+static void __init dtb_cpu_setup(void)
|
|
|
+{
|
|
|
+ struct device_node *dn;
|
|
|
+ u32 apic_id, version;
|
|
|
+ int ret;
|
|
|
+
|
|
|
+ version = GET_APIC_VERSION(apic_read(APIC_LVR));
|
|
|
+ for_each_node_by_type(dn, "cpu") {
|
|
|
+ ret = of_property_read_u32(dn, "reg", &apic_id);
|
|
|
+ if (ret < 0) {
|
|
|
+ pr_warn("%pOF: missing local APIC ID\n", dn);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ generic_processor_info(apic_id, version);
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
static void __init dtb_lapic_setup(void)
|
|
|
{
|
|
|
-#ifdef CONFIG_X86_LOCAL_APIC
|
|
|
struct device_node *dn;
|
|
|
struct resource r;
|
|
|
+ unsigned long lapic_addr = APIC_DEFAULT_PHYS_BASE;
|
|
|
int ret;
|
|
|
|
|
|
dn = of_find_compatible_node(NULL, NULL, "intel,ce4100-lapic");
|
|
|
- if (!dn)
|
|
|
- return;
|
|
|
-
|
|
|
- ret = of_address_to_resource(dn, 0, &r);
|
|
|
- if (WARN_ON(ret))
|
|
|
- return;
|
|
|
+ if (dn) {
|
|
|
+ ret = of_address_to_resource(dn, 0, &r);
|
|
|
+ if (WARN_ON(ret))
|
|
|
+ return;
|
|
|
+ lapic_addr = r.start;
|
|
|
+ }
|
|
|
|
|
|
/* Did the boot loader setup the local APIC ? */
|
|
|
if (!boot_cpu_has(X86_FEATURE_APIC)) {
|
|
|
- if (apic_force_enable(r.start))
|
|
|
+ if (apic_force_enable(lapic_addr))
|
|
|
return;
|
|
|
}
|
|
|
smp_found_config = 1;
|
|
|
pic_mode = 1;
|
|
|
- register_lapic_address(r.start);
|
|
|
- generic_processor_info(boot_cpu_physical_apicid,
|
|
|
- GET_APIC_VERSION(apic_read(APIC_LVR)));
|
|
|
-#endif
|
|
|
+ register_lapic_address(lapic_addr);
|
|
|
}
|
|
|
|
|
|
+#endif /* CONFIG_X86_LOCAL_APIC */
|
|
|
+
|
|
|
#ifdef CONFIG_X86_IO_APIC
|
|
|
static unsigned int ioapic_id;
|
|
|
|
|
@@ -194,19 +213,22 @@ static struct of_ioapic_type of_ioapic_type[] =
|
|
|
static int dt_irqdomain_alloc(struct irq_domain *domain, unsigned int virq,
|
|
|
unsigned int nr_irqs, void *arg)
|
|
|
{
|
|
|
- struct of_phandle_args *irq_data = (void *)arg;
|
|
|
+ struct irq_fwspec *fwspec = (struct irq_fwspec *)arg;
|
|
|
struct of_ioapic_type *it;
|
|
|
struct irq_alloc_info tmp;
|
|
|
+ int type_index;
|
|
|
|
|
|
- if (WARN_ON(irq_data->args_count < 2))
|
|
|
+ if (WARN_ON(fwspec->param_count < 2))
|
|
|
return -EINVAL;
|
|
|
- if (irq_data->args[1] >= ARRAY_SIZE(of_ioapic_type))
|
|
|
+
|
|
|
+ type_index = fwspec->param[1];
|
|
|
+ if (type_index >= ARRAY_SIZE(of_ioapic_type))
|
|
|
return -EINVAL;
|
|
|
|
|
|
- it = &of_ioapic_type[irq_data->args[1]];
|
|
|
+ it = &of_ioapic_type[type_index];
|
|
|
ioapic_set_alloc_attr(&tmp, NUMA_NO_NODE, it->trigger, it->polarity);
|
|
|
tmp.ioapic_id = mpc_ioapic_id(mp_irqdomain_ioapic_idx(domain));
|
|
|
- tmp.ioapic_pin = irq_data->args[0];
|
|
|
+ tmp.ioapic_pin = fwspec->param[0];
|
|
|
|
|
|
return mp_irqdomain_alloc(domain, virq, nr_irqs, &tmp);
|
|
|
}
|
|
@@ -255,7 +277,10 @@ static void __init dtb_ioapic_setup(void) {}
|
|
|
|
|
|
static void __init dtb_apic_setup(void)
|
|
|
{
|
|
|
+#ifdef CONFIG_X86_LOCAL_APIC
|
|
|
dtb_lapic_setup();
|
|
|
+ dtb_cpu_setup();
|
|
|
+#endif
|
|
|
dtb_ioapic_setup();
|
|
|
}
|
|
|
|
|
@@ -270,14 +295,15 @@ static void __init x86_flattree_get_config(void)
|
|
|
|
|
|
map_len = max(PAGE_SIZE - (initial_dtb & ~PAGE_MASK), (u64)128);
|
|
|
|
|
|
- initial_boot_params = dt = early_memremap(initial_dtb, map_len);
|
|
|
- size = of_get_flat_dt_size();
|
|
|
+ dt = early_memremap(initial_dtb, map_len);
|
|
|
+ size = fdt_totalsize(dt);
|
|
|
if (map_len < size) {
|
|
|
early_memunmap(dt, map_len);
|
|
|
- initial_boot_params = dt = early_memremap(initial_dtb, size);
|
|
|
+ dt = early_memremap(initial_dtb, size);
|
|
|
map_len = size;
|
|
|
}
|
|
|
|
|
|
+ early_init_dt_verify(dt);
|
|
|
unflatten_and_copy_device_tree();
|
|
|
early_memunmap(dt, map_len);
|
|
|
}
|