• Home
  • History
  • Annotate
  • Line#
  • Navigate
  • Raw
  • Download
  • only in /netgear-WNDR4500v2-V1.0.0.60_1.0.38/src/linux/linux-2.6/arch/sh/cchips/hd6446x/hd64461/
1/*
2 *	Copyright (C) 2000 YAEGASHI Takeshi
3 *	Typical I/O routines for HD64461 system.
4 */
5
6#include <asm/io.h>
7#include <asm/hd64461.h>
8
9#define MEM_BASE (CONFIG_HD64461_IOBASE - HD64461_STBCR)
10
11static __inline__ unsigned long PORT2ADDR(unsigned long port)
12{
13	/* 16550A: HD64461 internal */
14	if (0x3f8<=port && port<=0x3ff)
15		return CONFIG_HD64461_IOBASE + 0x8000 + ((port-0x3f8)<<1);
16	if (0x2f8<=port && port<=0x2ff)
17		return CONFIG_HD64461_IOBASE + 0x7000 + ((port-0x2f8)<<1);
18
19#ifdef CONFIG_HD64461_ENABLER
20	/* NE2000: HD64461 PCMCIA channel 0 (I/O) */
21	if (0x300<=port && port<=0x31f)
22		return 0xba000000 + port;
23
24	/* ide0: HD64461 PCMCIA channel 1 (memory) */
25	/* On HP690, CF in slot 1 is configured as a memory card
26	   device.  See CF+ and CompactFlash Specification for the
27	   detail of CF's memory mapped addressing. */
28	if (0x1f0<=port && port<=0x1f7)	return 0xb5000000 + port;
29	if (port == 0x3f6) return 0xb50001fe;
30	if (port == 0x3f7) return 0xb50001ff;
31
32	/* ide1 */
33	if (0x170<=port && port<=0x177)	return 0xba000000 + port;
34	if (port == 0x376) return 0xba000376;
35	if (port == 0x377) return 0xba000377;
36#endif
37
38	/* ??? */
39	if (port < 0xf000) return 0xa0000000 + port;
40	/* PCMCIA channel 0, I/O (0xba000000) */
41	if (port < 0x10000) return 0xba000000 + port - 0xf000;
42
43	/* HD64461 internal devices (0xb0000000) */
44	if (port < 0x20000) return CONFIG_HD64461_IOBASE + port - 0x10000;
45
46	/* PCMCIA channel 0, I/O (0xba000000) */
47	if (port < 0x30000) return 0xba000000 + port - 0x20000;
48
49	/* PCMCIA channel 1, memory (0xb5000000) */
50	if (port < 0x40000) return 0xb5000000 + port - 0x30000;
51
52	/* Whole physical address space (0xa0000000) */
53	return 0xa0000000 + (port & 0x1fffffff);
54}
55
56unsigned char hd64461_inb(unsigned long port)
57{
58	return *(volatile unsigned char*)PORT2ADDR(port);
59}
60
61unsigned char hd64461_inb_p(unsigned long port)
62{
63	unsigned long v = *(volatile unsigned char*)PORT2ADDR(port);
64	ctrl_delay();
65	return v;
66}
67
68unsigned short hd64461_inw(unsigned long port)
69{
70	return *(volatile unsigned short*)PORT2ADDR(port);
71}
72
73unsigned int hd64461_inl(unsigned long port)
74{
75	return *(volatile unsigned long*)PORT2ADDR(port);
76}
77
78void hd64461_outb(unsigned char b, unsigned long port)
79{
80	*(volatile unsigned char*)PORT2ADDR(port) = b;
81}
82
83void hd64461_outb_p(unsigned char b, unsigned long port)
84{
85	*(volatile unsigned char*)PORT2ADDR(port) = b;
86	ctrl_delay();
87}
88
89void hd64461_outw(unsigned short b, unsigned long port)
90{
91	*(volatile unsigned short*)PORT2ADDR(port) = b;
92}
93
94void hd64461_outl(unsigned int b, unsigned long port)
95{
96        *(volatile unsigned long*)PORT2ADDR(port) = b;
97}
98
99void hd64461_insb(unsigned long port, void *buffer, unsigned long count)
100{
101	volatile unsigned char* addr=(volatile unsigned char*)PORT2ADDR(port);
102	unsigned char *buf=buffer;
103	while(count--) *buf++=*addr;
104}
105
106void hd64461_insw(unsigned long port, void *buffer, unsigned long count)
107{
108	volatile unsigned short* addr=(volatile unsigned short*)PORT2ADDR(port);
109	unsigned short *buf=buffer;
110	while(count--) *buf++=*addr;
111}
112
113void hd64461_insl(unsigned long port, void *buffer, unsigned long count)
114{
115	volatile unsigned long* addr=(volatile unsigned long*)PORT2ADDR(port);
116	unsigned long *buf=buffer;
117	while(count--) *buf++=*addr;
118}
119
120void hd64461_outsb(unsigned long port, const void *buffer, unsigned long count)
121{
122	volatile unsigned char* addr=(volatile unsigned char*)PORT2ADDR(port);
123	const unsigned char *buf=buffer;
124	while(count--) *addr=*buf++;
125}
126
127void hd64461_outsw(unsigned long port, const void *buffer, unsigned long count)
128{
129	volatile unsigned short* addr=(volatile unsigned short*)PORT2ADDR(port);
130	const unsigned short *buf=buffer;
131	while(count--) *addr=*buf++;
132}
133
134void hd64461_outsl(unsigned long port, const void *buffer, unsigned long count)
135{
136	volatile unsigned long* addr=(volatile unsigned long*)PORT2ADDR(port);
137	const unsigned long *buf=buffer;
138	while(count--) *addr=*buf++;
139}
140
141unsigned short hd64461_readw(void __iomem *addr)
142{
143	return ctrl_inw(MEM_BASE+(unsigned long __force)addr);
144}
145
146void hd64461_writew(unsigned short b, void __iomem *addr)
147{
148	ctrl_outw(b, MEM_BASE+(unsigned long __force)addr);
149}
150