boards/z80/ez80/z20x/: Add support for W25 FLASH.
This commit is contained in:
parent
029680fb50
commit
350adb236f
@ -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
|
||||
|
@ -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
|
||||
|
@ -26,7 +26,7 @@
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/mount.h>
|
||||
#include <syslog.h>
|
||||
#include <debug.h>
|
||||
|
||||
#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
|
||||
|
||||
|
117
boards/z80/ez80/z20x/src/ez80_w25.c
Normal file
117
boards/z80/ez80/z20x/src/ez80_w25.c
Normal file
@ -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 <nuttx/config.h>
|
||||
|
||||
#include <sys/mount.h>
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/spi/spi.h>
|
||||
#include <nuttx/mtd/mtd.h>
|
||||
#include <nuttx/drivers/drivers.h>
|
||||
|
||||
#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;
|
||||
}
|
@ -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)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user