rio_linux.c 32 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204
  1. /* rio_linux.c -- Linux driver for the Specialix RIO series cards.
  2. *
  3. *
  4. * (C) 1999 R.E.Wolff@BitWizard.nl
  5. *
  6. * Specialix pays for the development and support of this driver.
  7. * Please DO contact support@specialix.co.uk if you require
  8. * support. But please read the documentation (rio.txt) first.
  9. *
  10. *
  11. *
  12. * This program is free software; you can redistribute it and/or
  13. * modify it under the terms of the GNU General Public License as
  14. * published by the Free Software Foundation; either version 2 of
  15. * the License, or (at your option) any later version.
  16. *
  17. * This program is distributed in the hope that it will be
  18. * useful, but WITHOUT ANY WARRANTY; without even the implied
  19. * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
  20. * PURPOSE. See the GNU General Public License for more details.
  21. *
  22. * You should have received a copy of the GNU General Public
  23. * License along with this program; if not, write to the Free
  24. * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139,
  25. * USA.
  26. *
  27. * Revision history:
  28. * $Log: rio.c,v $
  29. * Revision 1.1 1999/07/11 10:13:54 wolff
  30. * Initial revision
  31. *
  32. * */
  33. #include <linux/module.h>
  34. #include <linux/config.h>
  35. #include <linux/kdev_t.h>
  36. #include <asm/io.h>
  37. #include <linux/kernel.h>
  38. #include <linux/sched.h>
  39. #include <linux/ioport.h>
  40. #include <linux/interrupt.h>
  41. #include <linux/errno.h>
  42. #include <linux/tty.h>
  43. #include <linux/tty_flip.h>
  44. #include <linux/mm.h>
  45. #include <linux/serial.h>
  46. #include <linux/fcntl.h>
  47. #include <linux/major.h>
  48. #include <linux/delay.h>
  49. #include <linux/pci.h>
  50. #include <linux/slab.h>
  51. #include <linux/miscdevice.h>
  52. #include <linux/init.h>
  53. #include <linux/generic_serial.h>
  54. #include <asm/uaccess.h>
  55. #include "linux_compat.h"
  56. #include "pkt.h"
  57. #include "daemon.h"
  58. #include "rio.h"
  59. #include "riospace.h"
  60. #include "cmdpkt.h"
  61. #include "map.h"
  62. #include "rup.h"
  63. #include "port.h"
  64. #include "riodrvr.h"
  65. #include "rioinfo.h"
  66. #include "func.h"
  67. #include "errors.h"
  68. #include "pci.h"
  69. #include "parmmap.h"
  70. #include "unixrup.h"
  71. #include "board.h"
  72. #include "host.h"
  73. #include "phb.h"
  74. #include "link.h"
  75. #include "cmdblk.h"
  76. #include "route.h"
  77. #include "cirrus.h"
  78. #include "rioioctl.h"
  79. #include "param.h"
  80. #include "protsts.h"
  81. #include "rioboard.h"
  82. #include "rio_linux.h"
  83. /* I don't think that this driver can handle more than 512 ports on
  84. one machine. Specialix specifies max 4 boards in one machine. I don't
  85. know why. If you want to try anyway you'll have to increase the number
  86. of boards in rio.h. You'll have to allocate more majors if you need
  87. more than 512 ports.... */
  88. #ifndef RIO_NORMAL_MAJOR0
  89. /* This allows overriding on the compiler commandline, or in a "major.h"
  90. include or something like that */
  91. #define RIO_NORMAL_MAJOR0 154
  92. #define RIO_NORMAL_MAJOR1 156
  93. #endif
  94. #ifndef PCI_DEVICE_ID_SPECIALIX_SX_XIO_IO8
  95. #define PCI_DEVICE_ID_SPECIALIX_SX_XIO_IO8 0x2000
  96. #endif
  97. #ifndef RIO_WINDOW_LEN
  98. #define RIO_WINDOW_LEN 0x10000
  99. #endif
  100. /* Configurable options:
  101. (Don't be too sure that it'll work if you toggle them) */
  102. /* Am I paranoid or not ? ;-) */
  103. #undef RIO_PARANOIA_CHECK
  104. /* 20 -> 2000 per second. The card should rate-limit interrupts at 1000
  105. Hz, but it is user configurable. I don't recommend going above 1000
  106. Hz. The interrupt ratelimit might trigger if the interrupt is
  107. shared with a very active other device.
  108. undef this if you want to disable the check....
  109. */
  110. #define IRQ_RATE_LIMIT 200
  111. /* These constants are derived from SCO Source */
  112. static struct Conf
  113. RIOConf = {
  114. /* locator */ "RIO Config here",
  115. /* startuptime */ HZ * 2,
  116. /* how long to wait for card to run */
  117. /* slowcook */ 0,
  118. /* TRUE -> always use line disc. */
  119. /* intrpolltime */ 1,
  120. /* The frequency of OUR polls */
  121. /* breakinterval */ 25,
  122. /* x10 mS XXX: units seem to be 1ms not 10! -- REW */
  123. /* timer */ 10,
  124. /* mS */
  125. /* RtaLoadBase */ 0x7000,
  126. /* HostLoadBase */ 0x7C00,
  127. /* XpHz */ 5,
  128. /* number of Xprint hits per second */
  129. /* XpCps */ 120,
  130. /* Xprint characters per second */
  131. /* XpOn */ "\033d#",
  132. /* start Xprint for a wyse 60 */
  133. /* XpOff */ "\024",
  134. /* end Xprint for a wyse 60 */
  135. /* MaxXpCps */ 2000,
  136. /* highest Xprint speed */
  137. /* MinXpCps */ 10,
  138. /* slowest Xprint speed */
  139. /* SpinCmds */ 1,
  140. /* non-zero for mega fast boots */
  141. /* First Addr */ 0x0A0000,
  142. /* First address to look at */
  143. /* Last Addr */ 0xFF0000,
  144. /* Last address looked at */
  145. /* BufferSize */ 1024,
  146. /* Bytes per port of buffering */
  147. /* LowWater */ 256,
  148. /* how much data left before wakeup */
  149. /* LineLength */ 80,
  150. /* how wide is the console? */
  151. /* CmdTimeout */ HZ,
  152. /* how long a close command may take */
  153. };
  154. /* Function prototypes */
  155. static void rio_disable_tx_interrupts(void *ptr);
  156. static void rio_enable_tx_interrupts(void *ptr);
  157. static void rio_disable_rx_interrupts(void *ptr);
  158. static void rio_enable_rx_interrupts(void *ptr);
  159. static int rio_get_CD(void *ptr);
  160. static void rio_shutdown_port(void *ptr);
  161. static int rio_set_real_termios(void *ptr);
  162. static void rio_hungup(void *ptr);
  163. static void rio_close(void *ptr);
  164. static int rio_chars_in_buffer(void *ptr);
  165. static int rio_fw_ioctl(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg);
  166. static int rio_init_drivers(void);
  167. static void my_hd(void *addr, int len);
  168. static struct tty_driver *rio_driver, *rio_driver2;
  169. /* The name "p" is a bit non-descript. But that's what the rio-lynxos
  170. sources use all over the place. */
  171. struct rio_info *p;
  172. int rio_debug;
  173. /* You can have the driver poll your card.
  174. - Set rio_poll to 1 to poll every timer tick (10ms on Intel).
  175. This is used when the card cannot use an interrupt for some reason.
  176. */
  177. static int rio_poll = 1;
  178. /* These are the only open spaces in my computer. Yours may have more
  179. or less.... */
  180. static int rio_probe_addrs[] = { 0xc0000, 0xd0000, 0xe0000 };
  181. #define NR_RIO_ADDRS ARRAY_SIZE(rio_probe_addrs)
  182. /* Set the mask to all-ones. This alas, only supports 32 interrupts.
  183. Some architectures may need more. -- Changed to LONG to
  184. support up to 64 bits on 64bit architectures. -- REW 20/06/99 */
  185. static long rio_irqmask = -1;
  186. MODULE_AUTHOR("Rogier Wolff <R.E.Wolff@bitwizard.nl>, Patrick van de Lageweg <patrick@bitwizard.nl>");
  187. MODULE_DESCRIPTION("RIO driver");
  188. MODULE_LICENSE("GPL");
  189. module_param(rio_poll, int, 0);
  190. module_param(rio_debug, int, 0644);
  191. module_param(rio_irqmask, long, 0);
  192. static struct real_driver rio_real_driver = {
  193. rio_disable_tx_interrupts,
  194. rio_enable_tx_interrupts,
  195. rio_disable_rx_interrupts,
  196. rio_enable_rx_interrupts,
  197. rio_get_CD,
  198. rio_shutdown_port,
  199. rio_set_real_termios,
  200. rio_chars_in_buffer,
  201. rio_close,
  202. rio_hungup,
  203. NULL
  204. };
  205. /*
  206. * Firmware loader driver specific routines
  207. *
  208. */
  209. static struct file_operations rio_fw_fops = {
  210. .owner = THIS_MODULE,
  211. .ioctl = rio_fw_ioctl,
  212. };
  213. static struct miscdevice rio_fw_device = {
  214. RIOCTL_MISC_MINOR, "rioctl", &rio_fw_fops
  215. };
  216. #ifdef RIO_PARANOIA_CHECK
  217. /* This doesn't work. Who's paranoid around here? Not me! */
  218. static inline int rio_paranoia_check(struct rio_port const *port, char *name, const char *routine)
  219. {
  220. static const char *badmagic = KERN_ERR "rio: Warning: bad rio port magic number for device %s in %s\n";
  221. static const char *badinfo = KERN_ERR "rio: Warning: null rio port for device %s in %s\n";
  222. if (!port) {
  223. printk(badinfo, name, routine);
  224. return 1;
  225. }
  226. if (port->magic != RIO_MAGIC) {
  227. printk(badmagic, name, routine);
  228. return 1;
  229. }
  230. return 0;
  231. }
  232. #else
  233. #define rio_paranoia_check(a,b,c) 0
  234. #endif
  235. #ifdef DEBUG
  236. static void my_hd(void *ad, int len)
  237. {
  238. int i, j, ch;
  239. unsigned char *addr = ad;
  240. for (i = 0; i < len; i += 16) {
  241. rio_dprintk(RIO_DEBUG_PARAM, "%08lx ", (unsigned long) addr + i);
  242. for (j = 0; j < 16; j++) {
  243. rio_dprintk(RIO_DEBUG_PARAM, "%02x %s", addr[j + i], (j == 7) ? " " : "");
  244. }
  245. for (j = 0; j < 16; j++) {
  246. ch = addr[j + i];
  247. rio_dprintk(RIO_DEBUG_PARAM, "%c", (ch < 0x20) ? '.' : ((ch > 0x7f) ? '.' : ch));
  248. }
  249. rio_dprintk(RIO_DEBUG_PARAM, "\n");
  250. }
  251. }
  252. #else
  253. #define my_hd(ad,len) do{/* nothing*/ } while (0)
  254. #endif
  255. /* Delay a number of jiffies, allowing a signal to interrupt */
  256. int RIODelay(struct Port *PortP, int njiffies)
  257. {
  258. func_enter();
  259. rio_dprintk(RIO_DEBUG_DELAY, "delaying %d jiffies\n", njiffies);
  260. msleep_interruptible(jiffies_to_msecs(njiffies));
  261. func_exit();
  262. if (signal_pending(current))
  263. return RIO_FAIL;
  264. else
  265. return !RIO_FAIL;
  266. }
  267. /* Delay a number of jiffies, disallowing a signal to interrupt */
  268. int RIODelay_ni(struct Port *PortP, int njiffies)
  269. {
  270. func_enter();
  271. rio_dprintk(RIO_DEBUG_DELAY, "delaying %d jiffies (ni)\n", njiffies);
  272. msleep(jiffies_to_msecs(njiffies));
  273. func_exit();
  274. return !RIO_FAIL;
  275. }
  276. void rio_copy_to_card(void *to, void *from, int len)
  277. {
  278. rio_memcpy_toio(NULL, to, from, len);
  279. }
  280. int rio_minor(struct tty_struct *tty)
  281. {
  282. return tty->index + (tty->driver == rio_driver) ? 0 : 256;
  283. }
  284. static int rio_set_real_termios(void *ptr)
  285. {
  286. return RIOParam((struct Port *) ptr, CONFIG, 1, 1);
  287. }
  288. static void rio_reset_interrupt(struct Host *HostP)
  289. {
  290. func_enter();
  291. switch (HostP->Type) {
  292. case RIO_AT:
  293. case RIO_MCA:
  294. case RIO_PCI:
  295. writeb(0xFF, &HostP->ResetInt);
  296. }
  297. func_exit();
  298. }
  299. static irqreturn_t rio_interrupt(int irq, void *ptr, struct pt_regs *regs)
  300. {
  301. struct Host *HostP;
  302. func_enter();
  303. HostP = (struct Host *) ptr; /* &p->RIOHosts[(long)ptr]; */
  304. rio_dprintk(RIO_DEBUG_IFLOW, "rio: enter rio_interrupt (%d/%d)\n", irq, HostP->Ivec);
  305. /* AAargh! The order in which to do these things is essential and
  306. not trivial.
  307. - hardware twiddling goes before "recursive". Otherwise when we
  308. poll the card, and a recursive interrupt happens, we won't
  309. ack the card, so it might keep on interrupting us. (especially
  310. level sensitive interrupt systems like PCI).
  311. - Rate limit goes before hardware twiddling. Otherwise we won't
  312. catch a card that has gone bonkers.
  313. - The "initialized" test goes after the hardware twiddling. Otherwise
  314. the card will stick us in the interrupt routine again.
  315. - The initialized test goes before recursive.
  316. */
  317. rio_dprintk(RIO_DEBUG_IFLOW, "rio: We've have noticed the interrupt\n");
  318. if (HostP->Ivec == irq) {
  319. /* Tell the card we've noticed the interrupt. */
  320. rio_reset_interrupt(HostP);
  321. }
  322. if ((HostP->Flags & RUN_STATE) != RC_RUNNING)
  323. return IRQ_HANDLED;
  324. if (test_and_set_bit(RIO_BOARD_INTR_LOCK, &HostP->locks)) {
  325. printk(KERN_ERR "Recursive interrupt! (host %p/irq%d)\n", ptr, HostP->Ivec);
  326. return IRQ_HANDLED;
  327. }
  328. RIOServiceHost(p, HostP, irq);
  329. rio_dprintk(RIO_DEBUG_IFLOW, "riointr() doing host %p type %d\n", ptr, HostP->Type);
  330. clear_bit(RIO_BOARD_INTR_LOCK, &HostP->locks);
  331. rio_dprintk(RIO_DEBUG_IFLOW, "rio: exit rio_interrupt (%d/%d)\n", irq, HostP->Ivec);
  332. func_exit();
  333. return IRQ_HANDLED;
  334. }
  335. static void rio_pollfunc(unsigned long data)
  336. {
  337. func_enter();
  338. rio_interrupt(0, &p->RIOHosts[data], NULL);
  339. p->RIOHosts[data].timer.expires = jiffies + rio_poll;
  340. add_timer(&p->RIOHosts[data].timer);
  341. func_exit();
  342. }
  343. /* ********************************************************************** *
  344. * Here are the routines that actually *
  345. * interface with the generic_serial driver *
  346. * ********************************************************************** */
  347. /* Ehhm. I don't know how to fiddle with interrupts on the Specialix
  348. cards. .... Hmm. Ok I figured it out. You don't. -- REW */
  349. static void rio_disable_tx_interrupts(void *ptr)
  350. {
  351. func_enter();
  352. /* port->gs.flags &= ~GS_TX_INTEN; */
  353. func_exit();
  354. }
  355. static void rio_enable_tx_interrupts(void *ptr)
  356. {
  357. struct Port *PortP = ptr;
  358. /* int hn; */
  359. func_enter();
  360. /* hn = PortP->HostP - p->RIOHosts;
  361. rio_dprintk (RIO_DEBUG_TTY, "Pushing host %d\n", hn);
  362. rio_interrupt (-1,(void *) hn, NULL); */
  363. RIOTxEnable((char *) PortP);
  364. /*
  365. * In general we cannot count on "tx empty" interrupts, although
  366. * the interrupt routine seems to be able to tell the difference.
  367. */
  368. PortP->gs.flags &= ~GS_TX_INTEN;
  369. func_exit();
  370. }
  371. static void rio_disable_rx_interrupts(void *ptr)
  372. {
  373. func_enter();
  374. func_exit();
  375. }
  376. static void rio_enable_rx_interrupts(void *ptr)
  377. {
  378. /* struct rio_port *port = ptr; */
  379. func_enter();
  380. func_exit();
  381. }
  382. /* Jeez. Isn't this simple? */
  383. static int rio_get_CD(void *ptr)
  384. {
  385. struct Port *PortP = ptr;
  386. int rv;
  387. func_enter();
  388. rv = (PortP->ModemState & MSVR1_CD) != 0;
  389. rio_dprintk(RIO_DEBUG_INIT, "Getting CD status: %d\n", rv);
  390. func_exit();
  391. return rv;
  392. }
  393. /* Jeez. Isn't this simple? Actually, we can sync with the actual port
  394. by just pushing stuff into the queue going to the port... */
  395. static int rio_chars_in_buffer(void *ptr)
  396. {
  397. func_enter();
  398. func_exit();
  399. return 0;
  400. }
  401. /* Nothing special here... */
  402. static void rio_shutdown_port(void *ptr)
  403. {
  404. struct Port *PortP;
  405. func_enter();
  406. PortP = (struct Port *) ptr;
  407. PortP->gs.tty = NULL;
  408. func_exit();
  409. }
  410. /* I haven't the foggiest why the decrement use count has to happen
  411. here. The whole linux serial drivers stuff needs to be redesigned.
  412. My guess is that this is a hack to minimize the impact of a bug
  413. elsewhere. Thinking about it some more. (try it sometime) Try
  414. running minicom on a serial port that is driven by a modularized
  415. driver. Have the modem hangup. Then remove the driver module. Then
  416. exit minicom. I expect an "oops". -- REW */
  417. static void rio_hungup(void *ptr)
  418. {
  419. struct Port *PortP;
  420. func_enter();
  421. PortP = (struct Port *) ptr;
  422. PortP->gs.tty = NULL;
  423. func_exit();
  424. }
  425. /* The standard serial_close would become shorter if you'd wrap it like
  426. this.
  427. rs_close (...){save_flags;cli;real_close();dec_use_count;restore_flags;}
  428. */
  429. static void rio_close(void *ptr)
  430. {
  431. struct Port *PortP;
  432. func_enter();
  433. PortP = (struct Port *) ptr;
  434. riotclose(ptr);
  435. if (PortP->gs.count) {
  436. printk(KERN_ERR "WARNING port count:%d\n", PortP->gs.count);
  437. PortP->gs.count = 0;
  438. }
  439. PortP->gs.tty = NULL;
  440. func_exit();
  441. }
  442. static int rio_fw_ioctl(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg)
  443. {
  444. int rc = 0;
  445. func_enter();
  446. /* The "dev" argument isn't used. */
  447. rc = riocontrol(p, 0, cmd, (void *) arg, capable(CAP_SYS_ADMIN));
  448. func_exit();
  449. return rc;
  450. }
  451. extern int RIOShortCommand(struct rio_info *p, struct Port *PortP, int command, int len, int arg);
  452. static int rio_ioctl(struct tty_struct *tty, struct file *filp, unsigned int cmd, unsigned long arg)
  453. {
  454. int rc;
  455. struct Port *PortP;
  456. int ival;
  457. func_enter();
  458. PortP = (struct Port *) tty->driver_data;
  459. rc = 0;
  460. switch (cmd) {
  461. case TIOCSSOFTCAR:
  462. if ((rc = get_user(ival, (unsigned int *) arg)) == 0) {
  463. tty->termios->c_cflag = (tty->termios->c_cflag & ~CLOCAL) | (ival ? CLOCAL : 0);
  464. }
  465. break;
  466. case TIOCGSERIAL:
  467. rc = -EFAULT;
  468. if (access_ok(VERIFY_WRITE, (void *) arg, sizeof(struct serial_struct)))
  469. rc = gs_getserial(&PortP->gs, (struct serial_struct *) arg);
  470. break;
  471. case TCSBRK:
  472. if (PortP->State & RIO_DELETED) {
  473. rio_dprintk(RIO_DEBUG_TTY, "BREAK on deleted RTA\n");
  474. rc = -EIO;
  475. } else {
  476. if (RIOShortCommand(p, PortP, SBREAK, 2, 250) == RIO_FAIL) {
  477. rio_dprintk(RIO_DEBUG_INTR, "SBREAK RIOShortCommand failed\n");
  478. rc = -EIO;
  479. }
  480. }
  481. break;
  482. case TCSBRKP:
  483. if (PortP->State & RIO_DELETED) {
  484. rio_dprintk(RIO_DEBUG_TTY, "BREAK on deleted RTA\n");
  485. rc = -EIO;
  486. } else {
  487. int l;
  488. l = arg ? arg * 100 : 250;
  489. if (l > 255)
  490. l = 255;
  491. if (RIOShortCommand(p, PortP, SBREAK, 2, arg ? arg * 100 : 250) == RIO_FAIL) {
  492. rio_dprintk(RIO_DEBUG_INTR, "SBREAK RIOShortCommand failed\n");
  493. rc = -EIO;
  494. }
  495. }
  496. break;
  497. case TIOCSSERIAL:
  498. rc = -EFAULT;
  499. if (access_ok(VERIFY_READ, (void *) arg, sizeof(struct serial_struct)))
  500. rc = gs_setserial(&PortP->gs, (struct serial_struct *) arg);
  501. break;
  502. default:
  503. rc = -ENOIOCTLCMD;
  504. break;
  505. }
  506. func_exit();
  507. return rc;
  508. }
  509. /* The throttle/unthrottle scheme for the Specialix card is different
  510. * from other drivers and deserves some explanation.
  511. * The Specialix hardware takes care of XON/XOFF
  512. * and CTS/RTS flow control itself. This means that all we have to
  513. * do when signalled by the upper tty layer to throttle/unthrottle is
  514. * to make a note of it here. When we come to read characters from the
  515. * rx buffers on the card (rio_receive_chars()) we look to see if the
  516. * upper layer can accept more (as noted here in rio_rx_throt[]).
  517. * If it can't we simply don't remove chars from the cards buffer.
  518. * When the tty layer can accept chars, we again note that here and when
  519. * rio_receive_chars() is called it will remove them from the cards buffer.
  520. * The card will notice that a ports buffer has drained below some low
  521. * water mark and will unflow control the line itself, using whatever
  522. * flow control scheme is in use for that port. -- Simon Allen
  523. */
  524. static void rio_throttle(struct tty_struct *tty)
  525. {
  526. struct Port *port = (struct Port *) tty->driver_data;
  527. func_enter();
  528. /* If the port is using any type of input flow
  529. * control then throttle the port.
  530. */
  531. if ((tty->termios->c_cflag & CRTSCTS) || (I_IXOFF(tty))) {
  532. port->State |= RIO_THROTTLE_RX;
  533. }
  534. func_exit();
  535. }
  536. static void rio_unthrottle(struct tty_struct *tty)
  537. {
  538. struct Port *port = (struct Port *) tty->driver_data;
  539. func_enter();
  540. /* Always unthrottle even if flow control is not enabled on
  541. * this port in case we disabled flow control while the port
  542. * was throttled
  543. */
  544. port->State &= ~RIO_THROTTLE_RX;
  545. func_exit();
  546. return;
  547. }
  548. /* ********************************************************************** *
  549. * Here are the initialization routines. *
  550. * ********************************************************************** */
  551. static struct vpd_prom *get_VPD_PROM(struct Host *hp)
  552. {
  553. static struct vpd_prom vpdp;
  554. char *p;
  555. int i;
  556. func_enter();
  557. rio_dprintk(RIO_DEBUG_PROBE, "Going to verify vpd prom at %p.\n", hp->Caddr + RIO_VPD_ROM);
  558. p = (char *) &vpdp;
  559. for (i = 0; i < sizeof(struct vpd_prom); i++)
  560. *p++ = readb(hp->Caddr + RIO_VPD_ROM + i * 2);
  561. /* read_rio_byte (hp, RIO_VPD_ROM + i*2); */
  562. /* Terminate the identifier string.
  563. *** requires one extra byte in struct vpd_prom *** */
  564. *p++ = 0;
  565. if (rio_debug & RIO_DEBUG_PROBE)
  566. my_hd((char *) &vpdp, 0x20);
  567. func_exit();
  568. return &vpdp;
  569. }
  570. static struct tty_operations rio_ops = {
  571. .open = riotopen,
  572. .close = gs_close,
  573. .write = gs_write,
  574. .put_char = gs_put_char,
  575. .flush_chars = gs_flush_chars,
  576. .write_room = gs_write_room,
  577. .chars_in_buffer = gs_chars_in_buffer,
  578. .flush_buffer = gs_flush_buffer,
  579. .ioctl = rio_ioctl,
  580. .throttle = rio_throttle,
  581. .unthrottle = rio_unthrottle,
  582. .set_termios = gs_set_termios,
  583. .stop = gs_stop,
  584. .start = gs_start,
  585. .hangup = gs_hangup,
  586. };
  587. static int rio_init_drivers(void)
  588. {
  589. int error = -ENOMEM;
  590. rio_driver = alloc_tty_driver(256);
  591. if (!rio_driver)
  592. goto out;
  593. rio_driver2 = alloc_tty_driver(256);
  594. if (!rio_driver2)
  595. goto out1;
  596. func_enter();
  597. rio_driver->owner = THIS_MODULE;
  598. rio_driver->driver_name = "specialix_rio";
  599. rio_driver->name = "ttySR";
  600. rio_driver->major = RIO_NORMAL_MAJOR0;
  601. rio_driver->type = TTY_DRIVER_TYPE_SERIAL;
  602. rio_driver->subtype = SERIAL_TYPE_NORMAL;
  603. rio_driver->init_termios = tty_std_termios;
  604. rio_driver->init_termios.c_cflag = B9600 | CS8 | CREAD | HUPCL | CLOCAL;
  605. rio_driver->flags = TTY_DRIVER_REAL_RAW;
  606. tty_set_operations(rio_driver, &rio_ops);
  607. rio_driver2->owner = THIS_MODULE;
  608. rio_driver2->driver_name = "specialix_rio";
  609. rio_driver2->name = "ttySR";
  610. rio_driver2->major = RIO_NORMAL_MAJOR1;
  611. rio_driver2->type = TTY_DRIVER_TYPE_SERIAL;
  612. rio_driver2->subtype = SERIAL_TYPE_NORMAL;
  613. rio_driver2->init_termios = tty_std_termios;
  614. rio_driver2->init_termios.c_cflag = B9600 | CS8 | CREAD | HUPCL | CLOCAL;
  615. rio_driver2->flags = TTY_DRIVER_REAL_RAW;
  616. tty_set_operations(rio_driver2, &rio_ops);
  617. rio_dprintk(RIO_DEBUG_INIT, "set_termios = %p\n", gs_set_termios);
  618. if ((error = tty_register_driver(rio_driver)))
  619. goto out2;
  620. if ((error = tty_register_driver(rio_driver2)))
  621. goto out3;
  622. func_exit();
  623. return 0;
  624. out3:
  625. tty_unregister_driver(rio_driver);
  626. out2:
  627. put_tty_driver(rio_driver2);
  628. out1:
  629. put_tty_driver(rio_driver);
  630. out:
  631. printk(KERN_ERR "rio: Couldn't register a rio driver, error = %d\n", error);
  632. return 1;
  633. }
  634. static void *ckmalloc(int size)
  635. {
  636. void *p;
  637. p = kmalloc(size, GFP_KERNEL);
  638. if (p)
  639. memset(p, 0, size);
  640. return p;
  641. }
  642. static int rio_init_datastructures(void)
  643. {
  644. int i;
  645. struct Port *port;
  646. func_enter();
  647. /* Many drivers statically allocate the maximum number of ports
  648. There is no reason not to allocate them dynamically. Is there? -- REW */
  649. /* However, the RIO driver allows users to configure their first
  650. RTA as the ports numbered 504-511. We therefore need to allocate
  651. the whole range. :-( -- REW */
  652. #define RI_SZ sizeof(struct rio_info)
  653. #define HOST_SZ sizeof(struct Host)
  654. #define PORT_SZ sizeof(struct Port *)
  655. #define TMIO_SZ sizeof(struct termios *)
  656. rio_dprintk(RIO_DEBUG_INIT, "getting : %Zd %Zd %Zd %Zd %Zd bytes\n", RI_SZ, RIO_HOSTS * HOST_SZ, RIO_PORTS * PORT_SZ, RIO_PORTS * TMIO_SZ, RIO_PORTS * TMIO_SZ);
  657. if (!(p = ckmalloc(RI_SZ)))
  658. goto free0;
  659. if (!(p->RIOHosts = ckmalloc(RIO_HOSTS * HOST_SZ)))
  660. goto free1;
  661. if (!(p->RIOPortp = ckmalloc(RIO_PORTS * PORT_SZ)))
  662. goto free2;
  663. p->RIOConf = RIOConf;
  664. rio_dprintk(RIO_DEBUG_INIT, "Got : %p %p %p\n", p, p->RIOHosts, p->RIOPortp);
  665. #if 1
  666. for (i = 0; i < RIO_PORTS; i++) {
  667. port = p->RIOPortp[i] = ckmalloc(sizeof(struct Port));
  668. if (!port) {
  669. goto free6;
  670. }
  671. rio_dprintk(RIO_DEBUG_INIT, "initing port %d (%d)\n", i, port->Mapped);
  672. port->PortNum = i;
  673. port->gs.magic = RIO_MAGIC;
  674. port->gs.close_delay = HZ / 2;
  675. port->gs.closing_wait = 30 * HZ;
  676. port->gs.rd = &rio_real_driver;
  677. spin_lock_init(&port->portSem);
  678. /*
  679. * Initializing wait queue
  680. */
  681. init_waitqueue_head(&port->gs.open_wait);
  682. init_waitqueue_head(&port->gs.close_wait);
  683. }
  684. #else
  685. /* We could postpone initializing them to when they are configured. */
  686. #endif
  687. if (rio_debug & RIO_DEBUG_INIT) {
  688. my_hd(&rio_real_driver, sizeof(rio_real_driver));
  689. }
  690. func_exit();
  691. return 0;
  692. free6:for (i--; i >= 0; i--)
  693. kfree(p->RIOPortp[i]);
  694. /*free5:
  695. free4:
  696. free3:*/ kfree(p->RIOPortp);
  697. free2:kfree(p->RIOHosts);
  698. free1:
  699. rio_dprintk(RIO_DEBUG_INIT, "Not enough memory! %p %p %p\n", p, p->RIOHosts, p->RIOPortp);
  700. kfree(p);
  701. free0:
  702. return -ENOMEM;
  703. }
  704. static void __exit rio_release_drivers(void)
  705. {
  706. func_enter();
  707. tty_unregister_driver(rio_driver2);
  708. tty_unregister_driver(rio_driver);
  709. put_tty_driver(rio_driver2);
  710. put_tty_driver(rio_driver);
  711. func_exit();
  712. }
  713. #ifdef CONFIG_PCI
  714. /* This was written for SX, but applies to RIO too...
  715. (including bugs....)
  716. There is another bit besides Bit 17. Turning that bit off
  717. (on boards shipped with the fix in the eeprom) results in a
  718. hang on the next access to the card.
  719. */
  720. /********************************************************
  721. * Setting bit 17 in the CNTRL register of the PLX 9050 *
  722. * chip forces a retry on writes while a read is pending.*
  723. * This is to prevent the card locking up on Intel Xeon *
  724. * multiprocessor systems with the NX chipset. -- NV *
  725. ********************************************************/
  726. /* Newer cards are produced with this bit set from the configuration
  727. EEprom. As the bit is read/write for the CPU, we can fix it here,
  728. if we detect that it isn't set correctly. -- REW */
  729. static void fix_rio_pci(struct pci_dev *pdev)
  730. {
  731. unsigned long hwbase;
  732. unsigned char *rebase;
  733. unsigned int t;
  734. #define CNTRL_REG_OFFSET 0x50
  735. #define CNTRL_REG_GOODVALUE 0x18260000
  736. hwbase = pci_resource_start(pdev, 0);
  737. rebase = ioremap(hwbase, 0x80);
  738. t = readl(rebase + CNTRL_REG_OFFSET);
  739. if (t != CNTRL_REG_GOODVALUE) {
  740. printk(KERN_DEBUG "rio: performing cntrl reg fix: %08x -> %08x\n", t, CNTRL_REG_GOODVALUE);
  741. writel(CNTRL_REG_GOODVALUE, rebase + CNTRL_REG_OFFSET);
  742. }
  743. iounmap(rebase);
  744. }
  745. #endif
  746. static int __init rio_init(void)
  747. {
  748. int found = 0;
  749. int i;
  750. struct Host *hp;
  751. int retval;
  752. struct vpd_prom *vpdp;
  753. int okboard;
  754. #ifdef CONFIG_PCI
  755. struct pci_dev *pdev = NULL;
  756. unsigned short tshort;
  757. #endif
  758. func_enter();
  759. rio_dprintk(RIO_DEBUG_INIT, "Initing rio module... (rio_debug=%d)\n", rio_debug);
  760. if (abs((long) (&rio_debug) - rio_debug) < 0x10000) {
  761. printk(KERN_WARNING "rio: rio_debug is an address, instead of a value. " "Assuming -1. Was %x/%p.\n", rio_debug, &rio_debug);
  762. rio_debug = -1;
  763. }
  764. if (misc_register(&rio_fw_device) < 0) {
  765. printk(KERN_ERR "RIO: Unable to register firmware loader driver.\n");
  766. return -EIO;
  767. }
  768. retval = rio_init_datastructures();
  769. if (retval < 0) {
  770. misc_deregister(&rio_fw_device);
  771. return retval;
  772. }
  773. #ifdef CONFIG_PCI
  774. /* First look for the JET devices: */
  775. while ((pdev = pci_get_device(PCI_VENDOR_ID_SPECIALIX, PCI_DEVICE_ID_SPECIALIX_SX_XIO_IO8, pdev))) {
  776. u32 tint;
  777. if (pci_enable_device(pdev))
  778. continue;
  779. /* Specialix has a whole bunch of cards with
  780. 0x2000 as the device ID. They say its because
  781. the standard requires it. Stupid standard. */
  782. /* It seems that reading a word doesn't work reliably on 2.0.
  783. Also, reading a non-aligned dword doesn't work. So we read the
  784. whole dword at 0x2c and extract the word at 0x2e (SUBSYSTEM_ID)
  785. ourselves */
  786. pci_read_config_dword(pdev, 0x2c, &tint);
  787. tshort = (tint >> 16) & 0xffff;
  788. rio_dprintk(RIO_DEBUG_PROBE, "Got a specialix card: %x.\n", tint);
  789. if (tshort != 0x0100) {
  790. rio_dprintk(RIO_DEBUG_PROBE, "But it's not a RIO card (%d)...\n", tshort);
  791. continue;
  792. }
  793. rio_dprintk(RIO_DEBUG_PROBE, "cp1\n");
  794. hp = &p->RIOHosts[p->RIONumHosts];
  795. hp->PaddrP = pci_resource_start(pdev, 2);
  796. hp->Ivec = pdev->irq;
  797. if (((1 << hp->Ivec) & rio_irqmask) == 0)
  798. hp->Ivec = 0;
  799. hp->Caddr = ioremap(p->RIOHosts[p->RIONumHosts].PaddrP, RIO_WINDOW_LEN);
  800. hp->CardP = (struct DpRam *) hp->Caddr;
  801. hp->Type = RIO_PCI;
  802. hp->Copy = rio_copy_to_card;
  803. hp->Mode = RIO_PCI_BOOT_FROM_RAM;
  804. spin_lock_init(&hp->HostLock);
  805. rio_reset_interrupt(hp);
  806. rio_start_card_running(hp);
  807. rio_dprintk(RIO_DEBUG_PROBE, "Going to test it (%p/%p).\n", (void *) p->RIOHosts[p->RIONumHosts].PaddrP, p->RIOHosts[p->RIONumHosts].Caddr);
  808. if (RIOBoardTest(p->RIOHosts[p->RIONumHosts].PaddrP, p->RIOHosts[p->RIONumHosts].Caddr, RIO_PCI, 0) == 0) {
  809. rio_dprintk(RIO_DEBUG_INIT, "Done RIOBoardTest\n");
  810. writeb(0xFF, &p->RIOHosts[p->RIONumHosts].ResetInt);
  811. p->RIOHosts[p->RIONumHosts].UniqueNum =
  812. ((readb(&p->RIOHosts[p->RIONumHosts].Unique[0]) & 0xFF) << 0) |
  813. ((readb(&p->RIOHosts[p->RIONumHosts].Unique[1]) & 0xFF) << 8) | ((readb(&p->RIOHosts[p->RIONumHosts].Unique[2]) & 0xFF) << 16) | ((readb(&p->RIOHosts[p->RIONumHosts].Unique[3]) & 0xFF) << 24);
  814. rio_dprintk(RIO_DEBUG_PROBE, "Hmm Tested ok, uniqid = %x.\n", p->RIOHosts[p->RIONumHosts].UniqueNum);
  815. fix_rio_pci(pdev);
  816. p->RIOLastPCISearch = 0;
  817. p->RIONumHosts++;
  818. found++;
  819. } else {
  820. iounmap((char *) (p->RIOHosts[p->RIONumHosts].Caddr));
  821. }
  822. }
  823. /* Then look for the older PCI card.... : */
  824. /* These older PCI cards have problems (only byte-mode access is
  825. supported), which makes them a bit awkward to support.
  826. They also have problems sharing interrupts. Be careful.
  827. (The driver now refuses to share interrupts for these
  828. cards. This should be sufficient).
  829. */
  830. /* Then look for the older RIO/PCI devices: */
  831. while ((pdev = pci_get_device(PCI_VENDOR_ID_SPECIALIX, PCI_DEVICE_ID_SPECIALIX_RIO, pdev))) {
  832. if (pci_enable_device(pdev))
  833. continue;
  834. #ifdef CONFIG_RIO_OLDPCI
  835. hp = &p->RIOHosts[p->RIONumHosts];
  836. hp->PaddrP = pci_resource_start(pdev, 0);
  837. hp->Ivec = pdev->irq;
  838. if (((1 << hp->Ivec) & rio_irqmask) == 0)
  839. hp->Ivec = 0;
  840. hp->Ivec |= 0x8000; /* Mark as non-sharable */
  841. hp->Caddr = ioremap(p->RIOHosts[p->RIONumHosts].PaddrP, RIO_WINDOW_LEN);
  842. hp->CardP = (struct DpRam *) hp->Caddr;
  843. hp->Type = RIO_PCI;
  844. hp->Copy = rio_copy_to_card;
  845. hp->Mode = RIO_PCI_BOOT_FROM_RAM;
  846. spin_lock_init(&hp->HostLock);
  847. rio_dprintk(RIO_DEBUG_PROBE, "Ivec: %x\n", hp->Ivec);
  848. rio_dprintk(RIO_DEBUG_PROBE, "Mode: %x\n", hp->Mode);
  849. rio_reset_interrupt(hp);
  850. rio_start_card_running(hp);
  851. rio_dprintk(RIO_DEBUG_PROBE, "Going to test it (%p/%p).\n", (void *) p->RIOHosts[p->RIONumHosts].PaddrP, p->RIOHosts[p->RIONumHosts].Caddr);
  852. if (RIOBoardTest(p->RIOHosts[p->RIONumHosts].PaddrP, p->RIOHosts[p->RIONumHosts].Caddr, RIO_PCI, 0) == 0) {
  853. writeb(0xFF, &p->RIOHosts[p->RIONumHosts].ResetInt);
  854. p->RIOHosts[p->RIONumHosts].UniqueNum =
  855. ((readb(&p->RIOHosts[p->RIONumHosts].Unique[0]) & 0xFF) << 0) |
  856. ((readb(&p->RIOHosts[p->RIONumHosts].Unique[1]) & 0xFF) << 8) | ((readb(&p->RIOHosts[p->RIONumHosts].Unique[2]) & 0xFF) << 16) | ((readb(&p->RIOHosts[p->RIONumHosts].Unique[3]) & 0xFF) << 24);
  857. rio_dprintk(RIO_DEBUG_PROBE, "Hmm Tested ok, uniqid = %x.\n", p->RIOHosts[p->RIONumHosts].UniqueNum);
  858. p->RIOLastPCISearch = 0;
  859. p->RIONumHosts++;
  860. found++;
  861. } else {
  862. iounmap((char *) (p->RIOHosts[p->RIONumHosts].Caddr));
  863. }
  864. #else
  865. printk(KERN_ERR "Found an older RIO PCI card, but the driver is not " "compiled to support it.\n");
  866. #endif
  867. }
  868. #endif /* PCI */
  869. /* Now probe for ISA cards... */
  870. for (i = 0; i < NR_RIO_ADDRS; i++) {
  871. hp = &p->RIOHosts[p->RIONumHosts];
  872. hp->PaddrP = rio_probe_addrs[i];
  873. /* There was something about the IRQs of these cards. 'Forget what.--REW */
  874. hp->Ivec = 0;
  875. hp->Caddr = ioremap(p->RIOHosts[p->RIONumHosts].PaddrP, RIO_WINDOW_LEN);
  876. hp->CardP = (struct DpRam *) hp->Caddr;
  877. hp->Type = RIO_AT;
  878. hp->Copy = rio_copy_to_card; /* AT card PCI???? - PVDL
  879. * -- YES! this is now a normal copy. Only the
  880. * old PCI card uses the special PCI copy.
  881. * Moreover, the ISA card will work with the
  882. * special PCI copy anyway. -- REW */
  883. hp->Mode = 0;
  884. spin_lock_init(&hp->HostLock);
  885. vpdp = get_VPD_PROM(hp);
  886. rio_dprintk(RIO_DEBUG_PROBE, "Got VPD ROM\n");
  887. okboard = 0;
  888. if ((strncmp(vpdp->identifier, RIO_ISA_IDENT, 16) == 0) || (strncmp(vpdp->identifier, RIO_ISA2_IDENT, 16) == 0) || (strncmp(vpdp->identifier, RIO_ISA3_IDENT, 16) == 0)) {
  889. /* Board is present... */
  890. if (RIOBoardTest(hp->PaddrP, hp->Caddr, RIO_AT, 0) == 0) {
  891. /* ... and feeling fine!!!! */
  892. rio_dprintk(RIO_DEBUG_PROBE, "Hmm Tested ok, uniqid = %x.\n", p->RIOHosts[p->RIONumHosts].UniqueNum);
  893. if (RIOAssignAT(p, hp->PaddrP, hp->Caddr, 0)) {
  894. rio_dprintk(RIO_DEBUG_PROBE, "Hmm Tested ok, host%d uniqid = %x.\n", p->RIONumHosts, p->RIOHosts[p->RIONumHosts - 1].UniqueNum);
  895. okboard++;
  896. found++;
  897. }
  898. }
  899. if (!okboard)
  900. iounmap((char *) (hp->Caddr));
  901. }
  902. }
  903. for (i = 0; i < p->RIONumHosts; i++) {
  904. hp = &p->RIOHosts[i];
  905. if (hp->Ivec) {
  906. int mode = SA_SHIRQ;
  907. if (hp->Ivec & 0x8000) {
  908. mode = 0;
  909. hp->Ivec &= 0x7fff;
  910. }
  911. rio_dprintk(RIO_DEBUG_INIT, "Requesting interrupt hp: %p rio_interrupt: %d Mode: %x\n", hp, hp->Ivec, hp->Mode);
  912. retval = request_irq(hp->Ivec, rio_interrupt, mode, "rio", hp);
  913. rio_dprintk(RIO_DEBUG_INIT, "Return value from request_irq: %d\n", retval);
  914. if (retval) {
  915. printk(KERN_ERR "rio: Cannot allocate irq %d.\n", hp->Ivec);
  916. hp->Ivec = 0;
  917. }
  918. rio_dprintk(RIO_DEBUG_INIT, "Got irq %d.\n", hp->Ivec);
  919. if (hp->Ivec != 0) {
  920. rio_dprintk(RIO_DEBUG_INIT, "Enabling interrupts on rio card.\n");
  921. hp->Mode |= RIO_PCI_INT_ENABLE;
  922. } else
  923. hp->Mode &= !RIO_PCI_INT_ENABLE;
  924. rio_dprintk(RIO_DEBUG_INIT, "New Mode: %x\n", hp->Mode);
  925. rio_start_card_running(hp);
  926. }
  927. /* Init the timer "always" to make sure that it can safely be
  928. deleted when we unload... */
  929. init_timer(&hp->timer);
  930. if (!hp->Ivec) {
  931. rio_dprintk(RIO_DEBUG_INIT, "Starting polling at %dj intervals.\n", rio_poll);
  932. hp->timer.data = i;
  933. hp->timer.function = rio_pollfunc;
  934. hp->timer.expires = jiffies + rio_poll;
  935. add_timer(&hp->timer);
  936. }
  937. }
  938. if (found) {
  939. rio_dprintk(RIO_DEBUG_INIT, "rio: total of %d boards detected.\n", found);
  940. rio_init_drivers();
  941. } else {
  942. /* deregister the misc device we created earlier */
  943. misc_deregister(&rio_fw_device);
  944. }
  945. func_exit();
  946. return found ? 0 : -EIO;
  947. }
  948. static void __exit rio_exit(void)
  949. {
  950. int i;
  951. struct Host *hp;
  952. func_enter();
  953. for (i = 0, hp = p->RIOHosts; i < p->RIONumHosts; i++, hp++) {
  954. RIOHostReset(hp->Type, hp->CardP, hp->Slot);
  955. if (hp->Ivec) {
  956. free_irq(hp->Ivec, hp);
  957. rio_dprintk(RIO_DEBUG_INIT, "freed irq %d.\n", hp->Ivec);
  958. }
  959. /* It is safe/allowed to del_timer a non-active timer */
  960. del_timer(&hp->timer);
  961. }
  962. if (misc_deregister(&rio_fw_device) < 0) {
  963. printk(KERN_INFO "rio: couldn't deregister control-device\n");
  964. }
  965. rio_dprintk(RIO_DEBUG_CLEANUP, "Cleaning up drivers\n");
  966. rio_release_drivers();
  967. /* Release dynamically allocated memory */
  968. kfree(p->RIOPortp);
  969. kfree(p->RIOHosts);
  970. kfree(p);
  971. func_exit();
  972. }
  973. module_init(rio_init);
  974. module_exit(rio_exit);