Skip to contentSkip to conversation

cm4008: use common cfi_flash support

PATCH New Yann Vernier 5 participants 54 messages Jul 5, 2012 – Dec 1, 2012

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 3/3 cm4008: use common cfi_flash support

This change allows use of other flash chips than the two supported by the cm4008 flash.c. Tested with Micrel KSZ8695X demo board.

---
 board/cm4008/Makefile    |    2 +-
 include/configs/cm4008.h |    4 ++++
 2 files changed, 5 insertions(+), 1 deletion(-)
board/cm4008/Makefile +1 -1
index 5b98824..22fd74e 100644
@@ -25,7 +25,7 @@ include $(TOPDIR)/config.mk
 
 LIB	= $(obj)lib$(BOARD).o
 
-COBJS	:= cm4008.o flash.o
+COBJS	:= cm4008.o # flash.o
 
 SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
 OBJS	:= $(addprefix $(obj),$(COBJS))
include/configs/cm4008.h +4 -0
index 7c2e113..6d1a1ae 100644
@@ -125,6 +125,10 @@
 #define PHYS_FLASH_SECT_SIZE    0x00020000 /* 128 KB sectors (x1) */
 #define CONFIG_SYS_FLASH_BASE		PHYS_FLASH_1
 
+#define	CONFIG_SYS_FLASH_CFI
+#define	CONFIG_FLASH_CFI_DRIVER		1
+#define	CONFIG_SYS_FLASH_CFI_WIDTH	FLASH_CFI_8BIT
+
 /*-----------------------------------------------------------------------
  * FLASH and environment organization
  */
Signature · 1 line
1.7.10
#1 lore raw

PATCH 3/3 cm4008: use common cfi_flash support

Dear Yann Vernier,

Quoted 14 lines · Yann Vernier

This change allows use of other flash chips than the two supported by the cm4008 flash.c. Tested with Micrel KSZ8695X demo board.

---
 board/cm4008/Makefile    |    2 +-
 include/configs/cm4008.h |    4 ++++
 2 files changed, 5 insertions(+), 1 deletion(-)
board/cm4008/Makefile +0 -0
index 5b98824..22fd74e 100644

board/cm4008/Makefile include $(TOPDIR)/config.mk · line 28

Quoted 5 lines
board/cm4008/Makefile +1 -1
@@ -25,7 +25,7 @@ include $(TOPDIR)/config.mk
 
 LIB	= $(obj)lib$(BOARD).o
 
-COBJS	:= cm4008.o flash.o
+COBJS	:= cm4008.o # flash.o

please do not comment but remove that entry. Also remove that flash.c cause it is not longer necessary if you can use cfi flash implementation.

Quoted 9 lines
board/cm4008/Makefile +0 -0
 SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
 OBJS	:= $(addprefix $(obj),$(COBJS))
include/configs/cm4008.h +0 -0
index 7c2e113..6d1a1ae 100644

include/configs/cm4008.h line 134

Quoted 10 lines
include/configs/cm4008.h +4 -0
@@ -125,6 +125,10 @@
 #define PHYS_FLASH_SECT_SIZE    0x00020000 /* 128 KB sectors (x1) */
 #define CONFIG_SYS_FLASH_BASE		PHYS_FLASH_1
 
+#define	CONFIG_SYS_FLASH_CFI
+#define	CONFIG_FLASH_CFI_DRIVER		1
+#define	CONFIG_SYS_FLASH_CFI_WIDTH	FLASH_CFI_8BIT
+
 /*-----------------------------------------------------------------------
  * FLASH and environment organization
  */

Best regards

Andreas Bie?mann

#2 lore raw

PATCH v2 1/1 arm: cm4008, cm41xx: use common cfi_flash support

This change allows use of other flash chips than the two supported by the cm4008 flash.c. Tested with Micrel KSZ8695X demo board.
---
Changes for v2:
- Update cm41xx also
- Remove unused board specific flash code

---
 board/cm4008/Makefile    |    2 +-
 board/cm4008/flash.c     |  410 ----------------------------------------------
 board/cm41xx/Makefile    |    2 +-
 board/cm41xx/flash.c     |  410 ----------------------------------------------
 include/configs/cm4008.h |    4 +
 include/configs/cm41xx.h |    4 +
 6 files changed, 10 insertions(+), 822 deletions(-)
 delete mode 100644 board/cm4008/flash.c
 delete mode 100644 board/cm41xx/flash.c
board/cm4008/Makefile +1 -1
index 5b98824..dac422b 100644
@@ -25,7 +25,7 @@ include $(TOPDIR)/config.mk
 
 LIB	= $(obj)lib$(BOARD).o
 
-COBJS	:= cm4008.o flash.o
+COBJS	:= cm4008.o
 
 SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
 OBJS	:= $(addprefix $(obj),$(COBJS))
board/cm4008/flash.c deleted +0 -410

410 lines not on this page · raw message

board/cm41xx/Makefile +1 -1
index 6214f8c..d49fce1 100644
@@ -25,7 +25,7 @@ include $(TOPDIR)/config.mk
 
 LIB	= $(obj)lib$(BOARD).o
 
-COBJS	:= cm41xx.o flash.o
+COBJS	:= cm41xx.o
 
 SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
 OBJS	:= $(addprefix $(obj),$(COBJS))
board/cm41xx/flash.c deleted +0 -410

410 lines not on this page · raw message

include/configs/cm4008.h +4 -0
index 58b0f4b..18b37d7 100644
@@ -119,6 +119,10 @@
 #define PHYS_FLASH_SECT_SIZE    0x00020000 /* 128 KB sectors (x1) */
 #define CONFIG_SYS_FLASH_BASE		PHYS_FLASH_1
 
+#define CONFIG_SYS_FLASH_CFI
+#define CONFIG_FLASH_CFI_DRIVER		1
+#define CONFIG_SYS_FLASH_CFI_WIDTH	FLASH_CFI_8BIT
+
 /*-----------------------------------------------------------------------
  * FLASH and environment organization
  */
include/configs/cm41xx.h +4 -0
index d29040c..3f46b12 100644
@@ -119,6 +119,10 @@
 #define PHYS_FLASH_SECT_SIZE    0x00020000 /* 128 KB sectors (x1) */
 #define CONFIG_SYS_FLASH_BASE		PHYS_FLASH_1
 
+#define CONFIG_SYS_FLASH_CFI
+#define CONFIG_FLASH_CFI_DRIVER		1
+#define CONFIG_SYS_FLASH_CFI_WIDTH	FLASH_CFI_8BIT
+
 /*-----------------------------------------------------------------------
  * FLASH and environment organization
  */
Signature · 1 line
1.7.10
#3 lore raw

PATCH v2 1/1 arm: cm4008, cm41xx: use common cfi_flash support

Dear Yann Vernier,

a simple small change request.

Quoted 19 lines · Yann Vernier

This change allows use of other flash chips than the two supported by the cm4008 flash.c. Tested with Micrel KSZ8695X demo board.
---
Changes for v2:
- Update cm41xx also
- Remove unused board specific flash code

---
 board/cm4008/Makefile    |    2 +-
 board/cm4008/flash.c     |  410 ----------------------------------------------
 board/cm41xx/Makefile    |    2 +-
 board/cm41xx/flash.c     |  410 ----------------------------------------------
 include/configs/cm4008.h |    4 +
 include/configs/cm41xx.h |    4 +
 6 files changed, 10 insertions(+), 822 deletions(-)
 delete mode 100644 board/cm4008/flash.c
 delete mode 100644 board/cm41xx/flash.c

<snip>

include/configs/cm4008.h line 123

Quoted 10 lines
include/configs/cm4008.h +2 -0
index 58b0f4b..18b37d7 100644
@@ -119,6 +119,10 @@
 #define PHYS_FLASH_SECT_SIZE    0x00020000 /* 128 KB sectors (x1) */
 #define CONFIG_SYS_FLASH_BASE		PHYS_FLASH_1
 
+#define CONFIG_SYS_FLASH_CFI
+#define CONFIG_FLASH_CFI_DRIVER		1

Do not define to 1 where it is not required, just define.

Quoted 10 lines
include/configs/cm4008.h +2 -0
+#define CONFIG_SYS_FLASH_CFI_WIDTH	FLASH_CFI_8BIT
+
 /*-----------------------------------------------------------------------
  * FLASH and environment organization
  */
include/configs/cm41xx.h +0 -0
index d29040c..3f46b12 100644

include/configs/cm41xx.h line 123

Quoted 5 lines
include/configs/cm41xx.h +2 -0
@@ -119,6 +119,10 @@
 #define PHYS_FLASH_SECT_SIZE    0x00020000 /* 128 KB sectors (x1) */
 #define CONFIG_SYS_FLASH_BASE		PHYS_FLASH_1
 
+#define CONFIG_SYS_FLASH_CFI
+#define CONFIG_FLASH_CFI_DRIVER		1

same here

include/configs/cm41xx.h line 128

Quoted 6 lines
include/configs/cm41xx.h +2 -0
+#define CONFIG_SYS_FLASH_CFI_WIDTH	FLASH_CFI_8BIT
+
 /*-----------------------------------------------------------------------
  * FLASH and environment organization
  */

Best regards

Andreas Bie?mann

#4 lore raw

PATCH v3 1/1 arm: cm4008, cm41xx: use common cfi_flash support

This change allows use of other flash chips than the two supported by the cm4008 flash.c. Tested with Micrel KSZ8695X demo board.
---
Changes for v2:
- Update cm41xx also
- Remove unused board specific flash code
Changes for v3:
- Do not define to 1 where it is not required, just define

---
 board/cm4008/Makefile    |    2 +-
 board/cm4008/flash.c     |  410 ----------------------------------------------
 board/cm41xx/Makefile    |    2 +-
 board/cm41xx/flash.c     |  410 ----------------------------------------------
 include/configs/cm4008.h |    4 +
 include/configs/cm41xx.h |    4 +
 6 files changed, 10 insertions(+), 822 deletions(-)
 delete mode 100644 board/cm4008/flash.c
 delete mode 100644 board/cm41xx/flash.c
board/cm4008/Makefile +1 -1
index 5b98824..dac422b 100644
@@ -25,7 +25,7 @@ include $(TOPDIR)/config.mk
 
 LIB	= $(obj)lib$(BOARD).o
 
-COBJS	:= cm4008.o flash.o
+COBJS	:= cm4008.o
 
 SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
 OBJS	:= $(addprefix $(obj),$(COBJS))
board/cm4008/flash.c deleted +0 -410

410 lines not on this page · raw message

board/cm41xx/Makefile +1 -1
index 6214f8c..d49fce1 100644
@@ -25,7 +25,7 @@ include $(TOPDIR)/config.mk
 
 LIB	= $(obj)lib$(BOARD).o
 
-COBJS	:= cm41xx.o flash.o
+COBJS	:= cm41xx.o
 
 SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
 OBJS	:= $(addprefix $(obj),$(COBJS))
board/cm41xx/flash.c deleted +0 -410

410 lines not on this page · raw message

include/configs/cm4008.h +4 -0
index 58b0f4b..b0806cc 100644
@@ -119,6 +119,10 @@
 #define PHYS_FLASH_SECT_SIZE    0x00020000 /* 128 KB sectors (x1) */
 #define CONFIG_SYS_FLASH_BASE		PHYS_FLASH_1
 
+#define CONFIG_SYS_FLASH_CFI
+#define CONFIG_FLASH_CFI_DRIVER
+#define CONFIG_SYS_FLASH_CFI_WIDTH	FLASH_CFI_8BIT
+
 /*-----------------------------------------------------------------------
  * FLASH and environment organization
  */
include/configs/cm41xx.h +4 -0
index d29040c..ea9165a 100644
@@ -119,6 +119,10 @@
 #define PHYS_FLASH_SECT_SIZE    0x00020000 /* 128 KB sectors (x1) */
 #define CONFIG_SYS_FLASH_BASE		PHYS_FLASH_1
 
+#define CONFIG_SYS_FLASH_CFI
+#define CONFIG_FLASH_CFI_DRIVER
+#define CONFIG_SYS_FLASH_CFI_WIDTH	FLASH_CFI_8BIT
+
 /*-----------------------------------------------------------------------
  * FLASH and environment organization
  */
Signature · 1 line
1.7.10
#5 lore raw

PATCH v3 1/1 arm: cm4008, cm41xx: use common cfi_flash support

Quoted 10 lines · Yann Vernier

This change allows use of other flash chips than the two supported by the cm4008 flash.c. Tested with Micrel KSZ8695X demo board.
---
Changes for v2:
- Update cm41xx also
- Remove unused board specific flash code
Changes for v3:
- Do not define to 1 where it is not required, just define

(although I do not know who will pick it ...)

Quoted 10 lines
---
 board/cm4008/Makefile    |    2 +-
 board/cm4008/flash.c     |  410 ----------------------------------------------
 board/cm41xx/Makefile    |    2 +-
 board/cm41xx/flash.c     |  410 ----------------------------------------------
 include/configs/cm4008.h |    4 +
 include/configs/cm41xx.h |    4 +
 6 files changed, 10 insertions(+), 822 deletions(-)
 delete mode 100644 board/cm4008/flash.c
 delete mode 100644 board/cm41xx/flash.c
#6 lore raw

PATCH v3 1/1 arm: cm4008, cm41xx: use common cfi_flash support

Hi Andreas,

Quoted 10 lines · Andreas Bie?mann
Quoted 9 lines · Yann Vernier

This change allows use of other flash chips than the two supported by the cm4008 flash.c. Tested with Micrel KSZ8695X demo board.
---
Changes for v2:
- Update cm41xx also
- Remove unused board specific flash code
Changes for v3:
- Do not define to 1 where it is not required, just define

Quoted 5 lines
Quoted 1 line

(although I do not know who will pick it ...)

Always a problem, those board config patches... :)

I'll take this one in u-boot-arm/next, but later this week-end. if by Monday I haven't sent an 'applied' mail, ping me.

Amicalement,

Signature · 1 line
Albert.
#7 lore raw

cover ks8695 (cm4008, cm41xx) bugfixes, constant removals, configuration generalized

Quoted 4 lines · On Fri, 6 Jul 2012 13:33:42 +0200 Albert ARIBAUD <[email protected]>…

Always a problem, those board config patches... :)

I'll take this one in u-boot-arm/next, but later this week-end. if by Monday I haven't sent an 'applied' mail, ping me.

I haven't seen an applied mail, nor a commit in the git, so I figure this is still not merged. I've since made an attempt at cleaning up the magic constants. Since this is fairly intrusive I have a much larger patch affecting the same sections. I've attempted to split it up, though some combinations of these patches will likely not be very useful.

Yann Vernier (11):
arm: ks8695: use defined constants for UART
arm: ks8695: more macros for register values
arm: ks8695eth: Use MAC address from environment
arm: cm4008, cm41xx: use common cfi_flash support
arm: cm4008, cm41xx: set gd->ram_size in dram_init
arm: cm4008, cm41xx: Fix ROM relocation
arm: ks8695/cm4008/cm41xx: Parameterize SDRAM
arm: cm4008, cm41xx: don't define to 1
arm: ks8695/cm4xxx: don't reconfigure switch
arm: ks8695: document bus speed
arm: cm4008, cm41xx: read MAC address from flash

 arch/arm/cpu/arm920t/ks8695/lowlevel_init.S  |   95 +++---
 arch/arm/include/asm/arch-ks8695/platform.h  |   55 ++--
 arch/arm/include/asm/arch-ks8695/regvalues.h |  112 +++++++
 board/cm4008/Makefile                        |    2 +-
 board/cm4008/cm4008.c                        |   17 +-
 board/cm4008/config.mk                       |    1 -
 board/cm4008/flash.c                         |  410
 --------------------------
 board/cm41xx/Makefile                        |    2 +-
 board/cm41xx/cm41xx.c                        |   17 +-
 board/cm41xx/config.mk                       |    1 -
 board/cm41xx/flash.c                         |  410
 --------------------------
 drivers/net/ks8695eth.c                      |   38 +--
 include/configs/cm4008.h                     |   38 ++-

include/configs/cm41xx.h | 32 +- 14 files
changed, 305 insertions(+), 925 deletions(-) create mode 100644 arch/arm/include/asm/arch-ks8695/regvalues.h delete mode 100644 board/cm4008/config.mk delete mode 100644 board/cm4008/flash.c delete mode 100644 board/cm41xx/config.mk delete mode 100644 board/cm41xx/flash.c

Signature · 1 line
1.7.10.4
#8 lore raw

cover ks8695 (cm4008, cm41xx) bugfixes, constant removals, configuration generalized

Hi Yann,

Quoted 42 lines · Yann Vernier
Quoted 4 lines · On Fri, 6 Jul 2012 13:33:42 +0200 Albert ARIBAUD <[email protected]>…

Always a problem, those board config patches... :)

I'll take this one in u-boot-arm/next, but later this week-end. if by Monday I haven't sent an 'applied' mail, ping me.

I haven't seen an applied mail, nor a commit in the git, so I figure this is still not merged. I've since made an attempt at cleaning up the magic constants. Since this is fairly intrusive I have a much larger patch affecting the same sections. I've attempted to split it up, though some combinations of these patches will likely not be very useful.

Yann Vernier (11):
arm: ks8695: use defined constants for UART
arm: ks8695: more macros for register values
arm: ks8695eth: Use MAC address from environment
arm: cm4008, cm41xx: use common cfi_flash support
arm: cm4008, cm41xx: set gd->ram_size in dram_init
arm: cm4008, cm41xx: Fix ROM relocation
arm: ks8695/cm4008/cm41xx: Parameterize SDRAM
arm: cm4008, cm41xx: don't define to 1
arm: ks8695/cm4xxx: don't reconfigure switch
arm: ks8695: document bus speed
arm: cm4008, cm41xx: read MAC address from flash

 arch/arm/cpu/arm920t/ks8695/lowlevel_init.S  |   95 +++---
 arch/arm/include/asm/arch-ks8695/platform.h  |   55 ++--
 arch/arm/include/asm/arch-ks8695/regvalues.h |  112 +++++++
 board/cm4008/Makefile                        |    2 +-
 board/cm4008/cm4008.c                        |   17 +-
 board/cm4008/config.mk                       |    1 -
 board/cm4008/flash.c                         |  410
 --------------------------
 board/cm41xx/Makefile                        |    2 +-
 board/cm41xx/cm41xx.c                        |   17 +-
 board/cm41xx/config.mk                       |    1 -
 board/cm41xx/flash.c                         |  410
 --------------------------
 drivers/net/ks8695eth.c                      |   38 +--
 include/configs/cm4008.h                     |   38 ++-
Quoted 7 lines

include/configs/cm41xx.h | 32 +- 14 files
changed, 305 insertions(+), 925 deletions(-) create mode 100644 arch/arm/include/asm/arch-ks8695/regvalues.h delete mode 100644 board/cm4008/config.mk delete mode 100644 board/cm4008/flash.c delete mode 100644 board/cm41xx/config.mk delete mode 100644 board/cm41xx/flash.c

Sorry it took me so long to crawl my backlog... This series was posted with long lines folded apparently, which makes it impossible to process and explains why patchwork did not have all of it. Can you please repost it, this time using 'git send-email'?

Amicalement,

Signature · 1 line
Albert.
#9 lore raw

cover ks8695 (cm4008, cm41xx) bugfixes, constant removals, configuration generalized (repost)

Quoted 4 lines · On Thu, 4 Oct 2012 11:15:06 +0200 Albert ARIBAUD <[email protected]>…

Sorry it took me so long to crawl my backlog... This series was posted with long lines folded apparently, which makes it impossible to process and explains why patchwork did not have all of it. Can you please repost it, this time using 'git send-email'?

Terribly sorry. This should fix that problem.
In the meantime, work on our board progresses nicely, and we plan to submit it after registering a machine ID. We have u-boot support for PCI, FPGA configuration, and I2C for power control working, the latter two via GPIO.

Yann Vernier (11):
arm: ks8695: use defined constants for UART
arm: ks8695: more macros for register values
arm: ks8695eth: Use MAC address from environment
arm: cm4008, cm41xx: use common cfi_flash support
arm: cm4008, cm41xx: set gd->ram_size in dram_init
arm: cm4008, cm41xx: Fix ROM relocation
arm: ks8695/cm4008/cm41xx: Parameterize SDRAM
arm: cm4008, cm41xx: don't define to 1
arm: ks8695/cm4xxx: don't reconfigure switch
arm: ks8695: document bus speed
arm: cm4008, cm41xx: read MAC address from flash

 arch/arm/cpu/arm920t/ks8695/lowlevel_init.S  |   95 +++---
 arch/arm/include/asm/arch-ks8695/platform.h  |   55 ++--
 arch/arm/include/asm/arch-ks8695/regvalues.h |  112 +++++++
 board/cm4008/Makefile                        |    2 +-
 board/cm4008/cm4008.c                        |   17 +-
 board/cm4008/config.mk                       |    1 -
 board/cm4008/flash.c                         |  410 --------------------------
 board/cm41xx/Makefile                        |    2 +-
 board/cm41xx/cm41xx.c                        |   17 +-
 board/cm41xx/config.mk                       |    1 -
 board/cm41xx/flash.c                         |  410 --------------------------
 drivers/net/ks8695eth.c                      |   38 +--
 include/configs/cm4008.h                     |   38 ++-
 include/configs/cm41xx.h                     |   32 +-
 14 files changed, 305 insertions(+), 925 deletions(-)
 create mode 100644 arch/arm/include/asm/arch-ks8695/regvalues.h
 delete mode 100644 board/cm4008/config.mk
 delete mode 100644 board/cm4008/flash.c
 delete mode 100644 board/cm41xx/config.mk
 delete mode 100644 board/cm41xx/flash.c
Signature · 1 line
1.7.10.4
#10 lore raw

PATCH 1/11 arm: ks8695: use defined constants for UART

CONFIG_BAUDRATE and KS8695_UART_LINEC_WLEN8 used for UART registers

---
 arch/arm/cpu/arm920t/ks8695/lowlevel_init.S |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
arch/arm/cpu/arm920t/ks8695/lowlevel_init.S +3 -3
index e9f1227..1bba571 100644
@@ -72,10 +72,10 @@ lowlevel_init:
 	 * enable UART for early debug trace
 	 */
 	ldr	r1, =(KS8695_IO_BASE+KS8695_UART_DIVISOR)
-	mov	r2, #0xd9
-	str	r2, [r1]		/* 115200 baud */
+	mov	r2, #((25000000+CONFIG_BAUDRATE/2) / CONFIG_BAUDRATE)
+	str	r2, [r1]
 	ldr	r1, =(KS8695_IO_BASE+KS8695_UART_LINE_CTRL)
-	mov	r2, #0x03
+	mov	r2, #KS8695_UART_LINEC_WLEN8
 	str	r2, [r1]		/* 8 data bits, no parity, 1 stop */
 	ldr	r1, =(KS8695_IO_BASE+KS8695_UART_TX_HOLDING)
 	mov	r2, #0x41
Signature · 1 line
1.7.10.4
#11 lore raw

PATCH 1/11 arm: ks8695: use defined constants for UART

Hi Yann,

Quoted 13 lines · Yann Vernier

CONFIG_BAUDRATE and KS8695_UART_LINEC_WLEN8 used for UART registers

---
 arch/arm/cpu/arm920t/ks8695/lowlevel_init.S |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
arch/arm/cpu/arm920t/ks8695/lowlevel_init.S +0 -0
index e9f1227..1bba571 100644
@@ -72,10 +72,10 @@ lowlevel_init:
 	 * enable UART for early debug trace
 	 */
 	ldr	r1, =(KS8695_IO_BASE+KS8695_UART_DIVISOR)

arch/arm/cpu/arm920t/ks8695/lowlevel_init.S lowlevel_init: · line 81

Quoted 10 lines
arch/arm/cpu/arm920t/ks8695/lowlevel_init.S +3 -3
-	mov	r2, #0xd9
-	str	r2, [r1]		/* 115200 baud */
+	mov	r2, #((25000000+CONFIG_BAUDRATE/2) / CONFIG_BAUDRATE)
+	str	r2, [r1]
 	ldr	r1, =(KS8695_IO_BASE+KS8695_UART_LINE_CTRL)
-	mov	r2, #0x03
+	mov	r2, #KS8695_UART_LINEC_WLEN8
 	str	r2, [r1]		/* 8 data bits, no parity, 1 stop */
 	ldr	r1, =(KS8695_IO_BASE+KS8695_UART_TX_HOLDING)
 	mov	r2, #0x41

Applied to u-boot-arm/master, thanks!

Amicalement,

Signature · 1 line
Albert.
#12 lore raw

PATCH 2/11 arm: ks8695: more macros for register values

In reply to Yann Vernier

Adding macros for more configurable lowlevel_init code. Also cleanup of some typos.

---
 arch/arm/include/asm/arch-ks8695/platform.h  |   55 ++++++++-----
 arch/arm/include/asm/arch-ks8695/regvalues.h |  112 ++++++++++++++++++++++++++
 2 files changed, 149 insertions(+), 18 deletions(-)
arch/arm/include/asm/arch-ks8695/platform.h +37 -18
index de20015..0ed0ecb 100644
@@ -13,8 +13,8 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307	 USA
  */
-#ifndef __address_h
-#define __address_h			1
+#ifndef __ASM_ARM_ARCH_PLATFORM_H__
+#define __ASM_ARM_ARCH_PLATFORM_H__
 
 #define KS8695_SDRAM_START	    0x00000000
 #define KS8695_SDRAM_SIZE	    0x01000000
@@ -27,19 +27,19 @@
 #define KS8695_IO_BASE		    0x03FF0000
 #define KS8695_IO_SIZE		    0x00010000
 
-#define KS8695_SYSTEN_CONFIG	    0x00
-#define KS8695_SYSTEN_BUS_CLOCK	    0x04
+#define KS8695_SYSTEM_CONFIG	    0x00
+#define KS8695_SYSTEM_BUS_CLOCK	    0x04
 
 #define KS8695_FLASH_START	    0x02800000
 #define KS8695_FLASH_SIZE	    0x00400000
 
-/*i/o control registers offset difinitions*/
+/*i/o control register offset definitions*/
 #define KS8695_IO_CTRL0		    0x4000
 #define KS8695_IO_CTRL1		    0x4004
 #define KS8695_IO_CTRL2		    0x4008
 #define KS8695_IO_CTRL3		    0x400C
 
-/*memory control registers offset difinitions*/
+/*memory control register offset definitions*/
 #define KS8695_MEM_CTRL0	    0x4010
 #define KS8695_MEM_CTRL1	    0x4014
 #define KS8695_MEM_CTRL2	    0x4018
@@ -51,7 +51,7 @@
 #define KS8695_SDRAM_BUFFER	    0x403C
 #define KS8695_SDRAM_REFRESH	    0x4040
 
-/*WAN control registers offset difinitions*/
+/*WAN control register offset definitions*/
 #define KS8695_WAN_DMA_TX	    0x6000
 #define KS8695_WAN_DMA_RX	    0x6004
 #define KS8695_WAN_DMA_TX_START	    0x6008
@@ -63,7 +63,7 @@
 #define KS8695_WAN_MAC_ELOW	    0x6080
 #define KS8695_WAN_MAC_EHIGH	    0x6084
 
-/*LAN control registers offset difinitions*/
+/*LAN control register offset definitions*/
 #define KS8695_LAN_DMA_TX	    0x8000
 #define KS8695_LAN_DMA_RX	    0x8004
 #define KS8695_LAN_DMA_TX_START	    0x8008
@@ -75,7 +75,7 @@
 #define KS8695_LAN_MAC_ELOW	    0X8080
 #define KS8695_LAN_MAC_EHIGH	    0X8084
 
-/*HPNA control registers offset difinitions*/
+/*HPNA control register offset definitions*/
 #define KS8695_HPNA_DMA_TX	    0xA000
 #define KS8695_HPNA_DMA_RX	    0xA004
 #define KS8695_HPNA_DMA_TX_START    0xA008
