From 3f76e19769b5d8e3d53101886a4da27a5e6142a6 Mon Sep 17 00:00:00 2001 From: Li Jun Date: Wed, 9 Jan 2019 13:04:03 +0530 Subject: [PATCH] MLK-16298-1 usb: typec: make super speed signal mux select configurable Instead of fixed pull up super speed mux selection gpio for cc1, use GPIO_ACTIVE_HIGH/LOW to map the CC1/CC2 orientation via gpiod api, So for ss-sel-gpios: GPIO_ACTIVE_HIGH: CC1 <--> GPIO high GPIO_ACTIVE_LOW : CC1 <--> GPIO low Acked-by: Peter Chen Signed-off-by: Li Jun Signed-off-by: Vipul Kumar --- drivers/usb/typec/tcpci.c | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/drivers/usb/typec/tcpci.c b/drivers/usb/typec/tcpci.c index 86972c8a77c8..ce7cd482ffb9 100644 --- a/drivers/usb/typec/tcpci.c +++ b/drivers/usb/typec/tcpci.c @@ -32,7 +32,7 @@ struct tcpci { struct regmap *regmap; bool controls_vbus; - int ss_sel_gpio; + struct gpio_desc *ss_sel_gpio; struct tcpc_dev tcpc; unsigned int irq_mask; @@ -288,10 +288,13 @@ static int tcpci_set_ss_mux(struct tcpc_dev *tcpc, { struct tcpci *tcpci = tcpc_to_tcpci(tcpc); + if (!tcpci->ss_sel_gpio) + return 0; + if (polarity == TYPEC_POLARITY_CC1) - gpio_set_value(tcpci->ss_sel_gpio, 1); + gpiod_set_value_cansleep(tcpci->ss_sel_gpio, 1); else - gpio_set_value(tcpci->ss_sel_gpio, 0); + gpiod_set_value_cansleep(tcpci->ss_sel_gpio, 0); return 0; } @@ -656,22 +659,15 @@ static int tcpci_parse_config(struct tcpci *tcpci) static int tcpci_ss_mux_control_init(struct tcpci *tcpci) { struct device *dev = tcpci->dev; - int retval = 0; - tcpci->ss_sel_gpio = of_get_named_gpio(dev->of_node, - "ss-sel-gpios", 0); - if (!gpio_is_valid(tcpci->ss_sel_gpio)) { - /* Super speed signal mux conrol gpio is optional */ - dev_dbg(dev, "no Super Speed mux gpio pin available"); - } else { - retval = devm_gpio_request_one(dev, tcpci->ss_sel_gpio, - GPIOF_OUT_INIT_LOW, "typec_ss_sel"); - if (retval < 0) - dev_err(dev, "Unable to request super speed mux gpio %d\n", - retval); + tcpci->ss_sel_gpio = devm_gpiod_get_optional(dev, "ss-sel", + GPIOD_OUT_HIGH); + if (IS_ERR(tcpci->ss_sel_gpio)) { + dev_err(dev, "Failed to request super speed mux sel gpio."); + return PTR_ERR(tcpci->ss_sel_gpio); } - return retval; + return 0; } struct tcpci *tcpci_register_port(struct device *dev, struct tcpci_data *data) -- 2.17.1