]> git.karo-electronics.de Git - karo-tx-linux.git/blob - arch/powerpc/platforms/83xx/mpc832x_mds.c
54dea9d42dc96bc8724d4757561a2b01e1b24746
[karo-tx-linux.git] / arch / powerpc / platforms / 83xx / mpc832x_mds.c
1 /*
2  * Copyright (C) Freescale Semicondutor, Inc. 2006. All rights reserved.
3  *
4  * Description:
5  * MPC832xE MDS board specific routines.
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/init.h>
16 #include <linux/errno.h>
17 #include <linux/reboot.h>
18 #include <linux/pci.h>
19 #include <linux/kdev_t.h>
20 #include <linux/major.h>
21 #include <linux/console.h>
22 #include <linux/delay.h>
23 #include <linux/seq_file.h>
24 #include <linux/root_dev.h>
25 #include <linux/initrd.h>
26
27 #include <asm/system.h>
28 #include <asm/atomic.h>
29 #include <asm/time.h>
30 #include <asm/io.h>
31 #include <asm/machdep.h>
32 #include <asm/ipic.h>
33 #include <asm/bootinfo.h>
34 #include <asm/irq.h>
35 #include <asm/prom.h>
36 #include <asm/udbg.h>
37 #include <sysdev/fsl_soc.h>
38 #include <asm/qe.h>
39 #include <asm/qe_ic.h>
40
41 #include "mpc83xx.h"
42 #include "mpc832x_mds.h"
43
44 #undef DEBUG
45 #ifdef DEBUG
46 #define DBG(fmt...) udbg_printf(fmt)
47 #else
48 #define DBG(fmt...)
49 #endif
50
51 #ifndef CONFIG_PCI
52 unsigned long isa_io_base = 0;
53 unsigned long isa_mem_base = 0;
54 #endif
55
56 static u8 *bcsr_regs = NULL;
57
58 u8 *get_bcsr(void)
59 {
60         return bcsr_regs;
61 }
62
63 /* ************************************************************************
64  *
65  * Setup the architecture
66  *
67  */
68 static void __init mpc832x_sys_setup_arch(void)
69 {
70         struct device_node *np;
71
72         if (ppc_md.progress)
73                 ppc_md.progress("mpc832x_sys_setup_arch()", 0);
74
75         np = of_find_node_by_type(NULL, "cpu");
76         if (np != 0) {
77                 unsigned int *fp =
78                     (int *)get_property(np, "clock-frequency", NULL);
79                 if (fp != 0)
80                         loops_per_jiffy = *fp / HZ;
81                 else
82                         loops_per_jiffy = 50000000 / HZ;
83                 of_node_put(np);
84         }
85
86         /* Map BCSR area */
87         np = of_find_node_by_name(NULL, "bcsr");
88         if (np != 0) {
89                 struct resource res;
90
91                 of_address_to_resource(np, 0, &res);
92                 bcsr_regs = ioremap(res.start, res.end - res.start +1);
93                 of_node_put(np);
94         }
95
96 #ifdef CONFIG_PCI
97         for (np = NULL; (np = of_find_node_by_type(np, "pci")) != NULL;)
98                 add_bridge(np);
99
100         ppc_md.pci_swizzle = common_swizzle;
101         ppc_md.pci_exclude_device = mpc83xx_exclude_device;
102 #endif
103
104 #ifdef CONFIG_QUICC_ENGINE
105         qe_reset();
106
107         if ((np = of_find_node_by_name(np, "par_io")) != NULL) {
108                 par_io_init(np);
109                 of_node_put(np);
110
111                 for (np = NULL; (np = of_find_node_by_name(np, "ucc")) != NULL;)
112                         par_io_of_config(np);
113         }
114
115         if ((np = of_find_compatible_node(NULL, "network", "ucc_geth"))
116                         != NULL){
117                 /* Reset the Ethernet PHY */
118                 bcsr_regs[9] &= ~0x20;
119                 udelay(1000);
120                 bcsr_regs[9] |= 0x20;
121                 iounmap(bcsr_regs);
122                 of_node_put(np);
123         }
124
125 #endif                          /* CONFIG_QUICC_ENGINE */
126
127 #ifdef CONFIG_BLK_DEV_INITRD
128         if (initrd_start)
129                 ROOT_DEV = Root_RAM0;
130         else
131 #endif
132 #ifdef  CONFIG_ROOT_NFS
133                 ROOT_DEV = Root_NFS;
134 #else
135                 ROOT_DEV = Root_HDA1;
136 #endif
137 }
138
139 void __init mpc832x_sys_init_IRQ(void)
140 {
141
142         struct device_node *np;
143
144         np = of_find_node_by_type(NULL, "ipic");
145         if (!np)
146                 return;
147
148         ipic_init(np, 0);
149
150         /* Initialize the default interrupt mapping priorities,
151          * in case the boot rom changed something on us.
152          */
153         ipic_set_default_priority();
154         of_node_put(np);
155
156 #ifdef CONFIG_QUICC_ENGINE
157         np = of_find_node_by_type(NULL, "qeic");
158         if (!np)
159                 return;
160
161         qe_ic_init(np, 0);
162         of_node_put(np);
163 #endif                          /* CONFIG_QUICC_ENGINE */
164 }
165
166 #if defined(CONFIG_I2C_MPC) && defined(CONFIG_SENSORS_DS1374)
167 extern ulong ds1374_get_rtc_time(void);
168 extern int ds1374_set_rtc_time(ulong);
169
170 static int __init mpc832x_rtc_hookup(void)
171 {
172         struct timespec tv;
173
174         ppc_md.get_rtc_time = ds1374_get_rtc_time;
175         ppc_md.set_rtc_time = ds1374_set_rtc_time;
176
177         tv.tv_nsec = 0;
178         tv.tv_sec = (ppc_md.get_rtc_time) ();
179         do_settimeofday(&tv);
180
181         return 0;
182 }
183
184 late_initcall(mpc832x_rtc_hookup);
185 #endif
186
187 /*
188  * Called very early, MMU is off, device-tree isn't unflattened
189  */
190 static int __init mpc832x_sys_probe(void)
191 {
192         char *model = of_get_flat_dt_prop(of_get_flat_dt_root(),
193                                           "model", NULL);
194
195         if (model == NULL)
196                 return 0;
197         if (strcmp(model, "MPC8323EMDS"))
198                 return 0;
199
200         DBG("%s found\n", model);
201
202         return 1;
203 }
204
205 define_machine(mpc832x_mds) {
206         .name           = "MPC832x MDS",
207         .probe          = mpc832x_sys_probe,
208         .setup_arch     = mpc832x_sys_setup_arch,
209         .init_IRQ       = mpc832x_sys_init_IRQ,
210         .get_irq        = ipic_get_irq,
211         .restart        = mpc83xx_restart,
212         .time_init      = mpc83xx_time_init,
213         .calibrate_decr = generic_calibrate_decr,
214         .progress       = udbg_progress,
215 };