@@ -87,7 +87,7 @@
 #define KS8695_HPNA_MAC_ELOW	    0xA080
 #define KS8695_HPNA_MAC_EHIGH	    0xA084
 
-/*UART control registers offset difinitions*/
+/*UART control register offset definitions*/
 #define KS8695_UART_RX_BUFFER	    0xE000
 #define KS8695_UART_TX_HOLDING	    0xE004
 
@@ -133,7 +133,7 @@
 #define KS8695_UART_DIVISOR	    0xE01C
 #define KS8695_UART_STATUS	    0xE020
 
-/*Interrupt controlller registers offset difinitions*/
+/*Interrupt controller register offset definitions*/
 #define KS8695_INT_CONTL	    0xE200
 #define KS8695_INT_ENABLE	    0xE204
 #define KS8695_INT_ENABLE_MODEM	    0x0800
@@ -154,19 +154,19 @@
 #define KS8695_FIQ_PEND_PRIORITY    0xE230
 #define KS8695_IRQ_PEND_PRIORITY    0xE234
 
-/*timer registers offset difinitions*/
+/*timer register offset definitions*/
 #define KS8695_TIMER_CTRL	    0xE400
 #define KS8695_TIMER1		    0xE404
 #define KS8695_TIMER0		    0xE408
 #define KS8695_TIMER1_PCOUNT	    0xE40C
 #define KS8695_TIMER0_PCOUNT	    0xE410
 
-/*GPIO registers offset difinitions*/
+/*GPIO register offset definitions*/
 #define KS8695_GPIO_MODE	    0xE600
 #define KS8695_GPIO_CTRL	    0xE604
 #define KS8695_GPIO_DATA	    0xE608
 
-/*SWITCH registers offset difinitions*/
+/*SWITCH register offset definitions*/
 #define KS8695_SWITCH_CTRL0	    0xE800
 #define KS8695_SWITCH_CTRL1	    0xE804
 #define KS8695_SWITCH_PORT1	    0xE808
@@ -184,13 +184,13 @@
 #define KS8695_SWITCH_LPPM12	    0xE874
 #define KS8695_SWITCH_LPPM34	    0xE878
 
-/*host communication registers difinitions*/
+/*host communication register definitions*/
 #define KS8695_DSCP_HIGH	    0xE834
 #define KS8695_DSCP_LOW		    0xE838
 #define KS8695_SWITCH_MAC_HIGH	    0xE83C
 #define KS8695_SWITCH_MAC_LOW	    0xE840
 
-/*miscellaneours registers difinitions*/
+/*miscellaneous register definitions*/
 #define KS8695_MANAGE_COUNTER	    0xE844
 #define KS8695_MANAGE_DATA	    0xE848
 #define KS8695_LAN12_POWERMAGR	    0xE84C
@@ -205,7 +205,7 @@
 #define KS8695_WAN_PHY_CONTROL	    0xEA14
 #define KS8695_WAN_PHY_STATUS	    0xEA18
 
-/* bus clock definitions*/
+/* bus clock definitions for KS8695_SYSTEM_BUS_CLOCK */
 #define KS8695_BUS_CLOCK_125MHZ	    0x0
 #define KS8695_BUS_CLOCK_100MHZ	    0x1
 #define KS8695_BUS_CLOCK_62MHZ	    0x2
@@ -215,8 +215,27 @@
 #define KS8695_BUS_CLOCK_31MHZ	    0x6
 #define KS8695_BUS_CLOCK_25MHZ	    0x7
 
+/* bus width definitions for KS8695_MEM_GENERAL and SDRAM_CTRL */
+#define KS8695_BUS_WIDTH_OFF	0
+#define KS8695_BUS_WIDTH_8	1
+#define KS8695_BUS_WIDTH_16	2
+#define KS8695_BUS_WIDTH_32	3
+
+/* register value definitions for memory controller */
+#define KS8695_SDCON_D_OFF	(KS8695_BUS_WIDTH_OFF<<1)
+#define KS8695_SDCON_D_8	(KS8695_BUS_WIDTH_8<<1)
+#define KS8695_SDCON_D_16	(KS8695_BUS_WIDTH_16<<1)
+#define KS8695_SDCON_D_32	(KS8695_BUS_WIDTH_32<<1)
+#define KS8695_SDCON_2BANK	0x000
+#define KS8695_SDCON_4BANK	0x008
+#define KS8695_SDCON_CA_8BIT	0x000
+#define KS8695_SDCON_CA_9BIT	0x100
+#define KS8695_SDCON_CA_10BIT	0x200
+#define KS8695_SDCON_CA_11BIT	0x300
+#define KS8695_MEM_RANGE(BASE,SIZE) (((BASE)&0x03ff0000)>>(16-12) | (((BASE)+(SIZE)-1)&0x03ff0000)<<(22-16))
+
 /* -------------------------------------------------------------------------------
- *  definations for IRQ
+ *  definitions for IRQ
  * -------------------------------------------------------------------------------*/
 
 #define KS8695_INT_EXT_INT0		       2
arch/arm/include/asm/arch-ks8695/regvalues.h new file +112 -0

112 lines not on this page · raw message

Signature · 1 line
1.7.10.4
#13 lore raw

PATCH 2/11 arm: ks8695: more macros for register values

Hi Yann,

Quoted 12 lines · Yann Vernier

Adding macros for more configurable lowlevel_init code. Also cleanup of some typos.

---
 arch/arm/include/asm/arch-ks8695/platform.h  |   55 ++++++++-----
 arch/arm/include/asm/arch-ks8695/regvalues.h |  112 ++++++++++++++++++++++++++
 2 files changed, 149 insertions(+), 18 deletions(-)
arch/arm/include/asm/arch-ks8695/platform.h +0 -0
index de20015..0ed0ecb 100644

arch/arm/include/asm/arch-ks8695/platform.h line 17

Quoted 7 lines
arch/arm/include/asm/arch-ks8695/platform.h +2 -2
@@ -13,8 +13,8 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307	 USA
  */
-#ifndef __address_h
-#define __address_h			1
+#ifndef __ASM_ARM_ARCH_PLATFORM_H__
+#define __ASM_ARM_ARCH_PLATFORM_H__

This define's name has nothing specific to ks8695. If it only serves to avoid double #inclusion, then make it specific; otherwise you always run the risk that some previously included file already defines a more generic __ASM_ARM_ARCH_PLATFORM_H__.

Quoted 6 lines
arch/arm/include/asm/arch-ks8695/platform.h +0 -0
 #define KS8695_SDRAM_START	    0x00000000
 #define KS8695_SDRAM_SIZE	    0x01000000
@@ -27,19 +27,19 @@
 #define KS8695_IO_BASE		    0x03FF0000
 #define KS8695_IO_SIZE		    0x00010000
 

arch/arm/include/asm/arch-ks8695/platform.h line 36

Quoted 10 lines
arch/arm/include/asm/arch-ks8695/platform.h +3 -3
-#define KS8695_SYSTEN_CONFIG	    0x00
-#define KS8695_SYSTEN_BUS_CLOCK	    0x04
+#define KS8695_SYSTEM_CONFIG	    0x00
+#define KS8695_SYSTEM_BUS_CLOCK	    0x04
 
 #define KS8695_FLASH_START	    0x02800000
 #define KS8695_FLASH_SIZE	    0x00400000
 
-/*i/o control registers offset difinitions*/
+/*i/o control register offset definitions*/

For readability, please leave a blank after the start and before the end if comments. This comment applies across the whole patch set.

Quoted 145 lines
arch/arm/include/asm/arch-ks8695/platform.h +32 -13
 #define KS8695_IO_CTRL0		    0x4000
 #define KS8695_IO_CTRL1		    0x4004
 #define KS8695_IO_CTRL2		    0x4008
 #define KS8695_IO_CTRL3		    0x400C
 
-/*memory control registers offset difinitions*/
+/*memory control register offset definitions*/
 #define KS8695_MEM_CTRL0	    0x4010
 #define KS8695_MEM_CTRL1	    0x4014
 #define KS8695_MEM_CTRL2	    0x4018
@@ -51,7 +51,7 @@
 #define KS8695_SDRAM_BUFFER	    0x403C
 #define KS8695_SDRAM_REFRESH	    0x4040
 
-/*WAN control registers offset difinitions*/
+/*WAN control register offset definitions*/
 #define KS8695_WAN_DMA_TX	    0x6000
 #define KS8695_WAN_DMA_RX	    0x6004
 #define KS8695_WAN_DMA_TX_START	    0x6008
@@ -63,7 +63,7 @@
 #define KS8695_WAN_MAC_ELOW	    0x6080
 #define KS8695_WAN_MAC_EHIGH	    0x6084
 
-/*LAN control registers offset difinitions*/
+/*LAN control register offset definitions*/
 #define KS8695_LAN_DMA_TX	    0x8000
 #define KS8695_LAN_DMA_RX	    0x8004
 #define KS8695_LAN_DMA_TX_START	    0x8008
@@ -75,7 +75,7 @@
 #define KS8695_LAN_MAC_ELOW	    0X8080
 #define KS8695_LAN_MAC_EHIGH	    0X8084
 
-/*HPNA control registers offset difinitions*/
+/*HPNA control register offset definitions*/
 #define KS8695_HPNA_DMA_TX	    0xA000
 #define KS8695_HPNA_DMA_RX	    0xA004
 #define KS8695_HPNA_DMA_TX_START    0xA008
@@ -87,7 +87,7 @@
 #define KS8695_HPNA_MAC_ELOW	    0xA080
 #define KS8695_HPNA_MAC_EHIGH	    0xA084
 
-/*UART control registers offset difinitions*/
+/*UART control register offset definitions*/
 #define KS8695_UART_RX_BUFFER	    0xE000
 #define KS8695_UART_TX_HOLDING	    0xE004
 
@@ -133,7 +133,7 @@
 #define KS8695_UART_DIVISOR	    0xE01C
 #define KS8695_UART_STATUS	    0xE020
 
-/*Interrupt controlller registers offset difinitions*/
+/*Interrupt controller register offset definitions*/
 #define KS8695_INT_CONTL	    0xE200
 #define KS8695_INT_ENABLE	    0xE204
 #define KS8695_INT_ENABLE_MODEM	    0x0800
@@ -154,19 +154,19 @@
 #define KS8695_FIQ_PEND_PRIORITY    0xE230
 #define KS8695_IRQ_PEND_PRIORITY    0xE234
 
-/*timer registers offset difinitions*/
+/*timer register offset definitions*/
 #define KS8695_TIMER_CTRL	    0xE400
 #define KS8695_TIMER1		    0xE404
 #define KS8695_TIMER0		    0xE408
 #define KS8695_TIMER1_PCOUNT	    0xE40C
 #define KS8695_TIMER0_PCOUNT	    0xE410
 
-/*GPIO registers offset difinitions*/
+/*GPIO register offset definitions*/
 #define KS8695_GPIO_MODE	    0xE600
 #define KS8695_GPIO_CTRL	    0xE604
 #define KS8695_GPIO_DATA	    0xE608
 
-/*SWITCH registers offset difinitions*/
+/*SWITCH register offset definitions*/
 #define KS8695_SWITCH_CTRL0	    0xE800
 #define KS8695_SWITCH_CTRL1	    0xE804
 #define KS8695_SWITCH_PORT1	    0xE808
@@ -184,13 +184,13 @@
 #define KS8695_SWITCH_LPPM12	    0xE874
 #define KS8695_SWITCH_LPPM34	    0xE878
 
-/*host communication registers difinitions*/
+/*host communication register definitions*/
 #define KS8695_DSCP_HIGH	    0xE834
 #define KS8695_DSCP_LOW		    0xE838
 #define KS8695_SWITCH_MAC_HIGH	    0xE83C
 #define KS8695_SWITCH_MAC_LOW	    0xE840
 
-/*miscellaneours registers difinitions*/
+/*miscellaneous register definitions*/
 #define KS8695_MANAGE_COUNTER	    0xE844
 #define KS8695_MANAGE_DATA	    0xE848
 #define KS8695_LAN12_POWERMAGR	    0xE84C
@@ -205,7 +205,7 @@
 #define KS8695_WAN_PHY_CONTROL	    0xEA14
 #define KS8695_WAN_PHY_STATUS	    0xEA18
 
-/* bus clock definitions*/
+/* bus clock definitions for KS8695_SYSTEM_BUS_CLOCK */
 #define KS8695_BUS_CLOCK_125MHZ	    0x0
 #define KS8695_BUS_CLOCK_100MHZ	    0x1
 #define KS8695_BUS_CLOCK_62MHZ	    0x2
@@ -215,8 +215,27 @@
 #define KS8695_BUS_CLOCK_31MHZ	    0x6
 #define KS8695_BUS_CLOCK_25MHZ	    0x7
 
+/* bus width definitions for KS8695_MEM_GENERAL and SDRAM_CTRL */
+#define KS8695_BUS_WIDTH_OFF	0
+#define KS8695_BUS_WIDTH_8	1
+#define KS8695_BUS_WIDTH_16	2
+#define KS8695_BUS_WIDTH_32	3
+
+/* register value definitions for memory controller */
+#define KS8695_SDCON_D_OFF	(KS8695_BUS_WIDTH_OFF<<1)
+#define KS8695_SDCON_D_8	(KS8695_BUS_WIDTH_8<<1)
+#define KS8695_SDCON_D_16	(KS8695_BUS_WIDTH_16<<1)
+#define KS8695_SDCON_D_32	(KS8695_BUS_WIDTH_32<<1)
+#define KS8695_SDCON_2BANK	0x000
+#define KS8695_SDCON_4BANK	0x008
+#define KS8695_SDCON_CA_8BIT	0x000
+#define KS8695_SDCON_CA_9BIT	0x100
+#define KS8695_SDCON_CA_10BIT	0x200
+#define KS8695_SDCON_CA_11BIT	0x300
+#define KS8695_MEM_RANGE(BASE,SIZE) (((BASE)&0x03ff0000)>>(16-12) | (((BASE)+(SIZE)-1)&0x03ff0000)<<(22-16))
+
 /* -------------------------------------------------------------------------------
- *  definations for IRQ
+ *  definitions for IRQ
  * -------------------------------------------------------------------------------*/
 
 #define KS8695_INT_EXT_INT0		       2
arch/arm/include/asm/arch-ks8695/regvalues.h new file +7 -0
new file mode 100644
index 0000000..7d29bbf
@@ -0,0 +1,112 @@
+/*
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,

arch/arm/include/asm/arch-ks8695/regvalues.h line 17

Quoted 10 lines
arch/arm/include/asm/arch-ks8695/regvalues.h new file +10 -0
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	 See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307	 USA
+ */
+#ifndef __ASM_ARM_ARCH_REGVALUES_H__
+#define __ASM_ARM_ARCH_REGVALUES_H__

Same comment as above, make it specific.

Quoted 84 lines
arch/arm/include/asm/arch-ks8695/regvalues.h new file +84 -0
+/* This file calculates register values set by low level initialization code
+   from configuration macros */
+
+#define CONFIG_SYS_SDCS0_BASE	CONFIG_SYS_SDRAM_BASE
+#define CONFIG_SYS_SDCS0_SIZE	CONFIG_SYS_SDRAM_SIZE
+
+#ifndef CONFIG_SYS_RCS0_SPEED
+/* access cycle time 5tmult+6, normal ROM (no pages) */
+# define CONFIG_SYS_RCS0_SPEED 0x040
+#endif
+#ifndef CONFIG_SYS_RCS0_WIDTH
+# define CONFIG_SYS_RCS0_WIDTH KS8695_BUS_WIDTH_8
+#endif
+
+#ifdef CONFIG_SYS_RCS1_BASE
+# ifndef CONFIG_SYS_RCS1_WIDTH
+#  define CONFIG_SYS_RCS1_WIDTH CONFIG_SYS_RCS0_WIDTH
+# endif
+# ifndef CONFIG_SYS_RCS1_SPEED
+#  define CONFIG_SYS_RCS1_SPEED CONFIG_SYS_RCS0_SPEED
+# endif
+#else
+# define CONFIG_SYS_RCS1_WIDTH KS8695_BUS_WIDTH_OFF
+#endif
+
+#ifndef CONFIG_SYS_ECS0_WIDTH
+# define CONFIG_SYS_ECS0_WIDTH KS8695_BUS_WIDTH_OFF
+#endif
+#ifndef CONFIG_SYS_ECS1_WIDTH
+# define CONFIG_SYS_ECS1_WIDTH KS8695_BUS_WIDTH_OFF
+#endif
+#ifndef CONFIG_SYS_ECS2_WIDTH
+# define CONFIG_SYS_ECS2_WIDTH KS8695_BUS_WIDTH_OFF
+#endif
+
+#ifndef CONFIG_KS8695_TMULT
+# define CONFIG_KS8695_TMULT 3
+#endif
+
+#if CONFIG_SYS_SDCS0_PARAMS
+# ifndef CONFIG_SYS_SDCS0_BASE
+#  define CONFIG_SYS_SDCS0_BASE CONFIG_SYS_SDRAM_BASE
+#  define CONFIG_SYS_SDCS0_SIZE CONFIG_SYS_SDRAM_SIZE
+# endif
+#endif
+
+#define CONFIG_KS8695_ROMCON0_VALUE					\
+	(CONFIG_SYS_RCS0_SPEED |					\
+	 KS8695_MEM_RANGE(CONFIG_SYS_RCS0_BASE,CONFIG_SYS_RCS0_SIZE))
+#define CONFIG_KS8695_ROMCON1_VALUE					\
+	(CONFIG_SYS_RCS1_SPEED |					\
+	 KS8695_MEM_RANGE(CONFIG_SYS_RCS1_BASE,CONFIG_SYS_RCS1_SIZE))
+#define CONFIG_KS8695_EXTACON0_VALUE					\
+	(CONFIG_SYS_ECS0_SPEED |					\
+	 KS8695_MEM_RANGE(CONFIG_SYS_ECS0_BASE,CONFIG_SYS_ECS0_SIZE))
+#define CONFIG_KS8695_EXTACON1_VALUE					\
+	(CONFIG_SYS_ECS1_SPEED |					\
+	 KS8695_MEM_RANGE(CONFIG_SYS_ECS1_BASE,CONFIG_SYS_ECS1_SIZE))
+#define CONFIG_KS8695_EXTACON2_VALUE					\
+	(CONFIG_SYS_ECS2_SPEED |					\
+	 KS8695_MEM_RANGE(CONFIG_SYS_ECS2_BASE,CONFIG_SYS_ECS2_SIZE))
+
+#define CONFIG_KS8695_SDCON0_VALUE					\
+	(CONFIG_SYS_SDCS0_PARAMS |					\
+	 KS8695_MEM_RANGE(CONFIG_SYS_SDCS0_BASE,CONFIG_SYS_SDCS0_SIZE))
+#define CONFIG_KS8695_SDCON1_VALUE					\
+	(CONFIG_SYS_SDCS1_PARAMS |					\
+	 KS8695_MEM_RANGE(CONFIG_SYS_SDCS1_BASE,CONFIG_SYS_SDCS1_SIZE))
+
+#if CONFIG_SYS_SDRAM_RAS_CAS_DELAY<1 || CONFIG_SYS_SDRAM_RAS_CAS_DELAY>4
+#error Unsupported SDRAM timing: RAS to CAS delay
+#endif
+#ifndef CONFIG_SYS_SDRAM_CAS_LATENCY
+#define CONFIG_SYS_SDRAM_CAS_LATENCY ((CONFIG_SYS_SDRAM_MODE>>4)&7)
+#endif
+#if CONFIG_SYS_SDRAM_CAS_LATENCY<1 || CONFIG_SYS_SDRAM_CAS_LATENCY>4
+#error Unsupported SDRAM timing: CAS latency
+#endif
+#define CONFIG_KS8695_SDGCON_VALUE			\
+	((CONFIG_SYS_SDRAM_RAS_CAS_DELAY-1)<<2 |	\
+	 (CONFIG_SYS_SDRAM_CAS_LATENCY-1))
+#ifndef CONFIG_SYS_SDRAM_REFRESH_RATE
+#define CONFIG_SYS_SDRAM_REFRESH_RATE	0x0190
+#endif

arch/arm/include/asm/arch-ks8695/regvalues.h line 112

Quoted 10 lines
arch/arm/include/asm/arch-ks8695/regvalues.h new file +10 -0
+
+
+#define CONFIG_KS8695_ERGCON_VALUE (CONFIG_KS8695_TMULT<<28	|	\
+				    CONFIG_SYS_ECS2_WIDTH<<20	|	\
+				    CONFIG_SYS_ECS1_WIDTH<<18	|	\
+				    CONFIG_SYS_ECS0_WIDTH<<16	|	\
+				    CONFIG_SYS_RCS1_WIDTH<<2	|	\
+				    CONFIG_SYS_RCS0_WIDTH)
+
+#endif

Amicalement,

Signature · 1 line
Albert.
#14 lore raw

PATCH 1/1 arm: ks8695: more macros for register values

Adding macros for more configurable lowlevel_init code. Also cleanup of some typos.
---
Changes for v2:
- Add spaces for legibility
- Correct multiple #include protection to specify device

---
 arch/arm/include/asm/arch-ks8695/platform.h  |   55 ++++++++-----
 arch/arm/include/asm/arch-ks8695/regvalues.h |  112 ++++++++++++++++++++++++++
 2 files changed, 149 insertions(+), 18 deletions(-)
 create mode 100644 arch/arm/include/asm/arch-ks8695/regvalues.h
arch/arm/include/asm/arch-ks8695/platform.h +37 -18
index de20015..a78d312 100644
@@ -13,8 +13,8 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307	 USA
  */
-#ifndef __address_h
-#define __address_h			1
+#ifndef __ASM_ARM_ARCH_KS8695_PLATFORM_H__
+#define __ASM_ARM_ARCH_KS8695_PLATFORM_H__
 
 #define KS8695_SDRAM_START	    0x00000000
 #define KS8695_SDRAM_SIZE	    0x01000000
@@ -27,19 +27,19 @@
 #define KS8695_IO_BASE		    0x03FF0000
 #define KS8695_IO_SIZE		    0x00010000
 
-#define KS8695_SYSTEN_CONFIG	    0x00
-#define KS8695_SYSTEN_BUS_CLOCK	    0x04
+#define KS8695_SYSTEM_CONFIG        0x00
+#define KS8695_SYSTEM_BUS_CLOCK     0x04
 
 #define KS8695_FLASH_START	    0x02800000
 #define KS8695_FLASH_SIZE	    0x00400000
 
-/*i/o control registers offset difinitions*/
+/* i/o control register offset definitions */
 #define KS8695_IO_CTRL0		    0x4000
 #define KS8695_IO_CTRL1		    0x4004
 #define KS8695_IO_CTRL2		    0x4008
 #define KS8695_IO_CTRL3		    0x400C
 
-/*memory control registers offset difinitions*/
+/* memory control register offset definitions */
 #define KS8695_MEM_CTRL0	    0x4010
 #define KS8695_MEM_CTRL1	    0x4014
 #define KS8695_MEM_CTRL2	    0x4018
@@ -51,7 +51,7 @@
 #define KS8695_SDRAM_BUFFER	    0x403C
 #define KS8695_SDRAM_REFRESH	    0x4040
 
-/*WAN control registers offset difinitions*/
+/* WAN control register offset definitions */
 #define KS8695_WAN_DMA_TX	    0x6000
 #define KS8695_WAN_DMA_RX	    0x6004
 #define KS8695_WAN_DMA_TX_START	    0x6008
@@ -63,7 +63,7 @@
 #define KS8695_WAN_MAC_ELOW	    0x6080
 #define KS8695_WAN_MAC_EHIGH	    0x6084
 
-/*LAN control registers offset difinitions*/
+/* LAN control register offset definitions */
 #define KS8695_LAN_DMA_TX	    0x8000
 #define KS8695_LAN_DMA_RX	    0x8004
 #define KS8695_LAN_DMA_TX_START	    0x8008
@@ -75,7 +75,7 @@
 #define KS8695_LAN_MAC_ELOW	    0X8080
 #define KS8695_LAN_MAC_EHIGH	    0X8084
 
-/*HPNA control registers offset difinitions*/
+/* HPNA control register offset definitions */
 #define KS8695_HPNA_DMA_TX	    0xA000
 #define KS8695_HPNA_DMA_RX	    0xA004
 #define KS8695_HPNA_DMA_TX_START    0xA008
@@ -87,7 +87,7 @@
 #define KS8695_HPNA_MAC_ELOW	    0xA080
 #define KS8695_HPNA_MAC_EHIGH	    0xA084
 
-/*UART control registers offset difinitions*/
+/* UART control register offset definitions */
 #define KS8695_UART_RX_BUFFER	    0xE000
 #define KS8695_UART_TX_HOLDING	    0xE004
 
@@ -133,7 +133,7 @@
 #define KS8695_UART_DIVISOR	    0xE01C
 #define KS8695_UART_STATUS	    0xE020
 
-/*Interrupt controlller registers offset difinitions*/
+/* Interrupt controller register offset definitions */
 #define KS8695_INT_CONTL	    0xE200
 #define KS8695_INT_ENABLE	    0xE204
 #define KS8695_INT_ENABLE_MODEM	    0x0800
@@ -154,19 +154,19 @@
 #define KS8695_FIQ_PEND_PRIORITY    0xE230
 #define KS8695_IRQ_PEND_PRIORITY    0xE234
 
-/*timer registers offset difinitions*/
+/* timer register offset definitions */
 #define KS8695_TIMER_CTRL	    0xE400
 #define KS8695_TIMER1		    0xE404
 #define KS8695_TIMER0		    0xE408
 #define KS8695_TIMER1_PCOUNT	    0xE40C
 #define KS8695_TIMER0_PCOUNT	    0xE410
 
-/*GPIO registers offset difinitions*/
+/* GPIO register offset definitions */
 #define KS8695_GPIO_MODE	    0xE600
 #define KS8695_GPIO_CTRL	    0xE604
 #define KS8695_GPIO_DATA	    0xE608
 
-/*SWITCH registers offset difinitions*/
+/* SWITCH register offset definitions */
 #define KS8695_SWITCH_CTRL0	    0xE800
 #define KS8695_SWITCH_CTRL1	    0xE804
 #define KS8695_SWITCH_PORT1	    0xE808
@@ -184,13 +184,13 @@
 #define KS8695_SWITCH_LPPM12	    0xE874
 #define KS8695_SWITCH_LPPM34	    0xE878
 
-/*host communication registers difinitions*/
+/* host communication register definitions */
 #define KS8695_DSCP_HIGH	    0xE834
 #define KS8695_DSCP_LOW		    0xE838
 #define KS8695_SWITCH_MAC_HIGH	    0xE83C
 #define KS8695_SWITCH_MAC_LOW	    0xE840
 
-/*miscellaneours registers difinitions*/
+/* miscellaneous register definitions */
 #define KS8695_MANAGE_COUNTER	    0xE844
 #define KS8695_MANAGE_DATA	    0xE848
 #define KS8695_LAN12_POWERMAGR	    0xE84C
@@ -205,7 +205,7 @@
 #define KS8695_WAN_PHY_CONTROL	    0xEA14
 #define KS8695_WAN_PHY_STATUS	    0xEA18
 
-/* bus clock definitions*/
+/* bus clock definitions for KS8695_SYSTEM_BUS_CLOCK */
 #define KS8695_BUS_CLOCK_125MHZ	    0x0
 #define KS8695_BUS_CLOCK_100MHZ	    0x1
 #define KS8695_BUS_CLOCK_62MHZ	    0x2
@@ -215,8 +215,27 @@
 #define KS8695_BUS_CLOCK_31MHZ	    0x6
 #define KS8695_BUS_CLOCK_25MHZ	    0x7
 
