Jon Loeliger | d93daf8 | 2007-03-20 11:19:10 -0500 | [diff] [blame^] | 1 | /* |
| 2 | * MPC8544 DS Board Setup |
| 3 | * |
| 4 | * Author Xianghua Xiao (x.xiao@freescale.com) |
| 5 | * Copyright 2007 Freescale Semiconductor Inc. |
| 6 | * |
| 7 | * This program is free software; you can redistribute it and/or modify it |
| 8 | * under the terms of the GNU General Public License as published by the |
| 9 | * Free Software Foundation; either version 2 of the License, or (at your |
| 10 | * option) any later version. |
| 11 | */ |
| 12 | |
| 13 | #include <linux/stddef.h> |
| 14 | #include <linux/kernel.h> |
| 15 | #include <linux/kdev_t.h> |
| 16 | #include <linux/delay.h> |
| 17 | #include <linux/seq_file.h> |
| 18 | |
| 19 | #include <asm/system.h> |
| 20 | #include <asm/time.h> |
| 21 | #include <asm/machdep.h> |
| 22 | #include <asm/mpc85xx.h> |
| 23 | #include <mm/mmu_decl.h> |
| 24 | #include <asm/prom.h> |
| 25 | #include <asm/udbg.h> |
| 26 | #include <asm/mpic.h> |
| 27 | #include <asm/i8259.h> |
| 28 | |
| 29 | #include <sysdev/fsl_soc.h> |
| 30 | #include "mpc85xx.h" |
| 31 | |
| 32 | #undef DEBUG |
| 33 | |
| 34 | #ifdef DEBUG |
| 35 | #define DBG(fmt, args...) printk(KERN_ERR "%s: " fmt, __FUNCTION__, ## args) |
| 36 | #else |
| 37 | #define DBG(fmt, args...) |
| 38 | #endif |
| 39 | |
| 40 | |
| 41 | void __init mpc8544_ds_pic_init(void) |
| 42 | { |
| 43 | struct mpic *mpic; |
| 44 | struct resource r; |
| 45 | struct device_node *np = NULL; |
| 46 | #ifdef CONFIG_PPC_I8259 |
| 47 | struct device_node *cascade_node = NULL; |
| 48 | int cascade_irq; |
| 49 | #endif |
| 50 | |
| 51 | np = of_find_node_by_type(np, "open-pic"); |
| 52 | |
| 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 | |
| 64 | /* Alloc mpic structure and per isu has 16 INT entries. */ |
| 65 | mpic = mpic_alloc(np, r.start, |
| 66 | MPIC_PRIMARY | MPIC_WANTS_RESET | MPIC_BIG_ENDIAN, |
| 67 | 16, 64, " OPENPIC "); |
| 68 | BUG_ON(mpic == NULL); |
| 69 | |
| 70 | /* |
| 71 | * 48 Internal Interrupts |
| 72 | */ |
| 73 | mpic_assign_isu(mpic, 0, r.start + 0x10200); |
| 74 | mpic_assign_isu(mpic, 1, r.start + 0x10400); |
| 75 | mpic_assign_isu(mpic, 2, r.start + 0x10600); |
| 76 | |
| 77 | /* |
| 78 | * 16 External interrupts |
| 79 | */ |
| 80 | mpic_assign_isu(mpic, 3, r.start + 0x10000); |
| 81 | |
| 82 | mpic_init(mpic); |
| 83 | |
| 84 | #ifdef CONFIG_PPC_I8259 |
| 85 | /* Initialize the i8259 controller */ |
| 86 | for_each_node_by_type(np, "interrupt-controller") |
| 87 | if (device_is_compatible(np, "chrp,iic")) { |
| 88 | cascade_node = np; |
| 89 | break; |
| 90 | } |
| 91 | |
| 92 | if (cascade_node == NULL) { |
| 93 | printk(KERN_DEBUG "Could not find i8259 PIC\n"); |
| 94 | return; |
| 95 | } |
| 96 | |
| 97 | cascade_irq = irq_of_parse_and_map(cascade_node, 0); |
| 98 | if (cascade_irq == NO_IRQ) { |
| 99 | printk(KERN_ERR "Failed to map cascade interrupt\n"); |
| 100 | return; |
| 101 | } |
| 102 | |
| 103 | DBG("mpc8544ds: cascade mapped to irq %d\n", cascade_irq); |
| 104 | |
| 105 | i8259_init(cascade_node, 0); |
| 106 | of_node_put(cascade_node); |
| 107 | |
| 108 | set_irq_chained_handler(cascade_irq, mpc8544_8259_cascade); |
| 109 | #endif /* CONFIG_PPC_I8259 */ |
| 110 | } |
| 111 | |
| 112 | |
| 113 | /* |
| 114 | * Setup the architecture |
| 115 | */ |
| 116 | static void __init mpc8544_ds_setup_arch(void) |
| 117 | { |
| 118 | if (ppc_md.progress) |
| 119 | ppc_md.progress("mpc8544_ds_setup_arch()", 0); |
| 120 | |
| 121 | printk("MPC8544 DS board from Freescale Semiconductor\n"); |
| 122 | } |
| 123 | |
| 124 | |
| 125 | /* |
| 126 | * Called very early, device-tree isn't unflattened |
| 127 | */ |
| 128 | static int __init mpc8544_ds_probe(void) |
| 129 | { |
| 130 | unsigned long root = of_get_flat_dt_root(); |
| 131 | |
| 132 | return of_flat_dt_is_compatible(root, "MPC8544DS"); |
| 133 | } |
| 134 | |
| 135 | define_machine(mpc8544_ds) { |
| 136 | .name = "MPC8544 DS", |
| 137 | .probe = mpc8544_ds_probe, |
| 138 | .setup_arch = mpc8544_ds_setup_arch, |
| 139 | .init_IRQ = mpc8544_ds_pic_init, |
| 140 | .get_irq = mpic_get_irq, |
| 141 | .restart = mpc85xx_restart, |
| 142 | .calibrate_decr = generic_calibrate_decr, |
| 143 | .progress = udbg_progress, |
| 144 | }; |