blob: d0a634b056ca549040d79f0112de75e6062dbadf [file] [log] [blame]
Kumar Gala7d13d212006-01-13 11:19:58 -06001/*
Kumar Gala49baa912007-02-08 01:11:00 -06002 * arch/powerpc/platforms/83xx/mpc834x_mds.c
Kumar Gala7d13d212006-01-13 11:19:58 -06003 *
Kumar Gala49baa912007-02-08 01:11:00 -06004 * MPC834x MDS board specific routines
Kumar Gala7d13d212006-01-13 11:19:58 -06005 *
6 * Maintainer: Kumar Gala <galak@kernel.crashing.org>
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
Kumar Gala7d13d212006-01-13 11:19:58 -060014#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>
Scott Wood8129a592007-12-13 11:19:05 -060026#include <linux/of_platform.h>
Kumar Gala7d13d212006-01-13 11:19:58 -060027
28#include <asm/system.h>
Kumar Gala7d13d212006-01-13 11:19:58 -060029#include <asm/atomic.h>
30#include <asm/time.h>
31#include <asm/io.h>
32#include <asm/machdep.h>
33#include <asm/ipic.h>
Kumar Gala7d13d212006-01-13 11:19:58 -060034#include <asm/irq.h>
Kumar Gala7d13d212006-01-13 11:19:58 -060035#include <asm/prom.h>
36#include <asm/udbg.h>
37#include <sysdev/fsl_soc.h>
John Rigby76fe1ff2008-06-26 11:07:57 -060038#include <sysdev/fsl_pci.h>
Kumar Gala7d13d212006-01-13 11:19:58 -060039
40#include "mpc83xx.h"
41
Li Yangc1616982007-02-07 13:47:56 +080042#define BCSR5_INT_USB 0x02
Li Yange5a94af2007-07-03 17:43:16 +080043static int mpc834xemds_usb_cfg(void)
Li Yangc1616982007-02-07 13:47:56 +080044{
Li Yange5a94af2007-07-03 17:43:16 +080045 struct device_node *np;
Li Yangc1616982007-02-07 13:47:56 +080046 void __iomem *bcsr_regs = NULL;
47 u8 bcsr5;
Li Yangc1616982007-02-07 13:47:56 +080048
Li Yange5a94af2007-07-03 17:43:16 +080049 mpc834x_usb_cfg();
Li Yangc1616982007-02-07 13:47:56 +080050 /* Map BCSR area */
51 np = of_find_node_by_name(NULL, "bcsr");
Li Yange5a94af2007-07-03 17:43:16 +080052 if (np) {
Li Yangc1616982007-02-07 13:47:56 +080053 struct resource res;
54
55 of_address_to_resource(np, 0, &res);
56 bcsr_regs = ioremap(res.start, res.end - res.start + 1);
57 of_node_put(np);
58 }
59 if (!bcsr_regs)
60 return -1;
61
62 /*
Li Yangaea12b72007-03-06 17:11:06 +080063 * if Processor Board is plugged into PIB board,
64 * force to use the PHY on Processor Board
Li Yangc1616982007-02-07 13:47:56 +080065 */
66 bcsr5 = in_8(bcsr_regs + 5);
67 if (!(bcsr5 & BCSR5_INT_USB))
68 out_8(bcsr_regs + 5, (bcsr5 | BCSR5_INT_USB));
69 iounmap(bcsr_regs);
70 return 0;
71}
72
Kumar Gala7d13d212006-01-13 11:19:58 -060073/* ************************************************************************
74 *
75 * Setup the architecture
76 *
77 */
Kumar Gala49baa912007-02-08 01:11:00 -060078static void __init mpc834x_mds_setup_arch(void)
Kumar Gala7d13d212006-01-13 11:19:58 -060079{
Li Yangb38d06d2007-05-10 11:14:57 +080080#ifdef CONFIG_PCI
Kumar Gala7d13d212006-01-13 11:19:58 -060081 struct device_node *np;
Li Yangb38d06d2007-05-10 11:14:57 +080082#endif
Kumar Gala7d13d212006-01-13 11:19:58 -060083
84 if (ppc_md.progress)
Kumar Gala49baa912007-02-08 01:11:00 -060085 ppc_md.progress("mpc834x_mds_setup_arch()", 0);
Kumar Gala7d13d212006-01-13 11:19:58 -060086
Kumar Gala7d13d212006-01-13 11:19:58 -060087#ifdef CONFIG_PCI
Kumar Galac9438af2007-10-04 00:28:43 -050088 for_each_compatible_node(np, "pci", "fsl,mpc8349-pci")
Arnd Bergmann09b55f72007-06-18 01:06:54 +020089 mpc83xx_add_bridge(np);
Kumar Gala7d13d212006-01-13 11:19:58 -060090#endif
91
Li Yange5a94af2007-07-03 17:43:16 +080092 mpc834xemds_usb_cfg();
Kumar Gala7d13d212006-01-13 11:19:58 -060093}
94
Kumar Gala49baa912007-02-08 01:11:00 -060095static void __init mpc834x_mds_init_IRQ(void)
Kumar Gala7d13d212006-01-13 11:19:58 -060096{
Kim Phillipsf1f17712006-08-25 11:59:22 -050097 struct device_node *np;
Kumar Gala7d13d212006-01-13 11:19:58 -060098
Kim Phillipsf1f17712006-08-25 11:59:22 -050099 np = of_find_node_by_type(NULL, "ipic");
100 if (!np)
101 return;
102
103 ipic_init(np, 0);
Kumar Gala7d13d212006-01-13 11:19:58 -0600104
105 /* Initialize the default interrupt mapping priorities,
106 * in case the boot rom changed something on us.
107 */
108 ipic_set_default_priority();
109}
110
Scott Wood8129a592007-12-13 11:19:05 -0600111static struct of_device_id mpc834x_ids[] = {
112 { .type = "soc", },
113 { .compatible = "soc", },
Kim Phillipscf0d19f2008-07-29 15:29:24 -0500114 { .compatible = "simple-bus", },
Anton Vorontsov70b3adb2009-03-19 21:01:45 +0300115 { .compatible = "gianfar", },
Scott Wood8129a592007-12-13 11:19:05 -0600116 {},
117};
118
119static int __init mpc834x_declare_of_platform_devices(void)
120{
Scott Wood8129a592007-12-13 11:19:05 -0600121 of_platform_bus_probe(NULL, mpc834x_ids, NULL);
122 return 0;
123}
Kumar Gala6392f182008-01-15 09:47:10 -0600124machine_device_initcall(mpc834x_mds, mpc834x_declare_of_platform_devices);
Scott Wood8129a592007-12-13 11:19:05 -0600125
Kumar Gala72d2c3e2006-03-30 23:39:57 -0600126/*
127 * Called very early, MMU is off, device-tree isn't unflattened
128 */
Kumar Gala49baa912007-02-08 01:11:00 -0600129static int __init mpc834x_mds_probe(void)
Kumar Gala7d13d212006-01-13 11:19:58 -0600130{
Scott Wood8129a592007-12-13 11:19:05 -0600131 unsigned long root = of_get_flat_dt_root();
Kumar Gala336c3c22007-02-17 09:10:44 -0600132
Scott Wood8129a592007-12-13 11:19:05 -0600133 return of_flat_dt_is_compatible(root, "MPC834xMDS");
Kumar Gala7d13d212006-01-13 11:19:58 -0600134}
Kumar Gala72d2c3e2006-03-30 23:39:57 -0600135
Kumar Gala49baa912007-02-08 01:11:00 -0600136define_machine(mpc834x_mds) {
137 .name = "MPC834x MDS",
138 .probe = mpc834x_mds_probe,
139 .setup_arch = mpc834x_mds_setup_arch,
140 .init_IRQ = mpc834x_mds_init_IRQ,
Kumar Gala72d2c3e2006-03-30 23:39:57 -0600141 .get_irq = ipic_get_irq,
142 .restart = mpc83xx_restart,
143 .time_init = mpc83xx_time_init,
144 .calibrate_decr = generic_calibrate_decr,
145 .progress = udbg_progress,
146};