hwmon: (msi_mystic_light) Add support for additional MSI motherboards
Subsystems (2)
Guenter Roeck
maintainercover hwmon: (msi_mystic_light) Add support for additional MSI motherboards
This series extends the msi_mystic_light hwmon driver to support voltage monitoring on three MSI 500- and 600-series motherboards:
- MSI MAG B550M MORTAR MAX WIFI (MS-7C94, USB ID 1462:7c94)
- MSI MAG B650 TOMAHAWK WIFI (MS-7D75, USB ID 1462:7d75)
- MSI MAG B650M MORTAR WIFI (MS-7D76, USB ID 1462:7d76)
Unlike the 800-series MS-7E61 motherboard initially supported by the driver, which exposes voltage readings synchronously via a HID_REQ_GET_REPORT request on feature report 0xf0, the Mystic Light controllers on these 500- and 600-series boards require sending an output report to request sensor data and subsequently deliver the sensor readings asynchronously via a HID raw event.
Patch 1 rearranges structures and per-board definitions so board-specific read callbacks can be added without forward declarations.
Patch 2 drops redundant hid_hw_power() calls around sensor report reads, since the HID device is already kept open for the lifetime of the driver binding.
Patch 3 introduces a per-board read_report() callback in struct msi_ml_board.
Patch 4 adds the output-report/raw-event read implementation, board definitions, DMI/USB ID entries, and documentation for MS-7C94, MS-7D75, and MS-7D76.
Guenter Roeck (4):
hwmon: (msi_mystic_light) Rearrange code to simplify adding per-board
read functions
hwmon: (msi_mystic_light) Stop calling hid_hw_power()
hwmon: (msi_mystic_light) Make sensor read function board specific
hwmon: (msi_mystic_light) Add support for additional boards
Documentation/hwmon/msi_mystic_light.rst | 59 +++++- drivers/hwmon/msi_mystic_light.c | 222 ++++++++++++++++++----- 2 files changed, 227 insertions(+), 54 deletions(-)
Signature · 1 line
2.56.0
Guenter Roeck
maintainerPATCH 1/4 hwmon: (msi_mystic_light) Rearrange code to simplify adding per-board read functions
Currently, struct msi_ml_board, the per-board channel definitions, and msi_ml_dmi_table[] are placed at the top of the file ahead of struct msi_ml_data and the driver's operational functions.
Upcoming support for MSI 500- and 600-series motherboards requires a board-specific sensor read callback in struct msi_ml_board that takes a pointer to struct msi_ml_data, as well as referencing board-specific read functions from the per-board struct msi_ml_board initializers.
Move struct msi_ml_board below struct msi_ml_data, move the static msi_ml_board pointer above msi_ml_probe(), and relocate the per-board configuration data and DMI match table to the bottom of the file next to msi_ml_table[]. This avoids forward declarations of struct msi_ml_data and the per-board read callbacks in subsequent changes.
No functional change.
--- drivers/hwmon/msi_mystic_light.c | 80 ++++++++++++++++---------------- 1 file changed, 41 insertions(+), 39 deletions(-)
drivers/hwmon/msi_mystic_light.c +41 -39
@@ -44,45 +44,6 @@#define MSI_ML_MAX_IN 3#define MSI_ML_CACHE_TIME HZ -struct msi_ml_board { -int num_in; -const char *const *in_label; -/* little endian u16 in mV, offset at most MSI_ML_SENSOR_REPORT_SIZE - 2 */ -const u8 *in_offset; -}; - -/* MAG B850M MORTAR WIFI (MS-7E61) */ -static const char *const msi_ml_7e61_in_label[] = { -"CPU 1P8" ,"CHIP Core" ,"VDD MISC" , -}; - -static const u8 msi_ml_7e61_in_offset[] = {23 ,17 ,25 }; - -static_assert (ARRAY_SIZE (msi_ml_7e61_in_label) == -ARRAY_SIZE (msi_ml_7e61_in_offset)); -static_assert (ARRAY_SIZE (msi_ml_7e61_in_label) <=MSI_ML_MAX_IN ); - -static const struct msi_ml_board msi_ml_7e61 = { - .num_in =ARRAY_SIZE (msi_ml_7e61_in_label), - .in_label = msi_ml_7e61_in_label, - .in_offset = msi_ml_7e61_in_offset, -}; - -static const struct dmi_system_id msi_ml_dmi_table[]__initconst = { - { - .matches = { -DMI_MATCH (DMI_BOARD_VENDOR ,"Micro-Star International" ), -DMI_MATCH (DMI_BOARD_NAME ,"MS-7E61" ), - }, - .driver_data = (void *)&msi_ml_7e61, - }, - { } -}; -MODULE_DEVICE_TABLE (dmi, msi_ml_dmi_table); - -/* Board matched by DMI, set once before the HID driver is registered */ -static const struct msi_ml_board *msi_ml_board; -struct msi_ml_data {struct hid_device *hdev;struct device *hwmon_dev;
@@ -93,6 +54,13 @@ struct msi_ml_data {u64 updated;/* jiffies of the last successful read */ }; +struct msi_ml_board { +int num_in; +const char *const *in_label; +/* little endian u16 in mV, offset at most MSI_ML_SENSOR_REPORT_SIZE - 2 */ +const u8 *in_offset; +}; +/* * Read the sensor report. Called from probe before the hwmon device is * registered, and afterwards only from the hwmon read callback, which the
@@ -199,6 +167,9 @@ static const struct hwmon_chip_info msi_ml_chip_info = { .info = msi_ml_info, }; +/* Board matched by DMI, set once before the HID driver is registered */ +static const struct msi_ml_board *msi_ml_board; +static int msi_ml_probe (struct hid_device *hdev,const struct hid_device_id *id) {struct msi_ml_data *priv;
@@ -285,6 +256,37 @@ static void msi_ml_remove(struct hid_device *hdev)hid_hw_stop (hdev); } +/* Per-board data */ + +/* MAG B850M MORTAR WIFI (MS-7E61) */ +static const char *const msi_ml_7e61_in_label[] = { +"CPU 1P8" ,"CHIP Core" ,"VDD MISC" , +}; + +static const u8 msi_ml_7e61_in_offset[] = {23 ,17 ,25 }; + +static_assert (ARRAY_SIZE (msi_ml_7e61_in_label) == +ARRAY_SIZE (msi_ml_7e61_in_offset)); +static_assert (ARRAY_SIZE (msi_ml_7e61_in_label) <=MSI_ML_MAX_IN ); + +static const struct msi_ml_board msi_ml_7e61 = { + .num_in =ARRAY_SIZE (msi_ml_7e61_in_label), + .in_label = msi_ml_7e61_in_label, + .in_offset = msi_ml_7e61_in_offset, +}; + +static const struct dmi_system_id msi_ml_dmi_table[]__initconst = { + { + .matches = { +DMI_MATCH (DMI_BOARD_VENDOR ,"Micro-Star International" ), +DMI_MATCH (DMI_BOARD_NAME ,"MS-7E61" ), + }, + .driver_data = (void *)&msi_ml_7e61, + }, + { } +}; +MODULE_DEVICE_TABLE (dmi, msi_ml_dmi_table); +static const struct hid_device_id msi_ml_table[] = { {HID_USB_DEVICE (USB_VENDOR_ID_MSI_MB ,USB_PRODUCT_ID_MYSTIC_LIGHT ) }, { }
Signature · 1 line
2.45.2
Guenter Roeck
maintainerPATCH 2/4 hwmon: (msi_mystic_light) Stop calling hid_hw_power()
In reply to Guenter Roeckmsi_ml_read_report() currently wraps hid_hw_raw_request() with hid_hw_power(..., PM_HINT_FULLON) and hid_hw_power(..., PM_HINT_NORMAL) to prevent USB autosuspend during the feature report transfer.
However, msi_ml_probe() already calls hid_hw_open() and keeps the HID device open for the entire lifetime of the driver binding so its interrupt IN endpoint remains actively polled. Because the device is kept open and remote wakeup is not enabled on this controller, USB autosuspend is already inhibited while the driver is bound. Consistent with other hwmon HID drivers, explicit per-request hid_hw_power() calls are unnecessary.
Drop the redundant hid_hw_power() calls to simplify the report read path.
--- drivers/hwmon/msi_mystic_light.c | 8 -------- 1 file changed, 8 deletions(-)
drivers/hwmon/msi_mystic_light.c +0 -8
@@ -76,17 +76,9 @@ static int msi_ml_read_report(struct msi_ml_data *priv)memset (buf,0 ,MSI_ML_SENSOR_REPORT_SIZE ); buf[0 ] =MSI_ML_SENSOR_REPORT_ID ; -/* Make sure the device is not autosuspended during the request */ - ret =hid_hw_power (priv->hdev,PM_HINT_FULLON ); -if (ret <0 ) -return ret; - ret =hid_hw_raw_request (priv->hdev,MSI_ML_SENSOR_REPORT_ID , buf,MSI_ML_SENSOR_REPORT_SIZE ,HID_FEATURE_REPORT ,HID_REQ_GET_REPORT ); - -hid_hw_power (priv->hdev,PM_HINT_NORMAL ); -if (ret <0 )return ret;if (ret !=MSI_ML_SENSOR_REPORT_SIZE )
Signature · 1 line
2.45.2
Guenter Roeck
maintainerPATCH 3/4 hwmon: (msi_mystic_light) Make sensor read function board specific
In reply to Guenter RoeckMystic Light controllers on different generations of MSI motherboards use different HID communication mechanisms to retrieve voltage sensor data. While 800-series motherboards expose sensor readings directly via a synchronous HID_REQ_GET_REPORT request on feature report 0xf0, older 500- and 600-series motherboards require requesting sensor data via an output report and receiving the response asynchronously as an input event.
Add a read_report() callback to struct msi_ml_board, rename the existing implementation to msi_ml_read_report_7e61() for MS-7E61, and turn msi_ml_read_report() into a dispatch wrapper so probe and hwmon read paths remain board-independent.
--- drivers/hwmon/msi_mystic_light.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
drivers/hwmon/msi_mystic_light.c +8 -1
@@ -59,6 +59,7 @@ struct msi_ml_board {const char *const *in_label;/* little endian u16 in mV, offset at most MSI_ML_SENSOR_REPORT_SIZE - 2 */ const u8 *in_offset; +int (*read_report)(struct msi_ml_data *priv); };/*
@@ -67,7 +68,7 @@ struct msi_ml_board {* hwmon core serializes. No additional locking is needed for the buffer * and the cached values. */ -static int msi_ml_read_report (struct msi_ml_data *priv) +static int msi_ml_read_report_7e61 (struct msi_ml_data *priv) {const struct msi_ml_board *board = priv->board;u8 *buf = priv->buf;
@@ -98,6 +99,11 @@ static int msi_ml_read_report(struct msi_ml_data *priv)return 0 ; } +static int msi_ml_read_report (struct msi_ml_data *priv) +{ +return priv->board->read_report (priv); +} +static umode_t msi_ml_is_visible (const void *data,enum hwmon_sensor_types type,u32 attr,int channel)
@@ -265,6 +271,7 @@ static const struct msi_ml_board msi_ml_7e61 = { .num_in = ARRAY_SIZE(msi_ml_7e61_in_label), .in_label = msi_ml_7e61_in_label, .in_offset = msi_ml_7e61_in_offset, + .read_report = msi_ml_read_report_7e61, };static const struct dmi_system_id msi_ml_dmi_table[]__initconst = {
Signature · 1 line
2.45.2
Guenter Roeck
maintainerPATCH 4/4 hwmon: (msi_mystic_light) Add support for additional boards
In reply to Guenter RoeckAdd voltage monitoring support for three MSI 500- and 600-series motherboards using USB vendor ID 0x1462:
- MAG B550M MORTAR MAX WIFI (MS-7C94, USB ID 1462:7c94):
CPU VDDP, PROM Core
- MAG B650 TOMAHAWK WIFI (MS-7D75, USB ID 1462:7d75):
CPU 1P8, CHIP Core, VDD MISC
- MAG B650M MORTAR WIFI (MS-7D76, USB ID 1462:7d76):
CPU 1P8, CHIP Core, VDD MISC
Unlike the 800-series MS-7E61 controller, which returns sensor data synchronously via HID_REQ_GET_REPORT on feature report 0xf0, the controllers on these boards require sending a 64-byte output report (report ID 0xfa, command 0xa0, page 0x01 0xfc) via hid_hw_output_report(), after which the controller reports the sensor readings asynchronously via an interrupt IN transfer handled by the HID raw_event callback.
Implement msi_ml_read_report_7c94() and msi_ml_raw_event() synchronized with a completion and spinlock:
- Initialize the completion in the completed state in msi_ml_probe() so unsolicited raw events are ignored when no read is in progress.
- Call hid_device_io_start() in msi_ml_probe() before the initial sensor check so raw events are delivered during probe, and stop I/O on the probe error path.
- Reinitialize the completion before sending the output report, parse the voltage channels in msi_ml_raw_event() when a matching response arrives while a request is pending, and wait up to 500 ms for completion.
Update Documentation/hwmon/msi_mystic_light.rst with the new USB IDs, communication protocol description, and per-board channel tables.
--- Documentation/hwmon/msi_mystic_light.rst | 59 +++++++++-- drivers/hwmon/msi_mystic_light.c | 125 +++++++++++++++++++++++ 2 files changed, 178 insertions(+), 6 deletions(-)
Documentation/hwmon/msi_mystic_light.rst +53 -6
@@ -5,6 +5,15 @@ Kernel driver msi_mystic_light Supported devices: +* MSI Mystic Light USB controller (USB ID 1462:7c94) on MSI + MAG B550M MORTAR MAX WIFI (MS-7C94) + +* MSI Mystic Light USB controller (USB ID 1462:7d75) on MSI + MAG B650 TOMAHAWK WIFI (MS-7D75) + +* MSI Mystic Light USB controller (USB ID 1462:7d76) on MSI + MAG B650M MORTAR WIFI (MS-7D76) + * MSI Mystic Light USB controller (USB ID 0db0:0076) on these MSI 800-series motherboards:
@@ -15,7 +24,7 @@ Author: Tomasz Bojanowski <[email protected]> Description ----------- -On MSI 800-series motherboards the RGB LED headers ("Mystic Light") are +On various MSI series motherboards the RGB LED headers ("Mystic Light") are driven by a microcontroller attached over USB. The controller also measures a few voltage rails that are not monitored by the Super I/O chip (see nct6683). This driver reports these voltages.
@@ -31,11 +40,17 @@ the report cannot be read or does not have the expected format, the driver does not bind to the device. Only the rails that return a reading are exposed. -The driver never writes to the controller. The only request it sends is -a read of HID feature report 0xf0. While the driver is bound, the device -is kept open, so its interrupt endpoint is polled as it is with the -vendor software. The hidraw interface remains available, so user space -tools that control the LEDs keep working. +On 500- and 600-series motherboards, the driver requests sensor data with +an output report. Sensor data is subsequently reported by the controller +with a raw event. + +On 800-series motherboards, the driver never writes to the controller. +The only request it sends is a read of HID feature report 0xf0. + +While the driver is bound, the device is kept open, so its interrupt endpoint +is polled as it is with the vendor software. The hidraw interface remains +available, so user space tools that control the LEDs keep working. + Usage Notes -----------
@@ -52,6 +67,38 @@ in[0-2]_input Voltage in millivolts in[0-2]_label Rail name =============== ========================================================= +MSI MAG B550M MORTAR MAX WIFI (MS-7C94) +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +======= ========= ======================================== +Channel Label Typical value +======= ========= ======================================== +in0 CPU VDDP varies (may be 0 on systems with no APU) +in1 PROM Core 1.04 V +======= ========= ======================================== + +MSI MAG B650 TOMAHAWK WIFI (MS-7D75) +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +======= ========= ========================== +Channel Label Typical value +======= ========= ========================== +in0 CPU 1P8 1.80 V +in1 CHIP Core 1.04 V +in2 VDD MISC 1.10 V +======= ========= ========================== + +MSI MAG B650M MORTAR WIFI (MS-7D76) +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +======= ========= ========================== +Channel Label Typical value +======= ========= ========================== +in0 CPU 1P8 1.80 V +in1 CHIP Core 1.04 V +in2 VDD MISC 1.10 V +======= ========= ========================== + MSI MAG B850M MORTAR WIFI (MS-7E61) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/hwmon/msi_mystic_light.c +125 -0
196 lines not on this page · raw message
Signature · 1 line
2.45.2
Hi Guenter,
Tested on the MS-7E61 with the series applied on top of hwmon-next. The readings are the same as before.
This was my first driver, and working on it with you was a very pleasant experience. Thank you for the reviews and for adding support for the older boards so quickly.
Thanks,
Tomasz