Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c587b6fa authored by Feng Tang's avatar Feng Tang Committed by Grant Likely
Browse files

spi/dw_spi: add a FIFO depth detection



FIFO depth is configurable for each implementation of DW core,
so add a depth detection for those interface drivers who don't set
the fifo_len explicitly

Signed-off-by: default avatarFeng Tang <feng.tang@intel.com>
Acked-by: default avatarJean-Hugues Deschenes <jean-hugues.deschenes@octasic.com>
Signed-off-by: default avatarGrant Likely <grant.likely@secretlab.ca>
parent 99147b5c
Loading
Loading
Loading
Loading
+16 −0
Original line number Diff line number Diff line
@@ -831,6 +831,22 @@ static void spi_hw_init(struct dw_spi *dws)
	spi_mask_intr(dws, 0xff);
	spi_enable_chip(dws, 1);
	flush(dws);

	/*
	 * Try to detect the FIFO depth if not set by interface driver,
	 * the depth could be from 2 to 256 from HW spec
	 */
	if (!dws->fifo_len) {
		u32 fifo;
		for (fifo = 2; fifo <= 257; fifo++) {
			dw_writew(dws, txfltr, fifo);
			if (fifo != dw_readw(dws, txfltr))
				break;
		}

		dws->fifo_len = (fifo == 257) ? 0 : fifo;
		dw_writew(dws, txfltr, 0);
	}
}

int __devinit dw_spi_add_host(struct dw_spi *dws)