Register a mock platform device on x86 architectures to allow testing the GlandaGPU driver inside QEMU without cross-compiling.
Signed-off-by: Leander Kieweg <[email protected]> --- drivers/gpu/drm/tiny/Kconfig | 14 ++++++++++++ drivers/gpu/drm/tiny/glandagpu.c | 39 ++++++++++++++++++++++++++++++++ 2 files changed, 53 insertions(+) diff --git a/drivers/gpu/drm/tiny/Kconfig b/drivers/gpu/drm/tiny/Kconfig index 7a15bf95a..156713746 100644 --- a/drivers/gpu/drm/tiny/Kconfig +++ b/drivers/gpu/drm/tiny/Kconfig @@ -67,6 +67,20 @@ config DRM_GLANDA basic modesetting, dumb buffers, and simple 2D drawing acceleration via custom hardware IOCTLs. +config DRM_GLANDA_X86_TEST + bool "Register a fixed-address test device on x86 (QEMU only)" + depends on DRM_GLANDA && X86 + default n + help + Registers a platform device at a hardcoded physical address + (0xC0000000) for testing GlandaGPU against a QEMU-based digital + twin without needing a devicetree. + + WARNING: this blindly ioremaps a fixed physical address range. + Do NOT enable this on real x86 hardware. This exists solely to + let reviewers test the driver in QEMU without cross-compiling + an ARM kernel/rootfs. Leave disabled otherwise. + config DRM_GM12U320 tristate "GM12U320 driver for USB projectors" depends on DRM && USB && MMU diff --git a/drivers/gpu/drm/tiny/glandagpu.c b/drivers/gpu/drm/tiny/glandagpu.c index 8f87ae096..c1e9370f2 100644 --- a/drivers/gpu/drm/tiny/glandagpu.c +++ b/drivers/gpu/drm/tiny/glandagpu.c @@ -741,6 +741,34 @@ static struct platform_driver glandagpu_driver = { .remove = glandagpu_remove, }; +#ifdef CONFIG_DRM_GLANDA_X86_TEST +static struct platform_device *pdev_x86; + +static struct resource glandagpu_resources[] = { + [0] = { /* Single resource covering VRAM and MMIO. */ + .start = BRIDGE_BASE, + .end = GLANDA_BASE_SIZE, + .flags = IORESOURCE_MEM,}, + [1] = { /* IRQ */ + .start = 11, + .end = 11, + .flags = IORESOURCE_IRQ,}, +}; + +static int glandagpu_register_x86_test_device(void) +{ + pdev_x86 = platform_device_register_simple("glandagpu", -1, + glandagpu_resources, + ARRAY_SIZE(glandagpu_resources)); + if (IS_ERR(pdev_x86)) { + pr_err("GlandaGPU: Failed to register platform device\n"); + return PTR_ERR(pdev_x86); + } + + return 0; +} +#endif + static int __init glandagpu_init(void) { int ret; @@ -750,6 +778,13 @@ static int __init glandagpu_init(void) pr_err("GlandaGPU: Failed to register platform driver\n"); return ret; } +#ifdef CONFIG_DRM_GLANDA_X86_TEST + ret = glandagpu_register_x86_test_device(); + if (ret) { + platform_driver_unregister(&glandagpu_driver); + return ret; + } +#endif pr_info("GlandaGPU: Module loaded successfully\n"); return 0; @@ -757,6 +792,10 @@ static int __init glandagpu_init(void) static void __exit glandagpu_exit(void) { +#ifdef CONFIG_DRM_GLANDA_X86_TEST + if (pdev_x86) + platform_device_unregister(pdev_x86); +#endif platform_driver_unregister(&glandagpu_driver); pr_info("GlandaGPU: Module unloaded\n"); } -- 2.43.0
