aboutsummaryrefslogtreecommitdiffstats
path: root/target/linux/ramips
diff options
context:
space:
mode:
authorGabor Juhos <juhosg@openwrt.org>2010-12-08 10:15:25 +0000
committerGabor Juhos <juhosg@openwrt.org>2010-12-08 10:15:25 +0000
commit692d379b50681bd3111bfa8acd5fb899506d2465 (patch)
tree781b4c9a91ae32ffff09001a3f77eec488a1e469 /target/linux/ramips
parentf7c3f9107463f6a83c249eca7559240e849e4a3f (diff)
downloadupstream-692d379b50681bd3111bfa8acd5fb899506d2465.tar.gz
upstream-692d379b50681bd3111bfa8acd5fb899506d2465.tar.bz2
upstream-692d379b50681bd3111bfa8acd5fb899506d2465.zip
ramips: ramips_esw: add helper function to set vlan members
SVN-Revision: 24338
Diffstat (limited to 'target/linux/ramips')
-rw-r--r--target/linux/ramips/files/drivers/net/ramips_esw.c32
1 files changed, 31 insertions, 1 deletions
diff --git a/target/linux/ramips/files/drivers/net/ramips_esw.c b/target/linux/ramips/files/drivers/net/ramips_esw.c
index d57245cd63..c4220324a0 100644
--- a/target/linux/ramips/files/drivers/net/ramips_esw.c
+++ b/target/linux/ramips/files/drivers/net/ramips_esw.c
@@ -31,6 +31,17 @@
#define RT305X_ESW_VLANI_VID_M 0xfff
#define RT305X_ESW_VLANI_VID_S 12
+#define RT305X_ESW_VMSC_MSC_M 0xff
+#define RT305X_ESW_VMSC_MSC_S 8
+
+#define RT305X_ESW_PORT0 0
+#define RT305X_ESW_PORT1 1
+#define RT305X_ESW_PORT2 2
+#define RT305X_ESW_PORT3 3
+#define RT305X_ESW_PORT4 4
+#define RT305X_ESW_PORT5 5
+#define RT305X_ESW_PORT6 6
+
struct rt305x_esw {
void __iomem *base;
struct rt305x_esw_platform_data *pdata;
@@ -124,6 +135,18 @@ rt305x_esw_set_vlan_id(struct rt305x_esw *esw, unsigned vlan, unsigned vid)
}
static void
+rt305x_esw_set_vmsc(struct rt305x_esw *esw, unsigned vlan, unsigned msc)
+{
+ unsigned s;
+
+ s = RT305X_ESW_VMSC_MSC_S * (vlan % 4);
+ rt305x_esw_rmw(esw,
+ RT305X_ESW_REG_VMSC(vlan / 4),
+ RT305X_ESW_VMSC_MSC_M << s,
+ (msc & RT305X_ESW_VMSC_MSC_M) << s);
+}
+
+static void
rt305x_esw_hw_init(struct rt305x_esw *esw)
{
int i;
@@ -170,7 +193,14 @@ rt305x_esw_hw_init(struct rt305x_esw *esw)
/* set default vlan */
rt305x_esw_set_vlan_id(esw, 0, 1);
rt305x_esw_set_vlan_id(esw, 1, 2);
- rt305x_esw_wr(esw, 0x504f, RT305X_ESW_REG_VMSC(0));
+ rt305x_esw_set_vmsc(esw, 0,
+ (BIT(RT305X_ESW_PORT0) | BIT(RT305X_ESW_PORT1) |
+ BIT(RT305X_ESW_PORT2) | BIT(RT305X_ESW_PORT3) |
+ BIT(RT305X_ESW_PORT6)));
+ rt305x_esw_set_vmsc(esw, 1,
+ (BIT(RT305X_ESW_PORT4) | BIT(RT305X_ESW_PORT6)));
+ rt305x_esw_set_vmsc(esw, 2, 0);
+ rt305x_esw_set_vmsc(esw, 3, 0);
}
static int