Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b6deb84a authored by Ashay Jaiswal's avatar Ashay Jaiswal
Browse files

power: qpnp-typec: update SS-MUX configuration logic



SS-MUX Tx/Rx line connection is configured using an external GPIO.
Update the logic to control gpio output based on gpio flag.

CRs-Fixed: 977313
Change-Id: I27092e70537ecff7851f61cfc3caa0a7a61036a2
Signed-off-by: default avatarAshay Jaiswal <ashayj@codeaurora.org>
parent 2c0d0c8b
Loading
Loading
Loading
Loading
+7 −5
Original line number Original line Diff line number Diff line
/*
/*
 * Copyright (c) 2015, The Linux Foundation. All rights reserved.
 * Copyright (c) 2015-2016, The Linux Foundation. All rights reserved.
 *
 *
 * This program is free software; you can redistribute it and/or modify
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 and
 * it under the terms of the GNU General Public License version 2 and
@@ -56,9 +56,9 @@
#define TYPEC_PSY_NAME		"typec"
#define TYPEC_PSY_NAME		"typec"


enum cc_line_state {
enum cc_line_state {
	OPEN,
	CC_1,
	CC_1,
	CC_2,
	CC_2,
	OPEN,
};
};


struct qpnp_typec_chip {
struct qpnp_typec_chip {
@@ -84,6 +84,7 @@ struct qpnp_typec_chip {
	int			cc_line_state;
	int			cc_line_state;
	int			current_ma;
	int			current_ma;
	int			ssmux_gpio;
	int			ssmux_gpio;
	enum of_gpio_flags	gpio_flag;
	int			typec_state;
	int			typec_state;
};
};


@@ -200,7 +201,8 @@ static int qpnp_typec_configure_ssmux(struct qpnp_typec_chip *chip,


			if (chip->ssmux_gpio) {
			if (chip->ssmux_gpio) {
				rc = gpio_direction_output(chip->ssmux_gpio,
				rc = gpio_direction_output(chip->ssmux_gpio,
						(cc_line == CC_2) ? 1 : 0);
					(chip->gpio_flag == OF_GPIO_ACTIVE_LOW)
						? !cc_line : cc_line);
				if (rc) {
				if (rc) {
					pr_err("failed to configure ssmux gpio rc=%d\n",
					pr_err("failed to configure ssmux gpio rc=%d\n",
							rc);
							rc);
@@ -436,8 +438,8 @@ static int qpnp_typec_parse_dt(struct qpnp_typec_chip *chip)


	/* SS-Mux configuration gpio */
	/* SS-Mux configuration gpio */
	if (of_find_property(node, "qcom,ssmux-gpio", NULL)) {
	if (of_find_property(node, "qcom,ssmux-gpio", NULL)) {
		chip->ssmux_gpio = of_get_named_gpio(node, "qcom,ssmux-gpio",
		chip->ssmux_gpio = of_get_named_gpio_flags(node,
				0);
				"qcom,ssmux-gpio", 0, &chip->gpio_flag);
		if (!gpio_is_valid(chip->ssmux_gpio)) {
		if (!gpio_is_valid(chip->ssmux_gpio)) {
			if (chip->ssmux_gpio != -EPROBE_DEFER)
			if (chip->ssmux_gpio != -EPROBE_DEFER)
				pr_err("failed to get ss-mux config gpio=%d\n",
				pr_err("failed to get ss-mux config gpio=%d\n",