FreeBSD kernel CAM code
mmc_xpt.c File Reference
#include <sys/cdefs.h>
#include <sys/param.h>
#include <sys/bus.h>
#include <sys/endian.h>
#include <sys/systm.h>
#include <sys/types.h>
#include <sys/malloc.h>
#include <sys/kernel.h>
#include <sys/time.h>
#include <sys/conf.h>
#include <sys/fcntl.h>
#include <sys/interrupt.h>
#include <sys/sbuf.h>
#include <sys/lock.h>
#include <sys/mutex.h>
#include <sys/sysctl.h>
#include <sys/condvar.h>
#include <cam/cam.h>
#include <cam/cam_ccb.h>
#include <cam/cam_queue.h>
#include <cam/cam_periph.h>
#include <cam/cam_sim.h>
#include <cam/cam_xpt.h>
#include <cam/cam_xpt_sim.h>
#include <cam/cam_xpt_periph.h>
#include <cam/cam_xpt_internal.h>
#include <cam/cam_debug.h>
#include <cam/mmc/mmc.h>
#include <cam/mmc/mmc_bus.h>
#include <machine/stdarg.h>
#include <machine/_inttypes.h>
#include "opt_cam.h"
Include dependency graph for mmc_xpt.c:

Go to the source code of this file.

Data Structures

struct  mmcprobe_softc
 

Macros

#define PROBE_SET_ACTION(softc, newaction)
 
#define MMC_XPT_XPORT(x, X)
 
#define PROBE_FLAG_ACMD_SENT   0x1 /* CMD55 is sent, card expects ACMD */
 
#define PROBE_FLAG_HOST_CAN_DO_18V   0x2 /* Host can do 1.8V signaling */
 
#define CARD_ID_FREQUENCY   400000 /* Spec requires 400kHz max during ID phase. */
 

Enumerations

enum  probe_action {
  PROBE_RESET , PROBE_IDENTIFY , PROBE_POWER_OFF , PROBE_GET_HOST_OCR ,
  PROBE_RESET_BUS , PROBE_SET_ID_FREQ , PROBE_SET_CS , PROBE_GO_IDLE_STATE ,
  PROBE_SDIO_RESET , PROBE_SEND_IF_COND , PROBE_SDIO_INIT , PROBE_MMC_INIT ,
  PROBE_SEND_APP_OP_COND , PROBE_GET_CID , PROBE_GET_CSD , PROBE_SEND_RELATIVE_ADDR ,
  PROBE_MMC_SET_RELATIVE_ADDR , PROBE_SELECT_CARD , PROBE_DONE , PROBE_INVALID ,
  PROBE_TUR , PROBE_INQUIRY , PROBE_FULL_INQUIRY , PROBE_REPORT_LUNS ,
  PROBE_MODE_SENSE , PROBE_SUPPORTED_VPD_LIST , PROBE_DEVICE_ID , PROBE_EXTENDED_INQUIRY ,
  PROBE_SERIAL_NUM , PROBE_TUR_FOR_NEGOTIATION , PROBE_INQUIRY_BASIC_DV1 , PROBE_INQUIRY_BASIC_DV2 ,
  PROBE_DV_EXIT , PROBE_DONE , PROBE_INVALID
}
 

Functions

 __FBSDID ("$FreeBSD$")
 
 FEATURE (mmccam, "CAM-based MMC/SD/SDIO stack")
 
static struct cam_edmmc_alloc_device (struct cam_eb *bus, struct cam_et *target, lun_id_t lun_id)
 
static void mmc_dev_async (u_int32_t async_code, struct cam_eb *bus, struct cam_et *target, struct cam_ed *device, void *async_arg)
 
static void mmc_action (union ccb *start_ccb)
 
static void mmc_dev_advinfo (union ccb *start_ccb)
 
static void mmc_announce_periph (struct cam_periph *periph)
 
static void mmc_scan_lun (struct cam_periph *periph, struct cam_path *path, cam_flags flags, union ccb *ccb)
 
static cam_status mmcprobe_register (struct cam_periph *periph, void *arg)
 
static void mmcprobe_start (struct cam_periph *periph, union ccb *start_ccb)
 
static void mmcprobe_cleanup (struct cam_periph *periph)
 
static void mmcprobe_done (struct cam_periph *periph, union ccb *done_ccb)
 
static void mmc_proto_announce (struct cam_ed *device)
 
