Sun Feb 27 14:23:17 2022 UTC ()
radeon: Make radeon_bios.c ACPI stuff build.


(riastradh)
diff -r1.8 -r1.9 src/sys/external/bsd/drm2/dist/drm/radeon/radeon_bios.c

cvs diff -r1.8 -r1.9 src/sys/external/bsd/drm2/dist/drm/radeon/radeon_bios.c (expand / switch to unified diff)

--- src/sys/external/bsd/drm2/dist/drm/radeon/radeon_bios.c 2021/12/18 23:45:43 1.8
+++ src/sys/external/bsd/drm2/dist/drm/radeon/radeon_bios.c 2022/02/27 14:23:16 1.9
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: radeon_bios.c,v 1.8 2021/12/18 23:45:43 riastradh Exp $ */ 1/* $NetBSD: radeon_bios.c,v 1.9 2022/02/27 14:23:16 riastradh Exp $ */
2 2
3/* 3/*
4 * Copyright 2008 Advanced Micro Devices, Inc. 4 * Copyright 2008 Advanced Micro Devices, Inc.
5 * Copyright 2008 Red Hat Inc. 5 * Copyright 2008 Red Hat Inc.
6 * Copyright 2009 Jerome Glisse. 6 * Copyright 2009 Jerome Glisse.
7 * 7 *
8 * Permission is hereby granted, free of charge, to any person obtaining a 8 * Permission is hereby granted, free of charge, to any person obtaining a
9 * copy of this software and associated documentation files (the "Software"), 9 * copy of this software and associated documentation files (the "Software"),
10 * to deal in the Software without restriction, including without limitation 10 * to deal in the Software without restriction, including without limitation
11 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 11 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
12 * and/or sell copies of the Software, and to permit persons to whom the 12 * and/or sell copies of the Software, and to permit persons to whom the
13 * Software is furnished to do so, subject to the following conditions: 13 * Software is furnished to do so, subject to the following conditions:
14 * 14 *
@@ -19,38 +19,40 @@ @@ -19,38 +19,40 @@
19 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 20 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
21 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR 21 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
22 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 22 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
23 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 23 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
24 * OTHER DEALINGS IN THE SOFTWARE. 24 * OTHER DEALINGS IN THE SOFTWARE.
25 * 25 *
26 * Authors: Dave Airlie 26 * Authors: Dave Airlie
27 * Alex Deucher 27 * Alex Deucher
28 * Jerome Glisse 28 * Jerome Glisse
29 */ 29 */
30 30
31#include <sys/cdefs.h> 31#include <sys/cdefs.h>
32__KERNEL_RCSID(0, "$NetBSD: radeon_bios.c,v 1.8 2021/12/18 23:45:43 riastradh Exp $"); 32__KERNEL_RCSID(0, "$NetBSD: radeon_bios.c,v 1.9 2022/02/27 14:23:16 riastradh Exp $");
33 33
34#include <linux/acpi.h> 34#include <linux/acpi.h>
35#include <linux/pci.h> 35#include <linux/pci.h>
36#include <linux/slab.h> 36#include <linux/slab.h>
37 37
38#include <drm/drm_device.h> 38#include <drm/drm_device.h>
39 39
40#include "atom.h" 40#include "atom.h"
41#include "radeon.h" 41#include "radeon.h"
42#include "radeon_reg.h" 42#include "radeon_reg.h"
43 43
 44#include <linux/nbsd-namespace-acpi.h>
 45
