1 From 8e20f591f204f8db7f1182918f8e2285d3f589e0 Mon Sep 17 00:00:00 2001
2 From: "Russell King (Oracle)" <rmk+kernel@armlinux.org.uk>
3 Date: Tue, 26 Oct 2021 11:06:01 +0100
4 Subject: [PATCH] net: phy: add phy_interface_t bitmap support
6 Add support for a bitmap for phy interface modes, which includes:
7 - a macro to declare the interface bitmap
8 - an inline helper to zero the interface bitmap
9 - an inline helper to detect an empty interface bitmap
10 - inline helpers to do a bitwise AND and OR operations on two interface
13 Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
14 Signed-off-by: David S. Miller <davem@davemloft.net>
16 include/linux/phy.h | 34 ++++++++++++++++++++++++++++++++++
17 1 file changed, 34 insertions(+)
19 --- a/include/linux/phy.h
20 +++ b/include/linux/phy.h
21 @@ -155,6 +155,40 @@ typedef enum {
22 PHY_INTERFACE_MODE_MAX,
25 +/* PHY interface mode bitmap handling */
26 +#define DECLARE_PHY_INTERFACE_MASK(name) \
27 + DECLARE_BITMAP(name, PHY_INTERFACE_MODE_MAX)
29 +static inline void phy_interface_zero(unsigned long *intf)
31 + bitmap_zero(intf, PHY_INTERFACE_MODE_MAX);
34 +static inline bool phy_interface_empty(const unsigned long *intf)
36 + return bitmap_empty(intf, PHY_INTERFACE_MODE_MAX);
39 +static inline void phy_interface_and(unsigned long *dst, const unsigned long *a,
40 + const unsigned long *b)
42 + bitmap_and(dst, a, b, PHY_INTERFACE_MODE_MAX);
45 +static inline void phy_interface_or(unsigned long *dst, const unsigned long *a,
46 + const unsigned long *b)
48 + bitmap_or(dst, a, b, PHY_INTERFACE_MODE_MAX);
51 +static inline void phy_interface_set_rgmii(unsigned long *intf)
53 + __set_bit(PHY_INTERFACE_MODE_RGMII, intf);
54 + __set_bit(PHY_INTERFACE_MODE_RGMII_ID, intf);
55 + __set_bit(PHY_INTERFACE_MODE_RGMII_RXID, intf);
56 + __set_bit(PHY_INTERFACE_MODE_RGMII_TXID, intf);
60 * phy_supported_speeds - return all speeds currently supported by a PHY device