mail.coreboot.org
Sign In
Sign Up
Sign In
Sign Up
Manage this list
×
Keyboard Shortcuts
Thread View
j
: Next unread message
k
: Previous unread message
j a
: Jump to all threads
j l
: Jump to MailingList overview
2024
November
October
September
August
July
June
May
April
March
February
January
2023
December
November
October
September
August
July
June
May
April
March
February
January
2022
December
November
October
September
August
July
June
May
April
March
February
January
2021
December
November
October
September
August
July
June
May
April
March
February
January
2020
December
November
October
September
August
July
June
May
April
March
February
January
2019
December
November
October
September
August
July
June
May
April
March
February
January
2018
December
November
October
September
August
July
June
May
April
March
February
January
2017
December
November
October
September
August
July
June
May
April
March
February
January
2016
December
November
October
September
August
July
June
May
April
March
February
January
2015
December
November
October
September
August
July
June
May
April
March
February
January
2014
December
November
October
September
August
July
June
May
April
March
February
January
2013
December
November
October
September
August
July
June
May
April
March
List overview
Download
coreboot-gerrit
July 2014
----- 2024 -----
November 2024
October 2024
September 2024
August 2024
July 2024
June 2024
May 2024
April 2024
March 2024
February 2024
January 2024
----- 2023 -----
December 2023
November 2023
October 2023
September 2023
August 2023
July 2023
June 2023
May 2023
April 2023
March 2023
February 2023
January 2023
----- 2022 -----
December 2022
November 2022
October 2022
September 2022
August 2022
July 2022
June 2022
May 2022
April 2022
March 2022
February 2022
January 2022
----- 2021 -----
December 2021
November 2021
October 2021
September 2021
August 2021
July 2021
June 2021
May 2021
April 2021
March 2021
February 2021
January 2021
----- 2020 -----
December 2020
November 2020
October 2020
September 2020
August 2020
July 2020
June 2020
May 2020
April 2020
March 2020
February 2020
January 2020
----- 2019 -----
December 2019
November 2019
October 2019
September 2019
August 2019
July 2019
June 2019
May 2019
April 2019
March 2019
February 2019
January 2019
----- 2018 -----
December 2018
November 2018
October 2018
September 2018
August 2018
July 2018
June 2018
May 2018
April 2018
March 2018
February 2018
January 2018
----- 2017 -----
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
February 2017
January 2017
----- 2016 -----
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
----- 2015 -----
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
----- 2014 -----
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
----- 2013 -----
December 2013
November 2013
October 2013
September 2013
August 2013
July 2013
June 2013
May 2013
April 2013
March 2013
coreboot-gerrit@coreboot.org
1 participants
861 discussions
Start a n
N
ew thread
Patch set updated for coreboot: 3a82651 SPI: Split writes using spi_crop_chunk()
by Kyösti Mälkki
01 Jul '14
01 Jul '14
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/6163
-gerrit commit 3a8265160b7589c72e81a0e60973747edde53608 Author: Kyösti Mälkki <kyosti.malkki(a)gmail.com> Date: Sun Jun 29 16:17:33 2014 +0300 SPI: Split writes using spi_crop_chunk() SPI controllers in Intel and AMD bridges have a slightly different restriction on how long transactions they can handle. Change-Id: I3d149d4b7e7e9633482a153d5e380a86c553d871 Signed-off-by: Kyösti Mälkki <kyosti.malkki(a)gmail.com> --- src/drivers/spi/adesto.c | 4 ++-- src/drivers/spi/amic.c | 4 ++-- src/drivers/spi/gigadevice.c | 4 ++-- src/drivers/spi/macronix.c | 5 ++--- src/drivers/spi/stmicro.c | 4 ++-- src/drivers/spi/winbond.c | 4 ++-- src/include/spi-generic.h | 2 ++ src/include/spi_flash.h | 8 -------- src/soc/intel/baytrail/spi.c | 7 ++++++- src/soc/intel/fsp_baytrail/spi.c | 7 ++++++- src/southbridge/amd/agesa/hudson/spi.c | 6 ++++++ src/southbridge/amd/cimx/sb800/spi.c | 7 +++++++ src/southbridge/intel/common/spi.c | 7 ++++++- 13 files changed, 45 insertions(+), 24 deletions(-) diff --git a/src/drivers/spi/adesto.c b/src/drivers/spi/adesto.c index 9dc8e14..50e5883 100644 --- a/src/drivers/spi/adesto.c +++ b/src/drivers/spi/adesto.c @@ -100,7 +100,7 @@ static int adesto_write(struct spi_flash *flash, for (actual = 0; actual < len; actual += chunk_len) { chunk_len = min(len - actual, page_size - byte_addr); - chunk_len = min(chunk_len, CONTROLLER_PAGE_LIMIT); + chunk_len = spi_crop_chunk(sizeof(cmd), chunk_len); cmd[0] = CMD_AT25DF_PP; cmd[1] = (offset >> 16) & 0xff; @@ -118,7 +118,7 @@ static int adesto_write(struct spi_flash *flash, goto out; } - ret = spi_flash_cmd_write(flash->spi, cmd, 4, + ret = spi_flash_cmd_write(flash->spi, cmd, sizeof(cmd), buf + actual, chunk_len); if (ret < 0) { printk(BIOS_WARNING, "SF: adesto Page Program failed\n"); diff --git a/src/drivers/spi/amic.c b/src/drivers/spi/amic.c index 4cccc71..63a68a5 100644 --- a/src/drivers/spi/amic.c +++ b/src/drivers/spi/amic.c @@ -82,7 +82,7 @@ static int amic_write(struct spi_flash *flash, for (actual = 0; actual < len; actual += chunk_len) { chunk_len = min(len - actual, page_size - byte_addr); - chunk_len = min(chunk_len, CONTROLLER_PAGE_LIMIT); + chunk_len = spi_crop_chunk(sizeof(cmd), chunk_len); cmd[0] = CMD_A25_PP; cmd[1] = (offset >> 16) & 0xff; @@ -100,7 +100,7 @@ static int amic_write(struct spi_flash *flash, goto out; } - ret = spi_flash_cmd_write(flash->spi, cmd, 4, + ret = spi_flash_cmd_write(flash->spi, cmd, sizeof(cmd), buf + actual, chunk_len); if (ret < 0) { printk(BIOS_WARNING, "SF: AMIC Page Program failed\n"); diff --git a/src/drivers/spi/gigadevice.c b/src/drivers/spi/gigadevice.c index 3fb89c7..783d321 100644 --- a/src/drivers/spi/gigadevice.c +++ b/src/drivers/spi/gigadevice.c @@ -141,7 +141,7 @@ static int gigadevice_write(struct spi_flash *flash, u32 offset, for (actual = 0; actual < len; actual += chunk_len) { chunk_len = min(len - actual, page_size - byte_addr); - chunk_len = min(chunk_len, CONTROLLER_PAGE_LIMIT); + chunk_len = spi_crop_chunk(sizeof(cmd), chunk_len); ret = spi_flash_cmd(flash->spi, CMD_GD25_WREN, NULL, 0); if (ret < 0) { @@ -161,7 +161,7 @@ static int gigadevice_write(struct spi_flash *flash, u32 offset, cmd[0], cmd[1], cmd[2], cmd[3], chunk_len); #endif - ret = spi_flash_cmd_write(flash->spi, cmd, 4, + ret = spi_flash_cmd_write(flash->spi, cmd, sizeof(cmd), buf + actual, chunk_len); if (ret < 0) { printk(BIOS_WARNING, diff --git a/src/drivers/spi/macronix.c b/src/drivers/spi/macronix.c index 3611599..6e910f6 100644 --- a/src/drivers/spi/macronix.c +++ b/src/drivers/spi/macronix.c @@ -144,13 +144,12 @@ static int macronix_write(struct spi_flash *flash, ret = 0; for (actual = 0; actual < len; actual += chunk_len) { chunk_len = min(len - actual, page_size - byte_addr); - chunk_len = min(chunk_len, CONTROLLER_PAGE_LIMIT); + chunk_len = spi_crop_chunk(sizeof(cmd), chunk_len); cmd[0] = CMD_MX25XX_PP; cmd[1] = (offset >> 16) & 0xff; cmd[2] = (offset >> 8) & 0xff; cmd[3] = offset & 0xff; - #if CONFIG_DEBUG_SPI_FLASH printk(BIOS_SPEW, "PP: 0x%p => cmd = { 0x%02x 0x%02x%02x%02x }" " chunk_len = %zu\n", @@ -163,7 +162,7 @@ static int macronix_write(struct spi_flash *flash, break; } - ret = spi_flash_cmd_write(flash->spi, cmd, 4, + ret = spi_flash_cmd_write(flash->spi, cmd, sizeof(cmd), buf + actual, chunk_len); if (ret < 0) { printk(BIOS_WARNING, "SF: Macronix Page Program failed\n"); diff --git a/src/drivers/spi/stmicro.c b/src/drivers/spi/stmicro.c index c825bd0..bc7969d 100644 --- a/src/drivers/spi/stmicro.c +++ b/src/drivers/spi/stmicro.c @@ -155,7 +155,7 @@ static int stmicro_write(struct spi_flash *flash, for (actual = 0; actual < len; actual += chunk_len) { chunk_len = min(len - actual, page_size - byte_addr); - chunk_len = min(chunk_len, CONTROLLER_PAGE_LIMIT); + chunk_len = spi_crop_chunk(sizeof(cmd), chunk_len); cmd[0] = CMD_M25PXX_PP; cmd[1] = (offset >> 16) & 0xff; @@ -173,7 +173,7 @@ static int stmicro_write(struct spi_flash *flash, goto out; } - ret = spi_flash_cmd_write(flash->spi, cmd, 4, + ret = spi_flash_cmd_write(flash->spi, cmd, sizeof(cmd), buf + actual, chunk_len); if (ret < 0) { printk(BIOS_WARNING, "SF: STMicro Page Program failed\n"); diff --git a/src/drivers/spi/winbond.c b/src/drivers/spi/winbond.c index eb0868e..7ddd312 100644 --- a/src/drivers/spi/winbond.c +++ b/src/drivers/spi/winbond.c @@ -134,7 +134,7 @@ static int winbond_write(struct spi_flash *flash, for (actual = 0; actual < len; actual += chunk_len) { chunk_len = min(len - actual, page_size - byte_addr); - chunk_len = min(chunk_len, CONTROLLER_PAGE_LIMIT); + chunk_len = spi_crop_chunk(sizeof(cmd), chunk_len); cmd[0] = CMD_W25_PP; cmd[1] = (offset >> 16) & 0xff; @@ -152,7 +152,7 @@ static int winbond_write(struct spi_flash *flash, goto out; } - ret = spi_flash_cmd_write(flash->spi, cmd, 4, + ret = spi_flash_cmd_write(flash->spi, cmd, sizeof(cmd), buf + actual, chunk_len); if (ret < 0) { printk(BIOS_WARNING, "SF: Winbond Page Program failed\n"); diff --git a/src/include/spi-generic.h b/src/include/spi-generic.h index 6cdb87a..e92e56c 100644 --- a/src/include/spi-generic.h +++ b/src/include/spi-generic.h @@ -181,6 +181,8 @@ void spi_cs_deactivate(struct spi_slave *slave); */ void spi_set_speed(struct spi_slave *slave, uint32_t hz); +unsigned int spi_crop_chunk(unsigned int cmd_len, unsigned int buf_len); + /*----------------------------------------------------------------------- * Write 8 bits, then read 8 bits. * slave: The SPI slave we're communicating with diff --git a/src/include/spi_flash.h b/src/include/spi_flash.h index 8e51471..b424b4b 100644 --- a/src/include/spi_flash.h +++ b/src/include/spi_flash.h @@ -39,14 +39,6 @@ const typeof( ((type *)0)->member ) *__mptr = (ptr); \ (type *)( (char *)__mptr - offsetof(type,member) );}) -#define CONFIG_ICH_SPI -#ifdef CONFIG_ICH_SPI -#define CONTROLLER_PAGE_LIMIT 64 -#else -/* any number larger than 4K would do, actually */ -#define CONTROLLER_PAGE_LIMIT ((int)(~0U>>1)) -#endif - struct spi_flash { struct spi_slave *spi; diff --git a/src/soc/intel/baytrail/spi.c b/src/soc/intel/baytrail/spi.c index 5ac42c2..b66f6dc 100644 --- a/src/soc/intel/baytrail/spi.c +++ b/src/soc/intel/baytrail/spi.c @@ -500,6 +500,11 @@ static int ich_status_poll(u16 bitmask, int wait_til_set) return -1; } +unsigned int spi_crop_chunk(unsigned int cmd_len, unsigned int buf_len) +{ + return min(cntlr.databytes, buf_len); +} + int spi_xfer(struct spi_slave *slave, const void *dout, unsigned int bitsout, void *din, unsigned int bitsin) { @@ -594,7 +599,7 @@ int spi_xfer(struct spi_slave *slave, const void *dout, */ if (trans.bytesout > cntlr.databytes) { printk(BIOS_DEBUG, "ICH SPI: Too much to write. Does your SPI chip driver use" - " CONTROLLER_PAGE_LIMIT?\n"); + " spi_crop_chunk()?\n"); return -1; } diff --git a/src/soc/intel/fsp_baytrail/spi.c b/src/soc/intel/fsp_baytrail/spi.c index ddec2e0..c12dd52 100644 --- a/src/soc/intel/fsp_baytrail/spi.c +++ b/src/soc/intel/fsp_baytrail/spi.c @@ -498,6 +498,11 @@ static int ich_status_poll(u16 bitmask, int wait_til_set) return -1; } +unsigned int spi_crop_chunk(unsigned int cmd_len, unsigned int buf_len) +{ + return min(cntlr.databytes, buf_len); +} + int spi_xfer(struct spi_slave *slave, const void *dout, unsigned int bitsout, void *din, unsigned int bitsin) { @@ -591,7 +596,7 @@ int spi_xfer(struct spi_slave *slave, const void *dout, */ if (trans.bytesout > cntlr.databytes) { printk(BIOS_DEBUG, "ICH SPI: Too much to write. Does your SPI chip driver use" - " CONTROLLER_PAGE_LIMIT?\n"); + " spi_crop_chunk()?\n"); return -1; } diff --git a/src/southbridge/amd/agesa/hudson/spi.c b/src/southbridge/amd/agesa/hudson/spi.c index 573dd3d..3f3543a 100644 --- a/src/southbridge/amd/agesa/hudson/spi.c +++ b/src/southbridge/amd/agesa/hudson/spi.c @@ -42,6 +42,7 @@ static int bus_claimed = 0; #define SPI_REG_CNTRL11 0xd #define CNTRL11_FIFOPTR_MASK 0x07 +#define AMD_SB_SPI_TX_LEN 64 static u32 spibar; @@ -86,6 +87,11 @@ void spi_init(void) spibar = pci_read_config32(dev, 0xA0) & ~0x1F; } +unsigned int spi_crop_chunk(unsigned int cmd_len, unsigned int buf_len) +{ + return min(AMD_SB_SPI_TX_LEN - cmd_len, buf_len); +} + int spi_xfer(struct spi_slave *slave, const void *dout, unsigned int bitsout, void *din, unsigned int bitsin) { diff --git a/src/southbridge/amd/cimx/sb800/spi.c b/src/southbridge/amd/cimx/sb800/spi.c index a1cdf55..f8cea7e 100644 --- a/src/southbridge/amd/cimx/sb800/spi.c +++ b/src/southbridge/amd/cimx/sb800/spi.c @@ -32,6 +32,8 @@ static int bus_claimed = 0; #endif +#define AMD_SB_SPI_TX_LEN 8 + static u32 spibar; static void reset_internal_fifo_pointer(void) @@ -56,6 +58,11 @@ void spi_init() spibar = pci_read_config32(dev, 0xA0) & ~0x1F; } +unsigned int spi_crop_chunk(unsigned int cmd_len, unsigned int buf_len) +{ + return min(AMD_SB_SPI_TX_LEN - cmd_len, buf_len); +} + int spi_xfer(struct spi_slave *slave, const void *dout, unsigned int bitsout, void *din, unsigned int bitsin) { diff --git a/src/southbridge/intel/common/spi.c b/src/southbridge/intel/common/spi.c index 51586cc..8db134a 100644 --- a/src/southbridge/intel/common/spi.c +++ b/src/southbridge/intel/common/spi.c @@ -551,6 +551,11 @@ static int spi_is_multichip (void) return !!((cntlr.flmap0 >> 8) & 3); } +unsigned int spi_crop_chunk(unsigned int cmd_len, unsigned int buf_len) +{ + return min(cntlr.databytes, buf_len); +} + int spi_xfer(struct spi_slave *slave, const void *dout, unsigned int bitsout, void *din, unsigned int bitsin) { @@ -645,7 +650,7 @@ int spi_xfer(struct spi_slave *slave, const void *dout, */ if (trans.bytesout > cntlr.databytes) { printk(BIOS_DEBUG, "ICH SPI: Too much to write. Does your SPI chip driver use" - " CONTROLLER_PAGE_LIMIT?\n"); + " spi_crop_chunk()?\n"); return -1; }
1
0
0
0
← Newer
1
...
84
85
86
87
Older →
Jump to page:
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
Results per page:
10
25
50
100
200