diff options
Diffstat (limited to 'drivers/gpu/drm/ast/ast_main.c')
-rw-r--r-- | drivers/gpu/drm/ast/ast_main.c | 79 |
1 files changed, 71 insertions, 8 deletions
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 | ||
66 | static int ast_detect_chip(struct drm_device *dev) | 66 | static 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) | |||
346 | int ast_driver_load(struct drm_device *dev, unsigned long flags) | 391 | int 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; |