diff options
Diffstat (limited to 'arch/arm/mach-omap2/board-h4.c')
-rw-r--r-- | arch/arm/mach-omap2/board-h4.c | 111 |
1 files changed, 101 insertions, 10 deletions
diff --git a/arch/arm/mach-omap2/board-h4.c b/arch/arm/mach-omap2/board-h4.c index f125f432cc3e..d1915f99a5fa 100644 --- a/arch/arm/mach-omap2/board-h4.c +++ b/arch/arm/mach-omap2/board-h4.c | |||
@@ -19,6 +19,8 @@ | |||
19 | #include <linux/delay.h> | 19 | #include <linux/delay.h> |
20 | #include <linux/workqueue.h> | 20 | #include <linux/workqueue.h> |
21 | #include <linux/input.h> | 21 | #include <linux/input.h> |
22 | #include <linux/err.h> | ||
23 | #include <linux/clk.h> | ||
22 | 24 | ||
23 | #include <asm/hardware.h> | 25 | #include <asm/hardware.h> |
24 | #include <asm/mach-types.h> | 26 | #include <asm/mach-types.h> |
@@ -26,6 +28,7 @@ | |||
26 | #include <asm/mach/map.h> | 28 | #include <asm/mach/map.h> |
27 | #include <asm/mach/flash.h> | 29 | #include <asm/mach/flash.h> |
28 | 30 | ||
31 | #include <asm/arch/control.h> | ||
29 | #include <asm/arch/gpio.h> | 32 | #include <asm/arch/gpio.h> |
30 | #include <asm/arch/gpioexpander.h> | 33 | #include <asm/arch/gpioexpander.h> |
31 | #include <asm/arch/mux.h> | 34 | #include <asm/arch/mux.h> |
@@ -36,10 +39,13 @@ | |||
36 | #include <asm/arch/keypad.h> | 39 | #include <asm/arch/keypad.h> |
37 | #include <asm/arch/menelaus.h> | 40 | #include <asm/arch/menelaus.h> |
38 | #include <asm/arch/dma.h> | 41 | #include <asm/arch/dma.h> |
39 | #include "prcm-regs.h" | 42 | #include <asm/arch/gpmc.h> |
40 | 43 | ||
41 | #include <asm/io.h> | 44 | #include <asm/io.h> |
42 | 45 | ||
46 | #define H4_FLASH_CS 0 | ||
47 | #define H4_SMC91X_CS 1 | ||
48 | |||
43 | static unsigned int row_gpios[6] = { 88, 89, 124, 11, 6, 96 }; | 49 | static unsigned int row_gpios[6] = { 88, 89, 124, 11, 6, 96 }; |
44 | static unsigned int col_gpios[7] = { 90, 91, 100, 36, 12, 97, 98 }; | 50 | static unsigned int col_gpios[7] = { 90, 91, 100, 36, 12, 97, 98 }; |
45 | 51 | ||
@@ -116,8 +122,6 @@ static struct flash_platform_data h4_flash_data = { | |||
116 | }; | 122 | }; |
117 | 123 | ||
118 | static struct resource h4_flash_resource = { | 124 | static struct resource h4_flash_resource = { |
119 | .start = H4_CS0_BASE, | ||
120 | .end = H4_CS0_BASE + SZ_64M - 1, | ||
121 | .flags = IORESOURCE_MEM, | 125 | .flags = IORESOURCE_MEM, |
122 | }; | 126 | }; |
123 | 127 | ||
@@ -253,21 +257,107 @@ static struct platform_device *h4_devices[] __initdata = { | |||
253 | &h4_lcd_device, | 257 | &h4_lcd_device, |
254 | }; | 258 | }; |
255 | 259 | ||
260 | /* 2420 Sysboot setup (2430 is different) */ | ||
261 | static u32 get_sysboot_value(void) | ||
262 | { | ||
263 | return (omap_ctrl_readl(OMAP24XX_CONTROL_STATUS) & | ||
264 | (OMAP2_SYSBOOT_5_MASK | OMAP2_SYSBOOT_4_MASK | | ||
265 | OMAP2_SYSBOOT_3_MASK | OMAP2_SYSBOOT_2_MASK | | ||
266 | OMAP2_SYSBOOT_1_MASK | OMAP2_SYSBOOT_0_MASK)); | ||
267 | } | ||
268 | |||
269 | /* H4-2420's always used muxed mode, H4-2422's always use non-muxed | ||
270 | * | ||
271 | * Note: OMAP-GIT doesn't correctly do is_cpu_omap2422 and is_cpu_omap2423 | ||
272 | * correctly. The macro needs to look at production_id not just hawkeye. | ||
273 | */ | ||
274 | static u32 is_gpmc_muxed(void) | ||
275 | { | ||
276 | u32 mux; | ||
277 | mux = get_sysboot_value(); | ||
278 | if ((mux & 0xF) == 0xd) | ||
279 | return 1; /* NAND config (could be either) */ | ||
280 | if (mux & 0x2) /* if mux'ed */ | ||
281 | return 1; | ||
282 | else | ||
283 | return 0; | ||
284 | } | ||
285 | |||
256 | static inline void __init h4_init_debug(void) | 286 | static inline void __init h4_init_debug(void) |
257 | { | 287 | { |
288 | int eth_cs; | ||
289 | unsigned long cs_mem_base; | ||
290 | unsigned int muxed, rate; | ||
291 | struct clk *gpmc_fck; | ||
292 | |||
293 | eth_cs = H4_SMC91X_CS; | ||
294 | |||
295 | gpmc_fck = clk_get(NULL, "gpmc_fck"); /* Always on ENABLE_ON_INIT */ | ||
296 | if (IS_ERR(gpmc_fck)) { | ||
297 | WARN_ON(1); | ||
298 | return; | ||
299 | } | ||
300 | |||
301 | clk_enable(gpmc_fck); | ||
302 | rate = clk_get_rate(gpmc_fck); | ||
303 | clk_disable(gpmc_fck); | ||
304 | clk_put(gpmc_fck); | ||
305 | |||
306 | if (is_gpmc_muxed()) | ||
307 | muxed = 0x200; | ||
308 | else | ||
309 | muxed = 0; | ||
310 | |||
258 | /* Make sure CS1 timings are correct */ | 311 | /* Make sure CS1 timings are correct */ |
259 | GPMC_CONFIG1_1 = 0x00011200; | 312 | gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG1, |
260 | GPMC_CONFIG2_1 = 0x001f1f01; | 313 | 0x00011000 | muxed); |
261 | GPMC_CONFIG3_1 = 0x00080803; | 314 | |
262 | GPMC_CONFIG4_1 = 0x1c091c09; | 315 | if (rate >= 160000000) { |
263 | GPMC_CONFIG5_1 = 0x041f1f1f; | 316 | gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG2, 0x001f1f01); |
264 | GPMC_CONFIG6_1 = 0x000004c4; | 317 | gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG3, 0x00080803); |
265 | GPMC_CONFIG7_1 = 0x00000f40 | (0x08000000 >> 24); | 318 | gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG4, 0x1c0b1c0a); |
319 | gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG5, 0x041f1F1F); | ||
320 | gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG6, 0x000004C4); | ||
321 | } else if (rate >= 130000000) { | ||
322 | gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG2, 0x001f1f00); | ||
323 | gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG3, 0x00080802); | ||
324 | gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG4, 0x1C091C09); | ||
325 | gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG5, 0x041f1F1F); | ||
326 | gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG6, 0x000004C4); | ||
327 | } else {/* rate = 100000000 */ | ||
328 | gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG2, 0x001f1f00); | ||
329 | gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG3, 0x00080802); | ||
330 | gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG4, 0x1C091C09); | ||
331 | gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG5, 0x031A1F1F); | ||
332 | gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG6, 0x000003C2); | ||
333 | } | ||
334 | |||
335 | if (gpmc_cs_request(eth_cs, SZ_16M, &cs_mem_base) < 0) { | ||
336 | printk(KERN_ERR "Failed to request GPMC mem for smc91x\n"); | ||
337 | goto out; | ||
338 | } | ||
339 | |||
266 | udelay(100); | 340 | udelay(100); |
267 | 341 | ||
268 | omap_cfg_reg(M15_24XX_GPIO92); | 342 | omap_cfg_reg(M15_24XX_GPIO92); |
269 | if (debug_card_init(cs_mem_base, OMAP24XX_ETHR_GPIO_IRQ) < 0) | 343 | if (debug_card_init(cs_mem_base, OMAP24XX_ETHR_GPIO_IRQ) < 0) |
270 | gpmc_cs_free(eth_cs); | 344 | gpmc_cs_free(eth_cs); |
345 | |||
346 | out: | ||
347 | clk_disable(gpmc_fck); | ||
348 | clk_put(gpmc_fck); | ||
349 | } | ||
350 | |||
351 | static void __init h4_init_flash(void) | ||
352 | { | ||
353 | unsigned long base; | ||
354 | |||
355 | if (gpmc_cs_request(H4_FLASH_CS, SZ_64M, &base) < 0) { | ||
356 | printk("Can't request GPMC CS for flash\n"); | ||
357 | return; | ||
358 | } | ||
359 | h4_flash_resource.start = base; | ||
360 | h4_flash_resource.end = base + SZ_64M - 1; | ||
271 | } | 361 | } |
272 | 362 | ||
273 | static void __init omap_h4_init_irq(void) | 363 | static void __init omap_h4_init_irq(void) |
@@ -275,6 +365,7 @@ static void __init omap_h4_init_irq(void) | |||
275 | omap2_init_common_hw(); | 365 | omap2_init_common_hw(); |
276 | omap_init_irq(); | 366 | omap_init_irq(); |
277 | omap_gpio_init(); | 367 | omap_gpio_init(); |
368 | h4_init_flash(); | ||
278 | } | 369 | } |
279 | 370 | ||
280 | static struct omap_uart_config h4_uart_config __initdata = { | 371 | static struct omap_uart_config h4_uart_config __initdata = { |