1 // SPDX-License-Identifier: MIT 2 /* 3 * Copyright 2012 Red Hat Inc. 4 * 5 * Permission is hereby granted, free of charge, to any person obtaining a 6 * copy of this software and associated documentation files (the 7 * "Software"), to deal in the Software without restriction, including 8 * without limitation the rights to use, copy, modify, merge, publish, 9 * distribute, sub license, and/or sell copies of the Software, and to 10 * permit persons to whom the Software is furnished to do so, subject to 11 * the following conditions: 12 * 13 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL 16 * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, 17 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 18 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 19 * USE OR OTHER DEALINGS IN THE SOFTWARE. 20 * 21 * The above copyright notice and this permission notice (including the 22 * next paragraph) shall be included in all copies or substantial portions 23 * of the Software. 24 */ 25 /* 26 * Authors: Dave Airlie <airlied@redhat.com> 27 */ 28 29 #include <linux/pci.h> 30 31 #include <drm/drm_drv.h> 32 33 #include "ast_drv.h" 34 #include "ast_post.h" 35 36 /* 37 * POST 38 */ 39 40 int ast_2600_post(struct ast_device *ast) 41 { 42 ast_2300_set_def_ext_reg(ast); 43 44 if (ast->tx_chip == AST_TX_ASTDP) 45 return ast_dp_launch(ast); 46 47 return 0; 48 } 49 50 /* 51 * Device initialization 52 */ 53 54 static void ast_2600_detect_widescreen(struct ast_device *ast) 55 { 56 ast->support_wsxga_p = true; 57 ast->support_fullhd = true; 58 if (__ast_2100_detect_wuxga(ast)) 59 ast->support_wuxga = true; 60 } 61 62 struct drm_device *ast_2600_device_create(struct pci_dev *pdev, 63 const struct drm_driver *drv, 64 enum ast_chip chip, 65 enum ast_config_mode config_mode, 66 void __iomem *regs, 67 void __iomem *ioregs, 68 bool need_post) 69 { 70 struct drm_device *dev; 71 struct ast_device *ast; 72 int ret; 73 74 ast = devm_drm_dev_alloc(&pdev->dev, drv, struct ast_device, base); 75 if (IS_ERR(ast)) 76 return ERR_CAST(ast); 77 dev = &ast->base; 78 79 ast_device_init(ast, chip, config_mode, regs, ioregs); 80 81 ast_2300_detect_tx_chip(ast); 82 83 switch (ast->tx_chip) { 84 case AST_TX_ASTDP: 85 ret = ast_post_gpu(ast); 86 break; 87 default: 88 ret = 0; 89 if (need_post) 90 ret = ast_post_gpu(ast); 91 break; 92 } 93 if (ret) 94 return ERR_PTR(ret); 95 96 ret = ast_mm_init(ast); 97 if (ret) 98 return ERR_PTR(ret); 99 100 ast_2600_detect_widescreen(ast); 101 102 ret = ast_mode_config_init(ast); 103 if (ret) 104 return ERR_PTR(ret); 105 106 return dev; 107 } 108