xref: /linux/drivers/net/phy/aquantia/aquantia.h (revision a19ce320c379e0519b68178c596e43d1d5dda03b)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /* HWMON driver for Aquantia PHY
3  *
4  * Author: Nikita Yushchenko <nikita.yoush@cogentembedded.com>
5  * Author: Andrew Lunn <andrew@lunn.ch>
6  * Author: Heiner Kallweit <hkallweit1@gmail.com>
7  */
8 
9 #ifndef AQUANTIA_H
10 #define AQUANTIA_H
11 
12 #include <linux/device.h>
13 #include <linux/phy.h>
14 
15 /* Vendor specific 1, MDIO_MMD_VEND1 */
16 #define VEND1_GLOBAL_SC				0x0
17 #define VEND1_GLOBAL_SC_SOFT_RESET		BIT(15)
18 #define VEND1_GLOBAL_SC_LOW_POWER		BIT(11)
19 
20 #define VEND1_GLOBAL_FW_ID			0x0020
21 #define VEND1_GLOBAL_FW_ID_MAJOR		GENMASK(15, 8)
22 #define VEND1_GLOBAL_FW_ID_MINOR		GENMASK(7, 0)
23 
24 #define VEND1_GLOBAL_MAILBOX_INTERFACE1			0x0200
25 #define VEND1_GLOBAL_MAILBOX_INTERFACE1_EXECUTE		BIT(15)
26 #define VEND1_GLOBAL_MAILBOX_INTERFACE1_WRITE		BIT(14)
27 #define VEND1_GLOBAL_MAILBOX_INTERFACE1_CRC_RESET	BIT(12)
28 #define VEND1_GLOBAL_MAILBOX_INTERFACE1_BUSY		BIT(8)
29 
30 #define VEND1_GLOBAL_MAILBOX_INTERFACE2			0x0201
31 #define VEND1_GLOBAL_MAILBOX_INTERFACE3			0x0202
32 #define VEND1_GLOBAL_MAILBOX_INTERFACE3_MSW_ADDR_MASK	GENMASK(15, 0)
33 #define VEND1_GLOBAL_MAILBOX_INTERFACE3_MSW_ADDR(x)	FIELD_PREP(VEND1_GLOBAL_MAILBOX_INTERFACE3_MSW_ADDR_MASK, (u16)((x) >> 16))
34 #define VEND1_GLOBAL_MAILBOX_INTERFACE4			0x0203
35 #define VEND1_GLOBAL_MAILBOX_INTERFACE4_LSW_ADDR_MASK	GENMASK(15, 2)
36 #define VEND1_GLOBAL_MAILBOX_INTERFACE4_LSW_ADDR(x)	FIELD_PREP(VEND1_GLOBAL_MAILBOX_INTERFACE4_LSW_ADDR_MASK, (u16)(x))
37 
38 #define VEND1_GLOBAL_MAILBOX_INTERFACE5			0x0204
39 #define VEND1_GLOBAL_MAILBOX_INTERFACE5_MSW_DATA_MASK	GENMASK(15, 0)
40 #define VEND1_GLOBAL_MAILBOX_INTERFACE5_MSW_DATA(x)	FIELD_PREP(VEND1_GLOBAL_MAILBOX_INTERFACE5_MSW_DATA_MASK, (u16)((x) >> 16))
41 #define VEND1_GLOBAL_MAILBOX_INTERFACE6			0x0205
42 #define VEND1_GLOBAL_MAILBOX_INTERFACE6_LSW_DATA_MASK	GENMASK(15, 0)
43 #define VEND1_GLOBAL_MAILBOX_INTERFACE6_LSW_DATA(x)	FIELD_PREP(VEND1_GLOBAL_MAILBOX_INTERFACE6_LSW_DATA_MASK, (u16)(x))
44 
45 /* The following registers all have similar layouts; first the registers... */
46 #define VEND1_GLOBAL_CFG_10M			0x0310
47 #define VEND1_GLOBAL_CFG_100M			0x031b
48 #define VEND1_GLOBAL_CFG_1G			0x031c
49 #define VEND1_GLOBAL_CFG_2_5G			0x031d
50 #define VEND1_GLOBAL_CFG_5G			0x031e
51 #define VEND1_GLOBAL_CFG_10G			0x031f
52 /* ...and now the fields */
53 #define VEND1_GLOBAL_CFG_SERDES_MODE		GENMASK(2, 0)
54 #define VEND1_GLOBAL_CFG_SERDES_MODE_XFI	0
55 #define VEND1_GLOBAL_CFG_SERDES_MODE_SGMII	3
56 #define VEND1_GLOBAL_CFG_SERDES_MODE_OCSGMII	4
57 #define VEND1_GLOBAL_CFG_SERDES_MODE_XFI5G	6
58 #define VEND1_GLOBAL_CFG_RATE_ADAPT		GENMASK(8, 7)
59 #define VEND1_GLOBAL_CFG_RATE_ADAPT_NONE	0
60 #define VEND1_GLOBAL_CFG_RATE_ADAPT_USX		1
61 #define VEND1_GLOBAL_CFG_RATE_ADAPT_PAUSE	2
62 
63 /* Vendor specific 1, MDIO_MMD_VEND2 */
64 #define VEND1_GLOBAL_CONTROL2			0xc001
65 #define VEND1_GLOBAL_CONTROL2_UP_RUN_STALL_RST	BIT(15)
66 #define VEND1_GLOBAL_CONTROL2_UP_RUN_STALL_OVD	BIT(6)
67 #define VEND1_GLOBAL_CONTROL2_UP_RUN_STALL	BIT(0)
68 
69 #define VEND1_THERMAL_PROV_HIGH_TEMP_FAIL	0xc421
70 #define VEND1_THERMAL_PROV_LOW_TEMP_FAIL	0xc422
71 #define VEND1_THERMAL_PROV_HIGH_TEMP_WARN	0xc423
72 #define VEND1_THERMAL_PROV_LOW_TEMP_WARN	0xc424
73 #define VEND1_THERMAL_STAT1			0xc820
74 #define VEND1_THERMAL_STAT2			0xc821
75 #define VEND1_THERMAL_STAT2_VALID		BIT(0)
76 #define VEND1_GENERAL_STAT1			0xc830
77 #define VEND1_GENERAL_STAT1_HIGH_TEMP_FAIL	BIT(14)
78 #define VEND1_GENERAL_STAT1_LOW_TEMP_FAIL	BIT(13)
79 #define VEND1_GENERAL_STAT1_HIGH_TEMP_WARN	BIT(12)
80 #define VEND1_GENERAL_STAT1_LOW_TEMP_WARN	BIT(11)
81 
82 #define VEND1_GLOBAL_GEN_STAT2			0xc831
83 #define VEND1_GLOBAL_GEN_STAT2_OP_IN_PROG	BIT(15)
84 
85 #define VEND1_GLOBAL_RSVD_STAT1			0xc885
86 #define VEND1_GLOBAL_RSVD_STAT1_FW_BUILD_ID	GENMASK(7, 4)
87 #define VEND1_GLOBAL_RSVD_STAT1_PROV_ID		GENMASK(3, 0)
88 
89 #define VEND1_GLOBAL_RSVD_STAT9			0xc88d
90 #define VEND1_GLOBAL_RSVD_STAT9_MODE		GENMASK(7, 0)
91 #define VEND1_GLOBAL_RSVD_STAT9_1000BT2		0x23
92 
93 #define VEND1_GLOBAL_INT_STD_STATUS		0xfc00
94 #define VEND1_GLOBAL_INT_VEND_STATUS		0xfc01
95 
96 #define VEND1_GLOBAL_INT_STD_MASK		0xff00
97 #define VEND1_GLOBAL_INT_STD_MASK_PMA1		BIT(15)
98 #define VEND1_GLOBAL_INT_STD_MASK_PMA2		BIT(14)
99 #define VEND1_GLOBAL_INT_STD_MASK_PCS1		BIT(13)
100 #define VEND1_GLOBAL_INT_STD_MASK_PCS2		BIT(12)
101 #define VEND1_GLOBAL_INT_STD_MASK_PCS3		BIT(11)
102 #define VEND1_GLOBAL_INT_STD_MASK_PHY_XS1	BIT(10)
103 #define VEND1_GLOBAL_INT_STD_MASK_PHY_XS2	BIT(9)
104 #define VEND1_GLOBAL_INT_STD_MASK_AN1		BIT(8)
105 #define VEND1_GLOBAL_INT_STD_MASK_AN2		BIT(7)
106 #define VEND1_GLOBAL_INT_STD_MASK_GBE		BIT(6)
107 #define VEND1_GLOBAL_INT_STD_MASK_ALL		BIT(0)
108 
109 #define VEND1_GLOBAL_INT_VEND_MASK		0xff01
110 #define VEND1_GLOBAL_INT_VEND_MASK_PMA		BIT(15)
111 #define VEND1_GLOBAL_INT_VEND_MASK_PCS		BIT(14)
112 #define VEND1_GLOBAL_INT_VEND_MASK_PHY_XS	BIT(13)
113 #define VEND1_GLOBAL_INT_VEND_MASK_AN		BIT(12)
114 #define VEND1_GLOBAL_INT_VEND_MASK_GBE		BIT(11)
115 #define VEND1_GLOBAL_INT_VEND_MASK_GLOBAL1	BIT(2)
116 #define VEND1_GLOBAL_INT_VEND_MASK_GLOBAL2	BIT(1)
117 #define VEND1_GLOBAL_INT_VEND_MASK_GLOBAL3	BIT(0)
118 
119 #if IS_REACHABLE(CONFIG_HWMON)
120 int aqr_hwmon_probe(struct phy_device *phydev);
121 #else
122 static inline int aqr_hwmon_probe(struct phy_device *phydev) { return 0; }
123 #endif
124 
125 int aqr_firmware_load(struct phy_device *phydev);
126 
127 #endif /* AQUANTIA_H */
128