aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/ast/ast_main.c
diff options
context:
space:
mode:
authorBenjamin Herrenschmidt <benh@kernel.crashing.org>2014-09-04 03:50:11 -0400
committerDave Airlie <airlied@redhat.com>2014-09-14 21:37:44 -0400
commitd1b985572a3cf88e99a71fe7b8f294ad9f78f007 (patch)
treee78133fd737c7ed848576c6dcc1584adbc0354d2 /drivers/gpu/drm/ast/ast_main.c
parent0dd68309b9c516eac76549b71f68f01f57bb0c71 (diff)
drm/ast: POST chip at probe time if VGA not enabled
We need to do it on machines without a BIOS such as POWER8. Also for detection to work without triggering PCIe errors, we need to enable VGA early on, inside ast_detect_chip(). While touching those files, replace a few hard coded register numbers with the corresponding symbolic constant. Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org> Signed-off-by: Dave Airlie <airlied@redhat.com>
Diffstat (limited to 'drivers/gpu/drm/ast/ast_main.c')
-rw-r--r--drivers/gpu/drm/ast/ast_main.c47
1 files changed, 45 insertions, 2 deletions
diff --git a/drivers/gpu/drm/ast/ast_main.c b/drivers/gpu/drm/ast/ast_main.c
index c2ff7933a90e..556d065590cc 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;
@@ -109,6 +109,21 @@ static int ast_detect_chip(struct drm_device *dev)
109 } 109 }
110 } 110 }
111 111
112 /*
113 * If VGA isn't enabled, we need to enable now or subsequent
114 * access to the scratch registers will fail. We also inform
115 * our caller that it needs to POST the chip
116 * (Assumption: VGA not enabled -> need to POST)
117 */
118 if (!ast_is_vga_enabled(dev)) {
119 ast_enable_vga(dev);
120 ast_enable_mmio(dev);
121 DRM_INFO("VGA not enabled on entry, requesting chip POST\n");
122 *need_post = true;
123 } else
124 *need_post = false;
125
126 /* Check if we support wide screen */
112 switch (ast->chip) { 127 switch (ast->chip) {
113 case AST1180: 128 case AST1180:
114 ast->support_wide_screen = true; 129 ast->support_wide_screen = true;
@@ -124,6 +139,7 @@ static int ast_detect_chip(struct drm_device *dev)
124 ast->support_wide_screen = true; 139 ast->support_wide_screen = true;
125 else { 140 else {
126 ast->support_wide_screen = false; 141 ast->support_wide_screen = false;
142 /* Read SCU7c (silicon revision register) */
127 ast_write32(ast, 0xf004, 0x1e6e0000); 143 ast_write32(ast, 0xf004, 0x1e6e0000);
128 ast_write32(ast, 0xf000, 0x1); 144 ast_write32(ast, 0xf000, 0x1);
129 data = ast_read32(ast, 0x1207c); 145 data = ast_read32(ast, 0x1207c);
@@ -136,11 +152,23 @@ static int ast_detect_chip(struct drm_device *dev)
136 break; 152 break;
137 } 153 }
138 154
155 /* Check 3rd Tx option (digital output afaik) */
139 ast->tx_chip_type = AST_TX_NONE; 156 ast->tx_chip_type = AST_TX_NONE;
157
158 /*
159 * VGACRA3 Enhanced Color Mode Register, check if DVO is already
160 * enabled, in that case, assume we have a SIL164 TMDS transmitter
161 */
140 jreg = ast_get_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xa3, 0xff); 162 jreg = ast_get_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xa3, 0xff);
141 if (jreg & 0x80) 163 if (jreg & 0x80)
142 ast->tx_chip_type = AST_TX_SIL164; 164 ast->tx_chip_type = AST_TX_SIL164;
165
143 if ((ast->chip == AST2300) || (ast->chip == AST2400)) { 166 if ((ast->chip == AST2300) || (ast->chip == AST2400)) {
167 /*
168 * On AST2300 and 2400, look the configuration set by the SoC in
169 * the SOC scratch register #1 bits 11:8 (interestingly marked
170 * as "reserved" in the spec
171 */
144 jreg = ast_get_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xd1, 0xff); 172 jreg = ast_get_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xd1, 0xff);
145 switch (jreg) { 173 switch (jreg) {
146 case 0x04: 174 case 0x04:
@@ -161,6 +189,17 @@ static int ast_detect_chip(struct drm_device *dev)
161 } 189 }
162 } 190 }
163 191
192 /* Print stuff for diagnostic purposes */
193 switch(ast->tx_chip_type) {
194 case AST_TX_SIL164:
195 DRM_INFO("Using Sil164 TMDS transmitter\n");
196 break;
197 case AST_TX_DP501:
198 DRM_INFO("Using DP501 DisplayPort transmitter\n");
199 break;
200 default:
201 DRM_INFO("Analog VGA only\n");
202 }
164 return 0; 203 return 0;
165} 204}
166 205
@@ -345,6 +384,7 @@ static u32 ast_get_vram_info(struct drm_device *dev)
345int ast_driver_load(struct drm_device *dev, unsigned long flags) 384int ast_driver_load(struct drm_device *dev, unsigned long flags)
346{ 385{
347 struct ast_private *ast; 386 struct ast_private *ast;
387 bool need_post;
348 int ret = 0; 388 int ret = 0;
349 389
350 ast = kzalloc(sizeof(struct ast_private), GFP_KERNEL); 390 ast = kzalloc(sizeof(struct ast_private), GFP_KERNEL);
@@ -379,7 +419,7 @@ int ast_driver_load(struct drm_device *dev, unsigned long flags)
379 } 419 }
380 } 420 }
381 421
382 ast_detect_chip(dev); 422 ast_detect_chip(dev, &need_post);
383 423
384 if (ast->chip != AST1180) { 424 if (ast->chip != AST1180) {
385 ast_get_dram_info(dev); 425 ast_get_dram_info(dev);
@@ -387,6 +427,9 @@ int ast_driver_load(struct drm_device *dev, unsigned long flags)
387 DRM_INFO("dram %d %d %d %08x\n", ast->mclk, ast->dram_type, ast->dram_bus_width, ast->vram_size); 427 DRM_INFO("dram %d %d %d %08x\n", ast->mclk, ast->dram_type, ast->dram_bus_width, ast->vram_size);
388 } 428 }
389 429
430 if (need_post)
431 ast_post_gpu(dev);
432
390 ret = ast_mm_init(ast); 433 ret = ast_mm_init(ast);
391 if (ret) 434 if (ret)
392 goto out_free; 435 goto out_free;