Changeset 24337


Ignore:
Timestamp:
2010-12-08T11:15:22+01:00 (7 years ago)
Author:
juhosg
Message:

ramips: ramips_esw: add helper function to set VLAN id

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/target/linux/ramips/files/drivers/net/ramips_esw.c

    r24336 r24337  
    2929#define RT305X_ESW_PHY_TIMEOUT          (5 * HZ) 
    3030 
     31#define RT305X_ESW_VLANI_VID_M          0xfff 
     32#define RT305X_ESW_VLANI_VID_S          12 
     33 
    3134struct rt305x_esw { 
    3235        void __iomem *base; 
     
    110113 
    111114static void 
     115rt305x_esw_set_vlan_id(struct rt305x_esw *esw, unsigned vlan, unsigned vid) 
     116{ 
     117        unsigned s; 
     118 
     119        s = RT305X_ESW_VLANI_VID_S * (vlan % 2); 
     120        rt305x_esw_rmw(esw, 
     121                       RT305X_ESW_REG_VLANI(vlan / 2), 
     122                       RT305X_ESW_VLANI_VID_M << s, 
     123                       (vid & RT305X_ESW_VLANI_VID_M) << s); 
     124} 
     125 
     126static void 
    112127rt305x_esw_hw_init(struct rt305x_esw *esw) 
    113128{ 
     
    118133        rt305x_esw_wr(esw, 0x00000000, RT305X_ESW_REG_SGC2); 
    119134        rt305x_esw_wr(esw, 0x00405555, RT305X_ESW_REG_PFC1); 
    120         rt305x_esw_wr(esw, 0x00002001, RT305X_ESW_REG_VLANI(0)); 
    121135        rt305x_esw_wr(esw, 0x00007f7f, RT305X_ESW_REG_POC1); 
    122136        rt305x_esw_wr(esw, 0x00007f3f, RT305X_ESW_REG_POC3); 
     
    155169 
    156170        /* set default vlan */ 
    157         rt305x_esw_wr(esw, 0x2001, RT305X_ESW_REG_VLANI(0)); 
     171        rt305x_esw_set_vlan_id(esw, 0, 1); 
     172        rt305x_esw_set_vlan_id(esw, 1, 2); 
    158173        rt305x_esw_wr(esw, 0x504f, RT305X_ESW_REG_VMSC(0)); 
    159174} 
Note: See TracChangeset for help on using the changeset viewer.