blob: 7ed1276b29dc48aa675f46ccd0aef22958dd0b55 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/***************************************************************************/
2
3/*
4 * linux/arch/m68knommu/platform/528x/config.c
5 *
Lucas De Marchi25985ed2011-03-30 22:57:33 -03006 * Sub-architcture dependent initialization code for the Freescale
Greg Ungerer980f9232009-04-28 14:24:25 +10007 * 5280, 5281 and 5282 CPUs.
Linus Torvalds1da177e2005-04-16 15:20:36 -07008 *
9 * Copyright (C) 1999-2003, Greg Ungerer (gerg@snapgear.com)
10 * Copyright (C) 2001-2003, SnapGear Inc. (www.snapgear.com)
11 */
12
13/***************************************************************************/
14
Linus Torvalds1da177e2005-04-16 15:20:36 -070015#include <linux/kernel.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070016#include <linux/param.h>
17#include <linux/init.h>
Greg Ungerereb49e902008-02-01 17:34:50 +100018#include <linux/platform_device.h>
Greg Ungerereb49e902008-02-01 17:34:50 +100019#include <linux/io.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070020#include <asm/machdep.h>
21#include <asm/coldfire.h>
22#include <asm/mcfsim.h>
Greg Ungerereb49e902008-02-01 17:34:50 +100023#include <asm/mcfuart.h>
Greg Ungerere7749212012-04-17 14:23:41 +100024#include <asm/mcfgpio.h>
25
26/***************************************************************************/
27
28struct mcf_gpio_chip mcf_gpio_chips[] = {
29 MCFGPS(NQ, 1, 7, MCFEPORT_EPDDR, MCFEPORT_EPDR, MCFEPORT_EPPDR),
30 MCFGPS(TA, 8, 4, MCFGPTA_GPTDDR, MCFGPTA_GPTPORT, MCFGPTB_GPTPORT),
31 MCFGPS(TB, 16, 4, MCFGPTB_GPTDDR, MCFGPTB_GPTPORT, MCFGPTB_GPTPORT),
32 MCFGPS(QA, 24, 4, MCFQADC_DDRQA, MCFQADC_PORTQA, MCFQADC_PORTQA),
33 MCFGPS(QB, 32, 4, MCFQADC_DDRQB, MCFQADC_PORTQB, MCFQADC_PORTQB),
34 MCFGPF(A, 40, 8),
35 MCFGPF(B, 48, 8),
36 MCFGPF(C, 56, 8),
37 MCFGPF(D, 64, 8),
38 MCFGPF(E, 72, 8),
39 MCFGPF(F, 80, 8),
40 MCFGPF(G, 88, 8),
41 MCFGPF(H, 96, 8),
42 MCFGPF(J, 104, 8),
43 MCFGPF(DD, 112, 8),
44 MCFGPF(EH, 120, 8),
45 MCFGPF(EL, 128, 8),
46 MCFGPF(AS, 136, 6),
47 MCFGPF(QS, 144, 7),
48 MCFGPF(SD, 152, 6),
49 MCFGPF(TC, 160, 4),
50 MCFGPF(TD, 168, 4),
51 MCFGPF(UA, 176, 4),
52};
53
54unsigned int mcf_gpio_chips_size = ARRAY_SIZE(mcf_gpio_chips);
Linus Torvalds1da177e2005-04-16 15:20:36 -070055
56/***************************************************************************/
57
Steven King83ca6002012-05-06 12:22:53 -070058#if IS_ENABLED(CONFIG_SPI_COLDFIRE_QSPI)
Steven King91d60412010-01-22 12:43:03 -080059
60static void __init m528x_qspi_init(void)
61{
62 /* setup Port QS for QSPI with gpio CS control */
63 __raw_writeb(0x07, MCFGPIO_PQSPAR);
64}
Greg Ungererffba3f42009-02-26 22:40:38 -080065
Steven King83ca6002012-05-06 12:22:53 -070066#endif /* IS_ENABLED(CONFIG_SPI_COLDFIRE_QSPI) */
Greg Ungerereb49e902008-02-01 17:34:50 +100067
68/***************************************************************************/
69
Greg Ungerercae82a82011-12-24 01:00:48 +100070static void __init m528x_uarts_init(void)
Greg Ungerereb49e902008-02-01 17:34:50 +100071{
72 u8 port;
Greg Ungerereb49e902008-02-01 17:34:50 +100073
Greg Ungerereb49e902008-02-01 17:34:50 +100074 /* make sure PUAPAR is set for UART0 and UART1 */
Greg Ungerercae82a82011-12-24 01:00:48 +100075 port = readb(MCF5282_GPIO_PUAPAR);
76 port |= 0x03 | (0x03 << 2);
77 writeb(port, MCF5282_GPIO_PUAPAR);
Greg Ungerereb49e902008-02-01 17:34:50 +100078}
Linus Torvalds1da177e2005-04-16 15:20:36 -070079
80/***************************************************************************/
81
Greg Ungererffba3f42009-02-26 22:40:38 -080082static void __init m528x_fec_init(void)
83{
Greg Ungererffba3f42009-02-26 22:40:38 -080084 u16 v16;
85
Greg Ungererffba3f42009-02-26 22:40:38 -080086 /* Set multi-function pins to ethernet mode for fec0 */
87 v16 = readw(MCF_IPSBAR + 0x100056);
88 writew(v16 | 0xf00, MCF_IPSBAR + 0x100056);
89 writeb(0xc0, MCF_IPSBAR + 0x100058);
90}
91
92/***************************************************************************/
93
Steve Bennett188a9a42008-05-01 12:17:08 +100094#ifdef CONFIG_WILDFIRE
95void wildfire_halt(void)
96{
97 writeb(0, 0x30000007);
98 writeb(0x2, 0x30000007);
99}
100#endif
101
102#ifdef CONFIG_WILDFIREMOD
103void wildfiremod_halt(void)
104{
105 printk(KERN_INFO "WildFireMod hibernating...\n");
106
107 /* Set portE.5 to Digital IO */
108 MCF5282_GPIO_PEPAR &= ~(1 << (5 * 2));
109
110 /* Make portE.5 an output */
111 MCF5282_GPIO_DDRE |= (1 << 5);
112
113 /* Now toggle portE.5 from low to high */
114 MCF5282_GPIO_PORTE &= ~(1 << 5);
115 MCF5282_GPIO_PORTE |= (1 << 5);
116
117 printk(KERN_EMERG "Failed to hibernate. Halting!\n");
118}
119#endif
120
Greg Ungerereb49e902008-02-01 17:34:50 +1000121void __init config_BSP(char *commandp, int size)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700122{
Steve Bennett188a9a42008-05-01 12:17:08 +1000123#ifdef CONFIG_WILDFIRE
124 mach_halt = wildfire_halt;
125#endif
126#ifdef CONFIG_WILDFIREMOD
127 mach_halt = wildfiremod_halt;
128#endif
Greg Ungerer35aefb22012-01-23 15:34:58 +1000129 mach_sched_init = hw_timer_init;
Greg Ungerereb49e902008-02-01 17:34:50 +1000130 m528x_uarts_init();
Greg Ungererffba3f42009-02-26 22:40:38 -0800131 m528x_fec_init();
Steven King83ca6002012-05-06 12:22:53 -0700132#if IS_ENABLED(CONFIG_SPI_COLDFIRE_QSPI)
Steven King91d60412010-01-22 12:43:03 -0800133 m528x_qspi_init();
134#endif
Greg Ungerereb49e902008-02-01 17:34:50 +1000135}
136
Greg Ungerereb49e902008-02-01 17:34:50 +1000137/***************************************************************************/