static void mmc_proto_denounce (struct cam_ed *device)
 
static void mmc_proto_debug_out (union ccb *ccb)
 
 MMC_XPT_XPORT (mmc, MMCSD)
 
 CAM_XPT_PROTO (mmc_proto)
 
void mmccam_start_discovery (struct cam_sim *sim)
 
static void mmc_print_ident (struct mmc_params *ident_data, struct sbuf *sb)
 
 PERIPHDRIVER_DECLARE (mmcprobe, probe_driver)
 
static int mmc_highest_voltage (uint32_t ocr)
 
static void init_standard_ccb (union ccb *ccb, uint32_t cmd)
 
void mmc_path_inq (struct ccb_pathinq *cpi, const char *hba, const struct cam_sim *sim, size_t maxio)
 

Variables

static char * probe_action_text []
 
static struct xpt_xport_ops mmc_xport_ops
 
static struct xpt_proto_ops mmc_proto_ops
 
static struct xpt_proto mmc_proto
 
static periph_init_t probe_periph_init
 
static struct periph_driver probe_driver
 

Macro Definition Documentation

◆ CARD_ID_FREQUENCY

#define CARD_ID_FREQUENCY   400000 /* Spec requires 400kHz max during ID phase. */

Definition at line 515 of file mmc_xpt.c.

◆ MMC_XPT_XPORT

#define MMC_XPT_XPORT (   x,
 
)
Value:
static struct xpt_xport mmc_xport_ ## x = { \
.xport = XPORT_ ## X, \
.name = #x, \
}; \
CAM_XPT_XPORT(mmc_xport_ ## x);
static struct xpt_xport_ops mmc_xport_ops
Definition: mmc_xpt.c:146
cam_xport xport
struct xpt_xport_ops * ops

Definition at line 153 of file mmc_xpt.c.

◆ PROBE_FLAG_ACMD_SENT

#define PROBE_FLAG_ACMD_SENT   0x1 /* CMD55 is sent, card expects ACMD */

Definition at line 181 of file mmc_xpt.c.

◆ PROBE_FLAG_HOST_CAN_DO_18V

#define PROBE_FLAG_HOST_CAN_DO_18V   0x2 /* Host can do 1.8V signaling */

Definition at line 182 of file mmc_xpt.c.

◆ PROBE_SET_ACTION

#define PROBE_SET_ACTION (   softc,
  newaction 
)
Value:
do { \
char **text; \
CAM_DEBUG((softc)->periph->path, CAM_DEBUG_PROBE, \
("Probe %s to %s\n", text[(softc)->action], \
text[(newaction)])); \
(softc)->action = (newaction); \
} while(0)
@ CAM_DEBUG_PROBE
Definition: cam_debug.h:46
static char * probe_action_text[]
Definition: mmc_xpt.c:113

Definition at line 136 of file mmc_xpt.c.

Enumeration Type Documentation

◆ probe_action

Enumerator
PROBE_RESET 
PROBE_IDENTIFY 
PROBE_POWER_OFF 
PROBE_GET_HOST_OCR 
PROBE_RESET_BUS 
PROBE_SET_ID_FREQ 
PROBE_SET_CS 
PROBE_GO_IDLE_STATE 
PROBE_SDIO_RESET 
PROBE_SEND_IF_COND 
PROBE_SDIO_INIT 
PROBE_MMC_INIT 
PROBE_SEND_APP_OP_COND 
PROBE_GET_CID 
PROBE_GET_CSD 
PROBE_SEND_RELATIVE_ADDR 
PROBE_MMC_SET_RELATIVE_ADDR 
PROBE_SELECT_CARD 
PROBE_DONE 
PROBE_INVALID 
PROBE_TUR 
PROBE_INQUIRY 
PROBE_FULL_INQUIRY 
PROBE_REPORT_LUNS 
PROBE_MODE_SENSE 
PROBE_SUPPORTED_VPD_LIST 
PROBE_DEVICE_ID 
PROBE_EXTENDED_INQUIRY 
PROBE_SERIAL_NUM 
PROBE_TUR_FOR_NEGOTIATION 
PROBE_INQUIRY_BASIC_DV1 
PROBE_INQUIRY_BASIC_DV2 
PROBE_DV_EXIT 
PROBE_DONE 
PROBE_INVALID 

Definition at line 90 of file mmc_xpt.c.

Function Documentation

