Angel Pons | feedf23 | 2020-04-05 13:22:01 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Stefan Reinauer | 49428d8 | 2013-02-21 15:48:37 -0800 | [diff] [blame] | 2 | |
Furquan Shaikh | 76cedd2 | 2020-05-02 10:24:23 -0700 | [diff] [blame] | 3 | #include <acpi/acpi.h> |
Stefan Reinauer | 49428d8 | 2013-02-21 15:48:37 -0800 | [diff] [blame] | 4 | #include <console/console.h> |
| 5 | #include <cpu/x86/smm.h> |
Kyösti Mälkki | 661ad46 | 2020-12-29 06:26:21 +0200 | [diff] [blame] | 6 | #include <soc/nvs.h> |
Stefan Reinauer | 49428d8 | 2013-02-21 15:48:37 -0800 | [diff] [blame] | 7 | #include <southbridge/intel/bd82x6x/pch.h> |
| 8 | #include <southbridge/intel/bd82x6x/me.h> |
| 9 | #include <northbridge/intel/sandybridge/sandybridge.h> |
Stefan Reinauer | 49428d8 | 2013-02-21 15:48:37 -0800 | [diff] [blame] | 10 | |
Stefan Reinauer | 49428d8 | 2013-02-21 15:48:37 -0800 | [diff] [blame] | 11 | /* Include EC functions */ |
| 12 | #include <ec/google/chromeec/ec.h> |
Kyösti Mälkki | 923b8ec | 2022-11-29 07:36:44 +0200 | [diff] [blame] | 13 | #include <ec/google/chromeec/smm.h> |
Stefan Reinauer | 49428d8 | 2013-02-21 15:48:37 -0800 | [diff] [blame] | 14 | #include "ec.h" |
| 15 | |
Duncan Laurie | 0edc224 | 2013-04-29 15:04:30 -0700 | [diff] [blame] | 16 | void mainboard_smi_gpi(u32 gpi_sts) |
Stefan Reinauer | 49428d8 | 2013-02-21 15:48:37 -0800 | [diff] [blame] | 17 | { |
Kyösti Mälkki | 83faa5d | 2023-01-05 15:39:16 +0200 | [diff] [blame] | 18 | if (gpi_sts & (1 << EC_SMI_GPI)) |
| 19 | chromeec_smi_process_events(); |
Stefan Reinauer | 49428d8 | 2013-02-21 15:48:37 -0800 | [diff] [blame] | 20 | } |
| 21 | |
| 22 | void mainboard_smi_sleep(u8 slp_typ) |
| 23 | { |
| 24 | /* Disable USB charging if required */ |
| 25 | switch (slp_typ) { |
Aaron Durbin | 30b0c7a | 2016-07-13 13:01:13 -0500 | [diff] [blame] | 26 | case ACPI_S3: |
Kyösti Mälkki | 239abaf | 2020-06-28 12:12:01 +0300 | [diff] [blame] | 27 | if (gnvs->s3u0 == 0) |
Stefan Reinauer | 49428d8 | 2013-02-21 15:48:37 -0800 | [diff] [blame] | 28 | google_chromeec_set_usb_charge_mode( |
| 29 | 0, USB_CHARGE_MODE_DISABLED); |
Kyösti Mälkki | 239abaf | 2020-06-28 12:12:01 +0300 | [diff] [blame] | 30 | if (gnvs->s3u1 == 0) |
Stefan Reinauer | 49428d8 | 2013-02-21 15:48:37 -0800 | [diff] [blame] | 31 | google_chromeec_set_usb_charge_mode( |
| 32 | 1, USB_CHARGE_MODE_DISABLED); |
| 33 | break; |
Aaron Durbin | 30b0c7a | 2016-07-13 13:01:13 -0500 | [diff] [blame] | 34 | case ACPI_S5: |
Kyösti Mälkki | 239abaf | 2020-06-28 12:12:01 +0300 | [diff] [blame] | 35 | if (gnvs->s5u0 == 0) |
Stefan Reinauer | 49428d8 | 2013-02-21 15:48:37 -0800 | [diff] [blame] | 36 | google_chromeec_set_usb_charge_mode( |
| 37 | 0, USB_CHARGE_MODE_DISABLED); |
Kyösti Mälkki | 239abaf | 2020-06-28 12:12:01 +0300 | [diff] [blame] | 38 | if (gnvs->s5u1 == 0) |
Stefan Reinauer | 49428d8 | 2013-02-21 15:48:37 -0800 | [diff] [blame] | 39 | google_chromeec_set_usb_charge_mode( |
| 40 | 1, USB_CHARGE_MODE_DISABLED); |
| 41 | break; |
| 42 | } |
| 43 | |
| 44 | /* Disable SCI and SMI events */ |
| 45 | google_chromeec_set_smi_mask(0); |
| 46 | google_chromeec_set_sci_mask(0); |
| 47 | |
| 48 | /* Clear pending events that may trigger immediate wake */ |
Rob Barnes | f1ade48 | 2021-06-14 10:22:21 -0600 | [diff] [blame] | 49 | while (google_chromeec_get_event() != EC_HOST_EVENT_NONE) |
| 50 | ; |
Stefan Reinauer | 49428d8 | 2013-02-21 15:48:37 -0800 | [diff] [blame] | 51 | |
| 52 | /* Enable wake events */ |
| 53 | google_chromeec_set_wake_mask(LINK_EC_S3_WAKE_EVENTS); |
| 54 | } |
| 55 | |
Stefan Reinauer | 49428d8 | 2013-02-21 15:48:37 -0800 | [diff] [blame] | 56 | int mainboard_smi_apmc(u8 apmc) |
| 57 | { |
Kyösti Mälkki | 923b8ec | 2022-11-29 07:36:44 +0200 | [diff] [blame] | 58 | chromeec_smi_apmc(apmc, LINK_EC_SCI_EVENTS, LINK_EC_SMI_EVENTS); |
Stefan Reinauer | 49428d8 | 2013-02-21 15:48:37 -0800 | [diff] [blame] | 59 | return 0; |
| 60 | } |