aboutsummaryrefslogtreecommitdiff
path: root/resources/libreboot/patch/kgpe-d16/0066-southbridge-amd-sb700-Do-drive-detection-even-in-AHC.patch
blob: 3c6c1f3781f35199a9e7d3b95f751bb7231c24aa (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
From b199e0e69955a8313cee68c1d589cac5956982b9 Mon Sep 17 00:00:00 2001
From: Timothy Pearson <kb9vqf@pearsoncomputing.net>
Date: Sat, 20 Jun 2015 21:31:15 -0500
Subject: [PATCH 066/146] southbridge/amd/sb700: Do drive detection even in
 AHCI mode

SeaBIOS AHCI drive detection randomly fails for drives present
on the secondary channel of each AHCI SATA BAR.  Forcing native
drive detection in AHCI mode resolves this issue.
---
 src/southbridge/amd/sb700/sata.c |  101 ++++++++++++++++++++------------------
 1 file changed, 54 insertions(+), 47 deletions(-)

diff --git a/src/southbridge/amd/sb700/sata.c b/src/southbridge/amd/sb700/sata.c
index 10dbca2..6afdfdf 100644
--- a/src/southbridge/amd/sb700/sata.c
+++ b/src/southbridge/amd/sb700/sata.c
@@ -301,65 +301,72 @@ static void sata_init(struct device *dev)
 	if (port_count > max_port_count)
 		port_count = max_port_count;
 
-	if (!sata_ahci_mode) {
-		/* RPR7.7 SATA drive detection. */
-		/* Use BAR5+0x128,BAR0 for Primary Slave */
-		/* Use BAR5+0x1A8,BAR0 for Primary Slave */
-		/* Use BAR5+0x228,BAR2 for Secondary Master */
-		/* Use BAR5+0x2A8,BAR2 for Secondary Slave */
-		/* Use BAR5+0x328,PATA_BAR0/2 for Primary/Secondary Master emulation */
-		/* Use BAR5+0x3A8,PATA_BAR0/2 for Primary/Secondary Slave emulation */
-		for (i = 0; i < port_count; i++) {
+	/* RPR7.7 SATA drive detection. */
+	/* Use BAR5+0x128,BAR0 for Primary Slave */
+	/* Use BAR5+0x1A8,BAR0 for Primary Slave */
+	/* Use BAR5+0x228,BAR2 for Secondary Master */
+	/* Use BAR5+0x2A8,BAR2 for Secondary Slave */
+	/* Use BAR5+0x328,PATA_BAR0/2 for Primary/Secondary Master emulation */
+	/* Use BAR5+0x3A8,PATA_BAR0/2 for Primary/Secondary Slave emulation */
+	for (i = 0; i < port_count; i++) {
+		byte = read8(sata_bar5 + 0x128 + 0x80 * i);
+		printk(BIOS_SPEW, "SATA port %i status = %x\n", i, byte);
+		byte &= 0xF;
+		if (byte == 0x1) {
+			/* If the drive status is 0x1 then we see it but we aren't talking to it. */
+			/* Try to do something about it. */
+			printk(BIOS_SPEW, "SATA device detected but not talking. Trying lower speed.\n");
+
+			/* Read in Port-N Serial ATA Control Register */
+			byte = read8(sata_bar5 + 0x12C + 0x80 * i);
+
+			/* Set Reset Bit and 1.5g bit */
+			byte |= 0x11;
+			write8((sata_bar5 + 0x12C + 0x80 * i), byte);
+
+			/* Wait 1ms */
+			mdelay(1);
+
+			/* Clear Reset Bit */
+			byte &= ~0x01;
+			write8((sata_bar5 + 0x12C + 0x80 * i), byte);
+
+			/* Wait 1ms */
+			mdelay(1);
+
+			/* Reread status */
 			byte = read8(sata_bar5 + 0x128 + 0x80 * i);
 			printk(BIOS_SPEW, "SATA port %i status = %x\n", i, byte);
 			byte &= 0xF;
-			if (byte == 0x1) {
-				/* If the drive status is 0x1 then we see it but we aren't talking to it. */
-				/* Try to do something about it. */
-				printk(BIOS_SPEW, "SATA device detected but not talking. Trying lower speed.\n");
-	
-				/* Read in Port-N Serial ATA Control Register */
-				byte = read8(sata_bar5 + 0x12C + 0x80 * i);
-	
-				/* Set Reset Bit and 1.5g bit */
-				byte |= 0x11;
-				write8((sata_bar5 + 0x12C + 0x80 * i), byte);
-	
-				/* Wait 1ms */
-				mdelay(1);
-	
-				/* Clear Reset Bit */
-				byte &= ~0x01;
-				write8((sata_bar5 + 0x12C + 0x80 * i), byte);
-	
-				/* Wait 1ms */
-				mdelay(1);
-	
-				/* Reread status */
-				byte = read8(sata_bar5 + 0x128 + 0x80 * i);
-				printk(BIOS_SPEW, "SATA port %i status = %x\n", i, byte);
-				byte &= 0xF;
+		}
+
+		if (byte == 0x3) {
+			for (j = 0; j < 10; j++) {
+				if (i < 4)
+					current_bar = ((i / 2) == 0) ? sata_bar0 : sata_bar2;
+				else
+					current_bar = ide_bar0;
+				if (!sata_drive_detect(i, current_bar))
+					break;
 			}
-	
-			if (byte == 0x3) {
-				for (j = 0; j < 10; j++) {
-					if (i < 4)
-						current_bar = ((i / 2) == 0) ? sata_bar0 : sata_bar2;
-					else
-						current_bar = ide_bar0;
-					if (!sata_drive_detect(i, current_bar))
-						break;
-				}
+			if (sata_ahci_mode)
+				printk(BIOS_DEBUG, "AHCI device %d is %sready after %i tries\n",
+						i,
+						(j == 10) ? "not " : "",
+						(j == 10) ? j : j + 1);
+			else 
 				printk(BIOS_DEBUG, "%s %s device is %sready after %i tries\n",
 						(i / 2) ? "Secondary" : "Primary",
 						(i % 2 ) ? "Slave" : "Master",
 						(j == 10) ? "not " : "",
 						(j == 10) ? j : j + 1);
-			} else {
+		} else {
+			if (sata_ahci_mode)
+				printk(BIOS_DEBUG, "No AHCI SATA drive on Slot%i\n", i);
+			else
 				printk(BIOS_DEBUG, "No %s %s SATA drive on Slot%i\n",
 						(i / 2) ? "Secondary" : "Primary",
 						(i % 2 ) ? "Slave" : "Master", i);
-			}
 		}
 	}
 
-- 
1.7.9.5