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: tcpci: support setting orientation via GPIO

If the chip indicates its "Connection Orientation" standard output control
in STANDARD_OUTPUT_CAPABILITIES register, it can do the thing by
programming CONFIG_STANDARD_OUTPUT register. Due to the optional feature,
the chip which not present this capability currently doesn't have a way to
correctly set the data path. This add the support to set orientation via
a simple GPIO.

Signed-off-by: Xu Yang <xu.yang_2@nxp.com>
Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Link: https://patch.msgid.link/20260319-support-setting-orientation-use-gpio-v4-2-ab6dfa8610c2@nxp.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Xu Yang and committed by
Greg Kroah-Hartman
35a99b69 7ef80d63

+18
+18
drivers/usb/typec/tcpm/tcpci.c
··· 7 7 8 8 #include <linux/bitfield.h> 9 9 #include <linux/delay.h> 10 + #include <linux/gpio/consumer.h> 10 11 #include <linux/kernel.h> 11 12 #include <linux/module.h> 12 13 #include <linux/i2c.h> ··· 43 42 44 43 struct tcpc_dev tcpc; 45 44 struct tcpci_data *data; 45 + struct gpio_desc *orientation_gpio; 46 46 }; 47 47 48 48 struct tcpci_chip { ··· 317 315 { 318 316 struct tcpci *tcpci = tcpc_to_tcpci(tcpc); 319 317 unsigned int reg; 318 + 319 + if (tcpci->orientation_gpio) 320 + return gpiod_set_value_cansleep(tcpci->orientation_gpio, 321 + orientation != TYPEC_ORIENTATION_NORMAL); 320 322 321 323 switch (orientation) { 322 324 case TYPEC_ORIENTATION_NONE: ··· 909 903 static int tcpci_probe(struct i2c_client *client) 910 904 { 911 905 struct tcpci_chip *chip; 906 + struct gpio_desc *orient_gpio = NULL; 912 907 int err; 913 908 u16 val = 0; 914 909 ··· 938 931 if (err < 0) 939 932 return err; 940 933 934 + if (err == 0) { 935 + orient_gpio = devm_gpiod_get_optional(&client->dev, "orientation", 936 + GPIOD_OUT_LOW); 937 + if (IS_ERR(orient_gpio)) 938 + return dev_err_probe(&client->dev, PTR_ERR(orient_gpio), 939 + "unable to acquire orientation gpio\n"); 940 + err = !!orient_gpio; 941 + } 942 + 941 943 chip->data.set_orientation = err; 942 944 943 945 chip->tcpci = tcpci_register_port(&client->dev, &chip->data); 944 946 if (IS_ERR(chip->tcpci)) 945 947 return PTR_ERR(chip->tcpci); 948 + 949 + chip->tcpci->orientation_gpio = orient_gpio; 946 950 947 951 err = devm_request_threaded_irq(&client->dev, client->irq, NULL, 948 952 _tcpci_irq,