/** * __dma_memcpy - program the MDMA registers * * Actually program MDMA0 and wait for the transfer to finish. Disable IRQs * while programming registers so that everything is fully configured. Wait * for DMA to finish with IRQs enabled. If interrupted, the initial DMA_DONE * check will make sure we don't clobber any existing transfer. */ static void __dma_memcpy(u32 daddr, s16 dmod, u32 saddr, s16 smod, size_t cnt, u32 conf) { static DEFINE_SPINLOCK(mdma_lock); unsigned long flags; spin_lock_irqsave(&mdma_lock, flags); /* Force a sync in case a previous config reset on this channel * occurred. This is needed so subsequent writes to DMA registers * are not spuriously lost/corrupted. Do it under irq lock and * without the anomaly version (because we are atomic already). */ __builtin_bfin_ssync(); if (bfin_read_MDMA_S0_CONFIG()) while (!(bfin_read_MDMA_D0_IRQ_STATUS() & DMA_DONE)) continue; if (conf & DMA2D) { /* For larger bit sizes, we've already divided down cnt so it * is no longer a multiple of 64k. So we have to break down * the limit here so it is a multiple of the incoming size. * There is no limitation here in terms of total size other * than the hardware though as the bits lost in the shift are * made up by MODIFY (== we can hit the whole address space). * X: (2^(16 - 0)) * 1 == (2^(16 - 1)) * 2 == (2^(16 - 2)) * 4 */ u32 shift = abs(dmod) >> 1; size_t ycnt = cnt >> (16 - shift); cnt = 1 << (16 - shift); bfin_write_MDMA_D0_Y_COUNT(ycnt); bfin_write_MDMA_S0_Y_COUNT(ycnt); bfin_write_MDMA_D0_Y_MODIFY(dmod); bfin_write_MDMA_S0_Y_MODIFY(smod); }
static void dma_bitblit(void *dst, fastimage_t *logo, int x, int y) { if (dcache_status()) blackfin_dcache_flush_range(logo->data, logo->data + logo->size); bfin_write_MDMA_D0_IRQ_STATUS(DMA_DONE | DMA_ERR); /* Setup destination start address */ bfin_write_MDMA_D0_START_ADDR(dst + ((x & -2) * LCD_PIXEL_SIZE) + (y * LCD_X_RES * LCD_PIXEL_SIZE)); /* Setup destination xcount */ bfin_write_MDMA_D0_X_COUNT(logo->width * LCD_PIXEL_SIZE / DMA_SIZE16); /* Setup destination xmodify */ bfin_write_MDMA_D0_X_MODIFY(DMA_SIZE16); /* Setup destination ycount */ bfin_write_MDMA_D0_Y_COUNT(logo->height); /* Setup destination ymodify */ bfin_write_MDMA_D0_Y_MODIFY((LCD_X_RES - logo->width) * LCD_PIXEL_SIZE + DMA_SIZE16); /* Setup Source start address */ bfin_write_MDMA_S0_START_ADDR(logo->data); /* Setup Source xcount */ bfin_write_MDMA_S0_X_COUNT(logo->width * LCD_PIXEL_SIZE / DMA_SIZE16); /* Setup Source xmodify */ bfin_write_MDMA_S0_X_MODIFY(DMA_SIZE16); /* Setup Source ycount */ bfin_write_MDMA_S0_Y_COUNT(logo->height); /* Setup Source ymodify */ bfin_write_MDMA_S0_Y_MODIFY(DMA_SIZE16); /* Enable source DMA */ bfin_write_MDMA_S0_CONFIG(DMAEN | WDSIZE_16 | DMA2D); SSYNC(); bfin_write_MDMA_D0_CONFIG(WNR | DMAEN | WDSIZE_16 | DMA2D); while (bfin_read_MDMA_D0_IRQ_STATUS() & DMA_RUN) ; bfin_write_MDMA_S0_IRQ_STATUS(bfin_read_MDMA_S0_IRQ_STATUS() | DMA_DONE | DMA_ERR); bfin_write_MDMA_D0_IRQ_STATUS(bfin_read_MDMA_D0_IRQ_STATUS() | DMA_DONE | DMA_ERR); }
static void __dma_memcpy(u32 daddr, s16 dmod, u32 saddr, s16 smod, size_t cnt, u32 conf) { static DEFINE_SPINLOCK(mdma_lock); unsigned long flags; spin_lock_irqsave(&mdma_lock, flags); __builtin_bfin_ssync(); if (bfin_read_MDMA_S0_CONFIG()) while (!(bfin_read_MDMA_D0_IRQ_STATUS() & DMA_DONE)) continue; if (conf & DMA2D) { u32 shift = abs(dmod) >> 1; size_t ycnt = cnt >> (16 - shift); cnt = 1 << (16 - shift); bfin_write_MDMA_D0_Y_COUNT(ycnt); bfin_write_MDMA_S0_Y_COUNT(ycnt); bfin_write_MDMA_D0_Y_MODIFY(dmod); bfin_write_MDMA_S0_Y_MODIFY(smod); }