From patchwork Wed May 1 08:59:20 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Simek X-Patchwork-Id: 240750 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id 92A262C00C2 for ; Wed, 1 May 2013 19:01:03 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 2A8814A2DD; Wed, 1 May 2013 11:00:49 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 5mpW9HEfriCX; Wed, 1 May 2013 11:00:48 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 1B0644A2EC; Wed, 1 May 2013 11:00:10 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 8C2594A2D6 for ; Wed, 1 May 2013 11:00:04 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id MK93fbxhd+uT for ; Wed, 1 May 2013 10:59:59 +0200 (CEST) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from mail-ea0-f169.google.com (mail-ea0-f169.google.com [209.85.215.169]) by theia.denx.de (Postfix) with ESMTPS id 9768A4A2BC for ; Wed, 1 May 2013 10:59:48 +0200 (CEST) Received: by mail-ea0-f169.google.com with SMTP id d10so608430eaj.0 for ; Wed, 01 May 2013 01:59:48 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:sender:from:to:cc:subject:date:message-id:x-mailer :in-reply-to:references:in-reply-to:references:content-type :x-gm-message-state; bh=cvejoGBc+p8yLbaJy1z+s3DuH03IFuIgNNP0EgOeYA4=; b=dfE7+M9aWLgqLhCslJSjDkfSmmadIOfTLyZW57w6pQwaFKjnv4FuEybzLLHTx8jwmZ MRK1jYy9tRCNMmXzg4ecSyufmftGMPAKvCcWKeyheHJ9cAC+TF844cXrqcX4HnEzfRzS cAra6u02dL/gXwJlVOuvr8ES/JUY51SFS8uygdgB/FaLe0mBkCZiqZs0AtM5qpGIhBzU s05ySUKyXUU29K04SN/1+KkvvEe0yiPwDqCGpxKPc3BJlXtEWxIxt6p6TfPWnttDohTa xfOP2C3WjUc/F9vR5Ew/mZ2Rf6tmSW/ip9K02nPD7DBM8p8z2SDOYXQ0gUVxgqlrFATF oefg== X-Received: by 10.14.149.141 with SMTP id x13mr5547341eej.31.1367398788641; Wed, 01 May 2013 01:59:48 -0700 (PDT) Received: from localhost (nat-63.starnet.cz. [178.255.168.63]) by mx.google.com with ESMTPSA id f9sm2501312eeu.11.2013.05.01.01.59.47 for (version=TLSv1.1 cipher=RC4-SHA bits=128/128); Wed, 01 May 2013 01:59:48 -0700 (PDT) From: Michal Simek To: u-boot@lists.denx.de, Joe Hershberger , Albert Aribaud , Tom Rini Date: Wed, 1 May 2013 10:59:20 +0200 Message-Id: X-Mailer: git-send-email 1.8.2.1 In-Reply-To: References: In-Reply-To: References: X-Gm-Message-State: ALoCoQmqIxpQN5klJoIwQsZfzuc2QLRGXVYiEcn4H2BAcOJ6/aSG1+1LjmTIkS36BzQwg9Mal8pH Cc: Peter Crosthwaite , Jagannadha Sutradharudu Teki Subject: [U-Boot] [PATCH v2 4/7] cmd: fpga: Move fpga_loadbitstream to fpga.c X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.11 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de In bitstream decoding you can directly check device which you want to load and in fpga.c are fpga_validate and fpga_dev_info functions which should be used for it. Signed-off-by: Michal Simek --- Changes in v2: None common/cmd_fpga.c | 94 ----------------------------------------------------- drivers/fpga/fpga.c | 94 +++++++++++++++++++++++++++++++++++++++++++++++++++++ include/fpga.h | 1 + 3 files changed, 95 insertions(+), 94 deletions(-) -- 1.8.2.1 diff --git a/common/cmd_fpga.c b/common/cmd_fpga.c index f3579bb..aa14ceb 100644 --- a/common/cmd_fpga.c +++ b/common/cmd_fpga.c @@ -44,100 +44,6 @@ static int fpga_get_op(char *opstr); #define FPGA_DUMP 3 #define FPGA_LOADMK 4 -/* Convert bitstream data and load into the fpga */ -int fpga_loadbitstream(unsigned long dev, char *fpgadata, size_t size) -{ -#if defined(CONFIG_FPGA_XILINX) - unsigned int length; - unsigned int swapsize; - char buffer[80]; - unsigned char *dataptr; - unsigned int i; - int rc; - - dataptr = (unsigned char *)fpgadata; - - /* skip the first bytes of the bitsteam, their meaning is unknown */ - length = (*dataptr << 8) + *(dataptr + 1); - dataptr += 2; - dataptr += length; - - /* get design name (identifier, length, string) */ - length = (*dataptr << 8) + *(dataptr + 1); - dataptr += 2; - if (*dataptr++ != 0x61) { - debug("%s: Design name id not recognized in bitstream\n", - __func__); - return FPGA_FAIL; - } - - length = (*dataptr << 8) + *(dataptr + 1); - dataptr += 2; - for (i = 0; i < length; i++) - buffer[i] = *dataptr++; - - printf(" design filename = \"%s\"\n", buffer); - - /* get part number (identifier, length, string) */ - if (*dataptr++ != 0x62) { - printf("%s: Part number id not recognized in bitstream\n", - __func__); - return FPGA_FAIL; - } - - length = (*dataptr << 8) + *(dataptr + 1); - dataptr += 2; - for (i = 0; i < length; i++) - buffer[i] = *dataptr++; - printf(" part number = \"%s\"\n", buffer); - - /* get date (identifier, length, string) */ - if (*dataptr++ != 0x63) { - printf("%s: Date identifier not recognized in bitstream\n", - __func__); - return FPGA_FAIL; - } - - length = (*dataptr << 8) + *(dataptr+1); - dataptr += 2; - for (i = 0; i < length; i++) - buffer[i] = *dataptr++; - printf(" date = \"%s\"\n", buffer); - - /* get time (identifier, length, string) */ - if (*dataptr++ != 0x64) { - printf("%s: Time identifier not recognized in bitstream\n", - __func__); - return FPGA_FAIL; - } - - length = (*dataptr << 8) + *(dataptr+1); - dataptr += 2; - for (i = 0; i < length; i++) - buffer[i] = *dataptr++; - printf(" time = \"%s\"\n", buffer); - - /* get fpga data length (identifier, length) */ - if (*dataptr++ != 0x65) { - printf("%s: Data length id not recognized in bitstream\n", - __func__); - return FPGA_FAIL; - } - swapsize = ((unsigned int) *dataptr << 24) + - ((unsigned int) *(dataptr + 1) << 16) + - ((unsigned int) *(dataptr + 2) << 8) + - ((unsigned int) *(dataptr + 3)); - dataptr += 4; - printf(" bytes in bitstream = %d\n", swapsize); - - rc = fpga_load(dev, dataptr, swapsize); - return rc; -#else - printf("Bitstream support only for Xilinx devices\n"); - return FPGA_FAIL; -#endif -} - /* ------------------------------------------------------------------------- */ /* command form: * fpga diff --git a/drivers/fpga/fpga.c b/drivers/fpga/fpga.c index 43bdf4f..b74c84f 100644 --- a/drivers/fpga/fpga.c +++ b/drivers/fpga/fpga.c @@ -187,6 +187,100 @@ int fpga_add(fpga_type devtype, void *desc) return devnum; } +/* Convert bitstream data and load into the fpga */ +int fpga_loadbitstream(unsigned long dev, char *fpgadata, size_t size) +{ +#if defined(CONFIG_FPGA_XILINX) + unsigned int length; + unsigned int swapsize; + char buffer[80]; + unsigned char *dataptr; + unsigned int i; + int rc; + + dataptr = (unsigned char *)fpgadata; + + /* skip the first bytes of the bitsteam, their meaning is unknown */ + length = (*dataptr << 8) + *(dataptr + 1); + dataptr += 2; + dataptr += length; + + /* get design name (identifier, length, string) */ + length = (*dataptr << 8) + *(dataptr + 1); + dataptr += 2; + if (*dataptr++ != 0x61) { + debug("%s: Design name id not recognized in bitstream\n", + __func__); + return FPGA_FAIL; + } + + length = (*dataptr << 8) + *(dataptr + 1); + dataptr += 2; + for (i = 0; i < length; i++) + buffer[i] = *dataptr++; + + printf(" design filename = \"%s\"\n", buffer); + + /* get part number (identifier, length, string) */ + if (*dataptr++ != 0x62) { + printf("%s: Part number id not recognized in bitstream\n", + __func__); + return FPGA_FAIL; + } + + length = (*dataptr << 8) + *(dataptr + 1); + dataptr += 2; + for (i = 0; i < length; i++) + buffer[i] = *dataptr++; + printf(" part number = \"%s\"\n", buffer); + + /* get date (identifier, length, string) */ + if (*dataptr++ != 0x63) { + printf("%s: Date identifier not recognized in bitstream\n", + __func__); + return FPGA_FAIL; + } + + length = (*dataptr << 8) + *(dataptr+1); + dataptr += 2; + for (i = 0; i < length; i++) + buffer[i] = *dataptr++; + printf(" date = \"%s\"\n", buffer); + + /* get time (identifier, length, string) */ + if (*dataptr++ != 0x64) { + printf("%s: Time identifier not recognized in bitstream\n", + __func__); + return FPGA_FAIL; + } + + length = (*dataptr << 8) + *(dataptr+1); + dataptr += 2; + for (i = 0; i < length; i++) + buffer[i] = *dataptr++; + printf(" time = \"%s\"\n", buffer); + + /* get fpga data length (identifier, length) */ + if (*dataptr++ != 0x65) { + printf("%s: Data length id not recognized in bitstream\n", + __func__); + return FPGA_FAIL; + } + swapsize = ((unsigned int) *dataptr << 24) + + ((unsigned int) *(dataptr + 1) << 16) + + ((unsigned int) *(dataptr + 2) << 8) + + ((unsigned int) *(dataptr + 3)); + dataptr += 4; + printf(" bytes in bitstream = %d\n", swapsize); + + rc = fpga_load(dev, dataptr, swapsize); + return rc; +#else + printf("Bitstream support only for Xilinx devices\n"); + return FPGA_FAIL; +#endif +} + /* * Generic multiplexing code */ diff --git a/include/fpga.h b/include/fpga.h index 30a4e6a..0d01e04 100644 --- a/include/fpga.h +++ b/include/fpga.h @@ -68,6 +68,7 @@ extern void fpga_init(void); extern int fpga_add(fpga_type devtype, void *desc); extern int fpga_count(void); extern int fpga_load(int devnum, const void *buf, size_t bsize); +extern int fpga_loadbitstream(unsigned long dev, char *fpgadata, size_t size); extern int fpga_dump(int devnum, const void *buf, size_t bsize); extern int fpga_info(int devnum);