src/devices/shareddma/drivers/syn-dma/syn-dhub.cc
// channel_id is validated before calling this function.
channel_id is validated before calling this function.
channel_id is validated before calling this function .
void SynDhub::Init(uint32_t channel_id) {
  const uint32_t fifo_cmd_id = 2 * channel_id;
  const uint32_t fifo_data_id = 2 * channel_id + 1;
  FiFo_START::Get(fifo_cmd_id).FromValue(0).set_EN(0).WriteTo(&mmio_);
  FiFo_CLEAR::Get(fifo_cmd_id).FromValue(0).set_EN(1).WriteTo(&mmio_);
  FiFo_START::Get(fifo_data_id).FromValue(0).set_EN(0).WriteTo(&mmio_);
  FiFo_CLEAR::Get(fifo_data_id).FromValue(0).set_EN(1).WriteTo(&mmio_);
  channelCtl_START::Get(channel_id).FromValue(0).WriteTo(&mmio_);
  channelCtl_CFG::Get(channel_id)
      .FromValue(0)
      .set_selfLoop(0)
      .set_QoS(0)
      .set_MTU(4)  
      .WriteTo(&mmio_);
  ZX_ASSERT(kMtuSize == 128);
  const uint32_t bank = channel_info_[channel_id].bank;
  const uint32_t base_cmd = bank * 512;
  const uint32_t base_data = bank * 512 + 32;
  constexpr uint32_t depth_cmd = 4;  
  FiFo_CFG::Get(fifo_cmd_id).FromValue(0).set_BASE(base_cmd).WriteTo(&mmio_);
  cell_CFG::Get(false, fifo_cmd_id).FromValue(0).set_DEPTH(depth_cmd).WriteTo(&mmio_);
  FiFo_START::Get(fifo_cmd_id).FromValue(0).set_EN(1).WriteTo(&mmio_);
  FiFo_CFG::Get(fifo_data_id).FromValue(0).set_BASE(base_data).WriteTo(&mmio_);
  cell_CFG::Get(false, fifo_data_id)
      .FromValue(0)
      .set_DEPTH(channel_info_[channel_id].fifo_data_depth)
      .WriteTo(&mmio_);
  FiFo_START::Get(fifo_data_id).FromValue(0).set_EN(1).WriteTo(&mmio_);
  channelCtl_START::Get(channel_id).FromValue(0).set_EN(1).WriteTo(&mmio_);
  cell_CFG::Get(true, channel_id).FromValue(0).set_DEPTH(1).WriteTo(&mmio_);
  auto active = full::Get(true).ReadFrom(&mmio_);
  if (active.reg_value()) {
    zxlogf(DEBUG, "dhub: clearing active interrupts 0x%X", active.reg_value());
    full::Get(true).FromValue(active.reg_value()).WriteTo(&mmio_);
  }
  cell_INTR0_mask::Get(true, channel_id).FromValue(0).set_full(1).WriteTo(&mmio_);
}
void SynDhub :: Init ( uint32_t channel_id ) { const uint32_t fifo_cmd_id = 2 * channel_id ; const uint32_t fifo_data_id = 2 * channel_id + 1 ; FiFo_START :: Get ( fifo_cmd_id ) . FromValue ( 0 ) . set_EN ( 0 ) . WriteTo ( & mmio_ ) ; FiFo_CLEAR :: Get ( fifo_cmd_id ) . FromValue ( 0 ) . set_EN ( 1 ) . WriteTo ( & mmio_ ) ; FiFo_START :: Get ( fifo_data_id ) . FromValue ( 0 ) . set_EN ( 0 ) . WriteTo ( & mmio_ ) ; FiFo_CLEAR :: Get ( fifo_data_id ) . FromValue ( 0 ) . set_EN ( 1 ) . WriteTo ( & mmio_ ) ; channelCtl_START :: Get ( channel_id ) . FromValue ( 0 ) . WriteTo ( & mmio_ ) ; channelCtl_CFG :: Get ( channel_id ) . FromValue ( 0 ) . set_selfLoop ( 0 ) . set_QoS ( 0 ) . set_MTU ( 4 ) . WriteTo ( & mmio_ ) ; ZX_ASSERT ( kMtuSize == 128 ) ; const uint32_t bank = channel_info_ [ channel_id ] . bank ; const uint32_t base_cmd = bank * 512 ; const uint32_t base_data = bank * 512 + 32 ; constexpr uint32_t depth_cmd = 4 ; FiFo_CFG :: Get ( fifo_cmd_id ) . FromValue ( 0 ) . set_BASE ( base_cmd ) . WriteTo ( & mmio_ ) ; cell_CFG :: Get ( false , fifo_cmd_id ) . FromValue ( 0 ) . set_DEPTH ( depth_cmd ) . WriteTo ( & mmio_ ) ; FiFo_START :: Get ( fifo_cmd_id ) . FromValue ( 0 ) . set_EN ( 1 ) . WriteTo ( & mmio_ ) ; FiFo_CFG :: Get ( fifo_data_id ) . FromValue ( 0 ) . set_BASE ( base_data ) . WriteTo ( & mmio_ ) ; cell_CFG :: Get ( false , fifo_data_id ) . FromValue ( 0 ) . set_DEPTH ( channel_info_ [ channel_id ] . fifo_data_depth ) . WriteTo ( & mmio_ ) ; FiFo_START :: Get ( fifo_data_id ) . FromValue ( 0 ) . set_EN ( 1 ) . WriteTo ( & mmio_ ) ; channelCtl_START :: Get ( channel_id ) . FromValue ( 0 ) . set_EN ( 1 ) . WriteTo ( & mmio_ ) ; cell_CFG :: Get ( true , channel_id ) . FromValue ( 0 ) . set_DEPTH ( 1 ) . WriteTo ( & mmio_ ) ; auto active = full :: Get ( true ) . ReadFrom ( & mmio_ ) ; if ( active . reg_value ( ) ) { zxlogf ( DEBUG , " " , active . reg_value ( ) ) ; full :: Get ( true ) . FromValue ( active . reg_value ( ) ) . WriteTo ( & mmio_ ) ; } cell_INTR0_mask :: Get ( true , channel_id ) . FromValue ( 0 ) . set_full ( 1 ) . WriteTo ( & mmio_ ) ; }
channel_id is validated before calling this function.
channel_id is validated before calling this function .
// Stop and clear FIFO for cmd and data. // Stop and configure channel. // 128 bytes (2 ^ 4 x 8). // 4 x 8 = 32 bytes. // FIFO semaphores use cells with hub == false. // FIFO cmd configure and start. // FIFO data configure and start. // Channel configure and start. // Clear semaphore.