hc
2024-02-20 102a0743326a03cd1a1202ceda21e175b7d3575c
kernel/drivers/spi/spi-zynqmp-gqspi.c
....@@ -1147,11 +1147,16 @@
11471147 pm_runtime_set_autosuspend_delay(&pdev->dev, SPI_AUTOSUSPEND_TIMEOUT);
11481148 pm_runtime_set_active(&pdev->dev);
11491149 pm_runtime_enable(&pdev->dev);
1150
+
1151
+ ret = pm_runtime_get_sync(&pdev->dev);
1152
+ if (ret < 0) {
1153
+ dev_err(&pdev->dev, "Failed to pm_runtime_get_sync: %d\n", ret);
1154
+ goto clk_dis_all;
1155
+ }
1156
+
11501157 /* QSPI controller initializations */
11511158 zynqmp_qspi_init_hw(xqspi);
11521159
1153
- pm_runtime_mark_last_busy(&pdev->dev);
1154
- pm_runtime_put_autosuspend(&pdev->dev);
11551160 xqspi->irq = platform_get_irq(pdev, 0);
11561161 if (xqspi->irq <= 0) {
11571162 ret = -ENXIO;
....@@ -1178,6 +1183,7 @@
11781183 ctlr->mode_bits = SPI_CPOL | SPI_CPHA | SPI_RX_DUAL | SPI_RX_QUAD |
11791184 SPI_TX_DUAL | SPI_TX_QUAD;
11801185 ctlr->dev.of_node = np;
1186
+ ctlr->auto_runtime_pm = true;
11811187
11821188 ret = devm_spi_register_controller(&pdev->dev, ctlr);
11831189 if (ret) {
....@@ -1185,11 +1191,15 @@
11851191 goto clk_dis_all;
11861192 }
11871193
1194
+ pm_runtime_mark_last_busy(&pdev->dev);
1195
+ pm_runtime_put_autosuspend(&pdev->dev);
1196
+
11881197 return 0;
11891198
11901199 clk_dis_all:
1191
- pm_runtime_set_suspended(&pdev->dev);
11921200 pm_runtime_disable(&pdev->dev);
1201
+ pm_runtime_put_noidle(&pdev->dev);
1202
+ pm_runtime_set_suspended(&pdev->dev);
11931203 clk_disable_unprepare(xqspi->refclk);
11941204 clk_dis_pclk:
11951205 clk_disable_unprepare(xqspi->pclk);
....@@ -1213,11 +1223,15 @@
12131223 {
12141224 struct zynqmp_qspi *xqspi = platform_get_drvdata(pdev);
12151225
1226
+ pm_runtime_get_sync(&pdev->dev);
1227
+
12161228 zynqmp_gqspi_write(xqspi, GQSPI_EN_OFST, 0x0);
1229
+
1230
+ pm_runtime_disable(&pdev->dev);
1231
+ pm_runtime_put_noidle(&pdev->dev);
1232
+ pm_runtime_set_suspended(&pdev->dev);
12171233 clk_disable_unprepare(xqspi->refclk);
12181234 clk_disable_unprepare(xqspi->pclk);
1219
- pm_runtime_set_suspended(&pdev->dev);
1220
- pm_runtime_disable(&pdev->dev);
12211235
12221236 return 0;
12231237 }