Commit 55f2d72c authored by Bartosz Bilas's avatar Bartosz Bilas Committed by Carles Cufi
Browse files

drivers: eth_esp32: allow selecting ref clk source



In case of boards where REF_CLK signal is not connected
to the GPIO0 by default add the possibility to use
the optional GPIO16/GPIO17 as a REF CLK source.

Signed-off-by: default avatarBartosz Bilas <bartosz.bilas@hotmail.com>
parent 052f0994
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
#include <esp_mac.h>
#include <hal/emac_hal.h>
#include <hal/emac_ll.h>
#include <soc/rtc.h>

#include "eth.h"

@@ -223,8 +224,19 @@ int eth_esp32_initialize(const struct device *dev)

	if (strcmp(phy_connection_type, "rmii") == 0) {
		emac_hal_iomux_init_rmii();
#if DT_INST_NODE_HAS_PROP(0, ref_clk_output_gpios)
		BUILD_ASSERT(DT_INST_GPIO_PIN(0, ref_clk_output_gpios) == 16 ||
			DT_INST_GPIO_PIN(0, ref_clk_output_gpios) == 17,
			"Only GPIO16/17 are allowed as a GPIO REF_CLK source!");
		int ref_clk_gpio = DT_INST_GPIO_PIN(0, ref_clk_output_gpios);

		emac_hal_iomux_rmii_clk_output(ref_clk_gpio);
		emac_ll_clock_enable_rmii_output(dev_data->hal.ext_regs);
		rtc_clk_apll_enable(true, 0, 0, 6, 2);
#else
		emac_hal_iomux_rmii_clk_input();
		emac_ll_clock_enable_rmii_input(dev_data->hal.ext_regs);
#endif
	} else if (strcmp(phy_connection_type, "mii") == 0) {
		emac_hal_iomux_init_mii();
		emac_ll_clock_enable_mii(dev_data->hal.ext_regs);
+5 −0
Original line number Diff line number Diff line
@@ -14,3 +14,8 @@ properties:

  phy-connection-type:
    default: "rmii"

  ref-clk-output-gpios:
    type: phandle-array
    description: |
      GPIO to output RMII Clock.