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