blob: f8f61c3a1334a8d124739a5488bbde01acfe0647 [file] [log] [blame]
Nils31eabf92012-01-14 12:11:41 -05001// Geode GX2/LX VGA functions
2//
3// Copyright (C) 2009 Chris Kindt
4//
5// Written for Google Summer of Code 2009 for the coreboot project
6//
7// This file may be distributed under the terms of the GNU LGPLv3 license.
8
Nils31eabf92012-01-14 12:11:41 -05009#include "biosvar.h" // GET_BDA
Kevin O'Connor2d2fa312013-09-14 21:55:26 -040010#include "farptr.h" // SET_FARVAR
11#include "geodevga.h" // geodevga_setup
Kevin O'Connor5d369d82013-09-02 20:48:46 -040012#include "hw/pci.h" // pci_config_readl
13#include "hw/pci_regs.h" // PCI_BASE_ADDRESS_0
Kevin O'Connor2d2fa312013-09-14 21:55:26 -040014#include "output.h" // dprintf
15#include "stdvga.h" // stdvga_crtc_write
16#include "vgabios.h" // VGAREG_*
Nils31eabf92012-01-14 12:11:41 -050017
18
19/****************************************************************
20* MSR and High Mem access through VSA Virtual Register
21****************************************************************/
22
Kevin O'Connorf47461f2012-09-03 12:32:01 -040023static u64 geode_msr_read(u32 msrAddr)
Nils31eabf92012-01-14 12:11:41 -050024{
25 union u64_u32_u val;
26 asm __volatile__ (
27 "movw $0x0AC1C, %%dx \n"
28 "movl $0xFC530007, %%eax \n"
29 "outl %%eax, %%dx \n"
30 "addb $2, %%dl \n"
31 "inw %%dx, %%ax \n"
32 : "=a" (val.lo), "=d"(val.hi)
33 : "c"(msrAddr)
34 : "cc"
35 );
Christian Gmeiner0f5628d2013-02-14 10:34:36 +010036
37 dprintf(4, "%s(0x%08x) = 0x%08x-0x%08x\n"
38 , __func__, msrAddr, val.hi, val.lo);
Kevin O'Connorf47461f2012-09-03 12:32:01 -040039 return val.val;
Nils31eabf92012-01-14 12:11:41 -050040}
41
Kevin O'Connorf47461f2012-09-03 12:32:01 -040042static void geode_msr_mask(u32 msrAddr, u64 off, u64 on)
Nils31eabf92012-01-14 12:11:41 -050043{
Kevin O'Connorf47461f2012-09-03 12:32:01 -040044 union u64_u32_u uand, uor;
45 uand.val = ~off;
46 uor.val = on;
Christian Gmeiner0f5628d2013-02-14 10:34:36 +010047
48 dprintf(4, "%s(0x%08x, 0x%016llx, 0x%016llx)\n"
49 , __func__, msrAddr, off, on);
50
Nils31eabf92012-01-14 12:11:41 -050051 asm __volatile__ (
52 "push %%eax \n"
53 "movw $0x0AC1C, %%dx \n"
54 "movl $0xFC530007, %%eax \n"
55 "outl %%eax, %%dx \n"
56 "addb $2, %%dl \n"
57 "pop %%eax \n"
58 "outw %%ax, %%dx \n"
59 :
Kevin O'Connorf47461f2012-09-03 12:32:01 -040060 : "c"(msrAddr), "S" (uand.hi), "D" (uand.lo), "b" (uor.hi), "a" (uor.lo)
Nils31eabf92012-01-14 12:11:41 -050061 : "%edx","cc"
62 );
63}
64
Kevin O'Connorf47461f2012-09-03 12:32:01 -040065static u32 geode_mem_read(u32 addr)
Nils31eabf92012-01-14 12:11:41 -050066{
67 u32 val;
68 asm __volatile__ (
69 "movw $0x0AC1C, %%dx \n"
70 "movl $0xFC530001, %%eax \n"
71 "outl %%eax, %%dx \n"
72 "addb $2, %%dl \n"
73 "inw %%dx, %%ax \n"
74 : "=a" (val)
75 : "b"(addr)
76 : "cc"
77 );
78
79 return val;
80}
81
Kevin O'Connorf47461f2012-09-03 12:32:01 -040082static void geode_mem_mask(u32 addr, u32 off, u32 or)
Nils31eabf92012-01-14 12:11:41 -050083{
84 asm __volatile__ (
85 "movw $0x0AC1C, %%dx \n"
86 "movl $0xFC530001, %%eax \n"
87 "outl %%eax, %%dx \n"
88 "addb $2, %%dl \n"
89 "outw %%ax, %%dx \n"
90 :
Kevin O'Connorf47461f2012-09-03 12:32:01 -040091 : "b"(addr), "S" (~off), "D" (or)
Nils31eabf92012-01-14 12:11:41 -050092 : "%eax","cc"
93 );
94}
95
Christian Gmeiner119ece92012-10-01 14:02:43 +020096#define VP_FP_START 0x400
97
Kevin O'Connoref7f73f2012-09-16 13:24:30 -040098static u32 GeodeFB VAR16;
99static u32 GeodeDC VAR16;
100static u32 GeodeVP VAR16;
Christian Gmeiner7bec6db2012-09-01 17:13:02 +0200101
Kevin O'Connorf47461f2012-09-03 12:32:01 -0400102static u32 geode_dc_read(int reg)
Christian Gmeinerd136fd72012-09-01 17:13:04 +0200103{
Kevin O'Connoref7f73f2012-09-16 13:24:30 -0400104 u32 val = geode_mem_read(GET_GLOBAL(GeodeDC) + reg);
105 dprintf(4, "%s(0x%08x) = 0x%08x\n"
106 , __func__, GET_GLOBAL(GeodeDC) + reg, val);
Christian Gmeinerd136fd72012-09-01 17:13:04 +0200107 return val;
108}
109
Kevin O'Connorf47461f2012-09-03 12:32:01 -0400110static void geode_dc_write(int reg, u32 val)
Christian Gmeinerd136fd72012-09-01 17:13:04 +0200111{
Kevin O'Connoref7f73f2012-09-16 13:24:30 -0400112 dprintf(4, "%s(0x%08x, 0x%08x)\n"
113 , __func__, GET_GLOBAL(GeodeDC) + reg, val);
114 geode_mem_mask(GET_GLOBAL(GeodeDC) + reg, ~0, val);
Kevin O'Connorf47461f2012-09-03 12:32:01 -0400115}
116
117static void geode_dc_mask(int reg, u32 off, u32 on)
118{
Kevin O'Connoref7f73f2012-09-16 13:24:30 -0400119 dprintf(4, "%s(0x%08x, 0x%08x, 0x%08x)\n"
120 , __func__, GET_GLOBAL(GeodeDC) + reg, off, on);
121 geode_mem_mask(GET_GLOBAL(GeodeDC) + reg, off, on);
Kevin O'Connorf47461f2012-09-03 12:32:01 -0400122}
123
124static u32 geode_vp_read(int reg)
125{
Kevin O'Connoref7f73f2012-09-16 13:24:30 -0400126 u32 val = geode_mem_read(GET_GLOBAL(GeodeVP) + reg);
127 dprintf(4, "%s(0x%08x) = 0x%08x\n"
128 , __func__, GET_GLOBAL(GeodeVP) + reg, val);
Christian Gmeinerd136fd72012-09-01 17:13:04 +0200129 return val;
130}
131
Kevin O'Connorf47461f2012-09-03 12:32:01 -0400132static void geode_vp_write(int reg, u32 val)
Christian Gmeinerd136fd72012-09-01 17:13:04 +0200133{
Kevin O'Connoref7f73f2012-09-16 13:24:30 -0400134 dprintf(4, "%s(0x%08x, 0x%08x)\n"
135 , __func__, GET_GLOBAL(GeodeVP) + reg, val);
136 geode_mem_mask(GET_GLOBAL(GeodeVP) + reg, ~0, val);
Kevin O'Connorf47461f2012-09-03 12:32:01 -0400137}
138
139static void geode_vp_mask(int reg, u32 off, u32 on)
140{
Kevin O'Connoref7f73f2012-09-16 13:24:30 -0400141 dprintf(4, "%s(0x%08x, 0x%08x, 0x%08x)\n"
142 , __func__, GET_GLOBAL(GeodeVP) + reg, off, on);
143 geode_mem_mask(GET_GLOBAL(GeodeVP) + reg, off, on);
Christian Gmeinerd136fd72012-09-01 17:13:04 +0200144}
145
Christian Gmeiner119ece92012-10-01 14:02:43 +0200146static u32 geode_fp_read(int reg)
147{
148 u32 val = geode_mem_read(GET_GLOBAL(GeodeVP) + VP_FP_START + reg);
149 dprintf(4, "%s(0x%08x) = 0x%08x\n"
Christian Gmeinerbb7e54a2013-02-14 10:34:32 +0100150 , __func__, GET_GLOBAL(GeodeVP) + VP_FP_START + reg, val);
Christian Gmeiner119ece92012-10-01 14:02:43 +0200151 return val;
152}
153
154static void geode_fp_write(int reg, u32 val)
155{
156 dprintf(4, "%s(0x%08x, 0x%08x)\n"
157 , __func__, GET_GLOBAL(GeodeVP) + VP_FP_START + reg, val);
Christian Gmeinerbb7e54a2013-02-14 10:34:32 +0100158 geode_mem_mask(GET_GLOBAL(GeodeVP) + VP_FP_START + reg, ~0, val);
Christian Gmeiner119ece92012-10-01 14:02:43 +0200159}
160
Kevin O'Connoref7f73f2012-09-16 13:24:30 -0400161/****************************************************************
162 * Helper functions
163 ****************************************************************/
164
Nils31eabf92012-01-14 12:11:41 -0500165static int legacyio_check(void)
166{
167 int ret=0;
Kevin O'Connorf47461f2012-09-03 12:32:01 -0400168 u64 val;
Nils31eabf92012-01-14 12:11:41 -0500169
Nils24ddd862012-01-14 12:15:14 -0500170 if (CONFIG_VGA_GEODEGX2)
Kevin O'Connorf47461f2012-09-03 12:32:01 -0400171 val = geode_msr_read(GLIU0_P2D_BM_4);
Nils24ddd862012-01-14 12:15:14 -0500172 else
Kevin O'Connorf47461f2012-09-03 12:32:01 -0400173 val = geode_msr_read(MSR_GLIU0_BASE4);
174 if ((val & 0xffffffff) != 0x0A0fffe0)
Nils31eabf92012-01-14 12:11:41 -0500175 ret|=1;
176
Kevin O'Connorf47461f2012-09-03 12:32:01 -0400177 val = geode_msr_read(GLIU0_IOD_BM_0);
178 if ((val & 0xffffffff) != 0x3c0ffff0)
Nils31eabf92012-01-14 12:11:41 -0500179 ret|=2;
180
Kevin O'Connorf47461f2012-09-03 12:32:01 -0400181 val = geode_msr_read(GLIU0_IOD_BM_1);
182 if ((val & 0xffffffff) != 0x3d0ffff0)
Nils31eabf92012-01-14 12:11:41 -0500183 ret|=4;
184
185 return ret;
186}
187
Christian Gmeiner9de339d2012-09-01 17:12:56 +0200188static u32 framebuffer_size(void)
189{
Christian Gmeiner9de339d2012-09-01 17:12:56 +0200190 /* We use the P2D_R0 msr to read out the number of pages.
191 * One page has a size of 4k
192 *
193 * Bit Name Description
194 * 39:20 PMAX Physical Memory Address Max
195 * 19:0 PMIX Physical Memory Address Min
196 *
197 */
Kevin O'Connorf47461f2012-09-03 12:32:01 -0400198 u64 msr = geode_msr_read(GLIU0_P2D_RO);
Christian Gmeiner9de339d2012-09-01 17:12:56 +0200199
Kevin O'Connorf47461f2012-09-03 12:32:01 -0400200 u32 pmax = (msr >> 20) & 0x000fffff;
201 u32 pmin = msr & 0x000fffff;
202
203 u32 val = pmax - pmin;
Christian Gmeiner9de339d2012-09-01 17:12:56 +0200204 val += 1;
205
206 /* The page size is 4k */
207 return (val << 12);
208}
Nils31eabf92012-01-14 12:11:41 -0500209
210/****************************************************************
Nils31eabf92012-01-14 12:11:41 -0500211* Init Functions
212****************************************************************/
213
Christian Gmeiner42f33ff2013-02-14 10:34:35 +0100214static void geodevga_set_output_mode(void)
215{
216 u64 msr_addr;
217 u64 msr;
218
219 /* set output to crt and RGB/YUV */
220 if (CONFIG_VGA_GEODEGX2)
221 msr_addr = VP_MSR_CONFIG_GX2;
222 else
223 msr_addr = VP_MSR_CONFIG_LX;
224
225 /* set output mode (RGB/YUV) */
226 msr = geode_msr_read(msr_addr);
227 msr &= ~VP_MSR_CONFIG_FMT; // mask out FMT (bits 5:3)
228
229 if (CONFIG_VGA_OUTPUT_PANEL || CONFIG_VGA_OUTPUT_CRT_PANEL) {
230 msr |= VP_MSR_CONFIG_FMT_FP; // flat panel
231
232 if (CONFIG_VGA_OUTPUT_CRT_PANEL) {
233 msr |= VP_MSR_CONFIG_FPC; // simultaneous Flat Panel and CRT
234 dprintf(1, "output: simultaneous Flat Panel and CRT\n");
235 } else {
236 msr &= ~VP_MSR_CONFIG_FPC; // no simultaneous Flat Panel and CRT
237 dprintf(1, "ouput: flat panel\n");
238 }
239 } else {
240 msr |= VP_MSR_CONFIG_FMT_CRT; // CRT only
241 dprintf(1, "output: CRT\n");
242 }
243 geode_msr_mask(msr_addr, ~msr, msr);
244}
245
Nils31eabf92012-01-14 12:11:41 -0500246/* Set up the dc (display controller) portion of the geodelx
Christian Gmeinerc13c1812012-09-01 17:12:52 +0200247* The dc provides hardware support for VGA graphics.
Nils31eabf92012-01-14 12:11:41 -0500248*/
Christian Gmeiner11ebc7d2012-09-01 17:13:03 +0200249static void dc_setup(void)
Nils31eabf92012-01-14 12:11:41 -0500250{
Nils31eabf92012-01-14 12:11:41 -0500251 dprintf(2, "DC_SETUP\n");
252
Kevin O'Connorf47461f2012-09-03 12:32:01 -0400253 geode_dc_write(DC_UNLOCK, DC_LOCK_UNLOCK);
Nils31eabf92012-01-14 12:11:41 -0500254
255 /* zero memory config */
Kevin O'Connorf47461f2012-09-03 12:32:01 -0400256 geode_dc_write(DC_FB_ST_OFFSET, 0x0);
257 geode_dc_write(DC_CB_ST_OFFSET, 0x0);
258 geode_dc_write(DC_CURS_ST_OFFSET, 0x0);
Nils31eabf92012-01-14 12:11:41 -0500259
Christian Gmeiner286e0132012-10-01 14:02:42 +0200260 geode_dc_mask(DC_DISPLAY_CFG, ~DC_CFG_MSK, DC_DISPLAY_CFG_GDEN|DC_DISPLAY_CFG_TRUP);
Christian Gmeiner1337eb32013-02-14 10:34:37 +0100261 geode_dc_write(DC_GENERAL_CFG, DC_GENERAL_CFG_VGAE);
Nils31eabf92012-01-14 12:11:41 -0500262
Kevin O'Connorf47461f2012-09-03 12:32:01 -0400263 geode_dc_write(DC_UNLOCK, DC_LOCK_LOCK);
Nils31eabf92012-01-14 12:11:41 -0500264}
265
266/* Setup the vp (video processor) portion of the geodelx
267* Under VGA modes the vp was handled by softvg from inside VSA2.
268* Without a softvg module, access is only available through a pci bar.
269* The High Mem Access virtual register is used to configure the
270* pci mmio bar from 16bit friendly io space.
271*/
Christian Gmeiner11ebc7d2012-09-01 17:13:03 +0200272static void vp_setup(void)
Nils31eabf92012-01-14 12:11:41 -0500273{
Nils31eabf92012-01-14 12:11:41 -0500274 dprintf(2,"VP_SETUP\n");
Christian Gmeinereac884d2012-10-01 14:02:46 +0200275
Christian Gmeiner42f33ff2013-02-14 10:34:35 +0100276 geodevga_set_output_mode();
Nils31eabf92012-01-14 12:11:41 -0500277
Nils31eabf92012-01-14 12:11:41 -0500278 /* Set mmio registers
279 * there may be some timing issues here, the reads seem
280 * to slow things down enough work reliably
281 */
282
Kevin O'Connorf47461f2012-09-03 12:32:01 -0400283 u32 reg = geode_vp_read(VP_MISC);
Nils31eabf92012-01-14 12:11:41 -0500284 dprintf(1,"VP_SETUP VP_MISC=0x%08x\n",reg);
Christian Gmeiner286e0132012-10-01 14:02:42 +0200285 geode_vp_write(VP_MISC, VP_DCFG_BYP_BOTH);
Kevin O'Connorf47461f2012-09-03 12:32:01 -0400286 reg = geode_vp_read(VP_MISC);
Nils31eabf92012-01-14 12:11:41 -0500287 dprintf(1,"VP_SETUP VP_MISC=0x%08x\n",reg);
288
Kevin O'Connorf47461f2012-09-03 12:32:01 -0400289 reg = geode_vp_read(VP_DCFG);
Nils31eabf92012-01-14 12:11:41 -0500290 dprintf(1,"VP_SETUP VP_DCFG=0x%08x\n",reg);
Christian Gmeiner286e0132012-10-01 14:02:42 +0200291 geode_vp_mask(VP_DCFG, 0, VP_DCFG_CRT_EN|VP_DCFG_HSYNC_EN|VP_DCFG_VSYNC_EN|VP_DCFG_DAC_BL_EN|VP_DCFG_CRT_SKEW);
Kevin O'Connorf47461f2012-09-03 12:32:01 -0400292 reg = geode_vp_read(VP_DCFG);
Nils31eabf92012-01-14 12:11:41 -0500293 dprintf(1,"VP_SETUP VP_DCFG=0x%08x\n",reg);
Christian Gmeiner02203b52012-10-01 14:02:49 +0200294
295 /* setup flat panel */
296 if (CONFIG_VGA_OUTPUT_PANEL || CONFIG_VGA_OUTPUT_CRT_PANEL) {
Christian Gmeiner42f33ff2013-02-14 10:34:35 +0100297 u64 msr;
298
Christian Gmeiner02203b52012-10-01 14:02:49 +0200299 dprintf(1, "Setting up flat panel\n");
300 /* write timing register */
301 geode_fp_write(FP_PT1, 0x0);
302 geode_fp_write(FP_PT2, FP_PT2_SCRC);
303
304 /* set pad select for TFT/LVDS */
305 msr = VP_MSR_PADSEL_TFT_SEL_HIGH;
306 msr = msr << 32;
307 msr |= VP_MSR_PADSEL_TFT_SEL_LOW;
308 geode_msr_mask(VP_MSR_PADSEL, ~msr, msr);
309
310 /* turn the panel on (if it isn't already) */
311 reg = geode_fp_read(FP_PM);
312 reg |= FP_PM_P;
313 geode_fp_write(FP_PM, reg);
314 }
Nils31eabf92012-01-14 12:11:41 -0500315}
316
317static u8 geode_crtc_01[] VAR16 = {
318 0x2d, 0x27, 0x28, 0x90, 0x29, 0x8e, 0xbf, 0x1f,
319 0x00, 0x4f, 0x0d, 0x0e, 0x00, 0x00, 0x00, 0x00,
320 0x9b, 0x8d, 0x8f, 0x14, 0x1f, 0x97, 0xb9, 0xa3,
321 0xff };
322static u8 geode_crtc_03[] VAR16 = {
323 0x5f, 0x4f, 0x50, 0x82, 0x51, 0x9e, 0xbf, 0x1f,
324 0x00, 0x4f, 0x0d, 0x0e, 0x00, 0x00, 0x00, 0x00,
325 0x9b, 0x8d, 0x8f, 0x28, 0x1f, 0x97, 0xb9, 0xa3,
326 0xff };
327static u8 geode_crtc_04[] VAR16 = {
328 0x2d, 0x27, 0x28, 0x90, 0x29, 0x8e, 0xbf, 0x1f,
329 0x00, 0xc1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
330 0x9b, 0x8d, 0x8f, 0x14, 0x00, 0x97, 0xb9, 0xa2,
331 0xff };
332static u8 geode_crtc_05[] VAR16 = {
333 0x2d, 0x27, 0x28, 0x90, 0x29, 0x8e, 0xbf, 0x1f,
334 0x00, 0xc1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
335 0x9b, 0x8e, 0x8f, 0x14, 0x00, 0x97, 0xb9, 0xa2,
336 0xff };
337static u8 geode_crtc_06[] VAR16 = {
338 0x5f, 0x4f, 0x50, 0x82, 0x51, 0x9e, 0xbf, 0x1f,
339 0x00, 0xc1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
340 0x9b, 0x8d, 0x8f, 0x28, 0x00, 0x97, 0xb9, 0xc2,
341 0xff };
342static u8 geode_crtc_07[] VAR16 = {
343 0x5f, 0x4f, 0x50, 0x82, 0x51, 0x9e, 0xbf, 0x1f,
344 0x00, 0x4f, 0x0d, 0x0e, 0x00, 0x00, 0x00, 0x00,
345 0x9b, 0x8d, 0x8f, 0x28, 0x0f, 0x97, 0xb9, 0xa3,
346 0xff };
347static u8 geode_crtc_0d[] VAR16 = {
348 0x2d, 0x27, 0x28, 0x90, 0x29, 0x8e, 0xbf, 0x1f,
349 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
350 0x9b, 0x8d, 0x8f, 0x14, 0x00, 0x97, 0xb9, 0xe3,
351 0xff };
352static u8 geode_crtc_0e[] VAR16 = {
353 0x5f, 0x4f, 0x50, 0x82, 0x51, 0x9e, 0xbf, 0x1f,
354 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
355 0x9b, 0x8d, 0x8f, 0x28, 0x00, 0x97, 0xb9, 0xe3,
356 0xff };
357static u8 geode_crtc_0f[] VAR16 = {
358 0x5f, 0x4f, 0x50, 0x82, 0x51, 0x9e, 0xbf, 0x1f,
359 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
360 0x83, 0x85, 0x5d, 0x28, 0x0f, 0x65, 0xb9, 0xe3,
361 0xff };
362static u8 geode_crtc_11[] VAR16 = {
363 0x5f, 0x4f, 0x50, 0x82, 0x51, 0x9e, 0x0b, 0x3e,
364 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
365 0xe9, 0x8b, 0xdf, 0x28, 0x00, 0xe7, 0x04, 0xe3,
366 0xff };
367static u8 geode_crtc_13[] VAR16 = {
368 0x5f, 0x4f, 0x50, 0x82, 0x51, 0x9e, 0xbf, 0x1f,
369 0x00, 0x41, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
370 0x9b, 0x8d, 0x8f, 0x28, 0x40, 0x98, 0xb9, 0xa3,
371 0xff };
372
Kevin O'Connord83c87b2013-01-21 01:14:12 -0500373int geodevga_setup(void)
Nils31eabf92012-01-14 12:11:41 -0500374{
Kevin O'Connord83c87b2013-01-21 01:14:12 -0500375 int ret = stdvga_setup();
Nils31eabf92012-01-14 12:11:41 -0500376 if (ret)
377 return ret;
378
Kevin O'Connord83c87b2013-01-21 01:14:12 -0500379 dprintf(1,"GEODEVGA_SETUP\n");
Nils31eabf92012-01-14 12:11:41 -0500380
381 if ((ret=legacyio_check())) {
Kevin O'Connord83c87b2013-01-21 01:14:12 -0500382 dprintf(1,"GEODEVGA_SETUP legacyio_check=0x%x\n",ret);
Nils31eabf92012-01-14 12:11:41 -0500383 }
384
385 // Updated timings from geode datasheets, table 6-53 in particular
386 static u8 *new_crtc[] VAR16 = {
387 geode_crtc_01, geode_crtc_01, geode_crtc_03, geode_crtc_03,
388 geode_crtc_04, geode_crtc_05, geode_crtc_06, geode_crtc_07,
389 0, 0, 0, 0, 0,
390 geode_crtc_0d, geode_crtc_0e, geode_crtc_0f, geode_crtc_0f,
391 geode_crtc_11, geode_crtc_11, geode_crtc_13 };
392 int i;
393 for (i=0; i<ARRAY_SIZE(new_crtc); i++) {
394 u8 *crtc = GET_GLOBAL(new_crtc[i]);
Kevin O'Connor69b01cb2012-01-14 23:25:24 -0500395 if (crtc)
396 stdvga_override_crtc(i, crtc);
Nils31eabf92012-01-14 12:11:41 -0500397 }
398
Kevin O'Connor8cf8f8e2012-01-16 19:05:27 -0500399 if (GET_GLOBAL(VgaBDF) < 0)
400 // Device should be at 00:01.1
401 SET_VGA(VgaBDF, pci_to_bdf(0, 1, 1));
Kevin O'Connoref7f73f2012-09-16 13:24:30 -0400402
Christian Gmeiner7bec6db2012-09-01 17:13:02 +0200403 // setup geode struct which is used for register access
Kevin O'Connoref7f73f2012-09-16 13:24:30 -0400404 SET_VGA(GeodeFB, pci_config_readl(GET_GLOBAL(VgaBDF), PCI_BASE_ADDRESS_0));
405 SET_VGA(GeodeDC, pci_config_readl(GET_GLOBAL(VgaBDF), PCI_BASE_ADDRESS_2));
406 SET_VGA(GeodeVP, pci_config_readl(GET_GLOBAL(VgaBDF), PCI_BASE_ADDRESS_3));
407
408 dprintf(1, "fb addr: 0x%08x\n", GET_GLOBAL(GeodeFB));
409 dprintf(1, "dc addr: 0x%08x\n", GET_GLOBAL(GeodeDC));
410 dprintf(1, "vp addr: 0x%08x\n", GET_GLOBAL(GeodeVP));
411
Christian Gmeiner32057082013-02-14 10:34:34 +0100412 /* setup framebuffer */
413 geode_dc_write(DC_UNLOCK, DC_LOCK_UNLOCK);
414
415 /* read fb-bar from pci, then point dc to the fb base */
416 u32 fb = GET_GLOBAL(GeodeFB);
417 if (geode_dc_read(DC_GLIU0_MEM_OFFSET) != fb)
418 geode_dc_write(DC_GLIU0_MEM_OFFSET, fb);
419
420 geode_dc_write(DC_UNLOCK, DC_LOCK_LOCK);
421
422 u32 fb_size = framebuffer_size(); // in byte
423 dprintf(1, "%d KB of video memory at 0x%08x\n", fb_size / 1024, fb);
424
425 /* update VBE variables */
426 SET_VGA(VBE_framebuffer, fb);
427 SET_VGA(VBE_total_memory, fb_size / 1024 / 64); // number of 64K blocks
428
Christian Gmeiner11ebc7d2012-09-01 17:13:03 +0200429 vp_setup();
430 dc_setup();
Nils31eabf92012-01-14 12:11:41 -0500431
Christian Gmeiner11ebc7d2012-09-01 17:13:03 +0200432 return 0;
Nils31eabf92012-01-14 12:11:41 -0500433}