Commit 2f4effd8 authored by Linus Torvalds's avatar Linus Torvalds
Browse files

Merge tag 'hwmon-for-v6.5-rc4' of...

Merge tag 'hwmon-for-v6.5-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging

Pull hwmon fixes from Guenter Roeck:

 - k10temp: Display negative temperatures for industrial processors

 - pmbus core: Fix deadlock, NULL pointer dereference, and chip enable
   detection

 - nct7802: Do not display PECI1 temperature if disabled

 - nct6775: Fix IN scaling factors and feature detection for
   NCT6798/6799

 - oxp-sensors: Fix race condition during device attribute creation

 - aquacomputer_d5next: Fix incorrect PWM value readout

* tag 'hwmon-for-v6.5-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging:
  hwmon: (k10temp) Enable AMD3255 Proc to show negative temperature
  hwmon: (pmbus_core) Fix Deadlock in pmbus_regulator_get_status
  hwmon: (pmbus_core) Fix NULL pointer dereference
  hwmon: (pmbus_core) Fix pmbus_is_enabled()
  hwmon: (nct7802) Fix for temp6 (PECI1) processed even if PECI1 disabled
  hwmon: (nct6775) Fix IN scaling factors for 6798/6799
  hwmon: (oxp-sensors) Move tt_toggle attribute to dev_groups
  hwmon: (aquacomputer_d5next) Fix incorrect PWM value readout
  hwmon: (nct6775) Fix register for nct6799
parents c06f9091 e146503a
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -1027,7 +1027,7 @@ static int aqc_read(struct device *dev, enum hwmon_sensor_types type, u32 attr,
			if (ret < 0)
				return ret;

			*val = aqc_percent_to_pwm(ret);
			*val = aqc_percent_to_pwm(*val);
			break;
		}
		break;
+15 −2
Original line number Diff line number Diff line
@@ -77,6 +77,13 @@ static DEFINE_MUTEX(nb_smu_ind_mutex);
#define ZEN_CUR_TEMP_RANGE_SEL_MASK		BIT(19)
#define ZEN_CUR_TEMP_TJ_SEL_MASK		GENMASK(17, 16)

/*
 * AMD's Industrial processor 3255 supports temperature from -40 deg to 105 deg Celsius.
 * Use the model name to identify 3255 CPUs and set a flag to display negative temperature.
 * Do not round off to zero for negative Tctl or Tdie values if the flag is set
 */
#define AMD_I3255_STR				"3255"

