From: Fidan Aliyeva <fidan.aliyeva.ext@ericsson.com>
To: <andrew@lunn.ch>, <olteanv@gmail.com>, <davem@davemloft.net>,
<edumazet@google.com>, <kuba@kernel.org>, <pabeni@redhat.com>,
<marek.behun@nic.cz>
Cc: <netdev@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
<fidan.aliyeva.ext@ericsson.com>,
Thomas Eckerman <thomas.eckerman.ext@ericsson.com>
Subject: [PATCH net-next 2/4] mv88e6xxx: Cache scratch config3 of 6352
Date: Sat, 16 May 2026 00:37:05 +0200 [thread overview]
Message-ID: <20260515223707.1026325-3-fidan.aliyeva.ext@ericsson.com> (raw)
In-Reply-To: <20260515223707.1026325-1-fidan.aliyeva.ext@ericsson.com>
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>
---
drivers/net/dsa/mv88e6xxx/chip.c | 7 +++++-
drivers/net/dsa/mv88e6xxx/chip.h | 3 +++
drivers/net/dsa/mv88e6xxx/global2.h | 1 +
drivers/net/dsa/mv88e6xxx/global2_scratch.c | 25 +++++++++++++++++++++
4 files changed, 35 insertions(+), 1 deletion(-)
diff --git a/drivers/net/dsa/mv88e6xxx/chip.c b/drivers/net/dsa/mv88e6xxx/chip.c
index 6102b7fd8d44..4ed6f880e02c 100644
--- a/drivers/net/dsa/mv88e6xxx/chip.c
+++ b/drivers/net/dsa/mv88e6xxx/chip.c
@@ -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 */
diff --git a/drivers/net/dsa/mv88e6xxx/chip.h b/drivers/net/dsa/mv88e6xxx/chip.h
index 2b235ac2c5df..d911f60aca10 100644
--- a/drivers/net/dsa/mv88e6xxx/chip.h
+++ b/drivers/net/dsa/mv88e6xxx/chip.h
@@ -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
diff --git a/drivers/net/dsa/mv88e6xxx/global2.h b/drivers/net/dsa/mv88e6xxx/global2.h
index 82f9b410de0b..ff5adf7c9bc3 100644
--- a/drivers/net/dsa/mv88e6xxx/global2.h
+++ b/drivers/net/dsa/mv88e6xxx/global2.h
@@ -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);
diff --git a/drivers/net/dsa/mv88e6xxx/global2_scratch.c b/drivers/net/dsa/mv88e6xxx/global2_scratch.c
index 53a6d3ed63b3..a2c09bbdde17 100644
--- a/drivers/net/dsa/mv88e6xxx/global2_scratch.c
+++ b/drivers/net/dsa/mv88e6xxx/global2_scratch.c
@@ -321,6 +321,31 @@ 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. Returns 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
--
2.36.0
next prev parent reply other threads:[~2026-05-15 22:37 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-10 21:34 [RFC PATCH 1/1] mv88e6xxx: Cache scratch config of 6352 in setup Fidan Aliyeva
2026-05-10 21:45 ` Fidan Aliyeva
2026-05-10 23:06 ` Andrew Lunn
2026-05-10 23:13 ` Andrew Lunn
2026-05-15 14:50 ` Fidan Aliyeva
2026-05-15 15:35 ` Andrew Lunn
2026-05-15 22:37 ` [PATCH net-next 0/4] mv88e6xxx: Cache scratch config3 of 6352 Fidan Aliyeva
2026-05-15 22:37 ` [PATCH net-next 1/4] mv88e6xxx: Add mv88e6352_reset for 6352 family Fidan Aliyeva
2026-05-15 22:37 ` Fidan Aliyeva [this message]
2026-05-15 22:37 ` [PATCH net-next 3/4] mv88e6xxx: Use cached config3 in 6352 has_serdes Fidan Aliyeva
2026-05-15 22:37 ` [PATCH net-next 4/4] mv88e6xxx: Remove locks for 6352's has_serdes Fidan Aliyeva
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=20260515223707.1026325-3-fidan.aliyeva.ext@ericsson.com \
--to=fidan.aliyeva.ext@ericsson.com \
--cc=andrew@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=marek.behun@nic.cz \
--cc=netdev@vger.kernel.org \
--cc=olteanv@gmail.com \
--cc=pabeni@redhat.com \
--cc=thomas.eckerman.ext@ericsson.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