aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/spi/spi-tegra20-slink.c
diff options
context:
space:
mode:
authorMark Brown <broonie@linaro.org>2013-07-27 07:34:24 -0400
committerMark Brown <broonie@linaro.org>2013-07-29 12:12:38 -0400
commitbafe886936a8982f5780330c901889a37bba7d4c (patch)
tree1bbc35e208a96dfb0258c2087c984d376a1b9c9e /drivers/spi/spi-tegra20-slink.c
parent9f178c22fb0e88f4e84f7a66be8326f63b91e7e3 (diff)
spi/tegra-slink: Factor runtime PM out into transfer prepare/unprepare
Currently the tegra slink driver acquires a runtime PM reference for the duration of each transfer. This may result in the IP being powered down between transfers which would be at best wasteful. Instead it is better to do this in the callbacks that are generated before and after starting a series of transfers, keeping the IP powered throughout. Signed-off-by: Mark Brown <broonie@linaro.org> Acked-by: Laxman Dewangan <ldewangan@nvidia.com>
Diffstat (limited to 'drivers/spi/spi-tegra20-slink.c')
-rw-r--r--drivers/spi/spi-tegra20-slink.c32
1 files changed, 25 insertions, 7 deletions
diff --git a/drivers/spi/spi-tegra20-slink.c b/drivers/spi/spi-tegra20-slink.c
index 80490cc11ce5..b2fb115df027 100644
--- a/drivers/spi/spi-tegra20-slink.c
+++ b/drivers/spi/spi-tegra20-slink.c
@@ -824,6 +824,20 @@ static int tegra_slink_setup(struct spi_device *spi)
824 return 0; 824 return 0;
825} 825}
826 826
827static int tegra_slink_prepare_transfer(struct spi_master *spi)
828{
829 struct tegra_slink_data *tspi = spi_master_get_devdata(spi);
830 int ret;
831
832 ret = pm_runtime_get_sync(tspi->dev);
833 if (ret < 0) {
834 dev_err(tspi->dev, "runtime PM get failed: %d\n", ret);
835 return ret;
836 }
837
838 return ret;
839}
840
827static int tegra_slink_transfer_one_message(struct spi_master *master, 841static int tegra_slink_transfer_one_message(struct spi_master *master,
828 struct spi_message *msg) 842 struct spi_message *msg)
829{ 843{
@@ -836,11 +850,6 @@ static int tegra_slink_transfer_one_message(struct spi_master *master,
836 850
837 msg->status = 0; 851 msg->status = 0;
838 msg->actual_length = 0; 852 msg->actual_length = 0;
839 ret = pm_runtime_get_sync(tspi->dev);
840 if (ret < 0) {
841 dev_err(tspi->dev, "runtime get failed: %d\n", ret);
842 goto done;
843 }
844 853
845 single_xfer = list_is_singular(&msg->transfers); 854 single_xfer = list_is_singular(&msg->transfers);
846 list_for_each_entry(xfer, &msg->transfers, transfer_list) { 855 list_for_each_entry(xfer, &msg->transfers, transfer_list) {
@@ -878,13 +887,20 @@ static int tegra_slink_transfer_one_message(struct spi_master *master,
878exit: 887exit:
879 tegra_slink_writel(tspi, tspi->def_command_reg, SLINK_COMMAND); 888 tegra_slink_writel(tspi, tspi->def_command_reg, SLINK_COMMAND);
880 tegra_slink_writel(tspi, tspi->def_command2_reg, SLINK_COMMAND2); 889 tegra_slink_writel(tspi, tspi->def_command2_reg, SLINK_COMMAND2);
881 pm_runtime_put(tspi->dev);
882done:
883 msg->status = ret; 890 msg->status = ret;
884 spi_finalize_current_message(master); 891 spi_finalize_current_message(master);
885 return ret; 892 return ret;
886} 893}
887 894
895static int tegra_slink_unprepare_transfer(struct spi_master *spi)
896{
897 struct tegra_slink_data *tspi = spi_master_get_devdata(spi);
898
899 pm_runtime_put(tspi->dev);
900
901 return 0;
902}
903
888static irqreturn_t handle_cpu_based_xfer(struct tegra_slink_data *tspi) 904static irqreturn_t handle_cpu_based_xfer(struct tegra_slink_data *tspi)
889{ 905{
890 struct spi_transfer *t = tspi->curr_xfer; 906 struct spi_transfer *t = tspi->curr_xfer;
@@ -1085,7 +1101,9 @@ static int tegra_slink_probe(struct platform_device *pdev)
1085 /* the spi->mode bits understood by this driver: */ 1101 /* the spi->mode bits understood by this driver: */
1086 master->mode_bits = SPI_CPOL | SPI_CPHA | SPI_CS_HIGH; 1102 master->mode_bits = SPI_CPOL | SPI_CPHA | SPI_CS_HIGH;
1087 master->setup = tegra_slink_setup; 1103 master->setup = tegra_slink_setup;
1104 master->prepare_transfer_hardware = tegra_slink_prepare_transfer;
1088 master->transfer_one_message = tegra_slink_transfer_one_message; 1105 master->transfer_one_message = tegra_slink_transfer_one_message;
1106 master->unprepare_transfer_hardware = tegra_slink_unprepare_transfer;
1089 master->num_chipselect = MAX_CHIP_SELECT; 1107 master->num_chipselect = MAX_CHIP_SELECT;
1090 master->bus_num = -1; 1108 master->bus_num = -1;
1091 1109