From: "Cédric Le Goater" <clg@kaod.org>
To: "Jamin Lin" <jamin_lin@aspeedtech.com>,
"Peter Maydell" <peter.maydell@linaro.org>,
"Andrew Jeffery" <andrew@codeconstruct.com.au>,
"Joel Stanley" <joel@jms.id.au>,
"Alistair Francis" <alistair@alistair23.me>,
"Cleber Rosa" <crosa@redhat.com>,
"Philippe Mathieu-Daudé" <philmd@linaro.org>,
"Wainer dos Santos Moschetta" <wainersm@redhat.com>,
"Beraldo Leal" <bleal@redhat.com>,
"open list:ASPEED BMCs" <qemu-arm@nongnu.org>,
"open list:All patches CC here" <qemu-devel@nongnu.org>
Cc: troy_lee@aspeedtech.com, yunlin.tang@aspeedtech.com
Subject: Re: [PATCH v5 10/17] aspeed/smc: Add AST2700 support
Date: Tue, 4 Jun 2024 08:12:47 +0200 [thread overview]
Message-ID: <f2059eb2-7102-492a-a844-2bcb7067a1aa@kaod.org> (raw)
In-Reply-To: <20240604054438.3424349-11-jamin_lin@aspeedtech.com>
On 6/4/24 07:44, Jamin Lin wrote:
> AST2700 fmc/spi controller's address decoding unit is 64KB
> and only bits [31:16] are used for decoding. Introduce seg_to_reg
> and reg_to_seg handlers for ast2700 fmc/spi controller.
> In addition, adds ast2700 fmc, spi0, spi1, and spi2 class init handler.
>
> AST2700 is a 64 bits quad core CPUs(Cortex-a35). Introduce a new
> "aspeed_2700_smc_flash_ops" and set its valid "max_access_size"
> 8 for 64 bits data format access.
>
> Signed-off-by: Troy Lee <troy_lee@aspeedtech.com>
> Signed-off-by: Jamin Lin <jamin_lin@aspeedtech.com>
Reviewed-by: Cédric Le Goater <clg@redhat.com>
Thanks,
C.
> ---
> hw/ssi/aspeed_smc.c | 234 +++++++++++++++++++++++++++++++++++++++++++-
> 1 file changed, 233 insertions(+), 1 deletion(-)
>
> diff --git a/hw/ssi/aspeed_smc.c b/hw/ssi/aspeed_smc.c
> index 129d06690d..49205ab76d 100644
> --- a/hw/ssi/aspeed_smc.c
> +++ b/hw/ssi/aspeed_smc.c
> @@ -185,7 +185,7 @@
> * 0: 4 bytes
> * 0x1FFFFFC: 32M bytes
> *
> - * DMA length is from 1 byte to 32MB (AST2600, AST10x0)
> + * DMA length is from 1 byte to 32MB (AST2600, AST10x0 and AST2700)
> * 0: 1 byte
> * 0x1FFFFFF: 32M bytes
> */
> @@ -1938,6 +1938,234 @@ static const TypeInfo aspeed_1030_spi2_info = {
> .class_init = aspeed_1030_spi2_class_init,
> };
>
> +/*
> + * The FMC Segment Registers of the AST2700 have a 64KB unit.
> + * Only bits [31:16] are used for decoding.
> + */
> +#define AST2700_SEG_ADDR_MASK 0xffff0000
> +
> +static uint32_t aspeed_2700_smc_segment_to_reg(const AspeedSMCState *s,
> + const AspeedSegments *seg)
> +{
> + uint32_t reg = 0;
> +
> + /* Disabled segments have a nil register */
> + if (!seg->size) {
> + return 0;
> + }
> +
> + reg |= (seg->addr & AST2700_SEG_ADDR_MASK) >> 16; /* start offset */
> + reg |= (seg->addr + seg->size - 1) & AST2700_SEG_ADDR_MASK; /* end offset */
> + return reg;
> +}
> +
> +static void aspeed_2700_smc_reg_to_segment(const AspeedSMCState *s,
> + uint32_t reg, AspeedSegments *seg)
> +{
> + uint32_t start_offset = (reg << 16) & AST2700_SEG_ADDR_MASK;
> + uint32_t end_offset = reg & AST2700_SEG_ADDR_MASK;
> + AspeedSMCClass *asc = ASPEED_SMC_GET_CLASS(s);
> +
> + if (reg) {
> + seg->addr = asc->flash_window_base + start_offset;
> + seg->size = end_offset + (64 * KiB) - start_offset;
> + } else {
> + seg->addr = asc->flash_window_base;
> + seg->size = 0;
> + }
> +}
> +
> +static const uint32_t aspeed_2700_fmc_resets[ASPEED_SMC_R_MAX] = {
> + [R_CONF] = (CONF_FLASH_TYPE_SPI << CONF_FLASH_TYPE0 |
> + CONF_FLASH_TYPE_SPI << CONF_FLASH_TYPE1),
> + [R_CE_CTRL] = 0x0000aa00,
> + [R_CTRL0] = 0x406b0641,
> + [R_CTRL1] = 0x00000400,
> + [R_CTRL2] = 0x00000400,
> + [R_CTRL3] = 0x00000400,
> + [R_SEG_ADDR0] = 0x08000000,
> + [R_SEG_ADDR1] = 0x10000800,
> + [R_SEG_ADDR2] = 0x00000000,
> + [R_SEG_ADDR3] = 0x00000000,
> + [R_DUMMY_DATA] = 0x00010000,
> + [R_DMA_DRAM_ADDR_HIGH] = 0x00000000,
> + [R_TIMINGS] = 0x007b0000,
> +};
> +
> +static const MemoryRegionOps aspeed_2700_smc_flash_ops = {
> + .read = aspeed_smc_flash_read,
> + .write = aspeed_smc_flash_write,
> + .endianness = DEVICE_LITTLE_ENDIAN,
> + .valid = {
> + .min_access_size = 1,
> + .max_access_size = 8,
> + },
> +};
> +
> +static const AspeedSegments aspeed_2700_fmc_segments[] = {
> + { 0x0, 128 * MiB }, /* start address is readonly */
> + { 128 * MiB, 128 * MiB }, /* default is disabled but needed for -kernel */
> + { 256 * MiB, 128 * MiB }, /* default is disabled but needed for -kernel */
> + { 0x0, 0 }, /* disabled */
> +};
> +
> +static void aspeed_2700_fmc_class_init(ObjectClass *klass, void *data)
> +{
> + DeviceClass *dc = DEVICE_CLASS(klass);
> + AspeedSMCClass *asc = ASPEED_SMC_CLASS(klass);
> +
> + dc->desc = "Aspeed 2700 FMC Controller";
> + asc->r_conf = R_CONF;
> + asc->r_ce_ctrl = R_CE_CTRL;
> + asc->r_ctrl0 = R_CTRL0;
> + asc->r_timings = R_TIMINGS;
> + asc->nregs_timings = 3;
> + asc->conf_enable_w0 = CONF_ENABLE_W0;
> + asc->cs_num_max = 3;
> + asc->segments = aspeed_2700_fmc_segments;
> + asc->segment_addr_mask = 0xffffffff;
> + asc->resets = aspeed_2700_fmc_resets;
> + asc->flash_window_base = 0x100000000;
> + asc->flash_window_size = 1 * GiB;
> + asc->features = ASPEED_SMC_FEATURE_DMA |
> + ASPEED_SMC_FEATURE_DMA_DRAM_ADDR_HIGH;
> + asc->dma_flash_mask = 0x2FFFFFFC;
> + asc->dma_dram_mask = 0xFFFFFFFC;
> + asc->dma_start_length = 1;
> + asc->nregs = ASPEED_SMC_R_MAX;
> + asc->segment_to_reg = aspeed_2700_smc_segment_to_reg;
> + asc->reg_to_segment = aspeed_2700_smc_reg_to_segment;
> + asc->dma_ctrl = aspeed_2600_smc_dma_ctrl;
> + asc->reg_ops = &aspeed_2700_smc_flash_ops;
> +}
> +
> +static const TypeInfo aspeed_2700_fmc_info = {
> + .name = "aspeed.fmc-ast2700",
> + .parent = TYPE_ASPEED_SMC,
> + .class_init = aspeed_2700_fmc_class_init,
> +};
> +
> +static const AspeedSegments aspeed_2700_spi0_segments[] = {
> + { 0x0, 128 * MiB }, /* start address is readonly */
> + { 128 * MiB, 128 * MiB }, /* start address is readonly */
> + { 0x0, 0 }, /* disabled */
> +};
> +
> +static void aspeed_2700_spi0_class_init(ObjectClass *klass, void *data)
> +{
> + DeviceClass *dc = DEVICE_CLASS(klass);
> + AspeedSMCClass *asc = ASPEED_SMC_CLASS(klass);
> +
> + dc->desc = "Aspeed 2700 SPI0 Controller";
> + asc->r_conf = R_CONF;
> + asc->r_ce_ctrl = R_CE_CTRL;
> + asc->r_ctrl0 = R_CTRL0;
> + asc->r_timings = R_TIMINGS;
> + asc->nregs_timings = 2;
> + asc->conf_enable_w0 = CONF_ENABLE_W0;
> + asc->cs_num_max = 2;
> + asc->segments = aspeed_2700_spi0_segments;
> + asc->segment_addr_mask = 0xffffffff;
> + asc->flash_window_base = 0x180000000;
> + asc->flash_window_size = 1 * GiB;
> + asc->features = ASPEED_SMC_FEATURE_DMA |
> + ASPEED_SMC_FEATURE_DMA_DRAM_ADDR_HIGH;
> + asc->dma_flash_mask = 0x2FFFFFFC;
> + asc->dma_dram_mask = 0xFFFFFFFC;
> + asc->dma_start_length = 1;
> + asc->nregs = ASPEED_SMC_R_MAX;
> + asc->segment_to_reg = aspeed_2700_smc_segment_to_reg;
> + asc->reg_to_segment = aspeed_2700_smc_reg_to_segment;
> + asc->dma_ctrl = aspeed_2600_smc_dma_ctrl;
> + asc->reg_ops = &aspeed_2700_smc_flash_ops;
> +}
> +
> +static const TypeInfo aspeed_2700_spi0_info = {
> + .name = "aspeed.spi0-ast2700",
> + .parent = TYPE_ASPEED_SMC,
> + .class_init = aspeed_2700_spi0_class_init,
> +};
> +
> +static const AspeedSegments aspeed_2700_spi1_segments[] = {
> + { 0x0, 128 * MiB }, /* start address is readonly */
> + { 0x0, 0 }, /* disabled */
> +};
> +
> +static void aspeed_2700_spi1_class_init(ObjectClass *klass, void *data)
> +{
> + DeviceClass *dc = DEVICE_CLASS(klass);
> + AspeedSMCClass *asc = ASPEED_SMC_CLASS(klass);
> +
> + dc->desc = "Aspeed 2700 SPI1 Controller";
> + asc->r_conf = R_CONF;
> + asc->r_ce_ctrl = R_CE_CTRL;
> + asc->r_ctrl0 = R_CTRL0;
> + asc->r_timings = R_TIMINGS;
> + asc->nregs_timings = 2;
> + asc->conf_enable_w0 = CONF_ENABLE_W0;
> + asc->cs_num_max = 2;
> + asc->segments = aspeed_2700_spi1_segments;
> + asc->segment_addr_mask = 0xffffffff;
> + asc->flash_window_base = 0x200000000;
> + asc->flash_window_size = 1 * GiB;
> + asc->features = ASPEED_SMC_FEATURE_DMA |
> + ASPEED_SMC_FEATURE_DMA_DRAM_ADDR_HIGH;
> + asc->dma_flash_mask = 0x2FFFFFFC;
> + asc->dma_dram_mask = 0xFFFFFFFC;
> + asc->dma_start_length = 1;
> + asc->nregs = ASPEED_SMC_R_MAX;
> + asc->segment_to_reg = aspeed_2700_smc_segment_to_reg;
> + asc->reg_to_segment = aspeed_2700_smc_reg_to_segment;
> + asc->dma_ctrl = aspeed_2600_smc_dma_ctrl;
> + asc->reg_ops = &aspeed_2700_smc_flash_ops;
> +}
> +
> +static const TypeInfo aspeed_2700_spi1_info = {
> + .name = "aspeed.spi1-ast2700",
> + .parent = TYPE_ASPEED_SMC,
> + .class_init = aspeed_2700_spi1_class_init,
> +};
> +
> +static const AspeedSegments aspeed_2700_spi2_segments[] = {
> + { 0x0, 128 * MiB }, /* start address is readonly */
> + { 0x0, 0 }, /* disabled */
> +};
> +
> +static void aspeed_2700_spi2_class_init(ObjectClass *klass, void *data)
> +{
> + DeviceClass *dc = DEVICE_CLASS(klass);
> + AspeedSMCClass *asc = ASPEED_SMC_CLASS(klass);
> +
> + dc->desc = "Aspeed 2700 SPI2 Controller";
> + asc->r_conf = R_CONF;
> + asc->r_ce_ctrl = R_CE_CTRL;
> + asc->r_ctrl0 = R_CTRL0;
> + asc->r_timings = R_TIMINGS;
> + asc->nregs_timings = 2;
> + asc->conf_enable_w0 = CONF_ENABLE_W0;
> + asc->cs_num_max = 2;
> + asc->segments = aspeed_2700_spi2_segments;
> + asc->segment_addr_mask = 0xffffffff;
> + asc->flash_window_base = 0x280000000;
> + asc->flash_window_size = 1 * GiB;
> + asc->features = ASPEED_SMC_FEATURE_DMA |
> + ASPEED_SMC_FEATURE_DMA_DRAM_ADDR_HIGH;
> + asc->dma_flash_mask = 0x0FFFFFFC;
> + asc->dma_dram_mask = 0xFFFFFFFC;
> + asc->dma_start_length = 1;
> + asc->nregs = ASPEED_SMC_R_MAX;
> + asc->segment_to_reg = aspeed_2700_smc_segment_to_reg;
> + asc->reg_to_segment = aspeed_2700_smc_reg_to_segment;
> + asc->dma_ctrl = aspeed_2600_smc_dma_ctrl;
> + asc->reg_ops = &aspeed_2700_smc_flash_ops;
> +}
> +
> +static const TypeInfo aspeed_2700_spi2_info = {
> + .name = "aspeed.spi2-ast2700",
> + .parent = TYPE_ASPEED_SMC,
> + .class_init = aspeed_2700_spi2_class_init,
> +};
> +
> static void aspeed_smc_register_types(void)
> {
> type_register_static(&aspeed_smc_flash_info);
> @@ -1954,6 +2182,10 @@ static void aspeed_smc_register_types(void)
> type_register_static(&aspeed_1030_fmc_info);
> type_register_static(&aspeed_1030_spi1_info);
> type_register_static(&aspeed_1030_spi2_info);
> + type_register_static(&aspeed_2700_fmc_info);
> + type_register_static(&aspeed_2700_spi0_info);
> + type_register_static(&aspeed_2700_spi1_info);
> + type_register_static(&aspeed_2700_spi2_info);
> }
>
> type_init(aspeed_smc_register_types)
next prev parent reply other threads:[~2024-06-04 6:13 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-04 5:44 [PATCH v5 00/17] Add AST2700 support Jamin Lin via
2024-06-04 5:44 ` [PATCH v5 01/17] aspeed/wdt: " Jamin Lin via
2024-06-04 5:44 ` [PATCH v5 02/17] aspeed/sli: " Jamin Lin via
2024-06-04 5:44 ` [PATCH v5 03/17] aspeed/sdmc: remove redundant macros Jamin Lin via
2024-06-04 5:44 ` [PATCH v5 04/17] aspeed/sdmc: fix coding style Jamin Lin via
2024-06-04 5:44 ` [PATCH v5 05/17] aspeed/sdmc: Add AST2700 support Jamin Lin via
2024-06-04 6:10 ` Cédric Le Goater
2024-06-04 5:44 ` [PATCH v5 06/17] aspeed/smc: correct device description Jamin Lin via
2024-06-04 5:44 ` [PATCH v5 07/17] aspeed/smc: support dma start length and 1 byte length unit Jamin Lin via
2024-06-04 5:44 ` [PATCH v5 08/17] aspeed/smc: support 64 bits dma dram address Jamin Lin via
2024-06-04 5:44 ` [PATCH v5 09/17] aspeed/smc: support different memory region ops for SMC flash region Jamin Lin via
2024-06-04 6:11 ` Cédric Le Goater
2024-06-04 5:44 ` [PATCH v5 10/17] aspeed/smc: Add AST2700 support Jamin Lin via
2024-06-04 6:12 ` Cédric Le Goater [this message]
2024-06-04 5:44 ` [PATCH v5 11/17] aspeed/scu: " Jamin Lin via
2024-06-04 5:44 ` [PATCH v5 12/17] aspeed/intc: " Jamin Lin via
2024-06-04 7:18 ` Cédric Le Goater
2024-06-04 5:44 ` [PATCH v5 13/17] aspeed/soc: " Jamin Lin via
2024-06-04 6:17 ` Cédric Le Goater
2025-01-30 15:13 ` Philippe Mathieu-Daudé
2025-02-03 7:28 ` Jamin Lin
2025-02-03 7:43 ` Jamin Lin
2025-02-03 16:40 ` Philippe Mathieu-Daudé
2025-02-04 3:22 ` Jamin Lin
2024-06-04 5:44 ` [PATCH v5 14/17] aspeed: Add an AST2700 eval board Jamin Lin via
2024-06-04 5:44 ` [PATCH v5 15/17] aspeed/soc: fix incorrect dram size for AST2700 Jamin Lin via
2024-06-04 6:13 ` Cédric Le Goater
2024-06-04 5:44 ` [PATCH v5 16/17] test/avocado/machine_aspeed.py: Add AST2700 test case Jamin Lin via
2024-06-04 5:44 ` [PATCH v5 17/17] docs:aspeed: Add AST2700 Evaluation board Jamin Lin via
2024-06-04 11:51 ` [PATCH v5 00/17] Add AST2700 support Cédric Le Goater
2024-06-05 0:40 ` Jamin Lin
2024-06-10 9:23 ` Cédric Le Goater
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=f2059eb2-7102-492a-a844-2bcb7067a1aa@kaod.org \
--to=clg@kaod.org \
--cc=alistair@alistair23.me \
--cc=andrew@codeconstruct.com.au \
--cc=bleal@redhat.com \
--cc=crosa@redhat.com \
--cc=jamin_lin@aspeedtech.com \
--cc=joel@jms.id.au \
--cc=peter.maydell@linaro.org \
--cc=philmd@linaro.org \
--cc=qemu-arm@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=troy_lee@aspeedtech.com \
--cc=wainersm@redhat.com \
--cc=yunlin.tang@aspeedtech.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).