44/* 46/*
45 * BIOS. 47 * BIOS.
46 */ 48 */
47 49
48/* If you boot an IGP board with a discrete card as the primary, 50/* If you boot an IGP board with a discrete card as the primary,
49 * the IGP rom is not accessible via the rom bar as the IGP rom is 51 * the IGP rom is not accessible via the rom bar as the IGP rom is
50 * part of the system bios. On boot, the system bios puts a 52 * part of the system bios. On boot, the system bios puts a
51 * copy of the igp rom at the start of vram if a discrete card is 53 * copy of the igp rom at the start of vram if a discrete card is
52 * present. 54 * present.
53 */ 55 */
54static bool igp_read_bios_from_vram(struct radeon_device *rdev) 56static bool igp_read_bios_from_vram(struct radeon_device *rdev)
55{ 57{
56#ifdef __NetBSD__ 58#ifdef __NetBSD__
@@ -173,27 +175,26 @@ static bool radeon_read_platform_bios(st @@ -173,27 +175,26 @@ static bool radeon_read_platform_bios(st
173 175
174 if (size == 0 || bios[0] != 0x55 || bios[1] != 0xaa) { 176 if (size == 0 || bios[0] != 0x55 || bios[1] != 0xaa) {
175 return false; 177 return false;
176 } 178 }
177 rdev->bios = kmemdup(bios, size, GFP_KERNEL); 179 rdev->bios = kmemdup(bios, size, GFP_KERNEL);
178 if (rdev->bios == NULL) { 180 if (rdev->bios == NULL) {
179 return false; 181 return false;
180 } 182 }
181 183
182 return true; 184 return true;
183#endif 185#endif
184} 186}
185 187
186/* XXX radeon acpi */ 
187#ifdef CONFIG_ACPI 188#ifdef CONFIG_ACPI
188/* ATRM is used to get the BIOS on the discrete cards in 189/* ATRM is used to get the BIOS on the discrete cards in
189 * dual-gpu systems. 190 * dual-gpu systems.
190 */ 191 */
191/* retrieve the ROM in 4k blocks */ 192/* retrieve the ROM in 4k blocks */
192#define ATRM_BIOS_PAGE 4096 193#define ATRM_BIOS_PAGE 4096
193/** 194/**
194 * radeon_atrm_call - fetch a chunk of the vbios 195 * radeon_atrm_call - fetch a chunk of the vbios
195 * 196 *
196 * @atrm_handle: acpi ATRM handle 197 * @atrm_handle: acpi ATRM handle
197 * @bios: vbios image pointer 198 * @bios: vbios image pointer
198 * @offset: offset of vbios image data to fetch 199 * @offset: offset of vbios image data to fetch
199 * @len: length of vbios image data to fetch 200 * @len: length of vbios image data to fetch
@@ -237,40 +238,49 @@ static bool radeon_atrm_get_bios(struct  @@ -237,40 +238,49 @@ static bool radeon_atrm_get_bios(struct
237 int ret; 238 int ret;
238 int size = 256 * 1024; 239 int size = 256 * 1024;
239 int i; 240 int i;
240 struct pci_dev *pdev = NULL; 241 struct pci_dev *pdev = NULL;
241 acpi_handle dhandle, atrm_handle; 242 acpi_handle dhandle, atrm_handle;
242 acpi_status status; 243 acpi_status status;
243 bool found = false; 244 bool found = false;
244 245
245 /* ATRM is for the discrete card only */ 246 /* ATRM is for the discrete card only */
246 if (rdev->flags & RADEON_IS_IGP) 247 if (rdev->flags & RADEON_IS_IGP)
247 return false; 248 return false;
248 249
249 while ((pdev = pci_get_class(PCI_CLASS_DISPLAY_VGA << 8, pdev)) != NULL) { 250 while ((pdev = pci_get_class(PCI_CLASS_DISPLAY_VGA << 8, pdev)) != NULL) {
 251#ifdef __NetBSD__
 252 dhandle = (pdev->pd_ad ? pdev->pd_ad->ad_handle : NULL);
 253#else
250 dhandle = ACPI_HANDLE(&pdev->dev); 254 dhandle = ACPI_HANDLE(&pdev->dev);
 255#endif
251 if (!dhandle) 256 if (!dhandle)
252 continue; 257 continue;
253 258
254 status = acpi_get_handle(dhandle, "ATRM", &atrm_handle); 259 status = acpi_get_handle(dhandle, "ATRM", &atrm_handle);
255 if (!ACPI_FAILURE(status)) { 260 if (!ACPI_FAILURE(status)) {
256 found = true; 261 found = true;
257 break; 262 break;
258 } 263 }
259 } 264 }
260 265
261 if (!found) { 266 if (!found) {
262 while ((pdev = pci_get_class(PCI_CLASS_DISPLAY_OTHER << 8, pdev)) != NULL) { 267 while ((pdev = pci_get_class(PCI_CLASS_DISPLAY_OTHER << 8, pdev)) != NULL) {
 268#ifdef __NetBSD__
 269 dhandle = (pdev->pd_ad ? pdev->pd_ad->ad_handle
 270 : NULL);
 271#else
263 dhandle = ACPI_HANDLE(&pdev->dev); 272 dhandle = ACPI_HANDLE(&pdev->dev);
 273#endif
264 if (!dhandle) 274 if (!dhandle)
265 continue; 275 continue;
266 276
267 status = acpi_get_handle(dhandle, "ATRM", &atrm_handle); 277 status = acpi_get_handle(dhandle, "ATRM", &atrm_handle);
268 if (!ACPI_FAILURE(status)) { 278 if (!ACPI_FAILURE(status)) {
269 found = true; 279 found = true;
270 break; 280 break;
271 } 281 }
272 } 282 }
273 } 283 }
274 284
275 if (!found) 285 if (!found)
276 return false; 286 return false;