Skip to contentSkip to conversation

net: phy: aquantia: add hwmon support

PATCH In review Heiner Kallweit 3 participants 6 messages Feb 25, 2019

Subsystems (3)
lore
Share & tools
lore

Heiner Kallweit

author maintainer
#0 lore raw

v3 cover net: phy: aquantia: add hwmon support

This series adds HWMON support for the temperature sensor and the related alarms on the 107/108/109 chips.

v2:
- remove struct aqr_priv
- rename header file to aquantia.h
v3:
- add conditional compiling of aquantia_hwmon.c
- improve converting sensor register values to/from long
- add helper aqr_hwmon_test_bit

Heiner Kallweit (2):
net: phy: aquantia: rename aquantia.c to aquantia_main.c
net: phy: aquantia: add hwmon support

 drivers/net/phy/Makefile                      |   4 +
 drivers/net/phy/aquantia.h                    |  16 ++
 drivers/net/phy/aquantia_hwmon.c              | 250 ++++++++++++++++++
 .../net/phy/{aquantia.c => aquantia_main.c}   |   4 +
 4 files changed, 274 insertions(+)
 create mode 100644 drivers/net/phy/aquantia.h
 create mode 100644 drivers/net/phy/aquantia_hwmon.c
 rename drivers/net/phy/{aquantia.c => aquantia_main.c} (99%)
Signature · 1 line
2.20.1
author maintainer
#1 lore raw

PATCH v3 1/2 net: phy: aquantia: rename aquantia.c to aquantia_main.c

Rename aquantia.c to aquantia_main.c to be prepared for adding new functionality to separate source code files.

---
 drivers/net/phy/Makefile                        | 1 +
 drivers/net/phy/{aquantia.c => aquantia_main.c} | 0
 2 files changed, 1 insertion(+)
 rename drivers/net/phy/{aquantia.c => aquantia_main.c} (100%)
drivers/net/phy/Makefile +1 -0
index 5805c0b7d..b0845adaf 100644
@@ -45,6 +45,7 @@ sfp-obj-$(CONFIG_SFP)		+= sfp-bus.o
 obj-y				+= $(sfp-obj-y) $(sfp-obj-m)
 
 obj-$(CONFIG_AMD_PHY)		+= amd.o
+aquantia-objs			+= aquantia_main.o
 obj-$(CONFIG_AQUANTIA_PHY)	+= aquantia.o
 obj-$(CONFIG_ASIX_PHY)		+= asix.o
 obj-$(CONFIG_AT803X_PHY)	+= at803x.o
drivers/net/phy/aquantia_main.c renamed from drivers/net/phy/aquantia.c +0 -0
similarity index 100%
rename from drivers/net/phy/aquantia.c
rename to drivers/net/phy/aquantia_main.c
Signature · 1 line
2.20.1
author maintainer
#3 lore raw

PATCH v3 2/2 net: phy: aquantia: add hwmon support

In reply to Heiner Kallweit

This adds HWMON support for the temperature sensor and the related alarms on the 107/108/109 chips. This patch is based on work from Nikita and Andrew. I added:
- support for changing alarm thresholds via sysfs
- move HWMON code to a separate source file to improve maintainability
- smaller changes like using IS_REACHABLE instead of ifdef (avoids problems if PHY driver is built in and HWMON is a module)

v2:
- remove struct aqr_priv
- rename header file to aquantia.h
v3:
- add conditional compiling of aquantia_hwmon.c
- improve converting sensor register values to/from long
- add helper aqr_hwmon_test_bit

---
 drivers/net/phy/Makefile         |   3 +
 drivers/net/phy/aquantia.h       |  16 ++
 drivers/net/phy/aquantia_hwmon.c | 250 +++++++++++++++++++++++++++++++
 drivers/net/phy/aquantia_main.c  |   4 +
 4 files changed, 273 insertions(+)
 create mode 100644 drivers/net/phy/aquantia.h
 create mode 100644 drivers/net/phy/aquantia_hwmon.c
