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