Lines Matching refs:data

242 wbcir_select_bank(struct wbcir_data *data, enum wbcir_bank bank)  in wbcir_select_bank()  argument
244 outb(bank, data->sbase + WBCIR_REG_SP3_BSR); in wbcir_select_bank()
248 wbcir_set_irqmask(struct wbcir_data *data, u8 irqmask) in wbcir_set_irqmask() argument
250 if (data->irqmask == irqmask) in wbcir_set_irqmask()
253 wbcir_select_bank(data, WBCIR_BANK_0); in wbcir_set_irqmask()
254 outb(irqmask, data->sbase + WBCIR_REG_SP3_IER); in wbcir_set_irqmask()
255 data->irqmask = irqmask; in wbcir_set_irqmask()
261 struct wbcir_data *data = container_of(led_cdev, in wbcir_led_brightness_get() local
265 if (inb(data->ebase + WBCIR_REG_ECEIR_CTS) & WBCIR_LED_ENABLE) in wbcir_led_brightness_get()
275 struct wbcir_data *data = container_of(led_cdev, in wbcir_led_brightness_set() local
279 wbcir_set_bits(data->ebase + WBCIR_REG_ECEIR_CTS, in wbcir_led_brightness_set()
310 wbcir_carrier_report(struct wbcir_data *data) in wbcir_carrier_report() argument
312 unsigned counter = inb(data->ebase + WBCIR_REG_ECEIR_CNT_LO) | in wbcir_carrier_report()
313 inb(data->ebase + WBCIR_REG_ECEIR_CNT_HI) << 8; in wbcir_carrier_report()
319 data->pulse_duration) in wbcir_carrier_report()
322 ir_raw_event_store(data->dev, &ev); in wbcir_carrier_report()
326 data->pulse_duration = 0; in wbcir_carrier_report()
327 wbcir_set_bits(data->ebase + WBCIR_REG_ECEIR_CCTL, WBCIR_CNTR_R, in wbcir_carrier_report()
329 wbcir_set_bits(data->ebase + WBCIR_REG_ECEIR_CCTL, WBCIR_CNTR_EN, in wbcir_carrier_report()
336 struct wbcir_data *data = dev->priv; in wbcir_idle_rx() local
338 if (!idle && data->rxstate == WBCIR_RXSTATE_INACTIVE) in wbcir_idle_rx()
339 data->rxstate = WBCIR_RXSTATE_ACTIVE; in wbcir_idle_rx()
341 if (idle && data->rxstate != WBCIR_RXSTATE_INACTIVE) { in wbcir_idle_rx()
342 data->rxstate = WBCIR_RXSTATE_INACTIVE; in wbcir_idle_rx()
344 if (data->carrier_report_enabled) in wbcir_idle_rx()
345 wbcir_carrier_report(data); in wbcir_idle_rx()
348 outb(WBCIR_RX_DISABLE, data->sbase + WBCIR_REG_SP3_ASCR); in wbcir_idle_rx()
353 wbcir_irq_rx(struct wbcir_data *data, struct pnp_dev *device) in wbcir_irq_rx() argument
359 while (inb(data->sbase + WBCIR_REG_SP3_LSR) & WBCIR_RX_AVAIL) { in wbcir_irq_rx()
360 irdata = inb(data->sbase + WBCIR_REG_SP3_RXDATA); in wbcir_irq_rx()
361 if (data->rxstate == WBCIR_RXSTATE_ERROR) in wbcir_irq_rx()
365 (data->carrier_report_enabled ? 2 : 10); in wbcir_irq_rx()
369 data->pulse_duration += rawir.duration; in wbcir_irq_rx()
371 ir_raw_event_store_with_filter(data->dev, &rawir); in wbcir_irq_rx()
374 ir_raw_event_handle(data->dev); in wbcir_irq_rx()
378 wbcir_irq_tx(struct wbcir_data *data) in wbcir_irq_tx() argument
385 if (!data->txbuf) in wbcir_irq_tx()
388 switch (data->txstate) { in wbcir_irq_tx()
409 for (used = 0; used < space && data->txoff != data->txlen; used++) { in wbcir_irq_tx()
410 if (data->txbuf[data->txoff] == 0) { in wbcir_irq_tx()
411 data->txoff++; in wbcir_irq_tx()
414 byte = min((u32)0x80, data->txbuf[data->txoff]); in wbcir_irq_tx()
415 data->txbuf[data->txoff] -= byte; in wbcir_irq_tx()
417 byte |= (data->txoff % 2 ? 0x80 : 0x00); /* pulse/space */ in wbcir_irq_tx()
421 while (data->txoff != data->txlen && data->txbuf[data->txoff] == 0) in wbcir_irq_tx()
422 data->txoff++; in wbcir_irq_tx()
426 if (data->txstate == WBCIR_TXSTATE_ERROR) in wbcir_irq_tx()
428 outb(WBCIR_TX_UNDERRUN, data->sbase + WBCIR_REG_SP3_ASCR); in wbcir_irq_tx()
429 wbcir_set_irqmask(data, WBCIR_IRQ_RX | WBCIR_IRQ_ERR); in wbcir_irq_tx()
430 kfree(data->txbuf); in wbcir_irq_tx()
431 data->txbuf = NULL; in wbcir_irq_tx()
432 data->txstate = WBCIR_TXSTATE_INACTIVE; in wbcir_irq_tx()
433 } else if (data->txoff == data->txlen) { in wbcir_irq_tx()
435 outsb(data->sbase + WBCIR_REG_SP3_TXDATA, bytes, used - 1); in wbcir_irq_tx()
436 outb(WBCIR_TX_EOT, data->sbase + WBCIR_REG_SP3_ASCR); in wbcir_irq_tx()
437 outb(bytes[used - 1], data->sbase + WBCIR_REG_SP3_TXDATA); in wbcir_irq_tx()
438 wbcir_set_irqmask(data, WBCIR_IRQ_RX | WBCIR_IRQ_ERR | in wbcir_irq_tx()
442 outsb(data->sbase + WBCIR_REG_SP3_RXDATA, bytes, used); in wbcir_irq_tx()
443 if (data->txstate == WBCIR_TXSTATE_INACTIVE) { in wbcir_irq_tx()
444 wbcir_set_irqmask(data, WBCIR_IRQ_RX | WBCIR_IRQ_ERR | in wbcir_irq_tx()
446 data->txstate = WBCIR_TXSTATE_ACTIVE; in wbcir_irq_tx()
455 struct wbcir_data *data = pnp_get_drvdata(device); in wbcir_irq_handler() local
459 spin_lock_irqsave(&data->spinlock, flags); in wbcir_irq_handler()
460 wbcir_select_bank(data, WBCIR_BANK_0); in wbcir_irq_handler()
461 status = inb(data->sbase + WBCIR_REG_SP3_EIR); in wbcir_irq_handler()
462 status &= data->irqmask; in wbcir_irq_handler()
465 spin_unlock_irqrestore(&data->spinlock, flags); in wbcir_irq_handler()
471 if (inb(data->sbase + WBCIR_REG_SP3_LSR) & WBCIR_RX_OVERRUN) { in wbcir_irq_handler()
472 data->rxstate = WBCIR_RXSTATE_ERROR; in wbcir_irq_handler()
473 ir_raw_event_overflow(data->dev); in wbcir_irq_handler()
477 if (inb(data->sbase + WBCIR_REG_SP3_ASCR) & WBCIR_TX_UNDERRUN) in wbcir_irq_handler()
478 data->txstate = WBCIR_TXSTATE_ERROR; in wbcir_irq_handler()
482 wbcir_irq_rx(data, device); in wbcir_irq_handler()
485 wbcir_irq_tx(data); in wbcir_irq_handler()
487 spin_unlock_irqrestore(&data->spinlock, flags); in wbcir_irq_handler()
500 struct wbcir_data *data = dev->priv; in wbcir_set_carrier_report() local
503 spin_lock_irqsave(&data->spinlock, flags); in wbcir_set_carrier_report()
505 if (data->carrier_report_enabled == enable) { in wbcir_set_carrier_report()
506 spin_unlock_irqrestore(&data->spinlock, flags); in wbcir_set_carrier_report()
510 data->pulse_duration = 0; in wbcir_set_carrier_report()
511 wbcir_set_bits(data->ebase + WBCIR_REG_ECEIR_CCTL, WBCIR_CNTR_R, in wbcir_set_carrier_report()
514 if (enable && data->dev->idle) in wbcir_set_carrier_report()
515 wbcir_set_bits(data->ebase + WBCIR_REG_ECEIR_CCTL, in wbcir_set_carrier_report()
519 wbcir_select_bank(data, WBCIR_BANK_2); in wbcir_set_carrier_report()
520 data->dev->rx_resolution = enable ? 2 : 10; in wbcir_set_carrier_report()
521 outb(enable ? 0x03 : 0x0f, data->sbase + WBCIR_REG_SP3_BGDL); in wbcir_set_carrier_report()
522 outb(0x00, data->sbase + WBCIR_REG_SP3_BGDH); in wbcir_set_carrier_report()
525 wbcir_select_bank(data, WBCIR_BANK_7); in wbcir_set_carrier_report()
526 wbcir_set_bits(data->sbase + WBCIR_REG_SP3_RCCFG, in wbcir_set_carrier_report()
529 data->carrier_report_enabled = enable; in wbcir_set_carrier_report()
530 spin_unlock_irqrestore(&data->spinlock, flags); in wbcir_set_carrier_report()
538 struct wbcir_data *data = dev->priv; in wbcir_txcarrier() local
564 spin_lock_irqsave(&data->spinlock, flags); in wbcir_txcarrier()
565 if (data->txstate != WBCIR_TXSTATE_INACTIVE) { in wbcir_txcarrier()
566 spin_unlock_irqrestore(&data->spinlock, flags); in wbcir_txcarrier()
570 if (data->txcarrier != freq) { in wbcir_txcarrier()
571 wbcir_select_bank(data, WBCIR_BANK_7); in wbcir_txcarrier()
572 wbcir_set_bits(data->sbase + WBCIR_REG_SP3_IRTXMC, val, 0x1F); in wbcir_txcarrier()
573 data->txcarrier = freq; in wbcir_txcarrier()
576 spin_unlock_irqrestore(&data->spinlock, flags); in wbcir_txcarrier()
583 struct wbcir_data *data = dev->priv; in wbcir_txmask() local
609 spin_lock_irqsave(&data->spinlock, flags); in wbcir_txmask()
610 if (data->txstate != WBCIR_TXSTATE_INACTIVE) { in wbcir_txmask()
611 spin_unlock_irqrestore(&data->spinlock, flags); in wbcir_txmask()
615 if (data->txmask != mask) { in wbcir_txmask()
616 wbcir_set_bits(data->ebase + WBCIR_REG_ECEIR_CTS, val, 0x0c); in wbcir_txmask()
617 data->txmask = mask; in wbcir_txmask()
620 spin_unlock_irqrestore(&data->spinlock, flags); in wbcir_txmask()
627 struct wbcir_data *data = dev->priv; in wbcir_tx() local
641 spin_lock_irqsave(&data->spinlock, flags); in wbcir_tx()
642 if (data->txstate != WBCIR_TXSTATE_INACTIVE) { in wbcir_tx()
643 spin_unlock_irqrestore(&data->spinlock, flags); in wbcir_tx()
649 data->txbuf = buf; in wbcir_tx()
650 data->txlen = count; in wbcir_tx()
651 data->txoff = 0; in wbcir_tx()
652 wbcir_irq_tx(data); in wbcir_tx()
655 spin_unlock_irqrestore(&data->spinlock, flags); in wbcir_tx()
669 struct wbcir_data *data = pnp_get_drvdata(device); in wbcir_shutdown() local
670 struct rc_dev *rc = data->dev; in wbcir_shutdown()
676 u32 wake_sc = rc->scancode_wakeup_filter.data; in wbcir_shutdown()
825 wbcir_set_bits(data->wbase + WBCIR_REG_WCEIR_INDEX, in wbcir_shutdown()
828 outsb(data->wbase + WBCIR_REG_WCEIR_DATA, match, 11); in wbcir_shutdown()
829 wbcir_set_bits(data->wbase + WBCIR_REG_WCEIR_INDEX, in wbcir_shutdown()
832 outsb(data->wbase + WBCIR_REG_WCEIR_DATA, mask, 11); in wbcir_shutdown()
835 outb(rc6_csl, data->wbase + WBCIR_REG_WCEIR_CSL); in wbcir_shutdown()
838 wbcir_set_bits(data->wbase + WBCIR_REG_WCEIR_STS, 0x17, 0x17); in wbcir_shutdown()
841 wbcir_set_bits(data->wbase + WBCIR_REG_WCEIR_EV_EN, 0x01, 0x07); in wbcir_shutdown()
844 wbcir_set_bits(data->wbase + WBCIR_REG_WCEIR_CTL, in wbcir_shutdown()
849 wbcir_set_bits(data->wbase + WBCIR_REG_WCEIR_EV_EN, 0x00, 0x07); in wbcir_shutdown()
852 wbcir_set_bits(data->wbase + WBCIR_REG_WCEIR_CTL, 0x00, 0x01); in wbcir_shutdown()
861 wbcir_set_irqmask(data, WBCIR_IRQ_NONE); in wbcir_shutdown()
862 disable_irq(data->irq); in wbcir_shutdown()
877 struct wbcir_data *data = pnp_get_drvdata(device); in wbcir_suspend() local
878 led_classdev_suspend(&data->led); in wbcir_suspend()
884 wbcir_init_hw(struct wbcir_data *data) in wbcir_init_hw() argument
887 wbcir_set_irqmask(data, WBCIR_IRQ_NONE); in wbcir_init_hw()
890 wbcir_set_bits(data->wbase + WBCIR_REG_WCEIR_CTL, invert ? 8 : 0, 0x09); in wbcir_init_hw()
893 wbcir_set_bits(data->wbase + WBCIR_REG_WCEIR_STS, 0x17, 0x17); in wbcir_init_hw()
896 wbcir_set_bits(data->wbase + WBCIR_REG_WCEIR_EV_EN, 0x00, 0x07); in wbcir_init_hw()
899 wbcir_set_bits(data->wbase + WBCIR_REG_WCEIR_CFG1, 0x4A, 0x7F); in wbcir_init_hw()
903 outb(WBCIR_IRTX_INV, data->ebase + WBCIR_REG_ECEIR_CCTL); in wbcir_init_hw()
905 outb(0x00, data->ebase + WBCIR_REG_ECEIR_CCTL); in wbcir_init_hw()
911 outb(0x10, data->ebase + WBCIR_REG_ECEIR_CTS); in wbcir_init_hw()
912 data->txmask = 0x1; in wbcir_init_hw()
915 wbcir_select_bank(data, WBCIR_BANK_2); in wbcir_init_hw()
916 outb(WBCIR_EXT_ENABLE, data->sbase + WBCIR_REG_SP3_EXCR1); in wbcir_init_hw()
930 outb(0x30, data->sbase + WBCIR_REG_SP3_EXCR2); in wbcir_init_hw()
933 outb(0x0f, data->sbase + WBCIR_REG_SP3_BGDL); in wbcir_init_hw()
934 outb(0x00, data->sbase + WBCIR_REG_SP3_BGDH); in wbcir_init_hw()
937 wbcir_select_bank(data, WBCIR_BANK_0); in wbcir_init_hw()
938 outb(0xC0, data->sbase + WBCIR_REG_SP3_MCR); in wbcir_init_hw()
939 inb(data->sbase + WBCIR_REG_SP3_LSR); /* Clear LSR */ in wbcir_init_hw()
940 inb(data->sbase + WBCIR_REG_SP3_MSR); /* Clear MSR */ in wbcir_init_hw()
943 wbcir_select_bank(data, WBCIR_BANK_7); in wbcir_init_hw()
944 outb(0x90, data->sbase + WBCIR_REG_SP3_RCCFG); in wbcir_init_hw()
947 wbcir_select_bank(data, WBCIR_BANK_4); in wbcir_init_hw()
948 outb(0x00, data->sbase + WBCIR_REG_SP3_IRCR1); in wbcir_init_hw()
951 wbcir_select_bank(data, WBCIR_BANK_5); in wbcir_init_hw()
952 outb(txandrx ? 0x03 : 0x02, data->sbase + WBCIR_REG_SP3_IRCR2); in wbcir_init_hw()
955 wbcir_select_bank(data, WBCIR_BANK_6); in wbcir_init_hw()
956 outb(0x20, data->sbase + WBCIR_REG_SP3_IRCR3); in wbcir_init_hw()
959 wbcir_select_bank(data, WBCIR_BANK_7); in wbcir_init_hw()
960 outb(0xF2, data->sbase + WBCIR_REG_SP3_IRRXDC); in wbcir_init_hw()
963 outb(0x69, data->sbase + WBCIR_REG_SP3_IRTXMC); in wbcir_init_hw()
964 data->txcarrier = 36000; in wbcir_init_hw()
968 outb(0x10, data->sbase + WBCIR_REG_SP3_IRCFG4); in wbcir_init_hw()
970 outb(0x00, data->sbase + WBCIR_REG_SP3_IRCFG4); in wbcir_init_hw()
973 wbcir_select_bank(data, WBCIR_BANK_0); in wbcir_init_hw()
974 outb(0x97, data->sbase + WBCIR_REG_SP3_FCR); in wbcir_init_hw()
977 outb(0xE0, data->sbase + WBCIR_REG_SP3_ASCR); in wbcir_init_hw()
980 data->rxstate = WBCIR_RXSTATE_INACTIVE; in wbcir_init_hw()
981 wbcir_idle_rx(data->dev, true); in wbcir_init_hw()
984 if (data->txstate == WBCIR_TXSTATE_ACTIVE) { in wbcir_init_hw()
985 kfree(data->txbuf); in wbcir_init_hw()
986 data->txbuf = NULL; in wbcir_init_hw()
987 data->txstate = WBCIR_TXSTATE_INACTIVE; in wbcir_init_hw()
991 wbcir_set_irqmask(data, WBCIR_IRQ_RX | WBCIR_IRQ_ERR); in wbcir_init_hw()
997 struct wbcir_data *data = pnp_get_drvdata(device); in wbcir_resume() local
999 wbcir_init_hw(data); in wbcir_resume()
1000 enable_irq(data->irq); in wbcir_resume()
1001 led_classdev_resume(&data->led); in wbcir_resume()
1010 struct wbcir_data *data; in wbcir_probe() local
1020 data = kzalloc(sizeof(*data), GFP_KERNEL); in wbcir_probe()
1021 if (!data) { in wbcir_probe()
1026 pnp_set_drvdata(device, data); in wbcir_probe()
1028 spin_lock_init(&data->spinlock); in wbcir_probe()
1029 data->ebase = pnp_port_start(device, 0); in wbcir_probe()
1030 data->wbase = pnp_port_start(device, 1); in wbcir_probe()
1031 data->sbase = pnp_port_start(device, 2); in wbcir_probe()
1032 data->irq = pnp_irq(device, 0); in wbcir_probe()
1034 if (data->wbase == 0 || data->ebase == 0 || in wbcir_probe()
1035 data->sbase == 0 || data->irq == -1) { in wbcir_probe()
1042 data->wbase, data->ebase, data->sbase, data->irq); in wbcir_probe()
1044 data->led.name = "cir::activity"; in wbcir_probe()
1045 data->led.default_trigger = "rc-feedback"; in wbcir_probe()
1046 data->led.brightness_set = wbcir_led_brightness_set; in wbcir_probe()
1047 data->led.brightness_get = wbcir_led_brightness_get; in wbcir_probe()
1048 err = led_classdev_register(&device->dev, &data->led); in wbcir_probe()
1052 data->dev = rc_allocate_device(RC_DRIVER_IR_RAW); in wbcir_probe()
1053 if (!data->dev) { in wbcir_probe()
1058 data->dev->driver_name = DRVNAME; in wbcir_probe()
1059 data->dev->device_name = WBCIR_NAME; in wbcir_probe()
1060 data->dev->input_phys = "wbcir/cir0"; in wbcir_probe()
1061 data->dev->input_id.bustype = BUS_HOST; in wbcir_probe()
1062 data->dev->input_id.vendor = PCI_VENDOR_ID_WINBOND; in wbcir_probe()
1063 data->dev->input_id.product = WBCIR_ID_FAMILY; in wbcir_probe()
1064 data->dev->input_id.version = WBCIR_ID_CHIP; in wbcir_probe()
1065 data->dev->map_name = RC_MAP_RC6_MCE; in wbcir_probe()
1066 data->dev->s_idle = wbcir_idle_rx; in wbcir_probe()
1067 data->dev->s_carrier_report = wbcir_set_carrier_report; in wbcir_probe()
1068 data->dev->s_tx_mask = wbcir_txmask; in wbcir_probe()
1069 data->dev->s_tx_carrier = wbcir_txcarrier; in wbcir_probe()
1070 data->dev->tx_ir = wbcir_tx; in wbcir_probe()
1071 data->dev->priv = data; in wbcir_probe()
1072 data->dev->dev.parent = &device->dev; in wbcir_probe()
1073 data->dev->min_timeout = 1; in wbcir_probe()
1074 data->dev->timeout = IR_DEFAULT_TIMEOUT; in wbcir_probe()
1075 data->dev->max_timeout = 10 * IR_DEFAULT_TIMEOUT; in wbcir_probe()
1076 data->dev->rx_resolution = 2; in wbcir_probe()
1077 data->dev->allowed_protocols = RC_PROTO_BIT_ALL_IR_DECODER; in wbcir_probe()
1078 data->dev->allowed_wakeup_protocols = RC_PROTO_BIT_NEC | in wbcir_probe()
1083 data->dev->wakeup_protocol = RC_PROTO_RC6_MCE; in wbcir_probe()
1084 data->dev->scancode_wakeup_filter.data = 0x800f040c; in wbcir_probe()
1085 data->dev->scancode_wakeup_filter.mask = 0xffff7fff; in wbcir_probe()
1086 data->dev->s_wakeup_filter = wbcir_set_wakeup_filter; in wbcir_probe()
1088 err = rc_register_device(data->dev); in wbcir_probe()
1092 if (!request_region(data->wbase, WAKEUP_IOMEM_LEN, DRVNAME)) { in wbcir_probe()
1094 data->wbase, data->wbase + WAKEUP_IOMEM_LEN - 1); in wbcir_probe()
1099 if (!request_region(data->ebase, EHFUNC_IOMEM_LEN, DRVNAME)) { in wbcir_probe()
1101 data->ebase, data->ebase + EHFUNC_IOMEM_LEN - 1); in wbcir_probe()
1106 if (!request_region(data->sbase, SP_IOMEM_LEN, DRVNAME)) { in wbcir_probe()
1108 data->sbase, data->sbase + SP_IOMEM_LEN - 1); in wbcir_probe()
1113 err = request_irq(data->irq, wbcir_irq_handler, in wbcir_probe()
1116 dev_err(dev, "Failed to claim IRQ %u\n", data->irq); in wbcir_probe()
1123 wbcir_init_hw(data); in wbcir_probe()
1128 release_region(data->sbase, SP_IOMEM_LEN); in wbcir_probe()
1130 release_region(data->ebase, EHFUNC_IOMEM_LEN); in wbcir_probe()
1132 release_region(data->wbase, WAKEUP_IOMEM_LEN); in wbcir_probe()
1134 rc_unregister_device(data->dev); in wbcir_probe()
1135 data->dev = NULL; in wbcir_probe()
1137 rc_free_device(data->dev); in wbcir_probe()
1139 led_classdev_unregister(&data->led); in wbcir_probe()
1141 kfree(data); in wbcir_probe()
1150 struct wbcir_data *data = pnp_get_drvdata(device); in wbcir_remove() local
1153 wbcir_set_irqmask(data, WBCIR_IRQ_NONE); in wbcir_remove()
1154 free_irq(data->irq, device); in wbcir_remove()
1157 wbcir_set_bits(data->wbase + WBCIR_REG_WCEIR_STS, 0x17, 0x17); in wbcir_remove()
1160 wbcir_set_bits(data->wbase + WBCIR_REG_WCEIR_CTL, 0x00, 0x01); in wbcir_remove()
1163 wbcir_set_bits(data->wbase + WBCIR_REG_WCEIR_EV_EN, 0x00, 0x07); in wbcir_remove()
1165 rc_unregister_device(data->dev); in wbcir_remove()
1167 led_classdev_unregister(&data->led); in wbcir_remove()
1170 wbcir_led_brightness_set(&data->led, LED_OFF); in wbcir_remove()
1172 release_region(data->wbase, WAKEUP_IOMEM_LEN); in wbcir_remove()
1173 release_region(data->ebase, EHFUNC_IOMEM_LEN); in wbcir_remove()
1174 release_region(data->sbase, SP_IOMEM_LEN); in wbcir_remove()
1176 kfree(data); in wbcir_remove()