diff options
author | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-16 18:20:36 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-16 18:20:36 -0400 |
commit | 1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch) | |
tree | 0bba044c4ce775e45a88a51686b5d9f90697ea9d /drivers/video/geode |
Linux-2.6.12-rc2v2.6.12-rc2
Initial git repository build. I'm not bothering with the full history,
even though we have it. We can create a separate "historical" git
archive of that later if we want to, and in the meantime it's about
3.2GB when imported into git - space that would just make the early
git days unnecessarily complicated, when we don't have a lot of good
infrastructure for it.
Let it rip!
Diffstat (limited to 'drivers/video/geode')
-rw-r--r-- | drivers/video/geode/Kconfig | 29 | ||||
-rw-r--r-- | drivers/video/geode/Makefile | 5 | ||||
-rw-r--r-- | drivers/video/geode/display_gx1.c | 214 | ||||
-rw-r--r-- | drivers/video/geode/display_gx1.h | 154 | ||||
-rw-r--r-- | drivers/video/geode/geodefb.h | 39 | ||||
-rw-r--r-- | drivers/video/geode/gx1fb_core.c | 359 | ||||
-rw-r--r-- | drivers/video/geode/video_cs5530.c | 195 | ||||
-rw-r--r-- | drivers/video/geode/video_cs5530.h | 75 |
8 files changed, 1070 insertions, 0 deletions
diff --git a/drivers/video/geode/Kconfig b/drivers/video/geode/Kconfig new file mode 100644 index 000000000000..b075fd02de31 --- /dev/null +++ b/drivers/video/geode/Kconfig | |||
@@ -0,0 +1,29 @@ | |||
1 | # | ||
2 | # Geode family framebuffer configuration | ||
3 | # | ||
4 | config FB_GEODE | ||
5 | bool "AMD Geode family framebuffer support (EXPERIMENTAL)" | ||
6 | default n | ||
7 | depends on FB && EXPERIMENTAL && X86 | ||
8 | ---help--- | ||
9 | Say 'Y' here to allow you to select framebuffer drivers for | ||
10 | the AMD Geode family of processors. | ||
11 | |||
12 | config FB_GEODE_GX1 | ||
13 | tristate "AMD Geode GX1 framebuffer support (EXPERIMENTAL)" | ||
14 | default n | ||
15 | depends on FB_GEODE && EXPERIMENTAL | ||
16 | select FB_CFB_FILLRECT | ||
17 | select FB_CFB_COPYAREA | ||
18 | select FB_CFB_IMAGEBLIT | ||
19 | select FB_SOFT_CURSOR | ||
20 | ---help--- | ||
21 | Framebuffer driver for the display controller integrated into the | ||
22 | AMD Geode GX1 processor. | ||
23 | |||
24 | This driver is also available as a module ( = code which can be | ||
25 | inserted and removed from the running kernel whenever you want). The | ||
26 | module will be called gx1fb. If you want to compile it as a module, | ||
27 | say M here and read <file:Documentation/modules.txt>. | ||
28 | |||
29 | If unsure, say N. | ||
diff --git a/drivers/video/geode/Makefile b/drivers/video/geode/Makefile new file mode 100644 index 000000000000..13ad501ea990 --- /dev/null +++ b/drivers/video/geode/Makefile | |||
@@ -0,0 +1,5 @@ | |||
1 | # Makefile for the Geode family framebuffer drivers | ||
2 | |||
3 | obj-$(CONFIG_FB_GEODE_GX1) += gx1fb.o | ||
4 | |||
5 | gx1fb-objs := gx1fb_core.o display_gx1.o video_cs5530.o | ||
diff --git a/drivers/video/geode/display_gx1.c b/drivers/video/geode/display_gx1.c new file mode 100644 index 000000000000..f4983879fcc4 --- /dev/null +++ b/drivers/video/geode/display_gx1.c | |||
@@ -0,0 +1,214 @@ | |||
1 | /* | ||
2 | * drivers/video/geode/display_gx1.c | ||
3 | * -- Geode GX1 display controller | ||
4 | * | ||
5 | * Copyright (C) 2005 Arcom Control Systems Ltd. | ||
6 | * | ||
7 | * Based on AMD's original 2.4 driver: | ||
8 | * Copyright (C) 2004 Advanced Micro Devices, Inc. | ||
9 | * | ||
10 | * This program is free software; you can redistribute it and/or modify | ||
11 | * it under the terms of the GNU General Public License as published by | ||
12 | * the Free Software Foundation; either version 2 of the License, or | ||
13 | * (at your option) any later version. | ||
14 | */ | ||
15 | #include <linux/spinlock.h> | ||
16 | #include <linux/fb.h> | ||
17 | #include <linux/delay.h> | ||
18 | #include <asm/io.h> | ||
19 | #include <asm/div64.h> | ||
20 | #include <asm/delay.h> | ||
21 | |||
22 | #include "geodefb.h" | ||
23 | #include "display_gx1.h" | ||
24 | |||
25 | static spinlock_t gx1_conf_reg_lock = SPIN_LOCK_UNLOCKED; | ||
26 | |||
27 | static u8 gx1_read_conf_reg(u8 reg) | ||
28 | { | ||
29 | u8 val, ccr3; | ||
30 | unsigned long flags; | ||
31 | |||
32 | spin_lock_irqsave(&gx1_conf_reg_lock, flags); | ||
33 | |||
34 | outb(CONFIG_CCR3, 0x22); | ||
35 | ccr3 = inb(0x23); | ||
36 | outb(CONFIG_CCR3, 0x22); | ||
37 | outb(ccr3 | CONFIG_CCR3_MAPEN, 0x23); | ||
38 | outb(reg, 0x22); | ||
39 | val = inb(0x23); | ||
40 | outb(CONFIG_CCR3, 0x22); | ||
41 | outb(ccr3, 0x23); | ||
42 | |||
43 | spin_unlock_irqrestore(&gx1_conf_reg_lock, flags); | ||
44 | |||
45 | return val; | ||
46 | } | ||
47 | |||
48 | unsigned gx1_gx_base(void) | ||
49 | { | ||
50 | return (gx1_read_conf_reg(CONFIG_GCR) & 0x03) << 30; | ||
51 | } | ||
52 | |||
53 | int gx1_frame_buffer_size(void) | ||
54 | { | ||
55 | void __iomem *mc_regs; | ||
56 | u32 bank_cfg; | ||
57 | int d; | ||
58 | unsigned dram_size = 0, fb_base; | ||
59 | |||
60 | mc_regs = ioremap(gx1_gx_base() + 0x8400, 0x100); | ||
61 | if (!mc_regs) | ||
62 | return -ENOMEM; | ||
63 | |||
64 | |||
65 | /* Calculate the total size of both DIMM0 and DIMM1. */ | ||
66 | bank_cfg = readl(mc_regs + MC_BANK_CFG); | ||
67 | |||
68 | for (d = 0; d < 2; d++) { | ||
69 | if ((bank_cfg & MC_BCFG_DIMM0_PG_SZ_MASK) != MC_BCFG_DIMM0_PG_SZ_NO_DIMM) | ||
70 | dram_size += 0x400000 << ((bank_cfg & MC_BCFG_DIMM0_SZ_MASK) >> 8); | ||
71 | bank_cfg >>= 16; /* look at DIMM1 next */ | ||
72 | } | ||
73 | |||
74 | fb_base = (readl(mc_regs + MC_GBASE_ADD) & MC_GADD_GBADD_MASK) << 19; | ||
75 | |||
76 | iounmap(mc_regs); | ||
77 | |||
78 | return dram_size - fb_base; | ||
79 | } | ||
80 | |||
81 | static void gx1_set_mode(struct fb_info *info) | ||
82 | { | ||
83 | struct geodefb_par *par = info->par; | ||
84 | u32 gcfg, tcfg, ocfg, dclk_div, val; | ||
85 | int hactive, hblankstart, hsyncstart, hsyncend, hblankend, htotal; | ||
86 | int vactive, vblankstart, vsyncstart, vsyncend, vblankend, vtotal; | ||
87 | |||
88 | /* Unlock the display controller registers. */ | ||
89 | readl(par->dc_regs + DC_UNLOCK); | ||
90 | writel(DC_UNLOCK_CODE, par->dc_regs + DC_UNLOCK); | ||
91 | |||
92 | gcfg = readl(par->dc_regs + DC_GENERAL_CFG); | ||
93 | tcfg = readl(par->dc_regs + DC_TIMING_CFG); | ||
94 | |||
95 | /* Blank the display and disable the timing generator. */ | ||
96 | tcfg &= ~(DC_TCFG_BLKE | DC_TCFG_TGEN); | ||
97 | writel(tcfg, par->dc_regs + DC_TIMING_CFG); | ||
98 | |||
99 | /* Wait for pending memory requests before disabling the FIFO load. */ | ||
100 | udelay(100); | ||
101 | |||
102 | /* Disable FIFO load and compression. */ | ||
103 | gcfg &= ~(DC_GCFG_DFLE | DC_GCFG_CMPE | DC_GCFG_DECE); | ||
104 | writel(gcfg, par->dc_regs + DC_GENERAL_CFG); | ||
105 | |||
106 | /* Setup DCLK and its divisor. */ | ||
107 | gcfg &= ~DC_GCFG_DCLK_MASK; | ||
108 | writel(gcfg, par->dc_regs + DC_GENERAL_CFG); | ||
109 | |||
110 | par->vid_ops->set_dclk(info); | ||
111 | |||
112 | dclk_div = DC_GCFG_DCLK_DIV_1; /* FIXME: may need to divide DCLK by 2 sometimes? */ | ||
113 | gcfg |= dclk_div; | ||
114 | writel(gcfg, par->dc_regs + DC_GENERAL_CFG); | ||
115 | |||
116 | /* Wait for the clock generatation to settle. This is needed since | ||
117 | * some of the register writes that follow require that clock to be | ||
118 | * present. */ | ||
119 | udelay(1000); /* FIXME: seems a little long */ | ||
120 | |||
121 | /* | ||
122 | * Setup new mode. | ||
123 | */ | ||
124 | |||
125 | /* Clear all unused feature bits. */ | ||
126 | gcfg = DC_GCFG_VRDY | dclk_div; | ||
127 | |||
128 | /* Set FIFO priority (default 6/5) and enable. */ | ||
129 | /* FIXME: increase fifo priority for 1280x1024 modes? */ | ||
130 | gcfg |= (6 << DC_GCFG_DFHPEL_POS) | (5 << DC_GCFG_DFHPSL_POS) | DC_GCFG_DFLE; | ||
131 | |||
132 | /* FIXME: Set pixel and line double bits if necessary. */ | ||
133 | |||
134 | /* Framebuffer start offset. */ | ||
135 | writel(0, par->dc_regs + DC_FB_ST_OFFSET); | ||
136 | |||
137 | /* Line delta and line buffer length. */ | ||
138 | writel(info->fix.line_length >> 2, par->dc_regs + DC_LINE_DELTA); | ||
139 | writel(((info->var.xres * info->var.bits_per_pixel/8) >> 3) + 2, | ||
140 | par->dc_regs + DC_BUF_SIZE); | ||
141 | |||
142 | /* Output configuration. Enable panel data, set pixel format. */ | ||
143 | ocfg = DC_OCFG_PCKE | DC_OCFG_PDEL | DC_OCFG_PDEH; | ||
144 | if (info->var.bits_per_pixel == 8) ocfg |= DC_OCFG_8BPP; | ||
145 | |||
146 | /* Enable timing generator, sync and FP data. */ | ||
147 | tcfg = DC_TCFG_FPPE | DC_TCFG_HSYE | DC_TCFG_VSYE | DC_TCFG_BLKE | ||
148 | | DC_TCFG_TGEN; | ||
149 | |||
150 | /* Horizontal and vertical timings. */ | ||
151 | hactive = info->var.xres; | ||
152 | hblankstart = hactive; | ||
153 | hsyncstart = hblankstart + info->var.right_margin; | ||
154 | hsyncend = hsyncstart + info->var.hsync_len; | ||
155 | hblankend = hsyncend + info->var.left_margin; | ||
156 | htotal = hblankend; | ||
157 | |||
158 | vactive = info->var.yres; | ||
159 | vblankstart = vactive; | ||
160 | vsyncstart = vblankstart + info->var.lower_margin; | ||
161 | vsyncend = vsyncstart + info->var.vsync_len; | ||
162 | vblankend = vsyncend + info->var.upper_margin; | ||
163 | vtotal = vblankend; | ||
164 | |||
165 | val = (hactive - 1) | ((htotal - 1) << 16); | ||
166 | writel(val, par->dc_regs + DC_H_TIMING_1); | ||
167 | val = (hblankstart - 1) | ((hblankend - 1) << 16); | ||
168 | writel(val, par->dc_regs + DC_H_TIMING_2); | ||
169 | val = (hsyncstart - 1) | ((hsyncend - 1) << 16); | ||
170 | writel(val, par->dc_regs + DC_H_TIMING_3); | ||
171 | writel(val, par->dc_regs + DC_FP_H_TIMING); | ||
172 | val = (vactive - 1) | ((vtotal - 1) << 16); | ||
173 | writel(val, par->dc_regs + DC_V_TIMING_1); | ||
174 | val = (vblankstart - 1) | ((vblankend - 1) << 16); | ||
175 | writel(val, par->dc_regs + DC_V_TIMING_2); | ||
176 | val = (vsyncstart - 1) | ((vsyncend - 1) << 16); | ||
177 | writel(val, par->dc_regs + DC_V_TIMING_3); | ||
178 | val = (vsyncstart - 2) | ((vsyncend - 2) << 16); | ||
179 | writel(val, par->dc_regs + DC_FP_V_TIMING); | ||
180 | |||
181 | /* Write final register values. */ | ||
182 | writel(ocfg, par->dc_regs + DC_OUTPUT_CFG); | ||
183 | writel(tcfg, par->dc_regs + DC_TIMING_CFG); | ||
184 | udelay(1000); /* delay after TIMING_CFG. FIXME: perhaps a little long */ | ||
185 | writel(gcfg, par->dc_regs + DC_GENERAL_CFG); | ||
186 | |||
187 | par->vid_ops->configure_display(info); | ||
188 | |||
189 | /* Relock display controller registers */ | ||
190 | writel(0, par->dc_regs + DC_UNLOCK); | ||
191 | |||
192 | /* FIXME: write line_length and bpp to Graphics Pipeline GP_BLT_STATUS | ||
193 | * register. */ | ||
194 | } | ||
195 | |||
196 | static void gx1_set_hw_palette_reg(struct fb_info *info, unsigned regno, | ||
197 | unsigned red, unsigned green, unsigned blue) | ||
198 | { | ||
199 | struct geodefb_par *par = info->par; | ||
200 | int val; | ||
201 | |||
202 | /* Hardware palette is in RGB 6-6-6 format. */ | ||
203 | val = (red << 2) & 0x3f000; | ||
204 | val |= (green >> 4) & 0x00fc0; | ||
205 | val |= (blue >> 10) & 0x0003f; | ||
206 | |||
207 | writel(regno, par->dc_regs + DC_PAL_ADDRESS); | ||
208 | writel(val, par->dc_regs + DC_PAL_DATA); | ||
209 | } | ||
210 | |||
211 | struct geode_dc_ops gx1_dc_ops = { | ||
212 | .set_mode = gx1_set_mode, | ||
213 | .set_palette_reg = gx1_set_hw_palette_reg, | ||
214 | }; | ||
diff --git a/drivers/video/geode/display_gx1.h b/drivers/video/geode/display_gx1.h new file mode 100644 index 000000000000..671c05558c79 --- /dev/null +++ b/drivers/video/geode/display_gx1.h | |||
@@ -0,0 +1,154 @@ | |||
1 | /* | ||
2 | * drivers/video/geode/display_gx1.h | ||
3 | * -- Geode GX1 display controller | ||
4 | * | ||
5 | * Copyright (C) 2005 Arcom Control Systems Ltd. | ||
6 | * | ||
7 | * Based on AMD's original 2.4 driver: | ||
8 | * Copyright (C) 2004 Advanced Micro Devices, Inc. | ||
9 | * | ||
10 | * This program is free software; you can redistribute it and/or modify | ||
11 | * it under the terms of the GNU General Public License as published by | ||
12 | * the Free Software Foundation; either version 2 of the License, or | ||
13 | * (at your option) any later version. | ||
14 | */ | ||
15 | #ifndef __DISPLAY_GX1_H__ | ||
16 | #define __DISPLAY_GX1_H__ | ||
17 | |||
18 | unsigned gx1_gx_base(void); | ||
19 | int gx1_frame_buffer_size(void); | ||
20 | |||
21 | extern struct geode_dc_ops gx1_dc_ops; | ||
22 | |||
23 | /* GX1 configuration I/O registers */ | ||
24 | |||
25 | #define CONFIG_CCR3 0xc3 | ||
26 | # define CONFIG_CCR3_MAPEN 0x10 | ||
27 | #define CONFIG_GCR 0xb8 | ||
28 | |||
29 | /* Memory controller registers */ | ||
30 | |||
31 | #define MC_BANK_CFG 0x08 | ||
32 | # define MC_BCFG_DIMM0_SZ_MASK 0x00000700 | ||
33 | # define MC_BCFG_DIMM0_PG_SZ_MASK 0x00000070 | ||
34 | # define MC_BCFG_DIMM0_PG_SZ_NO_DIMM 0x00000070 | ||
35 | |||
36 | #define MC_GBASE_ADD 0x14 | ||
37 | # define MC_GADD_GBADD_MASK 0x000003ff | ||
38 | |||
39 | /* Display controller registers */ | ||
40 | |||
41 | #define DC_PAL_ADDRESS 0x70 | ||
42 | #define DC_PAL_DATA 0x74 | ||
43 | |||
44 | #define DC_UNLOCK 0x00 | ||
45 | # define DC_UNLOCK_CODE 0x00004758 | ||
46 | |||
47 | #define DC_GENERAL_CFG 0x04 | ||
48 | # define DC_GCFG_DFLE 0x00000001 | ||
49 | # define DC_GCFG_CURE 0x00000002 | ||
50 | # define DC_GCFG_VCLK_DIV 0x00000004 | ||
51 | # define DC_GCFG_PLNO 0x00000004 | ||
52 | # define DC_GCFG_PPC 0x00000008 | ||
53 | # define DC_GCFG_CMPE 0x00000010 | ||
54 | # define DC_GCFG_DECE 0x00000020 | ||
55 | # define DC_GCFG_DCLK_MASK 0x000000C0 | ||
56 | # define DC_GCFG_DCLK_DIV_1 0x00000080 | ||
57 | # define DC_GCFG_DFHPSL_MASK 0x00000F00 | ||
58 | # define DC_GCFG_DFHPSL_POS 8 | ||
59 | # define DC_GCFG_DFHPEL_MASK 0x0000F000 | ||
60 | # define DC_GCFG_DFHPEL_POS 12 | ||
61 | # define DC_GCFG_CIM_MASK 0x00030000 | ||
62 | # define DC_GCFG_CIM_POS 16 | ||
63 | # define DC_GCFG_FDTY 0x00040000 | ||
64 | # define DC_GCFG_RTPM 0x00080000 | ||
65 | # define DC_GCFG_DAC_RS_MASK 0x00700000 | ||
66 | # define DC_GCFG_DAC_RS_POS 20 | ||
67 | # define DC_GCFG_CKWR 0x00800000 | ||
68 | # define DC_GCFG_LDBL 0x01000000 | ||
69 | # define DC_GCFG_DIAG 0x02000000 | ||
70 | # define DC_GCFG_CH4S 0x04000000 | ||
71 | # define DC_GCFG_SSLC 0x08000000 | ||
72 | # define DC_GCFG_VIDE 0x10000000 | ||
73 | # define DC_GCFG_VRDY 0x20000000 | ||
74 | # define DC_GCFG_DPCK 0x40000000 | ||
75 | # define DC_GCFG_DDCK 0x80000000 | ||
76 | |||
77 | #define DC_TIMING_CFG 0x08 | ||
78 | # define DC_TCFG_FPPE 0x00000001 | ||
79 | # define DC_TCFG_HSYE 0x00000002 | ||
80 | # define DC_TCFG_VSYE 0x00000004 | ||
81 | # define DC_TCFG_BLKE 0x00000008 | ||
82 | # define DC_TCFG_DDCK 0x00000010 | ||
83 | # define DC_TCFG_TGEN 0x00000020 | ||
84 | # define DC_TCFG_VIEN 0x00000040 | ||
85 | # define DC_TCFG_BLNK 0x00000080 | ||
86 | # define DC_TCFG_CHSP 0x00000100 | ||
87 | # define DC_TCFG_CVSP 0x00000200 | ||
88 | # define DC_TCFG_FHSP 0x00000400 | ||
89 | # define DC_TCFG_FVSP 0x00000800 | ||
90 | # define DC_TCFG_FCEN 0x00001000 | ||
91 | # define DC_TCFG_CDCE 0x00002000 | ||
92 | # define DC_TCFG_PLNR 0x00002000 | ||
93 | # define DC_TCFG_INTL 0x00004000 | ||
94 | # define DC_TCFG_PXDB 0x00008000 | ||
95 | # define DC_TCFG_BKRT 0x00010000 | ||
96 | # define DC_TCFG_PSD_MASK 0x000E0000 | ||
97 | # define DC_TCFG_PSD_POS 17 | ||
98 | # define DC_TCFG_DDCI 0x08000000 | ||
99 | # define DC_TCFG_SENS 0x10000000 | ||
100 | # define DC_TCFG_DNA 0x20000000 | ||
101 | # define DC_TCFG_VNA 0x40000000 | ||
102 | # define DC_TCFG_VINT 0x80000000 | ||
103 | |||
104 | #define DC_OUTPUT_CFG 0x0C | ||
105 | # define DC_OCFG_8BPP 0x00000001 | ||
106 | # define DC_OCFG_555 0x00000002 | ||
107 | # define DC_OCFG_PCKE 0x00000004 | ||
108 | # define DC_OCFG_FRME 0x00000008 | ||
109 | # define DC_OCFG_DITE 0x00000010 | ||
110 | # define DC_OCFG_2PXE 0x00000020 | ||
111 | # define DC_OCFG_2XCK 0x00000040 | ||
112 | # define DC_OCFG_2IND 0x00000080 | ||
113 | # define DC_OCFG_34ADD 0x00000100 | ||
114 | # define DC_OCFG_FRMS 0x00000200 | ||
115 | # define DC_OCFG_CKSL 0x00000400 | ||
116 | # define DC_OCFG_PRMP 0x00000800 | ||
117 | # define DC_OCFG_PDEL 0x00001000 | ||
118 | # define DC_OCFG_PDEH 0x00002000 | ||
119 | # define DC_OCFG_CFRW 0x00004000 | ||
120 | # define DC_OCFG_DIAG 0x00008000 | ||
121 | |||
122 | #define DC_FB_ST_OFFSET 0x10 | ||
123 | #define DC_CB_ST_OFFSET 0x14 | ||
124 | #define DC_CURS_ST_OFFSET 0x18 | ||
125 | #define DC_ICON_ST_OFFSET 0x1C | ||
126 | #define DC_VID_ST_OFFSET 0x20 | ||
127 | #define DC_LINE_DELTA 0x24 | ||
128 | #define DC_BUF_SIZE 0x28 | ||
129 | |||
130 | #define DC_H_TIMING_1 0x30 | ||
131 | #define DC_H_TIMING_2 0x34 | ||
132 | #define DC_H_TIMING_3 0x38 | ||
133 | #define DC_FP_H_TIMING 0x3C | ||
134 | |||
135 | #define DC_V_TIMING_1 0x40 | ||
136 | #define DC_V_TIMING_2 0x44 | ||
137 | #define DC_V_TIMING_3 0x48 | ||
138 | #define DC_FP_V_TIMING 0x4C | ||
139 | |||
140 | #define DC_CURSOR_X 0x50 | ||
141 | #define DC_ICON_X 0x54 | ||
142 | #define DC_V_LINE_CNT 0x54 | ||
143 | #define DC_CURSOR_Y 0x58 | ||
144 | #define DC_ICON_Y 0x5C | ||
145 | #define DC_SS_LINE_CMP 0x5C | ||
146 | #define DC_CURSOR_COLOR 0x60 | ||
147 | #define DC_ICON_COLOR 0x64 | ||
148 | #define DC_BORDER_COLOR 0x68 | ||
149 | #define DC_PAL_ADDRESS 0x70 | ||
150 | #define DC_PAL_DATA 0x74 | ||
151 | #define DC_DFIFO_DIAG 0x78 | ||
152 | #define DC_CFIFO_DIAG 0x7C | ||
153 | |||
154 | #endif /* !__DISPLAY_GX1_H__ */ | ||
diff --git a/drivers/video/geode/geodefb.h b/drivers/video/geode/geodefb.h new file mode 100644 index 000000000000..b7bac0a526b3 --- /dev/null +++ b/drivers/video/geode/geodefb.h | |||
@@ -0,0 +1,39 @@ | |||
1 | /* | ||
2 | * drivers/video/geode/geodefb.h | ||
3 | * -- Geode framebuffer driver | ||
4 | * | ||
5 | * Copyright (C) 2005 Arcom Control Systems Ltd. | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or modify | ||
8 | * it under the terms of the GNU General Public License as published by | ||
9 | * the Free Software Foundation; either version 2 of the License, or | ||
10 | * (at your option) any later version. | ||
11 | */ | ||
12 | #ifndef __GEODEFB_H__ | ||
13 | #define __GEODEFB_H__ | ||
14 | |||
15 | struct geodefb_info; | ||
16 | |||
17 | struct geode_dc_ops { | ||
18 | void (*set_mode)(struct fb_info *); | ||
19 | void (*set_palette_reg)(struct fb_info *, unsigned, unsigned, unsigned, unsigned); | ||
20 | }; | ||
21 | |||
22 | struct geode_vid_ops { | ||
23 | void (*set_dclk)(struct fb_info *); | ||
24 | void (*configure_display)(struct fb_info *); | ||
25 | int (*blank_display)(struct fb_info *, int blank_mode); | ||
26 | }; | ||
27 | |||
28 | struct geodefb_par { | ||
29 | int enable_crt; | ||
30 | int panel_x; /* dimensions of an attached flat panel, non-zero => enable panel */ | ||
31 | int panel_y; | ||
32 | struct pci_dev *vid_dev; | ||
33 | void __iomem *dc_regs; | ||
34 | void __iomem *vid_regs; | ||
35 | struct geode_dc_ops *dc_ops; | ||
36 | struct geode_vid_ops *vid_ops; | ||
37 | }; | ||
38 | |||
39 | #endif /* !__GEODEFB_H__ */ | ||
diff --git a/drivers/video/geode/gx1fb_core.c b/drivers/video/geode/gx1fb_core.c new file mode 100644 index 000000000000..83830d24bcda --- /dev/null +++ b/drivers/video/geode/gx1fb_core.c | |||
@@ -0,0 +1,359 @@ | |||
1 | /* | ||
2 | * drivers/video/geode/gx1fb_core.c | ||
3 | * -- Geode GX1 framebuffer driver | ||
4 | * | ||
5 | * Copyright (C) 2005 Arcom Control Systems Ltd. | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or modify | ||
8 | * it under the terms of the GNU General Public License as published by | ||
9 | * the Free Software Foundation; either version 2 of the License, or | ||
10 | * (at your option) any later version. | ||
11 | */ | ||
12 | |||
13 | #include <linux/module.h> | ||
14 | #include <linux/kernel.h> | ||
15 | #include <linux/errno.h> | ||
16 | #include <linux/string.h> | ||
17 | #include <linux/mm.h> | ||
18 | #include <linux/tty.h> | ||
19 | #include <linux/slab.h> | ||
20 | #include <linux/delay.h> | ||
21 | #include <linux/fb.h> | ||
22 | #include <linux/init.h> | ||
23 | #include <linux/pci.h> | ||
24 | |||
25 | #include "geodefb.h" | ||
26 | #include "display_gx1.h" | ||
27 | #include "video_cs5530.h" | ||
28 | |||
29 | static char mode_option[32] = "640x480-16@60"; | ||
30 | static int crt_option = 1; | ||
31 | static char panel_option[32] = ""; | ||
32 | |||
33 | static int gx1_line_delta(int xres, int bpp) | ||
34 | { | ||
35 | int line_delta = xres * (bpp >> 3); | ||
36 | |||
37 | if (line_delta > 2048) | ||
38 | line_delta = 4096; | ||
39 | else if (line_delta > 1024) | ||
40 | line_delta = 2048; | ||
41 | else | ||
42 | line_delta = 1024; | ||
43 | return line_delta; | ||
44 | } | ||
45 | |||
46 | static int gx1fb_check_var(struct fb_var_screeninfo *var, struct fb_info *info) | ||
47 | { | ||
48 | struct geodefb_par *par = info->par; | ||
49 | |||
50 | printk(KERN_DEBUG "%s()\n", __FUNCTION__); | ||
51 | |||
52 | /* Maximum resolution is 1280x1024. */ | ||
53 | if (var->xres > 1280 || var->yres > 1024) | ||
54 | return -EINVAL; | ||
55 | |||
56 | if (par->panel_x && (var->xres > par->panel_x || var->yres > par->panel_y)) | ||
57 | return -EINVAL; | ||
58 | |||
59 | /* Only 16 bpp and 8 bpp is supported by the hardware. */ | ||
60 | if (var->bits_per_pixel == 16) { | ||
61 | var->red.offset = 11; var->red.length = 5; | ||
62 | var->green.offset = 5; var->green.length = 6; | ||
63 | var->blue.offset = 0; var->blue.length = 5; | ||
64 | var->transp.offset = 0; var->transp.length = 0; | ||
65 | } else if (var->bits_per_pixel == 8) { | ||
66 | var->red.offset = 0; var->red.length = 8; | ||
67 | var->green.offset = 0; var->green.length = 8; | ||
68 | var->blue.offset = 0; var->blue.length = 8; | ||
69 | var->transp.offset = 0; var->transp.length = 0; | ||
70 | } else | ||
71 | return -EINVAL; | ||
72 | |||
73 | /* Enough video memory? */ | ||
74 | if (gx1_line_delta(var->xres, var->bits_per_pixel) * var->yres > info->fix.smem_len) | ||
75 | return -EINVAL; | ||
76 | |||
77 | /* FIXME: Check timing parameters here? */ | ||
78 | |||
79 | return 0; | ||
80 | } | ||
81 | |||
82 | static int gx1fb_set_par(struct fb_info *info) | ||
83 | { | ||
84 | struct geodefb_par *par = info->par; | ||
85 | |||
86 | if (info->var.bits_per_pixel == 16) { | ||
87 | info->fix.visual = FB_VISUAL_TRUECOLOR; | ||
88 | fb_dealloc_cmap(&info->cmap); | ||
89 | } else { | ||
90 | info->fix.visual = FB_VISUAL_PSEUDOCOLOR; | ||
91 | fb_alloc_cmap(&info->cmap, 1<<info->var.bits_per_pixel, 0); | ||
92 | } | ||
93 | |||
94 | info->fix.line_length = gx1_line_delta(info->var.xres, info->var.bits_per_pixel); | ||
95 | |||
96 | par->dc_ops->set_mode(info); | ||
97 | |||
98 | return 0; | ||
99 | } | ||
100 | |||
101 | static inline u_int chan_to_field(u_int chan, struct fb_bitfield *bf) | ||
102 | { | ||
103 | chan &= 0xffff; | ||
104 | chan >>= 16 - bf->length; | ||
105 | return chan << bf->offset; | ||
106 | } | ||
107 | |||
108 | static int gx1fb_setcolreg(unsigned regno, unsigned red, unsigned green, | ||
109 | unsigned blue, unsigned transp, | ||
110 | struct fb_info *info) | ||
111 | { | ||
112 | struct geodefb_par *par = info->par; | ||
113 | |||
114 | if (info->var.grayscale) { | ||
115 | /* grayscale = 0.30*R + 0.59*G + 0.11*B */ | ||
116 | red = green = blue = (red * 77 + green * 151 + blue * 28) >> 8; | ||
117 | } | ||
118 | |||
119 | /* Truecolor has hardware independent palette */ | ||
120 | if (info->fix.visual == FB_VISUAL_TRUECOLOR) { | ||
121 | u32 *pal = info->pseudo_palette; | ||
122 | u32 v; | ||
123 | |||
124 | if (regno >= 16) | ||
125 | return -EINVAL; | ||
126 | |||
127 | v = chan_to_field(red, &info->var.red); | ||
128 | v |= chan_to_field(green, &info->var.green); | ||
129 | v |= chan_to_field(blue, &info->var.blue); | ||
130 | |||
131 | pal[regno] = v; | ||
132 | } else { | ||
133 | if (regno >= 256) | ||
134 | return -EINVAL; | ||
135 | |||
136 | par->dc_ops->set_palette_reg(info, regno, red, green, blue); | ||
137 | } | ||
138 | |||
139 | return 0; | ||
140 | } | ||
141 | |||
142 | static int gx1fb_blank(int blank_mode, struct fb_info *info) | ||
143 | { | ||
144 | struct geodefb_par *par = info->par; | ||
145 | |||
146 | return par->vid_ops->blank_display(info, blank_mode); | ||
147 | } | ||
148 | |||
149 | static int __init gx1fb_map_video_memory(struct fb_info *info) | ||
150 | { | ||
151 | struct geodefb_par *par = info->par; | ||
152 | unsigned gx_base; | ||
153 | int fb_len; | ||
154 | |||
155 | gx_base = gx1_gx_base(); | ||
156 | if (!gx_base) | ||
157 | return -ENODEV; | ||
158 | |||
159 | par->vid_dev = pci_get_device(PCI_VENDOR_ID_CYRIX, | ||
160 | PCI_DEVICE_ID_CYRIX_5530_VIDEO, NULL); | ||
161 | if (!par->vid_dev) | ||
162 | return -ENODEV; | ||
163 | |||
164 | par->vid_regs = ioremap(pci_resource_start(par->vid_dev, 1), | ||
165 | pci_resource_len(par->vid_dev, 1)); | ||
166 | if (!par->vid_regs) | ||
167 | return -ENOMEM; | ||
168 | |||
169 | par->dc_regs = ioremap(gx_base + 0x8300, 0x100); | ||
170 | if (!par->dc_regs) | ||
171 | return -ENOMEM; | ||
172 | |||
173 | info->fix.smem_start = gx_base + 0x800000; | ||
174 | if ((fb_len = gx1_frame_buffer_size()) < 0) | ||
175 | return -ENOMEM; | ||
176 | info->fix.smem_len = fb_len; | ||
177 | info->screen_base = ioremap(info->fix.smem_start, info->fix.smem_len); | ||
178 | if (!info->screen_base) | ||
179 | return -ENOMEM; | ||
180 | |||
181 | printk(KERN_INFO "%s: %d Kibyte of video memory at 0x%lx\n", | ||
182 | info->fix.id, info->fix.smem_len / 1024, info->fix.smem_start); | ||
183 | |||
184 | return 0; | ||
185 | } | ||
186 | |||
187 | static int parse_panel_option(struct fb_info *info) | ||
188 | { | ||
189 | struct geodefb_par *par = info->par; | ||
190 | |||
191 | if (strcmp(panel_option, "") != 0) { | ||
192 | int x, y; | ||
193 | char *s; | ||
194 | x = simple_strtol(panel_option, &s, 10); | ||
195 | if (!x) | ||
196 | return -EINVAL; | ||
197 | y = simple_strtol(s + 1, NULL, 10); | ||
198 | if (!y) | ||
199 | return -EINVAL; | ||
200 | par->panel_x = x; | ||
201 | par->panel_y = y; | ||
202 | } | ||
203 | return 0; | ||
204 | } | ||
205 | |||
206 | static struct fb_ops gx1fb_ops = { | ||
207 | .owner = THIS_MODULE, | ||
208 | .fb_check_var = gx1fb_check_var, | ||
209 | .fb_set_par = gx1fb_set_par, | ||
210 | .fb_setcolreg = gx1fb_setcolreg, | ||
211 | .fb_blank = gx1fb_blank, | ||
212 | /* No HW acceleration for now. */ | ||
213 | .fb_fillrect = cfb_fillrect, | ||
214 | .fb_copyarea = cfb_copyarea, | ||
215 | .fb_imageblit = cfb_imageblit, | ||
216 | .fb_cursor = soft_cursor, | ||
217 | }; | ||
218 | |||
219 | static struct fb_info * __init gx1fb_init_fbinfo(void) | ||
220 | { | ||
221 | struct fb_info *info; | ||
222 | struct geodefb_par *par; | ||
223 | |||
224 | /* Alloc enough space for the pseudo palette. */ | ||
225 | info = framebuffer_alloc(sizeof(struct geodefb_par) + sizeof(u32) * 16, NULL); | ||
226 | if (!info) | ||
227 | return NULL; | ||
228 | |||
229 | par = info->par; | ||
230 | |||
231 | strcpy(info->fix.id, "GX1"); | ||
232 | |||
233 | info->fix.type = FB_TYPE_PACKED_PIXELS; | ||
234 | info->fix.type_aux = 0; | ||
235 | info->fix.xpanstep = 0; | ||
236 | info->fix.ypanstep = 0; | ||
237 | info->fix.ywrapstep = 0; | ||
238 | info->fix.accel = FB_ACCEL_NONE; | ||
239 | |||
240 | info->var.nonstd = 0; | ||
241 | info->var.activate = FB_ACTIVATE_NOW; | ||
242 | info->var.height = -1; | ||
243 | info->var.width = -1; | ||
244 | info->var.accel_flags = 0; | ||
245 | info->var.vmode = FB_VMODE_NONINTERLACED; | ||
246 | |||
247 | info->fbops = &gx1fb_ops; | ||
248 | info->flags = FBINFO_DEFAULT; | ||
249 | info->node = -1; | ||
250 | |||
251 | info->pseudo_palette = (void *)par + sizeof(struct geodefb_par); | ||
252 | |||
253 | info->var.grayscale = 0; | ||
254 | |||
255 | /* CRT and panel options */ | ||
256 | par->enable_crt = crt_option; | ||
257 | if (parse_panel_option(info) < 0) | ||
258 | printk(KERN_WARNING "%s: invalid 'panel' option -- disabling flat panel\n", | ||
259 | info->fix.id); | ||
260 | if (!par->panel_x) | ||
261 | par->enable_crt = 1; /* fall back to CRT if no panel is specified */ | ||
262 | |||
263 | return info; | ||
264 | } | ||
265 | |||
266 | |||
267 | static struct fb_info *gx1fb_info; | ||
268 | |||
269 | static int __init gx1fb_init(void) | ||
270 | { | ||
271 | struct fb_info *info; | ||
272 | struct geodefb_par *par; | ||
273 | int ret; | ||
274 | |||
275 | #ifndef MODULE | ||
276 | if (fb_get_options("gx1fb", NULL)) | ||
277 | return -ENODEV; | ||
278 | #endif | ||
279 | |||
280 | info = gx1fb_init_fbinfo(); | ||
281 | if (!info) | ||
282 | return -ENOMEM; | ||
283 | gx1fb_info = info; | ||
284 | |||
285 | par = info->par; | ||
286 | |||
287 | /* GX1 display controller and CS5530 video device */ | ||
288 | par->dc_ops = &gx1_dc_ops; | ||
289 | par->vid_ops = &cs5530_vid_ops; | ||
290 | |||
291 | if ((ret = gx1fb_map_video_memory(info)) < 0) { | ||
292 | printk(KERN_ERR "%s: gx1fb_map_video_memory() failed\n", info->fix.id); | ||
293 | goto err; | ||
294 | } | ||
295 | |||
296 | ret = fb_find_mode(&info->var, info, mode_option, NULL, 0, NULL, 16); | ||
297 | if (ret == 0 || ret == 4) { | ||
298 | printk(KERN_ERR "%s: could not find valid video mode\n", info->fix.id); | ||
299 | ret = -EINVAL; | ||
300 | goto err; | ||
301 | } | ||
302 | |||
303 | /* Clear the frame buffer of garbage. */ | ||
304 | memset_io(info->screen_base, 0, info->fix.smem_len); | ||
305 | |||
306 | gx1fb_check_var(&info->var, info); | ||
307 | gx1fb_set_par(info); | ||
308 | |||
309 | if (register_framebuffer(info) < 0) { | ||
310 | ret = -EINVAL; | ||
311 | goto err; | ||
312 | } | ||
313 | printk(KERN_INFO "fb%d: %s frame buffer device\n", info->node, info->fix.id); | ||
314 | return 0; | ||
315 | |||
316 | err: | ||
317 | if (info->screen_base) | ||
318 | iounmap(info->screen_base); | ||
319 | if (par->vid_regs) | ||
320 | iounmap(par->vid_regs); | ||
321 | if (par->dc_regs) | ||
322 | iounmap(par->dc_regs); | ||
323 | if (par->vid_dev) | ||
324 | pci_dev_put(par->vid_dev); | ||
325 | if (info) | ||
326 | framebuffer_release(info); | ||
327 | return ret; | ||
328 | } | ||
329 | |||
330 | static void __exit gx1fb_cleanup(void) | ||
331 | { | ||
332 | struct fb_info *info = gx1fb_info; | ||
333 | struct geodefb_par *par = gx1fb_info->par; | ||
334 | |||
335 | unregister_framebuffer(info); | ||
336 | |||
337 | iounmap((void __iomem *)info->screen_base); | ||
338 | iounmap(par->vid_regs); | ||
339 | iounmap(par->dc_regs); | ||
340 | |||
341 | pci_dev_put(par->vid_dev); | ||
342 | |||
343 | framebuffer_release(info); | ||
344 | } | ||
345 | |||
346 | module_init(gx1fb_init); | ||
347 | module_exit(gx1fb_cleanup); | ||
348 | |||
349 | module_param_string(mode, mode_option, sizeof(mode_option), 0444); | ||
350 | MODULE_PARM_DESC(mode, "video mode (<x>x<y>[-<bpp>][@<refr>])"); | ||
351 | |||
352 | module_param_named(crt, crt_option, int, 0444); | ||
353 | MODULE_PARM_DESC(crt, "enable CRT output. 0 = off, 1 = on (default)"); | ||
354 | |||
355 | module_param_string(panel, panel_option, sizeof(panel_option), 0444); | ||
356 | MODULE_PARM_DESC(panel, "size of attached flat panel (<x>x<y>)"); | ||
357 | |||
358 | MODULE_DESCRIPTION("framebuffer driver for the AMD Geode GX1"); | ||
359 | MODULE_LICENSE("GPL"); | ||
diff --git a/drivers/video/geode/video_cs5530.c b/drivers/video/geode/video_cs5530.c new file mode 100644 index 000000000000..d3764acf8443 --- /dev/null +++ b/drivers/video/geode/video_cs5530.c | |||
@@ -0,0 +1,195 @@ | |||
1 | /* | ||
2 | * drivers/video/geode/video_cs5530.c | ||
3 | * -- CS5530 video device | ||
4 | * | ||
5 | * Copyright (C) 2005 Arcom Control Systems Ltd. | ||
6 | * | ||
7 | * Based on AMD's original 2.4 driver: | ||
8 | * Copyright (C) 2004 Advanced Micro Devices, Inc. | ||
9 | * | ||
10 | * This program is free software; you can redistribute it and/or modify | ||
11 | * it under the terms of the GNU General Public License as published by | ||
12 | * the Free Software Foundation; either version 2 of the License, or | ||
13 | * (at your option) any later version. | ||
14 | */ | ||
15 | #include <linux/fb.h> | ||
16 | #include <linux/delay.h> | ||
17 | #include <asm/io.h> | ||
18 | #include <asm/delay.h> | ||
19 | |||
20 | #include "geodefb.h" | ||
21 | #include "video_cs5530.h" | ||
22 | |||
23 | /* | ||
24 | * CS5530 PLL table. This maps pixclocks to the appropriate PLL register | ||
25 | * value. | ||
26 | */ | ||
27 | struct cs5530_pll_entry { | ||
28 | long pixclock; /* ps */ | ||
29 | u32 pll_value; | ||
30 | }; | ||
31 | |||
32 | static const struct cs5530_pll_entry cs5530_pll_table[] = { | ||
33 | { 39721, 0x31C45801, }, /* 25.1750 MHz */ | ||
34 | { 35308, 0x20E36802, }, /* 28.3220 */ | ||
35 | { 31746, 0x33915801, }, /* 31.5000 */ | ||
36 | { 27777, 0x31EC4801, }, /* 36.0000 */ | ||
37 | { 26666, 0x21E22801, }, /* 37.5000 */ | ||
38 | { 25000, 0x33088801, }, /* 40.0000 */ | ||
39 | { 22271, 0x33E22801, }, /* 44.9000 */ | ||
40 | { 20202, 0x336C4801, }, /* 49.5000 */ | ||
41 | { 20000, 0x23088801, }, /* 50.0000 */ | ||
42 | { 19860, 0x23088801, }, /* 50.3500 */ | ||
43 | { 18518, 0x3708A801, }, /* 54.0000 */ | ||
44 | { 17777, 0x23E36802, }, /* 56.2500 */ | ||
45 | { 17733, 0x23E36802, }, /* 56.3916 */ | ||
46 | { 17653, 0x23E36802, }, /* 56.6444 */ | ||
47 | { 16949, 0x37C45801, }, /* 59.0000 */ | ||
48 | { 15873, 0x23EC4801, }, /* 63.0000 */ | ||
49 | { 15384, 0x37911801, }, /* 65.0000 */ | ||
50 | { 14814, 0x37963803, }, /* 67.5000 */ | ||
51 | { 14124, 0x37058803, }, /* 70.8000 */ | ||
52 | { 13888, 0x3710C805, }, /* 72.0000 */ | ||
53 | { 13333, 0x37E22801, }, /* 75.0000 */ | ||
54 | { 12698, 0x27915801, }, /* 78.7500 */ | ||
55 | { 12500, 0x37D8D802, }, /* 80.0000 */ | ||
56 | { 11135, 0x27588802, }, /* 89.8000 */ | ||
57 | { 10582, 0x27EC4802, }, /* 94.5000 */ | ||
58 | { 10101, 0x27AC6803, }, /* 99.0000 */ | ||
59 | { 10000, 0x27088801, }, /* 100.0000 */ | ||
60 | { 9259, 0x2710C805, }, /* 108.0000 */ | ||
61 | { 8888, 0x27E36802, }, /* 112.5000 */ | ||
62 | { 7692, 0x27C58803, }, /* 130.0000 */ | ||
63 | { 7407, 0x27316803, }, /* 135.0000 */ | ||
64 | { 6349, 0x2F915801, }, /* 157.5000 */ | ||
65 | { 6172, 0x2F08A801, }, /* 162.0000 */ | ||
66 | { 5714, 0x2FB11802, }, /* 175.0000 */ | ||
67 | { 5291, 0x2FEC4802, }, /* 189.0000 */ | ||
68 | { 4950, 0x2F963803, }, /* 202.0000 */ | ||
69 | { 4310, 0x2FB1B802, }, /* 232.0000 */ | ||
70 | }; | ||
71 | |||
72 | #define NUM_CS5530_FREQUENCIES sizeof(cs5530_pll_table)/sizeof(struct cs5530_pll_entry) | ||
73 | |||
74 | static void cs5530_set_dclk_frequency(struct fb_info *info) | ||
75 | { | ||
76 | struct geodefb_par *par = info->par; | ||
77 | int i; | ||
78 | u32 value; | ||
79 | long min, diff; | ||
80 | |||
81 | /* Search the table for the closest pixclock. */ | ||
82 | value = cs5530_pll_table[0].pll_value; | ||
83 | min = cs5530_pll_table[0].pixclock - info->var.pixclock; | ||
84 | if (min < 0) min = -min; | ||
85 | for (i = 1; i < NUM_CS5530_FREQUENCIES; i++) { | ||
86 | diff = cs5530_pll_table[i].pixclock - info->var.pixclock; | ||
87 | if (diff < 0L) diff = -diff; | ||
88 | if (diff < min) { | ||
89 | min = diff; | ||
90 | value = cs5530_pll_table[i].pll_value; | ||
91 | } | ||
92 | } | ||
93 | |||
94 | writel(value, par->vid_regs + CS5530_DOT_CLK_CONFIG); | ||
95 | writel(value | 0x80000100, par->vid_regs + CS5530_DOT_CLK_CONFIG); /* set reset and bypass */ | ||
96 | udelay(500); /* wait for PLL to settle */ | ||
97 | writel(value & 0x7FFFFFFF, par->vid_regs + CS5530_DOT_CLK_CONFIG); /* clear reset */ | ||
98 | writel(value & 0x7FFFFEFF, par->vid_regs + CS5530_DOT_CLK_CONFIG); /* clear bypass */ | ||
99 | } | ||
100 | |||
101 | static void cs5530_configure_display(struct fb_info *info) | ||
102 | { | ||
103 | struct geodefb_par *par = info->par; | ||
104 | u32 dcfg; | ||
105 | |||
106 | dcfg = readl(par->vid_regs + CS5530_DISPLAY_CONFIG); | ||
107 | |||
108 | /* Clear bits from existing mode. */ | ||
109 | dcfg &= ~(CS5530_DCFG_CRT_SYNC_SKW_MASK | CS5530_DCFG_PWR_SEQ_DLY_MASK | ||
110 | | CS5530_DCFG_CRT_HSYNC_POL | CS5530_DCFG_CRT_VSYNC_POL | ||
111 | | CS5530_DCFG_FP_PWR_EN | CS5530_DCFG_FP_DATA_EN | ||
112 | | CS5530_DCFG_DAC_PWR_EN | CS5530_DCFG_VSYNC_EN | ||
113 | | CS5530_DCFG_HSYNC_EN); | ||
114 | |||
115 | /* Set default sync skew and power sequence delays. */ | ||
116 | dcfg |= (CS5530_DCFG_CRT_SYNC_SKW_INIT | CS5530_DCFG_PWR_SEQ_DLY_INIT | ||
117 | | CS5530_DCFG_GV_PAL_BYP); | ||
118 | |||
119 | /* Enable DACs, hsync and vsync for CRTs */ | ||
120 | if (par->enable_crt) { | ||
121 | dcfg |= CS5530_DCFG_DAC_PWR_EN; | ||
122 | dcfg |= CS5530_DCFG_HSYNC_EN | CS5530_DCFG_VSYNC_EN; | ||
123 | } | ||
124 | /* Enable panel power and data if using a flat panel. */ | ||
125 | if (par->panel_x > 0) { | ||
126 | dcfg |= CS5530_DCFG_FP_PWR_EN; | ||
127 | dcfg |= CS5530_DCFG_FP_DATA_EN; | ||
128 | } | ||
129 | |||
130 | /* Sync polarities. */ | ||
131 | if (info->var.sync & FB_SYNC_HOR_HIGH_ACT) | ||
132 | dcfg |= CS5530_DCFG_CRT_HSYNC_POL; | ||
133 | if (info->var.sync & FB_SYNC_VERT_HIGH_ACT) | ||
134 | dcfg |= CS5530_DCFG_CRT_VSYNC_POL; | ||
135 | |||
136 | writel(dcfg, par->vid_regs + CS5530_DISPLAY_CONFIG); | ||
137 | } | ||
138 | |||
139 | static int cs5530_blank_display(struct fb_info *info, int blank_mode) | ||
140 | { | ||
141 | struct geodefb_par *par = info->par; | ||
142 | u32 dcfg; | ||
143 | int blank, hsync, vsync; | ||
144 | |||
145 | switch (blank_mode) { | ||
146 | case FB_BLANK_UNBLANK: | ||
147 | blank = 0; hsync = 1; vsync = 1; | ||
148 | break; | ||
149 | case FB_BLANK_NORMAL: | ||
150 | blank = 1; hsync = 1; vsync = 1; | ||
151 | break; | ||
152 | case FB_BLANK_VSYNC_SUSPEND: | ||
153 | blank = 1; hsync = 1; vsync = 0; | ||
154 | break; | ||
155 | case FB_BLANK_HSYNC_SUSPEND: | ||
156 | blank = 1; hsync = 0; vsync = 1; | ||
157 | break; | ||
158 | case FB_BLANK_POWERDOWN: | ||
159 | blank = 1; hsync = 0; vsync = 0; | ||
160 | break; | ||
161 | default: | ||
162 | return -EINVAL; | ||
163 | } | ||
164 | |||
165 | dcfg = readl(par->vid_regs + CS5530_DISPLAY_CONFIG); | ||
166 | |||
167 | dcfg &= ~(CS5530_DCFG_DAC_BL_EN | CS5530_DCFG_DAC_PWR_EN | ||
168 | | CS5530_DCFG_HSYNC_EN | CS5530_DCFG_VSYNC_EN | ||
169 | | CS5530_DCFG_FP_DATA_EN | CS5530_DCFG_FP_PWR_EN); | ||
170 | |||
171 | if (par->enable_crt) { | ||
172 | if (!blank) | ||
173 | dcfg |= CS5530_DCFG_DAC_BL_EN | CS5530_DCFG_DAC_PWR_EN; | ||
174 | if (hsync) | ||
175 | dcfg |= CS5530_DCFG_HSYNC_EN; | ||
176 | if (vsync) | ||
177 | dcfg |= CS5530_DCFG_VSYNC_EN; | ||
178 | } | ||
179 | if (par->panel_x > 0) { | ||
180 | if (!blank) | ||
181 | dcfg |= CS5530_DCFG_FP_DATA_EN; | ||
182 | if (hsync && vsync) | ||
183 | dcfg |= CS5530_DCFG_FP_PWR_EN; | ||
184 | } | ||
185 | |||
186 | writel(dcfg, par->vid_regs + CS5530_DISPLAY_CONFIG); | ||
187 | |||
188 | return 0; | ||
189 | } | ||
190 | |||
191 | struct geode_vid_ops cs5530_vid_ops = { | ||
192 | .set_dclk = cs5530_set_dclk_frequency, | ||
193 | .configure_display = cs5530_configure_display, | ||
194 | .blank_display = cs5530_blank_display, | ||
195 | }; | ||
diff --git a/drivers/video/geode/video_cs5530.h b/drivers/video/geode/video_cs5530.h new file mode 100644 index 000000000000..56cecca7f1ce --- /dev/null +++ b/drivers/video/geode/video_cs5530.h | |||
@@ -0,0 +1,75 @@ | |||
1 | /* | ||
2 | * drivers/video/geode/video_cs5530.h | ||
3 | * -- CS5530 video device | ||
4 | * | ||
5 | * Copyright (C) 2005 Arcom Control Systems Ltd. | ||
6 | * | ||
7 | * Based on AMD's original 2.4 driver: | ||
8 | * Copyright (C) 2004 Advanced Micro Devices, Inc. | ||
9 | * | ||
10 | * This program is free software; you can redistribute it and/or modify | ||
11 | * it under the terms of the GNU General Public License as published by | ||
12 | * the Free Software Foundation; either version 2 of the License, or | ||
13 | * (at your option) any later version. | ||
14 | */ | ||
15 | #ifndef __VIDEO_CS5530_H__ | ||
16 | #define __VIDEO_CS5530_H__ | ||
17 | |||
18 | extern struct geode_vid_ops cs5530_vid_ops; | ||
19 | |||
20 | /* CS5530 Video device registers */ | ||
21 | |||
22 | #define CS5530_VIDEO_CONFIG 0x0000 | ||
23 | # define CS5530_VCFG_VID_EN 0x00000001 | ||
24 | # define CS5530_VCFG_VID_REG_UPDATE 0x00000002 | ||
25 | # define CS5530_VCFG_VID_INP_FORMAT 0x0000000C | ||
26 | # define CS5530_VCFG_8_BIT_4_2_0 0x00000004 | ||
27 | # define CS5530_VCFG_16_BIT_4_2_0 0x00000008 | ||
28 | # define CS5530_VCFG_GV_SEL 0x00000010 | ||
29 | # define CS5530_VCFG_CSC_BYPASS 0x00000020 | ||
30 | # define CS5530_VCFG_X_FILTER_EN 0x00000040 | ||
31 | # define CS5530_VCFG_Y_FILTER_EN 0x00000080 | ||
32 | # define CS5530_VCFG_LINE_SIZE_LOWER_MASK 0x0000FF00 | ||
33 | # define CS5530_VCFG_INIT_READ_MASK 0x01FF0000 | ||
34 | # define CS5530_VCFG_EARLY_VID_RDY 0x02000000 | ||
35 | # define CS5530_VCFG_LINE_SIZE_UPPER 0x08000000 | ||
36 | # define CS5530_VCFG_4_2_0_MODE 0x10000000 | ||
37 | # define CS5530_VCFG_16_BIT_EN 0x20000000 | ||
38 | # define CS5530_VCFG_HIGH_SPD_INT 0x40000000 | ||
39 | |||
40 | #define CS5530_DISPLAY_CONFIG 0x0004 | ||
41 | # define CS5530_DCFG_DIS_EN 0x00000001 | ||
42 | # define CS5530_DCFG_HSYNC_EN 0x00000002 | ||
43 | # define CS5530_DCFG_VSYNC_EN 0x00000004 | ||
44 | # define CS5530_DCFG_DAC_BL_EN 0x00000008 | ||
45 | # define CS5530_DCFG_DAC_PWR_EN 0x00000020 | ||
46 | # define CS5530_DCFG_FP_PWR_EN 0x00000040 | ||
47 | # define CS5530_DCFG_FP_DATA_EN 0x00000080 | ||
48 | # define CS5530_DCFG_CRT_HSYNC_POL 0x00000100 | ||
49 | # define CS5530_DCFG_CRT_VSYNC_POL 0x00000200 | ||
50 | # define CS5530_DCFG_FP_HSYNC_POL 0x00000400 | ||
51 | # define CS5530_DCFG_FP_VSYNC_POL 0x00000800 | ||
52 | # define CS5530_DCFG_XGA_FP 0x00001000 | ||
53 | # define CS5530_DCFG_FP_DITH_EN 0x00002000 | ||
54 | # define CS5530_DCFG_CRT_SYNC_SKW_MASK 0x0001C000 | ||
55 | # define CS5530_DCFG_CRT_SYNC_SKW_INIT 0x00010000 | ||
56 | # define CS5530_DCFG_PWR_SEQ_DLY_MASK 0x000E0000 | ||
57 | # define CS5530_DCFG_PWR_SEQ_DLY_INIT 0x00080000 | ||
58 | # define CS5530_DCFG_VG_CK 0x00100000 | ||
59 | # define CS5530_DCFG_GV_PAL_BYP 0x00200000 | ||
60 | # define CS5530_DCFG_DDC_SCL 0x00400000 | ||
61 | # define CS5530_DCFG_DDC_SDA 0x00800000 | ||
62 | # define CS5530_DCFG_DDC_OE 0x01000000 | ||
63 | # define CS5530_DCFG_16_BIT_EN 0x02000000 | ||
64 | |||
65 | #define CS5530_VIDEO_X_POS 0x0008 | ||
66 | #define CS5530_VIDEO_Y_POS 0x000C | ||
67 | #define CS5530_VIDEO_SCALE 0x0010 | ||
68 | #define CS5530_VIDEO_COLOR_KEY 0x0014 | ||
69 | #define CS5530_VIDEO_COLOR_MASK 0x0018 | ||
70 | #define CS5530_PALETTE_ADDRESS 0x001C | ||
71 | #define CS5530_PALETTE_DATA 0x0020 | ||
72 | #define CS5530_DOT_CLK_CONFIG 0x0024 | ||
73 | #define CS5530_CRCSIG_TFT_TV 0x0028 | ||
74 | |||
75 | #endif /* !__VIDEO_CS5530_H__ */ | ||