blob: 65eb792a0d001eabcdfefc04d0fc279ca7456051 [file] [log] [blame]
Heiko Schocher8159df72009-06-15 09:38:18 +02001/*
Holger Brunck93e2b952011-03-11 08:02:44 +01002 * Copyright 2008-2011 DENX Software Engineering GmbH
Heiko Schocher8159df72009-06-15 09:38:18 +02003 * Author: Heiko Schocher <hs@denx.de>
4 *
5 * Description:
6 * Keymile KMETER1 board specific routines.
7 *
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by the
10 * Free Software Foundation; either version 2 of the License, or (at your
11 * option) any later version.
12 */
13
14#include <linux/stddef.h>
15#include <linux/kernel.h>
16#include <linux/init.h>
17#include <linux/errno.h>
18#include <linux/reboot.h>
19#include <linux/pci.h>
20#include <linux/kdev_t.h>
21#include <linux/major.h>
22#include <linux/console.h>
23#include <linux/delay.h>
24#include <linux/seq_file.h>
25#include <linux/root_dev.h>
26#include <linux/initrd.h>
27#include <linux/of_platform.h>
28#include <linux/of_device.h>
29
30#include <asm/system.h>
Arun Sharma60063492011-07-26 16:09:06 -070031#include <linux/atomic.h>
Heiko Schocher8159df72009-06-15 09:38:18 +020032#include <asm/time.h>
33#include <asm/io.h>
34#include <asm/machdep.h>
35#include <asm/ipic.h>
36#include <asm/irq.h>
37#include <asm/prom.h>
38#include <asm/udbg.h>
39#include <sysdev/fsl_soc.h>
40#include <sysdev/fsl_pci.h>
41#include <asm/qe.h>
42#include <asm/qe_ic.h>
43
44#include "mpc83xx.h"
45
46#define SVR_REV(svr) (((svr) >> 0) & 0xFFFF) /* Revision field */
47/* ************************************************************************
48 *
49 * Setup the architecture
50 *
51 */
Holger Brunck93e2b952011-03-11 08:02:44 +010052static void __init mpc83xx_km_setup_arch(void)
Heiko Schocher8159df72009-06-15 09:38:18 +020053{
Dmitry Eremin-Solenikovbede4802011-11-17 18:48:48 +040054#ifdef CONFIG_QUICC_ENGINE
Heiko Schocher8159df72009-06-15 09:38:18 +020055 struct device_node *np;
Dmitry Eremin-Solenikovbede4802011-11-17 18:48:48 +040056#endif
Heiko Schocher8159df72009-06-15 09:38:18 +020057
58 if (ppc_md.progress)
Holger Brunck93e2b952011-03-11 08:02:44 +010059 ppc_md.progress("kmpbec83xx_setup_arch()", 0);
Heiko Schocher8159df72009-06-15 09:38:18 +020060
Dmitry Eremin-Solenikovbede4802011-11-17 18:48:48 +040061 mpc83xx_setup_pci();
Heiko Schocher8159df72009-06-15 09:38:18 +020062
63#ifdef CONFIG_QUICC_ENGINE
64 qe_reset();
65
66 np = of_find_node_by_name(NULL, "par_io");
67 if (np != NULL) {
68 par_io_init(np);
69 of_node_put(np);
70
Holger Brunck93e2b952011-03-11 08:02:44 +010071 for_each_node_by_name(np, "spi")
72 par_io_of_config(np);
73
Heiko Schocher8159df72009-06-15 09:38:18 +020074 for (np = NULL; (np = of_find_node_by_name(np, "ucc")) != NULL;)
75 par_io_of_config(np);
76 }
77
78 np = of_find_compatible_node(NULL, "network", "ucc_geth");
79 if (np != NULL) {
80 uint svid;
81
82 /* handle mpc8360ea rev.2.1 erratum 2: RGMII Timing */
83 svid = mfspr(SPRN_SVR);
84 if (SVR_REV(svid) == 0x0021) {
85 struct device_node *np_par;
86 struct resource res;
87 void __iomem *base;
88 int ret;
89
90 np_par = of_find_node_by_name(NULL, "par_io");
91 if (np_par == NULL) {
92 printk(KERN_WARNING "%s couldn;t find par_io node\n",
93 __func__);
94 return;
95 }
96 /* Map Parallel I/O ports registers */
97 ret = of_address_to_resource(np_par, 0, &res);
98 if (ret) {
99 printk(KERN_WARNING "%s couldn;t map par_io registers\n",
100 __func__);
101 return;
102 }
Joe Perches28f65c12011-06-09 09:13:32 -0700103 base = ioremap(res.start, resource_size(&res));
Heiko Schocher8159df72009-06-15 09:38:18 +0200104
105 /*
106 * IMMR + 0x14A8[4:5] = 11 (clk delay for UCC 2)
107 * IMMR + 0x14A8[18:19] = 11 (clk delay for UCC 1)
108 */
109 setbits32((base + 0xa8), 0x0c003000);
110
111 /*
112 * IMMR + 0x14AC[20:27] = 10101010
113 * (data delay for both UCC's)
114 */
115 clrsetbits_be32((base + 0xac), 0xff0, 0xaa0);
116 iounmap(base);
117 of_node_put(np_par);
118 }
119 of_node_put(np);
120 }
121#endif /* CONFIG_QUICC_ENGINE */
122}
123
Dmitry Eremin-Solenikov7669d582011-11-17 18:48:47 +0400124machine_device_initcall(mpc83xx_km, mpc83xx_declare_of_platform_devices);
Heiko Schocher8159df72009-06-15 09:38:18 +0200125
Holger Brunck93e2b952011-03-11 08:02:44 +0100126/* list of the supported boards */
127static char *board[] __initdata = {
128 "Keymile,KMETER1",
129 "Keymile,kmpbec8321",
130 NULL
131};
132
Heiko Schocher8159df72009-06-15 09:38:18 +0200133/*
134 * Called very early, MMU is off, device-tree isn't unflattened
135 */
Holger Brunck93e2b952011-03-11 08:02:44 +0100136static int __init mpc83xx_km_probe(void)
Heiko Schocher8159df72009-06-15 09:38:18 +0200137{
Holger Brunck93e2b952011-03-11 08:02:44 +0100138 unsigned long node = of_get_flat_dt_root();
139 int i = 0;
Heiko Schocher8159df72009-06-15 09:38:18 +0200140
Holger Brunck93e2b952011-03-11 08:02:44 +0100141 while (board[i]) {
142 if (of_flat_dt_is_compatible(node, board[i]))
143 break;
144 i++;
145 }
146 return (board[i] != NULL);
Heiko Schocher8159df72009-06-15 09:38:18 +0200147}
148
Holger Brunck93e2b952011-03-11 08:02:44 +0100149define_machine(mpc83xx_km) {
150 .name = "mpc83xx-km-platform",
151 .probe = mpc83xx_km_probe,
152 .setup_arch = mpc83xx_km_setup_arch,
Dmitry Eremin-Solenikovd4fb5eb2011-07-22 23:55:42 +0400153 .init_IRQ = mpc83xx_ipic_and_qe_init_IRQ,
Heiko Schocher8159df72009-06-15 09:38:18 +0200154 .get_irq = ipic_get_irq,
155 .restart = mpc83xx_restart,
156 .time_init = mpc83xx_time_init,
157 .calibrate_decr = generic_calibrate_decr,
158 .progress = udbg_progress,
159};