Lines Matching refs:uec
57 static int uec_mac_enable(uec_private_t *uec, comm_dir_e mode) in uec_mac_enable() argument
62 if (!uec) { in uec_mac_enable()
66 uec_regs = uec->uec_regs; in uec_mac_enable()
73 uec->mac_tx_enabled = 1; in uec_mac_enable()
79 uec->mac_rx_enabled = 1; in uec_mac_enable()
85 static int uec_mac_disable(uec_private_t *uec, comm_dir_e mode) in uec_mac_disable() argument
90 if (!uec) { in uec_mac_disable()
94 uec_regs = uec->uec_regs; in uec_mac_disable()
101 uec->mac_tx_enabled = 0; in uec_mac_disable()
107 uec->mac_rx_enabled = 0; in uec_mac_disable()
113 static int uec_graceful_stop_tx(uec_private_t *uec) in uec_graceful_stop_tx() argument
119 if (!uec || !uec->uccf) { in uec_graceful_stop_tx()
124 uf_regs = uec->uccf->uf_regs; in uec_graceful_stop_tx()
131 ucc_fast_get_qe_cr_subblock(uec->uec_info->uf_info.ucc_num); in uec_graceful_stop_tx()
140 uec->grace_stopped_tx = 1; in uec_graceful_stop_tx()
145 static int uec_graceful_stop_rx(uec_private_t *uec) in uec_graceful_stop_rx() argument
150 if (!uec) { in uec_graceful_stop_rx()
155 if (!uec->p_rx_glbl_pram) { in uec_graceful_stop_rx()
161 ack = uec->p_rx_glbl_pram->rxgstpack; in uec_graceful_stop_rx()
163 uec->p_rx_glbl_pram->rxgstpack = ack; in uec_graceful_stop_rx()
169 ucc_fast_get_qe_cr_subblock(uec->uec_info->uf_info.ucc_num); in uec_graceful_stop_rx()
172 ack = uec->p_rx_glbl_pram->rxgstpack; in uec_graceful_stop_rx()
175 uec->grace_stopped_rx = 1; in uec_graceful_stop_rx()
180 static int uec_restart_tx(uec_private_t *uec) in uec_restart_tx() argument
184 if (!uec || !uec->uec_info) { in uec_restart_tx()
190 ucc_fast_get_qe_cr_subblock(uec->uec_info->uf_info.ucc_num); in uec_restart_tx()
194 uec->grace_stopped_tx = 0; in uec_restart_tx()
199 static int uec_restart_rx(uec_private_t *uec) in uec_restart_rx() argument
203 if (!uec || !uec->uec_info) { in uec_restart_rx()
209 ucc_fast_get_qe_cr_subblock(uec->uec_info->uf_info.ucc_num); in uec_restart_rx()
213 uec->grace_stopped_rx = 0; in uec_restart_rx()
218 static int uec_open(uec_private_t *uec, comm_dir_e mode) in uec_open() argument
222 if (!uec || !uec->uccf) { in uec_open()
226 uccf = uec->uccf; in uec_open()
229 if (uec->uec_info->uf_info.ucc_num >= UCC_MAX_NUM) { in uec_open()
235 uec_mac_enable(uec, mode); in uec_open()
241 if ((mode & COMM_DIR_TX) && uec->grace_stopped_tx) { in uec_open()
242 uec_restart_tx(uec); in uec_open()
244 if ((mode & COMM_DIR_RX) && uec->grace_stopped_rx) { in uec_open()
245 uec_restart_rx(uec); in uec_open()
251 static int uec_stop(uec_private_t *uec, comm_dir_e mode) in uec_stop() argument
253 if (!uec || !uec->uccf) { in uec_stop()
259 if (uec->uec_info->uf_info.ucc_num >= UCC_MAX_NUM) { in uec_stop()
264 if ((mode & COMM_DIR_TX) && !uec->grace_stopped_tx) { in uec_stop()
265 uec_graceful_stop_tx(uec); in uec_stop()
268 if ((mode & COMM_DIR_RX) && !uec->grace_stopped_rx) { in uec_stop()
269 uec_graceful_stop_rx(uec); in uec_stop()
273 ucc_fast_disable(uec->uccf, mode); in uec_stop()
276 uec_mac_disable(uec, mode); in uec_stop()
281 static int uec_set_mac_duplex(uec_private_t *uec, int duplex) in uec_set_mac_duplex() argument
286 if (!uec) { in uec_set_mac_duplex()
290 uec_regs = uec->uec_regs; in uec_set_mac_duplex()
307 static int uec_set_mac_if_mode(uec_private_t *uec, in uec_set_mac_if_mode() argument
315 if (!uec) { in uec_set_mac_if_mode()
320 uec_regs = uec->uec_regs; in uec_set_mac_if_mode()
326 upsmr = in_be32(&uec->uccf->uf_regs->upsmr); in uec_set_mac_if_mode()
393 out_be32(&uec->uccf->uf_regs->upsmr, upsmr); in uec_set_mac_if_mode()
419 uec_private_t *uec; in init_phy() local
425 uec = (uec_private_t *)dev->priv; in init_phy()
426 umii_regs = uec->uec_mii_regs; in init_phy()
428 uec->oldlink = 0; in init_phy()
429 uec->oldspeed = 0; in init_phy()
430 uec->oldduplex = -1; in init_phy()
439 if (uec->uec_info->uf_info.eth_type == GIGA_ETH) { in init_phy()
455 mii_info->mii_id = uec->uec_info->phy_address; in init_phy()
461 uec->mii_info = mii_info; in init_phy()
463 qe_set_mii_clk_src(uec->uec_info->uf_info.ucc_num); in init_phy()
472 curphy = uec_get_phy_info(uec->mii_info); in init_phy()
483 err = curphy->init(uec->mii_info); in init_phy()
499 uec_private_t *uec = (uec_private_t *)dev->priv; in adjust_link() local
500 struct uec_mii_info *mii_info = uec->mii_info; in adjust_link()
508 if (mii_info->duplex != uec->oldduplex) { in adjust_link()
510 uec_set_mac_duplex(uec, DUPLEX_HALF); in adjust_link()
513 uec_set_mac_duplex(uec, DUPLEX_FULL); in adjust_link()
516 uec->oldduplex = mii_info->duplex; in adjust_link()
519 if (mii_info->speed != uec->oldspeed) { in adjust_link()
521 uec->uec_info->enet_interface_type; in adjust_link()
522 if (uec->uec_info->uf_info.eth_type == GIGA_ETH) { in adjust_link()
544 uec_set_mac_if_mode(uec, mode, mii_info->speed); in adjust_link()
547 uec->oldspeed = mii_info->speed; in adjust_link()
550 if (!uec->oldlink) { in adjust_link()
552 uec->oldlink = 1; in adjust_link()
556 if (uec->oldlink) { in adjust_link()
558 uec->oldlink = 0; in adjust_link()
559 uec->oldspeed = 0; in adjust_link()
560 uec->oldduplex = -1; in adjust_link()
567 uec_private_t *uec = (uec_private_t *)dev->priv; in phy_change() local
578 uec->mii_info->phyinfo->read_status(uec->mii_info); in phy_change()
664 static int uec_set_mac_address(uec_private_t *uec, u8 *mac_addr) in uec_set_mac_address() argument
670 if (!uec) { in uec_set_mac_address()
675 uec_regs = uec->uec_regs; in uec_set_mac_address()
723 static void uec_init_tx_parameter(uec_private_t *uec, int num_threads_tx) in uec_init_tx_parameter() argument
730 uec_info = uec->uec_info; in uec_init_tx_parameter()
733 uec->tx_glbl_pram_offset = qe_muram_alloc( in uec_init_tx_parameter()
736 uec->p_tx_glbl_pram = (uec_tx_global_pram_t *) in uec_init_tx_parameter()
737 qe_muram_addr(uec->tx_glbl_pram_offset); in uec_init_tx_parameter()
740 memset(uec->p_tx_glbl_pram, 0, sizeof(uec_tx_global_pram_t)); in uec_init_tx_parameter()
745 out_be16(&uec->p_tx_glbl_pram->temoder, TEMODER_INIT_VALUE); in uec_init_tx_parameter()
748 uec->send_q_mem_reg_offset = qe_muram_alloc( in uec_init_tx_parameter()
751 uec->p_send_q_mem_reg = (uec_send_queue_mem_region_t *) in uec_init_tx_parameter()
752 qe_muram_addr(uec->send_q_mem_reg_offset); in uec_init_tx_parameter()
753 out_be32(&uec->p_tx_glbl_pram->sqptr, uec->send_q_mem_reg_offset); in uec_init_tx_parameter()
756 end_bd = (u32)uec->p_tx_bd_ring + (uec_info->tx_bd_ring_len - 1) in uec_init_tx_parameter()
758 out_be32(&uec->p_send_q_mem_reg->sqqd[0].bd_ring_base, in uec_init_tx_parameter()
759 (u32)(uec->p_tx_bd_ring)); in uec_init_tx_parameter()
760 out_be32(&uec->p_send_q_mem_reg->sqqd[0].last_bd_completed_address, in uec_init_tx_parameter()
764 out_be32(&uec->p_tx_glbl_pram->schedulerbasepointer, 0); in uec_init_tx_parameter()
767 out_be32(&uec->p_tx_glbl_pram->txrmonbaseptr, 0); in uec_init_tx_parameter()
771 out_be32(&uec->p_tx_glbl_pram->tstate, ((u32)(bmrx) << BMR_SHIFT)); in uec_init_tx_parameter()
775 out_8(&uec->p_tx_glbl_pram->iphoffset[i], 0); in uec_init_tx_parameter()
780 out_be32(&uec->p_tx_glbl_pram->vtagtable[i], 0); in uec_init_tx_parameter()
784 uec->thread_dat_tx_offset = qe_muram_alloc( in uec_init_tx_parameter()
788 uec->p_thread_data_tx = (uec_thread_data_tx_t *) in uec_init_tx_parameter()
789 qe_muram_addr(uec->thread_dat_tx_offset); in uec_init_tx_parameter()
790 out_be32(&uec->p_tx_glbl_pram->tqptr, uec->thread_dat_tx_offset); in uec_init_tx_parameter()
793 static void uec_init_rx_parameter(uec_private_t *uec, int num_threads_rx) in uec_init_rx_parameter() argument
800 uec->rx_glbl_pram_offset = qe_muram_alloc( in uec_init_rx_parameter()
802 uec->p_rx_glbl_pram = (uec_rx_global_pram_t *) in uec_init_rx_parameter()
803 qe_muram_addr(uec->rx_glbl_pram_offset); in uec_init_rx_parameter()
806 memset(uec->p_rx_glbl_pram, 0, sizeof(uec_rx_global_pram_t)); in uec_init_rx_parameter()
815 out_be32(&uec->p_rx_glbl_pram->remoder, REMODER_INIT_VALUE); in uec_init_rx_parameter()
818 uec->thread_dat_rx_offset = qe_muram_alloc( in uec_init_rx_parameter()
821 uec->p_thread_data_rx = (uec_thread_data_rx_t *) in uec_init_rx_parameter()
822 qe_muram_addr(uec->thread_dat_rx_offset); in uec_init_rx_parameter()
823 out_be32(&uec->p_rx_glbl_pram->rqptr, uec->thread_dat_rx_offset); in uec_init_rx_parameter()
826 out_be16(&uec->p_rx_glbl_pram->typeorlen, 3072); in uec_init_rx_parameter()
829 out_be32(&uec->p_rx_glbl_pram->rxrmonbaseptr, 0); in uec_init_rx_parameter()
832 out_be32(&uec->p_rx_glbl_pram->intcoalescingptr, 0); in uec_init_rx_parameter()
836 out_8(&uec->p_rx_glbl_pram->rstate, bmrx); in uec_init_rx_parameter()
839 out_be16(&uec->p_rx_glbl_pram->mrblr, MAX_RXBUF_LEN); in uec_init_rx_parameter()
842 uec->rx_bd_qs_tbl_offset = qe_muram_alloc( in uec_init_rx_parameter()
846 uec->p_rx_bd_qs_tbl = (uec_rx_bd_queues_entry_t *) in uec_init_rx_parameter()
847 qe_muram_addr(uec->rx_bd_qs_tbl_offset); in uec_init_rx_parameter()
850 memset(uec->p_rx_bd_qs_tbl, 0, sizeof(uec_rx_bd_queues_entry_t) + \ in uec_init_rx_parameter()
852 out_be32(&uec->p_rx_glbl_pram->rbdqptr, uec->rx_bd_qs_tbl_offset); in uec_init_rx_parameter()
853 out_be32(&uec->p_rx_bd_qs_tbl->externalbdbaseptr, in uec_init_rx_parameter()
854 (u32)uec->p_rx_bd_ring); in uec_init_rx_parameter()
857 out_be16(&uec->p_rx_glbl_pram->mflr, MAX_FRAME_LEN); in uec_init_rx_parameter()
859 out_be16(&uec->p_rx_glbl_pram->minflr, MIN_FRAME_LEN); in uec_init_rx_parameter()
861 out_be16(&uec->p_rx_glbl_pram->maxd1, MAX_DMA1_LEN); in uec_init_rx_parameter()
863 out_be16(&uec->p_rx_glbl_pram->maxd2, MAX_DMA2_LEN); in uec_init_rx_parameter()
865 out_be32(&uec->p_rx_glbl_pram->ecamptr, 0); in uec_init_rx_parameter()
867 out_be32(&uec->p_rx_glbl_pram->l2qt, 0); in uec_init_rx_parameter()
870 out_be32(&uec->p_rx_glbl_pram->l3qt[i], 0); in uec_init_rx_parameter()
874 out_be16(&uec->p_rx_glbl_pram->vlantype, 0x8100); in uec_init_rx_parameter()
876 out_be16(&uec->p_rx_glbl_pram->vlantci, 0); in uec_init_rx_parameter()
880 uec->p_rx_glbl_pram->addressfiltering; in uec_init_rx_parameter()
888 static int uec_issue_init_enet_rxtx_cmd(uec_private_t *uec, in uec_issue_init_enet_rxtx_cmd() argument
901 uec_info = uec->uec_info; in uec_issue_init_enet_rxtx_cmd()
904 uec->init_enet_param_offset = qe_muram_alloc( in uec_issue_init_enet_rxtx_cmd()
906 init_enet_param_offset = uec->init_enet_param_offset; in uec_issue_init_enet_rxtx_cmd()
907 uec->p_init_enet_param = (uec_init_cmd_pram_t *) in uec_issue_init_enet_rxtx_cmd()
908 qe_muram_addr(uec->init_enet_param_offset); in uec_issue_init_enet_rxtx_cmd()
911 memset((void *)uec->p_init_enet_param, 0, sizeof(uec_init_cmd_pram_t)); in uec_issue_init_enet_rxtx_cmd()
914 p_init_enet_param = uec->p_init_enet_param; in uec_issue_init_enet_rxtx_cmd()
928 p_init_enet_param->rgftgfrxglobal |= uec->rx_glbl_pram_offset | in uec_issue_init_enet_rxtx_cmd()
952 p_init_enet_param->txglobal = uec->tx_glbl_pram_offset | in uec_issue_init_enet_rxtx_cmd()
975 uec->uec_info->uf_info.ucc_num); in uec_issue_init_enet_rxtx_cmd()
982 static int uec_startup(uec_private_t *uec) in uec_startup() argument
998 if (!uec || !uec->uec_info) { in uec_startup()
1003 uec_info = uec->uec_info; in uec_startup()
1029 uec->grace_stopped_rx = 1; in uec_startup()
1030 uec->grace_stopped_tx = 1; in uec_startup()
1039 uec->uccf = uccf; in uec_startup()
1059 uec->uec_regs = uec_regs; in uec_startup()
1062 out_be32(&uec->uccf->uf_regs->upsmr, UPSMR_INIT_VALUE); in uec_startup()
1071 uec_set_mac_if_mode(uec, uec_info->enet_interface_type, uec_info->speed); in uec_startup()
1075 uec->uec_mii_regs = (uec_mii_t *)(&uec_regs->miimcfg); in uec_startup()
1077 uec->uec_mii_regs = (uec_mii_t *) CONFIG_MIIM_ADDRESS; in uec_startup()
1094 if ((uec->uec_info->enet_interface_type == PHY_INTERFACE_MODE_SGMII) && in uec_startup()
1095 (uec->uec_info->speed == SPEED_1000)) { in uec_startup()
1096 uec_write_phy_reg(uec->dev, uec_regs->utbipar, in uec_startup()
1099 uec_write_phy_reg(uec->dev, uec_regs->utbipar, in uec_startup()
1102 uec_write_phy_reg(uec->dev, uec_regs->utbipar, in uec_startup()
1116 uec->tx_bd_ring_offset = (u32)malloc((u32)(length + align)); in uec_startup()
1117 if (uec->tx_bd_ring_offset != 0) { in uec_startup()
1118 uec->p_tx_bd_ring = (u8 *)((uec->tx_bd_ring_offset + align) in uec_startup()
1123 memset((void *)(uec->tx_bd_ring_offset), 0, length + align); in uec_startup()
1128 uec->rx_bd_ring_offset = (u32)(malloc((u32)(length + align))); in uec_startup()
1129 if (uec->rx_bd_ring_offset != 0) { in uec_startup()
1130 uec->p_rx_bd_ring = (u8 *)((uec->rx_bd_ring_offset + align) in uec_startup()
1135 memset((void *)(uec->rx_bd_ring_offset), 0, length + align); in uec_startup()
1140 uec->rx_buf_offset = (u32)malloc(length + align); in uec_startup()
1141 if (uec->rx_buf_offset != 0) { in uec_startup()
1142 uec->p_rx_buf = (u8 *)((uec->rx_buf_offset + align) in uec_startup()
1147 memset((void *)(uec->rx_buf_offset), 0, length + align); in uec_startup()
1150 bd = (qe_bd_t *)uec->p_tx_bd_ring; in uec_startup()
1151 uec->txBd = bd; in uec_startup()
1162 bd = (qe_bd_t *)uec->p_rx_bd_ring; in uec_startup()
1163 uec->rxBd = bd; in uec_startup()
1164 buf = uec->p_rx_buf; in uec_startup()
1175 uec_init_tx_parameter(uec, num_threads_tx); in uec_startup()
1178 uec_init_rx_parameter(uec, num_threads_rx); in uec_startup()
1181 if (uec_issue_init_enet_rxtx_cmd(uec, num_threads_tx, in uec_startup()
1192 uec_private_t *uec; in uec_init() local
1199 uec = (uec_private_t *)dev->priv; in uec_init()
1201 if (uec->the_first_run == 0) { in uec_init()
1215 curphy = uec->mii_info->phyinfo; in uec_init()
1218 err = curphy->config_aneg(uec->mii_info); in uec_init()
1228 err = curphy->read_status(uec->mii_info); in uec_init()
1229 if (!(((i-- > 0) && !uec->mii_info->link) || err)) in uec_init()
1243 uec->the_first_run = 1; in uec_init()
1252 uec_set_mac_address(uec, dev->enetaddr); in uec_init()
1255 err = uec_open(uec, COMM_DIR_RX_AND_TX); in uec_init()
1263 return (uec->mii_info->link ? 0 : -1); in uec_init()
1268 uec_private_t *uec = (uec_private_t *)dev->priv; in uec_halt() local
1269 uec_stop(uec, COMM_DIR_RX_AND_TX); in uec_halt()
1274 uec_private_t *uec; in uec_send() local
1281 uec = (uec_private_t *)dev->priv; in uec_send()
1282 uccf = uec->uccf; in uec_send()
1283 bd = uec->txBd; in uec_send()
1313 BD_ADVANCE(bd, status, uec->p_tx_bd_ring); in uec_send()
1314 uec->txBd = bd; in uec_send()
1322 uec_private_t *uec = dev->priv; in uec_recv() local
1328 bd = uec->rxBd; in uec_recv()
1342 BD_ADVANCE(bd, status, uec->p_rx_bd_ring); in uec_recv()
1345 uec->rxBd = bd; in uec_recv()
1354 uec_private_t *uec; in uec_initialize() local
1363 uec = (uec_private_t *)malloc(sizeof(uec_private_t)); in uec_initialize()
1364 if (!uec) { in uec_initialize()
1367 memset(uec, 0, sizeof(uec_private_t)); in uec_initialize()
1377 uec->uec_info = uec_info; in uec_initialize()
1378 uec->dev = dev; in uec_initialize()
1382 dev->priv = (void *)uec; in uec_initialize()
1394 err = uec_startup(uec); in uec_initialize()