From 9f8023a869dabf55ed91b6b73b133c4ea0232bc1 Mon Sep 17 00:00:00 2001 From: V Sowmya Date: Tue, 28 Feb 2017 17:52:05 +0530 Subject: drivers/intel/mipi_camera: Add MIPI CSI camera SSDT generator Add SSDT generator for MIPI CSI camera to create ACPI objects used by the Intel kernel drivers. * SSDB: Sensor specific database for camera sensor. * PWDB: Power database for all the camera devices. * CAMD: ACPI object to specify the camera device type. BUG=b:36580624 BRANCH=none TEST=Build and boot poppy. Dump and verify that the generated SSDT table has the required entries. Change-Id: Ief9e56d12b64081897613bf1c7abcdf915470b99 Signed-off-by: Rizwan Qureshi Signed-off-by: Sowmya V Reviewed-on: https://review.coreboot.org/18967 Reviewed-by: Martin Roth Tested-by: build bot (Jenkins) --- src/drivers/intel/mipi_camera/camera.c | 99 ++++++++++++++++++++++++++++++++++ 1 file changed, 99 insertions(+) create mode 100644 src/drivers/intel/mipi_camera/camera.c (limited to 'src/drivers/intel/mipi_camera/camera.c') diff --git a/src/drivers/intel/mipi_camera/camera.c b/src/drivers/intel/mipi_camera/camera.c new file mode 100644 index 0000000000..7752f0aff3 --- /dev/null +++ b/src/drivers/intel/mipi_camera/camera.c @@ -0,0 +1,99 @@ +/* + * This file is part of the coreboot project. + * + * Copyright (C) 2017 Intel Corporation. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include "chip.h" + +static void camera_fill_ssdt(struct device *dev) +{ + struct drivers_intel_mipi_camera_config *config = dev->chip_info; + const char *scope = acpi_device_scope(dev); + struct acpi_i2c i2c = { + .address = dev->path.i2c.device, + .mode_10bit = dev->path.i2c.mode_10bit, + .speed = I2C_SPEED_FAST, + .resource = scope, + }; + + if (!dev->enabled || !scope) + return; + + /* Device */ + acpigen_write_scope(scope); + acpigen_write_device(acpi_device_name(dev)); + acpigen_write_name_string("_HID", config->acpi_hid); + acpigen_write_name_integer("_UID", config->acpi_uid); + acpigen_write_name_string("_DDN", config->chip_name); + acpigen_write_STA(ACPI_STATUS_DEVICE_ALL_ON); + + /* Resources */ + acpigen_write_name("_CRS"); + acpigen_write_resourcetemplate_header(); + acpi_device_write_i2c(&i2c); + acpigen_write_resourcetemplate_footer(); + + /* Mark it as Camera related device */ + acpigen_write_name_integer("CAMD", config->device_type); + + /* Create Device specific data */ + if (config->device_type == INTEL_ACPI_CAMERA_SENSOR) { + acpigen_write_method_serialized("SSDB", 0); + acpigen_write_return_byte_buffer((uint8_t *)&config->ssdb, + sizeof(config->ssdb)); + acpigen_pop_len(); /* Method */ + } + + /* Fill Power Sequencing Data */ + acpigen_write_method_serialized("PWDB", 0); + acpigen_write_return_byte_buffer((uint8_t *)&config->pwdb, + (sizeof(struct intel_pwdb) * config->num_pwdb_entries)); + acpigen_pop_len(); /* Method */ + + acpigen_pop_len(); /* Device */ + acpigen_pop_len(); /* Scope */ + printk(BIOS_INFO, "%s: %s address 0%xh\n", acpi_device_path(dev), + dev->chip_ops->name, dev->path.i2c.device); +} + +static const char *camera_acpi_name(struct device *dev) +{ + struct drivers_intel_mipi_camera_config *config = dev->chip_info; + return config->acpi_name; +} + +static struct device_operations camera_ops = { + .read_resources = DEVICE_NOOP, + .set_resources = DEVICE_NOOP, + .enable_resources = DEVICE_NOOP, + .acpi_name = &camera_acpi_name, + .acpi_fill_ssdt_generator = &camera_fill_ssdt, +}; + +static void camera_enable(struct device *dev) +{ + dev->ops = &camera_ops; +} + +struct chip_operations drivers_intel_mipi_camera_ops = { + CHIP_NAME("Intel MIPI Camera Device") + .enable_dev = &camera_enable +}; -- cgit v1.2.3