microblaze: board: Remove compilation warning
Subsystems (2)
Michal Simek
maintainerPATCH 1/12 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'
--- arch/microblaze/lib/board.c | 7 ++++--- 1 files changed, 4 insertions(+), 3 deletions(-)
arch/microblaze/lib/board.c +4 -3
@@ -98,7 +98,6 @@ 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;#if defined(CONFIG_CMD_FLASH )ulong flash_size =0 ;#endif
@@ -157,9 +156,9 @@ void board_init (void)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;# ifdef CONFIG_SYS_FLASH_CHECKSUM +char *s; +print_size (flash_size,"" );/* * Compute and print flash CRC if flashchecksum is set to 'y'
@@ -176,6 +175,8 @@ void board_init (void)# else /* !CONFIG_SYS_FLASH_CHECKSUM */ print_size (flash_size,"\n" );# endif /* CONFIG_SYS_FLASH_CHECKSUM */ + bd->bi_flashsize = flash_size; + bd->bi_flashoffset =CONFIG_SYS_FLASH_BASE + flash_size; }else {puts ("Flash init FAILED" ); bd->bi_flashstart =0 ;
Signature · 1 line
1.7.0.4
Michal Simek
maintainerPATCH 2/12 microblaze: Remove extern from board.c
eth_init() is defined at include/net.h.
--- arch/microblaze/lib/board.c | 4 ---- 1 files changed, 0 insertions(+), 4 deletions(-)
arch/microblaze/lib/board.c +0 -4
@@ -42,10 +42,6 @@ extern int gpio_init (void);#ifdef CONFIG_SYS_INTC_0 extern int interrupts_init (void );#endif - -#if defined(CONFIG_CMD_NET ) -extern int eth_init (bd_t * bis); -#endif #ifdef CONFIG_SYS_TIMER_0 extern int timer_init (void );#endif
Signature · 1 line
1.7.0.4
PATCH 2/12 microblaze: Remove extern from board.c
Quoted 4 lines · Michal Simek
eth_init()is defined atinclude/net.h.Signed-off-by Michal Simek <[email protected]>
Quoted 23 lines
--- arch/microblaze/lib/board.c | 4 ---- 1 files changed, 0 insertions(+), 4 deletions(-)arch/microblaze/lib/board.c +0
-5@@ -42,10 +42,6 @@ extern int gpio_init (void);#ifdef CONFIG_SYS_INTC_0 extern int interrupts_init (void );#endif - -#if defined(CONFIG_CMD_NET ) -extern int eth_init (bd_t * bis); -#endif #ifdef CONFIG_SYS_TIMER_0 extern int timer_init (void );#endif --1.7.0.4
PATCH 2/12 microblaze: Remove extern from board.c
Quoted 1 line · Simon Glass
Acked-by Simon Glass <sjg at chromium.org <mailto:[email protected]>>
Applied.
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
Michal Simek
maintainerPATCH 3/12 microblaze: intc: Clear interrupt code
In reply to Michal SimekClear and prepare for device-tree driven configuration. Remove CONFIG_SYS_INTC_0 definition
Use dynamic allocation instead of static.
--- arch/microblaze/cpu/interrupts.c | 88 ++++++++++++++----------- arch/microblaze/cpu/start.S | 2 - arch/microblaze/cpu/timer.c | 2 - arch/microblaze/include/asm/microblaze_intc.h | 3 + arch/microblaze/lib/board.c | 6 +-- include/configs/microblaze-generic.h | 1 - 6 files changed, 54 insertions(+), 48 deletions(-)
arch/microblaze/cpu/interrupts.c +50 -38
@@ -26,6 +26,7 @@#include <common.h> #include <command.h> +#include <malloc.h> #include <asm/microblaze_intc.h> #include <asm/asm.h>
@@ -48,20 +49,19 @@ int disable_interrupts (void)return (msr &0x2 ) !=0 ; } -#ifdef CONFIG_SYS_INTC_0 - -static struct irq_action vecs[CONFIG_SYS_INTC_0_NUM ]; +static struct irq_action *vecs; +static u32 irq_no;/* mapping structure to interrupt controller */ -microblaze_intc_t *intc = (microblaze_intc_t *) (CONFIG_SYS_INTC_0_ADDR ); +microblaze_intc_t *intc;/* default handler */ -void def_hdlr (void ) +static void def_hdlr (void ) {puts ("def_hdlr\n" ); } -void enable_one_interrupt (int irq) +static void enable_one_interrupt (int irq) {int mask;int offset =1 ;
@@ -76,7 +76,7 @@ void enable_one_interrupt (int irq)#endif } -void disable_one_interrupt (int irq) +static void disable_one_interrupt (int irq) {int mask;int offset =1 ;
@@ -96,7 +96,7 @@ void install_interrupt_handler (int irq, interrupt_handler_t * hdlr, void *arg) {struct irq_action *act;/* irq out of range */ -if ((irq <0 ) || (irq >CONFIG_SYS_INTC_0_NUM )) { +if ((irq <0 ) || (irq > irq_no)) {puts ("IRQ out of range\n" );return ; }
@@ -114,7 +114,7 @@ void install_interrupt_handler (int irq, interrupt_handler_t * hdlr, void *arg) }/* initialization interrupt controller - hardware */ -void intc_init (void ) +static void intc_init (void ) { intc->mer =0 ; intc->ier =0 ;
@@ -127,18 +127,33 @@ void intc_init (void)#endif } -int interrupts_init (void ) +int interrupts_init (void ) {int i; -/* initialize irq list */ -for (i =0 ; i <CONFIG_SYS_INTC_0_NUM ; i++) { - vecs[i].handler = (interrupt_handler_t *) def_hdlr; - vecs[i].arg = (void *)i; - vecs[i].count =0 ; + +#if defined(CONFIG_SYS_INTC_0_ADDR ) && defined(CONFIG_SYS_INTC_0_NUM ) + intc = (microblaze_intc_t *) (CONFIG_SYS_INTC_0_ADDR ); + irq_no =CONFIG_SYS_INTC_0_NUM ; +#endif +if (irq_no) { + vecs =calloc (1 ,sizeof (struct irq_action ) * irq_no); +if (vecs ==NULL ) { +puts ("Interrupt vector allocation failed\n" ); +return -1 ; + } + +/* initialize irq list */ +for (i =0 ; i < irq_no; i++) { + vecs[i].handler = (interrupt_handler_t *) def_hdlr; + vecs[i].arg = (void *)i; + vecs[i].count =0 ; + } +/* initialize intc controller */ +intc_init (); +enable_interrupts (); + }else { +puts ("Undefined interrupt controller\n" ); } -/* initialize intc controller */ -intc_init (); -enable_interrupts ();return 0 ; }
@@ -172,33 +187,30 @@ void interrupt_handler (void)printf ("Interrupt handler on %x line, r14 %x\n" , irqs, value);#endif } -#endif #if defined(CONFIG_CMD_IRQ ) -#ifdef CONFIG_SYS_INTC_0 -int do_irqinfo (cmd_tbl_t * cmdtp,int flag,int argc,char *const argv[]) +int do_irqinfo (cmd_tbl_t *cmdtp,int flag,int argc,const char *argv[]) {int i;struct irq_action *act = vecs; -puts ("\nInterrupt-Information:\n\n" -"Nr Routine Arg Count\n" -"-----------------------------\n" ); - -for (i =0 ; i <CONFIG_SYS_INTC_0_NUM ; i++) { -if (act->handler != (interrupt_handler_t *) def_hdlr) { -printf ("%02d %08x %08x %d\n" , i, - (int )act->handler, (int )act->arg, act->count); +if (irq_no) { +puts ("\nInterrupt-Information:\n\n" +"Nr Routine Arg Count\n" +"-----------------------------\n" ); + +for (i =0 ; i < irq_no; i++) { +if (act->handler != (interrupt_handler_t *) def_hdlr) { +printf ("%02d %08x %08x %d\n" , i, + (int )act->handler, (int )act->arg, + act->count); + } + act++; } - act++; +puts ("\n" ); + }else { +puts ("Undefined interrupt controller\n" ); } -puts ("\n" ); -return (0 ); -} -#else -int do_irqinfo (cmd_tbl_t * cmdtp,int flag,int argc,char *const argv[]) -{ -puts ("Undefined interrupt controller\n" ); +return 0 ; }#endif -#endif
arch/microblaze/cpu/start.S +0 -2
@@ -108,7 +108,6 @@ _start: sh r6, r0, r8 #endif -#ifdef CONFIG_SYS_INTC_0 /* interrupt_handler */ swi r2, r0, 0x10 /* interrupt - imm opcode */ swi r3, r0, 0x14 /* interrupt - brai opcode */
@@ -120,7 +119,6 @@ _start: sh r7, r0, r8 rsubi r8, r10, 0x16 sh r6, r0, r8 -#endif /* hardware exception */ swi r2, r0, 0x20 /* hardware exception - imm opcode */
arch/microblaze/cpu/timer.c +0 -2
@@ -40,7 +40,6 @@ ulong get_timer (ulong base) }#endif -#ifdef CONFIG_SYS_INTC_0 #ifdef CONFIG_SYS_TIMER_0 microblaze_timer_t *tmr = (microblaze_timer_t *) (CONFIG_SYS_TIMER_0_ADDR );
@@ -61,7 +60,6 @@ int timer_init (void) return 0; }#endif -#endif /* * This function is derived from PowerPC code (read timebase as long long).
arch/microblaze/include/asm/microblaze_intc.h +3 -0
@@ -41,3 +41,6 @@ struct irq_action {void install_interrupt_handler (int irq,interrupt_handler_t * hdlr,void *arg); + +int interrupts_init (void ); +
arch/microblaze/lib/board.c +1 -5
@@ -32,6 +32,7 @@#include <stdio_dev.h> #include <net.h> #include <asm/processor.h> +#include <asm/microblaze_intc.h> #include <fdtdec.h> DECLARE_GLOBAL_DATA_PTR ;
@@ -39,9 +40,6 @@ DECLARE_GLOBAL_DATA_PTR;#ifdef CONFIG_SYS_GPIO_0 extern int gpio_init (void );#endif -#ifdef CONFIG_SYS_INTC_0 -extern int interrupts_init (void ); -#endif #ifdef CONFIG_SYS_TIMER_0 extern int timer_init (void );#endif
@@ -73,9 +71,7 @@ init_fnc_t *init_sequence[] = {#ifdef CONFIG_SYS_GPIO_0 gpio_init, #endif -#ifdef CONFIG_SYS_INTC_0 interrupts_init, -#endif #ifdef CONFIG_SYS_TIMER_0 timer_init,#endif
include/configs/microblaze-generic.h +0 -1
@@ -97,7 +97,6 @@/* interrupt controller */ #ifdef XILINX_INTC_BASEADDR -# define CONFIG_SYS_INTC_0 1# define CONFIG_SYS_INTC_0_ADDR XILINX_INTC_BASEADDR# define CONFIG_SYS_INTC_0_NUM XILINX_INTC_NUM_INTR_INPUTS#endif
Signature · 1 line
1.7.0.4
PATCH 3/12 microblaze: intc: Clear interrupt code
Hi Michal,
Quoted 6 lines · Michal Simek
Clear and prepare for device-tree driven configuration. Remove
CONFIG_SYS_INTC_0definition
Use dynamic allocation instead of static.Signed-off-by Michal Simek <[email protected]>
I'm not really qualified to review this, but it seems reasonable.
Quoted 89 lines
--- arch/microblaze/cpu/interrupts.c | 88 ++++++++++++++----------- arch/microblaze/cpu/start.S | 2 - arch/microblaze/cpu/timer.c | 2 - arch/microblaze/include/asm/microblaze_intc.h | 3 + arch/microblaze/lib/board.c | 6 +-- include/configs/microblaze-generic.h | 1 - 6 files changed, 54 insertions(+), 48 deletions(-)arch/microblaze/cpu/interrupts.c +8
-8@@ -26,6 +26,7 @@#include <common.h> #include <command.h> +#include <malloc.h> #include <asm/microblaze_intc.h> #include <asm/asm.h> @@ -48,20 +49,19 @@ int disable_interrupts (void)return (msr &0x2 ) !=0 ; } -#ifdef CONFIG_SYS_INTC_0 - -static struct irq_action vecs[CONFIG_SYS_INTC_0_NUM ]; +static struct irq_action *vecs; +static u32 irq_no;/* mapping structure to interrupt controller */ -microblaze_intc_t *intc = (microblaze_intc_t *) (CONFIG_SYS_INTC_0_ADDR ); +microblaze_intc_t *intc;/* default handler */ -void def_hdlr (void ) +static void def_hdlr (void ) {puts ("def_hdlr\n" ); } -void enable_one_interrupt (int irq) +static void enable_one_interrupt (int irq) {int mask;int offset =1 ;@@ -76,7 +76,7 @@ void enable_one_interrupt (int irq)#endif } -void disable_one_interrupt (int irq) +static void disable_one_interrupt (int irq) {int mask;int offset =1 ;@@ -96,7 +96,7 @@ void install_interrupt_handler (int irq, interrupt_handler_t * hdlr, void *arg) {struct irq_action *act;/* irq out of range */ -if ((irq <0 ) || (irq >CONFIG_SYS_INTC_0_NUM )) { +if ((irq <0 ) || (irq > irq_no)) {puts ("IRQ out of range\n" );return ;}arch/microblaze/cpu/interrupts.c +1
-1@@ -114,7 +114,7 @@ void install_interrupt_handler (int irq, interrupt_handler_t * hdlr, void *arg) }/* initialization interrupt controller - hardware */ -void intc_init (void ) +static void intc_init (void ) { intc->mer =0 ;intc->ier = 0;arch/microblaze/cpu/interrupts.c +1
-4@@ -127,18 +127,33 @@ void intc_init (void)#endif } -int interrupts_init (void ) +int interrupts_init (void ) {int i; -/* initialize irq list */ -for (i =0 ; i <CONFIG_SYS_INTC_0_NUM ; i++) { - vecs[i].handler = (interrupt_handler_t *) def_hdlr;
arch/microblaze/cpu/interrupts.c void intc_init (void) · line 140
Quoted 10 lines
arch/microblaze/cpu/interrupts.c +7
-2- vecs[i].arg = (void *)i; - vecs[i].count =0 ; + +#if defined(CONFIG_SYS_INTC_0_ADDR ) && defined(CONFIG_SYS_INTC_0_NUM ) + intc = (microblaze_intc_t *) (CONFIG_SYS_INTC_0_ADDR ); + irq_no =CONFIG_SYS_INTC_0_NUM ; +#endif +if (irq_no) { + vecs =calloc (1 ,sizeof (struct irq_action ) * irq_no);
This is fine, since I assume it is called after memalloc_init(), but you could set an arbitrary maximum limit if you prefer.
Quoted 181 lines
arch/microblaze/cpu/interrupts.c +32
-20+if (vecs ==NULL ) { +puts ("Interrupt vector allocation failed\n" ); +return -1 ; + } + +/* initialize irq list */ +for (i =0 ; i < irq_no; i++) { + vecs[i].handler = (interrupt_handler_t *) def_hdlr; + vecs[i].arg = (void *)i; + vecs[i].count =0 ; + } +/* initialize intc controller */ +intc_init (); +enable_interrupts (); + }else { +puts ("Undefined interrupt controller\n" ); } -/* initialize intc controller */ -intc_init (); -enable_interrupts ();return 0 ; }@@ -172,33 +187,30 @@ void interrupt_handler (void)printf ("Interrupt handler on %x line, r14 %x\n" , irqs, value);#endif } -#endif #if defined(CONFIG_CMD_IRQ ) -#ifdef CONFIG_SYS_INTC_0 -int do_irqinfo (cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[]) +int do_irqinfo (cmd_tbl_t *cmdtp,int flag,int argc,const char *argv[]) {int i;struct irq_action *act = vecs; - puts ("\nInterrupt-Information:\n\n" - "Nr Routine Arg Count\n" - "-----------------------------\n"); - - for (i = 0; i < CONFIG_SYS_INTC_0_NUM; i++) { - if (act->handler != (interrupt_handler_t*) def_hdlr) { - printf ("%02d %08x %08x %d\n", i, - (int)act->handler, (int)act->arg, act->count); +if (irq_no) { +puts ("\nInterrupt-Information:\n\n" +"Nr Routine Arg Count\n" +"-----------------------------\n" ); + +for (i =0 ; i < irq_no; i++) { +if (act->handler != (interrupt_handler_t *) def_hdlr) { +printf ("%02d %08x %08x %d\n" , i, + (int )act->handler, (int )act->arg, + act->count); + } + act++; } - act++; +puts ("\n" ); + }else { +puts ("Undefined interrupt controller\n" ); } - puts ("\n"); - return (0); -} -#else -int do_irqinfo (cmd_tbl_t * cmdtp, int flag, int argc, char * constargv[])
arch/microblaze/cpu/interrupts.c +1
-3-{ -puts ("Undefined interrupt controller\n" ); + return 0; }#endif -#endif arch/microblaze/cpu/start.S +0
-2@@ -108,7 +108,6 @@ _start: sh r6, r0, r8 #endif -#ifdef CONFIG_SYS_INTC_0 /* interrupt_handler */ swi r2, r0, 0x10 /* interrupt - imm opcode */ swi r3, r0, 0x14 /* interrupt - brai opcode */@@ -120,7 +119,6 @@ _start: sh r7, r0, r8 rsubi r8, r10, 0x16 sh r6, r0, r8 -#endif /* hardware exception */ swi r2, r0, 0x20 /* hardware exception - imm opcode */arch/microblaze/cpu/timer.c +0
-2@@ -40,7 +40,6 @@ ulong get_timer (ulong base) }#endif -#ifdef CONFIG_SYS_INTC_0 #ifdef CONFIG_SYS_TIMER_0 microblaze_timer_t *tmr = (microblaze_timer_t *) (CONFIG_SYS_TIMER_0_ADDR );@@ -61,7 +60,6 @@ int timer_init (void) return 0; }#endif -#endif /* * This function is derived from PowerPC code (read timebase as long long).
arch/microblaze/include/asm/microblaze_intc.h +3
-0@@ -41,3 +41,6 @@ struct irq_action {void install_interrupt_handler (int irq,interrupt_handler_t * hdlr,void *arg); + +int interrupts_init (void ); +arch/microblaze/lib/board.c +1
-5@@ -32,6 +32,7 @@#include <stdio_dev.h> #include <net.h> #include <asm/processor.h> +#include <asm/microblaze_intc.h> #include <fdtdec.h> DECLARE_GLOBAL_DATA_PTR ;@@ -39,9 +40,6 @@ DECLARE_GLOBAL_DATA_PTR;#ifdef CONFIG_SYS_GPIO_0 extern int gpio_init (void );#endif -#ifdef CONFIG_SYS_INTC_0 -extern int interrupts_init (void ); -#endif #ifdef CONFIG_SYS_TIMER_0 extern int timer_init (void );#endif @@ -73,9 +71,7 @@ init_fnc_t *init_sequence[] = {#ifdef CONFIG_SYS_GPIO_0 gpio_init, #endif -#ifdef CONFIG_SYS_INTC_0 interrupts_init, -#endif #ifdef CONFIG_SYS_TIMER_0 timer_init,#endif include/configs/microblaze-generic.h +0
-2@@ -97,7 +97,6 @@/* interrupt controller */ #ifdef XILINX_INTC_BASEADDR -# define CONFIG_SYS_INTC_0 1# define CONFIG_SYS_INTC_0_ADDR XILINX_INTC_BASEADDR# define CONFIG_SYS_INTC_0_NUM XILINX_INTC_NUM_INTR_INPUTS#endif --1.7.0.4
Quoted 1 line
Regards,
Simon
PATCH 3/12 microblaze: intc: Clear interrupt code
Quoted 8 lines · Simon Glass
Hi Michal,
On Mon, Jul 9, 2012 at 2:20 AM, Michal Simek <monstr at monstr.eu <mailto:[email protected]>> wrote:
Clear and prepare for device-tree driven configuration. Remove
CONFIG_SYS_INTC_0definition
Use dynamic allocation instead of static.
Quoted 6 lines
Signed-off-by Michal Simek <monstr at monstr.eu <mailto:[email protected]>>I'm not really qualified to review this, but it seems reasonable.
Acked-by Simon Glass <sjg at chromium.org <mailto:[email protected]>>
thanks.
Quoted 97 lines
---
arch/microblaze/cpu/interrupts.c | 88 ++++++++++++++-----------
arch/microblaze/cpu/start.S | 2 -
arch/microblaze/cpu/timer.c | 2 -
arch/microblaze/include/asm/microblaze_intc.h | 3 +
arch/microblaze/lib/board.c | 6 +--
include/configs/microblaze-generic.h | 1 -
6 files changed, 54 insertions(+), 48 deletions(-)
diff --git a/arch/microblaze/cpu/interrupts.c b/arch/microblaze/cpu/interrupts.c
index e7ca859..ee67082 100644
--- a/arch/microblaze/cpu/interrupts.c
+++ b/arch/microblaze/cpu/interrupts.c
@@ -26,6 +26,7 @@
#include <common.h>
#include <command.h>
+#include <malloc.h>
#include <asm/microblaze_intc.h>
#include <asm/asm.h>
@@ -48,20 +49,19 @@ int disable_interrupts (void)
return (msr & 0x2) != 0;
}
-#ifdef CONFIG_SYS_INTC_0
-
-static struct irq_action vecs[CONFIG_SYS_INTC_0_NUM];
+static struct irq_action *vecs;
+static u32 irq_no;
/* mapping structure to interrupt controller */
-microblaze_intc_t *intc = (microblaze_intc_t *) (CONFIG_SYS_INTC_0_ADDR);
+microblaze_intc_t *intc;
/* default handler */
-void def_hdlr (void)
+static void def_hdlr(void)
{
puts ("def_hdlr\n");
}
-void enable_one_interrupt (int irq)
+static void enable_one_interrupt(int irq)
{
int mask;
int offset = 1;
@@ -76,7 +76,7 @@ void enable_one_interrupt (int irq)
#endif
}
-void disable_one_interrupt (int irq)
+static void disable_one_interrupt(int irq)
{
int mask;
int offset = 1;
@@ -96,7 +96,7 @@ void install_interrupt_handler (int irq, interrupt_handler_t * hdlr, void *arg)
{
struct irq_action *act;
/* irq out of range */
- if ((irq < 0) || (irq > CONFIG_SYS_INTC_0_NUM)) {
+ if ((irq < 0) || (irq > irq_no)) {
puts ("IRQ out of range\n");
return;
}
@@ -114,7 +114,7 @@ void install_interrupt_handler (int irq, interrupt_handler_t * hdlr, void *arg)
}
/* initialization interrupt controller - hardware */
-void intc_init (void)
+static void intc_init(void)
{
intc->mer = 0;
intc->ier = 0;
@@ -127,18 +127,33 @@ void intc_init (void)
#endif
}
-int interrupts_init (void)
+int interrupts_init(void)
{
int i;
- /* initialize irq list */
- for (i = 0; i < CONFIG_SYS_INTC_0_NUM; i++) {
- vecs[i].handler = (interrupt_handler_t *) def_hdlr;
- vecs[i].arg = (void *)i;
- vecs[i].count = 0;
+
+#if defined(CONFIG_SYS_INTC_0_ADDR) && defined(CONFIG_SYS_INTC_0_NUM)
+ intc = (microblaze_intc_t *) (CONFIG_SYS_INTC_0_ADDR);
+ irq_no = CONFIG_SYS_INTC_0_NUM;
+#endif
+ if (irq_no) {
+ vecs = calloc(1, sizeof(struct irq_action) * irq_no);Quoted 2 lines
This is fine, since I assume it is called after
memalloc_init(), but you could set an arbitrary maximum limit if you prefer.
Yes, it is called after mem_malloc_init.
The maximum limit is 32 but it won't be reached.
This checking is done by u-boot BSP.
Applied.
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
Michal Simek
maintainerPATCH 4/12 microblaze: intc: Registering interrupt should return value
In reply to Michal SimekReturn value to find out if un/registration was succesful.
--- arch/microblaze/cpu/interrupts.c | 15 +++++++++------ arch/microblaze/include/asm/microblaze_intc.h | 2 +- 2 files changed, 10 insertions(+), 7 deletions(-)
arch/microblaze/cpu/interrupts.c +9 -6
@@ -92,13 +92,13 @@ static void disable_one_interrupt(int irq) }/* 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 +106,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
@@ -39,7 +39,7 @@ struct irq_action {int count;/* number of interrupt */ }; -void install_interrupt_handler (int irq,interrupt_handler_t * hdlr, +int install_interrupt_handler (int irq,interrupt_handler_t *hdlr,void *arg);int interrupts_init (void );
Signature · 1 line
1.7.0.4
PATCH 4/12 microblaze: intc: Registering interrupt should return value
Hi Michal,
Quoted 64 lines · Michal Simek
Return value to find out if un/registration was succesful.
Signed-off-by Michal Simek <[email protected]>--- arch/microblaze/cpu/interrupts.c | 15 +++++++++------ arch/microblaze/include/asm/microblaze_intc.h | 2 +- 2 files changed, 10 insertions(+), 7 deletions(-)arch/microblaze/cpu/interrupts.c +2
-2@@ -92,13 +92,13 @@ static void disable_one_interrupt(int irq) }/* 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 */arch/microblaze/cpu/interrupts.c +7
-4@@ -106,11 +106,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@@ -39,7 +39,7 @@ struct irq_action {int count;/* number of interrupt */ }; -void install_interrupt_handler (int irq,interrupt_handler_t * hdlr, +int install_interrupt_handler (int irq,interrupt_handler_t *hdlr,void *arg);
Quoted 1 line
Perhaps you should add a comment here as to what the return value is, and
maybe the other args also?
Quoted 5 lines
int
interrupts_init(void);
--
1.7.0.4Regards,
Simon
Michal Simek
maintainerPATCH 4/12 microblaze: intc: Registering interrupt should return value
Quoted 63 lines · Simon Glass
Hi Michal,
On Mon, Jul 9, 2012 at 2:20 AM, Michal Simek <monstr at monstr.eu <mailto:[email protected]>> wrote:
Return value to find out if un/registration was succesful. Signed-off-by: Michal Simek <monstr at monstr.eu <mailto:[email protected]>> --- arch/microblaze/cpu/interrupts.c | 15 +++++++++------ arch/microblaze/include/asm/microblaze_intc.h | 2 +- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/arch/microblaze/cpu/interrupts.c b/arch/microblaze/cpu/interrupts.c index ee67082..871cefb 100644 --- a/arch/microblaze/cpu/interrupts.c +++ b/arch/microblaze/cpu/interrupts.c @@ -92,13 +92,13 @@ static void disable_one_interrupt(int irq) } /* 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 +106,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 */ diff --git a/arch/microblaze/include/asm/microblaze_intc.h b/arch/microblaze/include/asm/microblaze_intc.h index 6142b9c..359efe4 100644 --- a/arch/microblaze/include/asm/microblaze_intc.h +++ b/arch/microblaze/include/asm/microblaze_intc.h @@ -39,7 +39,7 @@ struct irq_action { int count; /* number of interrupt */ }; -void install_interrupt_handler (int irq, interrupt_handler_t * hdlr, +int install_interrupt_handler(int irq, interrupt_handler_t *hdlr, void *arg);
Quoted 1 line
Perhaps you should add a comment here as to what the return value is, and maybe the other args also?
Make sense. Will be in v2.
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
Michal Simek
maintainerPATCH 5/12 microblaze: intc: Coding style cleanup
In reply to Michal SimekJust coding style cleanup.
Remove unneeded externs.
--- arch/microblaze/cpu/interrupts.c | 26 +++++++++++++------------- 1 files changed, 13 insertions(+), 13 deletions(-)
arch/microblaze/cpu/interrupts.c +13 -13
@@ -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 }
@@ -95,9 +94,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];
@@ -125,7 +125,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 }
@@ -160,7 +160,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
PATCH 5/12 microblaze: intc: Coding style cleanup
Quoted 5 lines · Michal Simek
Just coding style cleanup.
Remove unneeded externs.Signed-off-by Michal Simek <[email protected]>
Quoted 114 lines
--- arch/microblaze/cpu/interrupts.c | 26 +++++++++++++------------- 1 files changed, 13 insertions(+), 13 deletions(-)arch/microblaze/cpu/interrupts.c +6
-8@@ -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
}arch/microblaze/cpu/interrupts.c +3
-2@@ -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
}arch/microblaze/cpu/interrupts.c +2
-1@@ -95,9 +94,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];arch/microblaze/cpu/interrupts.c +1
-1@@ -125,7 +125,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
}arch/microblaze/cpu/interrupts.c +1
-2@@ -160,7 +160,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 ; --1.7.0.4
Michal Simek
maintainerPATCH 5/12 microblaze: intc: Coding style cleanup
Quoted 10 lines · Simon Glass
On Mon, Jul 9, 2012 at 2:20 AM, Michal Simek <monstr at monstr.eu <mailto:[email protected]>> wrote:
Just coding style cleanup.
Remove unneeded externs.Signed-off-by Michal Simek <monstr at monstr.eu <mailto:[email protected]>>Acked-by Simon Glass <sjg at chromium.org <mailto:[email protected]>>
It depends on previous patch that's why I will send it in v2 package.
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
Michal Simek
maintainerPATCH 6/12 microblaze: intc: Add device-tree driver configuration
In reply to Michal SimekRead configuration from DTB.
--- arch/microblaze/cpu/interrupts.c | 19 +++++++++++++++++++ 1 files changed, 19 insertions(+), 0 deletions(-)
arch/microblaze/cpu/interrupts.c +19 -0
@@ -29,6 +29,9 @@#include <malloc.h> #include <asm/microblaze_intc.h> #include <asm/asm.h> +#include <fdtdec.h> + +DECLARE_GLOBAL_DATA_PTR ;#undef DEBUG_INT
@@ -134,10 +137,26 @@ int interrupts_init(void) {int i; +#ifndef CONFIG_OF_CONTROL #if defined(CONFIG_SYS_INTC_0_ADDR ) && defined(CONFIG_SYS_INTC_0_NUM ) intc = (microblaze_intc_t *) (CONFIG_SYS_INTC_0_ADDR ); irq_no =CONFIG_SYS_INTC_0_NUM ;#endif +#else +int temp; +int offset =0 ; + + offset =fdt_node_offset_by_compatible (gd->fdt_blob, offset, +"xlnx,xps-intc-1.00.a" ); +if (offset >0 ) { + temp =fdtdec_get_addr (gd->fdt_blob, offset,"reg" ); +if (temp !=FDT_ADDR_T_NONE ) { + intc = (microblaze_intc_t *)temp; + irq_no =fdtdec_get_int (gd->fdt_blob, offset, +"xlnx,num-intr-inputs" ,0 ); + } + } +#endif if (irq_no) { vecs =calloc (1 ,sizeof (struct irq_action ) * irq_no);if (vecs ==NULL ) {
Signature · 1 line
1.7.0.4
PATCH 6/12 microblaze: intc: Add device-tree driver configuration
Hi Michal,
Quoted 25 lines · Michal Simek
Read configuration from DTB.
Signed-off-by Michal Simek <[email protected]>--- arch/microblaze/cpu/interrupts.c | 19 +++++++++++++++++++ 1 files changed, 19 insertions(+), 0 deletions(-)arch/microblaze/cpu/interrupts.c +3
-0@@ -29,6 +29,9 @@#include <malloc.h> #include <asm/microblaze_intc.h> #include <asm/asm.h> +#include <fdtdec.h> + +DECLARE_GLOBAL_DATA_PTR ;#undef DEBUG_INT@@ -134,10 +137,26 @@ int interrupts_init(void) {int i;
arch/microblaze/cpu/interrupts.c int interrupts_init(void) · line 148
Quoted 10 lines
arch/microblaze/cpu/interrupts.c +4
-0+#ifndef CONFIG_OF_CONTROL #if defined(CONFIG_SYS_INTC_0_ADDR ) && defined(CONFIG_SYS_INTC_0_NUM ) intc = (microblaze_intc_t *) (CONFIG_SYS_INTC_0_ADDR ); irq_no =CONFIG_SYS_INTC_0_NUM ;#endif +#else +int temp; +int offset =0 ;
I don't think you need the = 0.
Quoted 14 lines
arch/microblaze/cpu/interrupts.c +12
-0+ + offset =fdt_node_offset_by_compatible (gd->fdt_blob, offset, +"xlnx,xps-intc-1.00.a" ); +if (offset >0 ) { + temp =fdtdec_get_addr (gd->fdt_blob, offset,"reg" ); +if (temp !=FDT_ADDR_T_NONE ) { + intc = (microblaze_intc_t *)temp; + irq_no =fdtdec_get_int (gd->fdt_blob, offset, +"xlnx,num-intr-inputs" ,0 ); + } + } +#endif if (irq_no) { vecs =calloc (1 ,sizeof (struct irq_action ) * irq_no);
Quoted 2 lines
if (vecs == NULL) {I'm not completely clear about whether this should be doing a realloc() (copying the existing array and adding a new member) or not.
Quoted 4 lines
--
1.7.0.4
Regards,
Simon
Michal Simek
maintainerPATCH 6/12 microblaze: intc: Add device-tree driver configuration
Quoted 39 lines · Simon Glass
Hi Michal,
On Mon, Jul 9, 2012 at 2:20 AM, Michal Simek <monstr at monstr.eu <mailto:[email protected]>> wrote:
Read configuration from DTB. Signed-off-by: Michal Simek <monstr at monstr.eu <mailto:[email protected]>> --- arch/microblaze/cpu/interrupts.c | 19 +++++++++++++++++++ 1 files changed, 19 insertions(+), 0 deletions(-) diff --git a/arch/microblaze/cpu/interrupts.c b/arch/microblaze/cpu/interrupts.c index 79ee96a..98c9110 100644 --- a/arch/microblaze/cpu/interrupts.c +++ b/arch/microblaze/cpu/interrupts.c @@ -29,6 +29,9 @@ #include <malloc.h> #include <asm/microblaze_intc.h> #include <asm/asm.h> +#include <fdtdec.h> + +DECLARE_GLOBAL_DATA_PTR; #undef DEBUG_INT @@ -134,10 +137,26 @@ int interrupts_init(void) { int i; +#ifndef CONFIG_OF_CONTROL #if defined(CONFIG_SYS_INTC_0_ADDR) && defined(CONFIG_SYS_INTC_0_NUM) intc = (microblaze_intc_t *) (CONFIG_SYS_INTC_0_ADDR); irq_no = CONFIG_SYS_INTC_0_NUM; #endif +#else + int temp; + int offset = 0;
Quoted 1 line
I don't think you need the = 0.
Agree. Will remove it.
Quoted 18 lines
+
+ offset = fdt_node_offset_by_compatible(gd->fdt_blob, offset,
+ "xlnx,xps-intc-1.00.a");
+ if (offset > 0) {
+ temp =fdtdec_get_addr(gd->fdt_blob, offset, "reg");
+ if (temp !=FDT_ADDR_T_NONE) {
+ intc = (microblaze_intc_t*)temp;
+irq_no= fdtdec_get_int(gd->fdt_blob, offset,
+ "xlnx,num-intr-inputs", 0);
+ }
+ }
+#endif
if (irq_no) {
vecs =calloc(1, sizeof(struct irq_action) * irq_no); if (vecs == NULL) {
Quoted 1 line
I'm not completely clear about whether this should be doing a
realloc()(copying the existing array and adding a new member) or not.
I am not sure what you mean by that.
This is done after mem_alloc_init and microblaze u-boot does not any reallocation like other platforms. Is it what did you mean?
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
PATCH 6/12 microblaze: intc: Add device-tree driver configuration
Hi Michal,
Quoted 76 lines · Michal Simek
Quoted 45 lines · Simon Glass
Hi Michal,
On Mon, Jul 9, 2012 at 2:20 AM, Michal Simek <[email protected] <mailto:
monstr at monstr.eu>> wrote:Read configuration from DTB.
Signed-off-by Michal Simek <[email protected] <mailto:monstr at monstr.eu>>
--- arch/microblaze/cpu/**interrupts.c | 19 +++++++++++++++++++ 1 files changed, 19 insertions(+), 0 deletions(-) diff --git a/arch/microblaze/cpu/**interrupts.c b/arch/microblaze/cpu/**interrupts.c index 79ee96a..98c9110 100644 --- a/arch/microblaze/cpu/**interrupts.c +++ b/arch/microblaze/cpu/**interrupts.c @@ -29,6 +29,9 @@ #include <malloc.h> #include <asm/microblaze_intc.h> #include <asm/asm.h> +#include <fdtdec.h> + +DECLARE_GLOBAL_DATA_PTR; #undef DEBUG_INT @@ -134,10 +137,26 @@ int interrupts_init(void) { int i; +#ifndef CONFIG_OF_CONTROL #if defined(CONFIG_SYS_INTC_0_**ADDR) && defined(CONFIG_SYS_INTC_0_NUM) intc = (microblaze_intc_t *) (CONFIG_SYS_INTC_0_ADDR); irq_no = CONFIG_SYS_INTC_0_NUM; #endif +#else + int temp; + int offset = 0;Quoted 2 lines
I don't think you need the = 0.
Agree. Will remove it.
Quoted 18 lines
+
+ offset = fdt_node_offset_by_compatible(**gd->fdt_blob,
offset,
+ "xlnx,xps-intc-1.00.a");
+ if (offset > 0) {
+ temp =fdtdec_get_addr(gd->fdt_blob, offset, "reg");
+ if (temp !=FDT_ADDR_T_NONE) {
+ intc = (microblaze_intc_t*)temp;
+irq_no= fdtdec_get_int(gd->fdt_blob, offset,
+ "xlnx,num-intr-inputs", 0);
+ }
+ }
+#endif
if (irq_no) {
vecs =calloc(1, sizeof(struct irq_action) * irq_no); if (vecs == NULL) {Quoted 3 lines
I'm not completely clear about whether this should be doing a
realloc()(copying the existing array and adding a new member) or not.
Quoted 6 lines
I am not sure what you mean by that.
This is done aftermem_alloc_initand microblaze u-boot does not any reallocation like other platforms.
Is it what did you mean?No I just meant that if you had several calls to this it would need to add
to the existing list. But I see now that this is just a single item being alloced, so it is fine.
Quoted 11 lines
Thanks,
Michal--
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
Regards,
Simon
Michal Simek
maintainerPATCH 6/12 microblaze: intc: Add device-tree driver configuration
Quoted 78 lines · Simon Glass
Hi Michal,
On Tue, Jul 10, 2012 at 11:07 AM, Michal Simek <monstr at monstr.eu <mailto:[email protected]>> wrote:
On 07/09/2012 11:26 PM, Simon Glass wrote: Hi Michal, On Mon, Jul 9, 2012 at 2:20 AM, Michal Simek <monstr at monstr.eu <mailto:[email protected]> <mailto:monstr at monstr.eu <mailto:[email protected]>>> wrote: Read configuration from DTB. Signed-off-by: Michal Simek <monstr at monstr.eu <mailto:[email protected]> <mailto:monstr at monstr.eu <mailto:[email protected]>>> --- arch/microblaze/cpu/__interrupts.c | 19 +++++++++++++++++++ 1 files changed, 19 insertions(+), 0 deletions(-) diff --git a/arch/microblaze/cpu/__interrupts.c b/arch/microblaze/cpu/__interrupts.c index 79ee96a..98c9110 100644 --- a/arch/microblaze/cpu/__interrupts.c +++ b/arch/microblaze/cpu/__interrupts.c @@ -29,6 +29,9 @@ #include <malloc.h> #include <asm/microblaze_intc.h> #include <asm/asm.h> +#include <fdtdec.h> + +DECLARE_GLOBAL_DATA_PTR; #undef DEBUG_INT @@ -134,10 +137,26 @@ int interrupts_init(void) { int i; +#ifndef CONFIG_OF_CONTROL #if defined(CONFIG_SYS_INTC_0___ADDR) && defined(CONFIG_SYS_INTC_0_NUM) intc = (microblaze_intc_t *) (CONFIG_SYS_INTC_0_ADDR); irq_no = CONFIG_SYS_INTC_0_NUM; #endif +#else + int temp; + int offset = 0; I don't think you need the = 0. Agree. Will remove it. + + offset = fdt_node_offset_by_compatible(__gd->fdt_blob, offset, + "xlnx,xps-intc-1.00.a"); + if (offset > 0) { + temp = fdtdec_get_addr(gd->fdt_blob, offset, "reg"); + if (temp != FDT_ADDR_T_NONE) { + intc = (microblaze_intc_t *)temp; + irq_no = fdtdec_get_int(gd->fdt_blob, offset, + "xlnx,num-intr-inputs", 0); + } + } +#endif if (irq_no) { vecs = calloc(1, sizeof(struct irq_action) * irq_no); if (vecs == NULL) { I'm not completely clear about whether this should be doing a realloc() (copying the existing array and adding a new member) or not. I am not sure what you mean by that. This is done after mem_alloc_init and microblaze u-boot does not any reallocation like other platforms. Is it what did you mean?
Quoted 1 line
No I just meant that if you had several calls to this it would need to add to the existing list. But I see now that this is just a single item being alloced, so it is fine.
ok.
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
Michal Simek
maintainerPATCH 7/12 microblaze: Move __udelay implementation
In reply to Michal SimekMove __udelay to the timer code because of unification. And clean coding style because of checkpatch.pl.
--- arch/microblaze/cpu/timer.c | 19 +++++++++++++++++++ arch/microblaze/lib/Makefile | 1 - arch/microblaze/lib/time.c | 42 ------------------------------------------ 3 files changed, 19 insertions(+), 43 deletions(-)
arch/microblaze/cpu/timer.c +19 -0
@@ -41,6 +41,25 @@ ulong get_timer (ulong base)#endif #ifdef CONFIG_SYS_TIMER_0 +void __udelay (unsigned long usec) +{ +int i; + + i =get_timer (0 ); +while ((get_timer (0 ) - i) < (usec /1000 )) + ; +} +#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)
arch/microblaze/lib/Makefile +0 -1
@@ -29,7 +29,6 @@ SOBJS-y += COBJS-y += board.o COBJS-y += bootm.o -COBJS-y += time.o SRCS := $(SOBJS-y:.o=.S) $(COBJS-y:.o=.c) OBJS := $(addprefix $(obj),$(SOBJS-y) $(COBJS-y))
arch/microblaze/lib/time.c +0 -42
42 lines not on this page · raw message
Signature · 1 line
1.7.0.4
PATCH 7/12 microblaze: Move __udelay implementation
Quoted 5 lines · Michal Simek
Move
__udelayto the timer code because of unification. And clean coding style because of checkpatch.pl.Signed-off-by Michal Simek <[email protected]>
Quoted 101 lines
--- arch/microblaze/cpu/timer.c | 19 +++++++++++++++++++ arch/microblaze/lib/Makefile | 1 - arch/microblaze/lib/time.c | 42 ------------------------------------------ 3 files changed, 19 insertions(+), 43 deletions(-)arch/microblaze/cpu/timer.c +19
-0@@ -41,6 +41,25 @@ ulong get_timer (ulong base)#endif #ifdef CONFIG_SYS_TIMER_0 +void __udelay (unsigned long usec) +{ +int i; + + i =get_timer (0 ); +while ((get_timer (0 ) - i) < (usec /1000 )) + ; +} +#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)arch/microblaze/lib/Makefile +0
-1@@ -29,7 +29,6 @@ SOBJS-y += COBJS-y += board.o COBJS-y += bootm.o -COBJS-y += time.o SRCS := $(SOBJS-y:.o=.S) $(COBJS-y:.o=.c) OBJS := $(addprefix $(obj),$(SOBJS-y) $(COBJS-y))arch/microblaze/lib/time.c +0
-43@@ -1,42 +0,0 @@ -/* -* (C) Copyright 2007 Michal Simek -* (C) Copyright 2004 Atmark Techno, Inc. -* -* Michal SIMEK <[email protected]> -* Yasushi SHOJI <[email protected]> -* -* 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> - -#ifdef CONFIG_SYS_TIMER_0 -void __udelay (unsigned long usec) -{ -int i; - i =get_timer (0 ); -while ((get_timer (0 ) - i) < (usec /1000 )) ; -} -#else -void __udelay (unsigned long usec) -{ -unsigned int i; -for (i =0 ; i < (usec *CONFIG_XILINX_CLOCK_FREQ /10000000 ); i++); -} -#endif --1.7.0.4
PATCH 7/12 microblaze: Move __udelay implementation
Quoted 1 line · Simon Glass
Acked-by Simon Glass <sjg at chromium.org <mailto:[email protected]>>
Applied.
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
Michal Simek
maintainerPATCH 8/12 microblaze: timer: Prepare for device-tree initialization
In reply to Michal Simekmicroblaze: Fix CONFIG_SYS_HZ usage in board config
Do not use hardcoded value. Use CONFIG_SYS_HZ instead. Separate static configuration to single block.
--- 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
@@ -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); +u32 irq =0 ; +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 && irq && preload) { + 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
@@ -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
@@ -40,9 +40,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
@@ -72,9 +69,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
@@ -102,19 +102,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
PATCH 8/12 microblaze: timer: Prepare for device-tree initialization
Hi Michal,
Am Montag, den 09.07.2012, 11:20 +0200 schrieb Michal Simek:
Quoted 75 lines
microblaze: Fix
CONFIG_SYS_HZusage in board configDo not use hardcoded value. Use
CONFIG_SYS_HZinstead. Separate static configuration to single block.Signed-off-by Michal Simek <[email protected]>--- 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 +14
-26@@ -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 ;
arch/microblaze/cpu/timer.c void timer_isr (void *arg) · line 61
Quoted 10 lines
arch/microblaze/cpu/timer.c +1
-6@@ -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); +u32 irq =0 ;
should be int irq = -1; (see below)
arch/microblaze/cpu/timer.c void timer_isr (void *arg) · line 71
Quoted 10 lines
arch/microblaze/cpu/timer.c +10
-0+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 && irq && preload) {
it should be:
if (tmr && irq >= 0 && preload) {
irq valid --> irq >= 0
irq invalid --> irq == -1
br,
Stephan
Quoted 78 lines
arch/microblaze/cpu/timer.c +11
-1+ 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@@ -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@@ -40,9 +40,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 @@ -72,9 +69,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, #endifinclude/configs/microblaze-generic.h +2
-10@@ -102,19 +102,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 */
Michal Simek
maintainerPATCH 8/12 microblaze: timer: Prepare for device-tree initialization
Quoted 104 lines · Stephan Linz
Hi Michal,
Am Montag, den 09.07.2012, 11:20 +0200 schrieb Michal Simek:
Quoted 75 lines
microblaze: Fix
CONFIG_SYS_HZusage in board configDo not use hardcoded value. Use
CONFIG_SYS_HZinstead. Separate static configuration to single block.Signed-off-by Michal Simek<[email protected]>--- 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 +14
-26@@ -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 ;arch/microblaze/cpu/timer.c void timer_isr (void *arg) · line 61
Quoted 10 lines
arch/microblaze/cpu/timer.c +1
-6@@ -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); +u32 irq =0 ;should be int irq = -1; (see below)
arch/microblaze/cpu/timer.c void timer_isr (void *arg)
Quoted 10 lines
arch/microblaze/cpu/timer.c +10
-0+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&& irq&& preload) {it should be:
Quoted 4 lines
if (tmr&& irq>= 0&& preload) {
irq valid --> irq>= 0
irq invalid --> irq == -1
Correct - will be in the v2.
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
PATCH 8/12 microblaze: timer: Prepare for device-tree initialization
In reply to Michal SimekAm Montag, den 09.07.2012, 11:20 +0200 schrieb Michal Simek:
Quoted 41 lines
microblaze: Fix
CONFIG_SYS_HZusage in board configDo not use hardcoded value. Use
CONFIG_SYS_HZinstead. Separate static configuration to single block.Signed-off-by Michal Simek <[email protected]>--- 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 +4
-9@@ -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) {
arch/microblaze/cpu/timer.c line 46
Quoted 10 lines
arch/microblaze/cpu/timer.c +5
-4-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 )) + ;
Hi Michal,
arch/microblaze/cpu/timer.c line 49
Quoted 3 lines
arch/microblaze/cpu/timer.c +3
-0+ }else { +for (i =0 ; i < (usec *XILINX_CLOCK_FREQ /10000000 ); i++) + ;
this part should be enclosed by #ifdef XILINX_CLOCK_FREQ
br,
Stephan Linz
Quoted 119 lines
arch/microblaze/cpu/timer.c +24
-20+ } } -#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); +u32 irq =0 ; +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 && irq && preload) { + 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@@ -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@@ -40,9 +40,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 @@ -72,9 +69,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, #endifinclude/configs/microblaze-generic.h +2
-10@@ -102,19 +102,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 · 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
Michal Simek
maintainerPATCH 8/12 microblaze: timer: Prepare for device-tree initialization
Quoted 55 lines · Stephan Linz
Am Montag, den 09.07.2012, 11:20 +0200 schrieb Michal Simek:
Quoted 41 lines
microblaze: Fix
CONFIG_SYS_HZusage in board configDo not use hardcoded value. Use
CONFIG_SYS_HZinstead. Separate static configuration to single block.Signed-off-by Michal Simek<[email protected]>--- 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 +4
-9@@ -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) {arch/microblaze/cpu/timer.c line 46
Quoted 10 lines
arch/microblaze/cpu/timer.c +5
-4-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 )) + ;Hi Michal,
Quoted 5 lines
arch/microblaze/cpu/timer.c line 49
Quoted 3 lines
arch/microblaze/cpu/timer.c +3
-0+ }else { +for (i =0 ; i< (usec *XILINX_CLOCK_FREQ /10000000 ); i++) + ;this part should be enclosed by #ifdef
XILINX_CLOCK_FREQ
It was intentional because XILINX_CLOCK_FREQ must be define. Maybe it could be handle by
#ifndef XILINX_CLOCK_FREQ
# error Please define XILINX_CLOCK_FREQ #endif
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
PATCH 8/12 microblaze: timer: Prepare for device-tree initialization
Am Dienstag, den 10.07.2012, 10:16 +0200 schrieb Michal Simek:
Quoted 56 lines · Stephan Linz
Quoted 55 lines
Am Montag, den 09.07.2012, 11:20 +0200 schrieb Michal Simek:
Quoted 41 lines
microblaze: Fix
CONFIG_SYS_HZusage in board configDo not use hardcoded value. Use
CONFIG_SYS_HZinstead. Separate static configuration to single block.Signed-off-by Michal Simek<[email protected]>--- 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 +4
-9@@ -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) {arch/microblaze/cpu/timer.c line 46
Quoted 10 lines
arch/microblaze/cpu/timer.c +5
-4-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 )) + ;Hi Michal,
Quoted 7 lines
Quoted 5 lines
arch/microblaze/cpu/timer.c line 49
Quoted 3 lines
arch/microblaze/cpu/timer.c +3
-0+ }else { +for (i =0 ; i< (usec *XILINX_CLOCK_FREQ /10000000 ); i++) + ;this part should be enclosed by #ifdef
XILINX_CLOCK_FREQIt was intentional because
XILINX_CLOCK_FREQmust be define.
Hm, it's a catch-22 situation in between compilation and run time.
With a prober fdt setup you will implicitly fetch this value from dts (as tmr->loadreg) and you will never reach this code. In the case of a wrong dts content, for example a missing "clock-frequency" entry, this code snipped could be a fall back solution. But what is wrong and what is right?
I think you should make a hard cut here and make a strict distinguish between the old (undef CONFIG_OF_CONTROL) and the new timer setup. Your current code base leads to a hardware description with overdetermined definition of timer clock frequency:
first one here: board/xilinx/microblaze-generic/xparameters.h second one here: board/xilinx/microblaze-generic/dts/microblaze.dts
Quoted 5 lines
Maybe it could be handle by
#ifndef
XILINX_CLOCK_FREQ# error Please define XILINX_CLOCK_FREQ #endif
better would be:
#if !defined(CONFIG_OF_CONTROL) && !defined(XILINX_CLOCK_FREQ)
# error Please define XILINX_CLOCK_FREQ #endif
br,
Stephan
Michal Simek
maintainerPATCH 8/12 microblaze: timer: Prepare for device-tree initialization
Quoted 65 lines · Stephan Linz
Am Dienstag, den 10.07.2012, 10:16 +0200 schrieb Michal Simek:
Quoted 56 lines · Stephan Linz
Quoted 55 lines
Am Montag, den 09.07.2012, 11:20 +0200 schrieb Michal Simek:
Quoted 41 lines
microblaze: Fix
CONFIG_SYS_HZusage in board configDo not use hardcoded value. Use
CONFIG_SYS_HZinstead. Separate static configuration to single block.Signed-off-by Michal Simek<[email protected]>--- 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 +4
-9@@ -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) {arch/microblaze/cpu/timer.c line 46
Quoted 10 lines
arch/microblaze/cpu/timer.c +5
-4-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 )) + ;Hi Michal,
Quoted 7 lines
Quoted 5 lines
arch/microblaze/cpu/timer.c line 49
Quoted 3 lines
arch/microblaze/cpu/timer.c +3
-0+ }else { +for (i =0 ; i< (usec *XILINX_CLOCK_FREQ /10000000 ); i++) + ;this part should be enclosed by #ifdef
XILINX_CLOCK_FREQIt was intentional because
XILINX_CLOCK_FREQmust be define.
Quoted 7 lines
Hm, it's a catch-22 situation in between compilation and run time.
With a prober fdt setup you will implicitly fetch this value from dts (as
tmr->loadreg) and you will never reach this code. In the case of a wrong dts content, for example a missing "clock-frequency" entry, this code snipped could be a fall back solution. But what is wrong and what is right?
Correct - u-boot is able to work without timer and it is fall back solution. My point was that XILINX_CLOCK_FREQ will be setup to any default value just for sure.
Quoted 5 lines
I think you should make a hard cut here and make a strict distinguish between the old (undef
CONFIG_OF_CONTROL) and the new timer setup. Your current code base leads to a hardware description with overdetermined definition of timer clock frequency:
Not going to do hard cut. We can do it in future that we will use only DTS initialization but it is long way to go.
Quoted 2 lines
first one here:
board/xilinx/microblaze-generic/xparameters.h
It should be define here for non FDT platform
and my preference is completely remove xparameters for FDT platform.
Quoted 1 line
second one here:
board/xilinx/microblaze-generic/dts/microblaze.dts
For FDT platform with timer connected to intc.
Quoted 8 lines
Quoted 7 lines
Maybe it could be handle by
#ifndef
XILINX_CLOCK_FREQ# error Please define XILINX_CLOCK_FREQ #endif
Quoted 5 lines
better would be:
#if !defined(CONFIG_OF_CONTROL)&& !defined(XILINX_CLOCK_FREQ)
# error Please define XILINX_CLOCK_FREQ #endif
Still make sense to define default value for CONFIG_OF_CONTROL for that fall back solution which should be there.
There is also one more case for system which contains several timers where some of them have IRQ connected and some not.
This parsing just read the first timer with selected compatible property. But this is different topic.
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
Michal Simek
maintainerPATCH 9/12 microblaze: timer: Add device-tree driver configuration
In reply to Michal SimekRead configuration from DTB.
--- arch/microblaze/cpu/timer.c | 25 +++++++++++++++++++++++++ 1 files changed, 25 insertions(+), 0 deletions(-)
arch/microblaze/cpu/timer.c +25 -0
@@ -25,6 +25,9 @@#include <common.h> #include <asm/microblaze_timer.h> #include <asm/microblaze_intc.h> +#include <fdtdec.h> + +DECLARE_GLOBAL_DATA_PTR ;volatile int timestamp =0 ;microblaze_timer_t *tmr;
@@ -62,11 +65,33 @@ int timer_init (void)u32 preload =0 ;u32 ret =0 ; +#ifndef CONFIG_OF_CONTROL #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 +#else +int temp; +int offset =0 ; + + offset =fdt_node_offset_by_compatible (gd->fdt_blob, offset, +"xlnx,xps-timer-1.00.a" ); +if (offset >0 ) { + temp =fdtdec_get_addr (gd->fdt_blob, offset,"reg" ); +if (temp !=FDT_ADDR_T_NONE ) { + tmr = (microblaze_timer_t *)temp; + irq =fdtdec_get_int (gd->fdt_blob, offset, +"interrupts" ,-1 ); +if (irq ==-1 ) +panic ("Connect IRQ to system timer\n" ); +/* Set default clock frequency */ + temp =fdtdec_get_int (gd->fdt_blob, offset, +"clock-frequency" ,0 ); + preload = temp /CONFIG_SYS_HZ ; + } + } +#endif if (tmr && irq && preload) { tmr->loadreg = preload;
Signature · 1 line
1.7.0.4
PATCH 9/12 microblaze: timer: Add device-tree driver configuration
Hi Michal,
Am Montag, den 09.07.2012, 11:20 +0200 schrieb Michal Simek:
Quoted 34 lines
Read configuration from DTB.
Signed-off-by Michal Simek <[email protected]>--- arch/microblaze/cpu/timer.c | 25 +++++++++++++++++++++++++ 1 files changed, 25 insertions(+), 0 deletions(-)arch/microblaze/cpu/timer.c +7
-0@@ -25,6 +25,9 @@#include <common.h> #include <asm/microblaze_timer.h> #include <asm/microblaze_intc.h> +#include <fdtdec.h> + +DECLARE_GLOBAL_DATA_PTR ;volatile int timestamp =0 ;microblaze_timer_t *tmr;@@ -62,11 +65,33 @@ int timer_init (void)u32 preload =0 ;u32 ret =0 ; +#ifndef CONFIG_OF_CONTROL #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 +#else +int temp; +int offset =0 ;
arch/microblaze/cpu/timer.c int timer_init (void) · line 86
Quoted 10 lines
arch/microblaze/cpu/timer.c +10
-0+ + offset =fdt_node_offset_by_compatible (gd->fdt_blob, offset, +"xlnx,xps-timer-1.00.a" ); +if (offset >0 ) { + temp =fdtdec_get_addr (gd->fdt_blob, offset,"reg" ); +if (temp !=FDT_ADDR_T_NONE ) { + tmr = (microblaze_timer_t *)temp; + irq =fdtdec_get_int (gd->fdt_blob, offset, +"interrupts" ,-1 ); +if (irq ==-1 )
irq is u32 (unsigned) -- my be a problem. But yes, I'm missing a compilation warning here ...
br,
Stephan
Quoted 11 lines
arch/microblaze/cpu/timer.c +8
-0+panic ("Connect IRQ to system timer\n" ); +/* Set default clock frequency */ + temp =fdtdec_get_int (gd->fdt_blob, offset, +"clock-frequency" ,0 ); + preload = temp / CONFIG_SYS_HZ; + } + } +#endif if (tmr && irq && preload) { tmr->loadreg = preload;
PATCH 9/12 microblaze: timer: Add device-tree driver configuration
In reply to Michal SimekHi Michal,
Quoted 22 lines · Michal Simek
Read configuration from DTB.
Signed-off-by Michal Simek <[email protected]>--- arch/microblaze/cpu/timer.c | 25 +++++++++++++++++++++++++ 1 files changed, 25 insertions(+), 0 deletions(-)arch/microblaze/cpu/timer.c +3
-0@@ -25,6 +25,9 @@#include <common.h> #include <asm/microblaze_timer.h> #include <asm/microblaze_intc.h> +#include <fdtdec.h> + +DECLARE_GLOBAL_DATA_PTR ;volatile int timestamp =0 ;microblaze_timer_t *tmr;
arch/microblaze/cpu/timer.c int timer_init (void) · line 69
Quoted 5 lines
arch/microblaze/cpu/timer.c +1
-0@@ -62,11 +65,33 @@ int timer_init (void)u32 preload =0 ;u32 ret =0 ; +#ifndef CONFIG_OF_CONTROL
Maybe make this #ifdef and put the fdt code first?
arch/microblaze/cpu/timer.c int timer_init (void) · line 95
Quoted 9 lines
arch/microblaze/cpu/timer.c +3
-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 +#else +int temp; +int offset =0 ;
Can remove =0 I think.
arch/microblaze/cpu/timer.c int timer_init (void) · line 95
Quoted 12 lines
arch/microblaze/cpu/timer.c +11
-0+ + offset =fdt_node_offset_by_compatible (gd->fdt_blob, offset, +"xlnx,xps-timer-1.00.a" ); +if (offset >0 ) { + temp =fdtdec_get_addr (gd->fdt_blob, offset,"reg" ); +if (temp !=FDT_ADDR_T_NONE ) { + tmr = (microblaze_timer_t *)temp; + irq =fdtdec_get_int (gd->fdt_blob, offset, +"interrupts" ,-1 ); +if (irq ==-1 ) +panic ("Connect IRQ to system timer\n" );
That's a little cryptic - maybe should mention fdt?
Quoted 8 lines
arch/microblaze/cpu/timer.c +7
-0+/* Set default clock frequency */ + temp =fdtdec_get_int (gd->fdt_blob, offset, +"clock-frequency" ,0 ); + preload = temp / CONFIG_SYS_HZ; + } + } +#endif
Quoted 6 lines
if (tmr && irq && preload) { tmr->loadreg = preload;--
1.7.0.4
Regards,
Simon
Michal Simek
maintainerPATCH 9/12 microblaze: timer: Add device-tree driver configuration
Quoted 32 lines · Simon Glass
Hi Michal,
On Mon, Jul 9, 2012 at 2:20 AM, Michal Simek <monstr at monstr.eu <mailto:[email protected]>> wrote:
Read configuration from DTB. Signed-off-by: Michal Simek <monstr at monstr.eu <mailto:[email protected]>> --- arch/microblaze/cpu/timer.c | 25 +++++++++++++++++++++++++ 1 files changed, 25 insertions(+), 0 deletions(-) diff --git a/arch/microblaze/cpu/timer.c b/arch/microblaze/cpu/timer.c index dfaaaf5..91ca42b 100644 --- a/arch/microblaze/cpu/timer.c +++ b/arch/microblaze/cpu/timer.c @@ -25,6 +25,9 @@ #include <common.h> #include <asm/microblaze_timer.h> #include <asm/microblaze_intc.h> +#include <fdtdec.h> + +DECLARE_GLOBAL_DATA_PTR; volatile int timestamp = 0; microblaze_timer_t *tmr; @@ -62,11 +65,33 @@ int timer_init (void) u32 preload = 0; u32 ret = 0; +#ifndef CONFIG_OF_CONTROL
Quoted 1 line
Maybe make this #ifdef and put the fdt code first?
I see only one reason to do it (and that's why I have done it in intc code too) which is debug purpose. Because you can simple comment ifdefs and hardcoded values below fdt code which you can debug.
Quoted 11 lines
#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
+#else
+ int temp;
+ int offset = 0;Quoted 1 line
Can remove =0 I think.
done.
Quoted 14 lines
+
+ offset = fdt_node_offset_by_compatible(gd->fdt_blob, offset,
+ "xlnx,xps-timer-1.00.a");
+ if (offset > 0) {
+ temp =fdtdec_get_addr(gd->fdt_blob, offset, "reg");
+ if (temp !=FDT_ADDR_T_NONE) {
+ tmr = (microblaze_timer_t*)temp;
+ irq = fdtdec_get_int(gd->fdt_blob, offset,
+ "interrupts", -1);
+ if (irq == -1)
+panic("Connect IRQ to system timer\n");
Quoted 1 line
That's a little cryptic - maybe should mention fdt?
What about this?panic("Timer IRQ is not found in DTS/DTB\n");
I don't want to write there novels but this is also checked in different tool which generates DTS that's why simple panic should be eliminated for most cases.
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
Michal Simek
maintainerPATCH 9/12 microblaze: timer: Add device-tree driver configuration
In reply to Simon GlassQuoted 44 lines · Simon Glass
Hi Michal,
On Mon, Jul 9, 2012 at 2:20 AM, Michal Simek <monstr at monstr.eu <mailto:[email protected]>> wrote:
Read configuration from DTB. Signed-off-by: Michal Simek <monstr at monstr.eu <mailto:[email protected]>> --- arch/microblaze/cpu/timer.c | 25 +++++++++++++++++++++++++ 1 files changed, 25 insertions(+), 0 deletions(-) diff --git a/arch/microblaze/cpu/timer.c b/arch/microblaze/cpu/timer.c index dfaaaf5..91ca42b 100644 --- a/arch/microblaze/cpu/timer.c +++ b/arch/microblaze/cpu/timer.c @@ -25,6 +25,9 @@ #include <common.h> #include <asm/microblaze_timer.h> #include <asm/microblaze_intc.h> +#include <fdtdec.h> + +DECLARE_GLOBAL_DATA_PTR; volatile int timestamp = 0; microblaze_timer_t *tmr; @@ -62,11 +65,33 @@ int timer_init (void) u32 preload = 0; u32 ret = 0; +#ifndef CONFIG_OF_CONTROLMaybe make this #ifdef and put the fdt code first?
#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 +#else + int temp; + int offset = 0;
Quoted 5 lines
Can remove =0 I think.
+
+ offset = fdt_node_offset_by_compatible(gd->fdt_blob, offset,
+ "xlnx,xps-timer-1.00.a");
ok. It must be initialized because offset is passed as argument to the next function. For interrupt code is fine to add there zero but for timer I would keep there offset because system can contain more timers and we can change it to while loop soon.
(NOTE: We have had discussion to use aliases for system timer but we haven't finished it.
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
PATCH 9/12 microblaze: timer: Add device-tree driver configuration
Hi Mich
Quoted 60 lines · Michal Simek
Quoted 49 lines · Simon Glass
Hi Michal,
On Mon, Jul 9, 2012 at 2:20 AM, Michal Simek <[email protected] <mailto:
monstr at monstr.eu>> wrote:Read configuration from DTB.
Signed-off-by Michal Simek <[email protected] <mailto:monstr at monstr.eu>>
--- arch/microblaze/cpu/timer.c | 25 +++++++++++++++++++++++++ 1 files changed, 25 insertions(+), 0 deletions(-) diff --git a/arch/microblaze/cpu/timer.c b/arch/microblaze/cpu/timer.c index dfaaaf5..91ca42b 100644 --- a/arch/microblaze/cpu/timer.c +++ b/arch/microblaze/cpu/timer.c @@ -25,6 +25,9 @@ #include <common.h> #include <asm/microblaze_timer.h> #include <asm/microblaze_intc.h> +#include <fdtdec.h> + +DECLARE_GLOBAL_DATA_PTR; volatile int timestamp = 0; microblaze_timer_t *tmr; @@ -62,11 +65,33 @@ int timer_init (void) u32 preload = 0; u32 ret = 0; +#ifndef CONFIG_OF_CONTROLMaybe make this #ifdef and put the fdt code first?
#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 +#else + int temp; + int offset = 0;Quoted 7 lines
Can remove =0 I think.
+
+ offset = fdt_node_offset_by_compatible(**gd->fdt_blob,
offset,
+ "xlnx,xps-timer-1.00.a");
Quoted 8 lines
ok. It must be initialized because offset is passed as argument to the next function.
For interrupt code is fine to add there zero but for timer I would keep there offset
because system can contain more timers and we can change it to while loop soon.Yes, well maybe then:
+ offset = fdt_node_offset_by_compatible(**gd->fdt_blob, 0,
Quoted 9 lines
(NOTE: We have had discussion to use aliases for system timer but we haven't finished it.
Thanks,
Michal
Quoted 7 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
Regards,
Simon
Michal Simek
maintainerPATCH 9/12 microblaze: timer: Add device-tree driver configuration
Quoted 64 lines · Simon Glass
Hi Mich
On Tue, Jul 10, 2012 at 11:34 AM, Michal Simek <monstr at monstr.eu <mailto:[email protected]>> wrote:
On 07/09/2012 11:32 PM, Simon Glass wrote: Hi Michal, On Mon, Jul 9, 2012 at 2:20 AM, Michal Simek <monstr at monstr.eu <mailto:[email protected]> <mailto:monstr at monstr.eu <mailto:[email protected]>>> wrote: Read configuration from DTB. Signed-off-by: Michal Simek <monstr at monstr.eu <mailto:[email protected]> <mailto:monstr at monstr.eu <mailto:[email protected]>>> --- arch/microblaze/cpu/timer.c | 25 +++++++++++++++++++++++++ 1 files changed, 25 insertions(+), 0 deletions(-) diff --git a/arch/microblaze/cpu/timer.c b/arch/microblaze/cpu/timer.c index dfaaaf5..91ca42b 100644 --- a/arch/microblaze/cpu/timer.c +++ b/arch/microblaze/cpu/timer.c @@ -25,6 +25,9 @@ #include <common.h> #include <asm/microblaze_timer.h> #include <asm/microblaze_intc.h> +#include <fdtdec.h> + +DECLARE_GLOBAL_DATA_PTR; volatile int timestamp = 0; microblaze_timer_t *tmr; @@ -62,11 +65,33 @@ int timer_init (void) u32 preload = 0; u32 ret = 0; +#ifndef CONFIG_OF_CONTROL Maybe make this #ifdef and put the fdt code first? #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 +#else + int temp; + int offset = 0; Can remove =0 I think. + + offset = fdt_node_offset_by_compatible(__gd->fdt_blob, offset, + "xlnx,xps-timer-1.00.a"); ok. It must be initialized because offset is passed as argument to the next function. For interrupt code is fine to add there zero but for timer I would keep there offset because system can contain more timers and we can change it to while loop soon.
Quoted 3 lines
Yes, well maybe then:
+ offset = fdt_node_offset_by_compatible(__gd->fdt_blob, 0,
Both options just works. I can look at asm dump to see which solution is faster and better to use.
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
PATCH 9/12 microblaze: timer: Add device-tree driver configuration
Hi Michal,
Quoted 82 lines · Michal Simek
Quoted 80 lines · Simon Glass
Hi Mich
On Tue, Jul 10, 2012 at 11:34 AM, Michal Simek <[email protected] <mailto:
monstr at monstr.eu>> wrote:On 07/09/2012 11:32 PM, Simon Glass wrote:
Hi Michal,
On Mon, Jul 9, 2012 at 2:20 AM, Michal Simek <[email protected]<mailto:
monstr at monstr.eu> <mailto:monstr at monstr.eu <mailto:[email protected]>>> wrote:Read configuration from DTB.
Signed-off-by Michal Simek <[email protected] <mailto:monstr at monstr.eu> <mailto:monstr at monstr.eu <mailto:[email protected]>>>
---
arch/microblaze/cpu/timer.c| 25
+++++++++++++++++++++++++1 files changed, 25 insertions(+), 0 deletions(-)diff --git a/arch/microblaze/cpu/timer.c b/arch/microblaze/cpu/timer.c index dfaaaf5..91ca42b 100644 --- a/arch/microblaze/cpu/timer.c +++ b/arch/microblaze/cpu/timer.c @@ -25,6 +25,9 @@ #include <common.h> #include <asm/microblaze_timer.h> #include <asm/microblaze_intc.h> +#include <fdtdec.h> + +DECLARE_GLOBAL_DATA_PTR; volatile int timestamp = 0; microblaze_timer_t *tmr; @@ -62,11 +65,33 @@ int timer_init (void) u32 preload = 0; u32 ret = 0; +#ifndef CONFIG_OF_CONTROL Maybe make this #ifdef and put the fdt code first? #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
+#else
+ int temp;
+ int offset = 0;Can remove =0 I think.
+
+ offset = fdt_node_offset_by_compatible(**__gd->fdt_blob,
offset,+ "xlnx,xps-timer-1.00.a");
ok. It must be initialized because offset is passed as argument to
the next function.
For interrupt code is fine to add there zero but for timer I would
keep there offset
because system can contain more timers and we can change it to while
loop soon.
Quoted 8 lines
Quoted 4 lines
Yes, well maybe then:
+ offset = fdt_node_offset_by_compatible(**__gd->fdt_blob, 0,
Both options just works. I can look at asm dump to see which solution is faster
and better to use.
I doubt there will be any difference there, but OK.
Quoted 14 lines
Thanks,
Michal--
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
Michal Simek
maintainerPATCH 10/12 microblaze: Call serial multi initialization
In reply to Michal Simek--- arch/microblaze/lib/board.c | 5 +++++ 1 files changed, 5 insertions(+), 0 deletions(-)
arch/microblaze/lib/board.c +5 -0
@@ -30,6 +30,7 @@#include <version.h> #include <watchdog.h> #include <stdio_dev.h> +#include <serial.h> #include <net.h> #include <asm/processor.h> #include <asm/microblaze_intc.h>
@@ -118,6 +119,10 @@ void board_init (void)*/ mem_malloc_init (CONFIG_SYS_MALLOC_BASE ,CONFIG_SYS_MALLOC_LEN ); +#ifdef CONFIG_SERIAL_MULTI +serial_initialize (); +#endif +for (init_fnc_ptr = init_sequence; *init_fnc_ptr; ++init_fnc_ptr) {WATCHDOG_RESET ();if ((*init_fnc_ptr) () !=0 ) {
Signature · 1 line
1.7.0.4
PATCH 10/12 microblaze: Call serial multi initialization
Quoted 2 lines · Michal Simek
Signed-off-by Michal Simek <[email protected]>
Quoted 31 lines
--- arch/microblaze/lib/board.c | 5 +++++ 1 files changed, 5 insertions(+), 0 deletions(-)arch/microblaze/lib/board.c +5
-1@@ -30,6 +30,7 @@#include <version.h> #include <watchdog.h> #include <stdio_dev.h> +#include <serial.h> #include <net.h> #include <asm/processor.h> #include <asm/microblaze_intc.h> @@ -118,6 +119,10 @@ void board_init (void)*/ mem_malloc_init (CONFIG_SYS_MALLOC_BASE ,CONFIG_SYS_MALLOC_LEN ); +#ifdef CONFIG_SERIAL_MULTI +serial_initialize (); +#endif +for (init_fnc_ptr = init_sequence; *init_fnc_ptr; ++init_fnc_ptr) {WATCHDOG_RESET ();if ((*init_fnc_ptr) () !=0 ) { --1.7.0.4
PATCH 10/12 microblaze: Call serial multi initialization
Quoted 1 line · Simon Glass
Acked-by Simon Glass <sjg at chromium.org <mailto:[email protected]>>
Applied.
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
Michal Simek
maintainerPATCH 11/12 microblaze: Clean microblaze initialization
In reply to Michal SimekMove 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.
--- arch/microblaze/cpu/start.S | 2 +- arch/microblaze/lib/board.c | 17 +++-------------- .../xilinx/microblaze-generic/microblaze-generic.c | 10 ++++++++++ 3 files changed, 14 insertions(+), 15 deletions(-)
arch/microblaze/cpu/start.S +1 -1
@@ -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/lib/board.c +3 -14
@@ -38,13 +38,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
@@ -66,20 +59,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 +10 -0
@@ -31,6 +31,8 @@#include <asm/microblaze_intc.h> #include <asm/asm.h> +DECLARE_GLOBAL_DATA_PTR ; +int do_reset (cmd_tbl_t *cmdtp,int flag,int argc,char *const argv[]) {#ifdef CONFIG_SYS_GPIO_0
@@ -69,6 +71,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
Michal Simek
maintainerPATCH 12/12 microblaze: board: Use bi_flashstart instead of CONFIG_SYS_FLASH_BASE
In reply to Michal SimekPrepare for device-tree driven configuration.
--- arch/microblaze/lib/board.c | 8 +++++--- 1 files changed, 5 insertions(+), 3 deletions(-)
arch/microblaze/lib/board.c +5 -3
@@ -134,7 +134,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 ())) { + flash_size =flash_init (); +if (bd->bi_flashstart && flash_size >0 ) {# ifdef CONFIG_SYS_FLASH_CHECKSUM char *s;
@@ -147,7 +148,8 @@ 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' );
@@ -155,7 +157,7 @@ void board_init_f(ulong not_used)print_size (flash_size,"\n" );# endif /* CONFIG_SYS_FLASH_CHECKSUM */ bd->bi_flashsize = flash_size; - bd->bi_flashoffset =CONFIG_SYS_FLASH_BASE + 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
PATCH 1/12 microblaze: board: Remove compilation warning
In reply to Michal SimekHi Michal,
Quoted 24 lines · Michal Simek
Variable is used when
CONFIG_SYS_FLASH_CHECKSUMis used.Warning log:
board.c: In function 'board_init':
board.c:101: warning: unused variable 's'Signed-off-by Michal Simek <[email protected]>--- arch/microblaze/lib/board.c | 7 ++++--- 1 files changed, 4 insertions(+), 3 deletions(-)arch/microblaze/lib/board.c +0
-1@@ -98,7 +98,6 @@ 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;#if defined(CONFIG_CMD_FLASH )ulong flash_size =0 ;#endif
arch/microblaze/lib/board.c void board_init (void) · line 162
Quoted 9 lines
arch/microblaze/lib/board.c +2
-2@@ -157,9 +156,9 @@ void board_init (void)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;# ifdef CONFIG_SYS_FLASH_CHECKSUM +char *s; +
Is it a good idea to put declarations in the middle of the code? I don't think that is U-Boot style.
You could instead use __maybe_unused on the variable, or #ifdef the declaration :-(
Quoted 16 lines
arch/microblaze/lib/board.c +0
-0print_size (flash_size,"" );/* * Compute and print flash CRC if flashchecksum is set to
'y'arch/microblaze/lib/board.c +2
-1@@ -176,6 +175,8 @@ void board_init (void)# else /* !CONFIG_SYS_FLASH_CHECKSUM */ print_size (flash_size,"\n" );# endif /* CONFIG_SYS_FLASH_CHECKSUM */ + bd->bi_flashsize = flash_size; + bd->bi_flashoffset =CONFIG_SYS_FLASH_BASE + flash_size; }else {puts ("Flash init FAILED" ); bd->bi_flashstart =0 ; --1.7.0.4
Quoted 1 line
Regards,
Simon
Michal Simek
maintainerPATCH 1/12 microblaze: board: Remove compilation warning
Quoted 38 lines · Simon Glass
Hi Michal,
On Mon, Jul 9, 2012 at 2:20 AM, Michal Simek <monstr at monstr.eu <mailto:[email protected]>> wrote:
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' Signed-off-by: Michal Simek <monstr at monstr.eu <mailto:[email protected]>> --- arch/microblaze/lib/board.c | 7 ++++--- 1 files changed, 4 insertions(+), 3 deletions(-) diff --git a/arch/microblaze/lib/board.c b/arch/microblaze/lib/board.c index a8ed7ce..4146f5c 100644 --- a/arch/microblaze/lib/board.c +++ b/arch/microblaze/lib/board.c @@ -98,7 +98,6 @@ 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; #if defined(CONFIG_CMD_FLASH) ulong flash_size = 0; #endif @@ -157,9 +156,9 @@ void board_init (void) 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; # ifdef CONFIG_SYS_FLASH_CHECKSUM + char *s; +
Quoted 3 lines
Is it a good idea to put declarations in the middle of the code? I don't think that is U-Boot style.
You could instead use
__maybe_unusedon the variable, or #ifdef the declaration :-(
I wanted to avoid that ifdef mess. Will look at __maybe_unused. I wasn't aware about it.
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