diff options
Diffstat (limited to 'driver/retimer')
-rw-r--r-- | driver/retimer/ps8818.c | 92 | ||||
-rw-r--r-- | driver/retimer/ps8818.h | 13 |
2 files changed, 49 insertions, 56 deletions
diff --git a/driver/retimer/ps8818.c b/driver/retimer/ps8818.c index 7facba04d2..10dc70dca0 100644 --- a/driver/retimer/ps8818.c +++ b/driver/retimer/ps8818.c @@ -25,7 +25,7 @@ int ps8818_i2c_read(int port, int page, int offset, int *data) offset, data); if (PS8818_DEBUG) - ccprintf("%s(%d:0x%02X, 0x%02X) => 0x%02X\n", __func__, + ccprintf("%s(%d:0x%02X, 0x%02X) =>0x%02X\n", __func__, usb_retimers[port].i2c_port, usb_retimers[port].i2c_addr_flags + page, offset, *data); @@ -35,31 +35,67 @@ int ps8818_i2c_read(int port, int page, int offset, int *data) int ps8818_i2c_write(int port, int page, int offset, int data) { + int rv; + int pre_val, post_val; + if (PS8818_DEBUG) - ccprintf("%s(%d:0x%02X, 0x%02X, 0x%02X)\n", __func__, + i2c_read8(usb_retimers[port].i2c_port, + usb_retimers[port].i2c_addr_flags + page, + offset, &pre_val); + + rv = i2c_write8(usb_retimers[port].i2c_port, + usb_retimers[port].i2c_addr_flags + page, + offset, data); + + if (PS8818_DEBUG) { + i2c_read8(usb_retimers[port].i2c_port, + usb_retimers[port].i2c_addr_flags + page, + offset, &post_val); + + ccprintf("%s(%d:0x%02X, 0x%02X, 0x%02X) " + "0x%02X=>0x%02X\n", + __func__, usb_retimers[port].i2c_port, usb_retimers[port].i2c_addr_flags + page, - offset, data); + offset, data, + pre_val, post_val); + } - return i2c_write8(usb_retimers[port].i2c_port, - usb_retimers[port].i2c_addr_flags + page, - offset, data); + return rv; } int ps8818_i2c_field_update8(int port, int page, int offset, uint8_t field_mask, uint8_t set_value) { + int rv; + int pre_val, post_val; + if (PS8818_DEBUG) - ccprintf("%s(%d:0x%02X, 0x%02X, 0x%02X, 0x%02X)\n", __func__, + i2c_read8(usb_retimers[port].i2c_port, + usb_retimers[port].i2c_addr_flags + page, + offset, &pre_val); + + rv = i2c_field_update8(usb_retimers[port].i2c_port, + usb_retimers[port].i2c_addr_flags + page, + offset, + field_mask, + set_value); + + if (PS8818_DEBUG) { + i2c_read8(usb_retimers[port].i2c_port, + usb_retimers[port].i2c_addr_flags + page, + offset, &post_val); + + ccprintf("%s(%d:0x%02X, 0x%02X, 0x%02X, 0x%02X) " + "0x%02X=>0x%02X\n", + __func__, usb_retimers[port].i2c_port, usb_retimers[port].i2c_addr_flags + page, - offset, field_mask, set_value); + offset, field_mask, set_value, + pre_val, post_val); + } - return i2c_field_update8(usb_retimers[port].i2c_port, - usb_retimers[port].i2c_addr_flags + page, - offset, - field_mask, - set_value); + return rv; } int ps8818_detect(int port) @@ -141,36 +177,6 @@ static int ps8818_set_mux(int port, mux_state_t mux_state) return rv; } - if (PS8818_DEBUG) { - int tx_status; - int rx_status; - - rv = ps8818_i2c_read(port, - PS8818_REG_PAGE2, - PS8818_REG2_TX_STATUS, - &tx_status); - if (rv) - return rv; - - rv = ps8818_i2c_read(port, - PS8818_REG_PAGE2, - PS8818_REG2_RX_STATUS, - &rx_status); - if (rv) - return rv; - - ccprintf("%s: tx:channel %snormal %s10Gbps\n", - __func__, - (tx_status & PS8818_STATUS_NORMAL_OPERATION) - ? "" : "NOT-", - (tx_status & PS8818_STATUS_10_GBPS) ? "" : "NON-"); - ccprintf("%s: rx:channel %snormal %s10Gbps\n", - __func__, - (rx_status & PS8818_STATUS_NORMAL_OPERATION) - ? "" : "NOT-", - (rx_status & PS8818_STATUS_10_GBPS) ? "" : "NON-"); - } - return rv; } diff --git a/driver/retimer/ps8818.h b/driver/retimer/ps8818.h index ff11ff930e..a28d04a38b 100644 --- a/driver/retimer/ps8818.h +++ b/driver/retimer/ps8818.h @@ -77,19 +77,6 @@ #define PS8818_STATUS_NORMAL_OPERATION BIT(7) #define PS8818_STATUS_10_GBPS BIT(5) -#define PS8818_REG2_LINK_BW_SET 0x60 -#define PS8818_LINK_BW_SET_1_62_GBPS 0x06 -#define PS8818_LINK_BW_SET_2_7_GBPS 0x0A -#define PS8818_LINK_BW_SET_5_4_GBPS 0x14 -#define PS8818_LINK_BW_SET_8_1_GBPS 0x1E -#define PS8818_LINK_BW_SET_MASK 0xFF - -#define PS8818_REG2_LANE_COUNT_SET 0x61 -#define PS8818_LANE_COUNT_SET_1_LANE 0x01 -#define PS8818_LANE_COUNT_SET_2_LANE 0x02 -#define PS8818_LANE_COUNT_SET_4_LANE 0x04 -#define PS8818_LANE_COUNT_SET_MASK 0x1F - extern const struct usb_retimer_driver ps8818_usb_retimer; int ps8818_detect(int port); |