diff options
author | Maciej W. Rozycki <macro@linux-mips.org> | 2007-02-05 19:28:25 -0500 |
---|---|---|
committer | Ralf Baechle <ralf@linux-mips.org> | 2007-02-09 11:23:15 -0500 |
commit | b454cc6636d254fbf6049b73e9560aee76fb04a3 (patch) | |
tree | 5d3d0067ba49fa9e7bb2d6590db3ef8f3c1f499f /include | |
parent | 5986a2ec35836a878350c54af4bd91b1de6abc59 (diff) |
[TC] MIPS: TURBOchannel update to the driver model
This is a set of changes to convert support for the TURBOchannel bus to the
driver model. It implements the usual set of calls similar to what other bus
drivers have: tc_register_driver(), tc_unregister_driver(), etc. All the
platform-specific bits have been removed and headers from asm-mips/dec/ have
been merged into linux/tc.h, which should be included by drivers.
Signed-off-by: Maciej W. Rozycki <macro@linux-mips.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
Diffstat (limited to 'include')
-rw-r--r-- | include/asm-mips/dec/tc.h | 41 | ||||
-rw-r--r-- | include/asm-mips/dec/tcinfo.h | 47 | ||||
-rw-r--r-- | include/asm-mips/dec/tcmodule.h | 39 | ||||
-rw-r--r-- | include/linux/tc.h | 141 |
4 files changed, 141 insertions, 127 deletions
diff --git a/include/asm-mips/dec/tc.h b/include/asm-mips/dec/tc.h deleted file mode 100644 index 9cb51f24d42c..000000000000 --- a/include/asm-mips/dec/tc.h +++ /dev/null | |||
@@ -1,41 +0,0 @@ | |||
1 | /* | ||
2 | * Interface to the TURBOchannel related routines | ||
3 | * | ||
4 | * This file is subject to the terms and conditions of the GNU General Public | ||
5 | * License. See the file "COPYING" in the main directory of this archive | ||
6 | * for more details. | ||
7 | * | ||
8 | * Copyright (c) 1998 Harald Koerfgen | ||
9 | */ | ||
10 | #ifndef __ASM_DEC_TC_H | ||
11 | #define __ASM_DEC_TC_H | ||
12 | |||
13 | /* | ||
14 | * Search for a TURBOchannel Option Module | ||
15 | * with a certain name. Returns slot number | ||
16 | * of the first card not in use or -ENODEV | ||
17 | * if none found. | ||
18 | */ | ||
19 | extern int search_tc_card(const char *); | ||
20 | /* | ||
21 | * Marks the card in slot as used | ||
22 | */ | ||
23 | extern void claim_tc_card(int); | ||
24 | /* | ||
25 | * Marks the card in slot as free | ||
26 | */ | ||
27 | extern void release_tc_card(int); | ||
28 | /* | ||
29 | * Return base address of card in slot | ||
30 | */ | ||
31 | extern unsigned long get_tc_base_addr(int); | ||
32 | /* | ||
33 | * Return interrupt number of slot | ||
34 | */ | ||
35 | extern unsigned long get_tc_irq_nr(int); | ||
36 | /* | ||
37 | * Return TURBOchannel clock frequency in Hz | ||
38 | */ | ||
39 | extern unsigned long get_tc_speed(void); | ||
40 | |||
41 | #endif /* __ASM_DEC_TC_H */ | ||
diff --git a/include/asm-mips/dec/tcinfo.h b/include/asm-mips/dec/tcinfo.h deleted file mode 100644 index cc23509ee77a..000000000000 --- a/include/asm-mips/dec/tcinfo.h +++ /dev/null | |||
@@ -1,47 +0,0 @@ | |||
1 | /* | ||
2 | * Various TURBOchannel related stuff | ||
3 | * | ||
4 | * This file is subject to the terms and conditions of the GNU General Public | ||
5 | * License. See the file "COPYING" in the main directory of this archive | ||
6 | * for more details. | ||
7 | * | ||
8 | * Information obtained through the get_tcinfo prom call | ||
9 | * created from: | ||
10 | * | ||
11 | * TURBOchannel Firmware Specification | ||
12 | * | ||
13 | * EK-TCAAD-FS-004 | ||
14 | * from Digital Equipment Corporation | ||
15 | * | ||
16 | * Copyright (c) 1998 Harald Koerfgen | ||
17 | */ | ||
18 | |||
19 | typedef struct { | ||
20 | int revision; | ||
21 | int clk_period; | ||
22 | int slot_size; | ||
23 | int io_timeout; | ||
24 | int dma_range; | ||
25 | int max_dma_burst; | ||
26 | int parity; | ||
27 | int reserved[4]; | ||
28 | } tcinfo; | ||
29 | |||
30 | #define MAX_SLOT 7 | ||
31 | |||
32 | typedef struct { | ||
33 | unsigned long base_addr; | ||
34 | unsigned char name[9]; | ||
35 | unsigned char vendor[9]; | ||
36 | unsigned char firmware[9]; | ||
37 | int interrupt; | ||
38 | int flags; | ||
39 | } slot_info; | ||
40 | |||
41 | /* | ||
42 | * Values for flags | ||
43 | */ | ||
44 | #define FREE 1<<0 | ||
45 | #define IN_USE 1<<1 | ||
46 | |||
47 | |||
diff --git a/include/asm-mips/dec/tcmodule.h b/include/asm-mips/dec/tcmodule.h deleted file mode 100644 index 6268e8915d87..000000000000 --- a/include/asm-mips/dec/tcmodule.h +++ /dev/null | |||
@@ -1,39 +0,0 @@ | |||
1 | /* | ||
2 | * This file is subject to the terms and conditions of the GNU General Public | ||
3 | * License. See the file "COPYING" in the main directory of this archive | ||
4 | * for more details. | ||
5 | * | ||
6 | * Offsets for the ROM header locations for | ||
7 | * TURBOchannel cards | ||
8 | * | ||
9 | * created from: | ||
10 | * | ||
11 | * TURBOchannel Firmware Specification | ||
12 | * | ||
13 | * EK-TCAAD-FS-004 | ||
14 | * from Digital Equipment Corporation | ||
15 | * | ||
16 | * Jan.1998 Harald Koerfgen | ||
17 | */ | ||
18 | #ifndef __ASM_DEC_TCMODULE_H | ||
19 | #define __ASM_DEC_TCMODULE_H | ||
20 | |||
21 | #define OLDCARD 0x3c0000 | ||
22 | #define NEWCARD 0x000000 | ||
23 | |||
24 | #define TC_ROM_WIDTH 0x3e0 | ||
25 | #define TC_ROM_STRIDE 0x3e4 | ||
26 | #define TC_ROM_SIZE 0x3e8 | ||
27 | #define TC_SLOT_SIZE 0x3ec | ||
28 | #define TC_PATTERN0 0x3f0 | ||
29 | #define TC_PATTERN1 0x3f4 | ||
30 | #define TC_PATTERN2 0x3f8 | ||
31 | #define TC_PATTERN3 0x3fc | ||
32 | #define TC_FIRM_VER 0x400 | ||
33 | #define TC_VENDOR 0x420 | ||
34 | #define TC_MODULE 0x440 | ||
35 | #define TC_FIRM_TYPE 0x460 | ||
36 | #define TC_FLAGS 0x470 | ||
37 | #define TC_ROM_OBJECTS 0x480 | ||
38 | |||
39 | #endif /* __ASM_DEC_TCMODULE_H */ | ||
diff --git a/include/linux/tc.h b/include/linux/tc.h new file mode 100644 index 000000000000..f92511e57cdb --- /dev/null +++ b/include/linux/tc.h | |||
@@ -0,0 +1,141 @@ | |||
1 | /* | ||
2 | * Interface to the TURBOchannel related routines. | ||
3 | * | ||
4 | * Copyright (c) 1998 Harald Koerfgen | ||
5 | * Copyright (c) 2005 James Simmons | ||
6 | * Copyright (c) 2006 Maciej W. Rozycki | ||
7 | * | ||
8 | * Based on: | ||
9 | * | ||
10 | * "TURBOchannel Firmware Specification", EK-TCAAD-FS-004 | ||
11 | * | ||
12 | * from Digital Equipment Corporation. | ||
13 | * | ||
14 | * This file is subject to the terms and conditions of the GNU | ||
15 | * General Public License. See the file "COPYING" in the main | ||
16 | * directory of this archive for more details. | ||
17 | */ | ||
18 | #ifndef _LINUX_TC_H | ||
19 | #define _LINUX_TC_H | ||
20 | |||
21 | #include <linux/compiler.h> | ||
22 | #include <linux/device.h> | ||
23 | #include <linux/ioport.h> | ||
24 | #include <linux/types.h> | ||
25 | |||
26 | /* | ||
27 | * Offsets for the ROM header locations for TURBOchannel cards. | ||
28 | */ | ||
29 | #define TC_OLDCARD 0x3c0000 | ||
30 | #define TC_NEWCARD 0x000000 | ||
31 | |||
32 | #define TC_ROM_WIDTH 0x3e0 | ||
33 | #define TC_ROM_STRIDE 0x3e4 | ||
34 | #define TC_ROM_SIZE 0x3e8 | ||
35 | #define TC_SLOT_SIZE 0x3ec | ||
36 | #define TC_PATTERN0 0x3f0 | ||
37 | #define TC_PATTERN1 0x3f4 | ||
38 | #define TC_PATTERN2 0x3f8 | ||
39 | #define TC_PATTERN3 0x3fc | ||
40 | #define TC_FIRM_VER 0x400 | ||
41 | #define TC_VENDOR 0x420 | ||
42 | #define TC_MODULE 0x440 | ||
43 | #define TC_FIRM_TYPE 0x460 | ||
44 | #define TC_FLAGS 0x470 | ||
45 | #define TC_ROM_OBJECTS 0x480 | ||
46 | |||
47 | /* | ||
48 | * Information obtained through the get_tcinfo() PROM call. | ||
49 | */ | ||
50 | struct tcinfo { | ||
51 | s32 revision; /* Hardware revision level. */ | ||
52 | s32 clk_period; /* Clock period in nanoseconds. */ | ||
53 | s32 slot_size; /* Slot size in megabytes. */ | ||
54 | s32 io_timeout; /* I/O timeout in cycles. */ | ||
55 | s32 dma_range; /* DMA address range in megabytes. */ | ||
56 | s32 max_dma_burst; /* Maximum DMA burst length. */ | ||
57 | s32 parity; /* System module supports TC parity. */ | ||
58 | s32 reserved[4]; | ||
59 | }; | ||
60 | |||
61 | /* | ||
62 | * TURBOchannel bus. | ||
63 | */ | ||
64 | struct tc_bus { | ||
65 | struct list_head devices; /* List of devices on this bus. */ | ||
66 | struct resource resource[2]; /* Address space routed to this bus. */ | ||
67 | |||
68 | struct device dev; | ||
69 | char name[13]; | ||
70 | resource_size_t slot_base; | ||
71 | resource_size_t ext_slot_base; | ||
72 | resource_size_t ext_slot_size; | ||
73 | int num_tcslots; | ||
74 | struct tcinfo info; | ||
75 | }; | ||
76 | |||
77 | /* | ||
78 | * TURBOchannel device. | ||
79 | */ | ||
80 | struct tc_dev { | ||
81 | struct list_head node; /* Node in list of all TC devices. */ | ||
82 | struct tc_bus *bus; /* Bus this device is on. */ | ||
83 | struct tc_driver *driver; /* Which driver has allocated this | ||
84 | device. */ | ||
85 | struct device dev; /* Generic device interface. */ | ||
86 | struct resource resource; /* Address space of this device. */ | ||
87 | char vendor[9]; | ||
88 | char name[9]; | ||
89 | char firmware[9]; | ||
90 | int interrupt; | ||
91 | int slot; | ||
92 | }; | ||
93 | |||
94 | #define to_tc_dev(n) container_of(n, struct tc_dev, dev) | ||
95 | |||
96 | struct tc_device_id { | ||
97 | char vendor[9]; | ||
98 | char name[9]; | ||
99 | }; | ||
100 | |||
101 | /* | ||
102 | * TURBOchannel driver. | ||
103 | */ | ||
104 | struct tc_driver { | ||
105 | struct list_head node; | ||
106 | const struct tc_device_id *id_table; | ||
107 | struct device_driver driver; | ||
108 | }; | ||
109 | |||
110 | #define to_tc_driver(drv) container_of(drv, struct tc_driver, driver) | ||
111 | |||
112 | /* | ||
113 | * Return TURBOchannel clock frequency in Hz. | ||
114 | */ | ||
115 | static inline unsigned long tc_get_speed(struct tc_bus *tbus) | ||
116 | { | ||
117 | return 100000 * (10000 / (unsigned long)tbus->info.clk_period); | ||
118 | } | ||
119 | |||
120 | #ifdef CONFIG_TC | ||
121 | |||
122 | extern struct bus_type tc_bus_type; | ||
123 | |||
124 | extern int tc_register_driver(struct tc_driver *tdrv); | ||
125 | extern void tc_unregister_driver(struct tc_driver *tdrv); | ||
126 | |||
127 | #else /* !CONFIG_TC */ | ||
128 | |||
129 | static inline int tc_register_driver(struct tc_driver *tdrv) { return 0; } | ||
130 | static inline void tc_unregister_driver(struct tc_driver *tdrv) { } | ||
131 | |||
132 | #endif /* CONFIG_TC */ | ||
133 | |||
134 | /* | ||
135 | * These have to be provided by the architecture. | ||
136 | */ | ||
137 | extern int tc_preadb(u8 *valp, void __iomem *addr); | ||
138 | extern int tc_bus_get_info(struct tc_bus *tbus); | ||
139 | extern void tc_device_get_irq(struct tc_dev *tdev); | ||
140 | |||
141 | #endif /* _LINUX_TC_H */ | ||