Lines Matching +full:local +full:- +full:mac +full:- +full:address

1 // SPDX-License-Identifier: GPL-2.0-only
15 #include <linux/nvmem-consumer.h>
18 * of_get_phy_mode - Get phy mode for given device_node
22 * The function gets phy interface string from property 'phy-mode' or
23 * 'phy-connection-type'. The index in phy_modes table is set in
25 * PHY_INTERFACE_MODE_NA and an errno is returned, e.g. -ENODEV.
34 err = of_property_read_string(np, "phy-mode", &pm); in of_get_phy_mode()
36 err = of_property_read_string(np, "phy-connection-type", &pm); in of_get_phy_mode()
46 return -ENODEV; in of_get_phy_mode()
54 if (pp && pp->length == ETH_ALEN && is_valid_ether_addr(pp->value)) { in of_get_mac_addr()
55 memcpy(addr, pp->value, ETH_ALEN); in of_get_mac_addr()
58 return -ENODEV; in of_get_mac_addr()
65 const void *mac; in of_get_mac_address_nvmem() local
73 ret = nvmem_get_mac_address(&pdev->dev, addr); in of_get_mac_address_nvmem()
74 put_device(&pdev->dev); in of_get_mac_address_nvmem()
78 cell = of_nvmem_cell_get(np, "mac-address"); in of_get_mac_address_nvmem()
82 mac = nvmem_cell_read(cell, &len); in of_get_mac_address_nvmem()
85 if (IS_ERR(mac)) in of_get_mac_address_nvmem()
86 return PTR_ERR(mac); in of_get_mac_address_nvmem()
88 if (len != ETH_ALEN || !is_valid_ether_addr(mac)) { in of_get_mac_address_nvmem()
89 kfree(mac); in of_get_mac_address_nvmem()
90 return -EINVAL; in of_get_mac_address_nvmem()
93 memcpy(addr, mac, ETH_ALEN); in of_get_mac_address_nvmem()
94 kfree(mac); in of_get_mac_address_nvmem()
103 * @addr: Pointer to a six-byte array for the result
105 * Search the device tree for the best MAC address to use. 'mac-address' is
106 * checked first, because that is supposed to contain to "most recent" MAC
107 * address. If that isn't set, then 'local-mac-address' is checked next,
108 * because that is the default address. If that isn't set, then the obsolete
109 * 'address' is checked, just in case we're using an old device tree. If any
110 * of the above isn't set, then try to get MAC address from nvmem cell named
111 * 'mac-address'.
113 * Note that the 'address' property is supposed to contain a virtual address of
115 * MAC address.
117 * All-zero MAC addresses are rejected, because those could be properties that
118 * exist in the device tree, but were not set by U-Boot. For example, the
119 * DTS could define 'mac-address' and 'local-mac-address', with zero MAC
120 * addresses. Some older U-Boots only initialized 'local-mac-address'. In
121 * this case, the real MAC is in 'local-mac-address', and 'mac-address' exists
131 return -ENODEV; in of_get_mac_address()
133 ret = of_get_mac_addr(np, "mac-address", addr); in of_get_mac_address()
137 ret = of_get_mac_addr(np, "local-mac-address", addr); in of_get_mac_address()
141 ret = of_get_mac_addr(np, "address", addr); in of_get_mac_address()
152 * @dev: Pointer to netdevice which address will be updated
154 * Search the device tree for the best MAC address to use.
155 * If found set @dev->dev_addr to that address.
158 * the best address is determined.