Skip to contentSkip to conversation

eSPI: add the eSPI register support

PATCH New Mingkai Hu 6 participants 36 messages Mar 16, 2009 – Aug 27, 2009

Subsystems (4)
lore
Share & tools
lore

Mingkai Hu

author
#0 lore raw

PATCH 1/7 eSPI: add the eSPI register support

---
 include/asm-ppc/immap_85xx.h |   17 +++++++++++++++++
 1 files changed, 17 insertions(+), 0 deletions(-)
include/asm-ppc/immap_85xx.h +17 -0
index 094fb9c..f3ab750 100644
@@ -258,6 +258,21 @@ typedef struct ccsr_lbc {
 } ccsr_lbc_t;
 
 /*
+ * eSPI Registers(0x7000-0x8000)
+ */
+typedef struct ccsr_espi {
+	uint	mode;		/* 0x00 - eSPI mode register  */
+	uint	event;		/* 0x04 - eSPI event register */
+	uint	mask;		/* 0x08 - eSPI mask register  */
+	uint	com;		/* 0x0c - eSPI command register */
+	uint	tx;		/* 0x10 - eSPI transmit FIFO access register */
+	uint	rx;		/* 0x14 - eSPI receive FIFO access register */
+	char	res1[8];	/* reserved */
+	uint	csmode[4];	/* 0x20 - 0x2c: sSPI CS0/1/2/3 mode register */
+	char	res2[4048];	/* fill up to 0x1000 */
+} ccsr_espi_t;
+
+/*
  * PCI Registers(0x8000-0x9000)
  */
 typedef struct ccsr_pcix {
@@ -1682,6 +1697,8 @@ typedef struct ccsr_gur {
 #define CONFIG_SYS_MPC85xx_DDR2_ADDR	(CONFIG_SYS_IMMR + CONFIG_SYS_MPC85xx_DDR2_OFFSET)
 #define CONFIG_SYS_MPC85xx_LBC_OFFSET	(0x5000)
 #define CONFIG_SYS_MPC85xx_LBC_ADDR	(CONFIG_SYS_IMMR + CONFIG_SYS_MPC85xx_LBC_OFFSET)
+#define CONFIG_SYS_MPC85xx_ESPI_OFFSET	(0x7000)
+#define CONFIG_SYS_MPC85xx_ESPI_ADDR	(CONFIG_SYS_IMMR + CONFIG_SYS_MPC85xx_ESPI_OFFSET)
 #define CONFIG_SYS_MPC85xx_PCIX_OFFSET	(0x8000)
 #define CONFIG_SYS_MPC85xx_PCIX_ADDR	(CONFIG_SYS_IMMR + CONFIG_SYS_MPC85xx_PCIX_OFFSET)
 #define CONFIG_SYS_MPC85xx_PCIX2_OFFSET	(0x9000)
Signature · 1 line
1.5.4
author
#1 lore raw

PATCH 2/7 mtd: SPI Flash: Support the Spansion Flash

Add MTD SPI Flash support for S25FL008A, S25FL016A, S25FL032A, S25FL064A, S25FL128P.

---
 drivers/mtd/spi/Makefile   |    1 +
 drivers/mtd/spi/spansion.c |  356 ++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 357 insertions(+), 0 deletions(-)
 create mode 100644 drivers/mtd/spi/spansion.c
drivers/mtd/spi/Makefile +1 -0
index 3d4f892..3f46de2 100644
@@ -28,6 +28,7 @@ LIB	:= $(obj)libspi_flash.a
 COBJS-$(CONFIG_SPI_FLASH)	+= spi_flash.o
 COBJS-$(CONFIG_SPI_FLASH_ATMEL)	+= atmel.o
 COBJS-$(CONFIG_SPI_FLASH_STMICRO)	+= stmicro.o
+COBJS-$(CONFIG_SPI_FLASH_SPANSION)     += spansion.o
 
 COBJS	:= $(COBJS-y)
 SRCS	:= $(COBJS:.o=.c)
drivers/mtd/spi/spansion.c new file +356 -0

356 lines not on this page · raw message

Signature · 1 line
1.5.4
author
#2 lore raw

PATCH 3/7 eSPI: add eSPI controller support

Add eSPI controller support under the SPI framework.

---
 drivers/mtd/spi/spi_flash.c |   94 +++++++++++++++++-
 drivers/spi/Makefile        |    1 +
 drivers/spi/fsl_espi.c      |  232 +++++++++++++++++++++++++++++++++++++++++++
 include/spi.h               |   30 ++++++
 4 files changed, 354 insertions(+), 3 deletions(-)
 create mode 100644 drivers/spi/fsl_espi.c
drivers/mtd/spi/spi_flash.c +91 -3
index d1d81af..fa97896 100644
@@ -1,6 +1,8 @@
 /*
  * SPI flash interface
+ * Add support for Freescale eSPI controller
  *
+ * Copyright (C) 2009 Freescale Semiconductor, Inc.
  * Copyright (C) 2008 Atmel Corporation
  */
 #define DEBUG
@@ -16,6 +18,7 @@ int spi_flash_cmd(struct spi_slave *spi, u8 cmd, void *response, size_t len)
 	unsigned long flags = SPI_XFER_BEGIN;
 	int ret;
 
+#ifndef CONFIG_FSL_ESPI
 	if (len == 0)
 		flags |= SPI_XFER_END;
 
@@ -31,6 +34,35 @@ int spi_flash_cmd(struct spi_slave *spi, u8 cmd, void *response, size_t len)
 			debug("SF: Failed to read response (%zu bytes): %d\n",
 					len, ret);
 	}
+#else
+	struct espi_transfer transfer[1];
+	unsigned char *buffer;
+
+	buffer = (unsigned char *)malloc(len + 2);
+	if (!buffer) {
+		debug("SF: Failed to malloc memory.\n");
+		return 1;
+	}
+	memcpy(buffer, &cmd, 1);
+
+	transfer[0].cmd_len = 1;
+	transfer[0].data_len = len;
+	transfer[0].tx_buf = buffer;
+	transfer[0].rx_buf = buffer + 1;
+	transfer[0].flags = flags | SPI_XFER_END;
+
+	spi->transfer = &transfer[0];
+	ret = espi_xfer(spi);
+	if (ret) {
+		debug("SF: Failed to send command %02x: %d\n", cmd, ret);
+		return ret;
+	}
+
+	if (len)
+		memcpy(response, transfer[0].rx_buf + 1, len);
+
+	free(buffer);
+#endif
 
 	return ret;
 }
@@ -41,6 +73,7 @@ int spi_flash_cmd_read(struct spi_slave *spi, const u8 *cmd,
 	unsigned long flags = SPI_XFER_BEGIN;
 	int ret;
 
+#ifndef CONFIG_FSL_ESPI
 	if (data_len == 0)
 		flags |= SPI_XFER_END;
 
@@ -54,6 +87,33 @@ int spi_flash_cmd_read(struct spi_slave *spi, const u8 *cmd,
 			debug("SF: Failed to read %zu bytes of data: %d\n",
 					data_len, ret);
 	}
+#else
+	struct espi_transfer transfer[1];
+	unsigned char *buffer;
+
+	buffer = (unsigned char *)malloc(2 * cmd_len + data_len);
+	if (!buffer) {
+		debug("SF: Failed to malloc memory.\n");
+		return 1;
+	}
+	memcpy(buffer, cmd, cmd_len);
+
+	transfer[0].cmd_len = cmd_len;
+	transfer[0].data_len = data_len;
+	transfer[0].tx_buf = buffer;
+	transfer[0].rx_buf = buffer + cmd_len;
+	transfer[0].flags = flags | SPI_XFER_END;
+
+	spi->transfer = &transfer[0];
+	ret = espi_xfer(spi);
+	if (ret) {
+		debug("SF: Failed to read %zu bytes of data: %d\n",
+				data_len, ret);
+	}
+
+	memcpy(data, transfer[0].rx_buf + cmd_len, data_len);
+	free(buffer);
+#endif
 
 	return ret;
 }
@@ -64,6 +124,7 @@ int spi_flash_cmd_write(struct spi_slave *spi, const u8 *cmd, size_t cmd_len,
 	unsigned long flags = SPI_XFER_BEGIN;
 	int ret;
 
+#ifndef CONFIG_FSL_ESPI
 	if (data_len == 0)
 		flags |= SPI_XFER_END;
 
@@ -77,6 +138,33 @@ int spi_flash_cmd_write(struct spi_slave *spi, const u8 *cmd, size_t cmd_len,
 			debug("SF: Failed to read %zu bytes of data: %d\n",
 					data_len, ret);
 	}
+#else
+	struct espi_transfer transfer[1];
+	unsigned char *buffer;
+
+	buffer = (unsigned char *)malloc(cmd_len + data_len);
+	if (!buffer) {
+		debug("SF: Failed to malloc memory.\n");
+		return 1;
+	}
+	memcpy(buffer, cmd, cmd_len);
+	memcpy(buffer + cmd_len, data, data_len);
+
+	transfer[0].cmd_len = cmd_len;
+	transfer[0].data_len = data_len;
+	transfer[0].tx_buf = buffer;
+	transfer[0].rx_buf = NULL;
+	transfer[0].flags = flags | SPI_XFER_END;
+
+	spi->transfer = &transfer[0];
+	ret = espi_xfer(spi);
+	if (ret) {
+		debug("SF: Failed to read %zu bytes of data: %d\n",
+				data_len, ret);
+	}
+
+	free(buffer);
+#endif
 
 	return ret;
 }
