All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH 3/3] cm4008: use common cfi_flash support
@ 2012-07-05  8:05 Yann Vernier
  2012-07-05  9:48 ` Andreas Bießmann
  0 siblings, 1 reply; 54+ messages in thread
From: Yann Vernier @ 2012-07-05  8:05 UTC (permalink / raw)
  To: u-boot

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

Signed-off-by: Yann Vernier <yann.vernier@orsoc.se>
---
 board/cm4008/Makefile    |    2 +-
 include/configs/cm4008.h |    4 ++++
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/board/cm4008/Makefile b/board/cm4008/Makefile
index 5b98824..22fd74e 100644
--- a/board/cm4008/Makefile
+++ b/board/cm4008/Makefile
@@ -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))
diff --git a/include/configs/cm4008.h b/include/configs/cm4008.h
index 7c2e113..6d1a1ae 100644
--- a/include/configs/cm4008.h
+++ b/include/configs/cm4008.h
@@ -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
  */
-- 
1.7.10

^ permalink raw reply related	[flat|nested] 54+ messages in thread

* [U-Boot] [PATCH 3/3] cm4008: use common cfi_flash support
  2012-07-05  8:05 [U-Boot] [PATCH 3/3] cm4008: use common cfi_flash support Yann Vernier
@ 2012-07-05  9:48 ` Andreas Bießmann
  2012-07-05 13:11   ` [U-Boot] [PATCH v2] arm: cm4008, cm41xx: " Yann Vernier
  2012-07-05 13:22   ` [U-Boot] [PATCH v2] arm: cm4008, cm41xx: Fix ROM relocation Yann Vernier
  0 siblings, 2 replies; 54+ messages in thread
From: Andreas Bießmann @ 2012-07-05  9:48 UTC (permalink / raw)
  To: u-boot

Dear Yann Vernier,

On 05.07.2012 10:05, Yann Vernier wrote:
> This change allows use of other flash chips than the two supported by
> the cm4008 flash.c. Tested with Micrel KSZ8695X demo board.
> 
> Signed-off-by: Yann Vernier <yann.vernier@orsoc.se>
> ---
>  board/cm4008/Makefile    |    2 +-
>  include/configs/cm4008.h |    4 ++++
>  2 files changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/board/cm4008/Makefile b/board/cm4008/Makefile
> index 5b98824..22fd74e 100644
> --- a/board/cm4008/Makefile
> +++ b/board/cm4008/Makefile
> @@ -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.

>  
>  SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
>  OBJS	:= $(addprefix $(obj),$(COBJS))
> diff --git a/include/configs/cm4008.h b/include/configs/cm4008.h
> index 7c2e113..6d1a1ae 100644
> --- a/include/configs/cm4008.h
> +++ b/include/configs/cm4008.h
> @@ -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

^ permalink raw reply	[flat|nested] 54+ messages in thread

* [U-Boot] [PATCH v2] arm: cm4008, cm41xx: use common cfi_flash support
  2012-07-05  9:48 ` Andreas Bießmann
@ 2012-07-05 13:11   ` Yann Vernier
  2012-07-05 15:04     ` Andreas Bießmann
  2012-07-05 13:22   ` [U-Boot] [PATCH v2] arm: cm4008, cm41xx: Fix ROM relocation Yann Vernier
  1 sibling, 1 reply; 54+ messages in thread
From: Yann Vernier @ 2012-07-05 13:11 UTC (permalink / raw)
  To: u-boot

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

Signed-off-by: Yann Vernier <yann.vernier@orsoc.se>
---
 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

diff --git a/board/cm4008/Makefile b/board/cm4008/Makefile
index 5b98824..dac422b 100644
--- a/board/cm4008/Makefile
+++ b/board/cm4008/Makefile
@@ -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))
diff --git a/board/cm4008/flash.c b/board/cm4008/flash.c
deleted file mode 100644
index 5522bf0..0000000
--- a/board/cm4008/flash.c
+++ /dev/null
@@ -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;
-}
diff --git a/board/cm41xx/Makefile b/board/cm41xx/Makefile
index 6214f8c..d49fce1 100644
--- a/board/cm41xx/Makefile
+++ b/board/cm41xx/Makefile
@@ -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))
diff --git a/board/cm41xx/flash.c b/board/cm41xx/flash.c
deleted file mode 100644
index 5522bf0..0000000
--- a/board/cm41xx/flash.c
+++ /dev/null
@@ -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;
-}
diff --git a/include/configs/cm4008.h b/include/configs/cm4008.h
index 58b0f4b..18b37d7 100644
--- a/include/configs/cm4008.h
+++ b/include/configs/cm4008.h
@@ -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
  */
diff --git a/include/configs/cm41xx.h b/include/configs/cm41xx.h
index d29040c..3f46b12 100644
--- a/include/configs/cm41xx.h
+++ b/include/configs/cm41xx.h
@@ -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
  */
-- 
1.7.10

^ permalink raw reply related	[flat|nested] 54+ messages in thread

* [U-Boot] [PATCH v2] arm: cm4008, cm41xx: Fix ROM relocation
  2012-07-05  9:48 ` Andreas Bießmann
  2012-07-05 13:11   ` [U-Boot] [PATCH v2] arm: cm4008, cm41xx: " Yann Vernier
@ 2012-07-05 13:22   ` Yann Vernier
  2012-07-05 13:41     ` Yann Vernier
  2012-07-05 15:19     ` Andreas Bießmann
  1 sibling, 2 replies; 54+ messages in thread
From: Yann Vernier @ 2012-07-05 13:22 UTC (permalink / raw)
  To: u-boot

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

Signed-off-by: Yann Vernier <yann.vernier@orsoc.se>
---
 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

diff --git a/arch/arm/cpu/arm920t/ks8695/lowlevel_init.S b/arch/arm/cpu/arm920t/ks8695/lowlevel_init.S
index df13de6..7bb9ede 100644
--- a/arch/arm/cpu/arm920t/ks8695/lowlevel_init.S
+++ b/arch/arm/cpu/arm920t/ks8695/lowlevel_init.S
@@ -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 */
 
 	/*
diff --git a/board/cm4008/config.mk b/board/cm4008/config.mk
deleted file mode 100644
index 0d5923b..0000000
--- a/board/cm4008/config.mk
+++ /dev/null
@@ -1 +0,0 @@
-CONFIG_SYS_TEXT_BASE = 0x00f00000
diff --git a/board/cm41xx/config.mk b/board/cm41xx/config.mk
deleted file mode 100644
index 0d5923b..0000000
--- a/board/cm41xx/config.mk
+++ /dev/null
@@ -1 +0,0 @@
-CONFIG_SYS_TEXT_BASE = 0x00f00000
diff --git a/include/configs/cm4008.h b/include/configs/cm4008.h
index 18b37d7..3518206 100644
--- a/include/configs/cm4008.h
+++ b/include/configs/cm4008.h
@@ -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
diff --git a/include/configs/cm41xx.h b/include/configs/cm41xx.h
index 3f46b12..5f2d445 100644
--- a/include/configs/cm41xx.h
+++ b/include/configs/cm41xx.h
@@ -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
-- 
1.7.10

^ permalink raw reply related	[flat|nested] 54+ messages in thread

* [U-Boot] [PATCH v2] arm: cm4008, cm41xx: Fix ROM relocation
  2012-07-05 13:22   ` [U-Boot] [PATCH v2] arm: cm4008, cm41xx: Fix ROM relocation Yann Vernier
@ 2012-07-05 13:41     ` Yann Vernier
  2012-07-05 15:19     ` Andreas Bießmann
  1 sibling, 0 replies; 54+ messages in thread
From: Yann Vernier @ 2012-07-05 13:41 UTC (permalink / raw)
  To: u-boot

I do apologise. I mistakenly entered the wrong message ID for this mail; it is 
In-Reply-To: <4FF56547.6070104@gmail.com> 
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!

^ permalink raw reply	[flat|nested] 54+ messages in thread

