@@ -366,6 +366,40 @@ static irqreturn_t fsl_ssi_isr(int irq, void *dev_id)
return IRQ_HANDLED;
}
+// empty fifo: must be called when the unit is ENABLED!
+// otherwise it will not be able to empty the fifos.
+static u32 fsl_empty_fifo(struct device *dev, struct regmap *regs,
int is_rx, int dual_fifo)
+{
+ u32 val;
+ u32 sisr;
+ u32 err = 0;
+ int limit = 100;
+ if (is_rx) {
+ do {
+ regmap_read(regs, CCSR_SSI_SRX0, &val);
+ regmap_read(regs, CCSR_SSI_SISR, &sisr);
+ } while ((limit-- >=0) && (sisr & CCSR_SSI_SISR_RDR0));
+ if (limit <= 0) {
+ dev_err(dev, "Couldn't empty out the RX "
+ "FIFO 0. SISR = 0x%08x\n", sisr);
+ err = 1;
+ }
+ if (dual_fifo) {
+ do {
+ regmap_read(regs, CCSR_SSI_SRX1, &val);
+ regmap_read(regs, CCSR_SSI_SISR, &sisr);
+ } while ((limit-- >=0) &&
+ (sisr & CCSR_SSI_SISR_RDR1));
+ if (limit <= 0) {
+ dev_err(dev, "Couldn't empty out the RX "
+ "FIFO 1. SISR = 0x%08x\n", sisr);
+ err = 1;
+ }
+ }
+ }
+ return err;
+}
+
/*
* Enable/Disable all rx/tx config flags at once.