boards/pinephone: add support of MPU6050

This commit is contained in:
zouboan 2022-12-30 17:54:15 +08:00 committed by Xiang Xiao
parent 7e81dce71c
commit 8d7c1541c5
3 changed files with 138 additions and 2 deletions

View File

@ -0,0 +1,73 @@
#
# 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_RSB=y
CONFIG_A64_TWI1=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_HELLO=y
CONFIG_EXAMPLES_LEDS=y
CONFIG_EXPERIMENTAL=y
CONFIG_FS_PROCFS=y
CONFIG_FS_ROMFS=y
CONFIG_HAVE_CXX=y
CONFIG_HAVE_CXXINITIALIZE=y
CONFIG_IDLETHREAD_STACKSIZE=8192
CONFIG_INIT_ENTRYPOINT="nsh_main"
CONFIG_INTELHEX_BINARY=y
CONFIG_MPU60X0_I2C=y
CONFIG_NSH_ARCHINIT=y
CONFIG_NSH_BUILTIN_APPS=y
CONFIG_NSH_FILEIOSIZE=512
CONFIG_NSH_READLINE=y
CONFIG_NSH_ROMFSETC=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_SENSORS=y
CONFIG_SENSORS_MPU60X0=y
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

View File

@ -20,7 +20,7 @@
include $(TOPDIR)/Make.defs
CSRCS = pinephone_boardinit.c pinephone_bringup.c
CSRCS = pinephone_boardinit.c pinephone_bringup.c pinephone_pmic.c
ifeq ($(CONFIG_BOARDCTL),y)
CSRCS += pinephone_appinit.c
@ -38,7 +38,7 @@ CSRCS += pinephone_userleds.c
endif
ifeq ($(CONFIG_VIDEO_FB),y)
CSRCS += pinephone_display.c pinephone_lcd.c pinephone_pmic.c
CSRCS += pinephone_display.c pinephone_lcd.c
endif
include $(TOPDIR)/boards/Board.mk

View File

@ -25,6 +25,13 @@
#include <nuttx/config.h>
#include <sys/types.h>
#include <syslog.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>
@ -39,7 +46,9 @@
# include "pinephone_display.h"
#endif
#include "a64_twi.h"
#include "pinephone.h"
#include "pinephone_pmic.h"
/****************************************************************************
* Public Functions
@ -56,6 +65,13 @@
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;
#endif
#endif
#ifdef CONFIG_USERLED
/* Register the LED driver */
@ -91,6 +107,53 @@ int pinephone_bringup(void)
pinephone_display_test_pattern();
#endif
#if defined(CONFIG_I2C) && defined(CONFIG_A64_TWI1)
i2c_bus = 1;
i2c = a64_i2cbus_initialize(i2c_bus);
if (i2c == NULL)
{
syslog(LOG_ERR, "ERROR: Failed to get I2C%d interface\n", i2c_bus);
}
else
{
#if defined(CONFIG_SYSTEM_I2CTOOL)
ret = i2c_register(i2c, i2c_bus);
if (ret < 0)
{
syslog(LOG_ERR, "ERROR: Failed to register I2C%d driver: %d\n",
i2c_bus, ret);
}
#endif
#ifdef CONFIG_MPU60X0_I2C
/* Init PMIC */
ret = pinephone_pmic_init();
if (ret < 0)
{
syslog(LOG_ERR, "Init PMIC failed: %d\n", ret);
return ret;
}
/* Wait 15 milliseconds for power supply and power-on init */
up_mdelay(15);
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->addr = 0x68;
mpu60x0_register("/dev/imu0", mpu_config);
}
#endif
}
#endif
UNUSED(ret);
return OK;
}