Skip to contentSkip to conversation

microblaze: Add support for device tree driven board configuration

PATCH New Michal Simek 2 participants 18 messages Aug 6, 2012 – Aug 10, 2012

Subsystems (2)
lore
Share & tools
lore

Michal Simek

author maintainer
#0 lore raw

PATCH v2 1/7 microblaze: Add support for device tree driven board configuration

This is minimum code required to be able to use device-tree for u-boot initialization.
Currently only for device driver initialization.

Linker script change ensures DTB to be aligned for both options CONFIG_OF_EMBED and CONFIG_OF_SEPARATE.

---
v2: Show message about DTB address in bootlog

---
 arch/microblaze/config.mk                 |    2 ++
 arch/microblaze/cpu/u-boot.lds            |    1 +
 arch/microblaze/include/asm/global_data.h |    1 +
 arch/microblaze/lib/board.c               |   24 ++++++++++++++++++++++++
 4 files changed, 28 insertions(+), 0 deletions(-)
arch/microblaze/config.mk +2 -0
index aca79e2..b4935f0 100644
@@ -31,3 +31,5 @@ CONFIG_STANDALONE_LOAD_ADDR ?= 0x80F00000
 PLATFORM_CPPFLAGS += -ffixed-r31 -D__microblaze__
 
 LDSCRIPT ?= $(SRCTREE)/$(CPUDIR)/u-boot.lds
+
+CONFIG_ARCH_DEVICE_TREE := microblaze
arch/microblaze/cpu/u-boot.lds +1 -0
index ee41145..d033a28 100644
@@ -45,6 +45,7 @@ SECTIONS
 	.data ALIGN(0x4):
 	{
 		__data_start = .;
+		dts/libdts.o (.data)
 		*(.data)
 		__data_end = .;
 	}