@@ -101,7 +189,7 @@ struct spi_flash *spi_flash_probe(unsigned int bus, unsigned int cs,
 	struct spi_slave *spi;
 	struct spi_flash *flash;
 	int ret;
-	u8 idcode[3];
+	u8 idcode[5];
 
 	spi = spi_setup_slave(bus, cs, max_hz, spi_mode);
 	if (!spi) {
@@ -120,8 +208,8 @@ struct spi_flash *spi_flash_probe(unsigned int bus, unsigned int cs,
 	if (ret)
 		goto err_read_id;
 
-	debug("SF: Got idcode %02x %02x %02x\n", idcode[0],
-			idcode[1], idcode[2]);
+	debug("SF: Got idcode %02x %02x %02x %02x %02x\n", idcode[0],
+			idcode[1], idcode[2], idcode[3], idcode[4]);
 
 	switch (idcode[0]) {
 #ifdef CONFIG_SPI_FLASH_SPANSION
drivers/spi/Makefile +1 -0
index 6e2c121..406881a 100644
@@ -30,6 +30,7 @@ COBJS-$(CONFIG_BFIN_SPI) += bfin_spi.o
 COBJS-$(CONFIG_MPC8XXX_SPI) += mpc8xxx_spi.o
 COBJS-$(CONFIG_MXC_SPI) += mxc_spi.o
 COBJS-$(CONFIG_SOFT_SPI) += soft_spi.o
+COBJS-$(CONFIG_FSL_ESPI) += fsl_espi.o
 
 COBJS	:= $(COBJS-y)
 SRCS	:= $(COBJS:.o=.c)
drivers/spi/fsl_espi.c new file +232 -0

232 lines not on this page · raw message

include/spi.h +30 -0
index 320e50e..948a565 100644
@@ -50,16 +50,38 @@
 #define SPI_XFER_END	0x02			/* Deassert CS after transfer */
 
 /*-----------------------------------------------------------------------
+ * Representation of a eSPI transaction, which is always embeded in
+ * structure spi_slave.
+ *
+ *   cmd_len:	Length of the command.
+ *   data_len:	Length of the transmit/receive data.
+ *   tx_buf:	Buffer to store the transmit command and data.
+ *   rx_buf:	Buffer to store the receive data.
+ *   flags:	Flags to indicate the begin/end of the transfer.
+ */
+struct espi_transfer {
+	unsigned int	cmd_len;
+	unsigned int	data_len;
+	const void	*tx_buf;
+	void		*rx_buf;
+
+	unsigned long	flags;
+};
+
+/*-----------------------------------------------------------------------
  * Representation of a SPI slave, i.e. what we're communicating with.
  *
  * Drivers are expected to extend this with controller-specific data.
  *
  *   bus:	ID of the bus that the slave is attached to.
  *   cs:	ID of the chip select connected to the slave.
+ *   transfer:	Represent an eSPI transaction.
  */
 struct spi_slave {
 	unsigned int	bus;
 	unsigned int	cs;
+
+	struct espi_transfer *transfer;
 };
 
 /*-----------------------------------------------------------------------
@@ -148,6 +170,14 @@ int  spi_xfer(struct spi_slave *slave, unsigned int bitlen, const void *dout,
 		void *din, unsigned long flags);
 
 /*-----------------------------------------------------------------------
+ * eSPI transfer
+ *
+ *   Returns: 0 on success, not 0 on failure
+ */
+int  espi_xfer(struct spi_slave *slave);
+
+
+/*-----------------------------------------------------------------------
  * Determine if a SPI chipselect is valid.
  * This function is provided by the board if the low-level SPI driver
  * needs it to determine if a given chipselect is actually valid.
Signature · 1 line
1.5.4
author
#3 lore raw

PATCH 4/7 eSPI: make the chip selsec enable

On the MPC8536 processor, the eSPI chip selects and the eSDHC data interface have four pin-muxed pins shared between them, so if the eSDHC data interface is expanded to 8-bits, no eSPI chip selects are routed.

---
 board/freescale/mpc8536ds/mpc8536ds.c |    3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)
board/freescale/mpc8536ds/mpc8536ds.c +1 -2
index 31c1e15..1f028c2 100644
@@ -50,8 +50,7 @@ int board_early_init_f (void)
 	volatile ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR);
 
 	setbits_be32(&gur->pmuxcr,
-			(MPC85xx_PMUXCR_SD_DATA |
-			 MPC85xx_PMUXCR_SDHC_CD |
+			(MPC85xx_PMUXCR_SDHC_CD |
 			 MPC85xx_PMUXCR_SDHC_WP));
 
 #endif
Signature · 1 line
1.5.4
author
#4 lore raw

PATCH 5/7 Make a special uboot used for booting from SDcard or SPI flash

This patch is used to generate a special version u-boot, together with the data structure on the SDcard/SPI flash, can be used to booting from SDcard/SPI flash on 8536DS board.

The boot ROM in CPU and the data structure on SD card will initialize the DDR, set a large tlb0 for DDR and CCSR, set law0 for DDR. The special version uboot avoid initializing the DDR. Try to reseve the law0 for DDR by adding a CONFIG_SYS_RESERVED_LAW0 macro for the "dynamic law allocation" code. But keep the original tlb initialize code for DDR, disabled the large tlb0 which was set in the boot ROM.

This patch is intend for those who are interested in the function of booting from SD card on 8536DS board and not for opensource. An utility is needed to write the data structure and the special version u-boot onto the SD card which has filesystem on it or onto the SPI flash.

---
 Makefile                                    |   12 +++
 board/freescale/mpc8536ds/config.mk         |    2 +
 board/freescale/mpc8536ds/mpc8536ds.c       |    4 +
 board/freescale/mpc8536ds/tlb.c             |    3 +
 board/freescale/mpc8536ds/u-boot-sdboot.lds |  139 +++++++++++++++++++++++++++
 config.mk                                   |    4 +-
 cpu/mpc85xx/cpu_init.c                      |   70 +++++++++++++-
 cpu/mpc85xx/start.S                         |   17 +++-
 drivers/misc/fsl_law.c                      |    4 +
 include/configs/MPC8536DS.h                 |   12 ++-
 10 files changed, 262 insertions(+), 5 deletions(-)
 create mode 100644 board/freescale/mpc8536ds/u-boot-sdboot.lds
Makefile +12 -0
index e8b4c13..c18a2e0 100644
@@ -2360,6 +2360,18 @@ ATUM8548_config:	unconfig
 MPC8536DS_config:       unconfig
 	@$(MKCONFIG) $(@:_config=) ppc mpc85xx mpc8536ds freescale
 
+MPC8536DS_SPIFLASH_config \
+MPC8536DS_SDCARD_config:	unconfig
+	@echo "" >$(obj)include/config.h;
+	@if [ "$(findstring _SPIFLASH_,$@)" ] ; then \
+		echo "#define CONFIG_SPIFLASH_U_BOOT" >> $(obj)include/config.h ; \
+	fi ;
+	@echo "#define CONFIG_SDCARD_U_BOOT" >> $(obj)include/config.h ;
+	@$(MKCONFIG) -a MPC8536DS ppc mpc85xx mpc8536ds freescale ; \
+		echo "TEXT_BASE = 0x11001000" > $(obj)board/freescale/mpc8536ds/config.tmp ; \
+		echo "#define CONFIG_SDCARD_U_BOOT" >> $(obj)include/config.h ;  \
+		echo "CONFIG_SDCARD_U_BOOT = y" >> $(obj)include/config.mk ;
+
 MPC8540ADS_config:	unconfig
 	@$(MKCONFIG) $(@:_config=) ppc mpc85xx mpc8540ads freescale
 
board/freescale/mpc8536ds/config.mk +2 -0
index 9775ff4..b1c6251 100644
@@ -23,6 +23,8 @@
 #
 # mpc8536ds board
 #
+sinclude $(OBJTREE)/board/$(BOARDDIR)/config.tmp
+
 ifndef TEXT_BASE
 TEXT_BASE = 0xeff80000
 endif
board/freescale/mpc8536ds/mpc8536ds.c +4 -0
index 1f028c2..f4ce72f 100644
@@ -73,6 +73,10 @@ initdram(int board_type)
 
 	puts("Initializing....");
 
+#ifdef CONFIG_SDCARD_U_BOOT
+	return CONFIG_SYS_SDRAM_SIZE * 1024 * 1024;
+#endif
+
 #ifdef CONFIG_SPD_EEPROM
 	dram_size = fsl_ddr_sdram();
 #else
board/freescale/mpc8536ds/tlb.c +3 -0
index 35a13d4..cb570ef 100644
@@ -27,6 +27,8 @@
 #include <asm/mmu.h>
 
 struct fsl_e_tlb_entry tlb_table[] = {
+
+#if !defined(CONFIG_SDCARD_U_BOOT)
 	/* TLB 0 - for temp stack in cache */
 	SET_TLB_ENTRY(0, CONFIG_SYS_INIT_RAM_ADDR, CONFIG_SYS_INIT_RAM_ADDR,
 		      MAS3_SX|MAS3_SW|MAS3_SR, 0,
@@ -40,6 +42,7 @@ struct fsl_e_tlb_entry tlb_table[] = {
 	SET_TLB_ENTRY(0, CONFIG_SYS_INIT_RAM_ADDR + 12 * 1024 , CONFIG_SYS_INIT_RAM_ADDR + 12 * 1024,
 		      MAS3_SX|MAS3_SW|MAS3_SR, 0,
 		      0, 0, BOOKE_PAGESZ_4K, 0),
+#endif
 
 	SET_TLB_ENTRY(0, PIXIS_BASE, PIXIS_BASE_PHYS,
 		      MAS3_SX|MAS3_SW|MAS3_SR, MAS2_I|MAS2_G,
board/freescale/mpc8536ds/u-boot-sdboot.lds new file +139 -0

139 lines not on this page · raw message

config.mk +2 -2
index b1254e9..3300b75 100644
@@ -112,8 +112,8 @@ DBGFLAGS= -g # -DDEBUG
 OPTFLAGS= -Os #-fomit-frame-pointer
 ifndef LDSCRIPT
 #LDSCRIPT := $(TOPDIR)/board/$(BOARDDIR)/u-boot.lds.debug
-ifeq ($(CONFIG_NAND_U_BOOT),y)
-LDSCRIPT := $(TOPDIR)/board/$(BOARDDIR)/u-boot-nand.lds
+ifeq ($(CONFIG_SDCARD_U_BOOT),y)
+LDSCRIPT := $(TOPDIR)/board/$(BOARDDIR)/u-boot-sdboot.lds
 else
 LDSCRIPT := $(TOPDIR)/board/$(BOARDDIR)/u-boot.lds
 endif
cpu/mpc85xx/cpu_init.c +69 -1

80 lines not on this page · raw message

cpu/mpc85xx/start.S +16 -1
index 80f9677..4601c0a 100644
@@ -184,6 +184,7 @@ _start_e500:
 	mtspr	DBCR0,r0
 #endif
 
+#if !defined(CONFIG_SDCARD_U_BOOT)
 	/* create a temp mapping in AS=1 to the 4M boot window */
 	lis     r6,FSL_BOOKE_MAS0(1, 15, 0)@h
 	ori     r6,r6,FSL_BOOKE_MAS0(1, 15, 0)@l
@@ -254,9 +255,10 @@ switch_as:
 	dcbtls	0,r0,r3
 	addi	r3,r3,CONFIG_SYS_CACHELINE_SIZE
 	bdnz	1b
+#endif
 
 	/* Jump out the last 4K page and continue to 'normal' start */
-#ifdef CONFIG_SYS_RAMBOOT
+#if defined(CONFIG_SYS_RAMBOOT) || defined(CONFIG_SDCARD_U_BOOT)
 	b	_start_cont
 #else
 	/* Calculate absolute address in FLASH and jump there		*/
@@ -296,7 +298,20 @@ _start_cont:
 	stw	r0,+12(r1)		/* Save return addr (underflow vect) */
 
 	GET_GOT
+#if !defined(CONFIG_SDCARD_U_BOOT)
 	bl	cpu_init_early_f
+#else
+	bl	cpu_init_early_f_sd
+
+	/*Then switch to space 1*/
+	lis     r3,(MSR_CE|MSR_ME|MSR_DE|MSR_IS|MSR_DS)@h
+	ori     r3,r3,(MSR_CE|MSR_ME|MSR_DE|MSR_IS|MSR_DS)@l
+	mtmsr	r3
+	isync
+	msync
+
+	bl	cpu_init_early_f_sd_continue
+#endif
 
 	/* switch back to AS = 0 */
 	lis	r3,(MSR_CE|MSR_ME|MSR_DE)@h
drivers/misc/fsl_law.c +4 -0
index 58340c1..1d709dd 100644
@@ -168,6 +168,10 @@ void init_laws(void)
 
 	gd->used_laws = ~((1 << FSL_HW_NUM_LAWS) - 1);
 
+#ifdef CONFIG_SDCARD_U_BOOT
+	gd->used_laws |= (1 << CONFIG_SYS_RESERVED_LAW0);
+#endif
+
 	for (i = 0; i < num_law_entries; i++) {
 		if (law_table[i].index == -1)
 			set_next_law(law_table[i].addr, law_table[i].size,
include/configs/MPC8536DS.h +11 -1
index bbb448d..b19f028 100644
@@ -116,7 +116,7 @@ extern unsigned long get_board_ddr_clk(unsigned long dummy);
 #define CONFIG_SYS_SPD_BUS_NUM		1
 
 /* These are used when DDR doesn't use SPD. */
-#define CONFIG_SYS_SDRAM_SIZE		256		/* DDR is 256MB */
+#define CONFIG_SYS_SDRAM_SIZE		512		/* DDR is 512MB */
 #define CONFIG_SYS_DDR_CS0_BNDS	0x0000001F
 #define CONFIG_SYS_DDR_CS0_CONFIG	0x80010102	/* Enable, no interleaving */
 #define CONFIG_SYS_DDR_TIMING_3	0x00000000
@@ -235,9 +235,15 @@ extern unsigned long get_board_ddr_clk(unsigned long dummy);
 #define PIXIS_VCLKL		0x1A	/* VELA VCLKL register */
 #define CONFIG_SYS_PIXIS_VBOOT_MASK	0xc0
 
+#if !defined(CONFIG_SDCARD_U_BOOT)
 #define CONFIG_SYS_INIT_RAM_LOCK	1
 #define CONFIG_SYS_INIT_RAM_ADDR	0xffd00000	/* Initial L1 address */
 #define CONFIG_SYS_INIT_RAM_END	0x00004000	/* End of used area in RAM */
+#else
+#undef  CONFIG_SYS_INIT_RAM_LOCK
+#define CONFIG_SYS_INIT_RAM_ADDR	0x07d00000	/* unused memory region */
+#define CONFIG_SYS_INIT_RAM_END	0x4000          /* we have SDRAM initialized */
+#endif
 
 #define CONFIG_SYS_GBL_DATA_SIZE	128	/* num bytes initial data */
 #define CONFIG_SYS_GBL_DATA_OFFSET	(CONFIG_SYS_INIT_RAM_END - CONFIG_SYS_GBL_DATA_SIZE)
@@ -246,6 +252,10 @@ extern unsigned long get_board_ddr_clk(unsigned long dummy);
 #define CONFIG_SYS_MONITOR_LEN		(256 * 1024) /* Reserve 256 kB for Mon */
 #define CONFIG_SYS_MALLOC_LEN		(1024 * 1024)	/* Reserved for malloc */
 
+#ifdef CONFIG_SDCARD_U_BOOT
+#define CONFIG_SYS_RESERVED_LAW0	0
+#endif
+
 #define CONFIG_SYS_NAND_BASE           0xffa00000
 #define CONFIG_SYS_NAND_BASE_PHYS      CONFIG_SYS_NAND_BASE
 #define CONFIG_SYS_NAND_BASE_LIST     { CONFIG_SYS_NAND_BASE,\
Signature · 1 line
1.5.4
author
#5 lore raw

PATCH 6/7 Add support for save the env to SDcard

When after booting from SDcard, the environment variables can to be saved on it, this patch add the operation support.

---
 common/Makefile     |    1 +
 common/cmd_nvedit.c |    3 +-
 common/env_common.c |    3 +-
 common/env_sdcard.c |  129 +++++++++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 134 insertions(+), 2 deletions(-)
 create mode 100644 common/env_sdcard.c
common/Makefile +1 -0
index f13cd11..c768344 100644
@@ -57,6 +57,7 @@ COBJS-$(CONFIG_ENV_IS_IN_NAND) += env_nand.o
 COBJS-$(CONFIG_ENV_IS_IN_NVRAM) += env_nvram.o
 COBJS-$(CONFIG_ENV_IS_IN_ONENAND) += env_onenand.o
 COBJS-$(CONFIG_ENV_IS_IN_SPI_FLASH) += env_sf.o
+COBJS-$(CONFIG_ENV_IS_IN_SDCARD) += env_sdcard.o
 COBJS-$(CONFIG_ENV_IS_NOWHERE) += env_nowhere.o
 
 # command
common/cmd_nvedit.c +2 -1
index 68c673e..fb6ba8d 100644
@@ -59,8 +59,9 @@ DECLARE_GLOBAL_DATA_PTR;
     !defined(CONFIG_ENV_IS_IN_NAND)	&& \
     !defined(CONFIG_ENV_IS_IN_ONENAND)	&& \
     !defined(CONFIG_ENV_IS_IN_SPI_FLASH)	&& \
+    !defined(CONFIG_ENV_IS_IN_SDCARD)	&& \
     !defined(CONFIG_ENV_IS_NOWHERE)
-# error Define one of CONFIG_ENV_IS_IN_{NVRAM|EEPROM|FLASH|DATAFLASH|ONENAND|SPI_FLASH|NOWHERE}
+# error Define one of CONFIG_ENV_IS_IN_{NVRAM|EEPROM|FLASH|DATAFLASH|ONENAND|SPI_FLASH|SDCARD|NOWHERE}
 #endif
 
 #define XMK_STR(x)	#x
common/env_common.c +2 -1
index 6be3bb0..f1aaed2 100644
@@ -140,7 +140,8 @@ uchar default_environment[] = {
 };
 
 #if defined(CONFIG_ENV_IS_IN_NAND)		/* Environment is in Nand Flash */ \
-	|| defined(CONFIG_ENV_IS_IN_SPI_FLASH)
+	|| defined(CONFIG_ENV_IS_IN_SPI_FLASH)	\
+	|| defined(CONFIG_ENV_IS_IN_SDCARD)
 int default_environment_size = sizeof(default_environment);
 #endif
 
common/env_sdcard.c new file +129 -0

129 lines not on this page · raw message

Signature · 1 line
1.5.4
author
#6 lore raw

PATCH 7/7 Save the env variables to SDcard and SPI flash for MPC8536DS

MPC8536DS offer booting from SDcard or SPI flash. When after booting from SD card/SPI flash, the environment variables can to be saved on it, so this patch should be used together with the MMC driver and eSPI controller/SPI flash driver in u-boot.

---
 include/configs/MPC8536DS.h |   43 +++++++++++++++++++++++++++++++++++++------
 1 files changed, 37 insertions(+), 6 deletions(-)
include/configs/MPC8536DS.h +37 -6
index b19f028..974e432 100644
@@ -366,6 +366,19 @@ extern unsigned long get_board_ddr_clk(unsigned long dummy);
 #define CONFIG_SYS_EEPROM_BUS_NUM	1
 
 /*
+ * eSPI - Enhanced SPI
+ */
+#define CONFIG_SPI_FLASH
+#define CONFIG_SPI_FLASH_SPANSION
+
+#define CONFIG_HARD_SPI
+#define CONFIG_FSL_ESPI
+
+#define CONFIG_CMD_SF
+#define CONFIG_SF_DEFAULT_SPEED		10000000
+#define CONFIG_SF_DEFAULT_MODE		0
+
+/*
  * General PCI
  * Memory space is mapped 1-1, but I/O space must start from 0.
  */
@@ -507,14 +520,32 @@ extern unsigned long get_board_ddr_clk(unsigned long dummy);
 /*
  * Environment
  */
-#define CONFIG_ENV_IS_IN_FLASH	1
-#if CONFIG_SYS_MONITOR_BASE > 0xfff80000
-#define CONFIG_ENV_ADDR		0xfff80000
+#if !defined(CONFIG_SDCARD_U_BOOT)
+	#define CONFIG_ENV_IS_IN_FLASH	1
+	#if CONFIG_SYS_MONITOR_BASE > 0xfff80000
+	#define CONFIG_ENV_ADDR		0xfff80000
+	#else
+	#define CONFIG_ENV_ADDR		(CONFIG_SYS_MONITOR_BASE - CONFIG_ENV_SECT_SIZE)
+	#endif
+	#define CONFIG_ENV_SIZE		0x2000
+	#define CONFIG_ENV_SECT_SIZE	0x20000 /* 128K (one sector) */
 #else
-#define CONFIG_ENV_ADDR		(CONFIG_SYS_MONITOR_BASE - CONFIG_ENV_SECT_SIZE)
+#ifdef CONFIG_SPIFLASH_U_BOOT
+	#define CONFIG_ENV_IS_IN_SPI_FLASH	1
+	#define CONFIG_ENV_SPI_BUS		0
+	#define CONFIG_ENV_SPI_CS		0
+	#define CONFIG_ENV_SPI_MAX_HZ		10000000
+	#define CONFIG_ENV_SPI_MODE		0
+	#define CONFIG_ENV_SIZE			0x2000		/* 8KB */
+	#define CONFIG_ENV_OFFSET		0x100000	/* 1MB */
+	#define CONFIG_ENV_SECT_SIZE		0x10000
+#else
+	#define CONFIG_ENV_IS_IN_SDCARD		1
+	#define CONFIG_ENV_SIZE			0x2000
+	/*env located after the u-boot image, size is 8K*/
+	#define CONFIG_ENV_ADDR_IN_RAM	((TEXT_BASE - 0x1000) + 0x80000)
+#endif
 #endif
-#define CONFIG_ENV_SIZE		0x2000
-#define CONFIG_ENV_SECT_SIZE	0x20000 /* 128K (one sector) */
 
 #define CONFIG_LOADS_ECHO	1	/* echo on for serial download */
 #define CONFIG_SYS_LOADS_BAUD_CHANGE	1	/* allow baudrate change */
Signature · 1 line
1.5.4
#7 lore raw

PATCH 7/7 Save the env variables to SDcard and SPI flash for MPC8536DS

Dear Mingkai Hu,

Quoted 6 lines · In message <[email protected]> you…

MPC8536DS offer booting from SDcard or SPI flash. When after booting from SD card/SPI flash, the environment variables can to be saved on it, so this patch should be used together with the MMC driver and eSPI controller/SPI flash driver in u-boot.

...

Quoted 1 line

+#if !defined(CONFIG_SDCARD_U_BOOT)

...

Please swap cases and use positive logic.

Best regards,

Wolfgang Denk

Signature · 6 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
Am I your nanny? The kernel is there to support  user  programs,  but
it's a _resource_ handler, not a baby feeder.     - Linus Torvalds in
      <[email protected]>
#8 lore raw

PATCH 6/7 Add support for save the env to SDcard

In reply to Mingkai Hu
Quoted 2 lines · On Sunday 15 March 2009 22:52:22 Mingkai Hu wrote:

When after booting from SDcard, the environment variables can to be saved on it, this patch add the operation support.

so your board treats the SD storage as a raw block ? you cant actually put a filesystem on it or what ? considering SD cards are most often partitioned & formatted as FAT, this seems really weird ...
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
Url : http://lists.denx.de/pipermail/u-boot/attachments/20090316/16cb7fb5/attachment-0001.pgp

#9 lore raw

PATCH 5/7 Make a special uboot used for booting from SDcard or SPI flash

In reply to Mingkai Hu

Dear Mingkai Hu,

Quoted 11 lines · In message <[email protected]> you…

This patch is used to generate a special version u-boot, together with the data structure on the SDcard/SPI flash, can be used to booting from SDcard/SPI flash on 8536DS board.

The boot ROM in CPU and the data structure on SD card will initialize the DDR, set a large tlb0 for DDR and CCSR, set law0 for DDR. The special version uboot avoid initializing the DDR. Try to reseve the law0 for DDR by adding a CONFIG_SYS_RESERVED_LAW0 macro for the "dynamic law allocation" code. But keep the original tlb initialize code for DDR, disabled the large tlb0 which was set in the boot ROM.

Quoted 2 lines

This patch is intend for those who are interested in the function of booting from SD card on 8536DS board and not for opensource.

-------------------------------------------^^^^^^^^^^^^^^^^^^^^

Can you please explain what exactly this is supposed to mean?

Quoted 3 lines

An utility is needed to write the data structure and the special version u-boot onto the SD card which has filesystem on it or onto the SPI flash.

Cannot this be done with U-Boot, or with Linux running on any other system that das a SDCard reader/writer attached to it?

Quoted 6 lines
Makefile +2 -0
@@ -2360,6 +2360,18 @@ ATUM8548_config:	unconfig
 MPC8536DS_config:       unconfig
 	@$(MKCONFIG) $(@:_config=) ppc mpc85xx mpc8536ds freescale
 
+MPC8536DS_SPIFLASH_config \
+MPC8536DS_SDCARD_config:	unconfig

Makefile ATUM8548_config: unconfig · line 2374

Quoted 10 lines
Makefile +10 -0
+	@echo "" >$(obj)include/config.h;
+	@if [ "$(findstring _SPIFLASH_,$@)" ] ; then \
+		echo "#define CONFIG_SPIFLASH_U_BOOT" >> $(obj)include/config.h ; \
+	fi ;
+	@echo "#define CONFIG_SDCARD_U_BOOT" >> $(obj)include/config.h ;
+	@$(MKCONFIG) -a MPC8536DS ppc mpc85xx mpc8536ds freescale ; \
+		echo "TEXT_BASE = 0x11001000" > $(obj)board/freescale/mpc8536ds/config.tmp ; \
+		echo "#define CONFIG_SDCARD_U_BOOT" >> $(obj)include/config.h ;  \
+		echo "CONFIG_SDCARD_U_BOOT = y" >> $(obj)include/config.mk ;
+

Please do noty swamp the top level Makefile with configuration options for one board.

Quoted 14 lines
board/freescale/mpc8536ds/tlb.c +2 -0
index 35a13d4..cb570ef 100644
@@ -27,6 +27,8 @@
 #include <asm/mmu.h>
 
 struct fsl_e_tlb_entry tlb_table[] = {
+
+#if !defined(CONFIG_SDCARD_U_BOOT)
 	/* TLB 0 - for temp stack in cache */
 	SET_TLB_ENTRY(0, CONFIG_SYS_INIT_RAM_ADDR, CONFIG_SYS_INIT_RAM_ADDR,
 		      MAS3_SX|MAS3_SW|MAS3_SR, 0,

board/freescale/mpc8536ds/tlb.c struct fsl_e_tlb_entry tlb_table[] = { · line 42

Quoted 1 line
board/freescale/mpc8536ds/tlb.c +0 -0
@@ -40,6 +42,7 @@ struct fsl_e_tlb_entry tlb_table[] = {
 	SET_TLB_ENTRY(0, CONFIG_SYS_INIT_RAM_ADDR + 12 * 1024 , CONFIG_SYS_INIT_RAM_ADDR + 12 * 1024,

Line length. [I know this is old code, anyway...]

Quoted 6 lines
board/freescale/mpc8536ds/tlb.c +1 -0
+}
config.mk +0 -0
index b1254e9..3300b75 100644

config.mk DBGFLAGS= -g # -DDEBUG · line 119

Quoted 10 lines
config.mk +2 -2
@@ -112,8 +112,8 @@ DBGFLAGS= -g # -DDEBUG
 OPTFLAGS= -Os #-fomit-frame-pointer
 ifndef LDSCRIPT
 #LDSCRIPT := $(TOPDIR)/board/$(BOARDDIR)/u-boot.lds.debug
-ifeq ($(CONFIG_NAND_U_BOOT),y)
-LDSCRIPT := $(TOPDIR)/board/$(BOARDDIR)/u-boot-nand.lds
+ifeq ($(CONFIG_SDCARD_U_BOOT),y)
+LDSCRIPT := $(TOPDIR)/board/$(BOARDDIR)/u-boot-sdboot.lds
 else
 LDSCRIPT := $(TOPDIR)/board/$(BOARDDIR)/u-boot.lds
 endif

Is it absolutely necessary to set this in the top level config.mk file?

cpu/mpc85xx/cpu_init.c line 6

Quoted 12 lines
cpu/mpc85xx/cpu_init.c +5 -1
index 0b7c609..f2fd168 100644
@@ -1,5 +1,9 @@
 /*
- * Copyright 2007 Freescale Semiconductor.
+ * Copyright (C) 2007,2009 Freescale Semiconductor, Inc.
+ *
+ * (C) 2009 Freescale Semiconductor, Inc.
+ * Modified by Jason Jin, Jason.jin at freescale.com,
+ * 	       Mingkai hu, Mingkai.hu at freescale.com

Please do not add such "Modified by" comments. We use git to track the history of changes.

cpu/mpc85xx/cpu_init.c void cpu_init_early_f(void) · line 189

Quoted 5 lines
cpu/mpc85xx/cpu_init.c +5 -0
+#if (CONFIG_SYS_CCSRBAR_DEFAULT != CONFIG_SYS_CCSRBAR_PHYS)
+	{
+		u32 temp;
+		temp = in_be32((volatile u32 *)CONFIG_SYS_CCSRBAR_DEFAULT);
+		out_be32((volatile u32 *)CONFIG_SYS_CCSRBAR_DEFAULT, CONFIG_SYS_CCSRBAR_PHYS >> 12);

Line length.

cpu/mpc85xx/cpu_init.c

Quoted 2 lines
cpu/mpc85xx/cpu_init.c +1 -1
-#ifdef CONFIG_SYS_RAMBOOT
+#if defined(CONFIG_SYS_RAMBOOT) || defined(CONFIG_SDCARD_U_BOOT)

Please create a new config name to invoid an ever growing list of ...||...||...||...

Quoted 4 lines
cpu/mpc85xx/cpu_init.c +3 -0
+#if !defined(CONFIG_SDCARD_U_BOOT)
 	bl	cpu_init_early_f
+#else
+	bl	cpu_init_early_f_sd

cpu/mpc85xx/cpu_init.c

Quoted 10 lines
cpu/mpc85xx/cpu_init.c +10 -0
+
+	/*Then switch to space 1*/
+	lis     r3,(MSR_CE|MSR_ME|MSR_DE|MSR_IS|MSR_DS)@h
+	ori     r3,r3,(MSR_CE|MSR_ME|MSR_DE|MSR_IS|MSR_DS)@l
+	mtmsr	r3
+	isync
+	msync
+
+	bl	cpu_init_early_f_sd_continue
+#endif

Please swap cases and use positive logic instead.

include/configs/MPC8536DS.h extern unsigned long get_board_ddr_clk(unsigned long dummy); · line 119

Quoted 10 lines
include/configs/MPC8536DS.h +1 -1
index bbb448d..b19f028 100644
@@ -116,7 +116,7 @@ extern unsigned long get_board_ddr_clk(unsigned long dummy);
 #define CONFIG_SYS_SPD_BUS_NUM		1
 
 /* These are used when DDR doesn't use SPD. */
-#define CONFIG_SYS_SDRAM_SIZE		256		/* DDR is 256MB */
+#define CONFIG_SYS_SDRAM_SIZE		512		/* DDR is 512MB */

Line length.

Quoted 5 lines
include/configs/MPC8536DS.h +0 -0
 #define CONFIG_SYS_DDR_CS0_BNDS	0x0000001F
 #define CONFIG_SYS_DDR_CS0_CONFIG	0x80010102	/* Enable, no interleaving */
 #define CONFIG_SYS_DDR_TIMING_3	0x00000000
@@ -235,9 +235,15 @@ extern unsigned long get_board_ddr_clk(unsigned long dummy);
 #define PIXIS_VCLKL		0x1A	/* VELA VCLKL register */

include/configs/MPC8536DS.h extern unsigned long get_board_ddr_clk(unsigned long dummy); · line 245

Quoted 10 lines
include/configs/MPC8536DS.h +5 -0
 #define CONFIG_SYS_PIXIS_VBOOT_MASK	0xc0
 
+#if !defined(CONFIG_SDCARD_U_BOOT)
 #define CONFIG_SYS_INIT_RAM_LOCK	1
 #define CONFIG_SYS_INIT_RAM_ADDR	0xffd00000	/* Initial L1 address */
 #define CONFIG_SYS_INIT_RAM_END	0x00004000	/* End of used area in RAM */
+#else
+#undef  CONFIG_SYS_INIT_RAM_LOCK
+#define CONFIG_SYS_INIT_RAM_ADDR	0x07d00000	/* unused memory region */
+#define CONFIG_SYS_INIT_RAM_END	0x4000          /* we have SDRAM initialized */

Line length.

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
Sometimes, too long is too long.                          - Joe Crowe
#10 lore raw

PATCH 5/7 Make a special uboot used for booting from SDcard or SPI flash

Quoted 28 lines

-----Original Message-----
From: Wolfgang Denk [mailto:wd at denx.de]
Sent: Monday, March 16, 2009 4:56 PM
To: Hu Mingkai-B21284
Cc: Fleming Andy-AFLEMING; u-boot at lists.denx.de; Jin Zhengxiong-R64188
Subject: Re: [U-Boot] [PATCH 5/7] Make a special uboot used for booting from SDcard or SPI flash

Dear Mingkai Hu,

In message <[email protected]>

Quoted 1 line · you

This patch is used to generate a special version u-boot,

together with

Quoted 4 lines

the data structure on the SDcard/SPI flash, can be used to booting from SDcard/SPI flash on 8536DS board.

The boot ROM in CPU and the data structure on SD card will

initialize

Quoted 3 lines

the DDR, set a large tlb0 for DDR and CCSR, set law0 for DDR. The special version uboot avoid initializing the DDR. Try to reseve the law0 for DDR by adding a CONFIG_SYS_RESERVED_LAW0 macro for

the "dynamic law allocation"

Quoted 1 line

code. But keep the original tlb initialize code for DDR,

disabled the

Quoted 9 lines
Quoted 3 lines

large tlb0 which was set in the boot ROM.

This patch is intend for those who are interested in the

function of

Quoted 1 line

booting from SD card on 8536DS board and not for opensource.

-------------------------------------------^^^^^^^^^^^^^^^^^^^^

Can you please explain what exactly this is supposed to mean?

Oh, it should be deleted :-)

Quoted 8 lines
Quoted 2 lines

An utility is needed to write the data structure and the special version u-boot onto the SD card which has filesystem on it

or onto the

Quoted 1 line

SPI flash.

Cannot this be done with U-Boot, or with Linux running on any other system that das a SDCard reader/writer attached to it?

It's hard to do that, in order to support booting from the SDCard, we place the data structure onto the unused space on the MBR on the SDCard.

Quoted 15 lines

Makefile ATUM8548_config: unconfig · line 2367

Quoted 9 lines
Makefile +5 -0
@@ -2360,6 +2360,18 @@ ATUM8548_config:	unconfig
 MPC8536DS_config:       unconfig
 	@$(MKCONFIG) $(@:_config=) ppc mpc85xx mpc8536ds freescale
 
+MPC8536DS_SPIFLASH_config \
+MPC8536DS_SDCARD_config:	unconfig
+	@echo "" >$(obj)include/config.h;
+	@if [ "$(findstring _SPIFLASH_,$@)" ] ; then \
+		echo "#define CONFIG_SPIFLASH_U_BOOT" >> 

$(obj)include/config.h ; \

Makefile ATUM8548_config: unconfig

Quoted 4 lines
Makefile +4 -0
+	fi ;
+	@echo "#define CONFIG_SDCARD_U_BOOT" >> $(obj)include/config.h ;
+	@$(MKCONFIG) -a MPC8536DS ppc mpc85xx mpc8536ds freescale ; \
+		echo "TEXT_BASE = 0x11001000" > 

$(obj)board/freescale/mpc8536ds/config.tmp ; \

Quoted 9 lines

Review ATUM8548_config: unconfig · line 2372

Quoted 1 line
(quoted diff) +1 -0
+		echo "#define CONFIG_SDCARD_U_BOOT" >> 

$(obj)include/config.h ; \

Review ATUM8548_config: unconfig · line 2373

Quoted 1 line
(quoted diff) +1 -0
+		echo "CONFIG_SDCARD_U_BOOT = y" >> 

$(obj)include/config.mk ;

Review ATUM8548_config: unconfig · line 2374

Quoted 1 line
(quoted diff) +1 -0
+

Please do noty swamp the top level Makefile with
configuration options for one board.

Could you give me some suggestion? ;-)
Where is the proper position to handle this?

Quoted 13 lines

board/freescale/mpc8536ds/tlb.c line 33

Quoted 12 lines
(quoted diff) +0 -0

b/board/freescale/mpc8536ds/tlb.c index 35a13d4..cb570ef 100644

board/freescale/mpc8536ds/tlb.c +2 -0
@@ -27,6 +27,8 @@
 #include <asm/mmu.h>
 
 struct fsl_e_tlb_entry tlb_table[] = {
+
+#if !defined(CONFIG_SDCARD_U_BOOT)
 	/* TLB 0 - for temp stack in cache */
 	SET_TLB_ENTRY(0, CONFIG_SYS_INIT_RAM_ADDR, 

CONFIG_SYS_INIT_RAM_ADDR,

Quoted 6 lines

board/freescale/mpc8536ds/tlb.c struct fsl_e_tlb_entry tlb_table[] = { · line 43

Quoted 4 lines
board/freescale/mpc8536ds/tlb.c +0 -0
 		      MAS3_SX|MAS3_SW|MAS3_SR, 0,
@@ -40,6 +42,7 @@ struct fsl_e_tlb_entry tlb_table[] = {
 	SET_TLB_ENTRY(0, CONFIG_SYS_INIT_RAM_ADDR + 12 * 1024 , 
 CONFIG_SYS_INIT_RAM_ADDR + 12 * 1024,

Line length. [I know this is old code, anyway...]

Ok, I'll fix the line length issue.

Quoted 10 lines
Quoted 10 lines
board/freescale/mpc8536ds/tlb.c +1 -0
+}
config.mk +0 -0
index b1254e9..3300b75 100644
@@ -112,8 +112,8 @@ DBGFLAGS= -g # -DDEBUG  OPTFLAGS= -Os 
 #-fomit-frame-pointer  ifndef LDSCRIPT  #LDSCRIPT := 

$(TOPDIR)/board/$(BOARDDIR)/u-boot.lds.debug

config.mk +0 -2
-ifeq ($(CONFIG_NAND_U_BOOT),y)
-LDSCRIPT := $(TOPDIR)/board/$(BOARDDIR)/u-boot-nand.lds
Quoted 9 lines

config.mk DBGFLAGS= -g # -DDEBUG · line 119

Quoted 5 lines
config.mk +2 -0
+ifeq ($(CONFIG_SDCARD_U_BOOT),y)
+LDSCRIPT := $(TOPDIR)/board/$(BOARDDIR)/u-boot-sdboot.lds
 else
 LDSCRIPT := $(TOPDIR)/board/$(BOARDDIR)/u-boot.lds
 endif

Is it absolutely necessary to set this in the top level config.mk file?

Maybe combined with u-boot.lds.

Quoted 8 lines
Quoted 8 lines
config.mk +7 -0
+#if !defined(CONFIG_SDCARD_U_BOOT)
 	bl	cpu_init_early_f
+#else
+	bl	cpu_init_early_f_sd
+
+	/*Then switch to space 1*/
+	lis     r3,(MSR_CE|MSR_ME|MSR_DE|MSR_IS|MSR_DS)@h
+	ori     r3,r3,(MSR_CE|MSR_ME|MSR_DE|MSR_IS|MSR_DS)@l
Quoted 9 lines

config.mk

Quoted 6 lines
config.mk +6 -0
+	mtmsr	r3
+	isync
+	msync
+
+	bl	cpu_init_early_f_sd_continue
+#endif

Please swap cases and use positive logic instead.

Oh, thanks, I'll fix it.

Quoted 11 lines

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
Sometimes, too long is too long.                          - Joe Crowe

Thanks,
Mingkai

#11 lore raw

PATCH 5/7 Make a special uboot used for booting from SDcard or SPI flash

Dear "Hu Mingkai-B21284",

Quoted 7 lines · In message <73839B4A0818E747864426270AC332C303E411DE@zmy16exm20.fsl.freescale.n…
Quoted 3 lines

Cannot this be done with U-Boot, or with Linux running on any other system that das a SDCard reader/writer attached to it?

It's hard to do that, in order to support booting from the SDCard, we place the data structure onto the unused space on the MBR on the SDCard.

What exactly is the difficault part there?

Reading and modifying the MBR is just like reading or writing any other block on the device. Where is the problem?

Quoted 19 lines
Quoted 19 lines

Makefile ATUM8548_config: unconfig · line 2367

Quoted 9 lines
Makefile +5 -0
@@ -2360,6 +2360,18 @@ ATUM8548_config:	unconfig
 MPC8536DS_config:       unconfig
 	@$(MKCONFIG) $(@:_config=) ppc mpc85xx mpc8536ds freescale
 
+MPC8536DS_SPIFLASH_config \
+MPC8536DS_SDCARD_config:	unconfig
+	@echo "" >$(obj)include/config.h;
+	@if [ "$(findstring _SPIFLASH_,$@)" ] ; then \
+		echo "#define CONFIG_SPIFLASH_U_BOOT" >> 

$(obj)include/config.h ; \

Makefile ATUM8548_config: unconfig

Quoted 4 lines
Makefile +4 -0
+	fi ;
+	@echo "#define CONFIG_SDCARD_U_BOOT" >> $(obj)include/config.h ;
+	@$(MKCONFIG) -a MPC8536DS ppc mpc85xx mpc8536ds freescale ; \
+		echo "TEXT_BASE = 0x11001000" > 

$(obj)board/freescale/mpc8536ds/config.tmp ; \

Review ATUM8548_config: unconfig · line 2372

Quoted 1 line
(quoted diff) +1 -0
+		echo "#define CONFIG_SDCARD_U_BOOT" >> 

$(obj)include/config.h ; \

Review ATUM8548_config: unconfig · line 2373

Quoted 1 line
(quoted diff) +1 -0
+		echo "CONFIG_SDCARD_U_BOOT = y" >> 

$(obj)include/config.mk ;

Quoted 8 lines
Quoted 5 lines

Review ATUM8548_config: unconfig · line 2374

Quoted 1 line
(quoted diff) +1 -0
+

Please do noty swamp the top level Makefile with
configuration options for one board.

Could you give me some suggestion? ;-)
Where is the proper position to handle this?

Options if a board has (or uses) SPI flash and/or a SDCard and/or other things belong into the board config file. It makes no sense to provide long lists of make targets and then again long code to analyze these options in the top level Makefile. For example, above code would not allow for the case that a customer wants to use a board with SPI flash *and* SDCard - it covers only the *or* case. And no, please do not attempt to add even more such targets. This is not the way to go. It doesn't scale.

Assume each of the hundrets of boards would add code like this.

Quoted 16 lines
Quoted 7 lines
Quoted 7 lines
config.mk +0 -0
@@ -112,8 +112,8 @@ DBGFLAGS= -g # -DDEBUG  OPTFLAGS= -Os 
 #-fomit-frame-pointer  ifndef LDSCRIPT  #LDSCRIPT := 

$(TOPDIR)/board/$(BOARDDIR)/u-boot.lds.debug

config.mk +0 -2
-ifeq ($(CONFIG_NAND_U_BOOT),y)
-LDSCRIPT := $(TOPDIR)/board/$(BOARDDIR)/u-boot-nand.lds
Quoted 9 lines

config.mk DBGFLAGS= -g # -DDEBUG · line 119

Quoted 5 lines
config.mk +2 -0
+ifeq ($(CONFIG_SDCARD_U_BOOT),y)
+LDSCRIPT := $(TOPDIR)/board/$(BOARDDIR)/u-boot-sdboot.lds
 else
 LDSCRIPT := $(TOPDIR)/board/$(BOARDDIR)/u-boot.lds
 endif

Is it absolutely necessary to set this in the top level config.mk file?

Quoted 1 line

Maybe combined with u-boot.lds.

Or moved to a processor or board specific config.mk.

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
I haven't lost my mind -- it's backed up on tape somewhere.
#12 lore raw

PATCH 5/7 Make a special uboot used for booting from SDcard or SPI flash

Quoted 8 lines · Wolfgang Denk

Options if a board has (or uses) SPI flash and/or a SDCard and/or other things belong into the board config file. It makes no sense to provide long lists of make targets and then again long code to analyze these options in the top level Makefile. For example, above code would not allow for the case that a customer wants to use a board with SPI flash *and* SDCard - it covers only the *or* case. And no, please do not attempt to add even more such targets. This is not the way to go. It doesn't scale.

Unless I'm mistaken, those targets aren't for boards that merely *have* such things, but are trying to boot from the device in question, similar to the alternate configs for booting from NAND.

Quoted 1 line

Assume each of the hundrets of boards would add code like this.

That's why we need kconfig. :-)

But until then...

-Scott

#13 lore raw

PATCH 5/7 Make a special uboot used for booting from SDcard or SPI flash

Dear Scott Wood,

Quoted 10 lines · In message <[email protected]> you wrote:

Unless I'm mistaken, those targets aren't for boards that merely *have* such things, but are trying to boot from the device in question, similar to the alternate configs for booting from NAND.

Quoted 1 line

Assume each of the hundrets of boards would add code like this.

That's why we need kconfig. :-)

But until then...

...we should limit the number of make targets per board and not let grow it out of bound in an unreasonable way.

Best regards,

Wolfgang Denk

Signature · 5 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
One possible reason that things aren't going  according  to  plan  is
that there never was a plan in the first place.
#14 lore raw

PATCH 5/7 Make a special uboot used for booting from SDcard or SPI flash

Quoted 7 lines · Wolfgang Denk

Dear Scott Wood,

Quoted 4 lines · In message <[email protected]> you wrote:

Unless I'm mistaken, those targets aren't for boards that merely *have* such things, but are trying to boot from the device in question, similar to the alternate configs for booting from NAND.

Quoted 7 lines
Quoted 4 lines
Quoted 1 line

Assume each of the hundrets of boards would add code like this.

That's why we need kconfig. :-)

But until then...

...we should limit the number of make targets per board and not let grow it out of bound in an unreasonable way.

You'd rather tell the user they can't boot from a given device because it would clutter the makefile?

-Scott

#15 lore raw

PATCH 5/7 Make a special uboot used for booting from SDcard or SPI flash

Dear Scott,

Quoted 3 lines · In message <[email protected]> you wrote:

You'd rather tell the user they can't boot from a given device because it would clutter the makefile?

Select it in the board config file?

Best regards,

Wolfgang Denk

Signature · 6 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
After a time, you may find that "having" is not so pleasing a thing,
after all, as "wanting."  It is not logical, but it is often true.
	-- Spock, "Amok Time", stardate 3372.7
#16 lore raw

PATCH 5/7 Make a special uboot used for booting from SDcard or SPI flash

Quoted 7 lines · Wolfgang Denk

Dear Scott,

Quoted 2 lines · In message <[email protected]> you wrote:

You'd rather tell the user they can't boot from a given device because it would clutter the makefile?

Select it in the board config file?

So the options are:
1. Make the user hand-edit the board config file,
2. Duplicate the board config file, or
3. Put up with a little clutter in the makefile until a better system is put into place -- and hopefully the clutter will serve as encouragement for this to actually happen. :-)

I'm not sure which of #1 or #2 you're advocating, but I much prefer #3.

-Scott

#17 lore raw

PATCH 5/7 Make a special uboot used for booting from SDcard or SPI flash

Dear Scott Wood,

Quoted 9 lines · In message <[email protected]> you wrote:

So the options are:
1. Make the user hand-edit the board config file,
2. Duplicate the board config file, or
3. Put up with a little clutter in the makefile until a better system is put into place -- and hopefully the clutter will serve as encouragement for this to actually happen. :-)

I'm not sure which of #1 or #2 you're advocating, but I much prefer #3.

I'm seeing a pretty strong and growing tendency for Freescale boards to have 30+ lines entries in the Makefile. This is something that must stop.

If you want to handle this typo through Makefile configuration, then at least write much shorter code.

Best regards,

Wolfgang Denk

Signature · 5 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
Success in marriage is not so much finding the right person as it  is
being the right person.
#18 lore raw

PATCH 5/7 Make a special uboot used for booting from SDcard or SPI flash

In reply to Wolfgang Denk

Hi Wolfgang,

First truly sorry for the long time delay. I'm not on purpose.

I reworked this patch and unified the implementation of booting from NAND/SDCard/SPI flash
for MPC85xx platform, and sent to the U-Boot list on August:
http://lists.denx.de/pipermail/u-boot/2009-August/058803.html

Also we tried a method that not to swamp the top level Makefile with different configuration
options. Hope you can find some time to give some comments.

Please find comments inline about this patch.

Quoted 19 lines

-----Original Message-----
From: Wolfgang Denk [mailto:wd at denx.de]
Sent: Tuesday, March 17, 2009 8:31 PM
To: Hu Mingkai-B21284
Cc: Fleming Andy-AFLEMING; u-boot at lists.denx.de;
Subject: Re: [U-Boot] [PATCH 5/7] Make a special uboot used for booting from SDcard or SPI flash

Dear "Hu Mingkai-B21284",

In message <[email protected]

Quoted 2 lines · cale.net> you wrote:
Quoted 2 lines

Cannot this be done with U-Boot, or with Linux running on

any other

Quoted 3 lines
Quoted 1 line

system that das a SDCard reader/writer attached to it?

It's hard to do that, in order to support booting from the

Quoted 9 lines

SDCard, we

Quoted 2 lines

place the data structure onto the unused space on the MBR on the SDCard.

What exactly is the difficault part there?

Reading and modifying the MBR is just like reading or writing any other block on the device. Where is the problem?

Yes, you're right. We just need to put the specific info to the assigned address.

Quoted 42 lines
Quoted 3 lines
Quoted 3 lines

Review ATUM8548_config: unconfig · line 2361

Quoted 3 lines
(quoted diff) +0 -0
@@ -2360,6 +2360,18 @@ ATUM8548_config:	unconfig
 MPC8536DS_config:       unconfig
 	@$(MKCONFIG) $(@:_config=) ppc mpc85xx 

mpc8536ds freescale

Quoted 9 lines
Quoted 9 lines

Makefile ATUM8548_config: unconfig

Quoted 6 lines
Makefile +5 -0
+MPC8536DS_SPIFLASH_config \
+MPC8536DS_SDCARD_config:	unconfig
+	@echo "" >$(obj)include/config.h;
+	@if [ "$(findstring _SPIFLASH_,$@)" ] ; then \
+		echo "#define CONFIG_SPIFLASH_U_BOOT" >>

$(obj)include/config.h ; \

Review ATUM8548_config: unconfig · line 2368

Quoted 2 lines
(quoted diff) +2 -0
+	fi ;
+	@echo "#define CONFIG_SDCARD_U_BOOT" >> 

$(obj)include/config.h ;

Quoted 1 line
Quoted 1 line

Review ATUM8548_config: unconfig · line 2369

Quoted 1 line
(quoted diff) +1 -0
+	@$(MKCONFIG) -a MPC8536DS ppc mpc85xx mpc8536ds 

freescale ; \

Quoted 6 lines
Quoted 6 lines

Review ATUM8548_config: unconfig · line 2370

Quoted 1 line
(quoted diff) +1 -0
+		echo "TEXT_BASE = 0x11001000" >

$(obj)board/freescale/mpc8536ds/config.tmp ; \

Review ATUM8548_config: unconfig · line 2371

Quoted 1 line
(quoted diff) +1 -0
+		echo "#define CONFIG_SDCARD_U_BOOT" >>

$(obj)include/config.h ; \

Review ATUM8548_config: unconfig · line 2372

Quoted 1 line
(quoted diff) +1 -0
+		echo "CONFIG_SDCARD_U_BOOT = y" >>

$(obj)include/config.mk ;

Quoted 7 lines
Quoted 5 lines

Review ATUM8548_config: unconfig · line 2373

Quoted 1 line
(quoted diff) +1 -0
+

Please do noty swamp the top level Makefile with configuration options for one board.

Could you give me some suggestion? ;-) Where is the proper

position to

Quoted 1 line

handle this?

Options if a board has (or uses) SPI flash and/or a SDCard and/or other things belong into the board config file. It makes no sense to provide long lists of make targets and then again long code to analyze these options in the top level Makefile. For example, above code would not allow for the case that a customer wants to use a board with SPI flash *and* SDCard - it covers only the *or* case. And no, please do not attempt to add even more such targets. This is not the way to go. It doesn't scale.

Quoted 2 lines

Assume each of the hundrets of boards would add code like this.

So we add another option (-t) on the mkconfig file to parse the target to individual targets,
and put them to config.h and config.mk, then leave the board config file and board makefile
to handle the different options.
http://lists.denx.de/pipermail/u-boot/2009-August/058804.html

Really need your suggestions.

Quoted 16 lines
Quoted 16 lines
Quoted 16 lines

config.mk DBGFLAGS= -g # -DDEBUG · line 119

Quoted 12 lines
config.mk +0 -0
@@ -112,8 +112,8 @@ DBGFLAGS= -g # -DDEBUG  OPTFLAGS= -Os 
 #-fomit-frame-pointer  ifndef LDSCRIPT  #LDSCRIPT := 

$(TOPDIR)/board/$(BOARDDIR)/u-boot.lds.debug

config.mk +2 -2
-ifeq ($(CONFIG_NAND_U_BOOT),y)
-LDSCRIPT := $(TOPDIR)/board/$(BOARDDIR)/u-boot-nand.lds
+ifeq ($(CONFIG_SDCARD_U_BOOT),y)
+LDSCRIPT := $(TOPDIR)/board/$(BOARDDIR)/u-boot-sdboot.lds
 else
 LDSCRIPT := $(TOPDIR)/board/$(BOARDDIR)/u-boot.lds
 endif

Is it absolutely necessary to set this in the top level config.mk file?

Quoted 5 lines
Quoted 1 line

Maybe combined with u-boot.lds.

Or moved to a processor or board specific config.mk.

Reused the u-boot.lds for booting from SDCard/SPI flash.

Quoted 4 lines

Best regards,

Wolfgang Denk

Sorry again for the delayed response.

Many thanks,
Mingkai

#19 lore raw

PATCH 3/7 eSPI: add eSPI controller support

In reply to Mingkai Hu
Quoted 10 lines · Mingkai Hu

Add eSPI controller support under the SPI framework.

---
 drivers/mtd/spi/spi_flash.c |   94 +++++++++++++++++-
 drivers/spi/Makefile        |    1 +
 drivers/spi/fsl_espi.c      |  232 +++++++++++++++++++++++++++++++++++++++++++
 include/spi.h               |   30 ++++++
 4 files changed, 354 insertions(+), 3 deletions(-)
 create mode 100644 drivers/spi/fsl_espi.c

please use the spi framework, their is no need to touch the spi_flash support ti add and use the fsl_espi

Best Regards,
J.

#20 lore raw

PATCH 3/7 eSPI: add eSPI controller support

Quoted 13 lines · On Monday 16 March 2009 02:15:27 Jean-Christophe PLAGNIOL-VILLARD wrote:
Quoted 11 lines · Mingkai Hu

Add eSPI controller support under the SPI framework.

---
 drivers/mtd/spi/spi_flash.c |   94 +++++++++++++++++-
 drivers/spi/Makefile        |    1 +
 drivers/spi/fsl_espi.c      |  232
+++++++++++++++++++++++++++++++++++++++++++ include/spi.h               |
  30 ++++++
 4 files changed, 354 insertions(+), 3 deletions(-)
 create mode 100644 drivers/spi/fsl_espi.c
Quoted 2 lines

please use the spi framework, their is no need to touch the spi_flash support ti add and use the fsl_espi

indeed ... i was so happy to see the spansion driver i glossed over this ... those spi_flash.c changes are almost assuredly wrong and indicate you arent fitting into the framework correctly.
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
Url : http://lists.denx.de/pipermail/u-boot/attachments/20090316/766d68ff/attachment.pgp

#21 lore raw

PATCH 3/7 eSPI: add eSPI controller support

Quoted 27 lines

-----Original Message-----
From: Mike Frysinger [mailto:vapier at gentoo.org]
Sent: Monday, March 16, 2009 3:28 PM
To: u-boot at lists.denx.de
Cc: Jean-Christophe PLAGNIOL-VILLARD; Hu Mingkai-B21284; Fleming Andy-AFLEMING
Subject: Re: [U-Boot] [PATCH 3/7] eSPI: add eSPI controller support

Quoted 9 lines · On Monday 16 March 2009 02:15:27 Jean-Christophe PLAGNIOL-VILLARD wrote:
Quoted 8 lines · Mingkai Hu

Add eSPI controller support under the SPI framework.

---
 drivers/mtd/spi/spi_flash.c |   94 +++++++++++++++++-
 drivers/spi/Makefile        |    1 +
 drivers/spi/fsl_espi.c      |  232

+++++++++++++++++++++++++++++++++++++++++++ include/spi.h

              |
Quoted 5 lines
Quoted 3 lines

30 ++++++

 4 files changed, 354 insertions(+), 3 deletions(-)  create mode 

100644 drivers/spi/fsl_espi.c

please use the spi framework, their is no need to touch the

Quoted 9 lines

spi_flash

Quoted 1 line

support ti add and use the fsl_espi

indeed ... i was so happy to see the spansion driver i glossed over this ...
those spi_flash.c changes are almost assuredly wrong and indicate you arent fitting into the framework correctly. -mike

There is difference between the SPI and eSPI chip select signal. Generally, the SPI chip select is controlled by GPIO, so SW can control when to
assert the chip select signal and when to stop the chip select signal. But the eSPI controller integrate the chip select into the controller itself, it use the
transfer length to control the duration of the chip select signal.

The spi_flash_cmd_* function split the transfer into two steps: first the command
transfer and then the data transfer. At the first step, the transfer length is set to
the command length, and when transferred the command, the chip select will be
negated, so the eSPI controller thinks the transfer is cancelled and doesn't transfer
the data again.

I'm in a dilemma on this issue and really need your suggestion :-)

Thanks,
Mingkai

#22 lore raw

PATCH 3/7 eSPI: add eSPI controller support

Quoted 24 lines · On Monday 16 March 2009 04:56:22 Hu Mingkai-B21284 wrote:

From: Mike Frysinger [mailto:vapier at gentoo.org]

Quoted 15 lines · On Monday 16 March 2009 02:15:27 Jean-Christophe wrote:
Quoted 14 lines · Mingkai Hu
Quoted 12 lines

Add eSPI controller support under the SPI framework.

---
 drivers/mtd/spi/spi_flash.c |   94 +++++++++++++++++-
 drivers/spi/Makefile        |    1 +
 drivers/spi/fsl_espi.c      |  232

+++++++++++++++++++++++++++++++++++++++++++ include/spi.h

30 ++++++

 4 files changed, 354 insertions(+), 3 deletions(-)  create mode

100644 drivers/spi/fsl_espi.c

Quoted 7 lines
Quoted 2 lines

please use the spi framework, their is no need to touch the spi_flash support ti add and use the fsl_espi

indeed ... i was so happy to see the spansion driver i glossed over this ...
those spi_flash.c changes are almost assuredly wrong and indicate you arent fitting into the framework correctly.

Quoted 4 lines

There is difference between the SPI and eSPI chip select signal. Generally, the SPI chip select is controlled by GPIO, so SW can control when to assert the chip select signal and when to stop the chip select signal.

that is incorrect. the SPI framework does not care how the controller manages the CS. the Blackfin SPI controller for example has dedicated CS's which the controller manages automatically.

Quoted 3 lines

But the eSPI controller integrate the chip select into the controller itself, it use the transfer length to control the duration of the chip select signal.

so you must tell the controller ahead of time how many bytes are going to be transferred ? this sounds like a retarded hardware implementation to me. how exactly do you support arbitrary transfer lengths ?

Quoted 5 lines

The spi_flash_cmd_* function split the transfer into two steps: first the command transfer and then the data transfer. At the first step, the transfer length is set to the command length, and when transferred the command, the chip select will be negated, so the eSPI controller thinks the transfer is cancelled and doesn't transfer the data again.

the transfer state is passed in via the flags parameter. this way the SPI controller knows when a transfer starts (SPI_XFER_BEGIN) and when it ends (SPI_XFER_END).
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
Url : http://lists.denx.de/pipermail/u-boot/attachments/20090316/bf0c2261/attachment-0001.pgp

#23 lore raw

PATCH 3/7 eSPI: add eSPI controller support

Hi Mike,

First truly sorry for the long time delay.
Please find comments inline.

Quoted 46 lines

-----Original Message-----
From: Mike Frysinger [mailto:vapier at gentoo.org]
Sent: Monday, March 16, 2009 6:06 PM
To: Hu Mingkai-B21284
Cc: u-boot at lists.denx.de; Jean-Christophe PLAGNIOL-VILLARD; Fleming Andy-AFLEMING
Subject: Re: [U-Boot] [PATCH 3/7] eSPI: add eSPI controller support

Quoted 14 lines · On Monday 16 March 2009 04:56:22 Hu Mingkai-B21284 wrote:

From: Mike Frysinger [mailto:vapier at gentoo.org]

Quoted 13 lines · On Monday 16 March 2009 02:15:27 Jean-Christophe wrote:
Quoted 12 lines · Mingkai Hu
Quoted 11 lines

Add eSPI controller support under the SPI framework.

---
 drivers/mtd/spi/spi_flash.c |   94 +++++++++++++++++-
 drivers/spi/Makefile        |    1 +
 drivers/spi/fsl_espi.c      |  232

+++++++++++++++++++++++++++++++++++++++++++ include/spi.h

30 ++++++

 4 files changed, 354 insertions(+), 3 deletions(-)  

create mode

Quoted 6 lines
Quoted 6 lines
Quoted 4 lines
Quoted 1 line

100644 drivers/spi/fsl_espi.c

please use the spi framework, their is no need to touch the spi_flash support ti add and use the fsl_espi

indeed ... i was so happy to see the spansion driver i

glossed over

Quoted 8 lines
Quoted 3 lines

this ...
those spi_flash.c changes are almost assuredly wrong and indicate you arent fitting into the framework correctly.

There is difference between the SPI and eSPI chip select signal. Generally, the SPI chip select is controlled by GPIO, so SW can control when to assert the chip select signal and when to stop the chip select signal.

that is incorrect. the SPI framework does not care how the controller manages the CS. the Blackfin SPI controller for example has dedicated CS's which the controller manages automatically.

Quoted 1 line

But the eSPI controller integrate the chip select into the

controller

Quoted 9 lines
Quoted 1 line

itself, it use the transfer length to control the duration

of the chip

Quoted 1 line

select signal.

so you must tell the controller ahead of time how many bytes are going to be transferred ? this sounds like a retarded hardware implementation to me. how exactly do you support arbitrary transfer lengths ?

IIRC every transaction byte length control every transaction.

Quoted 6 lines
Quoted 1 line

The spi_flash_cmd_* function split the transfer into two

steps: first

Quoted 2 lines

the command transfer and then the data transfer. At the first step, the transfer length is set to the command length, and when

transferred

Quoted 1 line

the command, the chip select will be negated, so the eSPI

Quoted 9 lines

controller

Quoted 1 line

thinks the transfer is cancelled and doesn't transfer the

data again.

the transfer state is passed in via the flags parameter. this way the SPI controller knows when a transfer starts (SPI_XFER_BEGIN) and when it ends (SPI_XFER_END). -mike

As above, we can't use the start/end flags parameter.

Sorry again for the delayed response.

Many thanks,
Mingkai

#24 lore raw

PATCH 3/7 eSPI: add eSPI controller support

Quoted 6 lines · On Wednesday 26 August 2009 23:01:52 Hu Mingkai-B21284 wrote:

From: Mike Frysinger [mailto:vapier at gentoo.org]

Quoted 5 lines · On Monday 16 March 2009 04:56:22 Hu Mingkai-B21284 wrote:
Quoted 3 lines

But the eSPI controller integrate the chip select into the controller itself, it use the transfer length to control the duration of the chip select signal.

Quoted 6 lines
Quoted 4 lines

so you must tell the controller ahead of time how many bytes are going to be transferred ? this sounds like a retarded hardware implementation to me. how exactly do you support arbitrary transfer lengths ?

IIRC every transaction byte length control every transaction.

but what if you dont know the length of the transaction ahead of time ? if you look at the spi flash framework, it'll write a few bytes (like the opcode to read the status register) and then it'll just keep reading 1 byte at a time (polling the status register). there is no way of knowing the length ahead of time. most of the SPI code in u-boot operates this way.

Quoted 11 lines
Quoted 9 lines
Quoted 5 lines

The spi_flash_cmd_* function split the transfer into two steps: first the command transfer and then the data transfer. At the first step, the transfer length is set to the command length, and when transferred the command, the chip select will be negated, so the eSPI controller thinks the transfer is cancelled and doesn't transfer the data again.

the transfer state is passed in via the flags parameter. this way the SPI controller knows when a transfer starts (SPI_XFER_BEGIN) and when it ends (SPI_XFER_END).

As above, we can't use the start/end flags parameter.

then your controller wont be able to work with most (any?) of the code in u- boot. you need to reject every transfer that isnt done with both BEGIN and END flags set.
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
Url : http://lists.denx.de/pipermail/u-boot/attachments/20090827/cbfe3ffe/attachment.pgp

#25 lore raw

PATCH 3/7 eSPI: add eSPI controller support

Quoted 25 lines

-----Original Message-----
From: u-boot-bounces at lists.denx.de [mailto:u-boot-bounces at lists.denx.de] On Behalf Of Mike Frysinger
Sent: Thursday, August 27, 2009 1:54 PM
To: Hu Mingkai-B21284
Cc: u-boot at lists.denx.de; Fleming Andy-AFLEMING
Subject: Re: [U-Boot] [PATCH 3/7] eSPI: add eSPI controller support

Quoted 9 lines · On Wednesday 26 August 2009 23:01:52 Hu Mingkai-B21284 wrote:

From: Mike Frysinger [mailto:vapier at gentoo.org]

Quoted 8 lines · On Monday 16 March 2009 04:56:22 Hu Mingkai-B21284 wrote:
Quoted 3 lines

But the eSPI controller integrate the chip select into the controller itself, it use the transfer length to control the duration of the chip select signal.

so you must tell the controller ahead of time how many bytes are going to be transferred ? this sounds like a retarded hardware implementation to me. how exactly do you support

arbitrary transfer

Quoted 3 lines
Quoted 1 line

lengths ?

IIRC every transaction byte length control every transaction.

Quoted 8 lines

but what if you dont know the length of the transaction ahead of time ? if you look at the spi flash framework, it'll write a few bytes (like the opcode to read the status register) and then it'll just keep reading 1 byte at a time (polling the status register). there is no way of knowing the length ahead of time. most of the SPI code in u-boot operates this way.

So the driver use the length passed by SPI flash read function. If the length is greater than the max value that is limited by the transaction length register's bitfiled, the driver couldn't read anything.
We'll dig into this issue for the furture.

Quoted 13 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

The spi_flash_cmd_* function split the transfer into two steps:
first the command transfer and then the data transfer. At the first step, the transfer length is set to the command

length, and

Quoted 1 line
Quoted 1 line
Quoted 1 line

when transferred the command, the chip select will be

negated, so

Quoted 1 line
Quoted 1 line
Quoted 1 line

the eSPI controller thinks the transfer is cancelled

and doesn't transfer the data again.

Quoted 5 lines
Quoted 4 lines

the transfer state is passed in via the flags parameter. this way the SPI controller knows when a transfer starts (SPI_XFER_BEGIN) and when it ends (SPI_XFER_END).

Quoted 5 lines
Quoted 1 line

As above, we can't use the start/end flags parameter.

then your controller wont be able to work with most (any?) of the code in u- boot. you need to reject every transfer that snt done with both BEGIN and END flags set.

Looks like now.

Quoted 2 lines

-mike

Thanks,
Mingkai

#26 lore raw

PATCH 3/7 eSPI: add eSPI controller support

Quoted 8 lines · On Thursday 27 August 2009 02:27:30 Hu Mingkai-B21284 wrote:
Quoted 7 lines

but what if you dont know the length of the transaction ahead of time ? if you look at the spi flash framework, it'll write a few bytes (like the opcode to read the status register) and then it'll just keep reading 1 byte at a time (polling the status register). there is no way of knowing the length ahead of time. most of the SPI code in u-boot operates this way.

Quoted 4 lines

So the driver use the length passed by SPI flash read function. If the length is greater than the max value that is limited by the transaction length register's bitfiled, the driver couldn't read anything.

the length used by the first read covers just the length of the opcode, not any of the data returned by the part

as long as your driver rejects all of these things, it'll be detected at runtime and it should be fine to merge
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
Url : http://lists.denx.de/pipermail/u-boot/attachments/20090827/2dbfe7ee/attachment.pgp

#27 lore raw

PATCH 3/7 eSPI: add eSPI controller support

Quoted 24 lines

-----Original Message-----
From: Mike Frysinger [mailto:vapier at gentoo.org]
Sent: Thursday, August 27, 2009 2:43 PM
To: Hu Mingkai-B21284
Cc: u-boot at lists.denx.de; Fleming Andy-AFLEMING
Subject: Re: [U-Boot] [PATCH 3/7] eSPI: add eSPI controller support

Quoted 4 lines · On Thursday 27 August 2009 02:27:30 Hu Mingkai-B21284 wrote:
Quoted 4 lines

but what if you dont know the length of the transaction ahead of time ? if you look at the spi flash framework, it'll write a few bytes (like the opcode to read the status
register) and then it'll just keep reading 1 byte at a

time (polling

Quoted 1 line
Quoted 1 line

the status register). there is no way of knowing the

length ahead

Quoted 6 lines
Quoted 1 line

of time. most of the SPI code in u-boot operates this way.

So the driver use the length passed by SPI flash read function. If the length is greater than the max value that is limited by the transaction length register's bitfiled, the driver couldn't read anything.

Quoted 6 lines

the length used by the first read covers just the length of the opcode, not any of the data returned by the part

as long as your driver rejects all of these things, it'll be detected at runtime and it should be fine to merge -mike

So the driver combine the opcode length and the data length together, then pass to spi_xfer(for eSPI) . When return the read results, skip the first opcode length bytes.

Thanks,
Mingkai

#28 lore raw

PATCH 3/7 eSPI: add eSPI controller support

Quoted 17 lines · On Thursday 27 August 2009 02:59:34 Hu Mingkai-B21284 wrote:

From: Mike Frysinger [mailto:vapier at gentoo.org]

Quoted 16 lines · On Thursday 27 August 2009 02:27:30 Hu Mingkai-B21284 wrote:
Quoted 11 lines
Quoted 6 lines

but what if you dont know the length of the transaction ahead of time ? if you look at the spi flash framework, it'll write a few bytes (like the opcode to read the status
register) and then it'll just keep reading 1 byte at a time (polling the status register). there is no way of knowing the length ahead of time. most of the SPI code in u-boot operates this way.

So the driver use the length passed by SPI flash read function. If the length is greater than the max value that is limited by the transaction length register's bitfiled, the driver couldn't read anything.

the length used by the first read covers just the length of the opcode, not any of the data returned by the part

Quoted 6 lines
Quoted 2 lines

as long as your driver rejects all of these things, it'll be detected at runtime and it should be fine to merge -mike

So the driver combine the opcode length and the data length together, then pass to spi_xfer(for eSPI) . When return the read results, skip the first opcode length bytes.

you dont get it ... there is no data length. the code does:

spi_write(~3 bytes for opcode, BEGIN flag);

while (1) {
	spi_read(read 1 data byte);
	check_result();
}

end_spi_transaction();

there is no "data length" which means your controller cannot support the SPI flash framework
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
Url : http://lists.denx.de/pipermail/u-boot/attachments/20090827/bbe109b0/attachment.pgp

#29 lore raw

PATCH 3/7 eSPI: add eSPI controller support

Quoted 43 lines

-----Original Message-----
From: Mike Frysinger [mailto:vapier at gentoo.org]
Sent: Thursday, August 27, 2009 3:23 PM
To: Hu Mingkai-B21284
Cc: u-boot at lists.denx.de; Fleming Andy-AFLEMING
Subject: Re: [U-Boot] [PATCH 3/7] eSPI: add eSPI controller support

Quoted 3 lines · On Thursday 27 August 2009 02:59:34 Hu Mingkai-B21284 wrote:

From: Mike Frysinger [mailto:vapier at gentoo.org]

Quoted 2 lines · On Thursday 27 August 2009 02:27:30 Hu Mingkai-B21284 wrote:
Quoted 1 line
Quoted 1 line

but what if you dont know the length of the

transaction ahead of

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

time ? if you look at the spi flash framework, it'll write a few bytes (like the opcode to read the status register) and then it'll just keep reading 1 byte at a time (polling the status register). there is no way of

knowing the

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

length ahead of time. most of the SPI code in u-boot

operates this way.

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

So the driver use the length passed by SPI flash read function. If the length is greater than the max value that is

limited by the

Quoted 1 line
Quoted 1 line
Quoted 1 line

transaction length register's bitfiled, the driver

couldn't read

Quoted 9 lines
Quoted 7 lines
Quoted 1 line

anything.

the length used by the first read covers just the length of the opcode, not any of the data returned by the part

as long as your driver rejects all of these things, it'll be detected at runtime and it should be fine to merge -mike

So the driver combine the opcode length and the data length

together,

Quoted 1 line

then pass to spi_xfer(for eSPI) . When return the read

results, skip

Quoted 1 line

the first opcode length bytes.

you dont get it ... there is no data length. the code does:

Quoted 9 lines

spi_write(~3 bytes for opcode, BEGIN flag); while (1) {

	spi_read(read 1 data byte);
	check_result();
}

end_spi_transaction();

there is no "data length" which means your controller cannot support the SPI flash framework -mike

Sorry for the confusion, "the dirver" in my word refers to this patch that adds eSPI controller support. You're right, the controller can't support the SPI framework, that's the reason why this patch comes here. :-)

Thanks,
Mingkai

#30 lore raw

PATCH 3/7 eSPI: add eSPI controller support

In reply to Mingkai Hu

drivers/mtd/spi/spi_flash.c line 7

Quoted 12 lines
drivers/mtd/spi/spi_flash.c +2 -0
index d1d81af..fa97896 100644
@@ -1,6 +1,8 @@
 /*
  * SPI flash interface
+ * Add support for Freescale eSPI controller
  *
+ * Copyright (C) 2009 Freescale Semiconductor, Inc.
  * Copyright (C) 2008 Atmel Corporation
  */

Ummm ... call me crazy ... but this doesn't seem proper to me.

--Scott

#31 lore raw

PATCH 2/7 mtd: SPI Flash: Support the Spansion Flash

In reply to Mingkai Hu
Quoted 2 lines · On Sunday 15 March 2009 22:52:18 Mingkai Hu wrote:

Add MTD SPI Flash support for S25FL008A, S25FL016A, S25FL032A, S25FL064A, S25FL128P.

this doesnt really need to be part of this patch series and can be added all by itself

drivers/mtd/spi/Makefile LIB := $(obj)libspi_flash.a · line 31

Quoted 7 lines
drivers/mtd/spi/Makefile +1 -0
@@ -28,6 +28,7 @@ LIB	:= $(obj)libspi_flash.a
 COBJS-$(CONFIG_SPI_FLASH)	+= spi_flash.o
 COBJS-$(CONFIG_SPI_FLASH_ATMEL)	+= atmel.o
 COBJS-$(CONFIG_SPI_FLASH_STMICRO)	+= stmicro.o
+COBJS-$(CONFIG_SPI_FLASH_SPANSION)     += spansion.o

this should be above stmicro -- keep it sorted

also, the += is supposed to be indented with a tab, not spaces
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
Url : http://lists.denx.de/pipermail/u-boot/attachments/20090316/777189a9/attachment.pgp

#32 lore raw

PATCH 2/7 mtd: SPI Flash: Support the Spansion Flash

Quoted 27 lines

-----Original Message-----
From: Mike Frysinger [mailto:vapier at gentoo.org]
Sent: Monday, March 16, 2009 12:38 PM
To: u-boot at lists.denx.de
Cc: Hu Mingkai-B21284; Fleming Andy-AFLEMING
Subject: Re: [U-Boot] [PATCH 2/7] mtd: SPI Flash: Support the Spansion Flash

Quoted 2 lines · On Sunday 15 March 2009 22:52:18 Mingkai Hu wrote:

Add MTD SPI Flash support for S25FL008A, S25FL016A, S25FL032A, S25FL064A, S25FL128P.

this doesnt really need to be part of this patch series and can be added all by itself

drivers/mtd/spi/Makefile LIB := $(obj)libspi_flash.a · line 31

Quoted 7 lines
drivers/mtd/spi/Makefile +1 -0
@@ -28,6 +28,7 @@ LIB	:= $(obj)libspi_flash.a
 COBJS-$(CONFIG_SPI_FLASH)	+= spi_flash.o
 COBJS-$(CONFIG_SPI_FLASH_ATMEL)	+= atmel.o
 COBJS-$(CONFIG_SPI_FLASH_STMICRO)	+= stmicro.o
+COBJS-$(CONFIG_SPI_FLASH_SPANSION)     += spansion.o

this should be above stmicro -- keep it sorted

Quoted 2 lines

also, the += is supposed to be indented with a tab, not spaces -mike

Thanks, I'll fix it.

Best Regards,
Mingkai

#33 lore raw

PATCH 2/7 mtd: SPI Flash: Support the Spansion Flash

Quoted 18 lines · On Monday 16 March 2009 02:23:50 Hu Mingkai-B21284 wrote:

From: Mike Frysinger [mailto:vapier at gentoo.org]

Quoted 17 lines · On Sunday 15 March 2009 22:52:18 Mingkai Hu wrote:
Quoted 2 lines

Add MTD SPI Flash support for S25FL008A, S25FL016A, S25FL032A, S25FL064A, S25FL128P.

this doesnt really need to be part of this patch series and can be added all by itself

drivers/mtd/spi/Makefile LIB := $(obj)libspi_flash.a · line 31

Quoted 7 lines
drivers/mtd/spi/Makefile +1 -0
@@ -28,6 +28,7 @@ LIB	:= $(obj)libspi_flash.a
 COBJS-$(CONFIG_SPI_FLASH)	+= spi_flash.o
 COBJS-$(CONFIG_SPI_FLASH_ATMEL)	+= atmel.o
 COBJS-$(CONFIG_SPI_FLASH_STMICRO)	+= stmicro.o
+COBJS-$(CONFIG_SPI_FLASH_SPANSION)     += spansion.o

this should be above stmicro -- keep it sorted

Quoted 3 lines
Quoted 1 line

also, the += is supposed to be indented with a tab, not spaces -mike

Thanks, I'll fix it.

can you post an updated spansion flash driver ? it can be merged independently of the eSPI patch series and it'd be good to get it merged sooner so i can push the sf patches without conflicts ...
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
Url : http://lists.denx.de/pipermail/u-boot/attachments/20090329/3dfabca6/attachment.pgp

#34 lore raw

PATCH 2/7 mtd: SPI Flash: Support the Spansion Flash

In reply to Mingkai Hu

drivers/mtd/spi/spansion.c line 293

Quoted 4 lines · On Sunday 15 March 2009 22:52:18 Mingkai Hu wrote:
drivers/mtd/spi/spansion.c new file +4 -0
+int spansion_erase(struct spi_flash *flash, u32 offset, size_t len)
+{
+...
+		ret = spansion_wait_ready(flash, 2 * CONFIG_SYS_HZ);

there is a common define you should use instead: SPI_FLASH_PAGE_ERASE_TIMEOUT -mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
Url : http://lists.denx.de/pipermail/u-boot/attachments/20090330/541e4f5f/attachment.pgp

#35 lore raw

PATCH 2/7 mtd: SPI Flash: Support the Spansion Flash

Quoted 10 lines

-----Original Message-----
From: Mike Frysinger [mailto:vapier at gentoo.org]
Sent: Tuesday, March 31, 2009 9:12 AM
To: u-boot at lists.denx.de
Cc: Hu Mingkai-B21284; Fleming Andy-AFLEMING
Subject: Re: [U-Boot] [PATCH 2/7] mtd: SPI Flash: Support the Spansion Flash

Quoted 9 lines
Quoted 1 line · On Sunday 15 March 2009 22:52:18 Mingkai Hu wrote:

+int spansion_erase(struct spi_flash *flash, u32 offset,

size_t len) {

drivers/mtd/spi/spansion.c line 293

Quoted 2 lines

+...

drivers/mtd/spi/spansion.c new file +1 -0
+		ret = spansion_wait_ready(flash, 2 * CONFIG_SYS_HZ);

there is a common define you should use instead:
SPI_FLASH_PAGE_ERASE_TIMEOUT -mike

Thanks, Mike, I'll fix it.

Best Regards,
Mingkai