John Rigby | fb18032 | 2008-07-09 14:54:03 -0600 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2007,2008 Freescale Semiconductor, Inc. All rights reserved. |
| 3 | * |
| 4 | * Author: John Rigby <jrigby@freescale.com> |
| 5 | * |
| 6 | * Description: |
| 7 | * MPC512x Shared code |
| 8 | * |
| 9 | * This is free software; you can redistribute it and/or modify it |
| 10 | * under the terms of the GNU General Public License as published by |
| 11 | * the Free Software Foundation; either version 2 of the License, or |
| 12 | * (at your option) any later version. |
| 13 | */ |
| 14 | |
| 15 | #include <linux/kernel.h> |
| 16 | #include <linux/io.h> |
| 17 | #include <linux/irq.h> |
| 18 | #include <linux/of_platform.h> |
| 19 | |
| 20 | #include <asm/machdep.h> |
| 21 | #include <asm/ipic.h> |
| 22 | #include <asm/prom.h> |
| 23 | #include <asm/time.h> |
Anatolij Gustschin | a8dbceb7 | 2010-02-16 10:36:26 -0700 | [diff] [blame^] | 24 | #include <asm/mpc5121.h> |
John Rigby | fb18032 | 2008-07-09 14:54:03 -0600 | [diff] [blame] | 25 | |
| 26 | #include "mpc512x.h" |
| 27 | |
Anatolij Gustschin | a8dbceb7 | 2010-02-16 10:36:26 -0700 | [diff] [blame^] | 28 | static struct mpc512x_reset_module __iomem *reset_module_base; |
| 29 | |
| 30 | static void __init mpc512x_restart_init(void) |
| 31 | { |
| 32 | struct device_node *np; |
| 33 | |
| 34 | np = of_find_compatible_node(NULL, NULL, "fsl,mpc5121-reset"); |
| 35 | if (!np) |
| 36 | return; |
| 37 | |
| 38 | reset_module_base = of_iomap(np, 0); |
| 39 | of_node_put(np); |
| 40 | } |
| 41 | |
| 42 | void mpc512x_restart(char *cmd) |
| 43 | { |
| 44 | if (reset_module_base) { |
| 45 | /* Enable software reset "RSTE" */ |
| 46 | out_be32(&reset_module_base->rpr, 0x52535445); |
| 47 | /* Set software hard reset */ |
| 48 | out_be32(&reset_module_base->rcr, 0x2); |
| 49 | } else { |
| 50 | pr_err("Restart module not mapped.\n"); |
| 51 | } |
| 52 | for (;;) |
| 53 | ; |
| 54 | } |
| 55 | |
John Rigby | fb18032 | 2008-07-09 14:54:03 -0600 | [diff] [blame] | 56 | void __init mpc512x_init_IRQ(void) |
| 57 | { |
| 58 | struct device_node *np; |
| 59 | |
| 60 | np = of_find_compatible_node(NULL, NULL, "fsl,mpc5121-ipic"); |
| 61 | if (!np) |
| 62 | return; |
| 63 | |
| 64 | ipic_init(np, 0); |
| 65 | of_node_put(np); |
| 66 | |
| 67 | /* |
| 68 | * Initialize the default interrupt mapping priorities, |
| 69 | * in case the boot rom changed something on us. |
| 70 | */ |
| 71 | ipic_set_default_priority(); |
| 72 | } |
| 73 | |
| 74 | /* |
| 75 | * Nodes to do bus probe on, soc and localbus |
| 76 | */ |
| 77 | static struct of_device_id __initdata of_bus_ids[] = { |
| 78 | { .compatible = "fsl,mpc5121-immr", }, |
| 79 | { .compatible = "fsl,mpc5121-localbus", }, |
| 80 | {}, |
| 81 | }; |
| 82 | |
| 83 | void __init mpc512x_declare_of_platform_devices(void) |
| 84 | { |
| 85 | if (of_platform_bus_probe(NULL, of_bus_ids, NULL)) |
| 86 | printk(KERN_ERR __FILE__ ": " |
| 87 | "Error while probing of_platform bus\n"); |
| 88 | } |
| 89 | |
Anatolij Gustschin | 284ed66 | 2010-02-16 10:35:13 -0700 | [diff] [blame] | 90 | void __init mpc512x_init(void) |
| 91 | { |
| 92 | mpc512x_declare_of_platform_devices(); |
| 93 | mpc5121_clk_init(); |
Anatolij Gustschin | a8dbceb7 | 2010-02-16 10:36:26 -0700 | [diff] [blame^] | 94 | mpc512x_restart_init(); |
Anatolij Gustschin | 284ed66 | 2010-02-16 10:35:13 -0700 | [diff] [blame] | 95 | } |