]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blob - drivers/net/irda/ep7211_ir.c
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/roland...
[mirror_ubuntu-artful-kernel.git] / drivers / net / irda / ep7211_ir.c
1 /*
2 * IR port driver for the Cirrus Logic EP7211 processor.
3 *
4 * Copyright 2001, Blue Mug Inc. All rights reserved.
5 */
6
7 #include <linux/module.h>
8 #include <linux/delay.h>
9 #include <linux/tty.h>
10 #include <linux/init.h>
11 #include <linux/spinlock.h>
12
13 #include <net/irda/irda.h>
14 #include <net/irda/irda_device.h>
15
16 #include <asm/io.h>
17 #include <asm/hardware.h>
18
19 #define MIN_DELAY 25 /* 15 us, but wait a little more to be sure */
20 #define MAX_DELAY 10000 /* 1 ms */
21
22 static void ep7211_ir_open(dongle_t *self, struct qos_info *qos);
23 static void ep7211_ir_close(dongle_t *self);
24 static int ep7211_ir_change_speed(struct irda_task *task);
25 static int ep7211_ir_reset(struct irda_task *task);
26
27 static DEFINE_SPINLOCK(ep7211_lock);
28
29 static struct dongle_reg dongle = {
30 .type = IRDA_EP7211_IR,
31 .open = ep7211_ir_open,
32 .close = ep7211_ir_close,
33 .reset = ep7211_ir_reset,
34 .change_speed = ep7211_ir_change_speed,
35 .owner = THIS_MODULE,
36 };
37
38 static void ep7211_ir_open(dongle_t *self, struct qos_info *qos)
39 {
40 unsigned int syscon1, flags;
41
42 spin_lock_irqsave(&ep7211_lock, flags);
43
44 /* Turn on the SIR encoder. */
45 syscon1 = clps_readl(SYSCON1);
46 syscon1 |= SYSCON1_SIREN;
47 clps_writel(syscon1, SYSCON1);
48
49 /* XXX: We should disable modem status interrupts on the first
50 UART (interrupt #14). */
51
52 spin_unlock_irqrestore(&ep7211_lock, flags);
53 }
54
55 static void ep7211_ir_close(dongle_t *self)
56 {
57 unsigned int syscon1, flags;
58
59 spin_lock_irqsave(&ep7211_lock, flags);
60
61 /* Turn off the SIR encoder. */
62 syscon1 = clps_readl(SYSCON1);
63 syscon1 &= ~SYSCON1_SIREN;
64 clps_writel(syscon1, SYSCON1);
65
66 /* XXX: If we've disabled the modem status interrupts, we should
67 reset them back to their original state. */
68
69 spin_unlock_irqrestore(&ep7211_lock, flags);
70 }
71
72 /*
73 * Function ep7211_ir_change_speed (task)
74 *
75 * Change speed of the EP7211 I/R port. We don't really have to do anything
76 * for the EP7211 as long as the rate is being changed at the serial port
77 * level.
78 */
79 static int ep7211_ir_change_speed(struct irda_task *task)
80 {
81 irda_task_next_state(task, IRDA_TASK_DONE);
82 return 0;
83 }
84
85 /*
86 * Function ep7211_ir_reset (task)
87 *
88 * Reset the EP7211 I/R. We don't really have to do anything.
89 *
90 */
91 static int ep7211_ir_reset(struct irda_task *task)
92 {
93 irda_task_next_state(task, IRDA_TASK_DONE);
94 return 0;
95 }
96
97 /*
98 * Function ep7211_ir_init(void)
99 *
100 * Initialize EP7211 I/R module
101 *
102 */
103 static int __init ep7211_ir_init(void)
104 {
105 return irda_device_register_dongle(&dongle);
106 }
107
108 /*
109 * Function ep7211_ir_cleanup(void)
110 *
111 * Cleanup EP7211 I/R module
112 *
113 */
114 static void __exit ep7211_ir_cleanup(void)
115 {
116 irda_device_unregister_dongle(&dongle);
117 }
118
119 MODULE_AUTHOR("Jon McClintock <jonm@bluemug.com>");
120 MODULE_DESCRIPTION("EP7211 I/R driver");
121 MODULE_LICENSE("GPL");
122 MODULE_ALIAS("irda-dongle-8"); /* IRDA_EP7211_IR */
123
124 module_init(ep7211_ir_init);
125 module_exit(ep7211_ir_cleanup);