aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDon Skidmore <donald.c.skidmore@intel.com>2012-02-16 21:38:58 -0500
committerJeff Kirsher <jeffrey.t.kirsher@intel.com>2012-05-02 04:59:14 -0400
commite1ea9158e377de6dd6d88be8e1e039c0b34dba1a (patch)
tree7725cbfcd8d829355563ca171d0b08a8b9778dd6
parent69e1e0197ce739d86ca33fd275962d6cbd1b107a (diff)
ixgbe: add support functions to access thermal data
Some 82599 adapters contain thermal data that we can get to via an i2c interface. These functions provide support to get at that data. A following patch will export this data. Signed-off-by: Don Skidmore <donald.c.skidmore@intel.com> Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
-rw-r--r--drivers/net/ethernet/intel/ixgbe/ixgbe_common.c171
-rw-r--r--drivers/net/ethernet/intel/ixgbe/ixgbe_common.h13
-rw-r--r--drivers/net/ethernet/intel/ixgbe/ixgbe_type.h40
3 files changed, 224 insertions, 0 deletions
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_common.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_common.c
index e59888163a17..6c6c66eace6c 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_common.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_common.c
@@ -3604,3 +3604,174 @@ void ixgbe_clear_tx_pending(struct ixgbe_hw *hw)
3604 IXGBE_WRITE_REG(hw, IXGBE_GCR_EXT, gcr_ext); 3604 IXGBE_WRITE_REG(hw, IXGBE_GCR_EXT, gcr_ext);
3605 IXGBE_WRITE_REG(hw, IXGBE_HLREG0, hlreg0); 3605 IXGBE_WRITE_REG(hw, IXGBE_HLREG0, hlreg0);
3606} 3606}
3607
3608static const u8 ixgbe_emc_temp_data[4] = {
3609 IXGBE_EMC_INTERNAL_DATA,
3610 IXGBE_EMC_DIODE1_DATA,
3611 IXGBE_EMC_DIODE2_DATA,
3612 IXGBE_EMC_DIODE3_DATA
3613};
3614static const u8 ixgbe_emc_therm_limit[4] = {
3615 IXGBE_EMC_INTERNAL_THERM_LIMIT,
3616 IXGBE_EMC_DIODE1_THERM_LIMIT,
3617 IXGBE_EMC_DIODE2_THERM_LIMIT,
3618 IXGBE_EMC_DIODE3_THERM_LIMIT
3619};
3620
3621/**
3622 * ixgbe_get_ets_data - Extracts the ETS bit data
3623 * @hw: pointer to hardware structure
3624 * @ets_cfg: extected ETS data
3625 * @ets_offset: offset of ETS data
3626 *
3627 * Returns error code.
3628 **/
3629static s32 ixgbe_get_ets_data(struct ixgbe_hw *hw, u16 *ets_cfg,
3630 u16 *ets_offset)
3631{
3632 s32 status = 0;
3633
3634 status = hw->eeprom.ops.read(hw, IXGBE_ETS_CFG, ets_offset);
3635 if (status)
3636 goto out;
3637
3638 if ((*ets_offset == 0x0000) || (*ets_offset == 0xFFFF)) {
3639 status = IXGBE_NOT_IMPLEMENTED;
3640 goto out;
3641 }
3642
3643 status = hw->eeprom.ops.read(hw, *ets_offset, ets_cfg);
3644 if (status)
3645 goto out;
3646
3647 if ((*ets_cfg & IXGBE_ETS_TYPE_MASK) != IXGBE_ETS_TYPE_EMC_SHIFTED) {
3648 status = IXGBE_NOT_IMPLEMENTED;
3649 goto out;
3650 }
3651
3652out:
3653 return status;
3654}
3655
3656/**
3657 * ixgbe_get_thermal_sensor_data - Gathers thermal sensor data
3658 * @hw: pointer to hardware structure
3659 *
3660 * Returns the thermal sensor data structure
3661 **/
3662s32 ixgbe_get_thermal_sensor_data_generic(struct ixgbe_hw *hw)
3663{
3664 s32 status = 0;
3665 u16 ets_offset;
3666 u16 ets_cfg;
3667 u16 ets_sensor;
3668 u8 num_sensors;
3669 u8 i;
3670 struct ixgbe_thermal_sensor_data *data = &hw->mac.thermal_sensor_data;
3671
3672 /* Only support thermal sensors attached to 82599 physical port 0 */
3673 if ((hw->mac.type != ixgbe_mac_82599EB) ||
3674 (IXGBE_READ_REG(hw, IXGBE_STATUS) & IXGBE_STATUS_LAN_ID_1)) {
3675 status = IXGBE_NOT_IMPLEMENTED;
3676 goto out;
3677 }
3678
3679 status = ixgbe_get_ets_data(hw, &ets_cfg, &ets_offset);
3680 if (status)
3681 goto out;
3682
3683 num_sensors = (ets_cfg & IXGBE_ETS_NUM_SENSORS_MASK);
3684 if (num_sensors > IXGBE_MAX_SENSORS)
3685 num_sensors = IXGBE_MAX_SENSORS;
3686
3687 for (i = 0; i < num_sensors; i++) {
3688 u8 sensor_index;
3689 u8 sensor_location;
3690
3691 status = hw->eeprom.ops.read(hw, (ets_offset + 1 + i),
3692 &ets_sensor);
3693 if (status)
3694 goto out;
3695
3696 sensor_index = ((ets_sensor & IXGBE_ETS_DATA_INDEX_MASK) >>
3697 IXGBE_ETS_DATA_INDEX_SHIFT);
3698 sensor_location = ((ets_sensor & IXGBE_ETS_DATA_LOC_MASK) >>
3699 IXGBE_ETS_DATA_LOC_SHIFT);
3700
3701 if (sensor_location != 0) {
3702 status = hw->phy.ops.read_i2c_byte(hw,
3703 ixgbe_emc_temp_data[sensor_index],
3704 IXGBE_I2C_THERMAL_SENSOR_ADDR,
3705 &data->sensor[i].temp);
3706 if (status)
3707 goto out;
3708 }
3709 }
3710out:
3711 return status;
3712}
3713
3714/**
3715 * ixgbe_init_thermal_sensor_thresh_generic - Inits thermal sensor thresholds
3716 * @hw: pointer to hardware structure
3717 *
3718 * Inits the thermal sensor thresholds according to the NVM map
3719 * and save off the threshold and location values into mac.thermal_sensor_data
3720 **/
3721s32 ixgbe_init_thermal_sensor_thresh_generic(struct ixgbe_hw *hw)
3722{
3723 s32 status = 0;
3724 u16 ets_offset;
3725 u16 ets_cfg;
3726 u16 ets_sensor;
3727 u8 low_thresh_delta;
3728 u8 num_sensors;
3729 u8 therm_limit;
3730 u8 i;
3731 struct ixgbe_thermal_sensor_data *data = &hw->mac.thermal_sensor_data;
3732
3733 memset(data, 0, sizeof(struct ixgbe_thermal_sensor_data));
3734
3735 /* Only support thermal sensors attached to 82599 physical port 0 */
3736 if ((hw->mac.type != ixgbe_mac_82599EB) ||
3737 (IXGBE_READ_REG(hw, IXGBE_STATUS) & IXGBE_STATUS_LAN_ID_1)) {
3738 status = IXGBE_NOT_IMPLEMENTED;
3739 goto out;
3740 }
3741
3742 status = ixgbe_get_ets_data(hw, &ets_cfg, &ets_offset);
3743 if (status)
3744 goto out;
3745
3746 low_thresh_delta = ((ets_cfg & IXGBE_ETS_LTHRES_DELTA_MASK) >>
3747 IXGBE_ETS_LTHRES_DELTA_SHIFT);
3748 num_sensors = (ets_cfg & IXGBE_ETS_NUM_SENSORS_MASK);
3749 if (num_sensors > IXGBE_MAX_SENSORS)
3750 num_sensors = IXGBE_MAX_SENSORS;
3751
3752 for (i = 0; i < num_sensors; i++) {
3753 u8 sensor_index;
3754 u8 sensor_location;
3755
3756 hw->eeprom.ops.read(hw, (ets_offset + 1 + i), &ets_sensor);
3757 sensor_index = ((ets_sensor & IXGBE_ETS_DATA_INDEX_MASK) >>
3758 IXGBE_ETS_DATA_INDEX_SHIFT);
3759 sensor_location = ((ets_sensor & IXGBE_ETS_DATA_LOC_MASK) >>
3760 IXGBE_ETS_DATA_LOC_SHIFT);
3761 therm_limit = ets_sensor & IXGBE_ETS_DATA_HTHRESH_MASK;
3762
3763 hw->phy.ops.write_i2c_byte(hw,
3764 ixgbe_emc_therm_limit[sensor_index],
3765 IXGBE_I2C_THERMAL_SENSOR_ADDR, therm_limit);
3766
3767 if (sensor_location == 0)
3768 continue;
3769
3770 data->sensor[i].location = sensor_location;
3771 data->sensor[i].caution_thresh = therm_limit;
3772 data->sensor[i].max_op_thresh = therm_limit - low_thresh_delta;
3773 }
3774out:
3775 return status;
3776}
3777
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_common.h b/drivers/net/ethernet/intel/ixgbe/ixgbe_common.h
index d6d34324540c..f992777e67a8 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_common.h
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_common.h
@@ -107,6 +107,19 @@ void ixgbe_clear_tx_pending(struct ixgbe_hw *hw);
107void ixgbe_set_rxpba_generic(struct ixgbe_hw *hw, int num_pb, 107void ixgbe_set_rxpba_generic(struct ixgbe_hw *hw, int num_pb,
108 u32 headroom, int strategy); 108 u32 headroom, int strategy);
109 109
110#define IXGBE_I2C_THERMAL_SENSOR_ADDR 0xF8
111#define IXGBE_EMC_INTERNAL_DATA 0x00
112#define IXGBE_EMC_INTERNAL_THERM_LIMIT 0x20
113#define IXGBE_EMC_DIODE1_DATA 0x01
114#define IXGBE_EMC_DIODE1_THERM_LIMIT 0x19
115#define IXGBE_EMC_DIODE2_DATA 0x23
116#define IXGBE_EMC_DIODE2_THERM_LIMIT 0x1A
117#define IXGBE_EMC_DIODE3_DATA 0x2A
118#define IXGBE_EMC_DIODE3_THERM_LIMIT 0x30
119
120s32 ixgbe_get_thermal_sensor_data_generic(struct ixgbe_hw *hw);
121s32 ixgbe_init_thermal_sensor_thresh_generic(struct ixgbe_hw *hw);
122
110#define IXGBE_WRITE_REG(a, reg, value) writel((value), ((a)->hw_addr + (reg))) 123#define IXGBE_WRITE_REG(a, reg, value) writel((value), ((a)->hw_addr + (reg)))
111 124
112#ifndef writeq 125#ifndef writeq
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_type.h b/drivers/net/ethernet/intel/ixgbe/ixgbe_type.h
index 4acd9e665b28..d82e25c321ff 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_type.h
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_type.h
@@ -112,6 +112,27 @@
112#define IXGBE_I2C_DATA_OUT 0x00000008 112#define IXGBE_I2C_DATA_OUT 0x00000008
113#define IXGBE_I2C_CLOCK_STRETCHING_TIMEOUT 500 113#define IXGBE_I2C_CLOCK_STRETCHING_TIMEOUT 500
114 114
115#define IXGBE_I2C_THERMAL_SENSOR_ADDR 0xF8
116#define IXGBE_EMC_INTERNAL_DATA 0x00
117#define IXGBE_EMC_INTERNAL_THERM_LIMIT 0x20
118#define IXGBE_EMC_DIODE1_DATA 0x01
119#define IXGBE_EMC_DIODE1_THERM_LIMIT 0x19
120#define IXGBE_EMC_DIODE2_DATA 0x23
121#define IXGBE_EMC_DIODE2_THERM_LIMIT 0x1A
122
123#define IXGBE_MAX_SENSORS 3
124
125struct ixgbe_thermal_diode_data {
126 u8 location;
127 u8 temp;
128 u8 caution_thresh;
129 u8 max_op_thresh;
130};
131
132struct ixgbe_thermal_sensor_data {
133 struct ixgbe_thermal_diode_data sensor[IXGBE_MAX_SENSORS];
134};
135
115/* Interrupt Registers */ 136/* Interrupt Registers */
116#define IXGBE_EICR 0x00800 137#define IXGBE_EICR 0x00800
117#define IXGBE_EICS 0x00808 138#define IXGBE_EICS 0x00808
@@ -1678,6 +1699,22 @@ enum {
1678#define IXGBE_PBANUM0_PTR 0x15 1699#define IXGBE_PBANUM0_PTR 0x15
1679#define IXGBE_PBANUM1_PTR 0x16 1700#define IXGBE_PBANUM1_PTR 0x16
1680#define IXGBE_FREE_SPACE_PTR 0X3E 1701#define IXGBE_FREE_SPACE_PTR 0X3E
1702
1703/* External Thermal Sensor Config */
1704#define IXGBE_ETS_CFG 0x26
1705#define IXGBE_ETS_LTHRES_DELTA_MASK 0x07C0
1706#define IXGBE_ETS_LTHRES_DELTA_SHIFT 6
1707#define IXGBE_ETS_TYPE_MASK 0x0038
1708#define IXGBE_ETS_TYPE_SHIFT 3
1709#define IXGBE_ETS_TYPE_EMC 0x000
1710#define IXGBE_ETS_TYPE_EMC_SHIFTED 0x000
1711#define IXGBE_ETS_NUM_SENSORS_MASK 0x0007
1712#define IXGBE_ETS_DATA_LOC_MASK 0x3C00
1713#define IXGBE_ETS_DATA_LOC_SHIFT 10
1714#define IXGBE_ETS_DATA_INDEX_MASK 0x0300
1715#define IXGBE_ETS_DATA_INDEX_SHIFT 8
1716#define IXGBE_ETS_DATA_HTHRESH_MASK 0x00FF
1717
1681#define IXGBE_SAN_MAC_ADDR_PTR 0x28 1718#define IXGBE_SAN_MAC_ADDR_PTR 0x28
1682#define IXGBE_DEVICE_CAPS 0x2C 1719#define IXGBE_DEVICE_CAPS 0x2C
1683#define IXGBE_SERIAL_NUMBER_MAC_ADDR 0x11 1720#define IXGBE_SERIAL_NUMBER_MAC_ADDR 0x11
@@ -2775,6 +2812,8 @@ struct ixgbe_mac_operations {
2775 2812
2776 /* Manageability interface */ 2813 /* Manageability interface */
2777 s32 (*set_fw_drv_ver)(struct ixgbe_hw *, u8, u8, u8, u8); 2814 s32 (*set_fw_drv_ver)(struct ixgbe_hw *, u8, u8, u8, u8);
2815 s32 (*get_thermal_sensor_data)(struct ixgbe_hw *);
2816 s32 (*init_thermal_sensor_thresh)(struct ixgbe_hw *hw);
2778}; 2817};
2779 2818
2780struct ixgbe_phy_operations { 2819struct ixgbe_phy_operations {
@@ -2832,6 +2871,7 @@ struct ixgbe_mac_info {
2832 bool orig_link_settings_stored; 2871 bool orig_link_settings_stored;
2833 bool autotry_restart; 2872 bool autotry_restart;
2834 u8 flags; 2873 u8 flags;
2874 struct ixgbe_thermal_sensor_data thermal_sensor_data;
2835}; 2875};
2836 2876
2837struct ixgbe_phy_info { 2877struct ixgbe_phy_info {