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>
39 #include <asm/arch/pxa2xx-gpio.h>
41 #ifdef CONFIG_MACH_MAINSTONE
42 #include <asm/arch/mainstone.h>
45 #define IrSR_RXPL_NEG_IS_ZERO (1<<4)
46 #define IrSR_RXPL_POS_IS_ZERO 0x0
47 #define IrSR_TXPL_NEG_IS_ZERO (1<<3)
48 #define IrSR_TXPL_POS_IS_ZERO 0x0
49 #define IrSR_XMODE_PULSE_1_6 (1<<2)
50 #define IrSR_XMODE_PULSE_3_16 0x0
51 #define IrSR_RCVEIR_IR_MODE (1<<1)
52 #define IrSR_RCVEIR_UART_MODE 0x0
53 #define IrSR_XMITIR_IR_MODE (1<<0)
54 #define IrSR_XMITIR_UART_MODE 0x0
56 #define IrSR_IR_RECEIVE_ON (\
57 IrSR_RXPL_NEG_IS_ZERO | \
58 IrSR_TXPL_POS_IS_ZERO | \
59 IrSR_XMODE_PULSE_3_16 | \
60 IrSR_RCVEIR_IR_MODE | \
61 IrSR_XMITIR_UART_MODE)
63 #define IrSR_IR_TRANSMIT_ON (\
64 IrSR_RXPL_NEG_IS_ZERO | \
65 IrSR_TXPL_POS_IS_ZERO | \
66 IrSR_XMODE_PULSE_3_16 | \
67 IrSR_RCVEIR_UART_MODE | \
73 unsigned long last_oscr
;
75 unsigned char *dma_rx_buff
;
76 unsigned char *dma_tx_buff
;
77 dma_addr_t dma_rx_buff_phy
;
78 dma_addr_t dma_tx_buff_phy
;
79 unsigned int dma_tx_buff_len
;
83 struct net_device_stats stats
;
84 struct irlap_cb
*irlap
;
91 struct pxaficp_platform_data
*pdata
;
97 static inline void pxa_irda_disable_clk(struct pxa_irda
*si
)
100 clk_disable(si
->cur_clk
);
104 static inline void pxa_irda_enable_firclk(struct pxa_irda
*si
)
106 si
->cur_clk
= si
->fir_clk
;
107 clk_enable(si
->fir_clk
);
110 static inline void pxa_irda_enable_sirclk(struct pxa_irda
*si
)
112 si
->cur_clk
= si
->sir_clk
;
113 clk_enable(si
->sir_clk
);
117 #define IS_FIR(si) ((si)->speed >= 4000000)
118 #define IRDA_FRAME_SIZE_LIMIT 2047
120 inline static void pxa_irda_fir_dma_rx_start(struct pxa_irda
*si
)
122 DCSR(si
->rxdma
) = DCSR_NODESC
;
123 DSADR(si
->rxdma
) = __PREG(ICDR
);
124 DTADR(si
->rxdma
) = si
->dma_rx_buff_phy
;
125 DCMD(si
->rxdma
) = DCMD_INCTRGADDR
| DCMD_FLOWSRC
| DCMD_WIDTH1
| DCMD_BURST32
| IRDA_FRAME_SIZE_LIMIT
;
126 DCSR(si
->rxdma
) |= DCSR_RUN
;
129 inline static void pxa_irda_fir_dma_tx_start(struct pxa_irda
*si
)
131 DCSR(si
->txdma
) = DCSR_NODESC
;
132 DSADR(si
->txdma
) = si
->dma_tx_buff_phy
;
133 DTADR(si
->txdma
) = __PREG(ICDR
);
134 DCMD(si
->txdma
) = DCMD_INCSRCADDR
| DCMD_FLOWTRG
| DCMD_ENDIRQEN
| DCMD_WIDTH1
| DCMD_BURST32
| si
->dma_tx_buff_len
;
135 DCSR(si
->txdma
) |= DCSR_RUN
;
139 * Set the IrDA communications speed.
141 static int pxa_irda_set_speed(struct pxa_irda
*si
, int speed
)
144 unsigned int divisor
;
147 case 9600: case 19200: case 38400:
148 case 57600: case 115200:
150 /* refer to PXA250/210 Developer's Manual 10-7 */
151 /* BaudRate = 14.7456 MHz / (16*Divisor) */
152 divisor
= 14745600 / (16 * speed
);
154 local_irq_save(flags
);
158 DCSR(si
->rxdma
) &= ~DCSR_RUN
;
161 pxa_irda_disable_clk(si
);
163 /* set board transceiver to SIR mode */
164 si
->pdata
->transceiver_mode(si
->dev
, IR_SIRMODE
);
166 /* configure GPIO46/47 */
167 pxa_gpio_mode(GPIO46_STRXD_MD
);
168 pxa_gpio_mode(GPIO47_STTXD_MD
);
170 /* enable the STUART clock */
171 pxa_irda_enable_sirclk(si
);
174 /* disable STUART first */
177 /* access DLL & DLH */
179 STDLL
= divisor
& 0xff;
180 STDLH
= divisor
>> 8;
184 STISR
= IrSR_IR_RECEIVE_ON
| IrSR_XMODE_PULSE_1_6
;
185 STIER
= IER_UUE
| IER_RLSE
| IER_RAVIE
| IER_RTIOE
;
187 local_irq_restore(flags
);
191 local_irq_save(flags
);
196 pxa_irda_disable_clk(si
);
198 /* disable FICP first */
201 /* set board transceiver to FIR mode */
202 si
->pdata
->transceiver_mode(si
->dev
, IR_FIRMODE
);
204 /* configure GPIO46/47 */
205 pxa_gpio_mode(GPIO46_ICPRXD_MD
);
206 pxa_gpio_mode(GPIO47_ICPTXD_MD
);
208 /* enable the FICP clock */
209 pxa_irda_enable_firclk(si
);
212 pxa_irda_fir_dma_rx_start(si
);
213 ICCR0
= ICCR0_ITR
| ICCR0_RXE
;
215 local_irq_restore(flags
);
225 /* SIR interrupt service routine. */
226 static irqreturn_t
pxa_irda_sir_irq(int irq
, void *dev_id
)
228 struct net_device
*dev
= dev_id
;
229 struct pxa_irda
*si
= netdev_priv(dev
);
234 switch (iir
& 0x0F) {
235 case 0x06: /* Receiver Line Status */
237 while (lsr
& LSR_FIFOE
) {
239 if (lsr
& (LSR_OE
| LSR_PE
| LSR_FE
| LSR_BI
)) {
240 printk(KERN_DEBUG
"pxa_ir: sir receiving error\n");
241 si
->stats
.rx_errors
++;
243 si
->stats
.rx_frame_errors
++;
245 si
->stats
.rx_fifo_errors
++;
247 si
->stats
.rx_bytes
++;
248 async_unwrap_char(dev
, &si
->stats
, &si
->rx_buff
, data
);
252 dev
->last_rx
= jiffies
;
253 si
->last_oscr
= OSCR
;
256 case 0x04: /* Received Data Available */
259 case 0x0C: /* Character Timeout Indication */
261 si
->stats
.rx_bytes
++;
262 async_unwrap_char(dev
, &si
->stats
, &si
->rx_buff
, STRBR
);
263 } while (STLSR
& LSR_DR
);
264 dev
->last_rx
= jiffies
;
265 si
->last_oscr
= OSCR
;
268 case 0x02: /* Transmit FIFO Data Request */
269 while ((si
->tx_buff
.len
) && (STLSR
& LSR_TDRQ
)) {
270 STTHR
= *si
->tx_buff
.data
++;
271 si
->tx_buff
.len
-= 1;
274 if (si
->tx_buff
.len
== 0) {
275 si
->stats
.tx_packets
++;
276 si
->stats
.tx_bytes
+= si
->tx_buff
.data
-
279 /* We need to ensure that the transmitter has finished. */
280 while ((STLSR
& LSR_TEMT
) == 0)
282 si
->last_oscr
= OSCR
;
285 * Ok, we've finished transmitting. Now enable
286 * the receiver. Sometimes we get a receive IRQ
287 * immediately after a transmit...
290 pxa_irda_set_speed(si
, si
->newspeed
);
293 /* enable IR Receiver, disable IR Transmitter */
294 STISR
= IrSR_IR_RECEIVE_ON
| IrSR_XMODE_PULSE_1_6
;
295 /* enable STUART and receive interrupts */
296 STIER
= IER_UUE
| IER_RLSE
| IER_RAVIE
| IER_RTIOE
;
299 netif_wake_queue(dev
);
307 /* FIR Receive DMA interrupt handler */
308 static void pxa_irda_fir_dma_rx_irq(int channel
, void *data
)
310 int dcsr
= DCSR(channel
);
312 DCSR(channel
) = dcsr
& ~DCSR_RUN
;
314 printk(KERN_DEBUG
"pxa_ir: fir rx dma bus error %#x\n", dcsr
);
317 /* FIR Transmit DMA interrupt handler */
318 static void pxa_irda_fir_dma_tx_irq(int channel
, void *data
)
320 struct net_device
*dev
= data
;
321 struct pxa_irda
*si
= netdev_priv(dev
);
324 dcsr
= DCSR(channel
);
325 DCSR(channel
) = dcsr
& ~DCSR_RUN
;
327 if (dcsr
& DCSR_ENDINTR
) {
328 si
->stats
.tx_packets
++;
329 si
->stats
.tx_bytes
+= si
->dma_tx_buff_len
;
331 si
->stats
.tx_errors
++;
334 while (ICSR1
& ICSR1_TBY
)
336 si
->last_oscr
= OSCR
;
339 * HACK: It looks like the TBY bit is dropped too soon.
340 * Without this delay things break.
345 pxa_irda_set_speed(si
, si
->newspeed
);
351 pxa_irda_fir_dma_rx_start(si
);
352 while ((ICSR1
& ICSR1_RNE
) && i
--)
354 ICCR0
= ICCR0_ITR
| ICCR0_RXE
;
357 printk(KERN_ERR
"pxa_ir: cannot clear Rx FIFO!\n");
359 netif_wake_queue(dev
);
362 /* EIF(Error in FIFO/End in Frame) handler for FIR */
363 static void pxa_irda_fir_irq_eif(struct pxa_irda
*si
, struct net_device
*dev
, int icsr0
)
365 unsigned int len
, stat
, data
;
367 /* Get the current data position. */
368 len
= DTADR(si
->rxdma
) - si
->dma_rx_buff_phy
;
371 /* Read Status, and then Data. */
376 if (stat
& (ICSR1_CRE
| ICSR1_ROR
)) {
377 si
->stats
.rx_errors
++;
378 if (stat
& ICSR1_CRE
) {
379 printk(KERN_DEBUG
"pxa_ir: fir receive CRC error\n");
380 si
->stats
.rx_crc_errors
++;
382 if (stat
& ICSR1_ROR
) {
383 printk(KERN_DEBUG
"pxa_ir: fir receive overrun\n");
384 si
->stats
.rx_over_errors
++;
387 si
->dma_rx_buff
[len
++] = data
;
389 /* If we hit the end of frame, there's no point in continuing. */
390 if (stat
& ICSR1_EOF
)
392 } while (ICSR0
& ICSR0_EIF
);
394 if (stat
& ICSR1_EOF
) {
398 if (icsr0
& ICSR0_FRE
) {
399 printk(KERN_ERR
"pxa_ir: dropping erroneous frame\n");
400 si
->stats
.rx_dropped
++;
404 skb
= alloc_skb(len
+1,GFP_ATOMIC
);
406 printk(KERN_ERR
"pxa_ir: fir out of memory for receive skb\n");
407 si
->stats
.rx_dropped
++;
411 /* Align IP header to 20 bytes */
413 skb_copy_to_linear_data(skb
, si
->dma_rx_buff
, len
);
416 /* Feed it to IrLAP */
418 skb_reset_mac_header(skb
);
419 skb
->protocol
= htons(ETH_P_IRDA
);
422 si
->stats
.rx_packets
++;
423 si
->stats
.rx_bytes
+= len
;
425 dev
->last_rx
= jiffies
;
429 /* FIR interrupt handler */
430 static irqreturn_t
pxa_irda_fir_irq(int irq
, void *dev_id
)
432 struct net_device
*dev
= dev_id
;
433 struct pxa_irda
*si
= netdev_priv(dev
);
437 DCSR(si
->rxdma
) &= ~DCSR_RUN
;
438 si
->last_oscr
= OSCR
;
441 if (icsr0
& (ICSR0_FRE
| ICSR0_RAB
)) {
442 if (icsr0
& ICSR0_FRE
) {
443 printk(KERN_DEBUG
"pxa_ir: fir receive frame error\n");
444 si
->stats
.rx_frame_errors
++;
446 printk(KERN_DEBUG
"pxa_ir: fir receive abort\n");
447 si
->stats
.rx_errors
++;
449 ICSR0
= icsr0
& (ICSR0_FRE
| ICSR0_RAB
);
452 if (icsr0
& ICSR0_EIF
) {
453 /* An error in FIFO occured, or there is a end of frame */
454 pxa_irda_fir_irq_eif(si
, dev
, icsr0
);
458 pxa_irda_fir_dma_rx_start(si
);
459 while ((ICSR1
& ICSR1_RNE
) && i
--)
461 ICCR0
= ICCR0_ITR
| ICCR0_RXE
;
464 printk(KERN_ERR
"pxa_ir: cannot clear Rx FIFO!\n");
469 /* hard_xmit interface of irda device */
470 static int pxa_irda_hard_xmit(struct sk_buff
*skb
, struct net_device
*dev
)
472 struct pxa_irda
*si
= netdev_priv(dev
);
473 int speed
= irda_get_next_speed(skb
);
476 * Does this packet contain a request to change the interface
477 * speed? If so, remember it until we complete the transmission
480 if (speed
!= si
->speed
&& speed
!= -1)
481 si
->newspeed
= speed
;
484 * If this is an empty frame, we can bypass a lot.
489 pxa_irda_set_speed(si
, speed
);
495 netif_stop_queue(dev
);
498 si
->tx_buff
.data
= si
->tx_buff
.head
;
499 si
->tx_buff
.len
= async_wrap_skb(skb
, si
->tx_buff
.data
, si
->tx_buff
.truesize
);
501 /* Disable STUART interrupts and switch to transmit mode. */
503 STISR
= IrSR_IR_TRANSMIT_ON
| IrSR_XMODE_PULSE_1_6
;
505 /* enable STUART and transmit interrupts */
506 STIER
= IER_UUE
| IER_TIE
;
508 unsigned long mtt
= irda_get_mtt(skb
);
510 si
->dma_tx_buff_len
= skb
->len
;
511 skb_copy_from_linear_data(skb
, si
->dma_tx_buff
, skb
->len
);
514 while ((unsigned)(OSCR
- si
->last_oscr
)/4 < mtt
)
517 /* stop RX DMA, disable FICP */
518 DCSR(si
->rxdma
) &= ~DCSR_RUN
;
521 pxa_irda_fir_dma_tx_start(si
);
522 ICCR0
= ICCR0_ITR
| ICCR0_TXE
;
526 dev
->trans_start
= jiffies
;
530 static int pxa_irda_ioctl(struct net_device
*dev
, struct ifreq
*ifreq
, int cmd
)
532 struct if_irda_req
*rq
= (struct if_irda_req
*)ifreq
;
533 struct pxa_irda
*si
= netdev_priv(dev
);
539 if (capable(CAP_NET_ADMIN
)) {
541 * We are unable to set the speed if the
542 * device is not running.
544 if (netif_running(dev
)) {
545 ret
= pxa_irda_set_speed(si
,
548 printk(KERN_INFO
"pxa_ir: SIOCSBANDWIDTH: !netif_running\n");
556 if (capable(CAP_NET_ADMIN
)) {
557 irda_device_set_media_busy(dev
, TRUE
);
564 rq
->ifr_receiving
= IS_FIR(si
) ? 0
565 : si
->rx_buff
.state
!= OUTSIDE_FRAME
;
576 static struct net_device_stats
*pxa_irda_stats(struct net_device
*dev
)
578 struct pxa_irda
*si
= netdev_priv(dev
);
582 static void pxa_irda_startup(struct pxa_irda
*si
)
584 /* Disable STUART interrupts */
586 /* enable STUART interrupt to the processor */
588 /* configure SIR frame format: StartBit - Data 7 ... Data 0 - Stop Bit */
589 STLCR
= LCR_WLS0
| LCR_WLS1
;
590 /* enable FIFO, we use FIFO to improve performance */
591 STFCR
= FCR_TRFIFOE
| FCR_ITL_32
;
595 /* configure FICP ICCR2 */
596 ICCR2
= ICCR2_TXP
| ICCR2_TRIG_32
;
599 DRCMR17
= si
->rxdma
| DRCMR_MAPVLD
;
600 DRCMR18
= si
->txdma
| DRCMR_MAPVLD
;
602 /* force SIR reinitialization */
604 pxa_irda_set_speed(si
, 9600);
606 printk(KERN_DEBUG
"pxa_ir: irda startup\n");
609 static void pxa_irda_shutdown(struct pxa_irda
*si
)
613 local_irq_save(flags
);
615 /* disable STUART and interrupt */
617 /* disable STUART SIR mode */
621 DCSR(si
->txdma
) &= ~DCSR_RUN
;
622 DCSR(si
->rxdma
) &= ~DCSR_RUN
;
626 /* disable the STUART or FICP clocks */
627 pxa_irda_disable_clk(si
);
632 local_irq_restore(flags
);
634 /* power off board transceiver */
635 si
->pdata
->transceiver_mode(si
->dev
, IR_OFF
);
637 printk(KERN_DEBUG
"pxa_ir: irda shutdown\n");
640 static int pxa_irda_start(struct net_device
*dev
)
642 struct pxa_irda
*si
= netdev_priv(dev
);
647 err
= request_irq(IRQ_STUART
, pxa_irda_sir_irq
, 0, dev
->name
, dev
);
651 err
= request_irq(IRQ_ICP
, pxa_irda_fir_irq
, 0, dev
->name
, dev
);
656 * The interrupt must remain disabled for now.
658 disable_irq(IRQ_STUART
);
659 disable_irq(IRQ_ICP
);
662 si
->rxdma
= pxa_request_dma("FICP_RX",DMA_PRIO_LOW
, pxa_irda_fir_dma_rx_irq
, dev
);
666 si
->txdma
= pxa_request_dma("FICP_TX",DMA_PRIO_LOW
, pxa_irda_fir_dma_tx_irq
, dev
);
671 si
->dma_rx_buff
= dma_alloc_coherent(si
->dev
, IRDA_FRAME_SIZE_LIMIT
,
672 &si
->dma_rx_buff_phy
, GFP_KERNEL
);
673 if (!si
->dma_rx_buff
)
674 goto err_dma_rx_buff
;
676 si
->dma_tx_buff
= dma_alloc_coherent(si
->dev
, IRDA_FRAME_SIZE_LIMIT
,
677 &si
->dma_tx_buff_phy
, GFP_KERNEL
);
678 if (!si
->dma_tx_buff
)
679 goto err_dma_tx_buff
;
681 /* Setup the serial port for the initial speed. */
682 pxa_irda_startup(si
);
685 * Open a new IrLAP layer instance.
687 si
->irlap
= irlap_open(dev
, &si
->qos
, "pxa");
693 * Now enable the interrupt and start the queue
695 enable_irq(IRQ_STUART
);
697 netif_start_queue(dev
);
699 printk(KERN_DEBUG
"pxa_ir: irda driver opened\n");
704 pxa_irda_shutdown(si
);
705 dma_free_coherent(si
->dev
, IRDA_FRAME_SIZE_LIMIT
, si
->dma_tx_buff
, si
->dma_tx_buff_phy
);
707 dma_free_coherent(si
->dev
, IRDA_FRAME_SIZE_LIMIT
, si
->dma_rx_buff
, si
->dma_rx_buff_phy
);
709 pxa_free_dma(si
->txdma
);
711 pxa_free_dma(si
->rxdma
);
713 free_irq(IRQ_ICP
, dev
);
715 free_irq(IRQ_STUART
, dev
);
721 static int pxa_irda_stop(struct net_device
*dev
)
723 struct pxa_irda
*si
= netdev_priv(dev
);
725 netif_stop_queue(dev
);
727 pxa_irda_shutdown(si
);
731 irlap_close(si
->irlap
);
735 free_irq(IRQ_STUART
, dev
);
736 free_irq(IRQ_ICP
, dev
);
738 pxa_free_dma(si
->rxdma
);
739 pxa_free_dma(si
->txdma
);
742 dma_free_coherent(si
->dev
, IRDA_FRAME_SIZE_LIMIT
, si
->dma_tx_buff
, si
->dma_tx_buff_phy
);
744 dma_free_coherent(si
->dev
, IRDA_FRAME_SIZE_LIMIT
, si
->dma_rx_buff
, si
->dma_rx_buff_phy
);
746 printk(KERN_DEBUG
"pxa_ir: irda driver closed\n");
750 static int pxa_irda_suspend(struct platform_device
*_dev
, pm_message_t state
)
752 struct net_device
*dev
= platform_get_drvdata(_dev
);
755 if (dev
&& netif_running(dev
)) {
756 si
= netdev_priv(dev
);
757 netif_device_detach(dev
);
758 pxa_irda_shutdown(si
);
764 static int pxa_irda_resume(struct platform_device
*_dev
)
766 struct net_device
*dev
= platform_get_drvdata(_dev
);
769 if (dev
&& netif_running(dev
)) {
770 si
= netdev_priv(dev
);
771 pxa_irda_startup(si
);
772 netif_device_attach(dev
);
773 netif_wake_queue(dev
);
780 static int pxa_irda_init_iobuf(iobuff_t
*io
, int size
)
782 io
->head
= kmalloc(size
, GFP_KERNEL
| GFP_DMA
);
783 if (io
->head
!= NULL
) {
785 io
->in_frame
= FALSE
;
786 io
->state
= OUTSIDE_FRAME
;
789 return io
->head
? 0 : -ENOMEM
;
792 static int pxa_irda_probe(struct platform_device
*pdev
)
794 struct net_device
*dev
;
796 unsigned int baudrate_mask
;
799 if (!pdev
->dev
.platform_data
)
802 err
= request_mem_region(__PREG(STUART
), 0x24, "IrDA") ? 0 : -EBUSY
;
806 err
= request_mem_region(__PREG(FICP
), 0x1c, "IrDA") ? 0 : -EBUSY
;
810 dev
= alloc_irdadev(sizeof(struct pxa_irda
));
814 si
= netdev_priv(dev
);
815 si
->dev
= &pdev
->dev
;
816 si
->pdata
= pdev
->dev
.platform_data
;
818 si
->sir_clk
= clk_get(&pdev
->dev
, "UARTCLK");
819 si
->fir_clk
= clk_get(&pdev
->dev
, "FICPCLK");
820 if (IS_ERR(si
->sir_clk
) || IS_ERR(si
->fir_clk
)) {
821 err
= PTR_ERR(IS_ERR(si
->sir_clk
) ? si
->sir_clk
: si
->fir_clk
);
826 * Initialise the SIR buffers
828 err
= pxa_irda_init_iobuf(&si
->rx_buff
, 14384);
831 err
= pxa_irda_init_iobuf(&si
->tx_buff
, 4000);
835 if (si
->pdata
->startup
)
836 err
= si
->pdata
->startup(si
->dev
);
840 dev
->hard_start_xmit
= pxa_irda_hard_xmit
;
841 dev
->open
= pxa_irda_start
;
842 dev
->stop
= pxa_irda_stop
;
843 dev
->do_ioctl
= pxa_irda_ioctl
;
844 dev
->get_stats
= pxa_irda_stats
;
846 irda_init_max_qos_capabilies(&si
->qos
);
849 if (si
->pdata
->transceiver_cap
& IR_SIRMODE
)
850 baudrate_mask
|= IR_9600
|IR_19200
|IR_38400
|IR_57600
|IR_115200
;
851 if (si
->pdata
->transceiver_cap
& IR_FIRMODE
)
852 baudrate_mask
|= IR_4000000
<< 8;
854 si
->qos
.baud_rate
.bits
&= baudrate_mask
;
855 si
->qos
.min_turn_time
.bits
= 7; /* 1ms or more */
857 irda_qos_bits_to_value(&si
->qos
);
859 err
= register_netdev(dev
);
862 dev_set_drvdata(&pdev
->dev
, dev
);
865 if (si
->pdata
->shutdown
)
866 si
->pdata
->shutdown(si
->dev
);
868 kfree(si
->tx_buff
.head
);
870 kfree(si
->rx_buff
.head
);
872 if (si
->sir_clk
&& !IS_ERR(si
->sir_clk
))
873 clk_put(si
->sir_clk
);
874 if (si
->fir_clk
&& !IS_ERR(si
->fir_clk
))
875 clk_put(si
->fir_clk
);
878 release_mem_region(__PREG(FICP
), 0x1c);
880 release_mem_region(__PREG(STUART
), 0x24);
886 static int pxa_irda_remove(struct platform_device
*_dev
)
888 struct net_device
*dev
= platform_get_drvdata(_dev
);
891 struct pxa_irda
*si
= netdev_priv(dev
);
892 unregister_netdev(dev
);
893 if (si
->pdata
->shutdown
)
894 si
->pdata
->shutdown(si
->dev
);
895 kfree(si
->tx_buff
.head
);
896 kfree(si
->rx_buff
.head
);
897 clk_put(si
->fir_clk
);
898 clk_put(si
->sir_clk
);
902 release_mem_region(__PREG(STUART
), 0x24);
903 release_mem_region(__PREG(FICP
), 0x1c);
908 static struct platform_driver pxa_ir_driver
= {
911 .owner
= THIS_MODULE
,
913 .probe
= pxa_irda_probe
,
914 .remove
= pxa_irda_remove
,
915 .suspend
= pxa_irda_suspend
,
916 .resume
= pxa_irda_resume
,
919 static int __init
pxa_irda_init(void)
921 return platform_driver_register(&pxa_ir_driver
);
924 static void __exit
pxa_irda_exit(void)
926 platform_driver_unregister(&pxa_ir_driver
);
929 module_init(pxa_irda_init
);
930 module_exit(pxa_irda_exit
);
932 MODULE_LICENSE("GPL");
933 MODULE_ALIAS("platform:pxa2xx-ir");