drivers/mmc/host/ushc.c

Source file repositories/reference/linux-study-clean/drivers/mmc/host/ushc.c

File Facts

System
Linux kernel
Corpus path
drivers/mmc/host/ushc.c
Extension
.c
Size
13441 bytes
Lines
567
Domain
Driver Families
Bucket
drivers/mmc
Inferred role
Driver Families: implementation source
Status
source implementation candidate

Why This File Exists

Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.

Dependency Surface

Detected Declarations

Annotated Snippet

struct ushc_cbw {
	__u8 signature;
	__u8 cmd_idx;
	__le16 block_size;
	__le32 arg;
} __attribute__((packed));

#define USHC_CBW_SIGNATURE 'C'

struct ushc_csw {
	__u8 signature;
	__u8 status;
	__le32 response;
} __attribute__((packed));

#define USHC_CSW_SIGNATURE 'S'

struct ushc_int_data {
	u8 status;
	u8 reserved[3];
};

#define USHC_INT_STATUS_SDIO_INT     (1 << 1)
#define USHC_INT_STATUS_CARD_PRESENT (1 << 0)


struct ushc_data {
	struct usb_device *usb_dev;
	struct mmc_host *mmc;

	struct urb *int_urb;
	struct ushc_int_data *int_data;

	struct urb *cbw_urb;
	struct ushc_cbw *cbw;

	struct urb *data_urb;

	struct urb *csw_urb;
	struct ushc_csw *csw;

	spinlock_t lock;
	struct mmc_request *current_req;
	u32 caps;
	u16 host_ctrl;
	unsigned long flags;
	u8 last_status;
	int clock_freq;
};

#define DISCONNECTED    0
#define INT_EN          1
#define IGNORE_NEXT_INT 2

static void data_callback(struct urb *urb);

static int ushc_hw_reset(struct ushc_data *ushc)
{
	return usb_control_msg(ushc->usb_dev, usb_sndctrlpipe(ushc->usb_dev, 0),
			       USHC_RESET, USHC_RESET_TYPE,
			       0, 0, NULL, 0, 100);
}

static int ushc_hw_get_caps(struct ushc_data *ushc)
{
	int ret;
	int version;

	ret = usb_control_msg(ushc->usb_dev, usb_rcvctrlpipe(ushc->usb_dev, 0),
			      USHC_GET_CAPS, USHC_GET_CAPS_TYPE,
			      0, 0, &ushc->caps, sizeof(ushc->caps), 100);
	if (ret < 0)
		return ret;

	ushc->caps = le32_to_cpu(ushc->caps);

	version = ushc->caps & USHC_GET_CAPS_VERSION_MASK;
	if (version != 0x02) {
		dev_err(&ushc->usb_dev->dev, "controller version %d is not supported\n", version);
		return -EINVAL;
	}

	return 0;
}

static int ushc_hw_set_host_ctrl(struct ushc_data *ushc, u16 mask, u16 val)
{
	u16 host_ctrl;
	int ret;

Annotation

Implementation Notes