All of lore.kernel.org
 help / color / mirror / Atom feed
From: Michal Simek <michal.simek@amd.com>
To: Stefan Herbrechtsmeier
	<stefan.herbrechtsmeier-oss@weidmueller.com>,
	<u-boot@lists.denx.de>
Cc: Stefan Herbrechtsmeier <stefan.herbrechtsmeier@weidmueller.com>
Subject: Re: [PATCH 04/10] xilinx: zynqmp: Use soc machine function to get silicon idcode name
Date: Fri, 17 Jun 2022 12:41:18 +0200	[thread overview]
Message-ID: <5e17a9d5-6e67-d7d9-6ba9-a0eddb03e110@amd.com> (raw)
In-Reply-To: <20220608162054.25641-5-stefan.herbrechtsmeier-oss@weidmueller.com>



On 6/8/22 18:20, Stefan Herbrechtsmeier wrote:
> [CAUTION: External Email]
> 
> From: Stefan Herbrechtsmeier <stefan.herbrechtsmeier@weidmueller.com>
> 
> Use the soc_get_machine function of the soc uclass to get silicon idcode
> name for the fpga init.
> 
> Signed-off-by: Stefan Herbrechtsmeier <stefan.herbrechtsmeier@weidmueller.com>
> ---
> 
>   board/xilinx/zynqmp/zynqmp.c | 287 ++---------------------------------
>   1 file changed, 15 insertions(+), 272 deletions(-)
> 
> diff --git a/board/xilinx/zynqmp/zynqmp.c b/board/xilinx/zynqmp/zynqmp.c
> index e311aa772c..06f6dbab18 100644
> --- a/board/xilinx/zynqmp/zynqmp.c
> +++ b/board/xilinx/zynqmp/zynqmp.c
> @@ -19,6 +19,7 @@
>   #include <sata.h>
>   #include <ahci.h>
>   #include <scsi.h>
> +#include <soc.h>
>   #include <malloc.h>
>   #include <memalign.h>
>   #include <wdt.h>
> @@ -44,278 +45,10 @@
> 
>   #include "pm_cfg_obj.h"
> 
> -#define ZYNQMP_VERSION_SIZE    7
> -#define EFUSE_VCU_DIS_MASK     0x100
> -#define EFUSE_VCU_DIS_SHIFT    8
> -#define EFUSE_GPU_DIS_MASK     0x20
> -#define EFUSE_GPU_DIS_SHIFT    5
> -#define IDCODE2_PL_INIT_MASK   0x200
> -#define IDCODE2_PL_INIT_SHIFT  9
> -
>   DECLARE_GLOBAL_DATA_PTR;
> 
>   #if CONFIG_IS_ENABLED(FPGA) && defined(CONFIG_FPGA_ZYNQMPPL)
>   static xilinx_desc zynqmppl = XILINX_ZYNQMP_DESC;
> -
> -enum {
> -       ZYNQMP_VARIANT_EG = BIT(0U),
> -       ZYNQMP_VARIANT_EV = BIT(1U),
> -       ZYNQMP_VARIANT_CG = BIT(2U),
> -       ZYNQMP_VARIANT_DR = BIT(3U),
> -};
> -
> -static const struct {
> -       u32 id;
> -       u8 device;
> -       u8 variants;
> -} zynqmp_devices[] = {
> -       {
> -               .id = 0x04688093,
> -               .device = 1,
> -               .variants = ZYNQMP_VARIANT_EG,
> -       },
> -       {
> -               .id = 0x04711093,
> -               .device = 2,
> -               .variants = ZYNQMP_VARIANT_EG | ZYNQMP_VARIANT_CG,
> -       },
> -       {
> -               .id = 0x04710093,
> -               .device = 3,
> -               .variants = ZYNQMP_VARIANT_EG | ZYNQMP_VARIANT_CG,
> -       },
> -       {
> -               .id = 0x04721093,
> -               .device = 4,
> -               .variants = ZYNQMP_VARIANT_EG | ZYNQMP_VARIANT_CG |
> -                       ZYNQMP_VARIANT_EV,
> -       },
> -       {
> -               .id = 0x04720093,
> -               .device = 5,
> -               .variants = ZYNQMP_VARIANT_EG | ZYNQMP_VARIANT_CG |
> -                       ZYNQMP_VARIANT_EV,
> -       },
> -       {
> -               .id = 0x04739093,
> -               .device = 6,
> -               .variants = ZYNQMP_VARIANT_EG | ZYNQMP_VARIANT_CG,
> -       },
> -       {
> -               .id = 0x04730093,
> -               .device = 7,
> -               .variants = ZYNQMP_VARIANT_EG | ZYNQMP_VARIANT_CG |
> -                       ZYNQMP_VARIANT_EV,
> -       },
> -       {
> -               .id = 0x04738093,
> -               .device = 9,
> -               .variants = ZYNQMP_VARIANT_EG | ZYNQMP_VARIANT_CG,
> -       },
> -       {
> -               .id = 0x04740093,
> -               .device = 11,
> -               .variants = ZYNQMP_VARIANT_EG,
> -       },
> -       {
> -               .id = 0x04750093,
> -               .device = 15,
> -               .variants = ZYNQMP_VARIANT_EG,
> -       },
> -       {
> -               .id = 0x04759093,
> -               .device = 17,
> -               .variants = ZYNQMP_VARIANT_EG,
> -       },
> -       {
> -               .id = 0x04758093,
> -               .device = 19,
> -               .variants = ZYNQMP_VARIANT_EG,
> -       },
> -       {
> -               .id = 0x047E1093,
> -               .device = 21,
> -               .variants = ZYNQMP_VARIANT_DR,
> -       },
> -       {
> -               .id = 0x047E3093,
> -               .device = 23,
> -               .variants = ZYNQMP_VARIANT_DR,
> -       },
> -       {
> -               .id = 0x047E5093,
> -               .device = 25,
> -               .variants = ZYNQMP_VARIANT_DR,
> -       },
> -       {
> -               .id = 0x047E4093,
> -               .device = 27,
> -               .variants = ZYNQMP_VARIANT_DR,
> -       },
> -       {
> -               .id = 0x047E0093,
> -               .device = 28,
> -               .variants = ZYNQMP_VARIANT_DR,
> -       },
> -       {
> -               .id = 0x047E2093,
> -               .device = 29,
> -               .variants = ZYNQMP_VARIANT_DR,
> -       },
> -       {
> -               .id = 0x047E6093,
> -               .device = 39,
> -               .variants = ZYNQMP_VARIANT_DR,
> -       },
> -       {
> -               .id = 0x047FD093,
> -               .device = 43,
> -               .variants = ZYNQMP_VARIANT_DR,
> -       },
> -       {
> -               .id = 0x047F8093,
> -               .device = 46,
> -               .variants = ZYNQMP_VARIANT_DR,
> -       },
> -       {
> -               .id = 0x047FF093,
> -               .device = 47,
> -               .variants = ZYNQMP_VARIANT_DR,
> -       },
> -       {
> -               .id = 0x047FB093,
> -               .device = 48,
> -               .variants = ZYNQMP_VARIANT_DR,
> -       },
> -       {
> -               .id = 0x047FE093,
> -               .device = 49,
> -               .variants = ZYNQMP_VARIANT_DR,
> -       },
> -       {
> -               .id = 0x046d0093,
> -               .device = 67,
> -               .variants = ZYNQMP_VARIANT_DR,
> -       },
> -};
> -
> -static const struct {
> -       u32 id;
> -       char *name;
> -} zynqmp_svd_devices[] = {
> -       {
> -               .id = 0x04714093,
> -               .name = "xck24"
> -       },
> -       {
> -               .id = 0x04724093,
> -               .name = "xck26",
> -       },
> -};
> -
> -static char *zynqmp_detect_svd_name(u32 idcode)
> -{
> -       u32 i;
> -
> -       for (i = 0; i < ARRAY_SIZE(zynqmp_svd_devices); i++) {
> -               if (zynqmp_svd_devices[i].id == (idcode & 0x0FFFFFFF))
> -                       return zynqmp_svd_devices[i].name;
> -       }
> -
> -       return "unknown";
> -}
> -
> -static char *zynqmp_get_silicon_idcode_name(void)
> -{
> -       u32 i;
> -       u32 idcode, idcode2;
> -       char name[ZYNQMP_VERSION_SIZE];
> -       u32 ret_payload[PAYLOAD_ARG_CNT];
> -       int ret;
> -
> -       ret = xilinx_pm_request(PM_GET_CHIPID, 0, 0, 0, 0, ret_payload);
> -       if (ret) {
> -               debug("%s: Getting chipid failed\n", __func__);
> -               return "unknown";
> -       }
> -
> -       /*
> -        * Firmware returns:
> -        * payload[0][31:0]  = status of the operation
> -        * payload[1]] = IDCODE
> -        * payload[2][19:0]  = Version
> -        * payload[2][28:20] = EXTENDED_IDCODE
> -        * payload[2][29] = PL_INIT
> -        */
> -
> -       idcode  = ret_payload[1];
> -       idcode2 = ret_payload[2] >> ZYNQMP_CSU_VERSION_EMPTY_SHIFT;
> -       debug("%s, IDCODE: 0x%0x, IDCODE2: 0x%0x\r\n", __func__, idcode,
> -             idcode2);
> -
> -       for (i = 0; i < ARRAY_SIZE(zynqmp_devices); i++) {
> -               if (zynqmp_devices[i].id == (idcode & 0x0FFFFFFF))
> -                       break;
> -       }
> -
> -       if (i >= ARRAY_SIZE(zynqmp_devices))
> -               return zynqmp_detect_svd_name(idcode);
> -
> -       /* Add device prefix to the name */
> -       ret = snprintf(name, ZYNQMP_VERSION_SIZE, "zu%d",
> -                      zynqmp_devices[i].device);
> -       if (ret < 0)
> -               return "unknown";
> -
> -       if (zynqmp_devices[i].variants & ZYNQMP_VARIANT_EV) {
> -               /* Devices with EV variant might be EG/CG/EV family */
> -               if (idcode2 & IDCODE2_PL_INIT_MASK) {
> -                       u32 family = ((idcode2 & EFUSE_VCU_DIS_MASK) >>
> -                                     EFUSE_VCU_DIS_SHIFT) << 1 |
> -                                    ((idcode2 & EFUSE_GPU_DIS_MASK) >>
> -                                     EFUSE_GPU_DIS_SHIFT);
> -
> -                       /*
> -                        * Get family name based on extended idcode values as
> -                        * determined on UG1087, EXTENDED_IDCODE register
> -                        * description
> -                        */
> -                       switch (family) {
> -                       case 0x00:
> -                               strncat(name, "ev", 2);
> -                               break;
> -                       case 0x10:
> -                               strncat(name, "eg", 2);
> -                               break;
> -                       case 0x11:
> -                               strncat(name, "cg", 2);
> -                               break;
> -                       default:
> -                               /* Do not append family name*/
> -                               break;
> -                       }
> -               } else {
> -                       /*
> -                        * When PL powered down the VCU Disable efuse cannot be
> -                        * read. So, ignore the bit and just findout if it is CG
> -                        * or EG/EV variant.
> -                        */
> -                       strncat(name, (idcode2 & EFUSE_GPU_DIS_MASK) ? "cg" :
> -                               "e", 2);
> -               }
> -       } else if (zynqmp_devices[i].variants & ZYNQMP_VARIANT_CG) {
> -               /* Devices with CG variant might be EG or CG family */
> -               strncat(name, (idcode2 & EFUSE_GPU_DIS_MASK) ? "cg" : "eg", 2);
> -       } else if (zynqmp_devices[i].variants & ZYNQMP_VARIANT_EG) {
> -               strncat(name, "eg", 2);
> -       } else if (zynqmp_devices[i].variants & ZYNQMP_VARIANT_DR) {
> -               strncat(name, "dr", 2);
> -       } else {
> -               debug("Variant not identified\n");
> -       }
> -
> -       return strdup(name);
> -}
>   #endif
> 
>   int __maybe_unused psu_uboot_init(void)
> @@ -406,6 +139,11 @@ static void print_secure_boot(void)
> 
>   int board_init(void)
>   {
> +#if CONFIG_IS_ENABLED(FPGA) && defined(CONFIG_FPGA_ZYNQMPPL)
> +       struct udevice *soc;
> +       char name[SOC_MAX_STR_SIZE];
> +       int ret;
> +#endif
>   #if defined(CONFIG_ZYNQMP_FIRMWARE)
>          struct udevice *dev;
> 
> @@ -432,10 +170,15 @@ int board_init(void)
>          printf("EL Level:\tEL%d\n", current_el());
> 
>   #if CONFIG_IS_ENABLED(FPGA) && defined(CONFIG_FPGA_ZYNQMPPL)
> -       zynqmppl.name = zynqmp_get_silicon_idcode_name();
> -       printf("Chip ID:\t%s\n", zynqmppl.name);
> -       fpga_init();
> -       fpga_add(fpga_xilinx, &zynqmppl);
> +       ret = soc_get(&soc);
> +       if (!ret) {
> +               ret = soc_get_machine(soc, name, sizeof(name));
> +               if (ret >= 0) {
> +                       zynqmppl.name = strdup(name);
> +                       fpga_init();
> +                       fpga_add(fpga_xilinx, &zynqmppl);
> +               }
> +       }
>   #endif
> 
>          /* display secure boot information */
> --
> 2.30.2
> 

As I said please merge it with 3/10.

M


  reply	other threads:[~2022-06-17 10:41 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-08 16:20 [PATCH 00/10] xilinx: zynqmp: Support foreign vendor boards Stefan Herbrechtsmeier
2022-06-08 16:20 ` [PATCH 01/10] firmware: firmware-zynqmp: Check if rx channel dev pointer is valid Stefan Herbrechtsmeier
2022-06-08 16:20 ` [PATCH 02/10] firmware: firmware-zynqmp: Probe driver before use Stefan Herbrechtsmeier
2022-06-16 14:22   ` Michal Simek
2022-06-20  6:40     ` Stefan Herbrechtsmeier
2022-06-20  6:51       ` Michal Simek
2022-06-20  9:33         ` Stefan Herbrechtsmeier
2022-06-08 16:20 ` [PATCH 03/10] soc: xilinx: zynqmp: Add machine identification support Stefan Herbrechtsmeier
2022-06-17 10:41   ` Michal Simek
2022-06-20  9:16     ` Stefan Herbrechtsmeier
2022-06-08 16:20 ` [PATCH 04/10] xilinx: zynqmp: Use soc machine function to get silicon idcode name Stefan Herbrechtsmeier
2022-06-17 10:41   ` Michal Simek [this message]
2022-06-08 16:20 ` [PATCH 05/10] xilinx: cpuinfo: Print soc machine Stefan Herbrechtsmeier
2022-06-08 16:20 ` [PATCH 06/10] xilinx: common: Separate display cpu info function Stefan Herbrechtsmeier
2022-06-08 16:20 ` [PATCH 07/10] xilinx: zynqmp: make spi flash support optional Stefan Herbrechtsmeier
2022-06-08 16:20 ` [PATCH 08/10] tools: zynqmp_psu_init_minimize: Remove low level uart settings Stefan Herbrechtsmeier
2022-06-08 16:20 ` [PATCH 09/10] tools: zynqmp_psu_init_minimize: Add serdes_illcalib forward declaration Stefan Herbrechtsmeier
2022-06-16 15:13   ` Michal Simek
2022-06-20  7:07     ` Stefan Herbrechtsmeier
2022-06-20  7:18       ` Michal Simek
2022-06-20 13:38         ` Stefan Herbrechtsmeier
2022-06-20 13:53           ` Michal Simek
2022-06-08 16:20 ` [PATCH 10/10] xilinx: zynqmp: Support vendor specific board_init Stefan Herbrechtsmeier
2022-06-16 15:12   ` Michal Simek
2022-06-20  6:48     ` Stefan Herbrechtsmeier
2022-06-20  6:53       ` Michal Simek
2022-06-20  9:36         ` Stefan Herbrechtsmeier
2022-06-17 11:06 ` [PATCH 00/10] xilinx: zynqmp: Support foreign vendor boards Michal Simek

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5e17a9d5-6e67-d7d9-6ba9-a0eddb03e110@amd.com \
    --to=michal.simek@amd.com \
    --cc=stefan.herbrechtsmeier-oss@weidmueller.com \
    --cc=stefan.herbrechtsmeier@weidmueller.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.