hw/sd/allwinner-sdhost.c | 7 +++++++ 1 file changed, 7 insertions(+)
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>
---
hw/sd/allwinner-sdhost.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/hw/sd/allwinner-sdhost.c b/hw/sd/allwinner-sdhost.c
index 041e45c680..b66fd9bce7 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;
--
2.36.0
On Fri, 20 May 2022 at 13:42, Icenowy Zheng <uwu@icenowy.me> wrote: > > 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> > --- > hw/sd/allwinner-sdhost.c | 7 +++++++ > 1 file changed, 7 insertions(+) > > diff --git a/hw/sd/allwinner-sdhost.c b/hw/sd/allwinner-sdhost.c > index 041e45c680..b66fd9bce7 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), > }; Is there documentation on this hardware available somewhere? The Linux kernel driver for it doesn't seem to have a #define for this bit 17. In an ideal world we'd actually emulate the FIFO itself (our pl181 and bcm2835_sdhost models do this, for example). -- PMM
在 2022-05-23星期一的 15:14 +0100,Peter Maydell写道: > On Fri, 20 May 2022 at 13:42, Icenowy Zheng <uwu@icenowy.me> wrote: > > > > 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> > > --- > > hw/sd/allwinner-sdhost.c | 7 +++++++ > > 1 file changed, 7 insertions(+) > > > > diff --git a/hw/sd/allwinner-sdhost.c b/hw/sd/allwinner-sdhost.c > > index 041e45c680..b66fd9bce7 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), > > }; > > Is there documentation on this hardware available somewhere? > The Linux kernel driver for it doesn't seem to have a #define > for this bit 17. For the specific version on H3, https://linux-sunxi.org/File:Allwinner_H3_Datasheet_V1.2.pdf . > > In an ideal world we'd actually emulate the FIFO itself > (our pl181 and bcm2835_sdhost models do this, for example). Interesting, I will check it. > -- PMM
On Mon, 23 May 2022 at 17:40, Icenowy Zheng <uwu@icenowy.me> wrote: > > 在 2022-05-23星期一的 15:14 +0100,Peter Maydell写道: > > On Fri, 20 May 2022 at 13:42, Icenowy Zheng <uwu@icenowy.me> wrote: > > > > > > 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> > > > --- > > > hw/sd/allwinner-sdhost.c | 7 +++++++ > > > 1 file changed, 7 insertions(+) > > > > > > diff --git a/hw/sd/allwinner-sdhost.c b/hw/sd/allwinner-sdhost.c > > > index 041e45c680..b66fd9bce7 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), > > > }; > > > > Is there documentation on this hardware available somewhere? > > The Linux kernel driver for it doesn't seem to have a #define > > for this bit 17. > > For the specific version on H3, > https://linux-sunxi.org/File:Allwinner_H3_Datasheet_V1.2.pdf . Thanks. Since this patch fixes u-boot and is a reasonable approximation to correct device behaviour assuming we don't want to bother emulating the FIFO properly, I've applied it to my target-arm.next tree. -- PMM
© 2016 - 2024 Red Hat, Inc.