struct k10temp_data {
	struct pci_dev *pdev;
	void (*read_htcreg)(struct pci_dev *pdev, u32 *regval);
@@ -86,6 +93,7 @@ struct k10temp_data {
	u32 show_temp;
	bool is_zen;
	u32 ccd_offset;
	bool disp_negative;
};

#define TCTL_BIT	0
@@ -204,12 +212,12 @@ static int k10temp_read_temp(struct device *dev, u32 attr, int channel,
		switch (channel) {
		case 0:		/* Tctl */
			*val = get_raw_temp(data);
			if (*val < 0)
			if (*val < 0 && !data->disp_negative)
				*val = 0;
			break;
		case 1:		/* Tdie */
			*val = get_raw_temp(data) - data->temp_offset;
			if (*val < 0)
			if (*val < 0 && !data->disp_negative)
				*val = 0;
			break;
		case 2 ... 13:		/* Tccd{1-12} */
@@ -405,6 +413,11 @@ static int k10temp_probe(struct pci_dev *pdev, const struct pci_device_id *id)
	data->pdev = pdev;
	data->show_temp |= BIT(TCTL_BIT);	/* Always show Tctl */

	if (boot_cpu_data.x86 == 0x17 &&
	    strstr(boot_cpu_data.x86_model_id, AMD_I3255_STR)) {
		data->disp_negative = true;
	}

	if (boot_cpu_data.x86 == 0x15 &&
	    ((boot_cpu_data.x86_model & 0xf0) == 0x60 ||
	     (boot_cpu_data.x86_model & 0xf0) == 0x70)) {
+22 −6
Original line number Diff line number Diff line
@@ -955,14 +955,25 @@ static const u16 scale_in[15] = {
	800, 800
};

static inline long in_from_reg(u8 reg, u8 nr)
/*
 * NCT6798 scaling:
 *    CPUVC, IN1, AVSB, 3VCC, IN0, IN8, IN4, 3VSB, VBAT,  VTT,  IN5,  IN6, IN2,
 *      IN3, IN7
 * Additional scales to be added later: IN9 (800), VHIF (1600)
 */
static const u16 scale_in_6798[15] = {
	800, 800, 1600, 1600, 800, 800, 800, 1600, 1600, 1600, 1600, 1600, 800,
	800, 800
};

static inline long in_from_reg(u8 reg, u8 nr, const u16 *scales)
{
	return DIV_ROUND_CLOSEST(reg * scale_in[nr], 100);
	return DIV_ROUND_CLOSEST(reg * scales[nr], 100);
}

static inline u8 in_to_reg(u32 val, u8 nr)
static inline u8 in_to_reg(u32 val, u8 nr, const u16 *scales)
{
	return clamp_val(DIV_ROUND_CLOSEST(val * 100, scale_in[nr]), 0, 255);
	return clamp_val(DIV_ROUND_CLOSEST(val * 100, scales[nr]), 0, 255);
}

/* TSI temperatures are in 8.3 format */
@@ -1673,7 +1684,8 @@ show_in_reg(struct device *dev, struct device_attribute *attr, char *buf)
	if (IS_ERR(data))
		return PTR_ERR(data);

	return sprintf(buf, "%ld\n", in_from_reg(data->in[nr][index], nr));
	return sprintf(buf, "%ld\n",
		       in_from_reg(data->in[nr][index], nr, data->scale_in));
}

static ssize_t
@@ -1691,7 +1703,7 @@ store_in_reg(struct device *dev, struct device_attribute *attr, const char *buf,
	if (err < 0)
		return err;
	mutex_lock(&data->update_lock);
	data->in[nr][index] = in_to_reg(val, nr);
	data->in[nr][index] = in_to_reg(val, nr, data->scale_in);
	err = nct6775_write_value(data, data->REG_IN_MINMAX[index - 1][nr], data->in[nr][index]);
	mutex_unlock(&data->update_lock);
	return err ? : count;
@@ -3462,6 +3474,7 @@ int nct6775_probe(struct device *dev, struct nct6775_data *data,
	mutex_init(&data->update_lock);
	data->name = nct6775_device_names[data->kind];
	data->bank = 0xff;		/* Force initial bank selection */
	data->scale_in = scale_in;

	switch (data->kind) {
	case nct6106:
@@ -3977,6 +3990,9 @@ int nct6775_probe(struct device *dev, struct nct6775_data *data,
			break;
		}

		if (data->kind == nct6798 || data->kind == nct6799)
			data->scale_in = scale_in_6798;

		reg_temp = NCT6779_REG_TEMP;
		num_reg_temp = ARRAY_SIZE(NCT6779_REG_TEMP);
		if (data->kind == nct6791) {
+1 −1
Original line number Diff line number Diff line
@@ -586,7 +586,7 @@ nct6775_check_fan_inputs(struct nct6775_data *data, struct nct6775_sio_data *sio
		int creb;
		int cred;

		cre6 = sio_data->sio_inb(sio_data, 0xe0);
		cre6 = sio_data->sio_inb(sio_data, 0xe6);

		sio_data->sio_select(sio_data, NCT6775_LD_12);
		cre0 = sio_data->sio_inb(sio_data, 0xe0);
+1 −0
Original line number Diff line number Diff line
@@ -98,6 +98,7 @@ struct nct6775_data {
	u8 bank;		/* current register bank */
	u8 in_num;		/* number of in inputs we have */
	u8 in[15][3];		/* [0]=in, [1]=in_max, [2]=in_min */
	const u16 *scale_in;	/* internal scaling factors */
	unsigned int rpm[NUM_FAN];
	u16 fan_min[NUM_FAN];
	u8 fan_pulses[NUM_FAN];
Loading