2 * BRIEF MODULE DESCRIPTION
4 * Infra-red driver for the OMAP1610-H2 and OMAP1710-H3 and H4 Platforms
6 * (based on omap-sir.c)
8 * Copyright 2003 MontaVista Software Inc.
9 * Author: MontaVista Software, Inc.
12 * Copyright 2004 Texas Instruments.
14 * This program is free software; you can redistribute it and/or modify it
15 * under the terms of the GNU General Public License as published by the
16 * Free Software Foundation; either version 2 of the License, or (at your
17 * option) any later version.
19 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
20 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
21 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
22 * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
23 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
24 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
25 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
26 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
28 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 * You should have received a copy of the GNU General Public License along
31 * with this program; if not, write to the Free Software Foundation, Inc.,
32 * 675 Mass Ave, Cambridge, MA 02139, USA.
35 Feb 2004, Texas Instruments
36 - Ported to 2.6 kernel (Feb 2004).
38 Apr 2004, Texas Instruments
39 - Added support for H3 (Apr 2004).
40 Nov 2004, Texas Instruments
41 - Added support for Power Management.
44 #include <linux/module.h>
45 #include <linux/types.h>
46 #include <linux/init.h>
47 #include <linux/errno.h>
48 #include <linux/netdevice.h>
49 #include <linux/slab.h>
50 #include <linux/rtnetlink.h>
51 #include <linux/interrupt.h>
52 #include <linux/delay.h>
53 #include <linux/ioport.h>
54 #include <linux/dma-mapping.h>
55 #include <linux/platform_device.h>
56 #include <linux/i2c.h>
57 #include <linux/workqueue.h>
59 #include <net/irda/irda.h>
60 #include <net/irda/irmod.h>
61 #include <net/irda/wrapper.h>
62 #include <net/irda/irda_device.h>
66 #include <mach/hardware.h>
67 #include <asm/serial.h>
68 #include <asm/mach-types.h>
71 #include <mach/gpio.h>
72 #include <mach/irda.h>
74 #define UART3_EFR_EN (1 << 4)
75 #define UART3_MCR_EN_TCR_TLR (1 << 6)
77 #define UART3_LCR_WL_8 (3 << 0)
78 #define UART3_LCR_SP2 (1 << 2)
79 #define UART3_LCR_DIVEN (1 << 7)
81 #define UART3_FCR_FIFO_EN (1 << 0)
82 #define UART3_FCR_FIFO_RX (1 << 1)
83 #define UART3_FCR_FIFO_TX (1 << 2)
84 #define UART3_FCR_FIFO_DMA1 (1 << 3)
85 #define UART3_FCR_FIFO_TX_TRIG16 (1 << 4)
86 #define UART3_FCR_FIFO_RX_TRIG16 (1 << 6)
87 #define UART3_FCR_CONFIG (\
88 UART3_FCR_FIFO_EN | UART3_FCR_FIFO_RX |\
89 UART3_FCR_FIFO_TX | UART3_FCR_FIFO_DMA1 |\
90 UART3_FCR_FIFO_TX_TRIG16 |\
91 UART3_FCR_FIFO_RX_TRIG16)
93 #define UART3_SCR_TX_TRIG1 (1 << 6)
94 #define UART3_SCR_RX_TRIG1 (1 << 7)
96 #define UART3_MDR1_RESET (0x07)
97 #define UART3_MDR1_SIR (1 << 0)
98 #define UART3_MDR1_MIR (4 << 0)
99 #define UART3_MDR1_FIR (5 << 0)
100 #define UART3_MDR1_SIP_AUTO (1 << 6)
102 #define UART3_MDR2_TRIG1 (0 << 1)
103 #define UART3_MDR2_IRTX_UNDERRUN (1 << 0)
105 #define UART3_ACERG_TX_UNDERRUN_DIS (1 << 4)
106 #define UART3_ACERG_SD_MODE_LOW (1 << 6)
107 #define UART3_ACERG_DIS_IR_RX (1 << 5)
109 #define UART3_IER_EOF (1 << 5)
110 #define UART3_IER_CTS (1 << 7)
112 #define UART3_IIR_TX_STATUS (1 << 5)
113 #define UART3_IIR_EOF (0x80)
115 #define IS_FIR(omap_ir) ((omap_ir)->speed >= 4000000)
119 int speed; /* Current IrDA speed */
122 struct net_device_stats stats;
123 struct irlap_cb *irlap;
129 dma_addr_t rx_buf_dma_phys; /* Physical address of RX DMA buffer */
130 dma_addr_t tx_buf_dma_phys; /* Physical address of TX DMA buffer */
132 void *rx_buf_dma_virt; /* Virtual address of RX DMA buffer */
133 void *tx_buf_dma_virt; /* Virtual address of TX DMA buffer */
136 struct omap_irda_config *pdata;
139 static void inline uart_reg_out(int idx, u8 val)
141 omap_writeb(val, idx);
144 static u8 inline uart_reg_in(int idx)
146 u8 b = omap_readb(idx);
150 /* forward declarations */
151 extern void omap_stop_dma(int lch);
152 static int omap_irda_set_speed(struct net_device *dev, int speed);
154 static void omap_irda_start_rx_dma(struct omap_irda *omap_ir)
157 omap_set_dma_src_params(omap_ir->rx_dma_channel, 0x3, 0x0,
158 omap_ir->pdata->src_start,
161 omap_enable_dma_irq(omap_ir->rx_dma_channel, 0x01);
163 omap_set_dma_dest_params(omap_ir->rx_dma_channel, 0x0, 0x1,
164 omap_ir->rx_buf_dma_phys,
167 omap_set_dma_transfer_params(omap_ir->rx_dma_channel, 0x0,
168 IRDA_SKB_MAX_MTU, 0x1,
169 0x0, omap_ir->pdata->rx_trigger, 0);
171 omap_start_dma(omap_ir->rx_dma_channel);
174 static void omap_start_tx_dma(struct omap_irda *omap_ir, int size)
177 omap_set_dma_dest_params(omap_ir->tx_dma_channel, 0x03, 0x0,
178 omap_ir->pdata->dest_start, 0, 0);
180 omap_enable_dma_irq(omap_ir->tx_dma_channel, 0x01);
182 omap_set_dma_src_params(omap_ir->tx_dma_channel, 0x0, 0x1,
183 omap_ir->tx_buf_dma_phys,
186 omap_set_dma_transfer_params(omap_ir->tx_dma_channel, 0x0, size, 0x1,
187 0x0, omap_ir->pdata->tx_trigger, 0);
190 omap_start_dma(omap_ir->tx_dma_channel);
193 /* DMA RX callback - normally, we should not go here,
194 * it calls only if something is going wrong
196 static void omap_irda_rx_dma_callback(int lch, u16 ch_status, void *data)
198 struct net_device *dev = data;
199 struct omap_irda *omap_ir = netdev_priv(dev);
201 printk(KERN_ERR "RX Transfer error or very big frame\n");
203 /* Clear interrupts */
204 uart_reg_in(UART3_IIR);
206 omap_ir->stats.rx_frame_errors++;
208 uart_reg_in(UART3_RESUME);
211 omap_irda_start_rx_dma(omap_ir);
214 /* DMA TX callback - calling when frame transfer has been finished */
215 static void omap_irda_tx_dma_callback(int lch, u16 ch_status, void *data)
217 struct net_device *dev = data;
218 struct omap_irda *omap_ir = netdev_priv(dev);
220 /*Stop DMA controller */
221 omap_stop_dma(omap_ir->tx_dma_channel);
225 * Set the IrDA communications speed.
226 * Interrupt have to be disabled here.
228 static int omap_irda_startup(struct net_device *dev)
230 struct omap_irda *omap_ir = netdev_priv(dev);
232 /* FIXME: use clk_* apis for UART3 clock*/
233 /* Enable UART3 clock and set UART3 to IrDA mode */
234 if (machine_is_omap_h2() || machine_is_omap_h3())
235 omap_writel(omap_readl(MOD_CONF_CTRL_0) | (1 << 31) | (1 << 15),
240 if (omap_ir->pdata->transceiver_mode && machine_is_omap_h2()) {
241 /* Is it select_irda on H2 ? */
242 omap_writel(omap_readl(FUNC_MUX_CTRL_A) | 7,
244 omap_ir->pdata->transceiver_mode(omap_ir->dev, IR_SIRMODE);
247 uart_reg_out(UART3_MDR1, UART3_MDR1_RESET); /* Reset mode */
249 /* Clear DLH and DLL */
250 uart_reg_out(UART3_LCR, UART3_LCR_DIVEN);
252 uart_reg_out(UART3_DLL, 0);
253 uart_reg_out(UART3_DLH, 0);
254 uart_reg_out(UART3_LCR, 0xbf); /* FIXME: Add #define */
256 uart_reg_out(UART3_EFR, UART3_EFR_EN);
257 uart_reg_out(UART3_LCR, UART3_LCR_DIVEN);
259 /* Enable access to UART3_TLR and UART3_TCR registers */
260 uart_reg_out(UART3_MCR, UART3_MCR_EN_TCR_TLR);
262 uart_reg_out(UART3_SCR, 0);
263 /* Set Rx trigger to 1 and Tx trigger to 1 */
264 uart_reg_out(UART3_TLR, 0);
266 /* Set LCR to 8 bits and 1 stop bit */
267 uart_reg_out(UART3_LCR, 0x03);
269 /* Clear RX and TX FIFO and enable FIFO */
270 /* Use DMA Req for transfers */
271 uart_reg_out(UART3_FCR, UART3_FCR_CONFIG);
273 uart_reg_out(UART3_MCR, 0);
275 uart_reg_out(UART3_SCR, UART3_SCR_TX_TRIG1 |
278 /* Enable UART3 SIR Mode,(Frame-length method to end frames) */
279 uart_reg_out(UART3_MDR1, UART3_MDR1_SIR);
281 /* Set Status FIFO trig to 1 */
282 uart_reg_out(UART3_MDR2, 0);
284 /* Enables RXIR input */
285 /* and disable TX underrun */
287 uart_reg_out(UART3_ACREG, UART3_ACERG_SD_MODE_LOW |
288 UART3_ACERG_TX_UNDERRUN_DIS);
290 /* Enable EOF Interrupt only */
291 uart_reg_out(UART3_IER, UART3_IER_CTS | UART3_IER_EOF);
293 /* Set Maximum Received Frame size to 2048 bytes */
294 uart_reg_out(UART3_RXFLL, 0x00);
295 uart_reg_out(UART3_RXFLH, 0x08);
297 uart_reg_in(UART3_RESUME);
302 static int omap_irda_shutdown(struct omap_irda *omap_ir)
306 local_irq_save(flags);
308 /* Disable all UART3 Interrupts */
309 uart_reg_out(UART3_IER, 0);
311 /* Disable UART3 and disable baud rate generator */
312 uart_reg_out(UART3_MDR1, UART3_MDR1_RESET);
314 /* set SD_MODE pin to high and Disable RX IR */
315 uart_reg_out(UART3_ACREG, (UART3_ACERG_DIS_IR_RX |
316 ~(UART3_ACERG_SD_MODE_LOW)));
318 /* Clear DLH and DLL */
319 uart_reg_out(UART3_LCR, UART3_LCR_DIVEN);
320 uart_reg_out(UART3_DLL, 0);
321 uart_reg_out(UART3_DLH, 0);
323 local_irq_restore(flags);
329 omap_irda_irq(int irq, void *dev_id)
331 struct net_device *dev = dev_id;
332 struct omap_irda *omap_ir = netdev_priv(dev);
338 /* Clear EOF interrupt */
339 status = uart_reg_in(UART3_IIR);
341 if (status & UART3_IIR_TX_STATUS) {
342 u8 mdr2 = uart_reg_in(UART3_MDR2);
343 if (mdr2 & UART3_MDR2_IRTX_UNDERRUN)
344 printk(KERN_ERR "IrDA Buffer underrun error\n");
346 omap_ir->stats.tx_packets++;
348 if (omap_ir->newspeed) {
349 omap_irda_set_speed(dev, omap_ir->newspeed);
350 omap_ir->newspeed = 0;
353 netif_wake_queue(dev);
354 if (!(status & UART3_IIR_EOF))
358 /* Stop DMA and if there are no errors, send frame to upper layer */
359 omap_stop_dma(omap_ir->rx_dma_channel);
361 status = uart_reg_in(UART3_SFLSR); /* Take a frame status */
363 if (status != 0) { /* Bad frame? */
364 omap_ir->stats.rx_frame_errors++;
365 uart_reg_in(UART3_RESUME);
367 /* We got a frame! */
368 skb = dev_alloc_skb(IRDA_SKB_MAX_MTU);
371 printk(KERN_ERR "omap_sir: out of memory for RX SKB\n");
375 * Align any IP headers that may be contained
381 w = omap_get_dma_dst_pos(omap_ir->rx_dma_channel) -
382 omap_ir->rx_buf_dma_phys;
384 if (!IS_FIR(omap_ir))
385 /* Copy DMA buffer to skb */
386 memcpy(skb_put(skb, w - 2), omap_ir->rx_buf_dma_virt,
389 /* Copy DMA buffer to skb */
390 memcpy(skb_put(skb, w - 4), omap_ir->rx_buf_dma_virt,
394 skb_reset_mac_header(skb);
395 skb->protocol = htons(ETH_P_IRDA);
396 omap_ir->stats.rx_packets++;
397 omap_ir->stats.rx_bytes += skb->len;
398 netif_receive_skb(skb); /* Send data to upper level */
402 omap_irda_start_rx_dma(omap_ir);
404 dev->last_rx = jiffies;
409 static int omap_irda_hard_xmit(struct sk_buff *skb, struct net_device *dev)
411 struct omap_irda *omap_ir = netdev_priv(dev);
412 int speed = irda_get_next_speed(skb);
413 int mtt = irda_get_mtt(skb);
414 int xbofs = irda_get_next_xbofs(skb);
418 * Does this packet contain a request to change the interface
419 * speed? If so, remember it until we complete the transmission
422 if (speed != omap_ir->speed && speed != -1)
423 omap_ir->newspeed = speed;
425 if (xbofs) /* Set number of addtional BOFS */
426 uart_reg_out(UART3_EBLR, xbofs + 1);
429 * If this is an empty frame, we can bypass a lot.
432 if (omap_ir->newspeed) {
433 omap_ir->newspeed = 0;
434 omap_irda_set_speed(dev, speed);
440 netif_stop_queue(dev);
442 /* Copy skb data to DMA buffer */
443 skb_copy_from_linear_data(skb, omap_ir->tx_buf_dma_virt, skb->len);
445 /* Copy skb data to DMA buffer */
446 omap_ir->stats.tx_bytes += skb->len;
448 /* Set frame length */
449 uart_reg_out(UART3_TXFLL, (skb->len & 0xff));
450 uart_reg_out(UART3_TXFLH, (skb->len >> 8));
457 /* Start TX DMA transfer */
458 omap_start_tx_dma(omap_ir, skb->len);
460 /* We can free skb now because it's already in DMA buffer */
463 dev->trans_start = jiffies;
469 omap_irda_ioctl(struct net_device *dev, struct ifreq *ifreq, int cmd)
471 struct if_irda_req *rq = (struct if_irda_req *)ifreq;
472 struct omap_irda *omap_ir = netdev_priv(dev);
473 int ret = -EOPNOTSUPP;
478 if (capable(CAP_NET_ADMIN)) {
480 * We are unable to set the speed if the
481 * device is not running.
484 ret = omap_irda_set_speed(dev,
487 printk(KERN_ERR "omap_ir: SIOCSBANDWIDTH:"
488 " !netif_running\n");
496 if (capable(CAP_NET_ADMIN)) {
497 irda_device_set_media_busy(dev, TRUE);
503 rq->ifr_receiving = 0;
513 static struct net_device_stats *omap_irda_stats(struct net_device *dev)
515 struct omap_irda *omap_ir = netdev_priv(dev);
516 return &omap_ir->stats;
519 static int omap_irda_start(struct net_device *dev)
521 struct omap_irda *omap_ir = netdev_priv(dev);
524 omap_ir->speed = 9600;
526 err = request_irq(dev->irq, omap_irda_irq, 0, dev->name, dev);
531 * The interrupt must remain disabled for now.
533 disable_irq(dev->irq);
535 /* Request DMA channels for IrDA hardware */
536 if (omap_request_dma(omap_ir->pdata->rx_channel, "IrDA Rx DMA",
537 (void *)omap_irda_rx_dma_callback,
538 dev, &(omap_ir->rx_dma_channel))) {
539 printk(KERN_ERR "Failed to request IrDA Rx DMA\n");
543 if (omap_request_dma(omap_ir->pdata->tx_channel, "IrDA Tx DMA",
544 (void *)omap_irda_tx_dma_callback,
545 dev, &(omap_ir->tx_dma_channel))) {
546 printk(KERN_ERR "Failed to request IrDA Tx DMA\n");
550 /* Allocate TX and RX buffers for DMA channels */
551 omap_ir->rx_buf_dma_virt =
552 dma_alloc_coherent(NULL, IRDA_SKB_MAX_MTU,
553 &(omap_ir->rx_buf_dma_phys),
556 if (!omap_ir->rx_buf_dma_virt) {
557 printk(KERN_ERR "Unable to allocate memory for rx_buf_dma\n");
561 omap_ir->tx_buf_dma_virt =
562 dma_alloc_coherent(NULL, IRDA_SIR_MAX_FRAME,
563 &(omap_ir->tx_buf_dma_phys),
566 if (!omap_ir->tx_buf_dma_virt) {
567 printk(KERN_ERR "Unable to allocate memory for tx_buf_dma\n");
572 * Setup the serial port for the specified config.
574 if (omap_ir->pdata->select_irda)
575 omap_ir->pdata->select_irda(omap_ir->dev, IR_SEL);
577 err = omap_irda_startup(dev);
582 omap_irda_set_speed(dev, omap_ir->speed = 9600);
585 * Open a new IrLAP layer instance.
587 omap_ir->irlap = irlap_open(dev, &omap_ir->qos, "omap_sir");
593 /* Now enable the interrupt and start the queue */
597 omap_irda_start_rx_dma(omap_ir);
599 enable_irq(dev->irq);
600 netif_start_queue(dev);
606 omap_irda_shutdown(omap_ir);
608 dma_free_coherent(NULL, IRDA_SIR_MAX_FRAME,
609 omap_ir->tx_buf_dma_virt, omap_ir->tx_buf_dma_phys);
611 dma_free_coherent(NULL, IRDA_SKB_MAX_MTU,
612 omap_ir->rx_buf_dma_virt, omap_ir->rx_buf_dma_phys);
614 free_irq(dev->irq, dev);
618 static int omap_irda_stop(struct net_device *dev)
620 struct omap_irda *omap_ir = netdev_priv(dev);
622 disable_irq(dev->irq);
624 netif_stop_queue(dev);
626 omap_free_dma(omap_ir->rx_dma_channel);
627 omap_free_dma(omap_ir->tx_dma_channel);
629 if (omap_ir->rx_buf_dma_virt)
630 dma_free_coherent(NULL, IRDA_SKB_MAX_MTU,
631 omap_ir->rx_buf_dma_virt,
632 omap_ir->rx_buf_dma_phys);
633 if (omap_ir->tx_buf_dma_virt)
634 dma_free_coherent(NULL, IRDA_SIR_MAX_FRAME,
635 omap_ir->tx_buf_dma_virt,
636 omap_ir->tx_buf_dma_phys);
638 omap_irda_shutdown(omap_ir);
641 if (omap_ir->irlap) {
642 irlap_close(omap_ir->irlap);
643 omap_ir->irlap = NULL;
651 free_irq(dev->irq, dev);
656 static int omap_irda_set_speed(struct net_device *dev, int speed)
658 struct omap_irda *omap_ir = netdev_priv(dev);
663 if (speed <= 115200) {
665 local_irq_save(flags);
668 if (omap_ir->pdata->transceiver_mode)
669 omap_ir->pdata->transceiver_mode(omap_ir->dev,
673 uart_reg_out(UART3_MDR1, 1);
674 uart_reg_out(UART3_EBLR, 1);
676 divisor = 48000000 / (16 * speed); /* Base clock 48 MHz */
678 uart_reg_out(UART3_LCR, UART3_LCR_DIVEN);
679 uart_reg_out(UART3_DLL, (divisor & 0xff));
680 uart_reg_out(UART3_DLH, (divisor >> 8));
681 uart_reg_out(UART3_LCR, 0x03);
683 uart_reg_out(UART3_MCR, 0);
685 local_irq_restore(flags);
686 } else if (speed <= 1152000) {
688 local_irq_save(flags);
690 /* Set MIR mode, auto SIP */
691 uart_reg_out(UART3_MDR1, UART3_MDR1_MIR |
692 UART3_MDR1_SIP_AUTO);
694 uart_reg_out(UART3_EBLR, 2);
696 divisor = 48000000 / (41 * speed); /* Base clock 48 MHz */
698 uart_reg_out(UART3_LCR, UART3_LCR_DIVEN);
699 uart_reg_out(UART3_DLL, (divisor & 0xff));
700 uart_reg_out(UART3_DLH, (divisor >> 8));
701 uart_reg_out(UART3_LCR, 0x03);
703 if (omap_ir->pdata->transceiver_mode)
704 omap_ir->pdata->transceiver_mode(omap_ir->dev,
707 local_irq_restore(flags);
709 local_irq_save(flags);
712 uart_reg_out(UART3_MDR1, UART3_MDR1_FIR |
713 UART3_MDR1_SIP_AUTO);
715 if (omap_ir->pdata->transceiver_mode)
716 omap_ir->pdata->transceiver_mode(omap_ir->dev,
719 local_irq_restore(flags);
722 omap_ir->speed = speed;
729 * Suspend the IrDA interface.
731 static int omap_irda_suspend(struct platform_device *pdev, pm_message_t state)
733 struct net_device *dev = platform_get_drvdata(pdev);
734 struct omap_irda *omap_ir = netdev_priv(dev);
741 * Stop the transmit queue
743 netif_device_detach(dev);
744 disable_irq(dev->irq);
745 omap_irda_shutdown(omap_ir);
751 * Resume the IrDA interface.
753 static int omap_irda_resume(struct platform_device *pdev)
755 struct net_device *dev = platform_get_drvdata(pdev);
756 struct omap_irda *omap_ir= netdev_priv(dev);
763 * If we missed a speed change, initialise at the new speed
764 * directly. It is debatable whether this is actually
765 * required, but in the interests of continuing from where
766 * we left off it is desireable. The converse argument is
767 * that we should re-negotiate at 9600 baud again.
769 if (omap_ir->newspeed) {
770 omap_ir->speed = omap_ir->newspeed;
771 omap_ir->newspeed = 0;
774 omap_irda_startup(dev);
775 omap_irda_set_speed(dev, omap_ir->speed);
776 enable_irq(dev->irq);
779 * This automatically wakes up the queue
781 netif_device_attach(dev);
787 #define omap_irda_suspend NULL
788 #define omap_irda_resume NULL
791 static int omap_irda_probe(struct platform_device *pdev)
793 struct net_device *dev;
794 struct omap_irda *omap_ir;
795 struct omap_irda_config *pdata = pdev->dev.platform_data;
796 unsigned int baudrate_mask;
801 printk(KERN_ERR "IrDA Platform data not supplied\n");
805 if (!pdata->rx_channel || !pdata->tx_channel) {
806 printk(KERN_ERR "IrDA invalid rx/tx channel value\n");
810 irq = platform_get_irq(pdev, 0);
812 printk(KERN_WARNING "no irq for IrDA\n");
816 dev = alloc_irdadev(sizeof(struct omap_irda));
821 omap_ir = netdev_priv(dev);
822 omap_ir->dev = &pdev->dev;
823 omap_ir->pdata = pdata;
825 dev->hard_start_xmit = omap_irda_hard_xmit;
826 dev->open = omap_irda_start;
827 dev->stop = omap_irda_stop;
828 dev->do_ioctl = omap_irda_ioctl;
829 dev->get_stats = omap_irda_stats;
832 irda_init_max_qos_capabilies(&omap_ir->qos);
835 if (omap_ir->pdata->transceiver_cap & IR_SIRMODE)
836 baudrate_mask |= IR_9600|IR_19200|IR_38400|IR_57600|IR_115200;
837 if (omap_ir->pdata->transceiver_cap & IR_MIRMODE)
838 baudrate_mask |= IR_57600 | IR_1152000;
839 if (omap_ir->pdata->transceiver_cap & IR_FIRMODE)
840 baudrate_mask |= IR_4000000 << 8;
842 omap_ir->qos.baud_rate.bits &= baudrate_mask;
843 omap_ir->qos.min_turn_time.bits = 7;
845 irda_qos_bits_to_value(&omap_ir->qos);
847 /* Any better way to avoid this? No. */
848 if (machine_is_omap_h3() || machine_is_omap_h4())
849 INIT_DELAYED_WORK(&omap_ir->pdata->gpio_expa, NULL);
851 err = register_netdev(dev);
853 platform_set_drvdata(pdev, dev);
861 static int omap_irda_remove(struct platform_device *pdev)
863 struct net_device *dev = platform_get_drvdata(pdev);
866 unregister_netdev(dev);
872 static struct platform_driver omapir_driver = {
873 .probe = omap_irda_probe,
874 .remove = omap_irda_remove,
875 .suspend = omap_irda_suspend,
876 .resume = omap_irda_resume,
882 static char __initdata banner[] = KERN_INFO "OMAP IrDA driver initializing\n";
884 static int __init omap_irda_init(void)
887 return platform_driver_register(&omapir_driver);
890 static void __exit omap_irda_exit(void)
892 platform_driver_unregister(&omapir_driver);
895 module_init(omap_irda_init);
896 module_exit(omap_irda_exit);
898 MODULE_AUTHOR("MontaVista");
899 MODULE_DESCRIPTION("OMAP IrDA Driver");
900 MODULE_LICENSE("GPL");