sda.h revision 4bb7efa72ed531c10f097919636e67724ec4c25a
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#ifndef _SYS_SDCARD_SDA_H
#define _SYS_SDCARD_SDA_H
#ifdef __cplusplus
extern "C" {
#endif
/*
* SD card common framework. This module provides most of the common
* functionality so that SecureDigital host adapters and client devices
* (such as the sdmem driver) can share common code.
*/
/*
* SD Commands. Commmand format is 48-bits as follows:
*
* bits value desc
* -------------------------------------------
* 47 0 start bit
* 46 1 transmission bit
* 45:40 cmd command index (see values listed below)
* 39:8 arg 32-bit command argument
* 7:1 crc7 crc7 check value
* 0 1 end bit
* -------------------------------------------
*/
typedef enum {
CMD_GO_IDLE = 0,
CMD_BCAST_CID = 2,
CMD_SEND_RCA = 3,
CMD_SET_DSR = 4,
CMD_SWITCH_FUNC = 6,
CMD_SELECT_CARD = 7,
CMD_SEND_IF_COND = 8,
CMD_SEND_CSD = 9,
CMD_SEND_CID = 10,
CMD_STOP_TRANSMIT = 12,
CMD_SEND_STATUS = 13,
CMD_GO_INACTIVE = 15,
CMD_SET_BLOCKLEN = 16,
CMD_READ_SINGLE = 17,
CMD_READ_MULTI = 18,
CMD_WRITE_SINGLE = 24,
CMD_WRITE_MULTI = 25,
CMD_PROGRAM_CSD = 27,
CMD_SET_WRITE_PROT = 28,
CMD_CLR_WRITE_PROT = 29,
CMD_SEND_WRITE_PROT = 30,
CMD_ERASE_START = 32,
CMD_ERASE_END = 33,
CMD_ERASE = 38,
CMD_LOCK = 42,
CMD_IO_RW_DIRECT = 52,
CMD_IO_RW_EXTENDED = 53,
CMD_APP_CMD = 55,
CMD_GEN_CMD = 56,
/* APP CMD values, send ACMD first */
ACMD_SET_BUS_WIDTH = 6,
ACMD_SD_STATUS = 13,
ACMD_SEND_NUM_WR_BLKS = 22,
ACMD_SD_SEND_OCR = 41,
ACMD_SET_CLR_CARD_DETECT = 42,
ACMD_SEND_SCR = 51
} sda_index_t;
/*
* Classes of response type. Note that we encode the "busy bit" as
* value 0x10.
*/
typedef enum {
R0 = 0,
R1 = 1,
R2 = 2,
R3 = 3,
R4 = 4,
R5 = 5,
R6 = 6,
R7 = 7,
Rb = 0x10,
R1b = 0x11,
R5b = 0x15
} sda_rtype_t;
/*
* R1 status bits.
*/
/*
* Note that R1_COM_CRC_ERR, R1_ILLEGAL_COMMAND, R1_ERASE_SEQ_ERROR, and
* R1_AKE_SEQ_ERROR errors are delayed error bits reported on the next
* command. So we don't list them here.
*/
#define R1_ERRS (\
/*
* R5 status bits.
*/
#define R5_OUT_OF_RANGE (1U << 0)
/*
* R7 bits (CMD8).
*/
#define R7_PATTERN (0xAA)
/*
* OCR bits.
*/
/*
* Command structure. Used internally by the framework, and by host
* drivers. Note that it is forbidden to depend on the size of this
* structure.
*/
struct sda_cmd {
/*
* The ordering of these is done to maximize packing.
*/
/* private flags .. not for driver consumption */
};
/*
* The framework has two APIs. The first API is for host controllers,
* and is referred to as SDHOST. The second API is for target devices,
* and is referred to as SDCLIENT. Please don't mix and match usage outside
* of the framework implementation itself!
*/
typedef struct sda_host sda_host_t;
typedef enum {
} sda_prop_t;
typedef enum {
SDA_FAULT_NONE = 0, /* No failure */
} sda_fault_t;
typedef enum {
SDA_EOK = 0, /* Success */
} sda_err_t;
typedef struct sda_ops {
int so_version;
#define SDA_OPS_VERSION 1
} sda_ops_t;
/*
* Host operations.
*/
void sda_host_init_ops(struct dev_ops *);
void sda_host_fini_ops(struct dev_ops *);
void sda_host_free(sda_host_t *);
void sda_host_set_private(sda_host_t *, int, void *);
int sda_host_attach(sda_host_t *);
void sda_host_detach(sda_host_t *);
void sda_host_detect(sda_host_t *, int);
/*PRINTFLIKE3*/
void sda_host_log(sda_host_t *, int, const char *, ...);
#ifdef __cplusplus
}
#endif
#endif /* _SYS_SDCARD_SDA_H */