Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clock stop cleanup #13

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 22 additions & 14 deletions drivers/soundwire/bus.c
Original file line number Diff line number Diff line change
Expand Up @@ -813,19 +813,16 @@ static int sdw_bus_wait_for_clk_prep_deprep(struct sdw_bus *bus, u16 dev_num)
do {
val = sdw_bread_no_pm(bus, dev_num, SDW_SCP_STAT) &
SDW_SCP_STAT_CLK_STP_NF;
if (!val)
break;
if (!val) {
dev_info(bus->dev, "clock stop prep/de-prep done slave:%d",
dev_num);
return 0;
}

usleep_range(1000, 1500);
retry--;
} while (retry);

if (retry && !val) {
dev_info(bus->dev, "clock stop prep/de-prep done slave:%d",
dev_num);
return 0;
}

dev_err(bus->dev, "clock stop prep/de-prep failed slave:%d",
dev_num);

Expand Down Expand Up @@ -856,13 +853,13 @@ int sdw_bus_prep_clk_stop(struct sdw_bus *bus)
if (!slave->dev_num)
continue;

/* Identify if Slave(s) are available on Bus */
is_slave = true;

if (slave->status != SDW_SLAVE_ATTACHED &&
slave->status != SDW_SLAVE_ALERT)
continue;

/* Identify if Slave(s) are available on Bus */
is_slave = true;

slave_mode = sdw_get_clk_stop_mode(slave);
slave->curr_clk_stop_mode = slave_mode;

Expand Down Expand Up @@ -893,6 +890,10 @@ int sdw_bus_prep_clk_stop(struct sdw_bus *bus)
return ret;
}

/* Don't need to inform slaves if there is no slave attached */
if (!is_slave)
return ret;

/* Inform slaves that prep is done */
list_for_each_entry(slave, &bus->slaves, node) {
if (!slave->dev_num)
Expand Down Expand Up @@ -978,13 +979,13 @@ int sdw_bus_exit_clk_stop(struct sdw_bus *bus)
if (!slave->dev_num)
continue;

/* Identify if Slave(s) are available on Bus */
is_slave = true;

if (slave->status != SDW_SLAVE_ATTACHED &&
slave->status != SDW_SLAVE_ALERT)
continue;

/* Identify if Slave(s) are available on Bus */
is_slave = true;

mode = slave->curr_clk_stop_mode;

if (mode == SDW_CLK_STOP_MODE1) {
Expand All @@ -1009,6 +1010,13 @@ int sdw_bus_exit_clk_stop(struct sdw_bus *bus)
if (is_slave && !simple_clk_stop)
sdw_bus_wait_for_clk_prep_deprep(bus, SDW_BROADCAST_DEV_NUM);

/*
* Don't need to call slave callback function if there is no slave
* attached
*/
if (!is_slave)
return 0;

list_for_each_entry(slave, &bus->slaves, node) {
if (!slave->dev_num)
continue;
Expand Down