mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Lucas Stach <l.stach@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Andrey Smirnov <andrew.smirnov@gmail.com>,
	Chris Healy <cphealy@gmail.com>
Subject: [PATCH 2/6] ARM: zii-common: add support for switch reset on RDU1
Date: Wed, 13 Mar 2019 11:56:31 +0100	[thread overview]
Message-ID: <20190313105635.22055-2-l.stach@pengutronix.de> (raw)
In-Reply-To: <20190313105635.22055-1-l.stach@pengutronix.de>

Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
---
 arch/arm/boards/zii-common/switch-cmd.c | 38 ++++++++++++++++++++-----
 arch/arm/mach-imx/Kconfig               |  1 +
 include/linux/mfd/rave-sp.h             |  1 +
 3 files changed, 33 insertions(+), 7 deletions(-)

diff --git a/arch/arm/boards/zii-common/switch-cmd.c b/arch/arm/boards/zii-common/switch-cmd.c
index bdba46fb3615..30438053a1ef 100644
--- a/arch/arm/boards/zii-common/switch-cmd.c
+++ b/arch/arm/boards/zii-common/switch-cmd.c
@@ -11,19 +11,16 @@
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
  */
-#include <common.h>
 #include <command.h>
+#include <common.h>
 #include <i2c/i2c.h>
+#include <linux/mfd/rave-sp.h>
 
-static int do_rave_switch_reset(int argc, char *argv[])
+static int do_rdu2_switch_reset(void)
 {
 	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;
@@ -42,8 +39,35 @@ static int do_rave_switch_reset(int argc, char *argv[])
 	return 0;
 }
 
+static int do_rdu1_switch_reset(void)
+{
+	struct device_d *sp_dev = get_device_by_name("sp");
+	struct rave_sp *sp = sp_dev->priv;
+	u8 cmd[] = {
+		[0] = RAVE_SP_CMD_RESET_ETH_SWITCH,
+		[1] = 0
+	};
+
+	if (IS_ENABLED(CONFIG_RAVE_SP_CORE))
+		return rave_sp_exec(sp, cmd, sizeof(cmd), NULL, 0);
+	else
+		return -ENODEV;
+}
+
+static int do_rave_switch_reset(int argc, char *argv[])
+{
+	if (of_machine_is_compatible("zii,imx6q-zii-rdu2") ||
+	    of_machine_is_compatible("zii,imx6qp-zii-rdu2"))
+		return do_rdu2_switch_reset();
+
+	if (of_machine_is_compatible("zii,imx51-rdu1"))
+		return do_rdu1_switch_reset();
+
+	return -ENODEV;
+}
+
 BAREBOX_CMD_START(rave_reset_switch)
 	.cmd		= do_rave_switch_reset,
-	BAREBOX_CMD_DESC("reset ethernet switch on RDU2")
+	BAREBOX_CMD_DESC("reset ethernet switch on RDU")
 	BAREBOX_CMD_GROUP(CMD_GRP_HWMANIP)
 BAREBOX_CMD_END
diff --git a/arch/arm/mach-imx/Kconfig b/arch/arm/mach-imx/Kconfig
index 3cfa0c19870f..c4e7500e8fda 100644
--- a/arch/arm/mach-imx/Kconfig
+++ b/arch/arm/mach-imx/Kconfig
@@ -439,6 +439,7 @@ config MACH_ZII_RDU1
 	select ARCH_IMX51
 	select MACH_FREESCALE_MX51_PDK_POWER
 	select CRC8
+	select MACH_ZII_COMMON
 
 config MACH_ZII_RDU2
 	bool "ZII i.MX6Q(+) RDU2"
diff --git a/include/linux/mfd/rave-sp.h b/include/linux/mfd/rave-sp.h
index 37a37788d885..7b3187cb745c 100644
--- a/include/linux/mfd/rave-sp.h
+++ b/include/linux/mfd/rave-sp.h
@@ -25,6 +25,7 @@ enum rave_sp_command {
 	RAVE_SP_CMD_SET_BACKLIGHT		= 0xA6,
 	RAVE_SP_CMD_RESET			= 0xA7,
 	RAVE_SP_CMD_RESET_REASON		= 0xA8,
+	RAVE_SP_CMD_RESET_ETH_SWITCH		= 0xAF,
 
 	RAVE_SP_CMD_JUMP_TO_BOOTLOADER		= 0xB0,
 	RAVE_SP_CMD_BOOTLOADER			= 0xB1,
-- 
2.20.1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  reply	other threads:[~2019-03-13 10:56 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-13 10:56 [PATCH 1/6] ARM: add Zii common directory and move switch reset command Lucas Stach
2019-03-13 10:56 ` Lucas Stach [this message]
2019-03-13 10:56 ` [PATCH 3/6] ARM: zii-common: introduce RDU part-number based fixup abstraction Lucas Stach
2019-03-13 10:56 ` [PATCH 4/6] ARM: zii-common: fetch network config from SP Lucas Stach
2019-03-13 10:56 ` [PATCH 5/6] ARM: rdu2: Add p/n based fixups for touchscreen and display panel Lucas Stach
2019-03-13 10:56 ` [PATCH 6/6] ARM: rdu2: patch DSA config Lucas Stach
2019-03-18  8:06 ` [PATCH 1/6] ARM: add Zii common directory and move switch reset command Sascha Hauer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190313105635.22055-2-l.stach@pengutronix.de \
    --to=l.stach@pengutronix.de \
    --cc=andrew.smirnov@gmail.com \
    --cc=barebox@lists.infradead.org \
    --cc=cphealy@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox