lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20190821232724.1544-10-marek.behun@nic.cz>
Date:   Thu, 22 Aug 2019 01:27:23 +0200
From:   Marek Behún <marek.behun@....cz>
To:     netdev@...r.kernel.org
Cc:     Andrew Lunn <andrew@...n.ch>,
        Vivien Didelot <vivien.didelot@...il.com>,
        Florian Fainelli <f.fainelli@...il.com>,
        Vladimir Oltean <olteanv@...il.com>,
        Marek Behún <marek.behun@....cz>
Subject: [PATCH net-next 09/10] net: dsa: mv88e6xxx: support Block Address setting in hidden registers

Add support for setting the Block Address parameter when reading/writing
hidden registers. Marvell's mdio examples for SERDES settings on Topaz
use Block Address 0x7 when reading/writing hidden registers, although
the specification says that block must be set to 0xf.

Signed-off-by: Marek Behún <marek.behun@....cz>
---
 drivers/net/dsa/mv88e6xxx/chip.c   | 4 ++--
 drivers/net/dsa/mv88e6xxx/hidden.c | 8 ++++----
 drivers/net/dsa/mv88e6xxx/hidden.h | 8 +++++---
 3 files changed, 11 insertions(+), 9 deletions(-)

diff --git a/drivers/net/dsa/mv88e6xxx/chip.c b/drivers/net/dsa/mv88e6xxx/chip.c
index 96f7ac56dd02..9af6f3aeb83b 100644
--- a/drivers/net/dsa/mv88e6xxx/chip.c
+++ b/drivers/net/dsa/mv88e6xxx/chip.c
@@ -2326,7 +2326,7 @@ static bool mv88e6390_setup_errata_applied(struct mv88e6xxx_chip *chip)
 	u16 val;
 
 	for (port = 0; port < mv88e6xxx_num_ports(chip); port++) {
-		err = mv88e6390_hidden_read(chip, port, 0, &val);
+		err = mv88e6390_hidden_read(chip, 0xf, port, 0, &val);
 		if (err) {
 			dev_err(chip->dev,
 				"Error reading hidden register: %d\n", err);
@@ -2359,7 +2359,7 @@ static int mv88e6390_setup_errata(struct mv88e6xxx_chip *chip)
 	}
 
 	for (port = 0; port < mv88e6xxx_num_ports(chip); port++) {
-		err = mv88e6390_hidden_write(chip, port, 0, 0x01c0);
+		err = mv88e6390_hidden_write(chip, 0xf, port, 0, 0x01c0);
 		if (err)
 			return err;
 	}
diff --git a/drivers/net/dsa/mv88e6xxx/hidden.c b/drivers/net/dsa/mv88e6xxx/hidden.c
index efa93c776a30..d071c8810057 100644
--- a/drivers/net/dsa/mv88e6xxx/hidden.c
+++ b/drivers/net/dsa/mv88e6xxx/hidden.c
@@ -16,7 +16,7 @@
 /* The mv88e6390 and mv88e6341 have some hidden registers used for debug and
  * development. The errata also makes use of them.
  */
-int mv88e6390_hidden_write(struct mv88e6xxx_chip *chip, int port,
+int mv88e6390_hidden_write(struct mv88e6xxx_chip *chip, int block, int port,
 			   int reg, u16 val)
 {
 	u16 ctrl;
@@ -29,7 +29,7 @@ int mv88e6390_hidden_write(struct mv88e6xxx_chip *chip, int port,
 
 	ctrl = MV88E6XXX_PORT_RESERVED_1A_BUSY |
 	       MV88E6XXX_PORT_RESERVED_1A_WRITE |
-	       MV88E6XXX_PORT_RESERVED_1A_BLOCK |
+	       (block << MV88E6XXX_PORT_RESERVED_1A_BLOCK_SHIFT) |
 	       port << MV88E6XXX_PORT_RESERVED_1A_PORT_SHIFT | reg;
 
 	return mv88e6xxx_port_write(chip, MV88E6XXX_PORT_RESERVED_1A_CTRL_PORT,
@@ -44,7 +44,7 @@ int mv88e6390_hidden_wait(struct mv88e6xxx_chip *chip)
 				  MV88E6XXX_PORT_RESERVED_1A, bit, 0);
 }
 
-int mv88e6390_hidden_read(struct mv88e6xxx_chip *chip, int port,
+int mv88e6390_hidden_read(struct mv88e6xxx_chip *chip, int block, int port,
 			  int reg, u16 *val)
 {
 	u16 ctrl;
@@ -52,7 +52,7 @@ int mv88e6390_hidden_read(struct mv88e6xxx_chip *chip, int port,
 
 	ctrl = MV88E6XXX_PORT_RESERVED_1A_BUSY |
 	       MV88E6XXX_PORT_RESERVED_1A_READ |
-	       MV88E6XXX_PORT_RESERVED_1A_BLOCK |
+	       (block << MV88E6XXX_PORT_RESERVED_1A_BLOCK_SHIFT) |
 	       port << MV88E6XXX_PORT_RESERVED_1A_PORT_SHIFT | reg;
 
 	err = mv88e6xxx_port_write(chip, MV88E6XXX_PORT_RESERVED_1A_CTRL_PORT,
diff --git a/drivers/net/dsa/mv88e6xxx/hidden.h b/drivers/net/dsa/mv88e6xxx/hidden.h
index 632abbe4e139..71cc2f78fa30 100644
--- a/drivers/net/dsa/mv88e6xxx/hidden.h
+++ b/drivers/net/dsa/mv88e6xxx/hidden.h
@@ -18,14 +18,16 @@
 #define MV88E6XXX_PORT_RESERVED_1A_WRITE	BIT(14)
 #define MV88E6XXX_PORT_RESERVED_1A_READ		0
 #define MV88E6XXX_PORT_RESERVED_1A_PORT_SHIFT	5
-#define MV88E6XXX_PORT_RESERVED_1A_BLOCK	(0xf << 10)
+#define MV88E6XXX_PORT_RESERVED_1A_BLOCK_SHIFT	10
 #define MV88E6XXX_PORT_RESERVED_1A_CTRL_PORT	4
 #define MV88E6XXX_PORT_RESERVED_1A_DATA_PORT	5
+#define MV88E6341_PORT_RESERVED_1A_FORCE_CMODE	BIT(15)
+#define MV88E6341_PORT_RESERVED_1A_SGMII_AN	BIT(13)
 
-int mv88e6390_hidden_write(struct mv88e6xxx_chip *chip, int port,
+int mv88e6390_hidden_write(struct mv88e6xxx_chip *chip, int block, int port,
 			   int reg, u16 val);
 int mv88e6390_hidden_wait(struct mv88e6xxx_chip *chip);
-int mv88e6390_hidden_read(struct mv88e6xxx_chip *chip, int port,
+int mv88e6390_hidden_read(struct mv88e6xxx_chip *chip, int block, int port,
 			  int reg, u16 *val);
 
 #endif /* _MV88E6XXX_HIDDEN_H */
-- 
2.21.0

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