Re: [U-Boot] [Patch v8 4/5] armv8/fsl-lsch3: Add support to load and start MC Firmware

2014-06-23 Thread York Sun
In this case, I will have to send a new version to get rid of this check.

York


On 06/23/2014 01:50 PM, Rivera Jose-B46482 wrote:
 The uname == NULL check can be removed.
 
 Thanks,
 
 German
 
 From: Sun York-R58495
 Sent: Friday, June 20, 2014 3:38 PM
 To: Jeroen Hofstee; Rivera Jose-B46482
 Cc: albert.u.b...@aribaud.net; Kanetkar Shruti-B44454; u-boot@lists.denx.de
 Subject: Re: [U-Boot] [Patch v8 4/5] armv8/fsl-lsch3: Add support to load and 
 start MC Firmware
 
 On 06/20/2014 01:33 PM, Jeroen Hofstee wrote:
 Hi York,

 On 20-06-14 20:46, York Sun wrote:
 From: J. German Rivera german.riv...@freescale.com

 Adding support to load and start the Layerscape Management Complex (MC)
 firmware. First, the MC GCR register is set to 0 to reset all cores. MC
 firmware and DPL images are copied from their location in NOR flash to
 DDR. MC registers are updated with the location of these images.
 Deasserting the reset bit of MC GCR register releases core 0 to run.
 Core 1 will be released by MC firmware. Stop bits are not touched for
 this step. U-boot waits for MC until it boots up. In case of a failure,
 device tree is updated accordingly. The MC firmware image uses FIT format.


 +int parse_mc_firmware_fit_image(const void **raw_image_addr,
 +size_t *raw_image_size)
 +{
 +int format;
 +void *fit_hdr;
 +int node_offset;
 +const void *data;
 +size_t size;
 +const char *uname = firmware;
 +
 +/* Check if the image is in NOR flash*/
 +#ifdef CONFIG_SYS_LS_MC_FW_IN_NOR
 +fit_hdr = (void *)CONFIG_SYS_LS_MC_FW_ADDR;
 +#else
 +#error No CONFIG_SYS_LS_MC_FW_IN_xxx defined
 +#endif
 +
 +/* Check if Image is in FIT format */
 +format = genimg_get_format(fit_hdr);
 +
 +if (format != IMAGE_FORMAT_FIT) {
 +debug(Not a FIT image\n);
 +return 1;
 +}
 +
 +if (!fit_check_format(fit_hdr)) {
 +debug(Bad FIT image format\n);
 +return 1;
 +}
 +
 +/* Find node offset of MC Firmware image */
 +if (uname == NULL) {
 +debug(FIT subimage unit name not provided);
 +return 1;
 +}
 +

 I don't see how uname can ever be NULL here, since it is
 assigned above.

 
 Good question. I think German has a plan to use different name. I will let him
 comment.
 
 York
 

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [Patch v8 4/5] armv8/fsl-lsch3: Add support to load and start MC Firmware

2014-06-23 Thread Jose Rivera
The uname == NULL check can be removed.

Thanks,

German

From: Sun York-R58495
Sent: Friday, June 20, 2014 3:38 PM
To: Jeroen Hofstee; Rivera Jose-B46482
Cc: albert.u.b...@aribaud.net; Kanetkar Shruti-B44454; u-boot@lists.denx.de
Subject: Re: [U-Boot] [Patch v8 4/5] armv8/fsl-lsch3: Add support to load and 
start MC Firmware

On 06/20/2014 01:33 PM, Jeroen Hofstee wrote:
 Hi York,

 On 20-06-14 20:46, York Sun wrote:
 From: J. German Rivera german.riv...@freescale.com

 Adding support to load and start the Layerscape Management Complex (MC)
 firmware. First, the MC GCR register is set to 0 to reset all cores. MC
 firmware and DPL images are copied from their location in NOR flash to
 DDR. MC registers are updated with the location of these images.
 Deasserting the reset bit of MC GCR register releases core 0 to run.
 Core 1 will be released by MC firmware. Stop bits are not touched for
 this step. U-boot waits for MC until it boots up. In case of a failure,
 device tree is updated accordingly. The MC firmware image uses FIT format.


 +int parse_mc_firmware_fit_image(const void **raw_image_addr,
 +size_t *raw_image_size)
 +{
 +int format;
 +void *fit_hdr;
 +int node_offset;
 +const void *data;
 +size_t size;
 +const char *uname = firmware;
 +
 +/* Check if the image is in NOR flash*/
 +#ifdef CONFIG_SYS_LS_MC_FW_IN_NOR
 +fit_hdr = (void *)CONFIG_SYS_LS_MC_FW_ADDR;
 +#else
 +#error No CONFIG_SYS_LS_MC_FW_IN_xxx defined
 +#endif
 +
 +/* Check if Image is in FIT format */
 +format = genimg_get_format(fit_hdr);
 +
 +if (format != IMAGE_FORMAT_FIT) {
 +debug(Not a FIT image\n);
 +return 1;
 +}
 +
 +if (!fit_check_format(fit_hdr)) {
 +debug(Bad FIT image format\n);
 +return 1;
 +}
 +
 +/* Find node offset of MC Firmware image */
 +if (uname == NULL) {
 +debug(FIT subimage unit name not provided);
 +return 1;
 +}
 +

 I don't see how uname can ever be NULL here, since it is
 assigned above.


Good question. I think German has a plan to use different name. I will let him
comment.

York

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [Patch v8 4/5] armv8/fsl-lsch3: Add support to load and start MC Firmware

2014-06-20 Thread York Sun
From: J. German Rivera german.riv...@freescale.com

Adding support to load and start the Layerscape Management Complex (MC)
firmware. First, the MC GCR register is set to 0 to reset all cores. MC
firmware and DPL images are copied from their location in NOR flash to
DDR. MC registers are updated with the location of these images.
Deasserting the reset bit of MC GCR register releases core 0 to run.
Core 1 will be released by MC firmware. Stop bits are not touched for
this step. U-boot waits for MC until it boots up. In case of a failure,
device tree is updated accordingly. The MC firmware image uses FIT format.

Signed-off-by: J. German Rivera german.riv...@freescale.com
Signed-off-by: York Sun york...@freescale.com
Signed-off-by: Lijun Pan lijun@freescale.com
Signed-off-by: Shruti Kanetkar shr...@freescale.com
---
 v8: no change
 v7: no change
 v6: no change
 v5: Fix a typo in commit message supoort
 Fix variable declaration cause by squashing patches
 v4: no change
 v3: Add error detection and update device tree if failure
 Revise loading address to avoid overlap
 Use FIT image for the firmware
 Remove blank lines at the end of files

 README |   27 
 arch/arm/cpu/armv8/fsl-lsch3/cpu.c |   11 ++
 drivers/net/Makefile   |1 +
 drivers/net/fsl_mc/Makefile|8 ++
 drivers/net/fsl_mc/mc.c|  272 
 include/fdt_support.h  |   14 +-
 include/fsl_mc.h   |   59 
 7 files changed, 389 insertions(+), 3 deletions(-)
 create mode 100644 drivers/net/fsl_mc/Makefile
 create mode 100644 drivers/net/fsl_mc/mc.c
 create mode 100644 include/fsl_mc.h

diff --git a/README b/README
index 7129df8..9470c30 100644
--- a/README
+++ b/README
@@ -4653,6 +4653,33 @@ within that device.
window-master inbound window-master LAW-the ucode address in
master's memory space.
 
+Freescale Layerscape Management Complex Firmware Support:
+-
+The Freescale Layerscape Management Complex (MC) supports the loading of
+firmware.
+This firmware often needs to be loaded during U-Boot booting, so macros
+are used to identify the storage device (NOR flash, SPI, etc) and the address
+within that device.
+
+- CONFIG_FSL_MC_ENET
+   Enable the MC driver for Layerscape SoCs.
+
+- CONFIG_SYS_LS_MC_FW_ADDR
+   The address in the storage device where the firmware is located.  The
+   meaning of this address depends on which CONFIG_SYS_LS_MC_FW_IN_xxx 
macro
+   is also specified.
+
+- CONFIG_SYS_LS_MC_FW_LENGTH
+   The maximum possible size of the firmware.  The firmware binary format
+   has a field that specifies the actual size of the firmware, but it
+   might not be possible to read any part of the firmware unless some
+   local storage is allocated to hold the entire firmware first.
+
+- CONFIG_SYS_LS_MC_FW_IN_NOR
+   Specifies that MC firmware is located in NOR flash, mapped as
+   normal addressable memory via the LBC. CONFIG_SYS_LS_MC_FW_ADDR is the
+   virtual address in NOR flash.
+
 Building the Software:
 ==
 
diff --git a/arch/arm/cpu/armv8/fsl-lsch3/cpu.c 
b/arch/arm/cpu/armv8/fsl-lsch3/cpu.c
index 46965f0..c129d03 100644
--- a/arch/arm/cpu/armv8/fsl-lsch3/cpu.c
+++ b/arch/arm/cpu/armv8/fsl-lsch3/cpu.c
@@ -12,6 +12,7 @@
 #include asm/arch-fsl-lsch3/immap_lsch3.h
 #include cpu.h
 #include speed.h
+#include fsl_mc.h
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -423,3 +424,13 @@ int print_cpuinfo(void)
return 0;
 }
 #endif
+
+int cpu_eth_init(bd_t *bis)
+{
+   int error = 0;
+
+#ifdef CONFIG_FSL_MC_ENET
+   error = mc_init(bis);
+#endif
+   return error;
+}
diff --git a/drivers/net/Makefile b/drivers/net/Makefile
index 6005f7e..6226cb2 100644
--- a/drivers/net/Makefile
+++ b/drivers/net/Makefile
@@ -64,3 +64,4 @@ obj-$(CONFIG_XILINX_EMACLITE) += xilinx_emaclite.o
 obj-$(CONFIG_XILINX_LL_TEMAC) += xilinx_ll_temac.o xilinx_ll_temac_mdio.o \
xilinx_ll_temac_fifo.o xilinx_ll_temac_sdma.o
 obj-$(CONFIG_ZYNQ_GEM) += zynq_gem.o
+obj-$(CONFIG_FSL_MC_ENET) += fsl_mc/
diff --git a/drivers/net/fsl_mc/Makefile b/drivers/net/fsl_mc/Makefile
new file mode 100644
index 000..4834086
--- /dev/null
+++ b/drivers/net/fsl_mc/Makefile
@@ -0,0 +1,8 @@
+#
+# Copyright 2014 Freescale Semiconductor, Inc.
+#
+# SPDX-License-Identifier: GPL-2.0+
+#
+
+# Layerscape MC driver
+obj-y += mc.o
diff --git a/drivers/net/fsl_mc/mc.c b/drivers/net/fsl_mc/mc.c
new file mode 100644
index 000..056424b
--- /dev/null
+++ b/drivers/net/fsl_mc/mc.c
@@ -0,0 +1,272 @@
+/*
+ * Copyright (C) 2014 Freescale Semiconductor
+ *
+ * SPDX-License-Identifier:GPL-2.0+
+ */
+#include errno.h
+#include asm/io.h
+#include fsl_mc.h
+
+DECLARE_GLOBAL_DATA_PTR;
+static int mc_boot_status;
+
+/**
+ * Copying MC firmware or DPL image to DDR
+ */
+static int mc_copy_image(const 

Re: [U-Boot] [Patch v8 4/5] armv8/fsl-lsch3: Add support to load and start MC Firmware

2014-06-20 Thread Jeroen Hofstee

Hi York,

On 20-06-14 20:46, York Sun wrote:

From: J. German Rivera german.riv...@freescale.com

Adding support to load and start the Layerscape Management Complex (MC)
firmware. First, the MC GCR register is set to 0 to reset all cores. MC
firmware and DPL images are copied from their location in NOR flash to
DDR. MC registers are updated with the location of these images.
Deasserting the reset bit of MC GCR register releases core 0 to run.
Core 1 will be released by MC firmware. Stop bits are not touched for
this step. U-boot waits for MC until it boots up. In case of a failure,
device tree is updated accordingly. The MC firmware image uses FIT format.


+int parse_mc_firmware_fit_image(const void **raw_image_addr,
+   size_t *raw_image_size)
+{
+   int format;
+   void *fit_hdr;
+   int node_offset;
+   const void *data;
+   size_t size;
+   const char *uname = firmware;
+
+   /* Check if the image is in NOR flash*/
+#ifdef CONFIG_SYS_LS_MC_FW_IN_NOR
+   fit_hdr = (void *)CONFIG_SYS_LS_MC_FW_ADDR;
+#else
+#error No CONFIG_SYS_LS_MC_FW_IN_xxx defined
+#endif
+
+   /* Check if Image is in FIT format */
+   format = genimg_get_format(fit_hdr);
+
+   if (format != IMAGE_FORMAT_FIT) {
+   debug(Not a FIT image\n);
+   return 1;
+   }
+
+   if (!fit_check_format(fit_hdr)) {
+   debug(Bad FIT image format\n);
+   return 1;
+   }
+
+   /* Find node offset of MC Firmware image */
+   if (uname == NULL) {
+   debug(FIT subimage unit name not provided);
+   return 1;
+   }
+


I don't see how uname can ever be NULL here, since it is
assigned above.

Regards,
Jeroen



___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [Patch v8 4/5] armv8/fsl-lsch3: Add support to load and start MC Firmware

2014-06-20 Thread York Sun
On 06/20/2014 01:33 PM, Jeroen Hofstee wrote:
 Hi York,
 
 On 20-06-14 20:46, York Sun wrote:
 From: J. German Rivera german.riv...@freescale.com

 Adding support to load and start the Layerscape Management Complex (MC)
 firmware. First, the MC GCR register is set to 0 to reset all cores. MC
 firmware and DPL images are copied from their location in NOR flash to
 DDR. MC registers are updated with the location of these images.
 Deasserting the reset bit of MC GCR register releases core 0 to run.
 Core 1 will be released by MC firmware. Stop bits are not touched for
 this step. U-boot waits for MC until it boots up. In case of a failure,
 device tree is updated accordingly. The MC firmware image uses FIT format.


 +int parse_mc_firmware_fit_image(const void **raw_image_addr,
 +size_t *raw_image_size)
 +{
 +int format;
 +void *fit_hdr;
 +int node_offset;
 +const void *data;
 +size_t size;
 +const char *uname = firmware;
 +
 +/* Check if the image is in NOR flash*/
 +#ifdef CONFIG_SYS_LS_MC_FW_IN_NOR
 +fit_hdr = (void *)CONFIG_SYS_LS_MC_FW_ADDR;
 +#else
 +#error No CONFIG_SYS_LS_MC_FW_IN_xxx defined
 +#endif
 +
 +/* Check if Image is in FIT format */
 +format = genimg_get_format(fit_hdr);
 +
 +if (format != IMAGE_FORMAT_FIT) {
 +debug(Not a FIT image\n);
 +return 1;
 +}
 +
 +if (!fit_check_format(fit_hdr)) {
 +debug(Bad FIT image format\n);
 +return 1;
 +}
 +
 +/* Find node offset of MC Firmware image */
 +if (uname == NULL) {
 +debug(FIT subimage unit name not provided);
 +return 1;
 +}
 +
 
 I don't see how uname can ever be NULL here, since it is
 assigned above.
 

Good question. I think German has a plan to use different name. I will let him
comment.

York

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot