stm32l4x5_gpio.h 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /*
  2. * STM32L4x5 GPIO (General Purpose Input/Ouput)
  3. *
  4. * Copyright (c) 2024 Arnaud Minier <arnaud.minier@telecom-paris.fr>
  5. * Copyright (c) 2024 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. /*
  13. * The reference used is the STMicroElectronics RM0351 Reference manual
  14. * for STM32L4x5 and STM32L4x6 advanced Arm ® -based 32-bit MCUs.
  15. * https://www.st.com/en/microcontrollers-microprocessors/stm32l4x5/documentation.html
  16. */
  17. #ifndef HW_STM32L4X5_GPIO_H
  18. #define HW_STM32L4X5_GPIO_H
  19. #include "hw/sysbus.h"
  20. #include "qom/object.h"
  21. #define TYPE_STM32L4X5_GPIO "stm32l4x5-gpio"
  22. OBJECT_DECLARE_SIMPLE_TYPE(Stm32l4x5GpioState, STM32L4X5_GPIO)
  23. #define NUM_GPIOS 8
  24. #define GPIO_NUM_PINS 16
  25. struct Stm32l4x5GpioState {
  26. SysBusDevice parent_obj;
  27. MemoryRegion mmio;
  28. /* GPIO registers */
  29. uint32_t moder;
  30. uint32_t otyper;
  31. uint32_t ospeedr;
  32. uint32_t pupdr;
  33. uint32_t idr;
  34. uint32_t odr;
  35. uint32_t lckr;
  36. uint32_t afrl;
  37. uint32_t afrh;
  38. uint32_t ascr;
  39. /* GPIO registers reset values */
  40. uint32_t moder_reset;
  41. uint32_t ospeedr_reset;
  42. uint32_t pupdr_reset;
  43. /*
  44. * External driving of pins.
  45. * The pins can be set externally through the device
  46. * anonymous input GPIOs lines under certain conditions.
  47. * The pin must not be in push-pull output mode,
  48. * and can't be set high in open-drain mode.
  49. * Pins driven externally and configured to
  50. * output mode will in general be "disconnected"
  51. * (see `get_gpio_pinmask_to_disconnect()`)
  52. */
  53. uint16_t disconnected_pins;
  54. uint16_t pins_connected_high;
  55. char *name;
  56. Clock *clk;
  57. qemu_irq pin[GPIO_NUM_PINS];
  58. };
  59. #endif