From e1557c765f115bb763af04b1c8d85eb82ddd6d26 Mon Sep 17 00:00:00 2001 From: Kedareswara rao Appana Date: Wed, 27 May 2015 18:49:40 +0530 Subject: [PATCH] mcap: linux: Add check for bitstream completion This patch fixes the issue Done pin doesn't go high after programming the 2nd stage bit stream. Signed-off-by: Kedareswara rao Appana Reviewed-by: Srikanth Vemula --- mcap/linux/mcap_lib.c | 29 +++++++++++++++++++++++++++++ mcap/linux/mcap_lib.h | 4 ++++ 2 files changed, 33 insertions(+) diff --git a/mcap/linux/mcap_lib.c b/mcap/linux/mcap_lib.c index aaa14423..7174baf7 100644 --- a/mcap/linux/mcap_lib.c +++ b/mcap/linux/mcap_lib.c @@ -200,6 +200,30 @@ static int MCapClearRequestByConfigure(struct mcap_dev *mdev, u32 *restore) return 0; } +static int Checkforcompletion(struct mcap_dev *mdev) +{ + unsigned long retry_count = 0; + u32 delay; + int sr, i; + + sr = MCapRegRead(mdev, MCAP_STATUS); + while (!(sr & MCAP_STS_EOS_MASK)) { + + usleep(2); + for (i=0 ; i < EMCAP_EOS_LOOP_COUNT; i++) { + MCapRegWrite(mdev, MCAP_DATA, EMCAP_NOOP_VAL); + } + sr = MCapRegRead(mdev, MCAP_STATUS); + retry_count++; + if (retry_count > EMCAP_EOS_RETRY_COUNT) { + pr_err("Error: The MCAP EOS bit did not assert after"); + pr_err(" programming the specified programming file\n"); + return -EMCAPREQ; + } + } + return 0; +} + static int MCapWriteBitStream(struct mcap_dev *mdev, u32 *data, int len, u8 bswap) { @@ -242,6 +266,11 @@ static int MCapWriteBitStream(struct mcap_dev *mdev, u32 *data, MCapRegWrite(mdev, MCAP_DATA, __bswap_32(data[count])); } + /* Check for Completion */ + err = Checkforcompletion(mdev); + if (err) + return -EMCAPCFG; + if (IsErrSet(mdev) || IsFifoOverflow(mdev)) { pr_err("Failed to Write Bitstream\n"); MCapRegWrite(mdev, MCAP_CONTROL, restore); diff --git a/mcap/linux/mcap_lib.h b/mcap/linux/mcap_lib.h index b1b8ca72..a42e517c 100644 --- a/mcap/linux/mcap_lib.h +++ b/mcap/linux/mcap_lib.h @@ -92,6 +92,10 @@ #define EMCAPBUSWALK 127 #define EMCAPCFGACC 128 +#define EMCAP_EOS_RETRY_COUNT 10 +#define EMCAP_EOS_LOOP_COUNT 100 +#define EMCAP_NOOP_VAL 0x2000000 + #undef DEBUG #ifndef DEBUG