summaryrefslogtreecommitdiff
path: root/packages/linux/linux-rp-2.6.18+git/tmio-tc6393-r8.patch
blob: 2f1b47d783edb6300e10e34b977340e8f43aa206 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
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
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
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
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
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
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
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
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
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
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
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
 arch/arm/common/Kconfig         |    3 
 arch/arm/common/Makefile        |    1 
 arch/arm/common/tc6393xb.c      |  668 ++++++++++++++++++++++++++++++++++++++++
 arch/arm/mach-pxa/Kconfig       |    1 
 include/asm-arm/arch-pxa/irqs.h |   10 
 include/asm-arm/hardware/tmio.h |   44 ++
 6 files changed, 727 insertions(+)

Index: git/arch/arm/common/tc6393xb.c
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ git/arch/arm/common/tc6393xb.c	2006-11-07 22:14:49.000000000 +0000
@@ -0,0 +1,668 @@
+/*
+ * Toshiba TC6393XB SoC support
+ *
+ * Maintainer: Chris Humbert <mahadri-kernel@drigon.com>
+ *
+ * Copyright (c) 2005-2006 Chris Humbert
+ * Copyright (c) 2005 Dirk Opfer
+ *
+ * Based on code written by Sharp/Lineo for 2.4 kernels
+ * Based on locomo.c
+ *
+ * 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/module.h>
+#include <linux/init.h>
+#include <linux/kernel.h>
+#include <linux/delay.h>
+#include <linux/errno.h>
+#include <linux/ioport.h>
+#include <linux/device.h>
+#include <linux/platform_device.h>
+#include <linux/slab.h>
+#include <linux/spinlock.h>
+#include <linux/fb.h>
+
+#include <asm/hardware.h>
+#include <asm/mach-types.h>
+#include <asm/io.h>
+#include <asm/irq.h>
+#include <asm/mach/irq.h>
+#include <asm/arch/irqs.h>
+#include <asm/hardware/tmio.h>
+
+#ifndef TMIO_SOC_TC6393XB
+#error "TC6393XB SoC not configured"
+#endif
+
+/*--------------------------------------------------------------------------*/
+
+/* cell ids must be 0-based because they are used as array indexes. */
+#define	TC6393_CELL_NAND	0
+#define TC6393_CELL_SD		1
+#define	TC6393_CELL_OHCI	2
+#define TC6393_CELL_SERIAL	3
+#define TC6393_CELL_LCD		4
+#define TC6393_NUM_CELLS	5
+
+#define TC6393_RESOURCE(_name, _start, _end, _flags)	\
+	{						\
+		.name		= _name,		\
+		.start		= _start,		\
+		.end		= _end,			\
+		.flags		= _flags,		\
+	}
+
+#define TC6393_MEM(name, start, size)	\
+	TC6393_RESOURCE(name, start, (start) + (size) - 1, IORESOURCE_MEM)
+
+#define TC6393_IRQ(name, irq)	\
+	TC6393_RESOURCE(name, irq, irq, IORESOURCE_IRQ)
+
+const static struct resource tc6393_NAND_resource[] = {
+	TC6393_MEM (TMIO_NAME_NAND,	0x000100,	0x100),
+	TC6393_MEM (TMIO_NAME_NAND,	0x001000,	0x008),
+	TC6393_MEM (TMIO_NAME_NAND,	0,		0),
+	TC6393_IRQ (TMIO_NAME_NAND,	IRQ_TC6393_NAND),
+};
+
+const static struct resource tc6393_SD_resource[] = {
+	TC6393_MEM (TMIO_NAME_SD,	0x000200,	0x100),
+	TC6393_MEM (TMIO_NAME_SD,	0x002000,	0x200),
+	TC6393_MEM (TMIO_NAME_SD,	0,		0),
+	TC6393_IRQ (TMIO_NAME_SD,	IRQ_TC6393_SD),
+};
+
+const static struct resource tc6393_OHCI_resource[] = {
+	TC6393_MEM (TMIO_NAME_OHCI,	0x000300,	0x100),
+	TC6393_MEM (TMIO_NAME_OHCI,	0x003000,	0x100),
+	TC6393_MEM (TMIO_NAME_OHCI,	0x010000,	32 * 1024),
+	TC6393_IRQ (TMIO_NAME_OHCI,	IRQ_TC6393_OHCI),
+};
+
+const static struct resource tc6393_SERIAL_resource[] = {
+	TC6393_MEM (TMIO_NAME_SERIAL,	0x000400,	0x100),
+	TC6393_MEM (TMIO_NAME_SERIAL,	0x004000,	0x100),
+	TC6393_MEM (TMIO_NAME_SERIAL,	0,		0),
+	TC6393_IRQ (TMIO_NAME_SERIAL,	IRQ_TC6393_SERIAL),
+};
+
+const static struct resource tc6393_LCD_resource[] = {
+	TC6393_MEM (TMIO_NAME_LCD,	0x000500,	0x100),
+	TC6393_MEM (TMIO_NAME_LCD,	0x005000,	0x200),
+	TC6393_MEM (TMIO_NAME_LCD,	0x100000,	1024 * 1024),
+	TC6393_IRQ (TMIO_NAME_LCD,	IRQ_TC6393_LCD),
+};
+
+#define TC6393_CELL(_NAME)						\
+	[TC6393_CELL_##_NAME] = {					\
+		.name		= TMIO_NAME_##_NAME,			\
+		.id		= TC6393_CELL_##_NAME,			\
+		.resource	= tc6393_##_NAME##_resource,		\
+		.num_resources	= ARRAY_SIZE (tc6393_##_NAME##_resource), \
+	}
+
+struct tc6393_cell {
+	const char*		name;
+	unsigned int		id;
+	const struct resource*	resource;
+	unsigned int		num_resources;
+};
+
+const static struct tc6393_cell tc6393_cell [TC6393_NUM_CELLS] = {
+	TC6393_CELL (NAND	),
+	TC6393_CELL (SD		),
+	TC6393_CELL (OHCI	),
+	TC6393_CELL (SERIAL	),
+	TC6393_CELL (LCD	),
+};
+
+/*--------------------------------------------------------------------------*/
+
+/*
+ * TC6393 System Configuration Register
+ */
+struct tc6393_scr {
+	u8 x00[8];
+	u8	revid;		/* 0x08 Revision ID			*/
+	u8 x01[0x47];
+	u8	isr;		/* 0x50 Interrupt Status		*/
+	u8 x02;
+	u8	imr;		/* 0x52 Interrupt Mask			*/
+	u8 x03;
+	u8	irr;		/* 0x54 Interrupt Routing		*/
+	u8 x04[0x0b];
+	u16	gper;		/* 0x60 GP Enable			*/
+	u8 x05[2];
+	u16	gpi_sr[2];	/* 0x64 GPI Status			*/
+	u16	gpi_imr[2];	/* 0x68 GPI INT Mask			*/
+	u16	gpi_eder[2];	/* 0x6c GPI Edge Detect Enable		*/
+	u16	gpi_lir[4];	/* 0x70 GPI Level Invert		*/
+	u16	gpo_dsr[2];	/* 0x78 GPO Data Set			*/
+	u16	gpo_doecr[2];	/* 0x7c GPO Data OE Control		*/
+	u16	gp_iarcr[2];	/* 0x80 GP Internal Active Reg Control	*/
+	u16	gp_iarlcr[2];	/* 0x84 GP Internal Active Reg Level Con*/
+	u8	gpi_bcr[4];	/* 0x88 GPI Buffer Control		*/
+	u16	gpa_iarcr;	/* 0x8c GPa Internal Active Reg Control	*/
+	u8 x06[2];
+	u16	gpa_iarlcr;	/* 0x90 GPa Internal Active Reg Level Co*/
+	u8 x07[2];
+	u16	gpa_bcr;	/* 0x94 GPa Buffer Control		*/
+	u8 x08[2];
+	u16	ccr;		/* 0x98 Clock Control			*/
+	u16	pll2cr;		/* 0x9a PLL2 Control			*/
+	u16	pll1cr[2];	/* 0x9c PLL1 Control			*/
+	u8	diarcr;		/* 0xa0 Device Internal Active Reg Contr*/
+	u8	dbocr;		/* 0xa1 Device Buffer Off Control	*/
+	u8 x09[0x3e];
+	u8	fer;		/* 0xe0 Function Enable			*/
+	u8 x10[3];
+	u16	mcr;		/* 0xe4 Mode Control			*/
+	u8 x11[0x14];
+	u8	config;		/* 0xfc Configuration Control		*/
+	u8 x12[2];
+	u8	debug;		/* 0xff Debug				*/
+} __attribute__ ((packed));
+
+union tc6393_scr_fer {
+	u8		raw;
+struct {
+	unsigned	usben:1;	/* D0	USB enable		*/
+	unsigned	lcdcven:1;	/* D1	polysylicon TFT enable	*/
+	unsigned	slcden:1;	/* D2	SLCD enable		*/
+} __attribute__ ((packed));
+} __attribute__ ((packed));
+
+union tc6393_scr_ccr {
+	u16		raw;
+struct {
+	unsigned	ck32ken:1;	/* D0	SD host clock enable	*/
+	unsigned	usbcken:1;	/* D1	USB host clock enable	*/
+	unsigned	x00:2;
+	unsigned	sharp:1;	/* D4	??? set in Sharp's code	*/
+	unsigned	x01:3;
+	enum {				disable	= 0,
+					m12MHz	= 1,
+					m24MHz	= 2,
+					m48MHz	= 3,
+	}		mclksel:3;	/* D10-D8  LCD controller clock	*/
+	unsigned	x02:1;
+	enum {				h24MHz	= 0,
+					h48MHz	= 1,
+	}		hclksel:2;	/* D13-D12 host bus clock	*/
+	unsigned	x03:2;
+} __attribute__ ((packed));
+} __attribute__ ((packed));
+
+/*--------------------------------------------------------------------------*/
+
+struct tc6393 {
+	spinlock_t		lock;	/* read-modify-write lock	*/
+	struct device*		dev;	/* TC6393 device		*/
+	struct tc6393_scr __iomem *scr;	/* system configuration reg	*/
+
+	struct resource		rscr;	/* system config reg resource	*/
+	struct resource*	iomem;	/* entire TC6393 iomem resource	*/
+	unsigned int		irq;	/* hardware cascade irq		*/
+
+	struct tmio_device	tdev [TC6393_NUM_CELLS];
+};
+
+/*--------------------------------------------------------------------------*/
+
+static u32 tc6393_ioread32 (const void __iomem *addr)
+{
+	return ((u32) ioread16 (addr)) | (((u32) ioread16 (addr + 2)) << 16);
+}
+
+static u32 tc6393_iowrite32 (u32 val, const void __iomem *addr)
+{
+	iowrite16 (val,		addr);
+	iowrite16 (val >> 16,	addr + 2);
+	return val;
+}
+
+u32 get_tc6393_gpio (struct device *dev)
+{
+	struct tc6393*			tc6393	= dev_get_drvdata (dev);
+	struct tc6393_scr __iomem *	scr	= tc6393->scr;
+
+	return tc6393_ioread32 (scr->gpo_dsr);
+}
+EXPORT_SYMBOL (get_tc6393_gpio);
+
+u32 set_tc6393_gpio (struct device *dev, u32 bits)
+{
+	struct tc6393*			tc6393	= dev_get_drvdata (dev);
+	struct tc6393_scr __iomem *	scr	= tc6393->scr;
+	unsigned long			flags;
+	u32				dsr;
+
+	spin_lock_irqsave (&tc6393->lock, flags);
+	dsr = tc6393_ioread32 (scr->gpo_dsr) | bits;
+	tc6393_iowrite32 (dsr, scr->gpo_dsr);
+	spin_unlock_irqrestore (&tc6393->lock, flags);
+
+	return dsr;
+}
+EXPORT_SYMBOL (set_tc6393_gpio);
+
+u32 reset_tc6393_gpio (struct device *dev, u32 bits)
+{
+	struct tc6393*			tc6393	= dev_get_drvdata (dev);
+	struct tc6393_scr __iomem *	scr	= tc6393->scr;
+	unsigned long			flags;
+	u32				dsr;
+
+	spin_lock_irqsave (&tc6393->lock, flags);
+	dsr = tc6393_ioread32 (scr->gpo_dsr) & ~bits;
+	tc6393_iowrite32 (dsr, scr->gpo_dsr);
+	spin_unlock_irqrestore (&tc6393->lock, flags);
+
+	return dsr;
+}
+EXPORT_SYMBOL (reset_tc6393_gpio);
+
+/*--------------------------------------------------------------------------*/
+
+static void
+tc6393_irq (unsigned int irq, struct irqdesc *desc)
+{
+	struct tc6393*			tc6393	= get_irq_chipdata (irq);
+	struct tc6393_scr __iomem *	scr	= tc6393->scr;
+	unsigned int			isr;
+	unsigned int			bit;
+	unsigned int			i;
+
+	desc->chip->ack (irq);
+
+	while ((isr = ioread8(&scr->isr) & ~ioread8(&scr->imr)))
+		for (bit = 1, i = IRQ_TC6393_START; i <= IRQ_TC6393_LCD;
+								bit <<= 1, i++)
+			if (isr & bit)
+				desc_handle_irq (i, irq_desc + i);
+}
+
+static void tc6393_irq_ack (unsigned int irq)
+{
+}
+
+static void tc6393_irq_mask (unsigned int irq)
+{
+	struct tc6393*			tc6393	= get_irq_chipdata (irq);
+	struct tc6393_scr __iomem *	scr	= tc6393->scr;
+	unsigned long			flags;
+
+	spin_lock_irqsave (&tc6393->lock, flags);
+	iowrite8 (ioread8 (&scr->imr) | (1 << (irq - IRQ_TC6393_START)),
+								&scr->imr);
+	spin_unlock_irqrestore (&tc6393->lock, flags);
+}
+
+static void tc6393_irq_unmask (unsigned int irq)
+{
+	struct tc6393*			tc6393	= get_irq_chipdata (irq);
+	struct tc6393_scr __iomem *	scr	= tc6393->scr;
+	unsigned long			flags;
+
+	spin_lock_irqsave (&tc6393->lock, flags);
+	iowrite8 (ioread8 (&scr->imr) & ~(1 << (irq - IRQ_TC6393_START)),
+								&scr->imr);
+	spin_unlock_irqrestore (&tc6393->lock, flags);
+}
+
+static struct irqchip tc6393_chip = {
+	.ack	= tc6393_irq_ack,
+	.mask	= tc6393_irq_mask,
+	.unmask	= tc6393_irq_unmask,
+};
+
+static void tc6393_attach_irq (struct tc6393 *tc6393)
+{
+	unsigned int		irq;
+
+	for (irq = IRQ_TC6393_START; irq <= IRQ_TC6393_LCD; irq++) {
+		set_irq_chip	(irq, &tc6393_chip);
+		set_irq_chipdata(irq, tc6393);
+		set_irq_handler	(irq, do_edge_IRQ);
+		set_irq_flags	(irq, IRQF_VALID | IRQF_PROBE);
+	}
+
+	set_irq_type		(tc6393->irq, IRQT_FALLING);
+	set_irq_chipdata	(tc6393->irq, tc6393);
+	set_irq_chained_handler	(tc6393->irq, tc6393_irq);
+}
+
+static void tc6393_detach_irq (struct tc6393 *tc6393)
+{
+	unsigned int		irq;
+
+	set_irq_chained_handler	(tc6393->irq, NULL);
+	set_irq_chipdata	(tc6393->irq, NULL);
+
+	for (irq = IRQ_TC6393_START; irq <= IRQ_TC6393_LCD; irq++) {
+		set_irq_flags	(irq, 0);
+		set_irq_chip	(irq, NULL);
+		set_irq_chipdata(irq, NULL);
+	}
+}
+
+/*--------------------------------------------------------------------------*/
+
+static int tc6393_bus_match (struct device *dev, struct device_driver *drv)
+{
+	struct tmio_device*		tdev	= dev_to_tdev (dev);
+	const struct tc6393_cell*	cell	= tdev->soc_data;
+
+	return !strcmp (cell->name, drv->name);
+}
+
+static int tc6393_bus_suspend (struct device *dev, pm_message_t state)
+{
+	struct device_driver*	drv	= dev->driver;
+	return drv && drv->suspend ? drv->suspend (dev, state) : 0;
+}
+
+static int tc6393_bus_resume (struct device *dev)
+{
+	struct device_driver*	drv	= dev->driver;
+	return drv && drv->resume ? drv->resume (dev) : 0;
+}
+
+struct bus_type tc6393_bus_type = {
+	.name		= TMIO_NAME_BUS,
+	.match		= tc6393_bus_match,
+	.suspend	= tc6393_bus_suspend,
+	.resume		= tc6393_bus_resume,
+};
+EXPORT_SYMBOL (tc6393_bus_type);
+
+/*--------------------------------------------------------------------------*/
+
+static void tc6393_cell_clock (struct device *dev, int enable)
+{
+	struct tmio_device*		tdev	= dev_to_tdev (dev);
+	const struct tc6393_cell*	cell	= tdev->soc_data;
+	struct tc6393*			tc6393	= dev_get_drvdata (dev->parent);
+	struct tc6393_scr __iomem *	scr	= tc6393->scr;
+	union tc6393_scr_ccr		ccr;
+	unsigned long			flags;
+
+	spin_lock_irqsave (&tc6393->lock, flags);
+	ccr.raw = ioread16 (&scr->ccr);
+
+	switch (cell->id) {
+		case TC6393_CELL_SD:	ccr.ck32ken	= enable;	break;
+		case TC6393_CELL_OHCI:	ccr.usbcken	= enable;	break;
+		case TC6393_CELL_LCD:
+			ccr.mclksel = enable ? m48MHz : disable;
+			break;
+	}
+
+	printk (KERN_DEBUG TMIO_NAME_CORE ": scr->ccr = %04x\n", ccr.raw);
+
+	iowrite16(ccr.raw, &scr->ccr);
+	spin_unlock_irqrestore (&tc6393->lock, flags);
+}
+
+static void tc6393_cell_function (struct device *dev, int enable)
+{
+	struct tmio_device*		tdev	= dev_to_tdev (dev);
+	const struct tc6393_cell*	cell	= tdev->soc_data;
+	struct tc6393*			tc6393	= dev_get_drvdata (dev->parent);
+	struct tc6393_scr __iomem *	scr	= tc6393->scr;
+	union tc6393_scr_fer		fer;
+	unsigned long			flags;
+
+	if (cell->id == TC6393_CELL_NAND) {
+		if (enable) {
+			/* SMD buffer on */
+			printk (KERN_DEBUG TMIO_NAME_CORE ": SMD buffer on\n");
+			iowrite8 (0xff, scr->gpi_bcr + 1);
+		}
+		return;
+	}
+
+	spin_lock_irqsave (&tc6393->lock, flags);
+	fer.raw = ioread16 (&scr->fer);
+
+	switch (cell->id) {
+		case TC6393_CELL_OHCI:	fer.usben	= enable;	break;
+		case TC6393_CELL_LCD:	fer.slcden	= enable;	break;
+	}
+
+	printk (KERN_DEBUG TMIO_NAME_CORE ": scr->fer = %02x\n", fer.raw);
+
+	iowrite8 (fer.raw, &scr->fer);
+	spin_unlock_irqrestore (&tc6393->lock, flags);
+}
+
+static void
+tc6393_lcd_mode (struct device *dev, const struct fb_videomode *mode)
+{
+	struct tc6393*			tc6393	= dev_get_drvdata (dev->parent);
+	struct tc6393_scr __iomem *	scr	= tc6393->scr;
+
+	iowrite16 (mode->pixclock,		scr->pll1cr + 0);
+	iowrite16 (mode->pixclock >> 16,	scr->pll1cr + 1);
+}
+
+static struct tmio_cell_ops tc6393_cell_ops = {
+	.clock		= tc6393_cell_clock,
+	.function	= tc6393_cell_function,
+	.lcd_mode	= tc6393_lcd_mode,
+};
+
+static void tc6393_device_release (struct device *dev)
+{
+}
+
+static int
+tc6393_device_register (struct tc6393 *tc6393, struct tmio_cell *tcell)
+{
+	const struct tc6393_cell*	cell;
+	struct tmio_device*		tdev;
+	struct device*			dev;
+	int				i;
+
+	for (i = 0; strcmp (tcell->name, tc6393_cell [i].name); )
+		if (++i >= ARRAY_SIZE(tc6393_cell))
+			return -EINVAL;
+
+	cell			= tc6393_cell  + i;
+	tdev			= tc6393->tdev + i;
+	dev			= &tdev->dev;
+
+	tdev->ops		= &tc6393_cell_ops;
+	tdev->iomem		= tc6393->iomem;
+	tdev->soc_data		= (void*) cell;
+
+	dev->parent		= tc6393->dev;
+	strncpy (dev->bus_id, cell->name, sizeof dev->bus_id);
+	dev->bus		= &tc6393_bus_type;
+	dev->dma_mask		= tc6393->dev->dma_mask;
+	dev->coherent_dma_mask	= tc6393->dev->coherent_dma_mask;
+	dev->release		= tc6393_device_release;
+	dev->platform_data	= tcell->platform_data;
+
+	for (i=0; i < cell->num_resources; i++) {
+		const struct resource*	cr	= cell->resource + i;
+		struct resource*	dr	= tdev->resource + i;
+
+		dr->name	= cr->name;
+		dr->start	= cr->start;
+		dr->end		= cr->end;
+		dr->flags	= cr->flags;
+
+		/* convert memory offsets to absolutes */
+		if (cr->flags & IORESOURCE_MEM) {
+			dr->start	+= tc6393->iomem->start;
+			dr->end		+= tc6393->iomem->start;
+		}
+	}
+
+	return device_register (dev);
+}
+
+/*--------------------------------------------------------------------------*/
+
+static void tc6393_hw_init (struct tc6393 *tc6393)
+{
+	struct tc6393_scr __iomem *	scr	= tc6393->scr;
+	struct tc6393_platform_data*	tcpd	= tc6393->dev->platform_data;
+
+	tcpd->enable (tc6393->dev);
+
+	iowrite8 (0,				&scr->fer);
+	iowrite16(tcpd->scr_pll2cr,		&scr->pll2cr);
+	iowrite16(tcpd->scr_ccr,		&scr->ccr);
+	iowrite16(tcpd->scr_mcr,		&scr->mcr);
+	iowrite16(tcpd->scr_gper,		&scr->gper);
+	iowrite8 (0,				&scr->irr);
+	iowrite8 (0xbf,				&scr->imr);
+	iowrite16(tcpd->scr_gpo_dsr,		scr->gpo_dsr + 0);
+	iowrite16(tcpd->scr_gpo_dsr >> 16,	scr->gpo_dsr + 1);
+	iowrite16(tcpd->scr_gpo_doecr,		scr->gpo_doecr + 0);
+	iowrite16(tcpd->scr_gpo_doecr >> 16,	scr->gpo_doecr + 1);
+}
+
+static int tc6393_probe (struct device *dev)
+{
+	struct platform_device*		pdev	= to_platform_device (dev);
+	struct tc6393_platform_data*	tcpd	= dev->platform_data;
+	struct tc6393*			tc6393;
+	struct resource*		iomem;
+	struct resource*		rscr;
+	int				retval;
+	int				i;
+
+	iomem = platform_get_resource (pdev, IORESOURCE_MEM, 0);
+	if (!iomem)
+		return -EINVAL;
+
+	tc6393 = kzalloc (sizeof *tc6393, GFP_KERNEL);
+	if (!tc6393) {
+		retval = -ENOMEM;
+		goto err_kzalloc;
+	}
+
+	dev_set_drvdata (dev, tc6393);
+	spin_lock_init (&tc6393->lock);
+	tc6393->dev	= dev;
+	tc6393->iomem	= iomem;
+	tc6393->irq	= platform_get_irq (pdev, 0);
+
+	rscr		= &tc6393->rscr;
+	rscr->name	= TMIO_NAME_CORE;
+	rscr->start	= iomem->start;
+	rscr->end	= iomem->start + 0xff;
+	rscr->flags	= IORESOURCE_MEM;
+
+	retval = request_resource (iomem, rscr);
+	if (retval)
+		goto err_request_scr;
+
+	tc6393->scr	= ioremap (rscr->start, rscr->end - rscr->start + 1);
+	if (!tc6393->scr) {
+		retval = -ENOMEM;
+		goto err_ioremap;
+	}
+
+	tc6393_hw_init (tc6393);
+
+	printk (KERN_INFO "Toshiba %s revision %d at 0x%08lx, irq %d\n",
+			TMIO_SOC_NAME, ioread8 (&tc6393->scr->revid),
+			iomem->start, tc6393->irq);
+
+	if (tc6393->irq)
+		tc6393_attach_irq (tc6393);
+
+	for (i = 0; i < tcpd->num_cells; i++)
+		tc6393_device_register (tc6393, tcpd->cell + i);
+
+	return 0;
+
+err_ioremap:
+	release_resource (rscr);
+err_request_scr:
+	kfree(tc6393);
+err_kzalloc:
+	release_resource (iomem);
+	return retval;
+}
+
+static int tc6393_dev_remove (struct device *dev, void *data)
+{
+	device_unregister (dev);
+	return 0;
+}
+
+static int tc6393_remove (struct device *dev)
+{
+	struct tc6393*		tc6393	= dev_get_drvdata (dev);
+
+	device_for_each_child (dev, tc6393, tc6393_dev_remove);
+
+	if (tc6393->irq)
+		tc6393_detach_irq (tc6393);
+
+	iounmap (tc6393->scr);
+	release_resource (&tc6393->rscr);
+	release_resource (tc6393->iomem);
+	kfree (tc6393);
+	return 0;
+}
+
+#ifdef CONFIG_PM
+static int tc6393_suspend (struct device *dev, pm_message_t state)
+{
+	struct tc6393_platform_data*	tcpd	= dev->platform_data;
+	tcpd->disable (dev);
+	return 0;
+}
+
+static int tc6393_resume (struct device *dev)
+{
+	struct tc6393*			tc6393	= dev_get_drvdata (dev);
+	tc6393_hw_init (tc6393);
+	return 0;
+}
+#endif
+
+static struct device_driver tc6393_device_driver = {
+	.name		= TMIO_SOC_NAME,
+	.bus		= &platform_bus_type,
+	.probe		= tc6393_probe,
+	.remove		= tc6393_remove,
+#ifdef CONFIG_PM
+	.suspend	= tc6393_suspend,
+	.resume		= tc6393_resume,
+#endif
+};
+
+/*--------------------------------------------------------------------------*/
+
+static int __init tc6393_init (void)
+{
+	int retval = bus_register (&tc6393_bus_type);
+	if (retval)
+		return retval;
+
+	return driver_register (&tc6393_device_driver);
+}
+
+static void __exit tc6393_exit (void)
+{
+	driver_unregister (&tc6393_device_driver);
+	bus_unregister (&tc6393_bus_type);
+}
+
+module_init (tc6393_init);
+module_exit (tc6393_exit);
+
+MODULE_DESCRIPTION ("TC6393 SoC bus driver");
+MODULE_AUTHOR ("Chris Humbert, Dirk Opfer");
+MODULE_LICENSE ("GPL");
Index: git/arch/arm/common/Kconfig
===================================================================
--- git.orig/arch/arm/common/Kconfig	2006-10-31 16:08:28.000000000 +0000
+++ git/arch/arm/common/Kconfig	2006-11-07 22:13:09.000000000 +0000
@@ -31,3 +31,6 @@ config SHARPSL_PM
 
 config SHARP_SCOOP
 	bool
+
+config TOSHIBA_TC6393XB
+	bool
Index: git/arch/arm/mach-pxa/Kconfig
===================================================================
--- git.orig/arch/arm/mach-pxa/Kconfig	2006-11-07 22:13:06.000000000 +0000
+++ git/arch/arm/mach-pxa/Kconfig	2006-11-07 23:30:34.000000000 +0000
@@ -128,6 +128,7 @@ config MACH_BORZOI
 config MACH_TOSA
 	bool "Enable Sharp SL-6000x (Tosa) Support"
 	depends PXA_SHARPSL_25x
+	select TOSHIBA_TC6393XB
 
 config PXA25x
 	bool
Index: git/arch/arm/common/Makefile
===================================================================
--- git.orig/arch/arm/common/Makefile	2006-10-31 16:08:28.000000000 +0000
+++ git/arch/arm/common/Makefile	2006-11-07 22:13:09.000000000 +0000
@@ -17,3 +17,4 @@ obj-$(CONFIG_SHARPSL_PM)	+= sharpsl_pm.o
 obj-$(CONFIG_SHARP_SCOOP)	+= scoop.o
 obj-$(CONFIG_ARCH_IXP2000)	+= uengine.o
 obj-$(CONFIG_ARCH_IXP23XX)	+= uengine.o
+obj-$(CONFIG_TOSHIBA_TC6393XB)	+= tc6393xb.o
Index: git/include/asm-arm/hardware/tmio.h
===================================================================
--- git.orig/include/asm-arm/hardware/tmio.h	2006-11-07 22:13:09.000000000 +0000
+++ git/include/asm-arm/hardware/tmio.h	2006-11-07 22:13:09.000000000 +0000
@@ -91,6 +91,50 @@ struct tmio_device {
 
 /*--------------------------------------------------------------------------*/
 
+/*
+ * TC6393XB SoC
+ */
+#ifdef CONFIG_TOSHIBA_TC6393XB
+#define TMIO_SOC_TC6393XB
+#define TMIO_SOC_NAME			"TC6393XB"
+#define TMIO_NAME_BUS			"tc6393-bus"
+#define TMIO_NAME_CORE			"tc6393-core"
+#define TMIO_NAME_NAND			"tc6393-nand"
+#define TMIO_NAME_SD			"tc6393-sd"
+#define TMIO_NAME_OHCI			"tc6393-ohci"
+#define TMIO_NAME_SERIAL		"tc6393-serial"
+#define TMIO_NAME_LCD			"tc6393-lcd"
+#define tmio_bus_type			tc6393_bus_type
+
+#define TC6393_GPIO(x)			(1 << (x))
+
+extern struct bus_type tc6393_bus_type;
+
+struct tc6393_platform_data {
+	u16	scr_pll2cr;		/* PLL2 Control			*/
+	u16	scr_ccr;		/* Clock Control		*/
+	u16	scr_mcr;		/* Mode Control			*/
+	u16	scr_gper;		/* GP Enable			*/
+	u32	scr_gpo_doecr;		/* GPO Data OE Control		*/
+	u32	scr_gpo_dsr;		/* GPO Data Set			*/
+
+	/* cells to register as devices */
+	struct tmio_cell*		cell;
+	unsigned int			num_cells;
+
+	/* callbacks to enable and disable the TC6393XB's power and clock */
+	void (*enable)	(struct device *dev);
+	void (*disable)	(struct device *dev);
+};
+
+u32	get_tc6393_gpio		(struct device *dev);
+u32	set_tc6393_gpio		(struct device *dev, u32 bits);
+u32	reset_tc6393_gpio	(struct device *dev, u32 bits);
+
+/*--------------------------------------------------------------------------*/
+
+#else
 #error "no TMIO SoC configured"
+#endif
 
 #endif
Index: git/include/asm-arm/arch-pxa/irqs.h
===================================================================
--- git.orig/include/asm-arm/arch-pxa/irqs.h	2006-10-31 16:09:33.000000000 +0000
+++ git/include/asm-arm/arch-pxa/irqs.h	2006-11-07 22:13:09.000000000 +0000
@@ -163,17 +163,27 @@
 #define IRQ_LOCOMO_SPI_OVRN	(IRQ_BOARD_END + 20)
 #define IRQ_LOCOMO_SPI_TEND	(IRQ_BOARD_END + 21)
 
+#define IRQ_TC6393_START	(IRQ_BOARD_END)
+#define IRQ_TC6393_NAND		(IRQ_BOARD_END + 0)
+#define IRQ_TC6393_SD		(IRQ_BOARD_END + 1)
+#define IRQ_TC6393_OHCI		(IRQ_BOARD_END + 2)
+#define IRQ_TC6393_SERIAL	(IRQ_BOARD_END + 3)
+#define IRQ_TC6393_LCD		(IRQ_BOARD_END + 4)
+
 /*
  * Figure out the MAX IRQ number.
  *
  * If we have an SA1111, the max IRQ is S1_BVD1_STSCHG+1.
  * If we have an LoCoMo, the max IRQ is IRQ_LOCOMO_SPI_TEND+1
+ * If we have an TC6393XB, the max IRQ is IRQ_TC6393_LCD+1
  * Otherwise, we have the standard IRQs only.
  */
 #ifdef CONFIG_SA1111
 #define NR_IRQS			(IRQ_S1_BVD1_STSCHG + 1)
 #elif defined(CONFIG_SHARP_LOCOMO)
 #define NR_IRQS			(IRQ_LOCOMO_SPI_TEND + 1)
+#elif defined(CONFIG_TOSHIBA_TC6393XB)
+#define NR_IRQS			(IRQ_TC6393_LCD + 1)
 #elif defined(CONFIG_ARCH_LUBBOCK) || \
       defined(CONFIG_MACH_LOGICPD_PXA270) || \
       defined(CONFIG_MACH_MAINSTONE)