blob: 2eb0c389f4e9d417f8129a2aa9cd6a65c6976f72 [file] [log] [blame]
Angel Pons89ab2502020-04-03 01:22:28 +02001/* SPDX-License-Identifier: GPL-2.0-only */
Sven Schnellee2ca71e2011-02-14 20:02:47 +00002
Sven Schnellee2ca71e2011-02-14 20:02:47 +00003#include <device/pci_def.h>
Jonathan A. Kollasch25962832012-07-10 10:14:17 -05004#include <device/pci_ids.h>
Patrick Rudolphc670a412017-04-28 17:28:32 +02005#include <device/device.h>
Patrick Rudolphe56189c2018-04-18 10:11:59 +02006#include <device/pci_ops.h>
Patrick Rudolphc670a412017-04-28 17:28:32 +02007#include <arch/io.h>
Sven Schnellee2ca71e2011-02-14 20:02:47 +00008#include <ec/acpi/ec.h>
Sven Schnelle8099cbf2011-04-04 10:57:17 +00009#include <northbridge/intel/i945/i945.h>
Arthur Heymans742df5a2019-06-03 16:24:41 +020010#include <southbridge/intel/i82801gx/chip.h>
Sven Schnelle50270b82011-04-27 19:48:05 +000011#include "dock.h"
Vladimir Serbinenkoa2a906e2014-09-01 01:41:37 +020012#include <drivers/intel/gma/int15.h>
Patrick Rudolphc670a412017-04-28 17:28:32 +020013#include <drivers/lenovo/lenovo.h>
Furquan Shaikh76cedd22020-05-02 10:24:23 -070014#include <acpi/acpigen.h>
Vladimir Serbinenkoa2a906e2014-09-01 01:41:37 +020015
Denis 'GNUtoo' Carikli4062f172013-05-21 03:13:46 +020016#define PANEL INT15_5F35_CL_DISPLAY_DEFAULT
Sven Schnelle6eb8bef2011-10-23 16:57:50 +020017
Elyes HAOUAS64b759e2018-05-05 09:11:32 +020018static void mainboard_init(struct device *dev)
Sven Schnelleb31eb3e2011-04-05 13:00:14 +000019{
Elyes HAOUAS64b759e2018-05-05 09:11:32 +020020 struct device *idedev, *sdhci_dev;
Sven Schnelleb31eb3e2011-04-05 13:00:14 +000021
Sven Schnelle8d0b86c2011-07-11 18:36:16 +020022 ec_clr_bit(0x03, 2);
23
24 if (inb(0x164c) & 0x08) {
25 ec_set_bit(0x03, 2);
26 ec_write(0x0c, 0x88);
27 }
Denis 'GNUtoo' Carikli4062f172013-05-21 03:13:46 +020028
Patrick Rudolphc670a412017-04-28 17:28:32 +020029 install_intel_vga_int15_handler(GMA_INT15_ACTIVE_LFP_INT_LVDS,
30 GMA_INT15_PANEL_FIT_DEFAULT,
31 PANEL, 3);
Denis 'GNUtoo' Carikli4062f172013-05-21 03:13:46 +020032
Sven Schnelle8099cbf2011-04-04 10:57:17 +000033 /* If we're resuming from suspend, blink suspend LED */
Kyösti Mälkki81830252016-06-25 11:40:00 +030034 if (acpi_is_wakeup_s3())
Sven Schnelle8099cbf2011-04-04 10:57:17 +000035 ec_write(0x0c, 0xc7);
Sven Schnelle50270b82011-04-27 19:48:05 +000036
Kyösti Mälkkic70eed12018-05-22 02:18:00 +030037 idedev = pcidev_on_root(0x1f, 1);
Sven Schnelle50270b82011-04-27 19:48:05 +000038 if (idedev && idedev->chip_info && dock_ultrabay_device_present()) {
39 struct southbridge_intel_i82801gx_config *config = idedev->chip_info;
40 config->ide_enable_primary = 1;
41 /* enable Ultrabay power */
42 outb(inb(0x1628) | 0x01, 0x1628);
43 ec_write(0x0c, 0x84);
44 } else {
45 /* disable Ultrabay power */
46 outb(inb(0x1628) & ~0x01, 0x1628);
47 ec_write(0x0c, 0x04);
48 }
Sven Schnelled40d4f772011-06-12 15:08:58 +020049
Jonathan A. Kollasch25962832012-07-10 10:14:17 -050050 /* Set SDHCI write protect polarity "SDWPPol" */
Felix Singer43b7f412022-03-07 04:34:52 +010051 sdhci_dev = dev_find_device(PCI_VID_RICOH, PCI_DID_RICOH_R5C822, 0);
Jonathan A. Kollasch25962832012-07-10 10:14:17 -050052 if (sdhci_dev) {
53 if (pci_read_config8(sdhci_dev, 0xfa) != 0x20) {
54 /* unlock */
55 pci_write_config8(sdhci_dev, 0xf9, 0xfc);
56 /* set SDWPPol, keep CLKRUNDis, SDPWRPol clear */
57 pci_write_config8(sdhci_dev, 0xfa, 0x20);
58 /* restore lock */
59 pci_write_config8(sdhci_dev, 0xf9, 0x00);
60 }
61 }
Sven Schnellee2ca71e2011-02-14 20:02:47 +000062}
63
Furquan Shaikh7536a392020-04-24 21:59:21 -070064static void fill_ssdt(const struct device *device)
Vladimir Serbinenko0e646172014-08-31 00:27:05 +020065{
66 drivers_lenovo_serial_ports_ssdt_generate("\\_SB.PCI0.LPCB", 1);
67}
68
Elyes HAOUAS64b759e2018-05-05 09:11:32 +020069static void mainboard_enable(struct device *dev)
Peter Stugeeac99162013-07-06 20:05:13 +020070{
71 dev->ops->init = mainboard_init;
Nico Huber68680dd2020-03-31 17:34:52 +020072 dev->ops->acpi_fill_ssdt = fill_ssdt;
Peter Stugeeac99162013-07-06 20:05:13 +020073}
74
Sven Schnellee2ca71e2011-02-14 20:02:47 +000075struct chip_operations mainboard_ops = {
Sven Schnellee2ca71e2011-02-14 20:02:47 +000076 .enable_dev = mainboard_enable,
77};