Lines Matching refs:memac

488 static void setup_sgmii_internal_phy(struct fman_mac *memac,  in setup_sgmii_internal_phy()  argument
493 if (WARN_ON(!memac->pcsphy)) in setup_sgmii_internal_phy()
517 phy_write(memac->pcsphy, MDIO_SGMII_IF_MODE, tmp_reg16); in setup_sgmii_internal_phy()
521 phy_write(memac->pcsphy, MDIO_SGMII_DEV_ABIL_SGMII, tmp_reg16); in setup_sgmii_internal_phy()
535 phy_write(memac->pcsphy, MDIO_SGMII_LINK_TMR_H, LINK_TMR_H); in setup_sgmii_internal_phy()
536 phy_write(memac->pcsphy, MDIO_SGMII_LINK_TMR_L, LINK_TMR_L); in setup_sgmii_internal_phy()
544 phy_write(memac->pcsphy, 0x0, tmp_reg16); in setup_sgmii_internal_phy()
547 static void setup_sgmii_internal_phy_base_x(struct fman_mac *memac) in setup_sgmii_internal_phy_base_x() argument
553 phy_write(memac->pcsphy, MDIO_SGMII_DEV_ABIL_SGMII, tmp_reg16); in setup_sgmii_internal_phy_base_x()
567 phy_write(memac->pcsphy, MDIO_SGMII_LINK_TMR_H, LINK_TMR_H_BASEX); in setup_sgmii_internal_phy_base_x()
568 phy_write(memac->pcsphy, MDIO_SGMII_LINK_TMR_L, LINK_TMR_L_BASEX); in setup_sgmii_internal_phy_base_x()
572 phy_write(memac->pcsphy, 0x0, tmp_reg16); in setup_sgmii_internal_phy_base_x()
575 static int check_init_parameters(struct fman_mac *memac) in check_init_parameters() argument
577 if (!memac->exception_cb) { in check_init_parameters()
581 if (!memac->event_cb) { in check_init_parameters()
616 struct fman_mac *memac = (struct fman_mac *)handle; in memac_err_exception() local
617 struct memac_regs __iomem *regs = memac->regs; in memac_err_exception()
633 memac->exception_cb(memac->dev_id, FM_MAC_EX_TS_FIFO_ECC_ERR); in memac_err_exception()
635 memac->exception_cb(memac->dev_id, FM_MAC_EX_10G_TX_ECC_ER); in memac_err_exception()
637 memac->exception_cb(memac->dev_id, FM_MAC_EX_10G_RX_ECC_ER); in memac_err_exception()
642 struct fman_mac *memac = (struct fman_mac *)handle; in memac_exception() local
643 struct memac_regs __iomem *regs = memac->regs; in memac_exception()
659 memac->exception_cb(memac->dev_id, in memac_exception()
663 static void free_init_resources(struct fman_mac *memac) in free_init_resources() argument
665 fman_unregister_intr(memac->fm, FMAN_MOD_MAC, memac->mac_id, in free_init_resources()
668 fman_unregister_intr(memac->fm, FMAN_MOD_MAC, memac->mac_id, in free_init_resources()
672 free_hash_table(memac->multicast_addr_hash); in free_init_resources()
673 memac->multicast_addr_hash = NULL; in free_init_resources()
676 free_hash_table(memac->unicast_addr_hash); in free_init_resources()
677 memac->unicast_addr_hash = NULL; in free_init_resources()
689 static int memac_enable(struct fman_mac *memac) in memac_enable() argument
691 struct memac_regs __iomem *regs = memac->regs; in memac_enable()
694 if (!is_init_done(memac->memac_drv_param)) in memac_enable()
704 static void memac_disable(struct fman_mac *memac) in memac_disable() argument
707 struct memac_regs __iomem *regs = memac->regs; in memac_disable()
710 WARN_ON_ONCE(!is_init_done(memac->memac_drv_param)); in memac_disable()
717 static int memac_set_promiscuous(struct fman_mac *memac, bool new_val) in memac_set_promiscuous() argument
719 struct memac_regs __iomem *regs = memac->regs; in memac_set_promiscuous()
722 if (!is_init_done(memac->memac_drv_param)) in memac_set_promiscuous()
736 static int memac_adjust_link(struct fman_mac *memac, u16 speed) in memac_adjust_link() argument
738 struct memac_regs __iomem *regs = memac->regs; in memac_adjust_link()
741 if (!is_init_done(memac->memac_drv_param)) in memac_adjust_link()
749 if (phy_interface_mode_is_rgmii(memac->phy_if)) { in memac_adjust_link()
794 static int memac_set_tx_pause_frames(struct fman_mac *memac, u8 priority, in memac_set_tx_pause_frames() argument
797 struct memac_regs __iomem *regs = memac->regs; in memac_set_tx_pause_frames()
800 if (!is_init_done(memac->memac_drv_param)) in memac_set_tx_pause_frames()
832 static int memac_accept_rx_pause_frames(struct fman_mac *memac, bool en) in memac_accept_rx_pause_frames() argument
834 struct memac_regs __iomem *regs = memac->regs; in memac_accept_rx_pause_frames()
837 if (!is_init_done(memac->memac_drv_param)) in memac_accept_rx_pause_frames()
851 static int memac_modify_mac_address(struct fman_mac *memac, in memac_modify_mac_address() argument
854 if (!is_init_done(memac->memac_drv_param)) in memac_modify_mac_address()
857 add_addr_in_paddr(memac->regs, (const u8 *)(*enet_addr), 0); in memac_modify_mac_address()
862 static int memac_add_hash_mac_address(struct fman_mac *memac, in memac_add_hash_mac_address() argument
865 struct memac_regs __iomem *regs = memac->regs; in memac_add_hash_mac_address()
870 if (!is_init_done(memac->memac_drv_param)) in memac_add_hash_mac_address()
890 &memac->multicast_addr_hash->lsts[hash]); in memac_add_hash_mac_address()
896 static int memac_set_allmulti(struct fman_mac *memac, bool enable) in memac_set_allmulti() argument
899 struct memac_regs __iomem *regs = memac->regs; in memac_set_allmulti()
901 if (!is_init_done(memac->memac_drv_param)) in memac_set_allmulti()
914 memac->allmulti_enabled = enable; in memac_set_allmulti()
919 static int memac_set_tstamp(struct fman_mac *memac, bool enable) in memac_set_tstamp() argument
924 static int memac_del_hash_mac_address(struct fman_mac *memac, in memac_del_hash_mac_address() argument
927 struct memac_regs __iomem *regs = memac->regs; in memac_del_hash_mac_address()
933 if (!is_init_done(memac->memac_drv_param)) in memac_del_hash_mac_address()
940 list_for_each(pos, &memac->multicast_addr_hash->lsts[hash]) { in memac_del_hash_mac_address()
949 if (!memac->allmulti_enabled) { in memac_del_hash_mac_address()
950 if (list_empty(&memac->multicast_addr_hash->lsts[hash])) in memac_del_hash_mac_address()
958 static int memac_set_exception(struct fman_mac *memac, in memac_set_exception() argument
963 if (!is_init_done(memac->memac_drv_param)) in memac_set_exception()
969 memac->exceptions |= bit_mask; in memac_set_exception()
971 memac->exceptions &= ~bit_mask; in memac_set_exception()
976 set_exception(memac->regs, bit_mask, enable); in memac_set_exception()
981 static int memac_init(struct fman_mac *memac) in memac_init() argument
991 if (is_init_done(memac->memac_drv_param)) in memac_init()
994 err = check_init_parameters(memac); in memac_init()
998 memac_drv_param = memac->memac_drv_param; in memac_init()
1000 if (memac->fm_rev_info.major == 6 && memac->fm_rev_info.minor == 4) in memac_init()
1005 err = reset(memac->regs); in memac_init()
1013 if (memac->addr != 0) { in memac_init()
1014 MAKE_ENET_ADDR_FROM_UINT64(memac->addr, eth_addr); in memac_init()
1015 add_addr_in_paddr(memac->regs, (const u8 *)eth_addr, 0); in memac_init()
1020 init(memac->regs, memac->memac_drv_param, memac->phy_if, in memac_init()
1021 memac->max_speed, slow_10g_if, memac->exceptions); in memac_init()
1026 if ((memac->fm_rev_info.major == 6) && in memac_init()
1027 ((memac->fm_rev_info.minor == 0) || in memac_init()
1028 (memac->fm_rev_info.minor == 3))) { in memac_init()
1032 reg32 = ioread32be(&memac->regs->command_config); in memac_init()
1034 iowrite32be(reg32, &memac->regs->command_config); in memac_init()
1037 if (memac->phy_if == PHY_INTERFACE_MODE_SGMII) { in memac_init()
1039 if (memac->basex_if) in memac_init()
1040 setup_sgmii_internal_phy_base_x(memac); in memac_init()
1042 setup_sgmii_internal_phy(memac, fixed_link); in memac_init()
1043 } else if (memac->phy_if == PHY_INTERFACE_MODE_QSGMII) { in memac_init()
1052 phy_addr = memac->pcsphy->mdio.addr; in memac_init()
1054 memac->pcsphy->mdio.addr = qsmgii_phy_addr; in memac_init()
1055 if (memac->basex_if) in memac_init()
1056 setup_sgmii_internal_phy_base_x(memac); in memac_init()
1058 setup_sgmii_internal_phy(memac, fixed_link); in memac_init()
1060 memac->pcsphy->mdio.addr = phy_addr; in memac_init()
1065 err = fman_set_mac_max_frame(memac->fm, memac->mac_id, in memac_init()
1072 memac->multicast_addr_hash = alloc_hash_table(HASH_TABLE_SIZE); in memac_init()
1073 if (!memac->multicast_addr_hash) { in memac_init()
1074 free_init_resources(memac); in memac_init()
1079 memac->unicast_addr_hash = alloc_hash_table(HASH_TABLE_SIZE); in memac_init()
1080 if (!memac->unicast_addr_hash) { in memac_init()
1081 free_init_resources(memac); in memac_init()
1086 fman_register_intr(memac->fm, FMAN_MOD_MAC, memac->mac_id, in memac_init()
1087 FMAN_INTR_TYPE_ERR, memac_err_exception, memac); in memac_init()
1089 fman_register_intr(memac->fm, FMAN_MOD_MAC, memac->mac_id, in memac_init()
1090 FMAN_INTR_TYPE_NORMAL, memac_exception, memac); in memac_init()
1093 memac->memac_drv_param = NULL; in memac_init()
1098 static int memac_free(struct fman_mac *memac) in memac_free() argument
1100 free_init_resources(memac); in memac_free()
1102 if (memac->pcsphy) in memac_free()
1103 put_device(&memac->pcsphy->mdio.dev); in memac_free()
1105 kfree(memac->memac_drv_param); in memac_free()
1106 kfree(memac); in memac_free()
1114 struct fman_mac *memac; in memac_config() local
1118 memac = kzalloc(sizeof(*memac), GFP_KERNEL); in memac_config()
1119 if (!memac) in memac_config()
1125 memac_free(memac); in memac_config()
1130 memac->memac_drv_param = memac_drv_param; in memac_config()
1134 memac->addr = ENET_ADDR_TO_UINT64(mac_dev->addr); in memac_config()
1136 memac->regs = mac_dev->vaddr; in memac_config()
1137 memac->max_speed = params->max_speed; in memac_config()
1138 memac->phy_if = mac_dev->phy_if; in memac_config()
1139 memac->mac_id = params->mac_id; in memac_config()
1140 memac->exceptions = (MEMAC_IMASK_TSECC_ER | MEMAC_IMASK_TECC_ER | in memac_config()
1142 memac->exception_cb = params->exception_cb; in memac_config()
1143 memac->event_cb = params->event_cb; in memac_config()
1144 memac->dev_id = mac_dev; in memac_config()
1145 memac->fm = params->fm; in memac_config()
1146 memac->basex_if = params->basex_if; in memac_config()
1149 fman_get_revision(memac->fm, &memac->fm_rev_info); in memac_config()
1151 return memac; in memac_config()
1161 struct fman_mac *memac; in memac_initialization() local
1186 memac = mac_dev->fman_mac; in memac_initialization()
1187 memac->memac_drv_param->max_frame_length = fman_get_max_frm(); in memac_initialization()
1188 memac->memac_drv_param->reset_on_init = true; in memac_initialization()
1189 if (memac->phy_if == PHY_INTERFACE_MODE_SGMII || in memac_initialization()
1190 memac->phy_if == PHY_INTERFACE_MODE_QSGMII) { in memac_initialization()
1198 memac->pcsphy = of_phy_find_device(phy_node); in memac_initialization()
1199 if (!memac->pcsphy) { in memac_initialization()
1234 memac->memac_drv_param->fixed_link = fixed_link; in memac_initialization()