#include <linux/bitfield.h>
#include <linux/delay.h>
+#include <linux/gpio/consumer.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/i2c.h>
struct tcpc_dev tcpc;
struct tcpci_data *data;
+ struct gpio_desc *orientation_gpio;
};
struct tcpci_chip {
struct tcpci *tcpci = tcpc_to_tcpci(tcpc);
unsigned int reg;
+ if (tcpci->orientation_gpio)
+ return gpiod_set_value_cansleep(tcpci->orientation_gpio,
+ orientation != TYPEC_ORIENTATION_NORMAL);
+
switch (orientation) {
case TYPEC_ORIENTATION_NONE:
/* We can't put a single output into high impedance */
static int tcpci_probe(struct i2c_client *client)
{
struct tcpci_chip *chip;
+ struct gpio_desc *orient_gpio = NULL;
int err;
u16 val = 0;
if (err < 0)
return err;
+ if (err == 0) {
+ orient_gpio = devm_gpiod_get_optional(&client->dev, "orientation",
+ GPIOD_OUT_LOW);
+ if (IS_ERR(orient_gpio))
+ return dev_err_probe(&client->dev, PTR_ERR(orient_gpio),
+ "unable to acquire orientation gpio\n");
+ err = !!orient_gpio;
+ }
+
chip->data.set_orientation = err;
chip->tcpci = tcpci_register_port(&client->dev, &chip->data);
if (IS_ERR(chip->tcpci))
return PTR_ERR(chip->tcpci);
+ chip->tcpci->orientation_gpio = orient_gpio;
+
err = devm_request_threaded_irq(&client->dev, client->irq, NULL,
_tcpci_irq,
IRQF_SHARED | IRQF_ONESHOT,