smsc-ircc2.c 60 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364
  1. /*********************************************************************
  2. * $Id: smsc-ircc2.c,v 1.19.2.5 2002/10/27 11:34:26 dip Exp $
  3. *
  4. * Description: Driver for the SMC Infrared Communications Controller
  5. * Status: Experimental.
  6. * Author: Daniele Peri (peri@csai.unipa.it)
  7. * Created at:
  8. * Modified at:
  9. * Modified by:
  10. *
  11. * Copyright (c) 2002 Daniele Peri
  12. * All Rights Reserved.
  13. * Copyright (c) 2002 Jean Tourrilhes
  14. *
  15. *
  16. * Based on smc-ircc.c:
  17. *
  18. * Copyright (c) 2001 Stefani Seibold
  19. * Copyright (c) 1999-2001 Dag Brattli
  20. * Copyright (c) 1998-1999 Thomas Davis,
  21. *
  22. * and irport.c:
  23. *
  24. * Copyright (c) 1997, 1998, 1999-2000 Dag Brattli, All Rights Reserved.
  25. *
  26. *
  27. * This program is free software; you can redistribute it and/or
  28. * modify it under the terms of the GNU General Public License as
  29. * published by the Free Software Foundation; either version 2 of
  30. * the License, or (at your option) any later version.
  31. *
  32. * This program is distributed in the hope that it will be useful,
  33. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  34. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  35. * GNU General Public License for more details.
  36. *
  37. * You should have received a copy of the GNU General Public License
  38. * along with this program; if not, write to the Free Software
  39. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  40. * MA 02111-1307 USA
  41. *
  42. ********************************************************************/
  43. #include <linux/module.h>
  44. #include <linux/kernel.h>
  45. #include <linux/types.h>
  46. #include <linux/skbuff.h>
  47. #include <linux/netdevice.h>
  48. #include <linux/ioport.h>
  49. #include <linux/delay.h>
  50. #include <linux/slab.h>
  51. #include <linux/init.h>
  52. #include <linux/rtnetlink.h>
  53. #include <linux/serial_reg.h>
  54. #include <linux/dma-mapping.h>
  55. #include <asm/io.h>
  56. #include <asm/dma.h>
  57. #include <asm/byteorder.h>
  58. #include <linux/spinlock.h>
  59. #include <linux/pm.h>
  60. #include <net/irda/wrapper.h>
  61. #include <net/irda/irda.h>
  62. #include <net/irda/irda_device.h>
  63. #include "smsc-ircc2.h"
  64. #include "smsc-sio.h"
  65. MODULE_AUTHOR("Daniele Peri <peri@csai.unipa.it>");
  66. MODULE_DESCRIPTION("SMC IrCC SIR/FIR controller driver");
  67. MODULE_LICENSE("GPL");
  68. static int ircc_dma = 255;
  69. module_param(ircc_dma, int, 0);
  70. MODULE_PARM_DESC(ircc_dma, "DMA channel");
  71. static int ircc_irq = 255;
  72. module_param(ircc_irq, int, 0);
  73. MODULE_PARM_DESC(ircc_irq, "IRQ line");
  74. static int ircc_fir;
  75. module_param(ircc_fir, int, 0);
  76. MODULE_PARM_DESC(ircc_fir, "FIR Base Address");
  77. static int ircc_sir;
  78. module_param(ircc_sir, int, 0);
  79. MODULE_PARM_DESC(ircc_sir, "SIR Base Address");
  80. static int ircc_cfg;
  81. module_param(ircc_cfg, int, 0);
  82. MODULE_PARM_DESC(ircc_cfg, "Configuration register base address");
  83. static int ircc_transceiver;
  84. module_param(ircc_transceiver, int, 0);
  85. MODULE_PARM_DESC(ircc_transceiver, "Transceiver type");
  86. /* Types */
  87. struct smsc_transceiver {
  88. char *name;
  89. void (*set_for_speed)(int fir_base, u32 speed);
  90. int (*probe)(int fir_base);
  91. };
  92. struct smsc_chip {
  93. char *name;
  94. #if 0
  95. u8 type;
  96. #endif
  97. u16 flags;
  98. u8 devid;
  99. u8 rev;
  100. };
  101. struct smsc_chip_address {
  102. unsigned int cfg_base;
  103. unsigned int type;
  104. };
  105. /* Private data for each instance */
  106. struct smsc_ircc_cb {
  107. struct net_device *netdev; /* Yes! we are some kind of netdevice */
  108. struct net_device_stats stats;
  109. struct irlap_cb *irlap; /* The link layer we are binded to */
  110. chipio_t io; /* IrDA controller information */
  111. iobuff_t tx_buff; /* Transmit buffer */
  112. iobuff_t rx_buff; /* Receive buffer */
  113. dma_addr_t tx_buff_dma;
  114. dma_addr_t rx_buff_dma;
  115. struct qos_info qos; /* QoS capabilities for this device */
  116. spinlock_t lock; /* For serializing operations */
  117. __u32 new_speed;
  118. __u32 flags; /* Interface flags */
  119. int tx_buff_offsets[10]; /* Offsets between frames in tx_buff */
  120. int tx_len; /* Number of frames in tx_buff */
  121. int transceiver;
  122. struct pm_dev *pmdev;
  123. };
  124. /* Constants */
  125. static const char *driver_name = "smsc-ircc2";
  126. #define SMSC_IRCC2_C_IRDA_FALLBACK_SPEED 9600
  127. #define SMSC_IRCC2_C_DEFAULT_TRANSCEIVER 1
  128. #define SMSC_IRCC2_C_NET_TIMEOUT 0
  129. #define SMSC_IRCC2_C_SIR_STOP 0
  130. /* Prototypes */
  131. static int smsc_ircc_open(unsigned int firbase, unsigned int sirbase, u8 dma, u8 irq);
  132. static int smsc_ircc_present(unsigned int fir_base, unsigned int sir_base);
  133. static void smsc_ircc_setup_io(struct smsc_ircc_cb *self, unsigned int fir_base, unsigned int sir_base, u8 dma, u8 irq);
  134. static void smsc_ircc_setup_qos(struct smsc_ircc_cb *self);
  135. static void smsc_ircc_init_chip(struct smsc_ircc_cb *self);
  136. static int __exit smsc_ircc_close(struct smsc_ircc_cb *self);
  137. static int smsc_ircc_dma_receive(struct smsc_ircc_cb *self);
  138. static void smsc_ircc_dma_receive_complete(struct smsc_ircc_cb *self);
  139. static void smsc_ircc_sir_receive(struct smsc_ircc_cb *self);
  140. static int smsc_ircc_hard_xmit_sir(struct sk_buff *skb, struct net_device *dev);
  141. static int smsc_ircc_hard_xmit_fir(struct sk_buff *skb, struct net_device *dev);
  142. static void smsc_ircc_dma_xmit(struct smsc_ircc_cb *self, int bofs);
  143. static void smsc_ircc_dma_xmit_complete(struct smsc_ircc_cb *self);
  144. static void smsc_ircc_change_speed(void *priv, u32 speed);
  145. static void smsc_ircc_set_sir_speed(void *priv, u32 speed);
  146. static irqreturn_t smsc_ircc_interrupt(int irq, void *dev_id, struct pt_regs *regs);
  147. static irqreturn_t smsc_ircc_interrupt_sir(struct net_device *dev);
  148. static void smsc_ircc_sir_start(struct smsc_ircc_cb *self);
  149. #if SMSC_IRCC2_C_SIR_STOP
  150. static void smsc_ircc_sir_stop(struct smsc_ircc_cb *self);
  151. #endif
  152. static void smsc_ircc_sir_write_wakeup(struct smsc_ircc_cb *self);
  153. static int smsc_ircc_sir_write(int iobase, int fifo_size, __u8 *buf, int len);
  154. static int smsc_ircc_net_open(struct net_device *dev);
  155. static int smsc_ircc_net_close(struct net_device *dev);
  156. static int smsc_ircc_net_ioctl(struct net_device *dev, struct ifreq *rq, int cmd);
  157. #if SMSC_IRCC2_C_NET_TIMEOUT
  158. static void smsc_ircc_timeout(struct net_device *dev);
  159. #endif
  160. static struct net_device_stats *smsc_ircc_net_get_stats(struct net_device *dev);
  161. static int smsc_ircc_pmproc(struct pm_dev *dev, pm_request_t rqst, void *data);
  162. static int smsc_ircc_is_receiving(struct smsc_ircc_cb *self);
  163. static void smsc_ircc_probe_transceiver(struct smsc_ircc_cb *self);
  164. static void smsc_ircc_set_transceiver_for_speed(struct smsc_ircc_cb *self, u32 speed);
  165. static void smsc_ircc_sir_wait_hw_transmitter_finish(struct smsc_ircc_cb *self);
  166. /* Probing */
  167. static int __init smsc_ircc_look_for_chips(void);
  168. static const struct smsc_chip * __init smsc_ircc_probe(unsigned short cfg_base, u8 reg, const struct smsc_chip *chip, char *type);
  169. static int __init smsc_superio_flat(const struct smsc_chip *chips, unsigned short cfg_base, char *type);
  170. static int __init smsc_superio_paged(const struct smsc_chip *chips, unsigned short cfg_base, char *type);
  171. static int __init smsc_superio_fdc(unsigned short cfg_base);
  172. static int __init smsc_superio_lpc(unsigned short cfg_base);
  173. /* Transceivers specific functions */
  174. static void smsc_ircc_set_transceiver_toshiba_sat1800(int fir_base, u32 speed);
  175. static int smsc_ircc_probe_transceiver_toshiba_sat1800(int fir_base);
  176. static void smsc_ircc_set_transceiver_smsc_ircc_fast_pin_select(int fir_base, u32 speed);
  177. static int smsc_ircc_probe_transceiver_smsc_ircc_fast_pin_select(int fir_base);
  178. static void smsc_ircc_set_transceiver_smsc_ircc_atc(int fir_base, u32 speed);
  179. static int smsc_ircc_probe_transceiver_smsc_ircc_atc(int fir_base);
  180. /* Power Management */
  181. static void smsc_ircc_suspend(struct smsc_ircc_cb *self);
  182. static void smsc_ircc_wakeup(struct smsc_ircc_cb *self);
  183. static int smsc_ircc_pmproc(struct pm_dev *dev, pm_request_t rqst, void *data);
  184. /* Transceivers for SMSC-ircc */
  185. static struct smsc_transceiver smsc_transceivers[] =
  186. {
  187. { "Toshiba Satellite 1800 (GP data pin select)", smsc_ircc_set_transceiver_toshiba_sat1800, smsc_ircc_probe_transceiver_toshiba_sat1800 },
  188. { "Fast pin select", smsc_ircc_set_transceiver_smsc_ircc_fast_pin_select, smsc_ircc_probe_transceiver_smsc_ircc_fast_pin_select },
  189. { "ATC IRMode", smsc_ircc_set_transceiver_smsc_ircc_atc, smsc_ircc_probe_transceiver_smsc_ircc_atc },
  190. { NULL, NULL }
  191. };
  192. #define SMSC_IRCC2_C_NUMBER_OF_TRANSCEIVERS (ARRAY_SIZE(smsc_transceivers) - 1)
  193. /* SMC SuperIO chipsets definitions */
  194. #define KEY55_1 0 /* SuperIO Configuration mode with Key <0x55> */
  195. #define KEY55_2 1 /* SuperIO Configuration mode with Key <0x55,0x55> */
  196. #define NoIRDA 2 /* SuperIO Chip has no IRDA Port */
  197. #define SIR 0 /* SuperIO Chip has only slow IRDA */
  198. #define FIR 4 /* SuperIO Chip has fast IRDA */
  199. #define SERx4 8 /* SuperIO Chip supports 115,2 KBaud * 4=460,8 KBaud */
  200. static struct smsc_chip __initdata fdc_chips_flat[] =
  201. {
  202. /* Base address 0x3f0 or 0x370 */
  203. { "37C44", KEY55_1|NoIRDA, 0x00, 0x00 }, /* This chip cannot be detected */
  204. { "37C665GT", KEY55_2|NoIRDA, 0x65, 0x01 },
  205. { "37C665GT", KEY55_2|NoIRDA, 0x66, 0x01 },
  206. { "37C669", KEY55_2|SIR|SERx4, 0x03, 0x02 },
  207. { "37C669", KEY55_2|SIR|SERx4, 0x04, 0x02 }, /* ID? */
  208. { "37C78", KEY55_2|NoIRDA, 0x78, 0x00 },
  209. { "37N769", KEY55_1|FIR|SERx4, 0x28, 0x00 },
  210. { "37N869", KEY55_1|FIR|SERx4, 0x29, 0x00 },
  211. { NULL }
  212. };
  213. static struct smsc_chip __initdata fdc_chips_paged[] =
  214. {
  215. /* Base address 0x3f0 or 0x370 */
  216. { "37B72X", KEY55_1|SIR|SERx4, 0x4c, 0x00 },
  217. { "37B77X", KEY55_1|SIR|SERx4, 0x43, 0x00 },
  218. { "37B78X", KEY55_1|SIR|SERx4, 0x44, 0x00 },
  219. { "37B80X", KEY55_1|SIR|SERx4, 0x42, 0x00 },
  220. { "37C67X", KEY55_1|FIR|SERx4, 0x40, 0x00 },
  221. { "37C93X", KEY55_2|SIR|SERx4, 0x02, 0x01 },
  222. { "37C93XAPM", KEY55_1|SIR|SERx4, 0x30, 0x01 },
  223. { "37C93XFR", KEY55_2|FIR|SERx4, 0x03, 0x01 },
  224. { "37M707", KEY55_1|SIR|SERx4, 0x42, 0x00 },
  225. { "37M81X", KEY55_1|SIR|SERx4, 0x4d, 0x00 },
  226. { "37N958FR", KEY55_1|FIR|SERx4, 0x09, 0x04 },
  227. { "37N971", KEY55_1|FIR|SERx4, 0x0a, 0x00 },
  228. { "37N972", KEY55_1|FIR|SERx4, 0x0b, 0x00 },
  229. { NULL }
  230. };
  231. static struct smsc_chip __initdata lpc_chips_flat[] =
  232. {
  233. /* Base address 0x2E or 0x4E */
  234. { "47N227", KEY55_1|FIR|SERx4, 0x5a, 0x00 },
  235. { "47N267", KEY55_1|FIR|SERx4, 0x5e, 0x00 },
  236. { NULL }
  237. };
  238. static struct smsc_chip __initdata lpc_chips_paged[] =
  239. {
  240. /* Base address 0x2E or 0x4E */
  241. { "47B27X", KEY55_1|SIR|SERx4, 0x51, 0x00 },
  242. { "47B37X", KEY55_1|SIR|SERx4, 0x52, 0x00 },
  243. { "47M10X", KEY55_1|SIR|SERx4, 0x59, 0x00 },
  244. { "47M120", KEY55_1|NoIRDA|SERx4, 0x5c, 0x00 },
  245. { "47M13X", KEY55_1|SIR|SERx4, 0x59, 0x00 },
  246. { "47M14X", KEY55_1|SIR|SERx4, 0x5f, 0x00 },
  247. { "47N252", KEY55_1|FIR|SERx4, 0x0e, 0x00 },
  248. { "47S42X", KEY55_1|SIR|SERx4, 0x57, 0x00 },
  249. { NULL }
  250. };
  251. #define SMSCSIO_TYPE_FDC 1
  252. #define SMSCSIO_TYPE_LPC 2
  253. #define SMSCSIO_TYPE_FLAT 4
  254. #define SMSCSIO_TYPE_PAGED 8
  255. static struct smsc_chip_address __initdata possible_addresses[] =
  256. {
  257. { 0x3f0, SMSCSIO_TYPE_FDC|SMSCSIO_TYPE_FLAT|SMSCSIO_TYPE_PAGED },
  258. { 0x370, SMSCSIO_TYPE_FDC|SMSCSIO_TYPE_FLAT|SMSCSIO_TYPE_PAGED },
  259. { 0xe0, SMSCSIO_TYPE_FDC|SMSCSIO_TYPE_FLAT|SMSCSIO_TYPE_PAGED },
  260. { 0x2e, SMSCSIO_TYPE_LPC|SMSCSIO_TYPE_FLAT|SMSCSIO_TYPE_PAGED },
  261. { 0x4e, SMSCSIO_TYPE_LPC|SMSCSIO_TYPE_FLAT|SMSCSIO_TYPE_PAGED },
  262. { 0, 0 }
  263. };
  264. /* Globals */
  265. static struct smsc_ircc_cb *dev_self[] = { NULL, NULL };
  266. static unsigned short dev_count;
  267. static inline void register_bank(int iobase, int bank)
  268. {
  269. outb(((inb(iobase + IRCC_MASTER) & 0xf0) | (bank & 0x07)),
  270. iobase + IRCC_MASTER);
  271. }
  272. /*******************************************************************************
  273. *
  274. *
  275. * SMSC-ircc stuff
  276. *
  277. *
  278. *******************************************************************************/
  279. /*
  280. * Function smsc_ircc_init ()
  281. *
  282. * Initialize chip. Just try to find out how many chips we are dealing with
  283. * and where they are
  284. */
  285. static int __init smsc_ircc_init(void)
  286. {
  287. int ret = -ENODEV;
  288. IRDA_DEBUG(1, "%s\n", __FUNCTION__);
  289. dev_count = 0;
  290. if (ircc_fir > 0 && ircc_sir > 0) {
  291. IRDA_MESSAGE(" Overriding FIR address 0x%04x\n", ircc_fir);
  292. IRDA_MESSAGE(" Overriding SIR address 0x%04x\n", ircc_sir);
  293. if (smsc_ircc_open(ircc_fir, ircc_sir, ircc_dma, ircc_irq) == 0)
  294. return 0;
  295. return -ENODEV;
  296. }
  297. /* try user provided configuration register base address */
  298. if (ircc_cfg > 0) {
  299. IRDA_MESSAGE(" Overriding configuration address 0x%04x\n",
  300. ircc_cfg);
  301. if (!smsc_superio_fdc(ircc_cfg))
  302. ret = 0;
  303. if (!smsc_superio_lpc(ircc_cfg))
  304. ret = 0;
  305. }
  306. if (smsc_ircc_look_for_chips() > 0)
  307. ret = 0;
  308. return ret;
  309. }
  310. /*
  311. * Function smsc_ircc_open (firbase, sirbase, dma, irq)
  312. *
  313. * Try to open driver instance
  314. *
  315. */
  316. static int __init smsc_ircc_open(unsigned int fir_base, unsigned int sir_base, u8 dma, u8 irq)
  317. {
  318. struct smsc_ircc_cb *self;
  319. struct net_device *dev;
  320. int err;
  321. IRDA_DEBUG(1, "%s\n", __FUNCTION__);
  322. err = smsc_ircc_present(fir_base, sir_base);
  323. if (err)
  324. goto err_out;
  325. err = -ENOMEM;
  326. if (dev_count >= ARRAY_SIZE(dev_self)) {
  327. IRDA_WARNING("%s(), too many devices!\n", __FUNCTION__);
  328. goto err_out1;
  329. }
  330. /*
  331. * Allocate new instance of the driver
  332. */
  333. dev = alloc_irdadev(sizeof(struct smsc_ircc_cb));
  334. if (!dev) {
  335. IRDA_WARNING("%s() can't allocate net device\n", __FUNCTION__);
  336. goto err_out1;
  337. }
  338. SET_MODULE_OWNER(dev);
  339. dev->hard_start_xmit = smsc_ircc_hard_xmit_sir;
  340. #if SMSC_IRCC2_C_NET_TIMEOUT
  341. dev->tx_timeout = smsc_ircc_timeout;
  342. dev->watchdog_timeo = HZ * 2; /* Allow enough time for speed change */
  343. #endif
  344. dev->open = smsc_ircc_net_open;
  345. dev->stop = smsc_ircc_net_close;
  346. dev->do_ioctl = smsc_ircc_net_ioctl;
  347. dev->get_stats = smsc_ircc_net_get_stats;
  348. self = dev->priv;
  349. self->netdev = dev;
  350. /* Make ifconfig display some details */
  351. dev->base_addr = self->io.fir_base = fir_base;
  352. dev->irq = self->io.irq = irq;
  353. /* Need to store self somewhere */
  354. dev_self[dev_count++] = self;
  355. spin_lock_init(&self->lock);
  356. self->rx_buff.truesize = SMSC_IRCC2_RX_BUFF_TRUESIZE;
  357. self->tx_buff.truesize = SMSC_IRCC2_TX_BUFF_TRUESIZE;
  358. self->rx_buff.head =
  359. dma_alloc_coherent(NULL, self->rx_buff.truesize,
  360. &self->rx_buff_dma, GFP_KERNEL);
  361. if (self->rx_buff.head == NULL) {
  362. IRDA_ERROR("%s, Can't allocate memory for receive buffer!\n",
  363. driver_name);
  364. goto err_out2;
  365. }
  366. self->tx_buff.head =
  367. dma_alloc_coherent(NULL, self->tx_buff.truesize,
  368. &self->tx_buff_dma, GFP_KERNEL);
  369. if (self->tx_buff.head == NULL) {
  370. IRDA_ERROR("%s, Can't allocate memory for transmit buffer!\n",
  371. driver_name);
  372. goto err_out3;
  373. }
  374. memset(self->rx_buff.head, 0, self->rx_buff.truesize);
  375. memset(self->tx_buff.head, 0, self->tx_buff.truesize);
  376. self->rx_buff.in_frame = FALSE;
  377. self->rx_buff.state = OUTSIDE_FRAME;
  378. self->tx_buff.data = self->tx_buff.head;
  379. self->rx_buff.data = self->rx_buff.head;
  380. smsc_ircc_setup_io(self, fir_base, sir_base, dma, irq);
  381. smsc_ircc_setup_qos(self);
  382. smsc_ircc_init_chip(self);
  383. if (ircc_transceiver > 0 &&
  384. ircc_transceiver < SMSC_IRCC2_C_NUMBER_OF_TRANSCEIVERS)
  385. self->transceiver = ircc_transceiver;
  386. else
  387. smsc_ircc_probe_transceiver(self);
  388. err = register_netdev(self->netdev);
  389. if (err) {
  390. IRDA_ERROR("%s, Network device registration failed!\n",
  391. driver_name);
  392. goto err_out4;
  393. }
  394. self->pmdev = pm_register(PM_SYS_DEV, PM_SYS_IRDA, smsc_ircc_pmproc);
  395. if (self->pmdev)
  396. self->pmdev->data = self;
  397. IRDA_MESSAGE("IrDA: Registered device %s\n", dev->name);
  398. return 0;
  399. err_out4:
  400. dma_free_coherent(NULL, self->tx_buff.truesize,
  401. self->tx_buff.head, self->tx_buff_dma);
  402. err_out3:
  403. dma_free_coherent(NULL, self->rx_buff.truesize,
  404. self->rx_buff.head, self->rx_buff_dma);
  405. err_out2:
  406. free_netdev(self->netdev);
  407. dev_self[--dev_count] = NULL;
  408. err_out1:
  409. release_region(fir_base, SMSC_IRCC2_FIR_CHIP_IO_EXTENT);
  410. release_region(sir_base, SMSC_IRCC2_SIR_CHIP_IO_EXTENT);
  411. err_out:
  412. return err;
  413. }
  414. /*
  415. * Function smsc_ircc_present(fir_base, sir_base)
  416. *
  417. * Check the smsc-ircc chip presence
  418. *
  419. */
  420. static int smsc_ircc_present(unsigned int fir_base, unsigned int sir_base)
  421. {
  422. unsigned char low, high, chip, config, dma, irq, version;
  423. if (!request_region(fir_base, SMSC_IRCC2_FIR_CHIP_IO_EXTENT,
  424. driver_name)) {
  425. IRDA_WARNING("%s: can't get fir_base of 0x%03x\n",
  426. __FUNCTION__, fir_base);
  427. goto out1;
  428. }
  429. if (!request_region(sir_base, SMSC_IRCC2_SIR_CHIP_IO_EXTENT,
  430. driver_name)) {
  431. IRDA_WARNING("%s: can't get sir_base of 0x%03x\n",
  432. __FUNCTION__, sir_base);
  433. goto out2;
  434. }
  435. register_bank(fir_base, 3);
  436. high = inb(fir_base + IRCC_ID_HIGH);
  437. low = inb(fir_base + IRCC_ID_LOW);
  438. chip = inb(fir_base + IRCC_CHIP_ID);
  439. version = inb(fir_base + IRCC_VERSION);
  440. config = inb(fir_base + IRCC_INTERFACE);
  441. dma = config & IRCC_INTERFACE_DMA_MASK;
  442. irq = (config & IRCC_INTERFACE_IRQ_MASK) >> 4;
  443. if (high != 0x10 || low != 0xb8 || (chip != 0xf1 && chip != 0xf2)) {
  444. IRDA_WARNING("%s(), addr 0x%04x - no device found!\n",
  445. __FUNCTION__, fir_base);
  446. goto out3;
  447. }
  448. IRDA_MESSAGE("SMsC IrDA Controller found\n IrCC version %d.%d, "
  449. "firport 0x%03x, sirport 0x%03x dma=%d, irq=%d\n",
  450. chip & 0x0f, version, fir_base, sir_base, dma, irq);
  451. return 0;
  452. out3:
  453. release_region(sir_base, SMSC_IRCC2_SIR_CHIP_IO_EXTENT);
  454. out2:
  455. release_region(fir_base, SMSC_IRCC2_FIR_CHIP_IO_EXTENT);
  456. out1:
  457. return -ENODEV;
  458. }
  459. /*
  460. * Function smsc_ircc_setup_io(self, fir_base, sir_base, dma, irq)
  461. *
  462. * Setup I/O
  463. *
  464. */
  465. static void smsc_ircc_setup_io(struct smsc_ircc_cb *self,
  466. unsigned int fir_base, unsigned int sir_base,
  467. u8 dma, u8 irq)
  468. {
  469. unsigned char config, chip_dma, chip_irq;
  470. register_bank(fir_base, 3);
  471. config = inb(fir_base + IRCC_INTERFACE);
  472. chip_dma = config & IRCC_INTERFACE_DMA_MASK;
  473. chip_irq = (config & IRCC_INTERFACE_IRQ_MASK) >> 4;
  474. self->io.fir_base = fir_base;
  475. self->io.sir_base = sir_base;
  476. self->io.fir_ext = SMSC_IRCC2_FIR_CHIP_IO_EXTENT;
  477. self->io.sir_ext = SMSC_IRCC2_SIR_CHIP_IO_EXTENT;
  478. self->io.fifo_size = SMSC_IRCC2_FIFO_SIZE;
  479. self->io.speed = SMSC_IRCC2_C_IRDA_FALLBACK_SPEED;
  480. if (irq < 255) {
  481. if (irq != chip_irq)
  482. IRDA_MESSAGE("%s, Overriding IRQ - chip says %d, using %d\n",
  483. driver_name, chip_irq, irq);
  484. self->io.irq = irq;
  485. } else
  486. self->io.irq = chip_irq;
  487. if (dma < 255) {
  488. if (dma != chip_dma)
  489. IRDA_MESSAGE("%s, Overriding DMA - chip says %d, using %d\n",
  490. driver_name, chip_dma, dma);
  491. self->io.dma = dma;
  492. } else
  493. self->io.dma = chip_dma;
  494. }
  495. /*
  496. * Function smsc_ircc_setup_qos(self)
  497. *
  498. * Setup qos
  499. *
  500. */
  501. static void smsc_ircc_setup_qos(struct smsc_ircc_cb *self)
  502. {
  503. /* Initialize QoS for this device */
  504. irda_init_max_qos_capabilies(&self->qos);
  505. self->qos.baud_rate.bits = IR_9600|IR_19200|IR_38400|IR_57600|
  506. IR_115200|IR_576000|IR_1152000|(IR_4000000 << 8);
  507. self->qos.min_turn_time.bits = SMSC_IRCC2_MIN_TURN_TIME;
  508. self->qos.window_size.bits = SMSC_IRCC2_WINDOW_SIZE;
  509. irda_qos_bits_to_value(&self->qos);
  510. }
  511. /*
  512. * Function smsc_ircc_init_chip(self)
  513. *
  514. * Init chip
  515. *
  516. */
  517. static void smsc_ircc_init_chip(struct smsc_ircc_cb *self)
  518. {
  519. int iobase, ir_mode, ctrl, fast;
  520. IRDA_ASSERT(self != NULL, return;);
  521. iobase = self->io.fir_base;
  522. ir_mode = IRCC_CFGA_IRDA_SIR_A;
  523. ctrl = 0;
  524. fast = 0;
  525. register_bank(iobase, 0);
  526. outb(IRCC_MASTER_RESET, iobase + IRCC_MASTER);
  527. outb(0x00, iobase + IRCC_MASTER);
  528. register_bank(iobase, 1);
  529. outb(((inb(iobase + IRCC_SCE_CFGA) & 0x87) | ir_mode),
  530. iobase + IRCC_SCE_CFGA);
  531. #ifdef smsc_669 /* Uses pin 88/89 for Rx/Tx */
  532. outb(((inb(iobase + IRCC_SCE_CFGB) & 0x3f) | IRCC_CFGB_MUX_COM),
  533. iobase + IRCC_SCE_CFGB);
  534. #else
  535. outb(((inb(iobase + IRCC_SCE_CFGB) & 0x3f) | IRCC_CFGB_MUX_IR),
  536. iobase + IRCC_SCE_CFGB);
  537. #endif
  538. (void) inb(iobase + IRCC_FIFO_THRESHOLD);
  539. outb(SMSC_IRCC2_FIFO_THRESHOLD, iobase + IRCC_FIFO_THRESHOLD);
  540. register_bank(iobase, 4);
  541. outb((inb(iobase + IRCC_CONTROL) & 0x30) | ctrl, iobase + IRCC_CONTROL);
  542. register_bank(iobase, 0);
  543. outb(fast, iobase + IRCC_LCR_A);
  544. smsc_ircc_set_sir_speed(self, SMSC_IRCC2_C_IRDA_FALLBACK_SPEED);
  545. /* Power on device */
  546. outb(0x00, iobase + IRCC_MASTER);
  547. }
  548. /*
  549. * Function smsc_ircc_net_ioctl (dev, rq, cmd)
  550. *
  551. * Process IOCTL commands for this device
  552. *
  553. */
  554. static int smsc_ircc_net_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
  555. {
  556. struct if_irda_req *irq = (struct if_irda_req *) rq;
  557. struct smsc_ircc_cb *self;
  558. unsigned long flags;
  559. int ret = 0;
  560. IRDA_ASSERT(dev != NULL, return -1;);
  561. self = dev->priv;
  562. IRDA_ASSERT(self != NULL, return -1;);
  563. IRDA_DEBUG(2, "%s(), %s, (cmd=0x%X)\n", __FUNCTION__, dev->name, cmd);
  564. switch (cmd) {
  565. case SIOCSBANDWIDTH: /* Set bandwidth */
  566. if (!capable(CAP_NET_ADMIN))
  567. ret = -EPERM;
  568. else {
  569. /* Make sure we are the only one touching
  570. * self->io.speed and the hardware - Jean II */
  571. spin_lock_irqsave(&self->lock, flags);
  572. smsc_ircc_change_speed(self, irq->ifr_baudrate);
  573. spin_unlock_irqrestore(&self->lock, flags);
  574. }
  575. break;
  576. case SIOCSMEDIABUSY: /* Set media busy */
  577. if (!capable(CAP_NET_ADMIN)) {
  578. ret = -EPERM;
  579. break;
  580. }
  581. irda_device_set_media_busy(self->netdev, TRUE);
  582. break;
  583. case SIOCGRECEIVING: /* Check if we are receiving right now */
  584. irq->ifr_receiving = smsc_ircc_is_receiving(self);
  585. break;
  586. #if 0
  587. case SIOCSDTRRTS:
  588. if (!capable(CAP_NET_ADMIN)) {
  589. ret = -EPERM;
  590. break;
  591. }
  592. smsc_ircc_sir_set_dtr_rts(dev, irq->ifr_dtr, irq->ifr_rts);
  593. break;
  594. #endif
  595. default:
  596. ret = -EOPNOTSUPP;
  597. }
  598. return ret;
  599. }
  600. static struct net_device_stats *smsc_ircc_net_get_stats(struct net_device *dev)
  601. {
  602. struct smsc_ircc_cb *self = (struct smsc_ircc_cb *) dev->priv;
  603. return &self->stats;
  604. }
  605. #if SMSC_IRCC2_C_NET_TIMEOUT
  606. /*
  607. * Function smsc_ircc_timeout (struct net_device *dev)
  608. *
  609. * The networking timeout management.
  610. *
  611. */
  612. static void smsc_ircc_timeout(struct net_device *dev)
  613. {
  614. struct smsc_ircc_cb *self;
  615. unsigned long flags;
  616. self = (struct smsc_ircc_cb *) dev->priv;
  617. IRDA_WARNING("%s: transmit timed out, changing speed to: %d\n",
  618. dev->name, self->io.speed);
  619. spin_lock_irqsave(&self->lock, flags);
  620. smsc_ircc_sir_start(self);
  621. smsc_ircc_change_speed(self, self->io.speed);
  622. dev->trans_start = jiffies;
  623. netif_wake_queue(dev);
  624. spin_unlock_irqrestore(&self->lock, flags);
  625. }
  626. #endif
  627. /*
  628. * Function smsc_ircc_hard_xmit_sir (struct sk_buff *skb, struct net_device *dev)
  629. *
  630. * Transmits the current frame until FIFO is full, then
  631. * waits until the next transmit interrupt, and continues until the
  632. * frame is transmitted.
  633. */
  634. int smsc_ircc_hard_xmit_sir(struct sk_buff *skb, struct net_device *dev)
  635. {
  636. struct smsc_ircc_cb *self;
  637. unsigned long flags;
  638. s32 speed;
  639. IRDA_DEBUG(1, "%s\n", __FUNCTION__);
  640. IRDA_ASSERT(dev != NULL, return 0;);
  641. self = (struct smsc_ircc_cb *) dev->priv;
  642. IRDA_ASSERT(self != NULL, return 0;);
  643. netif_stop_queue(dev);
  644. /* Make sure test of self->io.speed & speed change are atomic */
  645. spin_lock_irqsave(&self->lock, flags);
  646. /* Check if we need to change the speed */
  647. speed = irda_get_next_speed(skb);
  648. if (speed != self->io.speed && speed != -1) {
  649. /* Check for empty frame */
  650. if (!skb->len) {
  651. /*
  652. * We send frames one by one in SIR mode (no
  653. * pipelining), so at this point, if we were sending
  654. * a previous frame, we just received the interrupt
  655. * telling us it is finished (UART_IIR_THRI).
  656. * Therefore, waiting for the transmitter to really
  657. * finish draining the fifo won't take too long.
  658. * And the interrupt handler is not expected to run.
  659. * - Jean II */
  660. smsc_ircc_sir_wait_hw_transmitter_finish(self);
  661. smsc_ircc_change_speed(self, speed);
  662. spin_unlock_irqrestore(&self->lock, flags);
  663. dev_kfree_skb(skb);
  664. return 0;
  665. }
  666. self->new_speed = speed;
  667. }
  668. /* Init tx buffer */
  669. self->tx_buff.data = self->tx_buff.head;
  670. /* Copy skb to tx_buff while wrapping, stuffing and making CRC */
  671. self->tx_buff.len = async_wrap_skb(skb, self->tx_buff.data,
  672. self->tx_buff.truesize);
  673. self->stats.tx_bytes += self->tx_buff.len;
  674. /* Turn on transmit finished interrupt. Will fire immediately! */
  675. outb(UART_IER_THRI, self->io.sir_base + UART_IER);
  676. spin_unlock_irqrestore(&self->lock, flags);
  677. dev_kfree_skb(skb);
  678. return 0;
  679. }
  680. /*
  681. * Function smsc_ircc_set_fir_speed (self, baud)
  682. *
  683. * Change the speed of the device
  684. *
  685. */
  686. static void smsc_ircc_set_fir_speed(struct smsc_ircc_cb *self, u32 speed)
  687. {
  688. int fir_base, ir_mode, ctrl, fast;
  689. IRDA_ASSERT(self != NULL, return;);
  690. fir_base = self->io.fir_base;
  691. self->io.speed = speed;
  692. switch (speed) {
  693. default:
  694. case 576000:
  695. ir_mode = IRCC_CFGA_IRDA_HDLC;
  696. ctrl = IRCC_CRC;
  697. fast = 0;
  698. IRDA_DEBUG(0, "%s(), handling baud of 576000\n", __FUNCTION__);
  699. break;
  700. case 1152000:
  701. ir_mode = IRCC_CFGA_IRDA_HDLC;
  702. ctrl = IRCC_1152 | IRCC_CRC;
  703. fast = IRCC_LCR_A_FAST | IRCC_LCR_A_GP_DATA;
  704. IRDA_DEBUG(0, "%s(), handling baud of 1152000\n",
  705. __FUNCTION__);
  706. break;
  707. case 4000000:
  708. ir_mode = IRCC_CFGA_IRDA_4PPM;
  709. ctrl = IRCC_CRC;
  710. fast = IRCC_LCR_A_FAST;
  711. IRDA_DEBUG(0, "%s(), handling baud of 4000000\n",
  712. __FUNCTION__);
  713. break;
  714. }
  715. #if 0
  716. Now in tranceiver!
  717. /* This causes an interrupt */
  718. register_bank(fir_base, 0);
  719. outb((inb(fir_base + IRCC_LCR_A) & 0xbf) | fast, fir_base + IRCC_LCR_A);
  720. #endif
  721. register_bank(fir_base, 1);
  722. outb(((inb(fir_base + IRCC_SCE_CFGA) & IRCC_SCE_CFGA_BLOCK_CTRL_BITS_MASK) | ir_mode), fir_base + IRCC_SCE_CFGA);
  723. register_bank(fir_base, 4);
  724. outb((inb(fir_base + IRCC_CONTROL) & 0x30) | ctrl, fir_base + IRCC_CONTROL);
  725. }
  726. /*
  727. * Function smsc_ircc_fir_start(self)
  728. *
  729. * Change the speed of the device
  730. *
  731. */
  732. static void smsc_ircc_fir_start(struct smsc_ircc_cb *self)
  733. {
  734. struct net_device *dev;
  735. int fir_base;
  736. IRDA_DEBUG(1, "%s\n", __FUNCTION__);
  737. IRDA_ASSERT(self != NULL, return;);
  738. dev = self->netdev;
  739. IRDA_ASSERT(dev != NULL, return;);
  740. fir_base = self->io.fir_base;
  741. /* Reset everything */
  742. /* Install FIR transmit handler */
  743. dev->hard_start_xmit = smsc_ircc_hard_xmit_fir;
  744. /* Clear FIFO */
  745. outb(inb(fir_base + IRCC_LCR_A) | IRCC_LCR_A_FIFO_RESET, fir_base + IRCC_LCR_A);
  746. /* Enable interrupt */
  747. /*outb(IRCC_IER_ACTIVE_FRAME|IRCC_IER_EOM, fir_base + IRCC_IER);*/
  748. register_bank(fir_base, 1);
  749. /* Select the TX/RX interface */
  750. #ifdef SMSC_669 /* Uses pin 88/89 for Rx/Tx */
  751. outb(((inb(fir_base + IRCC_SCE_CFGB) & 0x3f) | IRCC_CFGB_MUX_COM),
  752. fir_base + IRCC_SCE_CFGB);
  753. #else
  754. outb(((inb(fir_base + IRCC_SCE_CFGB) & 0x3f) | IRCC_CFGB_MUX_IR),
  755. fir_base + IRCC_SCE_CFGB);
  756. #endif
  757. (void) inb(fir_base + IRCC_FIFO_THRESHOLD);
  758. /* Enable SCE interrupts */
  759. outb(0, fir_base + IRCC_MASTER);
  760. register_bank(fir_base, 0);
  761. outb(IRCC_IER_ACTIVE_FRAME | IRCC_IER_EOM, fir_base + IRCC_IER);
  762. outb(IRCC_MASTER_INT_EN, fir_base + IRCC_MASTER);
  763. }
  764. /*
  765. * Function smsc_ircc_fir_stop(self, baud)
  766. *
  767. * Change the speed of the device
  768. *
  769. */
  770. static void smsc_ircc_fir_stop(struct smsc_ircc_cb *self)
  771. {
  772. int fir_base;
  773. IRDA_DEBUG(1, "%s\n", __FUNCTION__);
  774. IRDA_ASSERT(self != NULL, return;);
  775. fir_base = self->io.fir_base;
  776. register_bank(fir_base, 0);
  777. /*outb(IRCC_MASTER_RESET, fir_base + IRCC_MASTER);*/
  778. outb(inb(fir_base + IRCC_LCR_B) & IRCC_LCR_B_SIP_ENABLE, fir_base + IRCC_LCR_B);
  779. }
  780. /*
  781. * Function smsc_ircc_change_speed(self, baud)
  782. *
  783. * Change the speed of the device
  784. *
  785. * This function *must* be called with spinlock held, because it may
  786. * be called from the irq handler. - Jean II
  787. */
  788. static void smsc_ircc_change_speed(void *priv, u32 speed)
  789. {
  790. struct smsc_ircc_cb *self = (struct smsc_ircc_cb *) priv;
  791. struct net_device *dev;
  792. int last_speed_was_sir;
  793. IRDA_DEBUG(0, "%s() changing speed to: %d\n", __FUNCTION__, speed);
  794. IRDA_ASSERT(self != NULL, return;);
  795. dev = self->netdev;
  796. last_speed_was_sir = self->io.speed <= SMSC_IRCC2_MAX_SIR_SPEED;
  797. #if 0
  798. /* Temp Hack */
  799. speed= 1152000;
  800. self->io.speed = speed;
  801. last_speed_was_sir = 0;
  802. smsc_ircc_fir_start(self);
  803. #endif
  804. if (self->io.speed == 0)
  805. smsc_ircc_sir_start(self);
  806. #if 0
  807. if (!last_speed_was_sir) speed = self->io.speed;
  808. #endif
  809. if (self->io.speed != speed)
  810. smsc_ircc_set_transceiver_for_speed(self, speed);
  811. self->io.speed = speed;
  812. if (speed <= SMSC_IRCC2_MAX_SIR_SPEED) {
  813. if (!last_speed_was_sir) {
  814. smsc_ircc_fir_stop(self);
  815. smsc_ircc_sir_start(self);
  816. }
  817. smsc_ircc_set_sir_speed(self, speed);
  818. } else {
  819. if (last_speed_was_sir) {
  820. #if SMSC_IRCC2_C_SIR_STOP
  821. smsc_ircc_sir_stop(self);
  822. #endif
  823. smsc_ircc_fir_start(self);
  824. }
  825. smsc_ircc_set_fir_speed(self, speed);
  826. #if 0
  827. self->tx_buff.len = 10;
  828. self->tx_buff.data = self->tx_buff.head;
  829. smsc_ircc_dma_xmit(self, 4000);
  830. #endif
  831. /* Be ready for incoming frames */
  832. smsc_ircc_dma_receive(self);
  833. }
  834. netif_wake_queue(dev);
  835. }
  836. /*
  837. * Function smsc_ircc_set_sir_speed (self, speed)
  838. *
  839. * Set speed of IrDA port to specified baudrate
  840. *
  841. */
  842. void smsc_ircc_set_sir_speed(void *priv, __u32 speed)
  843. {
  844. struct smsc_ircc_cb *self = (struct smsc_ircc_cb *) priv;
  845. int iobase;
  846. int fcr; /* FIFO control reg */
  847. int lcr; /* Line control reg */
  848. int divisor;
  849. IRDA_DEBUG(0, "%s(), Setting speed to: %d\n", __FUNCTION__, speed);
  850. IRDA_ASSERT(self != NULL, return;);
  851. iobase = self->io.sir_base;
  852. /* Update accounting for new speed */
  853. self->io.speed = speed;
  854. /* Turn off interrupts */
  855. outb(0, iobase + UART_IER);
  856. divisor = SMSC_IRCC2_MAX_SIR_SPEED / speed;
  857. fcr = UART_FCR_ENABLE_FIFO;
  858. /*
  859. * Use trigger level 1 to avoid 3 ms. timeout delay at 9600 bps, and
  860. * almost 1,7 ms at 19200 bps. At speeds above that we can just forget
  861. * about this timeout since it will always be fast enough.
  862. */
  863. fcr |= self->io.speed < 38400 ?
  864. UART_FCR_TRIGGER_1 : UART_FCR_TRIGGER_14;
  865. /* IrDA ports use 8N1 */
  866. lcr = UART_LCR_WLEN8;
  867. outb(UART_LCR_DLAB | lcr, iobase + UART_LCR); /* Set DLAB */
  868. outb(divisor & 0xff, iobase + UART_DLL); /* Set speed */
  869. outb(divisor >> 8, iobase + UART_DLM);
  870. outb(lcr, iobase + UART_LCR); /* Set 8N1 */
  871. outb(fcr, iobase + UART_FCR); /* Enable FIFO's */
  872. /* Turn on interrups */
  873. outb(UART_IER_RLSI | UART_IER_RDI | UART_IER_THRI, iobase + UART_IER);
  874. IRDA_DEBUG(2, "%s() speed changed to: %d\n", __FUNCTION__, speed);
  875. }
  876. /*
  877. * Function smsc_ircc_hard_xmit_fir (skb, dev)
  878. *
  879. * Transmit the frame!
  880. *
  881. */
  882. static int smsc_ircc_hard_xmit_fir(struct sk_buff *skb, struct net_device *dev)
  883. {
  884. struct smsc_ircc_cb *self;
  885. unsigned long flags;
  886. s32 speed;
  887. int mtt;
  888. IRDA_ASSERT(dev != NULL, return 0;);
  889. self = (struct smsc_ircc_cb *) dev->priv;
  890. IRDA_ASSERT(self != NULL, return 0;);
  891. netif_stop_queue(dev);
  892. /* Make sure test of self->io.speed & speed change are atomic */
  893. spin_lock_irqsave(&self->lock, flags);
  894. /* Check if we need to change the speed after this frame */
  895. speed = irda_get_next_speed(skb);
  896. if (speed != self->io.speed && speed != -1) {
  897. /* Check for empty frame */
  898. if (!skb->len) {
  899. /* Note : you should make sure that speed changes
  900. * are not going to corrupt any outgoing frame.
  901. * Look at nsc-ircc for the gory details - Jean II */
  902. smsc_ircc_change_speed(self, speed);
  903. spin_unlock_irqrestore(&self->lock, flags);
  904. dev_kfree_skb(skb);
  905. return 0;
  906. }
  907. self->new_speed = speed;
  908. }
  909. memcpy(self->tx_buff.head, skb->data, skb->len);
  910. self->tx_buff.len = skb->len;
  911. self->tx_buff.data = self->tx_buff.head;
  912. mtt = irda_get_mtt(skb);
  913. if (mtt) {
  914. int bofs;
  915. /*
  916. * Compute how many BOFs (STA or PA's) we need to waste the
  917. * min turn time given the speed of the link.
  918. */
  919. bofs = mtt * (self->io.speed / 1000) / 8000;
  920. if (bofs > 4095)
  921. bofs = 4095;
  922. smsc_ircc_dma_xmit(self, bofs);
  923. } else {
  924. /* Transmit frame */
  925. smsc_ircc_dma_xmit(self, 0);
  926. }
  927. spin_unlock_irqrestore(&self->lock, flags);
  928. dev_kfree_skb(skb);
  929. return 0;
  930. }
  931. /*
  932. * Function smsc_ircc_dma_xmit (self, bofs)
  933. *
  934. * Transmit data using DMA
  935. *
  936. */
  937. static void smsc_ircc_dma_xmit(struct smsc_ircc_cb *self, int bofs)
  938. {
  939. int iobase = self->io.fir_base;
  940. u8 ctrl;
  941. IRDA_DEBUG(3, "%s\n", __FUNCTION__);
  942. #if 1
  943. /* Disable Rx */
  944. register_bank(iobase, 0);
  945. outb(0x00, iobase + IRCC_LCR_B);
  946. #endif
  947. register_bank(iobase, 1);
  948. outb(inb(iobase + IRCC_SCE_CFGB) & ~IRCC_CFGB_DMA_ENABLE,
  949. iobase + IRCC_SCE_CFGB);
  950. self->io.direction = IO_XMIT;
  951. /* Set BOF additional count for generating the min turn time */
  952. register_bank(iobase, 4);
  953. outb(bofs & 0xff, iobase + IRCC_BOF_COUNT_LO);
  954. ctrl = inb(iobase + IRCC_CONTROL) & 0xf0;
  955. outb(ctrl | ((bofs >> 8) & 0x0f), iobase + IRCC_BOF_COUNT_HI);
  956. /* Set max Tx frame size */
  957. outb(self->tx_buff.len >> 8, iobase + IRCC_TX_SIZE_HI);
  958. outb(self->tx_buff.len & 0xff, iobase + IRCC_TX_SIZE_LO);
  959. /*outb(UART_MCR_OUT2, self->io.sir_base + UART_MCR);*/
  960. /* Enable burst mode chip Tx DMA */
  961. register_bank(iobase, 1);
  962. outb(inb(iobase + IRCC_SCE_CFGB) | IRCC_CFGB_DMA_ENABLE |
  963. IRCC_CFGB_DMA_BURST, iobase + IRCC_SCE_CFGB);
  964. /* Setup DMA controller (must be done after enabling chip DMA) */
  965. irda_setup_dma(self->io.dma, self->tx_buff_dma, self->tx_buff.len,
  966. DMA_TX_MODE);
  967. /* Enable interrupt */
  968. register_bank(iobase, 0);
  969. outb(IRCC_IER_ACTIVE_FRAME | IRCC_IER_EOM, iobase + IRCC_IER);
  970. outb(IRCC_MASTER_INT_EN, iobase + IRCC_MASTER);
  971. /* Enable transmit */
  972. outb(IRCC_LCR_B_SCE_TRANSMIT | IRCC_LCR_B_SIP_ENABLE, iobase + IRCC_LCR_B);
  973. }
  974. /*
  975. * Function smsc_ircc_dma_xmit_complete (self)
  976. *
  977. * The transfer of a frame in finished. This function will only be called
  978. * by the interrupt handler
  979. *
  980. */
  981. static void smsc_ircc_dma_xmit_complete(struct smsc_ircc_cb *self)
  982. {
  983. int iobase = self->io.fir_base;
  984. IRDA_DEBUG(3, "%s\n", __FUNCTION__);
  985. #if 0
  986. /* Disable Tx */
  987. register_bank(iobase, 0);
  988. outb(0x00, iobase + IRCC_LCR_B);
  989. #endif
  990. register_bank(iobase, 1);
  991. outb(inb(iobase + IRCC_SCE_CFGB) & ~IRCC_CFGB_DMA_ENABLE,
  992. iobase + IRCC_SCE_CFGB);
  993. /* Check for underrun! */
  994. register_bank(iobase, 0);
  995. if (inb(iobase + IRCC_LSR) & IRCC_LSR_UNDERRUN) {
  996. self->stats.tx_errors++;
  997. self->stats.tx_fifo_errors++;
  998. /* Reset error condition */
  999. register_bank(iobase, 0);
  1000. outb(IRCC_MASTER_ERROR_RESET, iobase + IRCC_MASTER);
  1001. outb(0x00, iobase + IRCC_MASTER);
  1002. } else {
  1003. self->stats.tx_packets++;
  1004. self->stats.tx_bytes += self->tx_buff.len;
  1005. }
  1006. /* Check if it's time to change the speed */
  1007. if (self->new_speed) {
  1008. smsc_ircc_change_speed(self, self->new_speed);
  1009. self->new_speed = 0;
  1010. }
  1011. netif_wake_queue(self->netdev);
  1012. }
  1013. /*
  1014. * Function smsc_ircc_dma_receive(self)
  1015. *
  1016. * Get ready for receiving a frame. The device will initiate a DMA
  1017. * if it starts to receive a frame.
  1018. *
  1019. */
  1020. static int smsc_ircc_dma_receive(struct smsc_ircc_cb *self)
  1021. {
  1022. int iobase = self->io.fir_base;
  1023. #if 0
  1024. /* Turn off chip DMA */
  1025. register_bank(iobase, 1);
  1026. outb(inb(iobase + IRCC_SCE_CFGB) & ~IRCC_CFGB_DMA_ENABLE,
  1027. iobase + IRCC_SCE_CFGB);
  1028. #endif
  1029. /* Disable Tx */
  1030. register_bank(iobase, 0);
  1031. outb(0x00, iobase + IRCC_LCR_B);
  1032. /* Turn off chip DMA */
  1033. register_bank(iobase, 1);
  1034. outb(inb(iobase + IRCC_SCE_CFGB) & ~IRCC_CFGB_DMA_ENABLE,
  1035. iobase + IRCC_SCE_CFGB);
  1036. self->io.direction = IO_RECV;
  1037. self->rx_buff.data = self->rx_buff.head;
  1038. /* Set max Rx frame size */
  1039. register_bank(iobase, 4);
  1040. outb((2050 >> 8) & 0x0f, iobase + IRCC_RX_SIZE_HI);
  1041. outb(2050 & 0xff, iobase + IRCC_RX_SIZE_LO);
  1042. /* Setup DMA controller */
  1043. irda_setup_dma(self->io.dma, self->rx_buff_dma, self->rx_buff.truesize,
  1044. DMA_RX_MODE);
  1045. /* Enable burst mode chip Rx DMA */
  1046. register_bank(iobase, 1);
  1047. outb(inb(iobase + IRCC_SCE_CFGB) | IRCC_CFGB_DMA_ENABLE |
  1048. IRCC_CFGB_DMA_BURST, iobase + IRCC_SCE_CFGB);
  1049. /* Enable interrupt */
  1050. register_bank(iobase, 0);
  1051. outb(IRCC_IER_ACTIVE_FRAME | IRCC_IER_EOM, iobase + IRCC_IER);
  1052. outb(IRCC_MASTER_INT_EN, iobase + IRCC_MASTER);
  1053. /* Enable receiver */
  1054. register_bank(iobase, 0);
  1055. outb(IRCC_LCR_B_SCE_RECEIVE | IRCC_LCR_B_SIP_ENABLE,
  1056. iobase + IRCC_LCR_B);
  1057. return 0;
  1058. }
  1059. /*
  1060. * Function smsc_ircc_dma_receive_complete(self)
  1061. *
  1062. * Finished with receiving frames
  1063. *
  1064. */
  1065. static void smsc_ircc_dma_receive_complete(struct smsc_ircc_cb *self)
  1066. {
  1067. struct sk_buff *skb;
  1068. int len, msgcnt, lsr;
  1069. int iobase = self->io.fir_base;
  1070. register_bank(iobase, 0);
  1071. IRDA_DEBUG(3, "%s\n", __FUNCTION__);
  1072. #if 0
  1073. /* Disable Rx */
  1074. register_bank(iobase, 0);
  1075. outb(0x00, iobase + IRCC_LCR_B);
  1076. #endif
  1077. register_bank(iobase, 0);
  1078. outb(inb(iobase + IRCC_LSAR) & ~IRCC_LSAR_ADDRESS_MASK, iobase + IRCC_LSAR);
  1079. lsr= inb(iobase + IRCC_LSR);
  1080. msgcnt = inb(iobase + IRCC_LCR_B) & 0x08;
  1081. IRDA_DEBUG(2, "%s: dma count = %d\n", __FUNCTION__,
  1082. get_dma_residue(self->io.dma));
  1083. len = self->rx_buff.truesize - get_dma_residue(self->io.dma);
  1084. /* Look for errors */
  1085. if (lsr & (IRCC_LSR_FRAME_ERROR | IRCC_LSR_CRC_ERROR | IRCC_LSR_SIZE_ERROR)) {
  1086. self->stats.rx_errors++;
  1087. if (lsr & IRCC_LSR_FRAME_ERROR)
  1088. self->stats.rx_frame_errors++;
  1089. if (lsr & IRCC_LSR_CRC_ERROR)
  1090. self->stats.rx_crc_errors++;
  1091. if (lsr & IRCC_LSR_SIZE_ERROR)
  1092. self->stats.rx_length_errors++;
  1093. if (lsr & (IRCC_LSR_UNDERRUN | IRCC_LSR_OVERRUN))
  1094. self->stats.rx_length_errors++;
  1095. return;
  1096. }
  1097. /* Remove CRC */
  1098. len -= self->io.speed < 4000000 ? 2 : 4;
  1099. if (len < 2 || len > 2050) {
  1100. IRDA_WARNING("%s(), bogus len=%d\n", __FUNCTION__, len);
  1101. return;
  1102. }
  1103. IRDA_DEBUG(2, "%s: msgcnt = %d, len=%d\n", __FUNCTION__, msgcnt, len);
  1104. skb = dev_alloc_skb(len + 1);
  1105. if (!skb) {
  1106. IRDA_WARNING("%s(), memory squeeze, dropping frame.\n",
  1107. __FUNCTION__);
  1108. return;
  1109. }
  1110. /* Make sure IP header gets aligned */
  1111. skb_reserve(skb, 1);
  1112. memcpy(skb_put(skb, len), self->rx_buff.data, len);
  1113. self->stats.rx_packets++;
  1114. self->stats.rx_bytes += len;
  1115. skb->dev = self->netdev;
  1116. skb->mac.raw = skb->data;
  1117. skb->protocol = htons(ETH_P_IRDA);
  1118. netif_rx(skb);
  1119. }
  1120. /*
  1121. * Function smsc_ircc_sir_receive (self)
  1122. *
  1123. * Receive one frame from the infrared port
  1124. *
  1125. */
  1126. static void smsc_ircc_sir_receive(struct smsc_ircc_cb *self)
  1127. {
  1128. int boguscount = 0;
  1129. int iobase;
  1130. IRDA_ASSERT(self != NULL, return;);
  1131. iobase = self->io.sir_base;
  1132. /*
  1133. * Receive all characters in Rx FIFO, unwrap and unstuff them.
  1134. * async_unwrap_char will deliver all found frames
  1135. */
  1136. do {
  1137. async_unwrap_char(self->netdev, &self->stats, &self->rx_buff,
  1138. inb(iobase + UART_RX));
  1139. /* Make sure we don't stay here to long */
  1140. if (boguscount++ > 32) {
  1141. IRDA_DEBUG(2, "%s(), breaking!\n", __FUNCTION__);
  1142. break;
  1143. }
  1144. } while (inb(iobase + UART_LSR) & UART_LSR_DR);
  1145. }
  1146. /*
  1147. * Function smsc_ircc_interrupt (irq, dev_id, regs)
  1148. *
  1149. * An interrupt from the chip has arrived. Time to do some work
  1150. *
  1151. */
  1152. static irqreturn_t smsc_ircc_interrupt(int irq, void *dev_id, struct pt_regs *regs)
  1153. {
  1154. struct net_device *dev = (struct net_device *) dev_id;
  1155. struct smsc_ircc_cb *self;
  1156. int iobase, iir, lcra, lsr;
  1157. irqreturn_t ret = IRQ_NONE;
  1158. if (dev == NULL) {
  1159. printk(KERN_WARNING "%s: irq %d for unknown device.\n",
  1160. driver_name, irq);
  1161. goto irq_ret;
  1162. }
  1163. self = (struct smsc_ircc_cb *) dev->priv;
  1164. IRDA_ASSERT(self != NULL, return IRQ_NONE;);
  1165. /* Serialise the interrupt handler in various CPUs, stop Tx path */
  1166. spin_lock(&self->lock);
  1167. /* Check if we should use the SIR interrupt handler */
  1168. if (self->io.speed <= SMSC_IRCC2_MAX_SIR_SPEED) {
  1169. ret = smsc_ircc_interrupt_sir(dev);
  1170. goto irq_ret_unlock;
  1171. }
  1172. iobase = self->io.fir_base;
  1173. register_bank(iobase, 0);
  1174. iir = inb(iobase + IRCC_IIR);
  1175. if (iir == 0)
  1176. goto irq_ret_unlock;
  1177. ret = IRQ_HANDLED;
  1178. /* Disable interrupts */
  1179. outb(0, iobase + IRCC_IER);
  1180. lcra = inb(iobase + IRCC_LCR_A);
  1181. lsr = inb(iobase + IRCC_LSR);
  1182. IRDA_DEBUG(2, "%s(), iir = 0x%02x\n", __FUNCTION__, iir);
  1183. if (iir & IRCC_IIR_EOM) {
  1184. if (self->io.direction == IO_RECV)
  1185. smsc_ircc_dma_receive_complete(self);
  1186. else
  1187. smsc_ircc_dma_xmit_complete(self);
  1188. smsc_ircc_dma_receive(self);
  1189. }
  1190. if (iir & IRCC_IIR_ACTIVE_FRAME) {
  1191. /*printk(KERN_WARNING "%s(): Active Frame\n", __FUNCTION__);*/
  1192. }
  1193. /* Enable interrupts again */
  1194. register_bank(iobase, 0);
  1195. outb(IRCC_IER_ACTIVE_FRAME | IRCC_IER_EOM, iobase + IRCC_IER);
  1196. irq_ret_unlock:
  1197. spin_unlock(&self->lock);
  1198. irq_ret:
  1199. return ret;
  1200. }
  1201. /*
  1202. * Function irport_interrupt_sir (irq, dev_id, regs)
  1203. *
  1204. * Interrupt handler for SIR modes
  1205. */
  1206. static irqreturn_t smsc_ircc_interrupt_sir(struct net_device *dev)
  1207. {
  1208. struct smsc_ircc_cb *self = dev->priv;
  1209. int boguscount = 0;
  1210. int iobase;
  1211. int iir, lsr;
  1212. /* Already locked comming here in smsc_ircc_interrupt() */
  1213. /*spin_lock(&self->lock);*/
  1214. iobase = self->io.sir_base;
  1215. iir = inb(iobase + UART_IIR) & UART_IIR_ID;
  1216. if (iir == 0)
  1217. return IRQ_NONE;
  1218. while (iir) {
  1219. /* Clear interrupt */
  1220. lsr = inb(iobase + UART_LSR);
  1221. IRDA_DEBUG(4, "%s(), iir=%02x, lsr=%02x, iobase=%#x\n",
  1222. __FUNCTION__, iir, lsr, iobase);
  1223. switch (iir) {
  1224. case UART_IIR_RLSI:
  1225. IRDA_DEBUG(2, "%s(), RLSI\n", __FUNCTION__);
  1226. break;
  1227. case UART_IIR_RDI:
  1228. /* Receive interrupt */
  1229. smsc_ircc_sir_receive(self);
  1230. break;
  1231. case UART_IIR_THRI:
  1232. if (lsr & UART_LSR_THRE)
  1233. /* Transmitter ready for data */
  1234. smsc_ircc_sir_write_wakeup(self);
  1235. break;
  1236. default:
  1237. IRDA_DEBUG(0, "%s(), unhandled IIR=%#x\n",
  1238. __FUNCTION__, iir);
  1239. break;
  1240. }
  1241. /* Make sure we don't stay here to long */
  1242. if (boguscount++ > 100)
  1243. break;
  1244. iir = inb(iobase + UART_IIR) & UART_IIR_ID;
  1245. }
  1246. /*spin_unlock(&self->lock);*/
  1247. return IRQ_HANDLED;
  1248. }
  1249. #if 0 /* unused */
  1250. /*
  1251. * Function ircc_is_receiving (self)
  1252. *
  1253. * Return TRUE is we are currently receiving a frame
  1254. *
  1255. */
  1256. static int ircc_is_receiving(struct smsc_ircc_cb *self)
  1257. {
  1258. int status = FALSE;
  1259. /* int iobase; */
  1260. IRDA_DEBUG(1, "%s\n", __FUNCTION__);
  1261. IRDA_ASSERT(self != NULL, return FALSE;);
  1262. IRDA_DEBUG(0, "%s: dma count = %d\n", __FUNCTION__,
  1263. get_dma_residue(self->io.dma));
  1264. status = (self->rx_buff.state != OUTSIDE_FRAME);
  1265. return status;
  1266. }
  1267. #endif /* unused */
  1268. /*
  1269. * Function smsc_ircc_net_open (dev)
  1270. *
  1271. * Start the device
  1272. *
  1273. */
  1274. static int smsc_ircc_net_open(struct net_device *dev)
  1275. {
  1276. struct smsc_ircc_cb *self;
  1277. char hwname[16];
  1278. unsigned long flags;
  1279. IRDA_DEBUG(1, "%s\n", __FUNCTION__);
  1280. IRDA_ASSERT(dev != NULL, return -1;);
  1281. self = (struct smsc_ircc_cb *) dev->priv;
  1282. IRDA_ASSERT(self != NULL, return 0;);
  1283. if (request_irq(self->io.irq, smsc_ircc_interrupt, 0, dev->name,
  1284. (void *) dev)) {
  1285. IRDA_DEBUG(0, "%s(), unable to allocate irq=%d\n",
  1286. __FUNCTION__, self->io.irq);
  1287. return -EAGAIN;
  1288. }
  1289. spin_lock_irqsave(&self->lock, flags);
  1290. /*smsc_ircc_sir_start(self);*/
  1291. self->io.speed = 0;
  1292. smsc_ircc_change_speed(self, SMSC_IRCC2_C_IRDA_FALLBACK_SPEED);
  1293. spin_unlock_irqrestore(&self->lock, flags);
  1294. /* Give self a hardware name */
  1295. /* It would be cool to offer the chip revision here - Jean II */
  1296. sprintf(hwname, "SMSC @ 0x%03x", self->io.fir_base);
  1297. /*
  1298. * Open new IrLAP layer instance, now that everything should be
  1299. * initialized properly
  1300. */
  1301. self->irlap = irlap_open(dev, &self->qos, hwname);
  1302. /*
  1303. * Always allocate the DMA channel after the IRQ,
  1304. * and clean up on failure.
  1305. */
  1306. if (request_dma(self->io.dma, dev->name)) {
  1307. smsc_ircc_net_close(dev);
  1308. IRDA_WARNING("%s(), unable to allocate DMA=%d\n",
  1309. __FUNCTION__, self->io.dma);
  1310. return -EAGAIN;
  1311. }
  1312. netif_start_queue(dev);
  1313. return 0;
  1314. }
  1315. /*
  1316. * Function smsc_ircc_net_close (dev)
  1317. *
  1318. * Stop the device
  1319. *
  1320. */
  1321. static int smsc_ircc_net_close(struct net_device *dev)
  1322. {
  1323. struct smsc_ircc_cb *self;
  1324. IRDA_DEBUG(1, "%s\n", __FUNCTION__);
  1325. IRDA_ASSERT(dev != NULL, return -1;);
  1326. self = (struct smsc_ircc_cb *) dev->priv;
  1327. IRDA_ASSERT(self != NULL, return 0;);
  1328. /* Stop device */
  1329. netif_stop_queue(dev);
  1330. /* Stop and remove instance of IrLAP */
  1331. if (self->irlap)
  1332. irlap_close(self->irlap);
  1333. self->irlap = NULL;
  1334. free_irq(self->io.irq, dev);
  1335. disable_dma(self->io.dma);
  1336. free_dma(self->io.dma);
  1337. return 0;
  1338. }
  1339. static void smsc_ircc_suspend(struct smsc_ircc_cb *self)
  1340. {
  1341. IRDA_MESSAGE("%s, Suspending\n", driver_name);
  1342. if (!self->io.suspended) {
  1343. smsc_ircc_net_close(self->netdev);
  1344. self->io.suspended = 1;
  1345. }
  1346. }
  1347. static void smsc_ircc_wakeup(struct smsc_ircc_cb *self)
  1348. {
  1349. if (!self->io.suspended)
  1350. return;
  1351. /* The code was doing a "cli()" here, but this can't be right.
  1352. * If you need protection, do it in net_open with a spinlock
  1353. * or give a good reason. - Jean II */
  1354. smsc_ircc_net_open(self->netdev);
  1355. IRDA_MESSAGE("%s, Waking up\n", driver_name);
  1356. }
  1357. static int smsc_ircc_pmproc(struct pm_dev *dev, pm_request_t rqst, void *data)
  1358. {
  1359. struct smsc_ircc_cb *self = (struct smsc_ircc_cb*) dev->data;
  1360. if (self) {
  1361. switch (rqst) {
  1362. case PM_SUSPEND:
  1363. smsc_ircc_suspend(self);
  1364. break;
  1365. case PM_RESUME:
  1366. smsc_ircc_wakeup(self);
  1367. break;
  1368. }
  1369. }
  1370. return 0;
  1371. }
  1372. /*
  1373. * Function smsc_ircc_close (self)
  1374. *
  1375. * Close driver instance
  1376. *
  1377. */
  1378. static int __exit smsc_ircc_close(struct smsc_ircc_cb *self)
  1379. {
  1380. int iobase;
  1381. unsigned long flags;
  1382. IRDA_DEBUG(1, "%s\n", __FUNCTION__);
  1383. IRDA_ASSERT(self != NULL, return -1;);
  1384. iobase = self->io.fir_base;
  1385. if (self->pmdev)
  1386. pm_unregister(self->pmdev);
  1387. /* Remove netdevice */
  1388. unregister_netdev(self->netdev);
  1389. /* Make sure the irq handler is not exectuting */
  1390. spin_lock_irqsave(&self->lock, flags);
  1391. /* Stop interrupts */
  1392. register_bank(iobase, 0);
  1393. outb(0, iobase + IRCC_IER);
  1394. outb(IRCC_MASTER_RESET, iobase + IRCC_MASTER);
  1395. outb(0x00, iobase + IRCC_MASTER);
  1396. #if 0
  1397. /* Reset to SIR mode */
  1398. register_bank(iobase, 1);
  1399. outb(IRCC_CFGA_IRDA_SIR_A|IRCC_CFGA_TX_POLARITY, iobase + IRCC_SCE_CFGA);
  1400. outb(IRCC_CFGB_IR, iobase + IRCC_SCE_CFGB);
  1401. #endif
  1402. spin_unlock_irqrestore(&self->lock, flags);
  1403. /* Release the PORTS that this driver is using */
  1404. IRDA_DEBUG(0, "%s(), releasing 0x%03x\n", __FUNCTION__,
  1405. self->io.fir_base);
  1406. release_region(self->io.fir_base, self->io.fir_ext);
  1407. IRDA_DEBUG(0, "%s(), releasing 0x%03x\n", __FUNCTION__,
  1408. self->io.sir_base);
  1409. release_region(self->io.sir_base, self->io.sir_ext);
  1410. if (self->tx_buff.head)
  1411. dma_free_coherent(NULL, self->tx_buff.truesize,
  1412. self->tx_buff.head, self->tx_buff_dma);
  1413. if (self->rx_buff.head)
  1414. dma_free_coherent(NULL, self->rx_buff.truesize,
  1415. self->rx_buff.head, self->rx_buff_dma);
  1416. free_netdev(self->netdev);
  1417. return 0;
  1418. }
  1419. static void __exit smsc_ircc_cleanup(void)
  1420. {
  1421. int i;
  1422. IRDA_DEBUG(1, "%s\n", __FUNCTION__);
  1423. for (i = 0; i < 2; i++) {
  1424. if (dev_self[i])
  1425. smsc_ircc_close(dev_self[i]);
  1426. }
  1427. }
  1428. /*
  1429. * Start SIR operations
  1430. *
  1431. * This function *must* be called with spinlock held, because it may
  1432. * be called from the irq handler (via smsc_ircc_change_speed()). - Jean II
  1433. */
  1434. void smsc_ircc_sir_start(struct smsc_ircc_cb *self)
  1435. {
  1436. struct net_device *dev;
  1437. int fir_base, sir_base;
  1438. IRDA_DEBUG(3, "%s\n", __FUNCTION__);
  1439. IRDA_ASSERT(self != NULL, return;);
  1440. dev = self->netdev;
  1441. IRDA_ASSERT(dev != NULL, return;);
  1442. dev->hard_start_xmit = &smsc_ircc_hard_xmit_sir;
  1443. fir_base = self->io.fir_base;
  1444. sir_base = self->io.sir_base;
  1445. /* Reset everything */
  1446. outb(IRCC_MASTER_RESET, fir_base + IRCC_MASTER);
  1447. #if SMSC_IRCC2_C_SIR_STOP
  1448. /*smsc_ircc_sir_stop(self);*/
  1449. #endif
  1450. register_bank(fir_base, 1);
  1451. outb(((inb(fir_base + IRCC_SCE_CFGA) & IRCC_SCE_CFGA_BLOCK_CTRL_BITS_MASK) | IRCC_CFGA_IRDA_SIR_A), fir_base + IRCC_SCE_CFGA);
  1452. /* Initialize UART */
  1453. outb(UART_LCR_WLEN8, sir_base + UART_LCR); /* Reset DLAB */
  1454. outb((UART_MCR_DTR | UART_MCR_RTS | UART_MCR_OUT2), sir_base + UART_MCR);
  1455. /* Turn on interrups */
  1456. outb(UART_IER_RLSI | UART_IER_RDI |UART_IER_THRI, sir_base + UART_IER);
  1457. IRDA_DEBUG(3, "%s() - exit\n", __FUNCTION__);
  1458. outb(0x00, fir_base + IRCC_MASTER);
  1459. }
  1460. #if SMSC_IRCC2_C_SIR_STOP
  1461. void smsc_ircc_sir_stop(struct smsc_ircc_cb *self)
  1462. {
  1463. int iobase;
  1464. IRDA_DEBUG(3, "%s\n", __FUNCTION__);
  1465. iobase = self->io.sir_base;
  1466. /* Reset UART */
  1467. outb(0, iobase + UART_MCR);
  1468. /* Turn off interrupts */
  1469. outb(0, iobase + UART_IER);
  1470. }
  1471. #endif
  1472. /*
  1473. * Function smsc_sir_write_wakeup (self)
  1474. *
  1475. * Called by the SIR interrupt handler when there's room for more data.
  1476. * If we have more packets to send, we send them here.
  1477. *
  1478. */
  1479. static void smsc_ircc_sir_write_wakeup(struct smsc_ircc_cb *self)
  1480. {
  1481. int actual = 0;
  1482. int iobase;
  1483. int fcr;
  1484. IRDA_ASSERT(self != NULL, return;);
  1485. IRDA_DEBUG(4, "%s\n", __FUNCTION__);
  1486. iobase = self->io.sir_base;
  1487. /* Finished with frame? */
  1488. if (self->tx_buff.len > 0) {
  1489. /* Write data left in transmit buffer */
  1490. actual = smsc_ircc_sir_write(iobase, self->io.fifo_size,
  1491. self->tx_buff.data, self->tx_buff.len);
  1492. self->tx_buff.data += actual;
  1493. self->tx_buff.len -= actual;
  1494. } else {
  1495. /*if (self->tx_buff.len ==0) {*/
  1496. /*
  1497. * Now serial buffer is almost free & we can start
  1498. * transmission of another packet. But first we must check
  1499. * if we need to change the speed of the hardware
  1500. */
  1501. if (self->new_speed) {
  1502. IRDA_DEBUG(5, "%s(), Changing speed to %d.\n",
  1503. __FUNCTION__, self->new_speed);
  1504. smsc_ircc_sir_wait_hw_transmitter_finish(self);
  1505. smsc_ircc_change_speed(self, self->new_speed);
  1506. self->new_speed = 0;
  1507. } else {
  1508. /* Tell network layer that we want more frames */
  1509. netif_wake_queue(self->netdev);
  1510. }
  1511. self->stats.tx_packets++;
  1512. if (self->io.speed <= 115200) {
  1513. /*
  1514. * Reset Rx FIFO to make sure that all reflected transmit data
  1515. * is discarded. This is needed for half duplex operation
  1516. */
  1517. fcr = UART_FCR_ENABLE_FIFO | UART_FCR_CLEAR_RCVR;
  1518. fcr |= self->io.speed < 38400 ?
  1519. UART_FCR_TRIGGER_1 : UART_FCR_TRIGGER_14;
  1520. outb(fcr, iobase + UART_FCR);
  1521. /* Turn on receive interrupts */
  1522. outb(UART_IER_RDI, iobase + UART_IER);
  1523. }
  1524. }
  1525. }
  1526. /*
  1527. * Function smsc_ircc_sir_write (iobase, fifo_size, buf, len)
  1528. *
  1529. * Fill Tx FIFO with transmit data
  1530. *
  1531. */
  1532. static int smsc_ircc_sir_write(int iobase, int fifo_size, __u8 *buf, int len)
  1533. {
  1534. int actual = 0;
  1535. /* Tx FIFO should be empty! */
  1536. if (!(inb(iobase + UART_LSR) & UART_LSR_THRE)) {
  1537. IRDA_WARNING("%s(), failed, fifo not empty!\n", __FUNCTION__);
  1538. return 0;
  1539. }
  1540. /* Fill FIFO with current frame */
  1541. while (fifo_size-- > 0 && actual < len) {
  1542. /* Transmit next byte */
  1543. outb(buf[actual], iobase + UART_TX);
  1544. actual++;
  1545. }
  1546. return actual;
  1547. }
  1548. /*
  1549. * Function smsc_ircc_is_receiving (self)
  1550. *
  1551. * Returns true is we are currently receiving data
  1552. *
  1553. */
  1554. static int smsc_ircc_is_receiving(struct smsc_ircc_cb *self)
  1555. {
  1556. return (self->rx_buff.state != OUTSIDE_FRAME);
  1557. }
  1558. /*
  1559. * Function smsc_ircc_probe_transceiver(self)
  1560. *
  1561. * Tries to find the used Transceiver
  1562. *
  1563. */
  1564. static void smsc_ircc_probe_transceiver(struct smsc_ircc_cb *self)
  1565. {
  1566. unsigned int i;
  1567. IRDA_ASSERT(self != NULL, return;);
  1568. for (i = 0; smsc_transceivers[i].name != NULL; i++)
  1569. if (smsc_transceivers[i].probe(self->io.fir_base)) {
  1570. IRDA_MESSAGE(" %s transceiver found\n",
  1571. smsc_transceivers[i].name);
  1572. self->transceiver= i + 1;
  1573. return;
  1574. }
  1575. IRDA_MESSAGE("No transceiver found. Defaulting to %s\n",
  1576. smsc_transceivers[SMSC_IRCC2_C_DEFAULT_TRANSCEIVER].name);
  1577. self->transceiver = SMSC_IRCC2_C_DEFAULT_TRANSCEIVER;
  1578. }
  1579. /*
  1580. * Function smsc_ircc_set_transceiver_for_speed(self, speed)
  1581. *
  1582. * Set the transceiver according to the speed
  1583. *
  1584. */
  1585. static void smsc_ircc_set_transceiver_for_speed(struct smsc_ircc_cb *self, u32 speed)
  1586. {
  1587. unsigned int trx;
  1588. trx = self->transceiver;
  1589. if (trx > 0)
  1590. smsc_transceivers[trx - 1].set_for_speed(self->io.fir_base, speed);
  1591. }
  1592. /*
  1593. * Function smsc_ircc_wait_hw_transmitter_finish ()
  1594. *
  1595. * Wait for the real end of HW transmission
  1596. *
  1597. * The UART is a strict FIFO, and we get called only when we have finished
  1598. * pushing data to the FIFO, so the maximum amount of time we must wait
  1599. * is only for the FIFO to drain out.
  1600. *
  1601. * We use a simple calibrated loop. We may need to adjust the loop
  1602. * delay (udelay) to balance I/O traffic and latency. And we also need to
  1603. * adjust the maximum timeout.
  1604. * It would probably be better to wait for the proper interrupt,
  1605. * but it doesn't seem to be available.
  1606. *
  1607. * We can't use jiffies or kernel timers because :
  1608. * 1) We are called from the interrupt handler, which disable softirqs,
  1609. * so jiffies won't be increased
  1610. * 2) Jiffies granularity is usually very coarse (10ms), and we don't
  1611. * want to wait that long to detect stuck hardware.
  1612. * Jean II
  1613. */
  1614. static void smsc_ircc_sir_wait_hw_transmitter_finish(struct smsc_ircc_cb *self)
  1615. {
  1616. int iobase = self->io.sir_base;
  1617. int count = SMSC_IRCC2_HW_TRANSMITTER_TIMEOUT_US;
  1618. /* Calibrated busy loop */
  1619. while (count-- > 0 && !(inb(iobase + UART_LSR) & UART_LSR_TEMT))
  1620. udelay(1);
  1621. if (count == 0)
  1622. IRDA_DEBUG(0, "%s(): stuck transmitter\n", __FUNCTION__);
  1623. }
  1624. /* PROBING
  1625. *
  1626. *
  1627. */
  1628. static int __init smsc_ircc_look_for_chips(void)
  1629. {
  1630. struct smsc_chip_address *address;
  1631. char *type;
  1632. unsigned int cfg_base, found;
  1633. found = 0;
  1634. address = possible_addresses;
  1635. while (address->cfg_base) {
  1636. cfg_base = address->cfg_base;
  1637. /*printk(KERN_WARNING "%s(): probing: 0x%02x for: 0x%02x\n", __FUNCTION__, cfg_base, address->type);*/
  1638. if (address->type & SMSCSIO_TYPE_FDC) {
  1639. type = "FDC";
  1640. if (address->type & SMSCSIO_TYPE_FLAT)
  1641. if (!smsc_superio_flat(fdc_chips_flat, cfg_base, type))
  1642. found++;
  1643. if (address->type & SMSCSIO_TYPE_PAGED)
  1644. if (!smsc_superio_paged(fdc_chips_paged, cfg_base, type))
  1645. found++;
  1646. }
  1647. if (address->type & SMSCSIO_TYPE_LPC) {
  1648. type = "LPC";
  1649. if (address->type & SMSCSIO_TYPE_FLAT)
  1650. if (!smsc_superio_flat(lpc_chips_flat, cfg_base, type))
  1651. found++;
  1652. if (address->type & SMSCSIO_TYPE_PAGED)
  1653. if (!smsc_superio_paged(lpc_chips_paged, cfg_base, type))
  1654. found++;
  1655. }
  1656. address++;
  1657. }
  1658. return found;
  1659. }
  1660. /*
  1661. * Function smsc_superio_flat (chip, base, type)
  1662. *
  1663. * Try to get configuration of a smc SuperIO chip with flat register model
  1664. *
  1665. */
  1666. static int __init smsc_superio_flat(const struct smsc_chip *chips, unsigned short cfgbase, char *type)
  1667. {
  1668. unsigned short firbase, sirbase;
  1669. u8 mode, dma, irq;
  1670. int ret = -ENODEV;
  1671. IRDA_DEBUG(1, "%s\n", __FUNCTION__);
  1672. if (smsc_ircc_probe(cfgbase, SMSCSIOFLAT_DEVICEID_REG, chips, type) == NULL)
  1673. return ret;
  1674. outb(SMSCSIOFLAT_UARTMODE0C_REG, cfgbase);
  1675. mode = inb(cfgbase + 1);
  1676. /*printk(KERN_WARNING "%s(): mode: 0x%02x\n", __FUNCTION__, mode);*/
  1677. if (!(mode & SMSCSIOFLAT_UART2MODE_VAL_IRDA))
  1678. IRDA_WARNING("%s(): IrDA not enabled\n", __FUNCTION__);
  1679. outb(SMSCSIOFLAT_UART2BASEADDR_REG, cfgbase);
  1680. sirbase = inb(cfgbase + 1) << 2;
  1681. /* FIR iobase */
  1682. outb(SMSCSIOFLAT_FIRBASEADDR_REG, cfgbase);
  1683. firbase = inb(cfgbase + 1) << 3;
  1684. /* DMA */
  1685. outb(SMSCSIOFLAT_FIRDMASELECT_REG, cfgbase);
  1686. dma = inb(cfgbase + 1) & SMSCSIOFLAT_FIRDMASELECT_MASK;
  1687. /* IRQ */
  1688. outb(SMSCSIOFLAT_UARTIRQSELECT_REG, cfgbase);
  1689. irq = inb(cfgbase + 1) & SMSCSIOFLAT_UART2IRQSELECT_MASK;
  1690. IRDA_MESSAGE("%s(): fir: 0x%02x, sir: 0x%02x, dma: %02d, irq: %d, mode: 0x%02x\n", __FUNCTION__, firbase, sirbase, dma, irq, mode);
  1691. if (firbase && smsc_ircc_open(firbase, sirbase, dma, irq) == 0)
  1692. ret = 0;
  1693. /* Exit configuration */
  1694. outb(SMSCSIO_CFGEXITKEY, cfgbase);
  1695. return ret;
  1696. }
  1697. /*
  1698. * Function smsc_superio_paged (chip, base, type)
  1699. *
  1700. * Try to get configuration of a smc SuperIO chip with paged register model
  1701. *
  1702. */
  1703. static int __init smsc_superio_paged(const struct smsc_chip *chips, unsigned short cfg_base, char *type)
  1704. {
  1705. unsigned short fir_io, sir_io;
  1706. int ret = -ENODEV;
  1707. IRDA_DEBUG(1, "%s\n", __FUNCTION__);
  1708. if (smsc_ircc_probe(cfg_base, 0x20, chips, type) == NULL)
  1709. return ret;
  1710. /* Select logical device (UART2) */
  1711. outb(0x07, cfg_base);
  1712. outb(0x05, cfg_base + 1);
  1713. /* SIR iobase */
  1714. outb(0x60, cfg_base);
  1715. sir_io = inb(cfg_base + 1) << 8;
  1716. outb(0x61, cfg_base);
  1717. sir_io |= inb(cfg_base + 1);
  1718. /* Read FIR base */
  1719. outb(0x62, cfg_base);
  1720. fir_io = inb(cfg_base + 1) << 8;
  1721. outb(0x63, cfg_base);
  1722. fir_io |= inb(cfg_base + 1);
  1723. outb(0x2b, cfg_base); /* ??? */
  1724. if (fir_io && smsc_ircc_open(fir_io, sir_io, ircc_dma, ircc_irq) == 0)
  1725. ret = 0;
  1726. /* Exit configuration */
  1727. outb(SMSCSIO_CFGEXITKEY, cfg_base);
  1728. return ret;
  1729. }
  1730. static int __init smsc_access(unsigned short cfg_base, unsigned char reg)
  1731. {
  1732. IRDA_DEBUG(1, "%s\n", __FUNCTION__);
  1733. outb(reg, cfg_base);
  1734. return inb(cfg_base) != reg ? -1 : 0;
  1735. }
  1736. static const struct smsc_chip * __init smsc_ircc_probe(unsigned short cfg_base, u8 reg, const struct smsc_chip *chip, char *type)
  1737. {
  1738. u8 devid, xdevid, rev;
  1739. IRDA_DEBUG(1, "%s\n", __FUNCTION__);
  1740. /* Leave configuration */
  1741. outb(SMSCSIO_CFGEXITKEY, cfg_base);
  1742. if (inb(cfg_base) == SMSCSIO_CFGEXITKEY) /* not a smc superio chip */
  1743. return NULL;
  1744. outb(reg, cfg_base);
  1745. xdevid = inb(cfg_base + 1);
  1746. /* Enter configuration */
  1747. outb(SMSCSIO_CFGACCESSKEY, cfg_base);
  1748. #if 0
  1749. if (smsc_access(cfg_base,0x55)) /* send second key and check */
  1750. return NULL;
  1751. #endif
  1752. /* probe device ID */
  1753. if (smsc_access(cfg_base, reg))
  1754. return NULL;
  1755. devid = inb(cfg_base + 1);
  1756. if (devid == 0 || devid == 0xff) /* typical values for unused port */
  1757. return NULL;
  1758. /* probe revision ID */
  1759. if (smsc_access(cfg_base, reg + 1))
  1760. return NULL;
  1761. rev = inb(cfg_base + 1);
  1762. if (rev >= 128) /* i think this will make no sense */
  1763. return NULL;
  1764. if (devid == xdevid) /* protection against false positives */
  1765. return NULL;
  1766. /* Check for expected device ID; are there others? */
  1767. while (chip->devid != devid) {
  1768. chip++;
  1769. if (chip->name == NULL)
  1770. return NULL;
  1771. }
  1772. IRDA_MESSAGE("found SMC SuperIO Chip (devid=0x%02x rev=%02X base=0x%04x): %s%s\n",
  1773. devid, rev, cfg_base, type, chip->name);
  1774. if (chip->rev > rev) {
  1775. IRDA_MESSAGE("Revision higher than expected\n");
  1776. return NULL;
  1777. }
  1778. if (chip->flags & NoIRDA)
  1779. IRDA_MESSAGE("chipset does not support IRDA\n");
  1780. return chip;
  1781. }
  1782. static int __init smsc_superio_fdc(unsigned short cfg_base)
  1783. {
  1784. int ret = -1;
  1785. if (!request_region(cfg_base, 2, driver_name)) {
  1786. IRDA_WARNING("%s: can't get cfg_base of 0x%03x\n",
  1787. __FUNCTION__, cfg_base);
  1788. } else {
  1789. if (!smsc_superio_flat(fdc_chips_flat, cfg_base, "FDC") ||
  1790. !smsc_superio_paged(fdc_chips_paged, cfg_base, "FDC"))
  1791. ret = 0;
  1792. release_region(cfg_base, 2);
  1793. }
  1794. return ret;
  1795. }
  1796. static int __init smsc_superio_lpc(unsigned short cfg_base)
  1797. {
  1798. int ret = -1;
  1799. if (!request_region(cfg_base, 2, driver_name)) {
  1800. IRDA_WARNING("%s: can't get cfg_base of 0x%03x\n",
  1801. __FUNCTION__, cfg_base);
  1802. } else {
  1803. if (!smsc_superio_flat(lpc_chips_flat, cfg_base, "LPC") ||
  1804. !smsc_superio_paged(lpc_chips_paged, cfg_base, "LPC"))
  1805. ret = 0;
  1806. release_region(cfg_base, 2);
  1807. }
  1808. return ret;
  1809. }
  1810. /************************************************
  1811. *
  1812. * Transceivers specific functions
  1813. *
  1814. ************************************************/
  1815. /*
  1816. * Function smsc_ircc_set_transceiver_smsc_ircc_atc(fir_base, speed)
  1817. *
  1818. * Program transceiver through smsc-ircc ATC circuitry
  1819. *
  1820. */
  1821. static void smsc_ircc_set_transceiver_smsc_ircc_atc(int fir_base, u32 speed)
  1822. {
  1823. unsigned long jiffies_now, jiffies_timeout;
  1824. u8 val;
  1825. jiffies_now = jiffies;
  1826. jiffies_timeout = jiffies + SMSC_IRCC2_ATC_PROGRAMMING_TIMEOUT_JIFFIES;
  1827. /* ATC */
  1828. register_bank(fir_base, 4);
  1829. outb((inb(fir_base + IRCC_ATC) & IRCC_ATC_MASK) | IRCC_ATC_nPROGREADY|IRCC_ATC_ENABLE,
  1830. fir_base + IRCC_ATC);
  1831. while ((val = (inb(fir_base + IRCC_ATC) & IRCC_ATC_nPROGREADY)) &&
  1832. !time_after(jiffies, jiffies_timeout))
  1833. /* empty */;
  1834. if (val)
  1835. IRDA_WARNING("%s(): ATC: 0x%02x\n", __FUNCTION__,
  1836. inb(fir_base + IRCC_ATC));
  1837. }
  1838. /*
  1839. * Function smsc_ircc_probe_transceiver_smsc_ircc_atc(fir_base)
  1840. *
  1841. * Probe transceiver smsc-ircc ATC circuitry
  1842. *
  1843. */
  1844. static int smsc_ircc_probe_transceiver_smsc_ircc_atc(int fir_base)
  1845. {
  1846. return 0;
  1847. }
  1848. /*
  1849. * Function smsc_ircc_set_transceiver_smsc_ircc_fast_pin_select(self, speed)
  1850. *
  1851. * Set transceiver
  1852. *
  1853. */
  1854. static void smsc_ircc_set_transceiver_smsc_ircc_fast_pin_select(int fir_base, u32 speed)
  1855. {
  1856. u8 fast_mode;
  1857. switch (speed) {
  1858. default:
  1859. case 576000 :
  1860. fast_mode = 0;
  1861. break;
  1862. case 1152000 :
  1863. case 4000000 :
  1864. fast_mode = IRCC_LCR_A_FAST;
  1865. break;
  1866. }
  1867. register_bank(fir_base, 0);
  1868. outb((inb(fir_base + IRCC_LCR_A) & 0xbf) | fast_mode, fir_base + IRCC_LCR_A);
  1869. }
  1870. /*
  1871. * Function smsc_ircc_probe_transceiver_smsc_ircc_fast_pin_select(fir_base)
  1872. *
  1873. * Probe transceiver
  1874. *
  1875. */
  1876. static int smsc_ircc_probe_transceiver_smsc_ircc_fast_pin_select(int fir_base)
  1877. {
  1878. return 0;
  1879. }
  1880. /*
  1881. * Function smsc_ircc_set_transceiver_toshiba_sat1800(fir_base, speed)
  1882. *
  1883. * Set transceiver
  1884. *
  1885. */
  1886. static void smsc_ircc_set_transceiver_toshiba_sat1800(int fir_base, u32 speed)
  1887. {
  1888. u8 fast_mode;
  1889. switch (speed) {
  1890. default:
  1891. case 576000 :
  1892. fast_mode = 0;
  1893. break;
  1894. case 1152000 :
  1895. case 4000000 :
  1896. fast_mode = /*IRCC_LCR_A_FAST |*/ IRCC_LCR_A_GP_DATA;
  1897. break;
  1898. }
  1899. /* This causes an interrupt */
  1900. register_bank(fir_base, 0);
  1901. outb((inb(fir_base + IRCC_LCR_A) & 0xbf) | fast_mode, fir_base + IRCC_LCR_A);
  1902. }
  1903. /*
  1904. * Function smsc_ircc_probe_transceiver_toshiba_sat1800(fir_base)
  1905. *
  1906. * Probe transceiver
  1907. *
  1908. */
  1909. static int smsc_ircc_probe_transceiver_toshiba_sat1800(int fir_base)
  1910. {
  1911. return 0;
  1912. }
  1913. module_init(smsc_ircc_init);
  1914. module_exit(smsc_ircc_cleanup);