+/* bus width definitions for KS8695_MEM_GENERAL and SDRAM_CTRL */
+#define KS8695_BUS_WIDTH_OFF	0
+#define KS8695_BUS_WIDTH_8	1
+#define KS8695_BUS_WIDTH_16	2
+#define KS8695_BUS_WIDTH_32	3
+
+/* register value definitions for memory controller */
+#define KS8695_SDCON_D_OFF	(KS8695_BUS_WIDTH_OFF<<1)
+#define KS8695_SDCON_D_8	(KS8695_BUS_WIDTH_8<<1)
+#define KS8695_SDCON_D_16	(KS8695_BUS_WIDTH_16<<1)
+#define KS8695_SDCON_D_32	(KS8695_BUS_WIDTH_32<<1)
+#define KS8695_SDCON_2BANK	0x000
+#define KS8695_SDCON_4BANK	0x008
+#define KS8695_SDCON_CA_8BIT	0x000
+#define KS8695_SDCON_CA_9BIT	0x100
+#define KS8695_SDCON_CA_10BIT	0x200
+#define KS8695_SDCON_CA_11BIT	0x300
+#define KS8695_MEM_RANGE(BASE,SIZE) (((BASE)&0x03ff0000)>>(16-12) | (((BASE)+(SIZE)-1)&0x03ff0000)<<(22-16))
+
 /* -------------------------------------------------------------------------------
- *  definations for IRQ
+ *  definitions for IRQ
  * -------------------------------------------------------------------------------*/
 
 #define KS8695_INT_EXT_INT0		       2
arch/arm/include/asm/arch-ks8695/regvalues.h new file +112 -0

112 lines not on this page · raw message

Signature · 1 line
1.7.10.4
#15 lore raw

PATCH 1/1 arm: ks8695: more macros for register values

Sorry! I didn't remember this patch (regvalues.h) is where a poorly named macro (comment on patch 7/11, SDRAM parameters) was defined. I will fix it.

#16 lore raw

PATCH 1/1 arm: ks8695: more macros for register values

Dear Yann Vernier,

Quoted 3 lines

Sorry! I didn't remember this patch (regvalues.h) is where a poorly named macro (comment on patch 7/11, SDRAM parameters) was defined. I will fix it.

Make sure to run checkpatch.pl on those patches before reposting please.

Best regards,
Marek Vasut

#17 lore raw

PATCH 3/11 arm: ks8695eth: Use MAC address from environment

In reply to Yann Vernier

Removed board specific MAC reading code from driver. Should move the reading to the cm4008/cm41xx board code.

---
 drivers/net/ks8695eth.c |   38 +++++++++-----------------------------
 1 file changed, 9 insertions(+), 29 deletions(-)
