From: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
To: netdev@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, kernel@savoirfairelinux.com,
"David S. Miller" <davem@davemloft.net>,
Florian Fainelli <f.fainelli@gmail.com>,
Andrew Lunn <andrew@lunn.ch>,
Vivien Didelot <vivien.didelot@savoirfairelinux.com>
Subject: [PATCH net-next v2 17/21] net: dsa: mv88e6xxx: factorize GLOBAL_CONTROL_2 setup
Date: Mon, 9 May 2016 13:22:54 -0400 [thread overview]
Message-ID: <1462814578-6249-18-git-send-email-vivien.didelot@savoirfairelinux.com> (raw)
In-Reply-To: <1462814578-6249-1-git-send-email-vivien.didelot@savoirfairelinux.com>
All switch models setup the GLOBAL_CONTROL_2 register with slightly
differences.
Since the cascade mode is valid even in a single chip setup, factorize
such configuration.
Signed-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
---
drivers/net/dsa/mv88e6123.c | 15 ---------------
drivers/net/dsa/mv88e6131.c | 16 ----------------
drivers/net/dsa/mv88e6171.c | 15 ---------------
drivers/net/dsa/mv88e6352.c | 14 --------------
drivers/net/dsa/mv88e6xxx.c | 7 +++++++
5 files changed, 7 insertions(+), 60 deletions(-)
diff --git a/drivers/net/dsa/mv88e6123.c b/drivers/net/dsa/mv88e6123.c
index 5df06d8..8f3a7c5 100644
--- a/drivers/net/dsa/mv88e6123.c
+++ b/drivers/net/dsa/mv88e6123.c
@@ -51,17 +51,6 @@ static const char *mv88e6123_drv_probe(struct device *dsa_dev,
ARRAY_SIZE(mv88e6123_table));
}
-static int mv88e6123_setup_global(struct dsa_switch *ds)
-{
- struct mv88e6xxx_priv_state *ps = ds_to_priv(ds);
-
- /* Disable remote management for now, and set the switch's
- * DSA device number.
- */
- return mv88e6xxx_reg_write(ps, REG_GLOBAL, GLOBAL_CONTROL_2,
- ds->index & 0x1f);
-}
-
static int mv88e6123_setup(struct dsa_switch *ds)
{
struct mv88e6xxx_priv_state *ps = ds_to_priv(ds);
@@ -73,10 +62,6 @@ static int mv88e6123_setup(struct dsa_switch *ds)
if (ret < 0)
return ret;
- ret = mv88e6123_setup_global(ds);
- if (ret < 0)
- return ret;
-
return mv88e6xxx_setup_ports(ds);
}
diff --git a/drivers/net/dsa/mv88e6131.c b/drivers/net/dsa/mv88e6131.c
index c8e3974..b6ca07b 100644
--- a/drivers/net/dsa/mv88e6131.c
+++ b/drivers/net/dsa/mv88e6131.c
@@ -61,22 +61,6 @@ static const char *mv88e6131_drv_probe(struct device *dsa_dev,
static int mv88e6131_setup_global(struct dsa_switch *ds)
{
struct mv88e6xxx_priv_state *ps = ds_to_priv(ds);
- int ret;
-
- /* Disable cascade port functionality unless this device
- * is used in a cascade configuration, and set the switch's
- * DSA device number.
- */
- if (ds->dst->pd->nr_chips > 1)
- ret = mv88e6xxx_reg_write(ps, REG_GLOBAL, GLOBAL_CONTROL_2,
- GLOBAL_CONTROL_2_MULTIPLE_CASCADE |
- (ds->index & 0x1f));
- else
- ret = mv88e6xxx_reg_write(ps, REG_GLOBAL, GLOBAL_CONTROL_2,
- GLOBAL_CONTROL_2_NO_CASCADE |
- (ds->index & 0x1f));
- if (ret)
- return ret;
/* Force the priority of IGMP/MLD snoop frames and ARP frames
* to the highest setting.
diff --git a/drivers/net/dsa/mv88e6171.c b/drivers/net/dsa/mv88e6171.c
index a848aef..83678ad 100644
--- a/drivers/net/dsa/mv88e6171.c
+++ b/drivers/net/dsa/mv88e6171.c
@@ -58,17 +58,6 @@ static const char *mv88e6171_drv_probe(struct device *dsa_dev,
ARRAY_SIZE(mv88e6171_table));
}
-static int mv88e6171_setup_global(struct dsa_switch *ds)
-{
- struct mv88e6xxx_priv_state *ps = ds_to_priv(ds);
-
- /* Disable remote management for now, and set the switch's
- * DSA device number.
- */
- return mv88e6xxx_reg_write(ps, REG_GLOBAL, GLOBAL_CONTROL_2,
- ds->index & 0x1f);
-}
-
static int mv88e6171_setup(struct dsa_switch *ds)
{
struct mv88e6xxx_priv_state *ps = ds_to_priv(ds);
@@ -80,10 +69,6 @@ static int mv88e6171_setup(struct dsa_switch *ds)
if (ret < 0)
return ret;
- ret = mv88e6171_setup_global(ds);
- if (ret < 0)
- return ret;
-
return mv88e6xxx_setup_ports(ds);
}
diff --git a/drivers/net/dsa/mv88e6352.c b/drivers/net/dsa/mv88e6352.c
index e098870..81810dd 100644
--- a/drivers/net/dsa/mv88e6352.c
+++ b/drivers/net/dsa/mv88e6352.c
@@ -77,16 +77,6 @@ static const char *mv88e6352_drv_probe(struct device *dsa_dev,
ARRAY_SIZE(mv88e6352_table));
}
-static int mv88e6352_setup_global(struct dsa_switch *ds)
-{
- struct mv88e6xxx_priv_state *ps = ds_to_priv(ds);
-
- /* Disable remote management for now, and set the switch's
- * DSA device number.
- */
- return mv88e6xxx_reg_write(ps, REG_GLOBAL, 0x1c, ds->index & 0x1f);
-}
-
static int mv88e6352_setup(struct dsa_switch *ds)
{
struct mv88e6xxx_priv_state *ps = ds_to_priv(ds);
@@ -98,10 +88,6 @@ static int mv88e6352_setup(struct dsa_switch *ds)
if (ret < 0)
return ret;
- ret = mv88e6352_setup_global(ds);
- if (ret < 0)
- return ret;
-
return mv88e6xxx_setup_ports(ds);
}
diff --git a/drivers/net/dsa/mv88e6xxx.c b/drivers/net/dsa/mv88e6xxx.c
index 27551c1..d8bb4c8 100644
--- a/drivers/net/dsa/mv88e6xxx.c
+++ b/drivers/net/dsa/mv88e6xxx.c
@@ -2950,6 +2950,13 @@ static int mv88e6xxx_setup_global(struct mv88e6xxx_priv_state *ps)
if (err)
return err;
+ /* Disable remote management, and set the switch's DSA device number. */
+ err = _mv88e6xxx_reg_write(ps, REG_GLOBAL, GLOBAL_CONTROL_2,
+ GLOBAL_CONTROL_2_MULTIPLE_CASCADE |
+ (ds->index & 0x1f));
+ if (err)
+ return err;
+
/* Set the default address aging time to 5 minutes, and
* enable address learn messages to be sent to all message
* ports.
--
2.8.2
next prev parent reply other threads:[~2016-05-09 17:23 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-05-09 17:22 [PATCH net-next v2 00/21] net: dsa: mv88e6xxx: turn into monolithic driver Vivien Didelot
2016-05-09 17:22 ` [PATCH net-next v2 01/21] net: dsa: mv88e6xxx: add flags to info Vivien Didelot
2016-05-09 17:22 ` [PATCH net-next v2 02/21] net: dsa: mv88e6xxx: factorize PHY access with PPU Vivien Didelot
2016-05-09 17:22 ` [PATCH net-next v2 03/21] net: dsa: mv88e6xxx: factorize PHY indirect access Vivien Didelot
2016-05-09 17:22 ` [PATCH net-next v2 04/21] net: dsa: mv88e6xxx: factorize EEPROM access Vivien Didelot
2016-05-09 17:22 ` [PATCH net-next v2 05/21] net: dsa: mv88e6xxx: factorize temperature access Vivien Didelot
2016-05-09 17:22 ` [PATCH net-next v2 06/21] net: dsa: mv88e6xxx: factorize MAC address setting Vivien Didelot
2016-05-09 17:22 ` [PATCH net-next v2 07/21] net: dsa: mv88e6xxx: factorize EEE access Vivien Didelot
2016-05-09 17:22 ` [PATCH net-next v2 08/21] net: dsa: mv88e6131: add registers access Vivien Didelot
2016-05-09 17:22 ` [PATCH net-next v2 09/21] net: dsa: mv88e6xxx: factorize bridge support Vivien Didelot
2016-05-09 17:22 ` [PATCH net-next v2 10/21] net: dsa: mv88e6xxx: factorize VTU access Vivien Didelot
2016-05-09 17:22 ` [PATCH net-next v2 11/21] net: dsa: mv88e6xxx: factorize ATU access Vivien Didelot
2016-05-09 17:22 ` [PATCH net-next v2 12/21] net: dsa: mv88e6xxx: factorize switch reset Vivien Didelot
2016-05-09 17:22 ` [PATCH net-next v2 13/21] net: dsa: mv88e6xxx: factorize global setup Vivien Didelot
2016-05-09 17:22 ` [PATCH net-next v2 14/21] net: dsa: mv88e6xxx: factorize GLOBAL_CONTROL setup Vivien Didelot
2016-05-09 17:22 ` [PATCH net-next v2 15/21] net: dsa: mv88e6131: drop VLAN Ethertype setup Vivien Didelot
2016-05-09 17:22 ` [PATCH net-next v2 16/21] net: dsa: mv88e6xxx: factorize GLOBAL_MONITOR_CONTROL setup Vivien Didelot
2016-05-09 17:22 ` Vivien Didelot [this message]
2016-05-09 17:22 ` [PATCH net-next v2 18/21] net: dsa: mv88e6131: drop frames priorities setup Vivien Didelot
2016-05-09 17:22 ` [PATCH net-next v2 19/21] net: dsa: mv88e6xxx: factorize switch setup Vivien Didelot
2016-05-09 17:22 ` [PATCH net-next v2 20/21] net: dsa: mv88e6131: use EDSA tag protocol Vivien Didelot
2016-05-09 17:22 ` [PATCH net-next v2 21/21] net: dsa: mv88e6xxx: factorize the switch driver Vivien Didelot
2016-05-09 17:56 ` [PATCH net-next v2 00/21] net: dsa: mv88e6xxx: turn into monolithic driver Andrew Lunn
2016-05-09 19:00 ` David Miller
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=1462814578-6249-18-git-send-email-vivien.didelot@savoirfairelinux.com \
--to=vivien.didelot@savoirfairelinux.com \
--cc=andrew@lunn.ch \
--cc=davem@davemloft.net \
--cc=f.fainelli@gmail.com \
--cc=kernel@savoirfairelinux.com \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
/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;
as well as URLs for NNTP newsgroup(s).