1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * Copyright 2006 Freescale Semiconductor, Inc. All rights reserved.
5 * Author: Li Yang <LeoLi@freescale.com>
6 * Yin Olivia <Hong-hua.Yin@freescale.com>
9 * MPC8360E MDS board specific routines.
12 * Jun 21, 2006 Initial version
15 #include <linux/stddef.h>
16 #include <linux/kernel.h>
17 #include <linux/compiler.h>
18 #include <linux/init.h>
19 #include <linux/errno.h>
20 #include <linux/reboot.h>
21 #include <linux/pci.h>
22 #include <linux/kdev_t.h>
23 #include <linux/major.h>
24 #include <linux/console.h>
25 #include <linux/delay.h>
26 #include <linux/seq_file.h>
27 #include <linux/root_dev.h>
28 #include <linux/initrd.h>
29 #include <linux/of_platform.h>
30 #include <linux/of_device.h>
32 #include <linux/atomic.h>
35 #include <asm/machdep.h>
40 #include <sysdev/fsl_soc.h>
41 #include <sysdev/fsl_pci.h>
42 #include <sysdev/simple_gpio.h>
43 #include <soc/fsl/qe/qe.h>
44 #include <soc/fsl/qe/qe_ic.h>
50 #define DBG(fmt...) udbg_printf(fmt)
55 /* ************************************************************************
57 * Setup the architecture
60 static void __init mpc836x_mds_setup_arch(void)
62 struct device_node *np;
63 u8 __iomem *bcsr_regs = NULL;
68 np = of_find_node_by_name(NULL, "bcsr");
72 of_address_to_resource(np, 0, &res);
73 bcsr_regs = ioremap(res.start, resource_size(&res));
77 #ifdef CONFIG_QUICC_ENGINE
78 if ((np = of_find_node_by_name(NULL, "par_io")) != NULL) {
82 for_each_node_by_name(np, "ucc")
85 /* Must fixup Par IO before QE GPIO chips are registered. */
86 par_io_config_pin(1, 2, 1, 0, 3, 0); /* USBOE */
87 par_io_config_pin(1, 3, 1, 0, 3, 0); /* USBTP */
88 par_io_config_pin(1, 8, 1, 0, 1, 0); /* USBTN */
89 par_io_config_pin(1, 10, 2, 0, 3, 0); /* USBRXD */
90 par_io_config_pin(1, 9, 2, 1, 3, 0); /* USBRP */
91 par_io_config_pin(1, 11, 2, 1, 3, 0); /* USBRN */
92 par_io_config_pin(2, 20, 2, 0, 1, 0); /* CLK21 */
93 #endif /* CONFIG_QE_USB */
96 if ((np = of_find_compatible_node(NULL, "network", "ucc_geth"))
100 /* Reset the Ethernet PHY */
101 #define BCSR9_GETHRST 0x20
102 clrbits8(&bcsr_regs[9], BCSR9_GETHRST);
104 setbits8(&bcsr_regs[9], BCSR9_GETHRST);
106 /* handle mpc8360ea rev.2.1 erratum 2: RGMII Timing */
107 svid = mfspr(SPRN_SVR);
108 if (svid == 0x80480021) {
111 immap = ioremap(get_immrbase() + 0x14a8, 8);
114 * IMMR + 0x14A8[4:5] = 11 (clk delay for UCC 2)
115 * IMMR + 0x14A8[18:19] = 11 (clk delay for UCC 1)
117 setbits32(immap, 0x0c003000);
120 * IMMR + 0x14AC[20:27] = 10101010
121 * (data delay for both UCC's)
123 clrsetbits_be32(immap + 4, 0xff0, 0xaa0);
131 #endif /* CONFIG_QUICC_ENGINE */
134 machine_device_initcall(mpc836x_mds, mpc83xx_declare_of_platform_devices);
137 static int __init mpc836x_usb_cfg(void)
140 struct device_node *np;
144 np = of_find_compatible_node(NULL, NULL, "fsl,mpc8360mds-bcsr");
148 bcsr = of_iomap(np, 0);
153 np = of_find_compatible_node(NULL, NULL, "fsl,mpc8323-qe-usb");
159 #define BCSR8_TSEC1M_MASK (0x3 << 6)
160 #define BCSR8_TSEC1M_RGMII (0x0 << 6)
161 #define BCSR8_TSEC2M_MASK (0x3 << 4)
162 #define BCSR8_TSEC2M_RGMII (0x0 << 4)
164 * Default is GMII (2), but we should set it to RGMII (0) if we use
165 * USB (Eth PHY is in RGMII mode anyway).
167 clrsetbits_8(&bcsr[8], BCSR8_TSEC1M_MASK | BCSR8_TSEC2M_MASK,
168 BCSR8_TSEC1M_RGMII | BCSR8_TSEC2M_RGMII);
170 #define BCSR13_USBMASK 0x0f
171 #define BCSR13_nUSBEN 0x08 /* 1 - Disable, 0 - Enable */
172 #define BCSR13_USBSPEED 0x04 /* 1 - Full, 0 - Low */
173 #define BCSR13_USBMODE 0x02 /* 1 - Host, 0 - Function */
174 #define BCSR13_nUSBVCC 0x01 /* 1 - gets VBUS, 0 - supplies VBUS */
176 clrsetbits_8(&bcsr[13], BCSR13_USBMASK, BCSR13_USBSPEED);
178 mode = of_get_property(np, "mode", NULL);
179 if (mode && !strcmp(mode, "peripheral")) {
180 setbits8(&bcsr[13], BCSR13_nUSBVCC);
181 qe_usb_clock_set(QE_CLK21, 48000000);
183 setbits8(&bcsr[13], BCSR13_USBMODE);
185 * The BCSR GPIOs are used to control power and
186 * speed of the USB transceiver. This is needed for
189 simple_gpiochip_init("fsl,mpc8360mds-bcsr-gpio");
197 machine_arch_initcall(mpc836x_mds, mpc836x_usb_cfg);
198 #endif /* CONFIG_QE_USB */
201 * Called very early, MMU is off, device-tree isn't unflattened
203 static int __init mpc836x_mds_probe(void)
205 return of_machine_is_compatible("MPC836xMDS");
208 define_machine(mpc836x_mds) {
209 .name = "MPC836x MDS",
210 .probe = mpc836x_mds_probe,
211 .setup_arch = mpc836x_mds_setup_arch,
212 .init_IRQ = mpc83xx_ipic_and_qe_init_IRQ,
213 .get_irq = ipic_get_irq,
214 .restart = mpc83xx_restart,
215 .time_init = mpc83xx_time_init,
216 .calibrate_decr = generic_calibrate_decr,
217 .progress = udbg_progress,