Skip to content

Commit

Permalink
spi/bfin_spi: save/restore state when suspending/resuming
Browse files Browse the repository at this point in the history
We can't rely on the SPI_CTL/SPI_FLG registers retaining their state when
suspending, so save/restore their entire values.

Signed-off-by: Barry Song <barry.song@analog.com>
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
  • Loading branch information
Barry Song authored and Mike Frysinger committed Oct 18, 2010
1 parent d3cc71f commit b052fd0
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions drivers/spi/spi_bfin5xx.c
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,9 @@ struct master_data {
size_t rx_map_len;
size_t tx_map_len;
u8 n_bytes;
u16 ctrl_reg;
u16 flag_reg;

int cs_change;
const struct transfer_ops *ops;
};
Expand Down Expand Up @@ -1426,8 +1429,14 @@ static int bfin_spi_suspend(struct platform_device *pdev, pm_message_t state)
if (status != 0)
return status;

/* stop hardware */
bfin_spi_disable(drv_data);
drv_data->ctrl_reg = read_CTRL(drv_data);
drv_data->flag_reg = read_FLAG(drv_data);

/*
* reset SPI_CTL and SPI_FLG registers
*/
write_CTRL(drv_data, BIT_CTL_CPHA | BIT_CTL_MASTER);
write_FLAG(drv_data, 0xFF00);

return 0;
}
Expand All @@ -1437,8 +1446,8 @@ static int bfin_spi_resume(struct platform_device *pdev)
struct master_data *drv_data = platform_get_drvdata(pdev);
int status = 0;

/* Enable the SPI interface */
bfin_spi_enable(drv_data);
write_CTRL(drv_data, drv_data->ctrl_reg);
write_FLAG(drv_data, drv_data->flag_reg);

/* Start the queue running */
status = bfin_spi_start_queue(drv_data);
Expand Down

0 comments on commit b052fd0

Please sign in to comment.