Skip to content

Commit

Permalink
ethernet: esp32: make phy a phandle of the ethernet device
Browse files Browse the repository at this point in the history
Change the eth-phy definition so that the phy is pointed by a phandle
rather than a child node, make the phy device a child of mdio. This
makes more sense from a devicetree hirearchy where the phandles have to
be initialized before the device itself, allows keeping the priorities
in check with CHECK_INIT_PRIORITIES.

(cherry picked from commit d7504ab)

Original-Signed-off-by: Fabio Baltieri <[email protected]>
GitOrigin-RevId: d7504ab
Change-Id: I0277bcc74c124319d644873d555818ffe27d0810
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/zephyr/+/4743846
Commit-Queue: Keith Short <[email protected]>
Reviewed-by: Keith Short <[email protected]>
Tested-by: ChromeOS Prod (Robot) <[email protected]>
Tested-by: Keith Short <[email protected]>
  • Loading branch information
fabiobaltieri authored and Chromeos LUCI committed Aug 3, 2023
1 parent 73f1887 commit b9677d2
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
10 changes: 6 additions & 4 deletions boards/xtensa/esp32_ethernet_kit/esp32_ethernet_kit.dts
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,10 @@
};
};

&eth {
&mdio {
pinctrl-0 = <&mdio_default>;
pinctrl-names = "default";

phy: phy {
compatible = "ethernet-phy";
status = "disabled";
Expand All @@ -124,7 +127,6 @@
};
};

&mdio {
pinctrl-0 = <&mdio_default>;
pinctrl-names = "default";
&eth {
phy-handle = <&phy>;
};
9 changes: 6 additions & 3 deletions drivers/ethernet/eth_esp32.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ struct eth_esp32_dev_data {
struct k_thread rx_thread;
};

static const struct device *eth_esp32_phy_dev = DEVICE_DT_GET(
DT_INST_PHANDLE(0, phy_handle));

static enum ethernet_hw_caps eth_esp32_caps(const struct device *dev)
{
ARG_UNUSED(dev);
Expand Down Expand Up @@ -278,7 +281,6 @@ static void eth_esp32_iface_init(struct net_if *iface)
{
const struct device *dev = net_if_get_device(iface);
struct eth_esp32_dev_data *dev_data = dev->data;
const struct device *phy_dev = DEVICE_DT_GET(DT_INST_CHILD(0, phy));

dev_data->iface = iface;

Expand All @@ -288,8 +290,9 @@ static void eth_esp32_iface_init(struct net_if *iface)

ethernet_init(iface);

if (device_is_ready(phy_dev)) {
phy_link_callback_set(phy_dev, phy_link_state_changed, (void *)dev);
if (device_is_ready(eth_esp32_phy_dev)) {
phy_link_callback_set(eth_esp32_phy_dev, phy_link_state_changed,
(void *)dev);
} else {
LOG_ERR("PHY device not ready");
}
Expand Down
2 changes: 2 additions & 0 deletions dts/bindings/ethernet/espressif,esp32-eth.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,5 @@ properties:
Phy connection type define the physical interface connection between
PHY and MAC. The default value uses Reduced Media-Independent
Interface (RMII) mode.
phy-handle:
required: true

0 comments on commit b9677d2

Please sign in to comment.