18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0 28c2ecf20Sopenharmony_ci/***************************************************************************/ 38c2ecf20Sopenharmony_ci 48c2ecf20Sopenharmony_ci/* 58c2ecf20Sopenharmony_ci * m5272.c -- platform support for ColdFire 5272 based boards 68c2ecf20Sopenharmony_ci * 78c2ecf20Sopenharmony_ci * Copyright (C) 1999-2002, Greg Ungerer (gerg@snapgear.com) 88c2ecf20Sopenharmony_ci * Copyright (C) 2001-2002, SnapGear Inc. (www.snapgear.com) 98c2ecf20Sopenharmony_ci */ 108c2ecf20Sopenharmony_ci 118c2ecf20Sopenharmony_ci/***************************************************************************/ 128c2ecf20Sopenharmony_ci 138c2ecf20Sopenharmony_ci#include <linux/kernel.h> 148c2ecf20Sopenharmony_ci#include <linux/param.h> 158c2ecf20Sopenharmony_ci#include <linux/init.h> 168c2ecf20Sopenharmony_ci#include <linux/io.h> 178c2ecf20Sopenharmony_ci#include <linux/phy.h> 188c2ecf20Sopenharmony_ci#include <linux/phy_fixed.h> 198c2ecf20Sopenharmony_ci#include <asm/machdep.h> 208c2ecf20Sopenharmony_ci#include <asm/coldfire.h> 218c2ecf20Sopenharmony_ci#include <asm/mcfsim.h> 228c2ecf20Sopenharmony_ci#include <asm/mcfuart.h> 238c2ecf20Sopenharmony_ci#include <asm/mcfclk.h> 248c2ecf20Sopenharmony_ci 258c2ecf20Sopenharmony_ci/***************************************************************************/ 268c2ecf20Sopenharmony_ci 278c2ecf20Sopenharmony_ci/* 288c2ecf20Sopenharmony_ci * Some platforms need software versions of the GPIO data registers. 298c2ecf20Sopenharmony_ci */ 308c2ecf20Sopenharmony_ciunsigned short ppdata; 318c2ecf20Sopenharmony_ciunsigned char ledbank = 0xff; 328c2ecf20Sopenharmony_ci 338c2ecf20Sopenharmony_ci/***************************************************************************/ 348c2ecf20Sopenharmony_ci 358c2ecf20Sopenharmony_ciDEFINE_CLK(pll, "pll.0", MCF_CLK); 368c2ecf20Sopenharmony_ciDEFINE_CLK(sys, "sys.0", MCF_BUSCLK); 378c2ecf20Sopenharmony_ciDEFINE_CLK(mcftmr0, "mcftmr.0", MCF_BUSCLK); 388c2ecf20Sopenharmony_ciDEFINE_CLK(mcftmr1, "mcftmr.1", MCF_BUSCLK); 398c2ecf20Sopenharmony_ciDEFINE_CLK(mcftmr2, "mcftmr.2", MCF_BUSCLK); 408c2ecf20Sopenharmony_ciDEFINE_CLK(mcftmr3, "mcftmr.3", MCF_BUSCLK); 418c2ecf20Sopenharmony_ciDEFINE_CLK(mcfuart0, "mcfuart.0", MCF_BUSCLK); 428c2ecf20Sopenharmony_ciDEFINE_CLK(mcfuart1, "mcfuart.1", MCF_BUSCLK); 438c2ecf20Sopenharmony_ciDEFINE_CLK(mcfqspi0, "mcfqspi.0", MCF_BUSCLK); 448c2ecf20Sopenharmony_ciDEFINE_CLK(fec0, "fec.0", MCF_BUSCLK); 458c2ecf20Sopenharmony_ci 468c2ecf20Sopenharmony_cistruct clk *mcf_clks[] = { 478c2ecf20Sopenharmony_ci &clk_pll, 488c2ecf20Sopenharmony_ci &clk_sys, 498c2ecf20Sopenharmony_ci &clk_mcftmr0, 508c2ecf20Sopenharmony_ci &clk_mcftmr1, 518c2ecf20Sopenharmony_ci &clk_mcftmr2, 528c2ecf20Sopenharmony_ci &clk_mcftmr3, 538c2ecf20Sopenharmony_ci &clk_mcfuart0, 548c2ecf20Sopenharmony_ci &clk_mcfuart1, 558c2ecf20Sopenharmony_ci &clk_mcfqspi0, 568c2ecf20Sopenharmony_ci &clk_fec0, 578c2ecf20Sopenharmony_ci NULL 588c2ecf20Sopenharmony_ci}; 598c2ecf20Sopenharmony_ci 608c2ecf20Sopenharmony_ci/***************************************************************************/ 618c2ecf20Sopenharmony_ci 628c2ecf20Sopenharmony_cistatic void __init m5272_uarts_init(void) 638c2ecf20Sopenharmony_ci{ 648c2ecf20Sopenharmony_ci u32 v; 658c2ecf20Sopenharmony_ci 668c2ecf20Sopenharmony_ci /* Enable the output lines for the serial ports */ 678c2ecf20Sopenharmony_ci v = readl(MCFSIM_PBCNT); 688c2ecf20Sopenharmony_ci v = (v & ~0x000000ff) | 0x00000055; 698c2ecf20Sopenharmony_ci writel(v, MCFSIM_PBCNT); 708c2ecf20Sopenharmony_ci 718c2ecf20Sopenharmony_ci v = readl(MCFSIM_PDCNT); 728c2ecf20Sopenharmony_ci v = (v & ~0x000003fc) | 0x000002a8; 738c2ecf20Sopenharmony_ci writel(v, MCFSIM_PDCNT); 748c2ecf20Sopenharmony_ci} 758c2ecf20Sopenharmony_ci 768c2ecf20Sopenharmony_ci/***************************************************************************/ 778c2ecf20Sopenharmony_ci 788c2ecf20Sopenharmony_cistatic void m5272_cpu_reset(void) 798c2ecf20Sopenharmony_ci{ 808c2ecf20Sopenharmony_ci local_irq_disable(); 818c2ecf20Sopenharmony_ci /* Set watchdog to reset, and enabled */ 828c2ecf20Sopenharmony_ci __raw_writew(0, MCFSIM_WIRR); 838c2ecf20Sopenharmony_ci __raw_writew(1, MCFSIM_WRRR); 848c2ecf20Sopenharmony_ci __raw_writew(0, MCFSIM_WCR); 858c2ecf20Sopenharmony_ci for (;;) 868c2ecf20Sopenharmony_ci /* wait for watchdog to timeout */; 878c2ecf20Sopenharmony_ci} 888c2ecf20Sopenharmony_ci 898c2ecf20Sopenharmony_ci/***************************************************************************/ 908c2ecf20Sopenharmony_ci 918c2ecf20Sopenharmony_civoid __init config_BSP(char *commandp, int size) 928c2ecf20Sopenharmony_ci{ 938c2ecf20Sopenharmony_ci#if defined (CONFIG_MOD5272) 948c2ecf20Sopenharmony_ci /* Set base of device vectors to be 64 */ 958c2ecf20Sopenharmony_ci writeb(0x40, MCFSIM_PIVR); 968c2ecf20Sopenharmony_ci#endif 978c2ecf20Sopenharmony_ci 988c2ecf20Sopenharmony_ci#if defined(CONFIG_NETtel) || defined(CONFIG_SCALES) 998c2ecf20Sopenharmony_ci /* Copy command line from FLASH to local buffer... */ 1008c2ecf20Sopenharmony_ci memcpy(commandp, (char *) 0xf0004000, size); 1018c2ecf20Sopenharmony_ci commandp[size-1] = 0; 1028c2ecf20Sopenharmony_ci#elif defined(CONFIG_CANCam) 1038c2ecf20Sopenharmony_ci /* Copy command line from FLASH to local buffer... */ 1048c2ecf20Sopenharmony_ci memcpy(commandp, (char *) 0xf0010000, size); 1058c2ecf20Sopenharmony_ci commandp[size-1] = 0; 1068c2ecf20Sopenharmony_ci#endif 1078c2ecf20Sopenharmony_ci 1088c2ecf20Sopenharmony_ci mach_reset = m5272_cpu_reset; 1098c2ecf20Sopenharmony_ci mach_sched_init = hw_timer_init; 1108c2ecf20Sopenharmony_ci} 1118c2ecf20Sopenharmony_ci 1128c2ecf20Sopenharmony_ci/***************************************************************************/ 1138c2ecf20Sopenharmony_ci 1148c2ecf20Sopenharmony_ci/* 1158c2ecf20Sopenharmony_ci * Some 5272 based boards have the FEC ethernet directly connected to 1168c2ecf20Sopenharmony_ci * an ethernet switch. In this case we need to use the fixed phy type, 1178c2ecf20Sopenharmony_ci * and we need to declare it early in boot. 1188c2ecf20Sopenharmony_ci */ 1198c2ecf20Sopenharmony_cistatic struct fixed_phy_status nettel_fixed_phy_status __initdata = { 1208c2ecf20Sopenharmony_ci .link = 1, 1218c2ecf20Sopenharmony_ci .speed = 100, 1228c2ecf20Sopenharmony_ci .duplex = 0, 1238c2ecf20Sopenharmony_ci}; 1248c2ecf20Sopenharmony_ci 1258c2ecf20Sopenharmony_ci/***************************************************************************/ 1268c2ecf20Sopenharmony_ci 1278c2ecf20Sopenharmony_cistatic int __init init_BSP(void) 1288c2ecf20Sopenharmony_ci{ 1298c2ecf20Sopenharmony_ci m5272_uarts_init(); 1308c2ecf20Sopenharmony_ci fixed_phy_add(PHY_POLL, 0, &nettel_fixed_phy_status); 1318c2ecf20Sopenharmony_ci return 0; 1328c2ecf20Sopenharmony_ci} 1338c2ecf20Sopenharmony_ci 1348c2ecf20Sopenharmony_ciarch_initcall(init_BSP); 1358c2ecf20Sopenharmony_ci 1368c2ecf20Sopenharmony_ci/***************************************************************************/ 137