| .. | .. |
|---|
| 21 | 21 | #include <linux/mutex.h> |
|---|
| 22 | 22 | #include <linux/of.h> |
|---|
| 23 | 23 | #include <linux/reset.h> |
|---|
| 24 | +#include <linux/pm_runtime.h> |
|---|
| 24 | 25 | |
|---|
| 25 | 26 | #define HSSPI_GLOBAL_CTRL_REG 0x0 |
|---|
| 26 | 27 | #define GLOBAL_CTRL_CS_POLARITY_SHIFT 0 |
|---|
| .. | .. |
|---|
| 162 | 163 | int step_size = HSSPI_BUFFER_LEN; |
|---|
| 163 | 164 | const u8 *tx = t->tx_buf; |
|---|
| 164 | 165 | u8 *rx = t->rx_buf; |
|---|
| 166 | + u32 val = 0; |
|---|
| 165 | 167 | |
|---|
| 166 | 168 | bcm63xx_hsspi_set_clk(bs, spi, t->speed_hz); |
|---|
| 167 | 169 | bcm63xx_hsspi_set_cs(bs, spi->chip_select, true); |
|---|
| .. | .. |
|---|
| 177 | 179 | step_size -= HSSPI_OPCODE_LEN; |
|---|
| 178 | 180 | |
|---|
| 179 | 181 | 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)) { |
|---|
| 181 | 183 | opcode |= HSSPI_OP_MULTIBIT; |
|---|
| 182 | 184 | |
|---|
| 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, |
|---|
| 185 | 192 | bs->regs + HSSPI_PROFILE_MODE_CTRL_REG(chip_select)); |
|---|
| 186 | 193 | |
|---|
| 187 | 194 | while (pending > 0) { |
|---|
| .. | .. |
|---|
| 439 | 446 | if (ret) |
|---|
| 440 | 447 | goto out_put_master; |
|---|
| 441 | 448 | |
|---|
| 449 | + pm_runtime_enable(&pdev->dev); |
|---|
| 450 | + |
|---|
| 442 | 451 | /* register and we are done */ |
|---|
| 443 | 452 | ret = devm_spi_register_master(dev, master); |
|---|
| 444 | 453 | if (ret) |
|---|
| 445 | | - goto out_put_master; |
|---|
| 454 | + goto out_pm_disable; |
|---|
| 446 | 455 | |
|---|
| 447 | 456 | return 0; |
|---|
| 448 | 457 | |
|---|
| 458 | +out_pm_disable: |
|---|
| 459 | + pm_runtime_disable(&pdev->dev); |
|---|
| 449 | 460 | out_put_master: |
|---|
| 450 | 461 | spi_master_put(master); |
|---|
| 451 | 462 | out_disable_pll_clk: |
|---|