Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mszeredi...
[pandora-kernel.git] / arch / powerpc / platforms / 85xx / p1023_rds.c
1 /*
2  * Copyright 2010-2011 Freescale Semiconductor, Inc.
3  *
4  * Author: Roy Zang <tie-fei.zang@freescale.com>
5  *
6  * Description:
7  * P1023 RDS Board Setup
8  *
9  * This program is free software; you can redistribute  it and/or modify it
10  * under  the terms of  the GNU General  Public License as published by the
11  * Free Software Foundation;  either version 2 of the  License, or (at your
12  * option) any later version.
13  */
14
15 #include <linux/kernel.h>
16 #include <linux/init.h>
17 #include <linux/errno.h>
18 #include <linux/pci.h>
19 #include <linux/delay.h>
20 #include <linux/module.h>
21 #include <linux/fsl_devices.h>
22 #include <linux/of_platform.h>
23 #include <linux/of_device.h>
24
25 #include <asm/system.h>
26 #include <asm/time.h>
27 #include <asm/machdep.h>
28 #include <asm/pci-bridge.h>
29 #include <mm/mmu_decl.h>
30 #include <asm/prom.h>
31 #include <asm/udbg.h>
32 #include <asm/mpic.h>
33
34 #include <sysdev/fsl_soc.h>
35 #include <sysdev/fsl_pci.h>
36
37 /* ************************************************************************
38  *
39  * Setup the architecture
40  *
41  */
42 #ifdef CONFIG_SMP
43 void __init mpc85xx_smp_init(void);
44 #endif
45
46 static void __init mpc85xx_rds_setup_arch(void)
47 {
48         struct device_node *np;
49
50         if (ppc_md.progress)
51                 ppc_md.progress("p1023_rds_setup_arch()", 0);
52
53         /* Map BCSR area */
54         np = of_find_node_by_name(NULL, "bcsr");
55         if (np != NULL) {
56                 static u8 __iomem *bcsr_regs;
57
58                 bcsr_regs = of_iomap(np, 0);
59                 of_node_put(np);
60
61                 if (!bcsr_regs) {
62                         printk(KERN_ERR
63                                "BCSR: Failed to map bcsr register space\n");
64                         return;
65                 } else {
66 #define BCSR15_I2C_BUS0_SEG_CLR         0x07
67 #define BCSR15_I2C_BUS0_SEG2            0x02
68 /*
69  * Note: Accessing exclusively i2c devices.
70  *
71  * The i2c controller selects initially ID EEPROM in the u-boot;
72  * but if menu configuration selects RTC support in the kernel,
73  * the i2c controller switches to select RTC chip in the kernel.
74  */
75 #ifdef CONFIG_RTC_CLASS
76                         /* Enable RTC chip on the segment #2 of i2c */
77                         clrbits8(&bcsr_regs[15], BCSR15_I2C_BUS0_SEG_CLR);
78                         setbits8(&bcsr_regs[15], BCSR15_I2C_BUS0_SEG2);
79 #endif
80
81                         iounmap(bcsr_regs);
82                 }
83         }
84
85 #ifdef CONFIG_PCI
86         for_each_compatible_node(np, "pci", "fsl,p1023-pcie")
87                 fsl_add_bridge(np, 0);
88 #endif
89
90 #ifdef CONFIG_SMP
91         mpc85xx_smp_init();
92 #endif
93 }
94
95 static struct of_device_id p1023_ids[] = {
96         { .type = "soc", },
97         { .compatible = "soc", },
98         { .compatible = "simple-bus", },
99         {},
100 };
101
102
103 static int __init p1023_publish_devices(void)
104 {
105         of_platform_bus_probe(NULL, p1023_ids, NULL);
106
107         return 0;
108 }
109
110 machine_device_initcall(p1023_rds, p1023_publish_devices);
111
112 static void __init mpc85xx_rds_pic_init(void)
113 {
114         struct mpic *mpic;
115         struct resource r;
116         struct device_node *np = NULL;
117
118         np = of_find_node_by_type(NULL, "open-pic");
119         if (!np) {
120                 printk(KERN_ERR "Could not find open-pic node\n");
121                 return;
122         }
123
124         if (of_address_to_resource(np, 0, &r)) {
125                 printk(KERN_ERR "Failed to map mpic register space\n");
126                 of_node_put(np);
127                 return;
128         }
129
130         mpic = mpic_alloc(np, r.start,
131                 MPIC_PRIMARY | MPIC_WANTS_RESET | MPIC_BIG_ENDIAN |
132                 MPIC_BROKEN_FRR_NIRQS | MPIC_SINGLE_DEST_CPU,
133                 0, 256, " OpenPIC  ");
134
135         BUG_ON(mpic == NULL);
136         of_node_put(np);
137
138         mpic_init(mpic);
139 }
140
141 static int __init p1023_rds_probe(void)
142 {
143         unsigned long root = of_get_flat_dt_root();
144
145         return of_flat_dt_is_compatible(root, "fsl,P1023RDS");
146
147 }
148
149 define_machine(p1023_rds) {
150         .name                   = "P1023 RDS",
151         .probe                  = p1023_rds_probe,
152         .setup_arch             = mpc85xx_rds_setup_arch,
153         .init_IRQ               = mpc85xx_rds_pic_init,
154         .get_irq                = mpic_get_irq,
155         .restart                = fsl_rstcr_restart,
156         .calibrate_decr         = generic_calibrate_decr,
157         .progress               = udbg_progress,
158 #ifdef CONFIG_PCI
159         .pcibios_fixup_bus      = fsl_pcibios_fixup_bus,
160 #endif
161 };
162