Linux-2.6.12-rc2
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / drivers / char / ftape / lowlevel / ftape-init.c
1 /*
2 * Copyright (C) 1993-1996 Bas Laarhoven,
3 * (C) 1996-1997 Claus-Justus Heine.
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2, or (at your option)
8 any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; see the file COPYING. If not, write to
17 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
18
19 *
20 * This file contains the code that interfaces the kernel
21 * for the QIC-40/80/3010/3020 floppy-tape driver for Linux.
22 */
23
24 #include <linux/config.h>
25 #include <linux/module.h>
26 #include <linux/errno.h>
27 #include <linux/fs.h>
28 #include <linux/kernel.h>
29 #include <linux/signal.h>
30 #include <linux/major.h>
31
32 #include <linux/ftape.h>
33 #include <linux/init.h>
34 #include <linux/qic117.h>
35 #ifdef CONFIG_ZFTAPE
36 #include <linux/zftape.h>
37 #endif
38
39 #include "../lowlevel/ftape-init.h"
40 #include "../lowlevel/ftape-io.h"
41 #include "../lowlevel/ftape-read.h"
42 #include "../lowlevel/ftape-write.h"
43 #include "../lowlevel/ftape-ctl.h"
44 #include "../lowlevel/ftape-rw.h"
45 #include "../lowlevel/fdc-io.h"
46 #include "../lowlevel/ftape-buffer.h"
47 #include "../lowlevel/ftape-proc.h"
48 #include "../lowlevel/ftape-tracing.h"
49
50
51 #if defined(MODULE) && !defined(CONFIG_FT_NO_TRACE_AT_ALL)
52 static int ft_tracing = -1;
53 #endif
54
55
56 /* Called by modules package when installing the driver
57 * or by kernel during the initialization phase
58 */
59 static int __init ftape_init(void)
60 {
61 TRACE_FUN(ft_t_flow);
62
63 #ifdef MODULE
64 #ifndef CONFIG_FT_NO_TRACE_AT_ALL
65 if (ft_tracing != -1) {
66 ftape_tracing = ft_tracing;
67 }
68 #endif
69 printk(KERN_INFO FTAPE_VERSION "\n");
70 if (TRACE_LEVEL >= ft_t_info) {
71 printk(
72 KERN_INFO "(c) 1993-1996 Bas Laarhoven (bas@vimec.nl)\n"
73 KERN_INFO "(c) 1995-1996 Kai Harrekilde-Petersen (khp@dolphinics.no)\n"
74 KERN_INFO "(c) 1996-1997 Claus-Justus Heine (claus@momo.math.rwth-aachen.de)\n"
75 KERN_INFO "QIC-117 driver for QIC-40/80/3010/3020 floppy tape drives\n");
76 }
77 #else /* !MODULE */
78 /* print a short no-nonsense boot message */
79 printk(KERN_INFO FTAPE_VERSION "\n");
80 #endif /* MODULE */
81 TRACE(ft_t_info, "installing QIC-117 floppy tape hardware drive ... ");
82 TRACE(ft_t_info, "ftape_init @ 0x%p", ftape_init);
83 /* Allocate the DMA buffers. They are deallocated at cleanup() time.
84 */
85 #ifdef TESTING
86 #ifdef MODULE
87 while (ftape_set_nr_buffers(CONFIG_FT_NR_BUFFERS) < 0) {
88 ftape_sleep(FT_SECOND/20);
89 if (signal_pending(current)) {
90 (void)ftape_set_nr_buffers(0);
91 TRACE(ft_t_bug,
92 "Killed by signal while allocating buffers.");
93 TRACE_ABORT(-EINTR,
94 ft_t_bug, "Free up memory and retry");
95 }
96 }
97 #else
98 TRACE_CATCH(ftape_set_nr_buffers(CONFIG_FT_NR_BUFFERS),
99 (void)ftape_set_nr_buffers(0));
100 #endif
101 #else
102 TRACE_CATCH(ftape_set_nr_buffers(CONFIG_FT_NR_BUFFERS),
103 (void)ftape_set_nr_buffers(0));
104 #endif
105 ft_drive_sel = -1;
106 ft_failure = 1; /* inhibit any operation but open */
107 ftape_udelay_calibrate(); /* must be before fdc_wait_calibrate ! */
108 fdc_wait_calibrate();
109 #if defined(CONFIG_PROC_FS) && defined(CONFIG_FT_PROC_FS)
110 (void)ftape_proc_init();
111 #endif
112 #ifdef CONFIG_ZFTAPE
113 (void)zft_init();
114 #endif
115 TRACE_EXIT 0;
116 }
117
118 module_param(ft_fdc_base, uint, 0);
119 MODULE_PARM_DESC(ft_fdc_base, "Base address of FDC controller.");
120 module_param(ft_fdc_irq, uint, 0);
121 MODULE_PARM_DESC(ft_fdc_irq, "IRQ (interrupt channel) to use.");
122 module_param(ft_fdc_dma, uint, 0);
123 MODULE_PARM_DESC(ft_fdc_dma, "DMA channel to use.");
124 module_param(ft_fdc_threshold, uint, 0);
125 MODULE_PARM_DESC(ft_fdc_threshold, "Threshold of the FDC Fifo.");
126 module_param(ft_fdc_rate_limit, uint, 0);
127 MODULE_PARM_DESC(ft_fdc_rate_limit, "Maximal data rate for FDC.");
128 module_param(ft_probe_fc10, bool, 0);
129 MODULE_PARM_DESC(ft_probe_fc10,
130 "If non-zero, probe for a Colorado FC-10/FC-20 controller.");
131 module_param(ft_mach2, bool, 0);
132 MODULE_PARM_DESC(ft_mach2,
133 "If non-zero, probe for a Mountain MACH-2 controller.");
134 #if defined(MODULE) && !defined(CONFIG_FT_NO_TRACE_AT_ALL)
135 module_param(ft_tracing, int, 0644);
136 MODULE_PARM_DESC(ft_tracing,
137 "Amount of debugging output, 0 <= tracing <= 8, default 3.");
138 #endif
139
140 MODULE_AUTHOR(
141 "(c) 1993-1996 Bas Laarhoven (bas@vimec.nl), "
142 "(c) 1995-1996 Kai Harrekilde-Petersen (khp@dolphinics.no), "
143 "(c) 1996, 1997 Claus-Justus Heine (claus@momo.math.rwth-aachen.de)");
144 MODULE_DESCRIPTION(
145 "QIC-117 driver for QIC-40/80/3010/3020 floppy tape drives.");
146 MODULE_LICENSE("GPL");
147
148 static void __exit ftape_exit(void)
149 {
150 TRACE_FUN(ft_t_flow);
151
152 #if defined(CONFIG_PROC_FS) && defined(CONFIG_FT_PROC_FS)
153 ftape_proc_destroy();
154 #endif
155 (void)ftape_set_nr_buffers(0);
156 printk(KERN_INFO "ftape: unloaded.\n");
157 TRACE_EXIT;
158 }
159
160 module_init(ftape_init);
161 module_exit(ftape_exit);