| 1 | #include <linux/init.h> |
| 2 | #include <linux/cpu.h> |
| 3 | |
| 4 | #include <ifxmips.h> |
| 5 | |
| 6 | #ifdef CONFIG_IFXMIPS_PROM_ASC0 |
| 7 | #define IFXMIPS_ASC_DIFF 0 |
| 8 | #else |
| 9 | #define IFXMIPS_ASC_DIFF IFXMIPS_ASC_BASE_DIFF |
| 10 | #endif |
| 11 | |
| 12 | static char buf[1024]; |
| 13 | |
| 14 | static inline u32 |
| 15 | asc_r32(unsigned long r) |
| 16 | { |
| 17 | return ifxmips_r32((u32 *)(IFXMIPS_ASC_BASE_ADDR + IFXMIPS_ASC_DIFF + r)); |
| 18 | } |
| 19 | |
| 20 | static inline void |
| 21 | asc_w32(u32 v, unsigned long r) |
| 22 | { |
| 23 | ifxmips_w32(v, (u32 *)(IFXMIPS_ASC_BASE_ADDR + IFXMIPS_ASC_DIFF + r)); |
| 24 | } |
| 25 | |
| 26 | void |
| 27 | prom_putchar(char c) |
| 28 | { |
| 29 | unsigned long flags; |
| 30 | |
| 31 | local_irq_save(flags); |
| 32 | while ((asc_r32(IFXMIPS_ASC_FSTAT) & ASCFSTAT_TXFFLMASK) >> ASCFSTAT_TXFFLOFF); |
| 33 | |
| 34 | if (c == '\n') |
| 35 | asc_w32('\r', IFXMIPS_ASC_TBUF); |
| 36 | asc_w32(c, IFXMIPS_ASC_TBUF); |
| 37 | local_irq_restore(flags); |
| 38 | } |
| 39 | |
| 40 | void |
| 41 | early_printf(const char *fmt, ...) |
| 42 | { |
| 43 | va_list args; |
| 44 | int l; |
| 45 | char *p, *buf_end; |
| 46 | |
| 47 | va_start(args, fmt); |
| 48 | l = vsprintf(buf, fmt, args); |
| 49 | va_end(args); |
| 50 | buf_end = buf + l; |
| 51 | |
| 52 | for (p = buf; p < buf_end; p++) |
| 53 | prom_putchar(*p); |
| 54 | } |
| 55 | |
| 56 | |
| 57 | |