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
2025
May
April
March
February
January
2024
December
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
May 2017
----- 2025 -----
May 2025
April 2025
March 2025
February 2025
January 2025
----- 2024 -----
December 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
3888 discussions
Start a n
N
ew thread
Change in coreboot[master]: mainboard/google/poppy/variants/soraka: Add SPD for K3QFAFA0...
by Furquan Shaikh (Code Review)
19 May '17
19 May '17
Furquan Shaikh has submitted this change and it was merged. (
https://review.coreboot.org/19766
) Change subject: mainboard/google/poppy/variants/soraka: Add SPD for K3QFAFA0CM-AGCF ...................................................................... mainboard/google/poppy/variants/soraka: Add SPD for K3QFAFA0CM-AGCF BUG=b:37712455 Change-Id: Ia3d13ac7c18be8fa92603b6501a2e5df476adcf0 Signed-off-by: Furquan Shaikh <furquan(a)chromium.org> Reviewed-on:
https://review.coreboot.org/19766
Reviewed-by: Aaron Durbin <adurbin(a)chromium.org> Tested-by: build bot (Jenkins) <no-reply(a)coreboot.org> --- A src/mainboard/google/poppy/spd/samsung_dimm_K3QFAFA0CM-AGCF.spd.hex M src/mainboard/google/poppy/variants/soraka/Makefile.inc 2 files changed, 17 insertions(+), 1 deletion(-) Approvals: Aaron Durbin: Looks good to me, approved build bot (Jenkins): Verified diff --git a/src/mainboard/google/poppy/spd/samsung_dimm_K3QFAFA0CM-AGCF.spd.hex b/src/mainboard/google/poppy/spd/samsung_dimm_K3QFAFA0CM-AGCF.spd.hex new file mode 100644 index 0000000..9eb1f40 --- /dev/null +++ b/src/mainboard/google/poppy/spd/samsung_dimm_K3QFAFA0CM-AGCF.spd.hex @@ -0,0 +1,16 @@ +91 20 F1 03 05 1A 05 1B 03 11 01 08 09 00 40 05 +78 78 90 50 90 11 50 E0 90 06 3C 3C 01 90 00 00 +00 00 CA FA 00 00 00 A8 00 88 00 00 00 00 00 00 +00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +00 00 00 00 00 80 CE 01 00 00 55 00 00 00 00 00 +4B 33 51 46 41 46 41 30 43 4D 2D 41 47 43 46 20 +20 20 00 00 80 CE 00 00 00 00 00 00 00 00 00 00 +00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 diff --git a/src/mainboard/google/poppy/variants/soraka/Makefile.inc b/src/mainboard/google/poppy/variants/soraka/Makefile.inc index d757c56..3a5a58d 100644 --- a/src/mainboard/google/poppy/variants/soraka/Makefile.inc +++ b/src/mainboard/google/poppy/variants/soraka/Makefile.inc @@ -8,4 +8,4 @@ SPD_SOURCES += hynix_dimm_H9CCNNNFAGMLLR-NUD # 0b0110 SPD_SOURCES += samsung_dimm_K3QF3F30BM-AGCF # 0b0111 SPD_SOURCES += samsung_dimm_K3QF4F40BM-AGCF # 0b1000 -SPD_SOURCEs += empty # 0b1001 +SPD_SOURCES += samsung_dimm_K3QFAFA0CM-AGCF # 0b1001 -- To view, visit
https://review.coreboot.org/19766
To unsubscribe, visit
https://review.coreboot.org/settings
Gerrit-MessageType: merged Gerrit-Change-Id: Ia3d13ac7c18be8fa92603b6501a2e5df476adcf0 Gerrit-PatchSet: 2 Gerrit-Project: coreboot Gerrit-Branch: master Gerrit-Owner: Furquan Shaikh <furquan(a)google.com> Gerrit-Reviewer: Aaron Durbin <adurbin(a)chromium.org> Gerrit-Reviewer: Duncan Laurie <dlaurie(a)chromium.org> Gerrit-Reviewer: Furquan Shaikh <furquan(a)google.com> Gerrit-Reviewer: build bot (Jenkins) <no-reply(a)coreboot.org>
1
0
0
0
Change in coreboot[master]: mainboard/google/poppy: Fix SPD for micron MT52L256M64D2PP-107
by Furquan Shaikh (Code Review)
19 May '17
19 May '17
Furquan Shaikh has submitted this change and it was merged. (
https://review.coreboot.org/19749
) Change subject: mainboard/google/poppy: Fix SPD for micron MT52L256M64D2PP-107 ...................................................................... mainboard/google/poppy: Fix SPD for micron MT52L256M64D2PP-107 Fix SPD as per the vendor-provided data. BUG=b:37712790 Change-Id: Ib87c316479f4a05e64ca4acb540d7aacfa7338e9 Signed-off-by: Furquan Shaikh <furquan(a)chromium.org> Reviewed-on:
https://review.coreboot.org/19749
Tested-by: build bot (Jenkins) <no-reply(a)coreboot.org> Reviewed-by: Aaron Durbin <adurbin(a)chromium.org> --- M src/mainboard/google/poppy/spd/micron_dimm_MT52L256M64D2PP-107.spd.hex 1 file changed, 2 insertions(+), 2 deletions(-) Approvals: Aaron Durbin: Looks good to me, approved build bot (Jenkins): Verified diff --git a/src/mainboard/google/poppy/spd/micron_dimm_MT52L256M64D2PP-107.spd.hex b/src/mainboard/google/poppy/spd/micron_dimm_MT52L256M64D2PP-107.spd.hex index aa1b01e..7e77b51 100644 --- a/src/mainboard/google/poppy/spd/micron_dimm_MT52L256M64D2PP-107.spd.hex +++ b/src/mainboard/google/poppy/spd/micron_dimm_MT52L256M64D2PP-107.spd.hex @@ -1,11 +1,11 @@ 91 20 F1 03 05 19 05 03 03 11 01 08 09 00 00 05 78 78 90 50 90 11 50 E0 90 06 3C 3C 01 90 00 00 -00 21 CA FA 00 00 00 A8 00 00 00 00 00 00 00 00 +00 A1 CA FA 00 00 00 A8 00 88 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 -00 00 00 00 00 80 2C 00 00 00 00 00 00 00 E6 7D +00 00 00 00 00 80 2C 00 00 00 00 00 00 00 23 DD 4D 54 35 32 4C 32 35 36 4D 36 34 44 32 50 50 2D 31 30 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 -- To view, visit
https://review.coreboot.org/19749
To unsubscribe, visit
https://review.coreboot.org/settings
Gerrit-MessageType: merged Gerrit-Change-Id: Ib87c316479f4a05e64ca4acb540d7aacfa7338e9 Gerrit-PatchSet: 4 Gerrit-Project: coreboot Gerrit-Branch: master Gerrit-Owner: Furquan Shaikh <furquan(a)google.com> Gerrit-Reviewer: Aaron Durbin <adurbin(a)chromium.org> Gerrit-Reviewer: Duncan Laurie <dlaurie(a)chromium.org> Gerrit-Reviewer: Furquan Shaikh <furquan(a)google.com> Gerrit-Reviewer: Naresh Solanki <naresh.solanki(a)intel.com> Gerrit-Reviewer: Paul Menzel <paulepanter(a)users.sourceforge.net> Gerrit-Reviewer: build bot (Jenkins) <no-reply(a)coreboot.org>
1
0
0
0
Change in coreboot[master]: drivers/spi/spi_flash: Move flash ops to spi_flash_ops struc...
by Furquan Shaikh (Code Review)
19 May '17
19 May '17
Furquan Shaikh has submitted this change and it was merged. (
https://review.coreboot.org/19757
) Change subject: drivers/spi/spi_flash: Move flash ops to spi_flash_ops structure ...................................................................... drivers/spi/spi_flash: Move flash ops to spi_flash_ops structure Define a new spi_flash_ops structure, move all spi flash operations to this structure and add a pointer to this structure in struct spi_flash. BUG=b:38330715 Change-Id: I550cc4556fc4b63ebc174a7e2fde42251fe56052 Signed-off-by: Furquan Shaikh <furquan(a)chromium.org> Reviewed-on:
https://review.coreboot.org/19757
Tested-by: build bot (Jenkins) <no-reply(a)coreboot.org> Reviewed-by: Aaron Durbin <adurbin(a)chromium.org> --- M src/drivers/spi/adesto.c M src/drivers/spi/amic.c M src/drivers/spi/atmel.c M src/drivers/spi/eon.c M src/drivers/spi/gigadevice.c M src/drivers/spi/macronix.c M src/drivers/spi/spansion.c M src/drivers/spi/spi_flash.c M src/drivers/spi/sst.c M src/drivers/spi/stmicro.c M src/drivers/spi/winbond.c M src/include/spi_flash.h M src/soc/intel/common/block/fast_spi/fast_spi_flash.c M src/soc/mediatek/mt8173/flash_controller.c M src/southbridge/intel/common/spi.c 15 files changed, 170 insertions(+), 101 deletions(-) Approvals: Aaron Durbin: Looks good to me, approved build bot (Jenkins): Verified diff --git a/src/drivers/spi/adesto.c b/src/drivers/spi/adesto.c index c22bec1..3e857fc 100644 --- a/src/drivers/spi/adesto.c +++ b/src/drivers/spi/adesto.c @@ -126,6 +126,16 @@ return ret; } +static const struct spi_flash_ops spi_flash_ops = { + .write = adesto_write, + .erase = spi_flash_cmd_erase, +#if IS_ENABLED(CONFIG_SPI_FLASH_NO_FAST_READ) + .read = spi_flash_cmd_read_slow, +#else + .read = spi_flash_cmd_read_fast, +#endif +}; + int spi_flash_probe_adesto(const struct spi_slave *spi, u8 *idcode, struct spi_flash *flash) { @@ -153,13 +163,7 @@ params->nr_blocks; flash->erase_cmd = CMD_AT25DF_SE; - flash->internal_write = adesto_write; - flash->internal_erase = spi_flash_cmd_erase; -#if CONFIG_SPI_FLASH_NO_FAST_READ - flash->internal_read = spi_flash_cmd_read_slow; -#else - flash->internal_read = spi_flash_cmd_read_fast; -#endif + flash->ops = &spi_flash_ops; return 0; } diff --git a/src/drivers/spi/amic.c b/src/drivers/spi/amic.c index e97a362..239681c 100644 --- a/src/drivers/spi/amic.c +++ b/src/drivers/spi/amic.c @@ -109,6 +109,16 @@ return ret; } +static const struct spi_flash_ops spi_flash_ops = { + .write = amic_write, + .erase = spi_flash_cmd_erase, +#if IS_ENABLED(CONFIG_SPI_FLASH_NO_FAST_READ) + .read = spi_flash_cmd_read_slow, +#else + .read = spi_flash_cmd_read_fast, +#endif +}; + int spi_flash_probe_amic(const struct spi_slave *spi, u8 *idcode, struct spi_flash *flash) { @@ -137,13 +147,7 @@ params->nr_blocks; flash->erase_cmd = CMD_A25_SE; - flash->internal_write = amic_write; - flash->internal_erase = spi_flash_cmd_erase; -#if CONFIG_SPI_FLASH_NO_FAST_READ - flash->internal_read = spi_flash_cmd_read_slow; -#else - flash->internal_read = spi_flash_cmd_read_fast; -#endif + flash->ops = &spi_flash_ops; return 0; } diff --git a/src/drivers/spi/atmel.c b/src/drivers/spi/atmel.c index b97f255..07bbf16 100644 --- a/src/drivers/spi/atmel.c +++ b/src/drivers/spi/atmel.c @@ -154,6 +154,16 @@ return ret; } +static const struct spi_flash_ops spi_flash_ops = { + .write = atmel_write, + .erase = spi_flash_cmd_erase, +#if IS_ENABLED(CONFIG_SPI_FLASH_NO_FAST_READ) + .read = spi_flash_cmd_read_slow, +#else + .read = spi_flash_cmd_read_fast, +#endif +}; + int spi_flash_probe_atmel(const struct spi_slave *spi, u8 *idcode, struct spi_flash *flash) { @@ -182,13 +192,7 @@ params->nr_blocks; flash->erase_cmd = CMD_AT25_SE; - flash->internal_write = atmel_write; - flash->internal_erase = spi_flash_cmd_erase; -#if CONFIG_SPI_FLASH_NO_FAST_READ - flash->internal_read = spi_flash_cmd_read_slow; -#else - flash->internal_read = spi_flash_cmd_read_fast; -#endif + flash->ops = &spi_flash_ops; return 0; } diff --git a/src/drivers/spi/eon.c b/src/drivers/spi/eon.c index ece9810..a072e4e 100644 --- a/src/drivers/spi/eon.c +++ b/src/drivers/spi/eon.c @@ -126,6 +126,13 @@ return ret; } +static const struct spi_flash_ops spi_flash_ops = { + .write = eon_write, + .erase = spi_flash_cmd_erase, + .status = spi_flash_cmd_status, + .read = spi_flash_cmd_read_fast, +}; + int spi_flash_probe_eon(const struct spi_slave *spi, u8 *idcode, struct spi_flash *flash) { @@ -153,10 +160,7 @@ flash->erase_cmd = CMD_EN25_SE; flash->status_cmd = CMD_EN25_RDSR; - flash->internal_write = eon_write; - flash->internal_erase = spi_flash_cmd_erase; - flash->internal_status = spi_flash_cmd_status; - flash->internal_read = spi_flash_cmd_read_fast; + flash->ops = &spi_flash_ops; return 0; } diff --git a/src/drivers/spi/gigadevice.c b/src/drivers/spi/gigadevice.c index f68be8b..becc215 100644 --- a/src/drivers/spi/gigadevice.c +++ b/src/drivers/spi/gigadevice.c @@ -170,6 +170,17 @@ return ret; } +static const struct spi_flash_ops spi_flash_ops = { + .write = gigadevice_write, + .erase = spi_flash_cmd_erase, + .status = spi_flash_cmd_status, +#if IS_ENABLED(CONFIG_SPI_FLASH_NO_FAST_READ) + .read = spi_flash_cmd_read_slow, +#else + .read = spi_flash_cmd_read_fast, +#endif +}; + int spi_flash_probe_gigadevice(const struct spi_slave *spi, u8 *idcode, struct spi_flash *flash) { @@ -200,14 +211,7 @@ flash->erase_cmd = CMD_GD25_SE; flash->status_cmd = CMD_GD25_RDSR; - flash->internal_write = gigadevice_write; - flash->internal_erase = spi_flash_cmd_erase; - flash->internal_status = spi_flash_cmd_status; -#if CONFIG_SPI_FLASH_NO_FAST_READ - flash->internal_read = spi_flash_cmd_read_slow; -#else - flash->internal_read = spi_flash_cmd_read_fast; -#endif + flash->ops = &spi_flash_ops; return 0; } diff --git a/src/drivers/spi/macronix.c b/src/drivers/spi/macronix.c index 128d00f..fd2d25b 100644 --- a/src/drivers/spi/macronix.c +++ b/src/drivers/spi/macronix.c @@ -192,6 +192,17 @@ return ret; } +static const struct spi_flash_ops spi_flash_ops = { + .write = macronix_write, + .erase = spi_flash_cmd_erase, + .status = spi_flash_cmd_status, +#if IS_ENABLED(CONFIG_SPI_FLASH_NO_FAST_READ) + .read = spi_flash_cmd_read_slow, +#else + .read = spi_flash_cmd_read_fast, +#endif +}; + int spi_flash_probe_macronix(const struct spi_slave *spi, u8 *idcode, struct spi_flash *flash) { @@ -219,14 +230,7 @@ flash->erase_cmd = CMD_MX25XX_SE; flash->status_cmd = CMD_MX25XX_RDSR; - flash->internal_write = macronix_write; - flash->internal_erase = spi_flash_cmd_erase; - flash->internal_status = spi_flash_cmd_status; -#if CONFIG_SPI_FLASH_NO_FAST_READ - flash->internal_read = spi_flash_cmd_read_slow; -#else - flash->internal_read = spi_flash_cmd_read_fast; -#endif + flash->ops = &spi_flash_ops; return 0; } diff --git a/src/drivers/spi/spansion.c b/src/drivers/spi/spansion.c index de7ad55..cb528d3 100644 --- a/src/drivers/spi/spansion.c +++ b/src/drivers/spi/spansion.c @@ -246,6 +246,13 @@ return ret; } +static const struct spi_flash_ops spi_flash_ops = { + .write = spansion_write, + .erase = spi_flash_cmd_erase, + .read = spi_flash_cmd_read_slow, + .status = spi_flash_cmd_status, +}; + int spi_flash_probe_spansion(const struct spi_slave *spi, u8 *idcode, struct spi_flash *flash) { @@ -273,10 +280,7 @@ flash->erase_cmd = CMD_S25FLXX_SE; flash->status_cmd = CMD_S25FLXX_RDSR; - flash->internal_write = spansion_write; - flash->internal_erase = spi_flash_cmd_erase; - flash->internal_read = spi_flash_cmd_read_slow; - flash->internal_status = spi_flash_cmd_status; + flash->ops = &spi_flash_ops; return 0; } diff --git a/src/drivers/spi/spi_flash.c b/src/drivers/spi/spi_flash.c index 564d573..c145379 100644 --- a/src/drivers/spi/spi_flash.c +++ b/src/drivers/spi/spi_flash.c @@ -350,7 +350,7 @@ int spi_flash_read(const struct spi_flash *flash, u32 offset, size_t len, void *buf) { - return flash->internal_read(flash, offset, len, buf); + return flash->ops->read(flash, offset, len, buf); } int spi_flash_write(const struct spi_flash *flash, u32 offset, size_t len, @@ -361,7 +361,7 @@ if (spi_flash_volatile_group_begin(flash)) return -1; - ret = flash->internal_write(flash, offset, len, buf); + ret = flash->ops->write(flash, offset, len, buf); if (spi_flash_volatile_group_end(flash)) return -1; @@ -376,7 +376,7 @@ if (spi_flash_volatile_group_begin(flash)) return -1; - ret = flash->internal_erase(flash, offset, len); + ret = flash->ops->erase(flash, offset, len); if (spi_flash_volatile_group_end(flash)) return -1; @@ -386,7 +386,10 @@ int spi_flash_status(const struct spi_flash *flash, u8 *reg) { - return flash->internal_status(flash, reg); + if (flash->ops->status) + return flash->ops->status(flash, reg); + + return -1; } static uint32_t volatile_group_count CAR_GLOBAL; diff --git a/src/drivers/spi/sst.c b/src/drivers/spi/sst.c index 5325ef4..ce67e9b 100644 --- a/src/drivers/spi/sst.c +++ b/src/drivers/spi/sst.c @@ -43,8 +43,7 @@ u8 idcode1; u16 nr_sectors; const char *name; - int (*write)(const struct spi_flash *flash, u32 offset, - size_t len, const void *buf); + const struct spi_flash_ops *ops; }; static int sst_write_ai(const struct spi_flash *flash, u32 offset, size_t len, @@ -52,53 +51,67 @@ static int sst_write_256(const struct spi_flash *flash, u32 offset, size_t len, const void *buf); +static const struct spi_flash_ops spi_flash_ops_write_ai = { + .write = sst_write_ai, + .erase = spi_flash_cmd_erase, + .status = spi_flash_cmd_status, + .read = spi_flash_cmd_read_fast, +}; + +static const struct spi_flash_ops spi_flash_ops_write_256 = { + .write = sst_write_256, + .erase = spi_flash_cmd_erase, + .status = spi_flash_cmd_status, + .read = spi_flash_cmd_read_fast, +}; + #define SST_SECTOR_SIZE (4 * 1024) static const struct sst_spi_flash_params sst_spi_flash_table[] = { { .idcode1 = 0x8d, .nr_sectors = 128, .name = "SST25VF040B", - .write = sst_write_ai, + .ops = &spi_flash_ops_write_ai, },{ .idcode1 = 0x8e, .nr_sectors = 256, .name = "SST25VF080B", - .write = sst_write_ai, + .ops = &spi_flash_ops_write_ai, },{ .idcode1 = 0x41, .nr_sectors = 512, .name = "SST25VF016B", - .write = sst_write_ai, + .ops = &spi_flash_ops_write_ai, },{ .idcode1 = 0x4a, .nr_sectors = 1024, .name = "SST25VF032B", - .write = sst_write_ai, + .ops = &spi_flash_ops_write_ai, },{ .idcode1 = 0x4b, .nr_sectors = 2048, .name = "SST25VF064C", - .write = sst_write_256, + .ops = &spi_flash_ops_write_256, },{ .idcode1 = 0x01, .nr_sectors = 16, .name = "SST25WF512", - .write = sst_write_ai, + .ops = &spi_flash_ops_write_ai, },{ .idcode1 = 0x02, .nr_sectors = 32, .name = "SST25WF010", - .write = sst_write_ai, + .ops = &spi_flash_ops_write_ai, },{ .idcode1 = 0x03, .nr_sectors = 64, .name = "SST25WF020", - .write = sst_write_ai, + .ops = &spi_flash_ops_write_ai, },{ .idcode1 = 0x04, .nr_sectors = 128, .name = "SST25WF040", - .write = sst_write_ai, + .ops = &spi_flash_ops_write_ai, }, }; @@ -338,10 +351,7 @@ flash->erase_cmd = CMD_SST_SE; flash->status_cmd = CMD_SST_RDSR; - flash->internal_write = params->write; - flash->internal_erase = spi_flash_cmd_erase; - flash->internal_status = spi_flash_cmd_status; - flash->internal_read = spi_flash_cmd_read_fast; + flash->ops = params->ops; /* Flash powers up read-only, so clear BP# bits */ sst_unlock(flash); diff --git a/src/drivers/spi/stmicro.c b/src/drivers/spi/stmicro.c index fe8c466..68eb37b 100644 --- a/src/drivers/spi/stmicro.c +++ b/src/drivers/spi/stmicro.c @@ -222,6 +222,12 @@ return ret; } +static const struct spi_flash_ops spi_flash_ops = { + .write = stmicro_write, + .erase = spi_flash_cmd_erase, + .read = spi_flash_cmd_read_fast, +}; + int spi_flash_probe_stmicro(const struct spi_slave *spi, u8 *idcode, struct spi_flash *flash) { @@ -260,9 +266,7 @@ flash->size = flash->sector_size * params->nr_sectors; flash->erase_cmd = params->op_erase; - flash->internal_write = stmicro_write; - flash->internal_erase = spi_flash_cmd_erase; - flash->internal_read = spi_flash_cmd_read_fast; + flash->ops = &spi_flash_ops; return 0; } diff --git a/src/drivers/spi/winbond.c b/src/drivers/spi/winbond.c index 9694f8a..77064ea 100644 --- a/src/drivers/spi/winbond.c +++ b/src/drivers/spi/winbond.c @@ -184,6 +184,17 @@ return ret; } +static const struct spi_flash_ops spi_flash_ops = { + .write = winbond_write, + .erase = spi_flash_cmd_erase, + .status = spi_flash_cmd_status, +#if IS_ENABLED(CONFIG_SPI_FLASH_NO_FAST_READ) + .read = spi_flash_cmd_read_slow, +#else + .read = spi_flash_cmd_read_fast, +#endif +}; + int spi_flash_probe_winbond(const struct spi_slave *spi, u8 *idcode, struct spi_flash *flash) { @@ -212,14 +223,7 @@ flash->erase_cmd = CMD_W25_SE; flash->status_cmd = CMD_W25_RDSR; - flash->internal_write = winbond_write; - flash->internal_erase = spi_flash_cmd_erase; - flash->internal_status = spi_flash_cmd_status; -#if CONFIG_SPI_FLASH_NO_FAST_READ - flash->internal_read = spi_flash_cmd_read_slow; -#else - flash->internal_read = spi_flash_cmd_read_fast; -#endif + flash->ops = &spi_flash_ops; return 0; } diff --git a/src/include/spi_flash.h b/src/include/spi_flash.h index ab8155d..e9ea50c 100644 --- a/src/include/spi_flash.h +++ b/src/include/spi_flash.h @@ -24,6 +24,24 @@ #define SPI_OPCODE_WREN 0x06 #define SPI_OPCODE_FAST_READ 0x0b +struct spi_flash; + +/* + * Representation of SPI flash operations: + * read: Flash read operation. + * write: Flash write operation. + * erase: Flash erase operation. + * status: Read flash status register. + */ +struct spi_flash_ops { + int (*read)(const struct spi_flash *flash, u32 offset, size_t len, + void *buf); + int (*write)(const struct spi_flash *flash, u32 offset, size_t len, + const void *buf); + int (*erase)(const struct spi_flash *flash, u32 offset, size_t len); + int (*status)(const struct spi_flash *flash, u8 *reg); +}; + struct spi_flash { struct spi_slave spi; const char *name; @@ -32,19 +50,7 @@ u32 page_size; u8 erase_cmd; u8 status_cmd; - /* - * Internal functions are expected to be called ONLY by spi flash - * driver. External components should only use the public API calls - * spi_flash_{read,write,erase,status,volatile_group_begin, - * volatile_group_end}. - */ - int (*internal_read)(const struct spi_flash *flash, u32 offset, - size_t len, void *buf); - int (*internal_write)(const struct spi_flash *flash, u32 offset, - size_t len, const void *buf); - int (*internal_erase)(const struct spi_flash *flash, u32 offset, - size_t len); - int (*internal_status)(const struct spi_flash *flash, u8 *reg); + const struct spi_flash_ops *ops; }; void lb_spi_flash(struct lb_header *header); diff --git a/src/soc/intel/common/block/fast_spi/fast_spi_flash.c b/src/soc/intel/common/block/fast_spi/fast_spi_flash.c index fc36553..6dac24e 100644 --- a/src/soc/intel/common/block/fast_spi/fast_spi_flash.c +++ b/src/soc/intel/common/block/fast_spi/fast_spi_flash.c @@ -273,6 +273,13 @@ return ret; } +const struct spi_flash_ops fast_spi_flash_ops = { + .read = fast_spi_flash_read, + .write = fast_spi_flash_write, + .erase = fast_spi_flash_erase, + .status = fast_spi_flash_status, +}; + /* * We can't use FDOC and FDOD to read FLCOMP, as previous platforms did. * For details see: @@ -307,11 +314,7 @@ * flash->status_cmd = ??? */ - flash->internal_write = fast_spi_flash_write; - flash->internal_erase = fast_spi_flash_erase; - flash->internal_read = fast_spi_flash_read; - flash->internal_status = fast_spi_flash_status; - + flash->ops = &fast_spi_flash_ops; return 0; } diff --git a/src/soc/mediatek/mt8173/flash_controller.c b/src/soc/mediatek/mt8173/flash_controller.c index f4c0de4..f776885 100644 --- a/src/soc/mediatek/mt8173/flash_controller.c +++ b/src/soc/mediatek/mt8173/flash_controller.c @@ -228,18 +228,24 @@ return 0; } -int mtk_spi_flash_probe(const struct spi_slave *spi, struct spi_flash *flash) +const struct spi_flash_ops spi_flash_ops = { + .read = nor_read, + .write = nor_write, + .erase = nor_erase, +}; + +int mtk_spi_flash_probe(const struct spi_slave *spi, + struct spi_flash *flash) { write32(&mt8173_nor->wrprot, SFLASH_COMMAND_ENABLE); memcpy(&flash->spi, spi, sizeof(*spi)); + flash->name = "mt8173 flash controller"; - flash->internal_write = nor_write; - flash->internal_erase = nor_erase; - flash->internal_read = nor_read; - flash->internal_status = 0; flash->sector_size = 0x1000; flash->erase_cmd = SECTOR_ERASE_CMD; flash->size = CONFIG_ROM_SIZE; + flash->ops = &spi_flash_ops; + return 0; } diff --git a/src/southbridge/intel/common/spi.c b/src/southbridge/intel/common/spi.c index 79b1db7..be9b128 100644 --- a/src/southbridge/intel/common/spi.c +++ b/src/southbridge/intel/common/spi.c @@ -885,6 +885,12 @@ return 0; } +static const struct spi_flash_ops spi_flash_ops = { + .read = ich_hwseq_read, + .write = ich_hwseq_write, + .erase = ich_hwseq_erase, +}; + static int spi_flash_programmer_probe(const struct spi_slave *spi, struct spi_flash *flash) { @@ -897,9 +903,6 @@ memcpy(&flash->spi, spi, sizeof(*spi)); flash->name = "Opaque HW-sequencing"; - flash->internal_write = ich_hwseq_write; - flash->internal_erase = ich_hwseq_erase; - flash->internal_read = ich_hwseq_read; ich_hwseq_set_addr (0); switch ((cntlr.hsfs >> 3) & 3) { @@ -922,6 +925,8 @@ flash->size = 1 << (19 + (flcomp & 7)); + flash->ops = &spi_flash_ops; + if ((cntlr.hsfs & HSFS_FDV) && ((cntlr.flmap0 >> 8) & 3)) flash->size += 1 << (19 + ((flcomp >> 3) & 7)); printk (BIOS_DEBUG, "flash size 0x%x bytes\n", flash->size); -- To view, visit
https://review.coreboot.org/19757
To unsubscribe, visit
https://review.coreboot.org/settings
Gerrit-MessageType: merged Gerrit-Change-Id: I550cc4556fc4b63ebc174a7e2fde42251fe56052 Gerrit-PatchSet: 10 Gerrit-Project: coreboot Gerrit-Branch: master Gerrit-Owner: Furquan Shaikh <furquan(a)google.com> Gerrit-Reviewer: Aaron Durbin <adurbin(a)chromium.org> Gerrit-Reviewer: Duncan Laurie <dlaurie(a)chromium.org> Gerrit-Reviewer: Furquan Shaikh <furquan(a)google.com> Gerrit-Reviewer: Paul Menzel <paulepanter(a)users.sourceforge.net> Gerrit-Reviewer: build bot (Jenkins) <no-reply(a)coreboot.org>
1
0
0
0
Change in coreboot[master]: drivers/spi/spi_flash: Clean up SPI flash probe
by Furquan Shaikh (Code Review)
19 May '17
19 May '17
Furquan Shaikh has submitted this change and it was merged. (
https://review.coreboot.org/19708
) Change subject: drivers/spi/spi_flash: Clean up SPI flash probe ...................................................................... drivers/spi/spi_flash: Clean up SPI flash probe 1. Rename __spi_flash_probe to spi_flash_generic_probe and export it so that drivers can use it outside spi_flash.c. 2. Make southbridge intel spi driver use spi_flash_generic_probe if spi_is_multichip returns 0. 3. Add spi_flash_probe to spi_ctrlr structure to allow platforms to provide specialized probe functions. With this change, the specialized spi flash probe functions are now associated with a particular spi ctrlr structure and no longer disconnected from the spi controller. BUG=b:38330715 Change-Id: I35f3bd8ddc5e71515df3ef0c1c4b1a68ee56bf4b Signed-off-by: Furquan Shaikh <furquan(a)chromium.org> Reviewed-on:
https://review.coreboot.org/19708
Tested-by: build bot (Jenkins) <no-reply(a)coreboot.org> Reviewed-by: Aaron Durbin <adurbin(a)chromium.org> Reviewed-by: Julius Werner <jwerner(a)chromium.org> --- M src/drivers/spi/spi_flash.c M src/include/spi-generic.h M src/include/spi_flash.h M src/soc/intel/common/block/fast_spi/fast_spi_flash.c M src/soc/mediatek/mt8173/flash_controller.c M src/soc/mediatek/mt8173/include/soc/flash_controller.h M src/soc/mediatek/mt8173/spi.c M src/southbridge/intel/common/spi.c 8 files changed, 53 insertions(+), 62 deletions(-) Approvals: Aaron Durbin: Looks good to me, approved Julius Werner: Looks good to me, approved build bot (Jenkins): Verified diff --git a/src/drivers/spi/spi_flash.c b/src/drivers/spi/spi_flash.c index 096d7cd..564d573 100644 --- a/src/drivers/spi/spi_flash.c +++ b/src/drivers/spi/spi_flash.c @@ -281,16 +281,7 @@ }; #define IDCODE_LEN (IDCODE_CONT_LEN + IDCODE_PART_LEN) -int -__attribute__((weak)) spi_flash_programmer_probe(const struct spi_slave *spi, - int force, - struct spi_flash *flash) -{ - /* Default weak implementation. Do nothing. */ - return -1; -} - -static int __spi_flash_probe(const struct spi_slave *spi, +int spi_flash_generic_probe(const struct spi_slave *spi, struct spi_flash *flash) { int ret, i, shift; @@ -330,32 +321,29 @@ int spi_flash_probe(unsigned int bus, unsigned int cs, struct spi_flash *flash) { struct spi_slave spi; + int ret = -1; if (spi_setup_slave(bus, cs, &spi)) { printk(BIOS_WARNING, "SF: Failed to set up slave\n"); return -1; } - /* Try special programmer probe if any (without force). */ - if (spi_flash_programmer_probe(&spi, 0, flash) == 0) - goto flash_found; + /* Try special programmer probe if any. */ + if (spi.ctrlr->flash_probe) + ret = spi.ctrlr->flash_probe(&spi, flash); /* If flash is not found, try generic spi flash probe. */ - if (__spi_flash_probe(&spi, flash) == 0) - goto flash_found; - - /* If flash is not yet found, force special programmer probe if any. */ - if (spi_flash_programmer_probe(&spi, 1, flash) == 0) - goto flash_found; + if (ret) + ret = spi_flash_generic_probe(&spi, flash); /* Give up -- nothing more to try if flash is not found. */ - printk(BIOS_WARNING, "SF: Unsupported manufacturer!\n"); - return -1; + if (ret) { + printk(BIOS_WARNING, "SF: Unsupported manufacturer!\n"); + return -1; + } -flash_found: printk(BIOS_INFO, "SF: Detected %s with sector size 0x%x, total 0x%x\n", flash->name, flash->sector_size, flash->size); - return 0; } diff --git a/src/include/spi-generic.h b/src/include/spi-generic.h index 56353bb..783df0b 100644 --- a/src/include/spi-generic.h +++ b/src/include/spi-generic.h @@ -94,6 +94,8 @@ */ #define SPI_CTRLR_DEFAULT_MAX_XFER_SIZE (UINT32_MAX) +struct spi_flash; + /*----------------------------------------------------------------------- * Representation of a SPI controller. * @@ -108,6 +110,11 @@ * deduct_cmd_len: Whether cmd_len should be deducted from max_xfer_size * when calculating max_data_size * + * Following member is provided by specialized SPI controllers that are + * actually SPI flash controllers. + * + * flash_probe: Specialized probe function provided by SPI flash + * controllers. */ struct spi_ctrlr { int (*claim_bus)(const struct spi_slave *slave); @@ -119,6 +126,8 @@ struct spi_op vectors[], size_t count); uint32_t max_xfer_size; bool deduct_cmd_len; + int (*flash_probe)(const struct spi_slave *slave, + struct spi_flash *flash); }; /*----------------------------------------------------------------------- diff --git a/src/include/spi_flash.h b/src/include/spi_flash.h index bc0318c..ab8155d 100644 --- a/src/include/spi_flash.h +++ b/src/include/spi_flash.h @@ -65,20 +65,19 @@ * non-zero = error */ int spi_flash_probe(unsigned int bus, unsigned int cs, struct spi_flash *flash); + /* - * Specialized probing performed by platform. This is a weak function which can - * be overriden by platform driver. + * Generic probing for SPI flash chip based on the different flashes provided. * * Params: - * spi = Pointer to spi_slave structure. - * force = Indicates if the platform driver can skip specialized probing. + * spi = Pointer to spi_slave structure * flash = Pointer to spi_flash structure that needs to be filled. * * Return value: - * 0 = success + * 0 = success * non-zero = error */ -int spi_flash_programmer_probe(const struct spi_slave *spi, int force, +int spi_flash_generic_probe(const struct spi_slave *slave, struct spi_flash *flash); /* All the following functions return 0 on success and non-zero on error. */ diff --git a/src/soc/intel/common/block/fast_spi/fast_spi_flash.c b/src/soc/intel/common/block/fast_spi/fast_spi_flash.c index 7780144..fc36553 100644 --- a/src/soc/intel/common/block/fast_spi/fast_spi_flash.c +++ b/src/soc/intel/common/block/fast_spi/fast_spi_flash.c @@ -280,8 +280,8 @@ * The size of the flash component is always taken from density field in the * SFDP table. FLCOMP.C0DEN is no longer used by the Flash Controller. */ -int spi_flash_programmer_probe(const struct spi_slave *dev, - int force, struct spi_flash *flash) +static int fast_spi_flash_probe(const struct spi_slave *dev, + struct spi_flash *flash) { BOILERPLATE_CREATE_CTX(ctx); uint32_t flash_bits; @@ -362,4 +362,5 @@ const struct spi_ctrlr fast_spi_flash_ctrlr = { .setup = fast_spi_flash_ctrlr_setup, .max_xfer_size = SPI_CTRLR_DEFAULT_MAX_XFER_SIZE, + .flash_probe = fast_spi_flash_probe, }; diff --git a/src/soc/mediatek/mt8173/flash_controller.c b/src/soc/mediatek/mt8173/flash_controller.c index ee950b8..f4c0de4 100644 --- a/src/soc/mediatek/mt8173/flash_controller.c +++ b/src/soc/mediatek/mt8173/flash_controller.c @@ -228,14 +228,8 @@ return 0; } -int spi_flash_programmer_probe(const struct spi_slave *spi, - int force, struct spi_flash *flash) +int mtk_spi_flash_probe(const struct spi_slave *spi, struct spi_flash *flash) { - static int done; - - if (done) - return 0; - write32(&mt8173_nor->wrprot, SFLASH_COMMAND_ENABLE); memcpy(&flash->spi, spi, sizeof(*spi)); flash->name = "mt8173 flash controller"; @@ -246,6 +240,6 @@ flash->sector_size = 0x1000; flash->erase_cmd = SECTOR_ERASE_CMD; flash->size = CONFIG_ROM_SIZE; - done = 1; + return 0; } diff --git a/src/soc/mediatek/mt8173/include/soc/flash_controller.h b/src/soc/mediatek/mt8173/include/soc/flash_controller.h index 458f357..82d167a 100644 --- a/src/soc/mediatek/mt8173/include/soc/flash_controller.h +++ b/src/soc/mediatek/mt8173/include/soc/flash_controller.h @@ -87,4 +87,6 @@ check_member(mt8173_nor_regs, fdma_end_dadr, 0x724); static struct mt8173_nor_regs * const mt8173_nor = (void *)SFLASH_REG_BASE; +int mtk_spi_flash_probe(const struct spi_slave *spi, struct spi_flash *flash); + #endif /* __SOC_MEDIATEK_MT8173_FLASH_CONTROLLER_H__ */ diff --git a/src/soc/mediatek/mt8173/spi.c b/src/soc/mediatek/mt8173/spi.c index 188bdc2..b8ee423 100644 --- a/src/soc/mediatek/mt8173/spi.c +++ b/src/soc/mediatek/mt8173/spi.c @@ -295,6 +295,7 @@ .xfer = spi_ctrlr_xfer, .xfer_vector = spi_xfer_two_vectors, .max_xfer_size = 65535, + .flash_probe = mtk_spi_flash_probe, }; int spi_setup_slave(unsigned int bus, unsigned int cs, struct spi_slave *slave) diff --git a/src/southbridge/intel/common/spi.c b/src/southbridge/intel/common/spi.c index 110c29c..79b1db7 100644 --- a/src/southbridge/intel/common/spi.c +++ b/src/southbridge/intel/common/spi.c @@ -653,20 +653,6 @@ return 0; } -static const struct spi_ctrlr spi_ctrlr = { - .xfer = spi_ctrlr_xfer, - .xfer_vector = spi_xfer_two_vectors, - .max_xfer_size = member_size(ich9_spi_regs, fdata), -}; - -int spi_setup_slave(unsigned int bus, unsigned int cs, struct spi_slave *slave) -{ - slave->bus = bus; - slave->cs = cs; - slave->ctrlr = &spi_ctrlr; - return 0; -} - /* Sets FLA in FADDR to (addr & 0x01FFFFFF) without touching other bits. */ static void ich_hwseq_set_addr(uint32_t addr) { @@ -899,18 +885,14 @@ return 0; } -int spi_flash_programmer_probe(const struct spi_slave *spi, - int force, struct spi_flash *flash) +static int spi_flash_programmer_probe(const struct spi_slave *spi, + struct spi_flash *flash) { uint32_t flcomp; - /* - * Perform SPI flash probing only if: - * 1. spi_is_multichip returns 1 or - * 2. Specialized probing is forced by SPI flash driver. - */ - if (!spi_is_multichip() && !force) - return -1; + /* Try generic probing first if spi_is_multichip returns 0. */ + if (!spi_is_multichip() && !spi_flash_generic_probe(spi, flash)) + return 0; memcpy(&flash->spi, spi, sizeof(*spi)); flash->name = "Opaque HW-sequencing"; @@ -946,3 +928,18 @@ return 0; } + +static const struct spi_ctrlr spi_ctrlr = { + .xfer = spi_ctrlr_xfer, + .xfer_vector = spi_xfer_two_vectors, + .max_xfer_size = member_size(ich9_spi_regs, fdata), + .flash_probe = spi_flash_programmer_probe, +}; + +int spi_setup_slave(unsigned int bus, unsigned int cs, struct spi_slave *slave) +{ + slave->bus = bus; + slave->cs = cs; + slave->ctrlr = &spi_ctrlr; + return 0; +} -- To view, visit
https://review.coreboot.org/19708
To unsubscribe, visit
https://review.coreboot.org/settings
Gerrit-MessageType: merged Gerrit-Change-Id: I35f3bd8ddc5e71515df3ef0c1c4b1a68ee56bf4b Gerrit-PatchSet: 16 Gerrit-Project: coreboot Gerrit-Branch: master Gerrit-Owner: Furquan Shaikh <furquan(a)google.com> Gerrit-Reviewer: Aaron Durbin <adurbin(a)chromium.org> Gerrit-Reviewer: Duncan Laurie <dlaurie(a)chromium.org> Gerrit-Reviewer: Furquan Shaikh <furquan(a)google.com> Gerrit-Reviewer: Julius Werner <jwerner(a)chromium.org> Gerrit-Reviewer: Paul Menzel <paulepanter(a)users.sourceforge.net> Gerrit-Reviewer: build bot (Jenkins) <no-reply(a)coreboot.org>
1
0
0
0
Change in coreboot[master]: drivers/spi/spi_flash: Pass in spi_slave structure as const ...
by Furquan Shaikh (Code Review)
19 May '17
19 May '17
Furquan Shaikh has submitted this change and it was merged. (
https://review.coreboot.org/19707
) Change subject: drivers/spi/spi_flash: Pass in spi_slave structure as const to probe functions ...................................................................... drivers/spi/spi_flash: Pass in spi_slave structure as const to probe functions Pointer to spi_slave structure can be passed in as const to spi flash probe functions since the probe functions do not need to modify the slave properties. BUG=b:38330715 Change-Id: I956ee777c62dbb811fd6ce2aeb6ae090e1892acd Signed-off-by: Furquan Shaikh <furquan(a)chromium.org> Reviewed-on:
https://review.coreboot.org/19707
Reviewed-by: Aaron Durbin <adurbin(a)chromium.org> Tested-by: build bot (Jenkins) <no-reply(a)coreboot.org> --- M src/drivers/spi/adesto.c M src/drivers/spi/amic.c M src/drivers/spi/atmel.c M src/drivers/spi/eon.c M src/drivers/spi/gigadevice.c M src/drivers/spi/macronix.c M src/drivers/spi/spansion.c M src/drivers/spi/spi_flash.c M src/drivers/spi/spi_flash_internal.h M src/drivers/spi/sst.c M src/drivers/spi/stmicro.c M src/drivers/spi/winbond.c M src/include/spi_flash.h M src/soc/intel/common/block/fast_spi/fast_spi_flash.c M src/soc/mediatek/mt8173/flash_controller.c M src/southbridge/intel/common/spi.c 16 files changed, 28 insertions(+), 27 deletions(-) Approvals: Aaron Durbin: Looks good to me, approved build bot (Jenkins): Verified diff --git a/src/drivers/spi/adesto.c b/src/drivers/spi/adesto.c index d062c36..c22bec1 100644 --- a/src/drivers/spi/adesto.c +++ b/src/drivers/spi/adesto.c @@ -126,7 +126,7 @@ return ret; } -int spi_flash_probe_adesto(struct spi_slave *spi, u8 *idcode, +int spi_flash_probe_adesto(const struct spi_slave *spi, u8 *idcode, struct spi_flash *flash) { const struct adesto_spi_flash_params *params; diff --git a/src/drivers/spi/amic.c b/src/drivers/spi/amic.c index cf5a296..e97a362 100644 --- a/src/drivers/spi/amic.c +++ b/src/drivers/spi/amic.c @@ -109,7 +109,7 @@ return ret; } -int spi_flash_probe_amic(struct spi_slave *spi, u8 *idcode, +int spi_flash_probe_amic(const struct spi_slave *spi, u8 *idcode, struct spi_flash *flash) { const struct amic_spi_flash_params *params; diff --git a/src/drivers/spi/atmel.c b/src/drivers/spi/atmel.c index edc172e..b97f255 100644 --- a/src/drivers/spi/atmel.c +++ b/src/drivers/spi/atmel.c @@ -154,7 +154,7 @@ return ret; } -int spi_flash_probe_atmel(struct spi_slave *spi, u8 *idcode, +int spi_flash_probe_atmel(const struct spi_slave *spi, u8 *idcode, struct spi_flash *flash) { const struct atmel_spi_flash_params *params; diff --git a/src/drivers/spi/eon.c b/src/drivers/spi/eon.c index f5a3af6..ece9810 100644 --- a/src/drivers/spi/eon.c +++ b/src/drivers/spi/eon.c @@ -126,7 +126,7 @@ return ret; } -int spi_flash_probe_eon(struct spi_slave *spi, u8 *idcode, +int spi_flash_probe_eon(const struct spi_slave *spi, u8 *idcode, struct spi_flash *flash) { const struct eon_spi_flash_params *params; diff --git a/src/drivers/spi/gigadevice.c b/src/drivers/spi/gigadevice.c index 0b7173d..f68be8b 100644 --- a/src/drivers/spi/gigadevice.c +++ b/src/drivers/spi/gigadevice.c @@ -170,7 +170,7 @@ return ret; } -int spi_flash_probe_gigadevice(struct spi_slave *spi, u8 *idcode, +int spi_flash_probe_gigadevice(const struct spi_slave *spi, u8 *idcode, struct spi_flash *flash) { const struct gigadevice_spi_flash_params *params; diff --git a/src/drivers/spi/macronix.c b/src/drivers/spi/macronix.c index 87b6fd7..128d00f 100644 --- a/src/drivers/spi/macronix.c +++ b/src/drivers/spi/macronix.c @@ -192,7 +192,7 @@ return ret; } -int spi_flash_probe_macronix(struct spi_slave *spi, u8 *idcode, +int spi_flash_probe_macronix(const struct spi_slave *spi, u8 *idcode, struct spi_flash *flash) { const struct macronix_spi_flash_params *params; diff --git a/src/drivers/spi/spansion.c b/src/drivers/spi/spansion.c index a376b6e..de7ad55 100644 --- a/src/drivers/spi/spansion.c +++ b/src/drivers/spi/spansion.c @@ -246,7 +246,7 @@ return ret; } -int spi_flash_probe_spansion(struct spi_slave *spi, u8 *idcode, +int spi_flash_probe_spansion(const struct spi_slave *spi, u8 *idcode, struct spi_flash *flash) { const struct spansion_spi_flash_params *params; diff --git a/src/drivers/spi/spi_flash.c b/src/drivers/spi/spi_flash.c index 701033a..096d7cd 100644 --- a/src/drivers/spi/spi_flash.c +++ b/src/drivers/spi/spi_flash.c @@ -240,7 +240,7 @@ static struct { const u8 shift; const u8 idcode; - int (*probe) (struct spi_slave *spi, u8 *idcode, + int (*probe) (const struct spi_slave *spi, u8 *idcode, struct spi_flash *flash); } flashes[] = { /* Keep it sorted by define name */ @@ -282,7 +282,7 @@ #define IDCODE_LEN (IDCODE_CONT_LEN + IDCODE_PART_LEN) int -__attribute__((weak)) spi_flash_programmer_probe(struct spi_slave *spi, +__attribute__((weak)) spi_flash_programmer_probe(const struct spi_slave *spi, int force, struct spi_flash *flash) { @@ -290,7 +290,8 @@ return -1; } -static int __spi_flash_probe(struct spi_slave *spi, struct spi_flash *flash) +static int __spi_flash_probe(const struct spi_slave *spi, + struct spi_flash *flash) { int ret, i, shift; u8 idcode[IDCODE_LEN], *idp; diff --git a/src/drivers/spi/spi_flash_internal.h b/src/drivers/spi/spi_flash_internal.h index 55d3fa0..b42df59 100644 --- a/src/drivers/spi/spi_flash_internal.h +++ b/src/drivers/spi/spi_flash_internal.h @@ -64,25 +64,25 @@ int spi_flash_cmd_status(const struct spi_flash *flash, u8 *reg); /* Manufacturer-specific probe functions */ -int spi_flash_probe_spansion(struct spi_slave *spi, u8 *idcode, +int spi_flash_probe_spansion(const struct spi_slave *spi, u8 *idcode, struct spi_flash *flash); -int spi_flash_probe_amic(struct spi_slave *spi, u8 *idcode, +int spi_flash_probe_amic(const struct spi_slave *spi, u8 *idcode, struct spi_flash *flash); -int spi_flash_probe_atmel(struct spi_slave *spi, u8 *idcode, +int spi_flash_probe_atmel(const struct spi_slave *spi, u8 *idcode, struct spi_flash *flash); -int spi_flash_probe_eon(struct spi_slave *spi, u8 *idcode, +int spi_flash_probe_eon(const struct spi_slave *spi, u8 *idcode, struct spi_flash *flash); -int spi_flash_probe_macronix(struct spi_slave *spi, u8 *idcode, +int spi_flash_probe_macronix(const struct spi_slave *spi, u8 *idcode, struct spi_flash *flash); -int spi_flash_probe_sst(struct spi_slave *spi, u8 *idcode, +int spi_flash_probe_sst(const struct spi_slave *spi, u8 *idcode, struct spi_flash *flash); -int spi_flash_probe_stmicro(struct spi_slave *spi, u8 *idcode, +int spi_flash_probe_stmicro(const struct spi_slave *spi, u8 *idcode, struct spi_flash *flash); -int spi_flash_probe_winbond(struct spi_slave *spi, u8 *idcode, +int spi_flash_probe_winbond(const struct spi_slave *spi, u8 *idcode, struct spi_flash *flash); -int spi_flash_probe_gigadevice(struct spi_slave *spi, u8 *idcode, +int spi_flash_probe_gigadevice(const struct spi_slave *spi, u8 *idcode, struct spi_flash *flash); -int spi_flash_probe_adesto(struct spi_slave *spi, u8 *idcode, +int spi_flash_probe_adesto(const struct spi_slave *spi, u8 *idcode, struct spi_flash *flash); #endif /* SPI_FLASH_INTERNAL_H */ diff --git a/src/drivers/spi/sst.c b/src/drivers/spi/sst.c index bf21157..5325ef4 100644 --- a/src/drivers/spi/sst.c +++ b/src/drivers/spi/sst.c @@ -314,7 +314,7 @@ return ret; } -int spi_flash_probe_sst(struct spi_slave *spi, u8 *idcode, +int spi_flash_probe_sst(const struct spi_slave *spi, u8 *idcode, struct spi_flash *flash) { const struct sst_spi_flash_params *params; diff --git a/src/drivers/spi/stmicro.c b/src/drivers/spi/stmicro.c index b7ceba2..fe8c466 100644 --- a/src/drivers/spi/stmicro.c +++ b/src/drivers/spi/stmicro.c @@ -222,7 +222,7 @@ return ret; } -int spi_flash_probe_stmicro(struct spi_slave *spi, u8 *idcode, +int spi_flash_probe_stmicro(const struct spi_slave *spi, u8 *idcode, struct spi_flash *flash) { const struct stmicro_spi_flash_params *params; diff --git a/src/drivers/spi/winbond.c b/src/drivers/spi/winbond.c index c9d4aad..9694f8a 100644 --- a/src/drivers/spi/winbond.c +++ b/src/drivers/spi/winbond.c @@ -184,7 +184,7 @@ return ret; } -int spi_flash_probe_winbond(struct spi_slave *spi, u8 *idcode, +int spi_flash_probe_winbond(const struct spi_slave *spi, u8 *idcode, struct spi_flash *flash) { const struct winbond_spi_flash_params *params; diff --git a/src/include/spi_flash.h b/src/include/spi_flash.h index 3b18717..bc0318c 100644 --- a/src/include/spi_flash.h +++ b/src/include/spi_flash.h @@ -78,7 +78,7 @@ * 0 = success * non-zero = error */ -int spi_flash_programmer_probe(struct spi_slave *spi, int force, +int spi_flash_programmer_probe(const struct spi_slave *spi, int force, struct spi_flash *flash); /* All the following functions return 0 on success and non-zero on error. */ diff --git a/src/soc/intel/common/block/fast_spi/fast_spi_flash.c b/src/soc/intel/common/block/fast_spi/fast_spi_flash.c index 9f973b9..7780144 100644 --- a/src/soc/intel/common/block/fast_spi/fast_spi_flash.c +++ b/src/soc/intel/common/block/fast_spi/fast_spi_flash.c @@ -280,7 +280,7 @@ * The size of the flash component is always taken from density field in the * SFDP table. FLCOMP.C0DEN is no longer used by the Flash Controller. */ -int spi_flash_programmer_probe(struct spi_slave *dev, +int spi_flash_programmer_probe(const struct spi_slave *dev, int force, struct spi_flash *flash) { BOILERPLATE_CREATE_CTX(ctx); diff --git a/src/soc/mediatek/mt8173/flash_controller.c b/src/soc/mediatek/mt8173/flash_controller.c index 29a1c2f..ee950b8 100644 --- a/src/soc/mediatek/mt8173/flash_controller.c +++ b/src/soc/mediatek/mt8173/flash_controller.c @@ -228,7 +228,7 @@ return 0; } -int spi_flash_programmer_probe(struct spi_slave *spi, +int spi_flash_programmer_probe(const struct spi_slave *spi, int force, struct spi_flash *flash) { static int done; diff --git a/src/southbridge/intel/common/spi.c b/src/southbridge/intel/common/spi.c index effcc80..110c29c 100644 --- a/src/southbridge/intel/common/spi.c +++ b/src/southbridge/intel/common/spi.c @@ -899,7 +899,7 @@ return 0; } -int spi_flash_programmer_probe(struct spi_slave *spi, +int spi_flash_programmer_probe(const struct spi_slave *spi, int force, struct spi_flash *flash) { uint32_t flcomp; -- To view, visit
https://review.coreboot.org/19707
To unsubscribe, visit
https://review.coreboot.org/settings
Gerrit-MessageType: merged Gerrit-Change-Id: I956ee777c62dbb811fd6ce2aeb6ae090e1892acd Gerrit-PatchSet: 10 Gerrit-Project: coreboot Gerrit-Branch: master Gerrit-Owner: Furquan Shaikh <furquan(a)google.com> Gerrit-Reviewer: Aaron Durbin <adurbin(a)chromium.org> Gerrit-Reviewer: Duncan Laurie <dlaurie(a)chromium.org> Gerrit-Reviewer: Furquan Shaikh <furquan(a)google.com> Gerrit-Reviewer: Paul Menzel <paulepanter(a)users.sourceforge.net> Gerrit-Reviewer: build bot (Jenkins) <no-reply(a)coreboot.org>
1
0
0
0
Change in coreboot[master]: drivers/spi/spi_flash_internal: Remove unused spi_fram_probe...
by Furquan Shaikh (Code Review)
19 May '17
19 May '17
Furquan Shaikh has submitted this change and it was merged. (
https://review.coreboot.org/19706
) Change subject: drivers/spi/spi_flash_internal: Remove unused spi_fram_probe_ramtron ...................................................................... drivers/spi/spi_flash_internal: Remove unused spi_fram_probe_ramtron Remove unused function declaration spi_fram_probe_ramtron. BUG=b:38330715 Change-Id: I05e6c5c2b97d6c8a726c0e443ad855f9bcb703f9 Signed-off-by: Furquan Shaikh <furquan(a)chromium.org> Reviewed-on:
https://review.coreboot.org/19706
Reviewed-by: Aaron Durbin <adurbin(a)chromium.org> Tested-by: build bot (Jenkins) <no-reply(a)coreboot.org> --- M src/drivers/spi/spi_flash_internal.h 1 file changed, 0 insertions(+), 2 deletions(-) Approvals: Aaron Durbin: Looks good to me, approved build bot (Jenkins): Verified diff --git a/src/drivers/spi/spi_flash_internal.h b/src/drivers/spi/spi_flash_internal.h index 4ad0b09..55d3fa0 100644 --- a/src/drivers/spi/spi_flash_internal.h +++ b/src/drivers/spi/spi_flash_internal.h @@ -84,7 +84,5 @@ struct spi_flash *flash); int spi_flash_probe_adesto(struct spi_slave *spi, u8 *idcode, struct spi_flash *flash); -int spi_fram_probe_ramtron(struct spi_slave *spi, u8 *idcode, - struct spi_flash *flash); #endif /* SPI_FLASH_INTERNAL_H */ -- To view, visit
https://review.coreboot.org/19706
To unsubscribe, visit
https://review.coreboot.org/settings
Gerrit-MessageType: merged Gerrit-Change-Id: I05e6c5c2b97d6c8a726c0e443ad855f9bcb703f9 Gerrit-PatchSet: 10 Gerrit-Project: coreboot Gerrit-Branch: master Gerrit-Owner: Furquan Shaikh <furquan(a)google.com> Gerrit-Reviewer: Aaron Durbin <adurbin(a)chromium.org> Gerrit-Reviewer: Duncan Laurie <dlaurie(a)chromium.org> Gerrit-Reviewer: Furquan Shaikh <furquan(a)google.com> Gerrit-Reviewer: Paul Menzel <paulepanter(a)users.sourceforge.net> Gerrit-Reviewer: build bot (Jenkins) <no-reply(a)coreboot.org>
1
0
0
0
Change in coreboot[master]: drivers/spi/spi_flash: Pass in flash structure to fill in probe
by Furquan Shaikh (Code Review)
19 May '17
19 May '17
Furquan Shaikh has submitted this change and it was merged. (
https://review.coreboot.org/19705
) Change subject: drivers/spi/spi_flash: Pass in flash structure to fill in probe ...................................................................... drivers/spi/spi_flash: Pass in flash structure to fill in probe Instead of making all SPI drivers allocate space for a spi_flash structure and fill it in, udpate the API to allow callers to pass in a spi_flash structure that can be filled by the flash drivers as required. This also cleans up the interface so that the callers can maintain and free the space for spi_flash structure as required. BUG=b:38330715 Change-Id: If6f1b403731466525c4690777d9b32ce778eb563 Signed-off-by: Furquan Shaikh <furquan(a)chromium.org> Reviewed-on:
https://review.coreboot.org/19705
Tested-by: build bot (Jenkins) <no-reply(a)coreboot.org> Reviewed-by: Aaron Durbin <adurbin(a)chromium.org> --- M src/cpu/amd/pi/spi.c M src/drivers/intel/fsp1_0/fastboot_cache.c M src/drivers/spi/adesto.c M src/drivers/spi/amic.c M src/drivers/spi/atmel.c M src/drivers/spi/boot_device_rw_nommap.c M src/drivers/spi/cbfs_spi.c M src/drivers/spi/eon.c M src/drivers/spi/gigadevice.c M src/drivers/spi/macronix.c M src/drivers/spi/spansion.c M src/drivers/spi/spi_flash.c M src/drivers/spi/spi_flash_internal.h M src/drivers/spi/sst.c M src/drivers/spi/stmicro.c M src/drivers/spi/winbond.c M src/include/spi_flash.h M src/northbridge/amd/agesa/oem_s3.c M src/northbridge/amd/amdmct/mct_ddr3/s3utils.c M src/northbridge/intel/common/mrc_cache.c M src/soc/broadcom/cygnus/ddr_init.c M src/soc/intel/common/block/fast_spi/fast_spi_flash.c M src/soc/intel/fsp_baytrail/nvm.c M src/soc/mediatek/mt8173/flash_controller.c M src/southbridge/intel/common/spi.c 25 files changed, 261 insertions(+), 271 deletions(-) Approvals: Aaron Durbin: Looks good to me, approved build bot (Jenkins): Verified diff --git a/src/cpu/amd/pi/spi.c b/src/cpu/amd/pi/spi.c index 71b5d95..8ed0a37 100644 --- a/src/cpu/amd/pi/spi.c +++ b/src/cpu/amd/pi/spi.c @@ -21,23 +21,22 @@ void spi_SaveS3info(u32 pos, u32 size, u8 *buf, u32 len) { - struct spi_flash *flash; + struct spi_flash flash; spi_init(); - flash = spi_flash_probe(0, 0); - if (!flash) { + if (spi_flash_probe(0, 0, &flash)) { printk(BIOS_DEBUG, "Could not find SPI device\n"); /* Dont make flow stop. */ return; } - spi_flash_volatile_group_begin(flash); + spi_flash_volatile_group_begin(&flash); - spi_flash_erase(flash, pos, size); - spi_flash_write(flash, pos, sizeof(len), &len); - spi_flash_write(flash, pos + sizeof(len), len, buf); + spi_flash_erase(&flash, pos, size); + spi_flash_write(&flash, pos, sizeof(len), &len); + spi_flash_write(&flash, pos + sizeof(len), len, buf); - spi_flash_volatile_group_end(flash); + spi_flash_volatile_group_end(&flash); return; } diff --git a/src/drivers/intel/fsp1_0/fastboot_cache.c b/src/drivers/intel/fsp1_0/fastboot_cache.c index b57f382..906b356 100644 --- a/src/drivers/intel/fsp1_0/fastboot_cache.c +++ b/src/drivers/intel/fsp1_0/fastboot_cache.c @@ -157,6 +157,7 @@ struct mrc_data_container *current = cbmem_find(CBMEM_ID_MRCDATA); struct mrc_data_container *cache, *cache_base; u32 cache_size; + struct spi_flash flash; if (!current) { printk(BIOS_ERR, "No fast boot cache in cbmem. Can't update flash.\n"); @@ -189,8 +190,7 @@ /* 1. use spi_flash_probe() to find the flash, then... */ spi_init(); - struct spi_flash *flash = spi_flash_probe(0, 0); - if (!flash) { + if (spi_flash_probe(0, 0, &flash)) { printk(BIOS_DEBUG, "Could not find SPI device\n"); return; } @@ -209,7 +209,8 @@ "Need to erase the MRC cache region of %d bytes at %p\n", cache_size, cache_base); - spi_flash_erase(flash, to_flash_offset(cache_base), cache_size); + spi_flash_erase(&flash, to_flash_offset(cache_base), + cache_size); /* we will start at the beginning again */ cache = cache_base; @@ -217,7 +218,7 @@ /* 4. write mrc data with spi_flash_write() */ printk(BIOS_DEBUG, "Write MRC cache update to flash at %p\n", cache); - spi_flash_write(flash, to_flash_offset(cache), + spi_flash_write(&flash, to_flash_offset(cache), current->mrc_data_size + sizeof(*current), current); } diff --git a/src/drivers/spi/adesto.c b/src/drivers/spi/adesto.c index c5c68b5..d062c36 100644 --- a/src/drivers/spi/adesto.c +++ b/src/drivers/spi/adesto.c @@ -126,10 +126,10 @@ return ret; } -struct spi_flash *spi_flash_probe_adesto(struct spi_slave *spi, u8 *idcode) +int spi_flash_probe_adesto(struct spi_slave *spi, u8 *idcode, + struct spi_flash *flash) { const struct adesto_spi_flash_params *params; - struct spi_flash *flash; unsigned int i; for (i = 0; i < ARRAY_SIZE(adesto_spi_flash_table); i++) { @@ -141,13 +141,7 @@ if (i == ARRAY_SIZE(adesto_spi_flash_table)) { printk(BIOS_WARNING, "SF: Unsupported adesto ID %02x%02x\n", idcode[1], idcode[2]); - return NULL; - } - - flash = malloc(sizeof(*flash)); - if (!flash) { - printk(BIOS_WARNING, "SF: Failed to allocate memory\n"); - return NULL; + return -1; } memcpy(&flash->spi, spi, sizeof(*spi)); @@ -167,5 +161,5 @@ flash->internal_read = spi_flash_cmd_read_fast; #endif - return flash; + return 0; } diff --git a/src/drivers/spi/amic.c b/src/drivers/spi/amic.c index 6084360..cf5a296 100644 --- a/src/drivers/spi/amic.c +++ b/src/drivers/spi/amic.c @@ -109,11 +109,11 @@ return ret; } -struct spi_flash *spi_flash_probe_amic(struct spi_slave *spi, u8 *idcode) +int spi_flash_probe_amic(struct spi_slave *spi, u8 *idcode, + struct spi_flash *flash) { const struct amic_spi_flash_params *params; unsigned int i; - struct spi_flash *flash; for (i = 0; i < ARRAY_SIZE(amic_spi_flash_table); i++) { params = &amic_spi_flash_table[i]; @@ -124,13 +124,7 @@ if (i == ARRAY_SIZE(amic_spi_flash_table)) { printk(BIOS_WARNING, "SF: Unsupported AMIC ID %02x%02x\n", idcode[1], idcode[2]); - return NULL; - } - - flash = malloc(sizeof(*flash)); - if (!flash) { - printk(BIOS_WARNING, "SF: Failed to allocate memory\n"); - return NULL; + return -1; } memcpy(&flash->spi, spi, sizeof(*spi)); @@ -151,5 +145,5 @@ flash->internal_read = spi_flash_cmd_read_fast; #endif - return flash; + return 0; } diff --git a/src/drivers/spi/atmel.c b/src/drivers/spi/atmel.c index 4f614ff..edc172e 100644 --- a/src/drivers/spi/atmel.c +++ b/src/drivers/spi/atmel.c @@ -154,11 +154,11 @@ return ret; } -struct spi_flash *spi_flash_probe_atmel(struct spi_slave *spi, u8 *idcode) +int spi_flash_probe_atmel(struct spi_slave *spi, u8 *idcode, + struct spi_flash *flash) { const struct atmel_spi_flash_params *params; unsigned int i; - struct spi_flash *flash; for (i = 0; i < ARRAY_SIZE(atmel_spi_flash_table); i++) { params = &atmel_spi_flash_table[i]; @@ -169,13 +169,7 @@ if (i == ARRAY_SIZE(atmel_spi_flash_table)) { printk(BIOS_WARNING, "SF: Unsupported Atmel ID %02x%02x\n", idcode[1], idcode[2]); - return NULL; - } - - flash = malloc(sizeof(*flash)); - if (!flash) { - printk(BIOS_WARNING, "SF: Failed to allocate memory\n"); - return NULL; + return -1; } memcpy(&flash->spi, spi, sizeof(*spi)); @@ -196,5 +190,5 @@ flash->internal_read = spi_flash_cmd_read_fast; #endif - return flash; + return 0; } diff --git a/src/drivers/spi/boot_device_rw_nommap.c b/src/drivers/spi/boot_device_rw_nommap.c index e7d9b9a..64d81c5 100644 --- a/src/drivers/spi/boot_device_rw_nommap.c +++ b/src/drivers/spi/boot_device_rw_nommap.c @@ -17,13 +17,15 @@ #include <boot_device.h> #include <spi_flash.h> #include <spi-generic.h> +#include <stdint.h> -static struct spi_flash *sfg CAR_GLOBAL; +static struct spi_flash sfg CAR_GLOBAL; +static bool sfg_init_done CAR_GLOBAL; static ssize_t spi_readat(const struct region_device *rd, void *b, size_t offset, size_t size) { - struct spi_flash *sf = car_get_var(sfg); + struct spi_flash *sf = car_get_var_ptr(&sfg); if (sf == NULL) return -1; @@ -37,7 +39,7 @@ static ssize_t spi_writeat(const struct region_device *rd, const void *b, size_t offset, size_t size) { - struct spi_flash *sf = car_get_var(sfg); + struct spi_flash *sf = car_get_var_ptr(&sfg); if (sf == NULL) return -1; @@ -51,7 +53,7 @@ static ssize_t spi_eraseat(const struct region_device *rd, size_t offset, size_t size) { - struct spi_flash *sf = car_get_var(sfg); + struct spi_flash *sf = car_get_var_ptr(&sfg); if (sf == NULL) return -1; @@ -76,13 +78,14 @@ const int bus = CONFIG_BOOT_DEVICE_SPI_FLASH_BUS; const int cs = 0; - if (car_get_var(sfg) != NULL) + if (car_get_var(sfg_init_done) == true) return; /* Ensure any necessary setup is performed by the drivers. */ spi_init(); - car_set_var(sfg, spi_flash_probe(bus, cs)); + if (!spi_flash_probe(bus, cs, car_get_var_ptr(&sfg))) + car_set_var(sfg_init_done, true); } const struct region_device *boot_device_rw(void) @@ -90,7 +93,7 @@ /* Probe for the SPI flash device if not already done. */ boot_device_rw_init(); - if (car_get_var(sfg) == NULL) + if (car_get_var(sfg_init_done) != true) return NULL; return &spi_rw; @@ -99,5 +102,9 @@ const struct spi_flash *boot_device_spi_flash(void) { boot_device_rw_init(); - return car_get_var(sfg); + + if (car_get_var(sfg_init_done) != true) + return NULL; + + return car_get_var_ptr(&sfg); } diff --git a/src/drivers/spi/cbfs_spi.c b/src/drivers/spi/cbfs_spi.c index ae2994c..3e5f2af 100644 --- a/src/drivers/spi/cbfs_spi.c +++ b/src/drivers/spi/cbfs_spi.c @@ -24,9 +24,11 @@ #include <spi_flash.h> #include <symbols.h> #include <cbmem.h> +#include <stdint.h> #include <timer.h> -static struct spi_flash *spi_flash_info; +static struct spi_flash spi_flash_info; +static bool spi_flash_init_done; /* * Set this to 1 to debug SPI speed, 0 to disable it @@ -47,7 +49,7 @@ if (show) stopwatch_init(&sw); - if (spi_flash_read(spi_flash_info, offset, size, b)) + if (spi_flash_read(&spi_flash_info, offset, size, b)) return -1; if (show) { long usecs; @@ -68,7 +70,7 @@ static ssize_t spi_writeat(const struct region_device *rd, const void *b, size_t offset, size_t size) { - if (spi_flash_write(spi_flash_info, offset, size, b)) + if (spi_flash_write(&spi_flash_info, offset, size, b)) return -1; return size; } @@ -76,7 +78,7 @@ static ssize_t spi_eraseat(const struct region_device *rd, size_t offset, size_t size) { - if (spi_flash_erase(spi_flash_info, offset, size)) + if (spi_flash_erase(&spi_flash_info, offset, size)) return -1; return size; } @@ -112,10 +114,13 @@ int bus = CONFIG_BOOT_DEVICE_SPI_FLASH_BUS; int cs = 0; - if (spi_flash_info != NULL) + if (spi_flash_init_done == true) return; - spi_flash_info = spi_flash_probe(bus, cs); + if (spi_flash_probe(bus, cs, &spi_flash_info)) + return; + + spi_flash_init_done = true; mmap_helper_device_init(&mdev, _cbfs_cache, _cbfs_cache_size); } @@ -123,7 +128,7 @@ /* Return the CBFS boot device. */ const struct region_device *boot_device_ro(void) { - if (spi_flash_info == NULL) + if (spi_flash_init_done != true) return NULL; return &mdev.rdev; @@ -138,5 +143,9 @@ const struct spi_flash *boot_device_spi_flash(void) { boot_device_init(); - return spi_flash_info; + + if (spi_flash_init_done != true) + return NULL; + + return &spi_flash_info; } diff --git a/src/drivers/spi/eon.c b/src/drivers/spi/eon.c index 8ad5f84..f5a3af6 100644 --- a/src/drivers/spi/eon.c +++ b/src/drivers/spi/eon.c @@ -126,10 +126,10 @@ return ret; } -struct spi_flash *spi_flash_probe_eon(struct spi_slave *spi, u8 *idcode) +int spi_flash_probe_eon(struct spi_slave *spi, u8 *idcode, + struct spi_flash *flash) { const struct eon_spi_flash_params *params; - struct spi_flash *flash; unsigned int i; for (i = 0; i < ARRAY_SIZE(eon_spi_flash_table); ++i) { @@ -141,13 +141,7 @@ if (i == ARRAY_SIZE(eon_spi_flash_table)) { printk(BIOS_WARNING, "SF: Unsupported EON ID %#02x%02x\n", idcode[1], idcode[2]); - return NULL; - } - - flash = malloc(sizeof(*flash)); - if (!flash) { - printk(BIOS_WARNING, "SF: Failed to allocate memory\n"); - return NULL; + return -1; } memcpy(&flash->spi, spi, sizeof(*spi)); @@ -164,5 +158,5 @@ flash->internal_status = spi_flash_cmd_status; flash->internal_read = spi_flash_cmd_read_fast; - return flash; + return 0; } diff --git a/src/drivers/spi/gigadevice.c b/src/drivers/spi/gigadevice.c index bd6d6ed..0b7173d 100644 --- a/src/drivers/spi/gigadevice.c +++ b/src/drivers/spi/gigadevice.c @@ -170,9 +170,8 @@ return ret; } -static struct spi_flash flash; - -struct spi_flash *spi_flash_probe_gigadevice(struct spi_slave *spi, u8 *idcode) +int spi_flash_probe_gigadevice(struct spi_slave *spi, u8 *idcode, + struct spi_flash *flash) { const struct gigadevice_spi_flash_params *params; unsigned int i; @@ -187,28 +186,28 @@ printk(BIOS_WARNING, "SF gigadevice.c: Unsupported ID %#02x%02x\n", idcode[1], idcode[2]); - return NULL; + return -1; } - memcpy(&flash.spi, spi, sizeof(*spi)); - flash.name = params->name; + memcpy(&flash->spi, spi, sizeof(*spi)); + flash->name = params->name; /* Assuming power-of-two page size initially. */ - flash.page_size = 1 << params->l2_page_size; - flash.sector_size = flash.page_size * params->pages_per_sector; - flash.size = flash.sector_size * params->sectors_per_block * + flash->page_size = 1 << params->l2_page_size; + flash->sector_size = flash->page_size * params->pages_per_sector; + flash->size = flash->sector_size * params->sectors_per_block * params->nr_blocks; - flash.erase_cmd = CMD_GD25_SE; - flash.status_cmd = CMD_GD25_RDSR; + flash->erase_cmd = CMD_GD25_SE; + flash->status_cmd = CMD_GD25_RDSR; - flash.internal_write = gigadevice_write; - flash.internal_erase = spi_flash_cmd_erase; - flash.internal_status = spi_flash_cmd_status; + flash->internal_write = gigadevice_write; + flash->internal_erase = spi_flash_cmd_erase; + flash->internal_status = spi_flash_cmd_status; #if CONFIG_SPI_FLASH_NO_FAST_READ - flash.internal_read = spi_flash_cmd_read_slow; + flash->internal_read = spi_flash_cmd_read_slow; #else - flash.internal_read = spi_flash_cmd_read_fast; + flash->internal_read = spi_flash_cmd_read_fast; #endif - return &flash; + return 0; } diff --git a/src/drivers/spi/macronix.c b/src/drivers/spi/macronix.c index 6e17719..87b6fd7 100644 --- a/src/drivers/spi/macronix.c +++ b/src/drivers/spi/macronix.c @@ -192,9 +192,8 @@ return ret; } -static struct spi_flash flash; - -struct spi_flash *spi_flash_probe_macronix(struct spi_slave *spi, u8 *idcode) +int spi_flash_probe_macronix(struct spi_slave *spi, u8 *idcode, + struct spi_flash *flash) { const struct macronix_spi_flash_params *params; unsigned int i; @@ -208,26 +207,26 @@ if (i == ARRAY_SIZE(macronix_spi_flash_table)) { printk(BIOS_WARNING, "SF: Unsupported Macronix ID %04x\n", id); - return NULL; + return -1; } - memcpy(&flash.spi, spi, sizeof(*spi)); - flash.name = params->name; - flash.page_size = params->page_size; - flash.sector_size = params->page_size * params->pages_per_sector; - flash.size = flash.sector_size * params->sectors_per_block * + memcpy(&flash->spi, spi, sizeof(*spi)); + flash->name = params->name; + flash->page_size = params->page_size; + flash->sector_size = params->page_size * params->pages_per_sector; + flash->size = flash->sector_size * params->sectors_per_block * params->nr_blocks; - flash.erase_cmd = CMD_MX25XX_SE; - flash.status_cmd = CMD_MX25XX_RDSR; + flash->erase_cmd = CMD_MX25XX_SE; + flash->status_cmd = CMD_MX25XX_RDSR; - flash.internal_write = macronix_write; - flash.internal_erase = spi_flash_cmd_erase; - flash.internal_status = spi_flash_cmd_status; + flash->internal_write = macronix_write; + flash->internal_erase = spi_flash_cmd_erase; + flash->internal_status = spi_flash_cmd_status; #if CONFIG_SPI_FLASH_NO_FAST_READ - flash.internal_read = spi_flash_cmd_read_slow; + flash->internal_read = spi_flash_cmd_read_slow; #else - flash.internal_read = spi_flash_cmd_read_fast; + flash->internal_read = spi_flash_cmd_read_fast; #endif - return &flash; + return 0; } diff --git a/src/drivers/spi/spansion.c b/src/drivers/spi/spansion.c index 8f9e966..a376b6e 100644 --- a/src/drivers/spi/spansion.c +++ b/src/drivers/spi/spansion.c @@ -246,9 +246,8 @@ return ret; } -static struct spi_flash flash; - -struct spi_flash *spi_flash_probe_spansion(struct spi_slave *spi, u8 *idcode) +int spi_flash_probe_spansion(struct spi_slave *spi, u8 *idcode, + struct spi_flash *flash) { const struct spansion_spi_flash_params *params; unsigned int i; @@ -263,21 +262,21 @@ printk(BIOS_WARNING, "SF: Unsupported SPANSION ID %02x %02x %02x %02x %02x\n", idcode[0], idcode[1], idcode[2], idcode[3], idcode[4]); - return NULL; + return -1; } - memcpy(&flash.spi, spi, sizeof(*spi)); - flash.name = params->name; - flash.page_size = params->page_size; - flash.sector_size = params->page_size * params->pages_per_sector; - flash.size = flash.sector_size * params->nr_sectors; - flash.erase_cmd = CMD_S25FLXX_SE; - flash.status_cmd = CMD_S25FLXX_RDSR; + memcpy(&flash->spi, spi, sizeof(*spi)); + flash->name = params->name; + flash->page_size = params->page_size; + flash->sector_size = params->page_size * params->pages_per_sector; + flash->size = flash->sector_size * params->nr_sectors; + flash->erase_cmd = CMD_S25FLXX_SE; + flash->status_cmd = CMD_S25FLXX_RDSR; - flash.internal_write = spansion_write; - flash.internal_erase = spi_flash_cmd_erase; - flash.internal_read = spi_flash_cmd_read_slow; - flash.internal_status = spi_flash_cmd_status; + flash->internal_write = spansion_write; + flash->internal_erase = spi_flash_cmd_erase; + flash->internal_read = spi_flash_cmd_read_slow; + flash->internal_status = spi_flash_cmd_status; - return &flash; + return 0; } diff --git a/src/drivers/spi/spi_flash.c b/src/drivers/spi/spi_flash.c index e84df73..701033a 100644 --- a/src/drivers/spi/spi_flash.c +++ b/src/drivers/spi/spi_flash.c @@ -240,7 +240,8 @@ static struct { const u8 shift; const u8 idcode; - struct spi_flash *(*probe) (struct spi_slave *spi, u8 *idcode); + int (*probe) (struct spi_slave *spi, u8 *idcode, + struct spi_flash *flash); } flashes[] = { /* Keep it sorted by define name */ #if CONFIG_SPI_FLASH_AMIC @@ -280,24 +281,24 @@ }; #define IDCODE_LEN (IDCODE_CONT_LEN + IDCODE_PART_LEN) -struct spi_flash * +int __attribute__((weak)) spi_flash_programmer_probe(struct spi_slave *spi, - int force) + int force, + struct spi_flash *flash) { /* Default weak implementation. Do nothing. */ - return NULL; + return -1; } -static struct spi_flash *__spi_flash_probe(struct spi_slave *spi) +static int __spi_flash_probe(struct spi_slave *spi, struct spi_flash *flash) { int ret, i, shift; u8 idcode[IDCODE_LEN], *idp; - struct spi_flash *flash = NULL; /* Read the ID codes */ ret = spi_flash_cmd(spi, CMD_READ_ID, idcode, sizeof(idcode)); if (ret) - return NULL; + return -1; if (IS_ENABLED(CONFIG_DEBUG_SPI_FLASH)) { printk(BIOS_SPEW, "SF: Got idcode: "); @@ -317,45 +318,44 @@ for (i = 0; i < ARRAY_SIZE(flashes); ++i) if (flashes[i].shift == shift && flashes[i].idcode == *idp) { /* we have a match, call probe */ - flash = flashes[i].probe(spi, idp); - if (flash) - break; + if (flashes[i].probe(spi, idp, flash) == 0) + return 0; } - return flash; + /* No match, return error. */ + return -1; } -struct spi_flash *spi_flash_probe(unsigned int bus, unsigned int cs) +int spi_flash_probe(unsigned int bus, unsigned int cs, struct spi_flash *flash) { struct spi_slave spi; - struct spi_flash *flash; if (spi_setup_slave(bus, cs, &spi)) { printk(BIOS_WARNING, "SF: Failed to set up slave\n"); - return NULL; + return -1; } /* Try special programmer probe if any (without force). */ - flash = spi_flash_programmer_probe(&spi, 0); + if (spi_flash_programmer_probe(&spi, 0, flash) == 0) + goto flash_found; /* If flash is not found, try generic spi flash probe. */ - if (!flash) - flash = __spi_flash_probe(&spi); + if (__spi_flash_probe(&spi, flash) == 0) + goto flash_found; /* If flash is not yet found, force special programmer probe if any. */ - if (!flash) - flash = spi_flash_programmer_probe(&spi, 1); + if (spi_flash_programmer_probe(&spi, 1, flash) == 0) + goto flash_found; /* Give up -- nothing more to try if flash is not found. */ - if (!flash) { - printk(BIOS_WARNING, "SF: Unsupported manufacturer!\n"); - return NULL; - } + printk(BIOS_WARNING, "SF: Unsupported manufacturer!\n"); + return -1; +flash_found: printk(BIOS_INFO, "SF: Detected %s with sector size 0x%x, total 0x%x\n", flash->name, flash->sector_size, flash->size); - return flash; + return 0; } int spi_flash_read(const struct spi_flash *flash, u32 offset, size_t len, diff --git a/src/drivers/spi/spi_flash_internal.h b/src/drivers/spi/spi_flash_internal.h index 9b51723..4ad0b09 100644 --- a/src/drivers/spi/spi_flash_internal.h +++ b/src/drivers/spi/spi_flash_internal.h @@ -64,17 +64,27 @@ int spi_flash_cmd_status(const struct spi_flash *flash, u8 *reg); /* Manufacturer-specific probe functions */ -struct spi_flash *spi_flash_probe_spansion(struct spi_slave *spi, u8 *idcode); -struct spi_flash *spi_flash_probe_amic(struct spi_slave *spi, u8 *idcode); -struct spi_flash *spi_flash_probe_atmel(struct spi_slave *spi, u8 *idcode); -struct spi_flash *spi_flash_probe_eon(struct spi_slave *spi, u8 *idcode); -struct spi_flash *spi_flash_probe_macronix(struct spi_slave *spi, u8 *idcode); -struct spi_flash *spi_flash_probe_sst(struct spi_slave *spi, u8 *idcode); -struct spi_flash *spi_flash_probe_stmicro(struct spi_slave *spi, u8 *idcode); -struct spi_flash *spi_flash_probe_winbond(struct spi_slave *spi, u8 *idcode); -struct spi_flash *spi_flash_probe_gigadevice(struct spi_slave *spi, - u8 *idcode); -struct spi_flash *spi_flash_probe_adesto(struct spi_slave *spi, u8 *idcode); -struct spi_flash *spi_fram_probe_ramtron(struct spi_slave *spi, u8 *idcode); +int spi_flash_probe_spansion(struct spi_slave *spi, u8 *idcode, + struct spi_flash *flash); +int spi_flash_probe_amic(struct spi_slave *spi, u8 *idcode, + struct spi_flash *flash); +int spi_flash_probe_atmel(struct spi_slave *spi, u8 *idcode, + struct spi_flash *flash); +int spi_flash_probe_eon(struct spi_slave *spi, u8 *idcode, + struct spi_flash *flash); +int spi_flash_probe_macronix(struct spi_slave *spi, u8 *idcode, + struct spi_flash *flash); +int spi_flash_probe_sst(struct spi_slave *spi, u8 *idcode, + struct spi_flash *flash); +int spi_flash_probe_stmicro(struct spi_slave *spi, u8 *idcode, + struct spi_flash *flash); +int spi_flash_probe_winbond(struct spi_slave *spi, u8 *idcode, + struct spi_flash *flash); +int spi_flash_probe_gigadevice(struct spi_slave *spi, u8 *idcode, + struct spi_flash *flash); +int spi_flash_probe_adesto(struct spi_slave *spi, u8 *idcode, + struct spi_flash *flash); +int spi_fram_probe_ramtron(struct spi_slave *spi, u8 *idcode, + struct spi_flash *flash); #endif /* SPI_FLASH_INTERNAL_H */ diff --git a/src/drivers/spi/sst.c b/src/drivers/spi/sst.c index 0683846..bf21157 100644 --- a/src/drivers/spi/sst.c +++ b/src/drivers/spi/sst.c @@ -314,11 +314,10 @@ return ret; } -struct spi_flash * -spi_flash_probe_sst(struct spi_slave *spi, u8 *idcode) +int spi_flash_probe_sst(struct spi_slave *spi, u8 *idcode, + struct spi_flash *flash) { const struct sst_spi_flash_params *params; - struct spi_flash *flash; size_t i; for (i = 0; i < ARRAY_SIZE(sst_spi_flash_table); ++i) { @@ -329,13 +328,7 @@ if (i == ARRAY_SIZE(sst_spi_flash_table)) { printk(BIOS_WARNING, "SF: Unsupported SST ID %02x\n", idcode[1]); - return NULL; - } - - flash = malloc(sizeof(*flash)); - if (!flash) { - printk(BIOS_WARNING, "SF: Failed to allocate memory\n"); - return NULL; + return -1; } memcpy(&flash->spi, spi, sizeof(*spi)); @@ -353,5 +346,5 @@ /* Flash powers up read-only, so clear BP# bits */ sst_unlock(flash); - return flash; + return 0; } diff --git a/src/drivers/spi/stmicro.c b/src/drivers/spi/stmicro.c index 2ec9f18..b7ceba2 100644 --- a/src/drivers/spi/stmicro.c +++ b/src/drivers/spi/stmicro.c @@ -222,9 +222,8 @@ return ret; } -static struct spi_flash flash; - -struct spi_flash *spi_flash_probe_stmicro(struct spi_slave *spi, u8 * idcode) +int spi_flash_probe_stmicro(struct spi_slave *spi, u8 *idcode, + struct spi_flash *flash) { const struct stmicro_spi_flash_params *params; unsigned int i; @@ -232,13 +231,13 @@ if (idcode[0] == 0xff) { i = spi_flash_cmd(spi, CMD_M25PXX_RES, idcode, 4); if (i) - return NULL; + return -1; if ((idcode[3] & 0xf0) == 0x10) { idcode[0] = 0x20; idcode[1] = 0x20; idcode[2] = idcode[3] + 1; } else - return NULL; + return -1; } for (i = 0; i < ARRAY_SIZE(stmicro_spi_flash_table); i++) { @@ -251,19 +250,19 @@ if (i == ARRAY_SIZE(stmicro_spi_flash_table)) { printk(BIOS_WARNING, "SF: Unsupported STMicro ID %02x%02x\n", idcode[1], idcode[2]); - return NULL; + return -1; } - memcpy(&flash.spi, spi, sizeof(*spi)); - flash.name = params->name; - flash.page_size = params->page_size; - flash.sector_size = params->page_size * params->pages_per_sector; - flash.size = flash.sector_size * params->nr_sectors; - flash.erase_cmd = params->op_erase; + memcpy(&flash->spi, spi, sizeof(*spi)); + flash->name = params->name; + flash->page_size = params->page_size; + flash->sector_size = params->page_size * params->pages_per_sector; + flash->size = flash->sector_size * params->nr_sectors; + flash->erase_cmd = params->op_erase; - flash.internal_write = stmicro_write; - flash.internal_erase = spi_flash_cmd_erase; - flash.internal_read = spi_flash_cmd_read_fast; + flash->internal_write = stmicro_write; + flash->internal_erase = spi_flash_cmd_erase; + flash->internal_read = spi_flash_cmd_read_fast; - return &flash; + return 0; } diff --git a/src/drivers/spi/winbond.c b/src/drivers/spi/winbond.c index 3f167c0..c9d4aad 100644 --- a/src/drivers/spi/winbond.c +++ b/src/drivers/spi/winbond.c @@ -184,9 +184,8 @@ return ret; } -static struct spi_flash flash; - -struct spi_flash *spi_flash_probe_winbond(struct spi_slave *spi, u8 *idcode) +int spi_flash_probe_winbond(struct spi_slave *spi, u8 *idcode, + struct spi_flash *flash) { const struct winbond_spi_flash_params *params; unsigned int i; @@ -200,27 +199,27 @@ if (i == ARRAY_SIZE(winbond_spi_flash_table)) { printk(BIOS_WARNING, "SF: Unsupported Winbond ID %02x%02x\n", idcode[1], idcode[2]); - return NULL; + return -1; } - memcpy(&flash.spi, spi, sizeof(*spi)); - flash.name = params->name; + memcpy(&flash->spi, spi, sizeof(*spi)); + flash->name = params->name; /* Assuming power-of-two page size initially. */ - flash.page_size = 1 << params->l2_page_size; - flash.sector_size = flash.page_size * params->pages_per_sector; - flash.size = flash.sector_size * params->sectors_per_block * + flash->page_size = 1 << params->l2_page_size; + flash->sector_size = flash->page_size * params->pages_per_sector; + flash->size = flash->sector_size * params->sectors_per_block * params->nr_blocks; - flash.erase_cmd = CMD_W25_SE; - flash.status_cmd = CMD_W25_RDSR; + flash->erase_cmd = CMD_W25_SE; + flash->status_cmd = CMD_W25_RDSR; - flash.internal_write = winbond_write; - flash.internal_erase = spi_flash_cmd_erase; - flash.internal_status = spi_flash_cmd_status; + flash->internal_write = winbond_write; + flash->internal_erase = spi_flash_cmd_erase; + flash->internal_status = spi_flash_cmd_status; #if CONFIG_SPI_FLASH_NO_FAST_READ - flash.internal_read = spi_flash_cmd_read_slow; + flash->internal_read = spi_flash_cmd_read_slow; #else - flash.internal_read = spi_flash_cmd_read_fast; + flash->internal_read = spi_flash_cmd_read_fast; #endif - return &flash; + return 0; } diff --git a/src/include/spi_flash.h b/src/include/spi_flash.h index a72a13e..3b18717 100644 --- a/src/include/spi_flash.h +++ b/src/include/spi_flash.h @@ -50,14 +50,36 @@ void lb_spi_flash(struct lb_header *header); /* SPI Flash Driver Public API */ -struct spi_flash *spi_flash_probe(unsigned int bus, unsigned int cs); + +/* + * Probe for SPI flash chip on given SPI bus and chip select and fill info in + * spi_flash structure. + * + * Params: + * bus = SPI Bus # for the flash chip + * cs = Chip select # for the flash chip + * flash = Pointer to spi flash structure that needs to be filled + * + * Return value: + * 0 = success + * non-zero = error + */ +int spi_flash_probe(unsigned int bus, unsigned int cs, struct spi_flash *flash); /* * Specialized probing performed by platform. This is a weak function which can * be overriden by platform driver. + * + * Params: * spi = Pointer to spi_slave structure. * force = Indicates if the platform driver can skip specialized probing. + * flash = Pointer to spi_flash structure that needs to be filled. + * + * Return value: + * 0 = success + * non-zero = error */ -struct spi_flash *spi_flash_programmer_probe(struct spi_slave *spi, int force); +int spi_flash_programmer_probe(struct spi_slave *spi, int force, + struct spi_flash *flash); /* All the following functions return 0 on success and non-zero on error. */ int spi_flash_read(const struct spi_flash *flash, u32 offset, size_t len, diff --git a/src/northbridge/amd/agesa/oem_s3.c b/src/northbridge/amd/agesa/oem_s3.c index e3d58c2..02c384a 100644 --- a/src/northbridge/amd/agesa/oem_s3.c +++ b/src/northbridge/amd/agesa/oem_s3.c @@ -96,20 +96,19 @@ static int spi_SaveS3info(u32 pos, u32 size, u8 *buf, u32 len) { #if IS_ENABLED(CONFIG_SPI_FLASH) - struct spi_flash *flash; + struct spi_flash flash; spi_init(); - flash = spi_flash_probe(0, 0); - if (!flash) + if (spi_flash_probe(0, 0, &flash)) return -1; - spi_flash_volatile_group_begin(flash); + spi_flash_volatile_group_begin(&flash); - spi_flash_erase(flash, pos, size); - spi_flash_write(flash, pos, sizeof(len), &len); - spi_flash_write(flash, pos + sizeof(len), len, buf); + spi_flash_erase(&flash, pos, size); + spi_flash_write(&flash, pos, sizeof(len), &len); + spi_flash_write(&flash, pos + sizeof(len), len, buf); - spi_flash_volatile_group_end(flash); + spi_flash_volatile_group_end(&flash); return 0; #else return -1; diff --git a/src/northbridge/amd/amdmct/mct_ddr3/s3utils.c b/src/northbridge/amd/amdmct/mct_ddr3/s3utils.c index f69b6c4..4100b26 100644 --- a/src/northbridge/amd/amdmct/mct_ddr3/s3utils.c +++ b/src/northbridge/amd/amdmct/mct_ddr3/s3utils.c @@ -1100,7 +1100,7 @@ printk(BIOS_DEBUG, "Writing AMD DCT configuration to Flash\n"); - struct spi_flash *flash; + struct spi_flash flash; ssize_t s3nv_offset; struct amd_s3_persistent_data *persistent_data; @@ -1140,23 +1140,22 @@ /* Initialize SPI and detect devices */ spi_init(); - flash = spi_flash_probe(0, 0); - if (!flash) { + if (spi_flash_probe(0, 0, &flash)) { printk(BIOS_DEBUG, "Could not find SPI device\n"); return -1; } - spi_flash_volatile_group_begin(flash); + spi_flash_volatile_group_begin(&flash); /* Erase and write data structure */ - spi_flash_erase(flash, s3nv_offset, CONFIG_S3_DATA_SIZE); - spi_flash_write(flash, s3nv_offset, + spi_flash_erase(&flash, s3nv_offset, CONFIG_S3_DATA_SIZE); + spi_flash_write(&flash, s3nv_offset, sizeof(struct amd_s3_persistent_data), persistent_data); /* Deallocate temporary data structures */ free(persistent_data); - spi_flash_volatile_group_end(flash); + spi_flash_volatile_group_end(&flash); /* Allow training bypass if DIMM configuration is unchanged on next boot */ nvram = 1; diff --git a/src/northbridge/intel/common/mrc_cache.c b/src/northbridge/intel/common/mrc_cache.c index a158123..2fc8d96 100644 --- a/src/northbridge/intel/common/mrc_cache.c +++ b/src/northbridge/intel/common/mrc_cache.c @@ -160,6 +160,7 @@ struct mrc_data_container *cache, *cache_base; u32 cache_size; int ret; + struct spi_flash flash; if (!current) { printk(BIOS_ERR, "No MRC cache in cbmem. Can't update flash.\n"); @@ -192,8 +193,7 @@ // 1. use spi_flash_probe() to find the flash, then spi_init(); - struct spi_flash *flash = spi_flash_probe(0, 0); - if (!flash) { + if (spi_flash_probe(0, 0, &flash)) { printk(BIOS_DEBUG, "Could not find SPI device\n"); return; } @@ -212,7 +212,7 @@ "Need to erase the MRC cache region of %d bytes at %p\n", cache_size, cache_base); - spi_flash_erase(flash, to_flash_offset(flash, cache_base), + spi_flash_erase(&flash, to_flash_offset(&flash, cache_base), cache_size); /* we will start at the beginning again */ @@ -221,7 +221,7 @@ // 4. write mrc data with flash->write() printk(BIOS_DEBUG, "Finally: write MRC cache update to flash at %p\n", cache); - ret = spi_flash_write(flash, to_flash_offset(flash, cache), + ret = spi_flash_write(&flash, to_flash_offset(&flash, cache), current->mrc_data_size + sizeof(*current), current); if (ret) diff --git a/src/soc/broadcom/cygnus/ddr_init.c b/src/soc/broadcom/cygnus/ddr_init.c index b6bbf4a..5c4c985 100644 --- a/src/soc/broadcom/cygnus/ddr_init.c +++ b/src/soc/broadcom/cygnus/ddr_init.c @@ -717,7 +717,7 @@ static int write_shmoo_to_flash(void *buf, int length) { - struct spi_flash *flash; + struct spi_flash flash; int erase = 0; volatile uint32_t *flptr; int i, j, ret = 0; @@ -734,13 +734,7 @@ } /* Probe flash */ - flash = spi_flash_probe( - CONFIG_ENV_SPI_BUS, - CONFIG_ENV_SPI_CS, - CONFIG_ENV_SPI_MAX_HZ, - CONFIG_ENV_SPI_MODE - ); - if (!flash) { + if (spi_flash_probe(CONFIG_ENV_SPI_BUS, CONFIG_ENV_SPI_CS, &flash)) { printk(BIOS_ERR, "Failed to initialize SPI flash for saving Shmoo values!\n"); return -1; } @@ -748,25 +742,21 @@ /* Erase if necessary */ if (erase) { ret = spi_flash_erase( - flash, + &flash, offset / flash->sector_size * flash->sector_size, flash->sector_size ); if (ret) { printk(BIOS_ERR, "SPI flash erase failed, error=%d\n", ret); - spi_flash_free(flash); return ret; } } /* Write data */ - ret = spi_flash_write(flash, offset, length, buf); + ret = spi_flash_write(&flash, offset, length, buf); if (ret) { printk(BIOS_ERR, "SPI flash write failed, error=%d\n", ret); } - - /* Free flash instance */ - spi_flash_free(flash); return ret; } diff --git a/src/soc/intel/common/block/fast_spi/fast_spi_flash.c b/src/soc/intel/common/block/fast_spi/fast_spi_flash.c index 96a808d..9f973b9 100644 --- a/src/soc/intel/common/block/fast_spi/fast_spi_flash.c +++ b/src/soc/intel/common/block/fast_spi/fast_spi_flash.c @@ -169,9 +169,6 @@ } -/* Flash device operations. */ -static struct spi_flash boot_flash CAR_GLOBAL; - static int fast_spi_flash_erase(const struct spi_flash *flash, uint32_t offset, size_t len) { @@ -283,13 +280,11 @@ * The size of the flash component is always taken from density field in the * SFDP table. FLCOMP.C0DEN is no longer used by the Flash Controller. */ -struct spi_flash *spi_flash_programmer_probe(struct spi_slave *dev, int force) +int spi_flash_programmer_probe(struct spi_slave *dev, + int force, struct spi_flash *flash) { BOILERPLATE_CREATE_CTX(ctx); - struct spi_flash *flash; uint32_t flash_bits; - - flash = car_get_var_ptr(&boot_flash); /* * bytes = (bits + 1) / 8; @@ -317,7 +312,7 @@ flash->internal_read = fast_spi_flash_read; flash->internal_status = fast_spi_flash_status; - return flash; + return 0; } int spi_flash_get_fpr_info(struct fpr_info *info) diff --git a/src/soc/intel/fsp_baytrail/nvm.c b/src/soc/intel/fsp_baytrail/nvm.c index 6f2fdbb..a4a7998 100644 --- a/src/soc/intel/fsp_baytrail/nvm.c +++ b/src/soc/intel/fsp_baytrail/nvm.c @@ -21,25 +21,27 @@ #include <spi-generic.h> #include <spi_flash.h> #include <soc/nvm.h> +#include <stdint.h> /* This module assumes the flash is memory mapped just below 4GiB in the * address space for reading. Also this module assumes an area it erased * when all bytes read as all 0xff's. */ -static struct spi_flash *flash; +static struct spi_flash flash; +static bool spi_flash_init_done; static int nvm_init(void) { - if (flash != NULL) + if (spi_flash_init_done == true) return 0; spi_init(); - flash = spi_flash_probe(0, 0); - if (!flash) { + if (spi_flash_probe(0, 0, &flash)) { printk(BIOS_DEBUG, "Could not find SPI device\n"); return -1; } + spi_flash_init_done = true; return 0; } @@ -67,7 +69,7 @@ { if (nvm_init() < 0) return -1; - spi_flash_erase(flash, to_flash_offset(start), size); + spi_flash_erase(&flash, to_flash_offset(start), size); return 0; } @@ -76,6 +78,6 @@ { if (nvm_init() < 0) return -1; - spi_flash_write(flash, to_flash_offset(start), size, data); + spi_flash_write(&flash, to_flash_offset(start), size, data); return 0; } diff --git a/src/soc/mediatek/mt8173/flash_controller.c b/src/soc/mediatek/mt8173/flash_controller.c index 09df1a4..29a1c2f 100644 --- a/src/soc/mediatek/mt8173/flash_controller.c +++ b/src/soc/mediatek/mt8173/flash_controller.c @@ -228,24 +228,24 @@ return 0; } -struct spi_flash *spi_flash_programmer_probe(struct spi_slave *spi, int force) +int spi_flash_programmer_probe(struct spi_slave *spi, + int force, struct spi_flash *flash) { - static struct spi_flash flash; static int done; if (done) - return &flash; + return 0; write32(&mt8173_nor->wrprot, SFLASH_COMMAND_ENABLE); - memcpy(&flash.spi, spi, sizeof(*spi)); - flash.name = "mt8173 flash controller"; - flash.internal_write = nor_write; - flash.internal_erase = nor_erase; - flash.internal_read = nor_read; - flash.internal_status = 0; - flash.sector_size = 0x1000; - flash.erase_cmd = SECTOR_ERASE_CMD; - flash.size = CONFIG_ROM_SIZE; + memcpy(&flash->spi, spi, sizeof(*spi)); + flash->name = "mt8173 flash controller"; + flash->internal_write = nor_write; + flash->internal_erase = nor_erase; + flash->internal_read = nor_read; + flash->internal_status = 0; + flash->sector_size = 0x1000; + flash->erase_cmd = SECTOR_ERASE_CMD; + flash->size = CONFIG_ROM_SIZE; done = 1; - return &flash; + return 0; } diff --git a/src/southbridge/intel/common/spi.c b/src/southbridge/intel/common/spi.c index 11318f7..effcc80 100644 --- a/src/southbridge/intel/common/spi.c +++ b/src/southbridge/intel/common/spi.c @@ -899,10 +899,9 @@ return 0; } - -struct spi_flash *spi_flash_programmer_probe(struct spi_slave *spi, int force) +int spi_flash_programmer_probe(struct spi_slave *spi, + int force, struct spi_flash *flash) { - struct spi_flash *flash = NULL; uint32_t flcomp; /* @@ -911,13 +910,7 @@ * 2. Specialized probing is forced by SPI flash driver. */ if (!spi_is_multichip() && !force) - return NULL; - - flash = malloc(sizeof(*flash)); - if (!flash) { - printk(BIOS_WARNING, "SF: Failed to allocate memory\n"); - return NULL; - } + return -1; memcpy(&flash->spi, spi, sizeof(*spi)); flash->name = "Opaque HW-sequencing"; @@ -951,5 +944,5 @@ flash->size += 1 << (19 + ((flcomp >> 3) & 7)); printk (BIOS_DEBUG, "flash size 0x%x bytes\n", flash->size); - return flash; + return 0; } -- To view, visit
https://review.coreboot.org/19705
To unsubscribe, visit
https://review.coreboot.org/settings
Gerrit-MessageType: merged Gerrit-Change-Id: If6f1b403731466525c4690777d9b32ce778eb563 Gerrit-PatchSet: 10 Gerrit-Project: coreboot Gerrit-Branch: master Gerrit-Owner: Furquan Shaikh <furquan(a)google.com> Gerrit-Reviewer: Aaron Durbin <adurbin(a)chromium.org> Gerrit-Reviewer: Duncan Laurie <dlaurie(a)chromium.org> Gerrit-Reviewer: Furquan Shaikh <furquan(a)google.com> Gerrit-Reviewer: Paul Menzel <paulepanter(a)users.sourceforge.net> Gerrit-Reviewer: build bot (Jenkins) <no-reply(a)coreboot.org>
1
0
0
0
Change in coreboot[master]: drivers/spi/spi_flash: Add page_size to struct spi_flash
by Furquan Shaikh (Code Review)
19 May '17
19 May '17
Furquan Shaikh has submitted this change and it was merged. (
https://review.coreboot.org/19704
) Change subject: drivers/spi/spi_flash: Add page_size to struct spi_flash ...................................................................... drivers/spi/spi_flash: Add page_size to struct spi_flash Add a new member page_size to spi_flash structure so that the various spi flash drivers can store this info in spi_flash along with the other sizes (sector size and total size) during flash probe. This removes the need to have {driver}_spi_flash structure in every spi flash driver. This is part of patch series to clean up the SPI flash and SPI driver interface. BUG=b:38330715 Change-Id: I0f83e52cb1041432b0b575a8ee3bd173cc038d1f Signed-off-by: Furquan Shaikh <furquan(a)chromium.org> Reviewed-on:
https://review.coreboot.org/19704
Tested-by: build bot (Jenkins) <no-reply(a)coreboot.org> Reviewed-by: Aaron Durbin <adurbin(a)chromium.org> --- M src/drivers/spi/adesto.c M src/drivers/spi/amic.c M src/drivers/spi/atmel.c M src/drivers/spi/eon.c M src/drivers/spi/gigadevice.c M src/drivers/spi/macronix.c M src/drivers/spi/spansion.c M src/drivers/spi/sst.c M src/drivers/spi/stmicro.c M src/drivers/spi/winbond.c M src/include/spi_flash.h M src/soc/intel/common/block/fast_spi/fast_spi_flash.c 12 files changed, 162 insertions(+), 305 deletions(-) Approvals: Aaron Durbin: Looks good to me, approved build bot (Jenkins): Verified diff --git a/src/drivers/spi/adesto.c b/src/drivers/spi/adesto.c index 1091d9a..c5c68b5 100644 --- a/src/drivers/spi/adesto.c +++ b/src/drivers/spi/adesto.c @@ -42,18 +42,6 @@ const char *name; }; -/* spi_flash needs to be first so upper layers can free() it */ -struct adesto_spi_flash { - struct spi_flash flash; - const struct adesto_spi_flash_params *params; -}; - -static inline struct adesto_spi_flash * -to_adesto_spi_flash(const struct spi_flash *flash) -{ - return container_of(flash, struct adesto_spi_flash, flash); -} - static const struct adesto_spi_flash_params adesto_spi_flash_table[] = { { .id = 0x4501, @@ -84,7 +72,6 @@ static int adesto_write(const struct spi_flash *flash, u32 offset, size_t len, const void *buf) { - struct adesto_spi_flash *stm = to_adesto_spi_flash(flash); unsigned long byte_addr; unsigned long page_size; size_t chunk_len; @@ -92,7 +79,7 @@ int ret; u8 cmd[4]; - page_size = 1 << stm->params->l2_page_size; + page_size = flash->page_size; for (actual = 0; actual < len; actual += chunk_len) { byte_addr = offset % page_size; @@ -142,8 +129,7 @@ struct spi_flash *spi_flash_probe_adesto(struct spi_slave *spi, u8 *idcode) { const struct adesto_spi_flash_params *params; - unsigned page_size; - struct adesto_spi_flash *stm; + struct spi_flash *flash; unsigned int i; for (i = 0; i < ARRAY_SIZE(adesto_spi_flash_table); i++) { @@ -158,32 +144,28 @@ return NULL; } - stm = malloc(sizeof(struct adesto_spi_flash)); - if (!stm) { + flash = malloc(sizeof(*flash)); + if (!flash) { printk(BIOS_WARNING, "SF: Failed to allocate memory\n"); return NULL; } - stm->params = params; - memcpy(&stm->flash.spi, spi, sizeof(*spi)); - stm->flash.name = params->name; - + memcpy(&flash->spi, spi, sizeof(*spi)); + flash->name = params->name; /* Assuming power-of-two page size initially. */ - page_size = 1 << params->l2_page_size; + flash->page_size = 1 << params->l2_page_size; + flash->sector_size = flash->page_size * params->pages_per_sector; + flash->size = flash->sector_size *params->sectors_per_block * + params->nr_blocks; + flash->erase_cmd = CMD_AT25DF_SE; - stm->flash.internal_write = adesto_write; - stm->flash.internal_erase = spi_flash_cmd_erase; + flash->internal_write = adesto_write; + flash->internal_erase = spi_flash_cmd_erase; #if CONFIG_SPI_FLASH_NO_FAST_READ - stm->flash.internal_read = spi_flash_cmd_read_slow; + flash->internal_read = spi_flash_cmd_read_slow; #else - stm->flash.internal_read = spi_flash_cmd_read_fast; + flash->internal_read = spi_flash_cmd_read_fast; #endif - stm->flash.sector_size = (1 << stm->params->l2_page_size) * - stm->params->pages_per_sector; - stm->flash.size = page_size * params->pages_per_sector - * params->sectors_per_block - * params->nr_blocks; - stm->flash.erase_cmd = CMD_AT25DF_SE; - return &stm->flash; + return flash; } diff --git a/src/drivers/spi/amic.c b/src/drivers/spi/amic.c index 2ee5d69..6084360 100644 --- a/src/drivers/spi/amic.c +++ b/src/drivers/spi/amic.c @@ -40,18 +40,6 @@ const char *name; }; -/* spi_flash needs to be first so upper layers can free() it */ -struct amic_spi_flash { - struct spi_flash flash; - const struct amic_spi_flash_params *params; -}; - -static inline struct amic_spi_flash * -to_amic_spi_flash(const struct spi_flash *flash) -{ - return container_of(flash, struct amic_spi_flash, flash); -} - static const struct amic_spi_flash_params amic_spi_flash_table[] = { { .id = 0x3016, @@ -66,7 +54,6 @@ static int amic_write(const struct spi_flash *flash, u32 offset, size_t len, const void *buf) { - struct amic_spi_flash *amic = to_amic_spi_flash(flash); unsigned long byte_addr; unsigned long page_size; size_t chunk_len; @@ -74,7 +61,7 @@ int ret; u8 cmd[4]; - page_size = 1 << amic->params->l2_page_size; + page_size = flash->page_size; byte_addr = offset % page_size; for (actual = 0; actual < len; actual += chunk_len) { @@ -125,9 +112,8 @@ struct spi_flash *spi_flash_probe_amic(struct spi_slave *spi, u8 *idcode) { const struct amic_spi_flash_params *params; - unsigned page_size; - struct amic_spi_flash *amic; unsigned int i; + struct spi_flash *flash; for (i = 0; i < ARRAY_SIZE(amic_spi_flash_table); i++) { params = &amic_spi_flash_table[i]; @@ -141,32 +127,29 @@ return NULL; } - amic = malloc(sizeof(struct amic_spi_flash)); - if (!amic) { + flash = malloc(sizeof(*flash)); + if (!flash) { printk(BIOS_WARNING, "SF: Failed to allocate memory\n"); return NULL; } - amic->params = params; - memcpy(&amic->flash.spi, spi, sizeof(*spi)); - amic->flash.name = params->name; + memcpy(&flash->spi, spi, sizeof(*spi)); + flash->name = params->name; /* Assuming power-of-two page size initially. */ - page_size = 1 << params->l2_page_size; + flash->page_size = 1 << params->l2_page_size; + flash->sector_size = flash->page_size * params->pages_per_sector; + flash->size = flash->sector_size * params->sectors_per_block * + params->nr_blocks; + flash->erase_cmd = CMD_A25_SE; - amic->flash.internal_write = amic_write; - amic->flash.internal_erase = spi_flash_cmd_erase; + flash->internal_write = amic_write; + flash->internal_erase = spi_flash_cmd_erase; #if CONFIG_SPI_FLASH_NO_FAST_READ - amic->flash.internal_read = spi_flash_cmd_read_slow; + flash->internal_read = spi_flash_cmd_read_slow; #else - amic->flash.internal_read = spi_flash_cmd_read_fast; + flash->internal_read = spi_flash_cmd_read_fast; #endif - amic->flash.sector_size = (1 << amic->params->l2_page_size) * - amic->params->pages_per_sector; - amic->flash.size = page_size * params->pages_per_sector - * params->sectors_per_block - * params->nr_blocks; - amic->flash.erase_cmd = CMD_A25_SE; - return &amic->flash; + return flash; } diff --git a/src/drivers/spi/atmel.c b/src/drivers/spi/atmel.c index 4fe679d..4f614ff 100644 --- a/src/drivers/spi/atmel.c +++ b/src/drivers/spi/atmel.c @@ -38,18 +38,6 @@ const char *name; }; -/* spi_flash needs to be first so upper layers can free() it */ -struct atmel_spi_flash { - struct spi_flash flash; - const struct atmel_spi_flash_params *params; -}; - -static inline struct atmel_spi_flash * -to_atmel_spi_flash(const struct spi_flash *flash) -{ - return container_of(flash, struct atmel_spi_flash, flash); -} - static const struct atmel_spi_flash_params atmel_spi_flash_table[] = { { .id = 0x3015, @@ -112,7 +100,6 @@ static int atmel_write(const struct spi_flash *flash, u32 offset, size_t len, const void *buf) { - struct atmel_spi_flash *stm = to_atmel_spi_flash(flash); unsigned long byte_addr; unsigned long page_size; size_t chunk_len; @@ -120,7 +107,7 @@ int ret; u8 cmd[4]; - page_size = 1 << stm->params->l2_page_size; + page_size = flash->page_size; for (actual = 0; actual < len; actual += chunk_len) { byte_addr = offset % page_size; @@ -170,9 +157,8 @@ struct spi_flash *spi_flash_probe_atmel(struct spi_slave *spi, u8 *idcode) { const struct atmel_spi_flash_params *params; - unsigned page_size; - struct atmel_spi_flash *stm; unsigned int i; + struct spi_flash *flash; for (i = 0; i < ARRAY_SIZE(atmel_spi_flash_table); i++) { params = &atmel_spi_flash_table[i]; @@ -186,32 +172,29 @@ return NULL; } - stm = malloc(sizeof(struct atmel_spi_flash)); - if (!stm) { + flash = malloc(sizeof(*flash)); + if (!flash) { printk(BIOS_WARNING, "SF: Failed to allocate memory\n"); return NULL; } - stm->params = params; - memcpy(&stm->flash.spi, spi, sizeof(*spi)); - stm->flash.name = params->name; + memcpy(&flash->spi, spi, sizeof(*spi)); + flash->name = params->name; /* Assuming power-of-two page size initially. */ - page_size = 1 << params->l2_page_size; + flash->page_size = 1 << params->l2_page_size; + flash->sector_size = flash->page_size * params->pages_per_sector; + flash->size = flash->sector_size * params->sectors_per_block * + params->nr_blocks; + flash->erase_cmd = CMD_AT25_SE; - stm->flash.internal_write = atmel_write; - stm->flash.internal_erase = spi_flash_cmd_erase; + flash->internal_write = atmel_write; + flash->internal_erase = spi_flash_cmd_erase; #if CONFIG_SPI_FLASH_NO_FAST_READ - stm->flash.internal_read = spi_flash_cmd_read_slow; + flash->internal_read = spi_flash_cmd_read_slow; #else - stm->flash.internal_read = spi_flash_cmd_read_fast; + flash->internal_read = spi_flash_cmd_read_fast; #endif - stm->flash.sector_size = (1 << stm->params->l2_page_size) * - stm->params->pages_per_sector; - stm->flash.size = page_size * params->pages_per_sector - * params->sectors_per_block - * params->nr_blocks; - stm->flash.erase_cmd = CMD_AT25_SE; - return &stm->flash; + return flash; } diff --git a/src/drivers/spi/eon.c b/src/drivers/spi/eon.c index 9c1665d..8ad5f84 100644 --- a/src/drivers/spi/eon.c +++ b/src/drivers/spi/eon.c @@ -40,18 +40,6 @@ const char *name; }; -/* spi_flash needs to be first so upper layers can free() it */ -struct eon_spi_flash { - struct spi_flash flash; - const struct eon_spi_flash_params *params; -}; - -static inline -struct eon_spi_flash *to_eon_spi_flash(const struct spi_flash *flash) -{ - return container_of(flash, struct eon_spi_flash, flash); -} - static const struct eon_spi_flash_params eon_spi_flash_table[] = { { .id = EON_ID_EN25Q128, @@ -82,7 +70,6 @@ static int eon_write(const struct spi_flash *flash, u32 offset, size_t len, const void *buf) { - struct eon_spi_flash *eon = to_eon_spi_flash(flash); unsigned long byte_addr; unsigned long page_size; size_t chunk_len; @@ -90,7 +77,7 @@ int ret = 0; u8 cmd[4]; - page_size = 1 << eon->params->page_size; + page_size = flash->page_size; for (actual = 0; actual < len; actual += chunk_len) { byte_addr = offset % page_size; @@ -142,7 +129,7 @@ struct spi_flash *spi_flash_probe_eon(struct spi_slave *spi, u8 *idcode) { const struct eon_spi_flash_params *params; - struct eon_spi_flash *eon; + struct spi_flash *flash; unsigned int i; for (i = 0; i < ARRAY_SIZE(eon_spi_flash_table); ++i) { @@ -157,25 +144,25 @@ return NULL; } - eon = malloc(sizeof(*eon)); - if (!eon) { + flash = malloc(sizeof(*flash)); + if (!flash) { printk(BIOS_WARNING, "SF: Failed to allocate memory\n"); return NULL; } - eon->params = params; - memcpy(&eon->flash.spi, spi, sizeof(*spi)); - eon->flash.name = params->name; + memcpy(&flash->spi, spi, sizeof(*spi)); - eon->flash.internal_write = eon_write; - eon->flash.internal_erase = spi_flash_cmd_erase; - eon->flash.internal_status = spi_flash_cmd_status; - eon->flash.internal_read = spi_flash_cmd_read_fast; - eon->flash.sector_size = params->page_size * params->pages_per_sector; - eon->flash.size = params->page_size * params->pages_per_sector - * params->nr_sectors; - eon->flash.erase_cmd = CMD_EN25_SE; - eon->flash.status_cmd = CMD_EN25_RDSR; + flash->name = params->name; + flash->page_size = params->page_size; + flash->sector_size = params->page_size * params->pages_per_sector; + flash->size = flash->sector_size * params->nr_sectors; + flash->erase_cmd = CMD_EN25_SE; + flash->status_cmd = CMD_EN25_RDSR; - return &eon->flash; + flash->internal_write = eon_write; + flash->internal_erase = spi_flash_cmd_erase; + flash->internal_status = spi_flash_cmd_status; + flash->internal_read = spi_flash_cmd_read_fast; + + return flash; } diff --git a/src/drivers/spi/gigadevice.c b/src/drivers/spi/gigadevice.c index cbc9744..bd6d6ed 100644 --- a/src/drivers/spi/gigadevice.c +++ b/src/drivers/spi/gigadevice.c @@ -49,18 +49,6 @@ const char *name; }; -/* spi_flash needs to be first so upper layers can free() it */ -struct gigadevice_spi_flash { - struct spi_flash flash; - const struct gigadevice_spi_flash_params *params; -}; - -static inline struct gigadevice_spi_flash * -to_gigadevice_spi_flash(const struct spi_flash *flash) -{ - return container_of(flash, struct gigadevice_spi_flash, flash); -} - static const struct gigadevice_spi_flash_params gigadevice_spi_flash_table[] = { { .id = 0x4014, @@ -123,7 +111,6 @@ static int gigadevice_write(const struct spi_flash *flash, u32 offset, size_t len, const void *buf) { - struct gigadevice_spi_flash *stm = to_gigadevice_spi_flash(flash); unsigned long byte_addr; unsigned long page_size; size_t chunk_len; @@ -131,7 +118,7 @@ int ret = 0; u8 cmd[4]; - page_size = 1 << stm->params->l2_page_size; + page_size = flash->page_size; for (actual = 0; actual < len; actual += chunk_len) { byte_addr = offset % page_size; @@ -183,12 +170,11 @@ return ret; } -static struct gigadevice_spi_flash stm; +static struct spi_flash flash; struct spi_flash *spi_flash_probe_gigadevice(struct spi_slave *spi, u8 *idcode) { const struct gigadevice_spi_flash_params *params; - unsigned page_size; unsigned int i; for (i = 0; i < ARRAY_SIZE(gigadevice_spi_flash_table); i++) { @@ -204,28 +190,25 @@ return NULL; } - stm.params = params; - memcpy(&stm.flash.spi, spi, sizeof(*spi)); - stm.flash.name = params->name; + memcpy(&flash.spi, spi, sizeof(*spi)); + flash.name = params->name; /* Assuming power-of-two page size initially. */ - page_size = 1 << params->l2_page_size; + flash.page_size = 1 << params->l2_page_size; + flash.sector_size = flash.page_size * params->pages_per_sector; + flash.size = flash.sector_size * params->sectors_per_block * + params->nr_blocks; + flash.erase_cmd = CMD_GD25_SE; + flash.status_cmd = CMD_GD25_RDSR; - stm.flash.internal_write = gigadevice_write; - stm.flash.internal_erase = spi_flash_cmd_erase; - stm.flash.internal_status = spi_flash_cmd_status; + flash.internal_write = gigadevice_write; + flash.internal_erase = spi_flash_cmd_erase; + flash.internal_status = spi_flash_cmd_status; #if CONFIG_SPI_FLASH_NO_FAST_READ - stm.flash.internal_read = spi_flash_cmd_read_slow; + flash.internal_read = spi_flash_cmd_read_slow; #else - stm.flash.internal_read = spi_flash_cmd_read_fast; + flash.internal_read = spi_flash_cmd_read_fast; #endif - stm.flash.sector_size = (1 << stm.params->l2_page_size) * - stm.params->pages_per_sector; - stm.flash.size = page_size * params->pages_per_sector - * params->sectors_per_block - * params->nr_blocks; - stm.flash.erase_cmd = CMD_GD25_SE; - stm.flash.status_cmd = CMD_GD25_RDSR; - return &stm.flash; + return &flash; } diff --git a/src/drivers/spi/macronix.c b/src/drivers/spi/macronix.c index 07d1e56..6e17719 100644 --- a/src/drivers/spi/macronix.c +++ b/src/drivers/spi/macronix.c @@ -54,17 +54,6 @@ const char *name; }; -struct macronix_spi_flash { - struct spi_flash flash; - const struct macronix_spi_flash_params *params; -}; - -static inline -struct macronix_spi_flash *to_macronix_spi_flash(const struct spi_flash *flash) -{ - return container_of(flash, struct macronix_spi_flash, flash); -} - static const struct macronix_spi_flash_params macronix_spi_flash_table[] = { { .idcode = 0x2015, @@ -151,7 +140,6 @@ static int macronix_write(const struct spi_flash *flash, u32 offset, size_t len, const void *buf) { - struct macronix_spi_flash *mcx = to_macronix_spi_flash(flash); unsigned long byte_addr; unsigned long page_size; size_t chunk_len; @@ -159,7 +147,7 @@ int ret = 0; u8 cmd[4]; - page_size = mcx->params->page_size; + page_size = flash->page_size; for (actual = 0; actual < len; actual += chunk_len) { byte_addr = offset % page_size; @@ -204,7 +192,7 @@ return ret; } -static struct macronix_spi_flash mcx; +static struct spi_flash flash; struct spi_flash *spi_flash_probe_macronix(struct spi_slave *spi, u8 *idcode) { @@ -223,23 +211,23 @@ return NULL; } - mcx.params = params; - memcpy(&mcx.flash.spi, spi, sizeof(*spi)); - mcx.flash.name = params->name; + memcpy(&flash.spi, spi, sizeof(*spi)); + flash.name = params->name; + flash.page_size = params->page_size; + flash.sector_size = params->page_size * params->pages_per_sector; + flash.size = flash.sector_size * params->sectors_per_block * + params->nr_blocks; + flash.erase_cmd = CMD_MX25XX_SE; + flash.status_cmd = CMD_MX25XX_RDSR; - mcx.flash.internal_write = macronix_write; - mcx.flash.internal_erase = spi_flash_cmd_erase; - mcx.flash.internal_status = spi_flash_cmd_status; + flash.internal_write = macronix_write; + flash.internal_erase = spi_flash_cmd_erase; + flash.internal_status = spi_flash_cmd_status; #if CONFIG_SPI_FLASH_NO_FAST_READ - mcx.flash.internal_read = spi_flash_cmd_read_slow; + flash.internal_read = spi_flash_cmd_read_slow; #else - mcx.flash.internal_read = spi_flash_cmd_read_fast; + flash.internal_read = spi_flash_cmd_read_fast; #endif - mcx.flash.sector_size = params->page_size * params->pages_per_sector; - mcx.flash.size = mcx.flash.sector_size * params->sectors_per_block * - params->nr_blocks; - mcx.flash.erase_cmd = CMD_MX25XX_SE; - mcx.flash.status_cmd = CMD_MX25XX_RDSR; - return &mcx.flash; + return &flash; } diff --git a/src/drivers/spi/spansion.c b/src/drivers/spi/spansion.c index 139e823..8f9e966 100644 --- a/src/drivers/spi/spansion.c +++ b/src/drivers/spi/spansion.c @@ -64,17 +64,6 @@ const char *name; }; -struct spansion_spi_flash { - struct spi_flash flash; - const struct spansion_spi_flash_params *params; -}; - -static inline -struct spansion_spi_flash *to_spansion_spi_flash(const struct spi_flash *flash) -{ - return container_of(flash, struct spansion_spi_flash, flash); -} - /* * returns non-zero if the given idcode matches the ID of the chip. this is for * chips which use 2nd, 3rd, 4th, and 5th byte. @@ -204,7 +193,6 @@ static int spansion_write(const struct spi_flash *flash, u32 offset, size_t len, const void *buf) { - struct spansion_spi_flash *spsn = to_spansion_spi_flash(flash); unsigned long byte_addr; unsigned long page_size; size_t chunk_len; @@ -212,7 +200,7 @@ int ret = 0; u8 cmd[4]; - page_size = spsn->params->page_size; + page_size = flash->page_size; for (actual = 0; actual < len; actual += chunk_len) { byte_addr = offset % page_size; @@ -258,12 +246,11 @@ return ret; } -static struct spansion_spi_flash spsn_flash; +static struct spi_flash flash; struct spi_flash *spi_flash_probe_spansion(struct spi_slave *spi, u8 *idcode) { const struct spansion_spi_flash_params *params; - struct spansion_spi_flash *spsn; unsigned int i; for (i = 0; i < ARRAY_SIZE(spansion_spi_flash_table); i++) { @@ -279,20 +266,18 @@ return NULL; } - spsn = &spsn_flash; + memcpy(&flash.spi, spi, sizeof(*spi)); + flash.name = params->name; + flash.page_size = params->page_size; + flash.sector_size = params->page_size * params->pages_per_sector; + flash.size = flash.sector_size * params->nr_sectors; + flash.erase_cmd = CMD_S25FLXX_SE; + flash.status_cmd = CMD_S25FLXX_RDSR; - spsn->params = params; - memcpy(&spsn->flash.spi, spi, sizeof(*spi)); - spsn->flash.name = params->name; + flash.internal_write = spansion_write; + flash.internal_erase = spi_flash_cmd_erase; + flash.internal_read = spi_flash_cmd_read_slow; + flash.internal_status = spi_flash_cmd_status; - spsn->flash.internal_write = spansion_write; - spsn->flash.internal_erase = spi_flash_cmd_erase; - spsn->flash.internal_read = spi_flash_cmd_read_slow; - spsn->flash.internal_status = spi_flash_cmd_status; - spsn->flash.sector_size = params->page_size * params->pages_per_sector; - spsn->flash.size = spsn->flash.sector_size * params->nr_sectors; - spsn->flash.erase_cmd = CMD_S25FLXX_SE; - spsn->flash.status_cmd = CMD_S25FLXX_RDSR; - - return &spsn->flash; + return &flash; } diff --git a/src/drivers/spi/sst.c b/src/drivers/spi/sst.c index c9762ac..0683846 100644 --- a/src/drivers/spi/sst.c +++ b/src/drivers/spi/sst.c @@ -47,11 +47,6 @@ size_t len, const void *buf); }; -struct sst_spi_flash { - struct spi_flash flash; - const struct sst_spi_flash_params *params; -}; - static int sst_write_ai(const struct spi_flash *flash, u32 offset, size_t len, const void *buf); static int sst_write_256(const struct spi_flash *flash, u32 offset, size_t len, @@ -323,7 +318,7 @@ spi_flash_probe_sst(struct spi_slave *spi, u8 *idcode) { const struct sst_spi_flash_params *params; - struct sst_spi_flash *stm; + struct spi_flash *flash; size_t i; for (i = 0; i < ARRAY_SIZE(sst_spi_flash_table); ++i) { @@ -337,27 +332,26 @@ return NULL; } - stm = malloc(sizeof(*stm)); - if (!stm) { + flash = malloc(sizeof(*flash)); + if (!flash) { printk(BIOS_WARNING, "SF: Failed to allocate memory\n"); return NULL; } - stm->params = params; - memcpy(&stm->flash.spi, spi, sizeof(*spi)); - stm->flash.name = params->name; + memcpy(&flash->spi, spi, sizeof(*spi)); + flash->name = params->name; + flash->sector_size = SST_SECTOR_SIZE; + flash->size = flash->sector_size * params->nr_sectors; + flash->erase_cmd = CMD_SST_SE; + flash->status_cmd = CMD_SST_RDSR; - stm->flash.internal_write = params->write; - stm->flash.internal_erase = spi_flash_cmd_erase; - stm->flash.internal_status = spi_flash_cmd_status; - stm->flash.internal_read = spi_flash_cmd_read_fast; - stm->flash.sector_size = SST_SECTOR_SIZE; - stm->flash.size = stm->flash.sector_size * params->nr_sectors; - stm->flash.erase_cmd = CMD_SST_SE; - stm->flash.status_cmd = CMD_SST_RDSR; + flash->internal_write = params->write; + flash->internal_erase = spi_flash_cmd_erase; + flash->internal_status = spi_flash_cmd_status; + flash->internal_read = spi_flash_cmd_read_fast; /* Flash powers up read-only, so clear BP# bits */ - sst_unlock(&stm->flash); + sst_unlock(flash); - return &stm->flash; + return flash; } diff --git a/src/drivers/spi/stmicro.c b/src/drivers/spi/stmicro.c index 06004f1..2ec9f18 100644 --- a/src/drivers/spi/stmicro.c +++ b/src/drivers/spi/stmicro.c @@ -66,18 +66,6 @@ const char *name; }; -/* spi_flash needs to be first so upper layers can free() it */ -struct stmicro_spi_flash { - struct spi_flash flash; - const struct stmicro_spi_flash_params *params; -}; - -static inline -struct stmicro_spi_flash *to_stmicro_spi_flash(const struct spi_flash *flash) -{ - return container_of(flash, struct stmicro_spi_flash, flash); -} - static const struct stmicro_spi_flash_params stmicro_spi_flash_table[] = { { .device_id = STM_ID_M25P10, @@ -180,7 +168,6 @@ static int stmicro_write(const struct spi_flash *flash, u32 offset, size_t len, const void *buf) { - struct stmicro_spi_flash *stm = to_stmicro_spi_flash(flash); unsigned long byte_addr; unsigned long page_size; size_t chunk_len; @@ -188,7 +175,7 @@ int ret = 0; u8 cmd[4]; - page_size = stm->params->page_size; + page_size = flash->page_size; for (actual = 0; actual < len; actual += chunk_len) { byte_addr = offset % page_size; @@ -235,7 +222,7 @@ return ret; } -static struct stmicro_spi_flash stm; +static struct spi_flash flash; struct spi_flash *spi_flash_probe_stmicro(struct spi_slave *spi, u8 * idcode) { @@ -267,16 +254,16 @@ return NULL; } - stm.params = params; - memcpy(&stm.flash.spi, spi, sizeof(*spi)); - stm.flash.name = params->name; + memcpy(&flash.spi, spi, sizeof(*spi)); + flash.name = params->name; + flash.page_size = params->page_size; + flash.sector_size = params->page_size * params->pages_per_sector; + flash.size = flash.sector_size * params->nr_sectors; + flash.erase_cmd = params->op_erase; - stm.flash.internal_write = stmicro_write; - stm.flash.internal_erase = spi_flash_cmd_erase; - stm.flash.internal_read = spi_flash_cmd_read_fast; - stm.flash.sector_size = params->page_size * params->pages_per_sector; - stm.flash.size = stm.flash.sector_size * params->nr_sectors; - stm.flash.erase_cmd = params->op_erase; + flash.internal_write = stmicro_write; + flash.internal_erase = spi_flash_cmd_erase; + flash.internal_read = spi_flash_cmd_read_fast; - return &stm.flash; + return &flash; } diff --git a/src/drivers/spi/winbond.c b/src/drivers/spi/winbond.c index 25a7b5b..3f167c0 100644 --- a/src/drivers/spi/winbond.c +++ b/src/drivers/spi/winbond.c @@ -36,18 +36,6 @@ const char *name; }; -/* spi_flash needs to be first so upper layers can free() it */ -struct winbond_spi_flash { - struct spi_flash flash; - const struct winbond_spi_flash_params *params; -}; - -static inline struct winbond_spi_flash * -to_winbond_spi_flash(const struct spi_flash *flash) -{ - return container_of(flash, struct winbond_spi_flash, flash); -} - static const struct winbond_spi_flash_params winbond_spi_flash_table[] = { { .id = 0x3015, @@ -142,7 +130,6 @@ static int winbond_write(const struct spi_flash *flash, u32 offset, size_t len, const void *buf) { - struct winbond_spi_flash *stm = to_winbond_spi_flash(flash); unsigned long byte_addr; unsigned long page_size; size_t chunk_len; @@ -150,7 +137,7 @@ int ret = 0; u8 cmd[4]; - page_size = 1 << stm->params->l2_page_size; + page_size = flash->page_size; for (actual = 0; actual < len; actual += chunk_len) { byte_addr = offset % page_size; @@ -197,12 +184,11 @@ return ret; } -static struct winbond_spi_flash stm; +static struct spi_flash flash; struct spi_flash *spi_flash_probe_winbond(struct spi_slave *spi, u8 *idcode) { const struct winbond_spi_flash_params *params; - unsigned page_size; unsigned int i; for (i = 0; i < ARRAY_SIZE(winbond_spi_flash_table); i++) { @@ -217,28 +203,24 @@ return NULL; } - stm.params = params; - memcpy(&stm.flash.spi, spi, sizeof(*spi)); - stm.flash.name = params->name; - + memcpy(&flash.spi, spi, sizeof(*spi)); + flash.name = params->name; /* Assuming power-of-two page size initially. */ - page_size = 1 << params->l2_page_size; + flash.page_size = 1 << params->l2_page_size; + flash.sector_size = flash.page_size * params->pages_per_sector; + flash.size = flash.sector_size * params->sectors_per_block * + params->nr_blocks; + flash.erase_cmd = CMD_W25_SE; + flash.status_cmd = CMD_W25_RDSR; - stm.flash.internal_write = winbond_write; - stm.flash.internal_erase = spi_flash_cmd_erase; - stm.flash.internal_status = spi_flash_cmd_status; + flash.internal_write = winbond_write; + flash.internal_erase = spi_flash_cmd_erase; + flash.internal_status = spi_flash_cmd_status; #if CONFIG_SPI_FLASH_NO_FAST_READ - stm.flash.internal_read = spi_flash_cmd_read_slow; + flash.internal_read = spi_flash_cmd_read_slow; #else - stm.flash.internal_read = spi_flash_cmd_read_fast; + flash.internal_read = spi_flash_cmd_read_fast; #endif - stm.flash.sector_size = (1 << stm.params->l2_page_size) * - stm.params->pages_per_sector; - stm.flash.size = page_size * params->pages_per_sector - * params->sectors_per_block - * params->nr_blocks; - stm.flash.erase_cmd = CMD_W25_SE; - stm.flash.status_cmd = CMD_W25_RDSR; - return &stm.flash; + return &flash; } diff --git a/src/include/spi_flash.h b/src/include/spi_flash.h index 6b89012..a72a13e 100644 --- a/src/include/spi_flash.h +++ b/src/include/spi_flash.h @@ -29,6 +29,7 @@ const char *name; u32 size; u32 sector_size; + u32 page_size; u8 erase_cmd; u8 status_cmd; /* diff --git a/src/soc/intel/common/block/fast_spi/fast_spi_flash.c b/src/soc/intel/common/block/fast_spi/fast_spi_flash.c index d56b33f..96a808d 100644 --- a/src/soc/intel/common/block/fast_spi/fast_spi_flash.c +++ b/src/soc/intel/common/block/fast_spi/fast_spi_flash.c @@ -154,12 +154,13 @@ /* * Ensure read/write xfer len is not greater than SPIBAR_FDATA_FIFO_SIZE and - * that the operation does not cross 256-byte boundary. + * that the operation does not cross page boundary. */ -static size_t get_xfer_len(uint32_t addr, size_t len) +static size_t get_xfer_len(const struct spi_flash *flash, uint32_t addr, + size_t len) { size_t xfer_len = min(len, SPIBAR_FDATA_FIFO_SIZE); - size_t bytes_left = ALIGN_UP(addr, 256) - addr; + size_t bytes_left = ALIGN_UP(addr, flash->page_size) - addr; if (bytes_left) xfer_len = min(xfer_len, bytes_left); @@ -217,7 +218,7 @@ BOILERPLATE_CREATE_CTX(ctx); while (len) { - xfer_len = get_xfer_len(addr, len); + xfer_len = get_xfer_len(flash, addr, len); ret = exec_sync_hwseq_xfer(ctx, SPIBAR_HSFSTS_CYCLE_READ, addr, xfer_len); @@ -244,7 +245,7 @@ BOILERPLATE_CREATE_CTX(ctx); while (len) { - xfer_len = get_xfer_len(addr, len); + xfer_len = get_xfer_len(flash, addr, len); fill_xfer_fifo(ctx, data, xfer_len); ret = exec_sync_hwseq_xfer(ctx, SPIBAR_HSFSTS_CYCLE_WRITE, @@ -303,6 +304,7 @@ /* Can erase both 4 KiB and 64 KiB chunks. Declare the smaller size. */ flash->sector_size = 4 * KiB; + flash->page_size = 256; /* * FIXME: Get erase+cmd, and status_cmd from SFDP. * -- To view, visit
https://review.coreboot.org/19704
To unsubscribe, visit
https://review.coreboot.org/settings
Gerrit-MessageType: merged Gerrit-Change-Id: I0f83e52cb1041432b0b575a8ee3bd173cc038d1f Gerrit-PatchSet: 9 Gerrit-Project: coreboot Gerrit-Branch: master Gerrit-Owner: Furquan Shaikh <furquan(a)google.com> Gerrit-Reviewer: Aaron Durbin <adurbin(a)chromium.org> Gerrit-Reviewer: Duncan Laurie <dlaurie(a)chromium.org> Gerrit-Reviewer: Furquan Shaikh <furquan(a)google.com> Gerrit-Reviewer: Paul Menzel <paulepanter(a)users.sourceforge.net> Gerrit-Reviewer: build bot (Jenkins) <no-reply(a)coreboot.org>
1
0
0
0
Change in coreboot[master]: drivers/spi/spi_flash: Use boot_device_spi_flash to obtain s...
by Furquan Shaikh (Code Review)
19 May '17
19 May '17
Furquan Shaikh has submitted this change and it was merged. (
https://review.coreboot.org/19703
) Change subject: drivers/spi/spi_flash: Use boot_device_spi_flash to obtain spi_flash structure ...................................................................... drivers/spi/spi_flash: Use boot_device_spi_flash to obtain spi_flash structure Instead of storing spi flash device structure in spi flash driver, use boot_device_spi_flash callback to obtain pointer to boot device spi flash structure. BUG=b:38330715 Change-Id: Idd50b7644d1a4be8b62d38cc9239feae2215103c Signed-off-by: Furquan Shaikh <furquan(a)chromium.org> Reviewed-on:
https://review.coreboot.org/19703
Tested-by: build bot (Jenkins) <no-reply(a)coreboot.org> Reviewed-by: Aaron Durbin <adurbin(a)chromium.org> --- M src/drivers/spi/spi_flash.c 1 file changed, 2 insertions(+), 13 deletions(-) Approvals: Aaron Durbin: Looks good to me, approved build bot (Jenkins): Verified diff --git a/src/drivers/spi/spi_flash.c b/src/drivers/spi/spi_flash.c index 95362f2..e84df73 100644 --- a/src/drivers/spi/spi_flash.c +++ b/src/drivers/spi/spi_flash.c @@ -22,8 +22,6 @@ #include "spi_flash_internal.h" #include <timer.h> -static struct spi_flash *spi_flash_dev = NULL; - static void spi_flash_addr(u32 addr, u8 *cmd) { /* cmd[0] is actual command */ @@ -357,14 +355,6 @@ printk(BIOS_INFO, "SF: Detected %s with sector size 0x%x, total 0x%x\n", flash->name, flash->sector_size, flash->size); - /* - * Only set the global spi_flash_dev if this is the boot - * device's bus and it's previously unset while in ramstage. - */ - if (ENV_RAMSTAGE && IS_ENABLED(CONFIG_BOOT_DEVICE_SPI_FLASH) && - CONFIG_BOOT_DEVICE_SPI_FLASH_BUS == bus && !spi_flash_dev) - spi_flash_dev = flash; - return flash; } @@ -451,6 +441,7 @@ void lb_spi_flash(struct lb_header *header) { struct lb_spi_flash *flash; + const struct spi_flash *spi_flash_dev; if (!IS_ENABLED(CONFIG_BOOT_DEVICE_SPI_FLASH)) return; @@ -460,9 +451,7 @@ flash->tag = LB_TAG_SPI_FLASH; flash->size = sizeof(*flash); - /* Try to get the flash device if not loaded yet */ - if (!spi_flash_dev) - boot_device_init(); + spi_flash_dev = boot_device_spi_flash(); if (spi_flash_dev) { flash->flash_size = spi_flash_dev->size; -- To view, visit
https://review.coreboot.org/19703
To unsubscribe, visit
https://review.coreboot.org/settings
Gerrit-MessageType: merged Gerrit-Change-Id: Idd50b7644d1a4be8b62d38cc9239feae2215103c Gerrit-PatchSet: 9 Gerrit-Project: coreboot Gerrit-Branch: master Gerrit-Owner: Furquan Shaikh <furquan(a)google.com> Gerrit-Reviewer: Aaron Durbin <adurbin(a)chromium.org> Gerrit-Reviewer: Duncan Laurie <dlaurie(a)chromium.org> Gerrit-Reviewer: Furquan Shaikh <furquan(a)google.com> Gerrit-Reviewer: Paul Menzel <paulepanter(a)users.sourceforge.net> Gerrit-Reviewer: build bot (Jenkins) <no-reply(a)coreboot.org>
1
0
0
0
Change in coreboot[master]: drivers/spi/cbfs_spi: Provide implementation of boot_device_...
by Furquan Shaikh (Code Review)
19 May '17
19 May '17
Furquan Shaikh has submitted this change and it was merged. (
https://review.coreboot.org/19726
) Change subject: drivers/spi/cbfs_spi: Provide implementation of boot_device_spi_flash ...................................................................... drivers/spi/cbfs_spi: Provide implementation of boot_device_spi_flash This allows callers to retrieve handle to the boot device spi_flash structure. BUG=b:38330715 Change-Id: I1c07327115e0449cbd84d163218da76a6fa2cea0 Signed-off-by: Furquan Shaikh <furquan(a)chromium.org> Reviewed-on:
https://review.coreboot.org/19726
Tested-by: build bot (Jenkins) <no-reply(a)coreboot.org> Reviewed-by: Aaron Durbin <adurbin(a)chromium.org> Reviewed-by: Paul Menzel <paulepanter(a)users.sourceforge.net> --- M src/drivers/spi/cbfs_spi.c 1 file changed, 6 insertions(+), 0 deletions(-) Approvals: Aaron Durbin: Looks good to me, approved Paul Menzel: Looks good to me, but someone else must approve build bot (Jenkins): Verified diff --git a/src/drivers/spi/cbfs_spi.c b/src/drivers/spi/cbfs_spi.c index 7aeec57..ae2994c 100644 --- a/src/drivers/spi/cbfs_spi.c +++ b/src/drivers/spi/cbfs_spi.c @@ -134,3 +134,9 @@ { return boot_device_ro(); } + +const struct spi_flash *boot_device_spi_flash(void) +{ + boot_device_init(); + return spi_flash_info; +} -- To view, visit
https://review.coreboot.org/19726
To unsubscribe, visit
https://review.coreboot.org/settings
Gerrit-MessageType: merged Gerrit-Change-Id: I1c07327115e0449cbd84d163218da76a6fa2cea0 Gerrit-PatchSet: 7 Gerrit-Project: coreboot Gerrit-Branch: master Gerrit-Owner: Furquan Shaikh <furquan(a)google.com> Gerrit-Reviewer: Aaron Durbin <adurbin(a)chromium.org> Gerrit-Reviewer: Furquan Shaikh <furquan(a)google.com> Gerrit-Reviewer: Paul Menzel <paulepanter(a)users.sourceforge.net> Gerrit-Reviewer: build bot (Jenkins) <no-reply(a)coreboot.org>
1
0
0
0
← Newer
1
...
144
145
146
147
148
149
150
...
389
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
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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
Results per page:
10
25
50
100
200