w83977af_ir.c 31 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328
  1. /*********************************************************************
  2. *
  3. * Filename: w83977af_ir.c
  4. * Version: 1.0
  5. * Description: FIR driver for the Winbond W83977AF Super I/O chip
  6. * Status: Experimental.
  7. * Author: Paul VanderSpek
  8. * Created at: Wed Nov 4 11:46:16 1998
  9. * Modified at: Fri Jan 28 12:10:59 2000
  10. * Modified by: Dag Brattli <dagb@cs.uit.no>
  11. *
  12. * Copyright (c) 1998-2000 Dag Brattli <dagb@cs.uit.no>
  13. * Copyright (c) 1998-1999 Rebel.com
  14. *
  15. * This program is free software; you can redistribute it and/or
  16. * modify it under the terms of the GNU General Public License as
  17. * published by the Free Software Foundation; either version 2 of
  18. * the License, or (at your option) any later version.
  19. *
  20. * Neither Paul VanderSpek nor Rebel.com admit liability nor provide
  21. * warranty for any of this software. This material is provided "AS-IS"
  22. * and at no charge.
  23. *
  24. * If you find bugs in this file, its very likely that the same bug
  25. * will also be in pc87108.c since the implementations are quite
  26. * similar.
  27. *
  28. * Notice that all functions that needs to access the chip in _any_
  29. * way, must save BSR register on entry, and restore it on exit.
  30. * It is _very_ important to follow this policy!
  31. *
  32. * __u8 bank;
  33. *
  34. * bank = inb( iobase+BSR);
  35. *
  36. * do_your_stuff_here();
  37. *
  38. * outb( bank, iobase+BSR);
  39. *
  40. ********************************************************************/
  41. #include <linux/module.h>
  42. #include <linux/kernel.h>
  43. #include <linux/types.h>
  44. #include <linux/skbuff.h>
  45. #include <linux/netdevice.h>
  46. #include <linux/ioport.h>
  47. #include <linux/delay.h>
  48. #include <linux/init.h>
  49. #include <linux/interrupt.h>
  50. #include <linux/rtnetlink.h>
  51. #include <linux/dma-mapping.h>
  52. #include <linux/gfp.h>
  53. #include <asm/io.h>
  54. #include <asm/dma.h>
  55. #include <asm/byteorder.h>
  56. #include <net/irda/irda.h>
  57. #include <net/irda/wrapper.h>
  58. #include <net/irda/irda_device.h>
  59. #include "w83977af.h"
  60. #include "w83977af_ir.h"
  61. #ifdef CONFIG_ARCH_NETWINDER /* Adjust to NetWinder differences */
  62. #undef CONFIG_NETWINDER_TX_DMA_PROBLEMS /* Not needed */
  63. #define CONFIG_NETWINDER_RX_DMA_PROBLEMS /* Must have this one! */
  64. #endif
  65. #define CONFIG_USE_W977_PNP /* Currently needed */
  66. #define PIO_MAX_SPEED 115200
  67. static char *driver_name = "w83977af_ir";
  68. static int qos_mtt_bits = 0x07; /* 1 ms or more */
  69. #define CHIP_IO_EXTENT 8
  70. static unsigned int io[] = { 0x180, ~0, ~0, ~0 };
  71. #ifdef CONFIG_ARCH_NETWINDER /* Adjust to NetWinder differences */
  72. static unsigned int irq[] = { 6, 0, 0, 0 };
  73. #else
  74. static unsigned int irq[] = { 11, 0, 0, 0 };
  75. #endif
  76. static unsigned int dma[] = { 1, 0, 0, 0 };
  77. static unsigned int efbase[] = { W977_EFIO_BASE, W977_EFIO2_BASE };
  78. static unsigned int efio = W977_EFIO_BASE;
  79. static struct w83977af_ir *dev_self[] = { NULL, NULL, NULL, NULL};
  80. /* Some prototypes */
  81. static int w83977af_open(int i, unsigned int iobase, unsigned int irq,
  82. unsigned int dma);
  83. static int w83977af_close(struct w83977af_ir *self);
  84. static int w83977af_probe(int iobase, int irq, int dma);
  85. static int w83977af_dma_receive(struct w83977af_ir *self);
  86. static int w83977af_dma_receive_complete(struct w83977af_ir *self);
  87. static netdev_tx_t w83977af_hard_xmit(struct sk_buff *skb,
  88. struct net_device *dev);
  89. static int w83977af_pio_write(int iobase, __u8 *buf, int len, int fifo_size);
  90. static void w83977af_dma_write(struct w83977af_ir *self, int iobase);
  91. static void w83977af_change_speed(struct w83977af_ir *self, __u32 speed);
  92. static int w83977af_is_receiving(struct w83977af_ir *self);
  93. static int w83977af_net_open(struct net_device *dev);
  94. static int w83977af_net_close(struct net_device *dev);
  95. static int w83977af_net_ioctl(struct net_device *dev, struct ifreq *rq, int cmd);
  96. /*
  97. * Function w83977af_init ()
  98. *
  99. * Initialize chip. Just try to find out how many chips we are dealing with
  100. * and where they are
  101. */
  102. static int __init w83977af_init(void)
  103. {
  104. int i;
  105. IRDA_DEBUG(0, "%s()\n", __func__ );
  106. for (i=0; i < ARRAY_SIZE(dev_self) && io[i] < 2000; i++) {
  107. if (w83977af_open(i, io[i], irq[i], dma[i]) == 0)
  108. return 0;
  109. }
  110. return -ENODEV;
  111. }
  112. /*
  113. * Function w83977af_cleanup ()
  114. *
  115. * Close all configured chips
  116. *
  117. */
  118. static void __exit w83977af_cleanup(void)
  119. {
  120. int i;
  121. IRDA_DEBUG(4, "%s()\n", __func__ );
  122. for (i=0; i < ARRAY_SIZE(dev_self); i++) {
  123. if (dev_self[i])
  124. w83977af_close(dev_self[i]);
  125. }
  126. }
  127. static const struct net_device_ops w83977_netdev_ops = {
  128. .ndo_open = w83977af_net_open,
  129. .ndo_stop = w83977af_net_close,
  130. .ndo_start_xmit = w83977af_hard_xmit,
  131. .ndo_do_ioctl = w83977af_net_ioctl,
  132. };
  133. /*
  134. * Function w83977af_open (iobase, irq)
  135. *
  136. * Open driver instance
  137. *
  138. */
  139. static int w83977af_open(int i, unsigned int iobase, unsigned int irq,
  140. unsigned int dma)
  141. {
  142. struct net_device *dev;
  143. struct w83977af_ir *self;
  144. int err;
  145. IRDA_DEBUG(0, "%s()\n", __func__ );
  146. /* Lock the port that we need */
  147. if (!request_region(iobase, CHIP_IO_EXTENT, driver_name)) {
  148. IRDA_DEBUG(0, "%s(), can't get iobase of 0x%03x\n",
  149. __func__ , iobase);
  150. return -ENODEV;
  151. }
  152. if (w83977af_probe(iobase, irq, dma) == -1) {
  153. err = -1;
  154. goto err_out;
  155. }
  156. /*
  157. * Allocate new instance of the driver
  158. */
  159. dev = alloc_irdadev(sizeof(struct w83977af_ir));
  160. if (dev == NULL) {
  161. printk( KERN_ERR "IrDA: Can't allocate memory for "
  162. "IrDA control block!\n");
  163. err = -ENOMEM;
  164. goto err_out;
  165. }
  166. self = netdev_priv(dev);
  167. spin_lock_init(&self->lock);
  168. /* Initialize IO */
  169. self->io.fir_base = iobase;
  170. self->io.irq = irq;
  171. self->io.fir_ext = CHIP_IO_EXTENT;
  172. self->io.dma = dma;
  173. self->io.fifo_size = 32;
  174. /* Initialize QoS for this device */
  175. irda_init_max_qos_capabilies(&self->qos);
  176. /* The only value we must override it the baudrate */
  177. /* FIXME: The HP HDLS-1100 does not support 1152000! */
  178. self->qos.baud_rate.bits = IR_9600|IR_19200|IR_38400|IR_57600|
  179. IR_115200|IR_576000|IR_1152000|(IR_4000000 << 8);
  180. /* The HP HDLS-1100 needs 1 ms according to the specs */
  181. self->qos.min_turn_time.bits = qos_mtt_bits;
  182. irda_qos_bits_to_value(&self->qos);
  183. /* Max DMA buffer size needed = (data_size + 6) * (window_size) + 6; */
  184. self->rx_buff.truesize = 14384;
  185. self->tx_buff.truesize = 4000;
  186. /* Allocate memory if needed */
  187. self->rx_buff.head =
  188. dma_zalloc_coherent(NULL, self->rx_buff.truesize,
  189. &self->rx_buff_dma, GFP_KERNEL);
  190. if (self->rx_buff.head == NULL) {
  191. err = -ENOMEM;
  192. goto err_out1;
  193. }
  194. self->tx_buff.head =
  195. dma_zalloc_coherent(NULL, self->tx_buff.truesize,
  196. &self->tx_buff_dma, GFP_KERNEL);
  197. if (self->tx_buff.head == NULL) {
  198. err = -ENOMEM;
  199. goto err_out2;
  200. }
  201. self->rx_buff.in_frame = FALSE;
  202. self->rx_buff.state = OUTSIDE_FRAME;
  203. self->tx_buff.data = self->tx_buff.head;
  204. self->rx_buff.data = self->rx_buff.head;
  205. self->netdev = dev;
  206. dev->netdev_ops = &w83977_netdev_ops;
  207. err = register_netdev(dev);
  208. if (err) {
  209. IRDA_ERROR("%s(), register_netdevice() failed!\n", __func__);
  210. goto err_out3;
  211. }
  212. IRDA_MESSAGE("IrDA: Registered device %s\n", dev->name);
  213. /* Need to store self somewhere */
  214. dev_self[i] = self;
  215. return 0;
  216. err_out3:
  217. dma_free_coherent(NULL, self->tx_buff.truesize,
  218. self->tx_buff.head, self->tx_buff_dma);
  219. err_out2:
  220. dma_free_coherent(NULL, self->rx_buff.truesize,
  221. self->rx_buff.head, self->rx_buff_dma);
  222. err_out1:
  223. free_netdev(dev);
  224. err_out:
  225. release_region(iobase, CHIP_IO_EXTENT);
  226. return err;
  227. }
  228. /*
  229. * Function w83977af_close (self)
  230. *
  231. * Close driver instance
  232. *
  233. */
  234. static int w83977af_close(struct w83977af_ir *self)
  235. {
  236. int iobase;
  237. IRDA_DEBUG(0, "%s()\n", __func__ );
  238. iobase = self->io.fir_base;
  239. #ifdef CONFIG_USE_W977_PNP
  240. /* enter PnP configuration mode */
  241. w977_efm_enter(efio);
  242. w977_select_device(W977_DEVICE_IR, efio);
  243. /* Deactivate device */
  244. w977_write_reg(0x30, 0x00, efio);
  245. w977_efm_exit(efio);
  246. #endif /* CONFIG_USE_W977_PNP */
  247. /* Remove netdevice */
  248. unregister_netdev(self->netdev);
  249. /* Release the PORT that this driver is using */
  250. IRDA_DEBUG(0 , "%s(), Releasing Region %03x\n",
  251. __func__ , self->io.fir_base);
  252. release_region(self->io.fir_base, self->io.fir_ext);
  253. if (self->tx_buff.head)
  254. dma_free_coherent(NULL, self->tx_buff.truesize,
  255. self->tx_buff.head, self->tx_buff_dma);
  256. if (self->rx_buff.head)
  257. dma_free_coherent(NULL, self->rx_buff.truesize,
  258. self->rx_buff.head, self->rx_buff_dma);
  259. free_netdev(self->netdev);
  260. return 0;
  261. }
  262. static int w83977af_probe(int iobase, int irq, int dma)
  263. {
  264. int version;
  265. int i;
  266. for (i=0; i < 2; i++) {
  267. IRDA_DEBUG( 0, "%s()\n", __func__ );
  268. #ifdef CONFIG_USE_W977_PNP
  269. /* Enter PnP configuration mode */
  270. w977_efm_enter(efbase[i]);
  271. w977_select_device(W977_DEVICE_IR, efbase[i]);
  272. /* Configure PnP port, IRQ, and DMA channel */
  273. w977_write_reg(0x60, (iobase >> 8) & 0xff, efbase[i]);
  274. w977_write_reg(0x61, (iobase) & 0xff, efbase[i]);
  275. w977_write_reg(0x70, irq, efbase[i]);
  276. #ifdef CONFIG_ARCH_NETWINDER
  277. /* Netwinder uses 1 higher than Linux */
  278. w977_write_reg(0x74, dma+1, efbase[i]);
  279. #else
  280. w977_write_reg(0x74, dma, efbase[i]);
  281. #endif /*CONFIG_ARCH_NETWINDER */
  282. w977_write_reg(0x75, 0x04, efbase[i]); /* Disable Tx DMA */
  283. /* Set append hardware CRC, enable IR bank selection */
  284. w977_write_reg(0xf0, APEDCRC|ENBNKSEL, efbase[i]);
  285. /* Activate device */
  286. w977_write_reg(0x30, 0x01, efbase[i]);
  287. w977_efm_exit(efbase[i]);
  288. #endif /* CONFIG_USE_W977_PNP */
  289. /* Disable Advanced mode */
  290. switch_bank(iobase, SET2);
  291. outb(iobase+2, 0x00);
  292. /* Turn on UART (global) interrupts */
  293. switch_bank(iobase, SET0);
  294. outb(HCR_EN_IRQ, iobase+HCR);
  295. /* Switch to advanced mode */
  296. switch_bank(iobase, SET2);
  297. outb(inb(iobase+ADCR1) | ADCR1_ADV_SL, iobase+ADCR1);
  298. /* Set default IR-mode */
  299. switch_bank(iobase, SET0);
  300. outb(HCR_SIR, iobase+HCR);
  301. /* Read the Advanced IR ID */
  302. switch_bank(iobase, SET3);
  303. version = inb(iobase+AUID);
  304. /* Should be 0x1? */
  305. if (0x10 == (version & 0xf0)) {
  306. efio = efbase[i];
  307. /* Set FIFO size to 32 */
  308. switch_bank(iobase, SET2);
  309. outb(ADCR2_RXFS32|ADCR2_TXFS32, iobase+ADCR2);
  310. /* Set FIFO threshold to TX17, RX16 */
  311. switch_bank(iobase, SET0);
  312. outb(UFR_RXTL|UFR_TXTL|UFR_TXF_RST|UFR_RXF_RST|
  313. UFR_EN_FIFO,iobase+UFR);
  314. /* Receiver frame length */
  315. switch_bank(iobase, SET4);
  316. outb(2048 & 0xff, iobase+6);
  317. outb((2048 >> 8) & 0x1f, iobase+7);
  318. /*
  319. * Init HP HSDL-1100 transceiver.
  320. *
  321. * Set IRX_MSL since we have 2 * receive paths IRRX,
  322. * and IRRXH. Clear IRSL0D since we want IRSL0 * to
  323. * be a input pin used for IRRXH
  324. *
  325. * IRRX pin 37 connected to receiver
  326. * IRTX pin 38 connected to transmitter
  327. * FIRRX pin 39 connected to receiver (IRSL0)
  328. * CIRRX pin 40 connected to pin 37
  329. */
  330. switch_bank(iobase, SET7);
  331. outb(0x40, iobase+7);
  332. IRDA_MESSAGE("W83977AF (IR) driver loaded. "
  333. "Version: 0x%02x\n", version);
  334. return 0;
  335. } else {
  336. /* Try next extented function register address */
  337. IRDA_DEBUG( 0, "%s(), Wrong chip version", __func__ );
  338. }
  339. }
  340. return -1;
  341. }
  342. static void w83977af_change_speed(struct w83977af_ir *self, __u32 speed)
  343. {
  344. int ir_mode = HCR_SIR;
  345. int iobase;
  346. __u8 set;
  347. iobase = self->io.fir_base;
  348. /* Update accounting for new speed */
  349. self->io.speed = speed;
  350. /* Save current bank */
  351. set = inb(iobase+SSR);
  352. /* Disable interrupts */
  353. switch_bank(iobase, SET0);
  354. outb(0, iobase+ICR);
  355. /* Select Set 2 */
  356. switch_bank(iobase, SET2);
  357. outb(0x00, iobase+ABHL);
  358. switch (speed) {
  359. case 9600: outb(0x0c, iobase+ABLL); break;
  360. case 19200: outb(0x06, iobase+ABLL); break;
  361. case 38400: outb(0x03, iobase+ABLL); break;
  362. case 57600: outb(0x02, iobase+ABLL); break;
  363. case 115200: outb(0x01, iobase+ABLL); break;
  364. case 576000:
  365. ir_mode = HCR_MIR_576;
  366. IRDA_DEBUG(0, "%s(), handling baud of 576000\n", __func__ );
  367. break;
  368. case 1152000:
  369. ir_mode = HCR_MIR_1152;
  370. IRDA_DEBUG(0, "%s(), handling baud of 1152000\n", __func__ );
  371. break;
  372. case 4000000:
  373. ir_mode = HCR_FIR;
  374. IRDA_DEBUG(0, "%s(), handling baud of 4000000\n", __func__ );
  375. break;
  376. default:
  377. ir_mode = HCR_FIR;
  378. IRDA_DEBUG(0, "%s(), unknown baud rate of %d\n", __func__ , speed);
  379. break;
  380. }
  381. /* Set speed mode */
  382. switch_bank(iobase, SET0);
  383. outb(ir_mode, iobase+HCR);
  384. /* set FIFO size to 32 */
  385. switch_bank(iobase, SET2);
  386. outb(ADCR2_RXFS32|ADCR2_TXFS32, iobase+ADCR2);
  387. /* set FIFO threshold to TX17, RX16 */
  388. switch_bank(iobase, SET0);
  389. outb(0x00, iobase+UFR); /* Reset */
  390. outb(UFR_EN_FIFO, iobase+UFR); /* First we must enable FIFO */
  391. outb(0xa7, iobase+UFR);
  392. netif_wake_queue(self->netdev);
  393. /* Enable some interrupts so we can receive frames */
  394. switch_bank(iobase, SET0);
  395. if (speed > PIO_MAX_SPEED) {
  396. outb(ICR_EFSFI, iobase+ICR);
  397. w83977af_dma_receive(self);
  398. } else
  399. outb(ICR_ERBRI, iobase+ICR);
  400. /* Restore SSR */
  401. outb(set, iobase+SSR);
  402. }
  403. /*
  404. * Function w83977af_hard_xmit (skb, dev)
  405. *
  406. * Sets up a DMA transfer to send the current frame.
  407. *
  408. */
  409. static netdev_tx_t w83977af_hard_xmit(struct sk_buff *skb,
  410. struct net_device *dev)
  411. {
  412. struct w83977af_ir *self;
  413. __s32 speed;
  414. int iobase;
  415. __u8 set;
  416. int mtt;
  417. self = netdev_priv(dev);
  418. iobase = self->io.fir_base;
  419. IRDA_DEBUG(4, "%s(%ld), skb->len=%d\n", __func__ , jiffies,
  420. (int) skb->len);
  421. /* Lock transmit buffer */
  422. netif_stop_queue(dev);
  423. /* Check if we need to change the speed */
  424. speed = irda_get_next_speed(skb);
  425. if ((speed != self->io.speed) && (speed != -1)) {
  426. /* Check for empty frame */
  427. if (!skb->len) {
  428. w83977af_change_speed(self, speed);
  429. dev_kfree_skb(skb);
  430. return NETDEV_TX_OK;
  431. } else
  432. self->new_speed = speed;
  433. }
  434. /* Save current set */
  435. set = inb(iobase+SSR);
  436. /* Decide if we should use PIO or DMA transfer */
  437. if (self->io.speed > PIO_MAX_SPEED) {
  438. self->tx_buff.data = self->tx_buff.head;
  439. skb_copy_from_linear_data(skb, self->tx_buff.data, skb->len);
  440. self->tx_buff.len = skb->len;
  441. mtt = irda_get_mtt(skb);
  442. IRDA_DEBUG(4, "%s(%ld), mtt=%d\n", __func__ , jiffies, mtt);
  443. if (mtt)
  444. udelay(mtt);
  445. /* Enable DMA interrupt */
  446. switch_bank(iobase, SET0);
  447. outb(ICR_EDMAI, iobase+ICR);
  448. w83977af_dma_write(self, iobase);
  449. } else {
  450. self->tx_buff.data = self->tx_buff.head;
  451. self->tx_buff.len = async_wrap_skb(skb, self->tx_buff.data,
  452. self->tx_buff.truesize);
  453. /* Add interrupt on tx low level (will fire immediately) */
  454. switch_bank(iobase, SET0);
  455. outb(ICR_ETXTHI, iobase+ICR);
  456. }
  457. dev_kfree_skb(skb);
  458. /* Restore set register */
  459. outb(set, iobase+SSR);
  460. return NETDEV_TX_OK;
  461. }
  462. /*
  463. * Function w83977af_dma_write (self, iobase)
  464. *
  465. * Send frame using DMA
  466. *
  467. */
  468. static void w83977af_dma_write(struct w83977af_ir *self, int iobase)
  469. {
  470. __u8 set;
  471. #ifdef CONFIG_NETWINDER_TX_DMA_PROBLEMS
  472. unsigned long flags;
  473. __u8 hcr;
  474. #endif
  475. IRDA_DEBUG(4, "%s(), len=%d\n", __func__ , self->tx_buff.len);
  476. /* Save current set */
  477. set = inb(iobase+SSR);
  478. /* Disable DMA */
  479. switch_bank(iobase, SET0);
  480. outb(inb(iobase+HCR) & ~HCR_EN_DMA, iobase+HCR);
  481. /* Choose transmit DMA channel */
  482. switch_bank(iobase, SET2);
  483. outb(ADCR1_D_CHSW|/*ADCR1_DMA_F|*/ADCR1_ADV_SL, iobase+ADCR1);
  484. #ifdef CONFIG_NETWINDER_TX_DMA_PROBLEMS
  485. spin_lock_irqsave(&self->lock, flags);
  486. disable_dma(self->io.dma);
  487. clear_dma_ff(self->io.dma);
  488. set_dma_mode(self->io.dma, DMA_MODE_READ);
  489. set_dma_addr(self->io.dma, self->tx_buff_dma);
  490. set_dma_count(self->io.dma, self->tx_buff.len);
  491. #else
  492. irda_setup_dma(self->io.dma, self->tx_buff_dma, self->tx_buff.len,
  493. DMA_MODE_WRITE);
  494. #endif
  495. self->io.direction = IO_XMIT;
  496. /* Enable DMA */
  497. switch_bank(iobase, SET0);
  498. #ifdef CONFIG_NETWINDER_TX_DMA_PROBLEMS
  499. hcr = inb(iobase+HCR);
  500. outb(hcr | HCR_EN_DMA, iobase+HCR);
  501. enable_dma(self->io.dma);
  502. spin_unlock_irqrestore(&self->lock, flags);
  503. #else
  504. outb(inb(iobase+HCR) | HCR_EN_DMA | HCR_TX_WT, iobase+HCR);
  505. #endif
  506. /* Restore set register */
  507. outb(set, iobase+SSR);
  508. }
  509. /*
  510. * Function w83977af_pio_write (iobase, buf, len, fifo_size)
  511. *
  512. *
  513. *
  514. */
  515. static int w83977af_pio_write(int iobase, __u8 *buf, int len, int fifo_size)
  516. {
  517. int actual = 0;
  518. __u8 set;
  519. IRDA_DEBUG(4, "%s()\n", __func__ );
  520. /* Save current bank */
  521. set = inb(iobase+SSR);
  522. switch_bank(iobase, SET0);
  523. if (!(inb_p(iobase+USR) & USR_TSRE)) {
  524. IRDA_DEBUG(4,
  525. "%s(), warning, FIFO not empty yet!\n", __func__ );
  526. fifo_size -= 17;
  527. IRDA_DEBUG(4, "%s(), %d bytes left in tx fifo\n",
  528. __func__ , fifo_size);
  529. }
  530. /* Fill FIFO with current frame */
  531. while ((fifo_size-- > 0) && (actual < len)) {
  532. /* Transmit next byte */
  533. outb(buf[actual++], iobase+TBR);
  534. }
  535. IRDA_DEBUG(4, "%s(), fifo_size %d ; %d sent of %d\n",
  536. __func__ , fifo_size, actual, len);
  537. /* Restore bank */
  538. outb(set, iobase+SSR);
  539. return actual;
  540. }
  541. /*
  542. * Function w83977af_dma_xmit_complete (self)
  543. *
  544. * The transfer of a frame in finished. So do the necessary things
  545. *
  546. *
  547. */
  548. static void w83977af_dma_xmit_complete(struct w83977af_ir *self)
  549. {
  550. int iobase;
  551. __u8 set;
  552. IRDA_DEBUG(4, "%s(%ld)\n", __func__ , jiffies);
  553. IRDA_ASSERT(self != NULL, return;);
  554. iobase = self->io.fir_base;
  555. /* Save current set */
  556. set = inb(iobase+SSR);
  557. /* Disable DMA */
  558. switch_bank(iobase, SET0);
  559. outb(inb(iobase+HCR) & ~HCR_EN_DMA, iobase+HCR);
  560. /* Check for underrun! */
  561. if (inb(iobase+AUDR) & AUDR_UNDR) {
  562. IRDA_DEBUG(0, "%s(), Transmit underrun!\n", __func__ );
  563. self->netdev->stats.tx_errors++;
  564. self->netdev->stats.tx_fifo_errors++;
  565. /* Clear bit, by writing 1 to it */
  566. outb(AUDR_UNDR, iobase+AUDR);
  567. } else
  568. self->netdev->stats.tx_packets++;
  569. if (self->new_speed) {
  570. w83977af_change_speed(self, self->new_speed);
  571. self->new_speed = 0;
  572. }
  573. /* Unlock tx_buff and request another frame */
  574. /* Tell the network layer, that we want more frames */
  575. netif_wake_queue(self->netdev);
  576. /* Restore set */
  577. outb(set, iobase+SSR);
  578. }
  579. /*
  580. * Function w83977af_dma_receive (self)
  581. *
  582. * Get ready for receiving a frame. The device will initiate a DMA
  583. * if it starts to receive a frame.
  584. *
  585. */
  586. static int w83977af_dma_receive(struct w83977af_ir *self)
  587. {
  588. int iobase;
  589. __u8 set;
  590. #ifdef CONFIG_NETWINDER_RX_DMA_PROBLEMS
  591. unsigned long flags;
  592. __u8 hcr;
  593. #endif
  594. IRDA_ASSERT(self != NULL, return -1;);
  595. IRDA_DEBUG(4, "%s\n", __func__ );
  596. iobase= self->io.fir_base;
  597. /* Save current set */
  598. set = inb(iobase+SSR);
  599. /* Disable DMA */
  600. switch_bank(iobase, SET0);
  601. outb(inb(iobase+HCR) & ~HCR_EN_DMA, iobase+HCR);
  602. /* Choose DMA Rx, DMA Fairness, and Advanced mode */
  603. switch_bank(iobase, SET2);
  604. outb((inb(iobase+ADCR1) & ~ADCR1_D_CHSW)/*|ADCR1_DMA_F*/|ADCR1_ADV_SL,
  605. iobase+ADCR1);
  606. self->io.direction = IO_RECV;
  607. self->rx_buff.data = self->rx_buff.head;
  608. #ifdef CONFIG_NETWINDER_RX_DMA_PROBLEMS
  609. spin_lock_irqsave(&self->lock, flags);
  610. disable_dma(self->io.dma);
  611. clear_dma_ff(self->io.dma);
  612. set_dma_mode(self->io.dma, DMA_MODE_READ);
  613. set_dma_addr(self->io.dma, self->rx_buff_dma);
  614. set_dma_count(self->io.dma, self->rx_buff.truesize);
  615. #else
  616. irda_setup_dma(self->io.dma, self->rx_buff_dma, self->rx_buff.truesize,
  617. DMA_MODE_READ);
  618. #endif
  619. /*
  620. * Reset Rx FIFO. This will also flush the ST_FIFO, it's very
  621. * important that we don't reset the Tx FIFO since it might not
  622. * be finished transmitting yet
  623. */
  624. switch_bank(iobase, SET0);
  625. outb(UFR_RXTL|UFR_TXTL|UFR_RXF_RST|UFR_EN_FIFO, iobase+UFR);
  626. self->st_fifo.len = self->st_fifo.tail = self->st_fifo.head = 0;
  627. /* Enable DMA */
  628. switch_bank(iobase, SET0);
  629. #ifdef CONFIG_NETWINDER_RX_DMA_PROBLEMS
  630. hcr = inb(iobase+HCR);
  631. outb(hcr | HCR_EN_DMA, iobase+HCR);
  632. enable_dma(self->io.dma);
  633. spin_unlock_irqrestore(&self->lock, flags);
  634. #else
  635. outb(inb(iobase+HCR) | HCR_EN_DMA, iobase+HCR);
  636. #endif
  637. /* Restore set */
  638. outb(set, iobase+SSR);
  639. return 0;
  640. }
  641. /*
  642. * Function w83977af_receive_complete (self)
  643. *
  644. * Finished with receiving a frame
  645. *
  646. */
  647. static int w83977af_dma_receive_complete(struct w83977af_ir *self)
  648. {
  649. struct sk_buff *skb;
  650. struct st_fifo *st_fifo;
  651. int len;
  652. int iobase;
  653. __u8 set;
  654. __u8 status;
  655. IRDA_DEBUG(4, "%s\n", __func__ );
  656. st_fifo = &self->st_fifo;
  657. iobase = self->io.fir_base;
  658. /* Save current set */
  659. set = inb(iobase+SSR);
  660. iobase = self->io.fir_base;
  661. /* Read status FIFO */
  662. switch_bank(iobase, SET5);
  663. while ((status = inb(iobase+FS_FO)) & FS_FO_FSFDR) {
  664. st_fifo->entries[st_fifo->tail].status = status;
  665. st_fifo->entries[st_fifo->tail].len = inb(iobase+RFLFL);
  666. st_fifo->entries[st_fifo->tail].len |= inb(iobase+RFLFH) << 8;
  667. st_fifo->tail++;
  668. st_fifo->len++;
  669. }
  670. while (st_fifo->len) {
  671. /* Get first entry */
  672. status = st_fifo->entries[st_fifo->head].status;
  673. len = st_fifo->entries[st_fifo->head].len;
  674. st_fifo->head++;
  675. st_fifo->len--;
  676. /* Check for errors */
  677. if (status & FS_FO_ERR_MSK) {
  678. if (status & FS_FO_LST_FR) {
  679. /* Add number of lost frames to stats */
  680. self->netdev->stats.rx_errors += len;
  681. } else {
  682. /* Skip frame */
  683. self->netdev->stats.rx_errors++;
  684. self->rx_buff.data += len;
  685. if (status & FS_FO_MX_LEX)
  686. self->netdev->stats.rx_length_errors++;
  687. if (status & FS_FO_PHY_ERR)
  688. self->netdev->stats.rx_frame_errors++;
  689. if (status & FS_FO_CRC_ERR)
  690. self->netdev->stats.rx_crc_errors++;
  691. }
  692. /* The errors below can be reported in both cases */
  693. if (status & FS_FO_RX_OV)
  694. self->netdev->stats.rx_fifo_errors++;
  695. if (status & FS_FO_FSF_OV)
  696. self->netdev->stats.rx_fifo_errors++;
  697. } else {
  698. /* Check if we have transferred all data to memory */
  699. switch_bank(iobase, SET0);
  700. if (inb(iobase+USR) & USR_RDR) {
  701. udelay(80); /* Should be enough!? */
  702. }
  703. skb = dev_alloc_skb(len+1);
  704. if (skb == NULL) {
  705. printk(KERN_INFO
  706. "%s(), memory squeeze, dropping frame.\n", __func__);
  707. /* Restore set register */
  708. outb(set, iobase+SSR);
  709. return FALSE;
  710. }
  711. /* Align to 20 bytes */
  712. skb_reserve(skb, 1);
  713. /* Copy frame without CRC */
  714. if (self->io.speed < 4000000) {
  715. skb_put(skb, len-2);
  716. skb_copy_to_linear_data(skb,
  717. self->rx_buff.data,
  718. len - 2);
  719. } else {
  720. skb_put(skb, len-4);
  721. skb_copy_to_linear_data(skb,
  722. self->rx_buff.data,
  723. len - 4);
  724. }
  725. /* Move to next frame */
  726. self->rx_buff.data += len;
  727. self->netdev->stats.rx_packets++;
  728. skb->dev = self->netdev;
  729. skb_reset_mac_header(skb);
  730. skb->protocol = htons(ETH_P_IRDA);
  731. netif_rx(skb);
  732. }
  733. }
  734. /* Restore set register */
  735. outb(set, iobase+SSR);
  736. return TRUE;
  737. }
  738. /*
  739. * Function pc87108_pio_receive (self)
  740. *
  741. * Receive all data in receiver FIFO
  742. *
  743. */
  744. static void w83977af_pio_receive(struct w83977af_ir *self)
  745. {
  746. __u8 byte = 0x00;
  747. int iobase;
  748. IRDA_DEBUG(4, "%s()\n", __func__ );
  749. IRDA_ASSERT(self != NULL, return;);
  750. iobase = self->io.fir_base;
  751. /* Receive all characters in Rx FIFO */
  752. do {
  753. byte = inb(iobase+RBR);
  754. async_unwrap_char(self->netdev, &self->netdev->stats, &self->rx_buff,
  755. byte);
  756. } while (inb(iobase+USR) & USR_RDR); /* Data available */
  757. }
  758. /*
  759. * Function w83977af_sir_interrupt (self, eir)
  760. *
  761. * Handle SIR interrupt
  762. *
  763. */
  764. static __u8 w83977af_sir_interrupt(struct w83977af_ir *self, int isr)
  765. {
  766. int actual;
  767. __u8 new_icr = 0;
  768. __u8 set;
  769. int iobase;
  770. IRDA_DEBUG(4, "%s(), isr=%#x\n", __func__ , isr);
  771. iobase = self->io.fir_base;
  772. /* Transmit FIFO low on data */
  773. if (isr & ISR_TXTH_I) {
  774. /* Write data left in transmit buffer */
  775. actual = w83977af_pio_write(self->io.fir_base,
  776. self->tx_buff.data,
  777. self->tx_buff.len,
  778. self->io.fifo_size);
  779. self->tx_buff.data += actual;
  780. self->tx_buff.len -= actual;
  781. self->io.direction = IO_XMIT;
  782. /* Check if finished */
  783. if (self->tx_buff.len > 0) {
  784. new_icr |= ICR_ETXTHI;
  785. } else {
  786. set = inb(iobase+SSR);
  787. switch_bank(iobase, SET0);
  788. outb(AUDR_SFEND, iobase+AUDR);
  789. outb(set, iobase+SSR);
  790. self->netdev->stats.tx_packets++;
  791. /* Feed me more packets */
  792. netif_wake_queue(self->netdev);
  793. new_icr |= ICR_ETBREI;
  794. }
  795. }
  796. /* Check if transmission has completed */
  797. if (isr & ISR_TXEMP_I) {
  798. /* Check if we need to change the speed? */
  799. if (self->new_speed) {
  800. IRDA_DEBUG(2,
  801. "%s(), Changing speed!\n", __func__ );
  802. w83977af_change_speed(self, self->new_speed);
  803. self->new_speed = 0;
  804. }
  805. /* Turn around and get ready to receive some data */
  806. self->io.direction = IO_RECV;
  807. new_icr |= ICR_ERBRI;
  808. }
  809. /* Rx FIFO threshold or timeout */
  810. if (isr & ISR_RXTH_I) {
  811. w83977af_pio_receive(self);
  812. /* Keep receiving */
  813. new_icr |= ICR_ERBRI;
  814. }
  815. return new_icr;
  816. }
  817. /*
  818. * Function pc87108_fir_interrupt (self, eir)
  819. *
  820. * Handle MIR/FIR interrupt
  821. *
  822. */
  823. static __u8 w83977af_fir_interrupt(struct w83977af_ir *self, int isr)
  824. {
  825. __u8 new_icr = 0;
  826. __u8 set;
  827. int iobase;
  828. iobase = self->io.fir_base;
  829. set = inb(iobase+SSR);
  830. /* End of frame detected in FIFO */
  831. if (isr & (ISR_FEND_I|ISR_FSF_I)) {
  832. if (w83977af_dma_receive_complete(self)) {
  833. /* Wait for next status FIFO interrupt */
  834. new_icr |= ICR_EFSFI;
  835. } else {
  836. /* DMA not finished yet */
  837. /* Set timer value, resolution 1 ms */
  838. switch_bank(iobase, SET4);
  839. outb(0x01, iobase+TMRL); /* 1 ms */
  840. outb(0x00, iobase+TMRH);
  841. /* Start timer */
  842. outb(IR_MSL_EN_TMR, iobase+IR_MSL);
  843. new_icr |= ICR_ETMRI;
  844. }
  845. }
  846. /* Timer finished */
  847. if (isr & ISR_TMR_I) {
  848. /* Disable timer */
  849. switch_bank(iobase, SET4);
  850. outb(0, iobase+IR_MSL);
  851. /* Clear timer event */
  852. /* switch_bank(iobase, SET0); */
  853. /* outb(ASCR_CTE, iobase+ASCR); */
  854. /* Check if this is a TX timer interrupt */
  855. if (self->io.direction == IO_XMIT) {
  856. w83977af_dma_write(self, iobase);
  857. new_icr |= ICR_EDMAI;
  858. } else {
  859. /* Check if DMA has now finished */
  860. w83977af_dma_receive_complete(self);
  861. new_icr |= ICR_EFSFI;
  862. }
  863. }
  864. /* Finished with DMA */
  865. if (isr & ISR_DMA_I) {
  866. w83977af_dma_xmit_complete(self);
  867. /* Check if there are more frames to be transmitted */
  868. /* if (irda_device_txqueue_empty(self)) { */
  869. /* Prepare for receive
  870. *
  871. * ** Netwinder Tx DMA likes that we do this anyway **
  872. */
  873. w83977af_dma_receive(self);
  874. new_icr = ICR_EFSFI;
  875. /* } */
  876. }
  877. /* Restore set */
  878. outb(set, iobase+SSR);
  879. return new_icr;
  880. }
  881. /*
  882. * Function w83977af_interrupt (irq, dev_id, regs)
  883. *
  884. * An interrupt from the chip has arrived. Time to do some work
  885. *
  886. */
  887. static irqreturn_t w83977af_interrupt(int irq, void *dev_id)
  888. {
  889. struct net_device *dev = dev_id;
  890. struct w83977af_ir *self;
  891. __u8 set, icr, isr;
  892. int iobase;
  893. self = netdev_priv(dev);
  894. iobase = self->io.fir_base;
  895. /* Save current bank */
  896. set = inb(iobase+SSR);
  897. switch_bank(iobase, SET0);
  898. icr = inb(iobase+ICR);
  899. isr = inb(iobase+ISR) & icr; /* Mask out the interesting ones */
  900. outb(0, iobase+ICR); /* Disable interrupts */
  901. if (isr) {
  902. /* Dispatch interrupt handler for the current speed */
  903. if (self->io.speed > PIO_MAX_SPEED )
  904. icr = w83977af_fir_interrupt(self, isr);
  905. else
  906. icr = w83977af_sir_interrupt(self, isr);
  907. }
  908. outb(icr, iobase+ICR); /* Restore (new) interrupts */
  909. outb(set, iobase+SSR); /* Restore bank register */
  910. return IRQ_RETVAL(isr);
  911. }
  912. /*
  913. * Function w83977af_is_receiving (self)
  914. *
  915. * Return TRUE is we are currently receiving a frame
  916. *
  917. */
  918. static int w83977af_is_receiving(struct w83977af_ir *self)
  919. {
  920. int status = FALSE;
  921. int iobase;
  922. __u8 set;
  923. IRDA_ASSERT(self != NULL, return FALSE;);
  924. if (self->io.speed > 115200) {
  925. iobase = self->io.fir_base;
  926. /* Check if rx FIFO is not empty */
  927. set = inb(iobase+SSR);
  928. switch_bank(iobase, SET2);
  929. if ((inb(iobase+RXFDTH) & 0x3f) != 0) {
  930. /* We are receiving something */
  931. status = TRUE;
  932. }
  933. outb(set, iobase+SSR);
  934. } else
  935. status = (self->rx_buff.state != OUTSIDE_FRAME);
  936. return status;
  937. }
  938. /*
  939. * Function w83977af_net_open (dev)
  940. *
  941. * Start the device
  942. *
  943. */
  944. static int w83977af_net_open(struct net_device *dev)
  945. {
  946. struct w83977af_ir *self;
  947. int iobase;
  948. char hwname[32];
  949. __u8 set;
  950. IRDA_DEBUG(0, "%s()\n", __func__ );
  951. IRDA_ASSERT(dev != NULL, return -1;);
  952. self = netdev_priv(dev);
  953. IRDA_ASSERT(self != NULL, return 0;);
  954. iobase = self->io.fir_base;
  955. if (request_irq(self->io.irq, w83977af_interrupt, 0, dev->name,
  956. (void *) dev)) {
  957. return -EAGAIN;
  958. }
  959. /*
  960. * Always allocate the DMA channel after the IRQ,
  961. * and clean up on failure.
  962. */
  963. if (request_dma(self->io.dma, dev->name)) {
  964. free_irq(self->io.irq, dev);
  965. return -EAGAIN;
  966. }
  967. /* Save current set */
  968. set = inb(iobase+SSR);
  969. /* Enable some interrupts so we can receive frames again */
  970. switch_bank(iobase, SET0);
  971. if (self->io.speed > 115200) {
  972. outb(ICR_EFSFI, iobase+ICR);
  973. w83977af_dma_receive(self);
  974. } else
  975. outb(ICR_ERBRI, iobase+ICR);
  976. /* Restore bank register */
  977. outb(set, iobase+SSR);
  978. /* Ready to play! */
  979. netif_start_queue(dev);
  980. /* Give self a hardware name */
  981. sprintf(hwname, "w83977af @ 0x%03x", self->io.fir_base);
  982. /*
  983. * Open new IrLAP layer instance, now that everything should be
  984. * initialized properly
  985. */
  986. self->irlap = irlap_open(dev, &self->qos, hwname);
  987. return 0;
  988. }
  989. /*
  990. * Function w83977af_net_close (dev)
  991. *
  992. * Stop the device
  993. *
  994. */
  995. static int w83977af_net_close(struct net_device *dev)
  996. {
  997. struct w83977af_ir *self;
  998. int iobase;
  999. __u8 set;
  1000. IRDA_DEBUG(0, "%s()\n", __func__ );
  1001. IRDA_ASSERT(dev != NULL, return -1;);
  1002. self = netdev_priv(dev);
  1003. IRDA_ASSERT(self != NULL, return 0;);
  1004. iobase = self->io.fir_base;
  1005. /* Stop device */
  1006. netif_stop_queue(dev);
  1007. /* Stop and remove instance of IrLAP */
  1008. if (self->irlap)
  1009. irlap_close(self->irlap);
  1010. self->irlap = NULL;
  1011. disable_dma(self->io.dma);
  1012. /* Save current set */
  1013. set = inb(iobase+SSR);
  1014. /* Disable interrupts */
  1015. switch_bank(iobase, SET0);
  1016. outb(0, iobase+ICR);
  1017. free_irq(self->io.irq, dev);
  1018. free_dma(self->io.dma);
  1019. /* Restore bank register */
  1020. outb(set, iobase+SSR);
  1021. return 0;
  1022. }
  1023. /*
  1024. * Function w83977af_net_ioctl (dev, rq, cmd)
  1025. *
  1026. * Process IOCTL commands for this device
  1027. *
  1028. */
  1029. static int w83977af_net_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
  1030. {
  1031. struct if_irda_req *irq = (struct if_irda_req *) rq;
  1032. struct w83977af_ir *self;
  1033. unsigned long flags;
  1034. int ret = 0;
  1035. IRDA_ASSERT(dev != NULL, return -1;);
  1036. self = netdev_priv(dev);
  1037. IRDA_ASSERT(self != NULL, return -1;);
  1038. IRDA_DEBUG(2, "%s(), %s, (cmd=0x%X)\n", __func__ , dev->name, cmd);
  1039. spin_lock_irqsave(&self->lock, flags);
  1040. switch (cmd) {
  1041. case SIOCSBANDWIDTH: /* Set bandwidth */
  1042. if (!capable(CAP_NET_ADMIN)) {
  1043. ret = -EPERM;
  1044. goto out;
  1045. }
  1046. w83977af_change_speed(self, irq->ifr_baudrate);
  1047. break;
  1048. case SIOCSMEDIABUSY: /* Set media busy */
  1049. if (!capable(CAP_NET_ADMIN)) {
  1050. ret = -EPERM;
  1051. goto out;
  1052. }
  1053. irda_device_set_media_busy(self->netdev, TRUE);
  1054. break;
  1055. case SIOCGRECEIVING: /* Check if we are receiving right now */
  1056. irq->ifr_receiving = w83977af_is_receiving(self);
  1057. break;
  1058. default:
  1059. ret = -EOPNOTSUPP;
  1060. }
  1061. out:
  1062. spin_unlock_irqrestore(&self->lock, flags);
  1063. return ret;
  1064. }
  1065. MODULE_AUTHOR("Dag Brattli <dagb@cs.uit.no>");
  1066. MODULE_DESCRIPTION("Winbond W83977AF IrDA Device Driver");
  1067. MODULE_LICENSE("GPL");
  1068. module_param(qos_mtt_bits, int, 0);
  1069. MODULE_PARM_DESC(qos_mtt_bits, "Mimimum Turn Time");
  1070. module_param_array(io, int, NULL, 0);
  1071. MODULE_PARM_DESC(io, "Base I/O addresses");
  1072. module_param_array(irq, int, NULL, 0);
  1073. MODULE_PARM_DESC(irq, "IRQ lines");
  1074. /*
  1075. * Function init_module (void)
  1076. *
  1077. *
  1078. *
  1079. */
  1080. module_init(w83977af_init);
  1081. /*
  1082. * Function cleanup_module (void)
  1083. *
  1084. *
  1085. *
  1086. */
  1087. module_exit(w83977af_cleanup);