diff options
author | Scott Wood <scottwood@freescale.com> | 2007-09-14 15:38:16 -0400 |
---|---|---|
committer | Kumar Gala <galak@kernel.crashing.org> | 2007-10-04 12:02:38 -0400 |
commit | 20906ecea2004c0667c8b229ac6461d16ea6bde3 (patch) | |
tree | a883f211d08cb666739e865fee173df61929ea64 /arch/powerpc/platforms/8xx | |
parent | 96fca1dea8f32e96668d55727d66416fdd67360b (diff) |
[POWERPC] 8xx: mpc885ads cleanup
It now uses the new CPM binding and the generic pin/clock functions, and
has assorted fixes and cleanup.
Signed-off-by: Scott Wood <scottwood@freescale.com>
Signed-off-by: Kumar Gala <galak@kernel.crashing.org>
Diffstat (limited to 'arch/powerpc/platforms/8xx')
-rw-r--r-- | arch/powerpc/platforms/8xx/Kconfig | 1 | ||||
-rw-r--r-- | arch/powerpc/platforms/8xx/mpc885ads.h | 38 | ||||
-rw-r--r-- | arch/powerpc/platforms/8xx/mpc885ads_setup.c | 450 |
3 files changed, 153 insertions, 336 deletions
diff --git a/arch/powerpc/platforms/8xx/Kconfig b/arch/powerpc/platforms/8xx/Kconfig index 322b155f24ec..0d4ff0ae0746 100644 --- a/arch/powerpc/platforms/8xx/Kconfig +++ b/arch/powerpc/platforms/8xx/Kconfig | |||
@@ -26,6 +26,7 @@ config MPC86XADS | |||
26 | config MPC885ADS | 26 | config MPC885ADS |
27 | bool "MPC885ADS" | 27 | bool "MPC885ADS" |
28 | select CPM1 | 28 | select CPM1 |
29 | select PPC_CPM_NEW_BINDING | ||
29 | help | 30 | help |
30 | Freescale Semiconductor MPC885 Application Development System (ADS). | 31 | Freescale Semiconductor MPC885 Application Development System (ADS). |
31 | Also known as DUET. | 32 | Also known as DUET. |
diff --git a/arch/powerpc/platforms/8xx/mpc885ads.h b/arch/powerpc/platforms/8xx/mpc885ads.h index a21e528f26c6..a5076668bad6 100644 --- a/arch/powerpc/platforms/8xx/mpc885ads.h +++ b/arch/powerpc/platforms/8xx/mpc885ads.h | |||
@@ -17,25 +17,10 @@ | |||
17 | 17 | ||
18 | #include <sysdev/fsl_soc.h> | 18 | #include <sysdev/fsl_soc.h> |
19 | 19 | ||
20 | /* U-Boot maps BCSR to 0xff080000 */ | ||
21 | #define BCSR_ADDR ((uint)0xff080000) | ||
22 | #define BCSR_SIZE ((uint)32) | ||
23 | #define BCSR0 ((uint)(BCSR_ADDR + 0x00)) | ||
24 | #define BCSR1 ((uint)(BCSR_ADDR + 0x04)) | ||
25 | #define BCSR2 ((uint)(BCSR_ADDR + 0x08)) | ||
26 | #define BCSR3 ((uint)(BCSR_ADDR + 0x0c)) | ||
27 | #define BCSR4 ((uint)(BCSR_ADDR + 0x10)) | ||
28 | |||
29 | #define CFG_PHYDEV_ADDR ((uint)0xff0a0000) | ||
30 | #define BCSR5 ((uint)(CFG_PHYDEV_ADDR + 0x300)) | ||
31 | |||
32 | #define MPC8xx_CPM_OFFSET (0x9c0) | 20 | #define MPC8xx_CPM_OFFSET (0x9c0) |
33 | #define CPM_MAP_ADDR (get_immrbase() + MPC8xx_CPM_OFFSET) | 21 | #define CPM_MAP_ADDR (get_immrbase() + MPC8xx_CPM_OFFSET) |
34 | #define CPM_IRQ_OFFSET 16 // for compability with cpm_uart driver | 22 | #define CPM_IRQ_OFFSET 16 // for compability with cpm_uart driver |
35 | 23 | ||
36 | #define PCMCIA_MEM_ADDR ((uint)0xff020000) | ||
37 | #define PCMCIA_MEM_SIZE ((uint)(64 * 1024)) | ||
38 | |||
39 | /* Bits of interest in the BCSRs. | 24 | /* Bits of interest in the BCSRs. |
40 | */ | 25 | */ |
41 | #define BCSR1_ETHEN ((uint)0x20000000) | 26 | #define BCSR1_ETHEN ((uint)0x20000000) |
@@ -64,28 +49,5 @@ | |||
64 | #define BCSR5_MII1_EN 0x02 | 49 | #define BCSR5_MII1_EN 0x02 |
65 | #define BCSR5_MII1_RST 0x01 | 50 | #define BCSR5_MII1_RST 0x01 |
66 | 51 | ||
67 | /* Interrupt level assignments */ | ||
68 | #define PHY_INTERRUPT SIU_IRQ7 /* PHY link change interrupt */ | ||
69 | #define SIU_INT_FEC1 SIU_LEVEL1 /* FEC1 interrupt */ | ||
70 | #define SIU_INT_FEC2 SIU_LEVEL3 /* FEC2 interrupt */ | ||
71 | #define FEC_INTERRUPT SIU_INT_FEC1 /* FEC interrupt */ | ||
72 | |||
73 | /* We don't use the 8259 */ | ||
74 | #define NR_8259_INTS 0 | ||
75 | |||
76 | /* CPM Ethernet through SCC3 */ | ||
77 | #define PA_ENET_RXD ((ushort)0x0040) | ||
78 | #define PA_ENET_TXD ((ushort)0x0080) | ||
79 | #define PE_ENET_TCLK ((uint)0x00004000) | ||
80 | #define PE_ENET_RCLK ((uint)0x00008000) | ||
81 | #define PE_ENET_TENA ((uint)0x00000010) | ||
82 | #define PC_ENET_CLSN ((ushort)0x0400) | ||
83 | #define PC_ENET_RENA ((ushort)0x0800) | ||
84 | |||
85 | /* Control bits in the SICR to route TCLK (CLK5) and RCLK (CLK6) to | ||
86 | * SCC3. Also, make sure GR3 (bit 8) and SC3 (bit 9) are zero */ | ||
87 | #define SICR_ENET_MASK ((uint)0x00ff0000) | ||
88 | #define SICR_ENET_CLKRT ((uint)0x002c0000) | ||
89 | |||
90 | #endif /* __ASM_MPC885ADS_H__ */ | 52 | #endif /* __ASM_MPC885ADS_H__ */ |
91 | #endif /* __KERNEL__ */ | 53 | #endif /* __KERNEL__ */ |
diff --git a/arch/powerpc/platforms/8xx/mpc885ads_setup.c b/arch/powerpc/platforms/8xx/mpc885ads_setup.c index bad08683f7ae..2cf1b6a75173 100644 --- a/arch/powerpc/platforms/8xx/mpc885ads_setup.c +++ b/arch/powerpc/platforms/8xx/mpc885ads_setup.c | |||
@@ -1,11 +1,13 @@ | |||
1 | /*arch/powerpc/platforms/8xx/mpc885ads_setup.c | 1 | /* |
2 | * | ||
3 | * Platform setup for the Freescale mpc885ads board | 2 | * Platform setup for the Freescale mpc885ads board |
4 | * | 3 | * |
5 | * Vitaly Bordug <vbordug@ru.mvista.com> | 4 | * Vitaly Bordug <vbordug@ru.mvista.com> |
6 | * | 5 | * |
7 | * Copyright 2005 MontaVista Software Inc. | 6 | * Copyright 2005 MontaVista Software Inc. |
8 | * | 7 | * |
8 | * Heavily modified by Scott Wood <scottwood@freescale.com> | ||
9 | * Copyright 2007 Freescale Semiconductor, Inc. | ||
10 | * | ||
9 | * This file is licensed under the terms of the GNU General Public License | 11 | * 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 | 12 | * version 2. This program is licensed "as is" without any warranty of any |
11 | * kind, whether express or implied. | 13 | * kind, whether express or implied. |
@@ -18,12 +20,12 @@ | |||
18 | #include <linux/ioport.h> | 20 | #include <linux/ioport.h> |
19 | #include <linux/device.h> | 21 | #include <linux/device.h> |
20 | #include <linux/delay.h> | 22 | #include <linux/delay.h> |
21 | #include <linux/root_dev.h> | ||
22 | 23 | ||
23 | #include <linux/fs_enet_pd.h> | 24 | #include <linux/fs_enet_pd.h> |
24 | #include <linux/fs_uart_pd.h> | 25 | #include <linux/fs_uart_pd.h> |
25 | #include <linux/fsl_devices.h> | 26 | #include <linux/fsl_devices.h> |
26 | #include <linux/mii.h> | 27 | #include <linux/mii.h> |
28 | #include <linux/of_platform.h> | ||
27 | 29 | ||
28 | #include <asm/delay.h> | 30 | #include <asm/delay.h> |
29 | #include <asm/io.h> | 31 | #include <asm/io.h> |
@@ -36,34 +38,24 @@ | |||
36 | #include <asm/8xx_immap.h> | 38 | #include <asm/8xx_immap.h> |
37 | #include <asm/commproc.h> | 39 | #include <asm/commproc.h> |
38 | #include <asm/fs_pd.h> | 40 | #include <asm/fs_pd.h> |
39 | #include <asm/prom.h> | 41 | #include <asm/udbg.h> |
40 | 42 | ||
41 | #include <sysdev/commproc.h> | 43 | #include <sysdev/commproc.h> |
42 | 44 | ||
43 | static void init_smc1_uart_ioports(struct fs_uart_platform_info *fpi); | 45 | static u32 __iomem *bcsr, *bcsr5; |
44 | static void init_smc2_uart_ioports(struct fs_uart_platform_info *fpi); | ||
45 | static void init_scc3_ioports(struct fs_platform_info *ptr); | ||
46 | 46 | ||
47 | #ifdef CONFIG_PCMCIA_M8XX | 47 | #ifdef CONFIG_PCMCIA_M8XX |
48 | static void pcmcia_hw_setup(int slot, int enable) | 48 | static void pcmcia_hw_setup(int slot, int enable) |
49 | { | 49 | { |
50 | unsigned *bcsr_io; | ||
51 | |||
52 | bcsr_io = ioremap(BCSR1, sizeof(unsigned long)); | ||
53 | if (enable) | 50 | if (enable) |
54 | clrbits32(bcsr_io, BCSR1_PCCEN); | 51 | clrbits32(&bcsr[1], BCSR1_PCCEN); |
55 | else | 52 | else |
56 | setbits32(bcsr_io, BCSR1_PCCEN); | 53 | setbits32(&bcsr[1], BCSR1_PCCEN); |
57 | |||
58 | iounmap(bcsr_io); | ||
59 | } | 54 | } |
60 | 55 | ||
61 | static int pcmcia_set_voltage(int slot, int vcc, int vpp) | 56 | static int pcmcia_set_voltage(int slot, int vcc, int vpp) |
62 | { | 57 | { |
63 | u32 reg = 0; | 58 | u32 reg = 0; |
64 | unsigned *bcsr_io; | ||
65 | |||
66 | bcsr_io = ioremap(BCSR1, sizeof(unsigned long)); | ||
67 | 59 | ||
68 | switch (vcc) { | 60 | switch (vcc) { |
69 | case 0: | 61 | case 0: |
@@ -98,334 +90,196 @@ static int pcmcia_set_voltage(int slot, int vcc, int vpp) | |||
98 | } | 90 | } |
99 | 91 | ||
100 | /* first, turn off all power */ | 92 | /* first, turn off all power */ |
101 | clrbits32(bcsr_io, 0x00610000); | 93 | clrbits32(&bcsr[1], 0x00610000); |
102 | 94 | ||
103 | /* enable new powersettings */ | 95 | /* enable new powersettings */ |
104 | setbits32(bcsr_io, reg); | 96 | setbits32(&bcsr[1], reg); |
105 | 97 | ||
106 | iounmap(bcsr_io); | ||
107 | return 0; | 98 | return 0; |
108 | } | 99 | } |
109 | #endif | 100 | #endif |
110 | 101 | ||
111 | void __init mpc885ads_board_setup(void) | 102 | struct cpm_pin { |
112 | { | 103 | int port, pin, flags; |
113 | cpm8xx_t *cp; | 104 | }; |
114 | unsigned int *bcsr_io; | ||
115 | u8 tmpval8; | ||
116 | |||
117 | #ifdef CONFIG_FS_ENET | ||
118 | iop8xx_t *io_port; | ||
119 | #endif | ||
120 | |||
121 | bcsr_io = ioremap(BCSR1, sizeof(unsigned long)); | ||
122 | cp = (cpm8xx_t *) immr_map(im_cpm); | ||
123 | |||
124 | if (bcsr_io == NULL) { | ||
125 | printk(KERN_CRIT "Could not remap BCSR\n"); | ||
126 | return; | ||
127 | } | ||
128 | #ifdef CONFIG_SERIAL_CPM_SMC1 | ||
129 | clrbits32(bcsr_io, BCSR1_RS232EN_1); | ||
130 | clrbits32(&cp->cp_simode, 0xe0000000 >> 17); /* brg1 */ | ||
131 | tmpval8 = in_8(&(cp->cp_smc[0].smc_smcm)) | (SMCM_RX | SMCM_TX); | ||
132 | out_8(&(cp->cp_smc[0].smc_smcm), tmpval8); | ||
133 | clrbits16(&cp->cp_smc[0].smc_smcmr, SMCMR_REN | SMCMR_TEN); /* brg1 */ | ||
134 | #else | ||
135 | setbits32(bcsr_io, BCSR1_RS232EN_1); | ||
136 | out_be16(&cp->cp_smc[0].smc_smcmr, 0); | ||
137 | out_8(&cp->cp_smc[0].smc_smce, 0); | ||
138 | #endif | ||
139 | |||
140 | #ifdef CONFIG_SERIAL_CPM_SMC2 | ||
141 | clrbits32(bcsr_io, BCSR1_RS232EN_2); | ||
142 | clrbits32(&cp->cp_simode, 0xe0000000 >> 1); | ||
143 | setbits32(&cp->cp_simode, 0x20000000 >> 1); /* brg2 */ | ||
144 | tmpval8 = in_8(&(cp->cp_smc[1].smc_smcm)) | (SMCM_RX | SMCM_TX); | ||
145 | out_8(&(cp->cp_smc[1].smc_smcm), tmpval8); | ||
146 | clrbits16(&cp->cp_smc[1].smc_smcmr, SMCMR_REN | SMCMR_TEN); | ||
147 | |||
148 | init_smc2_uart_ioports(0); | ||
149 | #else | ||
150 | setbits32(bcsr_io, BCSR1_RS232EN_2); | ||
151 | out_be16(&cp->cp_smc[1].smc_smcmr, 0); | ||
152 | out_8(&cp->cp_smc[1].smc_smce, 0); | ||
153 | #endif | ||
154 | immr_unmap(cp); | ||
155 | iounmap(bcsr_io); | ||
156 | |||
157 | #ifdef CONFIG_FS_ENET | ||
158 | /* use MDC for MII (common) */ | ||
159 | io_port = (iop8xx_t *) immr_map(im_ioport); | ||
160 | setbits16(&io_port->iop_pdpar, 0x0080); | ||
161 | clrbits16(&io_port->iop_pddir, 0x0080); | ||
162 | |||
163 | bcsr_io = ioremap(BCSR5, sizeof(unsigned long)); | ||
164 | clrbits32(bcsr_io, BCSR5_MII1_EN); | ||
165 | clrbits32(bcsr_io, BCSR5_MII1_RST); | ||
166 | #ifndef CONFIG_FC_ENET_HAS_SCC | ||
167 | clrbits32(bcsr_io, BCSR5_MII2_EN); | ||
168 | clrbits32(bcsr_io, BCSR5_MII2_RST); | ||
169 | 105 | ||
170 | #endif | 106 | static struct cpm_pin mpc885ads_pins[] = { |
171 | iounmap(bcsr_io); | 107 | /* SMC1 */ |
172 | immr_unmap(io_port); | 108 | {CPM_PORTB, 24, CPM_PIN_INPUT}, /* RX */ |
109 | {CPM_PORTB, 25, CPM_PIN_INPUT | CPM_PIN_SECONDARY}, /* TX */ | ||
173 | 110 | ||
111 | /* SMC2 */ | ||
112 | #ifndef CONFIG_MPC8xx_SECOND_ETH_FEC2 | ||
113 | {CPM_PORTE, 21, CPM_PIN_INPUT}, /* RX */ | ||
114 | {CPM_PORTE, 20, CPM_PIN_INPUT | CPM_PIN_SECONDARY}, /* TX */ | ||
174 | #endif | 115 | #endif |
175 | 116 | ||
176 | #ifdef CONFIG_PCMCIA_M8XX | 117 | /* SCC3 */ |
177 | /*Set up board specific hook-ups */ | 118 | {CPM_PORTA, 9, CPM_PIN_INPUT}, /* RX */ |
178 | m8xx_pcmcia_ops.hw_ctrl = pcmcia_hw_setup; | 119 | {CPM_PORTA, 8, CPM_PIN_INPUT}, /* TX */ |
179 | m8xx_pcmcia_ops.voltage_set = pcmcia_set_voltage; | 120 | {CPM_PORTC, 4, CPM_PIN_INPUT | CPM_PIN_SECONDARY | CPM_PIN_GPIO}, /* RENA */ |
121 | {CPM_PORTC, 5, CPM_PIN_INPUT | CPM_PIN_SECONDARY | CPM_PIN_GPIO}, /* CLSN */ | ||
122 | {CPM_PORTE, 27, CPM_PIN_INPUT | CPM_PIN_SECONDARY}, /* TENA */ | ||
123 | {CPM_PORTE, 17, CPM_PIN_INPUT}, /* CLK5 */ | ||
124 | {CPM_PORTE, 16, CPM_PIN_INPUT}, /* CLK6 */ | ||
125 | |||
126 | /* MII1 */ | ||
127 | {CPM_PORTA, 0, CPM_PIN_INPUT}, | ||
128 | {CPM_PORTA, 1, CPM_PIN_INPUT}, | ||
129 | {CPM_PORTA, 2, CPM_PIN_INPUT}, | ||
130 | {CPM_PORTA, 3, CPM_PIN_INPUT}, | ||
131 | {CPM_PORTA, 4, CPM_PIN_OUTPUT}, | ||
132 | {CPM_PORTA, 10, CPM_PIN_OUTPUT}, | ||
133 | {CPM_PORTA, 11, CPM_PIN_OUTPUT}, | ||
134 | {CPM_PORTB, 19, CPM_PIN_INPUT}, | ||
135 | {CPM_PORTB, 31, CPM_PIN_INPUT}, | ||
136 | {CPM_PORTC, 12, CPM_PIN_INPUT}, | ||
137 | {CPM_PORTC, 13, CPM_PIN_INPUT}, | ||
138 | {CPM_PORTE, 30, CPM_PIN_OUTPUT}, | ||
139 | {CPM_PORTE, 31, CPM_PIN_OUTPUT}, | ||
140 | |||
141 | /* MII2 */ | ||
142 | #ifdef CONFIG_MPC8xx_SECOND_ETH_FEC2 | ||
143 | {CPM_PORTE, 14, CPM_PIN_OUTPUT | CPM_PIN_SECONDARY}, | ||
144 | {CPM_PORTE, 15, CPM_PIN_OUTPUT | CPM_PIN_SECONDARY}, | ||
145 | {CPM_PORTE, 16, CPM_PIN_OUTPUT}, | ||
146 | {CPM_PORTE, 17, CPM_PIN_OUTPUT | CPM_PIN_SECONDARY}, | ||
147 | {CPM_PORTE, 18, CPM_PIN_OUTPUT | CPM_PIN_SECONDARY}, | ||
148 | {CPM_PORTE, 19, CPM_PIN_OUTPUT | CPM_PIN_SECONDARY}, | ||
149 | {CPM_PORTE, 20, CPM_PIN_OUTPUT | CPM_PIN_SECONDARY}, | ||
150 | {CPM_PORTE, 21, CPM_PIN_OUTPUT}, | ||
151 | {CPM_PORTE, 22, CPM_PIN_OUTPUT}, | ||
152 | {CPM_PORTE, 23, CPM_PIN_OUTPUT}, | ||
153 | {CPM_PORTE, 24, CPM_PIN_OUTPUT}, | ||
154 | {CPM_PORTE, 25, CPM_PIN_OUTPUT}, | ||
155 | {CPM_PORTE, 26, CPM_PIN_OUTPUT}, | ||
156 | {CPM_PORTE, 27, CPM_PIN_OUTPUT}, | ||
157 | {CPM_PORTE, 28, CPM_PIN_OUTPUT}, | ||
158 | {CPM_PORTE, 29, CPM_PIN_OUTPUT}, | ||
180 | #endif | 159 | #endif |
181 | } | 160 | }; |
182 | 161 | ||
183 | static void init_fec1_ioports(struct fs_platform_info *ptr) | 162 | static void __init init_ioports(void) |
184 | { | 163 | { |
185 | cpm8xx_t *cp = (cpm8xx_t *) immr_map(im_cpm); | 164 | int i; |
186 | iop8xx_t *io_port = (iop8xx_t *) immr_map(im_ioport); | ||
187 | |||
188 | /* configure FEC1 pins */ | ||
189 | setbits16(&io_port->iop_papar, 0xf830); | ||
190 | setbits16(&io_port->iop_padir, 0x0830); | ||
191 | clrbits16(&io_port->iop_padir, 0xf000); | ||
192 | |||
193 | setbits32(&cp->cp_pbpar, 0x00001001); | ||
194 | clrbits32(&cp->cp_pbdir, 0x00001001); | ||
195 | 165 | ||
196 | setbits16(&io_port->iop_pcpar, 0x000c); | 166 | for (i = 0; i < ARRAY_SIZE(mpc885ads_pins); i++) { |
197 | clrbits16(&io_port->iop_pcdir, 0x000c); | 167 | struct cpm_pin *pin = &mpc885ads_pins[i]; |
168 | cpm1_set_pin(pin->port, pin->pin, pin->flags); | ||
169 | } | ||
198 | 170 | ||
199 | setbits32(&cp->cp_pepar, 0x00000003); | 171 | cpm1_clk_setup(CPM_CLK_SMC1, CPM_BRG1, CPM_CLK_RTX); |
200 | setbits32(&cp->cp_pedir, 0x00000003); | 172 | cpm1_clk_setup(CPM_CLK_SMC2, CPM_BRG2, CPM_CLK_RTX); |
201 | clrbits32(&cp->cp_peso, 0x00000003); | 173 | cpm1_clk_setup(CPM_CLK_SCC3, CPM_CLK5, CPM_CLK_TX); |
202 | clrbits32(&cp->cp_cptr, 0x00000100); | 174 | cpm1_clk_setup(CPM_CLK_SCC3, CPM_CLK6, CPM_CLK_RX); |
203 | 175 | ||
204 | immr_unmap(io_port); | 176 | /* Set FEC1 and FEC2 to MII mode */ |
205 | immr_unmap(cp); | 177 | clrbits32(&mpc8xx_immr->im_cpm.cp_cptr, 0x00000180); |
206 | } | 178 | } |
207 | 179 | ||
208 | static void init_fec2_ioports(struct fs_platform_info *ptr) | 180 | static void __init mpc885ads_setup_arch(void) |
209 | { | 181 | { |
210 | cpm8xx_t *cp = (cpm8xx_t *) immr_map(im_cpm); | 182 | struct device_node *np; |
211 | iop8xx_t *io_port = (iop8xx_t *) immr_map(im_ioport); | ||
212 | |||
213 | /* configure FEC2 pins */ | ||
214 | setbits32(&cp->cp_pepar, 0x0003fffc); | ||
215 | setbits32(&cp->cp_pedir, 0x0003fffc); | ||
216 | clrbits32(&cp->cp_peso, 0x000087fc); | ||
217 | setbits32(&cp->cp_peso, 0x00037800); | ||
218 | clrbits32(&cp->cp_cptr, 0x00000080); | ||
219 | |||
220 | immr_unmap(io_port); | ||
221 | immr_unmap(cp); | ||
222 | } | ||
223 | 183 | ||
224 | void init_fec_ioports(struct fs_platform_info *fpi) | 184 | cpm_reset(); |
225 | { | 185 | init_ioports(); |
226 | int fec_no = fs_get_fec_index(fpi->fs_no); | ||
227 | 186 | ||
228 | switch (fec_no) { | 187 | np = of_find_compatible_node(NULL, NULL, "fsl,mpc885ads-bcsr"); |
229 | case 0: | 188 | if (!np) { |
230 | init_fec1_ioports(fpi); | 189 | printk(KERN_CRIT "Could not find fsl,mpc885ads-bcsr node\n"); |
231 | break; | ||
232 | case 1: | ||
233 | init_fec2_ioports(fpi); | ||
234 | break; | ||
235 | default: | ||
236 | printk(KERN_ERR "init_fec_ioports: invalid FEC number\n"); | ||
237 | return; | 190 | return; |
238 | } | 191 | } |
239 | } | ||
240 | 192 | ||
241 | static void init_scc3_ioports(struct fs_platform_info *fpi) | 193 | bcsr = of_iomap(np, 0); |
242 | { | 194 | bcsr5 = of_iomap(np, 1); |
243 | unsigned *bcsr_io; | 195 | of_node_put(np); |
244 | iop8xx_t *io_port; | ||
245 | cpm8xx_t *cp; | ||
246 | 196 | ||
247 | bcsr_io = ioremap(BCSR_ADDR, BCSR_SIZE); | 197 | if (!bcsr || !bcsr5) { |
248 | io_port = (iop8xx_t *) immr_map(im_ioport); | ||
249 | cp = (cpm8xx_t *) immr_map(im_cpm); | ||
250 | |||
251 | if (bcsr_io == NULL) { | ||
252 | printk(KERN_CRIT "Could not remap BCSR\n"); | 198 | printk(KERN_CRIT "Could not remap BCSR\n"); |
253 | return; | 199 | return; |
254 | } | 200 | } |
255 | 201 | ||
256 | /* Enable the PHY. | 202 | clrbits32(&bcsr[1], BCSR1_RS232EN_1); |
257 | */ | 203 | #ifdef CONFIG_MPC8xx_SECOND_ETH_FEC2 |
258 | clrbits32(bcsr_io + 4, BCSR4_ETH10_RST); | 204 | setbits32(&bcsr[1], BCSR1_RS232EN_2); |
259 | udelay(1000); | 205 | #else |
260 | setbits32(bcsr_io + 4, BCSR4_ETH10_RST); | 206 | clrbits32(&bcsr[1], BCSR1_RS232EN_2); |
261 | /* Configure port A pins for Txd and Rxd. | 207 | #endif |
262 | */ | ||
263 | setbits16(&io_port->iop_papar, PA_ENET_RXD | PA_ENET_TXD); | ||
264 | clrbits16(&io_port->iop_padir, PA_ENET_RXD | PA_ENET_TXD); | ||
265 | 208 | ||
266 | /* Configure port C pins to enable CLSN and RENA. | 209 | clrbits32(bcsr5, BCSR5_MII1_EN); |
267 | */ | 210 | setbits32(bcsr5, BCSR5_MII1_RST); |
268 | clrbits16(&io_port->iop_pcpar, PC_ENET_CLSN | PC_ENET_RENA); | 211 | udelay(1000); |
269 | clrbits16(&io_port->iop_pcdir, PC_ENET_CLSN | PC_ENET_RENA); | 212 | clrbits32(bcsr5, BCSR5_MII1_RST); |
270 | setbits16(&io_port->iop_pcso, PC_ENET_CLSN | PC_ENET_RENA); | ||
271 | 213 | ||
272 | /* Configure port E for TCLK and RCLK. | 214 | #ifdef CONFIG_MPC8xx_SECOND_ETH_FEC2 |
273 | */ | 215 | clrbits32(bcsr5, BCSR5_MII2_EN); |
274 | setbits32(&cp->cp_pepar, PE_ENET_TCLK | PE_ENET_RCLK); | 216 | setbits32(bcsr5, BCSR5_MII2_RST); |
275 | clrbits32(&cp->cp_pepar, PE_ENET_TENA); | 217 | udelay(1000); |
276 | clrbits32(&cp->cp_pedir, PE_ENET_TCLK | PE_ENET_RCLK | PE_ENET_TENA); | 218 | clrbits32(bcsr5, BCSR5_MII2_RST); |
277 | clrbits32(&cp->cp_peso, PE_ENET_TCLK | PE_ENET_RCLK); | 219 | #else |
278 | setbits32(&cp->cp_peso, PE_ENET_TENA); | 220 | setbits32(bcsr5, BCSR5_MII2_EN); |
279 | 221 | #endif | |
280 | /* Configure Serial Interface clock routing. | ||
281 | * First, clear all SCC bits to zero, then set the ones we want. | ||
282 | */ | ||
283 | clrbits32(&cp->cp_sicr, SICR_ENET_MASK); | ||
284 | setbits32(&cp->cp_sicr, SICR_ENET_CLKRT); | ||
285 | 222 | ||
286 | /* Disable Rx and Tx. SMC1 sshould be stopped if SCC3 eternet are used. | 223 | #ifdef CONFIG_MPC8xx_SECOND_ETH_SCC3 |
287 | */ | 224 | clrbits32(&bcsr[4], BCSR4_ETH10_RST); |
288 | clrbits16(&cp->cp_smc[0].smc_smcmr, SMCMR_REN | SMCMR_TEN); | 225 | udelay(1000); |
289 | /* On the MPC885ADS SCC ethernet PHY is initialized in the full duplex mode | 226 | setbits32(&bcsr[4], BCSR4_ETH10_RST); |
290 | * by H/W setting after reset. SCC ethernet controller support only half duplex. | ||
291 | * This discrepancy of modes causes a lot of carrier lost errors. | ||
292 | */ | ||
293 | 227 | ||
294 | /* In the original SCC enet driver the following code is placed at | 228 | setbits32(&bcsr[1], BCSR1_ETHEN); |
295 | the end of the initialization */ | ||
296 | setbits32(&cp->cp_pepar, PE_ENET_TENA); | ||
297 | clrbits32(&cp->cp_pedir, PE_ENET_TENA); | ||
298 | setbits32(&cp->cp_peso, PE_ENET_TENA); | ||
299 | 229 | ||
300 | setbits32(bcsr_io + 4, BCSR1_ETHEN); | 230 | np = of_find_node_by_path("/soc@ff000000/cpm@9c0/serial@a80"); |
301 | iounmap(bcsr_io); | 231 | #else |
302 | immr_unmap(io_port); | 232 | np = of_find_node_by_path("/soc@ff000000/cpm@9c0/ethernet@a40"); |
303 | immr_unmap(cp); | 233 | #endif |
304 | } | ||
305 | 234 | ||
306 | void init_scc_ioports(struct fs_platform_info *fpi) | 235 | /* The SCC3 enet registers overlap the SMC1 registers, so |
307 | { | 236 | * one of the two must be removed from the device tree. |
308 | int scc_no = fs_get_scc_index(fpi->fs_no); | 237 | */ |
309 | 238 | ||
310 | switch (scc_no) { | 239 | if (np) { |
311 | case 2: | 240 | of_detach_node(np); |
312 | init_scc3_ioports(fpi); | 241 | of_node_put(np); |
313 | break; | ||
314 | default: | ||
315 | printk(KERN_ERR "init_scc_ioports: invalid SCC number\n"); | ||
316 | return; | ||
317 | } | 242 | } |
318 | } | ||
319 | |||
320 | static void init_smc1_uart_ioports(struct fs_uart_platform_info *ptr) | ||
321 | { | ||
322 | unsigned *bcsr_io; | ||
323 | cpm8xx_t *cp; | ||
324 | |||
325 | cp = (cpm8xx_t *) immr_map(im_cpm); | ||
326 | setbits32(&cp->cp_pepar, 0x000000c0); | ||
327 | clrbits32(&cp->cp_pedir, 0x000000c0); | ||
328 | clrbits32(&cp->cp_peso, 0x00000040); | ||
329 | setbits32(&cp->cp_peso, 0x00000080); | ||
330 | immr_unmap(cp); | ||
331 | |||
332 | bcsr_io = ioremap(BCSR1, sizeof(unsigned long)); | ||
333 | 243 | ||
334 | if (bcsr_io == NULL) { | 244 | #ifdef CONFIG_PCMCIA_M8XX |
335 | printk(KERN_CRIT "Could not remap BCSR1\n"); | 245 | /* Set up board specific hook-ups.*/ |
336 | return; | 246 | m8xx_pcmcia_ops.hw_ctrl = pcmcia_hw_setup; |
337 | } | 247 | m8xx_pcmcia_ops.voltage_set = pcmcia_set_voltage; |
338 | clrbits32(bcsr_io, BCSR1_RS232EN_1); | 248 | #endif |
339 | iounmap(bcsr_io); | ||
340 | } | 249 | } |
341 | 250 | ||
342 | static void init_smc2_uart_ioports(struct fs_uart_platform_info *fpi) | 251 | static int __init mpc885ads_probe(void) |
343 | { | 252 | { |
344 | unsigned *bcsr_io; | 253 | unsigned long root = of_get_flat_dt_root(); |
345 | cpm8xx_t *cp; | 254 | return of_flat_dt_is_compatible(root, "fsl,mpc885ads"); |
346 | |||
347 | cp = (cpm8xx_t *) immr_map(im_cpm); | ||
348 | setbits32(&cp->cp_pepar, 0x00000c00); | ||
349 | clrbits32(&cp->cp_pedir, 0x00000c00); | ||
350 | clrbits32(&cp->cp_peso, 0x00000400); | ||
351 | setbits32(&cp->cp_peso, 0x00000800); | ||
352 | immr_unmap(cp); | ||
353 | |||
354 | bcsr_io = ioremap(BCSR1, sizeof(unsigned long)); | ||
355 | |||
356 | if (bcsr_io == NULL) { | ||
357 | printk(KERN_CRIT "Could not remap BCSR1\n"); | ||
358 | return; | ||
359 | } | ||
360 | clrbits32(bcsr_io, BCSR1_RS232EN_2); | ||
361 | iounmap(bcsr_io); | ||
362 | } | 255 | } |
363 | 256 | ||
364 | void init_smc_ioports(struct fs_uart_platform_info *data) | 257 | static struct of_device_id __initdata of_bus_ids[] = { |
365 | { | 258 | { .name = "soc", }, |
366 | int smc_no = fs_uart_id_fsid2smc(data->fs_no); | 259 | { .name = "cpm", }, |
367 | 260 | { .name = "localbus", }, | |
368 | switch (smc_no) { | 261 | {}, |
369 | case 0: | 262 | }; |
370 | init_smc1_uart_ioports(data); | ||
371 | data->brg = data->clk_rx; | ||
372 | break; | ||
373 | case 1: | ||
374 | init_smc2_uart_ioports(data); | ||
375 | data->brg = data->clk_rx; | ||
376 | break; | ||
377 | default: | ||
378 | printk(KERN_ERR "init_scc_ioports: invalid SCC number\n"); | ||
379 | return; | ||
380 | } | ||
381 | } | ||
382 | 263 | ||
383 | int platform_device_skip(const char *model, int id) | 264 | static int __init declare_of_platform_devices(void) |
384 | { | 265 | { |
385 | #ifdef CONFIG_MPC8xx_SECOND_ETH_SCC3 | 266 | /* Publish the QE devices */ |
386 | const char *dev = "FEC"; | 267 | if (machine_is(mpc885_ads)) |
387 | int n = 2; | 268 | of_platform_bus_probe(NULL, of_bus_ids, NULL); |
388 | #else | ||
389 | const char *dev = "SCC"; | ||
390 | int n = 3; | ||
391 | #endif | ||
392 | |||
393 | if (!strcmp(model, dev) && n == id) | ||
394 | return 1; | ||
395 | 269 | ||
396 | return 0; | 270 | return 0; |
397 | } | 271 | } |
398 | 272 | device_initcall(declare_of_platform_devices); | |
399 | static void __init mpc885ads_setup_arch(void) | 273 | |
400 | { | 274 | define_machine(mpc885_ads) { |
401 | cpm_reset(); | 275 | .name = "Freescale MPC885 ADS", |
402 | 276 | .probe = mpc885ads_probe, | |
403 | mpc885ads_board_setup(); | 277 | .setup_arch = mpc885ads_setup_arch, |
404 | 278 | .init_IRQ = m8xx_pic_init, | |
405 | ROOT_DEV = Root_NFS; | 279 | .get_irq = mpc8xx_get_irq, |
406 | } | 280 | .restart = mpc8xx_restart, |
407 | 281 | .calibrate_decr = mpc8xx_calibrate_decr, | |
408 | static int __init mpc885ads_probe(void) | 282 | .set_rtc_time = mpc8xx_set_rtc_time, |
409 | { | 283 | .get_rtc_time = mpc8xx_get_rtc_time, |
410 | char *model = of_get_flat_dt_prop(of_get_flat_dt_root(), | 284 | .progress = udbg_progress, |
411 | "model", NULL); | ||
412 | if (model == NULL) | ||
413 | return 0; | ||
414 | if (strcmp(model, "MPC885ADS")) | ||
415 | return 0; | ||
416 | |||
417 | return 1; | ||
418 | } | ||
419 | |||
420 | define_machine(mpc885_ads) | ||
421 | { | ||
422 | .name = "MPC885 ADS", | ||
423 | .probe = mpc885ads_probe, | ||
424 | .setup_arch = mpc885ads_setup_arch, | ||
425 | .init_IRQ = m8xx_pic_init, | ||
426 | .get_irq = mpc8xx_get_irq, | ||
427 | .restart = mpc8xx_restart, | ||
428 | .calibrate_decr = mpc8xx_calibrate_decr, | ||
429 | .set_rtc_time = mpc8xx_set_rtc_time, | ||
430 | .get_rtc_time = mpc8xx_get_rtc_time, | ||
431 | }; | 285 | }; |