blob: 44fa4029f945754832c762e6182fac9634c6e6a2 [file] [log] [blame]
Sven Schnelled8129f92011-04-20 09:12:17 +00001/*
2 * This file is part of the coreboot project.
3 *
4 * Copyright (C) 2007-2009 coresystems GmbH
5 * Copyright (C) 2011 Sven Schnelle <svens@stackframe.org>
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License as
9 * published by the Free Software Foundation; version 2 of
10 * the License.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
Sven Schnelled8129f92011-04-20 09:12:17 +000016 */
17
18#include <console/console.h>
19#include <device/device.h>
20#include <arch/io.h>
Sven Schnelled8129f92011-04-20 09:12:17 +000021#include <delay.h>
Vladimir Serbinenko63acd222014-06-01 00:26:48 +020022#include <string.h>
Sven Schnelled8129f92011-04-20 09:12:17 +000023#include <device/pci_def.h>
24#include <device/pci_ops.h>
25#include <arch/io.h>
26#include <ec/lenovo/pmh7/pmh7.h>
27#include <ec/acpi/ec.h>
28#include <ec/lenovo/h8/h8.h>
29#include <northbridge/intel/i945/i945.h>
Sven Schnelled40d4f772011-06-12 15:08:58 +020030#include <pc80/mc146818rtc.h>
Sven Schnellef02c3962011-10-22 13:41:28 +020031#include <arch/x86/include/arch/acpigen.h>
Vladimir Serbinenko25b55f32014-03-04 17:43:57 +010032#include <arch/interrupt.h>
Trevor Mosey22373242014-05-02 20:07:03 -050033#include <smbios.h>
Vladimir Serbinenkoa2a906e2014-09-01 01:41:37 +020034#include <drivers/intel/gma/int15.h>
Vladimir Serbinenko25b55f32014-03-04 17:43:57 +010035#define PANEL INT15_5F35_CL_DISPLAY_DEFAULT
Sven Schnellef02c3962011-10-22 13:41:28 +020036
Stefan Reinauer4cc8c702012-04-27 21:34:16 +020037static acpi_cstate_t cst_entries[] = {
38 { 1, 1, 1000, { 0x7f, 1, 2, { 0 }, 1, 0 } },
39 { 2, 1, 500, { 0x01, 8, 0, { 0 }, DEFAULT_PMBASE + LV2, 0 } },
40 { 2, 17, 250, { 0x01, 8, 0, { 0 }, DEFAULT_PMBASE + LV3, 0 } },
Sven Schnellef02c3962011-10-22 13:41:28 +020041};
42
Stefan Reinauer4cc8c702012-04-27 21:34:16 +020043int get_cst_entries(acpi_cstate_t **entries)
Sven Schnellef02c3962011-10-22 13:41:28 +020044{
45 *entries = cst_entries;
46 return ARRAY_SIZE(cst_entries);
47}
Sven Schnelled8129f92011-04-20 09:12:17 +000048
Trevor Mosey8e5435a2014-05-02 16:11:50 -050049static void mainboard_init(device_t dev)
Sven Schnelled8129f92011-04-20 09:12:17 +000050{
Sven Schnelleb5381102011-10-15 17:31:01 +020051 struct southbridge_intel_i82801gx_config *config;
Sven Schnelleedabf542011-04-27 19:47:49 +000052 device_t dev0, idedev;
Sven Schnelled8129f92011-04-20 09:12:17 +000053
Vladimir Serbinenkoa2a906e2014-09-01 01:41:37 +020054 install_intel_vga_int15_handler(GMA_INT15_ACTIVE_LFP_INT_LVDS, GMA_INT15_PANEL_FIT_DEFAULT, PANEL, 3);
Vladimir Serbinenko25b55f32014-03-04 17:43:57 +010055
Sven Schnelled8129f92011-04-20 09:12:17 +000056 /* If we're resuming from suspend, blink suspend LED */
57 dev0 = dev_find_slot(0, PCI_DEVFN(0,0));
Sven Schnelled8c68a92011-06-15 09:26:34 +020058 if (dev0 && pci_read_config32(dev0, SKPAD) == SKPAD_ACPI_S3_MAGIC)
Sven Schnelled8129f92011-04-20 09:12:17 +000059 ec_write(0x0c, 0xc7);
60
Sven Schnelleedabf542011-04-27 19:47:49 +000061 idedev = dev_find_slot(0, PCI_DEVFN(0x1f,1));
Sven Schnelleb5381102011-10-15 17:31:01 +020062
63 if (!(inb(DEFAULT_GPIOBASE + 0x0c) & 0x40)) {
64 /* legacy I/O connected */
65 pmh7_ultrabay_power_enable(1);
66 ec_write(0x0c, 0x84);
67 } else if (idedev && idedev->chip_info &&
68 h8_ultrabay_device_present()) {
69 config = idedev->chip_info;
Sven Schnelleedabf542011-04-27 19:47:49 +000070 config->ide_enable_primary = 1;
71 pmh7_ultrabay_power_enable(1);
72 ec_write(0x0c, 0x84);
73 } else {
74 pmh7_ultrabay_power_enable(0);
75 ec_write(0x0c, 0x04);
76 }
Sven Schnelled40d4f772011-06-12 15:08:58 +020077
Sven Schnelle00d46492011-06-17 21:26:28 +020078 /* set dock status led */
Sven Schnelle61cd5bf2011-06-23 19:12:25 +020079 ec_write(0x0c, 0x08);
80 ec_write(0x0c, inb(0x164c) & 8 ? 0x89 : 0x09);
Sven Schnelled8129f92011-04-20 09:12:17 +000081}
82
Trevor Mosey8e5435a2014-05-02 16:11:50 -050083static void mainboard_enable(device_t dev)
84{
85 dev->ops->init = mainboard_init;
86}
87
Sven Schnelled8129f92011-04-20 09:12:17 +000088struct chip_operations mainboard_ops = {
Sven Schnelled8129f92011-04-20 09:12:17 +000089 .enable_dev = mainboard_enable,
90};