Sven Schnelle | d8129f9 | 2011-04-20 09:12:17 +0000 | [diff] [blame] | 1 | /* |
| 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 Schnelle | d8129f9 | 2011-04-20 09:12:17 +0000 | [diff] [blame] | 16 | */ |
| 17 | |
| 18 | #include <console/console.h> |
| 19 | #include <device/device.h> |
| 20 | #include <arch/io.h> |
Sven Schnelle | d8129f9 | 2011-04-20 09:12:17 +0000 | [diff] [blame] | 21 | #include <delay.h> |
Vladimir Serbinenko | 63acd22 | 2014-06-01 00:26:48 +0200 | [diff] [blame] | 22 | #include <string.h> |
Sven Schnelle | d8129f9 | 2011-04-20 09:12:17 +0000 | [diff] [blame] | 23 | #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 Schnelle | d40d4f77 | 2011-06-12 15:08:58 +0200 | [diff] [blame] | 30 | #include <pc80/mc146818rtc.h> |
Sven Schnelle | f02c396 | 2011-10-22 13:41:28 +0200 | [diff] [blame] | 31 | #include <arch/x86/include/arch/acpigen.h> |
Vladimir Serbinenko | 25b55f3 | 2014-03-04 17:43:57 +0100 | [diff] [blame] | 32 | #include <arch/interrupt.h> |
Trevor Mosey | 2237324 | 2014-05-02 20:07:03 -0500 | [diff] [blame] | 33 | #include <smbios.h> |
Vladimir Serbinenko | a2a906e | 2014-09-01 01:41:37 +0200 | [diff] [blame] | 34 | #include <drivers/intel/gma/int15.h> |
Vladimir Serbinenko | 25b55f3 | 2014-03-04 17:43:57 +0100 | [diff] [blame] | 35 | #define PANEL INT15_5F35_CL_DISPLAY_DEFAULT |
Sven Schnelle | f02c396 | 2011-10-22 13:41:28 +0200 | [diff] [blame] | 36 | |
Stefan Reinauer | 4cc8c70 | 2012-04-27 21:34:16 +0200 | [diff] [blame] | 37 | static 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 Schnelle | f02c396 | 2011-10-22 13:41:28 +0200 | [diff] [blame] | 41 | }; |
| 42 | |
Stefan Reinauer | 4cc8c70 | 2012-04-27 21:34:16 +0200 | [diff] [blame] | 43 | int get_cst_entries(acpi_cstate_t **entries) |
Sven Schnelle | f02c396 | 2011-10-22 13:41:28 +0200 | [diff] [blame] | 44 | { |
| 45 | *entries = cst_entries; |
| 46 | return ARRAY_SIZE(cst_entries); |
| 47 | } |
Sven Schnelle | d8129f9 | 2011-04-20 09:12:17 +0000 | [diff] [blame] | 48 | |
Trevor Mosey | 8e5435a | 2014-05-02 16:11:50 -0500 | [diff] [blame] | 49 | static void mainboard_init(device_t dev) |
Sven Schnelle | d8129f9 | 2011-04-20 09:12:17 +0000 | [diff] [blame] | 50 | { |
Sven Schnelle | b538110 | 2011-10-15 17:31:01 +0200 | [diff] [blame] | 51 | struct southbridge_intel_i82801gx_config *config; |
Sven Schnelle | edabf54 | 2011-04-27 19:47:49 +0000 | [diff] [blame] | 52 | device_t dev0, idedev; |
Sven Schnelle | d8129f9 | 2011-04-20 09:12:17 +0000 | [diff] [blame] | 53 | |
Vladimir Serbinenko | a2a906e | 2014-09-01 01:41:37 +0200 | [diff] [blame] | 54 | install_intel_vga_int15_handler(GMA_INT15_ACTIVE_LFP_INT_LVDS, GMA_INT15_PANEL_FIT_DEFAULT, PANEL, 3); |
Vladimir Serbinenko | 25b55f3 | 2014-03-04 17:43:57 +0100 | [diff] [blame] | 55 | |
Sven Schnelle | d8129f9 | 2011-04-20 09:12:17 +0000 | [diff] [blame] | 56 | /* If we're resuming from suspend, blink suspend LED */ |
| 57 | dev0 = dev_find_slot(0, PCI_DEVFN(0,0)); |
Sven Schnelle | d8c68a9 | 2011-06-15 09:26:34 +0200 | [diff] [blame] | 58 | if (dev0 && pci_read_config32(dev0, SKPAD) == SKPAD_ACPI_S3_MAGIC) |
Sven Schnelle | d8129f9 | 2011-04-20 09:12:17 +0000 | [diff] [blame] | 59 | ec_write(0x0c, 0xc7); |
| 60 | |
Sven Schnelle | edabf54 | 2011-04-27 19:47:49 +0000 | [diff] [blame] | 61 | idedev = dev_find_slot(0, PCI_DEVFN(0x1f,1)); |
Sven Schnelle | b538110 | 2011-10-15 17:31:01 +0200 | [diff] [blame] | 62 | |
| 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 Schnelle | edabf54 | 2011-04-27 19:47:49 +0000 | [diff] [blame] | 70 | 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 Schnelle | d40d4f77 | 2011-06-12 15:08:58 +0200 | [diff] [blame] | 77 | |
Sven Schnelle | 00d4649 | 2011-06-17 21:26:28 +0200 | [diff] [blame] | 78 | /* set dock status led */ |
Sven Schnelle | 61cd5bf | 2011-06-23 19:12:25 +0200 | [diff] [blame] | 79 | ec_write(0x0c, 0x08); |
| 80 | ec_write(0x0c, inb(0x164c) & 8 ? 0x89 : 0x09); |
Sven Schnelle | d8129f9 | 2011-04-20 09:12:17 +0000 | [diff] [blame] | 81 | } |
| 82 | |
Trevor Mosey | 8e5435a | 2014-05-02 16:11:50 -0500 | [diff] [blame] | 83 | static void mainboard_enable(device_t dev) |
| 84 | { |
| 85 | dev->ops->init = mainboard_init; |
| 86 | } |
| 87 | |
Sven Schnelle | d8129f9 | 2011-04-20 09:12:17 +0000 | [diff] [blame] | 88 | struct chip_operations mainboard_ops = { |
Sven Schnelle | d8129f9 | 2011-04-20 09:12:17 +0000 | [diff] [blame] | 89 | .enable_dev = mainboard_enable, |
| 90 | }; |