Wolfgang Grandegger | 393adca | 2009-03-22 14:58:43 +0100 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2008 Emcraft Systems |
| 3 | * Sergei Poselenov <sposelenov@emcraft.com> |
| 4 | * |
| 5 | * Based on MPC8560 ADS and arch/ppc tqm85xx ports |
| 6 | * |
| 7 | * Maintained by Kumar Gala (see MAINTAINERS for contact information) |
| 8 | * |
| 9 | * Copyright 2008 Freescale Semiconductor Inc. |
| 10 | * |
| 11 | * Copyright (c) 2005-2006 DENX Software Engineering |
| 12 | * Stefan Roese <sr@denx.de> |
| 13 | * |
| 14 | * Based on original work by |
| 15 | * Kumar Gala <kumar.gala@freescale.com> |
| 16 | * Copyright 2004 Freescale Semiconductor Inc. |
| 17 | * |
| 18 | * This program is free software; you can redistribute it and/or modify it |
| 19 | * under the terms of the GNU General Public License as published by the |
| 20 | * Free Software Foundation; either version 2 of the License, or (at your |
| 21 | * option) any later version. |
| 22 | */ |
| 23 | |
| 24 | #include <linux/stddef.h> |
| 25 | #include <linux/kernel.h> |
| 26 | #include <linux/pci.h> |
| 27 | #include <linux/kdev_t.h> |
| 28 | #include <linux/delay.h> |
| 29 | #include <linux/seq_file.h> |
| 30 | #include <linux/of_platform.h> |
| 31 | |
| 32 | #include <asm/system.h> |
| 33 | #include <asm/time.h> |
| 34 | #include <asm/machdep.h> |
| 35 | #include <asm/pci-bridge.h> |
| 36 | #include <asm/mpic.h> |
| 37 | #include <asm/prom.h> |
| 38 | #include <mm/mmu_decl.h> |
| 39 | #include <asm/udbg.h> |
| 40 | |
| 41 | #include <sysdev/fsl_soc.h> |
| 42 | #include <sysdev/fsl_pci.h> |
| 43 | |
Dmitry Eremin-Solenikov | 543a07b | 2011-11-17 21:56:16 +0400 | [diff] [blame] | 44 | #include "mpc85xx.h" |
Wolfgang Grandegger | 393adca | 2009-03-22 14:58:43 +0100 | [diff] [blame] | 45 | #include "socrates_fpga_pic.h" |
| 46 | |
| 47 | static void __init socrates_pic_init(void) |
| 48 | { |
| 49 | struct mpic *mpic; |
| 50 | struct resource r; |
| 51 | struct device_node *np; |
| 52 | |
| 53 | np = of_find_node_by_type(NULL, "open-pic"); |
| 54 | if (!np) { |
| 55 | printk(KERN_ERR "Could not find open-pic node\n"); |
| 56 | return; |
| 57 | } |
| 58 | |
| 59 | if (of_address_to_resource(np, 0, &r)) { |
| 60 | printk(KERN_ERR "Could not map mpic register space\n"); |
| 61 | of_node_put(np); |
| 62 | return; |
| 63 | } |
| 64 | |
| 65 | mpic = mpic_alloc(np, r.start, |
| 66 | MPIC_PRIMARY | MPIC_WANTS_RESET | MPIC_BIG_ENDIAN, |
| 67 | 0, 256, " OpenPIC "); |
| 68 | BUG_ON(mpic == NULL); |
| 69 | of_node_put(np); |
| 70 | |
| 71 | mpic_init(mpic); |
| 72 | |
| 73 | np = of_find_compatible_node(NULL, NULL, "abb,socrates-fpga-pic"); |
| 74 | if (!np) { |
| 75 | printk(KERN_ERR "Could not find socrates-fpga-pic node\n"); |
| 76 | return; |
| 77 | } |
| 78 | socrates_fpga_pic_init(np); |
| 79 | of_node_put(np); |
| 80 | } |
| 81 | |
| 82 | /* |
| 83 | * Setup the architecture |
| 84 | */ |
| 85 | static void __init socrates_setup_arch(void) |
| 86 | { |
| 87 | #ifdef CONFIG_PCI |
| 88 | struct device_node *np; |
| 89 | #endif |
| 90 | |
| 91 | if (ppc_md.progress) |
| 92 | ppc_md.progress("socrates_setup_arch()", 0); |
| 93 | |
| 94 | #ifdef CONFIG_PCI |
| 95 | for_each_compatible_node(np, "pci", "fsl,mpc8540-pci") |
| 96 | fsl_add_bridge(np, 1); |
| 97 | #endif |
| 98 | } |
| 99 | |
Dmitry Eremin-Solenikov | 46d026a | 2011-11-17 21:56:17 +0400 | [diff] [blame^] | 100 | machine_device_initcall(socrates, mpc85xx_common_publish_devices); |
Wolfgang Grandegger | 393adca | 2009-03-22 14:58:43 +0100 | [diff] [blame] | 101 | |
| 102 | /* |
| 103 | * Called very early, device-tree isn't unflattened |
| 104 | */ |
| 105 | static int __init socrates_probe(void) |
| 106 | { |
| 107 | unsigned long root = of_get_flat_dt_root(); |
| 108 | |
| 109 | if (of_flat_dt_is_compatible(root, "abb,socrates")) |
| 110 | return 1; |
| 111 | |
| 112 | return 0; |
| 113 | } |
| 114 | |
| 115 | define_machine(socrates) { |
| 116 | .name = "Socrates", |
| 117 | .probe = socrates_probe, |
| 118 | .setup_arch = socrates_setup_arch, |
Wolfgang Grandegger | 393adca | 2009-03-22 14:58:43 +0100 | [diff] [blame] | 119 | .init_IRQ = socrates_pic_init, |
| 120 | .get_irq = mpic_get_irq, |
| 121 | .restart = fsl_rstcr_restart, |
| 122 | .calibrate_decr = generic_calibrate_decr, |
| 123 | .progress = udbg_progress, |
| 124 | }; |