Initial i.MX7 support
v3 cover Initial i.MX7 support
Hi everyone,
This v3 of the patch series containing the work that I've done in order to enable support for i.MX7 emulation in QEMU.
As the one before last commit in the series states the supported i.MX7 features are:
* up to 2 Cortex A9 cores (SMP works with PSCI)
* A7 MPCORE (identical to A15 MPCORE)
* 4 GPTs modules
* 7 GPIO controllers
* 2 IOMUXC controllers
* 1 CCM module
* 1 SVNS module
* 1 SRC module
* 1 GPCv2 controller
* 4 eCSPI controllers
* 4 I2C controllers
* 7 i.MX UART controllers
* 2 FlexCAN controllers
* 2 Ethernet controllers (FEC)
* 3 SD controllers (USDHC)
* 4 WDT modules
* 1 SDMA module
* 1 GPR module
* 2 USBMISC modules
* 2 ADC modules
* 1 PCIe controller
* 3 USB controllers
* 1 LCD controller
* 1 ARMv7 DAP IP block
Feedback is welcome!
Changes since [v2]:
- Added stubs for more blocks that were causing memory transactions when booting Linux guest as were revealed by additional testing of the patchest
- Added proper USB emulation code, so now it should be possible to emulated guest's USB bus
Changes since [v1]:
- Patchset no longer relies on "ignore_memory_transaction_failures = false" for its functionality
- As a consequnce of implementing the above a number of patches implementing dummy IP block emulation as well as PCIe emulation patches that I alluded to in [v1] are now included in this patch series
- "has_el3" property is no longer being set to "false" as a part of intialization of A7 CPU. I couldn't reproduce the issues that I thought I was having, so I just dropped that code.
- A number of smaller feedback items from Peter and other has been incorporated into the patches.
Peter, I didn't hear anything from you about the code of mcimx7d_add_psci_node(), as discussed here:
https://www.mail-archive.com/[email protected]/msg486874.html
so I kept the original code intact. As I mentioned before, my goal was to be able to boot into vanilla Linux kerenel and have working SMP without needing to use a PSCI implementing bootloader. If that is something that new board code shouldn't do, please let me know.
Thanks,
Andrey Smirnov
[v2] https://lists.gnu.org/archive/html/qemu-devel/2017-10/msg05516.html
[v1] https://lists.gnu.org/archive/html/qemu-devel/2017-09/msg04770.html
Andrey Smirnov (30):
imx_fec: Do not link to netdev
imx_fec: Refactor imx_eth_enable_rx()
imx_fec: Change queue flushing heuristics
imx_fec: Use ENET_FTRL to determine truncation length
imx_fec: Use MIN instead of explicit ternary operator
imx_fec: Emulate SHIFT16 in ENETx_RACC
imx_fec: Add support for multiple Tx DMA rings
imx_fec: Use correct length for packet size
imx_fec: Fix a typo in imx_enet_receive()
imx_fec: Reserve full 4K page for the register file
sdhci: Add i.MX specific subtype of SDHCI
sdhci: Implement write method of ACMD12ERRSTS register i.MX: Add code to emulate i.MX7 CCM, PMU and ANALOG IP blocks i.MX: Add code to emulate i.MX2 watchdog IP block i.MX: Add code to emulate i.MX7 SNVS IP-block
i.MX: Add code to emulate GPCv2 IP block
i.MX: Add code to emulate i.MX7 IOMUXC IP block i.MX: Add i.MX7 GPT variant
i.MX: Add code to emulate SDMA IP block
i.MX: Add code to emulate FlexCAN IP block
i.MX: Add implementation of i.MX7 GPR IP block
pci: Add support for Designware IP block
i.MX: Add code to emulate i.MX7 USBMISC IP block i.MX: Add code to emulate i.MX7 ADC IP block
i.MX: Add code to emulate i.MX7 SRC IP-block
usb: Add basic code to emulate Chipidea USB IP
ARM: Add basic code to emulate A7MPCore DAP block i.MX: Add code to emulate i.MX LCD block
i.MX: Add i.MX7 SOC implementation.
Implement support for i.MX7 Sabre board
default-configs/arm-softmmu.mak | 3 + hw/arm/Makefile.objs | 4 +- hw/arm/coresight.c | 120 ++++++++ hw/arm/fsl-imx6.c | 1 + hw/arm/fsl-imx7.c | 646 +++++++++++++++++++++++++++++++++++++++ hw/arm/mcimx7d-sabre.c | 101 ++++++ hw/display/Makefile.objs | 2 + hw/display/imx_lcdif.c | 71 +++++ hw/dma/Makefile.objs | 1 + hw/dma/imx_sdma.c | 99 ++++++ hw/intc/Makefile.objs | 2 +- hw/intc/imx_gpcv2.c | 125 ++++++++ hw/misc/Makefile.objs | 8 + hw/misc/imx2_wdt.c | 88 ++++++ hw/misc/imx7_adc.c | 99 ++++++ hw/misc/imx7_ccm.c | 233 ++++++++++++++ hw/misc/imx7_gpr.c | 119 ++++++++ hw/misc/imx7_iomuxc.c | 99 ++++++ hw/misc/imx7_snvs.c | 83 +++++ hw/misc/imx7_src.c | 93 ++++++ hw/misc/imx_flexcan.c | 99 ++++++ hw/net/imx_fec.c | 163 +++++++--- hw/pci-host/Makefile.objs | 2 + hw/pci-host/designware.c | 614 +++++++++++++++++++++++++++++++++++++ hw/sd/sdhci-internal.h | 15 + hw/sd/sdhci.c | 130 +++++++- hw/timer/imx_gpt.c | 25 ++ hw/usb/Makefile.objs | 2 + hw/usb/chipidea.c | 176 +++++++++++ hw/usb/imx-usbmisc.c | 99 ++++++ include/hw/arm/coresight.h | 24 ++ include/hw/arm/fsl-imx7.h | 233 ++++++++++++++ include/hw/display/imx_lcdif.h | 16 + include/hw/dma/imx_sdma.h | 22 ++ include/hw/intc/imx_gpcv2.h | 22 ++ include/hw/misc/imx2_wdt.h | 34 +++ include/hw/misc/imx7_adc.h | 22 ++ include/hw/misc/imx7_ccm.h | 130 ++++++++ include/hw/misc/imx7_gpr.h | 28 ++ include/hw/misc/imx7_iomuxc.h | 22 ++ include/hw/misc/imx7_snvs.h | 35 +++ include/hw/misc/imx7_src.h | 22 ++ include/hw/misc/imx_flexcan.h | 22 ++ include/hw/net/imx_fec.h | 24 +- include/hw/pci-host/designware.h | 92 ++++++ include/hw/pci/pci_ids.h | 2 + include/hw/sd/sdhci.h | 8 + include/hw/timer/imx_gpt.h | 1 + include/hw/usb/chipidea.h | 16 + include/hw/usb/imx-usbmisc.h | 22 ++ 50 files changed, 4074 insertions(+), 45 deletions(-) create mode 100644 hw/arm/coresight.c create mode 100644 hw/arm/fsl-imx7.c create mode 100644 hw/arm/mcimx7d-sabre.c create mode 100644 hw/display/imx_lcdif.c create mode 100644 hw/dma/imx_sdma.c create mode 100644 hw/intc/imx_gpcv2.c create mode 100644 hw/misc/imx2_wdt.c create mode 100644 hw/misc/imx7_adc.c create mode 100644 hw/misc/imx7_ccm.c create mode 100644 hw/misc/imx7_gpr.c create mode 100644 hw/misc/imx7_iomuxc.c create mode 100644 hw/misc/imx7_snvs.c create mode 100644 hw/misc/imx7_src.c create mode 100644 hw/misc/imx_flexcan.c create mode 100644 hw/pci-host/designware.c create mode 100644 hw/usb/chipidea.c create mode 100644 hw/usb/imx-usbmisc.c create mode 100644 include/hw/arm/coresight.h create mode 100644 include/hw/arm/fsl-imx7.h create mode 100644 include/hw/display/imx_lcdif.h create mode 100644 include/hw/dma/imx_sdma.h create mode 100644 include/hw/intc/imx_gpcv2.h create mode 100644 include/hw/misc/imx2_wdt.h create mode 100644 include/hw/misc/imx7_adc.h create mode 100644 include/hw/misc/imx7_ccm.h create mode 100644 include/hw/misc/imx7_gpr.h create mode 100644 include/hw/misc/imx7_iomuxc.h create mode 100644 include/hw/misc/imx7_snvs.h create mode 100644 include/hw/misc/imx7_src.h create mode 100644 include/hw/misc/imx_flexcan.h create mode 100644 include/hw/pci-host/designware.h create mode 100644 include/hw/usb/chipidea.h create mode 100644 include/hw/usb/imx-usbmisc.h
Signature · 1 line
2.13.6
PATCH v3 1/30 imx_fec: Do not link to netdev
Binding to a particular netdev doesn't seem to belong to this layer and should probably be done as a part of board or SoC specific code.
Convert all of the users of this IP block to useqdev_set_nic_properties() instead.
--- hw/arm/fsl-imx6.c | 1 + hw/net/imx_fec.c | 2 -- 2 files changed, 1 insertion(+), 2 deletions(-)
hw/arm/fsl-imx6.c +1 -0
@@ -385,6 +385,7 @@ static void fsl_imx6_realize(DeviceState *dev, Error **errp) spi_table[i].irq)); } +qdev_set_nic_properties (DEVICE (&s->eth), &nd_table[0 ]);object_property_set_bool (OBJECT (&s->eth), true,"realized" , &err);if (err) {error_propagate (errp, err);
hw/net/imx_fec.c +0 -2
@@ -1171,8 +1171,6 @@ static void imx_eth_realize(DeviceState *dev, Error **errp)qemu_macaddr_default_if_unset (&s->conf.macaddr); - s->conf.peers.ncs[0 ] = nd_table[0 ].netdev; - s->nic =qemu_new_nic (&imx_eth_net_info, &s->conf,object_get_typename (OBJECT (dev)),DEVICE (dev)->id, s);
Signature · 1 line
2.13.6
PATCH v3 2/30 imx_fec: Refactor imx_eth_enable_rx()
In reply to Andrey SmirnovRefactor imx_eth_enable_rx() to have more meaningfull variable name than 'tmp' and to reduce number of logical negations done.
--- hw/net/imx_fec.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
hw/net/imx_fec.c +4 -4
@@ -536,19 +536,19 @@ static void imx_eth_do_tx(IMXFECState *s)static void imx_eth_enable_rx (IMXFECState *s) {IMXFECBufDesc bd; -bool tmp; +bool rx_ring_full;imx_fec_read_bd (&bd, s->rx_descriptor); - tmp = ((bd.flags &ENET_BD_E ) !=0 ); + rx_ring_full = !(bd.flags &ENET_BD_E ); -if (!tmp) { +if (rx_ring_full) {FEC_PRINTF ("RX buffer full\n" ); }else if (!s->regs[ENET_RDAR ]) {qemu_flush_queued_packets (qemu_get_queue (s->nic)); } - s->regs[ENET_RDAR ] = tmp ?ENET_RDAR_RDAR :0 ; + s->regs[ENET_RDAR ] = rx_ring_full ?0 :ENET_RDAR_RDAR ; }static void imx_eth_reset (DeviceState *d)
Signature · 1 line
2.13.6
PATCH v3 3/30 imx_fec: Change queue flushing heuristics
In reply to Andrey SmirnovIn current implementation, packet queue flushing logic seem to suffer from a deadlock like scenario if a packet is received by the interface before before Rx ring is initialized by Guest's driver. Consider the following sequence of events:
1. A QEMU instance is started against a TAP device on Linux host, running Linux guest, e. g., something to the effect of:
qemu-system-arm \
-net nic,model=imx.fec,netdev=lan0 \
netdev tap,id=lan0,ifname=tap0,script=no,downscript=no \
... rest of the arguments ...
2. Once QEMU starts, but before guest reaches the point where FEC deriver is done initializing the HW, Guest, via TAP interface, receives a number of multicast MDNS packets from Host (not necessarily true for every OS, but it happens at least on Fedora 25)
3. Recieving a packet in such a state results in imx_eth_can_receive() returning '0', which in turn causes tap_send() to disable corresponding event (tap.c:203)
4. Once Guest's driver reaches the point where it is ready to recieve packets it prepares Rx ring descriptors and writes ENET_RDAR_RDAR to ENET_RDAR register to indicate to HW that more descriptors are ready. And at this points emulation layer does this:
s->regs[index] = ENET_RDAR_RDAR;
imx_eth_enable_rx(s);
which, combined with:
if (!s->regs[ENET_RDAR]) {
qemu_flush_queued_packets(qemu_get_queue(s->nic));
}
results in Rx queue never being flushed and corresponding I/O event beign disabled.
To prevent the problem, change the code to always flush packet queue when ENET_RDAR transitions 0 -> ENET_RDAR_RDAR.
--- hw/net/imx_fec.c | 12 ++++++------ include/hw/net/imx_fec.h | 1 + 2 files changed, 7 insertions(+), 6 deletions(-)
hw/net/imx_fec.c +6 -6
@@ -533,7 +533,7 @@ static void imx_eth_do_tx(IMXFECState *s) } } -static void imx_eth_enable_rx (IMXFECState *s) +static void imx_eth_enable_rx (IMXFECState *s,bool flush) {IMXFECBufDesc bd;bool rx_ring_full;
@@ -544,7 +544,7 @@ static void imx_eth_enable_rx(IMXFECState *s)if (rx_ring_full) {FEC_PRINTF ("RX buffer full\n" ); - }else if (!s->regs[ENET_RDAR ]) { + }else if (flush) {qemu_flush_queued_packets (qemu_get_queue (s->nic)); }
@@ -807,7 +807,7 @@ static void imx_eth_write(void *opaque, hwaddr offset, uint64_t value,if (s->regs[ENET_ECR ] &ENET_ECR_ETHEREN ) {if (!s->regs[index]) { s->regs[index] =ENET_RDAR_RDAR ; -imx_eth_enable_rx (s); +imx_eth_enable_rx (s, true); } }else { s->regs[index] =0 ;
@@ -930,7 +930,7 @@ static int imx_eth_can_receive(NetClientState *nc)FEC_PRINTF ("\n" ); -return s->regs[ENET_RDAR ] ?1 :0 ; +return !!s->regs[ENET_RDAR ]; } static ssize_t imx_fec_receive(NetClientState *nc, const uint8_t *buf,
@@ -1020,7 +1020,7 @@ static ssize_t imx_fec_receive(NetClientState *nc, const uint8_t *buf, } } s->rx_descriptor = addr; -imx_eth_enable_rx (s); +imx_eth_enable_rx (s, false);imx_eth_update (s);return len; }
@@ -1116,7 +1116,7 @@ static ssize_t imx_enet_receive(NetClientState *nc, const uint8_t *buf, } } s->rx_descriptor = addr; -imx_eth_enable_rx (s); +imx_eth_enable_rx (s, false);imx_eth_update (s);return len; }
include/hw/net/imx_fec.h +1 -0
@@ -252,6 +252,7 @@ typedef struct IMXFECState {uint32_t phy_int_mask;bool is_fec; + bool needs_flush; } IMXFECState;#endif
Signature · 1 line
2.13.6
Re: [Qemu-arm] [PATCH v3 03/30] imx_fec: Change queue flushing heuristics
Quoted 57 lines · Andrey Smirnov
In current implementation, packet queue flushing logic seem to suffer from a deadlock like scenario if a packet is received by the interface before before Rx ring is initialized by Guest's driver. Consider the following sequence of events:
1. A QEMU instance is started against a TAP device on Linux host, running Linux guest, e. g., something to the effect of:
qemu-system-arm \
-net nic,model=imx.fec,netdev=lan0 \
netdev tap,id=lan0,ifname=tap0,script=no,downscript=no \
... rest of the arguments ...2. Once QEMU starts, but before guest reaches the point where FEC deriver is done initializing the HW, Guest, via TAP interface, receives a number of multicast MDNS packets from Host (not necessarily true for every OS, but it happens at least on Fedora 25)
3. Recieving a packet in such a state results in
imx_eth_can_receive()returning '0', which in turn causestap_send()to disable corresponding event (tap.c:203)4. Once Guest's driver reaches the point where it is ready to recieve packets it prepares Rx ring descriptors and writes
ENET_RDAR_RDARtoENET_RDARregister to indicate to HW that more descriptors are ready. And at this points emulation layer does this:s->regs[index] =
ENET_RDAR_RDAR;
imx_eth_enable_rx(s);which, combined with:
if (!s->regs[ENET_RDAR]) {
qemu_flush_queued_packets(qemu_get_queue(s->nic));
}results in Rx queue never being flushed and corresponding I/O event beign disabled.
To prevent the problem, change the code to always flush packet queue when
ENET_RDARtransitions 0 ->ENET_RDAR_RDAR.Cc Peter Maydell <[email protected]>Cc Jason Wang <[email protected]>Cc Philippe Mathieu-Daudé <[email protected]>Signed-off-by Andrey Smirnov <[email protected]>include/hw/net/imx_fec.h +0
-0
include/hw/net/imx_fec.h typedef struct IMXFECState { · line 256
Quoted 5 lines
include/hw/net/imx_fec.h +1
-0@@ -252,6 +252,7 @@ typedef struct IMXFECState {uint32_t phy_int_mask;bool is_fec; +bool needs_flush; } IMXFECState;
This field isn't needed any more in this version of the patch, I think?
otherwise
thanks
-- PMM
Re: [Qemu-arm] [PATCH v3 03/30] imx_fec: Change queue flushing heuristics
Quoted 60 lines · Peter Maydell
Quoted 59 lines · Andrey Smirnov
In current implementation, packet queue flushing logic seem to suffer from a deadlock like scenario if a packet is received by the interface before before Rx ring is initialized by Guest's driver. Consider the following sequence of events:
1. A QEMU instance is started against a TAP device on Linux host, running Linux guest, e. g., something to the effect of:
qemu-system-arm \
-net nic,model=imx.fec,netdev=lan0 \
netdev tap,id=lan0,ifname=tap0,script=no,downscript=no \
... rest of the arguments ...2. Once QEMU starts, but before guest reaches the point where FEC deriver is done initializing the HW, Guest, via TAP interface, receives a number of multicast MDNS packets from Host (not necessarily true for every OS, but it happens at least on Fedora 25)
3. Recieving a packet in such a state results in
imx_eth_can_receive()returning '0', which in turn causestap_send()to disable corresponding event (tap.c:203)4. Once Guest's driver reaches the point where it is ready to recieve packets it prepares Rx ring descriptors and writes
ENET_RDAR_RDARtoENET_RDARregister to indicate to HW that more descriptors are ready. And at this points emulation layer does this:s->regs[index] =
ENET_RDAR_RDAR;
imx_eth_enable_rx(s);which, combined with:
if (!s->regs[ENET_RDAR]) {
qemu_flush_queued_packets(qemu_get_queue(s->nic));
}results in Rx queue never being flushed and corresponding I/O event beign disabled.
To prevent the problem, change the code to always flush packet queue when
ENET_RDARtransitions 0 ->ENET_RDAR_RDAR.Cc Peter Maydell <[email protected]>Cc Jason Wang <[email protected]>Cc Philippe Mathieu-Daudé <[email protected]>Signed-off-by Andrey Smirnov <[email protected]>include/hw/net/imx_fec.h +0
-0@@ -252,6 +252,7 @@ typedef struct IMXFECState {uint32_t phy_int_mask;
Quoted 6 lines
include/hw/net/imx_fec.h typedef struct IMXFECState { · line 256
Quoted 3 lines
include/hw/net/imx_fec.h +1
-0bool is_fec; +bool needs_flush; } IMXFECState;This field isn't needed any more in this version of the patch, I think?
Yeah, my bad, forgot to remove this part. Will do in v4.
Thanks,
Andrey Smirnov
PATCH v3 4/30 imx_fec: Use ENET_FTRL to determine truncation length
In reply to Andrey SmirnovFrame truncation length, TRUNC_FL, is determined by the contents of ENET_FTRL register, so convert the code to use it instead of a hardcoded constant.
To avoid the case where TRUNC_FL is greater that ENET_MAX_FRAME_SIZE, increase the value of the latter to its theoretical maximum of 16K.
--- hw/net/imx_fec.c | 4 ++-- include/hw/net/imx_fec.h | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-)
hw/net/imx_fec.c +2 -2
@@ -1052,8 +1052,8 @@ static ssize_t imx_enet_receive(NetClientState *nc, const uint8_t *buf, crc_ptr = (uint8_t *) &crc;/* Huge frames are truncted. */ -if (size >ENET_MAX_FRAME_SIZE ) { - size =ENET_MAX_FRAME_SIZE ; +if (size > s->regs[ENET_FTRL ]) { + size = s->regs[ENET_FTRL ]; flags |=ENET_BD_TR |ENET_BD_LG ; }
include/hw/net/imx_fec.h +2 -1
@@ -86,7 +86,6 @@#define ENET_TCCR3 393#define ENET_MAX 400 -#define ENET_MAX_FRAME_SIZE 2032/* EIR and EIMR */ #define ENET_INT_HB (1 << 31)
@@ -155,6 +154,8 @@#define ENET_RCR_NLC (1 << 30)#define ENET_RCR_GRS (1 << 31) +#define ENET_MAX_FRAME_SIZE (1 << ENET_RCR_MAX_FL_LENGTH) +/* TCR */ #define ENET_TCR_GTS (1 << 0)#define ENET_TCR_FDEN (1 << 2)
Signature · 1 line
2.13.6
Re: [Qemu-arm] [PATCH v3 04/30] imx_fec: Use ENET_FTRL to determine truncation length
Quoted 47 lines · Andrey Smirnov
Frame truncation length,
TRUNC_FL, is determined by the contents ofENET_FTRLregister, so convert the code to use it instead of a hardcoded constant.To avoid the case where
TRUNC_FLis greater thatENET_MAX_FRAME_SIZE, increase the value of the latter to its theoretical maximum of 16K.Cc Peter Maydell <[email protected]>Cc Jason Wang <[email protected]>Cc Philippe Mathieu-Daudé <[email protected]>Signed-off-by Andrey Smirnov <[email protected]>--- hw/net/imx_fec.c | 4 ++-- include/hw/net/imx_fec.h | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-)hw/net/imx_fec.c +2
-2@@ -1052,8 +1052,8 @@ static ssize_t imx_enet_receive(NetClientState *nc, const uint8_t *buf, crc_ptr = (uint8_t *) &crc;/* Huge frames are truncted. */ -if (size >ENET_MAX_FRAME_SIZE ) { - size =ENET_MAX_FRAME_SIZE ; +if (size > s->regs[ENET_FTRL ]) { + size = s->regs[ENET_FTRL ]; flags |=ENET_BD_TR |ENET_BD_LG ; }include/hw/net/imx_fec.h +0
-1@@ -86,7 +86,6 @@#define ENET_TCCR3 393#define ENET_MAX 400 -#define ENET_MAX_FRAME_SIZE 2032/* EIR and EIMR */ #define ENET_INT_HB (1 << 31)
include/hw/net/imx_fec.h line 157
Quoted 4 lines
include/hw/net/imx_fec.h +1
-0@@ -155,6 +154,8 @@#define ENET_RCR_NLC (1 << 30)#define ENET_RCR_GRS (1 << 31) +#define ENET_MAX_FRAME_SIZE (1 << ENET_RCR_MAX_FL_LENGTH)
This means we now have functions with 16K local array variables on the stack, which seems like a bad idea.
thanks
-- PMM
Re: [Qemu-arm] [PATCH v3 04/30] imx_fec: Use ENET_FTRL to determine truncation length
Quoted 51 lines · Peter Maydell
Quoted 50 lines · Andrey Smirnov
Frame truncation length,
TRUNC_FL, is determined by the contents ofENET_FTRLregister, so convert the code to use it instead of a hardcoded constant.To avoid the case where
TRUNC_FLis greater thatENET_MAX_FRAME_SIZE, increase the value of the latter to its theoretical maximum of 16K.Cc Peter Maydell <[email protected]>Cc Jason Wang <[email protected]>Cc Philippe Mathieu-Daudé <[email protected]>Signed-off-by Andrey Smirnov <[email protected]>--- hw/net/imx_fec.c | 4 ++-- include/hw/net/imx_fec.h | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-)hw/net/imx_fec.c +2
-2@@ -1052,8 +1052,8 @@ static ssize_t imx_enet_receive(NetClientState *nc, const uint8_t *buf, crc_ptr = (uint8_t *) &crc;/* Huge frames are truncted. */ -if (size >ENET_MAX_FRAME_SIZE ) { - size =ENET_MAX_FRAME_SIZE ; +if (size > s->regs[ENET_FTRL ]) { + size = s->regs[ENET_FTRL ]; flags |=ENET_BD_TR |ENET_BD_LG ; }include/hw/net/imx_fec.h +0
-1@@ -86,7 +86,6 @@#define ENET_TCCR3 393#define ENET_MAX 400 -#define ENET_MAX_FRAME_SIZE 2032/* EIR and EIMR */ #define ENET_INT_HB (1 << 31)@@ -155,6 +154,8 @@#define ENET_RCR_NLC (1 << 30)#define ENET_RCR_GRS (1 << 31)
Quoted 5 lines
include/hw/net/imx_fec.h line 157
Quoted 1 line
include/hw/net/imx_fec.h +1
-0+#define ENET_MAX_FRAME_SIZE (1 << ENET_RCR_MAX_FL_LENGTH)This means we now have functions with 16K local array variables on the stack, which seems like a bad idea.
Can't say I see a big difference between having a 2K vs 16K buffer on the stack, but regardless, I am not quite clear if you are not too hot about this patch and want me to drop it (I am fine with it) or do you want me to modify it to have the emulation layer allocate said 16K buffer on the heap instead of a stack?
Thanks,
Andrey Smirnov
Re: [Qemu-arm] [PATCH v3 04/30] imx_fec: Use ENET_FTRL to determine truncation length
Quoted 16 lines · Andrey Smirnov
Quoted 5 lines · Peter Maydell
Quoted 4 lines · Andrey Smirnov
Frame truncation length,
TRUNC_FL, is determined by the contents ofENET_FTRLregister, so convert the code to use it instead of a hardcoded constant.Quoted 9 lines
Quoted 5 lines
To avoid the case where
TRUNC_FLis greater thatENET_MAX_FRAME_SIZE, increase the value of the latter to its theoretical maximum of 16K.+#define
ENET_MAX_FRAME_SIZE(1 <<ENET_RCR_MAX_FL_LENGTH)This means we now have functions with 16K local array variables on the stack, which seems like a bad idea.
Quoted 5 lines
Can't say I see a big difference between having a 2K vs 16K buffer on the stack, but regardless, I am not quite clear if you are not too hot about this patch and want me to drop it (I am fine with it) or do you want me to modify it to have the emulation layer allocate said 16K buffer on the heap instead of a stack?
To be clearer: 16K is too large a buffer to have on the stack; 2K is about as big as you want to go.
If you want to allow 16K packets then you need to avoid having on-stack arrays of that length. (But you don't want to do a heap allocation for every function call either.)
"look for and fix functions with arrays of 16K or more" is one of our bite-sized-tasks for people who want to fix bugs:
https://wiki.qemu.org/Contribute/BiteSizedTasks#Large_frames
thanks
-- PMM
PATCH v3 5/30 imx_fec: Use MIN instead of explicit ternary operator
In reply to Andrey Smirnov--- hw/net/imx_fec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
hw/net/imx_fec.c +1 -1
@@ -1076,7 +1076,7 @@ static ssize_t imx_enet_receive(NetClientState *nc, const uint8_t *buf, TYPE_IMX_FEC, __func__);break ; } - buf_len = (size <= s->regs[ENET_MRBR ]) ? size : s->regs[ENET_MRBR ]; + buf_len =MIN (size, s->regs[ENET_MRBR ]); bd.length = buf_len; size -= buf_len;
Signature · 1 line
2.13.6
PATCH v3 6/30 imx_fec: Emulate SHIFT16 in ENETx_RACC
In reply to Andrey SmirnovNeeded to support latest Linux kernel driver which relies on that functionality.
--- hw/net/imx_fec.c | 23 +++++++++++++++++++++++ include/hw/net/imx_fec.h | 2 ++ 2 files changed, 25 insertions(+)
hw/net/imx_fec.c +23 -0
@@ -1037,6 +1037,7 @@ static ssize_t imx_enet_receive(NetClientState *nc, const uint8_t *buf,uint8_t *crc_ptr;unsigned int buf_len;size_t size = len; +bool shift16 = s->regs[ENET_RACC ] &ENET_RACC_SHIFT16 ;FEC_PRINTF ("len %d\n" , (int )size);
@@ -1051,6 +1052,10 @@ static ssize_t imx_enet_receive(NetClientState *nc, const uint8_t *buf, crc =cpu_to_be32 (crc32 (~0 , buf, size)); crc_ptr = (uint8_t *) &crc; +if (shift16) { + size +=2 ; + } +/* Huge frames are truncted. */ if (size > s->regs[ENET_FTRL ]) { size = s->regs[ENET_FTRL ];
@@ -1087,6 +1092,24 @@ static ssize_t imx_enet_receive(NetClientState *nc, const uint8_t *buf, buf_len += size -4 ; } buf_addr = bd.data; + +if (shift16) { +/* +* If SHIFT16 bit of ENETx_RACC register is set we need to +* align the payload to 4-byte boundary. +*/ +const uint8_t zeros[2 ] = {0 }; + +dma_memory_write (&address_space_memory, buf_addr, + zeros,sizeof (zeros)); + + buf_addr +=sizeof (zeros); + buf_len -=sizeof (zeros); + +/* We only do this once per Ethernet frame */ + shift16 = false; + } +dma_memory_write (&address_space_memory, buf_addr, buf, buf_len); buf += buf_len;if (size <4 ) {
include/hw/net/imx_fec.h +2 -0
@@ -170,6 +170,8 @@#define ENET_TWFR_TFWR_LENGTH (6)#define ENET_TWFR_STRFWD (1 << 8) +#define ENET_RACC_SHIFT16 BIT(7) +/* Buffer Descriptor. */ typedef struct { uint16_t length;
Signature · 1 line
2.13.6
PATCH v3 7/30 imx_fec: Add support for multiple Tx DMA rings
In reply to Andrey SmirnovMore recent version of the IP block support more than one Tx DMA ring, so add the code implementing that feature.
--- hw/net/imx_fec.c | 106 ++++++++++++++++++++++++++++++++++++++--------- include/hw/net/imx_fec.h | 18 +++++++- 2 files changed, 102 insertions(+), 22 deletions(-)
hw/net/imx_fec.c +86 -20
@@ -198,13 +198,13 @@ static const char *imx_eth_reg_name(IMXFECState *s, uint32_t index)static const VMStateDescription vmstate_imx_eth = { .name =TYPE_IMX_FEC , - .version_id =2 , - .minimum_version_id =2 , + .version_id =3 , + .minimum_version_id =3 , .fields = (VMStateField []) {VMSTATE_UINT32_ARRAY (regs, IMXFECState,ENET_MAX ),VMSTATE_UINT32 (rx_descriptor, IMXFECState), -VMSTATE_UINT32 (tx_descriptor, IMXFECState), - +VMSTATE_UINT32_ARRAY (tx_descriptor, IMXFECState,ENET_TX_RING_NUM ), +VMSTATE_UINT32 (tx_ring_num, IMXFECState),VMSTATE_UINT32 (phy_status, IMXFECState),VMSTATE_UINT32 (phy_control, IMXFECState),VMSTATE_UINT32 (phy_advertise, IMXFECState),
@@ -407,7 +407,7 @@ static void imx_fec_do_tx(IMXFECState *s)int frame_size =0 , descnt =0 ;uint8_t frame[ENET_MAX_FRAME_SIZE ];uint8_t *ptr = frame; -uint32_t addr = s->tx_descriptor; +uint32_t addr = s->tx_descriptor[0 ];while (descnt++ <IMX_MAX_DESC ) {IMXFECBufDesc bd;
@@ -448,17 +448,47 @@ static void imx_fec_do_tx(IMXFECState *s) } } - s->tx_descriptor = addr; + s->tx_descriptor[0 ] = addr;imx_eth_update (s); } -static void imx_enet_do_tx (IMXFECState *s) +static void imx_enet_do_tx (IMXFECState *s,uint32_t index) {int frame_size =0 , descnt =0 ;uint8_t frame[ENET_MAX_FRAME_SIZE ];uint8_t *ptr = frame; -uint32_t addr = s->tx_descriptor; +uint32_t addr, int_txb, int_txf, tdsr; +size_t ring; + +switch (index) { +case ENET_TDAR : + ring =0 ; + int_txb =ENET_INT_TXB ; + int_txf =ENET_INT_TXF ; + tdsr =ENET_TDSR ; +break ; +case ENET_TDAR1 : + ring =1 ; + int_txb =ENET_INT_TXB1 ; + int_txf =ENET_INT_TXF1 ; + tdsr =ENET_TDSR1 ; +break ; +case ENET_TDAR2 : + ring =2 ; + int_txb =ENET_INT_TXB2 ; + int_txf =ENET_INT_TXF2 ; + tdsr =ENET_TDSR2 ; +break ; +default : +qemu_log_mask (LOG_GUEST_ERROR , +"%s: bogus value for index %x\n" , + __func__, index); +abort (); +break ; + } + + addr = s->tx_descriptor[ring];while (descnt++ <IMX_MAX_DESC ) {IMXENETBufDesc bd;
@@ -502,32 +532,32 @@ static void imx_enet_do_tx(IMXFECState *s) ptr = frame; frame_size =0 ;if (bd.option &ENET_BD_TX_INT ) { - s->regs[ENET_EIR ] |=ENET_INT_TXF ; + s->regs[ENET_EIR ] |= int_txf; } }if (bd.option &ENET_BD_TX_INT ) { - s->regs[ENET_EIR ] |=ENET_INT_TXB ; + s->regs[ENET_EIR ] |= int_txb; } bd.flags &= ~ENET_BD_R ;/* Write back the modified descriptor. */ imx_enet_write_bd (&bd, addr);/* Advance to the next descriptor. */ if ((bd.flags &ENET_BD_W ) !=0 ) { - addr = s->regs[ENET_TDSR ]; + addr = s->regs[tdsr]; }else { addr +=sizeof (bd); } } - s->tx_descriptor = addr; + s->tx_descriptor[ring] = addr;imx_eth_update (s); } -static void imx_eth_do_tx (IMXFECState *s) +static void imx_eth_do_tx (IMXFECState *s,uint32_t index) {if (!s->is_fec && (s->regs[ENET_ECR ] &ENET_ECR_EN1588 )) { -imx_enet_do_tx (s); +imx_enet_do_tx (s, index); }else {imx_fec_do_tx (s); }
@@ -585,7 +615,7 @@ static void imx_eth_reset(DeviceState *d) } s->rx_descriptor =0 ; - s->tx_descriptor =0 ; +memset (s->tx_descriptor,0 ,sizeof (s->tx_descriptor));/* We also reset the PHY */ phy_reset (s);
@@ -791,6 +821,7 @@ static void imx_eth_write(void *opaque, hwaddr offset, uint64_t value, unsigned size) {IMXFECState *s =IMX_FEC (opaque); +const bool single_tx_ring = s->tx_ring_num !=3 ;uint32_t index = offset >>2 ; FEC_PRINTF("reg[%s] <= 0x%" PRIx32 "\n", imx_eth_reg_name(s, index),
@@ -813,10 +844,18 @@ static void imx_eth_write(void *opaque, hwaddr offset, uint64_t value, s->regs[index] =0 ; }break ; -case ENET_TDAR : +case ENET_TDAR1 :/* FALLTHROUGH */ +case ENET_TDAR2 :/* FALLTHROUGH */ +if (unlikely (single_tx_ring)) { +qemu_log_mask (LOG_GUEST_ERROR , +"[%s]%s: trying to access TDAR2 or TDAR1\n" , +TYPE_IMX_FEC , __func__); +return ; + } +case ENET_TDAR :/* FALLTHROUGH */ if (s->regs[ENET_ECR ] &ENET_ECR_ETHEREN ) { s->regs[index] =ENET_TDAR_TDAR ; -imx_eth_do_tx (s); +imx_eth_do_tx (s, index); } s->regs[index] =0 ;break ;
@@ -828,8 +867,12 @@ static void imx_eth_write(void *opaque, hwaddr offset, uint64_t value,if ((s->regs[index] &ENET_ECR_ETHEREN ) ==0 ) { s->regs[ENET_RDAR ] =0 ; s->rx_descriptor = s->regs[ENET_RDSR ]; - s->regs[ENET_TDAR ] =0 ; - s->tx_descriptor = s->regs[ENET_TDSR ]; + s->regs[ENET_TDAR ] =0 ; + s->regs[ENET_TDAR1 ] =0 ; + s->regs[ENET_TDAR2 ] =0 ; + s->tx_descriptor[0 ] = s->regs[ENET_TDSR ]; + s->tx_descriptor[1 ] = s->regs[ENET_TDSR1 ]; + s->tx_descriptor[2 ] = s->regs[ENET_TDSR2 ]; }break ;case ENET_MMFR :
@@ -907,7 +950,29 @@ static void imx_eth_write(void *opaque, hwaddr offset, uint64_t value, }else { s->regs[index] = value & ~7 ; } - s->tx_descriptor = s->regs[index]; + s->tx_descriptor[0 ] = s->regs[index]; +break ; +case ENET_TDSR1 : +if (unlikely (single_tx_ring)) { +qemu_log_mask (LOG_GUEST_ERROR , +"[%s]%s: trying to access TDSR1\n" , +TYPE_IMX_FEC , __func__); +return ; + } + + s->regs[index] = value & ~7 ; + s->tx_descriptor[1 ] = s->regs[index]; +break ; +case ENET_TDSR2 : +if (unlikely (single_tx_ring)) { +qemu_log_mask (LOG_GUEST_ERROR , +"[%s]%s: trying to access TDSR2\n" , +TYPE_IMX_FEC , __func__); +return ; + } + + s->regs[index] = value & ~7 ; + s->tx_descriptor[2 ] = s->regs[index];break ;case ENET_MRBR : s->regs[index] = value &0x00003ff0 ;
@@ -1203,6 +1268,7 @@ static void imx_eth_realize(DeviceState *dev, Error **errp)static Property imx_eth_properties[] = {DEFINE_NIC_PROPERTIES (IMXFECState, conf), +DEFINE_PROP_UINT32 ("tx-ring-num" , IMXFECState, tx_ring_num,1 ),DEFINE_PROP_END_OF_LIST (), };
include/hw/net/imx_fec.h +16 -2
@@ -52,6 +52,8 @@#define ENET_TFWR 81#define ENET_FRBR 83#define ENET_FRSR 84 +#define ENET_TDSR1 89 +#define ENET_TDSR2 92#define ENET_RDSR 96#define ENET_TDSR 97#define ENET_MRBR 98
@@ -66,6 +68,8 @@#define ENET_FTRL 108#define ENET_TACC 112#define ENET_RACC 113 +#define ENET_TDAR1 121 +#define ENET_TDAR2 123#define ENET_MIIGSK_CFGR 192#define ENET_MIIGSK_ENR 194#define ENET_ATCR 256
@@ -105,13 +109,18 @@#define ENET_INT_WAKEUP (1 << 17)#define ENET_INT_TS_AVAIL (1 << 16)#define ENET_INT_TS_TIMER (1 << 15) +#define ENET_INT_TXF2 (1 << 7) +#define ENET_INT_TXB2 (1 << 6) +#define ENET_INT_TXF1 (1 << 3) +#define ENET_INT_TXB1 (1 << 2)#define ENET_INT_MAC (ENET_INT_HB | ENET_INT_BABR | ENET_INT_BABT | \ ENET_INT_GRA | ENET_INT_TXF | ENET_INT_TXB | \ ENET_INT_RXF | ENET_INT_RXB | ENET_INT_MII | \ ENET_INT_EBERR | ENET_INT_LC | ENET_INT_RL | \ ENET_INT_UN | ENET_INT_PLR | ENET_INT_WAKEUP | \ - ENET_INT_TS_AVAIL) + ENET_INT_TS_AVAIL | ENET_INT_TXF1 | \ + ENET_INT_TXB1 | ENET_INT_TXF2 | ENET_INT_TXB2)/* RDAR */ #define ENET_RDAR_RDAR (1 << 24)
@@ -234,6 +243,9 @@ typedef struct {#define ENET_BD_BDU (1 << 31) +#define ENET_TX_RING_NUM 3 + + typedef struct IMXFECState { /*< private >*/ SysBusDevice parent_obj;
@@ -246,7 +258,9 @@ typedef struct IMXFECState {uint32_t regs[ENET_MAX ];uint32_t rx_descriptor; -uint32_t tx_descriptor; + +uint32_t tx_descriptor[ENET_TX_RING_NUM ]; +uint32_t tx_ring_num;uint32_t phy_status;uint32_t phy_control;
Signature · 1 line
2.13.6
Re: [Qemu-arm] [PATCH v3 07/30] imx_fec: Add support for multiple Tx DMA rings
Quoted 17 lines · Andrey Smirnov
More recent version of the IP block support more than one Tx DMA ring, so add the code implementing that feature.
Cc Peter Maydell <[email protected]>Cc Jason Wang <[email protected]>Cc Philippe Mathieu-Daudé <[email protected]>Signed-off-by Andrey Smirnov <[email protected]>static const VMStateDescription
vmstate_imx_eth= {
.name =TYPE_IMX_FEC,hw/net/imx_fec.c +2
-2- .version_id = 2, - .minimum_version_id = 2, + .version_id = 3, + .minimum_version_id = 3,
hw/net/imx_fec.c static const char *imx_eth_reg_name(IMXFECState *s, uint32_t index) · line 210
Quoted 10 lines
hw/net/imx_fec.c +2
-2.fields = (VMStateField[]) {VMSTATE_UINT32_ARRAY (regs, IMXFECState,ENET_MAX ),VMSTATE_UINT32 (rx_descriptor, IMXFECState), -VMSTATE_UINT32 (tx_descriptor, IMXFECState), - +VMSTATE_UINT32_ARRAY (tx_descriptor, IMXFECState,ENET_TX_RING_NUM ), +VMSTATE_UINT32 (tx_ring_num, IMXFECState),VMSTATE_UINT32 (phy_status, IMXFECState),VMSTATE_UINT32 (phy_control, IMXFECState),VMSTATE_UINT32 (phy_advertise, IMXFECState),
tx_ring_num is constant for any particular instantiation of the device, so you don't need to put it in the vmstate.
It's pretty trivial to make this vmstate compatible with the old ones for the existing single-tx-descriptor devices, so we might as well:
/* Versions of this device with more than one TX descriptor
* save the 2nd and 3rd descriptors in a subsection, to maintain
* migration compatibility with previous versions of the device
* that only supported a single descriptor.
*/
static bool txdescs_needed(void *opaque) {
IMXFECState *s = opaque;
return s->tx_ring_num > 1;
}static const VMStateDescription vmstate_imx_eth_txdescs = {
.name = "imx.fec/txdescs",
.version_id = 1,
.minimum_version_id = 1,
.needed = txdescs_needed,
.fields = (VMStateField[]) {
VMSTATE_UINT32(tx_descriptor[1], IMXFECState),
VMSTATE_UINT32(tx_descriptor[2], IMXFECState),
VMSTATE_END_OF_LIST()
}
};and then add this to the vmx_state_eth at the end:
.subsections = (const VMStateDescription*[]) {
&vmstate_imx_eth_txdescs,
NULL
}Then you don't need to bump version_id/minimum_version_id on the vmstate_imx_eth struct.
hw/net/imx_fec.c static void imx_eth_write(void *opaque, hwaddr offset, uint64_t value, · line 824
Quoted 5 lines
hw/net/imx_fec.c +1
-0@@ -791,6 +821,7 @@ static void imx_eth_write(void *opaque, hwaddr offset, uint64_t value, unsigned size) {IMXFECState *s =IMX_FEC (opaque); +const bool single_tx_ring = s->tx_ring_num !=3 ;
This looks odd -- I would have expected "single_tx_ring = s->tx_ring_num == 1" ...
Otherwise
thanks
-- PMM
Re: [Qemu-arm] [PATCH v3 07/30] imx_fec: Add support for multiple Tx DMA rings
Quoted 58 lines · Peter Maydell
Quoted 17 lines · Andrey Smirnov
More recent version of the IP block support more than one Tx DMA ring, so add the code implementing that feature.
Cc Peter Maydell <[email protected]>Cc Jason Wang <[email protected]>Cc Philippe Mathieu-Daudé <[email protected]>Signed-off-by Andrey Smirnov <[email protected]>static const VMStateDescription
vmstate_imx_eth= {
.name =TYPE_IMX_FEC,hw/net/imx_fec.c +2
-2- .version_id = 2, - .minimum_version_id = 2, + .version_id = 3, + .minimum_version_id = 3,hw/net/imx_fec.c static const char *imx_eth_reg_name(IMXFECState *s, uint32_t index) · line 210
Quoted 10 lines
hw/net/imx_fec.c +2
-2.fields = (VMStateField[]) {VMSTATE_UINT32_ARRAY (regs, IMXFECState,ENET_MAX ),VMSTATE_UINT32 (rx_descriptor, IMXFECState), -VMSTATE_UINT32 (tx_descriptor, IMXFECState), - +VMSTATE_UINT32_ARRAY (tx_descriptor, IMXFECState,ENET_TX_RING_NUM ), +VMSTATE_UINT32 (tx_ring_num, IMXFECState),VMSTATE_UINT32 (phy_status, IMXFECState),VMSTATE_UINT32 (phy_control, IMXFECState),VMSTATE_UINT32 (phy_advertise, IMXFECState),
tx_ring_numis constant for any particular instantiation of the device, so you don't need to put it in the vmstate.It's pretty trivial to make this vmstate compatible with the old ones for the existing single-tx-descriptor devices, so we might as well:
/* Versions of this device with more than one TX descriptor
* save the 2nd and 3rd descriptors in a subsection, to maintain
* migration compatibility with previous versions of the device
* that only supported a single descriptor.
*/static bool txdescs_needed(void *opaque) { IMXFECState *s = opaque; return s->tx_ring_num > 1; }static const VMStateDescription vmstate_imx_eth_txdescs = { .name = "imx.fec/txdescs", .version_id = 1, .minimum_version_id = 1, .needed = txdescs_needed, .fields = (VMStateField[]) { VMSTATE_UINT32(tx_descriptor[1], IMXFECState), VMSTATE_UINT32(tx_descriptor[2], IMXFECState), VMSTATE_END_OF_LIST() } };
Quoted 9 lines
and then add this to the
vmx_state_ethat the end:.subsections = (const VMStateDescription*[]) { &vmstate_imx_eth_txdescs, NULL }Then you don't need to bump version_id/minimum_version_id on the
vmstate_imx_ethstruct.
Cool, sounds good. Will add that to the patch in v4.
Quoted 8 lines
hw/net/imx_fec.c static void imx_eth_write(void *opaque, hwaddr offset, uint64_t value, · line 824
Quoted 5 lines
hw/net/imx_fec.c +1
-0@@ -791,6 +821,7 @@ static void imx_eth_write(void *opaque, hwaddr offset, uint64_t value, unsigned size) {IMXFECState *s =IMX_FEC (opaque); +const bool single_tx_ring = s->tx_ring_num !=3 ;This looks odd -- I would have expected "
single_tx_ring=s->tx_ring_num== 1" ...
AFAIK the HW that's out there will have either 3 or 1 Tx ring, so that's why I wrote it this way. I'll change the logic to the way your suggest to avoid surprising the reader.
Thanks,
Andrey Smirnov
PATCH v3 8/30 imx_fec: Use correct length for packet size
In reply to Andrey SmirnovUse 'frame_size' instead of 'len' when calling qemu_send_packet(), failing to do so results in malformed packets send in case when that packed is fragmented into multiple DMA transactions.
--- hw/net/imx_fec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
hw/net/imx_fec.c +1 -1
@@ -528,7 +528,7 @@ static void imx_enet_do_tx(IMXFECState *s, uint32_t index) } }/* Last buffer in frame. */ -qemu_send_packet (qemu_get_queue (s->nic), frame, len); +qemu_send_packet (qemu_get_queue (s->nic), frame, frame_size); ptr = frame; frame_size =0 ;if (bd.option &ENET_BD_TX_INT ) {
Signature · 1 line
2.13.6
PATCH v3 9/30 imx_fec: Fix a typo in imx_enet_receive()
In reply to Andrey Smirnov--- hw/net/imx_fec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
hw/net/imx_fec.c +1 -1
@@ -1121,7 +1121,7 @@ static ssize_t imx_enet_receive(NetClientState *nc, const uint8_t *buf, size +=2 ; } -/* Huge frames are truncted. */ +/* Huge frames are truncated. */ if (size > s->regs[ENET_FTRL ]) { size = s->regs[ENET_FTRL ]; flags |=ENET_BD_TR |ENET_BD_LG ;
Signature · 1 line
2.13.6
Re: [Qemu-devel] [PATCH v3 09/30] imx_fec: Fix a typo in imx_enet_receive()
Quoted 25 lines · Andrey Smirnov
Cc Peter Maydell <[email protected]>Cc Jason Wang <[email protected]>Cc Philippe Mathieu-Daudé <[email protected]>Signed-off-by Andrey Smirnov <[email protected]>--- hw/net/imx_fec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)hw/net/imx_fec.c +1
-2@@ -1121,7 +1121,7 @@ static ssize_t imx_enet_receive(NetClientState *nc, const uint8_t *buf, size +=2 ; } -/* Huge frames are truncted. */ +/* Huge frames are truncated. */ if (size > s->regs[ENET_FTRL ]) { size = s->regs[ENET_FTRL ]; flags |=ENET_BD_TR |ENET_BD_LG ; --
Quoted 2 lines
2.13.6
thanks
-- PMM
PATCH v3 10/30 imx_fec: Reserve full 4K page for the register file
In reply to Andrey SmirnovSome i.MX SoCs (e.g. i.MX7) have FEC registers going as far as offset 0x614, so to avoid getting aborts when accessing those on QEMU, extend the register file to cover 4KB of address space instead of just 1K.
--- hw/net/imx_fec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
hw/net/imx_fec.c +1 -1
@@ -1252,7 +1252,7 @@ static void imx_eth_realize(DeviceState *dev, Error **errp)SysBusDevice *sbd =SYS_BUS_DEVICE (dev);memory_region_init_io (&s->iomem,OBJECT (dev), &imx_eth_ops, s, -TYPE_IMX_FEC ,0x400 ); +TYPE_IMX_FEC ,0x1000 );sysbus_init_mmio (sbd, &s->iomem);sysbus_init_irq (sbd, &s->irq[0 ]);sysbus_init_irq (sbd, &s->irq[1 ]);
Signature · 1 line
2.13.6
Re: [Qemu-devel] [PATCH v3 10/30] imx_fec: Reserve full 4K page for the register file
Quoted 20 lines · Andrey Smirnov
Some i.MX SoCs (e.g. i.MX7) have FEC registers going as far as offset
0x614, so to avoid getting aborts when accessing those on QEMU, extend the register file to cover 4KB of address space instead of just 1K.Cc Peter Maydell <[email protected]>Cc Jason Wang <[email protected]>Cc Philippe Mathieu-Daudé <[email protected]>Signed-off-by Andrey Smirnov <[email protected]>--- hw/net/imx_fec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)hw/net/imx_fec.c +0
-0
hw/net/imx_fec.c static void imx_eth_realize(DeviceState *dev, Error **errp)
Quoted 9 lines
hw/net/imx_fec.c +1
-2@@ -1252,7 +1252,7 @@ static void imx_eth_realize(DeviceState *dev, Error **errp)SysBusDevice *sbd =SYS_BUS_DEVICE (dev);memory_region_init_io (&s->iomem,OBJECT (dev), &imx_eth_ops, s, -TYPE_IMX_FEC ,0x400 ); +TYPE_IMX_FEC ,0x1000 );sysbus_init_mmio (sbd, &s->iomem);sysbus_init_irq (sbd, &s->irq[0 ]);sysbus_init_irq (sbd, &s->irq[1 ]); --
I notice that we have an unused #define FSL_IMX25_FEC_SIZE 0x4000 in fsl-imx25.h, and the Linux device trees for the imx25 define the size of the FEC register block as 0x4000. Should this be 0x4000 ?
thanks
-- PMM
Re: [Qemu-arm] [PATCH v3 10/30] imx_fec: Reserve full 4K page for the register file
Quoted 23 lines · Peter Maydell
Quoted 22 lines · Andrey Smirnov
Some i.MX SoCs (e.g. i.MX7) have FEC registers going as far as offset
0x614, so to avoid getting aborts when accessing those on QEMU, extend the register file to cover 4KB of address space instead of just 1K.Cc Peter Maydell <[email protected]>Cc Jason Wang <[email protected]>Cc Philippe Mathieu-Daudé <[email protected]>Signed-off-by Andrey Smirnov <[email protected]>--- hw/net/imx_fec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)hw/net/imx_fec.c +0
-0@@ -1252,7 +1252,7 @@ static void imx_eth_realize(DeviceState *dev, Error **errp)SysBusDevice *sbd =SYS_BUS_DEVICE (dev);
Quoted 12 lines
hw/net/imx_fec.c static void imx_eth_realize(DeviceState *dev, Error **errp)
Quoted 7 lines
hw/net/imx_fec.c +1
-2memory_region_init_io (&s->iomem,OBJECT (dev), &imx_eth_ops, s, -TYPE_IMX_FEC ,0x400 ); +TYPE_IMX_FEC ,0x1000 );sysbus_init_mmio (sbd, &s->iomem);sysbus_init_irq (sbd, &s->irq[0 ]);sysbus_init_irq (sbd, &s->irq[1 ]); --I notice that we have an unused #define
FSL_IMX25_FEC_SIZE0x4000infsl-imx25.h, and the Linux device trees for the imx25 define the size of the FEC register block as0x4000. Should this be0x4000?
I think the size reserved for that register file differs between differen SoC. E.g. it's 16K on i.MX25, as you pointed out, but 64K on i.MX7. It's all the same to me as long as it's greater than 0x1000. I'll change the code to use FSL_IMX25_FEC_SIZE since it gets rid of a magic number.
Thanks,
Andrey Smirnov
PATCH v3 11/30 sdhci: Add i.MX specific subtype of SDHCI
In reply to Andrey SmirnovIP block found on several generations of i.MX family does not use vanilla SDHCI implementation and it comes with a number of quirks.
Introduce i.MX SDHCI subtype of SDHCI block to add code necessary to support unmodified Linux guest driver.
--- hw/sd/sdhci-internal.h | 15 ++++++ hw/sd/sdhci.c | 127 ++++++++++++++++++++++++++++++++++++++++++++++++- include/hw/sd/sdhci.h | 8 ++++ 3 files changed, 148 insertions(+), 2 deletions(-)
hw/sd/sdhci-internal.h +15 -0
@@ -91,6 +91,8 @@#define SDHC_CTRL_ADMA2_32 0x10#define SDHC_CTRL_ADMA2_64 0x18#define SDHC_DMA_TYPE (x) ((x) & SDHC_CTRL_DMA_CHECK_MASK) +#define SDHC_CTRL_4BITBUS 0x02 +#define SDHC_CTRL_8BITBUS 0x20/* R/W Power Control Register 0x0 */ #define SDHC_PWRCON 0x29
@@ -229,4 +231,17 @@ enum {extern const VMStateDescription sdhci_vmstate; + +#define ESDHC_MIX_CTRL 0x48 +#define ESDHC_VENDOR_SPEC 0xc0 +#define ESDHC_DLL_CTRL 0x60 + +#define ESDHC_TUNING_CTRL 0xcc +#define ESDHC_TUNE_CTRL_STATUS 0x68 +#define ESDHC_WTMK_LVL 0x44 + +#define ESDHC_CTRL_4BITBUS (0x1 << 1) +#define ESDHC_CTRL_8BITBUS (0x2 << 1) + +#endif
hw/sd/sdhci.c +125 -2
156 lines not on this page · raw message
include/hw/sd/sdhci.h +8 -0
@@ -39,6 +39,7 @@ typedef struct SDHCIState { };SDBus sdbus;MemoryRegion iomem; +const MemoryRegionOps *io_ops;QEMUTimer *insert_timer;/* timer for 'changing' sd card. */ QEMUTimer *transfer_timer;
@@ -83,8 +84,13 @@ typedef struct SDHCIState {/* Force Event Auto CMD12 Error Interrupt Reg - write only */ /* Force Event Error Interrupt Register- write only */ /* RO Host Controller Version Register always reads as 0x2401 */ + +unsigned long quirks; } SDHCIState; +/* Controller does not provide transfer-complete interrupt when not busy */ +#define SDHCI_QUIRK_NO_BUSY_IRQ BIT(14) +#define TYPE_PCI_SDHCI "sdhci-pci"#define PCI_SDHCI (obj) OBJECT_CHECK(SDHCIState, (obj), TYPE_PCI_SDHCI)
@@ -92,4 +98,6 @@ typedef struct SDHCIState {#define SYSBUS_SDHCI (obj) \ OBJECT_CHECK(SDHCIState, (obj), TYPE_SYSBUS_SDHCI) +#define TYPE_IMX_USDHC "imx-usdhc" +#endif /* SDHCI_H */
Signature · 1 line
2.13.6
Re: [Qemu-devel] [PATCH v3 11/30] sdhci: Add i.MX specific subtype of SDHCI
Quoted 6 lines · Andrey Smirnov
IP block found on several generations of i.MX family does not use vanilla SDHCI implementation and it comes with a number of quirks.
Introduce i.MX SDHCI subtype of SDHCI block to add code necessary to support unmodified Linux guest driver.
Quoted 7 lines
Cc Peter Maydell <[email protected]>Cc Jason Wang <[email protected]>Cc Philippe Mathieu-Daudé <[email protected]>Signed-off-by Andrey Smirnov <[email protected]>
Hi. Mostly this looks ok; some comments below.
Quoted 136 lines
--- hw/sd/sdhci-internal.h | 15 ++++++ hw/sd/sdhci.c | 127 ++++++++++++++++++++++++++++++++++++++++++++++++- include/hw/sd/sdhci.h | 8 ++++ 3 files changed, 148 insertions(+), 2 deletions(-)hw/sd/sdhci-internal.h +15
-0@@ -91,6 +91,8 @@#define SDHC_CTRL_ADMA2_32 0x10#define SDHC_CTRL_ADMA2_64 0x18#define SDHC_DMA_TYPE (x) ((x) & SDHC_CTRL_DMA_CHECK_MASK) +#define SDHC_CTRL_4BITBUS 0x02 +#define SDHC_CTRL_8BITBUS 0x20/* R/W Power Control Register 0x0 */ #define SDHC_PWRCON 0x29@@ -229,4 +231,17 @@ enum {extern const VMStateDescription sdhci_vmstate; + +#define ESDHC_MIX_CTRL 0x48 +#define ESDHC_VENDOR_SPEC 0xc0 +#define ESDHC_DLL_CTRL 0x60 + +#define ESDHC_TUNING_CTRL 0xcc +#define ESDHC_TUNE_CTRL_STATUS 0x68 +#define ESDHC_WTMK_LVL 0x44 + +#define ESDHC_CTRL_4BITBUS (0x1 << 1) +#define ESDHC_CTRL_8BITBUS (0x2 << 1) + +#endif hw/sd/sdhci.c +68
-2@@ -265,7 +265,8 @@ static void sdhci_send_command(SDHCIState *s) } } -if ((s->norintstsen &SDHC_NISEN_TRSCMP ) && +if (!(s->quirks &SDHCI_QUIRK_NO_BUSY_IRQ ) && + (s->norintstsen &SDHC_NISEN_TRSCMP ) && (s->cmdreg &SDHC_CMD_RESPONSE ) ==SDHC_CMD_RSP_WITH_BUSY ) { s->norintsts |=SDHC_NIS_TRSCMP ; }@@ -1191,6 +1192,8 @@ static void sdhci_initfn(SDHCIState *s) s->insert_timer =timer_new_ns (QEMU_CLOCK_VIRTUAL , sdhci_raise_insertion_irq, s); s->transfer_timer =timer_new_ns (QEMU_CLOCK_VIRTUAL , sdhci_data_transfer, s); + + s->io_ops = &sdhci_mmio_ops; }static void sdhci_uninitfn (SDHCIState *s)@@ -1347,7 +1350,7 @@ static void sdhci_sysbus_realize(DeviceState *dev, Error ** errp) s->buf_maxsz =sdhci_get_fifolen (s); s->fifo_buffer =g_malloc0 (s->buf_maxsz);sysbus_init_irq (sbd, &s->irq); -memory_region_init_io (&s->iomem,OBJECT (s), &sdhci_mmio_ops, s,"sdhci" , +memory_region_init_io (&s->iomem,OBJECT (s), s->io_ops, s,"sdhci" ,SDHC_REGISTERS_MAP_SIZE );sysbus_init_mmio (sbd, &s->iomem); }@@ -1386,11 +1389,131 @@ static const TypeInfo sdhci_bus_info = { .class_init = sdhci_bus_class_init, }; +static uint64_t usdhc_read (void *opaque,hwaddr offset,unsigned size) +{ +SDHCIState *s =SYSBUS_SDHCI (opaque); +uint32_t ret; +uint16_t hostctl; + +switch (offset) { +default : +return sdhci_read (opaque, offset, size); + +case SDHC_HOSTCTL : + hostctl =SDHC_DMA_TYPE (s->hostctl) <<5 ; + +if (s->hostctl &SDHC_CTRL_8BITBUS ) { + hostctl |=ESDHC_CTRL_8BITBUS ; + } + +if (s->hostctl &SDHC_CTRL_4BITBUS ) { + hostctl |=ESDHC_CTRL_4BITBUS ; + } + + ret = hostctl | (s->blkgap <<16 ) | + (s->wakcon <<24 ); + +break ; + +case ESDHC_DLL_CTRL : +case ESDHC_TUNE_CTRL_STATUS : +case 0x6c : +case ESDHC_TUNING_CTRL : +case ESDHC_VENDOR_SPEC : +case ESDHC_MIX_CTRL : +case ESDHC_WTMK_LVL : + ret =0 ; +break ; + } + +return ret; +} + +static void +usdhc_write (void *opaque,hwaddr offset,uint64_t val,unsigned size) +{ +SDHCIState *s =SYSBUS_SDHCI (opaque); +uint8_t hostctl =0 ; +uint32_t value = (uint32_t )val; + +switch (offset) { +case ESDHC_DLL_CTRL : +case ESDHC_TUNE_CTRL_STATUS : +case 0x6c : +case ESDHC_TUNING_CTRL : +case ESDHC_WTMK_LVL : +case ESDHC_VENDOR_SPEC : +break ; + +case SDHC_HOSTCTL : +if (value &ESDHC_CTRL_8BITBUS ) { + hostctl |=SDHC_CTRL_8BITBUS ; + } + +if (value &ESDHC_CTRL_4BITBUS ) { + hostctl |=ESDHC_CTRL_4BITBUS ;
hw/sd/sdhci.c static const TypeInfo sdhci_bus_info = { · line 1464
Quoted 10 lines
hw/sd/sdhci.c +10
-0+ } + + hostctl |=SDHC_DMA_TYPE (value >>5 ); + + value &= ~0xFE ; + value |= hostctl; + value &= ~0xFF00 ; + value |= s->pwrcon; + +sdhci_write (opaque, offset, value, size);
This is pretty confusing, because we both mess about directly with the pwrcon field and also pass the write through to sdhci_write(). (a) some comments would help and (b) would it be clearer to just implement the different SDHC_HOSTCTL behaviour entirely here rather than trying to reuse the code in sdhci_write()? I get the impression that at least some of this is trying to shuffle stuff around so that code can unshuffle it.
hw/sd/sdhci.c static const TypeInfo sdhci_bus_info = { · line 1475
Quoted 11 lines
hw/sd/sdhci.c +11
-0+break ; + +case ESDHC_MIX_CTRL : +/* +* The layout of the register is slightly different, but we +* don't care about those bits +*/ + s->trnmod = value &0xFFFF ; +break ; +case SDHC_TRNMOD : +sdhci_write (opaque, offset, val | s->trnmod, size);
This one's simpler, but a comment would assist.
Quoted 57 lines
hw/sd/sdhci.c +36
-0+break ; +case SDHC_BLKSIZE : + val |=0x7 <<12 ; +default :/* FALLTHROUGH */ +sdhci_write (opaque, offset, val, size); +break ; + } +} + + +static const MemoryRegionOps usdhc_mmio_ops = { + .read = usdhc_read, + .write = usdhc_write, + .valid = { + .min_access_size =1 , + .max_access_size =4 , + .unaligned = false + }, + .endianness =DEVICE_LITTLE_ENDIAN , +}; + +static void imx_usdhc_init (Object *obj) +{ +SDHCIState *s =SYSBUS_SDHCI (obj); + + s->io_ops = &usdhc_mmio_ops; + s->quirks =SDHCI_QUIRK_NO_BUSY_IRQ ; +} + +static const TypeInfo imx_usdhc_info = { + .name =TYPE_IMX_USDHC , + .parent =TYPE_SYSBUS_SDHCI , + .instance_init = imx_usdhc_init, +}; +static void sdhci_register_types (void ) {type_register_static (&sdhci_pci_info);type_register_static (&sdhci_sysbus_info);type_register_static (&sdhci_bus_info); +type_register_static (&imx_usdhc_info); }type_init (sdhci_register_types)include/hw/sd/sdhci.h +1
-0@@ -39,6 +39,7 @@ typedef struct SDHCIState { };SDBus sdbus;MemoryRegion iomem; +const MemoryRegionOps *io_ops;QEMUTimer *insert_timer;/* timer for 'changing' sd card. */ QEMUTimer *transfer_timer;
include/hw/sd/sdhci.h typedef struct SDHCIState { · line 88
Quoted 5 lines
include/hw/sd/sdhci.h +2
-0@@ -83,8 +84,13 @@ typedef struct SDHCIState {/* Force Event Auto CMD12 Error Interrupt Reg - write only */ /* Force Event Error Interrupt Register- write only */ /* RO Host Controller Version Register always reads as 0x2401 */ + +unsigned long quirks;
Don't use 'unsigned long', it differs in size from host to host.
include/hw/sd/sdhci.h typedef struct SDHCIState { · line 92
Quoted 4 lines
include/hw/sd/sdhci.h +2
-0} SDHCIState; +/* Controller does not provide transfer-complete interrupt when not busy */ +#define SDHCI_QUIRK_NO_BUSY_IRQ BIT(14)
We only have one quirk, so why is it bit 14?
Quoted 12 lines
include/hw/sd/sdhci.h +3
-1+#define TYPE_PCI_SDHCI "sdhci-pci"#define PCI_SDHCI (obj) OBJECT_CHECK(SDHCIState, (obj), TYPE_PCI_SDHCI)@@ -92,4 +98,6 @@ typedef struct SDHCIState {#define SYSBUS_SDHCI (obj) \ OBJECT_CHECK(SDHCIState, (obj), TYPE_SYSBUS_SDHCI) +#define TYPE_IMX_USDHC "imx-usdhc" +#endif /* SDHCI_H */ --
Quoted 1 line
2.13.6
thanks
-- PMM
Re: [Qemu-arm] [PATCH v3 11/30] sdhci: Add i.MX specific subtype of SDHCI
Quoted 159 lines · Peter Maydell
Quoted 6 lines · Andrey Smirnov
IP block found on several generations of i.MX family does not use vanilla SDHCI implementation and it comes with a number of quirks.
Introduce i.MX SDHCI subtype of SDHCI block to add code necessary to support unmodified Linux guest driver.
Quoted 7 lines
Cc Peter Maydell <[email protected]>Cc Jason Wang <[email protected]>Cc Philippe Mathieu-Daudé <[email protected]>Signed-off-by Andrey Smirnov <[email protected]>Hi. Mostly this looks ok; some comments below.
Quoted 142 lines
--- hw/sd/sdhci-internal.h | 15 ++++++ hw/sd/sdhci.c | 127 ++++++++++++++++++++++++++++++++++++++++++++++++- include/hw/sd/sdhci.h | 8 ++++ 3 files changed, 148 insertions(+), 2 deletions(-)hw/sd/sdhci-internal.h +15
-0@@ -91,6 +91,8 @@#define SDHC_CTRL_ADMA2_32 0x10#define SDHC_CTRL_ADMA2_64 0x18#define SDHC_DMA_TYPE (x) ((x) & SDHC_CTRL_DMA_CHECK_MASK) +#define SDHC_CTRL_4BITBUS 0x02 +#define SDHC_CTRL_8BITBUS 0x20/* R/W Power Control Register 0x0 */ #define SDHC_PWRCON 0x29@@ -229,4 +231,17 @@ enum {extern const VMStateDescription sdhci_vmstate; + +#define ESDHC_MIX_CTRL 0x48 +#define ESDHC_VENDOR_SPEC 0xc0 +#define ESDHC_DLL_CTRL 0x60 + +#define ESDHC_TUNING_CTRL 0xcc +#define ESDHC_TUNE_CTRL_STATUS 0x68 +#define ESDHC_WTMK_LVL 0x44 + +#define ESDHC_CTRL_4BITBUS (0x1 << 1) +#define ESDHC_CTRL_8BITBUS (0x2 << 1) + +#endif hw/sd/sdhci.c +74
-2@@ -265,7 +265,8 @@ static void sdhci_send_command(SDHCIState *s) } } -if ((s->norintstsen &SDHC_NISEN_TRSCMP ) && +if (!(s->quirks &SDHCI_QUIRK_NO_BUSY_IRQ ) && + (s->norintstsen &SDHC_NISEN_TRSCMP ) && (s->cmdreg &SDHC_CMD_RESPONSE ) ==SDHC_CMD_RSP_WITH_BUSY ) { s->norintsts |=SDHC_NIS_TRSCMP ; }@@ -1191,6 +1192,8 @@ static void sdhci_initfn(SDHCIState *s) s->insert_timer =timer_new_ns (QEMU_CLOCK_VIRTUAL , sdhci_raise_insertion_irq, s); s->transfer_timer =timer_new_ns (QEMU_CLOCK_VIRTUAL , sdhci_data_transfer, s); + + s->io_ops = &sdhci_mmio_ops; }static void sdhci_uninitfn (SDHCIState *s)@@ -1347,7 +1350,7 @@ static void sdhci_sysbus_realize(DeviceState *dev, Error ** errp) s->buf_maxsz =sdhci_get_fifolen (s); s->fifo_buffer =g_malloc0 (s->buf_maxsz);sysbus_init_irq (sbd, &s->irq); -memory_region_init_io (&s->iomem,OBJECT (s), &sdhci_mmio_ops, s,"sdhci" , +memory_region_init_io (&s->iomem,OBJECT (s), s->io_ops, s,"sdhci" ,SDHC_REGISTERS_MAP_SIZE );sysbus_init_mmio (sbd, &s->iomem); }@@ -1386,11 +1389,131 @@ static const TypeInfo sdhci_bus_info = { .class_init = sdhci_bus_class_init, }; +static uint64_t usdhc_read (void *opaque,hwaddr offset,unsigned size) +{ +SDHCIState *s =SYSBUS_SDHCI (opaque); +uint32_t ret; +uint16_t hostctl; + +switch (offset) { +default : +return sdhci_read (opaque, offset, size); + +case SDHC_HOSTCTL : + hostctl =SDHC_DMA_TYPE (s->hostctl) <<5 ; + +if (s->hostctl &SDHC_CTRL_8BITBUS ) { + hostctl |=ESDHC_CTRL_8BITBUS ; + } + +if (s->hostctl &SDHC_CTRL_4BITBUS ) { + hostctl |=ESDHC_CTRL_4BITBUS ; + } + + ret = hostctl | (s->blkgap <<16 ) | + (s->wakcon <<24 ); + +break ; + +case ESDHC_DLL_CTRL : +case ESDHC_TUNE_CTRL_STATUS : +case 0x6c : +case ESDHC_TUNING_CTRL : +case ESDHC_VENDOR_SPEC : +case ESDHC_MIX_CTRL : +case ESDHC_WTMK_LVL : + ret =0 ; +break ; + } + +return ret; +} + +static void +usdhc_write (void *opaque,hwaddr offset,uint64_t val,unsigned size) +{ +SDHCIState *s =SYSBUS_SDHCI (opaque); +uint8_t hostctl =0 ; +uint32_t value = (uint32_t )val; + +switch (offset) { +case ESDHC_DLL_CTRL : +case ESDHC_TUNE_CTRL_STATUS : +case 0x6c : +case ESDHC_TUNING_CTRL : +case ESDHC_WTMK_LVL : +case ESDHC_VENDOR_SPEC : +break ; + +case SDHC_HOSTCTL : +if (value &ESDHC_CTRL_8BITBUS ) { + hostctl |=SDHC_CTRL_8BITBUS ; + } + +if (value &ESDHC_CTRL_4BITBUS ) { + hostctl |=ESDHC_CTRL_4BITBUS ; + } + + hostctl |=SDHC_DMA_TYPE (value >>5 ); + + value &= ~0xFE ; + value |= hostctl;
Quoted 8 lines
hw/sd/sdhci.c static const TypeInfo sdhci_bus_info = { · line 1464
Quoted 4 lines
hw/sd/sdhci.c +4
-0+ value &= ~0xFF00 ; + value |= s->pwrcon; + +sdhci_write (opaque, offset, value, size);This is pretty confusing, because we both mess about directly with the pwrcon field and also pass the write through to
sdhci_write(). (a) some comments would help and
Sure, will do.
Quoted 6 lines
(b) would it be clearer to just implement the different
SDHC_HOSTCTLbehaviour entirely here rather than trying to reuse the code insdhci_write()? I get the impression that at least some of this is trying to shuffle stuff around so that code can unshuffle it.
Main reason I did this is because those bit transformations are the inverse (or at least should be) of what Linux driver does in its "SDHCI -> ESDHC" conversion code.
Quoted 12 lines
hw/sd/sdhci.c static const TypeInfo sdhci_bus_info = { · line 1475
Quoted 11 lines
hw/sd/sdhci.c +11
-0+break ; + +case ESDHC_MIX_CTRL : +/* +* The layout of the register is slightly different, but we +* don't care about those bits +*/ + s->trnmod = value &0xFFFF ; +break ; +case SDHC_TRNMOD : +sdhci_write (opaque, offset, val | s->trnmod, size);
Quoted 2 lines
This one's simpler, but a comment would assist.
OK, will add.
Quoted 54 lines
Quoted 54 lines
hw/sd/sdhci.c +36
-0+break ; +case SDHC_BLKSIZE : + val |=0x7 <<12 ; +default :/* FALLTHROUGH */ +sdhci_write (opaque, offset, val, size); +break ; + } +} + + +static const MemoryRegionOps usdhc_mmio_ops = { + .read = usdhc_read, + .write = usdhc_write, + .valid = { + .min_access_size =1 , + .max_access_size =4 , + .unaligned = false + }, + .endianness =DEVICE_LITTLE_ENDIAN , +}; + +static void imx_usdhc_init (Object *obj) +{ +SDHCIState *s =SYSBUS_SDHCI (obj); + + s->io_ops = &usdhc_mmio_ops; + s->quirks =SDHCI_QUIRK_NO_BUSY_IRQ ; +} + +static const TypeInfo imx_usdhc_info = { + .name =TYPE_IMX_USDHC , + .parent =TYPE_SYSBUS_SDHCI , + .instance_init = imx_usdhc_init, +}; +static void sdhci_register_types (void ) {type_register_static (&sdhci_pci_info);type_register_static (&sdhci_sysbus_info);type_register_static (&sdhci_bus_info); +type_register_static (&imx_usdhc_info); }type_init (sdhci_register_types)include/hw/sd/sdhci.h +1
-0@@ -39,6 +39,7 @@ typedef struct SDHCIState { };SDBus sdbus;MemoryRegion iomem; +const MemoryRegionOps *io_ops;
Quoted 11 lines
include/hw/sd/sdhci.h typedef struct SDHCIState { · line 88
Quoted 8 lines
include/hw/sd/sdhci.h +2
-0QEMUTimer *insert_timer;/* timer for 'changing' sd card. */ QEMUTimer *transfer_timer;@@ -83,8 +84,13 @@ typedef struct SDHCIState {/* Force Event Auto CMD12 Error Interrupt Reg - write only */ /* Force Event Error Interrupt Register- write only */ /* RO Host Controller Version Register always reads as 0x2401 */ + +unsigned long quirks;Don't use 'unsigned long', it differs in size from host to host.
OK, sure.
Quoted 7 lines
include/hw/sd/sdhci.h typedef struct SDHCIState { · line 92
Quoted 4 lines
include/hw/sd/sdhci.h +2
-0} SDHCIState; +/* Controller does not provide transfer-complete interrupt when not busy */ +#define SDHCI_QUIRK_NO_BUSY_IRQ BIT(14)We only have one quirk, so why is it bit 14?
I took that code from Linux kernel, so I tried to keep it as is (same with unsigned long in quirks field).
Thanks,
Andrey Smirnov
Re: [Qemu-arm] [PATCH v3 11/30] sdhci: Add i.MX specific subtype of SDHCI
Quoted 11 lines · Andrey Smirnov
Quoted 6 lines · Peter Maydell
include/hw/sd/sdhci.h typedef struct SDHCIState { · line 92
Quoted 2 lines · Andrey Smirnov
include/hw/sd/sdhci.h +2
-0+/* Controller does not provide transfer-complete interrupt when not busy */ +#define SDHCI_QUIRK_NO_BUSY_IRQ BIT(14)We only have one quirk, so why is it bit 14?
I took that code from Linux kernel, so I tried to keep it as is (same with unsigned long in quirks field).
That's fine, but if so we should have a comment that that's what we're doing, so that subsequent additions by other contributors follow the same convention.
thanks
-- PMM
PATCH v3 12/30 sdhci: Implement write method of ACMD12ERRSTS register
In reply to Andrey Smirnov--- hw/sd/sdhci.c | 3 +++ 1 file changed, 3 insertions(+)
hw/sd/sdhci.c +3 -0
@@ -1139,6 +1139,9 @@ sdhci_write(void *opaque, hwaddr offset, uint64_t val, unsigned size) s->admasysaddr = (s->admasysaddr & (0x00000000FFFFFFFFULL | ((uint64_t )mask <<32 ))) | ((uint64_t )value <<32 );break ; +case SDHC_ACMD12ERRSTS : +MASKED_WRITE (s->acmd12errsts, mask, value); +break ;case SDHC_FEAER : s->acmd12errsts |= value; s->errintsts |= (value >>16 ) & s->errintstsen;
Signature · 1 line
2.13.6
Re: [Qemu-arm] [PATCH v3 12/30] sdhci: Implement write method of ACMD12ERRSTS register
Quoted 26 lines · Andrey Smirnov
Cc Peter Maydell <[email protected]>Cc Jason Wang <[email protected]>Cc Philippe Mathieu-Daudé <[email protected]>Signed-off-by Andrey Smirnov <[email protected]>--- hw/sd/sdhci.c | 3 +++ 1 file changed, 3 insertions(+)hw/sd/sdhci.c +3
-1@@ -1139,6 +1139,9 @@ sdhci_write(void *opaque, hwaddr offset, uint64_t val, unsigned size) s->admasysaddr = (s->admasysaddr & (0x00000000FFFFFFFFULL | ((uint64_t )mask <<32 ))) | ((uint64_t )value <<32 );break ; +case SDHC_ACMD12ERRSTS : +MASKED_WRITE (s->acmd12errsts, mask, value); +break ;case SDHC_FEAER : s->acmd12errsts |= value; s->errintsts |= (value >>16 ) & s->errintstsen; --
Quoted 1 line
2.13.6
Is this part of the stock SDHCI spec that we just forgot to implement? Assuming it is,
thanks
-- PMM
Re: [Qemu-arm] [PATCH v3 12/30] sdhci: Implement write method of ACMD12ERRSTS register
Quoted 22 lines · Peter Maydell
Quoted 21 lines · Andrey Smirnov
Cc Peter Maydell <[email protected]>Cc Jason Wang <[email protected]>Cc Philippe Mathieu-Daudé <[email protected]>Signed-off-by Andrey Smirnov <[email protected]>--- hw/sd/sdhci.c | 3 +++ 1 file changed, 3 insertions(+)hw/sd/sdhci.c +2
-0@@ -1139,6 +1139,9 @@ sdhci_write(void *opaque, hwaddr offset, uint64_t val, unsigned size) s->admasysaddr = (s->admasysaddr & (0x00000000FFFFFFFFULL | ((uint64_t )mask <<32 ))) | ((uint64_t )value <<32 );break ; +case SDHC_ACMD12ERRSTS : +MASKED_WRITE (s->acmd12errsts, mask, value);
Quoted 8 lines
Quoted 6 lines
hw/sd/sdhci.c +1
-1+break ;case SDHC_FEAER : s->acmd12errsts |= value; s->errintsts |= (value >>16 ) & s->errintstsen; --2.13.6
Is this part of the stock SDHCI spec that we just forgot to implement?
Yes it is. I don't know if missing that code critical for anything, but since the rest of the plumbing is there I thought that we may as well implement it.
Thanks,
Andrey Smirnov
PATCH v3 13/30 i.MX: Add code to emulate i.MX7 CCM, PMU and ANALOG IP blocks
In reply to Andrey SmirnovAdd minimal code needed to allow upstream Linux guest to boot.
--- hw/misc/Makefile.objs | 1 + hw/misc/imx7_ccm.c | 233 +++++++++++++++++++++++++++++++++++++++++++++ include/hw/misc/imx7_ccm.h | 130 +++++++++++++++++++++++++ 3 files changed, 364 insertions(+) create mode 100644 hw/misc/imx7_ccm.c create mode 100644 include/hw/misc/imx7_ccm.h
hw/misc/Makefile.objs +1 -0
@@ -34,6 +34,7 @@ obj-$(CONFIG_IMX) += imx31_ccm.o obj-$(CONFIG_IMX) += imx25_ccm.o obj-$(CONFIG_IMX) += imx6_ccm.o obj-$(CONFIG_IMX) += imx6_src.o +obj-$(CONFIG_IMX) += imx7_ccm.o obj-$(CONFIG_MILKYMIST) += milkymist-hpdmc.o obj-$(CONFIG_MILKYMIST) += milkymist-pfpu.o obj-$(CONFIG_MAINSTONE) += mst_fpga.o
hw/misc/imx7_ccm.c new file +233 -0
233 lines not on this page · raw message
include/hw/misc/imx7_ccm.h new file +130 -0
130 lines not on this page · raw message
Signature · 1 line
2.13.6
Re: [Qemu-arm] [PATCH v3 13/30] i.MX: Add code to emulate i.MX7 CCM, PMU and ANALOG IP blocks
Quoted 35 lines · Andrey Smirnov
Add minimal code needed to allow upstream Linux guest to boot.
Cc Peter Maydell <[email protected]>Cc Jason Wang <[email protected]>Cc Philippe Mathieu-Daudé <[email protected]>Signed-off-by Andrey Smirnov <[email protected]>--- hw/misc/Makefile.objs | 1 + hw/misc/imx7_ccm.c | 233 +++++++++++++++++++++++++++++++++++++++++++++ include/hw/misc/imx7_ccm.h | 130 +++++++++++++++++++++++++ 3 files changed, 364 insertions(+) create mode 100644 hw/misc/imx7_ccm.c create mode 100644 include/hw/misc/imx7_ccm.hhw/misc/Makefile.objs +1
-0@@ -34,6 +34,7 @@ obj-$(CONFIG_IMX) += imx31_ccm.o obj-$(CONFIG_IMX) += imx25_ccm.o obj-$(CONFIG_IMX) += imx6_ccm.o obj-$(CONFIG_IMX) += imx6_src.o +obj-$(CONFIG_IMX) += imx7_ccm.o obj-$(CONFIG_MILKYMIST) += milkymist-hpdmc.o obj-$(CONFIG_MILKYMIST) += milkymist-pfpu.o obj-$(CONFIG_MAINSTONE) += mst_fpga.ohw/misc/imx7_ccm.c new file +0
-0
hw/misc/imx7_ccm.c line 4
Quoted 4 lines
hw/misc/imx7_ccm.c new file +4
-0@@ -0,0 +1,233 @@ +/* +* Copyright (c) 2017, Impinj, Inc. +* +* i.MX7 CCM, PMU and ANALOG IP blocks emulation code
Should these really all be in one single device rather than one device per IP block ?
thanks
-- PMM
Re: [Qemu-arm] [PATCH v3 13/30] i.MX: Add code to emulate i.MX7 CCM, PMU and ANALOG IP blocks
Quoted 35 lines · Peter Maydell
Quoted 34 lines · Andrey Smirnov
Add minimal code needed to allow upstream Linux guest to boot.
Cc Peter Maydell <[email protected]>Cc Jason Wang <[email protected]>Cc Philippe Mathieu-Daudé <[email protected]>Signed-off-by Andrey Smirnov <[email protected]>--- hw/misc/Makefile.objs | 1 + hw/misc/imx7_ccm.c | 233 +++++++++++++++++++++++++++++++++++++++++++++ include/hw/misc/imx7_ccm.h | 130 +++++++++++++++++++++++++ 3 files changed, 364 insertions(+) create mode 100644 hw/misc/imx7_ccm.c create mode 100644 include/hw/misc/imx7_ccm.hhw/misc/Makefile.objs +1
-0@@ -34,6 +34,7 @@ obj-$(CONFIG_IMX) += imx31_ccm.o obj-$(CONFIG_IMX) += imx25_ccm.o obj-$(CONFIG_IMX) += imx6_ccm.o obj-$(CONFIG_IMX) += imx6_src.o +obj-$(CONFIG_IMX) += imx7_ccm.o obj-$(CONFIG_MILKYMIST) += milkymist-hpdmc.o obj-$(CONFIG_MILKYMIST) += milkymist-pfpu.o obj-$(CONFIG_MAINSTONE) += mst_fpga.ohw/misc/imx7_ccm.c new file +0
-0
Quoted 9 lines
hw/misc/imx7_ccm.c line 4
Quoted 5 lines
hw/misc/imx7_ccm.c new file +4
-0@@ -0,0 +1,233 @@ +/* +* Copyright (c) 2017, Impinj, Inc. +* +* i.MX7 CCM, PMU and ANALOG IP blocks emulation code Should these really all be in one single device rather than one device per IP block ?
They all share the same register write semantics, imx7_set_clr_tog_write, so I'd like to keep them in the same file. But other than that, they can be split into all sorts of configurations. As far as memory map in i.MX7 RM is concerned "CCM" and "Analog" are distinct register files where the rest of them ("digiprog", "pmu") are "sub-blocks" of those two (or at least that's my interpretation). I'll change v4 to have that split.
If you want me to convert every block _and_ sub-block into a standalone device, let me know.
Thanks,
Andrey Smirnov
PATCH v3 14/30 i.MX: Add code to emulate i.MX2 watchdog IP block
In reply to Andrey SmirnovAdd enough code to emulate i.MX2 watchdog IP block so it would be possible to reboot the machine running Linux Guest.
--- hw/misc/Makefile.objs | 1 + hw/misc/imx2_wdt.c | 88 ++++++++++++++++++++++++++++++++++++++++++++++ include/hw/misc/imx2_wdt.h | 34 ++++++++++++++++++ 3 files changed, 123 insertions(+) create mode 100644 hw/misc/imx2_wdt.c create mode 100644 include/hw/misc/imx2_wdt.h
hw/misc/Makefile.objs +1 -0
@@ -35,6 +35,7 @@ obj-$(CONFIG_IMX) += imx25_ccm.o obj-$(CONFIG_IMX) += imx6_ccm.o obj-$(CONFIG_IMX) += imx6_src.o obj-$(CONFIG_IMX) += imx7_ccm.o +obj-$(CONFIG_IMX) += imx2_wdt.o obj-$(CONFIG_MILKYMIST) += milkymist-hpdmc.o obj-$(CONFIG_MILKYMIST) += milkymist-pfpu.o obj-$(CONFIG_MAINSTONE) += mst_fpga.o
hw/misc/imx2_wdt.c new file +88 -0
88 lines not on this page · raw message
include/hw/misc/imx2_wdt.h new file +34 -0
@@ -0,0 +1,34 @@ +/* +* Copyright (c) 2017, Impinj, Inc. +* +* i.MX2 Watchdog IP block +* +* Author: Andrey Smirnov <[email protected]> +* +* This work is licensed under the terms of the GNU GPL, version 2 or later. +* See the COPYING file in the top-level directory. +*/ + +#ifndef IMX2_WDT_H +#define IMX2_WDT_H + +#include "qemu/bitops.h" +#include "hw/sysbus.h" + +#define TYPE_IMX2_WDT "imx2.wdt" +#define IMX2_WDT (obj) OBJECT_CHECK(IMX2WdtState, (obj), TYPE_IMX2_WDT) + +enum IMX2WdtRegisters { +IMX2_WDT_WCR =0x0000 , +IMX2_WDT_REG_NUM =0x0008 /sizeof (uint16_t ) +1 , +}; + + +typedef struct IMX2WdtState { +/* <private> */ +SysBusDevice parent_obj; + +MemoryRegion mmio; +}IMX2WdtState ; + +#endif /* IMX7_SNVS_H */
Signature · 1 line
2.13.6
Re: [Qemu-arm] [PATCH v3 14/30] i.MX: Add code to emulate i.MX2 watchdog IP block
Quoted 136 lines · Andrey Smirnov
Add enough code to emulate i.MX2 watchdog IP block so it would be possible to reboot the machine running Linux Guest.
Cc Peter Maydell <[email protected]>Cc Jason Wang <[email protected]>Cc Philippe Mathieu-Daudé <[email protected]>Signed-off-by Andrey Smirnov <[email protected]>--- hw/misc/Makefile.objs | 1 + hw/misc/imx2_wdt.c | 88 ++++++++++++++++++++++++++++++++++++++++++++++ include/hw/misc/imx2_wdt.h | 34 ++++++++++++++++++ 3 files changed, 123 insertions(+) create mode 100644 hw/misc/imx2_wdt.c create mode 100644 include/hw/misc/imx2_wdt.hhw/misc/Makefile.objs +1
-0@@ -35,6 +35,7 @@ obj-$(CONFIG_IMX) += imx25_ccm.o obj-$(CONFIG_IMX) += imx6_ccm.o obj-$(CONFIG_IMX) += imx6_src.o obj-$(CONFIG_IMX) += imx7_ccm.o +obj-$(CONFIG_IMX) += imx2_wdt.o obj-$(CONFIG_MILKYMIST) += milkymist-hpdmc.o obj-$(CONFIG_MILKYMIST) += milkymist-pfpu.o obj-$(CONFIG_MAINSTONE) += mst_fpga.ohw/misc/imx2_wdt.c new file +88
-0@@ -0,0 +1,88 @@ +/* +* Copyright (c) 2017, Impinj, Inc. +* +* i.MX2 Watchdog IP block +* +* Author: Andrey Smirnov <[email protected]> +* +* This work is licensed under the terms of the GNU GPL, version 2 or later. +* See the COPYING file in the top-level directory. +*/ + +#include "qemu/osdep.h" +#include "sysemu/watchdog.h" + +#include "hw/misc/imx2_wdt.h" + +#define IMX2_WDT_WCR_WDA BIT(5)/* -> External Reset WDOG_B */ +#define IMX2_WDT_WCR_SRS BIT(4)/* -> Software Reset Signal */ + +static uint64_t imx2_wdt_read (void *opaque,hwaddr addr, +unsigned int size) +{ +return 0 ; +} + +static void imx2_wdt_write (void *opaque,hwaddr addr, +uint64_t value,unsigned int size) +{ +if (addr ==IMX2_WDT_WCR && + (value & (IMX2_WDT_WCR_WDA |IMX2_WDT_WCR_SRS ))) { +watchdog_perform_action (); + } +} + +static const MemoryRegionOps imx2_wdt_ops = { + .read = imx2_wdt_read, + .write = imx2_wdt_write, + .endianness =DEVICE_NATIVE_ENDIAN , + .impl = { +/* +* Our device would not work correctly if the guest was doing +* unaligned access. This might not be a limitation on the +* real device but in practice there is no reason for a guest +* to access this device unaligned. +*/ + .min_access_size =4 , + .max_access_size =4 , + .unaligned = false, + }, +}; + +static void imx2_wdt_realize (DeviceState *dev,Error **errp) +{ +IMX2WdtState *s =IMX2_WDT (dev); + +memory_region_init_io (&s->mmio,OBJECT (dev), + &imx2_wdt_ops, s, +TYPE_IMX2_WDT ".mmio" , +IMX2_WDT_REG_NUM *sizeof (uint16_t )); +sysbus_init_mmio (SYS_BUS_DEVICE (dev), &s->mmio); +} + +static void imx2_wdt_class_init (ObjectClass *klass,void *data) +{ +DeviceClass *dc =DEVICE_CLASS (klass); + + dc->realize = imx2_wdt_realize; +set_bit (DEVICE_CATEGORY_MISC , dc->categories); +} + +static const TypeInfo imx2_wdt_info = { + .name =TYPE_IMX2_WDT , + .parent =TYPE_SYS_BUS_DEVICE , + .instance_size =sizeof (IMX2WdtState), + .class_init = imx2_wdt_class_init, +}; + +static WatchdogTimerModel model = { + .wdt_name ="imx2-watchdog" , + .wdt_description ="i.MX2 Watchdog" , +}; + +static void imx2_wdt_register_type (void ) +{ +watchdog_add_model (&model); +type_register_static (&imx2_wdt_info); +} +type_init (imx2_wdt_register_type)include/hw/misc/imx2_wdt.h new file +6
-0@@ -0,0 +1,34 @@ +/* +* Copyright (c) 2017, Impinj, Inc. +* +* i.MX2 Watchdog IP block +* +* Author: Andrey Smirnov <[email protected]>
include/hw/misc/imx2_wdt.h line 16
Quoted 10 lines
include/hw/misc/imx2_wdt.h new file +10
-0+* +* This work is licensed under the terms of the GNU GPL, version 2 or later. +* See the COPYING file in the top-level directory. +*/ + +#ifndef IMX2_WDT_H +#define IMX2_WDT_H + +#include "qemu/bitops.h" +#include "hw/sysbus.h"
The bitops.h include should be in the .c file, not here.
Quoted 19 lines
include/hw/misc/imx2_wdt.h new file +18
-1+ +#define TYPE_IMX2_WDT "imx2.wdt" +#define IMX2_WDT (obj) OBJECT_CHECK(IMX2WdtState, (obj), TYPE_IMX2_WDT) + +enum IMX2WdtRegisters { +IMX2_WDT_WCR =0x0000 , +IMX2_WDT_REG_NUM =0x0008 /sizeof (uint16_t ) +1 , +}; + + +typedef struct IMX2WdtState { +/* <private> */ +SysBusDevice parent_obj; + +MemoryRegion mmio; +}IMX2WdtState ; + +#endif /* IMX7_SNVS_H */ --
Quoted 2 lines
2.13.6
Otherwise
thanks
-- PMM
Re: [Qemu-arm] [PATCH v3 14/30] i.MX: Add code to emulate i.MX2 watchdog IP block
Quoted 141 lines · Peter Maydell
Quoted 140 lines · Andrey Smirnov
Add enough code to emulate i.MX2 watchdog IP block so it would be possible to reboot the machine running Linux Guest.
Cc Peter Maydell <[email protected]>Cc Jason Wang <[email protected]>Cc Philippe Mathieu-Daudé <[email protected]>Signed-off-by Andrey Smirnov <[email protected]>--- hw/misc/Makefile.objs | 1 + hw/misc/imx2_wdt.c | 88 ++++++++++++++++++++++++++++++++++++++++++++++ include/hw/misc/imx2_wdt.h | 34 ++++++++++++++++++ 3 files changed, 123 insertions(+) create mode 100644 hw/misc/imx2_wdt.c create mode 100644 include/hw/misc/imx2_wdt.hhw/misc/Makefile.objs +1
-0@@ -35,6 +35,7 @@ obj-$(CONFIG_IMX) += imx25_ccm.o obj-$(CONFIG_IMX) += imx6_ccm.o obj-$(CONFIG_IMX) += imx6_src.o obj-$(CONFIG_IMX) += imx7_ccm.o +obj-$(CONFIG_IMX) += imx2_wdt.o obj-$(CONFIG_MILKYMIST) += milkymist-hpdmc.o obj-$(CONFIG_MILKYMIST) += milkymist-pfpu.o obj-$(CONFIG_MAINSTONE) += mst_fpga.ohw/misc/imx2_wdt.c new file +88
-0@@ -0,0 +1,88 @@ +/* +* Copyright (c) 2017, Impinj, Inc. +* +* i.MX2 Watchdog IP block +* +* Author: Andrey Smirnov <[email protected]> +* +* This work is licensed under the terms of the GNU GPL, version 2 or later. +* See the COPYING file in the top-level directory. +*/ + +#include "qemu/osdep.h" +#include "sysemu/watchdog.h" + +#include "hw/misc/imx2_wdt.h" + +#define IMX2_WDT_WCR_WDA BIT(5)/* -> External Reset WDOG_B */ +#define IMX2_WDT_WCR_SRS BIT(4)/* -> Software Reset Signal */ + +static uint64_t imx2_wdt_read (void *opaque,hwaddr addr, +unsigned int size) +{ +return 0 ; +} + +static void imx2_wdt_write (void *opaque,hwaddr addr, +uint64_t value,unsigned int size) +{ +if (addr ==IMX2_WDT_WCR && + (value & (IMX2_WDT_WCR_WDA |IMX2_WDT_WCR_SRS ))) { +watchdog_perform_action (); + } +} + +static const MemoryRegionOps imx2_wdt_ops = { + .read = imx2_wdt_read, + .write = imx2_wdt_write, + .endianness =DEVICE_NATIVE_ENDIAN , + .impl = { +/* +* Our device would not work correctly if the guest was doing +* unaligned access. This might not be a limitation on the +* real device but in practice there is no reason for a guest +* to access this device unaligned. +*/ + .min_access_size =4 , + .max_access_size =4 , + .unaligned = false, + }, +}; + +static void imx2_wdt_realize (DeviceState *dev,Error **errp) +{ +IMX2WdtState *s =IMX2_WDT (dev); + +memory_region_init_io (&s->mmio,OBJECT (dev), + &imx2_wdt_ops, s, +TYPE_IMX2_WDT ".mmio" , +IMX2_WDT_REG_NUM *sizeof (uint16_t )); +sysbus_init_mmio (SYS_BUS_DEVICE (dev), &s->mmio); +} + +static void imx2_wdt_class_init (ObjectClass *klass,void *data) +{ +DeviceClass *dc =DEVICE_CLASS (klass); + + dc->realize = imx2_wdt_realize; +set_bit (DEVICE_CATEGORY_MISC , dc->categories); +} + +static const TypeInfo imx2_wdt_info = { + .name =TYPE_IMX2_WDT , + .parent =TYPE_SYS_BUS_DEVICE , + .instance_size =sizeof (IMX2WdtState), + .class_init = imx2_wdt_class_init, +}; + +static WatchdogTimerModel model = { + .wdt_name ="imx2-watchdog" , + .wdt_description ="i.MX2 Watchdog" , +}; + +static void imx2_wdt_register_type (void ) +{ +watchdog_add_model (&model); +type_register_static (&imx2_wdt_info); +} +type_init (imx2_wdt_register_type)include/hw/misc/imx2_wdt.h new file +10
-0@@ -0,0 +1,34 @@ +/* +* Copyright (c) 2017, Impinj, Inc. +* +* i.MX2 Watchdog IP block +* +* Author: Andrey Smirnov <[email protected]> +* +* This work is licensed under the terms of the GNU GPL, version 2 or later. +* See the COPYING file in the top-level directory. +*/
Quoted 9 lines
include/hw/misc/imx2_wdt.h line 16
Quoted 6 lines
include/hw/misc/imx2_wdt.h new file +6
-0+ +#ifndef IMX2_WDT_H +#define IMX2_WDT_H + +#include "qemu/bitops.h" +#include "hw/sysbus.h" The
bitops.hinclude should be in the .c file, not here.
Will fix in v4.
Thanks,
Andrey Smirnov
PATCH v3 15/30 i.MX: Add code to emulate i.MX7 SNVS IP-block
In reply to Andrey SmirnovAdd code to emulate SNVS IP-block. Currently only the bits needed to be able to emulate machine shutdown are implemented.
--- hw/misc/Makefile.objs | 1 + hw/misc/imx7_snvs.c | 83 +++++++++++++++++++++++++++++++++++++++++++++ include/hw/misc/imx7_snvs.h | 35 +++++++++++++++++++ 3 files changed, 119 insertions(+) create mode 100644 hw/misc/imx7_snvs.c create mode 100644 include/hw/misc/imx7_snvs.h
hw/misc/Makefile.objs +1 -0
@@ -36,6 +36,7 @@ obj-$(CONFIG_IMX) += imx6_ccm.o obj-$(CONFIG_IMX) += imx6_src.o obj-$(CONFIG_IMX) += imx7_ccm.o obj-$(CONFIG_IMX) += imx2_wdt.o +obj-$(CONFIG_IMX) += imx7_snvs.o obj-$(CONFIG_MILKYMIST) += milkymist-hpdmc.o obj-$(CONFIG_MILKYMIST) += milkymist-pfpu.o obj-$(CONFIG_MAINSTONE) += mst_fpga.o
hw/misc/imx7_snvs.c new file +83 -0
83 lines not on this page · raw message
include/hw/misc/imx7_snvs.h new file +35 -0
@@ -0,0 +1,35 @@ +/* +* Copyright (c) 2017, Impinj, Inc. +* +* i.MX7 SNVS block emulation code +* +* Author: Andrey Smirnov <[email protected]> +* +* This work is licensed under the terms of the GNU GPL, version 2 or later. +* See the COPYING file in the top-level directory. +*/ + +#ifndef IMX7_SNVS_H +#define IMX7_SNVS_H + +#include "qemu/bitops.h" +#include "hw/sysbus.h" + + +enum IMX7SNVSRegisters { +SNVS_LPCR =0x38 , +SNVS_LPCR_TOP =BIT (6 ), +SNVS_LPCR_DP_EN =BIT (5 ) +}; + +#define TYPE_IMX7_SNVS "imx7.snvs" +#define IMX7_SNVS (obj) OBJECT_CHECK(IMX7SNVSState, (obj), TYPE_IMX7_SNVS) + +typedef struct IMX7SNVSState { +/* <private> */ +SysBusDevice parent_obj; + +MemoryRegion mmio; +}IMX7SNVSState ; + +#endif /* IMX7_SNVS_H */
Signature · 1 line
2.13.6
Re: [Qemu-arm] [PATCH v3 15/30] i.MX: Add code to emulate i.MX7 SNVS IP-block
Quoted 10 lines · Andrey Smirnov
Add code to emulate SNVS IP-block. Currently only the bits needed to be able to emulate machine shutdown are implemented.
Cc Peter Maydell <[email protected]>Cc Jason Wang <[email protected]>Cc Philippe Mathieu-Daudé <[email protected]>Signed-off-by Andrey Smirnov <[email protected]>
thanks
-- PMM
PATCH v3 16/30 i.MX: Add code to emulate GPCv2 IP block
In reply to Andrey SmirnovAdd minimal code needed to allow upstream Linux guest to boot.
--- hw/intc/Makefile.objs | 2 +- hw/intc/imx_gpcv2.c | 125 ++++++++++++++++++++++++++++++++++++++++++++ include/hw/intc/imx_gpcv2.h | 22 ++++++++ 3 files changed, 148 insertions(+), 1 deletion(-) create mode 100644 hw/intc/imx_gpcv2.c create mode 100644 include/hw/intc/imx_gpcv2.h
hw/intc/Makefile.objs +1 -1
@@ -4,7 +4,7 @@ common-obj-$(CONFIG_PL190) += pl190.o common-obj-$(CONFIG_PUV3) += puv3_intc.o common-obj-$(CONFIG_XILINX) += xilinx_intc.o common-obj-$(CONFIG_ETRAXFS) += etraxfs_pic.o -common-obj-$(CONFIG_IMX) += imx_avic.o +common-obj-$(CONFIG_IMX) += imx_avic.o imx_gpcv2.o common-obj-$(CONFIG_LM32) += lm32_pic.o common-obj-$(CONFIG_REALVIEW) += realview_gic.o common-obj-$(CONFIG_SLAVIO) += slavio_intctl.o
hw/intc/imx_gpcv2.c new file +125 -0
125 lines not on this page · raw message
include/hw/intc/imx_gpcv2.h new file +22 -0
@@ -0,0 +1,22 @@ +#ifndef IMX_GPCV2_H +#define IMX_GPCV2_H + +#include "hw/sysbus.h" + +enum IMXGPCv2Registers { +GPC_NUM =0xE00 /sizeof (uint32_t ), +}; + +typedef struct IMXGPCv2State { +/*< private >*/ +SysBusDevice parent_obj; + +/*< public >*/ +MemoryRegion iomem; +uint32_t regs[GPC_NUM ]; +}IMXGPCv2State ; + +#define TYPE_IMX_GPCV2 "imx-gpcv2" +#define IMX_GPCV2 (obj) OBJECT_CHECK(IMXGPCv2State, (obj), TYPE_IMX_GPCV2) + +#endif /* IMX_GPCV2_H */
Signature · 1 line
2.13.6
Re: [Qemu-arm] [PATCH v3 16/30] i.MX: Add code to emulate GPCv2 IP block
Quoted 9 lines · Andrey Smirnov
Add minimal code needed to allow upstream Linux guest to boot.
Cc Peter Maydell <[email protected]>Cc Jason Wang <[email protected]>Cc Philippe Mathieu-Daudé <[email protected]>Signed-off-by Andrey Smirnov <[email protected]>
Quoted 7 lines
--- hw/intc/Makefile.objs | 2 +- hw/intc/imx_gpcv2.c | 125 ++++++++++++++++++++++++++++++++++++++++++++ include/hw/intc/imx_gpcv2.h | 22 ++++++++ 3 files changed, 148 insertions(+), 1 deletion(-) create mode 100644 hw/intc/imx_gpcv2.c create mode 100644 include/hw/intc/imx_gpcv2.h
thanks
-- PMM
PATCH v3 17/30 i.MX: Add code to emulate i.MX7 IOMUXC IP block
In reply to Andrey SmirnovAdd minimal code needed to allow upstream Linux guest to boot.
--- hw/misc/Makefile.objs | 1 + hw/misc/imx7_iomuxc.c | 99 +++++++++++++++++++++++++++++++++++++++++++ include/hw/misc/imx7_iomuxc.h | 22 ++++++++++ 3 files changed, 122 insertions(+) create mode 100644 hw/misc/imx7_iomuxc.c create mode 100644 include/hw/misc/imx7_iomuxc.h
hw/misc/Makefile.objs +1 -0
@@ -37,6 +37,7 @@ obj-$(CONFIG_IMX) += imx6_src.o obj-$(CONFIG_IMX) += imx7_ccm.o obj-$(CONFIG_IMX) += imx2_wdt.o obj-$(CONFIG_IMX) += imx7_snvs.o +obj-$(CONFIG_IMX) += imx7_iomuxc.o obj-$(CONFIG_MILKYMIST) += milkymist-hpdmc.o obj-$(CONFIG_MILKYMIST) += milkymist-pfpu.o obj-$(CONFIG_MAINSTONE) += mst_fpga.o
hw/misc/imx7_iomuxc.c new file +99 -0
99 lines not on this page · raw message
include/hw/misc/imx7_iomuxc.h new file +22 -0
@@ -0,0 +1,22 @@ +#ifndef IMX7_IOMUXC_H +#define IMX7_IOMUXC_H + +#include "hw/sysbus.h" + +enum IMX7IOMUXCRegisters { +IOMUXC_NUM =0x740 /sizeof (uint32_t ), +}; + +typedef struct IMX7IOMUXCState { +/*< private >*/ +SysBusDevice parent_obj; + +/*< public >*/ +MemoryRegion iomem; +uint32_t regs[IOMUXC_NUM ]; +}IMX7IOMUXCState ; + +#define TYPE_IMX7_IOMUXC "imx7-iomuxc" +#define IMX7_IOMUXC (obj) OBJECT_CHECK(IMX7IOMUXCState, (obj), TYPE_IMX7_IOMUXC) + +#endif /* IMX7_IOMUXC_H */
Signature · 1 line
2.13.6
PATCH v3 19/30 i.MX: Add code to emulate SDMA IP block
In reply to Andrey SmirnovAdd minimal code needed to allow upstream Linux guest to boot.
--- hw/dma/Makefile.objs | 1 + hw/dma/imx_sdma.c | 99 +++++++++++++++++++++++++++++++++++++++++++++++ include/hw/dma/imx_sdma.h | 22 +++++++++++ 3 files changed, 122 insertions(+) create mode 100644 hw/dma/imx_sdma.c create mode 100644 include/hw/dma/imx_sdma.h
hw/dma/Makefile.objs +1 -0
@@ -14,3 +14,4 @@ obj-$(CONFIG_XLNX_ZYNQMP) += xlnx_dpdma.o obj-$(CONFIG_OMAP) += omap_dma.o soc_dma.o obj-$(CONFIG_PXA2XX) += pxa2xx_dma.o obj-$(CONFIG_RASPI) += bcm2835_dma.o +obj-$(CONFIG_IMX) += imx_sdma.o
hw/dma/imx_sdma.c new file +99 -0
99 lines not on this page · raw message
include/hw/dma/imx_sdma.h new file +22 -0
@@ -0,0 +1,22 @@ +#ifndef IMX_SDMA_H +#define IMX_SDMA_H + +#include "hw/sysbus.h" + +enum IMXSDMARegisters { +SDMA_NUM =0x300 /sizeof (uint32_t ) +1 , +}; + +typedef struct IMXSDMAState { +/*< private >*/ +SysBusDevice parent_obj; + +/*< public >*/ +MemoryRegion iomem; +uint32_t regs[SDMA_NUM ]; +}IMXSDMAState ; + +#define TYPE_IMX_SDMA "imx-sdma" +#define IMX_SDMA (obj) OBJECT_CHECK(IMXSDMAState, (obj), TYPE_IMX_SDMA) + +#endif /* IMX_SDMA_H */
Signature · 1 line
2.13.6
Re: [Qemu-arm] [PATCH v3 19/30] i.MX: Add code to emulate SDMA IP block
Quoted 9 lines · Andrey Smirnov
Add minimal code needed to allow upstream Linux guest to boot.
Cc Peter Maydell <[email protected]>Cc Jason Wang <[email protected]>Cc Philippe Mathieu-Daudé <[email protected]>Signed-off-by Andrey Smirnov <[email protected]>
Quoted 8 lines
--- hw/dma/Makefile.objs | 1 + hw/dma/imx_sdma.c | 99 +++++++++++++++++++++++++++++++++++++++++++++++ include/hw/dma/imx_sdma.h | 22 +++++++++++ 3 files changed, 122 insertions(+) create mode 100644 hw/dma/imx_sdma.c create mode 100644 include/hw/dma/imx_sdma.h
Does Linux really insist on reads-as-written behaviour? (ie can you get away with just using create_unimplemented_device() ?)
thanks
-- PMM
Re: [Qemu-arm] [PATCH v3 19/30] i.MX: Add code to emulate SDMA IP block
Quoted 19 lines · Peter Maydell
Quoted 9 lines · Andrey Smirnov
Add minimal code needed to allow upstream Linux guest to boot.
Cc Peter Maydell <[email protected]>Cc Jason Wang <[email protected]>Cc Philippe Mathieu-Daudé <[email protected]>Signed-off-by Andrey Smirnov <[email protected]>Quoted 8 lines
--- hw/dma/Makefile.objs | 1 + hw/dma/imx_sdma.c | 99 +++++++++++++++++++++++++++++++++++++++++++++++ include/hw/dma/imx_sdma.h | 22 +++++++++++ 3 files changed, 122 insertions(+) create mode 100644 hw/dma/imx_sdma.c create mode 100644 include/hw/dma/imx_sdma.h
Quoted 4 lines
Does Linux really insist on reads-as-written behaviour? (ie can you get away with just using
create_unimplemented_device()?)
Not sure. I'll give it a try for v4.
Thanks,
Andrey Smirnov
PATCH v3 20/30 i.MX: Add code to emulate FlexCAN IP block
In reply to Andrey SmirnovAdd minimal code needed to allow upstream Linux guest to boot.
--- hw/misc/Makefile.objs | 1 + hw/misc/imx_flexcan.c | 99 +++++++++++++++++++++++++++++++++++++++++++ include/hw/misc/imx_flexcan.h | 22 ++++++++++ 3 files changed, 122 insertions(+) create mode 100644 hw/misc/imx_flexcan.c create mode 100644 include/hw/misc/imx_flexcan.h
hw/misc/Makefile.objs +1 -0
@@ -38,6 +38,7 @@ obj-$(CONFIG_IMX) += imx7_ccm.o obj-$(CONFIG_IMX) += imx2_wdt.o obj-$(CONFIG_IMX) += imx7_snvs.o obj-$(CONFIG_IMX) += imx7_iomuxc.o +obj-$(CONFIG_IMX) += imx_flexcan.o obj-$(CONFIG_MILKYMIST) += milkymist-hpdmc.o obj-$(CONFIG_MILKYMIST) += milkymist-pfpu.o obj-$(CONFIG_MAINSTONE) += mst_fpga.o
hw/misc/imx_flexcan.c new file +99 -0
99 lines not on this page · raw message
include/hw/misc/imx_flexcan.h new file +22 -0
@@ -0,0 +1,22 @@ +#ifndef IMX_FLEXCAN_H +#define IMX_FLEXCAN_H + +#include "hw/sysbus.h" + +enum IMXFlexCANRegisters { +FLEXCAN_NUM =0x9E0 /sizeof (uint32_t ) +1 , +}; + +typedef struct IMXFlexCANState { +/*< private >*/ +SysBusDevice parent_obj; + +/*< public >*/ +MemoryRegion iomem; +uint32_t regs[FLEXCAN_NUM ]; +}IMXFlexCANState ; + +#define TYPE_IMX_FLEXCAN "imx-flexcan" +#define IMX_FLEXCAN (obj) OBJECT_CHECK(IMXFlexCANState, (obj), TYPE_IMX_FLEXCAN) + +#endif /* IMX_FLEXCAN_H */
Signature · 1 line
2.13.6
PATCH v3 21/30 i.MX: Add implementation of i.MX7 GPR IP block
In reply to Andrey SmirnovAdd minimal code needed to allow upstream Linux guest to boot.
--- hw/misc/Makefile.objs | 1 + hw/misc/imx7_gpr.c | 119 +++++++++++++++++++++++++++++++++++++++++++++ include/hw/misc/imx7_gpr.h | 28 +++++++++++ 3 files changed, 148 insertions(+) create mode 100644 hw/misc/imx7_gpr.c create mode 100644 include/hw/misc/imx7_gpr.h
hw/misc/Makefile.objs +1 -0
@@ -39,6 +39,7 @@ obj-$(CONFIG_IMX) += imx2_wdt.o obj-$(CONFIG_IMX) += imx7_snvs.o obj-$(CONFIG_IMX) += imx7_iomuxc.o obj-$(CONFIG_IMX) += imx_flexcan.o +obj-$(CONFIG_IMX) += imx7_gpr.o obj-$(CONFIG_MILKYMIST) += milkymist-hpdmc.o obj-$(CONFIG_MILKYMIST) += milkymist-pfpu.o obj-$(CONFIG_MAINSTONE) += mst_fpga.o
hw/misc/imx7_gpr.c new file +119 -0
119 lines not on this page · raw message
include/hw/misc/imx7_gpr.h new file +28 -0
@@ -0,0 +1,28 @@ +/* +* Copyright (c) 2017, Impinj, Inc. +* +* i.MX7 GPR IP block emulation code +* +* Author: Andrey Smirnov <[email protected]> +* +* This work is licensed under the terms of the GNU GPL, version 2 or later. +* See the COPYING file in the top-level directory. +*/ + +#ifndef IMX7_GPR_H +#define IMX7_GPR_H + +#include "qemu/bitops.h" +#include "hw/sysbus.h" + +#define TYPE_IMX7_GPR "imx7.gpr" +#define IMX7_GPR (obj) OBJECT_CHECK(IMX7GPRState, (obj), TYPE_IMX7_GPR) + +typedef struct IMX7GPRState { +/* <private> */ +SysBusDevice parent_obj; + +MemoryRegion mmio; +}IMX7GPRState ; + +#endif /* IMX7_GPR_H */
Signature · 1 line
2.13.6
PATCH v3 22/30 pci: Add support for Designware IP block
In reply to Andrey SmirnovAdd code needed to get a functional PCI subsytem when using in conjunction with upstream Linux guest (4.13+). Tested to work against "e1000e" (network adapter, using MSI interrupts) as well as "usb-ehci" (USB controller, using legacy PCI interrupts).
--- default-configs/arm-softmmu.mak | 2 + hw/pci-host/Makefile.objs | 2 + hw/pci-host/designware.c | 614 +++++++++++++++++++++++++++++++++++++++ include/hw/pci-host/designware.h | 92 ++++++ include/hw/pci/pci_ids.h | 2 + 5 files changed, 712 insertions(+) create mode 100644 hw/pci-host/designware.c create mode 100644 include/hw/pci-host/designware.h
default-configs/arm-softmmu.mak +2 -0
@@ -129,3 +129,5 @@ CONFIG_ACPI=y CONFIG_SMBIOS=y CONFIG_ASPEED_SOC=y CONFIG_GPIO_KEY=y + +CONFIG_PCI_DESIGNWARE=y
hw/pci-host/Makefile.objs +2 -0
@@ -17,3 +17,5 @@ common-obj-$(CONFIG_PCI_PIIX) += piix.o common-obj-$(CONFIG_PCI_Q35) += q35.o common-obj-$(CONFIG_PCI_GENERIC) += gpex.o common-obj-$(CONFIG_PCI_XILINX) += xilinx-pcie.o + +common-obj-$(CONFIG_PCI_DESIGNWARE) += designware.o
hw/pci-host/designware.c new file +614 -0
614 lines not on this page · raw message
include/hw/pci-host/designware.h new file +92 -0
92 lines not on this page · raw message
include/hw/pci/pci_ids.h +2 -0
@@ -264,4 +264,6 @@#define PCI_VENDOR_ID_TEWS 0x1498#define PCI_DEVICE_ID_TEWS_TPCI200 0x30C8 +#define PCI_VENDOR_ID_SYNOPSYS 0x16C3 +#endif
Signature · 1 line
2.13.6
PATCH v3 23/30 i.MX: Add code to emulate i.MX7 USBMISC IP block
In reply to Andrey SmirnovAdd minimal code needed to allow upstream Linux guest to boot.
--- hw/usb/Makefile.objs | 1 + hw/usb/imx-usbmisc.c | 99 ++++++++++++++++++++++++++++++++++++++++++++ include/hw/usb/imx-usbmisc.h | 22 ++++++++++ 3 files changed, 122 insertions(+) create mode 100644 hw/usb/imx-usbmisc.c create mode 100644 include/hw/usb/imx-usbmisc.h
hw/usb/Makefile.objs +1 -0
@@ -12,6 +12,7 @@ common-obj-$(CONFIG_USB_XHCI_NEC) += hcd-xhci-nec.o common-obj-$(CONFIG_USB_MUSB) += hcd-musb.o obj-$(CONFIG_TUSB6010) += tusb6010.o +obj-$(CONFIG_IMX) += imx-usbmisc.o # emulated usb devices common-obj-$(CONFIG_USB) += dev-hub.o
hw/usb/imx-usbmisc.c new file +99 -0
99 lines not on this page · raw message
include/hw/usb/imx-usbmisc.h new file +22 -0
@@ -0,0 +1,22 @@ +#ifndef IMX_USBMISC_H +#define IMX_USBMISC_H + +#include "hw/sysbus.h" + +enum IMXUSBMiscRegisters { +USBMISC_NUM =0x24 /sizeof (uint32_t ) +1 , +}; + +typedef struct IMXUSBMiscState { +/*< private >*/ +SysBusDevice parent_obj; + +/*< public >*/ +MemoryRegion iomem; +uint32_t regs[USBMISC_NUM ]; +}IMXUSBMiscState ; + +#define TYPE_IMX_USBMISC "imx-usbmisc" +#define IMX_USBMISC (obj) OBJECT_CHECK(IMXUSBMiscState, (obj), TYPE_IMX_USBMISC) + +#endif /* IMX_USBMISC_H */
Signature · 1 line
2.13.6
PATCH v3 24/30 i.MX: Add code to emulate i.MX7 ADC IP block
In reply to Andrey SmirnovAdd minimal code needed to allow upstream Linux guest to boot.
--- hw/misc/Makefile.objs | 1 + hw/misc/imx7_adc.c | 99 ++++++++++++++++++++++++++++++++++++++++++++++ include/hw/misc/imx7_adc.h | 22 +++++++++++ 3 files changed, 122 insertions(+) create mode 100644 hw/misc/imx7_adc.c create mode 100644 include/hw/misc/imx7_adc.h
hw/misc/Makefile.objs +1 -0
@@ -39,6 +39,7 @@ obj-$(CONFIG_IMX) += imx2_wdt.o obj-$(CONFIG_IMX) += imx7_snvs.o obj-$(CONFIG_IMX) += imx7_iomuxc.o obj-$(CONFIG_IMX) += imx_flexcan.o +obj-$(CONFIG_IMX) += imx7_adc.o obj-$(CONFIG_IMX) += imx7_gpr.o obj-$(CONFIG_MILKYMIST) += milkymist-hpdmc.o obj-$(CONFIG_MILKYMIST) += milkymist-pfpu.o
hw/misc/imx7_adc.c new file +99 -0
99 lines not on this page · raw message
include/hw/misc/imx7_adc.h new file +22 -0
@@ -0,0 +1,22 @@ +#ifndef IMX7_ADC_H +#define IMX7_ADC_H + +#include "hw/sysbus.h" + +enum IMX7ADCRegisters { +ADC_NUM =0x130 /sizeof (uint32_t ) +1 , +}; + +typedef struct IMX7ADCState { +/*< private >*/ +SysBusDevice parent_obj; + +/*< public >*/ +MemoryRegion iomem; +uint32_t regs[ADC_NUM ]; +}IMX7ADCState ; + +#define TYPE_IMX7_ADC "imx7-adc" +#define IMX7_ADC (obj) OBJECT_CHECK(IMX7ADCState, (obj), TYPE_IMX7_ADC) + +#endif /* IMX7_ADC_H */
Signature · 1 line
2.13.6
PATCH v3 25/30 i.MX: Add code to emulate i.MX7 SRC IP-block
In reply to Andrey SmirnovAdd minimal code needed to allow upstream Linux guest to boot.
--- hw/misc/Makefile.objs | 1 + hw/misc/imx7_src.c | 93 ++++++++++++++++++++++++++++++++++++++++++++++ include/hw/misc/imx7_src.h | 22 +++++++++++ 3 files changed, 116 insertions(+) create mode 100644 hw/misc/imx7_src.c create mode 100644 include/hw/misc/imx7_src.h
hw/misc/Makefile.objs +1 -0
@@ -41,6 +41,7 @@ obj-$(CONFIG_IMX) += imx7_iomuxc.o obj-$(CONFIG_IMX) += imx_flexcan.o obj-$(CONFIG_IMX) += imx7_adc.o obj-$(CONFIG_IMX) += imx7_gpr.o +obj-$(CONFIG_IMX) += imx7_src.o obj-$(CONFIG_MILKYMIST) += milkymist-hpdmc.o obj-$(CONFIG_MILKYMIST) += milkymist-pfpu.o obj-$(CONFIG_MAINSTONE) += mst_fpga.o
hw/misc/imx7_src.c new file +93 -0
93 lines not on this page · raw message
include/hw/misc/imx7_src.h new file +22 -0
@@ -0,0 +1,22 @@ +#ifndef IMX7_SRC_H +#define IMX7_SRC_H + +#include "hw/sysbus.h" + +enum IMX7SRCRegisters { +SRC_NUM =0x1000 /sizeof (uint32_t ) +1 , +}; + +typedef struct IMX7SRCState { +/*< private >*/ +SysBusDevice parent_obj; + +/*< public >*/ +MemoryRegion iomem; +uint32_t regs[SRC_NUM ]; +}IMX7SRCState ; + +#define TYPE_IMX7_SRC "imx7-src" +#define IMX7_SRC (obj) OBJECT_CHECK(IMX7SRCState, (obj), TYPE_IMX7_SRC) + +#endif /* IMX7_SRC_H */
Signature · 1 line
2.13.6
PATCH v3 26/30 usb: Add basic code to emulate Chipidea USB IP
In reply to Andrey SmirnovAdd code to emulate Chipidea USB IP (used in i.MX SoCs). Tested to work against:
-usb -drive if=none,id=stick,file=usb.img,format=raw -device \
usb-storage,bus=usb-bus.0,drive=stick
--- hw/usb/Makefile.objs | 1 + hw/usb/chipidea.c | 176 ++++++++++++++++++++++++++++++++++++++++++++++ include/hw/usb/chipidea.h | 16 +++++ 3 files changed, 193 insertions(+) create mode 100644 hw/usb/chipidea.c create mode 100644 include/hw/usb/chipidea.h
hw/usb/Makefile.objs +1 -0
@@ -13,6 +13,7 @@ common-obj-$(CONFIG_USB_MUSB) += hcd-musb.o obj-$(CONFIG_TUSB6010) += tusb6010.o obj-$(CONFIG_IMX) += imx-usbmisc.o +obj-$(CONFIG_IMX) += chipidea.o # emulated usb devices common-obj-$(CONFIG_USB) += dev-hub.o
hw/usb/chipidea.c new file +176 -0
176 lines not on this page · raw message
include/hw/usb/chipidea.h new file +16 -0
@@ -0,0 +1,16 @@ +#ifndef CHIPIDEA_H +#define CHIPIDEA_H + +#include "hw/usb/hcd-ehci.h" + +typedef struct ChipideaState { +/*< private >*/ +EHCISysBusState parent_obj; + +MemoryRegion iomem[3 ]; +}ChipideaState ; + +#define TYPE_CHIPIDEA "usb-chipidea" +#define CHIPIDEA (obj) OBJECT_CHECK(ChipideaState, (obj), TYPE_CHIPIDEA) + +#endif /* CHIPIDEA_H */
Signature · 1 line
2.13.6
PATCH v3 27/30 ARM: Add basic code to emulate A7MPCore DAP block
In reply to Andrey SmirnovAdd minimal code to emulate A7MPCore DAP block needed to boot Linux guest.
--- hw/arm/Makefile.objs | 2 +- hw/arm/coresight.c | 120 +++++++++++++++++++++++++++++++++++++++++++++ include/hw/arm/coresight.h | 24 +++++++++ 3 files changed, 145 insertions(+), 1 deletion(-) create mode 100644 hw/arm/coresight.c create mode 100644 include/hw/arm/coresight.h
hw/arm/Makefile.objs +1 -1
@@ -1,4 +1,4 @@ -obj-y += boot.o collie.o exynos4_boards.o gumstix.o highbank.o +obj-y += boot.o collie.o exynos4_boards.o gumstix.o highbank.o coresight.o obj-$(CONFIG_DIGIC) += digic_boards.o obj-y += integratorcp.o mainstone.o musicpal.o nseries.o obj-y += omap_sx1.o palm.o realview.o spitz.o stellaris.o
hw/arm/coresight.c new file +120 -0
120 lines not on this page · raw message
include/hw/arm/coresight.h new file +24 -0
@@ -0,0 +1,24 @@ +#ifndef CORESIGHT_H +#define CORESIGHT_H + +#include "hw/sysbus.h" + +typedef struct A7MPCoreDAPState { +/*< private >*/ +SysBusDevice parent_obj; + +MemoryRegion container; + +MemoryRegion ca7_atb_funnel; +MemoryRegion cpu0_etm; +MemoryRegion atb_funnel; +MemoryRegion tmc_etb; +MemoryRegion tmc_etr; +MemoryRegion tpiu; + +}A7MPCoreDAPState ; + +#define TYPE_A7MPCORE_DAP "a7mpcore-dap" +#define A7MPCORE_DAP (obj) OBJECT_CHECK(A7MPCoreDAPState, (obj), TYPE_A7MPCORE_DAP) + +#endif /* CORESIGHT_H */
Signature · 1 line
2.13.6
PATCH v3 28/30 i.MX: Add code to emulate i.MX LCD block
In reply to Andrey SmirnovAdd basic i.MX LCD block emulation code needed to boot Linux guest.
--- hw/display/Makefile.objs | 2 ++ hw/display/imx_lcdif.c | 71 ++++++++++++++++++++++++++++++++++++++++++ include/hw/display/imx_lcdif.h | 16 ++++++++++ 3 files changed, 89 insertions(+) create mode 100644 hw/display/imx_lcdif.c create mode 100644 include/hw/display/imx_lcdif.h
hw/display/Makefile.objs +2 -0
@@ -41,3 +41,5 @@ virtio-gpu-3d.o-cflags := $(VIRGL_CFLAGS) virtio-gpu-3d.o-libs += $(VIRGL_LIBS) obj-$(CONFIG_DPCD) += dpcd.o obj-$(CONFIG_XLNX_ZYNQMP) += xlnx_dp.o + +obj-$(CONFIG_IMX) += imx_lcdif.o
hw/display/imx_lcdif.c new file +71 -0
71 lines not on this page · raw message
include/hw/display/imx_lcdif.h new file +16 -0
@@ -0,0 +1,16 @@ +#ifndef IMX_LCDIF_H +#define IMX_LCDIF_H + +#include "hw/sysbus.h" + +typedef struct IMXLCDState { +/*< private >*/ +SysBusDevice parent_obj; + +MemoryRegion iomem; +}IMXLCDState ; + +#define TYPE_IMX_LCDIF "imx:lcdif" +#define IMX_LCDIF (obj) OBJECT_CHECK(IMXLCDState, (obj), TYPE_IMX_LCDIF) + +#endif /* IMX_LCDIF_H */
Signature · 1 line
2.13.6
PATCH v3 29/30 i.MX: Add i.MX7 SOC implementation.
In reply to Andrey SmirnovThe following interfaces are partially or fully emulated:
* up to 2 Cortex A9 cores (SMP works with PSCI)
* A7 MPCORE (identical to A15 MPCORE)
* 4 GPTs modules
* 7 GPIO controllers
* 2 IOMUXC controllers
* 1 CCM module
* 1 SVNS module
* 1 SRC module
* 1 GPCv2 controller
* 4 eCSPI controllers
* 4 I2C controllers
* 7 i.MX UART controllers
* 2 FlexCAN controllers
* 2 Ethernet controllers (FEC)
* 3 SD controllers (USDHC)
* 4 WDT modules
* 1 SDMA module
* 1 GPR module
* 2 USBMISC modules
* 2 ADC modules
* 1 PCIe controller
Tested to boot and work with upstream Linux (4.13+) guest.
--- default-configs/arm-softmmu.mak | 1 + hw/arm/Makefile.objs | 2 + hw/arm/fsl-imx7.c | 646 ++++++++++++++++++++++++++++++++++++++++ include/hw/arm/fsl-imx7.h | 233 +++++++++++++++ 4 files changed, 882 insertions(+) create mode 100644 hw/arm/fsl-imx7.c create mode 100644 include/hw/arm/fsl-imx7.h
default-configs/arm-softmmu.mak +1 -0
@@ -118,6 +118,7 @@ CONFIG_ALLWINNER_A10=y CONFIG_FSL_IMX6=y CONFIG_FSL_IMX31=y CONFIG_FSL_IMX25=y +CONFIG_FSL_IMX7=y CONFIG_IMX_I2C=y
hw/arm/Makefile.objs +2 -0
@@ -19,3 +19,5 @@ obj-$(CONFIG_FSL_IMX31) += fsl-imx31.o kzm.o obj-$(CONFIG_FSL_IMX6) += fsl-imx6.o sabrelite.o obj-$(CONFIG_ASPEED_SOC) += aspeed_soc.o aspeed.o obj-$(CONFIG_MPS2) += mps2.o +obj-$(CONFIG_FSL_IMX7) += fsl-imx7.o +
hw/arm/fsl-imx7.c new file +646 -0
646 lines not on this page · raw message
include/hw/arm/fsl-imx7.h new file +233 -0
233 lines not on this page · raw message
Signature · 1 line
2.13.6
Re: [Qemu-arm] [Qemu-devel] [PATCH v3 29/30] i.MX: Add i.MX7 SOC implementation.
Quoted 34 lines · On Mon, 6 Nov 2017 07:48:12 -0800 Andrey Smirnov <[email protected]>…
The following interfaces are partially or fully emulated:
* up to 2 Cortex A9 cores (SMP works with PSCI)
* A7 MPCORE (identical to A15 MPCORE)
* 4 GPTs modules
* 7 GPIO controllers
* 2 IOMUXC controllers
* 1 CCM module
* 1 SVNS module
* 1 SRC module
* 1 GPCv2 controller
* 4 eCSPI controllers
* 4 I2C controllers
* 7 i.MX UART controllers
* 2 FlexCAN controllers
* 2 Ethernet controllers (FEC)
* 3 SD controllers (USDHC)
* 4 WDT modules
* 1 SDMA module
* 1 GPR module
* 2 USBMISC modules
* 2 ADC modules
* 1 PCIe controllerTested to boot and work with upstream Linux (4.13+) guest.
Cc Peter Maydell <[email protected]>Cc Jason Wang <[email protected]>Cc Philippe Mathieu-Daudé <[email protected]>Signed-off-by Andrey Smirnov <[email protected]>---
...
Quoted 7 lines
hw/arm/fsl-imx7.c new file +7
-0+ +static void fsl_imx7_init (Object *obj) +{ +BusState *sysbus =sysbus_get_default (); +FslIMX7State *s =FSL_IMX7 (obj); +char name[NAME_SIZE ]; +int i;
hw/arm/fsl-imx7.c line 45
Quoted 10 lines
hw/arm/fsl-imx7.c new file +10
-0+ +if (smp_cpus >FSL_IMX7_NUM_CPUS ) { +error_report ("%s: Only %d CPUs are supported (%d requested)" , +TYPE_FSL_IMX7 ,FSL_IMX7_NUM_CPUS , smp_cpus); +exit (1 ); + } + +for (i =0 ; i < smp_cpus; i++) { +object_initialize (&s->cpu[i],sizeof (s->cpu[i]), +"cortex-a7-" TYPE_ARM_CPU );
pls reuse ARM_CPU_TYPE_NAME() macro here
Quoted 4 lines
hw/arm/fsl-imx7.c new file +4
-0+snprintf (name,NAME_SIZE ,"cpu%d" , i); +object_property_add_child (obj, name,OBJECT (&s->cpu[i]), + &error_fatal); + }
Re: [Qemu-arm] [Qemu-devel] [PATCH v3 29/30] i.MX: Add i.MX7 SOC implementation.
Quoted 48 lines · Igor Mammedov
Quoted 34 lines · On Mon, 6 Nov 2017 07:48:12 -0800 Andrey Smirnov <[email protected]>…
The following interfaces are partially or fully emulated:
* up to 2 Cortex A9 cores (SMP works with PSCI)
* A7 MPCORE (identical to A15 MPCORE)
* 4 GPTs modules
* 7 GPIO controllers
* 2 IOMUXC controllers
* 1 CCM module
* 1 SVNS module
* 1 SRC module
* 1 GPCv2 controller
* 4 eCSPI controllers
* 4 I2C controllers
* 7 i.MX UART controllers
* 2 FlexCAN controllers
* 2 Ethernet controllers (FEC)
* 3 SD controllers (USDHC)
* 4 WDT modules
* 1 SDMA module
* 1 GPR module
* 2 USBMISC modules
* 2 ADC modules
* 1 PCIe controllerTested to boot and work with upstream Linux (4.13+) guest.
Cc Peter Maydell <[email protected]>Cc Jason Wang <[email protected]>Cc Philippe Mathieu-Daudé <[email protected]>Signed-off-by Andrey Smirnov <[email protected]>---
...
Quoted 10 lines
hw/arm/fsl-imx7.c new file +10
-0+ +static void fsl_imx7_init (Object *obj) +{ +BusState *sysbus =sysbus_get_default (); +FslIMX7State *s =FSL_IMX7 (obj); +char name[NAME_SIZE ]; +int i; + +if (smp_cpus >FSL_IMX7_NUM_CPUS ) { + error_report("%s: Only %d CPUs are supported (%d requested)",
Quoted 8 lines
hw/arm/fsl-imx7.c line 45
Quoted 7 lines
hw/arm/fsl-imx7.c new file +7
-0+ TYPE_FSL_IMX7, FSL_IMX7_NUM_CPUS, smp_cpus); +exit (1 ); + } + +for (i =0 ; i < smp_cpus; i++) { +object_initialize (&s->cpu[i],sizeof (s->cpu[i]), +"cortex-a7-" TYPE_ARM_CPU );pls reuse
ARM_CPU_TYPE_NAME()macro here
Will do in v4.
Thanks,
Andrey Smirnov
A message that is not in the archive (sent off-list or not yet received): [email protected]
Re: [Qemu-arm] [PATCH v3 30/30] Implement support for i.MX7 Sabre board
Quoted 4 lines · Andrey Smirnov
Implement code needed to set up emulation of MCIMX7SABRE board from NXP. For more info about the HW see:
You could put this URL in a comment in the code as well.
Quoted 59 lines
Cc Peter Maydell <[email protected]>Cc Jason Wang <[email protected]>Cc Philippe Mathieu-Daudé <[email protected]>Signed-off-by Andrey Smirnov <[email protected]>--- hw/arm/Makefile.objs | 2 +- hw/arm/mcimx7d-sabre.c | 101 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 102 insertions(+), 1 deletion(-) create mode 100644 hw/arm/mcimx7d-sabre.chw/arm/Makefile.objs +1
-1@@ -19,5 +19,5 @@ obj-$(CONFIG_FSL_IMX31) += fsl-imx31.o kzm.o obj-$(CONFIG_FSL_IMX6) += fsl-imx6.o sabrelite.o obj-$(CONFIG_ASPEED_SOC) += aspeed_soc.o aspeed.o obj-$(CONFIG_MPS2) += mps2.o -obj-$(CONFIG_FSL_IMX7) += fsl-imx7.o +obj-$(CONFIG_FSL_IMX7) += fsl-imx7.o mcimx7d-sabre.ohw/arm/mcimx7d-sabre.c new file +29
-0@@ -0,0 +1,101 @@ +/* +* Copyright (c) 2017, Impinj, Inc. +* +* MCIMX7D_SABRE Board System emulation. +* +* Author: Andrey Smirnov <[email protected]> +* +* This code is licensed under the GPL, version 2 or later. +* See the file `COPYING' in the top level directory. +* +* It (partially) emulates a mcimx7d_sabre board, with a Freescale +* i.MX7 SoC +*/ + +#include "qemu/osdep.h" +#include "qapi/error.h" +#include "qemu-common.h" +#include "hw/arm/fsl-imx7.h" +#include "hw/boards.h" +#include "sysemu/sysemu.h" +#include "sysemu/device_tree.h" +#include "qemu/error-report.h" +#include "sysemu/qtest.h" +#include "net/net.h" + +typedef struct { +FslIMX7State soc; +MemoryRegion ram; +}MCIMX7Sabre ;
hw/arm/mcimx7d-sabre.c line 39
Quoted 10 lines
hw/arm/mcimx7d-sabre.c new file +10
-0+ +static void mcimx7d_add_psci_node (const struct arm_boot_info *boot_info, +void *fdt) +{ +const char comp[] ="arm,psci-0.2\0arm,psci" ; + +qemu_fdt_add_subnode (fdt,"/psci" ); +qemu_fdt_setprop (fdt,"/psci" ,"compatible" , comp,sizeof (comp)); +qemu_fdt_setprop_string (fdt,"/psci" ,"method" ,"smc" ); +}
I'm still unconvinced by this (none of the other i.mx boards we have have anything like it). How does the real hardware boot SMP ?
thanks
-- PMM
Re: [Qemu-devel] [PATCH v3 30/30] Implement support for i.MX7 Sabre board
Quoted 72 lines · Peter Maydell
Quoted 4 lines · Andrey Smirnov
Implement code needed to set up emulation of MCIMX7SABRE board from NXP. For more info about the HW see:
You could put this URL in a comment in the code as well.
Quoted 64 lines
Cc Peter Maydell <[email protected]>Cc Jason Wang <[email protected]>Cc Philippe Mathieu-Daudé <[email protected]>Signed-off-by Andrey Smirnov <[email protected]>--- hw/arm/Makefile.objs | 2 +- hw/arm/mcimx7d-sabre.c | 101 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 102 insertions(+), 1 deletion(-) create mode 100644 hw/arm/mcimx7d-sabre.chw/arm/Makefile.objs +1
-1@@ -19,5 +19,5 @@ obj-$(CONFIG_FSL_IMX31) += fsl-imx31.o kzm.o obj-$(CONFIG_FSL_IMX6) += fsl-imx6.o sabrelite.o obj-$(CONFIG_ASPEED_SOC) += aspeed_soc.o aspeed.o obj-$(CONFIG_MPS2) += mps2.o -obj-$(CONFIG_FSL_IMX7) += fsl-imx7.o +obj-$(CONFIG_FSL_IMX7) += fsl-imx7.o mcimx7d-sabre.ohw/arm/mcimx7d-sabre.c new file +34
-0@@ -0,0 +1,101 @@ +/* +* Copyright (c) 2017, Impinj, Inc. +* +* MCIMX7D_SABRE Board System emulation. +* +* Author: Andrey Smirnov <[email protected]> +* +* This code is licensed under the GPL, version 2 or later. +* See the file `COPYING' in the top level directory. +* +* It (partially) emulates a mcimx7d_sabre board, with a Freescale +* i.MX7 SoC +*/ + +#include "qemu/osdep.h" +#include "qapi/error.h" +#include "qemu-common.h" +#include "hw/arm/fsl-imx7.h" +#include "hw/boards.h" +#include "sysemu/sysemu.h" +#include "sysemu/device_tree.h" +#include "qemu/error-report.h" +#include "sysemu/qtest.h" +#include "net/net.h" + +typedef struct { +FslIMX7State soc; +MemoryRegion ram; +}MCIMX7Sabre ; + +static void mcimx7d_add_psci_node (const struct arm_boot_info *boot_info, +void *fdt) +{ +const char comp[] ="arm,psci-0.2\0arm,psci" ;
Quoted 8 lines
hw/arm/mcimx7d-sabre.c line 39
Quoted 5 lines
hw/arm/mcimx7d-sabre.c new file +5
-0+ +qemu_fdt_add_subnode (fdt,"/psci" ); +qemu_fdt_setprop (fdt,"/psci" ,"compatible" , comp,sizeof (comp)); +qemu_fdt_setprop_string (fdt,"/psci" ,"method" ,"smc" ); +}I'm still unconvinced by this (none of the other i.mx boards we have have anything like it).
None of the other boards are both SMP capable and support SMP in upstream Linux only through PSCI (as it the case for i.MX7), so comparing against the precedent is not very helpful.
Quoted 2 lines
How does the real hardware boot SMP ?
Real hardware executes a bootloader which is expected to implement PSCI and do the DTB fixup as I implemented above.
Thanks,
Andrey Smirnov
Quoted 3 lines · Andrey Smirnov
Hi everyone,
- Added proper USB emulation code, so now it should be possible to emulated guest's USB bus
The patchset is huge as it is, if you add more stuff to it it makes it even more likely to sink to the bottom of my to-review queue...
Quoted 9 lines
Peter, I didn't hear anything from you about the code of
mcimx7d_add_psci_node(), as discussed here:https://www.mail-archive.com/[email protected]/msg486874.html
so I kept the original code intact. As I mentioned before, my goal was to be able to boot into vanilla Linux kerenel and have working SMP without needing to use a PSCI implementing bootloader. If that is something that new board code shouldn't do, please let me know.
Broadly, board code should work the same way the real hardware does, unless there's a clear reason why not. "virt" is special because it writes its own dtb entirely.
Maybe PSCI does need to be a different special case, since we're emulating part of a bootloader here. But if so I think that code belongs more in hw/arm/boot.c, so that we automatically fix up the dtb to say "we have psci" if we are (a) booting a kernel directly and (b) the CPU has the psci-conduit property set to enable QEMU's PSCI implementation.
(Also the code in virt.c for adding a PSCI node is considerably fuller-featured than yours is.)
Quoted 7 lines
Thanks,
Andrey Smirnov[v2] https://lists.gnu.org/archive/html/qemu-devel/2017-10/msg05516.html
[v1] https://lists.gnu.org/archive/html/qemu-devel/2017-09/msg04770.html
Quoted 13 lines
Andrey Smirnov (30):
imx_fec: Do not link to netdev
imx_fec: Refactorimx_eth_enable_rx()
imx_fec: Change queue flushing heuristics
imx_fec: UseENET_FTRLto determine truncation length
imx_fec: Use MIN instead of explicit ternary operator
imx_fec: Emulate SHIFT16 inENETx_RACC
imx_fec: Add support for multiple Tx DMA rings
imx_fec: Use correct length for packet size
imx_fec: Fix a typo inimx_enet_receive()
imx_fec: Reserve full 4K page for the register file
sdhci: Add i.MX specific subtype of SDHCI
sdhci: Implement write method of ACMD12ERRSTS register
Everything above here is pretty nearly ready to go in; if you send that as a patchseries then it should be easy to review and queue ready for 2.12 (which will open up for new commits in mid-december).
Quoted 10 lines
i.MX: Add code to emulate i.MX7 CCM, PMU and ANALOG IP blocks i.MX: Add code to emulate i.MX2 watchdog IP block i.MX: Add code to emulate i.MX7 SNVS IP-block
i.MX: Add code to emulate GPCv2 IP block
i.MX: Add code to emulate i.MX7 IOMUXC IP block i.MX: Add i.MX7 GPT variant
i.MX: Add code to emulate SDMA IP block
i.MX: Add code to emulate FlexCAN IP block
i.MX: Add implementation of i.MX7 GPR IP block
pci: Add support for Designware IP block
Quoted 8 lines
i.MX: Add code to emulate i.MX7 USBMISC IP block i.MX: Add code to emulate i.MX7 ADC IP block i.MX: Add code to emulate i.MX7 SRC IP-block
usb: Add basic code to emulate Chipidea USB IP
ARM: Add basic code to emulate A7MPCore DAP block i.MX: Add code to emulate i.MX LCD block i.MX: Add i.MX7 SOC implementation. Implement support for i.MX7 Sabre board
My review in this part of the patchset is more sketchy, but you can probably adjust the later patches as per remarks on the earlier ones.
thanks
-- PMM
Quoted 9 lines · Peter Maydell
Quoted 3 lines · Andrey Smirnov
Hi everyone,
- Added proper USB emulation code, so now it should be possible to emulated guest's USB busThe patchset is huge as it is, if you add more stuff to it it makes it even more likely to sink to the bottom of my to-review queue...
USB peripheral emulation had to be a part of a patch-set, either in dummy or a full featured form, in order to be able to boot vanilla Linux kernel because you insisted that I don't use "ignore_memory_transaction_failures". The reason why the dummy emulation version of it it was not a part of v2 was because I did my test with a bad kernel config where USB was disabled, didn't realize USB was essential and did not write code to support it. Now, once I realized it, I wrote a dummy version, and then later, while waiting for v2 to be reviewed, worked on proper USB emulation the code. Said code turned out to be comparatively trivial to the first dummy implementation, so instead of going through the exercise of submitting dummy first and then proper version later I squashed both and the result in v3.
Quoted 5 lines
Quoted 5 lines
Peter, I didn't hear anything from you about the code of
mcimx7d_add_psci_node(), as discussed here:https://www.mail-archive.com/[email protected]/msg486874.html
Quoted 7 lines
Quoted 4 lines
so I kept the original code intact. As I mentioned before, my goal was to be able to boot into vanilla Linux kerenel and have working SMP without needing to use a PSCI implementing bootloader. If that is something that new board code shouldn't do, please let me know.
Broadly, board code should work the same way the real hardware does, unless there's a clear reason why not.
Yes, this all makes sense. As far as I understand convenience being able to boot Linux directly in QEMU has long been the "clear reason why not". Now that certain SoC specific versions of Linux are not as self-sufficient and can't support SMP without external help, emulating PSCI and doing appropriate DTB fixups for that is just an adaptaion of the old convenience mechanism to new times and circumstances, IMHO.
Quoted 4 lines
"virt" is special because it writes its own dtb entirely.
Maybe PSCI does need to be a different special case, since we're emulating part of a bootloader here.
OK, I'll ignore the "maybe" part and proceed as if we are in agreement on PSCI for v4.
Quoted 5 lines
But if so I think that code belongs more in
hw/arm/boot.c, so that we automatically fix up the dtb to say "we have psci" if we are (a) booting a kernel directly
and (b) the CPU has the psci-conduit property set to enable QEMU's
PSCI implementation.
OK, sure, makes sense. I'll change the patch to use shared infrastructure for that.
Quoted 3 lines
(Also the code in
virt.cfor adding a PSCI node is considerably fuller-featured than yours is.)
Okay... My code is targeting both fixed PSCI conduit (smc) and PSCI implementation (0.2/1.0), implementing support for anything but that in my board specific code would've been, IMHO, silly. OK, I'll interpret that comment not as a slight, but as a request to use virt.c's implementation for shared infrastructure.
Quoted 21 lines
Quoted 7 lines
Thanks,
Andrey Smirnov[v2] https://lists.gnu.org/archive/html/qemu-devel/2017-10/msg05516.html
[v1] https://lists.gnu.org/archive/html/qemu-devel/2017-09/msg04770.htmlQuoted 13 lines
Andrey Smirnov (30):
imx_fec: Do not link to netdev
imx_fec: Refactorimx_eth_enable_rx()
imx_fec: Change queue flushing heuristics
imx_fec: UseENET_FTRLto determine truncation length
imx_fec: Use MIN instead of explicit ternary operator
imx_fec: Emulate SHIFT16 inENETx_RACC
imx_fec: Add support for multiple Tx DMA rings
imx_fec: Use correct length for packet size
imx_fec: Fix a typo inimx_enet_receive()
imx_fec: Reserve full 4K page for the register file
sdhci: Add i.MX specific subtype of SDHCI
sdhci: Implement write method of ACMD12ERRSTS register
Quoted 5 lines
Everything above here is pretty nearly ready to go in; if you send that as a patchseries then it should be easy to review and queue ready for 2.12 (which will open up for new commits in mid-december).
I'm not quite sure where you stand on "imx_fec: Use ENET_FTRL to determine truncation length", but sure, sounds good, I'll prepare the rest of them as a separate patch set and submit it, as soon as I get a chance.
Quoted 19 lines
Quoted 10 lines
i.MX: Add code to emulate i.MX7 CCM, PMU and ANALOG IP blocks i.MX: Add code to emulate i.MX2 watchdog IP block i.MX: Add code to emulate i.MX7 SNVS IP-block
i.MX: Add code to emulate GPCv2 IP block
i.MX: Add code to emulate i.MX7 IOMUXC IP block i.MX: Add i.MX7 GPT variant
i.MX: Add code to emulate SDMA IP block
i.MX: Add code to emulate FlexCAN IP block
i.MX: Add implementation of i.MX7 GPR IP block
pci: Add support for Designware IP blockQuoted 8 lines
i.MX: Add code to emulate i.MX7 USBMISC IP block i.MX: Add code to emulate i.MX7 ADC IP block i.MX: Add code to emulate i.MX7 SRC IP-block
usb: Add basic code to emulate Chipidea USB IP
ARM: Add basic code to emulate A7MPCore DAP block i.MX: Add code to emulate i.MX LCD block i.MX: Add i.MX7 SOC implementation. Implement support for i.MX7 Sabre board
Quoted 4 lines
My review in this part of the patchset is more sketchy, but you can probably adjust the later patches as per remarks on the earlier ones.
OK, no problem. I am fine on iterating on the rest of the series until it's in good shape.
Thanks,
Andrey Smirnov