summaryrefslogtreecommitdiff
path: root/drivers/gpu/drm/nova/gpu.rs
blob: d3f1890953b1fe04b811eb52b268baf260087d79 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
use kernel::{
    error::Result,
    io_mem::IoMem,
    c_str,
    firmware::{Firmware},
    pci,
};

use crate::bios::*;

use crate::driver::BAR_SIZE;

pub(crate) enum CardType {
    TU100 = 0x160,
    GA100 = 0x170,
    AD100 = 0x190,
}

pub(crate) struct Gpu {
    booter_load_fw: Firmware,
    booter_unload_fw: Firmware,
    gsp_fw: Firmware,
    card_type: CardType,
    bar: IoMem<BAR_SIZE>,
    bios: Bios
}

impl Gpu {
    pub(crate) fn new(card_type: CardType, bar: IoMem<BAR_SIZE>) -> Self
    {
        Self {
            booter_load_fw: Firmware::new(),
            booter_unload_fw: Firmware::new(),
            gsp_fw: Firmware::new(),
            card_type: card_type,
            bar: bar,
            bios: Bios::new(),
        }
    }

    pub(crate) fn init(&mut self, dev: &mut pci::Device) -> Result {
        match self.booter_load_fw.request(c_str!("nvidia/ad102/gsp/booter_load-535.113.01.bin"), dev) {
            Err(e) => return Err(e),
            Ok(_) => ()
        }

        match self.booter_unload_fw.request(c_str!("nvidia/ad102/gsp/booter_unload-535.113.01.bin"), dev) {
            Err(e) => return Err(e),
            Ok(_) => ()
        }

        match self.gsp_fw.request(c_str!("nvidia/ad102/gsp/gsp-535.113.01.bin"), dev) {
            Err(e) => return Err(e),
            Ok(_) => (),
        }

        self.bios.probe(&self.bar)?;

        self.bios.find_fwsec()?;
        Ok(())
    }
}