Lines Matching +full:init +full:- +full:mdio +full:- +full:phy
5 * Copyright (c) 2021 IP-Logix Inc.
8 * SPDX-License-Identifier: Apache-2.0
15 #include <zephyr/init.h>
17 #include <zephyr/drivers/mdio.h>
18 #include <zephyr/net/phy.h>
19 #include <zephyr/net/mdio.h>
28 /* PHY Specific Status Register */
39 /* The PHY Debug port address register */
41 /* The PHY Debug port data register */
77 const struct qc_ar8031_config *config = dev->config; in qc_ar8031_read()
80 /* Make sure excessive bits 16-31 are reset */ in qc_ar8031_read()
83 /* Read the PHY register */ in qc_ar8031_read()
84 ret = mdio_read(config->mdio_dev, config->addr, reg_addr, (uint16_t *)data); in qc_ar8031_read()
94 const struct qc_ar8031_config *config = dev->config; in qc_ar8031_write()
97 ret = mdio_write(config->mdio_dev, config->addr, reg_addr, (uint16_t)data); in qc_ar8031_write()
111 return -EIO; in qc_ar8031_mmd_set_device()
114 return -EIO; in qc_ar8031_mmd_set_device()
118 return -EIO; in qc_ar8031_mmd_set_device()
133 return -EIO; in qc_ar8031_mmd_read()
148 return -EIO; in qc_ar8031_mmd_write()
158 const struct qc_ar8031_config *const cfg = dev->config; in qc_ar8031_update_link_state()
159 struct qc_ar8031_data *const data = dev->data; in qc_ar8031_update_link_state()
165 return -EIO; in qc_ar8031_update_link_state()
171 if (link_up == data->state.is_up) { in qc_ar8031_update_link_state()
172 return -EAGAIN; in qc_ar8031_update_link_state()
175 data->state.is_up = link_up; in qc_ar8031_update_link_state()
178 if (data->state.is_up == false) { in qc_ar8031_update_link_state()
183 return -EIO; in qc_ar8031_update_link_state()
191 data->state.speed = LINK_FULL_10BASE_T; in qc_ar8031_update_link_state()
194 data->state.speed = LINK_HALF_10BASE_T; in qc_ar8031_update_link_state()
197 data->state.speed = LINK_FULL_100BASE_T; in qc_ar8031_update_link_state()
200 data->state.speed = LINK_HALF_100BASE_T; in qc_ar8031_update_link_state()
203 data->state.speed = LINK_FULL_1000BASE_T; in qc_ar8031_update_link_state()
206 data->state.speed = LINK_HALF_1000BASE_T; in qc_ar8031_update_link_state()
210 LOG_DBG("PHY (%d) Link speed %s Mb, %s duplex", cfg->addr, in qc_ar8031_update_link_state()
211 PHY_LINK_IS_SPEED_1000M(data->state.speed) in qc_ar8031_update_link_state()
213 : (PHY_LINK_IS_SPEED_100M(data->state.speed) ? "100" : "10"), in qc_ar8031_update_link_state()
214 PHY_LINK_IS_FULL_DUPLEX(data->state.speed) ? "full" : "half"); in qc_ar8031_update_link_state()
221 struct qc_ar8031_data *const data = dev->data; in invoke_link_cb()
224 if (data->cb == NULL) { in invoke_link_cb()
230 data->cb(data->dev, &state, data->cb_data); in invoke_link_cb()
238 const struct device *dev = data->dev; in monitor_work_handler()
241 k_sem_take(&data->sem, K_FOREVER); in monitor_work_handler()
245 k_sem_give(&data->sem); in monitor_work_handler()
253 k_work_reschedule(&data->monitor_work, K_MSEC(CONFIG_PHY_MONITOR_PERIOD)); in monitor_work_handler()
263 return -EIO; in qc_ar8031_cfg_link()
267 return -EIO; in qc_ar8031_cfg_link()
271 return -EIO; in qc_ar8031_cfg_link()
311 return -EIO; in qc_ar8031_cfg_link()
317 return -EIO; in qc_ar8031_cfg_link()
321 return -EIO; in qc_ar8031_cfg_link()
329 struct qc_ar8031_data *const data = dev->data; in qc_ar8031_get_link_state()
331 k_sem_take(&data->sem, K_FOREVER); in qc_ar8031_get_link_state()
333 memcpy(state, &data->state, sizeof(struct phy_link_state)); in qc_ar8031_get_link_state()
335 k_sem_give(&data->sem); in qc_ar8031_get_link_state()
342 struct qc_ar8031_data *const data = dev->data; in qc_ar8031_link_cb_set()
344 data->cb = cb; in qc_ar8031_link_cb_set()
345 data->cb_data = user_data; in qc_ar8031_link_cb_set()
358 const struct qc_ar8031_config *const cfg = dev->config; in qc_ar8031_init()
359 struct qc_ar8031_data *const data = dev->data; in qc_ar8031_init()
364 k_sem_init(&data->sem, 1, 1); in qc_ar8031_init()
366 mdio_bus_enable(cfg->mdio_dev); in qc_ar8031_init()
368 data->state.is_up = false; in qc_ar8031_init()
370 data->dev = dev; in qc_ar8031_init()
371 data->cb = NULL; in qc_ar8031_init()
375 return -EIO; in qc_ar8031_init()
377 } while (reg_value != AR8031_PHY_ID1 && counter-- > 0); in qc_ar8031_init()
379 LOG_ERR("PHY (%d) can't read ID", cfg->addr); in qc_ar8031_init()
380 return -EIO; in qc_ar8031_init()
383 /* Reset PHY */ in qc_ar8031_init()
386 return -EIO; in qc_ar8031_init()
393 return -EIO; in qc_ar8031_init()
397 return -EIO; in qc_ar8031_init()
401 return -EIO; in qc_ar8031_init()
407 return -EIO; in qc_ar8031_init()
411 return -EIO; in qc_ar8031_init()
416 return -EIO; in qc_ar8031_init()
422 return -EIO; in qc_ar8031_init()
426 return -EIO; in qc_ar8031_init()
431 return -EIO; in qc_ar8031_init()
435 if (cfg->enable_eee) { in qc_ar8031_init()
438 return -EIO; in qc_ar8031_init()
443 return -EIO; in qc_ar8031_init()
448 return -EIO; in qc_ar8031_init()
453 if (cfg->fixed_link) { in qc_ar8031_init()
457 return -EIO; in qc_ar8031_init()
462 return -EIO; in qc_ar8031_init()
470 data->state.speed = speed_to_phy_link_speed[cfg->fixed_speed]; in qc_ar8031_init()
471 data->state.is_up = true; in qc_ar8031_init()
478 k_work_init_delayable(&data->monitor_work, monitor_work_handler); in qc_ar8031_init()
480 monitor_work_handler(&data->monitor_work.work); in qc_ar8031_init()