xref: /linux/drivers/gpu/drm/ast/ast_2600.c (revision b1ce4ab06f70fa1dea6b4b6a372aa43989c55897)
1f67fb980SThomas Zimmermann // SPDX-License-Identifier: MIT
2f67fb980SThomas Zimmermann /*
3f67fb980SThomas Zimmermann  * Copyright 2012 Red Hat Inc.
4f67fb980SThomas Zimmermann  *
5f67fb980SThomas Zimmermann  * Permission is hereby granted, free of charge, to any person obtaining a
6f67fb980SThomas Zimmermann  * copy of this software and associated documentation files (the
7f67fb980SThomas Zimmermann  * "Software"), to deal in the Software without restriction, including
8f67fb980SThomas Zimmermann  * without limitation the rights to use, copy, modify, merge, publish,
9f67fb980SThomas Zimmermann  * distribute, sub license, and/or sell copies of the Software, and to
10f67fb980SThomas Zimmermann  * permit persons to whom the Software is furnished to do so, subject to
11f67fb980SThomas Zimmermann  * the following conditions:
12f67fb980SThomas Zimmermann  *
13f67fb980SThomas Zimmermann  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14f67fb980SThomas Zimmermann  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15f67fb980SThomas Zimmermann  * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
16f67fb980SThomas Zimmermann  * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
17f67fb980SThomas Zimmermann  * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
18f67fb980SThomas Zimmermann  * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
19f67fb980SThomas Zimmermann  * USE OR OTHER DEALINGS IN THE SOFTWARE.
20f67fb980SThomas Zimmermann  *
21f67fb980SThomas Zimmermann  * The above copyright notice and this permission notice (including the
22f67fb980SThomas Zimmermann  * next paragraph) shall be included in all copies or substantial portions
23f67fb980SThomas Zimmermann  * of the Software.
24f67fb980SThomas Zimmermann  */
25f67fb980SThomas Zimmermann /*
26f67fb980SThomas Zimmermann  * Authors: Dave Airlie <airlied@redhat.com>
27f67fb980SThomas Zimmermann  */
28f67fb980SThomas Zimmermann 
29f67fb980SThomas Zimmermann #include "ast_drv.h"
30*b1ce4ab0SThomas Zimmermann #include "ast_post.h"
31f67fb980SThomas Zimmermann 
32f67fb980SThomas Zimmermann /*
33f67fb980SThomas Zimmermann  * POST
34f67fb980SThomas Zimmermann  */
35f67fb980SThomas Zimmermann 
36*b1ce4ab0SThomas Zimmermann void ast_2600_set_def_ext_reg(struct ast_device *ast)
37*b1ce4ab0SThomas Zimmermann {
38*b1ce4ab0SThomas Zimmermann 	static const u8 extreginfo[] = { 0x0f, 0x04, 0x1c, 0xff };
39*b1ce4ab0SThomas Zimmermann 	u8 i, index, reg;
40*b1ce4ab0SThomas Zimmermann 	const u8 *ext_reg_info;
41*b1ce4ab0SThomas Zimmermann 
42*b1ce4ab0SThomas Zimmermann 	/* reset scratch */
43*b1ce4ab0SThomas Zimmermann 	for (i = 0x81; i <= 0x9f; i++)
44*b1ce4ab0SThomas Zimmermann 		ast_set_index_reg(ast, AST_IO_VGACRI, i, 0x00);
45*b1ce4ab0SThomas Zimmermann 
46*b1ce4ab0SThomas Zimmermann 	ext_reg_info = extreginfo;
47*b1ce4ab0SThomas Zimmermann 	index = 0xa0;
48*b1ce4ab0SThomas Zimmermann 	while (*ext_reg_info != 0xff) {
49*b1ce4ab0SThomas Zimmermann 		ast_set_index_reg_mask(ast, AST_IO_VGACRI, index, 0x00, *ext_reg_info);
50*b1ce4ab0SThomas Zimmermann 		index++;
51*b1ce4ab0SThomas Zimmermann 		ext_reg_info++;
52*b1ce4ab0SThomas Zimmermann 	}
53*b1ce4ab0SThomas Zimmermann 
54*b1ce4ab0SThomas Zimmermann 	/* disable standard IO/MEM decode if secondary */
55*b1ce4ab0SThomas Zimmermann 	/* ast_set_index_reg-mask(ast, AST_IO_VGACRI, 0xa1, 0xff, 0x3); */
56*b1ce4ab0SThomas Zimmermann 
57*b1ce4ab0SThomas Zimmermann 	/* Set Ext. Default */
58*b1ce4ab0SThomas Zimmermann 	ast_set_index_reg_mask(ast, AST_IO_VGACRI, 0x8c, 0x00, 0x01);
59*b1ce4ab0SThomas Zimmermann 	ast_set_index_reg_mask(ast, AST_IO_VGACRI, 0xb7, 0x00, 0x00);
60*b1ce4ab0SThomas Zimmermann 
61*b1ce4ab0SThomas Zimmermann 	/* Enable RAMDAC for A1 */
62*b1ce4ab0SThomas Zimmermann 	reg = 0x04;
63*b1ce4ab0SThomas Zimmermann 	ast_set_index_reg_mask(ast, AST_IO_VGACRI, 0xb6, 0xff, reg);
64*b1ce4ab0SThomas Zimmermann }
65*b1ce4ab0SThomas Zimmermann 
66f67fb980SThomas Zimmermann int ast_2600_post(struct ast_device *ast)
67f67fb980SThomas Zimmermann {
68*b1ce4ab0SThomas Zimmermann 	ast_2600_set_def_ext_reg(ast);
69*b1ce4ab0SThomas Zimmermann 
70f67fb980SThomas Zimmermann 	if (ast->tx_chip == AST_TX_ASTDP)
71f67fb980SThomas Zimmermann 		return ast_dp_launch(ast);
72f67fb980SThomas Zimmermann 
73f67fb980SThomas Zimmermann 	return 0;
74f67fb980SThomas Zimmermann }
75