blob: 9d34bd063c318277400ec17efe62da45e06a1e1c [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001// SPDX-License-Identifier: GPL-2.0
Linus Torvalds1da177e2005-04-16 15:20:36 -07002/*
3 * arch/m32r/boot/compressed/m32r_sio.c
4 *
5 * 2003-02-12: Takeo Takahashi
Hirokazu Takatad93f7de2006-12-08 02:35:57 -08006 * 2006-11-30: OPSPUT support by Kazuhiro Inaoka
Linus Torvalds1da177e2005-04-16 15:20:36 -07007 *
8 */
9
Hirokazu Takata23680862005-06-21 17:16:10 -070010#include <asm/processor.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070011
Sudip Mukherjee9babed62016-07-14 12:07:43 -070012static void m32r_putc(char c);
Linus Torvalds1da177e2005-04-16 15:20:36 -070013
14static int puts(const char *s)
15{
16 char c;
Sudip Mukherjee9babed62016-07-14 12:07:43 -070017 while ((c = *s++))
18 m32r_putc(c);
Linus Torvalds1da177e2005-04-16 15:20:36 -070019 return 0;
20}
21
Jiri Olsa78523752008-02-04 22:27:33 -080022#if defined(CONFIG_PLAT_M32700UT) || defined(CONFIG_PLAT_OPSPUT)
Linus Torvalds1da177e2005-04-16 15:20:36 -070023#include <asm/m32r.h>
24#include <asm/io.h>
25
26#define USE_FPGA_MAP 0
27
28#if USE_FPGA_MAP
29/*
30 * fpga configuration program uses MMU, and define map as same as
31 * M32104 uT-Engine board.
32 */
33#define BOOT_SIO0STS (volatile unsigned short *)(0x02c00000 + 0x20006)
34#define BOOT_SIO0TXB (volatile unsigned short *)(0x02c00000 + 0x2000c)
35#else
36#undef PLD_BASE
Hirokazu Takatad93f7de2006-12-08 02:35:57 -080037#if defined(CONFIG_PLAT_OPSPUT)
38#define PLD_BASE 0x1cc00000
39#else
Linus Torvalds1da177e2005-04-16 15:20:36 -070040#define PLD_BASE 0xa4c00000
Hirokazu Takatad93f7de2006-12-08 02:35:57 -080041#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -070042#define BOOT_SIO0STS PLD_ESIO0STS
43#define BOOT_SIO0TXB PLD_ESIO0TXB
44#endif
45
Sudip Mukherjee9babed62016-07-14 12:07:43 -070046static void m32r_putc(char c)
Linus Torvalds1da177e2005-04-16 15:20:36 -070047{
Hirokazu Takata23680862005-06-21 17:16:10 -070048 while ((*BOOT_SIO0STS & 0x3) != 0x3)
49 cpu_relax();
Linus Torvalds1da177e2005-04-16 15:20:36 -070050 if (c == '\n') {
51 *BOOT_SIO0TXB = '\r';
Hirokazu Takata23680862005-06-21 17:16:10 -070052 while ((*BOOT_SIO0STS & 0x3) != 0x3)
53 cpu_relax();
Linus Torvalds1da177e2005-04-16 15:20:36 -070054 }
55 *BOOT_SIO0TXB = c;
56}
Jiri Olsa78523752008-02-04 22:27:33 -080057#else /* !(CONFIG_PLAT_M32700UT) */
Hirokazu Takata23680862005-06-21 17:16:10 -070058#if defined(CONFIG_PLAT_MAPPI2)
Linus Torvalds1da177e2005-04-16 15:20:36 -070059#define SIO0STS (volatile unsigned short *)(0xa0efd000 + 14)
60#define SIO0TXB (volatile unsigned short *)(0xa0efd000 + 30)
61#else
62#define SIO0STS (volatile unsigned short *)(0x00efd000 + 14)
63#define SIO0TXB (volatile unsigned short *)(0x00efd000 + 30)
64#endif
65
Sudip Mukherjee9babed62016-07-14 12:07:43 -070066static void m32r_putc(char c)
Linus Torvalds1da177e2005-04-16 15:20:36 -070067{
Hirokazu Takata23680862005-06-21 17:16:10 -070068 while ((*SIO0STS & 0x1) == 0)
69 cpu_relax();
Linus Torvalds1da177e2005-04-16 15:20:36 -070070 if (c == '\n') {
71 *SIO0TXB = '\r';
Hirokazu Takata23680862005-06-21 17:16:10 -070072 while ((*SIO0STS & 0x1) == 0)
73 cpu_relax();
Linus Torvalds1da177e2005-04-16 15:20:36 -070074 }
75 *SIO0TXB = c;
76}
77#endif