18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0-or-later
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci * Copyright 2010-2011, 2013 Freescale Semiconductor, Inc.
48c2ecf20Sopenharmony_ci *
58c2ecf20Sopenharmony_ci * Author: Michael Johnston <michael.johnston@freescale.com>
68c2ecf20Sopenharmony_ci *
78c2ecf20Sopenharmony_ci * Description:
88c2ecf20Sopenharmony_ci * TWR-P102x Board Setup
98c2ecf20Sopenharmony_ci */
108c2ecf20Sopenharmony_ci
118c2ecf20Sopenharmony_ci#include <linux/kernel.h>
128c2ecf20Sopenharmony_ci#include <linux/init.h>
138c2ecf20Sopenharmony_ci#include <linux/errno.h>
148c2ecf20Sopenharmony_ci#include <linux/fsl/guts.h>
158c2ecf20Sopenharmony_ci#include <linux/pci.h>
168c2ecf20Sopenharmony_ci#include <linux/of_platform.h>
178c2ecf20Sopenharmony_ci
188c2ecf20Sopenharmony_ci#include <asm/pci-bridge.h>
198c2ecf20Sopenharmony_ci#include <asm/udbg.h>
208c2ecf20Sopenharmony_ci#include <asm/mpic.h>
218c2ecf20Sopenharmony_ci#include <soc/fsl/qe/qe.h>
228c2ecf20Sopenharmony_ci
238c2ecf20Sopenharmony_ci#include <sysdev/fsl_soc.h>
248c2ecf20Sopenharmony_ci#include <sysdev/fsl_pci.h>
258c2ecf20Sopenharmony_ci#include "smp.h"
268c2ecf20Sopenharmony_ci
278c2ecf20Sopenharmony_ci#include "mpc85xx.h"
288c2ecf20Sopenharmony_ci
298c2ecf20Sopenharmony_cistatic void __init twr_p1025_pic_init(void)
308c2ecf20Sopenharmony_ci{
318c2ecf20Sopenharmony_ci	struct mpic *mpic;
328c2ecf20Sopenharmony_ci
338c2ecf20Sopenharmony_ci	mpic = mpic_alloc(NULL, 0, MPIC_BIG_ENDIAN |
348c2ecf20Sopenharmony_ci			MPIC_SINGLE_DEST_CPU,
358c2ecf20Sopenharmony_ci			0, 256, " OpenPIC  ");
368c2ecf20Sopenharmony_ci
378c2ecf20Sopenharmony_ci	BUG_ON(mpic == NULL);
388c2ecf20Sopenharmony_ci	mpic_init(mpic);
398c2ecf20Sopenharmony_ci}
408c2ecf20Sopenharmony_ci
418c2ecf20Sopenharmony_ci/* ************************************************************************
428c2ecf20Sopenharmony_ci *
438c2ecf20Sopenharmony_ci * Setup the architecture
448c2ecf20Sopenharmony_ci *
458c2ecf20Sopenharmony_ci */
468c2ecf20Sopenharmony_cistatic void __init twr_p1025_setup_arch(void)
478c2ecf20Sopenharmony_ci{
488c2ecf20Sopenharmony_ci	if (ppc_md.progress)
498c2ecf20Sopenharmony_ci		ppc_md.progress("twr_p1025_setup_arch()", 0);
508c2ecf20Sopenharmony_ci
518c2ecf20Sopenharmony_ci	mpc85xx_smp_init();
528c2ecf20Sopenharmony_ci
538c2ecf20Sopenharmony_ci	fsl_pci_assign_primary();
548c2ecf20Sopenharmony_ci
558c2ecf20Sopenharmony_ci#ifdef CONFIG_QUICC_ENGINE
568c2ecf20Sopenharmony_ci	mpc85xx_qe_par_io_init();
578c2ecf20Sopenharmony_ci
588c2ecf20Sopenharmony_ci#if IS_ENABLED(CONFIG_UCC_GETH) || IS_ENABLED(CONFIG_SERIAL_QE)
598c2ecf20Sopenharmony_ci	if (machine_is(twr_p1025)) {
608c2ecf20Sopenharmony_ci		struct ccsr_guts __iomem *guts;
618c2ecf20Sopenharmony_ci		struct device_node *np;
628c2ecf20Sopenharmony_ci
638c2ecf20Sopenharmony_ci		np = of_find_compatible_node(NULL, NULL, "fsl,p1021-guts");
648c2ecf20Sopenharmony_ci		if (np) {
658c2ecf20Sopenharmony_ci			guts = of_iomap(np, 0);
668c2ecf20Sopenharmony_ci			if (!guts)
678c2ecf20Sopenharmony_ci				pr_err("twr_p1025: could not map global utilities register\n");
688c2ecf20Sopenharmony_ci			else {
698c2ecf20Sopenharmony_ci			/* P1025 has pins muxed for QE and other functions. To
708c2ecf20Sopenharmony_ci			 * enable QE UEC mode, we need to set bit QE0 for UCC1
718c2ecf20Sopenharmony_ci			 * in Eth mode, QE0 and QE3 for UCC5 in Eth mode, QE9
728c2ecf20Sopenharmony_ci			 * and QE12 for QE MII management signals in PMUXCR
738c2ecf20Sopenharmony_ci			 * register.
748c2ecf20Sopenharmony_ci			 * Set QE mux bits in PMUXCR */
758c2ecf20Sopenharmony_ci			setbits32(&guts->pmuxcr, MPC85xx_PMUXCR_QE(0) |
768c2ecf20Sopenharmony_ci					MPC85xx_PMUXCR_QE(3) |
778c2ecf20Sopenharmony_ci					MPC85xx_PMUXCR_QE(9) |
788c2ecf20Sopenharmony_ci					MPC85xx_PMUXCR_QE(12));
798c2ecf20Sopenharmony_ci			iounmap(guts);
808c2ecf20Sopenharmony_ci
818c2ecf20Sopenharmony_ci#if IS_ENABLED(CONFIG_SERIAL_QE)
828c2ecf20Sopenharmony_ci			/* On P1025TWR board, the UCC7 acted as UART port.
838c2ecf20Sopenharmony_ci			 * However, The UCC7's CTS pin is low level in default,
848c2ecf20Sopenharmony_ci			 * it will impact the transmission in full duplex
858c2ecf20Sopenharmony_ci			 * communication. So disable the Flow control pin PA18.
868c2ecf20Sopenharmony_ci			 * The UCC7 UART just can use RXD and TXD pins.
878c2ecf20Sopenharmony_ci			 */
888c2ecf20Sopenharmony_ci			par_io_config_pin(0, 18, 0, 0, 0, 0);
898c2ecf20Sopenharmony_ci#endif
908c2ecf20Sopenharmony_ci			/* Drive PB29 to CPLD low - CPLD will then change
918c2ecf20Sopenharmony_ci			 * muxing from LBC to QE */
928c2ecf20Sopenharmony_ci			par_io_config_pin(1, 29, 1, 0, 0, 0);
938c2ecf20Sopenharmony_ci			par_io_data_set(1, 29, 0);
948c2ecf20Sopenharmony_ci			}
958c2ecf20Sopenharmony_ci			of_node_put(np);
968c2ecf20Sopenharmony_ci		}
978c2ecf20Sopenharmony_ci	}
988c2ecf20Sopenharmony_ci#endif
998c2ecf20Sopenharmony_ci#endif	/* CONFIG_QUICC_ENGINE */
1008c2ecf20Sopenharmony_ci
1018c2ecf20Sopenharmony_ci	pr_info("TWR-P1025 board from Freescale Semiconductor\n");
1028c2ecf20Sopenharmony_ci}
1038c2ecf20Sopenharmony_ci
1048c2ecf20Sopenharmony_cimachine_arch_initcall(twr_p1025, mpc85xx_common_publish_devices);
1058c2ecf20Sopenharmony_ci
1068c2ecf20Sopenharmony_cistatic int __init twr_p1025_probe(void)
1078c2ecf20Sopenharmony_ci{
1088c2ecf20Sopenharmony_ci	return of_machine_is_compatible("fsl,TWR-P1025");
1098c2ecf20Sopenharmony_ci}
1108c2ecf20Sopenharmony_ci
1118c2ecf20Sopenharmony_cidefine_machine(twr_p1025) {
1128c2ecf20Sopenharmony_ci	.name			= "TWR-P1025",
1138c2ecf20Sopenharmony_ci	.probe			= twr_p1025_probe,
1148c2ecf20Sopenharmony_ci	.setup_arch		= twr_p1025_setup_arch,
1158c2ecf20Sopenharmony_ci	.init_IRQ		= twr_p1025_pic_init,
1168c2ecf20Sopenharmony_ci#ifdef CONFIG_PCI
1178c2ecf20Sopenharmony_ci	.pcibios_fixup_bus	= fsl_pcibios_fixup_bus,
1188c2ecf20Sopenharmony_ci#endif
1198c2ecf20Sopenharmony_ci	.get_irq		= mpic_get_irq,
1208c2ecf20Sopenharmony_ci	.calibrate_decr		= generic_calibrate_decr,
1218c2ecf20Sopenharmony_ci	.progress		= udbg_progress,
1228c2ecf20Sopenharmony_ci};
123