From 5001b07f9c9a994bb0fb258c77c9ea968b5fcd9a Mon Sep 17 00:00:00 2001 From: Matt DeVillier Date: Mon, 15 Dec 2025 15:17:23 -0600 Subject: [PATCH] drivers/intel/mipi_camera: Add validation and remove unused defaults Add validation checks in camera_enable() for required parameters: - ssdb.lanes_used - ssdb.platform - rom_address (when rom_type is set) - vcm_address (when vcm_type is set) Remove default values for ssdb.platform and ssdb.lanes_used from camera_fill_ssdb_defaults() since these parameters are now required and validated. All boards in the tree explicitly set these values in their devicetree configurations, so the defaults were never used. Also remove the unused cio2 and cio2_config variables that were only used for the lanes_used default logic. Change-Id: Idcb84c25b94ed9259698aafba201cc4f4e0f1af7 Signed-off-by: Matt DeVillier Reviewed-on: https://review.coreboot.org/c/coreboot/+/90517 Reviewed-by: Maximilian Brune Tested-by: build bot (Jenkins) Reviewed-by: Alicja Michalska Reviewed-by: Felix Singer --- src/drivers/intel/mipi_camera/camera.c | 54 ++++++++++++++------------ 1 file changed, 30 insertions(+), 24 deletions(-) diff --git a/src/drivers/intel/mipi_camera/camera.c b/src/drivers/intel/mipi_camera/camera.c index e4365d1b36..bab652fccb 100644 --- a/src/drivers/intel/mipi_camera/camera.c +++ b/src/drivers/intel/mipi_camera/camera.c @@ -465,9 +465,6 @@ static void camera_generate_dsm(const struct device *dev) static void camera_fill_ssdb_defaults(struct drivers_intel_mipi_camera_config *config) { - struct device *cio2 = pcidev_on_root(CIO2_PCI_DEV, CIO2_PCI_FN); - struct drivers_intel_mipi_camera_config *cio2_config; - config->ssdb.version = 1; if (!config->ssdb.sensor_card_sku.card_type) @@ -478,9 +475,6 @@ static void camera_fill_ssdb_defaults(struct drivers_intel_mipi_camera_config *c if (!config->ssdb.bdf_value) config->ssdb.bdf_value = PCI_DEVFN(CIO2_PCI_DEV, CIO2_PCI_FN); - if (!config->ssdb.platform) - config->ssdb.platform = PLAT_SKC; - if (!config->ssdb.flash_support) config->ssdb.flash_support = FLASH_DISABLE; @@ -492,24 +486,6 @@ static void camera_fill_ssdb_defaults(struct drivers_intel_mipi_camera_config *c if (!config->ssdb.mclk_speed) config->ssdb.mclk_speed = CLK_FREQ_19_2MHZ; - - if (!config->ssdb.lanes_used) { - cio2_config = cio2 ? cio2->chip_info : NULL; - - if (!cio2_config) { - printk(BIOS_ERR, "Failed to get CIO2 config\n"); - } else if (cio2_config->device_type != INTEL_ACPI_CAMERA_CIO2) { - printk(BIOS_ERR, "Device type isn't CIO2: %u\n", - (u32)cio2_config->device_type); - } else if (config->ssdb.link_used >= cio2_config->cio2_num_ports) { - printk(BIOS_ERR, "%u exceeds CIO2's %u links\n", - (u32)config->ssdb.link_used, - (u32)cio2_config->cio2_num_ports); - } else { - config->ssdb.lanes_used = - cio2_config->cio2_lanes_used[config->ssdb.link_used]; - } - } } /* @@ -1266,6 +1242,36 @@ static struct device_operations camera_ops = { static void camera_enable(struct device *dev) { + //Validate Camera Parameters + struct drivers_intel_mipi_camera_config *config = dev->chip_info; + bool params_error = false; + + if (!config->ssdb.lanes_used) { + printk(BIOS_ERR, "MIPI camera: SSDB lanes_used not set\n"); + params_error = true; + } + + if (!config->ssdb.platform) { + printk(BIOS_ERR, "MIPI camera: SSDB platform not set\n"); + params_error = true; + } + + if (config->ssdb.rom_type && !config->rom_address) { + printk(BIOS_ERR, "MIPI camera: ROM address not set\n"); + params_error = true; + } + + if (config->ssdb.vcm_type && !config->vcm_address) { + printk(BIOS_ERR, "MIPI camera: VCM address not set\n"); + params_error = true; + } + + if (params_error) { + printk(BIOS_ERR, "MIPI camera: Parameters missing, ACPI device(s) will not be created.\n"); + printk(BIOS_ERR, "MIPI camera: Please fix your devicetree configuration.\n"); + return; + } + dev->ops = &camera_ops; }