Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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>

authored by

Neil Armstrong and committed by
Greg Kroah-Hartman
ef1e29c6 c7054c31

+17
+17
drivers/usb/typec/mux/fsa4480.c
··· 25 25 #define FSA4480_DELAY_L_MIC 0x0e 26 26 #define FSA4480_DELAY_L_SENSE 0x0f 27 27 #define FSA4480_DELAY_L_AGND 0x10 28 + #define FSA4480_FUNCTION_ENABLE 0x12 28 29 #define FSA4480_RESET 0x1e 29 30 #define FSA4480_MAX_REGISTER 0x1f 30 31 31 32 #define FSA4480_ENABLE_DEVICE BIT(7) 32 33 #define FSA4480_ENABLE_SBU GENMASK(6, 5) 33 34 #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) 34 38 35 39 #define FSA4480_SEL_SBU_REVERSE GENMASK(6, 5) 36 40 #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) 37 46 38 47 struct fsa4480 { 39 48 struct i2c_client *client; ··· 104 95 default: 105 96 return -EOPNOTSUPP; 106 97 } 98 + } else if (fsa->mode == TYPEC_MODE_AUDIO) { 99 + /* Audio Accessory Mode, setup to auto Jack Detection */ 100 + enable |= FSA4480_ENABLE_USB | FSA4480_ENABLE_AGND; 107 101 } else 108 102 return -EOPNOTSUPP; 109 103 ··· 121 109 122 110 regmap_write(fsa->regmap, FSA4480_SWITCH_SELECT, sel); 123 111 regmap_write(fsa->regmap, FSA4480_SWITCH_ENABLE, enable); 112 + 113 + /* Start AUDIO JACK DETECTION to setup MIC, AGND & Sense muxes */ 114 + if (enable & FSA4480_ENABLE_AGND) 115 + regmap_write(fsa->regmap, FSA4480_FUNCTION_ENABLE, 116 + FSA4480_ENABLE_AUTO_JACK_DETECT); 124 117 125 118 if (enable & FSA4480_ENABLE_SBU) { 126 119 /* 15us to allow the SBU switch to turn on again */