summaryrefslogtreecommitdiff
path: root/driver/retimer/ps8811.h
blob: 5721f31eae2f8c1ee81647ebe4b5b8b4972ba284 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
/* Copyright 2020 The Chromium OS Authors. All rights reserved.
 * Use of this source code is governed by a BSD-style license that can be
 * found in the LICENSE file.
 *
 * PS8811 retimer.
 */

#include "usb_mux.h"

#ifndef __CROS_EC_USB_RETIMER_PS8811_H
#define __CROS_EC_USB_RETIMER_PS8811_H

/*
 * PS8811 uses 7-bit I2C addresses 0x28 to 0x29 (ADDR=LL).
 * Page 0 = 0x28, Page 1 = 0x29.
 * PS8811 uses 7-bit I2C addresses 0x2A to 0x2B (ADDR=LH).
 * Page 0 = 0x2A, Page 1 = 0x2B.
 * PS8811 uses 7-bit I2C addresses 0x70 to 0x71 (ADDR=HL).
 * Page 0 = 0x70, Page 1 = 0x71.
 * PS8811 uses 7-bit I2C addresses 0x72 to 0x73 (ADDR=HH).
 * Page 0 = 0x72, Page 1 = 0x73.
 */
#define PS8811_I2C_ADDR_FLAGS0	0x28
#define PS8811_I2C_ADDR_FLAGS1	0x2A
#define PS8811_I2C_ADDR_FLAGS2	0x70
#define PS8811_I2C_ADDR_FLAGS3	0x72

/*
 * PAGE 1 Register Definitions
 */
#define PS8811_REG_PAGE1			0x01

#define PS8811_REG1_USB_AEQ_LEVEL		0x01
#define PS8811_AEQ_PIN_LEVEL_UP_CONFIG_MASK	GENMASK(3, 0)
#define PS8811_AEQ_PIN_LEVEL_UP_SHIFT		0
#define PS8811_AEQ_PIN_LEVEL_UP_9DB		0x00
#define PS8811_AEQ_PIN_LEVEL_UP_10P5DB		0x01
#define PS8811_AEQ_PIN_LEVEL_UP_12DB		0x02
#define PS8811_AEQ_PIN_LEVEL_UP_13DB		0x03
#define PS8811_AEQ_PIN_LEVEL_UP_16DB		0x04
#define PS8811_AEQ_PIN_LEVEL_UP_17DB		0x05
#define PS8811_AEQ_PIN_LEVEL_UP_18DB		0x06
#define PS8811_AEQ_PIN_LEVEL_UP_19DB		0x07
#define PS8811_AEQ_PIN_LEVEL_UP_20DB		0x08
#define PS8811_AEQ_PIN_LEVEL_UP_21DB		0x09
#define PS8811_AEQ_PIN_LEVEL_UP_23DB		0x0A
#define PS8811_AEQ_I2C_LEVEL_UP_CONFIG_MASK	GENMASK(7, 4)
#define PS8811_AEQ_I2C_LEVEL_UP_SHIFT		4
#define PS8811_AEQ_I2C_LEVEL_UP_9DB		0x00
#define PS8811_AEQ_I2C_LEVEL_UP_10P5DB		0x01
#define PS8811_AEQ_I2C_LEVEL_UP_12DB		0x02
#define PS8811_AEQ_I2C_LEVEL_UP_13DB		0x03
#define PS8811_AEQ_I2C_LEVEL_UP_16DB		0x04
#define PS8811_AEQ_I2C_LEVEL_UP_17DB		0x05
#define PS8811_AEQ_I2C_LEVEL_UP_18DB		0x06
#define PS8811_AEQ_I2C_LEVEL_UP_19DB		0x07
#define PS8811_AEQ_I2C_LEVEL_UP_20DB		0x08
#define PS8811_AEQ_I2C_LEVEL_UP_21DB		0x09
#define PS8811_AEQ_I2C_LEVEL_UP_23DB		0x0A

