aboutsummaryrefslogtreecommitdiffstats
path: root/recipes/linux/linux-rp-2.6.24/tosa/0004-Add-support-for-tc6393xb-MFD-core.patch
blob: a78c0f37f3c3df49a0a66577e250b3218bbe4685 (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
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
From 3f56cac281fb407b7d8e574d18ee7d72aa7e7c28 Mon Sep 17 00:00:00 2001
From: Ian Molton <spyro@f2s.com>
Date: Sat, 29 Dec 2007 15:02:30 +0000
Subject: [PATCH 04/64] Add support for tc6393xb MFD core

---
 drivers/mfd/Kconfig          |    6 +
 drivers/mfd/Makefile         |    2 +
 drivers/mfd/tc6393xb.c       |  740 ++++++++++++++++++++++++++++++++++++++++++
 include/linux/mfd/tc6393xb.h |  108 ++++++
 4 files changed, 856 insertions(+), 0 deletions(-)
 create mode 100644 drivers/mfd/tc6393xb.c
 create mode 100644 include/linux/mfd/tc6393xb.h

diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
index 1205c89..9903d0a 100644
--- a/drivers/mfd/Kconfig
+++ b/drivers/mfd/Kconfig
@@ -9,6 +9,12 @@ config MFD_CORE
 	tristate
 	default n
 
+config MFD_TC6393XB
+	bool "Support Toshiba TC6393XB"
+	select MFD_CORE
+	help
+	  Support for Toshiba Mobile IO Controller TC6393XB
+
 config MFD_SM501
 	tristate "Support for Silicon Motion SM501"
 	 ---help---
diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile
index 6c20064..ffd342e 100644
--- a/drivers/mfd/Makefile
+++ b/drivers/mfd/Makefile
@@ -6,6 +6,8 @@ obj-$(CONFIG_MFD_SM501)		+= sm501.o
 
 obj-$(CONFIG_MFD_CORE)		+= mfd-core.o
 
+obj-$(CONFIG_MFD_TC6393XB)	+= tc6393xb.o
+
 obj-$(CONFIG_MCP)		+= mcp-core.o
 obj-$(CONFIG_MCP_SA11X0)	+= mcp-sa11x0.o
 obj-$(CONFIG_MCP_UCB1200)	+= ucb1x00-core.o
diff --git a/drivers/mfd/tc6393xb.c b/drivers/mfd/tc6393xb.c
new file mode 100644
index 0000000..9439f39
--- /dev/null
+++ b/drivers/mfd/tc6393xb.c
@@ -0,0 +1,740 @@
+/*
+ * Toshiba TC6393XB SoC support
+ *
+ * Copyright(c) 2005-2006 Chris Humbert
+ * Copyright(c) 2005 Dirk Opfer
+ * Copyright(c) 2005 Ian Molton <spyro@f2s.com>
+ * Copyright(c) 2007 Dmitry Baryshkov
+ *
+ * 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/kernel.h>
+#include <linux/module.h>
+#include <linux/io.h>
+#include <linux/irq.h>
+#include <linux/platform_device.h>
+#include <linux/fb.h>
+#include <linux/mfd-core.h>
+#include <linux/mfd/tmio.h>
+#include <linux/mfd/tc6393xb.h>
+
+struct tc6393xb_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));
+
+/*--------------------------------------------------------------------------*/
+
+struct tc6393xb {
+	struct tc6393xb_scr __iomem	*scr;
+
+	spinlock_t			lock; /* protects RMW cycles */
+
+	struct {
+		union tc6393xb_scr_fer	fer;
+		union tc6393xb_scr_ccr	ccr;
+		u8			gpi_bcr[4];
+	} suspend_state;
+
+	struct resource			rscr;
+	struct resource			*iomem;
+	int				irq;
+};
+
+/*--------------------------------------------------------------------------*/
+
+static int tc6393xb_mmc_enable(struct platform_device *mmc) {
+	struct platform_device		*dev	= to_platform_device(mmc->dev.parent);
+	struct tc6393xb			*tc6393xb = platform_get_drvdata(dev);
+	struct tc6393xb_scr __iomem	*scr = tc6393xb->scr;
+	union tc6393xb_scr_ccr		ccr;
+	unsigned long			flags;
+
+	spin_lock_irqsave(&tc6393xb->lock, flags);
+	ccr.raw = ioread16(&scr->ccr);
+	ccr.bits.ck32ken = 1;
+	iowrite16(ccr.raw, &scr->ccr);
+	spin_unlock_irqrestore(&tc6393xb->lock, flags);
+
+	return 0;
+}
+
+static int tc6393xb_mmc_disable(struct platform_device *mmc) {
+	struct platform_device		*dev	= to_platform_device(mmc->dev.parent);
+	struct tc6393xb			*tc6393xb = platform_get_drvdata(dev);
+	struct tc6393xb_scr __iomem	*scr	= tc6393xb->scr;
+	union tc6393xb_scr_ccr		ccr;
+	unsigned long			flags;
+
+	spin_lock_irqsave(&tc6393xb->lock, flags);
+	ccr.raw = ioread16(&scr->ccr);
+	ccr.bits.ck32ken = 0;
+	iowrite16(ccr.raw, &scr->ccr);
+	spin_unlock_irqrestore(&tc6393xb->lock, flags);
+
+	return 0;
+}
+
+/*--------------------------------------------------------------------------*/
+
+static int tc6393xb_nand_disable(struct platform_device *nand)
+{
+	return 0;
+}
+
+static int tc6393xb_nand_enable(struct platform_device *nand)
+{
+	struct platform_device		*dev	= to_platform_device(nand->dev.parent);
+	struct tc6393xb			*tc6393xb = platform_get_drvdata(dev);
+	struct tc6393xb_scr __iomem	*scr	= tc6393xb->scr;
+	unsigned long			flags;
+
+	spin_lock_irqsave(&tc6393xb->lock, flags);
+
+	/* SMD buffer on */
+	dev_dbg(&dev->dev, "SMD buffer on\n");
+	iowrite8(0xff, scr->gpi_bcr + 1);
+
+	spin_unlock_irqrestore(&tc6393xb->lock, flags);
+
+	return 0;
+}
+
+int tc6393xb_lcd_set_power(struct platform_device *fb, bool on)
+{
+	struct platform_device		*dev	= to_platform_device(fb->dev.parent);
+	struct tc6393xb			*tc6393xb = platform_get_drvdata(dev);
+	struct tc6393xb_scr __iomem	*scr	= tc6393xb->scr;
+	union tc6393xb_scr_fer		fer;
+	unsigned long			flags;
+
+	spin_lock_irqsave(&tc6393xb->lock, flags);
+
+	fer.raw	= ioread8(&scr->fer);
+	fer.bits.slcden = on ? 1 : 0;
+	iowrite8(fer.raw, &scr->fer);
+
+	spin_unlock_irqrestore(&tc6393xb->lock, flags);
+
+	return 0;
+}
+EXPORT_SYMBOL(tc6393xb_lcd_set_power);
+
+int tc6393xb_lcd_mode(struct platform_device *fb_dev,
+					struct fb_videomode *mode) {
+	struct tc6393xb			*tc6393xb =
+		platform_get_drvdata(to_platform_device(fb_dev->dev.parent));
+	struct tc6393xb_scr __iomem	*scr	= tc6393xb->scr;
+
+	iowrite16(mode->pixclock,		scr->pll1cr + 0);
+	iowrite16(mode->pixclock >> 16,		scr->pll1cr + 1);
+
+	return 0;
+}
+EXPORT_SYMBOL(tc6393xb_lcd_mode);
+
+static int tc6393xb_ohci_disable(struct platform_device *ohci)
+{
+	struct platform_device		*dev	= to_platform_device(ohci->dev.parent);
+	struct tc6393xb			*tc6393xb = platform_get_drvdata(dev);
+	struct tc6393xb_scr __iomem	*scr	= tc6393xb->scr;
+	union tc6393xb_scr_ccr		ccr;
+	union tc6393xb_scr_fer		fer;
+	unsigned long			flags;
+
+	spin_lock_irqsave(&tc6393xb->lock, flags);
+
+	fer.raw = ioread8(&scr->fer);
+	fer.bits.usben = 0;
+	iowrite8(fer.raw, &scr->fer);
+
+	ccr.raw = ioread16(&scr->ccr);
+	ccr.bits.usbcken = 0;
+	iowrite16(ccr.raw, &scr->ccr);
+
+	spin_unlock_irqrestore(&tc6393xb->lock, flags);
+
+	return 0;
+}
+
+static int tc6393xb_ohci_enable(struct platform_device *ohci)
+{
+	struct platform_device		*dev	= to_platform_device(ohci->dev.parent);
+	struct tc6393xb			*tc6393xb = platform_get_drvdata(dev);
+	struct tc6393xb_scr __iomem	*scr	= tc6393xb->scr;
+	union tc6393xb_scr_ccr		ccr;
+	union tc6393xb_scr_fer		fer;
+	unsigned long			flags;
+
+	spin_lock_irqsave(&tc6393xb->lock, flags);
+
+	ccr.raw = ioread16(&scr->ccr);
+	ccr.bits.usbcken = 1;
+	iowrite16(ccr.raw, &scr->ccr);
+
+	fer.raw = ioread8(&scr->fer);
+	fer.bits.usben = 1;
+	iowrite8(fer.raw, &scr->fer);
+
+	spin_unlock_irqrestore(&tc6393xb->lock, flags);
+
+	return 0;
+}
+
+static int tc6393xb_fb_disable(struct platform_device *fb)
+{
+	struct platform_device		*dev	= to_platform_device(fb->dev.parent);
+	struct tc6393xb			*tc6393xb = platform_get_drvdata(dev);
+	struct tc6393xb_scr __iomem	*scr	= tc6393xb->scr;
+	union tc6393xb_scr_ccr		ccr;
+	union tc6393xb_scr_fer		fer;
+	unsigned long			flags;
+
+	spin_lock_irqsave(&tc6393xb->lock, flags);
+
+	/*
+	 * FIXME: is this correct or it should be moved to other _disable?
+	 */
+	fer.raw	= ioread8(&scr->fer);
+	fer.bits.slcden = 0;
+/*	fer.bits.lcdcven = 0; */
+	iowrite8(fer.raw, &scr->fer);
+
+	ccr.raw = ioread16(&scr->ccr);
+	ccr.bits.mclksel = disable;
+	iowrite16(ccr.raw, &scr->ccr);
+
+	spin_unlock_irqrestore(&tc6393xb->lock, flags);
+
+	return 0;
+}
+
+static int tc6393xb_fb_enable(struct platform_device *fb)
+{
+	struct platform_device		*dev	= to_platform_device(fb->dev.parent);
+	struct tc6393xb			*tc6393xb = platform_get_drvdata(dev);
+	struct tc6393xb_scr __iomem	*scr	= tc6393xb->scr;
+	union tc6393xb_scr_ccr		ccr;
+	unsigned long			flags;
+
+	spin_lock_irqsave(&tc6393xb->lock, flags);
+
+	ccr.raw = ioread16(&scr->ccr);
+	ccr.bits.mclksel = m48MHz;
+	iowrite16(ccr.raw, &scr->ccr);
+
+	spin_unlock_irqrestore(&tc6393xb->lock, flags);
+
+	return 0;
+}
+
+static int tc6393xb_fb_suspend(struct platform_device *fb)
+{
+	struct platform_device		*dev	= to_platform_device(fb->dev.parent);
+	struct tc6393xb			*tc6393xb = platform_get_drvdata(dev);
+	struct tc6393xb_scr __iomem	*scr	= tc6393xb->scr;
+	union tc6393xb_scr_ccr		ccr;
+	unsigned long			flags;
+
+	spin_lock_irqsave(&tc6393xb->lock, flags);
+
+	ccr.raw = ioread16(&scr->ccr);
+	ccr.bits.mclksel = disable;
+	iowrite16(ccr.raw, &scr->ccr);
+
+	spin_unlock_irqrestore(&tc6393xb->lock, flags);
+
+	return 0;
+}
+
+static int tc6393xb_fb_resume(struct platform_device *fb)
+{
+	struct platform_device		*dev	= to_platform_device(fb->dev.parent);
+	struct tc6393xb			*tc6393xb = platform_get_drvdata(dev);
+	struct tc6393xb_scr __iomem	*scr	= tc6393xb->scr;
+	union tc6393xb_scr_ccr		ccr;
+	unsigned long			flags;
+
+	spin_lock_irqsave(&tc6393xb->lock, flags);
+
+	ccr.raw = ioread16(&scr->ccr);
+	ccr.bits.mclksel = m48MHz;
+	iowrite16(ccr.raw, &scr->ccr);
+
+	spin_unlock_irqrestore(&tc6393xb->lock, flags);
+
+	return 0;
+}
+
+static struct resource tc6393xb_mmc_resources[] = {
+	{
+		.name	= TMIO_MMC_CONTROL,
+		.start	= 0x800,
+		.end	= 0x9ff,
+		.flags	= IORESOURCE_MEM,
+	},
+	{
+		.name	= TMIO_MMC_CONFIG,
+		.start	= 0x200,
+		.end	= 0x2ff,
+		.flags	= IORESOURCE_MEM,
+	},
+	{
+		.name	= TMIO_MMC_IRQ,
+		.start	= IRQ_TC6393_MMC,
+		.end	= IRQ_TC6393_MMC,
+		.flags	= IORESOURCE_IRQ | IORESOURCE_IRQ_MFD_SUBDEVICE,
+	},
+};
+
+const static struct resource tc6393xb_nand_resources[] = {
+	{
+		.name	= TMIO_NAND_CONFIG,
+		.start	= 0x0100,
+		.end	= 0x01ff,
+		.flags	= IORESOURCE_MEM,
+	},
+	{
+		.name	= TMIO_NAND_CONTROL,
+		.start	= 0x1000,
+		.end	= 0x1007,
+		.flags	= IORESOURCE_MEM,
+	},
+	{
+		.name	= TMIO_NAND_IRQ,
+		.start	= IRQ_TC6393_NAND,
+		.end	= IRQ_TC6393_NAND,
+		.flags	= IORESOURCE_IRQ | IORESOURCE_IRQ_MFD_SUBDEVICE,
+	},
+};
+
+const static struct resource tc6393xb_ohci_resources[] = {
+	{
+		.name	= TMIO_OHCI_CONFIG,
+		.start	= 0x0300,
+		.end	= 0x03ff,
+		.flags	= IORESOURCE_MEM,
+	},
+	{
+		.name	= TMIO_OHCI_CONTROL,
+		.start	= 0x3000,
+		.end	= 0x31ff,
+		.flags	= IORESOURCE_MEM,
+	},
+	{
+		.name	= TMIO_OHCI_SRAM,
+		.start	= 0x010000,
+		.end	= 0x017fff,
+		.flags	= IORESOURCE_MEM,
+	},
+	{
+		.name	= TMIO_OHCI_SRAM_ALIAS,
+		.start	= 0x018000,
+		.end	= 0x01ffff,
+		.flags	= IORESOURCE_MEM,
+	},
+	{
+		.name	= TMIO_OHCI_IRQ,
+		.start	= IRQ_TC6393_OHCI,
+		.end	= IRQ_TC6393_OHCI,
+		.flags	= IORESOURCE_IRQ | IORESOURCE_IRQ_MFD_SUBDEVICE,
+	},
+};
+
+const static struct resource tc6393xb_fb_resources[] = {
+	{
+		.name	= TMIO_FB_CONFIG,
+		.start	= 0x0500,
+		.end	= 0x05ff,
+		.flags	= IORESOURCE_MEM,
+	},
+	{
+		.name	= TMIO_FB_CONTROL,
+		.start	= 0x5000,
+		.end	= 0x51ff,
+		.flags	= IORESOURCE_MEM,
+	},
+	{
+		.name	= TMIO_FB_VRAM,
+		.start	= 0x100000,
+		.end	= 0x1fffff,
+		.flags	= IORESOURCE_MEM,
+	},
+	{
+		.name	= TMIO_FB_IRQ,
+		.start	= IRQ_TC6393_FB,
+		.end	= IRQ_TC6393_FB,
+		.flags	= IORESOURCE_IRQ | IORESOURCE_IRQ_MFD_SUBDEVICE,
+	},
+};
+
+static struct mfd_cell tc6393xb_cells[] = {
+	{
+		.name = "tmio-nand",
+		.enable = tc6393xb_nand_enable,
+		.disable = tc6393xb_nand_disable,
+		.num_resources = ARRAY_SIZE(tc6393xb_nand_resources),
+		.resources = tc6393xb_nand_resources,
+	},
+	{
+		.name = "tmio-ohci",
+		.enable = tc6393xb_ohci_enable,
+		.disable = tc6393xb_ohci_disable,
+		.num_resources = ARRAY_SIZE(tc6393xb_ohci_resources),
+		.resources = tc6393xb_ohci_resources,
+	},
+	{
+		.name = "tmio-fb",
+		.enable = tc6393xb_fb_enable,
+		.disable = tc6393xb_fb_disable,
+		.suspend = tc6393xb_fb_suspend,
+		.resume = tc6393xb_fb_resume,
+		.num_resources = ARRAY_SIZE(tc6393xb_fb_resources),
+		.resources = tc6393xb_fb_resources,
+	},
+	{
+		.name = "tmio-mmc",
+		.enable = tc6393xb_mmc_enable,
+		.disable = tc6393xb_mmc_disable,
+		.num_resources = ARRAY_SIZE(tc6393xb_mmc_resources),
+		.resources = tc6393xb_mmc_resources,
+	},
+};
+
+/*--------------------------------------------------------------------------*/
+
+static void
+tc6393xb_irq(unsigned int irq, struct irq_desc *desc)
+{
+	struct platform_device		*dev	= get_irq_chip_data(irq);
+	struct tc6393xb_platform_data	*tcpd	= dev->dev.platform_data;
+	struct tc6393xb			*tc6393xb = platform_get_drvdata(dev);
+	struct tc6393xb_scr __iomem	*scr	= tc6393xb->scr;
+	unsigned int			isr;
+	unsigned int			i;
+
+	desc->chip->ack(irq);
+
+	while ((isr = ioread8(&scr->isr) & ~ioread8(&scr->imr)))
+		for (i = 0; i < TC6393XB_NR_IRQS; i++) {
+			if (isr & (1 << i))
+				desc_handle_irq(tcpd->irq_base + i,
+					irq_desc + tcpd->irq_base + i);
+		}
+}
+
+static void tc6393xb_irq_ack(unsigned int irq)
+{
+}
+
+static void tc6393xb_irq_mask(unsigned int irq)
+{
+	struct platform_device		*dev	= get_irq_chip_data(irq);
+	struct tc6393xb_platform_data	*tcpd	= dev->dev.platform_data;
+	struct tc6393xb			*tc6393xb = platform_get_drvdata(dev);
+	struct tc6393xb_scr __iomem	*scr	= tc6393xb->scr;
+	unsigned long			flags;
+
+	spin_lock_irqsave(&tc6393xb->lock, flags);
+	iowrite8(ioread8(&scr->imr) | (1 << (irq - tcpd->irq_base)),
+								&scr->imr);
+	spin_unlock_irqrestore(&tc6393xb->lock, flags);
+}
+
+static void tc6393xb_irq_unmask(unsigned int irq)
+{
+	struct platform_device		*dev	= get_irq_chip_data(irq);
+	struct tc6393xb_platform_data	*tcpd	= dev->dev.platform_data;
+	struct tc6393xb			*tc6393xb = platform_get_drvdata(dev);
+	struct tc6393xb_scr __iomem	*scr	= tc6393xb->scr;
+	unsigned long			flags;
+
+	spin_lock_irqsave(&tc6393xb->lock, flags);
+	iowrite8(ioread8(&scr->imr) & ~(1 << (irq - tcpd->irq_base)),
+								&scr->imr);
+	spin_unlock_irqrestore(&tc6393xb->lock, flags);
+}
+
+static struct irq_chip tc6393xb_chip = {
+	.name	= "tc6393xb",
+	.ack	= tc6393xb_irq_ack,
+	.mask	= tc6393xb_irq_mask,
+	.unmask	= tc6393xb_irq_unmask,
+};
+
+static void tc6393xb_attach_irq(struct platform_device *dev)
+{
+	struct tc6393xb_platform_data	*tcpd	= dev->dev.platform_data;
+	struct tc6393xb			*tc6393xb = platform_get_drvdata(dev);
+	unsigned int			irq;
+
+	for (
+			irq = tcpd->irq_base;
+			irq <= tcpd->irq_base + TC6393XB_NR_IRQS;
+			irq++) {
+		set_irq_chip(irq, &tc6393xb_chip);
+		set_irq_chip_data(irq, dev);
+		set_irq_handler(irq, handle_edge_irq);
+		set_irq_flags(irq, IRQF_VALID | IRQF_PROBE);
+	}
+
+	set_irq_type(tc6393xb->irq, IRQT_FALLING);
+	set_irq_chip_data(tc6393xb->irq, dev);
+	set_irq_chained_handler(tc6393xb->irq, tc6393xb_irq);
+}
+
+static void tc6393xb_detach_irq(struct platform_device *dev)
+{
+	struct tc6393xb_platform_data	*tcpd	= dev->dev.platform_data;
+	struct tc6393xb			*tc6393xb = platform_get_drvdata(dev);
+	unsigned int			irq;
+
+	set_irq_chained_handler(tc6393xb->irq, NULL);
+	set_irq_chip_data(tc6393xb->irq, NULL);
+
+	for (
+			irq = tcpd->irq_base;
+			irq <= tcpd->irq_base + TC6393XB_NR_IRQS;
+			irq++) {
+		set_irq_flags(irq, 0);
+		set_irq_chip(irq, NULL);
+		set_irq_chip_data(irq, NULL);
+	}
+}
+
+static int tc6393xb_hw_init(struct platform_device *dev, int resume)
+{
+	struct tc6393xb_platform_data	*tcpd	= dev->dev.platform_data;
+	struct tc6393xb			*tc6393xb = platform_get_drvdata(dev);
+	struct tc6393xb_scr __iomem	*scr	= tc6393xb->scr;
+	int				ret;
+	int				i;
+
+	if (resume)
+		ret = tcpd->resume(dev);
+	else
+		ret = tcpd->enable(dev);
+	if (ret)
+		return ret;
+
+	iowrite8(resume ?
+		tc6393xb->suspend_state.fer.raw :
+		0,				&scr->fer);
+	iowrite16(tcpd->scr_pll2cr,		&scr->pll2cr);
+	iowrite16(resume?
+		tc6393xb->suspend_state.ccr.raw :
+		tcpd->scr_ccr.raw,		&scr->ccr);
+	iowrite16(tcpd->scr_mcr.raw,		&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);
+
+	if (resume)
+		for (i = 0; i < 4; i++)
+			iowrite8(tc6393xb->suspend_state.gpi_bcr[i],
+						scr->gpi_bcr + i);
+
+	return 0;
+}
+
+static int __devinit tc6393xb_probe(struct platform_device *dev)
+{
+	struct tc6393xb_platform_data *tcpd	= dev->dev.platform_data;
+	struct tc6393xb		*tc6393xb;
+	struct resource		*iomem;
+	struct resource		*rscr;
+	int			retval;
+
+	iomem = platform_get_resource(dev, IORESOURCE_MEM, 0);
+	if (!iomem)
+		return -EINVAL;
+
+	tc6393xb = kzalloc(sizeof *tc6393xb, GFP_KERNEL);
+	if (!tc6393xb) {
+		retval = -ENOMEM;
+		goto err_kzalloc;
+	}
+
+	spin_lock_init(&tc6393xb->lock);
+
+	platform_set_drvdata(dev, tc6393xb);
+	tc6393xb->iomem	= iomem;
+	tc6393xb->irq	= platform_get_irq(dev, 0);
+
+	rscr		= &tc6393xb->rscr;
+	rscr->name	= "tc6393xb-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;
+
+	tc6393xb->scr	= ioremap(rscr->start, rscr->end - rscr->start + 1);
+	if (!tc6393xb->scr) {
+		retval = -ENOMEM;
+		goto err_ioremap;
+	}
+
+	retval = tc6393xb_hw_init(dev, 0);
+	if (retval)
+		goto err_hw_init;
+
+	printk(KERN_INFO "Toshiba tc6393xb revision %d at 0x%08lx, irq %d\n",
+			ioread8(&tc6393xb->scr->revid),
+			(unsigned long) iomem->start, tc6393xb->irq);
+
+	if (tc6393xb->irq)
+		tc6393xb_attach_irq(dev);
+
+	tc6393xb_cells[0].driver_data = tcpd->nand_data;
+	tc6393xb_cells[1].driver_data = NULL; /* tcpd->ohci_data; */
+	tc6393xb_cells[2].driver_data = tcpd->fb_data;
+
+	retval = mfd_add_devices(dev,
+			tc6393xb_cells, ARRAY_SIZE(tc6393xb_cells),
+			iomem, 0, tcpd->irq_base);
+
+	if (retval == 0)
+		return 0;
+
+	if (tc6393xb->irq)
+		tc6393xb_detach_irq(dev);
+
+err_hw_init:
+	iounmap(tc6393xb->scr);
+err_ioremap:
+	release_resource(rscr);
+err_request_scr:
+	kfree(tc6393xb);
+err_kzalloc:
+	release_resource(iomem);
+	return retval;
+}
+
+static int __devexit tc6393xb_remove(struct platform_device *dev) {
+	struct tc6393xb_platform_data	*tcpd	= dev->dev.platform_data;
+	struct tc6393xb			*tc6393xb = platform_get_drvdata(dev);
+	int ret;
+
+	if (tc6393xb->irq)
+		tc6393xb_detach_irq(dev);
+
+	ret = tcpd->disable(dev);
+
+	iounmap(tc6393xb->scr);
+	release_resource(&tc6393xb->rscr);
+	release_resource(tc6393xb->iomem);
+
+	mfd_remove_devices(dev);
+
+	platform_set_drvdata(dev, NULL);
+
+	kfree(tc6393xb);
+
+	return ret;
+}
+
+#ifdef CONFIG_PM
+static int tc6393xb_suspend(struct platform_device *dev, pm_message_t state)
+{
+	struct tc6393xb_platform_data	*tcpd	= dev->dev.platform_data;
+	struct tc6393xb			*tc6393xb = platform_get_drvdata(dev);
+	struct tc6393xb_scr __iomem	*scr = tc6393xb->scr;
+	int i;
+
+
+	tc6393xb->suspend_state.ccr.raw		= ioread16(&scr->ccr);
+	tc6393xb->suspend_state.fer.raw		= ioread8(&scr->fer);
+	for (i = 0; i < 4; i++)
+		tc6393xb->suspend_state.gpi_bcr[i] =
+			ioread8(scr->gpi_bcr + i);
+
+	return tcpd->suspend(dev);
+}
+
+static int tc6393xb_resume(struct platform_device *dev)
+{
+	return tc6393xb_hw_init(dev, 1);
+}
+#else
+#define tc6393xb_suspend NULL
+#define tc6393xb_resume NULL
+#endif
+
+static struct platform_driver tc6393xb_driver = {
+	.probe = tc6393xb_probe,
+	.remove = __devexit_p(tc6393xb_remove),
+	.suspend = tc6393xb_suspend,
+	.resume = tc6393xb_resume,
+
+	.driver = {
+		.name = "tc6393xb",
+		.owner		= THIS_MODULE,
+	},
+};
+
+static int __init tc6393xb_init(void)
+{
+	return platform_driver_register(&tc6393xb_driver);
+}
+
+static void __exit tc6393xb_exit(void)
+{
+	platform_driver_unregister(&tc6393xb_driver);
+}
+
+module_init(tc6393xb_init);
+module_exit(tc6393xb_exit);
+
+MODULE_LICENSE("GPL");
+MODULE_AUTHOR("Ian Molton, Dmitry Baryshkov and Dirk Opfer");
+MODULE_DESCRIPTION("tc6393xb Toshiba Mobile IO Controller");
diff --git a/include/linux/mfd/tc6393xb.h b/include/linux/mfd/tc6393xb.h
new file mode 100644
index 0000000..e699294
--- /dev/null
+++ b/include/linux/mfd/tc6393xb.h
@@ -0,0 +1,108 @@
+/*
+ * Toshiba TC6393XB SoC support
+ *
+ * Copyright(c) 2005-2006 Chris Humbert
+ * Copyright(c) 2005 Dirk Opfer
+ * Copyright(c) 2005 Ian Molton <spyro@f2s.com>
+ * Copyright(c) 2007 Dmitry Baryshkov
+ *
+ * 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.
+ */
+
+#ifndef TC6393XB_H
+#define TC6393XB_H
+
+#include <linux/mfd-core.h>
+#include <linux/mfd/tmio.h>
+
+union tc6393xb_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)) bits;
+} __attribute__ ((packed));
+
+union tc6393xb_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)) bits;
+} __attribute__ ((packed));
+
+enum pincontrol {
+	opendrain	= 0,
+	tristate	= 1,
+	pushpull	= 2,
+	/* reserved	= 3, */
+};
+
+union tc6393xb_scr_mcr {
+	u16		raw;
+struct {
+	enum pincontrol	rdyst:2;	/* D1-D0   HRDY control		*/
+	unsigned	x00:1;
+	unsigned	aren:1;		/* D3	   HRDY pull up resistance cut off */
+	enum pincontrol	intst:2;	/* D5-D4   #HINT control	*/
+	unsigned	x01:1;
+	unsigned	aien:1;		/* D7      #HINT pull up resitance cut off */
+	unsigned	x02:8;
+} __attribute__ ((packed)) bits;
+} __attribute__ ((packed));
+
+struct tc6393xb_platform_data {
+	u16	scr_pll2cr;	/* PLL2 Control */
+	union tc6393xb_scr_ccr	scr_ccr;	/* Clock Control */
+	union tc6393xb_scr_mcr	scr_mcr;	/* Mode Control */
+	u16	scr_gper;	/* GP Enable */
+	u32	scr_gpo_doecr;	/* GPO Data OE Control */
+	u32	scr_gpo_dsr;	/* GPO Data Set */
+
+	int	(*enable)(struct platform_device *dev);
+	int	(*disable)(struct platform_device *dev);
+	int	(*suspend)(struct platform_device *dev);
+	int	(*resume)(struct platform_device *dev);
+
+	int	irq_base;	/* a base for cascaded irq */
+
+	struct tmio_nand_data	*nand_data;
+	struct tmio_fb_data	*fb_data;
+};
+
+extern int tc6393xb_lcd_set_power(struct platform_device *fb_dev, bool on);
+extern int tc6393xb_lcd_mode(struct platform_device *fb_dev,
+					struct fb_videomode *mode);
+
+
+/*
+ * Relative to irq_base
+ */
+#define	IRQ_TC6393_NAND		0
+#define	IRQ_TC6393_MMC		1
+#define	IRQ_TC6393_OHCI		2
+#define	IRQ_TC6393_SERIAL	3
+#define	IRQ_TC6393_FB		4
+
+#define	TC6393XB_NR_IRQS	8
+
+#endif
-- 
1.5.3.8