2 * linux/drivers/net/irda/pxaficp_ir.c
4 * Based on sa1100_ir.c by Russell King
6 * Changes copyright (C) 2003-2005 MontaVista Software, Inc.
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
12 * Infra-red driver (SIR/FIR) for the PXA2xx embedded microprocessor
15 #include <linux/module.h>
16 #include <linux/types.h>
17 #include <linux/init.h>
18 #include <linux/errno.h>
19 #include <linux/netdevice.h>
20 #include <linux/slab.h>
21 #include <linux/rtnetlink.h>
22 #include <linux/interrupt.h>
23 #include <linux/dma-mapping.h>
24 #include <linux/platform_device.h>
26 #include <linux/clk.h>
28 #include <net/irda/irda.h>
29 #include <net/irda/irmod.h>
30 #include <net/irda/wrapper.h>
31 #include <net/irda/irda_device.h>
35 #include <asm/delay.h>
36 #include <asm/hardware.h>
37 #include <asm/arch/irda.h>
38 #include <asm/arch/pxa-regs.h>
40 #ifdef CONFIG_MACH_MAINSTONE
41 #include <asm/arch/mainstone.h>
44 #define IrSR_RXPL_NEG_IS_ZERO (1<<4)
45 #define IrSR_RXPL_POS_IS_ZERO 0x0
46 #define IrSR_TXPL_NEG_IS_ZERO (1<<3)
47 #define IrSR_TXPL_POS_IS_ZERO 0x0
48 #define IrSR_XMODE_PULSE_1_6 (1<<2)
49 #define IrSR_XMODE_PULSE_3_16 0x0
50 #define IrSR_RCVEIR_IR_MODE (1<<1)
51 #define IrSR_RCVEIR_UART_MODE 0x0
52 #define IrSR_XMITIR_IR_MODE (1<<0)
53 #define IrSR_XMITIR_UART_MODE 0x0
55 #define IrSR_IR_RECEIVE_ON (\
56 IrSR_RXPL_NEG_IS_ZERO | \
57 IrSR_TXPL_POS_IS_ZERO | \
58 IrSR_XMODE_PULSE_3_16 | \
59 IrSR_RCVEIR_IR_MODE | \
60 IrSR_XMITIR_UART_MODE)
62 #define IrSR_IR_TRANSMIT_ON (\
63 IrSR_RXPL_NEG_IS_ZERO | \
64 IrSR_TXPL_POS_IS_ZERO | \
65 IrSR_XMODE_PULSE_3_16 | \
66 IrSR_RCVEIR_UART_MODE | \
72 unsigned long last_oscr
;
74 unsigned char *dma_rx_buff
;
75 unsigned char *dma_tx_buff
;
76 dma_addr_t dma_rx_buff_phy
;
77 dma_addr_t dma_tx_buff_phy
;
78 unsigned int dma_tx_buff_len
;
82 struct net_device_stats stats
;
83 struct irlap_cb
*irlap
;
90 struct pxaficp_platform_data
*pdata
;
96 static inline void pxa_irda_disable_clk(struct pxa_irda
*si
)
99 clk_disable(si
->cur_clk
);
103 static inline void pxa_irda_enable_firclk(struct pxa_irda
*si
)
105 si
->cur_clk
= si
->fir_clk
;
106 clk_enable(si
->fir_clk
);
109 static inline void pxa_irda_enable_sirclk(struct pxa_irda
*si
)
111 si
->cur_clk
= si
->sir_clk
;
112 clk_enable(si
->sir_clk
);
116 #define IS_FIR(si) ((si)->speed >= 4000000)
117 #define IRDA_FRAME_SIZE_LIMIT 2047
119 inline static void pxa_irda_fir_dma_rx_start(struct pxa_irda
*si
)
121 DCSR(si
->rxdma
) = DCSR_NODESC
;
122 DSADR(si
->rxdma
) = __PREG(ICDR
);
123 DTADR(si
->rxdma
) = si
->dma_rx_buff_phy
;
124 DCMD(si
->rxdma
) = DCMD_INCTRGADDR
| DCMD_FLOWSRC
| DCMD_WIDTH1
| DCMD_BURST32
| IRDA_FRAME_SIZE_LIMIT
;
125 DCSR(si
->rxdma
) |= DCSR_RUN
;
128 inline static void pxa_irda_fir_dma_tx_start(struct pxa_irda
*si
)
130 DCSR(si
->txdma
) = DCSR_NODESC
;
131 DSADR(si
->txdma
) = si
->dma_tx_buff_phy
;
132 DTADR(si
->txdma
) = __PREG(ICDR
);
133 DCMD(si
->txdma
) = DCMD_INCSRCADDR
| DCMD_FLOWTRG
| DCMD_ENDIRQEN
| DCMD_WIDTH1
| DCMD_BURST32
| si
->dma_tx_buff_len
;
134 DCSR(si
->txdma
) |= DCSR_RUN
;
138 * Set the IrDA communications speed.
140 static int pxa_irda_set_speed(struct pxa_irda
*si
, int speed
)
143 unsigned int divisor
;
146 case 9600: case 19200: case 38400:
147 case 57600: case 115200:
149 /* refer to PXA250/210 Developer's Manual 10-7 */
150 /* BaudRate = 14.7456 MHz / (16*Divisor) */
151 divisor
= 14745600 / (16 * speed
);
153 local_irq_save(flags
);
157 DCSR(si
->rxdma
) &= ~DCSR_RUN
;
160 pxa_irda_disable_clk(si
);
162 /* set board transceiver to SIR mode */
163 si
->pdata
->transceiver_mode(si
->dev
, IR_SIRMODE
);
165 /* configure GPIO46/47 */
166 pxa_gpio_mode(GPIO46_STRXD_MD
);
167 pxa_gpio_mode(GPIO47_STTXD_MD
);
169 /* enable the STUART clock */
170 pxa_irda_enable_sirclk(si
);
173 /* disable STUART first */
176 /* access DLL & DLH */
178 STDLL
= divisor
& 0xff;
179 STDLH
= divisor
>> 8;
183 STISR
= IrSR_IR_RECEIVE_ON
| IrSR_XMODE_PULSE_1_6
;
184 STIER
= IER_UUE
| IER_RLSE
| IER_RAVIE
| IER_RTIOE
;
186 local_irq_restore(flags
);
190 local_irq_save(flags
);
195 pxa_irda_disable_clk(si
);
197 /* disable FICP first */
200 /* set board transceiver to FIR mode */
201 si
->pdata
->transceiver_mode(si
->dev
, IR_FIRMODE
);
203 /* configure GPIO46/47 */
204 pxa_gpio_mode(GPIO46_ICPRXD_MD
);
205 pxa_gpio_mode(GPIO47_ICPTXD_MD
);
207 /* enable the FICP clock */
208 pxa_irda_enable_firclk(si
);
211 pxa_irda_fir_dma_rx_start(si
);
212 ICCR0
= ICCR0_ITR
| ICCR0_RXE
;
214 local_irq_restore(flags
);
224 /* SIR interrupt service routine. */
225 static irqreturn_t
pxa_irda_sir_irq(int irq
, void *dev_id
)
227 struct net_device
*dev
= dev_id
;
228 struct pxa_irda
*si
= netdev_priv(dev
);
233 switch (iir
& 0x0F) {
234 case 0x06: /* Receiver Line Status */
236 while (lsr
& LSR_FIFOE
) {
238 if (lsr
& (LSR_OE
| LSR_PE
| LSR_FE
| LSR_BI
)) {
239 printk(KERN_DEBUG
"pxa_ir: sir receiving error\n");
240 si
->stats
.rx_errors
++;
242 si
->stats
.rx_frame_errors
++;
244 si
->stats
.rx_fifo_errors
++;
246 si
->stats
.rx_bytes
++;
247 async_unwrap_char(dev
, &si
->stats
, &si
->rx_buff
, data
);
251 dev
->last_rx
= jiffies
;
252 si
->last_oscr
= OSCR
;
255 case 0x04: /* Received Data Available */
258 case 0x0C: /* Character Timeout Indication */
260 si
->stats
.rx_bytes
++;
261 async_unwrap_char(dev
, &si
->stats
, &si
->rx_buff
, STRBR
);
262 } while (STLSR
& LSR_DR
);
263 dev
->last_rx
= jiffies
;
264 si
->last_oscr
= OSCR
;
267 case 0x02: /* Transmit FIFO Data Request */
268 while ((si
->tx_buff
.len
) && (STLSR
& LSR_TDRQ
)) {
269 STTHR
= *si
->tx_buff
.data
++;
270 si
->tx_buff
.len
-= 1;
273 if (si
->tx_buff
.len
== 0) {
274 si
->stats
.tx_packets
++;
275 si
->stats
.tx_bytes
+= si
->tx_buff
.data
-
278 /* We need to ensure that the transmitter has finished. */
279 while ((STLSR
& LSR_TEMT
) == 0)
281 si
->last_oscr
= OSCR
;
284 * Ok, we've finished transmitting. Now enable
285 * the receiver. Sometimes we get a receive IRQ
286 * immediately after a transmit...
289 pxa_irda_set_speed(si
, si
->newspeed
);
292 /* enable IR Receiver, disable IR Transmitter */
293 STISR
= IrSR_IR_RECEIVE_ON
| IrSR_XMODE_PULSE_1_6
;
294 /* enable STUART and receive interrupts */
295 STIER
= IER_UUE
| IER_RLSE
| IER_RAVIE
| IER_RTIOE
;
298 netif_wake_queue(dev
);
306 /* FIR Receive DMA interrupt handler */
307 static void pxa_irda_fir_dma_rx_irq(int channel
, void *data
)
309 int dcsr
= DCSR(channel
);
311 DCSR(channel
) = dcsr
& ~DCSR_RUN
;
313 printk(KERN_DEBUG
"pxa_ir: fir rx dma bus error %#x\n", dcsr
);
316 /* FIR Transmit DMA interrupt handler */
317 static void pxa_irda_fir_dma_tx_irq(int channel
, void *data
)
319 struct net_device
*dev
= data
;
320 struct pxa_irda
*si
= netdev_priv(dev
);
323 dcsr
= DCSR(channel
);
324 DCSR(channel
) = dcsr
& ~DCSR_RUN
;
326 if (dcsr
& DCSR_ENDINTR
) {
327 si
->stats
.tx_packets
++;
328 si
->stats
.tx_bytes
+= si
->dma_tx_buff_len
;
330 si
->stats
.tx_errors
++;
333 while (ICSR1
& ICSR1_TBY
)
335 si
->last_oscr
= OSCR
;
338 * HACK: It looks like the TBY bit is dropped too soon.
339 * Without this delay things break.
344 pxa_irda_set_speed(si
, si
->newspeed
);
350 pxa_irda_fir_dma_rx_start(si
);
351 while ((ICSR1
& ICSR1_RNE
) && i
--)
353 ICCR0
= ICCR0_ITR
| ICCR0_RXE
;
356 printk(KERN_ERR
"pxa_ir: cannot clear Rx FIFO!\n");
358 netif_wake_queue(dev
);
361 /* EIF(Error in FIFO/End in Frame) handler for FIR */
362 static void pxa_irda_fir_irq_eif(struct pxa_irda
*si
, struct net_device
*dev
, int icsr0
)
364 unsigned int len
, stat
, data
;
366 /* Get the current data position. */
367 len
= DTADR(si
->rxdma
) - si
->dma_rx_buff_phy
;
370 /* Read Status, and then Data. */
375 if (stat
& (ICSR1_CRE
| ICSR1_ROR
)) {
376 si
->stats
.rx_errors
++;
377 if (stat
& ICSR1_CRE
) {
378 printk(KERN_DEBUG
"pxa_ir: fir receive CRC error\n");
379 si
->stats
.rx_crc_errors
++;
381 if (stat
& ICSR1_ROR
) {
382 printk(KERN_DEBUG
"pxa_ir: fir receive overrun\n");
383 si
->stats
.rx_over_errors
++;
386 si
->dma_rx_buff
[len
++] = data
;
388 /* If we hit the end of frame, there's no point in continuing. */
389 if (stat
& ICSR1_EOF
)
391 } while (ICSR0
& ICSR0_EIF
);
393 if (stat
& ICSR1_EOF
) {
397 if (icsr0
& ICSR0_FRE
) {
398 printk(KERN_ERR
"pxa_ir: dropping erroneous frame\n");
399 si
->stats
.rx_dropped
++;
403 skb
= alloc_skb(len
+1,GFP_ATOMIC
);
405 printk(KERN_ERR
"pxa_ir: fir out of memory for receive skb\n");
406 si
->stats
.rx_dropped
++;
410 /* Align IP header to 20 bytes */
412 skb_copy_to_linear_data(skb
, si
->dma_rx_buff
, len
);
415 /* Feed it to IrLAP */
417 skb_reset_mac_header(skb
);
418 skb
->protocol
= htons(ETH_P_IRDA
);
421 si
->stats
.rx_packets
++;
422 si
->stats
.rx_bytes
+= len
;
424 dev
->last_rx
= jiffies
;
428 /* FIR interrupt handler */
429 static irqreturn_t
pxa_irda_fir_irq(int irq
, void *dev_id
)
431 struct net_device
*dev
= dev_id
;
432 struct pxa_irda
*si
= netdev_priv(dev
);
436 DCSR(si
->rxdma
) &= ~DCSR_RUN
;
437 si
->last_oscr
= OSCR
;
440 if (icsr0
& (ICSR0_FRE
| ICSR0_RAB
)) {
441 if (icsr0
& ICSR0_FRE
) {
442 printk(KERN_DEBUG
"pxa_ir: fir receive frame error\n");
443 si
->stats
.rx_frame_errors
++;
445 printk(KERN_DEBUG
"pxa_ir: fir receive abort\n");
446 si
->stats
.rx_errors
++;
448 ICSR0
= icsr0
& (ICSR0_FRE
| ICSR0_RAB
);
451 if (icsr0
& ICSR0_EIF
) {
452 /* An error in FIFO occured, or there is a end of frame */
453 pxa_irda_fir_irq_eif(si
, dev
, icsr0
);
457 pxa_irda_fir_dma_rx_start(si
);
458 while ((ICSR1
& ICSR1_RNE
) && i
--)
460 ICCR0
= ICCR0_ITR
| ICCR0_RXE
;
463 printk(KERN_ERR
"pxa_ir: cannot clear Rx FIFO!\n");
468 /* hard_xmit interface of irda device */
469 static int pxa_irda_hard_xmit(struct sk_buff
*skb
, struct net_device
*dev
)
471 struct pxa_irda
*si
= netdev_priv(dev
);
472 int speed
= irda_get_next_speed(skb
);
475 * Does this packet contain a request to change the interface
476 * speed? If so, remember it until we complete the transmission
479 if (speed
!= si
->speed
&& speed
!= -1)
480 si
->newspeed
= speed
;
483 * If this is an empty frame, we can bypass a lot.
488 pxa_irda_set_speed(si
, speed
);
494 netif_stop_queue(dev
);
497 si
->tx_buff
.data
= si
->tx_buff
.head
;
498 si
->tx_buff
.len
= async_wrap_skb(skb
, si
->tx_buff
.data
, si
->tx_buff
.truesize
);
500 /* Disable STUART interrupts and switch to transmit mode. */
502 STISR
= IrSR_IR_TRANSMIT_ON
| IrSR_XMODE_PULSE_1_6
;
504 /* enable STUART and transmit interrupts */
505 STIER
= IER_UUE
| IER_TIE
;
507 unsigned long mtt
= irda_get_mtt(skb
);
509 si
->dma_tx_buff_len
= skb
->len
;
510 skb_copy_from_linear_data(skb
, si
->dma_tx_buff
, skb
->len
);
513 while ((unsigned)(OSCR
- si
->last_oscr
)/4 < mtt
)
516 /* stop RX DMA, disable FICP */
517 DCSR(si
->rxdma
) &= ~DCSR_RUN
;
520 pxa_irda_fir_dma_tx_start(si
);
521 ICCR0
= ICCR0_ITR
| ICCR0_TXE
;
525 dev
->trans_start
= jiffies
;
529 static int pxa_irda_ioctl(struct net_device
*dev
, struct ifreq
*ifreq
, int cmd
)
531 struct if_irda_req
*rq
= (struct if_irda_req
*)ifreq
;
532 struct pxa_irda
*si
= netdev_priv(dev
);
538 if (capable(CAP_NET_ADMIN
)) {
540 * We are unable to set the speed if the
541 * device is not running.
543 if (netif_running(dev
)) {
544 ret
= pxa_irda_set_speed(si
,
547 printk(KERN_INFO
"pxa_ir: SIOCSBANDWIDTH: !netif_running\n");
555 if (capable(CAP_NET_ADMIN
)) {
556 irda_device_set_media_busy(dev
, TRUE
);
563 rq
->ifr_receiving
= IS_FIR(si
) ? 0
564 : si
->rx_buff
.state
!= OUTSIDE_FRAME
;
575 static struct net_device_stats
*pxa_irda_stats(struct net_device
*dev
)
577 struct pxa_irda
*si
= netdev_priv(dev
);
581 static void pxa_irda_startup(struct pxa_irda
*si
)
583 /* Disable STUART interrupts */
585 /* enable STUART interrupt to the processor */
587 /* configure SIR frame format: StartBit - Data 7 ... Data 0 - Stop Bit */
588 STLCR
= LCR_WLS0
| LCR_WLS1
;
589 /* enable FIFO, we use FIFO to improve performance */
590 STFCR
= FCR_TRFIFOE
| FCR_ITL_32
;
594 /* configure FICP ICCR2 */
595 ICCR2
= ICCR2_TXP
| ICCR2_TRIG_32
;
598 DRCMR17
= si
->rxdma
| DRCMR_MAPVLD
;
599 DRCMR18
= si
->txdma
| DRCMR_MAPVLD
;
601 /* force SIR reinitialization */
603 pxa_irda_set_speed(si
, 9600);
605 printk(KERN_DEBUG
"pxa_ir: irda startup\n");
608 static void pxa_irda_shutdown(struct pxa_irda
*si
)
612 local_irq_save(flags
);
614 /* disable STUART and interrupt */
616 /* disable STUART SIR mode */
620 DCSR(si
->txdma
) &= ~DCSR_RUN
;
621 DCSR(si
->rxdma
) &= ~DCSR_RUN
;
625 /* disable the STUART or FICP clocks */
626 pxa_irda_disable_clk(si
);
631 local_irq_restore(flags
);
633 /* power off board transceiver */
634 si
->pdata
->transceiver_mode(si
->dev
, IR_OFF
);
636 printk(KERN_DEBUG
"pxa_ir: irda shutdown\n");
639 static int pxa_irda_start(struct net_device
*dev
)
641 struct pxa_irda
*si
= netdev_priv(dev
);
646 err
= request_irq(IRQ_STUART
, pxa_irda_sir_irq
, 0, dev
->name
, dev
);
650 err
= request_irq(IRQ_ICP
, pxa_irda_fir_irq
, 0, dev
->name
, dev
);
655 * The interrupt must remain disabled for now.
657 disable_irq(IRQ_STUART
);
658 disable_irq(IRQ_ICP
);
661 si
->rxdma
= pxa_request_dma("FICP_RX",DMA_PRIO_LOW
, pxa_irda_fir_dma_rx_irq
, dev
);
665 si
->txdma
= pxa_request_dma("FICP_TX",DMA_PRIO_LOW
, pxa_irda_fir_dma_tx_irq
, dev
);
670 si
->dma_rx_buff
= dma_alloc_coherent(si
->dev
, IRDA_FRAME_SIZE_LIMIT
,
671 &si
->dma_rx_buff_phy
, GFP_KERNEL
);
672 if (!si
->dma_rx_buff
)
673 goto err_dma_rx_buff
;
675 si
->dma_tx_buff
= dma_alloc_coherent(si
->dev
, IRDA_FRAME_SIZE_LIMIT
,
676 &si
->dma_tx_buff_phy
, GFP_KERNEL
);
677 if (!si
->dma_tx_buff
)
678 goto err_dma_tx_buff
;
680 /* Setup the serial port for the initial speed. */
681 pxa_irda_startup(si
);
684 * Open a new IrLAP layer instance.
686 si
->irlap
= irlap_open(dev
, &si
->qos
, "pxa");
692 * Now enable the interrupt and start the queue
694 enable_irq(IRQ_STUART
);
696 netif_start_queue(dev
);
698 printk(KERN_DEBUG
"pxa_ir: irda driver opened\n");
703 pxa_irda_shutdown(si
);
704 dma_free_coherent(si
->dev
, IRDA_FRAME_SIZE_LIMIT
, si
->dma_tx_buff
, si
->dma_tx_buff_phy
);
706 dma_free_coherent(si
->dev
, IRDA_FRAME_SIZE_LIMIT
, si
->dma_rx_buff
, si
->dma_rx_buff_phy
);
708 pxa_free_dma(si
->txdma
);
710 pxa_free_dma(si
->rxdma
);
712 free_irq(IRQ_ICP
, dev
);
714 free_irq(IRQ_STUART
, dev
);
720 static int pxa_irda_stop(struct net_device
*dev
)
722 struct pxa_irda
*si
= netdev_priv(dev
);
724 netif_stop_queue(dev
);
726 pxa_irda_shutdown(si
);
730 irlap_close(si
->irlap
);
734 free_irq(IRQ_STUART
, dev
);
735 free_irq(IRQ_ICP
, dev
);
737 pxa_free_dma(si
->rxdma
);
738 pxa_free_dma(si
->txdma
);
741 dma_free_coherent(si
->dev
, IRDA_FRAME_SIZE_LIMIT
, si
->dma_tx_buff
, si
->dma_tx_buff_phy
);
743 dma_free_coherent(si
->dev
, IRDA_FRAME_SIZE_LIMIT
, si
->dma_rx_buff
, si
->dma_rx_buff_phy
);
745 printk(KERN_DEBUG
"pxa_ir: irda driver closed\n");
749 static int pxa_irda_suspend(struct platform_device
*_dev
, pm_message_t state
)
751 struct net_device
*dev
= platform_get_drvdata(_dev
);
754 if (dev
&& netif_running(dev
)) {
755 si
= netdev_priv(dev
);
756 netif_device_detach(dev
);
757 pxa_irda_shutdown(si
);
763 static int pxa_irda_resume(struct platform_device
*_dev
)
765 struct net_device
*dev
= platform_get_drvdata(_dev
);
768 if (dev
&& netif_running(dev
)) {
769 si
= netdev_priv(dev
);
770 pxa_irda_startup(si
);
771 netif_device_attach(dev
);
772 netif_wake_queue(dev
);
779 static int pxa_irda_init_iobuf(iobuff_t
*io
, int size
)
781 io
->head
= kmalloc(size
, GFP_KERNEL
| GFP_DMA
);
782 if (io
->head
!= NULL
) {
784 io
->in_frame
= FALSE
;
785 io
->state
= OUTSIDE_FRAME
;
788 return io
->head
? 0 : -ENOMEM
;
791 static int pxa_irda_probe(struct platform_device
*pdev
)
793 struct net_device
*dev
;
795 unsigned int baudrate_mask
;
798 if (!pdev
->dev
.platform_data
)
801 err
= request_mem_region(__PREG(STUART
), 0x24, "IrDA") ? 0 : -EBUSY
;
805 err
= request_mem_region(__PREG(FICP
), 0x1c, "IrDA") ? 0 : -EBUSY
;
809 dev
= alloc_irdadev(sizeof(struct pxa_irda
));
813 si
= netdev_priv(dev
);
814 si
->dev
= &pdev
->dev
;
815 si
->pdata
= pdev
->dev
.platform_data
;
817 si
->sir_clk
= clk_get(&pdev
->dev
, "UARTCLK");
818 si
->fir_clk
= clk_get(&pdev
->dev
, "FICPCLK");
819 if (IS_ERR(si
->sir_clk
) || IS_ERR(si
->fir_clk
)) {
820 err
= PTR_ERR(IS_ERR(si
->sir_clk
) ? si
->sir_clk
: si
->fir_clk
);
825 * Initialise the SIR buffers
827 err
= pxa_irda_init_iobuf(&si
->rx_buff
, 14384);
830 err
= pxa_irda_init_iobuf(&si
->tx_buff
, 4000);
834 dev
->hard_start_xmit
= pxa_irda_hard_xmit
;
835 dev
->open
= pxa_irda_start
;
836 dev
->stop
= pxa_irda_stop
;
837 dev
->do_ioctl
= pxa_irda_ioctl
;
838 dev
->get_stats
= pxa_irda_stats
;
840 irda_init_max_qos_capabilies(&si
->qos
);
843 if (si
->pdata
->transceiver_cap
& IR_SIRMODE
)
844 baudrate_mask
|= IR_9600
|IR_19200
|IR_38400
|IR_57600
|IR_115200
;
845 if (si
->pdata
->transceiver_cap
& IR_FIRMODE
)
846 baudrate_mask
|= IR_4000000
<< 8;
848 si
->qos
.baud_rate
.bits
&= baudrate_mask
;
849 si
->qos
.min_turn_time
.bits
= 7; /* 1ms or more */
851 irda_qos_bits_to_value(&si
->qos
);
853 err
= register_netdev(dev
);
856 dev_set_drvdata(&pdev
->dev
, dev
);
859 kfree(si
->tx_buff
.head
);
861 kfree(si
->rx_buff
.head
);
863 if (si
->sir_clk
&& !IS_ERR(si
->sir_clk
))
864 clk_put(si
->sir_clk
);
865 if (si
->fir_clk
&& !IS_ERR(si
->fir_clk
))
866 clk_put(si
->fir_clk
);
869 release_mem_region(__PREG(FICP
), 0x1c);
871 release_mem_region(__PREG(STUART
), 0x24);
877 static int pxa_irda_remove(struct platform_device
*_dev
)
879 struct net_device
*dev
= platform_get_drvdata(_dev
);
882 struct pxa_irda
*si
= netdev_priv(dev
);
883 unregister_netdev(dev
);
884 kfree(si
->tx_buff
.head
);
885 kfree(si
->rx_buff
.head
);
886 clk_put(si
->fir_clk
);
887 clk_put(si
->sir_clk
);
891 release_mem_region(__PREG(STUART
), 0x24);
892 release_mem_region(__PREG(FICP
), 0x1c);
897 static struct platform_driver pxa_ir_driver
= {
901 .probe
= pxa_irda_probe
,
902 .remove
= pxa_irda_remove
,
903 .suspend
= pxa_irda_suspend
,
904 .resume
= pxa_irda_resume
,
907 static int __init
pxa_irda_init(void)
909 return platform_driver_register(&pxa_ir_driver
);
912 static void __exit
pxa_irda_exit(void)
914 platform_driver_unregister(&pxa_ir_driver
);
917 module_init(pxa_irda_init
);
918 module_exit(pxa_irda_exit
);
920 MODULE_LICENSE("GPL");