summaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
authorLucas Stach <l.stach@pengutronix.de>2018-12-10 14:38:14 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2018-12-13 07:46:56 +0100
commitd71cbc669495051c00f36cccfa9197451530f264 (patch)
tree72a1b96ba975e1849f39ebc187e53b87981f4945 /arch
parent819da026492b3ccb22ad0998e08c477006001928 (diff)
downloadbarebox-d71cbc669495051c00f36cccfa9197451530f264.tar.gz
barebox-d71cbc669495051c00f36cccfa9197451530f264.tar.xz
ARM: rdu2: add command to reset network switch
This command allows to reset the network switch on the DEB, clearing any DSA configuration, which may still be present from a prior boot. Signed-off-by: Lucas Stach <l.stach@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'arch')
-rw-r--r--arch/arm/boards/zii-imx6q-rdu2/Makefile2
-rw-r--r--arch/arm/boards/zii-imx6q-rdu2/switch-cmd.c49
2 files changed, 50 insertions, 1 deletions
diff --git a/arch/arm/boards/zii-imx6q-rdu2/Makefile b/arch/arm/boards/zii-imx6q-rdu2/Makefile
index c6285362f2..10dfba3a3c 100644
--- a/arch/arm/boards/zii-imx6q-rdu2/Makefile
+++ b/arch/arm/boards/zii-imx6q-rdu2/Makefile
@@ -1,3 +1,3 @@
-obj-y += board.o
+obj-y += board.o switch-cmd.o
lwl-y += lowlevel.o
bbenv-y += defaultenv-rdu2
diff --git a/arch/arm/boards/zii-imx6q-rdu2/switch-cmd.c b/arch/arm/boards/zii-imx6q-rdu2/switch-cmd.c
new file mode 100644
index 0000000000..bdba46fb36
--- /dev/null
+++ b/arch/arm/boards/zii-imx6q-rdu2/switch-cmd.c
@@ -0,0 +1,49 @@
+/*
+ * Copyright (C) 2018 Zodiac Inflight Innovation
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ */
+#include <common.h>
+#include <command.h>
+#include <i2c/i2c.h>
+
+static int do_rave_switch_reset(int argc, char *argv[])
+{
+ struct i2c_client client;
+ u8 reg;
+
+ if (!of_machine_is_compatible("zii,imx6q-zii-rdu2") &&
+ !of_machine_is_compatible("zii,imx6qp-zii-rdu2"))
+ return -ENODEV;
+
+ client.adapter = i2c_get_adapter(1);
+ if (!client.adapter)
+ return -ENODEV;
+
+ /* address of the switch watchdog microcontroller */
+ client.addr = 0x38;
+ reg = 0x78;
+ /* set switch reset time to 100ms */
+ i2c_write_reg(&client, 0x0a, &reg, 1);
+ /* reset the switch */
+ reg = 0x01;
+ i2c_write_reg(&client, 0x0d, &reg, 1);
+ /* issue dummy command to work around firmware bug */
+ i2c_read_reg(&client, 0x01, &reg, 1);
+
+ return 0;
+}
+
+BAREBOX_CMD_START(rave_reset_switch)
+ .cmd = do_rave_switch_reset,
+ BAREBOX_CMD_DESC("reset ethernet switch on RDU2")
+ BAREBOX_CMD_GROUP(CMD_GRP_HWMANIP)
+BAREBOX_CMD_END