21 #include <linux/kernel.h>
22 #include <linux/module.h>
24 #include <linux/sched.h>
26 #include <linux/pci.h>
31 static int poll_main(
void);
32 static int atir_init_start(
void);
34 static void write_index(
unsigned char index,
unsigned int value);
35 static unsigned int read_index(
unsigned char index);
37 static void do_i2c_start(
void);
38 static void do_i2c_stop(
void);
40 static void seems_wr_byte(
unsigned char al);
41 static unsigned char seems_rd_byte(
void);
43 static unsigned int read_index(
unsigned char al);
44 static void write_index(
unsigned char ah,
unsigned int edx);
46 static void cycle_delay(
int cycle);
48 static void do_set_bits(
unsigned char bl);
49 static unsigned char do_get_bits(
void);
51 #define DATA_PCI_OFF 0x7FFC00
54 #define DRIVER_NAME "lirc_bt829"
57 #define dprintk(fmt, args...) \
60 printk(KERN_DEBUG DRIVER_NAME ": "fmt, ## args); \
63 static int atir_minor;
64 static unsigned long pci_addr_phys;
65 static unsigned char *pci_addr_lin;
69 static struct pci_dev *do_pci_probe(
void)
79 pci_addr_phys = my_dev->
resource[0].start;
81 (
unsigned int)pci_addr_phys);
83 if (pci_addr_phys == 0) {
99 key = (status >> 8) & 0xFF;
101 dprintk(
"reading key %02X\n", key);
102 lirc_buffer_write(buf, &key);
108 static int atir_set_use_inc(
void *data)
114 static void atir_set_use_dec(
void *data)
123 pdev = do_pci_probe();
127 if (!atir_init_start())
130 strcpy(atir_driver.name,
"ATIR");
131 atir_driver.minor = -1;
132 atir_driver.code_length = 8;
133 atir_driver.sample_rate = 10;
134 atir_driver.data = 0;
135 atir_driver.add_to_buf = atir_add_to_buf;
136 atir_driver.set_use_inc = atir_set_use_inc;
137 atir_driver.set_use_dec = atir_set_use_dec;
138 atir_driver.dev = &pdev->
dev;
142 if (atir_minor < 0) {
146 dprintk(
"driver is registered on minor %d\n", atir_minor);
158 static int atir_init_start(
void)
161 if (pci_addr_lin == 0) {
168 static void cycle_delay(
int cycle)
174 static int poll_main(
void)
176 unsigned char status_high, status_low;
187 status_low = seems_rd_byte();
188 status_high = seems_rd_byte();
192 return (status_high << 8) | status_low;
195 static void do_i2c_start(
void)
207 static void do_i2c_stop(
void)
210 bits = do_get_bits() & 0xFD;
225 static void seems_wr_byte(
unsigned char value)
231 for (i = 0; i < 8; i++) {
265 static unsigned char seems_rd_byte(
void)
269 unsigned char bits_2, bits_1;
271 bits_1 = do_get_bits() | 2;
275 for (i = 0; i < 8; i++) {
284 bits_2 = do_get_bits();
311 static void do_set_bits(
unsigned char new_bits)
314 reg_val = read_index(0x34);
316 reg_val &= 0xFFFFFFDF;
319 reg_val &= 0xFFFFFFFE;
323 write_index(0x34, reg_val);
325 reg_val = read_index(0x31);
327 reg_val |= 0x1000000;
329 reg_val &= 0xFEFFFFFF;
331 reg_val |= 0x8000000;
332 write_index(0x31, reg_val);
335 static unsigned char do_get_bits(
void)
340 reg_val = read_index(0x34);
342 reg_val &= 0xFFFFFFDF;
343 write_index(0x34, reg_val);
345 reg_val = read_index(0x34);
352 reg_val = read_index(0x31);
353 if (reg_val & 0x1000000)
361 static unsigned int read_index(
unsigned char index)
366 addr = pci_addr_lin + ((index & 0xFF) << 2);
371 static void write_index(
unsigned char index,
unsigned int reg_val)
374 addr = pci_addr_lin + ((index & 0xFF) << 2);