mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-09-04 20:19:47 +08:00

Register an auxiliary device for nova-drm. For now always use zero for the auxiliary device's ID; we don't use it yet anyways. However, once it lands, we should switch to XArray. Acked-by: Dave Airlie <airlied@redhat.com> Link: https://lore.kernel.org/r/20250424160452.8070-2-dakr@kernel.org Signed-off-by: Danilo Krummrich <dakr@kernel.org>
55 lines
1.4 KiB
Rust
55 lines
1.4 KiB
Rust
// SPDX-License-Identifier: GPL-2.0
|
|
|
|
use kernel::{auxiliary, bindings, c_str, device::Core, pci, prelude::*};
|
|
|
|
use crate::gpu::Gpu;
|
|
|
|
#[pin_data]
|
|
pub(crate) struct NovaCore {
|
|
#[pin]
|
|
pub(crate) gpu: Gpu,
|
|
_reg: auxiliary::Registration,
|
|
}
|
|
|
|
const BAR0_SIZE: usize = 8;
|
|
pub(crate) type Bar0 = pci::Bar<BAR0_SIZE>;
|
|
|
|
kernel::pci_device_table!(
|
|
PCI_TABLE,
|
|
MODULE_PCI_TABLE,
|
|
<NovaCore as pci::Driver>::IdInfo,
|
|
[(
|
|
pci::DeviceId::from_id(bindings::PCI_VENDOR_ID_NVIDIA, bindings::PCI_ANY_ID as _),
|
|
()
|
|
)]
|
|
);
|
|
|
|
impl pci::Driver for NovaCore {
|
|
type IdInfo = ();
|
|
const ID_TABLE: pci::IdTable<Self::IdInfo> = &PCI_TABLE;
|
|
|
|
fn probe(pdev: &pci::Device<Core>, _info: &Self::IdInfo) -> Result<Pin<KBox<Self>>> {
|
|
dev_dbg!(pdev.as_ref(), "Probe Nova Core GPU driver.\n");
|
|
|
|
pdev.enable_device_mem()?;
|
|
pdev.set_master();
|
|
|
|
let bar = pdev.iomap_region_sized::<BAR0_SIZE>(0, c_str!("nova-core/bar0"))?;
|
|
|
|
let this = KBox::pin_init(
|
|
try_pin_init!(Self {
|
|
gpu <- Gpu::new(pdev, bar)?,
|
|
_reg: auxiliary::Registration::new(
|
|
pdev.as_ref(),
|
|
c_str!("nova-drm"),
|
|
0, // TODO: Once it lands, use XArray; for now we don't use the ID.
|
|
crate::MODULE_NAME
|
|
)?,
|
|
}),
|
|
GFP_KERNEL,
|
|
)?;
|
|
|
|
Ok(this)
|
|
}
|
|
}
|