1 /* SPDX-License-Identifier: GPL-2.0+ */
3 * Copyright 2022 Google, Inc
5 * MAXIM TCPC header file.
10 #define VENDOR_CC_STATUS2 0x85
11 #define CC1_VUFP_RD0P5 BIT(1)
12 #define CC2_VUFP_RD0P5 BIT(5)
13 #define TCPC_VENDOR_FLADC_STATUS 0x89
15 #define TCPC_VENDOR_CC_CTRL1 0x8c
16 #define CCCONNDRY BIT(7)
17 #define CCCOMPEN BIT(5)
19 #define TCPC_VENDOR_CC_CTRL2 0x8d
20 #define SBUOVPDIS BIT(7)
21 #define CCOVPDIS BIT(6)
22 #define SBURPCTRL BIT(5)
23 #define CCLPMODESEL_MASK GENMASK(4, 3)
24 #define ULTRA_LOW_POWER_MODE BIT(3)
25 #define CCRPCTRL_MASK GENMASK(2, 0)
29 #define TCPC_VENDOR_CC_CTRL3 0x8e
30 #define CCWTRDEB_MASK GENMASK(7, 6)
31 #define CCWTRDEB_SHIFT 6
32 #define CCWTRDEB_1MS 1
33 #define CCWTRSEL_MASK GENMASK(5, 3)
34 #define CCWTRSEL_SHIFT 3
35 #define CCWTRSEL_1V 0x4
36 #define CCLADDERDIS BIT(2)
37 #define WTRCYCLE_MASK BIT(0)
38 #define WTRCYCLE_SHIFT 0
39 #define WTRCYCLE_2_4_S 0
40 #define WTRCYCLE_4_8_S 1
42 #define TCPC_VENDOR_ADC_CTRL1 0x91
43 #define ADCINSEL_MASK GENMASK(7, 5)
44 #define ADC_CHANNEL_OFFSET 5
47 enum contamiant_state {
54 * @potential_contaminant:
55 * Last returned result to tcpm indicating whether the TCPM port
56 * has potential contaminant.
58 struct max_tcpci_chip {
59 struct tcpci_data data;
62 struct i2c_client *client;
63 struct tcpm_port *port;
64 enum contamiant_state contaminant_state;
67 static inline int max_tcpci_read16(struct max_tcpci_chip *chip, unsigned int reg, u16 *val)
69 return regmap_raw_read(chip->data.regmap, reg, val, sizeof(u16));
72 static inline int max_tcpci_write16(struct max_tcpci_chip *chip, unsigned int reg, u16 val)
74 return regmap_raw_write(chip->data.regmap, reg, &val, sizeof(u16));
77 static inline int max_tcpci_read8(struct max_tcpci_chip *chip, unsigned int reg, u8 *val)
79 return regmap_raw_read(chip->data.regmap, reg, val, sizeof(u8));
82 static inline int max_tcpci_write8(struct max_tcpci_chip *chip, unsigned int reg, u8 val)
84 return regmap_raw_write(chip->data.regmap, reg, &val, sizeof(u8));
87 bool max_contaminant_is_contaminant(struct max_tcpci_chip *chip, bool disconnect_while_debounce);
89 #endif // TCPCI_MAXIM_H_