* [U-Boot] [PATCH v2] arm: cm4008, cm41xx: use common cfi_flash support
  2012-07-05 13:11   ` [U-Boot] [PATCH v2] arm: cm4008, cm41xx: " Yann Vernier
@ 2012-07-05 15:04     ` Andreas Bießmann
  2012-07-06  8:27       ` [U-Boot] [PATCH v3] " Yann Vernier
  0 siblings, 1 reply; 54+ messages in thread
From: Andreas Bießmann @ 2012-07-05 15:04 UTC (permalink / raw)
  To: u-boot

Dear Yann Vernier,

a simple small change request.

On 05.07.2012 15:11, Yann Vernier wrote:
> 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
> 
> Signed-off-by: Yann Vernier <yann.vernier@orsoc.se>
> ---
>  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>

> diff --git a/include/configs/cm4008.h b/include/configs/cm4008.h
> index 58b0f4b..18b37d7 100644
> --- a/include/configs/cm4008.h
> +++ b/include/configs/cm4008.h
> @@ -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.

> +#define CONFIG_SYS_FLASH_CFI_WIDTH	FLASH_CFI_8BIT
> +
>  /*-----------------------------------------------------------------------
>   * FLASH and environment organization
>   */
> diff --git a/include/configs/cm41xx.h b/include/configs/cm41xx.h
> index d29040c..3f46b12 100644
> --- a/include/configs/cm41xx.h
> +++ b/include/configs/cm41xx.h
> @@ -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

> +#define CONFIG_SYS_FLASH_CFI_WIDTH	FLASH_CFI_8BIT
> +
>  /*-----------------------------------------------------------------------
>   * FLASH and environment organization
>   */
> 

Best regards

Andreas Bie?mann

^ permalink raw reply	[flat|nested] 54+ messages in thread

* [U-Boot] [PATCH v2] arm: cm4008, cm41xx: Fix ROM relocation
  2012-07-05 13:22   ` [U-Boot] [PATCH v2] arm: cm4008, cm41xx: Fix ROM relocation Yann Vernier
  2012-07-05 13:41     ` Yann Vernier
@ 2012-07-05 15:19     ` Andreas Bießmann
  2012-07-12 19:37       ` Albert ARIBAUD
  1 sibling, 1 reply; 54+ messages in thread
From: Andreas Bießmann @ 2012-07-05 15:19 UTC (permalink / raw)
  To: u-boot

Dear Yann Vernier,

On 05.07.2012 15:22, Yann Vernier wrote:
> 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
> 
> Signed-off-by: Yann Vernier <yann.vernier@orsoc.se>
> ---
>  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
> 
> diff --git a/arch/arm/cpu/arm920t/ks8695/lowlevel_init.S b/arch/arm/cpu/arm920t/ks8695/lowlevel_init.S
> index df13de6..7bb9ede 100644
> --- a/arch/arm/cpu/arm920t/ks8695/lowlevel_init.S
> +++ b/arch/arm/cpu/arm920t/ks8695/lowlevel_init.S
> @@ -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)

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?

>  	str	r2, [r1]		/* remap flash range */
>  
>  	/*
> diff --git a/board/cm4008/config.mk b/board/cm4008/config.mk
> deleted file mode 100644
> index 0d5923b..0000000
> --- a/board/cm4008/config.mk
> +++ /dev/null
> @@ -1 +0,0 @@
> -CONFIG_SYS_TEXT_BASE = 0x00f00000
> diff --git a/board/cm41xx/config.mk b/board/cm41xx/config.mk
> deleted file mode 100644
> index 0d5923b..0000000
> --- a/board/cm41xx/config.mk
> +++ /dev/null
> @@ -1 +0,0 @@
> -CONFIG_SYS_TEXT_BASE = 0x00f00000
> diff --git a/include/configs/cm4008.h b/include/configs/cm4008.h
> index 18b37d7..3518206 100644
> --- a/include/configs/cm4008.h
> +++ b/include/configs/cm4008.h
> @@ -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
> diff --git a/include/configs/cm41xx.h b/include/configs/cm41xx.h
> index 3f46b12..5f2d445 100644
> --- a/include/configs/cm41xx.h
> +++ b/include/configs/cm41xx.h
> @@ -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
> 

Best regards

Andreas Bie?mann

^ permalink raw reply	[flat|nested] 54+ messages in thread

* [U-Boot] [PATCH v3] arm: cm4008, cm41xx: use common cfi_flash support
  2012-07-05 15:04     ` Andreas Bießmann
@ 2012-07-06  8:27       ` Yann Vernier
  2012-07-06  8:47         ` Andreas Bießmann
  0 siblings, 1 reply; 54+ messages in thread
From: Yann Vernier @ 2012-07-06  8:27 UTC (permalink / raw)
  To: u-boot

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

Signed-off-by: Yann Vernier <yann.vernier@orsoc.se>
---
 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

diff --git a/board/cm4008/Makefile b/board/cm4008/Makefile
index 5b98824..dac422b 100644
--- a/board/cm4008/Makefile
+++ b/board/cm4008/Makefile
@@ -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))
diff --git a/board/cm4008/flash.c b/board/cm4008/flash.c
deleted file mode 100644
index 5522bf0..0000000
--- a/board/cm4008/flash.c
+++ /dev/null
@@ -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;
-}
diff --git a/board/cm41xx/Makefile b/board/cm41xx/Makefile
index 6214f8c..d49fce1 100644
--- a/board/cm41xx/Makefile
+++ b/board/cm41xx/Makefile
@@ -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))
diff --git a/board/cm41xx/flash.c b/board/cm41xx/flash.c
deleted file mode 100644
index 5522bf0..0000000
--- a/board/cm41xx/flash.c
+++ /dev/null
@@ -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;
-}
diff --git a/include/configs/cm4008.h b/include/configs/cm4008.h
index 58b0f4b..b0806cc 100644
--- a/include/configs/cm4008.h
+++ b/include/configs/cm4008.h
@@ -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
  */
diff --git a/include/configs/cm41xx.h b/include/configs/cm41xx.h
index d29040c..ea9165a 100644
--- a/include/configs/cm41xx.h
+++ b/include/configs/cm41xx.h
@@ -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
  */
-- 
1.7.10

^ permalink raw reply related	[flat|nested] 54+ messages in thread

* [U-Boot] [PATCH v3] arm: cm4008, cm41xx: use common cfi_flash support
  2012-07-06  8:27       ` [U-Boot] [PATCH v3] " Yann Vernier
@ 2012-07-06  8:47         ` Andreas Bießmann
  2012-07-06 11:33           ` Albert ARIBAUD
  0 siblings, 1 reply; 54+ messages in thread
From: Andreas Bießmann @ 2012-07-06  8:47 UTC (permalink / raw)
  To: u-boot

On 06.07.2012 10:27, Yann Vernier wrote:
> 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
> 
> Signed-off-by: Yann Vernier <yann.vernieu@orsoc.se>

Acked-by: Andreas Bie?mann <andreas.devel@googlemail.com>

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

> ---
>  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

^ permalink raw reply	[flat|nested] 54+ messages in thread

* [U-Boot] [PATCH v3] arm: cm4008, cm41xx: use common cfi_flash support
  2012-07-06  8:47         ` Andreas Bießmann
@ 2012-07-06 11:33           ` Albert ARIBAUD
  2012-08-09 13:33             ` [U-Boot] [PATCH 11/11] arm: cm4008, cm41xx: read MAC address from flash Yann Vernier
                               ` (11 more replies)
  0 siblings, 12 replies; 54+ messages in thread
From: Albert ARIBAUD @ 2012-07-06 11:33 UTC (permalink / raw)
  To: u-boot

Hi Andreas,

On Fri, 06 Jul 2012 10:47:11 +0200, "Andreas Bie?mann"
<andreas.devel@googlemail.com> wrote:
> On 06.07.2012 10:27, Yann Vernier wrote:
> > 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
> > 
> > Signed-off-by: Yann Vernier <yann.vernieu@orsoc.se>
> 
> Acked-by: Andreas Bie?mann <andreas.devel@googlemail.com>
> 
> (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,
-- 
Albert.

^ permalink raw reply	[flat|nested] 54+ messages in thread

* [U-Boot] [PATCH v2] arm: cm4008, cm41xx: Fix ROM relocation
  2012-07-05 15:19     ` Andreas Bießmann
@ 2012-07-12 19:37       ` Albert ARIBAUD
  0 siblings, 0 replies; 54+ messages in thread
From: Albert ARIBAUD @ 2012-07-12 19:37 UTC (permalink / raw)
  To: u-boot

Hi Yann,

On Thu, 05 Jul 2012 17:19:00 +0200,
"Andreas Bie?mann" <andreas.devel@googlemail.com> wrote:

> Dear Yann Vernier,
> 
> On 05.07.2012 15:22, Yann Vernier wrote:
> > 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
> > 
> > Signed-off-by: Yann Vernier <yann.vernier@orsoc.se>
> > ---
> >  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
> > 
> > diff --git a/arch/arm/cpu/arm920t/ks8695/lowlevel_init.S b/arch/arm/cpu/arm920t/ks8695/lowlevel_init.S
> > index df13de6..7bb9ede 100644
> > --- a/arch/arm/cpu/arm920t/ks8695/lowlevel_init.S
> > +++ b/arch/arm/cpu/arm920t/ks8695/lowlevel_init.S
> > @@ -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)
> 
> 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?

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,
-- 
Albert.

^ permalink raw reply	[flat|nested] 54+ messages in thread

* [U-Boot] [PATCH 11/11] arm: cm4008, cm41xx: read MAC address from flash
  2012-07-06 11:33           ` Albert ARIBAUD
@ 2012-08-09 13:33             ` Yann Vernier
  2012-08-09 13:33             ` [U-Boot] [PATCH 00/11] ks8695 (cm4008, cm41xx) bugfixes, constant removals, configuration generalized Yann Vernier
                               ` (10 subsequent siblings)
  11 siblings, 0 replies; 54+ messages in thread
From: Yann Vernier @ 2012-08-09 13:33 UTC (permalink / raw)
  To: u-boot

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.

Signed-off-by: Yann Vernier <yann.vernier@orsoc.se>
---
 board/cm4008/cm4008.c |   12 ++++++++++++
 board/cm41xx/cm41xx.c |   12 ++++++++++++
 2 files changed, 24 insertions(+)

diff --git a/board/cm4008/cm4008.c b/board/cm4008/cm4008.c
index 6c0da9a..e14f8f4 100644
--- a/board/cm4008/cm4008.c
+++ b/board/cm4008/cm4008.c
@@ -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)
 {
diff --git a/board/cm41xx/cm41xx.c b/board/cm41xx/cm41xx.c
index 6aef617..771701d 100644
--- a/board/cm41xx/cm41xx.c
+++ b/board/cm41xx/cm41xx.c
@@ -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)
 {
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 54+ messages in thread

* [U-Boot] [PATCH 10/11] arm: ks8695: document bus speed
  2012-07-06 11:33           ` Albert ARIBAUD
  2012-08-09 13:33             ` [U-Boot] [PATCH 11/11] arm: cm4008, cm41xx: read MAC address from flash Yann Vernier
  2012-08-09 13:33             ` [U-Boot] [PATCH 00/11] ks8695 (cm4008, cm41xx) bugfixes, constant removals, configuration generalized Yann Vernier