◆ __FBSDID()

__FBSDID ( "$FreeBSD$"  )

◆ CAM_XPT_PROTO()

CAM_XPT_PROTO ( mmc_proto  )

◆ FEATURE()

FEATURE ( mmccam  ,
"CAM-based MMC/SD/SDIO stack"   
)

◆ init_standard_ccb()

static void init_standard_ccb ( union ccb ccb,
uint32_t  cmd 
)
inlinestatic

Definition at line 586 of file mmc_xpt.c.

References CAM_DIR_OUT, ccb_hdr::cbfcnp, ccb::ccb_h, ccb_hdr::flags, ccb_hdr::func_code, mmcprobe_done(), ccb_hdr::retry_count, and ccb_hdr::timeout.

Referenced by mmcprobe_start().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ mmc_action()

static void mmc_action ( union ccb start_ccb)
static

◆ mmc_alloc_device()

static struct cam_ed * mmc_alloc_device ( struct cam_eb bus,
struct cam_et target,
lun_id_t  lun_id 
)
static

◆ mmc_announce_periph()

static void mmc_announce_periph ( struct cam_periph periph)
static

◆ mmc_dev_advinfo()

◆ mmc_dev_async()

static void mmc_dev_async ( u_int32_t  async_code,
struct cam_eb bus,
struct cam_et target,
struct cam_ed device,
void *  async_arg 
)
static

Definition at line 210 of file mmc_xpt.c.

References AC_LOST_DEVICE, CAM_DEV_UNCONFIGURED, CAM_LUN_WILDCARD, CAM_TARGET_WILDCARD, cam_ed::flags, cam_ed::lun_id, cam_ed::target, cam_et::target_id, and xpt_release_device().

Here is the call graph for this function:

◆ mmc_highest_voltage()

static int mmc_highest_voltage ( uint32_t  ocr)
static

Definition at line 574 of file mmc_xpt.c.

Referenced by mmcprobe_start().

Here is the caller graph for this function:

◆ mmc_path_inq()

◆ mmc_print_ident()

static void mmc_print_ident ( struct mmc_params ident_data,
struct sbuf *  sb 
)
static

◆ mmc_proto_announce()

static void mmc_proto_announce ( struct cam_ed device)
static

Definition at line 476 of file mmc_xpt.c.

References cam_ed::mmc_ident_data, and mmc_print_ident().

Referenced by mmc_proto_denounce().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ mmc_proto_debug_out()

static void mmc_proto_debug_out ( union ccb ccb)
static

Definition at line 495 of file mmc_xpt.c.

References CAM_DEBUG, CAM_DEBUG_CDB, ccb::ccb_h, ccb_hdr::func_code, ccb_hdr::path, and XPT_MMC_IO.

◆ mmc_proto_denounce()

static void mmc_proto_denounce ( struct cam_ed device)
static

Definition at line 488 of file mmc_xpt.c.

References mmc_proto_announce().

Here is the call graph for this function:

◆ mmc_scan_lun()

static void mmc_scan_lun ( struct cam_periph periph,
struct cam_path path,
cam_flags  flags,
union ccb ccb 
)
static

◆ MMC_XPT_XPORT()

MMC_XPT_XPORT ( mmc  ,
MMCSD   
)

◆ mmccam_start_discovery()

void mmccam_start_discovery ( struct cam_sim sim)

Definition at line 403 of file mmc_xpt.c.

References CAM_REQ_CMP, cam_sim_name(), cam_sim_path(), ccb, ccb::ccb_h, ccb_hdr::path, xpt_alloc_ccb(), xpt_create_path(), xpt_free_ccb(), xpt_path_sim_device(), and xpt_rescan().

Referenced by mmc_cam_sim_discover().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ mmcprobe_cleanup()

static void mmcprobe_cleanup ( struct cam_periph periph)
static

Definition at line 812 of file mmc_xpt.c.

References cam_periph::softc.

Referenced by mmc_scan_lun().

Here is the caller graph for this function:

◆ mmcprobe_done()

static void mmcprobe_done ( struct cam_periph periph,
union ccb done_ccb 
)
static

Definition at line 818 of file mmc_xpt.c.

