Lines Matching +full:mac +full:- +full:s

1 // SPDX-License-Identifier: GPL-2.0-only
14 #include <linux/nvmem-consumer.h>
17 * of_get_phy_mode - Get phy mode for given device_node
21 * The function gets phy interface string from property 'phy-mode' or
22 * 'phy-connection-type'. The index in phy_modes table is set in
24 * PHY_INTERFACE_MODE_NA and an errno is returned, e.g. -ENODEV.
33 err = of_property_read_string(np, "phy-mode", &pm); in of_get_phy_mode()
35 err = of_property_read_string(np, "phy-connection-type", &pm); in of_get_phy_mode()
45 return -ENODEV; in of_get_phy_mode()
53 if (pp && pp->length == ETH_ALEN && is_valid_ether_addr(pp->value)) { in of_get_mac_addr()
54 memcpy(addr, pp->value, ETH_ALEN); in of_get_mac_addr()
57 return -ENODEV; in of_get_mac_addr()
64 const void *mac; in of_get_mac_addr_nvmem() local
72 ret = nvmem_get_mac_address(&pdev->dev, addr); in of_get_mac_addr_nvmem()
73 put_device(&pdev->dev); in of_get_mac_addr_nvmem()
77 cell = of_nvmem_cell_get(np, "mac-address"); in of_get_mac_addr_nvmem()
81 mac = nvmem_cell_read(cell, &len); in of_get_mac_addr_nvmem()
84 if (IS_ERR(mac)) in of_get_mac_addr_nvmem()
85 return PTR_ERR(mac); in of_get_mac_addr_nvmem()
87 if (len != ETH_ALEN || !is_valid_ether_addr(mac)) { in of_get_mac_addr_nvmem()
88 kfree(mac); in of_get_mac_addr_nvmem()
89 return -EINVAL; in of_get_mac_addr_nvmem()
92 memcpy(addr, mac, ETH_ALEN); in of_get_mac_addr_nvmem()
93 kfree(mac); in of_get_mac_addr_nvmem()
100 * @np: Caller's Device Node
101 * @addr: Pointer to a six-byte array for the result
103 * Search the device tree for the best MAC address to use. 'mac-address' is
104 * checked first, because that is supposed to contain to "most recent" MAC
105 * address. If that isn't set, then 'local-mac-address' is checked next,
108 * of the above isn't set, then try to get MAC address from nvmem cell named
109 * 'mac-address'.
113 * MAC address.
115 * All-zero MAC addresses are rejected, because those could be properties that
116 * exist in the device tree, but were not set by U-Boot. For example, the
117 * DTS could define 'mac-address' and 'local-mac-address', with zero MAC
118 * addresses. Some older U-Boots only initialized 'local-mac-address'. In
119 * this case, the real MAC is in 'local-mac-address', and 'mac-address' exists
129 return -ENODEV; in of_get_mac_address()
131 ret = of_get_mac_addr(np, "mac-address", addr); in of_get_mac_address()
135 ret = of_get_mac_addr(np, "local-mac-address", addr); in of_get_mac_address()
149 * @np: Caller's Device Node
152 * Search the device tree for the best MAC address to use.
153 * If found set @dev->dev_addr to that address.