drivers/net/phy/Makefile +3 -0
index b0845adaf..73e9670ef 100644
@@ -46,6 +46,9 @@ obj-y				+= $(sfp-obj-y) $(sfp-obj-m)
 
 obj-$(CONFIG_AMD_PHY)		+= amd.o
 aquantia-objs			+= aquantia_main.o
+ifdef CONFIG_HWMON
+aquantia-objs			+= aquantia_hwmon.o
+endif
 obj-$(CONFIG_AQUANTIA_PHY)	+= aquantia.o
 obj-$(CONFIG_ASIX_PHY)		+= asix.o
 obj-$(CONFIG_AT803X_PHY)	+= at803x.o
drivers/net/phy/aquantia.h new file +16 -0
new file mode 100644
index 000000000..5a16caab7
@@ -0,0 +1,16 @@
+/* SPDX-License-Identifier: GPL-2.0
+ * HWMON driver for Aquantia PHY
+ *
+ * Author: Nikita Yushchenko <[email protected]>
+ * Author: Andrew Lunn <[email protected]>
+ * Author: Heiner Kallweit <[email protected]>
+ */
+
+#include <linux/device.h>
+#include <linux/phy.h>
+
+#if IS_REACHABLE(CONFIG_HWMON)
+int aqr_hwmon_probe(struct phy_device *phydev);
+#else
+static inline int aqr_hwmon_probe(struct phy_device *phydev) { return 0; }
+#endif
drivers/net/phy/aquantia_hwmon.c new file +250 -0

250 lines not on this page · raw message

drivers/net/phy/aquantia_main.c +4 -0
index 0f0eb5682..37218e5d7 100644
@@ -12,6 +12,8 @@
 #include <linux/delay.h>
 #include <linux/phy.h>
 
+#include "aquantia.h"
+
 #define PHY_ID_AQ1202	0x03a1b445
 #define PHY_ID_AQ2104	0x03a1b460
 #define PHY_ID_AQR105	0x03a1b4a2
@@ -231,6 +233,7 @@ static struct phy_driver aqr_driver[] = {
 	.name		= "Aquantia AQR107",
 	.aneg_done	= genphy_c45_aneg_done,
 	.get_features	= genphy_c45_pma_read_abilities,
+	.probe		= aqr_hwmon_probe,
 	.config_aneg    = aqr_config_aneg,
 	.config_intr	= aqr_config_intr,
 	.ack_interrupt	= aqr_ack_interrupt,
@@ -241,6 +244,7 @@ static struct phy_driver aqr_driver[] = {
 	.name		= "Aquantia AQCS109",
 	.aneg_done	= genphy_c45_aneg_done,
 	.get_features	= genphy_c45_pma_read_abilities,
+	.probe		= aqr_hwmon_probe,
 	.config_init	= aqcs109_config_init,
 	.config_aneg    = aqr_config_aneg,
 	.config_intr	= aqr_config_intr,
Signature · 1 line
2.20.1
Reviewed-by on v3 2/2
#4 lore raw
Quoted 16 lines · Heiner Kallweit

This adds HWMON support for the temperature sensor and the related alarms on the 107/108/109 chips. This patch is based on work from Nikita and Andrew. I added:
- support for changing alarm thresholds via sysfs
- move HWMON code to a separate source file to improve maintainability
- smaller changes like using IS_REACHABLE instead of ifdef (avoids problems if PHY driver is built in and HWMON is a module)

v2:
- remove struct aqr_priv
- rename header file to aquantia.h
v3:
- add conditional compiling of aquantia_hwmon.c
- improve converting sensor register values to/from long
- add helper aqr_hwmon_test_bit

Quoted 3 lines
Signature · 1 line
Florian
maintainer
#5 lore raw
In reply to Heiner Kallweit

From: Heiner Kallweit <[email protected]>
Date: Mon, 25 Feb 2019 19:52:14 +0100

Quoted 10 lines

This series adds HWMON support for the temperature sensor and the related alarms on the 107/108/109 chips.

v2:
- remove struct aqr_priv
- rename header file to aquantia.h
v3:
- add conditional compiling of aquantia_hwmon.c
- improve converting sensor register values to/from long
- add helper aqr_hwmon_test_bit

Series applied, thanks Heiner.