summaryrefslogtreecommitdiff
path: root/packages/linux/openzaurus-pxa27x-2.4.20-rmk2-embedix20050228/P17-bvdd_050222.patch
blob: 785470a6aacfe1903d7fa5c00d9fdee373c0148d (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
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
diff -Nur c3000_pre/linux/drivers/video/Config.in c3000_work/linux/drivers/video/Config.in
--- c3000_pre/linux/drivers/video/Config.in	2005-02-22 00:14:45.000000000 +0900
+++ c3000_work/linux/drivers/video/Config.in	2005-02-21 23:36:35.000000000 +0900
@@ -86,6 +86,7 @@
      dep_bool '  Sharp SL-Series PXA LCD support' CONFIG_FB_SHARPSL_PXA $CONFIG_ARCH_SHARP_SL
      if [ "$CONFIG_FB_SHARPSL_PXA" = "y" ]; then
 	dep_bool '    Cached FB support for Sharp SL PXA LCDC' CONFIG_SHARPSL_PXA_CONSISTENT_ALLOC $CONFIG_FB_SHARPSL_PXA
+	dep_tristate '    PXA270 overlay(bvdd) support(EXPERIMENTAL)' CONFIG_FB_SHARPSL_PXA_BVDD $CONFIG_FB_SHARPSL_PXA
      fi
      dep_bool '  SHARP LOGO screen support' CONFIG_SHARP_LOGO_SCREEN $CONFIG_ARCH_SHARP_SL
      if [ "$CONFIG_FB_PXA" != "n" -a "$CONFIG_ARCH_LUBBOCK" = "y" ]; then
diff -Nur c3000_pre/linux/drivers/video/Makefile c3000_work/linux/drivers/video/Makefile
--- c3000_pre/linux/drivers/video/Makefile	2005-02-22 00:14:45.000000000 +0900
+++ c3000_work/linux/drivers/video/Makefile	2005-02-21 23:40:57.000000000 +0900
@@ -160,6 +160,7 @@
 obj-$(CONFIG_FB_CORGI)            += w100fb.o fbgen.o corgi_backlight.o
 obj-$(CONFIG_FB_TOSA)             += tc6393fb.o fbgen.o tosa_backlight.o
 obj-$(CONFIG_FB_SHARPSL_PXA)      += sharpsl_pxafb.o fbgen.o corgi_backlight.o
+obj-$(CONFIG_FB_SHARPSL_PXA_BVDD) += bvdd.o
 
 # Generic Low Level Drivers
 
diff -Nur c3000_pre/linux/drivers/video/bvdd.c c3000_work/linux/drivers/video/bvdd.c
--- c3000_pre/linux/drivers/video/bvdd.c	1970-01-01 09:00:00.000000000 +0900
+++ c3000_work/linux/drivers/video/bvdd.c	2005-02-22 00:05:24.000000000 +0900
@@ -0,0 +1,1124 @@
+/*  bvdd.c - Create an input/output character device
+ */
+
+#include <linux/kernel.h>   /* We're doing kernel work */
+#include <linux/module.h>   /* Specifically, a module */
+
+#if CONFIG_MODVERSIONS==1
+#define MODVERSIONS
+#include <linux/modversions.h>
+#endif
+
+#include <linux/fs.h>  /* The character device definitions are here */
+#include <linux/wrapper.h>
+#include <linux/mm.h>
+#include <linux/sched.h>
+#include <asm/system.h>
+#include <asm/hardware.h>
+#include <asm/uaccess.h>	/* for get_user and put_user */
+#include <asm/io.h>
+
+/* Our own ioctl numbers */
+#include "bvdd.h"
+#include "bvdd_p.h"
+
+#define SUCCESS 0
+
+#define DEVICE_NAME "bvdd"	/* The name for our device */
+
+#ifdef DEBUG
+# define PRINT_DEBUG(x...) printk(KERN_WARNING DEVICE_NAME ": " x)
+# define PRINT_INFO(x...) printk(KERN_WARNING DEVICE_NAME ": " x)
+# define PRINT_WARN(x...) printk(KERN_WARNING DEVICE_NAME ": " x)
+# define PRINT_ERROR(x...) printk(KERN_ERROR DEVICE_NAME ": " x)
+# define PRINT_FATAL(x...) printk(KERN_FATAL DEVICE_NAME ": " x)
+#else
+# define PRINT_DEBUG(x...)
+# define PRINT_INFO(x...)
+# define PRINT_WARN(x...) printk(KERN_WARNING DEVICE_NAME ": " x)
+# define PRINT_ERROR(x...) printk(KERN_ERROR DEVICE_NAME ": " x)
+# define PRINT_FATAL(x...) printk(KERN_FATAL DEVICE_NAME ": " x)
+#endif
+
+/* Is the device open right now? Used to prevent concurent access into the same device */
+static int device_open = 0;
+
+static dma_addr_t vram_sharpsl_pxafb_phys;
+static void *vram_virt = NULL; /* virtual address of VRAM (if NULL, VRAM is not allocated) */
+static dma_addr_t vram_phys = 0; /* physical address of VRAM */
+static u32 vram_size = 0;	/* VRAM size */
+
+#undef FDADR
+// ----------------------------------------------------------------
+// ディスクリプタ
+// aligned on a 16-byte boundary
+
+typedef struct {
+    unsigned long FDADR;	/* frame descriptor address */
+    unsigned long FSADR;      /* DMA Frame Source Address Registers */
+    unsigned long FIDR;		/* frame id reg */
+    unsigned long LDCMD;	/* LCD command reg */
+} descriptor_t;
+
+static descriptor_t *descriptors = NULL;
+#ifndef USE_PXAFB_DESCRIPTOR_AREA
+# define MAX_DESCRIPTORS (PAGE_SIZE / 16)
+static descriptor_t *descriptor_virt; /* ディスクリプタ配列の仮想アドレス */
+static dma_addr_t descriptor_phys; /* ディスクリプタ配列の物理アドレス */
+static u32 descriptor_size;	/* ディスクリプタ配列のサイズ */
+#else
+# define MAX_DESCRIPTORS ((PAGE_SIZE - 16) / 16)
+#endif
+
+// Physical addresses, offsets & lengths
+#define	SRAM_BASE	0xfe100000
+#define	SRAM_BASE_PHYS	0x5c000000
+#define MAX_VRAM_SIZE (1024 * 4)
+static unsigned long offset2phys_map[MAX_VRAM_SIZE >> PAGE_SHIFT];
+#define OFFSET2PHYS_MAP_SRAM_INDEX 0
+
+// vram manager
+typedef struct {
+    unsigned long start_phys;
+    void *start_virt;
+    unsigned long end_phys;
+    unsigned long offset;
+} vram_area_t;
+#define MAX_VRAM_AREAS 128
+static vram_area_t vram_areas[MAX_VRAM_AREAS];
+
+// test
+static volatile unsigned int next_fbr2 = 0;
+static volatile unsigned int next_fbr3 = 0;
+static volatile unsigned int next_fbr4 = 0;
+static wait_queue_head_t fbr2_wait;
+static wait_queue_head_t fbr3_wait;
+static wait_queue_head_t fbr4_wait;
+static wait_queue_head_t wq_lcd_quick_disable_done;
+static wait_queue_head_t wq_lcd_disable_done;
+
+
+#if defined(CONFIG_SL_CCCR_CHANGE)
+extern int read_cccr(void);
+extern void write_cccr(int);
+#endif
+#if defined(CONFIG_CHANGE_CORE_VOLT)
+extern int read_vcore(void);
+extern void write_vcore(int);
+#endif
+
+// ----------------------------------------------------------------
+static void bvdd_vsync();
+
+// ----------------------------------------------------------------
+#if 1
+static void *consistent_alloc(int gfp, size_t size, dma_addr_t *dma_handle);
+static void *l_consistent_alloc2(int gfp, size_t size, dma_addr_t *dma_handle, int pte);
+static void consistent_free(void *vaddr, size_t size, dma_addr_t handle);
+#endif
+
+
+static void inttest(int irq, void *dev_id, struct pt_regs *regs)
+{
+    static int count = 0;
+    static int start = 0;
+    LCSR0_u lcsr0;
+    LCSR1_u lcsr1;
+    int st = 0;
+
+    lcsr1.val = REG_LCSR1;
+    if (lcsr1.f.EOF2 == 1) {
+	LCSR1_u v;
+/* 	if ((next_fbr2 != 0) && ((REG_FBR2 & 1) == 0)) { */
+	if ((next_fbr2 != 0)) {
+	    REG_FBR2 = next_fbr2 | 3;
+/* 	    REG_FDADR2 = next_fbr2; */
+/* 	    wake_up_interruptible(&fbr2_wait); */
+	}
+	v.val = 0;
+	v.f.EOF2 = 1;
+	REG_LCSR1 = v.val;
+    }
+    else if (lcsr1.f.EOF3 == 1) {
+	LCSR1_u v;
+/* 	if ((next_fbr3 != 0) && ((REG_FBR3 & 1) == 0)) { */
+	if ((next_fbr3 != 0)) {
+	    REG_FBR3 = next_fbr3 | 3;
+/* 	    REG_FDADR3 = next_fbr3; */
+/* 	    next_fbr3 = 0; */
+/* 	    wake_up_interruptible(&fbr3_wait); */
+	}
+	v.val = 0;
+	v.f.EOF3 = 1;
+	REG_LCSR1 = v.val;
+    }
+    else if (lcsr1.f.EOF4 == 1) {
+	LCSR1_u v;
+/* 	if ((next_fbr4 != 0) && ((REG_FBR4 & 1) == 0)) { */
+	if ((next_fbr4 != 0)) {
+	    REG_FBR4 = next_fbr4 | 3;
+/* 	    REG_FDADR4 = next_fbr4; */
+/* 	    next_fbr4 = 0; */
+/* 	    wake_up_interruptible(&fbr4_wait); */
+	}
+	v.val = 0;
+	v.f.EOF4 = 1;
+	REG_LCSR1 = v.val;
+    }
+    if (REG_LCSR1 & 0x20000) {	/* BS2 */
+	next_fbr2 = 0;
+	wake_up_interruptible(&fbr2_wait);
+	REG_LCSR1 = 0x20000;
+    }
+    if (REG_LCSR1 & 0x40000) {	/* BS3 */
+	next_fbr3 = 0;
+	wake_up_interruptible(&fbr3_wait);
+	REG_LCSR1 = 0x40000;
+    }
+    if (REG_LCSR1 & 0x80000) {	/* BS4 */
+	next_fbr4 = 0;
+	wake_up_interruptible(&fbr4_wait);
+	REG_LCSR1 = 0x80000;
+    }
+
+#if 0
+    lcsr0.val = REG_LCSR0;
+    if (lcsr0.f.QD == 1) {
+	LCSR0_u v;
+	v.val = 0;
+	v.f.QD = 1;
+	REG_LCSR0 = v.val;
+	wake_up_interruptible(&wq_lcd_quick_disable_done);
+    }
+    if (lcsr0.f.LDD == 1) {
+	LCSR0_u v;
+	v.val = 0;
+	v.f.LDD = 1;
+	REG_LCSR0 = v.val;
+	wake_up_interruptible(&wq_lcd_disable_done);
+    }
+#endif
+}
+
+static int setup_vram(int size)
+{
+    int order, i;
+    unsigned int offset = BVDD_VRAM_OFFSET_USER;
+
+    size = PAGE_ALIGN(size);
+    order = get_order(size);
+    PRINT_DEBUG("setup_vram(size=%d)\n", size);
+
+    for (i = 2; i < MAX_VRAM_AREAS - 2; ++i) {
+	vram_area_t *va = &vram_areas[i];
+	va->start_virt = NULL;
+	do {
+/* 	    if (order > 3) { */
+/* 		order --; */
+/* 		continue; */
+/* 	    } */
+	    va->start_virt = consistent_alloc(GFP_KERNEL|GFP_DMA, PAGE_SIZE << order, (dma_addr_t *)&va->start_phys);
+	    if (va->start_virt == NULL) {
+		order --;
+		if (order < 1)
+		    return -1;
+	    }
+	} while (va->start_virt == NULL);
+	va->end_phys = va->start_phys + (PAGE_SIZE << order);
+	va->offset = offset;
+	offset += PAGE_SIZE << order;
+	size -= PAGE_SIZE << order;
+	PRINT_DEBUG("  vram_area[%2d] : 0x%p, %d, 0x%p\n", i, va->start_phys, PAGE_SIZE << order, va->offset);
+	if (size <= 0)
+	    break;
+    }
+
+    if (size > 0)
+	return -1;
+    else
+	return 0;
+}
+
+static int free_vram(void)
+{
+    int i;
+    for (i = 2; i < MAX_VRAM_AREAS - 2; ++i) {
+	vram_area_t *va = &vram_areas[i];
+	if (va->start_virt != NULL) {
+	    consistent_free(va->start_virt, va->end_phys - va->start_phys, va->start_phys);
+	    memset(va, 0, sizeof(vram_area_t));
+	}
+    }
+}
+
+// ----------------------------------------------------------------
+static lcdc_state_t lcdc_state_orig;
+static lcdc_state_t lcdc_state;
+
+static void lcdc_state_read(lcdc_state_t *ls)
+{
+    ls->cken20_intmem = (CKEN & CKEN20_INTMEM) ? 1 : 0;
+    ls->lccr0.val = REG_LCCR0;
+    ls->lccr0.f.reserved1 = 0;
+    ls->lccr0.f.reserved2 = 0;
+    ls->lccr1.val = REG_LCCR1;
+    ls->lccr2.val = REG_LCCR2;
+    ls->lccr3.val = REG_LCCR3;
+    ls->lccr3.f.reserved1 = 0;
+    ls->lccr4.val = REG_LCCR4;
+    ls->lccr4.f.reserved1 = 0;
+    ls->lccr4.f.reserved2 = 0;
+    ls->ovl1c1.val = REG_OVL1C1;
+    ls->ovl1c1.f.reserved1 = 0;
+    ls->ovl1c2.val = REG_OVL1C2;
+    ls->ovl1c2.f.reserved1 = 0;
+    ls->ovl2c1.val = REG_OVL2C1;
+    ls->ovl2c1.f.reserved1 = 0;
+    ls->ovl2c2.val = REG_OVL2C2;
+    ls->ovl2c2.f.reserved1 = 0;
+    ls->fdadr0 = REG_FDADR0;
+    ls->fdadr1 = REG_FDADR1;
+    ls->fdadr2 = REG_FDADR2;
+    ls->fdadr3 = REG_FDADR3;
+    ls->fdadr4 = REG_FDADR4;
+    ls->fdadr5 = REG_FDADR5;
+    ls->fdadr6 = REG_FDADR6;
+}
+
+static void lcdc_state_write(lcdc_state_t *ls)
+{
+    int i;
+
+    ls->cken20_intmem = (CKEN & CKEN20_INTMEM) ? 1 : 0;
+    if (ls->cken20_intmem)
+	CKEN |= CKEN20_INTMEM;
+    else
+	CKEN &= ~CKEN20_INTMEM;
+
+/*     { */
+/* 	LCCR0_u v; */
+/* 	v.val = 0; */
+/* 	v.f.QDM = 1; */
+/* 	v.f.LDM = 1; */
+/* 	REG_LCCR0 &= ~v.val; */
+/*     } */
+
+    ls->lccr2.f.EFW = 64;
+    ls->lccr2.f.VSW = 64;
+    for (i = 0; i < 2; ++i) {
+	bvdd_vsync();
+	REG_LCCR0 |= 0x400;	/* Disable LCD controller */
+/* 	interruptible_sleep_on(&wq_lcd_disable_done); */
+
+	bvdd_vsync();		/* Wait for disabled */
+	REG_LCCR0 &= ~1;	/* Do a quick disable */
+
+	REG_OVL2C1 = ls->ovl2c1.val;
+	REG_OVL2C2 = ls->ovl2c2.val;
+	REG_OVL1C1 = ls->ovl1c1.val;
+	REG_OVL1C2 = ls->ovl1c2.val;
+	REG_LCCR1 = ls->lccr1.val;
+	REG_LCCR2 = ls->lccr2.val;
+	REG_LCCR3 = ls->lccr3.val;
+	REG_LCCR4 = ls->lccr4.val;
+/* 	REG_LCCR5 = 0x3F3F3F31; */
+/* 	REG_LCCR5 = 0x3F3F313F;	/\* EOF *\/ */
+	REG_LCCR5 = 0x3F31313F;	/* BSM/EOF */
+
+	REG_LCDBSCNTR = 5;
+
+	REG_LCSR0 = 0x00001FFF;
+	REG_LCSR1 = 0x3E3F3F3F;
+
+	ls->lccr0.f.ENB = 1;
+	REG_LCCR0 = ls->lccr0.val; /* Enable LCD controller */
+
+	REG_LCCR0 &= ~1;	/* Do a quick disable */
+/* 	interruptible_sleep_on(&wq_lcd_quick_disable_done); */
+
+	REG_FDADR0 = ls->fdadr0;
+	REG_FDADR1 = ls->fdadr1;
+	REG_FDADR2 = ls->fdadr2;
+	REG_FDADR3 = ls->fdadr3;
+	REG_FDADR4 = ls->fdadr4;
+	REG_FDADR5 = ls->fdadr5;
+	REG_FDADR6 = ls->fdadr6;
+
+	REG_LCCR0 = ls->lccr0.val;
+    }
+}
+
+static void lcdc_state_print_descriptor(int n, unsigned long addr)
+{
+    PRINT_DEBUG("  FDADR%d : 0x%08x         FDADR      FSADR       FIDR      LDCMD\n", n, addr);
+    if (addr == 0)
+	PRINT_DEBUG("                         ---------- ---------- ---------- ----------\n");
+    else {
+	PRINT_DEBUG("                         0x%08x 0x%08x 0x%08x 0x%08x\n",
+		    ((unsigned long *)__phys_to_virt(addr))[0],
+		    ((unsigned long *)__phys_to_virt(addr))[1],
+		    ((unsigned long *)__phys_to_virt(addr))[2],
+		    ((unsigned long *)__phys_to_virt(addr))[3]);
+    }
+}
+
+static void lcdc_state_print(lcdc_state_t *ls)
+{
+    PRINT_DEBUG("lcdc_state_print(lcdc_state_t * = 0x%p)\n", ls);
+    PRINT_DEBUG("  CKEN20_INTMEM : %d\n", ls->cken20_intmem);
+    PRINT_DEBUG("  LCCR0 : 0x%08x\n", ls->lccr0.val);
+    PRINT_DEBUG("    ENB CMS SDS LDM SOFM0 IUM EOFM0 PAS DPD DIS QDM PDD BSM0 OUM LCDT\n");
+    PRINT_DEBUG("    %3d %3d %3d %3d   %3d %3d   %3d %3d %3d %3d %3d %3d  %3d %3d  %3d\n",
+		ls->lccr0.f.ENB, ls->lccr0.f.CMS, ls->lccr0.f.SDS, ls->lccr0.f.LDM, ls->lccr0.f.SOFM0,
+		ls->lccr0.f.IUM, ls->lccr0.f.EOFM0, ls->lccr0.f.PAS, ls->lccr0.f.DPD, ls->lccr0.f.DIS,
+		ls->lccr0.f.QDM, ls->lccr0.f.PDD, ls->lccr0.f.BSM0, ls->lccr0.f.OUM, ls->lccr0.f.LCDT);
+    PRINT_DEBUG("    RDSTM CMDIM OUC LDDALT\n");
+    PRINT_DEBUG("      %3d   %3d %3d    %3d\n",
+		ls->lccr0.f.RDSTM, ls->lccr0.f.CMDIM, ls->lccr0.f.OUC, ls->lccr0.f.LDDALT);
+    PRINT_DEBUG("  LCCR1 : 0x%08x\n", ls->lccr1.val);
+    PRINT_DEBUG("     PPL HSW ELW BLW\n");
+    PRINT_DEBUG("    %4d %3d %3d %3d\n",
+		ls->lccr1.f.PPL, ls->lccr1.f.HSW, ls->lccr1.f.ELW, ls->lccr1.f.BLW);
+    PRINT_DEBUG("  LCCR2 : 0x%08x\n", ls->lccr2.val);
+    PRINT_DEBUG("     LPP VSW EFW BFW\n");
+    PRINT_DEBUG("    %4d %3d %3d %3d\n",
+		ls->lccr2.f.LPP, ls->lccr2.f.VSW, ls->lccr2.f.EFW, ls->lccr2.f.BFW);
+    PRINT_DEBUG("  LCCR3 : 0x%08x\n", ls->lccr3.val);
+    PRINT_DEBUG("    PCD ACB API VSP HSP PCP OEP BPP DPC BPP3 PDFOR\n");
+    PRINT_DEBUG("    %3d %3d %3d %3d %3d %3d %3d %3d %3d  %3d   %3d\n",
+		ls->lccr3.f.PCD, ls->lccr3.f.ACB, ls->lccr3.f.API, ls->lccr3.f.VSP,
+		ls->lccr3.f.HSP, ls->lccr3.f.PCP, ls->lccr3.f.OEP, ls->lccr3.f.BPP,
+		ls->lccr3.f.DPC, ls->lccr3.f.BPP3, ls->lccr3.f.PDFOR);
+    PRINT_DEBUG("  LCCR4 : 0x%08x\n", ls->lccr4.val);
+    PRINT_DEBUG("    K1 K2 K3 PAL_FOR PCDDIV\n");
+    PRINT_DEBUG("    %2d %2d %2d     %3d    %3d\n",
+		ls->lccr4.f.K1, ls->lccr4.f.K2, ls->lccr4.f.K3, ls->lccr4.f.PAL_FOR,
+		ls->lccr4.f.PCDDIV);
+    PRINT_DEBUG("  OVL1C1 : 0x%08x\n", ls->ovl1c1.val);
+    PRINT_DEBUG("    PPL1 LPO1 BPP1 O1EN\n");
+    PRINT_DEBUG("     %3d  %3d  %3d  %3d\n",
+		ls->ovl1c1.f.PPL1, ls->ovl1c1.f.LPO1, ls->ovl1c1.f.BPP1, ls->ovl1c1.f.O1EN);
+    PRINT_DEBUG("  OVL1C2 : 0x%08x\n", ls->ovl1c2.val);
+    PRINT_DEBUG("    O1XPOS O1YPOS\n");
+    PRINT_DEBUG("      %4d   %4d\n",
+		ls->ovl1c2.f.O1XPOS, ls->ovl1c2.f.O1YPOS);
+    PRINT_DEBUG("  OVL2C1 : 0x%08x\n", ls->ovl2c1.val);
+    PRINT_DEBUG("    PPL2 LPO2 BPP2 O2EN\n");
+    PRINT_DEBUG("     %3d  %3d  %3d  %3d\n",
+		ls->ovl2c1.f.PPL2, ls->ovl2c1.f.LPO2, ls->ovl2c1.f.BPP2, ls->ovl2c1.f.O2EN);
+    PRINT_DEBUG("  OVL2C2 : 0x%08x\n", ls->ovl2c2.val);
+    PRINT_DEBUG("    O2XPOS O2YPOS FOR\n");
+    PRINT_DEBUG("      %4d   %4d %3d\n",
+		ls->ovl2c2.f.O2XPOS, ls->ovl2c2.f.O2YPOS, ls->ovl2c2.f.FOR);
+    lcdc_state_print_descriptor(0, ls->fdadr0);
+    lcdc_state_print_descriptor(1, ls->fdadr1);
+    lcdc_state_print_descriptor(2, ls->fdadr2);
+    lcdc_state_print_descriptor(3, ls->fdadr3);
+    lcdc_state_print_descriptor(4, ls->fdadr4);
+    lcdc_state_print_descriptor(5, ls->fdadr5);
+    lcdc_state_print_descriptor(6, ls->fdadr6);
+}
+
+typedef struct {
+    unsigned int offset;
+    int size;
+    unsigned int desc_phys;
+} desc_cache_t;
+
+#define MAX_DESC_CACHE 256
+desc_cache_t desc_cache[MAX_DESC_CACHE];
+int desc_cache_index = 0;
+
+static unsigned int lcdc_set_descriptor(unsigned long offset, int size)
+{
+    descriptor_t *desc, *desc_prev = NULL, *desc_prev2, *desc_first = NULL;
+    int i, count = 0, is_first_desc = 1;
+    unsigned int desc_phys, desc_first_phys;
+    unsigned int offset_orig = offset, size_orig = size;
+
+    PRINT_DEBUG("lcdc_set_descriptor(offset=0x%08x, size=0x%08x)\n", offset, size);
+
+    for (i = 0; i < desc_cache_index; ++i) {
+	if (desc_cache[i].offset == offset && desc_cache[i].size == size)
+	    return desc_cache[i].desc_phys;
+    }
+
+    /* build descriptor */
+    while (size > 0) {
+	vram_area_t *va = NULL;
+	unsigned int alen, aoff;
+
+	desc = NULL;
+	for (i = 0; i < MAX_DESCRIPTORS; ++i) {
+	    unsigned int fdadr = *(unsigned int *)(&descriptors[i]);
+	    if (fdadr == 0) {
+		desc = &descriptors[i];
+		desc_phys = descriptor_phys + (sizeof(descriptor_t) * i);
+		break;
+	    }
+	}
+	if (desc == NULL) {
+	    // empty
+	    return 0;
+	}
+
+	for (i = 0; i < MAX_VRAM_AREAS; ++i) {
+	    va = &vram_areas[i];
+	    if (va->offset <= offset && offset < (va->offset + (va->end_phys - va->start_phys)))
+		break;
+	}
+	if (i == MAX_VRAM_AREAS) {
+	    return 0;
+	}
+
+	aoff = offset - va->offset;
+	if (is_first_desc) {
+	    alen = 4 * 1024;
+	    is_first_desc = 0;
+	} else {
+	    alen = va->end_phys - va->start_phys - aoff;
+	    if (alen > size)
+		alen = size;
+	}
+
+	desc->FDADR = desc_phys;
+	desc->FSADR = va->start_phys + aoff;
+	desc->FIDR = 0;
+	desc->LDCMD = alen;
+
+	if (desc_prev != NULL)
+	    desc_prev->FDADR = desc_phys;
+	desc_prev2 = desc_prev;
+	desc_prev = desc;
+
+	if (desc_first == NULL) {
+	    desc_first = desc;
+	    desc_first_phys = desc_phys;
+	}
+
+	size -= alen;
+	offset += alen;
+    }
+
+    /* 先頭のディスクリプタへリンクさせる */
+    desc->FDADR = desc_first_phys;
+
+    /* 末尾のディスクリプタはSOF/EOF割り込みを発生させる */
+/*     desc->LDCMD = desc->LDCMD | 0x400000; */
+/*     desc->LDCMD = desc->LDCMD | 0x200000; */
+    desc_prev2->LDCMD |= 0x200000;
+
+    desc_cache[desc_cache_index].offset = offset_orig;
+    desc_cache[desc_cache_index].size = size_orig;
+    desc_cache[desc_cache_index].desc_phys = desc_first_phys;
+    ++ desc_cache_index;	/* FIXME: buffer overflow */
+
+#if 0
+    desc = desc_first;
+    desc_phys = desc_first_phys;
+    do {
+	lcdc_state_print_descriptor(count++, desc_phys);
+	if (count >= MAX_DESCRIPTORS)
+	    break;
+	desc_prev = desc;
+	desc_phys = desc->FDADR;
+    } while (desc_prev->FDADR != desc_first_phys);
+#endif
+
+    return desc_first_phys;
+}
+
+// ----------------------------------------------------------------
+
+static int bvdd_open(struct inode *inode,
+		     struct file *file)
+{
+    int i;
+    printk(DEVICE_NAME ": bvdd_open(0x%p, 0x%p)\n", inode, file);
+
+    if (device_open)
+	return -EBUSY;
+
+    lcdc_state_read(&lcdc_state_orig);
+    lcdc_state_orig.fdadr1 = 0;
+    lcdc_state_orig.fdadr2 = 0;
+    lcdc_state_orig.fdadr3 = 0;
+    lcdc_state_orig.fdadr4 = 0;
+    lcdc_state_orig.fdadr5 = 0;
+    lcdc_state_orig.fdadr6 = 0;
+/*     lcdc_state_print(&lcdc_state_orig); */
+
+    memcpy(&lcdc_state, &lcdc_state_orig, sizeof(lcdc_state));
+    lcdc_state.cken20_intmem = 1;
+
+#ifndef USE_PXAFB_DESCRIPTOR_AREA
+    descriptor_size = PAGE_ALIGN(sizeof(descriptor_t) * MAX_DESCRIPTORS);
+    descriptors = consistent_alloc(GFP_KERNEL|GFP_DMA, descriptor_size, &descriptor_phys);
+    memset(descriptors, 0, sizeof(descriptor_t) * MAX_DESCRIPTORS);
+    printk(DEVICE_NAME ":   descriptor: virt=0x%p, phys=0x%p, size=%d\n",
+	   descriptors, descriptor_phys, descriptor_size);
+#else
+    // SHARPSL_PXAFBが確保している領域を借用する。
+    // 頭の16バイトはSLARPSL_PXAFBが使っているのでスキップする。
+    descriptors = (descriptor_t *)__phys_to_virt((lcdc_state_orig.fdadr0 + 16));
+    PRINT_DEBUG("  descriptors : phys=0x%p, virt=0x%p\n", lcdc_state_orig.fdadr0 + 16, descriptors);
+    memset(descriptors, 0, sizeof(descriptor_t) * MAX_DESCRIPTORS);
+    PRINT_DEBUG("  descriptors : 0x%p, 0x%p\n", &descriptors[0], &descriptors[1]);
+#endif
+
+    init_waitqueue_head(&fbr2_wait);
+    init_waitqueue_head(&fbr3_wait);
+    init_waitqueue_head(&fbr4_wait);
+    init_waitqueue_head(&wq_lcd_quick_disable_done);
+    init_waitqueue_head(&wq_lcd_disable_done);
+
+    next_fbr2 = 0;
+    next_fbr3 = 0;
+    next_fbr4 = 0;
+
+    request_irq(17, inttest, SA_INTERRUPT|SA_SHIRQ, "bvdd", (void *)0xDEADBEAF);
+
+    device_open++;
+
+    MOD_INC_USE_COUNT;
+
+    return 0;
+}
+
+
+static int bvdd_release(struct inode *inode,
+			struct file *file)
+{
+    PRINT_DEBUG("bvdd_release(0x%p, 0x%p)\n", inode, file);
+    PRINT_DEBUG("  ***** %d\n", REG_LCSR1 & 0x200);
+
+    free_irq(17, (void *)0xDEADBEAF);
+
+    /* restore lcdc state */
+    lcdc_state_write(&lcdc_state_orig);
+    lcdc_state_write(&lcdc_state_orig);
+
+    // free vram
+    if (vram_virt != NULL) {
+	printk(DEVICE_NAME ":  Now freeing vram.\n");
+	consistent_free(vram_virt, vram_size, vram_phys);
+	vram_virt = NULL;
+    } else {
+	printk(DEVICE_NAME ":  vram is not allocated.\n");
+    }
+    free_vram();
+
+#ifndef USE_PXAFB_DESCRIPTOR_AREA
+    // free descriptor
+    consistent_free(descriptors, descriptor_size, descriptor_phys);
+    descriptors = NULL;
+    descriptor_size = 0;
+    descriptor_phys = 0;
+#else
+    descriptors = NULL;
+#endif
+
+    // free descriptor cache
+    desc_cache_index = 0;
+
+    __asm__ __volatile__ ("mcr p15, 0, %0, c15, c1, 0" : :"r"(0));
+
+    /* We're now ready for our next caller */
+    device_open --;
+
+    MOD_DEC_USE_COUNT;
+
+    return 0;
+}
+
+#define SHARPSL_PXA_VSYNC_TIMEOUT 30000 // timeout = 30[ms] > 16.8[ms]
+//
+static void bvdd_vsync()
+{
+    int timeout = SHARPSL_PXA_VSYNC_TIMEOUT;
+
+    while(timeout > 0)
+    {
+	if ((GPLR(GPIO74_LCD_FCLK) & GPIO_bit(GPIO74_LCD_FCLK)))
+	    break;
+	udelay(1);
+	timeout--;
+    }
+    while(timeout > 0)
+    {
+	if (!(GPLR(GPIO74_LCD_FCLK) & GPIO_bit(GPIO74_LCD_FCLK)))
+	    break;
+	udelay(1);
+	timeout--;
+    }
+}
+
+static int bvdd_setup_frame(int type, bvdd_frame_t *frame_user, int is_branch)
+{
+    bvdd_frame_t frame;
+    int i;
+
+    copy_from_user(&frame, (void *)frame_user, sizeof(frame));
+
+#if 0
+    PRINT_DEBUG("bvdd_setup_frame(type=%d,bvdd_frame_t*=0x%p)\n", type, frame_user);
+    printk(DEVICE_NAME ":   bvdd_frame_t {\n");
+    printk(DEVICE_NAME ":     format=%d\n", frame.format);
+    printk(DEVICE_NAME ":     width=%d\n", frame.width);
+    printk(DEVICE_NAME ":     height=%d\n", frame.height);
+    printk(DEVICE_NAME ":     x=%d\n", frame.x);
+    printk(DEVICE_NAME ":     y=%d\n", frame.y);
+    printk(DEVICE_NAME ":     offset=0x%p\n", frame.offset);
+    printk(DEVICE_NAME ":     u_offset=0x%p\n", frame.u_offset);
+    printk(DEVICE_NAME ":     v_offset=0x%p\n", frame.v_offset);
+    printk(DEVICE_NAME ":   }\n");
+#endif
+
+    if (frame.format > 16) {
+	unsigned int desc, y_stride, uv_stride;
+
+	y_stride = (frame.width + 15) & ~15;
+	uv_stride = y_stride / 2;
+
+/* 	lcdc_state.lccr3.f.PDFOR = 3; */
+
+	lcdc_state.ovl2c1.f.O2EN = 1;
+	lcdc_state.ovl2c1.f.LPO2 = frame.height - 1;
+	lcdc_state.ovl2c1.f.PPL2 = y_stride - 1;
+	lcdc_state.ovl2c1.f.BPP2 = 0;
+	lcdc_state.ovl2c2.f.FOR = frame.format - 16;
+/* 	lcdc_state.ovl2c2.f.FOR = 4; */
+	lcdc_state.ovl2c2.f.O2XPOS = frame.x;
+	lcdc_state.ovl2c2.f.O2YPOS = frame.y;
+
+	desc = lcdc_set_descriptor(frame.offset, y_stride * frame.height);
+	if (desc == 0) {
+	    PRINT_DEBUG("  couldn't set descriptors.\n");
+	    return -1;
+	}
+	lcdc_state.fdadr2 = desc;
+
+	desc = lcdc_set_descriptor(frame.u_offset, uv_stride * (frame.height / 2));
+	if (desc == 0) {
+	    PRINT_DEBUG("  couldn't set descriptors.\n");
+	    lcdc_state.fdadr2 = 0;
+	    return -1;
+	}
+	lcdc_state.fdadr3 = desc;
+
+	desc = lcdc_set_descriptor(frame.v_offset, uv_stride * (frame.height / 2));
+	if (desc == 0) {
+	    PRINT_DEBUG("  couldn't set descriptors.\n");
+	    lcdc_state.fdadr2 = 0;
+	    lcdc_state.fdadr3 = 0;
+	    return -1;
+	}
+	lcdc_state.fdadr4 = desc;
+
+	if (is_branch) {
+/* 	    interruptible_sleep_on(&fbr2_wait); */
+/* 	    interruptible_sleep_on(&fbr3_wait); */
+/* 	    interruptible_sleep_on(&fbr4_wait); */
+	    wait_event_interruptible(fbr2_wait, (next_fbr2 == 0));
+	    wait_event_interruptible(fbr3_wait, (next_fbr3 == 0));
+	    wait_event_interruptible(fbr4_wait, (next_fbr4 == 0));
+	    disable_irq(17);
+	    next_fbr2 = lcdc_state.fdadr2;
+	    next_fbr3 = lcdc_state.fdadr3;
+	    next_fbr4 = lcdc_state.fdadr4;
+	    enable_irq(17);
+	} else {
+	    lcdc_state_print(&lcdc_state);
+	    lcdc_state_write(&lcdc_state);
+	}
+    }
+}
+
+static int bvdd_ioctl(struct inode *inode, struct file *file,
+		      unsigned int ioctl_num, unsigned long ioctl_param)
+{
+    int i;
+    char *temp;
+    char ch;
+
+    switch (ioctl_num) {
+    case BVDD_IOCTL_SETUP_VRAM: {
+	printk(DEVICE_NAME ": BVDD_IOCTL_SETUP_VRAM(0x%08x)\n", ioctl_param);
+#if 0
+	// 既にVRAMが確保されていれば解放する
+	if (vram_virt != NULL) {
+	    printk(DEVICE_NAME ":   now freeing allocated vram\n");
+	    consistent_free(vram_virt, vram_size, vram_phys);
+	}
+
+	vram_size = PAGE_ALIGN(ioctl_param + PAGE_SIZE);
+	vram_virt = consistent_alloc(GFP_KERNEL /* | GFP_DMA */, vram_size, &vram_phys);
+	if (vram_virt == NULL) {
+	    printk(DEVICE_NAME ":   consistent_alloc failed\n");
+	    return -EINVAL;
+	}
+
+	printk(DEVICE_NAME ":   vram_virt=0x%p\n", vram_virt);
+	printk(DEVICE_NAME ":   vram_phys=0x%p\n", vram_phys);
+	printk(DEVICE_NAME ":   vram_size=%d\n", vram_size);
+	vram_areas[2].start_virt = vram_virt;
+	vram_areas[2].start_phys = vram_phys;
+	vram_areas[2].end_phys = vram_phys + vram_size;
+	vram_areas[2].offset = BVDD_VRAM_OFFSET_USER;
+#endif
+	free_vram();
+	if (setup_vram(ioctl_param) < 0)
+	    return -EINVAL;
+
+	break;
+    }
+
+    case BVDD_IOCTL_SETUP_BASE_FRAME: {
+	printk(DEVICE_NAME ": BVDD_IOCTL_SETUP_BASE_FRAME(0x%08x)\n", ioctl_param);
+	break;
+    }
+    case BVDD_IOCTL_SETUP_OVERLAY1_FRAME: {
+	break;
+    }
+    case BVDD_IOCTL_SETUP_OVERLAY2_FRAME: {
+	bvdd_frame_t frame;
+	printk(DEVICE_NAME ": BVDD_IOCTL_SETUP_OVERLAY2_FRAME(0x%08x)\n", ioctl_param);
+	bvdd_setup_frame(2, (bvdd_frame_t *)ioctl_param, 0);
+	break;
+    }
+
+    case BVDD_IOCTL_BRANCH_OVERLAY2_FRAME: {
+	bvdd_frame_t frame;
+/* 	PRINT_DEBUG("BVDD_IOCTL_BRANCH_OVERLAY2_FRAME(0x%08x)\n", ioctl_param); */
+	bvdd_setup_frame(2, (bvdd_frame_t *)ioctl_param, 1);
+	break;
+    }
+
+    case BVDD_IOCTL_SET_IWMMXT_STATE: {
+	__asm__ __volatile__ ("mcr p15, 0, %0, c15, c1, 0" : :"r"(ioctl_param ? 3 : 0));
+	break;
+    }
+
+#if defined(CONFIG_SL_CCCR_CHANGE)
+    case BVDD_IOCTL_GET_CCCR: {
+      *((int *)ioctl_param) = read_cccr();
+      printk(DEVICE_NAME ": Read CCCR = %x.\n", *((int *)ioctl_param));
+      break;
+    }
+    case BVDD_IOCTL_SET_CCCR: {
+      write_cccr((int)ioctl_param);
+      printk(DEVICE_NAME ": Change CCCR = %x.\n", (int)ioctl_param);
+      break;
+    }
+#endif
+#if defined(CONFIG_CHANGE_CORE_VOLT)
+    case BVDD_IOCTL_GET_VCORE: {
+      *((int *)ioctl_param) = read_vcore();
+      printk(DEVICE_NAME ": Read VCORE = %x.\n", *((int *)ioctl_param));
+      break;
+    }
+    case BVDD_IOCTL_SET_VCORE: {
+      write_vcore((int)ioctl_param);
+      printk(DEVICE_NAME ": Change VCORE = %x.\n", (int)ioctl_param);
+      break;
+    }
+#endif
+
+    case BVDD_IOCTL_DEBUG: {
+	printk(DEVICE_NAME ": BVDD_IOCTL_DEBUG\n");
+	break;
+    }
+    }
+
+    return 0;
+}
+
+/*
+  vma->vm_start, vma->vm_end は、mmap引数がページ境界でなくともアラインされたものがこの関数に渡る。
+  vma->vm_pgoff は、mmap引数がページ境界でなければエラーになる。
+*/
+static int bvdd_mmap(struct file *file, struct vm_area_struct *vma)
+{
+    unsigned long offset = vma->vm_pgoff << PAGE_SHIFT;
+    struct page *map, *mapend;
+    int i, size;
+    unsigned long vma_start;
+
+    PRINT_DEBUG("bvdd_mmap(file=0x%p, vma=0x%p)\n", file, vma);
+
+/*     if (vram_virt == NULL) { */
+/* 	printk(DEVICE_NAME ":   vram is not allocated.\n"); */
+/* 	return -EINVAL; */
+/*     } */
+
+    printk(DEVICE_NAME ":   vm_start = 0x%p\n", (uint32_t)vma->vm_start);
+    printk(DEVICE_NAME ":   vm_end   = 0x%p\n", (uint32_t)vma->vm_end);
+    printk(DEVICE_NAME ":   vm_pgoff = 0x%p\n", (uint32_t)vma->vm_pgoff);
+    printk(DEVICE_NAME ":   vm_page_prot.pgprot = 0x%08u\n", (uint32_t)vma->vm_page_prot.pgprot);
+    printk(DEVICE_NAME ":   PAGE_OFFSET = %x\n", (int)PAGE_OFFSET);
+    printk(DEVICE_NAME ":   offset = %x\n", (int)offset);
+    printk(DEVICE_NAME ":   vram_phys = 0x%p\n", vram_phys);
+
+    if (vma->vm_pgoff > (~0UL >> PAGE_SHIFT))
+	return -EINVAL;
+
+#if 0
+    if ((vma->vm_end - vma->vm_start + offset) > vram_size) {
+	printk(DEVICE_NAME ":   mmap length is too large (vram_size=%d, len=%d\n",
+	       vram_size, vma->vm_end - vma->vm_start + offset);
+	return -EINVAL;
+    }
+#endif
+
+    // from fbmem.c
+    vma->vm_flags |= VM_IO;
+    vma->vm_page_prot = __pgprot(pgprot_val(vma->vm_page_prot) | L_PTE_CACHEABLE);
+
+#if 0
+    for (i = vma->vm_pgoff; i < vma->vm_pgoff + ((vma->vm_end - vma->vm_start) >> PAGE_SHIFT); ++i) {
+	if (offset2phys_map[i] == 0) {
+	    printk(DEVICE_NAME ":   io_remap_page_range failed.\n");
+	    return -EAGAIN;
+	}
+	if (io_remap_page_range(vma->vm_start + (i << PAGE_SHIFT),
+				offset2phys_map[i],
+				PAGE_SIZE, vma->vm_page_prot)) {
+	    printk(DEVICE_NAME ":   io_remap_page_range failed.\n");
+	    return -EAGAIN;
+	}
+    }
+#endif
+
+#if 1
+    vma_start = vma->vm_start;
+    size = vma->vm_end - vma->vm_start;
+    while (size > 0) {
+	vram_area_t *va = NULL;
+	int aoff, alen;
+
+	for (i = 0; i < MAX_VRAM_AREAS; ++i) {
+	    va = &vram_areas[i];
+	    if (va->offset <= offset && offset < va->offset + (va->end_phys - va->start_phys))
+		break;
+	}
+	if (i == MAX_VRAM_AREAS) {
+	    return -EAGAIN;
+	}
+
+	aoff = offset - va->offset;
+	alen = va->end_phys - va->start_phys - aoff;
+	if (alen > size)
+	    alen = size;
+	PRINT_DEBUG("io_remap_page_range(0x%p, 0x%p, %d)\n", vma_start, va->start_phys + aoff, alen);
+	if (io_remap_page_range(vma_start, va->start_phys + aoff, alen, vma->vm_page_prot)) {
+	    printk(DEVICE_NAME ":   io_remap_page_range failed.\n");
+	    return -EAGAIN;
+	}
+	vma_start += alen;
+	size -= alen;
+	offset += alen;
+    }
+
+    printk(DEVICE_NAME ":   successed.\n");
+    return 0;
+#endif
+}
+
+/* Module Declarations *************************** */
+
+
+/* This structure will hold the functions to be called
+ * when a process does something to the device we
+ * created. Since a pointer to this structure is kept in
+ * the devices table, it can't be local to
+ * init_module. NULL is for unimplemented functions. */
+struct file_operations fops = {
+    ioctl : bvdd_ioctl,
+    mmap : bvdd_mmap,
+    open : bvdd_open,
+    release : bvdd_release,
+};
+
+
+/* Initialize the module - Register the character device */
+int init_module()
+{
+    int i, ret;
+    unsigned long *p;
+
+    /* Register the character device (atleast try) */
+    ret = register_chrdev(BVDD_MAJOR_NUM, DEVICE_NAME, &fops);
+
+    /* Negative values signify an error */
+    if (ret < 0) {
+	printk (DEVICE_NAME ": Registering the device failed with %d\n", ret);
+	return ret;
+    }
+
+    printk (DEVICE_NAME ": Registeration is a success. \n");
+
+    /* TODO */
+/*     vram_sharpsl_pxafb_phys = ((descriptor_t *)__phys_to_virt(FDADR0))->FSADR; */
+    vram_sharpsl_pxafb_phys = (dma_addr_t)0xA3E00000UL;
+
+#if 0
+    p = offset2phys_map;
+    for (i = 0; i < ((256 * 1024) >> PAGE_SHIFT); ++i) {
+	*p++ = SRAM_BASE_PHYS + (i << PAGE_SHIFT);
+    }
+    for (i = 0; i < ((PAGE_ALIGN(640 * 480 * 2)) >> PAGE_SHIFT); ++i) {
+	*p++ = vram_sharpsl_pxafb_phys + (i << PAGE_SHIFT);
+    }
+#endif
+
+    memset(vram_areas, 0, sizeof(vram_areas));
+    vram_areas[0].start_phys = vram_sharpsl_pxafb_phys;
+    vram_areas[0].start_virt = (void *)__phys_to_virt(vram_sharpsl_pxafb_phys);
+    vram_areas[0].end_phys = vram_areas[0].start_phys + PAGE_ALIGN(480 * 640 * 2);
+    vram_areas[0].offset = 0;
+    vram_areas[1].start_phys = SRAM_BASE_PHYS;
+    vram_areas[1].start_virt = (void *)SRAM_BASE;
+    vram_areas[1].end_phys = vram_areas[1].start_phys + 256 * 1024;
+    vram_areas[1].offset = PAGE_ALIGN(480 * 640 * 2);
+
+    return 0;
+}
+
+
+/* Cleanup - unregister the appropriate file from /proc */
+void cleanup_module()
+{
+    int ret;
+
+    /* Unregister the device */
+    ret = unregister_chrdev(BVDD_MAJOR_NUM, DEVICE_NAME);
+
+    /* If there's an error, report it */
+    if (ret < 0)
+	printk(DEVICE_NAME ": Error in unregister_chrdev: %d\n", ret);
+    printk (DEVICE_NAME ": Unregisteration is a success. \n");
+}
+
+#if 1
+//////////////////////////////////////////////
+#include <linux/interrupt.h>
+
+/*
+ * This allocates one page of cache-coherent memory space and returns
+ * both the virtual and a "dma" address to that space.  It is not clear
+ * whether this could be called from an interrupt context or not.  For
+ * now, we expressly forbid it, especially as some of the stuff we do
+ * here is not interrupt context safe.
+ *
+ * We should allow this function to be called from interrupt context.
+ * However, we call ioremap, which needs to fiddle around with various
+ * things (like the vmlist_lock, and allocating page tables).  These
+ * things aren't interrupt safe (yet).
+ *
+ * Note that this does *not* zero the allocated area!
+ */
+static void *consistent_alloc(int gfp, size_t size, dma_addr_t *dma_handle)
+{
+    return l_consistent_alloc2(gfp, size, dma_handle, L_PTE_CACHEABLE);
+}
+
+static void *l_consistent_alloc2(int gfp, size_t size, dma_addr_t *dma_handle, int pte)
+{
+    struct page *page, *end, *free;
+    unsigned long order;
+    void *ret;
+
+    /* FIXME */
+    if (in_interrupt())
+	BUG();
+
+    size = PAGE_ALIGN(size);
+    order = get_order(size);
+
+    page = alloc_pages(gfp, order);
+    if (!page) {
+	printk("size:%d, order:%d\n", size, order);
+	goto no_page;
+    }
+
+    *dma_handle = page_to_bus(page);
+    //ret = __ioremap(page_to_pfn(page) << PAGE_SHIFT, size, 0);
+    ret = __ioremap(page_to_pfn(page) << PAGE_SHIFT, size, pte);
+    if (!ret) {
+	goto no_remap;
+    }
+
+#if 0 /* ioremap_does_flush_cache_all */
+    {
+	void *virt = page_address(page);
+
+	/*
+	 * we need to ensure that there are no cachelines in use, or
+	 * worse dirty in this area.  Really, we don't need to do
+	 * this since __ioremap does a flush_cache_all() anyway. --rmk
+	 */
+	invalidate_dcache_range(virt, virt + size);
+    }
+#endif
+
+    /*
+     * free wasted pages.  We skip the first page since we know
+     * that it will have count = 1 and won't require freeing.
+     * We also mark the pages in use as reserved so that
+     * remap_page_range works.
+     */
+    free = page + (size >> PAGE_SHIFT);
+    end  = page + (1 << order);
+
+    for (; page < end; page++) {
+	set_page_count(page, 1);
+	if (page >= free)
+	    __free_page(page);
+	else
+	    SetPageReserved(page);
+    }
+    return ret;
+
+ no_remap:
+    __free_pages(page, order);
+ no_page:
+    return NULL;
+}
+
+/*
+ * free a page as defined by the above mapping.  We expressly forbid
+ * calling this from interrupt context.
+ */
+static void consistent_free(void *vaddr, size_t size, dma_addr_t handle)
+{
+    struct page *page, *end;
+
+    if (in_interrupt())
+	BUG();
+
+    /*
+     * More messing around with the MM internals.  This is
+     * sick, but then so is remap_page_range().
+     */
+    size = PAGE_ALIGN(size);
+    page = virt_to_page(bus_to_virt(handle));
+    end = page + (size >> PAGE_SHIFT);
+
+    for (; page < end; page++)
+	ClearPageReserved(page);
+
+    __iounmap(vaddr);
+}
+
+#endif
+
+/*
+
+document
+
+- Do not change resolution (VGA, QVGA) while bvdd device opened. (TODO)
+- open()するときとclose()するときの解像度が同じでないといけません。
+  状態が違ったときの動作は未保証です。
+
+
+*/
diff -Nur c3000_pre/linux/drivers/video/bvdd.h c3000_work/linux/drivers/video/bvdd.h
--- c3000_pre/linux/drivers/video/bvdd.h	1970-01-01 09:00:00.000000000 +0900
+++ c3000_work/linux/drivers/video/bvdd.h	2005-02-21 23:48:01.000000000 +0900
@@ -0,0 +1,64 @@
+/*  bulverded.h - bulverde(PXA27x) display driver
+BulVerDD
+ */
+
+#ifndef CHARDEV_H
+#define CHARDEV_H
+
+#include <linux/ioctl.h>
+
+#define BVDD_VRAM_OFFSET_PXAFB (0)
+#define BVDD_VRAM_OFFSET_SRAM (480 * 640 * 2)
+#define BVDD_VRAM_OFFSET_USER (BVDD_VRAM_OFFSET_SRAM + (256 * 1024))
+
+#define BVDD_FORMAT_RGB2 1	/* 2-bits/pixel [4 entry palette] */
+#define BVDD_FORMAT_RGB4 2	/* 4-bits/pixel [16 entry palette] */
+#define BVDD_FORMAT_RGB8 3	/* 8-bits/pixel [256 entry palette] */
+#define BVDD_FORMAT_RGB16 4	/* 16-bits/pixel */
+#define BVDD_FORMAT_RGB18 5	/* 18-bits/pixel, unpacked */
+#define BVDD_FORMAT_RGB18P 6	/* 18-bits/pixel, packed */
+#define BVDD_FORMAT_RGB19 7	/* 19-bits/pixel, unpacked */
+#define BVDD_FORMAT_RGB19P 8	/* 19-bits/pixel, packed */
+#define BVDD_FORMAT_RGB24 9	/* 24-bits/pixel */
+#define BVDD_FORMAT_RGB25 10	/* 25-bits/pixel */
+#define BVDD_FORMAT_YUV444P 17	/* YCbCr4:4:4 Packed */
+#define BVDD_FORMAT_YUV444 18	/* YCbCr4:4:4 Planar */
+#define BVDD_FORMAT_YUV422 19	/* YCbCr4:2:2 Planar */
+#define BVDD_FORMAT_YUV420 20	/* YCbCr4:2:0 Planar */
+
+
+typedef struct {
+    unsigned char format;
+    unsigned short width;
+    unsigned short height;
+    unsigned short x;
+    unsigned short y;
+    unsigned long offset;	/* aligned on a 16-byte boundary */
+    unsigned long u_offset;	/* aligned on a 16-byte boundary */
+    unsigned long v_offset;	/* aligned on a 16-byte boundary */
+} bvdd_frame_t;
+
+/* The major device number. We can't rely on dynamic 
+ * registration any more, because ioctls need to know 
+ * it. */
+#define BVDD_MAJOR_NUM 240
+
+/* Set the message of the device driver */
+#define BVDD_IOCTL_SETUP_VRAM _IOR(BVDD_MAJOR_NUM, 0, uint32_t)
+#define BVDD_IOCTL_SETUP_BASE_FRAME _IOR(BVDD_MAJOR_NUM, 1, bvdd_frame_t *)
+#define BVDD_IOCTL_SETUP_OVERLAY1_FRAME _IOR(BVDD_MAJOR_NUM, 2, bvdd_frame_t *)
+#define BVDD_IOCTL_SETUP_OVERLAY2_FRAME _IOR(BVDD_MAJOR_NUM, 3, bvdd_frame_t *)
+#define BVDD_IOCTL_BRANCH_OVERLAY2_FRAME _IOR(BVDD_MAJOR_NUM, 6, bvdd_frame_t *)
+#define BVDD_IOCTL_SET_IWMMXT_STATE _IOR(BVDD_MAJOR_NUM, 7, int)
+#define BVDD_IOCTL_GET_CCCR _IOR(BVDD_MAJOR_NUM, 11, int *)
+#define BVDD_IOCTL_SET_CCCR _IOR(BVDD_MAJOR_NUM, 12, int)
+#define BVDD_IOCTL_GET_VCORE _IOR(BVDD_MAJOR_NUM, 13, int *)
+#define BVDD_IOCTL_SET_VCORE _IOR(BVDD_MAJOR_NUM, 14, int)
+
+#define BVDD_IOCTL_DEBUG _IO(BVDD_MAJOR_NUM, 10)
+
+/* The name of the device file */
+#define BVDD_DEVICE_FILE_NAME "bvdd"
+
+
+#endif
diff -Nur c3000_pre/linux/drivers/video/bvdd_p.h c3000_work/linux/drivers/video/bvdd_p.h
--- c3000_pre/linux/drivers/video/bvdd_p.h	1970-01-01 09:00:00.000000000 +0900
+++ c3000_work/linux/drivers/video/bvdd_p.h	2005-02-21 23:41:29.000000000 +0900
@@ -0,0 +1,284 @@
+#ifndef BVDD_P_INCLUDED
+#define BVDD_P_INCLUDED
+
+#include <asm/hardware.h>
+
+#define REG_LCCR0	__REG(0x44000000) /* LCD Controller Control register 0 */
+#define REG_LCCR1	__REG(0x44000004) /* LCD Controller Control register 1 */
+#define REG_LCCR2	__REG(0x44000008) /* LCD Controller Control register 2 */
+#define REG_LCCR3	__REG(0x4400000C) /* LCD Controller Control register 3 */
+#define REG_LCCR4	__REG(0x44000010) /* LCD Controller Control register 4 */
+#define REG_LCCR5	__REG(0x44000014) /* LCD Controller Control register 5 */
+#define REG_FBR0	__REG(0x44000020)
+#define REG_FBR1	__REG(0x44000024)
+#define REG_FBR2	__REG(0x44000028)
+#define REG_FBR3	__REG(0x4400002C)
+#define REG_FBR4	__REG(0x44000030)
+#define REG_LCSR1	__REG(0x44000034)
+#define REG_LCSR0	__REG(0x44000038)
+#define REG_LIIDR	__REG(0x4400003C)
+#define REG_TRGBR	__REG(0x44000040)
+#define REG_TCR		__REG(0x44000044)
+#define REG_OVL1C1	__REG(0x44000050)
+#define REG_OVL1C2	__REG(0x44000060)
+#define REG_OVL2C1	__REG(0x44000070)
+#define REG_OVL2C2	__REG(0x44000080)
+#define REG_CCR		__REG(0x44000090)
+#define REG_CMDCR	__REG(0x44000100)
+#define REG_PRSR	__REG(0x44000104)
+#define REG_FBR5	__REG(0x44000110)
+#define REG_FBR6	__REG(0x44000114)
+#define REG_FDADR0	__REG(0x44000200)
+#define REG_FSADR0	__REG(0x44000204)
+#define REG_FIDR0	__REG(0x44000208)
+#define REG_LDCMD0	__REG(0x4400020C)
+#define REG_FDADR1	__REG(0x44000210)
+#define REG_FSADR1	__REG(0x44000214)
+#define REG_FIDR1	__REG(0x44000218)
+#define REG_LDCMD1	__REG(0x4400021C)
+#define REG_FDADR2	__REG(0x44000220)
+#define REG_FSADR2	__REG(0x44000224)
+#define REG_FIDR2	__REG(0x44000228)
+#define REG_LDCMD2	__REG(0x4400022C)
+#define REG_FDADR3	__REG(0x44000230)
+#define REG_FSADR3	__REG(0x44000234)
+#define REG_FIDR3	__REG(0x44000238)
+#define REG_LDCMD3	__REG(0x4400023C)
+#define REG_FDADR4	__REG(0x44000240)
+#define REG_FSADR4	__REG(0x44000244)
+#define REG_FIDR4	__REG(0x44000248)
+#define REG_LDCMD4	__REG(0x4400024C)
+#define REG_FDADR5	__REG(0x44000250)
+#define REG_FSADR5	__REG(0x44000254)
+#define REG_FIDR5	__REG(0x44000258)
+#define REG_LDCMD5	__REG(0x4400025C)
+#define REG_FDADR6	__REG(0x44000260)
+#define REG_FSADR6	__REG(0x44000264)
+#define REG_FIDR6	__REG(0x44000268)
+#define REG_LDCMD6	__REG(0x4400026C)
+#define REG_LCDBSCNTR	__REG(0x48000054)
+
+typedef struct {
+    unsigned long ENB		: 1; /* LCD Controller Enable */
+    unsigned long CMS		: 1; /* Color/Monochrome Select */
+    unsigned long SDS		: 1; /* Single-Scan/dual-scan Display Select */
+    unsigned long LDM		: 1; /* LCD Disable Done Mask */
+    unsigned long SOFM0		: 1; /* Start of Frame Mask for Channel 0 and Channel 1 (Dual Scan) */
+    unsigned long IUM		: 1; /* Input FIFO Underrun Mask */
+    unsigned long EOFM0		: 1; /* End of Frame Mask for Channel 0 and for Channel 1 (Dual Scan) */
+    unsigned long PAS		: 1; /* Passive/Active Display Select */
+    unsigned long reserved2	: 1;
+    unsigned long DPD		: 1; /* Double-Pixel Data (DPD) Pin Mode */
+    unsigned long DIS		: 1; /* LCD Disable */
+    unsigned long QDM		: 1; /* LCD Quick Disable Mask */
+    unsigned long PDD		: 8; /* Palette DMA Request Delay */
+    unsigned long BSM0		: 1; /* Branch Status Mask */
+    unsigned long OUM		: 1; /* Output FIFO Underrun Mask */
+    unsigned long LCDT		: 1; /* LCD Panel Type */
+    unsigned long RDSTM		: 1; /* LCD Read Status Interrupt Mask */
+    unsigned long CMDIM		: 1; /* LCD Command Interrupt Mask */
+    unsigned long OUC		: 1; /* Overlay Underlay Control Bit */
+    unsigned long LDDALT	: 1; /* LDD Alternate Mapping Control Bit */
+    unsigned long reserved1     : 5;
+} LCCR0_t;
+typedef union {
+    LCCR0_t f;
+    unsigned long val;
+} LCCR0_u;
+
+typedef struct {
+    unsigned long PPL		:10; /* Pixels per Line for the Base Frame */
+    unsigned long HSW		: 6; /* Horizontal Sync Pulse Width */
+    unsigned long ELW		: 8; /* End-of-Line Pixel Clock Wait Count */
+    unsigned long BLW		: 8; /* Beginning-of-Line Pixel Clock Wait Count */
+} LCCR1_t;
+typedef union {
+    LCCR1_t f;
+    unsigned long val;
+} LCCR1_u;
+
+typedef struct {
+    unsigned long LPP		:10; /* Lines per Panel for the Base Frame */
+    unsigned long VSW		: 6; /* Vertical Sync Pulse Width */
+    unsigned long EFW		: 8; /* End-of-Frame Line Clock Wait Count */
+    unsigned long BFW		: 8; /* Beginning-of-Frame Line Clock Wait Count */
+} LCCR2_t;
+typedef union {
+    LCCR2_t f;
+    unsigned long val;
+} LCCR2_u;
+
+typedef struct {
+    unsigned long PCD		: 8; /* Pixel Clock Divisor */
+    unsigned long ACB		: 8; /* AC Bias Pin Frequency */
+    unsigned long API		: 4; /* AC Bias Pin Transitions per Interrupt */
+    unsigned long VSP		: 1; /* Vertical Sync Polarity */
+    unsigned long HSP		: 1; /* Horizontal Sync Polarity */
+    unsigned long PCP		: 1; /* Pixel Clock Polarity */
+    unsigned long OEP		: 1; /* Output Enable Polarity */
+    unsigned long BPP		: 3; /* Bits per Pixel */
+    unsigned long DPC		: 1; /* Double Pixel Clock Mode */
+    unsigned long reserved1	: 1;
+    unsigned long BPP3		: 1; /* Bits per Pixel */
+    unsigned long PDFOR		: 2; /* Pixel Data Format */
+} LCCR3_t;
+typedef union {
+    LCCR3_t f;
+    unsigned long val;
+} LCCR3_u;
+
+typedef struct {
+    unsigned long K1		: 3; /* Multiplication Constant for Red for Half Transparency */
+    unsigned long K2		: 3; /* Multiplication Constant for Blue for Half Transparency */
+    unsigned long K3		: 3; /* Multiplication Constant for Green for Half Transparency */
+    unsigned long reserved2	: 6;
+    unsigned long PAL_FOR	: 2; /* Palette Data Format */
+    unsigned long reserved1	:12;
+    unsigned long PCDDIV	: 1; /* PCD Divisor Selection */
+} LCCR4_t;
+typedef union {
+    LCCR4_t f;
+    unsigned long val;
+} LCCR4_u;
+
+/* LCCR5 unused */
+
+typedef struct {
+    unsigned long PPL1		:10; /* Pixels per Line for Overlay 1 Frame */
+    unsigned long LPO1		:10; /* Number of Lines for Overlay 1 */
+    unsigned long BPP1		: 4; /* Bits per Pixel for Overlay 1 */
+    unsigned long reserved1	: 7;
+    unsigned long O1EN		: 1; /* Enable bit for Overlay 1 */
+} OVL1C1_t;
+typedef union {
+    OVL1C1_t f;
+    unsigned long val;
+} OVL1C1_u;
+
+typedef struct {
+    unsigned long O1XPOS	:10; /* Horizontal Position of the Upper Left-Most Pixel of Overlay 1 Window */
+    unsigned long O1YPOS	:10; /* Vertical Position of the Upper Left-Most Pixel of Overlay 1 Window */
+    unsigned long reserved1	:12;
+} OVL1C2_t;
+typedef union {
+    OVL1C2_t f;
+    unsigned long val;
+} OVL1C2_u;
+
+typedef struct {
+    unsigned long PPL2		:10; /* Pixels per Line for Overlay 2 Frame */
+    unsigned long LPO2		:10; /* Number of Lines for Overlay 2 Frame */
+    unsigned long BPP2		: 4; /* Bits per Pixel for Overlay 2 */
+    unsigned long reserved1	: 7;
+    unsigned long O2EN		: 1; /* Overlay 2 Enable */
+} OVL2C1_t;
+typedef union {
+    OVL2C1_t f;
+    unsigned long val;
+} OVL2C1_u;
+
+typedef struct {
+    unsigned long O2XPOS	:10; /* Horizontal Position of the Upper Left Most Pixel of Overlay 2 */
+    unsigned long O2YPOS	:10; /* Vertical Position of the Upper Left Most Pixel of Overlay 2 */
+    unsigned long FOR		: 3; /* Format */
+    unsigned long reserved1	: 9;
+} OVL2C2_t;
+typedef union {
+    OVL2C2_t f;
+    unsigned long val;
+} OVL2C2_u;
+
+#undef BS0
+typedef struct {
+    unsigned long LDD		: 1; /* LCD Disable Done Flag */
+    unsigned long SOF0		: 1; /* Start of Frame Status for Base */
+    unsigned long BER		: 1; /* Bus Error Status */
+    unsigned long ABC		: 1; /* AC Bias Count Status */
+    unsigned long IU0		: 1; /* Input FIFO Underrun for Channel 0 */
+    unsigned long IU1		: 1; /* Input FIFO Underrun for Channel 1 */
+    unsigned long OU		: 1; /* Output FIFO Underrun */
+    unsigned long QD		: 1; /* LCD Quick Disable Status */
+    unsigned long EOF0		: 1; /* End of Frame Status for Base (Channel 0) */
+    unsigned long BS0		: 1; /* Branch Status for Base */
+    unsigned long SINT		: 1; /* Subsequent Interrupt Status */
+    unsigned long RD_ST		: 1; /* Read Status */
+    unsigned long CMD_INT	: 1; /* Command Interrupt Status */
+    unsigned long reserved2	:15;
+    unsigned long BER_CH	: 3; /* Bus Error Channel Number */
+    unsigned long reserved1	: 1;
+} LCSR0_t;
+typedef union {
+    LCSR0_t f;
+    unsigned long val;
+} LCSR0_u;
+
+#undef BS1
+typedef struct {
+    unsigned long SOF1		: 1; /* Start of Frame Status for Channel 1 */
+    unsigned long SOF2		: 1; /* Start of Frame Status for Channel 2 */
+    unsigned long SOF3		: 1; /* Start of Frame Status for Channel 3 */
+    unsigned long SOF4		: 1; /* Start of Frame Status for Channel 4 */
+    unsigned long SOF5		: 1; /* Start of Frame Status for Channel 5 */
+    unsigned long SOF6		: 1; /* Start of Frame Status for Channel 6 */
+    unsigned long reserved4	: 2;
+    unsigned long EOF1		: 1; /* End of Frame Status for Channel 1 */
+    unsigned long EOF2		: 1; /* End of Frame Status for Channel 2 */
+    unsigned long EOF3		: 1; /* End of Frame Status for Channel 3 */
+    unsigned long EOF4		: 1; /* End of Frame Status for Channel 4 */
+    unsigned long EOF5		: 1; /* End of Frame Status for Channel 5 */
+    unsigned long EOF6		: 1; /* End of Frame Status for Channel 6 */
+    unsigned long reserved3	: 2;
+    unsigned long BS1		: 1; /* Branch Status for Channel 1 (Command Register) */
+    unsigned long BS2		: 1; /* Branch Status for Channel 2 (Command Register) */
+    unsigned long BS3		: 1; /* Branch Status for Channel 3 (Command Register) */
+    unsigned long BS4		: 1; /* Branch Status for Channel 4 (Command Register) */
+    unsigned long BS5		: 1; /* Branch Status for Channel 5 (Command Register) */
+    unsigned long BS6		: 1; /* Branch Status for Channel 6 (Command Register) */
+    unsigned long reserved2	: 3;
+    unsigned long IU2		: 1; /* Input FIFO Underrun for Channel 2 */
+    unsigned long IU3		: 1; /* Input FIFO Underrun for Channel 3 */
+    unsigned long IU4		: 1; /* Input FIFO Underrun for Channel 4 */
+    unsigned long IU5		: 1; /* Input FIFO Underrun for Channel 5 */
+    unsigned long IU6		: 1; /* Input FIFO Underrun for Channel 6 */
+    unsigned long reserved1	: 2;
+} LCSR1_t;
+typedef union {
+    LCSR1_t f;
+    unsigned long val;
+} LCSR1_u;
+
+/* CCR unused */
+/* CMDCR unused */
+/* TRGBR unused */
+/* TCR unused */
+
+typedef struct {
+    unsigned long LCDBS		: 4; /* LCD Buffer Strength */
+    unsigned long reserved1	:28;
+} LCDBSCNTR_t;
+typedef union {
+    LCDBSCNTR_t f;
+    unsigned long val;
+} LCDBSCNTR_u;
+
+typedef struct {
+    LCCR0_u lccr0;
+    LCCR1_u lccr1;
+    LCCR2_u lccr2;
+    LCCR3_u lccr3;
+    LCCR4_u lccr4;
+    OVL1C1_u ovl1c1;
+    OVL1C2_u ovl1c2;
+    OVL2C1_u ovl2c1;
+    OVL2C2_u ovl2c2;
+    unsigned long fdadr0;
+    unsigned long fdadr1;
+    unsigned long fdadr2;
+    unsigned long fdadr3;
+    unsigned long fdadr4;
+    unsigned long fdadr5;
+    unsigned long fdadr6;
+    char cken20_intmem;
+} lcdc_state_t;
+
+#endif /* BVDD_P_INCLUDED */