1 | /*␊ |
2 | * ATI injector␊ |
3 | *␊ |
4 | * Copyright (C) 2009 Jasmin Fazlic, iNDi, netkas␊ |
5 | *␊ |
6 | * ATI injector is free software: you can redistribute it and/or modify␊ |
7 | * it under the terms of the GNU General Public License as published by␊ |
8 | * the Free Software Foundation, either version 3 of the License, or␊ |
9 | * (at your option) any later version.␊ |
10 | *␊ |
11 | * ATI driver and injector is distributed in the hope that it will be useful,␊ |
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of␊ |
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the␊ |
14 | * GNU General Public License for more details.␊ |
15 | *␊ |
16 | * You should have received a copy of the GNU General Public License␊ |
17 | * along with ATI injector. If not, see <http://www.gnu.org/licenses/>.␊ |
18 | */ ␊ |
19 | /*␊ |
20 | * Alternatively you can choose to comply with APSL␊ |
21 | */␊ |
22 | ␊ |
23 | ␊ |
24 | #include "libsaio.h"␊ |
25 | #include "boot.h"␊ |
26 | #include "bootstruct.h"␊ |
27 | #include "pci.h"␊ |
28 | #include "platform.h"␊ |
29 | #include "device_inject.h"␊ |
30 | #include "ati.h"␊ |
31 | ␊ |
32 | #ifndef DEBUG_ATI␊ |
33 | #define DEBUG_ATI 0␊ |
34 | #endif␊ |
35 | ␊ |
36 | #if DEBUG_ATI␊ |
37 | #define DBG(x...)␉printf(x)␊ |
38 | #else␊ |
39 | #define DBG(x...)␊ |
40 | #endif␊ |
41 | ␊ |
42 | #define MAX_NUM_DCB_ENTRIES 16␊ |
43 | ␊ |
44 | #define TYPE_GROUPED 0xff␊ |
45 | ␊ |
46 | extern uint32_t devices_number;␊ |
47 | ␊ |
48 | const char *ati_compatible_0[]␉␉␉= { "@0,compatible", "ATY,%s" };␊ |
49 | const char *ati_compatible_1[]␉␉␉= { "@1,compatible", "ATY,%s" };␊ |
50 | const char *ati_compatible_2[]␉␉␉= { "@2,compatible", "ATY,%s" };␊ |
51 | const char *ati_device_type_0[]␉␉␉= { "@0,device_type", "display" };␊ |
52 | const char *ati_device_type_1[]␉␉␉= { "@1,device_type", "display" };␊ |
53 | const char *ati_device_type_2[]␉␉␉= { "@2,device_type", "display" };␊ |
54 | const char *ati_device_type[]␉␉␉= { "device_type", "ATY,%sParent" };␊ |
55 | const char *ati_name_0[]␉␉␉= { "@0,name", "ATY,%s" };␊ |
56 | const char *ati_name_1[]␉␉␉= { "@1,name", "ATY,%s" };␊ |
57 | const char *ati_name_2[]␉␉␉= { "@2,name", "ATY,%s" };␊ |
58 | const char *ati_name[]␉␉␉␉= { "name", "ATY,%sParent" };␊ |
59 | const char *ati_efidisplay_0[]␉␉␉= { "@0,ATY,EFIDisplay", "TMDSB" };␊ |
60 | struct ati_data_key ati_connector_type_0␉= { 0x04, "@0,connector-type", {0x00, 0x04, 0x00, 0x00} };␊ |
61 | struct ati_data_key ati_connector_type_1␉= { 0x04, "@1,connector-type", {0x04, 0x00, 0x00, 0x00} };␊ |
62 | struct ati_data_key ati_connector_type_2␉= { 0x04, "@2,connector-type", {0x04, 0x00, 0x00, 0x00} };␊ |
63 | struct ati_data_key ati_display_con_fl_type_0␉= { 0x04, "@0,display-connect-flags", {0x00, 0x00, 0x04, 0x00} };␊ |
64 | const char *ati_display_type_0[]␉␉= { "@0,display-type", "LCD" };␊ |
65 | const char *ati_display_type_1[]␉␉= { "@1,display-type", "NONE" };␊ |
66 | const char *ati_display_type_2[]␉␉= { "@2,display-type", "NONE" };␊ |
67 | struct ati_data_key ati_aux_power_conn␉␉= { 0x04, "AAPL,aux-power-connected", {0x01, 0x00, 0x00, 0x00} };␊ |
68 | struct ati_data_key ati_backlight_ctrl␉␉= { 0x04, "AAPL,backlight-control", {0x00, 0x00, 0x00, 0x00} };␊ |
69 | struct ati_data_key ati_aapl01_coher␉␉= { 0x04, "AAPL01,Coherency", {0x01, 0x00, 0x00, 0x00} };␊ |
70 | const char *ati_card_no[]␉␉␉= { "ATY,Card#", "109-B77101-00" };␊ |
71 | const char *ati_copyright[]␉␉␉= { "ATY,Copyright", "Copyright AMD Inc. All Rights Reserved. 2005-2009" };␊ |
72 | const char *ati_efi_compile_d[]␉␉␉= { "ATY,EFICompileDate", "Jan 26 2009" };␊ |
73 | struct ati_data_key ati_efi_disp_conf␉␉= { 0x08, "ATY,EFIDispConfig", {0x45, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01} };␊ |
74 | struct ati_data_key ati_efi_drv_type␉␉= { 0x01, "ATY,EFIDriverType", {0x02} };␊ |
75 | struct ati_data_key ati_efi_enbl_mode␉␉= { 0x01, "ATY,EFIEnabledMode", {0x01} };␊ |
76 | struct ati_data_key ati_efi_init_stat␉␉= { 0x04, "ATY,EFIHWInitStatus", {0x00, 0x00, 0x00, 0x00} };␊ |
77 | struct ati_data_key ati_efi_orientation␉␉= { 0x02, "ATY,EFIOrientation", {0x02, 0x00} };␊ |
78 | const char *ati_efi_version[]␉␉␉= { "ATY,EFIVersion", "01.00.318" };␊ |
79 | const char *ati_efi_versionB[]␉␉␉= { "ATY,EFIVersionB", "113-SBSJ1G04-00R-02" };␊ |
80 | const char *ati_efi_versionE[]␉␉␉= { "ATY,EFIVersionE", "113-B7710A-318" };␊ |
81 | struct ati_data_key ati_mclk␉␉␉= { 0x04, "ATY,MCLK", {0x70, 0x2e, 0x11, 0x00} };␊ |
82 | struct ati_data_key ati_mem_rev_id␉␉= { 0x02, "ATY,MemRevisionID", {0x03, 0x00} };␊ |
83 | struct ati_data_key ati_mem_vend_id␉␉= { 0x02, "ATY,MemVendorID", {0x02, 0x00} };␊ |
84 | const char *ati_mrt[]␉␉␉␉= { "ATY,MRT", " " };␊ |
85 | const char *ati_romno[]␉␉␉␉= { "ATY,Rom#", "113-B7710C-176" };␊ |
86 | struct ati_data_key ati_sclk␉␉␉= { 0x04, "ATY,SCLK", {0x28, 0xdb, 0x0b, 0x00} };␊ |
87 | struct ati_data_key ati_vendor_id␉␉= { 0x02, "ATY,VendorID", {0x02, 0x10} };␊ |
88 | struct ati_data_key ati_platform_info␉␉= { 0x80, "ATY,PlatformInfo", {0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} };␊ |
89 | struct ati_data_key ati_mvad␉␉␉= { 0x40, "MVAD", {0x3f, 0x5c, 0x82, 0x02, 0xff, 0x90, 0x00, 0x54, 0x60, 0x00, 0xac, 0x10, 0xa0, 0x17, 0x00, 0x03, 0xb0, 0x68, 0x00, 0x0a, 0xa0, 0x0a, 0x30, 0x00, 0x20, 0x00, 0x40, 0x06, 0x6e, 0x06, 0x03, 0x00, 0x06, 0x00, 0x40, 0x06, 0x00, 0x0a, 0x10, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x21, 0x00, 0x10, 0x06, 0x92, 0x20, 0x00, 0x03} };␊ |
90 | struct ati_data_key ati_saved_config␉␉= { 0x100, "saved-config", {0x3f, 0x5c, 0x82, 0x02, 0xff, 0x90, 0x00, 0x54, 0x60, 0x00, 0xac, 0x10, 0xa0, 0x17, 0x00, 0x03, 0xb0, 0x68, 0x00, 0x0a, 0xa0, 0x0a, 0x30, 0x00, 0x20, 0x00, 0x40, 0x06, 0x6e, 0x06, 0x03, 0x00, 0x06, 0x00, 0x40, 0x06, 0x00, 0x0a, 0x10, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x21, 0x00, 0x10, 0x06, 0x92, 0x20, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xee, 0x02, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x31, 0x30, 0x50, 0x44, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x32, 0x32, 0x32, 0x01, 0x00, 0x00, 0x00, 0x00, 0x02, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} };␊ |
91 | ///non 48xx keys␊ |
92 | const char *ati_efidisplay_0_n4[]␉␉= { "@0,ATY,EFIDisplay", "TMDSA" };␊ |
93 | struct ati_data_key ati_connector_type_0_n4␉= { 0x04, "@0,connector-type", {0x04, 0x00, 0x00, 0x00} };␊ |
94 | struct ati_data_key ati_connector_type_1_n4␉= { 0x04, "@1,connector-type", {0x00, 0x02, 0x00, 0x00} };␊ |
95 | struct ati_data_key ati_connector_type_2_n4␉= { 0x04, "@2,connector-type", {0x00, 0x02, 0x00, 0x00} };␊ |
96 | struct ati_data_key ati_aapl_emc_disp_list_n4␉= { 0x40, "AAPL,EMC-Display-List", {0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x10, 0x00, 0x00, 0x1b, 0x92, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x10, 0x00, 0x00, 0x1c, 0x92, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x10, 0x00, 0x00, 0x21, 0x92, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} };␊ |
97 | struct ati_data_key ati_fb_offset_n4␉␉= { 0x08, "ATY,FrameBufferOffset", {0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00} };␊ |
98 | struct ati_data_key ati_hwgpio_n4␉␉= { 0x04, "ATY,HWGPIO", {0x23, 0xa8, 0x48, 0x00} };␊ |
99 | struct ati_data_key ati_iospace_offset_n4␉= { 0x08, "ATY,IOSpaceOffset", {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00} };␊ |
100 | struct ati_data_key ati_mclk_n4␉␉␉= { 0x04, "ATY,MCLK", {0x00, 0x35, 0x0c, 0x00} };␊ |
101 | struct ati_data_key ati_sclk_n4␉␉␉= { 0x04, "ATY,SCLK", {0x60, 0xae, 0x0a, 0x00} };␊ |
102 | struct ati_data_key ati_refclk_n4␉␉= { 0x04, "ATY,RefCLK", {0x8c, 0x0a, 0x00, 0x00} };␊ |
103 | struct ati_data_key ati_regspace_offset_n4␉= { 0x08, "ATY,RegisterSpaceOffset", {0x00, 0x00, 0x00, 0x00, 0x90, 0xa2, 0x00, 0x00} };␊ |
104 | struct ati_data_key ati_vram_memsize_0␉␉= { 0x08, "@0,VRAM,memsize", {0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00} };␊ |
105 | struct ati_data_key ati_vram_memsize_1␉␉= { 0x08, "@1,VRAM,memsize", {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} };␊ |
106 | struct ati_data_key ati_vram_memsize_2␉␉= { 0x08, "@2,VRAM,memsize", {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} };␊ |
107 | struct ati_data_key ati_aapl_blackscr_prefs_0_n4= { 0x04, "AAPL00,blackscreen-preferences", {0x00, 0x00, 0x00, 0x00} };␊ |
108 | struct ati_data_key ati_aapl_blackscr_prefs_1_n4= { 0x04, "AAPL01,blackscreen-preferences", {0x00, 0x00, 0x00, 0x00} };␊ |
109 | struct ati_data_key ati_aapl_blackscr_prefs_2_n4= { 0x04, "AAPL02,blackscreen-preferences", {0x00, 0x00, 0x00, 0x00} };␊ |
110 | struct ati_data_key ati_swgpio_info_n4␉␉= { 0x04, "ATY,SWGPIO Info", {0x00, 0x48, 0xa8, 0x23} };␊ |
111 | struct ati_data_key ati_efi_orientation_n4␉= { 0x01, "ATY,EFIOrientation", {0x08} };␊ |
112 | struct ati_data_key ati_mvad_n4␉␉␉= { 0x100, "MVAD", {0x3e, 0x5c, 0x82, 0x00, 0xff, 0x90, 0x00, 0xf6, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x28, 0x3c, 0x80, 0x07, 0x20, 0x08, 0x30, 0x00, 0x20, 0x00, 0xb0, 0x04, 0xd3, 0x04, 0x03, 0x00, 0x06, 0x00, 0xb0, 0x04, 0x80, 0x07, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x90, 0x01, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x31, 0x30, 0x50, 0x44, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x32, 0x32, 0x32, 0x01, 0x00, 0x00, 0x00, 0x00, 0x02, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} };␊ |
113 | struct ati_data_key ati_saved_config_n4␉␉= { 0x100, "saved-config", {0x3e, 0x5c, 0x82, 0x00, 0xff, 0x90, 0x00, 0xf6, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x28, 0x3c, 0x80, 0x07, 0x20, 0x08, 0x30, 0x00, 0x20, 0x00, 0xb0, 0x04, 0xd3, 0x04, 0x03, 0x00, 0x06, 0x00, 0xb0, 0x04, 0x80, 0x07, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x90, 0x01, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x31, 0x30, 0x50, 0x44, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x32, 0x32, 0x32, 0x01, 0x00, 0x00, 0x00, 0x00, 0x02, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} };␊ |
114 | ␊ |
115 | struct pcir_s {␊ |
116 | ␉uint32_t signature;␊ |
117 | ␉uint16_t vid;␊ |
118 | ␉uint16_t devid;␊ |
119 | };␊ |
120 | ␊ |
121 | // Known cards as of 2008/08/26␊ |
122 | static struct ati_chipsets_t ATIKnownChipsets[] = {␊ |
123 | ␉{ 0x00000000, "Unknown" } ,␊ |
124 | ␉{ 0x10029589, "ATI Radeon 2600 Series"} ,␊ |
125 | ␉{ 0x10029588, "ATI Radeon 2600 Series"} ,␊ |
126 | ␉{ 0x100294C3, "ATI Radeon 2400 Series"} ,␊ |
127 | ␉{ 0x100294C4, "ATI Radeon 2400 Series"} ,␊ |
128 | ␉{ 0x100294C6, "ATI Radeon 2400 Series"} ,␊ |
129 | ␉{ 0x10029400, "ATI Radeon 2900 Series"} ,␊ |
130 | ␉{ 0x10029405, "ATI Radeon 2900GT Series"} ,␊ |
131 | ␉{ 0x10029581, "ATI Radeon 2600 Series"} ,␊ |
132 | ␉{ 0x10029583, "ATI Radeon 2600 Series"} ,␊ |
133 | ␉{ 0x10029586, "ATI Radeon 2600 Series"} ,␊ |
134 | ␉{ 0x10029587, "ATI Radeon 2600 Series"} ,␊ |
135 | ␉{ 0x100294C9, "ATI Radeon 2400 Series"} ,␊ |
136 | ␉{ 0x10029501, "ATI Radeon 3800 Series"} ,␊ |
137 | ␉{ 0x10029505, "ATI Radeon 3800 Series"} ,␊ |
138 | ␉{ 0x10029515, "ATI Radeon 3800 Series"} ,␊ |
139 | ␉{ 0x10029507, "ATI Radeon 3800 Series"} ,␊ |
140 | ␉{ 0x10029500, "ATI Radeon 3800 Series"} ,␊ |
141 | ␉{ 0x1002950F, "ATI Radeon 3800X2 Series"} ,␊ |
142 | ␉{ 0x100295C5, "ATI Radeon 3400 Series"} ,␊ |
143 | ␉{ 0x100295C7, "ATI Radeon 3400 Series"} ,␊ |
144 | ␉{ 0x100295C0, "ATI Radeon 3400 Series"} ,␊ |
145 | ␉{ 0x10029596, "ATI Radeon 3600 Series"} ,␊ |
146 | ␉{ 0x10029590, "ATI Radeon 3600 Series"} ,␊ |
147 | ␉{ 0x10029599, "ATI Radeon 3600 Series"} ,␊ |
148 | ␉{ 0x10029597, "ATI Radeon 3600 Series"} ,␊ |
149 | ␉{ 0x10029598, "ATI Radeon 3600 Series"} ,␊ |
150 | ␉{ 0x10029442, "ATI Radeon 4850 Series"} ,␊ |
151 | ␉{ 0x10029440, "ATI Radeon 4870 Series"} ,␊ |
152 | ␉{ 0x1002944C, "ATI Radeon 4830 Series"} ,␊ |
153 | ␉{ 0x10029460, "ATI Radeon 4890 Series"} ,␊ |
154 | ␉{ 0x10029462, "ATI Radeon 4890 Series"} ,␊ |
155 | ␉{ 0x10029441, "ATI Radeon 4870X2 Series"} ,␊ |
156 | ␉{ 0x10029443, "ATI Radeon 4850X2 Series"} ,␊ |
157 | ␉{ 0x10029444, "ATI Radeon 4800 Series"} ,␊ |
158 | ␉{ 0x10029446, "ATI Radeon 4800 Series"} ,␊ |
159 | ␉{ 0x1002944E, "ATI Radeon 4730 Series"} ,␊ |
160 | ␉{ 0x10029450, "ATI Radeon 4800 Series"} ,␊ |
161 | ␉{ 0x10029452, "ATI Radeon 4800 Series"} ,␉␉␊ |
162 | ␉{ 0x10029456, "ATI Radeon 4800 Series"} ,␉␉␊ |
163 | ␉{ 0x1002944A, "ATI Radeon 4800 Mobility Series"} ,␊ |
164 | ␉{ 0x1002945A, "ATI Radeon 4800 Mobility Series"} ,␊ |
165 | ␉{ 0x1002945B, "ATI Radeon 4800 Mobility Series"} ,␊ |
166 | ␉{ 0x1002944B, "ATI Radeon 4800 Mobility Series"} ,␊ |
167 | { 0x10029490, "ATI Radeon 4670 Series"} ,␊ |
168 | { 0x10029498, "ATI Radeon 4650 Series"} ,␊ |
169 | ␉{ 0x10029490, "ATI Radeon 4600 Series"} ,␊ |
170 | ␉{ 0x10029498, "ATI Radeon 4600 Series"} ,␊ |
171 | ␉{ 0x1002949E, "ATI Radeon 4600 Series"} ,␊ |
172 | ␉{ 0x10029480, "ATI Radeon 4600 Series"} ,␊ |
173 | ␉{ 0x10029488, "ATI Radeon 4600 Series"} ,␊ |
174 | ␉{ 0x10029540, "ATI Radeon 4500 Series"} ,␊ |
175 | ␉{ 0x10029541, "ATI Radeon 4500 Series"} ,␊ |
176 | ␉{ 0x1002954E, "ATI Radeon 4500 Series"} ,␊ |
177 | ␉{ 0x10029552, "ATI Radeon 4300 Mobility Series"} ,␊ |
178 | ␉{ 0x10029553, "ATI Radeon 4500 Mobility Series"} ,␊ |
179 | ␉{ 0x1002954F, "ATI Radeon 4300 Series"} ,␊ |
180 | { 0x100294B3, "ATI Radeon 4770 Series"} ,␊ |
181 | { 0x100294B5, "ATI Radeon 4770 Series"} ,␊ |
182 | ␉{ 0x100268F9, "ATI Radeon HD 5400"} , ␊ |
183 | ␉{ 0x100268D9, "ATI Radeon HD 5500"} ,␊ |
184 | ␉{ 0x100268DA, "ATI Radeon HD 5500"} ,␊ |
185 | ␉{ 0x100268D8, "ATI Radeon HD 5670"} ,␊ |
186 | /*␊ |
187 | { 0x100268B8, "ATI Radeon 5700 Series"} ,␊ |
188 | { 0x100268BE, "ATI Radeon 5700 Series"} ,␊ |
189 | */␊ |
190 | ␉{ 0x100268BE, "ATI Radeon HD 5750"} ,␊ |
191 | ␉{ 0x100268B8, "ATI Radeon HD 5770"} ,␊ |
192 | { 0x10026898, "ATI Radeon 5800 Series"} ,␊ |
193 | /* { 0x10026899, "ATI Radeon 5800 Series"} ,*/␊ |
194 | ␉{ 0x10026899, "ATI Radeon HD 5850"} ,␊ |
195 | ␉{ 0x1002689E, "ATI Radeon HD 5830"} ,␊ |
196 | ␉{ 0x10026898, "ATI Radeon HD 5870"} ,␊ |
197 | ␉{ 0x1002689C, "ATI Radeon HD 5970"} ,␊ |
198 | ␉{ 0x24511682,␉"ATI Radeon HD 4650"} ,␊ |
199 | ␉{ 0x24521682,␉"ATI Radeon HD 4650"} ,␊ |
200 | ␉{ 0x24541682,␉"ATI Radeon HD 4650"}␊ |
201 | };␊ |
202 | ␊ |
203 | static struct ati_chipsets_t ATIKnownFramebuffers[] = {␊ |
204 | ␉{ 0x00000000, "Megalodon" },␊ |
205 | ␉{ 0x10029589, "Lamna"} ,␊ |
206 | ␉{ 0x10029588, "Lamna"} ,␊ |
207 | ␉{ 0x100294C3, "Iago"} ,␊ |
208 | ␉{ 0x100294C4, "Iago"} ,␊ |
209 | ␉{ 0x100294C6, "Iago"} ,␊ |
210 | ␉{ 0x10029400, "Franklin"} ,␊ |
211 | ␉{ 0x10029405, "Franklin"} ,␊ |
212 | ␉{ 0x10029581, "Hypoprion"} ,␊ |
213 | ␉{ 0x10029583, "Hypoprion"} ,␊ |
214 | ␉{ 0x10029586, "Hypoprion"} ,␊ |
215 | ␉{ 0x10029587, "Hypoprion"} ,␊ |
216 | ␉{ 0x100294C9, "Iago"} ,␊ |
217 | ␉{ 0x10029501, "Megalodon"} ,␊ |
218 | ␉{ 0x10029505, "Megalodon"} ,␊ |
219 | ␉{ 0x10029515, "Megalodon"} ,␊ |
220 | ␉{ 0x10029507, "Megalodon"} ,␊ |
221 | ␉{ 0x10029500, "Megalodon"} ,␊ |
222 | ␉{ 0x1002950F, "Triakis"} ,␊ |
223 | ␉{ 0x100295C5, "Iago"} ,␊ |
224 | ␉{ 0x100295C7, "Iago"} ,␊ |
225 | ␉{ 0x100295C0, "Iago"} ,␊ |
226 | ␉{ 0x10029596, "Megalodon"} ,␊ |
227 | ␉{ 0x10029590, "Megalodon"} ,␊ |
228 | ␉{ 0x10029599, "Megalodon"} ,␊ |
229 | ␉{ 0x10029597, "Megalodon"} ,␊ |
230 | ␉{ 0x10029598, "Megalodon"} ,␊ |
231 | ␉{ 0x10029442, "Motmot"} ,␊ |
232 | ␉{ 0x10029440, "Motmot"} ,␊ |
233 | ␉{ 0x1002944C, "Motmot"} ,␊ |
234 | ␉{ 0x10029460, "Motmot"} ,␊ |
235 | ␉{ 0x10029462, "Motmot"} ,␊ |
236 | ␉{ 0x10029441, "Motmot"} ,␊ |
237 | ␉{ 0x10029443, "Motmot"} ,␊ |
238 | ␉{ 0x10029444, "Motmot"} ,␊ |
239 | ␉{ 0x10029446, "Motmot"} ,␊ |
240 | ␉{ 0x1002944E, "Motmot"} ,␊ |
241 | ␉{ 0x10029450, "Motmot"} ,␊ |
242 | ␉{ 0x10029452, "Motmot"} ,␉␉␊ |
243 | ␉{ 0x10029456, "Motmot"} ,␉␉␊ |
244 | ␉{ 0x1002944A, "Motmot"} ,␊ |
245 | ␉{ 0x1002945A, "Motmot"} ,␊ |
246 | ␉{ 0x1002945B, "Motmot"} ,␊ |
247 | ␉{ 0x1002944B, "Motmot"} ,␊ |
248 | { 0x10029490, "Peregrine"} ,␊ |
249 | { 0x10029498, "Peregrine"} ,␊ |
250 | { 0x1002949E, "Peregrine"} ,␊ |
251 | { 0x10029480, "Peregrine"} ,␊ |
252 | { 0x10029488, "Peregrine"} ,␊ |
253 | { 0x10029540, "Peregrine"} ,␊ |
254 | { 0x10029541, "Peregrine"} ,␊ |
255 | { 0x1002954E, "Peregrine"} ,␊ |
256 | { 0x10029552, "Peregrine"} ,␊ |
257 | { 0x10029553, "Peregrine"} ,␊ |
258 | { 0x1002954F, "Peregrine"} ,␊ |
259 | { 0x100294B3, "Peregrine"} ,␊ |
260 | { 0x100294B5, "Peregrine"} ,␊ |
261 | { 0x10026898, "Uakari"} ,␊ |
262 | { 0x10026899, "Uakari"} ,␊ |
263 | ␉{ 0x1002689C, "Uakari"} ,␊ |
264 | ␉{ 0x1002689E, "Zonalis"} ,␊ |
265 | { 0x100268B8, "Vervet"} ,␊ |
266 | { 0x100268BE, "Vervet"} ,␊ |
267 | ␉{ 0x100268D8, "Baboon"} ,␊ |
268 | ␉{ 0x100268D9, "Zonalis"} ,␊ |
269 | ␉{ 0x100268DA, "Zonalis"} ,␊ |
270 | ␉{ 0x100268F9, "Zonalis"}␊ |
271 | };␊ |
272 | ␊ |
273 | static uint32_t accessROM(pci_dt_t *ati_dev, unsigned int mode)␊ |
274 | {␊ |
275 | ␉uint32_t␉␉bar[7];␊ |
276 | ␉volatile uint32_t␉*regs;␊ |
277 | ␊ |
278 | ␉bar[2] = pci_config_read32(ati_dev->dev.addr, 0x18 );␊ |
279 | ␉regs = (uint32_t *) (bar[2] & ~0x0f);␊ |
280 | ␊ |
281 | ␉if (mode) {␊ |
282 | ␉␉if (mode != 1) {␊ |
283 | ␉␉␉return 0xe00002c7;␊ |
284 | ␉␉}␊ |
285 | ␉␉REG32W(0x179c, 0x00080000);␊ |
286 | ␉␉REG32W(0x1798, 0x00080721);␊ |
287 | ␉␉REG32W(0x17a0, 0x00080621);␊ |
288 | ␉␉REG32W(0x1600, 0x14030300);␊ |
289 | ␉␉REG32W(0x1798, 0x21);␊ |
290 | ␉␉REG32W(0x17a0, 0x21);␊ |
291 | ␉␉REG32W(0x179c, 0x00);␊ |
292 | ␉␉REG32W(0x17a0, 0x21);␊ |
293 | ␉␉REG32W(0x1798, 0x21);␊ |
294 | ␉␉REG32W(0x1798, 0x21);␊ |
295 | ␉} else {␊ |
296 | ␉␉REG32W(0x1600, 0x14030302);␉␊ |
297 | ␉␉REG32W(0x1798, 0x21);␊ |
298 | ␉␉REG32W(0x17a0, 0x21);␊ |
299 | ␉␉REG32W(0x179c, 0x00080000);␊ |
300 | ␉␉REG32W(0x17a0, 0x00080621);␊ |
301 | ␉␉REG32W(0x1798, 0x00080721);␊ |
302 | ␉␉REG32W(0x1798, 0x21);␊ |
303 | ␉␉REG32W(0x17a0, 0x21);␊ |
304 | ␉␉REG32W(0x179c, 0x00);␊ |
305 | ␉␉REG32W(0x1604, 0x0400e9fc);␊ |
306 | ␉␉REG32W(0x161c, 0x00);␊ |
307 | ␉␉REG32W(0x1620, 0x9f);␊ |
308 | ␉␉REG32W(0x1618, 0x00040004);␊ |
309 | ␉␉REG32W(0x161c, 0x00);␊ |
310 | ␉␉REG32W(0x1604, 0xe9fc);␊ |
311 | ␉␉REG32W(0x179c, 0x00080000);␊ |
312 | ␉␉REG32W(0x1798, 0x00080721);␊ |
313 | ␉␉REG32W(0x17a0, 0x00080621);␊ |
314 | ␉␉REG32W(0x1798, 0x21);␊ |
315 | ␉␉REG32W(0x17a0, 0x21);␊ |
316 | ␉␉REG32W(0x179c, 0x00);␊ |
317 | ␉}␊ |
318 | ␉return 0;␊ |
319 | }␊ |
320 | ␊ |
321 | static uint8_t *readAtomBIOS(pci_dt_t *ati_dev)␊ |
322 | {␊ |
323 | ␉uint32_t␉␉bar[7];␊ |
324 | ␉uint32_t␉␉*BIOSBase;␊ |
325 | ␉uint32_t␉␉counter;␊ |
326 | ␉volatile uint32_t␉*regs;␊ |
327 | ␊ |
328 | ␉bar[2] = pci_config_read32(ati_dev->dev.addr, 0x18 );␊ |
329 | ␉regs = (volatile uint32_t *) (bar[2] & ~0x0f);␊ |
330 | ␉accessROM(ati_dev, 0);␊ |
331 | ␉REG32W(0xa8, 0);␊ |
332 | ␉REG32R(0xac);␊ |
333 | ␉REG32W(0xa8, 0);␊ |
334 | ␉REG32R(0xac);␉␊ |
335 | ␊ |
336 | ␉BIOSBase = malloc(0x10000);␊ |
337 | ␉REG32W(0xa8, 0);␊ |
338 | ␉BIOSBase[0] = REG32R(0xac);␊ |
339 | ␉counter = 4;␊ |
340 | ␉do {␊ |
341 | ␉␉REG32W(0xa8, counter);␊ |
342 | ␉␉BIOSBase[counter/4] = REG32R(0xac);␊ |
343 | ␉␉counter +=4;␊ |
344 | ␉} while (counter != 0x10000);␊ |
345 | ␉accessROM((pci_dt_t *)regs, 1);␊ |
346 | ␊ |
347 | ␉if (*(uint16_t *)BIOSBase != 0xAA55) {␊ |
348 | ␉␉printf("Wrong BIOS signature: %04x\n", *(uint16_t *)BIOSBase);␊ |
349 | ␉␉return 0;␊ |
350 | ␉}␊ |
351 | ␉return (uint8_t *)BIOSBase;␊ |
352 | }␊ |
353 | ␊ |
354 | #define R5XX_CONFIG_MEMSIZE␉0x00F8␊ |
355 | #define R6XX_CONFIG_MEMSIZE␉0x5428␊ |
356 | ␊ |
357 | uint32_t getvramsizekb(pci_dt_t *ati_dev)␊ |
358 | {␊ |
359 | ␉uint32_t␉␉bar[7];␊ |
360 | ␉uint32_t␉␉size;␊ |
361 | ␉volatile uint32_t␉*regs;␊ |
362 | ␊ |
363 | ␉bar[2] = pci_config_read32(ati_dev->dev.addr, 0x18 );␊ |
364 | ␉regs = (uint32_t *) (bar[2] & ~0x0f);␊ |
365 | ␉if (ati_dev->device_id < 0x9400) {␊ |
366 | ␉␉size = (REG32R(R5XX_CONFIG_MEMSIZE)) >> 10;␊ |
367 | ␉} else {␊ |
368 | ␉␉size = (REG32R(R6XX_CONFIG_MEMSIZE)) >> 10;␊ |
369 | ␉}␊ |
370 | ␉return size;␊ |
371 | }␊ |
372 | ␊ |
373 | #define AVIVO_D1CRTC_CONTROL␉0x6080␊ |
374 | #define AVIVO_CRTC_EN␉␉(1<<0)␊ |
375 | #define AVIVO_D2CRTC_CONTROL␉0x6880␊ |
376 | ␊ |
377 | static bool radeon_card_posted(pci_dt_t *ati_dev)␊ |
378 | {␊ |
379 | ␉// if devid matches biosimage(from legacy) devid - posted card, fails with X2/crossfire cards.␊ |
380 | /*␉char *biosimage = 0xC0000;␊ |
381 | ␉␊ |
382 | ␉if ((uint8_t)biosimage[0] == 0x55 && (uint8_t)biosimage[1] == 0xaa)␊ |
383 | ␉{␊ |
384 | ␉␉struct pci_rom_pci_header_t *rom_pci_header; ␊ |
385 | ␉␉rom_pci_header = (struct pci_rom_pci_header_t*)(biosimage + (uint8_t)biosimage[24] + (uint8_t)biosimage[25]*256);␊ |
386 | ␉␊ |
387 | ␉if (rom_pci_header->signature == 0x52494350)␊ |
388 | ␉␉{␊ |
389 | ␉␉if (rom_pci_header->device == ati_dev->device_id)␊ |
390 | ␉␉␉{␊ |
391 | ␉␉␉␉return true;␊ |
392 | ␉␉␉␉printf("Card was POSTed\n");␊ |
393 | ␉␉␉}␊ |
394 | ␉␉}␊ |
395 | ␉}␊ |
396 | ␉return false;␊ |
397 | ␉printf("Card was not POSTed\n");␊ |
398 | ␉*/␊ |
399 | ␉//fails yet␊ |
400 | ␉uint32_t␉␉bar[7];␊ |
401 | ␉uint32_t␉␉val;␊ |
402 | ␉volatile uint32_t␉*regs;␊ |
403 | ␊ |
404 | ␉bar[2] = pci_config_read32(ati_dev->dev.addr, 0x18);␊ |
405 | ␉regs = (uint32_t *) (bar[2] & ~0x0f);␊ |
406 | ␊ |
407 | ␉val = REG32R(AVIVO_D1CRTC_CONTROL) | REG32R(AVIVO_D2CRTC_CONTROL);␊ |
408 | ␉if (val & AVIVO_CRTC_EN) {␊ |
409 | ␉␉return true;␊ |
410 | ␉} else {␊ |
411 | ␉␉return false;␊ |
412 | ␉}␊ |
413 | }␊ |
414 | ␊ |
415 | static uint32_t load_ati_bios_file(const char *filename, uint8_t *buf, int bufsize)␊ |
416 | {␊ |
417 | ␉int␉fd;␊ |
418 | ␉int␉size;␊ |
419 | ␊ |
420 | ␉if ((fd = open_bvdev("bt(0,0)", filename, 0)) < 0) {␊ |
421 | ␉␉return 0;␊ |
422 | ␉}␊ |
423 | ␉size = file_size(fd);␊ |
424 | ␉if (size > bufsize) {␊ |
425 | ␉␉printf("Filesize of %s is bigger than expected! Truncating to 0x%x Bytes!\n", filename, bufsize);␊ |
426 | ␉␉size = bufsize;␊ |
427 | ␉}␊ |
428 | ␉size = read(fd, (char *)buf, size);␊ |
429 | ␉close(fd);␊ |
430 | ␉return size > 0 ? size : 0;␊ |
431 | }␊ |
432 | ␊ |
433 | static char *get_ati_model(uint32_t id)␊ |
434 | {␊ |
435 | ␉int␉i;␊ |
436 | ␊ |
437 | ␉for (i=0; i< (sizeof(ATIKnownChipsets) / sizeof(ATIKnownChipsets[0])); i++) {␊ |
438 | ␉␉if (ATIKnownChipsets[i].device == id) {␊ |
439 | ␉␉␉return ATIKnownChipsets[i].name;␊ |
440 | ␉␉}␊ |
441 | ␉}␊ |
442 | ␉return ATIKnownChipsets[0].name;␊ |
443 | }␊ |
444 | ␊ |
445 | static char *get_ati_fb(uint32_t id)␊ |
446 | {␊ |
447 | ␉int␉i;␊ |
448 | ␊ |
449 | ␉for (i=0; i< (sizeof(ATIKnownFramebuffers) / sizeof(ATIKnownFramebuffers[0])); i++) {␊ |
450 | ␉␉if (ATIKnownFramebuffers[i].device == id) {␊ |
451 | ␉␉␉return ATIKnownFramebuffers[i].name;␊ |
452 | ␉␉}␊ |
453 | ␉}␊ |
454 | ␉return ATIKnownFramebuffers[0].name;␊ |
455 | }␊ |
456 | ␊ |
457 | static int devprop_add_iopciconfigspace(struct DevPropDevice *device, pci_dt_t *ati_dev)␊ |
458 | {␊ |
459 | ␉int␉i;␊ |
460 | ␉uint8_t␉*config_space;␊ |
461 | ␊ |
462 | ␉if (!device || !ati_dev) {␊ |
463 | ␉␉return 0;␊ |
464 | ␉}␊ |
465 | ␉printf("dumping pci config space, 256 bytes\n");␊ |
466 | ␉config_space = malloc(256);␊ |
467 | ␉for (i=0; i<=255; i++) {␊ |
468 | ␉␉config_space[i] = pci_config_read8( ati_dev->dev.addr, i);␊ |
469 | ␉}␊ |
470 | ␉devprop_add_value(device, "ATY,PCIConfigSpace", config_space, 256);␊ |
471 | ␉free (config_space);␊ |
472 | ␉return 1;␊ |
473 | }␊ |
474 | ␊ |
475 | static int devprop_add_ati_template_4xxx(struct DevPropDevice *device)␊ |
476 | {␊ |
477 | ␉if(!device)␊ |
478 | ␉␉return 0;␊ |
479 | ␉␊ |
480 | //␉if(!DP_ADD_TEMP_VAL(device, ati_compatible_0))␊ |
481 | //␉␉return 0;␊ |
482 | //␉if(!DP_ADD_TEMP_VAL(device, ati_compatible_1))␊ |
483 | //␉␉return 0;␊ |
484 | ␉if(!DP_ADD_TEMP_VAL(device, ati_device_type_0))␊ |
485 | ␉␉return 0;␊ |
486 | ␉if(!DP_ADD_TEMP_VAL(device, ati_device_type_1))␊ |
487 | ␉␉return 0;␊ |
488 | ␉if(!DP_ADD_TEMP_VAL(device, ati_device_type_2))␊ |
489 | ␉␉return 0;␊ |
490 | //␉if(!DP_ADD_TEMP_VAL(device, ati_device_type))␊ |
491 | //␉␉return 0;␊ |
492 | //␉if(!DP_ADD_TEMP_VAL(device, ati_name_0))␊ |
493 | //␉␉return 0;␊ |
494 | //␉if(!DP_ADD_TEMP_VAL(device, ati_name_1))␊ |
495 | //␉␉return 0;␊ |
496 | //␉if(!DP_ADD_TEMP_VAL(device, ati_name))␊ |
497 | //␉␉return 0;␊ |
498 | ␉if(!DP_ADD_TEMP_VAL(device, ati_efidisplay_0))␊ |
499 | ␉␉return 0;␊ |
500 | ␉if(!DP_ADD_TEMP_VAL(device, ati_display_type_0))␊ |
501 | ␉␉return 0;␊ |
502 | ␉if(!DP_ADD_TEMP_VAL(device, ati_display_type_1))␊ |
503 | ␉␉return 0;␊ |
504 | ␉if(!DP_ADD_TEMP_VAL(device, ati_display_type_2))␊ |
505 | ␉␉return 0;␉␊ |
506 | //␉if(!DP_ADD_TEMP_VAL(device, ati_slot_name))␊ |
507 | //␉␉return 0;␊ |
508 | ␉if(!DP_ADD_TEMP_VAL(device, ati_card_no))␊ |
509 | ␉␉return 0;␊ |
510 | ␉if(!DP_ADD_TEMP_VAL(device, ati_copyright))␊ |
511 | ␉␉return 0;␊ |
512 | ␉if(!DP_ADD_TEMP_VAL(device, ati_efi_compile_d))␊ |
513 | ␉␉return 0;␊ |
514 | ␉if(!DP_ADD_TEMP_VAL(device, ati_efi_version))␊ |
515 | ␉␉return 0;␊ |
516 | ␉if(!DP_ADD_TEMP_VAL(device, ati_efi_versionB))␊ |
517 | ␉␉return 0;␊ |
518 | ␉if(!DP_ADD_TEMP_VAL(device, ati_efi_versionE))␊ |
519 | ␉␉return 0;␊ |
520 | ␉if(!DP_ADD_TEMP_VAL(device, ati_mrt))␊ |
521 | ␉␉return 0;␊ |
522 | ␉if(!DP_ADD_TEMP_VAL(device, ati_romno))␊ |
523 | ␉␉return 0;␊ |
524 | ␉if(!DP_ADD_TEMP_VAL(device, ati_name_1))␊ |
525 | ␉␉return 0;␊ |
526 | ␉if(!DP_ADD_TEMP_VAL_DATA(device, ati_connector_type_0))␊ |
527 | ␉␉return 0;␊ |
528 | ␉if(!DP_ADD_TEMP_VAL_DATA(device, ati_connector_type_1))␊ |
529 | ␉␉return 0;␊ |
530 | ␉if(!DP_ADD_TEMP_VAL_DATA(device, ati_connector_type_2))␊ |
531 | ␉␉return 0;␉␊ |
532 | ␉if(!DP_ADD_TEMP_VAL_DATA(device, ati_display_con_fl_type_0))␊ |
533 | ␉␉return 0;␊ |
534 | ␉if(!DP_ADD_TEMP_VAL_DATA(device, ati_aux_power_conn))␊ |
535 | ␉␉return 0;␊ |
536 | ␉if(!DP_ADD_TEMP_VAL_DATA(device, ati_backlight_ctrl))␊ |
537 | ␉␉return 0;␊ |
538 | ␉if(!DP_ADD_TEMP_VAL_DATA(device, ati_aapl01_coher))␊ |
539 | ␉␉return 0;␊ |
540 | ␉if(!DP_ADD_TEMP_VAL_DATA(device, ati_efi_disp_conf))␊ |
541 | ␉␉return 0;␊ |
542 | ␉if(!DP_ADD_TEMP_VAL_DATA(device, ati_efi_drv_type))␊ |
543 | ␉␉return 0;␊ |
544 | ␉if(!DP_ADD_TEMP_VAL_DATA(device, ati_efi_enbl_mode))␊ |
545 | ␉␉return 0;␊ |
546 | ␉if(!DP_ADD_TEMP_VAL_DATA(device, ati_efi_init_stat))␊ |
547 | ␉␉return 0;␊ |
548 | ␉if(!DP_ADD_TEMP_VAL_DATA(device, ati_efi_orientation))␊ |
549 | ␉␉return 0;␊ |
550 | ␉if(!DP_ADD_TEMP_VAL_DATA(device, ati_mclk))␊ |
551 | ␉␉return 0;␊ |
552 | ␉if(!DP_ADD_TEMP_VAL_DATA(device, ati_mem_rev_id))␊ |
553 | ␉␉return 0;␊ |
554 | ␉if(!DP_ADD_TEMP_VAL_DATA(device, ati_mem_vend_id))␊ |
555 | ␉␉return 0;␊ |
556 | ␉if(!DP_ADD_TEMP_VAL_DATA(device, ati_sclk))␊ |
557 | ␉␉return 0;␊ |
558 | ␉if(!DP_ADD_TEMP_VAL_DATA(device, ati_vendor_id))␊ |
559 | ␉␉return 0;␊ |
560 | ␉if(!DP_ADD_TEMP_VAL_DATA(device, ati_platform_info))␊ |
561 | ␉␉return 0;␊ |
562 | ␉if(!DP_ADD_TEMP_VAL_DATA(device, ati_mvad))␊ |
563 | ␉␉return 0;␊ |
564 | ␉if(!DP_ADD_TEMP_VAL_DATA(device, ati_saved_config))␊ |
565 | ␉␉return 0;␊ |
566 | ␉return 1;␊ |
567 | }␊ |
568 | ␊ |
569 | static int devprop_add_ati_template(struct DevPropDevice *device)␊ |
570 | {␊ |
571 | ␉if(!device)␊ |
572 | ␉␉return 0;␊ |
573 | ␊ |
574 | ␉if(!DP_ADD_TEMP_VAL_DATA(device, ati_platform_info))␊ |
575 | ␉␉return 0;␉␊ |
576 | ␉if(!DP_ADD_TEMP_VAL(device, ati_device_type_0))␊ |
577 | ␉␉return 0;␊ |
578 | ␉if(!DP_ADD_TEMP_VAL(device, ati_device_type_1))␊ |
579 | ␉␉return 0;␊ |
580 | ␉if(!DP_ADD_TEMP_VAL(device, ati_device_type_2))␊ |
581 | ␉␉return 0;␉␉␊ |
582 | ␉if(!DP_ADD_TEMP_VAL(device, ati_efidisplay_0_n4))␊ |
583 | ␉␉return 0;␊ |
584 | //␉if(!DP_ADD_TEMP_VAL(device, ati_slot_name_n4))␊ |
585 | //␉␉return 0;␊ |
586 | ␉if(!DP_ADD_TEMP_VAL(device, ati_card_no))␊ |
587 | ␉␉return 0;␊ |
588 | ␉if(!DP_ADD_TEMP_VAL(device, ati_copyright))␊ |
589 | ␉␉return 0;␊ |
590 | ␉if(!DP_ADD_TEMP_VAL(device, ati_efi_compile_d))␊ |
591 | ␉␉return 0;␊ |
592 | ␉if(!DP_ADD_TEMP_VAL(device, ati_efi_version))␊ |
593 | ␉␉return 0;␊ |
594 | ␉if(!DP_ADD_TEMP_VAL(device, ati_efi_versionB))␊ |
595 | ␉␉return 0;␊ |
596 | ␉if(!DP_ADD_TEMP_VAL(device, ati_efi_versionE))␊ |
597 | ␉␉return 0;␊ |
598 | ␉if(!DP_ADD_TEMP_VAL(device, ati_mrt))␊ |
599 | ␉␉return 0;␊ |
600 | ␉if(!DP_ADD_TEMP_VAL(device, ati_romno))␊ |
601 | ␉␉return 0;␊ |
602 | ␉if(!DP_ADD_TEMP_VAL(device, ati_name_1))␊ |
603 | ␉␉return 0;␊ |
604 | ␉if(!DP_ADD_TEMP_VAL_DATA(device, ati_connector_type_0_n4))␊ |
605 | ␉␉return 0;␊ |
606 | ␉if(!DP_ADD_TEMP_VAL_DATA(device, ati_connector_type_1_n4))␊ |
607 | ␉␉return 0;␊ |
608 | ␉if(!DP_ADD_TEMP_VAL_DATA(device, ati_connector_type_2_n4))␊ |
609 | ␉␉return 0;␉␊ |
610 | ␉if(!DP_ADD_TEMP_VAL_DATA(device, ati_aux_power_conn))␊ |
611 | ␉␉return 0;␊ |
612 | ␉if(!DP_ADD_TEMP_VAL_DATA(device, ati_backlight_ctrl))␊ |
613 | ␉␉return 0;␊ |
614 | ␉if(!DP_ADD_TEMP_VAL_DATA(device, ati_aapl01_coher))␊ |
615 | ␉␉return 0;␊ |
616 | ␉if(!DP_ADD_TEMP_VAL_DATA(device, ati_efi_drv_type))␊ |
617 | ␉␉return 0;␊ |
618 | ␉if(!DP_ADD_TEMP_VAL_DATA(device, ati_efi_enbl_mode))␊ |
619 | ␉␉return 0;␊ |
620 | ␉if(!DP_ADD_TEMP_VAL_DATA(device, ati_mem_rev_id))␊ |
621 | ␉␉return 0;␊ |
622 | ␉if(!DP_ADD_TEMP_VAL_DATA(device, ati_mem_vend_id))␊ |
623 | ␉␉return 0;␊ |
624 | ␉if(!DP_ADD_TEMP_VAL_DATA(device, ati_vendor_id))␊ |
625 | ␉␉return 0;␊ |
626 | ␉if(!DP_ADD_TEMP_VAL_DATA(device, ati_aapl_emc_disp_list_n4))␊ |
627 | ␉␉return 0;␊ |
628 | ␉if(!DP_ADD_TEMP_VAL_DATA(device, ati_fb_offset_n4))␊ |
629 | ␉␉return 0;␊ |
630 | ␉if(!DP_ADD_TEMP_VAL_DATA(device, ati_hwgpio_n4))␊ |
631 | ␉␉return 0;␊ |
632 | ␉if(!DP_ADD_TEMP_VAL_DATA(device, ati_iospace_offset_n4))␊ |
633 | ␉␉return 0;␊ |
634 | ␉if(!DP_ADD_TEMP_VAL_DATA(device, ati_mclk_n4))␊ |
635 | ␉␉return 0;␊ |
636 | ␉if(!DP_ADD_TEMP_VAL_DATA(device, ati_sclk_n4))␊ |
637 | ␉␉return 0;␊ |
638 | ␉if(!DP_ADD_TEMP_VAL_DATA(device, ati_refclk_n4))␊ |
639 | ␉␉return 0;␊ |
640 | ␉if(!DP_ADD_TEMP_VAL_DATA(device, ati_regspace_offset_n4))␊ |
641 | ␉␉return 0;␊ |
642 | ␉if(!DP_ADD_TEMP_VAL_DATA(device, ati_efi_orientation_n4))␊ |
643 | ␉␉return 0;␊ |
644 | ␉if(!DP_ADD_TEMP_VAL_DATA(device, ati_aapl_blackscr_prefs_0_n4))␊ |
645 | ␉␉return 0;␊ |
646 | ␉if(!DP_ADD_TEMP_VAL_DATA(device, ati_aapl_blackscr_prefs_1_n4))␊ |
647 | ␉␉return 0;␊ |
648 | ␉if(!DP_ADD_TEMP_VAL_DATA(device, ati_aapl_blackscr_prefs_2_n4))␊ |
649 | ␉␉return 0;␉␊ |
650 | ␉if(!DP_ADD_TEMP_VAL_DATA(device, ati_swgpio_info_n4))␊ |
651 | ␉␉return 0;␊ |
652 | ␉if(!DP_ADD_TEMP_VAL_DATA(device, ati_efi_orientation_n4))␊ |
653 | ␉␉return 0;␊ |
654 | ␉if(!DP_ADD_TEMP_VAL_DATA(device, ati_mvad_n4))␊ |
655 | ␉␉return 0;␊ |
656 | ␉if(!DP_ADD_TEMP_VAL_DATA(device, ati_saved_config_n4))␊ |
657 | ␉␉return 0;␊ |
658 | ␉return 1;␊ |
659 | }␊ |
660 | ␊ |
661 | ␊ |
662 | bool setup_ati_devprop(pci_dt_t *ati_dev)␊ |
663 | {␊ |
664 | ␉struct DevPropDevice␉*device;␊ |
665 | ␉char␉␉␉*devicepath;␊ |
666 | ␉char␉␉␉*model;␊ |
667 | ␉char␉␉␉*framebuffer;␊ |
668 | ␉char␉␉␉tmp[64];␊ |
669 | ␉uint8_t␉␉␉*rom = NULL;␊ |
670 | ␉uint32_t␉␉rom_size = 0;␊ |
671 | ␉uint8_t␉␉␉*bios;␊ |
672 | ␉uint32_t␉␉bios_size;␊ |
673 | ␉uint32_t␉␉vram_size;␊ |
674 | ␉uint32_t␉␉boot_display;␊ |
675 | ␉uint8_t␉␉␉cmd;␊ |
676 | ␉bool␉␉␉doit;␊ |
677 | ␉bool␉␉␉toFree;␊ |
678 | ␊ |
679 | ␉devicepath = get_pci_dev_path(ati_dev);␊ |
680 | ␊ |
681 | ␉cmd = pci_config_read8(ati_dev->dev.addr, 4);␊ |
682 | ␉verbose("old pci command - %x\n", cmd);␊ |
683 | ␉if (cmd == 0) {␊ |
684 | ␉␉pci_config_write8(ati_dev->dev.addr, 4, 6);␉␊ |
685 | ␉␉cmd = pci_config_read8(ati_dev->dev.addr, 4);␊ |
686 | ␉␉verbose("new pci command - %x\n", cmd);␊ |
687 | ␉}␊ |
688 | ␊ |
689 | ␉model = get_ati_model((ati_dev->vendor_id << 16) | ati_dev->device_id);␊ |
690 | ␉framebuffer = get_ati_fb((ati_dev->vendor_id << 16) | ati_dev->device_id);␊ |
691 | ␉if (!string) {␊ |
692 | ␉␉string = devprop_create_string();␊ |
693 | ␉}␊ |
694 | ␉device = devprop_add_device(string, devicepath);␊ |
695 | ␉if (!device) {␊ |
696 | ␉␉printf("Failed initializing dev-prop string dev-entry, press any key...\n");␊ |
697 | ␉␉getc();␊ |
698 | ␉␉return false;␊ |
699 | ␉}␊ |
700 | ␊ |
701 | ␉/* FIXME: for primary graphics card only */␊ |
702 | ␉if (radeon_card_posted(ati_dev)) {␊ |
703 | ␉␉boot_display = 1;␊ |
704 | ␉} else {␊ |
705 | ␉␉boot_display = 0;␊ |
706 | ␉}␊ |
707 | ␉verbose("boot display - %x\n", boot_display);␊ |
708 | ␉devprop_add_value(device, "@0,AAPL,boot-display", (uint8_t*)&boot_display, 4);␊ |
709 | ␊ |
710 | ␉if((framebuffer[0] == 'M' && framebuffer[1] == 'o' && framebuffer[2] == 't') || ␊ |
711 | (framebuffer[0] == 'S' && framebuffer[1] == 'h' && framebuffer[2] == 'r') || ␊ |
712 | (framebuffer[0] == 'P' && framebuffer[1] == 'e' && framebuffer[2] == 'r')) //faster than strcmp ;)␊ |
713 | devprop_add_ati_template_4xxx(device);␊ |
714 | ␉else {␊ |
715 | ␉␉devprop_add_ati_template(device);␊ |
716 | ␉␉vram_size = getvramsizekb(ati_dev) * 1024;␊ |
717 | ␉␉if ((vram_size > 0x80000000) || (vram_size == 0)) {␊ |
718 | ␉␉␉vram_size = 0x10000000;␉//vram reported wrong, defaulting to 256 mb␊ |
719 | ␉␉}␊ |
720 | ␉␉devprop_add_value(device, "VRAM,totalsize", (uint8_t*)&vram_size, 4);␊ |
721 | ␉␉ati_vram_memsize_0.data[6] = (vram_size >> 16) & 0xFF; //4,5 are 0x00 anyway␊ |
722 | ␉␉ati_vram_memsize_0.data[7] = (vram_size >> 24) & 0xFF;␉␉␊ |
723 | ␉␉ati_vram_memsize_1.data[6] = (vram_size >> 16) & 0xFF; //4,5 are 0x00 anyway␊ |
724 | ␉␉ati_vram_memsize_1.data[7] = (vram_size >> 24) & 0xFF;␊ |
725 | ␉␉ati_vram_memsize_2.data[6] = (vram_size >> 16) & 0xFF; //4,5 are 0x00 anyway␊ |
726 | ␉␉ati_vram_memsize_2.data[7] = (vram_size >> 24) & 0xFF;␉␉␉␉␊ |
727 | ␉␉DP_ADD_TEMP_VAL_DATA(device, ati_vram_memsize_0);␊ |
728 | ␉␉DP_ADD_TEMP_VAL_DATA(device, ati_vram_memsize_1);␊ |
729 | ␉␉DP_ADD_TEMP_VAL_DATA(device, ati_vram_memsize_2);␉␉␊ |
730 | ␉␉devprop_add_iopciconfigspace(device, ati_dev);␉␉␊ |
731 | ␉}␊ |
732 | ␉devprop_add_value(device, "model", (uint8_t*)model, (strlen(model) + 1));␊ |
733 | ␉devprop_add_value(device, "ATY,DeviceID", (uint8_t*)&ati_dev->device_id, 2);␊ |
734 | ␊ |
735 | ␉//fb setup␊ |
736 | ␉sprintf(tmp, "Slot-%x",devices_number);␊ |
737 | ␉devprop_add_value(device, "AAPL,slot-name", (uint8_t*)tmp, strlen(tmp) + 1);␊ |
738 | ␉devices_number++;␊ |
739 | ␊ |
740 | ␉sprintf(tmp, ati_compatible_0[1], framebuffer);␊ |
741 | ␉devprop_add_value(device, (char *) ati_compatible_0[0], (uint8_t *)tmp, strlen(tmp) + 1);␊ |
742 | ␊ |
743 | ␉sprintf(tmp, ati_compatible_1[1], framebuffer);␊ |
744 | ␉devprop_add_value(device, (char *) ati_compatible_1[0], (uint8_t *)tmp, strlen(tmp) + 1);␊ |
745 | ␊ |
746 | ␉sprintf(tmp, ati_compatible_2[1], framebuffer);␊ |
747 | ␉devprop_add_value(device, (char *) ati_compatible_2[0], (uint8_t *)tmp, strlen(tmp) + 1);␉␊ |
748 | ␉␊ |
749 | ␉sprintf(tmp, ati_device_type[1], framebuffer);␊ |
750 | ␉devprop_add_value(device, (char *) ati_device_type[0], (uint8_t *)tmp, strlen(tmp) + 1);␊ |
751 | ␊ |
752 | ␉sprintf(tmp, ati_name[1], framebuffer);␊ |
753 | ␉devprop_add_value(device, (char *) ati_name[0], (uint8_t *)tmp, strlen(tmp) + 1);␊ |
754 | ␊ |
755 | ␉sprintf(tmp, ati_name_0[1], framebuffer);␊ |
756 | ␉devprop_add_value(device, (char *) ati_name_0[0], (uint8_t *)tmp, strlen(tmp) + 1);␊ |
757 | ␊ |
758 | ␉sprintf(tmp, ati_name_1[1], framebuffer);␊ |
759 | ␉devprop_add_value(device, (char *) ati_name_1[0], (uint8_t *)tmp, strlen(tmp) + 1);␊ |
760 | ␉␊ |
761 | ␉sprintf(tmp, ati_name_2[1], framebuffer);␊ |
762 | ␉devprop_add_value(device, (char *) ati_name_2[0], (uint8_t *)tmp, strlen(tmp) + 1);␉␊ |
763 | ␊ |
764 | ␉sprintf(tmp, "/Extra/%04x_%04x.rom", (uint16_t)ati_dev->vendor_id, (uint16_t)ati_dev->device_id);␊ |
765 | ␉if (getBoolForKey(kUseAtiROM, &doit, &bootInfo->bootConfig) && doit) {␊ |
766 | ␉␉verbose("looking for ati video bios file %s\n", tmp);␊ |
767 | ␉␉rom = malloc(0x20000);␊ |
768 | ␉␉rom_size = load_ati_bios_file(tmp, rom, 0x20000);␊ |
769 | ␉␉if (rom_size > 0) {␊ |
770 | ␉␉␉verbose("Using ATI Video BIOS File %s (%d Bytes)\n", tmp, rom_size);␊ |
771 | ␉␉␉if (rom_size > 0x10000) {␊ |
772 | ␉␉␉␉rom_size = 0x10000; //we dont need rest anyway;␊ |
773 | ␉␉␉}␊ |
774 | ␉␉} else {␊ |
775 | ␉␉␉printf("ERROR: unable to open ATI Video BIOS File %s\n", tmp);␊ |
776 | ␉␉}␊ |
777 | ␉}␊ |
778 | ␉if (rom_size == 0) {␊ |
779 | ␉␉if (boot_display) {␉␉// no custom rom␊ |
780 | ␉␉␉bios = NULL;␉// try to dump from legacy space, otherwise can result in 100% fan speed␊ |
781 | ␉␉} else {␊ |
782 | ␉␉␉// readAtomBios result in bug on some cards (100% fan speed and black screen),␊ |
783 | ␉␉␉// not using it for posted card, rading from legacy space instead␊ |
784 | ␉␉␉bios = readAtomBIOS(ati_dev);␊ |
785 | ␉␉}␊ |
786 | ␉} else {␊ |
787 | ␉␉bios = rom;␉//going custom rom way␊ |
788 | ␉␉verbose("Using rom %s\n", tmp);␊ |
789 | ␉}␊ |
790 | ␉if (bios == NULL) {␊ |
791 | ␉␉bios = (uint8_t *)0x000C0000;␊ |
792 | ␉␉toFree = false;␊ |
793 | ␉␉verbose("Not going to use bios image file\n");␊ |
794 | ␉} else {␊ |
795 | ␉␉toFree = true;␊ |
796 | ␉}␊ |
797 | ␊ |
798 | ␉if (bios[0] == 0x55 && bios[1] == 0xaa) {␊ |
799 | ␉␉printf("Found bios image\n");␊ |
800 | ␉␉bios_size = bios[2] * 512;␊ |
801 | ␊ |
802 | ␉␉struct pci_rom_pci_header_t *rom_pci_header;␊ |
803 | ␉␉rom_pci_header = (struct pci_rom_pci_header_t*)(bios + bios[24] + bios[25]*256);␊ |
804 | ␊ |
805 | ␉␉if (rom_pci_header->signature == 0x52494350) {␊ |
806 | ␉␉␉if (rom_pci_header->device != ati_dev->device_id) {␊ |
807 | ␉␉␉␉verbose("Bios image (%x) doesnt match card (%x), ignoring\n", rom_pci_header->device, ati_dev->device_id);␊ |
808 | ␉␉␉} else {␊ |
809 | ␉␉␉␉if (toFree) {␊ |
810 | ␉␉␉␉␉verbose("Adding binimage to card %x from mmio space with size %x\n", ati_dev->device_id, bios_size);␊ |
811 | ␉␉␉␉} else {␊ |
812 | ␉␉␉␉␉verbose("Adding binimage to card %x from legacy space with size %x\n", ati_dev->device_id, bios_size);␊ |
813 | ␉␉␉␉}␊ |
814 | ␉␉␉␉devprop_add_value(device, "ATY,bin_image", bios, bios_size);␊ |
815 | ␉␉␉}␊ |
816 | ␉␉} else {␊ |
817 | ␉␉␉verbose("Wrong pci header signature %x\n", rom_pci_header->signature);␊ |
818 | ␉␉}␊ |
819 | ␉} else {␊ |
820 | ␉␉verbose("Bios image not found at %x, content %x %x\n", bios, bios[0], bios[1]);␊ |
821 | ␉}␊ |
822 | ␉if (toFree) {␊ |
823 | ␉␉free(bios);␊ |
824 | ␉}␊ |
825 | ␉stringdata = malloc(sizeof(uint8_t) * string->length);␊ |
826 | ␉memcpy(stringdata, (uint8_t*)devprop_generate_string(string), string->length);␊ |
827 | ␉stringlength = string->length;␊ |
828 | ␊ |
829 | ␉return true;␊ |
830 | }␊ |
831 | |