smsc-ircc2.c 60 KB

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