Commit fd3d96ae authored by David S. Miller's avatar David S. Miller

Merge branch 'HWMON-support-for-SFP-modules'

Andrew Lunn says:

====================
HWMON support for SFP modules

This patchset adds HWMON support to SFP modules. The two patches add
some attributes for temperature and power sensors which are currently
missing from the hwmon core. The third patch adds a helper for
filtering out characters in hwmon names which are invalid. The last
patch then extends the core SFP code to export the sensors found in
SFP modules.

This code has been tested with two SFP modules:

module OEM SFP-7000-85 rev 11.0 sn M1512220075 dc 160221
module FINISAR CORP. FTLF8524E2GNL rev A sn PW40MNN dc 160725

The anonymous module uses external calibration, while the FINISAR uses
internal calibration. Thus both code paths have been tested.

Due to the cross subsystem nature of these patches, as discussed with
the RFC, it is hoped Guenter Roeck will ACK the patches, and then Dave
Miller will merge them all via net-next.
====================
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents 7c1fbfa7 1323061a
...@@ -394,12 +394,16 @@ static const char * const hwmon_power_attr_templates[] = { ...@@ -394,12 +394,16 @@ static const char * const hwmon_power_attr_templates[] = {
[hwmon_power_cap_hyst] = "power%d_cap_hyst", [hwmon_power_cap_hyst] = "power%d_cap_hyst",
[hwmon_power_cap_max] = "power%d_cap_max", [hwmon_power_cap_max] = "power%d_cap_max",
[hwmon_power_cap_min] = "power%d_cap_min", [hwmon_power_cap_min] = "power%d_cap_min",
[hwmon_power_min] = "power%d_min",
[hwmon_power_max] = "power%d_max", [hwmon_power_max] = "power%d_max",
[hwmon_power_lcrit] = "power%d_lcrit",
[hwmon_power_crit] = "power%d_crit", [hwmon_power_crit] = "power%d_crit",
[hwmon_power_label] = "power%d_label", [hwmon_power_label] = "power%d_label",
[hwmon_power_alarm] = "power%d_alarm", [hwmon_power_alarm] = "power%d_alarm",
[hwmon_power_cap_alarm] = "power%d_cap_alarm", [hwmon_power_cap_alarm] = "power%d_cap_alarm",
[hwmon_power_min_alarm] = "power%d_min_alarm",
[hwmon_power_max_alarm] = "power%d_max_alarm", [hwmon_power_max_alarm] = "power%d_max_alarm",
[hwmon_power_lcrit_alarm] = "power%d_lcrit_alarm",
[hwmon_power_crit_alarm] = "power%d_crit_alarm", [hwmon_power_crit_alarm] = "power%d_crit_alarm",
}; };
......
...@@ -215,6 +215,7 @@ config SFP ...@@ -215,6 +215,7 @@ config SFP
tristate "SFP cage support" tristate "SFP cage support"
depends on I2C && PHYLINK depends on I2C && PHYLINK
select MDIO_I2C select MDIO_I2C
imply HWMON
config AMD_PHY config AMD_PHY
tristate "AMD PHYs" tristate "AMD PHYs"
......
This diff is collapsed.
...@@ -93,6 +93,7 @@ enum hwmon_temp_attributes { ...@@ -93,6 +93,7 @@ enum hwmon_temp_attributes {
#define HWMON_T_MIN_ALARM BIT(hwmon_temp_min_alarm) #define HWMON_T_MIN_ALARM BIT(hwmon_temp_min_alarm)
#define HWMON_T_MAX_ALARM BIT(hwmon_temp_max_alarm) #define HWMON_T_MAX_ALARM BIT(hwmon_temp_max_alarm)
#define HWMON_T_CRIT_ALARM BIT(hwmon_temp_crit_alarm) #define HWMON_T_CRIT_ALARM BIT(hwmon_temp_crit_alarm)
#define HWMON_T_LCRIT_ALARM BIT(hwmon_temp_lcrit_alarm)
#define HWMON_T_EMERGENCY_ALARM BIT(hwmon_temp_emergency_alarm) #define HWMON_T_EMERGENCY_ALARM BIT(hwmon_temp_emergency_alarm)
#define HWMON_T_FAULT BIT(hwmon_temp_fault) #define HWMON_T_FAULT BIT(hwmon_temp_fault)
#define HWMON_T_OFFSET BIT(hwmon_temp_offset) #define HWMON_T_OFFSET BIT(hwmon_temp_offset)
...@@ -187,12 +188,16 @@ enum hwmon_power_attributes { ...@@ -187,12 +188,16 @@ enum hwmon_power_attributes {
hwmon_power_cap_hyst, hwmon_power_cap_hyst,
hwmon_power_cap_max, hwmon_power_cap_max,
hwmon_power_cap_min, hwmon_power_cap_min,
hwmon_power_min,
hwmon_power_max, hwmon_power_max,
hwmon_power_crit, hwmon_power_crit,
hwmon_power_lcrit,
hwmon_power_label, hwmon_power_label,
hwmon_power_alarm, hwmon_power_alarm,
hwmon_power_cap_alarm, hwmon_power_cap_alarm,
hwmon_power_min_alarm,
hwmon_power_max_alarm, hwmon_power_max_alarm,
hwmon_power_lcrit_alarm,
hwmon_power_crit_alarm, hwmon_power_crit_alarm,
}; };
...@@ -213,12 +218,16 @@ enum hwmon_power_attributes { ...@@ -213,12 +218,16 @@ enum hwmon_power_attributes {
#define HWMON_P_CAP_HYST BIT(hwmon_power_cap_hyst) #define HWMON_P_CAP_HYST BIT(hwmon_power_cap_hyst)
#define HWMON_P_CAP_MAX BIT(hwmon_power_cap_max) #define HWMON_P_CAP_MAX BIT(hwmon_power_cap_max)
#define HWMON_P_CAP_MIN BIT(hwmon_power_cap_min) #define HWMON_P_CAP_MIN BIT(hwmon_power_cap_min)
#define HWMON_P_MIN BIT(hwmon_power_min)
#define HWMON_P_MAX BIT(hwmon_power_max) #define HWMON_P_MAX BIT(hwmon_power_max)
#define HWMON_P_LCRIT BIT(hwmon_power_lcrit)
#define HWMON_P_CRIT BIT(hwmon_power_crit) #define HWMON_P_CRIT BIT(hwmon_power_crit)
#define HWMON_P_LABEL BIT(hwmon_power_label) #define HWMON_P_LABEL BIT(hwmon_power_label)
#define HWMON_P_ALARM BIT(hwmon_power_alarm) #define HWMON_P_ALARM BIT(hwmon_power_alarm)
#define HWMON_P_CAP_ALARM BIT(hwmon_power_cap_alarm) #define HWMON_P_CAP_ALARM BIT(hwmon_power_cap_alarm)
#define HWMON_P_MIN_ALARM BIT(hwmon_power_max_alarm)
#define HWMON_P_MAX_ALARM BIT(hwmon_power_max_alarm) #define HWMON_P_MAX_ALARM BIT(hwmon_power_max_alarm)
#define HWMON_P_LCRIT_ALARM BIT(hwmon_power_lcrit_alarm)
#define HWMON_P_CRIT_ALARM BIT(hwmon_power_crit_alarm) #define HWMON_P_CRIT_ALARM BIT(hwmon_power_crit_alarm)
enum hwmon_energy_attributes { enum hwmon_energy_attributes {
...@@ -389,4 +398,27 @@ devm_hwmon_device_register_with_info(struct device *dev, ...@@ -389,4 +398,27 @@ devm_hwmon_device_register_with_info(struct device *dev,
void hwmon_device_unregister(struct device *dev); void hwmon_device_unregister(struct device *dev);
void devm_hwmon_device_unregister(struct device *dev); void devm_hwmon_device_unregister(struct device *dev);
/**
* hwmon_is_bad_char - Is the char invalid in a hwmon name
* @ch: the char to be considered
*
* hwmon_is_bad_char() can be used to determine if the given character
* may not be used in a hwmon name.
*
* Returns true if the char is invalid, false otherwise.
*/
static inline bool hwmon_is_bad_char(const char ch)
{
switch (ch) {
case '-':
case '*':
case ' ':
case '\t':
case '\n':
return true;
default:
return false;
}
}
#endif #endif
...@@ -231,6 +231,50 @@ struct sfp_eeprom_id { ...@@ -231,6 +231,50 @@ struct sfp_eeprom_id {
struct sfp_eeprom_ext ext; struct sfp_eeprom_ext ext;
} __packed; } __packed;
struct sfp_diag {
__be16 temp_high_alarm;
__be16 temp_low_alarm;
__be16 temp_high_warn;
__be16 temp_low_warn;
__be16 volt_high_alarm;
__be16 volt_low_alarm;
__be16 volt_high_warn;
__be16 volt_low_warn;
__be16 bias_high_alarm;
__be16 bias_low_alarm;
__be16 bias_high_warn;
__be16 bias_low_warn;
__be16 txpwr_high_alarm;
__be16 txpwr_low_alarm;
__be16 txpwr_high_warn;
__be16 txpwr_low_warn;
__be16 rxpwr_high_alarm;
__be16 rxpwr_low_alarm;
__be16 rxpwr_high_warn;
__be16 rxpwr_low_warn;
__be16 laser_temp_high_alarm;
__be16 laser_temp_low_alarm;
__be16 laser_temp_high_warn;
__be16 laser_temp_low_warn;
__be16 tec_cur_high_alarm;
__be16 tec_cur_low_alarm;
__be16 tec_cur_high_warn;
__be16 tec_cur_low_warn;
__be32 cal_rxpwr4;
__be32 cal_rxpwr3;
__be32 cal_rxpwr2;
__be32 cal_rxpwr1;
__be32 cal_rxpwr0;
__be16 cal_txi_slope;
__be16 cal_txi_offset;
__be16 cal_txpwr_slope;
__be16 cal_txpwr_offset;
__be16 cal_t_slope;
__be16 cal_t_offset;
__be16 cal_v_slope;
__be16 cal_v_offset;
} __packed;
/* SFP EEPROM registers */ /* SFP EEPROM registers */
enum { enum {
SFP_PHYS_ID = 0x00, SFP_PHYS_ID = 0x00,
...@@ -384,7 +428,33 @@ enum { ...@@ -384,7 +428,33 @@ enum {
SFP_TEC_CUR = 0x6c, SFP_TEC_CUR = 0x6c,
SFP_STATUS = 0x6e, SFP_STATUS = 0x6e,
SFP_ALARM = 0x70, SFP_ALARM0 = 0x70,
SFP_ALARM0_TEMP_HIGH = BIT(7),
SFP_ALARM0_TEMP_LOW = BIT(6),
SFP_ALARM0_VCC_HIGH = BIT(5),
SFP_ALARM0_VCC_LOW = BIT(4),
SFP_ALARM0_TX_BIAS_HIGH = BIT(3),
SFP_ALARM0_TX_BIAS_LOW = BIT(2),
SFP_ALARM0_TXPWR_HIGH = BIT(1),
SFP_ALARM0_TXPWR_LOW = BIT(0),
SFP_ALARM1 = 0x71,
SFP_ALARM1_RXPWR_HIGH = BIT(7),
SFP_ALARM1_RXPWR_LOW = BIT(6),
SFP_WARN0 = 0x74,
SFP_WARN0_TEMP_HIGH = BIT(7),
SFP_WARN0_TEMP_LOW = BIT(6),
SFP_WARN0_VCC_HIGH = BIT(5),
SFP_WARN0_VCC_LOW = BIT(4),
SFP_WARN0_TX_BIAS_HIGH = BIT(3),
SFP_WARN0_TX_BIAS_LOW = BIT(2),
SFP_WARN0_TXPWR_HIGH = BIT(1),
SFP_WARN0_TXPWR_LOW = BIT(0),
SFP_WARN1 = 0x75,
SFP_WARN1_RXPWR_HIGH = BIT(7),
SFP_WARN1_RXPWR_LOW = BIT(6),
SFP_EXT_STATUS = 0x76, SFP_EXT_STATUS = 0x76,
SFP_VSL = 0x78, SFP_VSL = 0x78,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment