forked from torvalds/linux
-
Notifications
You must be signed in to change notification settings - Fork 0
/
au1200fb.c
1924 lines (1665 loc) · 51.3 KB
/
au1200fb.c
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
/*
* BRIEF MODULE DESCRIPTION
* Au1200 LCD Driver.
*
* Copyright 2004-2005 AMD
* Author: AMD
*
* Based on:
* linux/drivers/video/skeletonfb.c -- Skeleton for a frame buffer device
* Created 28 Dec 1997 by Geert Uytterhoeven
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
* NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include <linux/module.h>
#include <linux/platform_device.h>
#include <linux/kernel.h>
#include <linux/errno.h>
#include <linux/string.h>
#include <linux/mm.h>
#include <linux/fb.h>
#include <linux/init.h>
#include <linux/interrupt.h>
#include <linux/ctype.h>
#include <linux/dma-mapping.h>
#include <asm/mach-au1x00/au1000.h>
#include "au1200fb.h"
#ifdef CONFIG_PM
#include <asm/mach-au1x00/au1xxx_pm.h>
#endif
#ifndef CONFIG_FB_AU1200_DEVS
#define CONFIG_FB_AU1200_DEVS 4
#endif
#define DRIVER_NAME "au1200fb"
#define DRIVER_DESC "LCD controller driver for AU1200 processors"
#define DEBUG 1
#define print_err(f, arg...) printk(KERN_ERR DRIVER_NAME ": " f "\n", ## arg)
#define print_warn(f, arg...) printk(KERN_WARNING DRIVER_NAME ": " f "\n", ## arg)
#define print_info(f, arg...) printk(KERN_INFO DRIVER_NAME ": " f "\n", ## arg)
#if DEBUG
#define print_dbg(f, arg...) printk(KERN_DEBUG __FILE__ ": " f "\n", ## arg)
#else
#define print_dbg(f, arg...) do {} while (0)
#endif
#define AU1200_LCD_FB_IOCTL 0x46FF
#define AU1200_LCD_SET_SCREEN 1
#define AU1200_LCD_GET_SCREEN 2
#define AU1200_LCD_SET_WINDOW 3
#define AU1200_LCD_GET_WINDOW 4
#define AU1200_LCD_SET_PANEL 5
#define AU1200_LCD_GET_PANEL 6
#define SCREEN_SIZE (1<< 1)
#define SCREEN_BACKCOLOR (1<< 2)
#define SCREEN_BRIGHTNESS (1<< 3)
#define SCREEN_COLORKEY (1<< 4)
#define SCREEN_MASK (1<< 5)
struct au1200_lcd_global_regs_t {
unsigned int flags;
unsigned int xsize;
unsigned int ysize;
unsigned int backcolor;
unsigned int brightness;
unsigned int colorkey;
unsigned int mask;
unsigned int panel_choice;
char panel_desc[80];
};
#define WIN_POSITION (1<< 0)
#define WIN_ALPHA_COLOR (1<< 1)
#define WIN_ALPHA_MODE (1<< 2)
#define WIN_PRIORITY (1<< 3)
#define WIN_CHANNEL (1<< 4)
#define WIN_BUFFER_FORMAT (1<< 5)
#define WIN_COLOR_ORDER (1<< 6)
#define WIN_PIXEL_ORDER (1<< 7)
#define WIN_SIZE (1<< 8)
#define WIN_COLORKEY_MODE (1<< 9)
#define WIN_DOUBLE_BUFFER_MODE (1<< 10)
#define WIN_RAM_ARRAY_MODE (1<< 11)
#define WIN_BUFFER_SCALE (1<< 12)
#define WIN_ENABLE (1<< 13)
struct au1200_lcd_window_regs_t {
unsigned int flags;
unsigned int xpos;
unsigned int ypos;
unsigned int alpha_color;
unsigned int alpha_mode;
unsigned int priority;
unsigned int channel;
unsigned int buffer_format;
unsigned int color_order;
unsigned int pixel_order;
unsigned int xsize;
unsigned int ysize;
unsigned int colorkey_mode;
unsigned int double_buffer_mode;
unsigned int ram_array_mode;
unsigned int xscale;
unsigned int yscale;
unsigned int enable;
};
struct au1200_lcd_iodata_t {
unsigned int subcmd;
struct au1200_lcd_global_regs_t global;
struct au1200_lcd_window_regs_t window;
};
#if defined(__BIG_ENDIAN)
#define LCD_CONTROL_DEFAULT_PO LCD_CONTROL_PO_11
#else
#define LCD_CONTROL_DEFAULT_PO LCD_CONTROL_PO_00
#endif
#define LCD_CONTROL_DEFAULT_SBPPF LCD_CONTROL_SBPPF_565
/* Private, per-framebuffer management information (independent of the panel itself) */
struct au1200fb_device {
struct fb_info fb_info; /* FB driver info record */
int plane;
unsigned char* fb_mem; /* FrameBuffer memory map */
unsigned int fb_len;
dma_addr_t fb_phys;
};
static struct au1200fb_device _au1200fb_devices[CONFIG_FB_AU1200_DEVS];
/********************************************************************/
/* LCD controller restrictions */
#define AU1200_LCD_MAX_XRES 1280
#define AU1200_LCD_MAX_YRES 1024
#define AU1200_LCD_MAX_BPP 32
#define AU1200_LCD_MAX_CLK 96000000 /* fixme: this needs to go away ? */
#define AU1200_LCD_NBR_PALETTE_ENTRIES 256
/* Default number of visible screen buffer to allocate */
#define AU1200FB_NBR_VIDEO_BUFFERS 1
/********************************************************************/
static struct au1200_lcd *lcd = (struct au1200_lcd *) AU1200_LCD_ADDR;
static int window_index = 2; /* default is zero */
static int panel_index = 2; /* default is zero */
static struct window_settings *win;
static struct panel_settings *panel;
static int noblanking = 1;
static int nohwcursor = 0;
struct window_settings {
unsigned char name[64];
uint32 mode_backcolor;
uint32 mode_colorkey;
uint32 mode_colorkeymsk;
struct {
int xres;
int yres;
int xpos;
int ypos;
uint32 mode_winctrl1; /* winctrl1[FRM,CCO,PO,PIPE] */
uint32 mode_winenable;
} w[4];
};
#if defined(__BIG_ENDIAN)
#define LCD_WINCTRL1_PO_16BPP LCD_WINCTRL1_PO_00
#else
#define LCD_WINCTRL1_PO_16BPP LCD_WINCTRL1_PO_01
#endif
extern int board_au1200fb_panel_init (void);
extern int board_au1200fb_panel_shutdown (void);
#ifdef CONFIG_PM
int au1200fb_pm_callback(au1xxx_power_dev_t *dev,
au1xxx_request_t request, void *data);
au1xxx_power_dev_t *LCD_pm_dev;
#endif
/*
* Default window configurations
*/
static struct window_settings windows[] = {
{ /* Index 0 */
"0-FS gfx, 1-video, 2-ovly gfx, 3-ovly gfx",
/* mode_backcolor */ 0x006600ff,
/* mode_colorkey,msk*/ 0, 0,
{
{
/* xres, yres, xpos, ypos */ 0, 0, 0, 0,
/* mode_winctrl1 */ LCD_WINCTRL1_FRM_16BPP565 |
LCD_WINCTRL1_PO_16BPP,
/* mode_winenable*/ LCD_WINENABLE_WEN0,
},
{
/* xres, yres, xpos, ypos */ 100, 100, 100, 100,
/* mode_winctrl1 */ LCD_WINCTRL1_FRM_16BPP565 |
LCD_WINCTRL1_PO_16BPP |
LCD_WINCTRL1_PIPE,
/* mode_winenable*/ LCD_WINENABLE_WEN1,
},
{
/* xres, yres, xpos, ypos */ 0, 0, 0, 0,
/* mode_winctrl1 */ LCD_WINCTRL1_FRM_16BPP565 |
LCD_WINCTRL1_PO_16BPP,
/* mode_winenable*/ 0,
},
{
/* xres, yres, xpos, ypos */ 0, 0, 0, 0,
/* mode_winctrl1 */ LCD_WINCTRL1_FRM_16BPP565 |
LCD_WINCTRL1_PO_16BPP |
LCD_WINCTRL1_PIPE,
/* mode_winenable*/ 0,
},
},
},
{ /* Index 1 */
"0-FS gfx, 1-video, 2-ovly gfx, 3-ovly gfx",
/* mode_backcolor */ 0x006600ff,
/* mode_colorkey,msk*/ 0, 0,
{
{
/* xres, yres, xpos, ypos */ 320, 240, 5, 5,
/* mode_winctrl1 */ LCD_WINCTRL1_FRM_24BPP |
LCD_WINCTRL1_PO_00,
/* mode_winenable*/ LCD_WINENABLE_WEN0,
},
{
/* xres, yres, xpos, ypos */ 0, 0, 0, 0,
/* mode_winctrl1 */ LCD_WINCTRL1_FRM_16BPP565
| LCD_WINCTRL1_PO_16BPP,
/* mode_winenable*/ 0,
},
{
/* xres, yres, xpos, ypos */ 100, 100, 0, 0,
/* mode_winctrl1 */ LCD_WINCTRL1_FRM_16BPP565 |
LCD_WINCTRL1_PO_16BPP |
LCD_WINCTRL1_PIPE,
/* mode_winenable*/ 0/*LCD_WINENABLE_WEN2*/,
},
{
/* xres, yres, xpos, ypos */ 200, 25, 0, 0,
/* mode_winctrl1 */ LCD_WINCTRL1_FRM_16BPP565 |
LCD_WINCTRL1_PO_16BPP |
LCD_WINCTRL1_PIPE,
/* mode_winenable*/ 0,
},
},
},
{ /* Index 2 */
"0-FS gfx, 1-video, 2-ovly gfx, 3-ovly gfx",
/* mode_backcolor */ 0x006600ff,
/* mode_colorkey,msk*/ 0, 0,
{
{
/* xres, yres, xpos, ypos */ 0, 0, 0, 0,
/* mode_winctrl1 */ LCD_WINCTRL1_FRM_16BPP565 |
LCD_WINCTRL1_PO_16BPP,
/* mode_winenable*/ LCD_WINENABLE_WEN0,
},
{
/* xres, yres, xpos, ypos */ 0, 0, 0, 0,
/* mode_winctrl1 */ LCD_WINCTRL1_FRM_16BPP565 |
LCD_WINCTRL1_PO_16BPP,
/* mode_winenable*/ 0,
},
{
/* xres, yres, xpos, ypos */ 0, 0, 0, 0,
/* mode_winctrl1 */ LCD_WINCTRL1_FRM_32BPP |
LCD_WINCTRL1_PO_00|LCD_WINCTRL1_PIPE,
/* mode_winenable*/ 0/*LCD_WINENABLE_WEN2*/,
},
{
/* xres, yres, xpos, ypos */ 0, 0, 0, 0,
/* mode_winctrl1 */ LCD_WINCTRL1_FRM_16BPP565 |
LCD_WINCTRL1_PO_16BPP |
LCD_WINCTRL1_PIPE,
/* mode_winenable*/ 0,
},
},
},
/* Need VGA 640 @ 24bpp, @ 32bpp */
/* Need VGA 800 @ 24bpp, @ 32bpp */
/* Need VGA 1024 @ 24bpp, @ 32bpp */
};
/*
* Controller configurations for various panels.
*/
struct panel_settings
{
const char name[25]; /* Full name <vendor>_<model> */
struct fb_monspecs monspecs; /* FB monitor specs */
/* panel timings */
uint32 mode_screen;
uint32 mode_horztiming;
uint32 mode_verttiming;
uint32 mode_clkcontrol;
uint32 mode_pwmdiv;
uint32 mode_pwmhi;
uint32 mode_outmask;
uint32 mode_fifoctrl;
uint32 mode_toyclksrc;
uint32 mode_backlight;
uint32 mode_auxpll;
int (*device_init)(void);
int (*device_shutdown)(void);
#define Xres min_xres
#define Yres min_yres
u32 min_xres; /* Minimum horizontal resolution */
u32 max_xres; /* Maximum horizontal resolution */
u32 min_yres; /* Minimum vertical resolution */
u32 max_yres; /* Maximum vertical resolution */
};
/********************************************************************/
/* fixme: Maybe a modedb for the CRT ? otherwise panels should be as-is */
/* List of panels known to work with the AU1200 LCD controller.
* To add a new panel, enter the same specifications as the
* Generic_TFT one, and MAKE SURE that it doesn't conflicts
* with the controller restrictions. Restrictions are:
*
* STN color panels: max_bpp <= 12
* STN mono panels: max_bpp <= 4
* TFT panels: max_bpp <= 16
* max_xres <= 800
* max_yres <= 600
*/
static struct panel_settings known_lcd_panels[] =
{
[0] = { /* QVGA 320x240 H:33.3kHz V:110Hz */
.name = "QVGA_320x240",
.monspecs = {
.modedb = NULL,
.modedb_len = 0,
.hfmin = 30000,
.hfmax = 70000,
.vfmin = 60,
.vfmax = 60,
.dclkmin = 6000000,
.dclkmax = 28000000,
.input = FB_DISP_RGB,
},
.mode_screen = LCD_SCREEN_SX_N(320) |
LCD_SCREEN_SY_N(240),
.mode_horztiming = 0x00c4623b,
.mode_verttiming = 0x00502814,
.mode_clkcontrol = 0x00020002, /* /4=24Mhz */
.mode_pwmdiv = 0x00000000,
.mode_pwmhi = 0x00000000,
.mode_outmask = 0x00FFFFFF,
.mode_fifoctrl = 0x2f2f2f2f,
.mode_toyclksrc = 0x00000004, /* AUXPLL directly */
.mode_backlight = 0x00000000,
.mode_auxpll = 8, /* 96MHz AUXPLL */
.device_init = NULL,
.device_shutdown = NULL,
320, 320,
240, 240,
},
[1] = { /* VGA 640x480 H:30.3kHz V:58Hz */
.name = "VGA_640x480",
.monspecs = {
.modedb = NULL,
.modedb_len = 0,
.hfmin = 30000,
.hfmax = 70000,
.vfmin = 60,
.vfmax = 60,
.dclkmin = 6000000,
.dclkmax = 28000000,
.input = FB_DISP_RGB,
},
.mode_screen = 0x13f9df80,
.mode_horztiming = 0x003c5859,
.mode_verttiming = 0x00741201,
.mode_clkcontrol = 0x00020001, /* /4=24Mhz */
.mode_pwmdiv = 0x00000000,
.mode_pwmhi = 0x00000000,
.mode_outmask = 0x00FFFFFF,
.mode_fifoctrl = 0x2f2f2f2f,
.mode_toyclksrc = 0x00000004, /* AUXPLL directly */
.mode_backlight = 0x00000000,
.mode_auxpll = 8, /* 96MHz AUXPLL */
.device_init = NULL,
.device_shutdown = NULL,
640, 480,
640, 480,
},
[2] = { /* SVGA 800x600 H:46.1kHz V:69Hz */
.name = "SVGA_800x600",
.monspecs = {
.modedb = NULL,
.modedb_len = 0,
.hfmin = 30000,
.hfmax = 70000,
.vfmin = 60,
.vfmax = 60,
.dclkmin = 6000000,
.dclkmax = 28000000,
.input = FB_DISP_RGB,
},
.mode_screen = 0x18fa5780,
.mode_horztiming = 0x00dc7e77,
.mode_verttiming = 0x00584805,
.mode_clkcontrol = 0x00020000, /* /2=48Mhz */
.mode_pwmdiv = 0x00000000,
.mode_pwmhi = 0x00000000,
.mode_outmask = 0x00FFFFFF,
.mode_fifoctrl = 0x2f2f2f2f,
.mode_toyclksrc = 0x00000004, /* AUXPLL directly */
.mode_backlight = 0x00000000,
.mode_auxpll = 8, /* 96MHz AUXPLL */
.device_init = NULL,
.device_shutdown = NULL,
800, 800,
600, 600,
},
[3] = { /* XVGA 1024x768 H:56.2kHz V:70Hz */
.name = "XVGA_1024x768",
.monspecs = {
.modedb = NULL,
.modedb_len = 0,
.hfmin = 30000,
.hfmax = 70000,
.vfmin = 60,
.vfmax = 60,
.dclkmin = 6000000,
.dclkmax = 28000000,
.input = FB_DISP_RGB,
},
.mode_screen = 0x1ffaff80,
.mode_horztiming = 0x007d0e57,
.mode_verttiming = 0x00740a01,
.mode_clkcontrol = 0x000A0000, /* /1 */
.mode_pwmdiv = 0x00000000,
.mode_pwmhi = 0x00000000,
.mode_outmask = 0x00FFFFFF,
.mode_fifoctrl = 0x2f2f2f2f,
.mode_toyclksrc = 0x00000004, /* AUXPLL directly */
.mode_backlight = 0x00000000,
.mode_auxpll = 6, /* 72MHz AUXPLL */
.device_init = NULL,
.device_shutdown = NULL,
1024, 1024,
768, 768,
},
[4] = { /* XVGA XVGA 1280x1024 H:68.5kHz V:65Hz */
.name = "XVGA_1280x1024",
.monspecs = {
.modedb = NULL,
.modedb_len = 0,
.hfmin = 30000,
.hfmax = 70000,
.vfmin = 60,
.vfmax = 60,
.dclkmin = 6000000,
.dclkmax = 28000000,
.input = FB_DISP_RGB,
},
.mode_screen = 0x27fbff80,
.mode_horztiming = 0x00cdb2c7,
.mode_verttiming = 0x00600002,
.mode_clkcontrol = 0x000A0000, /* /1 */
.mode_pwmdiv = 0x00000000,
.mode_pwmhi = 0x00000000,
.mode_outmask = 0x00FFFFFF,
.mode_fifoctrl = 0x2f2f2f2f,
.mode_toyclksrc = 0x00000004, /* AUXPLL directly */
.mode_backlight = 0x00000000,
.mode_auxpll = 10, /* 120MHz AUXPLL */
.device_init = NULL,
.device_shutdown = NULL,
1280, 1280,
1024, 1024,
},
[5] = { /* Samsung 1024x768 TFT */
.name = "Samsung_1024x768_TFT",
.monspecs = {
.modedb = NULL,
.modedb_len = 0,
.hfmin = 30000,
.hfmax = 70000,
.vfmin = 60,
.vfmax = 60,
.dclkmin = 6000000,
.dclkmax = 28000000,
.input = FB_DISP_RGB,
},
.mode_screen = 0x1ffaff80,
.mode_horztiming = 0x018cc677,
.mode_verttiming = 0x00241217,
.mode_clkcontrol = 0x00000000, /* SCB 0x1 /4=24Mhz */
.mode_pwmdiv = 0x8000063f, /* SCB 0x0 */
.mode_pwmhi = 0x03400000, /* SCB 0x0 */
.mode_outmask = 0x00FFFFFF,
.mode_fifoctrl = 0x2f2f2f2f,
.mode_toyclksrc = 0x00000004, /* AUXPLL directly */
.mode_backlight = 0x00000000,
.mode_auxpll = 8, /* 96MHz AUXPLL */
.device_init = board_au1200fb_panel_init,
.device_shutdown = board_au1200fb_panel_shutdown,
1024, 1024,
768, 768,
},
[6] = { /* Toshiba 640x480 TFT */
.name = "Toshiba_640x480_TFT",
.monspecs = {
.modedb = NULL,
.modedb_len = 0,
.hfmin = 30000,
.hfmax = 70000,
.vfmin = 60,
.vfmax = 60,
.dclkmin = 6000000,
.dclkmax = 28000000,
.input = FB_DISP_RGB,
},
.mode_screen = LCD_SCREEN_SX_N(640) |
LCD_SCREEN_SY_N(480),
.mode_horztiming = LCD_HORZTIMING_HPW_N(96) |
LCD_HORZTIMING_HND1_N(13) | LCD_HORZTIMING_HND2_N(51),
.mode_verttiming = LCD_VERTTIMING_VPW_N(2) |
LCD_VERTTIMING_VND1_N(11) | LCD_VERTTIMING_VND2_N(32),
.mode_clkcontrol = 0x00000000, /* /4=24Mhz */
.mode_pwmdiv = 0x8000063f,
.mode_pwmhi = 0x03400000,
.mode_outmask = 0x00fcfcfc,
.mode_fifoctrl = 0x2f2f2f2f,
.mode_toyclksrc = 0x00000004, /* AUXPLL directly */
.mode_backlight = 0x00000000,
.mode_auxpll = 8, /* 96MHz AUXPLL */
.device_init = board_au1200fb_panel_init,
.device_shutdown = board_au1200fb_panel_shutdown,
640, 480,
640, 480,
},
[7] = { /* Sharp 320x240 TFT */
.name = "Sharp_320x240_TFT",
.monspecs = {
.modedb = NULL,
.modedb_len = 0,
.hfmin = 12500,
.hfmax = 20000,
.vfmin = 38,
.vfmax = 81,
.dclkmin = 4500000,
.dclkmax = 6800000,
.input = FB_DISP_RGB,
},
.mode_screen = LCD_SCREEN_SX_N(320) |
LCD_SCREEN_SY_N(240),
.mode_horztiming = LCD_HORZTIMING_HPW_N(60) |
LCD_HORZTIMING_HND1_N(13) | LCD_HORZTIMING_HND2_N(2),
.mode_verttiming = LCD_VERTTIMING_VPW_N(2) |
LCD_VERTTIMING_VND1_N(2) | LCD_VERTTIMING_VND2_N(5),
.mode_clkcontrol = LCD_CLKCONTROL_PCD_N(7), /*16=6Mhz*/
.mode_pwmdiv = 0x8000063f,
.mode_pwmhi = 0x03400000,
.mode_outmask = 0x00fcfcfc,
.mode_fifoctrl = 0x2f2f2f2f,
.mode_toyclksrc = 0x00000004, /* AUXPLL directly */
.mode_backlight = 0x00000000,
.mode_auxpll = 8, /* 96MHz AUXPLL */
.device_init = board_au1200fb_panel_init,
.device_shutdown = board_au1200fb_panel_shutdown,
320, 320,
240, 240,
},
[8] = { /* Toppoly TD070WGCB2 7" 856x480 TFT */
.name = "Toppoly_TD070WGCB2",
.monspecs = {
.modedb = NULL,
.modedb_len = 0,
.hfmin = 30000,
.hfmax = 70000,
.vfmin = 60,
.vfmax = 60,
.dclkmin = 6000000,
.dclkmax = 28000000,
.input = FB_DISP_RGB,
},
.mode_screen = LCD_SCREEN_SX_N(856) |
LCD_SCREEN_SY_N(480),
.mode_horztiming = LCD_HORZTIMING_HND2_N(43) |
LCD_HORZTIMING_HND1_N(43) | LCD_HORZTIMING_HPW_N(114),
.mode_verttiming = LCD_VERTTIMING_VND2_N(20) |
LCD_VERTTIMING_VND1_N(21) | LCD_VERTTIMING_VPW_N(4),
.mode_clkcontrol = 0x00020001, /* /4=24Mhz */
.mode_pwmdiv = 0x8000063f,
.mode_pwmhi = 0x03400000,
.mode_outmask = 0x00fcfcfc,
.mode_fifoctrl = 0x2f2f2f2f,
.mode_toyclksrc = 0x00000004, /* AUXPLL directly */
.mode_backlight = 0x00000000,
.mode_auxpll = 8, /* 96MHz AUXPLL */
.device_init = board_au1200fb_panel_init,
.device_shutdown = board_au1200fb_panel_shutdown,
856, 856,
480, 480,
},
};
#define NUM_PANELS (ARRAY_SIZE(known_lcd_panels))
/********************************************************************/
#ifdef CONFIG_PM
static int set_brightness(unsigned int brightness)
{
unsigned int hi1, divider;
/* limit brightness pwm duty to >= 30/1600 */
if (brightness < 30) {
brightness = 30;
}
divider = (lcd->pwmdiv & 0x3FFFF) + 1;
hi1 = (lcd->pwmhi >> 16) + 1;
hi1 = (((brightness & 0xFF) + 1) * divider >> 8);
lcd->pwmhi &= 0xFFFF;
lcd->pwmhi |= (hi1 << 16);
return brightness;
}
#endif /* CONFIG_PM */
static int winbpp (unsigned int winctrl1)
{
int bits = 0;
/* how many bits are needed for each pixel format */
switch (winctrl1 & LCD_WINCTRL1_FRM) {
case LCD_WINCTRL1_FRM_1BPP:
bits = 1;
break;
case LCD_WINCTRL1_FRM_2BPP:
bits = 2;
break;
case LCD_WINCTRL1_FRM_4BPP:
bits = 4;
break;
case LCD_WINCTRL1_FRM_8BPP:
bits = 8;
break;
case LCD_WINCTRL1_FRM_12BPP:
case LCD_WINCTRL1_FRM_16BPP655:
case LCD_WINCTRL1_FRM_16BPP565:
case LCD_WINCTRL1_FRM_16BPP556:
case LCD_WINCTRL1_FRM_16BPPI1555:
case LCD_WINCTRL1_FRM_16BPPI5551:
case LCD_WINCTRL1_FRM_16BPPA1555:
case LCD_WINCTRL1_FRM_16BPPA5551:
bits = 16;
break;
case LCD_WINCTRL1_FRM_24BPP:
case LCD_WINCTRL1_FRM_32BPP:
bits = 32;
break;
}
return bits;
}
static int fbinfo2index (struct fb_info *fb_info)
{
int i;
for (i = 0; i < CONFIG_FB_AU1200_DEVS; ++i) {
if (fb_info == (struct fb_info *)(&_au1200fb_devices[i].fb_info))
return i;
}
printk("au1200fb: ERROR: fbinfo2index failed!\n");
return -1;
}
static int au1200_setlocation (struct au1200fb_device *fbdev, int plane,
int xpos, int ypos)
{
uint32 winctrl0, winctrl1, winenable, fb_offset = 0;
int xsz, ysz;
/* FIX!!! NOT CHECKING FOR COMPLETE OFFSCREEN YET */
winctrl0 = lcd->window[plane].winctrl0;
winctrl1 = lcd->window[plane].winctrl1;
winctrl0 &= (LCD_WINCTRL0_A | LCD_WINCTRL0_AEN);
winctrl1 &= ~(LCD_WINCTRL1_SZX | LCD_WINCTRL1_SZY);
/* Check for off-screen adjustments */
xsz = win->w[plane].xres;
ysz = win->w[plane].yres;
if ((xpos + win->w[plane].xres) > panel->Xres) {
/* Off-screen to the right */
xsz = panel->Xres - xpos; /* off by 1 ??? */
/*printk("off screen right\n");*/
}
if ((ypos + win->w[plane].yres) > panel->Yres) {
/* Off-screen to the bottom */
ysz = panel->Yres - ypos; /* off by 1 ??? */
/*printk("off screen bottom\n");*/
}
if (xpos < 0) {
/* Off-screen to the left */
xsz = win->w[plane].xres + xpos;
fb_offset += (((0 - xpos) * winbpp(lcd->window[plane].winctrl1))/8);
xpos = 0;
/*printk("off screen left\n");*/
}
if (ypos < 0) {
/* Off-screen to the top */
ysz = win->w[plane].yres + ypos;
/* fixme: fb_offset += ((0-ypos)*fb_pars[plane].line_length); */
ypos = 0;
/*printk("off screen top\n");*/
}
/* record settings */
win->w[plane].xpos = xpos;
win->w[plane].ypos = ypos;
xsz -= 1;
ysz -= 1;
winctrl0 |= (xpos << 21);
winctrl0 |= (ypos << 10);
winctrl1 |= (xsz << 11);
winctrl1 |= (ysz << 0);
/* Disable the window while making changes, then restore WINEN */
winenable = lcd->winenable & (1 << plane);
au_sync();
lcd->winenable &= ~(1 << plane);
lcd->window[plane].winctrl0 = winctrl0;
lcd->window[plane].winctrl1 = winctrl1;
lcd->window[plane].winbuf0 =
lcd->window[plane].winbuf1 = fbdev->fb_phys;
lcd->window[plane].winbufctrl = 0; /* select winbuf0 */
lcd->winenable |= winenable;
au_sync();
return 0;
}
static void au1200_setpanel (struct panel_settings *newpanel)
{
/*
* Perform global setup/init of LCD controller
*/
uint32 winenable;
/* Make sure all windows disabled */
winenable = lcd->winenable;
lcd->winenable = 0;
au_sync();
/*
* Ensure everything is disabled before reconfiguring
*/
if (lcd->screen & LCD_SCREEN_SEN) {
/* Wait for vertical sync period */
lcd->intstatus = LCD_INT_SS;
while ((lcd->intstatus & LCD_INT_SS) == 0) {
au_sync();
}
lcd->screen &= ~LCD_SCREEN_SEN; /*disable the controller*/
do {
lcd->intstatus = lcd->intstatus; /*clear interrupts*/
au_sync();
/*wait for controller to shut down*/
} while ((lcd->intstatus & LCD_INT_SD) == 0);
/* Call shutdown of current panel (if up) */
/* this must occur last, because if an external clock is driving
the controller, the clock cannot be turned off before first
shutting down the controller.
*/
if (panel->device_shutdown != NULL)
panel->device_shutdown();
}
/* Newpanel == NULL indicates a shutdown operation only */
if (newpanel == NULL)
return;
panel = newpanel;
printk("Panel(%s), %dx%d\n", panel->name, panel->Xres, panel->Yres);
/*
* Setup clocking if internal LCD clock source (assumes sys_auxpll valid)
*/
if (!(panel->mode_clkcontrol & LCD_CLKCONTROL_EXT))
{
uint32 sys_clksrc;
au_writel(panel->mode_auxpll, SYS_AUXPLL);
sys_clksrc = au_readl(SYS_CLKSRC) & ~0x0000001f;
sys_clksrc |= panel->mode_toyclksrc;
au_writel(sys_clksrc, SYS_CLKSRC);
}
/*
* Configure panel timings
*/
lcd->screen = panel->mode_screen;
lcd->horztiming = panel->mode_horztiming;
lcd->verttiming = panel->mode_verttiming;
lcd->clkcontrol = panel->mode_clkcontrol;
lcd->pwmdiv = panel->mode_pwmdiv;
lcd->pwmhi = panel->mode_pwmhi;
lcd->outmask = panel->mode_outmask;
lcd->fifoctrl = panel->mode_fifoctrl;
au_sync();
/* fixme: Check window settings to make sure still valid
* for new geometry */
#if 0
au1200_setlocation(fbdev, 0, win->w[0].xpos, win->w[0].ypos);
au1200_setlocation(fbdev, 1, win->w[1].xpos, win->w[1].ypos);
au1200_setlocation(fbdev, 2, win->w[2].xpos, win->w[2].ypos);
au1200_setlocation(fbdev, 3, win->w[3].xpos, win->w[3].ypos);
#endif
lcd->winenable = winenable;
/*
* Re-enable screen now that it is configured
*/
lcd->screen |= LCD_SCREEN_SEN;
au_sync();
/* Call init of panel */
if (panel->device_init != NULL) panel->device_init();
/* FIX!!!! not appropriate on panel change!!! Global setup/init */
lcd->intenable = 0;
lcd->intstatus = ~0;
lcd->backcolor = win->mode_backcolor;
/* Setup Color Key - FIX!!! */
lcd->colorkey = win->mode_colorkey;
lcd->colorkeymsk = win->mode_colorkeymsk;
/* Setup HWCursor - FIX!!! Need to support this eventually */
lcd->hwc.cursorctrl = 0;
lcd->hwc.cursorpos = 0;
lcd->hwc.cursorcolor0 = 0;
lcd->hwc.cursorcolor1 = 0;
lcd->hwc.cursorcolor2 = 0;
lcd->hwc.cursorcolor3 = 0;
#if 0
#define D(X) printk("%25s: %08X\n", #X, X)
D(lcd->screen);
D(lcd->horztiming);
D(lcd->verttiming);
D(lcd->clkcontrol);
D(lcd->pwmdiv);
D(lcd->pwmhi);
D(lcd->outmask);
D(lcd->fifoctrl);
D(lcd->window[0].winctrl0);
D(lcd->window[0].winctrl1);
D(lcd->window[0].winctrl2);
D(lcd->window[0].winbuf0);
D(lcd->window[0].winbuf1);
D(lcd->window[0].winbufctrl);
D(lcd->window[1].winctrl0);
D(lcd->window[1].winctrl1);
D(lcd->window[1].winctrl2);
D(lcd->window[1].winbuf0);
D(lcd->window[1].winbuf1);
D(lcd->window[1].winbufctrl);
D(lcd->window[2].winctrl0);
D(lcd->window[2].winctrl1);
D(lcd->window[2].winctrl2);
D(lcd->window[2].winbuf0);
D(lcd->window[2].winbuf1);
D(lcd->window[2].winbufctrl);
D(lcd->window[3].winctrl0);
D(lcd->window[3].winctrl1);
D(lcd->window[3].winctrl2);
D(lcd->window[3].winbuf0);
D(lcd->window[3].winbuf1);
D(lcd->window[3].winbufctrl);
D(lcd->winenable);
D(lcd->intenable);
D(lcd->intstatus);
D(lcd->backcolor);
D(lcd->winenable);
D(lcd->colorkey);
D(lcd->colorkeymsk);
D(lcd->hwc.cursorctrl);
D(lcd->hwc.cursorpos);
D(lcd->hwc.cursorcolor0);
D(lcd->hwc.cursorcolor1);
D(lcd->hwc.cursorcolor2);
D(lcd->hwc.cursorcolor3);
#endif
}
static void au1200_setmode(struct au1200fb_device *fbdev)
{
int plane = fbdev->plane;
/* Window/plane setup */
lcd->window[plane].winctrl1 = ( 0
| LCD_WINCTRL1_PRI_N(plane)
| win->w[plane].mode_winctrl1 /* FRM,CCO,PO,PIPE */
) ;
au1200_setlocation(fbdev, plane, win->w[plane].xpos, win->w[plane].ypos);
lcd->window[plane].winctrl2 = ( 0
| LCD_WINCTRL2_CKMODE_00
| LCD_WINCTRL2_DBM
| LCD_WINCTRL2_BX_N( fbdev->fb_info.fix.line_length)
| LCD_WINCTRL2_SCX_1
| LCD_WINCTRL2_SCY_1
) ;
lcd->winenable |= win->w[plane].mode_winenable;
au_sync();
}
/* Inline helpers */
/*#define panel_is_dual(panel) ((panel->mode_screen & LCD_SCREEN_PT) == LCD_SCREEN_PT_010)*/
/*#define panel_is_active(panel)((panel->mode_screen & LCD_SCREEN_PT) == LCD_SCREEN_PT_010)*/
#define panel_is_color(panel) ((panel->mode_screen & LCD_SCREEN_PT) <= LCD_SCREEN_PT_CDSTN)
/* Bitfields format supported by the controller. */
static struct fb_bitfield rgb_bitfields[][4] = {
/* Red, Green, Blue, Transp */
[LCD_WINCTRL1_FRM_16BPP655 >> 25] =
{ { 10, 6, 0 }, { 5, 5, 0 }, { 0, 5, 0 }, { 0, 0, 0 } },
[LCD_WINCTRL1_FRM_16BPP565 >> 25] =
{ { 11, 5, 0 }, { 5, 6, 0 }, { 0, 5, 0 }, { 0, 0, 0 } },
[LCD_WINCTRL1_FRM_16BPP556 >> 25] =
{ { 11, 5, 0 }, { 6, 5, 0 }, { 0, 6, 0 }, { 0, 0, 0 } },
[LCD_WINCTRL1_FRM_16BPPI1555 >> 25] =
{ { 10, 5, 0 }, { 5, 5, 0 }, { 0, 5, 0 }, { 0, 0, 0 } },
[LCD_WINCTRL1_FRM_16BPPI5551 >> 25] =
{ { 11, 5, 0 }, { 6, 5, 0 }, { 1, 5, 0 }, { 0, 0, 0 } },
[LCD_WINCTRL1_FRM_16BPPA1555 >> 25] =
{ { 10, 5, 0 }, { 5, 5, 0 }, { 0, 5, 0 }, { 15, 1, 0 } },