drivers/net/ks8695eth.c +9 -29
index b4904b6..2dda7ab 100644
@@ -71,30 +71,13 @@ volatile uint8_t ks8695_bufs[BUFSIZE*(TXDESCS+RXDESCS)] __attribute__((aligned(2
 
 /****************************************************************************/
 
-/*
- *	Ideally we want to use the MAC address stored in flash.
- *	But we do some sanity checks in case they are not present
- *	first.
- */
-unsigned char eth_mac[] = {
-	0x00, 0x13, 0xc6, 0x00, 0x00, 0x00
-};
-
-void ks8695_getmac(void)
+static int ks8695_set_mac_address(struct eth_device *dev)
 {
-	unsigned char *fp;
-	int i;
-
-	/* Check if flash MAC is valid */
-	fp = (unsigned char *) 0x0201c000;
-	for (i = 0; (i < 6); i++) {
-		if ((fp[i] != 0) && (fp[i] != 0xff))
-			break;
-	}
-
-	/* If we found a valid looking MAC address then use it */
-	if (i < 6)
-		memcpy(&eth_mac[0], fp, 6);
+	/* Set MAC address */
+	ks8695_write(KS8695_LAN_MAC_LOW, (dev->enetaddr[5] | (dev->enetaddr[4] << 8) |
+		(dev->enetaddr[3] << 16) | (dev->enetaddr[2] << 24)));
+	ks8695_write(KS8695_LAN_MAC_HIGH, (dev->enetaddr[1] | (dev->enetaddr[0] << 8)));
+	return 0;
 }
 
 /****************************************************************************/
@@ -109,12 +92,8 @@ static int ks8695_eth_init(struct eth_device *dev, bd_t *bd)
 	ks8695_write(KS8695_LAN_DMA_TX, 0x80000000);
 	ks8695_write(KS8695_LAN_DMA_RX, 0x80000000);
 
-	ks8695_getmac();
-
 	/* Set MAC address */
-	ks8695_write(KS8695_LAN_MAC_LOW, (eth_mac[5] | (eth_mac[4] << 8) |
-		(eth_mac[3] << 16) | (eth_mac[2] << 24)));
-	ks8695_write(KS8695_LAN_MAC_HIGH, (eth_mac[1] | (eth_mac[0] << 8)));
+	ks8695_set_mac_address(dev);
 
 	/* Turn the 4 port switch on */
 	i = ks8695_read(KS8695_SWITCH_CTRL0);
@@ -150,7 +129,7 @@ static int ks8695_eth_init(struct eth_device *dev, bd_t *bd)
 	ks8695_write(KS8695_LAN_DMA_RX, 0x71);
 	ks8695_write(KS8695_LAN_DMA_RX_START, 0x1);
 
-	printf("KS8695 ETHERNET: %pM\n", eth_mac);
+	printf("KS8695 ETHERNET: %pM\n", dev->enetaddr);
 	return 0;
 }
 
@@ -234,6 +213,7 @@ int ks8695_eth_initialize(void)
 	dev->halt = ks8695_eth_halt;
 	dev->send = ks8695_eth_send;
 	dev->recv = ks8695_eth_recv;
+	dev->write_hwaddr = ks8695_set_mac_address;
 	strcpy(dev->name, "ks8695eth");
 
 	eth_register(dev);
Signature · 1 line
1.7.10.4
#18 lore raw

PATCH 3/11 arm: ks8695eth: Use MAC address from environment

Hi Yann,

Quoted 71 lines · Yann Vernier

Removed board specific MAC reading code from driver. Should move the reading to the cm4008/cm41xx board code.

---
 drivers/net/ks8695eth.c |   38 +++++++++-----------------------------
 1 file changed, 9 insertions(+), 29 deletions(-)
drivers/net/ks8695eth.c +8 -29
index b4904b6..2dda7ab 100644
@@ -71,30 +71,13 @@ volatile uint8_t ks8695_bufs[BUFSIZE*(TXDESCS+RXDESCS)] __attribute__((aligned(2
 
 /****************************************************************************/
 
-/*
- *	Ideally we want to use the MAC address stored in flash.
- *	But we do some sanity checks in case they are not present
- *	first.
- */
-unsigned char eth_mac[] = {
-	0x00, 0x13, 0xc6, 0x00, 0x00, 0x00
-};
-
-void ks8695_getmac(void)
+static int ks8695_set_mac_address(struct eth_device *dev)
 {
-	unsigned char *fp;
-	int i;
-
-	/* Check if flash MAC is valid */
-	fp = (unsigned char *) 0x0201c000;
-	for (i = 0; (i < 6); i++) {
-		if ((fp[i] != 0) && (fp[i] != 0xff))
-			break;
-	}
-
-	/* If we found a valid looking MAC address then use it */
-	if (i < 6)
-		memcpy(&eth_mac[0], fp, 6);
+	/* Set MAC address */
+	ks8695_write(KS8695_LAN_MAC_LOW, (dev->enetaddr[5] | (dev->enetaddr[4] << 8) |
+		(dev->enetaddr[3] << 16) | (dev->enetaddr[2] << 24)));
+	ks8695_write(KS8695_LAN_MAC_HIGH, (dev->enetaddr[1] | (dev->enetaddr[0] << 8)));
+	return 0;
 }
 
 /****************************************************************************/
@@ -109,12 +92,8 @@ static int ks8695_eth_init(struct eth_device *dev, bd_t *bd)
 	ks8695_write(KS8695_LAN_DMA_TX, 0x80000000);
 	ks8695_write(KS8695_LAN_DMA_RX, 0x80000000);
 
-	ks8695_getmac();
-
 	/* Set MAC address */
-	ks8695_write(KS8695_LAN_MAC_LOW, (eth_mac[5] | (eth_mac[4] << 8) |
-		(eth_mac[3] << 16) | (eth_mac[2] << 24)));
-	ks8695_write(KS8695_LAN_MAC_HIGH, (eth_mac[1] | (eth_mac[0] << 8)));
+	ks8695_set_mac_address(dev);
 
 	/* Turn the 4 port switch on */
 	i = ks8695_read(KS8695_SWITCH_CTRL0);
@@ -150,7 +129,7 @@ static int ks8695_eth_init(struct eth_device *dev, bd_t *bd)
 	ks8695_write(KS8695_LAN_DMA_RX, 0x71);
 	ks8695_write(KS8695_LAN_DMA_RX_START, 0x1);
 
-	printf("KS8695 ETHERNET: %pM\n", eth_mac);
+	printf("KS8695 ETHERNET: %pM\n", dev->enetaddr);
 	return 0;
 }
 

drivers/net/ks8695eth.c int ks8695_eth_initialize(void) · line 219

Quoted 7 lines
drivers/net/ks8695eth.c +1 -0
@@ -234,6 +213,7 @@ int ks8695_eth_initialize(void)
 	dev->halt = ks8695_eth_halt;
 	dev->send = ks8695_eth_send;
 	dev->recv = ks8695_eth_recv;
+	dev->write_hwaddr = ks8695_set_mac_address;
 	strcpy(dev->name, "ks8695eth");
 
 	eth_register(dev);

Cc:ing Joe as the network custodian for ack'ing the patch (although I'll take it along with the whole series).

Amicalement,

Signature · 1 line
Albert.
#19 lore raw

PATCH 3/11 arm: ks8695eth: Use MAC address from environment

In reply to Yann Vernier

Hi Yann,

Quoted 48 lines · Yann Vernier

Removed board specific MAC reading code from driver. Should move the reading to the cm4008/cm41xx board code.

---
 drivers/net/ks8695eth.c |   38 +++++++++-----------------------------
 1 file changed, 9 insertions(+), 29 deletions(-)
drivers/net/ks8695eth.c +6 -23
index b4904b6..2dda7ab 100644
@@ -71,30 +71,13 @@ volatile uint8_t ks8695_bufs[BUFSIZE*(TXDESCS+RXDESCS)] __attribute__((aligned(2
 
 /****************************************************************************/
 
-/*
- *     Ideally we want to use the MAC address stored in flash.
- *     But we do some sanity checks in case they are not present
- *     first.
- */
-unsigned char eth_mac[] = {
-       0x00, 0x13, 0xc6, 0x00, 0x00, 0x00
-};
-
-void ks8695_getmac(void)
+static int ks8695_set_mac_address(struct eth_device *dev)
 {
-       unsigned char *fp;
-       int i;
-
-       /* Check if flash MAC is valid */
-       fp = (unsigned char *) 0x0201c000;
-       for (i = 0; (i < 6); i++) {
-               if ((fp[i] != 0) && (fp[i] != 0xff))
-                       break;
-       }
-
-       /* If we found a valid looking MAC address then use it */
-       if (i < 6)
-               memcpy(&eth_mac[0], fp, 6);
+       /* Set MAC address */
+       ks8695_write(KS8695_LAN_MAC_LOW, (dev->enetaddr[5] | (dev->enetaddr[4] << 8) |
+               (dev->enetaddr[3] << 16) | (dev->enetaddr[2] << 24)));
+       ks8695_write(KS8695_LAN_MAC_HIGH, (dev->enetaddr[1] | (dev->enetaddr[0] << 8)));
+       return 0;
 }
 
 /****************************************************************************/

drivers/net/ks8695eth.c static int ks8695_eth_init(struct eth_device *dev, bd_t *bd) · line 96

Quoted 10 lines
drivers/net/ks8695eth.c +1 -5
@@ -109,12 +92,8 @@ static int ks8695_eth_init(struct eth_device *dev, bd_t *bd)
        ks8695_write(KS8695_LAN_DMA_TX, 0x80000000);
        ks8695_write(KS8695_LAN_DMA_RX, 0x80000000);
 
-       ks8695_getmac();
-
        /* Set MAC address */
-       ks8695_write(KS8695_LAN_MAC_LOW, (eth_mac[5] | (eth_mac[4] << 8) |
-               (eth_mac[3] << 16) | (eth_mac[2] << 24)));
-       ks8695_write(KS8695_LAN_MAC_HIGH, (eth_mac[1] | (eth_mac[0] << 8)));
+       ks8695_set_mac_address(dev);

Why do you set the MAC address here? It should be set for you by the network infrastructure without this call.

Quoted 21 lines
drivers/net/ks8695eth.c +2 -2
        /* Turn the 4 port switch on */
        i = ks8695_read(KS8695_SWITCH_CTRL0);
@@ -150,7 +129,7 @@ static int ks8695_eth_init(struct eth_device *dev, bd_t *bd)
        ks8695_write(KS8695_LAN_DMA_RX, 0x71);
        ks8695_write(KS8695_LAN_DMA_RX_START, 0x1);
 
-       printf("KS8695 ETHERNET: %pM\n", eth_mac);
+       printf("KS8695 ETHERNET: %pM\n", dev->enetaddr);
        return 0;
 }
 
@@ -234,6 +213,7 @@ int ks8695_eth_initialize(void)
        dev->halt = ks8695_eth_halt;
        dev->send = ks8695_eth_send;
        dev->recv = ks8695_eth_recv;
+       dev->write_hwaddr = ks8695_set_mac_address;
        strcpy(dev->name, "ks8695eth");
 
        eth_register(dev);
--
Quoted 1 line

1.7.10.4

-Joe

#20 lore raw

PATCH 3/11 arm: ks8695eth: Use MAC address from environment

Quoted 60 lines · On Thu, 18 Oct 2012 15:55:31 -0500 Joe Hershberger <[email protected]>…

Hi Yann,

Quoted 56 lines · Yann Vernier

Removed board specific MAC reading code from driver. Should move the reading to the cm4008/cm41xx board code.

---
 drivers/net/ks8695eth.c |   38

+++++++++----------------------------- 1 file changed, 9 insertions(+), 29 deletions(-)

drivers/net/ks8695eth.c +0 -0
index b4904b6..2dda7ab 100644
@@ -71,30 +71,13 @@ volatile uint8_t

ks8695_bufs[BUFSIZE*(TXDESCS+RXDESCS)] __attribute__((aligned(2

/****************************************************************************/

drivers/net/ks8695eth.c +3 -23
-/*
- *     Ideally we want to use the MAC address stored in flash.
- *     But we do some sanity checks in case they are not present
- *     first.
- */
-unsigned char eth_mac[] = {
-       0x00, 0x13, 0xc6, 0x00, 0x00, 0x00
-};
-
-void ks8695_getmac(void)
+static int ks8695_set_mac_address(struct eth_device *dev)
 {
-       unsigned char *fp;
-       int i;
-
-       /* Check if flash MAC is valid */
-       fp = (unsigned char *) 0x0201c000;
-       for (i = 0; (i < 6); i++) {
-               if ((fp[i] != 0) && (fp[i] != 0xff))
-                       break;
-       }
-
-       /* If we found a valid looking MAC address then use it */
-       if (i < 6)
-               memcpy(&eth_mac[0], fp, 6);
+       /* Set MAC address */
+       ks8695_write(KS8695_LAN_MAC_LOW, (dev->enetaddr[5] |

(dev->enetaddr[4] << 8) |
+ (dev->enetaddr[3] << 16) | (dev->enetaddr[2] <<
24)));
+ ks8695_write(KS8695_LAN_MAC_HIGH, (dev->enetaddr[1] |
(dev->enetaddr[0] << 8)));

drivers/net/ks8695eth.c +1 -0
+       return 0;
 }
 
 /****************************************************************************/
@@ -109,12 +92,8 @@ static int ks8695_eth_init(struct eth_device
 *dev, bd_t *bd) ks8695_write(KS8695_LAN_DMA_TX, 0x80000000);
        ks8695_write(KS8695_LAN_DMA_RX, 0x80000000);
 
Quoted 12 lines
Quoted 9 lines
drivers/net/ks8695eth.c +0 -3
-       ks8695_getmac();
-
        /* Set MAC address */
-       ks8695_write(KS8695_LAN_MAC_LOW, (eth_mac[5] | (eth_mac[4]

<< 8) |

drivers/net/ks8695eth.c +0 -2
-               (eth_mac[3] << 16) | (eth_mac[2] << 24)));
-       ks8695_write(KS8695_LAN_MAC_HIGH, (eth_mac[1] | (eth_mac[0]

<< 8)));
+ ks8695_set_mac_address(dev);

Why do you set the MAC address here? It should be set for you by the network infrastructure without this call.

Simply because I was not aware of this at the time. Before the changes here the generic infrastructure could not do it, as write_hwaddr was unimplemented, and I was just trying to preserve function. The main reason I started poking at the network driver was that it loaded the MAC from a hardcoded address in ROM, obviously board specific (this is the magic number in [PATCH 11/11] arm: cm4008, cm41xx: read MAC address from flash). It also has a bug where it stops working after one command (i.e. can't tftp twice), which I have not tracked down as yet.

Quoted 23 lines
Quoted 20 lines
        /* Turn the 4 port switch on */
        i = ks8695_read(KS8695_SWITCH_CTRL0);
drivers/net/ks8695eth.c +2 -2
@@ -150,7 +129,7 @@ static int ks8695_eth_init(struct eth_device
 *dev, bd_t *bd) ks8695_write(KS8695_LAN_DMA_RX, 0x71);
        ks8695_write(KS8695_LAN_DMA_RX_START, 0x1);
 
-       printf("KS8695 ETHERNET: %pM\n", eth_mac);
+       printf("KS8695 ETHERNET: %pM\n", dev->enetaddr);
        return 0;
 }
 
@@ -234,6 +213,7 @@ int ks8695_eth_initialize(void)
        dev->halt = ks8695_eth_halt;
        dev->send = ks8695_eth_send;
        dev->recv = ks8695_eth_recv;
+       dev->write_hwaddr = ks8695_set_mac_address;
        strcpy(dev->name, "ks8695eth");
 
        eth_register(dev);
--
Quoted 1 line

1.7.10.4

-Joe

#21 lore raw

PATCH 3/11 arm: ks8695eth: Use MAC address from environment

Hi Yann,

Quoted 76 lines · Yann Vernier
Quoted 60 lines · On Thu, 18 Oct 2012 15:55:31 -0500 Joe Hershberger <[email protected]>…

Hi Yann,

Quoted 56 lines · Yann Vernier

Removed board specific MAC reading code from driver. Should move the reading to the cm4008/cm41xx board code.

---
 drivers/net/ks8695eth.c |   38

+++++++++----------------------------- 1 file changed, 9 insertions(+), 29 deletions(-)

drivers/net/ks8695eth.c +0 -0
index b4904b6..2dda7ab 100644
@@ -71,30 +71,13 @@ volatile uint8_t

ks8695_bufs[BUFSIZE*(TXDESCS+RXDESCS)] __attribute__((aligned(2

/****************************************************************************/

drivers/net/ks8695eth.c +3 -23
-/*
- *     Ideally we want to use the MAC address stored in flash.
- *     But we do some sanity checks in case they are not present
- *     first.
- */
-unsigned char eth_mac[] = {
-       0x00, 0x13, 0xc6, 0x00, 0x00, 0x00
-};
-
-void ks8695_getmac(void)
+static int ks8695_set_mac_address(struct eth_device *dev)
 {
-       unsigned char *fp;
-       int i;
-
-       /* Check if flash MAC is valid */
-       fp = (unsigned char *) 0x0201c000;
-       for (i = 0; (i < 6); i++) {
-               if ((fp[i] != 0) && (fp[i] != 0xff))
-                       break;
-       }
-
-       /* If we found a valid looking MAC address then use it */
-       if (i < 6)
-               memcpy(&eth_mac[0], fp, 6);
+       /* Set MAC address */
+       ks8695_write(KS8695_LAN_MAC_LOW, (dev->enetaddr[5] |

(dev->enetaddr[4] << 8) |
+ (dev->enetaddr[3] << 16) | (dev->enetaddr[2] <<
24)));
+ ks8695_write(KS8695_LAN_MAC_HIGH, (dev->enetaddr[1] |
(dev->enetaddr[0] << 8)));

drivers/net/ks8695eth.c +1 -0
+       return 0;
 }
 
 /****************************************************************************/
@@ -109,12 +92,8 @@ static int ks8695_eth_init(struct eth_device
 *dev, bd_t *bd) ks8695_write(KS8695_LAN_DMA_TX, 0x80000000);
        ks8695_write(KS8695_LAN_DMA_RX, 0x80000000);
 
Quoted 12 lines
Quoted 9 lines
drivers/net/ks8695eth.c +0 -3
-       ks8695_getmac();
-
        /* Set MAC address */
-       ks8695_write(KS8695_LAN_MAC_LOW, (eth_mac[5] | (eth_mac[4]

<< 8) |

drivers/net/ks8695eth.c +0 -2
-               (eth_mac[3] << 16) | (eth_mac[2] << 24)));
-       ks8695_write(KS8695_LAN_MAC_HIGH, (eth_mac[1] | (eth_mac[0]

<< 8)));
+ ks8695_set_mac_address(dev);

Why do you set the MAC address here? It should be set for you by the network infrastructure without this call.

Quoted 32 lines

Simply because I was not aware of this at the time. Before the changes here the generic infrastructure could not do it, as write_hwaddr was unimplemented, and I was just trying to preserve function. The main reason I started poking at the network driver was that it loaded the MAC from a hardcoded address in ROM, obviously board specific (this is the magic number in [PATCH 11/11] arm: cm4008, cm41xx: read MAC address from flash). It also has a bug where it stops working after one command (i.e. can't tftp twice), which I have not tracked down as yet.

Quoted 23 lines
Quoted 20 lines
        /* Turn the 4 port switch on */
        i = ks8695_read(KS8695_SWITCH_CTRL0);
drivers/net/ks8695eth.c +2 -2
@@ -150,7 +129,7 @@ static int ks8695_eth_init(struct eth_device
 *dev, bd_t *bd) ks8695_write(KS8695_LAN_DMA_RX, 0x71);
        ks8695_write(KS8695_LAN_DMA_RX_START, 0x1);
 
-       printf("KS8695 ETHERNET: %pM\n", eth_mac);
+       printf("KS8695 ETHERNET: %pM\n", dev->enetaddr);
        return 0;
 }
 
@@ -234,6 +213,7 @@ int ks8695_eth_initialize(void)
        dev->halt = ks8695_eth_halt;
        dev->send = ks8695_eth_send;
        dev->recv = ks8695_eth_recv;
+       dev->write_hwaddr = ks8695_set_mac_address;
        strcpy(dev->name, "ks8695eth");
 
        eth_register(dev);
--
Quoted 1 line

1.7.10.4

-Joe

What is the status for this patch? Are you going to drop it or submit a new version?

Amicalement,

Signature · 1 line
Albert.
#22 lore raw

PATCH 3/11 arm: ks8695eth: Use MAC address from environment

Quoted 117 lines · On Fri, 26 Oct 2012 23:37:28 +0200 Albert ARIBAUD <[email protected]>…

Hi Yann,

Quoted 78 lines · Yann Vernier
Quoted 62 lines · On Thu, 18 Oct 2012 15:55:31 -0500 Joe Hershberger <[email protected]>…

Hi Yann,

Quoted 58 lines · Yann Vernier

Removed board specific MAC reading code from driver. Should move the reading to the cm4008/cm41xx board code.

---
 drivers/net/ks8695eth.c |   38

+++++++++----------------------------- 1 file changed, 9 insertions(+), 29 deletions(-)

drivers/net/ks8695eth.c +0 -0
index b4904b6..2dda7ab 100644
@@ -71,30 +71,13 @@ volatile uint8_t

ks8695_bufs[BUFSIZE*(TXDESCS+RXDESCS)] __attribute__((aligned(2

/****************************************************************************/

-/*
- * Ideally we want to use the MAC address stored in flash.
- * But we do some sanity checks in case they are not
present
- * first.
- */

drivers/net/ks8695eth.c +1 -16
-unsigned char eth_mac[] = {
-       0x00, 0x13, 0xc6, 0x00, 0x00, 0x00
-};
-
-void ks8695_getmac(void)
+static int ks8695_set_mac_address(struct eth_device *dev)
 {
-       unsigned char *fp;
-       int i;
-
-       /* Check if flash MAC is valid */
-       fp = (unsigned char *) 0x0201c000;
-       for (i = 0; (i < 6); i++) {
-               if ((fp[i] != 0) && (fp[i] != 0xff))
-                       break;
-       }
-
-       /* If we found a valid looking MAC address then use it

*/

drivers/net/ks8695eth.c +2 -2
-       if (i < 6)
-               memcpy(&eth_mac[0], fp, 6);
+       /* Set MAC address */
+       ks8695_write(KS8695_LAN_MAC_LOW, (dev->enetaddr[5] |

(dev->enetaddr[4] << 8) |
+ (dev->enetaddr[3] << 16) | (dev->enetaddr[2] <<
24)));
+ ks8695_write(KS8695_LAN_MAC_HIGH, (dev->enetaddr[1] |
(dev->enetaddr[0] << 8)));

drivers/net/ks8695eth.c +1 -0
+       return 0;
 }
 
 /****************************************************************************/
@@ -109,12 +92,8 @@ static int ks8695_eth_init(struct eth_device
 *dev, bd_t *bd) ks8695_write(KS8695_LAN_DMA_TX, 0x80000000);
        ks8695_write(KS8695_LAN_DMA_RX, 0x80000000);
 
Quoted 12 lines
Quoted 9 lines
drivers/net/ks8695eth.c +0 -3
-       ks8695_getmac();
-
        /* Set MAC address */
-       ks8695_write(KS8695_LAN_MAC_LOW, (eth_mac[5] |

(eth_mac[4] << 8) |

drivers/net/ks8695eth.c +0 -2
-               (eth_mac[3] << 16) | (eth_mac[2] << 24)));
-       ks8695_write(KS8695_LAN_MAC_HIGH, (eth_mac[1] |

(eth_mac[0] << 8)));
+ ks8695_set_mac_address(dev);

Why do you set the MAC address here? It should be set for you by the network infrastructure without this call.

Quoted 33 lines

Simply because I was not aware of this at the time. Before the changes here the generic infrastructure could not do it, as write_hwaddr was unimplemented, and I was just trying to preserve function. The main reason I started poking at the network driver was that it loaded the MAC from a hardcoded address in ROM, obviously board specific (this is the magic number in [PATCH 11/11]
arm: cm4008, cm41xx: read MAC address from flash). It also has a bug where it stops working after one command (i.e. can't tftp twice), which I have not tracked down as yet.

Quoted 23 lines
Quoted 20 lines
        /* Turn the 4 port switch on */
        i = ks8695_read(KS8695_SWITCH_CTRL0);
drivers/net/ks8695eth.c +2 -2
@@ -150,7 +129,7 @@ static int ks8695_eth_init(struct eth_device
 *dev, bd_t *bd) ks8695_write(KS8695_LAN_DMA_RX, 0x71);
        ks8695_write(KS8695_LAN_DMA_RX_START, 0x1);
 
-       printf("KS8695 ETHERNET: %pM\n", eth_mac);
+       printf("KS8695 ETHERNET: %pM\n", dev->enetaddr);
        return 0;
 }
 
@@ -234,6 +213,7 @@ int ks8695_eth_initialize(void)
        dev->halt = ks8695_eth_halt;
        dev->send = ks8695_eth_send;
        dev->recv = ks8695_eth_recv;
+       dev->write_hwaddr = ks8695_set_mac_address;
        strcpy(dev->name, "ks8695eth");
 
        eth_register(dev);
--
Quoted 1 line

1.7.10.4

-Joe

Quoted 4 lines

What is the status for this patch? Are you going to drop it or submit a new version?

Amicalement,

After some testing, I can conclude that removing the call to set_mac_address actually breaks this code. This is because the first section of ks8695_eth_init sets a reset bit, which resets all register values including the MAC address. The debug message shows that this has at some point been in an eth_reset() subroutine. The same reset bit is set in ks8695_eth_halt(), which is why Linux does not see the MAC address set by u-boot.

At this point, I do not know of a better approach than the patch as submitted. Advice is welcome.

#23 lore raw

PATCH 3/11 arm: ks8695eth: Use MAC address from environment

Hi Yann,

Quoted 133 lines · Yann Vernier
Quoted 117 lines · On Fri, 26 Oct 2012 23:37:28 +0200 Albert ARIBAUD <[email protected]>…

Hi Yann,

Quoted 78 lines · Yann Vernier
Quoted 62 lines · On Thu, 18 Oct 2012 15:55:31 -0500 Joe Hershberger <[email protected]>…

Hi Yann,

Quoted 58 lines · Yann Vernier

Removed board specific MAC reading code from driver. Should move the reading to the cm4008/cm41xx board code.

---
 drivers/net/ks8695eth.c |   38

+++++++++----------------------------- 1 file changed, 9 insertions(+), 29 deletions(-)

drivers/net/ks8695eth.c +0 -0
index b4904b6..2dda7ab 100644
@@ -71,30 +71,13 @@ volatile uint8_t

ks8695_bufs[BUFSIZE*(TXDESCS+RXDESCS)] __attribute__((aligned(2

/****************************************************************************/

-/*
- * Ideally we want to use the MAC address stored in flash.
- * But we do some sanity checks in case they are not
present
- * first.
- */

drivers/net/ks8695eth.c +1 -16
-unsigned char eth_mac[] = {
-       0x00, 0x13, 0xc6, 0x00, 0x00, 0x00
-};
-
-void ks8695_getmac(void)
+static int ks8695_set_mac_address(struct eth_device *dev)
 {
-       unsigned char *fp;
-       int i;
-
-       /* Check if flash MAC is valid */
-       fp = (unsigned char *) 0x0201c000;
-       for (i = 0; (i < 6); i++) {
-               if ((fp[i] != 0) && (fp[i] != 0xff))
-                       break;
-       }
-
-       /* If we found a valid looking MAC address then use it

*/

drivers/net/ks8695eth.c +2 -2
-       if (i < 6)
-               memcpy(&eth_mac[0], fp, 6);
+       /* Set MAC address */
+       ks8695_write(KS8695_LAN_MAC_LOW, (dev->enetaddr[5] |

(dev->enetaddr[4] << 8) |
+ (dev->enetaddr[3] << 16) | (dev->enetaddr[2] <<
24)));
+ ks8695_write(KS8695_LAN_MAC_HIGH, (dev->enetaddr[1] |
(dev->enetaddr[0] << 8)));

drivers/net/ks8695eth.c +1 -0
+       return 0;
 }
 
 /****************************************************************************/
@@ -109,12 +92,8 @@ static int ks8695_eth_init(struct eth_device
 *dev, bd_t *bd) ks8695_write(KS8695_LAN_DMA_TX, 0x80000000);
        ks8695_write(KS8695_LAN_DMA_RX, 0x80000000);
 
Quoted 12 lines
Quoted 9 lines
drivers/net/ks8695eth.c +0 -3
-       ks8695_getmac();
-
        /* Set MAC address */
-       ks8695_write(KS8695_LAN_MAC_LOW, (eth_mac[5] |

(eth_mac[4] << 8) |

drivers/net/ks8695eth.c +0 -2
-               (eth_mac[3] << 16) | (eth_mac[2] << 24)));
-       ks8695_write(KS8695_LAN_MAC_HIGH, (eth_mac[1] |

(eth_mac[0] << 8)));
+ ks8695_set_mac_address(dev);

Why do you set the MAC address here? It should be set for you by the network infrastructure without this call.

Quoted 33 lines

Simply because I was not aware of this at the time. Before the changes here the generic infrastructure could not do it, as write_hwaddr was unimplemented, and I was just trying to preserve function. The main reason I started poking at the network driver was that it loaded the MAC from a hardcoded address in ROM, obviously board specific (this is the magic number in [PATCH 11/11]
arm: cm4008, cm41xx: read MAC address from flash). It also has a bug where it stops working after one command (i.e. can't tftp twice), which I have not tracked down as yet.

Quoted 23 lines
Quoted 20 lines
        /* Turn the 4 port switch on */
        i = ks8695_read(KS8695_SWITCH_CTRL0);
drivers/net/ks8695eth.c +2 -2
@@ -150,7 +129,7 @@ static int ks8695_eth_init(struct eth_device
 *dev, bd_t *bd) ks8695_write(KS8695_LAN_DMA_RX, 0x71);
        ks8695_write(KS8695_LAN_DMA_RX_START, 0x1);
 
-       printf("KS8695 ETHERNET: %pM\n", eth_mac);
+       printf("KS8695 ETHERNET: %pM\n", dev->enetaddr);
        return 0;
 }
 
@@ -234,6 +213,7 @@ int ks8695_eth_initialize(void)
        dev->halt = ks8695_eth_halt;
        dev->send = ks8695_eth_send;
        dev->recv = ks8695_eth_recv;
+       dev->write_hwaddr = ks8695_set_mac_address;
        strcpy(dev->name, "ks8695eth");
 
        eth_register(dev);
--
Quoted 1 line

1.7.10.4

-Joe

Quoted 4 lines

What is the status for this patch? Are you going to drop it or submit a new version?

Amicalement,

After some testing, I can conclude that removing the call to set_mac_address actually breaks this code. This is because the first section of ks8695_eth_init sets a reset bit, which resets all register values including the MAC address. The debug message shows that this has at some point been in an eth_reset() subroutine. The same reset bit is set in ks8695_eth_halt(), which is why Linux does not see the MAC address set by u-boot.

Quoted 2 lines

At this point, I do not know of a better approach than the patch as submitted. Advice is welcome.

It seems to me you should not be resetting, or if you must then I guess what you have here is best. In that case, though, you should also be writing the MAC address in halt. It doesn't sound like good behavior that if you use Ethernet in u-boot, that you get no MAC address in Linux.

-Joe

#24 lore raw

PATCH 4/11 arm: cm4008, cm41xx: use common cfi_flash support

In reply to Yann Vernier

This change allows use of other flash chips than the two supported by the cm4008 flash.c. Tested with Micrel KSZ8695X demo board.
---
Changes for v2:
- Update cm41xx also
- Remove unused board specific flash code
Changes for v3:
- Do not define to 1 where it is not required, just define
Changes for v4:
- Define flash bank characteristics (for big constant cleanup)
- Poll status for AMD flash (as on KS8695X demo board)

---
 board/cm4008/Makefile    |    2 +-
 board/cm4008/flash.c     |  410 ----------------------------------------------
 board/cm41xx/Makefile    |    2 +-
 board/cm41xx/flash.c     |  410 ----------------------------------------------
 include/configs/cm4008.h |   17 +-
 include/configs/cm41xx.h |   23 ++-
 6 files changed, 36 insertions(+), 828 deletions(-)
board/cm4008/Makefile +1 -1
index 5b98824..dac422b 100644
@@ -25,7 +25,7 @@ include $(TOPDIR)/config.mk
 
 LIB	= $(obj)lib$(BOARD).o
 
-COBJS	:= cm4008.o flash.o
+COBJS	:= cm4008.o
 
 SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
 OBJS	:= $(addprefix $(obj),$(COBJS))
board/cm4008/flash.c deleted +0 -410

410 lines not on this page · raw message

board/cm41xx/Makefile +1 -1
index 6214f8c..d49fce1 100644
@@ -25,7 +25,7 @@ include $(TOPDIR)/config.mk
 
 LIB	= $(obj)lib$(BOARD).o
 
-COBJS	:= cm41xx.o flash.o
+COBJS	:= cm41xx.o
 
 SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
 OBJS	:= $(addprefix $(obj),$(COBJS))
board/cm41xx/flash.c deleted +0 -410

410 lines not on this page · raw message

include/configs/cm4008.h +14 -3
index 408e918..fe62f73 100644
@@ -116,13 +116,24 @@
 
 #define CONFIG_SYS_INIT_SP_ADDR	0x00020000 /* lowest 128k of RAM */
 
-#define PHYS_FLASH_1		0x02000000 /* Flash Bank #1 */
-#define PHYS_FLASH_SECT_SIZE    0x00020000 /* 128 KB sectors (x1) */
-#define CONFIG_SYS_FLASH_BASE		PHYS_FLASH_1
+/* CONFIG_SYS_TEXT_BASE and CONFIG_SYS_FLASH_BASE must match for both
+   relocation in lowlevel_init.S and function array in board.c */
+#define CONFIG_SYS_TEXT_BASE	0x02000000
+#define CONFIG_SYS_FLASH_BASE	CONFIG_SYS_TEXT_BASE
+#define CONFIG_SYS_RCS0_BASE	CONFIG_SYS_TEXT_BASE
+#define CONFIG_SYS_RCS0_SIZE	0x400000
+#define CONFIG_SYS_RCS1_BASE	(CONFIG_SYS_RCS0_BASE+CONFIG_SYS_RCS0_SIZE)
+#define CONFIG_SYS_RCS1_SIZE	0x400000
+
+#define CONFIG_SYS_FLASH_CFI
+#define CONFIG_FLASH_CFI_DRIVER
+#define CONFIG_SYS_FLASH_CFI_WIDTH	FLASH_CFI_8BIT
+#define CONFIG_SYS_CFI_FLASH_STATUS_POLL
 
 /*-----------------------------------------------------------------------
  * FLASH and environment organization
  */
+#define CONFIG_SYS_FLASH_BANKS_LIST	{CONFIG_SYS_RCS0_BASE, CONFIG_SYS_RCS1_BASE}
 #define CONFIG_SYS_MAX_FLASH_BANKS	2	/* max number of flash banks */
 #define CONFIG_SYS_MAX_FLASH_SECT	(128)	/* max number of sectors on one chip */
 
include/configs/cm41xx.h +20 -3
index d85a600..485792c 100644
@@ -116,13 +116,30 @@
 
 #define CONFIG_SYS_INIT_SP_ADDR	0x00020000 /* lowest 128k of RAM */
 
-#define PHYS_FLASH_1		0x02000000 /* Flash Bank #1 */
-#define PHYS_FLASH_SECT_SIZE    0x00020000 /* 128 KB sectors (x1) */
-#define CONFIG_SYS_FLASH_BASE		PHYS_FLASH_1
+/* CONFIG_SYS_TEXT_BASE and CONFIG_SYS_RCS0_BASE must match for both
+   relocation in lowlevel_init.S and function array in board.c */
+#define CONFIG_SYS_TEXT_BASE	0x02000000
+#define CONFIG_SYS_RCS0_BASE	CONFIG_SYS_TEXT_BASE
+#define CONFIG_SYS_RCS0_SIZE	0x400000
+#define CONFIG_SYS_RCS1_BASE	(CONFIG_SYS_RCS0_BASE+CONFIG_SYS_RCS0_SIZE)
+#define CONFIG_SYS_RCS1_SIZE	0x400000
+#define CONFIG_SYS_ECS0_BASE	(CONFIG_SYS_RCS1_BASE+CONFIG_SYS_RCS1_SIZE)
+#define CONFIG_SYS_ECS0_SIZE	0x400000
+#define CONFIG_SYS_ECS0_SPEED	0xb6d
+#define CONFIG_SYS_ECS0_WIDTH	KS8695_BUS_WIDTH_8
+#define CONFIG_SYS_ECS1_BASE	(CONFIG_SYS_ECS0_BASE+CONFIG_SYS_ECS0_SIZE)
+#define CONFIG_SYS_ECS1_SIZE	0x400000
+#define CONFIG_SYS_ECS1_SPEED	0xb6d
+#define CONFIG_SYS_ECS1_WIDTH	KS8695_BUS_WIDTH_8
+
+#define CONFIG_SYS_FLASH_CFI
+#define CONFIG_FLASH_CFI_DRIVER
+#define CONFIG_SYS_FLASH_CFI_WIDTH	FLASH_CFI_8BIT
 
 /*-----------------------------------------------------------------------
  * FLASH and environment organization
  */
+#define CONFIG_SYS_FLASH_BANKS_LIST	{CONFIG_SYS_RCS0_BASE, CONFIG_SYS_RCS1_BASE}
 #define CONFIG_SYS_MAX_FLASH_BANKS	2	/* max number of flash banks */
 #define CONFIG_SYS_MAX_FLASH_SECT	(128)	/* max number of sectors on one chip */
 
Signature · 1 line
1.7.10.4
#25 lore raw

PATCH 5/11 arm: cm4008, cm41xx: set gd->ram_size in dram_init

In reply to Yann Vernier

Leave dram_init_banksize to set up the bank info data. ram_size was previously uninitialized.
Also put data on SDRAM configuration in header file.

---
Changes for v2:
- Update to use CONFIG_SYS_SDRAM_ constants
- Update cm41xx also
- Map SDRAM to match configuration
Changes for v3:
- Moved SDRAM configuration to header file, in
preparation for lowlevel constant cleanup.

---
 board/cm4008/cm4008.c    |    5 +++--
 board/cm41xx/cm41xx.c    |    5 +++--
 include/configs/cm4008.h |   11 ++++++++---
 include/configs/cm41xx.h |    9 ++++++---
 4 files changed, 20 insertions(+), 10 deletions(-)
board/cm4008/cm4008.c +3 -2
index ed493a8..6c0da9a 100644
@@ -97,8 +97,9 @@ int board_init (void)
 
 int dram_init (void)
 {
-	gd->bd->bi_dram[0].start = PHYS_SDRAM_1;
-	gd->bd->bi_dram[0].size  = PHYS_SDRAM_1_SIZE;
+	/* dram_init must store complete ramsize in gd->ram_size */
+	gd->ram_size = get_ram_size((long *)CONFIG_SYS_SDRAM_BASE,
+			CONFIG_SYS_SDRAM_SIZE);
 
 	return (0);
 }
board/cm41xx/cm41xx.c +3 -2
index d9dff4e..6aef617 100644
@@ -97,8 +97,9 @@ int board_init (void)
 
 int dram_init (void)
 {
-	gd->bd->bi_dram[0].start = PHYS_SDRAM_1;
-	gd->bd->bi_dram[0].size  = PHYS_SDRAM_1_SIZE;
+	/* dram_init must store complete ramsize in gd->ram_size */
+	gd->ram_size = get_ram_size((long *)CONFIG_SYS_SDRAM_BASE,
+			CONFIG_SYS_SDRAM_SIZE);
 
 	return (0);
 }
include/configs/cm4008.h +8 -3
index fe62f73..18f7900 100644
@@ -106,13 +106,18 @@
 #define CONFIG_STACKSIZE_FIQ	(4*1024)	/* FIQ stack */
 #endif
 
+
 /*-----------------------------------------------------------------------
  * Physical Memory Map
  */
 #define CONFIG_NR_DRAM_BANKS	1	   /* we have 1 bank of DRAM */
-#define PHYS_SDRAM_1		0x00000000 /* SDRAM Bank #1 */
-#define PHYS_SDRAM_1_SIZE	0x01000000 /* 16 MB */
-#define CONFIG_SYS_SDRAM_BASE	PHYS_SDRAM_1
+#define CONFIG_SYS_SDRAM_BASE	0x00000000 /* SDRAM Bank #1 */
+#define CONFIG_SYS_SDRAM_SIZE	0x01000000 /* 16 MB */
+#define CONFIG_SYS_SDCS0_PARAMS	(KS8695_SDCON_CA_8BIT | \
+				 KS8695_SDCON_4BANK | KS8695_SDCON_D_32)
+#define CONFIG_SYS_SDRAM_RAS_CAS_DELAY	3
+#define CONFIG_SYS_SDRAM_MODE	0x033
+
 
 #define CONFIG_SYS_INIT_SP_ADDR	0x00020000 /* lowest 128k of RAM */
 
include/configs/cm41xx.h +6 -3
index 485792c..ed345b0 100644
@@ -110,9 +110,12 @@
  * Physical Memory Map
  */
 #define CONFIG_NR_DRAM_BANKS	1	   /* we have 1 bank of DRAM */
-#define PHYS_SDRAM_1		0x00000000 /* SDRAM Bank #1 */
-#define PHYS_SDRAM_1_SIZE	0x02000000 /* 32 MB */
-#define CONFIG_SYS_SDRAM_BASE	PHYS_SDRAM_1
+#define CONFIG_SYS_SDRAM_BASE	0x00000000 /* SDRAM Bank #1 */
+#define CONFIG_SYS_SDRAM_SIZE	0x02000000 /* 32 MB */
+#define CONFIG_SYS_SDCS0_PARAMS	(KS8695_SDCON_CA_8BIT | \
+				 KS8695_SDCON_4BANK | KS8695_SDCON_D_32)
+#define CONFIG_SYS_SDRAM_RAS_CAS_DELAY	3
+#define CONFIG_SYS_SDRAM_MODE	0x033
 
 #define CONFIG_SYS_INIT_SP_ADDR	0x00020000 /* lowest 128k of RAM */
 
Signature · 1 line
1.7.10.4
#26 lore raw

PATCH 6/11 arm: cm4008, cm41xx: Fix ROM relocation

In reply to Yann Vernier

Changed CONFIG_SYS_TEXT_BASE to actual address (required for board_init_f) and moved it into cm4{008,1xx}.h, along with a warning that it must match CONFIG_SYS_FLASH_BASE (since lowlevel_init relocates there).
lowlevel_init now uses CONFIG_SYS_RCS0_BASE to map ROM.
---
Changes for v2:
- Update to use CONFIG_SYS_FLASH_ constants only (no PHYS_FLASH)
- Use tabs where appropriate
- Update cm41xx also
- Explain the lowlevel_init change
Changes for v3:
- Use memory mappings per defined macros
- Change the final adjustment of lr and ip
- Verified mapping flash at 0x3000000 on KS8695X demo board

---
 arch/arm/cpu/arm920t/ks8695/lowlevel_init.S |   63 +++++++++++++++++++--------
 board/cm4008/config.mk                      |    1 -
 board/cm41xx/config.mk                      |    1 -
 3 files changed, 45 insertions(+), 20 deletions(-)
arch/arm/cpu/arm920t/ks8695/lowlevel_init.S +45 -18
index 1bba571..74579ed 100644
@@ -25,6 +25,7 @@
 #include <config.h>
 #include <version.h>
 #include <asm/arch/platform.h>
+#include <asm/arch/regvalues.h>
 
 #ifndef CONFIG_SKIP_LOWLEVEL_INIT
 
@@ -91,12 +92,31 @@ lowlevel_init:
 	 * remap the memory and flash regions. we want to end up with
 	 * ram from address 0, and flash at 32MB.
 	 */
+#if CONFIG_SYS_RCS0_BASE!=CONFIG_SYS_TEXT_BASE
+#error CONFIG_SYS_RCS0_BASE and CONFIG_SYS_TEXT_BASE must match for highflash address to work
+	/* Also needed for pointers in board_init_f() */
+#endif
+#if CONFIG_SYS_RCS0_BASE>=KS8695_IO_BASE
+#error Cannot relocate ROM past IO registers
+	/* Firstly, the IO registers are at the top supported address.
+	   Secondly, as we grow the ROM region it must not overlap the registers. */
+#endif
+#if CONFIG_SYS_RCS0_BASE&0xffff
+#error Cannot map memory to addresses not divisible by 64K
+#endif
 	ldr	r1, =(KS8695_IO_BASE+KS8695_MEM_CTRL0)
-	ldr	r2, =0xbfc00040
+	/* The default ROM mapping is at 0x0 - 0x01ffffff.
+	   Remap it to 0x0 - 0x03feffff so that it covers 0x02000000,
+	   where CONFIG_SYS_FLASH_BASE maps it, as well as 0.
+	   Relies on the limited address lines to repeat ROM images
+	   on every multiple of the real ROM size. */
+	ldr	r2, =(KS8695_MEM_RANGE(0,0x03ff0000)|(CONFIG_KS8695_ROMCON0_VALUE&0xfff))
 	str	r2, [r1]		/* large flash map */
-	ldr	pc, =(highflash+0x02000000-0x00f00000)	/* jump to high flash address */
+	/* Relies on CONFIG_SYS_RCS0_BASE==CONFIG_SYS_TEXT_BASE */
+	ldr	pc, =(highflash)	/* jump to high flash address */
 highflash:
-	ldr	r2, =0x8fe00040
+	/* Move ROM to high address, and reconfigure to 4MiB size */
+	ldr	r2, =CONFIG_KS8695_ROMCON0_VALUE
 	str	r2, [r1]		/* remap flash range */
 
 	/*
@@ -105,28 +125,35 @@ highflash:
 	 * then you can have it all mapped nicely. Has no effect if you
 	 * only have a 4Mb or smaller flash.
 	 */
+#if CONFIG_SYS_RCS1_WIDTH
 	ldr	r1, =(KS8695_IO_BASE+KS8695_MEM_CTRL1)
-	ldr	r2, =0x9fe40040
+	ldr	r2, =CONFIG_KS8695_ROMCON1_VALUE
 	str	r2, [r1]		/* remap flash2 region, contiguous */
-	ldr	r1, =(KS8695_IO_BASE+KS8695_MEM_GENERAL)
-	ldr	r2, =0x30000005
-	str	r2, [r1]		/* enable both flash selects */
+#endif
 
-#ifdef CONFIG_CM41xx
 	/*
-	 * map the second flash chip, using the external IO lines.
+	 * map additional flash chip, using the external IO lines.
 	 */
+#if CONFIG_SYS_ECS0_WIDTH
 	ldr	r1, =(KS8695_IO_BASE+KS8695_IO_CTRL0)
-	ldr	r2, =0xafe80b6d
-	str	r2, [r1]		/* remap io0 region, contiguous */
+	ldr	r2, =CONFIG_KS8695_EXTACON0_VALUE
+	str	r2, [r1]		/* map io0 region */
+#endif
+#if CONFIG_SYS_ECS1_WIDTH
 	ldr	r1, =(KS8695_IO_BASE+KS8695_IO_CTRL1)
-	ldr	r2, =0xbfec0b6d
-	str	r2, [r1]		/* remap io1 region, contiguous */
-	ldr	r1, =(KS8695_IO_BASE+KS8695_MEM_GENERAL)
-	ldr	r2, =0x30050005
-	str	r2, [r1]		/* enable second flash */
+	ldr	r2, =CONFIG_KS8695_EXTACON1_VALUE
+	str	r2, [r1]		/* map io1 region */
+#endif
+#if CONFIG_SYS_ECS2_WIDTH
+	ldr	r1, =(KS8695_IO_BASE+KS8695_IO_CTRL2)
+	ldr	r2, =CONFIG_KS8695_EXTACON2_VALUE
+	str	r2, [r1]		/* map io2 region */
 #endif
 
+	ldr	r1, =(KS8695_IO_BASE+KS8695_MEM_GENERAL)
+	ldr	r2, =CONFIG_KS8695_ERGCON_VALUE
+	str	r2, [r1]		/* enable relevant flash selects */
+
 	/*
 	 * before relocating, we have to setup RAM timing
 	 */
@@ -198,8 +225,8 @@ highflash:
 nobutton:
 #endif
 
-	add	lr, lr, #0x02000000	/* flash is now mapped high */
-	add	ip, ip, #0x02000000	/* this is a hack */
+	add	lr, lr, #CONFIG_SYS_TEXT_BASE	/* flash is now mapped high */
+	add	ip, ip, #CONFIG_SYS_TEXT_BASE	/* this is a hack */
 	mov	pc, lr			/* all done, return */
 
 #endif /* CONFIG_SKIP_LOWLEVEL_INIT */
board/cm4008/config.mk deleted +0 -1
deleted file mode 100644
index 0d5923b..0000000
@@ -1 +0,0 @@
-CONFIG_SYS_TEXT_BASE = 0x00f00000
board/cm41xx/config.mk deleted +0 -1
deleted file mode 100644
index 0d5923b..0000000
@@ -1 +0,0 @@
-CONFIG_SYS_TEXT_BASE = 0x00f00000
Signature · 1 line
1.7.10.4
#27 lore raw

PATCH 6/11 arm: cm4008, cm41xx: Fix ROM relocation

Hi Yann,

Quoted 141 lines · Yann Vernier

Changed CONFIG_SYS_TEXT_BASE to actual address (required for board_init_f) and moved it into cm4{008,1xx}.h, along with a warning that it must match CONFIG_SYS_FLASH_BASE (since lowlevel_init relocates there).
lowlevel_init now uses CONFIG_SYS_RCS0_BASE to map ROM.
---
Changes for v2:
- Update to use CONFIG_SYS_FLASH_ constants only (no PHYS_FLASH)
- Use tabs where appropriate
- Update cm41xx also
- Explain the lowlevel_init change
Changes for v3:
- Use memory mappings per defined macros
- Change the final adjustment of lr and ip
- Verified mapping flash at 0x3000000 on KS8695X demo board

---
 arch/arm/cpu/arm920t/ks8695/lowlevel_init.S |   63 +++++++++++++++++++--------
 board/cm4008/config.mk                      |    1 -
 board/cm41xx/config.mk                      |    1 -
 3 files changed, 45 insertions(+), 20 deletions(-)
arch/arm/cpu/arm920t/ks8695/lowlevel_init.S +45 -18
index 1bba571..74579ed 100644
@@ -25,6 +25,7 @@
 #include <config.h>
 #include <version.h>
 #include <asm/arch/platform.h>
+#include <asm/arch/regvalues.h>
 
 #ifndef CONFIG_SKIP_LOWLEVEL_INIT
 
@@ -91,12 +92,31 @@ lowlevel_init:
 	 * remap the memory and flash regions. we want to end up with
 	 * ram from address 0, and flash at 32MB.
 	 */
+#if CONFIG_SYS_RCS0_BASE!=CONFIG_SYS_TEXT_BASE
+#error CONFIG_SYS_RCS0_BASE and CONFIG_SYS_TEXT_BASE must match for highflash address to work
+	/* Also needed for pointers in board_init_f() */
+#endif
+#if CONFIG_SYS_RCS0_BASE>=KS8695_IO_BASE
+#error Cannot relocate ROM past IO registers
+	/* Firstly, the IO registers are at the top supported address.
+	   Secondly, as we grow the ROM region it must not overlap the registers. */
+#endif
+#if CONFIG_SYS_RCS0_BASE&0xffff
+#error Cannot map memory to addresses not divisible by 64K
+#endif
 	ldr	r1, =(KS8695_IO_BASE+KS8695_MEM_CTRL0)
-	ldr	r2, =0xbfc00040
+	/* The default ROM mapping is at 0x0 - 0x01ffffff.
+	   Remap it to 0x0 - 0x03feffff so that it covers 0x02000000,
+	   where CONFIG_SYS_FLASH_BASE maps it, as well as 0.
+	   Relies on the limited address lines to repeat ROM images
+	   on every multiple of the real ROM size. */
+	ldr	r2, =(KS8695_MEM_RANGE(0,0x03ff0000)|(CONFIG_KS8695_ROMCON0_VALUE&0xfff))
 	str	r2, [r1]		/* large flash map */
-	ldr	pc, =(highflash+0x02000000-0x00f00000)	/* jump to high flash address */
+	/* Relies on CONFIG_SYS_RCS0_BASE==CONFIG_SYS_TEXT_BASE */
+	ldr	pc, =(highflash)	/* jump to high flash address */
 highflash:
-	ldr	r2, =0x8fe00040
+	/* Move ROM to high address, and reconfigure to 4MiB size */
+	ldr	r2, =CONFIG_KS8695_ROMCON0_VALUE
 	str	r2, [r1]		/* remap flash range */
 
 	/*
@@ -105,28 +125,35 @@ highflash:
 	 * then you can have it all mapped nicely. Has no effect if you
 	 * only have a 4Mb or smaller flash.
 	 */
+#if CONFIG_SYS_RCS1_WIDTH
 	ldr	r1, =(KS8695_IO_BASE+KS8695_MEM_CTRL1)
-	ldr	r2, =0x9fe40040
+	ldr	r2, =CONFIG_KS8695_ROMCON1_VALUE
 	str	r2, [r1]		/* remap flash2 region, contiguous */
-	ldr	r1, =(KS8695_IO_BASE+KS8695_MEM_GENERAL)
-	ldr	r2, =0x30000005
-	str	r2, [r1]		/* enable both flash selects */
+#endif
 
-#ifdef CONFIG_CM41xx
 	/*
-	 * map the second flash chip, using the external IO lines.
+	 * map additional flash chip, using the external IO lines.
 	 */
+#if CONFIG_SYS_ECS0_WIDTH
 	ldr	r1, =(KS8695_IO_BASE+KS8695_IO_CTRL0)
-	ldr	r2, =0xafe80b6d
-	str	r2, [r1]		/* remap io0 region, contiguous */
+	ldr	r2, =CONFIG_KS8695_EXTACON0_VALUE
+	str	r2, [r1]		/* map io0 region */
+#endif
+#if CONFIG_SYS_ECS1_WIDTH
 	ldr	r1, =(KS8695_IO_BASE+KS8695_IO_CTRL1)
-	ldr	r2, =0xbfec0b6d
-	str	r2, [r1]		/* remap io1 region, contiguous */
-	ldr	r1, =(KS8695_IO_BASE+KS8695_MEM_GENERAL)
-	ldr	r2, =0x30050005
-	str	r2, [r1]		/* enable second flash */
+	ldr	r2, =CONFIG_KS8695_EXTACON1_VALUE
+	str	r2, [r1]		/* map io1 region */
+#endif
+#if CONFIG_SYS_ECS2_WIDTH
+	ldr	r1, =(KS8695_IO_BASE+KS8695_IO_CTRL2)
+	ldr	r2, =CONFIG_KS8695_EXTACON2_VALUE
+	str	r2, [r1]		/* map io2 region */
 #endif
 
+	ldr	r1, =(KS8695_IO_BASE+KS8695_MEM_GENERAL)
+	ldr	r2, =CONFIG_KS8695_ERGCON_VALUE
+	str	r2, [r1]		/* enable relevant flash selects */
+
 	/*
 	 * before relocating, we have to setup RAM timing
 	 */
@@ -198,8 +225,8 @@ highflash:
 nobutton:
 #endif
 
-	add	lr, lr, #0x02000000	/* flash is now mapped high */
-	add	ip, ip, #0x02000000	/* this is a hack */
+	add	lr, lr, #CONFIG_SYS_TEXT_BASE	/* flash is now mapped high */
+	add	ip, ip, #CONFIG_SYS_TEXT_BASE	/* this is a hack */
 	mov	pc, lr			/* all done, return */
 
 #endif /* CONFIG_SKIP_LOWLEVEL_INIT */
board/cm4008/config.mk deleted +0 -1
deleted file mode 100644
index 0d5923b..0000000
@@ -1 +0,0 @@
-CONFIG_SYS_TEXT_BASE = 0x00f00000
board/cm41xx/config.mk deleted +0 -0
deleted file mode 100644
index 0d5923b..0000000

board/cm41xx/config.mk line 1

Quoted 1 line
board/cm41xx/config.mk deleted +0 -1
@@ -1 +0,0 @@
-CONFIG_SYS_TEXT_BASE = 0x00f00000

This seems to remove CONFIG_SYS_TEXT_BASE from config.mk files but does not put it elsewhere. How do the corresponding boards build once this patch is applied?

Amicalement,

Signature · 1 line
Albert.
#28 lore raw

PATCH 6/11 arm: cm4008, cm41xx: Fix ROM relocation

Quoted 168 lines · On Thu, 18 Oct 2012 21:09:07 +0200 Albert ARIBAUD <[email protected]>…

Hi Yann,

Quoted 157 lines · Yann Vernier

Changed CONFIG_SYS_TEXT_BASE to actual address (required for board_init_f) and moved it into cm4{008,1xx}.h, along with a warning that it must match CONFIG_SYS_FLASH_BASE (since lowlevel_init relocates there).
lowlevel_init now uses CONFIG_SYS_RCS0_BASE to map ROM.
---
Changes for v2:
- Update to use CONFIG_SYS_FLASH_ constants only (no PHYS_FLASH)
- Use tabs where appropriate
- Update cm41xx also
- Explain the lowlevel_init change
Changes for v3:
- Use memory mappings per defined macros
- Change the final adjustment of lr and ip
- Verified mapping flash at 0x3000000 on KS8695X demo board

---
 arch/arm/cpu/arm920t/ks8695/lowlevel_init.S |   63
+++++++++++++++++++--------
board/cm4008/config.mk                      |    1 -
board/cm41xx/config.mk                      |    1 - 3 files

changed, 45 insertions(+), 20 deletions(-)

(quoted diff) +0 -0

b/arch/arm/cpu/arm920t/ks8695/lowlevel_init.S index 1bba571..74579ed 100644 --- a/arch/arm/cpu/arm920t/ks8695/lowlevel_init.S +++ b/arch/arm/cpu/arm920t/ks8695/lowlevel_init.S @@ -25,6 +25,7 @@
#include <config.h>
#include <version.h>
#include <asm/arch/platform.h>

arch/arm/cpu/arm920t/ks8695/lowlevel_init.S +1 -0
+#include <asm/arch/regvalues.h>
 
 #ifndef CONFIG_SKIP_LOWLEVEL_INIT
@@ -91,12 +92,31 @@ lowlevel_init:
 	 * remap the memory and flash regions. we want to end up

with

arch/arm/cpu/arm920t/ks8695/lowlevel_init.S +2 -0
 	 * ram from address 0, and flash at 32MB.
 	 */
+#if CONFIG_SYS_RCS0_BASE!=CONFIG_SYS_TEXT_BASE
+#error CONFIG_SYS_RCS0_BASE and CONFIG_SYS_TEXT_BASE must match

for highflash address to work

arch/arm/cpu/arm920t/ks8695/lowlevel_init.S +5 -0
+	/* Also needed for pointers in board_init_f() */
+#endif
+#if CONFIG_SYS_RCS0_BASE>=KS8695_IO_BASE
+#error Cannot relocate ROM past IO registers
+	/* Firstly, the IO registers are at the top supported

address.

(quoted diff) +1 -0
+	   Secondly, as we grow the ROM region it must not overlap

the registers. */ +#endif

arch/arm/cpu/arm920t/ks8695/lowlevel_init.S +5 -1
+#if CONFIG_SYS_RCS0_BASE&0xffff
+#error Cannot map memory to addresses not divisible by 64K
+#endif
 	ldr	r1, =(KS8695_IO_BASE+KS8695_MEM_CTRL0)
-	ldr	r2, =0xbfc00040
+	/* The default ROM mapping is at 0x0 - 0x01ffffff.
+	   Remap it to 0x0 - 0x03feffff so that it covers

0x02000000,

arch/arm/cpu/arm920t/ks8695/lowlevel_init.S +4 -0
+	   where CONFIG_SYS_FLASH_BASE maps it, as well as 0.
+	   Relies on the limited address lines to repeat ROM images
+	   on every multiple of the real ROM size. */
+	ldr	r2,

=(KS8695_MEM_RANGE(0,0x03ff0000)|(CONFIG_KS8695_ROMCON0_VALUE&0xfff))
str r2, [r1] /* large flash map */

(quoted diff) +0 -1
-	ldr	pc,

=(highflash+0x02000000-0x00f00000) /* jump to high flash
address */

(quoted diff) +2 -0
+	/* Relies on CONFIG_SYS_RCS0_BASE==CONFIG_SYS_TEXT_BASE */
+	ldr	pc, =(highflash)	/* jump to high flash

address */ highflash:

(quoted diff) +1 -1
-	ldr	r2, =0x8fe00040
+	/* Move ROM to high address, and reconfigure to 4MiB size

*/

arch/arm/cpu/arm920t/ks8695/lowlevel_init.S +1 -0
+	ldr	r2, =CONFIG_KS8695_ROMCON0_VALUE
 	str	r2, [r1]		/* remap flash range */
 
 	/*
@@ -105,28 +125,35 @@ highflash:
 	 * then you can have it all mapped nicely. Has no effect

if you

arch/arm/cpu/arm920t/ks8695/lowlevel_init.S +2 -1
 	 * only have a 4Mb or smaller flash.
 	 */
+#if CONFIG_SYS_RCS1_WIDTH
 	ldr	r1, =(KS8695_IO_BASE+KS8695_MEM_CTRL1)
-	ldr	r2, =0x9fe40040
+	ldr	r2, =CONFIG_KS8695_ROMCON1_VALUE
 	str	r2, [r1]		/* remap flash2 region,

contiguous */

arch/arm/cpu/arm920t/ks8695/lowlevel_init.S +0 -3
-	ldr	r1, =(KS8695_IO_BASE+KS8695_MEM_GENERAL)
-	ldr	r2, =0x30000005
-	str	r2, [r1]		/* enable both flash

selects */ +#endif

arch/arm/cpu/arm920t/ks8695/lowlevel_init.S +2 -4
-#ifdef CONFIG_CM41xx
 	/*
-	 * map the second flash chip, using the external IO lines.
+	 * map additional flash chip, using the external IO lines.
 	 */
+#if CONFIG_SYS_ECS0_WIDTH
 	ldr	r1, =(KS8695_IO_BASE+KS8695_IO_CTRL0)
-	ldr	r2, =0xafe80b6d
-	str	r2, [r1]		/* remap io0 region,

contiguous */

arch/arm/cpu/arm920t/ks8695/lowlevel_init.S +4 -2
+	ldr	r2, =CONFIG_KS8695_EXTACON0_VALUE
+	str	r2, [r1]		/* map io0 region */
+#endif
+#if CONFIG_SYS_ECS1_WIDTH
 	ldr	r1, =(KS8695_IO_BASE+KS8695_IO_CTRL1)
-	ldr	r2, =0xbfec0b6d
-	str	r2, [r1]		/* remap io1 region,

contiguous */

arch/arm/cpu/arm920t/ks8695/lowlevel_init.S +0 -3
-	ldr	r1, =(KS8695_IO_BASE+KS8695_MEM_GENERAL)
-	ldr	r2, =0x30050005
-	str	r2, [r1]		/* enable second flash

*/

arch/arm/cpu/arm920t/ks8695/lowlevel_init.S +10 -0
+	ldr	r2, =CONFIG_KS8695_EXTACON1_VALUE
+	str	r2, [r1]		/* map io1 region */
+#endif
+#if CONFIG_SYS_ECS2_WIDTH
+	ldr	r1, =(KS8695_IO_BASE+KS8695_IO_CTRL2)
+	ldr	r2, =CONFIG_KS8695_EXTACON2_VALUE
+	str	r2, [r1]		/* map io2 region */
 #endif
 
+	ldr	r1, =(KS8695_IO_BASE+KS8695_MEM_GENERAL)
+	ldr	r2, =CONFIG_KS8695_ERGCON_VALUE
+	str	r2, [r1]		/* enable relevant

flash selects */ +

arch/arm/cpu/arm920t/ks8695/lowlevel_init.S +0 -1
 	/*
 	 * before relocating, we have to setup RAM timing
 	 */
@@ -198,8 +225,8 @@ highflash:
 nobutton:
 #endif
 
-	add	lr, lr, #0x02000000	/* flash is now

mapped high */

(quoted diff) +1 -1
-	add	ip, ip, #0x02000000	/* this is a hack */
+	add	lr, lr, #CONFIG_SYS_TEXT_BASE	/* flash

is now mapped high */

(quoted diff) +1 -0
+	add	ip, ip, #CONFIG_SYS_TEXT_BASE	/* this is

a hack */ mov pc, lr /* all done,
return */
#endif /* CONFIG_SKIP_LOWLEVEL_INIT */

board/cm4008/config.mk deleted +0 -1
deleted file mode 100644
index 0d5923b..0000000
@@ -1 +0,0 @@
-CONFIG_SYS_TEXT_BASE = 0x00f00000
board/cm41xx/config.mk deleted +0 -0
deleted file mode 100644
index 0d5923b..0000000

board/cm41xx/config.mk line 1

Quoted 1 line
board/cm41xx/config.mk deleted +0 -1
@@ -1 +0,0 @@
-CONFIG_SYS_TEXT_BASE = 0x00f00000

This seems to remove CONFIG_SYS_TEXT_BASE from config.mk files but does not put it elsewhere. How do the corresponding boards build once this patch is applied?

Quoted 1 line

Amicalement,

It has been moved into cm4008.h and cm41xx.h configuration headers by patch 4. Sorry for the messy separation. Before this patch, the constant did not work properly as it had to be equal to the magic 0x02000000 above (and was not).

#29 lore raw

PATCH 7/11 arm: ks8695/cm4008/cm41xx: Parameterize SDRAM

In reply to Yann Vernier

Allows configuration macros to set SDRAM parameters.

---
 arch/arm/cpu/arm920t/ks8695/lowlevel_init.S |   20 +++++++++++---------
 1 file changed, 11 insertions(+), 9 deletions(-)
arch/arm/cpu/arm920t/ks8695/lowlevel_init.S +11 -9
index 74579ed..bec9738 100644
@@ -157,19 +157,20 @@ highflash:
 	/*
 	 * before relocating, we have to setup RAM timing
 	 */
+#if CONFIG_SYS_SDCS0_PARAMS
 	ldr	r1, =(KS8695_IO_BASE+KS8695_SDRAM_CTRL0)
-#if (PHYS_SDRAM_1_SIZE == 0x02000000)
-	ldr	r2, =0x7fc0000e		/* 32MB */
-#else
-	ldr	r2, =0x3fc0000e		/* 16MB */
-#endif
+	ldr	r2, =CONFIG_KS8695_SDCON0_VALUE
 	str	r2, [r1]		/* configure sdram bank0 setup */
+#endif
+#if CONFIG_SYS_SDCS1_PARAMS
 	ldr	r1, =(KS8695_IO_BASE+KS8695_SDRAM_CTRL1)
-	mov	r2, #0
+	mov	r2, #CONFIG_KS8695_SDCON1_VALUE
 	str	r2, [r1]		/* configure sdram bank1 setup */
+#endif
 
+#if CONFIG_SYS_SDCS0_PARAMS || CONFIG_SYS_SDCS1_PARAMS
 	ldr	r1, =(KS8695_IO_BASE+KS8695_SDRAM_GENERAL)
-	ldr	r2, =0x0000000a
+	ldr	r2, =CONFIG_KS8695_SDGCON_VALUE
 	str	r2, [r1]		/* set RAS/CAS timing */
 
 	ldr	r1, =(KS8695_IO_BASE+KS8695_SDRAM_BUFFER)
@@ -184,15 +185,16 @@ highflash:
 	ldr	r2, =0x00000020
 	str	r2, [r1]		/* set for fast refresh */
 	DELAY_FOR 0x100, r0
-	ldr	r2, =0x00000190
+	ldr	r2, =CONFIG_SYS_SDRAM_REFRESH_RATE
 	str	r2, [r1]		/* set normal refresh timing */
 
 	ldr	r1, =(KS8695_IO_BASE+KS8695_SDRAM_BUFFER)
-	ldr	r2, =0x00020033
+	ldr	r2, =(0x00020000 | CONFIG_SYS_SDRAM_MODE)
 	str	r2, [r1]		/* send mode command */
 	DELAY_FOR 0x100, r0
 	ldr	r2, =0x01f00000
 	str	r2, [r1]		/* enable sdram fifos */
+#endif
 
 	/*
 	 * set pll to top speed
Signature · 1 line
1.7.10.4
#30 lore raw

PATCH 7/11 arm: ks8695/cm4008/cm41xx: Parameterize SDRAM

Hi Yann,

Quoted 10 lines · Yann Vernier

Allows configuration macros to set SDRAM parameters.

---
 arch/arm/cpu/arm920t/ks8695/lowlevel_init.S |   20 +++++++++++---------
 1 file changed, 11 insertions(+), 9 deletions(-)
arch/arm/cpu/arm920t/ks8695/lowlevel_init.S +0 -0
index 74579ed..bec9738 100644

arch/arm/cpu/arm920t/ks8695/lowlevel_init.S highflash: · line 160

Quoted 4 lines
arch/arm/cpu/arm920t/ks8695/lowlevel_init.S +1 -0
@@ -157,19 +157,20 @@ highflash:
 	/*
 	 * before relocating, we have to setup RAM timing
 	 */
+#if CONFIG_SYS_SDCS0_PARAMS

That seems a newly introduced macro, which only pertains to certain hardwares but does not entirely show it in the name, i.e. readers may wrongly conclude that any board could define CONFIG_SYS_SDCS0_PARAMS. Rename the macro to also show which SoC it refers to.

Quoted 32 lines
arch/arm/cpu/arm920t/ks8695/lowlevel_init.S +8 -8
 	ldr	r1, =(KS8695_IO_BASE+KS8695_SDRAM_CTRL0)
-#if (PHYS_SDRAM_1_SIZE == 0x02000000)
-	ldr	r2, =0x7fc0000e		/* 32MB */
-#else
-	ldr	r2, =0x3fc0000e		/* 16MB */
-#endif
+	ldr	r2, =CONFIG_KS8695_SDCON0_VALUE
 	str	r2, [r1]		/* configure sdram bank0 setup */
+#endif
+#if CONFIG_SYS_SDCS1_PARAMS
 	ldr	r1, =(KS8695_IO_BASE+KS8695_SDRAM_CTRL1)
-	mov	r2, #0
+	mov	r2, #CONFIG_KS8695_SDCON1_VALUE
 	str	r2, [r1]		/* configure sdram bank1 setup */
+#endif
 
+#if CONFIG_SYS_SDCS0_PARAMS || CONFIG_SYS_SDCS1_PARAMS
 	ldr	r1, =(KS8695_IO_BASE+KS8695_SDRAM_GENERAL)
-	ldr	r2, =0x0000000a
+	ldr	r2, =CONFIG_KS8695_SDGCON_VALUE
 	str	r2, [r1]		/* set RAS/CAS timing */
 
 	ldr	r1, =(KS8695_IO_BASE+KS8695_SDRAM_BUFFER)
@@ -184,15 +185,16 @@ highflash:
 	ldr	r2, =0x00000020
 	str	r2, [r1]		/* set for fast refresh */
 	DELAY_FOR 0x100, r0
-	ldr	r2, =0x00000190
+	ldr	r2, =CONFIG_SYS_SDRAM_REFRESH_RATE
 	str	r2, [r1]		/* set normal refresh timing */
 
 	ldr	r1, =(KS8695_IO_BASE+KS8695_SDRAM_BUFFER)

arch/arm/cpu/arm920t/ks8695/lowlevel_init.S highflash: · line 200

Quoted 10 lines
arch/arm/cpu/arm920t/ks8695/lowlevel_init.S +2 -1
-	ldr	r2, =0x00020033
+	ldr	r2, =(0x00020000 | CONFIG_SYS_SDRAM_MODE)
 	str	r2, [r1]		/* send mode command */
 	DELAY_FOR 0x100, r0
 	ldr	r2, =0x01f00000
 	str	r2, [r1]		/* enable sdram fifos */
+#endif
 
 	/*
 	 * set pll to top speed

Amicalement,

Signature · 1 line
Albert.
#31 lore raw

PATCH 8/11 arm: cm4008, cm41xx: don't define to 1

In reply to Yann Vernier

Removed needless values for configuration macros.

---
 include/configs/cm4008.h |   10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
include/configs/cm4008.h +5 -5
index 18f7900..43a2591 100644
@@ -28,14 +28,14 @@
  * High Level Configuration Options
  * (easy to change)
  */
-#define CONFIG_KS8695	1		/* it is a KS8695 CPU */
-#define CONFIG_CM4008	1		/* it is an OpenGear CM4008 boad */
+#define CONFIG_KS8695			/* it is a KS8695 CPU */
+#define CONFIG_CM4008			/* it is an OpenGear CM4008 boad */
 
 #undef CONFIG_USE_IRQ			/* we don't need IRQ/FIQ stuff	*/
 
-#define CONFIG_CMDLINE_TAG	 1	/* enable passing of ATAGs	*/
-#define CONFIG_SETUP_MEMORY_TAGS 1
-#define CONFIG_INITRD_TAG	 1
+#define CONFIG_CMDLINE_TAG		/* enable passing of ATAGs	*/
+#define CONFIG_SETUP_MEMORY_TAGS
+#define CONFIG_INITRD_TAG
 
 #define CONFIG_DRIVER_KS8695ETH		/* use KS8695 ethernet driver	*/
 
Signature · 1 line
1.7.10.4
#32 lore raw

PATCH 9/11 arm: ks8695/cm4xxx: don't reconfigure switch

In reply to Yann Vernier

A small bug caused code to set up LEDs to instead disable lots of functionality in the Ethernet switch, including bounds checks.

---
 arch/arm/cpu/arm920t/ks8695/lowlevel_init.S |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/cpu/arm920t/ks8695/lowlevel_init.S +1 -1
index bec9738..31b028b 100644
@@ -205,7 +205,7 @@ highflash:
 
 	ldr	r1, =(KS8695_IO_BASE+KS8695_SWITCH_CTRL0)
 	ldr	r2, [r1]		/* Get switch ctrl0 register       */
-	and	r2, r2, #0x0fc00000	/* Mask out LED control bits       */
+	bic	r2, r2, #0x0fc00000	/* Mask out LED control bits       */
 	orr	r2, r2, #0x01800000	/* Set Link/activity/speed actions */
 	str	r2, [r1]
 
Signature · 1 line
1.7.10.4
#33 lore raw

PATCH 9/11 arm: ks8695/cm4xxx: don't reconfigure switch

Hi Yann,

Quoted 11 lines · Yann Vernier

A small bug caused code to set up LEDs to instead disable lots of functionality in the Ethernet switch, including bounds checks.

---
 arch/arm/cpu/arm920t/ks8695/lowlevel_init.S |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/cpu/arm920t/ks8695/lowlevel_init.S +0 -0
index bec9738..31b028b 100644

arch/arm/cpu/arm920t/ks8695/lowlevel_init.S highflash: · line 211

Quoted 8 lines
arch/arm/cpu/arm920t/ks8695/lowlevel_init.S +1 -1
@@ -205,7 +205,7 @@ highflash:
 
 	ldr	r1, =(KS8695_IO_BASE+KS8695_SWITCH_CTRL0)
 	ldr	r2, [r1]		/* Get switch ctrl0 register       */
-	and	r2, r2, #0x0fc00000	/* Mask out LED control bits       */
+	bic	r2, r2, #0x0fc00000	/* Mask out LED control bits       */
 	orr	r2, r2, #0x01800000	/* Set Link/activity/speed actions */
 	str	r2, [r1]
 

Can you turn the magic numbers here into more explicit symbolic values?

Amicalement,

Signature · 1 line
Albert.
#34 lore raw

PATCH 10/11 arm: ks8695: document bus speed

In reply to Yann Vernier

Just use the existing #define instead of magic number.

---
 arch/arm/cpu/arm920t/ks8695/lowlevel_init.S |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/arm/cpu/arm920t/ks8695/lowlevel_init.S +2 -2
index 31b028b..ba37c28 100644
@@ -199,8 +199,8 @@ highflash:
 	/*
 	 * set pll to top speed
 	 */
-	ldr	r1, =(KS8695_IO_BASE+KS8695_SYSTEN_BUS_CLOCK)
-	mov	r2, #0
+	ldr	r1, =(KS8695_IO_BASE+KS8695_SYSTEM_BUS_CLOCK)
+	mov	r2, #KS8695_BUS_CLOCK_125MHZ
 	str	r2, [r1]		/* set pll clock to 166MHz */
 
 	ldr	r1, =(KS8695_IO_BASE+KS8695_SWITCH_CTRL0)
Signature · 1 line
1.7.10.4
#35 lore raw

PATCH 11/11 arm: cm4008, cm41xx: read MAC address from flash

In reply to Yann Vernier

Previously code to do this was in the Ethernet driver itself. Since it is board specific, moved it here, and altered it to support preset MAC from environment.

---
 board/cm4008/cm4008.c |   12 ++++++++++++
 board/cm41xx/cm41xx.c |   12 ++++++++++++
 2 files changed, 24 insertions(+)
board/cm4008/cm4008.c +12 -0
index 6c0da9a..e14f8f4 100644
@@ -75,10 +75,22 @@ int board_late_init (void)
 	return 0;
 }
 
+#ifdef CONFIG_DRIVER_KS8695ETH
 int board_eth_init(bd_t *bis)
 {
+	uchar enetaddr[6];
+	const uchar * const fp=CONFIG_SYS_FLASH_BASE+0x1c000;
+
+	/* read MAC address from flash */
+	if (!eth_getenv_enetaddr("ethaddr", enetaddr)) {
+		memcpy(&enetaddr[0], fp, 6);
+		if (is_valid_ether_addr(enetaddr))
+			eth_setenv_enetaddr("ethaddr", enetaddr);
+	}
+
 	return ks8695_eth_initialize();
 }
+#endif
 
 int board_init (void)
 {
board/cm41xx/cm41xx.c +12 -0
index 6aef617..771701d 100644
@@ -75,10 +75,22 @@ int board_late_init (void)
 	return 0;
 }
 
+#ifdef CONFIG_DRIVER_KS8695ETH
 int board_eth_init(bd_t *bis)
 {
+	uchar enetaddr[6];
+	const uchar * const fp=CONFIG_SYS_FLASH_BASE+0x1c000;
+
+	/* read MAC address from flash */
+	if (!eth_getenv_enetaddr("ethaddr", enetaddr)) {
+		memcpy(&enetaddr[0], fp, 6);
+		if (is_valid_ether_addr(enetaddr))
+			eth_setenv_enetaddr("ethaddr", enetaddr);
+	}
+
 	return ks8695_eth_initialize();
 }
+#endif
 
 int board_init (void)
 {
Signature · 1 line
1.7.10.4
#36 lore raw

PATCH 11/11 arm: cm4008, cm41xx: read MAC address from flash

Hi Yann,

Quoted 40 lines · Yann Vernier

Previously code to do this was in the Ethernet driver itself. Since it is board specific, moved it here, and altered it to support preset MAC from environment.

---
 board/cm4008/cm4008.c |   12 ++++++++++++
 board/cm41xx/cm41xx.c |   12 ++++++++++++
 2 files changed, 24 insertions(+)
board/cm4008/cm4008.c +12 -0
index 6c0da9a..e14f8f4 100644
@@ -75,10 +75,22 @@ int board_late_init (void)
 	return 0;
 }
 
+#ifdef CONFIG_DRIVER_KS8695ETH
 int board_eth_init(bd_t *bis)
 {
+	uchar enetaddr[6];
+	const uchar * const fp=CONFIG_SYS_FLASH_BASE+0x1c000;
+
+	/* read MAC address from flash */
+	if (!eth_getenv_enetaddr("ethaddr", enetaddr)) {
+		memcpy(&enetaddr[0], fp, 6);
+		if (is_valid_ether_addr(enetaddr))
+			eth_setenv_enetaddr("ethaddr", enetaddr);
+	}
+
 	return ks8695_eth_initialize();
 }
+#endif
 
 int board_init (void)
 {
board/cm41xx/cm41xx.c +0 -0
index 6aef617..771701d 100644

board/cm41xx/cm41xx.c int board_late_init (void) · line 82

Quoted 8 lines
board/cm41xx/cm41xx.c +3 -0
@@ -75,10 +75,22 @@ int board_late_init (void)
 	return 0;
 }
 
+#ifdef CONFIG_DRIVER_KS8695ETH
 int board_eth_init(bd_t *bis)
 {
+	uchar enetaddr[6];
+	const uchar * const fp=CONFIG_SYS_FLASH_BASE+0x1c000;

Magic number here.

Quoted 4 lines
board/cm41xx/cm41xx.c +4 -0
+
+	/* read MAC address from flash */
+	if (!eth_getenv_enetaddr("ethaddr", enetaddr)) {
+		memcpy(&enetaddr[0], fp, 6);

board/cm41xx/cm41xx.c int board_late_init (void) · line 96

Quoted 10 lines
board/cm41xx/cm41xx.c +5 -0
+		if (is_valid_ether_addr(enetaddr))
+			eth_setenv_enetaddr("ethaddr", enetaddr);
+	}
+
 	return ks8695_eth_initialize();
 }
+#endif
 
 int board_init (void)
 {

Amicalement,

Signature · 1 line
Albert.
#37 lore raw

cover ks8695 (cm4008, cm41xx) bugfixes, constant removals, configuration generalized (repost)

In reply to Yann Vernier

Hi Yann,

Quoted 7 lines · Yann Vernier
Quoted 4 lines · On Thu, 4 Oct 2012 11:15:06 +0200 Albert ARIBAUD <[email protected]>…

Sorry it took me so long to crawl my backlog... This series was posted with long lines folded apparently, which makes it impossible to process and explains why patchwork did not have all of it. Can you please repost it, this time using 'git send-email'?

Quoted 5 lines

Terribly sorry. This should fix that problem.
In the meantime, work on our board progresses nicely, and we plan to submit it after registering a machine ID. We have u-boot support for PCI, FPGA configuration, and I2C for power control working, the latter two via GPIO.

There were several comments on this series, but I haven't seen any V2 for it. Did I miss it?

Amicalement,

Signature · 1 line
Albert.
#38 lore raw

cover ks8695 (cm4008, cm41xx) bugfixes, constant removals, configuration generalized (repost)

Quoted 18 lines · On Sat, 10 Nov 2012 09:03:32 +0100 Albert ARIBAUD <[email protected]>…

Hi Yann,

Quoted 7 lines · Yann Vernier
Quoted 4 lines · On Thu, 4 Oct 2012 11:15:06 +0200 Albert ARIBAUD <[email protected]>…

Sorry it took me so long to crawl my backlog... This series was posted with long lines folded apparently, which makes it impossible to process and explains why patchwork did not have all of it. Can you please repost it, this time using 'git send-email'?

Quoted 5 lines

Terribly sorry. This should fix that problem.
In the meantime, work on our board progresses nicely, and we plan to submit it after registering a machine ID. We have u-boot support for PCI, FPGA configuration, and I2C for power control working, the latter two via GPIO.

Quoted 4 lines

There were several comments on this series, but I haven't seen any V2 for it. Did I miss it?

Amicalement,

Sorry, I have not yet made it. I do intend to correct the patches but we got a high priority job in between.

#39 lore raw

PATCH 1/11 arm: ks8695: use defined constants for UART

In reply to Albert ARIBAUD

CONFIG_BAUDRATE and KS8695_UART_LINEC_WLEN8 used for UART registers

---
 arch/arm/cpu/arm920t/ks8695/lowlevel_init.S |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
(quoted diff) +0 -0

b/arch/arm/cpu/arm920t/ks8695/lowlevel_init.S index e9f1227..1bba571 100644 --- a/arch/arm/cpu/arm920t/ks8695/lowlevel_init.S +++ b/arch/arm/cpu/arm920t/ks8695/lowlevel_init.S
@@ -72,10 +72,10 @@ lowlevel_init:
* enable UART for early debug trace
*/
ldr r1, =(KS8695_IO_BASE+KS8695_UART_DIVISOR)
- mov r2, #0xd9
- str r2, [r1] /* 115200 baud */
+ mov r2, #((25000000+CONFIG_BAUDRATE/2) /
CONFIG_BAUDRATE)
+ str r2, [r1]
ldr r1, =(KS8695_IO_BASE+KS8695_UART_LINE_CTRL)
- mov r2, #0x03
+ mov r2, #KS8695_UART_LINEC_WLEN8
str r2, [r1] /* 8 data bits, no parity,
1 stop */ ldr r1, =(KS8695_IO_BASE+KS8695_UART_TX_HOLDING)
mov r2, #0x41

Signature · 1 line
1.7.10.4
#40 lore raw

PATCH 2/11 arm: ks8695: more macros for register values

In reply to Albert ARIBAUD

Adding macros for more configurable lowlevel_init code. Also cleanup of some typos.

---
 arch/arm/include/asm/arch-ks8695/platform.h  |   55 ++++++++-----
 arch/arm/include/asm/arch-ks8695/regvalues.h |  112

++++++++++++++++++++++++++ 2 files changed, 149 insertions(+), 18 deletions(-) create mode 100644 arch/arm/include/asm/arch-ks8695/regvalues.h

(quoted diff) +0 -0

b/arch/arm/include/asm/arch-ks8695/platform.h index de20015..0ed0ecb 100644 --- a/arch/arm/include/asm/arch-ks8695/platform.h +++ b/arch/arm/include/asm/arch-ks8695/platform.h
@@ -13,8 +13,8 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA */
-#ifndef __address_h
-#define __address_h 1
+#ifndef __ASM_ARM_ARCH_PLATFORM_H__
+#define __ASM_ARM_ARCH_PLATFORM_H__

#define KS8695_SDRAM_START 0x00000000
#define KS8695_SDRAM_SIZE 0x01000000
@@ -27,19 +27,19 @@
#define KS8695_IO_BASE 0x03FF0000
#define KS8695_IO_SIZE 0x00010000

-#define KS8695_SYSTEN_CONFIG 0x00
-#define KS8695_SYSTEN_BUS_CLOCK 0x04
+#define KS8695_SYSTEM_CONFIG 0x00
+#define KS8695_SYSTEM_BUS_CLOCK 0x04

#define KS8695_FLASH_START 0x02800000
#define KS8695_FLASH_SIZE 0x00400000

-/*i/o control registers offset difinitions*/
+/*i/o control register offset definitions*/

 #define KS8695_IO_CTRL0		    0x4000
 #define KS8695_IO_CTRL1		    0x4004
 #define KS8695_IO_CTRL2		    0x4008
 #define KS8695_IO_CTRL3		    0x400C

-/*memory control registers offset difinitions*/
+/*memory control register offset definitions*/

 #define KS8695_MEM_CTRL0	    0x4010
 #define KS8695_MEM_CTRL1	    0x4014
 #define KS8695_MEM_CTRL2	    0x4018

@@ -51,7 +51,7 @@
#define KS8695_SDRAM_BUFFER 0x403C
#define KS8695_SDRAM_REFRESH 0x4040

-/*WAN control registers offset difinitions*/
+/*WAN control register offset definitions*/
#define KS8695_WAN_DMA_TX 0x6000
#define KS8695_WAN_DMA_RX 0x6004
#define KS8695_WAN_DMA_TX_START 0x6008
@@ -63,7 +63,7 @@
#define KS8695_WAN_MAC_ELOW 0x6080
#define KS8695_WAN_MAC_EHIGH 0x6084

-/*LAN control registers offset difinitions*/
+/*LAN control register offset definitions*/
#define KS8695_LAN_DMA_TX 0x8000
#define KS8695_LAN_DMA_RX 0x8004
#define KS8695_LAN_DMA_TX_START 0x8008
@@ -75,7 +75,7 @@
#define KS8695_LAN_MAC_ELOW 0X8080
#define KS8695_LAN_MAC_EHIGH 0X8084

-/*HPNA control registers offset difinitions*/
+/*HPNA control register offset definitions*/
#define KS8695_HPNA_DMA_TX 0xA000
#define KS8695_HPNA_DMA_RX 0xA004
#define KS8695_HPNA_DMA_TX_START 0xA008
@@ -87,7 +87,7 @@
#define KS8695_HPNA_MAC_ELOW 0xA080
#define KS8695_HPNA_MAC_EHIGH 0xA084

-/*UART control registers offset difinitions*/
+/*UART control register offset definitions*/
#define KS8695_UART_RX_BUFFER 0xE000
#define KS8695_UART_TX_HOLDING 0xE004

@@ -133,7 +133,7 @@
#define KS8695_UART_DIVISOR 0xE01C
#define KS8695_UART_STATUS 0xE020

-/*Interrupt controlller registers offset difinitions*/ +/*Interrupt controller register offset definitions*/
#define KS8695_INT_CONTL 0xE200
#define KS8695_INT_ENABLE 0xE204
#define KS8695_INT_ENABLE_MODEM 0x0800
@@ -154,19 +154,19 @@
#define KS8695_FIQ_PEND_PRIORITY 0xE230
#define KS8695_IRQ_PEND_PRIORITY 0xE234

-/*timer registers offset difinitions*/
+/*timer register offset definitions*/
#define KS8695_TIMER_CTRL 0xE400
#define KS8695_TIMER1 0xE404
#define KS8695_TIMER0 0xE408
#define KS8695_TIMER1_PCOUNT 0xE40C
#define KS8695_TIMER0_PCOUNT 0xE410

-/*GPIO registers offset difinitions*/
+/*GPIO register offset definitions*/

 #define KS8695_GPIO_MODE	    0xE600
 #define KS8695_GPIO_CTRL	    0xE604
 #define KS8695_GPIO_DATA	    0xE608

-/*SWITCH registers offset difinitions*/
+/*SWITCH register offset definitions*/

 #define KS8695_SWITCH_CTRL0	    0xE800
 #define KS8695_SWITCH_CTRL1	    0xE804
 #define KS8695_SWITCH_PORT1	    0xE808

@@ -184,13 +184,13 @@
#define KS8695_SWITCH_LPPM12 0xE874
#define KS8695_SWITCH_LPPM34 0xE878

-/*host communication registers difinitions*/
+/*host communication register definitions*/
#define KS8695_DSCP_HIGH 0xE834
#define KS8695_DSCP_LOW 0xE838
#define KS8695_SWITCH_MAC_HIGH 0xE83C
#define KS8695_SWITCH_MAC_LOW 0xE840

-/*miscellaneours registers difinitions*/
+/*miscellaneous register definitions*/
#define KS8695_MANAGE_COUNTER 0xE844
#define KS8695_MANAGE_DATA 0xE848
#define KS8695_LAN12_POWERMAGR 0xE84C
@@ -205,7 +205,7 @@
#define KS8695_WAN_PHY_CONTROL 0xEA14
#define KS8695_WAN_PHY_STATUS 0xEA18

-/* bus clock definitions*/
+/* bus clock definitions for KS8695_SYSTEM_BUS_CLOCK */
#define KS8695_BUS_CLOCK_125MHZ 0x0
#define KS8695_BUS_CLOCK_100MHZ 0x1
#define KS8695_BUS_CLOCK_62MHZ 0x2
@@ -215,8 +215,27 @@
#define KS8695_BUS_CLOCK_31MHZ 0x6
#define KS8695_BUS_CLOCK_25MHZ 0x7

+/* bus width definitions for KS8695_MEM_GENERAL and SDRAM_CTRL */
+#define KS8695_BUS_WIDTH_OFF 0
+#define KS8695_BUS_WIDTH_8 1
+#define KS8695_BUS_WIDTH_16 2
+#define KS8695_BUS_WIDTH_32 3
+
+/* register value definitions for memory controller */
+#define KS8695_SDCON_D_OFF (KS8695_BUS_WIDTH_OFF<<1)
+#define KS8695_SDCON_D_8 (KS8695_BUS_WIDTH_8<<1)
+#define KS8695_SDCON_D_16 (KS8695_BUS_WIDTH_16<<1)
+#define KS8695_SDCON_D_32 (KS8695_BUS_WIDTH_32<<1)
+#define KS8695_SDCON_2BANK 0x000
+#define KS8695_SDCON_4BANK 0x008
+#define KS8695_SDCON_CA_8BIT 0x000
+#define KS8695_SDCON_CA_9BIT 0x100
+#define KS8695_SDCON_CA_10BIT 0x200
+#define KS8695_SDCON_CA_11BIT 0x300
+#define KS8695_MEM_RANGE(BASE,SIZE) (((BASE)&0x03ff0000)>>(16-12) | (((BASE)+(SIZE)-1)&0x03ff0000)<<(22-16)) +
/*
-------------------------------------------------------------------------------
- * definations for IRQ
+ * definitions for IRQ
*
-------------------------------------------------------------------------------*/
#define KS8695_INT_EXT_INT0 2

(quoted diff) +0 -0

b/arch/arm/include/asm/arch-ks8695/regvalues.h new file mode 100644 index 0000000..7d29bbf

arch/arm/include/asm/arch-ks8695/regvalues.h new file +14 -0
@@ -0,0 +1,112 @@
+/*
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	 See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA

02111-1307 USA
+ */
+#ifndef __ASM_ARM_ARCH_REGVALUES_H__
+#define __ASM_ARM_ARCH_REGVALUES_H__
+
+/* This file calculates register values set by low level initialization code
+ from configuration macros */
+
+#define CONFIG_SYS_SDCS0_BASE CONFIG_SYS_SDRAM_BASE
+#define CONFIG_SYS_SDCS0_SIZE CONFIG_SYS_SDRAM_SIZE
+
+#ifndef CONFIG_SYS_RCS0_SPEED
+/* access cycle time 5tmult+6, normal ROM (no pages) */
+# define CONFIG_SYS_RCS0_SPEED 0x040
+#endif
+#ifndef CONFIG_SYS_RCS0_WIDTH
+# define CONFIG_SYS_RCS0_WIDTH KS8695_BUS_WIDTH_8
+#endif
+
+#ifdef CONFIG_SYS_RCS1_BASE
+# ifndef CONFIG_SYS_RCS1_WIDTH
+# define CONFIG_SYS_RCS1_WIDTH CONFIG_SYS_RCS0_WIDTH
+# endif
+# ifndef CONFIG_SYS_RCS1_SPEED
+# define CONFIG_SYS_RCS1_SPEED CONFIG_SYS_RCS0_SPEED
+# endif
+#else
+# define CONFIG_SYS_RCS1_WIDTH KS8695_BUS_WIDTH_OFF +#endif
+
+#ifndef CONFIG_SYS_ECS0_WIDTH
+# define CONFIG_SYS_ECS0_WIDTH KS8695_BUS_WIDTH_OFF +#endif
+#ifndef CONFIG_SYS_ECS1_WIDTH
+# define CONFIG_SYS_ECS1_WIDTH KS8695_BUS_WIDTH_OFF +#endif
+#ifndef CONFIG_SYS_ECS2_WIDTH
+# define CONFIG_SYS_ECS2_WIDTH KS8695_BUS_WIDTH_OFF +#endif
+
+#ifndef CONFIG_KS8695_TMULT
+# define CONFIG_KS8695_TMULT 3
+#endif
+
+#if CONFIG_SYS_SDCS0_PARAMS
+# ifndef CONFIG_SYS_SDCS0_BASE
+# define CONFIG_SYS_SDCS0_BASE CONFIG_SYS_SDRAM_BASE
+# define CONFIG_SYS_SDCS0_SIZE CONFIG_SYS_SDRAM_SIZE
+# endif
+#endif
+
+#define
CONFIG_KS8695_ROMCON0_VALUE \
+ (CONFIG_SYS_RCS0_SPEED
| \
+ KS8695_MEM_RANGE(CONFIG_SYS_RCS0_BASE,CONFIG_SYS_RCS0_SIZE))
+#define
CONFIG_KS8695_ROMCON1_VALUE \
+ (CONFIG_SYS_RCS1_SPEED
| \
+ KS8695_MEM_RANGE(CONFIG_SYS_RCS1_BASE,CONFIG_SYS_RCS1_SIZE))
+#define
CONFIG_KS8695_EXTACON0_VALUE \
+ (CONFIG_SYS_ECS0_SPEED
| \
+ KS8695_MEM_RANGE(CONFIG_SYS_ECS0_BASE,CONFIG_SYS_ECS0_SIZE))
+#define
CONFIG_KS8695_EXTACON1_VALUE \
+ (CONFIG_SYS_ECS1_SPEED
| \
+ KS8695_MEM_RANGE(CONFIG_SYS_ECS1_BASE,CONFIG_SYS_ECS1_SIZE))
+#define
CONFIG_KS8695_EXTACON2_VALUE \
+ (CONFIG_SYS_ECS2_SPEED
| \
+ KS8695_MEM_RANGE(CONFIG_SYS_ECS2_BASE,CONFIG_SYS_ECS2_SIZE))
+
+#define
CONFIG_KS8695_SDCON0_VALUE \
+ (CONFIG_SYS_SDCS0_PARAMS
| \
+ KS8695_MEM_RANGE(CONFIG_SYS_SDCS0_BASE,CONFIG_SYS_SDCS0_SIZE))
+#define
CONFIG_KS8695_SDCON1_VALUE \
+ (CONFIG_SYS_SDCS1_PARAMS
| \
+ KS8695_MEM_RANGE(CONFIG_SYS_SDCS1_BASE,CONFIG_SYS_SDCS1_SIZE))
+
+#if CONFIG_SYS_SDRAM_RAS_CAS_DELAY<1 || CONFIG_SYS_SDRAM_RAS_CAS_DELAY>4 +#error Unsupported SDRAM timing: RAS to CAS delay +#endif
+#ifndef CONFIG_SYS_SDRAM_CAS_LATENCY
+#define CONFIG_SYS_SDRAM_CAS_LATENCY ((CONFIG_SYS_SDRAM_MODE>>4)&7) +#endif
+#if CONFIG_SYS_SDRAM_CAS_LATENCY<1 || CONFIG_SYS_SDRAM_CAS_LATENCY>4 +#error Unsupported SDRAM timing: CAS latency
+#endif
+#define CONFIG_KS8695_SDGCON_VALUE \
+ ((CONFIG_SYS_SDRAM_RAS_CAS_DELAY-1)<<2 | \
+ (CONFIG_SYS_SDRAM_CAS_LATENCY-1))
+#ifndef CONFIG_SYS_SDRAM_REFRESH_RATE
+#define CONFIG_SYS_SDRAM_REFRESH_RATE 0x0190
+#endif
+
+
+#define CONFIG_KS8695_ERGCON_VALUE
(CONFIG_KS8695_TMULT<<28 | \
+
CONFIG_SYS_ECS2_WIDTH<<20 | \
+
CONFIG_SYS_ECS1_WIDTH<<18 | \
+
CONFIG_SYS_ECS0_WIDTH<<16 | \
+
CONFIG_SYS_RCS1_WIDTH<<2 | \
+ CONFIG_SYS_RCS0_WIDTH)
+
+#endif

Signature · 1 line
1.7.10.4
#41 lore raw

PATCH 3/11 arm: ks8695eth: Use MAC address from environment

In reply to Albert ARIBAUD

Removed board specific MAC reading code from driver. Should move the reading to the cm4008/cm41xx board code.

---
 drivers/net/ks8695eth.c |   38 +++++++++-----------------------------
 1 file changed, 9 insertions(+), 29 deletions(-)
drivers/net/ks8695eth.c +0 -0
index b4904b6..2dda7ab 100644
@@ -71,30 +71,13 @@ volatile uint8_t

ks8695_bufs[BUFSIZE*(TXDESCS+RXDESCS)] __attribute__((aligned(2
/****************************************************************************/

-/*
- * Ideally we want to use the MAC address stored in flash.
- * But we do some sanity checks in case they are not present
- * first.
- */
-unsigned char eth_mac[] = {
- 0x00, 0x13, 0xc6, 0x00, 0x00, 0x00
-};
-
-void ks8695_getmac(void)
+static int ks8695_set_mac_address(struct eth_device *dev)
{
- unsigned char *fp;
- int i;
-
- /* Check if flash MAC is valid */
- fp = (unsigned char *) 0x0201c000;
- for (i = 0; (i < 6); i++) {
- if ((fp[i] != 0) && (fp[i] != 0xff))
- break;
- }
-
- /* If we found a valid looking MAC address then use it */
- if (i < 6)
- memcpy(&eth_mac[0], fp, 6);
+ /* Set MAC address */
+ ks8695_write(KS8695_LAN_MAC_LOW, (dev->enetaddr[5] |
(dev->enetaddr[4] << 8) |
+ (dev->enetaddr[3] << 16) | (dev->enetaddr[2] << 24)));
+ ks8695_write(KS8695_LAN_MAC_HIGH, (dev->enetaddr[1] |
(dev->enetaddr[0] << 8)));
+ return 0;
}

/****************************************************************************/
@@ -109,12 +92,8 @@ static int ks8695_eth_init(struct eth_device *dev, bd_t *bd) ks8695_write(KS8695_LAN_DMA_TX, 0x80000000);
ks8695_write(KS8695_LAN_DMA_RX, 0x80000000);

- ks8695_getmac();
-
/* Set MAC address */
- ks8695_write(KS8695_LAN_MAC_LOW, (eth_mac[5] | (eth_mac[4] <<
8) |
- (eth_mac[3] << 16) | (eth_mac[2] << 24)));
- ks8695_write(KS8695_LAN_MAC_HIGH, (eth_mac[1] | (eth_mac[0] <<
8)));
+ ks8695_set_mac_address(dev);

/* Turn the 4 port switch on */
i = ks8695_read(KS8695_SWITCH_CTRL0);
@@ -150,7 +129,7 @@ static int ks8695_eth_init(struct eth_device *dev, bd_t *bd) ks8695_write(KS8695_LAN_DMA_RX, 0x71);
ks8695_write(KS8695_LAN_DMA_RX_START, 0x1);

- printf("KS8695 ETHERNET: %pM\n", eth_mac);
+ printf("KS8695 ETHERNET: %pM\n", dev->enetaddr);
return 0;
}

@@ -234,6 +213,7 @@ int ks8695_eth_initialize(void)
dev->halt = ks8695_eth_halt; dev->send = ks8695_eth_send; dev->recv = ks8695_eth_recv;
+ dev->write_hwaddr = ks8695_set_mac_address;
strcpy(dev->name, "ks8695eth");

eth_register(dev);

Signature · 1 line
1.7.10.4
#42 lore raw

PATCH 4/11 arm: cm4008, cm41xx: use common cfi_flash support

In reply to Albert ARIBAUD

This change allows use of other flash chips than the two supported by the cm4008 flash.c. Tested with Micrel KSZ8695X demo board.
---
Changes for v2:
- Update cm41xx also
- Remove unused board specific flash code
Changes for v3:
- Do not define to 1 where it is not required, just define
Changes for v4:
- Define flash bank characteristics (for big constant cleanup)
- Poll status for AMD flash (as on KS8695X demo board)

---
 board/cm4008/Makefile    |    2 +-
 board/cm4008/flash.c     |  410

---------------------------------------------- board/cm41xx/Makefile
| 2 +- board/cm41xx/flash.c | 410
---------------------------------------------- include/configs/cm4008.h
| 17 +- include/configs/cm41xx.h | 23 ++-

 6 files changed, 36 insertions(+), 828 deletions(-)
 delete mode 100644 board/cm4008/flash.c
 delete mode 100644 board/cm41xx/flash.c
board/cm4008/Makefile +1 -1
index 5b98824..dac422b 100644
@@ -25,7 +25,7 @@ include $(TOPDIR)/config.mk
 
 LIB	= $(obj)lib$(BOARD).o
 
-COBJS	:= cm4008.o flash.o
+COBJS	:= cm4008.o
 
 SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
 OBJS	:= $(addprefix $(obj),$(COBJS))
board/cm4008/flash.c deleted +0 -34
deleted file mode 100644
index 5522bf0..0000000
@@ -1,410 +0,0 @@
-/*
- * (C) Copyright 2005
- * Greg Ungerer, OpenGear Inc, greg.ungerer at opengear.com
- *
- * (C) Copyright 2001
- * Kyle Harris, Nexus Technologies, Inc. kharris at nexus-tech.net
- *
- * (C) Copyright 2001
- * Wolfgang Denk, DENX Software Engineering, wd at denx.de.
- *
- * See file CREDITS for list of people who contributed to this
- * project.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
- * MA 02111-1307 USA
- */
-
-#include <common.h>
-#include <linux/byteorder/swab.h>
-
-
-flash_info_t flash_info[CONFIG_SYS_MAX_FLASH_BANKS];	/* info

for FLASH chips */ -
-#define mb() __asm__ __volatile__ ("" : : : "memory")
- -/*-----------------------------------------------------------------------
- * Functions
- */
-static ulong flash_get_size (unsigned char * addr, flash_info_t * info); -static int write_data (flash_info_t * info, ulong dest, unsigned char data); -static void flash_get_offsets (ulong base, flash_info_t * info); -void inline spin_wheel (void);
- -/*-----------------------------------------------------------------------
- */
-
-unsigned long flash_init (void)
-{
- int i;
- ulong size = 0;
-
- for (i = 0; i < CONFIG_SYS_MAX_FLASH_BANKS; i++) {
- switch (i) {
- case 0:
- flash_get_size ((unsigned char *)
PHYS_FLASH_1, &flash_info[i]);
- flash_get_offsets (PHYS_FLASH_1,
&flash_info[i]);
- break;
- case 1:
- /* ignore for now */
- flash_info[i].flash_id = FLASH_UNKNOWN;
- break;
- default:
- panic ("configured too many flash banks!\n");
- break;
- }
- size += flash_info[i].size;
- }
-
- /* Protect monitor and environment sectors
- */
- flash_protect (FLAG_PROTECT_SET,

-		       CONFIG_SYS_FLASH_BASE,
-		       CONFIG_SYS_FLASH_BASE + _bss_start_ofs,
-		       &flash_info[0]);

-
- return size;
-}
- -/*-----------------------------------------------------------------------
- */
-static void flash_get_offsets (ulong base, flash_info_t * info) -{
- int i;
-
- if (info->flash_id == FLASH_UNKNOWN)
- return;
-
- if ((info->flash_id & FLASH_VENDMASK) == FLASH_MAN_INTEL) {
- for (i = 0; i < info->sector_count; i++) {
- info->start[i] = base + (i *
PHYS_FLASH_SECT_SIZE);
- info->protect[i] = 0;
- }
- }
-}
- -/*-----------------------------------------------------------------------
- */
-void flash_print_info (flash_info_t * info)
-{
- int i;
-
- if (info->flash_id == FLASH_UNKNOWN) {
- printf ("missing or unknown FLASH type\n");
- return;
- }
-
- switch (info->flash_id & FLASH_VENDMASK) {
- case FLASH_MAN_INTEL:
- printf ("INTEL ");
- break;
- default:
- printf ("Unknown Vendor ");
- break;
- }
-
- switch (info->flash_id & FLASH_TYPEMASK) {
- case FLASH_28F128J3A:
- printf ("28F128J3A\n");
- break;
- default:
- printf ("Unknown Chip Type\n");
- break;
- }
-
- printf (" Size: %ld MB in %d Sectors\n",
- info->size >> 20, info->sector_count);
-
- printf (" Sector Start Addresses:");
- for (i = 0; i < info->sector_count; ++i) {
- if ((i % 5) == 0)
- printf ("\n ");
- printf (" %08lX%s",
- info->start[i], info->protect[i] ? " (RO)" :
" ");
- }
- printf ("\n");
- return;
-}
-
-/*
- * The following code cannot be run from FLASH!
- */
-static ulong flash_get_size (unsigned char * addr, flash_info_t * info) -{
- volatile unsigned char value;
-
- /* Write auto select command: read Manufacturer ID */
- addr[0x5555] = 0xAA;
- addr[0x2AAA] = 0x55;
- addr[0x5555] = 0x90;
-
- mb ();
- value = addr[0];
-
- switch (value) {
-
- case (unsigned char)INTEL_MANUFACT:
- info->flash_id = FLASH_MAN_INTEL;
- break;
-
- default:
- info->flash_id = FLASH_UNKNOWN;
- info->sector_count = 0;
- info->size = 0;
- addr[0] = 0xFF; /* restore read mode */
- return (0); /* no or unknown flash */
- }
-
- mb ();
- value = addr[2]; /* device ID */
-
- switch (value) {
-
- case (unsigned char)INTEL_ID_28F640J3A:
- info->flash_id += FLASH_28F640J3A;
- info->sector_count = 64;
- info->size = 0x00800000;
- break; /* => 8 MB */
-
- case (unsigned char)INTEL_ID_28F128J3A:
- info->flash_id += FLASH_28F128J3A;
- info->sector_count = 128;
- info->size = 0x01000000;
- break; /* => 16 MB */
-
- default:
- info->flash_id = FLASH_UNKNOWN;
- break;
- }
-
- if (info->sector_count > CONFIG_SYS_MAX_FLASH_SECT) {
- printf ("** ERROR: sector count %d > max (%d) **\n",
- info->sector_count, CONFIG_SYS_MAX_FLASH_SECT);
- info->sector_count = CONFIG_SYS_MAX_FLASH_SECT;
- }
-
- addr[0] = 0xFF; /* restore read mode */
-
- return (info->size);
-}
-
- -/*-----------------------------------------------------------------------
- */
-
-int flash_erase (flash_info_t * info, int s_first, int s_last) -{
- int prot, sect;
- ulong type;
- int rcode = 0;
- ulong start;
-
- if ((s_first < 0) || (s_first > s_last)) {
- if (info->flash_id == FLASH_UNKNOWN) {
- printf ("- missing\n");
- } else {
- printf ("- no sectors to erase\n");
- }
- return 1;
- }
-
- type = (info->flash_id & FLASH_VENDMASK);
- if ((type != FLASH_MAN_INTEL)) {
- printf ("Can't erase unknown flash type %08lx -
aborted\n",
- info->flash_id);
- return 1;
- }
-
- prot = 0;
- for (sect = s_first; sect <= s_last; ++sect) {
- if (info->protect[sect]) {
- prot++;
- }
- }
-
- if (prot)
- printf ("- Warning: %d protected sectors will not be
erased!\n", prot);
- else
- printf ("\n");
-
- /* Disable interrupts which might cause a timeout here */
- disable_interrupts();
-
- /* Start erase on unprotected sectors */
- for (sect = s_first; sect <= s_last; sect++) {
- if (info->protect[sect] == 0) { /* not
protected */
- volatile unsigned char *addr;
- unsigned char status;
-
- printf ("Erasing sector %2d ... ", sect);
-
- /* arm simple, non interrupt dependent timer */
- start = get_timer(0);
-
- addr = (volatile unsigned char *)
(info->start[sect]);
- *addr = 0x50; /* clear status register
*/
- *addr = 0x20; /* erase setup */
- *addr = 0xD0; /* erase confirm */
-
- while (((status = *addr) & 0x80) != 0x80) {
- if (get_timer(start) >
- CONFIG_SYS_FLASH_ERASE_TOUT) {
- printf ("Timeout\n");
- *addr = 0xB0; /*
suspend erase */
- *addr = 0xFF; /* reset
to read mode */
- rcode = 1;
- break;
- }
- }
-
- *addr = 0x50; /* clear status register
cmd */
- *addr = 0xFF; /* resest to read mode */
-
- printf (" done\n");
- }
- }
- return rcode;
-}
- -/*-----------------------------------------------------------------------
- * Copy memory to flash, returns:
- * 0 - OK
- * 1 - write timeout
- * 2 - Flash not erased
- * 4 - Flash not identified
- */
-
-int write_buff (flash_info_t * info, uchar * src, ulong addr, ulong cnt) -{
- ulong cp, wp;
- unsigned char data;
- int count, i, l, rc, port_width;
-
- if (info->flash_id == FLASH_UNKNOWN)
- return 4;
-
- wp = addr;
- port_width = 1;
-
- /*
- * handle unaligned start bytes
- */
- if ((l = addr - wp) != 0) {
- data = 0;
- for (i = 0, cp = wp; i < l; ++i, ++cp) {
- data = (data << 8) | (*(uchar *) cp);
- }
- for (; i < port_width && cnt > 0; ++i) {
- data = (data << 8) | *src++;
- --cnt;
- ++cp;
- }
- for (; cnt == 0 && i < port_width; ++i, ++cp) {
- data = (data << 8) | (*(uchar *) cp);
- }
-
- if ((rc = write_data (info, wp, data)) != 0) {
- return (rc);
- }
- wp += port_width;
- }
-
- /*
- * handle word aligned part
- */
- count = 0;
- while (cnt >= port_width) {
- data = 0;
- for (i = 0; i < port_width; ++i) {
- data = (data << 8) | *src++;
- }
- if ((rc = write_data (info, wp, data)) != 0) {
- return (rc);
- }
- wp += port_width;
- cnt -= port_width;
- if (count++ > 0x800) {
- spin_wheel ();
- count = 0;
- }
- }
-
- if (cnt == 0) {
- return (0);
- }
-
- /*
- * handle unaligned tail bytes
- */
- data = 0;
- for (i = 0, cp = wp; i < port_width && cnt > 0; ++i, ++cp) {
- data = (data << 8) | *src++;
- --cnt;
- }
- for (; i < port_width; ++i, ++cp) {
- data = (data << 8) | (*(uchar *) cp);
- }
-
- return (write_data (info, wp, data));
-}
- -/*-----------------------------------------------------------------------
- * Write a word or halfword to Flash, returns:
- * 0 - OK
- * 1 - write timeout
- * 2 - Flash not erased
- */
-static int write_data (flash_info_t * info, ulong dest, unsigned char data) -{
- volatile unsigned char *addr = (volatile unsigned char *) dest;
- ulong status;
- ulong start;
-
- /* Check if Flash is (sufficiently) erased */
- if ((*addr & data) != data) {
- printf ("not erased@%08lx (%lx)\n", (ulong) addr,
- (ulong) * addr);
- return (2);
- }
- /* Disable interrupts which might cause a timeout here */
- disable_interrupts();
-
- *addr = 0x40; /* write setup */
- *addr = data;
-
- /* arm simple, non interrupt dependent timer */
- start = get_timer(0);
-
- /* wait while polling the status register */
- while (((status = *addr) & 0x80) != 0x80) {
- if (get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT) {
- *addr = 0xFF; /* restore read mode */
- return (1);
- }
- }
-
- *addr = 0xFF; /* restore read mode */
-
- return (0);
-}
-
-void inline spin_wheel (void)
-{
- static int p = 0;
- static char w[] = "\\/-";
-
- printf ("\010%c", w[p]);
- (++p == 3) ? (p = 0) : 0;
-}

board/cm41xx/Makefile +1 -1
index 6214f8c..d49fce1 100644
@@ -25,7 +25,7 @@ include $(TOPDIR)/config.mk
 
 LIB	= $(obj)lib$(BOARD).o
 
-COBJS	:= cm41xx.o flash.o
+COBJS	:= cm41xx.o
 
 SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
 OBJS	:= $(addprefix $(obj),$(COBJS))
board/cm41xx/flash.c deleted +0 -34
deleted file mode 100644
index 5522bf0..0000000
@@ -1,410 +0,0 @@
-/*
- * (C) Copyright 2005
- * Greg Ungerer, OpenGear Inc, greg.ungerer at opengear.com
- *
- * (C) Copyright 2001
- * Kyle Harris, Nexus Technologies, Inc. kharris at nexus-tech.net
- *
- * (C) Copyright 2001
- * Wolfgang Denk, DENX Software Engineering, wd at denx.de.
- *
- * See file CREDITS for list of people who contributed to this
- * project.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
- * MA 02111-1307 USA
- */
-
-#include <common.h>
-#include <linux/byteorder/swab.h>
-
-
-flash_info_t flash_info[CONFIG_SYS_MAX_FLASH_BANKS];	/* info

for FLASH chips */ -
-#define mb() __asm__ __volatile__ ("" : : : "memory")
- -/*-----------------------------------------------------------------------
- * Functions
- */
-static ulong flash_get_size (unsigned char * addr, flash_info_t * info); -static int write_data (flash_info_t * info, ulong dest, unsigned char data); -static void flash_get_offsets (ulong base, flash_info_t * info); -void inline spin_wheel (void);
- -/*-----------------------------------------------------------------------
- */
-
-unsigned long flash_init (void)
-{
- int i;
- ulong size = 0;
-
- for (i = 0; i < CONFIG_SYS_MAX_FLASH_BANKS; i++) {
- switch (i) {
- case 0:
- flash_get_size ((unsigned char *)
PHYS_FLASH_1, &flash_info[i]);
- flash_get_offsets (PHYS_FLASH_1,
&flash_info[i]);
- break;
- case 1:
- /* ignore for now */
- flash_info[i].flash_id = FLASH_UNKNOWN;
- break;
- default:
- panic ("configured too many flash banks!\n");
- break;
- }
- size += flash_info[i].size;
- }
-
- /* Protect monitor and environment sectors
- */
- flash_protect (FLAG_PROTECT_SET,

-		       CONFIG_SYS_FLASH_BASE,
-		       CONFIG_SYS_FLASH_BASE + _bss_start_ofs,
-		       &flash_info[0]);

-
- return size;
-}
- -/*-----------------------------------------------------------------------
- */
-static void flash_get_offsets (ulong base, flash_info_t * info) -{
- int i;
-
- if (info->flash_id == FLASH_UNKNOWN)
- return;
-
- if ((info->flash_id & FLASH_VENDMASK) == FLASH_MAN_INTEL) {
- for (i = 0; i < info->sector_count; i++) {
- info->start[i] = base + (i *
PHYS_FLASH_SECT_SIZE);
- info->protect[i] = 0;
- }
- }
-}
- -/*-----------------------------------------------------------------------
- */
-void flash_print_info (flash_info_t * info)
-{
- int i;
-
- if (info->flash_id == FLASH_UNKNOWN) {
- printf ("missing or unknown FLASH type\n");
- return;
- }
-
- switch (info->flash_id & FLASH_VENDMASK) {
- case FLASH_MAN_INTEL:
- printf ("INTEL ");
- break;
- default:
- printf ("Unknown Vendor ");
- break;
- }
-
- switch (info->flash_id & FLASH_TYPEMASK) {
- case FLASH_28F128J3A:
- printf ("28F128J3A\n");
- break;
- default:
- printf ("Unknown Chip Type\n");
- break;
- }
-
- printf (" Size: %ld MB in %d Sectors\n",
- info->size >> 20, info->sector_count);
-
- printf (" Sector Start Addresses:");
- for (i = 0; i < info->sector_count; ++i) {
- if ((i % 5) == 0)
- printf ("\n ");
- printf (" %08lX%s",
- info->start[i], info->protect[i] ? " (RO)" :
" ");
- }
- printf ("\n");
- return;
-}
-
-/*
- * The following code cannot be run from FLASH!
- */
-static ulong flash_get_size (unsigned char * addr, flash_info_t * info) -{
- volatile unsigned char value;
-
- /* Write auto select command: read Manufacturer ID */
- addr[0x5555] = 0xAA;
- addr[0x2AAA] = 0x55;
- addr[0x5555] = 0x90;
-
- mb ();
- value = addr[0];
-
- switch (value) {
-
- case (unsigned char)INTEL_MANUFACT:
- info->flash_id = FLASH_MAN_INTEL;
- break;
-
- default:
- info->flash_id = FLASH_UNKNOWN;
- info->sector_count = 0;
- info->size = 0;
- addr[0] = 0xFF; /* restore read mode */
- return (0); /* no or unknown flash */
- }
-
- mb ();
- value = addr[2]; /* device ID */
-
- switch (value) {
-
- case (unsigned char)INTEL_ID_28F640J3A:
- info->flash_id += FLASH_28F640J3A;
- info->sector_count = 64;
- info->size = 0x00800000;
- break; /* => 8 MB */
-
- case (unsigned char)INTEL_ID_28F128J3A:
- info->flash_id += FLASH_28F128J3A;
- info->sector_count = 128;
- info->size = 0x01000000;
- break; /* => 16 MB */
-
- default:
- info->flash_id = FLASH_UNKNOWN;
- break;
- }
-
- if (info->sector_count > CONFIG_SYS_MAX_FLASH_SECT) {
- printf ("** ERROR: sector count %d > max (%d) **\n",
- info->sector_count, CONFIG_SYS_MAX_FLASH_SECT);
- info->sector_count = CONFIG_SYS_MAX_FLASH_SECT;
- }
-
- addr[0] = 0xFF; /* restore read mode */
-
- return (info->size);
-}
-
- -/*-----------------------------------------------------------------------
- */
-
-int flash_erase (flash_info_t * info, int s_first, int s_last) -{
- int prot, sect;
- ulong type;
- int rcode = 0;
- ulong start;
-
- if ((s_first < 0) || (s_first > s_last)) {
- if (info->flash_id == FLASH_UNKNOWN) {
- printf ("- missing\n");
- } else {
- printf ("- no sectors to erase\n");
- }
- return 1;
- }
-
- type = (info->flash_id & FLASH_VENDMASK);
- if ((type != FLASH_MAN_INTEL)) {
- printf ("Can't erase unknown flash type %08lx -
aborted\n",
- info->flash_id);
- return 1;
- }
-
- prot = 0;
- for (sect = s_first; sect <= s_last; ++sect) {
- if (info->protect[sect]) {
- prot++;
- }
- }
-
- if (prot)
- printf ("- Warning: %d protected sectors will not be
erased!\n", prot);
- else
- printf ("\n");
-
- /* Disable interrupts which might cause a timeout here */
- disable_interrupts();
-
- /* Start erase on unprotected sectors */
- for (sect = s_first; sect <= s_last; sect++) {
- if (info->protect[sect] == 0) { /* not
protected */
- volatile unsigned char *addr;
- unsigned char status;
-
- printf ("Erasing sector %2d ... ", sect);
-
- /* arm simple, non interrupt dependent timer */
- start = get_timer(0);
-
- addr = (volatile unsigned char *)
(info->start[sect]);
- *addr = 0x50; /* clear status register
*/
- *addr = 0x20; /* erase setup */
- *addr = 0xD0; /* erase confirm */
-
- while (((status = *addr) & 0x80) != 0x80) {
- if (get_timer(start) >
- CONFIG_SYS_FLASH_ERASE_TOUT) {
- printf ("Timeout\n");
- *addr = 0xB0; /*
suspend erase */
- *addr = 0xFF; /* reset
to read mode */
- rcode = 1;
- break;
- }
- }
-
- *addr = 0x50; /* clear status register
cmd */
- *addr = 0xFF; /* resest to read mode */
-
- printf (" done\n");
- }
- }
- return rcode;
-}
- -/*-----------------------------------------------------------------------
- * Copy memory to flash, returns:
- * 0 - OK
- * 1 - write timeout
- * 2 - Flash not erased
- * 4 - Flash not identified
- */
-
-int write_buff (flash_info_t * info, uchar * src, ulong addr, ulong cnt) -{
- ulong cp, wp;
- unsigned char data;
- int count, i, l, rc, port_width;
-
- if (info->flash_id == FLASH_UNKNOWN)
- return 4;
-
- wp = addr;
- port_width = 1;
-
- /*
- * handle unaligned start bytes
- */
- if ((l = addr - wp) != 0) {
- data = 0;
- for (i = 0, cp = wp; i < l; ++i, ++cp) {
- data = (data << 8) | (*(uchar *) cp);
- }
- for (; i < port_width && cnt > 0; ++i) {
- data = (data << 8) | *src++;
- --cnt;
- ++cp;
- }
- for (; cnt == 0 && i < port_width; ++i, ++cp) {
- data = (data << 8) | (*(uchar *) cp);
- }
-
- if ((rc = write_data (info, wp, data)) != 0) {
- return (rc);
- }
- wp += port_width;
- }
-
- /*
- * handle word aligned part
- */
- count = 0;
- while (cnt >= port_width) {
- data = 0;
- for (i = 0; i < port_width; ++i) {
- data = (data << 8) | *src++;
- }
- if ((rc = write_data (info, wp, data)) != 0) {
- return (rc);
- }
- wp += port_width;
- cnt -= port_width;
- if (count++ > 0x800) {
- spin_wheel ();
- count = 0;
- }
- }
-
- if (cnt == 0) {
- return (0);
- }
-
- /*
- * handle unaligned tail bytes
- */
- data = 0;
- for (i = 0, cp = wp; i < port_width && cnt > 0; ++i, ++cp) {
- data = (data << 8) | *src++;
- --cnt;
- }
- for (; i < port_width; ++i, ++cp) {
- data = (data << 8) | (*(uchar *) cp);
- }
-
- return (write_data (info, wp, data));
-}
- -/*-----------------------------------------------------------------------
- * Write a word or halfword to Flash, returns:
- * 0 - OK
- * 1 - write timeout
- * 2 - Flash not erased
- */
-static int write_data (flash_info_t * info, ulong dest, unsigned char data) -{
- volatile unsigned char *addr = (volatile unsigned char *) dest;
- ulong status;
- ulong start;
-
- /* Check if Flash is (sufficiently) erased */
- if ((*addr & data) != data) {
- printf ("not erased@%08lx (%lx)\n", (ulong) addr,
- (ulong) * addr);
- return (2);
- }
- /* Disable interrupts which might cause a timeout here */
- disable_interrupts();
-
- *addr = 0x40; /* write setup */
- *addr = data;
-
- /* arm simple, non interrupt dependent timer */
- start = get_timer(0);
-
- /* wait while polling the status register */
- while (((status = *addr) & 0x80) != 0x80) {
- if (get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT) {
- *addr = 0xFF; /* restore read mode */
- return (1);
- }
- }
-
- *addr = 0xFF; /* restore read mode */
-
- return (0);
-}
-
-void inline spin_wheel (void)
-{
- static int p = 0;
- static char w[] = "\\/-";
-
- printf ("\010%c", w[p]);
- (++p == 3) ? (p = 0) : 0;
-}

include/configs/cm4008.h +0 -0
index 408e918..fe62f73 100644
@@ -116,13 +116,24 @@
 
 #define CONFIG_SYS_INIT_SP_ADDR	0x00020000 /* lowest 128k of

RAM */
-#define PHYS_FLASH_1 0x02000000 /* Flash Bank #1 */
-#define PHYS_FLASH_SECT_SIZE 0x00020000 /* 128 KB sectors (x1) */
-#define CONFIG_SYS_FLASH_BASE PHYS_FLASH_1
+/* CONFIG_SYS_TEXT_BASE and CONFIG_SYS_FLASH_BASE must match for both
+ relocation in lowlevel_init.S and function array in board.c */
+#define CONFIG_SYS_TEXT_BASE 0x02000000
+#define CONFIG_SYS_FLASH_BASE CONFIG_SYS_TEXT_BASE
+#define CONFIG_SYS_RCS0_BASE CONFIG_SYS_TEXT_BASE
+#define CONFIG_SYS_RCS0_SIZE 0x400000
+#define CONFIG_SYS_RCS1_BASE (CONFIG_SYS_RCS0_BASE+CONFIG_SYS_RCS0_SIZE) +#define
CONFIG_SYS_RCS1_SIZE 0x400000 +
+#define CONFIG_SYS_FLASH_CFI
+#define CONFIG_FLASH_CFI_DRIVER
+#define CONFIG_SYS_FLASH_CFI_WIDTH FLASH_CFI_8BIT
+#define CONFIG_SYS_CFI_FLASH_STATUS_POLL

/*-----------------------------------------------------------------------
* FLASH and environment organization
*/
+#define CONFIG_SYS_FLASH_BANKS_LIST {CONFIG_SYS_RCS0_BASE,
CONFIG_SYS_RCS1_BASE} #define CONFIG_SYS_MAX_FLASH_BANKS
2 /* max number of flash banks */ #define
CONFIG_SYS_MAX_FLASH_SECT (128) /* max number of sectors
on one chip */ diff --git a/include/configs/cm41xx.h b/include/configs/cm41xx.h index d85a600..485792c 100644

include/configs/cm41xx.h +0 -0
@@ -116,13 +116,30 @@
 
 #define CONFIG_SYS_INIT_SP_ADDR	0x00020000 /* lowest 128k of

RAM */
-#define PHYS_FLASH_1 0x02000000 /* Flash Bank #1 */
-#define PHYS_FLASH_SECT_SIZE 0x00020000 /* 128 KB sectors (x1) */
-#define CONFIG_SYS_FLASH_BASE PHYS_FLASH_1
+/* CONFIG_SYS_TEXT_BASE and CONFIG_SYS_RCS0_BASE must match for both
+ relocation in lowlevel_init.S and function array in board.c */
+#define CONFIG_SYS_TEXT_BASE 0x02000000
+#define CONFIG_SYS_RCS0_BASE CONFIG_SYS_TEXT_BASE
+#define CONFIG_SYS_RCS0_SIZE 0x400000
+#define CONFIG_SYS_RCS1_BASE (CONFIG_SYS_RCS0_BASE+CONFIG_SYS_RCS0_SIZE) +#define
CONFIG_SYS_RCS1_SIZE 0x400000 +#define
CONFIG_SYS_ECS0_BASE (CONFIG_SYS_RCS1_BASE+CONFIG_SYS_RCS1_SIZE)
+#define CONFIG_SYS_ECS0_SIZE 0x400000 +#define
CONFIG_SYS_ECS0_SPEED 0xb6d +#define
CONFIG_SYS_ECS0_WIDTH KS8695_BUS_WIDTH_8 +#define
CONFIG_SYS_ECS1_BASE (CONFIG_SYS_ECS0_BASE+CONFIG_SYS_ECS0_SIZE)
+#define CONFIG_SYS_ECS1_SIZE 0x400000 +#define
CONFIG_SYS_ECS1_SPEED 0xb6d +#define
CONFIG_SYS_ECS1_WIDTH KS8695_BUS_WIDTH_8 +
+#define CONFIG_SYS_FLASH_CFI
+#define CONFIG_FLASH_CFI_DRIVER
+#define CONFIG_SYS_FLASH_CFI_WIDTH FLASH_CFI_8BIT

/*-----------------------------------------------------------------------
* FLASH and environment organization
*/
+#define CONFIG_SYS_FLASH_BANKS_LIST {CONFIG_SYS_RCS0_BASE,
CONFIG_SYS_RCS1_BASE} #define CONFIG_SYS_MAX_FLASH_BANKS
2 /* max number of flash banks */ #define
CONFIG_SYS_MAX_FLASH_SECT (128) /* max number of sectors
on one chip */

Signature · 1 line
1.7.10.4
#43 lore raw

PATCH 5/11 arm: cm4008, cm41xx: set gd->ram_size in dram_init

In reply to Albert ARIBAUD

Leave dram_init_banksize to set up the bank info data. ram_size was previously uninitialized.
Also put data on SDRAM configuration in header file.

---
Changes for v2:
- Update to use CONFIG_SYS_SDRAM_ constants
- Update cm41xx also
- Map SDRAM to match configuration
Changes for v3:
- Moved SDRAM configuration to header file, in
preparation for lowlevel constant cleanup.

---
 board/cm4008/cm4008.c    |    5 +++--
 board/cm41xx/cm41xx.c    |    5 +++--
 include/configs/cm4008.h |   11 ++++++++---
 include/configs/cm41xx.h |    9 ++++++---
 4 files changed, 20 insertions(+), 10 deletions(-)
board/cm4008/cm4008.c +3 -2
index ed493a8..6c0da9a 100644
@@ -97,8 +97,9 @@ int board_init (void)
 
 int dram_init (void)
 {
-	gd->bd->bi_dram[0].start = PHYS_SDRAM_1;
-	gd->bd->bi_dram[0].size  = PHYS_SDRAM_1_SIZE;
+	/* dram_init must store complete ramsize in gd->ram_size */
+	gd->ram_size = get_ram_size((long *)CONFIG_SYS_SDRAM_BASE,
+			CONFIG_SYS_SDRAM_SIZE);
 
 	return (0);
 }
board/cm41xx/cm41xx.c +3 -2
index d9dff4e..6aef617 100644
@@ -97,8 +97,9 @@ int board_init (void)
 
 int dram_init (void)
 {
-	gd->bd->bi_dram[0].start = PHYS_SDRAM_1;
-	gd->bd->bi_dram[0].size  = PHYS_SDRAM_1_SIZE;
+	/* dram_init must store complete ramsize in gd->ram_size */
+	gd->ram_size = get_ram_size((long *)CONFIG_SYS_SDRAM_BASE,
+			CONFIG_SYS_SDRAM_SIZE);
 
 	return (0);
 }
include/configs/cm4008.h +1 -0
index fe62f73..18f7900 100644
@@ -106,13 +106,18 @@
 #define CONFIG_STACKSIZE_FIQ	(4*1024)	/* FIQ stack */
 #endif
 
+
 /*-----------------------------------------------------------------------
  * Physical Memory Map
  */
 #define CONFIG_NR_DRAM_BANKS	1	   /* we have 1 bank of

DRAM */ -#define PHYS_SDRAM_1 0x00000000 /* SDRAM Bank
#1 */ -#define PHYS_SDRAM_1_SIZE 0x01000000 /* 16 MB */
-#define CONFIG_SYS_SDRAM_BASE PHYS_SDRAM_1
+#define CONFIG_SYS_SDRAM_BASE 0x00000000 /* SDRAM Bank #1 */
+#define CONFIG_SYS_SDRAM_SIZE 0x01000000 /* 16 MB */
+#define CONFIG_SYS_SDCS0_PARAMS (KS8695_SDCON_CA_8BIT | \
+ KS8695_SDCON_4BANK |
KS8695_SDCON_D_32) +#define CONFIG_SYS_SDRAM_RAS_CAS_DELAY 3
+#define CONFIG_SYS_SDRAM_MODE 0x033
+

#define CONFIG_SYS_INIT_SP_ADDR 0x00020000 /* lowest 128k of
RAM */

include/configs/cm41xx.h +0 -0
index 485792c..ed345b0 100644
@@ -110,9 +110,12 @@
  * Physical Memory Map
  */
 #define CONFIG_NR_DRAM_BANKS	1	   /* we have 1 bank of

DRAM */ -#define PHYS_SDRAM_1 0x00000000 /* SDRAM Bank
#1 */ -#define PHYS_SDRAM_1_SIZE 0x02000000 /* 32 MB */
-#define CONFIG_SYS_SDRAM_BASE PHYS_SDRAM_1
+#define CONFIG_SYS_SDRAM_BASE 0x00000000 /* SDRAM Bank #1 */
+#define CONFIG_SYS_SDRAM_SIZE 0x02000000 /* 32 MB */
+#define CONFIG_SYS_SDCS0_PARAMS (KS8695_SDCON_CA_8BIT | \
+ KS8695_SDCON_4BANK |
KS8695_SDCON_D_32) +#define CONFIG_SYS_SDRAM_RAS_CAS_DELAY 3
+#define CONFIG_SYS_SDRAM_MODE 0x033

#define CONFIG_SYS_INIT_SP_ADDR 0x00020000 /* lowest 128k of
RAM */

Signature · 1 line
1.7.10.4
#44 lore raw

PATCH 6/11 arm: cm4008, cm41xx: Fix ROM relocation

In reply to Albert ARIBAUD

Changed CONFIG_SYS_TEXT_BASE to actual address (required for board_init_f) and moved it into cm4{008,1xx}.h, along with a warning that it must match CONFIG_SYS_FLASH_BASE (since lowlevel_init relocates there).
lowlevel_init now uses CONFIG_SYS_RCS0_BASE to map ROM.
---
Changes for v2:
- Update to use CONFIG_SYS_FLASH_ constants only (no PHYS_FLASH)
- Use tabs where appropriate
- Update cm41xx also
- Explain the lowlevel_init change
Changes for v3:
- Use memory mappings per defined macros
- Change the final adjustment of lr and ip
- Verified mapping flash at 0x3000000 on KS8695X demo board

---
 arch/arm/cpu/arm920t/ks8695/lowlevel_init.S |   63
+++++++++++++++++++-------- board/cm4008/config.mk
|    1 - board/cm41xx/config.mk                      |    1 -
 3 files changed, 45 insertions(+), 20 deletions(-)
 delete mode 100644 board/cm4008/config.mk
 delete mode 100644 board/cm41xx/config.mk
(quoted diff) +0 -0

b/arch/arm/cpu/arm920t/ks8695/lowlevel_init.S index 1bba571..74579ed 100644 --- a/arch/arm/cpu/arm920t/ks8695/lowlevel_init.S +++ b/arch/arm/cpu/arm920t/ks8695/lowlevel_init.S
@@ -25,6 +25,7 @@
#include <config.h>
#include <version.h>
#include <asm/arch/platform.h>
+#include <asm/arch/regvalues.h>

#ifndef CONFIG_SKIP_LOWLEVEL_INIT

@@ -91,12 +92,31 @@ lowlevel_init:
* remap the memory and flash regions. we want to end up with
* ram from address 0, and flash at 32MB.
*/
+#if CONFIG_SYS_RCS0_BASE!=CONFIG_SYS_TEXT_BASE
+#error CONFIG_SYS_RCS0_BASE and CONFIG_SYS_TEXT_BASE must match for highflash address to work
+ /* Also needed for pointers in board_init_f() */
+#endif
+#if CONFIG_SYS_RCS0_BASE>=KS8695_IO_BASE
+#error Cannot relocate ROM past IO registers
+ /* Firstly, the IO registers are at the top supported address.
+ Secondly, as we grow the ROM region it must not overlap the
registers. */ +#endif
+#if CONFIG_SYS_RCS0_BASE&0xffff
+#error Cannot map memory to addresses not divisible by 64K +#endif
ldr r1, =(KS8695_IO_BASE+KS8695_MEM_CTRL0)
- ldr r2, =0xbfc00040
+ /* The default ROM mapping is at 0x0 - 0x01ffffff.

+	   Remap it to 0x0 - 0x03feffff so that it covers 0x02000000,
+	   where CONFIG_SYS_FLASH_BASE maps it, as well as 0.
+	   Relies on the limited address lines to repeat ROM images
+	   on every multiple of the real ROM size. */

+ ldr r2,
=(KS8695_MEM_RANGE(0,0x03ff0000)|(CONFIG_KS8695_ROMCON0_VALUE&0xfff))
str r2, [r1] /* large flash map */
- ldr pc, =(highflash+0x02000000-0x00f00000) /*
jump to high flash address */
+ /* Relies on CONFIG_SYS_RCS0_BASE==CONFIG_SYS_TEXT_BASE */
+ ldr pc, =(highflash) /* jump to high flash
address */ highflash:
- ldr r2, =0x8fe00040
+ /* Move ROM to high address, and reconfigure to 4MiB size */
+ ldr r2, =CONFIG_KS8695_ROMCON0_VALUE
str r2, [r1] /* remap flash range */

/*
@@ -105,28 +125,35 @@ highflash:
* then you can have it all mapped nicely. Has no effect if you
* only have a 4Mb or smaller flash.
*/
+#if CONFIG_SYS_RCS1_WIDTH
ldr r1, =(KS8695_IO_BASE+KS8695_MEM_CTRL1)
- ldr r2, =0x9fe40040
+ ldr r2, =CONFIG_KS8695_ROMCON1_VALUE
str r2, [r1] /* remap flash2 region,
contiguous */
- ldr r1, =(KS8695_IO_BASE+KS8695_MEM_GENERAL)
- ldr r2, =0x30000005
- str r2, [r1] /* enable both flash
selects */ +#endif

-#ifdef CONFIG_CM41xx
/*
- * map the second flash chip, using the external IO lines.
+ * map additional flash chip, using the external IO lines.
*/
+#if CONFIG_SYS_ECS0_WIDTH
ldr r1, =(KS8695_IO_BASE+KS8695_IO_CTRL0)
- ldr r2, =0xafe80b6d
- str r2, [r1] /* remap io0 region,
contiguous */
+ ldr r2, =CONFIG_KS8695_EXTACON0_VALUE
+ str r2, [r1] /* map io0 region */
+#endif
+#if CONFIG_SYS_ECS1_WIDTH
ldr r1, =(KS8695_IO_BASE+KS8695_IO_CTRL1)
- ldr r2, =0xbfec0b6d
- str r2, [r1] /* remap io1 region,
contiguous */
- ldr r1, =(KS8695_IO_BASE+KS8695_MEM_GENERAL)
- ldr r2, =0x30050005
- str r2, [r1] /* enable second flash */
+ ldr r2, =CONFIG_KS8695_EXTACON1_VALUE
+ str r2, [r1] /* map io1 region */
+#endif
+#if CONFIG_SYS_ECS2_WIDTH
+ ldr r1, =(KS8695_IO_BASE+KS8695_IO_CTRL2)
+ ldr r2, =CONFIG_KS8695_EXTACON2_VALUE
+ str r2, [r1] /* map io2 region */
#endif

+ ldr r1, =(KS8695_IO_BASE+KS8695_MEM_GENERAL)
+ ldr r2, =CONFIG_KS8695_ERGCON_VALUE
+ str r2, [r1] /* enable relevant flash
selects */ +
/*
* before relocating, we have to setup RAM timing */
@@ -198,8 +225,8 @@ highflash:
nobutton:
#endif

- add lr, lr, #0x02000000 /* flash is now mapped
high */
- add ip, ip, #0x02000000 /* this is a hack */
+ add lr, lr, #CONFIG_SYS_TEXT_BASE /* flash is
now mapped high */
+ add ip, ip, #CONFIG_SYS_TEXT_BASE /* this is a
hack */ mov pc, lr /* all done, return */

#endif /* CONFIG_SKIP_LOWLEVEL_INIT */

board/cm4008/config.mk deleted +0 -1
deleted file mode 100644
index 0d5923b..0000000
@@ -1 +0,0 @@
-CONFIG_SYS_TEXT_BASE = 0x00f00000
board/cm41xx/config.mk deleted +0 -1
deleted file mode 100644
index 0d5923b..0000000
@@ -1 +0,0 @@
-CONFIG_SYS_TEXT_BASE = 0x00f00000
Signature · 1 line
1.7.10.4
#45 lore raw

PATCH 7/11 arm: ks8695/cm4008/cm41xx: Parameterize SDRAM

In reply to Albert ARIBAUD

Allows configuration macros to set SDRAM parameters.

---
 arch/arm/cpu/arm920t/ks8695/lowlevel_init.S |   20 +++++++++++---------
 1 file changed, 11 insertions(+), 9 deletions(-)
(quoted diff) +0 -0

b/arch/arm/cpu/arm920t/ks8695/lowlevel_init.S index 74579ed..bec9738 100644 --- a/arch/arm/cpu/arm920t/ks8695/lowlevel_init.S +++ b/arch/arm/cpu/arm920t/ks8695/lowlevel_init.S
@@ -157,19 +157,20 @@ highflash:
/*
* before relocating, we have to setup RAM timing */
+#if CONFIG_SYS_SDCS0_PARAMS
ldr r1, =(KS8695_IO_BASE+KS8695_SDRAM_CTRL0)
-#if (PHYS_SDRAM_1_SIZE == 0x02000000)
- ldr r2, =0x7fc0000e /* 32MB */
-#else
- ldr r2, =0x3fc0000e /* 16MB */
-#endif
+ ldr r2, =CONFIG_KS8695_SDCON0_VALUE
str r2, [r1] /* configure sdram bank0
setup */ +#endif
+#if CONFIG_SYS_SDCS1_PARAMS
ldr r1, =(KS8695_IO_BASE+KS8695_SDRAM_CTRL1)
- mov r2, #0
+ mov r2, #CONFIG_KS8695_SDCON1_VALUE
str r2, [r1] /* configure sdram bank1
setup */ +#endif

+#if CONFIG_SYS_SDCS0_PARAMS || CONFIG_SYS_SDCS1_PARAMS
ldr r1, =(KS8695_IO_BASE+KS8695_SDRAM_GENERAL)
- ldr r2, =0x0000000a
+ ldr r2, =CONFIG_KS8695_SDGCON_VALUE
str r2, [r1] /* set RAS/CAS timing */

ldr r1, =(KS8695_IO_BASE+KS8695_SDRAM_BUFFER)
@@ -184,15 +185,16 @@ highflash:
ldr r2, =0x00000020
str r2, [r1] /* set for fast refresh */
DELAY_FOR 0x100, r0
- ldr r2, =0x00000190
+ ldr r2, =CONFIG_SYS_SDRAM_REFRESH_RATE
str r2, [r1] /* set normal refresh
timing */
ldr r1, =(KS8695_IO_BASE+KS8695_SDRAM_BUFFER)
- ldr r2, =0x00020033
+ ldr r2, =(0x00020000 | CONFIG_SYS_SDRAM_MODE)
str r2, [r1] /* send mode command */
DELAY_FOR 0x100, r0
ldr r2, =0x01f00000
str r2, [r1] /* enable sdram fifos */
+#endif

/*
* set pll to top speed

Signature · 1 line
1.7.10.4
#46 lore raw

PATCH 8/11 arm: cm4008, cm41xx: don't define to 1

In reply to Albert ARIBAUD

Removed needless values for configuration macros.

---
 include/configs/cm4008.h |   10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
include/configs/cm4008.h +0 -2
index 18f7900..43a2591 100644
@@ -28,14 +28,14 @@
  * High Level Configuration Options
  * (easy to change)
  */
-#define CONFIG_KS8695	1		/* it is a KS8695 CPU */
-#define CONFIG_CM4008	1		/* it is an OpenGear

CM4008 boad */ +#define CONFIG_KS8695 /* it is a
KS8695 CPU */ +#define CONFIG_CM4008 /* it is an
OpenGear CM4008 boad */
#undef CONFIG_USE_IRQ /* we don't need IRQ/FIQ
stuff */
-#define CONFIG_CMDLINE_TAG 1 /* enable passing of
ATAGs */ -#define CONFIG_SETUP_MEMORY_TAGS 1
-#define CONFIG_INITRD_TAG 1
+#define CONFIG_CMDLINE_TAG /* enable passing of
ATAGs */ +#define CONFIG_SETUP_MEMORY_TAGS
+#define CONFIG_INITRD_TAG

#define CONFIG_DRIVER_KS8695ETH /* use KS8695 ethernet
driver */

Signature · 1 line
1.7.10.4
#47 lore raw

PATCH 9/11 arm: ks8695/cm4xxx: don't reconfigure switch

In reply to Albert ARIBAUD

A small bug caused code to set up LEDs to instead disable lots of functionality in the Ethernet switch, including bounds checks.

---
 arch/arm/cpu/arm920t/ks8695/lowlevel_init.S |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
(quoted diff) +0 -0

b/arch/arm/cpu/arm920t/ks8695/lowlevel_init.S index bec9738..31b028b 100644 --- a/arch/arm/cpu/arm920t/ks8695/lowlevel_init.S +++ b/arch/arm/cpu/arm920t/ks8695/lowlevel_init.S
@@ -205,7 +205,7 @@ highflash:

ldr r1, =(KS8695_IO_BASE+KS8695_SWITCH_CTRL0)
ldr r2, [r1] /* Get switch ctrl0
register */
- and r2, r2, #0x0fc00000 /* Mask out LED control
bits */
+ bic r2, r2, #0x0fc00000 /* Mask out LED control
bits */ orr r2, r2, #0x01800000 /* Set
Link/activity/speed actions */ str r2, [r1]

Signature · 1 line
1.7.10.4
#48 lore raw

PATCH 10/11 arm: ks8695: document bus speed

In reply to Albert ARIBAUD

Just use the existing #define instead of magic number.

---
 arch/arm/cpu/arm920t/ks8695/lowlevel_init.S |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
(quoted diff) +0 -0

b/arch/arm/cpu/arm920t/ks8695/lowlevel_init.S index 31b028b..ba37c28 100644 --- a/arch/arm/cpu/arm920t/ks8695/lowlevel_init.S +++ b/arch/arm/cpu/arm920t/ks8695/lowlevel_init.S
@@ -199,8 +199,8 @@ highflash:
/*
* set pll to top speed
*/
- ldr r1, =(KS8695_IO_BASE+KS8695_SYSTEN_BUS_CLOCK)
- mov r2, #0
+ ldr r1, =(KS8695_IO_BASE+KS8695_SYSTEM_BUS_CLOCK)
+ mov r2, #KS8695_BUS_CLOCK_125MHZ
str r2, [r1] /* set pll clock to 166MHz
*/
ldr r1, =(KS8695_IO_BASE+KS8695_SWITCH_CTRL0)

Signature · 1 line
1.7.10.4
#49 lore raw

PATCH 11/11 arm: cm4008, cm41xx: read MAC address from flash

In reply to Albert ARIBAUD

Previously code to do this was in the Ethernet driver itself. Since it is board specific, moved it here, and altered it to support preset MAC from environment.

---
 board/cm4008/cm4008.c |   12 ++++++++++++
 board/cm41xx/cm41xx.c |   12 ++++++++++++
 2 files changed, 24 insertions(+)
board/cm4008/cm4008.c +12 -0
index 6c0da9a..e14f8f4 100644
@@ -75,10 +75,22 @@ int board_late_init (void)
 	return 0;
 }
 
+#ifdef CONFIG_DRIVER_KS8695ETH
 int board_eth_init(bd_t *bis)
 {
+	uchar enetaddr[6];
+	const uchar * const fp=CONFIG_SYS_FLASH_BASE+0x1c000;
+
+	/* read MAC address from flash */
+	if (!eth_getenv_enetaddr("ethaddr", enetaddr)) {
+		memcpy(&enetaddr[0], fp, 6);
+		if (is_valid_ether_addr(enetaddr))
+			eth_setenv_enetaddr("ethaddr", enetaddr);
+	}
+
 	return ks8695_eth_initialize();
 }
+#endif
 
 int board_init (void)
 {
board/cm41xx/cm41xx.c +12 -0
index 6aef617..771701d 100644
@@ -75,10 +75,22 @@ int board_late_init (void)
 	return 0;
 }
 
+#ifdef CONFIG_DRIVER_KS8695ETH
 int board_eth_init(bd_t *bis)
 {
+	uchar enetaddr[6];
+	const uchar * const fp=CONFIG_SYS_FLASH_BASE+0x1c000;
+
+	/* read MAC address from flash */
+	if (!eth_getenv_enetaddr("ethaddr", enetaddr)) {
+		memcpy(&enetaddr[0], fp, 6);
+		if (is_valid_ether_addr(enetaddr))
+			eth_setenv_enetaddr("ethaddr", enetaddr);
+	}
+
 	return ks8695_eth_initialize();
 }
+#endif
 
 int board_init (void)
 {
Signature · 1 line
1.7.10.4
#50 lore raw

PATCH v2 1/1 arm: cm4008, cm41xx: Fix ROM relocation

In reply to Andreas Bießmann

Changed CONFIG_SYS_TEXT_BASE to actual address (required for board_init_f) and moved it into cm4008.h, along with a warning that it must match CONFIG_SYS_FLASH_BASE (since lowlevel_init relocates there). lowlevel_init now uses CONFIG_SYS_FLASH_BASE to map ROM, although the second bank is still mapped at 0x02400000-0x027fffff.
---
Changes for v2:
- Update to use CONFIG_SYS_FLASH_ constants only (no PHYS_FLASH)
- Use tabs where appropriate
- Update cm41xx also
- Explain the lowlevel_init change

---
 arch/arm/cpu/arm920t/ks8695/lowlevel_init.S |    9 +++++++--
 board/cm4008/config.mk                      |    1 -
 board/cm41xx/config.mk                      |    1 -
 include/configs/cm4008.h                    |    7 ++++---
 include/configs/cm41xx.h                    |    7 ++++---
 5 files changed, 15 insertions(+), 10 deletions(-)
 delete mode 100644 board/cm4008/config.mk
 delete mode 100644 board/cm41xx/config.mk
arch/arm/cpu/arm920t/ks8695/lowlevel_init.S +7 -2
index df13de6..7bb9ede 100644
@@ -92,11 +92,16 @@ lowlevel_init:
 	 * ram from address 0, and flash at 32MB.
 	 */
 	ldr	r1, =(KS8695_IO_BASE+KS8695_MEM_CTRL0)
+	/* Remap flash memory to 768MB size, such that it covers
+	   both 0 (boot) and 512MB (run) regions */
 	ldr	r2, =0xbfc00040
 	str	r2, [r1]		/* large flash map */
-	ldr	pc, =(highflash+0x02000000-0x00f00000)	/* jump to high flash address */
+	/* Relies on CONFIG_SYS_FLASH_BASE==CONFIG_SYS_TEXT_BASE */
+	ldr	pc, =(highflash)	/* jump to high flash address */
 highflash:
-	ldr	r2, =0x8fe00040
+	/* Move ROM to high address, and reconfigure to 4MiB size */
+	ldr	r2, =(((CONFIG_SYS_FLASH_BASE+0x3f0000)<<(22-16))|	\
+		      (CONFIG_SYS_FLASH_BASE>>(16-12))|0x40)
 	str	r2, [r1]		/* remap flash range */
 
 	/*
board/cm4008/config.mk deleted +0 -1
deleted file mode 100644
index 0d5923b..0000000
@@ -1 +0,0 @@
-CONFIG_SYS_TEXT_BASE = 0x00f00000
board/cm41xx/config.mk deleted +0 -1
deleted file mode 100644
index 0d5923b..0000000
@@ -1 +0,0 @@
-CONFIG_SYS_TEXT_BASE = 0x00f00000
include/configs/cm4008.h +4 -3
index 18b37d7..3518206 100644
@@ -115,9 +115,10 @@
 
 #define CONFIG_SYS_INIT_SP_ADDR	0x00020000 /* lowest 128k of RAM */
 
-#define PHYS_FLASH_1		0x02000000 /* Flash Bank #1 */
-#define PHYS_FLASH_SECT_SIZE    0x00020000 /* 128 KB sectors (x1) */
-#define CONFIG_SYS_FLASH_BASE		PHYS_FLASH_1
+/* CONFIG_SYS_TEXT_BASE and CONFIG_SYS_FLASH_BASE must match for both
+   relocation in lowlevel_init.S and function array in board.c */
+#define CONFIG_SYS_TEXT_BASE	0x02000000
+#define CONFIG_SYS_FLASH_BASE	CONFIG_SYS_TEXT_BASE
 
 #define CONFIG_SYS_FLASH_CFI
 #define CONFIG_FLASH_CFI_DRIVER		1
include/configs/cm41xx.h +4 -3
index 3f46b12..5f2d445 100644
@@ -115,9 +115,10 @@
 
 #define CONFIG_SYS_INIT_SP_ADDR	0x00020000 /* lowest 128k of RAM */
 
-#define PHYS_FLASH_1		0x02000000 /* Flash Bank #1 */
-#define PHYS_FLASH_SECT_SIZE    0x00020000 /* 128 KB sectors (x1) */
-#define CONFIG_SYS_FLASH_BASE		PHYS_FLASH_1
+/* CONFIG_SYS_TEXT_BASE and CONFIG_SYS_FLASH_BASE must match for both
+   relocation in lowlevel_init.S and function array in board.c */
+#define CONFIG_SYS_TEXT_BASE	0x02000000
+#define CONFIG_SYS_FLASH_BASE	CONFIG_SYS_TEXT_BASE
 
 #define CONFIG_SYS_FLASH_CFI
 #define CONFIG_FLASH_CFI_DRIVER		1
Signature · 1 line
1.7.10
#51 lore raw

PATCH v2 1/1 arm: cm4008, cm41xx: Fix ROM relocation

I do apologise. I mistakenly entered the wrong message ID for this mail; it is
In-Reply-To: <[email protected]>
Subject: Re: [U-Boot] [PATCH 2/3] cm4008: Fix ROM relocation.

I shall soon submit the updated patch that does belong in this thread. Sorry!

#52 lore raw

PATCH v2 1/1 arm: cm4008, cm41xx: Fix ROM relocation

In reply to Yann Vernier

Dear Yann Vernier,

Quoted 33 lines · Yann Vernier

Changed CONFIG_SYS_TEXT_BASE to actual address (required for board_init_f) and moved it into cm4008.h, along with a warning that it must match CONFIG_SYS_FLASH_BASE (since lowlevel_init relocates there). lowlevel_init now uses CONFIG_SYS_FLASH_BASE to map ROM, although the second bank is still mapped at 0x02400000-0x027fffff.
---
Changes for v2:
- Update to use CONFIG_SYS_FLASH_ constants only (no PHYS_FLASH)
- Use tabs where appropriate
- Update cm41xx also
- Explain the lowlevel_init change

---
 arch/arm/cpu/arm920t/ks8695/lowlevel_init.S |    9 +++++++--
 board/cm4008/config.mk                      |    1 -
 board/cm41xx/config.mk                      |    1 -
 include/configs/cm4008.h                    |    7 ++++---
 include/configs/cm41xx.h                    |    7 ++++---
 5 files changed, 15 insertions(+), 10 deletions(-)
 delete mode 100644 board/cm4008/config.mk
 delete mode 100644 board/cm41xx/config.mk
arch/arm/cpu/arm920t/ks8695/lowlevel_init.S +2 -0
index df13de6..7bb9ede 100644
@@ -92,11 +92,16 @@ lowlevel_init:
 	 * ram from address 0, and flash at 32MB.
 	 */
 	ldr	r1, =(KS8695_IO_BASE+KS8695_MEM_CTRL0)
+	/* Remap flash memory to 768MB size, such that it covers
+	   both 0 (boot) and 512MB (run) regions */

arch/arm/cpu/arm920t/ks8695/lowlevel_init.S lowlevel_init: · line 104

Quoted 10 lines
arch/arm/cpu/arm920t/ks8695/lowlevel_init.S +5 -2
 	ldr	r2, =0xbfc00040
 	str	r2, [r1]		/* large flash map */
-	ldr	pc, =(highflash+0x02000000-0x00f00000)	/* jump to high flash address */
+	/* Relies on CONFIG_SYS_FLASH_BASE==CONFIG_SYS_TEXT_BASE */
+	ldr	pc, =(highflash)	/* jump to high flash address */
 highflash:
-	ldr	r2, =0x8fe00040
+	/* Move ROM to high address, and reconfigure to 4MiB size */
+	ldr	r2, =(((CONFIG_SYS_FLASH_BASE+0x3f0000)<<(22-16))|	\
+		      (CONFIG_SYS_FLASH_BASE>>(16-12))|0x40)

again some magic ... Well I do not know this architecture in detail and can nothing say about the register footprint. I just hope somebody with access to tech spec of this cpu is able to understand how 'Move ROM to high address, and reconfigure to 4MiB size' is related to this magic.

Beside that I tend to ack this patch. Yann, have you some proposal to resolve my doubts?

Quoted 44 lines
arch/arm/cpu/arm920t/ks8695/lowlevel_init.S +0 -0
 	str	r2, [r1]		/* remap flash range */
 
 	/*
board/cm4008/config.mk deleted +0 -1
deleted file mode 100644
index 0d5923b..0000000
@@ -1 +0,0 @@
-CONFIG_SYS_TEXT_BASE = 0x00f00000
board/cm41xx/config.mk deleted +0 -1
deleted file mode 100644
index 0d5923b..0000000
@@ -1 +0,0 @@
-CONFIG_SYS_TEXT_BASE = 0x00f00000
include/configs/cm4008.h +4 -3
index 18b37d7..3518206 100644
@@ -115,9 +115,10 @@
 
 #define CONFIG_SYS_INIT_SP_ADDR	0x00020000 /* lowest 128k of RAM */
 
-#define PHYS_FLASH_1		0x02000000 /* Flash Bank #1 */
-#define PHYS_FLASH_SECT_SIZE    0x00020000 /* 128 KB sectors (x1) */
-#define CONFIG_SYS_FLASH_BASE		PHYS_FLASH_1
+/* CONFIG_SYS_TEXT_BASE and CONFIG_SYS_FLASH_BASE must match for both
+   relocation in lowlevel_init.S and function array in board.c */
+#define CONFIG_SYS_TEXT_BASE	0x02000000
+#define CONFIG_SYS_FLASH_BASE	CONFIG_SYS_TEXT_BASE
 
 #define CONFIG_SYS_FLASH_CFI
 #define CONFIG_FLASH_CFI_DRIVER		1
include/configs/cm41xx.h +0 -0
index 3f46b12..5f2d445 100644
@@ -115,9 +115,10 @@
 
 #define CONFIG_SYS_INIT_SP_ADDR	0x00020000 /* lowest 128k of RAM */
 

include/configs/cm41xx.h line 124

Quoted 10 lines
include/configs/cm41xx.h +4 -3
-#define PHYS_FLASH_1		0x02000000 /* Flash Bank #1 */
-#define PHYS_FLASH_SECT_SIZE    0x00020000 /* 128 KB sectors (x1) */
-#define CONFIG_SYS_FLASH_BASE		PHYS_FLASH_1
+/* CONFIG_SYS_TEXT_BASE and CONFIG_SYS_FLASH_BASE must match for both
+   relocation in lowlevel_init.S and function array in board.c */
+#define CONFIG_SYS_TEXT_BASE	0x02000000
+#define CONFIG_SYS_FLASH_BASE	CONFIG_SYS_TEXT_BASE
 
 #define CONFIG_SYS_FLASH_CFI
 #define CONFIG_FLASH_CFI_DRIVER		1

Best regards

Andreas Bie?mann

#53 lore raw

PATCH v2 1/1 arm: cm4008, cm41xx: Fix ROM relocation

Hi Yann,

Quoted 52 lines · Andreas Bie?mann

Dear Yann Vernier,

Quoted 33 lines · Yann Vernier

Changed CONFIG_SYS_TEXT_BASE to actual address (required for board_init_f) and moved it into cm4008.h, along with a warning that it must match CONFIG_SYS_FLASH_BASE (since lowlevel_init relocates there). lowlevel_init now uses CONFIG_SYS_FLASH_BASE to map ROM, although the second bank is still mapped at 0x02400000-0x027fffff.
---
Changes for v2:
- Update to use CONFIG_SYS_FLASH_ constants only (no PHYS_FLASH)
- Use tabs where appropriate
- Update cm41xx also
- Explain the lowlevel_init change

---
 arch/arm/cpu/arm920t/ks8695/lowlevel_init.S |    9 +++++++--
 board/cm4008/config.mk                      |    1 -
 board/cm41xx/config.mk                      |    1 -
 include/configs/cm4008.h                    |    7 ++++---
 include/configs/cm41xx.h                    |    7 ++++---
 5 files changed, 15 insertions(+), 10 deletions(-)
 delete mode 100644 board/cm4008/config.mk
 delete mode 100644 board/cm41xx/config.mk
arch/arm/cpu/arm920t/ks8695/lowlevel_init.S +2 -0
index df13de6..7bb9ede 100644
@@ -92,11 +92,16 @@ lowlevel_init:
 	 * ram from address 0, and flash at 32MB.
 	 */
 	ldr	r1, =(KS8695_IO_BASE+KS8695_MEM_CTRL0)
+	/* Remap flash memory to 768MB size, such that it covers
+	   both 0 (boot) and 512MB (run) regions */

arch/arm/cpu/arm920t/ks8695/lowlevel_init.S lowlevel_init: · line 104

Quoted 10 lines
arch/arm/cpu/arm920t/ks8695/lowlevel_init.S +5 -2
 	ldr	r2, =0xbfc00040
 	str	r2, [r1]		/* large flash map */
-	ldr	pc, =(highflash+0x02000000-0x00f00000)	/* jump to high flash address */
+	/* Relies on CONFIG_SYS_FLASH_BASE==CONFIG_SYS_TEXT_BASE */
+	ldr	pc, =(highflash)	/* jump to high flash address */
 highflash:
-	ldr	r2, =0x8fe00040
+	/* Move ROM to high address, and reconfigure to 4MiB size */
+	ldr	r2, =(((CONFIG_SYS_FLASH_BASE+0x3f0000)<<(22-16))|	\
+		      (CONFIG_SYS_FLASH_BASE>>(16-12))|0x40)

again some magic ... Well I do not know this architecture in detail and can nothing say about the register footprint. I just hope somebody with access to tech spec of this cpu is able to understand how 'Move ROM to high address, and reconfigure to 4MiB size' is related to this magic.

Quoted 2 lines

Beside that I tend to ack this patch. Yann, have you some proposal to resolve my doubts?

Did not hear any answer to this. Do we get a V3 for this patch?

Or should I assume that the pversions to pick are V2 for 1/3 and 2/3, and V3 for 3/3?

Amicalement,

Signature · 1 line
Albert.