Poonam Aggrwal | fb8e3e1 | 2009-08-07 21:05:16 +0530 | [diff] [blame] | 1 | /* |
| 2 | * MPC85xx RDB Board Setup |
| 3 | * |
| 4 | * Copyright 2009 Freescale Semiconductor Inc. |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or modify it |
| 7 | * under the terms of the GNU General Public License as published by the |
| 8 | * Free Software Foundation; either version 2 of the License, or (at your |
| 9 | * option) any later version. |
| 10 | */ |
| 11 | |
| 12 | #include <linux/stddef.h> |
| 13 | #include <linux/kernel.h> |
| 14 | #include <linux/pci.h> |
| 15 | #include <linux/kdev_t.h> |
| 16 | #include <linux/delay.h> |
| 17 | #include <linux/seq_file.h> |
| 18 | #include <linux/interrupt.h> |
| 19 | #include <linux/of_platform.h> |
| 20 | |
| 21 | #include <asm/system.h> |
| 22 | #include <asm/time.h> |
| 23 | #include <asm/machdep.h> |
| 24 | #include <asm/pci-bridge.h> |
| 25 | #include <mm/mmu_decl.h> |
| 26 | #include <asm/prom.h> |
| 27 | #include <asm/udbg.h> |
| 28 | #include <asm/mpic.h> |
| 29 | |
| 30 | #include <sysdev/fsl_soc.h> |
| 31 | #include <sysdev/fsl_pci.h> |
| 32 | |
Dmitry Eremin-Solenikov | 543a07b | 2011-11-17 21:56:16 +0400 | [diff] [blame^] | 33 | #include "mpc85xx.h" |
| 34 | |
Poonam Aggrwal | fb8e3e1 | 2009-08-07 21:05:16 +0530 | [diff] [blame] | 35 | #undef DEBUG |
| 36 | |
| 37 | #ifdef DEBUG |
| 38 | #define DBG(fmt, args...) printk(KERN_ERR "%s: " fmt, __func__, ## args) |
| 39 | #else |
| 40 | #define DBG(fmt, args...) |
| 41 | #endif |
| 42 | |
| 43 | |
| 44 | void __init mpc85xx_rdb_pic_init(void) |
| 45 | { |
| 46 | struct mpic *mpic; |
| 47 | struct resource r; |
| 48 | struct device_node *np; |
Poonam Aggrwal | dc2e673 | 2009-09-19 22:43:56 +0530 | [diff] [blame] | 49 | unsigned long root = of_get_flat_dt_root(); |
Poonam Aggrwal | fb8e3e1 | 2009-08-07 21:05:16 +0530 | [diff] [blame] | 50 | |
| 51 | np = of_find_node_by_type(NULL, "open-pic"); |
| 52 | if (np == NULL) { |
| 53 | printk(KERN_ERR "Could not find open-pic node\n"); |
| 54 | return; |
| 55 | } |
| 56 | |
| 57 | if (of_address_to_resource(np, 0, &r)) { |
| 58 | printk(KERN_ERR "Failed to map mpic register space\n"); |
| 59 | of_node_put(np); |
| 60 | return; |
| 61 | } |
| 62 | |
Fabio Baltieri | a63e23b | 2011-07-12 09:49:43 +0200 | [diff] [blame] | 63 | if (of_flat_dt_is_compatible(root, "fsl,MPC85XXRDB-CAMP")) { |
Poonam Aggrwal | dc2e673 | 2009-09-19 22:43:56 +0530 | [diff] [blame] | 64 | mpic = mpic_alloc(np, r.start, |
| 65 | MPIC_PRIMARY | |
Fabio Baltieri | a63e23b | 2011-07-12 09:49:43 +0200 | [diff] [blame] | 66 | MPIC_BIG_ENDIAN | MPIC_BROKEN_FRR_NIRQS | |
| 67 | MPIC_SINGLE_DEST_CPU, |
Poonam Aggrwal | dc2e673 | 2009-09-19 22:43:56 +0530 | [diff] [blame] | 68 | 0, 256, " OpenPIC "); |
| 69 | } else { |
| 70 | mpic = mpic_alloc(np, r.start, |
Poonam Aggrwal | fb8e3e1 | 2009-08-07 21:05:16 +0530 | [diff] [blame] | 71 | MPIC_PRIMARY | MPIC_WANTS_RESET | |
| 72 | MPIC_BIG_ENDIAN | MPIC_BROKEN_FRR_NIRQS | |
| 73 | MPIC_SINGLE_DEST_CPU, |
| 74 | 0, 256, " OpenPIC "); |
Poonam Aggrwal | dc2e673 | 2009-09-19 22:43:56 +0530 | [diff] [blame] | 75 | } |
Poonam Aggrwal | fb8e3e1 | 2009-08-07 21:05:16 +0530 | [diff] [blame] | 76 | |
| 77 | BUG_ON(mpic == NULL); |
| 78 | of_node_put(np); |
| 79 | |
| 80 | mpic_init(mpic); |
| 81 | |
| 82 | } |
| 83 | |
| 84 | /* |
| 85 | * Setup the architecture |
| 86 | */ |
| 87 | #ifdef CONFIG_SMP |
| 88 | extern void __init mpc85xx_smp_init(void); |
| 89 | #endif |
| 90 | static void __init mpc85xx_rdb_setup_arch(void) |
| 91 | { |
| 92 | #ifdef CONFIG_PCI |
| 93 | struct device_node *np; |
| 94 | #endif |
| 95 | |
| 96 | if (ppc_md.progress) |
| 97 | ppc_md.progress("mpc85xx_rdb_setup_arch()", 0); |
| 98 | |
| 99 | #ifdef CONFIG_PCI |
| 100 | for_each_node_by_type(np, "pci") { |
| 101 | if (of_device_is_compatible(np, "fsl,mpc8548-pcie")) |
| 102 | fsl_add_bridge(np, 0); |
| 103 | } |
| 104 | |
| 105 | #endif |
| 106 | |
| 107 | #ifdef CONFIG_SMP |
| 108 | mpc85xx_smp_init(); |
| 109 | #endif |
| 110 | |
| 111 | printk(KERN_INFO "MPC85xx RDB board from Freescale Semiconductor\n"); |
| 112 | } |
| 113 | |
| 114 | static struct of_device_id __initdata mpc85xxrdb_ids[] = { |
| 115 | { .type = "soc", }, |
| 116 | { .compatible = "soc", }, |
| 117 | { .compatible = "simple-bus", }, |
| 118 | { .compatible = "gianfar", }, |
| 119 | {}, |
| 120 | }; |
| 121 | |
| 122 | static int __init mpc85xxrdb_publish_devices(void) |
| 123 | { |
| 124 | return of_platform_bus_probe(NULL, mpc85xxrdb_ids, NULL); |
| 125 | } |
| 126 | machine_device_initcall(p2020_rdb, mpc85xxrdb_publish_devices); |
Poonam Aggrwal | 52dffd7 | 2009-09-25 09:50:28 +0530 | [diff] [blame] | 127 | machine_device_initcall(p1020_rdb, mpc85xxrdb_publish_devices); |
Poonam Aggrwal | fb8e3e1 | 2009-08-07 21:05:16 +0530 | [diff] [blame] | 128 | |
| 129 | /* |
| 130 | * Called very early, device-tree isn't unflattened |
| 131 | */ |
| 132 | static int __init p2020_rdb_probe(void) |
| 133 | { |
| 134 | unsigned long root = of_get_flat_dt_root(); |
| 135 | |
| 136 | if (of_flat_dt_is_compatible(root, "fsl,P2020RDB")) |
| 137 | return 1; |
| 138 | return 0; |
| 139 | } |
| 140 | |
Poonam Aggrwal | 52dffd7 | 2009-09-25 09:50:28 +0530 | [diff] [blame] | 141 | static int __init p1020_rdb_probe(void) |
| 142 | { |
| 143 | unsigned long root = of_get_flat_dt_root(); |
| 144 | |
| 145 | if (of_flat_dt_is_compatible(root, "fsl,P1020RDB")) |
| 146 | return 1; |
| 147 | return 0; |
| 148 | } |
| 149 | |
Poonam Aggrwal | fb8e3e1 | 2009-08-07 21:05:16 +0530 | [diff] [blame] | 150 | define_machine(p2020_rdb) { |
| 151 | .name = "P2020 RDB", |
| 152 | .probe = p2020_rdb_probe, |
| 153 | .setup_arch = mpc85xx_rdb_setup_arch, |
| 154 | .init_IRQ = mpc85xx_rdb_pic_init, |
| 155 | #ifdef CONFIG_PCI |
| 156 | .pcibios_fixup_bus = fsl_pcibios_fixup_bus, |
| 157 | #endif |
| 158 | .get_irq = mpic_get_irq, |
| 159 | .restart = fsl_rstcr_restart, |
| 160 | .calibrate_decr = generic_calibrate_decr, |
| 161 | .progress = udbg_progress, |
| 162 | }; |
Poonam Aggrwal | 52dffd7 | 2009-09-25 09:50:28 +0530 | [diff] [blame] | 163 | |
| 164 | define_machine(p1020_rdb) { |
| 165 | .name = "P1020 RDB", |
| 166 | .probe = p1020_rdb_probe, |
| 167 | .setup_arch = mpc85xx_rdb_setup_arch, |
| 168 | .init_IRQ = mpc85xx_rdb_pic_init, |
| 169 | #ifdef CONFIG_PCI |
| 170 | .pcibios_fixup_bus = fsl_pcibios_fixup_bus, |
| 171 | #endif |
| 172 | .get_irq = mpic_get_irq, |
| 173 | .restart = fsl_rstcr_restart, |
| 174 | .calibrate_decr = generic_calibrate_decr, |
| 175 | .progress = udbg_progress, |
| 176 | }; |