blob: d804b2b9749f3b281ee07f5aed5ae154a581f779 [file] [log] [blame]
Angel Ponsd32b6de2020-04-03 01:23:13 +02001/* SPDX-License-Identifier: GPL-2.0-only */
Stefan Reinauer155e9b52012-04-27 23:19:58 +02002
3#include <types.h>
4#include <string.h>
5#include <device/device.h>
Vladimir Serbinenkoa2a906e2014-09-01 01:41:37 +02006#include <drivers/intel/gma/int15.h>
Furquan Shaikh76cedd22020-05-02 10:24:23 -07007#include <acpi/acpi.h>
Stefan Reinauer155e9b52012-04-27 23:19:58 +02008#include <ec/smsc/mec1308/ec.h>
Stefan Reinauer155e9b52012-04-27 23:19:58 +02009#include "ec.h"
10#include "onboard.h"
11#include <southbridge/intel/bd82x6x/pch.h>
12#include <smbios.h>
Aaron Durbinb0f81512016-07-25 21:31:41 -050013#include <vendorcode/google/chromeos/chromeos.h>
Stefan Reinauer155e9b52012-04-27 23:19:58 +020014
15void mainboard_suspend_resume(void)
16{
Stefan Reinauer155e9b52012-04-27 23:19:58 +020017 /* 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 HAOUAS5cb876c2018-06-08 18:31:43 +020022static void mainboard_init(struct device *dev)
Stefan Reinauer155e9b52012-04-27 23:19:58 +020023{
24 /* Initialize the Embedded Controller */
25 lumpy_ec_init();
26}
27
Stefan Reinauer155e9b52012-04-27 23:19:58 +020028static int lumpy_smbios_type41_irq(int *handle, unsigned long *current,
29 const char *name, u8 irq, u8 addr)
30{
Angel Ponsd62a5012021-06-28 17:18:06 +020031 struct smbios_type41 *t = smbios_carve_table(*current,
32 SMBIOS_ONBOARD_DEVICES_EXTENDED_INFORMATION,
33 sizeof(*t), *handle);
Stefan Reinauer155e9b52012-04-27 23:19:58 +020034
Stefan Reinauer155e9b52012-04-27 23:19:58 +020035 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 Ponsa37701a2021-06-28 17:36:53 +020044 const int len = smbios_full_table_len(&t->header, t->eos);
Stefan Reinauer155e9b52012-04-27 23:19:58 +020045 *current += len;
46 *handle += 1;
47 return len;
48}
49
50
Elyes HAOUAS5cb876c2018-06-08 18:31:43 +020051static int lumpy_onboard_smbios_data(struct device *dev, int *handle,
Stefan Reinauer155e9b52012-04-27 23:19:58 +020052 unsigned long *current)
53{
54 int len = 0;
55
56 len += lumpy_smbios_type41_irq(handle, current,
Kyösti Mälkkib9cd5ec2015-04-24 16:05:58 +030057 BOARD_LIGHTSENSOR_NAME,
58 BOARD_LIGHTSENSOR_IRQ,
59 BOARD_LIGHTSENSOR_I2C_ADDR);
Stefan Reinauer155e9b52012-04-27 23:19:58 +020060
61 len += lumpy_smbios_type41_irq(handle, current,
Kyösti Mälkkib9cd5ec2015-04-24 16:05:58 +030062 BOARD_TRACKPAD_NAME,
63 BOARD_TRACKPAD_IRQ,
64 BOARD_TRACKPAD_I2C_ADDR);
Stefan Reinauer155e9b52012-04-27 23:19:58 +020065
66 return len;
67}
68
Kyösti Mälkki9ead80f2012-08-28 07:49:49 +030069// mainboard_enable is executed as first thing after
70// enumerate_buses().
71
Elyes HAOUAS5cb876c2018-06-08 18:31:43 +020072static void mainboard_enable(struct device *dev)
Kyösti Mälkki9ead80f2012-08-28 07:49:49 +030073{
74 dev->ops->init = mainboard_init;
75 dev->ops->get_smbios_data = lumpy_onboard_smbios_data;
Nico Huber68680dd2020-03-31 17:34:52 +020076 dev->ops->acpi_inject_dsdt = chromeos_dsdt_generator;
Vladimir Serbinenkoa2a906e2014-09-01 01:41:37 +020077 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älkki9ead80f2012-08-28 07:49:49 +030078}
79
Stefan Reinauer155e9b52012-04-27 23:19:58 +020080struct chip_operations mainboard_ops = {
Stefan Reinauer155e9b52012-04-27 23:19:58 +020081 .enable_dev = mainboard_enable,
Stefan Reinauer155e9b52012-04-27 23:19:58 +020082};