]> git.karo-electronics.de Git - karo-tx-linux.git/blob - arch/powerpc/platforms/85xx/tqm85xx.c
powerpc/85xx: consolidate of_platform_bus_probe calls
[karo-tx-linux.git] / arch / powerpc / platforms / 85xx / tqm85xx.c
1 /*
2  * Based on MPC8560 ADS and arch/ppc tqm85xx ports
3  *
4  * Maintained by Kumar Gala (see MAINTAINERS for contact information)
5  *
6  * Copyright 2008 Freescale Semiconductor Inc.
7  *
8  * Copyright (c) 2005-2006 DENX Software Engineering
9  * Stefan Roese <sr@denx.de>
10  *
11  * Based on original work by
12  *      Kumar Gala <kumar.gala@freescale.com>
13  *      Copyright 2004 Freescale Semiconductor Inc.
14  *
15  * This program is free software; you can redistribute  it and/or modify it
16  * under  the terms of  the GNU General  Public License as published by the
17  * Free Software Foundation;  either version 2 of the  License, or (at your
18  * option) any later version.
19  */
20
21 #include <linux/stddef.h>
22 #include <linux/kernel.h>
23 #include <linux/pci.h>
24 #include <linux/kdev_t.h>
25 #include <linux/delay.h>
26 #include <linux/seq_file.h>
27 #include <linux/of_platform.h>
28
29 #include <asm/system.h>
30 #include <asm/time.h>
31 #include <asm/machdep.h>
32 #include <asm/pci-bridge.h>
33 #include <asm/mpic.h>
34 #include <asm/prom.h>
35 #include <mm/mmu_decl.h>
36 #include <asm/udbg.h>
37
38 #include <sysdev/fsl_soc.h>
39 #include <sysdev/fsl_pci.h>
40
41 #include "mpc85xx.h"
42
43 #ifdef CONFIG_CPM2
44 #include <asm/cpm2.h>
45 #endif /* CONFIG_CPM2 */
46
47 static void __init tqm85xx_pic_init(void)
48 {
49         struct mpic *mpic;
50         struct resource r;
51         struct device_node *np;
52
53         np = of_find_node_by_type(NULL, "open-pic");
54         if (!np) {
55                 printk(KERN_ERR "Could not find open-pic node\n");
56                 return;
57         }
58
59         if (of_address_to_resource(np, 0, &r)) {
60                 printk(KERN_ERR "Could not map mpic register space\n");
61                 of_node_put(np);
62                 return;
63         }
64
65         mpic = mpic_alloc(np, r.start,
66                         MPIC_PRIMARY | MPIC_WANTS_RESET | MPIC_BIG_ENDIAN,
67                         0, 256, " OpenPIC  ");
68         BUG_ON(mpic == NULL);
69         of_node_put(np);
70
71         mpic_init(mpic);
72
73         mpc85xx_cpm2_pic_init();
74 }
75
76 /*
77  * Setup the architecture
78  */
79 static void __init tqm85xx_setup_arch(void)
80 {
81 #ifdef CONFIG_PCI
82         struct device_node *np;
83 #endif
84
85         if (ppc_md.progress)
86                 ppc_md.progress("tqm85xx_setup_arch()", 0);
87
88 #ifdef CONFIG_CPM2
89         cpm2_reset();
90 #endif
91
92 #ifdef CONFIG_PCI
93         for_each_node_by_type(np, "pci") {
94                 if (of_device_is_compatible(np, "fsl,mpc8540-pci") ||
95                     of_device_is_compatible(np, "fsl,mpc8548-pcie")) {
96                         struct resource rsrc;
97                         if (!of_address_to_resource(np, 0, &rsrc)) {
98                                 if ((rsrc.start & 0xfffff) == 0x8000)
99                                         fsl_add_bridge(np, 1);
100                                 else
101                                         fsl_add_bridge(np, 0);
102                         }
103                 }
104         }
105 #endif
106 }
107
108 static void tqm85xx_show_cpuinfo(struct seq_file *m)
109 {
110         uint pvid, svid, phid1;
111
112         pvid = mfspr(SPRN_PVR);
113         svid = mfspr(SPRN_SVR);
114
115         seq_printf(m, "Vendor\t\t: TQ Components\n");
116         seq_printf(m, "PVR\t\t: 0x%x\n", pvid);
117         seq_printf(m, "SVR\t\t: 0x%x\n", svid);
118
119         /* Display cpu Pll setting */
120         phid1 = mfspr(SPRN_HID1);
121         seq_printf(m, "PLL setting\t: 0x%x\n", ((phid1 >> 24) & 0x3f));
122 }
123
124 static void __init tqm85xx_ti1520_fixup(struct pci_dev *pdev)
125 {
126         unsigned int val;
127
128         /* Do not do the fixup on other platforms! */
129         if (!machine_is(tqm85xx))
130                 return;
131
132         dev_info(&pdev->dev, "Using TI 1520 fixup on TQM85xx\n");
133
134         /*
135          * Enable P2CCLK bit in system control register
136          * to enable CLOCK output to power chip
137          */
138         pci_read_config_dword(pdev, 0x80, &val);
139         pci_write_config_dword(pdev, 0x80, val | (1 << 27));
140
141 }
142 DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_1520,
143                 tqm85xx_ti1520_fixup);
144
145 machine_device_initcall(tqm85xx, mpc85xx_common_publish_devices);
146
147 static const char *board[] __initdata = {
148         "tqc,tqm8540",
149         "tqc,tqm8541",
150         "tqc,tqm8548",
151         "tqc,tqm8555",
152         "tqc,tqm8560",
153         NULL
154 };
155
156 /*
157  * Called very early, device-tree isn't unflattened
158  */
159 static int __init tqm85xx_probe(void)
160 {
161         return of_flat_dt_match(of_get_flat_dt_root(), board);
162 }
163
164 define_machine(tqm85xx) {
165         .name                   = "TQM85xx",
166         .probe                  = tqm85xx_probe,
167         .setup_arch             = tqm85xx_setup_arch,
168         .init_IRQ               = tqm85xx_pic_init,
169         .show_cpuinfo           = tqm85xx_show_cpuinfo,
170         .get_irq                = mpic_get_irq,
171         .restart                = fsl_rstcr_restart,
172         .calibrate_decr         = generic_calibrate_decr,
173         .progress               = udbg_progress,
174 };