1 /*
2  * Hardware definitions for the Toshiba eseries PDAs
3  *
4  * Copyright (c) 2003 Ian Molton <spyro@f2s.com>
5  *
6  * This file is licensed under
7  * the terms of the GNU General Public License version 2. This program
8  * is licensed "as is" without any warranty of any kind, whether express
9  * or implied.
10  *
11  */
12 
13 #include <linux/clkdev.h>
14 #include <linux/kernel.h>
15 #include <linux/init.h>
16 #include <linux/clk-provider.h>
17 #include <linux/gpio/machine.h>
18 #include <linux/gpio.h>
19 #include <linux/delay.h>
20 #include <linux/platform_device.h>
21 #include <linux/mfd/tc6387xb.h>
22 #include <linux/mfd/tc6393xb.h>
23 #include <linux/mfd/t7l66xb.h>
24 #include <linux/mtd/rawnand.h>
25 #include <linux/mtd/partitions.h>
26 #include <linux/memblock.h>
27 #include <linux/gpio/machine.h>
28 
29 #include <video/w100fb.h>
30 
31 #include <asm/setup.h>
32 #include <asm/mach/arch.h>
33 #include <asm/mach-types.h>
34 
35 #include "pxa25x.h"
36 #include "eseries-gpio.h"
37 #include "eseries-irq.h"
38 #include <linux/platform_data/asoc-pxa.h>
39 #include <linux/platform_data/video-pxafb.h>
40 #include "udc.h"
41 #include <linux/platform_data/irda-pxaficp.h>
42 
43 #include "devices.h"
44 #include "generic.h"
45 
46 /* Only e800 has 128MB RAM */
eseries_fixup(struct tag * tags,char ** cmdline)47 void __init eseries_fixup(struct tag *tags, char **cmdline)
48 {
49 	if (machine_is_e800())
50 		memblock_add(0xa0000000, SZ_128M);
51 	else
52 		memblock_add(0xa0000000, SZ_64M);
53 }
54 
55 static struct gpiod_lookup_table e7xx_gpio_vbus_gpiod_table __maybe_unused = {
56 	.dev_id = "gpio-vbus",
57 	.table = {
58 		GPIO_LOOKUP("gpio-pxa", GPIO_E7XX_USB_DISC,
59 			    "vbus", GPIO_ACTIVE_HIGH),
60 		GPIO_LOOKUP("gpio-pxa", GPIO_E7XX_USB_PULLUP,
61 			    "pullup", GPIO_ACTIVE_LOW),
62 		{ },
63 	},
64 };
65 
66 static struct platform_device e7xx_gpio_vbus __maybe_unused = {
67 	.name	= "gpio-vbus",
68 	.id	= -1,
69 };
70 
71 struct pxaficp_platform_data e7xx_ficp_platform_data = {
72 	.gpio_pwdown		= GPIO_E7XX_IR_OFF,
73 	.transceiver_cap	= IR_SIRMODE | IR_OFF,
74 };
75 
eseries_tmio_enable(struct platform_device * dev)76 int eseries_tmio_enable(struct platform_device *dev)
77 {
78 	/* Reset - bring SUSPEND high before PCLR */
79 	gpio_set_value(GPIO_ESERIES_TMIO_SUSPEND, 0);
80 	gpio_set_value(GPIO_ESERIES_TMIO_PCLR, 0);
81 	msleep(1);
82 	gpio_set_value(GPIO_ESERIES_TMIO_SUSPEND, 1);
83 	msleep(1);
84 	gpio_set_value(GPIO_ESERIES_TMIO_PCLR, 1);
85 	msleep(1);
86 	return 0;
87 }
88 
eseries_tmio_disable(struct platform_device * dev)89 int eseries_tmio_disable(struct platform_device *dev)
90 {
91 	gpio_set_value(GPIO_ESERIES_TMIO_SUSPEND, 0);
92 	gpio_set_value(GPIO_ESERIES_TMIO_PCLR, 0);
93 	return 0;
94 }
95 
eseries_tmio_suspend(struct platform_device * dev)96 int eseries_tmio_suspend(struct platform_device *dev)
97 {
98 	gpio_set_value(GPIO_ESERIES_TMIO_SUSPEND, 0);
99 	return 0;
100 }
101 
eseries_tmio_resume(struct platform_device * dev)102 int eseries_tmio_resume(struct platform_device *dev)
103 {
104 	gpio_set_value(GPIO_ESERIES_TMIO_SUSPEND, 1);
105 	msleep(1);
106 	return 0;
107 }
108 
eseries_get_tmio_gpios(void)109 void eseries_get_tmio_gpios(void)
110 {
111 	gpio_request(GPIO_ESERIES_TMIO_SUSPEND, NULL);
112 	gpio_request(GPIO_ESERIES_TMIO_PCLR, NULL);
113 	gpio_direction_output(GPIO_ESERIES_TMIO_SUSPEND, 0);
114 	gpio_direction_output(GPIO_ESERIES_TMIO_PCLR, 0);
115 }
116 
117 /* TMIO controller uses the same resources on all e-series machines. */
118 struct resource eseries_tmio_resources[] = {
119 	[0] = {
120 		.start  = PXA_CS4_PHYS,
121 		.end    = PXA_CS4_PHYS + 0x1fffff,
122 		.flags  = IORESOURCE_MEM,
123 	},
124 	[1] = {
125 		.start  = PXA_GPIO_TO_IRQ(GPIO_ESERIES_TMIO_IRQ),
126 		.end    = PXA_GPIO_TO_IRQ(GPIO_ESERIES_TMIO_IRQ),
127 		.flags  = IORESOURCE_IRQ,
128 	},
129 };
130 
131 /* Some e-series hardware cannot control the 32K clock */
eseries_register_clks(void)132 static void __init __maybe_unused eseries_register_clks(void)
133 {
134 	clk_register_fixed_rate(NULL, "CLK_CK32K", NULL, 0, 32768);
135 }
136 
137 #ifdef CONFIG_MACH_E330
138 /* -------------------- e330 tc6387xb parameters -------------------- */
139 
140 static struct tc6387xb_platform_data e330_tc6387xb_info = {
141 	.enable   = &eseries_tmio_enable,
142 	.disable  = &eseries_tmio_disable,
143 	.suspend  = &eseries_tmio_suspend,
144 	.resume   = &eseries_tmio_resume,
145 };
146 
147 static struct platform_device e330_tc6387xb_device = {
148 	.name           = "tc6387xb",
149 	.id             = -1,
150 	.dev            = {
151 		.platform_data = &e330_tc6387xb_info,
152 	},
153 	.num_resources = 2,
154 	.resource      = eseries_tmio_resources,
155 };
156 
157 /* --------------------------------------------------------------- */
158 
159 static struct platform_device *e330_devices[] __initdata = {
160 	&e330_tc6387xb_device,
161 	&e7xx_gpio_vbus,
162 };
163 
e330_init(void)164 static void __init e330_init(void)
165 {
166 	pxa_set_ffuart_info(NULL);
167 	pxa_set_btuart_info(NULL);
168 	pxa_set_stuart_info(NULL);
169 	eseries_register_clks();
170 	eseries_get_tmio_gpios();
171 	gpiod_add_lookup_table(&e7xx_gpio_vbus_gpiod_table);
172 	platform_add_devices(ARRAY_AND_SIZE(e330_devices));
173 }
174 
175 MACHINE_START(E330, "Toshiba e330")
176 	/* Maintainer: Ian Molton (spyro@f2s.com) */
177 	.atag_offset	= 0x100,
178 	.map_io		= pxa25x_map_io,
179 	.nr_irqs	= ESERIES_NR_IRQS,
180 	.init_irq	= pxa25x_init_irq,
181 	.handle_irq	= pxa25x_handle_irq,
182 	.fixup		= eseries_fixup,
183 	.init_machine	= e330_init,
184 	.init_time	= pxa_timer_init,
185 	.restart	= pxa_restart,
186 MACHINE_END
187 #endif
188 
189 #ifdef CONFIG_MACH_E350
190 /* -------------------- e350 t7l66xb parameters -------------------- */
191 
192 static struct t7l66xb_platform_data e350_t7l66xb_info = {
193 	.irq_base               = IRQ_BOARD_START,
194 	.enable                 = &eseries_tmio_enable,
195 	.suspend                = &eseries_tmio_suspend,
196 	.resume                 = &eseries_tmio_resume,
197 };
198 
199 static struct platform_device e350_t7l66xb_device = {
200 	.name           = "t7l66xb",
201 	.id             = -1,
202 	.dev            = {
203 		.platform_data = &e350_t7l66xb_info,
204 	},
205 	.num_resources = 2,
206 	.resource      = eseries_tmio_resources,
207 };
208 
209 /* ---------------------------------------------------------- */
210 
211 static struct platform_device *e350_devices[] __initdata = {
212 	&e350_t7l66xb_device,
213 	&e7xx_gpio_vbus,
214 };
215 
e350_init(void)216 static void __init e350_init(void)
217 {
218 	pxa_set_ffuart_info(NULL);
219 	pxa_set_btuart_info(NULL);
220 	pxa_set_stuart_info(NULL);
221 	eseries_register_clks();
222 	eseries_get_tmio_gpios();
223 	gpiod_add_lookup_table(&e7xx_gpio_vbus_gpiod_table);
224 	platform_add_devices(ARRAY_AND_SIZE(e350_devices));
225 }
226 
227 MACHINE_START(E350, "Toshiba e350")
228 	/* Maintainer: Ian Molton (spyro@f2s.com) */
229 	.atag_offset	= 0x100,
230 	.map_io		= pxa25x_map_io,
231 	.nr_irqs	= ESERIES_NR_IRQS,
232 	.init_irq	= pxa25x_init_irq,
233 	.handle_irq	= pxa25x_handle_irq,
234 	.fixup		= eseries_fixup,
235 	.init_machine	= e350_init,
236 	.init_time	= pxa_timer_init,
237 	.restart	= pxa_restart,
238 MACHINE_END
239 #endif
240 
241 #ifdef CONFIG_MACH_E400
242 /* ------------------------ E400 LCD definitions ------------------------ */
243 
244 static struct pxafb_mode_info e400_pxafb_mode_info = {
245 	.pixclock       = 140703,
246 	.xres           = 240,
247 	.yres           = 320,
248 	.bpp            = 16,
249 	.hsync_len      = 4,
250 	.left_margin    = 28,
251 	.right_margin   = 8,
252 	.vsync_len      = 3,
253 	.upper_margin   = 5,
254 	.lower_margin   = 6,
255 	.sync           = 0,
256 };
257 
258 static struct pxafb_mach_info e400_pxafb_mach_info = {
259 	.modes          = &e400_pxafb_mode_info,
260 	.num_modes      = 1,
261 	.lcd_conn	= LCD_COLOR_TFT_16BPP,
262 	.lccr3          = 0,
263 	.pxafb_backlight_power  = NULL,
264 };
265 
266 /* ------------------------ E400 MFP config ----------------------------- */
267 
268 static unsigned long e400_pin_config[] __initdata = {
269 	/* Chip selects */
270 	GPIO15_nCS_1,   /* CS1 - Flash */
271 	GPIO80_nCS_4,   /* CS4 - TMIO */
272 
273 	/* Clocks */
274 	GPIO12_32KHz,
275 
276 	/* BTUART */
277 	GPIO42_BTUART_RXD,
278 	GPIO43_BTUART_TXD,
279 	GPIO44_BTUART_CTS,
280 
281 	/* TMIO controller */
282 	GPIO19_GPIO, /* t7l66xb #PCLR */
283 	GPIO45_GPIO, /* t7l66xb #SUSPEND (NOT BTUART!) */
284 
285 	/* wakeup */
286 	GPIO0_GPIO | WAKEUP_ON_EDGE_RISE,
287 };
288 
289 /* ---------------------------------------------------------------------- */
290 
291 static struct mtd_partition partition_a = {
292 	.name = "Internal NAND flash",
293 	.offset =  0,
294 	.size =  MTDPART_SIZ_FULL,
295 };
296 
297 static uint8_t scan_ff_pattern[] = { 0xff, 0xff };
298 
299 static struct nand_bbt_descr e400_t7l66xb_nand_bbt = {
300 	.options = 0,
301 	.offs = 4,
302 	.len = 2,
303 	.pattern = scan_ff_pattern
304 };
305 
306 static struct tmio_nand_data e400_t7l66xb_nand_config = {
307 	.num_partitions = 1,
308 	.partition = &partition_a,
309 	.badblock_pattern = &e400_t7l66xb_nand_bbt,
310 };
311 
312 static struct t7l66xb_platform_data e400_t7l66xb_info = {
313 	.irq_base 		= IRQ_BOARD_START,
314 	.enable                 = &eseries_tmio_enable,
315 	.suspend                = &eseries_tmio_suspend,
316 	.resume                 = &eseries_tmio_resume,
317 
318 	.nand_data              = &e400_t7l66xb_nand_config,
319 };
320 
321 static struct platform_device e400_t7l66xb_device = {
322 	.name           = "t7l66xb",
323 	.id             = -1,
324 	.dev            = {
325 		.platform_data = &e400_t7l66xb_info,
326 	},
327 	.num_resources = 2,
328 	.resource      = eseries_tmio_resources,
329 };
330 
331 /* ---------------------------------------------------------- */
332 
333 static struct platform_device *e400_devices[] __initdata = {
334 	&e400_t7l66xb_device,
335 	&e7xx_gpio_vbus,
336 };
337 
e400_init(void)338 static void __init e400_init(void)
339 {
340 	pxa2xx_mfp_config(ARRAY_AND_SIZE(e400_pin_config));
341 	pxa_set_ffuart_info(NULL);
342 	pxa_set_btuart_info(NULL);
343 	pxa_set_stuart_info(NULL);
344 	/* Fixme - e400 may have a switched clock */
345 	eseries_register_clks();
346 	eseries_get_tmio_gpios();
347 	pxa_set_fb_info(NULL, &e400_pxafb_mach_info);
348 	gpiod_add_lookup_table(&e7xx_gpio_vbus_gpiod_table);
349 	platform_add_devices(ARRAY_AND_SIZE(e400_devices));
350 }
351 
352 MACHINE_START(E400, "Toshiba e400")
353 	/* Maintainer: Ian Molton (spyro@f2s.com) */
354 	.atag_offset	= 0x100,
355 	.map_io		= pxa25x_map_io,
356 	.nr_irqs	= ESERIES_NR_IRQS,
357 	.init_irq	= pxa25x_init_irq,
358 	.handle_irq	= pxa25x_handle_irq,
359 	.fixup		= eseries_fixup,
360 	.init_machine	= e400_init,
361 	.init_time	= pxa_timer_init,
362 	.restart	= pxa_restart,
363 MACHINE_END
364 #endif
365 
366 #ifdef CONFIG_MACH_E740
367 /* ------------------------ e740 video support --------------------------- */
368 
369 static struct w100_gen_regs e740_lcd_regs = {
370 	.lcd_format =            0x00008023,
371 	.lcdd_cntl1 =            0x0f000000,
372 	.lcdd_cntl2 =            0x0003ffff,
373 	.genlcd_cntl1 =          0x00ffff03,
374 	.genlcd_cntl2 =          0x003c0f03,
375 	.genlcd_cntl3 =          0x000143aa,
376 };
377 
378 static struct w100_mode e740_lcd_mode = {
379 	.xres            = 240,
380 	.yres            = 320,
381 	.left_margin     = 20,
382 	.right_margin    = 28,
383 	.upper_margin    = 9,
384 	.lower_margin    = 8,
385 	.crtc_ss         = 0x80140013,
386 	.crtc_ls         = 0x81150110,
387 	.crtc_gs         = 0x80050005,
388 	.crtc_vpos_gs    = 0x000a0009,
389 	.crtc_rev        = 0x0040010a,
390 	.crtc_dclk       = 0xa906000a,
391 	.crtc_gclk       = 0x80050108,
392 	.crtc_goe        = 0x80050108,
393 	.pll_freq        = 57,
394 	.pixclk_divider         = 4,
395 	.pixclk_divider_rotated = 4,
396 	.pixclk_src     = CLK_SRC_XTAL,
397 	.sysclk_divider  = 1,
398 	.sysclk_src     = CLK_SRC_PLL,
399 	.crtc_ps1_active =       0x41060010,
400 };
401 
402 static struct w100_gpio_regs e740_w100_gpio_info = {
403 	.init_data1 = 0x21002103,
404 	.gpio_dir1  = 0xffffdeff,
405 	.gpio_oe1   = 0x03c00643,
406 	.init_data2 = 0x003f003f,
407 	.gpio_dir2  = 0xffffffff,
408 	.gpio_oe2   = 0x000000ff,
409 };
410 
411 static struct w100fb_mach_info e740_fb_info = {
412 	.modelist   = &e740_lcd_mode,
413 	.num_modes  = 1,
414 	.regs       = &e740_lcd_regs,
415 	.gpio       = &e740_w100_gpio_info,
416 	.xtal_freq = 14318000,
417 	.xtal_dbl   = 1,
418 };
419 
420 static struct resource e740_fb_resources[] = {
421 	[0] = {
422 		.start          = 0x0c000000,
423 		.end            = 0x0cffffff,
424 		.flags          = IORESOURCE_MEM,
425 	},
426 };
427 
428 static struct platform_device e740_fb_device = {
429 	.name           = "w100fb",
430 	.id             = -1,
431 	.dev            = {
432 		.platform_data  = &e740_fb_info,
433 	},
434 	.num_resources  = ARRAY_SIZE(e740_fb_resources),
435 	.resource       = e740_fb_resources,
436 };
437 
438 /* --------------------------- MFP Pin config -------------------------- */
439 
440 static unsigned long e740_pin_config[] __initdata = {
441 	/* Chip selects */
442 	GPIO15_nCS_1,   /* CS1 - Flash */
443 	GPIO79_nCS_3,   /* CS3 - IMAGEON */
444 	GPIO80_nCS_4,   /* CS4 - TMIO */
445 
446 	/* Clocks */
447 	GPIO12_32KHz,
448 
449 	/* BTUART */
450 	GPIO42_BTUART_RXD,
451 	GPIO43_BTUART_TXD,
452 	GPIO44_BTUART_CTS,
453 
454 	/* TMIO controller */
455 	GPIO19_GPIO, /* t7l66xb #PCLR */
456 	GPIO45_GPIO, /* t7l66xb #SUSPEND (NOT BTUART!) */
457 
458 	/* UDC */
459 	GPIO13_GPIO,
460 	GPIO3_GPIO,
461 
462 	/* IrDA */
463 	GPIO38_GPIO | MFP_LPM_DRIVE_HIGH,
464 
465 	/* AC97 */
466 	GPIO28_AC97_BITCLK,
467 	GPIO29_AC97_SDATA_IN_0,
468 	GPIO30_AC97_SDATA_OUT,
469 	GPIO31_AC97_SYNC,
470 
471 	/* Audio power control */
472 	GPIO16_GPIO,  /* AC97 codec AVDD2 supply (analogue power) */
473 	GPIO40_GPIO,  /* Mic amp power */
474 	GPIO41_GPIO,  /* Headphone amp power */
475 
476 	/* PC Card */
477 	GPIO8_GPIO,   /* CD0 */
478 	GPIO44_GPIO,  /* CD1 */
479 	GPIO11_GPIO,  /* IRQ0 */
480 	GPIO6_GPIO,   /* IRQ1 */
481 	GPIO27_GPIO,  /* RST0 */
482 	GPIO24_GPIO,  /* RST1 */
483 	GPIO20_GPIO,  /* PWR0 */
484 	GPIO23_GPIO,  /* PWR1 */
485 	GPIO48_nPOE,
486 	GPIO49_nPWE,
487 	GPIO50_nPIOR,
488 	GPIO51_nPIOW,
489 	GPIO52_nPCE_1,
490 	GPIO53_nPCE_2,
491 	GPIO54_nPSKTSEL,
492 	GPIO55_nPREG,
493 	GPIO56_nPWAIT,
494 	GPIO57_nIOIS16,
495 
496 	/* wakeup */
497 	GPIO0_GPIO | WAKEUP_ON_EDGE_RISE,
498 };
499 
500 /* -------------------- e740 t7l66xb parameters -------------------- */
501 
502 static struct t7l66xb_platform_data e740_t7l66xb_info = {
503 	.irq_base 		= IRQ_BOARD_START,
504 	.enable                 = &eseries_tmio_enable,
505 	.suspend                = &eseries_tmio_suspend,
506 	.resume                 = &eseries_tmio_resume,
507 };
508 
509 static struct platform_device e740_t7l66xb_device = {
510 	.name           = "t7l66xb",
511 	.id             = -1,
512 	.dev            = {
513 		.platform_data = &e740_t7l66xb_info,
514 	},
515 	.num_resources = 2,
516 	.resource      = eseries_tmio_resources,
517 };
518 
519 static struct platform_device e740_audio_device = {
520 	.name		= "e740-audio",
521 	.id		= -1,
522 };
523 
524 static struct gpiod_lookup_table e740_audio_gpio_table = {
525 	.dev_id = "e740-audio",
526 	.table = {
527 		GPIO_LOOKUP("gpio-pxa",  GPIO_E740_WM9705_nAVDD2, "Audio power",  GPIO_ACTIVE_HIGH),
528 		GPIO_LOOKUP("gpio-pxa",  GPIO_E740_AMP_ON, "Output amp",  GPIO_ACTIVE_HIGH),
529 		GPIO_LOOKUP("gpio-pxa",  GPIO_E740_MIC_ON, "Mic amp", GPIO_ACTIVE_HIGH),
530 		{ },
531 	},
532 };
533 
534 /* ----------------------------------------------------------------------- */
535 
536 static struct platform_device *e740_devices[] __initdata = {
537 	&e740_fb_device,
538 	&e740_t7l66xb_device,
539 	&e7xx_gpio_vbus,
540 	&e740_audio_device,
541 };
542 
e740_init(void)543 static void __init e740_init(void)
544 {
545 	pxa2xx_mfp_config(ARRAY_AND_SIZE(e740_pin_config));
546 	pxa_set_ffuart_info(NULL);
547 	pxa_set_btuart_info(NULL);
548 	pxa_set_stuart_info(NULL);
549 	eseries_register_clks();
550 	clk_add_alias("CLK_CK48M", e740_t7l66xb_device.name,
551 			"UDCCLK", &pxa25x_device_udc.dev),
552 	eseries_get_tmio_gpios();
553 	gpiod_add_lookup_table(&e7xx_gpio_vbus_gpiod_table);
554 	gpiod_add_lookup_table(&e740_audio_gpio_table);
555 	platform_add_devices(ARRAY_AND_SIZE(e740_devices));
556 	pxa_set_ac97_info(NULL);
557 	pxa_set_ficp_info(&e7xx_ficp_platform_data);
558 }
559 
560 MACHINE_START(E740, "Toshiba e740")
561 	/* Maintainer: Ian Molton (spyro@f2s.com) */
562 	.atag_offset	= 0x100,
563 	.map_io		= pxa25x_map_io,
564 	.nr_irqs	= ESERIES_NR_IRQS,
565 	.init_irq	= pxa25x_init_irq,
566 	.handle_irq	= pxa25x_handle_irq,
567 	.fixup		= eseries_fixup,
568 	.init_machine	= e740_init,
569 	.init_time	= pxa_timer_init,
570 	.restart	= pxa_restart,
571 MACHINE_END
572 #endif
573 
574 #ifdef CONFIG_MACH_E750
575 /* ---------------------- E750 LCD definitions -------------------- */
576 
577 static struct w100_gen_regs e750_lcd_regs = {
578 	.lcd_format =            0x00008003,
579 	.lcdd_cntl1 =            0x00000000,
580 	.lcdd_cntl2 =            0x0003ffff,
581 	.genlcd_cntl1 =          0x00fff003,
582 	.genlcd_cntl2 =          0x003c0f03,
583 	.genlcd_cntl3 =          0x000143aa,
584 };
585 
586 static struct w100_mode e750_lcd_mode = {
587 	.xres            = 240,
588 	.yres            = 320,
589 	.left_margin     = 21,
590 	.right_margin    = 22,
591 	.upper_margin    = 5,
592 	.lower_margin    = 4,
593 	.crtc_ss         = 0x80150014,
594 	.crtc_ls         = 0x8014000d,
595 	.crtc_gs         = 0xc1000005,
596 	.crtc_vpos_gs    = 0x00020147,
597 	.crtc_rev        = 0x0040010a,
598 	.crtc_dclk       = 0xa1700030,
599 	.crtc_gclk       = 0x80cc0015,
600 	.crtc_goe        = 0x80cc0015,
601 	.crtc_ps1_active = 0x61060017,
602 	.pll_freq        = 57,
603 	.pixclk_divider         = 4,
604 	.pixclk_divider_rotated = 4,
605 	.pixclk_src     = CLK_SRC_XTAL,
606 	.sysclk_divider  = 1,
607 	.sysclk_src     = CLK_SRC_PLL,
608 };
609 
610 static struct w100_gpio_regs e750_w100_gpio_info = {
611 	.init_data1 = 0x01192f1b,
612 	.gpio_dir1  = 0xd5ffdeff,
613 	.gpio_oe1   = 0x000020bf,
614 	.init_data2 = 0x010f010f,
615 	.gpio_dir2  = 0xffffffff,
616 	.gpio_oe2   = 0x000001cf,
617 };
618 
619 static struct w100fb_mach_info e750_fb_info = {
620 	.modelist   = &e750_lcd_mode,
621 	.num_modes  = 1,
622 	.regs       = &e750_lcd_regs,
623 	.gpio       = &e750_w100_gpio_info,
624 	.xtal_freq  = 14318000,
625 	.xtal_dbl   = 1,
626 };
627 
628 static struct resource e750_fb_resources[] = {
629 	[0] = {
630 		.start          = 0x0c000000,
631 		.end            = 0x0cffffff,
632 		.flags          = IORESOURCE_MEM,
633 	},
634 };
635 
636 static struct platform_device e750_fb_device = {
637 	.name           = "w100fb",
638 	.id             = -1,
639 	.dev            = {
640 		.platform_data  = &e750_fb_info,
641 	},
642 	.num_resources  = ARRAY_SIZE(e750_fb_resources),
643 	.resource       = e750_fb_resources,
644 };
645 
646 /* -------------------- e750 MFP parameters -------------------- */
647 
648 static unsigned long e750_pin_config[] __initdata = {
649 	/* Chip selects */
650 	GPIO15_nCS_1,   /* CS1 - Flash */
651 	GPIO79_nCS_3,   /* CS3 - IMAGEON */
652 	GPIO80_nCS_4,   /* CS4 - TMIO */
653 
654 	/* Clocks */
655 	GPIO11_3_6MHz,
656 
657 	/* BTUART */
658 	GPIO42_BTUART_RXD,
659 	GPIO43_BTUART_TXD,
660 	GPIO44_BTUART_CTS,
661 
662 	/* TMIO controller */
663 	GPIO19_GPIO, /* t7l66xb #PCLR */
664 	GPIO45_GPIO, /* t7l66xb #SUSPEND (NOT BTUART!) */
665 
666 	/* UDC */
667 	GPIO13_GPIO,
668 	GPIO3_GPIO,
669 
670 	/* IrDA */
671 	GPIO38_GPIO | MFP_LPM_DRIVE_HIGH,
672 
673 	/* AC97 */
674 	GPIO28_AC97_BITCLK,
675 	GPIO29_AC97_SDATA_IN_0,
676 	GPIO30_AC97_SDATA_OUT,
677 	GPIO31_AC97_SYNC,
678 
679 	/* Audio power control */
680 	GPIO4_GPIO,  /* Headphone amp power */
681 	GPIO7_GPIO,  /* Speaker amp power */
682 	GPIO37_GPIO, /* Headphone detect */
683 
684 	/* PC Card */
685 	GPIO8_GPIO,   /* CD0 */
686 	GPIO44_GPIO,  /* CD1 */
687 	/* GPIO11_GPIO,  IRQ0 */
688 	GPIO6_GPIO,   /* IRQ1 */
689 	GPIO27_GPIO,  /* RST0 */
690 	GPIO24_GPIO,  /* RST1 */
691 	GPIO20_GPIO,  /* PWR0 */
692 	GPIO23_GPIO,  /* PWR1 */
693 	GPIO48_nPOE,
694 	GPIO49_nPWE,
695 	GPIO50_nPIOR,
696 	GPIO51_nPIOW,
697 	GPIO52_nPCE_1,
698 	GPIO53_nPCE_2,
699 	GPIO54_nPSKTSEL,
700 	GPIO55_nPREG,
701 	GPIO56_nPWAIT,
702 	GPIO57_nIOIS16,
703 
704 	/* wakeup */
705 	GPIO0_GPIO | WAKEUP_ON_EDGE_RISE,
706 };
707 
708 /* ----------------- e750 tc6393xb parameters ------------------ */
709 
710 static struct tc6393xb_platform_data e750_tc6393xb_info = {
711 	.irq_base       = IRQ_BOARD_START,
712 	.scr_pll2cr     = 0x0cc1,
713 	.scr_gper       = 0,
714 	.suspend        = &eseries_tmio_suspend,
715 	.resume         = &eseries_tmio_resume,
716 	.enable         = &eseries_tmio_enable,
717 	.disable        = &eseries_tmio_disable,
718 };
719 
720 static struct platform_device e750_tc6393xb_device = {
721 	.name           = "tc6393xb",
722 	.id             = -1,
723 	.dev            = {
724 		.platform_data = &e750_tc6393xb_info,
725 	},
726 	.num_resources = 2,
727 	.resource      = eseries_tmio_resources,
728 };
729 
730 static struct gpiod_lookup_table e750_audio_gpio_table = {
731 	.dev_id = "e750-audio",
732 	.table = {
733 		GPIO_LOOKUP("gpio-pxa",  GPIO_E750_HP_AMP_OFF, "Output amp",  GPIO_ACTIVE_LOW),
734 		GPIO_LOOKUP("gpio-pxa",  GPIO_E750_SPK_AMP_OFF, "Mic amp", GPIO_ACTIVE_LOW),
735 		{ },
736 	},
737 };
738 
739 static struct platform_device e750_audio_device = {
740 	.name		= "e750-audio",
741 	.id		= -1,
742 };
743 
744 /* ------------------------------------------------------------- */
745 
746 static struct platform_device *e750_devices[] __initdata = {
747 	&e750_fb_device,
748 	&e750_tc6393xb_device,
749 	&e7xx_gpio_vbus,
750 	&e750_audio_device,
751 };
752 
e750_init(void)753 static void __init e750_init(void)
754 {
755 	pxa2xx_mfp_config(ARRAY_AND_SIZE(e750_pin_config));
756 	pxa_set_ffuart_info(NULL);
757 	pxa_set_btuart_info(NULL);
758 	pxa_set_stuart_info(NULL);
759 	clk_add_alias("CLK_CK3P6MI", e750_tc6393xb_device.name,
760 			"GPIO11_CLK", NULL),
761 	eseries_get_tmio_gpios();
762 	gpiod_add_lookup_table(&e7xx_gpio_vbus_gpiod_table);
763 	gpiod_add_lookup_table(&e750_audio_gpio_table);
764 	platform_add_devices(ARRAY_AND_SIZE(e750_devices));
765 	pxa_set_ac97_info(NULL);
766 	pxa_set_ficp_info(&e7xx_ficp_platform_data);
767 }
768 
769 MACHINE_START(E750, "Toshiba e750")
770 	/* Maintainer: Ian Molton (spyro@f2s.com) */
771 	.atag_offset	= 0x100,
772 	.map_io		= pxa25x_map_io,
773 	.nr_irqs	= ESERIES_NR_IRQS,
774 	.init_irq	= pxa25x_init_irq,
775 	.handle_irq	= pxa25x_handle_irq,
776 	.fixup		= eseries_fixup,
777 	.init_machine	= e750_init,
778 	.init_time	= pxa_timer_init,
779 	.restart	= pxa_restart,
780 MACHINE_END
781 #endif
782 
783 #ifdef CONFIG_MACH_E800
784 /* ------------------------ e800 LCD definitions ------------------------- */
785 
786 static unsigned long e800_pin_config[] __initdata = {
787 	/* AC97 */
788 	GPIO28_AC97_BITCLK,
789 	GPIO29_AC97_SDATA_IN_0,
790 	GPIO30_AC97_SDATA_OUT,
791 	GPIO31_AC97_SYNC,
792 
793 	/* tc6393xb */
794 	GPIO11_3_6MHz,
795 };
796 
797 static struct w100_gen_regs e800_lcd_regs = {
798 	.lcd_format =            0x00008003,
799 	.lcdd_cntl1 =            0x02a00000,
800 	.lcdd_cntl2 =            0x0003ffff,
801 	.genlcd_cntl1 =          0x000ff2a3,
802 	.genlcd_cntl2 =          0x000002a3,
803 	.genlcd_cntl3 =          0x000102aa,
804 };
805 
806 static struct w100_mode e800_lcd_mode[2] = {
807 	[0] = {
808 		.xres            = 480,
809 		.yres            = 640,
810 		.left_margin     = 52,
811 		.right_margin    = 148,
812 		.upper_margin    = 2,
813 		.lower_margin    = 6,
814 		.crtc_ss         = 0x80350034,
815 		.crtc_ls         = 0x802b0026,
816 		.crtc_gs         = 0x80160016,
817 		.crtc_vpos_gs    = 0x00020003,
818 		.crtc_rev        = 0x0040001d,
819 		.crtc_dclk       = 0xe0000000,
820 		.crtc_gclk       = 0x82a50049,
821 		.crtc_goe        = 0x80ee001c,
822 		.crtc_ps1_active = 0x00000000,
823 		.pll_freq        = 128,
824 		.pixclk_divider         = 4,
825 		.pixclk_divider_rotated = 6,
826 		.pixclk_src     = CLK_SRC_PLL,
827 		.sysclk_divider  = 0,
828 		.sysclk_src     = CLK_SRC_PLL,
829 	},
830 	[1] = {
831 		.xres            = 240,
832 		.yres            = 320,
833 		.left_margin     = 15,
834 		.right_margin    = 88,
835 		.upper_margin    = 0,
836 		.lower_margin    = 7,
837 		.crtc_ss         = 0xd010000f,
838 		.crtc_ls         = 0x80070003,
839 		.crtc_gs         = 0x80000000,
840 		.crtc_vpos_gs    = 0x01460147,
841 		.crtc_rev        = 0x00400003,
842 		.crtc_dclk       = 0xa1700030,
843 		.crtc_gclk       = 0x814b0008,
844 		.crtc_goe        = 0x80cc0015,
845 		.crtc_ps1_active = 0x00000000,
846 		.pll_freq        = 100,
847 		.pixclk_divider         = 6, /* Wince uses 14 which gives a */
848 		.pixclk_divider_rotated = 6, /* 7MHz Pclk. We use a 14MHz one */
849 		.pixclk_src     = CLK_SRC_PLL,
850 		.sysclk_divider  = 0,
851 		.sysclk_src     = CLK_SRC_PLL,
852 	}
853 };
854 
855 
856 static struct w100_gpio_regs e800_w100_gpio_info = {
857 	.init_data1 = 0xc13fc019,
858 	.gpio_dir1  = 0x3e40df7f,
859 	.gpio_oe1   = 0x003c3000,
860 	.init_data2 = 0x00000000,
861 	.gpio_dir2  = 0x00000000,
862 	.gpio_oe2   = 0x00000000,
863 };
864 
865 static struct w100_mem_info e800_w100_mem_info = {
866 	.ext_cntl        = 0x09640011,
867 	.sdram_mode_reg  = 0x00600021,
868 	.ext_timing_cntl = 0x10001545,
869 	.io_cntl         = 0x7ddd7333,
870 	.size            = 0x1fffff,
871 };
872 
e800_tg_change(struct w100fb_par * par)873 static void e800_tg_change(struct w100fb_par *par)
874 {
875 	unsigned long tmp;
876 
877 	tmp = w100fb_gpio_read(W100_GPIO_PORT_A);
878 	if (par->mode->xres == 480)
879 		tmp |= 0x100;
880 	else
881 		tmp &= ~0x100;
882 	w100fb_gpio_write(W100_GPIO_PORT_A, tmp);
883 }
884 
885 static struct w100_tg_info e800_tg_info = {
886 	.change = e800_tg_change,
887 };
888 
889 static struct w100fb_mach_info e800_fb_info = {
890 	.modelist   = e800_lcd_mode,
891 	.num_modes  = 2,
892 	.regs       = &e800_lcd_regs,
893 	.gpio       = &e800_w100_gpio_info,
894 	.mem        = &e800_w100_mem_info,
895 	.tg         = &e800_tg_info,
896 	.xtal_freq  = 16000000,
897 };
898 
899 static struct resource e800_fb_resources[] = {
900 	[0] = {
901 		.start          = 0x0c000000,
902 		.end            = 0x0cffffff,
903 		.flags          = IORESOURCE_MEM,
904 	},
905 };
906 
907 static struct platform_device e800_fb_device = {
908 	.name           = "w100fb",
909 	.id             = -1,
910 	.dev            = {
911 		.platform_data  = &e800_fb_info,
912 	},
913 	.num_resources  = ARRAY_SIZE(e800_fb_resources),
914 	.resource       = e800_fb_resources,
915 };
916 
917 /* --------------------------- UDC definitions --------------------------- */
918 
919 static struct gpiod_lookup_table e800_gpio_vbus_gpiod_table = {
920 	.dev_id = "gpio-vbus",
921 	.table = {
922 		GPIO_LOOKUP("gpio-pxa", GPIO_E800_USB_DISC,
923 			    "vbus", GPIO_ACTIVE_HIGH),
924 		GPIO_LOOKUP("gpio-pxa", GPIO_E800_USB_PULLUP,
925 			    "pullup", GPIO_ACTIVE_LOW),
926 		{ },
927 	},
928 };
929 
930 static struct platform_device e800_gpio_vbus = {
931 	.name	= "gpio-vbus",
932 	.id	= -1,
933 };
934 
935 
936 /* ----------------- e800 tc6393xb parameters ------------------ */
937 
938 static struct tc6393xb_platform_data e800_tc6393xb_info = {
939 	.irq_base       = IRQ_BOARD_START,
940 	.scr_pll2cr     = 0x0cc1,
941 	.scr_gper       = 0,
942 	.suspend        = &eseries_tmio_suspend,
943 	.resume         = &eseries_tmio_resume,
944 	.enable         = &eseries_tmio_enable,
945 	.disable        = &eseries_tmio_disable,
946 };
947 
948 static struct platform_device e800_tc6393xb_device = {
949 	.name           = "tc6393xb",
950 	.id             = -1,
951 	.dev            = {
952 		.platform_data = &e800_tc6393xb_info,
953 	},
954 	.num_resources = 2,
955 	.resource      = eseries_tmio_resources,
956 };
957 
958 static struct gpiod_lookup_table e800_audio_gpio_table = {
959 	.dev_id = "e800-audio",
960 	.table = {
961 		GPIO_LOOKUP("gpio-pxa",  GPIO_E800_HP_AMP_OFF, "Output amp",  GPIO_ACTIVE_LOW),
962 		GPIO_LOOKUP("gpio-pxa",  GPIO_E800_SPK_AMP_ON, "Mic amp", GPIO_ACTIVE_HIGH),
963 		{ },
964 	},
965 };
966 
967 static struct platform_device e800_audio_device = {
968 	.name		= "e800-audio",
969 	.id		= -1,
970 };
971 
972 /* ----------------------------------------------------------------------- */
973 
974 static struct platform_device *e800_devices[] __initdata = {
975 	&e800_fb_device,
976 	&e800_tc6393xb_device,
977 	&e800_gpio_vbus,
978 	&e800_audio_device,
979 };
980 
e800_init(void)981 static void __init e800_init(void)
982 {
983 	pxa2xx_mfp_config(ARRAY_AND_SIZE(e800_pin_config));
984 	pxa_set_ffuart_info(NULL);
985 	pxa_set_btuart_info(NULL);
986 	pxa_set_stuart_info(NULL);
987 	clk_add_alias("CLK_CK3P6MI", e800_tc6393xb_device.name,
988 			"GPIO11_CLK", NULL),
989 	eseries_get_tmio_gpios();
990 	gpiod_add_lookup_table(&e800_gpio_vbus_gpiod_table);
991 	gpiod_add_lookup_table(&e800_audio_gpio_table);
992 	platform_add_devices(ARRAY_AND_SIZE(e800_devices));
993 	pxa_set_ac97_info(NULL);
994 }
995 
996 MACHINE_START(E800, "Toshiba e800")
997 	/* Maintainer: Ian Molton (spyro@f2s.com) */
998 	.atag_offset	= 0x100,
999 	.map_io		= pxa25x_map_io,
1000 	.nr_irqs	= ESERIES_NR_IRQS,
1001 	.init_irq	= pxa25x_init_irq,
1002 	.handle_irq	= pxa25x_handle_irq,
1003 	.fixup		= eseries_fixup,
1004 	.init_machine	= e800_init,
1005 	.init_time	= pxa_timer_init,
1006 	.restart	= pxa_restart,
1007 MACHINE_END
1008 #endif
1009