sh_eth: fix EESIPR values for SH77{34|63}
[linux/fpc-iii.git] / drivers / media / rc / fintek-cir.c
blobecab69ea3d5157d3ef6bce57a742fa7d01d81073
1 /*
2 * Driver for Feature Integration Technology Inc. (aka Fintek) LPC CIR
4 * Copyright (C) 2011 Jarod Wilson <jarod@redhat.com>
6 * Special thanks to Fintek for providing hardware and spec sheets.
7 * This driver is based upon the nuvoton, ite and ene drivers for
8 * similar hardware.
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License as
12 * published by the Free Software Foundation; either version 2 of the
13 * License, or (at your option) any later version.
15 * This program is distributed in the hope that it will be useful, but
16 * WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
23 * USA
26 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
28 #include <linux/kernel.h>
29 #include <linux/module.h>
30 #include <linux/pnp.h>
31 #include <linux/io.h>
32 #include <linux/interrupt.h>
33 #include <linux/sched.h>
34 #include <linux/slab.h>
35 #include <media/rc-core.h>
37 #include "fintek-cir.h"
39 /* write val to config reg */
40 static inline void fintek_cr_write(struct fintek_dev *fintek, u8 val, u8 reg)
42 fit_dbg("%s: reg 0x%02x, val 0x%02x (ip/dp: %02x/%02x)",
43 __func__, reg, val, fintek->cr_ip, fintek->cr_dp);
44 outb(reg, fintek->cr_ip);
45 outb(val, fintek->cr_dp);
48 /* read val from config reg */
49 static inline u8 fintek_cr_read(struct fintek_dev *fintek, u8 reg)
51 u8 val;
53 outb(reg, fintek->cr_ip);
54 val = inb(fintek->cr_dp);
56 fit_dbg("%s: reg 0x%02x, val 0x%02x (ip/dp: %02x/%02x)",
57 __func__, reg, val, fintek->cr_ip, fintek->cr_dp);
58 return val;
61 /* update config register bit without changing other bits */
62 static inline void fintek_set_reg_bit(struct fintek_dev *fintek, u8 val, u8 reg)
64 u8 tmp = fintek_cr_read(fintek, reg) | val;
65 fintek_cr_write(fintek, tmp, reg);
68 /* clear config register bit without changing other bits */
69 static inline void fintek_clear_reg_bit(struct fintek_dev *fintek, u8 val, u8 reg)
71 u8 tmp = fintek_cr_read(fintek, reg) & ~val;
72 fintek_cr_write(fintek, tmp, reg);
75 /* enter config mode */
76 static inline void fintek_config_mode_enable(struct fintek_dev *fintek)
78 /* Enabling Config Mode explicitly requires writing 2x */
79 outb(CONFIG_REG_ENABLE, fintek->cr_ip);
80 outb(CONFIG_REG_ENABLE, fintek->cr_ip);
83 /* exit config mode */
84 static inline void fintek_config_mode_disable(struct fintek_dev *fintek)
86 outb(CONFIG_REG_DISABLE, fintek->cr_ip);
90 * When you want to address a specific logical device, write its logical
91 * device number to GCR_LOGICAL_DEV_NO
93 static inline void fintek_select_logical_dev(struct fintek_dev *fintek, u8 ldev)
95 fintek_cr_write(fintek, ldev, GCR_LOGICAL_DEV_NO);
98 /* write val to cir config register */
99 static inline void fintek_cir_reg_write(struct fintek_dev *fintek, u8 val, u8 offset)
101 outb(val, fintek->cir_addr + offset);
104 /* read val from cir config register */
105 static u8 fintek_cir_reg_read(struct fintek_dev *fintek, u8 offset)
107 return inb(fintek->cir_addr + offset);
110 /* dump current cir register contents */
111 static void cir_dump_regs(struct fintek_dev *fintek)
113 fintek_config_mode_enable(fintek);
114 fintek_select_logical_dev(fintek, fintek->logical_dev_cir);
116 pr_info("%s: Dump CIR logical device registers:\n", FINTEK_DRIVER_NAME);
117 pr_info(" * CR CIR BASE ADDR: 0x%x\n",
118 (fintek_cr_read(fintek, CIR_CR_BASE_ADDR_HI) << 8) |
119 fintek_cr_read(fintek, CIR_CR_BASE_ADDR_LO));
120 pr_info(" * CR CIR IRQ NUM: 0x%x\n",
121 fintek_cr_read(fintek, CIR_CR_IRQ_SEL));
123 fintek_config_mode_disable(fintek);
125 pr_info("%s: Dump CIR registers:\n", FINTEK_DRIVER_NAME);
126 pr_info(" * STATUS: 0x%x\n",
127 fintek_cir_reg_read(fintek, CIR_STATUS));
128 pr_info(" * CONTROL: 0x%x\n",
129 fintek_cir_reg_read(fintek, CIR_CONTROL));
130 pr_info(" * RX_DATA: 0x%x\n",
131 fintek_cir_reg_read(fintek, CIR_RX_DATA));
132 pr_info(" * TX_CONTROL: 0x%x\n",
133 fintek_cir_reg_read(fintek, CIR_TX_CONTROL));
134 pr_info(" * TX_DATA: 0x%x\n",
135 fintek_cir_reg_read(fintek, CIR_TX_DATA));
138 /* detect hardware features */
139 static int fintek_hw_detect(struct fintek_dev *fintek)
141 unsigned long flags;
142 u8 chip_major, chip_minor;
143 u8 vendor_major, vendor_minor;
144 u8 portsel, ir_class;
145 u16 vendor, chip;
147 fintek_config_mode_enable(fintek);
149 /* Check if we're using config port 0x4e or 0x2e */
150 portsel = fintek_cr_read(fintek, GCR_CONFIG_PORT_SEL);
151 if (portsel == 0xff) {
152 fit_pr(KERN_INFO, "first portsel read was bunk, trying alt");
153 fintek_config_mode_disable(fintek);
154 fintek->cr_ip = CR_INDEX_PORT2;
155 fintek->cr_dp = CR_DATA_PORT2;
156 fintek_config_mode_enable(fintek);
157 portsel = fintek_cr_read(fintek, GCR_CONFIG_PORT_SEL);
159 fit_dbg("portsel reg: 0x%02x", portsel);
161 ir_class = fintek_cir_reg_read(fintek, CIR_CR_CLASS);
162 fit_dbg("ir_class reg: 0x%02x", ir_class);
164 switch (ir_class) {
165 case CLASS_RX_2TX:
166 case CLASS_RX_1TX:
167 fintek->hw_tx_capable = true;
168 break;
169 case CLASS_RX_ONLY:
170 default:
171 fintek->hw_tx_capable = false;
172 break;
175 chip_major = fintek_cr_read(fintek, GCR_CHIP_ID_HI);
176 chip_minor = fintek_cr_read(fintek, GCR_CHIP_ID_LO);
177 chip = chip_major << 8 | chip_minor;
179 vendor_major = fintek_cr_read(fintek, GCR_VENDOR_ID_HI);
180 vendor_minor = fintek_cr_read(fintek, GCR_VENDOR_ID_LO);
181 vendor = vendor_major << 8 | vendor_minor;
183 if (vendor != VENDOR_ID_FINTEK)
184 fit_pr(KERN_WARNING, "Unknown vendor ID: 0x%04x", vendor);
185 else
186 fit_dbg("Read Fintek vendor ID from chip");
188 fintek_config_mode_disable(fintek);
190 spin_lock_irqsave(&fintek->fintek_lock, flags);
191 fintek->chip_major = chip_major;
192 fintek->chip_minor = chip_minor;
193 fintek->chip_vendor = vendor;
196 * Newer reviews of this chipset uses port 8 instead of 5
198 if ((chip != 0x0408) && (chip != 0x0804))
199 fintek->logical_dev_cir = LOGICAL_DEV_CIR_REV2;
200 else
201 fintek->logical_dev_cir = LOGICAL_DEV_CIR_REV1;
203 spin_unlock_irqrestore(&fintek->fintek_lock, flags);
205 return 0;
208 static void fintek_cir_ldev_init(struct fintek_dev *fintek)
210 /* Select CIR logical device and enable */
211 fintek_select_logical_dev(fintek, fintek->logical_dev_cir);
212 fintek_cr_write(fintek, LOGICAL_DEV_ENABLE, CIR_CR_DEV_EN);
214 /* Write allocated CIR address and IRQ information to hardware */
215 fintek_cr_write(fintek, fintek->cir_addr >> 8, CIR_CR_BASE_ADDR_HI);
216 fintek_cr_write(fintek, fintek->cir_addr & 0xff, CIR_CR_BASE_ADDR_LO);
218 fintek_cr_write(fintek, fintek->cir_irq, CIR_CR_IRQ_SEL);
220 fit_dbg("CIR initialized, base io address: 0x%lx, irq: %d (len: %d)",
221 fintek->cir_addr, fintek->cir_irq, fintek->cir_port_len);
224 /* enable CIR interrupts */
225 static void fintek_enable_cir_irq(struct fintek_dev *fintek)
227 fintek_cir_reg_write(fintek, CIR_STATUS_IRQ_EN, CIR_STATUS);
230 static void fintek_cir_regs_init(struct fintek_dev *fintek)
232 /* clear any and all stray interrupts */
233 fintek_cir_reg_write(fintek, CIR_STATUS_IRQ_MASK, CIR_STATUS);
235 /* and finally, enable interrupts */
236 fintek_enable_cir_irq(fintek);
239 static void fintek_enable_wake(struct fintek_dev *fintek)
241 fintek_config_mode_enable(fintek);
242 fintek_select_logical_dev(fintek, LOGICAL_DEV_ACPI);
244 /* Allow CIR PME's to wake system */
245 fintek_set_reg_bit(fintek, ACPI_WAKE_EN_CIR_BIT, LDEV_ACPI_WAKE_EN_REG);
246 /* Enable CIR PME's */
247 fintek_set_reg_bit(fintek, ACPI_PME_CIR_BIT, LDEV_ACPI_PME_EN_REG);
248 /* Clear CIR PME status register */
249 fintek_set_reg_bit(fintek, ACPI_PME_CIR_BIT, LDEV_ACPI_PME_CLR_REG);
250 /* Save state */
251 fintek_set_reg_bit(fintek, ACPI_STATE_CIR_BIT, LDEV_ACPI_STATE_REG);
253 fintek_config_mode_disable(fintek);
256 static int fintek_cmdsize(u8 cmd, u8 subcmd)
258 int datasize = 0;
260 switch (cmd) {
261 case BUF_COMMAND_NULL:
262 if (subcmd == BUF_HW_CMD_HEADER)
263 datasize = 1;
264 break;
265 case BUF_HW_CMD_HEADER:
266 if (subcmd == BUF_CMD_G_REVISION)
267 datasize = 2;
268 break;
269 case BUF_COMMAND_HEADER:
270 switch (subcmd) {
271 case BUF_CMD_S_CARRIER:
272 case BUF_CMD_S_TIMEOUT:
273 case BUF_RSP_PULSE_COUNT:
274 datasize = 2;
275 break;
276 case BUF_CMD_SIG_END:
277 case BUF_CMD_S_TXMASK:
278 case BUF_CMD_S_RXSENSOR:
279 datasize = 1;
280 break;
284 return datasize;
287 /* process ir data stored in driver buffer */
288 static void fintek_process_rx_ir_data(struct fintek_dev *fintek)
290 DEFINE_IR_RAW_EVENT(rawir);
291 u8 sample;
292 bool event = false;
293 int i;
295 for (i = 0; i < fintek->pkts; i++) {
296 sample = fintek->buf[i];
297 switch (fintek->parser_state) {
298 case CMD_HEADER:
299 fintek->cmd = sample;
300 if ((fintek->cmd == BUF_COMMAND_HEADER) ||
301 ((fintek->cmd & BUF_COMMAND_MASK) !=
302 BUF_PULSE_BIT)) {
303 fintek->parser_state = SUBCMD;
304 continue;
306 fintek->rem = (fintek->cmd & BUF_LEN_MASK);
307 fit_dbg("%s: rem: 0x%02x", __func__, fintek->rem);
308 if (fintek->rem)
309 fintek->parser_state = PARSE_IRDATA;
310 else
311 ir_raw_event_reset(fintek->rdev);
312 break;
313 case SUBCMD:
314 fintek->rem = fintek_cmdsize(fintek->cmd, sample);
315 fintek->parser_state = CMD_DATA;
316 break;
317 case CMD_DATA:
318 fintek->rem--;
319 break;
320 case PARSE_IRDATA:
321 fintek->rem--;
322 init_ir_raw_event(&rawir);
323 rawir.pulse = ((sample & BUF_PULSE_BIT) != 0);
324 rawir.duration = US_TO_NS((sample & BUF_SAMPLE_MASK)
325 * CIR_SAMPLE_PERIOD);
327 fit_dbg("Storing %s with duration %d",
328 rawir.pulse ? "pulse" : "space",
329 rawir.duration);
330 if (ir_raw_event_store_with_filter(fintek->rdev,
331 &rawir))
332 event = true;
333 break;
336 if ((fintek->parser_state != CMD_HEADER) && !fintek->rem)
337 fintek->parser_state = CMD_HEADER;
340 fintek->pkts = 0;
342 if (event) {
343 fit_dbg("Calling ir_raw_event_handle");
344 ir_raw_event_handle(fintek->rdev);
348 /* copy data from hardware rx register into driver buffer */
349 static void fintek_get_rx_ir_data(struct fintek_dev *fintek, u8 rx_irqs)
351 unsigned long flags;
352 u8 sample, status;
354 spin_lock_irqsave(&fintek->fintek_lock, flags);
357 * We must read data from CIR_RX_DATA until the hardware IR buffer
358 * is empty and clears the RX_TIMEOUT and/or RX_RECEIVE flags in
359 * the CIR_STATUS register
361 do {
362 sample = fintek_cir_reg_read(fintek, CIR_RX_DATA);
363 fit_dbg("%s: sample: 0x%02x", __func__, sample);
365 fintek->buf[fintek->pkts] = sample;
366 fintek->pkts++;
368 status = fintek_cir_reg_read(fintek, CIR_STATUS);
369 if (!(status & CIR_STATUS_IRQ_EN))
370 break;
371 } while (status & rx_irqs);
373 fintek_process_rx_ir_data(fintek);
375 spin_unlock_irqrestore(&fintek->fintek_lock, flags);
378 static void fintek_cir_log_irqs(u8 status)
380 fit_pr(KERN_INFO, "IRQ 0x%02x:%s%s%s%s%s", status,
381 status & CIR_STATUS_IRQ_EN ? " IRQEN" : "",
382 status & CIR_STATUS_TX_FINISH ? " TXF" : "",
383 status & CIR_STATUS_TX_UNDERRUN ? " TXU" : "",
384 status & CIR_STATUS_RX_TIMEOUT ? " RXTO" : "",
385 status & CIR_STATUS_RX_RECEIVE ? " RXOK" : "");
388 /* interrupt service routine for incoming and outgoing CIR data */
389 static irqreturn_t fintek_cir_isr(int irq, void *data)
391 struct fintek_dev *fintek = data;
392 u8 status, rx_irqs;
394 fit_dbg_verbose("%s firing", __func__);
396 fintek_config_mode_enable(fintek);
397 fintek_select_logical_dev(fintek, fintek->logical_dev_cir);
398 fintek_config_mode_disable(fintek);
401 * Get IR Status register contents. Write 1 to ack/clear
403 * bit: reg name - description
404 * 3: TX_FINISH - TX is finished
405 * 2: TX_UNDERRUN - TX underrun
406 * 1: RX_TIMEOUT - RX data timeout
407 * 0: RX_RECEIVE - RX data received
409 status = fintek_cir_reg_read(fintek, CIR_STATUS);
410 if (!(status & CIR_STATUS_IRQ_MASK) || status == 0xff) {
411 fit_dbg_verbose("%s exiting, IRSTS 0x%02x", __func__, status);
412 fintek_cir_reg_write(fintek, CIR_STATUS_IRQ_MASK, CIR_STATUS);
413 return IRQ_RETVAL(IRQ_NONE);
416 if (debug)
417 fintek_cir_log_irqs(status);
419 rx_irqs = status & (CIR_STATUS_RX_RECEIVE | CIR_STATUS_RX_TIMEOUT);
420 if (rx_irqs)
421 fintek_get_rx_ir_data(fintek, rx_irqs);
423 /* ack/clear all irq flags we've got */
424 fintek_cir_reg_write(fintek, status, CIR_STATUS);
426 fit_dbg_verbose("%s done", __func__);
427 return IRQ_RETVAL(IRQ_HANDLED);
430 static void fintek_enable_cir(struct fintek_dev *fintek)
432 /* set IRQ enabled */
433 fintek_cir_reg_write(fintek, CIR_STATUS_IRQ_EN, CIR_STATUS);
435 fintek_config_mode_enable(fintek);
437 /* enable the CIR logical device */
438 fintek_select_logical_dev(fintek, fintek->logical_dev_cir);
439 fintek_cr_write(fintek, LOGICAL_DEV_ENABLE, CIR_CR_DEV_EN);
441 fintek_config_mode_disable(fintek);
443 /* clear all pending interrupts */
444 fintek_cir_reg_write(fintek, CIR_STATUS_IRQ_MASK, CIR_STATUS);
446 /* enable interrupts */
447 fintek_enable_cir_irq(fintek);
450 static void fintek_disable_cir(struct fintek_dev *fintek)
452 fintek_config_mode_enable(fintek);
454 /* disable the CIR logical device */
455 fintek_select_logical_dev(fintek, fintek->logical_dev_cir);
456 fintek_cr_write(fintek, LOGICAL_DEV_DISABLE, CIR_CR_DEV_EN);
458 fintek_config_mode_disable(fintek);
461 static int fintek_open(struct rc_dev *dev)
463 struct fintek_dev *fintek = dev->priv;
464 unsigned long flags;
466 spin_lock_irqsave(&fintek->fintek_lock, flags);
467 fintek_enable_cir(fintek);
468 spin_unlock_irqrestore(&fintek->fintek_lock, flags);
470 return 0;
473 static void fintek_close(struct rc_dev *dev)
475 struct fintek_dev *fintek = dev->priv;
476 unsigned long flags;
478 spin_lock_irqsave(&fintek->fintek_lock, flags);
479 fintek_disable_cir(fintek);
480 spin_unlock_irqrestore(&fintek->fintek_lock, flags);
483 /* Allocate memory, probe hardware, and initialize everything */
484 static int fintek_probe(struct pnp_dev *pdev, const struct pnp_device_id *dev_id)
486 struct fintek_dev *fintek;
487 struct rc_dev *rdev;
488 int ret = -ENOMEM;
490 fintek = kzalloc(sizeof(struct fintek_dev), GFP_KERNEL);
491 if (!fintek)
492 return ret;
494 /* input device for IR remote (and tx) */
495 rdev = rc_allocate_device();
496 if (!rdev)
497 goto exit_free_dev_rdev;
499 ret = -ENODEV;
500 /* validate pnp resources */
501 if (!pnp_port_valid(pdev, 0)) {
502 dev_err(&pdev->dev, "IR PNP Port not valid!\n");
503 goto exit_free_dev_rdev;
506 if (!pnp_irq_valid(pdev, 0)) {
507 dev_err(&pdev->dev, "IR PNP IRQ not valid!\n");
508 goto exit_free_dev_rdev;
511 fintek->cir_addr = pnp_port_start(pdev, 0);
512 fintek->cir_irq = pnp_irq(pdev, 0);
513 fintek->cir_port_len = pnp_port_len(pdev, 0);
515 fintek->cr_ip = CR_INDEX_PORT;
516 fintek->cr_dp = CR_DATA_PORT;
518 spin_lock_init(&fintek->fintek_lock);
520 pnp_set_drvdata(pdev, fintek);
521 fintek->pdev = pdev;
523 ret = fintek_hw_detect(fintek);
524 if (ret)
525 goto exit_free_dev_rdev;
527 /* Initialize CIR & CIR Wake Logical Devices */
528 fintek_config_mode_enable(fintek);
529 fintek_cir_ldev_init(fintek);
530 fintek_config_mode_disable(fintek);
532 /* Initialize CIR & CIR Wake Config Registers */
533 fintek_cir_regs_init(fintek);
535 /* Set up the rc device */
536 rdev->priv = fintek;
537 rdev->driver_type = RC_DRIVER_IR_RAW;
538 rdev->allowed_protocols = RC_BIT_ALL;
539 rdev->open = fintek_open;
540 rdev->close = fintek_close;
541 rdev->input_name = FINTEK_DESCRIPTION;
542 rdev->input_phys = "fintek/cir0";
543 rdev->input_id.bustype = BUS_HOST;
544 rdev->input_id.vendor = VENDOR_ID_FINTEK;
545 rdev->input_id.product = fintek->chip_major;
546 rdev->input_id.version = fintek->chip_minor;
547 rdev->dev.parent = &pdev->dev;
548 rdev->driver_name = FINTEK_DRIVER_NAME;
549 rdev->map_name = RC_MAP_RC6_MCE;
550 rdev->timeout = US_TO_NS(1000);
551 /* rx resolution is hardwired to 50us atm, 1, 25, 100 also possible */
552 rdev->rx_resolution = US_TO_NS(CIR_SAMPLE_PERIOD);
554 fintek->rdev = rdev;
556 ret = -EBUSY;
557 /* now claim resources */
558 if (!request_region(fintek->cir_addr,
559 fintek->cir_port_len, FINTEK_DRIVER_NAME))
560 goto exit_free_dev_rdev;
562 if (request_irq(fintek->cir_irq, fintek_cir_isr, IRQF_SHARED,
563 FINTEK_DRIVER_NAME, (void *)fintek))
564 goto exit_free_cir_addr;
566 ret = rc_register_device(rdev);
567 if (ret)
568 goto exit_free_irq;
570 device_init_wakeup(&pdev->dev, true);
572 fit_pr(KERN_NOTICE, "driver has been successfully loaded\n");
573 if (debug)
574 cir_dump_regs(fintek);
576 return 0;
578 exit_free_irq:
579 free_irq(fintek->cir_irq, fintek);
580 exit_free_cir_addr:
581 release_region(fintek->cir_addr, fintek->cir_port_len);
582 exit_free_dev_rdev:
583 rc_free_device(rdev);
584 kfree(fintek);
586 return ret;
589 static void fintek_remove(struct pnp_dev *pdev)
591 struct fintek_dev *fintek = pnp_get_drvdata(pdev);
592 unsigned long flags;
594 spin_lock_irqsave(&fintek->fintek_lock, flags);
595 /* disable CIR */
596 fintek_disable_cir(fintek);
597 fintek_cir_reg_write(fintek, CIR_STATUS_IRQ_MASK, CIR_STATUS);
598 /* enable CIR Wake (for IR power-on) */
599 fintek_enable_wake(fintek);
600 spin_unlock_irqrestore(&fintek->fintek_lock, flags);
602 /* free resources */
603 free_irq(fintek->cir_irq, fintek);
604 release_region(fintek->cir_addr, fintek->cir_port_len);
606 rc_unregister_device(fintek->rdev);
608 kfree(fintek);
611 static int fintek_suspend(struct pnp_dev *pdev, pm_message_t state)
613 struct fintek_dev *fintek = pnp_get_drvdata(pdev);
614 unsigned long flags;
616 fit_dbg("%s called", __func__);
618 spin_lock_irqsave(&fintek->fintek_lock, flags);
620 /* disable all CIR interrupts */
621 fintek_cir_reg_write(fintek, CIR_STATUS_IRQ_MASK, CIR_STATUS);
623 spin_unlock_irqrestore(&fintek->fintek_lock, flags);
625 fintek_config_mode_enable(fintek);
627 /* disable cir logical dev */
628 fintek_select_logical_dev(fintek, fintek->logical_dev_cir);
629 fintek_cr_write(fintek, LOGICAL_DEV_DISABLE, CIR_CR_DEV_EN);
631 fintek_config_mode_disable(fintek);
633 /* make sure wake is enabled */
634 fintek_enable_wake(fintek);
636 return 0;
639 static int fintek_resume(struct pnp_dev *pdev)
641 struct fintek_dev *fintek = pnp_get_drvdata(pdev);
643 fit_dbg("%s called", __func__);
645 /* open interrupt */
646 fintek_enable_cir_irq(fintek);
648 /* Enable CIR logical device */
649 fintek_config_mode_enable(fintek);
650 fintek_select_logical_dev(fintek, fintek->logical_dev_cir);
651 fintek_cr_write(fintek, LOGICAL_DEV_ENABLE, CIR_CR_DEV_EN);
653 fintek_config_mode_disable(fintek);
655 fintek_cir_regs_init(fintek);
657 return 0;
660 static void fintek_shutdown(struct pnp_dev *pdev)
662 struct fintek_dev *fintek = pnp_get_drvdata(pdev);
663 fintek_enable_wake(fintek);
666 static const struct pnp_device_id fintek_ids[] = {
667 { "FIT0002", 0 }, /* CIR */
668 { "", 0 },
671 static struct pnp_driver fintek_driver = {
672 .name = FINTEK_DRIVER_NAME,
673 .id_table = fintek_ids,
674 .flags = PNP_DRIVER_RES_DO_NOT_CHANGE,
675 .probe = fintek_probe,
676 .remove = fintek_remove,
677 .suspend = fintek_suspend,
678 .resume = fintek_resume,
679 .shutdown = fintek_shutdown,
682 module_param(debug, int, S_IRUGO | S_IWUSR);
683 MODULE_PARM_DESC(debug, "Enable debugging output");
685 MODULE_DEVICE_TABLE(pnp, fintek_ids);
686 MODULE_DESCRIPTION(FINTEK_DESCRIPTION " driver");
688 MODULE_AUTHOR("Jarod Wilson <jarod@redhat.com>");
689 MODULE_LICENSE("GPL");
691 module_pnp_driver(fintek_driver);