Stefan Reinauer | 155e9b5 | 2012-04-27 23:19:58 +0200 | [diff] [blame] | 1 | /* |
| 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 Reinauer | 155e9b5 | 2012-04-27 23:19:58 +0200 | [diff] [blame] | 15 | */ |
| 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 Serbinenko | a2a906e | 2014-09-01 01:41:37 +0200 | [diff] [blame] | 23 | #include <drivers/intel/gma/int15.h> |
Stefan Reinauer | 155e9b5 | 2012-04-27 23:19:58 +0200 | [diff] [blame] | 24 | #include <pc80/mc146818rtc.h> |
| 25 | #include <arch/acpi.h> |
| 26 | #include <arch/io.h> |
| 27 | #include <arch/interrupt.h> |
Stefan Reinauer | 3e4e303 | 2013-03-20 14:08:04 -0700 | [diff] [blame] | 28 | #include <boot/coreboot_tables.h> |
Stefan Reinauer | 155e9b5 | 2012-04-27 23:19:58 +0200 | [diff] [blame] | 29 | #include <ec/smsc/mec1308/ec.h> |
Stefan Reinauer | 155e9b5 | 2012-04-27 23:19:58 +0200 | [diff] [blame] | 30 | #include "ec.h" |
| 31 | #include "onboard.h" |
| 32 | #include <southbridge/intel/bd82x6x/pch.h> |
| 33 | #include <smbios.h> |
Aaron Durbin | b0f8151 | 2016-07-25 21:31:41 -0500 | [diff] [blame] | 34 | #include <vendorcode/google/chromeos/chromeos.h> |
Stefan Reinauer | 155e9b5 | 2012-04-27 23:19:58 +0200 | [diff] [blame] | 35 | |
| 36 | void mainboard_suspend_resume(void) |
| 37 | { |
Stefan Reinauer | 155e9b5 | 2012-04-27 23:19:58 +0200 | [diff] [blame] | 38 | /* 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 Reinauer | 155e9b5 | 2012-04-27 23:19:58 +0200 | [diff] [blame] | 43 | |
Stefan Reinauer | 155e9b5 | 2012-04-27 23:19:58 +0200 | [diff] [blame] | 44 | |
| 45 | static void mainboard_init(device_t dev) |
| 46 | { |
| 47 | /* Initialize the Embedded Controller */ |
| 48 | lumpy_ec_init(); |
| 49 | } |
| 50 | |
Stefan Reinauer | 155e9b5 | 2012-04-27 23:19:58 +0200 | [diff] [blame] | 51 | static 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 | |
| 77 | static 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älkki | b9cd5ec | 2015-04-24 16:05:58 +0300 | [diff] [blame] | 83 | BOARD_LIGHTSENSOR_NAME, |
| 84 | BOARD_LIGHTSENSOR_IRQ, |
| 85 | BOARD_LIGHTSENSOR_I2C_ADDR); |
Stefan Reinauer | 155e9b5 | 2012-04-27 23:19:58 +0200 | [diff] [blame] | 86 | |
| 87 | len += lumpy_smbios_type41_irq(handle, current, |
Kyösti Mälkki | b9cd5ec | 2015-04-24 16:05:58 +0300 | [diff] [blame] | 88 | BOARD_TRACKPAD_NAME, |
| 89 | BOARD_TRACKPAD_IRQ, |
| 90 | BOARD_TRACKPAD_I2C_ADDR); |
Stefan Reinauer | 155e9b5 | 2012-04-27 23:19:58 +0200 | [diff] [blame] | 91 | |
| 92 | return len; |
| 93 | } |
| 94 | |
Kyösti Mälkki | 9ead80f | 2012-08-28 07:49:49 +0300 | [diff] [blame] | 95 | // mainboard_enable is executed as first thing after |
| 96 | // enumerate_buses(). |
| 97 | |
| 98 | static void mainboard_enable(device_t dev) |
| 99 | { |
| 100 | dev->ops->init = mainboard_init; |
| 101 | dev->ops->get_smbios_data = lumpy_onboard_smbios_data; |
Aaron Durbin | b0f8151 | 2016-07-25 21:31:41 -0500 | [diff] [blame] | 102 | dev->ops->acpi_inject_dsdt_generator = chromeos_dsdt_generator; |
Vladimir Serbinenko | a2a906e | 2014-09-01 01:41:37 +0200 | [diff] [blame] | 103 | 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] | 104 | } |
| 105 | |
Stefan Reinauer | 155e9b5 | 2012-04-27 23:19:58 +0200 | [diff] [blame] | 106 | struct chip_operations mainboard_ops = { |
Stefan Reinauer | 155e9b5 | 2012-04-27 23:19:58 +0200 | [diff] [blame] | 107 | .enable_dev = mainboard_enable, |
Stefan Reinauer | 155e9b5 | 2012-04-27 23:19:58 +0200 | [diff] [blame] | 108 | }; |