WIP FPC-III support
[linux/fpc-iii.git] / arch / powerpc / platforms / 82xx / pq2fads.c
bloba74082140718e6fad2ec4ecb2572d9944d46e0e0
1 // SPDX-License-Identifier: GPL-2.0-only
2 /*
3 * PQ2FADS board support
5 * Copyright 2007 Freescale Semiconductor, Inc.
6 * Author: Scott Wood <scottwood@freescale.com>
8 * Loosely based on mp82xx ADS support by Vitaly Bordug <vbordug@ru.mvista.com>
9 * Copyright (c) 2006 MontaVista Software, Inc.
12 #include <linux/init.h>
13 #include <linux/interrupt.h>
14 #include <linux/fsl_devices.h>
15 #include <linux/of_address.h>
16 #include <linux/of_fdt.h>
17 #include <linux/of_platform.h>
19 #include <asm/io.h>
20 #include <asm/cpm2.h>
21 #include <asm/udbg.h>
22 #include <asm/machdep.h>
23 #include <asm/time.h>
25 #include <sysdev/fsl_soc.h>
26 #include <sysdev/cpm2_pic.h>
28 #include "pq2ads.h"
29 #include "pq2.h"
31 static void __init pq2fads_pic_init(void)
33 struct device_node *np = of_find_compatible_node(NULL, NULL, "fsl,cpm2-pic");
34 if (!np) {
35 printk(KERN_ERR "PIC init: can not find fsl,cpm2-pic node\n");
36 return;
39 cpm2_pic_init(np);
40 of_node_put(np);
42 /* Initialize stuff for the 82xx CPLD IC and install demux */
43 pq2ads_pci_init_irq();
46 struct cpm_pin {
47 int port, pin, flags;
50 static struct cpm_pin pq2fads_pins[] = {
51 /* SCC1 */
52 {3, 30, CPM_PIN_OUTPUT | CPM_PIN_SECONDARY},
53 {3, 31, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
55 /* SCC2 */
56 {3, 27, CPM_PIN_OUTPUT | CPM_PIN_PRIMARY},
57 {3, 28, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
59 /* FCC2 */
60 {1, 18, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
61 {1, 19, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
62 {1, 20, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
63 {1, 21, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
64 {1, 22, CPM_PIN_OUTPUT | CPM_PIN_PRIMARY},
65 {1, 23, CPM_PIN_OUTPUT | CPM_PIN_PRIMARY},
66 {1, 24, CPM_PIN_OUTPUT | CPM_PIN_PRIMARY},
67 {1, 25, CPM_PIN_OUTPUT | CPM_PIN_PRIMARY},
68 {1, 26, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
69 {1, 27, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
70 {1, 28, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
71 {1, 29, CPM_PIN_OUTPUT | CPM_PIN_SECONDARY},
72 {1, 30, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
73 {1, 31, CPM_PIN_OUTPUT | CPM_PIN_PRIMARY},
74 {2, 18, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
75 {2, 19, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
77 /* FCC3 */
78 {1, 4, CPM_PIN_OUTPUT | CPM_PIN_PRIMARY},
79 {1, 5, CPM_PIN_OUTPUT | CPM_PIN_PRIMARY},
80 {1, 6, CPM_PIN_OUTPUT | CPM_PIN_PRIMARY},
81 {1, 7, CPM_PIN_OUTPUT | CPM_PIN_PRIMARY},
82 {1, 8, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
83 {1, 9, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
84 {1, 10, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
85 {1, 11, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
86 {1, 12, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
87 {1, 13, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
88 {1, 14, CPM_PIN_OUTPUT | CPM_PIN_PRIMARY},
89 {1, 15, CPM_PIN_OUTPUT | CPM_PIN_PRIMARY},
90 {1, 16, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
91 {1, 17, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
92 {2, 16, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
93 {2, 17, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
96 static void __init init_ioports(void)
98 int i;
100 for (i = 0; i < ARRAY_SIZE(pq2fads_pins); i++) {
101 struct cpm_pin *pin = &pq2fads_pins[i];
102 cpm2_set_pin(pin->port, pin->pin, pin->flags);
105 cpm2_clk_setup(CPM_CLK_SCC1, CPM_BRG1, CPM_CLK_RX);
106 cpm2_clk_setup(CPM_CLK_SCC1, CPM_BRG1, CPM_CLK_TX);
107 cpm2_clk_setup(CPM_CLK_SCC2, CPM_BRG2, CPM_CLK_RX);
108 cpm2_clk_setup(CPM_CLK_SCC2, CPM_BRG2, CPM_CLK_TX);
109 cpm2_clk_setup(CPM_CLK_FCC2, CPM_CLK13, CPM_CLK_RX);
110 cpm2_clk_setup(CPM_CLK_FCC2, CPM_CLK14, CPM_CLK_TX);
111 cpm2_clk_setup(CPM_CLK_FCC3, CPM_CLK15, CPM_CLK_RX);
112 cpm2_clk_setup(CPM_CLK_FCC3, CPM_CLK16, CPM_CLK_TX);
115 static void __init pq2fads_setup_arch(void)
117 struct device_node *np;
118 __be32 __iomem *bcsr;
120 if (ppc_md.progress)
121 ppc_md.progress("pq2fads_setup_arch()", 0);
123 cpm2_reset();
125 np = of_find_compatible_node(NULL, NULL, "fsl,pq2fads-bcsr");
126 if (!np) {
127 printk(KERN_ERR "No fsl,pq2fads-bcsr in device tree\n");
128 return;
131 bcsr = of_iomap(np, 0);
132 of_node_put(np);
133 if (!bcsr) {
134 printk(KERN_ERR "Cannot map BCSR registers\n");
135 return;
138 /* Enable the serial and ethernet ports */
140 clrbits32(&bcsr[1], BCSR1_RS232_EN1 | BCSR1_RS232_EN2 | BCSR1_FETHIEN);
141 setbits32(&bcsr[1], BCSR1_FETH_RST);
143 clrbits32(&bcsr[3], BCSR3_FETHIEN2);
144 setbits32(&bcsr[3], BCSR3_FETH2_RST);
146 iounmap(bcsr);
148 init_ioports();
150 /* Enable external IRQs */
151 clrbits32(&cpm2_immr->im_siu_conf.siu_82xx.sc_siumcr, 0x0c000000);
153 pq2_init_pci();
155 if (ppc_md.progress)
156 ppc_md.progress("pq2fads_setup_arch(), finish", 0);
160 * Called very early, device-tree isn't unflattened
162 static int __init pq2fads_probe(void)
164 return of_machine_is_compatible("fsl,pq2fads");
167 static const struct of_device_id of_bus_ids[] __initconst = {
168 { .name = "soc", },
169 { .name = "cpm", },
170 { .name = "localbus", },
174 static int __init declare_of_platform_devices(void)
176 /* Publish the QE devices */
177 of_platform_bus_probe(NULL, of_bus_ids, NULL);
178 return 0;
180 machine_device_initcall(pq2fads, declare_of_platform_devices);
182 define_machine(pq2fads)
184 .name = "Freescale PQ2FADS",
185 .probe = pq2fads_probe,
186 .setup_arch = pq2fads_setup_arch,
187 .init_IRQ = pq2fads_pic_init,
188 .get_irq = cpm2_get_irq,
189 .calibrate_decr = generic_calibrate_decr,
190 .restart = pq2_restart,
191 .progress = udbg_progress,