[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-arm] [PATCH for-2.9 14/30] aspeed/smc: rework the prototype of the
From: |
Cédric Le Goater |
Subject: |
[Qemu-arm] [PATCH for-2.9 14/30] aspeed/smc: rework the prototype of the AspeedSMCFlash helper routines |
Date: |
Tue, 29 Nov 2016 16:43:52 +0100 |
Change the routines prototype to use a 'AspeedSMCFlash *' instead of
'AspeedSMCState *'. The result will help in making future changes
clearer.
Signed-off-by: Cédric Le Goater <address@hidden>
Reviewed-by: Joel Stanley <address@hidden>
Reviewed-by: Andrew Jeffery <address@hidden>
---
hw/ssi/aspeed_smc.c | 36 ++++++++++++++++++++++++------------
include/hw/ssi/aspeed_smc.h | 2 +-
2 files changed, 25 insertions(+), 13 deletions(-)
diff --git a/hw/ssi/aspeed_smc.c b/hw/ssi/aspeed_smc.c
index 78f5aed53247..66622f198a2f 100644
--- a/hw/ssi/aspeed_smc.c
+++ b/hw/ssi/aspeed_smc.c
@@ -328,19 +328,30 @@ static const MemoryRegionOps aspeed_smc_flash_default_ops
= {
},
};
-static inline int aspeed_smc_flash_mode(const AspeedSMCState *s, int cs)
+static inline int aspeed_smc_flash_mode(const AspeedSMCFlash *fl)
{
- return s->regs[s->r_ctrl0 + cs] & CTRL_CMD_MODE_MASK;
+ AspeedSMCState *s = fl->controller;
+
+ return s->regs[s->r_ctrl0 + fl->id] & CTRL_CMD_MODE_MASK;
+}
+
+static inline bool aspeed_smc_is_usermode(const AspeedSMCFlash *fl)
+{
+ return aspeed_smc_flash_mode(fl) == CTRL_USERMODE;
}
-static inline bool aspeed_smc_is_usermode(const AspeedSMCState *s, int cs)
+static inline bool aspeed_smc_is_ce_stop_active(const AspeedSMCFlash *fl)
{
- return aspeed_smc_flash_mode(s, cs) == CTRL_USERMODE;
+ AspeedSMCState *s = fl->controller;
+
+ return s->regs[s->r_ctrl0 + fl->id] & CTRL_CE_STOP_ACTIVE;
}
-static inline bool aspeed_smc_is_writable(const AspeedSMCState *s, int cs)
+static inline bool aspeed_smc_is_writable(const AspeedSMCFlash *fl)
{
- return s->regs[s->r_conf] & (1 << (s->conf_enable_w0 + cs));
+ AspeedSMCState *s = fl->controller;
+
+ return s->regs[s->r_conf] & (1 << (s->conf_enable_w0 + fl->id));
}
static uint64_t aspeed_smc_flash_read(void *opaque, hwaddr addr, unsigned size)
@@ -350,7 +361,7 @@ static uint64_t aspeed_smc_flash_read(void *opaque, hwaddr
addr, unsigned size)
uint64_t ret = 0;
int i;
- if (aspeed_smc_is_usermode(s, fl->id)) {
+ if (aspeed_smc_is_usermode(fl)) {
for (i = 0; i < size; i++) {
ret |= ssi_transfer(s->spi, 0x0) << (8 * i);
}
@@ -370,13 +381,13 @@ static void aspeed_smc_flash_write(void *opaque, hwaddr
addr, uint64_t data,
const AspeedSMCState *s = fl->controller;
int i;
- if (!aspeed_smc_is_writable(s, fl->id)) {
+ if (!aspeed_smc_is_writable(fl)) {
qemu_log_mask(LOG_GUEST_ERROR, "%s: flash is not writable at 0x%"
HWADDR_PRIx "\n", __func__, addr);
return;
}
- if (!aspeed_smc_is_usermode(s, fl->id)) {
+ if (!aspeed_smc_is_usermode(fl)) {
qemu_log_mask(LOG_UNIMP, "%s: usermode not implemented\n",
__func__);
return;
@@ -397,9 +408,10 @@ static const MemoryRegionOps aspeed_smc_flash_ops = {
},
};
-static bool aspeed_smc_is_ce_stop_active(const AspeedSMCState *s, int cs)
+static void aspeed_smc_flash_update_cs(AspeedSMCFlash *fl)
{
- return s->regs[s->r_ctrl0 + cs] & CTRL_CE_STOP_ACTIVE;
+ AspeedSMCState *s = fl->controller;
+ qemu_set_irq(s->cs_lines[fl->id], aspeed_smc_is_ce_stop_active(fl));
}
static void aspeed_smc_update_cs(const AspeedSMCState *s)
@@ -407,7 +419,7 @@ static void aspeed_smc_update_cs(const AspeedSMCState *s)
int i;
for (i = 0; i < s->num_cs; ++i) {
- qemu_set_irq(s->cs_lines[i], aspeed_smc_is_ce_stop_active(s, i));
+ aspeed_smc_flash_update_cs(&s->flashes[i]);
}
}
diff --git a/include/hw/ssi/aspeed_smc.h b/include/hw/ssi/aspeed_smc.h
index bdfbcc0ffa7d..c64954f6103f 100644
--- a/include/hw/ssi/aspeed_smc.h
+++ b/include/hw/ssi/aspeed_smc.h
@@ -47,7 +47,7 @@ typedef struct AspeedSMCController {
} AspeedSMCController;
typedef struct AspeedSMCFlash {
- const struct AspeedSMCState *controller;
+ struct AspeedSMCState *controller;
uint8_t id;
uint32_t size;
--
2.7.4
- [Qemu-arm] [PATCH for-2.9 04/30] aspeed: remove cannot_destroy_with_object_finalize_yet, (continued)
- [Qemu-arm] [PATCH for-2.9 04/30] aspeed: remove cannot_destroy_with_object_finalize_yet, Cédric Le Goater, 2016/11/29
- [Qemu-arm] [PATCH for-2.9 05/30] aspeed: attach the second SPI controller object to the SoC, Cédric Le Goater, 2016/11/29
- [Qemu-arm] [PATCH for-2.9 06/30] aspeed: extend the board configuration with flash models, Cédric Le Goater, 2016/11/29
- [Qemu-arm] [PATCH for-2.9 07/30] aspeed: add support for the romulus-bmc board, Cédric Le Goater, 2016/11/29
- [Qemu-arm] [PATCH for-2.9 08/30] aspeed: add a memory region for SRAM, Cédric Le Goater, 2016/11/29
- [Qemu-arm] [PATCH for-2.9 09/30] aspeed: add the definitions for the AST2400 A1 SoC, Cédric Le Goater, 2016/11/29
- [Qemu-arm] [PATCH for-2.9 10/30] aspeed: change SoC revision of the palmetto-bmc machine, Cédric Le Goater, 2016/11/29
- [Qemu-arm] [PATCH for-2.9 11/30] aspeed/scu: fix SCU region size, Cédric Le Goater, 2016/11/29
- [Qemu-arm] [PATCH for-2.9 12/30] aspeed/smc: improve segment register support, Cédric Le Goater, 2016/11/29
- [Qemu-arm] [PATCH for-2.9 13/30] aspeed/smc: set the number of flash modules for the FMC controller, Cédric Le Goater, 2016/11/29
- [Qemu-arm] [PATCH for-2.9 14/30] aspeed/smc: rework the prototype of the AspeedSMCFlash helper routines,
Cédric Le Goater <=
- [Qemu-arm] [PATCH for-2.9 15/30] aspeed/smc: introduce a aspeed_smc_flash_update_cs() helper, Cédric Le Goater, 2016/11/29
- [Qemu-arm] [PATCH for-2.9 16/30] aspeed/smc: autostrap CE0/1 configuration, Cédric Le Goater, 2016/11/29
- [Qemu-arm] [PATCH for-2.9 17/30] aspeed/smc: handle SPI flash Command mode, Cédric Le Goater, 2016/11/29
- [Qemu-arm] [PATCH for-2.9 18/30] aspeed/smc: extend tests for Command mode, Cédric Le Goater, 2016/11/29
- [Qemu-arm] [PATCH for-2.9 19/30] aspeed/smc: unfold the AspeedSMCController array, Cédric Le Goater, 2016/11/29
- [Qemu-arm] [PATCH for-2.9 20/30] aspeed/smc: add a 'sdram_base' property, Cédric Le Goater, 2016/11/29
- [Qemu-arm] [PATCH for-2.9 21/30] aspeed/smc: add support for DMAs, Cédric Le Goater, 2016/11/29
- [Qemu-arm] [PATCH for-2.9 22/30] aspeed/smc: handle dummy bytes when doing fast reads, Cédric Le Goater, 2016/11/29
- [Qemu-arm] [PATCH for-2.9 23/30] aspeed/smc: adjust the size of the register region, Cédric Le Goater, 2016/11/29
- [Qemu-arm] [PATCH for-2.9 24/30] aspeed: use first SPI flash as a boot ROM, Cédric Le Goater, 2016/11/29