Skip to content

Commit ef1e29c

Browse files
superna9999gregkh
authored andcommitted
usb: typec: fsa4480: add support for Audio Accessory Mode
The FSA4480 Type-C switch supports switching the Audio R/L, AGND and MIC signals to the USB-C DP/DM and SBU1/2 to support the Audio Accessory Mode. The FSA4480 has an integrated Audio jack detection mechanism to automatically mux the AGND, MIX and Sense to the correct SBU lines to support 3 pole and both 4 pole TRRS pinouts. Signed-off-by: Neil Armstrong <neil.armstrong@linaro.org> Tested-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org> Link: https://lore.kernel.org/r/20230614-topic-sm8550-upstream-type-c-audio-v1-3-15a92565146b@linaro.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent c7054c3 commit ef1e29c

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

drivers/usb/typec/mux/fsa4480.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,24 @@
2525
#define FSA4480_DELAY_L_MIC 0x0e
2626
#define FSA4480_DELAY_L_SENSE 0x0f
2727
#define FSA4480_DELAY_L_AGND 0x10
28+
#define FSA4480_FUNCTION_ENABLE 0x12
2829
#define FSA4480_RESET 0x1e
2930
#define FSA4480_MAX_REGISTER 0x1f
3031

3132
#define FSA4480_ENABLE_DEVICE BIT(7)
3233
#define FSA4480_ENABLE_SBU GENMASK(6, 5)
3334
#define FSA4480_ENABLE_USB GENMASK(4, 3)
35+
#define FSA4480_ENABLE_SENSE BIT(2)
36+
#define FSA4480_ENABLE_MIC BIT(1)
37+
#define FSA4480_ENABLE_AGND BIT(0)
3438

3539
#define FSA4480_SEL_SBU_REVERSE GENMASK(6, 5)
3640
#define FSA4480_SEL_USB GENMASK(4, 3)
41+
#define FSA4480_SEL_SENSE BIT(2)
42+
#define FSA4480_SEL_MIC BIT(1)
43+
#define FSA4480_SEL_AGND BIT(0)
44+
45+
#define FSA4480_ENABLE_AUTO_JACK_DETECT BIT(0)
3746

3847
struct fsa4480 {
3948
struct i2c_client *client;
@@ -95,6 +104,9 @@ static int fsa4480_set(struct fsa4480 *fsa)
95104
default:
96105
return -EOPNOTSUPP;
97106
}
107+
} else if (fsa->mode == TYPEC_MODE_AUDIO) {
108+
/* Audio Accessory Mode, setup to auto Jack Detection */
109+
enable |= FSA4480_ENABLE_USB | FSA4480_ENABLE_AGND;
98110
} else
99111
return -EOPNOTSUPP;
100112

@@ -110,6 +122,11 @@ static int fsa4480_set(struct fsa4480 *fsa)
110122
regmap_write(fsa->regmap, FSA4480_SWITCH_SELECT, sel);
111123
regmap_write(fsa->regmap, FSA4480_SWITCH_ENABLE, enable);
112124

125+
/* Start AUDIO JACK DETECTION to setup MIC, AGND & Sense muxes */
126+
if (enable & FSA4480_ENABLE_AGND)
127+
regmap_write(fsa->regmap, FSA4480_FUNCTION_ENABLE,
128+
FSA4480_ENABLE_AUTO_JACK_DETECT);
129+
113130
if (enable & FSA4480_ENABLE_SBU) {
114131
/* 15us to allow the SBU switch to turn on again */
115132
usleep_range(15, 1000);

0 commit comments

Comments
 (0)