blob: 01d877c6868f05e5a8fb72639a980cd4b7ef66dc [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * arch/m32r/boot/compressed/m32r_sio.c
3 *
4 * 2003-02-12: Takeo Takahashi
Hirokazu Takatad93f7de2006-12-08 02:35:57 -08005 * 2006-11-30: OPSPUT support by Kazuhiro Inaoka
Linus Torvalds1da177e2005-04-16 15:20:36 -07006 *
7 */
8
Hirokazu Takata23680862005-06-21 17:16:10 -07009#include <asm/processor.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070010
11static void putc(char c);
12
13static int puts(const char *s)
14{
15 char c;
16 while ((c = *s++)) putc(c);
17 return 0;
18}
19
Jiri Olsa78523752008-02-04 22:27:33 -080020#if defined(CONFIG_PLAT_M32700UT) || defined(CONFIG_PLAT_OPSPUT)
Linus Torvalds1da177e2005-04-16 15:20:36 -070021#include <asm/m32r.h>
22#include <asm/io.h>
23
24#define USE_FPGA_MAP 0
25
26#if USE_FPGA_MAP
27/*
28 * fpga configuration program uses MMU, and define map as same as
29 * M32104 uT-Engine board.
30 */
31#define BOOT_SIO0STS (volatile unsigned short *)(0x02c00000 + 0x20006)
32#define BOOT_SIO0TXB (volatile unsigned short *)(0x02c00000 + 0x2000c)
33#else
34#undef PLD_BASE
Hirokazu Takatad93f7de2006-12-08 02:35:57 -080035#if defined(CONFIG_PLAT_OPSPUT)
36#define PLD_BASE 0x1cc00000
37#else
Linus Torvalds1da177e2005-04-16 15:20:36 -070038#define PLD_BASE 0xa4c00000
Hirokazu Takatad93f7de2006-12-08 02:35:57 -080039#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -070040#define BOOT_SIO0STS PLD_ESIO0STS
41#define BOOT_SIO0TXB PLD_ESIO0TXB
42#endif
43
44static void putc(char c)
45{
Hirokazu Takata23680862005-06-21 17:16:10 -070046 while ((*BOOT_SIO0STS & 0x3) != 0x3)
47 cpu_relax();
Linus Torvalds1da177e2005-04-16 15:20:36 -070048 if (c == '\n') {
49 *BOOT_SIO0TXB = '\r';
Hirokazu Takata23680862005-06-21 17:16:10 -070050 while ((*BOOT_SIO0STS & 0x3) != 0x3)
51 cpu_relax();
Linus Torvalds1da177e2005-04-16 15:20:36 -070052 }
53 *BOOT_SIO0TXB = c;
54}
Jiri Olsa78523752008-02-04 22:27:33 -080055#else /* !(CONFIG_PLAT_M32700UT) */
Hirokazu Takata23680862005-06-21 17:16:10 -070056#if defined(CONFIG_PLAT_MAPPI2)
Linus Torvalds1da177e2005-04-16 15:20:36 -070057#define SIO0STS (volatile unsigned short *)(0xa0efd000 + 14)
58#define SIO0TXB (volatile unsigned short *)(0xa0efd000 + 30)
59#else
60#define SIO0STS (volatile unsigned short *)(0x00efd000 + 14)
61#define SIO0TXB (volatile unsigned short *)(0x00efd000 + 30)
62#endif
63
64static void putc(char c)
65{
Hirokazu Takata23680862005-06-21 17:16:10 -070066 while ((*SIO0STS & 0x1) == 0)
67 cpu_relax();
Linus Torvalds1da177e2005-04-16 15:20:36 -070068 if (c == '\n') {
69 *SIO0TXB = '\r';
Hirokazu Takata23680862005-06-21 17:16:10 -070070 while ((*SIO0STS & 0x1) == 0)
71 cpu_relax();
Linus Torvalds1da177e2005-04-16 15:20:36 -070072 }
73 *SIO0TXB = c;
74}
75#endif