Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

arm64/pinephone: Add driver for PinePhone Touch Panel #25

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 35 additions & 9 deletions Documentation/platforms/arm/a64/boards/pinephone/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ Features
- **GPU:** ARM Mali400 MP2
- **Interrupt Controller:** ARM GIC PL400 (Generic Interrupt Controller v2)
- **Display Engine:** Allwinner Display Engine 2.0 (MIPI DSI with DMA)
- **Display:** Xingbangda XBD599 HD IPS Capacitive Touchscreen (5.95 inches, 1440x720 resolution, 16M colors, PWM Backlight)
- **Display:** Xingbangda XBD599 HD IPS Display (5.95 inches, 1440x720 resolution, 16M colors, PWM Backlight)
- **Touch Panel:** Goodix GT917S Capacitive Touch Panel (I2C)
- **LCD Controller:** Sitronix ST7703 (MIPI DSI)
- **RAM:** 2GB or 3GB LPDDR3 SDRAM
- **Internal Storage:** 16GB or 32GB eMMC, extendable up to 2TB via microSD
Expand All @@ -25,7 +26,9 @@ Features
- 2.4 GHz Wireless: Realtek RTL8723CS
- **WLAN:** WiFi 802.11 b/g/n, single-band, hotspot
- **Bluetooth:** 4.0, A2DP
- **Sensors:** Accelerometer, Gyroscope, Proximity, Ambient Light, Compass
- **Magnetometer:** STMicroelectronics LIS3MDL
- **Ambient Light / Proximity:** SensorTek STK3335
- **Accelerometer / Gyroscope:** InvenSense MPU-6050 (I2C)
- **Privacy Switches:** Modem, WiFi & Bluetooth, Microphone, Cameras, Headphone
- **Battery:** Lithium-ion, rated capacity 2800mAh (10.64Wh), typical capacity 3000mAh (11.40Wh)
- **I/O:** USB Type-C, USB Host, DisplayPort Alternate Mode output, 15W 5V 3A Quick Charge, follows USB PD specification
Expand Down Expand Up @@ -74,7 +77,7 @@ Configure the NuttX project and build the project:
.. code:: console

$ cd nuttx
$ tools/configure.sh pinephone:lcd
$ tools/configure.sh pinephone:lvgl
$ make
$ cp nuttx.bin Image
$ rm -f Image.gz
Expand Down Expand Up @@ -114,6 +117,12 @@ To see the available commands in NuttShell:

$ help

To run the LVGL Touchscreen Demo:

.. code:: console

$ lvgldemo widgets

LEDs
====

Expand All @@ -139,6 +148,13 @@ Power Management Integrated Circuit (AXP803) and
Reduced Serial Bus (RSB).
Serial Console is enabled on UART0 at 115.2 kbps.

lvgl
____

Supports all the features in ``lcd``,
plus LVGL Graphics Library and Touch Panel (GT917S).
Serial Console is enabled on UART0 at 115.2 kbps.

nsh
---

Expand All @@ -147,14 +163,23 @@ This configuration is focused on low level, command-line driver testing.
Built-in applications are supported, but none are enabled.
Serial Console is enabled on UART0 at 115.2 kbps.

sensor
------

Supports Accelerometer / Gyroscope (MPU-6050),
Power Management Integrated Circuit (AXP803) and
Reduced Serial Bus (RSB).
Serial Console is enabled on UART0 at 115.2 kbps.

Peripheral Support
==================

NuttX for PinePhone supports these peripherals:

======================= ======= =====
Peripheral Support NOTES
======================= ======= =====
======================== ======= =====
Peripheral Support NOTES
======================== ======= =====
Accelerometer (MPU-6050) Yes
Backlight Yes
Display Engine Yes
Frame Buffer Yes
Expand All @@ -166,6 +191,7 @@ PIO Yes
PMIC (AXP803) Yes
RSB Yes
TCON0 Yes
TWI Yes
UART Yes Only UART0 is supported
======================= ======= =====
TWI / I2C Yes
Touch Panel (GT917S) Yes
UART Yes Only UART0 is supported
======================== ======= =====
87 changes: 87 additions & 0 deletions boards/arm64/a64/pinephone/configs/lvgl/defconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
#
# This file is autogenerated: PLEASE DO NOT EDIT IT.
#
# You can use "make menuconfig" to make any modifications to the installed .config file.
# You can then do "make savedefconfig" to generate a new defconfig file that includes your
# modifications.
#
CONFIG_A64_TWI0=y
CONFIG_A64_UART=y
CONFIG_ARCH="arm64"
CONFIG_ARCH_ARM64=y
CONFIG_ARCH_BOARD="pinephone"
CONFIG_ARCH_BOARD_PINEPHONE=y
CONFIG_ARCH_CHIP="a64"
CONFIG_ARCH_CHIP_A64=y
CONFIG_ARCH_INTERRUPTSTACK=4096
CONFIG_BOARDCTL_RESET=y
CONFIG_BOARD_LOOPSPERMSEC=116524
CONFIG_BUILTIN=y
CONFIG_DEBUG_ASSERTIONS=y
CONFIG_DEBUG_ERROR=y
CONFIG_DEBUG_FEATURES=y
CONFIG_DEBUG_FULLOPT=y
CONFIG_DEBUG_INFO=y
CONFIG_DEBUG_SCHED=y
CONFIG_DEBUG_SCHED_ERROR=y
CONFIG_DEBUG_SCHED_WARN=y
CONFIG_DEBUG_SYMBOLS=y
CONFIG_DEBUG_WARN=y
CONFIG_DEFAULT_TASK_STACKSIZE=8192
CONFIG_DEV_ZERO=y
CONFIG_EXAMPLES_FB=y
CONFIG_EXAMPLES_HELLO=y
CONFIG_EXAMPLES_LEDS=y
CONFIG_EXAMPLES_LVGLDEMO=y
CONFIG_EXAMPLES_TOUCHSCREEN=y
CONFIG_EXPERIMENTAL=y
CONFIG_FS_PROCFS=y
CONFIG_FS_ROMFS=y
CONFIG_GRAPHICS_LVGL=y
CONFIG_HAVE_CXX=y
CONFIG_HAVE_CXXINITIALIZE=y
CONFIG_HOST_MACOS=y
CONFIG_I2C=y
CONFIG_IDLETHREAD_STACKSIZE=8192
CONFIG_INIT_ENTRYPOINT="nsh_main"
CONFIG_INPUT=y
CONFIG_INPUT_GT9XX=y
CONFIG_INTELHEX_BINARY=y
CONFIG_LV_COLOR_DEPTH_32=y
CONFIG_LV_DPI_DEF=267
CONFIG_LV_FONT_DEFAULT_MONTSERRAT_20=y
CONFIG_LV_MEM_SIZE_KILOBYTES=64
CONFIG_LV_PORT_USE_FBDEV=y
CONFIG_LV_PORT_USE_TOUCHPAD=y
CONFIG_LV_TICK_CUSTOM=y
CONFIG_LV_TICK_CUSTOM_INCLUDE="port/lv_port_tick.h"
CONFIG_LV_USE_DEMO_WIDGETS=y
CONFIG_NSH_ARCHINIT=y
CONFIG_NSH_BUILTIN_APPS=y
CONFIG_NSH_FILEIOSIZE=512
CONFIG_NSH_READLINE=y
CONFIG_NSH_ROMFSETC=y
CONFIG_PINEPHONE_LCD=y
CONFIG_PREALLOC_TIMERS=4
CONFIG_PTHREAD_STACK_MIN=8192
CONFIG_RAMLOG=y
CONFIG_RAM_SIZE=134217728
CONFIG_RAM_START=0x40000000
CONFIG_RAW_BINARY=y
CONFIG_READLINE_CMD_HISTORY=y
CONFIG_RR_INTERVAL=200
CONFIG_SCHED_HPWORK=y
CONFIG_SCHED_HPWORKPRIORITY=192
CONFIG_SPINLOCK=y
CONFIG_STACK_COLORATION=y
CONFIG_START_MONTH=11
CONFIG_START_YEAR=2022
CONFIG_SYMTAB_ORDEREDBYNAME=y
CONFIG_SYSTEM_NSH=y
CONFIG_SYSTEM_SYSTEM=y
CONFIG_TESTING_GETPRIME=y
CONFIG_TESTING_OSTEST=y
CONFIG_UART1_SERIAL_CONSOLE=y
CONFIG_USEC_PER_TICK=1000
CONFIG_USERLED=y
CONFIG_USERLED_LOWER=y
4 changes: 4 additions & 0 deletions boards/arm64/a64/pinephone/src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,8 @@ ifeq ($(CONFIG_VIDEO_FB),y)
CSRCS += pinephone_display.c pinephone_lcd.c
endif

ifeq ($(CONFIG_INPUT_GT9XX),y)
CSRCS += pinephone_touch.c
endif

include $(TOPDIR)/boards/Board.mk
98 changes: 74 additions & 24 deletions boards/arm64/a64/pinephone/src/pinephone_bringup.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,16 @@
****************************************************************************/

#include <nuttx/config.h>
#include <nuttx/kmalloc.h>
#include <sys/types.h>
#include <syslog.h>
#include "a64_twi.h"
#include "pinephone.h"
#include "pinephone_pmic.h"

