Blame view

arch/arm/mach-pxa/magician.c 21.7 KB
e5c271ec3   Philipp Zabel   [ARM] 4664/1: Add...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
  /*
   * Support for HTC Magician PDA phones:
   * i-mate JAM, O2 Xda mini, Orange SPV M500, Qtek s100, Qtek s110
   * and T-Mobile MDA Compact.
   *
   * Copyright (c) 2006-2007 Philipp Zabel
   *
   * Based on hx4700.c, spitz.c and others.
   *
   * This program is free software; you can redistribute it and/or modify
   * it under the terms of the GNU General Public License version 2 as
   * published by the Free Software Foundation.
   *
   */
  
  #include <linux/kernel.h>
  #include <linux/init.h>
  #include <linux/platform_device.h>
e07ff8d80   Philipp Zabel   [ARM] 4952/1: mag...
19
  #include <linux/delay.h>
e181191ac   Philipp Zabel   [ARM] 5119/1: mag...
20
  #include <linux/gpio.h>
e5c271ec3   Philipp Zabel   [ARM] 4664/1: Add...
21
22
  #include <linux/gpio_keys.h>
  #include <linux/input.h>
70e357f84   Philipp Zabel   [ARM] 4948/1: mag...
23
  #include <linux/mfd/htc-egpio.h>
81447b2ee   Philipp Zabel   [ARM] 4965/1: mag...
24
  #include <linux/mfd/htc-pasic3.h>
e5c271ec3   Philipp Zabel   [ARM] 4664/1: Add...
25
  #include <linux/mtd/physmap.h>
350d115d1   Philipp Zabel   [ARM] 4951/1: mag...
26
  #include <linux/pda_power.h>
bd3208bab   Thierry Reding   ARM: pxa: magicia...
27
  #include <linux/pwm.h>
85847a360   Philipp Zabel   [ARM] 5045/1: mag...
28
  #include <linux/pwm_backlight.h>
6967cca8b   Heiko Stübner   pxa: magician/hx4...
29
  #include <linux/regulator/driver.h>
e2f1b8b0a   Petr Cvek   ARM: pxa: magicia...
30
  #include <linux/regulator/fixed.h>
6967cca8b   Heiko Stübner   pxa: magician/hx4...
31
  #include <linux/regulator/gpio-regulator.h>
eb650b9ed   Philipp Zabel   [ARM] pxa/magicia...
32
  #include <linux/regulator/machine.h>
6489c611d   Philipp Zabel   [ARM] pxa/magicia...
33
  #include <linux/usb/gpio_vbus.h>
b459396ee   Sebastian Andrzej Siewior   ARM: pxa2xx: reor...
34
  #include <linux/i2c/pxa-i2c.h>
e5c271ec3   Philipp Zabel   [ARM] 4664/1: Add...
35

a09e64fbc   Russell King   [ARM] Move includ...
36
  #include <mach/hardware.h>
e5c271ec3   Philipp Zabel   [ARM] 4664/1: Add...
37
38
  #include <asm/mach-types.h>
  #include <asm/mach/arch.h>
9f97da78b   David Howells   Disintegrate asm/...
39
  #include <asm/system_info.h>
51c62982a   Eric Miao   [ARM] pxa: introd...
40
41
  
  #include <mach/pxa27x.h>
a09e64fbc   Russell King   [ARM] Move includ...
42
  #include <mach/magician.h>
293b2da1b   Arnd Bergmann   ARM: pxa: move pl...
43
44
45
46
  #include <linux/platform_data/video-pxafb.h>
  #include <linux/platform_data/mmc-pxamci.h>
  #include <linux/platform_data/irda-pxaficp.h>
  #include <linux/platform_data/usb-ohci-pxa27x.h>
e5c271ec3   Philipp Zabel   [ARM] 4664/1: Add...
47

ff5eff35c   Petr Cvek   ARM: pxa: magicia...
48
  #include <linux/regulator/max1586.h>
31134b515   Petr Cvek   ARM: pxa: magicia...
49
50
51
  #include <linux/platform_data/pxa2xx_udc.h>
  #include <mach/udc.h>
  #include <mach/pxa27x-udc.h>
85847a360   Philipp Zabel   [ARM] 5045/1: mag...
52
  #include "devices.h"
e5c271ec3   Philipp Zabel   [ARM] 4664/1: Add...
53
  #include "generic.h"
7a97010eb   Philipp Zabel   [ARM] 5125/1: mag...
54
  static unsigned long magician_pin_config[] __initdata = {
b168281c0   Philipp Zabel   [ARM] 4966/1: mag...
55
56
57
58
59
  
  	/* SDRAM and Static Memory I/O Signals */
  	GPIO20_nSDCS_2,
  	GPIO21_nSDCS_3,
  	GPIO15_nCS_1,
ccb6f9aec   Petr Cvek   ARM: pxa: magicia...
60
61
  	GPIO78_nCS_2,	/* PASIC3 */
  	GPIO79_nCS_3,	/* EGPIO CPLD */
b168281c0   Philipp Zabel   [ARM] 4966/1: mag...
62
63
  	GPIO80_nCS_4,
  	GPIO33_nCS_5,
f36150b17   Petr Cvek   ARM: pxa: magicia...
64
  	/* I2C UDA1380 + OV9640 */
b168281c0   Philipp Zabel   [ARM] 4966/1: mag...
65
66
  	GPIO117_I2C_SCL,
  	GPIO118_I2C_SDA,
f36150b17   Petr Cvek   ARM: pxa: magicia...
67
  	/* PWM 0 - LCD backlight */
b168281c0   Philipp Zabel   [ARM] 4966/1: mag...
68
  	GPIO16_PWM0_OUT,
f36150b17   Petr Cvek   ARM: pxa: magicia...
69
  	/* I2S UDA1380 capture */
b168281c0   Philipp Zabel   [ARM] 4966/1: mag...
70
71
72
73
  	GPIO28_I2S_BITCLK_OUT,
  	GPIO29_I2S_SDATA_IN,
  	GPIO31_I2S_SYNC,
  	GPIO113_I2S_SYSCLK,
f36150b17   Petr Cvek   ARM: pxa: magicia...
74
  	/* SSP 1 UDA1380 playback */
16c3ea43b   Philipp Zabel   [ARM] pxa/magicia...
75
76
77
  	GPIO23_SSP1_SCLK,
  	GPIO24_SSP1_SFRM,
  	GPIO25_SSP1_TXD,
f36150b17   Petr Cvek   ARM: pxa: magicia...
78
  	/* SSP 2 TSC2046 touchscreen */
b168281c0   Philipp Zabel   [ARM] 4966/1: mag...
79
80
81
82
  	GPIO19_SSP2_SCLK,
  	GPIO14_SSP2_SFRM,
  	GPIO89_SSP2_TXD,
  	GPIO88_SSP2_RXD,
f36150b17   Petr Cvek   ARM: pxa: magicia...
83
  	/* MMC/SD/SDHC slot */
b168281c0   Philipp Zabel   [ARM] 4966/1: mag...
84
85
86
87
88
89
90
91
  	GPIO32_MMC_CLK,
  	GPIO92_MMC_DAT_0,
  	GPIO109_MMC_DAT_1,
  	GPIO110_MMC_DAT_2,
  	GPIO111_MMC_DAT_3,
  	GPIO112_MMC_CMD,
  
  	/* LCD */
bedbda971   Eric Miao   [ARM] pxa: simpli...
92
  	GPIOxx_LCD_TFT_16BPP,
b168281c0   Philipp Zabel   [ARM] 4966/1: mag...
93

f36150b17   Petr Cvek   ARM: pxa: magicia...
94
  	/* QCI camera interface */
b168281c0   Philipp Zabel   [ARM] 4966/1: mag...
95
96
97
98
99
100
101
102
103
104
105
106
  	GPIO12_CIF_DD_7,
  	GPIO17_CIF_DD_6,
  	GPIO50_CIF_DD_3,
  	GPIO51_CIF_DD_2,
  	GPIO52_CIF_DD_4,
  	GPIO53_CIF_MCLK,
  	GPIO54_CIF_PCLK,
  	GPIO55_CIF_DD_1,
  	GPIO81_CIF_DD_0,
  	GPIO82_CIF_DD_5,
  	GPIO84_CIF_FV,
  	GPIO85_CIF_LV,
2f131958e   Philipp Zabel   [ARM] 5008/1: mag...
107
108
109
110
111
112
113
114
  
  	/* Magician specific input GPIOs */
  	GPIO9_GPIO,	/* unknown */
  	GPIO10_GPIO,	/* GSM_IRQ */
  	GPIO13_GPIO,	/* CPLD_IRQ */
  	GPIO107_GPIO,	/* DS1WM_IRQ */
  	GPIO108_GPIO,	/* GSM_READY */
  	GPIO115_GPIO,	/* nPEN_IRQ */
6f584cfab   Eric Miao   [ARM] pxa: move I...
115
116
117
118
  
  	/* I2C */
  	GPIO117_I2C_SCL,
  	GPIO118_I2C_SDA,
b168281c0   Philipp Zabel   [ARM] 4966/1: mag...
119
  };
