aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/spi/spi-atmel.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/spi/spi-atmel.c')
-rw-r--r--drivers/spi/spi-atmel.c51
1 files changed, 28 insertions, 23 deletions
diff --git a/drivers/spi/spi-atmel.c b/drivers/spi/spi-atmel.c
index b0842f751016..8005f9869481 100644
--- a/drivers/spi/spi-atmel.c
+++ b/drivers/spi/spi-atmel.c
@@ -9,7 +9,6 @@
9 */ 9 */
10 10
11#include <linux/kernel.h> 11#include <linux/kernel.h>
12#include <linux/init.h>
13#include <linux/clk.h> 12#include <linux/clk.h>
14#include <linux/module.h> 13#include <linux/module.h>
15#include <linux/platform_device.h> 14#include <linux/platform_device.h>
@@ -26,6 +25,7 @@
26 25
27#include <linux/io.h> 26#include <linux/io.h>
28#include <linux/gpio.h> 27#include <linux/gpio.h>
28#include <linux/pinctrl/consumer.h>
29 29
30/* SPI register offsets */ 30/* SPI register offsets */
31#define SPI_CR 0x0000 31#define SPI_CR 0x0000
@@ -993,13 +993,6 @@ static int atmel_spi_setup(struct spi_device *spi)
993 993
994 as = spi_master_get_devdata(spi->master); 994 as = spi_master_get_devdata(spi->master);
995 995
996 if (spi->chip_select > spi->master->num_chipselect) {
997 dev_dbg(&spi->dev,
998 "setup: invalid chipselect %u (%u defined)\n",
999 spi->chip_select, spi->master->num_chipselect);
1000 return -EINVAL;
1001 }
1002
1003 /* see notes above re chipselect */ 996 /* see notes above re chipselect */
1004 if (!atmel_spi_is_v2(as) 997 if (!atmel_spi_is_v2(as)
1005 && spi->chip_select == 0 998 && spi->chip_select == 0
@@ -1087,14 +1080,6 @@ static int atmel_spi_one_transfer(struct spi_master *master,
1087 } 1080 }
1088 } 1081 }
1089 1082
1090 if (xfer->bits_per_word > 8) {
1091 if (xfer->len % 2) {
1092 dev_dbg(&spi->dev,
1093 "buffer len should be 16 bits aligned\n");
1094 return -EINVAL;
1095 }
1096 }
1097
1098 /* 1083 /*
1099 * DMA map early, for performance (empties dcache ASAP) and 1084 * DMA map early, for performance (empties dcache ASAP) and
1100 * better fault reporting. 1085 * better fault reporting.
@@ -1221,9 +1206,6 @@ static int atmel_spi_transfer_one_message(struct spi_master *master,
1221 dev_dbg(&spi->dev, "new message %p submitted for %s\n", 1206 dev_dbg(&spi->dev, "new message %p submitted for %s\n",
1222 msg, dev_name(&spi->dev)); 1207 msg, dev_name(&spi->dev));
1223 1208
1224 if (unlikely(list_empty(&msg->transfers)))
1225 return -EINVAL;
1226
1227 atmel_spi_lock(as); 1209 atmel_spi_lock(as);
1228 cs_activate(as, spi); 1210 cs_activate(as, spi);
1229 1211
@@ -1244,10 +1226,10 @@ static int atmel_spi_transfer_one_message(struct spi_master *master,
1244 1226
1245 list_for_each_entry(xfer, &msg->transfers, transfer_list) { 1227 list_for_each_entry(xfer, &msg->transfers, transfer_list) {
1246 dev_dbg(&spi->dev, 1228 dev_dbg(&spi->dev,
1247 " xfer %p: len %u tx %p/%08x rx %p/%08x\n", 1229 " xfer %p: len %u tx %p/%pad rx %p/%pad\n",
1248 xfer, xfer->len, 1230 xfer, xfer->len,
1249 xfer->tx_buf, xfer->tx_dma, 1231 xfer->tx_buf, &xfer->tx_dma,
1250 xfer->rx_buf, xfer->rx_dma); 1232 xfer->rx_buf, &xfer->rx_dma);
1251 } 1233 }
1252 1234
1253msg_done: 1235msg_done:
@@ -1303,6 +1285,9 @@ static int atmel_spi_probe(struct platform_device *pdev)
1303 struct spi_master *master; 1285 struct spi_master *master;
1304 struct atmel_spi *as; 1286 struct atmel_spi *as;
1305 1287
1288 /* Select default pin state */
1289 pinctrl_pm_select_default_state(&pdev->dev);
1290
1306 regs = platform_get_resource(pdev, IORESOURCE_MEM, 0); 1291 regs = platform_get_resource(pdev, IORESOURCE_MEM, 0);
1307 if (!regs) 1292 if (!regs)
1308 return -ENXIO; 1293 return -ENXIO;
@@ -1455,8 +1440,19 @@ static int atmel_spi_suspend(struct device *dev)
1455{ 1440{
1456 struct spi_master *master = dev_get_drvdata(dev); 1441 struct spi_master *master = dev_get_drvdata(dev);
1457 struct atmel_spi *as = spi_master_get_devdata(master); 1442 struct atmel_spi *as = spi_master_get_devdata(master);
1443 int ret;
1444
1445 /* Stop the queue running */
1446 ret = spi_master_suspend(master);
1447 if (ret) {
1448 dev_warn(dev, "cannot suspend master\n");
1449 return ret;
1450 }
1458 1451
1459 clk_disable_unprepare(as->clk); 1452 clk_disable_unprepare(as->clk);
1453
1454 pinctrl_pm_select_sleep_state(dev);
1455
1460 return 0; 1456 return 0;
1461} 1457}
1462 1458
@@ -1464,9 +1460,18 @@ static int atmel_spi_resume(struct device *dev)
1464{ 1460{
1465 struct spi_master *master = dev_get_drvdata(dev); 1461 struct spi_master *master = dev_get_drvdata(dev);
1466 struct atmel_spi *as = spi_master_get_devdata(master); 1462 struct atmel_spi *as = spi_master_get_devdata(master);
1463 int ret;
1464
1465 pinctrl_pm_select_default_state(dev);
1467 1466
1468 clk_prepare_enable(as->clk); 1467 clk_prepare_enable(as->clk);
1469 return 0; 1468
1469 /* Start the queue running */
1470 ret = spi_master_resume(master);
1471 if (ret)
1472 dev_err(dev, "problem starting queue (%d)\n", ret);
1473
1474 return ret;
1470} 1475}
1471 1476
1472static SIMPLE_DEV_PM_OPS(atmel_spi_pm_ops, atmel_spi_suspend, atmel_spi_resume); 1477static SIMPLE_DEV_PM_OPS(atmel_spi_pm_ops, atmel_spi_suspend, atmel_spi_resume);