Skip to content

Commit 9674f16

Browse files
RajuRangojubroonie
authored andcommitted
spi: spi_amd: Set controller address mode
Add changes to set the controller address mode before initiating commands. The AMD SPI0 controller(AMDI0062) supports both 24-bit and 32-bit address modes, while the HID2 SPI controller(AMDI0063) supports only the 24-bit address mode. So this change is applicable only for SPI0 controller. Co-developed-by: Krishnamoorthi M <krishnamoorthi.m@amd.com> Signed-off-by: Krishnamoorthi M <krishnamoorthi.m@amd.com> Co-developed-by: Akshata MukundShetty <akshata.mukundshetty@amd.com> Signed-off-by: Akshata MukundShetty <akshata.mukundshetty@amd.com> Signed-off-by: Raju Rangoju <Raju.Rangoju@amd.com> Link: https://patch.msgid.link/20240925133644.2922359-8-Raju.Rangoju@amd.com Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent 145d61c commit 9674f16

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

drivers/spi/spi-amd.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
#define AMD_SPI_TX_COUNT_REG 0x48
3535
#define AMD_SPI_RX_COUNT_REG 0x4B
3636
#define AMD_SPI_STATUS_REG 0x4C
37+
#define AMD_SPI_ADDR32CTRL_REG 0x50
3738

3839
#define AMD_SPI_FIFO_SIZE 70
3940
#define AMD_SPI_MEM_SIZE 200
@@ -548,6 +549,17 @@ static void amd_spi_mem_data_in(struct amd_spi *amd_spi,
548549
nbytes + i - left_data);
549550
}
550551

552+
static void amd_set_spi_addr_mode(struct amd_spi *amd_spi,
553+
const struct spi_mem_op *op)
554+
{
555+
u32 val = amd_spi_readreg32(amd_spi, AMD_SPI_ADDR32CTRL_REG);
556+
557+
if (amd_is_spi_read_cmd_4b(op->cmd.opcode))
558+
amd_spi_writereg32(amd_spi, AMD_SPI_ADDR32CTRL_REG, val | BIT(0));
559+
else
560+
amd_spi_writereg32(amd_spi, AMD_SPI_ADDR32CTRL_REG, val & ~BIT(0));
561+
}
562+
551563
static int amd_spi_exec_mem_op(struct spi_mem *mem,
552564
const struct spi_mem_op *op)
553565
{
@@ -560,6 +572,9 @@ static int amd_spi_exec_mem_op(struct spi_mem *mem,
560572
if (ret)
561573
return ret;
562574

575+
if (amd_spi->version == AMD_SPI_V2)
576+
amd_set_spi_addr_mode(amd_spi, op);
577+
563578
switch (op->data.dir) {
564579
case SPI_MEM_DATA_IN:
565580
amd_spi_mem_data_in(amd_spi, op);

0 commit comments

Comments
 (0)