@ 2012-08-09 13:33             ` Yann Vernier
  2012-08-09 13:33             ` [U-Boot] [PATCH 07/11] arm: ks8695/cm4008/cm41xx: Parameterize SDRAM Yann Vernier
                               ` (8 subsequent siblings)
  11 siblings, 0 replies; 54+ messages in thread
From: Yann Vernier @ 2012-08-09 13:33 UTC (permalink / raw)
  To: u-boot

Just use the existing #define instead of magic number.

Signed-off-by: Yann Vernier <yann.vernier@orsoc.se>
---
 arch/arm/cpu/arm920t/ks8695/lowlevel_init.S |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/arm/cpu/arm920t/ks8695/lowlevel_init.S
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)
-- 
1.7.10.4

^ permalink raw reply	[flat|nested] 54+ messages in thread

* [U-Boot] [PATCH 00/11] ks8695 (cm4008, cm41xx) bugfixes, constant removals, configuration generalized
  2012-07-06 11:33           ` Albert ARIBAUD
  2012-08-09 13:33             ` [U-Boot] [PATCH 11/11] arm: cm4008, cm41xx: read MAC address from flash Yann Vernier
@ 2012-08-09 13:33             ` Yann Vernier
  2012-10-04  9:15               ` Albert ARIBAUD
  2012-08-09 13:33             ` [U-Boot] [PATCH 10/11] arm: ks8695: document bus speed Yann Vernier
                               ` (9 subsequent siblings)
  11 siblings, 1 reply; 54+ messages in thread
From: Yann Vernier @ 2012-08-09 13:33 UTC (permalink / raw)
  To: u-boot

On Fri, 6 Jul 2012 13:33:42 +0200
Albert ARIBAUD <albert.u.boot@aribaud.net> wrote:

> 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

-- 
1.7.10.4

^ permalink raw reply	[flat|nested] 54+ messages in thread

* [U-Boot] [PATCH 08/11] arm: cm4008, cm41xx: don't define to 1
  2012-07-06 11:33           ` Albert ARIBAUD
                               ` (3 preceding siblings ...)
  2012-08-09 13:33             ` [U-Boot] [PATCH 07/11] arm: ks8695/cm4008/cm41xx: Parameterize SDRAM Yann Vernier
@ 2012-08-09 13:33             ` Yann Vernier
  2012-08-09 13:33             ` [U-Boot] [PATCH 09/11] arm: ks8695/cm4xxx: don't reconfigure switch Yann Vernier
                               ` (6 subsequent siblings)
  11 siblings, 0 replies; 54+ messages in thread
From: Yann Vernier @ 2012-08-09 13:33 UTC (permalink / raw)
  To: u-boot

Removed needless values for configuration macros.

Signed-off-by: Yann Vernier <yann.vernier@orsoc.se>
---
 include/configs/cm4008.h |   10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/include/configs/cm4008.h b/include/configs/cm4008.h
index 18f7900..43a2591 100644
--- a/include/configs/cm4008.h
+++ b/include/configs/cm4008.h
@@ -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	*/ 
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 54+ messages in thread

* [U-Boot] [PATCH 09/11] arm: ks8695/cm4xxx: don't reconfigure switch
  2012-07-06 11:33           ` Albert ARIBAUD
                               ` (4 preceding siblings ...)
  2012-08-09 13:33             ` [U-Boot] [PATCH 08/11] arm: cm4008, cm41xx: don't define to 1 Yann Vernier
@ 2012-08-09 13:33             ` Yann Vernier
  2012-08-09 13:33             ` [U-Boot] [PATCH 05/11] arm: cm4008, cm41xx: set gd->ram_size in dram_init Yann Vernier
                               ` (5 subsequent siblings)
  11 siblings, 0 replies; 54+ messages in thread
From: Yann Vernier @ 2012-08-09 13:33 UTC (permalink / raw)
  To: u-boot

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

Signed-off-by: Yann Vernier <yann.vernier@orsoc.se>
---
 arch/arm/cpu/arm920t/ks8695/lowlevel_init.S |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm/cpu/arm920t/ks8695/lowlevel_init.S
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]
 
-- 
1.7.10.4

^ permalink raw reply	[flat|nested] 54+ messages in thread

* [U-Boot] [PATCH 07/11] arm: ks8695/cm4008/cm41xx: Parameterize SDRAM
  2012-07-06 11:33           ` Albert ARIBAUD
                               ` (2 preceding siblings ...)
  2012-08-09 13:33             ` [U-Boot] [PATCH 10/11] arm: ks8695: document bus speed Yann Vernier
@ 2012-08-09 13:33             ` Yann Vernier
  2012-08-09 13:33             ` [U-Boot] [PATCH 08/11] arm: cm4008, cm41xx: don't define to 1 Yann Vernier
                               ` (7 subsequent siblings)
  11 siblings, 0 replies; 54+ messages in thread
From: Yann Vernier @ 2012-08-09 13:33 UTC (permalink / raw)
  To: u-boot

Allows configuration macros to set SDRAM parameters.

Signed-off-by: Yann Vernier <yann.vernier@orsoc.se>
---
 arch/arm/cpu/arm920t/ks8695/lowlevel_init.S |   20 +++++++++++---------
 1 file changed, 11 insertions(+), 9 deletions(-)

diff --git a/arch/arm/cpu/arm920t/ks8695/lowlevel_init.S
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
-- 
1.7.10.4

^ permalink raw reply	[flat|nested] 54+ messages in thread

* [U-Boot] [PATCH 05/11] arm: cm4008, cm41xx: set gd->ram_size in dram_init
  2012-07-06 11:33           ` Albert ARIBAUD
                               ` (5 preceding siblings ...)
  2012-08-09 13:33             ` [U-Boot] [PATCH 09/11] arm: ks8695/cm4xxx: don't reconfigure switch Yann Vernier
@ 2012-08-09 13:33             ` Yann Vernier
  2012-08-09 13:33             ` [U-Boot] [PATCH 03/11] arm: ks8695eth: Use MAC address from environment Yann Vernier
                               ` (4 subsequent siblings)
  11 siblings, 0 replies; 54+ messages in thread
From: Yann Vernier @ 2012-08-09 13:33 UTC (permalink / raw)
  To: u-boot

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.

Signed-off-by: Yann Vernier <yann.vernier@orsoc.se>
---
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(-)

diff --git a/board/cm4008/cm4008.c b/board/cm4008/cm4008.c
index ed493a8..6c0da9a 100644
--- a/board/cm4008/cm4008.c
+++ b/board/cm4008/cm4008.c
@@ -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);
 }
diff --git a/board/cm41xx/cm41xx.c b/board/cm41xx/cm41xx.c
index d9dff4e..6aef617 100644
--- a/board/cm41xx/cm41xx.c
+++ b/board/cm41xx/cm41xx.c
@@ -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);
 }
diff --git a/include/configs/cm4008.h b/include/configs/cm4008.h
index fe62f73..18f7900 100644
--- a/include/configs/cm4008.h
+++ b/include/configs/cm4008.h
@@ -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 */ 
diff --git a/include/configs/cm41xx.h b/include/configs/cm41xx.h
index 485792c..ed345b0 100644
--- a/include/configs/cm41xx.h
+++ b/include/configs/cm41xx.h
@@ -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 */ 
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 54+ messages in thread

* [U-Boot] [PATCH 03/11] arm: ks8695eth: Use MAC address from environment
  2012-07-06 11:33           ` Albert ARIBAUD
                               ` (6 preceding siblings ...)
  2012-08-09 13:33             ` [U-Boot] [PATCH 05/11] arm: cm4008, cm41xx: set gd->ram_size in dram_init Yann Vernier
@ 2012-08-09 13:33             ` Yann Vernier
  2012-08-09 13:33             ` [U-Boot] [PATCH 04/11] arm: cm4008, cm41xx: use common cfi_flash support Yann Vernier
                               ` (3 subsequent siblings)
  11 siblings, 0 replies; 54+ messages in thread
From: Yann Vernier @ 2012-08-09 13:33 UTC (permalink / raw)
  To: u-boot

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

Signed-off-by: Yann Vernier <yann.vernier@orsoc.se>
---
 drivers/net/ks8695eth.c |   38 +++++++++-----------------------------
 1 file changed, 9 insertions(+), 29 deletions(-)

diff --git a/drivers/net/ks8695eth.c b/drivers/net/ks8695eth.c
index b4904b6..2dda7ab 100644
--- a/drivers/net/ks8695eth.c
+++ b/drivers/net/ks8695eth.c
@@ -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);
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 54+ messages in thread

* [U-Boot] [PATCH 06/11] arm: cm4008, cm41xx: Fix ROM relocation
  2012-07-06 11:33           ` Albert ARIBAUD
                               ` (8 preceding siblings ...)
  2012-08-09 13:33             ` [U-Boot] [PATCH 04/11] arm: cm4008, cm41xx: use common cfi_flash support Yann Vernier
@ 2012-08-09 13:33             ` Yann Vernier
  2012-08-09 13:33             ` [U-Boot] [PATCH 02/11] arm: ks8695: more macros for register values Yann Vernier
  2012-08-09 13:33             ` [U-Boot] [PATCH 01/11] arm: ks8695: use defined constants for UART Yann Vernier
  11 siblings, 0 replies; 54+ messages in thread
From: Yann Vernier @ 2012-08-09 13:33 UTC (permalink / raw)
  To: u-boot

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

Signed-off-by: Yann Vernier <yann.vernier@orsoc.se>
---
 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

diff --git a/arch/arm/cpu/arm920t/ks8695/lowlevel_init.S
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 */
diff --git a/board/cm4008/config.mk b/board/cm4008/config.mk
deleted file mode 100644
index 0d5923b..0000000
--- a/board/cm4008/config.mk
+++ /dev/null
@@ -1 +0,0 @@
-CONFIG_SYS_TEXT_BASE = 0x00f00000
diff --git a/board/cm41xx/config.mk b/board/cm41xx/config.mk
deleted file mode 100644
index 0d5923b..0000000
--- a/board/cm41xx/config.mk
+++ /dev/null
@@ -1 +0,0 @@
-CONFIG_SYS_TEXT_BASE = 0x00f00000
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 54+ messages in thread

* [U-Boot] [PATCH 04/11] arm: cm4008, cm41xx: use common cfi_flash support
  2012-07-06 11:33           ` Albert ARIBAUD
                               ` (7 preceding siblings ...)
  2012-08-09 13:33             ` [U-Boot] [PATCH 03/11] arm: ks8695eth: Use MAC address from environment Yann Vernier
