1 /* 2 * Copyright 2025 Arduino SA 3 * 4 * SPDX-License-Identifier: Apache-2.0 5 */ 6 7 #include <zephyr/kernel.h> 8 #include <zephyr/device.h> 9 #include <zephyr/drivers/clock_control.h> 10 #include <zephyr/logging/log.h> 11 12 LOG_MODULE_REGISTER(eth_clock, CONFIG_CLOCK_CONTROL_LOG_LEVEL); 13 14 #if DT_NODE_HAS_STATUS_OKAY(DT_NODELABEL(eth)) eth_clock_enable(void)15static int eth_clock_enable(void) 16 { 17 int ret; 18 const struct device *eth_clk_dev = DEVICE_DT_GET(DT_NODELABEL(eth_clock)); 19 20 if (!device_is_ready(eth_clk_dev)) { 21 LOG_ERR("Invalid eth_clock device"); 22 return -ENODEV; 23 } 24 25 ret = clock_control_on(eth_clk_dev, (clock_control_subsys_t)0); 26 if (ret < 0) { 27 LOG_ERR("Failed to enable Ethernet clock, error %d", ret); 28 return ret; 29 } 30 31 return 0; 32 } 33 34 SYS_INIT(eth_clock_enable, POST_KERNEL, CONFIG_CLOCK_CONTROL_PWM_INIT_PRIORITY); 35 #endif 36