Lines Matching refs:vsc

375 static int vsc73xx_read(struct vsc73xx *vsc, u8 block, u8 subblock, u8 reg,  in vsc73xx_read()  argument
378 return vsc->ops->read(vsc, block, subblock, reg, val); in vsc73xx_read()
381 static int vsc73xx_write(struct vsc73xx *vsc, u8 block, u8 subblock, u8 reg, in vsc73xx_write() argument
384 return vsc->ops->write(vsc, block, subblock, reg, val); in vsc73xx_write()
387 static int vsc73xx_update_bits(struct vsc73xx *vsc, u8 block, u8 subblock, in vsc73xx_update_bits() argument
394 ret = vsc73xx_read(vsc, block, subblock, reg, &orig); in vsc73xx_update_bits()
399 return vsc73xx_write(vsc, block, subblock, reg, tmp); in vsc73xx_update_bits()
402 static int vsc73xx_detect(struct vsc73xx *vsc) in vsc73xx_detect() argument
411 ret = vsc73xx_read(vsc, VSC73XX_BLOCK_SYSTEM, 0, in vsc73xx_detect()
414 dev_err(vsc->dev, "unable to read mailbox (%d)\n", ret); in vsc73xx_detect()
419 dev_info(vsc->dev, "chip seems dead.\n"); in vsc73xx_detect()
423 ret = vsc73xx_read(vsc, VSC73XX_BLOCK_SYSTEM, 0, in vsc73xx_detect()
426 dev_err(vsc->dev, "unable to read chip id (%d)\n", ret); in vsc73xx_detect()
439 dev_err(vsc->dev, "unsupported chip, id=%04x\n", id); in vsc73xx_detect()
443 vsc->chipid = id; in vsc73xx_detect()
446 dev_info(vsc->dev, "VSC%04X (rev: %d) switch found\n", id, rev); in vsc73xx_detect()
448 ret = vsc73xx_read(vsc, VSC73XX_BLOCK_SYSTEM, 0, in vsc73xx_detect()
451 dev_err(vsc->dev, "unable to read iCPU control\n"); in vsc73xx_detect()
464 dev_err(vsc->dev, in vsc73xx_detect()
466 dev_err(vsc->dev, "no idea how to deal with this\n"); in vsc73xx_detect()
470 dev_err(vsc->dev, in vsc73xx_detect()
475 dev_err(vsc->dev, in vsc73xx_detect()
477 dev_err(vsc->dev, "no idea how to deal with this\n"); in vsc73xx_detect()
481 dev_info(vsc->dev, "iCPU disabled, no external memory\n"); in vsc73xx_detect()
488 struct vsc73xx *vsc = ds->priv; in vsc73xx_phy_read() local
495 ret = vsc73xx_write(vsc, VSC73XX_BLOCK_MII, 0, 1, cmd); in vsc73xx_phy_read()
499 ret = vsc73xx_read(vsc, VSC73XX_BLOCK_MII, 0, 2, &val); in vsc73xx_phy_read()
503 dev_err(vsc->dev, "reading reg %02x from phy%d failed\n", in vsc73xx_phy_read()
509 dev_dbg(vsc->dev, "read reg %02x from phy%d = %04x\n", in vsc73xx_phy_read()
518 struct vsc73xx *vsc = ds->priv; in vsc73xx_phy_write() local
529 dev_info(vsc->dev, "reset PHY - disallowed\n"); in vsc73xx_phy_write()
534 ret = vsc73xx_write(vsc, VSC73XX_BLOCK_MII, 0, 1, cmd); in vsc73xx_phy_write()
538 dev_dbg(vsc->dev, "write %04x to reg %02x in phy%d\n", in vsc73xx_phy_write()
561 struct vsc73xx *vsc = ds->priv; in vsc73xx_setup() local
564 dev_info(vsc->dev, "set up the switch\n"); in vsc73xx_setup()
567 vsc73xx_write(vsc, VSC73XX_BLOCK_SYSTEM, 0, VSC73XX_GLORESET, in vsc73xx_setup()
580 vsc73xx_write(vsc, VSC73XX_BLOCK_MEMINIT, in vsc73xx_setup()
589 vsc73xx_write(vsc, VSC73XX_BLOCK_ANALYZER, 0, in vsc73xx_setup()
594 vsc73xx_write(vsc, VSC73XX_BLOCK_ANALYZER, 0, in vsc73xx_setup()
605 if (IS_739X(vsc)) in vsc73xx_setup()
606 vsc73xx_write(vsc, VSC73XX_BLOCK_MAC, 0x1f, in vsc73xx_setup()
614 vsc73xx_write(vsc, VSC73XX_BLOCK_MAC, 4, in vsc73xx_setup()
619 vsc73xx_write(vsc, VSC73XX_BLOCK_SYSTEM, 0, VSC73XX_GMIIDELAY, in vsc73xx_setup()
623 vsc73xx_write(vsc, VSC73XX_BLOCK_ANALYZER, 0, VSC73XX_RECVMASK, in vsc73xx_setup()
626 vsc73xx_write(vsc, VSC73XX_BLOCK_ANALYZER, 0, VSC73XX_IFLODMSK, in vsc73xx_setup()
632 vsc73xx_write(vsc, VSC73XX_BLOCK_SYSTEM, 0, VSC73XX_GLORESET, in vsc73xx_setup()
640 static void vsc73xx_init_port(struct vsc73xx *vsc, int port) in vsc73xx_init_port() argument
645 vsc73xx_write(vsc, VSC73XX_BLOCK_MAC, in vsc73xx_init_port()
659 vsc73xx_write(vsc, VSC73XX_BLOCK_MAC, in vsc73xx_init_port()
670 vsc73xx_write(vsc, VSC73XX_BLOCK_MAC, in vsc73xx_init_port()
686 vsc73xx_write(vsc, VSC73XX_BLOCK_MAC, in vsc73xx_init_port()
692 val = (vsc->addr[5] << 16) | (vsc->addr[4] << 8) | (vsc->addr[3]); in vsc73xx_init_port()
693 vsc73xx_write(vsc, VSC73XX_BLOCK_MAC, in vsc73xx_init_port()
697 val = (vsc->addr[2] << 16) | (vsc->addr[1] << 8) | (vsc->addr[0]); in vsc73xx_init_port()
698 vsc73xx_write(vsc, VSC73XX_BLOCK_MAC, in vsc73xx_init_port()
706 vsc73xx_write(vsc, VSC73XX_BLOCK_MAC, in vsc73xx_init_port()
712 vsc73xx_write(vsc, VSC73XX_BLOCK_MAC, in vsc73xx_init_port()
716 static void vsc73xx_adjust_enable_port(struct vsc73xx *vsc, in vsc73xx_adjust_enable_port() argument
725 vsc73xx_write(vsc, VSC73XX_BLOCK_MAC, port, VSC73XX_MAC_CFG, val); in vsc73xx_adjust_enable_port()
732 vsc73xx_write(vsc, VSC73XX_BLOCK_MAC, port, VSC73XX_MAC_CFG, val); in vsc73xx_adjust_enable_port()
739 vsc73xx_write(vsc, VSC73XX_BLOCK_MAC, port, VSC73XX_FCCONF, in vsc73xx_adjust_enable_port()
745 vsc73xx_update_bits(vsc, VSC73XX_BLOCK_ARBITER, 0, in vsc73xx_adjust_enable_port()
749 vsc73xx_update_bits(vsc, VSC73XX_BLOCK_MAC, port, in vsc73xx_adjust_enable_port()
759 struct vsc73xx *vsc = ds->priv; in vsc73xx_adjust_link() local
765 vsc73xx_init_port(vsc, CPU_PORT); in vsc73xx_adjust_link()
770 vsc73xx_write(vsc, VSC73XX_BLOCK_MAC, in vsc73xx_adjust_link()
784 dev_dbg(vsc->dev, "port %d: went down\n", in vsc73xx_adjust_link()
788 vsc73xx_update_bits(vsc, VSC73XX_BLOCK_MAC, port, in vsc73xx_adjust_link()
793 vsc73xx_update_bits(vsc, VSC73XX_BLOCK_ARBITER, 0, in vsc73xx_adjust_link()
797 vsc73xx_read(vsc, VSC73XX_BLOCK_ARBITER, 0, in vsc73xx_adjust_link()
801 vsc73xx_read(vsc, VSC73XX_BLOCK_ARBITER, 0, in vsc73xx_adjust_link()
804 dev_err(vsc->dev, in vsc73xx_adjust_link()
812 vsc73xx_write(vsc, VSC73XX_BLOCK_MAC, port, VSC73XX_MAC_CFG, in vsc73xx_adjust_link()
816 vsc73xx_update_bits(vsc, VSC73XX_BLOCK_ARBITER, 0, in vsc73xx_adjust_link()
820 vsc73xx_update_bits(vsc, VSC73XX_BLOCK_ARBITER, 0, in vsc73xx_adjust_link()
824 vsc73xx_update_bits(vsc, VSC73XX_BLOCK_ANALYZER, 0, in vsc73xx_adjust_link()
832 dev_dbg(vsc->dev, "port %d: 1000 Mbit mode full duplex\n", in vsc73xx_adjust_link()
840 vsc73xx_adjust_enable_port(vsc, port, phydev, val); in vsc73xx_adjust_link()
844 dev_dbg(vsc->dev, in vsc73xx_adjust_link()
849 dev_dbg(vsc->dev, in vsc73xx_adjust_link()
853 vsc73xx_adjust_enable_port(vsc, port, phydev, val); in vsc73xx_adjust_link()
857 dev_dbg(vsc->dev, in vsc73xx_adjust_link()
862 dev_dbg(vsc->dev, in vsc73xx_adjust_link()
866 vsc73xx_adjust_enable_port(vsc, port, phydev, val); in vsc73xx_adjust_link()
868 dev_err(vsc->dev, in vsc73xx_adjust_link()
873 vsc73xx_update_bits(vsc, VSC73XX_BLOCK_ANALYZER, 0, in vsc73xx_adjust_link()
880 struct vsc73xx *vsc = ds->priv; in vsc73xx_port_enable() local
882 dev_info(vsc->dev, "enable port %d\n", port); in vsc73xx_port_enable()
883 vsc73xx_init_port(vsc, port); in vsc73xx_port_enable()
890 struct vsc73xx *vsc = ds->priv; in vsc73xx_port_disable() local
893 vsc73xx_write(vsc, VSC73XX_BLOCK_MAC, port, in vsc73xx_port_disable()
898 vsc73xx_find_counter(struct vsc73xx *vsc, in vsc73xx_find_counter() argument
929 struct vsc73xx *vsc = ds->priv; in vsc73xx_get_strings() local
938 ret = vsc73xx_read(vsc, VSC73XX_BLOCK_MAC, port, in vsc73xx_get_strings()
963 cnt = vsc73xx_find_counter(vsc, indices[i], false); in vsc73xx_get_strings()
976 cnt = vsc73xx_find_counter(vsc, indices[i], true); in vsc73xx_get_strings()
996 struct vsc73xx *vsc = ds->priv; in vsc73xx_get_ethtool_stats() local
1012 ret = vsc73xx_read(vsc, VSC73XX_BLOCK_MAC, port, in vsc73xx_get_ethtool_stats()
1015 dev_err(vsc->dev, "error reading counter %d\n", i); in vsc73xx_get_ethtool_stats()
1024 struct vsc73xx *vsc = ds->priv; in vsc73xx_change_mtu() local
1026 return vsc73xx_write(vsc, VSC73XX_BLOCK_MAC, port, in vsc73xx_change_mtu()
1057 struct vsc73xx *vsc = gpiochip_get_data(chip); in vsc73xx_gpio_get() local
1061 ret = vsc73xx_read(vsc, VSC73XX_BLOCK_SYSTEM, 0, in vsc73xx_gpio_get()
1072 struct vsc73xx *vsc = gpiochip_get_data(chip); in vsc73xx_gpio_set() local
1075 vsc73xx_update_bits(vsc, VSC73XX_BLOCK_SYSTEM, 0, in vsc73xx_gpio_set()
1082 struct vsc73xx *vsc = gpiochip_get_data(chip); in vsc73xx_gpio_direction_output() local
1085 return vsc73xx_update_bits(vsc, VSC73XX_BLOCK_SYSTEM, 0, in vsc73xx_gpio_direction_output()
1093 struct vsc73xx *vsc = gpiochip_get_data(chip); in vsc73xx_gpio_direction_input() local
1095 return vsc73xx_update_bits(vsc, VSC73XX_BLOCK_SYSTEM, 0, in vsc73xx_gpio_direction_input()
1103 struct vsc73xx *vsc = gpiochip_get_data(chip); in vsc73xx_gpio_get_direction() local
1107 ret = vsc73xx_read(vsc, VSC73XX_BLOCK_SYSTEM, 0, in vsc73xx_gpio_get_direction()
1115 static int vsc73xx_gpio_probe(struct vsc73xx *vsc) in vsc73xx_gpio_probe() argument
1119 vsc->gc.label = devm_kasprintf(vsc->dev, GFP_KERNEL, "VSC%04x", in vsc73xx_gpio_probe()
1120 vsc->chipid); in vsc73xx_gpio_probe()
1121 if (!vsc->gc.label) in vsc73xx_gpio_probe()
1123 vsc->gc.ngpio = 4; in vsc73xx_gpio_probe()
1124 vsc->gc.owner = THIS_MODULE; in vsc73xx_gpio_probe()
1125 vsc->gc.parent = vsc->dev; in vsc73xx_gpio_probe()
1126 vsc->gc.base = -1; in vsc73xx_gpio_probe()
1127 vsc->gc.get = vsc73xx_gpio_get; in vsc73xx_gpio_probe()
1128 vsc->gc.set = vsc73xx_gpio_set; in vsc73xx_gpio_probe()
1129 vsc->gc.direction_input = vsc73xx_gpio_direction_input; in vsc73xx_gpio_probe()
1130 vsc->gc.direction_output = vsc73xx_gpio_direction_output; in vsc73xx_gpio_probe()
1131 vsc->gc.get_direction = vsc73xx_gpio_get_direction; in vsc73xx_gpio_probe()
1132 vsc->gc.can_sleep = true; in vsc73xx_gpio_probe()
1133 ret = devm_gpiochip_add_data(vsc->dev, &vsc->gc, vsc); in vsc73xx_gpio_probe()
1135 dev_err(vsc->dev, "unable to register GPIO chip\n"); in vsc73xx_gpio_probe()
1141 int vsc73xx_probe(struct vsc73xx *vsc) in vsc73xx_probe() argument
1143 struct device *dev = vsc->dev; in vsc73xx_probe()
1147 vsc->reset = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_LOW); in vsc73xx_probe()
1148 if (IS_ERR(vsc->reset)) { in vsc73xx_probe()
1150 return PTR_ERR(vsc->reset); in vsc73xx_probe()
1152 if (vsc->reset) in vsc73xx_probe()
1156 ret = vsc73xx_detect(vsc); in vsc73xx_probe()
1158 dev_err(vsc->dev, in vsc73xx_probe()
1160 gpiod_set_value_cansleep(vsc->reset, 1); in vsc73xx_probe()
1165 gpiod_set_value_cansleep(vsc->reset, 0); in vsc73xx_probe()
1168 ret = vsc73xx_detect(vsc); in vsc73xx_probe()
1175 eth_random_addr(vsc->addr); in vsc73xx_probe()
1176 dev_info(vsc->dev, in vsc73xx_probe()
1178 vsc->addr[0], vsc->addr[1], vsc->addr[2], in vsc73xx_probe()
1179 vsc->addr[3], vsc->addr[4], vsc->addr[5]); in vsc73xx_probe()
1192 vsc->ds = devm_kzalloc(dev, sizeof(*vsc->ds), GFP_KERNEL); in vsc73xx_probe()
1193 if (!vsc->ds) in vsc73xx_probe()
1196 vsc->ds->dev = dev; in vsc73xx_probe()
1197 vsc->ds->num_ports = 8; in vsc73xx_probe()
1198 vsc->ds->priv = vsc; in vsc73xx_probe()
1200 vsc->ds->ops = &vsc73xx_ds_ops; in vsc73xx_probe()
1201 ret = dsa_register_switch(vsc->ds); in vsc73xx_probe()
1207 ret = vsc73xx_gpio_probe(vsc); in vsc73xx_probe()
1209 dsa_unregister_switch(vsc->ds); in vsc73xx_probe()
1217 void vsc73xx_remove(struct vsc73xx *vsc) in vsc73xx_remove() argument
1219 dsa_unregister_switch(vsc->ds); in vsc73xx_remove()
1220 gpiod_set_value(vsc->reset, 1); in vsc73xx_remove()
1224 void vsc73xx_shutdown(struct vsc73xx *vsc) in vsc73xx_shutdown() argument
1226 dsa_switch_shutdown(vsc->ds); in vsc73xx_shutdown()