diff options
author | Guenter Roeck <linux@roeck-us.net> | 2015-03-26 21:36:29 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2015-03-29 16:23:50 -0400 |
commit | d827e88a3f48606f1fcd0c285613befce375e076 (patch) | |
tree | 0ee3b0cc80aa4b6ab4c1d3293ea896e218710f32 /drivers/net/dsa/mv88e6xxx.c | |
parent | acdaffcc890a29262c9bb47e287b62488c85eb59 (diff) |
net: dsa: mv88e6xxx: Provide function for common port initialization
Provide mv88e6xxx_setup_port_common() for common port initialization.
Currently only write Port 1 Control and VLAN configuration since
this will be needed for hardware bridging. More can be added later
if desired/needed.
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Tested-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/dsa/mv88e6xxx.c')
-rw-r--r-- | drivers/net/dsa/mv88e6xxx.c | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/drivers/net/dsa/mv88e6xxx.c b/drivers/net/dsa/mv88e6xxx.c index 6496beb74510..2052e51edd5d 100644 --- a/drivers/net/dsa/mv88e6xxx.c +++ b/drivers/net/dsa/mv88e6xxx.c | |||
@@ -700,6 +700,45 @@ int mv88e6xxx_set_eee(struct dsa_switch *ds, int port, | |||
700 | return 0; | 700 | return 0; |
701 | } | 701 | } |
702 | 702 | ||
703 | int mv88e6xxx_setup_port_common(struct dsa_switch *ds, int port) | ||
704 | { | ||
705 | struct mv88e6xxx_priv_state *ps = ds_to_priv(ds); | ||
706 | int ret, reg; | ||
707 | |||
708 | mutex_lock(&ps->smi_mutex); | ||
709 | |||
710 | /* Port Control 1: disable trunking. Also, if this is the | ||
711 | * CPU port, enable learn messages to be sent to this port. | ||
712 | */ | ||
713 | ret = _mv88e6xxx_reg_write(ds, REG_PORT(port), 0x05, | ||
714 | dsa_is_cpu_port(ds, port) ? 0x8000 : 0x0000); | ||
715 | if (ret) | ||
716 | goto abort; | ||
717 | |||
718 | /* Port based VLAN map: give each port its own address | ||
719 | * database, allow the CPU port to talk to each of the 'real' | ||
720 | * ports, and allow each of the 'real' ports to only talk to | ||
721 | * the upstream port. | ||
722 | */ | ||
723 | reg = (port & 0xf) << 12; | ||
724 | if (dsa_is_cpu_port(ds, port)) | ||
725 | reg |= ds->phys_port_mask; | ||
726 | else | ||
727 | reg |= 1 << dsa_upstream_port(ds); | ||
728 | |||
729 | ret = _mv88e6xxx_reg_write(ds, REG_PORT(port), 0x06, reg); | ||
730 | if (ret) | ||
731 | goto abort; | ||
732 | |||
733 | /* Default VLAN ID and priority: don't set a default VLAN | ||
734 | * ID, and set the default packet priority to zero. | ||
735 | */ | ||
736 | ret = _mv88e6xxx_reg_write(ds, REG_PORT(port), 0x07, 0x0000); | ||
737 | abort: | ||
738 | mutex_unlock(&ps->smi_mutex); | ||
739 | return ret; | ||
740 | } | ||
741 | |||
703 | int mv88e6xxx_setup_common(struct dsa_switch *ds) | 742 | int mv88e6xxx_setup_common(struct dsa_switch *ds) |
704 | { | 743 | { |
705 | struct mv88e6xxx_priv_state *ps = ds_to_priv(ds); | 744 | struct mv88e6xxx_priv_state *ps = ds_to_priv(ds); |