Lines Matching defs:rdev
120 iowrite32(priv->rdev[i]->rx_queue->index,
417 struct rswitch_device *rdev = netdev_priv(ndev);
436 desc->info1 = cpu_to_le64(INFO1_SPN(rdev->etha->index));
560 struct rswitch_device *rdev = netdev_priv(ndev);
561 struct rswitch_private *priv = rdev->priv;
564 rdev->tx_queue = rswitch_gwca_get(priv);
565 if (!rdev->tx_queue)
568 err = rswitch_gwca_queue_alloc(ndev, priv, rdev->tx_queue, true, TX_RING_SIZE);
570 rswitch_gwca_put(priv, rdev->tx_queue);
579 struct rswitch_device *rdev = netdev_priv(ndev);
581 rswitch_gwca_queue_free(ndev, rdev->tx_queue);
582 rswitch_gwca_put(rdev->priv, rdev->tx_queue);
587 struct rswitch_device *rdev = priv->rdev[index];
589 return rswitch_gwca_queue_format(rdev->ndev, priv, rdev->tx_queue);
594 struct rswitch_device *rdev = netdev_priv(ndev);
595 struct rswitch_private *priv = rdev->priv;
598 rdev->rx_queue = rswitch_gwca_get(priv);
599 if (!rdev->rx_queue)
602 err = rswitch_gwca_queue_alloc(ndev, priv, rdev->rx_queue, false, RX_RING_SIZE);
604 rswitch_gwca_put(priv, rdev->rx_queue);
613 struct rswitch_device *rdev = netdev_priv(ndev);
615 rswitch_gwca_queue_free(ndev, rdev->rx_queue);
616 rswitch_gwca_put(rdev->priv, rdev->rx_queue);
621 struct rswitch_device *rdev = priv->rdev[index];
622 struct net_device *ndev = rdev->ndev;
624 return rswitch_gwca_queue_ext_ts_format(ndev, priv, rdev->rx_queue);
697 struct rswitch_device *rdev = netdev_priv(ndev);
698 struct rswitch_gwca_queue *gq = rdev->rx_queue;
720 get_ts = rdev->priv->ptp_priv->tstamp_rx_ctrl & RCAR_GEN4_RXTSTAMP_TYPE_V2_L2_EVENT;
733 napi_gro_receive(&rdev->napi, skb);
734 rdev->ndev->stats.rx_packets++;
735 rdev->ndev->stats.rx_bytes += pkt_len;
758 rswitch_gwca_halt(rdev->priv);
765 struct rswitch_device *rdev = netdev_priv(ndev);
766 struct rswitch_gwca_queue *gq = rdev->tx_queue;
791 rdev->ndev->stats.tx_packets++;
792 rdev->ndev->stats.tx_bytes += size;
802 struct rswitch_device *rdev;
806 rdev = netdev_priv(ndev);
807 priv = rdev->priv;
814 else if (rdev->priv->gwca_halt)
816 else if (rswitch_is_queue_rxed(rdev->rx_queue))
823 rswitch_enadis_data_irq(priv, rdev->tx_queue->index, true);
824 rswitch_enadis_data_irq(priv, rdev->rx_queue->index, true);
839 struct rswitch_device *rdev = netdev_priv(ndev);
841 if (napi_schedule_prep(&rdev->napi)) {
842 spin_lock(&rdev->priv->lock);
843 rswitch_enadis_data_irq(rdev->priv, rdev->tx_queue->index, false);
844 rswitch_enadis_data_irq(rdev->priv, rdev->rx_queue->index, false);
845 spin_unlock(&rdev->priv->lock);
846 __napi_schedule(&rdev->napi);
1141 static struct device_node *rswitch_get_port_node(struct rswitch_device *rdev)
1147 ports = of_get_child_by_name(rdev->ndev->dev.parent->of_node,
1158 if (index == rdev->etha->index) {
1171 static int rswitch_etha_get_params(struct rswitch_device *rdev)
1176 if (!rdev->np_port)
1179 err = of_get_phy_mode(rdev->np_port, &rdev->etha->phy_interface);
1183 err = of_property_read_u32(rdev->np_port, "max-speed", &max_speed);
1185 rdev->etha->speed = max_speed;
1190 switch (rdev->etha->phy_interface) {
1192 rdev->etha->speed = SPEED_100;
1195 rdev->etha->speed = SPEED_1000;
1198 rdev->etha->speed = SPEED_2500;
1207 static int rswitch_mii_register(struct rswitch_device *rdev)
1218 sprintf(mii_bus->id, "etha%d", rdev->etha->index);
1219 mii_bus->priv = rdev->etha;
1222 mii_bus->parent = &rdev->priv->pdev->dev;
1224 mdio_np = of_get_child_by_name(rdev->np_port, "mdio");
1231 rdev->etha->mii = mii_bus;
1239 static void rswitch_mii_unregister(struct rswitch_device *rdev)
1241 if (rdev->etha->mii) {
1242 mdiobus_unregister(rdev->etha->mii);
1243 mdiobus_free(rdev->etha->mii);
1244 rdev->etha->mii = NULL;
1250 struct rswitch_device *rdev = netdev_priv(ndev);
1253 if (phydev->link != rdev->etha->link) {
1256 phy_power_on(rdev->serdes);
1257 else if (rdev->serdes->power_count)
1258 phy_power_off(rdev->serdes);
1260 rdev->etha->link = phydev->link;
1262 if (!rdev->priv->etha_no_runtime_change &&
1263 phydev->speed != rdev->etha->speed) {
1264 rdev->etha->speed = phydev->speed;
1266 rswitch_etha_hw_init(rdev->etha, rdev->ndev->dev_addr);
1267 phy_set_speed(rdev->serdes, rdev->etha->speed);
1272 static void rswitch_phy_remove_link_mode(struct rswitch_device *rdev,
1275 if (!rdev->priv->etha_no_runtime_change)
1278 switch (rdev->etha->speed) {
1295 phy_set_max_speed(phydev, rdev->etha->speed);
1298 static int rswitch_phy_device_init(struct rswitch_device *rdev)
1304 if (!rdev->np_port)
1307 phy = of_parse_phandle(rdev->np_port, "phy-handle", 0);
1317 __set_bit(rdev->etha->phy_interface, phydev->host_interfaces);
1319 phydev = of_phy_connect(rdev->ndev, phy, rswitch_adjust_link, 0,
1320 rdev->etha->phy_interface);
1329 rswitch_phy_remove_link_mode(rdev, phydev);
1340 static void rswitch_phy_device_deinit(struct rswitch_device *rdev)
1342 if (rdev->ndev->phydev)
1343 phy_disconnect(rdev->ndev->phydev);
1346 static int rswitch_serdes_set_params(struct rswitch_device *rdev)
1350 err = phy_set_mode_ext(rdev->serdes, PHY_MODE_ETHERNET,
1351 rdev->etha->phy_interface);
1355 return phy_set_speed(rdev->serdes, rdev->etha->speed);
1358 static int rswitch_ether_port_init_one(struct rswitch_device *rdev)
1362 if (!rdev->etha->operated) {
1363 err = rswitch_etha_hw_init(rdev->etha, rdev->ndev->dev_addr);
1366 if (rdev->priv->etha_no_runtime_change)
1367 rdev->etha->operated = true;
1370 err = rswitch_mii_register(rdev);
1374 err = rswitch_phy_device_init(rdev);
1378 rdev->serdes = devm_of_phy_get(&rdev->priv->pdev->dev, rdev->np_port, NULL);
1379 if (IS_ERR(rdev->serdes)) {
1380 err = PTR_ERR(rdev->serdes);
1384 err = rswitch_serdes_set_params(rdev);
1392 rswitch_phy_device_deinit(rdev);
1395 rswitch_mii_unregister(rdev);
1400 static void rswitch_ether_port_deinit_one(struct rswitch_device *rdev)
1402 rswitch_phy_device_deinit(rdev);
1403 rswitch_mii_unregister(rdev);
1411 err = rswitch_ether_port_init_one(priv->rdev[i]);
1417 err = phy_init(priv->rdev[i]->serdes);
1426 phy_exit(priv->rdev[i]->serdes);
1431 rswitch_ether_port_deinit_one(priv->rdev[i]);
1441 phy_exit(priv->rdev[i]->serdes);
1442 rswitch_ether_port_deinit_one(priv->rdev[i]);
1448 struct rswitch_device *rdev = netdev_priv(ndev);
1453 napi_enable(&rdev->napi);
1456 spin_lock_irqsave(&rdev->priv->lock, flags);
1457 rswitch_enadis_data_irq(rdev->priv, rdev->tx_queue->index, true);
1458 rswitch_enadis_data_irq(rdev->priv, rdev->rx_queue->index, true);
1459 spin_unlock_irqrestore(&rdev->priv->lock, flags);
1461 if (bitmap_empty(rdev->priv->opened_ports, RSWITCH_NUM_PORTS))
1462 iowrite32(GWCA_TS_IRQ_BIT, rdev->priv->addr + GWTSDIE);
1464 bitmap_set(rdev->priv->opened_ports, rdev->port, 1);
1471 struct rswitch_device *rdev = netdev_priv(ndev);
1476 bitmap_clear(rdev->priv->opened_ports, rdev->port, 1);
1478 if (bitmap_empty(rdev->priv->opened_ports, RSWITCH_NUM_PORTS))
1479 iowrite32(GWCA_TS_IRQ_BIT, rdev->priv->addr + GWTSDID);
1481 list_for_each_entry_safe(ts_info, ts_info2, &rdev->priv->gwca.ts_info_list, list) {
1482 if (ts_info->port != rdev->port)
1489 spin_lock_irqsave(&rdev->priv->lock, flags);
1490 rswitch_enadis_data_irq(rdev->priv, rdev->tx_queue->index, false);
1491 rswitch_enadis_data_irq(rdev->priv, rdev->rx_queue->index, false);
1492 spin_unlock_irqrestore(&rdev->priv->lock, flags);
1495 napi_disable(&rdev->napi);
1502 struct rswitch_device *rdev = netdev_priv(ndev);
1503 struct rswitch_gwca_queue *gq = rdev->tx_queue;
1525 desc->info1 = cpu_to_le64(INFO1_DV(BIT(rdev->etha->index)) |
1535 rdev->ts_tag++;
1536 desc->info1 |= cpu_to_le64(INFO1_TSUN(rdev->ts_tag) | INFO1_TXC);
1539 ts_info->port = rdev->port;
1540 ts_info->tag = rdev->ts_tag;
1541 list_add_tail(&ts_info->list, &rdev->priv->gwca.ts_info_list);
1552 rswitch_modify(rdev->addr, GWTRC(gq->index), 0, BIT(gq->index % 32));
1572 struct rswitch_device *rdev = netdev_priv(ndev);
1576 ptp_priv = rdev->priv->ptp_priv;
1598 struct rswitch_device *rdev = netdev_priv(ndev);
1633 rdev->priv->ptp_priv->tstamp_tx_ctrl = tstamp_tx_ctrl;
1634 rdev->priv->ptp_priv->tstamp_rx_ctrl = tstamp_rx_ctrl;
1666 struct rswitch_device *rdev = netdev_priv(ndev);
1668 info->phc_index = ptp_clock_index(rdev->priv->ptp_priv->clock);
1712 struct rswitch_device *rdev;
1726 rdev = netdev_priv(ndev);
1727 rdev->ndev = ndev;
1728 rdev->priv = priv;
1729 priv->rdev[index] = rdev;
1730 rdev->port = index;
1731 rdev->etha = &priv->etha[index];
1732 rdev->addr = priv->addr;
1734 ndev->base_addr = (unsigned long)rdev->addr;
1739 netif_napi_add(ndev, &rdev->napi, rswitch_poll);
1741 rdev->np_port = rswitch_get_port_node(rdev);
1742 rdev->disabled = !rdev->np_port;
1743 err = of_get_ethdev_address(rdev->np_port, ndev);
1744 of_node_put(rdev->np_port);
1746 if (is_valid_ether_addr(rdev->etha->mac_addr))
1747 eth_hw_addr_set(ndev, rdev->etha->mac_addr);
1752 err = rswitch_etha_get_params(rdev);
1756 if (rdev->priv->gwca.speed < rdev->etha->speed)
1757 rdev->priv->gwca.speed = rdev->etha->speed;
1774 netif_napi_del(&rdev->napi);
1782 struct rswitch_device *rdev = priv->rdev[index];
1783 struct net_device *ndev = rdev->ndev;
1787 netif_napi_del(&rdev->napi);
1853 err = register_netdev(priv->rdev[i]->ndev);
1856 unregister_netdev(priv->rdev[i]->ndev);
1862 netdev_info(priv->rdev[i]->ndev, "MAC address %pM\n",
1863 priv->rdev[i]->ndev->dev_addr);
1972 struct rswitch_device *rdev = priv->rdev[i];
1974 unregister_netdev(rdev->ndev);
1975 rswitch_ether_port_deinit_one(rdev);
1976 phy_exit(priv->rdev[i]->serdes);