From patchwork Mon Feb 20 03:35:59 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dalon Westergreen X-Patchwork-Id: 729826 X-Patchwork-Delegate: monstr@monstr.eu 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 3vRczq2FDYz9s86 for ; Mon, 20 Feb 2017 20:00:55 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="BPREgnm/"; dkim-atps=neutral Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id B6BE4B3E92; Mon, 20 Feb 2017 09:37:35 +0100 (CET) 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 dXSK9h5wmdg8; Mon, 20 Feb 2017 09:37:35 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 5C491B3E95; Mon, 20 Feb 2017 09:24:05 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 7C1574A08A for ; Mon, 20 Feb 2017 04:36:17 +0100 (CET) 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 M7hzUF28wh0t for ; Mon, 20 Feb 2017 04:36:17 +0100 (CET) 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-pg0-f66.google.com (mail-pg0-f66.google.com [74.125.83.66]) by theia.denx.de (Postfix) with ESMTPS id 079EF4A068 for ; Mon, 20 Feb 2017 04:36:12 +0100 (CET) Received: by mail-pg0-f66.google.com with SMTP id a123so8316336pgc.3 for ; Sun, 19 Feb 2017 19:36:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Zthsf4onbBvnSPL4oPBdkd0KiLKn3xD2NvxVrpsGCQ4=; b=BPREgnm/tMMg/mp5y8wWEUI0/bND8J7oZmg5qasau96UoznaHk+lmzf//7aHwlvLyx zysOdO0AQpVWo6F7BBruNAECr+cNO7nsLqBv071vS3mIpJt+b2R/WYpdxfNMge4rCHqG yEpwjgbnYvyGpIvK/4imuUWtxDRxVsw9pSYsPp3bDP0E6ZxlV+5n2kHrb7Ebik6EYcEH GUrN7zPJNW3fFVpCy2hPkd1ljBwLZReBRIt4uZRxEPMzV9IJGTrbMeIPWmM0lLByG0co sltnzB+K96OH3wOQ4f+oOSBQJJYyOudUdI3blQ5p60oHFbsf7YZV0LCmytMx3RS/F0Ip C+Pw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=Zthsf4onbBvnSPL4oPBdkd0KiLKn3xD2NvxVrpsGCQ4=; b=gjaZIWOf3TiEyMzyRYGirSSa34xI5f/nCKBiYbwGKIV4Co3dP44sPdPCAFfd9vtwy/ bippa41JnfTV4x5SHccefQxG2XBH0i6l3XtVp70+es+ObbdI8lu/FT9iwxgqYJP6CxBh OZKjInuciJ8ot38q+XbzE4esJwiIXT6B/Rf4mB/PubUP/Mmz0xYY+XGOQ0hK6GKThlaB QaeKsJ3QFCNaGPMt/QkVEsoHvHoFRhER4Xbayv1jof0Uw+BoZ0rBgD0qvyvyiaya+xIn cOZ4hRHHaZxNo4LQCmDPLGaNcidLD4chKRWwQzpifEXTPbQL1JHaNOLr8e9Sk2rfL0DX +UIA== X-Gm-Message-State: AMke39lbjVUJrVbjGfpRT5/5PZALpEumV03up00KF0XJvd3LjQBAlDehWSfmi3ftIali6A== X-Received: by 10.98.70.194 with SMTP id o63mr23593990pfi.49.1487561771341; Sun, 19 Feb 2017 19:36:11 -0800 (PST) Received: from dwesterg-mobl1.amr.corp.intel.com ([192.55.54.45]) by smtp.gmail.com with ESMTPSA id b7sm31536678pfg.53.2017.02.19.19.36.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 19 Feb 2017 19:36:10 -0800 (PST) From: Dalon Westergreen To: u-boot@lists.denx.de, marex@denx.de, chin.liang.see@intel.com, dinguyen@kernel.org, monstr@monstr.eu, michal.simek@xilinx.com, moritz.fischer@ettus.com, lftan.linux@gmail.com Date: Sun, 19 Feb 2017 19:35:59 -0800 Message-Id: <1487561760-26982-2-git-send-email-dwesterg@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1487561760-26982-1-git-send-email-dwesterg@gmail.com> References: <1487561760-26982-1-git-send-email-dwesterg@gmail.com> Subject: [U-Boot] [PATCH v2 1/2] common: image: update boot_get_fpga to support arbitrary fpga image X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.15 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" The implementation of boot_get_fpga only supported one fpga family. This modification allows for any of the fpga devices supported by fpga_load to be used. Signed-off-by: Dalon Westergreen --- Changes in v2: - Add fitimage support for fpga-devnum and fpga-partial-image - Use above in boot_get_fpga - for xilinx fpgas double check using image size to determine if image is a partial image --- common/image-fit.c | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ common/image.c | 51 ++++++++++++++++++++++++++++++++------------------- include/image.h | 5 +++++ 3 files changed, 88 insertions(+), 19 deletions(-) diff --git a/common/image-fit.c b/common/image-fit.c index 109ecfa..eb0c633 100644 --- a/common/image-fit.c +++ b/common/image-fit.c @@ -916,6 +916,57 @@ ulong fit_get_end(const void *fit) } /** + * fit_image_fpga_get_devnum - get fpga devnum + * @fit: pointer to the FIT format image header + * @noffset: fpga node offset + * @devnum: pointer to an int, will hold fpga devnum + * + * fit_image_fpga_get_devnum() finds the fpga devnum for which the fpga data is + * intended. If the property is not found, we default to 0. + * + * returns: + * 0, on devnum not found + * value, on devnum found + */ +int fit_image_fpga_get_devnum(const void *fit, int noffset, int *devnum) +{ + int len; + int *value; + + value = (int *)fdt_getprop(fit, noffset, FIT_FPGA_DEVNUM_PROP, &len); + if (value == NULL || len != sizeof(int)) + *devnum = 0; + else + *devnum = *value; + + return 0; +} + +/** + * fit_image_fpga_is_partial - is partial fpga + * @fit: pointer to the FIT format image header + * @noffset: fpga node offset + * + * fit_image_fpga_is_partial() checks if the fpga node sets the property + * indicating the data represents a partial fpga image. + * + * returns: + * 0, on devnum not found + * value, on devnum found + */ +int fit_image_fpga_is_partial(const void *fit, int noffset) +{ + int len; + int *value; + + value = (int *)fdt_getprop(fit, noffset, FIT_FPGA_PARTIAL_PROP, &len); + if ((value == NULL || len != sizeof(int)) || (value == 0)) + return 0; + else + return 1; +} + +/** * fit_set_timestamp - set node timestamp property * @fit: pointer to the FIT format image header * @noffset: node offset diff --git a/common/image.c b/common/image.c index 0f88984..6a3d2c3 100644 --- a/common/image.c +++ b/common/image.c @@ -1306,7 +1306,7 @@ int boot_get_setup(bootm_headers_t *images, uint8_t arch, } #if IMAGE_ENABLE_FIT -#if defined(CONFIG_FPGA) && defined(CONFIG_FPGA_XILINX) +#if defined(CONFIG_FPGA) int boot_get_fpga(int argc, char * const argv[], bootm_headers_t *images, uint8_t arch, const ulong *ld_start, ulong * const ld_len) { @@ -1316,9 +1316,10 @@ int boot_get_fpga(int argc, char * const argv[], bootm_headers_t *images, int fit_img_result; const char *uname, *name; int err; - int devnum = 0; /* TODO support multi fpga platforms */ - const fpga_desc * const desc = fpga_get_desc(devnum); - xilinx_desc *desc_xilinx = desc->devdesc; + int devnum; + const fpga_desc *desc; + xilinx_desc *desc_xilinx; + bitstream_type bstype = BIT_FULL; /* Check to see if the images struct has a FIT configuration */ if (!genimg_has_config(images)) { @@ -1365,26 +1366,38 @@ int boot_get_fpga(int argc, char * const argv[], bootm_headers_t *images, return fit_img_result; } - if (img_len >= desc_xilinx->size) { - name = "full"; - err = fpga_loadbitstream(devnum, (char *)img_data, - img_len, BIT_FULL); - if (err) - err = fpga_load(devnum, (const void *)img_data, - img_len, BIT_FULL); - } else { - name = "partial"; - err = fpga_loadbitstream(devnum, (char *)img_data, - img_len, BIT_PARTIAL); - if (err) - err = fpga_load(devnum, (const void *)img_data, - img_len, BIT_PARTIAL); + /* Get fpga devnum, defaults to 0 */ + fit_image_fpga_get_devnum(buf, conf_noffset, &devnum); + + /* check bitstream type */ + if (fit_image_fpga_is_partial(buf, conf_noffset)) + bstype = BIT_PARTIAL; + + /* legacy support detecting partial config files for xilinx */ + desc = fpga_get_desc(devnum); + if (desc->devtype == fpga_xilinx) { + desc_xilinx = desc->devdesc; + if (img_len < desc_xilinx->size) + bstype = BIT_PARTIAL; } + /* Try bitstream format first */ + err = fpga_loadbitstream(devnum, (char *)img_data, + img_len, bstype); + if (err) + err = fpga_load(devnum, (const void *)img_data, + img_len, bstype); + if (err) return err; - printf(" Programming %s bitstream... OK\n", name); + if (bstype == BIT_PARTIAL) + name = "partial"; + else + name = "full"; + + printf(" Programming %s bitstream into fpga %d... OK\n", + name, devnum); break; default: printf("The given image format is not supported (corrupt?)\n"); diff --git a/include/image.h b/include/image.h index 1e686b7..75d2afc 100644 --- a/include/image.h +++ b/include/image.h @@ -876,6 +876,8 @@ int bootz_setup(ulong image, ulong *start, ulong *end); #define FIT_COMP_PROP "compression" #define FIT_ENTRY_PROP "entry" #define FIT_LOAD_PROP "load" +#define FIT_FPGA_DEVNUM_PROP "fpga-devnum" +#define FIT_FPGA_PARTIAL_PROP "fpga-partial-image" /* configuration node */ #define FIT_KERNEL_PROP "kernel" @@ -955,6 +957,9 @@ int fit_image_hash_get_value(const void *fit, int noffset, uint8_t **value, int fit_set_timestamp(void *fit, int noffset, time_t timestamp); +int fit_image_fpga_get_devnum(const void *fit, int noffset, int *devnum); +int fit_image_fpga_is_partial(const void *fit, int noffset); + /** * fit_add_verification_data() - add verification data to FIT image nodes *