Lines Matching +full:sgmii +full:- +full:enable +full:- +full:pll
1 // SPDX-License-Identifier: GPL-2.0+
5 * (C) Copyright 2012-2014
20 #include <asm/ti-common/keystone_nav.h>
21 #include <asm/ti-common/keystone_net.h>
22 #include <asm/ti-common/keystone_serdes.h>
32 #define emac_gigabit_enable(x) /* no gigabit to enable */
108 * Check if link detected is giga-bit in keystone2_eth_gigabit_enable()
109 * If Gigabit mode detected, enable gigbit in MAC in keystone2_eth_gigabit_enable()
111 if (priv->has_mdio) { in keystone2_eth_gigabit_enable()
112 if (priv->phydev->speed != 1000) in keystone2_eth_gigabit_enable()
116 writel(readl(DEVICE_EMACSL_BASE(priv->slave_port - 1) + in keystone2_eth_gigabit_enable()
119 DEVICE_EMACSL_BASE(priv->slave_port - 1) + CPGMACSL_REG_CTL); in keystone2_eth_gigabit_enable()
131 phy_dev->link = 0; in keystone_rgmii_config()
137 phy_dev->link = 0; in keystone_rgmii_config()
138 return -EINTR; in keystone_rgmii_config()
195 * Wait for the SerDes pll to lock, in keystone_sgmii_config()
218 printf("\n%s Waiting for SGMII auto negotiation to complete", in keystone_sgmii_config()
219 phy_dev->dev->name); in keystone_sgmii_config()
226 phy_dev->link = 0; in keystone_sgmii_config()
232 phy_dev->link = 0; in keystone_sgmii_config()
233 return -EINTR; in keystone_sgmii_config()
279 if (cfg->max_rx_len > CPGMAC_REG_MAXLEN_LEN) { in mac_sl_config()
280 cfg->max_rx_len = CPGMAC_REG_MAXLEN_LEN; in mac_sl_config()
295 writel(cfg->max_rx_len, DEVICE_EMACSL_BASE(port) + CPGMACSL_REG_MAXLEN); in mac_sl_config()
296 writel(cfg->ctl, DEVICE_EMACSL_BASE(port) + CPGMACSL_REG_CTL); in mac_sl_config()
320 /* Reset and enable the ALE */ in ethss_config()
390 keystone_rgmii_config(priv->phydev); in ks2_eth_start()
392 keystone_sgmii_config(priv->phydev, priv->slave_port - 1, in ks2_eth_start()
393 priv->sgmii_link_type); in ks2_eth_start()
403 if (ksnav_init(priv->netcp_pktdma, &priv->net_rx_buffs)) { in ks2_eth_start()
415 if (priv->has_mdio) { in ks2_eth_start()
416 phy_startup(priv->phydev); in ks2_eth_start()
417 if (priv->phydev->link == 0) { in ks2_eth_start()
427 priv->emac_open = true; in ks2_eth_start()
432 ksnav_close(priv->netcp_pktdma); in ks2_eth_start()
436 return -EFAULT; in ks2_eth_start()
443 genphy_update_link(priv->phydev); in ks2_eth_send()
444 if (priv->phydev->link == 0) in ks2_eth_send()
445 return -1; in ks2_eth_send()
450 return ksnav_send(priv->netcp_pktdma, (u32 *)packet, in ks2_eth_send()
451 length, (priv->slave_port) << 16); in ks2_eth_send()
460 priv->hd = ksnav_recv(priv->netcp_pktdma, &pkt, &pkt_size); in ks2_eth_recv()
461 if (priv->hd == NULL) in ks2_eth_recv()
462 return -EAGAIN; in ks2_eth_recv()
474 ksnav_release_rxhd(priv->netcp_pktdma, priv->hd); in ks2_eth_free_pkt()
483 if (!priv->emac_open) in ks2_eth_stop()
487 ksnav_close(priv->netcp_pktdma); in ks2_eth_stop()
489 phy_shutdown(priv->phydev); in ks2_eth_stop()
490 priv->emac_open = false; in ks2_eth_stop()
500 /* Read the e-fuse mac address */ in ks2_eth_read_rom_hwaddr()
501 if (priv->slave_port == 1) { in ks2_eth_read_rom_hwaddr()
506 pdata->enetaddr[0] = (macb >> 8) & 0xff; in ks2_eth_read_rom_hwaddr()
507 pdata->enetaddr[1] = (macb >> 0) & 0xff; in ks2_eth_read_rom_hwaddr()
508 pdata->enetaddr[2] = (maca >> 24) & 0xff; in ks2_eth_read_rom_hwaddr()
509 pdata->enetaddr[3] = (maca >> 16) & 0xff; in ks2_eth_read_rom_hwaddr()
510 pdata->enetaddr[4] = (maca >> 8) & 0xff; in ks2_eth_read_rom_hwaddr()
511 pdata->enetaddr[5] = (maca >> 0) & 0xff; in ks2_eth_read_rom_hwaddr()
521 writel(mac_hi(pdata->enetaddr), in ks2_eth_write_hwaddr()
522 DEVICE_EMACSW_BASE(pdata->iobase, priv->slave_port - 1) + in ks2_eth_write_hwaddr()
524 writel(mac_lo(pdata->enetaddr), in ks2_eth_write_hwaddr()
525 DEVICE_EMACSW_BASE(pdata->iobase, priv->slave_port - 1) + in ks2_eth_write_hwaddr()
536 priv->dev = dev; in ks2_eth_probe()
537 priv->emac_open = false; in ks2_eth_probe()
543 /* By default, select PA PLL clock as PA clock source */ in ks2_eth_probe()
546 return -EACCES; in ks2_eth_probe()
549 return -EACCES; in ks2_eth_probe()
551 return -EACCES; in ks2_eth_probe()
556 priv->net_rx_buffs.buff_ptr = rx_buffs; in ks2_eth_probe()
557 priv->net_rx_buffs.num_buffs = RX_BUFF_NUMS; in ks2_eth_probe()
558 priv->net_rx_buffs.buff_len = RX_BUFF_LEN; in ks2_eth_probe()
560 if (priv->slave_port == 1) { in ks2_eth_probe()
566 * to re-use the same in ks2_eth_probe()
568 mdio_bus = cpsw_mdio_init("ethernet-mdio", in ks2_eth_probe()
569 (u32)priv->mdio_base, in ks2_eth_probe()
574 return -ENOMEM; in ks2_eth_probe()
576 priv->mdio_bus = mdio_bus; in ks2_eth_probe()
581 parent_priv = dev_get_priv(dev->parent); in ks2_eth_probe()
582 priv->mdio_bus = parent_priv->mdio_bus; in ks2_eth_probe()
583 priv->mdio_base = parent_priv->mdio_base; in ks2_eth_probe()
586 priv->netcp_pktdma = &netcp_pktdma; in ks2_eth_probe()
588 if (priv->has_mdio) { in ks2_eth_probe()
589 priv->phydev = phy_connect(priv->mdio_bus, priv->phy_addr, in ks2_eth_probe()
590 dev, priv->phy_if); in ks2_eth_probe()
591 phy_config(priv->phydev); in ks2_eth_probe()
601 cpsw_mdio_free(priv->mdio_bus); in ks2_eth_remove()
618 const void *fdt = gd->fdt_blob; in ks2_eth_bind_slaves()
630 slave_no = fdtdec_get_int(fdt, slave, "slave-port", -ENOENT); in ks2_eth_bind_slaves()
631 if (slave_no == -ENOENT) in ks2_eth_bind_slaves()
640 snprintf(slave_name, 20, "netcp@slave-%d", slave_no); in ks2_eth_bind_slaves()
645 pr_err("ks2_net - not able to bind slave interfaces\n"); in ks2_eth_bind_slaves()
651 sec_slave = fdt_subnode_offset(fdt, gbe, "secondary-slave-ports"); in ks2_eth_bind_slaves()
655 slave_no = fdtdec_get_int(fdt, slave, "slave-port", -ENOENT); in ks2_eth_bind_slaves()
656 if (slave_no == -ENOENT) in ks2_eth_bind_slaves()
661 snprintf(slave_name, 20, "netcp@slave-%d", slave_no); in ks2_eth_bind_slaves()
665 pr_err("ks2_net - not able to bind slave interfaces\n"); in ks2_eth_bind_slaves()
677 const void *fdt = gd->fdt_blob; in ks2_eth_parse_slave_interface()
683 priv->slave_port = fdtdec_get_int(fdt, slave, "slave-port", -1); in ks2_eth_parse_slave_interface()
684 priv->net_rx_buffs.rx_flow = priv->slave_port * 8; in ks2_eth_parse_slave_interface()
686 /* U-Boot slave port number starts with 1 instead of 0 */ in ks2_eth_parse_slave_interface()
687 priv->slave_port += 1; in ks2_eth_parse_slave_interface()
690 "ti,navigator-dmas", in ks2_eth_parse_slave_interface()
693 if (dma_count > (2 * priv->slave_port)) { in ks2_eth_parse_slave_interface()
696 dma_idx = priv->slave_port * 2 - 1; in ks2_eth_parse_slave_interface()
697 priv->net_rx_buffs.rx_flow = dma_channel[dma_idx]; in ks2_eth_parse_slave_interface()
700 priv->link_type = fdtdec_get_int(fdt, slave, "link-interface", -1); in ks2_eth_parse_slave_interface()
702 phy = fdtdec_lookup_phandle(fdt, slave, "phy-handle"); in ks2_eth_parse_slave_interface()
704 priv->phy_addr = fdtdec_get_int(fdt, phy, "reg", -1); in ks2_eth_parse_slave_interface()
709 return -ENODEV; in ks2_eth_parse_slave_interface()
711 priv->mdio_base = (void *)fdtdec_get_addr(fdt, mdio, "reg"); in ks2_eth_parse_slave_interface()
714 if (priv->link_type == LINK_TYPE_SGMII_MAC_TO_PHY_MODE) { in ks2_eth_parse_slave_interface()
715 priv->phy_if = PHY_INTERFACE_MODE_SGMII; in ks2_eth_parse_slave_interface()
716 pdata->phy_interface = priv->phy_if; in ks2_eth_parse_slave_interface()
717 priv->sgmii_link_type = SGMII_LINK_MAC_PHY; in ks2_eth_parse_slave_interface()
718 priv->has_mdio = true; in ks2_eth_parse_slave_interface()
719 } else if (priv->link_type == LINK_TYPE_RGMII_LINK_MAC_PHY) { in ks2_eth_parse_slave_interface()
720 priv->phy_if = PHY_INTERFACE_MODE_RGMII; in ks2_eth_parse_slave_interface()
721 pdata->phy_interface = priv->phy_if; in ks2_eth_parse_slave_interface()
722 priv->has_mdio = true; in ks2_eth_parse_slave_interface()
732 const void *fdt = gd->fdt_blob; in ks2_sl_eth_ofdata_to_platdata()
746 pdata->iobase = fdtdec_get_addr(fdt, netcp, "reg"); in ks2_sl_eth_ofdata_to_platdata()
755 const void *fdt = gd->fdt_blob; in ks2_eth_ofdata_to_platdata()
756 int gbe_0 = -ENODEV; in ks2_eth_ofdata_to_platdata()
761 "netcp-devices"); in ks2_eth_ofdata_to_platdata()
768 pdata->iobase = devfdt_get_addr(dev); in ks2_eth_ofdata_to_platdata()
774 { .compatible = "ti,netcp-1.0" },