@ 2012-08-09 13:33             ` Yann Vernier
  2012-08-09 13:33             ` [U-Boot] [PATCH 06/11] arm: cm4008, cm41xx: Fix ROM relocation Yann Vernier
                               ` (2 subsequent siblings)
  11 siblings, 0 replies; 54+ messages in thread
From: Yann Vernier @ 2012-08-09 13:33 UTC (permalink / raw)
  To: u-boot

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)

Signed-off-by: Yann Vernier <yann.vernier@orsoc.se>
---
 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

diff --git a/board/cm4008/Makefile b/board/cm4008/Makefile
index 5b98824..dac422b 100644
--- a/board/cm4008/Makefile
+++ b/board/cm4008/Makefile
@@ -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))
diff --git a/board/cm4008/flash.c b/board/cm4008/flash.c
deleted file mode 100644
index 5522bf0..0000000
--- a/board/cm4008/flash.c
+++ /dev/null
@@ -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;
-}
diff --git a/board/cm41xx/Makefile b/board/cm41xx/Makefile
index 6214f8c..d49fce1 100644
--- a/board/cm41xx/Makefile
+++ b/board/cm41xx/Makefile
@@ -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))
diff --git a/board/cm41xx/flash.c b/board/cm41xx/flash.c
deleted file mode 100644
index 5522bf0..0000000
--- a/board/cm41xx/flash.c
+++ /dev/null
@@ -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;
-}
diff --git a/include/configs/cm4008.h b/include/configs/cm4008.h
index 408e918..fe62f73 100644
--- a/include/configs/cm4008.h
+++ b/include/configs/cm4008.h
@@ -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
--- a/include/configs/cm41xx.h
+++ b/include/configs/cm41xx.h
@@ -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 */ 
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 54+ messages in thread

* [U-Boot] [PATCH 02/11] arm: ks8695: more macros for register values
  2012-07-06 11:33           ` Albert ARIBAUD
                               ` (9 preceding siblings ...)
  2012-08-09 13:33             ` [U-Boot] [PATCH 06/11] arm: cm4008, cm41xx: Fix ROM relocation Yann Vernier
@ 2012-08-09 13:33             ` Yann Vernier
  2012-08-09 13:33             ` [U-Boot] [PATCH 01/11] arm: ks8695: use defined constants for UART Yann Vernier
  11 siblings, 0 replies; 54+ messages in thread
From: Yann Vernier @ 2012-08-09 13:33 UTC (permalink / raw)
  To: u-boot

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

Signed-off-by: Yann Vernier <yann.vernier@orsoc.se>
---
 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

diff --git a/arch/arm/include/asm/arch-ks8695/platform.h
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
diff --git a/arch/arm/include/asm/arch-ks8695/regvalues.h
b/arch/arm/include/asm/arch-ks8695/regvalues.h new file mode 100644
index 0000000..7d29bbf
--- /dev/null
+++ b/arch/arm/include/asm/arch-ks8695/regvalues.h
@@ -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
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 54+ messages in thread

* [U-Boot] [PATCH 01/11] arm: ks8695: use defined constants for UART
  2012-07-06 11:33           ` Albert ARIBAUD
                               ` (10 preceding siblings ...)
  2012-08-09 13:33             ` [U-Boot] [PATCH 02/11] arm: ks8695: more macros for register values Yann Vernier
@ 2012-08-09 13:33             ` Yann Vernier
  11 siblings, 0 replies; 54+ messages in thread
From: Yann Vernier @ 2012-08-09 13:33 UTC (permalink / raw)
  To: u-boot

CONFIG_BAUDRATE and KS8695_UART_LINEC_WLEN8 used for UART registers

Signed-off-by: Yann Vernier <yann.vernier@orsoc.se>
---
 arch/arm/cpu/arm920t/ks8695/lowlevel_init.S |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/arch/arm/cpu/arm920t/ks8695/lowlevel_init.S
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
-- 
1.7.10.4

^ permalink raw reply	[flat|nested] 54+ messages in thread

* [U-Boot] [PATCH 00/11] ks8695 (cm4008, cm41xx) bugfixes, constant removals, configuration generalized
  2012-08-09 13:33             ` [U-Boot] [PATCH 00/11] ks8695 (cm4008, cm41xx) bugfixes, constant removals, configuration generalized Yann Vernier
@ 2012-10-04  9:15               ` Albert ARIBAUD
  2012-10-05 12:09                 ` [U-Boot] [PATCH 00/11] ks8695 (cm4008, cm41xx) bugfixes, constant removals, configuration generalized (repost) Yann Vernier
  0 siblings, 1 reply; 54+ messages in thread
From: Albert ARIBAUD @ 2012-10-04  9:15 UTC (permalink / raw)
  To: u-boot

Hi Yann,

On Thu, 9 Aug 2012 15:33:06 +0200, Yann Vernier <yann.vernier@orsoc.se>
wrote:

> On Fri, 6 Jul 2012 13:33:42 +0200
> Albert ARIBAUD <albert.u.boot@aribaud.net> wrote:
> 
> > 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
> 

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,
-- 
Albert.

^ permalink raw reply	[flat|nested] 54+ messages in thread

* [U-Boot] [PATCH 00/11] ks8695 (cm4008, cm41xx) bugfixes, constant removals, configuration generalized (repost)
  2012-10-04  9:15               ` Albert ARIBAUD
@ 2012-10-05 12:09                 ` Yann Vernier
  2012-10-05 12:09                   ` [U-Boot] [PATCH 01/11] arm: ks8695: use defined constants for UART Yann Vernier
                                     ` (11 more replies)
  0 siblings, 12 replies; 54+ messages in thread
From: Yann Vernier @ 2012-10-05 12:09 UTC (permalink / raw)
  To: u-boot

On Thu, 4 Oct 2012 11:15:06 +0200
Albert ARIBAUD <albert.u.boot@aribaud.net> wrote:
> 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

-- 
1.7.10.4

^ permalink raw reply	[flat|nested] 54+ messages in thread

* [U-Boot] [PATCH 01/11] arm: ks8695: use defined constants for UART
  2012-10-05 12:09                 ` [U-Boot] [PATCH 00/11] ks8695 (cm4008, cm41xx) bugfixes, constant removals, configuration generalized (repost) Yann Vernier
@ 2012-10-05 12:09                   ` Yann Vernier
  2012-10-26 21:34                     ` Albert ARIBAUD
  2012-10-05 12:09                   ` [U-Boot] [PATCH 02/11] arm: ks8695: more macros for register values Yann Vernier
                                     ` (10 subsequent siblings)
  11 siblings, 1 reply; 54+ messages in thread
From: Yann Vernier @ 2012-10-05 12:09 UTC (permalink / raw)
  To: u-boot

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(-)

diff --git a/arch/arm/cpu/arm920t/ks8695/lowlevel_init.S 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
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 54+ messages in thread

* [U-Boot] [PATCH 02/11] arm: ks8695: more macros for register values
  2012-10-05 12:09                 ` [U-Boot] [PATCH 00/11] ks8695 (cm4008, cm41xx) bugfixes, constant removals, configuration generalized (repost) Yann Vernier
  2012-10-05 12:09                   ` [U-Boot] [PATCH 01/11] arm: ks8695: use defined constants for UART Yann Vernier
@ 2012-10-05 12:09                   ` Yann Vernier
  2012-10-18 18:57                     ` Albert ARIBAUD
  2012-10-05 12:09                   ` [U-Boot] [PATCH 03/11] arm: ks8695eth: Use MAC address from environment Yann Vernier
                                     ` (9 subsequent siblings)
  11 siblings, 1 reply; 54+ messages in thread
From: Yann Vernier @ 2012-10-05 12:09 UTC (permalink / raw)
  To: u-boot

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(-)

diff --git a/arch/arm/include/asm/arch-ks8695/platform.h 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
diff --git a/arch/arm/include/asm/arch-ks8695/regvalues.h b/arch/arm/include/asm/arch-ks8695/regvalues.h
new file mode 100644
index 0000000..7d29bbf
--- /dev/null
+++ b/arch/arm/include/asm/arch-ks8695/regvalues.h
@@ -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
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 54+ messages in thread

* [U-Boot] [PATCH 03/11] arm: ks8695eth: Use MAC address from environment
  2012-10-05 12:09                 ` [U-Boot] [PATCH 00/11] ks8695 (cm4008, cm41xx) bugfixes, constant removals, configuration generalized (repost) Yann Vernier
  2012-10-05 12:09                   ` [U-Boot] [PATCH 01/11] arm: ks8695: use defined constants for UART Yann Vernier
  2012-10-05 12:09                   ` [U-Boot] [PATCH 02/11] arm: ks8695: more macros for register values Yann Vernier
@ 2012-10-05 12:09                   ` Yann Vernier
  2012-10-18 19:00                     ` Albert ARIBAUD
  2012-10-18 20:55                     ` Joe Hershberger
  2012-10-05 12:09                   ` [U-Boot] [PATCH 04/11] arm: cm4008, cm41xx: use common cfi_flash support Yann Vernier
                                     ` (8 subsequent siblings)
  11 siblings, 2 replies; 54+ messages in thread
From: Yann Vernier @ 2012-10-05 12:09 UTC (permalink / raw)
  To: u-boot

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(-)

diff --git a/drivers/net/ks8695eth.c b/drivers/net/ks8695eth.c
index b4904b6..2dda7ab 100644
--- a/drivers/net/ks8695eth.c
+++ b/drivers/net/ks8695eth.c
@@ -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);
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 54+ messages in thread

