Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Benjamin Herrenschmidt and committed by
Dave Airlie
d1b98557 0dd68309

+62 -11
+3
drivers/gpu/drm/ast/ast_drv.h
··· 384 384 int ast_mmap(struct file *filp, struct vm_area_struct *vma); 385 385 386 386 /* ast post */ 387 + void ast_enable_vga(struct drm_device *dev); 388 + void ast_enable_mmio(struct drm_device *dev); 389 + bool ast_is_vga_enabled(struct drm_device *dev); 387 390 void ast_post_gpu(struct drm_device *dev); 388 391 u32 ast_mindwm(struct ast_private *ast, u32 r); 389 392 void ast_moutdwm(struct ast_private *ast, u32 r, u32 v);
+45 -2
drivers/gpu/drm/ast/ast_main.c
··· 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 68 struct ast_private *ast = dev->dev_private; 69 69 uint32_t data, jreg; ··· 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 127 switch (ast->chip) { 113 128 case AST1180: 114 129 ast->support_wide_screen = true; ··· 139 124 ast->support_wide_screen = true; 140 125 else { 141 126 ast->support_wide_screen = false; 127 + /* Read SCU7c (silicon revision register) */ 142 128 ast_write32(ast, 0xf004, 0x1e6e0000); 143 129 ast_write32(ast, 0xf000, 0x1); 144 130 data = ast_read32(ast, 0x1207c); ··· 152 136 break; 153 137 } 154 138 139 + /* Check 3rd Tx option (digital output afaik) */ 155 140 ast->tx_chip_type = AST_TX_NONE; 141 + 142 + /* 143 + * VGACRA3 Enhanced Color Mode Register, check if DVO is already 144 + * enabled, in that case, assume we have a SIL164 TMDS transmitter 145 + */ 156 146 jreg = ast_get_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xa3, 0xff); 157 147 if (jreg & 0x80) 158 148 ast->tx_chip_type = AST_TX_SIL164; 149 + 159 150 if ((ast->chip == AST2300) || (ast->chip == AST2400)) { 151 + /* 152 + * On AST2300 and 2400, look the configuration set by the SoC in 153 + * the SOC scratch register #1 bits 11:8 (interestingly marked 154 + * as "reserved" in the spec 155 + */ 160 156 jreg = ast_get_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xd1, 0xff); 161 157 switch (jreg) { 162 158 case 0x04: ··· 189 161 } 190 162 } 191 163 164 + /* Print stuff for diagnostic purposes */ 165 + switch(ast->tx_chip_type) { 166 + case AST_TX_SIL164: 167 + DRM_INFO("Using Sil164 TMDS transmitter\n"); 168 + break; 169 + case AST_TX_DP501: 170 + DRM_INFO("Using DP501 DisplayPort transmitter\n"); 171 + break; 172 + default: 173 + DRM_INFO("Analog VGA only\n"); 174 + } 192 175 return 0; 193 176 } 194 177 ··· 384 345 int ast_driver_load(struct drm_device *dev, unsigned long flags) 385 346 { 386 347 struct ast_private *ast; 348 + bool need_post; 387 349 int ret = 0; 388 350 389 351 ast = kzalloc(sizeof(struct ast_private), GFP_KERNEL); ··· 419 379 } 420 380 } 421 381 422 - ast_detect_chip(dev); 382 + ast_detect_chip(dev, &need_post); 423 383 424 384 if (ast->chip != AST1180) { 425 385 ast_get_dram_info(dev); 426 386 ast->vram_size = ast_get_vram_info(dev); 427 387 DRM_INFO("dram %d %d %d %08x\n", ast->mclk, ast->dram_type, ast->dram_bus_width, ast->vram_size); 428 388 } 389 + 390 + if (need_post) 391 + ast_post_gpu(dev); 429 392 430 393 ret = ast_mm_init(ast); 431 394 if (ret)
+14 -9
drivers/gpu/drm/ast/ast_post.c
··· 33 33 34 34 static void ast_init_dram_2300(struct drm_device *dev); 35 35 36 - static void 37 - ast_enable_vga(struct drm_device *dev) 36 + void ast_enable_vga(struct drm_device *dev) 38 37 { 39 38 struct ast_private *ast = dev->dev_private; 40 39 41 - ast_io_write8(ast, 0x43, 0x01); 42 - ast_io_write8(ast, 0x42, 0x01); 40 + ast_io_write8(ast, AST_IO_VGA_ENABLE_PORT, 0x01); 41 + ast_io_write8(ast, AST_IO_MISC_PORT_WRITE, 0x01); 43 42 } 44 43 45 - #if 0 /* will use later */ 46 - static bool 47 - ast_is_vga_enabled(struct drm_device *dev) 44 + void ast_enable_mmio(struct drm_device *dev) 45 + { 46 + struct ast_private *ast = dev->dev_private; 47 + 48 + ast_set_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xa1, 0xff, 0x04); 49 + } 50 + 51 + 52 + bool ast_is_vga_enabled(struct drm_device *dev) 48 53 { 49 54 struct ast_private *ast = dev->dev_private; 50 55 u8 ch; ··· 57 52 if (ast->chip == AST1180) { 58 53 /* TODO 1180 */ 59 54 } else { 60 - ch = ast_io_read8(ast, 0x43); 55 + ch = ast_io_read8(ast, AST_IO_VGA_ENABLE_PORT); 61 56 if (ch) { 62 57 ast_open_key(ast); 63 58 ch = ast_get_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xb6, 0xff); ··· 66 61 } 67 62 return 0; 68 63 } 69 - #endif 70 64 71 65 static const u8 extreginfo[] = { 0x0f, 0x04, 0x1c, 0xff }; 72 66 static const u8 extreginfo_ast2300a0[] = { 0x0f, 0x04, 0x1c, 0xff }; ··· 375 371 pci_write_config_dword(ast->dev->pdev, 0x04, reg); 376 372 377 373 ast_enable_vga(dev); 374 + ast_enable_mmio(dev); 378 375 ast_open_key(ast); 379 376 ast_set_def_ext_reg(dev); 380 377