blob: 0130e9826aca619f086378b92cc59eb205ea7aa1 [file] [log] [blame]
Jamie Lenehana09749d2006-09-27 15:05:39 +09001/*
2 * I/O routines for Titan
3 */
Jamie Lenehana09749d2006-09-27 15:05:39 +09004#include <linux/pci.h>
5#include <asm/machvec.h>
6#include <asm/addrspace.h>
Paul Mundt7639a452008-10-20 13:02:48 +09007#include <mach/titan.h>
Jamie Lenehana09749d2006-09-27 15:05:39 +09008#include <asm/io.h>
Jamie Lenehana09749d2006-09-27 15:05:39 +09009
Paul Mundt373e68b2006-09-27 15:41:24 +090010static inline unsigned int port2adr(unsigned int port)
Jamie Lenehana09749d2006-09-27 15:05:39 +090011{
12 maybebadio((unsigned long)port);
Paul Mundt373e68b2006-09-27 15:41:24 +090013 return port;
Jamie Lenehana09749d2006-09-27 15:05:39 +090014}
15
16u8 titan_inb(unsigned long port)
17{
18 if (PXSEG(port))
19 return ctrl_inb(port);
Jamie Lenehana09749d2006-09-27 15:05:39 +090020 return ctrl_inw(port2adr(port)) & 0xff;
21}
22
23u8 titan_inb_p(unsigned long port)
24{
25 u8 v;
26
27 if (PXSEG(port))
28 v = ctrl_inb(port);
Jamie Lenehana09749d2006-09-27 15:05:39 +090029 else
30 v = ctrl_inw(port2adr(port)) & 0xff;
Paul Mundt959f85f2006-09-27 16:43:28 +090031 ctrl_delay();
Jamie Lenehana09749d2006-09-27 15:05:39 +090032 return v;
33}
34
35u16 titan_inw(unsigned long port)
36{
37 if (PXSEG(port))
38 return ctrl_inw(port);
Jamie Lenehana09749d2006-09-27 15:05:39 +090039 else if (port >= 0x2000)
40 return ctrl_inw(port2adr(port));
41 else
42 maybebadio(port);
43 return 0;
44}
45
46u32 titan_inl(unsigned long port)
47{
48 if (PXSEG(port))
49 return ctrl_inl(port);
Jamie Lenehana09749d2006-09-27 15:05:39 +090050 else if (port >= 0x2000)
51 return ctrl_inw(port2adr(port));
52 else
53 maybebadio(port);
54 return 0;
55}
56
57void titan_outb(u8 value, unsigned long port)
58{
59 if (PXSEG(port))
60 ctrl_outb(value, port);
Jamie Lenehana09749d2006-09-27 15:05:39 +090061 else
62 ctrl_outw(value, port2adr(port));
63}
64
65void titan_outb_p(u8 value, unsigned long port)
66{
67 if (PXSEG(port))
68 ctrl_outb(value, port);
Jamie Lenehana09749d2006-09-27 15:05:39 +090069 else
70 ctrl_outw(value, port2adr(port));
Paul Mundt959f85f2006-09-27 16:43:28 +090071 ctrl_delay();
Jamie Lenehana09749d2006-09-27 15:05:39 +090072}
73
74void titan_outw(u16 value, unsigned long port)
75{
76 if (PXSEG(port))
77 ctrl_outw(value, port);
Jamie Lenehana09749d2006-09-27 15:05:39 +090078 else if (port >= 0x2000)
79 ctrl_outw(value, port2adr(port));
80 else
81 maybebadio(port);
82}
83
84void titan_outl(u32 value, unsigned long port)
85{
86 if (PXSEG(port))
87 ctrl_outl(value, port);
Jamie Lenehana09749d2006-09-27 15:05:39 +090088 else
89 maybebadio(port);
90}
91
92void titan_insl(unsigned long port, void *dst, unsigned long count)
93{
94 maybebadio(port);
95}
96
97void titan_outsl(unsigned long port, const void *src, unsigned long count)
98{
99 maybebadio(port);
100}
101
Jamie Lenehana09749d2006-09-27 15:05:39 +0900102void __iomem *titan_ioport_map(unsigned long port, unsigned int size)
103{
Magnus Dammef339f22008-02-19 21:35:22 +0900104 if (PXSEG(port))
Jamie Lenehana09749d2006-09-27 15:05:39 +0900105 return (void __iomem *)port;
Jamie Lenehana09749d2006-09-27 15:05:39 +0900106
107 return (void __iomem *)port2adr(port);
108}