* [U-Boot] [PATCH 04/11] arm: cm4008, cm41xx: use common cfi_flash support
  2012-10-05 12:09                 ` [U-Boot] [PATCH 00/11] ks8695 (cm4008, cm41xx) bugfixes, constant removals, configuration generalized (repost) Yann Vernier
                                     ` (2 preceding siblings ...)
  2012-10-05 12:09                   ` [U-Boot] [PATCH 03/11] arm: ks8695eth: Use MAC address from environment Yann Vernier
@ 2012-10-05 12:09                   ` Yann Vernier
  2012-10-05 12:09                   ` [U-Boot] [PATCH 05/11] arm: cm4008, cm41xx: set gd->ram_size in dram_init Yann Vernier
                                     ` (7 subsequent siblings)
  11 siblings, 0 replies; 54+ messages in thread
From: Yann Vernier @ 2012-10-05 12:09 UTC (permalink / raw)
  To: u-boot

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(-)

diff --git a/board/cm4008/Makefile b/board/cm4008/Makefile
index 5b98824..dac422b 100644
--- a/board/cm4008/Makefile
+++ b/board/cm4008/Makefile
@@ -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))
diff --git a/board/cm4008/flash.c b/board/cm4008/flash.c
deleted file mode 100644
index 5522bf0..0000000
--- a/board/cm4008/flash.c
+++ /dev/null
@@ -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;
-}
diff --git a/board/cm41xx/Makefile b/board/cm41xx/Makefile
index 6214f8c..d49fce1 100644
--- a/board/cm41xx/Makefile
+++ b/board/cm41xx/Makefile
@@ -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))
diff --git a/board/cm41xx/flash.c b/board/cm41xx/flash.c
deleted file mode 100644
index 5522bf0..0000000
--- a/board/cm41xx/flash.c
+++ /dev/null
@@ -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;
-}
diff --git a/include/configs/cm4008.h b/include/configs/cm4008.h
index 408e918..fe62f73 100644
--- a/include/configs/cm4008.h
+++ b/include/configs/cm4008.h
@@ -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
--- a/include/configs/cm41xx.h
+++ b/include/configs/cm41xx.h
@@ -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 */
 
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 54+ messages in thread

* [U-Boot] [PATCH 05/11] arm: cm4008, cm41xx: set gd->ram_size in dram_init
  2012-10-05 12:09                 ` [U-Boot] [PATCH 00/11] ks8695 (cm4008, cm41xx) bugfixes, constant removals, configuration generalized (repost) Yann Vernier
                                     ` (3 preceding siblings ...)
  2012-10-05 12:09                   ` [U-Boot] [PATCH 04/11] arm: cm4008, cm41xx: use common cfi_flash support Yann Vernier
@ 2012-10-05 12:09                   ` Yann Vernier
  2012-10-05 12:09                   ` [U-Boot] [PATCH 06/11] arm: cm4008, cm41xx: Fix ROM relocation Yann Vernier
                                     ` (6 subsequent siblings)
  11 siblings, 0 replies; 54+ messages in thread
From: Yann Vernier @ 2012-10-05 12:09 UTC (permalink / raw)
  To: u-boot

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.

Signed-off-by: Yann Vernier <yann.vernier@orsoc.se>
---
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(-)

diff --git a/board/cm4008/cm4008.c b/board/cm4008/cm4008.c
index ed493a8..6c0da9a 100644
--- a/board/cm4008/cm4008.c
+++ b/board/cm4008/cm4008.c
@@ -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);
 }
diff --git a/board/cm41xx/cm41xx.c b/board/cm41xx/cm41xx.c
index d9dff4e..6aef617 100644
--- a/board/cm41xx/cm41xx.c
+++ b/board/cm41xx/cm41xx.c
@@ -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);
 }
diff --git a/include/configs/cm4008.h b/include/configs/cm4008.h
index fe62f73..18f7900 100644
--- a/include/configs/cm4008.h
+++ b/include/configs/cm4008.h
@@ -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 */
 
diff --git a/include/configs/cm41xx.h b/include/configs/cm41xx.h
index 485792c..ed345b0 100644
--- a/include/configs/cm41xx.h
+++ b/include/configs/cm41xx.h
@@ -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 */
 
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 54+ messages in thread

* [U-Boot] [PATCH 06/11] arm: cm4008, cm41xx: Fix ROM relocation
  2012-10-05 12:09                 ` [U-Boot] [PATCH 00/11] ks8695 (cm4008, cm41xx) bugfixes, constant removals, configuration generalized (repost) Yann Vernier
                                     ` (4 preceding siblings ...)
  2012-10-05 12:09                   ` [U-Boot] [PATCH 05/11] arm: cm4008, cm41xx: set gd->ram_size in dram_init Yann Vernier
@ 2012-10-05 12:09                   ` Yann Vernier
  2012-10-18 19:09                     ` Albert ARIBAUD
  2012-10-05 12:09                   ` [U-Boot] [PATCH 07/11] arm: ks8695/cm4008/cm41xx: Parameterize SDRAM Yann Vernier
                                     ` (5 subsequent siblings)
  11 siblings, 1 reply; 54+ messages in thread
From: Yann Vernier @ 2012-10-05 12:09 UTC (permalink / raw)
  To: u-boot

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(-)

diff --git a/arch/arm/cpu/arm920t/ks8695/lowlevel_init.S 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 */
diff --git a/board/cm4008/config.mk b/board/cm4008/config.mk
deleted file mode 100644
index 0d5923b..0000000
--- a/board/cm4008/config.mk
+++ /dev/null
@@ -1 +0,0 @@
-CONFIG_SYS_TEXT_BASE = 0x00f00000
diff --git a/board/cm41xx/config.mk b/board/cm41xx/config.mk
deleted file mode 100644
index 0d5923b..0000000
--- a/board/cm41xx/config.mk
+++ /dev/null
@@ -1 +0,0 @@
-CONFIG_SYS_TEXT_BASE = 0x00f00000
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 54+ messages in thread

* [U-Boot] [PATCH 07/11] arm: ks8695/cm4008/cm41xx: Parameterize SDRAM
  2012-10-05 12:09                 ` [U-Boot] [PATCH 00/11] ks8695 (cm4008, cm41xx) bugfixes, constant removals, configuration generalized (repost) Yann Vernier
                                     ` (5 preceding siblings ...)
  2012-10-05 12:09                   ` [U-Boot] [PATCH 06/11] arm: cm4008, cm41xx: Fix ROM relocation Yann Vernier
@ 2012-10-05 12:09                   ` Yann Vernier
  2012-10-18 19:11                     ` Albert ARIBAUD
  2012-10-05 12:09                   ` [U-Boot] [PATCH 08/11] arm: cm4008, cm41xx: don't define to 1 Yann Vernier
                                     ` (4 subsequent siblings)
  11 siblings, 1 reply; 54+ messages in thread
From: Yann Vernier @ 2012-10-05 12:09 UTC (permalink / raw)
  To: u-boot

Allows configuration macros to set SDRAM parameters.
---
 arch/arm/cpu/arm920t/ks8695/lowlevel_init.S |   20 +++++++++++---------
 1 file changed, 11 insertions(+), 9 deletions(-)

diff --git a/arch/arm/cpu/arm920t/ks8695/lowlevel_init.S 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
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 54+ messages in thread

* [U-Boot] [PATCH 08/11] arm: cm4008, cm41xx: don't define to 1
  2012-10-05 12:09                 ` [U-Boot] [PATCH 00/11] ks8695 (cm4008, cm41xx) bugfixes, constant removals, configuration generalized (repost) Yann Vernier
                                     ` (6 preceding siblings ...)
  2012-10-05 12:09                   ` [U-Boot] [PATCH 07/11] arm: ks8695/cm4008/cm41xx: Parameterize SDRAM Yann Vernier
@ 2012-10-05 12:09                   ` Yann Vernier
  2012-10-05 12:09                   ` [U-Boot] [PATCH 09/11] arm: ks8695/cm4xxx: don't reconfigure switch Yann Vernier
                                     ` (3 subsequent siblings)
  11 siblings, 0 replies; 54+ messages in thread
From: Yann Vernier @ 2012-10-05 12:09 UTC (permalink / raw)
  To: u-boot

Removed needless values for configuration macros.
---
 include/configs/cm4008.h |   10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/include/configs/cm4008.h b/include/configs/cm4008.h
index 18f7900..43a2591 100644
--- a/include/configs/cm4008.h
+++ b/include/configs/cm4008.h
@@ -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	*/
 
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 54+ messages in thread

* [U-Boot] [PATCH 09/11] arm: ks8695/cm4xxx: don't reconfigure switch
  2012-10-05 12:09                 ` [U-Boot] [PATCH 00/11] ks8695 (cm4008, cm41xx) bugfixes, constant removals, configuration generalized (repost) Yann Vernier
                                     ` (7 preceding siblings ...)
  2012-10-05 12:09                   ` [U-Boot] [PATCH 08/11] arm: cm4008, cm41xx: don't define to 1 Yann Vernier
@ 2012-10-05 12:09                   ` Yann Vernier
  2012-10-18 19:13                     ` Albert ARIBAUD
  2012-10-05 12:09                   ` [U-Boot] [PATCH 10/11] arm: ks8695: document bus speed Yann Vernier
                                     ` (2 subsequent siblings)
  11 siblings, 1 reply; 54+ messages in thread
From: Yann Vernier @ 2012-10-05 12:09 UTC (permalink / raw)
  To: u-boot

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(-)

diff --git a/arch/arm/cpu/arm920t/ks8695/lowlevel_init.S 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]
 
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 54+ messages in thread

* [U-Boot] [PATCH 10/11] arm: ks8695: document bus speed
  2012-10-05 12:09                 ` [U-Boot] [PATCH 00/11] ks8695 (cm4008, cm41xx) bugfixes, constant removals, configuration generalized (repost) Yann Vernier
                                     ` (8 preceding siblings ...)
  2012-10-05 12:09                   ` [U-Boot] [PATCH 09/11] arm: ks8695/cm4xxx: don't reconfigure switch Yann Vernier
