blob: 4cba38f7e4a85ceb73516bd4b56f4144950731ed [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
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>
David chosrova03488822006-03-20 19:00:04 -080011#include <linux/spinlock.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070012
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
22static void ep7211_ir_open(dongle_t *self, struct qos_info *qos);
23static void ep7211_ir_close(dongle_t *self);
24static int ep7211_ir_change_speed(struct irda_task *task);
25static int ep7211_ir_reset(struct irda_task *task);
26
David chosrova03488822006-03-20 19:00:04 -080027static DEFINE_SPINLOCK(ep7211_lock);
28
Linus Torvalds1da177e2005-04-16 15:20:36 -070029static 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
38static void ep7211_ir_open(dongle_t *self, struct qos_info *qos)
39{
40 unsigned int syscon1, flags;
41
David chosrova03488822006-03-20 19:00:04 -080042 spin_lock_irqsave(&ep7211_lock, flags);
Linus Torvalds1da177e2005-04-16 15:20:36 -070043
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
David chosrova03488822006-03-20 19:00:04 -080052 spin_unlock_irqrestore(&ep7211_lock, flags);
Linus Torvalds1da177e2005-04-16 15:20:36 -070053}
54
55static void ep7211_ir_close(dongle_t *self)
56{
57 unsigned int syscon1, flags;
58
David chosrova03488822006-03-20 19:00:04 -080059 spin_lock_irqsave(&ep7211_lock, flags);
Linus Torvalds1da177e2005-04-16 15:20:36 -070060
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
David chosrova03488822006-03-20 19:00:04 -080069 spin_unlock_irqrestore(&ep7211_lock, flags);
Linus Torvalds1da177e2005-04-16 15:20:36 -070070}
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 */
79static 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 */
91static 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 */
103static 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 */
114static void __exit ep7211_ir_cleanup(void)
115{
116 irda_device_unregister_dongle(&dongle);
117}
118
119MODULE_AUTHOR("Jon McClintock <jonm@bluemug.com>");
120MODULE_DESCRIPTION("EP7211 I/R driver");
121MODULE_LICENSE("GPL");
122MODULE_ALIAS("irda-dongle-8"); /* IRDA_EP7211_IR */
123
124module_init(ep7211_ir_init);
125module_exit(ep7211_ir_cleanup);