]> git.kernelconcepts.de Git - karo-tx-linux.git/blob - arch/powerpc/platforms/85xx/tqm85xx.c
powerpc/mpic: Search for open-pic device-tree node if NULL
[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 = mpic_alloc(NULL, 0,
50                         MPIC_PRIMARY | MPIC_WANTS_RESET | MPIC_BIG_ENDIAN,
51                         0, 256, " OpenPIC  ");
52         BUG_ON(mpic == NULL);
53         mpic_init(mpic);
54
55         mpc85xx_cpm2_pic_init();
56 }
57
58 /*
59  * Setup the architecture
60  */
61 static void __init tqm85xx_setup_arch(void)
62 {
63 #ifdef CONFIG_PCI
64         struct device_node *np;
65 #endif
66
67         if (ppc_md.progress)
68                 ppc_md.progress("tqm85xx_setup_arch()", 0);
69
70 #ifdef CONFIG_CPM2
71         cpm2_reset();
72 #endif
73
74 #ifdef CONFIG_PCI
75         for_each_node_by_type(np, "pci") {
76                 if (of_device_is_compatible(np, "fsl,mpc8540-pci") ||
77                     of_device_is_compatible(np, "fsl,mpc8548-pcie")) {
78                         struct resource rsrc;
79                         if (!of_address_to_resource(np, 0, &rsrc)) {
80                                 if ((rsrc.start & 0xfffff) == 0x8000)
81                                         fsl_add_bridge(np, 1);
82                                 else
83                                         fsl_add_bridge(np, 0);
84                         }
85                 }
86         }
87 #endif
88 }
89
90 static void tqm85xx_show_cpuinfo(struct seq_file *m)
91 {
92         uint pvid, svid, phid1;
93
94         pvid = mfspr(SPRN_PVR);
95         svid = mfspr(SPRN_SVR);
96
97         seq_printf(m, "Vendor\t\t: TQ Components\n");
98         seq_printf(m, "PVR\t\t: 0x%x\n", pvid);
99         seq_printf(m, "SVR\t\t: 0x%x\n", svid);
100
101         /* Display cpu Pll setting */
102         phid1 = mfspr(SPRN_HID1);
103         seq_printf(m, "PLL setting\t: 0x%x\n", ((phid1 >> 24) & 0x3f));
104 }
105
106 static void __init tqm85xx_ti1520_fixup(struct pci_dev *pdev)
107 {
108         unsigned int val;
109
110         /* Do not do the fixup on other platforms! */
111         if (!machine_is(tqm85xx))
112                 return;
113
114         dev_info(&pdev->dev, "Using TI 1520 fixup on TQM85xx\n");
115
116         /*
117          * Enable P2CCLK bit in system control register
118          * to enable CLOCK output to power chip
119          */
120         pci_read_config_dword(pdev, 0x80, &val);
121         pci_write_config_dword(pdev, 0x80, val | (1 << 27));
122
123 }
124 DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_1520,
125                 tqm85xx_ti1520_fixup);
126
127 machine_device_initcall(tqm85xx, mpc85xx_common_publish_devices);
128
129 static const char *board[] __initdata = {
130         "tqc,tqm8540",
131         "tqc,tqm8541",
132         "tqc,tqm8548",
133         "tqc,tqm8555",
134         "tqc,tqm8560",
135         NULL
136 };
137
138 /*
139  * Called very early, device-tree isn't unflattened
140  */
141 static int __init tqm85xx_probe(void)
142 {
143         return of_flat_dt_match(of_get_flat_dt_root(), board);
144 }
145
146 define_machine(tqm85xx) {
147         .name                   = "TQM85xx",
148         .probe                  = tqm85xx_probe,
149         .setup_arch             = tqm85xx_setup_arch,
150         .init_IRQ               = tqm85xx_pic_init,
151         .show_cpuinfo           = tqm85xx_show_cpuinfo,
152         .get_irq                = mpic_get_irq,
153         .restart                = fsl_rstcr_restart,
154         .calibrate_decr         = generic_calibrate_decr,
155         .progress               = udbg_progress,
156 };