#define PS8811_REG1_USB_ADE_CONFIG		0x02
#define PS8811_AEQ_CONFIG_REG_ENABLE		BIT(0)
#define PS8811_AEQ_ADAPTIVE_REG_ENABLE		BIT(1)
#define PS8811_ADE_PIN_MID_LEVEL_CONFIG_MASK	GENMASK(7, 5)
#define PS8811_ADE_PIN_MID_LEVEL_SHIFT		5
#define PS8811_ADE_PIN_MID_LEVEL_0P5DB		0x00
#define PS8811_ADE_PIN_MID_LEVEL_1P5DB		0x01
#define PS8811_ADE_PIN_MID_LEVEL_2DB		0x02
#define PS8811_ADE_PIN_MID_LEVEL_3DB		0x03
#define PS8811_ADE_PIN_MID_LEVEL_3P5DB		0x04
#define PS8811_ADE_PIN_MID_LEVEL_4P5DB		0x05
#define PS8811_ADE_PIN_MID_LEVEL_6DB		0x06
#define PS8811_ADE_PIN_MID_LEVEL_7P5DB		0x07
#define PS8811_ADE_PIN_LOW_LEVEL_CONFIG_MASK	GENMASK(4, 2)
#define PS8811_ADE_PIN_LOW_LEVEL_SHIFT		2
#define PS8811_ADE_PIN_LOW_LEVEL_0P5DB		0x00
#define PS8811_ADE_PIN_LOW_LEVEL_1P5DB		0x01
#define PS8811_ADE_PIN_LOW_LEVEL_2DB		0x02
#define PS8811_ADE_PIN_LOW_LEVEL_3DB		0x03
#define PS8811_ADE_PIN_LOW_LEVEL_3P5DB		0x04
#define PS8811_ADE_PIN_LOW_LEVEL_4P5DB		0x05
#define PS8811_ADE_PIN_LOW_LEVEL_6DB		0x06
#define PS8811_ADE_PIN_LOW_LEVEL_7P5DB		0x07

#define PS8811_REG1_USB_BEQ_LEVEL		0x05
#define PS8811_BEQ_PIN_LEVEL_UP_CONFIG_MASK	GENMASK(3, 0)
#define PS8811_BEQ_PIN_LEVEL_UP_SHIFT		0
#define PS8811_BEQ_PIN_LEVEL_UP_9DB		0x00
#define PS8811_BEQ_PIN_LEVEL_UP_10P5DB		0x01
#define PS8811_BEQ_PIN_LEVEL_UP_12DB		0x02
#define PS8811_BEQ_PIN_LEVEL_UP_13DB		0x03
#define PS8811_BEQ_PIN_LEVEL_UP_16DB		0x04
#define PS8811_BEQ_PIN_LEVEL_UP_17DB		0x05
#define PS8811_BEQ_PIN_LEVEL_UP_18DB		0x06
#define PS8811_BEQ_PIN_LEVEL_UP_19DB		0x07
#define PS8811_BEQ_PIN_LEVEL_UP_20DB		0x08
#define PS8811_BEQ_PIN_LEVEL_UP_21DB		0x09
#define PS8811_BEQ_PIN_LEVEL_UP_23DB		0x0A
#define PS8811_BEQ_I2C_LEVEL_UP_CONFIG_MASK	GENMASK(7, 4)
#define PS8811_BEQ_I2C_LEVEL_UP_SHIFT		4
#define PS8811_BEQ_I2C_LEVEL_UP_9DB		0x00
#define PS8811_BEQ_I2C_LEVEL_UP_10P5DB		0x01
#define PS8811_BEQ_I2C_LEVEL_UP_12DB		0x02
#define PS8811_BEQ_I2C_LEVEL_UP_13DB		0x03
#define PS8811_BEQ_I2C_LEVEL_UP_16DB		0x04
#define PS8811_BEQ_I2C_LEVEL_UP_17DB		0x05
#define PS8811_BEQ_I2C_LEVEL_UP_18DB		0x06
#define PS8811_BEQ_I2C_LEVEL_UP_19DB		0x07
#define PS8811_BEQ_I2C_LEVEL_UP_20DB		0x08
#define PS8811_BEQ_I2C_LEVEL_UP_21DB		0x09
#define PS8811_BEQ_I2C_LEVEL_UP_23DB		0x0A

#define PS8811_REG1_USB_BDE_CONFIG		0x06
#define PS8811_BEQ_CONFIG_REG_ENABLE		BIT(0)
#define PS8811_BEQ_ADAPTIVE_REG_ENABLE		BIT(1)
#define PS8811_BDE_PIN_MID_LEVEL_CONFIG_MASK	GENMASK(7, 5)
#define PS8811_BDE_PIN_MID_LEVEL_SHIFT		5
#define PS8811_BDE_PIN_MID_LEVEL_0P5DB		0x00
#define PS8811_BDE_PIN_MID_LEVEL_1P5DB		0x01
#define PS8811_BDE_PIN_MID_LEVEL_2DB		0x02
#define PS8811_BDE_PIN_MID_LEVEL_3DB		0x03
#define PS8811_BDE_PIN_MID_LEVEL_3P5DB		0x04
#define PS8811_BDE_PIN_MID_LEVEL_4P5DB		0x05
#define PS8811_BDE_PIN_MID_LEVEL_6DB		0x06
#define PS8811_BDE_PIN_MID_LEVEL_7P5DB		0x07
#define PS8811_BDE_PIN_LOW_LEVEL_CONFIG_MASK	GENMASK(4, 2)
#define PS8811_BDE_PIN_LOW_LEVEL_SHIFT		2
#define PS8811_BDE_PIN_LOW_LEVEL_0P5DB		0x00
#define PS8811_BDE_PIN_LOW_LEVEL_1P5DB		0x01
#define PS8811_BDE_PIN_LOW_LEVEL_2DB		0x02
#define PS8811_BDE_PIN_LOW_LEVEL_3DB		0x03
#define PS8811_BDE_PIN_LOW_LEVEL_3P5DB		0x04
#define PS8811_BDE_PIN_LOW_LEVEL_4P5DB		0x05
#define PS8811_BDE_PIN_LOW_LEVEL_6DB		0x06
#define PS8811_BDE_PIN_LOW_LEVEL_7P5DB		0x07

