| 425 | } |
| 426 | |
| 427 | static int |
| 428 | gicv3_its_table_init(device_t dev, struct gicv3_its_softc *sc) |
| 429 | { |
| 430 | vm_offset_t table; |
| 431 | vm_paddr_t paddr; |
| 432 | uint64_t cache, reg, share, tmp, type; |
| 433 | size_t esize, its_tbl_size, nidents, nitspages, npages; |
| 434 | int i, page_size; |
| 435 | int devbits; |
| 436 | |
| 437 | if ((sc->sc_its_flags & ITS_FLAGS_ERRATA_CAVIUM_22375) != 0) { |
| 438 | /* |
| 439 | * GITS_TYPER[17:13] of ThunderX reports that device IDs |
| 440 | * are to be 21 bits in length. The entry size of the ITS |
| 441 | * table can be read from GITS_BASERn[52:48] and on ThunderX |
| 442 | * is supposed to be 8 bytes in length (for device table). |
| 443 | * Finally the page size that is to be used by ITS to access |
| 444 | * this table will be set to 64KB. |
| 445 | * |
| 446 | * This gives 0x200000 entries of size 0x8 bytes covered by |
| 447 | * 256 pages each of which 64KB in size. The number of pages |
| 448 | * (minus 1) should then be written to GITS_BASERn[7:0]. In |
| 449 | * that case this value would be 0xFF but on ThunderX the |
| 450 | * maximum value that HW accepts is 0xFD. |
| 451 | * |
| 452 | * Set an arbitrary number of device ID bits to 20 in order |
| 453 | * to limit the number of entries in ITS device table to |
| 454 | * 0x100000 and the table size to 8MB. |
| 455 | */ |
| 456 | devbits = 20; |
| 457 | cache = 0; |
| 458 | } else { |
| 459 | devbits = GITS_TYPER_DEVB(gic_its_read_8(sc, GITS_TYPER)); |
| 460 | cache = GITS_BASER_CACHE_WAWB; |
| 461 | } |
| 462 | share = GITS_BASER_SHARE_IS; |
| 463 | page_size = PAGE_SIZE_64K; |
| 464 | |
| 465 | for (i = 0; i < GITS_BASER_NUM; i++) { |
| 466 | reg = gic_its_read_8(sc, GITS_BASER(i)); |
| 467 | /* The type of table */ |
| 468 | type = GITS_BASER_TYPE(reg); |
| 469 | /* The table entry size */ |
| 470 | esize = GITS_BASER_ESIZE(reg); |
| 471 | |
| 472 | switch(type) { |
| 473 | case GITS_BASER_TYPE_DEV: |
| 474 | nidents = (1 << devbits); |
| 475 | its_tbl_size = esize * nidents; |
| 476 | its_tbl_size = roundup2(its_tbl_size, PAGE_SIZE_64K); |
| 477 | break; |
| 478 | case GITS_BASER_TYPE_VP: |
| 479 | case GITS_BASER_TYPE_PP: /* Undocumented? */ |
| 480 | case GITS_BASER_TYPE_IC: |
| 481 | its_tbl_size = page_size; |
| 482 | break; |
| 483 | default: |
| 484 | continue; |
no test coverage detected