@@ -775,83 +775,6 @@ uint32_t pci_enum_bus(uint8_t bus, struct pci_enum_info *info)
775775 return 0 ;
776776}
777777
778- static int pci_get_capability (uint8_t bus , uint8_t dev , uint8_t fun ,
779- uint8_t cap_id , uint8_t * cap_off )
780- {
781- uint8_t r8 , id ;
782- uint32_t r32 ;
783-
784- r32 = pci_config_read16 (bus , dev , fun , PCI_STATUS_OFFSET );
785- if (!(r32 & PCI_STATUS_CAP_LIST ))
786- return -1 ;
787- r8 = pci_config_read8 (bus , dev , fun , PCI_CAP_OFFSET );
788- while (r8 != 0 ) {
789- id = pci_config_read8 (bus , dev , fun , r8 );
790- if (id == cap_id ) {
791- * cap_off = r8 ;
792- return 0 ;
793- }
794- r8 = pci_config_read8 (bus , dev , fun , r8 + 1 );
795- }
796- return -1 ;
797- }
798-
799- int pcie_retraining_link (uint8_t bus , uint8_t dev , uint8_t fun )
800- {
801- uint16_t link_status , link_control , vid ;
802- uint8_t pcie_cap_off ;
803- int ret , tries ;
804-
805- PCI_DEBUG_PRINTF ("retraining link: %x:%x.%x\r\n" , bus , dev , fun );
806- vid = pci_config_read16 (bus , dev , 0 , PCI_VENDOR_ID_OFFSET );
807- if (vid == 0xffff ) {
808- PCI_DEBUG_PRINTF ("can't find dev: %x:%x.%d\r\n" , bus , dev , fun );
809- return -1 ;
810- }
811-
812- ret = pci_get_capability (bus , dev , fun , PCI_PCIE_CAP_ID , & pcie_cap_off );
813- if (ret != 0 ) {
814- PCI_DEBUG_PRINTF ("can't find PCIE cap pointer\r\n" );
815- return -1 ;
816- }
817-
818- PCI_DEBUG_PRINTF ("pcie cap off: 0x%x\r\n" , pcie_cap_off );
819- link_status = pci_config_read16 (bus , dev , fun ,
820- pcie_cap_off + PCIE_LINK_STATUS_OFF );
821- if (link_status & PCIE_LINK_STATUS_TRAINING ) {
822- PCI_DEBUG_PRINTF ("link already training, waiting...\r\n" );
823- delay (PCIE_TRAINING_TIMEOUT_MS );
824- link_status = pci_config_read16 (bus , dev , fun ,
825- pcie_cap_off + PCIE_LINK_STATUS_OFF );
826- if (link_status & PCIE_LINK_STATUS_TRAINING ) {
827- PCI_DEBUG_PRINTF ("link training error: timeout\r\n" );
828- return -1 ;
829- }
830- }
831-
832- link_control = pci_config_read16 (bus , dev , fun ,
833- pcie_cap_off + PCIE_LINK_CONTROL_OFF );
834- link_control |= PCIE_LINK_CONTROL_RETRAINING ;
835- pci_config_write16 (bus , dev , fun , pcie_cap_off + PCIE_LINK_CONTROL_OFF ,
836- link_control );
837- tries = PCIE_TRAINING_TIMEOUT_MS / 10 ;
838- do {
839- link_status = pci_config_read16 (bus , dev , fun ,
840- pcie_cap_off + PCIE_LINK_STATUS_OFF );
841- if (!(link_status & PCIE_LINK_STATUS_TRAINING ))
842- break ;
843- delay (10 );
844- } while (tries -- );
845-
846- if ((link_status & PCIE_LINK_STATUS_TRAINING )) {
847- PCI_DEBUG_PRINTF ("Timeout reached during retraining\r\n" );
848- return -1 ;
849- }
850-
851- PCI_DEBUG_PRINTF ("retraining complete\r\n" );
852- return 0 ;
853- }
854-
855778int pci_pre_enum (void )
856779{
857780 uint32_t reg ;
0 commit comments