blob: d70be75bd199552d63cbc7d851d9fbd39f87d4c4 [file] [log] [blame]
Philipp Zabele5c271e2007-11-22 17:59:11 +01001/*
2 * Support for HTC Magician PDA phones:
3 * i-mate JAM, O2 Xda mini, Orange SPV M500, Qtek s100, Qtek s110
4 * and T-Mobile MDA Compact.
5 *
6 * Copyright (c) 2006-2007 Philipp Zabel
7 *
8 * Based on hx4700.c, spitz.c and others.
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License version 2 as
12 * published by the Free Software Foundation.
13 *
14 */
15
16#include <linux/kernel.h>
17#include <linux/init.h>
18#include <linux/platform_device.h>
Philipp Zabele07ff8d82008-04-09 19:27:10 +010019#include <linux/delay.h>
Philipp Zabele5c271e2007-11-22 17:59:11 +010020#include <linux/gpio_keys.h>
21#include <linux/input.h>
Philipp Zabel70e357f2008-04-09 19:22:57 +010022#include <linux/mfd/htc-egpio.h>
Philipp Zabel81447b22008-04-12 13:28:02 +010023#include <linux/mfd/htc-pasic3.h>
Philipp Zabele5c271e2007-11-22 17:59:11 +010024#include <linux/mtd/mtd.h>
25#include <linux/mtd/map.h>
26#include <linux/mtd/physmap.h>
Philipp Zabel350d1152008-04-09 19:25:56 +010027#include <linux/pda_power.h>
Philipp Zabele5c271e2007-11-22 17:59:11 +010028
29#include <asm/gpio.h>
30#include <asm/hardware.h>
31#include <asm/mach-types.h>
32#include <asm/mach/arch.h>
33#include <asm/arch/magician.h>
Philipp Zabelb1682812008-04-12 13:29:22 +010034#include <asm/arch/mfp-pxa27x.h>
Philipp Zabele5c271e2007-11-22 17:59:11 +010035#include <asm/arch/pxa-regs.h>
36#include <asm/arch/pxafb.h>
Philipp Zabele6816f32008-04-09 19:14:15 +010037#include <asm/arch/i2c.h>
Philipp Zabelbdb0c162008-04-09 19:24:55 +010038#include <asm/arch/mmc.h>
Philipp Zabele5c271e2007-11-22 17:59:11 +010039#include <asm/arch/irda.h>
40#include <asm/arch/ohci.h>
41
42#include "generic.h"
43
Philipp Zabelb1682812008-04-12 13:29:22 +010044static unsigned long magician_pin_config[] = {
45
46 /* SDRAM and Static Memory I/O Signals */
47 GPIO20_nSDCS_2,
48 GPIO21_nSDCS_3,
49 GPIO15_nCS_1,
50 GPIO78_nCS_2, /* PASIC3 */
51 GPIO79_nCS_3, /* EGPIO CPLD */
52 GPIO80_nCS_4,
53 GPIO33_nCS_5,
54
55 /* I2C */
56 GPIO117_I2C_SCL,
57 GPIO118_I2C_SDA,
58
59 /* PWM 0 */
60 GPIO16_PWM0_OUT,
61
62 /* I2S */
63 GPIO28_I2S_BITCLK_OUT,
64 GPIO29_I2S_SDATA_IN,
65 GPIO31_I2S_SYNC,
66 GPIO113_I2S_SYSCLK,
67
68 /* SSP 2 */
69 GPIO19_SSP2_SCLK,
70 GPIO14_SSP2_SFRM,
71 GPIO89_SSP2_TXD,
72 GPIO88_SSP2_RXD,
73
74 /* MMC */
75 GPIO32_MMC_CLK,
76 GPIO92_MMC_DAT_0,
77 GPIO109_MMC_DAT_1,
78 GPIO110_MMC_DAT_2,
79 GPIO111_MMC_DAT_3,
80 GPIO112_MMC_CMD,
81
82 /* LCD */
83 GPIO58_LCD_LDD_0,
84 GPIO59_LCD_LDD_1,
85 GPIO60_LCD_LDD_2,
86 GPIO61_LCD_LDD_3,
87 GPIO62_LCD_LDD_4,
88 GPIO63_LCD_LDD_5,
89 GPIO64_LCD_LDD_6,
90 GPIO65_LCD_LDD_7,
91 GPIO66_LCD_LDD_8,
92 GPIO67_LCD_LDD_9,
93 GPIO68_LCD_LDD_10,
94 GPIO69_LCD_LDD_11,
95 GPIO70_LCD_LDD_12,
96 GPIO71_LCD_LDD_13,
97 GPIO72_LCD_LDD_14,
98 GPIO73_LCD_LDD_15,
99 GPIO74_LCD_FCLK,
100 GPIO75_LCD_LCLK,
101 GPIO76_LCD_PCLK,
102 GPIO77_LCD_BIAS,
103
104 /* QCI */
105 GPIO12_CIF_DD_7,
106 GPIO17_CIF_DD_6,
107 GPIO50_CIF_DD_3,
108 GPIO51_CIF_DD_2,
109 GPIO52_CIF_DD_4,
110 GPIO53_CIF_MCLK,
111 GPIO54_CIF_PCLK,
112 GPIO55_CIF_DD_1,
113 GPIO81_CIF_DD_0,
114 GPIO82_CIF_DD_5,
115 GPIO84_CIF_FV,
116 GPIO85_CIF_LV,
117};
118
Philipp Zabele5c271e2007-11-22 17:59:11 +0100119/*
120 * IRDA
121 */
122
123static void magician_irda_transceiver_mode(struct device *dev, int mode)
124{
125 gpio_set_value(GPIO83_MAGICIAN_nIR_EN, mode & IR_OFF);
126}
127
128static struct pxaficp_platform_data magician_ficp_info = {
129 .transceiver_cap = IR_SIRMODE | IR_OFF,
130 .transceiver_mode = magician_irda_transceiver_mode,
131};
132
133/*
134 * GPIO Keys
135 */
136
137static struct gpio_keys_button magician_button_table[] = {
138 {KEY_POWER, GPIO0_MAGICIAN_KEY_POWER, 0, "Power button"},
139 {KEY_ESC, GPIO37_MAGICIAN_KEY_HANGUP, 0, "Hangup button"},
140 {KEY_F10, GPIO38_MAGICIAN_KEY_CONTACTS, 0, "Contacts button"},
141 {KEY_CALENDAR, GPIO90_MAGICIAN_KEY_CALENDAR, 0, "Calendar button"},
142 {KEY_CAMERA, GPIO91_MAGICIAN_KEY_CAMERA, 0, "Camera button"},
143 {KEY_UP, GPIO93_MAGICIAN_KEY_UP, 0, "Up button"},
144 {KEY_DOWN, GPIO94_MAGICIAN_KEY_DOWN, 0, "Down button"},
145 {KEY_LEFT, GPIO95_MAGICIAN_KEY_LEFT, 0, "Left button"},
146 {KEY_RIGHT, GPIO96_MAGICIAN_KEY_RIGHT, 0, "Right button"},
147 {KEY_KPENTER, GPIO97_MAGICIAN_KEY_ENTER, 0, "Action button"},
148 {KEY_RECORD, GPIO98_MAGICIAN_KEY_RECORD, 0, "Record button"},
149 {KEY_VOLUMEUP, GPIO100_MAGICIAN_KEY_VOL_UP, 0, "Volume up"},
150 {KEY_VOLUMEDOWN, GPIO101_MAGICIAN_KEY_VOL_DOWN, 0, "Volume down"},
151 {KEY_PHONE, GPIO102_MAGICIAN_KEY_PHONE, 0, "Phone button"},
152 {KEY_PLAY, GPIO99_MAGICIAN_HEADPHONE_IN, 0, "Headset button"},
153};
154
155static struct gpio_keys_platform_data gpio_keys_data = {
156 .buttons = magician_button_table,
157 .nbuttons = ARRAY_SIZE(magician_button_table),
158};
159
160static struct platform_device gpio_keys = {
161 .name = "gpio-keys",
162 .dev = {
163 .platform_data = &gpio_keys_data,
164 },
165 .id = -1,
166};
167
Philipp Zabel70e357f2008-04-09 19:22:57 +0100168
169/*
170 * EGPIO (Xilinx CPLD)
171 *
172 * 7 32-bit aligned 8-bit registers: 3x output, 1x irq, 3x input
173 */
174
175static struct resource egpio_resources[] = {
176 [0] = {
177 .start = PXA_CS3_PHYS,
178 .end = PXA_CS3_PHYS + 0x20,
179 .flags = IORESOURCE_MEM,
180 },
181 [1] = {
182 .start = gpio_to_irq(GPIO13_MAGICIAN_CPLD_IRQ),
183 .end = gpio_to_irq(GPIO13_MAGICIAN_CPLD_IRQ),
184 .flags = IORESOURCE_IRQ,
185 },
186};
187
188static struct htc_egpio_chip egpio_chips[] = {
189 [0] = {
190 .reg_start = 0,
191 .gpio_base = MAGICIAN_EGPIO(0, 0),
192 .num_gpios = 24,
193 .direction = HTC_EGPIO_OUTPUT,
194 .initial_values = 0x40, /* EGPIO_MAGICIAN_GSM_RESET */
195 },
196 [1] = {
197 .reg_start = 4,
198 .gpio_base = MAGICIAN_EGPIO(4, 0),
199 .num_gpios = 24,
200 .direction = HTC_EGPIO_INPUT,
201 },
202};
203
204static struct htc_egpio_platform_data egpio_info = {
205 .reg_width = 8,
206 .bus_width = 32,
207 .irq_base = IRQ_BOARD_START,
208 .num_irqs = 4,
209 .ack_register = 3,
210 .chip = egpio_chips,
211 .num_chips = ARRAY_SIZE(egpio_chips),
212};
213
214static struct platform_device egpio = {
215 .name = "htc-egpio",
216 .id = -1,
217 .resource = egpio_resources,
218 .num_resources = ARRAY_SIZE(egpio_resources),
219 .dev = {
220 .platform_data = &egpio_info,
221 },
222};
223
Philipp Zabele5c271e2007-11-22 17:59:11 +0100224/*
Philipp Zabele07ff8d82008-04-09 19:27:10 +0100225 * LCD - Toppoly TD028STEB1 or Samsung LTP280QV
Philipp Zabele5c271e2007-11-22 17:59:11 +0100226 */
227
228static struct pxafb_mode_info toppoly_modes[] = {
229 {
230 .pixclock = 96153,
231 .bpp = 16,
232 .xres = 240,
233 .yres = 320,
234 .hsync_len = 11,
235 .vsync_len = 3,
236 .left_margin = 19,
237 .upper_margin = 2,
238 .right_margin = 10,
239 .lower_margin = 2,
240 .sync = 0,
241 },
242};
243
Philipp Zabele07ff8d82008-04-09 19:27:10 +0100244static struct pxafb_mode_info samsung_modes[] = {
245 {
246 .pixclock = 96153,
247 .bpp = 16,
248 .xres = 240,
249 .yres = 320,
250 .hsync_len = 8,
251 .vsync_len = 4,
252 .left_margin = 9,
253 .upper_margin = 4,
254 .right_margin = 9,
255 .lower_margin = 4,
256 .sync = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
257 },
258};
259
260static void toppoly_lcd_power(int on, struct fb_var_screeninfo *si)
261{
262 pr_debug("Toppoly LCD power\n");
263
264 if (on) {
265 pr_debug("on\n");
266 gpio_set_value(EGPIO_MAGICIAN_TOPPOLY_POWER, 1);
267 gpio_set_value(GPIO106_MAGICIAN_LCD_POWER_3, 1);
268 udelay(2000);
269 gpio_set_value(EGPIO_MAGICIAN_LCD_POWER, 1);
270 udelay(2000);
271 /* FIXME: enable LCDC here */
272 udelay(2000);
273 gpio_set_value(GPIO104_MAGICIAN_LCD_POWER_1, 1);
274 udelay(2000);
275 gpio_set_value(GPIO105_MAGICIAN_LCD_POWER_2, 1);
276 } else {
277 pr_debug("off\n");
278 msleep(15);
279 gpio_set_value(GPIO105_MAGICIAN_LCD_POWER_2, 0);
280 udelay(500);
281 gpio_set_value(GPIO104_MAGICIAN_LCD_POWER_1, 0);
282 udelay(1000);
283 gpio_set_value(GPIO106_MAGICIAN_LCD_POWER_3, 0);
284 gpio_set_value(EGPIO_MAGICIAN_LCD_POWER, 0);
285 }
286}
287
288static void samsung_lcd_power(int on, struct fb_var_screeninfo *si)
289{
290 pr_debug("Samsung LCD power\n");
291
292 if (on) {
293 pr_debug("on\n");
294 if (system_rev < 3)
295 gpio_set_value(GPIO75_MAGICIAN_SAMSUNG_POWER, 1);
296 else
297 gpio_set_value(EGPIO_MAGICIAN_LCD_POWER, 1);
298 mdelay(10);
299 gpio_set_value(GPIO106_MAGICIAN_LCD_POWER_3, 1);
300 mdelay(10);
301 gpio_set_value(GPIO104_MAGICIAN_LCD_POWER_1, 1);
302 mdelay(30);
303 gpio_set_value(GPIO105_MAGICIAN_LCD_POWER_2, 1);
304 mdelay(10);
305 } else {
306 pr_debug("off\n");
307 mdelay(10);
308 gpio_set_value(GPIO105_MAGICIAN_LCD_POWER_2, 0);
309 mdelay(30);
310 gpio_set_value(GPIO104_MAGICIAN_LCD_POWER_1, 0);
311 mdelay(10);
312 gpio_set_value(GPIO106_MAGICIAN_LCD_POWER_3, 0);
313 mdelay(10);
314 if (system_rev < 3)
315 gpio_set_value(GPIO75_MAGICIAN_SAMSUNG_POWER, 0);
316 else
317 gpio_set_value(EGPIO_MAGICIAN_LCD_POWER, 0);
318 }
319}
320
Philipp Zabele5c271e2007-11-22 17:59:11 +0100321static struct pxafb_mach_info toppoly_info = {
Philipp Zabele07ff8d82008-04-09 19:27:10 +0100322 .modes = toppoly_modes,
323 .num_modes = 1,
324 .fixed_modes = 1,
325 .lccr0 = LCCR0_Color | LCCR0_Sngl | LCCR0_Act,
326 .lccr3 = LCCR3_PixRsEdg,
327 .pxafb_lcd_power = toppoly_lcd_power,
328};
329
330static struct pxafb_mach_info samsung_info = {
331 .modes = samsung_modes,
332 .num_modes = 1,
333 .fixed_modes = 1,
334 .lccr0 = LCCR0_LDDALT | LCCR0_Color | LCCR0_Sngl | LCCR0_Act,
335 .lccr3 = LCCR3_PixFlEdg,
336 .pxafb_lcd_power = samsung_lcd_power,
Philipp Zabele5c271e2007-11-22 17:59:11 +0100337};
338
339/*
340 * Backlight
341 */
342
343static void magician_set_bl_intensity(int intensity)
344{
345 if (intensity) {
346 PWM_CTRL0 = 1;
347 PWM_PERVAL0 = 0xc8;
Philipp Zabel608021882008-04-09 19:28:53 +0100348 if (intensity > 0xc7) {
349 PWM_PWDUTY0 = intensity - 0x48;
350 gpio_set_value(EGPIO_MAGICIAN_BL_POWER2, 1);
351 } else {
352 PWM_PWDUTY0 = intensity;
353 gpio_set_value(EGPIO_MAGICIAN_BL_POWER2, 0);
354 }
355 gpio_set_value(EGPIO_MAGICIAN_BL_POWER, 1);
Philipp Zabele5c271e2007-11-22 17:59:11 +0100356 pxa_set_cken(CKEN_PWM0, 1);
357 } else {
Philipp Zabel608021882008-04-09 19:28:53 +0100358 /* PWM_PWDUTY0 = intensity; */
359 gpio_set_value(EGPIO_MAGICIAN_BL_POWER, 0);
Philipp Zabele5c271e2007-11-22 17:59:11 +0100360 pxa_set_cken(CKEN_PWM0, 0);
361 }
362}
363
364static struct generic_bl_info backlight_info = {
365 .default_intensity = 0x64,
366 .limit_mask = 0x0b,
Philipp Zabel608021882008-04-09 19:28:53 +0100367 .max_intensity = 0xc7+0x48,
Philipp Zabele5c271e2007-11-22 17:59:11 +0100368 .set_bl_intensity = magician_set_bl_intensity,
369};
370
371static struct platform_device backlight = {
Philipp Zabeldf56eac2008-04-08 19:36:06 +0100372 .name = "generic-bl",
Philipp Zabele5c271e2007-11-22 17:59:11 +0100373 .dev = {
374 .platform_data = &backlight_info,
375 },
376 .id = -1,
377};
378
Philipp Zabel81447b22008-04-12 13:28:02 +0100379/*
380 * LEDs
381 */
382
383struct gpio_led gpio_leds[] = {
384 {
385 .name = "magician::vibra",
386 .default_trigger = "none",
387 .gpio = GPIO22_MAGICIAN_VIBRA_EN,
388 },
389 {
390 .name = "magician::phone_bl",
391 .default_trigger = "none",
392 .gpio = GPIO103_MAGICIAN_LED_KP,
393 },
394};
395
396static struct gpio_led_platform_data gpio_led_info = {
397 .leds = gpio_leds,
398 .num_leds = ARRAY_SIZE(gpio_leds),
399};
400
401static struct platform_device leds_gpio = {
402 .name = "leds-gpio",
403 .id = -1,
404 .dev = {
405 .platform_data = &gpio_led_info,
406 },
407};
408
409static struct pasic3_led pasic3_leds[] = {
410 {
411 .led = {
412 .name = "magician:red",
413 .default_trigger = "ds2760-battery.0-charging",
414 },
415 .hw_num = 0,
416 .bit2 = PASIC3_BIT2_LED0,
417 .mask = PASIC3_MASK_LED0,
418 },
419 {
420 .led = {
421 .name = "magician:green",
422 .default_trigger = "ds2760-battery.0-charging-or-full",
423 },
424 .hw_num = 1,
425 .bit2 = PASIC3_BIT2_LED1,
426 .mask = PASIC3_MASK_LED1,
427 },
428 {
429 .led = {
430 .name = "magician:blue",
431 .default_trigger = "bluetooth",
432 },
433 .hw_num = 2,
434 .bit2 = PASIC3_BIT2_LED2,
435 .mask = PASIC3_MASK_LED2,
436 },
437};
438
439static struct platform_device pasic3;
440
441static struct pasic3_leds_machinfo __devinit pasic3_leds_info = {
442 .num_leds = ARRAY_SIZE(pasic3_leds),
443 .power_gpio = EGPIO_MAGICIAN_LED_POWER,
444 .leds = pasic3_leds,
445};
446
447/*
448 * PASIC3 with DS1WM
449 */
450
451static struct resource pasic3_resources[] = {
452 [0] = {
453 .start = PXA_CS2_PHYS,
454 .end = PXA_CS2_PHYS + 0x1b,
455 .flags = IORESOURCE_MEM,
456 },
457 /* No IRQ handler in the PASIC3, DS1WM needs an external IRQ */
458 [1] = {
459 .start = gpio_to_irq(GPIO107_MAGICIAN_DS1WM_IRQ),
460 .end = gpio_to_irq(GPIO107_MAGICIAN_DS1WM_IRQ),
461 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE,
462 }
463};
464
465static struct pasic3_platform_data pasic3_platform_data = {
466 .bus_shift = 2,
467 .led_pdata = &pasic3_leds_info,
468 .clock_rate = 4000000,
469};
470
471static struct platform_device pasic3 = {
472 .name = "pasic3",
473 .id = -1,
474 .num_resources = ARRAY_SIZE(pasic3_resources),
475 .resource = pasic3_resources,
476 .dev = {
477 .platform_data = &pasic3_platform_data,
478 },
479};
Philipp Zabele5c271e2007-11-22 17:59:11 +0100480
481/*
Philipp Zabel350d1152008-04-09 19:25:56 +0100482 * External power
483 */
484
485static int magician_is_ac_online(void)
486{
487 return gpio_get_value(EGPIO_MAGICIAN_CABLE_STATE_AC);
488}
489
490static int magician_is_usb_online(void)
491{
492 return gpio_get_value(EGPIO_MAGICIAN_CABLE_STATE_USB);
493}
494
495static void magician_set_charge(int flags)
496{
497 gpio_set_value(GPIO30_MAGICIAN_nCHARGE_EN, !flags);
498 gpio_set_value(EGPIO_MAGICIAN_CHARGE_EN, flags);
499}
500
Philipp Zabel81447b22008-04-12 13:28:02 +0100501static char *magician_supplicants[] = {
502 "ds2760-battery.0", "backup-battery"
503};
504
Philipp Zabel350d1152008-04-09 19:25:56 +0100505static struct pda_power_pdata power_supply_info = {
Philipp Zabel81447b22008-04-12 13:28:02 +0100506 .is_ac_online = magician_is_ac_online,
507 .is_usb_online = magician_is_usb_online,
508 .set_charge = magician_set_charge,
509 .supplied_to = magician_supplicants,
510 .num_supplicants = ARRAY_SIZE(magician_supplicants),
Philipp Zabel350d1152008-04-09 19:25:56 +0100511};
512
513static struct resource power_supply_resources[] = {
514 [0] = {
515 .name = "ac",
516 .flags = IORESOURCE_IRQ,
517 .start = IRQ_MAGICIAN_AC,
518 .end = IRQ_MAGICIAN_AC,
519 },
520 [1] = {
521 .name = "usb",
522 .flags = IORESOURCE_IRQ,
523 .start = IRQ_MAGICIAN_AC,
524 .end = IRQ_MAGICIAN_AC,
525 },
526};
527
528static struct platform_device power_supply = {
529 .name = "pda-power",
530 .id = -1,
531 .dev = {
532 .platform_data = &power_supply_info,
533 },
534 .resource = power_supply_resources,
535 .num_resources = ARRAY_SIZE(power_supply_resources),
536};
537
538
539/*
Philipp Zabelbdb0c162008-04-09 19:24:55 +0100540 * MMC/SD
541 */
542
543static int magician_mci_init(struct device *dev,
544 irq_handler_t detect_irq, void *data)
545{
546 return request_irq(IRQ_MAGICIAN_SD, detect_irq,
547 IRQF_DISABLED | IRQF_SAMPLE_RANDOM,
548 "MMC card detect", data);
549}
550
551static void magician_mci_setpower(struct device *dev, unsigned int vdd)
552{
553 struct pxamci_platform_data *pdata = dev->platform_data;
554
555 gpio_set_value(EGPIO_MAGICIAN_SD_POWER, (1 << vdd) & pdata->ocr_mask);
556}
557
558static int magician_mci_get_ro(struct device *dev)
559{
560 return (!gpio_get_value(EGPIO_MAGICIAN_nSD_READONLY));
561}
562
563static void magician_mci_exit(struct device *dev, void *data)
564{
565 free_irq(IRQ_MAGICIAN_SD, data);
566}
567
568static struct pxamci_platform_data magician_mci_info = {
569 .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34,
570 .init = magician_mci_init,
571 .get_ro = magician_mci_get_ro,
572 .setpower = magician_mci_setpower,
573 .exit = magician_mci_exit,
574};
575
576
577/*
Philipp Zabele5c271e2007-11-22 17:59:11 +0100578 * USB OHCI
579 */
580
581static int magician_ohci_init(struct device *dev)
582{
583 UHCHR = (UHCHR | UHCHR_SSEP2 | UHCHR_PCPL | UHCHR_CGR) &
584 ~(UHCHR_SSEP1 | UHCHR_SSEP3 | UHCHR_SSE);
585
586 return 0;
587}
588
589static struct pxaohci_platform_data magician_ohci_info = {
590 .port_mode = PMM_PERPORT_MODE,
591 .init = magician_ohci_init,
592 .power_budget = 0,
593};
594
595
596/*
597 * StrataFlash
598 */
599
Philipp Zabelaa797592008-04-09 19:24:05 +0100600static void magician_set_vpp(struct map_info *map, int vpp)
601{
602 gpio_set_value(EGPIO_MAGICIAN_FLASH_VPP, vpp);
603}
604
Philipp Zabele5c271e2007-11-22 17:59:11 +0100605#define PXA_CS_SIZE 0x04000000
606
607static struct resource strataflash_resource = {
608 .start = PXA_CS0_PHYS,
609 .end = PXA_CS0_PHYS + PXA_CS_SIZE - 1,
610 .flags = IORESOURCE_MEM,
611};
612
613static struct physmap_flash_data strataflash_data = {
614 .width = 4,
Philipp Zabelaa797592008-04-09 19:24:05 +0100615 .set_vpp = magician_set_vpp,
Philipp Zabele5c271e2007-11-22 17:59:11 +0100616};
617
618static struct platform_device strataflash = {
619 .name = "physmap-flash",
620 .id = -1,
Philipp Zabele5c271e2007-11-22 17:59:11 +0100621 .resource = &strataflash_resource,
Philipp Zabel70e357f2008-04-09 19:22:57 +0100622 .num_resources = 1,
Philipp Zabele5c271e2007-11-22 17:59:11 +0100623 .dev = {
624 .platform_data = &strataflash_data,
625 },
626};
627
628/*
629 * Platform devices
630 */
631
632static struct platform_device *devices[] __initdata = {
633 &gpio_keys,
Philipp Zabel70e357f2008-04-09 19:22:57 +0100634 &egpio,
Philipp Zabele5c271e2007-11-22 17:59:11 +0100635 &backlight,
Philipp Zabel81447b22008-04-12 13:28:02 +0100636 &pasic3,
Philipp Zabel350d1152008-04-09 19:25:56 +0100637 &power_supply,
Philipp Zabele5c271e2007-11-22 17:59:11 +0100638 &strataflash,
Philipp Zabel81447b22008-04-12 13:28:02 +0100639 &leds_gpio,
Philipp Zabele5c271e2007-11-22 17:59:11 +0100640};
641
642static void __init magician_init(void)
643{
Philipp Zabele07ff8d82008-04-09 19:27:10 +0100644 void __iomem *cpld;
645 int lcd_select;
646
Philipp Zabelb1682812008-04-12 13:29:22 +0100647 pxa2xx_mfp_config(ARRAY_AND_SIZE(magician_pin_config));
648
Philipp Zabele5c271e2007-11-22 17:59:11 +0100649 platform_add_devices(devices, ARRAY_SIZE(devices));
Philipp Zabele6816f32008-04-09 19:14:15 +0100650 pxa_set_i2c_info(NULL);
Philipp Zabelbdb0c162008-04-09 19:24:55 +0100651 pxa_set_mci_info(&magician_mci_info);
Philipp Zabele5c271e2007-11-22 17:59:11 +0100652 pxa_set_ohci_info(&magician_ohci_info);
653 pxa_set_ficp_info(&magician_ficp_info);
Philipp Zabele07ff8d82008-04-09 19:27:10 +0100654
655 /* Check LCD type we have */
656 cpld = ioremap_nocache(PXA_CS3_PHYS, 0x1000);
657 if (cpld) {
658 u8 board_id = __raw_readb(cpld+0x14);
659 system_rev = board_id & 0x7;
660 lcd_select = board_id & 0x8;
661 iounmap(cpld);
662 pr_info("LCD type: %s\n", lcd_select ? "Samsung" : "Toppoly");
663 if (lcd_select && (system_rev < 3))
664 pxa_gpio_mode(GPIO75_MAGICIAN_SAMSUNG_POWER_MD);
665 pxa_gpio_mode(GPIO104_MAGICIAN_LCD_POWER_1_MD);
666 pxa_gpio_mode(GPIO105_MAGICIAN_LCD_POWER_2_MD);
667 pxa_gpio_mode(GPIO106_MAGICIAN_LCD_POWER_3_MD);
668 set_pxa_fb_info(lcd_select ? &samsung_info : &toppoly_info);
669 } else
670 pr_err("LCD detection: CPLD mapping failed\n");
Philipp Zabele5c271e2007-11-22 17:59:11 +0100671}
672
673
674MACHINE_START(MAGICIAN, "HTC Magician")
675 .phys_io = 0x40000000,
676 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
677 .boot_params = 0xa0000100,
678 .map_io = pxa_map_io,
679 .init_irq = pxa27x_init_irq,
680 .init_machine = magician_init,
681 .timer = &pxa_timer,
682MACHINE_END