1/* $Id: io.c,v 1.1.1.1 2007/08/03 18:52:15 Exp $
2 *
3 * linux/arch/sh/boards/se/7206/io.c
4 *
5 * Copyright (C) 2006 Yoshinori Sato
6 *
7 * I/O routine for Hitachi 7206 SolutionEngine.
8 *
9 */
10
11#include <linux/kernel.h>
12#include <linux/types.h>
13#include <asm/io.h>
14#include <asm/se7206.h>
15
16
17static inline void delay(void)
18{
19	ctrl_inw(0x20000000);  /* P2 ROM Area */
20}
21
22/* MS7750 requires special versions of in*, out* routines, since
23   PC-like io ports are located at upper half byte of 16-bit word which
24   can be accessed only with 16-bit wide.  */
25
26static inline volatile __u16 *
27port2adr(unsigned int port)
28{
29	if (port >= 0x2000)
30		return (volatile __u16 *) (PA_MRSHPC + (port - 0x2000));
31	else if (port >= 0x300 || port < 0x310)
32		return (volatile __u16 *) (PA_SMSC + (port - 0x300));
33}
34
35unsigned char se7206_inb(unsigned long port)
36{
37	return (*port2adr(port))&0xff;
38}
39
40unsigned char se7206_inb_p(unsigned long port)
41{
42	unsigned long v;
43
44	v = (*port2adr(port))&0xff;
45	delay();
46	return v;
47}
48
49unsigned short se7206_inw(unsigned long port)
50{
51	return *port2adr(port);;
52}
53
54unsigned int se7206_inl(unsigned long port)
55{
56	maybebadio(port);
57	return 0;
58}
59
60void se7206_outb(unsigned char value, unsigned long port)
61{
62	*(port2adr(port)) = value;
63}
64
65void se7206_outb_p(unsigned char value, unsigned long port)
66{
67	*(port2adr(port)) = value;
68	delay();
69}
70
71void se7206_outw(unsigned short value, unsigned long port)
72{
73	*port2adr(port) = value;
74}
75
76void se7206_outl(unsigned int value, unsigned long port)
77{
78	maybebadio(port);
79}
80
81void se7206_insb(unsigned long port, void *addr, unsigned long count)
82{
83	volatile __u16 *p = port2adr(port);
84	__u8 *ap = addr;
85
86	while (count--)
87		*ap++ = *p;
88}
89
90void se7206_insw(unsigned long port, void *addr, unsigned long count)
91{
92	volatile __u16 *p = port2adr(port);
93	__u16 *ap = addr;
94	while (count--)
95		*ap++ = *p;
96}
97
98void se7206_insl(unsigned long port, void *addr, unsigned long count)
99{
100	maybebadio(port);
101}
102
103void se7206_outsb(unsigned long port, const void *addr, unsigned long count)
104{
105	volatile __u16 *p = port2adr(port);
106	const __u8 *ap = addr;
107
108	while (count--)
109		*p = *ap++;
110}
111
112void se7206_outsw(unsigned long port, const void *addr, unsigned long count)
113{
114	volatile __u16 *p = port2adr(port);
115	const __u16 *ap = addr;
116	while (count--)
117		*p = *ap++;
118}
119
120void se7206_outsl(unsigned long port, const void *addr, unsigned long count)
121{
122	maybebadio(port);
123}
124