]>
Commit | Line | Data |
---|---|---|
1dbae815 | 1 | /* |
f30c2269 | 2 | * linux/arch/arm/mach-omap2/board-h4.c |
1dbae815 TL |
3 | * |
4 | * Copyright (C) 2005 Nokia Corporation | |
5 | * Author: Paul Mundt <paul.mundt@nokia.com> | |
6 | * | |
7 | * Modified from mach-omap/omap1/board-generic.c | |
8 | * | |
9 | * This program is free software; you can redistribute it and/or modify | |
10 | * it under the terms of the GNU General Public License version 2 as | |
11 | * published by the Free Software Foundation. | |
12 | */ | |
2f8163ba | 13 | #include <linux/gpio.h> |
1dbae815 TL |
14 | #include <linux/kernel.h> |
15 | #include <linux/init.h> | |
16 | #include <linux/platform_device.h> | |
17 | #include <linux/mtd/mtd.h> | |
18 | #include <linux/mtd/partitions.h> | |
561b036a | 19 | #include <linux/mtd/physmap.h> |
1dbae815 | 20 | #include <linux/delay.h> |
9b6553cd | 21 | #include <linux/workqueue.h> |
9df013b3 | 22 | #include <linux/i2c.h> |
6a769ed4 | 23 | #include <linux/i2c/at24.h> |
9b6553cd | 24 | #include <linux/input.h> |
44595982 PW |
25 | #include <linux/err.h> |
26 | #include <linux/clk.h> | |
fced80c7 | 27 | #include <linux/io.h> |
41eb2d81 | 28 | #include <linux/input/matrix_keypad.h> |
1dbae815 | 29 | |
a09e64fb | 30 | #include <mach/hardware.h> |
1dbae815 TL |
31 | #include <asm/mach-types.h> |
32 | #include <asm/mach/arch.h> | |
33 | #include <asm/mach/map.h> | |
1dbae815 | 34 | |
ce491cf8 TL |
35 | #include <plat/usb.h> |
36 | #include <plat/board.h> | |
4e65331c | 37 | #include "common.h" |
ce491cf8 TL |
38 | #include <plat/menelaus.h> |
39 | #include <plat/dma.h> | |
40 | #include <plat/gpmc.h> | |
1dbae815 | 41 | |
cbf1455b TV |
42 | #include <video/omapdss.h> |
43 | #include <video/omap-panel-generic-dpi.h> | |
44 | ||
23275d45 | 45 | #include "mux.h" |
4814ced5 | 46 | #include "control.h" |
23275d45 | 47 | |
44595982 PW |
48 | #define H4_FLASH_CS 0 |
49 | #define H4_SMC91X_CS 1 | |
50 | ||
40662d77 TL |
51 | #define H4_ETHR_GPIO_IRQ 92 |
52 | ||
41eb2d81 TL |
53 | #if defined(CONFIG_KEYBOARD_MATRIX) || defined(CONFIG_KEYBOARD_MATRIX_MODULE) |
54 | static const uint32_t board_matrix_keys[] = { | |
9b6553cd | 55 | KEY(0, 0, KEY_LEFT), |
da1f026b JK |
56 | KEY(1, 0, KEY_RIGHT), |
57 | KEY(2, 0, KEY_A), | |
58 | KEY(3, 0, KEY_B), | |
59 | KEY(4, 0, KEY_C), | |
60 | KEY(0, 1, KEY_DOWN), | |
9b6553cd | 61 | KEY(1, 1, KEY_UP), |
da1f026b JK |
62 | KEY(2, 1, KEY_E), |
63 | KEY(3, 1, KEY_F), | |
64 | KEY(4, 1, KEY_G), | |
65 | KEY(0, 2, KEY_ENTER), | |
66 | KEY(1, 2, KEY_I), | |
9b6553cd | 67 | KEY(2, 2, KEY_J), |
da1f026b JK |
68 | KEY(3, 2, KEY_K), |
69 | KEY(4, 2, KEY_3), | |
70 | KEY(0, 3, KEY_M), | |
71 | KEY(1, 3, KEY_N), | |
72 | KEY(2, 3, KEY_O), | |
9b6553cd | 73 | KEY(3, 3, KEY_P), |
da1f026b JK |
74 | KEY(4, 3, KEY_Q), |
75 | KEY(0, 4, KEY_R), | |
76 | KEY(1, 4, KEY_4), | |
77 | KEY(2, 4, KEY_T), | |
78 | KEY(3, 4, KEY_U), | |
9b6553cd | 79 | KEY(4, 4, KEY_ENTER), |
da1f026b JK |
80 | KEY(0, 5, KEY_V), |
81 | KEY(1, 5, KEY_W), | |
82 | KEY(2, 5, KEY_L), | |
83 | KEY(3, 5, KEY_S), | |
84 | KEY(4, 5, KEY_ENTER), | |
9b6553cd TL |
85 | }; |
86 | ||
41eb2d81 TL |
87 | static const struct matrix_keymap_data board_keymap_data = { |
88 | .keymap = board_matrix_keys, | |
89 | .keymap_size = ARRAY_SIZE(board_matrix_keys), | |
90 | }; | |
91 | ||
92 | static unsigned int board_keypad_row_gpios[] = { | |
93 | 88, 89, 124, 11, 6, 96 | |
94 | }; | |
95 | ||
96 | static unsigned int board_keypad_col_gpios[] = { | |
97 | 90, 91, 100, 36, 12, 97, 98 | |
98 | }; | |
99 | ||
100 | static struct matrix_keypad_platform_data board_keypad_platform_data = { | |
101 | .keymap_data = &board_keymap_data, | |
102 | .row_gpios = board_keypad_row_gpios, | |
103 | .num_row_gpios = ARRAY_SIZE(board_keypad_row_gpios), | |
104 | .col_gpios = board_keypad_col_gpios, | |
105 | .num_col_gpios = ARRAY_SIZE(board_keypad_col_gpios), | |
106 | .active_low = 1, | |
107 | ||
108 | .debounce_ms = 20, | |
109 | .col_scan_delay_us = 5, | |
110 | }; | |
111 | ||
112 | static struct platform_device board_keyboard = { | |
113 | .name = "matrix-keypad", | |
114 | .id = -1, | |
115 | .dev = { | |
116 | .platform_data = &board_keypad_platform_data, | |
117 | }, | |
118 | }; | |
119 | static void __init board_mkp_init(void) | |
120 | { | |
121 | omap_mux_init_gpio(88, OMAP_PULL_ENA | OMAP_PULL_UP); | |
122 | omap_mux_init_gpio(89, OMAP_PULL_ENA | OMAP_PULL_UP); | |
123 | omap_mux_init_gpio(124, OMAP_PULL_ENA | OMAP_PULL_UP); | |
124 | omap_mux_init_signal("mcbsp2_dr.gpio_11", OMAP_PULL_ENA | OMAP_PULL_UP); | |
125 | if (omap_has_menelaus()) { | |
126 | omap_mux_init_signal("sdrc_a14.gpio0", | |
127 | OMAP_PULL_ENA | OMAP_PULL_UP); | |
128 | omap_mux_init_signal("vlynq_rx0.gpio_15", 0); | |
129 | omap_mux_init_signal("gpio_98", 0); | |
130 | board_keypad_row_gpios[5] = 0; | |
131 | board_keypad_col_gpios[2] = 15; | |
132 | board_keypad_col_gpios[6] = 18; | |
133 | } else { | |
134 | omap_mux_init_signal("gpio_96", OMAP_PULL_ENA | OMAP_PULL_UP); | |
135 | omap_mux_init_signal("gpio_100", 0); | |
136 | omap_mux_init_signal("gpio_98", 0); | |
137 | } | |
138 | omap_mux_init_signal("gpio_90", 0); | |
139 | omap_mux_init_signal("gpio_91", 0); | |
140 | omap_mux_init_signal("gpio_36", 0); | |
141 | omap_mux_init_signal("mcbsp2_clkx.gpio_12", 0); | |
142 | omap_mux_init_signal("gpio_97", 0); | |
143 | ||
144 | platform_device_register(&board_keyboard); | |
145 | } | |
146 | #else | |
147 | static inline void board_mkp_init(void) | |
148 | { | |
149 | } | |
150 | #endif | |
151 | ||
1dbae815 TL |
152 | static struct mtd_partition h4_partitions[] = { |
153 | /* bootloader (U-Boot, etc) in first sector */ | |
154 | { | |
155 | .name = "bootloader", | |
156 | .offset = 0, | |
157 | .size = SZ_128K, | |
158 | .mask_flags = MTD_WRITEABLE, /* force read-only */ | |
159 | }, | |
160 | /* bootloader params in the next sector */ | |
161 | { | |
162 | .name = "params", | |
163 | .offset = MTDPART_OFS_APPEND, | |
164 | .size = SZ_128K, | |
165 | .mask_flags = 0, | |
166 | }, | |
167 | /* kernel */ | |
168 | { | |
169 | .name = "kernel", | |
170 | .offset = MTDPART_OFS_APPEND, | |
171 | .size = SZ_2M, | |
172 | .mask_flags = 0 | |
173 | }, | |
174 | /* file system */ | |
175 | { | |
176 | .name = "filesystem", | |
177 | .offset = MTDPART_OFS_APPEND, | |
178 | .size = MTDPART_SIZ_FULL, | |
179 | .mask_flags = 0 | |
180 | } | |
181 | }; | |
182 | ||
561b036a | 183 | static struct physmap_flash_data h4_flash_data = { |
1dbae815 TL |
184 | .width = 2, |
185 | .parts = h4_partitions, | |
186 | .nr_parts = ARRAY_SIZE(h4_partitions), | |
187 | }; | |
188 | ||
189 | static struct resource h4_flash_resource = { | |
1dbae815 TL |
190 | .flags = IORESOURCE_MEM, |
191 | }; | |
192 | ||
193 | static struct platform_device h4_flash_device = { | |
561b036a | 194 | .name = "physmap-flash", |
1dbae815 TL |
195 | .id = 0, |
196 | .dev = { | |
197 | .platform_data = &h4_flash_data, | |
198 | }, | |
199 | .num_resources = 1, | |
200 | .resource = &h4_flash_resource, | |
201 | }; | |
202 | ||
1dbae815 | 203 | static struct platform_device *h4_devices[] __initdata = { |
1dbae815 | 204 | &h4_flash_device, |
cbf1455b TV |
205 | }; |
206 | ||
207 | static struct panel_generic_dpi_data h4_panel_data = { | |
208 | .name = "h4", | |
209 | }; | |
210 | ||
211 | static struct omap_dss_device h4_lcd_device = { | |
212 | .name = "lcd", | |
213 | .driver_name = "generic_dpi_panel", | |
214 | .type = OMAP_DISPLAY_TYPE_DPI, | |
215 | .phy.dpi.data_lines = 16, | |
216 | .data = &h4_panel_data, | |
217 | }; | |
218 | ||
219 | static struct omap_dss_device *h4_dss_devices[] = { | |
9b6553cd | 220 | &h4_lcd_device, |
1dbae815 TL |
221 | }; |
222 | ||
cbf1455b TV |
223 | static struct omap_dss_board_info h4_dss_data = { |
224 | .num_devices = ARRAY_SIZE(h4_dss_devices), | |
225 | .devices = h4_dss_devices, | |
226 | .default_device = &h4_lcd_device, | |
227 | }; | |
228 | ||
44595982 PW |
229 | /* 2420 Sysboot setup (2430 is different) */ |
230 | static u32 get_sysboot_value(void) | |
231 | { | |
232 | return (omap_ctrl_readl(OMAP24XX_CONTROL_STATUS) & | |
233 | (OMAP2_SYSBOOT_5_MASK | OMAP2_SYSBOOT_4_MASK | | |
234 | OMAP2_SYSBOOT_3_MASK | OMAP2_SYSBOOT_2_MASK | | |
235 | OMAP2_SYSBOOT_1_MASK | OMAP2_SYSBOOT_0_MASK)); | |
236 | } | |
237 | ||
238 | /* H4-2420's always used muxed mode, H4-2422's always use non-muxed | |
239 | * | |
240 | * Note: OMAP-GIT doesn't correctly do is_cpu_omap2422 and is_cpu_omap2423 | |
241 | * correctly. The macro needs to look at production_id not just hawkeye. | |
242 | */ | |
243 | static u32 is_gpmc_muxed(void) | |
244 | { | |
245 | u32 mux; | |
246 | mux = get_sysboot_value(); | |
247 | if ((mux & 0xF) == 0xd) | |
248 | return 1; /* NAND config (could be either) */ | |
249 | if (mux & 0x2) /* if mux'ed */ | |
250 | return 1; | |
251 | else | |
252 | return 0; | |
253 | } | |
254 | ||
f6049312 | 255 | static inline void __init h4_init_debug(void) |
1dbae815 | 256 | { |
44595982 PW |
257 | int eth_cs; |
258 | unsigned long cs_mem_base; | |
259 | unsigned int muxed, rate; | |
260 | struct clk *gpmc_fck; | |
261 | ||
262 | eth_cs = H4_SMC91X_CS; | |
263 | ||
264 | gpmc_fck = clk_get(NULL, "gpmc_fck"); /* Always on ENABLE_ON_INIT */ | |
265 | if (IS_ERR(gpmc_fck)) { | |
266 | WARN_ON(1); | |
267 | return; | |
268 | } | |
269 | ||
270 | clk_enable(gpmc_fck); | |
271 | rate = clk_get_rate(gpmc_fck); | |
272 | clk_disable(gpmc_fck); | |
273 | clk_put(gpmc_fck); | |
274 | ||
275 | if (is_gpmc_muxed()) | |
276 | muxed = 0x200; | |
277 | else | |
278 | muxed = 0; | |
279 | ||
1dbae815 | 280 | /* Make sure CS1 timings are correct */ |
44595982 PW |
281 | gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG1, |
282 | 0x00011000 | muxed); | |
283 | ||
284 | if (rate >= 160000000) { | |
285 | gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG2, 0x001f1f01); | |
286 | gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG3, 0x00080803); | |
287 | gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG4, 0x1c0b1c0a); | |
288 | gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG5, 0x041f1F1F); | |
289 | gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG6, 0x000004C4); | |
290 | } else if (rate >= 130000000) { | |
291 | gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG2, 0x001f1f00); | |
292 | gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG3, 0x00080802); | |
293 | gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG4, 0x1C091C09); | |
294 | gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG5, 0x041f1F1F); | |
295 | gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG6, 0x000004C4); | |
296 | } else {/* rate = 100000000 */ | |
297 | gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG2, 0x001f1f00); | |
298 | gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG3, 0x00080802); | |
299 | gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG4, 0x1C091C09); | |
300 | gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG5, 0x031A1F1F); | |
301 | gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG6, 0x000003C2); | |
302 | } | |
303 | ||
304 | if (gpmc_cs_request(eth_cs, SZ_16M, &cs_mem_base) < 0) { | |
305 | printk(KERN_ERR "Failed to request GPMC mem for smc91x\n"); | |
306 | goto out; | |
307 | } | |
308 | ||
1dbae815 TL |
309 | udelay(100); |
310 | ||
f99bf16d | 311 | omap_mux_init_gpio(92, 0); |
40662d77 | 312 | if (debug_card_init(cs_mem_base, H4_ETHR_GPIO_IRQ) < 0) |
f6049312 | 313 | gpmc_cs_free(eth_cs); |
44595982 PW |
314 | |
315 | out: | |
316 | clk_disable(gpmc_fck); | |
317 | clk_put(gpmc_fck); | |
318 | } | |
319 | ||
320 | static void __init h4_init_flash(void) | |
321 | { | |
322 | unsigned long base; | |
323 | ||
324 | if (gpmc_cs_request(H4_FLASH_CS, SZ_64M, &base) < 0) { | |
325 | printk("Can't request GPMC CS for flash\n"); | |
326 | return; | |
327 | } | |
328 | h4_flash_resource.start = base; | |
329 | h4_flash_resource.end = base + SZ_64M - 1; | |
1dbae815 TL |
330 | } |
331 | ||
b0b5aa3f | 332 | static struct omap_usb_config h4_usb_config __initdata = { |
b0b5aa3f FB |
333 | /* S1.10 OFF -- usb "download port" |
334 | * usb0 switched to Mini-B port and isp1105 transceiver; | |
335 | * S2.POS3 = ON, S2.POS4 = OFF ... to enable battery charging | |
336 | */ | |
337 | .register_dev = 1, | |
338 | .pins[0] = 3, | |
339 | /* .hmc_mode = 0x14,*/ /* 0:dev 1:host 2:disable */ | |
340 | .hmc_mode = 0x00, /* 0:dev|otg 1:disable 2:disable */ | |
b0b5aa3f FB |
341 | }; |
342 | ||
6a769ed4 DB |
343 | static struct at24_platform_data m24c01 = { |
344 | .byte_len = SZ_1K / 8, | |
345 | .page_size = 16, | |
346 | }; | |
347 | ||
9df013b3 JD |
348 | static struct i2c_board_info __initdata h4_i2c_board_info[] = { |
349 | { | |
350 | I2C_BOARD_INFO("isp1301_omap", 0x2d), | |
9df013b3 | 351 | }, |
6a769ed4 DB |
352 | { /* EEPROM on mainboard */ |
353 | I2C_BOARD_INFO("24c01", 0x52), | |
354 | .platform_data = &m24c01, | |
355 | }, | |
356 | { /* EEPROM on cpu card */ | |
357 | I2C_BOARD_INFO("24c01", 0x57), | |
358 | .platform_data = &m24c01, | |
359 | }, | |
9df013b3 JD |
360 | }; |
361 | ||
23275d45 TL |
362 | #ifdef CONFIG_OMAP_MUX |
363 | static struct omap_board_mux board_mux[] __initdata = { | |
364 | { .reg_offset = OMAP_MUX_TERMINATOR }, | |
365 | }; | |
23275d45 TL |
366 | #endif |
367 | ||
1dbae815 TL |
368 | static void __init omap_h4_init(void) |
369 | { | |
23275d45 TL |
370 | omap2420_mux_init(board_mux, OMAP_PACKAGE_ZAF); |
371 | ||
1dbae815 TL |
372 | /* |
373 | * Make sure the serial ports are muxed on at this point. | |
374 | * You have to mux them off in device drivers later on | |
375 | * if not needed. | |
376 | */ | |
9b6553cd | 377 | |
41eb2d81 | 378 | board_mkp_init(); |
46a0a540 | 379 | h4_i2c_board_info[0].irq = gpio_to_irq(125); |
9df013b3 JD |
380 | i2c_register_board_info(1, h4_i2c_board_info, |
381 | ARRAY_SIZE(h4_i2c_board_info)); | |
382 | ||
1dbae815 | 383 | platform_add_devices(h4_devices, ARRAY_SIZE(h4_devices)); |
b5e8905b | 384 | omap2_usbfs_init(&h4_usb_config); |
1dbae815 | 385 | omap_serial_init(); |
a4ca9dbe | 386 | omap_sdrc_init(NULL, NULL); |
42924355 | 387 | h4_init_flash(); |
cbf1455b TV |
388 | |
389 | omap_display_init(&h4_dss_data); | |
1dbae815 TL |
390 | } |
391 | ||
1dbae815 TL |
392 | MACHINE_START(OMAP_H4, "OMAP2420 H4 board") |
393 | /* Maintainer: Paul Mundt <paul.mundt@nokia.com> */ | |
5e52b435 | 394 | .atag_offset = 0x100, |
71ee7dad | 395 | .reserve = omap_reserve, |
e990a406 | 396 | .map_io = omap242x_map_io, |
8f5b5a41 | 397 | .init_early = omap2420_init_early, |
be732460 | 398 | .init_irq = omap2_init_irq, |
6b2f55d7 | 399 | .handle_irq = omap2_intc_handle_irq, |
1dbae815 | 400 | .init_machine = omap_h4_init, |
e74984e4 | 401 | .timer = &omap2_timer, |
baa95883 | 402 | .restart = omap_prcm_restart, |
1dbae815 | 403 | MACHINE_END |