blob: 5be30e6dd4cba2c78d9212c99306d387d34dbf09 [file] [log] [blame]
Tony Lindgren1dbae812005-11-10 14:26:51 +00001/*
Uwe Zeisbergerf30c2262006-10-03 23:01:26 +02002 * linux/arch/arm/mach-omap2/board-h4.c
Tony Lindgren1dbae812005-11-10 14:26:51 +00003 *
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 */
Russell King2f8163b2011-07-26 10:53:52 +010013#include <linux/gpio.h>
Tony Lindgren1dbae812005-11-10 14:26:51 +000014#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>
Ladislav Michl561b0362010-02-15 10:03:32 -080019#include <linux/mtd/physmap.h>
Tony Lindgren1dbae812005-11-10 14:26:51 +000020#include <linux/delay.h>
Tony Lindgren9b6553c2006-04-02 17:46:30 +010021#include <linux/workqueue.h>
Jean Delvare9df013b2008-10-14 17:30:02 +020022#include <linux/i2c.h>
David Brownell6a769ed2008-12-10 17:36:33 -080023#include <linux/i2c/at24.h>
Tony Lindgren9b6553c2006-04-02 17:46:30 +010024#include <linux/input.h>
Paul Walmsley44595982008-03-18 10:04:51 +020025#include <linux/err.h>
26#include <linux/clk.h>
Russell Kingfced80c2008-09-06 12:10:45 +010027#include <linux/io.h>
Tony Lindgren41eb2d82011-10-06 15:43:00 -070028#include <linux/input/matrix_keypad.h>
Tony Lindgren1dbae812005-11-10 14:26:51 +000029
Russell Kinga09e64f2008-08-05 16:14:15 +010030#include <mach/hardware.h>
Tony Lindgren1dbae812005-11-10 14:26:51 +000031#include <asm/mach-types.h>
32#include <asm/mach/arch.h>
33#include <asm/mach/map.h>
Tony Lindgren1dbae812005-11-10 14:26:51 +000034
Tony Lindgren4e653312011-11-10 22:45:17 +010035#include "common.h"
Tony Lindgrence491cf2009-10-20 09:40:47 -070036#include <plat/menelaus.h>
37#include <plat/dma.h>
38#include <plat/gpmc.h>
Igor Grinberg801475c2012-08-29 02:18:56 +030039#include <plat/debug-devices.h>
Tony Lindgren1dbae812005-11-10 14:26:51 +000040
Tomi Valkeinencbf14552011-05-09 10:12:42 +030041#include <video/omapdss.h>
42#include <video/omap-panel-generic-dpi.h>
43
Tony Lindgren23275d42010-07-05 16:31:37 +030044#include "mux.h"
Paul Walmsley4814ced2010-10-08 11:40:20 -060045#include "control.h"
Tony Lindgren23275d42010-07-05 16:31:37 +030046
Paul Walmsley44595982008-03-18 10:04:51 +020047#define H4_FLASH_CS 0
48#define H4_SMC91X_CS 1
49
Tony Lindgren40662d772009-03-23 18:07:36 -070050#define H4_ETHR_GPIO_IRQ 92
51
Tony Lindgren41eb2d82011-10-06 15:43:00 -070052#if defined(CONFIG_KEYBOARD_MATRIX) || defined(CONFIG_KEYBOARD_MATRIX_MODULE)
53static const uint32_t board_matrix_keys[] = {
Tony Lindgren9b6553c2006-04-02 17:46:30 +010054 KEY(0, 0, KEY_LEFT),
Janusz Krzysztofikda1f0262010-12-20 21:09:22 +000055 KEY(1, 0, KEY_RIGHT),
56 KEY(2, 0, KEY_A),
57 KEY(3, 0, KEY_B),
58 KEY(4, 0, KEY_C),
59 KEY(0, 1, KEY_DOWN),
Tony Lindgren9b6553c2006-04-02 17:46:30 +010060 KEY(1, 1, KEY_UP),
Janusz Krzysztofikda1f0262010-12-20 21:09:22 +000061 KEY(2, 1, KEY_E),
62 KEY(3, 1, KEY_F),
63 KEY(4, 1, KEY_G),
64 KEY(0, 2, KEY_ENTER),
65 KEY(1, 2, KEY_I),
Tony Lindgren9b6553c2006-04-02 17:46:30 +010066 KEY(2, 2, KEY_J),
Janusz Krzysztofikda1f0262010-12-20 21:09:22 +000067 KEY(3, 2, KEY_K),
68 KEY(4, 2, KEY_3),
69 KEY(0, 3, KEY_M),
70 KEY(1, 3, KEY_N),
71 KEY(2, 3, KEY_O),
Tony Lindgren9b6553c2006-04-02 17:46:30 +010072 KEY(3, 3, KEY_P),
Janusz Krzysztofikda1f0262010-12-20 21:09:22 +000073 KEY(4, 3, KEY_Q),
74 KEY(0, 4, KEY_R),
75 KEY(1, 4, KEY_4),
76 KEY(2, 4, KEY_T),
77 KEY(3, 4, KEY_U),
Tony Lindgren9b6553c2006-04-02 17:46:30 +010078 KEY(4, 4, KEY_ENTER),
Janusz Krzysztofikda1f0262010-12-20 21:09:22 +000079 KEY(0, 5, KEY_V),
80 KEY(1, 5, KEY_W),
81 KEY(2, 5, KEY_L),
82 KEY(3, 5, KEY_S),
83 KEY(4, 5, KEY_ENTER),
Tony Lindgren9b6553c2006-04-02 17:46:30 +010084};
85
Tony Lindgren41eb2d82011-10-06 15:43:00 -070086static const struct matrix_keymap_data board_keymap_data = {
87 .keymap = board_matrix_keys,
88 .keymap_size = ARRAY_SIZE(board_matrix_keys),
89};
90
91static unsigned int board_keypad_row_gpios[] = {
92 88, 89, 124, 11, 6, 96
93};
94
95static unsigned int board_keypad_col_gpios[] = {
96 90, 91, 100, 36, 12, 97, 98
97};
98
99static struct matrix_keypad_platform_data board_keypad_platform_data = {
100 .keymap_data = &board_keymap_data,
101 .row_gpios = board_keypad_row_gpios,
102 .num_row_gpios = ARRAY_SIZE(board_keypad_row_gpios),
103 .col_gpios = board_keypad_col_gpios,
104 .num_col_gpios = ARRAY_SIZE(board_keypad_col_gpios),
105 .active_low = 1,
106
107 .debounce_ms = 20,
108 .col_scan_delay_us = 5,
109};
110
111static struct platform_device board_keyboard = {
112 .name = "matrix-keypad",
113 .id = -1,
114 .dev = {
115 .platform_data = &board_keypad_platform_data,
116 },
117};
118static void __init board_mkp_init(void)
119{
120 omap_mux_init_gpio(88, OMAP_PULL_ENA | OMAP_PULL_UP);
121 omap_mux_init_gpio(89, OMAP_PULL_ENA | OMAP_PULL_UP);
122 omap_mux_init_gpio(124, OMAP_PULL_ENA | OMAP_PULL_UP);
123 omap_mux_init_signal("mcbsp2_dr.gpio_11", OMAP_PULL_ENA | OMAP_PULL_UP);
124 if (omap_has_menelaus()) {
125 omap_mux_init_signal("sdrc_a14.gpio0",
126 OMAP_PULL_ENA | OMAP_PULL_UP);
127 omap_mux_init_signal("vlynq_rx0.gpio_15", 0);
128 omap_mux_init_signal("gpio_98", 0);
129 board_keypad_row_gpios[5] = 0;
130 board_keypad_col_gpios[2] = 15;
131 board_keypad_col_gpios[6] = 18;
132 } else {
133 omap_mux_init_signal("gpio_96", OMAP_PULL_ENA | OMAP_PULL_UP);
134 omap_mux_init_signal("gpio_100", 0);
135 omap_mux_init_signal("gpio_98", 0);
136 }
137 omap_mux_init_signal("gpio_90", 0);
138 omap_mux_init_signal("gpio_91", 0);
139 omap_mux_init_signal("gpio_36", 0);
140 omap_mux_init_signal("mcbsp2_clkx.gpio_12", 0);
141 omap_mux_init_signal("gpio_97", 0);
142
143 platform_device_register(&board_keyboard);
144}
145#else
146static inline void board_mkp_init(void)
147{
148}
149#endif
150
Tony Lindgren1dbae812005-11-10 14:26:51 +0000151static struct mtd_partition h4_partitions[] = {
152 /* bootloader (U-Boot, etc) in first sector */
153 {
154 .name = "bootloader",
155 .offset = 0,
156 .size = SZ_128K,
157 .mask_flags = MTD_WRITEABLE, /* force read-only */
158 },
159 /* bootloader params in the next sector */
160 {
161 .name = "params",
162 .offset = MTDPART_OFS_APPEND,
163 .size = SZ_128K,
164 .mask_flags = 0,
165 },
166 /* kernel */
167 {
168 .name = "kernel",
169 .offset = MTDPART_OFS_APPEND,
170 .size = SZ_2M,
171 .mask_flags = 0
172 },
173 /* file system */
174 {
175 .name = "filesystem",
176 .offset = MTDPART_OFS_APPEND,
177 .size = MTDPART_SIZ_FULL,
178 .mask_flags = 0
179 }
180};
181
Ladislav Michl561b0362010-02-15 10:03:32 -0800182static struct physmap_flash_data h4_flash_data = {
Tony Lindgren1dbae812005-11-10 14:26:51 +0000183 .width = 2,
184 .parts = h4_partitions,
185 .nr_parts = ARRAY_SIZE(h4_partitions),
186};
187
188static struct resource h4_flash_resource = {
Tony Lindgren1dbae812005-11-10 14:26:51 +0000189 .flags = IORESOURCE_MEM,
190};
191
192static struct platform_device h4_flash_device = {
Ladislav Michl561b0362010-02-15 10:03:32 -0800193 .name = "physmap-flash",
Tony Lindgren1dbae812005-11-10 14:26:51 +0000194 .id = 0,
195 .dev = {
196 .platform_data = &h4_flash_data,
197 },
198 .num_resources = 1,
199 .resource = &h4_flash_resource,
200};
201
Tony Lindgren1dbae812005-11-10 14:26:51 +0000202static struct platform_device *h4_devices[] __initdata = {
Tony Lindgren1dbae812005-11-10 14:26:51 +0000203 &h4_flash_device,
Tomi Valkeinencbf14552011-05-09 10:12:42 +0300204};
205
206static struct panel_generic_dpi_data h4_panel_data = {
207 .name = "h4",
208};
209
210static struct omap_dss_device h4_lcd_device = {
211 .name = "lcd",
212 .driver_name = "generic_dpi_panel",
213 .type = OMAP_DISPLAY_TYPE_DPI,
214 .phy.dpi.data_lines = 16,
215 .data = &h4_panel_data,
216};
217
218static struct omap_dss_device *h4_dss_devices[] = {
Tony Lindgren9b6553c2006-04-02 17:46:30 +0100219 &h4_lcd_device,
Tony Lindgren1dbae812005-11-10 14:26:51 +0000220};
221
Tomi Valkeinencbf14552011-05-09 10:12:42 +0300222static struct omap_dss_board_info h4_dss_data = {
223 .num_devices = ARRAY_SIZE(h4_dss_devices),
224 .devices = h4_dss_devices,
225 .default_device = &h4_lcd_device,
226};
227
Paul Walmsley44595982008-03-18 10:04:51 +0200228/* 2420 Sysboot setup (2430 is different) */
229static u32 get_sysboot_value(void)
230{
231 return (omap_ctrl_readl(OMAP24XX_CONTROL_STATUS) &
232 (OMAP2_SYSBOOT_5_MASK | OMAP2_SYSBOOT_4_MASK |
233 OMAP2_SYSBOOT_3_MASK | OMAP2_SYSBOOT_2_MASK |
234 OMAP2_SYSBOOT_1_MASK | OMAP2_SYSBOOT_0_MASK));
235}
236
237/* H4-2420's always used muxed mode, H4-2422's always use non-muxed
238 *
239 * Note: OMAP-GIT doesn't correctly do is_cpu_omap2422 and is_cpu_omap2423
240 * correctly. The macro needs to look at production_id not just hawkeye.
241 */
242static u32 is_gpmc_muxed(void)
243{
244 u32 mux;
245 mux = get_sysboot_value();
246 if ((mux & 0xF) == 0xd)
247 return 1; /* NAND config (could be either) */
248 if (mux & 0x2) /* if mux'ed */
249 return 1;
250 else
251 return 0;
252}
253
David Brownellf6049312006-12-06 17:14:03 -0800254static inline void __init h4_init_debug(void)
Tony Lindgren1dbae812005-11-10 14:26:51 +0000255{
Paul Walmsley44595982008-03-18 10:04:51 +0200256 int eth_cs;
257 unsigned long cs_mem_base;
258 unsigned int muxed, rate;
259 struct clk *gpmc_fck;
260
261 eth_cs = H4_SMC91X_CS;
262
263 gpmc_fck = clk_get(NULL, "gpmc_fck"); /* Always on ENABLE_ON_INIT */
264 if (IS_ERR(gpmc_fck)) {
265 WARN_ON(1);
266 return;
267 }
268
269 clk_enable(gpmc_fck);
270 rate = clk_get_rate(gpmc_fck);
271 clk_disable(gpmc_fck);
272 clk_put(gpmc_fck);
273
274 if (is_gpmc_muxed())
275 muxed = 0x200;
276 else
277 muxed = 0;
278
Tony Lindgren1dbae812005-11-10 14:26:51 +0000279 /* Make sure CS1 timings are correct */
Paul Walmsley44595982008-03-18 10:04:51 +0200280 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG1,
281 0x00011000 | muxed);
282
283 if (rate >= 160000000) {
284 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG2, 0x001f1f01);
285 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG3, 0x00080803);
286 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG4, 0x1c0b1c0a);
287 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG5, 0x041f1F1F);
288 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG6, 0x000004C4);
289 } else if (rate >= 130000000) {
290 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG2, 0x001f1f00);
291 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG3, 0x00080802);
292 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG4, 0x1C091C09);
293 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG5, 0x041f1F1F);
294 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG6, 0x000004C4);
295 } else {/* rate = 100000000 */
296 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG2, 0x001f1f00);
297 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG3, 0x00080802);
298 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG4, 0x1C091C09);
299 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG5, 0x031A1F1F);
300 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG6, 0x000003C2);
301 }
302
303 if (gpmc_cs_request(eth_cs, SZ_16M, &cs_mem_base) < 0) {
304 printk(KERN_ERR "Failed to request GPMC mem for smc91x\n");
305 goto out;
306 }
307
Tony Lindgren1dbae812005-11-10 14:26:51 +0000308 udelay(100);
309
Tony Lindgrenf99bf162010-07-05 16:31:40 +0300310 omap_mux_init_gpio(92, 0);
Tony Lindgren40662d772009-03-23 18:07:36 -0700311 if (debug_card_init(cs_mem_base, H4_ETHR_GPIO_IRQ) < 0)
David Brownellf6049312006-12-06 17:14:03 -0800312 gpmc_cs_free(eth_cs);
Paul Walmsley44595982008-03-18 10:04:51 +0200313
314out:
315 clk_disable(gpmc_fck);
316 clk_put(gpmc_fck);
317}
318
319static void __init h4_init_flash(void)
320{
321 unsigned long base;
322
323 if (gpmc_cs_request(H4_FLASH_CS, SZ_64M, &base) < 0) {
324 printk("Can't request GPMC CS for flash\n");
325 return;
326 }
327 h4_flash_resource.start = base;
328 h4_flash_resource.end = base + SZ_64M - 1;
Tony Lindgren1dbae812005-11-10 14:26:51 +0000329}
330
David Brownell6a769ed2008-12-10 17:36:33 -0800331static struct at24_platform_data m24c01 = {
332 .byte_len = SZ_1K / 8,
333 .page_size = 16,
334};
335
Jean Delvare9df013b2008-10-14 17:30:02 +0200336static struct i2c_board_info __initdata h4_i2c_board_info[] = {
337 {
338 I2C_BOARD_INFO("isp1301_omap", 0x2d),
Jean Delvare9df013b2008-10-14 17:30:02 +0200339 },
David Brownell6a769ed2008-12-10 17:36:33 -0800340 { /* EEPROM on mainboard */
341 I2C_BOARD_INFO("24c01", 0x52),
342 .platform_data = &m24c01,
343 },
344 { /* EEPROM on cpu card */
345 I2C_BOARD_INFO("24c01", 0x57),
346 .platform_data = &m24c01,
347 },
Jean Delvare9df013b2008-10-14 17:30:02 +0200348};
349
Tony Lindgren23275d42010-07-05 16:31:37 +0300350#ifdef CONFIG_OMAP_MUX
351static struct omap_board_mux board_mux[] __initdata = {
352 { .reg_offset = OMAP_MUX_TERMINATOR },
353};
Tony Lindgren23275d42010-07-05 16:31:37 +0300354#endif
355
Tony Lindgren1dbae812005-11-10 14:26:51 +0000356static void __init omap_h4_init(void)
357{
Tony Lindgren23275d42010-07-05 16:31:37 +0300358 omap2420_mux_init(board_mux, OMAP_PACKAGE_ZAF);
359
Tony Lindgren1dbae812005-11-10 14:26:51 +0000360 /*
361 * Make sure the serial ports are muxed on at this point.
362 * You have to mux them off in device drivers later on
363 * if not needed.
364 */
Tony Lindgren9b6553c2006-04-02 17:46:30 +0100365
Tony Lindgren41eb2d82011-10-06 15:43:00 -0700366 board_mkp_init();
Tarun Kanti DebBarma46a0a542012-03-29 08:41:01 -0700367 h4_i2c_board_info[0].irq = gpio_to_irq(125);
Jean Delvare9df013b2008-10-14 17:30:02 +0200368 i2c_register_board_info(1, h4_i2c_board_info,
369 ARRAY_SIZE(h4_i2c_board_info));
370
Tony Lindgren1dbae812005-11-10 14:26:51 +0000371 platform_add_devices(h4_devices, ARRAY_SIZE(h4_devices));
Tony Lindgren1dbae812005-11-10 14:26:51 +0000372 omap_serial_init();
Tony Lindgrena4ca9db2011-08-22 23:57:23 -0700373 omap_sdrc_init(NULL, NULL);
Tony Lindgren42924352011-03-10 09:51:29 -0800374 h4_init_flash();
Tomi Valkeinencbf14552011-05-09 10:12:42 +0300375
376 omap_display_init(&h4_dss_data);
Tony Lindgren1dbae812005-11-10 14:26:51 +0000377}
378
Tony Lindgren1dbae812005-11-10 14:26:51 +0000379MACHINE_START(OMAP_H4, "OMAP2420 H4 board")
380 /* Maintainer: Paul Mundt <paul.mundt@nokia.com> */
Nicolas Pitre5e52b432011-07-05 22:38:15 -0400381 .atag_offset = 0x100,
Russell King71ee7da2010-05-23 10:18:16 +0100382 .reserve = omap_reserve,
Tony Lindgrene990a402011-09-26 14:52:55 -0700383 .map_io = omap242x_map_io,
Tony Lindgren8f5b5a42011-08-22 23:57:24 -0700384 .init_early = omap2420_init_early,
Tony Lindgrenbe732462011-09-26 15:25:22 -0700385 .init_irq = omap2_init_irq,
Marc Zyngier6b2f55d2011-09-06 10:23:45 +0100386 .handle_irq = omap2_intc_handle_irq,
Tony Lindgren1dbae812005-11-10 14:26:51 +0000387 .init_machine = omap_h4_init,
Shawn Guobbd707a2012-04-26 16:06:50 +0800388 .init_late = omap2420_init_late,
Tony Lindgrene74984e2011-03-29 15:54:48 -0700389 .timer = &omap2_timer,
Russell Kingbaa95882011-11-05 17:06:28 +0000390 .restart = omap_prcm_restart,
Tony Lindgren1dbae812005-11-10 14:26:51 +0000391MACHINE_END