Commit b322fa07 authored by Angus Ainslie's avatar Angus Ainslie Committed by Martin Kepplinger
Browse files

usb: typec: tps6589x: set the data role on tps IRQ



Don't immediately set the data role, only set it in response the
negotiated value notification from the tps6589x. Otherwise data role
switch fails for DRP.

We only use values cached from the IRQ instead of poking I2C all
the time.

The update is moved in a function that will become more useful in later
commits.
Signed-off-by: default avatarAngus Ainslie <angus@akkea.ca>
Fixes: 18a6c866 ("usb: typec: tps6598x: Add USB role switching logic")
parent 4f5bf5eb
......@@ -95,6 +95,7 @@ struct tps6598x {
struct power_supply_desc psy_desc;
enum power_supply_usb_type usb_type;
u32 data_status;
u16 pwr_status;
};
......@@ -260,6 +261,15 @@ static int tps6598x_connect(struct tps6598x *tps, u32 status)
return 0;
}
static int
tps6598x_update_data_status(struct tps6598x *tps, u32 status)
{
tps6598x_set_data_role(tps, TPS_STATUS_TO_TYPEC_DATAROLE(status),
!!(tps->data_status & TPS_DATA_STATUS_DATA_CONNECTION));
trace_tps6598x_data_status(tps->data_status);
return 0;
}
static void tps6598x_disconnect(struct tps6598x *tps, u32 status)
{
if (!IS_ERR(tps->partner))
......@@ -358,8 +368,6 @@ static int tps6598x_dr_set(struct typec_port *port, enum typec_data_role role)
goto out_unlock;
}
tps6598x_set_data_role(tps, role, true);
out_unlock:
mutex_unlock(&tps->lock);
......@@ -406,7 +414,7 @@ static irqreturn_t tps6598x_interrupt(int irq, void *data)
struct tps6598x *tps = data;
u64 event1;
u64 event2;
u32 status;
u32 status, data_status;
u16 pwr_status;
int ret;
......@@ -443,7 +451,8 @@ static irqreturn_t tps6598x_interrupt(int irq, void *data)
dev_err(tps->dev, "failed to read data status: %d\n", ret);
goto err_clear_ints;
}
trace_tps6598x_data_status(data_status);
tps->data_status = data_status;
tps6598x_update_data_status(tps, status);
}
/* Handle plug insert or removal */
......
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