blob: 3de067eb826ce1c790aa8c363067023d78fd9a83 [file] [log] [blame]
Stefan Reinauer155e9b52012-04-27 23:19:58 +02001/*
2 * This file is part of the coreboot project.
3 *
4 * Copyright (C) 2007-2009 coresystems GmbH
5 * Copyright (C) 2011 The ChromiumOS Authors. All rights reserved.
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; version 2 of the License.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
Stefan Reinauer155e9b52012-04-27 23:19:58 +020015 */
16
17#include <types.h>
18#include <string.h>
19#include <device/device.h>
20#include <device/pci_def.h>
21#include <device/pci_ops.h>
22#include <console/console.h>
Vladimir Serbinenkoa2a906e2014-09-01 01:41:37 +020023#include <drivers/intel/gma/int15.h>
Stefan Reinauer155e9b52012-04-27 23:19:58 +020024#include <pc80/mc146818rtc.h>
25#include <arch/acpi.h>
26#include <arch/io.h>
27#include <arch/interrupt.h>
Stefan Reinauer3e4e3032013-03-20 14:08:04 -070028#include <boot/coreboot_tables.h>
Stefan Reinauer155e9b52012-04-27 23:19:58 +020029#include <ec/smsc/mec1308/ec.h>
Stefan Reinauer155e9b52012-04-27 23:19:58 +020030#include "ec.h"
31#include "onboard.h"
32#include <southbridge/intel/bd82x6x/pch.h>
33#include <smbios.h>
Aaron Durbinb0f81512016-07-25 21:31:41 -050034#include <vendorcode/google/chromeos/chromeos.h>
Stefan Reinauer155e9b52012-04-27 23:19:58 +020035
36void mainboard_suspend_resume(void)
37{
Stefan Reinauer155e9b52012-04-27 23:19:58 +020038 /* Enable EC ACPI mode for the OS before resume */
39 send_ec_command(EC_SMI_DISABLE);
40 send_ec_command(EC_ACPI_ENABLE);
41}
42
Stefan Reinauer155e9b52012-04-27 23:19:58 +020043
Stefan Reinauer155e9b52012-04-27 23:19:58 +020044
45static void mainboard_init(device_t dev)
46{
47 /* Initialize the Embedded Controller */
48 lumpy_ec_init();
49}
50
Stefan Reinauer155e9b52012-04-27 23:19:58 +020051static int lumpy_smbios_type41_irq(int *handle, unsigned long *current,
52 const char *name, u8 irq, u8 addr)
53{
54 struct smbios_type41 *t = (struct smbios_type41 *)*current;
55 int len = sizeof(struct smbios_type41);
56
57 memset(t, 0, sizeof(struct smbios_type41));
58 t->type = SMBIOS_ONBOARD_DEVICES_EXTENDED_INFORMATION;
59 t->handle = *handle;
60 t->length = len - 2;
61 t->reference_designation = smbios_add_string(t->eos, name);
62 t->device_type = SMBIOS_DEVICE_TYPE_OTHER;
63 t->device_status = 1;
64 t->device_type_instance = irq;
65 t->segment_group_number = 0;
66 t->bus_number = addr;
67 t->function_number = 0;
68 t->device_number = 0;
69
70 len = t->length + smbios_string_table_len(t->eos);
71 *current += len;
72 *handle += 1;
73 return len;
74}
75
76
77static int lumpy_onboard_smbios_data(device_t dev, int *handle,
78 unsigned long *current)
79{
80 int len = 0;
81
82 len += lumpy_smbios_type41_irq(handle, current,
Kyösti Mälkkib9cd5ec2015-04-24 16:05:58 +030083 BOARD_LIGHTSENSOR_NAME,
84 BOARD_LIGHTSENSOR_IRQ,
85 BOARD_LIGHTSENSOR_I2C_ADDR);
Stefan Reinauer155e9b52012-04-27 23:19:58 +020086
87 len += lumpy_smbios_type41_irq(handle, current,
Kyösti Mälkkib9cd5ec2015-04-24 16:05:58 +030088 BOARD_TRACKPAD_NAME,
89 BOARD_TRACKPAD_IRQ,
90 BOARD_TRACKPAD_I2C_ADDR);
Stefan Reinauer155e9b52012-04-27 23:19:58 +020091
92 return len;
93}
94
Kyösti Mälkki9ead80f2012-08-28 07:49:49 +030095// mainboard_enable is executed as first thing after
96// enumerate_buses().
97
98static void mainboard_enable(device_t dev)
99{
100 dev->ops->init = mainboard_init;
101 dev->ops->get_smbios_data = lumpy_onboard_smbios_data;
Aaron Durbinb0f81512016-07-25 21:31:41 -0500102 dev->ops->acpi_inject_dsdt_generator = chromeos_dsdt_generator;
Vladimir Serbinenkoa2a906e2014-09-01 01:41:37 +0200103 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 +0300104}
105
Stefan Reinauer155e9b52012-04-27 23:19:58 +0200106struct chip_operations mainboard_ops = {
Stefan Reinauer155e9b52012-04-27 23:19:58 +0200107 .enable_dev = mainboard_enable,
Stefan Reinauer155e9b52012-04-27 23:19:58 +0200108};