[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20190521193004.10767-9-vivien.didelot@gmail.com>
Date: Tue, 21 May 2019 15:30:03 -0400
From: Vivien Didelot <vivien.didelot@...il.com>
To: netdev@...r.kernel.org
Cc: cphealy@...il.com, Vivien Didelot <vivien.didelot@...il.com>,
Florian Fainelli <f.fainelli@...il.com>,
Andrew Lunn <andrew@...n.ch>,
"David S. Miller" <davem@...emloft.net>
Subject: [RFC net-next 8/9] net: dsa: mv88e6xxx: setup RMU port
Enable the RMU on the first upstream port found on this switch.
Signed-off-by: Vivien Didelot <vivien.didelot@...il.com>
---
drivers/net/dsa/mv88e6xxx/Makefile | 1 +
drivers/net/dsa/mv88e6xxx/chip.c | 9 +----
drivers/net/dsa/mv88e6xxx/rmu.c | 58 ++++++++++++++++++++++++++++++
drivers/net/dsa/mv88e6xxx/rmu.h | 33 +++++++++++++++++
4 files changed, 93 insertions(+), 8 deletions(-)
create mode 100644 drivers/net/dsa/mv88e6xxx/rmu.c
create mode 100644 drivers/net/dsa/mv88e6xxx/rmu.h
diff --git a/drivers/net/dsa/mv88e6xxx/Makefile b/drivers/net/dsa/mv88e6xxx/Makefile
index e85755dde90b..c95679d0c615 100644
--- a/drivers/net/dsa/mv88e6xxx/Makefile
+++ b/drivers/net/dsa/mv88e6xxx/Makefile
@@ -11,5 +11,6 @@ mv88e6xxx-$(CONFIG_NET_DSA_MV88E6XXX_PTP) += hwtstamp.o
mv88e6xxx-objs += phy.o
mv88e6xxx-objs += port.o
mv88e6xxx-$(CONFIG_NET_DSA_MV88E6XXX_PTP) += ptp.o
+mv88e6xxx-objs += rmu.o
mv88e6xxx-objs += serdes.o
mv88e6xxx-objs += smi.o
diff --git a/drivers/net/dsa/mv88e6xxx/chip.c b/drivers/net/dsa/mv88e6xxx/chip.c
index 3aa2b315b96d..048fdaf1335e 100644
--- a/drivers/net/dsa/mv88e6xxx/chip.c
+++ b/drivers/net/dsa/mv88e6xxx/chip.c
@@ -42,6 +42,7 @@
#include "phy.h"
#include "port.h"
#include "ptp.h"
+#include "rmu.h"
#include "serdes.h"
#include "smi.h"
@@ -1199,14 +1200,6 @@ static int mv88e6xxx_trunk_setup(struct mv88e6xxx_chip *chip)
return 0;
}
-static int mv88e6xxx_rmu_setup(struct mv88e6xxx_chip *chip)
-{
- if (chip->info->ops->rmu_disable)
- return chip->info->ops->rmu_disable(chip);
-
- return 0;
-}
-
static int mv88e6xxx_pot_setup(struct mv88e6xxx_chip *chip)
{
if (chip->info->ops->pot_clear)
diff --git a/drivers/net/dsa/mv88e6xxx/rmu.c b/drivers/net/dsa/mv88e6xxx/rmu.c
new file mode 100644
index 000000000000..71dabe6ecb46
--- /dev/null
+++ b/drivers/net/dsa/mv88e6xxx/rmu.c
@@ -0,0 +1,58 @@
+/*
+ * Marvell 88E6xxx Remote Management Unit (RMU) support
+ *
+ * Copyright (c) 2019 Vivien Didelot <vivien.didelot@...il.com>
+ *
+ * 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.
+ */
+
+#include "chip.h"
+#include "rmu.h"
+
+static int mv88e6xxx_rmu_setup_port(struct mv88e6xxx_chip *chip, int port)
+{
+ int err;
+
+ /* First disable the RMU */
+ if (chip->info->ops->rmu_disable) {
+ err = chip->info->ops->rmu_disable(chip);
+ if (err)
+ return err;
+ }
+
+ /* Then enable the RMU on this dedicated port */
+ if (chip->info->ops->rmu_enable) {
+ err = chip->info->ops->rmu_enable(chip, port, false);
+ if (err)
+ return err;
+
+ dev_info(chip->dev, "RMU enabled on port %d\n", port);
+
+ return 0;
+ }
+
+ return -EOPNOTSUPP;
+}
+
+int mv88e6xxx_rmu_setup(struct mv88e6xxx_chip *chip)
+{
+ struct dsa_switch *ds = chip->ds;
+ int port;
+ int err;
+
+ /* Find a local port (in)directly connected to the CPU to enable RMU on */
+ for (port = 0; port < mv88e6xxx_num_ports(chip); port++) {
+ if (dsa_is_upstream_port(ds, port)) {
+ err = mv88e6xxx_rmu_setup_port(chip, port);
+ if (err)
+ continue;
+
+ return 0;
+ }
+ }
+
+ return 0;
+}
diff --git a/drivers/net/dsa/mv88e6xxx/rmu.h b/drivers/net/dsa/mv88e6xxx/rmu.h
new file mode 100644
index 000000000000..f7d849b169d2
--- /dev/null
+++ b/drivers/net/dsa/mv88e6xxx/rmu.h
@@ -0,0 +1,33 @@
+/*
+ * Marvell 88E6xxx System Management Interface (RMU) support
+ *
+ * Copyright (c) 2019 Vivien Didelot <vivien.didelot@...il.com>
+ *
+ * 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.
+ */
+
+#ifndef _MV88E6XXX_RMU_H
+#define _MV88E6XXX_RMU_H
+
+#define MV88E6XXX_RMU_REQUEST_FORMAT_SOHO 0x0001
+
+#define MV88E6XXX_RMU_REQUEST_CODE_GET_ID 0x0000
+#define MV88E6XXX_RMU_REQUEST_CODE_DUMP_ATU 0x1000
+#define MV88E6XXX_RMU_REQUEST_CODE_DUMP_MIB 0x1020
+#define MV88E6XXX_RMU_REQUEST_CODE_READ_WRITE 0x2000
+
+#define MV88E6XXX_RMU_REQUEST_DATA_DUMP_MIB_CLEAR 0x8000
+
+#define MV88E6XXX_RMU_RESPONSE_CODE_GET_ID MV88E6XXX_RMU_REQUEST_CODE_GET_ID
+#define MV88E6XXX_RMU_RESPONSE_CODE_DUMP_ATU MV88E6XXX_RMU_REQUEST_CODE_DUMP_ATU
+#define MV88E6XXX_RMU_RESPONSE_CODE_DUMP_MIB MV88E6XXX_RMU_REQUEST_CODE_DUMP_MIB
+#define MV88E6XXX_RMU_RESPONSE_CODE_READ_WRITE MV88E6XXX_RMU_REQUEST_CODE_READ_WRITE
+
+#include "chip.h"
+
+int mv88e6xxx_rmu_setup(struct mv88e6xxx_chip *chip);
+
+#endif /* _MV88E6XXX_RMU_H */
--
2.21.0
Powered by blists - more mailing lists