diff --git a/boards/z80/ez80/z20x/Kconfig b/boards/z80/ez80/z20x/Kconfig index b324569c01..95eb696575 100644 --- a/boards/z80/ez80/z20x/Kconfig +++ b/boards/z80/ez80/z20x/Kconfig @@ -5,13 +5,6 @@ if ARCH_BOARD_Z20X -config Z20X_VGA - bool "VGA Controller attached?" - default n - ---help--- - Select this option if you have an I/O Controller and a VGA vide card - connected. - config Z20X_COPYTORAM bool "Copy to RAM" default n @@ -32,4 +25,20 @@ config Z20X_SDBOOT configuration. This will enable the components needed only by the boot loader. +choice + prompt "Winbond W25 Usage" + default Z20X_W25_CHARDEV + depends on EZ80_SPI && MTD_W25 + +config Z20X_W25_CHARDEV + bool "Character device" + select BCH + +config Z20X_W25_BLOCKDEV + bool "Block device" + +config Z20X_W25_MTDDEV + bool "MTD device" + +endchoice endif # ARCH_BOARD_Z20X diff --git a/boards/z80/ez80/z20x/src/Makefile b/boards/z80/ez80/z20x/src/Makefile index 0c4b3af292..83f54ec657 100644 --- a/boards/z80/ez80/z20x/src/Makefile +++ b/boards/z80/ez80/z20x/src/Makefile @@ -38,4 +38,8 @@ ifeq ($(CONFIG_Z20X_SDBOOT),y) CSRCS += sd_main.c endif +ifeq ($(CONFIG_MTD_W25),y) +CSRCS += ez80_w25.c +endif + include $(TOPDIR)/boards/Board.mk diff --git a/boards/z80/ez80/z20x/src/ez80_bringup.c b/boards/z80/ez80/z20x/src/ez80_bringup.c index 565bfe4f40..f9f1db6bec 100644 --- a/boards/z80/ez80/z20x/src/ez80_bringup.c +++ b/boards/z80/ez80/z20x/src/ez80_bringup.c @@ -26,7 +26,7 @@ #include #include -#include +#include #include "z20x.h" @@ -58,7 +58,18 @@ int ez80_bringup(void) ret = mount(NULL, "/proc", "procfs", 0, NULL); if (ret < 0) { - syslog(LOG_ERR, "ERROR: Failed to mount procfs at /proc: %d\n", ret); + ferr("ERROR: Failed to mount procfs at /proc: %d\n", ret); + } +#endif + +#ifdef HAVE_SPIFLASH + /* Initialize and register the W25 FLASH file system. */ + + ret = ez80_w25_initialize(0); + if (ret < 0) + { + ferr("ERROR: Failed to initialize W25 minor %d: %d\n", 0, ret); + return ret; } #endif @@ -68,7 +79,7 @@ int ez80_bringup(void) ret = ez80_mmcsd_initialize(); if (ret < 0) { - syslog(LOG_ERR, "ERROR: Failed to initialize SD card: %d\n", ret); + mcerr("ERROR: Failed to initialize SD card: %d\n", ret); } #endif diff --git a/boards/z80/ez80/z20x/src/ez80_w25.c b/boards/z80/ez80/z20x/src/ez80_w25.c new file mode 100644 index 0000000000..e4683316af --- /dev/null +++ b/boards/z80/ez80/z20x/src/ez80_w25.c @@ -0,0 +1,117 @@ +/**************************************************************************** + * boards/z80/ez80/z20x/src/ez80_w25.c + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include + +#include +#include +#include +#include + +#include +#include +#include + +#include "ez80f91_spi.h" +#include "z20x.h" + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: ez80_w25_initialize + * + * Description: + * Initialize and register the W25 FLASH file system. + * + ****************************************************************************/ + +int ez80_w25_initialize(int minor) +{ + FAR struct spi_dev_s *spi; + FAR struct mtd_dev_s *mtd; +#ifdef CONFIG_Z20X_W25_CHARDEV + char blockdev[18]; + char chardev[12]; +#endif + int ret; + + /* Get the SPI port */ + + spi = ez80_spibus_initialize(0); + if (!spi) + { + ferr("ERROR: Failed to initialize SPI port %d\n", 0); + return -ENODEV; + } + + /* Now bind the SPI interface to the W25 SPI FLASH driver */ + + mtd = w25_initialize(spi); + if (!mtd) + { + ferr("ERROR: Failed to bind SPI port %d to the W25 FLASH driver\n", 0); + return -ENODEV; + } + +#if defined(CONFIG_Z20X_W25_BLOCKDEV) + /* Use the FTL layer to wrap the MTD driver as a block driver. */ + + ret = ftl_initialize(minor, mtd); + if (ret < 0) + { + ferr("ERROR: Failed to initialize the FTL layer: %d\n", ret); + return ret; + } + +#elif defined(CONFIG_Z20X_W25_CHARDEV) + /* Use the FTL layer to wrap the MTD driver as a block driver */ + + ret = ftl_initialize(minor, mtd); + if (ret < 0) + { + ferr("ERROR: Failed to initialize the FTL layer: %d\n", ret); + return ret; + } + + /* Use the minor number to create device paths */ + + snprintf(blockdev, 18, "/dev/mtdblock%d", minor); + snprintf(chardev, 12, "/dev/mtd%d", minor); + + /* Now create a character device on the block device */ + + ret = bchdev_register(blockdev, chardev, false); + if (ret < 0) + { + ferr("ERROR: bchdev_register %s failed: %d\n", chardev, ret); + return ret; + } +#endif + + return OK; +} diff --git a/boards/z80/ez80/z20x/src/z20x.h b/boards/z80/ez80/z20x/src/z20x.h index 51e389eb60..1ca9052c33 100644 --- a/boards/z80/ez80/z20x/src/z20x.h +++ b/boards/z80/ez80/z20x/src/z20x.h @@ -152,6 +152,18 @@ int ez80_mmcsd_initialize(void); void ez80_spidev_initialize(void); #endif +/**************************************************************************** + * Name: ez80_w25_initialize + * + * Description: + * Called to initialize Winbond W25 memory + * + ****************************************************************************/ + +#ifdef HAVE_SPIFLASH +int ez80_w25_initialize(int minor); +#endif + #undef EXTERN #if defined(__cplusplus) }