hc
2024-02-20 102a0743326a03cd1a1202ceda21e175b7d3575c
kernel/drivers/spi/spi-tegra20-slink.c
....@@ -1,19 +1,8 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * SPI driver for Nvidia's Tegra20/Tegra30 SLINK Controller.
34 *
45 * Copyright (c) 2012, NVIDIA CORPORATION. All rights reserved.
5
- *
6
- * This program is free software; you can redistribute it and/or modify it
7
- * under the terms and conditions of the GNU General Public License,
8
- * version 2, as published by the Free Software Foundation.
9
- *
10
- * This program is distributed in the hope it will be useful, but WITHOUT
11
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13
- * more details.
14
- *
15
- * You should have received a copy of the GNU General Public License
16
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
176 */
187
198 #include <linux/clk.h>
....@@ -610,15 +599,10 @@
610599 int ret;
611600 struct dma_slave_config dma_sconfig;
612601
613
- dma_chan = dma_request_slave_channel_reason(tspi->dev,
614
- dma_to_memory ? "rx" : "tx");
615
- if (IS_ERR(dma_chan)) {
616
- ret = PTR_ERR(dma_chan);
617
- if (ret != -EPROBE_DEFER)
618
- dev_err(tspi->dev,
619
- "Dma channel is not available: %d\n", ret);
620
- return ret;
621
- }
602
+ dma_chan = dma_request_chan(tspi->dev, dma_to_memory ? "rx" : "tx");
603
+ if (IS_ERR(dma_chan))
604
+ return dev_err_probe(tspi->dev, PTR_ERR(dma_chan),
605
+ "Dma channel is not available\n");
622606
623607 dma_buf = dma_alloc_coherent(tspi->dev, tspi->dma_buf_size,
624608 &dma_phys, GFP_KERNEL);
....@@ -717,9 +701,6 @@
717701 command2 = tspi->command2_reg;
718702 command2 &= ~(SLINK_RXEN | SLINK_TXEN);
719703
720
- tegra_slink_writel(tspi, command, SLINK_COMMAND);
721
- tspi->command_reg = command;
722
-
723704 tspi->cur_direction = 0;
724705 if (t->rx_buf) {
725706 command2 |= SLINK_RXEN;
....@@ -729,8 +710,17 @@
729710 command2 |= SLINK_TXEN;
730711 tspi->cur_direction |= DATA_DIR_TX;
731712 }
713
+
714
+ /*
715
+ * Writing to the command2 register bevore the command register prevents
716
+ * a spike in chip_select line 0. This selects the chip_select line
717
+ * before changing the chip_select value.
718
+ */
732719 tegra_slink_writel(tspi, command2, SLINK_COMMAND2);
733720 tspi->command2_reg = command2;
721
+
722
+ tegra_slink_writel(tspi, command, SLINK_COMMAND);
723
+ tspi->command_reg = command;
734724
735725 if (total_fifo_words > SLINK_FIFO_DEPTH)
736726 ret = tegra_slink_start_dma_based_transfer(tspi, t);
....@@ -1016,14 +1006,8 @@
10161006 struct resource *r;
10171007 int ret, spi_irq;
10181008 const struct tegra_slink_chip_data *cdata = NULL;
1019
- const struct of_device_id *match;
10201009
1021
- match = of_match_device(tegra_slink_of_match, &pdev->dev);
1022
- if (!match) {
1023
- dev_err(&pdev->dev, "Error: No device match found\n");
1024
- return -ENODEV;
1025
- }
1026
- cdata = match->data;
1010
+ cdata = of_device_get_match_data(&pdev->dev);
10271011
10281012 master = spi_alloc_master(&pdev->dev, sizeof(*tspi));
10291013 if (!master) {
....@@ -1125,6 +1109,7 @@
11251109 ret = pm_runtime_get_sync(&pdev->dev);
11261110 if (ret < 0) {
11271111 dev_err(&pdev->dev, "pm runtime get failed, e = %d\n", ret);
1112
+ pm_runtime_put_noidle(&pdev->dev);
11281113 goto exit_pm_disable;
11291114 }
11301115 tspi->def_command_reg = SLINK_M_S;