2 * Copyright (C) 2000 YAEGASHI Takeshi
3 * Typical I/O routines for HD64461 system.
7 #include <asm/hd64461.h>
9 #define MEM_BASE (CONFIG_HD64461_IOBASE - HD64461_STBCR)
11 static __inline__
unsigned long PORT2ADDR(unsigned long port
)
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);
19 #ifdef CONFIG_HD64461_ENABLER
20 /* NE2000: HD64461 PCMCIA channel 0 (I/O) */
21 if (0x300<=port
&& port
<=0x31f)
22 return 0xba000000 + port
;
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;
33 if (0x170<=port
&& port
<=0x177) return 0xba000000 + port
;
34 if (port
== 0x376) return 0xba000376;
35 if (port
== 0x377) return 0xba000377;
39 if (port
< 0xf000) return 0xa0000000 + port
;
40 /* PCMCIA channel 0, I/O (0xba000000) */
41 if (port
< 0x10000) return 0xba000000 + port
- 0xf000;
43 /* HD64461 internal devices (0xb0000000) */
44 if (port
< 0x20000) return CONFIG_HD64461_IOBASE
+ port
- 0x10000;
46 /* PCMCIA channel 0, I/O (0xba000000) */
47 if (port
< 0x30000) return 0xba000000 + port
- 0x20000;
49 /* PCMCIA channel 1, memory (0xb5000000) */
50 if (port
< 0x40000) return 0xb5000000 + port
- 0x30000;
52 /* Whole physical address space (0xa0000000) */
53 return 0xa0000000 + (port
& 0x1fffffff);
56 unsigned char hd64461_inb(unsigned long port
)
58 return *(volatile unsigned char*)PORT2ADDR(port
);
61 unsigned char hd64461_inb_p(unsigned long port
)
63 unsigned long v
= *(volatile unsigned char*)PORT2ADDR(port
);
68 unsigned short hd64461_inw(unsigned long port
)
70 return *(volatile unsigned short*)PORT2ADDR(port
);
73 unsigned int hd64461_inl(unsigned long port
)
75 return *(volatile unsigned long*)PORT2ADDR(port
);
78 void hd64461_outb(unsigned char b
, unsigned long port
)
80 *(volatile unsigned char*)PORT2ADDR(port
) = b
;
83 void hd64461_outb_p(unsigned char b
, unsigned long port
)
85 *(volatile unsigned char*)PORT2ADDR(port
) = b
;
89 void hd64461_outw(unsigned short b
, unsigned long port
)
91 *(volatile unsigned short*)PORT2ADDR(port
) = b
;
94 void hd64461_outl(unsigned int b
, unsigned long port
)
96 *(volatile unsigned long*)PORT2ADDR(port
) = b
;
99 void hd64461_insb(unsigned long port
, void *buffer
, unsigned long count
)
101 volatile unsigned char* addr
=(volatile unsigned char*)PORT2ADDR(port
);
102 unsigned char *buf
=buffer
;
103 while(count
--) *buf
++=*addr
;
106 void hd64461_insw(unsigned long port
, void *buffer
, unsigned long count
)
108 volatile unsigned short* addr
=(volatile unsigned short*)PORT2ADDR(port
);
109 unsigned short *buf
=buffer
;
110 while(count
--) *buf
++=*addr
;
113 void hd64461_insl(unsigned long port
, void *buffer
, unsigned long count
)
115 volatile unsigned long* addr
=(volatile unsigned long*)PORT2ADDR(port
);
116 unsigned long *buf
=buffer
;
117 while(count
--) *buf
++=*addr
;
120 void hd64461_outsb(unsigned long port
, const void *buffer
, unsigned long count
)
122 volatile unsigned char* addr
=(volatile unsigned char*)PORT2ADDR(port
);
123 const unsigned char *buf
=buffer
;
124 while(count
--) *addr
=*buf
++;
127 void hd64461_outsw(unsigned long port
, const void *buffer
, unsigned long count
)
129 volatile unsigned short* addr
=(volatile unsigned short*)PORT2ADDR(port
);
130 const unsigned short *buf
=buffer
;
131 while(count
--) *addr
=*buf
++;
134 void hd64461_outsl(unsigned long port
, const void *buffer
, unsigned long count
)
136 volatile unsigned long* addr
=(volatile unsigned long*)PORT2ADDR(port
);
137 const unsigned long *buf
=buffer
;
138 while(count
--) *addr
=*buf
++;
141 unsigned short hd64461_readw(void __iomem
*addr
)
143 return ctrl_inw(MEM_BASE
+(unsigned long __force
)addr
);
146 void hd64461_writew(unsigned short b
, void __iomem
*addr
)
148 ctrl_outw(b
, MEM_BASE
+(unsigned long __force
)addr
);