|
| 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 <[email protected]> |
| 27 | + */ |
| 28 | + |
| 29 | +#include <linux/delay.h> |
| 30 | + |
| 31 | +#include "ast_dram_tables.h" |
| 32 | +#include "ast_drv.h" |
| 33 | + |
| 34 | +/* |
| 35 | + * POST |
| 36 | + */ |
| 37 | + |
| 38 | +static const struct ast_dramstruct ast2000_dram_table_data[] = { |
| 39 | + { 0x0108, 0x00000000 }, |
| 40 | + { 0x0120, 0x00004a21 }, |
| 41 | + { 0xFF00, 0x00000043 }, |
| 42 | + { 0x0000, 0xFFFFFFFF }, |
| 43 | + { 0x0004, 0x00000089 }, |
| 44 | + { 0x0008, 0x22331353 }, |
| 45 | + { 0x000C, 0x0d07000b }, |
| 46 | + { 0x0010, 0x11113333 }, |
| 47 | + { 0x0020, 0x00110350 }, |
| 48 | + { 0x0028, 0x1e0828f0 }, |
| 49 | + { 0x0024, 0x00000001 }, |
| 50 | + { 0x001C, 0x00000000 }, |
| 51 | + { 0x0014, 0x00000003 }, |
| 52 | + { 0xFF00, 0x00000043 }, |
| 53 | + { 0x0018, 0x00000131 }, |
| 54 | + { 0x0014, 0x00000001 }, |
| 55 | + { 0xFF00, 0x00000043 }, |
| 56 | + { 0x0018, 0x00000031 }, |
| 57 | + { 0x0014, 0x00000001 }, |
| 58 | + { 0xFF00, 0x00000043 }, |
| 59 | + { 0x0028, 0x1e0828f1 }, |
| 60 | + { 0x0024, 0x00000003 }, |
| 61 | + { 0x002C, 0x1f0f28fb }, |
| 62 | + { 0x0030, 0xFFFFFE01 }, |
| 63 | + { 0xFFFF, 0xFFFFFFFF } |
| 64 | +}; |
| 65 | + |
| 66 | +static void ast_post_chip_2000(struct ast_device *ast) |
| 67 | +{ |
| 68 | + u8 j; |
| 69 | + u32 temp, i; |
| 70 | + const struct ast_dramstruct *dram_reg_info; |
| 71 | + |
| 72 | + j = ast_get_index_reg_mask(ast, AST_IO_VGACRI, 0xd0, 0xff); |
| 73 | + |
| 74 | + if ((j & 0x80) == 0) { /* VGA only */ |
| 75 | + dram_reg_info = ast2000_dram_table_data; |
| 76 | + ast_write32(ast, 0xf004, 0x1e6e0000); |
| 77 | + ast_write32(ast, 0xf000, 0x1); |
| 78 | + ast_write32(ast, 0x10100, 0xa8); |
| 79 | + |
| 80 | + do { |
| 81 | + ; |
| 82 | + } while (ast_read32(ast, 0x10100) != 0xa8); |
| 83 | + |
| 84 | + while (dram_reg_info->index != 0xffff) { |
| 85 | + if (dram_reg_info->index == 0xff00) {/* delay fn */ |
| 86 | + for (i = 0; i < 15; i++) |
| 87 | + udelay(dram_reg_info->data); |
| 88 | + } else { |
| 89 | + ast_write32(ast, 0x10000 + dram_reg_info->index, |
| 90 | + dram_reg_info->data); |
| 91 | + } |
| 92 | + dram_reg_info++; |
| 93 | + } |
| 94 | + |
| 95 | + temp = ast_read32(ast, 0x10140); |
| 96 | + ast_write32(ast, 0x10140, temp | 0x40); |
| 97 | + } |
| 98 | + |
| 99 | + /* wait ready */ |
| 100 | + do { |
| 101 | + j = ast_get_index_reg_mask(ast, AST_IO_VGACRI, 0xd0, 0xff); |
| 102 | + } while ((j & 0x40) == 0); |
| 103 | +} |
| 104 | + |
| 105 | +int ast_2000_post(struct ast_device *ast) |
| 106 | +{ |
| 107 | + if (ast->config_mode == ast_use_p2a) { |
| 108 | + ast_post_chip_2000(ast); |
| 109 | + } else { |
| 110 | + if (ast->tx_chip == AST_TX_SIL164) { |
| 111 | + /* Enable DVO */ |
| 112 | + ast_set_index_reg_mask(ast, AST_IO_VGACRI, 0xa3, 0xcf, 0x80); |
| 113 | + } |
| 114 | + } |
| 115 | + |
| 116 | + return 0; |
| 117 | +} |
0 commit comments