#define SD_MODE_CARD_IDENTIFICATION 1
#define SD_MODE_DATA_TRANSFER_MODE 2
-
struct sd_card_regs
{
- uint32_t cid[4]; /* Card Identification */
- uint32_t rca; /* Relative card address */
- uint32_t dsr; /* Driver stage register */
- uint32_t csd[4]; /* Card specific data */
- uint32_t scr[2]; /* SD configuration */
- uint32_t ocr; /* Operation conditions */
- uint32_t ssr[5]; /* SD Status */
- uint32_t csr; /* Card status */
+ uint32_t cid[4]; /* Card Identification */
+ uint32_t rca; /* Relative card address */
+ uint32_t dsr; /* Driver stage register */
+ uint32_t csd[4]; /* Card specific data */
+ uint32_t scr[2]; /* SD configuration */
+ uint32_t ocr; /* Operation conditions */
+ uint32_t ssr[5]; /* SD Status */
+ uint32_t csr; /* Card status */
};
/* struct representing an mmc command */
#define NO_RESPONSE (0<<0)
uint32_t resp[4];
- unsigned char* data;
+ unsigned char *data;
uint32_t data_len;
};
/* MMC host configuration */
int (*host_init) (struct mmc_host * host);
/* Set log level */
- void(*set_log_level) (int level);
+ void (*set_log_level) (int level);
/* Host controller reset */
int (*host_reset) (struct mmc_host * host);
/* Card detection (binary yes/no) */
/* omap /hardware related */
#include "omap_mmc.h"
+/*
+ * Define a structure to be used for logging
+ */
+static struct mmclog log = {
+ .name = "mmc_host_mmchs",
+ .log_level = LEVEL_INFO,
+ .log_func = default_log
+};
+
#define REG(x)(*((volatile uint32_t *)(x)))
#define BIT(x)(0x1 << x)
base_address = (unsigned long) base_address - 0x100;
- /* Soft reset of the controller. This section is documented in the TRM */
+ /* Soft reset of the controller. This section is documented in the TRM
+ */
/* Write 1 to sysconfig[0] to trigger a reset */
set32(base_address + MMCHS_SD_SYSCONFIG, MMCHS_SD_SYSCONFIG_SOFTRESET,
set32(base_address + MMCHS_SD_HCTL, MMCHS_SD_HCTL_SDBP,
MMCHS_SD_HCTL_SDBP_ON);
- /* TODO: Add padconf stuff here as documented in the TRM*/
+ /* TODO: Add padconf stuff here as documented in the TRM */
while ((read32(base_address + MMCHS_SD_HCTL) & MMCHS_SD_HCTL_SDBP)
!= MMCHS_SD_HCTL_SDBP_ON) {
while ((read32(base_address + MMCHS_SD_STAT) & MMCHS_SD_STAT_CC)
!= MMCHS_SD_STAT_CC_RAISED) {
if (read32(base_address + MMCHS_SD_STAT) & 0x8000) {
- printf("%s, error stat %x\n", __FUNCTION__,
+ mmc_log_warn(&log, "%s, error stat %x\n",
+ __FUNCTION__,
read32(base_address + MMCHS_SD_STAT));
return 1;
}
/* Read current interrupt status and fail it an interrupt is already
* asserted */
if ((read32(base_address + MMCHS_SD_STAT) & 0xffffu)) {
- printf("%s, interrupt already raised stat %08x\n",
+ mmc_log_warn(&log, "%s, interrupt already raised stat %08x\n",
__FUNCTION__, read32(base_address + MMCHS_SD_STAT));
write32(base_address + MMCHS_SD_STAT,
MMCHS_SD_IE_CC_ENABLE_CLEAR);
}
if (read32(base_address + MMCHS_SD_STAT) & 0x8000) {
- printf("%s, error stat %08x\n", __FUNCTION__,
+ mmc_log_warn(&log, "%s, error stat %08x\n", __FUNCTION__,
read32(base_address + MMCHS_SD_STAT));
set32(base_address + MMCHS_SD_STAT, MMCHS_SD_STAT_ERROR_MASK,
0xffffffffu);
if (!(command.resp[0]
== (MMCHS_SD_ARG_CMD8_VHS | MMCHS_SD_ARG_CMD8_CHECK_PATTERN))) {
- printf("%s, check pattern check failed %08x\n", __FUNCTION__,
- command.resp[0]);
+ mmc_log_warn(&log, "%s, check pattern check failed %08x\n",
+ __FUNCTION__, command.resp[0]);
return 1;
}
return 0;
card->csd[3] = command.resp[3];
if (SD_CSD_CSDVER(card->csd) != SD_CSD_CSDVER_2_0) {
- printf("Version 2.0 of CSD register expected\n");
+ mmc_log_warn(&log, "Version 2.0 of CSD register expected\n");
return 1;
}
/* sanity check */
- // printf("size = %llu bytes\n", (long long
+ // mmc_log_warn(&log,"size = %llu bytes\n", (long long
// unsigned)SD_CSD_V2_CAPACITY( card->csd) * 512);
return 0;
}
return 0;
}
-/*
- * Define a structure to be used for logging
- */
-static struct mmclog log = {
- .name = "mmc_host_mmchs",
- .log_level = LEVEL_INFO,
- .log_func = default_log
-};
-
int
mmchs_host_init(struct mmc_host *host)
{
card->slot = slot;
if (card_goto_idle_state()) {
- printf("Failed to go idle state\n");
+ mmc_log_warn(&log, "Failed to go idle state\n");
return NULL;
}
if (card_identification()) {
- printf("Failed to do card_identification\n");
+ mmc_log_warn(&log, "Failed to do card_identification\n");
return NULL;
}
if (card_query_voltage_and_type(&slot->card.regs)) {
- printf("Failed to do card_query_voltage_and_type\n");
+ mmc_log_warn(&log,
+ "Failed to do card_query_voltage_and_type\n");
return NULL;
}
if (card_identify(&slot->card.regs)) {
- printf("Failed to identify card\n");
+ mmc_log_warn(&log, "Failed to identify card\n");
return NULL;
}
/* We have now initialized the hardware identified the card */
if (card_csd(&slot->card.regs)) {
- printf("failed to read csd (card specific data)\n");
+ mmc_log_warn(&log,
+ "failed to read csd (card specific data)\n");
return NULL;
}
if (select_card(&slot->card.regs)) {
- printf("Failed to select card\n");
+ mmc_log_warn(&log, "Failed to select card\n");
return NULL;
}
if (SD_CSD_READ_BL_LEN(slot->card.regs.csd) != 0x09) {
/* for CSD version 2.0 the value is fixed to 0x09 and means a
* block size of 512 */
- printf("Block size expect to be 512\n");
+ mmc_log_warn(&log, "Block size expect to be 512\n");
return NULL;
}