smsc-ircc2.c 60 KB

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