2008-10-15 16:19:46 +02:00
|
|
|
/****************************************************************************
|
|
|
|
* include/nuttx/mmcsd.h
|
|
|
|
*
|
2021-01-29 14:39:49 +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
|
2008-10-15 16:19:46 +02:00
|
|
|
*
|
2021-01-29 14:39:49 +01:00
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
2008-10-15 16:19:46 +02:00
|
|
|
*
|
2021-01-29 14:39:49 +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.
|
2008-10-15 16:19:46 +02:00
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
2012-07-17 05:58:11 +02:00
|
|
|
#ifndef __INCLUDE_NUTTX_MMCSD_H
|
|
|
|
#define __INCLUDE_NUTTX_MMCSD_H
|
2008-10-15 16:19:46 +02:00
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Included Files
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#include <nuttx/config.h>
|
|
|
|
|
2021-09-06 15:15:19 +02:00
|
|
|
#include <stdint.h>
|
|
|
|
#include <nuttx/fs/ioctl.h>
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Pre-processor Definitions
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
/* mmcsd ioctl */
|
|
|
|
|
2022-12-05 12:54:31 +01:00
|
|
|
#define MMC_IOC_CMD _MMCSDIOC(0x0000)
|
|
|
|
#define MMC_IOC_MULTI_CMD _MMCSDIOC(0x0001)
|
|
|
|
|
|
|
|
#define MMC_IOC_MAX_BYTES (512L * 1024)
|
|
|
|
#define MMC_IOC_MAX_CMDS 255
|
|
|
|
#define mmc_ioc_cmd_set_data(ic, ptr) (ic).data_ptr = (uint64_t)(unsigned long)(ptr)
|
2021-09-06 15:15:19 +02:00
|
|
|
|
|
|
|
/* rpmb request */
|
|
|
|
|
|
|
|
#define MMC_RPMB_WRITE_KEY 0x01
|
|
|
|
#define MMC_RPMB_READ_CNT 0x02
|
|
|
|
#define MMC_RPMB_WRITE 0x03
|
|
|
|
#define MMC_RPMB_READ 0x04
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Public Types
|
|
|
|
****************************************************************************/
|
|
|
|
|
2022-12-05 12:54:31 +01:00
|
|
|
struct mmc_ioc_cmd
|
|
|
|
{
|
|
|
|
/* Direction of data: nonzero = write, zero = read.
|
|
|
|
* Bit 31 selects 'Reliable Write' for RPMB.
|
|
|
|
*/
|
|
|
|
|
|
|
|
int write_flag;
|
|
|
|
|
|
|
|
/* Application-specific command. true = precede with CMD55 */
|
|
|
|
|
|
|
|
int is_acmd;
|
|
|
|
|
|
|
|
uint32_t opcode;
|
|
|
|
uint32_t arg;
|
|
|
|
uint32_t response[4]; /* CMD response */
|
|
|
|
unsigned int flags;
|
|
|
|
unsigned int blksz;
|
|
|
|
unsigned int blocks;
|
|
|
|
|
|
|
|
/* For 64-bit machines, the next member, ``uint64_t data_ptr``, wants to
|
|
|
|
* be 8-byte aligned. Make sure this struct is the same size when
|
|
|
|
* built for 32-bit.
|
|
|
|
*/
|
|
|
|
|
|
|
|
uint32_t pad;
|
|
|
|
|
|
|
|
/* DAT buffer */
|
|
|
|
|
|
|
|
uint64_t data_ptr;
|
|
|
|
};
|
|
|
|
|
|
|
|
/* struct mmc_ioc_multi_cmd - multi command information
|
|
|
|
* @num_of_cmds: Number of commands to send. Must be equal to or less than
|
|
|
|
* MMC_IOC_MAX_CMDS.
|
|
|
|
* @cmds: Array of commands with length equal to 'num_of_cmds'
|
|
|
|
*/
|
|
|
|
|
|
|
|
struct mmc_ioc_multi_cmd
|
|
|
|
{
|
|
|
|
uint64_t num_of_cmds;
|
|
|
|
struct mmc_ioc_cmd cmds[1];
|
|
|
|
};
|
|
|
|
|
2021-09-06 15:15:19 +02:00
|
|
|
struct mmc_rpmb_frame_s
|
|
|
|
{
|
|
|
|
uint8_t stuff[196];
|
|
|
|
uint8_t key_mac[32];
|
|
|
|
uint8_t data[256];
|
|
|
|
uint8_t nonce[16];
|
|
|
|
uint32_t write_counter;
|
|
|
|
uint16_t addr;
|
|
|
|
uint16_t block_count;
|
|
|
|
uint16_t result;
|
|
|
|
uint16_t req_resp;
|
|
|
|
};
|
|
|
|
|
2008-10-15 16:19:46 +02:00
|
|
|
/****************************************************************************
|
2021-01-28 14:28:18 +01:00
|
|
|
* Public Functions Definitions
|
2008-10-15 16:19:46 +02:00
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#undef EXTERN
|
|
|
|
#if defined(__cplusplus)
|
|
|
|
#define EXTERN extern "C"
|
2015-02-16 21:29:43 +01:00
|
|
|
extern "C"
|
|
|
|
{
|
2008-10-15 16:19:46 +02:00
|
|
|
#else
|
|
|
|
#define EXTERN extern
|
|
|
|
#endif
|
|
|
|
|
2009-11-06 19:10:32 +01:00
|
|
|
/****************************************************************************
|
|
|
|
* Name: mmcsd_slotinitialize
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Initialize one slot for operation using the MMC/SD interface
|
|
|
|
*
|
|
|
|
* Input Parameters:
|
|
|
|
* minor - The MMC/SD minor device number. The MMC/SD device will be
|
|
|
|
* registered as /dev/mmcsdN where N is the minor number
|
|
|
|
* dev - And instance of an MMC/SD interface. The MMC/SD hardware should
|
|
|
|
* be initialized and ready to use.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
2009-11-10 19:32:51 +01:00
|
|
|
struct sdio_dev_s; /* See nuttx/sdio.h */
|
2015-02-16 21:29:43 +01:00
|
|
|
int mmcsd_slotinitialize(int minor, FAR struct sdio_dev_s *dev);
|
2009-11-06 19:10:32 +01:00
|
|
|
|
2008-10-15 16:19:46 +02:00
|
|
|
/****************************************************************************
|
|
|
|
* Name: mmcsd_spislotinitialize
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Initialize one slot for operation using the SPI MMC/SD interface
|
|
|
|
*
|
|
|
|
* Input Parameters:
|
|
|
|
* minor - The MMC/SD minor device number. The MMC/SD device will be
|
|
|
|
* registered as /dev/mmcsdN where N is the minor number
|
2021-01-28 14:28:18 +01:00
|
|
|
* slotno - The slot number to use. This is only meaningful for
|
|
|
|
* architectures that support multiple MMC/SD slots. This value must be
|
|
|
|
* in the range {0, ..., CONFIG_MMCSD_NSLOTS}.
|
2016-01-27 16:27:56 +01:00
|
|
|
* spi - And instance of an SPI interface obtained by called the
|
2020-02-23 09:50:23 +01:00
|
|
|
* appropriate xyz_spibus_initialize() function for the MCU "xyz" with
|
2016-01-27 16:27:56 +01:00
|
|
|
* the appropriate port number.
|
2008-10-15 16:19:46 +02:00
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
2013-07-01 16:11:54 +02:00
|
|
|
struct spi_dev_s; /* See nuttx/spi/spi.h */
|
2021-09-06 15:15:19 +02:00
|
|
|
int mmcsd_spislotinitialize(int minor, int slotno,
|
2021-01-28 14:28:18 +01:00
|
|
|
FAR struct spi_dev_s *spi);
|
2008-10-15 16:19:46 +02:00
|
|
|
|
|
|
|
#undef EXTERN
|
|
|
|
#if defined(__cplusplus)
|
|
|
|
}
|
|
|
|
#endif
|
2012-07-17 05:58:11 +02:00
|
|
|
|
|
|
|
#endif /* __INCLUDE_NUTTX_MMCSD_H */
|