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> |
Kyle Moffett | 582d3e0 | 2011-12-02 06:27:58 +0000 | [diff] [blame^] | 32 | #include "smp.h" |
Poonam Aggrwal | fb8e3e1 | 2009-08-07 21:05:16 +0530 | [diff] [blame] | 33 | |
Dmitry Eremin-Solenikov | 543a07b | 2011-11-17 21:56:16 +0400 | [diff] [blame] | 34 | #include "mpc85xx.h" |
| 35 | |
Poonam Aggrwal | fb8e3e1 | 2009-08-07 21:05:16 +0530 | [diff] [blame] | 36 | #undef DEBUG |
| 37 | |
| 38 | #ifdef DEBUG |
| 39 | #define DBG(fmt, args...) printk(KERN_ERR "%s: " fmt, __func__, ## args) |
| 40 | #else |
| 41 | #define DBG(fmt, args...) |
| 42 | #endif |
| 43 | |
| 44 | |
| 45 | void __init mpc85xx_rdb_pic_init(void) |
| 46 | { |
| 47 | struct mpic *mpic; |
| 48 | struct resource r; |
| 49 | struct device_node *np; |
Poonam Aggrwal | dc2e673 | 2009-09-19 22:43:56 +0530 | [diff] [blame] | 50 | unsigned long root = of_get_flat_dt_root(); |
Poonam Aggrwal | fb8e3e1 | 2009-08-07 21:05:16 +0530 | [diff] [blame] | 51 | |
| 52 | np = of_find_node_by_type(NULL, "open-pic"); |
| 53 | if (np == NULL) { |
| 54 | printk(KERN_ERR "Could not find open-pic node\n"); |
| 55 | return; |
| 56 | } |
| 57 | |
| 58 | if (of_address_to_resource(np, 0, &r)) { |
| 59 | printk(KERN_ERR "Failed to map mpic register space\n"); |
| 60 | of_node_put(np); |
| 61 | return; |
| 62 | } |
| 63 | |
Fabio Baltieri | a63e23b | 2011-07-12 09:49:43 +0200 | [diff] [blame] | 64 | if (of_flat_dt_is_compatible(root, "fsl,MPC85XXRDB-CAMP")) { |
Poonam Aggrwal | dc2e673 | 2009-09-19 22:43:56 +0530 | [diff] [blame] | 65 | mpic = mpic_alloc(np, r.start, |
| 66 | MPIC_PRIMARY | |
Fabio Baltieri | a63e23b | 2011-07-12 09:49:43 +0200 | [diff] [blame] | 67 | MPIC_BIG_ENDIAN | MPIC_BROKEN_FRR_NIRQS | |
| 68 | MPIC_SINGLE_DEST_CPU, |
Poonam Aggrwal | dc2e673 | 2009-09-19 22:43:56 +0530 | [diff] [blame] | 69 | 0, 256, " OpenPIC "); |
| 70 | } else { |
| 71 | mpic = mpic_alloc(np, r.start, |
Poonam Aggrwal | fb8e3e1 | 2009-08-07 21:05:16 +0530 | [diff] [blame] | 72 | MPIC_PRIMARY | MPIC_WANTS_RESET | |
| 73 | MPIC_BIG_ENDIAN | MPIC_BROKEN_FRR_NIRQS | |
| 74 | MPIC_SINGLE_DEST_CPU, |
| 75 | 0, 256, " OpenPIC "); |
Poonam Aggrwal | dc2e673 | 2009-09-19 22:43:56 +0530 | [diff] [blame] | 76 | } |
Poonam Aggrwal | fb8e3e1 | 2009-08-07 21:05:16 +0530 | [diff] [blame] | 77 | |
| 78 | BUG_ON(mpic == NULL); |
| 79 | of_node_put(np); |
| 80 | |
| 81 | mpic_init(mpic); |
| 82 | |
| 83 | } |
| 84 | |
| 85 | /* |
| 86 | * Setup the architecture |
| 87 | */ |
Poonam Aggrwal | fb8e3e1 | 2009-08-07 21:05:16 +0530 | [diff] [blame] | 88 | static void __init mpc85xx_rdb_setup_arch(void) |
| 89 | { |
| 90 | #ifdef CONFIG_PCI |
| 91 | struct device_node *np; |
| 92 | #endif |
| 93 | |
| 94 | if (ppc_md.progress) |
| 95 | ppc_md.progress("mpc85xx_rdb_setup_arch()", 0); |
| 96 | |
| 97 | #ifdef CONFIG_PCI |
| 98 | for_each_node_by_type(np, "pci") { |
| 99 | if (of_device_is_compatible(np, "fsl,mpc8548-pcie")) |
| 100 | fsl_add_bridge(np, 0); |
| 101 | } |
| 102 | |
| 103 | #endif |
| 104 | |
Poonam Aggrwal | fb8e3e1 | 2009-08-07 21:05:16 +0530 | [diff] [blame] | 105 | mpc85xx_smp_init(); |
Poonam Aggrwal | fb8e3e1 | 2009-08-07 21:05:16 +0530 | [diff] [blame] | 106 | printk(KERN_INFO "MPC85xx RDB board from Freescale Semiconductor\n"); |
| 107 | } |
| 108 | |
Dmitry Eremin-Solenikov | 46d026a | 2011-11-17 21:56:17 +0400 | [diff] [blame] | 109 | machine_device_initcall(p2020_rdb, mpc85xx_common_publish_devices); |
| 110 | machine_device_initcall(p1020_rdb, mpc85xx_common_publish_devices); |
Poonam Aggrwal | fb8e3e1 | 2009-08-07 21:05:16 +0530 | [diff] [blame] | 111 | |
| 112 | /* |
| 113 | * Called very early, device-tree isn't unflattened |
| 114 | */ |
| 115 | static int __init p2020_rdb_probe(void) |
| 116 | { |
| 117 | unsigned long root = of_get_flat_dt_root(); |
| 118 | |
| 119 | if (of_flat_dt_is_compatible(root, "fsl,P2020RDB")) |
| 120 | return 1; |
| 121 | return 0; |
| 122 | } |
| 123 | |
Poonam Aggrwal | 52dffd7 | 2009-09-25 09:50:28 +0530 | [diff] [blame] | 124 | static int __init p1020_rdb_probe(void) |
| 125 | { |
| 126 | unsigned long root = of_get_flat_dt_root(); |
| 127 | |
| 128 | if (of_flat_dt_is_compatible(root, "fsl,P1020RDB")) |
| 129 | return 1; |
| 130 | return 0; |
| 131 | } |
| 132 | |
Poonam Aggrwal | fb8e3e1 | 2009-08-07 21:05:16 +0530 | [diff] [blame] | 133 | define_machine(p2020_rdb) { |
| 134 | .name = "P2020 RDB", |
| 135 | .probe = p2020_rdb_probe, |
| 136 | .setup_arch = mpc85xx_rdb_setup_arch, |
| 137 | .init_IRQ = mpc85xx_rdb_pic_init, |
| 138 | #ifdef CONFIG_PCI |
| 139 | .pcibios_fixup_bus = fsl_pcibios_fixup_bus, |
| 140 | #endif |
| 141 | .get_irq = mpic_get_irq, |
| 142 | .restart = fsl_rstcr_restart, |
| 143 | .calibrate_decr = generic_calibrate_decr, |
| 144 | .progress = udbg_progress, |
| 145 | }; |
Poonam Aggrwal | 52dffd7 | 2009-09-25 09:50:28 +0530 | [diff] [blame] | 146 | |
| 147 | define_machine(p1020_rdb) { |
| 148 | .name = "P1020 RDB", |
| 149 | .probe = p1020_rdb_probe, |
| 150 | .setup_arch = mpc85xx_rdb_setup_arch, |
| 151 | .init_IRQ = mpc85xx_rdb_pic_init, |
| 152 | #ifdef CONFIG_PCI |
| 153 | .pcibios_fixup_bus = fsl_pcibios_fixup_bus, |
| 154 | #endif |
| 155 | .get_irq = mpic_get_irq, |
| 156 | .restart = fsl_rstcr_restart, |
| 157 | .calibrate_decr = generic_calibrate_decr, |
| 158 | .progress = udbg_progress, |
| 159 | }; |