Lines Matching refs:self
127 static void sh_sir_write(struct sh_sir_self *self, u32 offset, u16 data) in sh_sir_write() argument
129 iowrite16(data, self->membase + offset); in sh_sir_write()
132 static u16 sh_sir_read(struct sh_sir_self *self, u32 offset) in sh_sir_read() argument
134 return ioread16(self->membase + offset); in sh_sir_read()
137 static void sh_sir_update_bits(struct sh_sir_self *self, u32 offset, in sh_sir_update_bits() argument
142 old = sh_sir_read(self, offset); in sh_sir_update_bits()
145 sh_sir_write(self, offset, new); in sh_sir_update_bits()
155 static void sh_sir_crc_reset(struct sh_sir_self *self) in sh_sir_crc_reset() argument
157 sh_sir_write(self, IRIF_CRC0, CRC_RST); in sh_sir_crc_reset()
160 static void sh_sir_crc_add(struct sh_sir_self *self, u8 data) in sh_sir_crc_add() argument
162 sh_sir_write(self, IRIF_CRC1, (u16)data); in sh_sir_crc_add()
165 static u16 sh_sir_crc_cnt(struct sh_sir_self *self) in sh_sir_crc_cnt() argument
167 return CRC_CT_MASK & sh_sir_read(self, IRIF_CRC0); in sh_sir_crc_cnt()
170 static u16 sh_sir_crc_out(struct sh_sir_self *self) in sh_sir_crc_out() argument
172 return sh_sir_read(self, IRIF_CRC4); in sh_sir_crc_out()
175 static int sh_sir_crc_init(struct sh_sir_self *self) in sh_sir_crc_init() argument
177 struct device *dev = &self->ndev->dev; in sh_sir_crc_init()
181 sh_sir_crc_reset(self); in sh_sir_crc_init()
183 sh_sir_crc_add(self, 0xCC); in sh_sir_crc_init()
184 sh_sir_crc_add(self, 0xF5); in sh_sir_crc_init()
185 sh_sir_crc_add(self, 0xF1); in sh_sir_crc_init()
186 sh_sir_crc_add(self, 0xA7); in sh_sir_crc_init()
188 val = sh_sir_crc_cnt(self); in sh_sir_crc_init()
194 val = sh_sir_crc_out(self); in sh_sir_crc_init()
204 sh_sir_crc_reset(self); in sh_sir_crc_init()
247 static int sh_sir_set_baudrate(struct sh_sir_self *self, u32 baudrate) in sh_sir_set_baudrate() argument
250 struct device *dev = &self->ndev->dev; in sh_sir_set_baudrate()
328 sh_sir_write(self, IRIF_SIR0, IRTPW | IRERRC); in sh_sir_set_baudrate()
329 sh_sir_write(self, IRIF_SIR1, irbca); in sh_sir_set_baudrate()
330 sh_sir_write(self, IRIF_SIR2, irbc); in sh_sir_set_baudrate()
368 sh_sir_write(self, IRIF_UART6, uabca); in sh_sir_set_baudrate()
369 sh_sir_write(self, IRIF_UART7, uabc); in sh_sir_set_baudrate()
395 static void sh_sir_remove_iobuf(struct sh_sir_self *self) in sh_sir_remove_iobuf() argument
397 kfree(self->rx_buff.head); in sh_sir_remove_iobuf()
398 kfree(self->tx_buff.head); in sh_sir_remove_iobuf()
400 self->rx_buff.head = NULL; in sh_sir_remove_iobuf()
401 self->tx_buff.head = NULL; in sh_sir_remove_iobuf()
404 static int sh_sir_init_iobuf(struct sh_sir_self *self, int rxsize, int txsize) in sh_sir_init_iobuf() argument
408 if (self->rx_buff.head || in sh_sir_init_iobuf()
409 self->tx_buff.head) { in sh_sir_init_iobuf()
410 dev_err(&self->ndev->dev, "iobuff has already existed."); in sh_sir_init_iobuf()
414 err = __sh_sir_init_iobuf(&self->rx_buff, rxsize); in sh_sir_init_iobuf()
418 err = __sh_sir_init_iobuf(&self->tx_buff, txsize); in sh_sir_init_iobuf()
422 sh_sir_remove_iobuf(self); in sh_sir_init_iobuf()
434 static void sh_sir_clear_all_err(struct sh_sir_self *self) in sh_sir_clear_all_err() argument
437 sh_sir_update_bits(self, IRIF_SIR0, IRERRC, IRERRC); in sh_sir_clear_all_err()
440 sh_sir_write(self, IRIF_SIR_FLG, 0xffff); in sh_sir_clear_all_err()
443 sh_sir_write(self, IRIF_UART_STS2, 0); in sh_sir_clear_all_err()
446 static void sh_sir_set_phase(struct sh_sir_self *self, int phase) in sh_sir_set_phase() argument
468 sh_sir_write(self, IRIF_UART5, uart5); in sh_sir_set_phase()
469 sh_sir_write(self, IRIF_UART0, uart0); in sh_sir_set_phase()
472 static int sh_sir_is_which_phase(struct sh_sir_self *self) in sh_sir_is_which_phase() argument
474 u16 val = sh_sir_read(self, IRIF_UART5); in sh_sir_is_which_phase()
488 static void sh_sir_tx(struct sh_sir_self *self, int phase) in sh_sir_tx() argument
492 if (0 >= self->tx_buff.len) { in sh_sir_tx()
493 sh_sir_set_phase(self, TX_COMP_PHASE); in sh_sir_tx()
495 sh_sir_write(self, IRIF_UART3, self->tx_buff.data[0]); in sh_sir_tx()
496 self->tx_buff.len--; in sh_sir_tx()
497 self->tx_buff.data++; in sh_sir_tx()
501 sh_sir_set_phase(self, RX_PHASE); in sh_sir_tx()
502 netif_wake_queue(self->ndev); in sh_sir_tx()
505 dev_err(&self->ndev->dev, "should not happen\n"); in sh_sir_tx()
510 static int sh_sir_read_data(struct sh_sir_self *self) in sh_sir_read_data() argument
516 val = sh_sir_read(self, IRIF_UART1); in sh_sir_read_data()
523 return (int)sh_sir_read(self, IRIF_UART4); in sh_sir_read_data()
529 dev_err(&self->ndev->dev, "UART1 %04x : STATUS %04x\n", in sh_sir_read_data()
530 val, sh_sir_read(self, IRIF_UART_STS2)); in sh_sir_read_data()
533 sh_sir_read(self, IRIF_UART4); in sh_sir_read_data()
538 static void sh_sir_rx(struct sh_sir_self *self) in sh_sir_rx() argument
544 data = sh_sir_read_data(self); in sh_sir_rx()
548 async_unwrap_char(self->ndev, &self->ndev->stats, in sh_sir_rx()
549 &self->rx_buff, (u8)data); in sh_sir_rx()
550 self->ndev->last_rx = jiffies; in sh_sir_rx()
552 if (EOFD & sh_sir_read(self, IRIF_SIR_FRM)) in sh_sir_rx()
561 struct sh_sir_self *self = dev_id; in sh_sir_irq() local
562 struct device *dev = &self->ndev->dev; in sh_sir_irq()
563 int phase = sh_sir_is_which_phase(self); in sh_sir_irq()
568 sh_sir_tx(self, phase); in sh_sir_irq()
571 if (sh_sir_read(self, IRIF_SIR3)) in sh_sir_irq()
574 sh_sir_rx(self); in sh_sir_irq()
575 sh_sir_clear_all_err(self); in sh_sir_irq()
593 struct sh_sir_self *self = netdev_priv(ndev); in sh_sir_hard_xmit() local
604 self->tx_buff.data = self->tx_buff.head; in sh_sir_hard_xmit()
605 self->tx_buff.len = 0; in sh_sir_hard_xmit()
607 self->tx_buff.len = async_wrap_skb(skb, self->tx_buff.data, in sh_sir_hard_xmit()
608 self->tx_buff.truesize); in sh_sir_hard_xmit()
610 sh_sir_set_phase(self, TX_PHASE); in sh_sir_hard_xmit()
629 struct sh_sir_self *self = netdev_priv(ndev); in sh_sir_stats() local
631 return &self->ndev->stats; in sh_sir_stats()
636 struct sh_sir_self *self = netdev_priv(ndev); in sh_sir_open() local
639 clk_enable(self->clk); in sh_sir_open()
640 err = sh_sir_crc_init(self); in sh_sir_open()
644 sh_sir_set_baudrate(self, 9600); in sh_sir_open()
646 self->irlap = irlap_open(ndev, &self->qos, DRIVER_NAME); in sh_sir_open()
647 if (!self->irlap) { in sh_sir_open()
655 sh_sir_update_bits(self, IRIF_SIR_FRM, FRP, FRP); in sh_sir_open()
656 sh_sir_read(self, IRIF_UART1); /* flag clear */ in sh_sir_open()
657 sh_sir_read(self, IRIF_UART4); /* flag clear */ in sh_sir_open()
658 sh_sir_set_phase(self, RX_PHASE); in sh_sir_open()
662 dev_info(&self->ndev->dev, "opened\n"); in sh_sir_open()
667 clk_disable(self->clk); in sh_sir_open()
674 struct sh_sir_self *self = netdev_priv(ndev); in sh_sir_stop() local
677 if (self->irlap) { in sh_sir_stop()
678 irlap_close(self->irlap); in sh_sir_stop()
679 self->irlap = NULL; in sh_sir_stop()
707 struct sh_sir_self *self; in sh_sir_probe() local
720 ndev = alloc_irdadev(sizeof(*self)); in sh_sir_probe()
724 self = netdev_priv(ndev); in sh_sir_probe()
725 self->membase = ioremap_nocache(res->start, resource_size(res)); in sh_sir_probe()
726 if (!self->membase) { in sh_sir_probe()
732 err = sh_sir_init_iobuf(self, IRDA_SKB_MAX_MTU, IRDA_SIR_MAX_FRAME); in sh_sir_probe()
737 self->clk = clk_get(&pdev->dev, clk_name); in sh_sir_probe()
738 if (IS_ERR(self->clk)) { in sh_sir_probe()
744 irda_init_max_qos_capabilies(&self->qos); in sh_sir_probe()
749 self->ndev = ndev; in sh_sir_probe()
750 self->qos.baud_rate.bits &= IR_9600; /* FIXME */ in sh_sir_probe()
751 self->qos.min_turn_time.bits = 1; /* 10 ms or more */ in sh_sir_probe()
753 irda_qos_bits_to_value(&self->qos); in sh_sir_probe()
760 err = devm_request_irq(&pdev->dev, irq, sh_sir_irq, 0, "sh_sir", self); in sh_sir_probe()
771 clk_put(self->clk); in sh_sir_probe()
773 sh_sir_remove_iobuf(self); in sh_sir_probe()
775 iounmap(self->membase); in sh_sir_probe()
785 struct sh_sir_self *self = netdev_priv(ndev); in sh_sir_remove() local
787 if (!self) in sh_sir_remove()
791 clk_put(self->clk); in sh_sir_remove()
792 sh_sir_remove_iobuf(self); in sh_sir_remove()
793 iounmap(self->membase); in sh_sir_remove()