#define PS8811_REG1_USB_CHAN_A_SWING		0x66
#define PS8811_CHAN_A_SWING_MASK		GENMASK(6, 4)
#define PS8811_CHAN_A_SWING_SHIFT		4

#define PS8811_REG1_50OHM_ADJUST_CHAN_B	0x73
#define PS8811_50OHM_ADJUST_CHAN_B_CONFIG_MASK	GENMASK(3, 1)
#define PS8811_50OHM_ADJUST_CHAN_B_SHIFT		1
#define PS8811_50OHM_ADJUST_CHAN_B_DEFAULT	0x00
#define PS8811_50OHM_ADJUST_CHAN_B_MINUS_6PCT	0x01
#define PS8811_50OHM_ADJUST_CHAN_B_MINUS_9PCT	0x02
#define PS8811_50OHM_ADJUST_CHAN_B_MINUS_14PCT	0x03
#define PS8811_50OHM_ADJUST_CHAN_B_PLUS_7PCT	0x04
#define PS8811_50OHM_ADJUST_CHAN_B_PLUS_11PCT	0x05
#define PS8811_50OHM_ADJUST_CHAN_B_PLUS_20PCT	0x06

#define PS8811_BDE_PIN_MID_LEVEL_1P5DB		0x01
#define PS8811_BDE_PIN_MID_LEVEL_2DB		0x02
#define PS8811_BDE_PIN_MID_LEVEL_3DB		0x03
#define PS8811_BDE_PIN_MID_LEVEL_3P5DB		0x04
#define PS8811_BDE_PIN_MID_LEVEL_4P5DB		0x05
#define PS8811_BDE_PIN_MID_LEVEL_6DB		0x06
#define PS8811_BDE_PIN_MID_LEVEL_7P5DB		0x07

#define PS8811_REG1_USB_CHAN_B_SWING		0xA4
#define PS8811_CHAN_B_SWING_MASK		GENMASK(2, 0)
#define PS8811_CHAN_B_SWING_SHIFT		0

/* De-emphasis -2.2 dB, Pre-shoot 1.2 dB */
#define PS8811_CHAN_B_DE_2_2_PS_1_2_LSB		0x1
#define PS8811_CHAN_B_DE_2_2_PS_1_2_MSB		0x13

/* De-emphasis -3.5 dB, Pre-shoot 0 dB */
#define PS8811_CHAN_B_DE_3_5_PS_0_LSB		0x0
#define PS8811_CHAN_B_DE_3_5_PS_0_MSB		0x5

/* De-emphasis -4.5 dB, Pre-shoot 0 dB */
#define PS8811_CHAN_B_DE_4_5_PS_0_LSB		0x0
#define PS8811_CHAN_B_DE_4_5_PS_0_MSB		0x6

/* De-emphasis -6 dB, Pre-shoot 1.5 dB */
#define PS8811_CHAN_B_DE_6_PS_1_5_LSB		0x2
#define PS8811_CHAN_B_DE_6_PS_1_5_MSB		0x16

/* De-emphasis -6 dB, Pre-shoot 3 dB */
#define PS8811_CHAN_B_DE_6_PS_3_LSB		0x4
#define PS8811_CHAN_B_DE_6_PS_3_MSB		0x16

#define PS8811_REG1_USB_CHAN_B_DE_PS_LSB	0xA5
#define PS8811_CHAN_B_DE_PS_LSB_MASK		GENMASK(2, 0)

#define PS8811_REG1_USB_CHAN_B_DE_PS_MSB	0xA6
#define PS8811_CHAN_B_DE_PS_MSB_MASK		GENMASK(5, 0)

int ps8811_i2c_read(const struct usb_mux *me, int page, int offset, int *data);
int ps8811_i2c_write(const struct usb_mux *me, int page, int offset, int data);
int ps8811_i2c_field_update(const struct usb_mux *me, int page, int offset,
			    uint8_t field_mask, uint8_t set_value);

#endif /* __CROS_EC_USB_RETIMER_PS8802_H */