static umode_t aqr_hwmon_is_visible(constvoid *data, enum hwmon_sensor_types type,
u32 attr, int channel)
{ if (type != hwmon_temp) return 0;
switch (attr) { case hwmon_temp_input: case hwmon_temp_min_alarm: case hwmon_temp_max_alarm: case hwmon_temp_lcrit_alarm: case hwmon_temp_crit_alarm: return 0444; case hwmon_temp_min: case hwmon_temp_max: case hwmon_temp_lcrit: case hwmon_temp_crit: return 0644; default: return 0;
}
}
staticint aqr_hwmon_get(struct phy_device *phydev, int reg, long *value)
{ int temp = phy_read_mmd(phydev, MDIO_MMD_VEND1, reg);
if (temp < 0) return temp;
/* 16 bit value is 2's complement with LSB = 1/256th degree Celsius */
*value = (s16)temp * 1000 / 256;
return 0;
}
staticint aqr_hwmon_set(struct phy_device *phydev, int reg, long value)
{ int temp;
if (value >= 128000 || value < -128000) return -ERANGE;
temp = value * 256 / 1000;
/* temp is in s16 range and we're interested in lower 16 bits only */ return phy_write_mmd(phydev, MDIO_MMD_VEND1, reg, (u16)temp);
}
staticint aqr_hwmon_test_bit(struct phy_device *phydev, int reg, int bit)
{ int val = phy_read_mmd(phydev, MDIO_MMD_VEND1, reg);
if (val < 0) return val;
return !!(val & bit);
}
staticint aqr_hwmon_status1(struct phy_device *phydev, int bit, long *value)
{ int val = aqr_hwmon_test_bit(phydev, VEND1_GENERAL_STAT1, bit);
if (val < 0) return val;
*value = val;
return 0;
}
staticint aqr_hwmon_read(struct device *dev, enum hwmon_sensor_types type,
u32 attr, int channel, long *value)
{ struct phy_device *phydev = dev_get_drvdata(dev); int reg;
if (type != hwmon_temp) return -EOPNOTSUPP;
switch (attr) { case hwmon_temp_input:
reg = aqr_hwmon_test_bit(phydev, VEND1_THERMAL_STAT2,
VEND1_THERMAL_STAT2_VALID); if (reg < 0) return reg; if (!reg) return -EBUSY;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.