分类: LINUX
2010-11-15 10:15:12
|
|
|
//以上三段代码是对发送数据请求处理的,下面是发送命令请求
static void s3cmci_send_command(struct s3cmci_host *host, struct mmc_command *cmd)
{
u32 ccon, imsk;
//出现CRC状态错误|命令响应超时|接收命令响应|命令发出|响应CRC校验失败时,将产生SDI中断
imsk = S3C2410_SDIIMSK_CRCSTATUS | S3C2410_SDIIMSK_CMDTIMEOUT |
S3C2410_SDIIMSK_RESPONSEND | S3C2410_SDIIMSK_CMDSENT |
S3C2410_SDIIMSK_RESPONSECRC;
//将值写入SDI中断屏蔽寄存器中
enable_imask(host, imsk);
//判断请求所处在何种状态
if (cmd->data)
//如果有数据传输,则设当前任务为完成数据传输且接收命令响应状态
host->complete_what = COMPLETION_XFERFINISH_RSPFIN;
else if (cmd->flags & MMC_RSP_PRESENT)
host->complete_what = COMPLETION_RSPFIN;
else
//命令发送状态
host->complete_what = COMPLETION_CMDSENT;
//设置命令参数寄存器
writel(cmd->arg, host->base + S3C2410_SDICMDARG);
ccon = cmd->opcode & S3C2410_SDICMDCON_INDEX;
ccon |= S3C2410_SDICMDCON_SENDERHOST | S3C2410_SDICMDCON_CMDSTART;//命令操作开始
if (cmd->flags & MMC_RSP_PRESENT)
ccon |= S3C2410_SDICMDCON_WAITRSP;//主设备等待响应
if (cmd->flags & MMC_RSP_136)
ccon |= S3C2410_SDICMDCON_LONGRSP;//主设备接收一个136位长的响应
//设置命令控制寄存器,开始命令的传输
writel(ccon, host->base + S3C2410_SDICMDCON);
}
7. s3cmci_irq_cd SDI的卡检测中断服务功能//当MMC/SD卡插入卡槽时引发的中断
static irqreturn_t s3cmci_irq_cd(int irq, void *dev_id)
{
//这个dev_id参数是申请中断时传递过来的
struct s3cmci_host *host = (struct s3cmci_host *)dev_id;
//调用核心层中的方法将将struct delayed_work detect加入共享工作队列,
//其处理函数为核心层中的mmc_rescan方法,用于卡的识别并初始化。
mmc_detect_change(host->mmc, msecs_to_jiffies(500));
return IRQ_HANDLED;
}