Commit | Line | Data |
---|---|---|
1dbae815 | 1 | /* |
f30c2269 | 2 | * linux/arch/arm/mach-omap2/board-h4.c |
1dbae815 TL |
3 | * |
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> | |
561b036a | 19 | #include <linux/mtd/physmap.h> |
1dbae815 | 20 | #include <linux/delay.h> |
9b6553cd | 21 | #include <linux/workqueue.h> |
9df013b3 | 22 | #include <linux/i2c.h> |
6a769ed4 | 23 | #include <linux/i2c/at24.h> |
9b6553cd | 24 | #include <linux/input.h> |
44595982 PW |
25 | #include <linux/err.h> |
26 | #include <linux/clk.h> | |
fced80c7 | 27 | #include <linux/io.h> |
1dbae815 | 28 | |
a09e64fb | 29 | #include <mach/hardware.h> |
1dbae815 TL |
30 | #include <asm/mach-types.h> |
31 | #include <asm/mach/arch.h> | |
32 | #include <asm/mach/map.h> | |
1dbae815 | 33 | |
ce491cf8 | 34 | #include <plat/control.h> |
a09e64fb | 35 | #include <mach/gpio.h> |
ce491cf8 TL |
36 | #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> | |
1dbae815 | 44 | |
44595982 PW |
45 | #define H4_FLASH_CS 0 |
46 | #define H4_SMC91X_CS 1 | |
47 | ||
40662d77 TL |
48 | #define H4_ETHR_GPIO_IRQ 92 |
49 | ||
9b6553cd TL |
50 | static unsigned int row_gpios[6] = { 88, 89, 124, 11, 6, 96 }; |
51 | static unsigned int col_gpios[7] = { 90, 91, 100, 36, 12, 97, 98 }; | |
52 | ||
53 | static int h4_keymap[] = { | |
54 | KEY(0, 0, KEY_LEFT), | |
55 | KEY(0, 1, KEY_RIGHT), | |
56 | KEY(0, 2, KEY_A), | |
57 | KEY(0, 3, KEY_B), | |
58 | KEY(0, 4, KEY_C), | |
59 | KEY(1, 0, KEY_DOWN), | |
60 | KEY(1, 1, KEY_UP), | |
61 | KEY(1, 2, KEY_E), | |
62 | KEY(1, 3, KEY_F), | |
63 | KEY(1, 4, KEY_G), | |
64 | KEY(2, 0, KEY_ENTER), | |
65 | KEY(2, 1, KEY_I), | |
66 | KEY(2, 2, KEY_J), | |
67 | KEY(2, 3, KEY_K), | |
68 | KEY(2, 4, KEY_3), | |
69 | KEY(3, 0, KEY_M), | |
70 | KEY(3, 1, KEY_N), | |
71 | KEY(3, 2, KEY_O), | |
72 | KEY(3, 3, KEY_P), | |
73 | KEY(3, 4, KEY_Q), | |
74 | KEY(4, 0, KEY_R), | |
75 | KEY(4, 1, KEY_4), | |
76 | KEY(4, 2, KEY_T), | |
77 | KEY(4, 3, KEY_U), | |
78 | KEY(4, 4, KEY_ENTER), | |
79 | KEY(5, 0, KEY_V), | |
80 | KEY(5, 1, KEY_W), | |
81 | KEY(5, 2, KEY_L), | |
82 | KEY(5, 3, KEY_S), | |
83 | KEY(5, 4, KEY_ENTER), | |
84 | 0 | |
85 | }; | |
86 | ||
1dbae815 TL |
87 | static struct mtd_partition h4_partitions[] = { |
88 | /* bootloader (U-Boot, etc) in first sector */ | |
89 | { | |
90 | .name = "bootloader", | |
91 | .offset = 0, | |
92 | .size = SZ_128K, | |
93 | .mask_flags = MTD_WRITEABLE, /* force read-only */ | |
94 | }, | |
95 | /* bootloader params in the next sector */ | |
96 | { | |
97 | .name = "params", | |
98 | .offset = MTDPART_OFS_APPEND, | |
99 | .size = SZ_128K, | |
100 | .mask_flags = 0, | |
101 | }, | |
102 | /* kernel */ | |
103 | { | |
104 | .name = "kernel", | |
105 | .offset = MTDPART_OFS_APPEND, | |
106 | .size = SZ_2M, | |
107 | .mask_flags = 0 | |
108 | }, | |
109 | /* file system */ | |
110 | { | |
111 | .name = "filesystem", | |
112 | .offset = MTDPART_OFS_APPEND, | |
113 | .size = MTDPART_SIZ_FULL, | |
114 | .mask_flags = 0 | |
115 | } | |
116 | }; | |
117 | ||
561b036a | 118 | static struct physmap_flash_data h4_flash_data = { |
1dbae815 TL |
119 | .width = 2, |
120 | .parts = h4_partitions, | |
121 | .nr_parts = ARRAY_SIZE(h4_partitions), | |
122 | }; | |
123 | ||
124 | static struct resource h4_flash_resource = { | |
1dbae815 TL |
125 | .flags = IORESOURCE_MEM, |
126 | }; | |
127 | ||
128 | static struct platform_device h4_flash_device = { | |
561b036a | 129 | .name = "physmap-flash", |
1dbae815 TL |
130 | .id = 0, |
131 | .dev = { | |
132 | .platform_data = &h4_flash_data, | |
133 | }, | |
134 | .num_resources = 1, | |
135 | .resource = &h4_flash_resource, | |
136 | }; | |
137 | ||
9b6553cd TL |
138 | static struct omap_kp_platform_data h4_kp_data = { |
139 | .rows = 6, | |
140 | .cols = 7, | |
141 | .keymap = h4_keymap, | |
4d24607b | 142 | .keymapsize = ARRAY_SIZE(h4_keymap), |
9b6553cd TL |
143 | .rep = 1, |
144 | .row_gpios = row_gpios, | |
145 | .col_gpios = col_gpios, | |
146 | }; | |
147 | ||
148 | static struct platform_device h4_kp_device = { | |
149 | .name = "omap-keypad", | |
150 | .id = -1, | |
151 | .dev = { | |
152 | .platform_data = &h4_kp_data, | |
153 | }, | |
154 | }; | |
155 | ||
156 | static struct platform_device h4_lcd_device = { | |
157 | .name = "lcd_h4", | |
158 | .id = -1, | |
159 | }; | |
160 | ||
1dbae815 | 161 | static struct platform_device *h4_devices[] __initdata = { |
1dbae815 | 162 | &h4_flash_device, |
9b6553cd TL |
163 | &h4_kp_device, |
164 | &h4_lcd_device, | |
1dbae815 TL |
165 | }; |
166 | ||
44595982 PW |
167 | /* 2420 Sysboot setup (2430 is different) */ |
168 | static u32 get_sysboot_value(void) | |
169 | { | |
170 | return (omap_ctrl_readl(OMAP24XX_CONTROL_STATUS) & | |
171 | (OMAP2_SYSBOOT_5_MASK | OMAP2_SYSBOOT_4_MASK | | |
172 | OMAP2_SYSBOOT_3_MASK | OMAP2_SYSBOOT_2_MASK | | |
173 | OMAP2_SYSBOOT_1_MASK | OMAP2_SYSBOOT_0_MASK)); | |
174 | } | |
175 | ||
176 | /* H4-2420's always used muxed mode, H4-2422's always use non-muxed | |
177 | * | |
178 | * Note: OMAP-GIT doesn't correctly do is_cpu_omap2422 and is_cpu_omap2423 | |
179 | * correctly. The macro needs to look at production_id not just hawkeye. | |
180 | */ | |
181 | static u32 is_gpmc_muxed(void) | |
182 | { | |
183 | u32 mux; | |
184 | mux = get_sysboot_value(); | |
185 | if ((mux & 0xF) == 0xd) | |
186 | return 1; /* NAND config (could be either) */ | |
187 | if (mux & 0x2) /* if mux'ed */ | |
188 | return 1; | |
189 | else | |
190 | return 0; | |
191 | } | |
192 | ||
f6049312 | 193 | static inline void __init h4_init_debug(void) |
1dbae815 | 194 | { |
44595982 PW |
195 | int eth_cs; |
196 | unsigned long cs_mem_base; | |
197 | unsigned int muxed, rate; | |
198 | struct clk *gpmc_fck; | |
199 | ||
200 | eth_cs = H4_SMC91X_CS; | |
201 | ||
202 | gpmc_fck = clk_get(NULL, "gpmc_fck"); /* Always on ENABLE_ON_INIT */ | |
203 | if (IS_ERR(gpmc_fck)) { | |
204 | WARN_ON(1); | |
205 | return; | |
206 | } | |
207 | ||
208 | clk_enable(gpmc_fck); | |
209 | rate = clk_get_rate(gpmc_fck); | |
210 | clk_disable(gpmc_fck); | |
211 | clk_put(gpmc_fck); | |
212 | ||
213 | if (is_gpmc_muxed()) | |
214 | muxed = 0x200; | |
215 | else | |
216 | muxed = 0; | |
217 | ||
1dbae815 | 218 | /* Make sure CS1 timings are correct */ |
44595982 PW |
219 | gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG1, |
220 | 0x00011000 | muxed); | |
221 | ||
222 | if (rate >= 160000000) { | |
223 | gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG2, 0x001f1f01); | |
224 | gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG3, 0x00080803); | |
225 | gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG4, 0x1c0b1c0a); | |
226 | gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG5, 0x041f1F1F); | |
227 | gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG6, 0x000004C4); | |
228 | } else if (rate >= 130000000) { | |
229 | gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG2, 0x001f1f00); | |
230 | gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG3, 0x00080802); | |
231 | gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG4, 0x1C091C09); | |
232 | gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG5, 0x041f1F1F); | |
233 | gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG6, 0x000004C4); | |
234 | } else {/* rate = 100000000 */ | |
235 | gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG2, 0x001f1f00); | |
236 | gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG3, 0x00080802); | |
237 | gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG4, 0x1C091C09); | |
238 | gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG5, 0x031A1F1F); | |
239 | gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG6, 0x000003C2); | |
240 | } | |
241 | ||
242 | if (gpmc_cs_request(eth_cs, SZ_16M, &cs_mem_base) < 0) { | |
243 | printk(KERN_ERR "Failed to request GPMC mem for smc91x\n"); | |
244 | goto out; | |
245 | } | |
246 | ||
1dbae815 TL |
247 | udelay(100); |
248 | ||
249 | omap_cfg_reg(M15_24XX_GPIO92); | |
40662d77 | 250 | if (debug_card_init(cs_mem_base, H4_ETHR_GPIO_IRQ) < 0) |
f6049312 | 251 | gpmc_cs_free(eth_cs); |
44595982 PW |
252 | |
253 | out: | |
254 | clk_disable(gpmc_fck); | |
255 | clk_put(gpmc_fck); | |
256 | } | |
257 | ||
258 | static void __init h4_init_flash(void) | |
259 | { | |
260 | unsigned long base; | |
261 | ||
262 | if (gpmc_cs_request(H4_FLASH_CS, SZ_64M, &base) < 0) { | |
263 | printk("Can't request GPMC CS for flash\n"); | |
264 | return; | |
265 | } | |
266 | h4_flash_resource.start = base; | |
267 | h4_flash_resource.end = base + SZ_64M - 1; | |
1dbae815 TL |
268 | } |
269 | ||
1dbae815 | 270 | static struct omap_lcd_config h4_lcd_config __initdata = { |
1dbae815 TL |
271 | .ctrl_name = "internal", |
272 | }; | |
273 | ||
b0b5aa3f FB |
274 | static struct omap_usb_config h4_usb_config __initdata = { |
275 | #ifdef CONFIG_MACH_OMAP2_H4_USB1 | |
276 | /* NOTE: usb1 could also be used with 3 wire signaling */ | |
277 | .pins[1] = 4, | |
278 | #endif | |
279 | ||
280 | #ifdef CONFIG_MACH_OMAP_H4_OTG | |
281 | /* S1.10 ON -- USB OTG port | |
282 | * usb0 switched to Mini-AB port and isp1301 transceiver; | |
283 | * S2.POS3 = OFF, S2.POS4 = ON ... to allow battery charging | |
284 | */ | |
285 | .otg = 1, | |
286 | .pins[0] = 4, | |
287 | #ifdef CONFIG_USB_GADGET_OMAP | |
288 | /* use OTG cable, or standard A-to-MiniB */ | |
289 | .hmc_mode = 0x14, /* 0:dev/otg 1:host 2:disable */ | |
290 | #elif defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE) | |
291 | /* use OTG cable, or NONSTANDARD (B-to-MiniB) */ | |
292 | .hmc_mode = 0x11, /* 0:host 1:host 2:disable */ | |
293 | #endif /* XX */ | |
294 | ||
295 | #else | |
296 | /* S1.10 OFF -- usb "download port" | |
297 | * usb0 switched to Mini-B port and isp1105 transceiver; | |
298 | * S2.POS3 = ON, S2.POS4 = OFF ... to enable battery charging | |
299 | */ | |
300 | .register_dev = 1, | |
301 | .pins[0] = 3, | |
302 | /* .hmc_mode = 0x14,*/ /* 0:dev 1:host 2:disable */ | |
303 | .hmc_mode = 0x00, /* 0:dev|otg 1:disable 2:disable */ | |
304 | #endif | |
305 | }; | |
306 | ||
1dbae815 | 307 | static struct omap_board_config_kernel h4_config[] = { |
1dbae815 TL |
308 | { OMAP_TAG_LCD, &h4_lcd_config }, |
309 | }; | |
310 | ||
b3c6df3a PW |
311 | static void __init omap_h4_init_irq(void) |
312 | { | |
313 | omap_board_config = h4_config; | |
314 | omap_board_config_size = ARRAY_SIZE(h4_config); | |
315 | omap2_init_common_hw(NULL, NULL); | |
316 | omap_init_irq(); | |
317 | omap_gpio_init(); | |
318 | h4_init_flash(); | |
319 | } | |
320 | ||
6a769ed4 DB |
321 | static struct at24_platform_data m24c01 = { |
322 | .byte_len = SZ_1K / 8, | |
323 | .page_size = 16, | |
324 | }; | |
325 | ||
9df013b3 JD |
326 | static struct i2c_board_info __initdata h4_i2c_board_info[] = { |
327 | { | |
328 | I2C_BOARD_INFO("isp1301_omap", 0x2d), | |
329 | .irq = OMAP_GPIO_IRQ(125), | |
330 | }, | |
6a769ed4 DB |
331 | { /* EEPROM on mainboard */ |
332 | I2C_BOARD_INFO("24c01", 0x52), | |
333 | .platform_data = &m24c01, | |
334 | }, | |
335 | { /* EEPROM on cpu card */ | |
336 | I2C_BOARD_INFO("24c01", 0x57), | |
337 | .platform_data = &m24c01, | |
338 | }, | |
9df013b3 JD |
339 | }; |
340 | ||
1dbae815 TL |
341 | static void __init omap_h4_init(void) |
342 | { | |
343 | /* | |
344 | * Make sure the serial ports are muxed on at this point. | |
345 | * You have to mux them off in device drivers later on | |
346 | * if not needed. | |
347 | */ | |
9b6553cd TL |
348 | #if defined(CONFIG_OMAP_IR) || defined(CONFIG_OMAP_IR_MODULE) |
349 | omap_cfg_reg(K15_24XX_UART3_TX); | |
350 | omap_cfg_reg(K14_24XX_UART3_RX); | |
351 | #endif | |
352 | ||
353 | #if defined(CONFIG_KEYBOARD_OMAP) || defined(CONFIG_KEYBOARD_OMAP_MODULE) | |
354 | if (omap_has_menelaus()) { | |
355 | row_gpios[5] = 0; | |
356 | col_gpios[2] = 15; | |
357 | col_gpios[6] = 18; | |
358 | } | |
359 | #endif | |
360 | ||
9df013b3 JD |
361 | i2c_register_board_info(1, h4_i2c_board_info, |
362 | ARRAY_SIZE(h4_i2c_board_info)); | |
363 | ||
1dbae815 | 364 | platform_add_devices(h4_devices, ARRAY_SIZE(h4_devices)); |
b0b5aa3f | 365 | omap_usb_init(&h4_usb_config); |
1dbae815 TL |
366 | omap_serial_init(); |
367 | } | |
368 | ||
369 | static void __init omap_h4_map_io(void) | |
370 | { | |
c8d2eb8e | 371 | omap2_set_globals_242x(); |
6fbd55d0 | 372 | omap242x_map_common_io(); |
1dbae815 TL |
373 | } |
374 | ||
375 | MACHINE_START(OMAP_H4, "OMAP2420 H4 board") | |
376 | /* Maintainer: Paul Mundt <paul.mundt@nokia.com> */ | |
1dbae815 | 377 | .phys_io = 0x48000000, |
b4224b23 | 378 | .io_pg_offst = ((0xfa000000) >> 18) & 0xfffc, |
1dbae815 TL |
379 | .boot_params = 0x80000100, |
380 | .map_io = omap_h4_map_io, | |
381 | .init_irq = omap_h4_init_irq, | |
382 | .init_machine = omap_h4_init, | |
383 | .timer = &omap_timer, | |
384 | MACHINE_END |