1 // SPDX-License-Identifier: GPL-2.0
2 /***************************************************************************/
5 * m5249.c -- platform support for ColdFire 5249 based boards
10 /***************************************************************************/
12 #include <linux/clkdev.h>
13 #include <linux/kernel.h>
14 #include <linux/param.h>
15 #include <linux/init.h>
17 #include <linux/platform_device.h>
18 #include <asm/machdep.h>
19 #include <asm/coldfire.h>
20 #include <asm/mcfsim.h>
21 #include <asm/mcfclk.h>
23 /***************************************************************************/
25 DEFINE_CLK(pll, "pll.0", MCF_CLK);
26 DEFINE_CLK(sys, "sys.0", MCF_BUSCLK);
28 struct clk_lookup m5249_clk_lookup[] = {
29 CLKDEV_INIT(NULL, "pll.0", &clk_pll),
30 CLKDEV_INIT(NULL, "sys.0", &clk_sys),
31 CLKDEV_INIT("mcftmr.0", NULL, &clk_sys),
32 CLKDEV_INIT("mcftmr.1", NULL, &clk_sys),
33 CLKDEV_INIT("mcfuart.0", NULL, &clk_sys),
34 CLKDEV_INIT("mcfuart.1", NULL, &clk_sys),
35 CLKDEV_INIT("mcfqspi.0", NULL, &clk_sys),
36 CLKDEV_INIT("imx1-i2c.0", NULL, &clk_sys),
37 CLKDEV_INIT("imx1-i2c.1", NULL, &clk_sys),
40 /***************************************************************************/
44 static struct resource m5249_smc91x_resources[] = {
47 .end = 0xe0000300 + 0x100,
48 .flags = IORESOURCE_MEM,
51 .start = MCF_IRQ_GPIO6,
53 .flags = IORESOURCE_IRQ,
57 static struct platform_device m5249_smc91x = {
60 .num_resources = ARRAY_SIZE(m5249_smc91x_resources),
61 .resource = m5249_smc91x_resources,
64 #endif /* CONFIG_M5249C3 */
66 static struct platform_device *m5249_devices[] __initdata = {
72 /***************************************************************************/
74 static void __init m5249_qspi_init(void)
76 #if IS_ENABLED(CONFIG_SPI_COLDFIRE_QSPI)
78 writeb(MCFSIM_ICR_AUTOVEC | MCFSIM_ICR_LEVEL4 | MCFSIM_ICR_PRI0,
80 mcf_mapirq2imr(MCF_IRQ_QSPI, MCFINTC_QSPI);
81 #endif /* IS_ENABLED(CONFIG_SPI_COLDFIRE_QSPI) */
84 /***************************************************************************/
86 static void __init m5249_i2c_init(void)
88 #if IS_ENABLED(CONFIG_I2C_IMX)
91 /* first I2C controller uses regular irq setup */
92 writeb(MCFSIM_ICR_AUTOVEC | MCFSIM_ICR_LEVEL5 | MCFSIM_ICR_PRI0,
94 mcf_mapirq2imr(MCF_IRQ_I2C0, MCFINTC_I2C);
96 /* second I2C controller is completely different */
97 r = readl(MCFINTC2_INTPRI_REG(MCF_IRQ_I2C1));
98 r &= ~MCFINTC2_INTPRI_BITS(0xf, MCF_IRQ_I2C1);
99 r |= MCFINTC2_INTPRI_BITS(0x5, MCF_IRQ_I2C1);
100 writel(r, MCFINTC2_INTPRI_REG(MCF_IRQ_I2C1));
101 #endif /* CONFIG_I2C_IMX */
104 /***************************************************************************/
106 #ifdef CONFIG_M5249C3
108 static void __init m5249_smc91x_init(void)
112 /* Set the GPIO line as interrupt source for smc91x device */
113 gpio = readl(MCFSIM2_GPIOINTENABLE);
114 writel(gpio | 0x40, MCFSIM2_GPIOINTENABLE);
116 gpio = readl(MCFINTC2_INTPRI5);
117 writel(gpio | 0x04000000, MCFINTC2_INTPRI5);
120 #endif /* CONFIG_M5249C3 */
122 /***************************************************************************/
124 void __init config_BSP(char *commandp, int size)
126 mach_sched_init = hw_timer_init;
128 #ifdef CONFIG_M5249C3
134 clkdev_add_table(m5249_clk_lookup, ARRAY_SIZE(m5249_clk_lookup));
137 /***************************************************************************/
139 static int __init init_BSP(void)
141 platform_add_devices(m5249_devices, ARRAY_SIZE(m5249_devices));
145 arch_initcall(init_BSP);
147 /***************************************************************************/