aboutsummaryrefslogtreecommitdiff
path: root/hw/sd
diff options
context:
space:
mode:
authorIcenowy Zheng <uwu@icenowy.me>2022-05-20 20:42:00 +0800
committerPeter Maydell <peter.maydell@linaro.org>2022-05-30 12:34:46 +0100
commitfd71f258bc0d245b2223bf3032c0ebc82f8a3463 (patch)
tree5ee35636920c1571ac899a814986d2b446c1033e /hw/sd
parentb5fb359cb5b9bf5d85932b869a707550a4e18ad1 (diff)
hw/sd/allwinner-sdhost: report FIFO water level as 1 when data ready
U-Boot queries the FIFO water level to reduce checking status register when doing PIO SD card operation. Report a FIFO water level of 1 when data is ready, to prevent the code from trying to read 0 words from the FIFO each time. Signed-off-by: Icenowy Zheng <uwu@icenowy.me> Message-id: 20220520124200.2112699-1-uwu@icenowy.me Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'hw/sd')
-rw-r--r--hw/sd/allwinner-sdhost.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/hw/sd/allwinner-sdhost.c b/hw/sd/allwinner-sdhost.c
index 041e45c680..455d6eabf6 100644
--- a/hw/sd/allwinner-sdhost.c
+++ b/hw/sd/allwinner-sdhost.c
@@ -114,7 +114,9 @@ enum {
};
enum {
+ SD_STAR_FIFO_EMPTY = (1 << 2),
SD_STAR_CARD_PRESENT = (1 << 8),
+ SD_STAR_FIFO_LEVEL_1 = (1 << 17),
};
enum {
@@ -467,6 +469,11 @@ static uint64_t allwinner_sdhost_read(void *opaque, hwaddr offset,
break;
case REG_SD_STAR: /* Status */
res = s->status;
+ if (sdbus_data_ready(&s->sdbus)) {
+ res |= SD_STAR_FIFO_LEVEL_1;
+ } else {
+ res |= SD_STAR_FIFO_EMPTY;
+ }
break;
case REG_SD_FWLR: /* FIFO Water Level */
res = s->fifo_wlevel;