blob: c12666ee7017a8880ff9cfd151b9a1e5d7ba77b3 [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 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/usb.h>
35#include <plat/board.h>
36#include <plat/common.h>
37#include <plat/keypad.h>
38#include <plat/menelaus.h>
39#include <plat/dma.h>
40#include <plat/gpmc.h>
Tony Lindgren1dbae812005-11-10 14:26:51 +000041
Tomi Valkeinencbf14552011-05-09 10:12:42 +030042#include <video/omapdss.h>
43#include <video/omap-panel-generic-dpi.h>
44
Tony Lindgren23275d42010-07-05 16:31:37 +030045#include "mux.h"
Paul Walmsley4814ced2010-10-08 11:40:20 -060046#include "control.h"
Tony Lindgren23275d42010-07-05 16:31:37 +030047
Paul Walmsley44595982008-03-18 10:04:51 +020048#define H4_FLASH_CS 0
49#define H4_SMC91X_CS 1
50
Tony Lindgren40662d772009-03-23 18:07:36 -070051#define H4_ETHR_GPIO_IRQ 92
52
Tony Lindgren9b6553c2006-04-02 17:46:30 +010053static unsigned int row_gpios[6] = { 88, 89, 124, 11, 6, 96 };
54static unsigned int col_gpios[7] = { 90, 91, 100, 36, 12, 97, 98 };
55
Janusz Krzysztofikda1f0262010-12-20 21:09:22 +000056static const unsigned int h4_keymap[] = {
Tony Lindgren9b6553c2006-04-02 17:46:30 +010057 KEY(0, 0, KEY_LEFT),
Janusz Krzysztofikda1f0262010-12-20 21:09:22 +000058 KEY(1, 0, KEY_RIGHT),
59 KEY(2, 0, KEY_A),
60 KEY(3, 0, KEY_B),
61 KEY(4, 0, KEY_C),
62 KEY(0, 1, KEY_DOWN),
Tony Lindgren9b6553c2006-04-02 17:46:30 +010063 KEY(1, 1, KEY_UP),
Janusz Krzysztofikda1f0262010-12-20 21:09:22 +000064 KEY(2, 1, KEY_E),
65 KEY(3, 1, KEY_F),
66 KEY(4, 1, KEY_G),
67 KEY(0, 2, KEY_ENTER),
68 KEY(1, 2, KEY_I),
Tony Lindgren9b6553c2006-04-02 17:46:30 +010069 KEY(2, 2, KEY_J),
Janusz Krzysztofikda1f0262010-12-20 21:09:22 +000070 KEY(3, 2, KEY_K),
71 KEY(4, 2, KEY_3),
72 KEY(0, 3, KEY_M),
73 KEY(1, 3, KEY_N),
74 KEY(2, 3, KEY_O),
Tony Lindgren9b6553c2006-04-02 17:46:30 +010075 KEY(3, 3, KEY_P),
Janusz Krzysztofikda1f0262010-12-20 21:09:22 +000076 KEY(4, 3, KEY_Q),
77 KEY(0, 4, KEY_R),
78 KEY(1, 4, KEY_4),
79 KEY(2, 4, KEY_T),
80 KEY(3, 4, KEY_U),
Tony Lindgren9b6553c2006-04-02 17:46:30 +010081 KEY(4, 4, KEY_ENTER),
Janusz Krzysztofikda1f0262010-12-20 21:09:22 +000082 KEY(0, 5, KEY_V),
83 KEY(1, 5, KEY_W),
84 KEY(2, 5, KEY_L),
85 KEY(3, 5, KEY_S),
86 KEY(4, 5, KEY_ENTER),
Tony Lindgren9b6553c2006-04-02 17:46:30 +010087};
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
Janusz Krzysztofikda1f0262010-12-20 21:09:22 +0000140static const struct matrix_keymap_data h4_keymap_data = {
141 .keymap = h4_keymap,
142 .keymap_size = ARRAY_SIZE(h4_keymap),
143};
144
Tony Lindgren9b6553c2006-04-02 17:46:30 +0100145static struct omap_kp_platform_data h4_kp_data = {
146 .rows = 6,
147 .cols = 7,
Janusz Krzysztofikda1f0262010-12-20 21:09:22 +0000148 .keymap_data = &h4_keymap_data,
149 .rep = true,
Tony Lindgren9b6553c2006-04-02 17:46:30 +0100150 .row_gpios = row_gpios,
151 .col_gpios = col_gpios,
152};
153
154static struct platform_device h4_kp_device = {
155 .name = "omap-keypad",
156 .id = -1,
157 .dev = {
158 .platform_data = &h4_kp_data,
159 },
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,
Tomi Valkeinencbf14552011-05-09 10:12:42 +0300165};
166
167static struct panel_generic_dpi_data h4_panel_data = {
168 .name = "h4",
169};
170
171static struct omap_dss_device h4_lcd_device = {
172 .name = "lcd",
173 .driver_name = "generic_dpi_panel",
174 .type = OMAP_DISPLAY_TYPE_DPI,
175 .phy.dpi.data_lines = 16,
176 .data = &h4_panel_data,
177};
178
179static struct omap_dss_device *h4_dss_devices[] = {
Tony Lindgren9b6553c2006-04-02 17:46:30 +0100180 &h4_lcd_device,
Tony Lindgren1dbae812005-11-10 14:26:51 +0000181};
182
Tomi Valkeinencbf14552011-05-09 10:12:42 +0300183static struct omap_dss_board_info h4_dss_data = {
184 .num_devices = ARRAY_SIZE(h4_dss_devices),
185 .devices = h4_dss_devices,
186 .default_device = &h4_lcd_device,
187};
188
Paul Walmsley44595982008-03-18 10:04:51 +0200189/* 2420 Sysboot setup (2430 is different) */
190static u32 get_sysboot_value(void)
191{
192 return (omap_ctrl_readl(OMAP24XX_CONTROL_STATUS) &
193 (OMAP2_SYSBOOT_5_MASK | OMAP2_SYSBOOT_4_MASK |
194 OMAP2_SYSBOOT_3_MASK | OMAP2_SYSBOOT_2_MASK |
195 OMAP2_SYSBOOT_1_MASK | OMAP2_SYSBOOT_0_MASK));
196}
197
198/* H4-2420's always used muxed mode, H4-2422's always use non-muxed
199 *
200 * Note: OMAP-GIT doesn't correctly do is_cpu_omap2422 and is_cpu_omap2423
201 * correctly. The macro needs to look at production_id not just hawkeye.
202 */
203static u32 is_gpmc_muxed(void)
204{
205 u32 mux;
206 mux = get_sysboot_value();
207 if ((mux & 0xF) == 0xd)
208 return 1; /* NAND config (could be either) */
209 if (mux & 0x2) /* if mux'ed */
210 return 1;
211 else
212 return 0;
213}
214
David Brownellf6049312006-12-06 17:14:03 -0800215static inline void __init h4_init_debug(void)
Tony Lindgren1dbae812005-11-10 14:26:51 +0000216{
Paul Walmsley44595982008-03-18 10:04:51 +0200217 int eth_cs;
218 unsigned long cs_mem_base;
219 unsigned int muxed, rate;
220 struct clk *gpmc_fck;
221
222 eth_cs = H4_SMC91X_CS;
223
224 gpmc_fck = clk_get(NULL, "gpmc_fck"); /* Always on ENABLE_ON_INIT */
225 if (IS_ERR(gpmc_fck)) {
226 WARN_ON(1);
227 return;
228 }
229
230 clk_enable(gpmc_fck);
231 rate = clk_get_rate(gpmc_fck);
232 clk_disable(gpmc_fck);
233 clk_put(gpmc_fck);
234
235 if (is_gpmc_muxed())
236 muxed = 0x200;
237 else
238 muxed = 0;
239
Tony Lindgren1dbae812005-11-10 14:26:51 +0000240 /* Make sure CS1 timings are correct */
Paul Walmsley44595982008-03-18 10:04:51 +0200241 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG1,
242 0x00011000 | muxed);
243
244 if (rate >= 160000000) {
245 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG2, 0x001f1f01);
246 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG3, 0x00080803);
247 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG4, 0x1c0b1c0a);
248 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG5, 0x041f1F1F);
249 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG6, 0x000004C4);
250 } else if (rate >= 130000000) {
251 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG2, 0x001f1f00);
252 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG3, 0x00080802);
253 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG4, 0x1C091C09);
254 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG5, 0x041f1F1F);
255 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG6, 0x000004C4);
256 } else {/* rate = 100000000 */
257 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG2, 0x001f1f00);
258 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG3, 0x00080802);
259 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG4, 0x1C091C09);
260 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG5, 0x031A1F1F);
261 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG6, 0x000003C2);
262 }
263
264 if (gpmc_cs_request(eth_cs, SZ_16M, &cs_mem_base) < 0) {
265 printk(KERN_ERR "Failed to request GPMC mem for smc91x\n");
266 goto out;
267 }
268
Tony Lindgren1dbae812005-11-10 14:26:51 +0000269 udelay(100);
270
Tony Lindgrenf99bf162010-07-05 16:31:40 +0300271 omap_mux_init_gpio(92, 0);
Tony Lindgren40662d772009-03-23 18:07:36 -0700272 if (debug_card_init(cs_mem_base, H4_ETHR_GPIO_IRQ) < 0)
David Brownellf6049312006-12-06 17:14:03 -0800273 gpmc_cs_free(eth_cs);
Paul Walmsley44595982008-03-18 10:04:51 +0200274
275out:
276 clk_disable(gpmc_fck);
277 clk_put(gpmc_fck);
278}
279
280static void __init h4_init_flash(void)
281{
282 unsigned long base;
283
284 if (gpmc_cs_request(H4_FLASH_CS, SZ_64M, &base) < 0) {
285 printk("Can't request GPMC CS for flash\n");
286 return;
287 }
288 h4_flash_resource.start = base;
289 h4_flash_resource.end = base + SZ_64M - 1;
Tony Lindgren1dbae812005-11-10 14:26:51 +0000290}
291
Felipe Balbib0b5aa32009-03-23 18:07:49 -0700292static struct omap_usb_config h4_usb_config __initdata = {
Felipe Balbib0b5aa32009-03-23 18:07:49 -0700293 /* S1.10 OFF -- usb "download port"
294 * usb0 switched to Mini-B port and isp1105 transceiver;
295 * S2.POS3 = ON, S2.POS4 = OFF ... to enable battery charging
296 */
297 .register_dev = 1,
298 .pins[0] = 3,
299/* .hmc_mode = 0x14,*/ /* 0:dev 1:host 2:disable */
300 .hmc_mode = 0x00, /* 0:dev|otg 1:disable 2:disable */
Felipe Balbib0b5aa32009-03-23 18:07:49 -0700301};
302
David Brownell6a769ed2008-12-10 17:36:33 -0800303static struct at24_platform_data m24c01 = {
304 .byte_len = SZ_1K / 8,
305 .page_size = 16,
306};
307
Jean Delvare9df013b2008-10-14 17:30:02 +0200308static struct i2c_board_info __initdata h4_i2c_board_info[] = {
309 {
310 I2C_BOARD_INFO("isp1301_omap", 0x2d),
311 .irq = OMAP_GPIO_IRQ(125),
312 },
David Brownell6a769ed2008-12-10 17:36:33 -0800313 { /* EEPROM on mainboard */
314 I2C_BOARD_INFO("24c01", 0x52),
315 .platform_data = &m24c01,
316 },
317 { /* EEPROM on cpu card */
318 I2C_BOARD_INFO("24c01", 0x57),
319 .platform_data = &m24c01,
320 },
Jean Delvare9df013b2008-10-14 17:30:02 +0200321};
322
Tony Lindgren23275d42010-07-05 16:31:37 +0300323#ifdef CONFIG_OMAP_MUX
324static struct omap_board_mux board_mux[] __initdata = {
325 { .reg_offset = OMAP_MUX_TERMINATOR },
326};
Tony Lindgren23275d42010-07-05 16:31:37 +0300327#endif
328
Tony Lindgren1dbae812005-11-10 14:26:51 +0000329static void __init omap_h4_init(void)
330{
Tony Lindgren23275d42010-07-05 16:31:37 +0300331 omap2420_mux_init(board_mux, OMAP_PACKAGE_ZAF);
332
Tony Lindgren1dbae812005-11-10 14:26:51 +0000333 /*
334 * Make sure the serial ports are muxed on at this point.
335 * You have to mux them off in device drivers later on
336 * if not needed.
337 */
Tony Lindgren9b6553c2006-04-02 17:46:30 +0100338
339#if defined(CONFIG_KEYBOARD_OMAP) || defined(CONFIG_KEYBOARD_OMAP_MODULE)
Tony Lindgren93c43f22010-07-05 16:31:39 +0300340 omap_mux_init_gpio(88, OMAP_PULL_ENA | OMAP_PULL_UP);
341 omap_mux_init_gpio(89, OMAP_PULL_ENA | OMAP_PULL_UP);
342 omap_mux_init_gpio(124, OMAP_PULL_ENA | OMAP_PULL_UP);
343 omap_mux_init_signal("mcbsp2_dr.gpio_11", OMAP_PULL_ENA | OMAP_PULL_UP);
Tony Lindgren9b6553c2006-04-02 17:46:30 +0100344 if (omap_has_menelaus()) {
Tony Lindgren93c43f22010-07-05 16:31:39 +0300345 omap_mux_init_signal("sdrc_a14.gpio0",
346 OMAP_PULL_ENA | OMAP_PULL_UP);
347 omap_mux_init_signal("vlynq_rx0.gpio_15", 0);
348 omap_mux_init_signal("gpio_98", 0);
Tony Lindgren9b6553c2006-04-02 17:46:30 +0100349 row_gpios[5] = 0;
350 col_gpios[2] = 15;
351 col_gpios[6] = 18;
Tony Lindgren93c43f22010-07-05 16:31:39 +0300352 } else {
353 omap_mux_init_signal("gpio_96", OMAP_PULL_ENA | OMAP_PULL_UP);
354 omap_mux_init_signal("gpio_100", 0);
355 omap_mux_init_signal("gpio_98", 0);
Tony Lindgren9b6553c2006-04-02 17:46:30 +0100356 }
Tony Lindgren93c43f22010-07-05 16:31:39 +0300357 omap_mux_init_signal("gpio_90", 0);
358 omap_mux_init_signal("gpio_91", 0);
359 omap_mux_init_signal("gpio_36", 0);
360 omap_mux_init_signal("mcbsp2_clkx.gpio_12", 0);
361 omap_mux_init_signal("gpio_97", 0);
Tony Lindgren9b6553c2006-04-02 17:46:30 +0100362#endif
363
Jean Delvare9df013b2008-10-14 17:30:02 +0200364 i2c_register_board_info(1, h4_i2c_board_info,
365 ARRAY_SIZE(h4_i2c_board_info));
366
Tony Lindgren1dbae812005-11-10 14:26:51 +0000367 platform_add_devices(h4_devices, ARRAY_SIZE(h4_devices));
Tony Lindgrenb5e89052010-07-05 16:31:29 +0300368 omap2_usbfs_init(&h4_usb_config);
Tony Lindgren1dbae812005-11-10 14:26:51 +0000369 omap_serial_init();
Tony Lindgrena4ca9db2011-08-22 23:57:23 -0700370 omap_sdrc_init(NULL, NULL);
Tony Lindgren42924352011-03-10 09:51:29 -0800371 h4_init_flash();
Tomi Valkeinencbf14552011-05-09 10:12:42 +0300372
373 omap_display_init(&h4_dss_data);
Tony Lindgren1dbae812005-11-10 14:26:51 +0000374}
375
Tony Lindgren1dbae812005-11-10 14:26:51 +0000376MACHINE_START(OMAP_H4, "OMAP2420 H4 board")
377 /* Maintainer: Paul Mundt <paul.mundt@nokia.com> */
Nicolas Pitre5e52b432011-07-05 22:38:15 -0400378 .atag_offset = 0x100,
Russell King71ee7da2010-05-23 10:18:16 +0100379 .reserve = omap_reserve,
Tony Lindgrene990a402011-09-26 14:52:55 -0700380 .map_io = omap242x_map_io,
Tony Lindgren8f5b5a42011-08-22 23:57:24 -0700381 .init_early = omap2420_init_early,
Tony Lindgrenbe732462011-09-26 15:25:22 -0700382 .init_irq = omap2_init_irq,
Tony Lindgren1dbae812005-11-10 14:26:51 +0000383 .init_machine = omap_h4_init,
Tony Lindgrene74984e2011-03-29 15:54:48 -0700384 .timer = &omap2_timer,
Tony Lindgren1dbae812005-11-10 14:26:51 +0000385MACHINE_END