Lines Matching full:ks
30 * @ks: The chip state
35 static void ks8851_lock(struct ks8851_net *ks, unsigned long *flags) in ks8851_lock() argument
37 ks->lock(ks, flags); in ks8851_lock()
42 * @ks: The chip state
47 static void ks8851_unlock(struct ks8851_net *ks, unsigned long *flags) in ks8851_unlock() argument
49 ks->unlock(ks, flags); in ks8851_unlock()
54 * @ks: The chip state
60 static void ks8851_wrreg16(struct ks8851_net *ks, unsigned int reg, in ks8851_wrreg16() argument
63 ks->wrreg16(ks, reg, val); in ks8851_wrreg16()
68 * @ks: The chip information
73 static unsigned int ks8851_rdreg16(struct ks8851_net *ks, in ks8851_rdreg16() argument
76 return ks->rdreg16(ks, reg); in ks8851_rdreg16()
81 * @ks: The device state.
92 static void ks8851_soft_reset(struct ks8851_net *ks, unsigned op) in ks8851_soft_reset() argument
94 ks8851_wrreg16(ks, KS_GRR, op); in ks8851_soft_reset()
96 ks8851_wrreg16(ks, KS_GRR, 0); in ks8851_soft_reset()
102 * @ks: The device state
107 static void ks8851_set_powermode(struct ks8851_net *ks, unsigned pwrmode) in ks8851_set_powermode() argument
111 netif_dbg(ks, hw, ks->netdev, "setting power mode %d\n", pwrmode); in ks8851_set_powermode()
113 pmecr = ks8851_rdreg16(ks, KS_PMECR); in ks8851_set_powermode()
117 ks8851_wrreg16(ks, KS_PMECR, pmecr); in ks8851_set_powermode()
131 struct ks8851_net *ks = netdev_priv(dev); in ks8851_write_mac_addr() local
136 ks8851_lock(ks, &flags); in ks8851_write_mac_addr()
142 ks8851_set_powermode(ks, PMECR_PM_NORMAL); in ks8851_write_mac_addr()
146 ks8851_wrreg16(ks, KS_MAR(i), val); in ks8851_write_mac_addr()
150 ks8851_set_powermode(ks, PMECR_PM_SOFTDOWN); in ks8851_write_mac_addr()
152 ks8851_unlock(ks, &flags); in ks8851_write_mac_addr()
165 struct ks8851_net *ks = netdev_priv(dev); in ks8851_read_mac_addr() local
171 ks8851_lock(ks, &flags); in ks8851_read_mac_addr()
174 reg = ks8851_rdreg16(ks, KS_MAR(i)); in ks8851_read_mac_addr()
180 ks8851_unlock(ks, &flags); in ks8851_read_mac_addr()
185 * @ks: The device structure
194 static void ks8851_init_mac(struct ks8851_net *ks, struct device_node *np) in ks8851_init_mac() argument
196 struct net_device *dev = ks->netdev; in ks8851_init_mac()
205 if (ks->rc_ccr & CCR_EEPROM) { in ks8851_init_mac()
210 netdev_err(ks->netdev, "invalid mac address read %pM\n", in ks8851_init_mac()
220 * @ks: The device state
225 static void ks8851_dbg_dumpkkt(struct ks8851_net *ks, u8 *rxpkt) in ks8851_dbg_dumpkkt() argument
227 netdev_dbg(ks->netdev, in ks8851_dbg_dumpkkt()
236 * @ks: The device information.
243 static void ks8851_rx_pkts(struct ks8851_net *ks, struct sk_buff_head *rxq) in ks8851_rx_pkts() argument
251 rxfc = (ks8851_rdreg16(ks, KS_RXFCTR) >> 8) & 0xff; in ks8851_rx_pkts()
253 netif_dbg(ks, rx_status, ks->netdev, in ks8851_rx_pkts()
267 rxstat = ks8851_rdreg16(ks, KS_RXFHSR); in ks8851_rx_pkts()
268 rxlen = ks8851_rdreg16(ks, KS_RXFHBCR) & RXFHBCR_CNT_MASK; in ks8851_rx_pkts()
270 netif_dbg(ks, rx_status, ks->netdev, in ks8851_rx_pkts()
276 ks8851_wrreg16(ks, KS_RXFDPR, RXFDPR_RXFPAI | 0x00); in ks8851_rx_pkts()
279 ks8851_wrreg16(ks, KS_RXQCR, ks->rc_rxqcr | RXQCR_SDA); in ks8851_rx_pkts()
286 skb = netdev_alloc_skb_ip_align(ks->netdev, rxalign); in ks8851_rx_pkts()
297 ks->rdfifo(ks, rxpkt, rxalign + 8); in ks8851_rx_pkts()
299 if (netif_msg_pktdata(ks)) in ks8851_rx_pkts()
300 ks8851_dbg_dumpkkt(ks, rxpkt); in ks8851_rx_pkts()
302 skb->protocol = eth_type_trans(skb, ks->netdev); in ks8851_rx_pkts()
305 ks->netdev->stats.rx_packets++; in ks8851_rx_pkts()
306 ks->netdev->stats.rx_bytes += rxlen; in ks8851_rx_pkts()
311 ks8851_wrreg16(ks, KS_RXQCR, ks->rc_rxqcr | RXQCR_RRXEF); in ks8851_rx_pkts()
329 struct ks8851_net *ks = _ks; in ks8851_irq() local
335 ks8851_lock(ks, &flags); in ks8851_irq()
337 status = ks8851_rdreg16(ks, KS_ISR); in ks8851_irq()
338 ks8851_wrreg16(ks, KS_ISR, status); in ks8851_irq()
340 netif_dbg(ks, intr, ks->netdev, in ks8851_irq()
344 u16 pmecr = ks8851_rdreg16(ks, KS_PMECR); in ks8851_irq()
346 ks8851_wrreg16(ks, KS_PMECR, pmecr | PMECR_WKEVT_LINK); in ks8851_irq()
350 unsigned short tx_space = ks8851_rdreg16(ks, KS_TXMIR); in ks8851_irq()
352 netif_dbg(ks, intr, ks->netdev, in ks8851_irq()
355 spin_lock_bh(&ks->statelock); in ks8851_irq()
356 ks->tx_space = tx_space; in ks8851_irq()
357 if (netif_queue_stopped(ks->netdev)) in ks8851_irq()
358 netif_wake_queue(ks->netdev); in ks8851_irq()
359 spin_unlock_bh(&ks->statelock); in ks8851_irq()
363 netdev_err(ks->netdev, "%s: spi bus error\n", __func__); in ks8851_irq()
373 ks8851_rx_pkts(ks, &rxq); in ks8851_irq()
380 struct ks8851_rxctrl *rxc = &ks->rxctrl; in ks8851_irq()
383 ks8851_wrreg16(ks, KS_MAHTR0, rxc->mchash[0]); in ks8851_irq()
384 ks8851_wrreg16(ks, KS_MAHTR1, rxc->mchash[1]); in ks8851_irq()
385 ks8851_wrreg16(ks, KS_MAHTR2, rxc->mchash[2]); in ks8851_irq()
386 ks8851_wrreg16(ks, KS_MAHTR3, rxc->mchash[3]); in ks8851_irq()
388 ks8851_wrreg16(ks, KS_RXCR2, rxc->rxcr2); in ks8851_irq()
389 ks8851_wrreg16(ks, KS_RXCR1, rxc->rxcr1); in ks8851_irq()
392 ks8851_unlock(ks, &flags); in ks8851_irq()
395 mii_check_link(&ks->mii); in ks8851_irq()
406 * @ks: The device state
408 static void ks8851_flush_tx_work(struct ks8851_net *ks) in ks8851_flush_tx_work() argument
410 if (ks->flush_tx_work) in ks8851_flush_tx_work()
411 ks->flush_tx_work(ks); in ks8851_flush_tx_work()
423 struct ks8851_net *ks = netdev_priv(dev); in ks8851_net_open() local
429 dev->name, ks); in ks8851_net_open()
437 ks8851_lock(ks, &flags); in ks8851_net_open()
439 netif_dbg(ks, ifup, ks->netdev, "opening\n"); in ks8851_net_open()
442 ks8851_set_powermode(ks, PMECR_PM_NORMAL); in ks8851_net_open()
446 ks8851_soft_reset(ks, GRR_QMU); in ks8851_net_open()
450 ks8851_wrreg16(ks, KS_TXCR, (TXCR_TXE | /* enable transmit process */ in ks8851_net_open()
456 ks8851_wrreg16(ks, KS_TXFDPR, TXFDPR_TXFPAI); in ks8851_net_open()
460 ks8851_wrreg16(ks, KS_RXCR1, (RXCR1_RXPAFMA | /* from mac filter */ in ks8851_net_open()
467 ks8851_wrreg16(ks, KS_RXCR2, RXCR2_SRDBL_FRAME); in ks8851_net_open()
470 ks8851_wrreg16(ks, KS_RXDTTR, 1000); /* 1ms after first frame to IRQ */ in ks8851_net_open()
471 ks8851_wrreg16(ks, KS_RXDBCTR, 4096); /* >4Kbytes in buffer to IRQ */ in ks8851_net_open()
472 ks8851_wrreg16(ks, KS_RXFCTR, 10); /* 10 frames to IRQ */ in ks8851_net_open()
474 ks->rc_rxqcr = (RXQCR_RXFCTE | /* IRQ on frame count exceeded */ in ks8851_net_open()
478 ks8851_wrreg16(ks, KS_RXQCR, ks->rc_rxqcr); in ks8851_net_open()
481 ks8851_wrreg16(ks, KS_ISR, ks->rc_ier); in ks8851_net_open()
482 ks8851_wrreg16(ks, KS_IER, ks->rc_ier); in ks8851_net_open()
484 ks->queued_len = 0; in ks8851_net_open()
485 ks->tx_space = ks8851_rdreg16(ks, KS_TXMIR); in ks8851_net_open()
486 netif_start_queue(ks->netdev); in ks8851_net_open()
488 netif_dbg(ks, ifup, ks->netdev, "network device up\n"); in ks8851_net_open()
490 ks8851_unlock(ks, &flags); in ks8851_net_open()
491 mii_check_link(&ks->mii); in ks8851_net_open()
505 struct ks8851_net *ks = netdev_priv(dev); in ks8851_net_stop() local
508 netif_info(ks, ifdown, dev, "shutting down\n"); in ks8851_net_stop()
512 ks8851_lock(ks, &flags); in ks8851_net_stop()
514 ks8851_wrreg16(ks, KS_IER, 0x0000); in ks8851_net_stop()
515 ks8851_wrreg16(ks, KS_ISR, 0xffff); in ks8851_net_stop()
516 ks8851_unlock(ks, &flags); in ks8851_net_stop()
519 ks8851_flush_tx_work(ks); in ks8851_net_stop()
520 flush_work(&ks->rxctrl_work); in ks8851_net_stop()
522 ks8851_lock(ks, &flags); in ks8851_net_stop()
524 ks8851_wrreg16(ks, KS_RXCR1, 0x0000); in ks8851_net_stop()
527 ks8851_wrreg16(ks, KS_TXCR, 0x0000); in ks8851_net_stop()
530 ks8851_set_powermode(ks, PMECR_PM_SOFTDOWN); in ks8851_net_stop()
531 ks8851_unlock(ks, &flags); in ks8851_net_stop()
534 while (!skb_queue_empty(&ks->txq)) { in ks8851_net_stop()
535 struct sk_buff *txb = skb_dequeue(&ks->txq); in ks8851_net_stop()
537 netif_dbg(ks, ifdown, ks->netdev, in ks8851_net_stop()
543 free_irq(dev->irq, ks); in ks8851_net_stop()
564 struct ks8851_net *ks = netdev_priv(dev); in ks8851_start_xmit() local
566 return ks->start_xmit(skb, dev); in ks8851_start_xmit()
584 struct ks8851_net *ks = container_of(work, struct ks8851_net, rxctrl_work); in ks8851_rxctrl_work() local
587 ks8851_lock(ks, &flags); in ks8851_rxctrl_work()
590 ks8851_wrreg16(ks, KS_RXCR1, 0x00); in ks8851_rxctrl_work()
592 ks8851_unlock(ks, &flags); in ks8851_rxctrl_work()
597 struct ks8851_net *ks = netdev_priv(dev); in ks8851_set_rx_mode() local
639 spin_lock_bh(&ks->statelock); in ks8851_set_rx_mode()
641 if (memcmp(&rxctrl, &ks->rxctrl, sizeof(rxctrl)) != 0) { in ks8851_set_rx_mode()
642 memcpy(&ks->rxctrl, &rxctrl, sizeof(ks->rxctrl)); in ks8851_set_rx_mode()
643 schedule_work(&ks->rxctrl_work); in ks8851_set_rx_mode()
646 spin_unlock_bh(&ks->statelock); in ks8851_set_rx_mode()
665 struct ks8851_net *ks = netdev_priv(dev); in ks8851_net_ioctl() local
670 return generic_mii_ioctl(&ks->mii, if_mii(req), cmd, NULL); in ks8851_net_ioctl()
695 struct ks8851_net *ks = netdev_priv(dev); in ks8851_get_msglevel() local
696 return ks->msg_enable; in ks8851_get_msglevel()
701 struct ks8851_net *ks = netdev_priv(dev); in ks8851_set_msglevel() local
702 ks->msg_enable = to; in ks8851_set_msglevel()
708 struct ks8851_net *ks = netdev_priv(dev); in ks8851_get_link_ksettings() local
710 mii_ethtool_get_link_ksettings(&ks->mii, cmd); in ks8851_get_link_ksettings()
718 struct ks8851_net *ks = netdev_priv(dev); in ks8851_set_link_ksettings() local
719 return mii_ethtool_set_link_ksettings(&ks->mii, cmd); in ks8851_set_link_ksettings()
724 struct ks8851_net *ks = netdev_priv(dev); in ks8851_get_link() local
725 return mii_link_ok(&ks->mii); in ks8851_get_link()
730 struct ks8851_net *ks = netdev_priv(dev); in ks8851_nway_reset() local
731 return mii_nway_restart(&ks->mii); in ks8851_nway_reset()
738 struct ks8851_net *ks = ee->data; in ks8851_eeprom_regread() local
741 val = ks8851_rdreg16(ks, KS_EEPCR); in ks8851_eeprom_regread()
750 struct ks8851_net *ks = ee->data; in ks8851_eeprom_regwrite() local
762 ks8851_wrreg16(ks, KS_EEPCR, val); in ks8851_eeprom_regwrite()
767 * @ks: The network device state.
772 static int ks8851_eeprom_claim(struct ks8851_net *ks) in ks8851_eeprom_claim() argument
775 ks8851_wrreg16(ks, KS_EEPCR, EEPCR_EESA | EEPCR_EECS); in ks8851_eeprom_claim()
781 * @ks: The device state
785 static void ks8851_eeprom_release(struct ks8851_net *ks) in ks8851_eeprom_release() argument
787 unsigned val = ks8851_rdreg16(ks, KS_EEPCR); in ks8851_eeprom_release()
789 ks8851_wrreg16(ks, KS_EEPCR, val & ~EEPCR_EESA); in ks8851_eeprom_release()
797 struct ks8851_net *ks = netdev_priv(dev); in ks8851_set_eeprom() local
810 if (!(ks->rc_ccr & CCR_EEPROM)) in ks8851_set_eeprom()
813 ks8851_lock(ks, &flags); in ks8851_set_eeprom()
815 ks8851_eeprom_claim(ks); in ks8851_set_eeprom()
817 eeprom_93cx6_wren(&ks->eeprom, true); in ks8851_set_eeprom()
822 eeprom_93cx6_read(&ks->eeprom, offset/2, &tmp); in ks8851_set_eeprom()
832 eeprom_93cx6_write(&ks->eeprom, offset/2, tmp); in ks8851_set_eeprom()
833 eeprom_93cx6_wren(&ks->eeprom, false); in ks8851_set_eeprom()
835 ks8851_eeprom_release(ks); in ks8851_set_eeprom()
836 ks8851_unlock(ks, &flags); in ks8851_set_eeprom()
844 struct ks8851_net *ks = netdev_priv(dev); in ks8851_get_eeprom() local
853 if (!(ks->rc_ccr & CCR_EEPROM)) in ks8851_get_eeprom()
856 ks8851_lock(ks, &flags); in ks8851_get_eeprom()
858 ks8851_eeprom_claim(ks); in ks8851_get_eeprom()
862 eeprom_93cx6_multiread(&ks->eeprom, offset/2, (__le16 *)data, len/2); in ks8851_get_eeprom()
863 ks8851_eeprom_release(ks); in ks8851_get_eeprom()
864 ks8851_unlock(ks, &flags); in ks8851_get_eeprom()
871 struct ks8851_net *ks = netdev_priv(dev); in ks8851_get_eeprom_len() local
874 return ks->rc_ccr & CCR_EEPROM ? 128 : 0; in ks8851_get_eeprom_len()
922 struct ks8851_net *ks = netdev_priv(dev); in ks8851_phy_read_common() local
931 ks8851_lock(ks, &flags); in ks8851_phy_read_common()
932 result = ks8851_rdreg16(ks, ksreg); in ks8851_phy_read_common()
933 ks8851_unlock(ks, &flags); in ks8851_phy_read_common()
967 struct ks8851_net *ks = netdev_priv(dev); in ks8851_phy_write() local
973 ks8851_lock(ks, &flags); in ks8851_phy_write()
974 ks8851_wrreg16(ks, ksreg, value); in ks8851_phy_write()
975 ks8851_unlock(ks, &flags); in ks8851_phy_write()
981 struct ks8851_net *ks = bus->priv; in ks8851_mdio_read() local
992 return ks8851_phy_read_common(ks->netdev, phy_id, reg); in ks8851_mdio_read()
997 struct ks8851_net *ks = bus->priv; in ks8851_mdio_write() local
999 ks8851_phy_write(ks->netdev, phy_id, reg, val); in ks8851_mdio_write()
1005 * @ks: The device state
1009 static void ks8851_read_selftest(struct ks8851_net *ks) in ks8851_read_selftest() argument
1014 rd = ks8851_rdreg16(ks, KS_MBIR); in ks8851_read_selftest()
1017 netdev_warn(ks->netdev, "Memory selftest not finished\n"); in ks8851_read_selftest()
1022 netdev_err(ks->netdev, "TX memory selftest fail\n"); in ks8851_read_selftest()
1025 netdev_err(ks->netdev, "RX memory selftest fail\n"); in ks8851_read_selftest()
1034 struct ks8851_net *ks = dev_get_drvdata(dev); in ks8851_suspend() local
1035 struct net_device *netdev = ks->netdev; in ks8851_suspend()
1048 struct ks8851_net *ks = dev_get_drvdata(dev); in ks8851_resume() local
1049 struct net_device *netdev = ks->netdev; in ks8851_resume()
1061 static int ks8851_register_mdiobus(struct ks8851_net *ks, struct device *dev) in ks8851_register_mdiobus() argument
1073 mii_bus->priv = ks; in ks8851_register_mdiobus()
1082 ks->mii_bus = mii_bus; in ks8851_register_mdiobus()
1091 static void ks8851_unregister_mdiobus(struct ks8851_net *ks) in ks8851_unregister_mdiobus() argument
1093 mdiobus_unregister(ks->mii_bus); in ks8851_unregister_mdiobus()
1094 mdiobus_free(ks->mii_bus); in ks8851_unregister_mdiobus()
1100 struct ks8851_net *ks = netdev_priv(netdev); in ks8851_probe_common() local
1104 ks->netdev = netdev; in ks8851_probe_common()
1106 ks->gpio = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_HIGH); in ks8851_probe_common()
1107 ret = PTR_ERR_OR_ZERO(ks->gpio); in ks8851_probe_common()
1114 ret = gpiod_set_consumer_name(ks->gpio, "ks8851_rst_n"); in ks8851_probe_common()
1120 ks->vdd_io = devm_regulator_get(dev, "vdd-io"); in ks8851_probe_common()
1121 if (IS_ERR(ks->vdd_io)) { in ks8851_probe_common()
1122 ret = PTR_ERR(ks->vdd_io); in ks8851_probe_common()
1126 ret = regulator_enable(ks->vdd_io); in ks8851_probe_common()
1132 ks->vdd_reg = devm_regulator_get(dev, "vdd"); in ks8851_probe_common()
1133 if (IS_ERR(ks->vdd_reg)) { in ks8851_probe_common()
1134 ret = PTR_ERR(ks->vdd_reg); in ks8851_probe_common()
1138 ret = regulator_enable(ks->vdd_reg); in ks8851_probe_common()
1144 if (ks->gpio) { in ks8851_probe_common()
1146 gpiod_set_value_cansleep(ks->gpio, 0); in ks8851_probe_common()
1149 spin_lock_init(&ks->statelock); in ks8851_probe_common()
1151 INIT_WORK(&ks->rxctrl_work, ks8851_rxctrl_work); in ks8851_probe_common()
1156 ks->eeprom.data = ks; in ks8851_probe_common()
1157 ks->eeprom.width = PCI_EEPROM_WIDTH_93C46; in ks8851_probe_common()
1158 ks->eeprom.register_read = ks8851_eeprom_regread; in ks8851_probe_common()
1159 ks->eeprom.register_write = ks8851_eeprom_regwrite; in ks8851_probe_common()
1162 ks->mii.dev = netdev; in ks8851_probe_common()
1163 ks->mii.phy_id = 1; in ks8851_probe_common()
1164 ks->mii.phy_id_mask = 1; in ks8851_probe_common()
1165 ks->mii.reg_num_mask = 0xf; in ks8851_probe_common()
1166 ks->mii.mdio_read = ks8851_phy_read; in ks8851_probe_common()
1167 ks->mii.mdio_write = ks8851_phy_write; in ks8851_probe_common()
1171 ret = ks8851_register_mdiobus(ks, dev); in ks8851_probe_common()
1176 ks->msg_enable = netif_msg_init(msg_en, NETIF_MSG_DRV | in ks8851_probe_common()
1180 skb_queue_head_init(&ks->txq); in ks8851_probe_common()
1184 dev_set_drvdata(dev, ks); in ks8851_probe_common()
1186 netif_carrier_off(ks->netdev); in ks8851_probe_common()
1191 ks8851_soft_reset(ks, GRR_GSR); in ks8851_probe_common()
1194 cider = ks8851_rdreg16(ks, KS_CIDER); in ks8851_probe_common()
1202 ks->rc_ccr = ks8851_rdreg16(ks, KS_CCR); in ks8851_probe_common()
1204 ks8851_read_selftest(ks); in ks8851_probe_common()
1205 ks8851_init_mac(ks, dev->of_node); in ks8851_probe_common()
1215 ks->rc_ccr & CCR_EEPROM ? "has" : "no"); in ks8851_probe_common()
1220 ks8851_unregister_mdiobus(ks); in ks8851_probe_common()
1222 if (ks->gpio) in ks8851_probe_common()
1223 gpiod_set_value_cansleep(ks->gpio, 1); in ks8851_probe_common()
1224 regulator_disable(ks->vdd_reg); in ks8851_probe_common()
1226 regulator_disable(ks->vdd_io); in ks8851_probe_common()