arch/microblaze/include/asm/global_data.h +1 -0
index 6e8537c..e802e4e 100644
@@ -43,6 +43,7 @@ typedef	struct	global_data {
 	unsigned long	precon_buf_idx;	/* Pre-Console buffer index */
 #endif
 	unsigned long	env_addr;	/* Address  of Environment struct */
+	const void	*fdt_blob;	/* Our device tree, NULL if none */
 	unsigned long	env_valid;	/* Checksum of Environment valid? */
 	unsigned long	fb_base;	/* base address of frame buffer */
 	void		**jt;		/* jump table */
arch/microblaze/lib/board.c +24 -0
index b80250a..942e18c 100644
@@ -34,6 +34,7 @@
 #include <net.h>
 #include <asm/processor.h>
 #include <asm/microblaze_intc.h>
+#include <fdtdec.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -63,6 +64,9 @@ typedef int (init_fnc_t) (void);
 
 init_fnc_t *init_sequence[] = {
 	env_init,
+#ifdef CONFIG_OF_CONTROL
+	fdtdec_check_fdt,
+#endif
 	serial_init,
 	console_init_f,
 #ifdef CONFIG_SYS_GPIO_0
@@ -103,6 +107,17 @@ void board_init (void)
 
 	monitor_flash_len = __end - __text_start;
 
+#ifdef CONFIG_OF_EMBED
+	/* Get a pointer to the FDT */
+	gd->fdt_blob = _binary_dt_dtb_start;
+#elif defined CONFIG_OF_SEPARATE
+	/* FDT is at end of image */
+	gd->fdt_blob = (void *)__end;
+#endif
+	/* Allow the early environment to override the fdt address */
+	gd->fdt_blob = (void *)getenv_ulong("fdtcontroladdr", 16,
+						(uintptr_t)gd->fdt_blob);
+
 	/*
 	 * The Malloc area is immediately below the monitor copy in DRAM
 	 * aka CONFIG_SYS_MONITOR_BASE - Note there is no need for reloc_off
@@ -121,6 +136,15 @@ void board_init (void)
 		}
 	}
 
+#ifdef CONFIG_OF_CONTROL
+	/* For now, put this check after the console is ready */
+	if (fdtdec_prepare_fdt()) {
+		panic("** CONFIG_OF_CONTROL defined but no FDT - please see "
+			"doc/README.fdt-control");
+	} else
+		printf("DTB: 0x%x\n", (u32)gd->fdt_blob);
+#endif
+
 	puts ("SDRAM :\n");
 	printf ("\t\tIcache:%s\n", icache_status() ? "ON" : "OFF");
 	printf ("\t\tDcache:%s\n", dcache_status() ? "ON" : "OFF");
Signature · 1 line
1.7.0.4
author maintainer
#1 lore raw

PATCH v2 2/7 microblaze: board: Remove compilation warning

Variable is used when CONFIG_SYS_FLASH_CHECKSUM is used.

Warning log:
board.c: In function 'board_init':
board.c:101: warning: unused variable 's'

---
v2: Use __mabe_unused prefix

---
 arch/microblaze/lib/board.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
arch/microblaze/lib/board.c +2 -1
index 942e18c..b5f21d8 100644
@@ -32,6 +32,7 @@
 #include <stdio_dev.h>
 #include <serial.h>
 #include <net.h>
+#include <linux/compiler.h>
 #include <asm/processor.h>
 #include <asm/microblaze_intc.h>
 #include <fdtdec.h>
@@ -91,7 +92,7 @@ void board_init (void)
 	gd = (gd_t *) (CONFIG_SYS_SDRAM_BASE + CONFIG_SYS_GBL_DATA_OFFSET);
 	bd = (bd_t *) (CONFIG_SYS_SDRAM_BASE + CONFIG_SYS_GBL_DATA_OFFSET \
 						- GENERATED_BD_INFO_SIZE);
-	char *s;
+	__maybe_unused char *s;
 #if defined(CONFIG_CMD_FLASH)
 	ulong flash_size = 0;
 #endif
Signature · 1 line
1.7.0.4
#2 lore raw

PATCH v2 2/7 microblaze: board: Remove compilation warning

Am Montag, den 06.08.2012, 09:46 +0200 schrieb Michal Simek:

Quoted 8 lines

Variable is used when CONFIG_SYS_FLASH_CHECKSUM is used.

Warning log:
board.c: In function 'board_init':
board.c:101: warning: unused variable 's'

Quoted 27 lines

---
v2: Use __mabe_unused prefix

---
 arch/microblaze/lib/board.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
arch/microblaze/lib/board.c +2 -1
index 942e18c..b5f21d8 100644
@@ -32,6 +32,7 @@
 #include <stdio_dev.h>
 #include <serial.h>
 #include <net.h>
+#include <linux/compiler.h>
 #include <asm/processor.h>
 #include <asm/microblaze_intc.h>
 #include <fdtdec.h>
@@ -91,7 +92,7 @@ void board_init (void)
 	gd = (gd_t *) (CONFIG_SYS_SDRAM_BASE + CONFIG_SYS_GBL_DATA_OFFSET);
 	bd = (bd_t *) (CONFIG_SYS_SDRAM_BASE + CONFIG_SYS_GBL_DATA_OFFSET \
 						- GENERATED_BD_INFO_SIZE);
-	char *s;
+	__maybe_unused char *s;
 #if defined(CONFIG_CMD_FLASH)
 	ulong flash_size = 0;
 #endif
Signature · 8 lines
Viele Gr??e,
Stephan Linz
______________________________________________________________________________
MB-Ref: http://www.li-pro.de/xilinx_mb:mbref:start
OpenDCC: http://www.li-pro.net/opendcc.phtml
PC/M: http://www.li-pro.net/pcm.phtml
Sourceforge: http://sourceforge.net/users/slz
Gitorious: https://gitorious.org/~slz
author maintainer
#3 lore raw

PATCH v2 3/7 microblaze: intc: Registering interrupt should return value

In reply to Michal Simek

Return value to find out if un/registration was succesful.

---
v2: Add comment to header file to describe parameters and return codes

---
 arch/microblaze/cpu/interrupts.c              |   16 +++++++++-------
 arch/microblaze/include/asm/microblaze_intc.h |   11 ++++++++++-
 2 files changed, 19 insertions(+), 8 deletions(-)
arch/microblaze/cpu/interrupts.c +9 -7
index ee67082..08f6bad 100644
@@ -91,14 +91,13 @@ static void disable_one_interrupt(int irq)
 #endif
 }
 
-/* adding new handler for interrupt */
-void install_interrupt_handler (int irq, interrupt_handler_t * hdlr, void *arg)
+int install_interrupt_handler(int irq, interrupt_handler_t *hdlr, void *arg)
 {
 	struct irq_action *act;
 	/* irq out of range */
 	if ((irq < 0) || (irq > irq_no)) {
 		puts ("IRQ out of range\n");
-		return;
+		return -1;
 	}
 	act = &vecs[irq];
 	if (hdlr) {		/* enable */
@@ -106,11 +105,14 @@ void install_interrupt_handler (int irq, interrupt_handler_t * hdlr, void *arg)
 		act->arg = arg;
 		act->count = 0;
 		enable_one_interrupt (irq);
-	} else {		/* disable */
-		act->handler = (interrupt_handler_t *) def_hdlr;
-		act->arg = (void *)irq;
-		disable_one_interrupt (irq);
+		return 0;
 	}
+
+	/* Disable */
+	act->handler = (interrupt_handler_t *) def_hdlr;
+	act->arg = (void *)irq;
+	disable_one_interrupt(irq);
+	return 1;
 }
 
 /* initialization interrupt controller - hardware */
arch/microblaze/include/asm/microblaze_intc.h +10 -1
index 6142b9c..e9640f5 100644
@@ -39,7 +39,16 @@ struct irq_action {
 	int count; /* number of interrupt */
 };
 
-void install_interrupt_handler (int irq, interrupt_handler_t * hdlr,
+/**
+ * Register and unregister interrupt handler rutines
+ *
+ * @param irq	IRQ number
+ * @param hdlr	Interrupt handler rutine
+ * @param arg	Pointer to argument which is passed to int. handler rutine
+ * @return	0 if registration pass, 1 if unregistration pass,
+ *		or an error code < 0 otherwise
+ */
+int install_interrupt_handler(int irq, interrupt_handler_t *hdlr,
 				       void *arg);
 
 int interrupts_init(void);
Signature · 1 line
1.7.0.4
#4 lore raw

PATCH v2 3/7 microblaze: intc: Registering interrupt should return value

Am Montag, den 06.08.2012, 09:46 +0200 schrieb Michal Simek:

Quoted 61 lines

Return value to find out if un/registration was succesful.

---
v2: Add comment to header file to describe parameters and return codes

---
 arch/microblaze/cpu/interrupts.c              |   16 +++++++++-------
 arch/microblaze/include/asm/microblaze_intc.h |   11 ++++++++++-
 2 files changed, 19 insertions(+), 8 deletions(-)
arch/microblaze/cpu/interrupts.c +9 -7
index ee67082..08f6bad 100644
@@ -91,14 +91,13 @@ static void disable_one_interrupt(int irq)
 #endif
 }
 
-/* adding new handler for interrupt */
-void install_interrupt_handler (int irq, interrupt_handler_t * hdlr, void *arg)
+int install_interrupt_handler(int irq, interrupt_handler_t *hdlr, void *arg)
 {
 	struct irq_action *act;
 	/* irq out of range */
 	if ((irq < 0) || (irq > irq_no)) {
 		puts ("IRQ out of range\n");
-		return;
+		return -1;
 	}
 	act = &vecs[irq];
 	if (hdlr) {		/* enable */
@@ -106,11 +105,14 @@ void install_interrupt_handler (int irq, interrupt_handler_t * hdlr, void *arg)
 		act->arg = arg;
 		act->count = 0;
 		enable_one_interrupt (irq);
-	} else {		/* disable */
-		act->handler = (interrupt_handler_t *) def_hdlr;
-		act->arg = (void *)irq;
-		disable_one_interrupt (irq);
+		return 0;
 	}
+
+	/* Disable */
+	act->handler = (interrupt_handler_t *) def_hdlr;
+	act->arg = (void *)irq;
+	disable_one_interrupt(irq);
+	return 1;
 }
 
 /* initialization interrupt controller - hardware */
arch/microblaze/include/asm/microblaze_intc.h +1 -1
index 6142b9c..e9640f5 100644
@@ -39,7 +39,16 @@ struct irq_action {
 	int count; /* number of interrupt */
 };
 
-void install_interrupt_handler (int irq, interrupt_handler_t * hdlr,
+/**

arch/microblaze/include/asm/microblaze_intc.h struct irq_action { · line 52

Quoted 10 lines
arch/microblaze/include/asm/microblaze_intc.h +9 -0
+ * Register and unregister interrupt handler rutines
+ *
+ * @param irq	IRQ number
+ * @param hdlr	Interrupt handler rutine
+ * @param arg	Pointer to argument which is passed to int. handler rutine
+ * @return	0 if registration pass, 1 if unregistration pass,
+ *		or an error code < 0 otherwise
+ */
+int install_interrupt_handler(int irq, interrupt_handler_t *hdlr,
 				       void *arg);

Hi Michal,

why not two different functions here, one for registration, another one for unregistration? To mee it is puzzling to use a 'install' function for unregistration ...

... whatever, you should evaluate the return code in fsl_init2() too.

Quoted 2 lines
arch/microblaze/include/asm/microblaze_intc.h +0 -0
 int interrupts_init(void);
author maintainer
#5 lore raw

PATCH v2 3/7 microblaze: intc: Registering interrupt should return value

Quoted 75 lines · Stephan Linz

Am Montag, den 06.08.2012, 09:46 +0200 schrieb Michal Simek:

Quoted 61 lines

Return value to find out if un/registration was succesful.

---
v2: Add comment to header file to describe parameters and return codes

---
  arch/microblaze/cpu/interrupts.c              |   16 +++++++++-------
  arch/microblaze/include/asm/microblaze_intc.h |   11 ++++++++++-
  2 files changed, 19 insertions(+), 8 deletions(-)
arch/microblaze/cpu/interrupts.c +9 -7
index ee67082..08f6bad 100644
@@ -91,14 +91,13 @@ static void disable_one_interrupt(int irq)
  #endif
  }
 
-/* adding new handler for interrupt */
-void install_interrupt_handler (int irq, interrupt_handler_t * hdlr, void *arg)
+int install_interrupt_handler(int irq, interrupt_handler_t *hdlr, void *arg)
  {
  	struct irq_action *act;
  	/* irq out of range */
  	if ((irq < 0) || (irq > irq_no)) {
  		puts ("IRQ out of range\n");
-		return;
+		return -1;
  	}
  	act = &vecs[irq];
  	if (hdlr) {		/* enable */
@@ -106,11 +105,14 @@ void install_interrupt_handler (int irq, interrupt_handler_t * hdlr, void *arg)
  		act->arg = arg;
  		act->count = 0;
  		enable_one_interrupt (irq);
-	} else {		/* disable */
-		act->handler = (interrupt_handler_t *) def_hdlr;
-		act->arg = (void *)irq;
-		disable_one_interrupt (irq);
+		return 0;
  	}
+
+	/* Disable */
+	act->handler = (interrupt_handler_t *) def_hdlr;
+	act->arg = (void *)irq;
+	disable_one_interrupt(irq);
+	return 1;
  }
 
  /* initialization interrupt controller - hardware */
arch/microblaze/include/asm/microblaze_intc.h +1 -1
index 6142b9c..e9640f5 100644
@@ -39,7 +39,16 @@ struct irq_action {
  	int count; /* number of interrupt */
  };
 
-void install_interrupt_handler (int irq, interrupt_handler_t * hdlr,
+/**

arch/microblaze/include/asm/microblaze_intc.h struct irq_action { · line 52

Quoted 10 lines
arch/microblaze/include/asm/microblaze_intc.h +9 -0
+ * Register and unregister interrupt handler rutines
+ *
+ * @param irq	IRQ number
+ * @param hdlr	Interrupt handler rutine
+ * @param arg	Pointer to argument which is passed to int. handler rutine
+ * @return	0 if registration pass, 1 if unregistration pass,
+ *		or an error code < 0 otherwise
+ */
+int install_interrupt_handler(int irq, interrupt_handler_t *hdlr,
  				       void *arg);

Hi Michal,

Quoted 3 lines

why not two different functions here, one for registration, another one for unregistration? To mee it is puzzling to use a 'install' function for unregistration ...

partially agree with that. Maybe we could introduce one macro for that.

#define uninstall_interrupt_handler(irq) install_interrupt_handler(irq, NULL, NULL)

Quoted 1 line

... whatever, you should evaluate the return code in fsl_init2() too.

Not necessary to do it in this patch.

Thanks,
Michal

Signature · 4 lines
Michal Simek, Ing. (M.Eng)
w: www.monstr.eu p: +42-0-721842854
Maintainer of Linux kernel 2.6 Microblaze Linux - http://www.monstr.eu/fdt/
Microblaze U-BOOT custodian
#6 lore raw

PATCH v2 3/7 microblaze: intc: Registering interrupt should return value

Am Mittwoch, den 08.08.2012, 10:27 +0200 schrieb Michal Simek:

Quoted 76 lines · Stephan Linz
Quoted 75 lines

Am Montag, den 06.08.2012, 09:46 +0200 schrieb Michal Simek:

Quoted 61 lines

Return value to find out if un/registration was succesful.

---
v2: Add comment to header file to describe parameters and return codes

---
  arch/microblaze/cpu/interrupts.c              |   16 +++++++++-------
  arch/microblaze/include/asm/microblaze_intc.h |   11 ++++++++++-
  2 files changed, 19 insertions(+), 8 deletions(-)
arch/microblaze/cpu/interrupts.c +9 -7
index ee67082..08f6bad 100644
@@ -91,14 +91,13 @@ static void disable_one_interrupt(int irq)
  #endif
  }
 
-/* adding new handler for interrupt */
-void install_interrupt_handler (int irq, interrupt_handler_t * hdlr, void *arg)
+int install_interrupt_handler(int irq, interrupt_handler_t *hdlr, void *arg)
  {
  	struct irq_action *act;
  	/* irq out of range */
  	if ((irq < 0) || (irq > irq_no)) {
  		puts ("IRQ out of range\n");
-		return;
+		return -1;
  	}
  	act = &vecs[irq];
  	if (hdlr) {		/* enable */
@@ -106,11 +105,14 @@ void install_interrupt_handler (int irq, interrupt_handler_t * hdlr, void *arg)
  		act->arg = arg;
  		act->count = 0;
  		enable_one_interrupt (irq);
-	} else {		/* disable */
-		act->handler = (interrupt_handler_t *) def_hdlr;
-		act->arg = (void *)irq;
-		disable_one_interrupt (irq);
+		return 0;
  	}
+
+	/* Disable */
+	act->handler = (interrupt_handler_t *) def_hdlr;
+	act->arg = (void *)irq;
+	disable_one_interrupt(irq);
+	return 1;
  }
 
  /* initialization interrupt controller - hardware */
arch/microblaze/include/asm/microblaze_intc.h +1 -1
index 6142b9c..e9640f5 100644
@@ -39,7 +39,16 @@ struct irq_action {
  	int count; /* number of interrupt */
  };
 
-void install_interrupt_handler (int irq, interrupt_handler_t * hdlr,
+/**

arch/microblaze/include/asm/microblaze_intc.h struct irq_action { · line 52

Quoted 10 lines
arch/microblaze/include/asm/microblaze_intc.h +9 -0
+ * Register and unregister interrupt handler rutines
+ *
+ * @param irq	IRQ number
+ * @param hdlr	Interrupt handler rutine
+ * @param arg	Pointer to argument which is passed to int. handler rutine
+ * @return	0 if registration pass, 1 if unregistration pass,
+ *		or an error code < 0 otherwise
+ */
+int install_interrupt_handler(int irq, interrupt_handler_t *hdlr,
  				       void *arg);

Hi Michal,

Quoted 7 lines
Quoted 3 lines

why not two different functions here, one for registration, another one for unregistration? To mee it is puzzling to use a 'install' function for unregistration ...

partially agree with that. Maybe we could introduce one macro for that.

#define uninstall_interrupt_handler(irq) install_interrupt_handler(irq, NULL, NULL)

yes, that is ok ...

Quoted 5 lines
Quoted 3 lines

... whatever, you should evaluate the return code in fsl_init2() too.

Not necessary to do it in this patch.

yes, it's another part ...

br,
Stephan

author maintainer
#7 lore raw

PATCH v2 4/7 microblaze: intc: Coding style cleanup

In reply to Michal Simek

Just coding style cleanup.
Remove unneeded externs.

--
v2: Rebase - depends on previous intc patch

---
 arch/microblaze/cpu/interrupts.c |   26 +++++++++++++-------------
 1 files changed, 13 insertions(+), 13 deletions(-)
arch/microblaze/cpu/interrupts.c +13 -13
index 08f6bad..7f2ee64 100644
@@ -32,15 +32,12 @@
 
 #undef DEBUG_INT
 
-extern void microblaze_disable_interrupts (void);
-extern void microblaze_enable_interrupts (void);
-
-void enable_interrupts (void)
+void enable_interrupts(void)
 {
 	MSRSET(0x2);
 }
 
-int disable_interrupts (void)
+int disable_interrupts(void)
 {
 	unsigned int msr;
 
@@ -58,20 +55,21 @@ microblaze_intc_t *intc;
 /* default handler */
 static void def_hdlr(void)
 {
-	puts ("def_hdlr\n");
+	puts("def_hdlr\n");
 }
 
 static void enable_one_interrupt(int irq)
 {
 	int mask;
 	int offset = 1;
+
 	offset <<= irq;
 	mask = intc->ier;
 	intc->ier = (mask | offset);
 #ifdef DEBUG_INT
-	printf ("Enable one interrupt irq %x - mask %x,ier %x\n", offset, mask,
+	printf("Enable one interrupt irq %x - mask %x,ier %x\n", offset, mask,
 		intc->ier);
-	printf ("INTC isr %x, ier %x, iar %x, mer %x\n", intc->isr, intc->ier,
+	printf("INTC isr %x, ier %x, iar %x, mer %x\n", intc->isr, intc->ier,
 		intc->iar, intc->mer);
 #endif
 }
@@ -80,13 +78,14 @@ static void disable_one_interrupt(int irq)
 {
 	int mask;
 	int offset = 1;
+
 	offset <<= irq;
 	mask = intc->ier;
 	intc->ier = (mask & ~offset);
 #ifdef DEBUG_INT
-	printf ("Disable one interrupt irq %x - mask %x,ier %x\n", irq, mask,
+	printf("Disable one interrupt irq %x - mask %x,ier %x\n", irq, mask,
 		intc->ier);
-	printf ("INTC isr %x, ier %x, iar %x, mer %x\n", intc->isr, intc->ier,
+	printf("INTC isr %x, ier %x, iar %x, mer %x\n", intc->isr, intc->ier,
 		intc->iar, intc->mer);
 #endif
 }
@@ -94,9 +93,10 @@ static void disable_one_interrupt(int irq)
 int install_interrupt_handler(int irq, interrupt_handler_t *hdlr, void *arg)
 {
 	struct irq_action *act;
+
 	/* irq out of range */
 	if ((irq < 0) || (irq > irq_no)) {
-		puts ("IRQ out of range\n");
+		puts("IRQ out of range\n");
 		return -1;
 	}
 	act = &vecs[irq];
@@ -124,7 +124,7 @@ static void intc_init(void)
 	/* XIntc_Start - hw_interrupt enable and all interrupt enable */
 	intc->mer = 0x3;
 #ifdef DEBUG_INT
-	printf ("INTC isr %x, ier %x, iar %x, mer %x\n", intc->isr, intc->ier,
+	printf("INTC isr %x, ier %x, iar %x, mer %x\n", intc->isr, intc->ier,
 		intc->iar, intc->mer);
 #endif
 }
@@ -159,7 +159,7 @@ int interrupts_init(void)
 	return 0;
 }
 
-void interrupt_handler (void)
+void interrupt_handler(void)
 {
 	int irqs = intc->ivr;	/* find active interrupt */
 	int mask = 1;
Signature · 1 line
1.7.0.4
#8 lore raw

PATCH v2 4/7 microblaze: intc: Coding style cleanup

Am Montag, den 06.08.2012, 09:46 +0200 schrieb Michal Simek:

Quoted 6 lines

Just coding style cleanup.
Remove unneeded externs.

Quoted 100 lines

--
v2: Rebase - depends on previous intc patch

---
 arch/microblaze/cpu/interrupts.c |   26 +++++++++++++-------------
 1 files changed, 13 insertions(+), 13 deletions(-)
arch/microblaze/cpu/interrupts.c +13 -13
index 08f6bad..7f2ee64 100644
@@ -32,15 +32,12 @@
 
 #undef DEBUG_INT
 
-extern void microblaze_disable_interrupts (void);
-extern void microblaze_enable_interrupts (void);
-
-void enable_interrupts (void)
+void enable_interrupts(void)
 {
 	MSRSET(0x2);
 }
 
-int disable_interrupts (void)
+int disable_interrupts(void)
 {
 	unsigned int msr;
 
@@ -58,20 +55,21 @@ microblaze_intc_t *intc;
 /* default handler */
 static void def_hdlr(void)
 {
-	puts ("def_hdlr\n");
+	puts("def_hdlr\n");
 }
 
 static void enable_one_interrupt(int irq)
 {
 	int mask;
 	int offset = 1;
+
 	offset <<= irq;
 	mask = intc->ier;
 	intc->ier = (mask | offset);
 #ifdef DEBUG_INT
-	printf ("Enable one interrupt irq %x - mask %x,ier %x\n", offset, mask,
+	printf("Enable one interrupt irq %x - mask %x,ier %x\n", offset, mask,
 		intc->ier);
-	printf ("INTC isr %x, ier %x, iar %x, mer %x\n", intc->isr, intc->ier,
+	printf("INTC isr %x, ier %x, iar %x, mer %x\n", intc->isr, intc->ier,
 		intc->iar, intc->mer);
 #endif
 }
@@ -80,13 +78,14 @@ static void disable_one_interrupt(int irq)
 {
 	int mask;
 	int offset = 1;
+
 	offset <<= irq;
 	mask = intc->ier;
 	intc->ier = (mask & ~offset);
 #ifdef DEBUG_INT
-	printf ("Disable one interrupt irq %x - mask %x,ier %x\n", irq, mask,
+	printf("Disable one interrupt irq %x - mask %x,ier %x\n", irq, mask,
 		intc->ier);
-	printf ("INTC isr %x, ier %x, iar %x, mer %x\n", intc->isr, intc->ier,
+	printf("INTC isr %x, ier %x, iar %x, mer %x\n", intc->isr, intc->ier,
 		intc->iar, intc->mer);
 #endif
 }
@@ -94,9 +93,10 @@ static void disable_one_interrupt(int irq)
 int install_interrupt_handler(int irq, interrupt_handler_t *hdlr, void *arg)
 {
 	struct irq_action *act;
+
 	/* irq out of range */
 	if ((irq < 0) || (irq > irq_no)) {
-		puts ("IRQ out of range\n");
+		puts("IRQ out of range\n");
 		return -1;
 	}
 	act = &vecs[irq];
@@ -124,7 +124,7 @@ static void intc_init(void)
 	/* XIntc_Start - hw_interrupt enable and all interrupt enable */
 	intc->mer = 0x3;
 #ifdef DEBUG_INT
-	printf ("INTC isr %x, ier %x, iar %x, mer %x\n", intc->isr, intc->ier,
+	printf("INTC isr %x, ier %x, iar %x, mer %x\n", intc->isr, intc->ier,
 		intc->iar, intc->mer);
 #endif
 }
@@ -159,7 +159,7 @@ int interrupts_init(void)
 	return 0;
 }
 
-void interrupt_handler (void)
+void interrupt_handler(void)
 {
 	int irqs = intc->ivr;	/* find active interrupt */
 	int mask = 1;
Signature · 8 lines
Viele Gr??e,
Stephan Linz
______________________________________________________________________________
MB-Ref: http://www.li-pro.de/xilinx_mb:mbref:start
OpenDCC: http://www.li-pro.net/opendcc.phtml
PC/M: http://www.li-pro.net/pcm.phtml
Sourceforge: http://sourceforge.net/users/slz
Gitorious: https://gitorious.org/~slz
author maintainer
#9 lore raw

PATCH v2 5/7 microblaze: timer: Prepare for device-tree initialization

In reply to Michal Simek

microblaze: Fix CONFIG_SYS_HZ usage in board config

Do not use hardcoded value. Use CONFIG_SYS_HZ instead. Separate static configuration to single block.

---
v2: Fix irq type irq == -1 means no IRQ

---
 arch/microblaze/cpu/timer.c                    |   69 ++++++++++++-----------
 arch/microblaze/include/asm/microblaze_timer.h |    3 +
 arch/microblaze/lib/board.c                    |    5 --
 include/configs/microblaze-generic.h           |   12 +----
 4 files changed, 41 insertions(+), 48 deletions(-)
arch/microblaze/cpu/timer.c +36 -33
index cc6b897..1330401 100644
@@ -27,42 +27,30 @@
 #include <asm/microblaze_intc.h>
 
 volatile int timestamp = 0;
+microblaze_timer_t *tmr;
 
-#ifdef CONFIG_SYS_TIMER_0
 ulong get_timer (ulong base)
 {
-	return (timestamp - base);
+	if (tmr)
+		return timestamp - base;
+	return timestamp++ - base;
 }
-#else
-ulong get_timer (ulong base)
-{
-	return (timestamp++ - base);
-}
-#endif
 
-#ifdef CONFIG_SYS_TIMER_0
 void __udelay(unsigned long usec)
 {
-	int i;
+	u32 i;
 
-	i = get_timer(0);
-	while ((get_timer(0) - i) < (usec / 1000))
-		;
+	if (tmr) {
+		i = get_timer(0);
+		while ((get_timer(0) - i) < (usec / 1000))
+			;
+	} else {
+		for (i = 0; i < (usec * XILINX_CLOCK_FREQ / 10000000); i++)
+			;
+	}
 }
-#else
-void __udelay(unsigned long usec)
-{
-	unsigned int i;
 
-	for (i = 0; i < (usec * CONFIG_XILINX_CLOCK_FREQ / 10000000); i++)
-		;
-}
-#endif
-
-#ifdef CONFIG_SYS_TIMER_0
-microblaze_timer_t *tmr = (microblaze_timer_t *) (CONFIG_SYS_TIMER_0_ADDR);
-
-void timer_isr (void *arg)
+static void timer_isr(void *arg)
 {
 	timestamp++;
 	tmr->control = tmr->control | TIMER_INTERRUPT;
@@ -70,15 +58,30 @@ void timer_isr (void *arg)
 
 int timer_init (void)
 {
-	tmr->loadreg = CONFIG_SYS_TIMER_0_PRELOAD;
-	tmr->control = TIMER_INTERRUPT | TIMER_RESET;
-	tmr->control =
-	    TIMER_ENABLE | TIMER_ENABLE_INTR | TIMER_RELOAD | TIMER_DOWN_COUNT;
-	timestamp = 0;
-	install_interrupt_handler (CONFIG_SYS_TIMER_0_IRQ, timer_isr, (void *)tmr);
+	int irq = -1;
+	u32 preload = 0;
+	u32 ret = 0;
+
+#if defined(CONFIG_SYS_TIMER_0_ADDR) && defined(CONFIG_SYS_INTC_0_NUM)
+	preload = XILINX_CLOCK_FREQ / CONFIG_SYS_HZ;
+	irq = CONFIG_SYS_TIMER_0_IRQ;
+	tmr = (microblaze_timer_t *) (CONFIG_SYS_TIMER_0_ADDR);
+#endif
+
+	if (tmr && preload && irq >= 0) {
+		tmr->loadreg = preload;
+		tmr->control = TIMER_INTERRUPT | TIMER_RESET;
+		tmr->control = TIMER_ENABLE | TIMER_ENABLE_INTR |\
+					TIMER_RELOAD | TIMER_DOWN_COUNT;
+		timestamp = 0;
+		ret = install_interrupt_handler (irq, timer_isr, (void *)tmr);
+		if (ret)
+			tmr = NULL;
+	}
+
+	/* No problem if timer is not found/initialized */
 	return 0;
 }
-#endif
 
 /*
  * This function is derived from PowerPC code (read timebase as long long).
arch/microblaze/include/asm/microblaze_timer.h +3 -0
index 844c8db..28e8b02 100644
@@ -39,3 +39,6 @@ typedef volatile struct microblaze_timer_t {
 	int loadreg; /* load register TLR */
 	int counter; /* timer/counter register */
 } microblaze_timer_t;
+
+int timer_init(void);
+
arch/microblaze/lib/board.c +0 -5
index b5f21d8..fde109f 100644
@@ -42,9 +42,6 @@ DECLARE_GLOBAL_DATA_PTR;
 #ifdef CONFIG_SYS_GPIO_0
 extern int gpio_init (void);
 #endif
-#ifdef CONFIG_SYS_TIMER_0
-extern int timer_init (void);
-#endif
 #ifdef CONFIG_SYS_FSL_2
 extern void fsl_init2 (void);
 #endif
@@ -74,9 +71,7 @@ init_fnc_t *init_sequence[] = {
 	gpio_init,
 #endif
 	interrupts_init,
-#ifdef CONFIG_SYS_TIMER_0
 	timer_init,
-#endif
 #ifdef CONFIG_SYS_FSL_2
 	fsl_init2,
 #endif
include/configs/microblaze-generic.h +2 -10
index 1266cf7..21ddb2b 100644
@@ -115,19 +115,11 @@
 #endif
 
 /* timer */
-#ifdef XILINX_TIMER_BASEADDR
-# if (XILINX_TIMER_IRQ != -1)
-#  define CONFIG_SYS_TIMER_0		1
+#if defined(XILINX_TIMER_BASEADD) && defined(XILINX_TIMER_IRQ)
 #  define CONFIG_SYS_TIMER_0_ADDR	XILINX_TIMER_BASEADDR
 #  define CONFIG_SYS_TIMER_0_IRQ	XILINX_TIMER_IRQ
-#  define FREQUENCE	XILINX_CLOCK_FREQ
-#  define CONFIG_SYS_TIMER_0_PRELOAD	( FREQUENCE/1000 )
-# endif
-#elif XILINX_CLOCK_FREQ
-# define CONFIG_XILINX_CLOCK_FREQ	XILINX_CLOCK_FREQ
-#else
-# error BAD CLOCK FREQ
 #endif
+
 /* FSL */
 /* #define	CONFIG_SYS_FSL_2 */
 /* #define	FSL_INTR_2	1 */
Signature · 1 line
1.7.0.4
#10 lore raw

PATCH v2 5/7 microblaze: timer: Prepare for device-tree initialization

Hi Michal,

looks fine, but ... (see below)

Am Montag, den 06.08.2012, 09:46 +0200 schrieb Michal Simek:

Quoted 155 lines

microblaze: Fix CONFIG_SYS_HZ usage in board config

Do not use hardcoded value. Use CONFIG_SYS_HZ instead. Separate static configuration to single block.

---
v2: Fix irq type irq == -1 means no IRQ

---
 arch/microblaze/cpu/timer.c                    |   69 ++++++++++++-----------
 arch/microblaze/include/asm/microblaze_timer.h |    3 +
 arch/microblaze/lib/board.c                    |    5 --
 include/configs/microblaze-generic.h           |   12 +----
 4 files changed, 41 insertions(+), 48 deletions(-)
arch/microblaze/cpu/timer.c +36 -33
index cc6b897..1330401 100644
@@ -27,42 +27,30 @@
 #include <asm/microblaze_intc.h>
 
 volatile int timestamp = 0;
+microblaze_timer_t *tmr;
 
-#ifdef CONFIG_SYS_TIMER_0
 ulong get_timer (ulong base)
 {
-	return (timestamp - base);
+	if (tmr)
+		return timestamp - base;
+	return timestamp++ - base;
 }
-#else
-ulong get_timer (ulong base)
-{
-	return (timestamp++ - base);
-}
-#endif
 
-#ifdef CONFIG_SYS_TIMER_0
 void __udelay(unsigned long usec)
 {
-	int i;
+	u32 i;
 
-	i = get_timer(0);
-	while ((get_timer(0) - i) < (usec / 1000))
-		;
+	if (tmr) {
+		i = get_timer(0);
+		while ((get_timer(0) - i) < (usec / 1000))
+			;
+	} else {
+		for (i = 0; i < (usec * XILINX_CLOCK_FREQ / 10000000); i++)
+			;
+	}
 }
-#else
-void __udelay(unsigned long usec)
-{
-	unsigned int i;
 
-	for (i = 0; i < (usec * CONFIG_XILINX_CLOCK_FREQ / 10000000); i++)
-		;
-}
-#endif
-
-#ifdef CONFIG_SYS_TIMER_0
-microblaze_timer_t *tmr = (microblaze_timer_t *) (CONFIG_SYS_TIMER_0_ADDR);
-
-void timer_isr (void *arg)
+static void timer_isr(void *arg)
 {
 	timestamp++;
 	tmr->control = tmr->control | TIMER_INTERRUPT;
@@ -70,15 +58,30 @@ void timer_isr (void *arg)
 
 int timer_init (void)
 {
-	tmr->loadreg = CONFIG_SYS_TIMER_0_PRELOAD;
-	tmr->control = TIMER_INTERRUPT | TIMER_RESET;
-	tmr->control =
-	    TIMER_ENABLE | TIMER_ENABLE_INTR | TIMER_RELOAD | TIMER_DOWN_COUNT;
-	timestamp = 0;
-	install_interrupt_handler (CONFIG_SYS_TIMER_0_IRQ, timer_isr, (void *)tmr);
+	int irq = -1;
+	u32 preload = 0;
+	u32 ret = 0;
+
+#if defined(CONFIG_SYS_TIMER_0_ADDR) && defined(CONFIG_SYS_INTC_0_NUM)
+	preload = XILINX_CLOCK_FREQ / CONFIG_SYS_HZ;
+	irq = CONFIG_SYS_TIMER_0_IRQ;
+	tmr = (microblaze_timer_t *) (CONFIG_SYS_TIMER_0_ADDR);
+#endif
+
+	if (tmr && preload && irq >= 0) {
+		tmr->loadreg = preload;
+		tmr->control = TIMER_INTERRUPT | TIMER_RESET;
+		tmr->control = TIMER_ENABLE | TIMER_ENABLE_INTR |\
+					TIMER_RELOAD | TIMER_DOWN_COUNT;
+		timestamp = 0;
+		ret = install_interrupt_handler (irq, timer_isr, (void *)tmr);
+		if (ret)
+			tmr = NULL;
+	}
+
+	/* No problem if timer is not found/initialized */
 	return 0;
 }
-#endif
 
 /*
  * This function is derived from PowerPC code (read timebase as long long).
arch/microblaze/include/asm/microblaze_timer.h +3 -0
index 844c8db..28e8b02 100644
@@ -39,3 +39,6 @@ typedef volatile struct microblaze_timer_t {
 	int loadreg; /* load register TLR */
 	int counter; /* timer/counter register */
 } microblaze_timer_t;
+
+int timer_init(void);
+
arch/microblaze/lib/board.c +0 -5
index b5f21d8..fde109f 100644
@@ -42,9 +42,6 @@ DECLARE_GLOBAL_DATA_PTR;
 #ifdef CONFIG_SYS_GPIO_0
 extern int gpio_init (void);
 #endif
-#ifdef CONFIG_SYS_TIMER_0
-extern int timer_init (void);
-#endif
 #ifdef CONFIG_SYS_FSL_2
 extern void fsl_init2 (void);
 #endif
@@ -74,9 +71,7 @@ init_fnc_t *init_sequence[] = {
 	gpio_init,
 #endif
 	interrupts_init,
-#ifdef CONFIG_SYS_TIMER_0
 	timer_init,
-#endif
 #ifdef CONFIG_SYS_FSL_2
 	fsl_init2,
 #endif
include/configs/microblaze-generic.h +0 -0
index 1266cf7..21ddb2b 100644

include/configs/microblaze-generic.h line 118

Quoted 7 lines
include/configs/microblaze-generic.h +1 -3
@@ -115,19 +115,11 @@
 #endif
 
 /* timer */
-#ifdef XILINX_TIMER_BASEADDR
-# if (XILINX_TIMER_IRQ != -1)
-#  define CONFIG_SYS_TIMER_0		1
+#if defined(XILINX_TIMER_BASEADD) && defined(XILINX_TIMER_IRQ)

typo here XILINX_TIMER_BASEADD <--- missing 'R'

br,
Stephan

Quoted 14 lines
include/configs/microblaze-generic.h +1 -7
 #  define CONFIG_SYS_TIMER_0_ADDR	XILINX_TIMER_BASEADDR
 #  define CONFIG_SYS_TIMER_0_IRQ	XILINX_TIMER_IRQ
-#  define FREQUENCE	XILINX_CLOCK_FREQ
-#  define CONFIG_SYS_TIMER_0_PRELOAD	( FREQUENCE/1000 )
-# endif
-#elif XILINX_CLOCK_FREQ
-# define CONFIG_XILINX_CLOCK_FREQ	XILINX_CLOCK_FREQ
-#else
-# error BAD CLOCK FREQ
 #endif
+
 /* FSL */
 /* #define	CONFIG_SYS_FSL_2 */
 /* #define	FSL_INTR_2	1 */
author maintainer
#11 lore raw

PATCH v2 5/7 microblaze: timer: Prepare for device-tree initialization

Quoted 162 lines · Stephan Linz

Hi Michal,

looks fine, but ... (see below)

Am Montag, den 06.08.2012, 09:46 +0200 schrieb Michal Simek:

Quoted 157 lines

microblaze: Fix CONFIG_SYS_HZ usage in board config

Do not use hardcoded value. Use CONFIG_SYS_HZ instead. Separate static configuration to single block.

---
v2: Fix irq type irq == -1 means no IRQ

---
  arch/microblaze/cpu/timer.c                    |   69 ++++++++++++-----------
  arch/microblaze/include/asm/microblaze_timer.h |    3 +
  arch/microblaze/lib/board.c                    |    5 --
  include/configs/microblaze-generic.h           |   12 +----
  4 files changed, 41 insertions(+), 48 deletions(-)
arch/microblaze/cpu/timer.c +36 -33
index cc6b897..1330401 100644
@@ -27,42 +27,30 @@
  #include <asm/microblaze_intc.h>
 
  volatile int timestamp = 0;
+microblaze_timer_t *tmr;
 
-#ifdef CONFIG_SYS_TIMER_0
  ulong get_timer (ulong base)
  {
-	return (timestamp - base);
+	if (tmr)
+		return timestamp - base;
+	return timestamp++ - base;
  }
-#else
-ulong get_timer (ulong base)
-{
-	return (timestamp++ - base);
-}
-#endif
 
-#ifdef CONFIG_SYS_TIMER_0
  void __udelay(unsigned long usec)
  {
-	int i;
+	u32 i;
 
-	i = get_timer(0);
-	while ((get_timer(0) - i) < (usec / 1000))
-		;
+	if (tmr) {
+		i = get_timer(0);
+		while ((get_timer(0) - i) < (usec / 1000))
+			;
+	} else {
+		for (i = 0; i < (usec * XILINX_CLOCK_FREQ / 10000000); i++)
+			;
+	}
  }
-#else
-void __udelay(unsigned long usec)
-{
-	unsigned int i;
 
-	for (i = 0; i < (usec * CONFIG_XILINX_CLOCK_FREQ / 10000000); i++)
-		;
-}
-#endif
-
-#ifdef CONFIG_SYS_TIMER_0
-microblaze_timer_t *tmr = (microblaze_timer_t *) (CONFIG_SYS_TIMER_0_ADDR);
-
-void timer_isr (void *arg)
+static void timer_isr(void *arg)
  {
  	timestamp++;
  	tmr->control = tmr->control | TIMER_INTERRUPT;
@@ -70,15 +58,30 @@ void timer_isr (void *arg)
 
  int timer_init (void)
  {
-	tmr->loadreg = CONFIG_SYS_TIMER_0_PRELOAD;
-	tmr->control = TIMER_INTERRUPT | TIMER_RESET;
-	tmr->control =
-	    TIMER_ENABLE | TIMER_ENABLE_INTR | TIMER_RELOAD | TIMER_DOWN_COUNT;
-	timestamp = 0;
-	install_interrupt_handler (CONFIG_SYS_TIMER_0_IRQ, timer_isr, (void *)tmr);
+	int irq = -1;
+	u32 preload = 0;
+	u32 ret = 0;
+
+#if defined(CONFIG_SYS_TIMER_0_ADDR) && defined(CONFIG_SYS_INTC_0_NUM)
+	preload = XILINX_CLOCK_FREQ / CONFIG_SYS_HZ;
+	irq = CONFIG_SYS_TIMER_0_IRQ;
+	tmr = (microblaze_timer_t *) (CONFIG_SYS_TIMER_0_ADDR);
+#endif
+
+	if (tmr && preload && irq >= 0) {
+		tmr->loadreg = preload;
+		tmr->control = TIMER_INTERRUPT | TIMER_RESET;
+		tmr->control = TIMER_ENABLE | TIMER_ENABLE_INTR |\
+					TIMER_RELOAD | TIMER_DOWN_COUNT;
+		timestamp = 0;
+		ret = install_interrupt_handler (irq, timer_isr, (void *)tmr);
+		if (ret)
+			tmr = NULL;
+	}
+
+	/* No problem if timer is not found/initialized */
  	return 0;
  }
-#endif
 
  /*
   * This function is derived from PowerPC code (read timebase as long long).
arch/microblaze/include/asm/microblaze_timer.h +3 -0
index 844c8db..28e8b02 100644
@@ -39,3 +39,6 @@ typedef volatile struct microblaze_timer_t {
  	int loadreg; /* load register TLR */
  	int counter; /* timer/counter register */
  } microblaze_timer_t;
+
+int timer_init(void);
+
arch/microblaze/lib/board.c +0 -5
index b5f21d8..fde109f 100644
@@ -42,9 +42,6 @@ DECLARE_GLOBAL_DATA_PTR;
  #ifdef CONFIG_SYS_GPIO_0
  extern int gpio_init (void);
  #endif
-#ifdef CONFIG_SYS_TIMER_0
-extern int timer_init (void);
-#endif
  #ifdef CONFIG_SYS_FSL_2
  extern void fsl_init2 (void);
  #endif
@@ -74,9 +71,7 @@ init_fnc_t *init_sequence[] = {
  	gpio_init,
  #endif
  	interrupts_init,
-#ifdef CONFIG_SYS_TIMER_0
  	timer_init,
-#endif
  #ifdef CONFIG_SYS_FSL_2
  	fsl_init2,
  #endif
include/configs/microblaze-generic.h +0 -0
index 1266cf7..21ddb2b 100644
@@ -115,19 +115,11 @@
  #endif
 
Quoted 7 lines

include/configs/microblaze-generic.h line 118

Quoted 5 lines
include/configs/microblaze-generic.h +1 -3
  /* timer */
-#ifdef XILINX_TIMER_BASEADDR
-# if (XILINX_TIMER_IRQ != -1)
-#  define CONFIG_SYS_TIMER_0		1
+#if defined(XILINX_TIMER_BASEADD) && defined(XILINX_TIMER_IRQ)

typo here XILINX_TIMER_BASEADD <--- missing 'R'

Will fix it when I add this to my branch.

Thanks,
Michal

Signature · 4 lines
Michal Simek, Ing. (M.Eng)
w: www.monstr.eu p: +42-0-721842854
Maintainer of Linux kernel 2.6 Microblaze Linux - http://www.monstr.eu/fdt/
Microblaze U-BOOT custodian
author maintainer
#12 lore raw

PATCH v2 6/7 microblaze: Clean microblaze initialization

In reply to Michal Simek

Move board specific function to board_init function in board/ folder Remove externs from generic board.c
Use board_init_f function in board.c file.

---
v2: Remove global pointer
Define board_init function in header

---
 arch/microblaze/cpu/start.S                        |    2 +-
 arch/microblaze/include/asm/processor.h            |    3 +++
 arch/microblaze/lib/board.c                        |   17 +++--------------
 .../xilinx/microblaze-generic/microblaze-generic.c |    9 +++++++++
 4 files changed, 16 insertions(+), 15 deletions(-)
arch/microblaze/cpu/start.S +1 -1
index 8a2f634..8564c4e 100644
@@ -149,7 +149,7 @@ clear_bss:
 	cmp     r6, r5, r4 /* check if we have reach the end */
 	bnei    r6, 2b
 3:	/* jumping to board_init */
-	brai	board_init
+	brai	board_init_f
 1:	bri	1b
 
 /*
arch/microblaze/include/asm/processor.h +3 -0
index 2295d0a..2c4d5ff 100644
@@ -28,4 +28,7 @@
 extern char __end[];
 extern char __text_start[];
 
+/* Microblaze board initialization function */
+void board_init(void);
+
 #endif /* __ASM_MICROBLAZE_PROCESSOR_H */
arch/microblaze/lib/board.c +3 -14
index fde109f..b450367 100644
@@ -39,13 +39,6 @@
 
 DECLARE_GLOBAL_DATA_PTR;
 
-#ifdef CONFIG_SYS_GPIO_0
-extern int gpio_init (void);
-#endif
-#ifdef CONFIG_SYS_FSL_2
-extern void fsl_init2 (void);
-#endif
-
 /*
  * All attempts to come up with a "common" initialization sequence
  * that works for all boards and architectures failed: some of the
@@ -67,20 +60,14 @@ init_fnc_t *init_sequence[] = {
 #endif
 	serial_init,
 	console_init_f,
-#ifdef CONFIG_SYS_GPIO_0
-	gpio_init,
-#endif
 	interrupts_init,
 	timer_init,
-#ifdef CONFIG_SYS_FSL_2
-	fsl_init2,
-#endif
 	NULL,
 };
 
 unsigned long monitor_flash_len;
 
-void board_init (void)
+void board_init_f(ulong not_used)
 {
 	bd_t *bd;
 	init_fnc_t **init_fnc_ptr;
@@ -189,6 +176,8 @@ void board_init (void)
 	/* Initialize the console (after the relocation and devices init) */
 	console_init_r();
 
+	board_init();
+
 	/* Initialize from environment */
 	load_addr = getenv_ulong("loadaddr", 16, load_addr);
 
board/xilinx/microblaze-generic/microblaze-generic.c +9 -0
index a1e2bfe..b75e62c 100644
@@ -28,6 +28,7 @@
 #include <common.h>
 #include <config.h>
 #include <netdev.h>
+#include <asm/processor.h>
 #include <asm/microblaze_intc.h>
 #include <asm/asm.h>
 
@@ -69,6 +70,14 @@ int fsl_init2 (void) {
 }
 #endif
 
+void board_init(void)
+{
+	gpio_init();
+#ifdef CONFIG_SYS_FSL_2
+	fsl_init2();
+#endif
+}
+
 int board_eth_init(bd_t *bis)
 {
 	int ret = 0;
Signature · 1 line
1.7.0.4
#13 lore raw

PATCH v2 6/7 microblaze: Clean microblaze initialization

Am Montag, den 06.08.2012, 09:46 +0200 schrieb Michal Simek:

Quoted 6 lines

Move board specific function to board_init function in board/ folder Remove externs from generic board.c
Use board_init_f function in board.c file.

Tested with AXI systems on Avnet S6LX150T and S6LX9 micro-evaluation.

Quoted 111 lines

---
v2: Remove global pointer
Define board_init function in header

---
 arch/microblaze/cpu/start.S                        |    2 +-
 arch/microblaze/include/asm/processor.h            |    3 +++
 arch/microblaze/lib/board.c                        |   17 +++--------------
 .../xilinx/microblaze-generic/microblaze-generic.c |    9 +++++++++
 4 files changed, 16 insertions(+), 15 deletions(-)
arch/microblaze/cpu/start.S +1 -1
index 8a2f634..8564c4e 100644
@@ -149,7 +149,7 @@ clear_bss:
 	cmp     r6, r5, r4 /* check if we have reach the end */
 	bnei    r6, 2b
 3:	/* jumping to board_init */
-	brai	board_init
+	brai	board_init_f
 1:	bri	1b
 
 /*
arch/microblaze/include/asm/processor.h +3 -0
index 2295d0a..2c4d5ff 100644
@@ -28,4 +28,7 @@
 extern char __end[];
 extern char __text_start[];
 
+/* Microblaze board initialization function */
+void board_init(void);
+
 #endif /* __ASM_MICROBLAZE_PROCESSOR_H */
arch/microblaze/lib/board.c +3 -14
index fde109f..b450367 100644
@@ -39,13 +39,6 @@
 
 DECLARE_GLOBAL_DATA_PTR;
 
-#ifdef CONFIG_SYS_GPIO_0
-extern int gpio_init (void);
-#endif
-#ifdef CONFIG_SYS_FSL_2
-extern void fsl_init2 (void);
-#endif
-
 /*
  * All attempts to come up with a "common" initialization sequence
  * that works for all boards and architectures failed: some of the
@@ -67,20 +60,14 @@ init_fnc_t *init_sequence[] = {
 #endif
 	serial_init,
 	console_init_f,
-#ifdef CONFIG_SYS_GPIO_0
-	gpio_init,
-#endif
 	interrupts_init,
 	timer_init,
-#ifdef CONFIG_SYS_FSL_2
-	fsl_init2,
-#endif
 	NULL,
 };
 
 unsigned long monitor_flash_len;
 
-void board_init (void)
+void board_init_f(ulong not_used)
 {
 	bd_t *bd;
 	init_fnc_t **init_fnc_ptr;
@@ -189,6 +176,8 @@ void board_init (void)
 	/* Initialize the console (after the relocation and devices init) */
 	console_init_r();
 
+	board_init();
+
 	/* Initialize from environment */
 	load_addr = getenv_ulong("loadaddr", 16, load_addr);
 
board/xilinx/microblaze-generic/microblaze-generic.c +9 -0
index a1e2bfe..b75e62c 100644
@@ -28,6 +28,7 @@
 #include <common.h>
 #include <config.h>
 #include <netdev.h>
+#include <asm/processor.h>
 #include <asm/microblaze_intc.h>
 #include <asm/asm.h>
 
@@ -69,6 +70,14 @@ int fsl_init2 (void) {
 }
 #endif
 
+void board_init(void)
+{
+	gpio_init();
+#ifdef CONFIG_SYS_FSL_2
+	fsl_init2();
+#endif
+}
+
 int board_eth_init(bd_t *bis)
 {
 	int ret = 0;
Signature · 8 lines
Viele Gr??e,
Stephan Linz
______________________________________________________________________________
MB-Ref: http://www.li-pro.de/xilinx_mb:mbref:start
OpenDCC: http://www.li-pro.net/opendcc.phtml
PC/M: http://www.li-pro.net/pcm.phtml
Sourceforge: http://sourceforge.net/users/slz
Gitorious: https://gitorious.org/~slz
author maintainer
#14 lore raw

PATCH v2 7/7 microblaze: board: Use bi_flashstart instead of CONFIG_SYS_FLASH_BASE

In reply to Michal Simek

Prepare for device-tree driven configuration.

---
v2: Move bi_flashsize and bi_flashoffset from other patch

---
 arch/microblaze/lib/board.c |   10 ++++++----
 1 files changed, 6 insertions(+), 4 deletions(-)
arch/microblaze/lib/board.c +6 -4
index b450367..674b573 100644
@@ -136,9 +136,8 @@ void board_init_f(ulong not_used)
 #if defined(CONFIG_CMD_FLASH)
 	puts ("Flash: ");
 	bd->bi_flashstart = CONFIG_SYS_FLASH_BASE;
-	if (0 < (flash_size = flash_init ())) {
-		bd->bi_flashsize = flash_size;
-		bd->bi_flashoffset = CONFIG_SYS_FLASH_BASE + flash_size;
+	flash_size = flash_init();
+	if (bd->bi_flashstart && flash_size > 0) {
 # ifdef CONFIG_SYS_FLASH_CHECKSUM
 		print_size (flash_size, "");
 		/*
@@ -149,13 +148,16 @@ void board_init_f(ulong not_used)
 		s = getenv ("flashchecksum");
 		if (s && (*s == 'y')) {
 			printf ("  CRC: %08X",
-				crc32 (0, (const unsigned char *) CONFIG_SYS_FLASH_BASE, flash_size)
+				crc32(0, (const u8 *)bd->bi_flashstart,
+							flash_size)
 			);
 		}
 		putc ('\n');
 # else	/* !CONFIG_SYS_FLASH_CHECKSUM */
 		print_size (flash_size, "\n");
 # endif /* CONFIG_SYS_FLASH_CHECKSUM */
+		bd->bi_flashsize = flash_size;
+		bd->bi_flashoffset = bd->bi_flashstart + flash_size;
 	} else {
 		puts ("Flash init FAILED");
 		bd->bi_flashstart = 0;
Signature · 1 line
1.7.0.4
#15 lore raw

PATCH v2 7/7 microblaze: board: Use bi_flashstart instead of CONFIG_SYS_FLASH_BASE

Am Montag, den 06.08.2012, 09:46 +0200 schrieb Michal Simek:

Quoted 4 lines

Prepare for device-tree driven configuration.

Tested with AXI systems on Avnet S6LX150T and S6LX9 micro-evaluation.

Quoted 40 lines

---
v2: Move bi_flashsize and bi_flashoffset from other patch

---
 arch/microblaze/lib/board.c |   10 ++++++----
 1 files changed, 6 insertions(+), 4 deletions(-)
arch/microblaze/lib/board.c +6 -4
index b450367..674b573 100644
@@ -136,9 +136,8 @@ void board_init_f(ulong not_used)
 #if defined(CONFIG_CMD_FLASH)
 	puts ("Flash: ");
 	bd->bi_flashstart = CONFIG_SYS_FLASH_BASE;
-	if (0 < (flash_size = flash_init ())) {
-		bd->bi_flashsize = flash_size;
-		bd->bi_flashoffset = CONFIG_SYS_FLASH_BASE + flash_size;
+	flash_size = flash_init();
+	if (bd->bi_flashstart && flash_size > 0) {
 # ifdef CONFIG_SYS_FLASH_CHECKSUM
 		print_size (flash_size, "");
 		/*
@@ -149,13 +148,16 @@ void board_init_f(ulong not_used)
 		s = getenv ("flashchecksum");
 		if (s && (*s == 'y')) {
 			printf ("  CRC: %08X",
-				crc32 (0, (const unsigned char *) CONFIG_SYS_FLASH_BASE, flash_size)
+				crc32(0, (const u8 *)bd->bi_flashstart,
+							flash_size)
 			);
 		}
 		putc ('\n');
 # else	/* !CONFIG_SYS_FLASH_CHECKSUM */
 		print_size (flash_size, "\n");
 # endif /* CONFIG_SYS_FLASH_CHECKSUM */
+		bd->bi_flashsize = flash_size;
+		bd->bi_flashoffset = bd->bi_flashstart + flash_size;
 	} else {
 		puts ("Flash init FAILED");
 		bd->bi_flashstart = 0;
Signature · 8 lines
Viele Gr??e,
Stephan Linz
______________________________________________________________________________
MB-Ref: http://www.li-pro.de/xilinx_mb:mbref:start
OpenDCC: http://www.li-pro.net/opendcc.phtml
PC/M: http://www.li-pro.net/pcm.phtml
Sourceforge: http://sourceforge.net/users/slz
Gitorious: https://gitorious.org/~slz
#16 lore raw

PATCH v2 1/7 microblaze: Add support for device tree driven board configuration

In reply to Michal Simek

Am Montag, den 06.08.2012, 09:46 +0200 schrieb Michal Simek:

Quoted 10 lines

This is minimum code required to be able to use device-tree for u-boot initialization.
Currently only for device driver initialization.

Linker script change ensures DTB to be aligned for both options CONFIG_OF_EMBED and CONFIG_OF_SEPARATE.

Tested with AXI systems on Avnet S6LX150T and S6LX9 micro-evaluation.

Quoted 99 lines

---
v2: Show message about DTB address in bootlog

---
 arch/microblaze/config.mk                 |    2 ++
 arch/microblaze/cpu/u-boot.lds            |    1 +
 arch/microblaze/include/asm/global_data.h |    1 +
 arch/microblaze/lib/board.c               |   24 ++++++++++++++++++++++++
 4 files changed, 28 insertions(+), 0 deletions(-)
arch/microblaze/config.mk +2 -0
index aca79e2..b4935f0 100644
@@ -31,3 +31,5 @@ CONFIG_STANDALONE_LOAD_ADDR ?= 0x80F00000
 PLATFORM_CPPFLAGS += -ffixed-r31 -D__microblaze__
 
 LDSCRIPT ?= $(SRCTREE)/$(CPUDIR)/u-boot.lds
+
+CONFIG_ARCH_DEVICE_TREE := microblaze
arch/microblaze/cpu/u-boot.lds +1 -0
index ee41145..d033a28 100644
@@ -45,6 +45,7 @@ SECTIONS
 	.data ALIGN(0x4):
 	{
 		__data_start = .;
+		dts/libdts.o (.data)
 		*(.data)
 		__data_end = .;
 	}
arch/microblaze/include/asm/global_data.h +1 -0
index 6e8537c..e802e4e 100644
@@ -43,6 +43,7 @@ typedef	struct	global_data {
 	unsigned long	precon_buf_idx;	/* Pre-Console buffer index */
 #endif
 	unsigned long	env_addr;	/* Address  of Environment struct */
+	const void	*fdt_blob;	/* Our device tree, NULL if none */
 	unsigned long	env_valid;	/* Checksum of Environment valid? */
 	unsigned long	fb_base;	/* base address of frame buffer */
 	void		**jt;		/* jump table */
arch/microblaze/lib/board.c +24 -0
index b80250a..942e18c 100644
@@ -34,6 +34,7 @@
 #include <net.h>
 #include <asm/processor.h>
 #include <asm/microblaze_intc.h>
+#include <fdtdec.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -63,6 +64,9 @@ typedef int (init_fnc_t) (void);
 
 init_fnc_t *init_sequence[] = {
 	env_init,
+#ifdef CONFIG_OF_CONTROL
+	fdtdec_check_fdt,
+#endif
 	serial_init,
 	console_init_f,
 #ifdef CONFIG_SYS_GPIO_0
@@ -103,6 +107,17 @@ void board_init (void)
 
 	monitor_flash_len = __end - __text_start;
 
+#ifdef CONFIG_OF_EMBED
+	/* Get a pointer to the FDT */
+	gd->fdt_blob = _binary_dt_dtb_start;
+#elif defined CONFIG_OF_SEPARATE
+	/* FDT is at end of image */
+	gd->fdt_blob = (void *)__end;
+#endif
+	/* Allow the early environment to override the fdt address */
+	gd->fdt_blob = (void *)getenv_ulong("fdtcontroladdr", 16,
+						(uintptr_t)gd->fdt_blob);
+
 	/*
 	 * The Malloc area is immediately below the monitor copy in DRAM
 	 * aka CONFIG_SYS_MONITOR_BASE - Note there is no need for reloc_off
@@ -121,6 +136,15 @@ void board_init (void)
 		}
 	}
 
+#ifdef CONFIG_OF_CONTROL
+	/* For now, put this check after the console is ready */
+	if (fdtdec_prepare_fdt()) {
+		panic("** CONFIG_OF_CONTROL defined but no FDT - please see "
+			"doc/README.fdt-control");
+	} else
+		printf("DTB: 0x%x\n", (u32)gd->fdt_blob);
+#endif
+
 	puts ("SDRAM :\n");
 	printf ("\t\tIcache:%s\n", icache_status() ? "ON" : "OFF");
 	printf ("\t\tDcache:%s\n", dcache_status() ? "ON" : "OFF");
Signature · 8 lines
Viele Gr??e,
Stephan Linz
______________________________________________________________________________
MB-Ref: http://www.li-pro.de/xilinx_mb:mbref:start
OpenDCC: http://www.li-pro.net/opendcc.phtml
PC/M: http://www.li-pro.net/pcm.phtml
Sourceforge: http://sourceforge.net/users/slz
Gitorious: https://gitorious.org/~slz
author maintainer
#17 lore raw

PATCH v2 1/7 microblaze: Add support for device tree driven board configuration

Quoted 8 lines · Stephan Linz

Am Montag, den 06.08.2012, 09:46 +0200 schrieb Michal Simek:

Quoted 7 lines

This is minimum code required to be able to use device-tree for u-boot initialization.
Currently only for device driver initialization.

Linker script change ensures DTB to be aligned for both options CONFIG_OF_EMBED and CONFIG_OF_SEPARATE.

Quoted 8 lines
Quoted 3 lines

Tested with AXI systems on Avnet S6LX150T and S6LX9 micro-evaluation.

Applied the whole series to microblaze custodian repo.

I have fixed small typo fault in 5/7 directly without sending v3 patch to mailing list.

Thanks,
Michal

Signature · 4 lines
Michal Simek, Ing. (M.Eng)
w: www.monstr.eu p: +42-0-721842854
Maintainer of Linux kernel 2.6 Microblaze Linux - http://www.monstr.eu/fdt/
Microblaze U-BOOT custodian