xref: /linux/drivers/gpu/nova-core/gsp/hal.rs (revision a355d2dd381d129135d1199d66a7f96490551bac)
1 // SPDX-License-Identifier: GPL-2.0
2 // SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
3 
4 mod gh100;
5 mod tu102;
6 
7 use kernel::prelude::*;
8 
9 use kernel::{
10     device,
11     dma::Coherent, //
12 };
13 
14 use crate::{
15     driver::Bar0,
16     falcon::{
17         gsp::Gsp as GspEngine,
18         sec2::Sec2,
19         Falcon, //
20     },
21     fb::FbLayout,
22     firmware::gsp::GspFirmware,
23     gpu::{
24         Architecture,
25         Chipset, //
26     },
27     gsp::{
28         Gsp,
29         GspFwWprMeta, //
30     },
31 };
32 
33 /// Trait implemented by GSP HALs.
34 pub(super) trait GspHal: Send {
35     /// Performs the GSP boot process, loading and running the required firmwares as needed.
36     #[allow(clippy::too_many_arguments)]
37     fn boot(
38         &self,
39         gsp: &Gsp,
40         dev: &device::Device<device::Bound>,
41         bar: &Bar0,
42         chipset: Chipset,
43         fb_layout: &FbLayout,
44         wpr_meta: &Coherent<GspFwWprMeta>,
45         gsp_falcon: &Falcon<GspEngine>,
46         sec2_falcon: &Falcon<Sec2>,
47     ) -> Result;
48 
49     /// Performs HAL-specific post-GSP boot tasks.
50     ///
51     /// This method is called by the GSP boot code after the GSP is confirmed to be running, and
52     /// after the initialization commands have been pushed onto its queue.
53     fn post_boot(
54         &self,
55         _gsp: &Gsp,
56         _dev: &device::Device<device::Bound>,
57         _bar: &Bar0,
58         _gsp_fw: &GspFirmware,
59         _gsp_falcon: &Falcon<GspEngine>,
60         _sec2_falcon: &Falcon<Sec2>,
61     ) -> Result {
62         Ok(())
63     }
64 }
65 
66 /// Returns the GSP HAL to be used for `chipset`.
67 pub(super) fn gsp_hal(chipset: Chipset) -> &'static dyn GspHal {
68     match chipset.arch() {
69         Architecture::Turing | Architecture::Ampere | Architecture::Ada => tu102::TU102_HAL,
70         Architecture::Hopper | Architecture::BlackwellGB10x | Architecture::BlackwellGB20x => {
71             gh100::GH100_HAL
72         }
73     }
74 }
75