blob: 0cada814e988aceb2e31bd2b5da6aa077f2f6a20 [file] [log] [blame]
V Sowmya9f8023a2017-02-28 17:52:05 +05301/*
2 * This file is part of the coreboot project.
3 *
V Sowmya9f8023a2017-02-28 17:52:05 +05304 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 2 of the License.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 */
13
14#include <arch/acpi.h>
15#include <arch/acpi_device.h>
16#include <arch/acpigen.h>
17#include <console/console.h>
Nico Huber0f2dd1e2017-08-01 14:02:40 +020018#include <device/i2c_simple.h>
V Sowmya9f8023a2017-02-28 17:52:05 +053019#include <device/device.h>
20#include <device/path.h>
V Sowmya9f8023a2017-02-28 17:52:05 +053021#include "chip.h"
22
23static void camera_fill_ssdt(struct device *dev)
24{
25 struct drivers_intel_mipi_camera_config *config = dev->chip_info;
26 const char *scope = acpi_device_scope(dev);
27 struct acpi_i2c i2c = {
28 .address = dev->path.i2c.device,
29 .mode_10bit = dev->path.i2c.mode_10bit,
30 .speed = I2C_SPEED_FAST,
31 .resource = scope,
32 };
33
34 if (!dev->enabled || !scope)
35 return;
36
37 /* Device */
38 acpigen_write_scope(scope);
39 acpigen_write_device(acpi_device_name(dev));
40 acpigen_write_name_string("_HID", config->acpi_hid);
41 acpigen_write_name_integer("_UID", config->acpi_uid);
42 acpigen_write_name_string("_DDN", config->chip_name);
Hung-Te Linb4be50c2018-09-10 10:55:49 +080043 acpigen_write_STA(acpi_device_status(dev));
V Sowmya9f8023a2017-02-28 17:52:05 +053044
45 /* Resources */
46 acpigen_write_name("_CRS");
47 acpigen_write_resourcetemplate_header();
48 acpi_device_write_i2c(&i2c);
49 acpigen_write_resourcetemplate_footer();
50
51 /* Mark it as Camera related device */
52 acpigen_write_name_integer("CAMD", config->device_type);
53
54 /* Create Device specific data */
55 if (config->device_type == INTEL_ACPI_CAMERA_SENSOR) {
56 acpigen_write_method_serialized("SSDB", 0);
57 acpigen_write_return_byte_buffer((uint8_t *)&config->ssdb,
58 sizeof(config->ssdb));
59 acpigen_pop_len(); /* Method */
60 }
61
62 /* Fill Power Sequencing Data */
63 acpigen_write_method_serialized("PWDB", 0);
64 acpigen_write_return_byte_buffer((uint8_t *)&config->pwdb,
65 (sizeof(struct intel_pwdb) * config->num_pwdb_entries));
66 acpigen_pop_len(); /* Method */
67
68 acpigen_pop_len(); /* Device */
69 acpigen_pop_len(); /* Scope */
70 printk(BIOS_INFO, "%s: %s address 0%xh\n", acpi_device_path(dev),
71 dev->chip_ops->name, dev->path.i2c.device);
72}
73
Aaron Durbinaa090cb2017-09-13 16:01:52 -060074static const char *camera_acpi_name(const struct device *dev)
V Sowmya9f8023a2017-02-28 17:52:05 +053075{
76 struct drivers_intel_mipi_camera_config *config = dev->chip_info;
77 return config->acpi_name;
78}
79
80static struct device_operations camera_ops = {
81 .read_resources = DEVICE_NOOP,
82 .set_resources = DEVICE_NOOP,
83 .enable_resources = DEVICE_NOOP,
Elyes HAOUAS2aa3b162018-11-27 17:02:10 +010084 .acpi_name = camera_acpi_name,
85 .acpi_fill_ssdt_generator = camera_fill_ssdt,
V Sowmya9f8023a2017-02-28 17:52:05 +053086};
87
88static void camera_enable(struct device *dev)
89{
90 dev->ops = &camera_ops;
91}
92
93struct chip_operations drivers_intel_mipi_camera_ops = {
94 CHIP_NAME("Intel MIPI Camera Device")
Elyes HAOUAS2aa3b162018-11-27 17:02:10 +010095 .enable_dev = camera_enable
V Sowmya9f8023a2017-02-28 17:52:05 +053096};