blob: 8c58f51063937cb0dba914ff429d3784788cc8ac [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 */
13
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>
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 Lindgren1dbae812005-11-10 14:26:51 +000028
Russell Kinga09e64f2008-08-05 16:14:15 +010029#include <mach/hardware.h>
Tony Lindgren1dbae812005-11-10 14:26:51 +000030#include <asm/mach-types.h>
31#include <asm/mach/arch.h>
32#include <asm/mach/map.h>
Tony Lindgren1dbae812005-11-10 14:26:51 +000033
Tony Lindgrence491cf2009-10-20 09:40:47 -070034#include <plat/control.h>
Russell Kinga09e64f2008-08-05 16:14:15 +010035#include <mach/gpio.h>
Tony Lindgrence491cf2009-10-20 09:40:47 -070036#include <plat/mux.h>
37#include <plat/usb.h>
38#include <plat/board.h>
39#include <plat/common.h>
40#include <plat/keypad.h>
41#include <plat/menelaus.h>
42#include <plat/dma.h>
43#include <plat/gpmc.h>
Tony Lindgren1dbae812005-11-10 14:26:51 +000044
Tony Lindgren23275d42010-07-05 16:31:37 +030045#include "mux.h"
46
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 Lindgren9b6553c2006-04-02 17:46:30 +010052static unsigned int row_gpios[6] = { 88, 89, 124, 11, 6, 96 };
53static unsigned int col_gpios[7] = { 90, 91, 100, 36, 12, 97, 98 };
54
55static int h4_keymap[] = {
56 KEY(0, 0, KEY_LEFT),
57 KEY(0, 1, KEY_RIGHT),
58 KEY(0, 2, KEY_A),
59 KEY(0, 3, KEY_B),
60 KEY(0, 4, KEY_C),
61 KEY(1, 0, KEY_DOWN),
62 KEY(1, 1, KEY_UP),
63 KEY(1, 2, KEY_E),
64 KEY(1, 3, KEY_F),
65 KEY(1, 4, KEY_G),
66 KEY(2, 0, KEY_ENTER),
67 KEY(2, 1, KEY_I),
68 KEY(2, 2, KEY_J),
69 KEY(2, 3, KEY_K),
70 KEY(2, 4, KEY_3),
71 KEY(3, 0, KEY_M),
72 KEY(3, 1, KEY_N),
73 KEY(3, 2, KEY_O),
74 KEY(3, 3, KEY_P),
75 KEY(3, 4, KEY_Q),
76 KEY(4, 0, KEY_R),
77 KEY(4, 1, KEY_4),
78 KEY(4, 2, KEY_T),
79 KEY(4, 3, KEY_U),
80 KEY(4, 4, KEY_ENTER),
81 KEY(5, 0, KEY_V),
82 KEY(5, 1, KEY_W),
83 KEY(5, 2, KEY_L),
84 KEY(5, 3, KEY_S),
85 KEY(5, 4, KEY_ENTER),
86 0
87};
88
Tony Lindgren1dbae812005-11-10 14:26:51 +000089static struct mtd_partition h4_partitions[] = {
90 /* bootloader (U-Boot, etc) in first sector */
91 {
92 .name = "bootloader",
93 .offset = 0,
94 .size = SZ_128K,
95 .mask_flags = MTD_WRITEABLE, /* force read-only */
96 },
97 /* bootloader params in the next sector */
98 {
99 .name = "params",
100 .offset = MTDPART_OFS_APPEND,
101 .size = SZ_128K,
102 .mask_flags = 0,
103 },
104 /* kernel */
105 {
106 .name = "kernel",
107 .offset = MTDPART_OFS_APPEND,
108 .size = SZ_2M,
109 .mask_flags = 0
110 },
111 /* file system */
112 {
113 .name = "filesystem",
114 .offset = MTDPART_OFS_APPEND,
115 .size = MTDPART_SIZ_FULL,
116 .mask_flags = 0
117 }
118};
119
Ladislav Michl561b0362010-02-15 10:03:32 -0800120static struct physmap_flash_data h4_flash_data = {
Tony Lindgren1dbae812005-11-10 14:26:51 +0000121 .width = 2,
122 .parts = h4_partitions,
123 .nr_parts = ARRAY_SIZE(h4_partitions),
124};
125
126static struct resource h4_flash_resource = {
Tony Lindgren1dbae812005-11-10 14:26:51 +0000127 .flags = IORESOURCE_MEM,
128};
129
130static struct platform_device h4_flash_device = {
Ladislav Michl561b0362010-02-15 10:03:32 -0800131 .name = "physmap-flash",
Tony Lindgren1dbae812005-11-10 14:26:51 +0000132 .id = 0,
133 .dev = {
134 .platform_data = &h4_flash_data,
135 },
136 .num_resources = 1,
137 .resource = &h4_flash_resource,
138};
139
Tony Lindgren9b6553c2006-04-02 17:46:30 +0100140static struct omap_kp_platform_data h4_kp_data = {
141 .rows = 6,
142 .cols = 7,
143 .keymap = h4_keymap,
Komal Shah4d246072006-09-29 01:59:20 -0700144 .keymapsize = ARRAY_SIZE(h4_keymap),
Tony Lindgren9b6553c2006-04-02 17:46:30 +0100145 .rep = 1,
146 .row_gpios = row_gpios,
147 .col_gpios = col_gpios,
148};
149
150static struct platform_device h4_kp_device = {
151 .name = "omap-keypad",
152 .id = -1,
153 .dev = {
154 .platform_data = &h4_kp_data,
155 },
156};
157
158static struct platform_device h4_lcd_device = {
159 .name = "lcd_h4",
160 .id = -1,
161};
162
Tony Lindgren1dbae812005-11-10 14:26:51 +0000163static struct platform_device *h4_devices[] __initdata = {
Tony Lindgren1dbae812005-11-10 14:26:51 +0000164 &h4_flash_device,
Tony Lindgren9b6553c2006-04-02 17:46:30 +0100165 &h4_kp_device,
166 &h4_lcd_device,
Tony Lindgren1dbae812005-11-10 14:26:51 +0000167};
168
Paul Walmsley44595982008-03-18 10:04:51 +0200169/* 2420 Sysboot setup (2430 is different) */
170static u32 get_sysboot_value(void)
171{
172 return (omap_ctrl_readl(OMAP24XX_CONTROL_STATUS) &
173 (OMAP2_SYSBOOT_5_MASK | OMAP2_SYSBOOT_4_MASK |
174 OMAP2_SYSBOOT_3_MASK | OMAP2_SYSBOOT_2_MASK |
175 OMAP2_SYSBOOT_1_MASK | OMAP2_SYSBOOT_0_MASK));
176}
177
178/* H4-2420's always used muxed mode, H4-2422's always use non-muxed
179 *
180 * Note: OMAP-GIT doesn't correctly do is_cpu_omap2422 and is_cpu_omap2423
181 * correctly. The macro needs to look at production_id not just hawkeye.
182 */
183static u32 is_gpmc_muxed(void)
184{
185 u32 mux;
186 mux = get_sysboot_value();
187 if ((mux & 0xF) == 0xd)
188 return 1; /* NAND config (could be either) */
189 if (mux & 0x2) /* if mux'ed */
190 return 1;
191 else
192 return 0;
193}
194
David Brownellf6049312006-12-06 17:14:03 -0800195static inline void __init h4_init_debug(void)
Tony Lindgren1dbae812005-11-10 14:26:51 +0000196{
Paul Walmsley44595982008-03-18 10:04:51 +0200197 int eth_cs;
198 unsigned long cs_mem_base;
199 unsigned int muxed, rate;
200 struct clk *gpmc_fck;
201
202 eth_cs = H4_SMC91X_CS;
203
204 gpmc_fck = clk_get(NULL, "gpmc_fck"); /* Always on ENABLE_ON_INIT */
205 if (IS_ERR(gpmc_fck)) {
206 WARN_ON(1);
207 return;
208 }
209
210 clk_enable(gpmc_fck);
211 rate = clk_get_rate(gpmc_fck);
212 clk_disable(gpmc_fck);
213 clk_put(gpmc_fck);
214
215 if (is_gpmc_muxed())
216 muxed = 0x200;
217 else
218 muxed = 0;
219
Tony Lindgren1dbae812005-11-10 14:26:51 +0000220 /* Make sure CS1 timings are correct */
Paul Walmsley44595982008-03-18 10:04:51 +0200221 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG1,
222 0x00011000 | muxed);
223
224 if (rate >= 160000000) {
225 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG2, 0x001f1f01);
226 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG3, 0x00080803);
227 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG4, 0x1c0b1c0a);
228 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG5, 0x041f1F1F);
229 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG6, 0x000004C4);
230 } else if (rate >= 130000000) {
231 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG2, 0x001f1f00);
232 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG3, 0x00080802);
233 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG4, 0x1C091C09);
234 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG5, 0x041f1F1F);
235 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG6, 0x000004C4);
236 } else {/* rate = 100000000 */
237 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG2, 0x001f1f00);
238 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG3, 0x00080802);
239 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG4, 0x1C091C09);
240 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG5, 0x031A1F1F);
241 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG6, 0x000003C2);
242 }
243
244 if (gpmc_cs_request(eth_cs, SZ_16M, &cs_mem_base) < 0) {
245 printk(KERN_ERR "Failed to request GPMC mem for smc91x\n");
246 goto out;
247 }
248
Tony Lindgren1dbae812005-11-10 14:26:51 +0000249 udelay(100);
250
251 omap_cfg_reg(M15_24XX_GPIO92);
Tony Lindgren40662d772009-03-23 18:07:36 -0700252 if (debug_card_init(cs_mem_base, H4_ETHR_GPIO_IRQ) < 0)
David Brownellf6049312006-12-06 17:14:03 -0800253 gpmc_cs_free(eth_cs);
Paul Walmsley44595982008-03-18 10:04:51 +0200254
255out:
256 clk_disable(gpmc_fck);
257 clk_put(gpmc_fck);
258}
259
260static void __init h4_init_flash(void)
261{
262 unsigned long base;
263
264 if (gpmc_cs_request(H4_FLASH_CS, SZ_64M, &base) < 0) {
265 printk("Can't request GPMC CS for flash\n");
266 return;
267 }
268 h4_flash_resource.start = base;
269 h4_flash_resource.end = base + SZ_64M - 1;
Tony Lindgren1dbae812005-11-10 14:26:51 +0000270}
271
Tony Lindgren1dbae812005-11-10 14:26:51 +0000272static struct omap_lcd_config h4_lcd_config __initdata = {
Tony Lindgren1dbae812005-11-10 14:26:51 +0000273 .ctrl_name = "internal",
274};
275
Felipe Balbib0b5aa32009-03-23 18:07:49 -0700276static struct omap_usb_config h4_usb_config __initdata = {
277#ifdef CONFIG_MACH_OMAP2_H4_USB1
278 /* NOTE: usb1 could also be used with 3 wire signaling */
279 .pins[1] = 4,
280#endif
281
282#ifdef CONFIG_MACH_OMAP_H4_OTG
283 /* S1.10 ON -- USB OTG port
284 * usb0 switched to Mini-AB port and isp1301 transceiver;
285 * S2.POS3 = OFF, S2.POS4 = ON ... to allow battery charging
286 */
287 .otg = 1,
288 .pins[0] = 4,
289#ifdef CONFIG_USB_GADGET_OMAP
290 /* use OTG cable, or standard A-to-MiniB */
291 .hmc_mode = 0x14, /* 0:dev/otg 1:host 2:disable */
292#elif defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE)
293 /* use OTG cable, or NONSTANDARD (B-to-MiniB) */
294 .hmc_mode = 0x11, /* 0:host 1:host 2:disable */
295#endif /* XX */
296
297#else
298 /* S1.10 OFF -- usb "download port"
299 * usb0 switched to Mini-B port and isp1105 transceiver;
300 * S2.POS3 = ON, S2.POS4 = OFF ... to enable battery charging
301 */
302 .register_dev = 1,
303 .pins[0] = 3,
304/* .hmc_mode = 0x14,*/ /* 0:dev 1:host 2:disable */
305 .hmc_mode = 0x00, /* 0:dev|otg 1:disable 2:disable */
306#endif
307};
308
Tony Lindgren1dbae812005-11-10 14:26:51 +0000309static struct omap_board_config_kernel h4_config[] = {
Tony Lindgren1dbae812005-11-10 14:26:51 +0000310 { OMAP_TAG_LCD, &h4_lcd_config },
311};
312
Paul Walmsleyb3c6df32009-09-03 20:14:02 +0300313static void __init omap_h4_init_irq(void)
314{
315 omap_board_config = h4_config;
316 omap_board_config_size = ARRAY_SIZE(h4_config);
317 omap2_init_common_hw(NULL, NULL);
318 omap_init_irq();
319 omap_gpio_init();
320 h4_init_flash();
321}
322
David Brownell6a769ed2008-12-10 17:36:33 -0800323static struct at24_platform_data m24c01 = {
324 .byte_len = SZ_1K / 8,
325 .page_size = 16,
326};
327
Jean Delvare9df013b2008-10-14 17:30:02 +0200328static struct i2c_board_info __initdata h4_i2c_board_info[] = {
329 {
330 I2C_BOARD_INFO("isp1301_omap", 0x2d),
331 .irq = OMAP_GPIO_IRQ(125),
332 },
David Brownell6a769ed2008-12-10 17:36:33 -0800333 { /* EEPROM on mainboard */
334 I2C_BOARD_INFO("24c01", 0x52),
335 .platform_data = &m24c01,
336 },
337 { /* EEPROM on cpu card */
338 I2C_BOARD_INFO("24c01", 0x57),
339 .platform_data = &m24c01,
340 },
Jean Delvare9df013b2008-10-14 17:30:02 +0200341};
342
Tony Lindgren23275d42010-07-05 16:31:37 +0300343#ifdef CONFIG_OMAP_MUX
344static struct omap_board_mux board_mux[] __initdata = {
345 { .reg_offset = OMAP_MUX_TERMINATOR },
346};
347#else
348#define board_mux NULL
349#endif
350
Tony Lindgren1dbae812005-11-10 14:26:51 +0000351static void __init omap_h4_init(void)
352{
Tony Lindgren23275d42010-07-05 16:31:37 +0300353 omap2420_mux_init(board_mux, OMAP_PACKAGE_ZAF);
354
Tony Lindgren1dbae812005-11-10 14:26:51 +0000355 /*
356 * Make sure the serial ports are muxed on at this point.
357 * You have to mux them off in device drivers later on
358 * if not needed.
359 */
Tony Lindgren9b6553c2006-04-02 17:46:30 +0100360#if defined(CONFIG_OMAP_IR) || defined(CONFIG_OMAP_IR_MODULE)
361 omap_cfg_reg(K15_24XX_UART3_TX);
362 omap_cfg_reg(K14_24XX_UART3_RX);
363#endif
364
365#if defined(CONFIG_KEYBOARD_OMAP) || defined(CONFIG_KEYBOARD_OMAP_MODULE)
366 if (omap_has_menelaus()) {
367 row_gpios[5] = 0;
368 col_gpios[2] = 15;
369 col_gpios[6] = 18;
370 }
371#endif
372
Jean Delvare9df013b2008-10-14 17:30:02 +0200373 i2c_register_board_info(1, h4_i2c_board_info,
374 ARRAY_SIZE(h4_i2c_board_info));
375
Tony Lindgren1dbae812005-11-10 14:26:51 +0000376 platform_add_devices(h4_devices, ARRAY_SIZE(h4_devices));
Tony Lindgrenb5e89052010-07-05 16:31:29 +0300377 omap2_usbfs_init(&h4_usb_config);
Tony Lindgren1dbae812005-11-10 14:26:51 +0000378 omap_serial_init();
379}
380
381static void __init omap_h4_map_io(void)
382{
Paul Walmsleyc8d2eb82008-05-07 16:55:13 -0700383 omap2_set_globals_242x();
Tony Lindgren6fbd55d2010-02-12 12:26:47 -0800384 omap242x_map_common_io();
Tony Lindgren1dbae812005-11-10 14:26:51 +0000385}
386
387MACHINE_START(OMAP_H4, "OMAP2420 H4 board")
388 /* Maintainer: Paul Mundt <paul.mundt@nokia.com> */
Tony Lindgren1dbae812005-11-10 14:26:51 +0000389 .phys_io = 0x48000000,
Santosh Shilimkarb4224b22009-10-19 17:25:55 -0700390 .io_pg_offst = ((0xfa000000) >> 18) & 0xfffc,
Tony Lindgren1dbae812005-11-10 14:26:51 +0000391 .boot_params = 0x80000100,
392 .map_io = omap_h4_map_io,
393 .init_irq = omap_h4_init_irq,
394 .init_machine = omap_h4_init,
395 .timer = &omap_timer,
396MACHINE_END