aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/spi/spi_bfin5xx.c
diff options
context:
space:
mode:
authorBarry Song <barry.song@analog.com>2009-11-18 04:43:21 -0500
committerMike Frysinger <vapier@gentoo.org>2010-10-18 02:49:37 -0400
commitb052fd0a44354c655eb98fd715ef52857631dfef (patch)
tree31f852bed15cd4ab35c9e4932476ca58d928d3d2 /drivers/spi/spi_bfin5xx.c
parentd3cc71f71ae13596cb988e16bfa2b15f09fb7347 (diff)
spi/bfin_spi: save/restore state when suspending/resuming
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>
Diffstat (limited to 'drivers/spi/spi_bfin5xx.c')
-rw-r--r--drivers/spi/spi_bfin5xx.c17
1 files changed, 13 insertions, 4 deletions
diff --git a/drivers/spi/spi_bfin5xx.c b/drivers/spi/spi_bfin5xx.c
index 278fe0a612c2..c23ac3b90533 100644
--- a/drivers/spi/spi_bfin5xx.c
+++ b/drivers/spi/spi_bfin5xx.c
@@ -101,6 +101,9 @@ struct master_data {
101 size_t rx_map_len; 101 size_t rx_map_len;
102 size_t tx_map_len; 102 size_t tx_map_len;
103 u8 n_bytes; 103 u8 n_bytes;
104 u16 ctrl_reg;
105 u16 flag_reg;
106
104 int cs_change; 107 int cs_change;
105 const struct transfer_ops *ops; 108 const struct transfer_ops *ops;
106}; 109};
@@ -1426,8 +1429,14 @@ static int bfin_spi_suspend(struct platform_device *pdev, pm_message_t state)
1426 if (status != 0) 1429 if (status != 0)
1427 return status; 1430 return status;
1428 1431
1429 /* stop hardware */ 1432 drv_data->ctrl_reg = read_CTRL(drv_data);
1430 bfin_spi_disable(drv_data); 1433 drv_data->flag_reg = read_FLAG(drv_data);
1434
1435 /*
1436 * reset SPI_CTL and SPI_FLG registers
1437 */
1438 write_CTRL(drv_data, BIT_CTL_CPHA | BIT_CTL_MASTER);
1439 write_FLAG(drv_data, 0xFF00);
1431 1440
1432 return 0; 1441 return 0;
1433} 1442}
@@ -1437,8 +1446,8 @@ static int bfin_spi_resume(struct platform_device *pdev)
1437 struct master_data *drv_data = platform_get_drvdata(pdev); 1446 struct master_data *drv_data = platform_get_drvdata(pdev);
1438 int status = 0; 1447 int status = 0;
1439 1448
1440 /* Enable the SPI interface */ 1449 write_CTRL(drv_data, drv_data->ctrl_reg);
1441 bfin_spi_enable(drv_data); 1450 write_FLAG(drv_data, drv_data->flag_reg);
1442 1451
1443 /* Start the queue running */ 1452 /* Start the queue running */
1444 status = bfin_spi_start_queue(drv_data); 1453 status = bfin_spi_start_queue(drv_data);