e5c271ec3   Philipp Zabel   [ARM] 4664/1: Add...
120
  /*
f36150b17   Petr Cvek   ARM: pxa: magicia...
121
   * IrDA
e5c271ec3   Philipp Zabel   [ARM] 4664/1: Add...
122
   */
e5c271ec3   Philipp Zabel   [ARM] 4664/1: Add...
123
  static struct pxaficp_platform_data magician_ficp_info = {
c4bd01727   Marek Vasut   [ARM] pxa: add gp...
124
125
  	.gpio_pwdown		= GPIO83_MAGICIAN_nIR_EN,
  	.transceiver_cap	= IR_SIRMODE | IR_OFF,
0f073e3e0   Petr Cvek   ARM: pxa: magicia...
126
  	.gpio_pwdown_inverted	= 0,
e5c271ec3   Philipp Zabel   [ARM] 4664/1: Add...
127
128
129
130
131
  };
  
  /*
   * GPIO Keys
   */
51c10bbc3   Philipp Zabel   [ARM] pxa/magicia...
132
133
  #define INIT_KEY(_code, _gpio, _desc)	\
  	{				\
ccb6f9aec   Petr Cvek   ARM: pxa: magicia...
134
135
136
137
138
  		.code	= KEY_##_code,	\
  		.gpio	= _gpio,	\
  		.desc	= _desc,	\
  		.type	= EV_KEY,	\
  		.wakeup	= 1,		\
51c10bbc3   Philipp Zabel   [ARM] pxa/magicia...
139
  	}
e5c271ec3   Philipp Zabel   [ARM] 4664/1: Add...
140
  static struct gpio_keys_button magician_button_table[] = {
51c10bbc3   Philipp Zabel   [ARM] pxa/magicia...
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
  	INIT_KEY(POWER,      GPIO0_MAGICIAN_KEY_POWER,      "Power button"),
  	INIT_KEY(ESC,        GPIO37_MAGICIAN_KEY_HANGUP,    "Hangup button"),
  	INIT_KEY(F10,        GPIO38_MAGICIAN_KEY_CONTACTS,  "Contacts button"),
  	INIT_KEY(CALENDAR,   GPIO90_MAGICIAN_KEY_CALENDAR,  "Calendar button"),
  	INIT_KEY(CAMERA,     GPIO91_MAGICIAN_KEY_CAMERA,    "Camera button"),
  	INIT_KEY(UP,         GPIO93_MAGICIAN_KEY_UP,        "Up button"),
  	INIT_KEY(DOWN,       GPIO94_MAGICIAN_KEY_DOWN,      "Down button"),
  	INIT_KEY(LEFT,       GPIO95_MAGICIAN_KEY_LEFT,      "Left button"),
  	INIT_KEY(RIGHT,      GPIO96_MAGICIAN_KEY_RIGHT,     "Right button"),
  	INIT_KEY(KPENTER,    GPIO97_MAGICIAN_KEY_ENTER,     "Action button"),
  	INIT_KEY(RECORD,     GPIO98_MAGICIAN_KEY_RECORD,    "Record button"),
  	INIT_KEY(VOLUMEUP,   GPIO100_MAGICIAN_KEY_VOL_UP,   "Volume up"),
  	INIT_KEY(VOLUMEDOWN, GPIO101_MAGICIAN_KEY_VOL_DOWN, "Volume down"),
  	INIT_KEY(PHONE,      GPIO102_MAGICIAN_KEY_PHONE,    "Phone button"),
  	INIT_KEY(PLAY,       GPIO99_MAGICIAN_HEADPHONE_IN,  "Headset button"),
e5c271ec3   Philipp Zabel   [ARM] 4664/1: Add...
156
157
158
  };
  
  static struct gpio_keys_platform_data gpio_keys_data = {
ccb6f9aec   Petr Cvek   ARM: pxa: magicia...
159
160
  	.buttons	= magician_button_table,
  	.nbuttons	= ARRAY_SIZE(magician_button_table),
e5c271ec3   Philipp Zabel   [ARM] 4664/1: Add...
161
162
163
  };
  
  static struct platform_device gpio_keys = {
ccb6f9aec   Petr Cvek   ARM: pxa: magicia...
164
165
  	.name	= "gpio-keys",
  	.dev	= {
e5c271ec3   Philipp Zabel   [ARM] 4664/1: Add...
166
167
  		.platform_data = &gpio_keys_data,
  	},
ccb6f9aec   Petr Cvek   ARM: pxa: magicia...
168
  	.id	= -1,
e5c271ec3   Philipp Zabel   [ARM] 4664/1: Add...
169
  };
70e357f84   Philipp Zabel   [ARM] 4948/1: mag...
170
171
172
  /*
   * EGPIO (Xilinx CPLD)
   *
f36150b17   Petr Cvek   ARM: pxa: magicia...
173
174
175
   * 32-bit aligned 8-bit registers
   * 16 possible registers (reg windows size), only 7 used:
   * 3x output, 1x irq, 3x input
70e357f84   Philipp Zabel   [ARM] 4948/1: mag...
176
177
178
179
   */
  
  static struct resource egpio_resources[] = {
  	[0] = {
ccb6f9aec   Petr Cvek   ARM: pxa: magicia...
180
181
182
  		.start	= PXA_CS3_PHYS,
  		.end	= PXA_CS3_PHYS + 0x20 - 1,
  		.flags	= IORESOURCE_MEM,
70e357f84   Philipp Zabel   [ARM] 4948/1: mag...
183
184
  	},
  	[1] = {
ccb6f9aec   Petr Cvek   ARM: pxa: magicia...
185
186
187
  		.start	= PXA_GPIO_TO_IRQ(GPIO13_MAGICIAN_CPLD_IRQ),
  		.end	= PXA_GPIO_TO_IRQ(GPIO13_MAGICIAN_CPLD_IRQ),
  		.flags	= IORESOURCE_IRQ,
70e357f84   Philipp Zabel   [ARM] 4948/1: mag...
188
189
190
191
192
  	},
  };
  
  static struct htc_egpio_chip egpio_chips[] = {
  	[0] = {
ccb6f9aec   Petr Cvek   ARM: pxa: magicia...
193
194
195
196
  		.reg_start	= 0,
  		.gpio_base	= MAGICIAN_EGPIO(0, 0),
  		.num_gpios	= 24,
  		.direction	= HTC_EGPIO_OUTPUT,
f36150b17   Petr Cvek   ARM: pxa: magicia...
197
198
199
  		/*
  		 * Depends on modules configuration
  		 */
ccb6f9aec   Petr Cvek   ARM: pxa: magicia...
200
  		.initial_values	= 0x40, /* EGPIO_MAGICIAN_GSM_RESET */
70e357f84   Philipp Zabel   [ARM] 4948/1: mag...
201
202
  	},
  	[1] = {
ccb6f9aec   Petr Cvek   ARM: pxa: magicia...
203
204
205
206
  		.reg_start	= 4,
  		.gpio_base	= MAGICIAN_EGPIO(4, 0),
  		.num_gpios	= 24,
  		.direction	= HTC_EGPIO_INPUT,
70e357f84   Philipp Zabel   [ARM] 4948/1: mag...
207
208
209
210
  	},
  };
  
  static struct htc_egpio_platform_data egpio_info = {
ccb6f9aec   Petr Cvek   ARM: pxa: magicia...
211
212
213
214
215
216
217
  	.reg_width	= 8,
  	.bus_width	= 32,
  	.irq_base	= IRQ_BOARD_START,
  	.num_irqs	= 4,
  	.ack_register	= 3,
  	.chip		= egpio_chips,
  	.num_chips	= ARRAY_SIZE(egpio_chips),
70e357f84   Philipp Zabel   [ARM] 4948/1: mag...
218
219
220
  };
  
  static struct platform_device egpio = {
ccb6f9aec   Petr Cvek   ARM: pxa: magicia...
221
222
223
224
  	.name		= "htc-egpio",
  	.id		= -1,
  	.resource	= egpio_resources,
  	.num_resources	= ARRAY_SIZE(egpio_resources),
70e357f84   Philipp Zabel   [ARM] 4948/1: mag...
225
226
227
228
  	.dev = {
  		.platform_data = &egpio_info,
  	},
  };
