2008-10-15 21:15:53 +02:00
|
|
|
/****************************************************************************
|
|
|
|
* drivers/mmcsd/mmcsd_debug.c
|
|
|
|
*
|
2021-03-04 07:10:42 +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 21:15:53 +02:00
|
|
|
*
|
2021-03-04 07:10:42 +01:00
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
2008-10-15 21:15:53 +02:00
|
|
|
*
|
2021-03-04 07:10:42 +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 21:15:53 +02:00
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Included Files
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#include <nuttx/config.h>
|
|
|
|
|
2009-12-15 15:25:14 +01:00
|
|
|
#include <stdint.h>
|
|
|
|
#include <stdbool.h>
|
2008-10-15 21:15:53 +02:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <errno.h>
|
|
|
|
#include <debug.h>
|
|
|
|
|
|
|
|
#include "mmcsd_csd.h"
|
2015-12-30 00:31:17 +01:00
|
|
|
#include "mmcsd.h"
|
2008-10-15 21:15:53 +02:00
|
|
|
|
|
|
|
/****************************************************************************
|
2015-04-08 15:15:32 +02:00
|
|
|
* Pre-processor Definitions
|
2008-10-15 21:15:53 +02:00
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Private Types
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Private Function Prototypes
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Private Data
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Private Functions
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Public Functions
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Name: mmcsd_dmpcsd
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Dump the contents of the CSD
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
2016-06-11 19:50:18 +02:00
|
|
|
#if defined(CONFIG_DEBUG_INFO) && defined(CONFIG_DEBUG_FS)
|
2009-12-15 15:25:14 +01:00
|
|
|
void mmcsd_dmpcsd(FAR const uint8_t *csd, uint8_t cardtype)
|
2008-10-15 21:15:53 +02:00
|
|
|
{
|
2009-12-15 15:25:14 +01:00
|
|
|
bool mmc = (cardtype == MMCSD_CARDTYPE_MMC);
|
|
|
|
bool sd2 = (MMCSD_CSD_CSDSTRUCT(csd) == 1);
|
2008-10-15 21:15:53 +02:00
|
|
|
|
2016-06-11 19:59:51 +02:00
|
|
|
finfo("CSD\n");
|
|
|
|
finfo(" CSD_STRUCTURE: 1.%d\n", MMCSD_CSD_CSDSTRUCT(csd));
|
2008-10-15 21:15:53 +02:00
|
|
|
if (mmc)
|
|
|
|
{
|
2016-06-11 19:59:51 +02:00
|
|
|
finfo(" MMC SPEC_VERS: %d\n", MMC_CSD_SPECVERS(csd));
|
2008-10-15 21:15:53 +02:00
|
|
|
}
|
2014-10-08 18:18:58 +02:00
|
|
|
|
2021-09-05 15:47:50 +02:00
|
|
|
finfo(" TAAC:\n");
|
2016-06-11 19:59:51 +02:00
|
|
|
finfo(" TIME_VALUE: 0x%02x\n",
|
2008-10-15 21:15:53 +02:00
|
|
|
sd2 ? SD20_CSD_TAC_TIMEVALUE(csd) : MMCSD_CSD_TAAC_TIMEVALUE(csd));
|
2016-06-11 19:59:51 +02:00
|
|
|
finfo(" TIME_UNIT: 0x%02x\n",
|
2008-10-15 21:15:53 +02:00
|
|
|
sd2 ? SD20_CSD_TAC_TIMEUNIT(csd) : MMCSD_CSD_TAAC_TIMEUNIT(csd));
|
2016-06-11 19:59:51 +02:00
|
|
|
finfo(" NSAC: 0x%02x\n",
|
2008-10-15 21:15:53 +02:00
|
|
|
sd2 ? SD20_CSD_NSAC(csd) : MMCSD_CSD_NSAC(csd));
|
2016-06-11 19:59:51 +02:00
|
|
|
finfo(" TRAN_SPEED:\n");
|
|
|
|
finfo(" TIME_VALUE: 0x%02x\n",
|
2021-03-04 08:02:21 +01:00
|
|
|
sd2 ? SD20_CSD_TRANSPEED_TIMEVALUE(csd) :
|
|
|
|
MMCSD_CSD_TRANSPEED_TIMEVALUE(csd));
|
2016-06-11 19:59:51 +02:00
|
|
|
finfo(" RATE_UNIT: 0x%02x\n",
|
2021-03-04 08:02:21 +01:00
|
|
|
sd2 ? SD20_CSD_TRANSPEED_TRANSFERRATEUNIT(csd) :
|
|
|
|
MMCSD_CSD_TRANSPEED_TRANSFERRATEUNIT(csd));
|
2016-06-11 19:59:51 +02:00
|
|
|
finfo(" CCC: 0x%03x\n",
|
2008-10-15 21:15:53 +02:00
|
|
|
sd2 ? SD20_CSD_CCC(csd) : MMCSD_CSD_CCC(csd));
|
2016-06-11 19:59:51 +02:00
|
|
|
finfo(" READ_BL_LEN: %d\n",
|
2008-10-15 21:15:53 +02:00
|
|
|
sd2 ? SD20_CSD_READBLLEN(csd) : MMCSD_CSD_READBLLEN(csd));
|
2016-06-11 19:59:51 +02:00
|
|
|
finfo(" READ_BL_PARTIAL: %d\n",
|
2008-10-15 21:15:53 +02:00
|
|
|
sd2 ? SD20_CSD_READBLPARTIAL(csd) : MMCSD_CSD_READBLPARTIAL(csd));
|
2016-06-11 19:59:51 +02:00
|
|
|
finfo(" WRITE_BLK_MISALIGN: %d\n",
|
2021-03-04 08:02:21 +01:00
|
|
|
sd2 ? SD20_CSD_WRITEBLKMISALIGN(csd) :
|
|
|
|
MMCSD_CSD_WRITEBLKMISALIGN(csd));
|
2016-06-11 19:59:51 +02:00
|
|
|
finfo(" READ_BLK_MISALIGN: %d\n",
|
2021-03-04 08:02:21 +01:00
|
|
|
sd2 ? SD20_CSD_READBLKMISALIGN(csd) :
|
|
|
|
MMCSD_CSD_READBLKMISALIGN(csd));
|
2016-06-11 19:59:51 +02:00
|
|
|
finfo(" DSR_IMP: %d\n",
|
2008-10-15 21:15:53 +02:00
|
|
|
sd2 ? SD20_CSD_DSRIMP(csd) : MMCSD_CSD_DSRIMP(csd));
|
2016-06-11 19:59:51 +02:00
|
|
|
finfo(" C_SIZE: %d\n",
|
2008-10-15 21:15:53 +02:00
|
|
|
sd2 ? SD20_CSD_CSIZE(csd) : MMCSD_CSD_CSIZE(csd));
|
2016-06-11 19:59:51 +02:00
|
|
|
finfo(" VDD_R_CURR_MIN: %d\n",
|
2008-10-15 21:15:53 +02:00
|
|
|
sd2 ? SD20_CSD_VDDRCURRMIN(csd) : MMCSD_CSD_VDDRCURRMIN(csd));
|
2016-06-11 19:59:51 +02:00
|
|
|
finfo(" VDD_R_CURR_MAX: %d\n",
|
2008-10-15 21:15:53 +02:00
|
|
|
sd2 ? SD20_CSD_VDDRCURRMAX(csd) : MMCSD_CSD_VDDRCURRMAX(csd));
|
2016-06-11 19:59:51 +02:00
|
|
|
finfo(" VDD_W_CURR_MIN: %d\n",
|
2008-10-15 21:15:53 +02:00
|
|
|
sd2 ? SD20_CSD_VDDWCURRMIN(csd) : MMCSD_CSD_VDDWCURRMIN(csd));
|
2016-06-11 19:59:51 +02:00
|
|
|
finfo(" VDD_W_CURR_MAX: %d\n",
|
2008-10-15 21:15:53 +02:00
|
|
|
sd2 ? SD20_CSD_VDDWCURRMAX(csd) : MMCSD_CSD_VDDWCURRMAX(csd));
|
2016-06-11 19:59:51 +02:00
|
|
|
finfo(" C_SIZE_MULT: %d\n",
|
2008-10-15 21:15:53 +02:00
|
|
|
sd2 ? SD20_CSD_CSIZEMULT(csd) : MMCSD_CSD_CSIZEMULT(csd));
|
|
|
|
if (mmc)
|
|
|
|
{
|
2016-06-11 19:59:51 +02:00
|
|
|
finfo(" MMC SECTOR_SIZE: %d\n", MMC_CSD_SECTORSIZE(csd));
|
|
|
|
finfo(" MMC ER_GRP_SIZE: %d\n", MMC_CSD_ERGRPSIZE(csd));
|
|
|
|
finfo(" MMC WP_GRP_SIZE: %d\n", MMC_CSD_WPGRPSIZE(csd));
|
|
|
|
finfo(" MMC DFLT_ECC: %d\n", MMC_CSD_DFLTECC(csd));
|
2008-10-15 21:15:53 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2016-06-11 19:59:51 +02:00
|
|
|
finfo(" SD ER_BLK_EN: %d\n",
|
2008-10-15 21:15:53 +02:00
|
|
|
sd2 ? SD20_CSD_SDERBLKEN(csd) : SD_CSD_SDERBLKEN(csd));
|
2016-06-11 19:59:51 +02:00
|
|
|
finfo(" SD SECTOR_SIZE: %d\n",
|
2008-10-15 21:15:53 +02:00
|
|
|
sd2 ? SD20_CSD_SECTORSIZE(csd) : SD_CSD_SECTORSIZE(csd));
|
2016-06-11 19:59:51 +02:00
|
|
|
finfo(" SD WP_GRP_SIZE: %d\n",
|
2008-10-15 21:15:53 +02:00
|
|
|
sd2 ? SD_CSD_WPGRPSIZE(csd) : SD_CSD_WPGRPSIZE(csd));
|
|
|
|
}
|
2021-03-04 08:02:21 +01:00
|
|
|
|
2016-06-11 19:59:51 +02:00
|
|
|
finfo(" WP_GRP_EN: %d\n",
|
2008-10-15 21:15:53 +02:00
|
|
|
sd2 ? SD20_WPGRPEN(csd) : MMCSD_WPGRPEN(csd));
|
2016-06-11 19:59:51 +02:00
|
|
|
finfo(" R2W_FACTOR: %d\n",
|
2008-10-15 21:15:53 +02:00
|
|
|
sd2 ? SD20_CSD_R2WFACTOR(csd) : MMCSD_CSD_R2WFACTOR(csd));
|
2016-06-11 19:59:51 +02:00
|
|
|
finfo(" WRITE_BL_LEN: %d\n",
|
2008-10-15 21:15:53 +02:00
|
|
|
sd2 ? SD20_CSD_WRITEBLLEN(csd) : MMCSD_CSD_WRITEBLLEN(csd));
|
2016-06-11 19:59:51 +02:00
|
|
|
finfo(" WRITE_BL_PARTIAL: %d\n",
|
2008-10-15 21:15:53 +02:00
|
|
|
sd2 ? SD20_CSD_WRITEBLPARTIAL(csd) : MMCSD_CSD_WRITEBLPARTIAL(csd));
|
2016-06-11 19:59:51 +02:00
|
|
|
finfo(" FILE_FORMAT_GROUP: %d\n",
|
2008-10-15 21:15:53 +02:00
|
|
|
sd2 ? SD20_CSD_FILEFORMATGRP(csd) : MMCSD_CSD_FILEFORMATGRP(csd));
|
2016-06-11 19:59:51 +02:00
|
|
|
finfo(" COPY: %d\n",
|
2008-10-15 21:15:53 +02:00
|
|
|
sd2 ? SD20_CSD_COPY(csd) : MMCSD_CSD_COPY(csd));
|
2016-06-11 19:59:51 +02:00
|
|
|
finfo(" PERM_WRITE_PROTECT: %d\n",
|
2021-03-04 08:02:21 +01:00
|
|
|
sd2 ? SD20_CSD_PERMWRITEPROTECT(csd) :
|
|
|
|
MMCSD_CSD_PERMWRITEPROTECT(csd));
|
2016-06-11 19:59:51 +02:00
|
|
|
finfo(" TMP_WRITE_PROTECT: %d\n",
|
2008-10-15 21:15:53 +02:00
|
|
|
sd2 ?SD20_CSD_TMPWRITEPROTECT(csd) : MMCSD_CSD_TMPWRITEPROTECT(csd));
|
2016-06-11 19:59:51 +02:00
|
|
|
finfo(" FILE_FORMAT: %d\n",
|
2008-10-15 21:15:53 +02:00
|
|
|
sd2 ? SD20_CSD_FILEFORMAT(csd) : MMCSD_CSD_FILEFORMAT(csd));
|
|
|
|
if (mmc)
|
|
|
|
{
|
2016-06-11 19:59:51 +02:00
|
|
|
finfo(" MMC ECC: %d\n",
|
2008-10-15 21:15:53 +02:00
|
|
|
sd2 ? MMC_CSD_ECC(csd) : MMC_CSD_ECC(csd));
|
|
|
|
}
|
2021-03-04 08:02:21 +01:00
|
|
|
|
2016-06-11 19:59:51 +02:00
|
|
|
finfo(" CRC: %02x\n",
|
2008-10-15 21:15:53 +02:00
|
|
|
sd2 ? SD20_CSD_CRC(csd) : MMCSD_CSD_CRC(csd));
|
|
|
|
}
|
|
|
|
#endif
|