Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

net: netcp: Fixes efuse mac addr swap on k2e and k2l

On some of the K2E and K2L platforms, the two DWORDs in
efuse occupied by the pre-programmed mac address for
slave port 1 are swapped. To workaround this issue,
this patch adds a new define NETCP_EFUSE_ADDR_SWAP (2)
which signifies the occurrence of such swapping so that
the driver can take proper action. The flag can be
enabled in the corresponding netcp interface dts binding
as efuse-mac = <2> under the corresponding netcp
interface node.

Signed-off-by: WingMan Kwok <w-kwok2@ti.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

WingMan Kwok and committed by
David S. Miller
71382bc0 5a4c3552

+18 -3
+5 -1
Documentation/devicetree/bindings/net/keystone-netcp.txt
··· 130 130 131 131 Optional properties: 132 132 - efuse-mac: If this is 1, then the MAC address for the interface is 133 - obtained from the device efuse mac address register 133 + obtained from the device efuse mac address register. 134 + If this is 2, the two DWORDs occupied by the MAC address 135 + are swapped. The netcp driver will swap the two DWORDs 136 + back to the proper order when this property is set to 2 137 + when it obtains the mac address from efuse. 134 138 - local-mac-address: the driver is designed to use the of_get_mac_address api 135 139 only if efuse-mac is 0. When efuse-mac is 0, the MAC 136 140 address is obtained from local-mac-address. If this
+13 -2
drivers/net/ethernet/ti/netcp_core.c
··· 51 51 NETIF_MSG_PKTDATA | NETIF_MSG_TX_QUEUED | \ 52 52 NETIF_MSG_RX_STATUS) 53 53 54 + #define NETCP_EFUSE_ADDR_SWAP 2 55 + 54 56 #define knav_queue_get_id(q) knav_queue_device_control(q, \ 55 57 KNAV_QUEUE_GET_ID, (unsigned long)NULL) 56 58 ··· 174 172 } 175 173 176 174 /* Read the e-fuse value as 32 bit values to be endian independent */ 177 - static int emac_arch_get_mac_addr(char *x, void __iomem *efuse_mac) 175 + static int emac_arch_get_mac_addr(char *x, void __iomem *efuse_mac, u32 swap) 178 176 { 179 177 unsigned int addr0, addr1; 180 178 181 179 addr1 = readl(efuse_mac + 4); 182 180 addr0 = readl(efuse_mac); 181 + 182 + switch (swap) { 183 + case NETCP_EFUSE_ADDR_SWAP: 184 + addr0 = addr1; 185 + addr1 = readl(efuse_mac); 186 + break; 187 + default: 188 + break; 189 + } 183 190 184 191 x[0] = (addr1 & 0x0000ff00) >> 8; 185 192 x[1] = addr1 & 0x000000ff; ··· 1913 1902 goto quit; 1914 1903 } 1915 1904 1916 - emac_arch_get_mac_addr(efuse_mac_addr, efuse); 1905 + emac_arch_get_mac_addr(efuse_mac_addr, efuse, efuse_mac); 1917 1906 if (is_valid_ether_addr(efuse_mac_addr)) 1918 1907 ether_addr_copy(ndev->dev_addr, efuse_mac_addr); 1919 1908 else