// 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"3334static void ast_2200_detect_widescreen(struct ast_device *ast)35{36if (__ast_2100_detect_wsxga_p(ast)) {37ast->support_wsxga_p = true;38if (ast->chip == AST2200)39ast->support_fullhd = true;40}41if (__ast_2100_detect_wuxga(ast))42ast->support_wuxga = true;43}4445static const struct ast_device_quirks ast_2200_device_quirks = {46.crtc_mem_req_threshold_low = 47,47.crtc_mem_req_threshold_high = 63,48};4950struct drm_device *ast_2200_device_create(struct pci_dev *pdev,51const struct drm_driver *drv,52enum ast_chip chip,53enum ast_config_mode config_mode,54void __iomem *regs,55void __iomem *ioregs,56bool need_post)57{58struct drm_device *dev;59struct ast_device *ast;60int ret;6162ast = devm_drm_dev_alloc(&pdev->dev, drv, struct ast_device, base);63if (IS_ERR(ast))64return ERR_CAST(ast);65dev = &ast->base;6667ast_device_init(ast, chip, config_mode, regs, ioregs, &ast_2200_device_quirks);6869ast->dclk_table = ast_2000_dclk_table;7071ast_2000_detect_tx_chip(ast, need_post);7273if (need_post) {74ret = ast_post_gpu(ast);75if (ret)76return ERR_PTR(ret);77}7879ret = ast_mm_init(ast);80if (ret)81return ERR_PTR(ret);8283ast_2200_detect_widescreen(ast);8485ret = ast_mode_config_init(ast);86if (ret)87return ERR_PTR(ret);8889return dev;90}91929394