spi/ep93xx: implemented driver for Cirrus EP93xx SPI controller
[deliverable/linux.git] / arch / powerpc / platforms / 512x / mpc512x_shared.c
CommitLineData
fb180322
JR
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>
a8dbceb7 24#include <asm/mpc5121.h>
fb180322
JR
25
26#include "mpc512x.h"
27
a8dbceb7
AG
28static struct mpc512x_reset_module __iomem *reset_module_base;
29
30static 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
42void 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
fb180322
JR
56void __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 */
77static struct of_device_id __initdata of_bus_ids[] = {
78 { .compatible = "fsl,mpc5121-immr", },
79 { .compatible = "fsl,mpc5121-localbus", },
80 {},
81};
82
83void __init mpc512x_declare_of_platform_devices(void)
84{
5b2b6255
AG
85 struct device_node *np;
86
fb180322
JR
87 if (of_platform_bus_probe(NULL, of_bus_ids, NULL))
88 printk(KERN_ERR __FILE__ ": "
89 "Error while probing of_platform bus\n");
5b2b6255
AG
90
91 np = of_find_compatible_node(NULL, NULL, "fsl,mpc5121-nfc");
92 if (np) {
93 of_platform_device_create(np, NULL, NULL);
94 of_node_put(np);
95 }
fb180322
JR
96}
97
284ed66f
AG
98void __init mpc512x_init(void)
99{
100 mpc512x_declare_of_platform_devices();
101 mpc5121_clk_init();
a8dbceb7 102 mpc512x_restart_init();
284ed66f 103}
This page took 0.171154 seconds and 5 git commands to generate.