References AC_FOUND_DEVICE, AC_LOST_DEVICE, mmcprobe_softc::action, CAM_DEBUG, CAM_DEBUG_PROBE, CAM_DEV_UNCONFIGURED, CAM_DIR_NONE, cam_periph_invalidate(), cam_periph_release_locked(), cam_release_devq(), mmc_params::card_cid, mmc_params::card_csd, CARD_FEATURE_18V, CARD_FEATURE_MEMORY, CARD_FEATURE_MMC, CARD_FEATURE_SD20, CARD_FEATURE_SDHC, CARD_FEATURE_SDIO, mmc_params::card_features, mmc_params::card_ocr, mmc_params::card_rca, ccb_hdr::cbfcnp, ccb::ccb_h, ccb_mmcio::cmd, ccb::cts, cts, cam_path::device, ccb_hdr::flags, cam_ed::flags, mmcprobe_softc::flags, ccb_hdr::func_code, ccb_trans_settings_mmc::host_ocr, mmcprobe_softc::host_ocr, mmc_params::io_ocr, ccb_trans_settings_mmc::ios, ccb_trans_settings_mmc::ios_valid, ccb_trans_settings::mmc, cam_ed::mmc_ident_data, MMC_PROPOSED_RCA, MMC_VCCQ, ccb::mmcio, ccb_hdr::path, cam_periph::path, ccb_hdr::pinfo, cam_pinfo::priority, PROBE_DONE, PROBE_FLAG_ACMD_SENT, PROBE_FLAG_HOST_CAN_DO_18V, PROBE_GET_CID, PROBE_GET_CSD, PROBE_GET_HOST_OCR, PROBE_GO_IDLE_STATE, PROBE_IDENTIFY, PROBE_INVALID, PROBE_MMC_INIT, PROBE_MMC_SET_RELATIVE_ADDR, PROBE_POWER_OFF, PROBE_RESET, PROBE_RESET_BUS, PROBE_SDIO_INIT, PROBE_SDIO_RESET, PROBE_SELECT_CARD, PROBE_SEND_APP_OP_COND, PROBE_SEND_IF_COND, PROBE_SEND_RELATIVE_ADDR, PROBE_SET_ACTION, PROBE_SET_CS, PROBE_SET_ID_FREQ, PROTO_MMCSD, ccb_trans_settings::proto_specific, cam_ed::protocol, ccb_hdr::retry_count, mmc_params::sdio_func_count, cam_periph::softc, ccb_hdr::timeout, xpt_acquire_device(), xpt_action(), xpt_async(), XPT_GDEV_TYPE, xpt_release_ccb(), xpt_schedule(), and XPT_SET_TRAN_SETTINGS.

Referenced by init_standard_ccb(), and mmcprobe_start().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ mmcprobe_register()

◆ mmcprobe_start()

static void mmcprobe_start ( struct cam_periph periph,
union ccb start_ccb 
)
static

Definition at line 596 of file mmc_xpt.c.

References mmcprobe_softc::acmd41_count, mmcprobe_softc::action, CAM_DEBUG, CAM_DEBUG_PROBE, CAM_DEV_QFREEZE, CAM_DEV_UNCONFIGURED, CAM_DIR_NONE, cam_fill_mmcio(), CARD_ID_FREQUENCY, mmc_params::card_rca, ccb::ccb_h, ccb_mmcio::cmd, ccb::cpi, ccb::cts, cts, cam_path::device, ccb_hdr::flags, cam_ed::flags, mmcprobe_softc::flags, ccb_trans_settings_mmc::host_caps, mmcprobe_softc::host_ocr, init_standard_ccb(), ccb_trans_settings_mmc::ios, ccb_trans_settings_mmc::ios_valid, ccb_trans_settings::mmc, MMC_BM, MMC_BT, MMC_BW, MMC_CAP_SIGNALING_180, MMC_CLK, MMC_CS, mmc_highest_voltage(), cam_ed::mmc_ident_data, MMC_PM, MMC_PROPOSED_RCA, MMC_VDD, ccb::mmcio, mmcprobe_done(), ccb_hdr::path, cam_periph::path, PROBE_DONE, PROBE_FLAG_ACMD_SENT, PROBE_FLAG_HOST_CAN_DO_18V, PROBE_GET_CID, PROBE_GET_CSD, PROBE_GET_HOST_OCR, PROBE_GO_IDLE_STATE, PROBE_IDENTIFY, PROBE_INVALID, PROBE_MMC_INIT, PROBE_MMC_SET_RELATIVE_ADDR, PROBE_POWER_OFF, PROBE_RESET, PROBE_RESET_BUS, PROBE_SDIO_INIT, PROBE_SDIO_RESET, PROBE_SELECT_CARD, PROBE_SEND_APP_OP_COND, PROBE_SEND_IF_COND, PROBE_SEND_RELATIVE_ADDR, PROBE_SET_CS, PROBE_SET_ID_FREQ, ccb_trans_settings::proto_specific, mmcprobe_softc::restart, cam_periph::softc, ccb_mmcio::stop, xpt_action(), XPT_MMC_GET_TRAN_SETTINGS, XPT_MMC_IO, XPT_MMC_SET_TRAN_SETTINGS, xpt_path_inq(), and XPT_SET_TRAN_SETTINGS.

