blob: 7b3a3b5e56e3ab17f4cc26946338d8cf967b2d8d [file] [log] [blame]
Jarod Wilson1beef3c2010-07-26 20:31:45 -03001/*
Sean Youngfa5dc29c2016-11-21 19:55:53 -02002 * serial_ir.c
Jarod Wilson1beef3c2010-07-26 20:31:45 -03003 *
Sean Youngfa5dc29c2016-11-21 19:55:53 -02004 * serial_ir - Device driver that records pulse- and pause-lengths
Jarod Wilson1beef3c2010-07-26 20:31:45 -03005 * (space-lengths) between DDCD event on a serial port.
6 *
7 * Copyright (C) 1996,97 Ralph Metzler <rjkm@thp.uni-koeln.de>
8 * Copyright (C) 1998 Trent Piepho <xyzzy@u.washington.edu>
9 * Copyright (C) 1998 Ben Pfaff <blp@gnu.org>
10 * Copyright (C) 1999 Christoph Bartelmus <lirc@bartelmus.de>
11 * Copyright (C) 2007 Andrei Tanas <andrei@tanas.ca> (suspend/resume support)
Sean Youngb66db532016-11-21 19:55:51 -020012 * Copyright (C) 2016 Sean Young <sean@mess.org> (port to rc-core)
Jarod Wilson1beef3c2010-07-26 20:31:45 -030013 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation; either version 2 of the License, or
16 * (at your option) any later version.
17 *
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
Jarod Wilson1beef3c2010-07-26 20:31:45 -030022 */
23
YAMANE Toshiakidf4f07b2012-11-08 15:55:09 -030024#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
25
Jarod Wilson1beef3c2010-07-26 20:31:45 -030026#include <linux/module.h>
27#include <linux/errno.h>
Jarod Wilson1beef3c2010-07-26 20:31:45 -030028#include <linux/interrupt.h>
Jarod Wilson1beef3c2010-07-26 20:31:45 -030029#include <linux/kernel.h>
30#include <linux/serial_reg.h>
Jarod Wilson1beef3c2010-07-26 20:31:45 -030031#include <linux/types.h>
Jarod Wilson1beef3c2010-07-26 20:31:45 -030032#include <linux/delay.h>
Jarod Wilson1beef3c2010-07-26 20:31:45 -030033#include <linux/platform_device.h>
Jarod Wilson1beef3c2010-07-26 20:31:45 -030034#include <linux/spinlock.h>
Sean Youngb66db532016-11-21 19:55:51 -020035#include <media/rc-core.h>
Jarod Wilson1beef3c2010-07-26 20:31:45 -030036
Sean Youngb66db532016-11-21 19:55:51 -020037struct serial_ir_hw {
Jarod Wilson1beef3c2010-07-26 20:31:45 -030038 int signal_pin;
39 int signal_pin_change;
40 u8 on;
41 u8 off;
Sean Youngb66db532016-11-21 19:55:51 -020042 unsigned set_send_carrier:1;
43 unsigned set_duty_cycle:1;
Sean Young0a847632016-11-21 19:55:52 -020044 void (*send_pulse)(unsigned int length, ktime_t edge);
45 void (*send_space)(void);
Jarod Wilson1beef3c2010-07-26 20:31:45 -030046 spinlock_t lock;
47};
48
Sean Youngb66db532016-11-21 19:55:51 -020049#define IR_HOMEBREW 0
50#define IR_IRDEO 1
51#define IR_IRDEO_REMOTE 2
52#define IR_ANIMAX 3
53#define IR_IGOR 4
Jarod Wilson1beef3c2010-07-26 20:31:45 -030054
Sean Youngb66db532016-11-21 19:55:51 -020055/* module parameters */
Jarod Wilson1beef3c2010-07-26 20:31:45 -030056static int type;
57static int io;
58static int irq;
Sean Young069f3b12017-02-13 20:53:23 -020059static ulong iommap;
Jarod Wilson1beef3c2010-07-26 20:31:45 -030060static int ioshift;
Heba Aamerf3a9d7e2015-01-26 10:21:09 -030061static bool softcarrier = true;
Rusty Russell90ab5ee2012-01-13 09:32:20 +103062static bool share_irq;
Jarod Wilson1beef3c2010-07-26 20:31:45 -030063static int sense = -1; /* -1 = auto, 0 = active high, 1 = active low */
Rusty Russell90ab5ee2012-01-13 09:32:20 +103064static bool txsense; /* 0 = active high, 1 = active low */
Jarod Wilson1beef3c2010-07-26 20:31:45 -030065
Jarod Wilson1beef3c2010-07-26 20:31:45 -030066/* forward declarations */
Sean Young0a847632016-11-21 19:55:52 -020067static void send_pulse_irdeo(unsigned int length, ktime_t edge);
68static void send_space_irdeo(void);
Sean Youngb66db532016-11-21 19:55:51 -020069#ifdef CONFIG_IR_SERIAL_TRANSMITTER
Sean Young0a847632016-11-21 19:55:52 -020070static void send_pulse_homebrew(unsigned int length, ktime_t edge);
71static void send_space_homebrew(void);
Sean Youngb66db532016-11-21 19:55:51 -020072#endif
Jarod Wilson1beef3c2010-07-26 20:31:45 -030073
Sean Youngb66db532016-11-21 19:55:51 -020074static struct serial_ir_hw hardware[] = {
75 [IR_HOMEBREW] = {
76 .lock = __SPIN_LOCK_UNLOCKED(hardware[IR_HOMEBREW].lock),
77 .signal_pin = UART_MSR_DCD,
Jarod Wilson1beef3c2010-07-26 20:31:45 -030078 .signal_pin_change = UART_MSR_DDCD,
79 .on = (UART_MCR_RTS | UART_MCR_OUT2 | UART_MCR_DTR),
80 .off = (UART_MCR_RTS | UART_MCR_OUT2),
Sean Youngb66db532016-11-21 19:55:51 -020081#ifdef CONFIG_IR_SERIAL_TRANSMITTER
Jarod Wilson1beef3c2010-07-26 20:31:45 -030082 .send_pulse = send_pulse_homebrew,
83 .send_space = send_space_homebrew,
Sean Youngb66db532016-11-21 19:55:51 -020084 .set_send_carrier = true,
85 .set_duty_cycle = true,
Jarod Wilson1beef3c2010-07-26 20:31:45 -030086#endif
87 },
88
Sean Youngb66db532016-11-21 19:55:51 -020089 [IR_IRDEO] = {
90 .lock = __SPIN_LOCK_UNLOCKED(hardware[IR_IRDEO].lock),
91 .signal_pin = UART_MSR_DSR,
Jarod Wilson1beef3c2010-07-26 20:31:45 -030092 .signal_pin_change = UART_MSR_DDSR,
93 .on = UART_MCR_OUT2,
94 .off = (UART_MCR_RTS | UART_MCR_DTR | UART_MCR_OUT2),
Sean Youngb66db532016-11-21 19:55:51 -020095 .send_pulse = send_pulse_irdeo,
96 .send_space = send_space_irdeo,
97 .set_duty_cycle = true,
Jarod Wilson1beef3c2010-07-26 20:31:45 -030098 },
99
Sean Youngb66db532016-11-21 19:55:51 -0200100 [IR_IRDEO_REMOTE] = {
101 .lock = __SPIN_LOCK_UNLOCKED(hardware[IR_IRDEO_REMOTE].lock),
102 .signal_pin = UART_MSR_DSR,
Jarod Wilson1beef3c2010-07-26 20:31:45 -0300103 .signal_pin_change = UART_MSR_DDSR,
104 .on = (UART_MCR_RTS | UART_MCR_DTR | UART_MCR_OUT2),
105 .off = (UART_MCR_RTS | UART_MCR_DTR | UART_MCR_OUT2),
Sean Youngb66db532016-11-21 19:55:51 -0200106 .send_pulse = send_pulse_irdeo,
107 .send_space = send_space_irdeo,
108 .set_duty_cycle = true,
Jarod Wilson1beef3c2010-07-26 20:31:45 -0300109 },
110
Sean Youngb66db532016-11-21 19:55:51 -0200111 [IR_ANIMAX] = {
112 .lock = __SPIN_LOCK_UNLOCKED(hardware[IR_ANIMAX].lock),
113 .signal_pin = UART_MSR_DCD,
Jarod Wilson1beef3c2010-07-26 20:31:45 -0300114 .signal_pin_change = UART_MSR_DDCD,
115 .on = 0,
116 .off = (UART_MCR_RTS | UART_MCR_DTR | UART_MCR_OUT2),
Jarod Wilson1beef3c2010-07-26 20:31:45 -0300117 },
118
Sean Youngb66db532016-11-21 19:55:51 -0200119 [IR_IGOR] = {
120 .lock = __SPIN_LOCK_UNLOCKED(hardware[IR_IGOR].lock),
121 .signal_pin = UART_MSR_DSR,
Jarod Wilson1beef3c2010-07-26 20:31:45 -0300122 .signal_pin_change = UART_MSR_DDSR,
123 .on = (UART_MCR_RTS | UART_MCR_OUT2 | UART_MCR_DTR),
124 .off = (UART_MCR_RTS | UART_MCR_OUT2),
Sean Youngb66db532016-11-21 19:55:51 -0200125#ifdef CONFIG_IR_SERIAL_TRANSMITTER
Jarod Wilson1beef3c2010-07-26 20:31:45 -0300126 .send_pulse = send_pulse_homebrew,
127 .send_space = send_space_homebrew,
Sean Youngb66db532016-11-21 19:55:51 -0200128 .set_send_carrier = true,
129 .set_duty_cycle = true,
Jarod Wilson1beef3c2010-07-26 20:31:45 -0300130#endif
131 },
Jarod Wilson1beef3c2010-07-26 20:31:45 -0300132};
133
134#define RS_ISR_PASS_LIMIT 256
135
Sean Youngb66db532016-11-21 19:55:51 -0200136struct serial_ir {
137 ktime_t lastkt;
138 struct rc_dev *rcdev;
139 struct platform_device *pdev;
Sean Young2940c7e2016-12-02 15:16:11 -0200140 struct timer_list timeout_timer;
Jarod Wilson1beef3c2010-07-26 20:31:45 -0300141
Sean Youngb66db532016-11-21 19:55:51 -0200142 unsigned int freq;
143 unsigned int duty_cycle;
Jarod Wilson1beef3c2010-07-26 20:31:45 -0300144
Sean Young0a847632016-11-21 19:55:52 -0200145 unsigned int pulse_width, space_width;
Sean Youngb66db532016-11-21 19:55:51 -0200146};
Jarod Wilson1beef3c2010-07-26 20:31:45 -0300147
Sean Youngb66db532016-11-21 19:55:51 -0200148static struct serial_ir serial_ir;
Jarod Wilson1beef3c2010-07-26 20:31:45 -0300149
Jarod Wilson1beef3c2010-07-26 20:31:45 -0300150/* fetch serial input packet (1 byte) from register offset */
151static u8 sinp(int offset)
152{
Heba Aamerf3a9d7e2015-01-26 10:21:09 -0300153 if (iommap)
Jarod Wilson1beef3c2010-07-26 20:31:45 -0300154 /* the register is memory-mapped */
155 offset <<= ioshift;
156
157 return inb(io + offset);
158}
159
160/* write serial output packet (1 byte) of value to register offset */
161static void soutp(int offset, u8 value)
162{
Heba Aamerf3a9d7e2015-01-26 10:21:09 -0300163 if (iommap)
Jarod Wilson1beef3c2010-07-26 20:31:45 -0300164 /* the register is memory-mapped */
165 offset <<= ioshift;
166
167 outb(value, io + offset);
168}
169
170static void on(void)
171{
Jarod Wilson1beef3c2010-07-26 20:31:45 -0300172 if (txsense)
173 soutp(UART_MCR, hardware[type].off);
174 else
175 soutp(UART_MCR, hardware[type].on);
176}
177
178static void off(void)
179{
Jarod Wilson1beef3c2010-07-26 20:31:45 -0300180 if (txsense)
181 soutp(UART_MCR, hardware[type].on);
182 else
183 soutp(UART_MCR, hardware[type].off);
184}
185
Sean Young0a847632016-11-21 19:55:52 -0200186static void init_timing_params(unsigned int new_duty_cycle,
187 unsigned int new_freq)
Jarod Wilson1beef3c2010-07-26 20:31:45 -0300188{
Sean Youngb66db532016-11-21 19:55:51 -0200189 serial_ir.duty_cycle = new_duty_cycle;
190 serial_ir.freq = new_freq;
Jarod Wilson1beef3c2010-07-26 20:31:45 -0300191
Sean Young0a847632016-11-21 19:55:52 -0200192 serial_ir.pulse_width = DIV_ROUND_CLOSEST(
193 new_duty_cycle * NSEC_PER_SEC, new_freq * 100l);
194 serial_ir.space_width = DIV_ROUND_CLOSEST(
195 (100l - new_duty_cycle) * NSEC_PER_SEC, new_freq * 100l);
Jarod Wilson1beef3c2010-07-26 20:31:45 -0300196}
Sean Young0a847632016-11-21 19:55:52 -0200197
198static void send_pulse_irdeo(unsigned int length, ktime_t target)
Jarod Wilson1beef3c2010-07-26 20:31:45 -0300199{
Sean Young0a847632016-11-21 19:55:52 -0200200 long rawbits;
Jarod Wilson1beef3c2010-07-26 20:31:45 -0300201 int i;
202 unsigned char output;
203 unsigned char chunk, shifted;
204
205 /* how many bits have to be sent ? */
206 rawbits = length * 1152 / 10000;
Sean Youngb66db532016-11-21 19:55:51 -0200207 if (serial_ir.duty_cycle > 50)
Jarod Wilson1beef3c2010-07-26 20:31:45 -0300208 chunk = 3;
209 else
210 chunk = 1;
211 for (i = 0, output = 0x7f; rawbits > 0; rawbits -= 3) {
212 shifted = chunk << (i * 3);
213 shifted >>= 1;
214 output &= (~shifted);
215 i++;
216 if (i == 3) {
217 soutp(UART_TX, output);
218 while (!(sinp(UART_LSR) & UART_LSR_THRE))
219 ;
220 output = 0x7f;
221 i = 0;
222 }
223 }
224 if (i != 0) {
225 soutp(UART_TX, output);
226 while (!(sinp(UART_LSR) & UART_LSR_TEMT))
227 ;
228 }
Jarod Wilson1beef3c2010-07-26 20:31:45 -0300229}
230
Sean Young0a847632016-11-21 19:55:52 -0200231static void send_space_irdeo(void)
Sean Youngb66db532016-11-21 19:55:51 -0200232{
Sean Youngb66db532016-11-21 19:55:51 -0200233}
234
235#ifdef CONFIG_IR_SERIAL_TRANSMITTER
Sean Young0a847632016-11-21 19:55:52 -0200236static void send_pulse_homebrew_softcarrier(unsigned int length, ktime_t edge)
Jarod Wilson1beef3c2010-07-26 20:31:45 -0300237{
Sean Young0a847632016-11-21 19:55:52 -0200238 ktime_t now, target = ktime_add_us(edge, length);
239 /*
240 * delta should never exceed 4 seconds and on m68k
241 * ndelay(s64) does not compile; so use s32 rather than s64.
242 */
243 s32 delta;
Gulsah Kose5ad6ae12014-09-21 01:20:44 +0300244
Sean Young0a847632016-11-21 19:55:52 -0200245 for (;;) {
246 now = ktime_get();
247 if (ktime_compare(now, target) >= 0)
248 break;
249 on();
250 edge = ktime_add_ns(edge, serial_ir.pulse_width);
251 delta = ktime_to_ns(ktime_sub(edge, now));
252 if (delta > 0)
253 ndelay(delta);
254 now = ktime_get();
255 off();
256 if (ktime_compare(now, target) >= 0)
257 break;
258 edge = ktime_add_ns(edge, serial_ir.space_width);
259 delta = ktime_to_ns(ktime_sub(edge, now));
260 if (delta > 0)
261 ndelay(delta);
Jarod Wilson1beef3c2010-07-26 20:31:45 -0300262 }
Jarod Wilson1beef3c2010-07-26 20:31:45 -0300263}
Jarod Wilson1beef3c2010-07-26 20:31:45 -0300264
Sean Young0a847632016-11-21 19:55:52 -0200265static void send_pulse_homebrew(unsigned int length, ktime_t edge)
Jarod Wilson1beef3c2010-07-26 20:31:45 -0300266{
Jarod Wilson1beef3c2010-07-26 20:31:45 -0300267 if (softcarrier)
Sean Young0a847632016-11-21 19:55:52 -0200268 send_pulse_homebrew_softcarrier(length, edge);
269 else
270 on();
Jarod Wilson1beef3c2010-07-26 20:31:45 -0300271}
272
Sean Young0a847632016-11-21 19:55:52 -0200273static void send_space_homebrew(void)
Jarod Wilson1beef3c2010-07-26 20:31:45 -0300274{
275 off();
Jarod Wilson1beef3c2010-07-26 20:31:45 -0300276}
Sean Youngb66db532016-11-21 19:55:51 -0200277#endif
Jarod Wilson1beef3c2010-07-26 20:31:45 -0300278
Sean Youngb66db532016-11-21 19:55:51 -0200279static void frbwrite(unsigned int l, bool is_pulse)
Jarod Wilson1beef3c2010-07-26 20:31:45 -0300280{
281 /* simple noise filter */
Sean Youngb66db532016-11-21 19:55:51 -0200282 static unsigned int ptr, pulse, space;
283 DEFINE_IR_RAW_EVENT(ev);
Jarod Wilson1beef3c2010-07-26 20:31:45 -0300284
Sean Youngb66db532016-11-21 19:55:51 -0200285 if (ptr > 0 && is_pulse) {
286 pulse += l;
287 if (pulse > 250000) {
288 ev.duration = space;
289 ev.pulse = false;
290 ir_raw_event_store_with_filter(serial_ir.rcdev, &ev);
291 ev.duration = pulse;
292 ev.pulse = true;
293 ir_raw_event_store_with_filter(serial_ir.rcdev, &ev);
Jarod Wilson1beef3c2010-07-26 20:31:45 -0300294 ptr = 0;
295 pulse = 0;
296 }
297 return;
298 }
Sean Youngb66db532016-11-21 19:55:51 -0200299 if (!is_pulse) {
Jarod Wilson1beef3c2010-07-26 20:31:45 -0300300 if (ptr == 0) {
Sean Youngb66db532016-11-21 19:55:51 -0200301 if (l > 20000000) {
Jarod Wilson1beef3c2010-07-26 20:31:45 -0300302 space = l;
303 ptr++;
304 return;
305 }
306 } else {
Sean Youngb66db532016-11-21 19:55:51 -0200307 if (l > 20000000) {
Jarod Wilson1beef3c2010-07-26 20:31:45 -0300308 space += pulse;
Sean Youngb66db532016-11-21 19:55:51 -0200309 if (space > IR_MAX_DURATION)
310 space = IR_MAX_DURATION;
Jarod Wilson1beef3c2010-07-26 20:31:45 -0300311 space += l;
Sean Youngb66db532016-11-21 19:55:51 -0200312 if (space > IR_MAX_DURATION)
313 space = IR_MAX_DURATION;
Jarod Wilson1beef3c2010-07-26 20:31:45 -0300314 pulse = 0;
315 return;
316 }
Sean Youngb66db532016-11-21 19:55:51 -0200317
318 ev.duration = space;
319 ev.pulse = false;
320 ir_raw_event_store_with_filter(serial_ir.rcdev, &ev);
321 ev.duration = pulse;
322 ev.pulse = true;
323 ir_raw_event_store_with_filter(serial_ir.rcdev, &ev);
Jarod Wilson1beef3c2010-07-26 20:31:45 -0300324 ptr = 0;
325 pulse = 0;
326 }
327 }
Sean Youngb66db532016-11-21 19:55:51 -0200328
329 ev.duration = l;
330 ev.pulse = is_pulse;
331 ir_raw_event_store_with_filter(serial_ir.rcdev, &ev);
Jarod Wilson1beef3c2010-07-26 20:31:45 -0300332}
333
Sean Youngb66db532016-11-21 19:55:51 -0200334static irqreturn_t serial_ir_irq_handler(int i, void *blah)
Jarod Wilson1beef3c2010-07-26 20:31:45 -0300335{
Arnd Bergmann84595032015-11-25 13:11:55 -0200336 ktime_t kt;
Jarod Wilson1beef3c2010-07-26 20:31:45 -0300337 int counter, dcd;
338 u8 status;
Arnd Bergmann84595032015-11-25 13:11:55 -0200339 ktime_t delkt;
Sean Youngb66db532016-11-21 19:55:51 -0200340 unsigned int data;
Jarod Wilson1beef3c2010-07-26 20:31:45 -0300341 static int last_dcd = -1;
342
343 if ((sinp(UART_IIR) & UART_IIR_NO_INT)) {
344 /* not our interrupt */
345 return IRQ_NONE;
346 }
347
348 counter = 0;
349 do {
350 counter++;
351 status = sinp(UART_MSR);
352 if (counter > RS_ISR_PASS_LIMIT) {
Sean Youngb66db532016-11-21 19:55:51 -0200353 dev_err(&serial_ir.pdev->dev, "Trapped in interrupt");
Jarod Wilson1beef3c2010-07-26 20:31:45 -0300354 break;
355 }
Mauro Carvalho Chehaba6f6ad42016-11-22 05:46:14 -0200356 if ((status & hardware[type].signal_pin_change) &&
357 sense != -1) {
Jarod Wilson1beef3c2010-07-26 20:31:45 -0300358 /* get current time */
Arnd Bergmann84595032015-11-25 13:11:55 -0200359 kt = ktime_get();
Jarod Wilson1beef3c2010-07-26 20:31:45 -0300360
Jarod Wilson1beef3c2010-07-26 20:31:45 -0300361 /*
Sean Youngb66db532016-11-21 19:55:51 -0200362 * The driver needs to know if your receiver is
363 * active high or active low, or the space/pulse
364 * sense could be inverted.
Jarod Wilson1beef3c2010-07-26 20:31:45 -0300365 */
366
Sean Youngb66db532016-11-21 19:55:51 -0200367 /* calc time since last interrupt in nanoseconds */
Jarod Wilson1beef3c2010-07-26 20:31:45 -0300368 dcd = (status & hardware[type].signal_pin) ? 1 : 0;
369
370 if (dcd == last_dcd) {
Sean Youngb66db532016-11-21 19:55:51 -0200371 dev_err(&serial_ir.pdev->dev,
372 "ignoring spike: %d %d %lldns %lldns\n",
373 dcd, sense, ktime_to_ns(kt),
374 ktime_to_ns(serial_ir.lastkt));
Jarod Wilson1beef3c2010-07-26 20:31:45 -0300375 continue;
376 }
377
Sean Youngb66db532016-11-21 19:55:51 -0200378 delkt = ktime_sub(kt, serial_ir.lastkt);
Arnd Bergmann84595032015-11-25 13:11:55 -0200379 if (ktime_compare(delkt, ktime_set(15, 0)) > 0) {
Sean Youngb66db532016-11-21 19:55:51 -0200380 data = IR_MAX_DURATION; /* really long time */
Mauro Carvalho Chehaba6f6ad42016-11-22 05:46:14 -0200381 if (!(dcd ^ sense)) {
Jarod Wilson1beef3c2010-07-26 20:31:45 -0300382 /* sanity check */
Sean Youngb66db532016-11-21 19:55:51 -0200383 dev_err(&serial_ir.pdev->dev,
384 "dcd unexpected: %d %d %lldns %lldns\n",
385 dcd, sense, ktime_to_ns(kt),
386 ktime_to_ns(serial_ir.lastkt));
Jarod Wilson1beef3c2010-07-26 20:31:45 -0300387 /*
388 * detecting pulse while this
389 * MUST be a space!
390 */
391 sense = sense ? 0 : 1;
392 }
Mauro Carvalho Chehaba6f6ad42016-11-22 05:46:14 -0200393 } else {
Sean Youngb66db532016-11-21 19:55:51 -0200394 data = ktime_to_ns(delkt);
Mauro Carvalho Chehaba6f6ad42016-11-22 05:46:14 -0200395 }
Sean Youngb66db532016-11-21 19:55:51 -0200396 frbwrite(data, !(dcd ^ sense));
397 serial_ir.lastkt = kt;
Jarod Wilson1beef3c2010-07-26 20:31:45 -0300398 last_dcd = dcd;
Jarod Wilson1beef3c2010-07-26 20:31:45 -0300399 }
400 } while (!(sinp(UART_IIR) & UART_IIR_NO_INT)); /* still pending ? */
Sean Young2940c7e2016-12-02 15:16:11 -0200401
402 mod_timer(&serial_ir.timeout_timer,
403 jiffies + nsecs_to_jiffies(serial_ir.rcdev->timeout));
404
405 ir_raw_event_handle(serial_ir.rcdev);
406
Jarod Wilson1beef3c2010-07-26 20:31:45 -0300407 return IRQ_HANDLED;
408}
409
Jarod Wilson1beef3c2010-07-26 20:31:45 -0300410static int hardware_init_port(void)
411{
412 u8 scratch, scratch2, scratch3;
413
414 /*
415 * This is a simple port existence test, borrowed from the autoconfig
Mauro Carvalho Chehabc60b4082016-11-22 06:17:44 -0200416 * function in drivers/tty/serial/8250/8250_port.c
Jarod Wilson1beef3c2010-07-26 20:31:45 -0300417 */
418 scratch = sinp(UART_IER);
419 soutp(UART_IER, 0);
420#ifdef __i386__
421 outb(0xff, 0x080);
422#endif
423 scratch2 = sinp(UART_IER) & 0x0f;
424 soutp(UART_IER, 0x0f);
425#ifdef __i386__
426 outb(0x00, 0x080);
427#endif
428 scratch3 = sinp(UART_IER) & 0x0f;
429 soutp(UART_IER, scratch);
430 if (scratch2 != 0 || scratch3 != 0x0f) {
431 /* we fail, there's nothing here */
YAMANE Toshiakidf4f07b2012-11-08 15:55:09 -0300432 pr_err("port existence test failed, cannot continue\n");
Ben Hutchings9b98d602011-11-16 01:53:35 -0300433 return -ENODEV;
Jarod Wilson1beef3c2010-07-26 20:31:45 -0300434 }
435
Jarod Wilson1beef3c2010-07-26 20:31:45 -0300436 /* Set DLAB 0. */
437 soutp(UART_LCR, sinp(UART_LCR) & (~UART_LCR_DLAB));
438
439 /* First of all, disable all interrupts */
440 soutp(UART_IER, sinp(UART_IER) &
Mauro Carvalho Chehaba6f6ad42016-11-22 05:46:14 -0200441 (~(UART_IER_MSI | UART_IER_RLSI | UART_IER_THRI | UART_IER_RDI)));
Jarod Wilson1beef3c2010-07-26 20:31:45 -0300442
443 /* Clear registers. */
444 sinp(UART_LSR);
445 sinp(UART_RX);
446 sinp(UART_IIR);
447 sinp(UART_MSR);
448
Jarod Wilson1beef3c2010-07-26 20:31:45 -0300449 /* Set line for power source */
450 off();
451
452 /* Clear registers again to be sure. */
453 sinp(UART_LSR);
454 sinp(UART_RX);
455 sinp(UART_IIR);
456 sinp(UART_MSR);
457
458 switch (type) {
Sean Youngb66db532016-11-21 19:55:51 -0200459 case IR_IRDEO:
460 case IR_IRDEO_REMOTE:
Jarod Wilson1beef3c2010-07-26 20:31:45 -0300461 /* setup port to 7N1 @ 115200 Baud */
462 /* 7N1+start = 9 bits at 115200 ~ 3 bits at 38kHz */
463
464 /* Set DLAB 1. */
465 soutp(UART_LCR, sinp(UART_LCR) | UART_LCR_DLAB);
466 /* Set divisor to 1 => 115200 Baud */
467 soutp(UART_DLM, 0);
468 soutp(UART_DLL, 1);
469 /* Set DLAB 0 + 7N1 */
470 soutp(UART_LCR, UART_LCR_WLEN7);
471 /* THR interrupt already disabled at this point */
472 break;
473 default:
474 break;
475 }
476
477 return 0;
478}
479
Sean Young2940c7e2016-12-02 15:16:11 -0200480static void serial_ir_timeout(unsigned long arg)
481{
482 DEFINE_IR_RAW_EVENT(ev);
483
484 ev.timeout = true;
485 ev.duration = serial_ir.rcdev->timeout;
486 ir_raw_event_store_with_filter(serial_ir.rcdev, &ev);
487 ir_raw_event_handle(serial_ir.rcdev);
488}
489
Sean Youngb66db532016-11-21 19:55:51 -0200490static int serial_ir_probe(struct platform_device *dev)
Jarod Wilson1beef3c2010-07-26 20:31:45 -0300491{
Jarod Wilsonc4b0afe2011-06-13 15:32:26 -0300492 int i, nlow, nhigh, result;
493
Sean Youngb66db532016-11-21 19:55:51 -0200494 result = devm_request_irq(&dev->dev, irq, serial_ir_irq_handler,
495 share_irq ? IRQF_SHARED : 0,
496 KBUILD_MODNAME, &hardware);
Ben Hutchingsaffc9a02011-11-16 01:54:04 -0300497 if (result < 0) {
498 if (result == -EBUSY)
YAMANE Toshiakidf4f07b2012-11-08 15:55:09 -0300499 dev_err(&dev->dev, "IRQ %d busy\n", irq);
Ben Hutchingsaffc9a02011-11-16 01:54:04 -0300500 else if (result == -EINVAL)
YAMANE Toshiakidf4f07b2012-11-08 15:55:09 -0300501 dev_err(&dev->dev, "Bad irq number or handler\n");
Ben Hutchingsaffc9a02011-11-16 01:54:04 -0300502 return result;
503 }
Jarod Wilson1beef3c2010-07-26 20:31:45 -0300504
505 /* Reserve io region. */
Mauro Carvalho Chehaba6f6ad42016-11-22 05:46:14 -0200506 if ((iommap &&
507 (devm_request_mem_region(&dev->dev, iommap, 8 << ioshift,
508 KBUILD_MODNAME) == NULL)) ||
509 (!iommap && (devm_request_region(&dev->dev, io, 8,
510 KBUILD_MODNAME) == NULL))) {
YAMANE Toshiakidf4f07b2012-11-08 15:55:09 -0300511 dev_err(&dev->dev, "port %04x already in use\n", io);
512 dev_warn(&dev->dev, "use 'setserial /dev/ttySX uart none'\n");
513 dev_warn(&dev->dev,
514 "or compile the serial port driver as module and\n");
515 dev_warn(&dev->dev, "make sure this module is loaded first\n");
Himangi Saraogi56a65a12014-07-03 16:38:40 -0300516 return -EBUSY;
Jarod Wilson1beef3c2010-07-26 20:31:45 -0300517 }
518
Sean Young2940c7e2016-12-02 15:16:11 -0200519 setup_timer(&serial_ir.timeout_timer, serial_ir_timeout,
520 (unsigned long)&serial_ir);
521
Ben Hutchings9b98d602011-11-16 01:53:35 -0300522 result = hardware_init_port();
523 if (result < 0)
Himangi Saraogi56a65a12014-07-03 16:38:40 -0300524 return result;
Jarod Wilson1beef3c2010-07-26 20:31:45 -0300525
526 /* Initialize pulse/space widths */
Sean Youngb66db532016-11-21 19:55:51 -0200527 init_timing_params(50, 38000);
Jarod Wilson1beef3c2010-07-26 20:31:45 -0300528
529 /* If pin is high, then this must be an active low receiver. */
530 if (sense == -1) {
531 /* wait 1/2 sec for the power supply */
532 msleep(500);
533
534 /*
535 * probe 9 times every 0.04s, collect "votes" for
536 * active high/low
537 */
538 nlow = 0;
539 nhigh = 0;
540 for (i = 0; i < 9; i++) {
541 if (sinp(UART_MSR) & hardware[type].signal_pin)
542 nlow++;
543 else
544 nhigh++;
545 msleep(40);
546 }
Haneen Mohammed8126e172015-03-13 20:46:57 +0300547 sense = nlow >= nhigh ? 1 : 0;
YAMANE Toshiakidf4f07b2012-11-08 15:55:09 -0300548 dev_info(&dev->dev, "auto-detected active %s receiver\n",
549 sense ? "low" : "high");
Jarod Wilson1beef3c2010-07-26 20:31:45 -0300550 } else
YAMANE Toshiakidf4f07b2012-11-08 15:55:09 -0300551 dev_info(&dev->dev, "Manually using active %s receiver\n",
552 sense ? "low" : "high");
Jarod Wilson1beef3c2010-07-26 20:31:45 -0300553
Maciek Borzecki4b4c7a12015-09-04 17:04:05 -0300554 dev_dbg(&dev->dev, "Interrupt %d, port %04x obtained\n", irq, io);
Jarod Wilson1beef3c2010-07-26 20:31:45 -0300555 return 0;
556}
557
Sean Youngb66db532016-11-21 19:55:51 -0200558static int serial_ir_open(struct rc_dev *rcdev)
Jarod Wilson1beef3c2010-07-26 20:31:45 -0300559{
Jarod Wilson1beef3c2010-07-26 20:31:45 -0300560 unsigned long flags;
561
562 /* initialize timestamp */
Sean Youngb66db532016-11-21 19:55:51 -0200563 serial_ir.lastkt = ktime_get();
Jarod Wilson1beef3c2010-07-26 20:31:45 -0300564
Jarod Wilson1beef3c2010-07-26 20:31:45 -0300565 spin_lock_irqsave(&hardware[type].lock, flags);
566
567 /* Set DLAB 0. */
568 soutp(UART_LCR, sinp(UART_LCR) & (~UART_LCR_DLAB));
569
Mauro Carvalho Chehaba6f6ad42016-11-22 05:46:14 -0200570 soutp(UART_IER, sinp(UART_IER) | UART_IER_MSI);
Jarod Wilson1beef3c2010-07-26 20:31:45 -0300571
572 spin_unlock_irqrestore(&hardware[type].lock, flags);
573
574 return 0;
575}
576
Sean Youngb66db532016-11-21 19:55:51 -0200577static void serial_ir_close(struct rc_dev *rcdev)
578{
579 unsigned long flags;
Jarod Wilson1beef3c2010-07-26 20:31:45 -0300580
581 spin_lock_irqsave(&hardware[type].lock, flags);
582
583 /* Set DLAB 0. */
584 soutp(UART_LCR, sinp(UART_LCR) & (~UART_LCR_DLAB));
585
586 /* First of all, disable all interrupts */
587 soutp(UART_IER, sinp(UART_IER) &
Mauro Carvalho Chehaba6f6ad42016-11-22 05:46:14 -0200588 (~(UART_IER_MSI | UART_IER_RLSI | UART_IER_THRI | UART_IER_RDI)));
Jarod Wilson1beef3c2010-07-26 20:31:45 -0300589 spin_unlock_irqrestore(&hardware[type].lock, flags);
Jarod Wilson1beef3c2010-07-26 20:31:45 -0300590}
591
Sean Youngb66db532016-11-21 19:55:51 -0200592static int serial_ir_tx(struct rc_dev *dev, unsigned int *txbuf,
593 unsigned int count)
Jarod Wilson1beef3c2010-07-26 20:31:45 -0300594{
Jarod Wilson1beef3c2010-07-26 20:31:45 -0300595 unsigned long flags;
Sean Young0a847632016-11-21 19:55:52 -0200596 ktime_t edge;
597 s64 delta;
Sean Youngb66db532016-11-21 19:55:51 -0200598 int i;
Jarod Wilson1beef3c2010-07-26 20:31:45 -0300599
Jarod Wilson1beef3c2010-07-26 20:31:45 -0300600 spin_lock_irqsave(&hardware[type].lock, flags);
Sean Youngb66db532016-11-21 19:55:51 -0200601 if (type == IR_IRDEO) {
Jarod Wilson1beef3c2010-07-26 20:31:45 -0300602 /* DTR, RTS down */
603 on();
604 }
Sean Young0a847632016-11-21 19:55:52 -0200605
606 edge = ktime_get();
Jarod Wilson1beef3c2010-07-26 20:31:45 -0300607 for (i = 0; i < count; i++) {
Mauro Carvalho Chehaba6f6ad42016-11-22 05:46:14 -0200608 if (i % 2)
Sean Young0a847632016-11-21 19:55:52 -0200609 hardware[type].send_space();
Jarod Wilson1beef3c2010-07-26 20:31:45 -0300610 else
Sean Young0a847632016-11-21 19:55:52 -0200611 hardware[type].send_pulse(txbuf[i], edge);
612
613 edge = ktime_add_us(edge, txbuf[i]);
614 delta = ktime_us_delta(edge, ktime_get());
615 if (delta > 25) {
616 spin_unlock_irqrestore(&hardware[type].lock, flags);
617 usleep_range(delta - 25, delta + 25);
618 spin_lock_irqsave(&hardware[type].lock, flags);
Mauro Carvalho Chehaba6f6ad42016-11-22 05:46:14 -0200619 } else if (delta > 0) {
Sean Young0a847632016-11-21 19:55:52 -0200620 udelay(delta);
Mauro Carvalho Chehaba6f6ad42016-11-22 05:46:14 -0200621 }
Jarod Wilson1beef3c2010-07-26 20:31:45 -0300622 }
623 off();
624 spin_unlock_irqrestore(&hardware[type].lock, flags);
Sean Youngb66db532016-11-21 19:55:51 -0200625 return count;
Jarod Wilson1beef3c2010-07-26 20:31:45 -0300626}
627
Sean Youngb66db532016-11-21 19:55:51 -0200628static int serial_ir_tx_duty_cycle(struct rc_dev *dev, u32 cycle)
Jarod Wilson1beef3c2010-07-26 20:31:45 -0300629{
Sean Young0a847632016-11-21 19:55:52 -0200630 init_timing_params(cycle, serial_ir.freq);
631 return 0;
Jarod Wilson1beef3c2010-07-26 20:31:45 -0300632}
633
Sean Youngb66db532016-11-21 19:55:51 -0200634static int serial_ir_tx_carrier(struct rc_dev *dev, u32 carrier)
635{
636 if (carrier > 500000 || carrier < 20000)
637 return -EINVAL;
Jarod Wilson1beef3c2010-07-26 20:31:45 -0300638
Sean Young0a847632016-11-21 19:55:52 -0200639 init_timing_params(serial_ir.duty_cycle, carrier);
640 return 0;
Sean Youngb66db532016-11-21 19:55:51 -0200641}
Jarod Wilson1beef3c2010-07-26 20:31:45 -0300642
Sean Youngb66db532016-11-21 19:55:51 -0200643static int serial_ir_suspend(struct platform_device *dev,
644 pm_message_t state)
Jarod Wilson1beef3c2010-07-26 20:31:45 -0300645{
646 /* Set DLAB 0. */
647 soutp(UART_LCR, sinp(UART_LCR) & (~UART_LCR_DLAB));
648
649 /* Disable all interrupts */
650 soutp(UART_IER, sinp(UART_IER) &
Mauro Carvalho Chehaba6f6ad42016-11-22 05:46:14 -0200651 (~(UART_IER_MSI | UART_IER_RLSI | UART_IER_THRI | UART_IER_RDI)));
Jarod Wilson1beef3c2010-07-26 20:31:45 -0300652
653 /* Clear registers. */
654 sinp(UART_LSR);
655 sinp(UART_RX);
656 sinp(UART_IIR);
657 sinp(UART_MSR);
658
659 return 0;
660}
661
Sean Youngb66db532016-11-21 19:55:51 -0200662static int serial_ir_resume(struct platform_device *dev)
Jarod Wilson1beef3c2010-07-26 20:31:45 -0300663{
664 unsigned long flags;
Ben Hutchings9b98d602011-11-16 01:53:35 -0300665 int result;
Jarod Wilson1beef3c2010-07-26 20:31:45 -0300666
Ben Hutchings9b98d602011-11-16 01:53:35 -0300667 result = hardware_init_port();
668 if (result < 0)
669 return result;
Jarod Wilson1beef3c2010-07-26 20:31:45 -0300670
671 spin_lock_irqsave(&hardware[type].lock, flags);
672 /* Enable Interrupt */
Sean Youngb66db532016-11-21 19:55:51 -0200673 serial_ir.lastkt = ktime_get();
Mauro Carvalho Chehaba6f6ad42016-11-22 05:46:14 -0200674 soutp(UART_IER, sinp(UART_IER) | UART_IER_MSI);
Jarod Wilson1beef3c2010-07-26 20:31:45 -0300675 off();
676
Jarod Wilson1beef3c2010-07-26 20:31:45 -0300677 spin_unlock_irqrestore(&hardware[type].lock, flags);
678
679 return 0;
680}
681
Sean Youngb66db532016-11-21 19:55:51 -0200682static struct platform_driver serial_ir_driver = {
683 .probe = serial_ir_probe,
684 .suspend = serial_ir_suspend,
685 .resume = serial_ir_resume,
Jarod Wilson1beef3c2010-07-26 20:31:45 -0300686 .driver = {
Sean Youngb66db532016-11-21 19:55:51 -0200687 .name = "serial_ir",
Jarod Wilson1beef3c2010-07-26 20:31:45 -0300688 },
689};
690
Sean Youngb66db532016-11-21 19:55:51 -0200691static int __init serial_ir_init(void)
Jarod Wilson1beef3c2010-07-26 20:31:45 -0300692{
693 int result;
694
Sean Youngb66db532016-11-21 19:55:51 -0200695 result = platform_driver_register(&serial_ir_driver);
696 if (result)
Ben Hutchings9b98d602011-11-16 01:53:35 -0300697 return result;
Jarod Wilson1beef3c2010-07-26 20:31:45 -0300698
Sean Youngb66db532016-11-21 19:55:51 -0200699 serial_ir.pdev = platform_device_alloc("serial_ir", 0);
700 if (!serial_ir.pdev) {
Jarod Wilson1beef3c2010-07-26 20:31:45 -0300701 result = -ENOMEM;
702 goto exit_driver_unregister;
703 }
704
Sean Youngb66db532016-11-21 19:55:51 -0200705 result = platform_device_add(serial_ir.pdev);
Jarod Wilson1beef3c2010-07-26 20:31:45 -0300706 if (result)
707 goto exit_device_put;
708
709 return 0;
710
711exit_device_put:
Sean Youngb66db532016-11-21 19:55:51 -0200712 platform_device_put(serial_ir.pdev);
Jarod Wilson1beef3c2010-07-26 20:31:45 -0300713exit_driver_unregister:
Sean Youngb66db532016-11-21 19:55:51 -0200714 platform_driver_unregister(&serial_ir_driver);
Jarod Wilson1beef3c2010-07-26 20:31:45 -0300715 return result;
716}
717
Sean Youngb66db532016-11-21 19:55:51 -0200718static void serial_ir_exit(void)
Jarod Wilson1beef3c2010-07-26 20:31:45 -0300719{
Sean Youngb66db532016-11-21 19:55:51 -0200720 platform_device_unregister(serial_ir.pdev);
721 platform_driver_unregister(&serial_ir_driver);
Jarod Wilson1beef3c2010-07-26 20:31:45 -0300722}
723
Sean Youngb66db532016-11-21 19:55:51 -0200724static int __init serial_ir_init_module(void)
Jarod Wilson1beef3c2010-07-26 20:31:45 -0300725{
Sean Youngb66db532016-11-21 19:55:51 -0200726 struct rc_dev *rcdev;
Jarod Wilson1beef3c2010-07-26 20:31:45 -0300727 int result;
728
Jarod Wilson1beef3c2010-07-26 20:31:45 -0300729 switch (type) {
Sean Youngb66db532016-11-21 19:55:51 -0200730 case IR_HOMEBREW:
731 case IR_IRDEO:
732 case IR_IRDEO_REMOTE:
733 case IR_ANIMAX:
734 case IR_IGOR:
Jarod Wilson1beef3c2010-07-26 20:31:45 -0300735 /* if nothing specified, use ttyS0/com1 and irq 4 */
736 io = io ? io : 0x3f8;
737 irq = irq ? irq : 4;
738 break;
Jarod Wilson1beef3c2010-07-26 20:31:45 -0300739 default:
Ben Hutchings9105b8b2011-11-16 01:49:41 -0300740 return -EINVAL;
Jarod Wilson1beef3c2010-07-26 20:31:45 -0300741 }
742 if (!softcarrier) {
743 switch (type) {
Sean Youngb66db532016-11-21 19:55:51 -0200744 case IR_HOMEBREW:
745 case IR_IGOR:
746 hardware[type].set_send_carrier = false;
747 hardware[type].set_duty_cycle = false;
Jarod Wilson1beef3c2010-07-26 20:31:45 -0300748 break;
749 }
750 }
751
Paul Bolle895507c2012-10-14 15:50:11 -0300752 /* make sure sense is either -1, 0, or 1 */
753 if (sense != -1)
754 sense = !!sense;
755
Sean Youngb66db532016-11-21 19:55:51 -0200756 result = serial_ir_init();
Ben Hutchings9105b8b2011-11-16 01:49:41 -0300757 if (result)
758 return result;
759
Andi Shyti0f7499f2016-12-16 06:50:58 -0200760 rcdev = devm_rc_allocate_device(&serial_ir.pdev->dev, RC_DRIVER_IR_RAW);
Sean Youngb66db532016-11-21 19:55:51 -0200761 if (!rcdev) {
762 result = -ENOMEM;
763 goto serial_cleanup;
Jarod Wilson1beef3c2010-07-26 20:31:45 -0300764 }
Sean Youngb66db532016-11-21 19:55:51 -0200765
766 if (hardware[type].send_pulse && hardware[type].send_space)
767 rcdev->tx_ir = serial_ir_tx;
768 if (hardware[type].set_send_carrier)
769 rcdev->s_tx_carrier = serial_ir_tx_carrier;
770 if (hardware[type].set_duty_cycle)
771 rcdev->s_tx_duty_cycle = serial_ir_tx_duty_cycle;
772
773 switch (type) {
774 case IR_HOMEBREW:
775 rcdev->input_name = "Serial IR type home-brew";
776 break;
777 case IR_IRDEO:
778 rcdev->input_name = "Serial IR type IRdeo";
779 break;
780 case IR_IRDEO_REMOTE:
781 rcdev->input_name = "Serial IR type IRdeo remote";
782 break;
783 case IR_ANIMAX:
784 rcdev->input_name = "Serial IR type AnimaX";
785 break;
786 case IR_IGOR:
787 rcdev->input_name = "Serial IR type IgorPlug";
788 break;
789 }
790
791 rcdev->input_phys = KBUILD_MODNAME "/input0";
792 rcdev->input_id.bustype = BUS_HOST;
793 rcdev->input_id.vendor = 0x0001;
794 rcdev->input_id.product = 0x0001;
795 rcdev->input_id.version = 0x0100;
796 rcdev->open = serial_ir_open;
797 rcdev->close = serial_ir_close;
798 rcdev->dev.parent = &serial_ir.pdev->dev;
Sean Young8c34b5c2016-12-03 08:55:56 -0200799 rcdev->allowed_protocols = RC_BIT_ALL_IR_DECODER;
Sean Youngb66db532016-11-21 19:55:51 -0200800 rcdev->driver_name = KBUILD_MODNAME;
801 rcdev->map_name = RC_MAP_RC6_MCE;
Sean Young2940c7e2016-12-02 15:16:11 -0200802 rcdev->min_timeout = 1;
Sean Youngb66db532016-11-21 19:55:51 -0200803 rcdev->timeout = IR_DEFAULT_TIMEOUT;
Sean Young2940c7e2016-12-02 15:16:11 -0200804 rcdev->max_timeout = 10 * IR_DEFAULT_TIMEOUT;
Sean Youngb66db532016-11-21 19:55:51 -0200805 rcdev->rx_resolution = 250000;
806
807 serial_ir.rcdev = rcdev;
808
809 result = rc_register_device(rcdev);
810
811 if (!result)
812 return 0;
813serial_cleanup:
814 serial_ir_exit();
815 return result;
Jarod Wilson1beef3c2010-07-26 20:31:45 -0300816}
817
Sean Youngb66db532016-11-21 19:55:51 -0200818static void __exit serial_ir_exit_module(void)
Jarod Wilson1beef3c2010-07-26 20:31:45 -0300819{
Sean Young2940c7e2016-12-02 15:16:11 -0200820 del_timer_sync(&serial_ir.timeout_timer);
Sean Youngb66db532016-11-21 19:55:51 -0200821 rc_unregister_device(serial_ir.rcdev);
822 serial_ir_exit();
Jarod Wilson1beef3c2010-07-26 20:31:45 -0300823}
824
Sean Youngb66db532016-11-21 19:55:51 -0200825module_init(serial_ir_init_module);
826module_exit(serial_ir_exit_module);
Jarod Wilson1beef3c2010-07-26 20:31:45 -0300827
828MODULE_DESCRIPTION("Infra-red receiver driver for serial ports.");
Sean Youngb66db532016-11-21 19:55:51 -0200829MODULE_AUTHOR("Ralph Metzler, Trent Piepho, Ben Pfaff, Christoph Bartelmus, Andrei Tanas");
Jarod Wilson1beef3c2010-07-26 20:31:45 -0300830MODULE_LICENSE("GPL");
831
Sean Youngb66db532016-11-21 19:55:51 -0200832module_param(type, int, 0444);
833MODULE_PARM_DESC(type, "Hardware type (0 = home-brew, 1 = IRdeo, 2 = IRdeo Remote, 3 = AnimaX, 4 = IgorPlug");
Jarod Wilson1beef3c2010-07-26 20:31:45 -0300834
Sean Youngb66db532016-11-21 19:55:51 -0200835module_param(io, int, 0444);
Jarod Wilson1beef3c2010-07-26 20:31:45 -0300836MODULE_PARM_DESC(io, "I/O address base (0x3f8 or 0x2f8)");
837
838/* some architectures (e.g. intel xscale) have memory mapped registers */
Sean Young069f3b12017-02-13 20:53:23 -0200839module_param(iommap, ulong, 0444);
Sean Youngb66db532016-11-21 19:55:51 -0200840MODULE_PARM_DESC(iommap, "physical base for memory mapped I/O (0 = no memory mapped io)");
Jarod Wilson1beef3c2010-07-26 20:31:45 -0300841
842/*
843 * some architectures (e.g. intel xscale) align the 8bit serial registers
844 * on 32bit word boundaries.
Justin P. Mattockb47acf22012-03-05 11:49:26 -0300845 * See linux-kernel/drivers/tty/serial/8250/8250.c serial_in()/out()
Jarod Wilson1beef3c2010-07-26 20:31:45 -0300846 */
Sean Youngb66db532016-11-21 19:55:51 -0200847module_param(ioshift, int, 0444);
Jarod Wilson1beef3c2010-07-26 20:31:45 -0300848MODULE_PARM_DESC(ioshift, "shift I/O register offset (0 = no shift)");
849
Sean Youngb66db532016-11-21 19:55:51 -0200850module_param(irq, int, 0444);
Jarod Wilson1beef3c2010-07-26 20:31:45 -0300851MODULE_PARM_DESC(irq, "Interrupt (4 or 3)");
852
Sean Youngb66db532016-11-21 19:55:51 -0200853module_param(share_irq, bool, 0444);
Jarod Wilson1beef3c2010-07-26 20:31:45 -0300854MODULE_PARM_DESC(share_irq, "Share interrupts (0 = off, 1 = on)");
855
Sean Youngb66db532016-11-21 19:55:51 -0200856module_param(sense, int, 0444);
857MODULE_PARM_DESC(sense, "Override autodetection of IR receiver circuit (0 = active high, 1 = active low )");
Jarod Wilson1beef3c2010-07-26 20:31:45 -0300858
Sean Youngb66db532016-11-21 19:55:51 -0200859#ifdef CONFIG_IR_SERIAL_TRANSMITTER
860module_param(txsense, bool, 0444);
861MODULE_PARM_DESC(txsense, "Sense of transmitter circuit (0 = active high, 1 = active low )");
Jarod Wilson1beef3c2010-07-26 20:31:45 -0300862#endif
863
Sean Youngb66db532016-11-21 19:55:51 -0200864module_param(softcarrier, bool, 0444);
Jarod Wilson1beef3c2010-07-26 20:31:45 -0300865MODULE_PARM_DESC(softcarrier, "Software carrier (0 = off, 1 = on, default on)");