Commit | Line | Data |
---|---|---|
e1d9b953 | 1 | /* |
2 | * linux/arch/arm/mach-pxa/littleton.c | |
3 | * | |
4 | * Support for the Marvell Littleton Development Platform. | |
5 | * | |
6 | * Author: Jason Chagas (largely modified code) | |
7 | * Created: Nov 20, 2006 | |
8 | * Copyright: (C) Copyright 2006 Marvell International Ltd. | |
9 | * | |
10 | * 2007-11-22 modified to align with latest kernel | |
11 | * eric miao <eric.miao@marvell.com> | |
12 | * | |
13 | * This program is free software; you can redistribute it and/or modify | |
14 | * it under the terms of the GNU General Public License version 2 as | |
15 | * publishhed by the Free Software Foundation. | |
16 | */ | |
17 | ||
18 | #include <linux/init.h> | |
19 | #include <linux/interrupt.h> | |
20 | #include <linux/delay.h> | |
21 | #include <linux/platform_device.h> | |
22 | #include <linux/clk.h> | |
80796f2a | 23 | #include <linux/gpio.h> |
24ff4cdd | 24 | #include <linux/spi/spi.h> |
e1719da6 | 25 | #include <linux/smc91x.h> |
3b24f30c EM |
26 | #include <linux/i2c.h> |
27 | #include <linux/leds.h> | |
28 | #include <linux/mfd/da903x.h> | |
29 | #include <linux/i2c/max732x.h> | |
e1d9b953 | 30 | |
31 | #include <asm/types.h> | |
32 | #include <asm/setup.h> | |
33 | #include <asm/memory.h> | |
34 | #include <asm/mach-types.h> | |
a09e64fb | 35 | #include <mach/hardware.h> |
e1d9b953 | 36 | #include <asm/irq.h> |
37 | ||
38 | #include <asm/mach/arch.h> | |
39 | #include <asm/mach/map.h> | |
40 | #include <asm/mach/irq.h> | |
41 | ||
a09e64fb RK |
42 | #include <mach/pxa-regs.h> |
43 | #include <mach/mfp-pxa300.h> | |
a09e64fb RK |
44 | #include <mach/pxafb.h> |
45 | #include <mach/ssp.h> | |
24ff4cdd | 46 | #include <mach/pxa2xx_spi.h> |
3b24f30c | 47 | #include <mach/i2c.h> |
a09e64fb RK |
48 | #include <mach/pxa27x_keypad.h> |
49 | #include <mach/pxa3xx_nand.h> | |
50 | #include <mach/littleton.h> | |
e1d9b953 | 51 | |
52 | #include "generic.h" | |
53 | ||
e1d9b953 | 54 | /* Littleton MFP configurations */ |
55 | static mfp_cfg_t littleton_mfp_cfg[] __initdata = { | |
56 | /* LCD */ | |
57 | GPIO54_LCD_LDD_0, | |
58 | GPIO55_LCD_LDD_1, | |
59 | GPIO56_LCD_LDD_2, | |
60 | GPIO57_LCD_LDD_3, | |
61 | GPIO58_LCD_LDD_4, | |
62 | GPIO59_LCD_LDD_5, | |
63 | GPIO60_LCD_LDD_6, | |
64 | GPIO61_LCD_LDD_7, | |
65 | GPIO62_LCD_LDD_8, | |
66 | GPIO63_LCD_LDD_9, | |
67 | GPIO64_LCD_LDD_10, | |
68 | GPIO65_LCD_LDD_11, | |
69 | GPIO66_LCD_LDD_12, | |
70 | GPIO67_LCD_LDD_13, | |
71 | GPIO68_LCD_LDD_14, | |
72 | GPIO69_LCD_LDD_15, | |
73 | GPIO70_LCD_LDD_16, | |
74 | GPIO71_LCD_LDD_17, | |
75 | GPIO72_LCD_FCLK, | |
76 | GPIO73_LCD_LCLK, | |
77 | GPIO74_LCD_PCLK, | |
78 | GPIO75_LCD_BIAS, | |
79 | ||
80 | /* SSP2 */ | |
81 | GPIO25_SSP2_SCLK, | |
e1d9b953 | 82 | GPIO27_SSP2_TXD, |
24ff4cdd | 83 | GPIO17_GPIO, /* SFRM as chip-select */ |
e1d9b953 | 84 | |
85 | /* Debug Ethernet */ | |
86 | GPIO90_GPIO, | |
5fa41510 | 87 | |
88 | /* Keypad */ | |
89 | GPIO107_KP_DKIN_0, | |
90 | GPIO108_KP_DKIN_1, | |
91 | GPIO115_KP_MKIN_0, | |
92 | GPIO116_KP_MKIN_1, | |
93 | GPIO117_KP_MKIN_2, | |
94 | GPIO118_KP_MKIN_3, | |
95 | GPIO119_KP_MKIN_4, | |
96 | GPIO120_KP_MKIN_5, | |
97 | GPIO121_KP_MKOUT_0, | |
98 | GPIO122_KP_MKOUT_1, | |
99 | GPIO123_KP_MKOUT_2, | |
100 | GPIO124_KP_MKOUT_3, | |
101 | GPIO125_KP_MKOUT_4, | |
e1d9b953 | 102 | }; |
103 | ||
104 | static struct resource smc91x_resources[] = { | |
105 | [0] = { | |
106 | .start = (LITTLETON_ETH_PHYS + 0x300), | |
107 | .end = (LITTLETON_ETH_PHYS + 0xfffff), | |
108 | .flags = IORESOURCE_MEM, | |
109 | }, | |
110 | [1] = { | |
111 | .start = IRQ_GPIO(mfp_to_gpio(MFP_PIN_GPIO90)), | |
112 | .end = IRQ_GPIO(mfp_to_gpio(MFP_PIN_GPIO90)), | |
8a6e8873 | 113 | .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWEDGE, |
e1d9b953 | 114 | } |
115 | }; | |
116 | ||
e1719da6 EM |
117 | static struct smc91x_platdata littleton_smc91x_info = { |
118 | .flags = SMC91X_USE_8BIT | SMC91X_USE_16BIT | | |
119 | SMC91X_NOWAIT | SMC91X_USE_DMA, | |
120 | }; | |
121 | ||
e1d9b953 | 122 | static struct platform_device smc91x_device = { |
123 | .name = "smc91x", | |
124 | .id = 0, | |
125 | .num_resources = ARRAY_SIZE(smc91x_resources), | |
126 | .resource = smc91x_resources, | |
e1719da6 EM |
127 | .dev = { |
128 | .platform_data = &littleton_smc91x_info, | |
129 | }, | |
e1d9b953 | 130 | }; |
131 | ||
36caeb4e | 132 | #if defined(CONFIG_FB_PXA) || defined(CONFIG_FB_PXA_MODULE) |
e1d9b953 | 133 | static struct pxafb_mode_info tpo_tdo24mtea1_modes[] = { |
134 | [0] = { | |
135 | /* VGA */ | |
136 | .pixclock = 38250, | |
137 | .xres = 480, | |
138 | .yres = 640, | |
139 | .bpp = 16, | |
140 | .hsync_len = 8, | |
141 | .left_margin = 8, | |
142 | .right_margin = 24, | |
143 | .vsync_len = 2, | |
144 | .upper_margin = 2, | |
145 | .lower_margin = 4, | |
146 | .sync = 0, | |
147 | }, | |
148 | [1] = { | |
149 | /* QVGA */ | |
150 | .pixclock = 153000, | |
151 | .xres = 240, | |
152 | .yres = 320, | |
153 | .bpp = 16, | |
154 | .hsync_len = 8, | |
155 | .left_margin = 8, | |
156 | .right_margin = 88, | |
157 | .vsync_len = 2, | |
158 | .upper_margin = 2, | |
159 | .lower_margin = 2, | |
160 | .sync = 0, | |
161 | }, | |
162 | }; | |
163 | ||
164 | static struct pxafb_mach_info littleton_lcd_info = { | |
165 | .modes = tpo_tdo24mtea1_modes, | |
166 | .num_modes = 2, | |
0454bd09 | 167 | .lcd_conn = LCD_COLOR_TFT_16BPP, |
e1d9b953 | 168 | }; |
169 | ||
170 | static void littleton_init_lcd(void) | |
171 | { | |
172 | set_pxa_fb_info(&littleton_lcd_info); | |
173 | } | |
174 | #else | |
175 | static inline void littleton_init_lcd(void) {}; | |
36caeb4e | 176 | #endif /* CONFIG_FB_PXA || CONFIG_FB_PXA_MODULE */ |
e1d9b953 | 177 | |
24ff4cdd EM |
178 | #if defined(CONFIG_SPI_PXA2XX) || defined(CONFIG_SPI_PXA2XX_MODULE) |
179 | static struct pxa2xx_spi_master littleton_spi_info = { | |
180 | .num_chipselect = 1, | |
181 | }; | |
182 | ||
183 | static void littleton_tdo24m_cs(u32 cmd) | |
184 | { | |
185 | gpio_set_value(LITTLETON_GPIO_LCD_CS, !(cmd == PXA2XX_CS_ASSERT)); | |
186 | } | |
187 | ||
188 | static struct pxa2xx_spi_chip littleton_tdo24m_chip = { | |
189 | .rx_threshold = 1, | |
190 | .tx_threshold = 1, | |
191 | .cs_control = littleton_tdo24m_cs, | |
192 | }; | |
193 | ||
194 | static struct spi_board_info littleton_spi_devices[] __initdata = { | |
195 | { | |
196 | .modalias = "tdo24m", | |
197 | .max_speed_hz = 1000000, | |
198 | .bus_num = 2, | |
199 | .chip_select = 0, | |
200 | .controller_data= &littleton_tdo24m_chip, | |
201 | }, | |
202 | }; | |
203 | ||
204 | static void __init littleton_init_spi(void) | |
205 | { | |
206 | int err; | |
207 | ||
208 | err = gpio_request(LITTLETON_GPIO_LCD_CS, "LCD_CS"); | |
209 | if (err) { | |
210 | pr_warning("failed to request GPIO for LCS CS\n"); | |
211 | return; | |
212 | } | |
213 | ||
214 | gpio_direction_output(LITTLETON_GPIO_LCD_CS, 1); | |
215 | ||
216 | pxa2xx_set_spi_info(2, &littleton_spi_info); | |
217 | spi_register_board_info(ARRAY_AND_SIZE(littleton_spi_devices)); | |
218 | } | |
219 | #else | |
220 | static inline void littleton_init_spi(void) {} | |
221 | #endif | |
222 | ||
36caeb4e | 223 | #if defined(CONFIG_KEYBOARD_PXA27x) || defined(CONFIG_KEYBOARD_PXA27x_MODULE) |
5fa41510 | 224 | static unsigned int littleton_matrix_key_map[] = { |
225 | /* KEY(row, col, key_code) */ | |
226 | KEY(1, 3, KEY_0), KEY(0, 0, KEY_1), KEY(1, 0, KEY_2), KEY(2, 0, KEY_3), | |
227 | KEY(0, 1, KEY_4), KEY(1, 1, KEY_5), KEY(2, 1, KEY_6), KEY(0, 2, KEY_7), | |
228 | KEY(1, 2, KEY_8), KEY(2, 2, KEY_9), | |
229 | ||
230 | KEY(0, 3, KEY_KPASTERISK), /* * */ | |
231 | KEY(2, 3, KEY_KPDOT), /* # */ | |
232 | ||
233 | KEY(5, 4, KEY_ENTER), | |
234 | ||
235 | KEY(5, 0, KEY_UP), | |
236 | KEY(5, 1, KEY_DOWN), | |
237 | KEY(5, 2, KEY_LEFT), | |
238 | KEY(5, 3, KEY_RIGHT), | |
239 | KEY(3, 2, KEY_HOME), | |
240 | KEY(4, 1, KEY_END), | |
241 | KEY(3, 3, KEY_BACK), | |
242 | ||
243 | KEY(4, 0, KEY_SEND), | |
244 | KEY(4, 2, KEY_VOLUMEUP), | |
245 | KEY(4, 3, KEY_VOLUMEDOWN), | |
246 | ||
247 | KEY(3, 0, KEY_F22), /* soft1 */ | |
248 | KEY(3, 1, KEY_F23), /* soft2 */ | |
249 | }; | |
250 | ||
251 | static struct pxa27x_keypad_platform_data littleton_keypad_info = { | |
252 | .matrix_key_rows = 6, | |
253 | .matrix_key_cols = 5, | |
254 | .matrix_key_map = littleton_matrix_key_map, | |
255 | .matrix_key_map_size = ARRAY_SIZE(littleton_matrix_key_map), | |
256 | ||
257 | .enable_rotary0 = 1, | |
258 | .rotary0_up_key = KEY_UP, | |
259 | .rotary0_down_key = KEY_DOWN, | |
260 | ||
261 | .debounce_interval = 30, | |
262 | }; | |
263 | static void __init littleton_init_keypad(void) | |
264 | { | |
265 | pxa_set_keypad_info(&littleton_keypad_info); | |
266 | } | |
267 | #else | |
268 | static inline void littleton_init_keypad(void) {} | |
269 | #endif | |
270 | ||
9c1db1a1 EM |
271 | #if defined(CONFIG_MTD_NAND_PXA3xx) || defined(CONFIG_MTD_NAND_PXA3xx_MODULE) |
272 | static struct mtd_partition littleton_nand_partitions[] = { | |
273 | [0] = { | |
274 | .name = "Bootloader", | |
275 | .offset = 0, | |
276 | .size = 0x060000, | |
277 | .mask_flags = MTD_WRITEABLE, /* force read-only */ | |
278 | }, | |
279 | [1] = { | |
280 | .name = "Kernel", | |
281 | .offset = 0x060000, | |
282 | .size = 0x200000, | |
283 | .mask_flags = MTD_WRITEABLE, /* force read-only */ | |
284 | }, | |
285 | [2] = { | |
286 | .name = "Filesystem", | |
287 | .offset = 0x0260000, | |
288 | .size = 0x3000000, /* 48M - rootfs */ | |
289 | }, | |
290 | [3] = { | |
291 | .name = "MassStorage", | |
292 | .offset = 0x3260000, | |
293 | .size = 0x3d40000, | |
294 | }, | |
295 | [4] = { | |
296 | .name = "BBT", | |
297 | .offset = 0x6FA0000, | |
298 | .size = 0x80000, | |
299 | .mask_flags = MTD_WRITEABLE, /* force read-only */ | |
300 | }, | |
301 | /* NOTE: we reserve some blocks at the end of the NAND flash for | |
302 | * bad block management, and the max number of relocation blocks | |
303 | * differs on different platforms. Please take care with it when | |
304 | * defining the partition table. | |
305 | */ | |
306 | }; | |
307 | ||
308 | static struct pxa3xx_nand_platform_data littleton_nand_info = { | |
309 | .enable_arbiter = 1, | |
310 | .parts = littleton_nand_partitions, | |
311 | .nr_parts = ARRAY_SIZE(littleton_nand_partitions), | |
312 | }; | |
313 | ||
314 | static void __init littleton_init_nand(void) | |
315 | { | |
316 | pxa3xx_set_nand_info(&littleton_nand_info); | |
317 | } | |
318 | #else | |
319 | static inline void littleton_init_nand(void) {} | |
320 | #endif /* CONFIG_MTD_NAND_PXA3xx || CONFIG_MTD_NAND_PXA3xx_MODULE */ | |
321 | ||
3b24f30c EM |
322 | #if defined(CONFIG_I2C_PXA) || defined(CONFIG_I2C_PXA_MODULE) |
323 | static struct led_info littleton_da9034_leds[] = { | |
324 | [0] = { | |
325 | .name = "littleton:keypad1", | |
326 | .flags = DA9034_LED_RAMP, | |
327 | }, | |
328 | [1] = { | |
329 | .name = "littleton:keypad2", | |
330 | .flags = DA9034_LED_RAMP, | |
331 | }, | |
332 | [2] = { | |
333 | .name = "littleton:vibra", | |
334 | .flags = 0, | |
335 | }, | |
336 | }; | |
337 | ||
338 | static struct da903x_subdev_info littleton_da9034_subdevs[] = { | |
339 | { | |
340 | .name = "da903x-led", | |
341 | .id = DA9034_ID_LED_1, | |
342 | .platform_data = &littleton_da9034_leds[0], | |
343 | }, { | |
344 | .name = "da903x-led", | |
345 | .id = DA9034_ID_LED_2, | |
346 | .platform_data = &littleton_da9034_leds[1], | |
347 | }, { | |
348 | .name = "da903x-led", | |
349 | .id = DA9034_ID_VIBRA, | |
350 | .platform_data = &littleton_da9034_leds[2], | |
351 | }, { | |
352 | .name = "da903x-backlight", | |
353 | .id = DA9034_ID_WLED, | |
354 | }, | |
355 | }; | |
356 | ||
357 | static struct da903x_platform_data littleton_da9034_info = { | |
358 | .num_subdevs = ARRAY_SIZE(littleton_da9034_subdevs), | |
359 | .subdevs = littleton_da9034_subdevs, | |
360 | }; | |
361 | ||
362 | static struct max732x_platform_data littleton_max7320_info = { | |
363 | .gpio_base = EXT0_GPIO_BASE, | |
364 | }; | |
365 | ||
366 | static struct i2c_board_info littleton_i2c_info[] = { | |
367 | [0] = { | |
368 | .type = "da9034", | |
369 | .addr = 0x34, | |
370 | .platform_data = &littleton_da9034_info, | |
371 | .irq = gpio_to_irq(mfp_to_gpio(MFP_PIN_GPIO18)), | |
372 | }, | |
373 | [1] = { | |
374 | .type = "max7320", | |
375 | .addr = 0x50, | |
376 | .platform_data = &littleton_max7320_info, | |
377 | }, | |
378 | }; | |
379 | ||
380 | static void __init littleton_init_i2c(void) | |
381 | { | |
382 | pxa_set_i2c_info(NULL); | |
383 | i2c_register_board_info(0, ARRAY_AND_SIZE(littleton_i2c_info)); | |
384 | } | |
385 | #else | |
386 | static inline void littleton_init_i2c(void) {} | |
387 | #endif /* CONFIG_I2C_PXA || CONFIG_I2C_PXA_MODULE */ | |
388 | ||
e1d9b953 | 389 | static void __init littleton_init(void) |
390 | { | |
391 | /* initialize MFP configurations */ | |
392 | pxa3xx_mfp_config(ARRAY_AND_SIZE(littleton_mfp_cfg)); | |
393 | ||
394 | /* | |
395 | * Note: we depend bootloader set the correct | |
396 | * value to MSC register for SMC91x. | |
397 | */ | |
398 | platform_device_register(&smc91x_device); | |
399 | ||
24ff4cdd | 400 | littleton_init_spi(); |
3b24f30c | 401 | littleton_init_i2c(); |
e1d9b953 | 402 | littleton_init_lcd(); |
5fa41510 | 403 | littleton_init_keypad(); |
9c1db1a1 | 404 | littleton_init_nand(); |
e1d9b953 | 405 | } |
406 | ||
407 | MACHINE_START(LITTLETON, "Marvell Form Factor Development Platform (aka Littleton)") | |
408 | .phys_io = 0x40000000, | |
409 | .boot_params = 0xa0000100, | |
410 | .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc, | |
411 | .map_io = pxa_map_io, | |
412 | .init_irq = pxa3xx_init_irq, | |
413 | .timer = &pxa_timer, | |
414 | .init_machine = littleton_init, | |
415 | MACHINE_END |