e5c271ec3   Philipp Zabel   [ARM] 4664/1: Add...
229
  /*
f36150b17   Petr Cvek   ARM: pxa: magicia...
230
   * PXAFB LCD - Toppoly TD028STEB1 or Samsung LTP280QV
e5c271ec3   Philipp Zabel   [ARM] 4664/1: Add...
231
232
233
234
   */
  
  static struct pxafb_mode_info toppoly_modes[] = {
  	{
ccb6f9aec   Petr Cvek   ARM: pxa: magicia...
235
236
237
238
239
240
241
242
243
244
245
  		.pixclock	= 96153,
  		.bpp		= 16,
  		.xres		= 240,
  		.yres		= 320,
  		.hsync_len	= 11,
  		.vsync_len	= 3,
  		.left_margin	= 19,
  		.upper_margin	= 2,
  		.right_margin	= 10,
  		.lower_margin	= 2,
  		.sync		= 0,
e5c271ec3   Philipp Zabel   [ARM] 4664/1: Add...
246
247
  	},
  };
e07ff8d80   Philipp Zabel   [ARM] 4952/1: mag...
248
249
  static struct pxafb_mode_info samsung_modes[] = {
  	{
e7b97a4ce   Petr Cvek   ARM: pxa: magicia...
250
  		.pixclock	= 226469,
ccb6f9aec   Petr Cvek   ARM: pxa: magicia...
251
252
253
254
255
256
257
258
259
260
  		.bpp		= 16,
  		.xres		= 240,
  		.yres		= 320,
  		.hsync_len	= 8,
  		.vsync_len	= 4,
  		.left_margin	= 9,
  		.upper_margin	= 4,
  		.right_margin	= 9,
  		.lower_margin	= 4,
  		.sync	= FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
e07ff8d80   Philipp Zabel   [ARM] 4952/1: mag...
261
262
263
264
265
  	},
  };
  
  static void toppoly_lcd_power(int on, struct fb_var_screeninfo *si)
  {
dedad4d28   Petr Cvek   ARM: pxa: magicia...
266
267
  	pr_debug("Toppoly LCD power: %s
  ", on ? "on" : "off");
e07ff8d80   Philipp Zabel   [ARM] 4952/1: mag...
268
269
  
  	if (on) {
e07ff8d80   Philipp Zabel   [ARM] 4952/1: mag...
270
  		gpio_set_value(EGPIO_MAGICIAN_TOPPOLY_POWER, 1);
6001ae70e   Petr Cvek   ARM: pxa: magicia...
271
  		gpio_set_value(GPIO106_MAGICIAN_LCD_DCDC_NRESET, 1);
e07ff8d80   Philipp Zabel   [ARM] 4952/1: mag...
272
273
274
275
276
  		udelay(2000);
  		gpio_set_value(EGPIO_MAGICIAN_LCD_POWER, 1);
  		udelay(2000);
  		/* FIXME: enable LCDC here */
  		udelay(2000);
6001ae70e   Petr Cvek   ARM: pxa: magicia...
277
  		gpio_set_value(GPIO104_MAGICIAN_LCD_VOFF_EN, 1);
e07ff8d80   Philipp Zabel   [ARM] 4952/1: mag...
278
  		udelay(2000);
6001ae70e   Petr Cvek   ARM: pxa: magicia...
279
  		gpio_set_value(GPIO105_MAGICIAN_LCD_VON_EN, 1);
e07ff8d80   Philipp Zabel   [ARM] 4952/1: mag...
280
  	} else {
e07ff8d80   Philipp Zabel   [ARM] 4952/1: mag...
281
  		msleep(15);
6001ae70e   Petr Cvek   ARM: pxa: magicia...
282
  		gpio_set_value(GPIO105_MAGICIAN_LCD_VON_EN, 0);
e07ff8d80   Philipp Zabel   [ARM] 4952/1: mag...
283
  		udelay(500);
6001ae70e   Petr Cvek   ARM: pxa: magicia...
284
  		gpio_set_value(GPIO104_MAGICIAN_LCD_VOFF_EN, 0);
e07ff8d80   Philipp Zabel   [ARM] 4952/1: mag...
285
  		udelay(1000);
6001ae70e   Petr Cvek   ARM: pxa: magicia...
286
  		gpio_set_value(GPIO106_MAGICIAN_LCD_DCDC_NRESET, 0);
e07ff8d80   Philipp Zabel   [ARM] 4952/1: mag...
287
288
289
290
291
292
  		gpio_set_value(EGPIO_MAGICIAN_LCD_POWER, 0);
  	}
  }
  
  static void samsung_lcd_power(int on, struct fb_var_screeninfo *si)
  {
dedad4d28   Petr Cvek   ARM: pxa: magicia...
293
294
  	pr_debug("Samsung LCD power: %s
  ", on ? "on" : "off");
e07ff8d80   Philipp Zabel   [ARM] 4952/1: mag...
295
296
  
  	if (on) {
e07ff8d80   Philipp Zabel   [ARM] 4952/1: mag...
297
298
299
300
  		if (system_rev < 3)
  			gpio_set_value(GPIO75_MAGICIAN_SAMSUNG_POWER, 1);
  		else
  			gpio_set_value(EGPIO_MAGICIAN_LCD_POWER, 1);
fa5407ad9   Petr Cvek   ARM: pxa: magicia...
301
  		mdelay(6);
6001ae70e   Petr Cvek   ARM: pxa: magicia...
302
  		gpio_set_value(GPIO106_MAGICIAN_LCD_DCDC_NRESET, 1);
fa5407ad9   Petr Cvek   ARM: pxa: magicia...
303
  		mdelay(6);	/* Avdd -> Voff >5ms */
6001ae70e   Petr Cvek   ARM: pxa: magicia...
304
  		gpio_set_value(GPIO104_MAGICIAN_LCD_VOFF_EN, 1);
fa5407ad9   Petr Cvek   ARM: pxa: magicia...
305
  		mdelay(16);	/* Voff -> Von >(5+10)ms */
6001ae70e   Petr Cvek   ARM: pxa: magicia...
306
  		gpio_set_value(GPIO105_MAGICIAN_LCD_VON_EN, 1);
e07ff8d80   Philipp Zabel   [ARM] 4952/1: mag...
307
  	} else {
6001ae70e   Petr Cvek   ARM: pxa: magicia...
308
  		gpio_set_value(GPIO105_MAGICIAN_LCD_VON_EN, 0);
fa5407ad9   Petr Cvek   ARM: pxa: magicia...
309
  		mdelay(16);
6001ae70e   Petr Cvek   ARM: pxa: magicia...
310
  		gpio_set_value(GPIO104_MAGICIAN_LCD_VOFF_EN, 0);
fa5407ad9   Petr Cvek   ARM: pxa: magicia...
311
  		mdelay(6);
6001ae70e   Petr Cvek   ARM: pxa: magicia...
312
  		gpio_set_value(GPIO106_MAGICIAN_LCD_DCDC_NRESET, 0);
fa5407ad9   Petr Cvek   ARM: pxa: magicia...
313
  		mdelay(6);
e07ff8d80   Philipp Zabel   [ARM] 4952/1: mag...
314
315
316
317
318
319
  		if (system_rev < 3)
  			gpio_set_value(GPIO75_MAGICIAN_SAMSUNG_POWER, 0);
  		else
  			gpio_set_value(EGPIO_MAGICIAN_LCD_POWER, 0);
  	}
  }
e5c271ec3   Philipp Zabel   [ARM] 4664/1: Add...
320
  static struct pxafb_mach_info toppoly_info = {
ccb6f9aec   Petr Cvek   ARM: pxa: magicia...
321
322
323
324
325
  	.modes			= toppoly_modes,
  	.num_modes		= 1,
  	.fixed_modes		= 1,
  	.lcd_conn		= LCD_COLOR_TFT_16BPP,
  	.pxafb_lcd_power	= toppoly_lcd_power,
e07ff8d80   Philipp Zabel   [ARM] 4952/1: mag...
326
327
328
  };
  
  static struct pxafb_mach_info samsung_info = {
ccb6f9aec   Petr Cvek   ARM: pxa: magicia...
329
330
331
332
333
334
  	.modes			= samsung_modes,
  	.num_modes		= 1,
  	.fixed_modes		= 1,
  	.lcd_conn		= LCD_COLOR_TFT_16BPP | LCD_PCLK_EDGE_FALL |
  		LCD_ALTERNATE_MAPPING,
  	.pxafb_lcd_power	= samsung_lcd_power,
e5c271ec3   Philipp Zabel   [ARM] 4664/1: Add...
335
336
337
338
339
  };
  
  /*
   * Backlight
   */
bd3208bab   Thierry Reding   ARM: pxa: magicia...
340
341
342
343
  static struct pwm_lookup magician_pwm_lookup[] = {
  	PWM_LOOKUP("pxa27x-pwm.0", 0, "pwm-backlight", NULL, 30923,
  		   PWM_POLARITY_NORMAL),
  };
e2f1b8b0a   Petr Cvek   ARM: pxa: magicia...
344
345
346
347
348
349
350
   /*
   * fixed regulator for pwm_backlight
   */
  
  static struct regulator_consumer_supply pwm_backlight_supply[] = {
  	REGULATOR_SUPPLY("power", "pwm_backlight"),
  };
5db15f868   Philipp Zabel   ARM: pxa/magician...
351
  static struct gpio magician_bl_gpios[] = {
ccb6f9aec   Petr Cvek   ARM: pxa: magicia...
352
353
  	{ EGPIO_MAGICIAN_BL_POWER,	GPIOF_DIR_OUT, "Backlight power" },
  	{ EGPIO_MAGICIAN_BL_POWER2,	GPIOF_DIR_OUT, "Backlight power 2" },
5db15f868   Philipp Zabel   ARM: pxa/magician...
354
  };
85847a360   Philipp Zabel   [ARM] 5045/1: mag...
355
  static int magician_backlight_init(struct device *dev)
e5c271ec3   Philipp Zabel   [ARM] 4664/1: Add...
356
  {
5db15f868   Philipp Zabel   ARM: pxa/magician...
357
  	return gpio_request_array(ARRAY_AND_SIZE(magician_bl_gpios));
85847a360   Philipp Zabel   [ARM] 5045/1: mag...
358
  }
2d51a521e   Eric Miao   [ARM] pxa: update...
359
  static int magician_backlight_notify(struct device *dev, int brightness)
85847a360   Philipp Zabel   [ARM] 5045/1: mag...
360
  {
539122ad3   Petr Cvek   ARM: pxa: magicia...
361
362
  	pr_debug("Brightness = %i
  ", brightness);
85847a360   Philipp Zabel   [ARM] 5045/1: mag...
363
364
365
366
  	gpio_set_value(EGPIO_MAGICIAN_BL_POWER, brightness);
  	if (brightness >= 200) {
  		gpio_set_value(EGPIO_MAGICIAN_BL_POWER2, 1);
  		return brightness - 72;
e5c271ec3   Philipp Zabel   [ARM] 4664/1: Add...
367
  	} else {
85847a360   Philipp Zabel   [ARM] 5045/1: mag...
368
369
  		gpio_set_value(EGPIO_MAGICIAN_BL_POWER2, 0);
  		return brightness;
e5c271ec3   Philipp Zabel   [ARM] 4664/1: Add...
370
371
  	}
  }
85847a360   Philipp Zabel   [ARM] 5045/1: mag...
372
373
  static void magician_backlight_exit(struct device *dev)
  {
5db15f868   Philipp Zabel   ARM: pxa/magician...
374
  	gpio_free_array(ARRAY_AND_SIZE(magician_bl_gpios));
85847a360   Philipp Zabel   [ARM] 5045/1: mag...
375
  }
f36150b17   Petr Cvek   ARM: pxa: magicia...
376
377
378
379
380
381
  /*
   * LCD PWM backlight (main)
   *
   * MP1521 frequency should be:
   *	100-400 Hz = 2 .5*10^6 - 10 *10^6 ns
   */
85847a360   Philipp Zabel   [ARM] 5045/1: mag...
382
  static struct platform_pwm_backlight_data backlight_data = {
ccb6f9aec   Petr Cvek   ARM: pxa: magicia...
383
384
385
386
387
388
  	.max_brightness	= 272,
  	.dft_brightness	= 100,
  	.enable_gpio	= -1,
  	.init		= magician_backlight_init,
  	.notify		= magician_backlight_notify,
  	.exit		= magician_backlight_exit,
e5c271ec3   Philipp Zabel   [ARM] 4664/1: Add...
389
390
391
  };
  
  static struct platform_device backlight = {
ccb6f9aec   Petr Cvek   ARM: pxa: magicia...
392
393
394
395
396
  	.name	= "pwm-backlight",
  	.id	= -1,
  	.dev	= {
  		.parent		= &pxa27x_device_pwm0.dev,
  		.platform_data	= &backlight_data,
e5c271ec3   Philipp Zabel   [ARM] 4664/1: Add...
397
  	},
e5c271ec3   Philipp Zabel   [ARM] 4664/1: Add...
398
  };
81447b2ee   Philipp Zabel   [ARM] 4965/1: mag...
399
  /*
f36150b17   Petr Cvek   ARM: pxa: magicia...
400
   * GPIO LEDs, Phone keys backlight, vibra
81447b2ee   Philipp Zabel   [ARM] 4965/1: mag...
401
   */
a55facae0   Russell King   [ARM] pxa: make "...
402
  static struct gpio_led gpio_leds[] = {
81447b2ee   Philipp Zabel   [ARM] 4965/1: mag...
403
404
405
406
407
408
409
  	{
  		.name = "magician::vibra",
  		.default_trigger = "none",
  		.gpio = GPIO22_MAGICIAN_VIBRA_EN,
  	},
  	{
  		.name = "magician::phone_bl",
05199ecb7   Philipp Zabel   [ARM] pxa/magicia...
410
  		.default_trigger = "backlight",
81447b2ee   Philipp Zabel   [ARM] 4965/1: mag...
411
412
413
414
415
416
417
418
419
420
  		.gpio = GPIO103_MAGICIAN_LED_KP,
  	},
  };
  
  static struct gpio_led_platform_data gpio_led_info = {
  	.leds = gpio_leds,
  	.num_leds = ARRAY_SIZE(gpio_leds),
  };
  
  static struct platform_device leds_gpio = {
ccb6f9aec   Petr Cvek   ARM: pxa: magicia...
421
422
423
  	.name	= "leds-gpio",
  	.id	= -1,
  	.dev	= {
81447b2ee   Philipp Zabel   [ARM] 4965/1: mag...
424
425
426
  		.platform_data = &gpio_led_info,
  	},
  };
f36150b17   Petr Cvek   ARM: pxa: magicia...
427
  /*
81447b2ee   Philipp Zabel   [ARM] 4965/1: mag...
428
429
430
431
432
   * PASIC3 with DS1WM
   */
  
  static struct resource pasic3_resources[] = {
  	[0] = {
ccb6f9aec   Petr Cvek   ARM: pxa: magicia...
433
  		.start	= PXA_CS2_PHYS,
81447b2ee   Philipp Zabel   [ARM] 4965/1: mag...
434
  		.end	= PXA_CS2_PHYS + 0x1b,
ccb6f9aec   Petr Cvek   ARM: pxa: magicia...
435
  		.flags	= IORESOURCE_MEM,
81447b2ee   Philipp Zabel   [ARM] 4965/1: mag...
436
437
438
  	},
  	/* No IRQ handler in the PASIC3, DS1WM needs an external IRQ */
  	[1] = {
ccb6f9aec   Petr Cvek   ARM: pxa: magicia...
439
440
441
  		.start	= PXA_GPIO_TO_IRQ(GPIO107_MAGICIAN_DS1WM_IRQ),
  		.end	= PXA_GPIO_TO_IRQ(GPIO107_MAGICIAN_DS1WM_IRQ),
  		.flags	= IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE,
81447b2ee   Philipp Zabel   [ARM] 4965/1: mag...
442
443
444
445
  	}
  };
  
  static struct pasic3_platform_data pasic3_platform_data = {
28496be98   Petr Cvek   ARM: pxa: magicia...
446
  	.clock_rate = 4000000,
81447b2ee   Philipp Zabel   [ARM] 4965/1: mag...
447
448
449
450
451
452
453
454
455
456
457
  };
  
  static struct platform_device pasic3 = {
  	.name		= "pasic3",
  	.id		= -1,
  	.num_resources	= ARRAY_SIZE(pasic3_resources),
  	.resource	= pasic3_resources,
  	.dev = {
  		.platform_data = &pasic3_platform_data,
  	},
  };
e5c271ec3   Philipp Zabel   [ARM] 4664/1: Add...
458
459
  
  /*
31134b515   Petr Cvek   ARM: pxa: magicia...
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
   * PXA UDC
   */
  
  static void magician_udc_command(int cmd)
  {
  	if (cmd == PXA2XX_UDC_CMD_CONNECT)
  		UP2OCR |= UP2OCR_DPPUE | UP2OCR_DPPUBE;
  	else if (cmd == PXA2XX_UDC_CMD_DISCONNECT)
  		UP2OCR &= ~(UP2OCR_DPPUE | UP2OCR_DPPUBE);
  }
  
  static struct pxa2xx_udc_mach_info magician_udc_info __initdata = {
  	.udc_command	= magician_udc_command,
  	.gpio_pullup	= GPIO27_MAGICIAN_USBC_PUEN,
  };
  
  /*
f36150b17   Petr Cvek   ARM: pxa: magicia...
477
   * USB device VBus detection
6489c611d   Philipp Zabel   [ARM] pxa/magicia...
478
479
480
   */
  
  static struct resource gpio_vbus_resource = {
ccb6f9aec   Petr Cvek   ARM: pxa: magicia...
481
482
483
  	.flags	= IORESOURCE_IRQ,
  	.start	= IRQ_MAGICIAN_VBUS,
  	.end	= IRQ_MAGICIAN_VBUS,
6489c611d   Philipp Zabel   [ARM] pxa/magicia...
484
485
486
  };
  
  static struct gpio_vbus_mach_info gpio_vbus_info = {
ccb6f9aec   Petr Cvek   ARM: pxa: magicia...
487
  	.gpio_pullup	= GPIO27_MAGICIAN_USBC_PUEN,
f78b3a126   Petr Cvek   ARM: pxa: magicia...
488
  	.gpio_vbus	= EGPIO_MAGICIAN_CABLE_VBUS,
6489c611d   Philipp Zabel   [ARM] pxa/magicia...
489
490
491
  };
  
  static struct platform_device gpio_vbus = {
ccb6f9aec   Petr Cvek   ARM: pxa: magicia...
492
493
494
495
  	.name		= "gpio-vbus",
  	.id		= -1,
  	.num_resources	= 1,
  	.resource	= &gpio_vbus_resource,
6489c611d   Philipp Zabel   [ARM] pxa/magicia...
496
497
498
499
500
501
  	.dev = {
  		.platform_data = &gpio_vbus_info,
  	},
  };
  
  /*
350d115d1   Philipp Zabel   [ARM] 4951/1: mag...
502
503
   * External power
   */
eac2eacc3   Petr Cvek   ARM: pxa: magicia...
504
  static int magician_supply_init(struct device *dev)
ff2792027   Philipp Zabel   [ARM] 5042/1: mag...
505
  {
eac2eacc3   Petr Cvek   ARM: pxa: magicia...
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
  	int ret = -1;
  
  	ret = gpio_request(EGPIO_MAGICIAN_CABLE_TYPE, "Cable is AC charger");
  	if (ret) {
  		pr_err("Cannot request AC/USB charger GPIO (%i)
  ", ret);
  		goto err_ac;
  	}
  
  	ret = gpio_request(EGPIO_MAGICIAN_CABLE_INSERTED, "Cable inserted");
  	if (ret) {
  		pr_err("Cannot request cable detection GPIO (%i)
  ", ret);
  		goto err_usb;
  	}
  
  	return 0;
  
  err_usb:
  	gpio_free(EGPIO_MAGICIAN_CABLE_TYPE);
  err_ac:
  	return ret;
  }
  
  static void magician_set_charge(int flags)
  {
  	if (flags & PDA_POWER_CHARGE_AC) {
  		pr_debug("Charging from AC
  ");
  		gpio_set_value(EGPIO_MAGICIAN_NICD_CHARGE, 1);
  	} else if (flags & PDA_POWER_CHARGE_USB) {
  		pr_debug("Charging from USB
  ");
  		gpio_set_value(EGPIO_MAGICIAN_NICD_CHARGE, 1);
  	} else {
  		pr_debug("Charging disabled
  ");
  		gpio_set_value(EGPIO_MAGICIAN_NICD_CHARGE, 0);
  	}
ff2792027   Philipp Zabel   [ARM] 5042/1: mag...
545
  }
350d115d1   Philipp Zabel   [ARM] 4951/1: mag...
546
547
  static int magician_is_ac_online(void)
  {
eac2eacc3   Petr Cvek   ARM: pxa: magicia...
548
549
550
551
552
553
554
555
  	return gpio_get_value(EGPIO_MAGICIAN_CABLE_INSERTED) &&
  		gpio_get_value(EGPIO_MAGICIAN_CABLE_TYPE); /* AC=1 */
  }
  
  static int magician_is_usb_online(void)
  {
  	return gpio_get_value(EGPIO_MAGICIAN_CABLE_INSERTED) &&
  		(!gpio_get_value(EGPIO_MAGICIAN_CABLE_TYPE)); /* USB=0 */
350d115d1   Philipp Zabel   [ARM] 4951/1: mag...
556
  }
eac2eacc3   Petr Cvek   ARM: pxa: magicia...
557
  static void magician_supply_exit(struct device *dev)
ff2792027   Philipp Zabel   [ARM] 5042/1: mag...
558
  {
eac2eacc3   Petr Cvek   ARM: pxa: magicia...
559
  	gpio_free(EGPIO_MAGICIAN_CABLE_INSERTED);
f78b3a126   Petr Cvek   ARM: pxa: magicia...
560
  	gpio_free(EGPIO_MAGICIAN_CABLE_TYPE);
ff2792027   Philipp Zabel   [ARM] 5042/1: mag...
561
  }
81447b2ee   Philipp Zabel   [ARM] 4965/1: mag...
562
563
564
  static char *magician_supplicants[] = {
  	"ds2760-battery.0", "backup-battery"
  };
350d115d1   Philipp Zabel   [ARM] 4951/1: mag...
565
  static struct pda_power_pdata power_supply_info = {
eac2eacc3   Petr Cvek   ARM: pxa: magicia...
566
567
  	.init			= magician_supply_init,
  	.exit			= magician_supply_exit,
ccb6f9aec   Petr Cvek   ARM: pxa: magicia...
568
  	.is_ac_online		= magician_is_ac_online,
eac2eacc3   Petr Cvek   ARM: pxa: magicia...
569
570
  	.is_usb_online		= magician_is_usb_online,
  	.set_charge		= magician_set_charge,
ccb6f9aec   Petr Cvek   ARM: pxa: magicia...
571
572
  	.supplied_to		= magician_supplicants,
  	.num_supplicants	= ARRAY_SIZE(magician_supplicants),
350d115d1   Philipp Zabel   [ARM] 4951/1: mag...
573
574
575
576
  };
  
  static struct resource power_supply_resources[] = {
  	[0] = {
ccb6f9aec   Petr Cvek   ARM: pxa: magicia...
577
578
579
580
581
  		.name	= "ac",
  		.flags	= IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE |
  			IORESOURCE_IRQ_LOWEDGE,
  		.start	= IRQ_MAGICIAN_VBUS,
  		.end	= IRQ_MAGICIAN_VBUS,
350d115d1   Philipp Zabel   [ARM] 4951/1: mag...
582
583
  	},
  	[1] = {
ccb6f9aec   Petr Cvek   ARM: pxa: magicia...
584
585
586
587
588
  		.name	= "usb",
  		.flags	= IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE |
  			IORESOURCE_IRQ_LOWEDGE,
  		.start	= IRQ_MAGICIAN_VBUS,
  		.end	= IRQ_MAGICIAN_VBUS,
350d115d1   Philipp Zabel   [ARM] 4951/1: mag...
589
590
591
592
  	},
  };
  
  static struct platform_device power_supply = {
ccb6f9aec   Petr Cvek   ARM: pxa: magicia...
593
594
595
  	.name	= "pda-power",
  	.id	= -1,
  	.dev = {
350d115d1   Philipp Zabel   [ARM] 4951/1: mag...
596
597
  		.platform_data = &power_supply_info,
  	},
ccb6f9aec   Petr Cvek   ARM: pxa: magicia...
598
599
  	.resource	= power_supply_resources,
  	.num_resources	= ARRAY_SIZE(power_supply_resources),
350d115d1   Philipp Zabel   [ARM] 4951/1: mag...
600
  };
eb650b9ed   Philipp Zabel   [ARM] pxa/magicia...
601
602
603
604
605
  /*
   * Battery charger
   */
  
  static struct regulator_consumer_supply bq24022_consumers[] = {
0bf189abc   Axel Lin   ARM: pxa: Use REG...
606
607
  	REGULATOR_SUPPLY("vbus_draw", NULL),
  	REGULATOR_SUPPLY("ac_draw", NULL),
eb650b9ed   Philipp Zabel   [ARM] pxa/magicia...
608
609
610
611
  };
  
  static struct regulator_init_data bq24022_init_data = {
  	.constraints = {
ccb6f9aec   Petr Cvek   ARM: pxa: magicia...
612
613
614
  		.max_uA		= 500000,
  		.valid_ops_mask	= REGULATOR_CHANGE_CURRENT |
  			REGULATOR_CHANGE_STATUS,
eb650b9ed   Philipp Zabel   [ARM] pxa/magicia...
615
  	},
ccb6f9aec   Petr Cvek   ARM: pxa: magicia...
616
617
  	.num_consumer_supplies	= ARRAY_SIZE(bq24022_consumers),
  	.consumer_supplies	= bq24022_consumers,
eb650b9ed   Philipp Zabel   [ARM] pxa/magicia...
618
  };
6967cca8b   Heiko Stübner   pxa: magician/hx4...
619
620
621
622
623
624
625
626
627
628
  static struct gpio bq24022_gpios[] = {
  	{ EGPIO_MAGICIAN_BQ24022_ISET2, GPIOF_OUT_INIT_LOW, "bq24022_iset2" },
  };
  
  static struct gpio_regulator_state bq24022_states[] = {
  	{ .value = 100000, .gpios = (0 << 0) },
  	{ .value = 500000, .gpios = (1 << 0) },
  };
  
  static struct gpio_regulator_config bq24022_info = {
ccb6f9aec   Petr Cvek   ARM: pxa: magicia...
629
  	.supply_name		= "bq24022",
6967cca8b   Heiko Stübner   pxa: magician/hx4...
630

ccb6f9aec   Petr Cvek   ARM: pxa: magicia...
631
632
  	.enable_gpio		= GPIO30_MAGICIAN_BQ24022_nCHARGE_EN,
  	.enable_high		= 0,
eac2eacc3   Petr Cvek   ARM: pxa: magicia...
633
  	.enabled_at_boot	= 1,
6967cca8b   Heiko Stübner   pxa: magician/hx4...
634

ccb6f9aec   Petr Cvek   ARM: pxa: magicia...
635
636
  	.gpios			= bq24022_gpios,
  	.nr_gpios		= ARRAY_SIZE(bq24022_gpios),
6967cca8b   Heiko Stübner   pxa: magician/hx4...
637

ccb6f9aec   Petr Cvek   ARM: pxa: magicia...
638
639
  	.states			= bq24022_states,
  	.nr_states		= ARRAY_SIZE(bq24022_states),
6967cca8b   Heiko Stübner   pxa: magician/hx4...
640

ccb6f9aec   Petr Cvek   ARM: pxa: magicia...
641
642
  	.type			= REGULATOR_CURRENT,
  	.init_data		= &bq24022_init_data,
eb650b9ed   Philipp Zabel   [ARM] pxa/magicia...
643
644
645
  };
  
  static struct platform_device bq24022 = {
ccb6f9aec   Petr Cvek   ARM: pxa: magicia...
646
647
648
  	.name	= "gpio-regulator",
  	.id	= -1,
  	.dev	= {
eb650b9ed   Philipp Zabel   [ARM] pxa/magicia...
649
650
651
  		.platform_data = &bq24022_info,
  	},
  };
350d115d1   Philipp Zabel   [ARM] 4951/1: mag...
652
653
  
  /*
ff5eff35c   Petr Cvek   ARM: pxa: magicia...
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
   * Vcore regulator MAX1587A
   */
  
  static struct regulator_consumer_supply magician_max1587a_consumers[] = {
  	REGULATOR_SUPPLY("vcc_core", NULL),
  };
  
  static struct regulator_init_data magician_max1587a_v3_info = {
  	.constraints = {
  		.name		= "vcc_core range",
  		.min_uV		= 700000,
  		.max_uV		= 1475000,
  		.always_on	= 1,
  		.valid_ops_mask	= REGULATOR_CHANGE_VOLTAGE,
  	},
  	.consumer_supplies	= magician_max1587a_consumers,
  	.num_consumer_supplies	= ARRAY_SIZE(magician_max1587a_consumers),
  };
  
  static struct max1586_subdev_data magician_max1587a_subdevs[] = {
  	{
  		.name		= "vcc_core",
  		.id		= MAX1586_V3,
  		.platform_data	= &magician_max1587a_v3_info,
  	}
  };
  
  static struct max1586_platform_data magician_max1587a_info = {
  	.subdevs     = magician_max1587a_subdevs,
  	.num_subdevs = ARRAY_SIZE(magician_max1587a_subdevs),
  	/*
  	 * NOTICE measured directly on the PCB (board_id == 0x3a), but
  	 * if R24 is present, it will boost the voltage
  	 * (write 1.475V, get 1.645V and smoke)
  	 */
  	.v3_gain     = MAX1586_GAIN_NO_R24,
  };
  
  static struct i2c_board_info magician_pwr_i2c_board_info[] __initdata = {
  	{
  		I2C_BOARD_INFO("max1586", 0x14),
  		.platform_data	= &magician_max1587a_info,
  	},
  };
  
  /*
bdb0c16ac   Philipp Zabel   [ARM] 4950/1: mag...
700
701
702
703
   * MMC/SD
   */
  
  static int magician_mci_init(struct device *dev,
ccb6f9aec   Petr Cvek   ARM: pxa: magicia...
704
  	irq_handler_t detect_irq, void *data)
bdb0c16ac   Philipp Zabel   [ARM] 4950/1: mag...
705
  {
ed7936f91   Michael Opdenacker   ARM: pxa: remove ...
706
  	return request_irq(IRQ_MAGICIAN_SD, detect_irq, 0,
ccb6f9aec   Petr Cvek   ARM: pxa: magicia...
707
  		"mmc card detect", data);
bdb0c16ac   Philipp Zabel   [ARM] 4950/1: mag...
708
709
710
711
712
713
714
715
  }
  
  static void magician_mci_exit(struct device *dev, void *data)
  {
  	free_irq(IRQ_MAGICIAN_SD, data);
  }
  
  static struct pxamci_platform_data magician_mci_info = {
ccb6f9aec   Petr Cvek   ARM: pxa: magicia...
716
717
718
  	.ocr_mask		= MMC_VDD_32_33|MMC_VDD_33_34,
  	.init			= magician_mci_init,
  	.exit			= magician_mci_exit,
7a648256b   Robert Jarzmik   [ARM] pxa: factor...
719
720
721
722
  	.gpio_card_detect	= -1,
  	.gpio_card_ro		= EGPIO_MAGICIAN_nSD_READONLY,
  	.gpio_card_ro_invert	= 1,
  	.gpio_power		= EGPIO_MAGICIAN_SD_POWER,
bdb0c16ac   Philipp Zabel   [ARM] 4950/1: mag...
723
724
725
726
  };
  
  
  /*
e5c271ec3   Philipp Zabel   [ARM] 4664/1: Add...
727
728
   * USB OHCI
   */
e5c271ec3   Philipp Zabel   [ARM] 4664/1: Add...
729
  static struct pxaohci_platform_data magician_ohci_info = {
097b53348   Eric Miao   [ARM] ohci-pxa27x...
730
  	.port_mode	= PMM_PERPORT_MODE,
2eb7414a9   Petr Cvek   ARM: pxa: magicia...
731
732
  	/* port1: CSR Bluetooth, port2: OTG with UDC */
  	.flags		= ENABLE_PORT1 | ENABLE_PORT2 | POWER_CONTROL_LOW,
097b53348   Eric Miao   [ARM] ohci-pxa27x...
733
  	.power_budget	= 0,
2eb7414a9   Petr Cvek   ARM: pxa: magicia...
734
  	.power_on_delay = 100,
e5c271ec3   Philipp Zabel   [ARM] 4664/1: Add...
735
  };
e5c271ec3   Philipp Zabel   [ARM] 4664/1: Add...
736
737
738
  /*
   * StrataFlash
   */
fdb902b6f   Petr Cvek   ARM: pxa: magicia...
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
  static int magician_flash_init(struct platform_device *pdev)
  {
  	int ret = gpio_request(EGPIO_MAGICIAN_FLASH_VPP, "flash Vpp enable");
  
  	if (ret) {
  		pr_err("Cannot request flash enable GPIO (%i)
  ", ret);
  		return ret;
  	}
  
  	ret = gpio_direction_output(EGPIO_MAGICIAN_FLASH_VPP, 1);
  	if (ret) {
  		pr_err("Cannot set direction for flash enable (%i)
  ", ret);
  		gpio_free(EGPIO_MAGICIAN_FLASH_VPP);
  	}
  
  	return ret;
  }
667f390be   Marc Zyngier   ARM: 6910/1: MTD:...
758
  static void magician_set_vpp(struct platform_device *pdev, int vpp)
aa7975901   Philipp Zabel   [ARM] 4949/1: mag...
759
760
761
  {
  	gpio_set_value(EGPIO_MAGICIAN_FLASH_VPP, vpp);
  }
fdb902b6f   Petr Cvek   ARM: pxa: magicia...
762
763
764
765
  static void magician_flash_exit(struct platform_device *pdev)
  {
  	gpio_free(EGPIO_MAGICIAN_FLASH_VPP);
  }
e5c271ec3   Philipp Zabel   [ARM] 4664/1: Add...
766
  static struct resource strataflash_resource = {
ccb6f9aec   Petr Cvek   ARM: pxa: magicia...
767
768
769
  	.start	= PXA_CS0_PHYS,
  	.end	= PXA_CS0_PHYS + SZ_64M - 1,
  	.flags	= IORESOURCE_MEM,
e5c271ec3   Philipp Zabel   [ARM] 4664/1: Add...
770
  };
fdb902b6f   Petr Cvek   ARM: pxa: magicia...
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
  static struct mtd_partition magician_flash_parts[] = {
  	{
  		.name		= "Bootloader",
  		.offset		= 0x0,
  		.size		= 0x40000,
  		.mask_flags	= MTD_WRITEABLE, /* EXPERIMENTAL */
  	},
  	{
  		.name		= "Linux Kernel",
  		.offset		= 0x40000,
  		.size		= MTDPART_SIZ_FULL,
  	},
  };
  
  /*
   * physmap-flash driver
   */
e5c271ec3   Philipp Zabel   [ARM] 4664/1: Add...
788
  static struct physmap_flash_data strataflash_data = {
ccb6f9aec   Petr Cvek   ARM: pxa: magicia...
789
  	.width		= 4,
fdb902b6f   Petr Cvek   ARM: pxa: magicia...
790
  	.init		= magician_flash_init,
ccb6f9aec   Petr Cvek   ARM: pxa: magicia...
791
  	.set_vpp	= magician_set_vpp,
fdb902b6f   Petr Cvek   ARM: pxa: magicia...
792
793
794
  	.exit		= magician_flash_exit,
  	.parts		= magician_flash_parts,
  	.nr_parts	= ARRAY_SIZE(magician_flash_parts),
e5c271ec3   Philipp Zabel   [ARM] 4664/1: Add...
795
796
797
  };
  
  static struct platform_device strataflash = {
ccb6f9aec   Petr Cvek   ARM: pxa: magicia...
798
799
800
801
  	.name		= "physmap-flash",
  	.id		= -1,
  	.resource	= &strataflash_resource,
  	.num_resources	= 1,
e5c271ec3   Philipp Zabel   [ARM] 4664/1: Add...
802
803
804
805
806
807
  	.dev = {
  		.platform_data = &strataflash_data,
  	},
  };
  
  /*
f36150b17   Petr Cvek   ARM: pxa: magicia...
808
   * PXA I2C main controller
f8f9d5ecf   Philipp Zabel   [ARM] pxa/magicia...
809
810
811
   */
  
  static struct i2c_pxa_platform_data i2c_info = {
0fb58abb5   Petr Cvek   ARM: pxa: magicia...
812
813
814
815
816
817
818
819
820
821
  	/* OV9640 I2C device doesn't support fast mode */
  	.fast_mode	= 0,
  };
  
  /*
   * PXA I2C power controller
   */
  
  static struct i2c_pxa_platform_data magician_i2c_power_info = {
  	.fast_mode	= 1,
f8f9d5ecf   Philipp Zabel   [ARM] pxa/magicia...
822
823
824
  };
  
  /*
e5c271ec3   Philipp Zabel   [ARM] 4664/1: Add...
825
826
827
828
829
   * Platform devices
   */
  
  static struct platform_device *devices[] __initdata = {
  	&gpio_keys,
70e357f84   Philipp Zabel   [ARM] 4948/1: mag...
830
  	&egpio,
e5c271ec3   Philipp Zabel   [ARM] 4664/1: Add...
831
  	&backlight,
81447b2ee   Philipp Zabel   [ARM] 4965/1: mag...
832
  	&pasic3,
eb650b9ed   Philipp Zabel   [ARM] pxa/magicia...
833
  	&bq24022,
6489c611d   Philipp Zabel   [ARM] pxa/magicia...
834
  	&gpio_vbus,
350d115d1   Philipp Zabel   [ARM] 4951/1: mag...
835
  	&power_supply,
e5c271ec3   Philipp Zabel   [ARM] 4664/1: Add...
836
  	&strataflash,
81447b2ee   Philipp Zabel   [ARM] 4965/1: mag...
837
  	&leds_gpio,
e5c271ec3   Philipp Zabel   [ARM] 4664/1: Add...
838
  };
5db15f868   Philipp Zabel   ARM: pxa/magician...
839
  static struct gpio magician_global_gpios[] = {
ccb6f9aec   Petr Cvek   ARM: pxa: magicia...
840
  	{ GPIO13_MAGICIAN_CPLD_IRQ, GPIOF_IN, "CPLD_IRQ" },
5db15f868   Philipp Zabel   ARM: pxa/magician...
841
  	{ GPIO107_MAGICIAN_DS1WM_IRQ, GPIOF_IN, "DS1WM_IRQ" },
6001ae70e   Petr Cvek   ARM: pxa: magicia...
842
843
844
845
846
  
  	/* NOTICE valid LCD init sequence */
  	{ GPIO106_MAGICIAN_LCD_DCDC_NRESET, GPIOF_OUT_INIT_LOW, "LCD DCDC nreset" },
  	{ GPIO104_MAGICIAN_LCD_VOFF_EN, GPIOF_OUT_INIT_LOW, "LCD VOFF enable" },
  	{ GPIO105_MAGICIAN_LCD_VON_EN, GPIOF_OUT_INIT_LOW, "LCD VON enable" },
5db15f868   Philipp Zabel   ARM: pxa/magician...
847
  };
e5c271ec3   Philipp Zabel   [ARM] 4664/1: Add...
848
849
  static void __init magician_init(void)
  {
e07ff8d80   Philipp Zabel   [ARM] 4952/1: mag...
850
851
  	void __iomem *cpld;
  	int lcd_select;
a1999cd1c   Philipp Zabel   [ARM] 5007/1: mag...
852
  	int err;
b168281c0   Philipp Zabel   [ARM] 4966/1: mag...
853
  	pxa2xx_mfp_config(ARRAY_AND_SIZE(magician_pin_config));
5db15f868   Philipp Zabel   ARM: pxa/magician...
854
855
  	err = gpio_request_array(ARRAY_AND_SIZE(magician_global_gpios));
  	if (err)
7f63a752c   Petr Cvek   ARM: pxa: magicia...
856
857
  		pr_err("magician: Failed to request global GPIOs: %d
  ", err);
b168281c0   Philipp Zabel   [ARM] 4966/1: mag...
858

cc155c6f2   Russell King   [ARM] pxa: allow ...
859
860
  	pxa_set_ffuart_info(NULL);
  	pxa_set_btuart_info(NULL);
cc155c6f2   Russell King   [ARM] pxa: allow ...
861

bd3208bab   Thierry Reding   ARM: pxa: magicia...
862
  	pwm_add_table(magician_pwm_lookup, ARRAY_SIZE(magician_pwm_lookup));
a1999cd1c   Philipp Zabel   [ARM] 5007/1: mag...
863

5db15f868   Philipp Zabel   ARM: pxa/magician...
864
  	pxa_set_ficp_info(&magician_ficp_info);
0fb58abb5   Petr Cvek   ARM: pxa: magicia...
865
  	pxa27x_set_i2c_power_info(&magician_i2c_power_info);
f8f9d5ecf   Philipp Zabel   [ARM] pxa/magicia...
866
  	pxa_set_i2c_info(&i2c_info);
ff5eff35c   Petr Cvek   ARM: pxa: magicia...
867
868
869
  
  	i2c_register_board_info(1,
  		ARRAY_AND_SIZE(magician_pwr_i2c_board_info));
bdb0c16ac   Philipp Zabel   [ARM] 4950/1: mag...
870
  	pxa_set_mci_info(&magician_mci_info);
e5c271ec3   Philipp Zabel   [ARM] 4664/1: Add...
871
  	pxa_set_ohci_info(&magician_ohci_info);
31134b515   Petr Cvek   ARM: pxa: magicia...
872
  	pxa_set_udc_info(&magician_udc_info);
e07ff8d80   Philipp Zabel   [ARM] 4952/1: mag...
873
874
875
876
  
  	/* Check LCD type we have */
  	cpld = ioremap_nocache(PXA_CS3_PHYS, 0x1000);
  	if (cpld) {
ccb6f9aec   Petr Cvek   ARM: pxa: magicia...
877
  		u8 board_id = __raw_readb(cpld + 0x14);
a1999cd1c   Philipp Zabel   [ARM] 5007/1: mag...
878
  		iounmap(cpld);
e07ff8d80   Philipp Zabel   [ARM] 4952/1: mag...
879
880
  		system_rev = board_id & 0x7;
  		lcd_select = board_id & 0x8;
e07ff8d80   Philipp Zabel   [ARM] 4952/1: mag...
881
882
  		pr_info("LCD type: %s
  ", lcd_select ? "Samsung" : "Toppoly");
5db15f868   Philipp Zabel   ARM: pxa/magician...
883
  		if (lcd_select && (system_rev < 3))
6001ae70e   Petr Cvek   ARM: pxa: magicia...
884
  			/* NOTICE valid LCD init sequence */
5db15f868   Philipp Zabel   ARM: pxa/magician...
885
  			gpio_request_one(GPIO75_MAGICIAN_SAMSUNG_POWER,
6382a5947   Petr Cvek   ARM: pxa: magicia...
886
  				GPIOF_OUT_INIT_LOW, "Samsung LCD Power");
ccb6f9aec   Petr Cvek   ARM: pxa: magicia...
887
888
  		pxa_set_fb_info(NULL,
  			lcd_select ? &samsung_info : &toppoly_info);
e07ff8d80   Philipp Zabel   [ARM] 4952/1: mag...
889
890
891
  	} else
  		pr_err("LCD detection: CPLD mapping failed
  ");
e2f1b8b0a   Petr Cvek   ARM: pxa: magicia...
892
893
894
  
  	regulator_register_always_on(0, "power", pwm_backlight_supply,
  		ARRAY_SIZE(pwm_backlight_supply), 5000000);
78afa4fcf   Petr Cvek   ARM: pxa: magicia...
895
896
  
  	platform_add_devices(ARRAY_AND_SIZE(devices));
e5c271ec3   Philipp Zabel   [ARM] 4664/1: Add...
897
  }
e5c271ec3   Philipp Zabel   [ARM] 4664/1: Add...
898
  MACHINE_START(MAGICIAN, "HTC Magician")
ccb6f9aec   Petr Cvek   ARM: pxa: magicia...
899
900
901
902
903
904
  	.atag_offset	= 0x100,
  	.map_io		= pxa27x_map_io,
  	.nr_irqs	= MAGICIAN_NR_IRQS,
  	.init_irq	= pxa27x_init_irq,
  	.handle_irq	= pxa27x_handle_irq,
  	.init_machine	= magician_init,
6bb27d734   Stephen Warren   ARM: delete struc...
905
  	.init_time	= pxa_timer_init,
271a74fc8   Russell King   ARM: restart: pxa...
906
  	.restart	= pxa_restart,
e5c271ec3   Philipp Zabel   [ARM] 4664/1: Add...
907
  MACHINE_END