LCOV - code coverage report
Current view: top level - include - chip.h (source / functions) Hit Total Coverage
Test: skiboot.info Lines: 2 2 100.0 %
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 __CHIP_H
       5                 :            : #define __CHIP_H
       6                 :            : 
       7                 :            : #include <stdint.h>
       8                 :            : #include <lock.h>
       9                 :            : 
      10                 :            : #include <ccan/list/list.h>
      11                 :            : 
      12                 :            : /*
      13                 :            :  * Note on chip IDs:
      14                 :            :  *
      15                 :            :  * We carry a "chip_id" around, in the cpu_thread, but also as
      16                 :            :  * ibm,chip-id properties.
      17                 :            :  *
      18                 :            :  * This ID is the HW fabric ID of a chip based on the XSCOM numbering,
      19                 :            :  * also known as "GCID" (Global Chip ID).
      20                 :            :  *
      21                 :            :  * The format of this number is different between chip generations and care must
      22                 :            :  * be taken when trying to convert between this chip ID and some other
      23                 :            :  * representation such as PIR values, interrupt-server numbers etc... :
      24                 :            :  *
      25                 :            :  */
      26                 :            : 
      27                 :            : /*
      28                 :            :  * P8 GCID
      29                 :            :  * -------
      30                 :            :  *
      31                 :            :  * Global chip ID is a 6 bit number:
      32                 :            :  *
      33                 :            :  *     NodeID      ChipID
      34                 :            :  * |           |           |
      35                 :            :  * |___|___|___|___|___|___|
      36                 :            :  *
      37                 :            :  * The the ChipID is 3 bits long, the GCID is the same as the high bits of PIR
      38                 :            :  */
      39                 :            : #define P8_PIR2GCID(pir) (((pir) >> 7) & 0x3f)
      40                 :            : 
      41                 :            : #define P8_PIR2COREID(pir) (((pir) >> 3) & 0xf)
      42                 :            : 
      43                 :            : #define P8_PIR2THREADID(pir) ((pir) & 0x7)
      44                 :            : 
      45                 :            : /*
      46                 :            :  * P9 GCID
      47                 :            :  * -------
      48                 :            :  *
      49                 :            :  * Global chip ID is a 7 bit number:
      50                 :            :  *
      51                 :            :  *        NodeID      ChipID
      52                 :            :  * |               |           |
      53                 :            :  * |___|___|___|___|___|___|___|
      54                 :            :  *
      55                 :            :  * Bit 56 is unused according to the manual by we add it to the coreid here,
      56                 :            :  * thus we have a 6-bit core number.
      57                 :            :  *
      58                 :            :  * Note: XIVE Only supports 4-bit chip numbers ...
      59                 :            :  *
      60                 :            :  * Upper PIR Bits
      61                 :            :  * --------------
      62                 :            :  *
      63                 :            :  * Normal-Core Mode:
      64                 :            :  * 57:61 CoreID
      65                 :            :  * 62:63 ThreadID
      66                 :            :  *
      67                 :            :  * Fused-Core Mode:
      68                 :            :  * 57:59 FusedQuadID
      69                 :            :  * 60    FusedCoreID
      70                 :            :  * 61:63 FusedThreadID
      71                 :            :  *
      72                 :            :  * FusedCoreID 0 contains normal-core chiplet 0 and 1
      73                 :            :  * FusedCoreID 1 contains normal-core chiplet 2 and 3
      74                 :            :  *
      75                 :            :  * Fused cores have interleaved threads:
      76                 :            :  * core chiplet 0/2 = t0, t2, t4, t6
      77                 :            :  * core chiplet 1/3 = t1, t3, t5, t7
      78                 :            :  *
      79                 :            :  */
      80                 :            : #define P9_PIR2GCID(pir) (((pir) >> 8) & 0x7f)
      81                 :            : 
      82                 :            : #define P9_PIR2COREID(pir) (((pir) >> 2) & 0x3f)
      83                 :            : 
      84                 :            : #define P9_PIR2THREADID(pir) ((pir) & 0x3)
      85                 :            : 
      86                 :            : #define P9_GCID2NODEID(gcid)    (((gcid) >> 3) & 0xf)
      87                 :            : 
      88                 :            : #define P9_GCID2CHIPID(gcid) ((gcid) & 0x7)
      89                 :            : 
      90                 :            : #define P9_PIR2FUSEDQUADID(pir) (((pir) >> 4) & 0x7)
      91                 :            : 
      92                 :            : #define P9_PIR2FUSEDCOREID(pir) (((pir) >> 3) & 0x1)
      93                 :            : 
      94                 :            : #define P9_PIR2FUSEDTHREADID(pir) ((pir) & 0x7)
      95                 :            : 
      96                 :            : #define P9_PIRFUSED2NORMALCOREID(pir) \
      97                 :            :         (P9_PIR2FUSEDQUADID(pir) << 2) | \
      98                 :            :         (P9_PIR2FUSEDCOREID(pir) << 1) | \
      99                 :            :         (P9_PIR2FUSEDTHREADID(pir) & 1)
     100                 :            : 
     101                 :            : #define P9_PIRFUSED2NORMALTHREADID(pir) (((pir) >> 1) & 0x3)
     102                 :            : 
     103                 :            : #define P10_PIR2FUSEDCOREID(pir) P9_PIR2FUSEDCOREID(pir)
     104                 :            : #define P10_PIRFUSED2NORMALCOREID(pir) P9_PIRFUSED2NORMALCOREID(pir)
     105                 :            : #define P10_PIRFUSED2NORMALTHREADID(pir) P9_PIRFUSED2NORMALTHREADID(pir)
     106                 :            : 
     107                 :            : /* P9 specific ones mostly used by XIVE */
     108                 :            : #define P9_PIR2LOCALCPU(pir) ((pir) & 0xff)
     109                 :            : #define P9_PIRFROMLOCALCPU(chip, cpu)   (((chip) << 8) | (cpu))
     110                 :            : 
     111                 :            : /*
     112                 :            :  * P10 PIR
     113                 :            :  * -------
     114                 :            :  *
     115                 :            :  * PIR layout:
     116                 :            :  *
     117                 :            :  * |  49|  50|  51|  52|  53|  54|  55|  56|  57|  58|  59|  60|  61|  62|  63|
     118                 :            :  * |Spare ID      |Topology ID        |Sp. |Quad ID       |Core ID  |Thread ID|
     119                 :            :  *
     120                 :            :  * Bit 56 is a spare quad ID. In big-core mode, thread ID extends to bit 61.
     121                 :            :  *
     122                 :            :  * P10 GCID
     123                 :            :  * --------
     124                 :            :  *
     125                 :            :  * - Global chip ID is also called Topology ID.
     126                 :            :  * - Node ID is called Group ID (? XXX P10).
     127                 :            :  *
     128                 :            :  * Global chip ID is a 4 bit number.
     129                 :            :  *
     130                 :            :  * There is a topology mode bit that can be 0 or 1, which changes GCID mapping.
     131                 :            :  *
     132                 :            :  * Topology mode 0:
     133                 :            :  *      NodeID    ChipID
     134                 :            :  * |              |    |
     135                 :            :  * |____|____|____|____|
     136                 :            :  *
     137                 :            :  * Topology mode 1:
     138                 :            :  *    NodeID    ChipID
     139                 :            :  * |         |         |
     140                 :            :  * |____|____|____|____|
     141                 :            :  */
     142                 :            : #define P10_PIR2GCID(pir) (((pir) >> 8) & 0xf)
     143                 :            : 
     144                 :            : #define P10_PIR2COREID(pir) (((pir) >> 2) & 0x3f)
     145                 :            : 
     146                 :            : #define P10_PIR2THREADID(pir) ((pir) & 0x3)
     147                 :            : 
     148                 :            : // XXX P10 These depend on the topology mode, how to get that (system type?)
     149                 :            : #define P10_GCID2NODEID(gcid, mode) ((mode) == 0 ? ((gcid) >> 1) & 0x7 : ((gcid) >> 2) & 0x3)
     150                 :            : #define P10_GCID2CHIPID(gcid, mode) ((mode) == 0 ? (gcid) & 0x1 : (gcid) & 0x3)
     151                 :            : 
     152                 :            : /* P10 specific ones mostly used by XIVE */
     153                 :            : #define P10_PIR2LOCALCPU(pir) ((pir) & 0xff)
     154                 :            : #define P10_PIRFROMLOCALCPU(chip, cpu)  (((chip) << 8) | (cpu))
     155                 :            : 
     156                 :            : struct dt_node;
     157                 :            : struct centaur_chip;
     158                 :            : struct mfsi;
     159                 :            : struct xive;
     160                 :            : struct lpcm;
     161                 :            : struct vas;
     162                 :            : struct p9_sbe;
     163                 :            : struct p9_dio;
     164                 :            : 
     165                 :            : /* Chip type */
     166                 :            : enum proc_chip_type {
     167                 :            :         PROC_CHIP_UNKNOWN,
     168                 :            :         PROC_CHIP_P8_MURANO,
     169                 :            :         PROC_CHIP_P8_VENICE,
     170                 :            :         PROC_CHIP_P8_NAPLES,
     171                 :            :         PROC_CHIP_P9_NIMBUS,
     172                 :            :         PROC_CHIP_P9_CUMULUS,
     173                 :            :         PROC_CHIP_P9P,
     174                 :            :         PROC_CHIP_P10,
     175                 :            : };
     176                 :            : 
     177                 :            : /* Simulator quirks */
     178                 :            : enum proc_chip_quirks {
     179                 :            :         QUIRK_NO_CHIPTOD        = 0x00000001,
     180                 :            :         QUIRK_MAMBO_CALLOUTS    = 0x00000002,
     181                 :            :         QUIRK_NO_F000F          = 0x00000004,
     182                 :            :         QUIRK_NO_PBA            = 0x00000008,
     183                 :            :         QUIRK_NO_OCC_IRQ        = 0x00000010,
     184                 :            :         QUIRK_SIMICS            = 0x00000020,
     185                 :            :         QUIRK_SLOW_SIM          = 0x00000040,
     186                 :            :         QUIRK_NO_DIRECT_CTL     = 0x00000080,
     187                 :            :         QUIRK_NO_RNG            = 0x00000100,
     188                 :            :         QUIRK_QEMU              = 0x00000200,
     189                 :            :         QUIRK_AWAN              = 0x00000400,
     190                 :            :         QUIRK_BML               = 0x00000800,
     191                 :            : };
     192                 :            : 
     193                 :            : extern enum proc_chip_quirks proc_chip_quirks;
     194                 :            : 
     195                 :         36 : static inline bool chip_quirk(unsigned int q)
     196                 :            : {
     197                 :         36 :         return !!(proc_chip_quirks & q);
     198                 :            : }
     199                 :            : 
     200                 :            : #define MAX_CHIPS       (1 << 6)  /* 6-bit chip ID */
     201                 :            : 
     202                 :            : /*
     203                 :            :  * For each chip in the system, we maintain this structure
     204                 :            :  *
     205                 :            :  * This contains fields used by different modules including
     206                 :            :  * modules in hw/ but is handy to keep per-chip data
     207                 :            :  */
     208                 :            : struct proc_chip {
     209                 :            :         uint32_t                id;             /* HW Chip ID (GCID) */
     210                 :            :         struct dt_node          *devnode;       /* "xscom" chip node */
     211                 :            : 
     212                 :            :         /* These are only initialized after xcom_init */
     213                 :            :         enum proc_chip_type     type;
     214                 :            :         uint32_t                ec_level;       /* 0xMm (DD1.0 = 0x10) */
     215                 :            :         uint8_t                 ec_rev;         /* sub-revision */
     216                 :            : 
     217                 :            :         /* Those two values are only populated on machines with an FSP
     218                 :            :          * dbob_id = Drawer/Block/Octant/Blade (DBOBID)
     219                 :            :          * pcid    = HDAT processor_chip_id
     220                 :            :          */
     221                 :            :         uint32_t                dbob_id;
     222                 :            :         uint32_t                pcid;
     223                 :            : 
     224                 :            :         /* If we expect to have an OCC (i.e. P8) and it is functional,
     225                 :            :          * set TRUE. If something has told us it is not, set FALSE and
     226                 :            :          * we can not wait for OCCs to init. This is only going to be
     227                 :            :          * FALSE in a simulator that doesn't simulate OCCs. */
     228                 :            :         bool                    occ_functional;
     229                 :            : 
     230                 :            :         /* Used by hw/xscom.c */
     231                 :            :         uint64_t                xscom_base;
     232                 :            : 
     233                 :            :         /* Used by hw/lpc.c */
     234                 :            :         struct lpcm             *lpc;
     235                 :            : 
     236                 :            :         /* Used by hw/slw.c */
     237                 :            :         uint64_t                slw_base;
     238                 :            :         uint64_t                slw_bar_size;
     239                 :            :         uint64_t                slw_image_size;
     240                 :            : 
     241                 :            :         /* Used by hw/homer.c */
     242                 :            :         uint64_t                homer_base;
     243                 :            :         uint64_t                homer_size;
     244                 :            :         uint64_t                occ_common_base;
     245                 :            :         uint64_t                occ_common_size;
     246                 :            :         uint8_t                 throttle;
     247                 :            : 
     248                 :            :         /* Must hold capi_lock to change */
     249                 :            :         uint8_t                 capp_phb3_attached_mask;
     250                 :            :         uint8_t                 capp_ucode_loaded;
     251                 :            : 
     252                 :            :         /* Used by hw/centaur.c */
     253                 :            :         struct centaur_chip     *centaurs;
     254                 :            : 
     255                 :            :         /* Used by hw/p8-i2c.c */
     256                 :            :         struct list_head        i2cms;
     257                 :            : 
     258                 :            :         /* Used by hw/psi.c */
     259                 :            :         struct psi              *psi;
     260                 :            : 
     261                 :            :         /* Used by hw/fsi-master.c */
     262                 :            :         struct mfsi             *fsi_masters;
     263                 :            : 
     264                 :            :         /* Used by hw/xive.c */
     265                 :            :         struct xive             *xive;
     266                 :            : 
     267                 :            :         struct vas              *vas;
     268                 :            : 
     269                 :            :         /* Used by hw/nx-compress.c */
     270                 :            :         uint64_t                nx_base;
     271                 :            :         /* location code of this chip */
     272                 :            :         const uint8_t           *loc_code;
     273                 :            : 
     274                 :            :         /* Used by hw/sbe-p9.c */
     275                 :            :         struct p9_sbe           *sbe;
     276                 :            : 
     277                 :            :         /* Used by hw/dio-p9.c */
     278                 :            :         struct p9_dio           *dio;
     279                 :            : 
     280                 :            :         /* Used during OCC init */
     281                 :            :         bool                    ex_present;
     282                 :            : 
     283                 :            :         /* Used by hw/vas.c on p10 */
     284                 :            :         uint32_t                primary_topology;
     285                 :            : };
     286                 :            : 
     287                 :            : extern uint32_t pir_to_chip_id(uint32_t pir);
     288                 :            : 
     289                 :            : /*
     290                 :            :  * Note: In P9 fused-core mode, these will return the "normal"
     291                 :            :  * core ID and thread ID (ie, thread ID 0..3)
     292                 :            :  */
     293                 :            : extern uint32_t pir_to_core_id(uint32_t pir);
     294                 :            : extern uint32_t pir_to_thread_id(uint32_t pir);
     295                 :            : 
     296                 :            : /* In P9 fused core mode, this is the "fused" core ID, in
     297                 :            :  * normal core mode or P8, this is the same as pir_to_core_id
     298                 :            :  */
     299                 :            : extern uint32_t pir_to_fused_core_id(uint32_t pir);
     300                 :            : 
     301                 :            : extern struct proc_chip *next_chip(struct proc_chip *chip);
     302                 :            : 
     303                 :            : #define for_each_chip(__c) for (__c=next_chip(NULL); __c; __c=next_chip(__c))
     304                 :            : 
     305                 :            : extern struct proc_chip *get_chip(uint32_t chip_id);
     306                 :            : 
     307                 :            : extern void init_chips(void);
     308                 :            : 
     309                 :            : /* helper to get number of chips in the system */
     310                 :            : static inline int nr_chips(void)
     311                 :            : {
     312                 :            :         struct proc_chip *chip;
     313                 :            :         int nr_chips = 0;
     314                 :            : 
     315                 :            :         for_each_chip(chip)
     316                 :            :                 nr_chips++;
     317                 :            : 
     318                 :            :         return nr_chips;
     319                 :            : }
     320                 :            : 
     321                 :            : /* helper to get location code of a chip */
     322                 :            : static inline const char *chip_loc_code(uint32_t chip_id)
     323                 :            : {
     324                 :            :         struct proc_chip *chip;
     325                 :            : 
     326                 :            :         chip = get_chip(chip_id);
     327                 :            :         if (!chip)
     328                 :            :                 return NULL;
     329                 :            : 
     330                 :            :         return chip->loc_code;
     331                 :            : }
     332                 :            : 
     333                 :            : #endif /* __CHIP_H */
     334                 :            : 

Generated by: LCOV version 1.14