diff mbox

[2/2] net: dsa: mv88e6xxx: add SERDES registers to debugfs

Message ID 1436387779-23407-2-git-send-email-vivien.didelot@savoirfairelinux.com
State Changes Requested, archived
Delegated to: David Miller
Headers show

Commit Message

Vivien Didelot July 8, 2015, 8:36 p.m. UTC
Add read and write access to a SERDES column in the regs debugfs file
for the Fiber/SERDES registers.

For instance, imagining that the Fiber Control register value is 0x1940,
you can clear the POWER_DOWN bit (11) with:

    echo SERDES 0 1140 > /sys/kernel/debug/dsa0/regs

Signed-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
---
 drivers/net/dsa/mv88e6xxx.c | 11 ++++++++---
 drivers/net/dsa/mv88e6xxx.h |  4 ++++
 2 files changed, 12 insertions(+), 3 deletions(-)

Comments

Andrew Lunn July 8, 2015, 9:08 p.m. UTC | #1
On Wed, Jul 08, 2015 at 04:36:19PM -0400, Vivien Didelot wrote:
> Add read and write access to a SERDES column in the regs debugfs file
> for the Fiber/SERDES registers.


Humm. I don't really like this. These SERDES registers are in a
complete different address space to the port, globalX registers. I
would suggest adding a new file, 'phy', which allows access to all the
phy registers, and SERDES at 0x0f.

This also makes it simpler to deal with devices which don't have
indirect access to the PHYs via Global 2 offset 0x18 and 0x19. For
such chips, the debugfs file should not be created.

Thanks
	Andrew
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/net/dsa/mv88e6xxx.c b/drivers/net/dsa/mv88e6xxx.c
index 04e6eb6..f1e9ab4 100644
--- a/drivers/net/dsa/mv88e6xxx.c
+++ b/drivers/net/dsa/mv88e6xxx.c
@@ -1628,16 +1628,18 @@  static int mv88e6xxx_regs_show(struct seq_file *s, void *p)
 	struct mv88e6xxx_priv_state *ps = ds_to_priv(ds);
 	int reg, port;
 
-	seq_puts(s, "    GLOBAL GLOBAL2 ");
+	seq_puts(s, "    GLOBAL GLOBAL2 SERDES ");
 	for (port = 0 ; port < ps->num_ports; port++)
 		seq_printf(s, " %2d  ", port);
 	seq_puts(s, "\n");
 
 	for (reg = 0; reg < 32; reg++) {
 		seq_printf(s, "%2x: ", reg);
-		seq_printf(s, " %4x    %4x  ",
+		seq_printf(s, " %4x    %4x    %4x  ",
 			   mv88e6xxx_reg_read(ds, REG_GLOBAL, reg),
-			   mv88e6xxx_reg_read(ds, REG_GLOBAL2, reg));
+			   mv88e6xxx_reg_read(ds, REG_GLOBAL2, reg),
+			   mv88e6xxx_phy_page_read(ds, REG_FIBER_SERDES,
+						   PAGE_FIBER_SERDES, reg));
 
 		for (port = 0 ; port < ps->num_ports; port++)
 			seq_printf(s, "%4x ",
@@ -1669,6 +1671,9 @@  static ssize_t mv88e6xxx_regs_write(struct file *file, const char __user *buf,
 		ret = mv88e6xxx_reg_write(ds, REG_GLOBAL, reg, val);
 	else if (strcasecmp(name, "GLOBAL2") == 0)
 		ret = mv88e6xxx_reg_write(ds, REG_GLOBAL2, reg, val);
+	else if (strcasecmp(name, "SERDES") == 0)
+		ret = mv88e6xxx_phy_page_write(ds, REG_FIBER_SERDES,
+					       PAGE_FIBER_SERDES, reg, val);
 	else if (kstrtouint(name, 10, &port) == 0 && port < ps->num_ports)
 		ret = mv88e6xxx_reg_write(ds, REG_PORT(port), reg, val);
 	else
diff --git a/drivers/net/dsa/mv88e6xxx.h b/drivers/net/dsa/mv88e6xxx.h
index 1bc5a3e..87573c3 100644
--- a/drivers/net/dsa/mv88e6xxx.h
+++ b/drivers/net/dsa/mv88e6xxx.h
@@ -310,6 +310,10 @@ 
 #define GLOBAL2_QOS_WEIGHT	0x1c
 #define GLOBAL2_MISC		0x1d
 
+/* Fiber/SERDES Registers are located at SMI address F, page 1 */
+#define REG_FIBER_SERDES	0x0f
+#define PAGE_FIBER_SERDES	0x01
+
 struct mv88e6xxx_priv_state {
 	/* When using multi-chip addressing, this mutex protects
 	 * access to the indirect access registers.  (In single-chip