Jamie Lenehan | a09749d | 2006-09-27 15:05:39 +0900 | [diff] [blame] | 1 | /* |
| 2 | * I/O routines for Titan |
| 3 | */ |
Jamie Lenehan | a09749d | 2006-09-27 15:05:39 +0900 | [diff] [blame] | 4 | #include <linux/pci.h> |
| 5 | #include <asm/machvec.h> |
| 6 | #include <asm/addrspace.h> |
Paul Mundt | 7639a45 | 2008-10-20 13:02:48 +0900 | [diff] [blame] | 7 | #include <mach/titan.h> |
Jamie Lenehan | a09749d | 2006-09-27 15:05:39 +0900 | [diff] [blame] | 8 | #include <asm/io.h> |
Jamie Lenehan | a09749d | 2006-09-27 15:05:39 +0900 | [diff] [blame] | 9 | |
Paul Mundt | 373e68b | 2006-09-27 15:41:24 +0900 | [diff] [blame] | 10 | static inline unsigned int port2adr(unsigned int port) |
Jamie Lenehan | a09749d | 2006-09-27 15:05:39 +0900 | [diff] [blame] | 11 | { |
| 12 | maybebadio((unsigned long)port); |
Paul Mundt | 373e68b | 2006-09-27 15:41:24 +0900 | [diff] [blame] | 13 | return port; |
Jamie Lenehan | a09749d | 2006-09-27 15:05:39 +0900 | [diff] [blame] | 14 | } |
| 15 | |
| 16 | u8 titan_inb(unsigned long port) |
| 17 | { |
| 18 | if (PXSEG(port)) |
| 19 | return ctrl_inb(port); |
Jamie Lenehan | a09749d | 2006-09-27 15:05:39 +0900 | [diff] [blame] | 20 | return ctrl_inw(port2adr(port)) & 0xff; |
| 21 | } |
| 22 | |
| 23 | u8 titan_inb_p(unsigned long port) |
| 24 | { |
| 25 | u8 v; |
| 26 | |
| 27 | if (PXSEG(port)) |
| 28 | v = ctrl_inb(port); |
Jamie Lenehan | a09749d | 2006-09-27 15:05:39 +0900 | [diff] [blame] | 29 | else |
| 30 | v = ctrl_inw(port2adr(port)) & 0xff; |
Paul Mundt | 959f85f | 2006-09-27 16:43:28 +0900 | [diff] [blame] | 31 | ctrl_delay(); |
Jamie Lenehan | a09749d | 2006-09-27 15:05:39 +0900 | [diff] [blame] | 32 | return v; |
| 33 | } |
| 34 | |
| 35 | u16 titan_inw(unsigned long port) |
| 36 | { |
| 37 | if (PXSEG(port)) |
| 38 | return ctrl_inw(port); |
Jamie Lenehan | a09749d | 2006-09-27 15:05:39 +0900 | [diff] [blame] | 39 | else if (port >= 0x2000) |
| 40 | return ctrl_inw(port2adr(port)); |
| 41 | else |
| 42 | maybebadio(port); |
| 43 | return 0; |
| 44 | } |
| 45 | |
| 46 | u32 titan_inl(unsigned long port) |
| 47 | { |
| 48 | if (PXSEG(port)) |
| 49 | return ctrl_inl(port); |
Jamie Lenehan | a09749d | 2006-09-27 15:05:39 +0900 | [diff] [blame] | 50 | else if (port >= 0x2000) |
| 51 | return ctrl_inw(port2adr(port)); |
| 52 | else |
| 53 | maybebadio(port); |
| 54 | return 0; |
| 55 | } |
| 56 | |
| 57 | void titan_outb(u8 value, unsigned long port) |
| 58 | { |
| 59 | if (PXSEG(port)) |
| 60 | ctrl_outb(value, port); |
Jamie Lenehan | a09749d | 2006-09-27 15:05:39 +0900 | [diff] [blame] | 61 | else |
| 62 | ctrl_outw(value, port2adr(port)); |
| 63 | } |
| 64 | |
| 65 | void titan_outb_p(u8 value, unsigned long port) |
| 66 | { |
| 67 | if (PXSEG(port)) |
| 68 | ctrl_outb(value, port); |
Jamie Lenehan | a09749d | 2006-09-27 15:05:39 +0900 | [diff] [blame] | 69 | else |
| 70 | ctrl_outw(value, port2adr(port)); |
Paul Mundt | 959f85f | 2006-09-27 16:43:28 +0900 | [diff] [blame] | 71 | ctrl_delay(); |
Jamie Lenehan | a09749d | 2006-09-27 15:05:39 +0900 | [diff] [blame] | 72 | } |
| 73 | |
| 74 | void titan_outw(u16 value, unsigned long port) |
| 75 | { |
| 76 | if (PXSEG(port)) |
| 77 | ctrl_outw(value, port); |
Jamie Lenehan | a09749d | 2006-09-27 15:05:39 +0900 | [diff] [blame] | 78 | else if (port >= 0x2000) |
| 79 | ctrl_outw(value, port2adr(port)); |
| 80 | else |
| 81 | maybebadio(port); |
| 82 | } |
| 83 | |
| 84 | void titan_outl(u32 value, unsigned long port) |
| 85 | { |
| 86 | if (PXSEG(port)) |
| 87 | ctrl_outl(value, port); |
Jamie Lenehan | a09749d | 2006-09-27 15:05:39 +0900 | [diff] [blame] | 88 | else |
| 89 | maybebadio(port); |
| 90 | } |
| 91 | |
| 92 | void titan_insl(unsigned long port, void *dst, unsigned long count) |
| 93 | { |
| 94 | maybebadio(port); |
| 95 | } |
| 96 | |
| 97 | void titan_outsl(unsigned long port, const void *src, unsigned long count) |
| 98 | { |
| 99 | maybebadio(port); |
| 100 | } |
| 101 | |
Jamie Lenehan | a09749d | 2006-09-27 15:05:39 +0900 | [diff] [blame] | 102 | void __iomem *titan_ioport_map(unsigned long port, unsigned int size) |
| 103 | { |
Magnus Damm | ef339f2 | 2008-02-19 21:35:22 +0900 | [diff] [blame] | 104 | if (PXSEG(port)) |
Jamie Lenehan | a09749d | 2006-09-27 15:05:39 +0900 | [diff] [blame] | 105 | return (void __iomem *)port; |
Jamie Lenehan | a09749d | 2006-09-27 15:05:39 +0900 | [diff] [blame] | 106 | |
| 107 | return (void __iomem *)port2adr(port); |
| 108 | } |