1c942fddfSThomas Gleixner /* SPDX-License-Identifier: GPL-2.0-or-later */ 2620a32bbSJuan J. Garcia de Soria /* 3620a32bbSJuan J. Garcia de Soria * Driver for ITE Tech Inc. IT8712F/IT8512F CIR 4620a32bbSJuan J. Garcia de Soria * 5620a32bbSJuan J. Garcia de Soria * Copyright (C) 2010 Juan Jesús García de Soria <skandalfo@gmail.com> 6620a32bbSJuan J. Garcia de Soria */ 7620a32bbSJuan J. Garcia de Soria 8620a32bbSJuan J. Garcia de Soria /* platform driver name to register */ 9620a32bbSJuan J. Garcia de Soria #define ITE_DRIVER_NAME "ite-cir" 10620a32bbSJuan J. Garcia de Soria 11620a32bbSJuan J. Garcia de Soria /* FIFO sizes */ 12620a32bbSJuan J. Garcia de Soria #define ITE_TX_FIFO_LEN 32 13620a32bbSJuan J. Garcia de Soria #define ITE_RX_FIFO_LEN 32 14620a32bbSJuan J. Garcia de Soria 15620a32bbSJuan J. Garcia de Soria /* interrupt types */ 16620a32bbSJuan J. Garcia de Soria #define ITE_IRQ_TX_FIFO 1 17620a32bbSJuan J. Garcia de Soria #define ITE_IRQ_RX_FIFO 2 18620a32bbSJuan J. Garcia de Soria #define ITE_IRQ_RX_FIFO_OVERRUN 4 19620a32bbSJuan J. Garcia de Soria 20620a32bbSJuan J. Garcia de Soria /* forward declaration */ 21620a32bbSJuan J. Garcia de Soria struct ite_dev; 22620a32bbSJuan J. Garcia de Soria 23620a32bbSJuan J. Garcia de Soria /* struct for storing the parameters of different recognized devices */ 24620a32bbSJuan J. Garcia de Soria struct ite_dev_params { 25620a32bbSJuan J. Garcia de Soria /* model of the device */ 26620a32bbSJuan J. Garcia de Soria const char *model; 27620a32bbSJuan J. Garcia de Soria 28620a32bbSJuan J. Garcia de Soria /* size of the I/O region */ 29620a32bbSJuan J. Garcia de Soria int io_region_size; 30620a32bbSJuan J. Garcia de Soria 3135d136c8SJarod Wilson /* IR pnp I/O resource number */ 3235d136c8SJarod Wilson int io_rsrc_no; 3335d136c8SJarod Wilson 34620a32bbSJuan J. Garcia de Soria /* hw-specific operation function pointers; most of these must be 35620a32bbSJuan J. Garcia de Soria * called while holding the spin lock, except for the TX FIFO length 36620a32bbSJuan J. Garcia de Soria * one */ 37620a32bbSJuan J. Garcia de Soria /* get pending interrupt causes */ 38620a32bbSJuan J. Garcia de Soria int (*get_irq_causes) (struct ite_dev *dev); 39620a32bbSJuan J. Garcia de Soria 40620a32bbSJuan J. Garcia de Soria /* enable rx */ 41620a32bbSJuan J. Garcia de Soria void (*enable_rx) (struct ite_dev *dev); 42620a32bbSJuan J. Garcia de Soria 43620a32bbSJuan J. Garcia de Soria /* make rx enter the idle state; keep listening for a pulse, but stop 44620a32bbSJuan J. Garcia de Soria * streaming space bytes */ 45620a32bbSJuan J. Garcia de Soria void (*idle_rx) (struct ite_dev *dev); 46620a32bbSJuan J. Garcia de Soria 47620a32bbSJuan J. Garcia de Soria /* disable rx completely */ 48620a32bbSJuan J. Garcia de Soria void (*disable_rx) (struct ite_dev *dev); 49620a32bbSJuan J. Garcia de Soria 50620a32bbSJuan J. Garcia de Soria /* read bytes from RX FIFO; return read count */ 51620a32bbSJuan J. Garcia de Soria int (*get_rx_bytes) (struct ite_dev *dev, u8 *buf, int buf_size); 52620a32bbSJuan J. Garcia de Soria 53620a32bbSJuan J. Garcia de Soria /* enable tx FIFO space available interrupt */ 54620a32bbSJuan J. Garcia de Soria void (*enable_tx_interrupt) (struct ite_dev *dev); 55620a32bbSJuan J. Garcia de Soria 56620a32bbSJuan J. Garcia de Soria /* disable tx FIFO space available interrupt */ 57620a32bbSJuan J. Garcia de Soria void (*disable_tx_interrupt) (struct ite_dev *dev); 58620a32bbSJuan J. Garcia de Soria 59620a32bbSJuan J. Garcia de Soria /* get number of full TX FIFO slots */ 60620a32bbSJuan J. Garcia de Soria int (*get_tx_used_slots) (struct ite_dev *dev); 61620a32bbSJuan J. Garcia de Soria 62620a32bbSJuan J. Garcia de Soria /* put a byte to the TX FIFO */ 63620a32bbSJuan J. Garcia de Soria void (*put_tx_byte) (struct ite_dev *dev, u8 value); 64620a32bbSJuan J. Garcia de Soria 65620a32bbSJuan J. Garcia de Soria /* disable hardware completely */ 66620a32bbSJuan J. Garcia de Soria void (*disable) (struct ite_dev *dev); 67620a32bbSJuan J. Garcia de Soria 68620a32bbSJuan J. Garcia de Soria /* initialize the hardware */ 69620a32bbSJuan J. Garcia de Soria void (*init_hardware) (struct ite_dev *dev); 70620a32bbSJuan J. Garcia de Soria 71620a32bbSJuan J. Garcia de Soria /* set the carrier parameters */ 72620a32bbSJuan J. Garcia de Soria void (*set_carrier_params) (struct ite_dev *dev, bool high_freq, 73620a32bbSJuan J. Garcia de Soria bool use_demodulator, u8 carrier_freq_bits, 74620a32bbSJuan J. Garcia de Soria u8 allowance_bits, u8 pulse_width_bits); 75620a32bbSJuan J. Garcia de Soria }; 76620a32bbSJuan J. Garcia de Soria 77620a32bbSJuan J. Garcia de Soria /* ITE CIR device structure */ 78620a32bbSJuan J. Garcia de Soria struct ite_dev { 79620a32bbSJuan J. Garcia de Soria struct pnp_dev *pdev; 80620a32bbSJuan J. Garcia de Soria struct rc_dev *rdev; 81620a32bbSJuan J. Garcia de Soria 82620a32bbSJuan J. Garcia de Soria /* sync data */ 83620a32bbSJuan J. Garcia de Soria spinlock_t lock; 840ec694d6SSean Young bool transmitting; 85620a32bbSJuan J. Garcia de Soria 86620a32bbSJuan J. Garcia de Soria /* transmit support */ 87620a32bbSJuan J. Garcia de Soria wait_queue_head_t tx_queue, tx_ended; 88620a32bbSJuan J. Garcia de Soria 890b16cd57SSean Young /* rx low carrier frequency, in Hz, 0 means no demodulation */ 900b16cd57SSean Young unsigned int rx_low_carrier_freq; 910b16cd57SSean Young 920b16cd57SSean Young /* tx high carrier frequency, in Hz, 0 means no demodulation */ 930b16cd57SSean Young unsigned int rx_high_carrier_freq; 940b16cd57SSean Young 950b16cd57SSean Young /* tx carrier frequency, in Hz */ 960b16cd57SSean Young unsigned int tx_carrier_freq; 970b16cd57SSean Young 980b16cd57SSean Young /* duty cycle, 0-100 */ 990b16cd57SSean Young int tx_duty_cycle; 1000b16cd57SSean Young 101620a32bbSJuan J. Garcia de Soria /* hardware I/O settings */ 102620a32bbSJuan J. Garcia de Soria unsigned long cir_addr; 103620a32bbSJuan J. Garcia de Soria int cir_irq; 104620a32bbSJuan J. Garcia de Soria 105620a32bbSJuan J. Garcia de Soria /* overridable copy of model parameters */ 1060b16cd57SSean Young const struct ite_dev_params *params; 107620a32bbSJuan J. Garcia de Soria }; 108620a32bbSJuan J. Garcia de Soria 109620a32bbSJuan J. Garcia de Soria /* common values for all kinds of hardware */ 110620a32bbSJuan J. Garcia de Soria 111620a32bbSJuan J. Garcia de Soria /* baud rate divisor default */ 112620a32bbSJuan J. Garcia de Soria #define ITE_BAUDRATE_DIVISOR 1 113620a32bbSJuan J. Garcia de Soria 114620a32bbSJuan J. Garcia de Soria /* low-speed carrier frequency limits (Hz) */ 115620a32bbSJuan J. Garcia de Soria #define ITE_LCF_MIN_CARRIER_FREQ 27000 116620a32bbSJuan J. Garcia de Soria #define ITE_LCF_MAX_CARRIER_FREQ 58000 117620a32bbSJuan J. Garcia de Soria 118620a32bbSJuan J. Garcia de Soria /* high-speed carrier frequency limits (Hz) */ 119620a32bbSJuan J. Garcia de Soria #define ITE_HCF_MIN_CARRIER_FREQ 400000 120620a32bbSJuan J. Garcia de Soria #define ITE_HCF_MAX_CARRIER_FREQ 500000 121620a32bbSJuan J. Garcia de Soria 122620a32bbSJuan J. Garcia de Soria /* default carrier freq for when demodulator is off (Hz) */ 123620a32bbSJuan J. Garcia de Soria #define ITE_DEFAULT_CARRIER_FREQ 38000 124620a32bbSJuan J. Garcia de Soria 125620a32bbSJuan J. Garcia de Soria /* convert bits to us */ 126528222d8SSean Young #define ITE_BITS_TO_US(bits, sample_period) \ 127528222d8SSean Young ((u32)((bits) * ITE_BAUDRATE_DIVISOR * (sample_period) / 1000)) 128620a32bbSJuan J. Garcia de Soria 129620a32bbSJuan J. Garcia de Soria /* 130620a32bbSJuan J. Garcia de Soria * n in RDCR produces a tolerance of +/- n * 6.25% around the center 131620a32bbSJuan J. Garcia de Soria * carrier frequency... 132620a32bbSJuan J. Garcia de Soria * 133620a32bbSJuan J. Garcia de Soria * From two limit frequencies, L (low) and H (high), we can get both the 134620a32bbSJuan J. Garcia de Soria * center frequency F = (L + H) / 2 and the variation from the center 135620a32bbSJuan J. Garcia de Soria * frequency A = (H - L) / (H + L). We can use this in order to honor the 136620a32bbSJuan J. Garcia de Soria * s_rx_carrier_range() call in ir-core. We'll suppose that any request 137620a32bbSJuan J. Garcia de Soria * setting L=0 means we must shut down the demodulator. 138620a32bbSJuan J. Garcia de Soria */ 139620a32bbSJuan J. Garcia de Soria #define ITE_RXDCR_PER_10000_STEP 625 140620a32bbSJuan J. Garcia de Soria 141620a32bbSJuan J. Garcia de Soria /* high speed carrier freq values */ 142620a32bbSJuan J. Garcia de Soria #define ITE_CFQ_400 0x03 143620a32bbSJuan J. Garcia de Soria #define ITE_CFQ_450 0x08 144620a32bbSJuan J. Garcia de Soria #define ITE_CFQ_480 0x0b 145620a32bbSJuan J. Garcia de Soria #define ITE_CFQ_500 0x0d 146620a32bbSJuan J. Garcia de Soria 147620a32bbSJuan J. Garcia de Soria /* values for pulse widths */ 148620a32bbSJuan J. Garcia de Soria #define ITE_TXMPW_A 0x02 149620a32bbSJuan J. Garcia de Soria #define ITE_TXMPW_B 0x03 150620a32bbSJuan J. Garcia de Soria #define ITE_TXMPW_C 0x04 151620a32bbSJuan J. Garcia de Soria #define ITE_TXMPW_D 0x05 152620a32bbSJuan J. Garcia de Soria #define ITE_TXMPW_E 0x06 153620a32bbSJuan J. Garcia de Soria 154620a32bbSJuan J. Garcia de Soria /* values for demodulator carrier range allowance */ 155620a32bbSJuan J. Garcia de Soria #define ITE_RXDCR_DEFAULT 0x01 /* default carrier range */ 156620a32bbSJuan J. Garcia de Soria #define ITE_RXDCR_MAX 0x07 /* default carrier range */ 157620a32bbSJuan J. Garcia de Soria 158620a32bbSJuan J. Garcia de Soria /* DR TX bits */ 159620a32bbSJuan J. Garcia de Soria #define ITE_TX_PULSE 0x00 160620a32bbSJuan J. Garcia de Soria #define ITE_TX_SPACE 0x80 161620a32bbSJuan J. Garcia de Soria #define ITE_TX_MAX_RLE 0x80 162620a32bbSJuan J. Garcia de Soria #define ITE_TX_RLE_MASK 0x7f 163620a32bbSJuan J. Garcia de Soria 164620a32bbSJuan J. Garcia de Soria /* 165620a32bbSJuan J. Garcia de Soria * IT8712F 166620a32bbSJuan J. Garcia de Soria * 167620a32bbSJuan J. Garcia de Soria * hardware data obtained from: 168620a32bbSJuan J. Garcia de Soria * 169620a32bbSJuan J. Garcia de Soria * IT8712F 170*730f0556SMauro Carvalho Chehab * Environment Control - Low Pin Count Input / Output 171620a32bbSJuan J. Garcia de Soria * (EC - LPC I/O) 172620a32bbSJuan J. Garcia de Soria * Preliminary Specification V0. 81 173620a32bbSJuan J. Garcia de Soria */ 174620a32bbSJuan J. Garcia de Soria 175620a32bbSJuan J. Garcia de Soria /* register offsets */ 176620a32bbSJuan J. Garcia de Soria #define IT87_DR 0x00 /* data register */ 177620a32bbSJuan J. Garcia de Soria #define IT87_IER 0x01 /* interrupt enable register */ 178620a32bbSJuan J. Garcia de Soria #define IT87_RCR 0x02 /* receiver control register */ 179620a32bbSJuan J. Garcia de Soria #define IT87_TCR1 0x03 /* transmitter control register 1 */ 180620a32bbSJuan J. Garcia de Soria #define IT87_TCR2 0x04 /* transmitter control register 2 */ 181620a32bbSJuan J. Garcia de Soria #define IT87_TSR 0x05 /* transmitter status register */ 182620a32bbSJuan J. Garcia de Soria #define IT87_RSR 0x06 /* receiver status register */ 183620a32bbSJuan J. Garcia de Soria #define IT87_BDLR 0x05 /* baud rate divisor low byte register */ 184620a32bbSJuan J. Garcia de Soria #define IT87_BDHR 0x06 /* baud rate divisor high byte register */ 185620a32bbSJuan J. Garcia de Soria #define IT87_IIR 0x07 /* interrupt identification register */ 186620a32bbSJuan J. Garcia de Soria 187620a32bbSJuan J. Garcia de Soria #define IT87_IOREG_LENGTH 0x08 /* length of register file */ 188620a32bbSJuan J. Garcia de Soria 189620a32bbSJuan J. Garcia de Soria /* IER bits */ 190620a32bbSJuan J. Garcia de Soria #define IT87_TLDLIE 0x01 /* transmitter low data interrupt enable */ 191620a32bbSJuan J. Garcia de Soria #define IT87_RDAIE 0x02 /* receiver data available interrupt enable */ 192620a32bbSJuan J. Garcia de Soria #define IT87_RFOIE 0x04 /* receiver FIFO overrun interrupt enable */ 193620a32bbSJuan J. Garcia de Soria #define IT87_IEC 0x08 /* interrupt enable control */ 194620a32bbSJuan J. Garcia de Soria #define IT87_BR 0x10 /* baud rate register enable */ 195620a32bbSJuan J. Garcia de Soria #define IT87_RESET 0x20 /* reset */ 196620a32bbSJuan J. Garcia de Soria 197620a32bbSJuan J. Garcia de Soria /* RCR bits */ 198620a32bbSJuan J. Garcia de Soria #define IT87_RXDCR 0x07 /* receiver demodulation carrier range mask */ 199620a32bbSJuan J. Garcia de Soria #define IT87_RXACT 0x08 /* receiver active */ 200620a32bbSJuan J. Garcia de Soria #define IT87_RXEND 0x10 /* receiver demodulation enable */ 201620a32bbSJuan J. Garcia de Soria #define IT87_RXEN 0x20 /* receiver enable */ 202620a32bbSJuan J. Garcia de Soria #define IT87_HCFS 0x40 /* high-speed carrier frequency select */ 203620a32bbSJuan J. Garcia de Soria #define IT87_RDWOS 0x80 /* receiver data without sync */ 204620a32bbSJuan J. Garcia de Soria 205620a32bbSJuan J. Garcia de Soria /* TCR1 bits */ 206620a32bbSJuan J. Garcia de Soria #define IT87_TXMPM 0x03 /* transmitter modulation pulse mode mask */ 207620a32bbSJuan J. Garcia de Soria #define IT87_TXMPM_DEFAULT 0x00 /* modulation pulse mode default */ 208620a32bbSJuan J. Garcia de Soria #define IT87_TXENDF 0x04 /* transmitter deferral */ 209620a32bbSJuan J. Garcia de Soria #define IT87_TXRLE 0x08 /* transmitter run length enable */ 210620a32bbSJuan J. Garcia de Soria #define IT87_FIFOTL 0x30 /* FIFO level threshold mask */ 211620a32bbSJuan J. Garcia de Soria #define IT87_FIFOTL_DEFAULT 0x20 /* FIFO level threshold default 212620a32bbSJuan J. Garcia de Soria * 0x00 -> 1, 0x10 -> 7, 0x20 -> 17, 213620a32bbSJuan J. Garcia de Soria * 0x30 -> 25 */ 214620a32bbSJuan J. Garcia de Soria #define IT87_ILE 0x40 /* internal loopback enable */ 215620a32bbSJuan J. Garcia de Soria #define IT87_FIFOCLR 0x80 /* FIFO clear bit */ 216620a32bbSJuan J. Garcia de Soria 217620a32bbSJuan J. Garcia de Soria /* TCR2 bits */ 218620a32bbSJuan J. Garcia de Soria #define IT87_TXMPW 0x07 /* transmitter modulation pulse width mask */ 219620a32bbSJuan J. Garcia de Soria #define IT87_TXMPW_DEFAULT 0x04 /* default modulation pulse width */ 220620a32bbSJuan J. Garcia de Soria #define IT87_CFQ 0xf8 /* carrier frequency mask */ 221620a32bbSJuan J. Garcia de Soria #define IT87_CFQ_SHIFT 3 /* carrier frequency bit shift */ 222620a32bbSJuan J. Garcia de Soria 223620a32bbSJuan J. Garcia de Soria /* TSR bits */ 224620a32bbSJuan J. Garcia de Soria #define IT87_TXFBC 0x3f /* transmitter FIFO byte count mask */ 225620a32bbSJuan J. Garcia de Soria 226620a32bbSJuan J. Garcia de Soria /* RSR bits */ 227620a32bbSJuan J. Garcia de Soria #define IT87_RXFBC 0x3f /* receiver FIFO byte count mask */ 228620a32bbSJuan J. Garcia de Soria #define IT87_RXFTO 0x80 /* receiver FIFO time-out */ 229620a32bbSJuan J. Garcia de Soria 230620a32bbSJuan J. Garcia de Soria /* IIR bits */ 231620a32bbSJuan J. Garcia de Soria #define IT87_IP 0x01 /* interrupt pending */ 232620a32bbSJuan J. Garcia de Soria #define IT87_II 0x06 /* interrupt identification mask */ 233620a32bbSJuan J. Garcia de Soria #define IT87_II_NOINT 0x00 /* no interrupt */ 234620a32bbSJuan J. Garcia de Soria #define IT87_II_TXLDL 0x02 /* transmitter low data level */ 235620a32bbSJuan J. Garcia de Soria #define IT87_II_RXDS 0x04 /* receiver data stored */ 236620a32bbSJuan J. Garcia de Soria #define IT87_II_RXFO 0x06 /* receiver FIFO overrun */ 237620a32bbSJuan J. Garcia de Soria 238620a32bbSJuan J. Garcia de Soria /* 239620a32bbSJuan J. Garcia de Soria * IT8512E/F 240620a32bbSJuan J. Garcia de Soria * 241620a32bbSJuan J. Garcia de Soria * Hardware data obtained from: 242620a32bbSJuan J. Garcia de Soria * 243620a32bbSJuan J. Garcia de Soria * IT8512E/F 244620a32bbSJuan J. Garcia de Soria * Embedded Controller 245620a32bbSJuan J. Garcia de Soria * Preliminary Specification V0.4.1 246620a32bbSJuan J. Garcia de Soria * 247620a32bbSJuan J. Garcia de Soria * Note that the CIR registers are not directly available to the host, because 248620a32bbSJuan J. Garcia de Soria * they only are accessible to the integrated microcontroller. Thus, in order 249620a32bbSJuan J. Garcia de Soria * use it, some kind of bridging is required. As the bridging may depend on 250620a32bbSJuan J. Garcia de Soria * the controller firmware in use, we are going to use the PNP ID in order to 251620a32bbSJuan J. Garcia de Soria * determine the strategy and ports available. See after these generic 252620a32bbSJuan J. Garcia de Soria * IT8512E/F register definitions for register definitions for those 253620a32bbSJuan J. Garcia de Soria * strategies. 254620a32bbSJuan J. Garcia de Soria */ 255620a32bbSJuan J. Garcia de Soria 256620a32bbSJuan J. Garcia de Soria /* register offsets */ 257620a32bbSJuan J. Garcia de Soria #define IT85_C0DR 0x00 /* data register */ 258620a32bbSJuan J. Garcia de Soria #define IT85_C0MSTCR 0x01 /* master control register */ 259620a32bbSJuan J. Garcia de Soria #define IT85_C0IER 0x02 /* interrupt enable register */ 260620a32bbSJuan J. Garcia de Soria #define IT85_C0IIR 0x03 /* interrupt identification register */ 261620a32bbSJuan J. Garcia de Soria #define IT85_C0CFR 0x04 /* carrier frequency register */ 262620a32bbSJuan J. Garcia de Soria #define IT85_C0RCR 0x05 /* receiver control register */ 263620a32bbSJuan J. Garcia de Soria #define IT85_C0TCR 0x06 /* transmitter control register */ 264620a32bbSJuan J. Garcia de Soria #define IT85_C0SCK 0x07 /* slow clock control register */ 265620a32bbSJuan J. Garcia de Soria #define IT85_C0BDLR 0x08 /* baud rate divisor low byte register */ 266620a32bbSJuan J. Garcia de Soria #define IT85_C0BDHR 0x09 /* baud rate divisor high byte register */ 267620a32bbSJuan J. Garcia de Soria #define IT85_C0TFSR 0x0a /* transmitter FIFO status register */ 268620a32bbSJuan J. Garcia de Soria #define IT85_C0RFSR 0x0b /* receiver FIFO status register */ 269620a32bbSJuan J. Garcia de Soria #define IT85_C0WCL 0x0d /* wakeup code length register */ 270620a32bbSJuan J. Garcia de Soria #define IT85_C0WCR 0x0e /* wakeup code read/write register */ 271620a32bbSJuan J. Garcia de Soria #define IT85_C0WPS 0x0f /* wakeup power control/status register */ 272620a32bbSJuan J. Garcia de Soria 273620a32bbSJuan J. Garcia de Soria #define IT85_IOREG_LENGTH 0x10 /* length of register file */ 274620a32bbSJuan J. Garcia de Soria 275620a32bbSJuan J. Garcia de Soria /* C0MSTCR bits */ 276620a32bbSJuan J. Garcia de Soria #define IT85_RESET 0x01 /* reset */ 277620a32bbSJuan J. Garcia de Soria #define IT85_FIFOCLR 0x02 /* FIFO clear bit */ 278620a32bbSJuan J. Garcia de Soria #define IT85_FIFOTL 0x0c /* FIFO level threshold mask */ 279620a32bbSJuan J. Garcia de Soria #define IT85_FIFOTL_DEFAULT 0x08 /* FIFO level threshold default 280620a32bbSJuan J. Garcia de Soria * 0x00 -> 1, 0x04 -> 7, 0x08 -> 17, 281620a32bbSJuan J. Garcia de Soria * 0x0c -> 25 */ 282620a32bbSJuan J. Garcia de Soria #define IT85_ILE 0x10 /* internal loopback enable */ 283620a32bbSJuan J. Garcia de Soria #define IT85_ILSEL 0x20 /* internal loopback select */ 284620a32bbSJuan J. Garcia de Soria 285620a32bbSJuan J. Garcia de Soria /* C0IER bits */ 286620a32bbSJuan J. Garcia de Soria #define IT85_TLDLIE 0x01 /* TX low data level interrupt enable */ 287620a32bbSJuan J. Garcia de Soria #define IT85_RDAIE 0x02 /* RX data available interrupt enable */ 288620a32bbSJuan J. Garcia de Soria #define IT85_RFOIE 0x04 /* RX FIFO overrun interrupt enable */ 289620a32bbSJuan J. Garcia de Soria #define IT85_IEC 0x80 /* interrupt enable function control */ 290620a32bbSJuan J. Garcia de Soria 291620a32bbSJuan J. Garcia de Soria /* C0IIR bits */ 292620a32bbSJuan J. Garcia de Soria #define IT85_TLDLI 0x01 /* transmitter low data level interrupt */ 293620a32bbSJuan J. Garcia de Soria #define IT85_RDAI 0x02 /* receiver data available interrupt */ 294620a32bbSJuan J. Garcia de Soria #define IT85_RFOI 0x04 /* receiver FIFO overrun interrupt */ 295620a32bbSJuan J. Garcia de Soria #define IT85_NIP 0x80 /* no interrupt pending */ 296620a32bbSJuan J. Garcia de Soria 297620a32bbSJuan J. Garcia de Soria /* C0CFR bits */ 298620a32bbSJuan J. Garcia de Soria #define IT85_CFQ 0x1f /* carrier frequency mask */ 299620a32bbSJuan J. Garcia de Soria #define IT85_HCFS 0x20 /* high speed carrier frequency select */ 300620a32bbSJuan J. Garcia de Soria 301620a32bbSJuan J. Garcia de Soria /* C0RCR bits */ 302620a32bbSJuan J. Garcia de Soria #define IT85_RXDCR 0x07 /* receiver demodulation carrier range mask */ 303620a32bbSJuan J. Garcia de Soria #define IT85_RXACT 0x08 /* receiver active */ 304620a32bbSJuan J. Garcia de Soria #define IT85_RXEND 0x10 /* receiver demodulation enable */ 305620a32bbSJuan J. Garcia de Soria #define IT85_RDWOS 0x20 /* receiver data without sync */ 306620a32bbSJuan J. Garcia de Soria #define IT85_RXEN 0x80 /* receiver enable */ 307620a32bbSJuan J. Garcia de Soria 308620a32bbSJuan J. Garcia de Soria /* C0TCR bits */ 309620a32bbSJuan J. Garcia de Soria #define IT85_TXMPW 0x07 /* transmitter modulation pulse width mask */ 310620a32bbSJuan J. Garcia de Soria #define IT85_TXMPW_DEFAULT 0x04 /* default modulation pulse width */ 311620a32bbSJuan J. Garcia de Soria #define IT85_TXMPM 0x18 /* transmitter modulation pulse mode mask */ 312620a32bbSJuan J. Garcia de Soria #define IT85_TXMPM_DEFAULT 0x00 /* modulation pulse mode default */ 313620a32bbSJuan J. Garcia de Soria #define IT85_TXENDF 0x20 /* transmitter deferral */ 314620a32bbSJuan J. Garcia de Soria #define IT85_TXRLE 0x40 /* transmitter run length enable */ 315620a32bbSJuan J. Garcia de Soria 316620a32bbSJuan J. Garcia de Soria /* C0SCK bits */ 317620a32bbSJuan J. Garcia de Soria #define IT85_SCKS 0x01 /* slow clock select */ 318620a32bbSJuan J. Garcia de Soria #define IT85_TXDCKG 0x02 /* TXD clock gating */ 319620a32bbSJuan J. Garcia de Soria #define IT85_DLL1P8E 0x04 /* DLL 1.8432M enable */ 320620a32bbSJuan J. Garcia de Soria #define IT85_DLLTE 0x08 /* DLL test enable */ 321620a32bbSJuan J. Garcia de Soria #define IT85_BRCM 0x70 /* baud rate count mode */ 322620a32bbSJuan J. Garcia de Soria #define IT85_DLLOCK 0x80 /* DLL lock */ 323620a32bbSJuan J. Garcia de Soria 324620a32bbSJuan J. Garcia de Soria /* C0TFSR bits */ 325620a32bbSJuan J. Garcia de Soria #define IT85_TXFBC 0x3f /* transmitter FIFO count mask */ 326620a32bbSJuan J. Garcia de Soria 327620a32bbSJuan J. Garcia de Soria /* C0RFSR bits */ 328620a32bbSJuan J. Garcia de Soria #define IT85_RXFBC 0x3f /* receiver FIFO count mask */ 329620a32bbSJuan J. Garcia de Soria #define IT85_RXFTO 0x80 /* receiver FIFO time-out */ 330620a32bbSJuan J. Garcia de Soria 331620a32bbSJuan J. Garcia de Soria /* C0WCL bits */ 332620a32bbSJuan J. Garcia de Soria #define IT85_WCL 0x3f /* wakeup code length mask */ 333620a32bbSJuan J. Garcia de Soria 334620a32bbSJuan J. Garcia de Soria /* C0WPS bits */ 335620a32bbSJuan J. Garcia de Soria #define IT85_CIRPOSIE 0x01 /* power on/off status interrupt enable */ 336620a32bbSJuan J. Garcia de Soria #define IT85_CIRPOIS 0x02 /* power on/off interrupt status */ 337620a32bbSJuan J. Garcia de Soria #define IT85_CIRPOII 0x04 /* power on/off interrupt identification */ 338620a32bbSJuan J. Garcia de Soria #define IT85_RCRST 0x10 /* wakeup code reading counter reset bit */ 339620a32bbSJuan J. Garcia de Soria #define IT85_WCRST 0x20 /* wakeup code writing counter reset bit */ 340620a32bbSJuan J. Garcia de Soria 341620a32bbSJuan J. Garcia de Soria /* 342620a32bbSJuan J. Garcia de Soria * ITE8708 343620a32bbSJuan J. Garcia de Soria * 344620a32bbSJuan J. Garcia de Soria * Hardware data obtained from hacked driver for IT8512 in this forum post: 345620a32bbSJuan J. Garcia de Soria * 346620a32bbSJuan J. Garcia de Soria * http://ubuntuforums.org/showthread.php?t=1028640 347620a32bbSJuan J. Garcia de Soria * 348620a32bbSJuan J. Garcia de Soria * Although there's no official documentation for that driver, analysis would 349620a32bbSJuan J. Garcia de Soria * suggest that it maps the 16 registers of IT8512 onto two 8-register banks, 350620a32bbSJuan J. Garcia de Soria * selectable by a single bank-select bit that's mapped onto both banks. The 351620a32bbSJuan J. Garcia de Soria * IT8512 registers are mapped in a different order, so that the first bank 352620a32bbSJuan J. Garcia de Soria * maps the ones that are used more often, and two registers that share a 353620a32bbSJuan J. Garcia de Soria * reserved high-order bit are placed at the same offset in both banks in 354620a32bbSJuan J. Garcia de Soria * order to reuse the reserved bit as the bank select bit. 355620a32bbSJuan J. Garcia de Soria */ 356620a32bbSJuan J. Garcia de Soria 357620a32bbSJuan J. Garcia de Soria /* register offsets */ 358620a32bbSJuan J. Garcia de Soria 359620a32bbSJuan J. Garcia de Soria /* mapped onto both banks */ 360620a32bbSJuan J. Garcia de Soria #define IT8708_BANKSEL 0x07 /* bank select register */ 361620a32bbSJuan J. Garcia de Soria #define IT8708_HRAE 0x80 /* high registers access enable */ 362620a32bbSJuan J. Garcia de Soria 363620a32bbSJuan J. Garcia de Soria /* mapped onto the low bank */ 364620a32bbSJuan J. Garcia de Soria #define IT8708_C0DR 0x00 /* data register */ 365620a32bbSJuan J. Garcia de Soria #define IT8708_C0MSTCR 0x01 /* master control register */ 366620a32bbSJuan J. Garcia de Soria #define IT8708_C0IER 0x02 /* interrupt enable register */ 367620a32bbSJuan J. Garcia de Soria #define IT8708_C0IIR 0x03 /* interrupt identification register */ 368620a32bbSJuan J. Garcia de Soria #define IT8708_C0RFSR 0x04 /* receiver FIFO status register */ 369620a32bbSJuan J. Garcia de Soria #define IT8708_C0RCR 0x05 /* receiver control register */ 370620a32bbSJuan J. Garcia de Soria #define IT8708_C0TFSR 0x06 /* transmitter FIFO status register */ 371620a32bbSJuan J. Garcia de Soria #define IT8708_C0TCR 0x07 /* transmitter control register */ 372620a32bbSJuan J. Garcia de Soria 373620a32bbSJuan J. Garcia de Soria /* mapped onto the high bank */ 374620a32bbSJuan J. Garcia de Soria #define IT8708_C0BDLR 0x01 /* baud rate divisor low byte register */ 375620a32bbSJuan J. Garcia de Soria #define IT8708_C0BDHR 0x02 /* baud rate divisor high byte register */ 376620a32bbSJuan J. Garcia de Soria #define IT8708_C0CFR 0x04 /* carrier frequency register */ 377620a32bbSJuan J. Garcia de Soria 378620a32bbSJuan J. Garcia de Soria /* registers whose bank mapping we don't know, since they weren't being used 379620a32bbSJuan J. Garcia de Soria * in the hacked driver... most probably they belong to the high bank too, 380620a32bbSJuan J. Garcia de Soria * since they fit in the holes the other registers leave */ 381620a32bbSJuan J. Garcia de Soria #define IT8708_C0SCK 0x03 /* slow clock control register */ 382620a32bbSJuan J. Garcia de Soria #define IT8708_C0WCL 0x05 /* wakeup code length register */ 383620a32bbSJuan J. Garcia de Soria #define IT8708_C0WCR 0x06 /* wakeup code read/write register */ 384620a32bbSJuan J. Garcia de Soria #define IT8708_C0WPS 0x07 /* wakeup power control/status register */ 385620a32bbSJuan J. Garcia de Soria 386620a32bbSJuan J. Garcia de Soria #define IT8708_IOREG_LENGTH 0x08 /* length of register file */ 387620a32bbSJuan J. Garcia de Soria 388620a32bbSJuan J. Garcia de Soria /* two more registers that are defined in the hacked driver, but can't be 389620a32bbSJuan J. Garcia de Soria * found in the data sheets; no idea what they are or how they are accessed, 390620a32bbSJuan J. Garcia de Soria * since the hacked driver doesn't seem to use them */ 391620a32bbSJuan J. Garcia de Soria #define IT8708_CSCRR 0x00 392620a32bbSJuan J. Garcia de Soria #define IT8708_CGPINTR 0x01 393620a32bbSJuan J. Garcia de Soria 394620a32bbSJuan J. Garcia de Soria /* CSCRR bits */ 395620a32bbSJuan J. Garcia de Soria #define IT8708_CSCRR_SCRB 0x3f 396620a32bbSJuan J. Garcia de Soria #define IT8708_CSCRR_PM 0x80 397620a32bbSJuan J. Garcia de Soria 398620a32bbSJuan J. Garcia de Soria /* CGPINTR bits */ 399620a32bbSJuan J. Garcia de Soria #define IT8708_CGPINT 0x01 400620a32bbSJuan J. Garcia de Soria 401620a32bbSJuan J. Garcia de Soria /* 402620a32bbSJuan J. Garcia de Soria * ITE8709 403620a32bbSJuan J. Garcia de Soria * 404620a32bbSJuan J. Garcia de Soria * Hardware interfacing data obtained from the original lirc_ite8709 driver. 405620a32bbSJuan J. Garcia de Soria * Verbatim from its sources: 406620a32bbSJuan J. Garcia de Soria * 407620a32bbSJuan J. Garcia de Soria * The ITE8709 device seems to be the combination of IT8512 superIO chip and 408620a32bbSJuan J. Garcia de Soria * a specific firmware running on the IT8512's embedded micro-controller. 409620a32bbSJuan J. Garcia de Soria * In addition of the embedded micro-controller, the IT8512 chip contains a 410620a32bbSJuan J. Garcia de Soria * CIR module and several other modules. A few modules are directly accessible 411620a32bbSJuan J. Garcia de Soria * by the host CPU, but most of them are only accessible by the 412620a32bbSJuan J. Garcia de Soria * micro-controller. The CIR module is only accessible by the 413620a32bbSJuan J. Garcia de Soria * micro-controller. 414620a32bbSJuan J. Garcia de Soria * 415620a32bbSJuan J. Garcia de Soria * The battery-backed SRAM module is accessible by the host CPU and the 416620a32bbSJuan J. Garcia de Soria * micro-controller. So one of the MC's firmware role is to act as a bridge 417620a32bbSJuan J. Garcia de Soria * between the host CPU and the CIR module. The firmware implements a kind of 418620a32bbSJuan J. Garcia de Soria * communication protocol using the SRAM module as a shared memory. The IT8512 419620a32bbSJuan J. Garcia de Soria * specification is publicly available on ITE's web site, but the 420620a32bbSJuan J. Garcia de Soria * communication protocol is not, so it was reverse-engineered. 421620a32bbSJuan J. Garcia de Soria */ 422620a32bbSJuan J. Garcia de Soria 423620a32bbSJuan J. Garcia de Soria /* register offsets */ 424620a32bbSJuan J. Garcia de Soria #define IT8709_RAM_IDX 0x00 /* index into the SRAM module bytes */ 425620a32bbSJuan J. Garcia de Soria #define IT8709_RAM_VAL 0x01 /* read/write data to the indexed byte */ 426620a32bbSJuan J. Garcia de Soria 427620a32bbSJuan J. Garcia de Soria #define IT8709_IOREG_LENGTH 0x02 /* length of register file */ 428620a32bbSJuan J. Garcia de Soria 429620a32bbSJuan J. Garcia de Soria /* register offsets inside the SRAM module */ 430620a32bbSJuan J. Garcia de Soria #define IT8709_MODE 0x1a /* request/ack byte */ 431620a32bbSJuan J. Garcia de Soria #define IT8709_REG_IDX 0x1b /* index of the CIR register to access */ 432620a32bbSJuan J. Garcia de Soria #define IT8709_REG_VAL 0x1c /* value read/to be written */ 433620a32bbSJuan J. Garcia de Soria #define IT8709_IIR 0x1e /* interrupt identification register */ 434620a32bbSJuan J. Garcia de Soria #define IT8709_RFSR 0x1f /* receiver FIFO status register */ 435620a32bbSJuan J. Garcia de Soria #define IT8709_FIFO 0x20 /* start of in RAM RX FIFO copy */ 436620a32bbSJuan J. Garcia de Soria 437620a32bbSJuan J. Garcia de Soria /* MODE values */ 438620a32bbSJuan J. Garcia de Soria #define IT8709_IDLE 0x00 439620a32bbSJuan J. Garcia de Soria #define IT8709_WRITE 0x01 440620a32bbSJuan J. Garcia de Soria #define IT8709_READ 0x02 441