Re: [PATCH 0/2] Implement something

2022-11-29 Thread Evgeny Ermakov
Evgeny Ermakov  writes:

Oops, sorry. Ignore this, I sent it by mistake.

> Hello!
>
> Evgeny Ermakov (2):
>   hw/char: Add STM32F7 peripheral: USART
>   hw/input: Add FT5336 touch controller
>
>  include/hw/char/stm32f7xx_usart.h |  30 +++
>  include/hw/input/ft5336.h |  14 ++
>  hw/char/stm32f7xx_usart.c | 361 ++
>  hw/input/ft5336.c | 357 +
>  hw/arm/Kconfig|   1 +
>  hw/char/Kconfig   |   3 +
>  hw/char/meson.build   |   1 +
>  hw/char/trace-events  |   4 +
>  hw/input/Kconfig  |   4 +
>  hw/input/meson.build  |   2 +
>  10 files changed, 777 insertions(+)
>  create mode 100644 include/hw/char/stm32f7xx_usart.h
>  create mode 100644 include/hw/input/ft5336.h
>  create mode 100644 hw/char/stm32f7xx_usart.c
>  create mode 100644 hw/input/ft5336.c
>
> -- 
> 2.38.1



[PATCH 1/2] hw/char: Add STM32F7 peripheral: USART

2022-11-29 Thread Evgeny Ermakov
Signed-off-by: Evgeny Ermakov 
---
 include/hw/char/stm32f7xx_usart.h |  30 +++
 hw/char/stm32f7xx_usart.c | 361 ++
 hw/arm/Kconfig|   1 +
 hw/char/Kconfig   |   3 +
 hw/char/meson.build   |   1 +
 hw/char/trace-events  |   4 +
 6 files changed, 400 insertions(+)
 create mode 100644 include/hw/char/stm32f7xx_usart.h
 create mode 100644 hw/char/stm32f7xx_usart.c

