Commit 4995bb15 authored by Hans de Goede's avatar Hans de Goede Committed by Greg Kroah-Hartman

usb: typec: fusb302: Fold fusb302_set_cc_pull into tcpm_set_cc

After the recent cleanups, tcpm_set_cc is the only caller of
fusb302_set_cc_pull, fold fusb302_set_cc_pull directly into
tcpm_set_cc for a nice cleanup.
Reviewed-by: default avatarGuenter Roeck <linux@roeck-us.net>
Signed-off-by: default avatarHans de Goede <hdegoede@redhat.com>
Acked-by: default avatarHeikki Krogerus <heikki.krogerus@linux.intel.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent daf81d01
...@@ -518,31 +518,6 @@ static int tcpm_get_current_limit(struct tcpc_dev *dev) ...@@ -518,31 +518,6 @@ static int tcpm_get_current_limit(struct tcpc_dev *dev)
return current_limit; return current_limit;
} }
static int fusb302_set_cc_pull(struct fusb302_chip *chip,
bool pull_up, bool pull_down)
{
int ret = 0;
u8 data = 0x00;
u8 mask = FUSB_REG_SWITCHES0_CC1_PU_EN |
FUSB_REG_SWITCHES0_CC2_PU_EN |
FUSB_REG_SWITCHES0_CC1_PD_EN |
FUSB_REG_SWITCHES0_CC2_PD_EN;
if (pull_up)
data |= (chip->cc_polarity == TYPEC_POLARITY_CC1) ?
FUSB_REG_SWITCHES0_CC1_PU_EN :
FUSB_REG_SWITCHES0_CC2_PU_EN;
if (pull_down)
data |= FUSB_REG_SWITCHES0_CC1_PD_EN |
FUSB_REG_SWITCHES0_CC2_PD_EN;
ret = fusb302_i2c_mask_write(chip, FUSB_REG_SWITCHES0,
mask, data);
if (ret < 0)
return ret;
return ret;
}
static int fusb302_set_src_current(struct fusb302_chip *chip, static int fusb302_set_src_current(struct fusb302_chip *chip,
enum src_current_status status) enum src_current_status status)
{ {
...@@ -674,27 +649,30 @@ static int tcpm_set_cc(struct tcpc_dev *dev, enum typec_cc_status cc) ...@@ -674,27 +649,30 @@ static int tcpm_set_cc(struct tcpc_dev *dev, enum typec_cc_status cc)
{ {
struct fusb302_chip *chip = container_of(dev, struct fusb302_chip, struct fusb302_chip *chip = container_of(dev, struct fusb302_chip,
tcpc_dev); tcpc_dev);
u8 switches0_mask = FUSB_REG_SWITCHES0_CC1_PU_EN |
FUSB_REG_SWITCHES0_CC2_PU_EN |
FUSB_REG_SWITCHES0_CC1_PD_EN |
FUSB_REG_SWITCHES0_CC2_PD_EN;
u8 switches0_data = 0x00;
int ret = 0; int ret = 0;
bool pull_up, pull_down;
enum toggling_mode mode; enum toggling_mode mode;
mutex_lock(&chip->lock); mutex_lock(&chip->lock);
switch (cc) { switch (cc) {
case TYPEC_CC_OPEN: case TYPEC_CC_OPEN:
pull_up = false;
pull_down = false;
mode = TOGGLING_MODE_OFF; mode = TOGGLING_MODE_OFF;
break; break;
case TYPEC_CC_RD: case TYPEC_CC_RD:
pull_up = false; switches0_data |= FUSB_REG_SWITCHES0_CC1_PD_EN |
pull_down = true; FUSB_REG_SWITCHES0_CC2_PD_EN;
mode = TOGGLING_MODE_SNK; mode = TOGGLING_MODE_SNK;
break; break;
case TYPEC_CC_RP_DEF: case TYPEC_CC_RP_DEF:
case TYPEC_CC_RP_1_5: case TYPEC_CC_RP_1_5:
case TYPEC_CC_RP_3_0: case TYPEC_CC_RP_3_0:
pull_up = true; switches0_data |= (chip->cc_polarity == TYPEC_POLARITY_CC1) ?
pull_down = false; FUSB_REG_SWITCHES0_CC1_PU_EN :
FUSB_REG_SWITCHES0_CC2_PU_EN;
mode = TOGGLING_MODE_SRC; mode = TOGGLING_MODE_SRC;
break; break;
default: default:
...@@ -706,13 +684,10 @@ static int tcpm_set_cc(struct tcpc_dev *dev, enum typec_cc_status cc) ...@@ -706,13 +684,10 @@ static int tcpm_set_cc(struct tcpc_dev *dev, enum typec_cc_status cc)
fusb302_log(chip, "cc := %s", typec_cc_status_name[cc]); fusb302_log(chip, "cc := %s", typec_cc_status_name[cc]);
ret = fusb302_set_cc_pull(chip, pull_up, pull_down); ret = fusb302_i2c_mask_write(chip, FUSB_REG_SWITCHES0,
switches0_mask, switches0_data);
if (ret < 0) { if (ret < 0) {
fusb302_log(chip, fusb302_log(chip, "cannot set pull-up/-down, ret = %d", ret);
"cannot set cc pulling up %s, down %s, ret = %d",
pull_up ? "True" : "False",
pull_down ? "True" : "False",
ret);
goto done; goto done;
} }
/* reset the cc status */ /* reset the cc status */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment