Lines Matching refs:dtsec

477 static int check_init_parameters(struct fman_mac *dtsec)  in check_init_parameters()  argument
479 if ((dtsec->dtsec_drv_param)->rx_prepend > in check_init_parameters()
485 if (((dtsec->dtsec_drv_param)->non_back_to_back_ipg1 > in check_init_parameters()
487 ((dtsec->dtsec_drv_param)->non_back_to_back_ipg2 > in check_init_parameters()
489 ((dtsec->dtsec_drv_param)->back_to_back_ipg > in check_init_parameters()
495 if ((dtsec->dtsec_drv_param)->halfdup_retransmit > in check_init_parameters()
501 if ((dtsec->dtsec_drv_param)->halfdup_coll_window > in check_init_parameters()
510 if (!dtsec->exception_cb) { in check_init_parameters()
514 if (!dtsec->event_cb) { in check_init_parameters()
580 static u16 dtsec_get_max_frame_length(struct fman_mac *dtsec) in dtsec_get_max_frame_length() argument
582 struct dtsec_regs __iomem *regs = dtsec->regs; in dtsec_get_max_frame_length()
589 struct fman_mac *dtsec = (struct fman_mac *)handle; in dtsec_isr() local
590 struct dtsec_regs __iomem *regs = dtsec->regs; in dtsec_isr()
602 dtsec->exception_cb(dtsec->dev_id, FM_MAC_EX_1G_BAB_RX); in dtsec_isr()
604 dtsec->exception_cb(dtsec->dev_id, FM_MAC_EX_1G_RX_CTL); in dtsec_isr()
606 dtsec->exception_cb(dtsec->dev_id, in dtsec_isr()
609 dtsec->exception_cb(dtsec->dev_id, FM_MAC_EX_1G_BAB_TX); in dtsec_isr()
611 dtsec->exception_cb(dtsec->dev_id, FM_MAC_EX_1G_TX_CTL); in dtsec_isr()
613 dtsec->exception_cb(dtsec->dev_id, FM_MAC_EX_1G_TX_ERR); in dtsec_isr()
615 dtsec->exception_cb(dtsec->dev_id, FM_MAC_EX_1G_LATE_COL); in dtsec_isr()
617 dtsec->exception_cb(dtsec->dev_id, FM_MAC_EX_1G_COL_RET_LMT); in dtsec_isr()
621 if (dtsec->fm_rev_info.major == 2) { in dtsec_isr()
642 (dtsec_get_max_frame_length(dtsec) * in dtsec_isr()
645 (dtsec) * 16 / 1000, 1) + 1)); in dtsec_isr()
690 fman_reset_mac(dtsec->fm, dtsec->mac_id); in dtsec_isr()
701 dtsec->exception_cb(dtsec->dev_id, FM_MAC_EX_1G_TX_FIFO_UNDRN); in dtsec_isr()
704 dtsec->exception_cb(dtsec->dev_id, FM_MAC_EX_1G_MAG_PCKT); in dtsec_isr()
706 dtsec->exception_cb(dtsec->dev_id, in dtsec_isr()
709 dtsec->exception_cb(dtsec->dev_id, FM_MAC_EX_1G_DATA_ERR); in dtsec_isr()
711 dtsec->exception_cb(dtsec->dev_id, FM_MAC_1G_RX_DATA_ERR); in dtsec_isr()
720 struct fman_mac *dtsec = (struct fman_mac *)handle; in dtsec_1588_isr() local
721 struct dtsec_regs __iomem *regs = dtsec->regs; in dtsec_1588_isr()
724 if (dtsec->ptp_tsu_enabled) { in dtsec_1588_isr()
731 dtsec->exception_cb(dtsec->dev_id, in dtsec_1588_isr()
737 static void free_init_resources(struct fman_mac *dtsec) in free_init_resources() argument
739 fman_unregister_intr(dtsec->fm, FMAN_MOD_MAC, dtsec->mac_id, in free_init_resources()
741 fman_unregister_intr(dtsec->fm, FMAN_MOD_MAC, dtsec->mac_id, in free_init_resources()
745 free_hash_table(dtsec->multicast_addr_hash); in free_init_resources()
746 dtsec->multicast_addr_hash = NULL; in free_init_resources()
749 free_hash_table(dtsec->unicast_addr_hash); in free_init_resources()
750 dtsec->unicast_addr_hash = NULL; in free_init_resources()
761 struct fman_mac *dtsec = pcs_to_dtsec(pcs); in dtsec_pcs_get_state() local
763 phylink_mii_c22_pcs_get_state(dtsec->tbidev, state); in dtsec_pcs_get_state()
771 struct fman_mac *dtsec = pcs_to_dtsec(pcs); in dtsec_pcs_config() local
773 return phylink_mii_c22_pcs_config(dtsec->tbidev, interface, in dtsec_pcs_config()
779 struct fman_mac *dtsec = pcs_to_dtsec(pcs); in dtsec_pcs_an_restart() local
781 phylink_mii_c22_pcs_an_restart(dtsec->tbidev); in dtsec_pcs_an_restart()
790 static void graceful_start(struct fman_mac *dtsec) in graceful_start() argument
792 struct dtsec_regs __iomem *regs = dtsec->regs; in graceful_start()
798 static void graceful_stop(struct fman_mac *dtsec) in graceful_stop() argument
800 struct dtsec_regs __iomem *regs = dtsec->regs; in graceful_stop()
807 if (dtsec->fm_rev_info.major == 2) { in graceful_stop()
816 if (dtsec->fm_rev_info.major == 2) { in graceful_stop()
828 static int dtsec_enable(struct fman_mac *dtsec) in dtsec_enable() argument
833 static void dtsec_disable(struct fman_mac *dtsec) in dtsec_disable() argument
837 static int dtsec_set_tx_pause_frames(struct fman_mac *dtsec, in dtsec_set_tx_pause_frames() argument
842 struct dtsec_regs __iomem *regs = dtsec->regs; in dtsec_set_tx_pause_frames()
847 if (dtsec->fm_rev_info.major == 2 && pause_time <= 320) { in dtsec_set_tx_pause_frames()
868 static int dtsec_accept_rx_pause_frames(struct fman_mac *dtsec, bool en) in dtsec_accept_rx_pause_frames() argument
870 struct dtsec_regs __iomem *regs = dtsec->regs; in dtsec_accept_rx_pause_frames()
886 struct fman_mac *dtsec = fman_config_to_mac(config)->fman_mac; in dtsec_select_pcs() local
892 return &dtsec->pcs; in dtsec_select_pcs()
934 struct fman_mac *dtsec = mac_dev->fman_mac; in dtsec_link_up() local
935 struct dtsec_regs __iomem *regs = dtsec->regs; in dtsec_link_up()
940 dtsec_set_tx_pause_frames(dtsec, 0, pause_time, 0); in dtsec_link_up()
941 dtsec_accept_rx_pause_frames(dtsec, rx_pause); in dtsec_link_up()
970 graceful_start(dtsec); in dtsec_link_up()
976 struct fman_mac *dtsec = fman_config_to_mac(config)->fman_mac; in dtsec_link_down() local
977 struct dtsec_regs __iomem *regs = dtsec->regs; in dtsec_link_down()
981 graceful_stop(dtsec); in dtsec_link_down()
995 static int dtsec_modify_mac_address(struct fman_mac *dtsec, in dtsec_modify_mac_address() argument
998 graceful_stop(dtsec); in dtsec_modify_mac_address()
1003 dtsec->addr = ENET_ADDR_TO_UINT64(*enet_addr); in dtsec_modify_mac_address()
1004 set_mac_address(dtsec->regs, (const u8 *)(*enet_addr)); in dtsec_modify_mac_address()
1006 graceful_start(dtsec); in dtsec_modify_mac_address()
1011 static int dtsec_add_hash_mac_address(struct fman_mac *dtsec, in dtsec_add_hash_mac_address() argument
1014 struct dtsec_regs __iomem *regs = dtsec->regs; in dtsec_add_hash_mac_address()
1055 set_bucket(dtsec->regs, bucket, true); in dtsec_add_hash_mac_address()
1067 &dtsec->multicast_addr_hash->lsts[bucket]); in dtsec_add_hash_mac_address()
1070 &dtsec->unicast_addr_hash->lsts[bucket]); in dtsec_add_hash_mac_address()
1075 static int dtsec_set_allmulti(struct fman_mac *dtsec, bool enable) in dtsec_set_allmulti() argument
1078 struct dtsec_regs __iomem *regs = dtsec->regs; in dtsec_set_allmulti()
1091 static int dtsec_set_tstamp(struct fman_mac *dtsec, bool enable) in dtsec_set_tstamp() argument
1093 struct dtsec_regs __iomem *regs = dtsec->regs; in dtsec_set_tstamp()
1113 static int dtsec_del_hash_mac_address(struct fman_mac *dtsec, in dtsec_del_hash_mac_address() argument
1116 struct dtsec_regs __iomem *regs = dtsec->regs; in dtsec_del_hash_mac_address()
1151 &dtsec->multicast_addr_hash->lsts[bucket]) { in dtsec_del_hash_mac_address()
1159 if (list_empty(&dtsec->multicast_addr_hash->lsts[bucket])) in dtsec_del_hash_mac_address()
1160 set_bucket(dtsec->regs, bucket, false); in dtsec_del_hash_mac_address()
1164 &dtsec->unicast_addr_hash->lsts[bucket]) { in dtsec_del_hash_mac_address()
1172 if (list_empty(&dtsec->unicast_addr_hash->lsts[bucket])) in dtsec_del_hash_mac_address()
1173 set_bucket(dtsec->regs, bucket, false); in dtsec_del_hash_mac_address()
1182 static int dtsec_set_promiscuous(struct fman_mac *dtsec, bool new_val) in dtsec_set_promiscuous() argument
1184 struct dtsec_regs __iomem *regs = dtsec->regs; in dtsec_set_promiscuous()
1208 static int dtsec_set_exception(struct fman_mac *dtsec, in dtsec_set_exception() argument
1211 struct dtsec_regs __iomem *regs = dtsec->regs; in dtsec_set_exception()
1218 dtsec->exceptions |= bit_mask; in dtsec_set_exception()
1220 dtsec->exceptions &= ~bit_mask; in dtsec_set_exception()
1232 if (!dtsec->ptp_tsu_enabled) { in dtsec_set_exception()
1239 dtsec->en_tsu_err_exception = true; in dtsec_set_exception()
1244 dtsec->en_tsu_err_exception = false; in dtsec_set_exception()
1259 static int dtsec_init(struct fman_mac *dtsec) in dtsec_init() argument
1261 struct dtsec_regs __iomem *regs = dtsec->regs; in dtsec_init()
1267 (fman_reset_mac(dtsec->fm, dtsec->mac_id) != 0)) { in dtsec_init()
1272 err = check_init_parameters(dtsec); in dtsec_init()
1276 dtsec_drv_param = dtsec->dtsec_drv_param; in dtsec_init()
1278 err = init(dtsec->regs, dtsec_drv_param, dtsec->phy_if, in dtsec_init()
1279 dtsec->max_speed, dtsec->addr, dtsec->exceptions, in dtsec_init()
1280 dtsec->tbidev->addr); in dtsec_init()
1282 free_init_resources(dtsec); in dtsec_init()
1289 mdiodev_write(dtsec->tbidev, MII_TBICON, tbicon); in dtsec_init()
1292 mdiodev_write(dtsec->tbidev, MII_TBICON, tbicon); in dtsec_init()
1296 err = fman_set_mac_max_frame(dtsec->fm, dtsec->mac_id, max_frm_ln); in dtsec_init()
1299 free_init_resources(dtsec); in dtsec_init()
1303 dtsec->multicast_addr_hash = in dtsec_init()
1305 if (!dtsec->multicast_addr_hash) { in dtsec_init()
1306 free_init_resources(dtsec); in dtsec_init()
1311 dtsec->unicast_addr_hash = alloc_hash_table(DTSEC_HASH_TABLE_SIZE); in dtsec_init()
1312 if (!dtsec->unicast_addr_hash) { in dtsec_init()
1313 free_init_resources(dtsec); in dtsec_init()
1319 fman_register_intr(dtsec->fm, FMAN_MOD_MAC, dtsec->mac_id, in dtsec_init()
1320 FMAN_INTR_TYPE_ERR, dtsec_isr, dtsec); in dtsec_init()
1322 fman_register_intr(dtsec->fm, FMAN_MOD_MAC, dtsec->mac_id, in dtsec_init()
1323 FMAN_INTR_TYPE_NORMAL, dtsec_1588_isr, dtsec); in dtsec_init()
1326 dtsec->dtsec_drv_param = NULL; in dtsec_init()
1331 static int dtsec_free(struct fman_mac *dtsec) in dtsec_free() argument
1333 free_init_resources(dtsec); in dtsec_free()
1335 kfree(dtsec->dtsec_drv_param); in dtsec_free()
1336 dtsec->dtsec_drv_param = NULL; in dtsec_free()
1337 if (!IS_ERR_OR_NULL(dtsec->tbidev)) in dtsec_free()
1338 put_device(&dtsec->tbidev->dev); in dtsec_free()
1339 kfree(dtsec); in dtsec_free()
1347 struct fman_mac *dtsec; in dtsec_config() local
1351 dtsec = kzalloc(sizeof(*dtsec), GFP_KERNEL); in dtsec_config()
1352 if (!dtsec) in dtsec_config()
1361 dtsec->dtsec_drv_param = dtsec_drv_param; in dtsec_config()
1365 dtsec->regs = mac_dev->vaddr; in dtsec_config()
1366 dtsec->addr = ENET_ADDR_TO_UINT64(mac_dev->addr); in dtsec_config()
1367 dtsec->phy_if = mac_dev->phy_if; in dtsec_config()
1368 dtsec->mac_id = params->mac_id; in dtsec_config()
1369 dtsec->exceptions = (DTSEC_IMASK_BREN | in dtsec_config()
1382 dtsec->exception_cb = params->exception_cb; in dtsec_config()
1383 dtsec->event_cb = params->event_cb; in dtsec_config()
1384 dtsec->dev_id = mac_dev; in dtsec_config()
1385 dtsec->ptp_tsu_enabled = dtsec->dtsec_drv_param->ptp_tsu_en; in dtsec_config()
1386 dtsec->en_tsu_err_exception = dtsec->dtsec_drv_param->ptp_exception_en; in dtsec_config()
1388 dtsec->fm = params->fm; in dtsec_config()
1391 fman_get_revision(dtsec->fm, &dtsec->fm_rev_info); in dtsec_config()
1393 return dtsec; in dtsec_config()
1396 kfree(dtsec); in dtsec_config()
1405 struct fman_mac *dtsec; in dtsec_initialization() local
1428 dtsec = mac_dev->fman_mac; in dtsec_initialization()
1429 dtsec->dtsec_drv_param->maximum_frame = fman_get_max_frm(); in dtsec_initialization()
1430 dtsec->dtsec_drv_param->tx_pad_crc = true; in dtsec_initialization()
1441 dtsec->tbidev = of_mdio_find_device(phy_node); in dtsec_initialization()
1443 if (!dtsec->tbidev) { in dtsec_initialization()
1449 dtsec->pcs.ops = &dtsec_pcs_ops; in dtsec_initialization()
1450 dtsec->pcs.neg_mode = true; in dtsec_initialization()
1451 dtsec->pcs.poll = true; in dtsec_initialization()
1467 if (!(ioread32be(&dtsec->regs->tsec_id2) & DTSEC_ID2_INT_REDUCED_OFF)) { in dtsec_initialization()
1485 err = dtsec_init(dtsec); in dtsec_initialization()
1490 err = dtsec_set_exception(dtsec, FM_MAC_EX_1G_RX_MIB_CNT_OVFL, false); in dtsec_initialization()
1495 ioread32be(&dtsec->regs->tsec_id)); in dtsec_initialization()
1500 dtsec_free(dtsec); in dtsec_initialization()