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