1*b2441318SGreg Kroah-Hartman // SPDX-License-Identifier: GPL-2.0 2f86b9e03SGreg Ungerer /***************************************************************************/ 3f86b9e03SGreg Ungerer 4f86b9e03SGreg Ungerer /* 5ece9ae65SGreg Ungerer * m528x.c -- platform support for ColdFire 528x based boards 6f86b9e03SGreg Ungerer * 7f86b9e03SGreg Ungerer * Sub-architcture dependent initialization code for the Freescale 8f86b9e03SGreg Ungerer * 5280, 5281 and 5282 CPUs. 9f86b9e03SGreg Ungerer * 10f86b9e03SGreg Ungerer * Copyright (C) 1999-2003, Greg Ungerer (gerg@snapgear.com) 11f86b9e03SGreg Ungerer * Copyright (C) 2001-2003, SnapGear Inc. (www.snapgear.com) 12f86b9e03SGreg Ungerer */ 13f86b9e03SGreg Ungerer 14f86b9e03SGreg Ungerer /***************************************************************************/ 15f86b9e03SGreg Ungerer 16f86b9e03SGreg Ungerer #include <linux/kernel.h> 17f86b9e03SGreg Ungerer #include <linux/param.h> 18f86b9e03SGreg Ungerer #include <linux/init.h> 19f86b9e03SGreg Ungerer #include <linux/platform_device.h> 20f86b9e03SGreg Ungerer #include <linux/io.h> 21f86b9e03SGreg Ungerer #include <asm/machdep.h> 22f86b9e03SGreg Ungerer #include <asm/coldfire.h> 23f86b9e03SGreg Ungerer #include <asm/mcfsim.h> 24f86b9e03SGreg Ungerer #include <asm/mcfuart.h> 25f86b9e03SGreg Ungerer #include <asm/mcfclk.h> 26f86b9e03SGreg Ungerer 27f86b9e03SGreg Ungerer /***************************************************************************/ 28f86b9e03SGreg Ungerer 29f86b9e03SGreg Ungerer DEFINE_CLK(pll, "pll.0", MCF_CLK); 30f86b9e03SGreg Ungerer DEFINE_CLK(sys, "sys.0", MCF_BUSCLK); 31f86b9e03SGreg Ungerer DEFINE_CLK(mcfpit0, "mcfpit.0", MCF_CLK); 32f86b9e03SGreg Ungerer DEFINE_CLK(mcfpit1, "mcfpit.1", MCF_CLK); 33f86b9e03SGreg Ungerer DEFINE_CLK(mcfpit2, "mcfpit.2", MCF_CLK); 34f86b9e03SGreg Ungerer DEFINE_CLK(mcfpit3, "mcfpit.3", MCF_CLK); 35f86b9e03SGreg Ungerer DEFINE_CLK(mcfuart0, "mcfuart.0", MCF_BUSCLK); 36f86b9e03SGreg Ungerer DEFINE_CLK(mcfuart1, "mcfuart.1", MCF_BUSCLK); 37f86b9e03SGreg Ungerer DEFINE_CLK(mcfuart2, "mcfuart.2", MCF_BUSCLK); 38f86b9e03SGreg Ungerer DEFINE_CLK(mcfqspi0, "mcfqspi.0", MCF_BUSCLK); 39f86b9e03SGreg Ungerer DEFINE_CLK(fec0, "fec.0", MCF_BUSCLK); 402d24b532SSteven King DEFINE_CLK(mcfi2c0, "imx1-i2c.0", MCF_BUSCLK); 41f86b9e03SGreg Ungerer 42f86b9e03SGreg Ungerer struct clk *mcf_clks[] = { 43f86b9e03SGreg Ungerer &clk_pll, 44f86b9e03SGreg Ungerer &clk_sys, 45f86b9e03SGreg Ungerer &clk_mcfpit0, 46f86b9e03SGreg Ungerer &clk_mcfpit1, 47f86b9e03SGreg Ungerer &clk_mcfpit2, 48f86b9e03SGreg Ungerer &clk_mcfpit3, 49f86b9e03SGreg Ungerer &clk_mcfuart0, 50f86b9e03SGreg Ungerer &clk_mcfuart1, 51f86b9e03SGreg Ungerer &clk_mcfuart2, 52f86b9e03SGreg Ungerer &clk_mcfqspi0, 53f86b9e03SGreg Ungerer &clk_fec0, 542d24b532SSteven King &clk_mcfi2c0, 55f86b9e03SGreg Ungerer NULL 56f86b9e03SGreg Ungerer }; 57f86b9e03SGreg Ungerer 58f86b9e03SGreg Ungerer /***************************************************************************/ 59f86b9e03SGreg Ungerer 60f86b9e03SGreg Ungerer static void __init m528x_qspi_init(void) 61f86b9e03SGreg Ungerer { 62f86b9e03SGreg Ungerer #if IS_ENABLED(CONFIG_SPI_COLDFIRE_QSPI) 63f86b9e03SGreg Ungerer /* setup Port QS for QSPI with gpio CS control */ 64f86b9e03SGreg Ungerer __raw_writeb(0x07, MCFGPIO_PQSPAR); 65f86b9e03SGreg Ungerer #endif /* IS_ENABLED(CONFIG_SPI_COLDFIRE_QSPI) */ 66f86b9e03SGreg Ungerer } 67f86b9e03SGreg Ungerer 68f86b9e03SGreg Ungerer /***************************************************************************/ 69f86b9e03SGreg Ungerer 702d24b532SSteven King static void __init m528x_i2c_init(void) 712d24b532SSteven King { 722d24b532SSteven King #if IS_ENABLED(CONFIG_I2C_IMX) 732d24b532SSteven King u16 paspar; 742d24b532SSteven King 752d24b532SSteven King /* setup Port AS Pin Assignment Register for I2C */ 762d24b532SSteven King /* set PASPA0 to SCL and PASPA1 to SDA */ 772d24b532SSteven King paspar = readw(MCFGPIO_PASPAR); 782d24b532SSteven King paspar |= 0xF; 792d24b532SSteven King writew(paspar, MCFGPIO_PASPAR); 802d24b532SSteven King #endif /* IS_ENABLED(CONFIG_I2C_IMX) */ 812d24b532SSteven King } 822d24b532SSteven King 832d24b532SSteven King /***************************************************************************/ 842d24b532SSteven King 85f86b9e03SGreg Ungerer static void __init m528x_uarts_init(void) 86f86b9e03SGreg Ungerer { 87f86b9e03SGreg Ungerer u8 port; 88f86b9e03SGreg Ungerer 89f86b9e03SGreg Ungerer /* make sure PUAPAR is set for UART0 and UART1 */ 90f86b9e03SGreg Ungerer port = readb(MCFGPIO_PUAPAR); 91f86b9e03SGreg Ungerer port |= 0x03 | (0x03 << 2); 92f86b9e03SGreg Ungerer writeb(port, MCFGPIO_PUAPAR); 93f86b9e03SGreg Ungerer } 94f86b9e03SGreg Ungerer 95f86b9e03SGreg Ungerer /***************************************************************************/ 96f86b9e03SGreg Ungerer 97f86b9e03SGreg Ungerer static void __init m528x_fec_init(void) 98f86b9e03SGreg Ungerer { 99f86b9e03SGreg Ungerer u16 v16; 100f86b9e03SGreg Ungerer 101f86b9e03SGreg Ungerer /* Set multi-function pins to ethernet mode for fec0 */ 102f86b9e03SGreg Ungerer v16 = readw(MCFGPIO_PASPAR); 103f86b9e03SGreg Ungerer writew(v16 | 0xf00, MCFGPIO_PASPAR); 104f86b9e03SGreg Ungerer writeb(0xc0, MCFGPIO_PEHLPAR); 105f86b9e03SGreg Ungerer } 106f86b9e03SGreg Ungerer 107f86b9e03SGreg Ungerer /***************************************************************************/ 108f86b9e03SGreg Ungerer 109f86b9e03SGreg Ungerer #ifdef CONFIG_WILDFIRE 110f86b9e03SGreg Ungerer void wildfire_halt(void) 111f86b9e03SGreg Ungerer { 112f86b9e03SGreg Ungerer writeb(0, 0x30000007); 113f86b9e03SGreg Ungerer writeb(0x2, 0x30000007); 114f86b9e03SGreg Ungerer } 115f86b9e03SGreg Ungerer #endif 116f86b9e03SGreg Ungerer 117f86b9e03SGreg Ungerer #ifdef CONFIG_WILDFIREMOD 118f86b9e03SGreg Ungerer void wildfiremod_halt(void) 119f86b9e03SGreg Ungerer { 120f86b9e03SGreg Ungerer printk(KERN_INFO "WildFireMod hibernating...\n"); 121f86b9e03SGreg Ungerer 122f86b9e03SGreg Ungerer /* Set portE.5 to Digital IO */ 12341b39ea1SGreg Ungerer writew(readw(MCFGPIO_PEPAR) & ~(1 << (5 * 2)), MCFGPIO_PEPAR); 124f86b9e03SGreg Ungerer 125f86b9e03SGreg Ungerer /* Make portE.5 an output */ 12641b39ea1SGreg Ungerer writeb(readb(MCFGPIO_PDDR_E) | (1 << 5), MCFGPIO_PDDR_E); 127f86b9e03SGreg Ungerer 128f86b9e03SGreg Ungerer /* Now toggle portE.5 from low to high */ 12941b39ea1SGreg Ungerer writeb(readb(MCFGPIO_PODR_E) & ~(1 << 5), MCFGPIO_PODR_E); 13041b39ea1SGreg Ungerer writeb(readb(MCFGPIO_PODR_E) | (1 << 5), MCFGPIO_PODR_E); 131f86b9e03SGreg Ungerer 132f86b9e03SGreg Ungerer printk(KERN_EMERG "Failed to hibernate. Halting!\n"); 133f86b9e03SGreg Ungerer } 134f86b9e03SGreg Ungerer #endif 135f86b9e03SGreg Ungerer 136f86b9e03SGreg Ungerer void __init config_BSP(char *commandp, int size) 137f86b9e03SGreg Ungerer { 138f86b9e03SGreg Ungerer #ifdef CONFIG_WILDFIRE 139f86b9e03SGreg Ungerer mach_halt = wildfire_halt; 140f86b9e03SGreg Ungerer #endif 141f86b9e03SGreg Ungerer #ifdef CONFIG_WILDFIREMOD 142f86b9e03SGreg Ungerer mach_halt = wildfiremod_halt; 143f86b9e03SGreg Ungerer #endif 144f86b9e03SGreg Ungerer mach_sched_init = hw_timer_init; 145f86b9e03SGreg Ungerer m528x_uarts_init(); 146f86b9e03SGreg Ungerer m528x_fec_init(); 147f86b9e03SGreg Ungerer m528x_qspi_init(); 1482d24b532SSteven King m528x_i2c_init(); 149f86b9e03SGreg Ungerer } 150f86b9e03SGreg Ungerer 151f86b9e03SGreg Ungerer /***************************************************************************/ 152