#ifdef CONFIG_I2C
# include <nuttx/i2c/i2c_master.h>
#endif
#include <nuttx/kmalloc.h>
#ifdef CONFIG_MPU60X0_I2C
# include <nuttx/sensors/mpu60x0.h>
#endif

#ifdef CONFIG_FS_PROCFS
# include <nuttx/fs/fs.h>
Expand All @@ -46,9 +47,13 @@
# include "pinephone_display.h"
#endif

#include "a64_twi.h"
#include "pinephone.h"
#include "pinephone_pmic.h"
#ifdef CONFIG_INPUT_GT9XX
# include "pinephone_touch.h"
#endif

#ifdef CONFIG_MPU60X0_I2C
# include <nuttx/sensors/mpu60x0.h>
#endif

/****************************************************************************
* Public Functions
Expand All @@ -64,13 +69,20 @@

int pinephone_bringup(void)
{
int ret;
#ifdef CONFIG_I2C
int i2c_bus;
struct i2c_master_s *i2c;
#ifdef CONFIG_MPU60X0_I2C
struct mpu_config_s *mpu_config;
int ret = OK;

#if defined(CONFIG_I2C) && defined(CONFIG_A64_TWI0)
const int i2c0_bus = 0;
struct i2c_master_s *i2c0 = NULL;
#endif

#if defined(CONFIG_I2C) && defined(CONFIG_A64_TWI1)
const int i2c1_bus = 1;
struct i2c_master_s *i2c1 = NULL;
#endif

#if defined(CONFIG_MPU60X0_I2C) && defined(CONFIG_A64_TWI1)
struct mpu_config_s *mpu_config = NULL;
#endif

#ifdef CONFIG_USERLED
Expand Down Expand Up @@ -107,25 +119,62 @@ int pinephone_bringup(void)
pinephone_display_test_pattern();
#endif

#if defined(CONFIG_I2C) && defined(CONFIG_A64_TWI0)
/* Initialize TWI0 as I2C Bus 0 */

i2c0 = a64_i2cbus_initialize(i2c0_bus);
if (i2c0 == NULL)
{
syslog(LOG_ERR, "ERROR: Failed to get I2C%d interface\n", i2c0_bus);
}
#endif

#if defined(CONFIG_I2C) && defined(CONFIG_A64_TWI1)
i2c_bus = 1;
i2c = a64_i2cbus_initialize(i2c_bus);
if (i2c == NULL)
/* Initialize TWI1 as I2C Bus 1 */

i2c1 = a64_i2cbus_initialize(i2c1_bus);
if (i2c1 == NULL)
{
syslog(LOG_ERR, "ERROR: Failed to get I2C%d interface\n", i2c_bus);
syslog(LOG_ERR, "ERROR: Failed to get I2C%d interface\n", i2c1_bus);
}
else
#endif

#if defined(CONFIG_SYSTEM_I2CTOOL) && defined(CONFIG_A64_TWI1)
/* Register I2C Driver for I2C Bus 1 at TWI1 */

if (i2c1 != NULL)
{
#if defined(CONFIG_SYSTEM_I2CTOOL)
ret = i2c_register(i2c, i2c_bus);
ret = i2c_register(i2c1, i2c1_bus);
if (ret < 0)
{
syslog(LOG_ERR, "ERROR: Failed to register I2C%d driver: %d\n",
i2c_bus, ret);
i2c1_bus, ret);
}
}
#endif

#ifdef CONFIG_MPU60X0_I2C
#if defined(CONFIG_INPUT_GT9XX) && defined(CONFIG_A64_TWI0)
/* Register Touch Input Driver for GT9XX Touch Panel at TWI0 */

if (i2c0 != NULL)
{
/* Register Touch Input Driver at /dev/input0 */

ret = pinephone_touch_panel_register("/dev/input0", i2c0);
if (ret < 0)
{
syslog(LOG_ERR,
"ERROR: Failed to register Touch Input GT9xx: %d\n",
ret);
}
}
#endif

#if defined(CONFIG_MPU60X0_I2C) && defined(CONFIG_A64_TWI1)
/* Register IMU Driver for MPU-60X0 Accelerometer at TWI1 */

if (i2c1 != NULL)
{
/* Init PMIC */

ret = pinephone_pmic_init();
Expand All @@ -139,18 +188,19 @@ int pinephone_bringup(void)

up_mdelay(15);

/* Register IMU Driver at /dev/imu0 */

mpu_config = kmm_zalloc(sizeof(struct mpu_config_s));
if (mpu_config == NULL)
{
syslog(LOG_ERR, "ERROR: Failed to allocate mpu60x0 driver\n");
}
else
{
mpu_config->i2c = i2c;
mpu_config->i2c = i2c1;
mpu_config->addr = 0x68;
mpu60x0_register("/dev/imu0", mpu_config);
}
#endif
}
#endif

Expand Down
Loading