3 * helper for define functions to access ISDN hardware
4 * supported are memory mapped IO
5 * indirect port IO (one port for address, one for data)
7 * Author Karsten Keil <keil@isdn4linux.de>
9 * Copyright 2009 by Karsten Keil <keil@isdn4linux.de>
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License version 2 as
13 * published by the Free Software Foundation.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
29 typedef u8 (read_reg_func
)(void *hwp
, u8 offset
);
30 typedef void (write_reg_func
)(void *hwp
, u8 offset
, u8 value
);
31 typedef void (fifo_func
)(void *hwp
, u8 offset
, u8
*datap
, int size
);
38 #define IOFUNC_IO(name, hws, ap) \
39 static u8 Read##name##_IO(void *p, u8 off) { \
41 return inb(hw->ap.port + off); \
43 static void Write##name##_IO(void *p, u8 off, u8 val) { \
45 outb(val, hw->ap.port + off); \
47 static void ReadFiFo##name##_IO(void *p, u8 off, u8 *dp, int size) { \
49 insb(hw->ap.port + off, dp, size); \
51 static void WriteFiFo##name##_IO(void *p, u8 off, u8 *dp, int size) { \
53 outsb(hw->ap.port + off, dp, size); \
56 #define IOFUNC_IND(name, hws, ap) \
57 static u8 Read##name##_IND(void *p, u8 off) { \
59 outb(off, hw->ap.ale); \
60 return inb(hw->ap.port); \
62 static void Write##name##_IND(void *p, u8 off, u8 val) { \
64 outb(off, hw->ap.ale); \
65 outb(val, hw->ap.port); \
67 static void ReadFiFo##name##_IND(void *p, u8 off, u8 *dp, int size) { \
69 outb(off, hw->ap.ale); \
70 insb(hw->ap.port, dp, size); \
72 static void WriteFiFo##name##_IND(void *p, u8 off, u8 *dp, int size) { \
74 outb(off, hw->ap.ale); \
75 outsb(hw->ap.port, dp, size); \
78 #define IOFUNC_MEMIO(name, hws, typ, adr) \
79 static u8 Read##name##_MIO(void *p, u8 off) { \
81 return readb(((typ *)hw->adr) + off); \
83 static void Write##name##_MIO(void *p, u8 off, u8 val) { \
85 writeb(val, ((typ *)hw->adr) + off); \
87 static void ReadFiFo##name##_MIO(void *p, u8 off, u8 *dp, int size) { \
90 *dp++ = readb(((typ *)hw->adr) + off); \
92 static void WriteFiFo##name##_MIO(void *p, u8 off, u8 *dp, int size) { \
95 writeb(*dp++, ((typ *)hw->adr) + off); \
98 #define ASSIGN_FUNC(typ, name, dest) do { \
99 dest.read_reg = &Read##name##_##typ; \
100 dest.write_reg = &Write##name##_##typ; \
101 dest.read_fifo = &ReadFiFo##name##_##typ; \
102 dest.write_fifo = &WriteFiFo##name##_##typ; \
104 #define ASSIGN_FUNC_IPAC(typ, target) do { \
105 ASSIGN_FUNC(typ, ISAC, target.isac); \
106 ASSIGN_FUNC(typ, IPAC, target); \