Lee Leahy | 28c3f23 | 2017-01-04 08:34:01 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2016-2017 Intel Corporation |
| 3 | * |
| 4 | * This program is free software; you can redistribute it and/or |
| 5 | * modify it under the terms of the GNU General Public License as |
| 6 | * published by the Free Software Foundation; either version 2 of |
| 7 | * the License, or (at your option) any later version. |
| 8 | * |
| 9 | * This program is distributed in the hope that it will be useful, |
| 10 | * but without any warranty; without even the implied warranty of |
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | * GNU General Public License for more details. |
| 13 | */ |
| 14 | |
| 15 | #include <assert.h> |
| 16 | #include <bootmode.h> |
Lee Leahy | 28c3f23 | 2017-01-04 08:34:01 -0800 | [diff] [blame] | 17 | #include <delay.h> |
Nico Huber | 0f2dd1e | 2017-08-01 14:02:40 +0200 | [diff] [blame] | 18 | #include <device/i2c_simple.h> |
Lee Leahy | 28c3f23 | 2017-01-04 08:34:01 -0800 | [diff] [blame] | 19 | #include <soc/i2c.h> |
| 20 | #include <soc/reg_access.h> |
| 21 | #include "reg_access.h" |
| 22 | #include "gen1.h" |
| 23 | #include "gen2.h" |
| 24 | #include <spi_flash.h> |
Philipp Deppenwiese | fea2429 | 2017-10-17 17:02:29 +0200 | [diff] [blame] | 25 | #include <security/vboot/vboot_common.h> |
| 26 | #include <security/vboot/vbnv.h> |
Lee Leahy | 28c3f23 | 2017-01-04 08:34:01 -0800 | [diff] [blame] | 27 | |
| 28 | int clear_recovery_mode_switch(void) |
| 29 | { |
| 30 | /* Nothing to do */ |
| 31 | return 0; |
| 32 | } |
| 33 | |
Lee Leahy | 28c3f23 | 2017-01-04 08:34:01 -0800 | [diff] [blame] | 34 | int get_recovery_mode_switch(void) |
| 35 | { |
| 36 | return 0; |
| 37 | } |
| 38 | |
Lee Leahy | 28c3f23 | 2017-01-04 08:34:01 -0800 | [diff] [blame] | 39 | int get_write_protect_state(void) |
| 40 | { |
| 41 | /* Not write protected */ |
| 42 | return 0; |
| 43 | } |
| 44 | |
| 45 | void log_recovery_mode_switch(void) |
| 46 | { |
| 47 | } |
| 48 | |
| 49 | void verstage_mainboard_init(void) |
| 50 | { |
| 51 | const struct reg_script *script; |
| 52 | |
| 53 | /* Crypto Shield I2C Addresses: |
| 54 | * |
| 55 | * 0x29: AT97S3204T - TPM 1.2 |
| 56 | * 0x50: ATAES132 - AES-128 |
| 57 | * 0x60: ATECC108 - Elliptical Curve |
| 58 | * 0x64: ATSHA204 - SHA-256 |
| 59 | * 0x68: DS3231M - RTC |
| 60 | */ |
| 61 | |
| 62 | /* Determine the correct script for the board */ |
| 63 | if (IS_ENABLED(CONFIG_GALILEO_GEN2)) |
| 64 | script = gen2_i2c_init; |
| 65 | else |
| 66 | /* Determine which I2C address is in use */ |
| 67 | script = (reg_legacy_gpio_read (R_QNC_GPIO_RGLVL_RESUME_WELL) |
| 68 | & GALILEO_DETERMINE_IOEXP_SLA_RESUMEWELL_GPIO) |
| 69 | ? gen1_i2c_0x20_init : gen1_i2c_0x21_init; |
| 70 | |
| 71 | /* Direct the I2C SDA and SCL signals to the Arduino connector */ |
| 72 | reg_script_run(script); |
| 73 | } |
| 74 | |
Aaron Durbin | 6403167 | 2018-04-21 14:45:32 -0600 | [diff] [blame] | 75 | void __weak vboot_platform_prepare_reboot(void) |
Lee Leahy | 28c3f23 | 2017-01-04 08:34:01 -0800 | [diff] [blame] | 76 | { |
| 77 | const struct reg_script *script; |
| 78 | |
| 79 | /* Crypto Shield I2C Addresses: |
| 80 | * |
| 81 | * 0x29: AT97S3204T - TPM 1.2 |
| 82 | * 0x50: ATAES132 - AES-128 |
| 83 | * 0x60: ATECC108 - Elliptical Curve |
| 84 | * 0x64: ATSHA204 - SHA-256 |
| 85 | * 0x68: DS3231M - RTC |
| 86 | */ |
| 87 | |
| 88 | /* Determine the correct script for the board */ |
| 89 | if (IS_ENABLED(CONFIG_GALILEO_GEN2)) |
| 90 | script = gen2_tpm_reset; |
| 91 | else |
| 92 | /* Determine which I2C address is in use */ |
| 93 | script = (reg_legacy_gpio_read (R_QNC_GPIO_RGLVL_RESUME_WELL) |
| 94 | & GALILEO_DETERMINE_IOEXP_SLA_RESUMEWELL_GPIO) |
| 95 | ? gen1_tpm_reset_0x20 : gen1_tpm_reset_0x21; |
| 96 | |
| 97 | /* Reset the TPM */ |
| 98 | reg_script_run(script); |
| 99 | } |
Aaron Durbin | 0990fbf | 2017-09-15 15:23:04 -0600 | [diff] [blame] | 100 | |
| 101 | int vbnv_cmos_failed(void) |
| 102 | { |
| 103 | /* Indicate no failure until RTC failure bits are supported. */ |
| 104 | return 0; |
| 105 | } |