@ 2012-10-05 12:09                   ` Yann Vernier
  2012-10-05 12:09                   ` [U-Boot] [PATCH 11/11] arm: cm4008, cm41xx: read MAC address from flash Yann Vernier
  2012-11-10  8:03                   ` [U-Boot] [PATCH 00/11] ks8695 (cm4008, cm41xx) bugfixes, constant removals, configuration generalized (repost) Albert ARIBAUD
  11 siblings, 0 replies; 54+ messages in thread
From: Yann Vernier @ 2012-10-05 12:09 UTC (permalink / raw)
  To: u-boot

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(-)

diff --git a/arch/arm/cpu/arm920t/ks8695/lowlevel_init.S 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)
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 54+ messages in thread

* [U-Boot] [PATCH 11/11] arm: cm4008, cm41xx: read MAC address from flash
  2012-10-05 12:09                 ` [U-Boot] [PATCH 00/11] ks8695 (cm4008, cm41xx) bugfixes, constant removals, configuration generalized (repost) Yann Vernier
                                     ` (9 preceding siblings ...)
  2012-10-05 12:09                   ` [U-Boot] [PATCH 10/11] arm: ks8695: document bus speed Yann Vernier
@ 2012-10-05 12:09                   ` Yann Vernier
  2012-10-18 19:14                     ` Albert ARIBAUD
  2012-11-10  8:03                   ` [U-Boot] [PATCH 00/11] ks8695 (cm4008, cm41xx) bugfixes, constant removals, configuration generalized (repost) Albert ARIBAUD
  11 siblings, 1 reply; 54+ messages in thread
From: Yann Vernier @ 2012-10-05 12:09 UTC (permalink / raw)
  To: u-boot

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(+)

diff --git a/board/cm4008/cm4008.c b/board/cm4008/cm4008.c
index 6c0da9a..e14f8f4 100644
--- a/board/cm4008/cm4008.c
+++ b/board/cm4008/cm4008.c
@@ -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)
 {
diff --git a/board/cm41xx/cm41xx.c b/board/cm41xx/cm41xx.c
index 6aef617..771701d 100644
--- a/board/cm41xx/cm41xx.c
+++ b/board/cm41xx/cm41xx.c
@@ -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)
 {
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 54+ messages in thread

* [U-Boot] [PATCH 02/11] arm: ks8695: more macros for register values
  2012-10-05 12:09                   ` [U-Boot] [PATCH 02/11] arm: ks8695: more macros for register values Yann Vernier
@ 2012-10-18 18:57                     ` Albert ARIBAUD
  2012-11-19 11:55                       ` [U-Boot] [PATCH] " Yann Vernier
  0 siblings, 1 reply; 54+ messages in thread
From: Albert ARIBAUD @ 2012-10-18 18:57 UTC (permalink / raw)
  To: u-boot

Hi Yann,

On Fri,  5 Oct 2012 14:09:49 +0200, Yann Vernier
<yann.vernier@orsoc.se> wrote:

> 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(-)
> 
> diff --git a/arch/arm/include/asm/arch-ks8695/platform.h 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__

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__.

>  #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*/

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

>  #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
> diff --git a/arch/arm/include/asm/arch-ks8695/regvalues.h b/arch/arm/include/asm/arch-ks8695/regvalues.h
> new file mode 100644
> index 0000000..7d29bbf
> --- /dev/null
> +++ b/arch/arm/include/asm/arch-ks8695/regvalues.h
> @@ -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__

Same comment as above, make it specific.

> +/* 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

Amicalement,
-- 
Albert.

^ permalink raw reply	[flat|nested] 54+ messages in thread

* [U-Boot] [PATCH 03/11] arm: ks8695eth: Use MAC address from environment
  2012-10-05 12:09                   ` [U-Boot] [PATCH 03/11] arm: ks8695eth: Use MAC address from environment Yann Vernier
@ 2012-10-18 19:00                     ` Albert ARIBAUD
  2012-10-18 20:55                     ` Joe Hershberger
  1 sibling, 0 replies; 54+ messages in thread
From: Albert ARIBAUD @ 2012-10-18 19:00 UTC (permalink / raw)
  To: u-boot

Hi Yann,

On Fri,  5 Oct 2012 14:09:50 +0200, Yann Vernier
<yann.vernier@orsoc.se> wrote:

> 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(-)
> 
> diff --git a/drivers/net/ks8695eth.c b/drivers/net/ks8695eth.c
> index b4904b6..2dda7ab 100644
> --- a/drivers/net/ks8695eth.c
> +++ b/drivers/net/ks8695eth.c
> @@ -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);

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

Amicalement,
-- 
Albert.

^ permalink raw reply	[flat|nested] 54+ messages in thread

* [U-Boot] [PATCH 06/11] arm: cm4008, cm41xx: Fix ROM relocation
  2012-10-05 12:09                   ` [U-Boot] [PATCH 06/11] arm: cm4008, cm41xx: Fix ROM relocation Yann Vernier
@ 2012-10-18 19:09                     ` Albert ARIBAUD
  2012-10-19  8:08                       ` Yann Vernier
  0 siblings, 1 reply; 54+ messages in thread
From: Albert ARIBAUD @ 2012-10-18 19:09 UTC (permalink / raw)
  To: u-boot

Hi Yann,

On Fri,  5 Oct 2012 14:09:53 +0200, Yann Vernier
<yann.vernier@orsoc.se> wrote:

> 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(-)
> 
> diff --git a/arch/arm/cpu/arm920t/ks8695/lowlevel_init.S 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 */
> diff --git a/board/cm4008/config.mk b/board/cm4008/config.mk
> deleted file mode 100644
> index 0d5923b..0000000
> --- a/board/cm4008/config.mk
> +++ /dev/null
> @@ -1 +0,0 @@
> -CONFIG_SYS_TEXT_BASE = 0x00f00000
> diff --git a/board/cm41xx/config.mk b/board/cm41xx/config.mk
> deleted file mode 100644
> index 0d5923b..0000000
> --- a/board/cm41xx/config.mk
> +++ /dev/null
> @@ -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,
-- 
Albert.

^ permalink raw reply	[flat|nested] 54+ messages in thread

* [U-Boot] [PATCH 07/11] arm: ks8695/cm4008/cm41xx: Parameterize SDRAM
  2012-10-05 12:09                   ` [U-Boot] [PATCH 07/11] arm: ks8695/cm4008/cm41xx: Parameterize SDRAM Yann Vernier
@ 2012-10-18 19:11                     ` Albert ARIBAUD
  0 siblings, 0 replies; 54+ messages in thread
From: Albert ARIBAUD @ 2012-10-18 19:11 UTC (permalink / raw)
  To: u-boot

Hi Yann,

On Fri,  5 Oct 2012 14:09:54 +0200, Yann Vernier
<yann.vernier@orsoc.se> wrote:

> Allows configuration macros to set SDRAM parameters.
> ---
>  arch/arm/cpu/arm920t/ks8695/lowlevel_init.S |   20 +++++++++++---------
>  1 file changed, 11 insertions(+), 9 deletions(-)
> 
> diff --git a/arch/arm/cpu/arm920t/ks8695/lowlevel_init.S 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

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.

>  	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



Amicalement,
-- 
Albert.

^ permalink raw reply	[flat|nested] 54+ messages in thread

* [U-Boot] [PATCH 09/11] arm: ks8695/cm4xxx: don't reconfigure switch
  2012-10-05 12:09                   ` [U-Boot] [PATCH 09/11] arm: ks8695/cm4xxx: don't reconfigure switch Yann Vernier
@ 2012-10-18 19:13                     ` Albert ARIBAUD
  0 siblings, 0 replies; 54+ messages in thread
From: Albert ARIBAUD @ 2012-10-18 19:13 UTC (permalink / raw)
  To: u-boot

Hi Yann,

On Fri,  5 Oct 2012 14:09:56 +0200, Yann Vernier
<yann.vernier@orsoc.se> wrote:

> 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(-)
> 
> diff --git a/arch/arm/cpu/arm920t/ks8695/lowlevel_init.S 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]
>  

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

Amicalement,
-- 
Albert.

^ permalink raw reply	[flat|nested] 54+ messages in thread

* [U-Boot] [PATCH 11/11] arm: cm4008, cm41xx: read MAC address from flash
  2012-10-05 12:09                   ` [U-Boot] [PATCH 11/11] arm: cm4008, cm41xx: read MAC address from flash Yann Vernier
@ 2012-10-18 19:14                     ` Albert ARIBAUD
  0 siblings, 0 replies; 54+ messages in thread
From: Albert ARIBAUD @ 2012-10-18 19:14 UTC (permalink / raw)
  To: u-boot

Hi Yann,

On Fri,  5 Oct 2012 14:09:58 +0200, Yann Vernier
<yann.vernier@orsoc.se> wrote:

