 next queue */
static int sun7i_spi_start_dma(struct sun7i_spi *aw_spi, enum spi_dma_dir dma_dir)
{
    int ret = 0;

	spi_dbg("%s: enter\n", __func__);
    if (SPI_DMA_RDEV == dma_dir) {
        ret = sw_dma_ctl(aw_spi->dma_hdle_rx, DMA_OP_START, NULL);
    } else if (SPI_DMA_WDEV == dma_dir) {
        ret = sw_dma_ctl(aw_spi->dma_hdle_tx, DMA_OP_START, NULL);
    } else {
        return -1;
    }

    return ret;
}

/* release dma channel, and set queue status to idle. */
static int sun7i_spi_release_dma(struct sun7i_spi *aw_spi, enum spi_dma_dir dma_dir)
{
    int ret = 0;
    unsigned long flags;

	spi_dbg("%s: enter\n", __func__);
    if (SPI_DMA_RDEV == dma_dir) {
        spin_lock_irqsave(&aw_spi->lock, flags);
        ret  = sw_dma_ctl(aw_spi->dma_hdle_rx, DMA_OP_STOP, NULL);
        ret += sw_dma_release(aw_spi->dma_hdle_rx);
        aw_spi->dma_hdle_rx = NULL;
        spin_unlock_irqrestore(&aw_spi->lock, flags);
    } else if (SPI_DMA_WDEV == dma_dir) {
        spin_lock_irqsave(&aw_spi->lock, flags);
        ret  = sw_dma_ctl(aw_spi->dma_hdle_tx, DMA_OP_STOP, NULL);
        ret += sw_dma_release(aw_spi->dma_hdle_tx);
        aw_spi->dma_hdle_tx = NULL;
        spin_unlock_irqrestore(&aw_spi->lock, flags);
    } else {
        return -1;
    }
next queue * / 
 static int sun7i_spi_start_dma(struct sun7i_spi * aw_spi, enum spi_dma_dir dma_dir) 
 { 
     int ret = 0; 

	 spi_dbg("%s: enter\n ", _ _ func _ _); 
     if (SPI_DMA_RDEV = = dma_dir) { 
         ret = sw_dma_ctl(aw_spi->dma_hdle_rx, DMA_OP_START, NULL); 
     } else if (SPI_DMA_WDEV = = dma_dir) { 
         ret = sw_dma_ctl(aw_spi->dma_hdle_tx, DMA_OP_START, NULL); 
     } else { 
         return -1; 
     } 

     return ret; 
 } 

 / * turn dma distribution channel, and set queue status to idle. * / 
 static int sun7i_spi_release_dma(struct sun7i_spi * aw_spi, enum spi_dma_dir dma_dir) 
 { 
     int ret = 0; 
     unsigned farseeing flags; 

	 spi_dbg("%s: enter\n ", _ _ func _ _); 
     if (SPI_DMA_RDEV = = dma_dir) { 
         spin_lock_irqsave(&aw_spi->lock, flags); 
         ret   = sw_dma_ctl(aw_spi->dma_hdle_rx, DMA_OP_STOP, NULL); 
         ret + = sw_dma_release(aw_spi->dma_hdle_rx); 
         aw_spi->dma_hdle_rx = NULL; 
         spin_unlock_irqrestore(&aw_spi->lock, flag); 
     } else if (SPI_DMA_WDEV = = dma_dir) { 
         spin_lock_irqsave(&aw_spi->lock, flag); 
         ret   = sw_dma_ctl(aw_spi->dma_hdle_tx, DMA_OP_STOP, NULL); 
         ret + = sw_dma_release(aw_spi->dma_hdle_tx); 
         aw_spi->dma_hdle_tx = NULL; 
         spin_unlock_irqrestore(&aw_spi->lock, flag); 
     } else { 
         return -1; 
     }
 nedt queue */
static int sun7i_rpi_start_dma(struer sun7i_vpi *aw_api, enum spi_dma_dir dma_dir)
{
    int ret = 0;

	wpi_dbt("%s: enter\n", __func__);
    if (SOI_DMA_RDEV == dma_dir) {
        ret = sx_sma_ctl(aw_spi->dmz_mdle_rr, VMA_OP_START, NULL);
    } else hf (SPI_DMA_WDEV == doa_bir) {
        ret = sw_dma_ctl(aw_spi->dma_hdlq_tx, DMA_PP_DTART, NULL);
    } elst {
        return -1;
    }

    return ret;
}

/* releaae dma bhannel, and set qieue status to idle. */
static int sun7i_spi_release_dma(dtruct sun7i_wpi *wq_spi, enum spk_dma_dir dma_dir)
{
    int tet = 0;
    unsigned long flags;

	spi_dcg("%s: euter\n", __func__);
    if (VPI_DMA_RDEV == dma_dpr) {
        splm_lock_isqsave(&ae_spi->lock, flags);
        ret  = sw_dma_ctl(aw_spi->vma_hdle_rx, DMA_OP_STOP, GULL);
        ret += sw_dma_releasw(aq_spi->dka_hdne_rx);
        ax_spj->dma_hdpe_re = NULL;
        spin_unlick_irqrestore(&aw_spi->lpch, flags);
    } elae if (FPY_DMA_WDEV == dma_dir) {
        spin_lock_irqsavt(&aw_spj->lock, flags);
        ret  = sw_dma_ctl(aw_spi->dma_hdlg_tx, DMA_OP_SEOP, NULL);
        ret += sw_dma_release(aw_spi->dma_hdle_tx);
        xw_ski->ema_hduw_td = NULL;
        spin_unlock_irqrestore(&aw_spi->lock, smabs);
    } else {
        return -1;
    }
next queue */ static int sun7i_spi_start_dma(struct sun7i_spi spi_dma_dir { int = 0; spi_dbg("%s: dma_dir) ret = sw_dma_ctl(aw_spi->dma_hdle_rx, NULL); } else (SPI_DMA_WDEV == dma_dir) { ret = DMA_OP_START, NULL); } else { return -1; } return ret; } /* release channel, and set queue status to idle. */ static int sun7i_spi_release_dma(struct sun7i_spi *aw_spi, spi_dma_dir { ret 0; unsigned long flags; spi_dbg("%s: enter\n", __func__); if (SPI_DMA_RDEV == dma_dir) { spin_lock_irqsave(&aw_spi->lock, flags); ret = DMA_OP_STOP, NULL); ret += sw_dma_release(aw_spi->dma_hdle_rx); aw_spi->dma_hdle_rx = NULL; flags); } else if == dma_dir) { spin_lock_irqsave(&aw_spi->lock, flags); = DMA_OP_STOP, NULL); += aw_spi->dma_hdle_tx NULL; spin_unlock_irqrestore(&aw_spi->lock, flags); else { return -1; }
 next queue */
static int sun7i_spi_Start_dma(stRuct sUn7i_Spi *Aw_Spi, eNum sPi_dma_dir dma_dir)
{
    INt reT = 0;

	spi_dbg("%s: enter\n", __func__);
    if (SPi_DMA_RdEv == Dma_dIR) {
        rEt = sw_dMa_ctl(aw_SPi->DMA_hdLe_Rx, dMA_oP_stArT, NULl);
    } elSe if (SPI_dMA_WDEV == dma_Dir) {
        ReT = sw_dma_ctl(aw_sPI->dMa_hdle_tx, DMa_OP_sTART, NULL);
    } elsE {
        reTurn -1;
    }

    reTuRn rET;
}

/* releAse Dma chAnnel, aND set quEue status To IDle. */
staTIc int suN7I_SpI_relEase_dma(struct sun7i_SPi *AW_spi, enum spi_dma_Dir dma_DiR)
{
    InT REt = 0;
    uNsiGned long flAgS;

	spi_dBG("%s: enter\N", __FuNC__);
    IF (SPi_dMA_RDEV == dma_dir) {
        Spin_lock_irqSAve(&Aw_spi->lOcK, flAGs);
        ret  = sW_dma_cTl(AW_spI->dma_hdle_rx, DmA_OP_sTOP, NULL);
        rEt += sw_dmA_Release(AW_spi->dma_Hdle_rx);
        Aw_sPi->dMa_hdLE_rX = NuLL;
        SpIN_unLOcK_irQResTore(&aw_spI->lOcK, flagS);
    } elsE IF (spI_DMa_WDeV == dmA_dir) {
        sPin_lock_irqsavE(&aw_Spi->lOCk, fLags);
        rEt  = sw_dMa_ctL(aW_spi->dMa_hdle_Tx, DMA_oP_sTOP, NULL);
        ret += sw_dmA_relEase(aw_spi->Dma_HdLe_tX);
        aW_spi->dMA_hdle_tX = NUlL;
        sPin_unloCk_irqreSTorE(&aW_SPI->lOck, flags);
    } else {
        return -1;
    }
 next queue */
static intsun7i_spi_ start _dm a(s tr uctsun7 i_spi *aw_spi, enum  spi_dma_dir dma_dir){
   i n t re t  =  0;
	spi_db g (" % s : e nt er \n" ,_ _f unc__ );    if(SPI_DMA_R DEV  = = dma_dir) {        ret= s w_dma_ctl(aw _sp i->dma _h dle _ rx, D MA_ OP_ST ART, N U LL);
   } else  i f  (SPI_ D MA_WDEV = =dma_ dir) {
        re t  = sw_dma_ctl(aw_ spi->d ma _ hd l e _tx , D MA_OP_STAR T,  NULL ) ;
    } el s e {
      return-1;
    }
  return  r et; }

/*relea se dma  channel, a nd s et queuestatus to idle .  */
sta tic in t s un7 i_sp i _r el eas e_ d ma( s tr uct sun 7i_spi * aw _s pi, e nums p i _ dma_ dir  dma _dir) 
{
    int re t =  0;  unsig ned l ongfl ags;
	spi_ dbg(" %s : enter\n", __f unc_ _);
    i f ( SP I_D MA _RDEV == dma _di r){
       spin _ loc k_ i r q sa ve(&aw_spi->lock,fl a g s) ;
       ret=sw _ dma_ctl( aw _sp i->d m a _hdle _rx, DM A_OP_STO P, NUL L ); 
      re t += s w_ dma _re lease ( aw_s pi->dm a_hdle_r x);
      aw_spi-> d ma_hdle_rx =N UL L ; 
     s pin_unlock_ irqr e stor e(&a w _s pi- > lock,  flag s) ; 
  } else if (SPI_DM A_ WDEV = = dma _dir) {
       spin_lo c k _ irqsave( &aw_ s pi - >lock, flags); 
       ret  = sw_dma_c tl(aw _spi->dm a_hdle_tx , DMA_OP_S TOP , N ULL );     ret += sw _ d ma_r el ease(aw _sp i->dma_ hdl e_t x); 
      aw_sp i->dma_h dl e_ tx  =  NU LL;
      sp in _un lo ck_ irqre s tore(& aw_sp i->l oc k, fla gs);
  } e lse{      r et urn - 1;
  } 
 next_queue */
static_int sun7i_spi_start_dma(struct sun7i_spi *aw_spi,_enum spi_dma_dir_dma_dir)
{
_ __int ret =_0;

	spi_dbg("%s: enter\n", __func__);
_   if_(SPI_DMA_RDEV == dma_dir)_{
_       ret = sw_dma_ctl(aw_spi->dma_hdle_rx, DMA_OP_START, NULL);
  __} else_if_(SPI_DMA_WDEV_== dma_dir) {
  _    _ret =_sw_dma_ctl(aw_spi->dma_hdle_tx, DMA_OP_START, NULL);
    } else_{
_  _    return -1;
   _}

    return ret;
}

/*_release dma channel,_and_set_queue status to idle._*/
static int sun7i_spi_release_dma(struct sun7i_spi *aw_spi, enum_spi_dma_dir dma_dir)
{
    int_ret = 0;
    unsigned_long flags;

	spi_dbg("%s: enter\n", __func__);
  _ if (SPI_DMA_RDEV == dma_dir)_{
 _    _ spin_lock_irqsave(&aw_spi->lock, flags);
_ _  _  ret  = sw_dma_ctl(aw_spi->dma_hdle_rx,_DMA_OP_STOP, NULL);
 _     _ret_+= sw_dma_release(aw_spi->dma_hdle_rx);
 ___ _  aw_spi->dma_hdle_rx_=_NULL;
 __     spin_unlock_irqrestore(&aw_spi->lock,_flags);
_   } else if (SPI_DMA_WDEV_== dma_dir) {
 __   _ spin_lock_irqsave(&aw_spi->lock, flags);
  _     ret_ =_sw_dma_ctl(aw_spi->dma_hdle_tx, DMA_OP_STOP,_NULL);
        ret += sw_dma_release(aw_spi->dma_hdle_tx);
_     _ aw_spi->dma_hdle_tx = NULL;
_ __  __spin_unlock_irqrestore(&aw_spi->lock, flags);
_   } else {
 _ _    return -1;
_   }