Lines Matching refs:fintek

26 static inline void fintek_cr_write(struct fintek_dev *fintek, u8 val, u8 reg)  in fintek_cr_write()  argument
29 __func__, reg, val, fintek->cr_ip, fintek->cr_dp); in fintek_cr_write()
30 outb(reg, fintek->cr_ip); in fintek_cr_write()
31 outb(val, fintek->cr_dp); in fintek_cr_write()
35 static inline u8 fintek_cr_read(struct fintek_dev *fintek, u8 reg) in fintek_cr_read() argument
39 outb(reg, fintek->cr_ip); in fintek_cr_read()
40 val = inb(fintek->cr_dp); in fintek_cr_read()
43 __func__, reg, val, fintek->cr_ip, fintek->cr_dp); in fintek_cr_read()
48 static inline void fintek_set_reg_bit(struct fintek_dev *fintek, u8 val, u8 reg) in fintek_set_reg_bit() argument
50 u8 tmp = fintek_cr_read(fintek, reg) | val; in fintek_set_reg_bit()
51 fintek_cr_write(fintek, tmp, reg); in fintek_set_reg_bit()
55 static inline void fintek_config_mode_enable(struct fintek_dev *fintek) in fintek_config_mode_enable() argument
58 outb(CONFIG_REG_ENABLE, fintek->cr_ip); in fintek_config_mode_enable()
59 outb(CONFIG_REG_ENABLE, fintek->cr_ip); in fintek_config_mode_enable()
63 static inline void fintek_config_mode_disable(struct fintek_dev *fintek) in fintek_config_mode_disable() argument
65 outb(CONFIG_REG_DISABLE, fintek->cr_ip); in fintek_config_mode_disable()
72 static inline void fintek_select_logical_dev(struct fintek_dev *fintek, u8 ldev) in fintek_select_logical_dev() argument
74 fintek_cr_write(fintek, ldev, GCR_LOGICAL_DEV_NO); in fintek_select_logical_dev()
78 static inline void fintek_cir_reg_write(struct fintek_dev *fintek, u8 val, u8 offset) in fintek_cir_reg_write() argument
80 outb(val, fintek->cir_addr + offset); in fintek_cir_reg_write()
84 static u8 fintek_cir_reg_read(struct fintek_dev *fintek, u8 offset) in fintek_cir_reg_read() argument
86 return inb(fintek->cir_addr + offset); in fintek_cir_reg_read()
90 static void cir_dump_regs(struct fintek_dev *fintek) in cir_dump_regs() argument
92 fintek_config_mode_enable(fintek); in cir_dump_regs()
93 fintek_select_logical_dev(fintek, fintek->logical_dev_cir); in cir_dump_regs()
97 (fintek_cr_read(fintek, CIR_CR_BASE_ADDR_HI) << 8) | in cir_dump_regs()
98 fintek_cr_read(fintek, CIR_CR_BASE_ADDR_LO)); in cir_dump_regs()
100 fintek_cr_read(fintek, CIR_CR_IRQ_SEL)); in cir_dump_regs()
102 fintek_config_mode_disable(fintek); in cir_dump_regs()
106 fintek_cir_reg_read(fintek, CIR_STATUS)); in cir_dump_regs()
108 fintek_cir_reg_read(fintek, CIR_CONTROL)); in cir_dump_regs()
110 fintek_cir_reg_read(fintek, CIR_RX_DATA)); in cir_dump_regs()
112 fintek_cir_reg_read(fintek, CIR_TX_CONTROL)); in cir_dump_regs()
114 fintek_cir_reg_read(fintek, CIR_TX_DATA)); in cir_dump_regs()
118 static int fintek_hw_detect(struct fintek_dev *fintek) in fintek_hw_detect() argument
126 fintek_config_mode_enable(fintek); in fintek_hw_detect()
129 portsel = fintek_cr_read(fintek, GCR_CONFIG_PORT_SEL); in fintek_hw_detect()
132 fintek_config_mode_disable(fintek); in fintek_hw_detect()
133 fintek->cr_ip = CR_INDEX_PORT2; in fintek_hw_detect()
134 fintek->cr_dp = CR_DATA_PORT2; in fintek_hw_detect()
135 fintek_config_mode_enable(fintek); in fintek_hw_detect()
136 portsel = fintek_cr_read(fintek, GCR_CONFIG_PORT_SEL); in fintek_hw_detect()
140 ir_class = fintek_cir_reg_read(fintek, CIR_CR_CLASS); in fintek_hw_detect()
146 fintek->hw_tx_capable = true; in fintek_hw_detect()
150 fintek->hw_tx_capable = false; in fintek_hw_detect()
154 chip_major = fintek_cr_read(fintek, GCR_CHIP_ID_HI); in fintek_hw_detect()
155 chip_minor = fintek_cr_read(fintek, GCR_CHIP_ID_LO); in fintek_hw_detect()
158 vendor_major = fintek_cr_read(fintek, GCR_VENDOR_ID_HI); in fintek_hw_detect()
159 vendor_minor = fintek_cr_read(fintek, GCR_VENDOR_ID_LO); in fintek_hw_detect()
167 fintek_config_mode_disable(fintek); in fintek_hw_detect()
169 spin_lock_irqsave(&fintek->fintek_lock, flags); in fintek_hw_detect()
170 fintek->chip_major = chip_major; in fintek_hw_detect()
171 fintek->chip_minor = chip_minor; in fintek_hw_detect()
172 fintek->chip_vendor = vendor; in fintek_hw_detect()
178 fintek->logical_dev_cir = LOGICAL_DEV_CIR_REV2; in fintek_hw_detect()
180 fintek->logical_dev_cir = LOGICAL_DEV_CIR_REV1; in fintek_hw_detect()
182 spin_unlock_irqrestore(&fintek->fintek_lock, flags); in fintek_hw_detect()
187 static void fintek_cir_ldev_init(struct fintek_dev *fintek) in fintek_cir_ldev_init() argument
190 fintek_select_logical_dev(fintek, fintek->logical_dev_cir); in fintek_cir_ldev_init()
191 fintek_cr_write(fintek, LOGICAL_DEV_ENABLE, CIR_CR_DEV_EN); in fintek_cir_ldev_init()
194 fintek_cr_write(fintek, fintek->cir_addr >> 8, CIR_CR_BASE_ADDR_HI); in fintek_cir_ldev_init()
195 fintek_cr_write(fintek, fintek->cir_addr & 0xff, CIR_CR_BASE_ADDR_LO); in fintek_cir_ldev_init()
197 fintek_cr_write(fintek, fintek->cir_irq, CIR_CR_IRQ_SEL); in fintek_cir_ldev_init()
200 fintek->cir_addr, fintek->cir_irq, fintek->cir_port_len); in fintek_cir_ldev_init()
204 static void fintek_enable_cir_irq(struct fintek_dev *fintek) in fintek_enable_cir_irq() argument
206 fintek_cir_reg_write(fintek, CIR_STATUS_IRQ_EN, CIR_STATUS); in fintek_enable_cir_irq()
209 static void fintek_cir_regs_init(struct fintek_dev *fintek) in fintek_cir_regs_init() argument
212 fintek_cir_reg_write(fintek, CIR_STATUS_IRQ_MASK, CIR_STATUS); in fintek_cir_regs_init()
215 fintek_enable_cir_irq(fintek); in fintek_cir_regs_init()
218 static void fintek_enable_wake(struct fintek_dev *fintek) in fintek_enable_wake() argument
220 fintek_config_mode_enable(fintek); in fintek_enable_wake()
221 fintek_select_logical_dev(fintek, LOGICAL_DEV_ACPI); in fintek_enable_wake()
224 fintek_set_reg_bit(fintek, ACPI_WAKE_EN_CIR_BIT, LDEV_ACPI_WAKE_EN_REG); in fintek_enable_wake()
226 fintek_set_reg_bit(fintek, ACPI_PME_CIR_BIT, LDEV_ACPI_PME_EN_REG); in fintek_enable_wake()
228 fintek_set_reg_bit(fintek, ACPI_PME_CIR_BIT, LDEV_ACPI_PME_CLR_REG); in fintek_enable_wake()
230 fintek_set_reg_bit(fintek, ACPI_STATE_CIR_BIT, LDEV_ACPI_STATE_REG); in fintek_enable_wake()
232 fintek_config_mode_disable(fintek); in fintek_enable_wake()
267 static void fintek_process_rx_ir_data(struct fintek_dev *fintek) in fintek_process_rx_ir_data() argument
274 for (i = 0; i < fintek->pkts; i++) { in fintek_process_rx_ir_data()
275 sample = fintek->buf[i]; in fintek_process_rx_ir_data()
276 switch (fintek->parser_state) { in fintek_process_rx_ir_data()
278 fintek->cmd = sample; in fintek_process_rx_ir_data()
279 if ((fintek->cmd == BUF_COMMAND_HEADER) || in fintek_process_rx_ir_data()
280 ((fintek->cmd & BUF_COMMAND_MASK) != in fintek_process_rx_ir_data()
282 fintek->parser_state = SUBCMD; in fintek_process_rx_ir_data()
285 fintek->rem = (fintek->cmd & BUF_LEN_MASK); in fintek_process_rx_ir_data()
286 fit_dbg("%s: rem: 0x%02x", __func__, fintek->rem); in fintek_process_rx_ir_data()
287 if (fintek->rem) in fintek_process_rx_ir_data()
288 fintek->parser_state = PARSE_IRDATA; in fintek_process_rx_ir_data()
290 ir_raw_event_overflow(fintek->rdev); in fintek_process_rx_ir_data()
293 fintek->rem = fintek_cmdsize(fintek->cmd, sample); in fintek_process_rx_ir_data()
294 fintek->parser_state = CMD_DATA; in fintek_process_rx_ir_data()
297 fintek->rem--; in fintek_process_rx_ir_data()
300 fintek->rem--; in fintek_process_rx_ir_data()
308 if (ir_raw_event_store_with_filter(fintek->rdev, in fintek_process_rx_ir_data()
314 if ((fintek->parser_state != CMD_HEADER) && !fintek->rem) in fintek_process_rx_ir_data()
315 fintek->parser_state = CMD_HEADER; in fintek_process_rx_ir_data()
318 fintek->pkts = 0; in fintek_process_rx_ir_data()
322 ir_raw_event_handle(fintek->rdev); in fintek_process_rx_ir_data()
327 static void fintek_get_rx_ir_data(struct fintek_dev *fintek, u8 rx_irqs) in fintek_get_rx_ir_data() argument
332 spin_lock_irqsave(&fintek->fintek_lock, flags); in fintek_get_rx_ir_data()
340 sample = fintek_cir_reg_read(fintek, CIR_RX_DATA); in fintek_get_rx_ir_data()
343 fintek->buf[fintek->pkts] = sample; in fintek_get_rx_ir_data()
344 fintek->pkts++; in fintek_get_rx_ir_data()
346 status = fintek_cir_reg_read(fintek, CIR_STATUS); in fintek_get_rx_ir_data()
351 fintek_process_rx_ir_data(fintek); in fintek_get_rx_ir_data()
353 spin_unlock_irqrestore(&fintek->fintek_lock, flags); in fintek_get_rx_ir_data()
369 struct fintek_dev *fintek = data; in fintek_cir_isr() local
374 fintek_config_mode_enable(fintek); in fintek_cir_isr()
375 fintek_select_logical_dev(fintek, fintek->logical_dev_cir); in fintek_cir_isr()
376 fintek_config_mode_disable(fintek); in fintek_cir_isr()
387 status = fintek_cir_reg_read(fintek, CIR_STATUS); in fintek_cir_isr()
390 fintek_cir_reg_write(fintek, CIR_STATUS_IRQ_MASK, CIR_STATUS); in fintek_cir_isr()
399 fintek_get_rx_ir_data(fintek, rx_irqs); in fintek_cir_isr()
402 fintek_cir_reg_write(fintek, status, CIR_STATUS); in fintek_cir_isr()
408 static void fintek_enable_cir(struct fintek_dev *fintek) in fintek_enable_cir() argument
411 fintek_cir_reg_write(fintek, CIR_STATUS_IRQ_EN, CIR_STATUS); in fintek_enable_cir()
413 fintek_config_mode_enable(fintek); in fintek_enable_cir()
416 fintek_select_logical_dev(fintek, fintek->logical_dev_cir); in fintek_enable_cir()
417 fintek_cr_write(fintek, LOGICAL_DEV_ENABLE, CIR_CR_DEV_EN); in fintek_enable_cir()
419 fintek_config_mode_disable(fintek); in fintek_enable_cir()
422 fintek_cir_reg_write(fintek, CIR_STATUS_IRQ_MASK, CIR_STATUS); in fintek_enable_cir()
425 fintek_enable_cir_irq(fintek); in fintek_enable_cir()
428 static void fintek_disable_cir(struct fintek_dev *fintek) in fintek_disable_cir() argument
430 fintek_config_mode_enable(fintek); in fintek_disable_cir()
433 fintek_select_logical_dev(fintek, fintek->logical_dev_cir); in fintek_disable_cir()
434 fintek_cr_write(fintek, LOGICAL_DEV_DISABLE, CIR_CR_DEV_EN); in fintek_disable_cir()
436 fintek_config_mode_disable(fintek); in fintek_disable_cir()
441 struct fintek_dev *fintek = dev->priv; in fintek_open() local
444 spin_lock_irqsave(&fintek->fintek_lock, flags); in fintek_open()
445 fintek_enable_cir(fintek); in fintek_open()
446 spin_unlock_irqrestore(&fintek->fintek_lock, flags); in fintek_open()
453 struct fintek_dev *fintek = dev->priv; in fintek_close() local
456 spin_lock_irqsave(&fintek->fintek_lock, flags); in fintek_close()
457 fintek_disable_cir(fintek); in fintek_close()
458 spin_unlock_irqrestore(&fintek->fintek_lock, flags); in fintek_close()
464 struct fintek_dev *fintek; in fintek_probe() local
468 fintek = kzalloc(sizeof(struct fintek_dev), GFP_KERNEL); in fintek_probe()
469 if (!fintek) in fintek_probe()
489 fintek->cir_addr = pnp_port_start(pdev, 0); in fintek_probe()
490 fintek->cir_irq = pnp_irq(pdev, 0); in fintek_probe()
491 fintek->cir_port_len = pnp_port_len(pdev, 0); in fintek_probe()
493 fintek->cr_ip = CR_INDEX_PORT; in fintek_probe()
494 fintek->cr_dp = CR_DATA_PORT; in fintek_probe()
496 spin_lock_init(&fintek->fintek_lock); in fintek_probe()
498 pnp_set_drvdata(pdev, fintek); in fintek_probe()
499 fintek->pdev = pdev; in fintek_probe()
501 ret = fintek_hw_detect(fintek); in fintek_probe()
506 fintek_config_mode_enable(fintek); in fintek_probe()
507 fintek_cir_ldev_init(fintek); in fintek_probe()
508 fintek_config_mode_disable(fintek); in fintek_probe()
511 fintek_cir_regs_init(fintek); in fintek_probe()
514 rdev->priv = fintek; in fintek_probe()
522 rdev->input_id.product = fintek->chip_major; in fintek_probe()
523 rdev->input_id.version = fintek->chip_minor; in fintek_probe()
531 fintek->rdev = rdev; in fintek_probe()
535 if (!request_region(fintek->cir_addr, in fintek_probe()
536 fintek->cir_port_len, FINTEK_DRIVER_NAME)) in fintek_probe()
539 if (request_irq(fintek->cir_irq, fintek_cir_isr, IRQF_SHARED, in fintek_probe()
540 FINTEK_DRIVER_NAME, (void *)fintek)) in fintek_probe()
551 cir_dump_regs(fintek); in fintek_probe()
556 free_irq(fintek->cir_irq, fintek); in fintek_probe()
558 release_region(fintek->cir_addr, fintek->cir_port_len); in fintek_probe()
561 kfree(fintek); in fintek_probe()
568 struct fintek_dev *fintek = pnp_get_drvdata(pdev); in fintek_remove() local
571 spin_lock_irqsave(&fintek->fintek_lock, flags); in fintek_remove()
573 fintek_disable_cir(fintek); in fintek_remove()
574 fintek_cir_reg_write(fintek, CIR_STATUS_IRQ_MASK, CIR_STATUS); in fintek_remove()
576 fintek_enable_wake(fintek); in fintek_remove()
577 spin_unlock_irqrestore(&fintek->fintek_lock, flags); in fintek_remove()
580 free_irq(fintek->cir_irq, fintek); in fintek_remove()
581 release_region(fintek->cir_addr, fintek->cir_port_len); in fintek_remove()
583 rc_unregister_device(fintek->rdev); in fintek_remove()
585 kfree(fintek); in fintek_remove()
590 struct fintek_dev *fintek = pnp_get_drvdata(pdev); in fintek_suspend() local
595 spin_lock_irqsave(&fintek->fintek_lock, flags); in fintek_suspend()
598 fintek_cir_reg_write(fintek, CIR_STATUS_IRQ_MASK, CIR_STATUS); in fintek_suspend()
600 spin_unlock_irqrestore(&fintek->fintek_lock, flags); in fintek_suspend()
602 fintek_config_mode_enable(fintek); in fintek_suspend()
605 fintek_select_logical_dev(fintek, fintek->logical_dev_cir); in fintek_suspend()
606 fintek_cr_write(fintek, LOGICAL_DEV_DISABLE, CIR_CR_DEV_EN); in fintek_suspend()
608 fintek_config_mode_disable(fintek); in fintek_suspend()
611 fintek_enable_wake(fintek); in fintek_suspend()
618 struct fintek_dev *fintek = pnp_get_drvdata(pdev); in fintek_resume() local
623 fintek_enable_cir_irq(fintek); in fintek_resume()
626 fintek_config_mode_enable(fintek); in fintek_resume()
627 fintek_select_logical_dev(fintek, fintek->logical_dev_cir); in fintek_resume()
628 fintek_cr_write(fintek, LOGICAL_DEV_ENABLE, CIR_CR_DEV_EN); in fintek_resume()
630 fintek_config_mode_disable(fintek); in fintek_resume()
632 fintek_cir_regs_init(fintek); in fintek_resume()
639 struct fintek_dev *fintek = pnp_get_drvdata(pdev); in fintek_shutdown() local
640 fintek_enable_wake(fintek); in fintek_shutdown()