blob: 61f72abc0788aa87b763f54aa95a67bedd1235eb [file] [log] [blame]
Angel Pons8a3453f2020-04-02 23:48:19 +02001/* SPDX-License-Identifier: GPL-2.0-only */
V Sowmya9f8023a2017-02-28 17:52:05 +05302
Furquan Shaikh76cedd22020-05-02 10:24:23 -07003#include <acpi/acpi.h>
4#include <acpi/acpi_device.h>
5#include <acpi/acpigen.h>
V Sowmya9f8023a2017-02-28 17:52:05 +05306#include <console/console.h>
Nico Huber0f2dd1e2017-08-01 14:02:40 +02007#include <device/i2c_simple.h>
V Sowmya9f8023a2017-02-28 17:52:05 +05308#include <device/device.h>
9#include <device/path.h>
V Sowmya9f8023a2017-02-28 17:52:05 +053010#include "chip.h"
11
Furquan Shaikh7536a392020-04-24 21:59:21 -070012static void camera_fill_ssdt(const struct device *dev)
V Sowmya9f8023a2017-02-28 17:52:05 +053013{
14 struct drivers_intel_mipi_camera_config *config = dev->chip_info;
15 const char *scope = acpi_device_scope(dev);
16 struct acpi_i2c i2c = {
17 .address = dev->path.i2c.device,
18 .mode_10bit = dev->path.i2c.mode_10bit,
19 .speed = I2C_SPEED_FAST,
20 .resource = scope,
21 };
22
23 if (!dev->enabled || !scope)
24 return;
25
26 /* Device */
27 acpigen_write_scope(scope);
28 acpigen_write_device(acpi_device_name(dev));
29 acpigen_write_name_string("_HID", config->acpi_hid);
30 acpigen_write_name_integer("_UID", config->acpi_uid);
31 acpigen_write_name_string("_DDN", config->chip_name);
Hung-Te Linb4be50c2018-09-10 10:55:49 +080032 acpigen_write_STA(acpi_device_status(dev));
V Sowmya9f8023a2017-02-28 17:52:05 +053033
34 /* Resources */
35 acpigen_write_name("_CRS");
36 acpigen_write_resourcetemplate_header();
37 acpi_device_write_i2c(&i2c);
38 acpigen_write_resourcetemplate_footer();
39
40 /* Mark it as Camera related device */
41 acpigen_write_name_integer("CAMD", config->device_type);
42
43 /* Create Device specific data */
44 if (config->device_type == INTEL_ACPI_CAMERA_SENSOR) {
45 acpigen_write_method_serialized("SSDB", 0);
46 acpigen_write_return_byte_buffer((uint8_t *)&config->ssdb,
47 sizeof(config->ssdb));
48 acpigen_pop_len(); /* Method */
49 }
50
51 /* Fill Power Sequencing Data */
52 acpigen_write_method_serialized("PWDB", 0);
53 acpigen_write_return_byte_buffer((uint8_t *)&config->pwdb,
54 (sizeof(struct intel_pwdb) * config->num_pwdb_entries));
55 acpigen_pop_len(); /* Method */
56
57 acpigen_pop_len(); /* Device */
58 acpigen_pop_len(); /* Scope */
59 printk(BIOS_INFO, "%s: %s address 0%xh\n", acpi_device_path(dev),
60 dev->chip_ops->name, dev->path.i2c.device);
61}
62
Aaron Durbinaa090cb2017-09-13 16:01:52 -060063static const char *camera_acpi_name(const struct device *dev)
V Sowmya9f8023a2017-02-28 17:52:05 +053064{
65 struct drivers_intel_mipi_camera_config *config = dev->chip_info;
66 return config->acpi_name;
67}
68
69static struct device_operations camera_ops = {
Nico Huber2f8ba692020-04-05 14:05:24 +020070 .read_resources = noop_read_resources,
71 .set_resources = noop_set_resources,
Nico Huber68680dd2020-03-31 17:34:52 +020072 .acpi_name = camera_acpi_name,
73 .acpi_fill_ssdt = camera_fill_ssdt,
V Sowmya9f8023a2017-02-28 17:52:05 +053074};
75
76static void camera_enable(struct device *dev)
77{
78 dev->ops = &camera_ops;
79}
80
81struct chip_operations drivers_intel_mipi_camera_ops = {
82 CHIP_NAME("Intel MIPI Camera Device")
Elyes HAOUAS2aa3b162018-11-27 17:02:10 +010083 .enable_dev = camera_enable
V Sowmya9f8023a2017-02-28 17:52:05 +053084};