diff options
Diffstat (limited to 'drivers/tty/hvc/hvc_dcc.c')
-rw-r--r-- | drivers/tty/hvc/hvc_dcc.c | 43 |
1 files changed, 7 insertions, 36 deletions
diff --git a/drivers/tty/hvc/hvc_dcc.c b/drivers/tty/hvc/hvc_dcc.c index 6470f63deb4b..435f6facbc23 100644 --- a/drivers/tty/hvc/hvc_dcc.c +++ b/drivers/tty/hvc/hvc_dcc.c | |||
@@ -33,54 +33,29 @@ | |||
33 | static inline u32 __dcc_getstatus(void) | 33 | static inline u32 __dcc_getstatus(void) |
34 | { | 34 | { |
35 | u32 __ret; | 35 | u32 __ret; |
36 | 36 | asm volatile("mrc p14, 0, %0, c0, c1, 0 @ read comms ctrl reg" | |
37 | asm("mrc p14, 0, %0, c0, c1, 0 @ read comms ctrl reg" | ||
38 | : "=r" (__ret) : : "cc"); | 37 | : "=r" (__ret) : : "cc"); |
39 | 38 | ||
40 | return __ret; | 39 | return __ret; |
41 | } | 40 | } |
42 | 41 | ||
43 | 42 | ||
44 | #if defined(CONFIG_CPU_V7) | ||
45 | static inline char __dcc_getchar(void) | 43 | static inline char __dcc_getchar(void) |
46 | { | 44 | { |
47 | char __c; | 45 | char __c; |
48 | 46 | ||
49 | asm("get_wait: mrc p14, 0, pc, c0, c1, 0 \n\ | 47 | asm volatile("mrc p14, 0, %0, c0, c5, 0 @ read comms data reg" |
50 | bne get_wait \n\ | ||
51 | mrc p14, 0, %0, c0, c5, 0 @ read comms data reg" | ||
52 | : "=r" (__c) : : "cc"); | ||
53 | |||
54 | return __c; | ||
55 | } | ||
56 | #else | ||
57 | static inline char __dcc_getchar(void) | ||
58 | { | ||
59 | char __c; | ||
60 | |||
61 | asm("mrc p14, 0, %0, c0, c5, 0 @ read comms data reg" | ||
62 | : "=r" (__c)); | 48 | : "=r" (__c)); |
63 | 49 | ||
64 | return __c; | 50 | return __c; |
65 | } | 51 | } |
66 | #endif | ||
67 | 52 | ||
68 | #if defined(CONFIG_CPU_V7) | ||
69 | static inline void __dcc_putchar(char c) | ||
70 | { | ||
71 | asm("put_wait: mrc p14, 0, pc, c0, c1, 0 \n\ | ||
72 | bcs put_wait \n\ | ||
73 | mcr p14, 0, %0, c0, c5, 0 " | ||
74 | : : "r" (c) : "cc"); | ||
75 | } | ||
76 | #else | ||
77 | static inline void __dcc_putchar(char c) | 53 | static inline void __dcc_putchar(char c) |
78 | { | 54 | { |
79 | asm("mcr p14, 0, %0, c0, c5, 0 @ write a char" | 55 | asm volatile("mcr p14, 0, %0, c0, c5, 0 @ write a char" |
80 | : /* no output register */ | 56 | : /* no output register */ |
81 | : "r" (c)); | 57 | : "r" (c)); |
82 | } | 58 | } |
83 | #endif | ||
84 | 59 | ||
85 | static int hvc_dcc_put_chars(uint32_t vt, const char *buf, int count) | 60 | static int hvc_dcc_put_chars(uint32_t vt, const char *buf, int count) |
86 | { | 61 | { |
@@ -90,7 +65,7 @@ static int hvc_dcc_put_chars(uint32_t vt, const char *buf, int count) | |||
90 | while (__dcc_getstatus() & DCC_STATUS_TX) | 65 | while (__dcc_getstatus() & DCC_STATUS_TX) |
91 | cpu_relax(); | 66 | cpu_relax(); |
92 | 67 | ||
93 | __dcc_putchar((char)(buf[i] & 0xFF)); | 68 | __dcc_putchar(buf[i]); |
94 | } | 69 | } |
95 | 70 | ||
96 | return count; | 71 | return count; |
@@ -100,15 +75,11 @@ static int hvc_dcc_get_chars(uint32_t vt, char *buf, int count) | |||
100 | { | 75 | { |
101 | int i; | 76 | int i; |
102 | 77 | ||
103 | for (i = 0; i < count; ++i) { | 78 | for (i = 0; i < count; ++i) |
104 | int c = -1; | ||
105 | |||
106 | if (__dcc_getstatus() & DCC_STATUS_RX) | 79 | if (__dcc_getstatus() & DCC_STATUS_RX) |
107 | c = __dcc_getchar(); | 80 | buf[i] = __dcc_getchar(); |
108 | if (c < 0) | 81 | else |
109 | break; | 82 | break; |
110 | buf[i] = c; | ||
111 | } | ||
112 | 83 | ||
113 | return i; | 84 | return i; |
114 | } | 85 | } |