diff options
author | Zuma copybara merger <zuma-automerger@google.com> | 2022-10-20 23:05:37 -0700 |
---|---|---|
committer | Copybara-Service <copybara-worker@google.com> | 2022-10-27 00:32:59 -0700 |
commit | 72b23489b1f0b45aec2274f08d899ce17dcf33ad (patch) | |
tree | 77c19a394ad4069776104eaad27173fe9462b304 | |
parent | c99afef64f5492b8fa1a393471a7a7195f7952fa (diff) | |
download | rio-72b23489b1f0b45aec2274f08d899ce17dcf33ad.tar.gz |
[Copybara Auto Merge] Merge branch zuma into android13-gs-pixel-5.15
edgetpu: add support for firmware header gen 2
BUG: 244103549
edgetpu: Add ACPM plugin
Bug: 216396699
Signed-off-by: Zuma copybara merger <zuma-automerger@google.com>
GitOrigin-RevId: e7a675bfe11aac394fb11e7242271a0f3c29d3f8
Change-Id: I45b877b1f53a940192800ce4157542d4bcf5bdb0
-rw-r--r-- | drivers/edgetpu/mobile-firmware.c | 32 | ||||
-rw-r--r-- | drivers/edgetpu/mobile-firmware.h | 31 | ||||
-rw-r--r-- | drivers/edgetpu/mobile-soc-gsx01.c | 19 |
3 files changed, 59 insertions, 23 deletions
diff --git a/drivers/edgetpu/mobile-firmware.c b/drivers/edgetpu/mobile-firmware.c index 33c2ab2..b326156 100644 --- a/drivers/edgetpu/mobile-firmware.c +++ b/drivers/edgetpu/mobile-firmware.c @@ -243,16 +243,32 @@ static int mobile_firmware_setup_buffer(struct edgetpu_firmware *et_fw, } hdr = (struct mobile_image_header *)fw_buf->vaddr; - if (hdr->Magic != EDGETPU_MOBILE_FW_MAGIC) - etdev_warn(etdev, "Invalid firmware header magic value %#08x\n", - hdr->Magic); + if (hdr->common.Magic != EDGETPU_MOBILE_FW_MAGIC) { + etdev_err(etdev, "Invalid firmware header magic value %#08x\n", hdr->common.Magic); + ret = -EINVAL; + goto out; + } + + switch (hdr->common.Generation) { + case 1: + image_config = &hdr->gen1.ImageConfig; + break; + case 2: + image_config = &hdr->gen2.ImageConfig; + break; + default: + etdev_err(etdev, "Invalid header generation identifier (%d)\n", + hdr->common.Generation); + goto out; + } - /* fetch the firmware versions */ - image_config = fw_buf->vaddr + MOBILE_IMAGE_CONFIG_OFFSET; - memcpy(&etdev->fw_version, &image_config->firmware_versions, - sizeof(etdev->fw_version)); + memcpy(&etdev->fw_version, &image_config->firmware_versions, sizeof(etdev->fw_version)); - if (etmdev->gsa_dev) { + /* + * TODO(b/244103549) re-enable authentication of non-secure images when + * GSA and TPU updates for Zuma land + */ + if (etmdev->gsa_dev && !gcip_image_config_is_ns(image_config)) { ret = mobile_firmware_gsa_authenticate(etmdev, fw_buf, image_vaddr); } else if (gcip_image_config_is_ns(image_config)) { etdev_dbg(etdev, "Loading unauthenticated non-secure firmware\n"); diff --git a/drivers/edgetpu/mobile-firmware.h b/drivers/edgetpu/mobile-firmware.h index d4486ed..cd2ad4a 100644 --- a/drivers/edgetpu/mobile-firmware.h +++ b/drivers/edgetpu/mobile-firmware.h @@ -21,28 +21,45 @@ /* mobile FW header size */ #define MOBILE_FW_HEADER_SIZE SZ_4K -/* The offset to the signed firmware header. */ -#define MOBILE_HEADER_OFFSET 0x400 -/* The offset to image configuration. */ -#define MOBILE_IMAGE_CONFIG_OFFSET (MOBILE_HEADER_OFFSET + 0x160) /* * Mobile firmware header. */ -struct mobile_image_header { - char sig[512]; - char pub[512]; + +struct mobile_image_sub_header_common { int Magic; int Generation; int RollbackInfo; int Length; char Flags[16]; +}; + +struct mobile_image_sub_header_gen1 { char BodyHash[32]; char ChipId[32]; char AuthConfig[256]; struct gcip_image_config ImageConfig; }; +struct mobile_image_sub_header_gen2 { + char BodyHash[64]; + char ChipId[32]; + char AuthConfig[256]; + struct gcip_image_config ImageConfig; +}; + +struct mobile_image_header { + char sig[512]; + char pub[512]; + struct { + struct mobile_image_sub_header_common common; + union { + struct mobile_image_sub_header_gen1 gen1; + struct mobile_image_sub_header_gen2 gen2; + }; + }; +}; + /* Value of Magic field above: 'TPUF' as a 32-bit LE int */ #define EDGETPU_MOBILE_FW_MAGIC 0x46555054 diff --git a/drivers/edgetpu/mobile-soc-gsx01.c b/drivers/edgetpu/mobile-soc-gsx01.c index f194b77..104cf46 100644 --- a/drivers/edgetpu/mobile-soc-gsx01.c +++ b/drivers/edgetpu/mobile-soc-gsx01.c @@ -5,6 +5,7 @@ * Copyright (C) 2022 Google LLC */ +#include <linux/acpm_dvfs.h> #include <linux/device.h> #include <linux/errno.h> #include <linux/gsa/gsa_tpu.h> @@ -24,6 +25,8 @@ #include "mobile-firmware.h" #include "mobile-soc-gsx01.h" +#define TPU_ACPM_DOMAIN 9 + #define MAX_VOLTAGE_VAL 1250000 #define TPU_DEBUG_REQ (1 << 31) @@ -364,7 +367,7 @@ static int edgetpu_core_rate_get(void *data, u64 *val) { struct edgetpu_dev *etdev = (typeof(etdev))data; - *val = edgetpu_soc_pm_get_rate(etdev, TPU_DEBUG_REQ | TPU_CLK_CORE_DEBUG); + *val = exynos_acpm_get_rate(TPU_ACPM_DOMAIN, TPU_DEBUG_REQ | TPU_CLK_CORE_DEBUG); return 0; } @@ -383,7 +386,7 @@ static int edgetpu_ctl_rate_get(void *data, u64 *val) { struct edgetpu_dev *etdev = (typeof(etdev))data; - *val = edgetpu_soc_pm_get_rate(etdev, TPU_DEBUG_REQ | TPU_CLK_CTL_DEBUG); + *val = exynos_acpm_get_rate(TPU_ACPM_DOMAIN, TPU_DEBUG_REQ | TPU_CLK_CTL_DEBUG); return 0; } @@ -402,7 +405,7 @@ static int edgetpu_axi_rate_get(void *data, u64 *val) { struct edgetpu_dev *etdev = (typeof(etdev))data; - *val = edgetpu_soc_pm_get_rate(etdev, TPU_DEBUG_REQ | TPU_CLK_AXI_DEBUG); + *val = exynos_acpm_get_rate(TPU_ACPM_DOMAIN, TPU_DEBUG_REQ | TPU_CLK_AXI_DEBUG); return 0; } @@ -421,7 +424,7 @@ static int edgetpu_apb_rate_get(void *data, u64 *val) { struct edgetpu_dev *etdev = (typeof(etdev))data; - *val = edgetpu_soc_pm_get_rate(etdev, TPU_DEBUG_REQ | TPU_CLK_APB_DEBUG); + *val = exynos_acpm_get_rate(TPU_ACPM_DOMAIN, TPU_DEBUG_REQ | TPU_CLK_APB_DEBUG); return 0; } @@ -430,7 +433,7 @@ static int edgetpu_uart_rate_get(void *data, u64 *val) { struct edgetpu_dev *etdev = (typeof(etdev))data; - *val = edgetpu_soc_pm_get_rate(etdev, TPU_DEBUG_REQ | TPU_CLK_UART_DEBUG); + *val = exynos_acpm_get_rate(TPU_ACPM_DOMAIN, TPU_DEBUG_REQ | TPU_CLK_UART_DEBUG); return 0; } @@ -455,7 +458,7 @@ static int edgetpu_vdd_int_m_get(void *data, u64 *val) { struct edgetpu_dev *etdev = (typeof(etdev))data; - *val = edgetpu_soc_pm_get_rate(etdev, TPU_DEBUG_REQ | TPU_VDD_INT_M_DEBUG); + *val = exynos_acpm_get_rate(TPU_ACPM_DOMAIN, TPU_DEBUG_REQ | TPU_VDD_INT_M_DEBUG); return 0; } @@ -482,7 +485,7 @@ static int edgetpu_vdd_tpu_get(void *data, u64 *val) { struct edgetpu_dev *etdev = (typeof(etdev))data; - *val = edgetpu_soc_pm_get_rate(etdev, TPU_DEBUG_REQ | TPU_VDD_TPU_DEBUG); + *val = exynos_acpm_get_rate(TPU_ACPM_DOMAIN, TPU_DEBUG_REQ | TPU_VDD_TPU_DEBUG); return 0; } @@ -509,7 +512,7 @@ static int edgetpu_vdd_tpu_m_get(void *data, u64 *val) { struct edgetpu_dev *etdev = (typeof(etdev))data; - *val = edgetpu_soc_pm_get_rate(etdev, TPU_DEBUG_REQ | TPU_VDD_TPU_M_DEBUG); + *val = exynos_acpm_get_rate(TPU_ACPM_DOMAIN, TPU_DEBUG_REQ | TPU_VDD_TPU_M_DEBUG); return 0; } |