arm/dcc: use static support to allow to use it at anytime
PATCH 1/2 arm/dcc: use static support to allow to use it at anytime
the dcc can be use at the start of the cpu
--- drivers/serial/arm_dcc.c | 156 ++++++++++++--------------------------------- 1 files changed, 42 insertions(+), 114 deletions(-)
drivers/serial/arm_dcc.c +42 -114
@@ -29,69 +29,50 @@#include <common.h> #include <devices.h> -#define DCC_ARM9_RBIT (1 << 0) -#define DCC_ARM9_WBIT (1 << 1) -#define DCC_ARM11_RBIT (1 << 30) -#define DCC_ARM11_WBIT (1 << 29) - -#define read_core_id (x) do { \ - __asm__ ("mrc p15, 0, %0, c0, c0, 0\n" : "=r" (x)); \ - x = (x >> 4) & 0xFFF; \ - } while (0); - +#if defined(CONFIG_CPU_V6 )/* -* ARM9 +* ARMV6 */ -#define write_arm9_dcc (x) \ - __asm__ volatile ("mcr p14, 0, %0, c1, c0, 0\n" : : "r" (x)) +#define DCC_RBIT (1 << 30) +#define DCC_WBIT (1 << 29) -#define read_arm9_dcc (x) \ - __asm__ volatile ("mrc p14, 0, %0, c1, c0, 0\n" : "=r" (x)) +#define write_dcc (x) \ + __asm__ volatile ("mcr p14, 0, %0, c0, c5, 0\n" : : "r" (x)) -#define status_arm9_dcc (x) \ - __asm__ volatile ("mrc p14, 0, %0, c0, c0, 0\n" : "=r" (x)) +#define read_dcc (x) \ + __asm__ volatile ("mrc p14, 0, %0, c0, c5, 0\n" : "=r" (x)) -#define can_read_arm9_dcc (x) do { \ - status_arm9_dcc(x); \ - x &= DCC_ARM9_RBIT; \ - } while (0); +#define status_dcc (x) \ + __asm__ volatile ("mrc p14, 0, %0, c0, c1, 0\n" : "=r" (x)) -#define can_write_arm9_dcc (x) do { \ - status_arm9_dcc(x); \ - x &= DCC_ARM9_WBIT; \ - x = (x == 0); \ - } while (0); +#else +#define DCC_RBIT (1 << 0) +#define DCC_WBIT (1 << 1) -/* -* ARM11 -*/ -#define write_arm11_dcc (x) \ - __asm__ volatile ("mcr p14, 0, %0, c0, c5, 0\n" : : "r" (x)) +#define write_dcc (x) \ + __asm__ volatile ("mcr p14, 0, %0, c1, c0, 0\n" : : "r" (x)) -#define read_arm11_dcc (x) \ - __asm__ volatile ("mrc p14, 0, %0, c0, c5, 0\n" : "=r" (x)) +#define read_dcc (x) \ + __asm__ volatile ("mrc p14, 0, %0, c1, c0, 0\n" : "=r" (x)) -#define status_arm11_dcc (x) \ - __asm__ volatile ("mrc p14, 0, %0, c0, c1, 0\n" : "=r" (x)) +#define status_dcc (x) \ + __asm__ volatile ("mrc p14, 0, %0, c0, c0, 0\n" : "=r" (x)) + +#endif -#define can_read_arm11_dcc (x) do { \ - status_arm11_dcc(x); \ - x &= DCC_ARM11_RBIT; \ +#define can_read_dcc (x) do { \ + status_dcc(x); \ + x &= DCC_RBIT; \ } while (0); -#define can_write_arm11_dcc (x) do { \ - status_arm11_dcc(x); \ - x &= DCC_ARM11_WBIT; \ - x = (x == 0); \ +#define can_write_dcc (x) do { \ + status_dcc(x); \ + x &= DCC_WBIT; \ + x = (x == 0); \ } while (0);#define TIMEOUT_COUNT 0x4000000 -static enum { - arm9_and_earlier, - arm11_and_later -} arm_type = arm9_and_earlier; -#ifndef CONFIG_ARM_DCC_MULTI #define arm_dcc_init serial_initvoid serial_setbrg (void ) {}
@@ -103,15 +84,6 @@ void serial_setbrg(void) {}int arm_dcc_init (void ) { - registerunsigned int id; - -read_core_id (id); - -if (id >=0xb00 ) - arm_type = arm11_and_later; -else - arm_type = arm9_and_earlier; -return 0 ; }
@@ -120,22 +92,10 @@ int arm_dcc_getc(void)int ch; registerunsigned int reg; -switch (arm_type) { -case arm11_and_later: -do { -can_read_arm11_dcc (reg); - }while (!reg); -read_arm11_dcc (ch); -break ; - -case arm9_and_earlier: -default : -do { -can_read_arm9_dcc (reg); - }while (!reg); -read_arm9_dcc (ch); -break ; - } +do { +can_read_dcc (reg); + }while (!reg); +read_dcc (ch);return ch; }
@@ -145,32 +105,15 @@ void arm_dcc_putc(char ch) registerunsigned int reg;unsigned int timeout_count =TIMEOUT_COUNT ; -switch (arm_type) { -case arm11_and_later: -while (--timeout_count) { -can_write_arm11_dcc (reg); -if (reg) -break ; - } -if (timeout_count ==0 ) -return ; -else -write_arm11_dcc (ch); -break ; - -case arm9_and_earlier: -default : -while (--timeout_count) { -can_write_arm9_dcc (reg); -if (reg) -break ; - } -if (timeout_count ==0 ) -return ; -else -write_arm9_dcc (ch); -break ; +while (--timeout_count) { +can_write_dcc (reg); +if (reg) +break ; } +if (timeout_count ==0 ) +return ; +else +write_dcc (ch); }void arm_dcc_puts (const char *s)
@@ -183,15 +126,7 @@ int arm_dcc_tstc(void) { registerunsigned int reg; -switch (arm_type) { -case arm11_and_later: -can_read_arm11_dcc (reg); -break ; -case arm9_and_earlier: -default : -can_read_arm9_dcc (reg); -break ; - } +can_read_dcc (reg);return reg; }
@@ -214,13 +149,6 @@ int drv_arm_dcc_init(void) arm_dcc_dev.putc = arm_dcc_putc;/* 'putc' function */ arm_dcc_dev.puts = arm_dcc_puts;/* 'puts' function */ - rc =device_register (&arm_dcc_dev); - -if (rc ==0 ) { -arm_dcc_init (); -return 1 ; - } - - return 0; + return device_register(&arm_dcc_dev); }#endif
Signature · 1 line
1.6.1.3
PATCH 2/2 arm/dcc: add xcale support
--- drivers/serial/arm_dcc.c | 16 ++++++++++++++++ 1 files changed, 16 insertions(+), 0 deletions(-)
drivers/serial/arm_dcc.c +16 -0
@@ -45,6 +45,22 @@#define status_dcc (x) \ __asm__ volatile ("mrc p14, 0, %0, c0, c1, 0\n" : "=r" (x)) +#elif defined(CONFIG_CPU_XSCALE ) +/* +* XSCALE +*/ +#define DCC_RBIT (1 << 31) +#define DCC_WBIT (1 << 28) + +#define write_dcc (x) \ + __asm__ volatile ("mcr p14, 0, %0, c8, c0, 0\n" : : "r" (x)) + +#define read_dcc (x) \ + __asm__ volatile ("mrc p14, 0, %0, c9, c0, 0\n" : "=r" (x)) + +#define status_dcc (x) \ + __asm__ volatile ("mrc p14, 0, %0, c14, c0, 0\n" : "=r" (x)) +#else #define DCC_RBIT (1 << 0)#define DCC_WBIT (1 << 1)
Signature · 1 line
1.6.1.3
PATCH 2/2 arm/dcc: add xcale support
Dear Jean-Christophe PLAGNIOL-VILLARD,
Quoted 4 lines · In message <[email protected]> you wrote:
Signed-off-by Jean-Christophe PLAGNIOL-VILLARD <[email protected]>--- drivers/serial/arm_dcc.c | 16 ++++++++++++++++ 1 files changed, 16 insertions(+), 0 deletions(-)
Please fix typo in subject line. Thanks.
Best regards,
Wolfgang Denk
Signature · 5 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
It is a good thing for an uneducated man to read books of quotations.
- Sir Winston Churchill _My Early Life_ ch. 9PATCH 1/2 arm/dcc: use static support to allow to use it at anytime
In reply to Jean-Christophe PLAGNIOL-VILLARDDear Jean-Christophe PLAGNIOL-VILLARD,
Quoted 1 line · In message <[email protected]> you wrote:
the dcc can be use at the start of the cpu
Can you please explain in a little more detail what exactly you are doing here? Your short description
"use static support to allow to use it at anytime"
does not make any sense to me, and the next line "the dcc can be use at the start of the cpu" does not help my understanding, either. Sorry...
I don't even understand what "static support" means in this context.
Quoted 7 lines
drivers/serial/arm_dcc.c +1
-5-#define read_core_id (x) do { \ - __asm__ ("mrc p15, 0, %0, c0, c0, 0\n" : "=r" (x)); \ - x = (x >> 4) & 0xFFF; \ - } while (0); - +#if defined(CONFIG_CPU_V6 )/*
drivers/serial/arm_dcc.c line 49
Quoted 10 lines
drivers/serial/arm_dcc.c +3
-5-* ARM9 +* ARMV6 */ -#define write_arm9_dcc (x) \ - __asm__ volatile ("mcr p14, 0, %0, c1, c0, 0\n" : : "r" (x)) +#define DCC_RBIT (1 << 30) +#define DCC_WBIT (1 << 29) -#define read_arm9_dcc (x) \ - __asm__ volatile ("mrc p14, 0, %0, c1, c0, 0\n" : "=r" (x))
This changes from "p15" (old) into "p14" (new). I guess this is intentional?
drivers/serial/arm_dcc.c line 72
Quoted 5 lines
drivers/serial/arm_dcc.c +4
-0+#define can_write_dcc (x) do { \ + status_dcc(x); \ + x &= DCC_WBIT; \ + x = (x == 0); \ } while (0);
Indentation wrong (here and elsewhere).
Quoted 5 lines
drivers/serial/arm_dcc.c +0
-1@@ -103,15 +84,6 @@ void serial_setbrg(void) {}int arm_dcc_init (void ) { - registerunsigned int id;
drivers/serial/arm_dcc.c void serial_setbrg(void) {} · line 88
Quoted 10 lines
drivers/serial/arm_dcc.c +0
-8- -read_core_id (id); - -if (id >=0xb00 ) - arm_type = arm11_and_later; -else - arm_type = arm9_and_earlier; -return 0 ; }
If the function returns 0 unconditionally, we should delete the whole function.
Quoted 14 lines
drivers/serial/arm_dcc.c +0
-10@@ -120,22 +92,10 @@ int arm_dcc_getc(void)int ch; registerunsigned int reg; -switch (arm_type) { -case arm11_and_later: -do { -can_read_arm11_dcc (reg); - }while (!reg); -read_arm11_dcc (ch); -break ; - -case arm9_and_earlier: -default :
drivers/serial/arm_dcc.c int arm_dcc_getc(void) · line 98
Quoted 10 lines
drivers/serial/arm_dcc.c +4
-6-do { -can_read_arm9_dcc (reg); - }while (!reg); -read_arm9_dcc (ch); -break ; - } +do { +can_read_dcc (reg); + }while (!reg); +read_dcc (ch);
No timeout here? Is there a risk that this might permanently hang the system?
drivers/serial/arm_dcc.c void arm_dcc_putc(char ch) · line 117
Quoted 10 lines
drivers/serial/arm_dcc.c +8
-0+while (--timeout_count) { +can_write_dcc (reg); +if (reg) +break ; } +if (timeout_count ==0 ) +return ; +else +write_dcc (ch); }
No error messages in case of timeout?
Best regards,
Wolfgang Denk
Signature · 8 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
The universe contains any amount of horrible ways to be woken up,
such as the noise of the mob breaking down the front door, the scream
of fire engines, or the realization that today is the Monday which on
Friday night was a comfortably long way off.
- Terry Pratchett, _Moving Pictures_