* drivers/mmcsd/mmcsd.h
*
* SPDX-License-Identifier: Apache-2.0
*
* 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.
*
****************************************************************************/
#ifndef __DRIVERS_MMCSD_MMCSD_H
#define __DRIVERS_MMCSD_MMCSD_H
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <nuttx/sdio.h>
#include <stdint.h>
#include <debug.h>
* Pre-processor Definitions
****************************************************************************/
#undef CONFIG_MMCSD_DUMPALL
#if !defined(CONFIG_DEBUG_INFO) || !defined(CONFIG_DEBUG_FS)
# undef CONFIG_MMCSD_DUMPALL
#endif
#define MMCSD_PART_COUNT 8
#define MMCSD_CARDTYPE_UNKNOWN 0
#define MMCSD_CARDTYPE_MMC 1
#define MMCSD_CARDTYPE_SDV1 2
#define MMCSD_CARDTYPE_SDV2 4
#define MMCSD_CARDTYPE_BLOCK 8
#define IS_MMC(t) (((t) & MMCSD_CARDTYPE_MMC) != 0)
#define IS_SD(t) (((t) & (MMCSD_CARDTYPE_SDV1|MMCSD_CARDTYPE_SDV2)) != 0)
#define IS_SDV1(t) (((t) & MMCSD_CARDTYPE_SDV1) != 0)
#define IS_SDV2(t) (((t) & MMCSD_CARDTYPE_SDV2) != 0)
#define IS_BLOCK(t) (((t) & MMCSD_CARDTYPE_BLOCK) != 0)
* Public Types
****************************************************************************/
struct mmcsd_part_s
{
FAR struct mmcsd_state_s *priv;
blkcnt_t nblocks;
};
struct mmcsd_state_s
{
FAR struct sdio_dev_s *dev;
uint8_t crefs;
mutex_t lock;
int minor;
struct mmcsd_part_s part[MMCSD_PART_COUNT];
uint32_t partnum;
uint8_t probed:1;
uint8_t widebus:1;
uint8_t mediachanged:1;
uint8_t wrbusy:1;
uint8_t wrprotect:1;
uint8_t locked:1;
uint8_t dsrimp:1;
#ifdef CONFIG_SDIO_DMA
uint8_t dma:1;
#endif
uint8_t mode:4;
uint8_t type:4;
uint8_t buswidth:4;
uint8_t cmd23support:1;
sdio_capset_t caps;
uint32_t cid[4];
uint32_t csd[4];
uint16_t selblocklen;
uint16_t rca;
uint8_t blockshift;
uint16_t blocksize;
};
* Public Functions Definitions
****************************************************************************/
#undef EXTERN
#if defined(__cplusplus)
#define EXTERN extern "C"
extern "C"
{
#else
#define EXTERN extern
#endif
#ifdef CONFIG_MMCSD_PROCFS
void mmcsd_initialize_procfs(void);
#endif
#ifdef CONFIG_MMCSD_DUMPALL
# define mmcsd_dumpbuffer(m,b,l) finfodumpbuffer(m,b,l)
#else
# define mmcsd_dumpbuffer(m,b,l)
#endif
#if defined(CONFIG_DEBUG_INFO) && defined(CONFIG_DEBUG_FS)
EXTERN void mmcsd_dmpcsd(FAR const uint8_t *csd, uint8_t cardtype);
#else
# define mmcsd_dmpcsd(csd,cadtype)
#endif
#undef EXTERN
#if defined(__cplusplus)
}
#endif
#endif