hc
2024-01-03 2f7c68cb55ecb7331f2381deb497c27155f32faf
kernel/drivers/spi/spi-bcm63xx-hsspi.c
....@@ -21,6 +21,7 @@
2121 #include <linux/mutex.h>
2222 #include <linux/of.h>
2323 #include <linux/reset.h>
24
+#include <linux/pm_runtime.h>
2425
2526 #define HSSPI_GLOBAL_CTRL_REG 0x0
2627 #define GLOBAL_CTRL_CS_POLARITY_SHIFT 0
....@@ -162,6 +163,7 @@
162163 int step_size = HSSPI_BUFFER_LEN;
163164 const u8 *tx = t->tx_buf;
164165 u8 *rx = t->rx_buf;
166
+ u32 val = 0;
165167
166168 bcm63xx_hsspi_set_clk(bs, spi, t->speed_hz);
167169 bcm63xx_hsspi_set_cs(bs, spi->chip_select, true);
....@@ -177,11 +179,16 @@
177179 step_size -= HSSPI_OPCODE_LEN;
178180
179181 if ((opcode == HSSPI_OP_READ && t->rx_nbits == SPI_NBITS_DUAL) ||
180
- (opcode == HSSPI_OP_WRITE && t->tx_nbits == SPI_NBITS_DUAL))
182
+ (opcode == HSSPI_OP_WRITE && t->tx_nbits == SPI_NBITS_DUAL)) {
181183 opcode |= HSSPI_OP_MULTIBIT;
182184
183
- __raw_writel(1 << MODE_CTRL_MULTIDATA_WR_SIZE_SHIFT |
184
- 1 << MODE_CTRL_MULTIDATA_RD_SIZE_SHIFT | 0xff,
185
+ if (t->rx_nbits == SPI_NBITS_DUAL)
186
+ val |= 1 << MODE_CTRL_MULTIDATA_RD_SIZE_SHIFT;
187
+ if (t->tx_nbits == SPI_NBITS_DUAL)
188
+ val |= 1 << MODE_CTRL_MULTIDATA_WR_SIZE_SHIFT;
189
+ }
190
+
191
+ __raw_writel(val | 0xff,
185192 bs->regs + HSSPI_PROFILE_MODE_CTRL_REG(chip_select));
186193
187194 while (pending > 0) {
....@@ -439,13 +446,17 @@
439446 if (ret)
440447 goto out_put_master;
441448
449
+ pm_runtime_enable(&pdev->dev);
450
+
442451 /* register and we are done */
443452 ret = devm_spi_register_master(dev, master);
444453 if (ret)
445
- goto out_put_master;
454
+ goto out_pm_disable;
446455
447456 return 0;
448457
458
+out_pm_disable:
459
+ pm_runtime_disable(&pdev->dev);
449460 out_put_master:
450461 spi_master_put(master);
451462 out_disable_pll_clk: