From 03159ba83bd6b01843bd42ffec0e3c3e6fb12429 Mon Sep 17 00:00:00 2001 From: Alan Ott Date: Sun, 20 Aug 2017 15:33:34 -0400 Subject: Silicon/AMD/Styx: Use PcdSataPortMode properly for two controllers The previous implementation used only the lower bits for both the first and second SATA controller, when the upper bits should have been used for the second SATA controller. Also ASSERT that SataChPerSerdes is 2, because the even/odd logic doesn't work if it's not. Signed-off-by: Alan Ott Contributed-under: TianoCore Contribution Agreement 1.1 Reviewed-by: Ard Biesheuvel Reviewed-by: Leif Lindholm --- Silicon/AMD/Styx/Drivers/StyxSataPlatformDxe/InitController.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'Silicon') diff --git a/Silicon/AMD/Styx/Drivers/StyxSataPlatformDxe/InitController.c b/Silicon/AMD/Styx/Drivers/StyxSataPlatformDxe/InitController.c index 78c6819138..ea49cae989 100644 --- a/Silicon/AMD/Styx/Drivers/StyxSataPlatformDxe/InitController.c +++ b/Silicon/AMD/Styx/Drivers/StyxSataPlatformDxe/InitController.c @@ -109,10 +109,15 @@ InitializeSataController ( SataChPerSerdes = FixedPcdGet8 (PcdSataNumChPerSerdes); - for (PortNum = 0; PortNum < SataPortCount; PortNum += SataChPerSerdes) { + // + // SataChPerSerdes must be 2 for the Even/Odd logic in the loop below + // + ASSERT(SataChPerSerdes == 2); + + for (PortNum = StartPort; PortNum < SataPortCount + StartPort; PortNum += SataChPerSerdes) { EvenPort = (UINT32)(FixedPcdGet32 (PcdSataPortMode) >> (PortNum * 2)) & 3; OddPort = (UINT32)(FixedPcdGet32 (PcdSataPortMode) >> ((PortNum+1) * 2)) & 3; - SataPhyInit ((StartPort + PortNum) / SataChPerSerdes, EvenPort, OddPort); + SataPhyInit (PortNum / SataChPerSerdes, EvenPort, OddPort); } // -- cgit v1.2.3