From 9389558241d228f91f0a4fefcc4fa2391c54fc25 Mon Sep 17 00:00:00 2001 From: Ouyang Changchun Date: Thu, 12 Feb 2015 20:00:54 +0800 Subject: [PATCH 1/1] ixgbe/base: i2c combined functions New API to perform I2C read combined operation. New API to perform I2C write combined operation. Signed-off-by: Changchun Ouyang Acked-by: Jijiang Liu --- lib/librte_pmd_ixgbe/ixgbe/ixgbe_api.c | 32 +++++++++++++++++++++++++ lib/librte_pmd_ixgbe/ixgbe/ixgbe_api.h | 2 ++ lib/librte_pmd_ixgbe/ixgbe/ixgbe_x550.c | 7 ++++-- 3 files changed, 39 insertions(+), 2 deletions(-) diff --git a/lib/librte_pmd_ixgbe/ixgbe/ixgbe_api.c b/lib/librte_pmd_ixgbe/ixgbe/ixgbe_api.c index 9d8ea277a1..9b760cd3e9 100644 --- a/lib/librte_pmd_ixgbe/ixgbe/ixgbe_api.c +++ b/lib/librte_pmd_ixgbe/ixgbe/ixgbe_api.c @@ -1270,6 +1270,7 @@ s32 ixgbe_init_uta_tables(struct ixgbe_hw *hw) * ixgbe_read_i2c_byte - Reads 8 bit word over I2C at specified device address * @hw: pointer to hardware structure * @byte_offset: byte offset to read + * @dev_addr: I2C bus address to read from * @data: value read * * Performs byte read operation to SFP module's EEPROM over I2C interface. @@ -1281,10 +1282,26 @@ s32 ixgbe_read_i2c_byte(struct ixgbe_hw *hw, u8 byte_offset, u8 dev_addr, dev_addr, data), IXGBE_NOT_IMPLEMENTED); } +/** + * ixgbe_read_i2c_combined - Perform I2C read combined operation + * @hw: pointer to the hardware structure + * @addr: I2C bus address to read from + * @reg: I2C device register to read from + * @val: pointer to location to receive read value + * + * Returns an error code on error. + */ +s32 ixgbe_read_i2c_combined(struct ixgbe_hw *hw, u8 addr, u16 reg, u16 *val) +{ + return ixgbe_call_func(hw, hw->phy.ops.read_i2c_combined, (hw, addr, + reg, val), IXGBE_NOT_IMPLEMENTED); +} + /** * ixgbe_write_i2c_byte - Writes 8 bit word over I2C * @hw: pointer to hardware structure * @byte_offset: byte offset to write + * @dev_addr: I2C bus address to write to * @data: value to write * * Performs byte write operation to SFP module's EEPROM over I2C interface @@ -1297,6 +1314,21 @@ s32 ixgbe_write_i2c_byte(struct ixgbe_hw *hw, u8 byte_offset, u8 dev_addr, dev_addr, data), IXGBE_NOT_IMPLEMENTED); } +/** + * ixgbe_write_i2c_combined - Perform I2C write combined operation + * @hw: pointer to the hardware structure + * @addr: I2C bus address to write to + * @reg: I2C device register to write to + * @val: value to write + * + * Returns an error code on error. + */ +s32 ixgbe_write_i2c_combined(struct ixgbe_hw *hw, u8 addr, u16 reg, u16 val) +{ + return ixgbe_call_func(hw, hw->phy.ops.write_i2c_combined, (hw, addr, + reg, val), IXGBE_NOT_IMPLEMENTED); +} + /** * ixgbe_write_i2c_eeprom - Writes 8 bit EEPROM word over I2C interface * @hw: pointer to hardware structure diff --git a/lib/librte_pmd_ixgbe/ixgbe/ixgbe_api.h b/lib/librte_pmd_ixgbe/ixgbe/ixgbe_api.h index cb6208dd9e..dfa45a2278 100644 --- a/lib/librte_pmd_ixgbe/ixgbe/ixgbe_api.h +++ b/lib/librte_pmd_ixgbe/ixgbe/ixgbe_api.h @@ -169,8 +169,10 @@ u32 ixgbe_atr_compute_sig_hash_82599(union ixgbe_atr_hash_dword input, bool ixgbe_verify_lesm_fw_enabled_82599(struct ixgbe_hw *hw); s32 ixgbe_read_i2c_byte(struct ixgbe_hw *hw, u8 byte_offset, u8 dev_addr, u8 *data); +s32 ixgbe_read_i2c_combined(struct ixgbe_hw *hw, u8 addr, u16 reg, u16 *val); s32 ixgbe_write_i2c_byte(struct ixgbe_hw *hw, u8 byte_offset, u8 dev_addr, u8 data); +s32 ixgbe_write_i2c_combined(struct ixgbe_hw *hw, u8 addr, u16 reg, u16 val); s32 ixgbe_write_i2c_eeprom(struct ixgbe_hw *hw, u8 byte_offset, u8 eeprom_data); s32 ixgbe_get_san_mac_addr(struct ixgbe_hw *hw, u8 *san_mac_addr); s32 ixgbe_set_san_mac_addr(struct ixgbe_hw *hw, u8 *san_mac_addr); diff --git a/lib/librte_pmd_ixgbe/ixgbe/ixgbe_x550.c b/lib/librte_pmd_ixgbe/ixgbe/ixgbe_x550.c index 540b4779e5..9750777701 100644 --- a/lib/librte_pmd_ixgbe/ixgbe/ixgbe_x550.c +++ b/lib/librte_pmd_ixgbe/ixgbe/ixgbe_x550.c @@ -789,6 +789,7 @@ s32 ixgbe_setup_sfp_modules_X550em(struct ixgbe_hw *hw) { bool setup_linear; u16 reg_slice, edc_mode; + s32 ret_val; DEBUGFUNC("ixgbe_setup_sfp_modules_X550em"); @@ -829,8 +830,10 @@ s32 ixgbe_setup_sfp_modules_X550em(struct ixgbe_hw *hw) edc_mode = (IXGBE_CS4227_EDC_MODE_SR << 1) | 0x1; /* Configure CS4227 for connection type. */ - return hw->phy.ops.write_i2c_combined(hw, IXGBE_CS4227, - reg_slice, edc_mode); + ret_val = ixgbe_write_i2c_combined(hw, IXGBE_CS4227, reg_slice, + edc_mode); + + return ret_val; } /** -- 2.20.1