Lines Matching +full:link +full:- +full:speed

2  * Copyright 2023-2024 NXP
5 * Copyright (c) 2021 IP-Logix Inc.
8 * SPDX-License-Identifier: Apache-2.0
65 const struct mc_ksz8081_config *config = dev->config; in phy_mc_ksz8081_read()
68 /* Make sure excessive bits 16-31 are reset */ in phy_mc_ksz8081_read()
71 ret = mdio_read(config->mdio_dev, config->addr, reg_addr, (uint16_t *)data); in phy_mc_ksz8081_read()
82 const struct mc_ksz8081_config *config = dev->config; in phy_mc_ksz8081_write()
85 ret = mdio_write(config->mdio_dev, config->addr, reg_addr, (uint16_t)data); in phy_mc_ksz8081_write()
95 const struct mc_ksz8081_config *config = dev->config; in phy_mc_ksz8081_autonegotiate()
104 LOG_ERR("Error reading phy (%d) basic control register", config->addr); in phy_mc_ksz8081_autonegotiate()
109 LOG_DBG("PHY (%d) is entering autonegotiation sequence", config->addr); in phy_mc_ksz8081_autonegotiate()
115 LOG_ERR("Error writing phy (%d) basic control register", config->addr); in phy_mc_ksz8081_autonegotiate()
121 if (timeout-- == 0) { in phy_mc_ksz8081_autonegotiate()
122 LOG_DBG("PHY (%d) autonegotiation timed out", config->addr); in phy_mc_ksz8081_autonegotiate()
123 /* The value -ETIMEDOUT can be returned by PHY read/write functions, so in phy_mc_ksz8081_autonegotiate()
124 * return -ENETDOWN instead to distinguish link timeout from PHY timeout. in phy_mc_ksz8081_autonegotiate()
126 return -ENETDOWN; in phy_mc_ksz8081_autonegotiate()
132 LOG_ERR("Error reading phy (%d) basic status register", config->addr); in phy_mc_ksz8081_autonegotiate()
137 LOG_DBG("PHY (%d) autonegotiation completed", config->addr); in phy_mc_ksz8081_autonegotiate()
145 const struct mc_ksz8081_config *config = dev->config; in phy_mc_ksz8081_get_link()
146 struct mc_ksz8081_data *data = dev->data; in phy_mc_ksz8081_get_link()
151 struct phy_link_state old_state = data->state; in phy_mc_ksz8081_get_link()
154 ret = k_mutex_lock(&data->mutex, K_FOREVER); in phy_mc_ksz8081_get_link()
160 /* Read link state */ in phy_mc_ksz8081_get_link()
163 LOG_ERR("Error reading phy (%d) basic status register", config->addr); in phy_mc_ksz8081_get_link()
164 k_mutex_unlock(&data->mutex); in phy_mc_ksz8081_get_link()
167 state->is_up = bmsr & MII_BMSR_LINK_STATUS; in phy_mc_ksz8081_get_link()
169 if (!state->is_up) { in phy_mc_ksz8081_get_link()
170 k_mutex_unlock(&data->mutex); in phy_mc_ksz8081_get_link()
177 LOG_ERR("Error reading phy (%d) advertising register", config->addr); in phy_mc_ksz8081_get_link()
178 k_mutex_unlock(&data->mutex); in phy_mc_ksz8081_get_link()
182 /* Read link partner capability */ in phy_mc_ksz8081_get_link()
185 LOG_ERR("Error reading phy (%d) link partner register", config->addr); in phy_mc_ksz8081_get_link()
186 k_mutex_unlock(&data->mutex); in phy_mc_ksz8081_get_link()
191 k_mutex_unlock(&data->mutex); in phy_mc_ksz8081_get_link()
196 state->speed = LINK_FULL_100BASE_T; in phy_mc_ksz8081_get_link()
198 state->speed = LINK_HALF_100BASE_T; in phy_mc_ksz8081_get_link()
200 state->speed = LINK_FULL_10BASE_T; in phy_mc_ksz8081_get_link()
202 state->speed = LINK_HALF_10BASE_T; in phy_mc_ksz8081_get_link()
204 ret = -EIO; in phy_mc_ksz8081_get_link()
209 LOG_DBG("PHY %d is %s", config->addr, state->is_up ? "up" : "down"); in phy_mc_ksz8081_get_link()
210 if (state->is_up) { in phy_mc_ksz8081_get_link()
211 LOG_DBG("PHY (%d) Link speed %s Mb, %s duplex\n", config->addr, in phy_mc_ksz8081_get_link()
212 (PHY_LINK_IS_SPEED_100M(state->speed) ? "100" : "10"), in phy_mc_ksz8081_get_link()
213 PHY_LINK_IS_FULL_DUPLEX(state->speed) ? "full" : "half"); in phy_mc_ksz8081_get_link()
227 const struct mc_ksz8081_config *config = dev->config; in phy_mc_ksz8081_static_cfg()
240 if (config->phy_iface == KSZ8081_RMII) { in phy_mc_ksz8081_static_cfg()
256 if (config->phy_iface == KSZ8081_RMII) { in phy_mc_ksz8081_static_cfg()
273 const struct mc_ksz8081_config *config = dev->config; in phy_mc_ksz8081_reset()
275 struct mc_ksz8081_data *data = dev->data; in phy_mc_ksz8081_reset()
279 ret = k_mutex_lock(&data->mutex, K_FOREVER); in phy_mc_ksz8081_reset()
286 if (!config->reset_gpio.port) { in phy_mc_ksz8081_reset()
291 ret = gpio_pin_set_dt(&config->reset_gpio, 0); in phy_mc_ksz8081_reset()
300 ret = gpio_pin_set_dt(&config->reset_gpio, 1); in phy_mc_ksz8081_reset()
320 k_mutex_unlock(&data->mutex); in phy_mc_ksz8081_reset()
327 const struct mc_ksz8081_config *config = dev->config; in phy_mc_ksz8081_cfg_link()
328 struct mc_ksz8081_data *data = dev->data; in phy_mc_ksz8081_cfg_link()
334 ret = k_mutex_lock(&data->mutex, K_FOREVER); in phy_mc_ksz8081_cfg_link()
341 k_work_cancel_delayable(&data->phy_monitor_work); in phy_mc_ksz8081_cfg_link()
352 LOG_ERR("Error reading phy (%d) advertising register", config->addr); in phy_mc_ksz8081_cfg_link()
381 LOG_ERR("Error writing phy (%d) advertising register", config->addr); in phy_mc_ksz8081_cfg_link()
387 if (ret && (ret != -ENETDOWN)) { in phy_mc_ksz8081_cfg_link()
392 /* Get link status */ in phy_mc_ksz8081_cfg_link()
395 if (ret == 0 && memcmp(&state, &data->state, sizeof(struct phy_link_state)) != 0) { in phy_mc_ksz8081_cfg_link()
396 memcpy(&data->state, &state, sizeof(struct phy_link_state)); in phy_mc_ksz8081_cfg_link()
397 if (data->cb) { in phy_mc_ksz8081_cfg_link()
398 data->cb(dev, &data->state, data->cb_data); in phy_mc_ksz8081_cfg_link()
403 LOG_INF("PHY %d is %s", config->addr, data->state.is_up ? "up" : "down"); in phy_mc_ksz8081_cfg_link()
404 if (data->state.is_up) { in phy_mc_ksz8081_cfg_link()
405 LOG_INF("PHY (%d) Link speed %s Mb, %s duplex\n", config->addr, in phy_mc_ksz8081_cfg_link()
406 (PHY_LINK_IS_SPEED_100M(data->state.speed) ? "100" : "10"), in phy_mc_ksz8081_cfg_link()
407 PHY_LINK_IS_FULL_DUPLEX(data->state.speed) ? "full" : "half"); in phy_mc_ksz8081_cfg_link()
412 k_mutex_unlock(&data->mutex); in phy_mc_ksz8081_cfg_link()
415 k_work_reschedule(&data->phy_monitor_work, in phy_mc_ksz8081_cfg_link()
424 struct mc_ksz8081_data *data = dev->data; in phy_mc_ksz8081_link_cb_set()
426 data->cb = cb; in phy_mc_ksz8081_link_cb_set()
427 data->cb_data = user_data; in phy_mc_ksz8081_link_cb_set()
429 phy_mc_ksz8081_get_link(dev, &data->state); in phy_mc_ksz8081_link_cb_set()
431 data->cb(dev, &data->state, data->cb_data); in phy_mc_ksz8081_link_cb_set()
441 const struct device *dev = data->dev; in phy_mc_ksz8081_monitor_work_handler()
447 if (rc == 0 && memcmp(&state, &data->state, sizeof(struct phy_link_state)) != 0) { in phy_mc_ksz8081_monitor_work_handler()
448 memcpy(&data->state, &state, sizeof(struct phy_link_state)); in phy_mc_ksz8081_monitor_work_handler()
449 if (data->cb) { in phy_mc_ksz8081_monitor_work_handler()
450 data->cb(dev, &data->state, data->cb_data); in phy_mc_ksz8081_monitor_work_handler()
455 k_work_reschedule(&data->phy_monitor_work, K_MSEC(CONFIG_PHY_MONITOR_PERIOD)); in phy_mc_ksz8081_monitor_work_handler()
460 const struct mc_ksz8081_config *config = dev->config; in phy_mc_ksz8081_init()
461 struct mc_ksz8081_data *data = dev->data; in phy_mc_ksz8081_init()
464 data->dev = dev; in phy_mc_ksz8081_init()
466 ret = k_mutex_init(&data->mutex); in phy_mc_ksz8081_init()
471 mdio_bus_enable(config->mdio_dev); in phy_mc_ksz8081_init()
474 if (!config->interrupt_gpio.port) { in phy_mc_ksz8081_init()
479 ret = gpio_pin_configure_dt(&config->interrupt_gpio, GPIO_OUTPUT_ACTIVE); in phy_mc_ksz8081_init()
488 if (config->reset_gpio.port) { in phy_mc_ksz8081_init()
489 ret = gpio_pin_configure_dt(&config->reset_gpio, GPIO_OUTPUT_ACTIVE); in phy_mc_ksz8081_init()
502 k_work_init_delayable(&data->phy_monitor_work, in phy_mc_ksz8081_init()