diff options
Diffstat (limited to 'arch/ppc/platforms/mpc866ads_setup.c')
-rw-r--r-- | arch/ppc/platforms/mpc866ads_setup.c | 140 |
1 files changed, 140 insertions, 0 deletions
diff --git a/arch/ppc/platforms/mpc866ads_setup.c b/arch/ppc/platforms/mpc866ads_setup.c index ac8fcc68afeb..6ce3b842defe 100644 --- a/arch/ppc/platforms/mpc866ads_setup.c +++ b/arch/ppc/platforms/mpc866ads_setup.c | |||
@@ -20,6 +20,7 @@ | |||
20 | #include <linux/device.h> | 20 | #include <linux/device.h> |
21 | 21 | ||
22 | #include <linux/fs_enet_pd.h> | 22 | #include <linux/fs_enet_pd.h> |
23 | #include <linux/fs_uart_pd.h> | ||
23 | #include <linux/mii.h> | 24 | #include <linux/mii.h> |
24 | 25 | ||
25 | #include <asm/delay.h> | 26 | #include <asm/delay.h> |
@@ -37,6 +38,11 @@ | |||
37 | 38 | ||
38 | extern unsigned char __res[]; | 39 | extern unsigned char __res[]; |
39 | 40 | ||
41 | static void setup_fec1_ioports(void); | ||
42 | static void setup_scc1_ioports(void); | ||
43 | static void setup_smc1_ioports(void); | ||
44 | static void setup_smc2_ioports(void); | ||
45 | |||
40 | static struct fs_mii_bus_info fec_mii_bus_info = { | 46 | static struct fs_mii_bus_info fec_mii_bus_info = { |
41 | .method = fsmii_fec, | 47 | .method = fsmii_fec, |
42 | .id = 0, | 48 | .id = 0, |
@@ -79,6 +85,28 @@ static struct fs_platform_info mpc8xx_scc_pdata = { | |||
79 | .phy_irq = -1, | 85 | .phy_irq = -1, |
80 | 86 | ||
81 | .bus_info = &scc_mii_bus_info, | 87 | .bus_info = &scc_mii_bus_info, |
88 | |||
89 | }; | ||
90 | |||
91 | static struct fs_uart_platform_info mpc866_uart_pdata[] = { | ||
92 | [fsid_smc1_uart] = { | ||
93 | .brg = 1, | ||
94 | .fs_no = fsid_smc1_uart, | ||
95 | .init_ioports = setup_smc1_ioports, | ||
96 | .tx_num_fifo = 4, | ||
97 | .tx_buf_size = 32, | ||
98 | .rx_num_fifo = 4, | ||
99 | .rx_buf_size = 32, | ||
100 | }, | ||
101 | [fsid_smc2_uart] = { | ||
102 | .brg = 2, | ||
103 | .fs_no = fsid_smc2_uart, | ||
104 | .init_ioports = setup_smc2_ioports, | ||
105 | .tx_num_fifo = 4, | ||
106 | .tx_buf_size = 32, | ||
107 | .rx_num_fifo = 4, | ||
108 | .rx_buf_size = 32, | ||
109 | }, | ||
82 | }; | 110 | }; |
83 | 111 | ||
84 | void __init board_init(void) | 112 | void __init board_init(void) |
@@ -92,9 +120,12 @@ void __init board_init(void) | |||
92 | printk(KERN_CRIT "Could not remap BCSR1\n"); | 120 | printk(KERN_CRIT "Could not remap BCSR1\n"); |
93 | return; | 121 | return; |
94 | } | 122 | } |
123 | |||
95 | #ifdef CONFIG_SERIAL_CPM_SMC1 | 124 | #ifdef CONFIG_SERIAL_CPM_SMC1 |
96 | cp->cp_simode &= ~(0xe0000000 >> 17); /* brg1 */ | 125 | cp->cp_simode &= ~(0xe0000000 >> 17); /* brg1 */ |
97 | clrbits32(bcsr_io,(0x80000000 >> 7)); | 126 | clrbits32(bcsr_io,(0x80000000 >> 7)); |
127 | cp->cp_smc[0].smc_smcm |= (SMCM_RX | SMCM_TX); | ||
128 | cp->cp_smc[0].smc_smcmr &= ~(SMCMR_REN | SMCMR_TEN); | ||
98 | #else | 129 | #else |
99 | setbits32(bcsr_io,(0x80000000 >> 7)); | 130 | setbits32(bcsr_io,(0x80000000 >> 7)); |
100 | 131 | ||
@@ -108,6 +139,8 @@ void __init board_init(void) | |||
108 | cp->cp_simode &= ~(0xe0000000 >> 1); | 139 | cp->cp_simode &= ~(0xe0000000 >> 1); |
109 | cp->cp_simode |= (0x20000000 >> 1); /* brg2 */ | 140 | cp->cp_simode |= (0x20000000 >> 1); /* brg2 */ |
110 | clrbits32(bcsr_io,(0x80000000 >> 13)); | 141 | clrbits32(bcsr_io,(0x80000000 >> 13)); |
142 | cp->cp_smc[1].smc_smcm |= (SMCM_RX | SMCM_TX); | ||
143 | cp->cp_smc[1].smc_smcmr &= ~(SMCMR_REN | SMCMR_TEN); | ||
111 | #else | 144 | #else |
112 | clrbits32(bcsr_io,(0x80000000 >> 13)); | 145 | clrbits32(bcsr_io,(0x80000000 >> 13)); |
113 | cp->cp_pbpar &= ~(0x00000c00); | 146 | cp->cp_pbpar &= ~(0x00000c00); |
@@ -232,6 +265,74 @@ static void mpc866ads_fixup_scc_enet_pdata(struct platform_device *pdev, | |||
232 | mpc866ads_fixup_enet_pdata(pdev, fsid_scc1 + pdev->id - 1); | 265 | mpc866ads_fixup_enet_pdata(pdev, fsid_scc1 + pdev->id - 1); |
233 | } | 266 | } |
234 | 267 | ||
268 | static void setup_smc1_ioports(void) | ||
269 | { | ||
270 | immap_t *immap = (immap_t *) IMAP_ADDR; | ||
271 | unsigned *bcsr_io; | ||
272 | unsigned int iobits = 0x000000c0; | ||
273 | |||
274 | bcsr_io = ioremap(BCSR1, sizeof(unsigned long)); | ||
275 | |||
276 | if (bcsr_io == NULL) { | ||
277 | printk(KERN_CRIT "Could not remap BCSR1\n"); | ||
278 | return; | ||
279 | } | ||
280 | |||
281 | clrbits32(bcsr_io,BCSR1_RS232EN_1); | ||
282 | iounmap(bcsr_io); | ||
283 | |||
284 | setbits32(&immap->im_cpm.cp_pbpar, iobits); | ||
285 | clrbits32(&immap->im_cpm.cp_pbdir, iobits); | ||
286 | clrbits16(&immap->im_cpm.cp_pbodr, iobits); | ||
287 | |||
288 | } | ||
289 | |||
290 | static void setup_smc2_ioports(void) | ||
291 | { | ||
292 | immap_t *immap = (immap_t *) IMAP_ADDR; | ||
293 | unsigned *bcsr_io; | ||
294 | unsigned int iobits = 0x00000c00; | ||
295 | |||
296 | bcsr_io = ioremap(BCSR1, sizeof(unsigned long)); | ||
297 | |||
298 | if (bcsr_io == NULL) { | ||
299 | printk(KERN_CRIT "Could not remap BCSR1\n"); | ||
300 | return; | ||
301 | } | ||
302 | |||
303 | clrbits32(bcsr_io,BCSR1_RS232EN_2); | ||
304 | |||
305 | iounmap(bcsr_io); | ||
306 | |||
307 | #ifndef CONFIG_SERIAL_CPM_ALT_SMC2 | ||
308 | setbits32(&immap->im_cpm.cp_pbpar, iobits); | ||
309 | clrbits32(&immap->im_cpm.cp_pbdir, iobits); | ||
310 | clrbits16(&immap->im_cpm.cp_pbodr, iobits); | ||
311 | #else | ||
312 | setbits16(&immap->im_ioport.iop_papar, iobits); | ||
313 | clrbits16(&immap->im_ioport.iop_padir, iobits); | ||
314 | clrbits16(&immap->im_ioport.iop_paodr, iobits); | ||
315 | #endif | ||
316 | |||
317 | } | ||
318 | |||
319 | static void __init mpc866ads_fixup_uart_pdata(struct platform_device *pdev, | ||
320 | int idx) | ||
321 | { | ||
322 | bd_t *bd = (bd_t *) __res; | ||
323 | struct fs_uart_platform_info *pinfo; | ||
324 | int num = ARRAY_SIZE(mpc866_uart_pdata); | ||
325 | |||
326 | int id = fs_uart_id_smc2fsid(idx); | ||
327 | |||
328 | /* no need to alter anything if console */ | ||
329 | if ((id <= num) && (!pdev->dev.platform_data)) { | ||
330 | pinfo = &mpc866_uart_pdata[id]; | ||
331 | pinfo->uart_clk = bd->bi_intfreq; | ||
332 | pdev->dev.platform_data = pinfo; | ||
333 | } | ||
334 | } | ||
335 | |||
235 | static int mpc866ads_platform_notify(struct device *dev) | 336 | static int mpc866ads_platform_notify(struct device *dev) |
236 | { | 337 | { |
237 | static const struct platform_notify_dev_map dev_map[] = { | 338 | static const struct platform_notify_dev_map dev_map[] = { |
@@ -244,6 +345,10 @@ static int mpc866ads_platform_notify(struct device *dev) | |||
244 | .rtn = mpc866ads_fixup_scc_enet_pdata, | 345 | .rtn = mpc866ads_fixup_scc_enet_pdata, |
245 | }, | 346 | }, |
246 | { | 347 | { |
348 | .bus_id = "fsl-cpm-smc:uart", | ||
349 | .rtn = mpc866ads_fixup_uart_pdata | ||
350 | }, | ||
351 | { | ||
247 | .bus_id = NULL | 352 | .bus_id = NULL |
248 | } | 353 | } |
249 | }; | 354 | }; |
@@ -267,7 +372,42 @@ int __init mpc866ads_init(void) | |||
267 | #endif | 372 | #endif |
268 | ppc_sys_device_enable(MPC8xx_CPM_FEC1); | 373 | ppc_sys_device_enable(MPC8xx_CPM_FEC1); |
269 | 374 | ||
375 | /* Since either of the uarts could be used as console, they need to ready */ | ||
376 | #ifdef CONFIG_SERIAL_CPM_SMC1 | ||
377 | ppc_sys_device_enable(MPC8xx_CPM_SMC1); | ||
378 | ppc_sys_device_setfunc(MPC8xx_CPM_SMC1, PPC_SYS_FUNC_UART); | ||
379 | #endif | ||
380 | |||
381 | #ifdef CONFIG_SERIAL_CPM_SMCer | ||
382 | ppc_sys_device_enable(MPC8xx_CPM_SMC2); | ||
383 | ppc_sys_device_setfunc(MPC8xx_CPM_SMC2, PPC_SYS_FUNC_UART); | ||
384 | #endif | ||
385 | |||
270 | return 0; | 386 | return 0; |
271 | } | 387 | } |
272 | 388 | ||
389 | /* | ||
390 | To prevent confusion, console selection is gross: | ||
391 | by 0 assumed SMC1 and by 1 assumed SMC2 | ||
392 | */ | ||
393 | struct platform_device* early_uart_get_pdev(int index) | ||
394 | { | ||
395 | bd_t *bd = (bd_t *) __res; | ||
396 | struct fs_uart_platform_info *pinfo; | ||
397 | |||
398 | struct platform_device* pdev = NULL; | ||
399 | if(index) { /*assume SMC2 here*/ | ||
400 | pdev = &ppc_sys_platform_devices[MPC8xx_CPM_SMC2]; | ||
401 | pinfo = &mpc866_uart_pdata[1]; | ||
402 | } else { /*over SMC1*/ | ||
403 | pdev = &ppc_sys_platform_devices[MPC8xx_CPM_SMC1]; | ||
404 | pinfo = &mpc866_uart_pdata[0]; | ||
405 | } | ||
406 | |||
407 | pinfo->uart_clk = bd->bi_intfreq; | ||
408 | pdev->dev.platform_data = pinfo; | ||
409 | ppc_sys_fixup_mem_resource(pdev, IMAP_ADDR); | ||
410 | return NULL; | ||
411 | } | ||
412 | |||
273 | arch_initcall(mpc866ads_init); | 413 | arch_initcall(mpc866ads_init); |