1*4882a593Smuzhiyun /* SPDX-License-Identifier: GPL-2.0-or-later */ 2*4882a593Smuzhiyun /* 3*4882a593Smuzhiyun * Driver for ITE Tech Inc. IT8712F/IT8512F CIR 4*4882a593Smuzhiyun * 5*4882a593Smuzhiyun * Copyright (C) 2010 Juan Jesús García de Soria <skandalfo@gmail.com> 6*4882a593Smuzhiyun */ 7*4882a593Smuzhiyun 8*4882a593Smuzhiyun /* platform driver name to register */ 9*4882a593Smuzhiyun #define ITE_DRIVER_NAME "ite-cir" 10*4882a593Smuzhiyun 11*4882a593Smuzhiyun /* logging macros */ 12*4882a593Smuzhiyun #define ite_pr(level, text, ...) \ 13*4882a593Smuzhiyun printk(level KBUILD_MODNAME ": " text, ## __VA_ARGS__) 14*4882a593Smuzhiyun #define ite_dbg(text, ...) do { \ 15*4882a593Smuzhiyun if (debug) \ 16*4882a593Smuzhiyun printk(KERN_DEBUG \ 17*4882a593Smuzhiyun KBUILD_MODNAME ": " text "\n" , ## __VA_ARGS__); \ 18*4882a593Smuzhiyun } while (0) 19*4882a593Smuzhiyun 20*4882a593Smuzhiyun #define ite_dbg_verbose(text, ...) do {\ 21*4882a593Smuzhiyun if (debug > 1) \ 22*4882a593Smuzhiyun printk(KERN_DEBUG \ 23*4882a593Smuzhiyun KBUILD_MODNAME ": " text "\n" , ## __VA_ARGS__); \ 24*4882a593Smuzhiyun } while (0) 25*4882a593Smuzhiyun 26*4882a593Smuzhiyun /* FIFO sizes */ 27*4882a593Smuzhiyun #define ITE_TX_FIFO_LEN 32 28*4882a593Smuzhiyun #define ITE_RX_FIFO_LEN 32 29*4882a593Smuzhiyun 30*4882a593Smuzhiyun /* interrupt types */ 31*4882a593Smuzhiyun #define ITE_IRQ_TX_FIFO 1 32*4882a593Smuzhiyun #define ITE_IRQ_RX_FIFO 2 33*4882a593Smuzhiyun #define ITE_IRQ_RX_FIFO_OVERRUN 4 34*4882a593Smuzhiyun 35*4882a593Smuzhiyun /* forward declaration */ 36*4882a593Smuzhiyun struct ite_dev; 37*4882a593Smuzhiyun 38*4882a593Smuzhiyun /* struct for storing the parameters of different recognized devices */ 39*4882a593Smuzhiyun struct ite_dev_params { 40*4882a593Smuzhiyun /* model of the device */ 41*4882a593Smuzhiyun const char *model; 42*4882a593Smuzhiyun 43*4882a593Smuzhiyun /* size of the I/O region */ 44*4882a593Smuzhiyun int io_region_size; 45*4882a593Smuzhiyun 46*4882a593Smuzhiyun /* IR pnp I/O resource number */ 47*4882a593Smuzhiyun int io_rsrc_no; 48*4882a593Smuzhiyun 49*4882a593Smuzhiyun /* true if the hardware supports transmission */ 50*4882a593Smuzhiyun bool hw_tx_capable; 51*4882a593Smuzhiyun 52*4882a593Smuzhiyun /* base sampling period, in ns */ 53*4882a593Smuzhiyun u32 sample_period; 54*4882a593Smuzhiyun 55*4882a593Smuzhiyun /* rx low carrier frequency, in Hz, 0 means no demodulation */ 56*4882a593Smuzhiyun unsigned int rx_low_carrier_freq; 57*4882a593Smuzhiyun 58*4882a593Smuzhiyun /* tx high carrier frequency, in Hz, 0 means no demodulation */ 59*4882a593Smuzhiyun unsigned int rx_high_carrier_freq; 60*4882a593Smuzhiyun 61*4882a593Smuzhiyun /* tx carrier frequency, in Hz */ 62*4882a593Smuzhiyun unsigned int tx_carrier_freq; 63*4882a593Smuzhiyun 64*4882a593Smuzhiyun /* duty cycle, 0-100 */ 65*4882a593Smuzhiyun int tx_duty_cycle; 66*4882a593Smuzhiyun 67*4882a593Smuzhiyun /* hw-specific operation function pointers; most of these must be 68*4882a593Smuzhiyun * called while holding the spin lock, except for the TX FIFO length 69*4882a593Smuzhiyun * one */ 70*4882a593Smuzhiyun /* get pending interrupt causes */ 71*4882a593Smuzhiyun int (*get_irq_causes) (struct ite_dev *dev); 72*4882a593Smuzhiyun 73*4882a593Smuzhiyun /* enable rx */ 74*4882a593Smuzhiyun void (*enable_rx) (struct ite_dev *dev); 75*4882a593Smuzhiyun 76*4882a593Smuzhiyun /* make rx enter the idle state; keep listening for a pulse, but stop 77*4882a593Smuzhiyun * streaming space bytes */ 78*4882a593Smuzhiyun void (*idle_rx) (struct ite_dev *dev); 79*4882a593Smuzhiyun 80*4882a593Smuzhiyun /* disable rx completely */ 81*4882a593Smuzhiyun void (*disable_rx) (struct ite_dev *dev); 82*4882a593Smuzhiyun 83*4882a593Smuzhiyun /* read bytes from RX FIFO; return read count */ 84*4882a593Smuzhiyun int (*get_rx_bytes) (struct ite_dev *dev, u8 *buf, int buf_size); 85*4882a593Smuzhiyun 86*4882a593Smuzhiyun /* enable tx FIFO space available interrupt */ 87*4882a593Smuzhiyun void (*enable_tx_interrupt) (struct ite_dev *dev); 88*4882a593Smuzhiyun 89*4882a593Smuzhiyun /* disable tx FIFO space available interrupt */ 90*4882a593Smuzhiyun void (*disable_tx_interrupt) (struct ite_dev *dev); 91*4882a593Smuzhiyun 92*4882a593Smuzhiyun /* get number of full TX FIFO slots */ 93*4882a593Smuzhiyun int (*get_tx_used_slots) (struct ite_dev *dev); 94*4882a593Smuzhiyun 95*4882a593Smuzhiyun /* put a byte to the TX FIFO */ 96*4882a593Smuzhiyun void (*put_tx_byte) (struct ite_dev *dev, u8 value); 97*4882a593Smuzhiyun 98*4882a593Smuzhiyun /* disable hardware completely */ 99*4882a593Smuzhiyun void (*disable) (struct ite_dev *dev); 100*4882a593Smuzhiyun 101*4882a593Smuzhiyun /* initialize the hardware */ 102*4882a593Smuzhiyun void (*init_hardware) (struct ite_dev *dev); 103*4882a593Smuzhiyun 104*4882a593Smuzhiyun /* set the carrier parameters */ 105*4882a593Smuzhiyun void (*set_carrier_params) (struct ite_dev *dev, bool high_freq, 106*4882a593Smuzhiyun bool use_demodulator, u8 carrier_freq_bits, 107*4882a593Smuzhiyun u8 allowance_bits, u8 pulse_width_bits); 108*4882a593Smuzhiyun }; 109*4882a593Smuzhiyun 110*4882a593Smuzhiyun /* ITE CIR device structure */ 111*4882a593Smuzhiyun struct ite_dev { 112*4882a593Smuzhiyun struct pnp_dev *pdev; 113*4882a593Smuzhiyun struct rc_dev *rdev; 114*4882a593Smuzhiyun struct ir_raw_event rawir; 115*4882a593Smuzhiyun 116*4882a593Smuzhiyun /* sync data */ 117*4882a593Smuzhiyun spinlock_t lock; 118*4882a593Smuzhiyun bool in_use, transmitting; 119*4882a593Smuzhiyun 120*4882a593Smuzhiyun /* transmit support */ 121*4882a593Smuzhiyun int tx_fifo_allowance; 122*4882a593Smuzhiyun wait_queue_head_t tx_queue, tx_ended; 123*4882a593Smuzhiyun 124*4882a593Smuzhiyun /* hardware I/O settings */ 125*4882a593Smuzhiyun unsigned long cir_addr; 126*4882a593Smuzhiyun int cir_irq; 127*4882a593Smuzhiyun 128*4882a593Smuzhiyun /* overridable copy of model parameters */ 129*4882a593Smuzhiyun struct ite_dev_params params; 130*4882a593Smuzhiyun }; 131*4882a593Smuzhiyun 132*4882a593Smuzhiyun /* common values for all kinds of hardware */ 133*4882a593Smuzhiyun 134*4882a593Smuzhiyun /* baud rate divisor default */ 135*4882a593Smuzhiyun #define ITE_BAUDRATE_DIVISOR 1 136*4882a593Smuzhiyun 137*4882a593Smuzhiyun /* low-speed carrier frequency limits (Hz) */ 138*4882a593Smuzhiyun #define ITE_LCF_MIN_CARRIER_FREQ 27000 139*4882a593Smuzhiyun #define ITE_LCF_MAX_CARRIER_FREQ 58000 140*4882a593Smuzhiyun 141*4882a593Smuzhiyun /* high-speed carrier frequency limits (Hz) */ 142*4882a593Smuzhiyun #define ITE_HCF_MIN_CARRIER_FREQ 400000 143*4882a593Smuzhiyun #define ITE_HCF_MAX_CARRIER_FREQ 500000 144*4882a593Smuzhiyun 145*4882a593Smuzhiyun /* default carrier freq for when demodulator is off (Hz) */ 146*4882a593Smuzhiyun #define ITE_DEFAULT_CARRIER_FREQ 38000 147*4882a593Smuzhiyun 148*4882a593Smuzhiyun /* convert bits to us */ 149*4882a593Smuzhiyun #define ITE_BITS_TO_US(bits, sample_period) \ 150*4882a593Smuzhiyun ((u32)((bits) * ITE_BAUDRATE_DIVISOR * (sample_period) / 1000)) 151*4882a593Smuzhiyun 152*4882a593Smuzhiyun /* 153*4882a593Smuzhiyun * n in RDCR produces a tolerance of +/- n * 6.25% around the center 154*4882a593Smuzhiyun * carrier frequency... 155*4882a593Smuzhiyun * 156*4882a593Smuzhiyun * From two limit frequencies, L (low) and H (high), we can get both the 157*4882a593Smuzhiyun * center frequency F = (L + H) / 2 and the variation from the center 158*4882a593Smuzhiyun * frequency A = (H - L) / (H + L). We can use this in order to honor the 159*4882a593Smuzhiyun * s_rx_carrier_range() call in ir-core. We'll suppose that any request 160*4882a593Smuzhiyun * setting L=0 means we must shut down the demodulator. 161*4882a593Smuzhiyun */ 162*4882a593Smuzhiyun #define ITE_RXDCR_PER_10000_STEP 625 163*4882a593Smuzhiyun 164*4882a593Smuzhiyun /* high speed carrier freq values */ 165*4882a593Smuzhiyun #define ITE_CFQ_400 0x03 166*4882a593Smuzhiyun #define ITE_CFQ_450 0x08 167*4882a593Smuzhiyun #define ITE_CFQ_480 0x0b 168*4882a593Smuzhiyun #define ITE_CFQ_500 0x0d 169*4882a593Smuzhiyun 170*4882a593Smuzhiyun /* values for pulse widths */ 171*4882a593Smuzhiyun #define ITE_TXMPW_A 0x02 172*4882a593Smuzhiyun #define ITE_TXMPW_B 0x03 173*4882a593Smuzhiyun #define ITE_TXMPW_C 0x04 174*4882a593Smuzhiyun #define ITE_TXMPW_D 0x05 175*4882a593Smuzhiyun #define ITE_TXMPW_E 0x06 176*4882a593Smuzhiyun 177*4882a593Smuzhiyun /* values for demodulator carrier range allowance */ 178*4882a593Smuzhiyun #define ITE_RXDCR_DEFAULT 0x01 /* default carrier range */ 179*4882a593Smuzhiyun #define ITE_RXDCR_MAX 0x07 /* default carrier range */ 180*4882a593Smuzhiyun 181*4882a593Smuzhiyun /* DR TX bits */ 182*4882a593Smuzhiyun #define ITE_TX_PULSE 0x00 183*4882a593Smuzhiyun #define ITE_TX_SPACE 0x80 184*4882a593Smuzhiyun #define ITE_TX_MAX_RLE 0x80 185*4882a593Smuzhiyun #define ITE_TX_RLE_MASK 0x7f 186*4882a593Smuzhiyun 187*4882a593Smuzhiyun /* 188*4882a593Smuzhiyun * IT8712F 189*4882a593Smuzhiyun * 190*4882a593Smuzhiyun * hardware data obtained from: 191*4882a593Smuzhiyun * 192*4882a593Smuzhiyun * IT8712F 193*4882a593Smuzhiyun * Environment Control – Low Pin Count Input / Output 194*4882a593Smuzhiyun * (EC - LPC I/O) 195*4882a593Smuzhiyun * Preliminary Specification V0. 81 196*4882a593Smuzhiyun */ 197*4882a593Smuzhiyun 198*4882a593Smuzhiyun /* register offsets */ 199*4882a593Smuzhiyun #define IT87_DR 0x00 /* data register */ 200*4882a593Smuzhiyun #define IT87_IER 0x01 /* interrupt enable register */ 201*4882a593Smuzhiyun #define IT87_RCR 0x02 /* receiver control register */ 202*4882a593Smuzhiyun #define IT87_TCR1 0x03 /* transmitter control register 1 */ 203*4882a593Smuzhiyun #define IT87_TCR2 0x04 /* transmitter control register 2 */ 204*4882a593Smuzhiyun #define IT87_TSR 0x05 /* transmitter status register */ 205*4882a593Smuzhiyun #define IT87_RSR 0x06 /* receiver status register */ 206*4882a593Smuzhiyun #define IT87_BDLR 0x05 /* baud rate divisor low byte register */ 207*4882a593Smuzhiyun #define IT87_BDHR 0x06 /* baud rate divisor high byte register */ 208*4882a593Smuzhiyun #define IT87_IIR 0x07 /* interrupt identification register */ 209*4882a593Smuzhiyun 210*4882a593Smuzhiyun #define IT87_IOREG_LENGTH 0x08 /* length of register file */ 211*4882a593Smuzhiyun 212*4882a593Smuzhiyun /* IER bits */ 213*4882a593Smuzhiyun #define IT87_TLDLIE 0x01 /* transmitter low data interrupt enable */ 214*4882a593Smuzhiyun #define IT87_RDAIE 0x02 /* receiver data available interrupt enable */ 215*4882a593Smuzhiyun #define IT87_RFOIE 0x04 /* receiver FIFO overrun interrupt enable */ 216*4882a593Smuzhiyun #define IT87_IEC 0x08 /* interrupt enable control */ 217*4882a593Smuzhiyun #define IT87_BR 0x10 /* baud rate register enable */ 218*4882a593Smuzhiyun #define IT87_RESET 0x20 /* reset */ 219*4882a593Smuzhiyun 220*4882a593Smuzhiyun /* RCR bits */ 221*4882a593Smuzhiyun #define IT87_RXDCR 0x07 /* receiver demodulation carrier range mask */ 222*4882a593Smuzhiyun #define IT87_RXACT 0x08 /* receiver active */ 223*4882a593Smuzhiyun #define IT87_RXEND 0x10 /* receiver demodulation enable */ 224*4882a593Smuzhiyun #define IT87_RXEN 0x20 /* receiver enable */ 225*4882a593Smuzhiyun #define IT87_HCFS 0x40 /* high-speed carrier frequency select */ 226*4882a593Smuzhiyun #define IT87_RDWOS 0x80 /* receiver data without sync */ 227*4882a593Smuzhiyun 228*4882a593Smuzhiyun /* TCR1 bits */ 229*4882a593Smuzhiyun #define IT87_TXMPM 0x03 /* transmitter modulation pulse mode mask */ 230*4882a593Smuzhiyun #define IT87_TXMPM_DEFAULT 0x00 /* modulation pulse mode default */ 231*4882a593Smuzhiyun #define IT87_TXENDF 0x04 /* transmitter deferral */ 232*4882a593Smuzhiyun #define IT87_TXRLE 0x08 /* transmitter run length enable */ 233*4882a593Smuzhiyun #define IT87_FIFOTL 0x30 /* FIFO level threshold mask */ 234*4882a593Smuzhiyun #define IT87_FIFOTL_DEFAULT 0x20 /* FIFO level threshold default 235*4882a593Smuzhiyun * 0x00 -> 1, 0x10 -> 7, 0x20 -> 17, 236*4882a593Smuzhiyun * 0x30 -> 25 */ 237*4882a593Smuzhiyun #define IT87_ILE 0x40 /* internal loopback enable */ 238*4882a593Smuzhiyun #define IT87_FIFOCLR 0x80 /* FIFO clear bit */ 239*4882a593Smuzhiyun 240*4882a593Smuzhiyun /* TCR2 bits */ 241*4882a593Smuzhiyun #define IT87_TXMPW 0x07 /* transmitter modulation pulse width mask */ 242*4882a593Smuzhiyun #define IT87_TXMPW_DEFAULT 0x04 /* default modulation pulse width */ 243*4882a593Smuzhiyun #define IT87_CFQ 0xf8 /* carrier frequency mask */ 244*4882a593Smuzhiyun #define IT87_CFQ_SHIFT 3 /* carrier frequency bit shift */ 245*4882a593Smuzhiyun 246*4882a593Smuzhiyun /* TSR bits */ 247*4882a593Smuzhiyun #define IT87_TXFBC 0x3f /* transmitter FIFO byte count mask */ 248*4882a593Smuzhiyun 249*4882a593Smuzhiyun /* RSR bits */ 250*4882a593Smuzhiyun #define IT87_RXFBC 0x3f /* receiver FIFO byte count mask */ 251*4882a593Smuzhiyun #define IT87_RXFTO 0x80 /* receiver FIFO time-out */ 252*4882a593Smuzhiyun 253*4882a593Smuzhiyun /* IIR bits */ 254*4882a593Smuzhiyun #define IT87_IP 0x01 /* interrupt pending */ 255*4882a593Smuzhiyun #define IT87_II 0x06 /* interrupt identification mask */ 256*4882a593Smuzhiyun #define IT87_II_NOINT 0x00 /* no interrupt */ 257*4882a593Smuzhiyun #define IT87_II_TXLDL 0x02 /* transmitter low data level */ 258*4882a593Smuzhiyun #define IT87_II_RXDS 0x04 /* receiver data stored */ 259*4882a593Smuzhiyun #define IT87_II_RXFO 0x06 /* receiver FIFO overrun */ 260*4882a593Smuzhiyun 261*4882a593Smuzhiyun /* 262*4882a593Smuzhiyun * IT8512E/F 263*4882a593Smuzhiyun * 264*4882a593Smuzhiyun * Hardware data obtained from: 265*4882a593Smuzhiyun * 266*4882a593Smuzhiyun * IT8512E/F 267*4882a593Smuzhiyun * Embedded Controller 268*4882a593Smuzhiyun * Preliminary Specification V0.4.1 269*4882a593Smuzhiyun * 270*4882a593Smuzhiyun * Note that the CIR registers are not directly available to the host, because 271*4882a593Smuzhiyun * they only are accessible to the integrated microcontroller. Thus, in order 272*4882a593Smuzhiyun * use it, some kind of bridging is required. As the bridging may depend on 273*4882a593Smuzhiyun * the controller firmware in use, we are going to use the PNP ID in order to 274*4882a593Smuzhiyun * determine the strategy and ports available. See after these generic 275*4882a593Smuzhiyun * IT8512E/F register definitions for register definitions for those 276*4882a593Smuzhiyun * strategies. 277*4882a593Smuzhiyun */ 278*4882a593Smuzhiyun 279*4882a593Smuzhiyun /* register offsets */ 280*4882a593Smuzhiyun #define IT85_C0DR 0x00 /* data register */ 281*4882a593Smuzhiyun #define IT85_C0MSTCR 0x01 /* master control register */ 282*4882a593Smuzhiyun #define IT85_C0IER 0x02 /* interrupt enable register */ 283*4882a593Smuzhiyun #define IT85_C0IIR 0x03 /* interrupt identification register */ 284*4882a593Smuzhiyun #define IT85_C0CFR 0x04 /* carrier frequency register */ 285*4882a593Smuzhiyun #define IT85_C0RCR 0x05 /* receiver control register */ 286*4882a593Smuzhiyun #define IT85_C0TCR 0x06 /* transmitter control register */ 287*4882a593Smuzhiyun #define IT85_C0SCK 0x07 /* slow clock control register */ 288*4882a593Smuzhiyun #define IT85_C0BDLR 0x08 /* baud rate divisor low byte register */ 289*4882a593Smuzhiyun #define IT85_C0BDHR 0x09 /* baud rate divisor high byte register */ 290*4882a593Smuzhiyun #define IT85_C0TFSR 0x0a /* transmitter FIFO status register */ 291*4882a593Smuzhiyun #define IT85_C0RFSR 0x0b /* receiver FIFO status register */ 292*4882a593Smuzhiyun #define IT85_C0WCL 0x0d /* wakeup code length register */ 293*4882a593Smuzhiyun #define IT85_C0WCR 0x0e /* wakeup code read/write register */ 294*4882a593Smuzhiyun #define IT85_C0WPS 0x0f /* wakeup power control/status register */ 295*4882a593Smuzhiyun 296*4882a593Smuzhiyun #define IT85_IOREG_LENGTH 0x10 /* length of register file */ 297*4882a593Smuzhiyun 298*4882a593Smuzhiyun /* C0MSTCR bits */ 299*4882a593Smuzhiyun #define IT85_RESET 0x01 /* reset */ 300*4882a593Smuzhiyun #define IT85_FIFOCLR 0x02 /* FIFO clear bit */ 301*4882a593Smuzhiyun #define IT85_FIFOTL 0x0c /* FIFO level threshold mask */ 302*4882a593Smuzhiyun #define IT85_FIFOTL_DEFAULT 0x08 /* FIFO level threshold default 303*4882a593Smuzhiyun * 0x00 -> 1, 0x04 -> 7, 0x08 -> 17, 304*4882a593Smuzhiyun * 0x0c -> 25 */ 305*4882a593Smuzhiyun #define IT85_ILE 0x10 /* internal loopback enable */ 306*4882a593Smuzhiyun #define IT85_ILSEL 0x20 /* internal loopback select */ 307*4882a593Smuzhiyun 308*4882a593Smuzhiyun /* C0IER bits */ 309*4882a593Smuzhiyun #define IT85_TLDLIE 0x01 /* TX low data level interrupt enable */ 310*4882a593Smuzhiyun #define IT85_RDAIE 0x02 /* RX data available interrupt enable */ 311*4882a593Smuzhiyun #define IT85_RFOIE 0x04 /* RX FIFO overrun interrupt enable */ 312*4882a593Smuzhiyun #define IT85_IEC 0x80 /* interrupt enable function control */ 313*4882a593Smuzhiyun 314*4882a593Smuzhiyun /* C0IIR bits */ 315*4882a593Smuzhiyun #define IT85_TLDLI 0x01 /* transmitter low data level interrupt */ 316*4882a593Smuzhiyun #define IT85_RDAI 0x02 /* receiver data available interrupt */ 317*4882a593Smuzhiyun #define IT85_RFOI 0x04 /* receiver FIFO overrun interrupt */ 318*4882a593Smuzhiyun #define IT85_NIP 0x80 /* no interrupt pending */ 319*4882a593Smuzhiyun 320*4882a593Smuzhiyun /* C0CFR bits */ 321*4882a593Smuzhiyun #define IT85_CFQ 0x1f /* carrier frequency mask */ 322*4882a593Smuzhiyun #define IT85_HCFS 0x20 /* high speed carrier frequency select */ 323*4882a593Smuzhiyun 324*4882a593Smuzhiyun /* C0RCR bits */ 325*4882a593Smuzhiyun #define IT85_RXDCR 0x07 /* receiver demodulation carrier range mask */ 326*4882a593Smuzhiyun #define IT85_RXACT 0x08 /* receiver active */ 327*4882a593Smuzhiyun #define IT85_RXEND 0x10 /* receiver demodulation enable */ 328*4882a593Smuzhiyun #define IT85_RDWOS 0x20 /* receiver data without sync */ 329*4882a593Smuzhiyun #define IT85_RXEN 0x80 /* receiver enable */ 330*4882a593Smuzhiyun 331*4882a593Smuzhiyun /* C0TCR bits */ 332*4882a593Smuzhiyun #define IT85_TXMPW 0x07 /* transmitter modulation pulse width mask */ 333*4882a593Smuzhiyun #define IT85_TXMPW_DEFAULT 0x04 /* default modulation pulse width */ 334*4882a593Smuzhiyun #define IT85_TXMPM 0x18 /* transmitter modulation pulse mode mask */ 335*4882a593Smuzhiyun #define IT85_TXMPM_DEFAULT 0x00 /* modulation pulse mode default */ 336*4882a593Smuzhiyun #define IT85_TXENDF 0x20 /* transmitter deferral */ 337*4882a593Smuzhiyun #define IT85_TXRLE 0x40 /* transmitter run length enable */ 338*4882a593Smuzhiyun 339*4882a593Smuzhiyun /* C0SCK bits */ 340*4882a593Smuzhiyun #define IT85_SCKS 0x01 /* slow clock select */ 341*4882a593Smuzhiyun #define IT85_TXDCKG 0x02 /* TXD clock gating */ 342*4882a593Smuzhiyun #define IT85_DLL1P8E 0x04 /* DLL 1.8432M enable */ 343*4882a593Smuzhiyun #define IT85_DLLTE 0x08 /* DLL test enable */ 344*4882a593Smuzhiyun #define IT85_BRCM 0x70 /* baud rate count mode */ 345*4882a593Smuzhiyun #define IT85_DLLOCK 0x80 /* DLL lock */ 346*4882a593Smuzhiyun 347*4882a593Smuzhiyun /* C0TFSR bits */ 348*4882a593Smuzhiyun #define IT85_TXFBC 0x3f /* transmitter FIFO count mask */ 349*4882a593Smuzhiyun 350*4882a593Smuzhiyun /* C0RFSR bits */ 351*4882a593Smuzhiyun #define IT85_RXFBC 0x3f /* receiver FIFO count mask */ 352*4882a593Smuzhiyun #define IT85_RXFTO 0x80 /* receiver FIFO time-out */ 353*4882a593Smuzhiyun 354*4882a593Smuzhiyun /* C0WCL bits */ 355*4882a593Smuzhiyun #define IT85_WCL 0x3f /* wakeup code length mask */ 356*4882a593Smuzhiyun 357*4882a593Smuzhiyun /* C0WPS bits */ 358*4882a593Smuzhiyun #define IT85_CIRPOSIE 0x01 /* power on/off status interrupt enable */ 359*4882a593Smuzhiyun #define IT85_CIRPOIS 0x02 /* power on/off interrupt status */ 360*4882a593Smuzhiyun #define IT85_CIRPOII 0x04 /* power on/off interrupt identification */ 361*4882a593Smuzhiyun #define IT85_RCRST 0x10 /* wakeup code reading counter reset bit */ 362*4882a593Smuzhiyun #define IT85_WCRST 0x20 /* wakeup code writing counter reset bit */ 363*4882a593Smuzhiyun 364*4882a593Smuzhiyun /* 365*4882a593Smuzhiyun * ITE8708 366*4882a593Smuzhiyun * 367*4882a593Smuzhiyun * Hardware data obtained from hacked driver for IT8512 in this forum post: 368*4882a593Smuzhiyun * 369*4882a593Smuzhiyun * http://ubuntuforums.org/showthread.php?t=1028640 370*4882a593Smuzhiyun * 371*4882a593Smuzhiyun * Although there's no official documentation for that driver, analysis would 372*4882a593Smuzhiyun * suggest that it maps the 16 registers of IT8512 onto two 8-register banks, 373*4882a593Smuzhiyun * selectable by a single bank-select bit that's mapped onto both banks. The 374*4882a593Smuzhiyun * IT8512 registers are mapped in a different order, so that the first bank 375*4882a593Smuzhiyun * maps the ones that are used more often, and two registers that share a 376*4882a593Smuzhiyun * reserved high-order bit are placed at the same offset in both banks in 377*4882a593Smuzhiyun * order to reuse the reserved bit as the bank select bit. 378*4882a593Smuzhiyun */ 379*4882a593Smuzhiyun 380*4882a593Smuzhiyun /* register offsets */ 381*4882a593Smuzhiyun 382*4882a593Smuzhiyun /* mapped onto both banks */ 383*4882a593Smuzhiyun #define IT8708_BANKSEL 0x07 /* bank select register */ 384*4882a593Smuzhiyun #define IT8708_HRAE 0x80 /* high registers access enable */ 385*4882a593Smuzhiyun 386*4882a593Smuzhiyun /* mapped onto the low bank */ 387*4882a593Smuzhiyun #define IT8708_C0DR 0x00 /* data register */ 388*4882a593Smuzhiyun #define IT8708_C0MSTCR 0x01 /* master control register */ 389*4882a593Smuzhiyun #define IT8708_C0IER 0x02 /* interrupt enable register */ 390*4882a593Smuzhiyun #define IT8708_C0IIR 0x03 /* interrupt identification register */ 391*4882a593Smuzhiyun #define IT8708_C0RFSR 0x04 /* receiver FIFO status register */ 392*4882a593Smuzhiyun #define IT8708_C0RCR 0x05 /* receiver control register */ 393*4882a593Smuzhiyun #define IT8708_C0TFSR 0x06 /* transmitter FIFO status register */ 394*4882a593Smuzhiyun #define IT8708_C0TCR 0x07 /* transmitter control register */ 395*4882a593Smuzhiyun 396*4882a593Smuzhiyun /* mapped onto the high bank */ 397*4882a593Smuzhiyun #define IT8708_C0BDLR 0x01 /* baud rate divisor low byte register */ 398*4882a593Smuzhiyun #define IT8708_C0BDHR 0x02 /* baud rate divisor high byte register */ 399*4882a593Smuzhiyun #define IT8708_C0CFR 0x04 /* carrier frequency register */ 400*4882a593Smuzhiyun 401*4882a593Smuzhiyun /* registers whose bank mapping we don't know, since they weren't being used 402*4882a593Smuzhiyun * in the hacked driver... most probably they belong to the high bank too, 403*4882a593Smuzhiyun * since they fit in the holes the other registers leave */ 404*4882a593Smuzhiyun #define IT8708_C0SCK 0x03 /* slow clock control register */ 405*4882a593Smuzhiyun #define IT8708_C0WCL 0x05 /* wakeup code length register */ 406*4882a593Smuzhiyun #define IT8708_C0WCR 0x06 /* wakeup code read/write register */ 407*4882a593Smuzhiyun #define IT8708_C0WPS 0x07 /* wakeup power control/status register */ 408*4882a593Smuzhiyun 409*4882a593Smuzhiyun #define IT8708_IOREG_LENGTH 0x08 /* length of register file */ 410*4882a593Smuzhiyun 411*4882a593Smuzhiyun /* two more registers that are defined in the hacked driver, but can't be 412*4882a593Smuzhiyun * found in the data sheets; no idea what they are or how they are accessed, 413*4882a593Smuzhiyun * since the hacked driver doesn't seem to use them */ 414*4882a593Smuzhiyun #define IT8708_CSCRR 0x00 415*4882a593Smuzhiyun #define IT8708_CGPINTR 0x01 416*4882a593Smuzhiyun 417*4882a593Smuzhiyun /* CSCRR bits */ 418*4882a593Smuzhiyun #define IT8708_CSCRR_SCRB 0x3f 419*4882a593Smuzhiyun #define IT8708_CSCRR_PM 0x80 420*4882a593Smuzhiyun 421*4882a593Smuzhiyun /* CGPINTR bits */ 422*4882a593Smuzhiyun #define IT8708_CGPINT 0x01 423*4882a593Smuzhiyun 424*4882a593Smuzhiyun /* 425*4882a593Smuzhiyun * ITE8709 426*4882a593Smuzhiyun * 427*4882a593Smuzhiyun * Hardware interfacing data obtained from the original lirc_ite8709 driver. 428*4882a593Smuzhiyun * Verbatim from its sources: 429*4882a593Smuzhiyun * 430*4882a593Smuzhiyun * The ITE8709 device seems to be the combination of IT8512 superIO chip and 431*4882a593Smuzhiyun * a specific firmware running on the IT8512's embedded micro-controller. 432*4882a593Smuzhiyun * In addition of the embedded micro-controller, the IT8512 chip contains a 433*4882a593Smuzhiyun * CIR module and several other modules. A few modules are directly accessible 434*4882a593Smuzhiyun * by the host CPU, but most of them are only accessible by the 435*4882a593Smuzhiyun * micro-controller. The CIR module is only accessible by the 436*4882a593Smuzhiyun * micro-controller. 437*4882a593Smuzhiyun * 438*4882a593Smuzhiyun * The battery-backed SRAM module is accessible by the host CPU and the 439*4882a593Smuzhiyun * micro-controller. So one of the MC's firmware role is to act as a bridge 440*4882a593Smuzhiyun * between the host CPU and the CIR module. The firmware implements a kind of 441*4882a593Smuzhiyun * communication protocol using the SRAM module as a shared memory. The IT8512 442*4882a593Smuzhiyun * specification is publicly available on ITE's web site, but the 443*4882a593Smuzhiyun * communication protocol is not, so it was reverse-engineered. 444*4882a593Smuzhiyun */ 445*4882a593Smuzhiyun 446*4882a593Smuzhiyun /* register offsets */ 447*4882a593Smuzhiyun #define IT8709_RAM_IDX 0x00 /* index into the SRAM module bytes */ 448*4882a593Smuzhiyun #define IT8709_RAM_VAL 0x01 /* read/write data to the indexed byte */ 449*4882a593Smuzhiyun 450*4882a593Smuzhiyun #define IT8709_IOREG_LENGTH 0x02 /* length of register file */ 451*4882a593Smuzhiyun 452*4882a593Smuzhiyun /* register offsets inside the SRAM module */ 453*4882a593Smuzhiyun #define IT8709_MODE 0x1a /* request/ack byte */ 454*4882a593Smuzhiyun #define IT8709_REG_IDX 0x1b /* index of the CIR register to access */ 455*4882a593Smuzhiyun #define IT8709_REG_VAL 0x1c /* value read/to be written */ 456*4882a593Smuzhiyun #define IT8709_IIR 0x1e /* interrupt identification register */ 457*4882a593Smuzhiyun #define IT8709_RFSR 0x1f /* receiver FIFO status register */ 458*4882a593Smuzhiyun #define IT8709_FIFO 0x20 /* start of in RAM RX FIFO copy */ 459*4882a593Smuzhiyun 460*4882a593Smuzhiyun /* MODE values */ 461*4882a593Smuzhiyun #define IT8709_IDLE 0x00 462*4882a593Smuzhiyun #define IT8709_WRITE 0x01 463*4882a593Smuzhiyun #define IT8709_READ 0x02 464