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

Merge branch 'drm-next-ast-fixes' of ssh://people.freedesktop.org/~/linux into drm-next

Pull in first set of changes from Ben for ast on ppc.

I've done a quick boot test on x86 and it still seems to boot.

* 'drm-next-ast-fixes' of ssh://people.freedesktop.org/~/linux:
drm/ast: Cleanup analog init code path
drm/ast: Don't assume DVO enabled means SIL164 on uninitialized chips
drm/ast: Properly initialize P2A base before using it in ast_init_3rdtx()
drm/ast: POST chip at probe time if VGA not enabled
drm/ast: Try to use MMIO registers when PIO isn't supported

+124 -26
+31 -7
drivers/gpu/drm/ast/ast_dp501.c
··· 379 379 return true; 380 380 } 381 381 382 + 383 + static 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 + 382 410 void ast_init_3rdtx(struct drm_device *dev) 383 411 { 384 412 struct ast_private *ast = dev->dev_private; 385 413 u8 jreg; 386 - u32 data; 414 + 387 415 if (ast->chip == AST2300 || ast->chip == AST2400) { 388 416 jreg = ast_get_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xd1, 0xff); 389 417 switch (jreg & 0x0e) { ··· 427 399 default: 428 400 if (ast->tx_chip_type == AST_TX_SIL164) 429 401 ast_init_dvo(dev); 430 - else { 431 - ast_write32(ast, 0x12000, 0x1688a8a8); 432 - data = ast_read32(ast, 0x1202c); 433 - data &= 0xfffcffff; 434 - ast_write32(ast, 0, data); 435 - } 402 + else 403 + ast_init_analog(dev); 436 404 } 437 405 } 438 406 }
+7 -1
drivers/gpu/drm/ast/ast_drv.h
··· 125 125 126 126 #define AST_IO_AR_PORT_WRITE (0x40) 127 127 #define AST_IO_MISC_PORT_WRITE (0x42) 128 + #define AST_IO_VGA_ENABLE_PORT (0x43) 128 129 #define AST_IO_SEQ_PORT (0x44) 129 - #define AST_DAC_INDEX_READ (0x3c7) 130 + #define AST_IO_DAC_INDEX_READ (0x47) 130 131 #define AST_IO_DAC_INDEX_WRITE (0x48) 131 132 #define AST_IO_DAC_DATA (0x49) 132 133 #define AST_IO_GR_PORT (0x4E) 133 134 #define AST_IO_CRTC_PORT (0x54) 134 135 #define AST_IO_INPUT_STATUS1_READ (0x5A) 135 136 #define AST_IO_MISC_PORT_READ (0x4C) 137 + 138 + #define AST_IO_MM_OFFSET (0x380) 136 139 137 140 #define __ast_read(x) \ 138 141 static inline u##x ast_read##x(struct ast_private *ast, u32 reg) { \ ··· 384 381 int ast_mmap(struct file *filp, struct vm_area_struct *vma); 385 382 386 383 /* ast post */ 384 + void ast_enable_vga(struct drm_device *dev); 385 + void ast_enable_mmio(struct drm_device *dev); 386 + bool ast_is_vga_enabled(struct drm_device *dev); 387 387 void ast_post_gpu(struct drm_device *dev); 388 388 u32 ast_mindwm(struct ast_private *ast, u32 r); 389 389 void ast_moutdwm(struct ast_private *ast, u32 r, u32 v);
+72 -9
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; ··· 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 128 switch (ast->chip) { 114 129 case AST1180: 115 130 ast->support_wide_screen = true; ··· 140 125 ast->support_wide_screen = true; 141 126 else { 142 127 ast->support_wide_screen = false; 128 + /* Read SCU7c (silicon revision register) */ 143 129 ast_write32(ast, 0xf004, 0x1e6e0000); 144 130 ast_write32(ast, 0xf000, 0x1); 145 131 data = ast_read32(ast, 0x1207c); ··· 153 137 break; 154 138 } 155 139 140 + /* Check 3rd Tx option (digital output afaik) */ 156 141 ast->tx_chip_type = AST_TX_NONE; 157 - jreg = ast_get_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xa3, 0xff); 158 - if (jreg & 0x80) 159 - ast->tx_chip_type = AST_TX_SIL164; 142 + 143 + /* 144 + * VGACRA3 Enhanced Color Mode Register, check if DVO is already 145 + * enabled, in that case, assume we have a SIL164 TMDS transmitter 146 + * 147 + * Don't make that assumption if we the chip wasn't enabled and 148 + * is at power-on reset, otherwise we'll incorrectly "detect" a 149 + * SIL164 when there is none. 150 + */ 151 + if (!*need_post) { 152 + jreg = ast_get_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xa3, 0xff); 153 + if (jreg & 0x80) 154 + ast->tx_chip_type = AST_TX_SIL164; 155 + } 156 + 160 157 if ((ast->chip == AST2300) || (ast->chip == AST2400)) { 158 + /* 159 + * On AST2300 and 2400, look the configuration set by the SoC in 160 + * the SOC scratch register #1 bits 11:8 (interestingly marked 161 + * as "reserved" in the spec) 162 + */ 161 163 jreg = ast_get_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xd1, 0xff); 162 164 switch (jreg) { 163 165 case 0x04: ··· 196 162 } 197 163 } 198 164 165 + /* Print stuff for diagnostic purposes */ 166 + switch(ast->tx_chip_type) { 167 + case AST_TX_SIL164: 168 + DRM_INFO("Using Sil164 TMDS transmitter\n"); 169 + break; 170 + case AST_TX_DP501: 171 + DRM_INFO("Using DP501 DisplayPort transmitter\n"); 172 + break; 173 + default: 174 + DRM_INFO("Analog VGA only\n"); 175 + } 199 176 return 0; 200 177 } 201 178 ··· 391 346 int ast_driver_load(struct drm_device *dev, unsigned long flags) 392 347 { 393 348 struct ast_private *ast; 349 + bool need_post; 394 350 int ret = 0; 395 351 396 352 ast = kzalloc(sizeof(struct ast_private), GFP_KERNEL); ··· 406 360 ret = -EIO; 407 361 goto out_free; 408 362 } 409 - ast->ioregs = pci_iomap(dev->pdev, 2, 0); 410 - if (!ast->ioregs) { 411 - ret = -EIO; 412 - goto out_free; 363 + 364 + /* 365 + * If we don't have IO space at all, use MMIO now and 366 + * assume the chip has MMIO enabled by default (rev 0x20 367 + * and higher). 368 + */ 369 + if (!(pci_resource_flags(dev->pdev, 2) & IORESOURCE_IO)) { 370 + DRM_INFO("platform has no IO space, trying MMIO\n"); 371 + ast->ioregs = ast->regs + AST_IO_MM_OFFSET; 413 372 } 414 373 415 - ast_detect_chip(dev); 374 + /* "map" IO regs if the above hasn't done so already */ 375 + if (!ast->ioregs) { 376 + ast->ioregs = pci_iomap(dev->pdev, 2, 0); 377 + if (!ast->ioregs) { 378 + ret = -EIO; 379 + goto out_free; 380 + } 381 + } 382 + 383 + ast_detect_chip(dev, &need_post); 416 384 417 385 if (ast->chip != AST1180) { 418 386 ast_get_dram_info(dev); 419 387 ast->vram_size = ast_get_vram_info(dev); 420 388 DRM_INFO("dram %d %d %d %08x\n", ast->mclk, ast->dram_type, ast->dram_bus_width, ast->vram_size); 421 389 } 390 + 391 + if (need_post) 392 + ast_post_gpu(dev); 422 393 423 394 ret = ast_mm_init(ast); 424 395 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