Blame view

arch/arm/mach-pxa/balloon3.c 21.5 KB
2a23ec367   Jonathan McDowell   [ARM] pxa: balloo...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
  /*
   *  linux/arch/arm/mach-pxa/balloon3.c
   *
   *  Support for Balloonboard.org Balloon3 board.
   *
   *  Author:	Nick Bane, Wookey, Jonathan McDowell
   *  Created:	June, 2006
   *  Copyright:	Toby Churchill Ltd
   *  Derived from mainstone.c, by Nico Pitre
   *
   *  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.
   */
61cbaa928   Axel Lin   ARM: pxa: Include...
15
  #include <linux/export.h>
2a23ec367   Jonathan McDowell   [ARM] pxa: balloo...
16
17
  #include <linux/init.h>
  #include <linux/platform_device.h>
2a23ec367   Jonathan McDowell   [ARM] pxa: balloo...
18
19
20
21
22
23
  #include <linux/interrupt.h>
  #include <linux/sched.h>
  #include <linux/bitops.h>
  #include <linux/fb.h>
  #include <linux/gpio.h>
  #include <linux/ioport.h>
12a2449c7   Marek Vasut   [ARM] pxa/balloon...
24
  #include <linux/ucb1400.h>
2a23ec367   Jonathan McDowell   [ARM] pxa: balloo...
25
26
27
  #include <linux/mtd/mtd.h>
  #include <linux/mtd/partitions.h>
  #include <linux/types.h>
02a453e4a   Marek Vasut   [ARM] pxa/balloon...
28
  #include <linux/i2c/pcf857x.h>
b459396ee   Sebastian Andrzej Siewior   ARM: pxa2xx: reor...
29
  #include <linux/i2c/pxa-i2c.h>
e6a8ef547   Marek Vasut   [ARM] pxa/balloon...
30
31
  #include <linux/mtd/nand.h>
  #include <linux/mtd/physmap.h>
3a27f6e0a   Marek Vasut   [ARM] pxa/balloon...
32
  #include <linux/regulator/max1586.h>
2a23ec367   Jonathan McDowell   [ARM] pxa: balloo...
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
  
  #include <asm/setup.h>
  #include <asm/mach-types.h>
  #include <asm/irq.h>
  #include <asm/sizes.h>
  
  #include <asm/mach/arch.h>
  #include <asm/mach/map.h>
  #include <asm/mach/irq.h>
  #include <asm/mach/flash.h>
  
  #include <mach/pxa27x.h>
  #include <mach/balloon3.h>
  #include <mach/audio.h>
  #include <mach/pxafb.h>
  #include <mach/mmc.h>
  #include <mach/udc.h>
  #include <mach/pxa27x-udc.h>
  #include <mach/irda.h>
  #include <mach/ohci.h>
2a23ec367   Jonathan McDowell   [ARM] pxa: balloo...
53
54
  #include "generic.h"
  #include "devices.h"
b0240bf4d   Marek Vasut   [ARM] pxa/balloon...
55
56
57
58
59
60
61
62
63
  /******************************************************************************
   * Pin configuration
   ******************************************************************************/
  static unsigned long balloon3_pin_config[] __initdata = {
  	/* Select BTUART 'COM1/ttyS0' as IO option for pins 42/43/44/45 */
  	GPIO42_BTUART_RXD,
  	GPIO43_BTUART_TXD,
  	GPIO44_BTUART_CTS,
  	GPIO45_BTUART_RTS,
2a23ec367   Jonathan McDowell   [ARM] pxa: balloo...
64

12a2449c7   Marek Vasut   [ARM] pxa/balloon...
65
  	/* Reset, configured as GPIO wakeup source */
b0240bf4d   Marek Vasut   [ARM] pxa/balloon...
66
  	GPIO1_GPIO | WAKEUP_ON_EDGE_BOTH,
c11b6a420   Eric Miao   [ARM] pxa: add th...
67
  };
b0240bf4d   Marek Vasut   [ARM] pxa/balloon...
68
  /******************************************************************************
12a2449c7   Marek Vasut   [ARM] pxa/balloon...
69
   * Compatibility: Parameter parsing
b0240bf4d   Marek Vasut   [ARM] pxa/balloon...
70
   ******************************************************************************/
12a2449c7   Marek Vasut   [ARM] pxa/balloon...
71
  static unsigned long balloon3_irq_enabled;
b0240bf4d   Marek Vasut   [ARM] pxa/balloon...
72

12a2449c7   Marek Vasut   [ARM] pxa/balloon...
73
74
75
76
77
78
  static unsigned long balloon3_features_present =
  		(1 << BALLOON3_FEATURE_OHCI) | (1 << BALLOON3_FEATURE_CF) |
  		(1 << BALLOON3_FEATURE_AUDIO) |
  		(1 << BALLOON3_FEATURE_TOPPOLY);
  
  int balloon3_has(enum balloon3_features feature)
2a23ec367   Jonathan McDowell   [ARM] pxa: balloo...
79
  {
12a2449c7   Marek Vasut   [ARM] pxa/balloon...
80
81
82
83
84
85
86
87
88
89
  	return (balloon3_features_present & (1 << feature)) ? 1 : 0;
  }
  EXPORT_SYMBOL_GPL(balloon3_has);
  
  int __init parse_balloon3_features(char *arg)
  {
  	if (!arg)
  		return 0;
  
  	return strict_strtoul(arg, 0, &balloon3_features_present);
2a23ec367   Jonathan McDowell   [ARM] pxa: balloo...
90
  }
12a2449c7   Marek Vasut   [ARM] pxa/balloon...
91
  early_param("balloon3_features", parse_balloon3_features);
2a23ec367   Jonathan McDowell   [ARM] pxa: balloo...
92

