Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

spi: aspeed: Add support for the AST2700 SPI controller

Extend the driver to support the AST2700 SPI controller. Compared to
AST2600, AST2700 has the following characteristics:
- A 64-bit memory address space.
- A 64KB address decoding unit.
- Segment registers now use (start <= range < end) semantics,
which differs slightly from (start <= range <= end) in AST2600.
- Known issues related to address decoding range registers have been
resolved, and the decoding range is now 1GB, which is sufficient.
Therefore, the adjust_window callback is no longer required on AST2700
for range adjustment and bug fixes.
- The SPI clock divider method and timing calibration logic remain
unchanged from AST2600.

Signed-off-by: Chin-Ting Kuo <chin-ting_kuo@aspeedtech.com>
Link: https://patch.msgid.link/20251114101042.1520997-5-chin-ting_kuo@aspeedtech.com
Signed-off-by: Mark Brown <broonie@kernel.org>

authored by

Chin-Ting Kuo and committed by
Mark Brown
9e510e67 508f3d3b

+71
+71
drivers/spi/spi-aspeed-smc.c
··· 985 985 ((end - 1) & AST2600_SEG_ADDR_MASK); 986 986 } 987 987 988 + /* The Segment Registers of the AST2700 use a 64KB unit. */ 989 + #define AST2700_SEG_ADDR_MASK 0x7fff0000 990 + 991 + static phys_addr_t aspeed_spi_segment_ast2700_start(struct aspeed_spi *aspi, 992 + u32 reg) 993 + { 994 + u64 start_offset = (reg << 16) & AST2700_SEG_ADDR_MASK; 995 + 996 + if (!start_offset) 997 + return aspi->ahb_base_phy; 998 + 999 + return aspi->ahb_base_phy + start_offset; 1000 + } 1001 + 1002 + static phys_addr_t aspeed_spi_segment_ast2700_end(struct aspeed_spi *aspi, 1003 + u32 reg) 1004 + { 1005 + u64 end_offset = reg & AST2700_SEG_ADDR_MASK; 1006 + 1007 + if (!end_offset) 1008 + return aspi->ahb_base_phy; 1009 + 1010 + return aspi->ahb_base_phy + end_offset; 1011 + } 1012 + 1013 + static u32 aspeed_spi_segment_ast2700_reg(struct aspeed_spi *aspi, 1014 + phys_addr_t start, phys_addr_t end) 1015 + { 1016 + if (start == end) 1017 + return 0; 1018 + 1019 + return (u32)(((start & AST2700_SEG_ADDR_MASK) >> 16) | 1020 + (end & AST2700_SEG_ADDR_MASK)); 1021 + } 1022 + 988 1023 /* 989 1024 * Read timing compensation sequences 990 1025 */ ··· 1546 1511 .adjust_window = aspeed_adjust_window_ast2600, 1547 1512 }; 1548 1513 1514 + static const struct aspeed_spi_data ast2700_fmc_data = { 1515 + .max_cs = 3, 1516 + .hastype = false, 1517 + .mode_bits = SPI_RX_QUAD | SPI_TX_QUAD, 1518 + .we0 = 16, 1519 + .ctl0 = CE0_CTRL_REG, 1520 + .timing = CE0_TIMING_COMPENSATION_REG, 1521 + .hclk_mask = 0xf0fff0ff, 1522 + .hdiv_max = 2, 1523 + .min_window_size = 0x10000, 1524 + .get_clk_div = aspeed_get_clk_div_ast2600, 1525 + .calibrate = aspeed_spi_ast2600_calibrate, 1526 + .segment_start = aspeed_spi_segment_ast2700_start, 1527 + .segment_end = aspeed_spi_segment_ast2700_end, 1528 + .segment_reg = aspeed_spi_segment_ast2700_reg, 1529 + }; 1530 + 1531 + static const struct aspeed_spi_data ast2700_spi_data = { 1532 + .max_cs = 2, 1533 + .hastype = false, 1534 + .mode_bits = SPI_RX_QUAD | SPI_TX_QUAD, 1535 + .we0 = 16, 1536 + .ctl0 = CE0_CTRL_REG, 1537 + .timing = CE0_TIMING_COMPENSATION_REG, 1538 + .hclk_mask = 0xf0fff0ff, 1539 + .hdiv_max = 2, 1540 + .min_window_size = 0x10000, 1541 + .get_clk_div = aspeed_get_clk_div_ast2600, 1542 + .calibrate = aspeed_spi_ast2600_calibrate, 1543 + .segment_start = aspeed_spi_segment_ast2700_start, 1544 + .segment_end = aspeed_spi_segment_ast2700_end, 1545 + .segment_reg = aspeed_spi_segment_ast2700_reg, 1546 + }; 1547 + 1549 1548 static const struct of_device_id aspeed_spi_matches[] = { 1550 1549 { .compatible = "aspeed,ast2400-fmc", .data = &ast2400_fmc_data }, 1551 1550 { .compatible = "aspeed,ast2400-spi", .data = &ast2400_spi_data }, ··· 1587 1518 { .compatible = "aspeed,ast2500-spi", .data = &ast2500_spi_data }, 1588 1519 { .compatible = "aspeed,ast2600-fmc", .data = &ast2600_fmc_data }, 1589 1520 { .compatible = "aspeed,ast2600-spi", .data = &ast2600_spi_data }, 1521 + { .compatible = "aspeed,ast2700-fmc", .data = &ast2700_fmc_data }, 1522 + { .compatible = "aspeed,ast2700-spi", .data = &ast2700_spi_data }, 1590 1523 { } 1591 1524 }; 1592 1525 MODULE_DEVICE_TABLE(of, aspeed_spi_matches);