V Sowmya | 9f8023a | 2017-02-28 17:52:05 +0530 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the coreboot project. |
| 3 | * |
V Sowmya | 9f8023a | 2017-02-28 17:52:05 +0530 | [diff] [blame] | 4 | * 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 Huber | 0f2dd1e | 2017-08-01 14:02:40 +0200 | [diff] [blame] | 18 | #include <device/i2c_simple.h> |
V Sowmya | 9f8023a | 2017-02-28 17:52:05 +0530 | [diff] [blame] | 19 | #include <device/device.h> |
| 20 | #include <device/path.h> |
V Sowmya | 9f8023a | 2017-02-28 17:52:05 +0530 | [diff] [blame] | 21 | #include "chip.h" |
| 22 | |
| 23 | static 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 Lin | b4be50c | 2018-09-10 10:55:49 +0800 | [diff] [blame] | 43 | acpigen_write_STA(acpi_device_status(dev)); |
V Sowmya | 9f8023a | 2017-02-28 17:52:05 +0530 | [diff] [blame] | 44 | |
| 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 Durbin | aa090cb | 2017-09-13 16:01:52 -0600 | [diff] [blame] | 74 | static const char *camera_acpi_name(const struct device *dev) |
V Sowmya | 9f8023a | 2017-02-28 17:52:05 +0530 | [diff] [blame] | 75 | { |
| 76 | struct drivers_intel_mipi_camera_config *config = dev->chip_info; |
| 77 | return config->acpi_name; |
| 78 | } |
| 79 | |
| 80 | static struct device_operations camera_ops = { |
| 81 | .read_resources = DEVICE_NOOP, |
| 82 | .set_resources = DEVICE_NOOP, |
| 83 | .enable_resources = DEVICE_NOOP, |
Elyes HAOUAS | 2aa3b16 | 2018-11-27 17:02:10 +0100 | [diff] [blame] | 84 | .acpi_name = camera_acpi_name, |
| 85 | .acpi_fill_ssdt_generator = camera_fill_ssdt, |
V Sowmya | 9f8023a | 2017-02-28 17:52:05 +0530 | [diff] [blame] | 86 | }; |
| 87 | |
| 88 | static void camera_enable(struct device *dev) |
| 89 | { |
| 90 | dev->ops = &camera_ops; |
| 91 | } |
| 92 | |
| 93 | struct chip_operations drivers_intel_mipi_camera_ops = { |
| 94 | CHIP_NAME("Intel MIPI Camera Device") |
Elyes HAOUAS | 2aa3b16 | 2018-11-27 17:02:10 +0100 | [diff] [blame] | 95 | .enable_dev = camera_enable |
V Sowmya | 9f8023a | 2017-02-28 17:52:05 +0530 | [diff] [blame] | 96 | }; |