LCOV - code coverage report
Current view: top level - hdata - spira.h (source / functions) Hit Total Coverage
Test: skiboot.info Lines: 4 11 36.4 %
Date: 2024-01-02 21:04:04 Functions: 1 1 100.0 %
Branches: 0 0 -

           Branch data     Line data    Source code
       1                 :            : // SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
       2                 :            : /* Copyright 2013-2019 IBM Corp. */
       3                 :            : 
       4                 :            : #ifndef __SPIRA_H
       5                 :            : #define __SPIRA_H
       6                 :            : 
       7                 :            : #include "hdif.h"
       8                 :            : 
       9                 :            : /*
      10                 :            :  * The SPIRA-H and SPIRA-S structures
      11                 :            :  *
      12                 :            :  * SPIRA-H is built in the primary hypervisor (skiboot) lid, pointed to by
      13                 :            :  * the NACA and provides details to the boot firmware.
      14                 :            :  *
      15                 :            :  * SPIRA-S is built at IPL time by the boot firmware at the host data area
      16                 :            :  * location specified in SPIRA-H, and thus must be parsed.
      17                 :            :  */
      18                 :            : 
      19                 :            : struct spira_ntuple {
      20                 :            :         __be64          addr;
      21                 :            :         __be16          alloc_cnt;
      22                 :            :         __be16          act_cnt;
      23                 :            :         __be32          alloc_len;
      24                 :            :         __be32          act_len;
      25                 :            :         __be32          tce_off;
      26                 :            :         __be64          padding;
      27                 :            : } __packed;
      28                 :            : 
      29                 :            : /* SPIRA-H signature */
      30                 :            : #define SPIRAH_HDIF_SIG         "SPIRAH"
      31                 :            : 
      32                 :            : /* First version of the secure boot compliant design. */
      33                 :            : #define SPIRAH_VERSION          0x50
      34                 :            : 
      35                 :            : /* N-tuples in SPIRAH */
      36                 :            : #define SPIRAH_NTUPLES_COUNT    0x6
      37                 :            : 
      38                 :            : struct spirah_ntuples {
      39                 :            :         struct HDIF_array_hdr   array_hdr;      /* 0x030 */
      40                 :            :         struct spira_ntuple     hs_data_area;   /* 0x040 */
      41                 :            :         struct spira_ntuple     proc_init;      /* 0x060 */
      42                 :            :         struct spira_ntuple     cpu_ctrl;       /* 0x080 */
      43                 :            :         struct spira_ntuple     mdump_src;      /* 0x0a0 */
      44                 :            :         struct spira_ntuple     mdump_dst;      /* 0x0c0 */
      45                 :            :         struct spira_ntuple     mdump_res;      /* 0x0e0 */
      46                 :            :         struct spira_ntuple     proc_dump_area; /* 0x100 */
      47                 :            : };
      48                 :            : 
      49                 :            : struct spirah {
      50                 :            :         struct HDIF_common_hdr  hdr;
      51                 :            :         struct HDIF_idata_ptr   ntuples_ptr;
      52                 :            :         __be64                  pad;
      53                 :            :         struct spirah_ntuples   ntuples;
      54                 :            :         u8                      reserved[0xE0];
      55                 :            : } __packed __align(0x100);
      56                 :            : 
      57                 :            : extern struct spirah spirah;
      58                 :            : 
      59                 :            : /* SPIRA-S signature */
      60                 :            : #define SPIRAS_HDIF_SIG         "SPIRAS"
      61                 :            : 
      62                 :            : /* First version on 810 release */
      63                 :            : #define SPIRAS_VERSION_P8       0x40
      64                 :            : #define SPIRAS_VERSION_P9       0x50
      65                 :            : 
      66                 :            : /* N-tuples in SPIRAS */
      67                 :            : #define SPIRAS_NTUPLES_COUNT    0x10
      68                 :            : 
      69                 :            : struct spiras_ntuples {
      70                 :            :         struct HDIF_array_hdr   array_hdr;              /* 0x030 */
      71                 :            :         struct spira_ntuple     sp_subsys;              /* 0x040 */
      72                 :            :         struct spira_ntuple     ipl_parms;              /* 0x060 */
      73                 :            :         struct spira_ntuple     nt_enclosure_vpd;       /* 0x080 */
      74                 :            :         struct spira_ntuple     slca;                   /* 0x0a0 */
      75                 :            :         struct spira_ntuple     backplane_vpd;          /* 0x0c0 */
      76                 :            :         struct spira_ntuple     system_vpd;             /* 0x0e0 */
      77                 :            :         struct spira_ntuple     clock_vpd;              /* 0x100 */
      78                 :            :         struct spira_ntuple     anchor_vpd;             /* 0x120 */
      79                 :            :         struct spira_ntuple     op_panel_vpd;           /* 0x140 */
      80                 :            :         struct spira_ntuple     misc_cec_fru_vpd;       /* 0x160 */
      81                 :            :         struct spira_ntuple     ms_vpd;                 /* 0x180 */
      82                 :            :         struct spira_ntuple     cec_iohub_fru;          /* 0x1a0 */
      83                 :            :         struct spira_ntuple     pcia;                   /* 0x1c0 */
      84                 :            :         struct spira_ntuple     proc_chip;              /* 0x1e0 */
      85                 :            :         struct spira_ntuple     hs_data;                /* 0x200 */
      86                 :            :         struct spira_ntuple     hbrt_data;              /* 0x220 */
      87                 :            :         struct spira_ntuple     ipmi_sensor;            /* 0x240 */
      88                 :            :         struct spira_ntuple     node_stb_data;          /* 0x260 */
      89                 :            : };
      90                 :            : 
      91                 :            : struct spiras {
      92                 :            :         struct HDIF_common_hdr  hdr;
      93                 :            :         struct HDIF_idata_ptr   ntuples_ptr;
      94                 :            :         __be64                  pad;
      95                 :            :         struct spiras_ntuples   ntuples;
      96                 :            :         u8                      reserved[0x180];
      97                 :            : } __packed __align(0x100);
      98                 :            : 
      99                 :            : extern struct spiras *skiboot_constant_addr spiras;
     100                 :            : 
     101                 :            : /* This macro can be used to check the validity of a pointer returned
     102                 :            :  * by one of the HDIF API functions. It returns true if the pointer
     103                 :            :  * appears valid. If it's not valid and not NULL, it will print some
     104                 :            :  * error in the log as well.
     105                 :            :  */
     106                 :            : #define CHECK_SPPTR(_ptr)       spira_check_ptr(_ptr, __FILE__, __LINE__)
     107                 :            : 
     108                 :            : #define get_hdif(ntuple, id) __get_hdif((ntuple), (id), __FILE__, __LINE__)
     109                 :            : 
     110                 :            : extern struct HDIF_common_hdr *__get_hdif(struct spira_ntuple *n,
     111                 :            :                                           const char id[],
     112                 :            :                                           const char *file, int line);
     113                 :            : 
     114                 :            : #define for_each_ntuple_idx(_ntuples, _p, _idx, _id)                    \
     115                 :            :         for (_p = get_hdif((_ntuples), _id ""), _idx = 0;             \
     116                 :            :              _p && _idx < be16_to_cpu((_ntuples)->act_cnt);               \
     117                 :            :              _p = (void *)_p + be32_to_cpu((_ntuples)->alloc_len), _idx++)
     118                 :            : 
     119                 :            : #define for_each_ntuple(_ntuples, _p, _id)                              \
     120                 :            :         for (_p = get_hdif((_ntuples), _id "");                               \
     121                 :            :              _p && (void *)_p < ntuple_addr(_ntuples)                        \
     122                 :            :                      + (be16_to_cpu((_ntuples)->act_cnt) *           \
     123                 :            :                         be32_to_cpu((_ntuples)->alloc_len));         \
     124                 :            :              _p = (void *)_p + be32_to_cpu((_ntuples)->alloc_len))
     125                 :            : 
     126                 :            : #define for_each_pcia(s, p) for_each_ntuple(&(s)->ntuples.pcia, p, SPPCIA_HDIF_SIG)
     127                 :            : 
     128                 :            : /* We override these for testing. */
     129                 :            : #ifndef ntuple_addr
     130                 :            : #define ntuple_addr(_ntuples) ((void *)BE64_TO_CPU((_ntuples)->addr))
     131                 :            : #endif
     132                 :            : 
     133                 :            : #ifndef spira_check_ptr
     134                 :            : extern bool spira_check_ptr(const void *ptr, const char *file,
     135                 :            :                             unsigned int line);
     136                 :            : #endif
     137                 :            : 
     138                 :            : struct proc_init_data {
     139                 :            :         struct HDIF_common_hdr  hdr;
     140                 :            :         struct HDIF_idata_ptr   regs_ptr;
     141                 :            :         struct {
     142                 :            :                 __be64  nia;
     143                 :            :                 __be64  msr;
     144                 :            :                 __be64  nia_charm_time;
     145                 :            :                 __be64  msr_charm_time;
     146                 :            :         } regs;
     147                 :            : } __packed __align(0x10);
     148                 :            : 
     149                 :            : /*
     150                 :            :  * The FRU ID structure is used in several tuples, so we
     151                 :            :  * define it generically here
     152                 :            :  */
     153                 :            : struct spira_fru_id {
     154                 :            :         __be16          slca_index;
     155                 :            :         __be16          rsrc_id;        /* formerly VPD port number */
     156                 :            : } __packed;
     157                 :            : 
     158                 :            : /*
     159                 :            :  * The FRU operational status structure is used in several
     160                 :            :  * tuples, so we define it generically here
     161                 :            :  */
     162                 :            : struct spira_fru_op_status {
     163                 :            :         uint8_t flags;
     164                 :            : #define FRU_OP_STATUS_FLAG_USED         0x02 /* If 0 -> not used (redundant) */
     165                 :            : #define FRU_OP_STATUS_FLAG_FUNCTIONAL   0x01 /* If 0 -> non-functional */
     166                 :            :         uint8_t reserved[3];
     167                 :            : } __packed;
     168                 :            : 
     169                 :            : /*
     170                 :            :  * Move VPD related stuff to another file ...
     171                 :            :  */
     172                 :            : #define VPD_ID(_a, _b)  ((_a) << 8 | (_b))
     173                 :            : 
     174                 :            : /*
     175                 :            :  * Service Processor Subsystem Structure
     176                 :            :  *
     177                 :            :  * This structure contains several internal data blocks
     178                 :            :  * describing the service processor(s) in the system
     179                 :            :  */
     180                 :            : 
     181                 :            : #define SPSS_HDIF_SIG   "SPINFO"
     182                 :            : 
     183                 :            : /* Idata index 0 : FRU ID Data */
     184                 :            : #define SPSS_IDATA_FRU_ID       0
     185                 :            : 
     186                 :            : /* Idata index 1 : Keyword VPD for the FSP instance */
     187                 :            : #define SPSS_IDATA_KEYWORD_VPD  1
     188                 :            : 
     189                 :            : /* Idata index 2 : SP Implementation */
     190                 :            : #define SPSS_IDATA_SP_IMPL      2
     191                 :            : 
     192                 :            : struct spss_sp_impl {
     193                 :            :         __be16  hw_version;
     194                 :            :         __be16  sw_version;
     195                 :            :         __be16  func_flags;
     196                 :            : #define SPSS_SP_IMPL_FLAGS_INSTALLED    0x8000
     197                 :            : #define SPSS_SP_IMPL_FLAGS_FUNCTIONAL   0x4000
     198                 :            : #define SPSS_SP_IMPL_FLAGS_PRIMARY      0x2000
     199                 :            :         u8      chip_version;
     200                 :            :         u8      reserved;
     201                 :            :         u8      sp_family[64];
     202                 :            : } __packed;
     203                 :            : 
     204                 :            : /* Idata index 3 is deprecated */
     205                 :            : 
     206                 :            : /* Idata index 4 : SP Memory Locator */
     207                 :            : #define SPSS_IDATA_SP_MEMLOC    4
     208                 :            : 
     209                 :            : /* Idata index 5 : SP I/O path array */
     210                 :            : #define SPSS_IDATA_SP_IOPATH    5
     211                 :            : 
     212                 :            : /* An HDIF array of IO path */
     213                 :            : struct spss_iopath {
     214                 :            :         __be16  iopath_type;
     215                 :            : #define SPSS_IOPATH_TYPE_IOHUB_PHB      0x0001
     216                 :            : #define SPSS_IOPATH_TYPE_PSI            0x0002
     217                 :            : #define SPSS_IOPATH_TYPE_LPC            0x0003
     218                 :            :         union {
     219                 :            :                 struct {
     220                 :            :                         __be16  iohub_chip_inst;
     221                 :            :                         __be16  iohub_chip_port;
     222                 :            :                         __be16  phb_id;
     223                 :            :                 } __packed iohub_phb;
     224                 :            : 
     225                 :            :                 struct {
     226                 :            :                         __be16  link_status;
     227                 :            : #define SPSS_IO_PATH_PSI_LINK_BAD_FRU   0x0000
     228                 :            : #define SPSS_IO_PATH_PSI_LINK_CURRENT   0x0001
     229                 :            : #define SPSS_IO_PATH_PSI_LINK_BACKUP    0x0002
     230                 :            :                         u8      ml2_version;
     231                 :            :                         u8      reserved;
     232                 :            :                         __be16  slca_count;
     233                 :            :                         u8      slca_idx[16];
     234                 :            :                         __be32  proc_chip_id;
     235                 :            :                         __be32  reserved2;
     236                 :            :                         __be64  gxhb_base;
     237                 :            :                 } __packed psi;
     238                 :            : 
     239                 :            :                 struct { /* only populated after version 0x30 */
     240                 :            :                         __be16  link_status;
     241                 :            : #define LPC_STATUS_STUFFED 0x0000
     242                 :            : #define LPC_STATUS_ACTIVE  0x0001
     243                 :            :                         uint8_t ml2_version;
     244                 :            :                         uint8_t reserved[3];
     245                 :            :                         __be32  chip_id;
     246                 :            : 
     247                 :            :                         __be32  io_bar;
     248                 :            :                         __be32  memory_bar;
     249                 :            :                         __be32  firmware_bar;
     250                 :            :                         __be32  internal_bar;
     251                 :            : 
     252                 :            :                         __be32  mctp_base;
     253                 :            : 
     254                 :            :                         __be64  uart_base;
     255                 :            :                         __be32  uart_size;
     256                 :            :                         __be32  uart_clk;  /* UART baud clock in Hz */
     257                 :            :                         __be32  uart_baud; /* UART baud rate */
     258                 :            : 
     259                 :            :                         uint8_t uart_int_number;
     260                 :            :                         uint8_t uart_int_type;
     261                 :            : #define                 UART_INT_LVL_LOW        0x1
     262                 :            : #define                 UART_INT_RISING         0x2
     263                 :            : #define                 UART_INT_LVL_HIGH       0x3
     264                 :            :                         uint8_t uart_valid;
     265                 :            :                         uint8_t reserved3;
     266                 :            : 
     267                 :            :                         __be64  bt_base;
     268                 :            :                         __be32  bt_size;
     269                 :            :                         uint8_t bt_sms_int_num;
     270                 :            :                         uint8_t bt_bmc_response_int_num;
     271                 :            :                         uint8_t reserved4[2];
     272                 :            : 
     273                 :            :                         __be16  kcs_data_reg_addr;
     274                 :            :                         __be16  kcs_status_reg_addr;
     275                 :            :                         uint8_t kcs_int_number;
     276                 :            : 
     277                 :            :                         __be64  uart2_base;
     278                 :            :                         __be32  uart2_size;
     279                 :            :                         __be32  uart2_clk;  /* UART baud clock in Hz */
     280                 :            :                         __be32  uart2_baud; /* UART baud rate */
     281                 :            :                         uint8_t uart2_int_number;
     282                 :            :                         uint8_t uart2_int_type;
     283                 :            :                         uint8_t uart2_valid;
     284                 :            :                         uint8_t reserved5;
     285                 :            :                 } __packed lpc;
     286                 :            :         };
     287                 :            : } __packed;
     288                 :            : 
     289                 :            : /*
     290                 :            :  * IPL Parms structure
     291                 :            :  *
     292                 :            :  */
     293                 :            : 
     294                 :            : /* Idata index 0: System Parameters */
     295                 :            : #define IPLPARAMS_SYSPARAMS     0
     296                 :            : 
     297                 :            : struct iplparams_sysparams {
     298                 :            :         char            sys_model[4];
     299                 :            :         char            cpu_feature_code[4];
     300                 :            :         __be32          effective_pvr;
     301                 :            :         __be32          system_type;
     302                 :            :         uint8_t         num_lpar_oct[8];
     303                 :            :         __be32          abc_bus_speed;
     304                 :            :         __be32          wxyz_bus_speed;
     305                 :            :         __be32          sys_eco_mode;
     306                 :            : #define SYS_ATTR_MULTIPLE_TPM PPC_BIT32(0)
     307                 :            : #define SYS_ATTR_RISK_LEVEL PPC_BIT32(3)
     308                 :            : #define SYS_ATTR_MPIPL_SUPPORTED PPC_BIT32(5)
     309                 :            :         __be32          sys_attributes;
     310                 :            :         __be32          mem_scrubbing;
     311                 :            :         __be16          cur_spl_value;
     312                 :            :         uint8_t         pump_mode;              /* Reserved */
     313                 :            :         uint8_t         use_pore_sleep;
     314                 :            :         __be32          pore_image_size;        /* Reserved */
     315                 :            :         uint8_t         vtpm_enabled;
     316                 :            :         uint8_t         hw_page_table_size;     /* >= 0x59 */
     317                 :            :         __be16          hv_disp_wheel;          /* >= 0x58 */
     318                 :            :         __be32          nest_freq_mhz;          /* >= 0x5b */
     319                 :            :         uint8_t         split_core_mode;        /* >= 0x5c */
     320                 :            :         uint8_t         reserved[1];
     321                 :            : #define KEY_CLEAR_ALL     PPC_BIT16(0)
     322                 :            : #define KEY_CLEAR_OS_KEYS PPC_BIT16(1)
     323                 :            : #define KEY_CLEAR_MFG     PPC_BIT16(7)
     324                 :            :         __be16          host_fw_key_clear;
     325                 :            :         uint8_t         sys_vendor[64];         /* >= 0x5f */
     326                 :            : #define SEC_CONTAINER_SIG_CHECKING PPC_BIT16(0)
     327                 :            : #define SEC_HASHES_EXTENDED_TO_TPM PPC_BIT16(1)
     328                 :            : #define PHYSICAL_PRESENCE_ASSERTED PPC_BIT16(3)
     329                 :            :         __be16          sys_sec_setting;        /* >= 0x60 */
     330                 :            :         __be16          tpm_config_bit;         /* >= 0x60 */
     331                 :            :         __be16          tpm_drawer;             /* >= 0x60 */
     332                 :            :         __be16          hw_key_hash_size;       /* >= 0x60 */
     333                 :            : #define SYSPARAMS_HW_KEY_HASH_MAX   64
     334                 :            :         uint8_t         hw_key_hash[SYSPARAMS_HW_KEY_HASH_MAX];  /* >= 0x60 */
     335                 :            :         uint8_t         sys_family_str[64];     /* vendor,name */
     336                 :            :         uint8_t         sys_type_str[64];       /* vendor,type */
     337                 :            : } __packed;
     338                 :            : 
     339                 :            : /* Idata index 1: IPL parameters */
     340                 :            : #define IPLPARAMS_IPLPARAMS     1
     341                 :            : 
     342                 :            : struct iplparams_iplparams {
     343                 :            :         uint8_t         reserved;
     344                 :            :         uint8_t         hv_ipl_dest;
     345                 :            :         uint8_t         ipl_side;
     346                 :            : #define IPLPARAMS_CEC_FW_IPL_SIDE_TEMP  0x10
     347                 :            : #define IPLPARAMS_FSP_FW_IPL_SIDE_TEMP  0x01
     348                 :            :         uint8_t         ipl_speed;
     349                 :            :         __be16          cec_ipl_attrib;
     350                 :            : #define IPLPARAMS_ATTRIB_MEM_PRESERVE   PPC_BIT16(2)
     351                 :            :         uint8_t         cec_ipl_maj_type;
     352                 :            : #define IPLPARAMS_MAJ_TYPE_REIPL        0x1
     353                 :            :         uint8_t         cec_ipl_min_type;
     354                 :            : #define IPLPARAMS_MIN_TYPE_POST_DUMP    0xc
     355                 :            : #define IPLPARAMS_MIN_TYPE_PLAT_REBOOT  0xd
     356                 :            :         uint8_t         os_ipl_mode;
     357                 :            :         uint8_t         keylock_pos;
     358                 :            :         uint8_t         lmb_size;
     359                 :            :         uint8_t         deprecated;
     360                 :            :         __be32          max_hsl_opticonnect;
     361                 :            :         __be32          other_attrib;
     362                 :            : #define IPLPARAMS_OATTR_RST_PCI_BUSNO   0x08000000
     363                 :            : #define IPLPARAMS_OATTR_CLEAR_NVRAM     0x04000000
     364                 :            : #define IPLPARAMS_OATRR_LIGHT_PATH      0x00000004
     365                 :            :         __be16          huge_page_count;
     366                 :            :         uint8_t         huge_page_size;
     367                 :            : #define IPLPARAMS_HUGE_PG_SIZE_16G      0
     368                 :            :         uint8_t         num_vlan_switches;
     369                 :            :         __be32          reserved2;
     370                 :            :         __be32          enlarge_io;     /* >= 0x5a */
     371                 :            :         uint8_t         core_config;
     372                 :            : #define IPLPARAMS_CORE_NORMAL   0x00
     373                 :            : #define IPLPARAMS_CORE_FUSE     0x01
     374                 :            : } __packed;
     375                 :            : 
     376                 :            : /* Idata index 4: Platform Dump Descriptor */
     377                 :            : #define IPLPARAMS_PLATFORM_DUMP         4
     378                 :            : 
     379                 :            : struct iplparams_dump {
     380                 :            :         __be16  flags;
     381                 :            :         uint8_t reserved1;
     382                 :            :         uint8_t policy;
     383                 :            : #define HYP_DUMP_POLICY_NORMAL  0x00
     384                 :            :         __be32  dump_id;
     385                 :            :         __be64  reserved2;
     386                 :            :         __be64  act_dump_sz;
     387                 :            :         __be32  max_hw_dump_sz;
     388                 :            :         __be32  act_hw_dump_sz;
     389                 :            :         __be32  max_sp_dump_sz;
     390                 :            :         __be32  plid;
     391                 :            : } __packed;
     392                 :            : 
     393                 :            : /* Idata index 8: serial ports */
     394                 :            : #define IPLPARMS_IDATA_SERIAL   8
     395                 :            : 
     396                 :            : /* An HDIF array of serial descriptions */
     397                 :            : struct iplparms_serial {
     398                 :            :         uint8_t         loc_code[LOC_CODE_SIZE];
     399                 :            :         __be16          rsrc_id;
     400                 :            :         __be16          flags;
     401                 :            : #define PLPARMS_SERIAL_FLAGS_CALLHOME   0x8000
     402                 :            : } __packed;
     403                 :            : 
     404                 :            : /* Idata index 9: FW features */
     405                 :            : #define IPLPARAMS_FEATURES      9
     406                 :            : struct iplparams_feature {
     407                 :            :         char name[64];
     408                 :            :         __be64 flags;
     409                 :            : } __packed;
     410                 :            : 
     411                 :            : /*
     412                 :            :  * Chip TOD structure
     413                 :            :  *
     414                 :            :  * This is an array of 32 entries (I assume per possible chip)
     415                 :            :  */
     416                 :            : 
     417                 :            : /* Idata index 0: Chip ID data (array) */
     418                 :            : #define CHIPTOD_IDATA_CHIPID    0
     419                 :            : 
     420                 :            : struct chiptod_chipid {
     421                 :            :         __be32          chip_id;
     422                 :            :         __be32          flags;
     423                 :            : #define CHIPTOD_ID_FLAGS_PRIMARY        0x02
     424                 :            : #define CHIPTOD_ID_FLAGS_SECONDARY      0x01
     425                 :            : #define CHIPTOD_ID_FLAGS_STATUS_MASK    0x0c
     426                 :            : #define CHIPTOD_ID_FLAGS_STATUS_OK      0x04
     427                 :            : #define CHIPTOD_ID_FLAGS_STATUS_NOK     0x08
     428                 :            : } __packed;
     429                 :            : 
     430                 :            : /* Idata index 0: Chip Initialization data */
     431                 :            : #define CHIPTOD_IDATA_CHIPINIT  1
     432                 :            : 
     433                 :            : struct chiptod_chipinit {
     434                 :            :         __be32          ctrl_reg_internal;
     435                 :            :         __be32          tod_ctrl_reg;
     436                 :            : } __packed;
     437                 :            : 
     438                 :            : /*
     439                 :            :  * MS VPD - Memory Description Tree
     440                 :            :  *
     441                 :            :  * One such structure pointing to the various memory arrays
     442                 :            :  * along with other infos about the BCRs, Page Mover, XSCOM,...
     443                 :            :  */
     444                 :            : #define MSVPD_HDIF_SIG  "MS VPD"
     445                 :            : 
     446                 :            : /* Idata index 0: Mainstore address config */
     447                 :            : #define MSVPD_IDATA_MS_ADDR_CONFIG      0
     448                 :            : 
     449                 :            : /* Mainstore Address Configuration */
     450                 :            : struct msvpd_ms_addr_config {
     451                 :            :         __be64   max_configured_ms_address;
     452                 :            :         __be64   max_possible_ms_address;
     453                 :            :         __be32   deprecated;
     454                 :            :         __be64   mirrorable_memory_starting_address;
     455                 :            :         __be64   hrmor_stash_loc_address;
     456                 :            : } __packed;
     457                 :            : 
     458                 :            : /* Idata index 1: Total configured mainstore */
     459                 :            : #define MSVPD_IDATA_TOTAL_CONFIG_MS     1
     460                 :            : 
     461                 :            : struct msvpd_total_config_ms {
     462                 :            :         __be64   total_in_mb;
     463                 :            : } __packed;
     464                 :            : 
     465                 :            : /* Idata index 2: Page mover and sync structure */
     466                 :            : #define MSVPD_IDATA_PMOVER_SYNCHRO      2
     467                 :            : 
     468                 :            : struct msvpd_pmover_bsr_synchro {
     469                 :            :         __be32          flags;
     470                 :            : #define MSVPD_PMS_FLAG_HWLOCK_EN        0x80000000
     471                 :            : #define MSVPD_PMS_FLAG_PMOVER_EN        0x40000000
     472                 :            : #define MSVPD_PMS_FLAG_BSR_EN           0x20000000
     473                 :            : #define MSVPD_PMS_FLAG_XSCOMBASE_VALID  0x10000000
     474                 :            :         __be32          hwlocks_per_page;
     475                 :            :         __be64          hwlock_addr;
     476                 :            :         __be64          pmover_addr;
     477                 :            :         __be64          bsr_addr;
     478                 :            :         __be64          xscom_addr;
     479                 :            : } __packed;
     480                 :            : 
     481                 :            : /* Idata index 3: Memory Trace Array */
     482                 :            : #define MSVPD_IDATA_TRACE_AREAS         3
     483                 :            : struct msvpd_trace {
     484                 :            :         __be64 start, end;
     485                 :            :         char reserved[16];
     486                 :            : };
     487                 :            : 
     488                 :            : /* Idata index 4: UE Address Array */
     489                 :            : 
     490                 :            : /* Idata index 5: Hostboot reserved memory address range */
     491                 :            : #define MSVPD_IDATA_HB_RESERVED_MEM     5
     492                 :            : #define HB_RESERVE_MEM_LABEL_SIZE       64
     493                 :            : struct msvpd_hb_reserved_mem {
     494                 :            : #define MSVPD_HBRMEM_RANGE_TYPE PPC_BITMASK32(0,7)
     495                 :            : #define HBRMEM_CONTAINER_VERIFICATION_CODE      0x3
     496                 :            :         __be32          type_instance;
     497                 :            :         __be64          start_addr;
     498                 :            :         __be64          end_addr;
     499                 :            :         __be32          label_size;
     500                 :            :         uint8_t         label[HB_RESERVE_MEM_LABEL_SIZE];
     501                 :            :         uint8_t         rw_perms;
     502                 :            : #define HB_RESERVE_READABLE 0x80
     503                 :            : #define HB_RESERVE_WRITEABLE 0x40
     504                 :            :         uint8_t         reserved[7];
     505                 :            : } __packed;
     506                 :            : 
     507                 :            : /* Child index 0: MS area child structure */
     508                 :            : #define MSVPD_CHILD_MS_AREAS            0
     509                 :            : 
     510                 :            : /*
     511                 :            :  * CEC I/O Hub FRU
     512                 :            :  *
     513                 :            :  * This is an array of CEC Hub FRU HDIF structures
     514                 :            :  *
     515                 :            :  * Each of these has some idata pointers to generic info about the
     516                 :            :  * hub and a possible child pointer for daughter card.
     517                 :            :  *
     518                 :            :  * Actual ports are in the SLCA and need to be cross referenced
     519                 :            :  *
     520                 :            :  * Note that slots meant for the addition of GX+ adapters that
     521                 :            :  * are currently unpopulated but support hotplug will have a
     522                 :            :  * minimum "placeholder" entry, which will be fully populated
     523                 :            :  * when the array is rebuild during concurrent maintenance.
     524                 :            :  * This "placeholder" is called a "reservation".
     525                 :            :  *
     526                 :            :  * WARNING: The array rebuild by concurrent maintenance is not
     527                 :            :  * guaranteed to be in the same order as the IPL array, not is
     528                 :            :  * the order stable between concurrent maintenance operations.
     529                 :            :  *
     530                 :            :  * There's also a child pointer to daughter card structures but
     531                 :            :  * we aren't going to handle that just yet.
     532                 :            :  */
     533                 :            : #define CECHUB_FRU_HDIF_SIG     "IO HUB"
     534                 :            : #define IOKID_FRU_HDIF_SIG      "IO KID"
     535                 :            : #define IOSLOT_FRU_HDIF_SIG     "IOSLOT"
     536                 :            : 
     537                 :            : /* Idata index 0: FRU ID data
     538                 :            :  *
     539                 :            :  * This is a generic struct spira_fru_id defined above
     540                 :            :  */
     541                 :            : #define CECHUB_FRU_ID_DATA              0
     542                 :            : 
     543                 :            : /* Idata index 1: ASCII Keyword VPD */
     544                 :            : #define CECHUB_ASCII_KEYWORD_VPD        1
     545                 :            : 
     546                 :            : /* Idata index 2: Hub FRU ID data area */
     547                 :            : #define CECHUB_FRU_ID_DATA_AREA         2
     548                 :            : 
     549                 :            : struct cechub_hub_fru_id {
     550                 :            :         __be32          card_type;
     551                 :            : #define CECHUB_FRU_TYPE_IOHUB_RSRV      0
     552                 :            : #define CECHUB_FRU_TYPE_IOHUB_CARD      1
     553                 :            : #define CECHUB_FRU_TYPE_CPU_CARD        2
     554                 :            : #define CECHUB_FRU_TYPE_CEC_BKPLANE     3
     555                 :            : #define CECHUB_FRU_TYPE_BKPLANE_EXT     4
     556                 :            :         __be32          unused;
     557                 :            :         __be16          total_chips;
     558                 :            :         uint8_t         flags;
     559                 :            : #define CECHUB_FRU_FLAG_HEADLESS        0x80 /* not connected to CPU */
     560                 :            : #define CECHUB_FRU_FLAG_PASSTHROUGH     0x40 /* connected to passhtrough
     561                 :            :                                                 port of another hub */
     562                 :            :         uint8_t         reserved;
     563                 :            :         __be16          parent_hub_id;  /* chip instance number of the
     564                 :            :                                            hub that contains the passthrough
     565                 :            :                                            port this one is connected to */
     566                 :            :         __be16          reserved2;
     567                 :            : } __packed;
     568                 :            : 
     569                 :            : 
     570                 :            : /* Idata index 3: IO HUB array */
     571                 :            : 
     572                 :            : #define CECHUB_FRU_IO_HUBS              3
     573                 :            : 
     574                 :            : /* This is an HDIF array of IO Hub structures */
     575                 :            : struct cechub_io_hub {
     576                 :            :         __be64          fmtc_address;
     577                 :            :         __be32          fmtc_tce_size;
     578                 :            :         __be16          hub_num;        /* unique hub number (I/O Hub ID) */
     579                 :            :         uint8_t         flags;
     580                 :            : #define CECHUB_HUB_FLAG_STATE_MASK      0xc0
     581                 :            : #define CECHUB_HUB_FLAG_STATE_OK        0x00
     582                 :            : #define CECHUB_HUB_FLAG_STATE_FAILURES  0x40
     583                 :            : #define CECHUB_HUB_FLAG_STATE_NOT_INST  0x80
     584                 :            : #define CECHUB_HUB_FLAG_STATE_UNUSABLE  0xc0
     585                 :            : #define CECHUB_HUB_FLAG_MASTER_HUB      0x20 /* HDAT < v9.x only */
     586                 :            : #define CECHUB_HUB_FLAG_GARD_MASK_VALID 0x08 /* HDAT < v9.x only */
     587                 :            : #define CECHUB_HUB_FLAG_SWITCH_MASK_PDT 0x04 /* HDAT < v9.x only */
     588                 :            : #define CECHUB_HUB_FLAG_FAB_BR0_PDT     0x02 /* HDAT < v9.x only */
     589                 :            : #define CECHUB_HUB_FLAG_FAB_BR1_PDT     0x01 /* HDAT < v9.x only */
     590                 :            :         uint8_t         nr_ports;            /* HDAT < v9.x only */
     591                 :            :         uint8_t         fab_br0_pdt;    /* p5ioc2 PCI-X or P8 PHB3's */
     592                 :            : #define CECHUB_HUB_FAB_BR0_PDT_PHB0     0x80
     593                 :            : #define CECHUB_HUB_FAB_BR0_PDT_PHB1     0x40
     594                 :            : #define CECHUB_HUB_FAB_BR0_PDT_PHB2     0x20
     595                 :            : #define CECHUB_HUB_FAB_BR0_PDT_PHB3     0x10
     596                 :            : #define CECHUB_HUB_FAB_BR0_PDT_PHB4     0x08
     597                 :            : #define CECHUB_HUB_FAB_BR0_PDT_PHB5     0x04
     598                 :            :         uint8_t         fab_br1_pdt;    /* p5ioc2 & p7ioc PCI-E */
     599                 :            : #define CECHUB_HUB_FAB_BR1_PDT_PHB0     0x80
     600                 :            : #define CECHUB_HUB_FAB_BR1_PDT_PHB1     0x40
     601                 :            : #define CECHUB_HUB_FAB_BR1_PDT_PHB2     0x20
     602                 :            : #define CECHUB_HUB_FAB_BR1_PDT_PHB3     0x10
     603                 :            : #define CECHUB_HUB_FAB_BR1_PDT_PHB4     0x08 /* p7ioc only */
     604                 :            : #define CECHUB_HUB_FAB_BR1_PDT_PHB5     0x04 /* p7ioc only */
     605                 :            :         __be16          iohub_id;       /* the type of hub */
     606                 :            : #define CECHUB_HUB_MURANO               0x20ef  /* Murano from spec */
     607                 :            : #define CECHUB_HUB_MURANO_SEGU          0x0001  /* Murano+Seguso from spec */
     608                 :            : #define CECHUB_HUB_VENICE_WYATT         0x0010  /* Venice+Wyatt from spec */
     609                 :            : #define CECHUB_HUB_NIMBUS_SFORAZ        0x0020  /* Nimbus+sforaz from spec */
     610                 :            : #define CECHUB_HUB_NIMBUS_MONZA         0x0021  /* Nimbus+monza from spec */
     611                 :            : #define CECHUB_HUB_NIMBUS_LAGRANGE      0x0022  /* Nimbus+lagrange from spec */
     612                 :            : #define CECHUB_HUB_CUMULUS_DUOMO        0x0030  /* cumulus+duomo from spec */
     613                 :            : #define CECHUB_HUB_AXONE_HOPPER         0x0040  /* axone+hopper */
     614                 :            : #define CECHUB_HUB_RAINIER              0x0050
     615                 :            : #define CECHUB_HUB_DENALI               0x0051
     616                 :            :         __be32          ec_level;
     617                 :            :         __be32          aff_dom2;       /* HDAT < v9.x only */
     618                 :            :         __be32          aff_dom3;       /* HDAT < v9.x only */
     619                 :            :         __be64          reserved;
     620                 :            :         __be32          proc_chip_id;
     621                 :            : 
     622                 :            :         union {
     623                 :            :                 /* HDAT < v9.x */
     624                 :            :                 struct {
     625                 :            :                         __be32          gx_index;       /* GX bus index on cpu */
     626                 :            :                         __be32          buid_ext;       /* BUID Extension */
     627                 :            :                         __be32          xscom_chip_id;  /* TORRENT ONLY */
     628                 :            :                 };
     629                 :            :                 /* HDAT >= v9.x */
     630                 :            :                 struct {
     631                 :            :                         __be32          reserved1;
     632                 :            :                         __be32          reserved2;
     633                 :            :                         __be16          reserved3;
     634                 :            :                         __be16          hw_topology;
     635                 :            :                 };
     636                 :            :         };
     637                 :            :         __be32          mrid;
     638                 :            :         __be32          mem_map_vers;
     639                 :            :         union {
     640                 :            :                 /* HDAT < v9.x */
     641                 :            :                 struct {
     642                 :            :                         __be64          gx_ctrl_bar0;
     643                 :            :                         __be64          gx_ctrl_bar1;
     644                 :            :                         __be64          gx_ctrl_bar2;
     645                 :            :                         __be64          gx_ctrl_bar3;
     646                 :            :                         __be64          gx_ctrl_bar4;
     647                 :            :                         __be32          sw_mask_pdt;
     648                 :            :                         __be16          gard_mask;
     649                 :            :                         __be16          gx_bus_speed;   /* Version 0x58 */
     650                 :            :                 };
     651                 :            : 
     652                 :            :                 /* HDAT >= v9.x, HDIF version 0x6A adds phb_lane_eq with four
     653                 :            :                  *               words per PHB (4 PHBs).
     654                 :            :                  *
     655                 :            :                  * HDAT >= 10.x, HDIF version 0x7A adds space for another
     656                 :            :                  *               two PHBs (6 total) and the gen4 EQ values.
     657                 :            :                  *
     658                 :            :                  * HDAT >= 10.5x, HDIF version 0x8B adds space for the
     659                 :            :                  *                gen5 EQ values.
     660                 :            :                  */
     661                 :            :                 struct {
     662                 :            :                         /* Gen 3 PHB eq values, 6 PHBs */
     663                 :            :                         __be64          phb_lane_eq[6][4];
     664                 :            : 
     665                 :            :                         /* Gen 4 PHB eq values */
     666                 :            :                         __be64          phb4_lane_eq[6][4];
     667                 :            : 
     668                 :            :                         /* Gen 5 PHB eq values */
     669                 :            :                         __be64          phb5_lane_eq[6][4];
     670                 :            :                 };
     671                 :            :         };
     672                 :            : } __packed;
     673                 :            : 
     674                 :            : /* We support structures as small as 0x68 bytes */
     675                 :            : #define CECHUB_IOHUB_MIN_SIZE   0x68
     676                 :            : 
     677                 :            : /* Child index 0: IO Daugther Card */
     678                 :            : #define CECHUB_CHILD_IO_KIDS            0
     679                 :            : 
     680                 :            : /* Child index 1: PCIe Slot Mapping Information */
     681                 :            : #define CECHUB_CHILD_IOSLOTS            1
     682                 :            : 
     683                 :            : #define IOSLOT_IDATA_SLOTMAP 0
     684                 :            : 
     685                 :            : struct slot_map_entry {
     686                 :            :         __be16 entry_id;
     687                 :            :         __be16 parent_id;
     688                 :            :         uint8_t phb_index; /* only valid for ROOT and SWITCH_UP */
     689                 :            : 
     690                 :            :         uint8_t type;
     691                 :            : #define SLOT_TYPE_ROOT_COMPLEX 0x0
     692                 :            : #define SLOT_TYPE_SWITCH_UP    0x1
     693                 :            : #define SLOT_TYPE_SWITCH_DOWN  0x2
     694                 :            : #define SLOT_TYPE_BUILTIN      0x3
     695                 :            : 
     696                 :            :         uint8_t lane_swapped;
     697                 :            :         uint8_t reserved;
     698                 :            :         __be16  lane_mask;
     699                 :            :         __be16  lane_reverse;
     700                 :            : 
     701                 :            :         /* what can I do with this? reference something under/vpd/ ? */
     702                 :            :         __be16 slca_idx;
     703                 :            : 
     704                 :            :         __be16 mrw_slot_id;
     705                 :            : 
     706                 :            :         __be32 features;
     707                 :            : #define SLOT_FEAT_SLOT 0x1
     708                 :            : 
     709                 :            :         uint8_t up_port;
     710                 :            :         uint8_t down_port; /* the switch port this device is attached to */
     711                 :            : 
     712                 :            :         __be32 vendor_id;
     713                 :            :         __be32 device_id;
     714                 :            :         __be32 sub_vendor_id;
     715                 :            :         __be32 sub_device_id;
     716                 :            :         char name[8];
     717                 :            : } __packed;
     718                 :            : 
     719                 :            : #define IOSLOT_IDATA_DETAILS 1
     720                 :            : 
     721                 :            : struct slot_map_details {
     722                 :            :         __be16 entry;
     723                 :            : 
     724                 :            :         /* Phyp junk, ignore */
     725                 :            :         uint8_t mgc_load_source;
     726                 :            :         uint8_t hddw_order;
     727                 :            :         __be16 mmio_size_32; /* In MB */
     728                 :            :         __be16 mmio_size_64;
     729                 :            :         __be16 dma_size_32;
     730                 :            :         __be16 dma_size_64;
     731                 :            : 
     732                 :            :         uint8_t power_ctrl_type; /* slot power control source */
     733                 :            : #define SLOT_PWR_NONE 0x0
     734                 :            : #define SLOT_PWR_I2C  0x1
     735                 :            : 
     736                 :            :         uint8_t presence_det_type; /* slot presence detect source */
     737                 :            : #define SLOT_PRESENCE_NONE 0x0
     738                 :            : #define SLOT_PRESENCE_PCI  0x1
     739                 :            : #define SLOT_PRESENCE_I2C  0x2
     740                 :            : 
     741                 :            :         uint8_t perst_ctl_type; /* slot PERST source */
     742                 :            : #define SLOT_PERST_NONE      0x0
     743                 :            : #define SLOT_PERST_PHB_OR_SW 0x1
     744                 :            : #define SLOT_PERST_SW_GPIO   0x2
     745                 :            :         uint8_t perst_gpio;
     746                 :            : 
     747                 :            :         __be16 max_power; /* in W? */
     748                 :            : 
     749                 :            :         __be32 slot_caps;
     750                 :            : #define SLOT_CAP_LSI      0x01 /* phyp junk? */
     751                 :            : #define SLOT_CAP_CAPI     0x02
     752                 :            : #define SLOT_CAP_CCARD    0x04
     753                 :            : #define SLOT_CAP_HOTPLUG  0x08
     754                 :            : #define SLOT_CAP_SRIOV    0x10 /* phyp junk */
     755                 :            : #define SLOT_CAP_ELLOCO   0x20 /* why is this seperate from the nvlink cap? */
     756                 :            : #define SLOT_CAP_NVLINK   0x30
     757                 :            : 
     758                 :            :         __be16 reserved1;
     759                 :            : 
     760                 :            :         /* I2C Link IDs */
     761                 :            :         __be32 i2c_power_ctl;
     762                 :            :         __be32 i2c_pgood;
     763                 :            :         __be32 i2c_cable_card; /* opencapi presence detect? */
     764                 :            :         __be32 i2c_mex_fpga;
     765                 :            : };
     766                 :            : 
     767                 :            : /*
     768                 :            :  * IO KID is a dauther card structure
     769                 :            :  */
     770                 :            : #define IOKID_FRU_ID_DATA       0
     771                 :            : #define IOKID_KW_VPD            1
     772                 :            : 
     773                 :            : /*
     774                 :            :  * CPU Controls Legacy Structure
     775                 :            :  */
     776                 :            : struct cpu_ctl_legacy {
     777                 :            :         __be64 addr;
     778                 :            :         __be64 size;
     779                 :            : } __packed;
     780                 :            : 
     781                 :            : /*
     782                 :            :  * CPU Control Legacy table
     783                 :            :  *
     784                 :            :  * Format of this table is defined in FIPS PHYP Attn spec.
     785                 :            :  */
     786                 :            : struct cpu_ctl_legacy_table {
     787                 :            :         struct cpu_ctl_legacy spat;
     788                 :            :         struct cpu_ctl_legacy sp_attn_area1;
     789                 :            :         struct cpu_ctl_legacy sp_attn_area2;
     790                 :            :         struct cpu_ctl_legacy hsr_area;
     791                 :            :         struct cpu_ctl_legacy reserved[12];
     792                 :            : } __packed;
     793                 :            : 
     794                 :            : /*
     795                 :            :  * CPU Controls Header Structure
     796                 :            :  */
     797                 :            : #define CPU_CTL_HDIF_SIG        "CPUCTL"
     798                 :            : struct cpu_ctl_init_data {
     799                 :            :         struct HDIF_common_hdr          hdr;
     800                 :            :         struct HDIF_idata_ptr           cpu_ctl;
     801                 :            :         uint8_t                         reserved[8];
     802                 :            :         struct cpu_ctl_legacy_table     cpu_ctl_lt;
     803                 :            : } __packed __align(0x10);
     804                 :            : 
     805                 :            : /*
     806                 :            :  * Slot Location Code Array (aka SLCA)
     807                 :            :  *
     808                 :            :  * This is a pile of location codes referenced by various other
     809                 :            :  * structures such as the IO Hubs for things on the CEC. Not
     810                 :            :  * everything in there is a physical port. The SLCA is actually
     811                 :            :  * a tree which represent the topology of the system.
     812                 :            :  *
     813                 :            :  * The tree works as follow: A parent has a pointer to the first
     814                 :            :  * child. A child has a pointer to its parent. Siblings are
     815                 :            :  * consecutive entries.
     816                 :            :  *
     817                 :            :  * Note: If we ever support concurrent maintenance... this is
     818                 :            :  * completely rebuilt, invalidating all indices, though other
     819                 :            :  * structures that may reference SLCA by index will be rebuilt
     820                 :            :  * as well.
     821                 :            :  *
     822                 :            :  * Note that a lot of that stuff is based on VPD documentation
     823                 :            :  * such as the identification keywords. I will list the ones
     824                 :            :  * I manage to figure out without the doc separately.
     825                 :            :  */
     826                 :            : #define SLCA_HDIF_SIG   "SLCA  "
     827                 :            : 
     828                 :            : /* Idata index 0 : SLCA root pointer
     829                 :            :  *
     830                 :            :  * The SLCA array is an HDIF array of all the entries. The tree
     831                 :            :  * structure is based on indices inside the entries and order of
     832                 :            :  * the entries
     833                 :            :  */
     834                 :            : #define SLCA_IDATA_ARRAY        0
     835                 :            : 
     836                 :            : #define SLCA_ROOT_INDEX         0
     837                 :            : 
     838                 :            : /* Note: An "index" (or idx) is always an index into the SLCA array
     839                 :            :  * and "id" is a reference to some other object.
     840                 :            :  */
     841                 :            : struct slca_entry {
     842                 :            :         __be16          my_index;       /* redundant, useful */
     843                 :            :         __be16          rsrc_id;        /* formerly VPD port number */
     844                 :            :         uint8_t         fru_id[2];      /* ASCII VPD ID */
     845                 :            : #define SLCA_ROOT_VPD_ID        VPD_ID('V','V')
     846                 :            : #define SLCA_SYSTEM_VPD_ID      VPD_ID('S','V')
     847                 :            : #define SLCA_SAI_INDICATOR_ID   VPD_ID('S','A')
     848                 :            :         __be16          parent_index;   /* Parent entry index */
     849                 :            :         uint8_t         flags;
     850                 :            : #define SLCA_FLAG_NON_FUNCTIONAL        0x02    /* For redundant entries */
     851                 :            : #define SLCA_FLAG_IMBEDDED              0x01    /* not set => pluggable */
     852                 :            :         uint8_t         old_nr_child;   /* Legacy: Nr of children */
     853                 :            :         __be16          child_index;    /* First child index */
     854                 :            :         __be16          child_rsrc_id;  /* Resource ID of first child */
     855                 :            :         uint8_t         loc_code_allen; /* Alloc len of loc code */
     856                 :            :         uint8_t         loc_code_len;   /* Loc code len */
     857                 :            :         uint8_t         loc_code[LOC_CODE_SIZE]; /* NULL terminated (thus max 79 chr) */
     858                 :            :         __be16          first_dup_idx;  /* First redundant resource index */
     859                 :            :         uint8_t         nr_dups;        /* Number of redundant entries */
     860                 :            :         uint8_t         reserved;
     861                 :            :         __be16          nr_child;       /* New version */
     862                 :            :         uint8_t         install_indic;  /* Installed indicator */
     863                 :            : #define SLCA_INSTALL_NO_HW_PDT          1 /* No HW presence detect */
     864                 :            : #define SLCA_INSTALL_INSTALLED          2
     865                 :            : #define SLCA_INSTALL_NOT_INSTALLED      3
     866                 :            :         uint8_t         vpd_collected;
     867                 :            : #define SLCA_VPD_COLLECTED              2
     868                 :            : #define SLCA_VPD_NOT_COLLECTED          3
     869                 :            : } __packed;
     870                 :            : 
     871                 :            : /*
     872                 :            :  * System VPD
     873                 :            :  */
     874                 :            : #define SYSVPD_HDIF_SIG "SYSVPD"
     875                 :            : 
     876                 :            : /* Idata index 0 : FRU ID Data */
     877                 :            : #define SYSVPD_IDATA_FRU_ID     0
     878                 :            : 
     879                 :            : /* Idata index 1 : Keyword VPD */
     880                 :            : #define SYSVPD_IDATA_KW_VPD     1
     881                 :            : 
     882                 :            : /* Idata index 2 : Operational status */
     883                 :            : #define SYSVPD_IDATA_OP_STATUS  2
     884                 :            : 
     885                 :            : /*
     886                 :            :  * FRU keyword VPD structure
     887                 :            :  */
     888                 :            : #define FRUVPD_HDIF_SIG "FRUVPD"
     889                 :            : 
     890                 :            : /* Idata index 0 : FRU ID Data */
     891                 :            : #define FRUVPD_IDATA_FRU_ID     0
     892                 :            : 
     893                 :            : /* Idata index 1 : Keyword VPD */
     894                 :            : #define FRUVPD_IDATA_KW_VPD     1
     895                 :            : 
     896                 :            : /* Idata index 2 : Operational status */
     897                 :            : #define FRUVPD_IDATA_OP_STATUS  2
     898                 :            : 
     899                 :            : 
     900                 :            : /*
     901                 :            :  * SPPCIA structure. The SPIRA contain an array of these, one
     902                 :            :  * per processor core
     903                 :            :  */
     904                 :            : #define SPPCIA_HDIF_SIG "SPPCIA"
     905                 :            : 
     906                 :            : /* Idata index 0 : Core unique data */
     907                 :            : #define SPPCIA_IDATA_CORE_UNIQUE        0
     908                 :            : 
     909                 :            : struct sppcia_core_unique {
     910                 :            :         __be32 reserved;
     911                 :            :         __be32 proc_fru_id;
     912                 :            :         __be32 hw_proc_id;
     913                 :            : #define CPU_ID_VERIFY_MASK                      0xC0000000
     914                 :            : #define CPU_ID_VERIFY_SHIFT                     30
     915                 :            : #define CPU_ID_VERIFY_USABLE_NO_FAILURES        0
     916                 :            : #define CPU_ID_VERIFY_USABLE_FAILURES           1
     917                 :            : #define CPU_ID_VERIFY_NOT_INSTALLED             2
     918                 :            : #define CPU_ID_VERIFY_UNUSABLE                  3
     919                 :            : #define CPU_ID_SECONDARY_THREAD                 0x20000000
     920                 :            : #define CPU_ID_PCIA_RESERVED                    0x10000000
     921                 :            : #define CPU_ID_NUM_SECONDARY_THREAD_MASK        0x00FF0000
     922                 :            : #define CPU_ID_NUM_SECONDARY_THREAD_SHIFT       16
     923                 :            :         __be32 verif_exist_flags;
     924                 :            :         __be32 chip_ec_level;
     925                 :            :         __be32 proc_chip_id;
     926                 :            :         __be32 reserved2;
     927                 :            :         __be32 reserved3;
     928                 :            :         __be32 reserved4;
     929                 :            :         __be32 hw_module_id;
     930                 :            :         __be64 reserved5;
     931                 :            :         __be32 reserved6;
     932                 :            :         __be32 reserved7;
     933                 :            :         __be32 reserved8;
     934                 :            :         __be32 ccm_node_id;
     935                 :            :         __be32 hw_card_id;
     936                 :            :         __be32 internal_drawer_node_id;
     937                 :            :         __be32 drawer_book_octant_blade_id;
     938                 :            :         __be32 memory_interleaving_scope;
     939                 :            :         __be32 lco_target;
     940                 :            :         __be32 reserved9;
     941                 :            : } __packed;
     942                 :            : 
     943                 :            : /* Idata index 1 : CPU Time base structure */
     944                 :            : #define SPPCIA_IDATA_TIMEBASE           1
     945                 :            : 
     946                 :            : struct sppcia_cpu_timebase {
     947                 :            :         __be32 cycle_time;
     948                 :            :         __be32 time_base;
     949                 :            :         __be32 actual_clock_speed;
     950                 :            :         __be32 memory_bus_frequency;
     951                 :            : } __packed;
     952                 :            : 
     953                 :            : /* Idata index 2 : CPU Cache Size Structure */
     954                 :            : #define SPPCIA_IDATA_CPU_CACHE          2
     955                 :            : 
     956                 :            : struct sppcia_cpu_cache {
     957                 :            :         __be32 icache_size_kb;
     958                 :            :         __be32 icache_line_size;
     959                 :            :         __be32 l1_dcache_size_kb;
     960                 :            :         __be32 l1_dcache_line_size;
     961                 :            :         __be32 l2_dcache_size_kb;
     962                 :            :         __be32 l2_line_size;
     963                 :            :         __be32 l3_dcache_size_kb;
     964                 :            :         __be32 l3_line_size;
     965                 :            :         __be32 dcache_block_size;
     966                 :            :         __be32 icache_block_size;
     967                 :            :         __be32 dcache_assoc_sets;
     968                 :            :         __be32 icache_assoc_sets;
     969                 :            :         __be32 dtlb_entries;
     970                 :            :         __be32 dtlb_assoc_sets;
     971                 :            :         __be32 itlb_entries;
     972                 :            :         __be32 itlb_assoc_sets;
     973                 :            :         __be32 reservation_size;
     974                 :            :         __be32 l2_cache_assoc_sets;
     975                 :            :         __be32 l35_dcache_size_kb;
     976                 :            :         __be32 l35_cache_line_size;
     977                 :            : } __packed;
     978                 :            : 
     979                 :            : 
     980                 :            : /* Idata index 3 : Thread Array Data
     981                 :            :  *
     982                 :            :  * HDIF array of
     983                 :            :  */
     984                 :            : #define SPPCIA_IDATA_THREAD_ARRAY       3
     985                 :            : 
     986                 :            : struct sppcia_cpu_thread {
     987                 :            :         __be32 proc_int_line;
     988                 :            :         __be32 phys_thread_id;
     989                 :            :         __be64 ibase;
     990                 :            :         __be32 pir;
     991                 :            : } __packed;
     992                 :            : 
     993                 :            : /* Idata index 4 : CPU Attributes */
     994                 :            : #define SPPCIA_IDATA_CPU_ATTR           4
     995                 :            : 
     996                 :            : struct sppcia_cpu_attr {
     997                 :            : #define CPU_ATTR_UNIFIED_PL1    0x80
     998                 :            : #define CPU_ATTR_SPLIT_TLB      0x40
     999                 :            : #define CPU_ATTR_TLBIA          0x20
    1000                 :            : #define CPU_ATTR_PERF_MONITOR   0x10
    1001                 :            : #define CPU_ATTR_EXTERN_CONT    0x02
    1002                 :            :         __be32 attr;
    1003                 :            : } __packed;
    1004                 :            : 
    1005                 :            : /*
    1006                 :            :  * Processor Chip Related Data. The SPIRA contain an array of these, one
    1007                 :            :  * per chip
    1008                 :            :  */
    1009                 :            : #define SPPCRD_HDIF_SIG "SPPCRD"
    1010                 :            : 
    1011                 :            : /* Idata index 0 : Chip info */
    1012                 :            : #define SPPCRD_IDATA_CHIP_INFO  0
    1013                 :            : 
    1014                 :            : struct sppcrd_chip_info {
    1015                 :            :         __be32 proc_chip_id;
    1016                 :            :         __be32 verif_exist_flags;
    1017                 :            : #define CHIP_VERIFY_MASK                        0xC0000000
    1018                 :            : #define CHIP_VERIFY_SHIFT                       30
    1019                 :            : #define CHIP_VERIFY_USABLE_NO_FAILURES          0
    1020                 :            : #define CHIP_VERIFY_USABLE_FAILURES             1
    1021                 :            : #define CHIP_VERIFY_NOT_INSTALLED               2
    1022                 :            : #define CHIP_VERIFY_UNUSABLE                    3
    1023                 :            : #define CHIP_VERIFY_MASTER_PROC                 PPC_BIT32(4)
    1024                 :            :         __be32 nx_state;
    1025                 :            :         __be32 pore_state;
    1026                 :            :         __be32 xscom_id;
    1027                 :            :         /* Version 0xA */
    1028                 :            :         __be32 reserved;
    1029                 :            :         __be32 dbob_id;
    1030                 :            :         __be32 occ_state;
    1031                 :            :         /* Version 0xC - none of these are used */
    1032                 :            :         __be32 processor_fru_id;
    1033                 :            :         __be32 chip_ec_level;
    1034                 :            :         __be32 hw_module_id;
    1035                 :            :         __be32 hw_card_id;
    1036                 :            :         __be32 internal_drawer_nid;
    1037                 :            :         __be32 ccm_nid;
    1038                 :            :         /* Version 0xD */
    1039                 :            :         __be32 capp0_func_state;
    1040                 :            :         /* Version 0xE */
    1041                 :            :         __be32 capp1_func_state;
    1042                 :            :         /* *possibly* from Version 0x20 - check spec */
    1043                 :            :         __be32 stop_levels;
    1044                 :            :         /* From latest version (possibly 0x21 and later) */
    1045                 :            :         __be32 sw_xstop_fir_scom;
    1046                 :            :         uint8_t sw_xstop_fir_bitpos;
    1047                 :            :         /* Latest version for P10 */
    1048                 :            : #define CHIP_MAX_TOPOLOGY_ENTRIES       32
    1049                 :            :         uint8_t topology_id_table[CHIP_MAX_TOPOLOGY_ENTRIES];
    1050                 :            :         uint8_t primary_topology_loc;   /* Index in topology_id_table */
    1051                 :            :         __be32  abc_bus_speed;  /* SMP A */
    1052                 :            :         __be32  wxyz_bus_speed; /* SMP X */
    1053                 :            :         uint8_t fab_topology_id;/* topology id associated with the chip. */
    1054                 :            : } __packed;
    1055                 :            : 
    1056                 :            : /* Idata index 1 : Chip TOD */
    1057                 :            : #define SPPCRD_IDATA_CHIP_TOD   1
    1058                 :            : 
    1059                 :            : struct sppcrd_chip_tod {
    1060                 :            :         __be32 flags;
    1061                 :            :         /* CHIPTOD_ID_... values */
    1062                 :            :         __be32 ctrl_reg_internal;
    1063                 :            :         __be32 tod_ctrl_reg;
    1064                 :            : } __packed;
    1065                 :            : 
    1066                 :            : /* Idata index 2 : FRU ID */
    1067                 :            : #define SPPCRD_IDATA_FRU_ID     2
    1068                 :            : 
    1069                 :            : /* Idata index 3 : ASCII Keyword data */
    1070                 :            : #define SPPCRD_IDATA_KW_VPD     3
    1071                 :            : 
    1072                 :            : /* Idata index 4 : Module VPD */
    1073                 :            : #define SPPCRD_IDATA_MODULE_VPD 4
    1074                 :            : 
    1075                 :            : /* Idata index 5 : Chip attached I2C devices */
    1076                 :            : #define SPPCRD_IDATA_HOST_I2C   5
    1077                 :            : 
    1078                 :            : /* Idata index 5 : Chip attached I2C devices */
    1079                 :            : #define SPPCRD_IDATA_PNOR       6
    1080                 :            : 
    1081                 :            : /* Idata index 6 : OpenCAPI/NVlink info */
    1082                 :            : #define SPPCRD_IDATA_SMP_LINK   7
    1083                 :            : struct sppcrd_smp_link {
    1084                 :            :         __be32 link_id;
    1085                 :            :         __be32 usage;
    1086                 :            : #define SMP_LINK_USE_NONE       0
    1087                 :            : #define SMP_LINK_USE_GPU        1
    1088                 :            : #define SMP_LINK_USE_OPENCAPI   2
    1089                 :            : #define SMP_LINK_USE_INTERPOSER 3
    1090                 :            : #define SMP_LINK_USE_DRAWER     4
    1091                 :            : #define SMP_LINK_USE_D2D        5 /* GPU to GPU */
    1092                 :            :         __be32 brick_id;
    1093                 :            :         __be32 lane_mask;
    1094                 :            : 
    1095                 :            :         /* bonded pci slots (mostly a NVLink thing) */
    1096                 :            :         __be16 pci_slot_idx;
    1097                 :            :         __be16 pci_sideband_slot_idx;
    1098                 :            : 
    1099                 :            :         __be16 slca_idx; /* SLCA index of the *external* port */
    1100                 :            :         __be16 opt_id;
    1101                 :            : 
    1102                 :            :         /* nvlink/ocapi detection devices */
    1103                 :            :         __be32 i2c_link_cable;
    1104                 :            :         __be32 i2c_presence;
    1105                 :            :         __be32 i2c_micro;
    1106                 :            :         uint8_t link_speed;
    1107                 :            :         uint8_t occ_flag_bit;
    1108                 :            :         __be16 gpu_slca;
    1109                 :            : } __packed;
    1110                 :            : 
    1111                 :            : /* Idata index 8 : chip EC Level array */
    1112                 :            : #define SPPCRD_IDATA_EC_LEVEL   8
    1113                 :            : 
    1114                 :            : struct sppcrd_ecid {
    1115                 :            :         __be32  chip_id;
    1116                 :            :         __be32  ec_level;
    1117                 :            :         __be64  low;    /* Processor ECID bit 0-63 */
    1118                 :            :         __be64  high;   /* Processor ECID bit 64-127 */
    1119                 :            : } __packed;
    1120                 :            : 
    1121                 :            : /*
    1122                 :            :  * Host Services Data.
    1123                 :            :  */
    1124                 :            : #define HSERV_HDIF_SIG  "HOSTSR"
    1125                 :            : 
    1126                 :            : /* Idata index 0 : System attribute data */
    1127                 :            : #define HSERV_IDATA_SYS_ATTR    0
    1128                 :            : 
    1129                 :            : /* IPMI sensors mapping data */
    1130                 :            : #define IPMI_SENSORS_HDIF_SIG   "FRUSE "
    1131                 :            : 
    1132                 :            : /* Idata index 0 : Sensor mapping data */
    1133                 :            : #define IPMI_SENSORS_IDATA_SENSORS      0
    1134                 :            : 
    1135                 :            : struct ipmi_sensors_data {
    1136                 :            :         __be32  slca_index;
    1137                 :            :         uint8_t type;
    1138                 :            :         uint8_t id;
    1139                 :            :         uint8_t entity_id;
    1140                 :            :         uint8_t reserved;
    1141                 :            : } __packed;
    1142                 :            : 
    1143                 :            : struct ipmi_sensors {
    1144                 :            :         __be32  count;
    1145                 :            :         struct ipmi_sensors_data data[];
    1146                 :            : } __packed;
    1147                 :            : 
    1148                 :            : /* Idata index 1 : LED - sensors ID mapping data */
    1149                 :            : #define IPMI_SENSORS_IDATA_LED          1
    1150                 :            : 
    1151                 :            : /*
    1152                 :            :  * Node Secure and Trusted Boot Related Data
    1153                 :            :  */
    1154                 :            : #define STB_HDIF_SIG    "TPMREL"
    1155                 :            : 
    1156                 :            : /*
    1157                 :            :  * Idata index 0 : Secure Boot and TPM Instance Info
    1158                 :            :  *
    1159                 :            :  * There can be multiple entries with each entry corresponding to
    1160                 :            :  * a master processor that has a TPM device
    1161                 :            :  */
    1162                 :            : #define TPMREL_IDATA_SECUREBOOT_TPM_INFO        0
    1163                 :            : 
    1164                 :            : struct secureboot_tpm_info {
    1165                 :            :         __be32 chip_id;
    1166                 :            :         __be32 dbob_id;
    1167                 :            :         uint8_t locality1;
    1168                 :            :         uint8_t locality2;
    1169                 :            :         uint8_t locality3;
    1170                 :            :         uint8_t locality4;
    1171                 :            : #define TPM_PRESENT_AND_FUNCTIONAL      0x01
    1172                 :            : #define TPM_PRESENT_AND_NOT_FUNCTIONAL  0x02
    1173                 :            : #define TPM_NOT_PRESENT                 0x03
    1174                 :            :         uint8_t tpm_status;
    1175                 :            :         uint8_t reserved[3];
    1176                 :            :         /* zero indicates no tpm log data */
    1177                 :            :         __be32 srtm_log_offset;
    1178                 :            :         __be32 srtm_log_size;
    1179                 :            :         /* zero indicates no tpm log data */
    1180                 :            :         __be32 drtm_log_offset;
    1181                 :            :         __be32 drtm_log_size;
    1182                 :            : } __packed;
    1183                 :            : 
    1184                 :            : /* Idata index 2: Hash and Verification Function Offsets Array */
    1185                 :            : #define TPMREL_IDATA_HASH_VERIF_OFFSETS         2
    1186                 :            : 
    1187                 :            : struct hash_and_verification {
    1188                 :            : #define TPMREL_HV_SHA512        0x00
    1189                 :            : #define TPMREL_HV_VERIFY        0x01
    1190                 :            :         __be32 type;
    1191                 :            :         __be32 version;
    1192                 :            :         __be32 dbob_id;
    1193                 :            :         __be32 offset;
    1194                 :            : } __packed;
    1195                 :            : 
    1196                 :          6 : static inline const char *cpu_state(u32 flags)
    1197                 :            : {
    1198                 :          6 :         switch ((flags & CPU_ID_VERIFY_MASK) >> CPU_ID_VERIFY_SHIFT) {
    1199                 :          6 :         case CPU_ID_VERIFY_USABLE_NO_FAILURES:
    1200                 :          6 :                 return "OK";
    1201                 :          0 :         case CPU_ID_VERIFY_USABLE_FAILURES:
    1202                 :          0 :                 return "FAILURES";
    1203                 :          0 :         case CPU_ID_VERIFY_NOT_INSTALLED:
    1204                 :          0 :                 return "NOT-INSTALLED";
    1205                 :          0 :         case CPU_ID_VERIFY_UNUSABLE:
    1206                 :          0 :                 return "UNUSABLE";
    1207                 :            :         }
    1208                 :          0 :         return "**UNKNOWN**";
    1209                 :            : }
    1210                 :            : #endif /* __SPIRA_H */

Generated by: LCOV version 1.14