aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/gpu/drm/ast/ast_dp501.c38
-rw-r--r--drivers/gpu/drm/ast/ast_drv.h8
-rw-r--r--drivers/gpu/drm/ast/ast_main.c79
-rw-r--r--drivers/gpu/drm/ast/ast_post.c23
4 files changed, 123 insertions, 25 deletions
diff --git a/drivers/gpu/drm/ast/ast_dp501.c b/drivers/gpu/drm/ast/ast_dp501.c
index 5da4b62285fa..76f07f38b941 100644
--- a/drivers/gpu/drm/ast/ast_dp501.c
+++ b/drivers/gpu/drm/ast/ast_dp501.c
@@ -379,11 +379,39 @@ static bool ast_init_dvo(struct drm_device *dev)
379 return true; 379 return true;
380} 380}
381 381
382
383static void ast_init_analog(struct drm_device *dev)
384{
385 struct ast_private *ast = dev->dev_private;
386 u32 data;
387
388 /*
389 * Set DAC source to VGA mode in SCU2C via the P2A
390 * bridge. First configure the P2U to target the SCU
391 * in case it isn't at this stage.
392 */
393 ast_write32(ast, 0xf004, 0x1e6e0000);
394 ast_write32(ast, 0xf000, 0x1);
395
396 /* Then unlock the SCU with the magic password */
397 ast_write32(ast, 0x12000, 0x1688a8a8);
398 ast_write32(ast, 0x12000, 0x1688a8a8);
399 ast_write32(ast, 0x12000, 0x1688a8a8);
400
401 /* Finally, clear bits [17:16] of SCU2c */
402 data = ast_read32(ast, 0x1202c);
403 data &= 0xfffcffff;
404 ast_write32(ast, 0, data);
405
406 /* Disable DVO */
407 ast_set_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xa3, 0xcf, 0x00);
408}
409
382void ast_init_3rdtx(struct drm_device *dev) 410void ast_init_3rdtx(struct drm_device *dev)
383{ 411{
384 struct ast_private *ast = dev->dev_private; 412 struct ast_private *ast = dev->dev_private;
385 u8 jreg; 413 u8 jreg;
386 u32 data; 414
387 if (ast->chip == AST2300 || ast->chip == AST2400) { 415 if (ast->chip == AST2300 || ast->chip == AST2400) {
388 jreg = ast_get_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xd1, 0xff); 416 jreg = ast_get_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xd1, 0xff);
389 switch (jreg & 0x0e) { 417 switch (jreg & 0x0e) {
@@ -399,12 +427,8 @@ void ast_init_3rdtx(struct drm_device *dev)
399 default: 427 default:
400 if (ast->tx_chip_type == AST_TX_SIL164) 428 if (ast->tx_chip_type == AST_TX_SIL164)
401 ast_init_dvo(dev); 429 ast_init_dvo(dev);
402 else { 430 else
403 ast_write32(ast, 0x12000, 0x1688a8a8); 431 ast_init_analog(dev);
404 data = ast_read32(ast, 0x1202c);
405 data &= 0xfffcffff;
406 ast_write32(ast, 0, data);
407 }
408 } 432 }
409 } 433 }
410} 434}
diff --git a/drivers/gpu/drm/ast/ast_drv.h b/drivers/gpu/drm/ast/ast_drv.h
index cb91c2acc3cb..7485ff945ca9 100644
--- a/drivers/gpu/drm/ast/ast_drv.h
+++ b/drivers/gpu/drm/ast/ast_drv.h
@@ -125,8 +125,9 @@ struct ast_gem_object;
125 125
126#define AST_IO_AR_PORT_WRITE (0x40) 126#define AST_IO_AR_PORT_WRITE (0x40)
127#define AST_IO_MISC_PORT_WRITE (0x42) 127#define AST_IO_MISC_PORT_WRITE (0x42)
128#define AST_IO_VGA_ENABLE_PORT (0x43)
128#define AST_IO_SEQ_PORT (0x44) 129#define AST_IO_SEQ_PORT (0x44)
129#define AST_DAC_INDEX_READ (0x3c7) 130#define AST_IO_DAC_INDEX_READ (0x47)
130#define AST_IO_DAC_INDEX_WRITE (0x48) 131#define AST_IO_DAC_INDEX_WRITE (0x48)
131#define AST_IO_DAC_DATA (0x49) 132#define AST_IO_DAC_DATA (0x49)
132#define AST_IO_GR_PORT (0x4E) 133#define AST_IO_GR_PORT (0x4E)
@@ -134,6 +135,8 @@ struct ast_gem_object;
134#define AST_IO_INPUT_STATUS1_READ (0x5A) 135#define AST_IO_INPUT_STATUS1_READ (0x5A)
135#define AST_IO_MISC_PORT_READ (0x4C) 136#define AST_IO_MISC_PORT_READ (0x4C)
136 137
138#define AST_IO_MM_OFFSET (0x380)
139
137#define __ast_read(x) \ 140#define __ast_read(x) \
138static inline u##x ast_read##x(struct ast_private *ast, u32 reg) { \ 141static inline u##x ast_read##x(struct ast_private *ast, u32 reg) { \
139u##x val = 0;\ 142u##x val = 0;\
@@ -381,6 +384,9 @@ int ast_bo_push_sysram(struct ast_bo *bo);
381int ast_mmap(struct file *filp, struct vm_area_struct *vma); 384int ast_mmap(struct file *filp, struct vm_area_struct *vma);
382 385
383/* ast post */ 386/* ast post */
387void ast_enable_vga(struct drm_device *dev);
388void ast_enable_mmio(struct drm_device *dev);
389bool ast_is_vga_enabled(struct drm_device *dev);
384void ast_post_gpu(struct drm_device *dev); 390void ast_post_gpu(struct drm_device *dev);
385u32 ast_mindwm(struct ast_private *ast, u32 r); 391u32 ast_mindwm(struct ast_private *ast, u32 r);
386void ast_moutdwm(struct ast_private *ast, u32 r, u32 v); 392void ast_moutdwm(struct ast_private *ast, u32 r, u32 v);
diff --git a/drivers/gpu/drm/ast/ast_main.c b/drivers/gpu/drm/ast/ast_main.c
index b792194e0d9c..035dacc93382 100644
--- a/drivers/gpu/drm/ast/ast_main.c
+++ b/drivers/gpu/drm/ast/ast_main.c
@@ -63,7 +63,7 @@ uint8_t ast_get_index_reg_mask(struct ast_private *ast,
63} 63}
64 64
65 65
66static int ast_detect_chip(struct drm_device *dev) 66static int ast_detect_chip(struct drm_device *dev, bool *need_post)
67{ 67{
68 struct ast_private *ast = dev->dev_private; 68 struct ast_private *ast = dev->dev_private;
69 uint32_t data, jreg; 69 uint32_t data, jreg;
@@ -110,6 +110,21 @@ static int ast_detect_chip(struct drm_device *dev)
110 } 110 }
111 } 111 }
112 112
113 /*
114 * If VGA isn't enabled, we need to enable now or subsequent
115 * access to the scratch registers will fail. We also inform
116 * our caller that it needs to POST the chip
117 * (Assumption: VGA not enabled -> need to POST)
118 */
119 if (!ast_is_vga_enabled(dev)) {
120 ast_enable_vga(dev);
121 ast_enable_mmio(dev);
122 DRM_INFO("VGA not enabled on entry, requesting chip POST\n");
123 *need_post = true;
124 } else
125 *need_post = false;
126
127 /* Check if we support wide screen */
113 switch (ast->chip) { 128 switch (ast->chip) {
114 case AST1180: 129 case AST1180:
115 ast->support_wide_screen = true; 130 ast->support_wide_screen = true;
@@ -125,6 +140,7 @@ static int ast_detect_chip(struct drm_device *dev)
125 ast->support_wide_screen = true; 140 ast->support_wide_screen = true;
126 else { 141 else {
127 ast->support_wide_screen = false; 142 ast->support_wide_screen = false;
143 /* Read SCU7c (silicon revision register) */
128 ast_write32(ast, 0xf004, 0x1e6e0000); 144 ast_write32(ast, 0xf004, 0x1e6e0000);
129 ast_write32(ast, 0xf000, 0x1); 145 ast_write32(ast, 0xf000, 0x1);
130 data = ast_read32(ast, 0x1207c); 146 data = ast_read32(ast, 0x1207c);
@@ -137,11 +153,29 @@ static int ast_detect_chip(struct drm_device *dev)
137 break; 153 break;
138 } 154 }
139 155
156 /* Check 3rd Tx option (digital output afaik) */
140 ast->tx_chip_type = AST_TX_NONE; 157 ast->tx_chip_type = AST_TX_NONE;
141 jreg = ast_get_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xa3, 0xff); 158
142 if (jreg & 0x80) 159 /*
143 ast->tx_chip_type = AST_TX_SIL164; 160 * VGACRA3 Enhanced Color Mode Register, check if DVO is already
161 * enabled, in that case, assume we have a SIL164 TMDS transmitter
162 *
163 * Don't make that assumption if we the chip wasn't enabled and
164 * is at power-on reset, otherwise we'll incorrectly "detect" a
165 * SIL164 when there is none.
166 */
167 if (!*need_post) {
168 jreg = ast_get_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xa3, 0xff);
169 if (jreg & 0x80)
170 ast->tx_chip_type = AST_TX_SIL164;
171 }
172
144 if ((ast->chip == AST2300) || (ast->chip == AST2400)) { 173 if ((ast->chip == AST2300) || (ast->chip == AST2400)) {
174 /*
175 * On AST2300 and 2400, look the configuration set by the SoC in
176 * the SOC scratch register #1 bits 11:8 (interestingly marked
177 * as "reserved" in the spec)
178 */
145 jreg = ast_get_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xd1, 0xff); 179 jreg = ast_get_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xd1, 0xff);
146 switch (jreg) { 180 switch (jreg) {
147 case 0x04: 181 case 0x04:
@@ -162,6 +196,17 @@ static int ast_detect_chip(struct drm_device *dev)
162 } 196 }
163 } 197 }
164 198
199 /* Print stuff for diagnostic purposes */
200 switch(ast->tx_chip_type) {
201 case AST_TX_SIL164:
202 DRM_INFO("Using Sil164 TMDS transmitter\n");
203 break;
204 case AST_TX_DP501:
205 DRM_INFO("Using DP501 DisplayPort transmitter\n");
206 break;
207 default:
208 DRM_INFO("Analog VGA only\n");
209 }
165 return 0; 210 return 0;
166} 211}
167 212
@@ -346,6 +391,7 @@ static u32 ast_get_vram_info(struct drm_device *dev)
346int ast_driver_load(struct drm_device *dev, unsigned long flags) 391int ast_driver_load(struct drm_device *dev, unsigned long flags)
347{ 392{
348 struct ast_private *ast; 393 struct ast_private *ast;
394 bool need_post;
349 int ret = 0; 395 int ret = 0;
350 396
351 ast = kzalloc(sizeof(struct ast_private), GFP_KERNEL); 397 ast = kzalloc(sizeof(struct ast_private), GFP_KERNEL);
@@ -360,13 +406,27 @@ int ast_driver_load(struct drm_device *dev, unsigned long flags)
360 ret = -EIO; 406 ret = -EIO;
361 goto out_free; 407 goto out_free;
362 } 408 }
363 ast->ioregs = pci_iomap(dev->pdev, 2, 0); 409
410 /*
411 * If we don't have IO space at all, use MMIO now and
412 * assume the chip has MMIO enabled by default (rev 0x20
413 * and higher).
414 */
415 if (!(pci_resource_flags(dev->pdev, 2) & IORESOURCE_IO)) {
416 DRM_INFO("platform has no IO space, trying MMIO\n");
417 ast->ioregs = ast->regs + AST_IO_MM_OFFSET;
418 }
419
420 /* "map" IO regs if the above hasn't done so already */
364 if (!ast->ioregs) { 421 if (!ast->ioregs) {
365 ret = -EIO; 422 ast->ioregs = pci_iomap(dev->pdev, 2, 0);
366 goto out_free; 423 if (!ast->ioregs) {
424 ret = -EIO;
425 goto out_free;
426 }
367 } 427 }
368 428
369 ast_detect_chip(dev); 429 ast_detect_chip(dev, &need_post);
370 430
371 if (ast->chip != AST1180) { 431 if (ast->chip != AST1180) {
372 ast_get_dram_info(dev); 432 ast_get_dram_info(dev);
@@ -374,6 +434,9 @@ int ast_driver_load(struct drm_device *dev, unsigned long flags)
374 DRM_INFO("dram %d %d %d %08x\n", ast->mclk, ast->dram_type, ast->dram_bus_width, ast->vram_size); 434 DRM_INFO("dram %d %d %d %08x\n", ast->mclk, ast->dram_type, ast->dram_bus_width, ast->vram_size);
375 } 435 }
376 436
437 if (need_post)
438 ast_post_gpu(dev);
439
377 ret = ast_mm_init(ast); 440 ret = ast_mm_init(ast);
378 if (ret) 441 if (ret)
379 goto out_free; 442 goto out_free;
diff --git a/drivers/gpu/drm/ast/ast_post.c b/drivers/gpu/drm/ast/ast_post.c
index 38d437f3a267..810c51d92b99 100644
--- a/drivers/gpu/drm/ast/ast_post.c
+++ b/drivers/gpu/drm/ast/ast_post.c
@@ -33,18 +33,23 @@
33 33
34static void ast_init_dram_2300(struct drm_device *dev); 34static void ast_init_dram_2300(struct drm_device *dev);
35 35
36static void 36void ast_enable_vga(struct drm_device *dev)
37ast_enable_vga(struct drm_device *dev) 37{
38 struct ast_private *ast = dev->dev_private;
39
40 ast_io_write8(ast, AST_IO_VGA_ENABLE_PORT, 0x01);
41 ast_io_write8(ast, AST_IO_MISC_PORT_WRITE, 0x01);
42}
43
44void ast_enable_mmio(struct drm_device *dev)
38{ 45{
39 struct ast_private *ast = dev->dev_private; 46 struct ast_private *ast = dev->dev_private;
40 47
41 ast_io_write8(ast, 0x43, 0x01); 48 ast_set_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xa1, 0xff, 0x04);
42 ast_io_write8(ast, 0x42, 0x01);
43} 49}
44 50
45#if 0 /* will use later */ 51
46static bool 52bool ast_is_vga_enabled(struct drm_device *dev)
47ast_is_vga_enabled(struct drm_device *dev)
48{ 53{
49 struct ast_private *ast = dev->dev_private; 54 struct ast_private *ast = dev->dev_private;
50 u8 ch; 55 u8 ch;
@@ -52,7 +57,7 @@ ast_is_vga_enabled(struct drm_device *dev)
52 if (ast->chip == AST1180) { 57 if (ast->chip == AST1180) {
53 /* TODO 1180 */ 58 /* TODO 1180 */
54 } else { 59 } else {
55 ch = ast_io_read8(ast, 0x43); 60 ch = ast_io_read8(ast, AST_IO_VGA_ENABLE_PORT);
56 if (ch) { 61 if (ch) {
57 ast_open_key(ast); 62 ast_open_key(ast);
58 ch = ast_get_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xb6, 0xff); 63 ch = ast_get_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xb6, 0xff);
@@ -61,7 +66,6 @@ ast_is_vga_enabled(struct drm_device *dev)
61 } 66 }
62 return 0; 67 return 0;
63} 68}
64#endif
65 69
66static const u8 extreginfo[] = { 0x0f, 0x04, 0x1c, 0xff }; 70static const u8 extreginfo[] = { 0x0f, 0x04, 0x1c, 0xff };
67static const u8 extreginfo_ast2300a0[] = { 0x0f, 0x04, 0x1c, 0xff }; 71static const u8 extreginfo_ast2300a0[] = { 0x0f, 0x04, 0x1c, 0xff };
@@ -371,6 +375,7 @@ void ast_post_gpu(struct drm_device *dev)
371 pci_write_config_dword(ast->dev->pdev, 0x04, reg); 375 pci_write_config_dword(ast->dev->pdev, 0x04, reg);
372 376
373 ast_enable_vga(dev); 377 ast_enable_vga(dev);
378 ast_enable_mmio(dev);
374 ast_open_key(ast); 379 ast_open_key(ast);
375 ast_set_def_ext_reg(dev); 380 ast_set_def_ext_reg(dev);
376 381