stm32l4x5_usart.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. /*
  2. * STM32L4X5 USART (Universal Synchronous Asynchronous Receiver Transmitter)
  3. *
  4. * Copyright (c) 2023 Arnaud Minier <arnaud.minier@telecom-paris.fr>
  5. * Copyright (c) 2023 Inès Varhol <ines.varhol@telecom-paris.fr>
  6. *
  7. * SPDX-License-Identifier: GPL-2.0-or-later
  8. *
  9. * This work is licensed under the terms of the GNU GPL, version 2 or later.
  10. * See the COPYING file in the top-level directory.
  11. *
  12. * The STM32L4X5 USART is heavily inspired by the stm32f2xx_usart
  13. * by Alistair Francis.
  14. * The reference used is the STMicroElectronics RM0351 Reference manual
  15. * for STM32L4x5 and STM32L4x6 advanced Arm ® -based 32-bit MCUs.
  16. */
  17. #ifndef HW_STM32L4X5_USART_H
  18. #define HW_STM32L4X5_USART_H
  19. #include "hw/sysbus.h"
  20. #include "chardev/char-fe.h"
  21. #include "qom/object.h"
  22. #define TYPE_STM32L4X5_USART_BASE "stm32l4x5-usart-base"
  23. #define TYPE_STM32L4X5_USART "stm32l4x5-usart"
  24. #define TYPE_STM32L4X5_UART "stm32l4x5-uart"
  25. #define TYPE_STM32L4X5_LPUART "stm32l4x5-lpuart"
  26. OBJECT_DECLARE_TYPE(Stm32l4x5UsartBaseState, Stm32l4x5UsartBaseClass,
  27. STM32L4X5_USART_BASE)
  28. typedef enum {
  29. STM32L4x5_USART,
  30. STM32L4x5_UART,
  31. STM32L4x5_LPUART,
  32. } Stm32l4x5UsartType;
  33. struct Stm32l4x5UsartBaseState {
  34. SysBusDevice parent_obj;
  35. MemoryRegion mmio;
  36. uint32_t cr1;
  37. uint32_t cr2;
  38. uint32_t cr3;
  39. uint32_t brr;
  40. uint32_t gtpr;
  41. uint32_t rtor;
  42. /* rqr is write-only */
  43. uint32_t isr;
  44. /* icr is a clear register */
  45. uint32_t rdr;
  46. uint32_t tdr;
  47. Clock *clk;
  48. CharBackend chr;
  49. qemu_irq irq;
  50. guint watch_tag;
  51. };
  52. struct Stm32l4x5UsartBaseClass {
  53. SysBusDeviceClass parent_class;
  54. Stm32l4x5UsartType type;
  55. };
  56. #endif /* HW_STM32L4X5_USART_H */