1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
|
/*
* Copyright 2007-2008 Freescale Semiconductor, Inc. All Rights Reserved.
*/
/*
* The code contained herein is licensed under the GNU General Public
* License. You may obtain a copy of the GNU General Public License
* Version 2 or later at the following locations:
*
* http://www.opensource.org/licenses/gpl-license.html
* http://www.gnu.org/copyleft/gpl.html
*/
#include <linux/types.h>
#include <linux/sched.h>
#include <linux/delay.h>
#include <linux/interrupt.h>
#include <linux/irq.h>
#include <linux/init.h>
#include <linux/input.h>
#include <linux/nodemask.h>
#include <linux/clk.h>
#include <linux/platform_device.h>
#include <linux/spi/spi.h>
#if defined(CONFIG_MTD) || defined(CONFIG_MTD_MODULE)
#include <linux/mtd/mtd.h>
#include <linux/mtd/map.h>
#include <linux/mtd/partitions.h>
#include <asm/mach/flash.h>
#endif
#include <asm/hardware.h>
#include <asm/irq.h>
#include <asm/setup.h>
#include <asm/mach-types.h>
#include <asm/mach/arch.h>
#include <asm/mach/keypad.h>
#include <asm/arch/memory.h>
#include <asm/arch/gpio.h>
#include "board-mx37_3stack.h"
#include "iomux.h"
#include "crm_regs.h"
/*!
* @file mach-mx37/mx37_3stack.c
*
* @brief This file contains the board specific initialization routines.
*
* @ingroup MSL_MX37
*/
extern void mxc_map_io(void);
extern void mxc_init_irq(void);
extern void mxc_cpu_init(void) __init;
extern struct sys_timer mxc_timer;
extern void mxc_cpu_common_init(void);
extern int mxc_clocks_init(void);
extern void __init early_console_setup(char *);
static void mxc_nop_release(struct device *dev)
{
/* Nothing */
}
/* Get reference input clocks */
void board_ref_clk_rate(unsigned long *ckil, unsigned long *osc,
unsigned long *ckih)
{
*ckil = 32768;
*osc = 24000000;
*ckih = 22579200;
}
/* MTD NAND flash */
#if defined(CONFIG_MTD_NAND_MXC) || defined(CONFIG_MTD_NAND_MXC_MODULE) \
|| defined(CONFIG_MTD_NAND_MXC_V2) || defined(CONFIG_MTD_NAND_MXC_V2_MODULE) \
|| defined(CONFIG_MTD_NAND_MXC_V3)
static struct mtd_partition mxc_nand_partitions[] = {
{
.name = "bootloader",
.offset = 0,
.size = 2 * 1024 * 1024},
{
.name = "nand.kernel",
.offset = MTDPART_OFS_APPEND,
.size = 4 * 1024 * 1024},
{
.name = "nand.rootfs",
.offset = MTDPART_OFS_APPEND,
.size = 128 * 1024 * 1024},
{
.name = "nand.userfs1",
.offset = MTDPART_OFS_APPEND,
.size = 256 * 1024 * 1024},
{
.name = "nand.userfs2",
.offset = MTDPART_OFS_APPEND,
.size = 512 * 1024 * 1024},
{
.name = "nand.userfs3",
.offset = MTDPART_OFS_APPEND,
.size = 1024 * 1024 * 1024},
};
static struct flash_platform_data mxc_nand_data = {
.parts = mxc_nand_partitions,
.nr_parts = ARRAY_SIZE(mxc_nand_partitions),
.width = 1,
};
static struct platform_device mxc_nandv2_mtd_device = {
.name = "mxc_nandv2_flash",
.id = 0,
.dev = {
.release = mxc_nop_release,
.platform_data = &mxc_nand_data,
},
};
static void mxc_init_nand_mtd(void)
{
// if (__raw_readl(MXC_CCM_RCSR) & MXC_CCM_RCSR_NF16B) {
// mxc_nand_data.width = 2;
// }
(void)platform_device_register(&mxc_nandv2_mtd_device);
}
#else
static inline void mxc_init_nand_mtd(void)
{
}
#endif
static void lcd_reset(void)
{
static int first;
/* ensure that LCDIO(1.8V) has been turn on */
/* active reset line GPIO */
if (!first) {
mxc_request_iomux(MX37_PIN_GPIO1_5, IOMUX_CONFIG_GPIO);
first = 1;
}
mxc_set_gpio_dataout(MX37_PIN_GPIO1_5, 0);
mxc_set_gpio_direction(MX37_PIN_GPIO1_5, 0);
/* do reset */
msleep(10); /* tRES >= 100us */
mxc_set_gpio_dataout(MX37_PIN_GPIO1_5, 1);
msleep(60);
}
static struct mxc_lcd_platform_data lcd_data = {
.core_reg = "LDO1",
.io_reg = "DCDC6",
.reset = lcd_reset,
};
static struct spi_board_info mxc_spi_board_info[] __initdata = {
{
.modalias = "cpld_spi",
.max_speed_hz = 27000000,
.bus_num = 2,
.chip_select = 0,
},
{
.modalias = "lcd_spi",
.max_speed_hz = 5000000,
.bus_num = 2,
.platform_data = &lcd_data,
.chip_select = 1,},
};
#if defined(CONFIG_FB_MXC_SYNC_PANEL) || defined(CONFIG_FB_MXC_SYNC_PANEL_MODULE)
static struct platform_device mxc_fb_device[] = {
{
.name = "mxc_sdc_fb",
.id = 0,
.dev = {
.release = mxc_nop_release,
.coherent_dma_mask = 0xFFFFFFFF,
},
},
{
.name = "mxc_sdc_fb",
.id = 1,
.dev = {
.release = mxc_nop_release,
.coherent_dma_mask = 0xFFFFFFFF,
},
},
{
.name = "mxc_sdc_fb",
.id = 2,
.dev = {
.release = mxc_nop_release,
.coherent_dma_mask = 0xFFFFFFFF,
},
},
};
static void mxc_init_fb(void)
{
(void)platform_device_register(&mxc_fb_device[0]);
(void)platform_device_register(&mxc_fb_device[1]);
(void)platform_device_register(&mxc_fb_device[2]);
}
#else
static inline void mxc_init_fb(void)
{
}
#endif
/*lan9217 device*/
#if defined(CONFIG_SMSC911X) || defined(CONFIG_SMSC911X_MODULE)
static struct resource smsc911x_resources[] = {
{
.start = LAN9217_BASE_ADDR,
.end = LAN9217_BASE_ADDR + 255,
.flags = IORESOURCE_MEM,
},
{
.start = MXC_EXP_IO_BASE,
.flags = IORESOURCE_IRQ,
},
};
static struct platform_device smsc_lan9217_device = {
.name = "smsc911x",
.id = 0,
.dev = {
.release = mxc_nop_release,
},
.num_resources = ARRAY_SIZE(smsc911x_resources),
.resource = smsc911x_resources,
};
static int __init mxc_init_enet(void)
{
(void)platform_device_register(&smsc_lan9217_device);
return 0;
}
#else
static int __init mxc_init_enet(void)
{
return 0;
}
#endif
late_initcall(mxc_init_enet);
/*!
* Board specific fixup function. It is called by \b setup_arch() in
* setup.c file very early on during kernel starts. It allows the user to
* statically fill in the proper values for the passed-in parameters. None of
* the parameters is used currently.
*
* @param desc pointer to \b struct \b machine_desc
* @param tags pointer to \b struct \b tag
* @param cmdline pointer to the command line
* @param mi pointer to \b struct \b meminfo
*/
static void __init fixup_mxc_board(struct machine_desc *desc, struct tag *tags,
char **cmdline, struct meminfo *mi)
{
mxc_cpu_init();
#ifdef CONFIG_DISCONTIGMEM
do {
int nid;
mi->nr_banks = MXC_NUMNODES;
for (nid = 0; nid < mi->nr_banks; nid++) {
SET_NODE(mi, nid);
}
} while (0);
#endif
}
/*!
* Board specific initialization.
*/
static void __init mxc_board_init(void)
{
mxc_cpu_common_init();
mxc_clocks_init();
mxc_gpio_init();
early_console_setup(saved_command_line);
spi_register_board_info(mxc_spi_board_info,
ARRAY_SIZE(mxc_spi_board_info));
mxc_init_nand_mtd();
mxc_init_fb();
}
/*
* The following uses standard kernel macros define in arch.h in order to
* initialize __mach_desc_MX37_3STACK data structure.
*/
/* *INDENT-OFF* */
MACHINE_START(MX37_3DS, "Freescale MX37 3-Stack Board")
/* Maintainer: Freescale Semiconductor, Inc. */
.phys_io = AIPS1_BASE_ADDR,
.io_pg_offst = ((AIPS1_BASE_ADDR_VIRT) >> 18) & 0xfffc,
.boot_params = PHYS_OFFSET + 0x100,
.fixup = fixup_mxc_board,
.map_io = mxc_map_io,
.init_irq = mxc_init_irq,
.init_machine = mxc_board_init,
.timer = &mxc_timer,
MACHINE_END
|