Changeset 35580


Ignore:
Timestamp:
2013-02-13T17:03:03+01:00 (5 years ago)
Author:
hauke
Message:

switch: the BCM5365 is a special switch and the BCM5350 or BCM5325 is the normal case.

This makes it easier to compare this code with the code from the Broadcom SDK.

Location:
trunk/package/switch/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/package/switch/src/etc53xx.h

    r34992 r35580  
    543543#define VLAN_TABLE_READ 0               /* for read/write state in table access reg */ 
    544544#define VLAN_ID_HIGH_BITS 0             /* static high bits in table access reg */ 
    545 #define VLAN_ID_MAX 255                 /* max VLAN id */ 
    546 #define VLAN_ID_MAX5350 15              /* max VLAN id (5350) */ 
    547 #define VLAN_ID_MAX5395 4094            /* max VLAN id (5395) */ 
     545#define VLAN_ID_MAX 15                  /* max VLAN id (5350) */ 
     546#define VLAN_ID_MAX_5365 255            /* max VLAN id */ 
     547#define VLAN_ID_MAX_5395 4094           /* max VLAN id (5395) */ 
    548548#define VLAN_ID_MASK VLAN_ID_MAX        /* VLAN id mask */ 
    549549#ifdef BCM5380 
     
    596596#define ROBO_VLAN_CTRL4             0x04 /* 8b: VLAN Control 4 Register */ 
    597597#define ROBO_VLAN_CTRL5             0x05 /* 8b: VLAN Control 5 Register */ 
    598 #define ROBO_VLAN_TABLE_ACCESS      0x08 /* 14b: VLAN Table Access Register */ 
    599 #define ROBO_VLAN_TABLE_ACCESS_5350 0x06 /* 14b: VLAN Table Access Register (5350) */ 
    600 #define ROBO_VLAN_WRITE             0x0a /* 15b: VLAN Write Register */ 
    601 #define ROBO_VLAN_WRITE_5350        0x08 /* 15b: VLAN Write Register (5350) */ 
     598#define ROBO_VLAN_TABLE_ACCESS_5365 0x08 /* 14b: VLAN Table Access Register */ 
     599#define ROBO_VLAN_TABLE_ACCESS      0x06 /* 14b: VLAN Table Access Register (5350) */ 
     600#define ROBO_VLAN_WRITE_5365        0x0a /* 15b: VLAN Write Register */ 
     601#define ROBO_VLAN_WRITE             0x08 /* 15b: VLAN Write Register (5350) */ 
    602602#define ROBO_VLAN_READ              0x0c /* 15b: VLAN Read Register */ 
    603603#define ROBO_VLAN_PORT0_DEF_TAG     0x10 /* 16b: VLAN Port 0 Default Tag Register */ 
  • trunk/package/switch/src/switch-robo.c

    r35579 r35580  
    7373        char *device;                   /* The device name string (ethX) */ 
    7474        u16 devid;                      /* ROBO_DEVICE_ID_53xx */ 
    75         bool is_5350; 
    76         u8 gmii;                        /* gigabit mii */ 
     75        bool is_5365; 
     76        bool gmii;                      /* gigabit mii */ 
    7777        int gpio_robo_reset; 
    7878        int gpio_lanports_enable; 
     
    199199} 
    200200 
    201 /* checks that attached switch is 5325/5352/5354/5356/5357/53115 */ 
    202 static int robo_vlan5350(__u32 phyid) 
     201/* checks that attached switch is 5365 */ 
     202static bool robo_bcm5365(void) 
    203203{ 
    204204        /* set vlan access id to 15 and read it back */ 
    205205        __u16 val16 = 15; 
    206         robo_write16(ROBO_VLAN_PAGE, ROBO_VLAN_TABLE_ACCESS_5350, val16); 
     206        robo_write16(ROBO_VLAN_PAGE, ROBO_VLAN_TABLE_ACCESS, val16); 
    207207 
    208208        /* 5365 will refuse this as it does not have this reg */ 
    209         if (robo_read16(ROBO_VLAN_PAGE, ROBO_VLAN_TABLE_ACCESS_5350) != val16) 
    210                 return 0; 
    211         /* gigabit ? */ 
     209        return robo_read16(ROBO_VLAN_PAGE, ROBO_VLAN_TABLE_ACCESS) != val16; 
     210} 
     211 
     212static bool robo_gmii(void) 
     213{ 
    212214        if (mdio_read(0, ROBO_MII_STAT) & 0x0100) 
    213                 robo.gmii = ((mdio_read(0, 0x0f) & 0xf000) != 0); 
    214         /* 53115 ? */ 
    215         if (robo.gmii && robo_read32(ROBO_STAT_PAGE, ROBO_LSA_IM_PORT) != 0) { 
    216                 robo_write16(ROBO_ARLIO_PAGE, ROBO_VTBL_INDX_5395, val16); 
    217                 robo_write16(ROBO_ARLIO_PAGE, ROBO_VTBL_ACCESS_5395, 
    218                                          (1 << 7) /* start */ | 1 /* read */); 
    219                 if (robo_read16(ROBO_ARLIO_PAGE, ROBO_VTBL_ACCESS_5395) == 1 && 
    220                     robo_read16(ROBO_ARLIO_PAGE, ROBO_VTBL_INDX_5395) == val16) 
    221                         return 4; 
    222         } 
    223         /* dirty trick for 5356/5357 */ 
    224         if ((phyid & 0xfff0ffff ) == 0x5da00362 || 
    225             (phyid & 0xfff0ffff ) == 0x5e000362) 
    226                 return 3; 
    227         /* 5325/5352/5354*/ 
    228         return 1; 
     215                return ((mdio_read(0, 0x0f) & 0xf000) != 0); 
     216        return false; 
    229217} 
    230218 
     
    393381        if (!robo.devid) 
    394382                robo.devid = ROBO_DEVICE_ID_5325; /* Fake it */ 
    395         robo.is_5350 = robo_vlan5350(phyid); 
     383        if (robo.devid == ROBO_DEVICE_ID_5325) 
     384                robo.is_5365 = robo_bcm5365(); 
     385        else 
     386                robo.is_5365 = false; 
     387 
     388        robo.gmii = robo_gmii(); 
    396389 
    397390        robo_switch_reset(); 
     
    401394 
    402395        printk(KERN_INFO PFX "found a 5%s%x!%s at %s\n", robo.devid & 0xff00 ? "" : "3", robo.devid, 
    403                 robo.is_5350 ? " It's a 5350." : "", devname); 
     396                robo.is_5365 ? " It's a BCM5365." : "", devname); 
    404397 
    405398        return 0; 
     
    427420        val16 = (nr) /* vlan */ | (0 << 12) /* read */ | (1 << 13) /* enable */; 
    428421 
    429         if (robo.is_5350) { 
     422        if (!robo.is_5365) { 
    430423                u32 val32; 
    431                 robo_write16(ROBO_VLAN_PAGE, ROBO_VLAN_TABLE_ACCESS_5350, val16); 
     424                robo_write16(ROBO_VLAN_PAGE, ROBO_VLAN_TABLE_ACCESS, val16); 
    432425                /* actual read */ 
    433426                val32 = robo_read32(ROBO_VLAN_PAGE, ROBO_VLAN_READ); 
     
    449442                } 
    450443        } else { 
    451                 robo_write16(ROBO_VLAN_PAGE, ROBO_VLAN_TABLE_ACCESS, val16); 
     444                robo_write16(ROBO_VLAN_PAGE, ROBO_VLAN_TABLE_ACCESS_5365, val16); 
    452445                /* actual read */ 
    453446                val16 = robo_read16(ROBO_VLAN_PAGE, ROBO_VLAN_READ); 
     
    505498 
    506499        val16 = (nr) /* vlan */ | (1 << 12) /* write */ | (1 << 13) /* enable */; 
    507         if (robo.is_5350) { 
    508                 robo_write32(ROBO_VLAN_PAGE, ROBO_VLAN_WRITE_5350, 
     500        if (robo.is_5365) { 
     501                robo_write16(ROBO_VLAN_PAGE, ROBO_VLAN_WRITE_5365, 
     502                        (1 << 14)  /* valid */ | (c->untag << 7) | c->port); 
     503                robo_write16(ROBO_VLAN_PAGE, ROBO_VLAN_TABLE_ACCESS_5365, val16); 
     504        } else { 
     505                robo_write32(ROBO_VLAN_PAGE, ROBO_VLAN_WRITE, 
    509506                        (1 << 20) /* valid */ | (c->untag << 6) | c->port); 
    510                 robo_write16(ROBO_VLAN_PAGE, ROBO_VLAN_TABLE_ACCESS_5350, val16); 
    511         } else { 
    512                 robo_write16(ROBO_VLAN_PAGE, ROBO_VLAN_WRITE, 
    513                         (1 << 14)  /* valid */ | (c->untag << 7) | c->port); 
    514507                robo_write16(ROBO_VLAN_PAGE, ROBO_VLAN_TABLE_ACCESS, val16); 
    515508        } 
     
    644637 
    645638        /* reset vlans */ 
    646         for (j = 0; j <= ((robo.is_5350) ? VLAN_ID_MAX5350 : VLAN_ID_MAX); j++) { 
     639        for (j = 0; j <= ((robo.is_5365) ? VLAN_ID_MAX_5365 : VLAN_ID_MAX); j++) { 
    647640                /* write config now */ 
    648641                val16 = (j) /* vlan */ | (1 << 12) /* write */ | (1 << 13) /* enable */; 
    649                 if (robo.is_5350) 
    650                         robo_write32(ROBO_VLAN_PAGE, ROBO_VLAN_WRITE_5350, 0); 
     642                if (robo.is_5365) 
     643                        robo_write16(ROBO_VLAN_PAGE, ROBO_VLAN_WRITE_5365, 0); 
    651644                else 
    652                         robo_write16(ROBO_VLAN_PAGE, ROBO_VLAN_WRITE, 0); 
    653                 robo_write16(ROBO_VLAN_PAGE, robo.is_5350 ? ROBO_VLAN_TABLE_ACCESS_5350 : 
     645                        robo_write32(ROBO_VLAN_PAGE, ROBO_VLAN_WRITE, 0); 
     646                robo_write16(ROBO_VLAN_PAGE, robo.is_5365 ? ROBO_VLAN_TABLE_ACCESS_5365 : 
    654647                                                            ROBO_VLAN_TABLE_ACCESS, 
    655648                             val16); 
Note: See TracChangeset for help on using the changeset viewer.