18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0-or-later 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * MPC85xx setup and early boot code plus other random bits. 48c2ecf20Sopenharmony_ci * 58c2ecf20Sopenharmony_ci * Maintained by Kumar Gala (see MAINTAINERS for contact information) 68c2ecf20Sopenharmony_ci * 78c2ecf20Sopenharmony_ci * Copyright 2005 Freescale Semiconductor Inc. 88c2ecf20Sopenharmony_ci */ 98c2ecf20Sopenharmony_ci 108c2ecf20Sopenharmony_ci#include <linux/stddef.h> 118c2ecf20Sopenharmony_ci#include <linux/kernel.h> 128c2ecf20Sopenharmony_ci#include <linux/pci.h> 138c2ecf20Sopenharmony_ci#include <linux/kdev_t.h> 148c2ecf20Sopenharmony_ci#include <linux/delay.h> 158c2ecf20Sopenharmony_ci#include <linux/seq_file.h> 168c2ecf20Sopenharmony_ci#include <linux/of_platform.h> 178c2ecf20Sopenharmony_ci 188c2ecf20Sopenharmony_ci#include <asm/time.h> 198c2ecf20Sopenharmony_ci#include <asm/machdep.h> 208c2ecf20Sopenharmony_ci#include <asm/pci-bridge.h> 218c2ecf20Sopenharmony_ci#include <asm/mpic.h> 228c2ecf20Sopenharmony_ci#include <mm/mmu_decl.h> 238c2ecf20Sopenharmony_ci#include <asm/udbg.h> 248c2ecf20Sopenharmony_ci 258c2ecf20Sopenharmony_ci#include <sysdev/fsl_soc.h> 268c2ecf20Sopenharmony_ci#include <sysdev/fsl_pci.h> 278c2ecf20Sopenharmony_ci 288c2ecf20Sopenharmony_ci#ifdef CONFIG_CPM2 298c2ecf20Sopenharmony_ci#include <asm/cpm2.h> 308c2ecf20Sopenharmony_ci#include <sysdev/cpm2_pic.h> 318c2ecf20Sopenharmony_ci#endif 328c2ecf20Sopenharmony_ci 338c2ecf20Sopenharmony_ci#include "mpc85xx.h" 348c2ecf20Sopenharmony_ci 358c2ecf20Sopenharmony_cistatic void __init mpc85xx_ads_pic_init(void) 368c2ecf20Sopenharmony_ci{ 378c2ecf20Sopenharmony_ci struct mpic *mpic = mpic_alloc(NULL, 0, MPIC_BIG_ENDIAN, 388c2ecf20Sopenharmony_ci 0, 256, " OpenPIC "); 398c2ecf20Sopenharmony_ci BUG_ON(mpic == NULL); 408c2ecf20Sopenharmony_ci mpic_init(mpic); 418c2ecf20Sopenharmony_ci 428c2ecf20Sopenharmony_ci mpc85xx_cpm2_pic_init(); 438c2ecf20Sopenharmony_ci} 448c2ecf20Sopenharmony_ci 458c2ecf20Sopenharmony_ci/* 468c2ecf20Sopenharmony_ci * Setup the architecture 478c2ecf20Sopenharmony_ci */ 488c2ecf20Sopenharmony_ci#ifdef CONFIG_CPM2 498c2ecf20Sopenharmony_cistruct cpm_pin { 508c2ecf20Sopenharmony_ci int port, pin, flags; 518c2ecf20Sopenharmony_ci}; 528c2ecf20Sopenharmony_ci 538c2ecf20Sopenharmony_cistatic const struct cpm_pin mpc8560_ads_pins[] = { 548c2ecf20Sopenharmony_ci /* SCC1 */ 558c2ecf20Sopenharmony_ci {3, 29, CPM_PIN_OUTPUT | CPM_PIN_PRIMARY}, 568c2ecf20Sopenharmony_ci {3, 30, CPM_PIN_OUTPUT | CPM_PIN_SECONDARY}, 578c2ecf20Sopenharmony_ci {3, 31, CPM_PIN_INPUT | CPM_PIN_PRIMARY}, 588c2ecf20Sopenharmony_ci 598c2ecf20Sopenharmony_ci /* SCC2 */ 608c2ecf20Sopenharmony_ci {2, 12, CPM_PIN_INPUT | CPM_PIN_PRIMARY}, 618c2ecf20Sopenharmony_ci {2, 13, CPM_PIN_INPUT | CPM_PIN_PRIMARY}, 628c2ecf20Sopenharmony_ci {3, 26, CPM_PIN_OUTPUT | CPM_PIN_PRIMARY}, 638c2ecf20Sopenharmony_ci {3, 27, CPM_PIN_OUTPUT | CPM_PIN_PRIMARY}, 648c2ecf20Sopenharmony_ci {3, 28, CPM_PIN_INPUT | CPM_PIN_PRIMARY}, 658c2ecf20Sopenharmony_ci 668c2ecf20Sopenharmony_ci /* FCC2 */ 678c2ecf20Sopenharmony_ci {1, 18, CPM_PIN_INPUT | CPM_PIN_PRIMARY}, 688c2ecf20Sopenharmony_ci {1, 19, CPM_PIN_INPUT | CPM_PIN_PRIMARY}, 698c2ecf20Sopenharmony_ci {1, 20, CPM_PIN_INPUT | CPM_PIN_PRIMARY}, 708c2ecf20Sopenharmony_ci {1, 21, CPM_PIN_INPUT | CPM_PIN_PRIMARY}, 718c2ecf20Sopenharmony_ci {1, 22, CPM_PIN_OUTPUT | CPM_PIN_PRIMARY}, 728c2ecf20Sopenharmony_ci {1, 23, CPM_PIN_OUTPUT | CPM_PIN_PRIMARY}, 738c2ecf20Sopenharmony_ci {1, 24, CPM_PIN_OUTPUT | CPM_PIN_PRIMARY}, 748c2ecf20Sopenharmony_ci {1, 25, CPM_PIN_OUTPUT | CPM_PIN_PRIMARY}, 758c2ecf20Sopenharmony_ci {1, 26, CPM_PIN_INPUT | CPM_PIN_PRIMARY}, 768c2ecf20Sopenharmony_ci {1, 27, CPM_PIN_INPUT | CPM_PIN_PRIMARY}, 778c2ecf20Sopenharmony_ci {1, 28, CPM_PIN_INPUT | CPM_PIN_PRIMARY}, 788c2ecf20Sopenharmony_ci {1, 29, CPM_PIN_OUTPUT | CPM_PIN_SECONDARY}, 798c2ecf20Sopenharmony_ci {1, 30, CPM_PIN_INPUT | CPM_PIN_PRIMARY}, 808c2ecf20Sopenharmony_ci {1, 31, CPM_PIN_OUTPUT | CPM_PIN_PRIMARY}, 818c2ecf20Sopenharmony_ci {2, 18, CPM_PIN_INPUT | CPM_PIN_PRIMARY}, /* CLK14 */ 828c2ecf20Sopenharmony_ci {2, 19, CPM_PIN_INPUT | CPM_PIN_PRIMARY}, /* CLK13 */ 838c2ecf20Sopenharmony_ci 848c2ecf20Sopenharmony_ci /* FCC3 */ 858c2ecf20Sopenharmony_ci {1, 4, CPM_PIN_OUTPUT | CPM_PIN_PRIMARY}, 868c2ecf20Sopenharmony_ci {1, 5, CPM_PIN_OUTPUT | CPM_PIN_PRIMARY}, 878c2ecf20Sopenharmony_ci {1, 6, CPM_PIN_OUTPUT | CPM_PIN_PRIMARY}, 888c2ecf20Sopenharmony_ci {1, 8, CPM_PIN_INPUT | CPM_PIN_PRIMARY}, 898c2ecf20Sopenharmony_ci {1, 9, CPM_PIN_INPUT | CPM_PIN_PRIMARY}, 908c2ecf20Sopenharmony_ci {1, 10, CPM_PIN_INPUT | CPM_PIN_PRIMARY}, 918c2ecf20Sopenharmony_ci {1, 11, CPM_PIN_INPUT | CPM_PIN_PRIMARY}, 928c2ecf20Sopenharmony_ci {1, 12, CPM_PIN_INPUT | CPM_PIN_PRIMARY}, 938c2ecf20Sopenharmony_ci {1, 13, CPM_PIN_INPUT | CPM_PIN_PRIMARY}, 948c2ecf20Sopenharmony_ci {1, 14, CPM_PIN_OUTPUT | CPM_PIN_PRIMARY}, 958c2ecf20Sopenharmony_ci {1, 15, CPM_PIN_OUTPUT | CPM_PIN_PRIMARY}, 968c2ecf20Sopenharmony_ci {1, 16, CPM_PIN_INPUT | CPM_PIN_PRIMARY}, 978c2ecf20Sopenharmony_ci {1, 17, CPM_PIN_INPUT | CPM_PIN_PRIMARY}, 988c2ecf20Sopenharmony_ci {2, 16, CPM_PIN_INPUT | CPM_PIN_PRIMARY}, /* CLK16 */ 998c2ecf20Sopenharmony_ci {2, 17, CPM_PIN_INPUT | CPM_PIN_PRIMARY}, /* CLK15 */ 1008c2ecf20Sopenharmony_ci {2, 27, CPM_PIN_OUTPUT | CPM_PIN_PRIMARY}, 1018c2ecf20Sopenharmony_ci}; 1028c2ecf20Sopenharmony_ci 1038c2ecf20Sopenharmony_cistatic void __init init_ioports(void) 1048c2ecf20Sopenharmony_ci{ 1058c2ecf20Sopenharmony_ci int i; 1068c2ecf20Sopenharmony_ci 1078c2ecf20Sopenharmony_ci for (i = 0; i < ARRAY_SIZE(mpc8560_ads_pins); i++) { 1088c2ecf20Sopenharmony_ci const struct cpm_pin *pin = &mpc8560_ads_pins[i]; 1098c2ecf20Sopenharmony_ci cpm2_set_pin(pin->port, pin->pin, pin->flags); 1108c2ecf20Sopenharmony_ci } 1118c2ecf20Sopenharmony_ci 1128c2ecf20Sopenharmony_ci cpm2_clk_setup(CPM_CLK_SCC1, CPM_BRG1, CPM_CLK_RX); 1138c2ecf20Sopenharmony_ci cpm2_clk_setup(CPM_CLK_SCC1, CPM_BRG1, CPM_CLK_TX); 1148c2ecf20Sopenharmony_ci cpm2_clk_setup(CPM_CLK_SCC2, CPM_BRG2, CPM_CLK_RX); 1158c2ecf20Sopenharmony_ci cpm2_clk_setup(CPM_CLK_SCC2, CPM_BRG2, CPM_CLK_TX); 1168c2ecf20Sopenharmony_ci cpm2_clk_setup(CPM_CLK_FCC2, CPM_CLK13, CPM_CLK_RX); 1178c2ecf20Sopenharmony_ci cpm2_clk_setup(CPM_CLK_FCC2, CPM_CLK14, CPM_CLK_TX); 1188c2ecf20Sopenharmony_ci cpm2_clk_setup(CPM_CLK_FCC3, CPM_CLK15, CPM_CLK_RX); 1198c2ecf20Sopenharmony_ci cpm2_clk_setup(CPM_CLK_FCC3, CPM_CLK16, CPM_CLK_TX); 1208c2ecf20Sopenharmony_ci} 1218c2ecf20Sopenharmony_ci#endif 1228c2ecf20Sopenharmony_ci 1238c2ecf20Sopenharmony_cistatic void __init mpc85xx_ads_setup_arch(void) 1248c2ecf20Sopenharmony_ci{ 1258c2ecf20Sopenharmony_ci if (ppc_md.progress) 1268c2ecf20Sopenharmony_ci ppc_md.progress("mpc85xx_ads_setup_arch()", 0); 1278c2ecf20Sopenharmony_ci 1288c2ecf20Sopenharmony_ci#ifdef CONFIG_CPM2 1298c2ecf20Sopenharmony_ci cpm2_reset(); 1308c2ecf20Sopenharmony_ci init_ioports(); 1318c2ecf20Sopenharmony_ci#endif 1328c2ecf20Sopenharmony_ci 1338c2ecf20Sopenharmony_ci fsl_pci_assign_primary(); 1348c2ecf20Sopenharmony_ci} 1358c2ecf20Sopenharmony_ci 1368c2ecf20Sopenharmony_cistatic void mpc85xx_ads_show_cpuinfo(struct seq_file *m) 1378c2ecf20Sopenharmony_ci{ 1388c2ecf20Sopenharmony_ci uint pvid, svid, phid1; 1398c2ecf20Sopenharmony_ci 1408c2ecf20Sopenharmony_ci pvid = mfspr(SPRN_PVR); 1418c2ecf20Sopenharmony_ci svid = mfspr(SPRN_SVR); 1428c2ecf20Sopenharmony_ci 1438c2ecf20Sopenharmony_ci seq_printf(m, "Vendor\t\t: Freescale Semiconductor\n"); 1448c2ecf20Sopenharmony_ci seq_printf(m, "PVR\t\t: 0x%x\n", pvid); 1458c2ecf20Sopenharmony_ci seq_printf(m, "SVR\t\t: 0x%x\n", svid); 1468c2ecf20Sopenharmony_ci 1478c2ecf20Sopenharmony_ci /* Display cpu Pll setting */ 1488c2ecf20Sopenharmony_ci phid1 = mfspr(SPRN_HID1); 1498c2ecf20Sopenharmony_ci seq_printf(m, "PLL setting\t: 0x%x\n", ((phid1 >> 24) & 0x3f)); 1508c2ecf20Sopenharmony_ci} 1518c2ecf20Sopenharmony_ci 1528c2ecf20Sopenharmony_cimachine_arch_initcall(mpc85xx_ads, mpc85xx_common_publish_devices); 1538c2ecf20Sopenharmony_ci 1548c2ecf20Sopenharmony_ci/* 1558c2ecf20Sopenharmony_ci * Called very early, device-tree isn't unflattened 1568c2ecf20Sopenharmony_ci */ 1578c2ecf20Sopenharmony_cistatic int __init mpc85xx_ads_probe(void) 1588c2ecf20Sopenharmony_ci{ 1598c2ecf20Sopenharmony_ci return of_machine_is_compatible("MPC85xxADS"); 1608c2ecf20Sopenharmony_ci} 1618c2ecf20Sopenharmony_ci 1628c2ecf20Sopenharmony_cidefine_machine(mpc85xx_ads) { 1638c2ecf20Sopenharmony_ci .name = "MPC85xx ADS", 1648c2ecf20Sopenharmony_ci .probe = mpc85xx_ads_probe, 1658c2ecf20Sopenharmony_ci .setup_arch = mpc85xx_ads_setup_arch, 1668c2ecf20Sopenharmony_ci .init_IRQ = mpc85xx_ads_pic_init, 1678c2ecf20Sopenharmony_ci .show_cpuinfo = mpc85xx_ads_show_cpuinfo, 1688c2ecf20Sopenharmony_ci .get_irq = mpic_get_irq, 1698c2ecf20Sopenharmony_ci .calibrate_decr = generic_calibrate_decr, 1708c2ecf20Sopenharmony_ci .progress = udbg_progress, 1718c2ecf20Sopenharmony_ci}; 172