> 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(+)
> 
> diff --git a/board/cm4008/cm4008.c b/board/cm4008/cm4008.c
> index 6c0da9a..e14f8f4 100644
> --- a/board/cm4008/cm4008.c
> +++ b/board/cm4008/cm4008.c
> @@ -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)
>  {
> diff --git a/board/cm41xx/cm41xx.c b/board/cm41xx/cm41xx.c
> index 6aef617..771701d 100644
> --- a/board/cm41xx/cm41xx.c
> +++ b/board/cm41xx/cm41xx.c
> @@ -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.

> +
> +	/* 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)
>  {



Amicalement,
-- 
Albert.

^ permalink raw reply	[flat|nested] 54+ messages in thread

* [U-Boot] [PATCH 03/11] arm: ks8695eth: Use MAC address from environment
  2012-10-05 12:09                   ` [U-Boot] [PATCH 03/11] arm: ks8695eth: Use MAC address from environment Yann Vernier
  2012-10-18 19:00                     ` Albert ARIBAUD
@ 2012-10-18 20:55                     ` Joe Hershberger
  2012-10-19  8:02                       ` Yann Vernier
  1 sibling, 1 reply; 54+ messages in thread
From: Joe Hershberger @ 2012-10-18 20:55 UTC (permalink / raw)
  To: u-boot

Hi Yann,

On Fri, Oct 5, 2012 at 7:09 AM, Yann Vernier <yann.vernier@orsoc.se> wrote:
> 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(-)
>
> diff --git a/drivers/net/ks8695eth.c b/drivers/net/ks8695eth.c
> index b4904b6..2dda7ab 100644
> --- a/drivers/net/ks8695eth.c
> +++ b/drivers/net/ks8695eth.c
> @@ -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);

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

>
>         /* 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);
> --
> 1.7.10.4

-Joe

^ permalink raw reply	[flat|nested] 54+ messages in thread

* [U-Boot] [PATCH 03/11] arm: ks8695eth: Use MAC address from environment
  2012-10-18 20:55                     ` Joe Hershberger
@ 2012-10-19  8:02                       ` Yann Vernier
  2012-10-26 21:37                         ` Albert ARIBAUD
  0 siblings, 1 reply; 54+ messages in thread
From: Yann Vernier @ 2012-10-19  8:02 UTC (permalink / raw)
  To: u-boot

On Thu, 18 Oct 2012 15:55:31 -0500
Joe Hershberger <joe.hershberger@gmail.com> wrote:

> Hi Yann,
> 
> On Fri, Oct 5, 2012 at 7:09 AM, Yann Vernier <yann.vernier@orsoc.se>
> wrote:
> > 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(-)
> >
> > diff --git a/drivers/net/ks8695eth.c b/drivers/net/ks8695eth.c
> > index b4904b6..2dda7ab 100644
> > --- a/drivers/net/ks8695eth.c
> > +++ b/drivers/net/ks8695eth.c
> > @@ -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);
> 
> 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. 

> >         /* 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);
> > --
> > 1.7.10.4
> 
> -Joe

^ permalink raw reply	[flat|nested] 54+ messages in thread

* [U-Boot] [PATCH 06/11] arm: cm4008, cm41xx: Fix ROM relocation
  2012-10-18 19:09                     ` Albert ARIBAUD
@ 2012-10-19  8:08                       ` Yann Vernier
  0 siblings, 0 replies; 54+ messages in thread
From: Yann Vernier @ 2012-10-19  8:08 UTC (permalink / raw)
  To: u-boot

On Thu, 18 Oct 2012 21:09:07 +0200
Albert ARIBAUD <albert.u.boot@aribaud.net> wrote:

> Hi Yann,
> 
> On Fri,  5 Oct 2012 14:09:53 +0200, Yann Vernier
> <yann.vernier@orsoc.se> wrote:
> 
> > 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(-)
> > 
> > diff --git a/arch/arm/cpu/arm920t/ks8695/lowlevel_init.S
> > 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 */
> > diff --git a/board/cm4008/config.mk b/board/cm4008/config.mk
> > deleted file mode 100644
> > index 0d5923b..0000000
> > --- a/board/cm4008/config.mk
> > +++ /dev/null
> > @@ -1 +0,0 @@
> > -CONFIG_SYS_TEXT_BASE = 0x00f00000
> > diff --git a/board/cm41xx/config.mk b/board/cm41xx/config.mk
> > deleted file mode 100644
> > index 0d5923b..0000000
> > --- a/board/cm41xx/config.mk
> > +++ /dev/null
> > @@ -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,

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). 

^ permalink raw reply	[flat|nested] 54+ messages in thread

* [U-Boot] [PATCH 01/11] arm: ks8695: use defined constants for UART
  2012-10-05 12:09                   ` [U-Boot] [PATCH 01/11] arm: ks8695: use defined constants for UART Yann Vernier
@ 2012-10-26 21:34                     ` Albert ARIBAUD
  0 siblings, 0 replies; 54+ messages in thread
From: Albert ARIBAUD @ 2012-10-26 21:34 UTC (permalink / raw)
  To: u-boot

Hi Yann,

On Fri,  5 Oct 2012 14:09:48 +0200, Yann Vernier
<yann.vernier@orsoc.se> wrote:

> 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(-)
> 
> diff --git a/arch/arm/cpu/arm920t/ks8695/lowlevel_init.S 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

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

Amicalement,
-- 
Albert.

^ permalink raw reply	[flat|nested] 54+ messages in thread

* [U-Boot] [PATCH 03/11] arm: ks8695eth: Use MAC address from environment
  2012-10-19  8:02                       ` Yann Vernier
@ 2012-10-26 21:37                         ` Albert ARIBAUD
  2012-11-19 11:42                           ` Yann Vernier
  0 siblings, 1 reply; 54+ messages in thread
From: Albert ARIBAUD @ 2012-10-26 21:37 UTC (permalink / raw)
  To: u-boot

Hi Yann,

On Fri, 19 Oct 2012 10:02:09 +0200, Yann Vernier
<yann.vernier@orsoc.se> wrote:

> On Thu, 18 Oct 2012 15:55:31 -0500
> Joe Hershberger <joe.hershberger@gmail.com> wrote:
> 
> > Hi Yann,
> > 
> > On Fri, Oct 5, 2012 at 7:09 AM, Yann Vernier <yann.vernier@orsoc.se>
> > wrote:
> > > 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(-)
> > >
> > > diff --git a/drivers/net/ks8695eth.c b/drivers/net/ks8695eth.c
> > > index b4904b6..2dda7ab 100644
> > > --- a/drivers/net/ks8695eth.c
> > > +++ b/drivers/net/ks8695eth.c
> > > @@ -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);
> > 
> > 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. 
> 
> > >         /* 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);
> > > --
> > > 1.7.10.4
> > 
> > -Joe

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

Amicalement,
-- 
Albert.

^ permalink raw reply	[flat|nested] 54+ messages in thread

* [U-Boot] [PATCH 00/11] ks8695 (cm4008, cm41xx) bugfixes, constant removals, configuration generalized (repost)
  2012-10-05 12:09                 ` [U-Boot] [PATCH 00/11] ks8695 (cm4008, cm41xx) bugfixes, constant removals, configuration generalized (repost) Yann Vernier
                                     ` (10 preceding siblings ...)
  2012-10-05 12:09                   ` [U-Boot] [PATCH 11/11] arm: cm4008, cm41xx: read MAC address from flash Yann Vernier
@ 2012-11-10  8:03                   ` Albert ARIBAUD
  2012-11-13 12:46                     ` Yann Vernier
  11 siblings, 1 reply; 54+ messages in thread
From: Albert ARIBAUD @ 2012-11-10  8:03 UTC (permalink / raw)
  To: u-boot

Hi Yann,

On Fri,  5 Oct 2012 14:09:47 +0200, Yann Vernier
<yann.vernier@orsoc.se> wrote:

> On Thu, 4 Oct 2012 11:15:06 +0200
> Albert ARIBAUD <albert.u.boot@aribaud.net> wrote:
> > 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.

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

Amicalement,
-- 
Albert.

^ permalink raw reply	[flat|nested] 54+ messages in thread

* [U-Boot] [PATCH 00/11] ks8695 (cm4008, cm41xx) bugfixes, constant removals, configuration generalized (repost)
  2012-11-10  8:03                   ` [U-Boot] [PATCH 00/11] ks8695 (cm4008, cm41xx) bugfixes, constant removals, configuration generalized (repost) Albert ARIBAUD
@ 2012-11-13 12:46                     ` Yann Vernier
  0 siblings, 0 replies; 54+ messages in thread
From: Yann Vernier @ 2012-11-13 12:46 UTC (permalink / raw)
  To: u-boot

On Sat, 10 Nov 2012 09:03:32 +0100
Albert ARIBAUD <albert.u.boot@aribaud.net> wrote:

> Hi Yann,
> 
> On Fri,  5 Oct 2012 14:09:47 +0200, Yann Vernier
> <yann.vernier@orsoc.se> wrote:
> 
> > On Thu, 4 Oct 2012 11:15:06 +0200
> > Albert ARIBAUD <albert.u.boot@aribaud.net> wrote:
> > > 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.
> 
> 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. 

^ permalink raw reply	[flat|nested] 54+ messages in thread

* [U-Boot] [PATCH 03/11] arm: ks8695eth: Use MAC address from environment
  2012-10-26 21:37                         ` Albert ARIBAUD
@ 2012-11-19 11:42                           ` Yann Vernier
  2012-12-01 19:23                             ` Joe Hershberger
  0 siblings, 1 reply; 54+ messages in thread
From: Yann Vernier @ 2012-11-19 11:42 UTC (permalink / raw)
  To: u-boot

On Fri, 26 Oct 2012 23:37:28 +0200
Albert ARIBAUD <albert.u.boot@aribaud.net> wrote:

> Hi Yann,
> 
> On Fri, 19 Oct 2012 10:02:09 +0200, Yann Vernier
> <yann.vernier@orsoc.se> wrote:
> 
> > On Thu, 18 Oct 2012 15:55:31 -0500
> > Joe Hershberger <joe.hershberger@gmail.com> wrote:
> > 
> > > Hi Yann,
> > > 
> > > On Fri, Oct 5, 2012 at 7:09 AM, Yann Vernier
> > > <yann.vernier@orsoc.se> wrote:
> > > > 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(-)
> > > >
> > > > diff --git a/drivers/net/ks8695eth.c b/drivers/net/ks8695eth.c
> > > > index b4904b6..2dda7ab 100644
> > > > --- a/drivers/net/ks8695eth.c
> > > > +++ b/drivers/net/ks8695eth.c
> > > > @@ -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);
> > > 
> > > 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. 
> > 
> > > >         /* 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);
> > > > --
> > > > 1.7.10.4
> > > 
> > > -Joe
> 
> 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. 

^ permalink raw reply	[flat|nested] 54+ messages in thread

* [U-Boot] [PATCH] arm: ks8695: more macros for register values
  2012-10-18 18:57                     ` Albert ARIBAUD
