static int robo_probe(char *devname) { struct ethtool_drvinfo info; int i; __u32 phyid; printk("Probing device %s: ", devname); strcpy(ifr.ifr_name, devname); if ((dev = dev_get_by_name(devname)) == NULL) { printk("No such device\n"); return 1; } info.cmd = ETHTOOL_GDRVINFO; if (do_ioctl(SIOCETHTOOL, (void *) &info) < 0) { printk("SIOCETHTOOL: not supported\n"); return 1; } /* try access using MII ioctls - get phy address */ if (do_ioctl(SIOCGMIIPHY, NULL) < 0) { use_et = 1; } else { /* got phy address check for robo address */ struct mii_ioctl_data *mii = (struct mii_ioctl_data *) &ifr.ifr_data; if (mii->phy_id != ROBO_PHY_ADDR) { printk("Invalid phy address (%d)\n", mii->phy_id); return 1; } } phyid = mdio_read(ROBO_PHY_ADDR, 0x2) | (mdio_read(ROBO_PHY_ADDR, 0x3) << 16); if (phyid == 0xffffffff || phyid == 0x55210022) { printk("No Robo switch in managed mode found\n"); return 1; } is_5350 = robo_vlan5350(); printk("found!\n"); return 0; }
static int robo_probe(char *devname) { __u32 phyid; unsigned int i; int err = 1; printk(KERN_INFO PFX "Probing device %s: ", devname); strcpy(robo.ifr.ifr_name, devname); #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24) if ((robo.dev = dev_get_by_name(devname)) == NULL) { #else if ((robo.dev = dev_get_by_name(&init_net, devname)) == NULL) { #endif printk("No such device\n"); return 1; } robo.device = devname; for (i = 0; i < 5; i++) robo.port[i] = i; robo.port[5] = 8; /* try access using MII ioctls - get phy address */ if (do_ioctl(SIOCGMIIPHY, NULL) < 0) { robo.use_et = 1; robo.phy_addr = ROBO_PHY_ADDR; } else { /* got phy address check for robo address */ struct mii_ioctl_data *mii = (struct mii_ioctl_data *) &robo.ifr.ifr_data; if ((mii->phy_id != ROBO_PHY_ADDR) && (mii->phy_id != ROBO_PHY_ADDR_BCM63XX) && (mii->phy_id != ROBO_PHY_ADDR_TG3)) { printk("Invalid phy address (%d)\n", mii->phy_id); goto done; } robo.use_et = 0; /* The robo has a fixed PHY address that is different from the * Tigon3 and BCM63xx PHY address. */ robo.phy_addr = ROBO_PHY_ADDR; } phyid = mdio_read(robo.phy_addr, 0x2) | (mdio_read(robo.phy_addr, 0x3) << 16); if (phyid == 0xffffffff || phyid == 0x55210022) { printk("No Robo switch in managed mode found, phy_id = 0x%08x\n", phyid); goto done; } /* Get the device ID */ for (i = 0; i < 10; i++) { robo.devid = robo_read16(ROBO_MGMT_PAGE, ROBO_DEVICE_ID); if (robo.devid) break; udelay(10); } if (!robo.devid) robo.devid = ROBO_DEVICE_ID_5325; /* Fake it */ robo.is_5350 = robo_vlan5350(); robo_switch_reset(); err = robo_switch_enable(); if (err) goto done; err = 0; printk("found a 5%s%x!%s\n", robo.devid & 0xff00 ? "" : "3", robo.devid, robo.is_5350 ? " It's a 5350." : ""); done: if (err) { dev_put(robo.dev); robo.dev = NULL; } return err; } static int handle_vlan_port_read(void *driver, char *buf, int nr) { __u16 val16; int len = 0; int j; val16 = (nr) /* vlan */ | (0 << 12) /* read */ | (1 << 13) /* enable */; if (robo.is_5350) { u32 val32; robo_write16(ROBO_VLAN_PAGE, ROBO_VLAN_TABLE_ACCESS_5350, val16); /* actual read */ val32 = robo_read32(ROBO_VLAN_PAGE, ROBO_VLAN_READ); if ((val32 & (1 << 20)) /* valid */) { for (j = 0; j < 6; j++) { if (val32 & (1 << j)) { len += sprintf(buf + len, "%d", j); if (val32 & (1 << (j + 6))) { if (j == 5) buf[len++] = 'u'; } else { buf[len++] = 't'; if (robo_read16(ROBO_VLAN_PAGE, ROBO_VLAN_PORT0_DEF_TAG + (j << 1)) == nr) buf[len++] = '*'; } buf[len++] = '\t'; } } len += sprintf(buf + len, "\n"); } } else { robo_write16(ROBO_VLAN_PAGE, ROBO_VLAN_TABLE_ACCESS, val16); /* actual read */ val16 = robo_read16(ROBO_VLAN_PAGE, ROBO_VLAN_READ); if ((val16 & (1 << 14)) /* valid */) { for (j = 0; j < 6; j++) { if (val16 & (1 << j)) { len += sprintf(buf + len, "%d", j); if (val16 & (1 << (j + 7))) { if (j == 5) buf[len++] = 'u'; } else { buf[len++] = 't'; if (robo_read16(ROBO_VLAN_PAGE, ROBO_VLAN_PORT0_DEF_TAG + (j << 1)) == nr) buf[len++] = '*'; } buf[len++] = '\t'; } } len += sprintf(buf + len, "\n"); } } buf[len] = '\0'; return len; }
static int robo_probe(char *devname) { struct ethtool_drvinfo info; int i; __u32 phyid; printk("Probing device %s: ", devname); strcpy(ifr.ifr_name, devname); if ((dev = dev_get_by_name(devname)) == NULL) { printk("No such device\n"); return 1; } info.cmd = ETHTOOL_GDRVINFO; if (do_ioctl(SIOCETHTOOL, (void *) &info) < 0) { printk("SIOCETHTOOL: not supported\n"); return 1; } /* try access using MII ioctls - get phy address */ if (do_ioctl(SIOCGMIIPHY, NULL) < 0) { use_et = 1; } else { /* got phy address check for robo address */ struct mii_ioctl_data *mii = (struct mii_ioctl_data *) &ifr.ifr_data; if (mii->phy_id != ROBO_PHY_ADDR) { printk("Invalid phy address (%d)\n", mii->phy_id); return 1; } } phyid = mdio_read(ROBO_PHY_ADDR, 0x2) | (mdio_read(ROBO_PHY_ADDR, 0x3) << 16); if (phyid == 0xffffffff || phyid == 0x55210022) { printk("No Robo switch in managed mode found\n"); return 1; } is_5350 = robo_vlan5350(); max_ports = 6; for (i = 0; i <= (is_5350 ? VLAN_ID_MAX5350 : VLAN_ID_MAX); i++) { /* issue read */ __u16 val16 = (i) /* vlan */ | (0 << 12) /* read */ | (1 << 13) /* enable */; if (is_5350) { u32 val32; robo_write16(ROBO_VLAN_PAGE, ROBO_VLAN_TABLE_ACCESS_5350, val16); /* actual read */ val32 = robo_read32(ROBO_VLAN_PAGE, ROBO_VLAN_READ); if ((val32 & (1 << 20)) /* valid */) { max_vlans = i + 1; } } else { robo_write16(ROBO_VLAN_PAGE, ROBO_VLAN_TABLE_ACCESS, val16); /* actual read */ val16 = robo_read16(ROBO_VLAN_PAGE, ROBO_VLAN_READ); if ((val16 & (1 << 14)) /* valid */) { max_vlans = i + 1; } } } printk("found!\n"); return 0; }