/* initialize the hardware */ static void it8709_init_hardware(struct ite_dev *dev) { ite_dbg("%s called", __func__); /* disable all the interrupts */ it8709_wr(dev, it8709_rr(dev, IT85_C0IER) & ~(IT85_IEC | IT85_RFOIE | IT85_RDAIE | IT85_TLDLIE), IT85_C0IER); /* program the baud rate divisor */ it8709_wr(dev, ITE_BAUDRATE_DIVISOR & 0xff, IT85_C0BDLR); it8709_wr(dev, (ITE_BAUDRATE_DIVISOR >> 8) & 0xff, IT85_C0BDHR); /* program the C0MSTCR register defaults */ it8709_wr(dev, (it8709_rr(dev, IT85_C0MSTCR) & ~(IT85_ILSEL | IT85_ILE | IT85_FIFOTL | IT85_FIFOCLR | IT85_RESET)) | IT85_FIFOTL_DEFAULT, IT85_C0MSTCR); /* program the C0RCR register defaults */ it8709_wr(dev, (it8709_rr(dev, IT85_C0RCR) & ~(IT85_RXEN | IT85_RDWOS | IT85_RXEND | IT85_RXACT | IT85_RXDCR)) | ITE_RXDCR_DEFAULT, IT85_C0RCR); /* program the C0TCR register defaults */ it8709_wr(dev, (it8709_rr(dev, IT85_C0TCR) & ~(IT85_TXMPM | IT85_TXMPW)) | IT85_TXRLE | IT85_TXENDF | IT85_TXMPM_DEFAULT | IT85_TXMPW_DEFAULT, IT85_C0TCR); /* program the carrier parameters */ ite_set_carrier_params(dev); }
/* set the carrier parameters; to be called with the spinlock held */ static void it8709_set_carrier_params(struct ite_dev *dev, bool high_freq, bool use_demodulator, u8 carrier_freq_bits, u8 allowance_bits, u8 pulse_width_bits) { u8 val; ite_dbg("%s called", __func__); val = (it8709_rr(dev, IT85_C0CFR) &~(IT85_HCFS | IT85_CFQ)) | carrier_freq_bits; if (high_freq) val |= IT85_HCFS; it8709_wr(dev, val, IT85_C0CFR); /* program the C0RCR register */ val = it8709_rr(dev, IT85_C0RCR) & ~(IT85_RXEND | IT85_RXDCR); if (use_demodulator) val |= IT85_RXEND; val |= allowance_bits; it8709_wr(dev, val, IT85_C0RCR); /* program the C0TCR register */ val = it8709_rr(dev, IT85_C0TCR) & ~IT85_TXMPW; val |= pulse_width_bits; it8709_wr(dev, val, IT85_C0TCR); }
static void it8709_init_hardware(struct ite_dev *dev) { ite_dbg("%s called", __func__); it8709_wr(dev, it8709_rr(dev, IT85_C0IER) & ~(IT85_IEC | IT85_RFOIE | IT85_RDAIE | IT85_TLDLIE), IT85_C0IER); it8709_wr(dev, ITE_BAUDRATE_DIVISOR & 0xff, IT85_C0BDLR); it8709_wr(dev, (ITE_BAUDRATE_DIVISOR >> 8) & 0xff, IT85_C0BDHR); it8709_wr(dev, (it8709_rr(dev, IT85_C0MSTCR) & ~(IT85_ILSEL | IT85_ILE | IT85_FIFOTL | IT85_FIFOCLR | IT85_RESET)) | IT85_FIFOTL_DEFAULT, IT85_C0MSTCR); it8709_wr(dev, (it8709_rr(dev, IT85_C0RCR) & ~(IT85_RXEN | IT85_RDWOS | IT85_RXEND | IT85_RXACT | IT85_RXDCR)) | ITE_RXDCR_DEFAULT, IT85_C0RCR); it8709_wr(dev, (it8709_rr(dev, IT85_C0TCR) & ~(IT85_TXMPM | IT85_TXMPW)) | IT85_TXRLE | IT85_TXENDF | IT85_TXMPM_DEFAULT | IT85_TXMPW_DEFAULT, IT85_C0TCR); ite_set_carrier_params(dev); }
/* idle the receiver so that we won't receive samples until another pulse is detected; this must be called with the device spinlock held */ static void it8709_idle_rx(struct ite_dev *dev) { ite_dbg("%s called", __func__); /* disable streaming by clearing RXACT writing it as 1 */ it8709_wr(dev, it8709_rr(dev, IT85_C0RCR) | IT85_RXACT, IT85_C0RCR); /* clear the FIFO */ it8709_wr(dev, it8709_rr(dev, IT85_C0MSTCR) | IT85_FIFOCLR, IT85_C0MSTCR); }
static void it8709_idle_rx(struct ite_dev *dev) { ite_dbg("%s called", __func__); it8709_wr(dev, it8709_rr(dev, IT85_C0RCR) | IT85_RXACT, IT85_C0RCR); it8709_wr(dev, it8709_rr(dev, IT85_C0MSTCR) | IT85_FIFOCLR, IT85_C0MSTCR); }
static void it8709_disable_rx(struct ite_dev *dev) { ite_dbg("%s called", __func__); it8709_wr(dev, it8709_rr(dev, IT85_C0IER) & ~(IT85_RDAIE | IT85_RFOIE), IT85_C0IER); it8709_wr(dev, it8709_rr(dev, IT85_C0RCR) & ~IT85_RXEN, IT85_C0RCR); it8709_idle_rx(dev); }
/* disable the device; this must be called with the device spinlock held */ static void it8709_disable(struct ite_dev *dev) { ite_dbg("%s called", __func__); /* clear out all interrupt enable flags */ it8709_wr(dev, it8709_rr(dev, IT85_C0IER) & ~(IT85_IEC | IT85_RFOIE | IT85_RDAIE | IT85_TLDLIE), IT85_C0IER); /* disable the receiver */ it8709_disable_rx(dev); /* erase the FIFO */ it8709_wr(dev, IT85_FIFOCLR | it8709_rr(dev, IT85_C0MSTCR), IT85_C0MSTCR); }
/* enable the receiver; this must be called with the device spinlock held */ static void it8709_enable_rx(struct ite_dev *dev) { ite_dbg("%s called", __func__); /* enable the receiver by setting RXEN */ it8709_wr(dev, it8709_rr(dev, IT85_C0RCR) | IT85_RXEN, IT85_C0RCR); /* just prepare it to idle for the next reception */ it8709_idle_rx(dev); /* enable the receiver interrupts and master enable flag */ it8709_wr(dev, it8709_rr(dev, IT85_C0IER) |IT85_RDAIE | IT85_RFOIE | IT85_IEC, IT85_C0IER); }
static void it8709_disable(struct ite_dev *dev) { ite_dbg("%s called", __func__); it8709_wr(dev, it8709_rr(dev, IT85_C0IER) & ~(IT85_IEC | IT85_RFOIE | IT85_RDAIE | IT85_TLDLIE), IT85_C0IER); it8709_disable_rx(dev); it8709_wr(dev, IT85_FIFOCLR | it8709_rr(dev, IT85_C0MSTCR), IT85_C0MSTCR); }
/* disable the transmitter interrupt; this must be called with the device * spinlock held */ static void it8709_disable_tx_interrupt(struct ite_dev *dev) { ite_dbg("%s called", __func__); /* disable the transmitter interrupts */ it8709_wr(dev, it8709_rr(dev, IT85_C0IER) & ~IT85_TLDLIE, IT85_C0IER); }
/* disable the receiver; this must be called with the device spinlock held */ static void it8709_disable_rx(struct ite_dev *dev) { ite_dbg("%s called", __func__); /* disable the receiver interrupts */ it8709_wr(dev, it8709_rr(dev, IT85_C0IER) & ~(IT85_RDAIE | IT85_RFOIE), IT85_C0IER); /* disable the receiver */ it8709_wr(dev, it8709_rr(dev, IT85_C0RCR) & ~IT85_RXEN, IT85_C0RCR); /* clear the FIFO and RXACT (actually RXACT should have been cleared * in the previous it8709_wr(dev, ) call) */ it8709_idle_rx(dev); }
/* enable the transmitter interrupt; this must be called with the device * spinlock held */ static void it8709_enable_tx_interrupt(struct ite_dev *dev) { ite_dbg("%s called", __func__); /* enable the transmitter interrupts and master enable flag */ it8709_wr(dev, it8709_rr(dev, IT85_C0IER) |IT85_TLDLIE | IT85_IEC, IT85_C0IER); }
static void it8709_enable_tx_interrupt(struct ite_dev *dev) { ite_dbg("%s called", __func__); it8709_wr(dev, it8709_rr(dev, IT85_C0IER) |IT85_TLDLIE | IT85_IEC, IT85_C0IER); }
/* return how many bytes are still in the FIFO; this will be called * with the device spinlock NOT HELD while waiting for the TX FIFO to get * empty; let's expect this won't be a problem */ static int it8709_get_tx_used_slots(struct ite_dev *dev) { ite_dbg("%s called", __func__); return it8709_rr(dev, IT85_C0TFSR) & IT85_TXFBC; }