blob: f7c09de2ed1c3d49103c7ee814b353a3d775768c [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
Tomi Valkeinencbf14552011-05-09 10:12:42 +030043#include <video/omapdss.h>
44#include <video/omap-panel-generic-dpi.h>
45
Tony Lindgren23275d42010-07-05 16:31:37 +030046#include "mux.h"
Paul Walmsley4814ced2010-10-08 11:40:20 -060047#include "control.h"
Tony Lindgren23275d42010-07-05 16:31:37 +030048
Paul Walmsley44595982008-03-18 10:04:51 +020049#define H4_FLASH_CS 0
50#define H4_SMC91X_CS 1
51
Tony Lindgren40662d772009-03-23 18:07:36 -070052#define H4_ETHR_GPIO_IRQ 92
53
Tony Lindgren9b6553c2006-04-02 17:46:30 +010054static unsigned int row_gpios[6] = { 88, 89, 124, 11, 6, 96 };
55static unsigned int col_gpios[7] = { 90, 91, 100, 36, 12, 97, 98 };
56
Janusz Krzysztofikda1f0262010-12-20 21:09:22 +000057static const unsigned int h4_keymap[] = {
Tony Lindgren9b6553c2006-04-02 17:46:30 +010058 KEY(0, 0, KEY_LEFT),
Janusz Krzysztofikda1f0262010-12-20 21:09:22 +000059 KEY(1, 0, KEY_RIGHT),
60 KEY(2, 0, KEY_A),
61 KEY(3, 0, KEY_B),
62 KEY(4, 0, KEY_C),
63 KEY(0, 1, KEY_DOWN),
Tony Lindgren9b6553c2006-04-02 17:46:30 +010064 KEY(1, 1, KEY_UP),
Janusz Krzysztofikda1f0262010-12-20 21:09:22 +000065 KEY(2, 1, KEY_E),
66 KEY(3, 1, KEY_F),
67 KEY(4, 1, KEY_G),
68 KEY(0, 2, KEY_ENTER),
69 KEY(1, 2, KEY_I),
Tony Lindgren9b6553c2006-04-02 17:46:30 +010070 KEY(2, 2, KEY_J),
Janusz Krzysztofikda1f0262010-12-20 21:09:22 +000071 KEY(3, 2, KEY_K),
72 KEY(4, 2, KEY_3),
73 KEY(0, 3, KEY_M),
74 KEY(1, 3, KEY_N),
75 KEY(2, 3, KEY_O),
Tony Lindgren9b6553c2006-04-02 17:46:30 +010076 KEY(3, 3, KEY_P),
Janusz Krzysztofikda1f0262010-12-20 21:09:22 +000077 KEY(4, 3, KEY_Q),
78 KEY(0, 4, KEY_R),
79 KEY(1, 4, KEY_4),
80 KEY(2, 4, KEY_T),
81 KEY(3, 4, KEY_U),
Tony Lindgren9b6553c2006-04-02 17:46:30 +010082 KEY(4, 4, KEY_ENTER),
Janusz Krzysztofikda1f0262010-12-20 21:09:22 +000083 KEY(0, 5, KEY_V),
84 KEY(1, 5, KEY_W),
85 KEY(2, 5, KEY_L),
86 KEY(3, 5, KEY_S),
87 KEY(4, 5, KEY_ENTER),
Tony Lindgren9b6553c2006-04-02 17:46:30 +010088};
89
Tony Lindgren1dbae812005-11-10 14:26:51 +000090static struct mtd_partition h4_partitions[] = {
91 /* bootloader (U-Boot, etc) in first sector */
92 {
93 .name = "bootloader",
94 .offset = 0,
95 .size = SZ_128K,
96 .mask_flags = MTD_WRITEABLE, /* force read-only */
97 },
98 /* bootloader params in the next sector */
99 {
100 .name = "params",
101 .offset = MTDPART_OFS_APPEND,
102 .size = SZ_128K,
103 .mask_flags = 0,
104 },
105 /* kernel */
106 {
107 .name = "kernel",
108 .offset = MTDPART_OFS_APPEND,
109 .size = SZ_2M,
110 .mask_flags = 0
111 },
112 /* file system */
113 {
114 .name = "filesystem",
115 .offset = MTDPART_OFS_APPEND,
116 .size = MTDPART_SIZ_FULL,
117 .mask_flags = 0
118 }
119};
120
Ladislav Michl561b0362010-02-15 10:03:32 -0800121static struct physmap_flash_data h4_flash_data = {
Tony Lindgren1dbae812005-11-10 14:26:51 +0000122 .width = 2,
123 .parts = h4_partitions,
124 .nr_parts = ARRAY_SIZE(h4_partitions),
125};
126
127static struct resource h4_flash_resource = {
Tony Lindgren1dbae812005-11-10 14:26:51 +0000128 .flags = IORESOURCE_MEM,
129};
130
131static struct platform_device h4_flash_device = {
Ladislav Michl561b0362010-02-15 10:03:32 -0800132 .name = "physmap-flash",
Tony Lindgren1dbae812005-11-10 14:26:51 +0000133 .id = 0,
134 .dev = {
135 .platform_data = &h4_flash_data,
136 },
137 .num_resources = 1,
138 .resource = &h4_flash_resource,
139};
140
Janusz Krzysztofikda1f0262010-12-20 21:09:22 +0000141static const struct matrix_keymap_data h4_keymap_data = {
142 .keymap = h4_keymap,
143 .keymap_size = ARRAY_SIZE(h4_keymap),
144};
145
Tony Lindgren9b6553c2006-04-02 17:46:30 +0100146static struct omap_kp_platform_data h4_kp_data = {
147 .rows = 6,
148 .cols = 7,
Janusz Krzysztofikda1f0262010-12-20 21:09:22 +0000149 .keymap_data = &h4_keymap_data,
150 .rep = true,
Tony Lindgren9b6553c2006-04-02 17:46:30 +0100151 .row_gpios = row_gpios,
152 .col_gpios = col_gpios,
153};
154
155static struct platform_device h4_kp_device = {
156 .name = "omap-keypad",
157 .id = -1,
158 .dev = {
159 .platform_data = &h4_kp_data,
160 },
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,
Tomi Valkeinencbf14552011-05-09 10:12:42 +0300166};
167
168static struct panel_generic_dpi_data h4_panel_data = {
169 .name = "h4",
170};
171
172static struct omap_dss_device h4_lcd_device = {
173 .name = "lcd",
174 .driver_name = "generic_dpi_panel",
175 .type = OMAP_DISPLAY_TYPE_DPI,
176 .phy.dpi.data_lines = 16,
177 .data = &h4_panel_data,
178};
179
180static struct omap_dss_device *h4_dss_devices[] = {
Tony Lindgren9b6553c2006-04-02 17:46:30 +0100181 &h4_lcd_device,
Tony Lindgren1dbae812005-11-10 14:26:51 +0000182};
183
Tomi Valkeinencbf14552011-05-09 10:12:42 +0300184static struct omap_dss_board_info h4_dss_data = {
185 .num_devices = ARRAY_SIZE(h4_dss_devices),
186 .devices = h4_dss_devices,
187 .default_device = &h4_lcd_device,
188};
189
Paul Walmsley44595982008-03-18 10:04:51 +0200190/* 2420 Sysboot setup (2430 is different) */
191static u32 get_sysboot_value(void)
192{
193 return (omap_ctrl_readl(OMAP24XX_CONTROL_STATUS) &
194 (OMAP2_SYSBOOT_5_MASK | OMAP2_SYSBOOT_4_MASK |
195 OMAP2_SYSBOOT_3_MASK | OMAP2_SYSBOOT_2_MASK |
196 OMAP2_SYSBOOT_1_MASK | OMAP2_SYSBOOT_0_MASK));
197}
198
199/* H4-2420's always used muxed mode, H4-2422's always use non-muxed
200 *
201 * Note: OMAP-GIT doesn't correctly do is_cpu_omap2422 and is_cpu_omap2423
202 * correctly. The macro needs to look at production_id not just hawkeye.
203 */
204static u32 is_gpmc_muxed(void)
205{
206 u32 mux;
207 mux = get_sysboot_value();
208 if ((mux & 0xF) == 0xd)
209 return 1; /* NAND config (could be either) */
210 if (mux & 0x2) /* if mux'ed */
211 return 1;
212 else
213 return 0;
214}
215
David Brownellf6049312006-12-06 17:14:03 -0800216static inline void __init h4_init_debug(void)
Tony Lindgren1dbae812005-11-10 14:26:51 +0000217{
Paul Walmsley44595982008-03-18 10:04:51 +0200218 int eth_cs;
219 unsigned long cs_mem_base;
220 unsigned int muxed, rate;
221 struct clk *gpmc_fck;
222
223 eth_cs = H4_SMC91X_CS;
224
225 gpmc_fck = clk_get(NULL, "gpmc_fck"); /* Always on ENABLE_ON_INIT */
226 if (IS_ERR(gpmc_fck)) {
227 WARN_ON(1);
228 return;
229 }
230
231 clk_enable(gpmc_fck);
232 rate = clk_get_rate(gpmc_fck);
233 clk_disable(gpmc_fck);
234 clk_put(gpmc_fck);
235
236 if (is_gpmc_muxed())
237 muxed = 0x200;
238 else
239 muxed = 0;
240
Tony Lindgren1dbae812005-11-10 14:26:51 +0000241 /* Make sure CS1 timings are correct */
Paul Walmsley44595982008-03-18 10:04:51 +0200242 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG1,
243 0x00011000 | muxed);
244
245 if (rate >= 160000000) {
246 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG2, 0x001f1f01);
247 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG3, 0x00080803);
248 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG4, 0x1c0b1c0a);
249 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG5, 0x041f1F1F);
250 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG6, 0x000004C4);
251 } else if (rate >= 130000000) {
252 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG2, 0x001f1f00);
253 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG3, 0x00080802);
254 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG4, 0x1C091C09);
255 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG5, 0x041f1F1F);
256 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG6, 0x000004C4);
257 } else {/* rate = 100000000 */
258 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG2, 0x001f1f00);
259 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG3, 0x00080802);
260 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG4, 0x1C091C09);
261 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG5, 0x031A1F1F);
262 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG6, 0x000003C2);
263 }
264
265 if (gpmc_cs_request(eth_cs, SZ_16M, &cs_mem_base) < 0) {
266 printk(KERN_ERR "Failed to request GPMC mem for smc91x\n");
267 goto out;
268 }
269
Tony Lindgren1dbae812005-11-10 14:26:51 +0000270 udelay(100);
271
Tony Lindgrenf99bf162010-07-05 16:31:40 +0300272 omap_mux_init_gpio(92, 0);
Tony Lindgren40662d772009-03-23 18:07:36 -0700273 if (debug_card_init(cs_mem_base, H4_ETHR_GPIO_IRQ) < 0)
David Brownellf6049312006-12-06 17:14:03 -0800274 gpmc_cs_free(eth_cs);
Paul Walmsley44595982008-03-18 10:04:51 +0200275
276out:
277 clk_disable(gpmc_fck);
278 clk_put(gpmc_fck);
279}
280
281static void __init h4_init_flash(void)
282{
283 unsigned long base;
284
285 if (gpmc_cs_request(H4_FLASH_CS, SZ_64M, &base) < 0) {
286 printk("Can't request GPMC CS for flash\n");
287 return;
288 }
289 h4_flash_resource.start = base;
290 h4_flash_resource.end = base + SZ_64M - 1;
Tony Lindgren1dbae812005-11-10 14:26:51 +0000291}
292
Felipe Balbib0b5aa32009-03-23 18:07:49 -0700293static struct omap_usb_config h4_usb_config __initdata = {
Felipe Balbib0b5aa32009-03-23 18:07:49 -0700294 /* S1.10 OFF -- usb "download port"
295 * usb0 switched to Mini-B port and isp1105 transceiver;
296 * S2.POS3 = ON, S2.POS4 = OFF ... to enable battery charging
297 */
298 .register_dev = 1,
299 .pins[0] = 3,
300/* .hmc_mode = 0x14,*/ /* 0:dev 1:host 2:disable */
301 .hmc_mode = 0x00, /* 0:dev|otg 1:disable 2:disable */
Felipe Balbib0b5aa32009-03-23 18:07:49 -0700302};
303
Russell King - ARM Linux3dc3bad2011-02-14 15:40:20 -0800304static void __init omap_h4_init_early(void)
Paul Walmsleyb3c6df32009-09-03 20:14:02 +0300305{
Paul Walmsley48057342010-12-21 15:25:10 -0700306 omap2_init_common_infrastructure();
307 omap2_init_common_devices(NULL, NULL);
Russell King - ARM Linux3dc3bad2011-02-14 15:40:20 -0800308}
309
310static void __init omap_h4_init_irq(void)
311{
Tony Lindgren741e3a82011-05-17 03:51:26 -0700312 omap2_init_irq();
Paul Walmsleyb3c6df32009-09-03 20:14:02 +0300313}
314
David Brownell6a769ed2008-12-10 17:36:33 -0800315static struct at24_platform_data m24c01 = {
316 .byte_len = SZ_1K / 8,
317 .page_size = 16,
318};
319
Jean Delvare9df013b2008-10-14 17:30:02 +0200320static struct i2c_board_info __initdata h4_i2c_board_info[] = {
321 {
322 I2C_BOARD_INFO("isp1301_omap", 0x2d),
323 .irq = OMAP_GPIO_IRQ(125),
324 },
David Brownell6a769ed2008-12-10 17:36:33 -0800325 { /* EEPROM on mainboard */
326 I2C_BOARD_INFO("24c01", 0x52),
327 .platform_data = &m24c01,
328 },
329 { /* EEPROM on cpu card */
330 I2C_BOARD_INFO("24c01", 0x57),
331 .platform_data = &m24c01,
332 },
Jean Delvare9df013b2008-10-14 17:30:02 +0200333};
334
Tony Lindgren23275d42010-07-05 16:31:37 +0300335#ifdef CONFIG_OMAP_MUX
336static struct omap_board_mux board_mux[] __initdata = {
337 { .reg_offset = OMAP_MUX_TERMINATOR },
338};
Tony Lindgren23275d42010-07-05 16:31:37 +0300339#endif
340
Tony Lindgren1dbae812005-11-10 14:26:51 +0000341static void __init omap_h4_init(void)
342{
Tony Lindgren23275d42010-07-05 16:31:37 +0300343 omap2420_mux_init(board_mux, OMAP_PACKAGE_ZAF);
344
Tony Lindgren1dbae812005-11-10 14:26:51 +0000345 /*
346 * Make sure the serial ports are muxed on at this point.
347 * You have to mux them off in device drivers later on
348 * if not needed.
349 */
Tony Lindgren9b6553c2006-04-02 17:46:30 +0100350
351#if defined(CONFIG_KEYBOARD_OMAP) || defined(CONFIG_KEYBOARD_OMAP_MODULE)
Tony Lindgren93c43f22010-07-05 16:31:39 +0300352 omap_mux_init_gpio(88, OMAP_PULL_ENA | OMAP_PULL_UP);
353 omap_mux_init_gpio(89, OMAP_PULL_ENA | OMAP_PULL_UP);
354 omap_mux_init_gpio(124, OMAP_PULL_ENA | OMAP_PULL_UP);
355 omap_mux_init_signal("mcbsp2_dr.gpio_11", OMAP_PULL_ENA | OMAP_PULL_UP);
Tony Lindgren9b6553c2006-04-02 17:46:30 +0100356 if (omap_has_menelaus()) {
Tony Lindgren93c43f22010-07-05 16:31:39 +0300357 omap_mux_init_signal("sdrc_a14.gpio0",
358 OMAP_PULL_ENA | OMAP_PULL_UP);
359 omap_mux_init_signal("vlynq_rx0.gpio_15", 0);
360 omap_mux_init_signal("gpio_98", 0);
Tony Lindgren9b6553c2006-04-02 17:46:30 +0100361 row_gpios[5] = 0;
362 col_gpios[2] = 15;
363 col_gpios[6] = 18;
Tony Lindgren93c43f22010-07-05 16:31:39 +0300364 } else {
365 omap_mux_init_signal("gpio_96", OMAP_PULL_ENA | OMAP_PULL_UP);
366 omap_mux_init_signal("gpio_100", 0);
367 omap_mux_init_signal("gpio_98", 0);
Tony Lindgren9b6553c2006-04-02 17:46:30 +0100368 }
Tony Lindgren93c43f22010-07-05 16:31:39 +0300369 omap_mux_init_signal("gpio_90", 0);
370 omap_mux_init_signal("gpio_91", 0);
371 omap_mux_init_signal("gpio_36", 0);
372 omap_mux_init_signal("mcbsp2_clkx.gpio_12", 0);
373 omap_mux_init_signal("gpio_97", 0);
Tony Lindgren9b6553c2006-04-02 17:46:30 +0100374#endif
375
Jean Delvare9df013b2008-10-14 17:30:02 +0200376 i2c_register_board_info(1, h4_i2c_board_info,
377 ARRAY_SIZE(h4_i2c_board_info));
378
Tony Lindgren1dbae812005-11-10 14:26:51 +0000379 platform_add_devices(h4_devices, ARRAY_SIZE(h4_devices));
Tony Lindgrenb5e89052010-07-05 16:31:29 +0300380 omap2_usbfs_init(&h4_usb_config);
Tony Lindgren1dbae812005-11-10 14:26:51 +0000381 omap_serial_init();
Tony Lindgren42924352011-03-10 09:51:29 -0800382 h4_init_flash();
Tomi Valkeinencbf14552011-05-09 10:12:42 +0300383
384 omap_display_init(&h4_dss_data);
Tony Lindgren1dbae812005-11-10 14:26:51 +0000385}
386
387static void __init omap_h4_map_io(void)
388{
Paul Walmsleyc8d2eb82008-05-07 16:55:13 -0700389 omap2_set_globals_242x();
Tony Lindgren6fbd55d2010-02-12 12:26:47 -0800390 omap242x_map_common_io();
Tony Lindgren1dbae812005-11-10 14:26:51 +0000391}
392
393MACHINE_START(OMAP_H4, "OMAP2420 H4 board")
394 /* Maintainer: Paul Mundt <paul.mundt@nokia.com> */
Tony Lindgren1dbae812005-11-10 14:26:51 +0000395 .boot_params = 0x80000100,
Russell King71ee7da2010-05-23 10:18:16 +0100396 .reserve = omap_reserve,
Russell King - ARM Linux3dc3bad2011-02-14 15:40:20 -0800397 .map_io = omap_h4_map_io,
398 .init_early = omap_h4_init_early,
Tony Lindgren1dbae812005-11-10 14:26:51 +0000399 .init_irq = omap_h4_init_irq,
400 .init_machine = omap_h4_init,
Tony Lindgrene74984e2011-03-29 15:54:48 -0700401 .timer = &omap2_timer,
Tony Lindgren1dbae812005-11-10 14:26:51 +0000402MACHINE_END