blob: cab855d34e73fa9b4dd5b86703f729322dc58062 [file] [log] [blame]
Angel Pons3ef916f2020-04-02 23:49:13 +02001/* SPDX-License-Identifier: GPL-2.0-only */
Stefan Reinauer9aea04a2012-03-30 12:01:06 -07002
3#ifndef __CHROMEOS_H__
4#define __CHROMEOS_H__
5
Aaron Durbin790e3ad2014-01-27 15:08:27 -06006#include <stddef.h>
Aaron Durbinfd795622013-03-01 17:12:26 -06007#include <stdint.h>
Cheng-Yi Chiangcfde82c2019-10-14 12:10:51 +08008#include <types.h>
Aaron Durbinfd795622013-03-01 17:12:26 -06009
Julius Wernercd49cce2019-03-05 16:53:33 -080010#if CONFIG(CHROMEOS)
Julius Werner105f5b72015-01-21 17:39:49 -080011/* functions implemented in watchdog.c */
Julius Wernerc7135942016-03-23 16:08:11 -070012void mark_watchdog_tombstone(void);
Julius Werner105f5b72015-01-21 17:39:49 -080013void reboot_from_watchdog(void);
Kyösti Mälkki662353a2021-02-11 07:18:29 +020014bool reset_watchdog_tombstone(void);
Duncan Laurie203e8ce2014-04-22 10:52:31 -070015#else
Julius Wernerc7135942016-03-23 16:08:11 -070016static inline void mark_watchdog_tombstone(void) { return; }
Julius Werner105f5b72015-01-21 17:39:49 -080017static inline void reboot_from_watchdog(void) { return; }
Duncan Laurie203e8ce2014-04-22 10:52:31 -070018#endif /* CONFIG_CHROMEOS */
Stefan Reinauer9aea04a2012-03-30 12:01:06 -070019
Keith Shorte0f34002019-02-05 16:15:10 -070020/**
21 * Perform any platform specific actions required prior to resetting the Cr50.
22 * Defined as weak function in cr50_enable_update.c
23 */
24void mainboard_prepare_cr50_reset(void);
Duncan Laurief131fc72019-01-23 15:01:21 -080025
Vadim Bendebury318708d2014-10-23 16:02:51 -070026void cbmem_add_vpd_calibration_data(void);
Kyösti Mälkki1749b772020-12-19 16:19:44 +020027void chromeos_set_me_hash(u32*, int);
Kyösti Mälkki8a1fcf42021-02-12 18:43:36 +020028void chromeos_set_ramoops(void *ram_oops, size_t size);
Vadim Bendebury318708d2014-10-23 16:02:51 -070029
Aaron Durbinb0f81512016-07-25 21:31:41 -050030/*
Jon Murphyc4e90452022-06-28 10:36:23 -060031 * Declaration for mainboards to use to generate ACPI-specific ChromeOS needs.
Aaron Durbinb0f81512016-07-25 21:31:41 -050032 */
Kyösti Mälkki4fdd84e2021-11-02 10:36:20 +020033void chromeos_acpi_gpio_generate(void);
Aaron Durbinb0f81512016-07-25 21:31:41 -050034
35enum {
36 CROS_GPIO_REC = 1, /* Recovery */
Joel Kitching1d948492019-03-27 18:26:28 +080037 CROS_GPIO_DEPRECATED_DEV = 2, /* Developer;
38 * deprecated (chromium:942901) */
Aaron Durbinb0f81512016-07-25 21:31:41 -050039 CROS_GPIO_WP = 3, /* Write Protect */
Aaron Durbin73deeae2016-12-12 13:57:11 -060040 CROS_GPIO_PE = 4, /* Phase enforcement for final product */
Aaron Durbinb0f81512016-07-25 21:31:41 -050041
42 CROS_GPIO_ACTIVE_LOW = 0,
43 CROS_GPIO_ACTIVE_HIGH = 1,
44
45 CROS_GPIO_VIRTUAL = -1,
46};
47
48struct cros_gpio {
49 int type;
50 int polarity;
51 int gpio_num;
52 const char *device;
53};
54
55#define CROS_GPIO_INITIALIZER(typ, pol, num, dev) \
56 { \
57 .type = (typ), \
58 .polarity = (pol), \
59 .gpio_num = (num), \
60 .device = (dev), \
61 }
62
63#define CROS_GPIO_REC_INITIALIZER(pol, num, dev) \
64 CROS_GPIO_INITIALIZER(CROS_GPIO_REC, pol, num, dev)
65
66#define CROS_GPIO_REC_AL(num, dev) \
67 CROS_GPIO_REC_INITIALIZER(CROS_GPIO_ACTIVE_LOW, num, dev)
68
69#define CROS_GPIO_REC_AH(num, dev) \
70 CROS_GPIO_REC_INITIALIZER(CROS_GPIO_ACTIVE_HIGH, num, dev)
71
Aaron Durbinb0f81512016-07-25 21:31:41 -050072#define CROS_GPIO_WP_INITIALIZER(pol, num, dev) \
73 CROS_GPIO_INITIALIZER(CROS_GPIO_WP, pol, num, dev)
74
75#define CROS_GPIO_WP_AL(num, dev) \
76 CROS_GPIO_WP_INITIALIZER(CROS_GPIO_ACTIVE_LOW, num, dev)
77
78#define CROS_GPIO_WP_AH(num, dev) \
79 CROS_GPIO_WP_INITIALIZER(CROS_GPIO_ACTIVE_HIGH, num, dev)
80
Aaron Durbin73deeae2016-12-12 13:57:11 -060081#define CROS_GPIO_PE_INITIALIZER(pol, num, dev) \
82 CROS_GPIO_INITIALIZER(CROS_GPIO_PE, pol, num, dev)
83
84#define CROS_GPIO_PE_AL(num, dev) \
85 CROS_GPIO_PE_INITIALIZER(CROS_GPIO_ACTIVE_LOW, num, dev)
86
87#define CROS_GPIO_PE_AH(num, dev) \
88 CROS_GPIO_PE_INITIALIZER(CROS_GPIO_ACTIVE_HIGH, num, dev)
89
Kyösti Mälkki4ff218a2021-11-02 13:03:06 +020090struct cros_gpio_pack {
91 int count;
92 const struct cros_gpio *gpios;
93};
94
95extern const struct cros_gpio_pack variant_cros_gpio;
96
97#define DECLARE_NO_CROS_GPIOS() \
98 const struct cros_gpio_pack variant_cros_gpio = \
99 { .count = 0, .gpios = NULL }
100
101#define DECLARE_CROS_GPIOS(x) \
102 const struct cros_gpio_pack variant_cros_gpio = \
103 { .count = ARRAY_SIZE(x), .gpios = x }
104
105#define DECLARE_WEAK_CROS_GPIOS(x) \
106 const struct cros_gpio_pack __weak variant_cros_gpio = \
107 { .count = ARRAY_SIZE(x), .gpios = x }
Kyösti Mälkki4fdd84e2021-11-02 10:36:20 +0200108
Daisuke Nojiri742fc8d2014-10-10 10:51:06 -0700109#endif /* __CHROMEOS_H__ */