xref: /openbmc/linux/arch/m68k/coldfire/amcore.c (revision a41cdd01)
1a41cdd01SAngelo Dureghello /*
2a41cdd01SAngelo Dureghello  * amcore.c -- Support for Sysam AMCORE open board
3a41cdd01SAngelo Dureghello  *
4a41cdd01SAngelo Dureghello  * (C) Copyright 2016, Angelo Dureghello <angelo@sysam.it>
5a41cdd01SAngelo Dureghello  *
6a41cdd01SAngelo Dureghello  * This file is subject to the terms and conditions of the GNU General Public
7a41cdd01SAngelo Dureghello  * License.  See the file COPYING in the main directory of this archive
8a41cdd01SAngelo Dureghello  * for more details.
9a41cdd01SAngelo Dureghello  */
10a41cdd01SAngelo Dureghello 
11a41cdd01SAngelo Dureghello #include <linux/device.h>
12a41cdd01SAngelo Dureghello #include <linux/platform_device.h>
13a41cdd01SAngelo Dureghello #include <linux/dm9000.h>
14a41cdd01SAngelo Dureghello #include <linux/irq.h>
15a41cdd01SAngelo Dureghello #include <linux/interrupt.h>
16a41cdd01SAngelo Dureghello #include <linux/mtd/mtd.h>
17a41cdd01SAngelo Dureghello #include <linux/mtd/map.h>
18a41cdd01SAngelo Dureghello #include <linux/mtd/partitions.h>
19a41cdd01SAngelo Dureghello #include <linux/mtd/physmap.h>
20a41cdd01SAngelo Dureghello #include <linux/i2c.h>
21a41cdd01SAngelo Dureghello 
22a41cdd01SAngelo Dureghello #include <asm/coldfire.h>
23a41cdd01SAngelo Dureghello #include <asm/mcfsim.h>
24a41cdd01SAngelo Dureghello #include <asm/io.h>
25a41cdd01SAngelo Dureghello 
26a41cdd01SAngelo Dureghello #if IS_ENABLED(CONFIG_DM9000)
27a41cdd01SAngelo Dureghello 
28a41cdd01SAngelo Dureghello #define DM9000_IRQ	25
29a41cdd01SAngelo Dureghello #define DM9000_ADDR	0x30000000
30a41cdd01SAngelo Dureghello 
31a41cdd01SAngelo Dureghello /*
32a41cdd01SAngelo Dureghello  * DEVICES and related device RESOURCES
33a41cdd01SAngelo Dureghello  */
34a41cdd01SAngelo Dureghello static struct resource dm9000_resources[] = {
35a41cdd01SAngelo Dureghello 	/* physical address of the address register (CMD [A2] to 0)*/
36a41cdd01SAngelo Dureghello 	[0] = {
37a41cdd01SAngelo Dureghello 		.start  = DM9000_ADDR,
38a41cdd01SAngelo Dureghello 		.end    = DM9000_ADDR,
39a41cdd01SAngelo Dureghello 		.flags  = IORESOURCE_MEM,
40a41cdd01SAngelo Dureghello 	},
41a41cdd01SAngelo Dureghello 	/*
42a41cdd01SAngelo Dureghello 	 * physical address of the data register (CMD [A2] to 1),
43a41cdd01SAngelo Dureghello 	 * driver wants a range >=4 to assume a 32bit data bus
44a41cdd01SAngelo Dureghello 	 */
45a41cdd01SAngelo Dureghello 	[1] = {
46a41cdd01SAngelo Dureghello 		.start  = DM9000_ADDR + 4,
47a41cdd01SAngelo Dureghello 		.end    = DM9000_ADDR + 7,
48a41cdd01SAngelo Dureghello 		.flags  = IORESOURCE_MEM,
49a41cdd01SAngelo Dureghello 	},
50a41cdd01SAngelo Dureghello 	/* IRQ line the device's interrupt pin is connected to */
51a41cdd01SAngelo Dureghello 	[2] = {
52a41cdd01SAngelo Dureghello 		.start  = DM9000_IRQ,
53a41cdd01SAngelo Dureghello 		.end    = DM9000_IRQ,
54a41cdd01SAngelo Dureghello 		.flags  = IORESOURCE_IRQ,
55a41cdd01SAngelo Dureghello 	},
56a41cdd01SAngelo Dureghello };
57a41cdd01SAngelo Dureghello 
58a41cdd01SAngelo Dureghello static struct dm9000_plat_data dm9000_platdata = {
59a41cdd01SAngelo Dureghello 	.flags		= DM9000_PLATF_32BITONLY,
60a41cdd01SAngelo Dureghello };
61a41cdd01SAngelo Dureghello 
62a41cdd01SAngelo Dureghello static struct platform_device dm9000_device = {
63a41cdd01SAngelo Dureghello 	.name           = "dm9000",
64a41cdd01SAngelo Dureghello 	.id             = 0,
65a41cdd01SAngelo Dureghello 	.num_resources  = ARRAY_SIZE(dm9000_resources),
66a41cdd01SAngelo Dureghello 	.resource       = dm9000_resources,
67a41cdd01SAngelo Dureghello 	.dev = {
68a41cdd01SAngelo Dureghello 		.platform_data = &dm9000_platdata,
69a41cdd01SAngelo Dureghello 	}
70a41cdd01SAngelo Dureghello };
71a41cdd01SAngelo Dureghello #endif
72a41cdd01SAngelo Dureghello 
dm9000_pre_init(void)73a41cdd01SAngelo Dureghello static void __init dm9000_pre_init(void)
74a41cdd01SAngelo Dureghello {
75a41cdd01SAngelo Dureghello 	/* Set the dm9000 interrupt to be auto-vectored */
76a41cdd01SAngelo Dureghello 	mcf_autovector(DM9000_IRQ);
77a41cdd01SAngelo Dureghello }
78a41cdd01SAngelo Dureghello 
79a41cdd01SAngelo Dureghello /*
80a41cdd01SAngelo Dureghello  * Partitioning of parallel NOR flash (39VF3201B)
81a41cdd01SAngelo Dureghello  */
82a41cdd01SAngelo Dureghello static struct mtd_partition amcore_partitions[] = {
83a41cdd01SAngelo Dureghello 	{
84a41cdd01SAngelo Dureghello 		.name	= "U-Boot (128K)",
85a41cdd01SAngelo Dureghello 		.size	= 0x20000,
86a41cdd01SAngelo Dureghello 		.offset	= 0x0
87a41cdd01SAngelo Dureghello 	},
88a41cdd01SAngelo Dureghello 	{
89a41cdd01SAngelo Dureghello 		.name	= "Kernel+ROMfs (2994K)",
90a41cdd01SAngelo Dureghello 		.size	= 0x2E0000,
91a41cdd01SAngelo Dureghello 		.offset	= MTDPART_OFS_APPEND
92a41cdd01SAngelo Dureghello 	},
93a41cdd01SAngelo Dureghello 	{
94a41cdd01SAngelo Dureghello 		.name	= "Flash Free Space (1024K)",
95a41cdd01SAngelo Dureghello 		.size	= MTDPART_SIZ_FULL,
96a41cdd01SAngelo Dureghello 		.offset	= MTDPART_OFS_APPEND
97a41cdd01SAngelo Dureghello 	}
98a41cdd01SAngelo Dureghello };
99a41cdd01SAngelo Dureghello 
100a41cdd01SAngelo Dureghello static struct physmap_flash_data flash_data = {
101a41cdd01SAngelo Dureghello 	.parts		= amcore_partitions,
102a41cdd01SAngelo Dureghello 	.nr_parts	= ARRAY_SIZE(amcore_partitions),
103a41cdd01SAngelo Dureghello 	.width		= 2,
104a41cdd01SAngelo Dureghello };
105a41cdd01SAngelo Dureghello 
106a41cdd01SAngelo Dureghello static struct resource flash_resource = {
107a41cdd01SAngelo Dureghello 	.start		= 0xffc00000,
108a41cdd01SAngelo Dureghello 	.end		= 0xffffffff,
109a41cdd01SAngelo Dureghello 	.flags		= IORESOURCE_MEM,
110a41cdd01SAngelo Dureghello };
111a41cdd01SAngelo Dureghello 
112a41cdd01SAngelo Dureghello static struct platform_device flash_device = {
113a41cdd01SAngelo Dureghello 	.name		= "physmap-flash",
114a41cdd01SAngelo Dureghello 	.id		= -1,
115a41cdd01SAngelo Dureghello 	.resource	= &flash_resource,
116a41cdd01SAngelo Dureghello 	.num_resources	= 1,
117a41cdd01SAngelo Dureghello 	.dev		= {
118a41cdd01SAngelo Dureghello 		.platform_data	= &flash_data,
119a41cdd01SAngelo Dureghello 	},
120a41cdd01SAngelo Dureghello };
121a41cdd01SAngelo Dureghello 
122a41cdd01SAngelo Dureghello static struct platform_device rtc_device = {
123a41cdd01SAngelo Dureghello 	.name	= "rtc-ds1307",
124a41cdd01SAngelo Dureghello 	.id	= -1,
125a41cdd01SAngelo Dureghello };
126a41cdd01SAngelo Dureghello 
127a41cdd01SAngelo Dureghello static struct i2c_board_info amcore_i2c_info[] __initdata = {
128a41cdd01SAngelo Dureghello 	{
129a41cdd01SAngelo Dureghello 		I2C_BOARD_INFO("ds1338", 0x68),
130a41cdd01SAngelo Dureghello 	},
131a41cdd01SAngelo Dureghello };
132a41cdd01SAngelo Dureghello 
133a41cdd01SAngelo Dureghello static struct platform_device *amcore_devices[] __initdata = {
134a41cdd01SAngelo Dureghello #if IS_ENABLED(CONFIG_DM9000)
135a41cdd01SAngelo Dureghello 	&dm9000_device,
136a41cdd01SAngelo Dureghello #endif
137a41cdd01SAngelo Dureghello 	&flash_device,
138a41cdd01SAngelo Dureghello 	&rtc_device,
139a41cdd01SAngelo Dureghello };
140a41cdd01SAngelo Dureghello 
init_amcore(void)141a41cdd01SAngelo Dureghello static int __init init_amcore(void)
142a41cdd01SAngelo Dureghello {
143a41cdd01SAngelo Dureghello #if IS_ENABLED(CONFIG_DM9000)
144a41cdd01SAngelo Dureghello 	dm9000_pre_init();
145a41cdd01SAngelo Dureghello #endif
146a41cdd01SAngelo Dureghello 
147a41cdd01SAngelo Dureghello 	/* Add i2c RTC Dallas chip supprt */
148a41cdd01SAngelo Dureghello 	i2c_register_board_info(0, amcore_i2c_info,
149a41cdd01SAngelo Dureghello 				ARRAY_SIZE(amcore_i2c_info));
150a41cdd01SAngelo Dureghello 
151a41cdd01SAngelo Dureghello 	platform_add_devices(amcore_devices, ARRAY_SIZE(amcore_devices));
152a41cdd01SAngelo Dureghello 
153a41cdd01SAngelo Dureghello 	return 0;
154a41cdd01SAngelo Dureghello }
155a41cdd01SAngelo Dureghello 
156a41cdd01SAngelo Dureghello arch_initcall(init_amcore);
157