diff --git a/include/hw/char/stm32f7xx_usart.h 
b/include/hw/char/stm32f7xx_usart.h
new file mode 100644
index 00..ec005be8d8
--- /dev/null
+++ b/include/hw/char/stm32f7xx_usart.h
@@ -0,0 +1,30 @@
+/*
+ * STM32F7XX Universal synchronous/asynchronous receiver transmitter (USART)
+ *
+ * Copyright (c) 2022 Evgeny Ermakov 
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+#ifndef HW_CHAR_STM32F7XX_USART_H
+#define HW_CHAR_STM32F7XX_USART_H
+
+#include "hw/arm/stm32f.h"
+#include "chardev/char-fe.h"
+
+#define TYPE_STM32F7XX_USART "stm32f7xx-usart"
+OBJECT_DECLARE_SIMPLE_TYPE(STM32F7XXUSARTState, STM32F7XX_USART)
+
+#define STM32F7XX_USART_R_MAX 11
+
+struct STM32F7XXUSARTState {
+/*< private >*/
+STM32FPeripheralState parent_obj;
+
+uint32_t regs[STM32F7XX_USART_R_MAX];
+
+CharBackend chr;
+qemu_irq irq;
+};
+
+#endif /* HW_CHAR_STM32F7XX_USART_H */
diff --git a/hw/char/stm32f7xx_usart.c b/hw/char/stm32f7xx_usart.c
new file mode 100644
index 00..122781705a
--- /dev/null
+++ b/hw/char/stm32f7xx_usart.c
@@ -0,0 +1,361 @@
+/*
+ * STM32F7XX Universal synchronous/asynchronous receiver transmitter (USART)
+ *
+ * Reference documents:
+ *   - Reference manual RM0385
+ *   "STM32F75xxx and stm32f74xxx advanced Arm(R)-based 32-bit MCUs"
+ *   - Reference manual RM0410
+ *   "STM32F76xxx and STM32F77xxx advanced Arm(R)-based 32-bit MCUs"
+ *
+ * Copyright (c) 2022 Evgeny Ermakov 
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+#include "qemu/osdep.h"
+#include "hw/char/stm32f7xx_usart.h"
+#include "hw/irq.h"
+#include "hw/qdev-properties-system.h"
+#include "hw/registerfields.h"
+#include "migration/vmstate.h"
+#include "qemu/log.h"
+#include "trace.h"
+
+#ifndef STM_USART_ERR_DEBUG
+#define STM_USART_ERR_DEBUG 0
+#endif
+
+#define DB_PRINT_L(lvl, fmt, args...)   \
+do {\
+if (STM_USART_ERR_DEBUG >= lvl) {   \
+qemu_log("%s: " fmt, __func__, ## args);\
+}   \
+} while (0)
+
+#define DB_PRINT(fmt, args...) DB_PRINT_L(1, fmt, ## args)
+
+REG32(CR1, 0x00)
+/* reserved: 31:29, 1 */
+FIELD(CR1,M1, 28, 1)
+FIELD(CR1,EOBIE,  27, 1)
+FIELD(CR1,RTOIE,  26, 1)
+FIELD(CR1,DEAT,   21, 5)
+FIELD(CR1,DEDT,   16, 5)
+FIELD(CR1,OVER8,  15, 1)
+FIELD(CR1,CMIE,   14, 1)
+FIELD(CR1,MME,13, 1)
+FIELD(CR1,M0, 12, 1)
+FIELD(CR1,WAKE,   11, 1)
+FIELD(CR1,PCE,10, 1)
+FIELD(CR1,PS,  9, 1)
+FIELD(CR1,PEIE,8, 1)
+FIELD(CR1,TXEIE,   7, 1)
+FIELD(CR1,TCIE,6, 1)
+FIELD(CR1,RXNEIE,  5, 1)
+FIELD(CR1,IDLEIE,  4, 1)
+FIELD(CR1,TE,  3, 1)
+FIELD(CR1,RE,  2, 1)
+FIELD(CR1,UE,  0, 1)
+REG32(CR2, 0x04)
+/* reserved: 7, 3:0 */
+FIELD(CR2,ADD,24, 8)
+FIELD(CR2,RTOEN,  23, 1)
+FIELD(CR2,ABRMOD, 21, 2)
+FIELD(CR2,ABREN,  20, 1)
+FIELD(CR2,MSBFIRST,   19, 1)
+FIELD(CR2,DATAINV,18, 1)
+FIELD(CR2,TXINV,  17, 1)
+FIELD(CR2,RXINV,  16, 1)
+FIELD(CR2,SWAP,   15, 1)
+FIELD(CR2,LINEN,  14, 1)
+FIELD(CR2,STOP,   12, 2)
+FIELD(CR2,CLKEN,  11, 1)
+FIELD(CR2,CPOL,   10, 1)
+FIELD(CR2,CPHA,9, 1)
+FIELD(CR2,LBCL,8, 1)
+FIELD(CR2,LBDIE,   6, 1)
+FIELD(CR2,LBDL,5, 1)
+FIELD(CR2,ADDM7,   4, 1)
+REG32(CR3, 0x08)
+/* reserved: 31:25, 16 */
+FIELD(CR3,TCBGTIE,24, 1)
+FIELD(CR3,UCESM,  23, 1)
+FIELD(CR3,WUFIE,  22, 1)
+FIELD(CR3,WUS,20, 2)
+FIELD(CR3,SCARCNT,17, 3)
+FIELD(CR3,DEP,15, 1)
+FIELD(CR3,   

[PATCH 0/2] Implement something

2022-11-29 Thread Evgeny Ermakov
Hello!

Evgeny Ermakov (2):
  hw/char: Add STM32F7 peripheral: USART
  hw/input: Add FT5336 touch controller

 include/hw/char/stm32f7xx_usart.h |  30 +++
 include/hw/input/ft5336.h |  14 ++
 hw/char/stm32f7xx_usart.c | 361 ++
 hw/input/ft5336.c | 357 +
 hw/arm/Kconfig|   1 +
 hw/char/Kconfig   |   3 +
 hw/char/meson.build   |   1 +
 hw/char/trace-events  |   4 +
 hw/input/Kconfig  |   4 +
 hw/input/meson.build  |   2 +
 10 files changed, 777 insertions(+)
 create mode 100644 include/hw/char/stm32f7xx_usart.h
 create mode 100644 include/hw/input/ft5336.h
 create mode 100644 hw/char/stm32f7xx_usart.c
 create mode 100644 hw/input/ft5336.c

-- 
2.38.1




[PATCH 2/2] hw/input: Add FT5336 touch controller

2022-11-29 Thread Evgeny Ermakov
Signed-off-by: Evgeny Ermakov 
---
 include/hw/input/ft5336.h |  14 ++
 hw/input/ft5336.c | 357 ++
 hw/input/Kconfig  |   4 +
 hw/input/meson.build  |   2 +
 4 files changed, 377 insertions(+)
 create mode 100644 include/hw/input/ft5336.h
 create mode 100644 hw/input/ft5336.c

diff --git a/include/hw/input/ft5336.h b/include/hw/input/ft5336.h
new file mode 100644
index 00..7bef3f9efb
--- /dev/null
+++ b/include/hw/input/ft5336.h
@@ -0,0 +1,14 @@
+/*
+ * FT5336 touch controller
+ *
+ * Copyright (c) 2022 Evgeny Ermakov 
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+#ifndef HW_INPUT_FT5336_H
+#define HW_INPUT_FT5336_H
+
+#define TYPE_FT5336 "ft5336"
+
+#endif
diff --git a/hw/input/ft5336.c b/hw/input/ft5336.c
new file mode 100644
index 00..bacf79201a
--- /dev/null
+++ b/hw/input/ft5336.c
@@ -0,0 +1,357 @@
+/*
+ * FT5336 touch controller
+ *
+ * Copyright (c) 2022 Evgeny Ermakov 
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+#include "qemu/osdep.h"
+#include "hw/input/ft5336.h"
+#include "hw/i2c/i2c.h"
+#include "hw/irq.h"
+#include "migration/vmstate.h"
+#include "qemu/module.h"
+#include "qemu/log.h"
+#include "qemu/timer.h"
+#include "ui/input.h"
+#include "qom/object.h"
+
+OBJECT_DECLARE_SIMPLE_TYPE(FT5336TouchState, FT5336)
+
+struct FT5336TouchState {
+I2CSlave parent_obj;
+
+uint8_t i2c_cycle;
+uint8_t reg;
+
+qemu_irq irq;
+
+int32_t abs_x;
+int32_t abs_y;
+uint16_t touch_x;
+uint16_t touch_y;
+bool touch_press;
+
+bool inte;
+};
+
+/* I2C Slave address of touchscreen FocalTech FT5336 */
+#define FT5336_I2C_SLAVE_ADDRESS0x70
+
+/* Maximum border values of the touchscreen pad */
+#define FT5336_MAX_WIDTH((uint16_t)480) /* Touchscreen 
pad max width   */
+#define FT5336_MAX_HEIGHT   ((uint16_t)272) /* Touchscreen 
pad max height  */
+
+/* Max detectable simultaneous touches */
+#define FT5336_MAX_DETECTABLE_TOUCH 0x05
+
+
+enum {
+FT5336_P_XH   = 0x00,
+FT5336_P_XL   = 0x01,
+FT5336_P_YH   = 0x02,
+FT5336_P_YL   = 0x03,
+   /* Values Pn_XH and Pn_YH related */
+#define FT5336_TOUCH_EVT_FLAG_PRESS_DOWN0x00
+#define FT5336_TOUCH_EVT_FLAG_LIFT_UP   0x01
+#define FT5336_TOUCH_EVT_FLAG_CONTACT   0x02
+#define FT5336_TOUCH_EVT_FLAG_NO_EVENT  0x03
+
+FT5336_P_WEIGHT   = 0x04,
+/* Values Pn_WEIGHT related  */
+#define FT5336_TOUCH_WEIGHT_MASK0xFF
+#define FT5336_TOUCH_WEIGHT_SHIFT   0x00
+
+FT5336_P_MISC = 0x05
+/* Values related to FT5336_Pn_MISC_REG */
+#define FT5336_TOUCH_AREA_MASK  (0x04 << 4))
+#define FT5336_TOUCH_AREA_SHIFT 0x04
+};
+
+enum {
+FT5336_R_MODE   = 0x00,
+#define FT5336_DEV_MODE_WORKING 0x00
+#define FT5336_DEV_MODE_FACTORY 0x04
+
+#define FT5336_DEV_MODE_MASK0x07
+#define FT5336_DEV_MODE_SHIFT   0x04
+
+FT5336_R_GEST_ID= 0x01,
+#define FT5336_GEST_ID_NO_GESTURE   0x00
+#define FT5336_GEST_ID_MOVE_UP  0x10
+#define FT5336_GEST_ID_MOVE_RIGHT   0x14
+#define FT5336_GEST_ID_MOVE_DOWN0x18
+#define FT5336_GEST_ID_MOVE_LEFT0x1C
+#define FT5336_GEST_ID_SINGLE_CLICK 0x20
+#define FT5336_GEST_ID_DOUBLE_CLICK 0x22
+#define FT5336_GEST_ID_ROTATE_CLOCKWISE 0x28
+#define FT5336_GEST_ID_ROTATE_C_CLOCKWISE   0x29
+#define FT5336_GEST_ID_ZOOM_IN  0x40
+#define FT5336_GEST_ID_ZOOM_OUT 0x49
+
+FT5336_R_STAT   = 0x02,
+#define FT5336_TD_STAT_MASK 0x0F
+#define FT5336_TD_STAT_SHIFT0x00
+
+FT5336_R_P1_BASE= 0x03,
+FT5336_R_P2_BASE= 0x09,
+FT5336_R_P3_BASE= 0x0f,
+FT5336_R_P4_BASE= 0x15,
+FT5336_R_P5_BASE= 0x1b,
+FT5336_R_P6_BASE= 0x21,
+FT5336_R_P7_BASE= 0x27,
+FT5336_R_P8_BASE= 0x2d,
+FT5336_R_P9_BASE= 0x33,
+FT5336_R_P10_BASE   = 0x39,
+
+#define FT5336_TOUCH_EVT_FLAG_SHIFT 0x06
+#define FT5336_TOUCH_EVT_FLAG_MASK  (3 << FT5336_TOUCH_EVT_FLAG_SHIFT))
+
+#define FT5336_TOUCH_POS_MSB_MASK   0x0F
+#define FT5336_TOUCH_POS_MSB_SHIFT  0x00
+
+/* Values Pn_XL and Pn_YL related */
+#define FT5336_TOUCH_POS_LSB_MASK   0xFF
+#define FT5336_TOUCH_POS_LSB_SHIFT  0x00
+
+FT5336_R_TH_GROUP   = 0x80,
+/* Values FT5336_TH_GROUP_REG : threshold related  */
+#define FT5336_THRESHOLD_MASK   0xFF
+#define FT5336_THRESHOLD_SHIFT  0x00
+
+FT5336_R_TH_DIFF= 0x85,
+
+   

Re: [PATCH for-7.2] target/arm: Set TCGCPUOps.restore_state_to_opc for v7m

2022-11-29 Thread Evgeny Ermakov
Signed-off-by: Evgeny Ermakov 
---




[PATCH] hw/display/next-fb: Fix comment typo

2022-11-25 Thread Evgeny Ermakov
Signed-off-by: Evgeny Ermakov 
---
 hw/display/next-fb.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/hw/display/next-fb.c b/hw/display/next-fb.c
index dd6a1aa8ae..8446ff3c00 100644
--- a/hw/display/next-fb.c
+++ b/hw/display/next-fb.c
@@ -126,7 +126,7 @@ static void nextfb_class_init(ObjectClass *oc, void *data)
 set_bit(DEVICE_CATEGORY_DISPLAY, dc->categories);
 dc->realize = nextfb_realize;
 
-/* Note: This device does not any state that we have to reset or migrate */
+/* Note: This device does not have any state that we have to reset or 
migrate */
 }
 
 static const TypeInfo nextfb_info = {
-- 
2.38.1




Re: [PATCH] hw/intc/armv7m_nvic: Fix typo in comment

2022-02-25 Thread Evgeny Ermakov
Ah, indeed.

Sorry for having bothered you.


On Thu, 24 Feb 2022, 23:46 Peter Maydell,  wrote:

> On Thu, 24 Feb 2022 at 12:22, Evgeny Ermakov 
> wrote:
> >
> > Signed-off-by: Evgeny Ermakov 
> > ---
> >  hw/intc/armv7m_nvic.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/hw/intc/armv7m_nvic.c b/hw/intc/armv7m_nvic.c
> > index 13df002ce4..a08a0fdc50 100644
> > --- a/hw/intc/armv7m_nvic.c
> > +++ b/hw/intc/armv7m_nvic.c
> > @@ -97,7 +97,7 @@ static int nvic_pending_prio(NVICState *s)
> >   * this is only different in the obscure corner case where guest
> >   * code has manually deactivated an exception and is about
> >   * to fail an exception-return integrity check. The definition
> > - * above is the one from the v8M ARM ARM and is also in line
> > + * above is the one from the v8M ARM and is also in line
> >   * with the behaviour documented for the Cortex-M3.
> >   */
>
> This is not a typo. The "ARM ARM" (or "Arm ARM" these days if
> you want to follow the official corporate name capitalization)
> is the standard abbreviated way to refer to the
> Arm Architecture Reference Manual. "git grep -i 'arm arm'"
> finds over 50 uses of it in various comments.
>
> thanks
> -- PMM
>


[PATCH] hw/intc/armv7m_nvic: Fix typo in comment

2022-02-24 Thread Evgeny Ermakov
Signed-off-by: Evgeny Ermakov 
---
 hw/intc/armv7m_nvic.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/hw/intc/armv7m_nvic.c b/hw/intc/armv7m_nvic.c
index 13df002ce4..a08a0fdc50 100644
--- a/hw/intc/armv7m_nvic.c
+++ b/hw/intc/armv7m_nvic.c
@@ -97,7 +97,7 @@ static int nvic_pending_prio(NVICState *s)
  * this is only different in the obscure corner case where guest
  * code has manually deactivated an exception and is about
  * to fail an exception-return integrity check. The definition
- * above is the one from the v8M ARM ARM and is also in line
+ * above is the one from the v8M ARM and is also in line
  * with the behaviour documented for the Cortex-M3.
  */
 static bool nvic_rettobase(NVICState *s)
-- 
2.35.1