rio_linux.c 32 KB

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