123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245 |
- #include <linux/spinlock.h>
- #include <linux/ioctl.h>
- #define FINTEK_DRIVER_NAME "fintek-cir"
- #define FINTEK_DESCRIPTION "Fintek LPC SuperIO Consumer IR Transceiver"
- #define VENDOR_ID_FINTEK 0x1934
- static int debug;
- #define fit_pr(level, text, ...) \
- printk(level KBUILD_MODNAME ": " text, ## __VA_ARGS__)
- #define fit_dbg(text, ...) \
- if (debug) \
- printk(KERN_DEBUG \
- KBUILD_MODNAME ": " text "\n" , ## __VA_ARGS__)
- #define fit_dbg_verbose(text, ...) \
- if (debug > 1) \
- printk(KERN_DEBUG \
- KBUILD_MODNAME ": " text "\n" , ## __VA_ARGS__)
- #define fit_dbg_wake(text, ...) \
- if (debug > 2) \
- printk(KERN_DEBUG \
- KBUILD_MODNAME ": " text "\n" , ## __VA_ARGS__)
- #define TX_BUF_LEN 256
- #define RX_BUF_LEN 32
- struct fintek_dev {
- struct pnp_dev *pdev;
- struct rc_dev *rdev;
- spinlock_t fintek_lock;
-
- u8 buf[RX_BUF_LEN];
- unsigned int pkts;
- struct {
- spinlock_t lock;
- u8 buf[TX_BUF_LEN];
- unsigned int buf_count;
- unsigned int cur_buf_num;
- wait_queue_head_t queue;
- } tx;
-
- u32 cr_ip;
- u32 cr_dp;
-
- unsigned long cir_addr;
- int cir_irq;
- int cir_port_len;
-
- u8 chip_major;
- u8 chip_minor;
- u16 chip_vendor;
- u8 logical_dev_cir;
-
- bool hw_learning_capable;
- bool hw_tx_capable;
-
- bool learning_enabled;
- bool carrier_detect_enabled;
- enum {
- CMD_HEADER = 0,
- SUBCMD,
- CMD_DATA,
- PARSE_IRDATA,
- } parser_state;
- u8 cmd, rem;
-
- u32 carrier;
- };
- #define BUF_PULSE_BIT 0x80
- #define BUF_LEN_MASK 0x1f
- #define BUF_SAMPLE_MASK 0x7f
- #define BUF_COMMAND_HEADER 0x9f
- #define BUF_COMMAND_MASK 0xe0
- #define BUF_COMMAND_NULL 0x00
- #define BUF_HW_CMD_HEADER 0xff
- #define BUF_CMD_G_REVISION 0x0b
- #define BUF_CMD_S_CARRIER 0x06
- #define BUF_CMD_S_TIMEOUT 0x0c
- #define BUF_CMD_SIG_END 0x01
- #define BUF_CMD_S_TXMASK 0x08
- #define BUF_CMD_S_RXSENSOR 0x14
- #define BUF_RSP_PULSE_COUNT 0x15
- #define CIR_SAMPLE_PERIOD 50
- #define CR_INDEX_PORT 0x2e
- #define CR_DATA_PORT 0x2f
- #define CR_INDEX_PORT2 0x4e
- #define CR_DATA_PORT2 0x4f
- #define PORT_SEL_PORT_4E_EN 0x10
- #define CONFIG_REG_ENABLE 0x87
- #define CONFIG_REG_DISABLE 0xaa
- #define CHIP_ID_HIGH_F71809U 0x04
- #define CHIP_ID_LOW_F71809U 0x08
- #define GCR_SOFTWARE_RESET 0x02
- #define GCR_LOGICAL_DEV_NO 0x07
- #define GCR_CHIP_ID_HI 0x20
- #define GCR_CHIP_ID_LO 0x21
- #define GCR_VENDOR_ID_HI 0x23
- #define GCR_VENDOR_ID_LO 0x24
- #define GCR_CONFIG_PORT_SEL 0x25
- #define GCR_KBMOUSE_WAKEUP 0x27
- #define LOGICAL_DEV_DISABLE 0x00
- #define LOGICAL_DEV_ENABLE 0x01
- #define LOGICAL_DEV_CIR_REV1 0x05
- #define LOGICAL_DEV_CIR_REV2 0x08
- #define CIR_CR_COMMAND_INDEX 0x04
- #define CIR_CR_IRCS 0x05
- #define CIR_CR_COMMAND_DATA 0x06
- #define CIR_CR_CLASS 0x07
- #define CIR_CR_DEV_EN 0x30
- #define CIR_CR_BASE_ADDR_HI 0x60
- #define CIR_CR_BASE_ADDR_LO 0x61
- #define CIR_CR_IRQ_SEL 0x70
- #define CIR_CR_PSOUT_STATUS 0xf1
- #define CIR_CR_WAKE_KEY3_ADDR 0xf8
- #define CIR_CR_WAKE_KEY3_CODE 0xf9
- #define CIR_CR_WAKE_KEY3_DC 0xfa
- #define CIR_CR_WAKE_CONTROL 0xfb
- #define CIR_CR_WAKE_KEY12_ADDR 0xfc
- #define CIR_CR_WAKE_KEY4_ADDR 0xfd
- #define CIR_CR_WAKE_KEY5_ADDR 0xfe
- #define CLASS_RX_ONLY 0xff
- #define CLASS_RX_2TX 0x66
- #define CLASS_RX_1TX 0x33
- #define CIR_STATUS 0x00
- #define CIR_RX_DATA 0x01
- #define CIR_TX_CONTROL 0x02
- #define CIR_TX_DATA 0x03
- #define CIR_CONTROL 0x04
- #define LOGICAL_DEV_ACPI 0x01
- #define LDEV_ACPI_WAKE_EN_REG 0xe8
- #define ACPI_WAKE_EN_CIR_BIT 0x04
- #define LDEV_ACPI_PME_EN_REG 0xf0
- #define LDEV_ACPI_PME_CLR_REG 0xf1
- #define ACPI_PME_CIR_BIT 0x02
- #define LDEV_ACPI_STATE_REG 0xf4
- #define ACPI_STATE_CIR_BIT 0x20
- #define CIR_STATUS_IRQ_EN 0x80
- #define CIR_STATUS_TX_FINISH 0x08
- #define CIR_STATUS_TX_UNDERRUN 0x04
- #define CIR_STATUS_RX_TIMEOUT 0x02
- #define CIR_STATUS_RX_RECEIVE 0x01
- #define CIR_STATUS_IRQ_MASK 0x0f
- #define CIR_TX_CONTROL_TX_START 0x80
- #define CIR_TX_CONTROL_TX_END 0x40
|