static inline void sepmmc_dma(int real_num,struct sepmmc_host *host)
{
struct sepmmc_dma_descriptor *descriptor[real_num];
dma_addr_t bus_addr;
dma_addr_t DESCRIPTOR_BASE[real_num];
int seg_len;
int temp=0;
mmc_debug("[%s] into \n",__func__);
addr_minus =(unsigned int *)kmalloc(sizeof(unsigned int)*real_num,GFP_KERNEL);
if(real_num > 1){
for(host->cur_seg = 0;host->cur_seg<real_num;host->cur_seg++)
{
mmc_debug("[%s] real_num > 1 \n",__func__);
descriptor[host->cur_seg]=dma_alloc_coherent(NULL, sizeof(struct sepmmc_dma_descriptor),&DESCRIPTOR_BASE[host->cur_seg], GFP_KERNEL);
printk("descriptor = 0x%08x,DESCRIPTOR_BASE = 0x%08x\n",(unsigned int)descriptor[host->cur_seg],DESCRIPTOR_BASE[host->cur_seg]);
addr_minus[host->cur_seg] = (unsigned int)descriptor[host->cur_seg] - (unsigned int)DESCRIPTOR_BASE[host->cur_seg];
printk("addr_minux = 0x%08x \n", addr_minus[host->cur_seg]);
if(!descriptor[host->cur_seg])
printk("descriptor malloc err\n");
if(host->cur_seg == 0)
descriptor[host->cur_seg]->des0 = 0x80000018;
else if(host->cur_seg == (real_num-1))
descriptor[host->cur_seg]->des0 = 0x80000034;
else
descriptor[host->cur_seg]->des0 = 0x80000010;
}
for(host->cur_seg = 0;host->cur_seg<host->seg_num;host->cur_seg++)
{
seg_len = sg_dma_len(&host->data->sg[host->cur_seg]);
bus_addr = sg_dma_address(&host->data->sg[host->cur_seg]);
if((seg_len - 8192)>0)
{
descriptor[temp]->des1 = 0x2000;
descriptor[temp+1]->des1 = seg_len-0x2000;
descriptor[temp]->des2 = bus_addr;
descriptor[temp+1]->des2 = bus_addr+0x2000;
temp = temp + 2;
}
else
{
descriptor[temp]->des1 = seg_len;
descriptor[temp]->des2 = bus_addr;
temp++;
}
}
for(host->cur_seg = 0;host->cur_seg<real_num;host->cur_seg++)
{
mmc_debug("[%s],cur_seg=%d,bus_addr=0x%08x,seg_len=0x%x\n",__func__,host->cur_seg,descriptor[host->cur_seg]->des2,descriptor[host->cur_seg]->des1);
mmc_debug("[%s],descriptor->des0=0x%08x\n",__func__,descriptor[host->cur_seg]->des0);
}
for(host->cur_seg = 0;host->cur_seg<real_num;host->cur_seg++)
{
if(host->cur_seg < (real_num-1))
descriptor[host->cur_seg]->des3 = DESCRIPTOR_BASE[host->cur_seg+1];
else
descriptor[host->cur_seg]->des3 = 0;
printk("---descriptor->des3=0x%08x\n",descriptor[host->cur_seg]->des3);
}
}else{
mmc_debug("[%s] real_num = 1 \n",__func__);
descriptor[0] =dma_alloc_coherent(NULL, sizeof(struct sepmmc_dma_descriptor),&DESCRIPTOR_BASE[0], GFP_KERNEL);
descriptor[0]->des0 = 0x8000003c;
seg_len = sg_dma_len(&host->data->sg[0]);
descriptor[0]->des1 = seg_len;
bus_addr = sg_dma_address(&host->data->sg[0]);
descriptor[0]->des2 = bus_addr;
mmc_debug("[%s],bus_addr=0x%08x,seg_len=0x%x\n",__func__,bus_addr,seg_len);
descriptor[0]->des3 = 0;
printk("descriptor[0] = 0x%08x,DESCRIPTOR_BASE[0]=0x%08x \n",(unsigned int)descriptor[0],DESCRIPTOR_BASE[0]);
addr_minus[0] =(unsigned int)descriptor[0] - (unsigned int)DESCRIPTOR_BASE[0];
printk("addr_minux = 0x%08x \n",addr_minus[0]);
}
writel(DESCRIPTOR_BASE[0],SDIO1_DBADDR_V);
writel(0x82,SDIO1_BMOD_V);
mmc_debug("[%s] out \n",__func__);
}