blob: 35e2dde740990ac72ce6b4308ca1cc28cbb854a3 [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>
Kyösti Mälkki5687fc92013-11-28 18:11:49 +02008#include <bootmode.h>
Aaron Durbinb0f81512016-07-25 21:31:41 -05009#include <device/device.h>
Aaron Durbin818e9282015-04-21 15:23:41 -050010#include <rules.h>
Philipp Deppenwiesefea24292017-10-17 17:02:29 +020011#include <security/vboot/misc.h>
12#include <security/vboot/vboot_common.h>
Cheng-Yi Chiangcfde82c2019-10-14 12:10:51 +080013#include <types.h>
Aaron Durbinfd795622013-03-01 17:12:26 -060014
Julius Wernercd49cce2019-03-05 16:53:33 -080015#if CONFIG(CHROMEOS)
Julius Werner105f5b72015-01-21 17:39:49 -080016/* functions implemented in watchdog.c */
Julius Wernerc7135942016-03-23 16:08:11 -070017void mark_watchdog_tombstone(void);
Julius Werner105f5b72015-01-21 17:39:49 -080018void reboot_from_watchdog(void);
Duncan Laurie203e8ce2014-04-22 10:52:31 -070019#else
Julius Wernerc7135942016-03-23 16:08:11 -070020static inline void mark_watchdog_tombstone(void) { return; }
Julius Werner105f5b72015-01-21 17:39:49 -080021static inline void reboot_from_watchdog(void) { return; }
Duncan Laurie203e8ce2014-04-22 10:52:31 -070022#endif /* CONFIG_CHROMEOS */
Stefan Reinauer9aea04a2012-03-30 12:01:06 -070023
Keith Shorte0f34002019-02-05 16:15:10 -070024/**
25 * Perform any platform specific actions required prior to resetting the Cr50.
26 * Defined as weak function in cr50_enable_update.c
27 */
28void mainboard_prepare_cr50_reset(void);
Duncan Laurief131fc72019-01-23 15:01:21 -080029
Aaron Durbin06ece7d2014-02-14 00:30:04 -060030#include "gnvs.h"
Aaron Durbin06ece7d2014-02-14 00:30:04 -060031
Julius Wernercd49cce2019-03-05 16:53:33 -080032#if CONFIG(CHROMEOS_RAMOOPS)
Aaron Durbin06ece7d2014-02-14 00:30:04 -060033void chromeos_ram_oops_init(chromeos_acpi_t *chromeos);
Aaron Durbin06ece7d2014-02-14 00:30:04 -060034#else /* !CONFIG_CHROMEOS_RAMOOPS */
35static inline void chromeos_ram_oops_init(chromeos_acpi_t *chromeos) {}
Aaron Durbin06ece7d2014-02-14 00:30:04 -060036#endif /* CONFIG_CHROMEOS_RAMOOPS */
37
Vadim Bendebury318708d2014-10-23 16:02:51 -070038void cbmem_add_vpd_calibration_data(void);
Kyösti Mälkki1749b772020-12-19 16:19:44 +020039void chromeos_set_me_hash(u32*, int);
Vadim Bendebury318708d2014-10-23 16:02:51 -070040
Cheng-Yi Chiangcfde82c2019-10-14 12:10:51 +080041/**
42 * get_dsm_calibration_from_key - Gets value related to DSM calibration from VPD
43 * @key: The key in RO_VPD. The valid prefix is "dsm_calib_". The valid keys are
44 * documented in https://chromeos.google.com/partner/dlm/docs/factory/vpd.html.
45 * @value: Output value. The value read from VPD parsed into uint64_t integer.
46 *
47 * Returns CB_SUCCESS on success or CB_ERR on failure.
48 */
49enum cb_err get_dsm_calibration_from_key(const char *key, uint64_t *value);
50
Aaron Durbinb0f81512016-07-25 21:31:41 -050051/*
52 * Create the OIPG package containing the Chrome OS gpios described by
53 * the chromeos_gpio array.
54 */
55struct cros_gpio;
56void chromeos_acpi_gpio_generate(const struct cros_gpio *gpios, size_t num);
57
58/*
59 * Common helper function and delcarations for mainboards to use to generate
60 * ACPI-specific Chrome OS needs.
61 */
62void mainboard_chromeos_acpi_generate(void);
Julius Wernercd49cce2019-03-05 16:53:33 -080063#if CONFIG(CHROMEOS)
Kyösti Mälkkifce36e42021-02-10 19:31:26 +020064struct device;
Furquan Shaikh338fd9a2020-04-24 22:57:05 -070065void chromeos_dsdt_generator(const struct device *dev);
Aaron Durbinb0f81512016-07-25 21:31:41 -050066#else
Nico Hubera461b692020-04-05 13:55:12 +020067#define chromeos_dsdt_generator NULL
Aaron Durbinb0f81512016-07-25 21:31:41 -050068#endif
69
70enum {
71 CROS_GPIO_REC = 1, /* Recovery */
Joel Kitching1d948492019-03-27 18:26:28 +080072 CROS_GPIO_DEPRECATED_DEV = 2, /* Developer;
73 * deprecated (chromium:942901) */
Aaron Durbinb0f81512016-07-25 21:31:41 -050074 CROS_GPIO_WP = 3, /* Write Protect */
Aaron Durbin73deeae2016-12-12 13:57:11 -060075 CROS_GPIO_PE = 4, /* Phase enforcement for final product */
Aaron Durbinb0f81512016-07-25 21:31:41 -050076
77 CROS_GPIO_ACTIVE_LOW = 0,
78 CROS_GPIO_ACTIVE_HIGH = 1,
79
80 CROS_GPIO_VIRTUAL = -1,
81};
82
83struct cros_gpio {
84 int type;
85 int polarity;
86 int gpio_num;
87 const char *device;
88};
89
90#define CROS_GPIO_INITIALIZER(typ, pol, num, dev) \
91 { \
92 .type = (typ), \
93 .polarity = (pol), \
94 .gpio_num = (num), \
95 .device = (dev), \
96 }
97
98#define CROS_GPIO_REC_INITIALIZER(pol, num, dev) \
99 CROS_GPIO_INITIALIZER(CROS_GPIO_REC, pol, num, dev)
100
101#define CROS_GPIO_REC_AL(num, dev) \
102 CROS_GPIO_REC_INITIALIZER(CROS_GPIO_ACTIVE_LOW, num, dev)
103
104#define CROS_GPIO_REC_AH(num, dev) \
105 CROS_GPIO_REC_INITIALIZER(CROS_GPIO_ACTIVE_HIGH, num, dev)
106
Aaron Durbinb0f81512016-07-25 21:31:41 -0500107#define CROS_GPIO_WP_INITIALIZER(pol, num, dev) \
108 CROS_GPIO_INITIALIZER(CROS_GPIO_WP, pol, num, dev)
109
110#define CROS_GPIO_WP_AL(num, dev) \
111 CROS_GPIO_WP_INITIALIZER(CROS_GPIO_ACTIVE_LOW, num, dev)
112
113#define CROS_GPIO_WP_AH(num, dev) \
114 CROS_GPIO_WP_INITIALIZER(CROS_GPIO_ACTIVE_HIGH, num, dev)
115
Aaron Durbin73deeae2016-12-12 13:57:11 -0600116#define CROS_GPIO_PE_INITIALIZER(pol, num, dev) \
117 CROS_GPIO_INITIALIZER(CROS_GPIO_PE, pol, num, dev)
118
119#define CROS_GPIO_PE_AL(num, dev) \
120 CROS_GPIO_PE_INITIALIZER(CROS_GPIO_ACTIVE_LOW, num, dev)
121
122#define CROS_GPIO_PE_AH(num, dev) \
123 CROS_GPIO_PE_INITIALIZER(CROS_GPIO_ACTIVE_HIGH, num, dev)
124
Daisuke Nojiri742fc8d2014-10-10 10:51:06 -0700125#endif /* __CHROMEOS_H__ */