Hello Matt Delco,
I'd like you to do a code review. Please visit
https://review.coreboot.org/c/coreboot/+/42468
to review the following change.
Change subject: drivers/intel/mipi_camera: SSDT changes to add DSM ......................................................................
drivers/intel/mipi_camera: SSDT changes to add DSM
This change updates mipi_camera driver to add DSM section to SSDT.
Change-Id: Ic60e972b6aebad171a7b77fe0d99781693adfb20 Signed-off-by: Sugnan Prabhu S sugnan.prabhu.s@intel.com --- M src/drivers/intel/mipi_camera/camera.c 1 file changed, 83 insertions(+), 0 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/68/42468/1
diff --git a/src/drivers/intel/mipi_camera/camera.c b/src/drivers/intel/mipi_camera/camera.c index 81cd968..a3a9323 100644 --- a/src/drivers/intel/mipi_camera/camera.c +++ b/src/drivers/intel/mipi_camera/camera.c @@ -13,6 +13,86 @@ #define SENSOR_NAME_UUID "822ace8f-2814-4174-a56b-5f029fe079ee" #define SENSOR_TYPE_UUID "26257549-9271-4ca4-bb43-c4899d5a4881"
+static uint32_t address_for_dev_type(const struct device *dev, uint8_t dev_type) +{ + struct drivers_intel_mipi_camera_config *config = dev->chip_info; + uint16_t i2c_bus = dev->bus ? dev->bus->secondary : 0xFFFF; + uint16_t i2c_addr = dev->path.i2c.device; + + switch (dev_type) { + case DEV_TYPE_SENSOR: + return (((uint32_t)i2c_bus) << 24 | ((uint32_t)i2c_addr) << 8 | + dev_type); + case DEV_TYPE_VCM: + return (((uint32_t)i2c_bus) << 24 | ((uint32_t)config->vcm_address) << 8 | + dev_type); + case DEV_TYPE_ROM: + return (((uint32_t)i2c_bus) << 24 | ((uint32_t)config->rom_address) << 8 | + dev_type); + } + + return 0; +} + +static void camera_generate_dsm(const struct device *dev) +{ + struct drivers_intel_mipi_camera_config *config = dev->chip_info; + int local1_ret = (config->ssdb.vcm_type ? 1 : 0) + (config->ssdb.rom_type ? 1 : 0) + 1; + int next_local1 = 1; + /* Method (_DSM, 4, NotSerialized) */ + acpigen_write_method("_DSM", 4); + + /* ToBuffer (Arg0, Local0) */ + acpigen_write_to_buffer(ARG0_OP, LOCAL0_OP); + + /* If (LEqual (Local0, ToUUID(uuid))) */ + acpigen_write_if(); + acpigen_emit_byte(LEQUAL_OP); + acpigen_emit_byte(LOCAL0_OP); + acpigen_write_uuid(SENSOR_NAME_UUID); + acpigen_write_return_string(config->sensor_name ? config->sensor_name : "UNKNOWN"); + acpigen_pop_len(); /* If */ + + /* If (LEqual (Local0, ToUUID(uuid))) */ + acpigen_write_if(); + acpigen_emit_byte(LEQUAL_OP); + acpigen_emit_byte(LOCAL0_OP); + acpigen_write_uuid(SENSOR_TYPE_UUID); + /* ToInteger (Arg2, Local1) */ + acpigen_write_to_integer(ARG2_OP, LOCAL1_OP); + + /* If (LEqual (Local1, 1)) */ + acpigen_write_if_lequal_op_int(LOCAL1_OP, next_local1++); + acpigen_write_return_integer(local1_ret); + acpigen_pop_len(); /* If Arg2=1 */ + + /* If (LEqual (Local1, 2)) */ + acpigen_write_if_lequal_op_int(LOCAL1_OP, next_local1++); + acpigen_write_return_integer(address_for_dev_type(dev, DEV_TYPE_SENSOR)); + acpigen_pop_len(); /* If Arg2=2 */ + + if (config->ssdb.vcm_type) { + /* If (LEqual (Local1, 3)) */ + acpigen_write_if_lequal_op_int(LOCAL1_OP, next_local1++); + acpigen_write_return_integer(address_for_dev_type(dev, DEV_TYPE_VCM)); + acpigen_pop_len(); /* If Arg2=3 */ + } + + if (config->ssdb.rom_type) { + /* If (LEqual (Local1, 3 or 4)) */ + acpigen_write_if_lequal_op_int(LOCAL1_OP, next_local1); + acpigen_write_return_integer(address_for_dev_type(dev, DEV_TYPE_ROM)); + acpigen_pop_len(); /* If Arg2=3 or 4 */ + } + + acpigen_pop_len(); /* If uuid */ + + /* Return (Buffer (One) { 0x0 }) */ + acpigen_write_return_singleton_buffer(0x0); + + acpigen_pop_len(); /* Method _DSM */ +} + static void camera_fill_sensor_defaults(struct drivers_intel_mipi_camera_config *config) { if (!config->ssdb.platform) @@ -63,6 +143,9 @@ if (!config->disable_ssdb_defaults) camera_fill_sensor_defaults(config);
+ /* _DSM */ + camera_generate_dsm(dev); + ep00 = acpi_dp_new_table("EP00"); acpi_dp_add_integer(ep00, "endpoint", 0); acpi_dp_add_integer(ep00, "clock-lanes", 0);