Referenced by mmc_scan_lun().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ PERIPHDRIVER_DECLARE()

PERIPHDRIVER_DECLARE ( mmcprobe  ,
probe_driver   
)

Variable Documentation

◆ mmc_proto

struct xpt_proto mmc_proto
static
Initial value:
= {
.proto = PROTO_MMCSD,
.name = "mmcsd",
.ops = &mmc_proto_ops,
}
@ PROTO_MMCSD
Definition: cam_ccb.h:285
static struct xpt_proto_ops mmc_proto_ops
Definition: mmc_xpt.c:163

Definition at line 169 of file mmc_xpt.c.

◆ mmc_proto_ops

struct xpt_proto_ops mmc_proto_ops
static
Initial value:
= {
.announce = mmc_proto_announce,
.denounce = mmc_proto_denounce,
.debug_out = mmc_proto_debug_out,
}
static void mmc_proto_denounce(struct cam_ed *device)
Definition: mmc_xpt.c:488
static void mmc_proto_debug_out(union ccb *ccb)
Definition: mmc_xpt.c:495
static void mmc_proto_announce(struct cam_ed *device)
Definition: mmc_xpt.c:476

Definition at line 163 of file mmc_xpt.c.

◆ mmc_xport_ops

struct xpt_xport_ops mmc_xport_ops
static
Initial value:
= {
.alloc_device = mmc_alloc_device,
.action = mmc_action,
.async = mmc_dev_async,
.announce = mmc_announce_periph,
}
static void mmc_action(union ccb *start_ccb)
Definition: mmc_xpt.c:301
static struct cam_ed * mmc_alloc_device(struct cam_eb *bus, struct cam_et *target, lun_id_t lun_id)
Definition: mmc_xpt.c:190
static void mmc_dev_async(u_int32_t async_code, struct cam_eb *bus, struct cam_et *target, struct cam_ed *device, void *async_arg)
Definition: mmc_xpt.c:210
static void mmc_announce_periph(struct cam_periph *periph)
Definition: mmc_xpt.c:380

Definition at line 146 of file mmc_xpt.c.

◆ probe_action_text

char* probe_action_text[]
static
Initial value:
= {
"PROBE_RESET",
"PROBE_IDENTIFY",
"PROBE_POWER_OFF",
"PROBE_GET_HOST_OCR",
"PROBE_RESET_BUS",
"PROBE_SET_ID_FREQ",
"PROBE_SET_CS",
"PROBE_GO_IDLE_STATE",
"PROBE_SDIO_RESET",
"PROBE_SEND_IF_COND",
"PROBE_SDIO_INIT",
"PROBE_MMC_INIT",
"PROBE_SEND_APP_OP_COND",
"PROBE_GET_CID",
"PROBE_GET_CSD",
"PROBE_SEND_RELATIVE_ADDR",
"PROBE_MMC_SET_RELATIVE_ADDR",
"PROBE_SELECT_CARD",
"PROBE_DONE",
"PROBE_INVALID"
}

Definition at line 113 of file mmc_xpt.c.

◆ probe_driver

struct periph_driver probe_driver
static
Initial value:
=
{
probe_periph_init, "mmcprobe",
TAILQ_HEAD_INITIALIZER(probe_driver.units), 0,
}
#define CAM_PERIPH_DRV_EARLY
Definition: cam_periph.h:99
static periph_init_t probe_periph_init
Definition: mmc_xpt.c:504
static struct periph_driver probe_driver
Definition: mmc_xpt.c:506

Definition at line 506 of file mmc_xpt.c.

◆ probe_periph_init

static void probe_periph_init ( void  )
static

Definition at line 504 of file mmc_xpt.c.