[Skiboot] [PATCH 3/5] opal: Get chip part-number and serial-number.

Oliver O'Halloran oohall at gmail.com
Wed Jul 29 17:16:25 AEST 2020


On Wed, Jul 29, 2020 at 1:01 PM Mahesh Salgaonkar <mahesh at linux.ibm.com> wrote:
>
> From: Mahesh Salgaonkar <mahesh at linux.vnet.ibm.com>
>
> Get chip part-number and serial-number and store it under proc_chip for
> quick reference while sending error log that needs proc chip FRU details.
>
> Signed-off-by: Mahesh Salgaonkar <mahesh at linux.vnet.ibm.com>
> ---
>  core/chip.c    |   13 +++++++++++++
>  include/chip.h |   28 ++++++++++++++++++++++++++++
>  2 files changed, 41 insertions(+)
>
> diff --git a/core/chip.c b/core/chip.c
> index 191432d29..8e97a7bcd 100644
> --- a/core/chip.c
> +++ b/core/chip.c
> @@ -63,6 +63,8 @@ static void init_chip(struct dt_node *dn)
>         struct proc_chip *chip;
>         uint32_t id;
>         const char *lc = NULL;
> +       const char *part_no = NULL;
> +       const char *serial_no = NULL;
>
>         id = dt_get_chip_id(dn);
>         assert(id < MAX_CHIPS);

> @@ -93,6 +95,17 @@ static void init_chip(struct dt_node *dn)
>         if (lc)
>                 chip->loc_code = strdup(lc);
>
> +       /* Update part number and serial number for this chip */
> +       if (dt_has_node_property(dn, "part-number", NULL))
> +               part_no = dt_prop_get(dn, "part-number");
> +       if (part_no)
> +               chip->part_no = strdup(part_no);
> +
> +       if (dt_has_node_property(dn, "serial-number", NULL))
> +               serial_no = dt_prop_get(dn, "serial-number");
> +       if (serial_no)
> +               chip->serial_no = strdup(serial_no);

Use dt_prop_get_def()

> +
>         prlog(PR_INFO, "CHIP: Initialised chip %d from %s\n", id, dn->name);
>         chips[id] = chip;
>  }
> diff --git a/include/chip.h b/include/chip.h
> index b79b63ecf..e63f17a18 100644
> --- a/include/chip.h
> +++ b/include/chip.h
> @@ -187,6 +187,10 @@ struct proc_chip {
>         /* location code of this chip */
>         const uint8_t           *loc_code;
>
> +       /* part-number and serial number for this chip */
> +       const uint8_t           *part_no;
> +       const uint8_t           *serial_no;
> +
>         /* Used by hw/sbe-p9.c */
>         struct p9_sbe           *sbe;
>
> @@ -233,5 +237,29 @@ static inline const char *chip_loc_code(uint32_t chip_id)
>         return chip->loc_code;
>  }
>
> +/* helper to get part number of a chip */
> +static inline const char *chip_part_number(uint32_t chip_id)
> +{
> +       struct proc_chip *chip;
> +
> +       chip = get_chip(chip_id);
> +       if (!chip)
> +               return NULL;
> +
> +       return chip->part_no;
> +}
> +
> +/* helper to get serial number of a chip */
> +static inline const char *chip_serial_number(uint32_t chip_id)
> +{
> +       struct proc_chip *chip;
> +
> +       chip = get_chip(chip_id);
> +       if (!chip)
> +               return NULL;
> +
> +       return chip->serial_no;
> +}
> +
>  #endif /* __CHIP_H */
>
>
>


More information about the Skiboot mailing list