blob: 30394b409b3f98655074d4f55e9514912b3506a5 [file] [log] [blame]
Vitaly Bordug91bd6102006-10-02 22:45:17 +04001/*
Scott Woode00c5492007-09-14 15:41:56 -05002 * MPC8272 ADS board support
Vitaly Bordug91bd6102006-10-02 22:45:17 +04003 *
Scott Woode00c5492007-09-14 15:41:56 -05004 * Copyright 2007 Freescale Semiconductor, Inc.
5 * Author: Scott Wood <scottwood@freescale.com>
Vitaly Bordug91bd6102006-10-02 22:45:17 +04006 *
Scott Woode00c5492007-09-14 15:41:56 -05007 * Based on code by Vitaly Bordug <vbordug@ru.mvista.com>
Vitaly Bordug91bd6102006-10-02 22:45:17 +04008 * Copyright (c) 2006 MontaVista Software, Inc.
9 *
10 * This program is free software; you can redistribute it and/or modify it
11 * under the terms of the GNU General Public License as published by the
12 * Free Software Foundation; either version 2 of the License, or (at your
13 * option) any later version.
14 */
15
Vitaly Bordug91bd6102006-10-02 22:45:17 +040016#include <linux/init.h>
Vitaly Bordug91bd6102006-10-02 22:45:17 +040017#include <linux/interrupt.h>
Vitaly Bordug91bd6102006-10-02 22:45:17 +040018#include <linux/fsl_devices.h>
Scott Woode00c5492007-09-14 15:41:56 -050019#include <linux/of_platform.h>
20#include <linux/io.h>
Vitaly Bordug91bd6102006-10-02 22:45:17 +040021
Vitaly Bordug91bd6102006-10-02 22:45:17 +040022#include <asm/cpm2.h>
23#include <asm/udbg.h>
Scott Woode00c5492007-09-14 15:41:56 -050024#include <asm/machdep.h>
25#include <asm/time.h>
26
27#include <platforms/82xx/pq2.h>
Vitaly Bordug91bd6102006-10-02 22:45:17 +040028
29#include <sysdev/fsl_soc.h>
Arnd Bergmann14305602007-06-18 01:06:55 +020030#include <sysdev/cpm2_pic.h>
Vitaly Bordug91bd6102006-10-02 22:45:17 +040031
Scott Woode00c5492007-09-14 15:41:56 -050032#include "pq2.h"
Vitaly Bordug91bd6102006-10-02 22:45:17 +040033
Scott Wood2d2294a2007-07-26 13:52:28 -050034static void __init mpc8272_ads_pic_init(void)
Vitaly Bordug91bd6102006-10-02 22:45:17 +040035{
Scott Woode00c5492007-09-14 15:41:56 -050036 struct device_node *np = of_find_compatible_node(NULL, NULL,
37 "fsl,cpm2-pic");
38 if (!np) {
39 printk(KERN_ERR "PIC init: can not find fsl,cpm2-pic node\n");
40 return;
41 }
Vitaly Bordug91bd6102006-10-02 22:45:17 +040042
Vitaly Bordug91bd6102006-10-02 22:45:17 +040043 cpm2_pic_init(np);
44 of_node_put(np);
45
Vitaly Bordug91bd6102006-10-02 22:45:17 +040046 /* Initialize stuff for the 82xx CPLD IC and install demux */
Scott Woode00c5492007-09-14 15:41:56 -050047 pq2ads_pci_init_irq();
Vitaly Bordug91bd6102006-10-02 22:45:17 +040048}
49
Scott Woode00c5492007-09-14 15:41:56 -050050struct cpm_pin {
51 int port, pin, flags;
Vitaly Bordug91bd6102006-10-02 22:45:17 +040052};
53
Scott Woode00c5492007-09-14 15:41:56 -050054static struct cpm_pin mpc8272_ads_pins[] = {
55 /* SCC1 */
56 {3, 30, CPM_PIN_OUTPUT | CPM_PIN_SECONDARY},
57 {3, 31, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
Vitaly Bordug91bd6102006-10-02 22:45:17 +040058
Scott Woode00c5492007-09-14 15:41:56 -050059 /* SCC4 */
60 {3, 21, CPM_PIN_OUTPUT | CPM_PIN_PRIMARY},
61 {3, 22, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
Vitaly Bordug91bd6102006-10-02 22:45:17 +040062
Scott Woode00c5492007-09-14 15:41:56 -050063 /* FCC1 */
64 {0, 14, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
65 {0, 15, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
66 {0, 16, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
67 {0, 17, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
68 {0, 18, CPM_PIN_OUTPUT | CPM_PIN_PRIMARY},
69 {0, 19, CPM_PIN_OUTPUT | CPM_PIN_PRIMARY},
70 {0, 20, CPM_PIN_OUTPUT | CPM_PIN_PRIMARY},
71 {0, 21, CPM_PIN_OUTPUT | CPM_PIN_PRIMARY},
72 {0, 26, CPM_PIN_INPUT | CPM_PIN_SECONDARY},
73 {0, 27, CPM_PIN_INPUT | CPM_PIN_SECONDARY},
74 {0, 28, CPM_PIN_OUTPUT | CPM_PIN_SECONDARY},
75 {0, 29, CPM_PIN_OUTPUT | CPM_PIN_SECONDARY},
76 {0, 30, CPM_PIN_INPUT | CPM_PIN_SECONDARY},
77 {0, 31, CPM_PIN_INPUT | CPM_PIN_SECONDARY},
78 {2, 21, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
79 {2, 22, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
Vitaly Bordug91bd6102006-10-02 22:45:17 +040080
Scott Woode00c5492007-09-14 15:41:56 -050081 /* FCC2 */
82 {1, 18, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
83 {1, 19, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
84 {1, 20, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
85 {1, 21, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
86 {1, 22, CPM_PIN_OUTPUT | CPM_PIN_PRIMARY},
87 {1, 23, CPM_PIN_OUTPUT | CPM_PIN_PRIMARY},
88 {1, 24, CPM_PIN_OUTPUT | CPM_PIN_PRIMARY},
89 {1, 25, CPM_PIN_OUTPUT | CPM_PIN_PRIMARY},
90 {1, 26, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
91 {1, 27, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
92 {1, 28, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
93 {1, 29, CPM_PIN_OUTPUT | CPM_PIN_SECONDARY},
94 {1, 30, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
95 {1, 31, CPM_PIN_OUTPUT | CPM_PIN_PRIMARY},
96 {2, 16, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
97 {2, 17, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
Jochen Friedricha5d28c82008-07-02 18:06:13 +020098
99 /* I2C */
100 {3, 14, CPM_PIN_INPUT | CPM_PIN_SECONDARY | CPM_PIN_OPENDRAIN},
101 {3, 15, CPM_PIN_INPUT | CPM_PIN_SECONDARY | CPM_PIN_OPENDRAIN},
Anton Vorontsov818fcac2009-08-19 03:28:17 +0400102
103 /* USB */
104 {2, 10, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
105 {2, 11, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
106 {2, 20, CPM_PIN_OUTPUT | CPM_PIN_PRIMARY},
107 {2, 24, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
108 {3, 23, CPM_PIN_OUTPUT | CPM_PIN_PRIMARY},
109 {3, 24, CPM_PIN_OUTPUT | CPM_PIN_PRIMARY},
110 {3, 25, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
Vitaly Bordug91bd6102006-10-02 22:45:17 +0400111};
112
Scott Woode00c5492007-09-14 15:41:56 -0500113static void __init init_ioports(void)
Vitaly Bordug91bd6102006-10-02 22:45:17 +0400114{
Vitaly Bordug91bd6102006-10-02 22:45:17 +0400115 int i;
Vitaly Bordug91bd6102006-10-02 22:45:17 +0400116
Scott Woode00c5492007-09-14 15:41:56 -0500117 for (i = 0; i < ARRAY_SIZE(mpc8272_ads_pins); i++) {
118 struct cpm_pin *pin = &mpc8272_ads_pins[i];
119 cpm2_set_pin(pin->port, pin->pin, pin->flags);
Vitaly Bordug91bd6102006-10-02 22:45:17 +0400120 }
Vitaly Bordug91bd6102006-10-02 22:45:17 +0400121
Scott Woode00c5492007-09-14 15:41:56 -0500122 cpm2_clk_setup(CPM_CLK_SCC1, CPM_BRG1, CPM_CLK_RX);
123 cpm2_clk_setup(CPM_CLK_SCC1, CPM_BRG1, CPM_CLK_TX);
Anton Vorontsov818fcac2009-08-19 03:28:17 +0400124 cpm2_clk_setup(CPM_CLK_SCC3, CPM_CLK8, CPM_CLK_RX);
125 cpm2_clk_setup(CPM_CLK_SCC3, CPM_CLK8, CPM_CLK_TX);
Scott Woode00c5492007-09-14 15:41:56 -0500126 cpm2_clk_setup(CPM_CLK_SCC4, CPM_BRG4, CPM_CLK_RX);
127 cpm2_clk_setup(CPM_CLK_SCC4, CPM_BRG4, CPM_CLK_TX);
128 cpm2_clk_setup(CPM_CLK_FCC1, CPM_CLK11, CPM_CLK_RX);
129 cpm2_clk_setup(CPM_CLK_FCC1, CPM_CLK10, CPM_CLK_TX);
130 cpm2_clk_setup(CPM_CLK_FCC2, CPM_CLK15, CPM_CLK_RX);
131 cpm2_clk_setup(CPM_CLK_FCC2, CPM_CLK16, CPM_CLK_TX);
Vitaly Bordug91bd6102006-10-02 22:45:17 +0400132}
133
Scott Wood2d2294a2007-07-26 13:52:28 -0500134static void __init mpc8272_ads_setup_arch(void)
Vitaly Bordug91bd6102006-10-02 22:45:17 +0400135{
Vitaly Bordug91bd6102006-10-02 22:45:17 +0400136 struct device_node *np;
Scott Woode00c5492007-09-14 15:41:56 -0500137 __be32 __iomem *bcsr;
Vitaly Bordug91bd6102006-10-02 22:45:17 +0400138
139 if (ppc_md.progress)
Scott Wood2d2294a2007-07-26 13:52:28 -0500140 ppc_md.progress("mpc8272_ads_setup_arch()", 0);
Scott Woode00c5492007-09-14 15:41:56 -0500141
Vitaly Bordug91bd6102006-10-02 22:45:17 +0400142 cpm2_reset();
143
Scott Woode00c5492007-09-14 15:41:56 -0500144 np = of_find_compatible_node(NULL, NULL, "fsl,mpc8272ads-bcsr");
145 if (!np) {
146 printk(KERN_ERR "No bcsr in device tree\n");
147 return;
148 }
Vitaly Bordug91bd6102006-10-02 22:45:17 +0400149
Scott Woode00c5492007-09-14 15:41:56 -0500150 bcsr = of_iomap(np, 0);
Julia Lawall75e89b02008-02-04 23:35:00 -0800151 of_node_put(np);
Scott Woode00c5492007-09-14 15:41:56 -0500152 if (!bcsr) {
153 printk(KERN_ERR "Cannot map BCSR registers\n");
154 return;
155 }
Vitaly Bordug91bd6102006-10-02 22:45:17 +0400156
Anton Vorontsova70e88b2009-08-19 03:28:10 +0400157#define BCSR1_FETHIEN 0x08000000
158#define BCSR1_FETH_RST 0x04000000
159#define BCSR1_RS232_EN1 0x02000000
160#define BCSR1_RS232_EN2 0x01000000
Anton Vorontsov818fcac2009-08-19 03:28:17 +0400161#define BCSR3_USB_nEN 0x80000000
Anton Vorontsova70e88b2009-08-19 03:28:10 +0400162#define BCSR3_FETHIEN2 0x10000000
163#define BCSR3_FETH2_RST 0x08000000
164
Scott Woode00c5492007-09-14 15:41:56 -0500165 clrbits32(&bcsr[1], BCSR1_RS232_EN1 | BCSR1_RS232_EN2 | BCSR1_FETHIEN);
166 setbits32(&bcsr[1], BCSR1_FETH_RST);
167
168 clrbits32(&bcsr[3], BCSR3_FETHIEN2);
169 setbits32(&bcsr[3], BCSR3_FETH2_RST);
170
Anton Vorontsov818fcac2009-08-19 03:28:17 +0400171 clrbits32(&bcsr[3], BCSR3_USB_nEN);
172
Scott Woode00c5492007-09-14 15:41:56 -0500173 iounmap(bcsr);
174
175 init_ioports();
176 pq2_init_pci();
Vitaly Bordug91bd6102006-10-02 22:45:17 +0400177
178 if (ppc_md.progress)
Scott Wood2d2294a2007-07-26 13:52:28 -0500179 ppc_md.progress("mpc8272_ads_setup_arch(), finish", 0);
Vitaly Bordug91bd6102006-10-02 22:45:17 +0400180}
181
Scott Woode00c5492007-09-14 15:41:56 -0500182static struct of_device_id __initdata of_bus_ids[] = {
183 { .name = "soc", },
184 { .name = "cpm", },
185 { .name = "localbus", },
186 {},
187};
188
189static int __init declare_of_platform_devices(void)
190{
Scott Woode00c5492007-09-14 15:41:56 -0500191 /* Publish the QE devices */
192 of_platform_bus_probe(NULL, of_bus_ids, NULL);
193 return 0;
194}
Grant Likelyca956f02008-01-24 22:23:24 -0700195machine_device_initcall(mpc8272_ads, declare_of_platform_devices);
Scott Woode00c5492007-09-14 15:41:56 -0500196
Vitaly Bordug91bd6102006-10-02 22:45:17 +0400197/*
198 * Called very early, device-tree isn't unflattened
199 */
Scott Wood2d2294a2007-07-26 13:52:28 -0500200static int __init mpc8272_ads_probe(void)
Vitaly Bordug91bd6102006-10-02 22:45:17 +0400201{
Scott Woode00c5492007-09-14 15:41:56 -0500202 unsigned long root = of_get_flat_dt_root();
203 return of_flat_dt_is_compatible(root, "fsl,mpc8272ads");
Vitaly Bordug91bd6102006-10-02 22:45:17 +0400204}
205
Scott Wood2d2294a2007-07-26 13:52:28 -0500206define_machine(mpc8272_ads)
Vitaly Bordug91bd6102006-10-02 22:45:17 +0400207{
Scott Woode00c5492007-09-14 15:41:56 -0500208 .name = "Freescale MPC8272 ADS",
209 .probe = mpc8272_ads_probe,
210 .setup_arch = mpc8272_ads_setup_arch,
211 .init_IRQ = mpc8272_ads_pic_init,
212 .get_irq = cpm2_get_irq,
Scott Wood4ff62e12007-08-27 16:56:43 -0500213 .calibrate_decr = generic_calibrate_decr,
Scott Woode00c5492007-09-14 15:41:56 -0500214 .restart = pq2_restart,
215 .progress = udbg_progress,
Vitaly Bordug91bd6102006-10-02 22:45:17 +0400216};