Lines Matching +full:tx +full:- +full:buffer +full:- +full:descriptors
5 * SPDX-License-Identifier: Apache-2.0
12 * - no link monitoring through PHY interrupt
54 eth->NETWORKCTRL &= ~(ETH_NETWORKCTRL_ENBTX | ETH_NETWORKCTRL_ENBRX); in link_configure()
57 val = eth->NETWORKCFG; in link_configure()
61 eth->NETWORKCFG = val; in link_configure()
64 eth->NETWORKCTRL |= (ETH_NETWORKCTRL_ENBTX | ETH_NETWORKCTRL_ENBRX); in link_configure()
69 const struct eth_gecko_dev_cfg *const cfg = dev->config; in eth_gecko_setup_mac()
70 ETH_TypeDef *eth = cfg->regs; in eth_gecko_setup_mac()
74 /* PHY auto-negotiate link parameters */ in eth_gecko_setup_mac()
75 result = phy_gecko_auto_negotiate(&cfg->phy, &link_status); in eth_gecko_setup_mac()
77 LOG_ERR("ETH PHY auto-negotiate sequence failed"); in eth_gecko_setup_mac()
95 /* Initialize TX buffer descriptors */ in eth_init_tx_buf_desc()
103 dma_tx_desc_tab[i - 1].status |= ETH_TX_WRAP; in eth_init_tx_buf_desc()
119 dma_rx_desc_tab[i - 1].address |= ETH_RX_WRAP; in eth_init_rx_buf_desc()
130 /* Reset RX buffer descriptor list */ in rx_error_handler()
132 eth->RXQPTR = (uint32_t)dma_rx_desc_tab; in rx_error_handler()
140 struct eth_gecko_dev_data *const dev_data = dev->data; in frame_get()
141 const struct eth_gecko_dev_cfg *const cfg = dev->config; in frame_get()
142 ETH_TypeDef *eth = cfg->regs; in frame_get()
163 j -= ETH_RX_BUF_COUNT; in frame_get()
166 /* Verify it is an ETH owned buffer */ in frame_get()
195 rx_frame = net_pkt_rx_alloc_with_buffer(dev_data->iface, in frame_get()
198 LOG_ERR("Failed to obtain RX buffer"); in frame_get()
201 eth->RXQPTR = (uint32_t)dma_rx_desc_tab; in frame_get()
214 LOG_ERR("Failed to append RX buffer"); in frame_get()
224 total_len -= frag_len; in frame_get()
226 j -= ETH_RX_BUF_COUNT; in frame_get()
230 rx_buf_idx -= ETH_RX_BUF_COUNT; in frame_get()
240 struct eth_gecko_dev_data *const dev_data = dev->data; in eth_rx()
251 res = net_recv_data(dev_data->iface, rx_frame); in eth_rx()
255 eth_stats_update_errors_rx(dev_data->iface); in eth_rx()
266 struct eth_gecko_dev_data *const dev_data = dev->data; in eth_tx()
267 const struct eth_gecko_dev_cfg *const cfg = dev->config; in eth_tx()
268 ETH_TypeDef *eth = cfg->regs; in eth_tx()
278 __ASSERT(pkt->frags, "Frame data missing"); in eth_tx()
284 res = -EIO; in eth_tx()
288 if (k_sem_take(&dev_data->tx_sem, K_MSEC(100)) != 0) { in eth_tx()
289 LOG_ERR("TX process did not complete within 100ms"); in eth_tx()
290 res = -EIO; in eth_tx()
294 /* Make sure current buffer is available for writing */ in eth_tx()
296 LOG_ERR("Buffer already in use"); in eth_tx()
297 res = -EIO; in eth_tx()
303 LOG_ERR("Failed to read packet into buffer"); in eth_tx()
304 res = -EIO; in eth_tx()
308 if (tx_buf_idx < (ETH_TX_BUF_COUNT - 1)) { in eth_tx()
320 eth->NETWORKCTRL |= ETH_NETWORKCTRL_TXSTRT; in eth_tx()
329 struct eth_gecko_dev_data *const dev_data = dev->data; in rx_thread()
330 const struct eth_gecko_dev_cfg *const cfg = dev->config; in rx_thread()
340 res = k_sem_take(&dev_data->rx_sem, K_MSEC( in rx_thread()
343 if (dev_data->link_up != true) { in rx_thread()
344 dev_data->link_up = true; in rx_thread()
347 net_eth_carrier_on(dev_data->iface); in rx_thread()
352 } else if (res == -EAGAIN) { in rx_thread()
353 if (phy_gecko_is_linked(&cfg->phy)) { in rx_thread()
354 if (dev_data->link_up != true) { in rx_thread()
355 dev_data->link_up = true; in rx_thread()
358 net_eth_carrier_on(dev_data->iface); in rx_thread()
361 if (dev_data->link_up != false) { in rx_thread()
362 dev_data->link_up = false; in rx_thread()
364 net_eth_carrier_off(dev_data->iface); in rx_thread()
373 struct eth_gecko_dev_data *const dev_data = dev->data; in eth_isr()
374 const struct eth_gecko_dev_cfg *const cfg = dev->config; in eth_isr()
375 ETH_TypeDef *eth = cfg->regs; in eth_isr()
377 uint32_t int_stat = eth->IFCR; in eth_isr()
391 k_sem_give(&dev_data->rx_sem); in eth_isr()
407 * buffer is no longer used and we release the in eth_isr()
409 * start TX of a new packet in eth_isr()
415 /* Signal TX thread we're ready to start transmission */ in eth_isr()
416 k_sem_give(&dev_data->tx_sem); in eth_isr()
420 eth->IFCR = int_clr; in eth_isr()
433 const struct eth_gecko_dev_cfg *const cfg = dev->config; in eth_init_pins()
434 ETH_TypeDef *eth = cfg->regs; in eth_init_pins()
440 eth->ROUTELOC1 = 0; in eth_init_pins()
441 eth->ROUTEPEN = 0; in eth_init_pins()
444 for (idx = 0; idx < ARRAY_SIZE(cfg->pin_list->rmii); idx++) { in eth_init_pins()
445 GPIO_PinModeSet(cfg->pin_list->rmii[idx].port, cfg->pin_list->rmii[idx].pin, in eth_init_pins()
446 cfg->pin_list->rmii[idx].mode, cfg->pin_list->rmii[idx].out); in eth_init_pins()
449 eth->ROUTELOC1 |= (DT_INST_PROP(0, location_rmii) << in eth_init_pins()
451 eth->ROUTEPEN |= ETH_ROUTEPEN_RMIIPEN; in eth_init_pins()
455 for (idx = 0; idx < ARRAY_SIZE(cfg->pin_list->mdio); idx++) { in eth_init_pins()
456 GPIO_PinModeSet(cfg->pin_list->mdio[idx].port, cfg->pin_list->mdio[idx].pin, in eth_init_pins()
457 cfg->pin_list->mdio[idx].mode, cfg->pin_list->mdio[idx].out); in eth_init_pins()
460 eth->ROUTELOC1 |= (DT_INST_PROP(0, location_mdio) << in eth_init_pins()
462 eth->ROUTEPEN |= ETH_ROUTEPEN_MDIOPEN; in eth_init_pins()
469 const struct eth_gecko_dev_cfg *const cfg = dev->config; in eth_init()
470 ETH_TypeDef *eth = cfg->regs; in eth_init()
483 eth->CTRL = ETH_CTRL_GBLCLKEN | ETH_CTRL_MIISEL_RMII; in eth_init()
487 cfg->config_func(); in eth_init()
489 LOG_INF("Device %s initialized", dev->name); in eth_init()
499 mac_addr[0] = DEVINFO->EUI48H >> 8; in generate_mac()
500 mac_addr[1] = DEVINFO->EUI48H >> 0; in generate_mac()
501 mac_addr[2] = DEVINFO->EUI48L >> 24; in generate_mac()
502 mac_addr[3] = DEVINFO->EUI48L >> 16; in generate_mac()
503 mac_addr[4] = DEVINFO->EUI48L >> 8; in generate_mac()
504 mac_addr[5] = DEVINFO->EUI48L >> 0; in generate_mac()
511 struct eth_gecko_dev_data *const dev_data = dev->data; in eth_iface_init()
512 const struct eth_gecko_dev_cfg *const cfg = dev->config; in eth_iface_init()
513 ETH_TypeDef *eth = cfg->regs; in eth_iface_init()
523 dev_data->iface = iface; in eth_iface_init()
524 dev_data->link_up = false; in eth_iface_init()
530 generate_mac(dev_data->mac_addr); in eth_iface_init()
534 dev_data->mac_addr[0], dev_data->mac_addr[1], in eth_iface_init()
535 dev_data->mac_addr[2], dev_data->mac_addr[3], in eth_iface_init()
536 dev_data->mac_addr[4], dev_data->mac_addr[5]); in eth_iface_init()
538 net_if_set_link_addr(iface, dev_data->mac_addr, in eth_iface_init()
539 sizeof(dev_data->mac_addr), NET_LINK_ETHERNET); in eth_iface_init()
542 eth->NETWORKCTRL = 0; in eth_iface_init()
543 eth->NETWORKCFG = 0; in eth_iface_init()
546 eth->SPECADDR1BOTTOM = in eth_iface_init()
547 (dev_data->mac_addr[0] << 0) | in eth_iface_init()
548 (dev_data->mac_addr[1] << 8) | in eth_iface_init()
549 (dev_data->mac_addr[2] << 16) | in eth_iface_init()
550 (dev_data->mac_addr[3] << 24); in eth_iface_init()
551 eth->SPECADDR1TOP = in eth_iface_init()
552 (dev_data->mac_addr[4] << 0) | in eth_iface_init()
553 (dev_data->mac_addr[5] << 8); in eth_iface_init()
555 eth->SPECADDR2BOTTOM = 0; in eth_iface_init()
556 eth->SPECADDR3BOTTOM = 0; in eth_iface_init()
557 eth->SPECADDR4BOTTOM = 0; in eth_iface_init()
560 eth->HASHBOTTOM = 0; in eth_iface_init()
561 eth->HASHTOP = 0; in eth_iface_init()
567 /* Point to locations of TX/RX DMA descriptor lists */ in eth_iface_init()
568 eth->TXQPTR = (uint32_t)dma_tx_desc_tab; in eth_iface_init()
569 eth->RXQPTR = (uint32_t)dma_rx_desc_tab; in eth_iface_init()
572 eth->DMACFG = (eth->DMACFG & ~_ETH_DMACFG_RXBUFSIZE_MASK) | in eth_iface_init()
576 eth->IFCR |= _ETH_IFCR_MASK; in eth_iface_init()
577 eth->TXSTATUS = ETH_TXSTATUS_TXUNDERRUN | ETH_TXSTATUS_TXCMPLT | in eth_iface_init()
581 eth->RXSTATUS = ETH_RXSTATUS_RESPNOTOK | ETH_RXSTATUS_RXOVERRUN | in eth_iface_init()
585 eth->IENS = ETH_IENS_RXCMPLT | in eth_iface_init()
594 eth->DMACFG |= _ETH_DMACFG_AMBABRSTLEN_MASK | in eth_iface_init()
597 eth->DMACFG &= ~ETH_DMACFG_HDRDATASPLITEN; in eth_iface_init()
600 eth->NETWORKCFG |= ETH_NETWORKCFG_FCSREMOVE | in eth_iface_init()
607 eth->NETWORKCFG |= (4 << _ETH_NETWORKCFG_MDCCLKDIV_SHIFT) & in eth_iface_init()
609 eth->NETWORKCTRL |= ETH_NETWORKCTRL_MANPORTEN; in eth_iface_init()
612 result = phy_gecko_init(&cfg->phy); in eth_iface_init()
618 /* Initialise TX/RX semaphores */ in eth_iface_init()
619 k_sem_init(&dev_data->tx_sem, 1, ETH_TX_BUF_COUNT); in eth_iface_init()
620 k_sem_init(&dev_data->rx_sem, 0, K_SEM_MAX_LIMIT); in eth_iface_init()
622 /* Start interruption-poll thread */ in eth_iface_init()
623 k_thread_create(&dev_data->rx_thread, dev_data->rx_thread_stack, in eth_iface_init()
624 K_KERNEL_STACK_SIZEOF(dev_data->rx_thread_stack), in eth_iface_init()