blob: 0590f8c421f194fc1acf105fcba13e3241433263 [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001// SPDX-License-Identifier: GPL-2.0
Linus Torvalds1da177e2005-04-16 15:20:36 -07002/***************************************************************************/
3
4/*
Greg Ungererece9ae62014-08-19 11:55:24 +10005 * m5249.c -- platform support for ColdFire 5249 based boards
Linus Torvalds1da177e2005-04-16 15:20:36 -07006 *
7 * Copyright (C) 2002, Greg Ungerer (gerg@snapgear.com)
8 */
9
10/***************************************************************************/
11
Linus Torvalds1da177e2005-04-16 15:20:36 -070012#include <linux/kernel.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070013#include <linux/param.h>
14#include <linux/init.h>
Greg Ungerer5f84bd52008-02-01 17:34:30 +100015#include <linux/io.h>
Greg Ungererfa1fc242011-12-24 12:56:10 +100016#include <linux/platform_device.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070017#include <asm/machdep.h>
18#include <asm/coldfire.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070019#include <asm/mcfsim.h>
Greg Ungereree1e6b32012-07-13 15:58:41 +100020#include <asm/mcfclk.h>
21
22/***************************************************************************/
23
24DEFINE_CLK(pll, "pll.0", MCF_CLK);
25DEFINE_CLK(sys, "sys.0", MCF_BUSCLK);
26DEFINE_CLK(mcftmr0, "mcftmr.0", MCF_BUSCLK);
27DEFINE_CLK(mcftmr1, "mcftmr.1", MCF_BUSCLK);
28DEFINE_CLK(mcfuart0, "mcfuart.0", MCF_BUSCLK);
29DEFINE_CLK(mcfuart1, "mcfuart.1", MCF_BUSCLK);
Steven King74859522014-05-14 10:06:29 -070030DEFINE_CLK(mcfqspi0, "mcfqspi.0", MCF_BUSCLK);
Steven King2d24b532014-06-30 09:53:19 -070031DEFINE_CLK(mcfi2c0, "imx1-i2c.0", MCF_BUSCLK);
32DEFINE_CLK(mcfi2c1, "imx1-i2c.1", MCF_BUSCLK);
Greg Ungereree1e6b32012-07-13 15:58:41 +100033
34struct clk *mcf_clks[] = {
35 &clk_pll,
36 &clk_sys,
37 &clk_mcftmr0,
38 &clk_mcftmr1,
39 &clk_mcfuart0,
40 &clk_mcfuart1,
Steven King74859522014-05-14 10:06:29 -070041 &clk_mcfqspi0,
Steven King2d24b532014-06-30 09:53:19 -070042 &clk_mcfi2c0,
43 &clk_mcfi2c1,
Greg Ungereree1e6b32012-07-13 15:58:41 +100044 NULL
45};
Linus Torvalds1da177e2005-04-16 15:20:36 -070046
47/***************************************************************************/
48
Greg Ungerer4a1479b2009-06-12 16:17:20 +100049#ifdef CONFIG_M5249C3
50
51static struct resource m5249_smc91x_resources[] = {
52 {
53 .start = 0xe0000300,
54 .end = 0xe0000300 + 0x100,
55 .flags = IORESOURCE_MEM,
56 },
57 {
Greg Ungerer5a4acf32012-09-19 13:52:12 +100058 .start = MCF_IRQ_GPIO6,
59 .end = MCF_IRQ_GPIO6,
Greg Ungerer4a1479b2009-06-12 16:17:20 +100060 .flags = IORESOURCE_IRQ,
61 },
62};
63
64static struct platform_device m5249_smc91x = {
65 .name = "smc91x",
66 .id = 0,
67 .num_resources = ARRAY_SIZE(m5249_smc91x_resources),
68 .resource = m5249_smc91x_resources,
69};
70
71#endif /* CONFIG_M5249C3 */
72
Greg Ungererfa1fc242011-12-24 12:56:10 +100073static struct platform_device *m5249_devices[] __initdata = {
74#ifdef CONFIG_M5249C3
75 &m5249_smc91x,
76#endif
Steven King91d60412010-01-22 12:43:03 -080077};
78
Greg Ungererfa1fc242011-12-24 12:56:10 +100079/***************************************************************************/
Steven King91d60412010-01-22 12:43:03 -080080
Steven King91d60412010-01-22 12:43:03 -080081static void __init m5249_qspi_init(void)
82{
Steven King151d14f2014-05-14 10:07:55 -070083#if IS_ENABLED(CONFIG_SPI_COLDFIRE_QSPI)
Steven King91d60412010-01-22 12:43:03 -080084 /* QSPI irq setup */
85 writeb(MCFSIM_ICR_AUTOVEC | MCFSIM_ICR_LEVEL4 | MCFSIM_ICR_PRI0,
Greg Ungererc986a3d2012-08-17 16:48:16 +100086 MCFSIM_QSPIICR);
Steven King91d60412010-01-22 12:43:03 -080087 mcf_mapirq2imr(MCF_IRQ_QSPI, MCFINTC_QSPI);
Steven King83ca6002012-05-06 12:22:53 -070088#endif /* IS_ENABLED(CONFIG_SPI_COLDFIRE_QSPI) */
Steven King151d14f2014-05-14 10:07:55 -070089}
Greg Ungerer5f84bd52008-02-01 17:34:30 +100090
91/***************************************************************************/
92
Steven King2d24b532014-06-30 09:53:19 -070093static void __init m5249_i2c_init(void)
94{
95#if IS_ENABLED(CONFIG_I2C_IMX)
96 u32 r;
97
98 /* first I2C controller uses regular irq setup */
99 writeb(MCFSIM_ICR_AUTOVEC | MCFSIM_ICR_LEVEL5 | MCFSIM_ICR_PRI0,
100 MCFSIM_I2CICR);
101 mcf_mapirq2imr(MCF_IRQ_I2C0, MCFINTC_I2C);
102
103 /* second I2C controller is completely different */
104 r = readl(MCFINTC2_INTPRI_REG(MCF_IRQ_I2C1));
105 r &= ~MCFINTC2_INTPRI_BITS(0xf, MCF_IRQ_I2C1);
106 r |= MCFINTC2_INTPRI_BITS(0x5, MCF_IRQ_I2C1);
107 writel(r, MCFINTC2_INTPRI_REG(MCF_IRQ_I2C1));
108#endif /* CONFIG_I2C_IMX */
109}
110
111/***************************************************************************/
112
Greg Ungerer4a1479b2009-06-12 16:17:20 +1000113#ifdef CONFIG_M5249C3
114
115static void __init m5249_smc91x_init(void)
116{
117 u32 gpio;
118
119 /* Set the GPIO line as interrupt source for smc91x device */
Greg Ungerer041a89a2012-09-14 23:57:39 +1000120 gpio = readl(MCFSIM2_GPIOINTENABLE);
121 writel(gpio | 0x40, MCFSIM2_GPIOINTENABLE);
Greg Ungerer4a1479b2009-06-12 16:17:20 +1000122
Greg Ungerer5a4acf32012-09-19 13:52:12 +1000123 gpio = readl(MCFINTC2_INTPRI5);
124 writel(gpio | 0x04000000, MCFINTC2_INTPRI5);
Greg Ungerer4a1479b2009-06-12 16:17:20 +1000125}
126
127#endif /* CONFIG_M5249C3 */
128
129/***************************************************************************/
130
Greg Ungerer5f84bd52008-02-01 17:34:30 +1000131void __init config_BSP(char *commandp, int size)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700132{
Greg Ungerer35aefb22012-01-23 15:34:58 +1000133 mach_sched_init = hw_timer_init;
Greg Ungererd894b892012-02-19 16:16:58 +1000134
Greg Ungerer4a1479b2009-06-12 16:17:20 +1000135#ifdef CONFIG_M5249C3
136 m5249_smc91x_init();
137#endif
Steven King91d60412010-01-22 12:43:03 -0800138 m5249_qspi_init();
Steven King2d24b532014-06-30 09:53:19 -0700139 m5249_i2c_init();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700140}
141
142/***************************************************************************/
Greg Ungerer5f84bd52008-02-01 17:34:30 +1000143
144static int __init init_BSP(void)
145{
Greg Ungerer5f84bd52008-02-01 17:34:30 +1000146 platform_add_devices(m5249_devices, ARRAY_SIZE(m5249_devices));
147 return 0;
148}
149
150arch_initcall(init_BSP);
151
152/***************************************************************************/