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> |
| 7 | #include <asm/titan.h> |
| 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); |
Paul Mundt | 959f85f | 2006-09-27 16:43:28 +0900 | [diff] [blame] | 20 | else if (is_pci_ioaddr(port)) |
| 21 | return ctrl_inb(pci_ioaddr(port)); |
Jamie Lenehan | a09749d | 2006-09-27 15:05:39 +0900 | [diff] [blame] | 22 | return ctrl_inw(port2adr(port)) & 0xff; |
| 23 | } |
| 24 | |
| 25 | u8 titan_inb_p(unsigned long port) |
| 26 | { |
| 27 | u8 v; |
| 28 | |
| 29 | if (PXSEG(port)) |
| 30 | v = ctrl_inb(port); |
Paul Mundt | 959f85f | 2006-09-27 16:43:28 +0900 | [diff] [blame] | 31 | else if (is_pci_ioaddr(port)) |
| 32 | v = ctrl_inb(pci_ioaddr(port)); |
Jamie Lenehan | a09749d | 2006-09-27 15:05:39 +0900 | [diff] [blame] | 33 | else |
| 34 | v = ctrl_inw(port2adr(port)) & 0xff; |
Paul Mundt | 959f85f | 2006-09-27 16:43:28 +0900 | [diff] [blame] | 35 | ctrl_delay(); |
Jamie Lenehan | a09749d | 2006-09-27 15:05:39 +0900 | [diff] [blame] | 36 | return v; |
| 37 | } |
| 38 | |
| 39 | u16 titan_inw(unsigned long port) |
| 40 | { |
| 41 | if (PXSEG(port)) |
| 42 | return ctrl_inw(port); |
Paul Mundt | 959f85f | 2006-09-27 16:43:28 +0900 | [diff] [blame] | 43 | else if (is_pci_ioaddr(port)) |
| 44 | return ctrl_inw(pci_ioaddr(port)); |
Jamie Lenehan | a09749d | 2006-09-27 15:05:39 +0900 | [diff] [blame] | 45 | else if (port >= 0x2000) |
| 46 | return ctrl_inw(port2adr(port)); |
| 47 | else |
| 48 | maybebadio(port); |
| 49 | return 0; |
| 50 | } |
| 51 | |
| 52 | u32 titan_inl(unsigned long port) |
| 53 | { |
| 54 | if (PXSEG(port)) |
| 55 | return ctrl_inl(port); |
Paul Mundt | 959f85f | 2006-09-27 16:43:28 +0900 | [diff] [blame] | 56 | else if (is_pci_ioaddr(port)) |
| 57 | return ctrl_inl(pci_ioaddr(port)); |
Jamie Lenehan | a09749d | 2006-09-27 15:05:39 +0900 | [diff] [blame] | 58 | else if (port >= 0x2000) |
| 59 | return ctrl_inw(port2adr(port)); |
| 60 | else |
| 61 | maybebadio(port); |
| 62 | return 0; |
| 63 | } |
| 64 | |
| 65 | void titan_outb(u8 value, unsigned long port) |
| 66 | { |
| 67 | if (PXSEG(port)) |
| 68 | ctrl_outb(value, port); |
Paul Mundt | 959f85f | 2006-09-27 16:43:28 +0900 | [diff] [blame] | 69 | else if (is_pci_ioaddr(port)) |
| 70 | ctrl_outb(value, pci_ioaddr(port)); |
Jamie Lenehan | a09749d | 2006-09-27 15:05:39 +0900 | [diff] [blame] | 71 | else |
| 72 | ctrl_outw(value, port2adr(port)); |
| 73 | } |
| 74 | |
| 75 | void titan_outb_p(u8 value, unsigned long port) |
| 76 | { |
| 77 | if (PXSEG(port)) |
| 78 | ctrl_outb(value, port); |
Paul Mundt | 959f85f | 2006-09-27 16:43:28 +0900 | [diff] [blame] | 79 | else if (is_pci_ioaddr(port)) |
| 80 | ctrl_outb(value, pci_ioaddr(port)); |
Jamie Lenehan | a09749d | 2006-09-27 15:05:39 +0900 | [diff] [blame] | 81 | else |
| 82 | ctrl_outw(value, port2adr(port)); |
Paul Mundt | 959f85f | 2006-09-27 16:43:28 +0900 | [diff] [blame] | 83 | ctrl_delay(); |
Jamie Lenehan | a09749d | 2006-09-27 15:05:39 +0900 | [diff] [blame] | 84 | } |
| 85 | |
| 86 | void titan_outw(u16 value, unsigned long port) |
| 87 | { |
| 88 | if (PXSEG(port)) |
| 89 | ctrl_outw(value, port); |
Paul Mundt | 959f85f | 2006-09-27 16:43:28 +0900 | [diff] [blame] | 90 | else if (is_pci_ioaddr(port)) |
| 91 | ctrl_outw(value, pci_ioaddr(port)); |
Jamie Lenehan | a09749d | 2006-09-27 15:05:39 +0900 | [diff] [blame] | 92 | else if (port >= 0x2000) |
| 93 | ctrl_outw(value, port2adr(port)); |
| 94 | else |
| 95 | maybebadio(port); |
| 96 | } |
| 97 | |
| 98 | void titan_outl(u32 value, unsigned long port) |
| 99 | { |
| 100 | if (PXSEG(port)) |
| 101 | ctrl_outl(value, port); |
Paul Mundt | 959f85f | 2006-09-27 16:43:28 +0900 | [diff] [blame] | 102 | else if (is_pci_ioaddr(port)) |
| 103 | ctrl_outl(value, pci_ioaddr(port)); |
Jamie Lenehan | a09749d | 2006-09-27 15:05:39 +0900 | [diff] [blame] | 104 | else |
| 105 | maybebadio(port); |
| 106 | } |
| 107 | |
| 108 | void titan_insl(unsigned long port, void *dst, unsigned long count) |
| 109 | { |
| 110 | maybebadio(port); |
| 111 | } |
| 112 | |
| 113 | void titan_outsl(unsigned long port, const void *src, unsigned long count) |
| 114 | { |
| 115 | maybebadio(port); |
| 116 | } |
| 117 | |
Jamie Lenehan | a09749d | 2006-09-27 15:05:39 +0900 | [diff] [blame] | 118 | void __iomem *titan_ioport_map(unsigned long port, unsigned int size) |
| 119 | { |
Paul Mundt | 959f85f | 2006-09-27 16:43:28 +0900 | [diff] [blame] | 120 | if (PXSEG(port) || is_pci_memaddr(port)) |
Jamie Lenehan | a09749d | 2006-09-27 15:05:39 +0900 | [diff] [blame] | 121 | return (void __iomem *)port; |
Paul Mundt | 959f85f | 2006-09-27 16:43:28 +0900 | [diff] [blame] | 122 | else if (is_pci_ioaddr(port)) |
| 123 | return (void __iomem *)pci_ioaddr(port); |
Jamie Lenehan | a09749d | 2006-09-27 15:05:39 +0900 | [diff] [blame] | 124 | |
| 125 | return (void __iomem *)port2adr(port); |
| 126 | } |