12a2449c7   Marek Vasut   [ARM] pxa/balloon...
93
  /******************************************************************************
b476ef059   Marek Vasut   ARM: pxa/balloon3...
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
   * Compact Flash slot
   ******************************************************************************/
  #if	defined(CONFIG_PCMCIA_PXA2XX) || defined(CONFIG_PCMCIA_PXA2XX_MODULE)
  static unsigned long balloon3_cf_pin_config[] __initdata = {
  	GPIO48_nPOE,
  	GPIO49_nPWE,
  	GPIO50_nPIOR,
  	GPIO51_nPIOW,
  	GPIO85_nPCE_1,
  	GPIO54_nPCE_2,
  	GPIO79_PSKTSEL,
  	GPIO55_nPREG,
  	GPIO56_nPWAIT,
  	GPIO57_nIOIS16,
  };
  
  static void __init balloon3_cf_init(void)
  {
  	if (!balloon3_has(BALLOON3_FEATURE_CF))
  		return;
  
  	pxa2xx_mfp_config(ARRAY_AND_SIZE(balloon3_cf_pin_config));
  }
  #else
  static inline void balloon3_cf_init(void) {}
  #endif
  
  /******************************************************************************
12a2449c7   Marek Vasut   [ARM] pxa/balloon...
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
   * NOR Flash
   ******************************************************************************/
  #if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE)
  static struct mtd_partition balloon3_nor_partitions[] = {
  	{
  		.name		= "Flash",
  		.offset		= 0x00000000,
  		.size		= MTDPART_SIZ_FULL,
  	}
  };
  
  static struct physmap_flash_data balloon3_flash_data[] = {
  	{
  		.width		= 2,	/* bankwidth in bytes */
  		.parts		= balloon3_nor_partitions,
  		.nr_parts	= ARRAY_SIZE(balloon3_nor_partitions)
  	}
  };
  
  static struct resource balloon3_flash_resource = {
  	.start	= PXA_CS0_PHYS,
  	.end	= PXA_CS0_PHYS + SZ_64M - 1,
  	.flags	= IORESOURCE_MEM,
  };
  
  static struct platform_device balloon3_flash = {
  	.name		= "physmap-flash",
  	.id		= 0,
  	.resource	= &balloon3_flash_resource,
  	.num_resources	= 1,
  	.dev 		= {
  		.platform_data = balloon3_flash_data,
  	},
  };
  static void __init balloon3_nor_init(void)
  {
  	platform_device_register(&balloon3_flash);
  }
  #else
  static inline void balloon3_nor_init(void) {}
  #endif
  
  /******************************************************************************
   * Audio and Touchscreen
   ******************************************************************************/
  #if	defined(CONFIG_TOUCHSCREEN_UCB1400) || \
  	defined(CONFIG_TOUCHSCREEN_UCB1400_MODULE)
b476ef059   Marek Vasut   ARM: pxa/balloon3...
169
170
171
172
173
174
175
176
  static unsigned long balloon3_ac97_pin_config[] __initdata = {
  	GPIO28_AC97_BITCLK,
  	GPIO29_AC97_SDATA_IN_0,
  	GPIO30_AC97_SDATA_OUT,
  	GPIO31_AC97_SYNC,
  	GPIO113_AC97_nRESET,
  	GPIO95_GPIO,
  };
12a2449c7   Marek Vasut   [ARM] pxa/balloon...
177
  static struct ucb1400_pdata vpac270_ucb1400_pdata = {
6384fdadb   Haojian Zhuang   ARM: pxa: rename ...
178
  	.irq		= PXA_GPIO_TO_IRQ(BALLOON3_GPIO_CODEC_IRQ),
12a2449c7   Marek Vasut   [ARM] pxa/balloon...
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
  };
  
  
  static struct platform_device balloon3_ucb1400_device = {
  	.name		= "ucb1400_core",
  	.id		= -1,
  	.dev		= {
  		.platform_data = &vpac270_ucb1400_pdata,
  	},
  };
  
  static void __init balloon3_ts_init(void)
  {
  	if (!balloon3_has(BALLOON3_FEATURE_AUDIO))
  		return;
b476ef059   Marek Vasut   ARM: pxa/balloon3...
194
  	pxa2xx_mfp_config(ARRAY_AND_SIZE(balloon3_ac97_pin_config));
12a2449c7   Marek Vasut   [ARM] pxa/balloon...
195
196
197
198
199
200
201
202
203
204
205
  	pxa_set_ac97_info(NULL);
  	platform_device_register(&balloon3_ucb1400_device);
  }
  #else
  static inline void balloon3_ts_init(void) {}
  #endif
  
  /******************************************************************************
   * Framebuffer
   ******************************************************************************/
  #if defined(CONFIG_FB_PXA) || defined(CONFIG_FB_PXA_MODULE)
b476ef059   Marek Vasut   ARM: pxa/balloon3...
206
207
208
209
  static unsigned long balloon3_lcd_pin_config[] __initdata = {
  	GPIOxx_LCD_TFT_16BPP,
  	GPIO99_GPIO,
  };
2a23ec367   Jonathan McDowell   [ARM] pxa: balloo...
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
  static struct pxafb_mode_info balloon3_lcd_modes[] = {
  	{
  		.pixclock		= 38000,
  		.xres			= 480,
  		.yres			= 640,
  		.bpp			= 16,
  		.hsync_len		= 8,
  		.left_margin		= 8,
  		.right_margin		= 8,
  		.vsync_len		= 2,
  		.upper_margin		= 4,
  		.lower_margin		= 5,
  		.sync			= 0,
  	},
  };
12a2449c7   Marek Vasut   [ARM] pxa/balloon...
225
  static struct pxafb_mach_info balloon3_lcd_screen = {
2a23ec367   Jonathan McDowell   [ARM] pxa: balloo...
226
227
228
  	.modes			= balloon3_lcd_modes,
  	.num_modes		= ARRAY_SIZE(balloon3_lcd_modes),
  	.lcd_conn		= LCD_COLOR_TFT_16BPP | LCD_PCLK_EDGE_FALL,
2a23ec367   Jonathan McDowell   [ARM] pxa: balloo...
229
  };
