Skip to content

Commit 53526ab

Browse files
legoaterbroonie
authored andcommitted
spi: aspeed: Add support for the AST2400 SPI controller
Extend the driver for the AST2400 SPI Flash Controller (SPI). This controller has a slightly different interface which requires adaptation of the 4B handling. Summary of features : . host Firmware . 1 chip select pin (CE0) . slightly different register set, between AST2500 and the legacy controller . no segment registers . single, dual mode. Reviewed-by: Joel Stanley <[email protected]> Tested-by: Joel Stanley <[email protected]> Tested-by: Tao Ren <[email protected]> Tested-by: Jae Hyun Yoo <[email protected]> Signed-off-by: Cédric Le Goater <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent 5785eed commit 53526ab

File tree

1 file changed

+32
-1
lines changed

1 file changed

+32
-1
lines changed

drivers/spi/spi-aspeed-smc.c

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
#define CTRL_IO_DUAL_DATA BIT(29)
3131
#define CTRL_IO_QUAD_DATA BIT(30)
3232
#define CTRL_COMMAND_SHIFT 16
33+
#define CTRL_IO_ADDRESS_4B BIT(13) /* AST2400 SPI only */
3334
#define CTRL_IO_DUMMY_SET(dummy) \
3435
(((((dummy) >> 2) & 0x1) << 14) | (((dummy) & 0x3) << 6))
3536
#define CTRL_CE_STOP_ACTIVE BIT(2)
@@ -280,6 +281,8 @@ static bool aspeed_spi_supports_op(struct spi_mem *mem, const struct spi_mem_op
280281
return spi_mem_default_supports_op(mem, op);
281282
}
282283

284+
static const struct aspeed_spi_data ast2400_spi_data;
285+
283286
static int do_aspeed_spi_exec_op(struct spi_mem *mem, const struct spi_mem_op *op)
284287
{
285288
struct aspeed_spi *aspi = spi_controller_get_devdata(mem->spi->master);
@@ -309,6 +312,9 @@ static int do_aspeed_spi_exec_op(struct spi_mem *mem, const struct spi_mem_op *o
309312
addr_mode |= (0x11 << chip->cs);
310313
else
311314
addr_mode &= ~(0x11 << chip->cs);
315+
316+
if (op->addr.nbytes == 4 && chip->aspi->data == &ast2400_spi_data)
317+
ctl_val |= CTRL_IO_ADDRESS_4B;
312318
}
313319

314320
if (op->dummy.nbytes)
@@ -398,7 +404,13 @@ static int aspeed_spi_chip_set_default_window(struct aspeed_spi_chip *chip)
398404
struct aspeed_spi_window windows[ASPEED_SPI_MAX_NUM_CS] = { 0 };
399405
struct aspeed_spi_window *win = &windows[chip->cs];
400406

401-
aspeed_spi_get_windows(aspi, windows);
407+
/* No segment registers for the AST2400 SPI controller */
408+
if (aspi->data == &ast2400_spi_data) {
409+
win->offset = 0;
410+
win->size = aspi->ahb_window_size;
411+
} else {
412+
aspeed_spi_get_windows(aspi, windows);
413+
}
402414

403415
chip->ahb_base = aspi->ahb_base + win->offset;
404416
chip->ahb_window_size = win->size;
@@ -461,6 +473,10 @@ static int aspeed_spi_chip_adjust_window(struct aspeed_spi_chip *chip,
461473
struct aspeed_spi_window *win = &windows[chip->cs];
462474
int ret;
463475

476+
/* No segment registers for the AST2400 SPI controller */
477+
if (aspi->data == &ast2400_spi_data)
478+
return 0;
479+
464480
/*
465481
* Due to an HW issue on the AST2500 SPI controller, the CE0
466482
* window size should be smaller than the maximum 128MB.
@@ -545,6 +561,12 @@ static int aspeed_spi_dirmap_create(struct spi_mem_dirmap_desc *desc)
545561
else
546562
addr_mode &= ~(0x11 << chip->cs);
547563
writel(addr_mode, aspi->regs + CE_CTRL_REG);
564+
565+
/* AST2400 SPI controller sets 4BYTE address mode in
566+
* CE0 Control Register
567+
*/
568+
if (op->addr.nbytes == 4 && chip->aspi->data == &ast2400_spi_data)
569+
ctl_val |= CTRL_IO_ADDRESS_4B;
548570
}
549571

550572
/* READ mode is the controller default setting */
@@ -816,6 +838,14 @@ static const struct aspeed_spi_data ast2400_fmc_data = {
816838
.segment_reg = aspeed_spi_segment_reg,
817839
};
818840

841+
static const struct aspeed_spi_data ast2400_spi_data = {
842+
.max_cs = 1,
843+
.hastype = false,
844+
.we0 = 0,
845+
.ctl0 = 0x04,
846+
/* No segment registers */
847+
};
848+
819849
static const struct aspeed_spi_data ast2500_fmc_data = {
820850
.max_cs = 3,
821851
.hastype = true,
@@ -860,6 +890,7 @@ static const struct aspeed_spi_data ast2600_spi_data = {
860890

861891
static const struct of_device_id aspeed_spi_matches[] = {
862892
{ .compatible = "aspeed,ast2400-fmc", .data = &ast2400_fmc_data },
893+
{ .compatible = "aspeed,ast2400-spi", .data = &ast2400_spi_data },
863894
{ .compatible = "aspeed,ast2500-fmc", .data = &ast2500_fmc_data },
864895
{ .compatible = "aspeed,ast2500-spi", .data = &ast2500_spi_data },
865896
{ .compatible = "aspeed,ast2600-fmc", .data = &ast2600_fmc_data },

0 commit comments

Comments
 (0)