Lines Matching refs:fm_eth
47 static void dtsec_configure_serdes(struct fm_eth *priv) in dtsec_configure_serdes()
125 static void dtsec_init_phy(struct fm_eth *fm_eth) in dtsec_init_phy() argument
134 if (fm_eth->enet_if == PHY_INTERFACE_MODE_SGMII || in dtsec_init_phy()
135 fm_eth->enet_if == PHY_INTERFACE_MODE_QSGMII || in dtsec_init_phy()
136 fm_eth->enet_if == PHY_INTERFACE_MODE_SGMII_2500) in dtsec_init_phy()
137 dtsec_configure_serdes(fm_eth); in dtsec_init_phy()
142 static int tgec_is_fibre(struct fm_eth *fm) in tgec_is_fibre()
245 static int fm_eth_rx_port_parameter_init(struct fm_eth *fm_eth) in fm_eth_rx_port_parameter_init() argument
255 struct fm_bmi_rx_port *bmi_rx_port = fm_eth->rx_port; in fm_eth_rx_port_parameter_init()
259 pram = (struct fm_port_global_pram *)fm_muram_alloc(fm_eth->fm_index, in fm_eth_rx_port_parameter_init()
266 fm_eth->rx_pram = pram; in fm_eth_rx_port_parameter_init()
269 pram_page_offset = (void *)pram - fm_muram_base(fm_eth->fm_index); in fm_eth_rx_port_parameter_init()
298 fm_eth->rx_bd_ring = rx_bd_ring_base; in fm_eth_rx_port_parameter_init()
299 fm_eth->cur_rxbd = rx_bd_ring_base; in fm_eth_rx_port_parameter_init()
300 fm_eth->rx_buf = rx_buf_pool; in fm_eth_rx_port_parameter_init()
334 static int fm_eth_tx_port_parameter_init(struct fm_eth *fm_eth) in fm_eth_tx_port_parameter_init() argument
342 struct fm_bmi_tx_port *bmi_tx_port = fm_eth->tx_port; in fm_eth_tx_port_parameter_init()
346 pram = (struct fm_port_global_pram *)fm_muram_alloc(fm_eth->fm_index, in fm_eth_tx_port_parameter_init()
352 fm_eth->tx_pram = pram; in fm_eth_tx_port_parameter_init()
355 pram_page_offset = (void *)pram - fm_muram_base(fm_eth->fm_index); in fm_eth_tx_port_parameter_init()
372 fm_eth->tx_bd_ring = tx_bd_ring_base; in fm_eth_tx_port_parameter_init()
373 fm_eth->cur_txbd = tx_bd_ring_base; in fm_eth_tx_port_parameter_init()
402 static int fm_eth_init(struct fm_eth *fm_eth) in fm_eth_init() argument
406 ret = fm_eth_rx_port_parameter_init(fm_eth); in fm_eth_init()
410 ret = fm_eth_tx_port_parameter_init(fm_eth); in fm_eth_init()
417 static int fm_eth_startup(struct fm_eth *fm_eth) in fm_eth_startup() argument
422 mac = fm_eth->mac; in fm_eth_startup()
425 ret = fm_eth_init(fm_eth); in fm_eth_startup()
432 if (((fm_eth->enet_if == PHY_INTERFACE_MODE_SGMII) || in fm_eth_startup()
433 (fm_eth->enet_if == PHY_INTERFACE_MODE_SGMII_2500) || in fm_eth_startup()
434 (fm_eth->enet_if == PHY_INTERFACE_MODE_QSGMII)) && in fm_eth_startup()
436 mac->set_if_mode(mac, fm_eth->enet_if, SPEED_100); in fm_eth_startup()
439 bmi_rx_port_init(fm_eth->rx_port); in fm_eth_startup()
441 bmi_tx_port_init(fm_eth->tx_port); in fm_eth_startup()
446 static void fmc_tx_port_graceful_stop_enable(struct fm_eth *fm_eth) in fmc_tx_port_graceful_stop_enable() argument
450 pram = fm_eth->tx_pram; in fmc_tx_port_graceful_stop_enable()
456 static void fmc_tx_port_graceful_stop_disable(struct fm_eth *fm_eth) in fmc_tx_port_graceful_stop_disable() argument
460 pram = fm_eth->tx_pram; in fmc_tx_port_graceful_stop_disable()
473 struct fm_eth *fm_eth = dev->priv; in fm_eth_open() local
476 struct fm_eth *fm_eth = dev_get_priv(dev); in fm_eth_open()
484 mac = fm_eth->mac; in fm_eth_open()
496 enetaddr[5] = fm_eth->num; in fm_eth_open()
501 setbits_be32(&fm_eth->rx_port->fmbm_rcfg, FMBM_RCFG_EN); in fm_eth_open()
505 setbits_be32(&fm_eth->tx_port->fmbm_tcfg, FMBM_TCFG_EN); in fm_eth_open()
507 fmc_tx_port_graceful_stop_disable(fm_eth); in fm_eth_open()
510 if (fm_eth->phydev) { in fm_eth_open()
511 ret = phy_startup(fm_eth->phydev); in fm_eth_open()
515 fm_eth->phydev->dev->name); in fm_eth_open()
525 fm_eth->phydev->speed = SPEED_1000; in fm_eth_open()
526 fm_eth->phydev->link = 1; in fm_eth_open()
527 fm_eth->phydev->duplex = DUPLEX_FULL; in fm_eth_open()
531 mac->set_if_mode(mac, fm_eth->enet_if, fm_eth->phydev->speed); in fm_eth_open()
532 debug("MAC IF mode %d, speed %d, link %d\n", fm_eth->enet_if, in fm_eth_open()
533 fm_eth->phydev->speed, fm_eth->phydev->link); in fm_eth_open()
535 if (!fm_eth->phydev->link) in fm_eth_open()
536 printf("%s: No link.\n", fm_eth->phydev->dev->name); in fm_eth_open()
538 return fm_eth->phydev->link ? 0 : -1; in fm_eth_open()
547 struct fm_eth *fm_eth; in fm_eth_halt() local
551 fm_eth = (struct fm_eth *)dev->priv; in fm_eth_halt()
553 fm_eth = dev_get_priv(dev); in fm_eth_halt()
555 mac = fm_eth->mac; in fm_eth_halt()
558 fmc_tx_port_graceful_stop_enable(fm_eth); in fm_eth_halt()
560 bmi_tx_port_disable(fm_eth->tx_port); in fm_eth_halt()
564 bmi_rx_port_disable(fm_eth->rx_port); in fm_eth_halt()
567 if (fm_eth->phydev) in fm_eth_halt()
568 phy_shutdown(fm_eth->phydev); in fm_eth_halt()
578 struct fm_eth *fm_eth; in fm_eth_send() local
585 fm_eth = (struct fm_eth *)dev->priv; in fm_eth_send()
587 fm_eth = dev_get_priv(dev); in fm_eth_send()
589 pram = fm_eth->tx_pram; in fm_eth_send()
590 txbd = fm_eth->cur_txbd; in fm_eth_send()
629 txbd_base = (struct fm_port_bd *)fm_eth->tx_bd_ring; in fm_eth_send()
633 fm_eth->cur_txbd = (void *)txbd; in fm_eth_send()
638 static struct fm_port_bd *fm_eth_free_one(struct fm_eth *fm_eth, in fm_eth_free_one() argument
645 pram = fm_eth->rx_pram; in fm_eth_free_one()
654 rxbd_base = (struct fm_port_bd *)fm_eth->rx_bd_ring; in fm_eth_free_one()
675 struct fm_eth *fm_eth; in fm_eth_recv() local
683 fm_eth = (struct fm_eth *)dev->priv; in fm_eth_recv()
685 fm_eth = dev_get_priv(dev); in fm_eth_recv()
687 rxbd = fm_eth->cur_rxbd; in fm_eth_recv()
708 rxbd = fm_eth_free_one(fm_eth, rxbd); in fm_eth_recv()
713 fm_eth->cur_rxbd = (void *)rxbd; in fm_eth_recv()
721 struct fm_eth *fm_eth = (struct fm_eth *)dev_get_priv(dev); in fm_eth_free_pkt() local
723 fm_eth->cur_rxbd = fm_eth_free_one(fm_eth, fm_eth->cur_rxbd); in fm_eth_free_pkt()
730 static int fm_eth_init_mac(struct fm_eth *fm_eth, struct ccsr_fman *reg) in fm_eth_init_mac() argument
736 num = fm_eth->num; in fm_eth_init_mac()
740 if (fm_eth->type == FM_ETH_10G_E) { in fm_eth_init_mac()
746 if (fm_eth->num >= 2) in fm_eth_init_mac()
756 if (fm_eth->type == FM_ETH_1G_E) { in fm_eth_init_mac()
772 fm_eth->mac = mac; in fm_eth_init_mac()
777 if (fm_eth->type == FM_ETH_1G_E) in fm_eth_init_mac()
786 static int fm_eth_init_mac(struct fm_eth *fm_eth, void *reg) in fm_eth_init_mac() argument
792 fm_eth->mac = kzalloc(sizeof(*fm_eth->mac), GFP_KERNEL); in fm_eth_init_mac()
793 if (!fm_eth->mac) in fm_eth_init_mac()
797 mdio = fman_mdio(fm_eth->dev->parent, fm_eth->mac_type, fm_eth->num); in fm_eth_init_mac()
798 debug("MDIO %d @ %p\n", fm_eth->num, mdio); in fm_eth_init_mac()
801 switch (fm_eth->mac_type) { in fm_eth_init_mac()
804 init_memac(fm_eth->mac, reg, NULL, MAX_RXBUF_LEN); in fm_eth_init_mac()
808 init_dtsec(fm_eth->mac, reg, mdio, MAX_RXBUF_LEN); in fm_eth_init_mac()
811 init_tgec(fm_eth->mac, reg, mdio, MAX_RXBUF_LEN); in fm_eth_init_mac()
820 static int init_phy(struct fm_eth *fm_eth) in init_phy() argument
828 if (fm_eth->type == FM_ETH_10G_E) in init_phy()
830 if (fm_eth->enet_if == PHY_INTERFACE_MODE_SGMII_2500) in init_phy()
834 if (fm_eth->type == FM_ETH_1G_E) in init_phy()
835 dtsec_init_phy(fm_eth); in init_phy()
840 fm_eth->phydev = dm_eth_phy_connect(fm_eth->dev); in init_phy()
841 if (!fm_eth->phydev) in init_phy()
844 fm_eth->phydev->advertising &= supported; in init_phy()
845 fm_eth->phydev->supported &= supported; in init_phy()
847 phy_config(fm_eth->phydev); in init_phy()
851 if (fm_eth->bus) { in init_phy()
852 phydev = phy_connect(fm_eth->bus, fm_eth->phyaddr, fm_eth->dev, in init_phy()
853 fm_eth->enet_if); in init_phy()
862 if (fm_eth->type == FM_ETH_1G_E) { in init_phy()
871 if (tgec_is_fibre(fm_eth)) in init_phy()
878 fm_eth->phydev = phydev; in init_phy()
890 struct fm_eth *fm_eth; in fm_eth_initialize() local
901 fm_eth = (struct fm_eth *)malloc(sizeof(struct fm_eth)); in fm_eth_initialize()
902 if (!fm_eth) in fm_eth_initialize()
904 memset(fm_eth, 0, sizeof(struct fm_eth)); in fm_eth_initialize()
907 fm_eth->fm_index = info->index - 1; /* keep as 0 based for muram */ in fm_eth_initialize()
908 fm_eth->num = num; in fm_eth_initialize()
909 fm_eth->type = info->type; in fm_eth_initialize()
911 fm_eth->rx_port = (void *)®->port[info->rx_port_id - 1].fm_bmi; in fm_eth_initialize()
912 fm_eth->tx_port = (void *)®->port[info->tx_port_id - 1].fm_bmi; in fm_eth_initialize()
915 fm_eth->max_rx_len = MAX_RXBUF_LEN; in fm_eth_initialize()
918 ret = fm_eth_init_mac(fm_eth, reg); in fm_eth_initialize()
923 if (fm_eth->type == FM_ETH_1G_E) in fm_eth_initialize()
930 dev->priv = (void *)fm_eth; in fm_eth_initialize()
935 fm_eth->dev = dev; in fm_eth_initialize()
936 fm_eth->bus = info->bus; in fm_eth_initialize()
937 fm_eth->phyaddr = info->phy_addr; in fm_eth_initialize()
938 fm_eth->enet_if = info->enet_if; in fm_eth_initialize()
941 ret = fm_eth_startup(fm_eth); in fm_eth_initialize()
945 init_phy(fm_eth); in fm_eth_initialize()
1021 struct fm_eth *fm_eth = (struct fm_eth *)dev_get_priv(dev); in fm_eth_probe() local
1026 debug("%s enter for dev %p fm_eth %p - %s\n", __func__, dev, fm_eth, in fm_eth_probe()
1029 if (fm_eth->dev) { in fm_eth_probe()
1034 fm_eth->dev = dev; in fm_eth_probe()
1035 fm_eth->fm_index = fman_id(dev->parent); in fm_eth_probe()
1037 fm_eth->mac_type = dev_get_driver_data(dev); in fm_eth_probe()
1039 fm_eth->enet_if = fman_read_sys_if(dev); in fm_eth_probe()
1041 fm_eth->enet_if = PHY_INTERFACE_MODE_SGMII; in fm_eth_probe()
1044 switch (fm_eth->mac_type) { in fm_eth_probe()
1047 fm_eth->type = FM_ETH_10G_E; in fm_eth_probe()
1054 fm_eth->type = FM_ETH_1G_E; in fm_eth_probe()
1058 if (dev_read_u32(dev, "cell-index", &fm_eth->num)) { in fm_eth_probe()
1069 fm_eth->rx_port = fman_port(dev->parent, index); in fm_eth_probe()
1072 fm_eth->type = FM_ETH_10G_E; in fm_eth_probe()
1080 fm_eth->tx_port = fman_port(dev->parent, index); in fm_eth_probe()
1083 fm_eth->max_rx_len = MAX_RXBUF_LEN; in fm_eth_probe()
1085 switch (fm_eth->enet_if) { in fm_eth_probe()
1088 if (fm_eth->num != 0) in fm_eth_probe()
1092 fm_eth->pcs_mdio = fm_get_internal_mdio(dev); in fm_eth_probe()
1099 ret = fm_eth_init_mac(fm_eth, reg); in fm_eth_probe()
1104 ret = fm_eth_startup(fm_eth); in fm_eth_probe()
1107 ret = init_phy(fm_eth); in fm_eth_probe()
1147 .priv_auto = sizeof(struct fm_eth),