提交 0584d3c3 编写于 作者: C Cédric Le Goater 提交者: Peter Maydell

aspeed/smc: improve segment register support

The HW does not enforce all the rules in the specs and allows a few
"curious" setups like zero size segments and overlaps. So change the
model to be in sync but keep the warnings which are always interesting
for debug.
Signed-off-by: NCédric Le Goater <clg@kaod.org>
Reviewed-by: NJoel Stanley <joel@jms.id.au>
Message-id: 1480434248-27138-13-git-send-email-clg@kaod.org
Signed-off-by: NPeter Maydell <peter.maydell@linaro.org>
上级 c491e152
...@@ -253,7 +253,8 @@ static void aspeed_smc_flash_set_segment(AspeedSMCState *s, int cs, ...@@ -253,7 +253,8 @@ static void aspeed_smc_flash_set_segment(AspeedSMCState *s, int cs,
qemu_log_mask(LOG_GUEST_ERROR, qemu_log_mask(LOG_GUEST_ERROR,
"%s: Tried to change CS0 start address to 0x%" "%s: Tried to change CS0 start address to 0x%"
HWADDR_PRIx "\n", s->ctrl->name, seg.addr); HWADDR_PRIx "\n", s->ctrl->name, seg.addr);
return; seg.addr = s->ctrl->flash_window_base;
new = aspeed_smc_segment_to_reg(&seg);
} }
/* /*
...@@ -267,8 +268,10 @@ static void aspeed_smc_flash_set_segment(AspeedSMCState *s, int cs, ...@@ -267,8 +268,10 @@ static void aspeed_smc_flash_set_segment(AspeedSMCState *s, int cs,
s->ctrl->segments[cs].size) { s->ctrl->segments[cs].size) {
qemu_log_mask(LOG_GUEST_ERROR, qemu_log_mask(LOG_GUEST_ERROR,
"%s: Tried to change CS%d end address to 0x%" "%s: Tried to change CS%d end address to 0x%"
HWADDR_PRIx "\n", s->ctrl->name, cs, seg.addr); HWADDR_PRIx "\n", s->ctrl->name, cs, seg.addr + seg.size);
return; seg.size = s->ctrl->segments[cs].addr + s->ctrl->segments[cs].size -
seg.addr;
new = aspeed_smc_segment_to_reg(&seg);
} }
/* Keep the segment in the overall flash window */ /* Keep the segment in the overall flash window */
...@@ -281,16 +284,14 @@ static void aspeed_smc_flash_set_segment(AspeedSMCState *s, int cs, ...@@ -281,16 +284,14 @@ static void aspeed_smc_flash_set_segment(AspeedSMCState *s, int cs,
} }
/* Check start address vs. alignment */ /* Check start address vs. alignment */
if (seg.addr % seg.size) { if (seg.size && !QEMU_IS_ALIGNED(seg.addr, seg.size)) {
qemu_log_mask(LOG_GUEST_ERROR, "%s: new segment for CS%d is not " qemu_log_mask(LOG_GUEST_ERROR, "%s: new segment for CS%d is not "
"aligned : [ 0x%"HWADDR_PRIx" - 0x%"HWADDR_PRIx" ]\n", "aligned : [ 0x%"HWADDR_PRIx" - 0x%"HWADDR_PRIx" ]\n",
s->ctrl->name, cs, seg.addr, seg.addr + seg.size); s->ctrl->name, cs, seg.addr, seg.addr + seg.size);
} }
/* And segments should not overlap */ /* And segments should not overlap (in the specs) */
if (aspeed_smc_flash_overlap(s, &seg, cs)) { aspeed_smc_flash_overlap(s, &seg, cs);
return;
}
/* All should be fine now to move the region */ /* All should be fine now to move the region */
memory_region_transaction_begin(); memory_region_transaction_begin();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册