Edward O'Callaghan (eocallaghan(a)alterapraxis.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/6225
-gerrit
commit cc145df33888fe24fe6f808f587bbac13bcf124d
Author: Edward O'Callaghan <eocallaghan(a)alterapraxis.com>
Date: Wed Jul 9 04:55:16 2014 +1000
device/pci_early.c: Mixes up variants of a typedefs to 'u32'
Unfortantly coreboot has to deal with ROMCC's short comings which has
lead to a little bit of confusion due to typedefs. Essentially, coreboot
defines four typedefs:
* 'typedef struct device * device_t' in ramstage not in SIMPLE_DEVICE mode
* 'typedef u32 device_t' in romstage or when SIMPLE_DEVICE is defined
* 'typedef u32 pnp_devfn_t'
* 'typedef u32 pci_devfn_t'
Some early functions make use of 'device_t' over 'pci_devfn_t' and since
the C type-checker does not enforce typedefs to the same type 'u32'
these are never noticed. Fix these so that 'device_t' does not conflict
in romstage for later work. We later plan to have 'pnp_devfn_t' and
'pci_devfn_t' as the only variants of 'u32' and 'device_t' to be a
struct pointer time exclusively.
Change-Id: I948801f5be968a934798f1bad7722649758cd4d3
Signed-off-by: Edward O'Callaghan <eocallaghan(a)alterapraxis.com>
---
src/device/pci_early.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/src/device/pci_early.c b/src/device/pci_early.c
index e31287e..e690211 100644
--- a/src/device/pci_early.c
+++ b/src/device/pci_early.c
@@ -25,8 +25,7 @@
#include <delay.h>
#ifdef __PRE_RAM__
-
-unsigned pci_find_next_capability(device_t dev, unsigned cap, unsigned last)
+unsigned pci_find_next_capability(pci_devfn_t dev, unsigned cap, unsigned last)
{
unsigned pos = 0;
u16 status;
@@ -69,11 +68,11 @@ unsigned pci_find_next_capability(device_t dev, unsigned cap, unsigned last)
return 0;
}
-unsigned pci_find_capability(device_t dev, unsigned cap)
+unsigned pci_find_capability(pci_devfn_t dev, unsigned cap)
{
return pci_find_next_capability(dev, cap, 0);
}
-#endif
+#endif /* __PRE_RAM__ */
#if CONFIG_EARLY_PCI_BRIDGE
Kyösti Mälkki (kyosti.malkki(a)gmail.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/6164
-gerrit
commit 954c27cdfb6cd0851ebb57c03a5e3b87b94569e6
Author: Kyösti Mälkki <kyosti.malkki(a)gmail.com>
Date: Mon Jun 30 07:34:36 2014 +0300
AMD SPI: Optimise for longer writes
Leave it to the implementation of flash->write() to split the writes
to match SPI controller and SPI flash part restrictions. This allows
for some optimisation for auto-address-increment (AAI) commands.
Kconfig AMD_SB_SPI_TX_LEN can be kept as local.
Change-Id: I4a8bc55ab7eb0eeda8f25003a8f5ff2a643ab7a7
Signed-off-by: Kyösti Mälkki <kyosti.malkki(a)gmail.com>
---
src/cpu/amd/agesa/spi.c | 7 +------
src/southbridge/amd/Kconfig | 9 ---------
src/southbridge/amd/agesa/hudson/spi.c | 15 +++++++++++++++
src/southbridge/amd/cimx/sb800/spi.c | 14 ++++++++++++++
4 files changed, 30 insertions(+), 15 deletions(-)
diff --git a/src/cpu/amd/agesa/spi.c b/src/cpu/amd/agesa/spi.c
index 5631053..1c652fd 100644
--- a/src/cpu/amd/agesa/spi.c
+++ b/src/cpu/amd/agesa/spi.c
@@ -40,12 +40,7 @@ void spi_SaveS3info(u32 pos, u32 size, u8 *buf, u32 len)
flash->erase(flash, pos, size);
flash->write(flash, pos, sizeof(len), &len);
-
- u32 nvram_pos;
- for (nvram_pos = 0; nvram_pos < len - CONFIG_AMD_SB_SPI_TX_LEN; nvram_pos += CONFIG_AMD_SB_SPI_TX_LEN) {
- flash->write(flash, nvram_pos + pos + 4, CONFIG_AMD_SB_SPI_TX_LEN, (u8 *)(buf + nvram_pos));
- }
- flash->write(flash, nvram_pos + pos + 4, len % CONFIG_AMD_SB_SPI_TX_LEN, (u8 *)(buf + nvram_pos));
+ flash->write(flash, pos + sizeof(len), len, buf);
flash->spi->rw = SPI_WRITE_FLAG;
spi_release_bus(flash->spi);
diff --git a/src/southbridge/amd/Kconfig b/src/southbridge/amd/Kconfig
index 39aeb09..867afca 100644
--- a/src/southbridge/amd/Kconfig
+++ b/src/southbridge/amd/Kconfig
@@ -14,12 +14,3 @@ source src/southbridge/amd/sb800/Kconfig
source src/southbridge/amd/cimx/Kconfig
source src/southbridge/amd/agesa/Kconfig
source src/southbridge/amd/sr5650/Kconfig
-
-if CPU_AMD_AGESA
-
-config AMD_SB_SPI_TX_LEN
- int
- default 4
- depends on SPI_FLASH
-
-endif
diff --git a/src/southbridge/amd/agesa/hudson/spi.c b/src/southbridge/amd/agesa/hudson/spi.c
index f050a63..2aeb2c0 100644
--- a/src/southbridge/amd/agesa/hudson/spi.c
+++ b/src/southbridge/amd/agesa/hudson/spi.c
@@ -20,6 +20,7 @@
#include <stdlib.h>
#include <string.h>
#include <arch/io.h>
+#include <console/console.h>
#include <spi-generic.h>
#include <device/device.h>
#include <device/pci.h>
@@ -101,6 +102,20 @@ int spi_xfer(struct spi_slave *slave, const void *dout,
u8 count;
bytesout--;
+
+ /*
+ * Check if this is a write command attempting to transfer more bytes
+ * than the controller can handle. Iterations for writes are not
+ * supported here because each SPI write command needs to be preceded
+ * and followed by other SPI commands, and this sequence is controlled
+ * by the SPI chip driver.
+ */
+ if (bytesout > AMD_SB_SPI_TX_LEN) {
+ printk(BIOS_DEBUG, "FCH SPI: Too much to write. Does your SPI chip driver use"
+ " spi_crop_chunk()?\n");
+ return -1;
+ }
+
readoffby1 = bytesout ? 0 : 1;
#if CONFIG_SOUTHBRIDGE_AMD_AGESA_YANGTZE
diff --git a/src/southbridge/amd/cimx/sb800/spi.c b/src/southbridge/amd/cimx/sb800/spi.c
index e5b2407..f38e691 100644
--- a/src/southbridge/amd/cimx/sb800/spi.c
+++ b/src/southbridge/amd/cimx/sb800/spi.c
@@ -20,6 +20,7 @@
#include <stdlib.h>
#include <string.h>
#include <arch/io.h>
+#include <console/console.h>
#include <spi-generic.h>
#include <device/device.h>
#include <device/pci.h>
@@ -74,6 +75,19 @@ int spi_xfer(struct spi_slave *slave, const void *dout,
bytesout--;
+ /*
+ * Check if this is a write command attempting to transfer more bytes
+ * than the controller can handle. Iterations for writes are not
+ * supported here because each SPI write command needs to be preceded
+ * and followed by other SPI commands, and this sequence is controlled
+ * by the SPI chip driver.
+ */
+ if (bytesout > AMD_SB_SPI_TX_LEN) {
+ printk(BIOS_DEBUG, "FCH SPI: Too much to write. Does your SPI chip driver use"
+ " spi_crop_chunk()?\n");
+ return -1;
+ }
+
readoffby1 = bytesout ? 0 : 1;
readwrite = (bytesin + readoffby1) << 4 | bytesout;