Lines Matching +full:phy +full:- +full:poll +full:-

5  * SPDX-License-Identifier: Apache-2.0
16 #include <zephyr/net/phy.h>
30 /* TJA1103 PHY identifier */
33 /* MMD30 - Device status register */
37 /* Shared - PHY control register */
40 /* Shared - PHY status register */
44 /* Shared - PHY functional IRQ masked status register */
48 /* Shared -PHY functional IRQ source & enable registers */
81 const struct phy_tja1103_config *const cfg = dev->config; in phy_tja1103_c22_read()
83 return mdio_read(cfg->mdio, cfg->phy_addr, reg, val); in phy_tja1103_c22_read()
88 const struct phy_tja1103_config *const cfg = dev->config; in phy_tja1103_c22_write()
90 return mdio_write(cfg->mdio, cfg->phy_addr, reg, val); in phy_tja1103_c22_write()
96 const struct phy_tja1103_config *cfg = dev->config; in phy_tja1103_c45_write()
98 return mdio_write_c45(cfg->mdio, cfg->phy_addr, devad, reg, val); in phy_tja1103_c45_write()
104 const struct phy_tja1103_config *cfg = dev->config; in phy_tja1103_c45_read()
106 return mdio_read_c45(cfg->mdio, cfg->phy_addr, devad, reg, val); in phy_tja1103_c45_read()
111 const struct phy_tja1103_config *cfg = dev->config; in phy_tja1103_reg_read()
114 mdio_bus_enable(cfg->mdio); in phy_tja1103_reg_read()
118 mdio_bus_disable(cfg->mdio); in phy_tja1103_reg_read()
125 const struct phy_tja1103_config *cfg = dev->config; in phy_tja1103_reg_write()
128 mdio_bus_enable(cfg->mdio); in phy_tja1103_reg_write()
132 mdio_bus_disable(cfg->mdio); in phy_tja1103_reg_write()
142 return -EIO; in phy_tja1103_id()
148 return -EIO; in phy_tja1103_id()
158 struct phy_tja1103_data *const data = dev->data; in update_link_state()
163 return -EIO; in update_link_state()
168 /* Let workqueue re-schedule and re-check if the in update_link_state()
171 if (data->state.is_up == link_up) { in update_link_state()
172 return -EAGAIN; in update_link_state()
175 data->state.is_up = link_up; in update_link_state()
182 struct phy_tja1103_data *const data = dev->data; in phy_tja1103_get_link_state()
183 const struct phy_tja1103_config *const cfg = dev->config; in phy_tja1103_get_link_state()
186 k_sem_take(&data->sem, K_FOREVER); in phy_tja1103_get_link_state()
191 if (cfg->gpio_interrupt.port != NULL) { in phy_tja1103_get_link_state()
195 memcpy(state, &data->state, sizeof(struct phy_link_state)); in phy_tja1103_get_link_state()
197 k_sem_give(&data->sem); in phy_tja1103_get_link_state()
204 struct phy_tja1103_data *const data = dev->data; in invoke_link_cb()
207 if (data->cb == NULL) { in invoke_link_cb()
216 data->cb(dev, &state, data->cb_data); in invoke_link_cb()
224 const struct device *dev = data->dev; in monitor_work_handler()
227 k_sem_take(&data->sem, K_FOREVER); in monitor_work_handler()
231 k_sem_give(&data->sem); in monitor_work_handler()
239 k_work_reschedule(&data->monitor_work, K_MSEC(CONFIG_PHY_MONITOR_PERIOD)); in monitor_work_handler()
248 struct phy_tja1103_data *const data = dev->data; in phy_tja1103_irq_offload_thread()
253 k_sem_take(&data->offload_sem, K_FOREVER); in phy_tja1103_irq_offload_thread()
282 k_sem_give(&data->offload_sem); in phy_tja1103_handle_irq()
287 struct phy_tja1103_data *const data = dev->data; in phy_tja1103_cfg_irq_poll()
288 const struct phy_tja1103_config *const cfg = dev->config; in phy_tja1103_cfg_irq_poll()
291 if (cfg->gpio_interrupt.port != NULL) { in phy_tja1103_cfg_irq_poll()
292 if (!gpio_is_ready_dt(&cfg->gpio_interrupt)) { in phy_tja1103_cfg_irq_poll()
294 cfg->gpio_interrupt.port->name); in phy_tja1103_cfg_irq_poll()
298 ret = gpio_pin_configure_dt(&cfg->gpio_interrupt, GPIO_INPUT); in phy_tja1103_cfg_irq_poll()
304 gpio_init_callback(&(data->phy_tja1103_int_callback), phy_tja1103_handle_irq, in phy_tja1103_cfg_irq_poll()
305 BIT(cfg->gpio_interrupt.pin)); in phy_tja1103_cfg_irq_poll()
308 ret = gpio_add_callback(cfg->gpio_interrupt.port, &data->phy_tja1103_int_callback); in phy_tja1103_cfg_irq_poll()
321 ret = gpio_pin_interrupt_configure_dt(&cfg->gpio_interrupt, GPIO_INT_EDGE_FALLING); in phy_tja1103_cfg_irq_poll()
327 /* PHY initialized, IRQ configured, now initialize the BH handler */ in phy_tja1103_cfg_irq_poll()
328 k_thread_create(&data->irq_thread, data->irq_thread_stack, in phy_tja1103_cfg_irq_poll()
332 k_thread_name_set(&data->irq_thread, "phy_tja1103_irq_offload"); in phy_tja1103_cfg_irq_poll()
335 k_work_init_delayable(&data->monitor_work, monitor_work_handler); in phy_tja1103_cfg_irq_poll()
337 monitor_work_handler(&data->monitor_work.work); in phy_tja1103_cfg_irq_poll()
349 return -ENOTSUP; in phy_tja1103_cfg_link()
354 const struct phy_tja1103_config *const cfg = dev->config; in phy_tja1103_init()
355 struct phy_tja1103_data *const data = dev->data; in phy_tja1103_init()
360 data->dev = dev; in phy_tja1103_init()
361 data->cb = NULL; in phy_tja1103_init()
362 data->state.is_up = false; in phy_tja1103_init()
363 data->state.speed = LINK_FULL_100BASE_T; in phy_tja1103_init()
369 LOG_ERR("Unable to obtain PHY ID for device 0x%x", cfg->phy_addr); in phy_tja1103_init()
370 return -ENODEV; in phy_tja1103_init()
393 if (cfg->master_slave == 1) { in phy_tja1103_init()
395 } else if (cfg->master_slave == 2) { in phy_tja1103_init()
417 /* Configure interrupt or poll mode for reporting link changes */ in phy_tja1103_init()
425 struct phy_tja1103_data *const data = dev->data; in phy_tja1103_link_cb_set()
427 data->cb = cb; in phy_tja1103_link_cb_set()
428 data->cb_data = user_data; in phy_tja1103_link_cb_set()