EXYNOS: SPL: Add a custom spi copy function
Subsystems (2)
PATCH 1/1 EXYNOS: SPL: Add a custom spi copy function
This CL implements a custom spi_copy funtion to copy u-boot from SF to RAM. This is faster then iROM spi_copy funtion as this runs spi at 50Mhz and also in WORD mode of operation.
Changed a printf in pimux.c to debug just to avoid the the compilation error in SPL.
Removed the enum for boot mode from spl_boot.c as it was already define in spl.h
--- arch/arm/cpu/armv7/exynos/pinmux.c | 2 +- arch/arm/include/asm/arch-exynos/spi.h | 2 + board/samsung/smdk5250/spl_boot.c | 126 +++++++++++++++++++++++++++++--- include/configs/exynos5250-dt.h | 3 + spl/Makefile | 4 + 5 files changed, 124 insertions(+), 13 deletions(-)
arch/arm/cpu/armv7/exynos/pinmux.c +1 -1
@@ -399,7 +399,7 @@ static int exynos4_pinmux_config(int peripheral, int flags)case PERIPH_ID_SDMMC1 :case PERIPH_ID_SDMMC3 :case PERIPH_ID_SDMMC4 : -printf ("SDMMC device %d not implemented\n" , peripheral); +debug ("SDMMC device %d not implemented\n" , peripheral);return -1 ;default :debug ("%s: invalid peripheral %d" , __func__, peripheral);
arch/arm/include/asm/arch-exynos/spi.h +2 -0
@@ -43,6 +43,8 @@ struct exynos_spi {#define SPI_TIMEOUT_MS 10 +#define SF_READ_DATA_CMD 0x3 +/* SPI_CHCFG */ #define SPI_CH_HS_EN (1 << 6)#define SPI_CH_RST (1 << 5)
board/samsung/smdk5250/spl_boot.c +114 -12
147 lines not on this page · raw message
include/configs/exynos5250-dt.h +3 -0
@@ -135,6 +135,8 @@/* MMC SPL */ #define CONFIG_SPL +#define CONFIG_SPL_GPIO_SUPPORT +#define COPY_BL2_FNPTR_ADDR 0x02020030/* specific .lds file */
@@ -288,6 +290,7 @@#define CONFIG_ENV_SPI_MODE SPI_MODE_0#define CONFIG_ENV_SECT_SIZE CONFIG_ENV_SIZE#define CONFIG_ENV_SPI_BUS 1 +#define CONFIG_ENV_SPI_BASE 0x12D30000#define CONFIG_ENV_SPI_MAX_HZ 50000000#endif
spl/Makefile +4 -0
@@ -92,6 +92,10 @@ LIBS-y += arch/$(ARCH)/cpu/tegra-common/libcputegra-common.o LIBS-y += $(CPUDIR)/tegra-common/libtegra-common.o endif +ifneq ($(CONFIG_EXYNOS4)$(CONFIG_EXYNOS5),) +LIBS-y += $(CPUDIR)/s5p-common/libs5p-common.o +endif + # Add GCC lib ifeq ("$(USE_PRIVATE_LIBGCC)", "yes") PLATFORM_LIBGCC = $(SPLTREE)/arch/$(ARCH)/lib/libgcc.o
Signature · 1 line
1.7.4.4
PATCH 1/1 EXYNOS: SPL: Add a custom spi copy function
Hi Rajeshwari,
Quoted 11 lines · Rajeshwari Shinde
This CL implements a custom
spi_copyfuntion to copy u-boot from SF to RAM. This is faster then iROMspi_copyfuntion as this runs spi at 50Mhz and also in WORD mode of operation.Changed a printf in
pimux.cto debug just to avoid the the compilation error in SPL.
Removed the enum for boot mode fromspl_boot.cas it was already define inspl.hSigned-off-by Alim Akhtar <[email protected]>Signed-off-by Tom Wai-Hong Tam <[email protected]>Signe-off-by Rajeshwari Shinde <[email protected]>
This now conflicts with the MMC series. I have an updated patch so will post it as a v2 to this one. That way the MMC patches can be applied first, then all your SPI patches.
Regards,
Simon
PATCH v2 1/1 EXYNOS: SPL: Add a custom spi copy function
In reply to Rajeshwari ShindeFrom: Rajeshwari Shinde <[email protected]>
This CL implements a custom spi_copy funtion to copy u-boot from SF to RAM. This is faster then iROM spi_copy funtion as this runs spi at 50Mhz and also in WORD mode of operation.
Changed a printf in pimux.c to debug just to avoid the the compilation error in SPL.
Removed the enum for boot mode from spl_boot.c as it was already define in spl.h
Rebased on top of MMC series:
---
Changes in v2:
- Rebase on top of MMC series
- Fix new checkpatch warnings
arch/arm/cpu/armv7/exynos/pinmux.c | 2 +- arch/arm/include/asm/arch-exynos/spi.h | 2 + arch/arm/include/asm/arch-exynos/spl.h | 1 + board/samsung/smdk5250/spl_boot.c | 132 +++++++++++++++++++++++++++++---- include/configs/exynos5250-dt.h | 3 + spl/Makefile | 4 + 6 files changed, 129 insertions(+), 15 deletions(-)
arch/arm/cpu/armv7/exynos/pinmux.c +1 -1
@@ -427,7 +427,7 @@ static int exynos4_pinmux_config(int peripheral, int flags)case PERIPH_ID_SDMMC1 :case PERIPH_ID_SDMMC3 :case PERIPH_ID_SDMMC4 : -printf ("SDMMC device %d not implemented\n" , peripheral); +debug ("SDMMC device %d not implemented\n" , peripheral);return -1 ;default :debug ("%s: invalid peripheral %d" , __func__, peripheral);
arch/arm/include/asm/arch-exynos/spi.h +2 -0
@@ -43,6 +43,8 @@ struct exynos_spi {#define SPI_TIMEOUT_MS 10 +#define SF_READ_DATA_CMD 0x3 +/* SPI_CHCFG */ #define SPI_CH_HS_EN (1 << 6)#define SPI_CH_RST (1 << 5)
arch/arm/include/asm/arch-exynos/spl.h +1 -0
@@ -32,6 +32,7 @@ enum boot_mode {* pin values are the same across Exynos4 and Exynos5. */ BOOT_MODE_MMC =4 , +BOOT_MODE_EMMC =8 ,/* EMMC4.4 */ BOOT_MODE_SERIAL =20 ,/* Boot based on Operating Mode pin settings */ BOOT_MODE_OM = 32,
board/samsung/smdk5250/spl_boot.c +118 -14
162 lines not on this page · raw message
include/configs/exynos5250-dt.h +3 -0
@@ -152,6 +152,8 @@/* MMC SPL */ #define CONFIG_SPL +#define CONFIG_SPL_GPIO_SUPPORT +#define COPY_BL2_FNPTR_ADDR 0x02020030/* specific .lds file */
@@ -305,6 +307,7 @@#define CONFIG_ENV_SPI_MODE SPI_MODE_0#define CONFIG_ENV_SECT_SIZE CONFIG_ENV_SIZE#define CONFIG_ENV_SPI_BUS 1 +#define CONFIG_ENV_SPI_BASE 0x12D30000#define CONFIG_ENV_SPI_MAX_HZ 50000000#endif
spl/Makefile +4 -0
@@ -94,6 +94,10 @@ LIBS-y += arch/$(ARCH)/cpu/tegra-common/libcputegra-common.o LIBS-y += $(CPUDIR)/tegra-common/libtegra-common.o endif +ifneq ($(CONFIG_EXYNOS4)$(CONFIG_EXYNOS5),) +LIBS-y += $(CPUDIR)/s5p-common/libs5p-common.o +endif + # Add GCC lib ifeq ("$(USE_PRIVATE_LIBGCC)", "yes") PLATFORM_LIBGCC = $(SPLTREE)/arch/$(ARCH)/lib/libgcc.o
Signature · 1 line
1.8.2.1
PATCH v2 1/1 EXYNOS: SPL: Add a custom spi copy function
Hi Rajeshwari,
Quoted 13 lines · Simon Glass
From: Rajeshwari Shinde <[email protected]>
This CL implements a custom
spi_copyfuntion to copy u-boot from SF to RAM. This is faster then iROMspi_copyfuntion as this runs spi at 50Mhz and also in WORD mode of operation.Changed a printf in
pimux.cto debug just to avoid the the compilation error in SPL.
Removed the enum for boot mode fromspl_boot.cas it was already define inspl.hSigned-off-by Alim Akhtar <[email protected]>Signed-off-by Tom Wai-Hong Tam <[email protected]>Signed-off-by Rajeshwari Shinde <[email protected]>
Quoted 7 lines
Rebased on top of MMC series:
Signed-off-by Simon Glass <[email protected]>---
Changes in v2:
- Rebase on top of MMC series
- Fix new checkpatch warnings
For all your SPI patches (listed below):
I have applied the MMC series and all of your SPI patches, and tested on snow. Everything works correctly I think.
Original SPI speed is very slow:
SMDK5250 # time sf read 40000000 0 400000
time: 1 minutes, 9.906 seconds, 69906 ticks
With your SPI patches and my 50MHz device tree patch I get:
SMDK5250 # time sf read 40000000 0 400000
time: 1.427 seconds, 1427 ticks
which is a dramatic improvement. If I turn on the caches (remove CONFIG_SYS_DCACHE_OFF from include/configs/exynos5-dt.h) then it goes at full sped:
SMDK5250 # time sf read 40000000 0 400000
time: 0.699 seconds, 699 ticks
Note that we are working on some further SPI code improvements locally and may send patches for that, but it will be after the merge window.
For references, here are the patches in my tree when I tested (listed in the reverse order they were applied).
660d9fd (HEAD, ws/snow, snow) exynos: dts: Use 50MHz SPI flash speed on snow 0295f39 EXYNOS: SPL: Add a custom spi copy function
e712583 EXYNOS: SPI: Support word transfers
aac5c2d EXYNOS: SPI: Minimise access to SPI FIFO level
99f2680 EXYNOS: SPI: Support a delay after deactivate
cbe66cb EXYNOS: Export timer_get_us() to get microsecond timer 893d152 EXYNOS: SPI: Support SPI_PREAMBLE mode
f4cce8b SPI: Add support for preamble bytes
f91072a exynos: Enable mmc for snow
aa1b39f COMMON: MMC: Command to support EMMC booting and to resize EMMC boot partition
a6358a3 SMDK5250: Enable EMMC booting
e37cc9f MMC: APIs to support resize of EMMC boot partition
919c7f6 SMDK5250: Initialise and Enable DWMMC, support FDT and non-FDT 2277040 EXYNOS5: DWMMC: Initialise the local variable to avoid unwanted results. 206af80 EXYNOS5: DWMMC: Added FDT support for DWMMC
0e8e41c DWMMC: Initialise dwmci and resolve EMMC read write issues 087075c EXYNOS5: FDT: Add DWMMC device node data
0f2db62 FDT: Add compatible string for DWMMC
6e4e37c EXYNOS5: I2C: Add FDT and non-FDT support for I2C
Quoted 8 lines
arch/arm/cpu/armv7/exynos/pinmux.c | 2 +- arch/arm/include/asm/arch-exynos/spi.h | 2 + arch/arm/include/asm/arch-exynos/spl.h | 1 + board/samsung/smdk5250/spl_boot.c | 132 +++++++++++++++++++++++++++++---- include/configs/exynos5250-dt.h | 3 + spl/Makefile | 4 + 6 files changed, 129 insertions(+), 15 deletions(-)
Regards,
Simon
PATCH v2 1/1 EXYNOS: SPL: Add a custom spi copy function
In reply to Simon GlassDear Simon Glass,
Quoted 3 lines · In message <[email protected]> you wrote:
From: Rajeshwari Shinde <[email protected]>
This CL implements a custom
spi_copyfuntion to copy u-boot from SF to
What is a "CL" ?
Quoted 1 line
Changed a printf in
pimux.cto debug just to avoid the the compilation
s/the the/the/ ??
Quoted 1 line
Removed the enum for boot mode from
spl_boot.cas it was already define inspl.h
s/define/defined/
Line length in commit messages should be not more than 72 characters.
Quoted 6 lines
+/**
+ * Copy uboot from spi flash to RAM
+ *
+ * @parmauboot_sizesize of u-boot to copy
+ * @paramuboot_addraddress of u-boot to copy
+ */
Incorrect multiline comment style.
Quoted 13 lines
board/samsung/smdk5250/spl_boot.c +13
-0+static void exynos_spi_copy (unsigned int uboot_size,unsigned int uboot_addr) +{ +int upto, todo; +int i; +struct exynos_spi *regs = (struct exynos_spi *)CONFIG_ENV_SPI_BASE ; + +set_spi_clk (PERIPH_ID_SPI1 ,50000000 );/* set spi clock to 50Mhz */ +/* set the spi1 GPIO */ +exynos_pinmux_config (PERIPH_ID_SPI1 ,PINMUX_FLAG_NONE ); + +/* set pktcnt and enable it */ +writel (4 |SPI_PACKET_CNT_EN , ®s->pkt_cnt); +/* set FB_CLK_SEL */
board/samsung/smdk5250/spl_boot.c static int config_branch_prediction(int set_cr_z) · line 140
Quoted 10 lines
board/samsung/smdk5250/spl_boot.c +10
-0+writel (SPI_FB_DELAY_180 , ®s->fb_clk); +/* set CH_WIDTH and BUS_WIDTH as word */ +setbits_le32 (®s->mode_cfg,SPI_MODE_CH_WIDTH_WORD | +SPI_MODE_BUS_WIDTH_WORD ); +clrbits_le32 (®s->ch_cfg,SPI_CH_CPOL_L );/* CPOL: active high */ + +/* clear rx and tx channel if set priveously */ +clrbits_le32 (®s->ch_cfg,SPI_RX_CH_ON |SPI_TX_CH_ON ); + +typedef u32 (*spi_copy_func_t )(u32 offset,u32 nblock,u32 dst);
We do not allow typedefs or variable declarations etc. right in the middle of the code.
I'm surprised that checkpatch does not complain here about not to add new typedefs ??
board/samsung/smdk5250/spl_boot.c static int config_branch_prediction(int set_cr_z) · line 158
Quoted 3 lines
board/samsung/smdk5250/spl_boot.c +3
-0+/* waiting for TX done */ +while (!(readl (®s->spi_sts) &SPI_ST_TX_DONE )) + ;
Potentially infinite loop. This (and similar code) should always have a timeout and appropriate error handling.
board/samsung/smdk5250/spl_boot.c void copy_uboot_to_ram(void) · line 211
Quoted 1 line
board/samsung/smdk5250/spl_boot.c +1
-0+/* let us our own function to copy u-boot from SF */
Please fix the wording of this comment.
spl/Makefile LIBS-y += arch/$(ARCH)/cpu/tegra-common/libcputegra-common.o · line 99
Quoted 11 lines
spl/Makefile +3
-0@@ -94,6 +94,10 @@ LIBS-y += arch/$(ARCH)/cpu/tegra-common/libcputegra-common.o LIBS-y += $(CPUDIR)/tegra-common/libtegra-common.o endif +ifneq ($(CONFIG_EXYNOS4)$(CONFIG_EXYNOS5),) +LIBS-y += $(CPUDIR)/s5p-common/libs5p-common.o +endif
This should be done without the "ifneq".
Best regards,
Wolfgang Denk
Signature · 4 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de Love all, trust a few. - William Shakespeare
PATCH v2 1/1 EXYNOS: SPL: Add a custom spi copy function
Hi Wolfgang Denk,
Thank you for review comments.
Quoted 11 lines · Wolfgang Denk
Dear Simon Glass,
Quoted 3 lines · In message <[email protected]> you wrote:
From: Rajeshwari Shinde <[email protected]>
This CL implements a custom
spi_copyfuntion to copy u-boot from SF toWhat is a "CL" ?
Quoted 1 line
Changed a printf in
pimux.cto debug just to avoid the the compilation
Quoted 7 lines
s/the the/the/ ??
Quoted 1 line
Removed the enum for boot mode from
spl_boot.cas it was already define inspl.hs/define/defined/
Line length in commit messages should be not more than 72 characters.
Will correct these issues and resubmit the patch set soon.
Quoted 10 lines
Quoted 8 lines
+/**
+ * Copy uboot from spi flash to RAM
+ *
+ * @parmauboot_sizesize of u-boot to copy
+ * @paramuboot_addraddress of u-boot to copy
+ */Incorrect multiline comment style.
Will correct these
Quoted 28 lines
Quoted 14 lines
board/samsung/smdk5250/spl_boot.c +13
-0+static void exynos_spi_copy (unsigned int uboot_size,unsigned int uboot_addr) +{ +int upto, todo; +int i; +struct exynos_spi *regs = (struct exynos_spi *)CONFIG_ENV_SPI_BASE ; + +set_spi_clk (PERIPH_ID_SPI1 ,50000000 );/* set spi clock to 50Mhz */ +/* set the spi1 GPIO */ +exynos_pinmux_config (PERIPH_ID_SPI1 ,PINMUX_FLAG_NONE ); + +/* set pktcnt and enable it */ +writel (4 |SPI_PACKET_CNT_EN , ®s->pkt_cnt); +/* set FB_CLK_SEL */ board/samsung/smdk5250/spl_boot.c static int config_branch_prediction(int set_cr_z) · line 140
Quoted 10 lines
board/samsung/smdk5250/spl_boot.c +10
-0+writel (SPI_FB_DELAY_180 , ®s->fb_clk); +/* set CH_WIDTH and BUS_WIDTH as word */ +setbits_le32 (®s->mode_cfg,SPI_MODE_CH_WIDTH_WORD | +SPI_MODE_BUS_WIDTH_WORD ); +clrbits_le32 (®s->ch_cfg,SPI_CH_CPOL_L );/* CPOL: active high */ + +/* clear rx and tx channel if set priveously */ +clrbits_le32 (®s->ch_cfg,SPI_RX_CH_ON |SPI_TX_CH_ON ); + +typedef u32 (*spi_copy_func_t )(u32 offset,u32 nblock,u32 dst);We do not allow typedefs or variable declarations etc. right in the middle of the code.
Quoted 2 lines
I'm surprised that checkpatch does not complain here about not to add new typedefs ??
Basically typedef u32 (*spi_copy_func_t)(u32 offset, u32 nblock, u32 dst); was removed in my original patch.
Will check and remove this from the version of patch set I submit.
Quoted 7 lines
board/samsung/smdk5250/spl_boot.c static int config_branch_prediction(int set_cr_z) · line 158
Quoted 4 lines
board/samsung/smdk5250/spl_boot.c +3
-0+/* waiting for TX done */ +while (!(readl (®s->spi_sts) &SPI_ST_TX_DONE )) + ;Potentially infinite loop. This (and similar code) should always have a timeout and appropriate error handling.
Will add a timeout check here
Quoted 4 lines
Quoted 2 lines
+ /* let us our own function to copy u-boot from SF */
Please fix the wording of this comment.
Will correct this.
Quoted 9 lines
Quoted 9 lines
spl/Makefile +0
-0@@ -94,6 +94,10 @@ LIBS-y += arch/$(ARCH)/cpu/tegra-common/libcputegra-common.o LIBS-y += $(CPUDIR)/tegra-common/libtegra-common.o endif
Quoted 5 lines
spl/Makefile LIBS-y += arch/$(ARCH)/cpu/tegra-common/libcputegra-common.o · line 99
Quoted 3 lines
spl/Makefile +3
-0+ifneq ($(CONFIG_EXYNOS4)$(CONFIG_EXYNOS5),) +LIBS-y += $(CPUDIR)/s5p-common/libs5p-common.o +endifThis should be done without the "ifneq".
This is specific to samsung and currently used only by EXYNOS hence it was added with a ifneq
Quoted 15 lines
Best regards,
Wolfgang Denk
--
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Love all, trust a few. - William Shakespeare
_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot
Signature · 2 lines
Regards, Rajeshwari Shinde