Merge master.kernel.org:/pub/scm/linux/kernel/git/sam/kbuild
[sfrench/cifs-2.6.git] / arch / arm / mach-omap2 / board-h4.c
1 /*
2  * linux/arch/arm/mach-omap/omap2/board-h4.c
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>
19 #include <linux/delay.h>
20
21 #include <asm/hardware.h>
22 #include <asm/mach-types.h>
23 #include <asm/mach/arch.h>
24 #include <asm/mach/map.h>
25 #include <asm/mach/flash.h>
26
27 #include <asm/arch/gpio.h>
28 #include <asm/arch/mux.h>
29 #include <asm/arch/usb.h>
30 #include <asm/arch/board.h>
31 #include <asm/arch/common.h>
32 #include <asm/arch/prcm.h>
33
34 #include <asm/io.h>
35 #include <asm/delay.h>
36
37 static struct mtd_partition h4_partitions[] = {
38         /* bootloader (U-Boot, etc) in first sector */
39         {
40               .name             = "bootloader",
41               .offset           = 0,
42               .size             = SZ_128K,
43               .mask_flags       = MTD_WRITEABLE, /* force read-only */
44         },
45         /* bootloader params in the next sector */
46         {
47               .name             = "params",
48               .offset           = MTDPART_OFS_APPEND,
49               .size             = SZ_128K,
50               .mask_flags       = 0,
51         },
52         /* kernel */
53         {
54               .name             = "kernel",
55               .offset           = MTDPART_OFS_APPEND,
56               .size             = SZ_2M,
57               .mask_flags       = 0
58         },
59         /* file system */
60         {
61               .name             = "filesystem",
62               .offset           = MTDPART_OFS_APPEND,
63               .size             = MTDPART_SIZ_FULL,
64               .mask_flags       = 0
65         }
66 };
67
68 static struct flash_platform_data h4_flash_data = {
69         .map_name       = "cfi_probe",
70         .width          = 2,
71         .parts          = h4_partitions,
72         .nr_parts       = ARRAY_SIZE(h4_partitions),
73 };
74
75 static struct resource h4_flash_resource = {
76         .start          = H4_CS0_BASE,
77         .end            = H4_CS0_BASE + SZ_64M - 1,
78         .flags          = IORESOURCE_MEM,
79 };
80
81 static struct platform_device h4_flash_device = {
82         .name           = "omapflash",
83         .id             = 0,
84         .dev            = {
85                 .platform_data  = &h4_flash_data,
86         },
87         .num_resources  = 1,
88         .resource       = &h4_flash_resource,
89 };
90
91 static struct resource h4_smc91x_resources[] = {
92         [0] = {
93                 .start  = OMAP24XX_ETHR_START,          /* Physical */
94                 .end    = OMAP24XX_ETHR_START + 0xf,
95                 .flags  = IORESOURCE_MEM,
96         },
97         [1] = {
98                 .start  = OMAP_GPIO_IRQ(OMAP24XX_ETHR_GPIO_IRQ),
99                 .end    = OMAP_GPIO_IRQ(OMAP24XX_ETHR_GPIO_IRQ),
100                 .flags  = IORESOURCE_IRQ,
101         },
102 };
103
104 static struct platform_device h4_smc91x_device = {
105         .name           = "smc91x",
106         .id             = -1,
107         .num_resources  = ARRAY_SIZE(h4_smc91x_resources),
108         .resource       = h4_smc91x_resources,
109 };
110
111 static struct platform_device *h4_devices[] __initdata = {
112         &h4_smc91x_device,
113         &h4_flash_device,
114 };
115
116 static inline void __init h4_init_smc91x(void)
117 {
118         /* Make sure CS1 timings are correct */
119         GPMC_CONFIG1_1 = 0x00011200;
120         GPMC_CONFIG2_1 = 0x001f1f01;
121         GPMC_CONFIG3_1 = 0x00080803;
122         GPMC_CONFIG4_1 = 0x1c091c09;
123         GPMC_CONFIG5_1 = 0x041f1f1f;
124         GPMC_CONFIG6_1 = 0x000004c4;
125         GPMC_CONFIG7_1 = 0x00000f40 | (0x08000000 >> 24);
126         udelay(100);
127
128         omap_cfg_reg(M15_24XX_GPIO92);
129         if (omap_request_gpio(OMAP24XX_ETHR_GPIO_IRQ) < 0) {
130                 printk(KERN_ERR "Failed to request GPIO%d for smc91x IRQ\n",
131                         OMAP24XX_ETHR_GPIO_IRQ);
132                 return;
133         }
134         omap_set_gpio_direction(OMAP24XX_ETHR_GPIO_IRQ, 1);
135 }
136
137 static void __init omap_h4_init_irq(void)
138 {
139         omap_init_irq();
140         omap_gpio_init();
141         h4_init_smc91x();
142 }
143
144 static struct omap_uart_config h4_uart_config __initdata = {
145         .enabled_uarts = ((1 << 0) | (1 << 1) | (1 << 2)),
146 };
147
148 static struct omap_mmc_config h4_mmc_config __initdata = {
149         .mmc [0] = {
150                 .enabled        = 1,
151                 .wire4          = 1,
152                 .wp_pin         = -1,
153                 .power_pin      = -1,
154                 .switch_pin     = -1,
155         },
156 };
157
158 static struct omap_lcd_config h4_lcd_config __initdata = {
159         .panel_name     = "h4",
160         .ctrl_name      = "internal",
161 };
162
163 static struct omap_board_config_kernel h4_config[] = {
164         { OMAP_TAG_UART,        &h4_uart_config },
165         { OMAP_TAG_MMC,         &h4_mmc_config },
166         { OMAP_TAG_LCD,         &h4_lcd_config },
167 };
168
169 static void __init omap_h4_init(void)
170 {
171         /*
172          * Make sure the serial ports are muxed on at this point.
173          * You have to mux them off in device drivers later on
174          * if not needed.
175          */
176         platform_add_devices(h4_devices, ARRAY_SIZE(h4_devices));
177         omap_board_config = h4_config;
178         omap_board_config_size = ARRAY_SIZE(h4_config);
179         omap_serial_init();
180 }
181
182 static void __init omap_h4_map_io(void)
183 {
184         omap_map_common_io();
185 }
186
187 MACHINE_START(OMAP_H4, "OMAP2420 H4 board")
188         /* Maintainer: Paul Mundt <paul.mundt@nokia.com> */
189         .phys_ram       = 0x80000000,
190         .phys_io        = 0x48000000,
191         .io_pg_offst    = ((0xd8000000) >> 18) & 0xfffc,
192         .boot_params    = 0x80000100,
193         .map_io         = omap_h4_map_io,
194         .init_irq       = omap_h4_init_irq,
195         .init_machine   = omap_h4_init,
196         .timer          = &omap_timer,
197 MACHINE_END