Commit 952f7d10 authored by Hans de Goede's avatar Hans de Goede Committed by Jiri Kosina
Browse files

AMD_SFH: Add sensor_mask module parameter

Add a sensor_mask module parameter which can be used to override the
sensor-mask read from the activestatus bits of the AMD_P2C_MSG3
registers. Some BIOS-es do not program the activestatus bits, leading
to the AMD-SFH driver not registering any HID devices even though the
laptop in question does actually have sensors.

While at it also fix the wrong indentation of the MAGNO_EN define.

BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=199715
BugLink: https://bugzilla.redhat.com/show_bug.cgi?id=1651886


Fixes: 4f567b9f ("SFH: PCIe driver to add support of AMD sensor fusion hub")
Suggested-by: default avatarRichard Neumann <mail@richard-neumann.de>
Signed-off-by: default avatarHans de Goede <hdegoede@redhat.com>
Acked-by: default avatarSandeep Singh <sandeep.singh@amd.com>
Signed-off-by: default avatarJiri Kosina <jkosina@suse.cz>
parent a9e54f4b
Loading
Loading
Loading
Loading
+11 −3
Original line number Original line Diff line number Diff line
@@ -25,6 +25,10 @@
#define MAGNO_EN	BIT(2)
#define MAGNO_EN	BIT(2)
#define ALS_EN		BIT(19)
#define ALS_EN		BIT(19)


static int sensor_mask_override = -1;
module_param_named(sensor_mask, sensor_mask_override, int, 0444);
MODULE_PARM_DESC(sensor_mask, "override the detected sensors mask");

void amd_start_sensor(struct amd_mp2_dev *privdata, struct amd_mp2_sensor_info info)
void amd_start_sensor(struct amd_mp2_dev *privdata, struct amd_mp2_sensor_info info)
{
{
	union sfh_cmd_param cmd_param;
	union sfh_cmd_param cmd_param;
@@ -78,8 +82,12 @@ int amd_mp2_get_sensor_num(struct amd_mp2_dev *privdata, u8 *sensor_id)
	int activestatus, num_of_sensors = 0;
	int activestatus, num_of_sensors = 0;
	u32 activecontrolstatus;
	u32 activecontrolstatus;


	if (sensor_mask_override >= 0) {
		activestatus = sensor_mask_override;
	} else {
		activecontrolstatus = readl(privdata->mmio + AMD_P2C_MSG3);
		activecontrolstatus = readl(privdata->mmio + AMD_P2C_MSG3);
		activestatus = activecontrolstatus >> 4;
		activestatus = activecontrolstatus >> 4;
	}


	if (ACEL_EN  & activestatus)
	if (ACEL_EN  & activestatus)
		sensor_id[num_of_sensors++] = accel_idx;
		sensor_id[num_of_sensors++] = accel_idx;