12a2449c7   Marek Vasut   [ARM] pxa/balloon...
230
231
232
233
  static void balloon3_backlight_power(int on)
  {
  	gpio_set_value(BALLOON3_GPIO_RUN_BACKLIGHT, on);
  }
2a23ec367   Jonathan McDowell   [ARM] pxa: balloo...
234

12a2449c7   Marek Vasut   [ARM] pxa/balloon...
235
  static void __init balloon3_lcd_init(void)
2a23ec367   Jonathan McDowell   [ARM] pxa: balloo...
236
  {
12a2449c7   Marek Vasut   [ARM] pxa/balloon...
237
238
239
240
  	int ret;
  
  	if (!balloon3_has(BALLOON3_FEATURE_TOPPOLY))
  		return;
b476ef059   Marek Vasut   ARM: pxa/balloon3...
241
  	pxa2xx_mfp_config(ARRAY_AND_SIZE(balloon3_lcd_pin_config));
12a2449c7   Marek Vasut   [ARM] pxa/balloon...
242
243
244
245
246
247
248
249
250
251
252
253
  	ret = gpio_request(BALLOON3_GPIO_RUN_BACKLIGHT, "BKL-ON");
  	if (ret) {
  		pr_err("Requesting BKL-ON GPIO failed!
  ");
  		goto err;
  	}
  
  	ret = gpio_direction_output(BALLOON3_GPIO_RUN_BACKLIGHT, 1);
  	if (ret) {
  		pr_err("Setting BKL-ON GPIO direction failed!
  ");
  		goto err2;
2a23ec367   Jonathan McDowell   [ARM] pxa: balloo...
254
  	}
12a2449c7   Marek Vasut   [ARM] pxa/balloon...
255
256
  
  	balloon3_lcd_screen.pxafb_backlight_power = balloon3_backlight_power;
4321e1a12   Russell King - ARM Linux   ARM: pxa: clean u...
257
  	pxa_set_fb_info(NULL, &balloon3_lcd_screen);
12a2449c7   Marek Vasut   [ARM] pxa/balloon...
258
259
260
261
262
263
  	return;
  
  err2:
  	gpio_free(BALLOON3_GPIO_RUN_BACKLIGHT);
  err:
  	return;
2a23ec367   Jonathan McDowell   [ARM] pxa: balloo...
264
  }
12a2449c7   Marek Vasut   [ARM] pxa/balloon...
265
266
267
  #else
  static inline void balloon3_lcd_init(void) {}
  #endif
2a23ec367   Jonathan McDowell   [ARM] pxa: balloo...
268

12a2449c7   Marek Vasut   [ARM] pxa/balloon...
269
270
271
272
  /******************************************************************************
   * SD/MMC card controller
   ******************************************************************************/
  #if defined(CONFIG_MMC_PXA) || defined(CONFIG_MMC_PXA_MODULE)
b476ef059   Marek Vasut   ARM: pxa/balloon3...
273
274
275
276
277
278
279
280
  static unsigned long balloon3_mmc_pin_config[] __initdata = {
  	GPIO32_MMC_CLK,
  	GPIO92_MMC_DAT_0,
  	GPIO109_MMC_DAT_1,
  	GPIO110_MMC_DAT_2,
  	GPIO111_MMC_DAT_3,
  	GPIO112_MMC_CMD,
  };
2a23ec367   Jonathan McDowell   [ARM] pxa: balloo...
281
  static struct pxamci_platform_data balloon3_mci_platform_data = {
12a2449c7   Marek Vasut   [ARM] pxa/balloon...
282
283
284
285
286
  	.ocr_mask		= MMC_VDD_32_33 | MMC_VDD_33_34,
  	.gpio_card_detect	= -1,
  	.gpio_card_ro		= -1,
  	.gpio_power		= -1,
  	.detect_delay_ms	= 200,
2a23ec367   Jonathan McDowell   [ARM] pxa: balloo...
287
  };
12a2449c7   Marek Vasut   [ARM] pxa/balloon...
288
289
  static void __init balloon3_mmc_init(void)
  {
b476ef059   Marek Vasut   ARM: pxa/balloon3...
290
  	pxa2xx_mfp_config(ARRAY_AND_SIZE(balloon3_mmc_pin_config));
12a2449c7   Marek Vasut   [ARM] pxa/balloon...
291
292
293
294
295
  	pxa_set_mci_info(&balloon3_mci_platform_data);
  }
  #else
  static inline void balloon3_mmc_init(void) {}
  #endif
b0240bf4d   Marek Vasut   [ARM] pxa/balloon...
296
297
298
  /******************************************************************************
   * USB Gadget
   ******************************************************************************/
c0a39151a   Haojian Zhuang   ARM: pxa: fix inc...
299
  #if defined(CONFIG_USB_PXA27X)||defined(CONFIG_USB_PXA27X_MODULE)
12a2449c7   Marek Vasut   [ARM] pxa/balloon...
300
  static void balloon3_udc_command(int cmd)
2a23ec367   Jonathan McDowell   [ARM] pxa: balloo...
301
  {
12a2449c7   Marek Vasut   [ARM] pxa/balloon...
302
303
304
305
  	if (cmd == PXA2XX_UDC_CMD_CONNECT)
  		UP2OCR |= UP2OCR_DPPUE | UP2OCR_DPPUBE;
  	else if (cmd == PXA2XX_UDC_CMD_DISCONNECT)
  		UP2OCR &= ~UP2OCR_DPPUE;
2a23ec367   Jonathan McDowell   [ARM] pxa: balloo...
306
  }
12a2449c7   Marek Vasut   [ARM] pxa/balloon...
307
  static int balloon3_udc_is_connected(void)
2a23ec367   Jonathan McDowell   [ARM] pxa: balloo...
308
  {
12a2449c7   Marek Vasut   [ARM] pxa/balloon...
309
  	return 1;
2a23ec367   Jonathan McDowell   [ARM] pxa: balloo...
310
  }
12a2449c7   Marek Vasut   [ARM] pxa/balloon...
311
312
313
314
  static struct pxa2xx_udc_mach_info balloon3_udc_info __initdata = {
  	.udc_command		= balloon3_udc_command,
  	.udc_is_connected	= balloon3_udc_is_connected,
  	.gpio_pullup		= -1,
2a23ec367   Jonathan McDowell   [ARM] pxa: balloo...
315
  };
12a2449c7   Marek Vasut   [ARM] pxa/balloon...
316
317
318
319
320
321
322
323
  static void __init balloon3_udc_init(void)
  {
  	pxa_set_udc_info(&balloon3_udc_info);
  	platform_device_register(&balloon3_gpio_vbus);
  }
  #else
  static inline void balloon3_udc_init(void) {}
  #endif
b0240bf4d   Marek Vasut   [ARM] pxa/balloon...
324
325
326
  /******************************************************************************
   * IrDA
   ******************************************************************************/
12a2449c7   Marek Vasut   [ARM] pxa/balloon...
327
  #if defined(CONFIG_IRDA) || defined(CONFIG_IRDA_MODULE)
2a23ec367   Jonathan McDowell   [ARM] pxa: balloo...
328
  static struct pxaficp_platform_data balloon3_ficp_platform_data = {
12a2449c7   Marek Vasut   [ARM] pxa/balloon...
329
  	.transceiver_cap	= IR_FIRMODE | IR_SIRMODE | IR_OFF,
2a23ec367   Jonathan McDowell   [ARM] pxa: balloo...
330
  };
12a2449c7   Marek Vasut   [ARM] pxa/balloon...
331
332
333
334
335
336
337
  static void __init balloon3_irda_init(void)
  {
  	pxa_set_ficp_info(&balloon3_ficp_platform_data);
  }
  #else
  static inline void balloon3_irda_init(void) {}
  #endif
b0240bf4d   Marek Vasut   [ARM] pxa/balloon...
338
339
340
  /******************************************************************************
   * USB Host
   ******************************************************************************/
12a2449c7   Marek Vasut   [ARM] pxa/balloon...
341
  #if defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE)
b476ef059   Marek Vasut   ARM: pxa/balloon3...
342
343
344
345
  static unsigned long balloon3_uhc_pin_config[] __initdata = {
  	GPIO88_USBH1_PWR,
  	GPIO89_USBH1_PEN,
  };
12a2449c7   Marek Vasut   [ARM] pxa/balloon...
346
  static struct pxaohci_platform_data balloon3_ohci_info = {
2a23ec367   Jonathan McDowell   [ARM] pxa: balloo...
347
348
349
  	.port_mode	= PMM_PERPORT_MODE,
  	.flags		= ENABLE_PORT_ALL | POWER_CONTROL_LOW | POWER_SENSE_LOW,
  };
12a2449c7   Marek Vasut   [ARM] pxa/balloon...
350
351
352
353
  static void __init balloon3_uhc_init(void)
  {
  	if (!balloon3_has(BALLOON3_FEATURE_OHCI))
  		return;
b476ef059   Marek Vasut   ARM: pxa/balloon3...
354
  	pxa2xx_mfp_config(ARRAY_AND_SIZE(balloon3_uhc_pin_config));
12a2449c7   Marek Vasut   [ARM] pxa/balloon...
355
356
357
358
359
  	pxa_set_ohci_info(&balloon3_ohci_info);
  }
  #else
  static inline void balloon3_uhc_init(void) {}
  #endif
b0240bf4d   Marek Vasut   [ARM] pxa/balloon...
360
  /******************************************************************************
12a2449c7   Marek Vasut   [ARM] pxa/balloon...
361
   * LEDs
b0240bf4d   Marek Vasut   [ARM] pxa/balloon...
362
   ******************************************************************************/
12a2449c7   Marek Vasut   [ARM] pxa/balloon...
363
  #if defined(CONFIG_LEDS_GPIO) || defined(CONFIG_LEDS_GPIO_MODULE)
b476ef059   Marek Vasut   ARM: pxa/balloon3...
364
365
366
367
  static unsigned long balloon3_led_pin_config[] __initdata = {
  	GPIO9_GPIO,	/* NAND activity LED */
  	GPIO10_GPIO,	/* Heartbeat LED */
  };
12a2449c7   Marek Vasut   [ARM] pxa/balloon...
368
  struct gpio_led balloon3_gpio_leds[] = {
2a23ec367   Jonathan McDowell   [ARM] pxa: balloo...
369
370
371
372
373
  	{
  		.name			= "balloon3:green:idle",
  		.default_trigger	= "heartbeat",
  		.gpio			= BALLOON3_GPIO_LED_IDLE,
  		.active_low		= 1,
12a2449c7   Marek Vasut   [ARM] pxa/balloon...
374
  	}, {
2a23ec367   Jonathan McDowell   [ARM] pxa: balloo...
375
376
377
378
379
380
  		.name			= "balloon3:green:nand",
  		.default_trigger	= "nand-disk",
  		.gpio			= BALLOON3_GPIO_LED_NAND,
  		.active_low		= 1,
  	},
  };
12a2449c7   Marek Vasut   [ARM] pxa/balloon...
381
  static struct gpio_led_platform_data balloon3_gpio_led_info = {
2a23ec367   Jonathan McDowell   [ARM] pxa: balloo...
382
383
384
  	.leds		= balloon3_gpio_leds,
  	.num_leds	= ARRAY_SIZE(balloon3_gpio_leds),
  };
12a2449c7   Marek Vasut   [ARM] pxa/balloon...
385
  static struct platform_device balloon3_leds = {
2a23ec367   Jonathan McDowell   [ARM] pxa: balloo...
386
  	.name	= "leds-gpio",
02a453e4a   Marek Vasut   [ARM] pxa/balloon...
387
  	.id	= 0,
2a23ec367   Jonathan McDowell   [ARM] pxa: balloo...
388
  	.dev	= {
12a2449c7   Marek Vasut   [ARM] pxa/balloon...
389
390
  		.platform_data	= &balloon3_gpio_led_info,
  	}
2a23ec367   Jonathan McDowell   [ARM] pxa: balloo...
391
  };
02a453e4a   Marek Vasut   [ARM] pxa/balloon...
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
  struct gpio_led balloon3_pcf_gpio_leds[] = {
  	{
  		.name			= "balloon3:green:led0",
  		.gpio			= BALLOON3_PCF_GPIO_LED0,
  		.active_low		= 1,
  	}, {
  		.name			= "balloon3:green:led1",
  		.gpio			= BALLOON3_PCF_GPIO_LED1,
  		.active_low		= 1,
  	}, {
  		.name			= "balloon3:orange:led2",
  		.gpio			= BALLOON3_PCF_GPIO_LED2,
  		.active_low		= 1,
  	}, {
  		.name			= "balloon3:orange:led3",
  		.gpio			= BALLOON3_PCF_GPIO_LED3,
  		.active_low		= 1,
  	}, {
  		.name			= "balloon3:orange:led4",
  		.gpio			= BALLOON3_PCF_GPIO_LED4,
  		.active_low		= 1,
  	}, {
  		.name			= "balloon3:orange:led5",
  		.gpio			= BALLOON3_PCF_GPIO_LED5,
  		.active_low		= 1,
  	}, {
  		.name			= "balloon3:red:led6",
  		.gpio			= BALLOON3_PCF_GPIO_LED6,
  		.active_low		= 1,
  	}, {
  		.name			= "balloon3:red:led7",
  		.gpio			= BALLOON3_PCF_GPIO_LED7,
  		.active_low		= 1,
  	},
  };
  
  static struct gpio_led_platform_data balloon3_pcf_gpio_led_info = {
  	.leds		= balloon3_pcf_gpio_leds,
  	.num_leds	= ARRAY_SIZE(balloon3_pcf_gpio_leds),
  };
  
  static struct platform_device balloon3_pcf_leds = {
  	.name	= "leds-gpio",
  	.id	= 1,
  	.dev	= {
  		.platform_data	= &balloon3_pcf_gpio_led_info,
  	}
  };
12a2449c7   Marek Vasut   [ARM] pxa/balloon...
440
  static void __init balloon3_leds_init(void)
b0240bf4d   Marek Vasut   [ARM] pxa/balloon...
441
  {
b476ef059   Marek Vasut   ARM: pxa/balloon3...
442
  	pxa2xx_mfp_config(ARRAY_AND_SIZE(balloon3_led_pin_config));
12a2449c7   Marek Vasut   [ARM] pxa/balloon...
443
  	platform_device_register(&balloon3_leds);
02a453e4a   Marek Vasut   [ARM] pxa/balloon...
444
  	platform_device_register(&balloon3_pcf_leds);
b0240bf4d   Marek Vasut   [ARM] pxa/balloon...
445
  }
12a2449c7   Marek Vasut   [ARM] pxa/balloon...
446
447
448
  #else
  static inline void balloon3_leds_init(void) {}
  #endif
b0240bf4d   Marek Vasut   [ARM] pxa/balloon...
449
450
451
452
  
  /******************************************************************************
   * FPGA IRQ
   ******************************************************************************/
a3f4c927d   Lennert Buytenhek   ARM: PXA SoCs: ir...
453
  static void balloon3_mask_irq(struct irq_data *d)
b0240bf4d   Marek Vasut   [ARM] pxa/balloon...
454
  {
a3f4c927d   Lennert Buytenhek   ARM: PXA SoCs: ir...
455
  	int balloon3_irq = (d->irq - BALLOON3_IRQ(0));
b0240bf4d   Marek Vasut   [ARM] pxa/balloon...
456
457
458
  	balloon3_irq_enabled &= ~(1 << balloon3_irq);
  	__raw_writel(~balloon3_irq_enabled, BALLOON3_INT_CONTROL_REG);
  }
a3f4c927d   Lennert Buytenhek   ARM: PXA SoCs: ir...
459
  static void balloon3_unmask_irq(struct irq_data *d)
b0240bf4d   Marek Vasut   [ARM] pxa/balloon...
460
  {
a3f4c927d   Lennert Buytenhek   ARM: PXA SoCs: ir...
461
  	int balloon3_irq = (d->irq - BALLOON3_IRQ(0));
b0240bf4d   Marek Vasut   [ARM] pxa/balloon...
462
463
464
465
466
467
  	balloon3_irq_enabled |= (1 << balloon3_irq);
  	__raw_writel(~balloon3_irq_enabled, BALLOON3_INT_CONTROL_REG);
  }
  
  static struct irq_chip balloon3_irq_chip = {
  	.name		= "FPGA",
a3f4c927d   Lennert Buytenhek   ARM: PXA SoCs: ir...
468
469
470
  	.irq_ack	= balloon3_mask_irq,
  	.irq_mask	= balloon3_mask_irq,
  	.irq_unmask	= balloon3_unmask_irq,
b0240bf4d   Marek Vasut   [ARM] pxa/balloon...
471
472
473
474
475
476
  };
  
  static void balloon3_irq_handler(unsigned int irq, struct irq_desc *desc)
  {
  	unsigned long pending = __raw_readl(BALLOON3_INT_CONTROL_REG) &
  					balloon3_irq_enabled;
b0240bf4d   Marek Vasut   [ARM] pxa/balloon...
477
478
  	do {
  		/* clear useless edge notification */
a3f4c927d   Lennert Buytenhek   ARM: PXA SoCs: ir...
479
480
481
482
483
484
  		if (desc->irq_data.chip->irq_ack) {
  			struct irq_data *d;
  
  			d = irq_get_irq_data(BALLOON3_AUX_NIRQ);
  			desc->irq_data.chip->irq_ack(d);
  		}
b0240bf4d   Marek Vasut   [ARM] pxa/balloon...
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
  		while (pending) {
  			irq = BALLOON3_IRQ(0) + __ffs(pending);
  			generic_handle_irq(irq);
  			pending &= pending - 1;
  		}
  		pending = __raw_readl(BALLOON3_INT_CONTROL_REG) &
  				balloon3_irq_enabled;
  	} while (pending);
  }
  
  static void __init balloon3_init_irq(void)
  {
  	int irq;
  
  	pxa27x_init_irq();
  	/* setup extra Balloon3 irqs */
  	for (irq = BALLOON3_IRQ(0); irq <= BALLOON3_IRQ(7); irq++) {
f38c02f3b   Thomas Gleixner   arm: Fold irq_set...
502
503
  		irq_set_chip_and_handler(irq, &balloon3_irq_chip,
  					 handle_level_irq);
b0240bf4d   Marek Vasut   [ARM] pxa/balloon...
504
505
  		set_irq_flags(irq, IRQF_VALID | IRQF_PROBE);
  	}
6845664a6   Thomas Gleixner   arm: Cleanup the ...
506
507
  	irq_set_chained_handler(BALLOON3_AUX_NIRQ, balloon3_irq_handler);
  	irq_set_irq_type(BALLOON3_AUX_NIRQ, IRQ_TYPE_EDGE_FALLING);
b0240bf4d   Marek Vasut   [ARM] pxa/balloon...
508
509
510
511
512
513
514
  
  	pr_debug("%s: chained handler installed - irq %d automatically "
  		"enabled
  ", __func__, BALLOON3_AUX_NIRQ);
  }
  
  /******************************************************************************
02a453e4a   Marek Vasut   [ARM] pxa/balloon...
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
   * GPIO expander
   ******************************************************************************/
  #if defined(CONFIG_GPIO_PCF857X) || defined(CONFIG_GPIO_PCF857X_MODULE)
  static struct pcf857x_platform_data balloon3_pcf857x_pdata = {
  	.gpio_base	= BALLOON3_PCF_GPIO_BASE,
  	.n_latch	= 0,
  	.setup		= NULL,
  	.teardown	= NULL,
  	.context	= NULL,
  };
  
  static struct i2c_board_info __initdata balloon3_i2c_devs[] = {
  	{
  		I2C_BOARD_INFO("pcf8574a", 0x38),
  		.platform_data	= &balloon3_pcf857x_pdata,
  	},
  };
  
  static void __init balloon3_i2c_init(void)
  {
  	pxa_set_i2c_info(NULL);
  	i2c_register_board_info(0, ARRAY_AND_SIZE(balloon3_i2c_devs));
  }
  #else
  static inline void balloon3_i2c_init(void) {}
  #endif
  
  /******************************************************************************
e6a8ef547   Marek Vasut   [ARM] pxa/balloon...
543
544
545
   * NAND
   ******************************************************************************/
  #if defined(CONFIG_MTD_NAND_PLATFORM)||defined(CONFIG_MTD_NAND_PLATFORM_MODULE)
e6a8ef547   Marek Vasut   [ARM] pxa/balloon...
546
547
548
  static void balloon3_nand_cmd_ctl(struct mtd_info *mtd, int cmd, unsigned int ctrl)
  {
  	struct nand_chip *this = mtd->priv;
1b9169d8a   Marek Vasut   ARM: pxa: Update ...
549
  	uint8_t balloon3_ctl_set = 0, balloon3_ctl_clr = 0;
e6a8ef547   Marek Vasut   [ARM] pxa/balloon...
550
551
552
  
  	if (ctrl & NAND_CTRL_CHANGE) {
  		if (ctrl & NAND_CLE)
1b9169d8a   Marek Vasut   ARM: pxa: Update ...
553
  			balloon3_ctl_set |= BALLOON3_NAND_CONTROL_FLCLE;
e6a8ef547   Marek Vasut   [ARM] pxa/balloon...
554
  		else
1b9169d8a   Marek Vasut   ARM: pxa: Update ...
555
  			balloon3_ctl_clr |= BALLOON3_NAND_CONTROL_FLCLE;
e6a8ef547   Marek Vasut   [ARM] pxa/balloon...
556
557
  
  		if (ctrl & NAND_ALE)
1b9169d8a   Marek Vasut   ARM: pxa: Update ...
558
  			balloon3_ctl_set |= BALLOON3_NAND_CONTROL_FLALE;
e6a8ef547   Marek Vasut   [ARM] pxa/balloon...
559
  		else
1b9169d8a   Marek Vasut   ARM: pxa: Update ...
560
561
562
563
564
565
566
  			balloon3_ctl_clr |= BALLOON3_NAND_CONTROL_FLALE;
  
  		if (balloon3_ctl_clr)
  			__raw_writel(balloon3_ctl_clr,
  				BALLOON3_NAND_CONTROL_REG);
  		if (balloon3_ctl_set)
  			__raw_writel(balloon3_ctl_set,
97b09da4e   Arnd Bergmann   ARM: pxa: use cor...
567
  				BALLOON3_NAND_CONTROL_REG +
1b9169d8a   Marek Vasut   ARM: pxa: Update ...
568
  				BALLOON3_FPGA_SETnCLR);
e6a8ef547   Marek Vasut   [ARM] pxa/balloon...
569
570
571
572
573
574
575
576
577
578
  	}
  
  	if (cmd != NAND_CMD_NONE)
  		writeb(cmd, this->IO_ADDR_W);
  }
  
  static void balloon3_nand_select_chip(struct mtd_info *mtd, int chip)
  {
  	if (chip < 0 || chip > 3)
  		return;
1b9169d8a   Marek Vasut   ARM: pxa: Update ...
579
580
581
582
  	/* Assert all nCE lines */
  	__raw_writew(
  		BALLOON3_NAND_CONTROL_FLCE0 | BALLOON3_NAND_CONTROL_FLCE1 |
  		BALLOON3_NAND_CONTROL_FLCE2 | BALLOON3_NAND_CONTROL_FLCE3,
97b09da4e   Arnd Bergmann   ARM: pxa: use cor...
583
  		BALLOON3_NAND_CONTROL_REG + BALLOON3_FPGA_SETnCLR);
e6a8ef547   Marek Vasut   [ARM] pxa/balloon...
584
585
  
  	/* Deassert correct nCE line */
1b9169d8a   Marek Vasut   ARM: pxa: Update ...
586
587
  	__raw_writew(BALLOON3_NAND_CONTROL_FLCE0 << chip,
  		BALLOON3_NAND_CONTROL_REG);
e6a8ef547   Marek Vasut   [ARM] pxa/balloon...
588
  }
59bdd1335   Marek Vasut   ARM: pxa: Add Bal...
589
590
591
592
  static int balloon3_nand_dev_ready(struct mtd_info *mtd)
  {
  	return __raw_readl(BALLOON3_NAND_STAT_REG) & BALLOON3_NAND_STAT_RNB;
  }
e6a8ef547   Marek Vasut   [ARM] pxa/balloon...
593
594
  static int balloon3_nand_probe(struct platform_device *pdev)
  {
e6a8ef547   Marek Vasut   [ARM] pxa/balloon...
595
596
  	uint16_t ver;
  	int ret;
1b9169d8a   Marek Vasut   ARM: pxa: Update ...
597
  	__raw_writew(BALLOON3_NAND_CONTROL2_16BIT,
97b09da4e   Arnd Bergmann   ARM: pxa: use cor...
598
  		BALLOON3_NAND_CONTROL2_REG + BALLOON3_FPGA_SETnCLR);
e6a8ef547   Marek Vasut   [ARM] pxa/balloon...
599
600
  
  	ver = __raw_readw(BALLOON3_FPGA_VER);
1b9169d8a   Marek Vasut   ARM: pxa: Update ...
601
602
  	if (ver < 0x4f08)
  		pr_warn("The FPGA code, version 0x%04x, is too old. "
e6a8ef547   Marek Vasut   [ARM] pxa/balloon...
603
604
605
606
607
608
609
610
611
612
613
614
615
616
  			"NAND support might be broken in this version!", ver);
  
  	/* Power up the NAND chips */
  	ret = gpio_request(BALLOON3_GPIO_RUN_NAND, "NAND");
  	if (ret)
  		goto err1;
  
  	ret = gpio_direction_output(BALLOON3_GPIO_RUN_NAND, 1);
  	if (ret)
  		goto err2;
  
  	gpio_set_value(BALLOON3_GPIO_RUN_NAND, 1);
  
  	/* Deassert all nCE lines and write protect line */
1b9169d8a   Marek Vasut   ARM: pxa: Update ...
617
618
619
620
  	__raw_writel(
  		BALLOON3_NAND_CONTROL_FLCE0 | BALLOON3_NAND_CONTROL_FLCE1 |
  		BALLOON3_NAND_CONTROL_FLCE2 | BALLOON3_NAND_CONTROL_FLCE3 |
  		BALLOON3_NAND_CONTROL_FLWP,
97b09da4e   Arnd Bergmann   ARM: pxa: use cor...
621
  		BALLOON3_NAND_CONTROL_REG + BALLOON3_FPGA_SETnCLR);
e6a8ef547   Marek Vasut   [ARM] pxa/balloon...
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
  	return 0;
  
  err2:
  	gpio_free(BALLOON3_GPIO_RUN_NAND);
  err1:
  	return ret;
  }
  
  static void balloon3_nand_remove(struct platform_device *pdev)
  {
  	/* Power down the NAND chips */
  	gpio_set_value(BALLOON3_GPIO_RUN_NAND, 0);
  	gpio_free(BALLOON3_GPIO_RUN_NAND);
  }
  
  static struct mtd_partition balloon3_partition_info[] = {
  	[0] = {
  		.name	= "Boot",
  		.offset	= 0,
  		.size	= SZ_4M,
  	},
  	[1] = {
  		.name	= "RootFS",
  		.offset	= MTDPART_OFS_APPEND,
  		.size	= MTDPART_SIZ_FULL
  	},
  };
  
  static const char *balloon3_part_probes[] = { "cmdlinepart", NULL };
  
  struct platform_nand_data balloon3_nand_pdata = {
  	.chip = {
  		.nr_chips	= 4,
  		.chip_offset	= 0,
  		.nr_partitions	= ARRAY_SIZE(balloon3_partition_info),
  		.partitions	= balloon3_partition_info,
  		.chip_delay	= 50,
  		.part_probe_types = balloon3_part_probes,
  	},
  	.ctrl = {
  		.hwcontrol	= 0,
59bdd1335   Marek Vasut   ARM: pxa: Add Bal...
663
  		.dev_ready	= balloon3_nand_dev_ready,
e6a8ef547   Marek Vasut   [ARM] pxa/balloon...
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
  		.select_chip	= balloon3_nand_select_chip,
  		.cmd_ctrl	= balloon3_nand_cmd_ctl,
  		.probe		= balloon3_nand_probe,
  		.remove		= balloon3_nand_remove,
  	},
  };
  
  static struct resource balloon3_nand_resource[] = {
  	[0] = {
  		.start = BALLOON3_NAND_BASE,
  		.end   = BALLOON3_NAND_BASE + 0x4,
  		.flags = IORESOURCE_MEM,
  	},
  };
  
  static struct platform_device balloon3_nand = {
  	.name		= "gen_nand",
  	.num_resources	= ARRAY_SIZE(balloon3_nand_resource),
  	.resource	= balloon3_nand_resource,
  	.id		= -1,
  	.dev		= {
  		.platform_data = &balloon3_nand_pdata,
  	}
  };
  
  static void __init balloon3_nand_init(void)
  {
  	platform_device_register(&balloon3_nand);
  }
  #else
  static inline void balloon3_nand_init(void) {}
  #endif
  
  /******************************************************************************
3a27f6e0a   Marek Vasut   [ARM] pxa/balloon...
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
   * Core power regulator
   ******************************************************************************/
  #if defined(CONFIG_REGULATOR_MAX1586) || \
      defined(CONFIG_REGULATOR_MAX1586_MODULE)
  static struct regulator_consumer_supply balloon3_max1587a_consumers[] = {
  	{
  		.supply	= "vcc_core",
  	}
  };
  
  static struct regulator_init_data balloon3_max1587a_v3_info = {
  	.constraints = {
  		.name		= "vcc_core range",
  		.min_uV		= 900000,
  		.max_uV		= 1705000,
  		.always_on	= 1,
  		.valid_ops_mask	= REGULATOR_CHANGE_VOLTAGE,
  	},
  	.consumer_supplies	= balloon3_max1587a_consumers,
  	.num_consumer_supplies	= ARRAY_SIZE(balloon3_max1587a_consumers),
  };
  
  static struct max1586_subdev_data balloon3_max1587a_subdevs[] = {
  	{
  		.name		= "vcc_core",
  		.id		= MAX1586_V3,
  		.platform_data	= &balloon3_max1587a_v3_info,
  	}
  };
  
  static struct max1586_platform_data balloon3_max1587a_info = {
  	.subdevs     = balloon3_max1587a_subdevs,
  	.num_subdevs = ARRAY_SIZE(balloon3_max1587a_subdevs),
  	.v3_gain     = MAX1586_GAIN_R24_3k32, /* 730..1550 mV */
  };
  
  static struct i2c_board_info __initdata balloon3_pi2c_board_info[] = {
  	{
  		I2C_BOARD_INFO("max1586", 0x14),
  		.platform_data	= &balloon3_max1587a_info,
  	},
  };
  
  static void __init balloon3_pmic_init(void)
  {
  	pxa27x_set_i2c_power_info(NULL);
  	i2c_register_board_info(1, ARRAY_AND_SIZE(balloon3_pi2c_board_info));
  }
  #else
  static inline void balloon3_pmic_init(void) {}
  #endif
  
  /******************************************************************************
b0240bf4d   Marek Vasut   [ARM] pxa/balloon...
751
752
   * Machine init
   ******************************************************************************/
2a23ec367   Jonathan McDowell   [ARM] pxa: balloo...
753
754
  static void __init balloon3_init(void)
  {
2a23ec367   Jonathan McDowell   [ARM] pxa: balloo...
755
  	ARB_CNTRL = ARB_CORE_PARK | 0x234;
12a2449c7   Marek Vasut   [ARM] pxa/balloon...
756
  	pxa2xx_mfp_config(ARRAY_AND_SIZE(balloon3_pin_config));
cc155c6f2   Russell King   [ARM] pxa: allow ...
757
758
759
  	pxa_set_ffuart_info(NULL);
  	pxa_set_btuart_info(NULL);
  	pxa_set_stuart_info(NULL);
02a453e4a   Marek Vasut   [ARM] pxa/balloon...
760
  	balloon3_i2c_init();
12a2449c7   Marek Vasut   [ARM] pxa/balloon...
761
762
763
764
  	balloon3_irda_init();
  	balloon3_lcd_init();
  	balloon3_leds_init();
  	balloon3_mmc_init();
e6a8ef547   Marek Vasut   [ARM] pxa/balloon...
765
  	balloon3_nand_init();
12a2449c7   Marek Vasut   [ARM] pxa/balloon...
766
  	balloon3_nor_init();
3a27f6e0a   Marek Vasut   [ARM] pxa/balloon...
767
  	balloon3_pmic_init();
12a2449c7   Marek Vasut   [ARM] pxa/balloon...
768
769
770
  	balloon3_ts_init();
  	balloon3_udc_init();
  	balloon3_uhc_init();
b476ef059   Marek Vasut   ARM: pxa/balloon3...
771
  	balloon3_cf_init();
2a23ec367   Jonathan McDowell   [ARM] pxa: balloo...
772
773
774
775
  }
  
  static struct map_desc balloon3_io_desc[] __initdata = {
  	{	/* CPLD/FPGA */
97b09da4e   Arnd Bergmann   ARM: pxa: use cor...
776
  		.virtual	= (unsigned long)BALLOON3_FPGA_VIRT,
2a23ec367   Jonathan McDowell   [ARM] pxa: balloo...
777
778
779
780
781
782
783
784
  		.pfn		= __phys_to_pfn(BALLOON3_FPGA_PHYS),
  		.length		= BALLOON3_FPGA_LENGTH,
  		.type		= MT_DEVICE,
  	},
  };
  
  static void __init balloon3_map_io(void)
  {
851982c1b   Marek Vasut   ARM: pxa: Introdu...
785
  	pxa27x_map_io();
2a23ec367   Jonathan McDowell   [ARM] pxa: balloo...
786
787
788
789
790
  	iotable_init(balloon3_io_desc, ARRAY_SIZE(balloon3_io_desc));
  }
  
  MACHINE_START(BALLOON3, "Balloon3")
  	/* Maintainer: Nick Bane. */
2a23ec367   Jonathan McDowell   [ARM] pxa: balloo...
791
  	.map_io		= balloon3_map_io,
6ac6b817f   Haojian Zhuang   ARM: pxa: encode ...
792
  	.nr_irqs	= BALLOON3_NR_IRQS,
2a23ec367   Jonathan McDowell   [ARM] pxa: balloo...
793
  	.init_irq	= balloon3_init_irq,
8a97ae2f5   Eric Miao   ARM: pxa: enable ...
794
  	.handle_irq	= pxa27x_handle_irq,
2a23ec367   Jonathan McDowell   [ARM] pxa: balloo...
795
796
  	.timer		= &pxa_timer,
  	.init_machine	= balloon3_init,
7375aba67   Nicolas Pitre   ARM: mach-pxa: co...
797
  	.atag_offset	= 0x100,
271a74fc8   Russell King   ARM: restart: pxa...
798
  	.restart	= pxa_restart,
2a23ec367   Jonathan McDowell   [ARM] pxa: balloo...
799
  MACHINE_END