Logo Search packages:      
Sourcecode: linux-fsl-imx51 version File versions  Download package

int mxc_spi_poll_transfer ( struct spi_device *  spi,
struct spi_transfer *  t 
)

This function is called when the data has to transfer from/to the current SPI device in poll mode

Parameters:
spi the current spi device
t the transfer request - read/write buffer pairs
Returns:
Returns 0 on success.

Definition at line 794 of file mxc_spi.c.

References mxc_spi::base, mxc_spi::chipselect_active, mxc_spi::chipselect_inactive, mxc_spi::clk, mxc_spi_xfer::count, mxc_spi::ctrl_addr, mxc_spi_unique_def::fifo_size, mxc_spi_unique_def::mode_mask, mxc_spi_chipselect(), mxc_spi_xfer::rx_buf, mxc_spi_unique_def::rx_cnt_mask, mxc_spi_xfer::rx_get, spi_put_tx_data(), mxc_spi::spi_ver_def, mxc_spi_unique_def::ss_pol_shift, mxc_spi::test_addr, mxc_spi::transfer, and mxc_spi_xfer::tx_buf.

Referenced by mx25_3ds_cpld_rw(), and mx37_3ds_cpld_rw().

{
      struct mxc_spi *master_drv_data = NULL;
      int count, i;
      volatile unsigned int status;
      u32 rx_tmp;
      u32 fifo_size;
      int chipselect_status;

      mxc_spi_chipselect(spi, BITBANG_CS_ACTIVE);

      /* Get the master controller driver data from spi device's master */
      master_drv_data = spi_master_get_devdata(spi->master);

      chipselect_status = __raw_readl(MXC_CSPICONFIG +
                              master_drv_data->ctrl_addr);
      chipselect_status >>= master_drv_data->spi_ver_def->ss_pol_shift &
          master_drv_data->spi_ver_def->mode_mask;
      if (master_drv_data->chipselect_active)
            master_drv_data->chipselect_active(spi->master->bus_num,
                                       chipselect_status,
                                       (spi->chip_select &
                                        MXC_CSPICTRL_CSMASK) + 1);

      clk_enable(master_drv_data->clk);

      /* Modify the Tx, Rx, Count */
      master_drv_data->transfer.tx_buf = t->tx_buf;
      master_drv_data->transfer.rx_buf = t->rx_buf;
      master_drv_data->transfer.count = t->len;
      fifo_size = master_drv_data->spi_ver_def->fifo_size;

      count = (t->len > fifo_size) ? fifo_size : t->len;
      spi_put_tx_data(master_drv_data->base, count, master_drv_data);

      while ((((status = __raw_readl(master_drv_data->test_addr)) &
             master_drv_data->spi_ver_def->rx_cnt_mask) >> master_drv_data->
            spi_ver_def->rx_cnt_off) != count) ;

      for (i = 0; i < count; i++) {
            rx_tmp = __raw_readl(master_drv_data->base + MXC_CSPIRXDATA);
            master_drv_data->transfer.rx_get(master_drv_data, rx_tmp);
      }

      clk_disable(master_drv_data->clk);
      if (master_drv_data->chipselect_inactive)
            master_drv_data->chipselect_inactive(spi->master->bus_num,
                                         chipselect_status,
                                         (spi->chip_select &
                                          MXC_CSPICTRL_CSMASK) + 1);
      return 0;
}


Generated by  Doxygen 1.6.0   Back to index