2 #include "../port/lib.h"
8 /* bcmstb PCIe controller registers */
10 RC_CFG_VENDOR_VENDOR_SPECIFIC_REG1 = 0x0188/4,
11 RC_CFG_PRIV1_ID_VAL3 = 0x043c/4,
12 RC_DL_MDIO_ADDR = 0x1100/4,
13 RC_DL_MDIO_WR_DATA = 0x1104/4,
14 RC_DL_MDIO_RD_DATA = 0x1108/4,
15 MISC_MISC_CTRL = 0x4008/4,
16 MISC_CPU_2_PCIE_MEM_WIN0_LO = 0x400c/4,
17 MISC_CPU_2_PCIE_MEM_WIN0_HI = 0x4010/4,
18 MISC_RC_BAR1_CONFIG_LO = 0x402c/4,
19 MISC_RC_BAR2_CONFIG_LO = 0x4034/4,
20 MISC_RC_BAR2_CONFIG_HI = 0x4038/4,
21 MISC_RC_BAR3_CONFIG_LO = 0x403c/4,
22 MISC_MSI_BAR_CONFIG_LO = 0x4044/4,
23 MISC_MSI_BAR_CONFIG_HI = 0x4048/4,
24 MISC_MSI_DATA_CONFIG = 0x404c/4,
25 MISC_EOI_CTRL = 0x4060/4,
26 MISC_PCIE_CTRL = 0x4064/4,
27 MISC_PCIE_STATUS = 0x4068/4,
28 MISC_REVISION = 0x406c/4,
29 MISC_CPU_2_PCIE_MEM_WIN0_BASE_LIMIT = 0x4070/4,
30 MISC_CPU_2_PCIE_MEM_WIN0_BASE_HI = 0x4080/4,
31 MISC_CPU_2_PCIE_MEM_WIN0_LIMIT_HI = 0x4084/4,
32 MISC_HARD_PCIE_HARD_DEBUG = 0x4204/4,
34 INTR2_CPU_BASE = 0x4300/4,
35 MSI_INTR2_BASE = 0x4500/4,
43 EXT_CFG_INDEX = 0x9000/4,
44 RGR1_SW_INIT_1 = 0x9210/4,
45 EXT_CFG_DATA = 0x8000/4,
49 #define MSI_TARGET_ADDR 0xFFFFFFFFCULL
51 static u32int *regs = (u32int*)(VIRTIO1 + 0x500000);
53 static Lock pcicfglock;
54 static int pcimaxbno = 0;
55 static int pcimaxdno = 0;
56 static Pcidev* pciroot;
57 static Pcidev* pcilist;
58 static Pcidev* pcitail;
60 typedef struct Pcisiz Pcisiz;
74 static char* bustypes[] = {
102 if((p = malloc(READSTR)) == nil)
103 return fmtstrcpy(fmt, "(tbdfconv)");
107 tbdf = va_arg(fmt->args, int);
108 if(tbdf == BUSUNKNOWN)
109 snprint(p, READSTR, "unknown");
111 type = BUSTYPE(tbdf);
112 if(type < nelem(bustypes))
113 l = snprint(p, READSTR, bustypes[type]);
115 l = snprint(p, READSTR, "%d", type);
116 snprint(p+l, READSTR-l, ".%d.%d.%d",
117 BUSBNO(tbdf), BUSDNO(tbdf), BUSFNO(tbdf));
122 snprint(p, READSTR, "(tbdfconv)");
125 r = fmtstrcpy(fmt, p);
131 static void pcicfginit(void);
134 cfgaddr(int tbdf, int rno)
136 if(BUSBNO(tbdf) == 0 && BUSDNO(tbdf) == 0)
137 return (uchar*)regs + rno;
138 regs[EXT_CFG_INDEX] = BUSBNO(tbdf) << 20 | BUSDNO(tbdf) << 15 | BUSFNO(tbdf) << 12;
140 return ((uchar*)®s[EXT_CFG_DATA]) + rno;
144 pcicfgrw32(int tbdf, int rno, int data, int read)
150 if((p = cfgaddr(tbdf, rno & ~3)) != nil){
156 iunlock(&pcicfglock);
160 pcicfgrw16(int tbdf, int rno, int data, int read)
166 if((p = cfgaddr(tbdf, rno & ~1)) != nil){
172 iunlock(&pcicfglock);
176 pcicfgrw8(int tbdf, int rno, int data, int read)
182 if((p = cfgaddr(tbdf, rno)) != nil){
188 iunlock(&pcicfglock);
193 pcicfgr32(Pcidev* pcidev, int rno)
195 return pcicfgrw32(pcidev->tbdf, rno, 0, 1);
198 pcicfgw32(Pcidev* pcidev, int rno, int data)
200 pcicfgrw32(pcidev->tbdf, rno, data, 0);
203 pcicfgr16(Pcidev* pcidev, int rno)
205 return pcicfgrw16(pcidev->tbdf, rno, 0, 1);
208 pcicfgw16(Pcidev* pcidev, int rno, int data)
210 pcicfgrw16(pcidev->tbdf, rno, data, 0);
213 pcicfgr8(Pcidev* pcidev, int rno)
215 return pcicfgrw8(pcidev->tbdf, rno, 0, 1);
218 pcicfgw8(Pcidev* pcidev, int rno, int data)
220 pcicfgrw8(pcidev->tbdf, rno, data, 0);
224 pcimatch(Pcidev* prev, int vid, int did)
232 if((vid == 0 || prev->vid == vid)
233 && (did == 0 || prev->did == did))
241 pcimatchtbdf(int tbdf)
245 for(pcidev = pcilist; pcidev != nil; pcidev = pcidev->list) {
246 if(pcidev->tbdf == tbdf)
253 pcibarsize(Pcidev *p, int rno)
257 v = pcicfgrw32(p->tbdf, rno, 0, 1);
258 pcicfgrw32(p->tbdf, rno, 0xFFFFFFF0, 0);
259 size = pcicfgrw32(p->tbdf, rno, 0, 1);
262 pcicfgrw32(p->tbdf, rno, v, 0);
264 return -(size & ~0x0F);
268 pcisizcmp(void *a, void *b)
274 return aa->siz - bb->siz;
283 for(m = 1<<(m-1); m != 0; m >>= 1) {
297 pcibusmap(Pcidev *root, uintptr *pmema, uintptr *pioa, int wrreg)
300 int ntb, i, size, rno, hole;
301 uintptr v, mema, ioa, sioa, smema, base, limit;
302 Pcisiz *table, *tptr, *mtb, *itb;
308 for(p = root; p != nil; p = p->link)
311 ntb *= (PciCIS-PciBAR0)/4;
312 table = malloc(2*ntb*sizeof(Pcisiz));
314 panic("pcibusmap: can't allocate memory");
319 * Build a table of sizes
321 for(p = root; p != nil; p = p->link) {
322 if(p->ccrb == 0x06) {
323 if(p->ccru != 0x04 || p->bridge == nil)
328 pcibusmap(p->bridge, &smema, &sioa, 0);
330 hole = pcimask(smema-mema);
335 hole = pcimask(sioa-ioa);
343 itb->siz = p->ioa.size;
348 mtb->siz = p->mema.size;
353 for(i = 0; i <= 5; i++) {
355 v = pcicfgrw32(p->tbdf, rno, 0, 1);
356 size = pcibarsize(p, rno);
360 p->mem[i].size = size;
380 * Sort both tables IO smallest first, Memory largest
382 qsort(table, itb-table, sizeof(Pcisiz), pcisizcmp);
384 qsort(tptr, mtb-tptr, sizeof(Pcisiz), pcisizcmp);
387 * Allocate IO address space on this bus
389 for(tptr = table; tptr < itb; tptr++) {
393 ioa = (ioa+hole-1) & ~(hole-1);
400 p->mem[tptr->bar].bar = ioa|1;
402 pcicfgrw32(p->tbdf, PciBAR0+(tptr->bar*4), ioa|1, 0);
409 * Allocate Memory address space on this bus
411 for(tptr = table+ntb; tptr < mtb; tptr++) {
415 mema = (mema+hole-1) & ~(hole-1);
422 p->mem[tptr->bar].bar = mema;
424 rno = PciBAR0+(tptr->bar*4);
425 if((mema >> 32) != 0){
426 pcicfgrw32(p->tbdf, rno, mema|4, 0);
427 pcicfgrw32(p->tbdf, rno+4, mema >> 32, 0);
429 pcicfgrw32(p->tbdf, rno, mema, 0);
444 * Finally set all the bridge addresses & registers
446 for(p = root; p != nil; p = p->link) {
447 if(p->bridge == nil) {
450 pcicfgw8(p, PciCLS, p->cls);
452 pcicfgrw8(p->tbdf, PciLTR, 64, 0);
454 pcicfgrw16(p->tbdf, PciPCR, p->pcr, 0);
460 limit = base+p->mema.size-1;
461 regs[MISC_CPU_2_PCIE_MEM_WIN0_LO] = base;
462 regs[MISC_CPU_2_PCIE_MEM_WIN0_HI] = base >> 32;
463 base >>= 20, limit >>= 20;
464 regs[MISC_CPU_2_PCIE_MEM_WIN0_BASE_LIMIT] = (base & 0xFFF) << 4 | (limit & 0xFFF) << 20;
465 regs[MISC_CPU_2_PCIE_MEM_WIN0_BASE_HI] = base >> 12;
466 regs[MISC_CPU_2_PCIE_MEM_WIN0_LIMIT_HI] = limit >> 12;
470 limit = base+p->ioa.size-1;
471 v = pcicfgrw32(p->tbdf, PciIBR, 0, 1);
472 v = (v&0xFFFF0000)|(limit & 0xF000)|((base & 0xF000)>>8);
473 pcicfgrw32(p->tbdf, PciIBR, v, 0);
474 v = (limit & 0xFFFF0000)|(base>>16);
475 pcicfgrw32(p->tbdf, PciIUBR, v, 0);
478 limit = base+p->mema.size-1;
479 v = (limit & 0xFFF00000)|((base & 0xFFF00000)>>16);
480 pcicfgrw32(p->tbdf, PciMBR, v, 0);
483 * Disable memory prefetch
485 pcicfgrw32(p->tbdf, PciPMBR, 0x0000FFFF, 0);
486 pcicfgrw8(p->tbdf, PciLTR, 64, 0);
491 p->pcr |= IOen|MEMen|MASen;
492 pcicfgrw32(p->tbdf, PciPCR, 0xFFFF0000|p->pcr, 0);
496 pcibusmap(p->bridge, &smema, &sioa, 1);
501 pcilscan(int bno, Pcidev** list, Pcidev *parent)
503 Pcidev *p, *head, *tail;
504 int dno, fno, i, hdt, l, maxfno, maxubn, rno, sbn, tbdf, ubn;
509 for(dno = 0; dno <= pcimaxdno; dno++){
511 for(fno = 0; fno <= maxfno; fno++){
513 * For this possible device, form the
514 * bus+device+function triplet needed to address it
515 * and try to read the vendor and device ID.
516 * If successful, allocate a device struct and
517 * start to fill it in with some useful information
518 * from the device's configuration space.
520 tbdf = MKBUS(BusPCI, bno, dno, fno);
521 l = pcicfgrw32(tbdf, PciVID, 0, 1);
522 if(l == 0xFFFFFFFF || l == 0)
524 p = malloc(sizeof(*p));
526 panic("pcilscan: no memory");
537 p->pcr = pcicfgr16(p, PciPCR);
538 p->rid = pcicfgr8(p, PciRID);
539 p->ccrp = pcicfgr8(p, PciCCRp);
540 p->ccru = pcicfgr8(p, PciCCRu);
541 p->ccrb = pcicfgr8(p, PciCCRb);
542 p->cls = pcicfgr8(p, PciCLS);
543 p->ltr = pcicfgr8(p, PciLTR);
545 p->intl = pcicfgr8(p, PciINTL);
548 * If the device is a multi-function device adjust the
549 * loop count so all possible functions are checked.
551 hdt = pcicfgr8(p, PciHDT);
556 * If appropriate, read the base address registers
557 * and work out the sizes.
560 case 0x00: /* prehistoric */
561 case 0x01: /* mass storage controller */
562 case 0x02: /* network controller */
563 case 0x03: /* display controller */
564 case 0x04: /* multimedia device */
565 case 0x07: /* simple comm. controllers */
566 case 0x08: /* base system peripherals */
567 case 0x09: /* input devices */
568 case 0x0A: /* docking stations */
569 case 0x0B: /* processors */
570 case 0x0C: /* serial bus controllers */
571 case 0x0D: /* wireless controllers */
572 case 0x0E: /* intelligent I/O controllers */
573 case 0x0F: /* sattelite communication controllers */
574 case 0x10: /* encryption/decryption controllers */
575 case 0x11: /* signal processing controllers */
576 if((hdt & 0x7F) != 0)
579 for(i = 0; i <= 5; i++) {
580 p->mem[i].bar = pcicfgr32(p, rno);
581 p->mem[i].size = pcibarsize(p, rno);
582 if((p->mem[i].bar & 7) == 4 && i < 5){
584 p->mem[i].bar |= (uintptr)pcicfgr32(p, rno) << 32;
591 case 0x05: /* memory controller */
592 case 0x06: /* bridge device */
607 for(p = head; p != nil; p = p->link){
609 * Find PCI-PCI bridges and recursively descend the tree.
611 if(p->ccrb != 0x06 || p->ccru != 0x04)
615 * If the secondary or subordinate bus number is not
616 * initialised try to do what the PCI BIOS should have
617 * done and fill in the numbers as the tree is descended.
618 * On the way down the subordinate bus number is set to
619 * the maximum as it's not known how many buses are behind
620 * this one; the final value is set on the way back up.
622 sbn = pcicfgr8(p, PciSBN);
623 ubn = pcicfgr8(p, PciUBN);
625 if(sbn == 0 || ubn == 0) {
628 * Make sure memory, I/O and master enables are
629 * off, set the primary, secondary and subordinate
630 * bus numbers and clear the secondary status before
631 * attempting to scan the secondary bus.
633 * Initialisation of the bridge should be done here.
635 pcicfgw32(p, PciPCR, 0xFFFF0000);
636 l = (MaxUBN<<16)|(sbn<<8)|bno;
637 pcicfgw32(p, PciPBN, l);
638 pcicfgw16(p, PciSPSR, 0xFFFF);
639 maxubn = pcilscan(sbn, &p->bridge, p);
640 l = (maxubn<<16)|(sbn<<8)|bno;
642 pcicfgw32(p, PciPBN, l);
647 pcilscan(sbn, &p->bridge, p);
659 fmtinstall('T', tbdffmt);
661 pcilscan(0, &pciroot, nil);
664 * Work out how big the top bus is
668 pcibusmap(pciroot, &mema, &ioa, 0);
671 * Align the windows and map it
675 pcibusmap(pciroot, &mema, &ioa, 1);
686 print("bus dev type vid did intl memory\n");
688 for(t = p; t != nil; t = t->link) {
689 print("%d %2d/%d %.2ux %.2ux %.2ux %.4ux %.4ux %3d ",
690 BUSBNO(t->tbdf), BUSDNO(t->tbdf), BUSFNO(t->tbdf),
691 t->ccrb, t->ccru, t->ccrp, t->vid, t->did, t->intl);
693 for(i = 0; i < nelem(p->mem); i++) {
694 if(t->mem[i].size == 0)
696 print("%d:%llux %d ", i,
697 (uvlong)t->mem[i].bar, t->mem[i].size);
700 print("->%d", BUSBNO(t->bridge->tbdf));
720 pcicfgw16(p, PciPCR, p->pcr);
727 pcicfgw16(p, PciPCR, p->pcr);
734 pcicfgw16(p, PciPCR, p->pcr);
741 pcicfgw16(p, PciPCR, p->pcr);
748 pcicfgw16(p, PciPCR, p->pcr);
755 pcicfgw16(p, PciPCR, p->pcr);
759 enumcaps(Pcidev *p, int (*fmatch)(Pcidev*, int, int, int), int arg)
763 /* status register bit 4 has capabilities */
764 if((pcicfgr16(p, PciPSR) & 1<<4) == 0)
766 switch(pcicfgr8(p, PciHDT) & 0x7F){
770 case 1: /* pci to pci bridge */
773 case 2: /* cardbus bridge */
778 off = pcicfgr8(p, off);
779 if(off < 0x40 || (off & 3))
782 cap = pcicfgr8(p, off);
785 r = (*fmatch)(p, cap, off, arg);
796 matchcap(Pcidev *, int cap, int, int arg)
802 matchhtcap(Pcidev *p, int cap, int off, int arg)
808 if(arg == 0x00 || arg == 0x20)
812 cap = pcicfgr8(p, off+3);
813 return (cap & mask) != arg;
817 pcicap(Pcidev *p, int cap)
819 return enumcaps(p, matchcap, cap);
823 pcinextcap(Pcidev *pci, int offset)
826 if((pcicfgr16(pci, PciPSR) & (1<<4)) == 0)
827 return 0; /* no capabilities */
830 return pcicfgr8(pci, offset+1) & ~3;
834 pcihtcap(Pcidev *p, int cap)
836 return enumcaps(p, matchhtcap, cap);
840 pcigetpmrb(Pcidev* p)
844 return p->pmrb = pcicap(p, PciCapPMG);
852 if((ptr = pcigetpmrb(p)) == -1)
856 * Power Management Register Block:
857 * offset 0: Capability ID
858 * 1: next item pointer
861 * 6: bridge support extensions
864 pmcsr = pcicfgr16(p, ptr+4);
866 return pmcsr & 0x0003;
870 pcisetpms(Pcidev* p, int state)
872 int ostate, pmc, pmcsr, ptr;
874 if((ptr = pcigetpmrb(p)) == -1)
877 pmc = pcicfgr16(p, ptr+2);
878 pmcsr = pcicfgr16(p, ptr+4);
879 ostate = pmcsr & 0x0003;
899 pcicfgw16(p, ptr+4, pmcsr);
913 pcienable(p->parent);
915 switch(pcisetpms(p, 0)){
917 print("pcienable %T: wakeup from D1\n", p->tbdf);
920 print("pcienable %T: wakeup from D2\n", p->tbdf);
922 delay(100); /* B2: minimum delay 50ms */
924 delay(1); /* D2: minimum delay 200µs */
927 print("pcienable %T: wakeup from D3\n", p->tbdf);
928 delay(100); /* D3: minimum delay 50ms */
930 /* restore registers */
931 for(i = 0; i < 6; i++)
932 pcicfgw32(p, PciBAR0+i*4, p->mem[i].bar);
933 pcicfgw8(p, PciINTL, p->intl);
934 pcicfgw8(p, PciLTR, p->ltr);
935 pcicfgw8(p, PciCLS, p->cls);
936 pcicfgw16(p, PciPCR, p->pcr);
941 pcr = IOen|MEMen|MASen;
944 for(i = 0; i < 6; i++){
945 if(p->mem[i].size == 0)
947 if(p->mem[i].bar & 1)
954 if((p->pcr & pcr) != pcr){
955 print("pcienable %T: pcr %ux->%ux\n", p->tbdf, p->pcr, p->pcr|pcr);
957 pcicfgrw32(p->tbdf, PciPCR, 0xFFFF0000|p->pcr, 0);
962 pcidisable(Pcidev *p)
970 MSICtrl = 0x02, /* message control register (16 bit) */
971 MSIAddr = 0x04, /* message address register (64 bit) */
972 MSIData32 = 0x08, /* message data register for 32 bit MSI (16 bit) */
973 MSIData64 = 0x0C, /* message data register for 64 bit MSI (16 bit) */
976 typedef struct Pciisr Pciisr;
978 void (*f)(Ureg*, void*);
983 static Pciisr pciisr[32];
984 static Lock pciisrlk;
987 pciintrenable(int tbdf, void (*f)(Ureg*, void*), void *a)
995 if((p = pcimatchtbdf(tbdf)) == nil){
996 print("pciintrenable: %T: unknown device\n", tbdf);
999 if((cap = pcicap(p, PciCapMSI)) < 0){
1000 print("pciintrenable: %T: no MSI cap\n", tbdf);
1005 for(isr = pciisr; isr < &pciisr[nelem(pciisr)]; isr++){
1008 regs[MSI_INTR2_BASE + INTR_MASK_SET] = 1 << (isr-pciisr);
1012 for(isr = pciisr; isr < &pciisr[nelem(pciisr)]; isr++){
1017 regs[MSI_INTR2_BASE + INTR_CLR] = 1 << (isr-pciisr);
1018 regs[MSI_INTR2_BASE + INTR_MASK_CLR] = 1 << (isr-pciisr);
1024 if(isr >= &pciisr[nelem(pciisr)]){
1025 print("pciintrenable: %T: out of isr slots\n", tbdf);
1029 adr = MSI_TARGET_ADDR;
1030 ok64 = (pcicfgr16(p, cap + MSICtrl) & (1<<7)) != 0;
1031 pcicfgw32(p, cap + MSIAddr, adr);
1032 if(ok64) pcicfgw32(p, cap + MSIAddr + 4, adr>>32);
1033 dat = regs[MISC_MSI_DATA_CONFIG];
1034 dat = ((dat >> 16) & (dat & 0xFFFF)) | (isr-pciisr);
1035 pcicfgw16(p, cap + (ok64 ? MSIData64 : MSIData32), dat);
1036 pcicfgw16(p, cap + MSICtrl, 1);
1040 pciintrdisable(int tbdf, void (*f)(Ureg*, void*), void *a)
1045 for(isr = pciisr; isr < &pciisr[nelem(pciisr)]; isr++){
1046 if(isr->p != nil && isr->p->tbdf == tbdf && isr->f == f && isr->a == a){
1047 regs[MSI_INTR2_BASE + INTR_MASK_SET] = 1 << (isr-pciisr);
1058 pciinterrupt(Ureg *ureg, void*)
1063 sts = regs[MSI_INTR2_BASE + INTR_STATUS];
1066 regs[MSI_INTR2_BASE + INTR_CLR] = sts;
1067 for(isr = pciisr; sts != 0 && isr < &pciisr[nelem(pciisr)]; isr++, sts>>=1){
1068 if((sts & 1) != 0 && isr->f != nil)
1069 (*isr->f)(ureg, isr->a);
1071 regs[MISC_EOI_CTRL] = 1;
1077 int log2dmasize = 30; // 1GB
1079 regs[RGR1_SW_INIT_1] |= 3;
1081 regs[RGR1_SW_INIT_1] &= ~2;
1082 regs[MISC_PCIE_CTRL] &= ~5;
1085 regs[MISC_HARD_PCIE_HARD_DEBUG] &= ~0x08000000;
1088 regs[MSI_INTR2_BASE + INTR_CLR] = -1;
1089 regs[MSI_INTR2_BASE + INTR_MASK_SET] = -1;
1091 regs[MISC_CPU_2_PCIE_MEM_WIN0_LO] = 0;
1092 regs[MISC_CPU_2_PCIE_MEM_WIN0_HI] = 0;
1093 regs[MISC_CPU_2_PCIE_MEM_WIN0_BASE_LIMIT] = 0;
1094 regs[MISC_CPU_2_PCIE_MEM_WIN0_BASE_HI] = 0;
1095 regs[MISC_CPU_2_PCIE_MEM_WIN0_LIMIT_HI] = 0;
1097 // SCB_ACCESS_EN, CFG_READ_UR_MODE, MAX_BURST_SIZE_128, SCB0SIZE
1098 regs[MISC_MISC_CTRL] = 1<<12 | 1<<13 | 0<<20 | (log2dmasize-15)<<27;
1100 regs[MISC_RC_BAR2_CONFIG_LO] = (log2dmasize-15);
1101 regs[MISC_RC_BAR2_CONFIG_HI] = 0;
1103 regs[MISC_RC_BAR1_CONFIG_LO] = 0;
1104 regs[MISC_RC_BAR3_CONFIG_LO] = 0;
1106 regs[MISC_MSI_BAR_CONFIG_LO] = MSI_TARGET_ADDR | 1;
1107 regs[MISC_MSI_BAR_CONFIG_HI] = MSI_TARGET_ADDR>>32;
1108 regs[MISC_MSI_DATA_CONFIG] = 0xFFF86540;
1109 intrenable(IRQpci, pciinterrupt, nil, BUSUNKNOWN, "pci");
1112 regs[(0xAC + 12)/4] = (regs[(0xAC + 12)/4] & ~15) | 2; // linkcap
1113 regs[(0xAC + 48)/4] = (regs[(0xAC + 48)/4] & ~15) | 2; // linkctl2
1115 regs[RGR1_SW_INIT_1] &= ~1;
1118 if((regs[MISC_PCIE_STATUS] & 0x30) != 0x30){
1119 print("pcireset: phy link is down\n");
1123 regs[RC_CFG_PRIV1_ID_VAL3] = 0x060400;
1124 regs[RC_CFG_VENDOR_VENDOR_SPECIFIC_REG1] &= ~0xC;
1125 regs[MISC_HARD_PCIE_HARD_DEBUG] |= 2;