2014-03-10 22:18:46 +01:00
|
|
|
/****************************************************************************
|
2019-08-15 18:19:17 +02:00
|
|
|
* boards/arm/sam34/sam4e-ek/src/sam_usbmsc.c
|
2014-03-10 22:18:46 +01:00
|
|
|
*
|
2021-03-17 18:14:12 +01:00
|
|
|
* 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
|
2014-03-10 22:18:46 +01:00
|
|
|
*
|
2021-03-17 18:14:12 +01:00
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
2014-03-10 22:18:46 +01:00
|
|
|
*
|
2021-03-17 18:14:12 +01:00
|
|
|
* 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.
|
2014-03-10 22:18:46 +01:00
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Included Files
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#include <nuttx/config.h>
|
|
|
|
|
|
|
|
#include <stdio.h>
|
2014-10-08 22:59:10 +02:00
|
|
|
#include <syslog.h>
|
2014-03-10 22:18:46 +01:00
|
|
|
#include <errno.h>
|
|
|
|
|
2016-03-25 19:09:37 +01:00
|
|
|
#include <nuttx/board.h>
|
|
|
|
|
2014-03-18 18:00:20 +01:00
|
|
|
#include "sam4e-ek.h"
|
2014-03-10 22:18:46 +01:00
|
|
|
|
2014-03-18 16:31:02 +01:00
|
|
|
#ifdef CONFIG_SAM34_UDP
|
2014-03-10 22:18:46 +01:00
|
|
|
|
|
|
|
/****************************************************************************
|
2015-04-08 17:15:17 +02:00
|
|
|
* Pre-processor Definitions
|
2014-03-10 22:18:46 +01:00
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
/* Configuration ************************************************************/
|
|
|
|
|
|
|
|
#ifndef CONFIG_SYSTEM_USBMSC_DEVMINOR1
|
|
|
|
# define CONFIG_SYSTEM_USBMSC_DEVMINOR1 0
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* SLOT number(s) depends on the board configuration */
|
|
|
|
|
|
|
|
#undef SAM_MMCSDSLOTNO
|
|
|
|
#define SAM_MMCSDSLOTNO 0
|
|
|
|
|
2014-03-18 16:31:02 +01:00
|
|
|
/* Can't use a block device if it is not available */
|
|
|
|
|
|
|
|
#ifndef HAVE_AT25
|
|
|
|
# undef CONFIG_SAM4EEK_AT25_BLOCKDEVICE
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef HAVE_HSMCI
|
|
|
|
# undef CONFIG_SAM4EEK_HSMCI_BLOCKDEVICE
|
|
|
|
#endif
|
|
|
|
|
2014-03-10 22:18:46 +01:00
|
|
|
/****************************************************************************
|
|
|
|
* Public Functions
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
/****************************************************************************
|
2016-03-25 19:09:37 +01:00
|
|
|
* Name: board_usbmsc_initialize
|
2014-03-10 22:18:46 +01:00
|
|
|
*
|
|
|
|
* Description:
|
2016-03-25 19:09:37 +01:00
|
|
|
* Perform architecture specific initialization as needed to establish
|
|
|
|
* the mass storage device that will be exported by the USB MSC device.
|
2014-03-10 22:18:46 +01:00
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
2016-03-25 19:09:37 +01:00
|
|
|
int board_usbmsc_initialize(int port)
|
2014-03-10 22:18:46 +01:00
|
|
|
{
|
2014-03-18 16:31:02 +01:00
|
|
|
/* Initialize the AT25 MTD driver */
|
2014-03-10 22:18:46 +01:00
|
|
|
|
2014-03-18 16:31:02 +01:00
|
|
|
#if defined(CONFIG_SAM4EEK_AT25_BLOCKDEVICE)
|
|
|
|
int ret = sam_at25_automount(0);
|
|
|
|
if (ret < 0)
|
2014-03-10 22:18:46 +01:00
|
|
|
{
|
2014-10-08 22:59:10 +02:00
|
|
|
syslog(LOG_ERR, "ERROR: sam_at25_automount failed: %d\n", ret);
|
2014-03-10 22:18:46 +01:00
|
|
|
}
|
|
|
|
|
2014-03-18 16:31:02 +01:00
|
|
|
return ret;
|
2014-03-10 22:18:46 +01:00
|
|
|
|
2014-03-18 16:31:02 +01:00
|
|
|
#elif defined(CONFIG_SAM4EEK_HSMCI_BLOCKDEVICE)
|
|
|
|
/* Initialize the HSMCI driver */
|
2014-03-10 22:18:46 +01:00
|
|
|
|
2014-10-08 22:59:10 +02:00
|
|
|
int ret = sam_hsmci_initialize(0);
|
2014-03-18 16:31:02 +01:00
|
|
|
if (ret < 0)
|
2014-03-10 22:18:46 +01:00
|
|
|
{
|
2014-10-08 22:59:10 +02:00
|
|
|
syslog(LOG_ERR, "ERROR: sam_hsmci_initialize(0) failed: %d\n", ret);
|
2014-03-10 22:18:46 +01:00
|
|
|
}
|
|
|
|
|
2014-03-18 16:31:02 +01:00
|
|
|
return ret;
|
2014-03-10 22:18:46 +01:00
|
|
|
|
2014-03-18 16:31:02 +01:00
|
|
|
#else
|
|
|
|
return -ENODEV;
|
|
|
|
#endif
|
2014-03-10 22:18:46 +01:00
|
|
|
}
|
|
|
|
|
2014-03-18 16:31:02 +01:00
|
|
|
#endif /* CONFIG_SAM34_UDP */
|