1 // SPDX-License-Identifier: GPL-2.0-only
2 /*
3  *  linux/arch/arm/mach-ep93xx/micro9.c
4  *
5  * Copyright (C) 2006 Contec Steuerungstechnik & Automation GmbH
6  *                    Manfred Gruber <m.gruber@tirol.com>
7  * Copyright (C) 2009 Contec Steuerungstechnik & Automation GmbH
8  *                    Hubert Feurstein <hubert.feurstein@contec.at>
9  */
10 
11 #include <linux/kernel.h>
12 #include <linux/init.h>
13 #include <linux/platform_device.h>
14 #include <linux/io.h>
15 
16 #include "hardware.h"
17 
18 #include <asm/mach-types.h>
19 #include <asm/mach/arch.h>
20 
21 #include "soc.h"
22 
23 /*************************************************************************
24  * Micro9 NOR Flash
25  *
26  * Micro9-High has up to 64MB of 32-bit flash on CS1
27  * Micro9-Mid has up to 64MB of either 32-bit or 16-bit flash on CS1
28  * Micro9-Lite uses a separate MTD map driver for flash support
29  * Micro9-Slim has up to 64MB of either 32-bit or 16-bit flash on CS1
30  *************************************************************************/
micro9_detect_bootwidth(void)31 static unsigned int __init micro9_detect_bootwidth(void)
32 {
33 	u32 v;
34 
35 	/* Detect the bus width of the external flash memory */
36 	v = __raw_readl(EP93XX_SYSCON_SYSCFG);
37 	if (v & EP93XX_SYSCON_SYSCFG_LCSN7)
38 		return 4; /* 32-bit */
39 	else
40 		return 2; /* 16-bit */
41 }
42 
micro9_register_flash(void)43 static void __init micro9_register_flash(void)
44 {
45 	unsigned int width;
46 
47 	if (machine_is_micro9())
48 		width = 4;
49 	else if (machine_is_micro9m() || machine_is_micro9s())
50 		width = micro9_detect_bootwidth();
51 	else
52 		width = 0;
53 
54 	if (width)
55 		ep93xx_register_flash(width, EP93XX_CS1_PHYS_BASE, SZ_64M);
56 }
57 
58 
59 /*************************************************************************
60  * Micro9 Ethernet
61  *************************************************************************/
62 static struct ep93xx_eth_data __initdata micro9_eth_data = {
63 	.phy_id		= 0x1f,
64 };
65 
66 
micro9_init_machine(void)67 static void __init micro9_init_machine(void)
68 {
69 	ep93xx_init_devices();
70 	ep93xx_register_eth(&micro9_eth_data, 1);
71 	micro9_register_flash();
72 }
73 
74 
75 #ifdef CONFIG_MACH_MICRO9H
76 MACHINE_START(MICRO9, "Contec Micro9-High")
77 	/* Maintainer: Hubert Feurstein <hubert.feurstein@contec.at> */
78 	.atag_offset	= 0x100,
79 	.map_io		= ep93xx_map_io,
80 	.init_irq	= ep93xx_init_irq,
81 	.init_time	= ep93xx_timer_init,
82 	.init_machine	= micro9_init_machine,
83 	.restart	= ep93xx_restart,
84 MACHINE_END
85 #endif
86 
87 #ifdef CONFIG_MACH_MICRO9M
88 MACHINE_START(MICRO9M, "Contec Micro9-Mid")
89 	/* Maintainer: Hubert Feurstein <hubert.feurstein@contec.at> */
90 	.atag_offset	= 0x100,
91 	.map_io		= ep93xx_map_io,
92 	.init_irq	= ep93xx_init_irq,
93 	.init_time	= ep93xx_timer_init,
94 	.init_machine	= micro9_init_machine,
95 	.restart	= ep93xx_restart,
96 MACHINE_END
97 #endif
98 
99 #ifdef CONFIG_MACH_MICRO9L
100 MACHINE_START(MICRO9L, "Contec Micro9-Lite")
101 	/* Maintainer: Hubert Feurstein <hubert.feurstein@contec.at> */
102 	.atag_offset	= 0x100,
103 	.map_io		= ep93xx_map_io,
104 	.init_irq	= ep93xx_init_irq,
105 	.init_time	= ep93xx_timer_init,
106 	.init_machine	= micro9_init_machine,
107 	.restart	= ep93xx_restart,
108 MACHINE_END
109 #endif
110 
111 #ifdef CONFIG_MACH_MICRO9S
112 MACHINE_START(MICRO9S, "Contec Micro9-Slim")
113 	/* Maintainer: Hubert Feurstein <hubert.feurstein@contec.at> */
114 	.atag_offset	= 0x100,
115 	.map_io		= ep93xx_map_io,
116 	.init_irq	= ep93xx_init_irq,
117 	.init_time	= ep93xx_timer_init,
118 	.init_machine	= micro9_init_machine,
119 	.restart	= ep93xx_restart,
120 MACHINE_END
121 #endif
122