0014-ec-dell-mec5035-Route-power-button-event-to-host.patch 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. From 847b2b952602576f8c3bab678377ff4a770d2fc8 Mon Sep 17 00:00:00 2001
  2. From: Nicholas Chin <nic.c3.14@gmail.com>
  3. Date: Tue, 18 Jun 2024 21:31:08 -0600
  4. Subject: [PATCH 14/18] ec/dell/mec5035: Route power button event to host
  5. If command 0x3e with an argument of 1 isn't sent to the EC, pressing the
  6. power button results in the EC powering off the system without letting
  7. the OS cleanly shutting itself down. This command and argument tells the
  8. EC to route power button events to the host so that it can determine
  9. what to do.
  10. The EC command was identified from the ec/google/wilco code, which is
  11. used for Dell's Latitude Chromebooks. According to the EC_GOOGLE_WILCO
  12. Kconfig help text, those ECs run a modified version of Dell's typical
  13. Latitude EC firmware, so it is likely that the two firmware
  14. implementations use similar commands. Examining LPC traffic between the
  15. host and the EC on the Latitude E6400 did reveal that the same command
  16. was being sent by the vendor firmware to the EC, but this does not
  17. confirm that it has the same meaning as the command from the Wilco code.
  18. Sending the command using inb/outb calls in a userspace C program while
  19. running coreboot without this patch did allow subsequent power button
  20. events to be handled by the host, confirming that the command was indeed
  21. the same.
  22. Change-Id: I5ded315270c0e1efbbc90cfa9d9d894b872e99a2
  23. Signed-off-by: Nicholas Chin <nic.c3.14@gmail.com>
  24. ---
  25. src/ec/dell/mec5035/mec5035.c | 8 ++++++++
  26. src/ec/dell/mec5035/mec5035.h | 7 +++++++
  27. 2 files changed, 15 insertions(+)
  28. diff --git a/src/ec/dell/mec5035/mec5035.c b/src/ec/dell/mec5035/mec5035.c
  29. index 85c2ab0140..bdae929a27 100644
  30. --- a/src/ec/dell/mec5035/mec5035.c
  31. +++ b/src/ec/dell/mec5035/mec5035.c
  32. @@ -94,6 +94,13 @@ void mec5035_control_radio(enum ec_radio_dev dev, enum ec_radio_state state)
  33. ec_command(CMD_RADIO_CTRL);
  34. }
  35. +void mec5035_power_button_route(enum ec_power_button_route target)
  36. +{
  37. + u8 buf = (u8)target;
  38. + write_mailbox_regs(&buf, 2, 1);
  39. + ec_command(CMD_POWER_BUTTON_TO_HOST);
  40. +}
  41. +
  42. void mec5035_change_wake(u8 source, enum ec_wake_change change)
  43. {
  44. u8 buf[ACPI_WAKEUP_NUM_ARGS] = {change, source, 0, 0x40};
  45. @@ -121,6 +128,7 @@ static void mec5035_init(struct device *dev)
  46. /* Unconditionally use this argument for now as this setting
  47. is probably the most sensible default out of the 3 choices. */
  48. mec5035_mouse_touchpad(TP_PS2_MOUSE);
  49. + mec5035_power_button_route(HOST);
  50. pc_keyboard_init(NO_AUX_DEVICE);
  51. diff --git a/src/ec/dell/mec5035/mec5035.h b/src/ec/dell/mec5035/mec5035.h
  52. index 8d4fded28b..51422598c4 100644
  53. --- a/src/ec/dell/mec5035/mec5035.h
  54. +++ b/src/ec/dell/mec5035/mec5035.h
  55. @@ -11,6 +11,7 @@
  56. enum mec5035_cmd {
  57. CMD_MOUSE_TP = 0x1a,
  58. CMD_RADIO_CTRL = 0x2b,
  59. + CMD_POWER_BUTTON_TO_HOST = 0x3e,
  60. CMD_ACPI_WAKEUP_CHANGE = 0x4a,
  61. CMD_SLEEP_ENABLE = 0x64,
  62. CMD_CPU_OK = 0xc2,
  63. @@ -36,6 +37,11 @@ enum ec_radio_state {
  64. RADIO_ON
  65. };
  66. +enum ec_power_button_route {
  67. + EC = 0,
  68. + HOST
  69. +};
  70. +
  71. #define ACPI_WAKEUP_NUM_ARGS 4
  72. enum ec_wake_change {
  73. WAKE_OFF = 0,
  74. @@ -55,6 +61,7 @@ u8 mec5035_mouse_touchpad(enum ec_mouse_setting setting);
  75. void mec5035_cpu_ok(void);
  76. void mec5035_early_init(void);
  77. void mec5035_control_radio(enum ec_radio_dev device, enum ec_radio_state state);
  78. +void mec5035_power_button_route(enum ec_power_button_route target);
  79. void mec5035_change_wake(u8 source, enum ec_wake_change change);
  80. void mec5035_sleep_enable(void);
  81. --
  82. 2.39.5