Angel Pons | 89ab250 | 2020-04-03 01:22:28 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
| 2 | /* This file is part of the coreboot project. */ |
Sven Schnelle | e2ca71e | 2011-02-14 20:02:47 +0000 | [diff] [blame] | 3 | |
Sven Schnelle | e2ca71e | 2011-02-14 20:02:47 +0000 | [diff] [blame] | 4 | #include <device/pci_def.h> |
Jonathan A. Kollasch | 2596283 | 2012-07-10 10:14:17 -0500 | [diff] [blame] | 5 | #include <device/pci_ids.h> |
Patrick Rudolph | c670a41 | 2017-04-28 17:28:32 +0200 | [diff] [blame] | 6 | #include <device/device.h> |
Patrick Rudolph | e56189c | 2018-04-18 10:11:59 +0200 | [diff] [blame] | 7 | #include <device/pci_ops.h> |
Patrick Rudolph | c670a41 | 2017-04-28 17:28:32 +0200 | [diff] [blame] | 8 | #include <arch/io.h> |
Sven Schnelle | e2ca71e | 2011-02-14 20:02:47 +0000 | [diff] [blame] | 9 | #include <ec/acpi/ec.h> |
Sven Schnelle | 8099cbf | 2011-04-04 10:57:17 +0000 | [diff] [blame] | 10 | #include <northbridge/intel/i945/i945.h> |
Arthur Heymans | 742df5a | 2019-06-03 16:24:41 +0200 | [diff] [blame] | 11 | #include <southbridge/intel/i82801gx/chip.h> |
Sven Schnelle | 50270b8 | 2011-04-27 19:48:05 +0000 | [diff] [blame] | 12 | #include "dock.h" |
Vladimir Serbinenko | a2a906e | 2014-09-01 01:41:37 +0200 | [diff] [blame] | 13 | #include <drivers/intel/gma/int15.h> |
Patrick Rudolph | c670a41 | 2017-04-28 17:28:32 +0200 | [diff] [blame] | 14 | #include <drivers/lenovo/lenovo.h> |
Furquan Shaikh | 76cedd2 | 2020-05-02 10:24:23 -0700 | [diff] [blame^] | 15 | #include <acpi/acpigen.h> |
Vladimir Serbinenko | a2a906e | 2014-09-01 01:41:37 +0200 | [diff] [blame] | 16 | |
Denis 'GNUtoo' Carikli | 4062f17 | 2013-05-21 03:13:46 +0200 | [diff] [blame] | 17 | #define PANEL INT15_5F35_CL_DISPLAY_DEFAULT |
Sven Schnelle | 6eb8bef | 2011-10-23 16:57:50 +0200 | [diff] [blame] | 18 | |
Arthur Heymans | e1f0ac4 | 2016-05-19 16:02:38 +0200 | [diff] [blame] | 19 | #define MWAIT_RES(state, sub_state) \ |
| 20 | { \ |
| 21 | .space_id = ACPI_ADDRESS_SPACE_FIXED, \ |
| 22 | .bit_width = ACPI_FFIXEDHW_VENDOR_INTEL, \ |
| 23 | .bit_offset = ACPI_FFIXEDHW_CLASS_MWAIT, \ |
Elyes HAOUAS | 8ee161d | 2019-03-03 12:49:56 +0100 | [diff] [blame] | 24 | .access_size = 0, \ |
Arthur Heymans | e1f0ac4 | 2016-05-19 16:02:38 +0200 | [diff] [blame] | 25 | .addrl = (((state) << 4) | (sub_state)), \ |
| 26 | .addrh = 0, \ |
| 27 | } |
| 28 | |
Stefan Reinauer | 4cc8c70 | 2012-04-27 21:34:16 +0200 | [diff] [blame] | 29 | static acpi_cstate_t cst_entries[] = { |
Arthur Heymans | e1f0ac4 | 2016-05-19 16:02:38 +0200 | [diff] [blame] | 30 | { |
| 31 | .ctype = 1, |
| 32 | .latency = 1, |
| 33 | .power = 1000, |
| 34 | .resource = MWAIT_RES(0, 0), |
| 35 | }, |
| 36 | { |
| 37 | .ctype = 2, |
| 38 | .latency = 1, |
| 39 | .power = 500, |
| 40 | .resource = MWAIT_RES(1, 0), |
| 41 | }, |
| 42 | { |
| 43 | .ctype = 3, |
| 44 | .latency = 17, |
| 45 | .power = 250, |
| 46 | .resource = MWAIT_RES(2, 0), |
| 47 | }, |
Sven Schnelle | 6eb8bef | 2011-10-23 16:57:50 +0200 | [diff] [blame] | 48 | }; |
| 49 | |
Stefan Reinauer | 4cc8c70 | 2012-04-27 21:34:16 +0200 | [diff] [blame] | 50 | int get_cst_entries(acpi_cstate_t **entries) |
Sven Schnelle | 6eb8bef | 2011-10-23 16:57:50 +0200 | [diff] [blame] | 51 | { |
| 52 | *entries = cst_entries; |
| 53 | return ARRAY_SIZE(cst_entries); |
| 54 | } |
Sven Schnelle | e2ca71e | 2011-02-14 20:02:47 +0000 | [diff] [blame] | 55 | |
Elyes HAOUAS | 64b759e | 2018-05-05 09:11:32 +0200 | [diff] [blame] | 56 | static void mainboard_init(struct device *dev) |
Sven Schnelle | b31eb3e | 2011-04-05 13:00:14 +0000 | [diff] [blame] | 57 | { |
Elyes HAOUAS | 64b759e | 2018-05-05 09:11:32 +0200 | [diff] [blame] | 58 | struct device *idedev, *sdhci_dev; |
Sven Schnelle | b31eb3e | 2011-04-05 13:00:14 +0000 | [diff] [blame] | 59 | |
Sven Schnelle | 8d0b86c | 2011-07-11 18:36:16 +0200 | [diff] [blame] | 60 | ec_clr_bit(0x03, 2); |
| 61 | |
| 62 | if (inb(0x164c) & 0x08) { |
| 63 | ec_set_bit(0x03, 2); |
| 64 | ec_write(0x0c, 0x88); |
| 65 | } |
Denis 'GNUtoo' Carikli | 4062f17 | 2013-05-21 03:13:46 +0200 | [diff] [blame] | 66 | |
Patrick Rudolph | c670a41 | 2017-04-28 17:28:32 +0200 | [diff] [blame] | 67 | install_intel_vga_int15_handler(GMA_INT15_ACTIVE_LFP_INT_LVDS, |
| 68 | GMA_INT15_PANEL_FIT_DEFAULT, |
| 69 | PANEL, 3); |
Denis 'GNUtoo' Carikli | 4062f17 | 2013-05-21 03:13:46 +0200 | [diff] [blame] | 70 | |
Sven Schnelle | 8099cbf | 2011-04-04 10:57:17 +0000 | [diff] [blame] | 71 | /* If we're resuming from suspend, blink suspend LED */ |
Kyösti Mälkki | 8183025 | 2016-06-25 11:40:00 +0300 | [diff] [blame] | 72 | if (acpi_is_wakeup_s3()) |
Sven Schnelle | 8099cbf | 2011-04-04 10:57:17 +0000 | [diff] [blame] | 73 | ec_write(0x0c, 0xc7); |
Sven Schnelle | 50270b8 | 2011-04-27 19:48:05 +0000 | [diff] [blame] | 74 | |
Kyösti Mälkki | c70eed1 | 2018-05-22 02:18:00 +0300 | [diff] [blame] | 75 | idedev = pcidev_on_root(0x1f, 1); |
Sven Schnelle | 50270b8 | 2011-04-27 19:48:05 +0000 | [diff] [blame] | 76 | if (idedev && idedev->chip_info && dock_ultrabay_device_present()) { |
| 77 | struct southbridge_intel_i82801gx_config *config = idedev->chip_info; |
| 78 | config->ide_enable_primary = 1; |
| 79 | /* enable Ultrabay power */ |
| 80 | outb(inb(0x1628) | 0x01, 0x1628); |
| 81 | ec_write(0x0c, 0x84); |
| 82 | } else { |
| 83 | /* disable Ultrabay power */ |
| 84 | outb(inb(0x1628) & ~0x01, 0x1628); |
| 85 | ec_write(0x0c, 0x04); |
| 86 | } |
Sven Schnelle | d40d4f77 | 2011-06-12 15:08:58 +0200 | [diff] [blame] | 87 | |
Jonathan A. Kollasch | 2596283 | 2012-07-10 10:14:17 -0500 | [diff] [blame] | 88 | /* Set SDHCI write protect polarity "SDWPPol" */ |
| 89 | sdhci_dev = dev_find_device(PCI_VENDOR_ID_RICOH, PCI_DEVICE_ID_RICOH_R5C822, 0); |
| 90 | if (sdhci_dev) { |
| 91 | if (pci_read_config8(sdhci_dev, 0xfa) != 0x20) { |
| 92 | /* unlock */ |
| 93 | pci_write_config8(sdhci_dev, 0xf9, 0xfc); |
| 94 | /* set SDWPPol, keep CLKRUNDis, SDPWRPol clear */ |
| 95 | pci_write_config8(sdhci_dev, 0xfa, 0x20); |
| 96 | /* restore lock */ |
| 97 | pci_write_config8(sdhci_dev, 0xf9, 0x00); |
| 98 | } |
| 99 | } |
Sven Schnelle | e2ca71e | 2011-02-14 20:02:47 +0000 | [diff] [blame] | 100 | } |
| 101 | |
Furquan Shaikh | 7536a39 | 2020-04-24 21:59:21 -0700 | [diff] [blame] | 102 | static void fill_ssdt(const struct device *device) |
Vladimir Serbinenko | 0e64617 | 2014-08-31 00:27:05 +0200 | [diff] [blame] | 103 | { |
| 104 | drivers_lenovo_serial_ports_ssdt_generate("\\_SB.PCI0.LPCB", 1); |
| 105 | } |
| 106 | |
Elyes HAOUAS | 64b759e | 2018-05-05 09:11:32 +0200 | [diff] [blame] | 107 | static void mainboard_enable(struct device *dev) |
Peter Stuge | eac9916 | 2013-07-06 20:05:13 +0200 | [diff] [blame] | 108 | { |
| 109 | dev->ops->init = mainboard_init; |
Nico Huber | 68680dd | 2020-03-31 17:34:52 +0200 | [diff] [blame] | 110 | dev->ops->acpi_fill_ssdt = fill_ssdt; |
Peter Stuge | eac9916 | 2013-07-06 20:05:13 +0200 | [diff] [blame] | 111 | } |
| 112 | |
Sven Schnelle | e2ca71e | 2011-02-14 20:02:47 +0000 | [diff] [blame] | 113 | struct chip_operations mainboard_ops = { |
Sven Schnelle | e2ca71e | 2011-02-14 20:02:47 +0000 | [diff] [blame] | 114 | .enable_dev = mainboard_enable, |
| 115 | }; |