blob: 9ec77a4a6b883c1d3a7a9ef8189562df940052f7 [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
Russell Kinga09e64f2008-08-05 16:14:15 +010034#include <mach/gpio.h>
Tony Lindgrence491cf2009-10-20 09:40:47 -070035#include <plat/usb.h>
36#include <plat/board.h>
37#include <plat/common.h>
38#include <plat/keypad.h>
39#include <plat/menelaus.h>
40#include <plat/dma.h>
41#include <plat/gpmc.h>
Tony Lindgren1dbae812005-11-10 14:26:51 +000042
Tony Lindgren23275d42010-07-05 16:31:37 +030043#include "mux.h"
Paul Walmsley4814ced2010-10-08 11:40:20 -060044#include "control.h"
Tony Lindgren23275d42010-07-05 16:31:37 +030045
Paul Walmsley44595982008-03-18 10:04:51 +020046#define H4_FLASH_CS 0
47#define H4_SMC91X_CS 1
48
Tony Lindgren40662d772009-03-23 18:07:36 -070049#define H4_ETHR_GPIO_IRQ 92
50
Tony Lindgren9b6553c2006-04-02 17:46:30 +010051static unsigned int row_gpios[6] = { 88, 89, 124, 11, 6, 96 };
52static unsigned int col_gpios[7] = { 90, 91, 100, 36, 12, 97, 98 };
53
54static int h4_keymap[] = {
55 KEY(0, 0, KEY_LEFT),
56 KEY(0, 1, KEY_RIGHT),
57 KEY(0, 2, KEY_A),
58 KEY(0, 3, KEY_B),
59 KEY(0, 4, KEY_C),
60 KEY(1, 0, KEY_DOWN),
61 KEY(1, 1, KEY_UP),
62 KEY(1, 2, KEY_E),
63 KEY(1, 3, KEY_F),
64 KEY(1, 4, KEY_G),
65 KEY(2, 0, KEY_ENTER),
66 KEY(2, 1, KEY_I),
67 KEY(2, 2, KEY_J),
68 KEY(2, 3, KEY_K),
69 KEY(2, 4, KEY_3),
70 KEY(3, 0, KEY_M),
71 KEY(3, 1, KEY_N),
72 KEY(3, 2, KEY_O),
73 KEY(3, 3, KEY_P),
74 KEY(3, 4, KEY_Q),
75 KEY(4, 0, KEY_R),
76 KEY(4, 1, KEY_4),
77 KEY(4, 2, KEY_T),
78 KEY(4, 3, KEY_U),
79 KEY(4, 4, KEY_ENTER),
80 KEY(5, 0, KEY_V),
81 KEY(5, 1, KEY_W),
82 KEY(5, 2, KEY_L),
83 KEY(5, 3, KEY_S),
84 KEY(5, 4, KEY_ENTER),
85 0
86};
87
Tony Lindgren1dbae812005-11-10 14:26:51 +000088static struct mtd_partition h4_partitions[] = {
89 /* bootloader (U-Boot, etc) in first sector */
90 {
91 .name = "bootloader",
92 .offset = 0,
93 .size = SZ_128K,
94 .mask_flags = MTD_WRITEABLE, /* force read-only */
95 },
96 /* bootloader params in the next sector */
97 {
98 .name = "params",
99 .offset = MTDPART_OFS_APPEND,
100 .size = SZ_128K,
101 .mask_flags = 0,
102 },
103 /* kernel */
104 {
105 .name = "kernel",
106 .offset = MTDPART_OFS_APPEND,
107 .size = SZ_2M,
108 .mask_flags = 0
109 },
110 /* file system */
111 {
112 .name = "filesystem",
113 .offset = MTDPART_OFS_APPEND,
114 .size = MTDPART_SIZ_FULL,
115 .mask_flags = 0
116 }
117};
118
Ladislav Michl561b0362010-02-15 10:03:32 -0800119static struct physmap_flash_data h4_flash_data = {
Tony Lindgren1dbae812005-11-10 14:26:51 +0000120 .width = 2,
121 .parts = h4_partitions,
122 .nr_parts = ARRAY_SIZE(h4_partitions),
123};
124
125static struct resource h4_flash_resource = {
Tony Lindgren1dbae812005-11-10 14:26:51 +0000126 .flags = IORESOURCE_MEM,
127};
128
129static struct platform_device h4_flash_device = {
Ladislav Michl561b0362010-02-15 10:03:32 -0800130 .name = "physmap-flash",
Tony Lindgren1dbae812005-11-10 14:26:51 +0000131 .id = 0,
132 .dev = {
133 .platform_data = &h4_flash_data,
134 },
135 .num_resources = 1,
136 .resource = &h4_flash_resource,
137};
138
Tony Lindgren9b6553c2006-04-02 17:46:30 +0100139static struct omap_kp_platform_data h4_kp_data = {
140 .rows = 6,
141 .cols = 7,
142 .keymap = h4_keymap,
Komal Shah4d246072006-09-29 01:59:20 -0700143 .keymapsize = ARRAY_SIZE(h4_keymap),
Tony Lindgren9b6553c2006-04-02 17:46:30 +0100144 .rep = 1,
145 .row_gpios = row_gpios,
146 .col_gpios = col_gpios,
147};
148
149static struct platform_device h4_kp_device = {
150 .name = "omap-keypad",
151 .id = -1,
152 .dev = {
153 .platform_data = &h4_kp_data,
154 },
155};
156
157static struct platform_device h4_lcd_device = {
158 .name = "lcd_h4",
159 .id = -1,
160};
161
Tony Lindgren1dbae812005-11-10 14:26:51 +0000162static struct platform_device *h4_devices[] __initdata = {
Tony Lindgren1dbae812005-11-10 14:26:51 +0000163 &h4_flash_device,
Tony Lindgren9b6553c2006-04-02 17:46:30 +0100164 &h4_kp_device,
165 &h4_lcd_device,
Tony Lindgren1dbae812005-11-10 14:26:51 +0000166};
167
Paul Walmsley44595982008-03-18 10:04:51 +0200168/* 2420 Sysboot setup (2430 is different) */
169static u32 get_sysboot_value(void)
170{
171 return (omap_ctrl_readl(OMAP24XX_CONTROL_STATUS) &
172 (OMAP2_SYSBOOT_5_MASK | OMAP2_SYSBOOT_4_MASK |
173 OMAP2_SYSBOOT_3_MASK | OMAP2_SYSBOOT_2_MASK |
174 OMAP2_SYSBOOT_1_MASK | OMAP2_SYSBOOT_0_MASK));
175}
176
177/* H4-2420's always used muxed mode, H4-2422's always use non-muxed
178 *
179 * Note: OMAP-GIT doesn't correctly do is_cpu_omap2422 and is_cpu_omap2423
180 * correctly. The macro needs to look at production_id not just hawkeye.
181 */
182static u32 is_gpmc_muxed(void)
183{
184 u32 mux;
185 mux = get_sysboot_value();
186 if ((mux & 0xF) == 0xd)
187 return 1; /* NAND config (could be either) */
188 if (mux & 0x2) /* if mux'ed */
189 return 1;
190 else
191 return 0;
192}
193
David Brownellf6049312006-12-06 17:14:03 -0800194static inline void __init h4_init_debug(void)
Tony Lindgren1dbae812005-11-10 14:26:51 +0000195{
Paul Walmsley44595982008-03-18 10:04:51 +0200196 int eth_cs;
197 unsigned long cs_mem_base;
198 unsigned int muxed, rate;
199 struct clk *gpmc_fck;
200
201 eth_cs = H4_SMC91X_CS;
202
203 gpmc_fck = clk_get(NULL, "gpmc_fck"); /* Always on ENABLE_ON_INIT */
204 if (IS_ERR(gpmc_fck)) {
205 WARN_ON(1);
206 return;
207 }
208
209 clk_enable(gpmc_fck);
210 rate = clk_get_rate(gpmc_fck);
211 clk_disable(gpmc_fck);
212 clk_put(gpmc_fck);
213
214 if (is_gpmc_muxed())
215 muxed = 0x200;
216 else
217 muxed = 0;
218
Tony Lindgren1dbae812005-11-10 14:26:51 +0000219 /* Make sure CS1 timings are correct */
Paul Walmsley44595982008-03-18 10:04:51 +0200220 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG1,
221 0x00011000 | muxed);
222
223 if (rate >= 160000000) {
224 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG2, 0x001f1f01);
225 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG3, 0x00080803);
226 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG4, 0x1c0b1c0a);
227 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG5, 0x041f1F1F);
228 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG6, 0x000004C4);
229 } else if (rate >= 130000000) {
230 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG2, 0x001f1f00);
231 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG3, 0x00080802);
232 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG4, 0x1C091C09);
233 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG5, 0x041f1F1F);
234 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG6, 0x000004C4);
235 } else {/* rate = 100000000 */
236 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG2, 0x001f1f00);
237 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG3, 0x00080802);
238 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG4, 0x1C091C09);
239 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG5, 0x031A1F1F);
240 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG6, 0x000003C2);
241 }
242
243 if (gpmc_cs_request(eth_cs, SZ_16M, &cs_mem_base) < 0) {
244 printk(KERN_ERR "Failed to request GPMC mem for smc91x\n");
245 goto out;
246 }
247
Tony Lindgren1dbae812005-11-10 14:26:51 +0000248 udelay(100);
249
Tony Lindgrenf99bf162010-07-05 16:31:40 +0300250 omap_mux_init_gpio(92, 0);
Tony Lindgren40662d772009-03-23 18:07:36 -0700251 if (debug_card_init(cs_mem_base, H4_ETHR_GPIO_IRQ) < 0)
David Brownellf6049312006-12-06 17:14:03 -0800252 gpmc_cs_free(eth_cs);
Paul Walmsley44595982008-03-18 10:04:51 +0200253
254out:
255 clk_disable(gpmc_fck);
256 clk_put(gpmc_fck);
257}
258
259static void __init h4_init_flash(void)
260{
261 unsigned long base;
262
263 if (gpmc_cs_request(H4_FLASH_CS, SZ_64M, &base) < 0) {
264 printk("Can't request GPMC CS for flash\n");
265 return;
266 }
267 h4_flash_resource.start = base;
268 h4_flash_resource.end = base + SZ_64M - 1;
Tony Lindgren1dbae812005-11-10 14:26:51 +0000269}
270
Tony Lindgren1dbae812005-11-10 14:26:51 +0000271static struct omap_lcd_config h4_lcd_config __initdata = {
Tony Lindgren1dbae812005-11-10 14:26:51 +0000272 .ctrl_name = "internal",
273};
274
Felipe Balbib0b5aa32009-03-23 18:07:49 -0700275static struct omap_usb_config h4_usb_config __initdata = {
Felipe Balbib0b5aa32009-03-23 18:07:49 -0700276 /* S1.10 OFF -- usb "download port"
277 * usb0 switched to Mini-B port and isp1105 transceiver;
278 * S2.POS3 = ON, S2.POS4 = OFF ... to enable battery charging
279 */
280 .register_dev = 1,
281 .pins[0] = 3,
282/* .hmc_mode = 0x14,*/ /* 0:dev 1:host 2:disable */
283 .hmc_mode = 0x00, /* 0:dev|otg 1:disable 2:disable */
Felipe Balbib0b5aa32009-03-23 18:07:49 -0700284};
285
Tony Lindgren1dbae812005-11-10 14:26:51 +0000286static struct omap_board_config_kernel h4_config[] = {
Tony Lindgren1dbae812005-11-10 14:26:51 +0000287 { OMAP_TAG_LCD, &h4_lcd_config },
288};
289
Paul Walmsleyb3c6df32009-09-03 20:14:02 +0300290static void __init omap_h4_init_irq(void)
291{
292 omap_board_config = h4_config;
293 omap_board_config_size = ARRAY_SIZE(h4_config);
294 omap2_init_common_hw(NULL, NULL);
295 omap_init_irq();
Paul Walmsleyb3c6df32009-09-03 20:14:02 +0300296 h4_init_flash();
297}
298
David Brownell6a769ed2008-12-10 17:36:33 -0800299static struct at24_platform_data m24c01 = {
300 .byte_len = SZ_1K / 8,
301 .page_size = 16,
302};
303
Jean Delvare9df013b2008-10-14 17:30:02 +0200304static struct i2c_board_info __initdata h4_i2c_board_info[] = {
305 {
306 I2C_BOARD_INFO("isp1301_omap", 0x2d),
307 .irq = OMAP_GPIO_IRQ(125),
308 },
David Brownell6a769ed2008-12-10 17:36:33 -0800309 { /* EEPROM on mainboard */
310 I2C_BOARD_INFO("24c01", 0x52),
311 .platform_data = &m24c01,
312 },
313 { /* EEPROM on cpu card */
314 I2C_BOARD_INFO("24c01", 0x57),
315 .platform_data = &m24c01,
316 },
Jean Delvare9df013b2008-10-14 17:30:02 +0200317};
318
Tony Lindgren23275d42010-07-05 16:31:37 +0300319#ifdef CONFIG_OMAP_MUX
320static struct omap_board_mux board_mux[] __initdata = {
321 { .reg_offset = OMAP_MUX_TERMINATOR },
322};
Tony Lindgren23275d42010-07-05 16:31:37 +0300323#endif
324
Tony Lindgren1dbae812005-11-10 14:26:51 +0000325static void __init omap_h4_init(void)
326{
Tony Lindgren23275d42010-07-05 16:31:37 +0300327 omap2420_mux_init(board_mux, OMAP_PACKAGE_ZAF);
328
Tony Lindgren1dbae812005-11-10 14:26:51 +0000329 /*
330 * Make sure the serial ports are muxed on at this point.
331 * You have to mux them off in device drivers later on
332 * if not needed.
333 */
Tony Lindgren9b6553c2006-04-02 17:46:30 +0100334
335#if defined(CONFIG_KEYBOARD_OMAP) || defined(CONFIG_KEYBOARD_OMAP_MODULE)
Tony Lindgren93c43f22010-07-05 16:31:39 +0300336 omap_mux_init_gpio(88, OMAP_PULL_ENA | OMAP_PULL_UP);
337 omap_mux_init_gpio(89, OMAP_PULL_ENA | OMAP_PULL_UP);
338 omap_mux_init_gpio(124, OMAP_PULL_ENA | OMAP_PULL_UP);
339 omap_mux_init_signal("mcbsp2_dr.gpio_11", OMAP_PULL_ENA | OMAP_PULL_UP);
Tony Lindgren9b6553c2006-04-02 17:46:30 +0100340 if (omap_has_menelaus()) {
Tony Lindgren93c43f22010-07-05 16:31:39 +0300341 omap_mux_init_signal("sdrc_a14.gpio0",
342 OMAP_PULL_ENA | OMAP_PULL_UP);
343 omap_mux_init_signal("vlynq_rx0.gpio_15", 0);
344 omap_mux_init_signal("gpio_98", 0);
Tony Lindgren9b6553c2006-04-02 17:46:30 +0100345 row_gpios[5] = 0;
346 col_gpios[2] = 15;
347 col_gpios[6] = 18;
Tony Lindgren93c43f22010-07-05 16:31:39 +0300348 } else {
349 omap_mux_init_signal("gpio_96", OMAP_PULL_ENA | OMAP_PULL_UP);
350 omap_mux_init_signal("gpio_100", 0);
351 omap_mux_init_signal("gpio_98", 0);
Tony Lindgren9b6553c2006-04-02 17:46:30 +0100352 }
Tony Lindgren93c43f22010-07-05 16:31:39 +0300353 omap_mux_init_signal("gpio_90", 0);
354 omap_mux_init_signal("gpio_91", 0);
355 omap_mux_init_signal("gpio_36", 0);
356 omap_mux_init_signal("mcbsp2_clkx.gpio_12", 0);
357 omap_mux_init_signal("gpio_97", 0);
Tony Lindgren9b6553c2006-04-02 17:46:30 +0100358#endif
359
Jean Delvare9df013b2008-10-14 17:30:02 +0200360 i2c_register_board_info(1, h4_i2c_board_info,
361 ARRAY_SIZE(h4_i2c_board_info));
362
Tony Lindgren1dbae812005-11-10 14:26:51 +0000363 platform_add_devices(h4_devices, ARRAY_SIZE(h4_devices));
Tony Lindgrenb5e89052010-07-05 16:31:29 +0300364 omap2_usbfs_init(&h4_usb_config);
Tony Lindgren1dbae812005-11-10 14:26:51 +0000365 omap_serial_init();
366}
367
368static void __init omap_h4_map_io(void)
369{
Paul Walmsleyc8d2eb82008-05-07 16:55:13 -0700370 omap2_set_globals_242x();
Tony Lindgren6fbd55d2010-02-12 12:26:47 -0800371 omap242x_map_common_io();
Tony Lindgren1dbae812005-11-10 14:26:51 +0000372}
373
374MACHINE_START(OMAP_H4, "OMAP2420 H4 board")
375 /* Maintainer: Paul Mundt <paul.mundt@nokia.com> */
Tony Lindgren1dbae812005-11-10 14:26:51 +0000376 .boot_params = 0x80000100,
377 .map_io = omap_h4_map_io,
Russell King71ee7da2010-05-23 10:18:16 +0100378 .reserve = omap_reserve,
Tony Lindgren1dbae812005-11-10 14:26:51 +0000379 .init_irq = omap_h4_init_irq,
380 .init_machine = omap_h4_init,
381 .timer = &omap_timer,
382MACHINE_END