diff options
author | Peter Maydell | 2018-03-19 20:20:45 +0100 |
---|---|---|
committer | Peter Maydell | 2018-03-19 20:20:45 +0100 |
commit | c26ef39204f3200efe89470f6b21ac783edadd29 (patch) | |
tree | 092ec87be2c37ebc77edf4c5cb59751c78c3839f /hw/char/imx_serial.c | |
parent | Merge remote-tracking branch 'remotes/kevin/tags/for-upstream' into staging (diff) | |
parent | hw/arm/raspi: Provide spin-loop code for AArch64 CPUs (diff) | |
download | qemu-c26ef39204f3200efe89470f6b21ac783edadd29.tar.gz qemu-c26ef39204f3200efe89470f6b21ac783edadd29.tar.xz qemu-c26ef39204f3200efe89470f6b21ac783edadd29.zip |
Merge remote-tracking branch 'remotes/pmaydell/tags/pull-target-arm-20180319' into staging
target-arm queue:
* fsl-imx6: Fix incorrect Ethernet interrupt defines
* dump: Update correct kdump phys_base field for AArch64
* char: i.MX: Add support for "TX complete" interrupt
* bcm2836/raspi: Fix various bugs resulting in panics trying
to boot a Debian Linux kernel on raspi3
# gpg: Signature made Mon 19 Mar 2018 18:30:33 GMT
# gpg: using RSA key 3C2525ED14360CDE
# gpg: Good signature from "Peter Maydell <peter.maydell@linaro.org>"
# gpg: aka "Peter Maydell <pmaydell@gmail.com>"
# gpg: aka "Peter Maydell <pmaydell@chiark.greenend.org.uk>"
# Primary key fingerprint: E1A5 C593 CD41 9DE2 8E83 15CF 3C25 25ED 1436 0CDE
* remotes/pmaydell/tags/pull-target-arm-20180319:
hw/arm/raspi: Provide spin-loop code for AArch64 CPUs
hw/arm/bcm2836: Hardcode correct CPU type
hw/arm/bcm2836: Use correct affinity values for BCM2837
hw/arm/bcm2836: Create proper bcm2837 device
hw/arm/bcm2836: Rename bcm2836 type/struct to bcm283x
hw/arm/bcm2386: Fix parent type of bcm2386
hw/arm/boot: If booting a kernel in EL2, set SCR_EL3.HCE
hw/arm/boot: assert that secure_boot and secure_board_setup are false for AArch64
hw/arm/raspi: Don't do board-setup or secure-boot for raspi3
char: i.MX: Add support for "TX complete" interrupt
char: i.MX: Simplify imx_update()
dump: Update correct kdump phys_base field for AArch64
fsl-imx6: Swap Ethernet interrupt defines
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'hw/char/imx_serial.c')
-rw-r--r-- | hw/char/imx_serial.c | 44 |
1 files changed, 33 insertions, 11 deletions
diff --git a/hw/char/imx_serial.c b/hw/char/imx_serial.c index 70405ccf8b..1e5540472b 100644 --- a/hw/char/imx_serial.c +++ b/hw/char/imx_serial.c @@ -37,8 +37,8 @@ static const VMStateDescription vmstate_imx_serial = { .name = TYPE_IMX_SERIAL, - .version_id = 1, - .minimum_version_id = 1, + .version_id = 2, + .minimum_version_id = 2, .fields = (VMStateField[]) { VMSTATE_INT32(readbuff, IMXSerialState), VMSTATE_UINT32(usr1, IMXSerialState), @@ -50,22 +50,36 @@ static const VMStateDescription vmstate_imx_serial = { VMSTATE_UINT32(ubmr, IMXSerialState), VMSTATE_UINT32(ubrc, IMXSerialState), VMSTATE_UINT32(ucr3, IMXSerialState), + VMSTATE_UINT32(ucr4, IMXSerialState), VMSTATE_END_OF_LIST() }, }; static void imx_update(IMXSerialState *s) { - uint32_t flags; + uint32_t usr1; + uint32_t usr2; + uint32_t mask; - flags = (s->usr1 & s->ucr1) & (USR1_TRDY|USR1_RRDY); - if (s->ucr1 & UCR1_TXMPTYEN) { - flags |= (s->uts1 & UTS1_TXEMPTY); - } else { - flags &= ~USR1_TRDY; - } + /* + * Lucky for us TRDY and RRDY has the same offset in both USR1 and + * UCR1, so we can get away with something as simple as the + * following: + */ + usr1 = s->usr1 & s->ucr1 & (USR1_TRDY | USR1_RRDY); + /* + * Bits that we want in USR2 are not as conveniently laid out, + * unfortunately. + */ + mask = (s->ucr1 & UCR1_TXMPTYEN) ? USR2_TXFE : 0; + /* + * TCEN and TXDC are both bit 3 + */ + mask |= s->ucr4 & UCR4_TCEN; - qemu_set_irq(s->irq, !!flags); + usr2 = s->usr2 & mask; + + qemu_set_irq(s->irq, usr1 || usr2); } static void imx_serial_reset(IMXSerialState *s) @@ -155,6 +169,8 @@ static uint64_t imx_serial_read(void *opaque, hwaddr offset, return s->ucr3; case 0x23: /* UCR4 */ + return s->ucr4; + case 0x29: /* BRM Incremental */ return 0x0; /* TODO */ @@ -183,8 +199,10 @@ static void imx_serial_write(void *opaque, hwaddr offset, * qemu_chr_fe_write and background I/O callbacks */ qemu_chr_fe_write_all(&s->chr, &ch, 1); s->usr1 &= ~USR1_TRDY; + s->usr2 &= ~USR2_TXDC; imx_update(s); s->usr1 |= USR1_TRDY; + s->usr2 |= USR2_TXDC; imx_update(s); } break; @@ -257,8 +275,12 @@ static void imx_serial_write(void *opaque, hwaddr offset, s->ucr3 = value & 0xffff; break; - case 0x2d: /* UTS1 */ case 0x23: /* UCR4 */ + s->ucr4 = value & 0xffff; + imx_update(s); + break; + + case 0x2d: /* UTS1 */ qemu_log_mask(LOG_UNIMP, "[%s]%s: Unimplemented reg 0x%" HWADDR_PRIx "\n", TYPE_IMX_SERIAL, __func__, offset); /* TODO */ |