summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorMike Belopuhov <mikeb@cvs.openbsd.org>2012-12-17 18:44:28 +0000
committerMike Belopuhov <mikeb@cvs.openbsd.org>2012-12-17 18:44:28 +0000
commit52226555b6f8e369307c37dfdb08e5e0aa8659ec (patch)
tree49dd8e805347eed28d137b2bfd48cc77e92d3521 /sys
parentec07f4cc3a664060f3ae02cfaca2fda270c30293 (diff)
sync up ixgbe_raise_i2c_clk with freebsd which basically allows
for larger timeouts and should be more reliable; tested on 82598, 82599 and x540.
Diffstat (limited to 'sys')
-rw-r--r--sys/dev/pci/ixgbe_phy.c18
-rw-r--r--sys/dev/pci/ixgbe_type.h3
2 files changed, 13 insertions, 8 deletions
diff --git a/sys/dev/pci/ixgbe_phy.c b/sys/dev/pci/ixgbe_phy.c
index 708f6242286..3409aee0891 100644
--- a/sys/dev/pci/ixgbe_phy.c
+++ b/sys/dev/pci/ixgbe_phy.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ixgbe_phy.c,v 1.9 2012/12/05 14:41:28 mikeb Exp $ */
+/* $OpenBSD: ixgbe_phy.c,v 1.10 2012/12/17 18:44:27 mikeb Exp $ */
/******************************************************************************
@@ -1656,16 +1656,20 @@ int32_t ixgbe_clock_out_i2c_bit(struct ixgbe_hw *hw, int data)
**/
int32_t ixgbe_raise_i2c_clk(struct ixgbe_hw *hw, uint32_t *i2cctl)
{
- int32_t status = IXGBE_SUCCESS;
+ int i;
*i2cctl |= IXGBE_I2C_CLK_OUT;
- IXGBE_WRITE_REG(hw, IXGBE_I2CCTL, *i2cctl);
-
- /* SCL rise time (1000ns) */
- usec_delay(IXGBE_I2C_T_RISE);
+ for (i = 0; i < IXGBE_I2C_CLOCK_STRETCHING_TIMEOUT; i++) {
+ IXGBE_WRITE_REG(hw, IXGBE_I2CCTL, *i2cctl);
+ IXGBE_WRITE_FLUSH(hw);
+ /* SCL rise time (1000ns) */
+ usec_delay(IXGBE_I2C_T_RISE);
- return status;
+ if (IXGBE_READ_REG(hw, IXGBE_I2CCTL) & IXGBE_I2C_CLK_IN)
+ return (IXGBE_SUCCESS);
+ }
+ return (IXGBE_ERR_I2C);
}
/**
diff --git a/sys/dev/pci/ixgbe_type.h b/sys/dev/pci/ixgbe_type.h
index 3e0bf9a690e..b7dfeb18cb4 100644
--- a/sys/dev/pci/ixgbe_type.h
+++ b/sys/dev/pci/ixgbe_type.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: ixgbe_type.h,v 1.17 2012/12/17 18:38:27 mikeb Exp $ */
+/* $OpenBSD: ixgbe_type.h,v 1.18 2012/12/17 18:44:27 mikeb Exp $ */
/******************************************************************************
@@ -113,6 +113,7 @@
#define IXGBE_I2C_CLK_OUT 0x00000002
#define IXGBE_I2C_DATA_IN 0x00000004
#define IXGBE_I2C_DATA_OUT 0x00000008
+#define IXGBE_I2C_CLOCK_STRETCHING_TIMEOUT 500
/* Interrupt Registers */
#define IXGBE_EICR 0x00800