@ 2012-11-19 11:55                       ` Yann Vernier
  2012-11-19 12:29                         ` Yann Vernier
  0 siblings, 1 reply; 54+ messages in thread
From: Yann Vernier @ 2012-11-19 11:55 UTC (permalink / raw)
  To: u-boot

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

diff --git a/arch/arm/include/asm/arch-ks8695/platform.h b/arch/arm/include/asm/arch-ks8695/platform.h
index de20015..a78d312 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_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
diff --git a/arch/arm/include/asm/arch-ks8695/regvalues.h b/arch/arm/include/asm/arch-ks8695/regvalues.h
new file mode 100644
index 0000000..a4d48bd
--- /dev/null
+++ b/arch/arm/include/asm/arch-ks8695/regvalues.h
@@ -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_KS8695_REGVALUES_H__
+#define __ASM_ARM_ARCH_KS8695_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
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 54+ messages in thread

* [U-Boot] [PATCH] arm: ks8695: more macros for register values
  2012-11-19 11:55                       ` [U-Boot] [PATCH] " Yann Vernier
@ 2012-11-19 12:29                         ` Yann Vernier
  2012-11-20  0:05                           ` Marek Vasut
  0 siblings, 1 reply; 54+ messages in thread
From: Yann Vernier @ 2012-11-19 12:29 UTC (permalink / raw)
  To: u-boot

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. 

^ permalink raw reply	[flat|nested] 54+ messages in thread

* [U-Boot] [PATCH] arm: ks8695: more macros for register values
  2012-11-19 12:29                         ` Yann Vernier
@ 2012-11-20  0:05                           ` Marek Vasut
  0 siblings, 0 replies; 54+ messages in thread
From: Marek Vasut @ 2012-11-20  0:05 UTC (permalink / raw)
  To: u-boot

Dear Yann Vernier,

> 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

^ permalink raw reply	[flat|nested] 54+ messages in thread

* [U-Boot] [PATCH 03/11] arm: ks8695eth: Use MAC address from environment
  2012-11-19 11:42                           ` Yann Vernier
@ 2012-12-01 19:23                             ` Joe Hershberger
  0 siblings, 0 replies; 54+ messages in thread
From: Joe Hershberger @ 2012-12-01 19:23 UTC (permalink / raw)
  To: u-boot

Hi Yann,

On Mon, Nov 19, 2012 at 5:42 AM, Yann Vernier <yann.vernier@orsoc.se> wrote:
> On Fri, 26 Oct 2012 23:37:28 +0200
> Albert ARIBAUD <albert.u.boot@aribaud.net> wrote:
>
>> Hi Yann,
>>
>> On Fri, 19 Oct 2012 10:02:09 +0200, Yann Vernier
>> <yann.vernier@orsoc.se> wrote:
>>
>> > On Thu, 18 Oct 2012 15:55:31 -0500
>> > Joe Hershberger <joe.hershberger@gmail.com> wrote:
>> >
>> > > Hi Yann,
>> > >
>> > > On Fri, Oct 5, 2012 at 7:09 AM, Yann Vernier
>> > > <yann.vernier@orsoc.se> wrote:
>> > > > 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(-)
>> > > >
>> > > > diff --git a/drivers/net/ks8695eth.c b/drivers/net/ks8695eth.c
>> > > > index b4904b6..2dda7ab 100644
>> > > > --- a/drivers/net/ks8695eth.c
>> > > > +++ b/drivers/net/ks8695eth.c
>> > > > @@ -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);
>> > >
>> > > 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.
>> >
>> > > >         /* 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);
>> > > > --
>> > > > 1.7.10.4
>> > >
>> > > -Joe
>>
>> 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.

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

^ permalink raw reply	[flat|nested] 54+ messages in thread

end of thread, other threads:[~2012-12-01 19:23 UTC | newest]

Thread overview: 54+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-07-05  8:05 [U-Boot] [PATCH 3/3] cm4008: use common cfi_flash support Yann Vernier
2012-07-05  9:48 ` Andreas Bießmann
2012-07-05 13:11   ` [U-Boot] [PATCH v2] arm: cm4008, cm41xx: " Yann Vernier
2012-07-05 15:04     ` Andreas Bießmann
2012-07-06  8:27       ` [U-Boot] [PATCH v3] " Yann Vernier
2012-07-06  8:47         ` Andreas Bießmann
2012-07-06 11:33           ` Albert ARIBAUD
2012-08-09 13:33             ` [U-Boot] [PATCH 11/11] arm: cm4008, cm41xx: read MAC address from flash Yann Vernier
2012-08-09 13:33             ` [U-Boot] [PATCH 00/11] ks8695 (cm4008, cm41xx) bugfixes, constant removals, configuration generalized Yann Vernier
2012-10-04  9:15               ` Albert ARIBAUD
2012-10-05 12:09                 ` [U-Boot] [PATCH 00/11] ks8695 (cm4008, cm41xx) bugfixes, constant removals, configuration generalized (repost) Yann Vernier
2012-10-05 12:09                   ` [U-Boot] [PATCH 01/11] arm: ks8695: use defined constants for UART Yann Vernier
2012-10-26 21:34                     ` Albert ARIBAUD
2012-10-05 12:09                   ` [U-Boot] [PATCH 02/11] arm: ks8695: more macros for register values Yann Vernier
2012-10-18 18:57                     ` Albert ARIBAUD
2012-11-19 11:55                       ` [U-Boot] [PATCH] " Yann Vernier
2012-11-19 12:29                         ` Yann Vernier
2012-11-20  0:05                           ` Marek Vasut
2012-10-05 12:09                   ` [U-Boot] [PATCH 03/11] arm: ks8695eth: Use MAC address from environment Yann Vernier
2012-10-18 19:00                     ` Albert ARIBAUD
2012-10-18 20:55                     ` Joe Hershberger
2012-10-19  8:02                       ` Yann Vernier
2012-10-26 21:37                         ` Albert ARIBAUD
2012-11-19 11:42                           ` Yann Vernier
2012-12-01 19:23                             ` Joe Hershberger
2012-10-05 12:09                   ` [U-Boot] [PATCH 04/11] arm: cm4008, cm41xx: use common cfi_flash support Yann Vernier
2012-10-05 12:09                   ` [U-Boot] [PATCH 05/11] arm: cm4008, cm41xx: set gd->ram_size in dram_init Yann Vernier
2012-10-05 12:09                   ` [U-Boot] [PATCH 06/11] arm: cm4008, cm41xx: Fix ROM relocation Yann Vernier
2012-10-18 19:09                     ` Albert ARIBAUD
2012-10-19  8:08                       ` Yann Vernier
2012-10-05 12:09                   ` [U-Boot] [PATCH 07/11] arm: ks8695/cm4008/cm41xx: Parameterize SDRAM Yann Vernier
2012-10-18 19:11                     ` Albert ARIBAUD
2012-10-05 12:09                   ` [U-Boot] [PATCH 08/11] arm: cm4008, cm41xx: don't define to 1 Yann Vernier
2012-10-05 12:09                   ` [U-Boot] [PATCH 09/11] arm: ks8695/cm4xxx: don't reconfigure switch Yann Vernier
2012-10-18 19:13                     ` Albert ARIBAUD
2012-10-05 12:09                   ` [U-Boot] [PATCH 10/11] arm: ks8695: document bus speed Yann Vernier
2012-10-05 12:09                   ` [U-Boot] [PATCH 11/11] arm: cm4008, cm41xx: read MAC address from flash Yann Vernier
2012-10-18 19:14                     ` Albert ARIBAUD
2012-11-10  8:03                   ` [U-Boot] [PATCH 00/11] ks8695 (cm4008, cm41xx) bugfixes, constant removals, configuration generalized (repost) Albert ARIBAUD
2012-11-13 12:46                     ` Yann Vernier
2012-08-09 13:33             ` [U-Boot] [PATCH 10/11] arm: ks8695: document bus speed Yann Vernier
2012-08-09 13:33             ` [U-Boot] [PATCH 07/11] arm: ks8695/cm4008/cm41xx: Parameterize SDRAM Yann Vernier
2012-08-09 13:33             ` [U-Boot] [PATCH 08/11] arm: cm4008, cm41xx: don't define to 1 Yann Vernier
2012-08-09 13:33             ` [U-Boot] [PATCH 09/11] arm: ks8695/cm4xxx: don't reconfigure switch Yann Vernier
2012-08-09 13:33             ` [U-Boot] [PATCH 05/11] arm: cm4008, cm41xx: set gd->ram_size in dram_init Yann Vernier
2012-08-09 13:33             ` [U-Boot] [PATCH 03/11] arm: ks8695eth: Use MAC address from environment Yann Vernier
2012-08-09 13:33             ` [U-Boot] [PATCH 04/11] arm: cm4008, cm41xx: use common cfi_flash support Yann Vernier
2012-08-09 13:33             ` [U-Boot] [PATCH 06/11] arm: cm4008, cm41xx: Fix ROM relocation Yann Vernier
2012-08-09 13:33             ` [U-Boot] [PATCH 02/11] arm: ks8695: more macros for register values Yann Vernier
2012-08-09 13:33             ` [U-Boot] [PATCH 01/11] arm: ks8695: use defined constants for UART Yann Vernier
2012-07-05 13:22   ` [U-Boot] [PATCH v2] arm: cm4008, cm41xx: Fix ROM relocation Yann Vernier
2012-07-05 13:41     ` Yann Vernier
2012-07-05 15:19     ` Andreas Bießmann
2012-07-12 19:37       ` Albert ARIBAUD

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.