summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobin Peng <robinpeng@google.com>2022-10-28 10:06:43 +0000
committerRobin Peng <robinpeng@google.com>2022-10-28 10:06:43 +0000
commit2d8d797e852b2479c84dd25a23f511021a0f7acd (patch)
tree77c19a394ad4069776104eaad27173fe9462b304
parent570942d2b2be572cedb9c24e54a4b130d660f8da (diff)
parent72b23489b1f0b45aec2274f08d899ce17dcf33ad (diff)
downloadrio-2d8d797e852b2479c84dd25a23f511021a0f7acd.tar.gz
Merge android13-gs-pixel-5.15 into android14-gs-pixel-5.15
Bug: 236259002 Change-Id: I77c382c09a675512b1da31932d33c6d51bd1e565 Signed-off-by: Robin Peng <robinpeng@google.com>
-rw-r--r--drivers/edgetpu/mobile-firmware.c32
-rw-r--r--drivers/edgetpu/mobile-firmware.h31
-rw-r--r--drivers/edgetpu/mobile-soc-gsx01.c19
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;
}