[U-Boot] [PATCH v2 0/5] Fix SPI read and Enable required configs for Exynos5

This patch set intends to - 1. Fix SPI flash reading. 2. Enable saving environment at the end of flash. 3. Increase SPL size. 4. Enable USB booting for all Exynos5 Socs.
Changes since v1: - Added check for step in 1/5. - Added new config for SPI flash size in 2/5. - Made spl footprint 30 KB instead of 32 in 3/5. - Added "Acked-by" in 4/5. - Introduced new patch 5/5.
Akshay Saraswat (4): Exynos: SPI: Fix reading data from SPI flash Exynos5: Config: Place environment at the end of SPI flash Exynos5: Config: Increase SPL footprint for Exynos5420 Exynos5: Config: Enable USB boot mode for all Exynos5 SoCs
Michael Pratt (1): Exynos: Split 5250 and 5420 memory bank configuration
drivers/spi/exynos_spi.c | 5 +++++ include/configs/exynos5-dt.h | 15 ++++++++++----- include/configs/exynos5250-dt.h | 13 +++++++------ include/configs/exynos5420.h | 6 ++++++ 4 files changed, 28 insertions(+), 11 deletions(-)

SPI recieve and transfer code in exynos_spi driver has a logical bug. We read data in a variable which can hold an integer. Then we assign this integer 32 bit value to another variable which has data type uchar. Latter represents a unit of our recieve buffer. Everytime when we write a value to our recieve buffer we step ahead by 4 units when actually we wrote to one unit. This results in the loss of 3 bytes out of every 4 bytes recieved. This patch intends to fix this bug.
Signed-off-by: Akshay Saraswat akshay.s@samsung.com --- Changes since v1: - Added check for step.
drivers/spi/exynos_spi.c | 5 +++++ 1 file changed, 5 insertions(+)
diff --git a/drivers/spi/exynos_spi.c b/drivers/spi/exynos_spi.c index 4d5def2..68d1206 100644 --- a/drivers/spi/exynos_spi.c +++ b/drivers/spi/exynos_spi.c @@ -302,6 +302,11 @@ static int spi_rx_tx(struct exynos_spi_slave *spi_slave, int todo, } } else { if (rxp || stopping) { + if (step == 4) { + *(rxp + 3) = temp >> 24; + *(rxp + 2) = temp >> 16; + *(rxp + 1) = temp >> 8; + } *rxp = temp; rxp += step; }

HI Akshay,
On 3 June 2014 06:37, Akshay Saraswat akshay.s@samsung.com wrote:
SPI recieve and transfer code in exynos_spi driver has a logical bug. We read data in a variable which can hold an integer. Then we assign this integer 32 bit value to another variable which has data type uchar. Latter represents a unit of our recieve buffer. Everytime when we write a value to our recieve buffer we step ahead by 4 units when actually we wrote to one unit. This results in the loss of 3 bytes out of every 4 bytes recieved. This patch intends to fix this bug.
Signed-off-by: Akshay Saraswat akshay.s@samsung.com
Acked-by: Simon Glass sjg@chromium.org
(see comment below - could update this patch or do a follow-on to improve speed of both tx and rx)
Changes since v1: - Added check for step.
drivers/spi/exynos_spi.c | 5 +++++ 1 file changed, 5 insertions(+)
diff --git a/drivers/spi/exynos_spi.c b/drivers/spi/exynos_spi.c index 4d5def2..68d1206 100644 --- a/drivers/spi/exynos_spi.c +++ b/drivers/spi/exynos_spi.c @@ -302,6 +302,11 @@ static int spi_rx_tx(struct exynos_spi_slave *spi_slave, int todo, } } else { if (rxp || stopping) {
if (step == 4) {
*(rxp + 3) = temp >> 24;
*(rxp + 2) = temp >> 16;
*(rxp + 1) = temp >> 8;
}
BTW I just had another look at the code - sorry I didn't notice this before, but you know that rxp is word-aligned so you can just do *((uint32_t *)rxp) = temp;
*rxp = temp; rxp += step; }
-- 1.7.12.4

On 3 June 2014 08:23, Simon Glass sjg@chromium.org wrote:
HI Akshay,
On 3 June 2014 06:37, Akshay Saraswat akshay.s@samsung.com wrote:
SPI recieve and transfer code in exynos_spi driver has a logical bug. We read data in a variable which can hold an integer. Then we assign this integer 32 bit value to another variable which has data type uchar. Latter represents a unit of our recieve buffer. Everytime when we write a value to our recieve buffer we step ahead by 4 units when actually we wrote to one unit. This results in the loss of 3 bytes out of every 4 bytes recieved. This patch intends to fix this bug.
Signed-off-by: Akshay Saraswat akshay.s@samsung.com
Acked-by: Simon Glass sjg@chromium.org
Tested on pit using saveenv Tested-by: Simon Glass sjg@chromium.org

Currently environment resides at the location where BL2 ends. This may hold good in case there is an empty space at this position. But what if this place already has a binary or is expected to have one. To avoid such scenarios it is better to save environment at the end of the flash.
Signed-off-by: Akshay Saraswat akshay.s@samsung.com --- Changes since v1: - Added new config for SPI flash size.
include/configs/exynos5-dt.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/include/configs/exynos5-dt.h b/include/configs/exynos5-dt.h index 5a9b1b4..3bcec85 100644 --- a/include/configs/exynos5-dt.h +++ b/include/configs/exynos5-dt.h @@ -207,7 +207,10 @@
#define CONFIG_BL1_OFFSET (CONFIG_RES_BLOCK_SIZE + CONFIG_SEC_FW_SIZE) #define CONFIG_BL2_OFFSET (CONFIG_BL1_OFFSET + CONFIG_BL1_SIZE) -#define CONFIG_ENV_OFFSET (CONFIG_BL2_OFFSET + CONFIG_BL2_SIZE) + +/* Store environment at the end of a 4 MB SPI flash */ +#define FLASH_SIZE (0x4 << 20) +#define CONFIG_ENV_OFFSET (FLASH_SIZE - CONFIG_BL2_SIZE)
/* U-boot copy size from boot Media to DRAM.*/ #define BL2_START_OFFSET (CONFIG_BL2_OFFSET/512)

On 3 June 2014 06:37, Akshay Saraswat akshay.s@samsung.com wrote:
Currently environment resides at the location where BL2 ends. This may hold good in case there is an empty space at this position. But what if this place already has a binary or is expected to have one. To avoid such scenarios it is better to save environment at the end of the flash.
Signed-off-by: Akshay Saraswat akshay.s@samsung.com
Acked-by: Simon Glass sjg@chromium.org Tested on pit with saveenv Tested-by: Simon Glass sjg@chromium.org

Max footprint for SPL in both Exynos 5250 and 5420 is limited to 14 KB. For Exynos5250 we need to keep it 14 KB because BL1 supports only fixed size SPL downloading. But in case of Exynos5420 we need not restrict it to 14 KB. And also, the SPL size for Exynos5420 is expected to increase with the upcoming patches and the patches under review right now.
Signed-off-by: Akshay Saraswat akshay.s@samsung.com --- Changes since v1: - Changed 5420 SPL footprint from 32 to 30 KB.
include/configs/exynos5-dt.h | 2 -- include/configs/exynos5250-dt.h | 2 ++ include/configs/exynos5420.h | 2 ++ 3 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/include/configs/exynos5-dt.h b/include/configs/exynos5-dt.h index 3bcec85..e9787c7 100644 --- a/include/configs/exynos5-dt.h +++ b/include/configs/exynos5-dt.h @@ -144,8 +144,6 @@
/* specific .lds file */ #define CONFIG_SPL_LDSCRIPT "board/samsung/common/exynos-uboot-spl.lds" -#define CONFIG_SPL_MAX_FOOTPRINT (14 * 1024) -
/* Miscellaneous configurable options */ #define CONFIG_SYS_LONGHELP /* undef to save memory */ diff --git a/include/configs/exynos5250-dt.h b/include/configs/exynos5250-dt.h index b7ff472..9fff1af 100644 --- a/include/configs/exynos5250-dt.h +++ b/include/configs/exynos5250-dt.h @@ -20,6 +20,8 @@ #define MACH_TYPE_SMDK5250 3774 #define CONFIG_MACH_TYPE MACH_TYPE_SMDK5250
+#define CONFIG_SPL_MAX_FOOTPRINT (14 * 1024) + /* USB */ #define CONFIG_CMD_USB #define CONFIG_USB_XHCI diff --git a/include/configs/exynos5420.h b/include/configs/exynos5420.h index 3a28bbc..2ffe5ee 100644 --- a/include/configs/exynos5420.h +++ b/include/configs/exynos5420.h @@ -25,6 +25,8 @@ #endif #define CONFIG_IRAM_TOP 0x02074000
+#define CONFIG_SPL_MAX_FOOTPRINT (30 * 1024) + #define CONFIG_DEVICE_TREE_LIST "exynos5420-peach-pit exynos5420-smdk5420"
#define CONFIG_MAX_I2C_NUM 11

On 3 June 2014 06:37, Akshay Saraswat akshay.s@samsung.com wrote:
Max footprint for SPL in both Exynos 5250 and 5420 is limited to 14 KB. For Exynos5250 we need to keep it 14 KB because BL1 supports only fixed size SPL downloading. But in case of Exynos5420 we need not restrict it to 14 KB. And also, the SPL size for Exynos5420 is expected to increase with the upcoming patches and the patches under review right now.
Signed-off-by: Akshay Saraswat akshay.s@samsung.com
Acked-by: Simon Glass sjg@chromium.org Tested on pit Tested-by: Simon Glass sjg@chromium.org
Changes since v1: - Changed 5420 SPL footprint from 32 to 30 KB.

Right now USB booting is enabled for Exynos5250 only. Moving all the configs for USB boot mode from exynos5250-dt.h to exynos5-dt.h in order to enableUSB booting for all Exynos5 SoCs.
Signed-off-by: Akshay Saraswat akshay.s@samsung.com Acked-by: Simon Glass sjg@chromium.org --- Changes since v1: - Added "Acked-by".
include/configs/exynos5-dt.h | 6 ++++++ include/configs/exynos5250-dt.h | 6 ------ 2 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/include/configs/exynos5-dt.h b/include/configs/exynos5-dt.h index e9787c7..d3ef44c 100644 --- a/include/configs/exynos5-dt.h +++ b/include/configs/exynos5-dt.h @@ -291,4 +291,10 @@
#define CONFIG_CMD_GPIO
+/* USB boot mode */ +#define CONFIG_USB_BOOTING +#define EXYNOS_COPY_USB_FNPTR_ADDR 0x02020070 +#define EXYNOS_USB_SECONDARY_BOOT 0xfeed0002 +#define EXYNOS_IRAM_SECONDARY_BASE 0x02020018 + #endif /* __CONFIG_H */ diff --git a/include/configs/exynos5250-dt.h b/include/configs/exynos5250-dt.h index 9fff1af..10b8942 100644 --- a/include/configs/exynos5250-dt.h +++ b/include/configs/exynos5250-dt.h @@ -29,12 +29,6 @@ #define CONFIG_SYS_USB_XHCI_MAX_ROOT_PORTS 2 #define CONFIG_USB_STORAGE
-/* USB boot mode */ -#define CONFIG_USB_BOOTING -#define EXYNOS_COPY_USB_FNPTR_ADDR 0x02020070 -#define EXYNOS_USB_SECONDARY_BOOT 0xfeed0002 -#define EXYNOS_IRAM_SECONDARY_BASE 0x02020018 - #define CONFIG_SPL_TEXT_BASE 0x02023400
#define CONFIG_BOOTCOMMAND "mmc read 40007000 451 2000; bootm 40007000"

From: Michael Pratt mpratt@chromium.org
Since snow has a different memory configuration than peach, split the configuration between the 5250 and 5420. Exynos 5420 supports runtime memory configuration detection, and can make the determination between 4 and 7 banks at runtime.
Include the bank size with the number of banks for context to make the number of banks meaningful.
Signed-off-by: Michael Pratt mpratt@chromium.org Signed-off-by: Akshay Saraswat akshay.s@samsung.com --- Changes since v1: - New patch.
include/configs/exynos5-dt.h | 2 -- include/configs/exynos5250-dt.h | 5 +++++ include/configs/exynos5420.h | 4 ++++ 3 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/include/configs/exynos5-dt.h b/include/configs/exynos5-dt.h index d3ef44c..fd607ee 100644 --- a/include/configs/exynos5-dt.h +++ b/include/configs/exynos5-dt.h @@ -161,8 +161,6 @@
#define CONFIG_RD_LVL
-#define CONFIG_NR_DRAM_BANKS 8 -#define SDRAM_BANK_SIZE (256UL << 20UL) /* 256 MB */ #define PHYS_SDRAM_1 CONFIG_SYS_SDRAM_BASE #define PHYS_SDRAM_1_SIZE SDRAM_BANK_SIZE #define PHYS_SDRAM_2 (CONFIG_SYS_SDRAM_BASE + SDRAM_BANK_SIZE) diff --git a/include/configs/exynos5250-dt.h b/include/configs/exynos5250-dt.h index 10b8942..27aa455 100644 --- a/include/configs/exynos5250-dt.h +++ b/include/configs/exynos5250-dt.h @@ -65,4 +65,9 @@ #define LCD_YRES 1600 #define LCD_BPP LCD_COLOR16 #endif + +/* DRAM Memory Banks */ +#define CONFIG_NR_DRAM_BANKS 8 +#define SDRAM_BANK_SIZE (256UL << 20UL) /* 256 MB */ + #endif /* __CONFIG_5250_H */ diff --git a/include/configs/exynos5420.h b/include/configs/exynos5420.h index 2ffe5ee..d2a9556 100644 --- a/include/configs/exynos5420.h +++ b/include/configs/exynos5420.h @@ -45,4 +45,8 @@ */ #define CONFIG_SYS_INIT_SP_ADDR (CONFIG_IRAM_TOP - 0x800)
+/* DRAM Memory Banks */ +#define CONFIG_NR_DRAM_BANKS 7 +#define SDRAM_BANK_SIZE (512UL << 20UL) /* 512 MB */ + #endif /* __CONFIG_EXYNOS5420_H */

On 3 June 2014 06:37, Akshay Saraswat akshay.s@samsung.com wrote:
From: Michael Pratt mpratt@chromium.org
Since snow has a different memory configuration than peach, split the configuration between the 5250 and 5420. Exynos 5420 supports runtime memory configuration detection, and can make the determination between 4 and 7 banks at runtime.
Include the bank size with the number of banks for context to make the number of banks meaningful.
Signed-off-by: Michael Pratt mpratt@chromium.org Signed-off-by: Akshay Saraswat akshay.s@samsung.com
Acked-by: Simon Glass sjg@chromium.org Tested on 2GB pit Tested-by: Simon Glass sjg@chromium.org
participants (2)
-
Akshay Saraswat
-
Simon Glass