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 <asm/hardware.h>
67 #include <asm/serial.h>
68 #include <asm/mach-types.h>
70 #include <asm/arch/mux.h>
71 #include <asm/arch/gpio.h>
72 #include <asm/arch/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_DMA_CDAC_REG(omap_ir->rx_dma_channel);
383 if (cpu_is_omap16xx())
384 w -= OMAP1_DMA_CDSA_L_REG(omap_ir->rx_dma_channel);
385 if (cpu_is_omap24xx())
386 w -= OMAP2_DMA_CDSA_REG(omap_ir->rx_dma_channel);
388 if (!IS_FIR(omap_ir))
389 /* Copy DMA buffer to skb */
390 memcpy(skb_put(skb, w - 2), omap_ir->rx_buf_dma_virt,
393 /* Copy DMA buffer to skb */
394 memcpy(skb_put(skb, w - 4), omap_ir->rx_buf_dma_virt,
398 skb->mac.raw = skb->data;
399 skb->protocol = htons(ETH_P_IRDA);
400 omap_ir->stats.rx_packets++;
401 omap_ir->stats.rx_bytes += skb->len;
402 netif_receive_skb(skb); /* Send data to upper level */
406 omap_irda_start_rx_dma(omap_ir);
408 dev->last_rx = jiffies;
413 static int omap_irda_hard_xmit(struct sk_buff *skb, struct net_device *dev)
415 struct omap_irda *omap_ir = netdev_priv(dev);
416 int speed = irda_get_next_speed(skb);
417 int mtt = irda_get_mtt(skb);
418 int xbofs = irda_get_next_xbofs(skb);
422 * Does this packet contain a request to change the interface
423 * speed? If so, remember it until we complete the transmission
426 if (speed != omap_ir->speed && speed != -1)
427 omap_ir->newspeed = speed;
429 if (xbofs) /* Set number of addtional BOFS */
430 uart_reg_out(UART3_EBLR, xbofs + 1);
433 * If this is an empty frame, we can bypass a lot.
436 if (omap_ir->newspeed) {
437 omap_ir->newspeed = 0;
438 omap_irda_set_speed(dev, speed);
444 netif_stop_queue(dev);
446 /* Copy skb data to DMA buffer */
447 memcpy(omap_ir->tx_buf_dma_virt, skb->data, skb->len);
449 /* Copy skb data to DMA buffer */
450 omap_ir->stats.tx_bytes += skb->len;
452 /* Set frame length */
453 uart_reg_out(UART3_TXFLL, (skb->len & 0xff));
454 uart_reg_out(UART3_TXFLH, (skb->len >> 8));
461 /* Start TX DMA transfer */
462 omap_start_tx_dma(omap_ir, skb->len);
464 /* We can free skb now because it's already in DMA buffer */
467 dev->trans_start = jiffies;
473 omap_irda_ioctl(struct net_device *dev, struct ifreq *ifreq, int cmd)
475 struct if_irda_req *rq = (struct if_irda_req *)ifreq;
476 struct omap_irda *omap_ir = netdev_priv(dev);
477 int ret = -EOPNOTSUPP;
482 if (capable(CAP_NET_ADMIN)) {
484 * We are unable to set the speed if the
485 * device is not running.
488 ret = omap_irda_set_speed(dev,
491 printk(KERN_ERR "omap_ir: SIOCSBANDWIDTH:"
492 " !netif_running\n");
500 if (capable(CAP_NET_ADMIN)) {
501 irda_device_set_media_busy(dev, TRUE);
507 rq->ifr_receiving = 0;
517 static struct net_device_stats *omap_irda_stats(struct net_device *dev)
519 struct omap_irda *omap_ir = netdev_priv(dev);
520 return &omap_ir->stats;
523 static int omap_irda_start(struct net_device *dev)
525 struct omap_irda *omap_ir = netdev_priv(dev);
528 omap_ir->speed = 9600;
530 err = request_irq(dev->irq, omap_irda_irq, 0, dev->name, dev);
535 * The interrupt must remain disabled for now.
537 disable_irq(dev->irq);
539 /* Request DMA channels for IrDA hardware */
540 if (omap_request_dma(omap_ir->pdata->rx_channel, "IrDA Rx DMA",
541 (void *)omap_irda_rx_dma_callback,
542 dev, &(omap_ir->rx_dma_channel))) {
543 printk(KERN_ERR "Failed to request IrDA Rx DMA\n");
547 if (omap_request_dma(omap_ir->pdata->tx_channel, "IrDA Tx DMA",
548 (void *)omap_irda_tx_dma_callback,
549 dev, &(omap_ir->tx_dma_channel))) {
550 printk(KERN_ERR "Failed to request IrDA Tx DMA\n");
554 /* Allocate TX and RX buffers for DMA channels */
555 omap_ir->rx_buf_dma_virt =
556 dma_alloc_coherent(NULL, IRDA_SKB_MAX_MTU,
557 &(omap_ir->rx_buf_dma_phys),
560 if (!omap_ir->rx_buf_dma_virt) {
561 printk(KERN_ERR "Unable to allocate memory for rx_buf_dma\n");
565 omap_ir->tx_buf_dma_virt =
566 dma_alloc_coherent(NULL, IRDA_SIR_MAX_FRAME,
567 &(omap_ir->tx_buf_dma_phys),
570 if (!omap_ir->tx_buf_dma_virt) {
571 printk(KERN_ERR "Unable to allocate memory for tx_buf_dma\n");
576 * Setup the serial port for the specified config.
578 if (omap_ir->pdata->select_irda)
579 omap_ir->pdata->select_irda(omap_ir->dev, IR_SEL);
581 err = omap_irda_startup(dev);
586 omap_irda_set_speed(dev, omap_ir->speed = 9600);
589 * Open a new IrLAP layer instance.
591 omap_ir->irlap = irlap_open(dev, &omap_ir->qos, "omap_sir");
597 /* Now enable the interrupt and start the queue */
601 omap_irda_start_rx_dma(omap_ir);
603 enable_irq(dev->irq);
604 netif_start_queue(dev);
610 omap_irda_shutdown(omap_ir);
612 dma_free_coherent(NULL, IRDA_SIR_MAX_FRAME,
613 omap_ir->tx_buf_dma_virt, omap_ir->tx_buf_dma_phys);
615 dma_free_coherent(NULL, IRDA_SKB_MAX_MTU,
616 omap_ir->rx_buf_dma_virt, omap_ir->rx_buf_dma_phys);
618 free_irq(dev->irq, dev);
622 static int omap_irda_stop(struct net_device *dev)
624 struct omap_irda *omap_ir = netdev_priv(dev);
626 disable_irq(dev->irq);
628 netif_stop_queue(dev);
630 omap_free_dma(omap_ir->rx_dma_channel);
631 omap_free_dma(omap_ir->tx_dma_channel);
633 if (omap_ir->rx_buf_dma_virt)
634 dma_free_coherent(NULL, IRDA_SKB_MAX_MTU,
635 omap_ir->rx_buf_dma_virt,
636 omap_ir->rx_buf_dma_phys);
637 if (omap_ir->tx_buf_dma_virt)
638 dma_free_coherent(NULL, IRDA_SIR_MAX_FRAME,
639 omap_ir->tx_buf_dma_virt,
640 omap_ir->tx_buf_dma_phys);
642 omap_irda_shutdown(omap_ir);
645 if (omap_ir->irlap) {
646 irlap_close(omap_ir->irlap);
647 omap_ir->irlap = NULL;
655 free_irq(dev->irq, dev);
660 static int omap_irda_set_speed(struct net_device *dev, int speed)
662 struct omap_irda *omap_ir = netdev_priv(dev);
667 if (speed <= 115200) {
669 local_irq_save(flags);
672 if (omap_ir->pdata->transceiver_mode)
673 omap_ir->pdata->transceiver_mode(omap_ir->dev,
677 uart_reg_out(UART3_MDR1, 1);
678 uart_reg_out(UART3_EBLR, 1);
680 divisor = 48000000 / (16 * speed); /* Base clock 48 MHz */
682 uart_reg_out(UART3_LCR, UART3_LCR_DIVEN);
683 uart_reg_out(UART3_DLL, (divisor & 0xff));
684 uart_reg_out(UART3_DLH, (divisor >> 8));
685 uart_reg_out(UART3_LCR, 0x03);
687 uart_reg_out(UART3_MCR, 0);
689 local_irq_restore(flags);
690 } else if (speed <= 1152000) {
692 local_irq_save(flags);
694 /* Set MIR mode, auto SIP */
695 uart_reg_out(UART3_MDR1, UART3_MDR1_MIR |
696 UART3_MDR1_SIP_AUTO);
698 uart_reg_out(UART3_EBLR, 2);
700 divisor = 48000000 / (41 * speed); /* Base clock 48 MHz */
702 uart_reg_out(UART3_LCR, UART3_LCR_DIVEN);
703 uart_reg_out(UART3_DLL, (divisor & 0xff));
704 uart_reg_out(UART3_DLH, (divisor >> 8));
705 uart_reg_out(UART3_LCR, 0x03);
707 if (omap_ir->pdata->transceiver_mode)
708 omap_ir->pdata->transceiver_mode(omap_ir->dev,
711 local_irq_restore(flags);
713 local_irq_save(flags);
716 uart_reg_out(UART3_MDR1, UART3_MDR1_FIR |
717 UART3_MDR1_SIP_AUTO);
719 if (omap_ir->pdata->transceiver_mode)
720 omap_ir->pdata->transceiver_mode(omap_ir->dev,
723 local_irq_restore(flags);
726 omap_ir->speed = speed;
733 * Suspend the IrDA interface.
735 static int omap_irda_suspend(struct platform_device *pdev, pm_message_t state)
737 struct net_device *dev = platform_get_drvdata(pdev);
738 struct omap_irda *omap_ir = netdev_priv(dev);
745 * Stop the transmit queue
747 netif_device_detach(dev);
748 disable_irq(dev->irq);
749 omap_irda_shutdown(omap_ir);
755 * Resume the IrDA interface.
757 static int omap_irda_resume(struct platform_device *pdev)
759 struct net_device *dev = platform_get_drvdata(pdev);
760 struct omap_irda *omap_ir= netdev_priv(dev);
767 * If we missed a speed change, initialise at the new speed
768 * directly. It is debatable whether this is actually
769 * required, but in the interests of continuing from where
770 * we left off it is desireable. The converse argument is
771 * that we should re-negotiate at 9600 baud again.
773 if (omap_ir->newspeed) {
774 omap_ir->speed = omap_ir->newspeed;
775 omap_ir->newspeed = 0;
778 omap_irda_startup(dev);
779 omap_irda_set_speed(dev, omap_ir->speed);
780 enable_irq(dev->irq);
783 * This automatically wakes up the queue
785 netif_device_attach(dev);
791 #define omap_irda_suspend NULL
792 #define omap_irda_resume NULL
795 static int omap_irda_probe(struct platform_device *pdev)
797 struct net_device *dev;
798 struct omap_irda *omap_ir;
799 struct omap_irda_config *pdata = pdev->dev.platform_data;
800 unsigned int baudrate_mask;
805 printk(KERN_ERR "IrDA Platform data not supplied\n");
809 if (!pdata->rx_channel || !pdata->tx_channel) {
810 printk(KERN_ERR "IrDA invalid rx/tx channel value\n");
814 irq = platform_get_irq(pdev, 0);
816 printk(KERN_WARNING "no irq for IrDA\n");
820 dev = alloc_irdadev(sizeof(struct omap_irda));
825 omap_ir = netdev_priv(dev);
826 omap_ir->dev = &pdev->dev;
827 omap_ir->pdata = pdata;
829 dev->hard_start_xmit = omap_irda_hard_xmit;
830 dev->open = omap_irda_start;
831 dev->stop = omap_irda_stop;
832 dev->do_ioctl = omap_irda_ioctl;
833 dev->get_stats = omap_irda_stats;
836 irda_init_max_qos_capabilies(&omap_ir->qos);
839 if (omap_ir->pdata->transceiver_cap & IR_SIRMODE)
840 baudrate_mask |= IR_9600|IR_19200|IR_38400|IR_57600|IR_115200;
841 if (omap_ir->pdata->transceiver_cap & IR_MIRMODE)
842 baudrate_mask |= IR_57600 | IR_1152000;
843 if (omap_ir->pdata->transceiver_cap & IR_FIRMODE)
844 baudrate_mask |= IR_4000000 << 8;
846 omap_ir->qos.baud_rate.bits &= baudrate_mask;
847 omap_ir->qos.min_turn_time.bits = 7;
849 irda_qos_bits_to_value(&omap_ir->qos);
851 /* Any better way to avoid this? No. */
852 if (machine_is_omap_h3() || machine_is_omap_h4())
853 INIT_DELAYED_WORK(&omap_ir->pdata->gpio_expa, NULL);
855 err = register_netdev(dev);
857 platform_set_drvdata(pdev, dev);
865 static int omap_irda_remove(struct platform_device *pdev)
867 struct net_device *dev = platform_get_drvdata(pdev);
870 unregister_netdev(dev);
876 static struct platform_driver omapir_driver = {
877 .probe = omap_irda_probe,
878 .remove = omap_irda_remove,
879 .suspend = omap_irda_suspend,
880 .resume = omap_irda_resume,
886 static char __initdata banner[] = KERN_INFO "OMAP IrDA driver initializing\n";
888 static int __init omap_irda_init(void)
891 return platform_driver_register(&omapir_driver);
894 static void __exit omap_irda_exit(void)
896 platform_driver_unregister(&omapir_driver);
899 module_init(omap_irda_init);
900 module_exit(omap_irda_exit);
902 MODULE_AUTHOR("MontaVista");
903 MODULE_DESCRIPTION("OMAP IrDA Driver");
904 MODULE_LICENSE("GPL");