Initial i.MX7 support
v2 cover Initial i.MX7 support
Hi everyone,
This v2 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
Feedback is welcome!
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
[v1] https://lists.gnu.org/archive/html/qemu-devel/2017-09/msg04770.html
P.S.: I don't know the best way to specify mailing list message archives, so if I did it wrong please let me know.
Andrey Smirnov (27):
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
i.MX: Add i.MX7 SOC implementation.
Implement support for i.MX7 Sabre board
default-configs/arm-softmmu.mak | 3 + hw/arm/Makefile.objs | 2 + hw/arm/fsl-imx6.c | 1 + hw/arm/fsl-imx7.c | 596 +++++++++++++++++++++++++++++++++++++ hw/arm/mcimx7d-sabre.c | 101 +++++++ 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 | 1 + hw/usb/imx-usbmisc.c | 99 +++++++ include/hw/arm/fsl-imx7.h | 217 ++++++++++++++ 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/imx-usbmisc.h | 22 ++ 43 files changed, 3581 insertions(+), 44 deletions(-) create mode 100644 hw/arm/fsl-imx7.c create mode 100644 hw/arm/mcimx7d-sabre.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/imx-usbmisc.c create mode 100644 include/hw/arm/fsl-imx7.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/imx-usbmisc.h
Signature · 1 line
2.13.5
PATCH v2 1/27 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.5
PATCH v2 2/27 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.5
PATCH v2 3/27 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.5
PATCH v2 4/27 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.5
PATCH v2 5/27 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.5
PATCH v2 6/27 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.5
PATCH v2 7/27 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.5
PATCH v2 8/27 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.5
PATCH v2 9/27 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.5
PATCH v2 10/27 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.5
PATCH v2 11/27 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.5
PATCH v2 12/27 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.5
PATCH v2 13/27 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.5
PATCH v2 14/27 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.5
PATCH v2 15/27 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.5
PATCH v2 16/27 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.5
PATCH v2 17/27 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.5
PATCH v2 19/27 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.5
PATCH v2 20/27 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.5
PATCH v2 21/27 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.5
PATCH v2 22/27 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.5
PATCH v2 23/27 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.5
PATCH v2 24/27 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.5
PATCH v2 26/27 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 | 596 ++++++++++++++++++++++++++++++++++++++++ include/hw/arm/fsl-imx7.h | 217 +++++++++++++++ 4 files changed, 816 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 +596 -0
596 lines not on this page · raw message
include/hw/arm/fsl-imx7.h new file +217 -0
217 lines not on this page · raw message
Signature · 1 line
2.13.5