aboutsummaryrefslogtreecommitdiff
path: root/drivers/renesas/rcar
diff options
context:
space:
mode:
authorJorge Ramirez-Ortiz <jramirez@baylibre.com>2018-09-23 09:39:11 +0200
committerldts <jorge.ramirez.ortiz@gmail.com>2018-10-17 18:40:30 +0200
commit070b0f0821148f5569727213817bc7b788535f00 (patch)
treefecb1a3f326a50a42550074aa6e81e4abf341d02 /drivers/renesas/rcar
parent0cdb86d41d417a644a7ff736c44dfd436fb0ccc0 (diff)
downloadtrusted-firmware-a-070b0f0821148f5569727213817bc7b788535f00.tar.gz
rcar_gen3: drivers: board identification
Signed-off-by: ldts <jramirez@baylibre.com>
Diffstat (limited to 'drivers/renesas/rcar')
-rw-r--r--drivers/renesas/rcar/board/board.c88
-rw-r--r--drivers/renesas/rcar/board/board.h35
2 files changed, 123 insertions, 0 deletions
diff --git a/drivers/renesas/rcar/board/board.c b/drivers/renesas/rcar/board/board.c
new file mode 100644
index 0000000000..147a0b0c38
--- /dev/null
+++ b/drivers/renesas/rcar/board/board.c
@@ -0,0 +1,88 @@
+/*
+ * Copyright (c) 2015-2018, Renesas Electronics Corporation. All rights
+ * reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#include <stdint.h>
+#include <iic_dvfs.h>
+#include "board.h"
+#include "utils_def.h"
+
+#ifndef BOARD_DEFAULT
+#if (RCAR_LSI == RCAR_E3)
+#define BOARD_DEFAULT (BOARD_EBISU << BOARD_CODE_SHIFT)
+#else
+#define BOARD_DEFAULT (BOARD_SALVATOR_X << BOARD_CODE_SHIFT)
+#endif
+#endif
+
+#define BOARD_CODE_MASK (0xF8)
+#define BOARD_REV_MASK (0x07)
+#define BOARD_CODE_SHIFT (0x03)
+#define BOARD_ID_UNKNOWN (0xFF)
+
+#define SXS_ID { 0x10U, 0xFFU, 0xFFU, 0xFFU, 0xFFU, 0xFFU, 0xFFU, 0xFFU }
+#define SX_ID { 0x10U, 0x11U, 0xFFU, 0xFFU, 0xFFU, 0xFFU, 0xFFU, 0xFFU }
+#define SKP_ID { 0x10U, 0x10U, 0xFFU, 0xFFU, 0xFFU, 0xFFU, 0xFFU, 0xFFU }
+#define SK_ID { 0x10U, 0xFFU, 0xFFU, 0xFFU, 0xFFU, 0xFFU, 0xFFU, 0xFFU }
+#define EB4_ID { 0x10U, 0xFFU, 0xFFU, 0xFFU, 0xFFU, 0xFFU, 0xFFU, 0xFFU }
+#define EB_ID { 0x10U, 0xFFU, 0xFFU, 0xFFU, 0xFFU, 0xFFU, 0xFFU, 0xFFU }
+#define KK_ID { 0x10U, 0xFFU, 0xFFU, 0xFFU, 0xFFU, 0xFFU, 0xFFU, 0xFFU }
+
+const char *g_board_tbl[] = {
+ [BOARD_STARTER_KIT_PRE] = "Starter Kit Premier",
+ [BOARD_STARTER_KIT] = "Starter Kit",
+ [BOARD_SALVATOR_XS] = "Salvator-XS",
+ [BOARD_SALVATOR_X] = "Salvator-X",
+ [BOARD_EBISU_4D] = "Ebisu-4D",
+ [BOARD_KRIEK] = "Kriek",
+ [BOARD_EBISU] = "Ebisu",
+ [BOARD_UNKNOWN] = "unknown"
+};
+
+int32_t rcar_get_board_type(uint32_t *type, uint32_t *rev)
+{
+ int32_t ret = 0;
+ const uint8_t board_tbl[][8] = {
+ [BOARD_STARTER_KIT_PRE] = SKP_ID,
+ [BOARD_SALVATOR_XS] = SXS_ID,
+ [BOARD_STARTER_KIT] = SK_ID,
+ [BOARD_SALVATOR_X] = SX_ID,
+ [BOARD_EBISU_4D] = EB4_ID,
+ [BOARD_EBISU] = EB_ID,
+ [BOARD_KRIEK] = KK_ID,
+ };
+ static uint8_t board_id = BOARD_ID_UNKNOWN;
+
+ if (board_id != BOARD_ID_UNKNOWN)
+ goto get_type;
+
+#if PMIC_ROHM_BD9571
+ /* Board ID detection from EEPROM */
+ ret = rcar_iic_dvfs_receive(EEPROM, BOARD_ID, &board_id);
+ if (ret) {
+ board_id = BOARD_ID_UNKNOWN;
+ goto get_type;
+ }
+
+ if (board_id == BOARD_ID_UNKNOWN)
+ board_id = BOARD_DEFAULT;
+#else
+ board_id = BOARD_DEFAULT;
+#endif
+
+get_type:
+ *type = ((uint32_t) board_id & BOARD_CODE_MASK) >> BOARD_CODE_SHIFT;
+
+ if (*type >= ARRAY_SIZE(board_tbl)) {
+ /* no revision information, set Rev0.0. */
+ *rev = 0;
+ return ret;
+ }
+
+ *rev = board_tbl[*type][(uint8_t) (board_id & BOARD_REV_MASK)];
+
+ return ret;
+}
diff --git a/drivers/renesas/rcar/board/board.h b/drivers/renesas/rcar/board/board.h
new file mode 100644
index 0000000000..15d80b9b4d
--- /dev/null
+++ b/drivers/renesas/rcar/board/board.h
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2015-2018, Renesas Electronics Corporation. All rights
+ * reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#ifndef BOARD_H_
+#define BOARD_H_
+
+#define BOARD_SALVATOR_X (0x00)
+#define BOARD_KRIEK (0x01)
+#define BOARD_STARTER_KIT (0x02)
+#define BOARD_SALVATOR_XS (0x04)
+#define BOARD_EBISU (0x08)
+#define BOARD_STARTER_KIT_PRE (0x0B)
+#define BOARD_EBISU_4D (0x0DU)
+#define BOARD_UNKNOWN (BOARD_EBISU_4D + 1U)
+
+#define BOARD_REV_UNKNOWN (0xFF)
+
+extern const char *g_board_tbl[];
+
+/************************************************************************
+ * Revisions are expressed in 8 bits.
+ * The upper 4 bits are major version.
+ * The lower 4 bits are minor version.
+ ************************************************************************/
+#define GET_BOARD_MAJOR(a) ((uint32_t)(a) >> 0x4)
+#define GET_BOARD_MINOR(a) ((uint32_t)(a) & 0xF)
+#define GET_BOARD_NAME(a) (g_board_tbl[(a)])
+
+int32_t rcar_get_board_type(uint32_t *type, uint32_t *rev);
+
+#endif