From c6355f58d6e9ef1413438acb081c4bd9297cbe4d Mon Sep 17 00:00:00 2001 From: Alin Jerpelea Date: Wed, 21 Aug 2019 13:39:29 +0000 Subject: [PATCH] Merged in alinjerpelea/nuttx (pull request #1014) boards: add stub drivers folder for later use * boards: add stub drivers folder for later use The board/drivers folder is added for future use. In this folder we should place drives that are platform specific and depend on HW that is present only on a specific platform. NOTE: All shared drivers should go to the regular driver folder Signed-off-by: Alin Jerpelea * tools: shift BOARD_DIR one level up In preparation for drivers and common folders we are moving the BOARD_DIR path up one level. Signed-off-by: Alin Jerpelea * tools: add drivers/platform symlink Link the boards///drivers dir to drivers/platform Signed-off-by: Alin Jerpelea * drivers: add platform specifc drivers extension There are platforms that use specific drivers and we should be able to include those drivers in the build Signed-off-by: Alin Jerpelea * board: cxd56xx: drivers: add AK09912 driver for SCU This is a platform specific driver connected on the SCU unit. Signed-off-by: Alin Jerpelea Approved-by: Gregory Nutt --- boards/arm/a1x/drivers/Kconfig | 4 + boards/arm/am335x/drivers/Kconfig | 4 + boards/arm/c5471/drivers/Kconfig | 4 + boards/arm/cxd56xx/drivers/Kconfig | 6 + boards/arm/cxd56xx/drivers/Make.defs | 36 ++ boards/arm/cxd56xx/drivers/sensors/Kconfig | 20 + boards/arm/cxd56xx/drivers/sensors/Make.defs | 42 ++ .../arm/cxd56xx/drivers/sensors/ak09912_scu.c | 582 ++++++++++++++++++ boards/arm/dm320/drivers/Kconfig | 4 + boards/arm/efm32/drivers/Kconfig | 4 + boards/arm/imx6/drivers/Kconfig | 4 + boards/arm/imxrt/drivers/Kconfig | 4 + boards/arm/kinetis/drivers/Kconfig | 4 + boards/arm/kl/drivers/Kconfig | 4 + boards/arm/lc823450/drivers/Kconfig | 4 + boards/arm/lpc17xx_40xx/drivers/Kconfig | 4 + boards/arm/lpc214x/drivers/Kconfig | 4 + boards/arm/lpc2378/drivers/Kconfig | 4 + boards/arm/lpc31xx/drivers/Kconfig | 4 + boards/arm/lpc43xx/drivers/Kconfig | 4 + boards/arm/lpc54xx/drivers/Kconfig | 4 + boards/arm/max326xx/drivers/Kconfig | 4 + boards/arm/moxart/drivers/Kconfig | 4 + boards/arm/nrf52/drivers/Kconfig | 4 + boards/arm/nuc1xx/drivers/Kconfig | 4 + boards/arm/s32k1xx/drivers/Kconfig | 4 + boards/arm/sam34/drivers/Kconfig | 4 + boards/arm/sama5/drivers/Kconfig | 4 + boards/arm/samd2l2/drivers/Kconfig | 4 + boards/arm/samd5e5/drivers/Kconfig | 4 + boards/arm/samv7/drivers/Kconfig | 4 + boards/arm/stm32/drivers/Kconfig | 4 + boards/arm/stm32f0l0g0/drivers/Kconfig | 4 + boards/arm/stm32f7/drivers/Kconfig | 4 + boards/arm/stm32h7/drivers/Kconfig | 4 + boards/arm/stm32l4/drivers/Kconfig | 4 + boards/arm/str71x/drivers/Kconfig | 4 + boards/arm/tiva/drivers/Kconfig | 4 + boards/arm/tms570/drivers/Kconfig | 4 + boards/arm/xmc4/drivers/Kconfig | 4 + boards/avr/drivers/Kconfig | 4 + boards/hc/drivers/Kconfig | 4 + boards/mips/drivers/Kconfig | 4 + boards/misoc/drivers/Kconfig | 4 + boards/or1k/drivers/Kconfig | 4 + boards/renesas/drivers/Kconfig | 4 + boards/risc-v/drivers/Kconfig | 4 + boards/sim/drivers/Kconfig | 4 + boards/x86/drivers/Kconfig | 4 + boards/xtensa/drivers/Kconfig | 4 + boards/z16/drivers/Kconfig | 4 + boards/z80/drivers/Kconfig | 4 + drivers/Kconfig | 10 + drivers/Makefile | 4 + include/nuttx/sensors/ak09912.h | 30 +- tools/Makefile.unix | 23 +- tools/Makefile.win | 32 +- 57 files changed, 952 insertions(+), 21 deletions(-) create mode 100644 boards/arm/a1x/drivers/Kconfig create mode 100644 boards/arm/am335x/drivers/Kconfig create mode 100644 boards/arm/c5471/drivers/Kconfig create mode 100644 boards/arm/cxd56xx/drivers/Kconfig create mode 100644 boards/arm/cxd56xx/drivers/Make.defs create mode 100644 boards/arm/cxd56xx/drivers/sensors/Kconfig create mode 100644 boards/arm/cxd56xx/drivers/sensors/Make.defs create mode 100644 boards/arm/cxd56xx/drivers/sensors/ak09912_scu.c create mode 100644 boards/arm/dm320/drivers/Kconfig create mode 100644 boards/arm/efm32/drivers/Kconfig create mode 100644 boards/arm/imx6/drivers/Kconfig create mode 100644 boards/arm/imxrt/drivers/Kconfig create mode 100644 boards/arm/kinetis/drivers/Kconfig create mode 100644 boards/arm/kl/drivers/Kconfig create mode 100644 boards/arm/lc823450/drivers/Kconfig create mode 100644 boards/arm/lpc17xx_40xx/drivers/Kconfig create mode 100644 boards/arm/lpc214x/drivers/Kconfig create mode 100644 boards/arm/lpc2378/drivers/Kconfig create mode 100644 boards/arm/lpc31xx/drivers/Kconfig create mode 100644 boards/arm/lpc43xx/drivers/Kconfig create mode 100644 boards/arm/lpc54xx/drivers/Kconfig create mode 100644 boards/arm/max326xx/drivers/Kconfig create mode 100644 boards/arm/moxart/drivers/Kconfig create mode 100644 boards/arm/nrf52/drivers/Kconfig create mode 100644 boards/arm/nuc1xx/drivers/Kconfig create mode 100644 boards/arm/s32k1xx/drivers/Kconfig create mode 100644 boards/arm/sam34/drivers/Kconfig create mode 100644 boards/arm/sama5/drivers/Kconfig create mode 100644 boards/arm/samd2l2/drivers/Kconfig create mode 100644 boards/arm/samd5e5/drivers/Kconfig create mode 100644 boards/arm/samv7/drivers/Kconfig create mode 100644 boards/arm/stm32/drivers/Kconfig create mode 100644 boards/arm/stm32f0l0g0/drivers/Kconfig create mode 100644 boards/arm/stm32f7/drivers/Kconfig create mode 100644 boards/arm/stm32h7/drivers/Kconfig create mode 100644 boards/arm/stm32l4/drivers/Kconfig create mode 100644 boards/arm/str71x/drivers/Kconfig create mode 100644 boards/arm/tiva/drivers/Kconfig create mode 100644 boards/arm/tms570/drivers/Kconfig create mode 100644 boards/arm/xmc4/drivers/Kconfig create mode 100644 boards/avr/drivers/Kconfig create mode 100644 boards/hc/drivers/Kconfig create mode 100644 boards/mips/drivers/Kconfig create mode 100644 boards/misoc/drivers/Kconfig create mode 100644 boards/or1k/drivers/Kconfig create mode 100644 boards/renesas/drivers/Kconfig create mode 100644 boards/risc-v/drivers/Kconfig create mode 100644 boards/sim/drivers/Kconfig create mode 100644 boards/x86/drivers/Kconfig create mode 100644 boards/xtensa/drivers/Kconfig create mode 100644 boards/z16/drivers/Kconfig create mode 100644 boards/z80/drivers/Kconfig diff --git a/boards/arm/a1x/drivers/Kconfig b/boards/arm/a1x/drivers/Kconfig new file mode 100644 index 0000000000..f72f3c094c --- /dev/null +++ b/boards/arm/a1x/drivers/Kconfig @@ -0,0 +1,4 @@ +# +# For a description of the syntax of this configuration file, +# see the file kconfig-language.txt in the NuttX tools repository. +# diff --git a/boards/arm/am335x/drivers/Kconfig b/boards/arm/am335x/drivers/Kconfig new file mode 100644 index 0000000000..f72f3c094c --- /dev/null +++ b/boards/arm/am335x/drivers/Kconfig @@ -0,0 +1,4 @@ +# +# For a description of the syntax of this configuration file, +# see the file kconfig-language.txt in the NuttX tools repository. +# diff --git a/boards/arm/c5471/drivers/Kconfig b/boards/arm/c5471/drivers/Kconfig new file mode 100644 index 0000000000..f72f3c094c --- /dev/null +++ b/boards/arm/c5471/drivers/Kconfig @@ -0,0 +1,4 @@ +# +# For a description of the syntax of this configuration file, +# see the file kconfig-language.txt in the NuttX tools repository. +# diff --git a/boards/arm/cxd56xx/drivers/Kconfig b/boards/arm/cxd56xx/drivers/Kconfig new file mode 100644 index 0000000000..84e3601a0d --- /dev/null +++ b/boards/arm/cxd56xx/drivers/Kconfig @@ -0,0 +1,6 @@ +# +# For a description of the syntax of this configuration file, +# see the file kconfig-language.txt in the NuttX tools repository. +# + +source "drivers/platform/sensors/Kconfig" diff --git a/boards/arm/cxd56xx/drivers/Make.defs b/boards/arm/cxd56xx/drivers/Make.defs new file mode 100644 index 0000000000..816d87fdfe --- /dev/null +++ b/boards/arm/cxd56xx/drivers/Make.defs @@ -0,0 +1,36 @@ +############################################################################ +# drivers/Makefile +# +# Copyright 2018 Sony Semiconductor Solutions Corporation +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name of Sony Semiconductor Solutions Corporation nor +# the names of its contributors may be used to endorse or promote +# products derived from this software without specific prior written +# permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +############################################################################ + +include platform$(DELIM)sensors$(DELIM)Make.defs diff --git a/boards/arm/cxd56xx/drivers/sensors/Kconfig b/boards/arm/cxd56xx/drivers/sensors/Kconfig new file mode 100644 index 0000000000..dfe1ce8103 --- /dev/null +++ b/boards/arm/cxd56xx/drivers/sensors/Kconfig @@ -0,0 +1,20 @@ +# +# For a description of the syntax of this configuration file, +# see the file kconfig-language.txt in the NuttX tools repository. +# + +menuconfig SCU_SENSORS + bool "SCU Sensor Drivers" + +if SCU_SENSORS + +config SENSORS_AK09912_SCU + bool "Asahi AK09911/AK09912 Compass Sensor" + default n + select CXD56_I2C + select CXD56_SCU + ---help--- + Enable driver for AK09911/AK09912 Compass sensor. + NOTE: This sensor is connected to the SCU unit + +endif # SCU_SENSORS diff --git a/boards/arm/cxd56xx/drivers/sensors/Make.defs b/boards/arm/cxd56xx/drivers/sensors/Make.defs new file mode 100644 index 0000000000..e0a5f66bfb --- /dev/null +++ b/boards/arm/cxd56xx/drivers/sensors/Make.defs @@ -0,0 +1,42 @@ +############################################################################ +# drivers/platform/sensors/Make.defs +# +# Copyright 2018 Sony Semiconductor Solutions Corporation +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name of Sony Semiconductor Solutions Corporation nor +# the names of its contributors may be used to endorse or promote +# products derived from this software without specific prior written +# permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +############################################################################ + +ifeq ($(CONFIG_SENSORS_AK09912_SCU),y) +CSRCS += ak09912_scu.c +endif + +DEPPATH += --dep-path platform$(DELIM)sensors +VPATH += :platform$(DELIM)sensors +CFLAGS += $(shell $(INCDIR) $(INCDIROPT) "$(CC)" $(TOPDIR)$(DELIM)drivers$(DELIM)platform$(DELIM)sensors) diff --git a/boards/arm/cxd56xx/drivers/sensors/ak09912_scu.c b/boards/arm/cxd56xx/drivers/sensors/ak09912_scu.c new file mode 100644 index 0000000000..5dcaa6b8a9 --- /dev/null +++ b/boards/arm/cxd56xx/drivers/sensors/ak09912_scu.c @@ -0,0 +1,582 @@ +/**************************************************************************** + * drivers/platform/sensors/ak09912_scu.c + * + * Copyright 2018 Sony Semiconductor Solutions Corporation + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name of Sony Semiconductor Solutions Corporation nor + * the names of its contributors may be used to endorse or promote + * products derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#if defined(CONFIG_I2C) && defined(CONFIG_SENSORS_AK09912_SCU) + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +#ifdef CONFIG_CXD56_DECI_AK09912 +# define MAG_SEQ_TYPE SEQ_TYPE_DECI +#else +# define MAG_SEQ_TYPE SEQ_TYPE_NORMAL +#endif + +#define AK09912_ADDR 0x0C +#define AK09912_FREQ 400000 +#define AK09912_DEVID 0x0448 +#define AK09911_DEVID 0x0548 + +/* REGISTER: WIA + * Who I am. + */ + +#define AK09912_WIA1 0x00 +#define AK09912_WIA2 0x01 + +/* REGISTER: CNTL2 + * Power mode + */ + +#define POWER_MODE_ADDR 0x31 + +/* REGISTER: ASAX + * Sensitivity values + */ + +#define AK09912_ASAX 0x60 + +/* REGISTER: CNTL1 + * Enable or disable temparature measure or enable or disable Noise + * suppression filter. + */ + +#define AK09912_CTRL1 0x30 + +/* REGISTER: HXL + * The start address of data registers. + */ + +#define AK09912_HXL 0x11 + +/* The parameter for compensating. */ + +#define AK09912_SENSITIVITY (128) +#define AK09912_SENSITIVITY_DIV (256) + +/* Noise Suppression Filter */ + +#define AK09912_NSF_MASK (0x3 << 5) +#define AK09912_NSF_NONE (0x0 << 5) +#define AK09912_NSF_LOW (0x1 << 5) +#define AK09912_NSF_MIDDLE (0x2 << 5) +#define AK09912_NSF_HIGH (0x3 << 5) + +/* Power mode */ + +#define AKM_POWER_DOWN_MODE 0b0000 +#define AKM_SINGL_MEAS_MODE 0b00001 +#define AKM_CONT_MEAS_1 0b00010 +#define AKM_CONT_MEAS_2 0b00100 +#define AKM_CONT_MEAS_3 0b00110 +#define AKM_CONT_MEAS_4 0b01000 +#define AKM_EXT_TRIG_MODE 0b01010 +#define AKM_SELF_TEST_MODE 0b10000 +#define AKM_FUSE_ROM_MODE 0b11111 + +/* REGISTER: ST1 + * DRDY: Data ready bit. 0: not ready, 1: ready + * DOR: Data overrun. 0: Not overrun, 1: overrun + */ + +#define AK09912_ST1 0x10 + +/* AK09912 is magnetometer */ + +#define AK09912_BYTESPERSAMPLE 6 +#define AK09912_ELEMENTSIZE 2 + +#ifndef itemsof +# define itemsof(array) (sizeof(array)/sizeof(array[0])) +#endif + +/**************************************************************************** + * Private Type Definitions + ****************************************************************************/ +/** + * @brief Structure for ak09912 device + */ + +struct ak09912_dev_s +{ + FAR struct i2c_master_s *i2c; /* I2C interface */ + uint8_t addr; /* I2C address */ + int freq; /* Frequency <= 3.4MHz */ + int port; /* I2C port */ + + struct seq_s *seq; + int id; +}; + +/**************************************************************************** + * Private Function Prototypes + ****************************************************************************/ + +/* Character driver methods */ + +static int ak09912_open(FAR struct file *filep); +static int ak09912_close(FAR struct file *filep); +static ssize_t ak09912_read(FAR struct file *filep, FAR char *buffer, + size_t buflen); +static ssize_t ak09912_write(FAR struct file *filep, FAR const char *buffer, + size_t buflen); +static int ak09912_ioctl(FAR struct file *filep, int cmd, unsigned long arg); + +/**************************************************************************** + * Private Data + ****************************************************************************/ + +static const struct file_operations g_ak09912fops = +{ + ak09912_open, /* open */ + ak09912_close, /* close */ + ak09912_read, /* read */ + ak09912_write, /* write */ + 0, /* seek */ + ak09912_ioctl, /* ioctl */ +#ifndef CONFIG_DISABLE_POLL + 0, /* poll */ +#endif + 0 /* unlink */ +}; + +/* Take XYZ data, temperature and Status 2 register. + * Status 2 register has a role as data reading end. + */ + +static const uint16_t g_ak09912inst[] = +{ + SCU_INST_SEND(AK09912_HXL), + SCU_INST_RECV(AK09912_BYTESPERSAMPLE + 2) | SCU_INST_LAST, +}; + +static struct ak09912_sensadj_s g_asa; + +/* Sequencer instance */ + +static FAR struct seq_s *g_seq = NULL; + +/* Reference count */ + +static int g_refcnt = 0; + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: ak09912_getreg8 + * + * Description: + * Read from an 8-bit AK09912 register + * + ****************************************************************************/ + +static uint8_t ak09912_getreg8(FAR struct ak09912_dev_s *priv, + uint8_t regaddr) +{ + uint8_t regval = 0; + uint16_t inst[2]; + + /* Send register to read and get the next byte */ + + inst[0] = SCU_INST_SEND(regaddr); + inst[1] = SCU_INST_RECV(1) | SCU_INST_LAST; + + scu_i2ctransfer(priv->port, priv->addr, inst, 2, ®val, 1); + + return regval; +} + +/**************************************************************************** + * Name: ak09912_putreg8 + * + * Description: + * Write to an 8-bit AK09912 register + * + ****************************************************************************/ + +static void ak09912_putreg8(FAR struct ak09912_dev_s *priv, uint8_t regaddr, + uint8_t regval) +{ + uint16_t inst[2]; + + /* Send register address and set the value */ + + inst[0] = SCU_INST_SEND(regaddr); + inst[1] = SCU_INST_SEND(regval) | SCU_INST_LAST; + + scu_i2ctransfer(priv->port, priv->addr, inst, 2, NULL, 0); +} + +/**************************************************************************** + * Name: ak09912_getreg + * + * Description: + * Read cnt bytes from a ak09912 register + * + ****************************************************************************/ + +static int ak09912_getreg(FAR struct ak09912_dev_s *priv, uint8_t regaddr, + uint8_t* buffer, uint32_t cnt) +{ + uint16_t inst[2]; + + /* Send register to read and get the next byte */ + + inst[0] = SCU_INST_SEND(regaddr); + inst[1] = SCU_INST_RECV(cnt) | SCU_INST_LAST; + + scu_i2ctransfer(priv->port, priv->addr, inst, 2, buffer, cnt); + + return OK; +} + +/**************************************************************************** + * Name: ak09912_checkid + * + * Description: + * Read and verify the AK09911/AK09912 chip ID + * + ****************************************************************************/ + +static int ak09912_checkid(FAR struct ak09912_dev_s *priv) +{ + uint16_t devid = 0; + + /* Read device ID */ + + devid = ak09912_getreg8(priv, AK09912_WIA1); + devid += ak09912_getreg8(priv, AK09912_WIA2) << 8; + sninfo("devid: 0x%04x\n", devid); + + if (devid != AK09911_DEVID && devid != AK09912_DEVID) + { + /* ID is not Correct */ + + snerr("Wrong Device ID! %02x\n", devid); + return -ENODEV; + } + + return OK; +} + +static int ak09912_seqinit(FAR struct ak09912_dev_s *priv) +{ + DEBUGASSERT(g_seq == NULL); + + /* Open sequencer */ + + g_seq = seq_open(MAG_SEQ_TYPE, SCU_BUS_I2C0); + if (!g_seq) + { + return -ENOENT; + } + priv->seq = g_seq; + + seq_setaddress(priv->seq, priv->addr); + + /* Set instruction and sample data information to sequencer */ + + seq_setinstruction(priv->seq, g_ak09912inst, itemsof(g_ak09912inst)); + seq_setsample(priv->seq, AK09912_BYTESPERSAMPLE, 0, + AK09912_ELEMENTSIZE, false); + + return OK; +} + +/**************************************************************************** + * Name: ak09912_open + * + * Description: + * This function is called whenever the AK09912 device is opened. + * + ****************************************************************************/ + +static int ak09912_open(FAR struct file *filep) +{ + FAR struct inode *inode = filep->f_inode; + FAR struct ak09912_dev_s *priv = inode->i_private; + + if (g_refcnt == 0) + { + int ret; + + ret = ak09912_seqinit(priv); + if (ret < 0) + { + return ret; + } + + ak09912_putreg8(priv, POWER_MODE_ADDR, AKM_CONT_MEAS_4); + up_mdelay(1); + } + else + { + /* Set existing sequencer */ + + priv->seq = g_seq; + } + + g_refcnt++; + + return OK; +} + +/**************************************************************************** + * Name: ak09912_close + * + * Description: + * This routine is called when the AK09912 device is closed. + * + ****************************************************************************/ + +static int ak09912_close(FAR struct file *filep) +{ + FAR struct inode *inode = filep->f_inode; + FAR struct ak09912_dev_s *priv = inode->i_private; + + g_refcnt--; + + (void) seq_ioctl(priv->seq, priv->id, SCUIOC_STOP, 0); + + if (g_refcnt == 0) + { + DEBUGASSERT(g_seq); + + ak09912_putreg8(priv, POWER_MODE_ADDR, AKM_POWER_DOWN_MODE); + up_mdelay(1); + + seq_close(g_seq); + g_seq = NULL; + } + else + { + (void) seq_ioctl(priv->seq, priv->id, SCUIOC_FREEFIFO, 0); + } + + return OK; +} + +/**************************************************************************** + * Name: ak09912_read + ****************************************************************************/ + +static ssize_t ak09912_read(FAR struct file *filep, FAR char *buffer, + size_t len) +{ + FAR struct inode *inode = filep->f_inode; + FAR struct ak09912_dev_s *priv = inode->i_private; + + len = len / AK09912_BYTESPERSAMPLE * AK09912_BYTESPERSAMPLE; + len = seq_read(priv->seq, priv->id, buffer, len); + + return len; +} + +/**************************************************************************** + * Name: ak09912_write + ****************************************************************************/ + +static ssize_t ak09912_write(FAR struct file *filep, FAR const char *buffer, + size_t buflen) +{ + return -ENOSYS; +} + +/**************************************************************************** + * Name: ak09912_write + ****************************************************************************/ + +static int ak09912_ioctl(FAR struct file *filep, int cmd, unsigned long arg) +{ + FAR struct inode *inode = filep->f_inode; + FAR struct ak09912_dev_s *priv = inode->i_private; + int ret = OK; + + switch (cmd) + { + /* Get sensitivity adjustment value + * Arg: Pointer to struct ak09912_sensadj_s + */ + + case SNIOC_GETADJ: + { + struct ak09912_sensadj_s *user = (struct ak09912_sensadj_s *)(uintptr_t)arg; + + user->x = g_asa.x; + user->y = g_asa.y; + user->z = g_asa.z; + } + break; + + default: + { + if (_SCUIOCVALID(cmd)) + { + /* Redirect SCU commands */ + + ret = seq_ioctl(priv->seq, priv->id, cmd, arg); + } + else + { + snerr("Unrecognized cmd: %d\n", cmd); + ret = - ENOTTY; + } + } + break; + } + + return ret; +} + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +int ak09912_init(FAR struct i2c_master_s *i2c, int port) +{ + FAR struct ak09912_dev_s tmp, *priv = &tmp; + uint8_t val; + int ret; + + /* Setup temporary device structure for initialization */ + + priv->i2c = i2c; + priv->addr = AK09912_ADDR; + priv->freq = AK09912_FREQ; + priv->port = port; + + /* Check Device ID */ + + ret = ak09912_checkid(priv); + if (ret < 0) + { + snerr("Failed to register driver: %d\n", ret); + return ret; + } + + ak09912_putreg8(priv, POWER_MODE_ADDR, AKM_FUSE_ROM_MODE); + up_mdelay(1); + + ak09912_getreg(priv, AK09912_ASAX, (uint8_t *)&g_asa, + sizeof(struct ak09912_sensadj_s)); + + ak09912_putreg8(priv, POWER_MODE_ADDR, AKM_POWER_DOWN_MODE); + up_mdelay(1); + + /* Set noise suppression filter to LOW */ + + val = ak09912_getreg8(priv, AK09912_CTRL1); + val = (val & ~AK09912_NSF_MASK) | AK09912_NSF_LOW; + ak09912_putreg8(priv, AK09912_CTRL1, val); + + return OK; +} + +/**************************************************************************** + * Name: ak09912_register + * + * Description: + * Register the AK09912 character device as 'devpath' + * + * Input Parameters: + * devpath - The full path to the driver to register. E.g., "/dev/mag" + * i2c - An instance of the I2C interface to use to communicate with + * AK09912 + * + * Returned Value: + * Zero (OK) on success; a negated errno value on failure. + * + ****************************************************************************/ + +int ak09912_register(FAR const char *devpath, int minor, + FAR struct i2c_master_s *i2c, int port) +{ + FAR struct ak09912_dev_s *priv; + char path[16]; + int ret; + + /* Initialize the AK09912 device structure */ + + priv = (FAR struct ak09912_dev_s *)kmm_malloc(sizeof(struct ak09912_dev_s)); + if (!priv) + { + snerr("Failed to allocate instance\n"); + return -ENOMEM; + } + + priv->i2c = i2c; + priv->id = minor; + priv->addr = AK09912_ADDR; + priv->freq = AK09912_FREQ; + priv->port = port; + + /* Register the character driver */ + + (void) snprintf(path, sizeof(path), "%s%d", devpath, minor); + ret = register_driver(path, &g_ak09912fops, 0666, priv); + if (ret < 0) + { + snerr("Failed to register driver: %d\n", ret); + kmm_free(priv); + } + + sninfo("AK09912 driver loaded successfully!\n"); + return ret; +} + +#endif /* CONFIG_I2C && CONFIG_SENSORS_AK09912_SCU */ diff --git a/boards/arm/dm320/drivers/Kconfig b/boards/arm/dm320/drivers/Kconfig new file mode 100644 index 0000000000..f72f3c094c --- /dev/null +++ b/boards/arm/dm320/drivers/Kconfig @@ -0,0 +1,4 @@ +# +# For a description of the syntax of this configuration file, +# see the file kconfig-language.txt in the NuttX tools repository. +# diff --git a/boards/arm/efm32/drivers/Kconfig b/boards/arm/efm32/drivers/Kconfig new file mode 100644 index 0000000000..f72f3c094c --- /dev/null +++ b/boards/arm/efm32/drivers/Kconfig @@ -0,0 +1,4 @@ +# +# For a description of the syntax of this configuration file, +# see the file kconfig-language.txt in the NuttX tools repository. +# diff --git a/boards/arm/imx6/drivers/Kconfig b/boards/arm/imx6/drivers/Kconfig new file mode 100644 index 0000000000..f72f3c094c --- /dev/null +++ b/boards/arm/imx6/drivers/Kconfig @@ -0,0 +1,4 @@ +# +# For a description of the syntax of this configuration file, +# see the file kconfig-language.txt in the NuttX tools repository. +# diff --git a/boards/arm/imxrt/drivers/Kconfig b/boards/arm/imxrt/drivers/Kconfig new file mode 100644 index 0000000000..f72f3c094c --- /dev/null +++ b/boards/arm/imxrt/drivers/Kconfig @@ -0,0 +1,4 @@ +# +# For a description of the syntax of this configuration file, +# see the file kconfig-language.txt in the NuttX tools repository. +# diff --git a/boards/arm/kinetis/drivers/Kconfig b/boards/arm/kinetis/drivers/Kconfig new file mode 100644 index 0000000000..f72f3c094c --- /dev/null +++ b/boards/arm/kinetis/drivers/Kconfig @@ -0,0 +1,4 @@ +# +# For a description of the syntax of this configuration file, +# see the file kconfig-language.txt in the NuttX tools repository. +# diff --git a/boards/arm/kl/drivers/Kconfig b/boards/arm/kl/drivers/Kconfig new file mode 100644 index 0000000000..f72f3c094c --- /dev/null +++ b/boards/arm/kl/drivers/Kconfig @@ -0,0 +1,4 @@ +# +# For a description of the syntax of this configuration file, +# see the file kconfig-language.txt in the NuttX tools repository. +# diff --git a/boards/arm/lc823450/drivers/Kconfig b/boards/arm/lc823450/drivers/Kconfig new file mode 100644 index 0000000000..f72f3c094c --- /dev/null +++ b/boards/arm/lc823450/drivers/Kconfig @@ -0,0 +1,4 @@ +# +# For a description of the syntax of this configuration file, +# see the file kconfig-language.txt in the NuttX tools repository. +# diff --git a/boards/arm/lpc17xx_40xx/drivers/Kconfig b/boards/arm/lpc17xx_40xx/drivers/Kconfig new file mode 100644 index 0000000000..f72f3c094c --- /dev/null +++ b/boards/arm/lpc17xx_40xx/drivers/Kconfig @@ -0,0 +1,4 @@ +# +# For a description of the syntax of this configuration file, +# see the file kconfig-language.txt in the NuttX tools repository. +# diff --git a/boards/arm/lpc214x/drivers/Kconfig b/boards/arm/lpc214x/drivers/Kconfig new file mode 100644 index 0000000000..f72f3c094c --- /dev/null +++ b/boards/arm/lpc214x/drivers/Kconfig @@ -0,0 +1,4 @@ +# +# For a description of the syntax of this configuration file, +# see the file kconfig-language.txt in the NuttX tools repository. +# diff --git a/boards/arm/lpc2378/drivers/Kconfig b/boards/arm/lpc2378/drivers/Kconfig new file mode 100644 index 0000000000..f72f3c094c --- /dev/null +++ b/boards/arm/lpc2378/drivers/Kconfig @@ -0,0 +1,4 @@ +# +# For a description of the syntax of this configuration file, +# see the file kconfig-language.txt in the NuttX tools repository. +# diff --git a/boards/arm/lpc31xx/drivers/Kconfig b/boards/arm/lpc31xx/drivers/Kconfig new file mode 100644 index 0000000000..f72f3c094c --- /dev/null +++ b/boards/arm/lpc31xx/drivers/Kconfig @@ -0,0 +1,4 @@ +# +# For a description of the syntax of this configuration file, +# see the file kconfig-language.txt in the NuttX tools repository. +# diff --git a/boards/arm/lpc43xx/drivers/Kconfig b/boards/arm/lpc43xx/drivers/Kconfig new file mode 100644 index 0000000000..f72f3c094c --- /dev/null +++ b/boards/arm/lpc43xx/drivers/Kconfig @@ -0,0 +1,4 @@ +# +# For a description of the syntax of this configuration file, +# see the file kconfig-language.txt in the NuttX tools repository. +# diff --git a/boards/arm/lpc54xx/drivers/Kconfig b/boards/arm/lpc54xx/drivers/Kconfig new file mode 100644 index 0000000000..f72f3c094c --- /dev/null +++ b/boards/arm/lpc54xx/drivers/Kconfig @@ -0,0 +1,4 @@ +# +# For a description of the syntax of this configuration file, +# see the file kconfig-language.txt in the NuttX tools repository. +# diff --git a/boards/arm/max326xx/drivers/Kconfig b/boards/arm/max326xx/drivers/Kconfig new file mode 100644 index 0000000000..f72f3c094c --- /dev/null +++ b/boards/arm/max326xx/drivers/Kconfig @@ -0,0 +1,4 @@ +# +# For a description of the syntax of this configuration file, +# see the file kconfig-language.txt in the NuttX tools repository. +# diff --git a/boards/arm/moxart/drivers/Kconfig b/boards/arm/moxart/drivers/Kconfig new file mode 100644 index 0000000000..f72f3c094c --- /dev/null +++ b/boards/arm/moxart/drivers/Kconfig @@ -0,0 +1,4 @@ +# +# For a description of the syntax of this configuration file, +# see the file kconfig-language.txt in the NuttX tools repository. +# diff --git a/boards/arm/nrf52/drivers/Kconfig b/boards/arm/nrf52/drivers/Kconfig new file mode 100644 index 0000000000..f72f3c094c --- /dev/null +++ b/boards/arm/nrf52/drivers/Kconfig @@ -0,0 +1,4 @@ +# +# For a description of the syntax of this configuration file, +# see the file kconfig-language.txt in the NuttX tools repository. +# diff --git a/boards/arm/nuc1xx/drivers/Kconfig b/boards/arm/nuc1xx/drivers/Kconfig new file mode 100644 index 0000000000..f72f3c094c --- /dev/null +++ b/boards/arm/nuc1xx/drivers/Kconfig @@ -0,0 +1,4 @@ +# +# For a description of the syntax of this configuration file, +# see the file kconfig-language.txt in the NuttX tools repository. +# diff --git a/boards/arm/s32k1xx/drivers/Kconfig b/boards/arm/s32k1xx/drivers/Kconfig new file mode 100644 index 0000000000..f72f3c094c --- /dev/null +++ b/boards/arm/s32k1xx/drivers/Kconfig @@ -0,0 +1,4 @@ +# +# For a description of the syntax of this configuration file, +# see the file kconfig-language.txt in the NuttX tools repository. +# diff --git a/boards/arm/sam34/drivers/Kconfig b/boards/arm/sam34/drivers/Kconfig new file mode 100644 index 0000000000..f72f3c094c --- /dev/null +++ b/boards/arm/sam34/drivers/Kconfig @@ -0,0 +1,4 @@ +# +# For a description of the syntax of this configuration file, +# see the file kconfig-language.txt in the NuttX tools repository. +# diff --git a/boards/arm/sama5/drivers/Kconfig b/boards/arm/sama5/drivers/Kconfig new file mode 100644 index 0000000000..f72f3c094c --- /dev/null +++ b/boards/arm/sama5/drivers/Kconfig @@ -0,0 +1,4 @@ +# +# For a description of the syntax of this configuration file, +# see the file kconfig-language.txt in the NuttX tools repository. +# diff --git a/boards/arm/samd2l2/drivers/Kconfig b/boards/arm/samd2l2/drivers/Kconfig new file mode 100644 index 0000000000..f72f3c094c --- /dev/null +++ b/boards/arm/samd2l2/drivers/Kconfig @@ -0,0 +1,4 @@ +# +# For a description of the syntax of this configuration file, +# see the file kconfig-language.txt in the NuttX tools repository. +# diff --git a/boards/arm/samd5e5/drivers/Kconfig b/boards/arm/samd5e5/drivers/Kconfig new file mode 100644 index 0000000000..f72f3c094c --- /dev/null +++ b/boards/arm/samd5e5/drivers/Kconfig @@ -0,0 +1,4 @@ +# +# For a description of the syntax of this configuration file, +# see the file kconfig-language.txt in the NuttX tools repository. +# diff --git a/boards/arm/samv7/drivers/Kconfig b/boards/arm/samv7/drivers/Kconfig new file mode 100644 index 0000000000..f72f3c094c --- /dev/null +++ b/boards/arm/samv7/drivers/Kconfig @@ -0,0 +1,4 @@ +# +# For a description of the syntax of this configuration file, +# see the file kconfig-language.txt in the NuttX tools repository. +# diff --git a/boards/arm/stm32/drivers/Kconfig b/boards/arm/stm32/drivers/Kconfig new file mode 100644 index 0000000000..f72f3c094c --- /dev/null +++ b/boards/arm/stm32/drivers/Kconfig @@ -0,0 +1,4 @@ +# +# For a description of the syntax of this configuration file, +# see the file kconfig-language.txt in the NuttX tools repository. +# diff --git a/boards/arm/stm32f0l0g0/drivers/Kconfig b/boards/arm/stm32f0l0g0/drivers/Kconfig new file mode 100644 index 0000000000..f72f3c094c --- /dev/null +++ b/boards/arm/stm32f0l0g0/drivers/Kconfig @@ -0,0 +1,4 @@ +# +# For a description of the syntax of this configuration file, +# see the file kconfig-language.txt in the NuttX tools repository. +# diff --git a/boards/arm/stm32f7/drivers/Kconfig b/boards/arm/stm32f7/drivers/Kconfig new file mode 100644 index 0000000000..f72f3c094c --- /dev/null +++ b/boards/arm/stm32f7/drivers/Kconfig @@ -0,0 +1,4 @@ +# +# For a description of the syntax of this configuration file, +# see the file kconfig-language.txt in the NuttX tools repository. +# diff --git a/boards/arm/stm32h7/drivers/Kconfig b/boards/arm/stm32h7/drivers/Kconfig new file mode 100644 index 0000000000..f72f3c094c --- /dev/null +++ b/boards/arm/stm32h7/drivers/Kconfig @@ -0,0 +1,4 @@ +# +# For a description of the syntax of this configuration file, +# see the file kconfig-language.txt in the NuttX tools repository. +# diff --git a/boards/arm/stm32l4/drivers/Kconfig b/boards/arm/stm32l4/drivers/Kconfig new file mode 100644 index 0000000000..f72f3c094c --- /dev/null +++ b/boards/arm/stm32l4/drivers/Kconfig @@ -0,0 +1,4 @@ +# +# For a description of the syntax of this configuration file, +# see the file kconfig-language.txt in the NuttX tools repository. +# diff --git a/boards/arm/str71x/drivers/Kconfig b/boards/arm/str71x/drivers/Kconfig new file mode 100644 index 0000000000..f72f3c094c --- /dev/null +++ b/boards/arm/str71x/drivers/Kconfig @@ -0,0 +1,4 @@ +# +# For a description of the syntax of this configuration file, +# see the file kconfig-language.txt in the NuttX tools repository. +# diff --git a/boards/arm/tiva/drivers/Kconfig b/boards/arm/tiva/drivers/Kconfig new file mode 100644 index 0000000000..f72f3c094c --- /dev/null +++ b/boards/arm/tiva/drivers/Kconfig @@ -0,0 +1,4 @@ +# +# For a description of the syntax of this configuration file, +# see the file kconfig-language.txt in the NuttX tools repository. +# diff --git a/boards/arm/tms570/drivers/Kconfig b/boards/arm/tms570/drivers/Kconfig new file mode 100644 index 0000000000..f72f3c094c --- /dev/null +++ b/boards/arm/tms570/drivers/Kconfig @@ -0,0 +1,4 @@ +# +# For a description of the syntax of this configuration file, +# see the file kconfig-language.txt in the NuttX tools repository. +# diff --git a/boards/arm/xmc4/drivers/Kconfig b/boards/arm/xmc4/drivers/Kconfig new file mode 100644 index 0000000000..f72f3c094c --- /dev/null +++ b/boards/arm/xmc4/drivers/Kconfig @@ -0,0 +1,4 @@ +# +# For a description of the syntax of this configuration file, +# see the file kconfig-language.txt in the NuttX tools repository. +# diff --git a/boards/avr/drivers/Kconfig b/boards/avr/drivers/Kconfig new file mode 100644 index 0000000000..f72f3c094c --- /dev/null +++ b/boards/avr/drivers/Kconfig @@ -0,0 +1,4 @@ +# +# For a description of the syntax of this configuration file, +# see the file kconfig-language.txt in the NuttX tools repository. +# diff --git a/boards/hc/drivers/Kconfig b/boards/hc/drivers/Kconfig new file mode 100644 index 0000000000..f72f3c094c --- /dev/null +++ b/boards/hc/drivers/Kconfig @@ -0,0 +1,4 @@ +# +# For a description of the syntax of this configuration file, +# see the file kconfig-language.txt in the NuttX tools repository. +# diff --git a/boards/mips/drivers/Kconfig b/boards/mips/drivers/Kconfig new file mode 100644 index 0000000000..f72f3c094c --- /dev/null +++ b/boards/mips/drivers/Kconfig @@ -0,0 +1,4 @@ +# +# For a description of the syntax of this configuration file, +# see the file kconfig-language.txt in the NuttX tools repository. +# diff --git a/boards/misoc/drivers/Kconfig b/boards/misoc/drivers/Kconfig new file mode 100644 index 0000000000..f72f3c094c --- /dev/null +++ b/boards/misoc/drivers/Kconfig @@ -0,0 +1,4 @@ +# +# For a description of the syntax of this configuration file, +# see the file kconfig-language.txt in the NuttX tools repository. +# diff --git a/boards/or1k/drivers/Kconfig b/boards/or1k/drivers/Kconfig new file mode 100644 index 0000000000..f72f3c094c --- /dev/null +++ b/boards/or1k/drivers/Kconfig @@ -0,0 +1,4 @@ +# +# For a description of the syntax of this configuration file, +# see the file kconfig-language.txt in the NuttX tools repository. +# diff --git a/boards/renesas/drivers/Kconfig b/boards/renesas/drivers/Kconfig new file mode 100644 index 0000000000..f72f3c094c --- /dev/null +++ b/boards/renesas/drivers/Kconfig @@ -0,0 +1,4 @@ +# +# For a description of the syntax of this configuration file, +# see the file kconfig-language.txt in the NuttX tools repository. +# diff --git a/boards/risc-v/drivers/Kconfig b/boards/risc-v/drivers/Kconfig new file mode 100644 index 0000000000..f72f3c094c --- /dev/null +++ b/boards/risc-v/drivers/Kconfig @@ -0,0 +1,4 @@ +# +# For a description of the syntax of this configuration file, +# see the file kconfig-language.txt in the NuttX tools repository. +# diff --git a/boards/sim/drivers/Kconfig b/boards/sim/drivers/Kconfig new file mode 100644 index 0000000000..f72f3c094c --- /dev/null +++ b/boards/sim/drivers/Kconfig @@ -0,0 +1,4 @@ +# +# For a description of the syntax of this configuration file, +# see the file kconfig-language.txt in the NuttX tools repository. +# diff --git a/boards/x86/drivers/Kconfig b/boards/x86/drivers/Kconfig new file mode 100644 index 0000000000..f72f3c094c --- /dev/null +++ b/boards/x86/drivers/Kconfig @@ -0,0 +1,4 @@ +# +# For a description of the syntax of this configuration file, +# see the file kconfig-language.txt in the NuttX tools repository. +# diff --git a/boards/xtensa/drivers/Kconfig b/boards/xtensa/drivers/Kconfig new file mode 100644 index 0000000000..f72f3c094c --- /dev/null +++ b/boards/xtensa/drivers/Kconfig @@ -0,0 +1,4 @@ +# +# For a description of the syntax of this configuration file, +# see the file kconfig-language.txt in the NuttX tools repository. +# diff --git a/boards/z16/drivers/Kconfig b/boards/z16/drivers/Kconfig new file mode 100644 index 0000000000..f72f3c094c --- /dev/null +++ b/boards/z16/drivers/Kconfig @@ -0,0 +1,4 @@ +# +# For a description of the syntax of this configuration file, +# see the file kconfig-language.txt in the NuttX tools repository. +# diff --git a/boards/z80/drivers/Kconfig b/boards/z80/drivers/Kconfig new file mode 100644 index 0000000000..f72f3c094c --- /dev/null +++ b/boards/z80/drivers/Kconfig @@ -0,0 +1,4 @@ +# +# For a description of the syntax of this configuration file, +# see the file kconfig-language.txt in the NuttX tools repository. +# diff --git a/drivers/Kconfig b/drivers/Kconfig index 8b69500653..0df048c63d 100644 --- a/drivers/Kconfig +++ b/drivers/Kconfig @@ -407,3 +407,13 @@ menuconfig 1WIRE source drivers/1wire/Kconfig source drivers/syslog/Kconfig + +menuconfig SPECIFIC_DRIVERS + bool "Board specific drivers" + default n + ---help--- + Board specific drivers located in each board/driver folder. + +if SPECIFIC_DRIVERS +source drivers/platform/Kconfig +endif # SPECIFIC_DRIVERS diff --git a/drivers/Makefile b/drivers/Makefile index b4fc05160b..184126bf49 100644 --- a/drivers/Makefile +++ b/drivers/Makefile @@ -83,6 +83,10 @@ include wireless$(DELIM)Make.defs include contactless$(DELIM)Make.defs include 1wire$(DELIM)Make.defs +ifeq ($(CONFIG_SPECIFIC_DRIVERS),y) +include platform$(DELIM)Make.defs +endif + CSRCS += dev_null.c dev_zero.c ifneq ($(CONFIG_DISABLE_MOUNTPOINT),y) diff --git a/include/nuttx/sensors/ak09912.h b/include/nuttx/sensors/ak09912.h index a8c3e23791..306e2f5ce1 100644 --- a/include/nuttx/sensors/ak09912.h +++ b/include/nuttx/sensors/ak09912.h @@ -38,7 +38,8 @@ #include -#if defined(CONFIG_I2C) && defined(CONFIG_SENSORS_AK09912) +#if defined(CONFIG_I2C) && (defined(CONFIG_SENSORS_AK09912) || defined (CONFIG_SENSORS_AK09912_SCU)) + /**************************************************************************** * Pre-processor Definitions @@ -75,7 +76,6 @@ extern "C" /* Arg: 0: Disable compensated * 1: Enable compensated */ - #define ENABLE_COMPENSATED (1) #define DISABLE_COMPENSATED (0) #define SNIOC_ENABLE_COMPENSATED _SNIOC(0x0001) @@ -96,6 +96,25 @@ struct ak09912_sensadj_s uint8_t z; }; +#ifdef CONFIG_SENSORS_AK09912_SCU +/**************************************************************************** + * Name: ak09912_init + * + * Description: + * Initialize AK09912 magnetometer device + * + * Input Parameters: + * i2c - An instance of the I2C interface to use to communicate with + * AK09912 + * + * Returned Value: + * Zero (OK) on success; a negated errno value on failure. + * + ****************************************************************************/ + +int ak09912_init(FAR struct i2c_master_s *i2c, int port); +#endif + /**************************************************************************** * Name: ak09912_register * @@ -111,7 +130,12 @@ struct ak09912_sensadj_s * Zero (OK) on success; a negated errno value on failure. * ****************************************************************************/ +#ifdef CONFIG_SENSORS_AK09912_SCU +int ak09912_register(FAR const char *devpath, int minor, + FAR struct i2c_master_s *i2c, int port); +#else int ak09912_register(FAR const char *devpath, FAR struct i2c_master_s *i2c); +#endif #undef EXTERN #ifdef __cplusplus @@ -119,4 +143,4 @@ int ak09912_register(FAR const char *devpath, FAR struct i2c_master_s *i2c); #endif #endif /* CONFIG_I2C && CONFIG_AK09912 */ -#endif /* __DRIVERS_AK09912_H */ +#endif /* __INCLUDE_NUTTX_SENSORS_AK09912_H */ diff --git a/tools/Makefile.unix b/tools/Makefile.unix index c8c964eed1..43c8259de4 100644 --- a/tools/Makefile.unix +++ b/tools/Makefile.unix @@ -78,7 +78,7 @@ else BOARD_DIR = $(CONFIG_ARCH_BOARD_CUSTOM_DIR) endif else -BOARD_DIR = $(TOPDIR)$(DELIM)boards$(DELIM)$(CONFIG_ARCH)$(DELIM)$(CONFIG_ARCH_CHIP)$(DELIM)$(CONFIG_ARCH_BOARD) +BOARD_DIR = $(TOPDIR)$(DELIM)boards$(DELIM)$(CONFIG_ARCH)$(DELIM)$(CONFIG_ARCH_CHIP) endif # CONFIG_APPS_DIR can be over-ridden from the command line or in the .config file. @@ -314,17 +314,23 @@ include/arch: .config @echo "LN: include/arch to $(ARCH_DIR)/include" $(Q) $(DIRLINK) $(TOPDIR)/$(ARCH_DIR)/include include/arch -# Link the boards///include directory to include/arch/board +# Link the boards////include directory to include/arch/board include/arch/board: include/arch - @echo "LN: include/arch/board to $(BOARD_DIR)/include" - $(Q) $(DIRLINK) $(BOARD_DIR)/include include/arch/board + @echo "LN: include/arch/board to $(BOARD_DIR)/$(CONFIG_ARCH_BOARD)/include" + $(Q) $(DIRLINK) $(BOARD_DIR)/$(CONFIG_ARCH_BOARD)/include include/arch/board -# Link the boards///src dir to arch//src/board +# Link the boards////src dir to arch//src/board $(ARCH_SRC)/board: .config - @echo "LN: $(ARCH_SRC)/board to $(BOARD_DIR)/src" - $(Q) $(DIRLINK) $(BOARD_DIR)/src $(ARCH_SRC)/board + @echo "LN: $(ARCH_SRC)/board to $(BOARD_DIR)/$(CONFIG_ARCH_BOARD)/src" + $(Q) $(DIRLINK) $(BOARD_DIR)/$(CONFIG_ARCH_BOARD)/src $(ARCH_SRC)/board + +# Link the boards///drivers dir to drivers/platform + +$(ARCH_SRC)/drivers: .config + @echo "LN: $(ARCH_SRC)/drivers to $(BOARD_DIR)/drivers/platform" + $(Q) $(DIRLINK) $(BOARD_DIR)/drivers $(TOPDIR)/drivers/platform # Link arch//include/ to arch//include/chip @@ -342,7 +348,7 @@ ifneq ($(CONFIG_ARCH_CHIP),) $(Q) $(DIRLINK) $(TOPDIR)/$(ARCH_INC)/$(CONFIG_ARCH_CHIP) include/arch/chip endif -dirlinks: include/arch include/arch/board include/arch/chip $(ARCH_SRC)/board $(ARCH_SRC)/chip +dirlinks: include/arch include/arch/board include/arch/chip $(ARCH_SRC)/board $(ARCH_SRC)/chip $(ARCH_SRC)/drivers $(Q) $(MAKE) -C boards dirlinks TOPDIR="$(TOPDIR)" $(Q) $(MAKE) -C $(CONFIG_APPS_DIR) dirlinks TOPDIR="$(TOPDIR)" @@ -376,6 +382,7 @@ clean_context: $(Q) $(DIRUNLINK) include/arch $(Q) $(DIRUNLINK) $(ARCH_SRC)/board $(Q) $(DIRUNLINK) $(ARCH_SRC)/chip + $(Q) $(DIRUNLINK) $(TOPDIR)/drivers/platform # check_context # diff --git a/tools/Makefile.win b/tools/Makefile.win index 2ff527df37..b353cea564 100644 --- a/tools/Makefile.win +++ b/tools/Makefile.win @@ -73,7 +73,7 @@ else BOARD_DIR = $(CONFIG_ARCH_BOARD_CUSTOM_DIR) endif else -BOARD_DIR = $(TOPDIR)$(DELIM)boards$(DELIM)$(CONFIG_ARCH)$(DELIM)$(CONFIG_ARCH_CHIP)$(DELIM)$(CONFIG_ARCH_BOARD) +BOARD_DIR = $(TOPDIR)$(DELIM)boards$(DELIM)$(CONFIG_ARCH)$(DELIM)$(CONFIG_ARCH_CHIP) endif # CONFIG_APPS_DIR can be over-ridden from the command line or in the .config file. @@ -316,25 +316,36 @@ else $(Q) echo FAKELNK > include\arch\.fakelnk endif -# Link the boards\\\include directory to include\arch\board +# Link the boards\\\\include directory to include\arch\board include\arch\board: include\arch - @echo LN: include\arch\board to $(BOARD_DIR)\include + @echo LN: include\arch\board to $(BOARD_DIR)\$(CONFIG_ARCH_BOARD)\include ifeq ($(CONFIG_WINDOWS_MKLINK),y) - $(Q) /user:administrator mklink /d include\arch\board $(BOARD_DIR)\include + $(Q) /user:administrator mklink /d include\arch\board $(BOARD_DIR)\$(CONFIG_ARCH_BOARD)\include else - $(Q) xcopy $(BOARD_DIR)\include include\arch\board /c /q /s /e /y /i + $(Q) xcopy $(BOARD_DIR)\$(CONFIG_ARCH_BOARD)\include include\arch\board /c /q /s /e /y /i $(Q) echo FAKELNK > include\arch\board\.fakelnk endif -# Link the boards\\\src dir to arch\\src\board +# Link the boards\\\drivers dir to drivers\platform + +$(ARCH_SRC)\drivers: .config + @echo LN: drivers\platform to $(BOARD_DIR)\drivers +ifeq ($(CONFIG_WINDOWS_MKLINK),y) + $(Q) /user:administrator mklink /d $(TOPDIR)\drivers\platform $(BOARD_DIR)\drivers +else + $(Q) xcopy $(BOARD_DIR)\drivers $(TOPDIR)\drivers\platform /c /q /s /e /y /i + $(Q) echo FAKELNK > $(TOPDIR)\drivers\platform .fakelnk +endif + +# Link the boards\\\\src dir to arch\\src\board $(ARCH_SRC)\board: .config - @echo LN: $(ARCH_SRC)\board to $(BOARD_DIR)\src + @echo LN: $(ARCH_SRC)\board to $(BOARD_DIR)\$(CONFIG_ARCH_BOARD)\src ifeq ($(CONFIG_WINDOWS_MKLINK),y) - $(Q) /user:administrator mklink /d $(ARCH_SRC)\board $(BOARD_DIR)\src + $(Q) /user:administrator mklink /d $(ARCH_SRC)\board $(BOARD_DIR)\$(CONFIG_ARCH_BOARD)\src else - $(Q) xcopy $(BOARD_DIR)\src $(ARCH_SRC)\board /c /q /s /e /y /i + $(Q) xcopy $(BOARD_DIR)\$(CONFIG_ARCH_BOARD)\src $(ARCH_SRC)\board /c /q /s /e /y /i $(Q) echo FAKELNK > $(ARCH_SRC)\board\.fakelnk endif @@ -364,7 +375,7 @@ else endif endif -dirlinks: include\arch include\arch\board include\arch\chip $(ARCH_SRC)\board $(ARCH_SRC)\chip +dirlinks: include\arch include\arch\board include\arch\chip $(ARCH_SRC)\board $(ARCH_SRC)\chip $(ARCH_SRC)\drivers $(Q) $(MAKE) -C boards dirlinks TOPDIR="$(TOPDIR)" $(Q) $(MAKE) -C $(CONFIG_APPS_DIR) dirlinks TOPDIR="$(TOPDIR)" @@ -396,6 +407,7 @@ clean_context: $(call DELDIR, include\arch) $(call DELDIR, $(ARCH_SRC)\board) $(call DELDIR, $(ARCH_SRC)\chip) + $(call DELDIR, $(TOPDIR)\drivers\platform) # check_context #