Angel Pons | d32b6de | 2020-04-03 01:23:13 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Stefan Reinauer | 155e9b5 | 2012-04-27 23:19:58 +0200 | [diff] [blame] | 2 | |
| 3 | #include <types.h> |
| 4 | #include <string.h> |
| 5 | #include <device/device.h> |
Vladimir Serbinenko | a2a906e | 2014-09-01 01:41:37 +0200 | [diff] [blame] | 6 | #include <drivers/intel/gma/int15.h> |
Furquan Shaikh | 76cedd2 | 2020-05-02 10:24:23 -0700 | [diff] [blame] | 7 | #include <acpi/acpi.h> |
Stefan Reinauer | 155e9b5 | 2012-04-27 23:19:58 +0200 | [diff] [blame] | 8 | #include <ec/smsc/mec1308/ec.h> |
Stefan Reinauer | 155e9b5 | 2012-04-27 23:19:58 +0200 | [diff] [blame] | 9 | #include "ec.h" |
| 10 | #include "onboard.h" |
| 11 | #include <southbridge/intel/bd82x6x/pch.h> |
| 12 | #include <smbios.h> |
Aaron Durbin | b0f8151 | 2016-07-25 21:31:41 -0500 | [diff] [blame] | 13 | #include <vendorcode/google/chromeos/chromeos.h> |
Stefan Reinauer | 155e9b5 | 2012-04-27 23:19:58 +0200 | [diff] [blame] | 14 | |
| 15 | void mainboard_suspend_resume(void) |
| 16 | { |
Stefan Reinauer | 155e9b5 | 2012-04-27 23:19:58 +0200 | [diff] [blame] | 17 | /* Enable EC ACPI mode for the OS before resume */ |
| 18 | send_ec_command(EC_SMI_DISABLE); |
| 19 | send_ec_command(EC_ACPI_ENABLE); |
| 20 | } |
| 21 | |
Elyes HAOUAS | 5cb876c | 2018-06-08 18:31:43 +0200 | [diff] [blame] | 22 | static void mainboard_init(struct device *dev) |
Stefan Reinauer | 155e9b5 | 2012-04-27 23:19:58 +0200 | [diff] [blame] | 23 | { |
| 24 | /* Initialize the Embedded Controller */ |
| 25 | lumpy_ec_init(); |
| 26 | } |
| 27 | |
Stefan Reinauer | 155e9b5 | 2012-04-27 23:19:58 +0200 | [diff] [blame] | 28 | static int lumpy_smbios_type41_irq(int *handle, unsigned long *current, |
| 29 | const char *name, u8 irq, u8 addr) |
| 30 | { |
Angel Pons | d62a501 | 2021-06-28 17:18:06 +0200 | [diff] [blame] | 31 | struct smbios_type41 *t = smbios_carve_table(*current, |
| 32 | SMBIOS_ONBOARD_DEVICES_EXTENDED_INFORMATION, |
| 33 | sizeof(*t), *handle); |
Stefan Reinauer | 155e9b5 | 2012-04-27 23:19:58 +0200 | [diff] [blame] | 34 | |
Stefan Reinauer | 155e9b5 | 2012-04-27 23:19:58 +0200 | [diff] [blame] | 35 | t->reference_designation = smbios_add_string(t->eos, name); |
| 36 | t->device_type = SMBIOS_DEVICE_TYPE_OTHER; |
| 37 | t->device_status = 1; |
| 38 | t->device_type_instance = irq; |
| 39 | t->segment_group_number = 0; |
| 40 | t->bus_number = addr; |
| 41 | t->function_number = 0; |
| 42 | t->device_number = 0; |
| 43 | |
Angel Pons | a37701a | 2021-06-28 17:36:53 +0200 | [diff] [blame] | 44 | const int len = smbios_full_table_len(&t->header, t->eos); |
Stefan Reinauer | 155e9b5 | 2012-04-27 23:19:58 +0200 | [diff] [blame] | 45 | *current += len; |
| 46 | *handle += 1; |
| 47 | return len; |
| 48 | } |
| 49 | |
| 50 | |
Elyes HAOUAS | 5cb876c | 2018-06-08 18:31:43 +0200 | [diff] [blame] | 51 | static int lumpy_onboard_smbios_data(struct device *dev, int *handle, |
Stefan Reinauer | 155e9b5 | 2012-04-27 23:19:58 +0200 | [diff] [blame] | 52 | unsigned long *current) |
| 53 | { |
| 54 | int len = 0; |
| 55 | |
| 56 | len += lumpy_smbios_type41_irq(handle, current, |
Kyösti Mälkki | b9cd5ec | 2015-04-24 16:05:58 +0300 | [diff] [blame] | 57 | BOARD_LIGHTSENSOR_NAME, |
| 58 | BOARD_LIGHTSENSOR_IRQ, |
| 59 | BOARD_LIGHTSENSOR_I2C_ADDR); |
Stefan Reinauer | 155e9b5 | 2012-04-27 23:19:58 +0200 | [diff] [blame] | 60 | |
| 61 | len += lumpy_smbios_type41_irq(handle, current, |
Kyösti Mälkki | b9cd5ec | 2015-04-24 16:05:58 +0300 | [diff] [blame] | 62 | BOARD_TRACKPAD_NAME, |
| 63 | BOARD_TRACKPAD_IRQ, |
| 64 | BOARD_TRACKPAD_I2C_ADDR); |
Stefan Reinauer | 155e9b5 | 2012-04-27 23:19:58 +0200 | [diff] [blame] | 65 | |
| 66 | return len; |
| 67 | } |
| 68 | |
Kyösti Mälkki | 9ead80f | 2012-08-28 07:49:49 +0300 | [diff] [blame] | 69 | // mainboard_enable is executed as first thing after |
| 70 | // enumerate_buses(). |
| 71 | |
Elyes HAOUAS | 5cb876c | 2018-06-08 18:31:43 +0200 | [diff] [blame] | 72 | static void mainboard_enable(struct device *dev) |
Kyösti Mälkki | 9ead80f | 2012-08-28 07:49:49 +0300 | [diff] [blame] | 73 | { |
| 74 | dev->ops->init = mainboard_init; |
| 75 | dev->ops->get_smbios_data = lumpy_onboard_smbios_data; |
Nico Huber | 68680dd | 2020-03-31 17:34:52 +0200 | [diff] [blame] | 76 | dev->ops->acpi_inject_dsdt = chromeos_dsdt_generator; |
Vladimir Serbinenko | a2a906e | 2014-09-01 01:41:37 +0200 | [diff] [blame] | 77 | install_intel_vga_int15_handler(GMA_INT15_ACTIVE_LFP_INT_LVDS, GMA_INT15_PANEL_FIT_DEFAULT, GMA_INT15_BOOT_DISPLAY_DEFAULT, 0); |
Kyösti Mälkki | 9ead80f | 2012-08-28 07:49:49 +0300 | [diff] [blame] | 78 | } |
| 79 | |
Stefan Reinauer | 155e9b5 | 2012-04-27 23:19:58 +0200 | [diff] [blame] | 80 | struct chip_operations mainboard_ops = { |
Stefan Reinauer | 155e9b5 | 2012-04-27 23:19:58 +0200 | [diff] [blame] | 81 | .enable_dev = mainboard_enable, |
Stefan Reinauer | 155e9b5 | 2012-04-27 23:19:58 +0200 | [diff] [blame] | 82 | }; |