summaryrefslogtreecommitdiff
path: root/arch
diff options
context:
space:
mode:
authorFranck LENORMAND <franck.lenormand@nxp.com>2020-05-14 10:37:02 +0200
committerFranck LENORMAND <franck.lenormand@nxp.com>2020-06-24 15:01:56 +0200
commit6d9db1b243d5826f3f36e96dcbbc2b7d56569a5a (patch)
treef123d403bc1205ae2117111a238235bd1ece0612 /arch
parent388efa59f3367a1c521f75ee25009b6db83d5056 (diff)
MLK-23834: Add gpio_conf command to configure GPIO
This patch adds a command to configure the GPIO from uboot shell in order to be able to configure the tampers by hand. Signed-off-by: Franck LENORMAND <franck.lenormand@nxp.com>
Diffstat (limited to 'arch')
-rw-r--r--arch/arm/mach-imx/imx8/snvs_security_sc.c59
1 files changed, 59 insertions, 0 deletions
diff --git a/arch/arm/mach-imx/imx8/snvs_security_sc.c b/arch/arm/mach-imx/imx8/snvs_security_sc.c
index 64ebb72c0c..aa1fac4425 100644
--- a/arch/arm/mach-imx/imx8/snvs_security_sc.c
+++ b/arch/arm/mach-imx/imx8/snvs_security_sc.c
@@ -300,6 +300,18 @@ static sc_err_t pad_write(u32 _pad, u32 _value)
return sciErr;
}
+static sc_err_t pad_read(u32 _pad, u32 *_value)
+{
+ sc_err_t sciErr = sc_pad_get(-1, _pad, _value);
+
+ if (sciErr != SC_ERR_NONE) {
+ printf("Failed to get pad configuration\n");
+ printf("Failed to get conf pad %d", _pad);
+ }
+
+ return sciErr;
+}
+
static int apply_tamper_pin_list_config(struct tamper_pin_cfg *confs, u32 size)
{
sc_err_t sciErr = 0;
@@ -672,3 +684,50 @@ U_BOOT_CMD(snvs_sec_status,
"tamper pin configuration",
snvs_sec_status_help_text
);
+
+static char gpio_conf_help_text[] =
+ "gpio_conf <pad> <hexval>\n"
+ "Configure the GPIO of an IOMUX:\n"
+ " - pad:\n"
+ " - hexval:";
+
+static int do_gpio_conf(cmd_tbl_t *cmdtp, int flag, int argc,
+ char *const argv[])
+{
+ int err = -EIO;
+ sc_err_t sciErr;
+ u32 pad, val, valcheck;
+
+ pad = simple_strtoul(argv[1], NULL, 10);
+ val = simple_strtoul(argv[2], NULL, 16);
+
+ printf("Configuring GPIO %d with %x\n", pad, val);
+
+ sciErr = pad_write(pad, 3 << 30 | val);
+ if (sciErr != SC_ERR_NONE) {
+ printf("Error writing conf\n");
+ goto exit;
+ }
+
+ sciErr = pad_read(pad, &valcheck);
+ if (sciErr != SC_ERR_NONE) {
+ printf("Error reading conf\n");
+ goto exit;
+ }
+
+ if (valcheck != val) {
+ printf("Error: configured %x instead of %x\n", valcheck, val);
+ goto exit;
+ }
+
+ err = 0;
+
+exit:
+ return err;
+}
+
+U_BOOT_CMD(gpio_conf,
+ 3, 1, do_gpio_conf,
+ "gpio configuration",
+ gpio_conf_help_text
+);