Angel Pons | 3ef916f | 2020-04-02 23:49:13 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Stefan Reinauer | 9aea04a | 2012-03-30 12:01:06 -0700 | [diff] [blame] | 2 | |
| 3 | #ifndef __CHROMEOS_H__ |
| 4 | #define __CHROMEOS_H__ |
| 5 | |
Aaron Durbin | 790e3ad | 2014-01-27 15:08:27 -0600 | [diff] [blame] | 6 | #include <stddef.h> |
Aaron Durbin | fd79562 | 2013-03-01 17:12:26 -0600 | [diff] [blame] | 7 | #include <stdint.h> |
Cheng-Yi Chiang | cfde82c | 2019-10-14 12:10:51 +0800 | [diff] [blame] | 8 | #include <types.h> |
Aaron Durbin | fd79562 | 2013-03-01 17:12:26 -0600 | [diff] [blame] | 9 | |
Julius Werner | cd49cce | 2019-03-05 16:53:33 -0800 | [diff] [blame] | 10 | #if CONFIG(CHROMEOS) |
Julius Werner | 105f5b7 | 2015-01-21 17:39:49 -0800 | [diff] [blame] | 11 | /* functions implemented in watchdog.c */ |
Julius Werner | c713594 | 2016-03-23 16:08:11 -0700 | [diff] [blame] | 12 | void mark_watchdog_tombstone(void); |
Julius Werner | 105f5b7 | 2015-01-21 17:39:49 -0800 | [diff] [blame] | 13 | void reboot_from_watchdog(void); |
Kyösti Mälkki | 662353a | 2021-02-11 07:18:29 +0200 | [diff] [blame] | 14 | bool reset_watchdog_tombstone(void); |
Duncan Laurie | 203e8ce | 2014-04-22 10:52:31 -0700 | [diff] [blame] | 15 | #else |
Julius Werner | c713594 | 2016-03-23 16:08:11 -0700 | [diff] [blame] | 16 | static inline void mark_watchdog_tombstone(void) { return; } |
Julius Werner | 105f5b7 | 2015-01-21 17:39:49 -0800 | [diff] [blame] | 17 | static inline void reboot_from_watchdog(void) { return; } |
Duncan Laurie | 203e8ce | 2014-04-22 10:52:31 -0700 | [diff] [blame] | 18 | #endif /* CONFIG_CHROMEOS */ |
Stefan Reinauer | 9aea04a | 2012-03-30 12:01:06 -0700 | [diff] [blame] | 19 | |
Subrata Banik | 8e7251c | 2024-01-02 23:28:49 +0530 | [diff] [blame^] | 20 | #define UNDEFINED_FACTORY_CONFIG ~((uint64_t)0) |
| 21 | |
Keith Short | e0f3400 | 2019-02-05 16:15:10 -0700 | [diff] [blame] | 22 | /** |
| 23 | * Perform any platform specific actions required prior to resetting the Cr50. |
| 24 | * Defined as weak function in cr50_enable_update.c |
| 25 | */ |
| 26 | void mainboard_prepare_cr50_reset(void); |
Duncan Laurie | f131fc7 | 2019-01-23 15:01:21 -0800 | [diff] [blame] | 27 | |
Vadim Bendebury | 318708d | 2014-10-23 16:02:51 -0700 | [diff] [blame] | 28 | void cbmem_add_vpd_calibration_data(void); |
Kyösti Mälkki | 1749b77 | 2020-12-19 16:19:44 +0200 | [diff] [blame] | 29 | void chromeos_set_me_hash(u32*, int); |
Kyösti Mälkki | 8a1fcf4 | 2021-02-12 18:43:36 +0200 | [diff] [blame] | 30 | void chromeos_set_ramoops(void *ram_oops, size_t size); |
Subrata Banik | 73505f1 | 2023-12-27 21:13:25 +0530 | [diff] [blame] | 31 | /* |
| 32 | * The factory config space is a one-time programmable info page. |
| 33 | * For the unprovisioned one, the read will be 0x0. |
Subrata Banik | 8e7251c | 2024-01-02 23:28:49 +0530 | [diff] [blame^] | 34 | * Return "UNDEFINED_FACTORY_CONFIG" in case of error. |
Subrata Banik | 73505f1 | 2023-12-27 21:13:25 +0530 | [diff] [blame] | 35 | */ |
Subrata Banik | 8e7251c | 2024-01-02 23:28:49 +0530 | [diff] [blame^] | 36 | uint64_t chromeos_get_factory_config(void); |
Subrata Banik | d968b85 | 2023-12-28 23:37:27 +0530 | [diff] [blame] | 37 | /* |
| 38 | * Determines whether a ChromeOS device is branded as a Chromebook Plus |
| 39 | * based on specific bit flags: |
| 40 | * |
| 41 | * - Bit 4 (0x10): Indicates whether the device chassis has the |
| 42 | * "chromebook-plus" branding. |
| 43 | * - Bits 3-0 (0x1): Must be 0x1 to signify compliance with Chromebook Plus |
| 44 | * hardware specifications. |
| 45 | * |
| 46 | * To be considered a Chromebook Plus, either of these conditions needs to be met. |
| 47 | */ |
| 48 | bool chromeos_device_branded_plus(void); |
Vadim Bendebury | 318708d | 2014-10-23 16:02:51 -0700 | [diff] [blame] | 49 | |
Aaron Durbin | b0f8151 | 2016-07-25 21:31:41 -0500 | [diff] [blame] | 50 | /* |
Jon Murphy | c4e9045 | 2022-06-28 10:36:23 -0600 | [diff] [blame] | 51 | * Declaration for mainboards to use to generate ACPI-specific ChromeOS needs. |
Aaron Durbin | b0f8151 | 2016-07-25 21:31:41 -0500 | [diff] [blame] | 52 | */ |
Kyösti Mälkki | 4fdd84e | 2021-11-02 10:36:20 +0200 | [diff] [blame] | 53 | void chromeos_acpi_gpio_generate(void); |
Aaron Durbin | b0f8151 | 2016-07-25 21:31:41 -0500 | [diff] [blame] | 54 | |
| 55 | enum { |
| 56 | CROS_GPIO_REC = 1, /* Recovery */ |
Joel Kitching | 1d94849 | 2019-03-27 18:26:28 +0800 | [diff] [blame] | 57 | CROS_GPIO_DEPRECATED_DEV = 2, /* Developer; |
| 58 | * deprecated (chromium:942901) */ |
Aaron Durbin | b0f8151 | 2016-07-25 21:31:41 -0500 | [diff] [blame] | 59 | CROS_GPIO_WP = 3, /* Write Protect */ |
Aaron Durbin | 73deeae | 2016-12-12 13:57:11 -0600 | [diff] [blame] | 60 | CROS_GPIO_PE = 4, /* Phase enforcement for final product */ |
Aaron Durbin | b0f8151 | 2016-07-25 21:31:41 -0500 | [diff] [blame] | 61 | |
| 62 | CROS_GPIO_ACTIVE_LOW = 0, |
| 63 | CROS_GPIO_ACTIVE_HIGH = 1, |
| 64 | |
| 65 | CROS_GPIO_VIRTUAL = -1, |
| 66 | }; |
| 67 | |
| 68 | struct cros_gpio { |
| 69 | int type; |
| 70 | int polarity; |
| 71 | int gpio_num; |
| 72 | const char *device; |
| 73 | }; |
| 74 | |
| 75 | #define CROS_GPIO_INITIALIZER(typ, pol, num, dev) \ |
| 76 | { \ |
| 77 | .type = (typ), \ |
| 78 | .polarity = (pol), \ |
| 79 | .gpio_num = (num), \ |
| 80 | .device = (dev), \ |
| 81 | } |
| 82 | |
| 83 | #define CROS_GPIO_REC_INITIALIZER(pol, num, dev) \ |
| 84 | CROS_GPIO_INITIALIZER(CROS_GPIO_REC, pol, num, dev) |
| 85 | |
| 86 | #define CROS_GPIO_REC_AL(num, dev) \ |
| 87 | CROS_GPIO_REC_INITIALIZER(CROS_GPIO_ACTIVE_LOW, num, dev) |
| 88 | |
| 89 | #define CROS_GPIO_REC_AH(num, dev) \ |
| 90 | CROS_GPIO_REC_INITIALIZER(CROS_GPIO_ACTIVE_HIGH, num, dev) |
| 91 | |
Aaron Durbin | b0f8151 | 2016-07-25 21:31:41 -0500 | [diff] [blame] | 92 | #define CROS_GPIO_WP_INITIALIZER(pol, num, dev) \ |
| 93 | CROS_GPIO_INITIALIZER(CROS_GPIO_WP, pol, num, dev) |
| 94 | |
| 95 | #define CROS_GPIO_WP_AL(num, dev) \ |
| 96 | CROS_GPIO_WP_INITIALIZER(CROS_GPIO_ACTIVE_LOW, num, dev) |
| 97 | |
| 98 | #define CROS_GPIO_WP_AH(num, dev) \ |
| 99 | CROS_GPIO_WP_INITIALIZER(CROS_GPIO_ACTIVE_HIGH, num, dev) |
| 100 | |
Aaron Durbin | 73deeae | 2016-12-12 13:57:11 -0600 | [diff] [blame] | 101 | #define CROS_GPIO_PE_INITIALIZER(pol, num, dev) \ |
| 102 | CROS_GPIO_INITIALIZER(CROS_GPIO_PE, pol, num, dev) |
| 103 | |
| 104 | #define CROS_GPIO_PE_AL(num, dev) \ |
| 105 | CROS_GPIO_PE_INITIALIZER(CROS_GPIO_ACTIVE_LOW, num, dev) |
| 106 | |
| 107 | #define CROS_GPIO_PE_AH(num, dev) \ |
| 108 | CROS_GPIO_PE_INITIALIZER(CROS_GPIO_ACTIVE_HIGH, num, dev) |
| 109 | |
Kyösti Mälkki | 4ff218a | 2021-11-02 13:03:06 +0200 | [diff] [blame] | 110 | struct cros_gpio_pack { |
| 111 | int count; |
| 112 | const struct cros_gpio *gpios; |
| 113 | }; |
| 114 | |
| 115 | extern const struct cros_gpio_pack variant_cros_gpio; |
| 116 | |
| 117 | #define DECLARE_NO_CROS_GPIOS() \ |
| 118 | const struct cros_gpio_pack variant_cros_gpio = \ |
| 119 | { .count = 0, .gpios = NULL } |
| 120 | |
| 121 | #define DECLARE_CROS_GPIOS(x) \ |
| 122 | const struct cros_gpio_pack variant_cros_gpio = \ |
| 123 | { .count = ARRAY_SIZE(x), .gpios = x } |
| 124 | |
| 125 | #define DECLARE_WEAK_CROS_GPIOS(x) \ |
| 126 | const struct cros_gpio_pack __weak variant_cros_gpio = \ |
| 127 | { .count = ARRAY_SIZE(x), .gpios = x } |
Kyösti Mälkki | 4fdd84e | 2021-11-02 10:36:20 +0200 | [diff] [blame] | 128 | |
Daisuke Nojiri | 742fc8d | 2014-10-10 10:51:06 -0700 | [diff] [blame] | 129 | #endif /* __CHROMEOS_H__ */ |