aboutsummaryrefslogtreecommitdiffstats
path: root/arch/powerpc/platforms/8xx/mpc86xads_setup.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/powerpc/platforms/8xx/mpc86xads_setup.c')
-rw-r--r--arch/powerpc/platforms/8xx/mpc86xads_setup.c289
1 files changed, 80 insertions, 209 deletions
diff --git a/arch/powerpc/platforms/8xx/mpc86xads_setup.c b/arch/powerpc/platforms/8xx/mpc86xads_setup.c
index 49012835f453..d2927a434aef 100644
--- a/arch/powerpc/platforms/8xx/mpc86xads_setup.c
+++ b/arch/powerpc/platforms/8xx/mpc86xads_setup.c
@@ -6,264 +6,134 @@
6 * 6 *
7 * Copyright 2005 MontaVista Software Inc. 7 * Copyright 2005 MontaVista Software Inc.
8 * 8 *
9 * Heavily modified by Scott Wood <scottwood@freescale.com>
10 * Copyright 2007 Freescale Semiconductor, Inc.
11 *
9 * This file is licensed under the terms of the GNU General Public License 12 * This file is licensed under the terms of the GNU General Public License
10 * version 2. This program is licensed "as is" without any warranty of any 13 * version 2. This program is licensed "as is" without any warranty of any
11 * kind, whether express or implied. 14 * kind, whether express or implied.
12 */ 15 */
13 16
14#include <linux/init.h> 17#include <linux/init.h>
15#include <linux/module.h> 18#include <linux/of_platform.h>
16#include <linux/param.h>
17#include <linux/string.h>
18#include <linux/ioport.h>
19#include <linux/device.h>
20#include <linux/delay.h>
21#include <linux/root_dev.h>
22
23#include <linux/fs_enet_pd.h>
24#include <linux/fs_uart_pd.h>
25#include <linux/mii.h>
26 19
27#include <asm/delay.h>
28#include <asm/io.h> 20#include <asm/io.h>
29#include <asm/machdep.h> 21#include <asm/machdep.h>
30#include <asm/page.h>
31#include <asm/processor.h>
32#include <asm/system.h> 22#include <asm/system.h>
33#include <asm/time.h> 23#include <asm/time.h>
34#include <asm/mpc8xx.h> 24#include <asm/mpc8xx.h>
35#include <asm/8xx_immap.h> 25#include <asm/8xx_immap.h>
36#include <asm/commproc.h> 26#include <asm/commproc.h>
37#include <asm/fs_pd.h> 27#include <asm/fs_pd.h>
38#include <asm/prom.h> 28#include <asm/udbg.h>
39 29
40#include <sysdev/commproc.h> 30#include <sysdev/commproc.h>
41 31
42static void init_smc1_uart_ioports(struct fs_uart_platform_info* fpi); 32#include "mpc86xads.h"
43static void init_smc2_uart_ioports(struct fs_uart_platform_info* fpi);
44static void init_scc1_ioports(struct fs_platform_info* ptr);
45
46void __init mpc86xads_board_setup(void)
47{
48 cpm8xx_t *cp;
49 unsigned int *bcsr_io;
50 u8 tmpval8;
51
52 bcsr_io = ioremap(BCSR1, sizeof(unsigned long));
53 cp = (cpm8xx_t *)immr_map(im_cpm);
54
55 if (bcsr_io == NULL) {
56 printk(KERN_CRIT "Could not remap BCSR\n");
57 return;
58 }
59#ifdef CONFIG_SERIAL_CPM_SMC1
60 clrbits32(bcsr_io, BCSR1_RS232EN_1);
61 clrbits32(&cp->cp_simode, 0xe0000000 >> 17); /* brg1 */
62 tmpval8 = in_8(&(cp->cp_smc[0].smc_smcm)) | (SMCM_RX | SMCM_TX);
63 out_8(&(cp->cp_smc[0].smc_smcm), tmpval8);
64 clrbits16(&cp->cp_smc[0].smc_smcmr, SMCMR_REN | SMCMR_TEN);
65#else
66 setbits32(bcsr_io,BCSR1_RS232EN_1);
67 out_be16(&cp->cp_smc[0].smc_smcmr, 0);
68 out_8(&cp->cp_smc[0].smc_smce, 0);
69#endif
70
71#ifdef CONFIG_SERIAL_CPM_SMC2
72 clrbits32(bcsr_io,BCSR1_RS232EN_2);
73 clrbits32(&cp->cp_simode, 0xe0000000 >> 1);
74 setbits32(&cp->cp_simode, 0x20000000 >> 1); /* brg2 */
75 tmpval8 = in_8(&(cp->cp_smc[1].smc_smcm)) | (SMCM_RX | SMCM_TX);
76 out_8(&(cp->cp_smc[1].smc_smcm), tmpval8);
77 clrbits16(&cp->cp_smc[1].smc_smcmr, SMCMR_REN | SMCMR_TEN);
78 33
79 init_smc2_uart_ioports(0); 34struct cpm_pin {
80#else 35 int port, pin, flags;
81 setbits32(bcsr_io,BCSR1_RS232EN_2); 36};
82 out_be16(&cp->cp_smc[1].smc_smcmr, 0);
83 out_8(&cp->cp_smc[1].smc_smce, 0);
84#endif
85 immr_unmap(cp);
86 iounmap(bcsr_io);
87}
88 37
38static struct cpm_pin mpc866ads_pins[] = {
39 /* SMC1 */
40 {CPM_PORTB, 24, CPM_PIN_INPUT}, /* RX */
41 {CPM_PORTB, 25, CPM_PIN_INPUT | CPM_PIN_SECONDARY}, /* TX */
42
43 /* SMC2 */
44 {CPM_PORTB, 21, CPM_PIN_INPUT}, /* RX */
45 {CPM_PORTB, 20, CPM_PIN_INPUT | CPM_PIN_SECONDARY}, /* TX */
46
47 /* SCC1 */
48 {CPM_PORTA, 6, CPM_PIN_INPUT}, /* CLK1 */
49 {CPM_PORTA, 7, CPM_PIN_INPUT}, /* CLK2 */
50 {CPM_PORTA, 14, CPM_PIN_INPUT}, /* TX */
51 {CPM_PORTA, 15, CPM_PIN_INPUT}, /* RX */
52 {CPM_PORTB, 19, CPM_PIN_INPUT | CPM_PIN_SECONDARY}, /* TENA */
53 {CPM_PORTC, 10, CPM_PIN_INPUT | CPM_PIN_SECONDARY | CPM_PIN_GPIO}, /* RENA */
54 {CPM_PORTC, 11, CPM_PIN_INPUT | CPM_PIN_SECONDARY | CPM_PIN_GPIO}, /* CLSN */
55
56 /* MII */
57 {CPM_PORTD, 3, CPM_PIN_OUTPUT},
58 {CPM_PORTD, 4, CPM_PIN_OUTPUT},
59 {CPM_PORTD, 5, CPM_PIN_OUTPUT},
60 {CPM_PORTD, 6, CPM_PIN_OUTPUT},
61 {CPM_PORTD, 7, CPM_PIN_OUTPUT},
62 {CPM_PORTD, 8, CPM_PIN_OUTPUT},
63 {CPM_PORTD, 9, CPM_PIN_OUTPUT},
64 {CPM_PORTD, 10, CPM_PIN_OUTPUT},
65 {CPM_PORTD, 11, CPM_PIN_OUTPUT},
66 {CPM_PORTD, 12, CPM_PIN_OUTPUT},
67 {CPM_PORTD, 13, CPM_PIN_OUTPUT},
68 {CPM_PORTD, 14, CPM_PIN_OUTPUT},
69 {CPM_PORTD, 15, CPM_PIN_OUTPUT},
70};
89 71
90static void init_fec1_ioports(struct fs_platform_info* ptr) 72static void __init init_ioports(void)
91{ 73{
92 iop8xx_t *io_port = (iop8xx_t *)immr_map(im_ioport); 74 int i;
93 75
94 /* configure FEC1 pins */ 76 for (i = 0; i < ARRAY_SIZE(mpc866ads_pins); i++) {
77 struct cpm_pin *pin = &mpc866ads_pins[i];
78 cpm1_set_pin(pin->port, pin->pin, pin->flags);
79 }
95 80
96 setbits16(&io_port->iop_pdpar, 0x1fff); 81 cpm1_clk_setup(CPM_CLK_SMC1, CPM_BRG1, CPM_CLK_RTX);
97 setbits16(&io_port->iop_pddir, 0x1fff); 82 cpm1_clk_setup(CPM_CLK_SMC2, CPM_BRG2, CPM_CLK_RTX);
83 cpm1_clk_setup(CPM_CLK_SCC1, CPM_CLK1, CPM_CLK_TX);
84 cpm1_clk_setup(CPM_CLK_SCC1, CPM_CLK2, CPM_CLK_RX);
98 85
99 immr_unmap(io_port); 86 /* Set FEC1 and FEC2 to MII mode */
87 clrbits32(&mpc8xx_immr->im_cpm.cp_cptr, 0x00000180);
100} 88}
101 89
102void init_fec_ioports(struct fs_platform_info *fpi) 90static void __init mpc86xads_setup_arch(void)
103{ 91{
104 int fec_no = fs_get_fec_index(fpi->fs_no); 92 struct device_node *np;
93 u32 __iomem *bcsr_io;
94
95 cpm_reset();
96 init_ioports();
105 97
106 switch (fec_no) { 98 np = of_find_compatible_node(NULL, NULL, "fsl,mpc866ads-bcsr");
107 case 0: 99 if (!np) {
108 init_fec1_ioports(fpi); 100 printk(KERN_CRIT "Could not find fsl,mpc866ads-bcsr node\n");
109 break;
110 default:
111 printk(KERN_ERR "init_fec_ioports: invalid FEC number\n");
112 return; 101 return;
113 } 102 }
114}
115 103
116static void init_scc1_ioports(struct fs_platform_info* fpi) 104 bcsr_io = of_iomap(np, 0);
117{ 105 of_node_put(np);
118 unsigned *bcsr_io;
119 iop8xx_t *io_port;
120 cpm8xx_t *cp;
121
122 bcsr_io = ioremap(BCSR_ADDR, BCSR_SIZE);
123 io_port = (iop8xx_t *)immr_map(im_ioport);
124 cp = (cpm8xx_t *)immr_map(im_cpm);
125 106
126 if (bcsr_io == NULL) { 107 if (bcsr_io == NULL) {
127 printk(KERN_CRIT "Could not remap BCSR\n"); 108 printk(KERN_CRIT "Could not remap BCSR\n");
128 return; 109 return;
129 } 110 }
130 111
131 /* Configure port A pins for Txd and Rxd. 112 clrbits32(bcsr_io, BCSR1_RS232EN_1 | BCSR1_RS232EN_2 | BCSR1_ETHEN);
132 */
133 setbits16(&io_port->iop_papar, PA_ENET_RXD | PA_ENET_TXD);
134 clrbits16(&io_port->iop_padir, PA_ENET_RXD | PA_ENET_TXD);
135 clrbits16(&io_port->iop_paodr, PA_ENET_TXD);
136
137 /* Configure port C pins to enable CLSN and RENA.
138 */
139 clrbits16(&io_port->iop_pcpar, PC_ENET_CLSN | PC_ENET_RENA);
140 clrbits16(&io_port->iop_pcdir, PC_ENET_CLSN | PC_ENET_RENA);
141 setbits16(&io_port->iop_pcso, PC_ENET_CLSN | PC_ENET_RENA);
142
143 /* Configure port A for TCLK and RCLK.
144 */
145 setbits16(&io_port->iop_papar, PA_ENET_TCLK | PA_ENET_RCLK);
146 clrbits16(&io_port->iop_padir, PA_ENET_TCLK | PA_ENET_RCLK);
147 clrbits32(&cp->cp_pbpar, PB_ENET_TENA);
148 clrbits32(&cp->cp_pbdir, PB_ENET_TENA);
149
150 /* Configure Serial Interface clock routing.
151 * First, clear all SCC bits to zero, then set the ones we want.
152 */
153 clrbits32(&cp->cp_sicr, SICR_ENET_MASK);
154 setbits32(&cp->cp_sicr, SICR_ENET_CLKRT);
155
156 /* In the original SCC enet driver the following code is placed at
157 the end of the initialization */
158 setbits32(&cp->cp_pbpar, PB_ENET_TENA);
159 setbits32(&cp->cp_pbdir, PB_ENET_TENA);
160
161 clrbits32(bcsr_io+1, BCSR1_ETHEN);
162 iounmap(bcsr_io); 113 iounmap(bcsr_io);
163 immr_unmap(cp);
164 immr_unmap(io_port);
165}
166
167void init_scc_ioports(struct fs_platform_info *fpi)
168{
169 int scc_no = fs_get_scc_index(fpi->fs_no);
170
171 switch (scc_no) {
172 case 0:
173 init_scc1_ioports(fpi);
174 break;
175 default:
176 printk(KERN_ERR "init_scc_ioports: invalid SCC number\n");
177 return;
178 }
179} 114}
180 115
181 116static int __init mpc86xads_probe(void)
182
183static void init_smc1_uart_ioports(struct fs_uart_platform_info* ptr)
184{ 117{
185 unsigned *bcsr_io; 118 unsigned long root = of_get_flat_dt_root();
186 cpm8xx_t *cp = (cpm8xx_t *)immr_map(im_cpm); 119 return of_flat_dt_is_compatible(root, "fsl,mpc866ads");
187
188 setbits32(&cp->cp_pbpar, 0x000000c0);
189 clrbits32(&cp->cp_pbdir, 0x000000c0);
190 clrbits16(&cp->cp_pbodr, 0x00c0);
191 immr_unmap(cp);
192
193 bcsr_io = ioremap(BCSR1, sizeof(unsigned long));
194
195 if (bcsr_io == NULL) {
196 printk(KERN_CRIT "Could not remap BCSR1\n");
197 return;
198 }
199 clrbits32(bcsr_io,BCSR1_RS232EN_1);
200 iounmap(bcsr_io);
201} 120}
202 121
203static void init_smc2_uart_ioports(struct fs_uart_platform_info* fpi) 122static struct of_device_id __initdata of_bus_ids[] = {
204{ 123 { .name = "soc", },
205 unsigned *bcsr_io; 124 { .name = "cpm", },
206 cpm8xx_t *cp = (cpm8xx_t *)immr_map(im_cpm); 125 { .name = "localbus", },
207 126 {},
208 setbits32(&cp->cp_pbpar, 0x00000c00); 127};
209 clrbits32(&cp->cp_pbdir, 0x00000c00);
210 clrbits16(&cp->cp_pbodr, 0x0c00);
211 immr_unmap(cp);
212
213 bcsr_io = ioremap(BCSR1, sizeof(unsigned long));
214
215 if (bcsr_io == NULL) {
216 printk(KERN_CRIT "Could not remap BCSR1\n");
217 return;
218 }
219 clrbits32(bcsr_io,BCSR1_RS232EN_2);
220 iounmap(bcsr_io);
221}
222 128
223void init_smc_ioports(struct fs_uart_platform_info *data) 129static int __init declare_of_platform_devices(void)
224{ 130{
225 int smc_no = fs_uart_id_fsid2smc(data->fs_no); 131 if (machine_is(mpc86x_ads))
132 of_platform_bus_probe(NULL, of_bus_ids, NULL);
226 133
227 switch (smc_no) {
228 case 0:
229 init_smc1_uart_ioports(data);
230 data->brg = data->clk_rx;
231 break;
232 case 1:
233 init_smc2_uart_ioports(data);
234 data->brg = data->clk_rx;
235 break;
236 default:
237 printk(KERN_ERR "init_scc_ioports: invalid SCC number\n");
238 return;
239 }
240}
241
242int platform_device_skip(const char *model, int id)
243{
244 return 0; 134 return 0;
245} 135}
246 136device_initcall(declare_of_platform_devices);
247static void __init mpc86xads_setup_arch(void)
248{
249 cpm_reset();
250
251 mpc86xads_board_setup();
252
253 ROOT_DEV = Root_NFS;
254}
255
256static int __init mpc86xads_probe(void)
257{
258 char *model = of_get_flat_dt_prop(of_get_flat_dt_root(),
259 "model", NULL);
260 if (model == NULL)
261 return 0;
262 if (strcmp(model, "MPC866ADS"))
263 return 0;
264
265 return 1;
266}
267 137
268define_machine(mpc86x_ads) { 138define_machine(mpc86x_ads) {
269 .name = "MPC86x ADS", 139 .name = "MPC86x ADS",
@@ -275,4 +145,5 @@ define_machine(mpc86x_ads) {
275 .calibrate_decr = mpc8xx_calibrate_decr, 145 .calibrate_decr = mpc8xx_calibrate_decr,
276 .set_rtc_time = mpc8xx_set_rtc_time, 146 .set_rtc_time = mpc8xx_set_rtc_time,
277 .get_rtc_time = mpc8xx_get_rtc_time, 147 .get_rtc_time = mpc8xx_get_rtc_time,
148 .progress = udbg_progress,
278}; 149};