diff options
author | Danilo Krummrich <dakr@redhat.com> | 2023-11-22 22:37:18 +0100 |
---|---|---|
committer | Danilo Krummrich <dakr@redhat.com> | 2023-11-22 22:37:18 +0100 |
commit | fee3fdf9ae8b2f4bb33f4a1556dc5fb14a45a66c (patch) | |
tree | ba74746194c186654150ec03b7bea959b5c15fa0 | |
parent | 66b014ea4b042cad8d4b8da42a1f39209fa890e6 (diff) |
nova: initial pci driver skeleton
Signed-off-by: Danilo Krummrich <dakr@redhat.com>
-rw-r--r-- | drivers/gpu/drm/Kconfig | 2 | ||||
-rw-r--r-- | drivers/gpu/drm/Makefile | 1 | ||||
-rw-r--r-- | drivers/gpu/drm/nova/Kconfig | 3 | ||||
-rw-r--r-- | drivers/gpu/drm/nova/Makefile | 3 | ||||
-rw-r--r-- | drivers/gpu/drm/nova/nova_drv.rs | 73 |
5 files changed, 82 insertions, 0 deletions
diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig index 3caa020391c7..bf5d88cfe9c8 100644 --- a/drivers/gpu/drm/Kconfig +++ b/drivers/gpu/drm/Kconfig @@ -266,6 +266,8 @@ source "drivers/gpu/drm/amd/amdgpu/Kconfig" source "drivers/gpu/drm/nouveau/Kconfig" +source "drivers/gpu/drm/nova/Kconfig" + source "drivers/gpu/drm/i915/Kconfig" source "drivers/gpu/drm/kmb/Kconfig" diff --git a/drivers/gpu/drm/Makefile b/drivers/gpu/drm/Makefile index 215e78e79125..840cd32f52c8 100644 --- a/drivers/gpu/drm/Makefile +++ b/drivers/gpu/drm/Makefile @@ -153,6 +153,7 @@ obj-$(CONFIG_DRM_VMWGFX)+= vmwgfx/ obj-$(CONFIG_DRM_VGEM) += vgem/ obj-$(CONFIG_DRM_VKMS) += vkms/ obj-$(CONFIG_DRM_NOUVEAU) +=nouveau/ +obj-$(CONFIG_DRM_NOVA) += nova/ obj-$(CONFIG_DRM_EXYNOS) +=exynos/ obj-$(CONFIG_DRM_ROCKCHIP) +=rockchip/ obj-$(CONFIG_DRM_GMA500) += gma500/ diff --git a/drivers/gpu/drm/nova/Kconfig b/drivers/gpu/drm/nova/Kconfig new file mode 100644 index 000000000000..bd04a412b62e --- /dev/null +++ b/drivers/gpu/drm/nova/Kconfig @@ -0,0 +1,3 @@ +config DRM_NOVA + tristate "Nova GPU driver" + depends on RUST diff --git a/drivers/gpu/drm/nova/Makefile b/drivers/gpu/drm/nova/Makefile new file mode 100644 index 000000000000..6fbb32893ecc --- /dev/null +++ b/drivers/gpu/drm/nova/Makefile @@ -0,0 +1,3 @@ +nova-y += nova_drv.o + +obj-$(CONFIG_DRM_NOVA) += nova.o diff --git a/drivers/gpu/drm/nova/nova_drv.rs b/drivers/gpu/drm/nova/nova_drv.rs new file mode 100644 index 000000000000..9eeb69cb7e3e --- /dev/null +++ b/drivers/gpu/drm/nova/nova_drv.rs @@ -0,0 +1,73 @@ +/// Nova GPU Driver + +// For now, catch 'em all! +use alloc::boxed::Box; +use core::{ + cell::UnsafeCell, + convert::TryInto, + format_args, + pin::Pin, + sync::atomic::{AtomicU16, AtomicU32, AtomicU64, Ordering}, +}; +use kernel::{ + bindings, + c_str, + device::{self, Device, RawDevice}, + dma, driver, + error::code::*, + io_mem::IoMem, + new_mutex, new_spinlock, pci, + pci::define_pci_id_table, + prelude::*, + stack_pin_init, + sync::Mutex, + sync::{Arc, SpinLock}, + types::AtomicOptionalBoxedPtr, +}; + +struct NovaDevice; + +impl pci::Driver for NovaDevice { + + define_pci_id_table! { + (), + [ (pci::DeviceId::new(bindings::PCI_VENDOR_ID_NVIDIA, bindings::PCI_ANY_ID as u32), None) ] + } + + fn probe(_dev: &mut pci::Device, _id_info: Option<&Self::IdInfo>) -> Result { + pr_info!("probe()\n"); + + Ok(()) + } + + fn remove(_data: &Self::Data) { + pr_info!("remove()\n"); + } +} + +struct NovaModule { + _registration: Pin<Box<driver::Registration<pci::Adapter<NovaDevice>>>>, +} + +impl kernel::Module for NovaModule { + fn init(_name: &'static CStr, module: &'static ThisModule) -> Result<Self> { + pr_info!("Module loaded!\n"); + + let registration = driver::Registration::new_pinned(c_str!("nova"), module)?; + pr_info!("Registerd PCI driver.\n"); + + Ok(Self { + _registration: registration, + }) + } +} + +module! { + type: NovaModule, + name: "Nova", + author: "Danilo Krummrich", + description: "Nova GPU driver", + license: "GPL v2", + params: { + }, +} |