static void flush(struct dw_spi *dws)
{
	while (dw_readw(dws, sr) & SR_RF_NOT_EMPT)
		dw_readw(dws, dr);

	wait_till_not_busy(dws);
}
static void dw_writer(struct dw_spi *dws)
{
	u32 max = tx_max(dws);
	u16 txw = 0;	
	
	DBG_SPI("%dbyte tx:",dws->n_bytes);
	while (max--) {
		/* Set the tx word if the transfer's original "tx" is not null */
		if (dws->tx_end - dws->len) {
			if (dws->n_bytes == 1)
			{
				txw = *(u8 *)(dws->tx);	
				DBG_SPI("0x%02x,", *(u8 *)(dws->tx));
			}
			else
			{
				txw = *(u16 *)(dws->tx);
				DBG_SPI("0x%02x,", *(u16 *)(dws->tx));
			}
		}
		dw_writew(dws, SPIM_TXDR, txw);
		dws->tx += dws->n_bytes;
	}
	
	//it is neccessary
	wait_till_not_busy(dws);
	
	DBG_SPI("\n");
}
static void flush(struct dw_spi *dws)
{
	while (!(dw_readw(dws, SPIM_SR) & SR_RF_EMPT))
		dw_readw(dws, SPIM_RXDR);

	wait_till_not_busy(dws);
}
static int reader_all(struct dw_spi *dws)
{
	while (!(dw_readw(dws, SPIM_SR) & SR_RF_EMPT)
		&& (dws->rx < dws->rx_end)) {
			dw_reader(dws);		
			wait_till_not_busy(dws);
		}

	return dws->rx == dws->rx_end;
}
Esempio n. 5
0
static int u8_reader(struct dw_spi *dws)
{
	while ((dw_readw(dws, sr) & SR_RF_NOT_EMPT)
		&& (dws->rx < dws->rx_end)) {
		*(u8 *)(dws->rx) = dw_readw(dws, dr);
		++dws->rx;
	}

	wait_till_not_busy(dws);
	return dws->rx == dws->rx_end;
}
Esempio n. 6
0
static int u16_writer(struct dw_spi *dws)
{
	if (!(dw_readw(dws, sr) & SR_TF_NOT_FULL)
		|| (dws->tx == dws->tx_end))
		return 0;

	dw_writew(dws, dr, *(u16 *)(dws->tx));
	dws->tx += 2;

	wait_till_not_busy(dws);
	return 1;
}
Esempio n. 7
0
static int null_reader(struct dw_spi *dws)
{
	u8 n_bytes = dws->n_bytes;

	while ((dw_readw(dws, sr) & SR_RF_NOT_EMPT)
		&& (dws->rx < dws->rx_end)) {
		dw_readw(dws, dr);
		dws->rx += n_bytes;
	}
	wait_till_not_busy(dws);
	return dws->rx == dws->rx_end;
}
Esempio n. 8
0
static int null_writer(struct dw_spi *dws)
{
	u8 n_bytes = dws->n_bytes;

	if (!(dw_readw(dws, sr) & SR_TF_NOT_FULL)
		|| (dws->tx == dws->tx_end))
		return 0;
	dw_writew(dws, dr, 0);
	dws->tx += n_bytes;

	wait_till_not_busy(dws);
	return 1;
}
Esempio n. 9
0
static int u16_reader(struct dw_spi *dws)
{
	u16 temp;

	while ((dw_readw(dws, sr) & SR_RF_NOT_EMPT)
		&& (dws->rx < dws->rx_end)) {
		temp = dw_readw(dws, dr);
		*(u16 *)(dws->rx) = temp;
		dws->rx += 2;
	}

	wait_till_not_busy(dws);
	return dws->rx == dws->rx_end;
}