Skip to content

Commit 45d2af8

Browse files
Tharun Kumar Pbroonie
authored andcommitted
spi: mchp-pci1xxxx: Fix improper implementation of disabling chip select lines
Hardware does not have support to disable individual chip select lines. Disable all chip select lines by using SPI_FORCE_CE bit. Fixes: 1cc0cbe ("spi: microchip: pci1xxxx: Add driver for SPI controller of PCI1XXXX PCIe switch") Signed-off-by: Tharun Kumar P <tharunkumar.pasumarthi@microchip.com> Link: https://lore.kernel.org/r/20230404171613.1336093-4-tharunkumar.pasumarthi@microchip.com Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent 4266d21 commit 45d2af8

1 file changed

Lines changed: 5 additions & 12 deletions

File tree

drivers/spi/spi-pci1xxxx.c

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -114,17 +114,14 @@ static void pci1xxxx_spi_set_cs(struct spi_device *spi, bool enable)
114114

115115
/* Set the DEV_SEL bits of the SPI_MST_CTL_REG */
116116
regval = readl(par->reg_base + SPI_MST_CTL_REG_OFFSET(p->hw_inst));
117-
if (enable) {
117+
if (!enable) {
118+
regval |= SPI_FORCE_CE;
118119
regval &= ~SPI_MST_CTL_DEVSEL_MASK;
119120
regval |= (spi_get_chipselect(spi, 0) << 25);
120-
writel(regval,
121-
par->reg_base + SPI_MST_CTL_REG_OFFSET(p->hw_inst));
122121
} else {
123-
regval &= ~(spi_get_chipselect(spi, 0) << 25);
124-
writel(regval,
125-
par->reg_base + SPI_MST_CTL_REG_OFFSET(p->hw_inst));
126-
122+
regval &= ~SPI_FORCE_CE;
127123
}
124+
writel(regval, par->reg_base + SPI_MST_CTL_REG_OFFSET(p->hw_inst));
128125
}
129126

130127
static u8 pci1xxxx_get_clock_div(u32 hz)
@@ -199,7 +196,7 @@ static int pci1xxxx_spi_transfer_one(struct spi_controller *spi_ctlr,
199196
else
200197
regval &= ~SPI_MST_CTL_MODE_SEL;
201198

202-
regval |= ((clkdiv << 5) | SPI_FORCE_CE);
199+
regval |= (clkdiv << 5);
203200
regval &= ~SPI_MST_CTL_CMD_LEN_MASK;
204201
regval |= (len << 8);
205202
writel(regval, par->reg_base +
@@ -223,10 +220,6 @@ static int pci1xxxx_spi_transfer_one(struct spi_controller *spi_ctlr,
223220
}
224221
}
225222
}
226-
227-
regval = readl(par->reg_base + SPI_MST_CTL_REG_OFFSET(p->hw_inst));
228-
regval &= ~SPI_FORCE_CE;
229-
writel(regval, par->reg_base + SPI_MST_CTL_REG_OFFSET(p->hw_inst));
230223
p->spi_xfer_in_progress = false;
231224

232225
return 0;

0 commit comments

Comments
 (0)