Lines Matching +full:half +full:- +full:duplex

1 /* ENC424J600 Stand-alone Ethernet Controller with SPI
7 * SPDX-License-Identifier: Apache-2.0
29 const struct enc424j600_config *config = dev->config; in enc424j600_write_sbc()
40 spi_write_dt(&config->spi, &tx); in enc424j600_write_sbc()
46 const struct enc424j600_config *config = dev->config; in enc424j600_write_sfru()
62 spi_write_dt(&config->spi, &tx); in enc424j600_write_sfru()
68 const struct enc424j600_config *config = dev->config; in enc424j600_read_sfru()
90 if (!spi_transceive_dt(&config->spi, &tx, &rx)) { in enc424j600_read_sfru()
101 const struct enc424j600_config *config = dev->config; in enc424j600_modify_sfru()
117 spi_write_dt(&config->spi, &tx); in enc424j600_modify_sfru()
162 const struct enc424j600_config *config = dev->config; in enc424j600_write_mem()
179 if (spi_write_dt(&config->spi, &tx)) { in enc424j600_write_mem()
188 const struct enc424j600_config *config = dev->config; in enc424j600_read_mem()
213 if (spi_transceive_dt(&config->spi, &tx, &rx)) { in enc424j600_read_mem()
226 k_sem_give(&context->int_sem); in enc424j600_gpio_callback()
288 LOG_INF("full duplex"); in enc424j600_setup_mac()
296 LOG_INF("half duplex"); in enc424j600_setup_mac()
310 struct enc424j600_runtime *context = dev->data; in enc424j600_tx()
317 k_sem_take(&context->tx_rx_sem, K_FOREVER); in enc424j600_tx()
322 for (frag = pkt->frags; frag; frag = frag->frags) { in enc424j600_tx()
323 enc424j600_write_mem(dev, ENC424J600_NBC_WGPDATA, frag->data, in enc424j600_tx()
324 frag->len); in enc424j600_tx()
342 k_sem_give(&context->tx_rx_sem); in enc424j600_tx()
349 struct enc424j600_runtime *context = dev->data; in enc424j600_rx()
350 const struct enc424j600_config *config = dev->config; in enc424j600_rx()
358 k_sem_take(&context->tx_rx_sem, K_FOREVER); in enc424j600_rx()
361 context->next_pkt_ptr); in enc424j600_rx()
375 context->next_pkt_ptr = sys_get_le16(&info[0]); in enc424j600_rx()
379 context->next_pkt_ptr, frm_len, status); in enc424j600_rx()
381 frm_len -= 4; in enc424j600_rx()
384 eth_stats_update_errors_rx(context->iface); in enc424j600_rx()
389 pkt = net_pkt_rx_alloc_with_buffer(context->iface, frm_len, in enc424j600_rx()
391 K_MSEC(config->timeout)); in enc424j600_rx()
394 eth_stats_update_errors_rx(context->iface); in enc424j600_rx()
398 pkt_buf = pkt->buffer; in enc424j600_rx()
405 data_ptr = pkt_buf->data; in enc424j600_rx()
422 frm_len -= spi_frame_len; in enc424j600_rx()
423 pkt_buf = pkt_buf->frags; in enc424j600_rx()
426 if (net_recv_data(context->iface, pkt) < 0) { in enc424j600_rx()
431 if (context->next_pkt_ptr == ENC424J600_RXSTART) { in enc424j600_rx()
432 tmp = ENC424J600_RXEND - 1; in enc424j600_rx()
435 tmp = context->next_pkt_ptr - 2; in enc424j600_rx()
440 k_sem_give(&context->tx_rx_sem); in enc424j600_rx()
452 k_sem_take(&context->int_sem, K_FOREVER); in enc424j600_rx_thread()
454 enc424j600_write_sbc(context->dev, ENC424J600_1BC_CLREIE); in enc424j600_rx_thread()
455 enc424j600_read_sfru(context->dev, ENC424J600_SFRX_EIRL, &eir); in enc424j600_rx_thread()
456 enc424j600_read_sfru(context->dev, in enc424j600_rx_thread()
463 enc424j600_rx(context->dev); in enc424j600_rx_thread()
464 enc424j600_read_sfru(context->dev, in enc424j600_rx_thread()
471 enc424j600_clear_sfru(context->dev, in enc424j600_rx_thread()
476 enc424j600_setup_mac(context->dev); in enc424j600_rx_thread()
477 net_eth_carrier_on(context->iface); in enc424j600_rx_thread()
481 if (context->iface_initialized) { in enc424j600_rx_thread()
482 net_eth_carrier_off(context->iface); in enc424j600_rx_thread()
496 enc424j600_write_sbc(context->dev, ENC424J600_1BC_SETEIE); in enc424j600_rx_thread()
506 struct enc424j600_runtime *context = dev->data; in enc424j600_get_config()
511 return -ENOTSUP; in enc424j600_get_config()
514 k_sem_take(&context->tx_rx_sem, K_FOREVER); in enc424j600_get_config()
522 config->l.link_100bt = true; in enc424j600_get_config()
525 config->l.link_10bt = true; in enc424j600_get_config()
528 rc = -EINVAL; in enc424j600_get_config()
531 /* Query if half or full duplex */ in enc424j600_get_config()
534 /* Assume operating in half duplex mode */ in enc424j600_get_config()
535 config->full_duplex = false; in enc424j600_get_config()
538 /* Operating in full duplex mode */ in enc424j600_get_config()
539 config->full_duplex = true; in enc424j600_get_config()
543 k_sem_give(&context->tx_rx_sem); in enc424j600_get_config()
558 struct enc424j600_runtime *context = dev->data; in enc424j600_iface_init()
560 net_if_set_link_addr(iface, context->mac_address, in enc424j600_iface_init()
561 sizeof(context->mac_address), in enc424j600_iface_init()
563 context->iface = iface; in enc424j600_iface_init()
567 context->iface_initialized = true; in enc424j600_iface_init()
572 struct enc424j600_runtime *context = dev->data; in enc424j600_start_device()
575 if (!context->suspended) { in enc424j600_start_device()
580 k_sem_take(&context->tx_rx_sem, K_FOREVER); in enc424j600_start_device()
593 context->suspended = false; in enc424j600_start_device()
594 k_sem_give(&context->tx_rx_sem); in enc424j600_start_device()
602 struct enc424j600_runtime *context = dev->data; in enc424j600_stop_device()
605 if (context->suspended) { in enc424j600_stop_device()
610 k_sem_take(&context->tx_rx_sem, K_FOREVER); in enc424j600_stop_device()
633 context->suspended = true; in enc424j600_stop_device()
634 k_sem_give(&context->tx_rx_sem); in enc424j600_stop_device()
651 const struct enc424j600_config *config = dev->config; in enc424j600_init()
652 struct enc424j600_runtime *context = dev->data; in enc424j600_init()
656 context->dev = dev; in enc424j600_init()
659 if (!spi_is_ready_dt(&config->spi)) { in enc424j600_init()
660 LOG_ERR("SPI master port %s not ready", config->spi.bus->name); in enc424j600_init()
661 return -EINVAL; in enc424j600_init()
665 if (!gpio_is_ready_dt(&config->interrupt)) { in enc424j600_init()
666 LOG_ERR("GPIO port %s not ready", config->interrupt.port->name); in enc424j600_init()
667 return -EINVAL; in enc424j600_init()
670 if (gpio_pin_configure_dt(&config->interrupt, GPIO_INPUT)) { in enc424j600_init()
672 config->interrupt.pin); in enc424j600_init()
673 return -EINVAL; in enc424j600_init()
676 gpio_init_callback(&(context->gpio_cb), enc424j600_gpio_callback, in enc424j600_init()
677 BIT(config->interrupt.pin)); in enc424j600_init()
679 if (gpio_add_callback(config->interrupt.port, &(context->gpio_cb))) { in enc424j600_init()
680 return -EINVAL; in enc424j600_init()
683 gpio_pin_interrupt_configure_dt(&config->interrupt, in enc424j600_init()
691 retries--; in enc424j600_init()
696 return -EIO; in enc424j600_init()
703 retries--; in enc424j600_init()
708 return -EIO; in enc424j600_init()
717 return -EIO; in enc424j600_init()
735 (ENC424J600_RXEND - 1)); in enc424j600_init()
736 context->next_pkt_ptr = ENC424J600_RXSTART; in enc424j600_init()
738 /* Disable user-defined buffer */ in enc424j600_init()
740 (ENC424J600_RXEND - 1)); in enc424j600_init()
742 (ENC424J600_RXEND - 1)); in enc424j600_init()
746 context->mac_address[0] = tmp; in enc424j600_init()
747 context->mac_address[1] = tmp >> 8; in enc424j600_init()
750 context->mac_address[2] = tmp; in enc424j600_init()
751 context->mac_address[3] = tmp >> 8; in enc424j600_init()
754 context->mac_address[4] = tmp; in enc424j600_init()
755 context->mac_address[5] = tmp >> 8; in enc424j600_init()
767 /* Start interruption-poll thread */ in enc424j600_init()
768 k_thread_create(&context->thread, context->thread_stack, in enc424j600_init()
777 context->suspended = false; in enc424j600_init()