blob: aabf2bad2d82de28cca8568c4bc6adc8fc37bfc9 [file] [log] [blame]
Angel Pons8a3453f2020-04-02 23:48:19 +02001/* SPDX-License-Identifier: GPL-2.0-only */
2/* This file is part of the coreboot project. */
V Sowmya9f8023a2017-02-28 17:52:05 +05303
4#include <arch/acpi.h>
5#include <arch/acpi_device.h>
6#include <arch/acpigen.h>
7#include <console/console.h>
Nico Huber0f2dd1e2017-08-01 14:02:40 +02008#include <device/i2c_simple.h>
V Sowmya9f8023a2017-02-28 17:52:05 +05309#include <device/device.h>
10#include <device/path.h>
V Sowmya9f8023a2017-02-28 17:52:05 +053011#include "chip.h"
12
13static void camera_fill_ssdt(struct device *dev)
14{
15 struct drivers_intel_mipi_camera_config *config = dev->chip_info;
16 const char *scope = acpi_device_scope(dev);
17 struct acpi_i2c i2c = {
18 .address = dev->path.i2c.device,
19 .mode_10bit = dev->path.i2c.mode_10bit,
20 .speed = I2C_SPEED_FAST,
21 .resource = scope,
22 };
23
24 if (!dev->enabled || !scope)
25 return;
26
27 /* Device */
28 acpigen_write_scope(scope);
29 acpigen_write_device(acpi_device_name(dev));
30 acpigen_write_name_string("_HID", config->acpi_hid);
31 acpigen_write_name_integer("_UID", config->acpi_uid);
32 acpigen_write_name_string("_DDN", config->chip_name);
Hung-Te Linb4be50c2018-09-10 10:55:49 +080033 acpigen_write_STA(acpi_device_status(dev));
V Sowmya9f8023a2017-02-28 17:52:05 +053034
35 /* Resources */
36 acpigen_write_name("_CRS");
37 acpigen_write_resourcetemplate_header();
38 acpi_device_write_i2c(&i2c);
39 acpigen_write_resourcetemplate_footer();
40
41 /* Mark it as Camera related device */
42 acpigen_write_name_integer("CAMD", config->device_type);
43
44 /* Create Device specific data */
45 if (config->device_type == INTEL_ACPI_CAMERA_SENSOR) {
46 acpigen_write_method_serialized("SSDB", 0);
47 acpigen_write_return_byte_buffer((uint8_t *)&config->ssdb,
48 sizeof(config->ssdb));
49 acpigen_pop_len(); /* Method */
50 }
51
52 /* Fill Power Sequencing Data */
53 acpigen_write_method_serialized("PWDB", 0);
54 acpigen_write_return_byte_buffer((uint8_t *)&config->pwdb,
55 (sizeof(struct intel_pwdb) * config->num_pwdb_entries));
56 acpigen_pop_len(); /* Method */
57
58 acpigen_pop_len(); /* Device */
59 acpigen_pop_len(); /* Scope */
60 printk(BIOS_INFO, "%s: %s address 0%xh\n", acpi_device_path(dev),
61 dev->chip_ops->name, dev->path.i2c.device);
62}
63
Aaron Durbinaa090cb2017-09-13 16:01:52 -060064static const char *camera_acpi_name(const struct device *dev)
V Sowmya9f8023a2017-02-28 17:52:05 +053065{
66 struct drivers_intel_mipi_camera_config *config = dev->chip_info;
67 return config->acpi_name;
68}
69
70static struct device_operations camera_ops = {
Nico Huber2f8ba692020-04-05 14:05:24 +020071 .read_resources = noop_read_resources,
72 .set_resources = noop_set_resources,
Nico Huber68680dd2020-03-31 17:34:52 +020073 .acpi_name = camera_acpi_name,
74 .acpi_fill_ssdt = camera_fill_ssdt,
V Sowmya9f8023a2017-02-28 17:52:05 +053075};
76
77static void camera_enable(struct device *dev)
78{
79 dev->ops = &camera_ops;
80}
81
82struct chip_operations drivers_intel_mipi_camera_ops = {
83 CHIP_NAME("Intel MIPI Camera Device")
Elyes HAOUAS2aa3b162018-11-27 17:02:10 +010084 .enable_dev = camera_enable
V Sowmya9f8023a2017-02-28 17:52:05 +053085};