Lines Matching +full:settling +full:- +full:time
2 * Copyright 2023-2024 NXP
5 * Copyright (c) 2021 IP-Logix Inc.
8 * SPDX-License-Identifier: Apache-2.0
85 const struct rt_rtl8211f_config *config = dev->config; in phy_rt_rtl8211f_read()
88 /* Make sure excessive bits 16-31 are reset */ in phy_rt_rtl8211f_read()
92 ret = mdio_read(config->mdio_dev, config->addr, reg_addr, (uint16_t *)data); in phy_rt_rtl8211f_read()
103 const struct rt_rtl8211f_config *config = dev->config; in phy_rt_rtl8211f_write()
106 ret = mdio_write(config->mdio_dev, config->addr, reg_addr, (uint16_t)data); in phy_rt_rtl8211f_write()
116 const struct rt_rtl8211f_config *config = dev->config; in phy_rt_rtl8211f_reset()
121 if (config->reset_gpio.port) { in phy_rt_rtl8211f_reset()
123 ret = gpio_pin_set_dt(&config->reset_gpio, 0); in phy_rt_rtl8211f_reset()
128 /* Hold reset for the minimum time specified by datasheet */ in phy_rt_rtl8211f_reset()
132 ret = gpio_pin_set_dt(&config->reset_gpio, 1); in phy_rt_rtl8211f_reset()
137 /* Wait another 30 ms (circuits settling time) before accessing registers */ in phy_rt_rtl8211f_reset()
147 LOG_ERR("Error writing phy (%d) basic control register", config->addr); in phy_rt_rtl8211f_reset()
151 /* Wait for the minimum reset time specified by datasheet */ in phy_rt_rtl8211f_reset()
158 LOG_ERR("Error reading phy (%d) basic control register", config->addr); in phy_rt_rtl8211f_reset()
170 LOG_ERR("Error reading phy (%d) identifier register 1", config->addr); in phy_rt_rtl8211f_reset()
180 const struct rt_rtl8211f_config *config = dev->config; in phy_rt_rtl8211f_restart_autonegotiation()
187 LOG_ERR("Error reading phy (%d) basic control register", config->addr); in phy_rt_rtl8211f_restart_autonegotiation()
192 LOG_DBG("PHY (%d) is entering autonegotiation sequence", config->addr); in phy_rt_rtl8211f_restart_autonegotiation()
197 LOG_ERR("Error writing phy (%d) basic control register", config->addr); in phy_rt_rtl8211f_restart_autonegotiation()
207 const struct rt_rtl8211f_config *config = dev->config; in phy_rt_rtl8211f_get_link()
208 struct rt_rtl8211f_data *data = dev->data; in phy_rt_rtl8211f_get_link()
212 struct phy_link_state old_state = data->state; in phy_rt_rtl8211f_get_link()
216 ret = k_mutex_lock(&data->mutex, K_FOREVER); in phy_rt_rtl8211f_get_link()
225 LOG_ERR("Error reading phy (%d) specific status register", config->addr); in phy_rt_rtl8211f_get_link()
226 (void)k_mutex_unlock(&data->mutex); in phy_rt_rtl8211f_get_link()
231 (void)k_mutex_unlock(&data->mutex); in phy_rt_rtl8211f_get_link()
267 LOG_INF("PHY %d is %s", config->addr, new_state.is_up ? "up" : "down"); in phy_rt_rtl8211f_get_link()
269 LOG_INF("PHY (%d) Link speed %s Mb, %s duplex", config->addr, in phy_rt_rtl8211f_get_link()
284 const struct rt_rtl8211f_config *config = dev->config; in phy_rt_rtl8211f_cfg_link()
285 struct rt_rtl8211f_data *data = dev->data; in phy_rt_rtl8211f_cfg_link()
291 ret = k_mutex_lock(&data->mutex, K_FOREVER); in phy_rt_rtl8211f_cfg_link()
299 if (!config->interrupt_gpio.port) { in phy_rt_rtl8211f_cfg_link()
300 k_work_cancel_delayable(&data->phy_monitor_work); in phy_rt_rtl8211f_cfg_link()
303 k_work_cancel_delayable(&data->phy_monitor_work); in phy_rt_rtl8211f_cfg_link()
309 LOG_ERR("Error reading phy (%d) advertising register", config->addr); in phy_rt_rtl8211f_cfg_link()
316 LOG_ERR("Error reading phy (%d) 1000Base-T control register", config->addr); in phy_rt_rtl8211f_cfg_link()
342 /* Setup 1000Base-T control register */ in phy_rt_rtl8211f_cfg_link()
352 LOG_ERR("Error writing phy (%d) advertising register", config->addr); in phy_rt_rtl8211f_cfg_link()
356 /* Write capabilities to 1000Base-T control register */ in phy_rt_rtl8211f_cfg_link()
359 LOG_ERR("Error writing phy (%d) 1000Base-T control register", config->addr); in phy_rt_rtl8211f_cfg_link()
371 (void)k_mutex_unlock(&data->mutex); in phy_rt_rtl8211f_cfg_link()
375 if (!config->interrupt_gpio.port) { in phy_rt_rtl8211f_cfg_link()
376 k_work_reschedule(&data->phy_monitor_work, K_MSEC(CONFIG_PHY_MONITOR_PERIOD)); in phy_rt_rtl8211f_cfg_link()
379 k_work_reschedule(&data->phy_monitor_work, K_MSEC(CONFIG_PHY_MONITOR_PERIOD)); in phy_rt_rtl8211f_cfg_link()
388 struct rt_rtl8211f_data *data = dev->data; in phy_rt_rtl8211f_link_cb_set()
390 data->cb = cb; in phy_rt_rtl8211f_link_cb_set()
391 data->cb_data = user_data; in phy_rt_rtl8211f_link_cb_set()
393 phy_rt_rtl8211f_get_link(dev, &data->state); in phy_rt_rtl8211f_link_cb_set()
395 data->cb(dev, &data->state, data->cb_data); in phy_rt_rtl8211f_link_cb_set()
403 const struct device *dev = data->dev; in phy_rt_rtl8211f_clear_interrupt()
404 const struct rt_rtl8211f_config *config = dev->config; in phy_rt_rtl8211f_clear_interrupt()
409 ret = k_mutex_lock(&data->mutex, K_FOREVER); in phy_rt_rtl8211f_clear_interrupt()
418 LOG_ERR("Error reading phy (%d) interrupt status register", config->addr); in phy_rt_rtl8211f_clear_interrupt()
422 (void)k_mutex_unlock(&data->mutex); in phy_rt_rtl8211f_clear_interrupt()
434 ret = k_work_reschedule(&data->phy_monitor_work, K_NO_WAIT); in phy_rt_rtl8211f_interrupt_handler()
446 const struct device *dev = data->dev; in phy_rt_rtl8211f_monitor_work_handler()
448 const struct rt_rtl8211f_config *config = dev->config; in phy_rt_rtl8211f_monitor_work_handler()
454 if (config->interrupt_gpio.port) { in phy_rt_rtl8211f_monitor_work_handler()
464 if (ret == 0 && memcmp(&state, &data->state, sizeof(struct phy_link_state)) != 0) { in phy_rt_rtl8211f_monitor_work_handler()
465 memcpy(&data->state, &state, sizeof(struct phy_link_state)); in phy_rt_rtl8211f_monitor_work_handler()
466 if (data->cb) { in phy_rt_rtl8211f_monitor_work_handler()
467 data->cb(dev, &data->state, data->cb_data); in phy_rt_rtl8211f_monitor_work_handler()
472 if (!config->interrupt_gpio.port) { in phy_rt_rtl8211f_monitor_work_handler()
473 k_work_reschedule(&data->phy_monitor_work, K_MSEC(CONFIG_PHY_MONITOR_PERIOD)); in phy_rt_rtl8211f_monitor_work_handler()
476 k_work_reschedule(&data->phy_monitor_work, K_MSEC(CONFIG_PHY_MONITOR_PERIOD)); in phy_rt_rtl8211f_monitor_work_handler()
482 const struct rt_rtl8211f_config *config = dev->config; in phy_rt_rtl8211f_init()
483 struct rt_rtl8211f_data *data = dev->data; in phy_rt_rtl8211f_init()
487 data->dev = dev; in phy_rt_rtl8211f_init()
489 ret = k_mutex_init(&data->mutex); in phy_rt_rtl8211f_init()
494 mdio_bus_enable(config->mdio_dev); in phy_rt_rtl8211f_init()
498 if (config->reset_gpio.port) { in phy_rt_rtl8211f_init()
499 ret = gpio_pin_configure_dt(&config->reset_gpio, GPIO_OUTPUT_ACTIVE); in phy_rt_rtl8211f_init()
509 LOG_ERR("Failed to reset phy (%d)", config->addr); in phy_rt_rtl8211f_init()
517 LOG_ERR("Error writing phy (%d) page select register", config->addr); in phy_rt_rtl8211f_init()
523 LOG_ERR("Error reading phy (%d) mii control register1", config->addr); in phy_rt_rtl8211f_init()
530 LOG_ERR("Error writing phy (%d) mii control register1", config->addr); in phy_rt_rtl8211f_init()
536 LOG_ERR("Error reading phy (%d) mii control register2", config->addr); in phy_rt_rtl8211f_init()
543 LOG_ERR("Error writing phy (%d) mii control register2", config->addr); in phy_rt_rtl8211f_init()
550 LOG_ERR("Error writing phy (%d) page select register", config->addr); in phy_rt_rtl8211f_init()
554 k_work_init_delayable(&data->phy_monitor_work, phy_rt_rtl8211f_monitor_work_handler); in phy_rt_rtl8211f_init()
557 if (!config->interrupt_gpio.port) { in phy_rt_rtl8211f_init()
558 phy_rt_rtl8211f_monitor_work_handler(&data->phy_monitor_work.work); in phy_rt_rtl8211f_init()
566 LOG_ERR("Error writing phy (%d) page select register", config->addr); in phy_rt_rtl8211f_init()
575 config->addr); in phy_rt_rtl8211f_init()
579 LOG_ERR("Error reading phy (%d) interrupt pin setting register", config->addr); in phy_rt_rtl8211f_init()
585 LOG_ERR("Error writing phy (%d) page select register", config->addr); in phy_rt_rtl8211f_init()
596 ret = gpio_pin_configure_dt(&config->interrupt_gpio, GPIO_INPUT); in phy_rt_rtl8211f_init()
601 gpio_init_callback(&data->gpio_callback, phy_rt_rtl8211f_interrupt_handler, in phy_rt_rtl8211f_init()
602 BIT(config->interrupt_gpio.pin)); in phy_rt_rtl8211f_init()
603 ret = gpio_add_callback_dt(&config->interrupt_gpio, &data->gpio_callback); in phy_rt_rtl8211f_init()
608 ret = gpio_pin_interrupt_configure_dt(&config->interrupt_gpio, GPIO_INT_EDGE_TO_ACTIVE); in phy_rt_rtl8211f_init()
617 LOG_ERR("Error writing phy (%d) page select register", config->addr); in phy_rt_rtl8211f_init()
622 LOG_ERR("Error reading phy (%d) interrupt enable register", config->addr); in phy_rt_rtl8211f_init()
628 LOG_ERR("Error writing phy (%d) interrupt enable register", config->addr); in phy_rt_rtl8211f_init()
634 LOG_ERR("Error writing phy (%d) page select register", config->addr); in phy_rt_rtl8211f_init()
639 phy_rt_rtl8211f_monitor_work_handler(&data->phy_monitor_work.work); in phy_rt_rtl8211f_init()