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); 39f86b9e03SGreg Ungerer 40f86b9e03SGreg Ungerer struct clk *mcf_clks[] = { 41f86b9e03SGreg Ungerer &clk_pll, 42f86b9e03SGreg Ungerer &clk_sys, 43f86b9e03SGreg Ungerer &clk_mcfpit0, 44f86b9e03SGreg Ungerer &clk_mcfpit1, 45f86b9e03SGreg Ungerer &clk_mcfpit2, 46f86b9e03SGreg Ungerer &clk_mcfpit3, 47f86b9e03SGreg Ungerer &clk_mcfuart0, 48f86b9e03SGreg Ungerer &clk_mcfuart1, 49f86b9e03SGreg Ungerer &clk_mcfuart2, 50f86b9e03SGreg Ungerer &clk_mcfqspi0, 51f86b9e03SGreg Ungerer &clk_fec0, 52f86b9e03SGreg Ungerer NULL 53f86b9e03SGreg Ungerer }; 54f86b9e03SGreg Ungerer 55f86b9e03SGreg Ungerer /***************************************************************************/ 56f86b9e03SGreg Ungerer 57f86b9e03SGreg Ungerer static void __init m528x_qspi_init(void) 58f86b9e03SGreg Ungerer { 59f86b9e03SGreg Ungerer #if IS_ENABLED(CONFIG_SPI_COLDFIRE_QSPI) 60f86b9e03SGreg Ungerer /* setup Port QS for QSPI with gpio CS control */ 61f86b9e03SGreg Ungerer __raw_writeb(0x07, MCFGPIO_PQSPAR); 62f86b9e03SGreg Ungerer #endif /* IS_ENABLED(CONFIG_SPI_COLDFIRE_QSPI) */ 63f86b9e03SGreg Ungerer } 64f86b9e03SGreg Ungerer 65f86b9e03SGreg Ungerer /***************************************************************************/ 66f86b9e03SGreg Ungerer 67f86b9e03SGreg Ungerer static void __init m528x_uarts_init(void) 68f86b9e03SGreg Ungerer { 69f86b9e03SGreg Ungerer u8 port; 70f86b9e03SGreg Ungerer 71f86b9e03SGreg Ungerer /* make sure PUAPAR is set for UART0 and UART1 */ 72f86b9e03SGreg Ungerer port = readb(MCFGPIO_PUAPAR); 73f86b9e03SGreg Ungerer port |= 0x03 | (0x03 << 2); 74f86b9e03SGreg Ungerer writeb(port, MCFGPIO_PUAPAR); 75f86b9e03SGreg Ungerer } 76f86b9e03SGreg Ungerer 77f86b9e03SGreg Ungerer /***************************************************************************/ 78f86b9e03SGreg Ungerer 79f86b9e03SGreg Ungerer static void __init m528x_fec_init(void) 80f86b9e03SGreg Ungerer { 81f86b9e03SGreg Ungerer u16 v16; 82f86b9e03SGreg Ungerer 83f86b9e03SGreg Ungerer /* Set multi-function pins to ethernet mode for fec0 */ 84f86b9e03SGreg Ungerer v16 = readw(MCFGPIO_PASPAR); 85f86b9e03SGreg Ungerer writew(v16 | 0xf00, MCFGPIO_PASPAR); 86f86b9e03SGreg Ungerer writeb(0xc0, MCFGPIO_PEHLPAR); 87f86b9e03SGreg Ungerer } 88f86b9e03SGreg Ungerer 89f86b9e03SGreg Ungerer /***************************************************************************/ 90f86b9e03SGreg Ungerer 91f86b9e03SGreg Ungerer #ifdef CONFIG_WILDFIRE 92f86b9e03SGreg Ungerer void wildfire_halt(void) 93f86b9e03SGreg Ungerer { 94f86b9e03SGreg Ungerer writeb(0, 0x30000007); 95f86b9e03SGreg Ungerer writeb(0x2, 0x30000007); 96f86b9e03SGreg Ungerer } 97f86b9e03SGreg Ungerer #endif 98f86b9e03SGreg Ungerer 99f86b9e03SGreg Ungerer #ifdef CONFIG_WILDFIREMOD 100f86b9e03SGreg Ungerer void wildfiremod_halt(void) 101f86b9e03SGreg Ungerer { 102f86b9e03SGreg Ungerer printk(KERN_INFO "WildFireMod hibernating...\n"); 103f86b9e03SGreg Ungerer 104f86b9e03SGreg Ungerer /* Set portE.5 to Digital IO */ 105*41b39ea1SGreg Ungerer writew(readw(MCFGPIO_PEPAR) & ~(1 << (5 * 2)), MCFGPIO_PEPAR); 106f86b9e03SGreg Ungerer 107f86b9e03SGreg Ungerer /* Make portE.5 an output */ 108*41b39ea1SGreg Ungerer writeb(readb(MCFGPIO_PDDR_E) | (1 << 5), MCFGPIO_PDDR_E); 109f86b9e03SGreg Ungerer 110f86b9e03SGreg Ungerer /* Now toggle portE.5 from low to high */ 111*41b39ea1SGreg Ungerer writeb(readb(MCFGPIO_PODR_E) & ~(1 << 5), MCFGPIO_PODR_E); 112*41b39ea1SGreg Ungerer writeb(readb(MCFGPIO_PODR_E) | (1 << 5), MCFGPIO_PODR_E); 113f86b9e03SGreg Ungerer 114f86b9e03SGreg Ungerer printk(KERN_EMERG "Failed to hibernate. Halting!\n"); 115f86b9e03SGreg Ungerer } 116f86b9e03SGreg Ungerer #endif 117f86b9e03SGreg Ungerer 118f86b9e03SGreg Ungerer void __init config_BSP(char *commandp, int size) 119f86b9e03SGreg Ungerer { 120f86b9e03SGreg Ungerer #ifdef CONFIG_WILDFIRE 121f86b9e03SGreg Ungerer mach_halt = wildfire_halt; 122f86b9e03SGreg Ungerer #endif 123f86b9e03SGreg Ungerer #ifdef CONFIG_WILDFIREMOD 124f86b9e03SGreg Ungerer mach_halt = wildfiremod_halt; 125f86b9e03SGreg Ungerer #endif 126f86b9e03SGreg Ungerer mach_sched_init = hw_timer_init; 127f86b9e03SGreg Ungerer m528x_uarts_init(); 128f86b9e03SGreg Ungerer m528x_fec_init(); 129f86b9e03SGreg Ungerer m528x_qspi_init(); 130f86b9e03SGreg Ungerer } 131f86b9e03SGreg Ungerer 132f86b9e03SGreg Ungerer /***************************************************************************/ 133