18c2ecf20Sopenharmony_ci/* 28c2ecf20Sopenharmony_ci * Platform setup for the MPC8xx based boards from TQM. 38c2ecf20Sopenharmony_ci * 48c2ecf20Sopenharmony_ci * Heiko Schocher <hs@denx.de> 58c2ecf20Sopenharmony_ci * Copyright 2010 DENX Software Engineering GmbH 68c2ecf20Sopenharmony_ci * 78c2ecf20Sopenharmony_ci * based on: 88c2ecf20Sopenharmony_ci * Vitaly Bordug <vbordug@ru.mvista.com> 98c2ecf20Sopenharmony_ci * 108c2ecf20Sopenharmony_ci * Copyright 2005 MontaVista Software Inc. 118c2ecf20Sopenharmony_ci * 128c2ecf20Sopenharmony_ci * Heavily modified by Scott Wood <scottwood@freescale.com> 138c2ecf20Sopenharmony_ci * Copyright 2007 Freescale Semiconductor, Inc. 148c2ecf20Sopenharmony_ci * 158c2ecf20Sopenharmony_ci * This file is licensed under the terms of the GNU General Public License 168c2ecf20Sopenharmony_ci * version 2. This program is licensed "as is" without any warranty of any 178c2ecf20Sopenharmony_ci * kind, whether express or implied. 188c2ecf20Sopenharmony_ci */ 198c2ecf20Sopenharmony_ci 208c2ecf20Sopenharmony_ci#include <linux/init.h> 218c2ecf20Sopenharmony_ci#include <linux/param.h> 228c2ecf20Sopenharmony_ci#include <linux/string.h> 238c2ecf20Sopenharmony_ci#include <linux/ioport.h> 248c2ecf20Sopenharmony_ci#include <linux/device.h> 258c2ecf20Sopenharmony_ci#include <linux/delay.h> 268c2ecf20Sopenharmony_ci 278c2ecf20Sopenharmony_ci#include <linux/fs_enet_pd.h> 288c2ecf20Sopenharmony_ci#include <linux/fs_uart_pd.h> 298c2ecf20Sopenharmony_ci#include <linux/fsl_devices.h> 308c2ecf20Sopenharmony_ci#include <linux/mii.h> 318c2ecf20Sopenharmony_ci#include <linux/of_fdt.h> 328c2ecf20Sopenharmony_ci#include <linux/of_platform.h> 338c2ecf20Sopenharmony_ci 348c2ecf20Sopenharmony_ci#include <asm/delay.h> 358c2ecf20Sopenharmony_ci#include <asm/io.h> 368c2ecf20Sopenharmony_ci#include <asm/machdep.h> 378c2ecf20Sopenharmony_ci#include <asm/page.h> 388c2ecf20Sopenharmony_ci#include <asm/processor.h> 398c2ecf20Sopenharmony_ci#include <asm/time.h> 408c2ecf20Sopenharmony_ci#include <asm/8xx_immap.h> 418c2ecf20Sopenharmony_ci#include <asm/cpm1.h> 428c2ecf20Sopenharmony_ci#include <asm/fs_pd.h> 438c2ecf20Sopenharmony_ci#include <asm/udbg.h> 448c2ecf20Sopenharmony_ci 458c2ecf20Sopenharmony_ci#include "mpc8xx.h" 468c2ecf20Sopenharmony_ci 478c2ecf20Sopenharmony_cistruct cpm_pin { 488c2ecf20Sopenharmony_ci int port, pin, flags; 498c2ecf20Sopenharmony_ci}; 508c2ecf20Sopenharmony_ci 518c2ecf20Sopenharmony_cistatic struct cpm_pin tqm8xx_pins[] __initdata = { 528c2ecf20Sopenharmony_ci /* SMC1 */ 538c2ecf20Sopenharmony_ci {CPM_PORTB, 24, CPM_PIN_INPUT}, /* RX */ 548c2ecf20Sopenharmony_ci {CPM_PORTB, 25, CPM_PIN_INPUT | CPM_PIN_SECONDARY}, /* TX */ 558c2ecf20Sopenharmony_ci 568c2ecf20Sopenharmony_ci /* SCC1 */ 578c2ecf20Sopenharmony_ci {CPM_PORTA, 5, CPM_PIN_INPUT}, /* CLK1 */ 588c2ecf20Sopenharmony_ci {CPM_PORTA, 7, CPM_PIN_INPUT}, /* CLK2 */ 598c2ecf20Sopenharmony_ci {CPM_PORTA, 14, CPM_PIN_INPUT}, /* TX */ 608c2ecf20Sopenharmony_ci {CPM_PORTA, 15, CPM_PIN_INPUT}, /* RX */ 618c2ecf20Sopenharmony_ci {CPM_PORTC, 15, CPM_PIN_INPUT | CPM_PIN_SECONDARY}, /* TENA */ 628c2ecf20Sopenharmony_ci {CPM_PORTC, 10, CPM_PIN_INPUT | CPM_PIN_SECONDARY | CPM_PIN_GPIO}, 638c2ecf20Sopenharmony_ci {CPM_PORTC, 11, CPM_PIN_INPUT | CPM_PIN_SECONDARY | CPM_PIN_GPIO}, 648c2ecf20Sopenharmony_ci}; 658c2ecf20Sopenharmony_ci 668c2ecf20Sopenharmony_cistatic struct cpm_pin tqm8xx_fec_pins[] __initdata = { 678c2ecf20Sopenharmony_ci /* MII */ 688c2ecf20Sopenharmony_ci {CPM_PORTD, 3, CPM_PIN_OUTPUT}, 698c2ecf20Sopenharmony_ci {CPM_PORTD, 4, CPM_PIN_OUTPUT}, 708c2ecf20Sopenharmony_ci {CPM_PORTD, 5, CPM_PIN_OUTPUT}, 718c2ecf20Sopenharmony_ci {CPM_PORTD, 6, CPM_PIN_OUTPUT}, 728c2ecf20Sopenharmony_ci {CPM_PORTD, 7, CPM_PIN_OUTPUT}, 738c2ecf20Sopenharmony_ci {CPM_PORTD, 8, CPM_PIN_OUTPUT}, 748c2ecf20Sopenharmony_ci {CPM_PORTD, 9, CPM_PIN_OUTPUT}, 758c2ecf20Sopenharmony_ci {CPM_PORTD, 10, CPM_PIN_OUTPUT}, 768c2ecf20Sopenharmony_ci {CPM_PORTD, 11, CPM_PIN_OUTPUT}, 778c2ecf20Sopenharmony_ci {CPM_PORTD, 12, CPM_PIN_OUTPUT}, 788c2ecf20Sopenharmony_ci {CPM_PORTD, 13, CPM_PIN_OUTPUT}, 798c2ecf20Sopenharmony_ci {CPM_PORTD, 14, CPM_PIN_OUTPUT}, 808c2ecf20Sopenharmony_ci {CPM_PORTD, 15, CPM_PIN_OUTPUT}, 818c2ecf20Sopenharmony_ci}; 828c2ecf20Sopenharmony_ci 838c2ecf20Sopenharmony_cistatic void __init init_pins(int n, struct cpm_pin *pin) 848c2ecf20Sopenharmony_ci{ 858c2ecf20Sopenharmony_ci int i; 868c2ecf20Sopenharmony_ci 878c2ecf20Sopenharmony_ci for (i = 0; i < n; i++) { 888c2ecf20Sopenharmony_ci cpm1_set_pin(pin->port, pin->pin, pin->flags); 898c2ecf20Sopenharmony_ci pin++; 908c2ecf20Sopenharmony_ci } 918c2ecf20Sopenharmony_ci} 928c2ecf20Sopenharmony_ci 938c2ecf20Sopenharmony_cistatic void __init init_ioports(void) 948c2ecf20Sopenharmony_ci{ 958c2ecf20Sopenharmony_ci struct device_node *dnode; 968c2ecf20Sopenharmony_ci struct property *prop; 978c2ecf20Sopenharmony_ci int len; 988c2ecf20Sopenharmony_ci 998c2ecf20Sopenharmony_ci init_pins(ARRAY_SIZE(tqm8xx_pins), &tqm8xx_pins[0]); 1008c2ecf20Sopenharmony_ci 1018c2ecf20Sopenharmony_ci cpm1_clk_setup(CPM_CLK_SMC1, CPM_BRG1, CPM_CLK_RTX); 1028c2ecf20Sopenharmony_ci 1038c2ecf20Sopenharmony_ci dnode = of_find_node_by_name(NULL, "aliases"); 1048c2ecf20Sopenharmony_ci if (dnode == NULL) 1058c2ecf20Sopenharmony_ci return; 1068c2ecf20Sopenharmony_ci prop = of_find_property(dnode, "ethernet1", &len); 1078c2ecf20Sopenharmony_ci if (prop == NULL) 1088c2ecf20Sopenharmony_ci return; 1098c2ecf20Sopenharmony_ci 1108c2ecf20Sopenharmony_ci /* init FEC pins */ 1118c2ecf20Sopenharmony_ci init_pins(ARRAY_SIZE(tqm8xx_fec_pins), &tqm8xx_fec_pins[0]); 1128c2ecf20Sopenharmony_ci} 1138c2ecf20Sopenharmony_ci 1148c2ecf20Sopenharmony_cistatic void __init tqm8xx_setup_arch(void) 1158c2ecf20Sopenharmony_ci{ 1168c2ecf20Sopenharmony_ci cpm_reset(); 1178c2ecf20Sopenharmony_ci init_ioports(); 1188c2ecf20Sopenharmony_ci} 1198c2ecf20Sopenharmony_ci 1208c2ecf20Sopenharmony_cistatic int __init tqm8xx_probe(void) 1218c2ecf20Sopenharmony_ci{ 1228c2ecf20Sopenharmony_ci return of_machine_is_compatible("tqc,tqm8xx"); 1238c2ecf20Sopenharmony_ci} 1248c2ecf20Sopenharmony_ci 1258c2ecf20Sopenharmony_cistatic const struct of_device_id of_bus_ids[] __initconst = { 1268c2ecf20Sopenharmony_ci { .name = "soc", }, 1278c2ecf20Sopenharmony_ci { .name = "cpm", }, 1288c2ecf20Sopenharmony_ci { .name = "localbus", }, 1298c2ecf20Sopenharmony_ci { .compatible = "simple-bus" }, 1308c2ecf20Sopenharmony_ci {}, 1318c2ecf20Sopenharmony_ci}; 1328c2ecf20Sopenharmony_ci 1338c2ecf20Sopenharmony_cistatic int __init declare_of_platform_devices(void) 1348c2ecf20Sopenharmony_ci{ 1358c2ecf20Sopenharmony_ci of_platform_bus_probe(NULL, of_bus_ids, NULL); 1368c2ecf20Sopenharmony_ci 1378c2ecf20Sopenharmony_ci return 0; 1388c2ecf20Sopenharmony_ci} 1398c2ecf20Sopenharmony_cimachine_device_initcall(tqm8xx, declare_of_platform_devices); 1408c2ecf20Sopenharmony_ci 1418c2ecf20Sopenharmony_cidefine_machine(tqm8xx) { 1428c2ecf20Sopenharmony_ci .name = "TQM8xx", 1438c2ecf20Sopenharmony_ci .probe = tqm8xx_probe, 1448c2ecf20Sopenharmony_ci .setup_arch = tqm8xx_setup_arch, 1458c2ecf20Sopenharmony_ci .init_IRQ = mpc8xx_pics_init, 1468c2ecf20Sopenharmony_ci .get_irq = mpc8xx_get_irq, 1478c2ecf20Sopenharmony_ci .restart = mpc8xx_restart, 1488c2ecf20Sopenharmony_ci .calibrate_decr = mpc8xx_calibrate_decr, 1498c2ecf20Sopenharmony_ci .set_rtc_time = mpc8xx_set_rtc_time, 1508c2ecf20Sopenharmony_ci .get_rtc_time = mpc8xx_get_rtc_time, 1518c2ecf20Sopenharmony_ci .progress = udbg_progress, 1528c2ecf20Sopenharmony_ci}; 153