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

1 // SPDX-License-Identifier: GPL-2.0+
3 * Microchip's LAN865x 10BASE-T1S MAC-PHY driver
15 /* MAC Network Control Register */
20 /* MAC Network Configuration Reg */
26 /* MAC Hash Register Bottom */
28 /* MAC Hash Register Top */
30 /* MAC Specific Addr 1 Bottom Reg */
32 /* MAC Specific Addr 1 Top Reg */
42 static int lan865x_set_hw_macaddr_low_bytes(struct oa_tc6 *tc6, const u8 *mac) in lan865x_set_hw_macaddr_low_bytes() argument
46 regval = (mac[3] << 24) | (mac[2] << 16) | (mac[1] << 8) | mac[0]; in lan865x_set_hw_macaddr_low_bytes()
51 static int lan865x_set_hw_macaddr(struct lan865x_priv *priv, const u8 *mac) in lan865x_set_hw_macaddr() argument
57 /* Configure MAC address low bytes */ in lan865x_set_hw_macaddr()
58 ret = lan865x_set_hw_macaddr_low_bytes(priv->tc6, mac); in lan865x_set_hw_macaddr()
62 /* Prepare and configure MAC address high bytes */ in lan865x_set_hw_macaddr()
63 regval = (mac[5] << 8) | mac[4]; in lan865x_set_hw_macaddr()
64 ret = oa_tc6_write_register(priv->tc6, LAN865X_REG_MAC_H_SADDR1, in lan865x_set_hw_macaddr()
69 /* Restore the old MAC address low bytes from netdev if the new MAC in lan865x_set_hw_macaddr()
70 * address high bytes setting failed. in lan865x_set_hw_macaddr()
72 restore_ret = lan865x_set_hw_macaddr_low_bytes(priv->tc6, in lan865x_set_hw_macaddr()
73 priv->netdev->dev_addr); in lan865x_set_hw_macaddr()
88 struct sockaddr *address = addr; in lan865x_set_mac_address() local
95 if (ether_addr_equal(address->sa_data, netdev->dev_addr)) in lan865x_set_mac_address()
98 ret = lan865x_set_hw_macaddr(priv, address->sa_data); in lan865x_set_mac_address()
135 netdev_for_each_mc_addr(ha, priv->netdev) { in lan865x_set_specific_multicast_addr()
136 u32 bit_num = lan865x_hash(ha->addr); in lan865x_set_specific_multicast_addr()
139 hash_hi |= (1 << (bit_num - BIT(5))); in lan865x_set_specific_multicast_addr()
145 ret = oa_tc6_write_register(priv->tc6, LAN865X_REG_MAC_H_HASH, hash_hi); in lan865x_set_specific_multicast_addr()
147 netdev_err(priv->netdev, "Failed to write reg_hashh: %d\n", in lan865x_set_specific_multicast_addr()
152 ret = oa_tc6_write_register(priv->tc6, LAN865X_REG_MAC_L_HASH, hash_lo); in lan865x_set_specific_multicast_addr()
154 netdev_err(priv->netdev, "Failed to write reg_hashl: %d\n", in lan865x_set_specific_multicast_addr()
165 ret = oa_tc6_write_register(priv->tc6, LAN865X_REG_MAC_H_HASH, in lan865x_set_all_multicast_addr()
168 netdev_err(priv->netdev, "Failed to write reg_hashh: %d\n", in lan865x_set_all_multicast_addr()
173 ret = oa_tc6_write_register(priv->tc6, LAN865X_REG_MAC_L_HASH, in lan865x_set_all_multicast_addr()
176 netdev_err(priv->netdev, "Failed to write reg_hashl: %d\n", in lan865x_set_all_multicast_addr()
186 ret = oa_tc6_write_register(priv->tc6, LAN865X_REG_MAC_H_HASH, 0); in lan865x_clear_all_multicast_addr()
188 netdev_err(priv->netdev, "Failed to write reg_hashh: %d\n", in lan865x_clear_all_multicast_addr()
193 ret = oa_tc6_write_register(priv->tc6, LAN865X_REG_MAC_L_HASH, 0); in lan865x_clear_all_multicast_addr()
195 netdev_err(priv->netdev, "Failed to write reg_hashl: %d\n", in lan865x_clear_all_multicast_addr()
208 if (priv->netdev->flags & IFF_PROMISC) { in lan865x_multicast_work_handler()
213 } else if (priv->netdev->flags & IFF_ALLMULTI) { in lan865x_multicast_work_handler()
221 } else if (!netdev_mc_empty(priv->netdev)) { in lan865x_multicast_work_handler()
230 /* Enabling local mac address only */ in lan865x_multicast_work_handler()
234 ret = oa_tc6_write_register(priv->tc6, LAN865X_REG_MAC_NET_CFG, regval); in lan865x_multicast_work_handler()
236 netdev_err(priv->netdev, "Failed to enable promiscuous/multicast/normal mode: %d\n", in lan865x_multicast_work_handler()
244 schedule_work(&priv->multicast_work); in lan865x_set_multicast_list()
252 return oa_tc6_start_xmit(priv->tc6, skb); in lan865x_send_packet()
259 if (oa_tc6_read_register(priv->tc6, LAN865X_REG_MAC_NET_CTL, &regval)) in lan865x_hw_disable()
260 return -ENODEV; in lan865x_hw_disable()
264 if (oa_tc6_write_register(priv->tc6, LAN865X_REG_MAC_NET_CTL, regval)) in lan865x_hw_disable()
265 return -ENODEV; in lan865x_hw_disable()
276 phy_stop(netdev->phydev); in lan865x_net_close()
290 if (oa_tc6_read_register(priv->tc6, LAN865X_REG_MAC_NET_CTL, &regval)) in lan865x_hw_enable()
291 return -ENODEV; in lan865x_hw_enable()
295 if (oa_tc6_write_register(priv->tc6, LAN865X_REG_MAC_NET_CTL, regval)) in lan865x_hw_enable()
296 return -ENODEV; in lan865x_hw_enable()
312 phy_start(netdev->phydev); in lan865x_net_open()
333 return -ENOMEM; in lan865x_probe()
336 priv->netdev = netdev; in lan865x_probe()
337 priv->spi = spi; in lan865x_probe()
339 INIT_WORK(&priv->multicast_work, lan865x_multicast_work_handler); in lan865x_probe()
341 priv->tc6 = oa_tc6_init(spi, netdev); in lan865x_probe()
342 if (!priv->tc6) { in lan865x_probe()
343 ret = -ENODEV; in lan865x_probe()
357 …chip.com/downloads/aemDocuments/documents/AIS/ProductDocuments/Errata/LAN8650-1-Errata-80001075.pdf in lan865x_probe()
359 ret = oa_tc6_zero_align_receive_frame_enable(priv->tc6); in lan865x_probe()
361 dev_err(&spi->dev, "Failed to set ZARFE: %d\n", ret); in lan865x_probe()
365 /* Get the MAC address from the SPI device tree node */ in lan865x_probe()
366 if (device_get_ethdev_address(&spi->dev, netdev)) in lan865x_probe()
369 ret = lan865x_set_hw_macaddr(priv, netdev->dev_addr); in lan865x_probe()
371 dev_err(&spi->dev, "Failed to configure MAC: %d\n", ret); in lan865x_probe()
375 netdev->if_port = IF_PORT_10BASET; in lan865x_probe()
376 netdev->irq = spi->irq; in lan865x_probe()
377 netdev->netdev_ops = &lan865x_netdev_ops; in lan865x_probe()
378 netdev->ethtool_ops = &lan865x_ethtool_ops; in lan865x_probe()
382 dev_err(&spi->dev, "Register netdev failed (ret = %d)", ret); in lan865x_probe()
389 oa_tc6_exit(priv->tc6); in lan865x_probe()
391 free_netdev(priv->netdev); in lan865x_probe()
399 cancel_work_sync(&priv->multicast_work); in lan865x_remove()
400 unregister_netdev(priv->netdev); in lan865x_remove()
401 oa_tc6_exit(priv->tc6); in lan865x_remove()
402 free_netdev(priv->netdev); in lan865x_remove()
427 MODULE_DESCRIPTION(DRV_NAME " 10Base-T1S MACPHY Ethernet Driver");