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