diff options
author | hselasky <hselasky@FreeBSD.org> | 2015-12-30 14:58:55 +0000 |
---|---|---|
committer | hselasky <hselasky@FreeBSD.org> | 2015-12-30 14:58:55 +0000 |
commit | 3e461a3c0e58d75b4e1c3937831ed0e65f36ddc2 (patch) | |
tree | 18098c858e7e0ac655fd91f3cb2b8e1ffd7fd827 /sys/dev/mlx5 | |
parent | 58f5ebe6c799b202d362f35351dd27efec212438 (diff) | |
download | FreeBSD-src-3e461a3c0e58d75b4e1c3937831ed0e65f36ddc2.zip FreeBSD-src-3e461a3c0e58d75b4e1c3937831ed0e65f36ddc2.tar.gz |
Allow I2C to read address 0x51 as well as address 0x50.
MFC after: 1 week
Submitted by: Shahar Klein <shahark@mellanox.com>
Sponsored by: Mellanox Technologies
Diffstat (limited to 'sys/dev/mlx5')
-rw-r--r-- | sys/dev/mlx5/mlx5_en/mlx5_en_main.c | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/sys/dev/mlx5/mlx5_en/mlx5_en_main.c b/sys/dev/mlx5/mlx5_en/mlx5_en_main.c index 05ab87e..28b3054 100644 --- a/sys/dev/mlx5/mlx5_en/mlx5_en_main.c +++ b/sys/dev/mlx5/mlx5_en/mlx5_en_main.c @@ -2298,6 +2298,7 @@ mlx5e_ioctl(struct ifnet *ifp, u_long command, caddr_t data) int size_read = 0; int module_num; int max_mtu; + uint8_t read_addr; priv = ifp->if_softc; @@ -2484,11 +2485,21 @@ out: } /* - * Note that we ignore i2c.addr here. The driver hardcodes - * the address to 0x50, while standard expects it to be 0xA0. + * Currently 0XA0 and 0xA2 are the only addresses permitted. + * The internal conversion is as follows: */ + if (i2c.dev_addr == 0xA0) + read_addr = MLX5E_I2C_ADDR_LOW; + else if (i2c.dev_addr == 0xA2) + read_addr = MLX5E_I2C_ADDR_HIGH; + else { + if_printf(ifp, "Query eeprom failed, " + "Invalid Address: %X\n", i2c.dev_addr); + error = EINVAL; + goto err_i2c; + } error = mlx5_query_eeprom(priv->mdev, - MLX5E_I2C_ADDR_LOW, MLX5E_EEPROM_LOW_PAGE, + read_addr, MLX5E_EEPROM_LOW_PAGE, (uint32_t)i2c.offset, (uint32_t)i2c.len, module_num, (uint32_t *)i2c.data, &size_read); if (error) { @@ -2499,7 +2510,7 @@ out: if (i2c.len > MLX5_EEPROM_MAX_BYTES) { error = mlx5_query_eeprom(priv->mdev, - MLX5E_I2C_ADDR_LOW, MLX5E_EEPROM_LOW_PAGE, + read_addr, MLX5E_EEPROM_LOW_PAGE, (uint32_t)(i2c.offset + size_read), (uint32_t)(i2c.len - size_read), module_num, (uint32_t *)(i2c.data + size_read), &size_read); |