[coreboot-gerrit] Patch set updated for coreboot: drivers/i2c/ov_camera: Add generic i2c driver for OV cameras
Rizwan Qureshi (rizwan.qureshi@intel.com)
gerrit at coreboot.org
Tue Feb 14 12:34:24 CET 2017
Rizwan Qureshi (rizwan.qureshi at intel.com) just uploaded a new patch set to gerrit, which you can find at https://review.coreboot.org/18066
-gerrit
commit de09411278275b12785e7f06bc01327a24edae94
Author: Rizwan Qureshi <rizwan.qureshi at intel.com>
Date: Mon Jan 9 22:58:04 2017 +0530
drivers/i2c/ov_camera: Add generic i2c driver for OV cameras
Add generic i2c driver for OV cameras
Change-Id: I64afc42b898c866f81ed00bbca99e191f7d48c5a
Signed-off-by: Rizwan Qureshi <rizwan.qureshi at intel.com>
---
src/drivers/i2c/ov_camera/Kconfig | 2 +
src/drivers/i2c/ov_camera/Makefile.inc | 1 +
src/drivers/i2c/ov_camera/chip.h | 70 +++++++++++++++++++++
src/drivers/i2c/ov_camera/ov_camera.c | 112 +++++++++++++++++++++++++++++++++
4 files changed, 185 insertions(+)
diff --git a/src/drivers/i2c/ov_camera/Kconfig b/src/drivers/i2c/ov_camera/Kconfig
new file mode 100644
index 0000000..0d90e98
--- /dev/null
+++ b/src/drivers/i2c/ov_camera/Kconfig
@@ -0,0 +1,2 @@
+config DRIVERS_I2C_OV_CAMERA
+ bool
diff --git a/src/drivers/i2c/ov_camera/Makefile.inc b/src/drivers/i2c/ov_camera/Makefile.inc
new file mode 100644
index 0000000..13e3c48
--- /dev/null
+++ b/src/drivers/i2c/ov_camera/Makefile.inc
@@ -0,0 +1 @@
+ramstage-$(CONFIG_DRIVERS_I2C_OV_CAMERA) += ov_camera.c
diff --git a/src/drivers/i2c/ov_camera/chip.h b/src/drivers/i2c/ov_camera/chip.h
new file mode 100644
index 0000000..40a2342
--- /dev/null
+++ b/src/drivers/i2c/ov_camera/chip.h
@@ -0,0 +1,70 @@
+/*
+ * This file is part of the coreboot project.
+ *
+ * Copyright 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 <arch/acpi_device.h>
+
+#define MAX_SSDB_BUF 94
+
+typedef union {
+ uint8_t ssdb_arr[MAX_SSDB_BUF];
+ struct {
+ uint8_t version;
+ uint8_t sensor_card_sku;
+ uint8_t csi2_data_stream_interface[16];
+ uint16_t bdf_value;
+ uint32_t dphy_link_en_fuses;
+ uint32_t lanes_clock_division;
+ uint8_t link_used;
+ uint8_t lanes_used;
+ uint32_t csi_rx_dly_cnt_termen_clane;
+ uint32_t csi_rx_dly_cnt_settle_clane;
+ uint32_t csi_rx_dly_cnt_termen_dlane0;
+ uint32_t csi_rx_dly_cnt_settle_dlane0;
+ uint32_t csi_rx_dly_cnt_termen_dlane1;
+ uint32_t csi_rx_dly_cnt_settle_dlane1;
+ uint32_t csi_rx_dly_cnt_termen_dlane2;
+ uint32_t csi_rx_dly_cnt_settle_dlane2;
+ uint32_t csi_rx_dly_cnt_termen_dlane3;
+ uint32_t csi_rx_dly_cnt_settle_dlane3;
+ uint32_t max_lane_speed;
+ uint8_t sensor_calibration_file_index;
+ uint8_t sensor_calibration_file_index_mbz[3];
+ uint8_t rom_type;
+ uint8_t vcm_type;
+ uint8_t platform;
+ uint8_t platform_sub;
+ uint8_t flash_support;
+ uint8_t privacy_led;
+ uint8_t degree; /* Camera module rotation */
+ uint8_t mipi_define;
+ uint32_t mclk;
+ uint8_t control_logic_id;
+ uint8_t mipi_data_format;
+ uint8_t silicon_version;
+ uint8_t customer_id;
+ }ssdb;
+}__attribute__((packed))ov_camera_ssdb;
+
+struct drivers_i2c_ov_camera_config {
+
+ /* I2C Bus Frequency in Hertz (default 400kHz) */
+ unsigned bus_speed;
+ ov_camera_ssdb buf;
+ uint8_t vcm_addr;
+ uint8_t eeprom0_addr;
+ const char acpi_hid[9];
+ const char acpi_name[5];
+ uint64_t acpi_uid;
+};
diff --git a/src/drivers/i2c/ov_camera/ov_camera.c b/src/drivers/i2c/ov_camera/ov_camera.c
new file mode 100644
index 0000000..02bcda6
--- /dev/null
+++ b/src/drivers/i2c/ov_camera/ov_camera.c
@@ -0,0 +1,112 @@
+/*
+ * This file is part of the coreboot project.
+ *
+ * Copyright 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 <arch/acpi.h>
+#include <arch/acpi_device.h>
+#include <arch/acpigen.h>
+#include <console/console.h>
+#include <device/i2c.h>
+#include <device/device.h>
+#include <device/path.h>
+#include <stdint.h>
+#include <string.h>
+#include "chip.h"
+
+#if IS_ENABLED(CONFIG_HAVE_ACPI_TABLES)
+
+static void ov_camera_fill_ssdt(struct device *dev)
+{
+ struct drivers_i2c_ov_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 = config->bus_speed ? : I2C_SPEED_FAST,
+ .resource = scope,
+ };
+ struct acpi_i2c i2c_vcm = {
+ .address = config->vcm_addr,
+ .mode_10bit = dev->path.i2c.mode_10bit,
+ .speed = config->bus_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", dev->chip_ops->name);
+ acpigen_write_STA(ACPI_STATUS_DEVICE_ALL_ON);
+
+ /* Resources */
+// acpigen_write_method("_CRS", 0)
+ acpigen_write_name("_CRS");
+ acpigen_write_resourcetemplate_header();
+ acpi_device_write_i2c(&i2c);
+ acpi_device_write_i2c(&i2c_vcm);
+/*
+ int i;
+ for (i = 0; i < 4; i++) {
+ struct acpi_i2c i2c_eeprom = {
+ .address = config->eeprom0_addr + i,
+ .mode_10bit = dev->path.i2c.mode_10bit,
+ .speed = config->bus_speed ? : I2C_SPEED_FAST,
+ .resource = scope,
+ };
+ acpi_device_write_i2c(&i2c_eeprom);
+ }
+*/
+ acpigen_write_resourcetemplate_footer();
+
+ /* Device Properties */
+ acpigen_write_method_serialized("SSDB",0);
+ acpigen_write_return_byte_buffer((uint8_t *)&config->buf,
+ MAX_SSDB_BUF);
+ acpigen_pop_len(); /* Method */
+ acpigen_pop_len(); /* Device */
+ acpigen_pop_len(); /* Scope */
+
+}
+
+static const char *ov_camera_acpi_name(struct device *dev)
+{
+ struct drivers_i2c_ov_camera_config *config = dev->chip_info;
+ return config->acpi_name;
+}
+#endif
+
+static struct device_operations ov_camera_ops = {
+ .read_resources = DEVICE_NOOP,
+ .set_resources = DEVICE_NOOP,
+ .enable_resources = DEVICE_NOOP,
+#if IS_ENABLED(CONFIG_HAVE_ACPI_TABLES)
+ .acpi_name = &ov_camera_acpi_name,
+ .acpi_fill_ssdt_generator = &ov_camera_fill_ssdt,
+#endif
+};
+
+static void ov_camera_enable(struct device *dev)
+{
+ dev->ops = &ov_camera_ops;
+}
+
+struct chip_operations drivers_i2c_ov_camera_ops = {
+ CHIP_NAME("OV CAMERA")
+ .enable_dev = &ov_camera_enable
+};
More information about the coreboot-gerrit
mailing list