From 04f84f637bd23915391bdf0bfb7542dbfd6b6728 Mon Sep 17 00:00:00 2001 From: Kedareswara rao Appana Date: Wed, 27 May 2015 18:35:37 +0530 Subject: [PATCH] mcap: linux: Add support for multiple bitstreams This patch adds support for configuring a partial clear file followed by a partial bit file. (Ex: ./mcap -x 0x8038 -C partialclear.bit -p partial.bit) Signed-off-by: Kedareswara rao Appana Reviewed-by: Srikanth Vemula --- mcap/linux/mcap.c | 12 ++++++++++-- mcap/linux/mcap_lib.c | 27 +++++++++++++++++++-------- mcap/linux/mcap_lib.h | 1 + 3 files changed, 30 insertions(+), 10 deletions(-) diff --git a/mcap/linux/mcap.c b/mcap/linux/mcap.c index 7e6055f0..4d046711 100644 --- a/mcap/linux/mcap.c +++ b/mcap/linux/mcap.c @@ -151,12 +151,20 @@ int main(int argc, char **argv) } if (programconfigfile) { + if (argc > 6) + mdev->is_multiplebit = 1; + MCapConfigureFPGA(mdev, argv[4], EMCAP_PARTIALCONFIG_FILE); - goto free; + + if(!mdev->is_multiplebit) + goto free; } if (program) { - MCapConfigureFPGA(mdev, argv[4], EMCAP_CONFIG_FILE); + if (argc > 6) + MCapConfigureFPGA(mdev, argv[6], EMCAP_CONFIG_FILE); + else + MCapConfigureFPGA(mdev, argv[4], EMCAP_CONFIG_FILE); goto free; } diff --git a/mcap/linux/mcap_lib.c b/mcap/linux/mcap_lib.c index 2f16aa05..0c983407 100644 --- a/mcap/linux/mcap_lib.c +++ b/mcap/linux/mcap_lib.c @@ -276,6 +276,13 @@ static int MCapWritePartialBitStream(struct mcap_dev *mdev, u32 *data, return -EMCAPWRITE; } + if (!mdev->is_multiplebit) { + pr_info("Info: A partial reconfiguration clear file (-C) was"); + pr_info(" loaded without a partial reconfiguration file (-p)"); + pr_info(" as result the MCAP Control register was not restored"); + pr_info(" to its original value\n\r"); + } + return 0; } @@ -301,16 +308,18 @@ static int MCapWriteBitStream(struct mcap_dev *mdev, u32 *data, return -EMCAPWRITE; } - /* Set 'Mode', 'In Use by PCIe' and 'Data Reg Protect' bits */ - set = MCapRegRead(mdev, MCAP_CONTROL); - set |= MCAP_CTRL_MODE_MASK | MCAP_CTRL_IN_USE_MASK | - MCAP_CTRL_DATA_REG_PROT_MASK; + if (!mdev->is_multiplebit) { + /* Set 'Mode', 'In Use by PCIe' and 'Data Reg Protect' bits */ + set = MCapRegRead(mdev, MCAP_CONTROL); + set |= MCAP_CTRL_MODE_MASK | MCAP_CTRL_IN_USE_MASK | + MCAP_CTRL_DATA_REG_PROT_MASK; - /* Clear 'Reset', 'Module Reset' and 'Register Read' bits */ - set &= ~(MCAP_CTRL_RESET_MASK | MCAP_CTRL_MOD_RESET_MASK | - MCAP_CTRL_REG_READ_MASK | MCAP_CTRL_DESIGN_SWITCH_MASK); + /* Clear 'Reset', 'Module Reset' and 'Register Read' bits */ + set &= ~(MCAP_CTRL_RESET_MASK | MCAP_CTRL_MOD_RESET_MASK | + MCAP_CTRL_REG_READ_MASK | MCAP_CTRL_DESIGN_SWITCH_MASK); - MCapRegWrite(mdev, MCAP_CONTROL, set); + MCapRegWrite(mdev, MCAP_CONTROL, set); + } /* Write Data */ if (!bswap) { @@ -361,6 +370,8 @@ struct mcap_dev *MCapLibInit(int device_id) /* Get the pci_access structure */ mdev->pacc = pci_alloc(); + mdev->is_multiplebit = 0; + /* Initialize the PCI library */ pci_init(mdev->pacc); diff --git a/mcap/linux/mcap_lib.h b/mcap/linux/mcap_lib.h index 3f105477..8c50aa22 100644 --- a/mcap/linux/mcap_lib.h +++ b/mcap/linux/mcap_lib.h @@ -115,6 +115,7 @@ struct mcap_dev { struct pci_dev *pdev; struct pci_access *pacc; unsigned int reg_base; + u32 is_multiplebit; }; #define MCapRegWrite(mdev, offset, value) \