Skip to content

Commit 9e510e6

Browse files
chintingkuobroonie
authored andcommitted
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>
1 parent 508f3d3 commit 9e510e6

1 file changed

Lines changed: 71 additions & 0 deletions

File tree

drivers/spi/spi-aspeed-smc.c

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -985,6 +985,41 @@ static u32 aspeed_spi_segment_ast2600_reg(struct aspeed_spi *aspi,
985985
((end - 1) & AST2600_SEG_ADDR_MASK);
986986
}
987987

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+
9881023
/*
9891024
* Read timing compensation sequences
9901025
*/
@@ -1511,13 +1546,49 @@ static const struct aspeed_spi_data ast2600_spi_data = {
15111546
.adjust_window = aspeed_adjust_window_ast2600,
15121547
};
15131548

1549+
static const struct aspeed_spi_data ast2700_fmc_data = {
1550+
.max_cs = 3,
1551+
.hastype = false,
1552+
.mode_bits = SPI_RX_QUAD | SPI_TX_QUAD,
1553+
.we0 = 16,
1554+
.ctl0 = CE0_CTRL_REG,
1555+
.timing = CE0_TIMING_COMPENSATION_REG,
1556+
.hclk_mask = 0xf0fff0ff,
1557+
.hdiv_max = 2,
1558+
.min_window_size = 0x10000,
1559+
.get_clk_div = aspeed_get_clk_div_ast2600,
1560+
.calibrate = aspeed_spi_ast2600_calibrate,
1561+
.segment_start = aspeed_spi_segment_ast2700_start,
1562+
.segment_end = aspeed_spi_segment_ast2700_end,
1563+
.segment_reg = aspeed_spi_segment_ast2700_reg,
1564+
};
1565+
1566+
static const struct aspeed_spi_data ast2700_spi_data = {
1567+
.max_cs = 2,
1568+
.hastype = false,
1569+
.mode_bits = SPI_RX_QUAD | SPI_TX_QUAD,
1570+
.we0 = 16,
1571+
.ctl0 = CE0_CTRL_REG,
1572+
.timing = CE0_TIMING_COMPENSATION_REG,
1573+
.hclk_mask = 0xf0fff0ff,
1574+
.hdiv_max = 2,
1575+
.min_window_size = 0x10000,
1576+
.get_clk_div = aspeed_get_clk_div_ast2600,
1577+
.calibrate = aspeed_spi_ast2600_calibrate,
1578+
.segment_start = aspeed_spi_segment_ast2700_start,
1579+
.segment_end = aspeed_spi_segment_ast2700_end,
1580+
.segment_reg = aspeed_spi_segment_ast2700_reg,
1581+
};
1582+
15141583
static const struct of_device_id aspeed_spi_matches[] = {
15151584
{ .compatible = "aspeed,ast2400-fmc", .data = &ast2400_fmc_data },
15161585
{ .compatible = "aspeed,ast2400-spi", .data = &ast2400_spi_data },
15171586
{ .compatible = "aspeed,ast2500-fmc", .data = &ast2500_fmc_data },
15181587
{ .compatible = "aspeed,ast2500-spi", .data = &ast2500_spi_data },
15191588
{ .compatible = "aspeed,ast2600-fmc", .data = &ast2600_fmc_data },
15201589
{ .compatible = "aspeed,ast2600-spi", .data = &ast2600_spi_data },
1590+
{ .compatible = "aspeed,ast2700-fmc", .data = &ast2700_fmc_data },
1591+
{ .compatible = "aspeed,ast2700-spi", .data = &ast2700_spi_data },
15211592
{ }
15221593
};
15231594
MODULE_DEVICE_TABLE(of, aspeed_spi_matches);

0 commit comments

Comments
 (0)