diff --git a/configs/samv71-xult/README.txt b/configs/samv71-xult/README.txt index 9843890858..57cb52cdb2 100644 --- a/configs/samv71-xult/README.txt +++ b/configs/samv71-xult/README.txt @@ -344,6 +344,8 @@ NOTES: AT24MAC402 Serial EEPROM ======================== +Ethernet MAC Address +-------------------- The SAM V71 Xplained Ultra features one external AT24MAC402 serial EEPROM with a EIA-48 MAC address connected to the SAM V71 through I2C. This device contains a MAC address for use with the Ethernet interface. @@ -367,6 +369,29 @@ I2C address: the A0, A1, and A3 pins on the part. On the SAMV71-XULT board, these are all pulled high so the full, 7-bit address is 0x5f. +Configuration +------------- + + System Type -> SAMV7 Peripheral Support + CONFIG_SAMV7_TWIHS0=y : Used to access the EEPROM + CONFIG_SAMV7_TWIHS0_FREQUENCY=100000 + + Device drivers -> Memory Technology Devices + CONFIG_MTD_AT24XX=y : Enable the AT24 device driver + CONFIG_AT24XX_SIZE=2 : Normal EEPROM is 2Kbit (256b) + CONFIG_AT24XX_ADDR=0x57 : Normal EEPROM address */ + CONFIG_AT24XX_EXTENDED=y : Supports an extended memory region + CONFIG_AT24XX_EXTSIZE=160 : Extended address up to 0x9f + +MTD Configuration Data +---------------------- +The AT24 EEPROM can also be used to storage of up to 256 bytes of +configuration data: + + Device drivers -> Memory Technology Devices + +The configuration data device will appear at /dev/config. + Networking ========== @@ -398,7 +423,7 @@ Selecting the GMAC peripheral System Type -> SAMV7 Peripheral Support CONFIG_SAMV7_EMAC0=y : Enable the GMAC peripheral (aka, EMAC0) CONFIG_SAMV7_TWIHS0=y : We will get the MAC address from the AT24 EEPROM - CONFIG_SAMV7_TWIHS0_FREQUENCY=100000 + CONFIG_SAMV7_TWIHS0_FREQUENCY=100000 System Type -> EMAC device driver options CONFIG_SAMV7_EMAC0_NRXBUFFERS=16 : Set aside some RS and TX buffers @@ -866,7 +891,11 @@ Configuration sub-directories the AT2 EEPROM (I am not sure what the other address, 0x37, is are as this writing). - 7. Support for HSMCI is built-in by default. The SAMV71-XULT provides + 7. TWIHS0 is also used to support 256 byte non-volatile storage for + configuration data using the MTD configuration as described above + under the heading, "MTD Configuration Data". + + 8. Support for HSMCI is built-in by default. The SAMV71-XULT provides one full-size SD memory card slot. Refer to the section entitled "SD card" for configuration-related information. @@ -875,7 +904,7 @@ Configuration sub-directories The auto-mounter is not enabled. See the section above entitled "Auto-Mounter". - 8. Performance-related Configuration settings: + 9. Performance-related Configuration settings: CONFIG_ARMV7M_ICACHE=y : Instruction cache is enabled CONFIG_ARMV7M_DCACHE=y : Data cache is enabled diff --git a/configs/samv71-xult/src/Makefile b/configs/samv71-xult/src/Makefile index 376581baa0..cfa246d065 100644 --- a/configs/samv71-xult/src/Makefile +++ b/configs/samv71-xult/src/Makefile @@ -82,6 +82,14 @@ ifeq ($(CONFIG_USBMSC),y) CSRCS += sam_usbmsc.c endif +ifeq ($(CONFIG_MTD_CONFIG),y) +ifeq ($(CONFIG_SAMV7_TWIHS0),y) +ifeq ($(CONFIG_MTD_AT24XX),y) +CSRCS += sam_at24config.c +endif +endif +endif + COBJS = $(CSRCS:.c=$(OBJEXT)) SRCS = $(ASRCS) $(CSRCS) diff --git a/configs/samv71-xult/src/sam_at24config.c b/configs/samv71-xult/src/sam_at24config.c new file mode 100644 index 0000000000..9cd35418c4 --- /dev/null +++ b/configs/samv71-xult/src/sam_at24config.c @@ -0,0 +1,112 @@ +/************************************************************************************ + * configs/samv71-xult/src/sam_at24config.c + * + * Copyright (C) 2015 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * 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 NuttX 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 "sam_twihs.h" +#include "samv71-xult.h" + +#ifdef HAVE_MTDCONFIG + +/************************************************************************************ + * Public Functions + ************************************************************************************/ + +/************************************************************************************ + * Name: sam_at24config + * + * Description: + * Create an AT24xx-based MTD configuration device for storage device configuration + * information. + * + ************************************************************************************/ + +int sam_at24config(void) +{ + struct i2c_dev_s *i2c; + struct mtd_dev_s *at24; + int ret; + + /* Get an instance of the TWI0 interface */ + + i2c = up_i2cinitialize(0); + if (!i2c) + { + fdbg("ERROR: Failed to initialize TWI0\n"); + return -ENODEV; + } + + /* Initialize the AT24 driver */ + + at24 = at24c_initialize(i2c); + if (!at24) + { + fdbg("ERROR: Failed to initialize the AT24 driver\n"); + (void)up_i2cuninitialize(i2c); + return -ENODEV; + } + + /* Make sure that the AT24 is in normal memory access mode */ + + ret = at24->ioctl(at24, MTDIOC_EXTENDED, 0); + if (ret < 0) + { + fdbg("ERROR: AT24 ioctl(MTDIOC_EXTENDED) failed: %d\n", ret); + } + + /* Bind the instance of an MTD device to the /dev/config device. */ + + ret = mtdconfig_register(at24); + if (ret < 0) + { + fdbg("ERROR: Failed to bind AT24 driver to the MTD config device\n"); + (void)up_i2cuninitialize(i2c); + } + + return ret; +} + +#endif /* HAVE_MTDCONFIG */ diff --git a/configs/samv71-xult/src/sam_bringup.c b/configs/samv71-xult/src/sam_bringup.c index 5f8ceed9af..3b18784106 100644 --- a/configs/samv71-xult/src/sam_bringup.c +++ b/configs/samv71-xult/src/sam_bringup.c @@ -89,11 +89,7 @@ int sam_bringup(void) { -#if defined(HAVE_MACADDR) || defined(HAVE_HSMCI) || defined(HAVE_USBHOST) || \ - defined(HAVE_USBMONITOR) || defined(HAVE_WM8904) || \ - defined(HAVE_AUTOMOUNTER) || defined(HAVE_ELF) || defined(HAVE_ROMFS) int ret; -#endif #ifdef HAVE_MACADDR /* Read the Ethernet MAC address from the AT24 FLASH and configure the @@ -107,8 +103,19 @@ int sam_bringup(void) } #endif +#ifdef HAVE_MTDCONFIG + /* Create an AT24xx-based MTD configuration device for storage device + * configuration information. + */ + + ret = sam_at24config(); + if (ret < 0) + { + SYSLOG("ERROR: sam_at24config() failed: %d\n", ret); + } +#endif + #ifdef HAVE_HSMCI -#ifdef CONFIG_SAMV7_HSMCI0 /* Initialize the HSMCI0 driver */ ret = sam_hsmci_initialize(HSMCI0_SLOTNO, HSMCI0_MINOR); @@ -137,7 +144,6 @@ int sam_bringup(void) } #endif /* CONFIG_SAMV7XULT_HSMCI0_MOUNT */ -#endif /* CONFIG_SAMV7_HSMCI0 */ #endif /* HAVE_HSMCI */ #ifdef HAVE_AUTOMOUNTER @@ -230,5 +236,6 @@ int sam_bringup(void) * capabilities. */ + UNUSED(ret); return OK; } diff --git a/configs/samv71-xult/src/samv71-xult.h b/configs/samv71-xult/src/samv71-xult.h index 863629e8d4..28ac66dfbb 100644 --- a/configs/samv71-xult/src/samv71-xult.h +++ b/configs/samv71-xult/src/samv71-xult.h @@ -60,6 +60,7 @@ #define HAVE_USBMONITOR 1 #define HAVE_NETWORK 1 #define HAVE_MACADDR 1 +#define HAVE_MTDCONFIG 1 /* HSMCI */ /* Can't support MMC/SD if the card interface is not enabled */ @@ -157,16 +158,24 @@ # undef HAVE_USBMONITOR #endif -/* Networking */ +/* Networking and AT24-based MTD config */ #if !defined(CONFIG_NET) || !defined(CONFIG_SAMV7_EMAC) # undef HAVE_NETWORK # undef HAVE_MACADDR #endif -#if defined(CONFIG_NSH_NOMAC) || !defined(CONFIG_SAMV7_TWIHS0) || \ - !defined(CONFIG_MTD_AT24XX) || !defined(CONFIG_AT24XX_EXTENDED) +#if !defined(CONFIG_SAMV7_TWIHS0) || !defined(CONFIG_MTD_AT24XX) # undef HAVE_MACADDR +# undef HAVE_MTDCONFIG +#endif + +#if defined(CONFIG_NSH_NOMAC) || !defined(CONFIG_AT24XX_EXTENDED) +# undef HAVE_MACADDR +#endif + +#if !defined(CONFIG_MTD_CONFIG) +# undef HAVE_MTDCONFIG #endif /* SAMV71-XULT GPIO Pin Definitions *************************************************/ @@ -476,5 +485,18 @@ bool sam_writeprotected(int slotno); # define sam_writeprotected(slotno) (false) #endif +/************************************************************************************ + * Name: sam_at24config + * + * Description: + * Create an AT24xx-based MTD configuration device for storage device configuration + * information. + * + ************************************************************************************/ + +#ifdef HAVE_MTDCONFIG +int sam_at24config(void); +#endif + #endif /* __ASSEMBLY__ */ #endif /* __CONFIGS_SAMV71_XULT_SRC_SAMV71_XULT_H */ diff --git a/include/nuttx/configdata.h b/include/nuttx/configdata.h index e43f0b63cc..60539993aa 100644 --- a/include/nuttx/configdata.h +++ b/include/nuttx/configdata.h @@ -52,18 +52,9 @@ #include -#ifdef CONFIG_PLATFORM_CONFIGDATA - /**************************************************************************** * Pre-processor Definitions ****************************************************************************/ -/* Configuration ************************************************************/ -/* CONFIG_AUDIO - Enables Audio driver support - * CONFIG_DEBUG_AUDIO - If enabled (with CONFIG_DEBUG and, optionally, - * CONFIG_DEBUG_VERBOSE), this will generate output that can be used to - * debug Audio drivers. - */ - /* IOCTL Commands ***********************************************************/ /* The Audio module uses a standard character driver framework. However, a * lot of the Audio driver functionality is configured via a device control @@ -134,6 +125,7 @@ extern "C" * ****************************************************************************/ +struct mtd_dev_s; int mtdconfig_register(FAR struct mtd_dev_s *mtd); #undef EXTERN @@ -141,5 +133,4 @@ int mtdconfig_register(FAR struct mtd_dev_s *mtd); } #endif -#endif /* CONFIG_PLATFORM_CONFIGDATA */ #endif /* __INCLUDE_NUTTX_CONFIGDATA_H */