]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
mv88e6xxx: Cache scratch config3 of 6352
authorFidan Aliyeva <fidan.aliyeva.ext@ericsson.com>
Thu, 21 May 2026 20:29:22 +0000 (22:29 +0200)
committerPaolo Abeni <pabeni@redhat.com>
Tue, 26 May 2026 10:11:32 +0000 (12:11 +0200)
Changes:

1. Add g2_scratch_config3 member to mv88e6xxx_chip.

2. Add mv88e6352_g2_cache_global_scratch_config3  which reads the
CONFIG3 value from the scratch register and caches it.

3. Call this function in mv88e6352_reset.

Co-developed-by: Thomas Eckerman <thomas.eckerman.ext@ericsson.com>
Signed-off-by: Thomas Eckerman <thomas.eckerman.ext@ericsson.com>
Signed-off-by: Fidan Aliyeva <fidan.aliyeva.ext@ericsson.com>
Link: https://patch.msgid.link/20260521202924.727929-3-fidan.aliyeva.ext@ericsson.com
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
drivers/net/dsa/mv88e6xxx/chip.c
drivers/net/dsa/mv88e6xxx/chip.h
drivers/net/dsa/mv88e6xxx/global2.h
drivers/net/dsa/mv88e6xxx/global2_scratch.c

index 21fc2e7f6a423dce2c4a25ab5a28df1be3b09e93..703421069cf897ea77d8ab382e27af11c3eec03b 100644 (file)
@@ -3736,13 +3736,18 @@ static int mv88e6390_setup_errata(struct mv88e6xxx_chip *chip)
        return mv88e6xxx_software_reset(chip);
 }
 
+/* For MV88E6XXX_FAMILY_6352, perform reset on G1 control.
+ * Also, read and cache G2 scratch register.
+ */
 static int mv88e6352_reset(struct mv88e6xxx_chip *chip)
 {
        int err;
 
        err = mv88e6352_g1_reset(chip);
+       if (err)
+               return err;
 
-       return err;
+       return mv88e6352_g2_cache_global_scratch_config3(chip);
 }
 
 /* prod_id for switch families which do not have a PHY model number */
index 4339f6810535e31df4d40c6e6ff3ae11d6875560..e966e7c4cc5dea37ab570f939b94d17db8fe3a83 100644 (file)
@@ -454,6 +454,9 @@ struct mv88e6xxx_chip {
 
        /* TCAM entries */
        struct mv88e6xxx_tcam tcam;
+
+       /* Global2 scratch register config data3 */
+       u8 g2_scratch_config3;
 };
 
 #define TCAM_MATCH_SIZE 96
index 82f9b410de0b885ba31e2535b51b477a82e3a2ca..ff5adf7c9bc3ab068222c2c41ae03ef8183f3e79 100644 (file)
@@ -382,6 +382,7 @@ int mv88e6390_g2_scratch_gpio_set_smi(struct mv88e6xxx_chip *chip,
                                      bool external);
 int mv88e6393x_g2_scratch_gpio_set_smi(struct mv88e6xxx_chip *chip,
                                       bool external);
+int mv88e6352_g2_cache_global_scratch_config3(struct mv88e6xxx_chip *chip);
 int mv88e6352_g2_scratch_port_has_serdes(struct mv88e6xxx_chip *chip, int port);
 int mv88e6xxx_g2_atu_stats_set(struct mv88e6xxx_chip *chip, u16 kind, u16 bin);
 int mv88e6xxx_g2_atu_stats_get(struct mv88e6xxx_chip *chip, u16 *stats);
index 53a6d3ed63b320eb116f3d1a17ad9b17dda3cbd2..f2f9e7dce1aadb2013791e61ae05d6cebd66ec07 100644 (file)
@@ -321,6 +321,32 @@ int mv88e6393x_g2_scratch_gpio_set_smi(struct mv88e6xxx_chip *chip,
        return mv88e6xxx_g2_scratch_write(chip, misc_cfg, val);
 }
 
+/**
+ * mv88e6352_g2_cache_global_scratch_config3 - caches G2 CONFIG3 value
+ * @chip: chip private data
+ *
+ * Reads and stores config3 value of global2 scratch registers, which
+ * can be used to determine if the port is attached to a serdes. The
+ * value does not change once the switch is released from reset and
+ * represents the value of the pin strapping.
+ *
+ * Return: negative error number if the register read fails; otherwise, 0
+ */
+int mv88e6352_g2_cache_global_scratch_config3(struct mv88e6xxx_chip *chip)
+{
+       u8 config3;
+       int err;
+
+       err = mv88e6xxx_g2_scratch_read(chip, MV88E6352_G2_SCRATCH_CONFIG_DATA3,
+                                       &config3);
+       if (err)
+               return err;
+
+       chip->g2_scratch_config3 = config3;
+
+       return 0;
+}
+
 /**
  * mv88e6352_g2_scratch_port_has_serdes - indicate if a port can have a serdes
  * @chip: chip private data