kernel: bump 5.15 to 5.15.132
[openwrt/openwrt.git] / target / linux / generic / backport-5.15 / 703-07-v5.16-net-phy-add-phy_interface_t-bitmap-support.patch
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
5
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
11 bitmaps
12
13 Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
14 Signed-off-by: David S. Miller <davem@davemloft.net>
15 ---
16 include/linux/phy.h | 34 ++++++++++++++++++++++++++++++++++
17 1 file changed, 34 insertions(+)
18
19 --- a/include/linux/phy.h
20 +++ b/include/linux/phy.h
21 @@ -155,6 +155,40 @@ typedef enum {
22 PHY_INTERFACE_MODE_MAX,
23 } phy_interface_t;
24
25 +/* PHY interface mode bitmap handling */
26 +#define DECLARE_PHY_INTERFACE_MASK(name) \
27 + DECLARE_BITMAP(name, PHY_INTERFACE_MODE_MAX)
28 +
29 +static inline void phy_interface_zero(unsigned long *intf)
30 +{
31 + bitmap_zero(intf, PHY_INTERFACE_MODE_MAX);
32 +}
33 +
34 +static inline bool phy_interface_empty(const unsigned long *intf)
35 +{
36 + return bitmap_empty(intf, PHY_INTERFACE_MODE_MAX);
37 +}
38 +
39 +static inline void phy_interface_and(unsigned long *dst, const unsigned long *a,
40 + const unsigned long *b)
41 +{
42 + bitmap_and(dst, a, b, PHY_INTERFACE_MODE_MAX);
43 +}
44 +
45 +static inline void phy_interface_or(unsigned long *dst, const unsigned long *a,
46 + const unsigned long *b)
47 +{
48 + bitmap_or(dst, a, b, PHY_INTERFACE_MODE_MAX);
49 +}
50 +
51 +static inline void phy_interface_set_rgmii(unsigned long *intf)
52 +{
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);
57 +}
58 +
59 /*
60 * phy_supported_speeds - return all speeds currently supported by a PHY device
61 */