// SPDX-License-Identifier: MIT1/*2* Copyright 2012 Red Hat Inc.3*4* Permission is hereby granted, free of charge, to any person obtaining a5* copy of this software and associated documentation files (the6* "Software"), to deal in the Software without restriction, including7* without limitation the rights to use, copy, modify, merge, publish,8* distribute, sub license, and/or sell copies of the Software, and to9* permit persons to whom the Software is furnished to do so, subject to10* the following conditions:11*12* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR13* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,14* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL15* THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,16* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR17* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE18* USE OR OTHER DEALINGS IN THE SOFTWARE.19*20* The above copyright notice and this permission notice (including the21* next paragraph) shall be included in all copies or substantial portions22* of the Software.23*/24/*25* Authors: Dave Airlie <[email protected]>26*/2728#include <linux/pci.h>2930#include <drm/drm_drv.h>3132#include "ast_drv.h"33#include "ast_post.h"3435/*36* POST37*/3839int ast_2600_post(struct ast_device *ast)40{41ast_2300_set_def_ext_reg(ast);4243if (ast->tx_chip == AST_TX_ASTDP)44return ast_dp_launch(ast);4546return 0;47}4849/*50* Device initialization51*/5253static void ast_2600_detect_widescreen(struct ast_device *ast)54{55ast->support_wsxga_p = true;56ast->support_fullhd = true;57if (__ast_2100_detect_wuxga(ast))58ast->support_wuxga = true;59}6061static const struct ast_device_quirks ast_2600_device_quirks = {62.crtc_mem_req_threshold_low = 160,63.crtc_mem_req_threshold_high = 224,64.crtc_hsync_precatch_needed = true,65.crtc_hsync_add4_needed = true,66};6768struct drm_device *ast_2600_device_create(struct pci_dev *pdev,69const struct drm_driver *drv,70enum ast_chip chip,71enum ast_config_mode config_mode,72void __iomem *regs,73void __iomem *ioregs,74bool need_post)75{76struct drm_device *dev;77struct ast_device *ast;78int ret;7980ast = devm_drm_dev_alloc(&pdev->dev, drv, struct ast_device, base);81if (IS_ERR(ast))82return ERR_CAST(ast);83dev = &ast->base;8485ast_device_init(ast, chip, config_mode, regs, ioregs, &ast_2600_device_quirks);8687ast->dclk_table = ast_2500_dclk_table;8889ast_2300_detect_tx_chip(ast);9091switch (ast->tx_chip) {92case AST_TX_ASTDP:93ret = ast_post_gpu(ast);94break;95default:96ret = 0;97if (need_post)98ret = ast_post_gpu(ast);99break;100}101if (ret)102return ERR_PTR(ret);103104ret = ast_mm_init(ast);105if (ret)106return ERR_PTR(ret);107108ast_2600_detect_widescreen(ast);109110ret = ast_mode_config_init(ast);111if (ret)112return ERR_PTR(ret);113114return dev;115}116117118